finish the simple call
moving jump address
This commit is contained in:
parent
49880267bb
commit
f424e58715
@ -20,12 +20,13 @@ module Mom
|
||||
# For returning, we add a label after the call, and load it's address into the
|
||||
# return_address of the next_message, for the ReturnSequence to pick it up.
|
||||
def to_risc(compiler)
|
||||
reg = compiler.use_reg(:int)
|
||||
jump_address = compiler.use_reg(:int)
|
||||
return_label = Risc::Label.new(self,"continue")
|
||||
save_return = SlotLoad.new([:message,:next_message,:return_address],[return_label])
|
||||
moves = save_return.to_risc(compiler)
|
||||
moves << Risc.slot_to_reg(self, :message , :next_message , Risc.message_reg)
|
||||
moves << Risc::FunctionCall.new(self, method ,reg)
|
||||
moves << Risc.load_constant(self , method.binary , jump_address)
|
||||
moves << Risc::FunctionCall.new(self, method ,jump_address)
|
||||
moves << return_label
|
||||
end
|
||||
|
||||
|
@ -9,8 +9,8 @@ module Risc
|
||||
@input = "r = 5.mod4"
|
||||
@expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg ,
|
||||
RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant ,
|
||||
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, FunctionCall ,
|
||||
Label, SlotToReg, SlotToReg, RegToSlot]
|
||||
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg ,
|
||||
LoadConstant, FunctionCall, Label, SlotToReg, SlotToReg, RegToSlot]
|
||||
end
|
||||
def test_local_assign_instructions
|
||||
assert_nil msg = check_nil , msg
|
||||
|
@ -10,7 +10,7 @@ module Risc
|
||||
@expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg ,
|
||||
RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant ,
|
||||
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg ,
|
||||
FunctionCall, Label]
|
||||
LoadConstant, FunctionCall, Label]
|
||||
end
|
||||
|
||||
def test_send_instructions
|
||||
@ -18,8 +18,8 @@ module Risc
|
||||
end
|
||||
def test_function_call
|
||||
produced = produce_body
|
||||
assert_equal FunctionCall , produced.next(18).class
|
||||
assert_equal :mod4 , produced.next(18).method.name
|
||||
assert_equal FunctionCall , produced.next(19).class
|
||||
assert_equal :mod4 , produced.next(19).method.name
|
||||
end
|
||||
def test_load_label
|
||||
produced = produce_body
|
||||
@ -29,24 +29,10 @@ module Risc
|
||||
produced = produce_body
|
||||
assert_equal 5 , produced.next(11).constant.known_object.value
|
||||
end
|
||||
|
||||
def est_call_reg_setup
|
||||
def test_call_reg_setup
|
||||
produced = produce_body
|
||||
assert_equal produced.next(16).register , produced.next(17).register
|
||||
assert_equal produced.next(18).register , produced.next(19).register
|
||||
end
|
||||
def pest_nil_load
|
||||
produced = produce_body
|
||||
assert_equal Mom::NilConstant , produced.next(4).constant.known_object.class
|
||||
end
|
||||
def pest_nil_check
|
||||
produced = produce_body
|
||||
assert_equal produced.next(10) , produced.next(5).label
|
||||
end
|
||||
|
||||
def pest_true_label
|
||||
produced = produce_body
|
||||
assert produced.next(6).name.start_with?("true_label")
|
||||
end
|
||||
|
||||
#TODO check the message setup, type and frame moves
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user