本文整理汇总了C#中AstNode.GetChildren方法的典型用法代码示例。如果您正苦于以下问题:C# AstNode.GetChildren方法的具体用法?C# AstNode.GetChildren怎么用?C# AstNode.GetChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AstNode
的用法示例。
在下文中一共展示了AstNode.GetChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnalyzeNode
void AnalyzeNode(AstNode node)
{
AstExpression expr = node as AstExpression;
if (expr != null) {
AstVariable locVar = expr.Operand as AstVariable;
if (locVar != null) {
if (expr.Code == AstCode.Stloc) {
numStloc[locVar] = numStloc.GetOrDefault(locVar) + 1;
} else if (expr.Code == AstCode.Ldloc) {
numLdloc[locVar] = numLdloc.GetOrDefault(locVar) + 1;
} else if (expr.Code == AstCode.Ldloca) {
numLdloca[locVar] = numLdloca.GetOrDefault(locVar) + 1;
} else {
throw new NotSupportedException(expr.Code.ToString());
}
}
foreach (AstExpression child in expr.Arguments)
AnalyzeNode(child);
} else {
var catchBlock = node as AstTryCatchBlock.CatchBlock;
if (catchBlock != null && catchBlock.ExceptionVariable != null) {
numStloc[catchBlock.ExceptionVariable] = numStloc.GetOrDefault(catchBlock.ExceptionVariable) + 1;
}
foreach (AstNode child in node.GetChildren())
AnalyzeNode(child);
}
}
示例2: 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>
private void CreateDependencyGraph(AstNode node)
{
var catchBlock = node as AstTryCatchBlock.CatchBlock;
if (catchBlock != null && catchBlock.ExceptionVariable != null && catchBlock.ExceptionType != null && catchBlock.ExceptionVariable.Type == null)
{
catchBlock.ExceptionVariable.Type = catchBlock.ExceptionType;
}
var expr = node as AstExpression;
if (expr != null)
{
var expressionToInfer = new ExpressionToInfer(expr);
allExpressions.Add(expressionToInfer);
FindNestedAssignments(expr, expressionToInfer);
if ((expr.Code == AstCode.Stloc) && ((AstVariable) expr.Operand).Type == null)
{
assignmentExpressions[(AstVariable)expr.Operand].Add(expressionToInfer);
}
return;
}
foreach (var child in node.GetChildren())
{
CreateDependencyGraph(child);
}
}