Class: Lilac::CLI::TemplateAST::WalkScopes
- Inherits:
-
Object
- Object
- Lilac::CLI::TemplateAST::WalkScopes
- Defined in:
- lib/lilac/cli/build/template_ast.rb
Overview
Immutable per-frame walk state: the stacks that get pushed/popped
as the walker descends/ascends. Bundled so walk doesn't have to
thread individual args through recursion (the accumulators —
directives / refs_map — are mutated in place and stay separate).
Instance Attribute Summary collapse
-
#each_scope ⇒ Object
readonly
each_scope: ref_ids of currently-open
data-eachelements; children's directives carryscope_id = each_scope.lastref_scopes: Stack<{ ref_name => line }> for duplicate ref detection perdata-each/data-componentscope. -
#ref_scopes ⇒ Object
readonly
each_scope: ref_ids of currently-open
data-eachelements; children's directives carryscope_id = each_scope.lastref_scopes: Stack<{ ref_name => line }> for duplicate ref detection perdata-each/data-componentscope.
Instance Method Summary collapse
- #current_each_ref ⇒ Object
- #current_ref_scope ⇒ Object
-
#initialize(each_scope: [], ref_scopes: [{}]) ⇒ WalkScopes
constructor
A new instance of WalkScopes.
-
#push_each(ref_id) ⇒ Object
Push helpers return a NEW WalkScopes — frames are immutable so the recursive call doesn't accidentally mutate the parent's stack.
- #push_ref_scope ⇒ Object
Constructor Details
#initialize(each_scope: [], ref_scopes: [{}]) ⇒ WalkScopes
Returns a new instance of WalkScopes.
94 95 96 97 |
# File 'lib/lilac/cli/build/template_ast.rb', line 94 def initialize(each_scope: [], ref_scopes: [{}]) @each_scope = each_scope @ref_scopes = ref_scopes end |
Instance Attribute Details
#each_scope ⇒ Object (readonly)
each_scope: ref_ids of currently-open data-each elements;
children's directives carry scope_id = each_scope.last
ref_scopes: Stack<{ ref_name => line }> for duplicate ref detection
per data-each / data-component scope
92 93 94 |
# File 'lib/lilac/cli/build/template_ast.rb', line 92 def each_scope @each_scope end |
#ref_scopes ⇒ Object (readonly)
each_scope: ref_ids of currently-open data-each elements;
children's directives carry scope_id = each_scope.last
ref_scopes: Stack<{ ref_name => line }> for duplicate ref detection
per data-each / data-component scope
92 93 94 |
# File 'lib/lilac/cli/build/template_ast.rb', line 92 def ref_scopes @ref_scopes end |
Instance Method Details
#current_each_ref ⇒ Object
113 114 115 |
# File 'lib/lilac/cli/build/template_ast.rb', line 113 def current_each_ref @each_scope.last end |
#current_ref_scope ⇒ Object
109 110 111 |
# File 'lib/lilac/cli/build/template_ast.rb', line 109 def current_ref_scope @ref_scopes.last end |
#push_each(ref_id) ⇒ Object
Push helpers return a NEW WalkScopes — frames are immutable so the recursive call doesn't accidentally mutate the parent's stack.
101 102 103 |
# File 'lib/lilac/cli/build/template_ast.rb', line 101 def push_each(ref_id) self.class.new(each_scope: @each_scope + [ref_id], ref_scopes: @ref_scopes) end |
#push_ref_scope ⇒ Object
105 106 107 |
# File 'lib/lilac/cli/build/template_ast.rb', line 105 def push_ref_scope self.class.new(each_scope: @each_scope, ref_scopes: @ref_scopes + [{}]) end |