Class: Liquid2::StaticAnalysis::StaticScope
- Inherits:
-
Object
- Object
- Liquid2::StaticAnalysis::StaticScope
- Defined in:
- lib/liquid2/static_analysis.rb
Overview
Helper to manage variable scope during static analysis.
Instance Method Summary collapse
- #add(name) ⇒ Object
- #include?(key) ⇒ Boolean
-
#initialize(globals) ⇒ StaticScope
constructor
A new instance of StaticScope.
- #pop ⇒ Object
- #push(scope) ⇒ Object
Constructor Details
#initialize(globals) ⇒ StaticScope
Returns a new instance of StaticScope.
99 100 101 |
# File 'lib/liquid2/static_analysis.rb', line 99 def initialize(globals) @stack = [globals] end |
Instance Method Details
#add(name) ⇒ Object
116 117 118 |
# File 'lib/liquid2/static_analysis.rb', line 116 def add(name) @stack.first.add(name) end |
#include?(key) ⇒ Boolean
103 104 105 |
# File 'lib/liquid2/static_analysis.rb', line 103 def include?(key) @stack.any? { |scope| scope.include?(key) } end |
#pop ⇒ Object
112 113 114 |
# File 'lib/liquid2/static_analysis.rb', line 112 def pop @stack.pop end |
#push(scope) ⇒ Object
107 108 109 110 |
# File 'lib/liquid2/static_analysis.rb', line 107 def push(scope) @stack << scope self end |