public override bool StoreIndirect(DmdType type, LoadValueType loadValueType, ILValue value) { Collection[Index] = value; return(true); }
public override bool StoreIndirect(DmdType type, LoadValueType loadValueType, ILValue value) { Fields[Field] = value; return(true); }
public override ILValue LoadIndirect(DmdType type, LoadValueType loadValueType) => Collection[Index];
/// <summary> /// Stores a value. Returns false if it's not supported. /// </summary> /// <param name="type">Type</param> /// <param name="loadValueType">Type of value to store</param> /// <param name="value">Value</param> /// <returns></returns> public override bool StoreIndirect(DmdType type, LoadValueType loadValueType, ILValue value) { int pointerSize = type.AppDomain.Runtime.PointerSize; long v; double d; switch (loadValueType) { case LoadValueType.I: if (pointerSize == 4) { if (offset + 4 - 1 < offset || (ulong)offset + 4 - 1 >= (ulong)data.Length) { return(false); } if (!GetValue(value, pointerSize, out v)) { return(false); } WriteInt32(data, (int)offset, v); return(true); } else { Debug.Assert(pointerSize == 8); if (offset + 8 - 1 < offset || (ulong)offset + 8 - 1 >= (ulong)data.Length) { return(false); } if (!GetValue(value, pointerSize, out v)) { return(false); } WriteInt64(data, (int)offset, v); return(true); } case LoadValueType.I1: case LoadValueType.U1: if ((ulong)offset >= (ulong)data.Length) { return(false); } if (!GetValue(value, pointerSize, out v)) { return(false); } WriteInt8(data, (int)offset, v); return(true); case LoadValueType.I2: case LoadValueType.U2: if (offset + 2 - 1 < offset || (ulong)offset + 2 - 1 >= (ulong)data.Length) { return(false); } if (!GetValue(value, pointerSize, out v)) { return(false); } WriteInt16(data, (int)offset, v); return(true); case LoadValueType.I4: case LoadValueType.U4: if (offset + 4 - 1 < offset || (ulong)offset + 4 - 1 >= (ulong)data.Length) { return(false); } if (!GetValue(value, pointerSize, out v)) { return(false); } WriteInt32(data, (int)offset, v); return(true); case LoadValueType.I8: if (offset + 8 - 1 < offset || (ulong)offset + 8 - 1 >= (ulong)data.Length) { return(false); } if (!GetValue(value, pointerSize, out v)) { return(false); } WriteInt64(data, (int)offset, v); return(true); case LoadValueType.R4: if (offset + 4 - 1 < offset || (ulong)offset + 4 - 1 >= (ulong)data.Length) { return(false); } if (!GetValue(value, out d)) { return(false); } WriteSingle(data, (int)offset, (float)d); return(true); case LoadValueType.R8: if (offset + 8 - 1 < offset || (ulong)offset + 8 - 1 >= (ulong)data.Length) { return(false); } if (!GetValue(value, out d)) { return(false); } WriteDouble(data, (int)offset, d); return(true); case LoadValueType.Ref: return(false); default: return(false); } }
public override ILValue LoadIndirect(DmdType type, LoadValueType loadValueType) => Fields[Field];
/// <summary> /// Stores a value. Returns false if it's not supported. /// </summary> /// <param name="type">Type</param> /// <param name="loadValueType">Type of value to store</param> /// <param name="value">Value</param> /// <returns></returns> public virtual bool StoreIndirect(DmdType type, LoadValueType loadValueType, ILValue value) => false;
/// <summary> /// Loads a value. Returns null if it's not supported. /// </summary> /// <param name="type">Type</param> /// <param name="loadValueType">Type of value to load</param> /// <returns></returns> public override ILValue?LoadIndirect(DmdType type, LoadValueType loadValueType) { int pointerSize = type.AppDomain.Runtime.PointerSize; switch (loadValueType) { case LoadValueType.I: if (pointerSize == 4) { if (offset + 4 - 1 < offset || (ulong)offset + 4 - 1 >= (ulong)data.Length) { return(null); } return(ConstantNativeIntILValue.Create32(type.AppDomain, BitConverter.ToInt32(data, (int)offset))); } else { Debug.Assert(pointerSize == 8); if (offset + 8 - 1 < offset || (ulong)offset + 8 - 1 >= (ulong)data.Length) { return(null); } return(ConstantNativeIntILValue.Create64(type.AppDomain, BitConverter.ToInt64(data, (int)offset))); } case LoadValueType.I1: if ((ulong)offset >= (ulong)data.Length) { return(null); } return(new ConstantInt32ILValue(type.AppDomain.System_SByte, (sbyte)data[(int)offset])); case LoadValueType.I2: if (offset + 2 - 1 < offset || (ulong)offset + 2 - 1 >= (ulong)data.Length) { return(null); } return(new ConstantInt32ILValue(type.AppDomain.System_Int16, BitConverter.ToInt16(data, (int)offset))); case LoadValueType.I4: if (offset + 4 - 1 < offset || (ulong)offset + 4 - 1 >= (ulong)data.Length) { return(null); } return(new ConstantInt32ILValue(type.AppDomain.System_Int32, BitConverter.ToInt32(data, (int)offset))); case LoadValueType.I8: if (offset + 8 - 1 < offset || (ulong)offset + 8 - 1 >= (ulong)data.Length) { return(null); } return(new ConstantInt64ILValue(type.AppDomain.System_Int64, BitConverter.ToInt64(data, (int)offset))); case LoadValueType.R4: if (offset + 4 - 1 < offset || (ulong)offset + 4 - 1 >= (ulong)data.Length) { return(null); } return(new ConstantFloatILValue(type.AppDomain.System_Single, BitConverter.ToSingle(data, (int)offset))); case LoadValueType.R8: if (offset + 8 - 1 < offset || (ulong)offset + 8 - 1 >= (ulong)data.Length) { return(null); } return(new ConstantFloatILValue(type.AppDomain.System_Double, BitConverter.ToDouble(data, (int)offset))); case LoadValueType.Ref: return(null); case LoadValueType.U1: if ((ulong)offset >= (ulong)data.Length) { return(null); } return(new ConstantInt32ILValue(type.AppDomain.System_Byte, data[(int)offset])); case LoadValueType.U2: if (offset + 2 - 1 < offset || (ulong)offset + 2 - 1 >= (ulong)data.Length) { return(null); } return(new ConstantInt32ILValue(type.AppDomain.System_UInt16, BitConverter.ToUInt16(data, (int)offset))); case LoadValueType.U4: if (offset + 4 - 1 < offset || (ulong)offset + 4 - 1 >= (ulong)data.Length) { return(null); } return(new ConstantInt32ILValue(type.AppDomain.System_UInt32, BitConverter.ToInt32(data, (int)offset))); default: return(null); } }
/// <summary> /// Loads a value. Returns null if it's not supported. /// </summary> /// <param name="type">Type</param> /// <param name="loadValueType">Type of value to load</param> /// <returns></returns> public virtual ILValue?LoadIndirect(DmdType type, LoadValueType loadValueType) => null;
/// <summary> /// Writes an SZ array element. Returns false if it's not supported. /// </summary> /// <param name="loadValueType">Type of value to store</param> /// <param name="index">Index</param> /// <param name="value">Value</param> /// <param name="elementType">Optional element type (eg. it's the stelem instruction)</param> /// <returns></returns> public virtual bool StoreSZArrayElement(LoadValueType loadValueType, long index, ILValue value, DmdType elementType) => false;
/// <summary> /// Loads an SZ array element. Returns null if it's not supported. /// </summary> /// <param name="loadValueType">Type of value to load</param> /// <param name="index">Array index</param> /// <param name="elementType">Optional element type (eg. it's the ldelem instruction)</param> /// <returns></returns> public virtual ILValue?LoadSZArrayElement(LoadValueType loadValueType, long index, DmdType elementType) => null;
public override bool StoreIndirect(DmdType type, LoadValueType loadValueType, ILValue value) { WriteValue(runtime.GetDebuggerValue(value, Type.GetElementType())); return(true); }
public override ILValue LoadIndirect(DmdType type, LoadValueType loadValueType) => LoadIndirect();