本文整理汇总了C#中dnlib.DotNet.Emit.Instruction类的典型用法代码示例。如果您正苦于以下问题:C# Instruction类的具体用法?C# Instruction怎么用?C# Instruction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Instruction类属于dnlib.DotNet.Emit命名空间,在下文中一共展示了Instruction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Clear
public void Clear()
{
instructions = new List<Instruction>();
branchOrRet = new List<Instruction>();
afterInstr = null;
fakeBranches = new List<Instruction>();
}
示例2: EmulateUntil
public void EmulateUntil(Instruction instruction, CilBody body, Instruction starter)
{
Snapshots.Add(new Snapshot(new Stack<StackEntry>(Stack), new Dictionary<int, LocalEntry>(_locals),
instruction, _methodBody, null));
_instructionPointer = starter.GetInstructionIndex(body.Instructions) - 1;
Trace(() => _methodBody.Instructions[_instructionPointer] != instruction);
}
示例3: FollowsPattern
public static bool FollowsPattern(
this Instruction instr,
CilBody body,
out Instruction ender,
List<Predicate<Instruction>> preds,
int minPatternSize,
out int patternSize)
{
var curInstr = instr;
ender = null;
var correct = 0;
patternSize = 0;
while (curInstr.Next(body) != null && preds.Any(p => p(curInstr.Next(body))))
{
curInstr = curInstr.Next(body);
correct++;
}
if (correct >= minPatternSize)
{
patternSize = correct + 1;
ender = curInstr;
return true;
}
return false;
}
示例4: getInstruction
static Instruction getInstruction(IList<Instruction> instrs, Instruction source, int displ)
{
int sourceIndex = instrs.IndexOf(source);
if (sourceIndex < 0)
throw new ApplicationException("Could not find source instruction");
return instrs[sourceIndex + displ];
}
示例5: OnAfterLoadArg
protected override Instruction OnAfterLoadArg(MethodDef methodToInline, Instruction instr, ref int instrIndex) {
if (instr.OpCode.Code != Code.Box)
return instr;
if (methodToInline.MethodSig.GetGenParamCount() == 0)
return instr;
return DotNetUtils.GetInstruction(methodToInline.Body.Instructions, ref instrIndex);
}
示例6: MarkAsBranchTarget
void MarkAsBranchTarget(Instruction instr) {
if (instr == null)
return;
int index = instrToIndex[instr];
GetBranchTargetList(index); // Just create the list
}
示例7: Emulate
public bool Emulate(Instruction instr) {
switch (instr.OpCode.Code) {
case Code.Br:
case Code.Br_S: return Emulate_Br();
case Code.Beq:
case Code.Beq_S: return Emulate_Beq();
case Code.Bge:
case Code.Bge_S: return Emulate_Bge();
case Code.Bge_Un:
case Code.Bge_Un_S: return Emulate_Bge_Un();
case Code.Bgt:
case Code.Bgt_S: return Emulate_Bgt();
case Code.Bgt_Un:
case Code.Bgt_Un_S: return Emulate_Bgt_Un();
case Code.Ble:
case Code.Ble_S: return Emulate_Ble();
case Code.Ble_Un:
case Code.Ble_Un_S: return Emulate_Ble_Un();
case Code.Blt:
case Code.Blt_S: return Emulate_Blt();
case Code.Blt_Un:
case Code.Blt_Un_S: return Emulate_Blt_Un();
case Code.Bne_Un:
case Code.Bne_Un_S: return Emulate_Bne_Un();
case Code.Brfalse:
case Code.Brfalse_S:return Emulate_Brfalse();
case Code.Brtrue:
case Code.Brtrue_S: return Emulate_Brtrue();
case Code.Switch: return Emulate_Switch();
default:
return false;
}
}
示例8: EmitDecode
public Instruction[] EmitDecode(MethodDef init, RPContext ctx, Instruction[] arg) {
Tuple<Expression, Func<int, int>> key = GetKey(ctx, init);
var invCompiled = new List<Instruction>();
new CodeGen(arg, ctx.Method, invCompiled).GenerateCIL(key.Item1);
init.Body.MaxStack += (ushort)ctx.Depth;
return invCompiled.ToArray();
}
示例9: ReadInlineTok
protected override ITokenOperand ReadInlineTok(Instruction instr) {
switch (reader.ReadByte()) {
case 0: return imageReader.ReadTypeSig().ToTypeDefOrRef();
case 1: return imageReader.ReadFieldRef();
case 2: return imageReader.ReadMethodRef();
default: throw new ApplicationException("Unknown token type");
}
}
示例10: EmitDecode
public Instruction[] EmitDecode(MethodDef init, RPContext ctx, Instruction[] arg) {
Tuple<MethodDef, Func<int, int>> key = GetKey(ctx, init);
var repl = new List<Instruction>();
repl.AddRange(arg);
repl.Add(Instruction.Create(OpCodes.Call, key.Item1));
return repl.ToArray();
}
示例11: getExInfo
ExInfo getExInfo(Instruction instruction)
{
if (instruction == null)
return lastExInfo;
ExInfo exInfo;
if (!exInfos.TryGetValue(instruction, out exInfo))
exInfos[instruction] = exInfo = new ExInfo();
return exInfo;
}
示例12: checkInvokeCall
static bool checkInvokeCall(Instruction instr, string returnType, string parameters)
{
var method = instr.Operand as MethodDef;
if (method == null)
return false;
if (method.Name != "Invoke")
return false;
return DotNetUtils.isMethod(method, returnType, parameters);
}
示例13: GetInstructionSize
protected static int GetInstructionSize(Instruction instr)
{
var opcode = instr.OpCode;
if (opcode == null)
return 5; // Load store/field
var op = instr.Operand as SwitchTargetDisplOperand;
if (op == null)
return instr.GetSize();
return instr.OpCode.Size + (op.TargetDisplacements.Length + 1) * 4;
}
示例14: GetOffset
/// <summary>
/// Gets the offset of an instruction
/// </summary>
/// <param name="instr">The instruction</param>
/// <returns>The offset or <c>0</c> if <paramref name="instr"/> is <c>null</c> or not
/// present in the list of all instructions.</returns>
protected uint GetOffset(Instruction instr) {
if (instr == null) {
Error("Instruction is null");
return 0;
}
uint offset;
if (offsets.TryGetValue(instr, out offset))
return offset;
Error("Found some other method's instruction or a removed instruction. You probably removed an instruction that is the target of a branch instruction or an instruction that's the first/last instruction in an exception handler.");
return 0;
}
示例15: InlineLoadMethod
protected bool InlineLoadMethod(int patchIndex, MethodDef methodToInline, Instruction loadInstr, int instrIndex) {
if (!IsReturn(methodToInline, instrIndex))
return false;
int methodArgsCount = DotNetUtils.GetArgsCount(methodToInline);
for (int i = 0; i < methodArgsCount; i++)
block.Insert(patchIndex++, OpCodes.Pop.ToInstruction());
block.Instructions[patchIndex] = new Instr(loadInstr.Clone());
return true;
}