Class: SystemRDL::Evaluator::Literal

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

Direct Known Subclasses

Boolean, EnumLiteral, Number, String, VerilogNumber

Instance Attribute Summary collapse

Attributes included from Common

#component, #parent

Instance Method Summary collapse

Methods included from Common

#connect

Constructor Details

#initialize(node) ⇒ Literal

Returns a new instance of Literal.



8
9
10
11
12
# File 'lib/systemrdl/evaluator/literal.rb', line 8

def initialize(node)
  super(node.token_range)
  @node = node
  evaluate_literal
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



14
15
16
# File 'lib/systemrdl/evaluator/literal.rb', line 14

def value
  @value
end

Instance Method Details

#evaluate(_instance, **_optargs) ⇒ Object



16
17
18
# File 'lib/systemrdl/evaluator/literal.rb', line 16

def evaluate(_instance, **_optargs)
  @evaluated ||= Value.new(value, type, width, token_range)
end

#expression_widthObject



20
21
22
# File 'lib/systemrdl/evaluator/literal.rb', line 20

def expression_width
  width
end

#token_rangeObject



24
25
26
# File 'lib/systemrdl/evaluator/literal.rb', line 24

def token_range
  @node.token_range
end