Class: Kumi::Core::Analyzer::Passes::AttachAnchorsPass
- Defined in:
- lib/kumi/core/analyzer/passes/attach_anchors_pass.rb
Constant Summary collapse
- NAST =
Kumi::Core::NAST
Instance Method Summary collapse
Methods inherited from PassBase
#debug, #debug_enabled?, #initialize
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
#run(_errors) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kumi/core/analyzer/passes/attach_anchors_pass.rb', line 10 def run(_errors) @snast = get_state(:snast_module, required: true) out = {} @snast.decls.each do |name, decl| out[name] ||= {} wanted = axes_of(decl) wanted = axes_of(decl.body) if wanted.empty? # No anchors needed for scalars (rank-0) next if wanted.empty? out[name][wanted] = pick_anchor_fqn(decl.body, wanted) end state.with(:anchor_by_decl, out.freeze) end |