load constant to create register names with class

Just the id_ did give no clue to the contents, just took care of the uniqueness.
Better for debugging
This commit is contained in:
Torsten 2020-03-07 19:25:07 +02:00
parent 3ec5557ddb
commit 53eb28fff4
2 changed files with 8 additions and 5 deletions

View File

@ -45,7 +45,8 @@ module Risc
type = constant.ct_type
value = constant.value
end
register = RegisterValue.new( "id_#{value.object_id}".to_sym , type )
value_class = value.class.name.to_s.split("::").last.downcase
register = RegisterValue.new( "id_#{value_class}_#{value.object_id}".to_sym , type )
end
LoadConstant.new( source , constant , register )
end

View File

@ -5,22 +5,24 @@ module Risc
def setup
Parfait.boot!({})
end
def load(const = SlotMachine::StringConstant.new("hi") )
def risc(i)
const = SlotMachine::StringConstant.new("hi")
Risc.load_constant("source" , const)
end
def test_const
assert_load load , SlotMachine::StringConstant , "id_"
assert_load 1 , SlotMachine::StringConstant , "id_string_"
end
end
class TestLoadConstant1 < MiniTest::Test
def setup
Parfait.boot!({})
end
def load(const = Parfait.new_word("hi") )
def risc(i)
const = Parfait.new_word("hi")
Risc.load_constant("source" , const)
end
def test_parf
assert_load load , Parfait::Word , "id_"
assert_load 1 , Parfait::Word , "id_word_"
end
end
end