コード例 #1
0
ファイル: QilGenerator.cs プロジェクト: Corillian/corefx
        private QilNode CompileApplyTemplates(XslNodeEx node)
        {
            QilNode result;
            IList<XslNode> content = node.Content;

            // Calculate select expression
            int varScope = _varHelper.StartVariables();

            QilIterator select = _f.Let(CompileNodeSetExpression(node.Select));
            _varHelper.AddVariable(select);

            // Compile with-param's, they must be calculated outside the loop and
            // if they are neither constant nor reference we need to cache them in Let's
            for (int i = 0; i < content.Count; i++)
            {
                VarPar withParam = content[i] as VarPar;
                if (withParam != null)
                {
                    Debug.Assert(withParam.NodeType == XslNodeType.WithParam);
                    CompileWithParam(withParam);
                    QilNode val = withParam.Value;
                    if (IsDebug || !(val is QilIterator || val is QilLiteral))
                    {
                        QilIterator let = _f.Let(val);
                        let.DebugName = _f.QName("with-param " + withParam.Name.QualifiedName, XmlReservedNs.NsXslDebug).ToString();
                        _varHelper.AddVariable(let);
                        withParam.Value = let;
                    }
                }
            }

            // Push new loop frame on the stack
            LoopFocus curLoopSaved = _curLoop;
            QilIterator it = _f.For(select);
            _curLoop.SetFocus(it);

            // Compile sort keys and body
            _curLoop.Sort(CompileSorts(content, ref curLoopSaved));

            result = GenerateApply(_compiler.Root, node);

            result = WrapLoopBody(node.ElemNameLi, result, node.EndTagLi);
            result = AddCurrentPositionLast(result);
            result = _curLoop.ConstructLoop(result);

            // Pop loop frame
            _curLoop = curLoopSaved;

            result = _varHelper.FinishVariables(result, varScope);
            return result;
        }
コード例 #2
0
ファイル: QilGenerator.cs プロジェクト: Corillian/corefx
        private QilNode CompileCallTemplate(XslNodeEx node)
        {
            VerifyXPathQName(node.Name);
            int varScope = _varHelper.StartVariables();

            IList<XslNode> content = node.Content;
            foreach (VarPar withParam in content)
            {
                CompileWithParam(withParam);
                // In debug mode precalculate all with-param's
                if (IsDebug)
                {
                    QilNode val = withParam.Value;
                    QilIterator let = _f.Let(val);
                    let.DebugName = _f.QName("with-param " + withParam.Name.QualifiedName, XmlReservedNs.NsXslDebug).ToString();
                    _varHelper.AddVariable(let);
                    withParam.Value = let;
                }
            }

            QilNode result;
            {
                Template tmpl;
                if (_compiler.NamedTemplates.TryGetValue(node.Name, out tmpl))
                {
                    Debug.Assert(tmpl.Function != null, "All templates should be already compiled");
                    result = _invkGen.GenerateInvoke(tmpl.Function, AddRemoveImplicitArgs(node.Content, tmpl.Flags));
                }
                else
                {
                    if (!_compiler.IsPhantomName(node.Name))
                    {
                        _compiler.ReportError(/*[XT0710]*/node.SourceLine, SR.Xslt_InvalidCallTemplate, node.Name.QualifiedName);
                    }
                    result = _f.Sequence();
                }
            }

            // Do not create an additional sequence point if there are no parameters
            if (content.Count > 0)
            {
                result = SetLineInfo(result, node.ElemNameLi);
            }
            result = _varHelper.FinishVariables(result, varScope);
            if (IsDebug)
            {
                return _f.Nop(result);
            }
            return result;
        }
コード例 #3
0
ファイル: QilGenerator.cs プロジェクト: Corillian/corefx
        private QilNode CompileForEach(XslNodeEx node)
        {
            QilNode result;
            IList<XslNode> content = node.Content;

            // Push new loop frame on the stack
            LoopFocus curLoopSaved = _curLoop;
            QilIterator it = _f.For(CompileNodeSetExpression(node.Select));
            _curLoop.SetFocus(it);

            // Compile sort keys and body
            int varScope = _varHelper.StartVariables();
            _curLoop.Sort(CompileSorts(content, ref curLoopSaved));
            result = CompileInstructions(content);
            result = WrapLoopBody(node.ElemNameLi, result, node.EndTagLi);
            result = AddCurrentPositionLast(result);
            result = _curLoop.ConstructLoop(result);
            result = _varHelper.FinishVariables(result, varScope);

            // Pop loop frame
            _curLoop = curLoopSaved;
            return result;
        }