fix compiling support

which makes all the vool tests pass again
This commit is contained in:
Torsten Ruger 2018-07-02 15:52:51 +03:00
parent 6a4c90e2bd
commit 4e49c0469c

View File

@ -21,22 +21,25 @@ end
module MomCompile module MomCompile
include ScopeHelper include ScopeHelper
def compile_mom(input) def compile_method(input)
statements = RubyX::RubyXCompiler.new(input).ruby_to_vool statements = RubyX::RubyXCompiler.new(input).ruby_to_vool
res = statements.to_mom(nil) assert statements.is_a?(Vool::ClassStatement)
ret = statements.to_mom(nil)
assert_equal Parfait::Class , statements.clazz.class , statements assert_equal Parfait::Class , statements.clazz.class , statements
@method = statements.clazz.get_method(:main) @method = statements.clazz.get_method(:main)
assert_equal Parfait::VoolMethod , @method.class assert_equal Parfait::VoolMethod , @method.class
res ret
end end
def compile_first_method( input ) def compile_first_method( input )
res = compile_mom( as_test_main( input )) ret = compile_method( as_test_main( input ))
method = res.clazz.instance_methods.first assert_equal Mom::MomCompiler , ret.class
compile_to_mom(method , res.clazz.instance_type) compiler = ret.method_compilers.find{|c| c.method.name == :main and c.method.for_type.object_class.name == :Test}
assert_equal Risc::MethodCompiler , compiler.class
@method.source.to_mom( compiler.method )
end end
def compile_to_mom(method , for_type)
typed_method = method.create_typed_method(for_type) def compile_mom(input)
method.source.to_mom( typed_method ) RubyX::RubyXCompiler.new(input).ruby_to_mom
end end
def check_array( should , is ) def check_array( should , is )