public PrgState oneStep(PrgState state) { MyIStack <IStmt> stk = state.getStk(); IStmt crtStmt = stk.pop(); return(crtStmt.execute(state)); }
/** * Adds a statemtn to the repository * @param stmt - type IStmt, statement to be added */ public void Add(IStmt stmt) { ProgState prg = new ProgState(new ArrayList <int>(), new ArrayDict <string, int>(), new ArrayStack <IStmt>(), new ArrayDict <int, int>()); prg.GetExe.Push(stmt); repo.AddState(prg); }
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); } }
private void button5_Click(object sender, EventArgs e) { IStmt stmt = null; ctr = new Controller <IStmt>(stmt); ctr.Deserialize(); }
static Controller.Controller CreateController(IStmt stmt, string log) { IRepository repo = new Repository.Repository(log); Controller.Controller ctrl = new Controller.Controller(repo); ctrl.SetMain(new ProgramState(stmt)); return(ctrl); }
public PrgState(IStmt prg) { exeStack = new MyStack <IStmt>(new Stack <IStmt>()); exeStack.push(prg); symTable = new MyDictionary <string, int>(new Dictionary <string, int>()); outList = new MyList <int>(new List <int>()); fileTable = new MyDictionary <int, Tuple <string, TextReader> >(new Dictionary <int, Tuple <string, TextReader> >()); }
public CompStmt( IStmt _first, IStmt _second ) { first = _first; second = _second; }
public void executeOneStep() { ProgramState p = repo.getCurrentPrgState(); IStmt stmt = p.Stack.pop(); stmt.execute(p); Console.WriteLine(p); }
public ProgramState(ExeStack <IStmt> exeStack, Output <int> output, SymTable <string, int> symTable, FileTable fileTable, IStmt program) { _exeStack = exeStack; _output = output; _symTable = symTable; _fileTable = fileTable; _program = program; }
public PrgState(IStmt prg) { this.exeStack = new MyStack <IStmt>(); this.symTable = new MyDictionary <String, int>(); this.outTbl = new MyList <int>(); this.originalProgram = prg.deepCopy(); this.fileTable = new FileTable <int, FileTuple>(); this.exeStack.push(prg); }
public PrgState oneStep() { try { IStmt crtStmt = exeStack.Pop(); return(crtStmt.execute(this)); } catch (EmptyStackException) { throw new MyStmtExecException(); } }
public SwitchStmt(Exp exp, Exp opCase1, IStmt case1, Exp opCase2, IStmt case2, IStmt defaultCase) { this.exp = exp; this.expCase1 = opCase1; this.case1 = case1; this.case2 = case2; this.expCase2 = opCase2; this.defaultCase = defaultCase; }
public PrgState() { id = 0; exeStack = null; symTable = null; output = null; originalProgram = null; heap = null; }
public PrgState(IMyStack <IStmt> exe, IMyDictionary <String, int> d, IMyList <int> l, IMyFileTable <int, FileData> ft, IStmt orig) { exeStack = exe; symTable = d; messages = l; fileTable = ft; originalPrg = orig; exeStack.Push(orig); }
public ProgramState(IStmt statement) { _exeStack = new ExeStack <IStmt>(); _exeStack.Push(statement); _symTable = new SymTable <string, int>(); _output = new Output <int>(); _fileTable = new FileTable(); _program = statement; }
private void button1_Click(object sender, EventArgs e) { StmtMenu m = new StmtMenu(); m.ShowDialog(); prg = m.GetPrg(); this.textBox1.Text = prg.ToString(); ctr = new Controller <IStmt>(prg); }
public void UiInput() { StmtMenu(); IStmt stmt = AddStmt(GetInputString()); Console.WriteLine("You've added to program: "); Console.WriteLine(stmt.ToString()); ctrl.Add(stmt); }
public SwitchStmt(Expr ex1, Expr ex2, VarExpr varn, IStmt st1, IStmt st2, IStmt st3) { var = varn; exp1 = ex1; exp2 = ex2; stm1 = st1; stm2 = st2; stm3 = st3; }
public Stmt(StmtClass kind, IStmt parent) { Class = kind; Parent = parent as Stmt; if (Parent != null) { Parent.Stmts.Add(this); } }
public PrgState(IStmt prg) { exeStack = new MyStack <IStmt>(); symTable = new MyDictionary <string, int>(); outList = new MyList <int>(); fileTable = new MyFileTable <int, Tuple <string, StreamReader> >(); originalProgram = prg; exeStack.push(prg); }
public PrgState(IStmt initialProgram) { this.exeStack = new Stack <IStmt>(); this.symTable = new Dictionary <String, int>(); this.stdout = new List <int>(); this.fileTable = new Dictionary <int, MyFile>(); this.initialProgram = initialProgram; this.exeStack.Push(initialProgram); }
public SwitchStmt(Exp varExp, Exp exp1, IStmt statement1, Exp exp2, IStmt statement2, IStmt statement3) { mVarExp = varExp; mExp1 = exp1; mExp2 = exp2; mStatement1 = statement1; mStatement2 = statement2; mStatement3 = statement3; }
public SwitchStmt(Exp op, Exp opCase1, IStmt case1, Exp opCase2, IStmt case2, IStmt defaultCase) { this.op = op; this.opCase1 = opCase1; this.case1 = case1; this.case2 = case2; this.opCase2 = opCase2; this.defaultCase = defaultCase; }
public PrgState(IStack <IStmt> stk, IDict <String, int> symtbl, IList <int> output, IDictRandIntKey <MyTuple <String, TextReader> > fileTable, IStmt stmt) { this.exeStack = stk; this.symTable = symtbl; this.output = output; this.fileTable = fileTable; this.originalProgramState = stmt; this.exeStack.push(stmt); }
private void ExecuteCommand(int command) { IExeStack <IStmt> exeStack = new ExeStack <IStmt>(); IModList <int> outList = new ModList <int>(); IModDictionary <string, int> dict = new ModDictionary <string, int>(); IStmt stmt = default(IStmt); IFileTable <int, FileData> fileTable = new FileTable <int, FileData>(); switch (command) { case 1: stmt = new CompStmt( new AssingStmt("v", new ConstExp(2)), new PrintStmt(new VarExp("v"))); break; case 2: break; case 3: break; case 4: stmt = new CompStmt( new OpenRFile("var_f", @"E:\GitRepoCollege\MAP\C# - Toy language\Lab10\Toy Language\Toy Language\test.in"), new CompStmt( new ReadRFile(new VarExp("var_f"), "var_c"), new CompStmt( new PrintStmt(new VarExp("var_c")), new CompStmt( new IfStmt( new VarExp("var_c"), new CompStmt( new ReadRFile(new VarExp("var_f"), "var_c"), new PrintStmt(new VarExp("var_c"))), new PrintStmt(new ConstExp(0))), new CloseRFile(new VarExp("var_f")))))); break; default: // throw some error throw new Exception("Invalid command"); } PrgState prgState = new PrgState(exeStack, dict, outList, fileTable, stmt); ctrl.AddPrgState(prgState); try { ctrl.AllStep(); } catch (Exception ex) { Console.WriteLine(ex); } }
public ProgState OneStep() { if (exeStack.IsEmpty()) { throw new MyStmtException("Exception in onestep progstate \n"); } IStmt stm = exeStack.Pop(); return(stm.execute(this)); }
public PrgState(MyIStack <IStmt> stk, MyIDictionary <string, int> symtbl, MyIList <int> ot, IFileTable <int, FileTuple> fileTable, IStmt prg) { this.exeStack = stk; this.symTable = symtbl; this.outTbl = ot; this.originalProgram = prg.deepCopy(); this.fileTable = fileTable; this.exeStack.push(prg); }
//optional field, but good to have public PrgState(StackInterface<IStmt> stack, MapInterface<String, int> dictionary, HeapInterface<int> heap, ListInterface<int> list, IStmt prg) { id = generator++; exeStack = stack; symTable = dictionary; heapTable = heap; output = list; originalProgram = prg; exeStack.Push (originalProgram); }
private IfThenStmt ifThenStatement() { print("Expression:"); Exp expression = inputExpression(); print("Then Statement:"); IStmt thenS = inputStatement(); return(new IfThenStmt(expression, thenS)); }
private WhileStmt whileStatement() { print("Expression:"); Exp expression = inputExpression(); print("Statement:"); IStmt statement = inputStatement(); return(new WhileStmt(expression, statement)); }
private CompStmt compoundStatement() { print("Left side:"); IStmt left = inputStatement(); print("Right side:"); IStmt right = inputStatement(); return(new CompStmt(left, right)); }
public void SetStmt(string name, IStmt stmt) { var prop = GetType().GetProperty(name, typeof(IStmt)); if (prop == null) { return; } prop.SetValue(this, stmt); }
public IfThenStmt(Exp e, IStmt then) { exp = e; thenStmt = then; }
public IfStmt(Exp e, IStmt then, IStmt otherwise) { this.exp = e; this.thenStmt = then; this.elseStmt = otherwise; }
public WhileStmt(Exp e, IStmt stmt) { this.exp = e; this.stmt = stmt; }
public ForkStmt(IStmt forkStmt) { this.forkStmt = forkStmt; }
public CompStmt(IStmt left, IStmt right) { first = left; second = right; }
public CmpStmt(IStmt first, IStmt second) { this.first = first; this.second = second; }
public RepeatStmt(IStmt statement, Exp expr) { exp = expr; stmt = statement; }
public IfStmt(Exp e, IStmt t, IStmt el) { exp = e; thenS = t; elseS = el; }
public IfThenStmt(Exp e, IStmt t) { exp = e; thenS = t; }