Class: FunctionDecNode

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

Overview

Function Nodes

Instance Attribute Summary

Attributes inherited from Node

#value

Instance Method Summary collapse

Constructor Details

#initialize(node, value) ⇒ FunctionDecNode

Returns a new instance of FunctionDecNode.



79
80
81
82
83
# File 'lib/nodes/stmtnodes.rb', line 79

def initialize(node, value)
  super(value)
  @name = node
  @args = node.args
end

Instance Method Details

#create_tree_entryObject



85
86
87
88
89
# File 'lib/nodes/stmtnodes.rb', line 85

def create_tree_entry
  result = set_up_scope_header
  result += "Function #{@name} declared"
  TREE_ARRAY << result unless TREE_ARRAY[-1] == result
end

#evaluateObject



95
96
97
98
99
# File 'lib/nodes/stmtnodes.rb', line 95

def evaluate
  ScopeManager.add_func_to_global_scope(@name, @value, @args)
  create_tree_entry if PRINT_TREE_FLAG
  return nil
end

#to_sObject



91
92
93
# File 'lib/nodes/stmtnodes.rb', line 91

def to_s
  "#{@name} = #{@value}"
end