rubyx/stash/rubyx/passes/method_collector.rb
Torsten Ruger 112ec26bd1 deprecating ruby package
to be replaced by vool and mom
2017-08-31 16:18:59 +03:00

39 lines
837 B
Ruby

module Rubyx
module Passes
class MethodCollector < TotalProcessor
def initialize
@methods = []
end
def collect(statement)
process statement
@methods
end
def on_def(statement)
name , args , body = *statement
args_type = make_type(args)
locals_type = make_locals(body)
@methods << Vool::VoolMethod.new(name , args_type , locals_type , body )
end
private
def make_type( statement )
type_hash = {}
statement.children.each do |arg|
type_hash[arg.children[0]] = :Object
end
Parfait::NamedList.type_for( type_hash )
end
def make_locals(body)
type_hash = LocalsCollector.new.collect(body)
Parfait::NamedList.type_for( type_hash )
end
end
end
end