Class: CallNode

Inherits:
Struct
  • Object
show all
Defined in:
lib/turmali/nodes.rb,
lib/turmali/interpreter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#argumentsObject

Returns the value of attribute arguments

Returns:

  • (Object)

    the current value of arguments



32
33
34
# File 'lib/turmali/nodes.rb', line 32

def arguments
  @arguments
end

#methodObject

Returns the value of attribute method

Returns:

  • (Object)

    the current value of method



32
33
34
# File 'lib/turmali/nodes.rb', line 32

def method
  @method
end

#receiverObject

Returns the value of attribute receiver

Returns:

  • (Object)

    the current value of receiver



32
33
34
# File 'lib/turmali/nodes.rb', line 32

def receiver
  @receiver
end

Instance Method Details

#eval(context) ⇒ Object



83
84
85
86
87
88
89
90
91
92
# File 'lib/turmali/interpreter.rb', line 83

def eval(context)
  if receiver
    value = receiver.eval(context)
  else
    value = context.current_self 
  end
  
  evaluated_arguments = arguments.map { |arg| arg.eval(context) }
  value.call(method, evaluated_arguments)
end