class RDG::CFG
Public Class Methods
from_path(path)
click to toggle source
# File lib/rdg/cfg.rb, line 9 def self.from_path(path) new(Tree::AST.from_path(path)) end
from_source(source)
click to toggle source
# File lib/rdg/cfg.rb, line 13 def self.from_source(source) new(Tree::AST.from_source(source)) end
new(ast)
click to toggle source
# File lib/rdg/cfg.rb, line 17 def initialize(ast) @context = Analysis::Context.new @context.graph.add_vertex(ast.root) analyse(ast) end
Public Instance Methods
edge?(u, v)
click to toggle source
# File lib/rdg/cfg.rb, line 35 def edge?(u, v) @context.graph.has_edge?(u, v) end
successors(v)
click to toggle source
# File lib/rdg/cfg.rb, line 31 def successors(v) @context.graph.each_adjacent(v).to_a end
vertices()
click to toggle source
# File lib/rdg/cfg.rb, line 27 def vertices @context.graph.each_vertex.to_a end
write_to_graphic_file(format = 'png', filename = "cfg")
click to toggle source
# File lib/rdg/cfg.rb, line 23 def write_to_graphic_file(format = 'png', filename = "cfg") @context.graph.write_to_graphic_file(format, filename) end
Private Instance Methods
analyse(ast)
click to toggle source
# File lib/rdg/cfg.rb, line 41 def analyse(ast) ast.pre_order_iterator.select(&:compound?).each do |ast_node| @context.registry.analyser_for(ast_node, @context).analyse end end