Class: VariableDecNode
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Attributes inherited from Node
Instance Method Summary collapse
- #create_tree_entry ⇒ Object
- #evaluate ⇒ Object
-
#initialize(name, value) ⇒ VariableDecNode
constructor
A new instance of VariableDecNode.
- #to_s ⇒ Object
Constructor Details
#initialize(name, value) ⇒ VariableDecNode
Returns a new instance of VariableDecNode.
38 39 40 41 |
# File 'lib/nodes/stmtnodes.rb', line 38 def initialize(name, value) super(value) @name = name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
36 37 38 |
# File 'lib/nodes/stmtnodes.rb', line 36 def name @name end |
Instance Method Details
#create_tree_entry ⇒ Object
43 44 45 46 47 |
# File 'lib/nodes/stmtnodes.rb', line 43 def create_tree_entry result = set_up_scope_header result += "Variable #{@name} is now #{@value}" TREE_ARRAY << result unless TREE_ARRAY[-1] == result end |
#evaluate ⇒ Object
53 54 55 56 57 |
# File 'lib/nodes/stmtnodes.rb', line 53 def evaluate ScopeManager.add_to_current_scope(name, @value) create_tree_entry if PRINT_TREE_FLAG self end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/nodes/stmtnodes.rb', line 49 def to_s "#{@name} = #{@value}" end |