本文整理汇总了C#中System.Reflection.Emit.OpCode类的典型用法代码示例。如果您正苦于以下问题:C# OpCode类的具体用法?C# OpCode怎么用?C# OpCode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OpCode类属于System.Reflection.Emit命名空间,在下文中一共展示了OpCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsTailableCall
public static bool IsTailableCall(OpCode op)
{
return
op == OpCodes.Call ||
//op == OpCodes.Calli ||
op == OpCodes.Callvirt;
}
示例2: Emit
public void Emit(OpCode code, ConstructorInfo constructor)
{
if (code == OpCodes.Newobj)
{
instructions.Add((args) => EmitInternal(code, constructor));
}
}
示例3: EmitIf
public void EmitIf(OpCode comparasionOpcode, bool not = false)
{
_generator
.Emit(comparasionOpcode)
.EmitIf(!not, a => a.Brfalse(_ifFalse))
.EmitIf(not, a => a.Brtrue(_ifFalse));
}
示例4: Get
public static int Get(OpCode op, Sigil.Label[] labels = null)
{
var baseSize = op.Size;
int operandSize;
switch (op.OperandType)
{
case OperandType.InlineBrTarget: operandSize = 4; break;
case OperandType.InlineField: operandSize = 4; break;
case OperandType.InlineI: operandSize = 4; break;
case OperandType.InlineI8: operandSize = 8; break;
case OperandType.InlineMethod: operandSize = 4; break;
case OperandType.InlineNone: operandSize = 0; break;
case OperandType.InlineR: operandSize = 8; break;
case OperandType.InlineSig: operandSize = 4; break;
case OperandType.InlineString: operandSize = 4; break;
case OperandType.InlineSwitch: operandSize = 4 + labels.Length * 4; break;
case OperandType.InlineTok: operandSize = 4; break;
case OperandType.InlineType: operandSize = 4; break;
case OperandType.InlineVar: operandSize = 2; break;
case OperandType.ShortInlineBrTarget: operandSize = 1; break;
case OperandType.ShortInlineI: operandSize = 1; break;
case OperandType.ShortInlineR: operandSize = 4; break;
case OperandType.ShortInlineVar: operandSize = 1; break;
default: throw new Exception("Unexpected operand type [" + op.OperandType + "]");
}
return baseSize + operandSize;
}
示例5: OperatorToken
internal OperatorToken(Operator op)
{
switch (op)
{
case Operator.Add:
_opCode = OpCodes.Add;
break;
case Operator.Subtract:
_opCode = OpCodes.Sub;
break;
case Operator.Multiply:
_opCode = OpCodes.Mul;
break;
case Operator.Divide:
_opCode = OpCodes.Div;
break;
case Operator.Power:
_opCode = OpCodes.Call;
break;
case Operator.Modulus:
_opCode = OpCodes.Rem;
break;
default:
throw new ArgumentException("Unknown operator.");
}
Operator = op;
}
示例6: Instruction
Instruction(ILReader reader, OpCode op, Operand arg, ushort label)
{
this.reader = reader;
this.OpCode = op;
this.Operand = arg;
this.label = (ushort)label;
}
示例7: EmitIndexedInstruction
private static void EmitIndexedInstruction(this ILGenerator il, OpCode[] index, int argument) {
if (argument < index.Length - 1) {
il.Emit(index[argument]);
return;
}
il.Emit(index[index.Length - 1], argument);
}
示例8: MethodInstruction
internal MethodInstruction(int offset, OpCode opCode, int token, ModuleScopeTokenResolver resolver)
{
this.offset = offset;
this.opCode = opCode;
this.resolver = resolver;
this.token = token;
}
示例9: GetOperandSize
int GetOperandSize(OpCode o, int pos)
{
switch (o.OperandType)
{
case OperandType.ShortInlineBrTarget: return 1;
case OperandType.ShortInlineI: return 1;
case OperandType.ShortInlineR: return 4;
case OperandType.ShortInlineVar: return 1;
case OperandType.InlineVar: return 2;
case OperandType.InlineType: return 4;
case OperandType.InlineTok: return 4;
case OperandType.InlineString: return 4;
case OperandType.InlineSig: return 4;
case OperandType.InlineR: return 8;
case OperandType.InlineNone: return 0;
case OperandType.InlineMethod: return 4;
case OperandType.InlineI8: return 8;
case OperandType.InlineI: return 4;
case OperandType.InlineField: return 4;
case OperandType.InlineBrTarget: return 4;
case OperandType.InlineSwitch:
return 4 + 4 * BitConverter.ToInt32(code, pos);
}
throw new NotImplementedException();
}
示例10: AdvanceOffsetWithLabel
private void AdvanceOffsetWithLabel(OpCode opcode) {
AdvanceOffset(opcode);
if (OpCodes.TakesSingleByteArgument(opcode)) {
_offset++;
} else {
_offset += 4;
}
}
示例11: Emit
public virtual void Emit(OpCode opcode, MethodInfo method)
{
_gen.Emit(opcode, method);
var methodParameters = method.GetParameters();
var parameters = string.Join(", ", methodParameters.Select(p => p.ParameterType.Name));
_writer.WriteLine(string.Concat(opcode, ", ", method.Name, "(", parameters, ")"));
}
示例12: IsPrefix
public static bool IsPrefix(OpCode op)
{
return
op == OpCodes.Tailcall ||
op == OpCodes.Readonly ||
op == OpCodes.Volatile ||
op == OpCodes.Unaligned;
}
示例13: BranchSet
private BranchSet(OpCode brTrue, OpCode brFalse, OpCode brEq, OpCode brNe, OpCode brLt, OpCode brLtUn, OpCode brGt, OpCode brGtUn, OpCode brLe, OpCode brLeUn, OpCode brGe, OpCode brGeUn)
{
this.brTrue = brTrue; this.brFalse = brFalse;
this.brEq = brEq; this.brNe = brNe;
this.brLt = brLt; this.brLtUn = brLtUn;
this.brGt = brGt; this.brGtUn = brGtUn;
this.brLe = brLe; this.brLeUn = brLeUn;
this.brGe = brGe; this.brGeUn = brGeUn;
}
示例14: ConditionExpression
public ConditionExpression( OpCode operation, Expression left, Expression right )
{
_trueStmts = new ArrayList();
_falseStmts = new ArrayList();
_operation = operation;
_left = left;
_right = right;
}
示例15: CheckAndEmit
protected void CheckAndEmit(OpCode? argument)
{
if(!argument.HasValue)
{
throw new InvalidOperationException();
}
generator.Emit(argument.Value);
}