rubyx/lib/melon/compiler.rb
Torsten Ruger aa5f48e3c6 remove instance_names from class again
and use types names instead. For now assuming Object class
2016-12-19 14:20:47 +02:00

26 lines
612 B
Ruby

require_relative "type_collector"
module Melon
class Compiler < AST::Processor
def self.compile input
ast = Parser::Ruby22.parse input
compiler = self.new
compiler.process ast
end
def get_name( statement )
return nil unless statement
statement.children[1]
end
def on_class statement
name , sup , body = *statement
clazz = Parfait::Space.object_space.create_class(get_name(name) , get_name(sup) )
ivar_hash = TypeCollector.new.collect(body)
clazz.set_instance_type( Parfait::Type.for_hash( clazz , ivar_hash ) )
end
end
end