Example #1
0
 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);
 }
Example #2
0
        public PrgState execute(PrgState state)
        {
            IDictRandIntKey <MyTuple <String, TextReader> > fileTable = state.getFileTable();

            foreach (MyTuple <String, TextReader> act in fileTable.values())
            {
                if (act.getFirst() == this.filename)
                {
                    throw new FileAlreadyUsed();
                }
            }
            if (!File.Exists(this.filename))
            {
                throw new FileDoesntExist();
            }
            IDict <String, int> symTbl         = state.getSymTbl();
            FileStream          fs             = File.OpenRead(this.filename);
            TextReader          bufferedReader = new StreamReader(fs);
            int uniqueRandomNumber             = fileTable.add(new MyTuple <String, TextReader>(this.filename, bufferedReader));

            symTbl.add(var_file_id, uniqueRandomNumber);
            return(state);
        }