Fix slot access for constants
Type access is allowed for any object, including constants. Needed for parfait
This commit is contained in:
parent
5a80850975
commit
ee8927b059
@ -63,7 +63,11 @@ module Mom
|
|||||||
parfait = known_object.to_parfait(compiler)
|
parfait = known_object.to_parfait(compiler)
|
||||||
const = Risc.load_constant(source, parfait , right)
|
const = Risc.load_constant(source, parfait , right)
|
||||||
compiler.add_code const
|
compiler.add_code const
|
||||||
raise "Can't have slots into Constants" if slots.length > 0
|
if slots.length == 1
|
||||||
|
raise "only type allowed for constants, not #{slots[0]}" unless slots[0] == :type
|
||||||
|
compiler.add_code Risc::SlotToReg.new( source , right , Parfait::TYPE_INDEX, right)
|
||||||
|
end
|
||||||
|
raise "Can't have slots into Constants #{slots}" if slots.length > 1
|
||||||
when Parfait::Object , Risc::Label
|
when Parfait::Object , Risc::Label
|
||||||
const = const = Risc.load_constant(source, known_object , right)
|
const = const = Risc.load_constant(source, known_object , right)
|
||||||
compiler.add_code const
|
compiler.add_code const
|
||||||
|
@ -12,7 +12,7 @@ module Mains
|
|||||||
def self.Qemu
|
def self.Qemu
|
||||||
@Qemu
|
@Qemu
|
||||||
end
|
end
|
||||||
DEBUG = true
|
DEBUG = false
|
||||||
|
|
||||||
# runnable_methods is called by minitest to determine which tests to run
|
# runnable_methods is called by minitest to determine which tests to run
|
||||||
def self.runnable_methods
|
def self.runnable_methods
|
||||||
@ -37,7 +37,7 @@ module Mains
|
|||||||
def self.has_qemu
|
def self.has_qemu
|
||||||
if `uname -a`.include?("torsten")
|
if `uname -a`.include?("torsten")
|
||||||
@Linker = "arm-linux-gnu-ld"
|
@Linker = "arm-linux-gnu-ld"
|
||||||
#return false
|
return false
|
||||||
end
|
end
|
||||||
begin
|
begin
|
||||||
`#{@Qemu} -version`
|
`#{@Qemu} -version`
|
||||||
|
@ -28,7 +28,9 @@ module Risc
|
|||||||
end
|
end
|
||||||
def to_target
|
def to_target
|
||||||
assert @expect , "No output given"
|
assert @expect , "No output given"
|
||||||
RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_target(as_test_main,:interpreter)
|
compiler = RubyX::RubyXCompiler.new(RubyX.default_test_options)
|
||||||
|
vool = compiler.ruby_to_vool(as_test_main)
|
||||||
|
compiler.to_target(:interpreter)
|
||||||
end
|
end
|
||||||
def produce_main
|
def produce_main
|
||||||
produce_target(:main)
|
produce_target(:main)
|
||||||
|
@ -23,4 +23,31 @@ module Mom
|
|||||||
assert_equal "[StringConstant]" , @definition.to_s
|
assert_equal "[StringConstant]" , @definition.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
class TestSlotDefinitionConstantType < MiniTest::Test
|
||||||
|
def setup
|
||||||
|
Parfait.boot!(Parfait.default_test_options)
|
||||||
|
@compiler = Risc::FakeCompiler.new
|
||||||
|
@definition = SlotDefinition.new(StringConstant.new("hi") , [:type])
|
||||||
|
@register = @definition.to_register(@compiler , InstructionMock.new)
|
||||||
|
@instruction = @compiler.instructions.first
|
||||||
|
end
|
||||||
|
def test_def_class
|
||||||
|
assert_equal Risc::LoadConstant , @instruction.class
|
||||||
|
end
|
||||||
|
def test_def_register
|
||||||
|
assert_equal :r1 , @instruction.register.symbol
|
||||||
|
end
|
||||||
|
def test_def_const
|
||||||
|
assert_equal "hi" , @instruction.constant.to_string
|
||||||
|
end
|
||||||
|
def test_to_s
|
||||||
|
assert_equal "[StringConstant, type]" , @definition.to_s
|
||||||
|
end
|
||||||
|
def test_def_register2
|
||||||
|
assert_equal :r1 , @compiler.instructions[1].register.symbol
|
||||||
|
end
|
||||||
|
def test_def_next_index
|
||||||
|
assert_equal 0 , @compiler.instructions[1].index
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user