Class: Kumi::Core::Analyzer::Passes::VisitorPass

Inherits:
PassBase
  • Object
show all
Defined in:
lib/kumi/core/analyzer/passes/visitor_pass.rb

Overview

Base class for analyzer passes that need to traverse the AST using the visitor pattern. Inherits the new immutable state interface from PassBase.

Instance Method Summary collapse

Methods inherited from PassBase

#debug, #debug_enabled?, #initialize, #run

Methods included from ErrorReporting

#inferred_location, #raise_localized_error, #raise_syntax_error, #raise_type_error, #report_enhanced_error, #report_error, #report_semantic_error, #report_syntax_error, #report_type_error

Constructor Details

This class inherits a constructor from Kumi::Core::Analyzer::Passes::PassBase

Instance Method Details

#visit(node) {|Syntax::Node| ... } ⇒ Object

Visit a node and all its children using depth-first traversal

Yields:



13
14
15
16
17
18
# File 'lib/kumi/core/analyzer/passes/visitor_pass.rb', line 13

def visit(node, &block)
  return unless node

  yield(node)
  node.children.each { |child| visit(child, &block) }
end