Class: OrigenVerilog::Preprocessor::Processor::Define
- Inherits:
-
Object
- Object
- OrigenVerilog::Preprocessor::Processor::Define
- Defined in:
- lib/origen_verilog/preprocessor/processor.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(options) ⇒ Define
constructor
A new instance of Define.
- #value(node, arguments) ⇒ Object
Constructor Details
#initialize(options) ⇒ Define
Returns a new instance of Define.
115 116 117 118 119 |
# File 'lib/origen_verilog/preprocessor/processor.rb', line 115 def initialize() @name = [:name] @args = [:args] || [] @text = [:text] end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
113 114 115 |
# File 'lib/origen_verilog/preprocessor/processor.rb', line 113 def args @args end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
113 114 115 |
# File 'lib/origen_verilog/preprocessor/processor.rb', line 113 def name @name end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
113 114 115 |
# File 'lib/origen_verilog/preprocessor/processor.rb', line 113 def text @text end |
Instance Method Details
#value(node, arguments) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/origen_verilog/preprocessor/processor.rb', line 121 def value(node, arguments) return '' unless text arguments = Array(arguments) unless args.size == arguments.size puts "Macro #{node.to_a[0]} required #{args.size} arguments, but only #{arguments.size} have been given!" puts "#{node.file}:#{node.line_number}" exit 1 end t = text args.each_with_index do |a, i| t = t.gsub(a, arguments[i]) end t end |