SA for slot_to_reg
This commit is contained in:
parent
77003eed06
commit
d22da1ab97
@ -16,9 +16,12 @@ module Risc
|
||||
# Produce a SlotToReg instruction.
|
||||
# Array and to are registers
|
||||
# index may be a Symbol in which case is resolves with resolve_index.
|
||||
def self.slot_to_reg( source , array , index , to)
|
||||
raise "Not register #{array}" unless RegisterValue.look_like_reg(array)
|
||||
def self.slot_to_reg( source , array , index )
|
||||
raise "Register #{array}" if RegisterValue.look_like_reg(array.symbol)
|
||||
index = array.resolve_index(index) if index.is_a?(Symbol)
|
||||
type = array.type_at(index)
|
||||
#puts "Slot for #{array.symbol}@ index #{index} is #{type}"
|
||||
to = RegisterValue.new( "#{array.symbol}.#{type.to_s.downcase}".to_sym , type )
|
||||
SlotToReg.new( source , array , index , to)
|
||||
end
|
||||
end
|
||||
|
18
test/risc/instructions/test_slot_to_reg.rb
Normal file
18
test/risc/instructions/test_slot_to_reg.rb
Normal file
@ -0,0 +1,18 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Risc
|
||||
class TestSlotToReg < MiniTest::Test
|
||||
def setup
|
||||
Parfait.boot!({})
|
||||
end
|
||||
def slot
|
||||
Risc.slot_to_reg("source" , Risc.message_named_reg , :type)
|
||||
end
|
||||
def test_slot
|
||||
assert_equal SlotToReg , slot.class
|
||||
end
|
||||
def test_slot_reg
|
||||
assert_equal :"message.type" , slot.register.symbol
|
||||
end
|
||||
end
|
||||
end
|
@ -29,9 +29,6 @@ module Risc
|
||||
def test_const
|
||||
assert_equal Array , @compiler.constants.class
|
||||
end
|
||||
def test_use_reg
|
||||
@compiler.use_reg(:Type)
|
||||
end
|
||||
end
|
||||
class TestFakeCallableCompiler < MiniTest::Test
|
||||
def setup
|
||||
|
Loading…
Reference in New Issue
Block a user