System.Xml.Xsl.IlGen.XmlILOptimizerVisitor.NoReplace C# (CSharp) Method

NoReplace() protected method

Called when all replacements have already been made and all annotations are complete.
protected NoReplace ( QilNode node ) : QilNode
node QilNode
return QilNode
        protected override QilNode NoReplace(QilNode node) {
            // Calculate MaybeSideEffects pattern.  This is done here rather than using P because every node needs
            // to compute it and P has no good way of matching every node type.
            if (node != null) {
                switch (node.NodeType) {
                    case QilNodeType.Error:
                    case QilNodeType.Warning:
                    case QilNodeType.XsltInvokeLateBound:
                        // Error, Warning, and XsltInvokeLateBound are always assumed to have side-effects
                        OptimizerPatterns.Write(node).AddPattern(OptimizerPatternName.MaybeSideEffects);
                        break;

                    case QilNodeType.XsltInvokeEarlyBound:
                        // XsltInvokeEarlyBound is assumed to have side-effects if it is not a built-in function
                        if (((QilInvokeEarlyBound) node).Name.NamespaceUri.Length != 0)
                            goto case QilNodeType.XsltInvokeLateBound;
                        goto default;

                    case QilNodeType.Invoke:
                        // Invoke is assumed to have side-effects if it invokes a function with its SideEffects flag set
                        if (((QilInvoke) node).Function.MaybeSideEffects)
                            goto case QilNodeType.XsltInvokeLateBound;

                        // Otherwise, check children
                        goto default;

                    default:
                        // If any of the visited node's children have side effects, then mark the node as also having side effects
                        for (int i = 0; i < node.Count; i++) {
                            if (node[i] != null) {
                                if (OptimizerPatterns.Read(node[i]).MatchesPattern(OptimizerPatternName.MaybeSideEffects))
                                    goto case QilNodeType.XsltInvokeLateBound;
                            }
                        }
                        break;
                }
            }

            return node;
        }
XmlILOptimizerVisitor