combining sources at vool level

using ScopeStatements
(those unfortunately don't go to_mom)
This commit is contained in:
Torsten Ruger 2018-11-02 12:36:23 -07:00
parent 52f6f1eaa8
commit 1377bda641
2 changed files with 30 additions and 8 deletions

View File

@ -83,7 +83,14 @@ module RubyX
# ruby_to_vool compiles the ruby to ast, and then to vool
def ruby_to_vool(ruby_source)
ruby_tree = Ruby::RubyCompiler.compile( ruby_source )
@vool = ruby_tree.to_vool
unless(@vool)
@vool = ruby_tree.to_vool
return @vool
end
unless(@vool.is_a?(Vool::ScopeStatement))
@vool = Vool::ScopeStatement.new([@vool])
end
@vool << ruby_tree.to_vool
end

View File

@ -5,16 +5,31 @@ module RubyX
include ScopeHelper
include RubyXHelper
def setup
# code = "class Space ; def main(arg);return arg;end; end"
# @compiler = ruby_to_binary(code, :interpreter)
def space_source_for( name )
"class Space ; def #{name}(arg);return arg;end; end"
end
def test_to_binary
code = "class Space ; def main(arg);return arg;end; end"
@linker = RubyXCompiler.ruby_to_binary(code, :interpreter)
def test_return_linker
@linker = RubyXCompiler.ruby_to_binary(space_source_for("main"), :interpreter)
assert_equal Risc::Linker , @linker.class
end
def test_method
def test_one_vool_call
compiler = RubyXCompiler.new
compiler.ruby_to_vool(space_source_for("main"))
assert_equal Vool::ClassStatement , compiler.vool.class
end
def test_two_vool_calls
compiler = RubyXCompiler.new
compiler.ruby_to_vool(space_source_for("main"))
compiler.ruby_to_vool(space_source_for("twain"))
assert_equal Vool::ScopeStatement , compiler.vool.class
assert_equal 2 , compiler.vool.length
end
def test_bin_two_sources
compiler = RubyXCompiler.new
compiler.ruby_to_vool(space_source_for("main"))
compiler.ruby_to_vool(space_source_for("twain"))
# linker = compiler.to_binary(:interpreter)
# assert_equal Vool::ScopeStatement , linker.class
end
end
end