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:
parent
3ec5557ddb
commit
53eb28fff4
@ -45,7 +45,8 @@ module Risc
|
|||||||
type = constant.ct_type
|
type = constant.ct_type
|
||||||
value = constant.value
|
value = constant.value
|
||||||
end
|
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
|
end
|
||||||
LoadConstant.new( source , constant , register )
|
LoadConstant.new( source , constant , register )
|
||||||
end
|
end
|
||||||
|
@ -5,22 +5,24 @@ module Risc
|
|||||||
def setup
|
def setup
|
||||||
Parfait.boot!({})
|
Parfait.boot!({})
|
||||||
end
|
end
|
||||||
def load(const = SlotMachine::StringConstant.new("hi") )
|
def risc(i)
|
||||||
|
const = SlotMachine::StringConstant.new("hi")
|
||||||
Risc.load_constant("source" , const)
|
Risc.load_constant("source" , const)
|
||||||
end
|
end
|
||||||
def test_const
|
def test_const
|
||||||
assert_load load , SlotMachine::StringConstant , "id_"
|
assert_load 1 , SlotMachine::StringConstant , "id_string_"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class TestLoadConstant1 < MiniTest::Test
|
class TestLoadConstant1 < MiniTest::Test
|
||||||
def setup
|
def setup
|
||||||
Parfait.boot!({})
|
Parfait.boot!({})
|
||||||
end
|
end
|
||||||
def load(const = Parfait.new_word("hi") )
|
def risc(i)
|
||||||
|
const = Parfait.new_word("hi")
|
||||||
Risc.load_constant("source" , const)
|
Risc.load_constant("source" , const)
|
||||||
end
|
end
|
||||||
def test_parf
|
def test_parf
|
||||||
assert_load load , Parfait::Word , "id_"
|
assert_load 1 , Parfait::Word , "id_word_"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user