Makes slots linked list
slots used to ba an array of symbols Now we have an object for each slot, that holds the name and the next_slot relatively easy change, though quite broad
This commit is contained in:
@ -33,7 +33,7 @@ module Sol
|
||||
# Derived classes do not implement to_slot, only slot_position
|
||||
def to_slot(compiler)
|
||||
to = SlotMachine::Slotted.for(:message , self.slot_position(compiler))
|
||||
from = @value.to_slot_definition(compiler)
|
||||
from = @value.to_slotted(compiler)
|
||||
assign = SlotMachine::SlotLoad.new(self,to,from)
|
||||
return assign unless @value.is_a?(CallStatement)
|
||||
@value.to_slot(compiler) << assign
|
||||
|
@ -9,7 +9,7 @@ module Sol
|
||||
def initialize(value)
|
||||
@value = value
|
||||
end
|
||||
def to_slot_definition(_)
|
||||
def to_slotted(_)
|
||||
return SlotMachine::Slotted.for(SlotMachine::IntegerConstant.new(@value) , [])
|
||||
end
|
||||
def ct_type
|
||||
@ -37,7 +37,7 @@ module Sol
|
||||
def ct_type
|
||||
Parfait.object_space.get_type_by_class_name(:True)
|
||||
end
|
||||
def to_slot_definition(_)
|
||||
def to_slotted(_)
|
||||
return SlotMachine::Slotted.for(Parfait.object_space.true_object , [])
|
||||
end
|
||||
def to_s(depth = 0)
|
||||
@ -49,7 +49,7 @@ module Sol
|
||||
def ct_type
|
||||
Parfait.object_space.get_type_by_class_name(:False)
|
||||
end
|
||||
def to_slot_definition(_)
|
||||
def to_slotted(_)
|
||||
return SlotMachine::Slotted.for(Parfait.object_space.false_object , [])
|
||||
end
|
||||
def to_s(depth = 0)
|
||||
@ -61,7 +61,7 @@ module Sol
|
||||
def ct_type
|
||||
Parfait.object_space.get_type_by_class_name(:Nil)
|
||||
end
|
||||
def to_slot_definition(_)
|
||||
def to_slotted(_)
|
||||
return SlotMachine::Slotted.for(Parfait.object_space.nil_object , [])
|
||||
end
|
||||
def to_s(depth = 0)
|
||||
@ -75,7 +75,7 @@ module Sol
|
||||
def initialize(type = nil)
|
||||
@my_type = type
|
||||
end
|
||||
def to_slot_definition(compiler)
|
||||
def to_slotted(compiler)
|
||||
@my_type = compiler.receiver_type
|
||||
SlotMachine::Slotted.for(:message , [:receiver])
|
||||
end
|
||||
@ -91,7 +91,7 @@ module Sol
|
||||
def initialize(value)
|
||||
@value = value
|
||||
end
|
||||
def to_slot_definition(_)
|
||||
def to_slotted(_)
|
||||
return SlotMachine::Slotted.for(SlotMachine::StringConstant.new(@value),[])
|
||||
end
|
||||
def ct_type
|
||||
|
@ -10,7 +10,7 @@ module Sol
|
||||
|
||||
# When used as right hand side, this tells what data to move to get the result into
|
||||
# a varaible. It is (off course) the return value of the message
|
||||
def to_slot_definition(_)
|
||||
def to_slotted(_)
|
||||
SlotMachine::Slotted.for(:message ,[ :return_value])
|
||||
end
|
||||
|
||||
|
@ -32,7 +32,7 @@ module Sol
|
||||
|
||||
# create the slot lazily, so to_slot gets called first
|
||||
def check_slot(compiler , false_label)
|
||||
SlotMachine::TruthCheck.new(@condition.to_slot_definition(compiler) , false_label)
|
||||
SlotMachine::TruthCheck.new(@condition.to_slotted(compiler) , false_label)
|
||||
end
|
||||
|
||||
def each(&block)
|
||||
|
@ -13,7 +13,7 @@ module Sol
|
||||
#
|
||||
# This means we do the compiler here (rather than to_slot, which is in
|
||||
# fact never called)
|
||||
def to_slot_definition(compiler)
|
||||
def to_slotted(compiler)
|
||||
compile(compiler) unless @parfait_block
|
||||
return SlotMachine::Slotted.for(SlotMachine::LambdaConstant.new(parfait_block(compiler)) , [])
|
||||
end
|
||||
|
@ -14,7 +14,7 @@ module Sol
|
||||
|
||||
# When used as right hand side, this tells what data to move to get the result into
|
||||
# a varaible. It is (off course) the return value of the message
|
||||
def to_slot_definition(_)
|
||||
def to_slotted(_)
|
||||
SlotMachine::Slotted.for(:message ,[ :return_value])
|
||||
end
|
||||
|
||||
|
@ -32,7 +32,7 @@ module Sol
|
||||
|
||||
def slot_load(compiler)
|
||||
SlotMachine::SlotLoad.new( self , [:message , :return_value] ,
|
||||
@return_value.to_slot_definition(compiler) )
|
||||
@return_value.to_slotted(compiler) )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -67,11 +67,11 @@ module Sol
|
||||
|
||||
def message_setup(compiler,called_method)
|
||||
setup = SlotMachine::MessageSetup.new( called_method )
|
||||
slot_receive = @receiver.to_slot_definition(compiler)
|
||||
slot_receive = @receiver.to_slotted(compiler)
|
||||
arg_target = [:message , :next_message ]
|
||||
args = []
|
||||
@arguments.each_with_index do |arg , index| # +1 because of type
|
||||
args << SlotMachine::SlotLoad.new(self, arg_target + ["arg#{index+1}".to_sym] , arg.to_slot_definition(compiler))
|
||||
args << SlotMachine::SlotLoad.new(self, arg_target + ["arg#{index+1}".to_sym] , arg.to_slotted(compiler))
|
||||
end
|
||||
setup << SlotMachine::ArgumentTransfer.new(self, slot_receive , args )
|
||||
end
|
||||
@ -111,10 +111,11 @@ module Sol
|
||||
|
||||
private
|
||||
def receiver_type_definition(compiler)
|
||||
defi = @receiver.to_slot_definition(compiler)
|
||||
defi.slots << :type
|
||||
defi = @receiver.to_slotted(compiler)
|
||||
defi.set_next( SlotMachine::Slot.new(:type) )
|
||||
defi
|
||||
end
|
||||
|
||||
def build_condition(ok_label, compiler)
|
||||
cached_type = SlotMachine::Slotted.for(dynamic_call.cache_entry , [:cached_type])
|
||||
current_type = receiver_type_definition(compiler)
|
||||
|
@ -10,7 +10,7 @@ module Sol
|
||||
|
||||
class LocalVariable < Expression
|
||||
include Named
|
||||
def to_slot_definition(compiler)
|
||||
def to_slotted(compiler)
|
||||
slot_def = compiler.slot_type_for(@name)
|
||||
SlotMachine::Slotted.for(:message , slot_def)
|
||||
end
|
||||
@ -24,7 +24,7 @@ module Sol
|
||||
|
||||
class InstanceVariable < Expression
|
||||
include Named
|
||||
def to_slot_definition(_)
|
||||
def to_slotted(_)
|
||||
SlotMachine::Slotted.for(:message , [ :receiver , @name] )
|
||||
end
|
||||
# used to collect type information
|
||||
@ -51,7 +51,7 @@ module Sol
|
||||
def ct_type
|
||||
get_named_class.single_class.instance_type
|
||||
end
|
||||
def to_slot_definition(_)
|
||||
def to_slotted(_)
|
||||
return SlotMachine::Slotted.for( get_named_class, [])
|
||||
end
|
||||
def get_named_class
|
||||
|
@ -15,7 +15,7 @@ module Sol
|
||||
codes = cond_label
|
||||
codes << @hoisted.to_slot(compiler) if @hoisted
|
||||
codes << @condition.to_slot(compiler) if @condition.is_a?(SendStatement)
|
||||
codes << SlotMachine::TruthCheck.new(condition.to_slot_definition(compiler) , merge_label)
|
||||
codes << SlotMachine::TruthCheck.new(condition.to_slotted(compiler) , merge_label)
|
||||
codes << @body.to_slot(compiler)
|
||||
codes << SlotMachine::Jump.new(cond_label)
|
||||
codes << merge_label
|
||||
|
@ -49,11 +49,11 @@ module Sol
|
||||
def yield_arg_block(compiler)
|
||||
arg_index = compiler.get_method.arguments_type.get_length - 1
|
||||
setup = SlotMachine::MessageSetup.new( arg_index )
|
||||
slot_receive = @receiver.to_slot_definition(compiler)
|
||||
slot_receive = @receiver.to_slotted(compiler)
|
||||
arg_target = [:message , :next_message ]
|
||||
args = []
|
||||
@arguments.each_with_index do |arg , index| # +1 because of type
|
||||
args << SlotMachine::SlotLoad.new(self, arg_target + ["arg#{index+1}".to_sym] , arg.to_slot_definition(compiler))
|
||||
args << SlotMachine::SlotLoad.new(self, arg_target + ["arg#{index+1}".to_sym] , arg.to_slotted(compiler))
|
||||
end
|
||||
setup << SlotMachine::ArgumentTransfer.new( self , slot_receive , args )
|
||||
setup << SlotMachine::BlockYield.new( self , arg_index )
|
||||
|
Reference in New Issue
Block a user