public PrgState(ADT.IDictionary <string, int> s, IExeStack <Statement> exe, IOutput <int> o, IFileTable <int, FileData> ft) { this.symbolTable = s; this.exeStack = exe; this.output = o; this.filetable = ft; }
public PrgState Execute(PrgState p) { ADT.IDictionary <string, int> dict = p.Dict; int val = this.expr.Eval(dict); if (val != 0) { p.Stack.Push(thenstmt); } else { p.Stack.Push(elsestmt); } return(p); }
public int Eval(ADT.IDictionary <string, int> dict) { int resl = this.left.Eval(dict); int resr = this.right.Eval(dict); if (this.op == '+') { return(resl + resr); } else if (this.op == '-') { return(resl - resr); } else if (this.op == '*') { return(resl * resr); } else if (this.op == '%') { if (resr == 0) { throw new DivideByZeroException("Division by 0"); } else { return(resl % resr); } } else { if (resr == 0) { throw new DivideByZeroException("Division by 0"); } else { return(resl / resr); } } }
public int Eval(ADT.IDictionary <string, int> dict) { return(dict.getValue(this.varName)); }
public int Eval(ADT.IDictionary <string, int> dict) { return(this.value); }