Class: RgGen::VerilogUtility::Identifier
- Inherits:
-
Object
- Object
- RgGen::VerilogUtility::Identifier
show all
- Includes:
- InputBase::RegxpPatterns
- Defined in:
- lib/rggen/core_components/verilog_utility/identifier.rb
Constant Summary
collapse
- TYPE_CONVERSIONS =
[
:to_a, :to_ary, :to_hash, :to_int, :to_io, :to_proc, :to_regexp, :to_str
].freeze
InputBase::RegxpPatterns::BIN_REGEXP, InputBase::RegxpPatterns::DEC_REGEXP, InputBase::RegxpPatterns::HEX_REGEXP, InputBase::RegxpPatterns::OCT_REGEXP, InputBase::RegxpPatterns::UNSIGNED_NUMBER_REGEXP, InputBase::RegxpPatterns::VARIABLE_NAME_REGEXP
Instance Method Summary
collapse
included
Constructor Details
#initialize(name, width = nil, array_dimensions = nil, array_format = nil) ⇒ Identifier
6
7
8
9
10
11
|
# File 'lib/rggen/core_components/verilog_utility/identifier.rb', line 6
def initialize(name, width = nil, array_dimensions = nil, array_format = nil)
@name = name
@width = width
@array_dimensions = array_dimensions
@array_format = array_format || :unpacked
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
37
38
39
40
41
42
|
# File 'lib/rggen/core_components/verilog_utility/identifier.rb', line 37
def method_missing(name, *args)
args.size.zero? || (return super)
TYPE_CONVERSIONS.include?(name) && (return super)
(name =~ variable_name) || (return super)
Identifier.new("#{@name}.#{name}", nil, nil, nil)
end
|
Instance Method Details
#[](array_index_or_msb, lsb = array_index_or_msb) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/rggen/core_components/verilog_utility/identifier.rb', line 17
def [](array_index_or_msb, lsb = array_index_or_msb)
if array_index_or_msb.nil?
self
else
new_name =
if array_index_or_msb.is_a?(Array)
"#{@name}#{array_selection(array_index_or_msb)}"
elsif array_index_or_msb == lsb
"#{@name}[#{array_index_or_msb}]"
else
"#{@name}[#{array_index_or_msb}:#{lsb}]"
end
Identifier.new(new_name, nil, nil, nil)
end
end
|
#respond_to_missing?(symbol, include_private) ⇒ Boolean
44
45
46
47
48
|
# File 'lib/rggen/core_components/verilog_utility/identifier.rb', line 44
def respond_to_missing?(symbol, include_private)
TYPE_CONVERSIONS.include?(symbol) && (return super)
symbol =~ variable_name || (return super)
true
end
|
#to_s ⇒ Object
13
14
15
|
# File 'lib/rggen/core_components/verilog_utility/identifier.rb', line 13
def to_s
@name.to_s
end
|