Class: VariableCallNode

Inherits:
Node
  • Object
show all
Defined in:
lib/nodes/stmtnodes.rb

Overview

Variable Nodes

Instance Attribute Summary collapse

Attributes inherited from Node

#value

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ VariableCallNode

Returns a new instance of VariableCallNode.



14
15
16
# File 'lib/nodes/stmtnodes.rb', line 14

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



12
13
14
# File 'lib/nodes/stmtnodes.rb', line 12

def name
  @name
end

Instance Method Details

#create_tree_entryObject



18
19
20
21
22
# File 'lib/nodes/stmtnodes.rb', line 18

def create_tree_entry
  result = set_up_scope_header
  result += "Variable #{@name} is now  #{@value}"
  TREE_ARRAY << result unless TREE_ARRAY[-1] == result
end

#evaluateObject



28
29
30
31
32
# File 'lib/nodes/stmtnodes.rb', line 28

def evaluate
  @value = ScopeManager.lookup_var(@name)
  create_tree_entry if PRINT_TREE_FLAG
  return @value
end

#to_sObject



24
25
26
# File 'lib/nodes/stmtnodes.rb', line 24

def to_s
  @name
end