View over a Qil operator having two children, the second of which is a literal type.
Don't construct QIL nodes directly; instead, use the QilFactory.
Inheritance: QilBinary
Beispiel #1
0
        public QilTargetType XsltConvert(QilNode source, QilNode targetType)
        {
            QilTargetType n = new QilTargetType(QilNodeType.XsltConvert, source, targetType);

            n.XmlType = _typeCheck.CheckXsltConvert(n);
            TraceNode(n);
            return(n);
        }
        //-----------------------------------------------
        // Type operators
        //-----------------------------------------------
        public QilTargetType TypeAssert(QilNode source, QilNode targetType)
        {
            QilTargetType n = new QilTargetType(QilNodeType.TypeAssert, source, targetType);

            n.XmlType = this.typeCheck.CheckTypeAssert(n);
            TraceNode(n);
            return(n);
        }
Beispiel #3
0
        public QilTargetType IsType(QilNode source, QilNode targetType)
        {
            QilTargetType n = new QilTargetType(QilNodeType.IsType, source, targetType);

            n.XmlType = _typeCheck.CheckIsType(n);
            TraceNode(n);
            return(n);
        }
Beispiel #4
0
 protected override QilNode VisitXsltConvert(QilTargetType n)
 {
     return(NoReplace(n));
 }
Beispiel #5
0
 protected override QilNode VisitIsType(QilTargetType n)
 {
     return(NoReplace(n));
 }
 protected override QilNode VisitTypeAssert(QilTargetType local0)
 {
     QilNode local1 = local0[0];
     QilNode local2 = local0[1];
     if (this[XmlILOptimization.FoldNone])
     {
         if ((object)((local1).XmlType) == (object)XmlQueryTypeFactory.None)
         {
             // PATTERN: [FoldNone] (TypeAssert $x:* ^ (None? (TypeOf $x)) *) => (Nop $x)
             if (AllowReplace(XmlILOptimization.FoldNone, local0))
             {
                 return Replace(XmlILOptimization.FoldNone, local0, VisitNop(f.Nop(local1)));
             }
         }
     }
     if (this[XmlILOptimization.EliminateTypeAssert])
     {
         if (local2.NodeType == QilNodeType.LiteralType)
         {
             XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
             if ((local1).XmlType.NeverSubtypeOf(local3))
             {
                 // PATTERN: [EliminateTypeAssert] (TypeAssert $opnd:* (LiteralType $typ:*) ^ (NeverSubtypeOf? (TypeOf $opnd) $typ)) => (Error (LiteralString ""))
                 if (AllowReplace(XmlILOptimization.EliminateTypeAssert, local0))
                 {
                     return Replace(XmlILOptimization.EliminateTypeAssert, local0, VisitError(f.Error(VisitLiteralString(f.LiteralString(string.Empty)))));
                 }
             }
         }
     }
     if (this[XmlILOptimization.EliminateTypeAssert])
     {
         if (local2.NodeType == QilNodeType.LiteralType)
         {
             XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
             if ((local1).XmlType.Prime.NeverSubtypeOf(local3.Prime))
             {
                 // PATTERN: [EliminateTypeAssert] (TypeAssert $opnd:* (LiteralType $typ:*) ^ (NeverSubtypeOf? (Prime (TypeOf $opnd)) (Prime $typ))) => (Conditional (IsEmpty $opnd) (Sequence) (Error (LiteralString "")))
                 if (AllowReplace(XmlILOptimization.EliminateTypeAssert, local0))
                 {
                     return Replace(XmlILOptimization.EliminateTypeAssert, local0, VisitConditional(f.Conditional(VisitIsEmpty(f.IsEmpty(local1)), VisitSequence(f.Sequence()), VisitError(f.Error(VisitLiteralString(f.LiteralString(string.Empty)))))));
                 }
             }
         }
     }
     if (this[XmlILOptimization.EliminateTypeAssertOptional])
     {
         if (local2.NodeType == QilNodeType.LiteralType)
         {
             XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
             if ((local1).XmlType.IsSubtypeOf(local3))
             {
                 // PATTERN: [EliminateTypeAssertOptional] (TypeAssert $opnd:* (LiteralType $base:*) ^ (SubtypeOf? (TypeOf $opnd) $base)) => $opnd
                 if (AllowReplace(XmlILOptimization.EliminateTypeAssertOptional, local0))
                 {
                     return Replace(XmlILOptimization.EliminateTypeAssertOptional, local0, local1);
                 }
             }
         }
     }
     return NoReplace(local0);
 }
Beispiel #7
0
 protected virtual QilNode VisitIsType(QilTargetType n)
 {
     return(VisitChildren(n));
 }
Beispiel #8
0
 public XmlQueryType CheckIsType(QilTargetType node)
 {
     CheckClassAndNodeType(node[1], typeof(QilLiteral), QilNodeType.LiteralType);
     return(XmlQueryTypeFactory.BooleanX);
 }
 public XmlQueryType CheckIsType(QilTargetType node) {
     CheckClassAndNodeType(node[1], typeof(QilLiteral), QilNodeType.LiteralType);
     return XmlQueryTypeFactory.BooleanX;
 }
 protected override QilNode VisitXsltConvert(QilTargetType local0)
 {
     QilNode local1 = local0[0];
     QilNode local2 = local0[1];
     if (this[XmlILOptimization.FoldNone])
     {
         if ((object)((local1).XmlType) == (object)XmlQueryTypeFactory.None)
         {
             // PATTERN: [FoldNone] (XsltConvert $x:* ^ (None? (TypeOf $x)) *) => (Nop $x)
             if (AllowReplace(XmlILOptimization.FoldNone, local0))
             {
                 return Replace(XmlILOptimization.FoldNone, local0, VisitNop(f.Nop(local1)));
             }
         }
     }
     if (this[XmlILOptimization.FoldXsltConvertLiteral])
     {
         if (IsLiteral((local1)))
         {
             if (local2.NodeType == QilNodeType.LiteralType)
             {
                 XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
                 if (CanFoldXsltConvert(local1, local3))
                 {
                     // PATTERN: [FoldXsltConvertLiteral] (XsltConvert $lit:* ^ (Literal? $lit) (LiteralType $typ:*) ^ (CanFoldXsltConvert? $lit $typ)) => (FoldXsltConvert $lit $typ)
                     if (AllowReplace(XmlILOptimization.FoldXsltConvertLiteral, local0))
                     {
                         return Replace(XmlILOptimization.FoldXsltConvertLiteral, local0, FoldXsltConvert(local1, local3));
                     }
                 }
             }
         }
     }
     if (this[XmlILOptimization.EliminateXsltConvert])
     {
         if (local2.NodeType == QilNodeType.LiteralType)
         {
             XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
             if (((local1).XmlType) == (local3))
             {
                 // PATTERN: [EliminateXsltConvert] (XsltConvert $expr:* (LiteralType $typ:*) ^ (Equal? (TypeOf $expr) $typ)) => $expr
                 if (AllowReplace(XmlILOptimization.EliminateXsltConvert, local0))
                 {
                     return Replace(XmlILOptimization.EliminateXsltConvert, local0, local1);
                 }
             }
         }
     }
     return NoReplace(local0);
 }
 protected override QilNode VisitIsType(QilTargetType n) { return NoReplace(n); }
Beispiel #12
0
        /// <summary>
        /// Generate code for QilNodeType.XsltConvert.
        /// </summary>
        protected override QilNode VisitXsltConvert(QilTargetType ndConv)
        {
            XmlQueryType typSrc, typDst;
            MethodInfo meth;

            typSrc = ndConv.Source.XmlType;
            typDst = ndConv.TargetType;

            if (GetXsltConvertMethod(typSrc, typDst, out meth))
            {
                NestedVisitEnsureStack(ndConv.Source);
            }
            else
            {
                // If a conversion could not be found, then convert the source expression to item or item* and try again
                NestedVisitEnsureStack(ndConv.Source, typeof(XPathItem), !typSrc.IsSingleton);
                if (!GetXsltConvertMethod(typSrc.IsSingleton ? TypeFactory.Item : TypeFactory.ItemS, typDst, out meth))
                    Debug.Fail("Conversion from " + ndConv.Source.XmlType + " to " + ndConv.TargetType + " is not supported.");
            }

            // XsltConvert.XXXToYYY(value);
            if (meth != null)
                _helper.Call(meth);

            _iterCurr.Storage = StorageDescriptor.Stack(GetItemStorageType(typDst), !typDst.IsSingleton);
            return ndConv;
        }
Beispiel #13
0
        /// <summary>
        /// Faster code can be generated if type test is just a node kind test.  If this special case is detected, then generate code and return true.
        /// Otherwise, return false, and a call to MatchesXmlType will be generated instead.
        /// </summary>
        private bool MatchesNodeKinds(QilTargetType ndIsType, XmlQueryType typDerived, XmlQueryType typBase)
        {
            XmlNodeKindFlags kinds;
            bool allowKinds = true;
            XPathNodeType kindsRuntime;
            int kindsUnion;

            // If not checking whether typDerived is some kind of singleton node, then fallback to MatchesXmlType
            if (!typBase.IsNode || !typBase.IsSingleton)
                return false;

            // If typDerived is not statically guaranteed to be a singleton node (and not an rtf), then fallback to MatchesXmlType
            if (!typDerived.IsNode || !typDerived.IsSingleton || !typDerived.IsNotRtf)
                return false;

            // Now we are guaranteed that typDerived is a node, and typBase is a node, so check node kinds
            // Ensure that typBase is only composed of kind-test prime types (no name-test, no schema-test, etc.)
            kinds = XmlNodeKindFlags.None;
            foreach (XmlQueryType typItem in typBase)
            {
                if ((object)typItem == (object)TypeFactory.Element) kinds |= XmlNodeKindFlags.Element;
                else if ((object)typItem == (object)TypeFactory.Attribute) kinds |= XmlNodeKindFlags.Attribute;
                else if ((object)typItem == (object)TypeFactory.Text) kinds |= XmlNodeKindFlags.Text;
                else if ((object)typItem == (object)TypeFactory.Document) kinds |= XmlNodeKindFlags.Document;
                else if ((object)typItem == (object)TypeFactory.Comment) kinds |= XmlNodeKindFlags.Comment;
                else if ((object)typItem == (object)TypeFactory.PI) kinds |= XmlNodeKindFlags.PI;
                else if ((object)typItem == (object)TypeFactory.Namespace) kinds |= XmlNodeKindFlags.Namespace;
                else return false;
            }

            Debug.Assert((typDerived.NodeKinds & kinds) != XmlNodeKindFlags.None, "Normalizer should have taken care of case where node kinds are disjoint.");

            kinds = typDerived.NodeKinds & kinds;

            // Attempt to allow or disallow exactly one kind
            if (!Bits.ExactlyOne((uint)kinds))
            {
                // Not possible to allow one kind, so try to disallow one kind
                kinds = ~kinds & XmlNodeKindFlags.Any;
                allowKinds = !allowKinds;
            }

            switch (kinds)
            {
                case XmlNodeKindFlags.Element: kindsRuntime = XPathNodeType.Element; break;
                case XmlNodeKindFlags.Attribute: kindsRuntime = XPathNodeType.Attribute; break;
                case XmlNodeKindFlags.Namespace: kindsRuntime = XPathNodeType.Namespace; break;
                case XmlNodeKindFlags.PI: kindsRuntime = XPathNodeType.ProcessingInstruction; break;
                case XmlNodeKindFlags.Comment: kindsRuntime = XPathNodeType.Comment; break;
                case XmlNodeKindFlags.Document: kindsRuntime = XPathNodeType.Root; break;

                default:
                    // Union of several types (when testing for Text, we need to test for Whitespace as well)

                    // if (((1 << navigator.NodeType) & nodesDisallow) op 0) goto LabelBranch;
                    _helper.Emit(OpCodes.Ldc_I4_1);
                    kindsRuntime = XPathNodeType.All;
                    break;
            }

            // Push navigator.NodeType onto the stack
            NestedVisitEnsureStack(ndIsType.Source);
            _helper.Call(XmlILMethods.NavType);

            if (kindsRuntime == XPathNodeType.All)
            {
                // if (((1 << navigator.NodeType) & kindsUnion) op 0) goto LabelBranch;
                _helper.Emit(OpCodes.Shl);

                kindsUnion = 0;
                if ((kinds & XmlNodeKindFlags.Document) != 0) kindsUnion |= (1 << (int)XPathNodeType.Root);
                if ((kinds & XmlNodeKindFlags.Element) != 0) kindsUnion |= (1 << (int)XPathNodeType.Element);
                if ((kinds & XmlNodeKindFlags.Attribute) != 0) kindsUnion |= (1 << (int)XPathNodeType.Attribute);
                if ((kinds & XmlNodeKindFlags.Text) != 0)
                    kindsUnion |= (1 << (int)(int)XPathNodeType.Text) |
                                (1 << (int)(int)XPathNodeType.SignificantWhitespace) |
                                (1 << (int)(int)XPathNodeType.Whitespace);
                if ((kinds & XmlNodeKindFlags.Comment) != 0) kindsUnion |= (1 << (int)XPathNodeType.Comment);
                if ((kinds & XmlNodeKindFlags.PI) != 0) kindsUnion |= (1 << (int)XPathNodeType.ProcessingInstruction);
                if ((kinds & XmlNodeKindFlags.Namespace) != 0) kindsUnion |= (1 << (int)XPathNodeType.Namespace);

                _helper.LoadInteger(kindsUnion);
                _helper.Emit(OpCodes.And);
                ZeroCompare(allowKinds ? QilNodeType.Ne : QilNodeType.Eq, false);
            }
            else
            {
                // if (navigator.NodeType op runtimeItem) goto LabelBranch;
                _helper.LoadInteger((int)kindsRuntime);
                ClrCompare(allowKinds ? QilNodeType.Eq : QilNodeType.Ne, XmlTypeCode.Int);
            }

            return true;
        }
Beispiel #14
0
        /// <summary>
        /// Generate code for QilNodeType.IsType.
        /// </summary>
        protected override QilNode VisitIsType(QilTargetType ndIsType)
        {
            XmlQueryType typDerived, typBase;
            XmlTypeCode codeBase;

            typDerived = ndIsType.Source.XmlType;
            typBase = ndIsType.TargetType;
            Debug.Assert(!typDerived.NeverSubtypeOf(typBase), "Normalizer should have eliminated IsType where source can never be a subtype of destination type.");

            // Special Case: Test whether singleton item is a Node
            if (typDerived.IsSingleton && (object)typBase == (object)TypeFactory.Node)
            {
                NestedVisitEnsureStack(ndIsType.Source);
                Debug.Assert(_iterCurr.Storage.ItemStorageType == typeof(XPathItem), "If !IsNode, then storage type should be Item");

                // if (item.IsNode op true) goto LabelBranch;
                _helper.Call(XmlILMethods.ItemIsNode);
                ZeroCompare(QilNodeType.Ne, true);

                return ndIsType;
            }

            // Special Case: Source value is a singleton Node, and we're testing whether it is an Element, Attribute, PI, etc.
            if (MatchesNodeKinds(ndIsType, typDerived, typBase))
                return ndIsType;

            // Special Case: XmlTypeCode is sufficient to describe destination type
            if ((object)typBase == (object)TypeFactory.Double) codeBase = XmlTypeCode.Double;
            else if ((object)typBase == (object)TypeFactory.String) codeBase = XmlTypeCode.String;
            else if ((object)typBase == (object)TypeFactory.Boolean) codeBase = XmlTypeCode.Boolean;
            else if ((object)typBase == (object)TypeFactory.Node) codeBase = XmlTypeCode.Node;
            else codeBase = XmlTypeCode.None;

            if (codeBase != XmlTypeCode.None)
            {
                // if (runtime.MatchesXmlType(value, code) op true) goto LabelBranch;
                _helper.LoadQueryRuntime();
                NestedVisitEnsureStack(ndIsType.Source, typeof(XPathItem), !typDerived.IsSingleton);
                _helper.LoadInteger((int)codeBase);
                _helper.Call(typDerived.IsSingleton ? XmlILMethods.ItemMatchesCode : XmlILMethods.SeqMatchesCode);
                ZeroCompare(QilNodeType.Ne, true);

                return ndIsType;
            }

            // if (runtime.MatchesXmlType(value, idxType) op true) goto LabelBranch;
            _helper.LoadQueryRuntime();
            NestedVisitEnsureStack(ndIsType.Source, typeof(XPathItem), !typDerived.IsSingleton);
            _helper.LoadInteger(_helper.StaticData.DeclareXmlType(typBase));
            _helper.Call(typDerived.IsSingleton ? XmlILMethods.ItemMatchesType : XmlILMethods.SeqMatchesType);
            ZeroCompare(QilNodeType.Ne, true);

            return ndIsType;
        }
Beispiel #15
0
        /// <summary>
        /// Find physical query plan for QilNodeType.TypeAssert.
        /// </summary>
        protected override QilNode VisitTypeAssert(QilTargetType ndTypeAssert)
        {
            if (!ndTypeAssert.Source.XmlType.IsSingleton && ndTypeAssert.XmlType.IsSingleton && !_iterCurr.HasLabelNext)
            {
                // This case occurs when a non-singleton expression is treated as cardinality One.
                // The trouble is that the expression will branch to an end label when it's done iterating, so
                // an end label must be provided.  But there is no next label in the current iteration context,
                // so we've got to create a dummy label instead (IL requires it).  This creates an infinite loop,
                // but since it's known statically that the expression is cardinality One, this branch will never
                // be taken.
                Label lblDummy = _helper.DefineLabel();
                _helper.MarkLabel(lblDummy);
                NestedVisit(ndTypeAssert.Source, lblDummy);
            }
            else
            {
                // Generate code for child expression
                Visit(ndTypeAssert.Source);
            }

            _iterCurr.EnsureItemStorageType(ndTypeAssert.Source.XmlType, GetItemStorageType(ndTypeAssert));
            return ndTypeAssert;
        }
Beispiel #16
0
 //-----------------------------------------------
 // Type operators
 //-----------------------------------------------
 public QilTargetType TypeAssert(QilNode source, QilNode targetType)
 {
     QilTargetType n = new QilTargetType(QilNodeType.TypeAssert, source, targetType);
     n.XmlType = _typeCheck.CheckTypeAssert(n);
     TraceNode(n);
     return n;
 }
 protected virtual QilNode VisitIsType(QilTargetType n) { return VisitChildren(n); }
 public QilTargetType IsType(QilNode source, QilNode targetType) {
     QilTargetType n = new QilTargetType(QilNodeType.IsType, source, targetType);
     n.XmlType = this.typeCheck.CheckIsType(n);
     TraceNode(n);
     return n;
 }
 protected override QilNode VisitIsType(QilTargetType local0)
 {
     QilNode local1 = local0[0];
     QilNode local2 = local0[1];
     if (this[XmlILOptimization.FoldNone])
     {
         if ((object)((local1).XmlType) == (object)XmlQueryTypeFactory.None)
         {
             // PATTERN: [FoldNone] (IsType $x:* ^ (None? (TypeOf $x)) *) => (Nop $x)
             if (AllowReplace(XmlILOptimization.FoldNone, local0))
             {
                 return Replace(XmlILOptimization.FoldNone, local0, VisitNop(f.Nop(local1)));
             }
         }
     }
     if (this[XmlILOptimization.EliminateIsType])
     {
         if (!OptimizerPatterns.Read(local1).MatchesPattern(OptimizerPatternName.MaybeSideEffects))
         {
             if (local2.NodeType == QilNodeType.LiteralType)
             {
                 XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
                 if ((local1).XmlType.IsSubtypeOf(local3))
                 {
                     // PATTERN: [EliminateIsType] (IsType $opnd:* ^ (NoSideEffects? $opnd) (LiteralType $base:*) ^ (SubtypeOf? (TypeOf $opnd) $base)) => (True)
                     if (AllowReplace(XmlILOptimization.EliminateIsType, local0))
                     {
                         return Replace(XmlILOptimization.EliminateIsType, local0, VisitTrue(f.True()));
                     }
                 }
             }
         }
     }
     if (this[XmlILOptimization.EliminateIsType])
     {
         if (!OptimizerPatterns.Read(local1).MatchesPattern(OptimizerPatternName.MaybeSideEffects))
         {
             if (local2.NodeType == QilNodeType.LiteralType)
             {
                 XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
                 if ((local1).XmlType.NeverSubtypeOf(local3))
                 {
                     // PATTERN: [EliminateIsType] (IsType $opnd:* ^ (NoSideEffects? $opnd) (LiteralType $typ:*) ^ (NeverSubtypeOf? (TypeOf $opnd) $typ)) => (False)
                     if (AllowReplace(XmlILOptimization.EliminateIsType, local0))
                     {
                         return Replace(XmlILOptimization.EliminateIsType, local0, VisitFalse(f.False()));
                     }
                 }
             }
         }
     }
     if (this[XmlILOptimization.EliminateIsType])
     {
         if (local2.NodeType == QilNodeType.LiteralType)
         {
             XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
             if ((local1).XmlType.Prime.NeverSubtypeOf(local3.Prime))
             {
                 // PATTERN: [EliminateIsType] (IsType $opnd:* (LiteralType $typ:*) ^ (NeverSubtypeOf? (Prime (TypeOf $opnd)) (Prime $typ))) => (IsEmpty $opnd)
                 if (AllowReplace(XmlILOptimization.EliminateIsType, local0))
                 {
                     return Replace(XmlILOptimization.EliminateIsType, local0, VisitIsEmpty(f.IsEmpty(local1)));
                 }
             }
         }
     }
     if (this[XmlILOptimization.EliminateIsType])
     {
         if (!(!OptimizerPatterns.Read(local1).MatchesPattern(OptimizerPatternName.MaybeSideEffects)))
         {
             if (local2.NodeType == QilNodeType.LiteralType)
             {
                 XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
                 if ((local1).XmlType.IsSubtypeOf(local3))
                 {
                     // PATTERN: [EliminateIsType] (IsType $opnd:* ^ ~((NoSideEffects? $opnd)) (LiteralType $base:*) ^ (SubtypeOf? (TypeOf $opnd) $base)) => (Loop (Let $opnd) (True))
                     if (AllowReplace(XmlILOptimization.EliminateIsType, local0))
                     {
                         return Replace(XmlILOptimization.EliminateIsType, local0, VisitLoop(f.Loop(VisitLet(f.Let(local1)), VisitTrue(f.True()))));
                     }
                 }
             }
         }
     }
     if (this[XmlILOptimization.EliminateIsType])
     {
         if (!(!OptimizerPatterns.Read(local1).MatchesPattern(OptimizerPatternName.MaybeSideEffects)))
         {
             if (local2.NodeType == QilNodeType.LiteralType)
             {
                 XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
                 if ((local1).XmlType.NeverSubtypeOf(local3))
                 {
                     // PATTERN: [EliminateIsType] (IsType $opnd:* ^ ~((NoSideEffects? $opnd)) (LiteralType $typ:*) ^ (NeverSubtypeOf? (TypeOf $opnd) $typ)) => (Loop (Let $opnd) (False))
                     if (AllowReplace(XmlILOptimization.EliminateIsType, local0))
                     {
                         return Replace(XmlILOptimization.EliminateIsType, local0, VisitLoop(f.Loop(VisitLet(f.Let(local1)), VisitFalse(f.False()))));
                     }
                 }
             }
         }
     }
     return NoReplace(local0);
 }
 protected override QilNode VisitXsltConvert(QilTargetType n) { return NoReplace(n); }
 public QilTargetType XsltConvert(QilNode source, QilNode targetType) {
     QilTargetType n = new QilTargetType(QilNodeType.XsltConvert, source, targetType);
     n.XmlType = this.typeCheck.CheckXsltConvert(n);
     TraceNode(n);
     return n;
 }
 protected virtual QilNode VisitXsltConvert(QilTargetType n) { return VisitChildren(n); }
 protected override QilNode VisitTypeAssert(QilTargetType local0) {
     QilNode local1 = local0[0];
     QilNode local2 = local0[1];
     if (this[XmlILOptimization.FoldNone]) {
         if ( (object) ( (local1).XmlType ) == (object) XmlQueryTypeFactory.None ) {
             if (AllowReplace(XmlILOptimization.FoldNone, local0)) {
                 return Replace(XmlILOptimization.FoldNone, local0, VisitNop(f.Nop(local1)));
             }
         }
     }
     if (this[XmlILOptimization.EliminateTypeAssert]) {
         if (local2.NodeType == QilNodeType.LiteralType) {
             XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
             if (  (local1).XmlType .NeverSubtypeOf(local3) ) {
                 if (AllowReplace(XmlILOptimization.EliminateTypeAssert, local0)) {
                     return Replace(XmlILOptimization.EliminateTypeAssert, local0, VisitError(f.Error(VisitLiteralString(f.LiteralString("")))));
                 }
             }
         }
     }
     if (this[XmlILOptimization.EliminateTypeAssert]) {
         if (local2.NodeType == QilNodeType.LiteralType) {
             XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
             if (   (local1).XmlType .Prime .NeverSubtypeOf( local3.Prime ) ) {
                 if (AllowReplace(XmlILOptimization.EliminateTypeAssert, local0)) {
                     return Replace(XmlILOptimization.EliminateTypeAssert, local0, VisitConditional(f.Conditional(VisitIsEmpty(f.IsEmpty(local1)), VisitSequence(f.Sequence()), VisitError(f.Error(VisitLiteralString(f.LiteralString("")))))));
                 }
             }
         }
     }
     if (this[XmlILOptimization.EliminateTypeAssertOptional]) {
         if (local2.NodeType == QilNodeType.LiteralType) {
             XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
             if (  (local1).XmlType .IsSubtypeOf(local3) ) {
                 if (AllowReplace(XmlILOptimization.EliminateTypeAssertOptional, local0)) {
                     return Replace(XmlILOptimization.EliminateTypeAssertOptional, local0, local1);
                 }
             }
         }
     }
     return NoReplace(local0);
 }
 public XmlQueryType CheckXsltConvert(QilTargetType node) {
     CheckClassAndNodeType(node[1], typeof(QilLiteral), QilNodeType.LiteralType);
     return node.TargetType;
 }
 protected override QilNode VisitIsType(QilTargetType local0) {
     QilNode local1 = local0[0];
     QilNode local2 = local0[1];
     if (this[XmlILOptimization.FoldNone]) {
         if ( (object) ( (local1).XmlType ) == (object) XmlQueryTypeFactory.None ) {
             if (AllowReplace(XmlILOptimization.FoldNone, local0)) {
                 return Replace(XmlILOptimization.FoldNone, local0, VisitNop(f.Nop(local1)));
             }
         }
     }
     if (this[XmlILOptimization.EliminateIsType]) {
         if ( !OptimizerPatterns.Read(local1).MatchesPattern(OptimizerPatternName.MaybeSideEffects) ) {
             if (local2.NodeType == QilNodeType.LiteralType) {
                 XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
                 if (  (local1).XmlType .IsSubtypeOf(local3) ) {
                     if (AllowReplace(XmlILOptimization.EliminateIsType, local0)) {
                         return Replace(XmlILOptimization.EliminateIsType, local0, VisitTrue(f.True()));
                     }
                 }
             }
         }
     }
     if (this[XmlILOptimization.EliminateIsType]) {
         if ( !OptimizerPatterns.Read(local1).MatchesPattern(OptimizerPatternName.MaybeSideEffects) ) {
             if (local2.NodeType == QilNodeType.LiteralType) {
                 XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
                 if (  (local1).XmlType .NeverSubtypeOf(local3) ) {
                     if (AllowReplace(XmlILOptimization.EliminateIsType, local0)) {
                         return Replace(XmlILOptimization.EliminateIsType, local0, VisitFalse(f.False()));
                     }
                 }
             }
         }
     }
     if (this[XmlILOptimization.EliminateIsType]) {
         if (local2.NodeType == QilNodeType.LiteralType) {
             XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
             if (   (local1).XmlType .Prime .NeverSubtypeOf( local3.Prime ) ) {
                 if (AllowReplace(XmlILOptimization.EliminateIsType, local0)) {
                     return Replace(XmlILOptimization.EliminateIsType, local0, VisitIsEmpty(f.IsEmpty(local1)));
                 }
             }
         }
     }
     if (this[XmlILOptimization.EliminateIsType]) {
         if (!( !OptimizerPatterns.Read(local1).MatchesPattern(OptimizerPatternName.MaybeSideEffects) )) {
             if (local2.NodeType == QilNodeType.LiteralType) {
                 XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
                 if (  (local1).XmlType .IsSubtypeOf(local3) ) {
                     if (AllowReplace(XmlILOptimization.EliminateIsType, local0)) {
                         return Replace(XmlILOptimization.EliminateIsType, local0, VisitLoop(f.Loop(VisitLet(f.Let(local1)), VisitTrue(f.True()))));
                     }
                 }
             }
         }
     }
     if (this[XmlILOptimization.EliminateIsType]) {
         if (!( !OptimizerPatterns.Read(local1).MatchesPattern(OptimizerPatternName.MaybeSideEffects) )) {
             if (local2.NodeType == QilNodeType.LiteralType) {
                 XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
                 if (  (local1).XmlType .NeverSubtypeOf(local3) ) {
                     if (AllowReplace(XmlILOptimization.EliminateIsType, local0)) {
                         return Replace(XmlILOptimization.EliminateIsType, local0, VisitLoop(f.Loop(VisitLet(f.Let(local1)), VisitFalse(f.False()))));
                     }
                 }
             }
         }
     }
     return NoReplace(local0);
 }
Beispiel #26
0
 public XmlQueryType CheckXsltConvert(QilTargetType node)
 {
     CheckClassAndNodeType(node[1], typeof(QilLiteral), QilNodeType.LiteralType);
     return(node.TargetType);
 }
 protected override QilNode VisitXsltConvert(QilTargetType local0) {
     QilNode local1 = local0[0];
     QilNode local2 = local0[1];
     if (this[XmlILOptimization.FoldNone]) {
         if ( (object) ( (local1).XmlType ) == (object) XmlQueryTypeFactory.None ) {
             if (AllowReplace(XmlILOptimization.FoldNone, local0)) {
                 return Replace(XmlILOptimization.FoldNone, local0, VisitNop(f.Nop(local1)));
             }
         }
     }
     if (this[XmlILOptimization.FoldXsltConvertLiteral]) {
         if ( IsLiteral((local1)) ) {
             if (local2.NodeType == QilNodeType.LiteralType) {
                 XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
                 if ( CanFoldXsltConvert(local1, local3) ) {
                     if (AllowReplace(XmlILOptimization.FoldXsltConvertLiteral, local0)) {
                         return Replace(XmlILOptimization.FoldXsltConvertLiteral, local0,  FoldXsltConvert(local1, local3) );
                     }
                 }
             }
         }
     }
     if (this[XmlILOptimization.EliminateXsltConvert]) {
         if (local2.NodeType == QilNodeType.LiteralType) {
             XmlQueryType local3 = (XmlQueryType)((QilLiteral)local2).Value;
             if ( ( (local1).XmlType ) == (local3) ) {
                 if (AllowReplace(XmlILOptimization.EliminateXsltConvert, local0)) {
                     return Replace(XmlILOptimization.EliminateXsltConvert, local0, local1);
                 }
             }
         }
     }
     return NoReplace(local0);
 }
Beispiel #28
0
 protected virtual QilNode VisitXsltConvert(QilTargetType n)
 {
     return(VisitChildren(n));
 }
Beispiel #29
0
 protected override QilNode VisitTypeAssert(QilTargetType n) { return NoReplace(n); }