本文整理汇总了C#中Microsoft.Cci.UtilityDataStructures.MemoryReader.ReadSingle方法的典型用法代码示例。如果您正苦于以下问题:C# MemoryReader.ReadSingle方法的具体用法?C# MemoryReader.ReadSingle怎么用?C# MemoryReader.ReadSingle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Cci.UtilityDataStructures.MemoryReader
的用法示例。
在下文中一共展示了MemoryReader.ReadSingle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopulateCilInstructions
bool PopulateCilInstructions() {
MethodBodyDocument document = new MethodBodyDocument(this.MethodDefinition);
MemoryReader memReader = new MemoryReader(this.MethodIL.EncodedILMemoryBlock);
var numInstructions = CountCilInstructions(memReader);
if (numInstructions == 0) return true;
CilInstruction[] instrList = new CilInstruction[numInstructions];
int instructionNumber = 0;
while (memReader.NotEndOfBytes) {
object/*?*/ value = null;
uint offset = (uint)memReader.Offset;
OperationCode cilOpCode = memReader.ReadOpcode();
switch (cilOpCode) {
case OperationCode.Nop:
case OperationCode.Break:
break;
case OperationCode.Ldarg_0:
case OperationCode.Ldarg_1:
case OperationCode.Ldarg_2:
case OperationCode.Ldarg_3:
value = this.GetParameter((uint)(cilOpCode - OperationCode.Ldarg_0));
break;
case OperationCode.Ldloc_0:
case OperationCode.Ldloc_1:
case OperationCode.Ldloc_2:
case OperationCode.Ldloc_3:
value = this.GetLocal((uint)(cilOpCode - OperationCode.Ldloc_0));
break;
case OperationCode.Stloc_0:
case OperationCode.Stloc_1:
case OperationCode.Stloc_2:
case OperationCode.Stloc_3:
value = this.GetLocal((uint)(cilOpCode - OperationCode.Stloc_0));
break;
case OperationCode.Ldarg_S:
case OperationCode.Ldarga_S:
case OperationCode.Starg_S:
value = this.GetParameter(memReader.ReadByte());
break;
case OperationCode.Ldloc_S:
case OperationCode.Ldloca_S:
case OperationCode.Stloc_S:
value = this.GetLocal(memReader.ReadByte());
break;
case OperationCode.Ldnull:
case OperationCode.Ldc_I4_M1:
case OperationCode.Ldc_I4_0:
case OperationCode.Ldc_I4_1:
case OperationCode.Ldc_I4_2:
case OperationCode.Ldc_I4_3:
case OperationCode.Ldc_I4_4:
case OperationCode.Ldc_I4_5:
case OperationCode.Ldc_I4_6:
case OperationCode.Ldc_I4_7:
case OperationCode.Ldc_I4_8:
break;
case OperationCode.Ldc_I4_S:
value = (int)memReader.ReadSByte();
break;
case OperationCode.Ldc_I4:
value = memReader.ReadInt32();
break;
case OperationCode.Ldc_I8:
value = memReader.ReadInt64();
break;
case OperationCode.Ldc_R4:
value = memReader.ReadSingle();
break;
case OperationCode.Ldc_R8:
value = memReader.ReadDouble();
break;
case OperationCode.Dup:
case OperationCode.Pop:
break;
case OperationCode.Jmp:
value = this.GetMethod(memReader.ReadUInt32());
break;
case OperationCode.Call: {
IMethodReference methodReference = this.GetMethod(memReader.ReadUInt32());
IArrayTypeReference/*?*/ arrayType = methodReference.ContainingType as IArrayTypeReference;
if (arrayType != null) {
// For Get(), Set() and Address() on arrays, the runtime provides method implementations.
// Hence, CCI2 replaces these with pseudo instrcutions Array_Set, Array_Get and Array_Addr.
// All other methods on arrays will not use pseudo instruction and will have methodReference as their operand.
if (methodReference.Name.UniqueKey == this.PEFileToObjectModel.NameTable.Set.UniqueKey) {
cilOpCode = OperationCode.Array_Set;
value = arrayType;
} else if (methodReference.Name.UniqueKey == this.PEFileToObjectModel.NameTable.Get.UniqueKey) {
cilOpCode = OperationCode.Array_Get;
value = arrayType;
} else if (methodReference.Name.UniqueKey == this.PEFileToObjectModel.NameTable.Address.UniqueKey) {
cilOpCode = OperationCode.Array_Addr;
value = arrayType;
} else {
value = methodReference;
}
} else {
value = methodReference;
}
}
break;
//.........这里部分代码省略.........
示例2: GetDefaultValue
internal IMetadataConstant GetDefaultValue(
MetadataObject metadataObject
) {
uint constRowId = this.PEFileReader.ConstantTable.GetConstantRowId(metadataObject.TokenValue);
if (constRowId == 0)
return Dummy.Constant;
ConstantRow constRow = this.PEFileReader.ConstantTable[constRowId];
MemoryBlock constValueMemoryBlock = this.PEFileReader.BlobStream.GetMemoryBlockAt(constRow.Value);
MemoryReader memoryReader = new MemoryReader(constValueMemoryBlock);
switch (constRow.Type) {
case ElementType.Boolean: {
byte val = memoryReader.ReadByte();
return new ConstantExpression(this.PlatformType.SystemBoolean, val != 0);
}
case ElementType.Char:
return new ConstantExpression(this.PlatformType.SystemChar, memoryReader.ReadChar());
case ElementType.Int8:
return new ConstantExpression(this.PlatformType.SystemInt8, memoryReader.ReadSByte());
case ElementType.Int16:
return new ConstantExpression(this.PlatformType.SystemInt16, memoryReader.ReadInt16());
case ElementType.Int32:
return new ConstantExpression(this.PlatformType.SystemInt32, memoryReader.ReadInt32());
case ElementType.Int64:
return new ConstantExpression(this.PlatformType.SystemInt64, memoryReader.ReadInt64());
case ElementType.UInt8:
return new ConstantExpression(this.PlatformType.SystemUInt8, memoryReader.ReadByte());
case ElementType.UInt16:
return new ConstantExpression(this.PlatformType.SystemUInt16, memoryReader.ReadUInt16());
case ElementType.UInt32:
return new ConstantExpression(this.PlatformType.SystemUInt32, memoryReader.ReadUInt32());
case ElementType.UInt64:
return new ConstantExpression(this.PlatformType.SystemUInt64, memoryReader.ReadUInt64());
case ElementType.Single:
return new ConstantExpression(this.PlatformType.SystemFloat32, memoryReader.ReadSingle());
case ElementType.Double:
return new ConstantExpression(this.PlatformType.SystemFloat64, memoryReader.ReadDouble());
case ElementType.String: {
int byteLen = memoryReader.Length;
string/*?*/ value;
if (byteLen == -1) {
value = null;
} else if (byteLen == 0) {
value = string.Empty;
} else {
value = memoryReader.ReadUTF16WithSize(byteLen);
}
return new ConstantExpression(this.PlatformType.SystemString, value);
}
case ElementType.Class:
return new ConstantExpression(this.PlatformType.SystemObject, null);
}
// MDError...
return Dummy.Constant;
}