Method: IdentifierNode#evaluate

Defined in:
lib/nodes.rb

#evaluate(scope) ⇒ Object



363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# File 'lib/nodes.rb', line 363

def evaluate(scope)
  
  # Checks if the identifier is a function. If true raise SyntaxError. 
  if scope.is_function?(@value)
    raise SyntaxError, "Identifier #{@value} is assigned to a function. Please use correct syntax for function call."
  end

  # Checks if the identifier is a local variable. If false, add it to non-local list.
  id_value = scope.get_identifier(@value)
  unless scope.identifiers.has_key?(@value)
    scope.set_non_local_variable(@value)
  end
  
  return id_value
end