本文整理汇总了C#中AstNode.GetChild方法的典型用法代码示例。如果您正苦于以下问题:C# AstNode.GetChild方法的具体用法?C# AstNode.GetChild怎么用?C# AstNode.GetChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AstNode
的用法示例。
在下文中一共展示了AstNode.GetChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Evaluate
/// <summary>
/// Performs the specified action on an expression tree.
/// </summary>
/// <returns>The top node of the results.</returns>
/// <exception>ApplicationException</exception>
/// <param name="node">The top node of the tree.</param>
/// <param name="data">Data passed to the visitor (Typically not used).</param>
/// <param name="pv">Visitor object that can be used to descend the tree.</param>
/// <param name="stack">The stack to operate on.</param>
/// <exception cref="ApplicationException">If operator must have 3 arguments.</exception>
public virtual object Evaluate( AstNode node, object data, IAstNodeVisitor pv, Stack< double? > stack )
{
if ( node.NumChildren != 3 )
throw new ApplicationException( "If operator must have 3 arguments." );
AstNode condition = node.GetChild( 0 );
condition.Accept( pv, data );
CheckStack( stack );
double? condVal = stack.Pop();
if ( condVal.HasValue && ( condVal > 0.0 ) )
{
AstNode trueNode = node.GetChild( 1 );
trueNode.Accept( pv, data );
return data;
}
AstNode falseNode = node.GetChild( 2 );
falseNode.Accept( pv, data );
return data;
}