rubyx/lib/mom/instruction/message_setup.rb
Torsten Ruger 12c71fa394 first go at message setups translation to risc
simplest possible implementation, ie the method and next_messages are
loaded many times.

But the layer design shines, it’s easy to understand
2018-03-21 12:20:55 +05:30

39 lines
1.4 KiB
Ruby

module Mom
# As reminder: a statically resolved call (the simplest one) becomes three Mom Instructions.
# Ie: MessageSetup,ArgumentTransfer,SimpleCall
#
# MessageSetup does Setup before a call can be made, acquiring and filling the message
# basically.
#
# With the current design the next message is already ready (hardwired as a linked list),
# so nothing to be done there.
# (but this does not account for continuations or closures and so will have to be changed)
#
# But we do need to set the message name to the called method's name,
# and also set the arg and local types on the new message, currently for debugging
# but later for dynamic checking
#
class MessageSetup < Instruction
attr_reader :method
def initialize(method)
@method = method
end
# Move method name, frame and arguemnt types from the method to the neext_message
# Assumes the message is ready, see class description
def to_risc(compiler)
name_move = SlotLoad.new( [:message , :next_message,:name] , [method , :name])
moves = name_move.to_risc(compiler)
args_move = SlotLoad.new( [:message , :next_message, :arguments,:type] , [method , :arguments, :type])
moves << args_move.to_risc(compiler)
type_move = SlotLoad.new( [:message , :next_message, :frame,:type] , [method , :frame,:type])
moves << type_move.to_risc(compiler)
end
end
end