diff --git a/lib/rubyx/rubyx_compiler.rb b/lib/rubyx/rubyx_compiler.rb index f938dc6d..1c7e6a5a 100644 --- a/lib/rubyx/rubyx_compiler.rb +++ b/lib/rubyx/rubyx_compiler.rb @@ -87,6 +87,8 @@ module RubyX @vool = ruby_tree.to_vool return @vool end + # TODO: should check if this works with reopening classes + # or whether we need to unify the vool for a class unless(@vool.is_a?(Vool::ScopeStatement)) @vool = Vool::ScopeStatement.new([@vool]) end diff --git a/lib/vool/statements.rb b/lib/vool/statements.rb index 60484f74..358bda4d 100644 --- a/lib/vool/statements.rb +++ b/lib/vool/statements.rb @@ -31,15 +31,19 @@ module Vool @statements = [o] + @statements end - # create mom instructions + # to_mom all the statements. Append subsequent ones to the first, and return the + # first. + # + # For ClassStatements this creates and returns a MomCompiler + # def to_mom( compiler ) raise "Empty list ? #{statements.length}" if empty? stats = @statements.dup - flat = stats.shift.to_mom(compiler) + first = stats.shift.to_mom(compiler) while( nekst = stats.shift ) - flat.append nekst.to_mom(compiler) + first.append nekst.to_mom(compiler) end - flat + first end def each(&block) diff --git a/test/rubyx/test_rubyx_compiler2.rb b/test/rubyx/test_rubyx_compiler2.rb index 373d8fa1..87e13fef 100644 --- a/test/rubyx/test_rubyx_compiler2.rb +++ b/test/rubyx/test_rubyx_compiler2.rb @@ -16,5 +16,8 @@ module RubyX def test_method assert_equal :main , @linker.assemblers.first.callable.name end + def test_asm_len + assert_equal 23 , @linker.assemblers.length + end end end diff --git a/test/rubyx/test_rubyx_compiler3.rb b/test/rubyx/test_rubyx_compiler3.rb index dff6e7f6..e971fd9c 100644 --- a/test/rubyx/test_rubyx_compiler3.rb +++ b/test/rubyx/test_rubyx_compiler3.rb @@ -28,8 +28,9 @@ module RubyX 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 + linker = compiler.to_binary(:interpreter) + assert_equal Risc::Linker , linker.class + assert_equal 24 , linker.assemblers.length end end end