fix constants being passed down

This commit is contained in:
Torsten Ruger 2018-03-22 02:38:06 +05:30
parent 01151b4ba7
commit ca3bf6acfa
11 changed files with 15 additions and 14 deletions

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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