diff --git a/lib/mom/instruction/slot_load.rb b/lib/mom/instruction/slot_load.rb index d10c2501..faba209d 100644 --- a/lib/mom/instruction/slot_load.rb +++ b/lib/mom/instruction/slot_load.rb @@ -103,7 +103,7 @@ module Mom right = compiler.use_reg( type ) case known_object when Constant , Parfait::Object , Risc::Label - const = Risc.load_constant(instruction, self , right) + const = Risc.load_constant(instruction, known_object , right) when Symbol const = Risc::SlotToReg.new( instruction , Risc.resolve_to_register(known_object) , Risc.resolve_to_index(:message , slots[0]), right) diff --git a/lib/risc/instructions/load_constant.rb b/lib/risc/instructions/load_constant.rb index b8682bbb..53a6c032 100644 --- a/lib/risc/instructions/load_constant.rb +++ b/lib/risc/instructions/load_constant.rb @@ -9,6 +9,7 @@ module Risc super(source) @register = register @constant = constant + raise "Not Constant #{constant}" if constant.is_a?(Mom::SlotDefinition) end attr_accessor :register , :constant diff --git a/test/mom/assign/test_assign_arg_const.rb b/test/mom/assign/test_assign_arg_const.rb index 8436262e..51fe3d3e 100644 --- a/test/mom/assign/test_assign_arg_const.rb +++ b/test/mom/assign/test_assign_arg_const.rb @@ -15,7 +15,7 @@ module Risc def test_constant_load produced = produce_body - assert_equal 5 , produced.constant.known_object.value + assert_equal 5 , produced.constant.value end def test_slot_move diff --git a/test/mom/assign/test_assign_ivar_const.rb b/test/mom/assign/test_assign_ivar_const.rb index 1dbaf38b..09cd3c63 100644 --- a/test/mom/assign/test_assign_ivar_const.rb +++ b/test/mom/assign/test_assign_ivar_const.rb @@ -15,7 +15,7 @@ module Risc def test_constant_load produced = produce_body - assert_equal 5 , produced.constant.known_object.value + assert_equal 5 , produced.constant.value end def test_slot_move diff --git a/test/mom/assign/test_assign_local_const.rb b/test/mom/assign/test_assign_local_const.rb index 8c38e7ea..5ddf1254 100644 --- a/test/mom/assign/test_assign_local_const.rb +++ b/test/mom/assign/test_assign_local_const.rb @@ -15,7 +15,7 @@ module Risc def test_constant_load produced = produce_body - assert_equal 5 , produced.constant.known_object.value + assert_equal 5 , produced.constant.value end def test_slot_move diff --git a/test/mom/assign/test_assign_local_ivar.rb b/test/mom/assign/test_assign_local_ivar.rb index 7cf328d3..3bfb4897 100644 --- a/test/mom/assign/test_assign_local_ivar.rb +++ b/test/mom/assign/test_assign_local_ivar.rb @@ -16,7 +16,7 @@ module Risc def test_constant_load produced = produce_body - assert_equal 5 , produced.constant.known_object.value + assert_equal 5 , produced.constant.value end def test_slot_move diff --git a/test/mom/assign/test_assign_local_send.rb b/test/mom/assign/test_assign_local_send.rb index dfe7b174..63a6cc18 100644 --- a/test/mom/assign/test_assign_local_send.rb +++ b/test/mom/assign/test_assign_local_send.rb @@ -18,7 +18,7 @@ module Risc def test_constant_load produced = produce_body - assert_equal 5 , produced.next(11).constant.known_object.value + assert_equal 5 , produced.next(11).constant.value end end end diff --git a/test/mom/test_if_else.rb b/test/mom/test_if_else.rb index 1c57656f..8135b9fe 100644 --- a/test/mom/test_if_else.rb +++ b/test/mom/test_if_else.rb @@ -18,7 +18,7 @@ module Risc def test_false_load produced = produce_body - assert_equal Mom::FalseConstant , produced.next(2).constant.known_object.class + assert_equal Mom::FalseConstant , produced.next(2).constant.class end def test_false_check produced = produce_body @@ -26,7 +26,7 @@ module Risc end def test_nil_load produced = produce_body - assert_equal Mom::NilConstant , produced.next(4).constant.known_object.class + assert_equal Mom::NilConstant , produced.next(4).constant.class end def test_nil_check produced = produce_body diff --git a/test/mom/test_if_no_else.rb b/test/mom/test_if_no_else.rb index 74526cd1..2b2e8e79 100644 --- a/test/mom/test_if_no_else.rb +++ b/test/mom/test_if_no_else.rb @@ -17,7 +17,7 @@ module Risc def test_false_load produced = produce_body - assert_equal Mom::FalseConstant , produced.next(2).constant.known_object.class + assert_equal Mom::FalseConstant , produced.next(2).constant.class end def test_false_check produced = produce_body @@ -25,7 +25,7 @@ module Risc end def test_nil_load produced = produce_body - assert_equal Mom::NilConstant , produced.next(4).constant.known_object.class + assert_equal Mom::NilConstant , produced.next(4).constant.class end def test_nil_check produced = produce_body diff --git a/test/mom/test_send_simple.rb b/test/mom/test_send_simple.rb index 7c027630..6fd1f08a 100644 --- a/test/mom/test_send_simple.rb +++ b/test/mom/test_send_simple.rb @@ -27,11 +27,11 @@ module Risc end def test_load_label produced = produce_body - assert_equal Label , produced.next(14).constant.known_object.class + assert_equal Label , produced.next(14).constant.class end def test_load_5 produced = produce_body - assert_equal 5 , produced.next(11).constant.known_object.value + assert_equal 5 , produced.next(11).constant.value end def test_call_reg_setup produced = produce_body diff --git a/test/mom/test_while.rb b/test/mom/test_while.rb index cebdc106..868cb2ec 100644 --- a/test/mom/test_while.rb +++ b/test/mom/test_while.rb @@ -17,7 +17,7 @@ module Risc def test_false_load produced = produce_body - assert_equal Mom::FalseConstant , produced.next(3).constant.known_object.class + assert_equal Mom::FalseConstant , produced.next(3).constant.class end def test_false_check produced = produce_body @@ -25,7 +25,7 @@ module Risc end def test_nil_load produced = produce_body - assert_equal Mom::NilConstant , produced.next(5).constant.known_object.class + assert_equal Mom::NilConstant , produced.next(5).constant.class end def test_nil_check produced = produce_body