2015-06-21 16:23:15 +02:00
|
|
|
module Register
|
2015-07-01 18:27:52 +02:00
|
|
|
# This implements the creation of a new frame object.
|
|
|
|
# Or to be more precise, it makes the frame available in a register, as the message (any message)
|
|
|
|
# carries a frame around which is reused.
|
2014-09-24 17:15:08 +02:00
|
|
|
|
2015-07-01 18:27:52 +02:00
|
|
|
# Just as a reminder: a message object is used to send and holds return address/message
|
|
|
|
# and arguments + self
|
|
|
|
# frames are used by a method and hold local and temporary variables
|
2015-05-24 12:55:05 +02:00
|
|
|
|
2014-09-24 17:15:08 +02:00
|
|
|
|
|
|
|
class FrameImplementation
|
|
|
|
def run block
|
|
|
|
block.codes.dup.each do |code|
|
2015-07-01 18:27:52 +02:00
|
|
|
next unless code.is_a?(Virtual::NewFrame)
|
|
|
|
# load the frame from message by index, simple get_slot
|
2015-07-27 11:13:39 +02:00
|
|
|
new_codes = [ Register.get_slot( code, :message , :frame , Register.resolve_to_register(:frame))]
|
2014-09-24 17:15:08 +02:00
|
|
|
block.replace(code , new_codes )
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-06-21 16:23:15 +02:00
|
|
|
Virtual.machine.add_pass "Register::FrameImplementation"
|
2014-09-24 17:15:08 +02:00
|
|
|
end
|