本文整理汇总了C#中System.Collections.Stack.Duplicate方法的典型用法代码示例。如果您正苦于以下问题:C# Stack.Duplicate方法的具体用法?C# Stack.Duplicate怎么用?C# Stack.Duplicate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Stack
的用法示例。
在下文中一共展示了Stack.Duplicate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LinearizePath
private void LinearizePath(MethodDefData pMethodDefData, IRInstruction pStartInstruction, Stack<IRStackObject> pStack, Queue<Tuple<IRInstruction, Stack<IRStackObject>>> pBranches)
{
int stackReturn = pStack.Count;
IRInstruction currentInstruction = pStartInstruction;
MethodDefData.MethodDefBodyData.MethodDefBodyExceptionData exceptionData = null;
while (currentInstruction != null)
{
if (currentInstruction.Linearized && pStack.Count == stackReturn) break;
if ((exceptionData = Array.Find(pMethodDefData.Body.Exceptions, e => e.Flags == 0 && e.HandlerOffset == currentInstruction.ILOffset)) != null)
{
IRType exceptionType = Assembly.AppDomain.PresolveType(Assembly.File.ExpandMetadataToken(exceptionData.ClassTokenOrFilterOffset));
IRStackObject exceptionObj = new IRStackObject();
exceptionObj.Type = exceptionType;
exceptionObj.LinearizedTarget = new IRLinearizedLocation(currentInstruction, IRLinearizedLocationType.Local);
exceptionObj.LinearizedTarget.Local.LocalIndex = currentInstruction.AddLinearizedLocal(pStack, exceptionType);
pStack.Push(exceptionObj);
}
if (currentInstruction.Linearized)
{
currentInstruction.Destination = null;
currentInstruction.Sources.Clear();
}
currentInstruction.Linearize(pStack);
currentInstruction.Linearized = true;
switch (currentInstruction.Opcode)
{
case IROpcode.Branch:
{
IRBranchInstruction branchInstruction = (IRBranchInstruction)currentInstruction;
if (branchInstruction.BranchCondition == IRBranchCondition.Always) currentInstruction = branchInstruction.TargetIRInstruction;
else
{
pBranches.Enqueue(new Tuple<IRInstruction, Stack<IRStackObject>>(branchInstruction.TargetIRInstruction, pStack.Duplicate()));
currentInstruction = Instructions[currentInstruction.IRIndex + 1];
}
break;
}
case IROpcode.Switch:
{
IRSwitchInstruction switchInstruction = (IRSwitchInstruction)currentInstruction;
foreach (IRInstruction targetInstruction in switchInstruction.TargetIRInstructions)
{
pBranches.Enqueue(new Tuple<IRInstruction, Stack<IRStackObject>>(targetInstruction, pStack.Duplicate()));
}
currentInstruction = Instructions[currentInstruction.IRIndex + 1];
break;
}
case IROpcode.Leave:
{
IRLeaveInstruction leaveInstruction = (IRLeaveInstruction)currentInstruction;
currentInstruction = leaveInstruction.TargetIRInstruction;
break;
}
case IROpcode.Jump:
case IROpcode.Throw:
case IROpcode.Return: currentInstruction = null; break;
default: currentInstruction = currentInstruction.IRIndex >= Instructions.Count ? null : Instructions[currentInstruction.IRIndex + 1]; break;
}
}
}