Starting to rework slot instructions that create risc
have to go through all and all macros and all thems tests. What did the wise man say: one step at a time
This commit is contained in:
@ -40,11 +40,9 @@ module SlotMachine
|
||||
#TODO transfer the Number of arguments to :arguments_given (to be checked on entry)
|
||||
arg_target = [:message , :next_message ]
|
||||
@arguments.each_with_index do |arg , index| # +1 because of type
|
||||
compiler.reset_regs
|
||||
load = SlotMachine::SlotLoad.new(self.source, arg_target + ["arg#{index+1}".to_sym] , arg)
|
||||
load.to_risc(compiler)
|
||||
end
|
||||
compiler.reset_regs
|
||||
transfer
|
||||
end
|
||||
end
|
||||
|
@ -1,85 +0,0 @@
|
||||
module SlotMachine
|
||||
# just name scoping the same stuff to slot
|
||||
# so we know we are on the way down, keeping our layers seperated
|
||||
# and we can put constant adding into the to_risc methods (instead of on sol classes)
|
||||
class Constant
|
||||
end
|
||||
|
||||
class LambdaConstant < Constant
|
||||
attr_reader :lambda
|
||||
def initialize(bl)
|
||||
@lambda = bl
|
||||
end
|
||||
def to_parfait(compiler)
|
||||
@lambda
|
||||
end
|
||||
end
|
||||
|
||||
class IntegerConstant < Constant
|
||||
attr_reader :value
|
||||
def initialize(value)
|
||||
@value = value
|
||||
end
|
||||
def to_parfait(compiler)
|
||||
value = Parfait.object_space.get_factory_for(:Integer).get_next_object
|
||||
value.set_value(@value)
|
||||
compiler.add_constant(value)
|
||||
value
|
||||
end
|
||||
def ct_type
|
||||
Parfait.object_space.get_type_by_class_name(:Integer)
|
||||
end
|
||||
end
|
||||
class FloatConstant < Constant
|
||||
attr_reader :value
|
||||
def initialize(value)
|
||||
@value = value
|
||||
end
|
||||
def ct_type
|
||||
true
|
||||
end
|
||||
end
|
||||
class TrueConstant < Constant
|
||||
def to_parfait(compiler)
|
||||
Parfait.object_space.true_object
|
||||
end
|
||||
def ct_type
|
||||
Parfait.object_space.get_type_by_class_name(:TrueClass)
|
||||
end
|
||||
end
|
||||
class FalseConstant < Constant
|
||||
def to_parfait(compiler)
|
||||
Parfait.object_space.false_object
|
||||
end
|
||||
def ct_type
|
||||
Parfait.object_space.get_type_by_class_name(:FalseClass)
|
||||
end
|
||||
end
|
||||
class NilConstant < Constant
|
||||
def to_parfait(compiler)
|
||||
Parfait.object_space.nil_object
|
||||
end
|
||||
def ct_type
|
||||
Parfait.object_space.get_type_by_class_name(:NilClass)
|
||||
end
|
||||
end
|
||||
class StringConstant < Constant
|
||||
attr_reader :value
|
||||
def initialize(value)
|
||||
@value = value
|
||||
end
|
||||
def to_parfait(compiler)
|
||||
value = Parfait.new_word(@value)
|
||||
compiler.add_constant(value)
|
||||
value
|
||||
end
|
||||
def ct_type
|
||||
Parfait.object_space.get_type_by_class_name(:Word)
|
||||
end
|
||||
end
|
||||
class SymbolConstant < Constant
|
||||
def ct_type
|
||||
Parfait.object_space.get_type_by_class_name(:Word)
|
||||
end
|
||||
end
|
||||
end
|
@ -48,7 +48,6 @@ module SlotMachine
|
||||
def to_risc(compiler)
|
||||
const_reg = @right.to_register(compiler , original_source)
|
||||
@left.reduce_and_load(const_reg , compiler , original_source )
|
||||
compiler.reset_regs
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user