Class: Luoma::StaticAnalysis::StaticScope
- Inherits:
-
Object
- Object
- Luoma::StaticAnalysis::StaticScope
- Defined in:
- lib/luoma/static_analysis.rb,
sig/luoma/static_analysis.rbs
Overview
Helper to manage variable scope during static analysis.
Instance Method Summary collapse
- #add(name) ⇒ void
- #include?(key) ⇒ Boolean
-
#initialize(globals) ⇒ StaticScope
constructor
(Set) -> void.
- #pop ⇒ Object
- #push(scope) ⇒ self
Constructor Details
#initialize(globals) ⇒ StaticScope
(Set) -> void
126 127 128 |
# File 'lib/luoma/static_analysis.rb', line 126 def initialize(globals) @stack = [globals] #: Array[Set[String]] end |
Instance Method Details
#add(name) ⇒ void
This method returns an undefined value.
143 144 145 |
# File 'lib/luoma/static_analysis.rb', line 143 def add(name) @stack.first.add(name) end |
#include?(key) ⇒ Boolean
130 131 132 |
# File 'lib/luoma/static_analysis.rb', line 130 def include?(key) @stack.any? { |scope| scope.include?(key) } end |
#pop ⇒ Object
139 140 141 |
# File 'lib/luoma/static_analysis.rb', line 139 def pop @stack.pop end |
#push(scope) ⇒ self
134 135 136 137 |
# File 'lib/luoma/static_analysis.rb', line 134 def push(scope) @stack << scope self end |