diff --git a/lib/vool/class_method_statement.rb b/lib/vool/class_method_statement.rb index d7a8aaf0..5737058d 100644 --- a/lib/vool/class_method_statement.rb +++ b/lib/vool/class_method_statement.rb @@ -20,15 +20,9 @@ module Vool @body.each(&block) end - def has_yield? - each{|statement| return true if statement.is_a?(YieldStatement)} - return false - end - def make_arg_type( ) type_hash = {} @args.each {|arg| type_hash[arg] = :Object } - type_hash[:implicit_block] = :Block if has_yield? Parfait::NamedList.type_for( type_hash ) end @@ -42,10 +36,6 @@ module Vool def make_frame nodes = [] @body.each { |node| nodes << node } - nodes.dup.each do |node| - next unless node.is_a?(BlockStatement) - node.each {|block_scope| nodes.delete(block_scope)} - end type_hash = {} nodes.each do |node| next unless node.is_a?(LocalVariable) or node.is_a?(LocalAssignment) diff --git a/lib/vool/class_statement.rb b/lib/vool/class_statement.rb index 049392bb..dd43efd0 100644 --- a/lib/vool/class_statement.rb +++ b/lib/vool/class_statement.rb @@ -20,7 +20,9 @@ module Vool def to_mom( _ ) create_class_object method_compilers = body.statements.collect do |node| - raise "Only methods for now #{node}" unless node.is_a?(MethodStatement) + unless node.is_a?(MethodStatement) or node.is_a?(ClassMethodStatement) + raise "Only methods for now #{node.class}:#{node}" + end node.to_mom(@clazz) end Mom::MomCompiler.new(method_compilers) diff --git a/lib/vool/variables.rb b/lib/vool/variables.rb index 42c94fa1..cea85af7 100644 --- a/lib/vool/variables.rb +++ b/lib/vool/variables.rb @@ -39,5 +39,14 @@ module Vool class ModuleName < Expression include Named + def ct_type + get_named_class.instance_type + end + def slot_definition(_) + return Mom::SlotDefinition.new( get_named_class, []) + end + def get_named_class + Parfait.object_space.get_class_by_name(self.name) + end end end diff --git a/test/vool/blocks/test_class_blocks.rb b/test/vool/blocks/test_class_blocks.rb new file mode 100644 index 00000000..b90e762b --- /dev/null +++ b/test/vool/blocks/test_class_blocks.rb @@ -0,0 +1,23 @@ +require_relative "../helper" + +module VoolBlocks + class TestClassAssignMom < MiniTest::Test + include MomCompile + + def setup + Parfait.boot!(Parfait.default_test_options) + end + def as_class_method(source) + "class Space;def self.main();#{source};end;end" + end + def test_block_not_compiles + source = "main{|val| val = 0}" + vool = Ruby::RubyCompiler.compile( as_class_method(source) ).to_vool + begin + vool.to_mom(nil) + rescue => err + assert err.message.include?("Blocks") + end + end + end +end diff --git a/test/vool/send/test_send_class.rb b/test/vool/send/test_send_class.rb new file mode 100644 index 00000000..7fabfd20 --- /dev/null +++ b/test/vool/send/test_send_class.rb @@ -0,0 +1,30 @@ +require_relative "helper" + +module Vool + class TestSendClassMom < MiniTest::Test + include SimpleSendHarness + include Mom + + def send_method + "Object.get_internal_word(0)" + end + def test_receiver + assert_equal SlotDefinition, @ins.next.receiver.class + end + def test_arg_one + assert_equal SlotLoad, @ins.next(1).arguments[0].class + end + def test_call_two + assert_equal SimpleCall, @ins.next(2).class + end + def test_call_has_method + assert_equal Parfait::CallableMethod, @ins.next(2).method.class + end + def test_call_has_right_method + assert_equal :get_internal_word, @ins.next(2).method.name + end + def test_call_has_right_receiver + assert_equal "Object_Type", @ins.next(2).method.self_type.name + end + end +end