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.

Constant Summary

Constants inherited from PassBase

PassBase::HALT

Instance Method Summary collapse

Methods inherited from PassBase

contract_declared?, #debug, #debug_enabled?, declared_optional_reads, declared_reads, declared_writes, #initialize, optional_reads, reads, #run, writes

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

Parameters:

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