bringing the locals into the ruby method

This commit is contained in:
Torsten Ruger
2016-12-21 11:30:35 +02:00
parent 9ec9ccb9b6
commit b242f9e223
3 changed files with 22 additions and 6 deletions

View File

@ -14,9 +14,12 @@ module Melon
def on_def(statement)
name , args , body = *statement
args_type = make_type(args)
@methods << RubyMethod.new(name , args_type , body )
locals_type = make_locals(body)
@methods << RubyMethod.new(name , args_type , locals_type , body )
end
private
def make_type( statement )
type = Parfait::Space.object_space.get_class_by_name(:Message ).instance_type
statement.children.each do |arg|
@ -25,5 +28,13 @@ module Melon
type
end
def make_locals(body)
locals = LocalsCollector.new.collect(body)
type = Parfait::Space.object_space.get_class_by_name(:Frame ).instance_type
locals.each do |name , local_type |
type = type.add_instance_variable( name , local_type )
end
type
end
end
end

View File

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