本文整理汇总了C#中dnlib.DotNet.Emit.Instruction.GetNext方法的典型用法代码示例。如果您正苦于以下问题:C# Instruction.GetNext方法的具体用法?C# Instruction.GetNext怎么用?C# Instruction.GetNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dnlib.DotNet.Emit.Instruction
的用法示例。
在下文中一共展示了Instruction.GetNext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteStructureBody
void WriteStructureBody(MethodDef method, CilBody body, ILStructure s, HashSet<uint> branchTargets, ref Instruction inst, MemberMapping currentMethodMapping, uint codeSize)
{
bool isFirstInstructionInStructure = true;
bool prevInstructionWasBranch = false;
int childIndex = 0;
while (inst != null && inst.Offset < s.EndOffset) {
uint offset = inst.Offset;
if (childIndex < s.Children.Count && s.Children[childIndex].StartOffset <= offset && offset < s.Children[childIndex].EndOffset) {
ILStructure child = s.Children[childIndex++];
WriteStructureHeader(child);
WriteStructureBody(method, body, child, branchTargets, ref inst, currentMethodMapping, codeSize);
WriteStructureFooter(child);
} else {
if (!isFirstInstructionInStructure && (prevInstructionWasBranch || branchTargets.Contains(offset))) {
output.WriteLine(); // put an empty line after branches, and in front of branch targets
}
var startLocation = output.Location;
inst.WriteTo(method, body, output);
// add IL code mappings - used in debugger
if (currentMethodMapping != null) {
var next = inst.GetNext(body);
currentMethodMapping.MemberCodeMappings.Add(
new SourceCodeMapping() {
StartLocation = startLocation,
EndLocation = output.Location,
ILInstructionOffset = new ILRange { From = inst.Offset, To = next == null ? codeSize : next.Offset },
MemberMapping = currentMethodMapping
});
}
output.WriteLine();
prevInstructionWasBranch = inst.OpCode.FlowControl == FlowControl.Branch
|| inst.OpCode.FlowControl == FlowControl.Cond_Branch
|| inst.OpCode.FlowControl == FlowControl.Return
|| inst.OpCode.FlowControl == FlowControl.Throw;
inst = inst.GetNext(body);
}
isFirstInstructionInStructure = false;
}
}