public PrgState execute(PrgState state) { MyIStack <IStmt> stk = state.getStk(); stk.push(snd); stk.push(first); return(state); }
private PrgState oneStep(PrgState state) { MyIStack <IStmt> stk = state.getStk(); if (stk.isEmpty()) { throw new MyStmtExecException("The stack is empty"); } IStmt crtStmt = stk.pop(); try { return(crtStmt.execute(state)); } catch (MyException ex) { throw new MyStmtExecException("" + ex); } }
public void allStep() { PrgState prg = repo.getCtrPrg(); repo.clearData(); while (!prg.getStk().isEmpty()) { try { oneStep(prg); repo.logPrgStateExec(); } catch (MyStmtExecException e) { Console.WriteLine("Exception is : " + e); } Console.WriteLine(prg.ToString()); } }
public PrgState execute(PrgState state) { MyIDictionary <string, int> dict = state.getSymTable(); MyIStack <IStmt> stk = state.getStk(); try { if (exp.eval(dict) != 0) { stk.push(thenS); } else { stk.push(elseS); } } catch (MyException ex) { throw new MyException("" + ex); } return(state); }