combining sources at vool level
using ScopeStatements (those unfortunately don't go to_mom)
This commit is contained in:
parent
52f6f1eaa8
commit
1377bda641
@ -83,7 +83,14 @@ module RubyX
|
|||||||
# ruby_to_vool compiles the ruby to ast, and then to vool
|
# ruby_to_vool compiles the ruby to ast, and then to vool
|
||||||
def ruby_to_vool(ruby_source)
|
def ruby_to_vool(ruby_source)
|
||||||
ruby_tree = Ruby::RubyCompiler.compile( 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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,16 +5,31 @@ module RubyX
|
|||||||
include ScopeHelper
|
include ScopeHelper
|
||||||
include RubyXHelper
|
include RubyXHelper
|
||||||
|
|
||||||
def setup
|
def space_source_for( name )
|
||||||
# code = "class Space ; def main(arg);return arg;end; end"
|
"class Space ; def #{name}(arg);return arg;end; end"
|
||||||
# @compiler = ruby_to_binary(code, :interpreter)
|
|
||||||
end
|
end
|
||||||
def test_to_binary
|
def test_return_linker
|
||||||
code = "class Space ; def main(arg);return arg;end; end"
|
@linker = RubyXCompiler.ruby_to_binary(space_source_for("main"), :interpreter)
|
||||||
@linker = RubyXCompiler.ruby_to_binary(code, :interpreter)
|
|
||||||
assert_equal Risc::Linker , @linker.class
|
assert_equal Risc::Linker , @linker.class
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user