Example #1
0
        public ProgState OneStep(int index)
        {
            ProgState state;

            try {
                state = rep.getPrg(index);
            }
            catch (MyException.MyException e) {
                throw e;
            }


            MyIntStack <IntStatement> stack = state.getExecStack();

            if (stack.empty())
            {
                throw new MyException.MyException("Stack is empty!");
            }
            IntStatement statement = stack.pop();
            ProgState    newstate;

            try {
                newstate = statement.execute(state);
            }
            catch (MyException.MyException e) {
                throw e;
            }


            return(newstate);
        }
Example #2
0
        public ProgState execute(ProgState state)
        {
            MyIntStack <IntStatement> stack = state.getExecStack();

            stack.push(second);
            stack.push(first);
            return(null);
        }
Example #3
0
 public ProgState(
     MyIntStack <IntStatement> stack,
     MyIntDict <String, int> dict,
     MyIntList <int> list,
     IntFileTable _fileTable,
     IntStatement statement)
 {
     execStack       = stack;
     symTable        = dict;
     output          = list;
     filetable       = _fileTable;
     originalProgram = statement;
     execStack.push(statement);
 }
Example #4
0
        public ProgState execute(ProgState state)
        {
            MyIntDict <String, int>   tabel = state.getSymTable();
            MyIntStack <IntStatement> stack = state.getExecStack();
            int val;

            try {
                val = exp.eval(tabel);
            }
            catch (MyException.MyException e) {
                throw e;
            }
            if (val != 0)
            {
                stack.push(first);
            }
            else
            {
                stack.push(second);
            }
            return(null);
        }