Class: SystemRDL::Evaluator::InstanceRefElement
- Inherits:
-
Object
- Object
- SystemRDL::Evaluator::InstanceRefElement
- Includes:
- Common
- Defined in:
- lib/systemrdl/evaluator/reference.rb
Instance Attribute Summary collapse
-
#array ⇒ Object
readonly
Returns the value of attribute array.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Attributes included from Common
#component, #parent, #token_range
Instance Method Summary collapse
- #array_select? ⇒ Boolean
- #find(base) ⇒ Object
-
#initialize(id, array, token_range) ⇒ InstanceRefElement
constructor
A new instance of InstanceRefElement.
Methods included from Common
Constructor Details
#initialize(id, array, token_range) ⇒ InstanceRefElement
Returns a new instance of InstanceRefElement.
8 9 10 11 12 |
# File 'lib/systemrdl/evaluator/reference.rb', line 8 def initialize(id, array, token_range) super(token_range) @id = id @array = array end |
Instance Attribute Details
#array ⇒ Object (readonly)
Returns the value of attribute array.
15 16 17 |
# File 'lib/systemrdl/evaluator/reference.rb', line 15 def array @array end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/systemrdl/evaluator/reference.rb', line 14 def id @id end |
Instance Method Details
#array_select? ⇒ Boolean
33 34 35 |
# File 'lib/systemrdl/evaluator/reference.rb', line 33 def array_select? !array.nil? end |
#find(base) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/systemrdl/evaluator/reference.rb', line 17 def find(base) result = find_instance(base) return result unless result.empty? inst_name = if array_select? array .elements .inject([id.value]) { |elements, select| elements << "[#{select.value}]" } .join else id.value.to_s end raise_evaluation_error "unresolvable instance: #{inst_name}", token_range end |