Class: SystemRDL::Evaluator::InstanceRefElement

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/systemrdl/evaluator/reference.rb

Instance Attribute Summary collapse

Attributes included from Common

#component, #parent, #token_range

Instance Method Summary collapse

Methods included from Common

#connect

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

#arrayObject (readonly)

Returns the value of attribute array.



15
16
17
# File 'lib/systemrdl/evaluator/reference.rb', line 15

def array
  @array
end

#idObject (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

Returns:



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