give labels an integer that will end up being the position at runtime
Since integers are first class objects, we need to use an integer object as the return address. The actual address can not be stored in an instance variable since it is not an object. The address is unique to the label and never changes after positioning (using the int is next up)
This commit is contained in:
@ -11,7 +11,8 @@ module Mom
|
||||
@value = value
|
||||
end
|
||||
def to_parfait(compiler)
|
||||
value = Parfait::Integer.new(@value)
|
||||
value = Parfait.object_space.get_integer
|
||||
value.set_value(@value)
|
||||
compiler.add_constant(value)
|
||||
value
|
||||
end
|
||||
|
@ -33,7 +33,7 @@ module Mom
|
||||
def to_risc(compiler)
|
||||
compiler.add_constant( @cache_entry )
|
||||
reg = compiler.use_reg( :Object )
|
||||
return_label = Risc::Label.new(self,"continue_#{object_id}")
|
||||
return_label = Risc.label(self, "continue_#{object_id}")
|
||||
save_return = SlotLoad.new([:message,:next_message,:return_address],[return_label],self)
|
||||
moves = save_return.to_risc(compiler)
|
||||
moves << Risc.slot_to_reg(self, :message , :next_message , Risc.message_reg)
|
||||
|
@ -31,8 +31,9 @@ module Mom
|
||||
# Off course some specific place still has to be responsible for actually
|
||||
# adding the label to the instruction list (usually an if/while)
|
||||
def to_risc(compiler)
|
||||
|
||||
@risc_label ||= Risc::Label.new(self,name)
|
||||
int = Parfait.object_space.get_integer
|
||||
compiler.add_constant(int)
|
||||
@risc_label ||= Risc.label(self,name , int , nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -19,11 +19,11 @@ module Mom
|
||||
end
|
||||
# Calling a Method is basically jumping to the Binary (+ offset).
|
||||
# We just swap in the new message and go.
|
||||
#
|
||||
#
|
||||
# For returning, we add a label after the call, and load it's address into the
|
||||
# return_address of the next_message, for the ReturnSequence to pick it up.
|
||||
def to_risc(compiler)
|
||||
return_label = Risc::Label.new(self,"continue_#{object_id}")
|
||||
return_label = Risc.label(self,"continue_#{object_id}")
|
||||
save_return = SlotLoad.new([:message,:next_message,:return_address],[return_label],self)
|
||||
moves = save_return.to_risc(compiler)
|
||||
moves << Risc.slot_to_reg(self, :message , :next_message , Risc.message_reg)
|
||||
|
Reference in New Issue
Block a user