use compiler base class for blocks too

can now go to mom level and add
test harness still looks overly complicated, but works
first block tests at mom level
This commit is contained in:
Torsten Ruger
2018-07-10 22:03:32 +03:00
parent a3e758357c
commit 27a142f2a3
4 changed files with 34 additions and 12 deletions

View File

@ -38,8 +38,16 @@ module MomCompile
@method.source.to_mom( compiler )
end
def compile_first_block( block_input )
mom = compile_first_method( "main_local = 5 ; self.main{|val| #{block_input}}")
mom.next(4) # ignore local assign (1) and call (3)
source = "main_local = 5 ; self.main{|val| #{block_input}}"
vool = RubyX::RubyCompiler.compile( as_test_main(source) ).normalize
mom_c = vool.to_mom(nil)
compiler = mom_c.method_compilers.find{|c| c.get_method.name == :main and c.get_method.self_type.object_class.name == :Test}
block = nil
vool.each {|b| block = b if b.is_a?(Vool::BlockStatement)}
assert block
block_c = compiler.block_compilers.first
assert block_c
block.body.to_mom(block_c)
end
def compile_mom(input)
Risc.boot!