Esempio n. 1
0
        public PrgState Execute(PrgState state)
        {
            IModDictionary <string, int> symbTable = state.SymbTable;
            int id = expFileId.Eval(symbTable);

            FileData fd = state.FileTable.Get(id);

            System.IO.StreamReader reader = fd.Header;
            reader.Close();
            state.FileTable.Remove(id);

            return(state);
        }
Esempio n. 2
0
 public PrgState(
     IExeStack <IStmt> _exeStack,
     IModDictionary <string, int> _symbTable,
     IModList <int> _outList,
     IFileTable <int, FileData> _fileTable,
     IStmt _originalProgram
     )
 {
     this.ExeStack        = _exeStack;
     this.SymbTable       = _symbTable;
     this.OutList         = _outList;
     this.FileTable       = _fileTable;
     this.OriginalProgram = _originalProgram;
     ExeStack.Push(OriginalProgram);
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        public PrgState Execute(PrgState state)
        {
            IModDictionary<string, int> symbTable = state.SymbTable;
            IExeStack<IStmt> exeStack = state.ExeStack;

            int res = exp.Eval(symbTable);
            
            if (res != 0)
            {
                exeStack.Push(thenS);
            }
            else
            {
                exeStack.Push(elseS);
            }

            return state;
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
 public abstract int Eval(IModDictionary <string, int> symbTable);
Esempio n. 7
0
 public override int Eval(IModDictionary <string, int> symbTable)
 {
     return(number);
 }