本文整理汇总了C#中ProtoCore.AST.AssociativeAST.BinaryExpressionNode.InheritID方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryExpressionNode.InheritID方法的具体用法?C# BinaryExpressionNode.InheritID怎么用?C# BinaryExpressionNode.InheritID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProtoCore.AST.AssociativeAST.BinaryExpressionNode
的用法示例。
在下文中一共展示了BinaryExpressionNode.InheritID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleRedefinedLHS
/// <summary>
///
/// Handle instances of redefining the lhs of an expression
/// Given:
/// a = p.x -> b = p.x
/// In such a scenario, the new expression 'b = p.x' must inherit the previous expression id of a = p.x
/// </summary>
/// <param name="newNode"></param>
/// <param name="cachedASTList"></param>
private void HandleRedefinedLHS(BinaryExpressionNode newNode, List<AssociativeNode> cachedASTList)
{
//
// Note that after SSA is applied, the expression:
// a = p.x
// transforms to:
// t0 = p
// t1 = t0.x
// a = t1
//
// And the expression:
// b = p.x
// transforms to:
// t0 = p
// t1 = t0.x
// b = t1
//
// As such we only need to update the expression id of 'b = t1' to inherit the expression id of 'a = t1'
//
if (null != newNode)
{
IdentifierNode rnode = newNode.RightNode as IdentifierNode;
if (null != rnode)
{
foreach (AssociativeNode prevNode in cachedASTList)
{
BinaryExpressionNode prevBinaryNode = prevNode as BinaryExpressionNode;
if (null != prevBinaryNode)
{
IdentifierNode prevIdent = prevBinaryNode.LeftNode as IdentifierNode;
if (null != prevIdent)
{
if (prevIdent.Equals(rnode))
{
newNode.InheritID(prevBinaryNode.ID);
newNode.ExpressionUID = prevBinaryNode.ExpressionUID;
}
}
}
}
}
}
}