jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/ApplyTemplates.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
3 */ |
3 */ |
4 /* |
4 /* |
5 * Licensed to the Apache Software Foundation (ASF) under one or more |
5 * Licensed to the Apache Software Foundation (ASF) under one or more |
6 * contributor license agreements. See the NOTICE file distributed with |
6 * contributor license agreements. See the NOTICE file distributed with |
7 * this work for additional information regarding copyright ownership. |
7 * this work for additional information regarding copyright ownership. |
15 * distributed under the License is distributed on an "AS IS" BASIS, |
15 * distributed under the License is distributed on an "AS IS" BASIS, |
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
17 * See the License for the specific language governing permissions and |
17 * See the License for the specific language governing permissions and |
18 * limitations under the License. |
18 * limitations under the License. |
19 */ |
19 */ |
20 /* |
|
21 * $Id: ApplyTemplates.java,v 1.2.4.1 2005/09/12 09:59:21 pvedula Exp $ |
|
22 */ |
|
23 |
20 |
24 package com.sun.org.apache.xalan.internal.xsltc.compiler; |
21 package com.sun.org.apache.xalan.internal.xsltc.compiler; |
25 |
22 |
26 import java.util.Enumeration; |
23 import java.util.Enumeration; |
27 import java.util.Vector; |
24 import java.util.Vector; |
120 final ConstantPoolGen cpg = classGen.getConstantPool(); |
117 final ConstantPoolGen cpg = classGen.getConstantPool(); |
121 final InstructionList il = methodGen.getInstructionList(); |
118 final InstructionList il = methodGen.getInstructionList(); |
122 final int current = methodGen.getLocalIndex("current"); |
119 final int current = methodGen.getLocalIndex("current"); |
123 |
120 |
124 // check if sorting nodes is required |
121 // check if sorting nodes is required |
125 final Vector sortObjects = new Vector(); |
122 final Vector<Sort> sortObjects = new Vector<>(); |
126 final Iterator<SyntaxTreeNode> children = elements(); |
123 for (final SyntaxTreeNode child : getContents()) { |
127 while (children.hasNext()) { |
|
128 final SyntaxTreeNode child = children.next(); |
|
129 if (child instanceof Sort) { |
124 if (child instanceof Sort) { |
130 sortObjects.addElement(child); |
125 sortObjects.addElement((Sort)child); |
131 } |
126 } |
132 } |
127 } |
133 |
128 |
134 // Push a new parameter frame |
129 // Push a new parameter frame |
135 if (stylesheet.hasLocalParams() || hasContents()) { |
130 if (stylesheet.hasLocalParams() || hasContents()) { |
191 final int applyTemplates = cpg.addMethodref(className, |
186 final int applyTemplates = cpg.addMethodref(className, |
192 _functionName, |
187 _functionName, |
193 applyTemplatesSig); |
188 applyTemplatesSig); |
194 il.append(new INVOKEVIRTUAL(applyTemplates)); |
189 il.append(new INVOKEVIRTUAL(applyTemplates)); |
195 |
190 |
|
191 // unmap parameters to release temporary result trees |
|
192 for (final SyntaxTreeNode child : getContents()) { |
|
193 if (child instanceof WithParam) { |
|
194 ((WithParam)child).releaseResultTree(classGen, methodGen); |
|
195 } |
|
196 } |
|
197 |
196 // Pop parameter frame |
198 // Pop parameter frame |
197 if (stylesheet.hasLocalParams() || hasContents()) { |
199 if (stylesheet.hasLocalParams() || hasContents()) { |
198 il.append(classGen.loadTranslet()); |
200 il.append(classGen.loadTranslet()); |
199 final int popFrame = cpg.addMethodref(TRANSLET_CLASS, |
201 final int popFrame = cpg.addMethodref(TRANSLET_CLASS, |
200 POP_PARAM_FRAME, |
202 POP_PARAM_FRAME, |