Class: Ibex::Frontend::Resolution
- Inherits:
-
Object
- Object
- Ibex::Frontend::Resolution
- Defined in:
- lib/ibex/frontend/resolution.rb
Overview
Immutable result of resolving one root grammar and its fragment closure.
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
: Array.
-
#root ⇒ Object
readonly
: AST::Root.
-
#root_directory ⇒ Object
readonly
: String.
-
#root_path ⇒ Object
readonly
: String.
Instance Method Summary collapse
- #include_chain_for(rule) ⇒ Object
-
#initialize(root:, root_path:, root_directory:, files:, include_chains:) ⇒ Resolution
constructor
A new instance of Resolution.
Constructor Details
#initialize(root:, root_path:, root_directory:, files:, include_chains:) ⇒ Resolution
Returns a new instance of Resolution.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ibex/frontend/resolution.rb', line 17 def initialize(root:, root_path:, root_directory:, files:, include_chains:) @root = deep_freeze_ast(root) @root_path = root_path.dup.freeze @root_directory = root_directory.dup.freeze @files = files.map { |file| file.dup.freeze }.freeze chains = {} #: Hash[AST::Rule, Array[IR::source_provenance]] @include_chains = chains.compare_by_identity include_chains.each do |rule, chain| frozen_chain = chain.map { |entry| copy_provenance(entry) }.freeze @include_chains[rule] = frozen_chain end @include_chains.freeze freeze end |
Instance Attribute Details
#files ⇒ Object (readonly)
: Array
13 14 15 |
# File 'lib/ibex/frontend/resolution.rb', line 13 def files @files end |
#root ⇒ Object (readonly)
: AST::Root
10 11 12 |
# File 'lib/ibex/frontend/resolution.rb', line 10 def root @root end |
#root_directory ⇒ Object (readonly)
: String
12 13 14 |
# File 'lib/ibex/frontend/resolution.rb', line 12 def root_directory @root_directory end |
#root_path ⇒ Object (readonly)
: String
11 12 13 |
# File 'lib/ibex/frontend/resolution.rb', line 11 def root_path @root_path end |
Instance Method Details
#include_chain_for(rule) ⇒ Object
33 34 35 |
# File 'lib/ibex/frontend/resolution.rb', line 33 def include_chain_for(rule) @include_chains.fetch(rule, EMPTY_CHAIN) end |