当前位置: 首页>>代码示例>>C#>>正文


C# Stack.Duplicate方法代码示例

本文整理汇总了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;
				}
			}
		}
开发者ID:carriercomm,项目名称:Proton-1,代码行数:62,代码来源:IRMethod.cs


注:本文中的System.Collections.Stack.Duplicate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。