remove instance_names from class again

and use types names instead. For now assuming Object class
This commit is contained in:
Torsten Ruger
2016-12-19 14:20:47 +02:00
parent af9fed863f
commit aa5f48e3c6
5 changed files with 13 additions and 15 deletions

View File

@ -18,7 +18,8 @@ module Melon
def on_class statement
name , sup , body = *statement
clazz = Parfait::Space.object_space.create_class(get_name(name) , get_name(sup) )
clazz.set_instance_names( TypeCollector.new.collect(body) )
ivar_hash = TypeCollector.new.collect(body)
clazz.set_instance_type( Parfait::Type.for_hash( clazz , ivar_hash ) )
end
end
end

View File

@ -3,16 +3,17 @@ module Melon
class TypeCollector < AST::Processor
def initialize
@ivar_names = []
@ivars = {}
end
def collect(statement)
process statement
@ivar_names
@ivars
end
def on_ivar(statement)
@ivar_names.push statement.children[0].to_s[1..-1].to_sym
var = statement.children[0].to_s[1..-1].to_sym
@ivars[var] = :Object #guess, can maybe guess better
end
def handler_missing(node)