2017-09-11 13:22:33 +02:00
|
|
|
module Mom
|
|
|
|
|
2018-03-21 07:50:55 +01:00
|
|
|
# As reminder: a statically resolved call (the simplest one) becomes three Mom Instructions.
|
|
|
|
# Ie: MessageSetup,ArgumentTransfer,SimpleCall
|
2017-09-11 13:22:33 +02:00
|
|
|
#
|
2018-03-21 07:50:55 +01:00
|
|
|
# MessageSetup does Setup before a call can be made, acquiring and filling the message
|
|
|
|
# basically.
|
2017-09-11 13:22:33 +02:00
|
|
|
#
|
2018-03-21 07:50:55 +01:00
|
|
|
# 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
|
2017-09-11 13:22:33 +02:00
|
|
|
#
|
|
|
|
class MessageSetup < Instruction
|
|
|
|
attr_reader :method
|
|
|
|
|
|
|
|
def initialize(method)
|
|
|
|
@method = method
|
|
|
|
end
|
2018-03-13 11:46:06 +01:00
|
|
|
|
2018-03-21 07:50:55 +01:00
|
|
|
# Move method name, frame and arguemnt types from the method to the neext_message
|
|
|
|
# Assumes the message is ready, see class description
|
2018-03-13 11:46:06 +01:00
|
|
|
def to_risc(compiler)
|
2018-03-21 07:50:55 +01:00
|
|
|
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)
|
2018-03-13 11:46:06 +01:00
|
|
|
end
|
|
|
|
|
2017-09-11 13:22:33 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|