public PrgState Execute(PrgState state)
        {
            MyIList <int> list = state.GetPrintList();

            list.Add1(exp.Eval(state.GetSymTable(), state.GetHeap()));
            return(null);
        }
Exemple #2
0
 public PrgState <T> Execute <T>(PrgState <T> state)
 {
     if (mExp.Eval(state.GetSymTable(), state.GetHeap()) > 0)
     {
         state.AddExeStack((T)(IStmt)this);
         state.AddExeStack((T)mStatement);
     }
     return(null);
 }
Exemple #3
0
 public PrgState <T> Execute <T>(PrgState <T> state)
 {
     if (mExp.Eval(state.GetSymTable(), state.GetHeap()) != 0)
     {
         state.AddExeStack((T)mThenS);
     }
     else
     {
         state.AddExeStack((T)mElseS);
     }
     return(null);
 }
Exemple #4
0
        public PrgState <T> Execute <T>(PrgState <T> state)
        {
            MyIStack <T> stk2 = new MyStack <T>();

            stk2.Push((T)mStmt);
            int          id   = state.GetId();
            MyDictionary sym2 = new MyDictionary();

            sym2 = (MyDictionary)state.GetSymTable().DeepCopy();
            PrgState <T> state2 = new PrgState <T>(
                stk2, sym2, state.GetOut(), state.GetHeap(), ++id);

            return(state2);
        }
Exemple #5
0
        public PrgState <T> Execute <T>(PrgState <T> state)
        {
            MyIHeap       heap     = state.GetHeap();
            MyIDictionary symTable = state.GetSymTable();

            if (symTable.IsDefined(mVarName))
            {
                heap.Update(symTable.Lookup(mVarName), mExp.Eval(symTable, heap));;
            }
            else
            {
                throw new ArgumentException("Heap address undefined");
            }

            return(null);
        }
Exemple #6
0
        public PrgState Execute(PrgState state)
        {
            MyIStack <IStmt> stk      = state.GetStk();
            IStmt            thenStmt = this.thenS;
            IStmt            elseStmt = this.elseS;

            if (exp.Eval(state.GetSymTable(), state.GetHeap()) != 0)
            {
                stk.Push(thenStmt);
            }
            else
            {
                stk.Push(elseStmt);
            }
            return(null);
        }
Exemple #7
0
        public PrgState Execute(PrgState state)
        {
            Stack <MyIDictionary <MyMap> > symTbl = state.GetSymTable();
            IHeap <HMap> heap    = state.GetHeap();
            int          address = symTbl.ElementAt(0).Lookup(this.var);

            try
            {
                HMap h = (HMap)heap.Gett(address);
                h.SetAddr(address);
                h.SetCont(exp.Eval(symTbl, heap));
            }
            catch (MissingMemberException e)
            {
            }
            return(null);
        }
Exemple #8
0
        public PrgState <T> Execute <T>(PrgState <T> state)
        {
            MyIDictionary symTbl = state.GetSymTable();
            int           val;

            val = mExp.Eval(symTbl, state.GetHeap());

            if (symTbl.IsDefined(mId))
            {
                symTbl.Update(mId, val);
            }
            else
            {
                symTbl.Add(mId, val);
            }
            return(null);
        }
Exemple #9
0
        PrgState IStmt.Execute(PrgState state)
        {
            MyIStack <IStmt> stack = new MyLibStack <IStmt>();
            Stack <MyIDictionary <MyMap> > symtable = state.GetSymTable();
            MyIList <int> printList = state.GetPrintList();
            IHeap <HMap>  h         = state.GetHeap();

            MyLibStack <IStmt> crtstm = new MyLibStack <IStmt>();


            PrgState childPrgState = new PrgState(stack, symtable, printList, stmt, h);

            childPrgState.id = state.id * 10;


            return(childPrgState);
        }
Exemple #10
0
        public PrgState Execute(PrgState state)
        {
            MyIStack <IStmt> stk = state.GetStk();

            IStmt[] s = this.stmt;
            int     k = exp.Eval(state.GetSymTable(), state.GetHeap());

            while (k > 0)
            {
                for (int i = 0; i < s.Length; i++)
                {
                    stk.Push(s[i]);
                }
                k--;
            }
            return(null);
        }
Exemple #11
0
        public PrgState <T> Execute <T>(PrgState <T> state)
        {
            MyIHeap       heap     = state.GetHeap();
            MyIDictionary symTable = state.GetSymTable();

            if (symTable.IsDefined(mVarName))
            {
                symTable.Update(mVarName, heap.Size() + 1);
                heap.Put(heap.Size() + 1, mExp.Eval(symTable, heap));
            }
            else
            {
                symTable.Add(mVarName, heap.Size() + 1);
                heap.Put(heap.Size() + 1, mExp.Eval(symTable, heap));
            }

            return(null);
        }
        public PrgState Execute(PrgState state)
        {
            Exp exp = this.exp;
            Stack <MyIDictionary <MyMap> > symTbl = state.GetSymTable();
            String       id  = this.id;
            IHeap <HMap> h   = state.GetHeap();
            int          val = exp.Eval(symTbl, h);

            if (symTbl.ElementAt(0).IsDefined(id))
            {
                symTbl.ElementAt(0).Update(id, val);
            }
            else
            {
                MyMap m = new MyMap(id, val);
                symTbl.ElementAt(0).Add(m);
            }
            return(null);
        }
Exemple #13
0
        public PrgState Execute(PrgState state)
        {
            Stack <MyIDictionary <MyMap> > symTbl = state.GetSymTable();
            IHeap <HMap> heap  = state.GetHeap();
            String       v     = this.var;
            int          index = heap.GiveHeapLocation();

            int val = exp.Eval(symTbl, heap);

            if (symTbl.ElementAt(0).IsDefined(v))
            {
                symTbl.ElementAt(0).Update(v, index);
            }

            else
            {
                MyMap m = new MyMap(v, index);
                symTbl.ElementAt(0).Add(m);
            }

            heap.Add1(val);

            return(null);
        }
Exemple #14
0
        public PrgState <T> Execute <T>(PrgState <T> state)
        {
            state.AddOut(mExp.Eval(state.GetSymTable(), state.GetHeap()).ToString());

            return(null);
        }