diff --git a/lib/mom/instruction/slot_load.rb b/lib/mom/instruction/slot_load.rb index 34c2d161..ff6b5d4f 100644 --- a/lib/mom/instruction/slot_load.rb +++ b/lib/mom/instruction/slot_load.rb @@ -58,6 +58,7 @@ module Mom end when Parfait::CacheEntry left = compiler.use_reg( :int ) + const << Risc.load_constant(original_source, @left.known_object , left) left_index = Risc.resolve_to_index(:cache_entry , left_slots.first) else raise "We have left #{@left.known_object}" diff --git a/test/risc/interpreter/test_dynamic_call.rb b/test/risc/interpreter/test_dynamic_call.rb new file mode 100644 index 00000000..4d4131ef --- /dev/null +++ b/test/risc/interpreter/test_dynamic_call.rb @@ -0,0 +1,59 @@ +require_relative "helper" + +module Risc + class InterpreterDynamicCall < MiniTest::Test + include Ticker + + def setup + @string_input = as_main("a = 15 ; return a.div10") + super + end + + def test_chain + #show_ticks # get output of what is + check_chain [Branch, Label, LoadConstant, SlotToReg, LoadConstant, + SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, + SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant, + SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, + SlotToReg, RegToSlot, LoadConstant, RegToSlot, FunctionCall, + Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, + SlotToReg, SlotToReg, SlotToReg, OperatorInstruction, IsZero, + SlotToReg, SlotToReg, LoadConstant, RegToSlot, LoadConstant, + SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg, + SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant, + SlotToReg, SlotToReg, SlotToReg, SlotToReg, RegToSlot, + LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, + SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, + SlotToReg, LoadConstant, FunctionCall, Label, Label, + NilClass] + #assert_equal 1 , get_return + end + + def test_call_main + call_ins = ticks(25) + assert_equal FunctionCall , call_ins.class + assert_equal :main , call_ins.method.name + end + def test_call_resolve + call_ins = ticks(68) + assert_equal FunctionCall , call_ins.class + assert_equal :resolve_method , call_ins.method.name + end + def test_label + call_ins = ticks(69) + assert_equal Label , call_ins.class + assert_equal "Word_Type.resolve_method" , call_ins.name + end + #should end in exit, but doesn't, becasue resolve never returns + def ttest_sys + sys = ticks(20) + assert_equal Syscall , sys.class + end + def ttest_return + ret = ticks(18) + assert_equal FunctionReturn , ret.class + link = @interpreter.get_register( ret.register ) + assert_equal Label , link.class + end + end +end