Exemple #1
0
 public override object ConvertValueToHardwareType(object value)
 {
     if (_isSigned)
     {
         long longVal = (long)Convert.ChangeType(value, typeof(long));
         return(Signed.FromLong(longVal, _size));
     }
     else
     {
         ulong ulongVal = (ulong)Convert.ChangeType(value, typeof(ulong));
         return(Unsigned.FromULong(ulongVal, _size));
     }
 }
Exemple #2
0
        public override bool Rewrite(CodeDescriptor decompilee, MethodBase callee, StackElement[] args, IDecompiler stack, IFunctionBuilder builder)
        {
            if (args[0].Sample == null)
            {
                return(false);
            }

            ISized one, rsample;

            if (IsSigned)
            {
                Signed sample = (Signed)args[0].Sample;
                Signed sone   = Signed.FromLong(1, (int)sample.Size);
                one     = sone;
                rsample = sample + sone;
            }
            else
            {
                Unsigned sample = (Unsigned)args[0].Sample;
                Unsigned uone   = Unsigned.FromULong(1, (int)sample.Size);
                one     = uone;
                rsample = sample + uone;
            }
            LiteralReference oneLit = LiteralReference.CreateConstant(one);
            Expression       inc;

            if (IsDecrement)
            {
                inc = args[0].Expr - oneLit;
            }
            else
            {
                inc = args[0].Expr + oneLit;
            }
            inc.ResultType = TypeDescriptor.GetTypeOf(rsample);
            inc            = IntrinsicFunctions.Resize(inc, (int)one.Size, TypeDescriptor.GetTypeOf(one));
            stack.Push(new StackElement(inc, one, Analysis.Msil.EVariability.ExternVariable));
            return(true);
        }