class Farts::CallSyntaxNode

Public Class Methods

new( lineno, func, args ) click to toggle source
# File lib/farts/farts_parser.rb, line 636
def initialize( lineno, func, args )
  super lineno
  @funcname = func
  @args = args
end

Public Instance Methods

execute(intp) click to toggle source
# File lib/farts/farts_parser.rb, line 642
def execute(intp)
  arg = @args.collect {|i| i.execute(intp) }
  begin
    case @funcname
    when "||"
      arg[0] || arg[1]
    when "&&"
      arg[0] && arg[1]
    when "!="
      arg[0] != arg[1]
    when "!"
      !arg[0]
    else
      if arg.empty? || !arg[0].respond_to?(@funcname)
        intp.call_lib_function(@funcname, arg) do
          fart_err("undefined function '#{@funcname}'")
        end
      else
        recv = arg.shift
        recv.send(@funcname, *arg)
      end
    end
  rescue ArgumentError
    pp self
    pp arg
    fart_err($!.message)
  end
end