test correct instance_type creation
so ivar collection happens and a type is created from the names
This commit is contained in:
parent
96f8bf61ca
commit
af196c17d3
@ -16,11 +16,14 @@ module Vool
|
||||
@clazz = Parfait.object_space.get_class_by_name(@name )
|
||||
if(@clazz)
|
||||
#FIXME super class check with "sup"
|
||||
else #existing class, don't overwrite type (parfait only?)
|
||||
#existing class, don't overwrite type (parfait only?)
|
||||
else
|
||||
@clazz = Parfait.object_space.create_class(@name , @super_class_name )
|
||||
#FIXME
|
||||
# ivar_hash = Passes::TypeCollector.new.collect(body)
|
||||
# @clazz.set_instance_type( Parfait::Type.for_hash( clazz , ivar_hash ) )
|
||||
vars = []
|
||||
@body.collect([]).each { |node| node.add_ivar(vars) }
|
||||
ivar_hash = {}
|
||||
vars.each { |var| ivar_hash[var] = :Object }
|
||||
@clazz.set_instance_type( Parfait::Type.for_hash( @clazz , ivar_hash ) )
|
||||
end
|
||||
body.collect([]).each {|node| node.set_class(@clazz) }
|
||||
body.create_objects
|
||||
|
@ -7,7 +7,6 @@ module Vool
|
||||
end
|
||||
|
||||
def collect(arr)
|
||||
@args.each{ |arg| arg.collect(arr)}
|
||||
@body.collect(arr)
|
||||
super
|
||||
end
|
||||
@ -28,22 +27,15 @@ module Vool
|
||||
|
||||
def make_type( )
|
||||
type_hash = {}
|
||||
@args.each do |arg|
|
||||
puts "ARG #{arg}"
|
||||
type_hash[arg.children[0]] = :Object
|
||||
end
|
||||
@args.each {|arg| type_hash[arg.children[0]] = :Object }
|
||||
Parfait::NamedList.type_for( type_hash )
|
||||
end
|
||||
|
||||
def make_locals
|
||||
type_hash = {}
|
||||
vars = []
|
||||
@body.collect([]).each do |node|
|
||||
node.add_local(vars)
|
||||
end
|
||||
vars.each do |var|
|
||||
type_hash[var] = :Object
|
||||
end
|
||||
@body.collect([]).each { |node| node.add_local(vars) }
|
||||
vars.each { |var| type_hash[var] = :Object }
|
||||
Parfait::NamedList.type_for( type_hash )
|
||||
end
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
require_relative "helper"
|
||||
require_relative "test_ivar_collect"
|
||||
require_relative "test_local_collect"
|
||||
require_relative "test_class_compiler"
|
||||
require_relative "test_method_compiler"
|
||||
|
29
test/vool/compilers/test_class_compiler.rb
Normal file
29
test/vool/compilers/test_class_compiler.rb
Normal file
@ -0,0 +1,29 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestClassCompiler < MiniTest::Test
|
||||
include CompilerHelper
|
||||
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
end
|
||||
|
||||
def compile_in_test input
|
||||
VoolCompiler.compile in_Test(input)
|
||||
itest = Parfait.object_space.get_class_by_name(:Test)
|
||||
assert itest
|
||||
itest
|
||||
end
|
||||
|
||||
def test_compile_class_one
|
||||
itest = compile_in_test "def meth; @ivar; end"
|
||||
assert itest.instance_type.names.include?(:ivar) , itest.instance_type.names.inspect
|
||||
end
|
||||
|
||||
def test_compile_class_two
|
||||
itest = compile_in_test "def meth; @ivar; end;def meth2(arg); @trivar = 5; end"
|
||||
assert itest.instance_type.names.include?(:trivar) , itest.instance_type.names.inspect
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -1,7 +1,7 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestVoolCompiler < MiniTest::Test
|
||||
class TestMethodCompiler < MiniTest::Test
|
||||
include CompilerHelper
|
||||
|
||||
def setup
|
||||
|
Loading…
Reference in New Issue
Block a user