< prev index next >

jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java

Print this page

        

*** 1,8 **** /* ! * reserved comment block ! * DO NOT REMOVE OR ALTER! */ /* * Copyright 2001-2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); --- 1,7 ---- /* ! * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. */ /* * Copyright 2001-2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License");
*** 15,36 **** * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ - /* - * $Id: CallTemplate.java,v 1.2.4.1 2005/09/12 10:02:41 pvedula Exp $ - */ package com.sun.org.apache.xalan.internal.xsltc.compiler; - import com.sun.org.apache.bcel.internal.generic.ALOAD; - import com.sun.org.apache.bcel.internal.generic.ASTORE; import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen; import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL; import com.sun.org.apache.bcel.internal.generic.InstructionList; - import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; --- 14,29 ----
*** 54,64 **** /** * The array of effective parameters in this CallTemplate. An object in * this array can be either a WithParam or a Param if no WithParam * exists for a particular parameter. */ ! private Object[] _parameters = null; /** * The corresponding template which this CallTemplate calls. */ private Template _calleeTemplate = null; --- 47,57 ---- /** * The array of effective parameters in this CallTemplate. An object in * this array can be either a WithParam or a Param if no WithParam * exists for a particular parameter. */ ! private SyntaxTreeNode[] _parameters = null; /** * The corresponding template which this CallTemplate calls. */ private Template _calleeTemplate = null;
*** 145,159 **** StringBuffer methodSig = new StringBuffer("(" + DOM_INTF_SIG + NODE_ITERATOR_SIG + TRANSLET_OUTPUT_SIG + NODE_SIG); // If calling a simply named template, push actual arguments if (_calleeTemplate != null) { - Vector calleeParams = _calleeTemplate.getParameters(); int numParams = _parameters.length; for (int i = 0; i < numParams; i++) { ! SyntaxTreeNode node = (SyntaxTreeNode)_parameters[i]; methodSig.append(OBJECT_SIG); // append Object to signature // Push 'null' if Param to indicate no actual parameter specified if (node instanceof Param) { il.append(ACONST_NULL); --- 138,151 ---- StringBuffer methodSig = new StringBuffer("(" + DOM_INTF_SIG + NODE_ITERATOR_SIG + TRANSLET_OUTPUT_SIG + NODE_SIG); // If calling a simply named template, push actual arguments if (_calleeTemplate != null) { int numParams = _parameters.length; for (int i = 0; i < numParams; i++) { ! SyntaxTreeNode node = _parameters[i]; methodSig.append(OBJECT_SIG); // append Object to signature // Push 'null' if Param to indicate no actual parameter specified if (node instanceof Param) { il.append(ACONST_NULL);
*** 168,177 **** --- 160,178 ---- methodSig.append(")V"); il.append(new INVOKEVIRTUAL(cpg.addMethodref(className, methodName, methodSig.toString()))); + // release temporary result trees + if (_parameters != null) { + for (int i = 0; i < _parameters.length; i++) { + if (_parameters[i] instanceof WithParam) { + ((WithParam)_parameters[i]).releaseResultTree(classGen, methodGen); + } + } + } + // Do not need to call Translet.popParamFrame() if we are // calling a simple named template. if (_calleeTemplate == null && (stylesheet.hasLocalParams() || hasContents())) { // Pop parameter frame final int pop = cpg.addMethodref(TRANSLET_CLASS,
*** 201,213 **** * the Param with a corresponding WithParam having the same name. */ private void buildParameterList() { // Put the parameters from the called template into the array first. // This is to ensure the order of the parameters. ! Vector defaultParams = _calleeTemplate.getParameters(); int numParams = defaultParams.size(); ! _parameters = new Object[numParams]; for (int i = 0; i < numParams; i++) { _parameters[i] = defaultParams.elementAt(i); } // Replace a Param with a WithParam if they have the same name. --- 202,214 ---- * the Param with a corresponding WithParam having the same name. */ private void buildParameterList() { // Put the parameters from the called template into the array first. // This is to ensure the order of the parameters. ! Vector<Param> defaultParams = _calleeTemplate.getParameters(); int numParams = defaultParams.size(); ! _parameters = new SyntaxTreeNode[numParams]; for (int i = 0; i < numParams; i++) { _parameters[i] = defaultParams.elementAt(i); } // Replace a Param with a WithParam if they have the same name.
*** 220,238 **** WithParam withParam = (WithParam)node; QName name = withParam.getName(); // Search for a Param with the same name for (int k = 0; k < numParams; k++) { ! Object object = _parameters[k]; ! if (object instanceof Param ! && ((Param)object).getName().equals(name)) { withParam.setDoParameterOptimization(true); _parameters[k] = withParam; break; } ! else if (object instanceof WithParam ! && ((WithParam)object).getName().equals(name)) { withParam.setDoParameterOptimization(true); _parameters[k] = withParam; break; } } --- 221,239 ---- WithParam withParam = (WithParam)node; QName name = withParam.getName(); // Search for a Param with the same name for (int k = 0; k < numParams; k++) { ! SyntaxTreeNode parm = _parameters[k]; ! if (parm instanceof Param ! && ((Param)parm).getName().equals(name)) { withParam.setDoParameterOptimization(true); _parameters[k] = withParam; break; } ! else if (parm instanceof WithParam ! && ((WithParam)parm).getName().equals(name)) { withParam.setDoParameterOptimization(true); _parameters[k] = withParam; break; } }
< prev index next >