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


C# ILNode.GetChildren方法代码示例

本文整理汇总了C#中ILNode.GetChildren方法的典型用法代码示例。如果您正苦于以下问题:C# ILNode.GetChildren方法的具体用法?C# ILNode.GetChildren怎么用?C# ILNode.GetChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ILNode的用法示例。


在下文中一共展示了ILNode.GetChildren方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AnalyzeNode

		void AnalyzeNode(ILNode node)
		{
			ILExpression expr = node as ILExpression;
			if (expr != null) {
				ILVariable locVar = expr.Operand as ILVariable;
				if (locVar != null) {
					if (expr.Code == ILCode.Stloc) {
						numStloc[locVar] = numStloc.GetOrDefault(locVar) + 1;
					} else if (expr.Code == ILCode.Ldloc) {
						numLdloc[locVar] = numLdloc.GetOrDefault(locVar) + 1;
					} else if (expr.Code == ILCode.Ldloca) {
						numLdloca[locVar] = numLdloca.GetOrDefault(locVar) + 1;
					} else {
						throw new NotSupportedException(expr.Code.ToString());
					}
				}
				foreach (ILExpression child in expr.Arguments)
					AnalyzeNode(child);
			} else {
				var catchBlock = node as ILTryCatchBlock.CatchBlock;
				if (catchBlock != null && catchBlock.ExceptionVariable != null) {
					numStloc[catchBlock.ExceptionVariable] = numStloc.GetOrDefault(catchBlock.ExceptionVariable) + 1;
				}
				
				foreach (ILNode child in node.GetChildren())
					AnalyzeNode(child);
			}
		}
开发者ID:BGCX261,项目名称:zoom-decompiler-hg-to-git,代码行数:28,代码来源:ILInlining.cs

示例2: InferTypes

		void InferTypes(ILNode node)
		{
			ILCondition cond = node as ILCondition;
			if (cond != null) {
				InferTypeForExpression(cond.Condition, typeSystem.Boolean, false);
			}
			ILWhileLoop loop = node as ILWhileLoop;
			if (loop != null && loop.Condition != null) {
				InferTypeForExpression(loop.Condition, typeSystem.Boolean, false);
			}
			ILExpression expr = node as ILExpression;
			if (expr != null) {
				ILVariable v = expr.Operand as ILVariable;
				if (v != null && v.IsGenerated && v.Type == null && expr.Code == ILCode.Stloc && !inferredVariables.Contains(v) && HasSingleLoad(v)) {
					// Don't deal with this node or its children yet,
					// wait for the expected type to be inferred first.
					// This happens with the arg_... variables introduced by the ILAst - we skip inferring the whole statement,
					// and first infer the statement that reads from the arg_... variable.
					// The ldloc inference will write the expected type to the variable, and the next InferRemainingStores() pass
					// will then infer this statement with the correct expected type.
					storedToGeneratedVariables.Add(expr);
					return;
				}
				bool anyArgumentIsMissingType = expr.Arguments.Any(a => a.InferredType == null);
				if (expr.InferredType == null || anyArgumentIsMissingType)
					expr.InferredType = InferTypeForExpression(expr, expr.ExpectedType, forceInferChildren: anyArgumentIsMissingType);
			}
			foreach (ILNode child in node.GetChildren()) {
				InferTypes(child);
			}
		}
开发者ID:hlesesne,项目名称:ILSpy,代码行数:31,代码来源:TypeAnalysis.cs

示例3: CreateDependencyGraph

		/// <summary>
		/// Creates the "ExpressionToInfer" instances (=nodes in dependency graph)
		/// </summary>
		/// <remarks>
		/// We are using a dependency graph to ensure that expressions are analyzed in the correct order.
		/// </remarks>
		void CreateDependencyGraph(ILNode node)
		{
			ILCondition cond = node as ILCondition;
			if (cond != null) {
				cond.Condition.ExpectedType = typeSystem.Boolean;
			}
			ILWhileLoop loop = node as ILWhileLoop;
			if (loop != null && loop.Condition != null) {
				loop.Condition.ExpectedType = typeSystem.Boolean;
			}
			ILTryCatchBlock.CatchBlock catchBlock = node as ILTryCatchBlock.CatchBlock;
			if (catchBlock != null && catchBlock.ExceptionVariable != null && catchBlock.ExceptionType != null && catchBlock.ExceptionVariable.Type == null) {
				catchBlock.ExceptionVariable.Type = catchBlock.ExceptionType;
			}
			ILExpression expr = node as ILExpression;
			if (expr != null) {
				ExpressionToInfer expressionToInfer = new ExpressionToInfer();
				expressionToInfer.Expression = expr;
				allExpressions.Add(expressionToInfer);
				FindNestedAssignments(expr, expressionToInfer);
				
				if (expr.Code == ILCode.Stloc && ((ILVariable)expr.Operand).Type == null)
					assignmentExpressions[(ILVariable)expr.Operand].Add(expressionToInfer);
				return;
			}
			foreach (ILNode child in node.GetChildren()) {
				CreateDependencyGraph(child);
			}
		}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:35,代码来源:TypeAnalysis.cs

示例4: FlattenNestedMovableBlocks

 /// <summary>
 /// Flattens all nested movable blocks, except the the top level 'node' argument
 /// </summary>
 void FlattenNestedMovableBlocks(ILNode node)
 {
     ILBlock block = node as ILBlock;
     if (block != null) {
         List<ILNode> flatBody = new List<ILNode>();
         if (block.EntryPoint != null) {
             flatBody.Add(new ILExpression(OpCodes.Br, block.EntryPoint));
             block.EntryPoint = null;
         }
         foreach (ILNode child in block.Body) {
             FlattenNestedMovableBlocks(child);
             if (child is ILMoveableBlock) {
                 flatBody.AddRange(((ILMoveableBlock)child).Body);
             } else {
                 flatBody.Add(child);
             }
         }
         block.Body = flatBody;
     } else if (node is ILExpression) {
         // Optimization - no need to check expressions
     } else if (node != null) {
         // Recursively find all ILBlocks
         foreach(ILNode child in node.GetChildren()) {
             FlattenNestedMovableBlocks(child);
         }
     }
 }
开发者ID:FriedWishes,项目名称:ILSpy,代码行数:30,代码来源:ILAstOptimizer.cs

示例5: FlattenBasicBlocks

 /// <summary>
 /// Flattens all nested basic blocks, except the the top level 'node' argument
 /// </summary>
 void FlattenBasicBlocks(ILNode node)
 {
     ILBlock block = node as ILBlock;
     if (block != null) {
         List<ILNode> flatBody = new List<ILNode>();
         foreach (ILNode child in block.GetChildren()) {
             FlattenBasicBlocks(child);
             if (child is ILBasicBlock) {
                 flatBody.AddRange(child.GetChildren());
             } else {
                 flatBody.Add(child);
             }
         }
         block.EntryGoto = null;
         block.Body = flatBody;
     } else if (node is ILExpression) {
         // Optimization - no need to check expressions
     } else if (node != null) {
         // Recursively find all ILBlocks
         foreach(ILNode child in node.GetChildren()) {
             FlattenBasicBlocks(child);
         }
     }
 }
开发者ID:petr-k,项目名称:ILSpy,代码行数:27,代码来源:ILAstOptimizer.cs


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