System.Xml.Xsl.IlGen.XmlILVisitor.VisitXsltInvokeLateBound C# (CSharp) Method

VisitXsltInvokeLateBound() protected method

Generate code for for QilNodeType.XsltInvokeLateBound.
protected VisitXsltInvokeLateBound ( QilInvokeLateBound ndInvoke ) : QilNode
ndInvoke QilInvokeLateBound
return QilNode
        protected override QilNode VisitXsltInvokeLateBound(QilInvokeLateBound ndInvoke) {
            LocalBuilder locArgs = this.helper.DeclareLocal("$$$args", typeof(IList<XPathItem>[]));
            QilName ndName = (QilName) ndInvoke.Name;
            Debug.Assert(XmlILConstructInfo.Read(ndInvoke).ConstructMethod != XmlILConstructMethod.Writer);

            // runtime.ExternalContext.InvokeXsltLateBoundFunction(name, ns, args);
            this.helper.LoadQueryContext();
            this.helper.Emit(OpCodes.Ldstr, ndName.LocalName);
            this.helper.Emit(OpCodes.Ldstr, ndName.NamespaceUri);

            // args = new IList<XPathItem>[argCount];
            this.helper.LoadInteger(ndInvoke.Arguments.Count);
            this.helper.Emit(OpCodes.Newarr, typeof(IList<XPathItem>));
            this.helper.Emit(OpCodes.Stloc, locArgs);

            for (int iArg = 0; iArg < ndInvoke.Arguments.Count; iArg++) {
                QilNode ndArg = ndInvoke.Arguments[iArg];

                // args[0] = arg0;
                // ...
                // args[N] = argN;
                this.helper.Emit(OpCodes.Ldloc, locArgs);
                this.helper.LoadInteger(iArg);
                this.helper.Emit(OpCodes.Ldelema, typeof(IList<XPathItem>));

                NestedVisitEnsureCache(ndArg, typeof(XPathItem));
                this.iterCurr.EnsureStack();

                this.helper.Emit(OpCodes.Stobj, typeof(IList<XPathItem>));
            }

            this.helper.Emit(OpCodes.Ldloc, locArgs);

            this.helper.Call(XmlILMethods.InvokeXsltLate);

            // Returned item sequence is on the stack
            this.iterCurr.Storage = StorageDescriptor.Stack(typeof(XPathItem), true);

            return ndInvoke;
        }
XmlILVisitor