Ejemplo n.º 1
0
        public override void Execute(EpsInterpreter interpreter)
        {
            var proc = interpreter.OperandStack.Pop();

            interpreter.ResetExitCurrentLoop();

            while (true)
            {
                interpreter.Execute(proc);

                if (interpreter.BreakCurrentLoop)
                {
                    break;
                }
            }

            interpreter.ResetExitCurrentLoop();
        }
Ejemplo n.º 2
0
        public override void Execute(EpsInterpreter interpreter)
        {
            var operandStack = interpreter.OperandStack;

            var proc    = operandStack.Pop();
            var countOp = operandStack.PopInteger();

            interpreter.ResetExitCurrentLoop();

            for (int i = 0; i < countOp.Value; i++)
            {
                interpreter.Execute(proc);

                if (interpreter.BreakCurrentLoop)
                {
                    break;
                }
            }

            interpreter.ResetExitCurrentLoop();
        }
Ejemplo n.º 3
0
        public override void Execute(EpsInterpreter interpreter)
        {
            var operandStack = interpreter.OperandStack;

            var proc      = operandStack.Pop();
            var limit     = operandStack.Pop();
            var increment = operandStack.Pop();
            var initial   = operandStack.Pop();

            interpreter.ResetExitCurrentLoop();

            if (initial is IntegerOperand intInitial && increment is IntegerOperand intIncrement && limit is IntegerOperand intLimit)
            {
                ExecuteInt(interpreter, intInitial.Value, intIncrement.Value, intLimit.Value, proc);
            }
Ejemplo n.º 4
0
        public override void Execute(EpsInterpreter interpreter)
        {
            var operandStack = interpreter.OperandStack;

            var proc    = operandStack.Pop();
            var operand = operandStack.Pop();

            interpreter.ResetExitCurrentLoop();

            switch (operand)
            {
            case DictionaryOperand dictionaryOperand:
            {
                foreach (var kv in dictionaryOperand.Dictionary)
                {
                    operandStack.Push(kv.Key);
                    operandStack.Push(kv.Value);
                    interpreter.Execute(proc);

                    if (interpreter.BreakCurrentLoop)
                    {
                        break;
                    }
                }

                break;
            }

            case ArrayOperand arrayOperand:
            {
                foreach (var ao in arrayOperand.Values)
                {
                    operandStack.Push(ao.Operand);
                    interpreter.Execute(proc);

                    if (interpreter.BreakCurrentLoop)
                    {
                        break;
                    }
                }

                break;
            }

            case StringOperand stringOperand:
            {
                foreach (var ch in stringOperand.Value)
                {
                    operandStack.Push(new IntegerOperand((int)ch));
                    interpreter.Execute(proc);

                    if (interpreter.BreakCurrentLoop)
                    {
                        break;
                    }
                }

                break;
            }
            }

            interpreter.ResetExitCurrentLoop();
        }