/**
  * Executes the 'if' statement, returning any value.
  */
 public Value execute(Env env)
 {
     if (_test.evalBoolean(env))
     {
         return(_trueBlock.execute(env));
     }
     else if (_falseBlock != null)
     {
         return(_falseBlock.execute(env));
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 2
0
        public Value execute(Env env)
        {
            Value origObj = _objExpr.eval(env);
            Value obj     = origObj.copy(); // php/0669

            if (_key == null && !_isRef)
            {
                Iterator <Value> iter = obj.getValueIterator(env);

                while (iter.hasNext())
                {
                    Value value = iter.next();

                    value = value.copy(); // php/0662

                    _value.evalAssignValue(env, value);

                    Value result = _block.execute(env);

                    if (result == null)
                    {
                    }
                    else if (result instanceof ContinueValue)
                    {
                        ContinueValue conValue = (ContinueValue)result;

                        int target = conValue.getTarget();

                        if (target > 1)
                        {
                            return(new ContinueValue(target - 1));
                        }
                    }
                    else if (result instanceof BreakValue)
                    {
                        BreakValue breakValue = (BreakValue)result;

                        int target = breakValue.getTarget();

                        if (target > 1)
                        {
                            return(new BreakValue(target - 1));
                        }
                        else
                        {
                            break;
                        }
                    }
Ejemplo n.º 3
0
        public Value execute(Env env)
        {
            for (int i = 0; i < _statements.length; i++)
            {
                Statement statement = _statements[i];

                Value value = statement.execute(env);

                if (value != null)
                {
                    return(value);
                }
            }

            return(null);
        }
Ejemplo n.º 4
0
        public Value execute(Env env)
        {
            try {
                if (_init != null)
                {
                    _init.eval(env);
                }

                while (_test == null || _test.evalBoolean(env))
                {
                    env.checkTimeout();

                    Value value = _block.execute(env);

                    if (value == null)
                    {
                    }
                    else if (value instanceof ContinueValue)
                    {
                        ContinueValue conValue = (ContinueValue)value;

                        int target = conValue.getTarget();

                        if (target > 1)
                        {
                            return(new ContinueValue(target - 1));
                        }
                    }
                    else if (value instanceof BreakValue)
                    {
                        BreakValue breakValue = (BreakValue)value;

                        int target = breakValue.getTarget();

                        if (target > 1)
                        {
                            return(new BreakValue(target - 1));
                        }
                        else
                        {
                            break;
                        }
                    }
Ejemplo n.º 5
0
        public Value execute(Env env)
        {
            try {
                return(_block.execute(env));
            }
            catch (QuercusLanguageException e) {
                Value value = null;

                try {
                    value = e.toValue(env);
                }
                catch (Throwable e1) {
                    throw new QuercusRuntimeException(e1);
                }

                for (int i = 0; i < _catchList.size(); i++)
                {
                    Catch item = _catchList.get(i);

                    if (value != null && value.isA(env, item.getId()) ||
                        item.getId().equalsString("Exception"))
                    {
                        if (value != null)
                        {
                            item.getExpr().evalAssignValue(env, value);
                        }
                        else
                        {
                            item.getExpr().evalAssignValue(env, NullValue.NULL);
                        }

                        return(item.getBlock().execute(env));
                    }
                }

                throw e;
            } catch (QuercusDieException e) {
                for (int i = 0; i < _catchList.size(); i++)
                {
                    Catch item = _catchList.get(i);

                    if (item.getId().equalsString("QuercusDieException"))
                    {
                        item.getExpr().evalAssignValue(env, env.createException(e));

                        return(item.getBlock().execute(env));
                    }
                }

                throw e;
            } catch (QuercusExitException e) {
                for (int i = 0; i < _catchList.size(); i++)
                {
                    Catch item = _catchList.get(i);

                    if (item.getId().equalsString("QuercusExitException"))
                    {
                        item.getExpr().evalAssignValue(env, env.createException(e));

                        return(item.getBlock().execute(env));
                    }
                }

                throw e;
            } catch (Exception e) {
                for (int i = 0; i < _catchList.size(); i++)
                {
                    Catch item = _catchList.get(i);

                    if (item.getId().equalsString("Exception"))
                    {
                        Throwable cause = e;

                        //if (e instanceof QuercusException && e.getCause() != null)
                        //cause = e.getCause();

                        item.getExpr().evalAssignValue(env, env.createException(cause));

                        return(item.getBlock().execute(env));
                    }
                }

                if (e instanceof QuercusException)
                {
                    throw (QuercusException)e;
                }