public PrgState Execute(PrgState p) { try { this.Containsp(p); StreamReader fs = new StreamReader("read.txt"); FileData f = new FileData(fileName, fs); int id = IDGenerator.GenerateId(); p.FileTable.Add(id, f); IMyDictionary <String, int> st = p.SymTable; if (st.ContainsKey(var_file_id)) { st.Update(var_file_id, id); } else { st.Add(var_file_id, id); } } catch (NullReferenceException e) { Console.WriteLine(e.StackTrace); } return(p); }
public PrgState Execute(PrgState p) { IMyDictionary <String, int> symbolT = p.SymTable; int id = expFileId.Eval(symbolT); FileData fd; p.FileTable.TryGetValue(id, out fd); StreamReader bf = fd.FileDescriptor; String s = bf.ReadLine(); int number; if (s.Equals("")) { number = 0; } else { Int32.TryParse(s, out number); } if (symbolT.Exists(varName)) { symbolT.Update(varName, number); } else { symbolT.Add(varName, number); } return(p); }
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 PrgState Execute(PrgState state) { IMyDictionary <string, int> sym = state.SymTable; IMyList <int> msg = state.Messages; int res = expr.Eval(sym); msg.Add(res); return(state); }
public ProgramState(IMyStack<IMyStatement> executionStack, IMyDictionary<string, int> myDictionary, IMyList<string> output, IHeap<int, int> heap, IMyStatement originalProgram) { this.executionStack = executionStack; this.myDictionary = myDictionary; this.output = output; this.originalProgram = originalProgram; this.executionStack.push(originalProgram); this.heap = heap; this.stateId = globalStateId++; }
public override int Eval(IMyDictionary <String, int> sym) { if (sym.ContainsKey(id)) { int v; sym.TryGetValue(id, out v); return(v); } else { throw new Exception("The element does not exist in the symbol table"); } }
public PrgState Execute(PrgState p) { IMyDictionary <string, int> symbolt = p.SymTable; int id; symbolt.TryGetValue(expFileId, out id); FileData fd; p.FileTable.TryGetValue(id, out fd); StreamReader sr = fd.FileDescriptor; sr.Close(); p.FileTable.Remove(id); return(p); }
public PrgState Execute(PrgState state) { IMyStack <IStmt> stk = state.ExeStack; IMyDictionary <string, int> sym = state.SymTable; int val = expr.Eval(sym); if (val == 0) { stk.Push(elses); } else { stk.Push(ifs); } return(state); }
/** * Evaluates the expression * For simplicity the result will be converted to int * @param table The table of values in case of a variable * @return int result */ public int eval(IMyDictionary<string, int> table, IHeap<int, int> heap) { switch (operatorType) { case OperatorsEnum.ADD: return (int)(firstExpression.eval(table, heap) + secondExpression.eval(table, heap)); case OperatorsEnum.SUBSTRACT: return (int)(firstExpression.eval(table, heap) - secondExpression.eval(table, heap)); case OperatorsEnum.MULTIPLY: return (int)(firstExpression.eval(table, heap) * secondExpression.eval(table, heap)); case OperatorsEnum.DIVIDE: return (int)(firstExpression.eval(table, heap) + secondExpression.eval(table, heap)); default: return int.MaxValue; } }
public PrgState Execute(PrgState state) { IMyDictionary <string, int> sym = state.SymTable; IMyStack <IStmt> stk = state.ExeStack; int val = expr.Eval(sym); if (sym.Exists(id)) { sym.Update(id, val); } else { sym.Add(id, val); } return(state); }
/** * Evaluates the expression * For simplicity the result will be converted to int * * @param table The table of values in case of a variable * @return int result */ public int eval(IMyDictionary<string, int> table, IHeap<int, int> heap) { bool firstBoolean; bool secondBoolean; if (firstExpression.eval(table, heap) == 0) { firstBoolean = false; } else { firstBoolean = true; } if (firstExpression.eval(table, heap) == 0) { secondBoolean = false; } else { secondBoolean = true; } switch (operatorType) { case OperatorsEnum.AND: if (firstBoolean && secondBoolean) { return 1; } return 0; case OperatorsEnum.OR: if (firstBoolean || secondBoolean) { return 1; } return 0; case OperatorsEnum.NOT: if (!firstBoolean) { return 1; } return 0; default: return int.MinValue; } }
public MyDictionary <TKey, TValue> Intersect(IMyDictionary <TKey, TValue> other) { var result = new MyDictionary <TKey, TValue>(); foreach (var key in _internal.Keys) { var lst = other.Get(key); if (lst != null) { foreach (var val in lst) { result.Add(key, val); } } } return(result); }
/** * Evaluates the expression * For simplicity the result will be converted to int * @param table The table of values in case of a variable * @return int result */ public int eval(IMyDictionary<string, int> table, IHeap<int, int> heap) { switch (operatorType) { case OperatorsEnum.LESS: if (firstExpression.eval(table, heap) < secondExpression.eval(table, heap)) { return 1; } return 0; case OperatorsEnum.LESS_EQUAL: if (firstExpression.eval(table, heap) <= secondExpression.eval(table, heap)) { return 1; } return 0; case OperatorsEnum.GRATER_EQUAL: if (firstExpression.eval(table, heap) >= secondExpression.eval(table, heap)) { return 1; } return 0; case OperatorsEnum.GRATER: if (firstExpression.eval(table, heap) > secondExpression.eval(table, heap)) { return 1; } return 0; case OperatorsEnum.EQUAL: if (firstExpression.eval(table, heap) == secondExpression.eval(table, heap)) { return 1; } return 0; case OperatorsEnum.DIFFERENT: if (firstExpression.eval(table, heap) != secondExpression.eval(table, heap)) { return 1; } return 0; default: return int.MinValue; } }
public override int Eval(IMyDictionary <String, int> st) { switch (op) { case '+': return(exp1.Eval(st) + exp2.Eval(st)); case '-': return(exp1.Eval(st) - exp2.Eval(st)); case '*': return(exp1.Eval(st) * exp2.Eval(st)); case '/': return(exp1.Eval(st) / exp2.Eval(st)); default: throw new Exception("The operator must be valid!"); } }
public void Initialize() { dict = new MyDictionary <string, string>(); }
/** * Evaluate the variable by getting its value from the Table * @param table Table of values * @return int value */ public int eval(IMyDictionary<string, int> table, IHeap<int, int> heap) { return table.lookUp(name); }
public HomeModule(IMyDictionary dict) { Get["/"] => dict; }
public int eval(IMyDictionary<string, int> table, IHeap<int, int> heap) { return number; }
public int eval(IMyDictionary<string, int> table, IHeap<int, int> heap) { return heap.lookUp(table.lookUp(variableName)); }
public int eval(IMyDictionary<string, int> table) { throw new NotImplementedException(); }
public HangfireController(IBackgroundJobClient backgroundJobClient, IMyDictionary dictionary) { m_BackgroundJobClient = backgroundJobClient; _dictionary = dictionary; }
abstract public int Eval(IMyDictionary <String, int> sym);
public void setMyDictionary(IMyDictionary<string, int> myDictionary) { this.myDictionary = myDictionary; }
public void Initialize() { dict = new MyDictionary<string, string>(); }
public void createProgram(IMyStack<IMyStatement> mExecutionStack, IMyDictionary<String, int> myDictionary, IMyList<String> mOutput, IHeap<int, int> heap, IMyStatement mInitialProgram) { programStateList.Add(new ProgramState(mExecutionStack, myDictionary, mOutput, heap, mInitialProgram)); }
public override int Eval(IMyDictionary <string, int> sym) { return(number); }