bit more method collector/creation testing

This commit is contained in:
Torsten Ruger
2017-01-13 22:16:06 +02:00
parent 3f6c1bc3a3
commit 75c7ca950e
5 changed files with 31 additions and 16 deletions

View File

@ -17,7 +17,7 @@ module Melon
def add_local(statement)
var = statement.children[0]
@locals[var] = :Object #guess, can maybe guess better
@locals[var] = :Object #not really used right now
end
end

View File

@ -21,20 +21,16 @@ module Melon
private
def make_type( statement )
type = Parfait.object_space.get_class_by_name(:Message ).instance_type
type_hash = {}
statement.children.each do |arg|
type = type.add_instance_variable( arg.children[0] , :Object )
type_hash[arg.children[0]] = :Object
end
type
Parfait::NamedList.type_for( type_hash )
end
def make_locals(body)
locals = LocalsCollector.new.collect(body)
type = Parfait.object_space.get_class_by_name(:NamedList ).instance_type
locals.each do |name , local_type |
type = type.add_instance_variable( name , local_type )
end
type
type_hash = LocalsCollector.new.collect(body)
Parfait::NamedList.type_for( type_hash )
end
end
end

View File

@ -2,10 +2,10 @@ module Melon
class RubyMethod
attr_reader :name , :args_type , :locals_type , :body
attr_reader :name , :args_type , :locals_type , :source
def initialize(name , args_type , locals_type , body )
@name , @args_type , @locals_type , @body = name , args_type, locals_type , body
def initialize(name , args_type , locals_type , source )
@name , @args_type , @locals_type , @source = name , args_type, locals_type , source
end
end