remove use_reg on compiler and SA for load
This commit is contained in:
parent
0ce14bdfd1
commit
77003eed06
@ -51,12 +51,6 @@ module Risc
|
|||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
# require a (temporary) register. code must give this back with release_reg
|
|
||||||
# Second extra parameter may give extra info about the value, see RegisterValue
|
|
||||||
def use_reg( type , extra = {} )
|
|
||||||
@allocator.use_reg(type, extra)
|
|
||||||
end
|
|
||||||
|
|
||||||
# resolve the type of the slot, by inferring from it's name, using the type
|
# resolve the type of the slot, by inferring from it's name, using the type
|
||||||
# scope related slots are resolved by the compiler by method/block
|
# scope related slots are resolved by the compiler by method/block
|
||||||
def slot_type( slot , type)
|
def slot_type( slot , type)
|
||||||
|
@ -10,7 +10,7 @@ module Risc
|
|||||||
@register = register
|
@register = register
|
||||||
@constant = constant
|
@constant = constant
|
||||||
raise "Not Constant #{constant}" if constant.is_a?(SlotMachine::Slot)
|
raise "Not Constant #{constant}" if constant.is_a?(SlotMachine::Slot)
|
||||||
raise "Not register #{register}" unless RegisterValue.look_like_reg(register)
|
raise "Not register #{register}" unless register.is_a?(RegisterValue)
|
||||||
end
|
end
|
||||||
attr_accessor :register , :constant
|
attr_accessor :register , :constant
|
||||||
|
|
||||||
@ -32,7 +32,15 @@ module Risc
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def self.load_constant( source , constant , register )
|
def self.load_constant( source , constant )
|
||||||
|
if(constant.is_a?(Parfait::Object))
|
||||||
|
type = constant.get_type
|
||||||
|
value = constant
|
||||||
|
else
|
||||||
|
type = constant.ct_type
|
||||||
|
value = constant.value
|
||||||
|
end
|
||||||
|
register = RegisterValue.new( "id_#{value.object_id}".to_sym , type )
|
||||||
LoadConstant.new( source , constant , register )
|
LoadConstant.new( source , constant , register )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
32
test/risc/instructions/test_load_constant.rb
Normal file
32
test/risc/instructions/test_load_constant.rb
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
require_relative "../helper"
|
||||||
|
|
||||||
|
module Risc
|
||||||
|
class TestLoadConstant < MiniTest::Test
|
||||||
|
def setup
|
||||||
|
Parfait.boot!({})
|
||||||
|
end
|
||||||
|
def load(const = SlotMachine::StringConstant.new("hi") )
|
||||||
|
Risc.load_constant("source" , const)
|
||||||
|
end
|
||||||
|
def test_const
|
||||||
|
assert_equal LoadConstant , load.class
|
||||||
|
end
|
||||||
|
def test_const_reg
|
||||||
|
assert load.register.is_object?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
class TestLoadConstant1 < MiniTest::Test
|
||||||
|
def setup
|
||||||
|
Parfait.boot!({})
|
||||||
|
end
|
||||||
|
def load(const = Parfait.new_word("hi") )
|
||||||
|
Risc.load_constant("source" , const)
|
||||||
|
end
|
||||||
|
def test_parf
|
||||||
|
assert_equal LoadConstant , load.class
|
||||||
|
end
|
||||||
|
def test_parf_reg
|
||||||
|
assert load.register.is_object?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user