/**
         * Executes the 'switch' statement, returning any value.
         */
        public Value execute(Env env)
        {
            try {
                Value testValue = _value.eval(env);

                int len = _cases.length;

                for (int i = 0; i < len; i++)
                {
                    Expr [] values = _cases[i];

                    for (int j = 0; j < values.length; j++)
                    {
                        Value caseValue = values[j].eval(env);

                        if (testValue.eq(caseValue))
                        {
                            Value retValue = _blocks[i].execute(env);

                            if (retValue instanceof BreakValue)
                            {
                                BreakValue breakValue = (BreakValue)retValue;

                                int target = breakValue.getTarget();

                                if (target > 1)
                                {
                                    return(new BreakValue(target - 1));
                                }
                                else
                                {
                                    return(null);
                                }
                            }
                            else if (retValue instanceof ContinueValue)
                            {
                                ContinueValue conValue = (ContinueValue)retValue;

                                int target = conValue.getTarget();

                                if (target > 1)
                                {
                                    return(new ContinueValue(target - 1));
                                }
                                else
                                {
                                    return(null);
                                }
                            }
                            else
                            {
                                return(retValue);
                            }
                        }
예제 #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;
                        }
                    }
예제 #3
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;
                        }
                    }