fix platform derivation and some tests
This commit is contained in:
parent
bb49f1be78
commit
5f2a256608
@ -1,6 +1,6 @@
|
|||||||
require_relative "translator"
|
require_relative "translator"
|
||||||
module Arm
|
module Arm
|
||||||
class ArmPlatform
|
class ArmPlatform < Risc::Platform
|
||||||
def translator
|
def translator
|
||||||
Translator.new
|
Translator.new
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
module Risc
|
module Risc
|
||||||
class InterpreterPlatform
|
class InterpreterPlatform < Platform
|
||||||
def translator
|
def translator
|
||||||
IdentityTranslator.new
|
IdentityTranslator.new
|
||||||
end
|
end
|
||||||
|
@ -13,7 +13,13 @@ module Risc
|
|||||||
include Util::Logging
|
include Util::Logging
|
||||||
log_level :info
|
log_level :info
|
||||||
|
|
||||||
def initialize
|
def initialize(platform)
|
||||||
|
if(platform.is_a?(Symbol))
|
||||||
|
platform = platform.to_s.capitalize
|
||||||
|
platform = Risc::Platform.for(platform)
|
||||||
|
end
|
||||||
|
raise "Platform must be platform, not #{platform.class}" unless platform.is_a?(Platform)
|
||||||
|
@platform = platform
|
||||||
@risc_init = nil
|
@risc_init = nil
|
||||||
@constants = []
|
@constants = []
|
||||||
end
|
end
|
||||||
|
@ -27,9 +27,9 @@ module RubyX
|
|||||||
def ruby_to_binary(platform = :arm)
|
def ruby_to_binary(platform = :arm)
|
||||||
Parfait.boot!
|
Parfait.boot!
|
||||||
Risc.boot!
|
Risc.boot!
|
||||||
assemblers = ruby_to_mom(platform)
|
assemblers = ruby_to_mom
|
||||||
puts "Assemblers #{assemblers}"
|
puts "Assemblers #{assemblers}"
|
||||||
linker = Linker.new
|
linker = Risc::Linker.new(platform)
|
||||||
linker.position_all
|
linker.position_all
|
||||||
linker.create_binary
|
linker.create_binary
|
||||||
end
|
end
|
||||||
|
@ -6,7 +6,7 @@ module Risc
|
|||||||
def setup
|
def setup
|
||||||
Parfait.boot!
|
Parfait.boot!
|
||||||
Risc.boot!
|
Risc.boot!
|
||||||
@machine = Linker.new
|
@machine = Linker.new(:arm)
|
||||||
end
|
end
|
||||||
def test_objects
|
def test_objects
|
||||||
objects = @machine.object_positions
|
objects = @machine.object_positions
|
||||||
@ -20,11 +20,12 @@ module Risc
|
|||||||
assert @machine.add_constant( Parfait::Integer.new(5) )
|
assert @machine.add_constant( Parfait::Integer.new(5) )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class TestMachinePos #< MiniTest::Test
|
class TestMachinePos < MiniTest::Test
|
||||||
def setup
|
def setup
|
||||||
Parfait.boot!
|
Parfait.boot!
|
||||||
@machine = Risc.machine.boot
|
Risc.boot!
|
||||||
@machine.translate(:arm)
|
@linker = Linker.new(:arm)
|
||||||
|
@linker.translate
|
||||||
@machine.position_all
|
@machine.position_all
|
||||||
end
|
end
|
||||||
def test_positions_set
|
def test_positions_set
|
||||||
|
@ -9,7 +9,7 @@ module Risc
|
|||||||
def setup
|
def setup
|
||||||
Parfait.boot!
|
Parfait.boot!
|
||||||
Risc.boot!
|
Risc.boot!
|
||||||
RubyX::RubyXCompiler.ruby_to_binary( @string_input , :interpreter)
|
RubyX::RubyXCompiler.new(@string_input).ruby_to_binary( :interpreter)
|
||||||
@interpreter = Interpreter.new
|
@interpreter = Interpreter.new
|
||||||
@interpreter.start_machine
|
@interpreter.start_machine
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user