本文整理汇总了C#中BinaryOperator.ReplaceChild方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryOperator.ReplaceChild方法的具体用法?C# BinaryOperator.ReplaceChild怎么用?C# BinaryOperator.ReplaceChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryOperator
的用法示例。
在下文中一共展示了BinaryOperator.ReplaceChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RotateFromRight
/// <summary>
/// We have determined that our right-hand operand is another binary operator, and its
/// left-hand operand is a constant that can be combined with our left-hand operand.
/// Now we want to set the left-hand operand of that other operator to the newly-
/// combined constant value, and then rotate it up -- replace our binary operator
/// with this newly-modified binary operator, and then attempt to re-evaluate it.
/// </summary>
/// <param name="binaryOp">the binary operator that is our right-hand operand</param>
/// <param name="newLiteral">the newly-combined literal</param>
private void RotateFromRight(BinaryOperator node, BinaryOperator binaryOp, ConstantWrapper newLiteral)
{
// replace our node with the binary operator
binaryOp.ReplaceChild(binaryOp.Operand1, newLiteral);
node.Parent.ReplaceChild(node, binaryOp);
// and just for good measure.. revisit the node that's taking our place, since
// we just changed a constant value. Assuming the other operand is a constant, too.
ConstantWrapper otherConstant = binaryOp.Operand2 as ConstantWrapper;
if (otherConstant != null)
{
EvalThisOperator(binaryOp, newLiteral, otherConstant);
}
}