Move booting to RubyXCompiler init

Also pass the source into the compile method.
This way compiler can be reused for subsequent compile.
Does remove some double boots, but no major time save
This commit is contained in:
Torsten Ruger
2018-09-02 13:57:19 +03:00
parent d73e1526cd
commit 8a81d41d5e
14 changed files with 39 additions and 57 deletions

View File

@ -19,7 +19,7 @@ module Risc
end
class TestLinkerInit < MiniTest::Test
def setup
@linker = RubyX::RubyXCompiler.new("class Space;def main;return 1;end;end").ruby_to_binary(:arm)
@linker = RubyX::RubyXCompiler.new.ruby_to_binary("class Space;def main;return 1;end;end",:arm)
end
def test_pos_cpu
assert_equal 0 , Position.get(@linker.cpu_init).at

View File

@ -3,9 +3,8 @@ require_relative "helper"
module Risc
class TestMachinePos < MiniTest::Test
def setup
Parfait.boot!
Risc.boot!
@linker = RubyX::RubyXCompiler.new("class Space; def main(arg);a = 1;return a;end;end").ruby_to_risc(:arm)
code = "class Space; def main(arg);a = 1;return a;end;end"
@linker = RubyX::RubyXCompiler.new.ruby_to_risc(code,:arm)
@linker.position_all
end
def test_positions_set

View File

@ -5,11 +5,10 @@ module Risc
include ScopeHelper
def setup
Parfait.boot!
end
def in_test_vool(str)
vool = RubyX::RubyXCompiler.new(in_Test(str)).ruby_to_vool
vool = RubyX::RubyXCompiler.new.ruby_to_vool(in_Test(str))
vool.to_mom(nil)
vool
end
@ -65,7 +64,7 @@ module Risc
assert_equal 2 , method.frame_type.variable_index(:a)
end
def constant_setup(input)
mom = RubyX::RubyXCompiler.new(in_Test(input)).ruby_to_mom
mom = RubyX::RubyXCompiler.new.ruby_to_mom(in_Test(input))
assert_equal Mom::MomCompiler , mom.class
compiler = mom.method_compilers.first
assert_equal MethodCompiler , compiler.class