Class: Idl::Var
Overview
Objects to represent variables in the ISA def
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #clone ⇒ Object
- #const? ⇒ Boolean
- #const_eval? ⇒ Boolean
- #const_incompatible! ⇒ Object
- #decode_var? ⇒ Boolean
- #for_loop_iter? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(name, type, value = nil, decode_var: false, function_name: nil, param: false, for_loop_iter: false) ⇒ Var
constructor
A new instance of Var.
- #param? ⇒ Boolean
- #to_cxx ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, type, value = nil, decode_var: false, function_name: nil, param: false, for_loop_iter: false) ⇒ Var
Returns a new instance of Var.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/idlc/symbol_table.rb', line 22 def initialize(name, type, value = nil, decode_var: false, function_name: nil, param: false, for_loop_iter: false) @name = name raise ArgumentError, "Expecting a Type, got #{type.class.name}" unless type.is_a?(Type) @type = type @type.freeze @value = value raise "unexpected" unless decode_var.is_a?(TrueClass) || decode_var.is_a?(FalseClass) @decode_var = decode_var @function_name = function_name @param = param @for_loop_iter = for_loop_iter @const_compatible = true # until otherwise known end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
20 21 22 |
# File 'lib/idlc/symbol_table.rb', line 20 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
20 21 22 |
# File 'lib/idlc/symbol_table.rb', line 20 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
20 21 22 |
# File 'lib/idlc/symbol_table.rb', line 20 def value @value end |
Instance Method Details
#clone ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/idlc/symbol_table.rb', line 66 def clone Var.new( name, type.clone, value&.clone, decode_var: @decode_var, function_name: @function_name, param: @param ) end |
#const? ⇒ Boolean
77 78 79 |
# File 'lib/idlc/symbol_table.rb', line 77 def const? @type.const? end |
#const_eval? ⇒ Boolean
45 46 47 48 49 50 51 |
# File 'lib/idlc/symbol_table.rb', line 45 def const_eval? if @global @name[0].upcase == @name[0] else @const_compatible end end |
#const_incompatible! ⇒ Object
40 41 42 |
# File 'lib/idlc/symbol_table.rb', line 40 def const_incompatible! @const_compatible = false end |
#decode_var? ⇒ Boolean
81 82 83 |
# File 'lib/idlc/symbol_table.rb', line 81 def decode_var? @decode_var end |
#for_loop_iter? ⇒ Boolean
54 55 56 |
# File 'lib/idlc/symbol_table.rb', line 54 def for_loop_iter? @for_loop_iter end |
#hash ⇒ Object
58 59 60 |
# File 'lib/idlc/symbol_table.rb', line 58 def hash [@name, @type, @value, @decode_var, @function_name, @param].hash end |
#param? ⇒ Boolean
85 86 87 |
# File 'lib/idlc/symbol_table.rb', line 85 def param? @param end |
#to_cxx ⇒ Object
89 90 91 |
# File 'lib/idlc/symbol_table.rb', line 89 def to_cxx @name end |
#to_s ⇒ Object
62 63 64 |
# File 'lib/idlc/symbol_table.rb', line 62 def to_s "VAR: #{type} #{name} #{value.nil? ? 'NO VALUE' : value}" end |