extracting processor comonality before adding a third
This commit is contained in:
parent
cfa0c23373
commit
8b05951883
@ -1,3 +1,4 @@
|
||||
require_relative "compiler/total_processor"
|
||||
require_relative "compiler/type_collector"
|
||||
require_relative "compiler/method_collector"
|
||||
require_relative "compiler/ruby_method"
|
||||
|
@ -1,6 +1,6 @@
|
||||
module Melon
|
||||
|
||||
class MethodCollector < AST::Processor
|
||||
class MethodCollector < TotalProcessor
|
||||
|
||||
def initialize
|
||||
@methods = []
|
||||
@ -25,11 +25,5 @@ module Melon
|
||||
type
|
||||
end
|
||||
|
||||
def handler_missing(node)
|
||||
node.children.each do |kid |
|
||||
process(kid) if kid.is_a?(AST::Node)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
12
lib/melon/compiler/total_processor.rb
Normal file
12
lib/melon/compiler/total_processor.rb
Normal file
@ -0,0 +1,12 @@
|
||||
module Melon
|
||||
|
||||
class TotalProcessor < AST::Processor
|
||||
|
||||
def handler_missing(node)
|
||||
node.children.each do |kid |
|
||||
process(kid) if kid.is_a?(AST::Node)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -1,6 +1,6 @@
|
||||
module Melon
|
||||
|
||||
class TypeCollector < AST::Processor
|
||||
class TypeCollector < TotalProcessor
|
||||
|
||||
def initialize
|
||||
@ivars = {}
|
||||
@ -24,10 +24,5 @@ module Melon
|
||||
@ivars[var] = :Object #guess, can maybe guess better
|
||||
end
|
||||
|
||||
def handler_missing(node)
|
||||
node.children.each do |kid |
|
||||
process(kid) if kid.is_a?(AST::Node)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user