本文整理汇总了C#中Code.ToOpCode方法的典型用法代码示例。如果您正苦于以下问题:C# Code.ToOpCode方法的具体用法?C# Code.ToOpCode怎么用?C# Code.ToOpCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Code
的用法示例。
在下文中一共展示了Code.ToOpCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetOperandType
static MethodBody.InstructionOperandType GetOperandType(Code code)
{
switch (code.ToOpCode().OperandType) {
case OperandType.InlineBrTarget: return MethodBody.InstructionOperandType.BranchTarget;
case OperandType.InlineField: return MethodBody.InstructionOperandType.Field;
case OperandType.InlineI: return MethodBody.InstructionOperandType.Int32;
case OperandType.InlineI8: return MethodBody.InstructionOperandType.Int64;
case OperandType.InlineMethod: return MethodBody.InstructionOperandType.Method;
case OperandType.InlineNone: return MethodBody.InstructionOperandType.None;
case OperandType.InlinePhi: return MethodBody.InstructionOperandType.None;
case OperandType.InlineR: return MethodBody.InstructionOperandType.Double;
case OperandType.InlineSig: return MethodBody.InstructionOperandType.MethodSig;
case OperandType.InlineString: return MethodBody.InstructionOperandType.String;
case OperandType.InlineSwitch: return MethodBody.InstructionOperandType.SwitchTargets;
case OperandType.InlineTok: return MethodBody.InstructionOperandType.Token;
case OperandType.InlineType: return MethodBody.InstructionOperandType.Type;
case OperandType.ShortInlineBrTarget: return MethodBody.InstructionOperandType.BranchTarget;
case OperandType.ShortInlineR: return MethodBody.InstructionOperandType.Single;
default: return MethodBody.InstructionOperandType.None;
case OperandType.ShortInlineI:
if (code == Code.Ldc_I4_S)
return MethodBody.InstructionOperandType.SByte;
return MethodBody.InstructionOperandType.Byte;
case OperandType.InlineVar:
case OperandType.ShortInlineVar:
switch (code) {
case Code.Ldloc:
case Code.Ldloc_S:
case Code.Ldloca:
case Code.Ldloca_S:
case Code.Stloc:
case Code.Stloc_S:
return MethodBody.InstructionOperandType.Local;
case Code.Ldarg:
case Code.Ldarg_S:
case Code.Ldarga:
case Code.Ldarga_S:
case Code.Starg:
case Code.Starg_S:
return MethodBody.InstructionOperandType.Parameter;
default:
throw new InvalidOperationException();
}
}
}