start on collector for local variables
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
require_relative "compiler/total_processor"
|
||||
require_relative "compiler/type_collector"
|
||||
require_relative "compiler/method_collector"
|
||||
require_relative "compiler/locals_collector"
|
||||
require_relative "compiler/ruby_method"
|
||||
|
||||
|
||||
|
24
lib/melon/compiler/locals_collector.rb
Normal file
24
lib/melon/compiler/locals_collector.rb
Normal file
@ -0,0 +1,24 @@
|
||||
module Melon
|
||||
|
||||
class LocalsCollector < TotalProcessor
|
||||
|
||||
def initialize
|
||||
@locals = {}
|
||||
end
|
||||
|
||||
def collect(statement)
|
||||
process statement
|
||||
@locals
|
||||
end
|
||||
|
||||
def on_lvasgn statement
|
||||
add_local( statement )
|
||||
end
|
||||
|
||||
def add_local(statement)
|
||||
var = statement.children[0]
|
||||
@locals[var] = :Object #guess, can maybe guess better
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user