public PrgState Execute(PrgState state) { if (IsOpen(state)) { throw new Exception("File " + fileName + " is open"); } else { System.IO.StreamReader file = new System.IO.StreamReader(fileName); FileData fd = new FileData(fileName, file); int id = IDGenerator.GenerateId(); // add the id and the descriptor state.FileTable.Add(id, fd); // get the dictionary IModDictionary <string, int> dict = state.SymbTable; if (dict.Contains(varFileId)) { dict.Update(varFileId, id); } else { dict.Put(varFileId, id); } return(state); } }
public override int Eval(IModDictionary <string, int> symbTable) { if (symbTable.Contains(id)) { return(symbTable.Get(id)); } throw new Exception("Element not found"); }
public PrgState Execute(PrgState state) { IModDictionary <string, int> symbTable = state.SymbTable; int val = exp.Eval(symbTable); if (symbTable.Contains(id)) { symbTable.Update(id, val); } else { symbTable.Put(id, val); } return(state); }
public PrgState Execute(PrgState state) { int value; IModDictionary <string, int> symbTable = state.SymbTable; // int id = expFileId.Eval(symbTable); // FileData fd = state.FileTable.Get(id); System.IO.StreamReader reader = fd.Header; string line = reader.ReadLine(); if (line == null) { value = 0; } else { value = Int32.Parse(line); System.Console.WriteLine(">>>>>>>>>>>>>>> " + value); } if (symbTable.Contains(varName)) { symbTable.Update(varName, value); } else { symbTable.Put(varName, value); } return(state); }