public PrgState oneStep(PrgState state) { MyIStack <IStmt> stk = state.getExeStack(); try { if (stk.empty()) { throw new Exception("Empty stack"); } IStmt crtStmt = stk.pop(); PrgState newState = crtStmt.execute(state); if (flag == 1) { this.displayCrtPrgState(newState); } //repo.logPrgStateExec(); return(newState); } catch (Exception ex) { throw new Exception(ex.Message); } }
public void allStep() { PrgState prg = repo.getCrtPrg(); while (!prg.getExeStack().empty()) { try { while (true) { oneStep(prg); repo.logPrgStateExec(); } } catch (IOException e) { throw new Exception(e.Message); } catch (Exception e) { throw new Exception(e.Message); } } }
public void execute(PrgState state) { ImyStack <Istmt> stk = state.getExeStack(); stk.push(second); stk.push(first); }
public PrgState execute(PrgState state) { MyIStack <IStmt> stk = state.getExeStack(); // stk.pop(); MyIDictionary <String, int> symTbl = state.getSymTable(); IFileTable <int, FileTuple> fileTbl = state.getFileTable(); int value_exp = this.exp_file_id.eval(symTbl); FileTuple ft = fileTbl.getValue(value_exp); if (!fileTbl.isDefined(value_exp)) { throw new Exception("The key is not defined in the file table"); } StreamReader streamReader = fileTbl.getValue(value_exp).getStreamReader(); try { streamReader.Close(); } catch (IOException ex) { throw new Exception(ex.Message); } fileTbl.remove(value_exp); return(state); }
public PrgState execute(PrgState state) { MyIStack <IStmt> stk = state.getExeStack(); stk.push(snd); stk.push(first); return(state); }
public PrgState oneStep(PrgState prgState) { MyIStack <IStmt> exeStack = prgState.getExeStack(); if (exeStack.isEmpty()) { throw new Exception("stack is empty"); } return(exeStack.pop().execute(prgState)); }
public void allSteps() { PrgState prgState = this.repo.getPrgList().ElementAt(0); repo.logPrgStateExec(prgState); while (prgState.getExeStack().isEmpty() == false) { oneStep(prgState); repo.logPrgStateExec(prgState); } }
public void execute(PrgState state) { ImyStack <Istmt> stk = state.getExeStack(); ImyDict <string, int> symTable = state.getSymTable(); try { if (e.eval(symTable) != 0) { stk.push(thenS); } else { stk.push(elseS); } } catch (ExpException) { throw new StmtException("Id in \"" + this.ToString() + "\" statement has no value asociated with it"); } }
public PrgState execute(PrgState state) { MyIStack <IStmt> stk = state.getExeStack(); MyIDictionary <String, int> symTbl = state.getSymTable(); IFileTable <int, FileTuple> fileTbl = state.getFileTable(); int value_exp = this.exp_file_id.eval(symTbl); FileTuple ft = fileTbl.getValue(value_exp); if (!symTbl.isDefined(ft.getFileName())) { //throw new MyStmtExecException("The key is not defined in the file table"); } StreamReader streamReader = ft.getStreamReader(); int val = -1; try { String line = streamReader.ReadLine(); if (line == null) { val = 0; } else { try { val = int.Parse(line); } catch (Exception ex) { Console.WriteLine(ex.Message); } } symTbl.put(this.var_name, val); } catch (IOException ex) { throw new Exception(ex.Message); } return(state); }
public PrgState execute(PrgState state) { MyIStack <IStmt> stk = state.getExeStack(); IFileTable <int, FileTuple> filetable = state.getFileTable(); MyIDictionary <String, int> symTbl = state.getSymTable(); try { FileStream reader = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read); StreamReader bufferedStream = new StreamReader(reader); int id = IdGenerator.generateId(); FileTuple tuple = new FileTuple(this.filename, bufferedStream); filetable.put(id, tuple); symTbl.put(this.var_file_id, id); } catch (Exception ex) { throw new Exception(ex.Message); } return(state); }
public PrgState execute(PrgState state) { MyIStack <IStmt> stk = state.getExeStack(); MyIDictionary <String, int> symTbl = state.getSymTable(); try { int val = exp.eval(symTbl); //if (!symTbl.isDefined(this.id)) //throw new MyStmtExecException("The variable is not assigned"); //int address = symTbl.get(this.id); //heap.put(address, val); symTbl.put(this.id, val); //we assign the new values } catch (Exception ex) { Console.WriteLine("ASSIGN ERROR"); } return(state); }