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
|
# 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.
|
# return_address of the next_message, for the ReturnSequence to pick it up.
|
||||||
def to_risc(compiler)
|
def to_risc(compiler)
|
||||||
reg = compiler.use_reg(:int)
|
jump_address = compiler.use_reg(:int)
|
||||||
return_label = Risc::Label.new(self,"continue")
|
return_label = Risc::Label.new(self,"continue")
|
||||||
save_return = SlotLoad.new([:message,:next_message,:return_address],[return_label])
|
save_return = SlotLoad.new([:message,:next_message,:return_address],[return_label])
|
||||||
moves = save_return.to_risc(compiler)
|
moves = save_return.to_risc(compiler)
|
||||||
moves << Risc.slot_to_reg(self, :message , :next_message , Risc.message_reg)
|
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
|
moves << return_label
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ module Risc
|
|||||||
@input = "r = 5.mod4"
|
@input = "r = 5.mod4"
|
||||||
@expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg ,
|
@expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg ,
|
||||||
RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant ,
|
RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant ,
|
||||||
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, FunctionCall ,
|
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg ,
|
||||||
Label, SlotToReg, SlotToReg, RegToSlot]
|
LoadConstant, FunctionCall, Label, SlotToReg, SlotToReg, RegToSlot]
|
||||||
end
|
end
|
||||||
def test_local_assign_instructions
|
def test_local_assign_instructions
|
||||||
assert_nil msg = check_nil , msg
|
assert_nil msg = check_nil , msg
|
||||||
|
@ -10,7 +10,7 @@ module Risc
|
|||||||
@expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg ,
|
@expect = [LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, SlotToReg ,
|
||||||
RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant ,
|
RegToSlot, LoadConstant, SlotToReg, SlotToReg, RegToSlot, LoadConstant ,
|
||||||
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg ,
|
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, SlotToReg ,
|
||||||
FunctionCall, Label]
|
LoadConstant, FunctionCall, Label]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_send_instructions
|
def test_send_instructions
|
||||||
@ -18,8 +18,8 @@ module Risc
|
|||||||
end
|
end
|
||||||
def test_function_call
|
def test_function_call
|
||||||
produced = produce_body
|
produced = produce_body
|
||||||
assert_equal FunctionCall , produced.next(18).class
|
assert_equal FunctionCall , produced.next(19).class
|
||||||
assert_equal :mod4 , produced.next(18).method.name
|
assert_equal :mod4 , produced.next(19).method.name
|
||||||
end
|
end
|
||||||
def test_load_label
|
def test_load_label
|
||||||
produced = produce_body
|
produced = produce_body
|
||||||
@ -29,24 +29,10 @@ module Risc
|
|||||||
produced = produce_body
|
produced = produce_body
|
||||||
assert_equal 5 , produced.next(11).constant.known_object.value
|
assert_equal 5 , produced.next(11).constant.known_object.value
|
||||||
end
|
end
|
||||||
|
def test_call_reg_setup
|
||||||
def est_call_reg_setup
|
|
||||||
produced = produce_body
|
produced = produce_body
|
||||||
assert_equal produced.next(16).register , produced.next(17).register
|
assert_equal produced.next(18).register , produced.next(19).register
|
||||||
end
|
end
|
||||||
def pest_nil_load
|
#TODO check the message setup, type and frame moves
|
||||||
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
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user