Esempio n. 1
0
 public GetValByAdress(IOperation adress, ValueType retType)
 {
     operationString = "get";
     a = adress;
     try
     {
         variable        = ASTTree.variables[(int)((adress as ASTvalue).getValue)];
         operationString = variable.name;
         returnType      = variable.returnTypes();
         from            = variable;
         return;
     }
     catch (Exception e)
     {
         variable = null;
         try
         {
             adder = (a as BinarySummatic).FindNonVariable(out from);
         }
         catch (Exception E)
         {
             // case if you have only *d, but not d[0], so there is no summ action in there
             from = adress; adder = new ASTvalue(new ValueType(VT.Cint), (object)0);
         }
         returnType = retType.TypeOfPointedByThis();
     };
 }
Esempio n. 2
0
        public GetValByAdress(IOperation adress, ValueType retType)
        {
            operationString = "get";
            a = adress;
            try
            {
                if ((adress as ASTvalue) != null)
                {
                    operationString = ASTTree.variables[(int)((adress as ASTvalue).getValue)].name;
                    returnType      = ASTTree.variables[(int)((adress as ASTvalue).getValue)].returnTypes();
                    return;
                }
                throw new Exception("Get by adress operation error! " + adress.ToString());
            }
            catch (Exception e)
            {
                returnType = retType.TypeOfPointedByThis();
            };

            //a = adress;
            ////if (a.returnTypes() != ValueType.Cadress)
            ////    throw new Exception("You can get value only by number of memory slot!");

            //returnType = retType;

            //if (retType == VT.Cadress)
            //{
            //    //IOperation dep = a; int res = -1;
            //    //while ((a as GetValByAdress) != null)
            //    //{
            //    //    a.Trace(0);
            //    //    res = (a as GetValByAdress).GetAdress();
            //    //    a = (a as GetValByAdress).a;
            //    //}
            //    //if (res >= 0)
            //    //    returnType = ASTTree.variables[res].returnTypes();

            //    //Console.WriteLine(a.returnTypes() + " /// " + res + " //// " + returnType.ToString());
            //    //Console.ReadKey();
            //    IOperation dep = a; int res = -1;
            //    while (a.returnTypes() == ValueType.Cadress)
            //    {
            //        a.Trace(0);
            //        res = ((a as GetValByAdress) != null) ? (a as GetValByAdress).GetAdress() : (int)((a as ASTvalue).getValue);
            //        a = ASTTree.variables[res];
            //        returnType = a.returnTypes();
            //        dep = new GetValByAdress(new ASTvalue(ValueType.Cadress, (object)res), returnType, true);
            //    }
            //    a = dep;
            //}
        }