View over a Qil StrConcat operator.
Don't construct QIL nodes directly; instead, use the QilFactory.
Inheritance: QilBinary
Example #1
0
        public QilStrConcat StrConcat(QilNode delimiter, QilNode values)
        {
            QilStrConcat n = new QilStrConcat(QilNodeType.StrConcat, delimiter, values);

            n.XmlType = this.typeCheck.CheckStrConcat(n);
            TraceNode(n);
            return(n);
        }
Example #2
0
 protected virtual QilNode VisitStrConcat(QilStrConcat n)
 {
     return(VisitChildren(n));
 }
Example #3
0
 public XmlQueryType CheckStrConcat(QilStrConcat node)
 {
     CheckXmlType(node.Delimiter, XmlQueryTypeFactory.StringX);
     CheckXmlType(node.Values, XmlQueryTypeFactory.StringXS);
     return(XmlQueryTypeFactory.StringX);
 }
 public XmlQueryType CheckStrConcat(QilStrConcat node) {
     CheckXmlType(node.Delimiter, XmlQueryTypeFactory.StringX);
     CheckXmlType(node.Values, XmlQueryTypeFactory.StringXS);
     return XmlQueryTypeFactory.StringX;
 }
 protected virtual QilNode VisitStrConcat(QilStrConcat n) { return VisitChildren(n); }
Example #6
0
 protected override QilNode VisitStrConcat(QilStrConcat n) { return NoReplace(n); }
Example #7
0
 protected override QilNode VisitStrConcat(QilStrConcat n)
 {
     return(NoReplace(n));
 }
        protected override QilNode VisitStrConcat(QilStrConcat 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.FoldNone]) {
                if ( (object) ( (local2).XmlType ) == (object) XmlQueryTypeFactory.None ) {
                    if (AllowReplace(XmlILOptimization.FoldNone, local0)) {
                        return Replace(XmlILOptimization.FoldNone, local0, VisitNop(f.Nop(local2)));
                    }
                }
            }
            if (( ( (local2).XmlType ).IsSingleton ) && (this[XmlILOptimization.EliminateStrConcatSingle])) {
                if (AllowReplace(XmlILOptimization.EliminateStrConcatSingle, local0)) {
                    return Replace(XmlILOptimization.EliminateStrConcatSingle, local0, VisitNop(f.Nop(local2)));
                }
            }
            if (this[XmlILOptimization.EliminateStrConcat]) {
                if (local1.NodeType == QilNodeType.LiteralString) {
                    string local3 = (string)((QilLiteral)local1).Value;
                    if (local2.NodeType == QilNodeType.Sequence) {
                        if ( AreLiteralArgs(local2) ) {
                            if (AllowReplace(XmlILOptimization.EliminateStrConcat, local0)) {
                                
    // Concatenate all constant arguments
    StringConcat concat = new StringConcat();
    concat.Delimiter = local3;

    foreach (QilLiteral lit in local2)
        concat.Concat((string) lit);
return Replace(XmlILOptimization.EliminateStrConcat, local0, VisitLiteralString(f.LiteralString( concat.GetResult() )));
                            }
                        }
                    }
                }
            }
            return NoReplace(local0);
        }
 public QilStrConcat StrConcat(QilNode delimiter, QilNode values) {
     QilStrConcat n = new QilStrConcat(QilNodeType.StrConcat, delimiter, values);
     n.XmlType = this.typeCheck.CheckStrConcat(n);
     TraceNode(n);
     return n;
 }
Example #10
0
        /// <summary>
        /// Generate code for QilNodeType.StrConcat.
        /// </summary>
        protected override QilNode VisitStrConcat(QilStrConcat ndStrConcat)
        {
            LocalBuilder locStringConcat;
            bool fasterConcat;
            QilNode delimiter;
            QilNode listStrings;
            Debug.Assert(!ndStrConcat.Values.XmlType.IsSingleton, "Optimizer should have folded StrConcat of a singleton value");

            // Get delimiter (assuming it's not the empty string)
            delimiter = ndStrConcat.Delimiter;
            if (delimiter.NodeType == QilNodeType.LiteralString && ((string)(QilLiteral)delimiter).Length == 0)
            {
                delimiter = null;
            }

            listStrings = ndStrConcat.Values;
            if (listStrings.NodeType == QilNodeType.Sequence && listStrings.Count < 5)
            {
                // Faster concat possible only if cardinality can be guaranteed at compile-time and there's no delimiter
                fasterConcat = true;
                foreach (QilNode ndStr in listStrings)
                {
                    if (!ndStr.XmlType.IsSingleton)
                        fasterConcat = false;
                }
            }
            else
            {
                // If more than 4 strings, array will need to be built
                fasterConcat = false;
            }

            if (fasterConcat)
            {
                foreach (QilNode ndStr in listStrings)
                    NestedVisitEnsureStack(ndStr);

                _helper.CallConcatStrings(listStrings.Count);
            }
            else
            {
                // Create StringConcat helper internal class
                locStringConcat = _helper.DeclareLocal("$$$strcat", typeof(StringConcat));
                _helper.Emit(OpCodes.Ldloca, locStringConcat);
                _helper.Call(XmlILMethods.StrCatClear);

                // Set delimiter, if it's not empty string
                if (delimiter != null)
                {
                    _helper.Emit(OpCodes.Ldloca, locStringConcat);
                    NestedVisitEnsureStack(delimiter);
                    _helper.Call(XmlILMethods.StrCatDelim);
                }

                _helper.Emit(OpCodes.Ldloca, locStringConcat);

                if (listStrings.NodeType == QilNodeType.Sequence)
                {
                    foreach (QilNode ndStr in listStrings)
                        GenerateConcat(ndStr, locStringConcat);
                }
                else
                {
                    GenerateConcat(listStrings, locStringConcat);
                }

                // Push resulting string onto stack
                _helper.Call(XmlILMethods.StrCatResult);
            }

            _iterCurr.Storage = StorageDescriptor.Stack(typeof(string), false);

            return ndStrConcat;
        }