コード例 #1
0
        /**
         * Evaluates the function.
         */
        public Value call(Env env, Value [] args)
        {
            if (_globalId > 0)
            {
                AbstractFunction fun = env._fun[_globalId];
                env._fun[_id] = fun;

                return(fun.call(env, args));
            }

            return(env.error(L.l("'{0}' @is an unknown function.", _name)));
        }
コード例 #2
0
        /**
         * Evaluates the expression.
         *
         * @param env the calling environment.
         *
         * @return the expression value.
         */
        private Value evalImpl(Env env, bool isRef, bool isCopy)
        {
            if (_funId <= 0)
            {
                _funId = env.findFunctionId(_name);

                if (_funId <= 0)
                {
                    if (_nsName != null)
                    {
                        _funId = env.findFunctionId(_nsName);
                    }

                    if (_funId <= 0)
                    {
                        env.error(L.l("'{0}' @is an unknown function.", _name), getLocation());

                        return(NullValue.NULL);
                    }
                }
            }

            AbstractFunction fun = env.getFunction(_funId);

            if (fun == null)
            {
                env.error(L.l("'{0}' @is an unknown function.", _name), getLocation());

                return(NullValue.NULL);
            }

            Value [] args = evalArgs(env, _args);

            env.pushCall(this, NullValue.NULL, args);

            // php/0249
            QuercusClass oldCallingClass = env.setCallingClass(null);

            // XXX: qa/1d14 Value oldThis = env.setThis(UnsetValue.NULL);
            try {
                env.checkTimeout();

                /*
                 * if (isRef)
                 * return fun.callRef(env, args);
                 * else if (isCopy)
                 * return fun.callCopy(env, args);
                 * else
                 * return fun.call(env, args);
                 */

                if (isRef)
                {
                    return(fun.callRef(env, args));
                }
                else if (isCopy)
                {
                    return(fun.call(env, args).copyReturn());
                }
                else
                {
                    return(fun.call(env, args).toValue());
                }
                //} catch (Exception e) {
                //  throw QuercusException.create(e, env.getStackTrace());
            } finally {
                env.popCall();
                env.setCallingClass(oldCallingClass);
                // XXX: qa/1d14 env.setThis(oldThis);
            }
        }