fix most mom and risc apart
apart from things involving builtn, which is not yet conceptually solved (as it codes risc, not mom)
This commit is contained in:
@ -22,7 +22,8 @@ module Mom
|
||||
|
||||
# receiver is a slot_definition
|
||||
# arguments is an array of SlotLoads
|
||||
def initialize( receiver,arguments )
|
||||
def initialize( source , receiver,arguments )
|
||||
super(source)
|
||||
@receiver , @arguments = receiver , arguments
|
||||
raise "Receiver not SlotDefinition #{@receiver}" unless @receiver.is_a?(SlotDefinition)
|
||||
@arguments.each{|a| raise "args not SlotLoad #{a}" unless a.is_a?(SlotLoad)}
|
||||
@ -35,7 +36,7 @@ module Mom
|
||||
# load receiver and then each arg into the new message
|
||||
# delegates to SlotLoad for receiver and to the actual args.to_risc
|
||||
def to_risc(compiler)
|
||||
transfer = SlotLoad.new([:message , :next_message , :receiver] , @receiver, self).to_risc(compiler)
|
||||
transfer = SlotLoad.new(self.source ,[:message , :next_message , :receiver] , @receiver, self).to_risc(compiler)
|
||||
compiler.reset_regs
|
||||
@arguments.each do |arg|
|
||||
arg.to_risc(compiler)
|
||||
|
@ -7,9 +7,20 @@ module Mom
|
||||
#
|
||||
class ReturnJump < Instruction
|
||||
|
||||
attr_reader :return_label
|
||||
|
||||
# pass in the source_name (string/vool_instruction) for accounting purposes
|
||||
# and the return_label, where we actually jump to. This is set up by the
|
||||
# method_compiler, so it is easy to find (see return_label in compiler)
|
||||
def initialize( source , label )
|
||||
super(source)
|
||||
@return_label = label
|
||||
end
|
||||
|
||||
# the jump quite simple resolves to an uncondition risc Branch
|
||||
# we use the label that is passed in at creation
|
||||
def to_risc(compiler)
|
||||
compiler.add_code Risc::Branch.new(self , compiler.return_label)
|
||||
compiler.add_code Risc::Branch.new(self , return_label.risc_label(compiler))
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user