Esempio n. 1
0
 public PrgState(ISymbolTable <string, int> s, IExeStack <Statement> exe, IOutput <int> o, IFileTable <int, FileData> ft)
 {
     this.symbolTable = s;
     this.exeStack    = exe;
     this.output      = o;
     this.filetable   = ft;
 }
 public PrgState(IDictionary <string, int> dict, IExeStack <IStatement> stack, IMyList <int> outList, FileTable <int, FileData> fileTable)
 {
     this.dict      = dict;
     this.stack     = stack;
     this.outList   = outList;
     this.fileTable = fileTable;
 }
        public PrgState Execute(PrgState p)
        {
            IExeStack <Statement> stk = p.Stack;

            stk.Push(this.second);
            stk.Push(this.first);
            return(p);
        }
Esempio n. 4
0
        public PrgState execute(PrgState p)
        {
            IExeStack <Statement> exe = p.ExeStack;

            exe.push(this.second);
            exe.push(this.first);
            return(p);
        }
Esempio n. 5
0
 public PrgState(ADT.IDictionary <string, int> s, IExeStack <Statement> exe, IOutput <int> o, IFileTable <int, FileData> ft, Statement st)
 {
     this.symbolTable = s;
     this.exeStack    = exe;
     this.output      = o;
     this.filetable   = ft;
     exe.Push(st);
 }
Esempio n. 6
0
 public PrgState(IDictionaryy <string, int> d, IExeStack <Statement> exes, IListt <int> ol, Statement s, FileTable <int, FileData> ft)
 {
     dict       = d;
     stack      = exes;
     outputList = ol;
     stmt       = s;
     fileTable  = ft;
 }
Esempio n. 7
0
        public PrgState Execute(PrgState state)
        {
            IExeStack <IStmt> exeStack = state.ExeStack;

            exeStack.Push(second);
            exeStack.Push(first);

            return(state);
        }
        public void executeAll()
        {
            IExeStack <IStatement> stack = state.Stack;

            while (!stack.isEmpty())
            {
                executeOneStep();
            }
        }
        public void executeOneStep()
        {
            IExeStack <IStatement> stack = state.Stack;

            IStatement statement = stack.pop();

            statement.execute(state);
            printState(state);
        }
Esempio n. 10
0
 public PrgState(Statement ip,
                 IExeStack <Statement> es,
                 ISymbolTable <string, int> st,
                 IFileTable <int, FileStream> ft,
                 IOutput <int> o)
 {
     this.initialProg = ip;
     this.exeStack    = es; this.exeStack.push(ip);
     this.symTable    = st;
     this.fileTable   = ft;
     this.output      = o;
 }
Esempio n. 11
0
        public void executeOneStep()
        {
            PrgState ps = repo.GetCurrentProgram();
            IExeStack <Statement> ex = ps.ExeStack;

            if (!ex.IsEmpty())
            {
                Statement stmt = ex.PopS();
                stmt.Execute(ps);
            }
            Console.WriteLine("----------------------------------------------\n\n");
        }
Esempio n. 12
0
        private PrgState OneStep(PrgState state)
        {
            IExeStack <IStmt> stk = state.ExeStack;

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

            IStmt crtStmt = stk.Pop();

            return(crtStmt.Execute(state));
        }
Esempio n. 13
0
        public PrgState oneStep(PrgState state)
        {
            IExeStack <Statement> exeStack = state.ExeStack;

            if (exeStack.isEmpty())
            {
                throw new IException("exe stack is empty");
            }
            Statement stmt = exeStack.pop();

            Console.WriteLine(stmt);
            return(stmt.execute(state));
        }
Esempio n. 14
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. 15
0
        public PrgState execute(PrgState p)
        {
            IExeStack <Statement>      exe = p.ExeStack;
            ISymbolTable <string, int> t   = p.getSymbolTable();
            int resExpr = this.expr.evaluate(t);

            if (resExpr != 0)
            {
                exe.push(this.first);
            }
            else
            {
                exe.push(this.second);
            }

            return(p);
        }
Esempio n. 16
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. 17
0
        public void executeAll()
        {
            PrgState ps = repo.GetCurrentProgram();
            IExeStack <Statement> es = ps.ExeStack;

            while (!es.IsEmpty())
            {
                try
                {
                    executeOneStep();
                    repo.logPrgStateExec();
                }
                catch (FileException e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            Console.WriteLine("----------------------------------------------\n\n");
        }