push the callable into the callable compiler

thus generalizing for .callable access
keep block and method aliases for destinction in derived classes
This commit is contained in:
Torsten Ruger
2018-07-30 10:26:11 +03:00
parent 285a88b59f
commit 2dc03f8d1b
5 changed files with 32 additions and 29 deletions

View File

@ -22,7 +22,6 @@ module Vool
def to_mom( compiler )
parfait_block = self.parfait_block(compiler)
block_compiler = Risc::BlockCompiler.new( parfait_block , compiler.get_method )
compiler.add_block_compiler(block_compiler)
head = body.to_mom( block_compiler )
block_compiler.add_mom(head)
block_compiler

View File

@ -1,19 +1,19 @@
module Vool
class MethodStatement < Statement
attr_reader :name, :args , :body , :clazz
attr_reader :name, :args , :body
def initialize( name , args , body , clazz = nil)
def initialize( name , args , body )
@name , @args , @body = name , args , body
raise "no bod" unless @body
@clazz = clazz
end
def to_mom(clazz)
@clazz = clazz || raise( "no class in #{self}")
method = @clazz.add_method_for(name , make_arg_type , make_frame , body )
raise( "no class in #{self}") unless clazz
method = clazz.add_method_for(name , make_arg_type , make_frame , body )
compiler = method.compiler_for(clazz.instance_type)
each do |node| ## TODO: must account for nested blocks (someday)
node.to_mom(compiler) if node.is_a?(BlockStatement)
next unless node.is_a?(BlockStatement)
compiler.block_compilers << node.to_mom(compiler)
end
compiler
end