make the interpreter platform
but still using the risc_instruction stream
This commit is contained in:
18
test/arm/test_arm_platform.rb
Normal file
18
test/arm/test_arm_platform.rb
Normal file
@ -0,0 +1,18 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Arm
|
||||
class TestArmPlatform < MiniTest::Test
|
||||
def setup
|
||||
@arm = Risc::Platform.for("Arm")
|
||||
end
|
||||
def test_platform_class
|
||||
assert_equal Arm::ArmPlatform , @arm.class
|
||||
end
|
||||
def test_platform_translator_class
|
||||
assert_equal Arm::Translator , @arm.translator.class
|
||||
end
|
||||
def test_platform_loaded_class
|
||||
assert_equal Fixnum , @arm.loaded_at.class
|
||||
end
|
||||
end
|
||||
end
|
@ -1 +1,4 @@
|
||||
require_relative "../helper"
|
||||
class DevNull
|
||||
def write_unsigned_int_32( _ );end
|
||||
end
|
||||
|
61
test/risc/test_interpreter_platform.rb
Normal file
61
test/risc/test_interpreter_platform.rb
Normal file
@ -0,0 +1,61 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Risc
|
||||
class TestInterpreterPlatform < MiniTest::Test
|
||||
def setup
|
||||
@inter = Platform.for("Interpreter")
|
||||
end
|
||||
def test_platform_class
|
||||
assert_equal Risc::InterpreterPlatform , @inter.class
|
||||
end
|
||||
def test_platform_translator_class
|
||||
assert_equal Risc::IdentityTranslator , @inter.translator.class
|
||||
end
|
||||
def test_platform_loaded_class
|
||||
assert_equal Fixnum , @inter.loaded_at.class
|
||||
end
|
||||
def test_translator
|
||||
assert IdentityTranslator.new
|
||||
end
|
||||
end
|
||||
class TestTranslator < MiniTest::Test
|
||||
|
||||
def setup
|
||||
@machine = Risc.machine.boot
|
||||
@translator = IdentityTranslator.new
|
||||
end
|
||||
|
||||
def test_translate_label
|
||||
label = Parfait.object_space.get_main.risc_instructions
|
||||
assert_equal "Space_Type.main" ,label.to_cpu(@translator).name , label
|
||||
end
|
||||
|
||||
def test_translate_space
|
||||
assert @machine.translate(:interpreter)
|
||||
end
|
||||
|
||||
def test_no_loops_in_chain
|
||||
@machine.translate(:interpreter)
|
||||
@machine.position_all
|
||||
init = Parfait.object_space.get_init
|
||||
all = []
|
||||
init.cpu_instructions.each do |ins|
|
||||
assert !all.include?(ins)
|
||||
all << ins
|
||||
end
|
||||
end
|
||||
def test_no_risc #by assembling, risc doesnt have assemble method
|
||||
@machine.translate(:interpreter)
|
||||
@machine.position_all
|
||||
@machine.create_binary
|
||||
@machine.objects.each do |id , method|
|
||||
next unless method.is_a? Parfait::TypedMethod
|
||||
method.cpu_instructions.each do |ins|
|
||||
ins.assemble(DevNull.new)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
@ -3,23 +3,14 @@ require_relative "../helper"
|
||||
module Risc
|
||||
class TestPlaform < MiniTest::Test
|
||||
|
||||
def test_factory_exists
|
||||
def test_arm_factory_exists
|
||||
assert Platform.for("Arm")
|
||||
end
|
||||
def test_inter_factory_exists
|
||||
assert Platform.for("Interpreter")
|
||||
end
|
||||
def test_factory_raise
|
||||
assert_raises{ Platform.for("NotArm")}
|
||||
end
|
||||
def test_platform_class
|
||||
arm = Platform.for("Arm")
|
||||
assert_equal Arm::ArmPlatform , arm.class
|
||||
end
|
||||
def test_platform_translator_class
|
||||
arm = Platform.for("Arm")
|
||||
assert_equal Arm::Translator , arm.translator.class
|
||||
end
|
||||
def test_platform_loaded_class
|
||||
arm = Platform.for("Arm")
|
||||
assert_equal Fixnum , arm.loaded_at.class
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,8 +1,5 @@
|
||||
require_relative "../helper"
|
||||
require_relative "helper"
|
||||
|
||||
class DevNull
|
||||
def write_unsigned_int_32( _ );end
|
||||
end
|
||||
module Risc
|
||||
class TestTranslator < MiniTest::Test
|
||||
|
||||
|
@ -9,7 +9,7 @@ module Risc
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
do_clean_compile
|
||||
Vool::VoolCompiler.ruby_to_vool( @string_input )
|
||||
Vool::VoolCompiler.ruby_to_binary( @string_input , :interpreter)
|
||||
Collector.collect_space
|
||||
@interpreter = Interpreter.new
|
||||
@interpreter.start Risc.machine.risc_init
|
||||
|
Reference in New Issue
Block a user