37 lines
772 B
Ruby
37 lines
772 B
Ruby
|
module Util
|
||
|
|
||
|
module CompilerList
|
||
|
|
||
|
attr_reader :next_compiler
|
||
|
|
||
|
def add_method_compiler(comp)
|
||
|
raise "not compiler #{comp.class}" unless comp.is_a?(MethodCompiler)
|
||
|
if(@next_compiler)
|
||
|
@next_compiler.add_method_compiler(comp)
|
||
|
else
|
||
|
@next_compiler = comp
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def each_compiler &block
|
||
|
block.yield(self)
|
||
|
@next_compiler.each(&block) if @next_compiler
|
||
|
end
|
||
|
|
||
|
def find_compiler &block
|
||
|
return self if block.yield(self)
|
||
|
@next_compiler.find_compiler(&block) if @next_compiler
|
||
|
end
|
||
|
|
||
|
def last_compiler
|
||
|
return self unless @next_compiler
|
||
|
@next_compiler.last_compiler
|
||
|
end
|
||
|
|
||
|
def num_compilers
|
||
|
1 + (@next_compiler ? @next_compiler.num_compilers : 0)
|
||
|
end
|
||
|
|
||
|
end
|
||
|
end
|