class Unparser::AST::LocalVariableScopeEnumerator
Local variable scope enumerator
def self.each(node:, stack:, &block)
def self.each(node:, stack:, &block) new(stack: stack).each(node: node, &block) end
def current
def current @stack.last end
def define(name)
def define(name) current << name end
def each(node:, &block)
- Api: - private
Returns:
-
(Enumerator
- ]>) -
(self)
-
def each(node:, &block) visit(node, &block) end
def enter(node)
def enter(node) case node.type when *RESET_NODES push_reset when ASSIGN_NODES value = node.children.first and define(value) when *INHERIT_NODES push_inherit end end
def initialize(stack:)
- Api: - private
Returns:
-
(undefined)
-
def initialize(stack:) @stack = [stack] end
def leave(node)
def leave(node) pop if CLOSE_NODES.include?(node.type) end
def pop
def pop @stack.pop end
def push_inherit
def push_inherit @stack << current.dup end
def push_reset
def push_reset @stack << Set.new end
def visit(node, &block)
def visit(node, &block) before = current.dup enter(node) yield node, current.dup, before node.children.each do |child| visit(child, &block) if child.instance_of?(Parser::AST::Node) end leave(node) end