public PrgState execute(PrgState state) { if (exp.eval(state.getSymTable(), state.getHeap()) != 0) { state.getExeStack().Push(this); state.getExeStack().Push(stmt); } return state; }
public PrgState execute(PrgState state) { IStack<IStmt> newStk = new ArrayStack<IStmt>(); newStk.Push(forkStmt); IDictionary<String, int> newDict = new ArrayDictionary<String, int>( (ArrayDictionary<String, int>) state.getSymTable() ); return new PrgState(newStk, newDict, state.getOut(), state.getHeap(), (state.getId() + 1) * 10); }
public PrgState execute(PrgState state) { int result = exp.eval(state.getSymTable(), state.getHeap()); if (result != 0) state.getExeStack().Push(thenStmt); else state.getExeStack().Push(elseStmt); return state; }
public PrgState execute(PrgState state) { // Exp difSwitch = new ArithmExp(op, opCase2, '-'); // Exp difSwitch2 = new ArithmExp(op, opCase1, '-'); // IStmt ifSwitch = new IfStmt(difSwitch2, defaultCase, case1); // IStmt switchStmt = new IfStmt(difSwitch, ifSwitch, case2); // state.getExeStack().push(switchStmt); return state; }
public PrgState execute(PrgState state) { state.getExeStack().Push(second); state.getExeStack().Push(first); return state; }
public PrgState execute(PrgState state) { int value = exp.eval(state.getSymTable(), state.getHeap()); state.getSymTable().Add(id, state.getHeap().Add(value)); return state; }
public PrgState execute(PrgState state) { state.getHeap().Update(state.getSymTable()[id], exp.eval(state.getSymTable(), state.getHeap())); return state; }
public void add(PrgState ps) { ps.setId (nrPrg++); prgStates.Add (ps); }
public void addPrgState(PrgState p) { repo.add(p); }
public PrgState execute(PrgState state) { state.getExeStack().Push(new IfStmt(exp, thenStmt, new SkipStmt())); return(state); }
public PrgState execute(PrgState state) { state.getSymTable().Add(id, exp.eval(state.getSymTable(), state.getHeap())); return state; }
private void addProgram() { IStmt st1 = new AssignStmt("v", new ConstExp(10)); IStmt st2 = new NewStmt("a", new ConstExp(22)); IStmt st3 = new AssignStmt("v", new ConstExp(32)); IStmt st4 = new PrintStmt(new VarExp("v")); IStmt st5 = new PrintStmt(new ReadHeapExp("a")); IStmt st8 = new ForkStmt(new CmpStmt(new WriteHeapStmt("a", new ConstExp(30)), new CmpStmt(st3, new CmpStmt(st4, st5)))); IStmt st6 = new PrintStmt(new VarExp("v")); IStmt st7 = new PrintStmt(new ReadHeapExp("a")); IStmt prgStmt = new CmpStmt(st1, new CmpStmt(st2, new CmpStmt(st8, new CmpStmt(st6, st7)))); //IStmt prgStmt = addNewStmt(); IStack<IStmt> exeStk = new ArrayStack<IStmt>(); IDictionary<String, int> tbl = new ArrayDictionary<String, int>(); IList<int> outl = new ArrayList<int>(); IHeap<int> h = new MyHeap<int>(); exeStk.Push(prgStmt); PrgState crtPrg = new PrgState(exeStk, tbl, outl, h); ctrl.addPrgState(crtPrg); ctrl.repoSer (); try { mainMenu(); } catch (ControllerException) { Console.WriteLine("Step evaluation error."); } catch (RepositoryException) { Console.WriteLine("Program state error."); } catch (ConsoleException) { Console.WriteLine("Wrong option. Try again."); } }
public PrgState execute(PrgState state) { return state; }
public void add(PrgState ps) { ps.setId(nrPrg++); prgStates.Add(ps); }
public PrgState execute(PrgState state) { state.getExeStack().Push(new IfStmt(exp, thenStmt, new SkipStmt())); return state; }
public PrgState execute(PrgState state) { state.getOut().Add(exp.eval(state.getSymTable(), state.getHeap())); return(state); }