diff --git a/lib/vool/class_expression.rb b/lib/vool/class_expression.rb index 3cfd5cd8..018239c7 100644 --- a/lib/vool/class_expression.rb +++ b/lib/vool/class_expression.rb @@ -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}" diff --git a/lib/vool/class_method_expression.rb b/lib/vool/class_method_expression.rb index 9b4ab97e..9ba05ca4 100644 --- a/lib/vool/class_method_expression.rb +++ b/lib/vool/class_method_expression.rb @@ -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 diff --git a/lib/vool/lambda_expression.rb b/lib/vool/lambda_expression.rb index 7dc1d424..3f5b9391 100644 --- a/lib/vool/lambda_expression.rb +++ b/lib/vool/lambda_expression.rb @@ -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 diff --git a/lib/vool/method_expression.rb b/lib/vool/method_expression.rb index 96abf790..98d829b4 100644 --- a/lib/vool/method_expression.rb +++ b/lib/vool/method_expression.rb @@ -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 = {} diff --git a/lib/vool/send_statement.rb b/lib/vool/send_statement.rb index 15f4dd49..2a7ffff3 100644 --- a/lib/vool/send_statement.rb +++ b/lib/vool/send_statement.rb @@ -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 ) diff --git a/test/vool/test_class_expression.rb b/test/vool/test_class_expression.rb index b3656d3c..e2d94a0a 100644 --- a/test/vool/test_class_expression.rb +++ b/test/vool/test_class_expression.rb @@ -10,10 +10,10 @@ module Vool @vool = ruby_tree.to_vool end def test_class - assert_equal ClassStatement , @vool.class + assert_equal ClassExpression , @vool.class end def test_method - assert_equal MethodStatement , @vool.body.first.class + assert_equal MethodExpression , @vool.body.first.class end def test_create_class assert_equal Parfait::Class , @vool.create_class_object.class @@ -33,7 +33,7 @@ module Vool def assert_type_for(input) ruby_tree = Ruby::RubyCompiler.compile( as_test_main(input) ) vool = ruby_tree.to_vool - assert_equal ClassStatement , vool.class + assert_equal ClassExpression , vool.class clazz = vool.create_class_object assert_equal Parfait::Class , clazz.class assert_equal :a , clazz.instance_type.names[1] diff --git a/test/vool/test_method_expression.rb b/test/vool/test_method_expression.rb index dcbf7813..84fbfb53 100644 --- a/test/vool/test_method_expression.rb +++ b/test/vool/test_method_expression.rb @@ -13,9 +13,9 @@ module Vool @clazz.body.first end def test_setup - assert_equal ClassStatement , @clazz.class + assert_equal ClassExpression , @clazz.class assert_equal Statements , @clazz.body.class - assert_equal MethodStatement , method.class + assert_equal MethodExpression , method.class end def test_class assert_equal Parfait::Class , @clazz.create_class_object.class