Example #1
0
        /**
         * Evaluates the expression.
         *
         * @param env the calling environment.
         *
         * @return the expression value.
         */
        public override Value evalRef(Env env)
        {
            Value value = _value.evalCopy(env);

            _var.evalAssignValue(env, value);

            // php/03d9, php/03mk
            return(_var.eval(env));
        }
 /**
  * Evaluates the expression.
  *
  * @param env the calling environment.
  *
  * @return the expression value.
  */
 public Value evalCopy(Env env)
 {
     if (_test.evalBoolean(env))
     {
         return(_trueExpr.evalCopy(env));
     }
     else
     {
         return(_falseExpr.evalCopy(env));
     }
 }
        /**
         * Evaluates the expression.
         *
         * @param env the calling environment.
         *
         * @return the expression value.
         */
        public Value eval(Env env)
        {
            Value value = _test.eval(env);

            if (value.toBoolean())
            {
                return(value.copy()); // php/03cj, php/03ck
            }
            else
            {
                return(_falseExpr.evalCopy(env)); // php/03cl
            }
        }
Example #4
0
        /**
         * Evaluates as an array index assign ($a[index] = value).
         */
        public override Value evalArrayAssign(Env env, Expr indexExpr, Expr valueExpr)
        {
            Value obj = env.getThis();

            StringValue name = evalName(env);

            Value fieldVar = obj.getThisFieldArray(env, name);
            Value index    = indexExpr.eval(env);

            Value value = valueExpr.evalCopy(env);

            // php/03mn
            return(fieldVar.putThisFieldArray(env, obj, name, index, value));
        }
        /**
         * Evaluates as an array index assign ($a[index] = value).
         */
        public override Value evalArrayAssign(Env env, Expr indexExpr, Expr valueExpr)
        {
            init();

            Value obj = env.getThis();

            if (obj.isNull())
            {
                return(env.thisError(getLocation()));
            }

            // php/044i
            Value fieldVar = obj.getThisFieldArray(env, _name);
            Value index    = indexExpr.eval(env);

            Value value = valueExpr.evalCopy(env);

            return(fieldVar.putThisFieldArray(env, obj, _name, index, value));
        }
        /**
         * Evaluates as an array index assign ($a[index] = value).
         * @return what was assigned
         */
        public Value evalArrayAssign(Env env, Expr indexExpr, Expr valueExpr)
        {
            // php/03mk, php/03mm, php/03mn, php/04b3
            // overrided in ThisFieldExpr and ThisFieldVarExpr
            //Value var = eval(env);
            //
            //return var.put(index, value);

            Value array = evalArray(env);
            Value index = indexExpr.eval(env);

            Value value = valueExpr.evalCopy(env);

            Value result = array.put(index, value);

            //return array.get(index); // php/03mm php/03mn

            return(result);
        }
        /**
         * Evaluates an assignment. The value must not be a Var.
         */
        public Value evalAssignValue(Env env, Expr valueExpr)
        {
            Value value = valueExpr.evalCopy(env);

            return(evalAssignValue(env, value));
        }