Move vool block compilation into constant generation
When the lambda is passed as argument, it must be moved. This triggers the generation of a corresponding parfait object (as before, and as for other constants) but now also triggers the code build. The code being the constant as it were Also some more name fixes from renames
This commit is contained in:
@ -34,9 +34,9 @@ module Vool
|
||||
create_class_object
|
||||
method_compilers = body.statements.collect do |node|
|
||||
case node
|
||||
when MethodStatement
|
||||
when MethodExpression
|
||||
node.to_mom(@clazz)
|
||||
when ClassMethodStatement
|
||||
when ClassMethodExpression
|
||||
node.to_mom(@clazz.meta_class)
|
||||
else
|
||||
raise "Only methods for now #{node.class}:#{node}"
|
||||
|
@ -13,7 +13,7 @@ module Vool
|
||||
method = clazz.add_method_for(name , make_arg_type , make_frame , body )
|
||||
#VoolMethod
|
||||
compiler = method.compiler_for(clazz.instance_type)
|
||||
each {|node| raise "Blocks not implemented" if node.is_a?(BlockStatement)}
|
||||
each {|node| raise "Blocks not implemented" if node.is_a?(LambdaExpression)}
|
||||
compiler
|
||||
end
|
||||
|
||||
|
@ -14,14 +14,16 @@ module Vool
|
||||
# This means we do the compiler here (rather than to_mom, which is in
|
||||
# fact never called)
|
||||
def to_slot(compiler)
|
||||
compile(compiler) unless @parfait_block
|
||||
return Mom::SlotDefinition.new(Mom::LambdaConstant.new(parfait_block(compiler)) , [])
|
||||
end
|
||||
|
||||
# create a block, a compiler for it, comile the bock and add the compiler(code)
|
||||
# to the method compiler for further processing
|
||||
def to_mom( compiler )
|
||||
def compile( compiler )
|
||||
parfait_block = self.parfait_block(compiler)
|
||||
block_compiler = Mom::BlockCompiler.new( parfait_block , compiler.get_method )
|
||||
compiler.add_block_compiler(block_compiler)
|
||||
head = body.to_mom( block_compiler )
|
||||
block_compiler.add_code(head)
|
||||
block_compiler
|
||||
|
@ -52,7 +52,7 @@ module Vool
|
||||
nodes = []
|
||||
@body.each { |node| nodes << node }
|
||||
nodes.dup.each do |node|
|
||||
next unless node.is_a?(BlockStatement)
|
||||
next unless node.is_a?(LambdaExpression)
|
||||
node.each {|block_scope| nodes.delete(block_scope)}
|
||||
end
|
||||
type_hash = {}
|
||||
|
@ -10,12 +10,11 @@ module Vool
|
||||
# As cache key we must use the type of the object (which is the first word of _every_ object)
|
||||
# as that is constant, and function implementations depend on the type (not class)
|
||||
class SendStatement < CallStatement
|
||||
attr_reader :block
|
||||
|
||||
def block
|
||||
return nil if arguments.empty?
|
||||
bl = arguments.last
|
||||
bl.is_a?(BlockStatement) ? bl : nil
|
||||
bl.is_a?(LambdaExpression) ? bl : nil
|
||||
end
|
||||
|
||||
def add_block( block )
|
||||
|
Reference in New Issue
Block a user