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
This commit is contained in:
parent
b99fdc3425
commit
12c71fa394
@ -1,14 +1,18 @@
|
||||
module Mom
|
||||
|
||||
# Preamble when entering the method body.
|
||||
# Acquiring the message basically.
|
||||
# As reminder: a statically resolved call (the simplest one) becomes three Mom Instructions.
|
||||
# Ie: MessageSetup,ArgumentTransfer,SimpleCall
|
||||
#
|
||||
# Currently messages are hardwired as a linked list,
|
||||
# but this does not account for continuations or closures and
|
||||
# so will have to be changed.
|
||||
# MessageSetup does Setup before a call can be made, acquiring and filling the message
|
||||
# basically.
|
||||
#
|
||||
# With the current setup this maps to a single SlotMove, ie 2 risc Instructions
|
||||
# But clearer this way.
|
||||
# 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
|
||||
@ -17,8 +21,15 @@ module Mom
|
||||
@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)
|
||||
Risc::Label.new(self,"MethodSetup")
|
||||
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
|
||||
|
@ -102,7 +102,7 @@ module Mom
|
||||
type = known_object.respond_to?(:ct_type) ? known_object.ct_type : :int
|
||||
right = compiler.use_reg( type )
|
||||
case known_object
|
||||
when Constant
|
||||
when Constant , Parfait::Object
|
||||
const = Risc.load_constant(instruction, self , right)
|
||||
when Symbol
|
||||
const = Risc::SlotToReg.new( instruction , Risc.resolve_to_register(known_object) ,
|
||||
|
@ -7,8 +7,9 @@ module Risc
|
||||
def setup
|
||||
super
|
||||
@input = "r = 5.mod4"
|
||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, Label, SlotToReg ,
|
||||
SlotToReg, RegToSlot]
|
||||
@expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg ,
|
||||
RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant ,
|
||||
SlotToReg, RegToSlot, Label, SlotToReg, SlotToReg, RegToSlot]
|
||||
end
|
||||
def test_local_assign_instructions
|
||||
assert_nil msg = check_nil , msg
|
||||
|
Loading…
Reference in New Issue
Block a user