Class: Confuscript::Nodes::Print::PrintCallNode

Inherits:
BaseNode
  • Object
show all
Defined in:
lib/confuscript/nodes/print/print_call_node.rb

Overview

Represents a PrintCall node

Instance Method Summary collapse

Methods inherited from BaseNode

#find_node

Instance Method Details

#evaluate(context) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/confuscript/nodes/print/print_call_node.rb', line 6

def evaluate(context)
  print_name_element = elements[0]
  print_arguments_element = elements[3]

  print_name = print_name_element.text_value
  raise Confuscript::SyntaxError, "Print #{print_name} not defined" unless context[print_name]

  print_arguments = retrieve_arguments(print_arguments_element.elements, context)

  begin
    context[print_name].call(*print_arguments)
  rescue Confuscript::VoidEncountered => e
    e.value
  end
end