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

@ -3,20 +3,18 @@ require_relative "../helper"
module RubyX
module RubyXHelper
def setup
Parfait.boot!
Risc.boot!
end
def ruby_to_risc(input , platform)
mom = ruby_to_mom(input)
mom.translate(platform)
end
def ruby_to_vool(input)
RubyXCompiler.new(input).ruby_to_vool
RubyXCompiler.new.ruby_to_vool(input)
end
def ruby_to_mom(input)
RubyXCompiler.new(input).ruby_to_mom
RubyXCompiler.new.ruby_to_mom(input)
end
def compile_in_test input
def compile_in_test( input )
vool = ruby_to_vool in_Test(input)
vool.to_mom(nil)
itest = Parfait.object_space.get_class_by_name(:Test)

View File

@ -15,13 +15,6 @@ module RubyX
assert itest.instance_type.names.include?(:trivar) , itest.instance_type.names.inspect
end
def test_doesnt_create_existing_clas
space_class = Parfait.object_space.get_class_by_name(:Space)
ruby_to_vool "class Space ; end"
clazz = Parfait.object_space.get_class_by_name(:Space)
assert_equal clazz , space_class
end
def test_class_body_is_scope
clazz = ruby_to_vool in_Test("def meth; @ivar = 5 ;end")
assert_equal Vool::Statements , clazz.body.class
@ -29,15 +22,17 @@ module RubyX
end
def test_space_is_unchanged_by_compile
compiler = RubyXCompiler.new
space1 = Parfait.object_space.get_class_by_name(:Space)
ruby_to_vool "class Space ;end"
compiler.ruby_to_vool "class Space ;end"
space2 = Parfait.object_space.get_class_by_name(:Space)
assert_equal space1 , space2
end
def test_space_type_is_unchanged_by_compile
compiler = RubyXCompiler.new
space1 = Parfait.object_space.get_type_by_class_name(:Space)
ruby_to_vool "class Space ;end"
compiler.ruby_to_vool "class Space ;end"
space2 = Parfait.object_space.get_type_by_class_name(:Space)
assert_equal space1 , space2
end

View File

@ -25,8 +25,9 @@ module RubyX
end
def test_space_type_is_unchanged_by_compile
compiler = RubyXCompiler.new
space1 = Parfait.object_space.get_type_by_class_name(:Space)
ruby_to_vool "class Space ;end"
compiler.ruby_to_vool "class Space ;end"
space2 = Parfait.object_space.get_type_by_class_name(:Space)
assert_equal space1 , space2
end