private void FlushBuilder()
 {
     if (_concat == null)
     {
         _concat = _f.BaseFactory.Sequence();
     }
     if (_builder.Length != 0)
     {
         _concat.Add(_f.String(_builder.ToString()));
         _builder.Length = 0;
     }
 }
Exemple #2
0
 private void FlushBuilder()
 {
     if (concat == null)
     {
         concat = f.BaseFactory.Sequence();
     }
     if (builder.Length != 0)
     {
         concat.Add(f.String(builder.ToString()));
         builder.Length = 0;
     }
 }
Exemple #3
0
        private QilNode CompileSingleKey(List <Key> defList, QilIterator key, QilIterator context)
        {
            Debug.Assert(defList != null && defList.Count > 0);
            QilList result = _f.BaseFactory.Sequence();
            QilNode keyRef = null;

            foreach (Key keyDef in defList)
            {
                keyRef = _f.Invoke(keyDef.Function, _f.ActualParameterList(context, key));
                result.Add(keyRef);
            }
            return(defList.Count == 1 ? keyRef : result);
        }
Exemple #4
0
        public QilNode GenerateInvoke(QilFunction func, IList <XslNode> actualArgs)
        {
            iterStack.Clear();
            formalArgs = func.Arguments;
            invokeArgs = fac.ActualParameterList();

            // curArg is an instance variable used in Clone() method
            for (curArg = 0; curArg < formalArgs.Count; curArg++)
            {
                // Find actual value for a given formal arg
                QilParameter formalArg = (QilParameter)formalArgs[curArg];
                QilNode      invokeArg = FindActualArg(formalArg, actualArgs);

                // If actual value was not specified, use the default value and copy its debug comment
                if (invokeArg == null)
                {
                    if (debug)
                    {
                        if (formalArg.Name.NamespaceUri == XmlReservedNs.NsXslDebug)
                        {
                            Debug.Assert(formalArg.Name.LocalName == "namespaces", "Cur,Pos,Last don't have default values and should be always added to by caller in AddImplicitArgs()");
                            Debug.Assert(formalArg.DefaultValue != null, "PrecompileProtoTemplatesHeaders() set it");
                            invokeArg = Clone(formalArg.DefaultValue);
                        }
                        else
                        {
                            invokeArg = fac.DefaultValueMarker();
                        }
                    }
                    else
                    {
                        Debug.Assert(formalArg.Name.NamespaceUri != XmlReservedNs.NsXslDebug, "Cur,Pos,Last don't have default values and should be always added to by caller in AddImplicitArgs(). We don't have $namespaces in !debug.");
                        invokeArg = Clone(formalArg.DefaultValue);
                    }
                }

                XmlQueryType formalType = formalArg.XmlType;
                XmlQueryType invokeType = invokeArg.XmlType;

                // Possible arg types: anyType, node-set, string, boolean, and number
                fac.CheckXsltType(formalArg);
                fac.CheckXsltType(invokeArg);

                if (!invokeType.IsSubtypeOf(formalType))
                {
                    // This may occur only if inferred type of invokeArg is XslFlags.None
                    Debug.Assert(invokeType == T.ItemS, "Actual argument type is not a subtype of formal argument type");
                    invokeArg = fac.TypeAssert(invokeArg, formalType);
                }

                invokeArgs.Add(invokeArg);
            }

            // Create Invoke node and wrap it with previous parameter declarations
            QilNode invoke = fac.Invoke(func, invokeArgs);

            while (iterStack.Count != 0)
            {
                invoke = fac.Loop(iterStack.Pop(), invoke);
            }

            return(invoke);
        }