return the linker from mom_compiler
linker holds assemblers assemblers come from method compilation and so the layers come into focus
This commit is contained in:
@ -13,7 +13,7 @@ module Mom
|
||||
assert_equal MomCompiler , @comp.class
|
||||
end
|
||||
def test_compilers
|
||||
assert_equal 1 , @comp.method_compilers.length
|
||||
assert_equal 24 , @comp.method_compilers.length
|
||||
end
|
||||
def test_has_translate
|
||||
assert @comp.translate(:interpreter)
|
||||
@ -29,16 +29,19 @@ module Mom
|
||||
end
|
||||
|
||||
def test_translate_class
|
||||
assert_equal Array , @trans.class
|
||||
assert_equal Risc::Linker , @trans.class
|
||||
end
|
||||
def test_translate_platform
|
||||
assert_kind_of Risc::Platform , @trans.platform
|
||||
end
|
||||
def test_translate_assemblers
|
||||
assert_equal Risc::Assembler , @trans.first.class
|
||||
assert_equal Risc::Assembler , @trans.assemblers.first.class
|
||||
end
|
||||
def test_assembler_code
|
||||
assert_equal Risc::Label , @trans.first.instructions.class
|
||||
assert_equal Risc::Label , @trans.assemblers.first.instructions.class
|
||||
end
|
||||
def test_assembler_assembled
|
||||
assert_equal Risc::LoadConstant , @trans.first.instructions.next.class
|
||||
assert_equal Risc::SlotToReg , @trans.assemblers.first.instructions.next.class
|
||||
end
|
||||
end
|
||||
end
|
@ -6,27 +6,23 @@ module Risc
|
||||
def setup
|
||||
Parfait.boot!
|
||||
Risc.boot!
|
||||
@machine = Linker.new(:arm)
|
||||
@linker = Mom::MomCompiler.new.translate(:arm)
|
||||
end
|
||||
def test_objects
|
||||
objects = @machine.object_positions
|
||||
objects = @linker.object_positions
|
||||
assert_equal Hash , objects.class
|
||||
assert 350 < objects.length
|
||||
end
|
||||
def test_constant_fail
|
||||
assert_raises {@machine.add_constant( 1 )}
|
||||
end
|
||||
def test_constant
|
||||
assert @machine.add_constant( Parfait::Integer.new(5) )
|
||||
end
|
||||
end
|
||||
class TestMachinePos < MiniTest::Test
|
||||
def setup
|
||||
Parfait.boot!
|
||||
Risc.boot!
|
||||
@linker = Linker.new(:arm)
|
||||
@linker.translate
|
||||
@machine.position_all
|
||||
@linker = Mom::MomCompiler.new.translate(:arm)
|
||||
@linker.position_all
|
||||
end
|
||||
def test_positions_set
|
||||
@machine.object_positions.each do |obj , position|
|
||||
|
@ -5,11 +5,16 @@ module RubyX
|
||||
include ScopeHelper
|
||||
include RubyXHelper
|
||||
|
||||
def test_to_risc
|
||||
def setup
|
||||
super
|
||||
code = "class Space ; def main(arg);return arg;end; end"
|
||||
risc = ruby_to_risc(code, :interpreter)
|
||||
assert_equal Array , risc.class
|
||||
@linker = ruby_to_risc(code, :interpreter)
|
||||
end
|
||||
def test_to_risc
|
||||
assert_equal Risc::Linker , @linker.class
|
||||
end
|
||||
def test_method
|
||||
assert_equal :main , @linker.assemblers.last.method.name
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -16,5 +16,10 @@ module Vool
|
||||
def test_has_compilers
|
||||
assert_equal Risc::MethodCompiler , @ret.method_compilers.first.class
|
||||
end
|
||||
|
||||
def test_constant
|
||||
assert @ret.method_compilers.first.add_constant( Parfait::Integer.new(5) )
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user