예제 #1
0
        public PrgState execute(PrgState state)
        {
            MyIStack <IStmt> stk = state.getExeStack();
            // stk.pop();

            MyIDictionary <String, int> symTbl  = state.getSymTable();
            IFileTable <int, FileTuple> fileTbl = state.getFileTable();

            int value_exp = this.exp_file_id.eval(symTbl);


            FileTuple ft = fileTbl.getValue(value_exp);

            if (!fileTbl.isDefined(value_exp))
            {
                throw new Exception("The key is not defined in the file table");
            }

            StreamReader streamReader = fileTbl.getValue(value_exp).getStreamReader();

            try
            {
                streamReader.Close();
            }
            catch (IOException ex) { throw new Exception(ex.Message); }

            fileTbl.remove(value_exp);
            return(state);
        }
예제 #2
0
 public ProgramState(MyIStack <IStatement> executionStack, MyIDictionary <string, int> symbolTable,
                     MyIList <int> output)
 {
     this.executionStack = executionStack;
     this.symbolTable    = symbolTable;
     this.output         = output;
 }
예제 #3
0
        public PrgState oneStep(PrgState state)
        {
            MyIStack <IStmt> stk     = state.getStk();
            IStmt            crtStmt = stk.pop();

            return(crtStmt.execute(state));
        }
예제 #4
0
        public PrgState oneStep(PrgState state)
        {
            MyIStack <IStmt> stk = state.getExeStack();

            try
            {
                if (stk.empty())
                {
                    throw new Exception("Empty stack");
                }

                IStmt    crtStmt  = stk.pop();
                PrgState newState = crtStmt.execute(state);
                if (flag == 1)
                {
                    this.displayCrtPrgState(newState);
                }
                //repo.logPrgStateExec();
                return(newState);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #5
0
        public ProgState execute(ProgState prog)
        {
            MyIStack <IStmt> stk = prog.getStk();

            stk.push(st2);
            stk.push(st1);
            return(prog);
        }
예제 #6
0
        public PrgState execute(PrgState state)
        {
            MyIStack <IStmt> stk = state.getStk();

            stk.push(second);
            stk.push(first);
            return(null);
        }
예제 #7
0
 public PrgState(MyIStack <IStmt> exeStack, MyIDictionary <string, int> symTable, MyIList <int> output, MyIFileDictionary <int, KeyValuePair <string, StreamReader> > fileTable, IStmt prg)
 {
     this.exeStack  = exeStack;
     this.symTable  = symTable;
     this.output    = output;
     this.fileTable = fileTable;
     exeStack.push(prg);
 }
예제 #8
0
파일: PrgState.cs 프로젝트: pamhrituc/MAP
 public PrgState(MyIStack <IStmt> stk, MyIDictionary <String, int> symtbl, MyIList <int> ot, MyIDictionary <int, MyPair <String, StreamReader> > fT, IStmt prg)
 {
     exeStack  = stk;
     symTable  = symtbl;
     outList   = ot;
     fileTable = fT;
     exeStack.Push(prg);
 }
예제 #9
0
 public ProgramState(IStatement statement)
 {
     executionStack = new MyStack <IStatement>(new Stack <IStatement>());
     executionStack.Push(statement);
     symbolTable = new MyDictionary <string, int>(new Dictionary <string, int>());
     outputList  = new MyList <int>(new List <int>());
     fileTable   = new MyDictionary <int, Tuple <string, TextReader> >(new Dictionary <int, Tuple <string, TextReader> >());
 }
예제 #10
0
 public PrgState(IStmt prg)
 {
     exeStack = new MyStack <IStmt>(new Stack <IStmt>());
     exeStack.push(prg);
     symTable  = new MyDictionary <string, int>(new Dictionary <string, int>());
     outList   = new MyList <int>(new List <int>());
     fileTable = new MyDictionary <int, Tuple <string, TextReader> >(new Dictionary <int, Tuple <string, TextReader> >());
 }
예제 #11
0
        public ProgramState Execute(ProgramState state)
        {
            MyIStack <IStatement> stack = state.getExecutionStack();

            stack.Push(second);
            stack.Push(first);
            return(null);
        }
예제 #12
0
        public PrgState execute(PrgState prgState)
        {
            MyIStack <IStmt> stk = prgState.getExeStack();

            stk.push(second);
            stk.push(first);
            return(prgState);
        }
예제 #13
0
 public ProgState(MyIStack <IStmt> stk, MyIDictionary <string, int> dict, MyIList <int> list, MyIFileTable <Tuple> fileT, IStmt prog)
 {
     this.stk   = stk;
     this.dict  = dict;
     this.list  = list;
     this.fileT = fileT;
     stk.push(prog);
 }
예제 #14
0
        public PrgState execute(PrgState state)
        {
            MyIStack <IStmt> stk = state.getExeStack();

            stk.push(snd);
            stk.push(first);
            return(state);
        }
        public ProgramState Execute(ProgramState state)
        {
            MyIStack <IStatement> st = state.GetExeStack();

            st.Push(this.second);
            st.Push(this.first);
            return(null);
        }
예제 #16
0
 public PrgState(MyIStack<T> stk, MyIDictionary symtbl, MyIList ot, MyIHeap heap, int id)
 {
     exeStack = stk;
     @out = ot;
     symTable = symtbl;
     mHeap = heap;
     mId = id;
 }
예제 #17
0
 public PrgState(IStmt prg)
 {
     this.exeStack        = new MyStack <IStmt>();
     this.symTable        = new MyDictionary <String, int>();
     this.outTbl          = new MyList <int>();
     this.originalProgram = prg.deepCopy();
     this.fileTable       = new FileTable <int, FileTuple>();
     this.exeStack.push(prg);
 }
예제 #18
0
        public ProgramState Execute(ProgramState programState)
        {
            MyIStack <IStatement> executionStack = programState.ExecutionStack;

            executionStack.Push(second);
            executionStack.Push(first);

            return(programState);
        }
예제 #19
0
 public PrgState(IStmt prg)
 {
     exeStack        = new MyStack <IStmt>();
     symTable        = new MyDictionary <string, int>();
     outList         = new MyList <int>();
     fileTable       = new MyFileTable <int, Tuple <string, StreamReader> >();
     originalProgram = prg;
     exeStack.push(prg);
 }
예제 #20
0
 public PrgState()
 {
     id              = 0;
     exeStack        = null;
     symTable        = null;
     output          = null;
     originalProgram = null;
     heap            = null;
 }
예제 #21
0
 public PrgState(MyIStack <IStmt> stk, MyIDictionary <string, int> symtbl,
                 MyIList <int> ot, IFileTable <int, FileTuple> fileTable, IStmt prg)
 {
     this.exeStack        = stk;
     this.symTable        = symtbl;
     this.outTbl          = ot;
     this.originalProgram = prg.deepCopy();
     this.fileTable       = fileTable;
     this.exeStack.push(prg);
 }
예제 #22
0
        public PrgState Execute(PrgState state)
        {
            MyIStack <IStmt> stk = state.GetStk();

            stk.Push(this.snd);
            stk.Push(this.first);


            return(null);
        }
예제 #23
0
        public PrgState <T> Execute <T>(PrgState <T> state)
        {
            MyIStack <T> stk = state.GetStk();

            stk.Push((T)mSecond);


            stk.Push((T)mFirst);
            return(null);
        }
        public PrgState oneStep(PrgState prgState)
        {
            MyIStack <IStmt> exeStack = prgState.getExeStack();

            if (exeStack.isEmpty())
            {
                throw new Exception("stack is empty");
            }
            return(exeStack.pop().execute(prgState));
        }
예제 #25
0
 public PrgState(MyIStack <IStmt> stk, Stack <MyIDictionary <MyMap> > symtbl, MyIList <int> otp, IStmt crtstm, IHeap <HMap> h)
 {
     id++;
     exeStack        = stk;
     symTable        = symtbl;
     output          = otp;
     originalProgram = crtstm;
     exeStack.Push(crtstm);
     heap = h;
 }
예제 #26
0
        public ProgramState OneStep(ProgramState prgState)
        {
            MyIStack <IStatement> exeStack = prgState.getExecutionStack();

            if (exeStack.IsEmpty())
            {
                throw new Exception("stack is empty");
            }
            return(exeStack.Pop().Execute(prgState));
        }
예제 #27
0
        public PrgState OneStep(PrgState state)
        {
            MyIStack <IStmt> stk = state.GetExeStack();

            if (stk.IsEmpty())
            {
                throw new MyException("Stack is empty");
            }
            IStmt crtStmt = stk.Pop();

            return(crtStmt.Execute(state));
        }
        public ProgramState(MyIStack <IStatement> exeStack, MyIDictionary <string, int> symTab,
                            MyIList <int> outList, MyIDictionary <int, MyPair <string, StreamReader> > fileTab,
                            IStatement originalProgram)
        {
            this.exeStack        = exeStack;
            this.symTab          = symTab;
            this.outList         = outList;
            this.fileTab         = fileTab;
            this.originalProgram = originalProgram;

            this.exeStack.Push(originalProgram);
        }
예제 #29
0
        private ProgramState ExecuteOneStep(ProgramState programState)
        {
            MyIStack <IStatement> executionStack = programState.ExecutionStack;

            if (executionStack.IsEmpty)
            {
                throw new InterpreterControllerException("Execution stack is empty!");
            }

            IStatement current = executionStack.Pop();

            return(current.Execute(programState));
        }
예제 #30
0
        public ProgramState OneStep(ProgramState state)
        {
            MyIStack <IStatement> st = state.GetExeStack();

            try
            {
                IStatement currentStatement = st.Pop();
                return(currentStatement.Execute(state));
            }
            catch (EmptyMyStackException)
            {
                throw new MyStatementExecutionException("Exception. Execution stack is empty.");
            }
        }