Class: SystemRDL::Evaluator::ComponentDefinition
- Inherits:
-
Object
- Object
- SystemRDL::Evaluator::ComponentDefinition
show all
- Includes:
- Common
- Defined in:
- lib/systemrdl/evaluator/component_definition.rb
Instance Attribute Summary collapse
Attributes included from Common
#component, #parent, #token_range
Instance Method Summary
collapse
-
#assign_default_property(name, value, token_range) ⇒ Object
-
#connect(parent, component) ⇒ Object
-
#create_instances(parent_instance, inst_name, inst_values, token_range, **optargs) ⇒ Object
-
#evaluate(instance, **optargs) ⇒ Object
-
#finalize(_instance) ⇒ Object
-
#find_default_property(name) ⇒ Object
-
#initialize(id, elements, insts, token_range) ⇒ ComponentDefinition
constructor
A new instance of ComponentDefinition.
-
#revalidate(_instance) ⇒ Object
-
#upper_layers(include_self: false) ⇒ Object
-
#validate(_instance) ⇒ Object
Constructor Details
#initialize(id, elements, insts, token_range) ⇒ ComponentDefinition
Returns a new instance of ComponentDefinition.
8
9
10
11
12
13
14
15
|
# File 'lib/systemrdl/evaluator/component_definition.rb', line 8
def initialize(id, elements, insts, token_range)
super(token_range)
@id = id || insts.insts[0].inst_id
@definitions = {}
@elements = elements
@insts = insts
@default_properties = {}
end
|
Instance Attribute Details
#definitions ⇒ Object
Returns the value of attribute definitions.
18
19
20
|
# File 'lib/systemrdl/evaluator/component_definition.rb', line 18
def definitions
@definitions
end
|
#id ⇒ Object
Returns the value of attribute id.
17
18
19
|
# File 'lib/systemrdl/evaluator/component_definition.rb', line 17
def id
@id
end
|
Instance Method Details
#assign_default_property(name, value, token_range) ⇒ Object
58
59
60
61
62
63
64
65
|
# File 'lib/systemrdl/evaluator/component_definition.rb', line 58
def assign_default_property(name, value, token_range)
if @default_properties.key?(name)
message = "#{name} already assigned in this scope"
raise_evaluation_error message, token_range
end
@default_properties[name] = value
end
|
#connect(parent, component) ⇒ Object
20
21
22
23
24
25
|
# File 'lib/systemrdl/evaluator/component_definition.rb', line 20
def connect(parent, component)
super
@component&.add_definition(self)
@elements.each { |element| element.connect(self, self) }
@insts&.connect(self, self)
end
|
#create_instances(parent_instance, inst_name, inst_values, token_range, **optargs) ⇒ Object
40
41
42
43
44
45
46
47
|
# File 'lib/systemrdl/evaluator/component_definition.rb', line 40
def create_instances(parent_instance, inst_name, inst_values, token_range, **optargs)
eval_array(inst_values) do |array_info|
create_instance(
parent_instance, inst_name, inst_values,
array_info, token_range, **optargs
)
end
end
|
#evaluate(instance, **optargs) ⇒ Object
35
36
37
38
|
# File 'lib/systemrdl/evaluator/component_definition.rb', line 35
def evaluate(instance, **optargs)
check_definable(instance)
@insts&.evaluate(instance, @parent, @id, **optargs)
end
|
#finalize(_instance) ⇒ Object
55
56
|
# File 'lib/systemrdl/evaluator/component_definition.rb', line 55
def finalize(_instance)
end
|
#find_default_property(name) ⇒ Object
67
68
69
70
71
72
73
74
75
|
# File 'lib/systemrdl/evaluator/component_definition.rb', line 67
def find_default_property(name)
upper_layers.reverse_each do |component|
if (prop = component.default_properties[name])
return prop
end
end
nil
end
|
#revalidate(_instance) ⇒ Object
52
53
|
# File 'lib/systemrdl/evaluator/component_definition.rb', line 52
def revalidate(_instance)
end
|
#upper_layers(include_self: false) ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/systemrdl/evaluator/component_definition.rb', line 27
def upper_layers(include_self: false)
return [] if layer == :root
layers = [*component.upper_layers, component]
layers << self if include_self
layers
end
|
#validate(_instance) ⇒ Object
49
50
|
# File 'lib/systemrdl/evaluator/component_definition.rb', line 49
def validate(_instance)
end
|