示例#1
0
        /// <summary>
        /// Adds a constant to a copy of this value and returns the result. Returns null if it's not supported.
        /// </summary>
        /// <param name="kind">Opcode kind</param>
        /// <param name="value">Value to add</param>
        /// <param name="pointerSize">Size of a pointer in bytes</param>
        /// <returns></returns>
        public override ILValue?Add(AddOpCodeKind kind, long value, int pointerSize)
        {
            if (value == 0)
            {
                return(this);
            }

            switch (kind)
            {
            case AddOpCodeKind.Add:
                if (pointerSize == 4)
                {
                    return(new NativeMemoryILValue(data, Offset32 + (int)value));
                }
                return(new NativeMemoryILValue(data, Offset64 + value));

            case AddOpCodeKind.Add_Ovf:
                if (pointerSize == 4)
                {
                    int value2 = (int)value;
                    return(new NativeMemoryILValue(data, checked (Offset32 + value2)));
                }
                return(new NativeMemoryILValue(data, checked (Offset64 + value)));

            case AddOpCodeKind.Add_Ovf_Un:
                if (pointerSize == 4)
                {
                    uint value2 = (uint)value;
                    return(new NativeMemoryILValue(data, (int)checked (UnsignedOffset32 + value2)));
                }
                else
                {
                    ulong value2 = (ulong)value;
                    return(new NativeMemoryILValue(data, (long)checked (UnsignedOffset64 + value2)));
                }

            default:
                throw new InvalidOperationException();
            }
        }
示例#2
0
 /// <summary>
 /// Adds a constant to a copy of this value and returns the result. Returns null if it's not supported.
 /// </summary>
 /// <param name="kind">Opcode kind</param>
 /// <param name="value">Value to add</param>
 /// <param name="pointerSize">Size of a pointer in bytes</param>
 /// <returns></returns>
 public virtual ILValue?Add(AddOpCodeKind kind, long value, int pointerSize) => null;