Esempio n. 1
0
        public PrgState Execute(PrgState p)
        {
            IMyDictionary <String, int> symbolT = p.SymTable;
            int      id = expFileId.Eval(symbolT);
            FileData fd;

            p.FileTable.TryGetValue(id, out fd);
            StreamReader bf = fd.FileDescriptor;
            String       s  = bf.ReadLine();
            int          number;

            if (s.Equals(""))
            {
                number = 0;
            }
            else
            {
                Int32.TryParse(s, out number);
            }

            if (symbolT.Exists(varName))
            {
                symbolT.Update(varName, number);
            }
            else
            {
                symbolT.Add(varName, number);
            }
            return(p);
        }
Esempio n. 2
0
        public PrgState Execute(PrgState state)
        {
            IMyDictionary <string, int> sym = state.SymTable;
            IMyStack <IStmt>            stk = state.ExeStack;
            int val = expr.Eval(sym);

            if (sym.Exists(id))
            {
                sym.Update(id, val);
            }
            else
            {
                sym.Add(id, val);
            }
            return(state);
        }