Exemplo n.º 1
0
        public ProgramState Exec(ProgramState state)
        {
            if (exp.Eval(state) > 0)
            {
                return(thenS.Exec(state));
            }

            if (elseS == null)
            {
                return(null);
            }

            return(elseS.Exec(state));
        }
Exemplo n.º 2
0
        public ToyProgram OneStep()
        {
            if (this.Completed())
            {
                throw new ProgramCompletedException("All steps executed");
            }

            IStatement   currentStatement = State.ExeStack.Pop();
            ProgramState newState         = currentStatement.Exec(State);

            if (newState != null)
            {
                return(new ToyProgram(newState));
            }

            return(null);
        }