Exemple #1
0
        public PrgState Execute(PrgState state)
        {
            MyIStack <IStmt> stk = state.GetExeStack();

            stk.Push(snd);
            stk.Push(first);
            return(state);
        }
Exemple #2
0
        public PrgState OneStep(PrgState state)
        {
            MyIStack <IStmt> stk = state.GetExeStack();

            if (stk.IsEmpty())
            {
                throw new MyException("Stack is empty");
            }
            IStmt crtStmt = stk.Pop();

            return(crtStmt.Execute(state));
        }
Exemple #3
0
        public PrgState Execute(PrgState state)
        {
            MyIStack <IStmt>            stk    = state.GetExeStack();
            MyIDictionary <String, int> symtbl = state.GetSymTable();

            if (exp.Eval(symtbl) != 0)
            {
                stk.Push(thenS);
            }
            else
            {
                stk.Push(elseS);
            }
            return(state);
        }
Exemple #4
0
        public PrgState Execute(PrgState state)
        {
            MyIStack <IStmt>            stk    = state.GetExeStack();
            MyIDictionary <String, int> symTbl = state.GetSymTable();
            int val = exp.Eval(symTbl);

            if (symTbl.IsDefinedU(id))
            {
                symTbl.Update(id, val);
            }
            else
            {
                symTbl.Add(id, val);
            }
            return(state);
        }