jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/WithParam.java
author joehw
Wed, 09 Mar 2016 16:09:55 -0800
changeset 36486 b84e564d2358
parent 25868 686eef1e7a79
child 42801 b6efd9c4f416
permissions -rw-r--r--
8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees Reviewed-by: joehw Contributed-by: christoph.langer@sap.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
36486
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     5
 * Copyright 2001-2004 The Apache Software Foundation.
7f561c08de6b Initial load
duke
parents:
diff changeset
     6
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
     7
 * Licensed under the Apache License, Version 2.0 (the "License");
7f561c08de6b Initial load
duke
parents:
diff changeset
     8
 * you may not use this file except in compliance with the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
     9
 * You may obtain a copy of the License at
7f561c08de6b Initial load
duke
parents:
diff changeset
    10
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    11
 *     http://www.apache.org/licenses/LICENSE-2.0
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    13
 * Unless required by applicable law or agreed to in writing, software
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 * distributed under the License is distributed on an "AS IS" BASIS,
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 * See the License for the specific language governing permissions and
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
 * limitations under the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
package com.sun.org.apache.xalan.internal.xsltc.compiler;
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
36486
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
    22
import com.sun.org.apache.bcel.internal.generic.ALOAD;
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
    23
import com.sun.org.apache.bcel.internal.generic.ASTORE;
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
    24
import com.sun.org.apache.bcel.internal.generic.CHECKCAST;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
36486
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
    26
import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
import com.sun.org.apache.bcel.internal.generic.InstructionList;
36486
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
    29
import com.sun.org.apache.bcel.internal.generic.LocalVariableGen;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
import com.sun.org.apache.bcel.internal.generic.PUSH;
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType;
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
import com.sun.org.apache.xml.internal.utils.XML11Char;
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
 * @author Jacek Ambroziak
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
 * @author Santiago Pericas-Geertsen
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
 * @author Morten Jorgensen
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
 * @author John Howard <JohnH@schemasoft.com>
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
final class WithParam extends Instruction {
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
     * Parameter's name.
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    51
    private QName _name;
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
7f561c08de6b Initial load
duke
parents:
diff changeset
    53
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    54
     * The escaped qname of the with-param.
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
    protected String _escapedName;
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
     * Parameter's default value.
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
    private Expression _select;
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
    /**
36486
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
    64
     * Reference to JVM variable holding temporary result tree.
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
    65
     */
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
    66
    private LocalVariableGen _domAdapter;
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
    67
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
    68
    /**
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
     * %OPT% This is set to true when the WithParam is used in a CallTemplate
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
     * for a simple named template. If this is true, the parameters are
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
     * passed to the named template through method arguments rather than
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
     * using the expensive Translet.addParameter() call.
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
    private boolean _doParameterOptimization = false;
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
     * Displays the contents of this element
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
    public void display(int indent) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
        indent(indent);
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
        Util.println("with-param " + _name);
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
        if (_select != null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
            indent(indent + IndentIncrement);
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
            Util.println("select " + _select.toString());
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
        displayContents(indent + IndentIncrement);
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
     * Returns the escaped qname of the parameter
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
    public String getEscapedName() {
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
        return _escapedName;
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
     * Return the name of this WithParam.
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
    public QName getName() {
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
        return _name;
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
     * Set the name of the variable or paremeter. Escape all special chars.
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
    public void setName(QName name) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
        _name = name;
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
        _escapedName = Util.escape(name.getStringRep());
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
     * Set the do parameter optimization flag
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
    public void setDoParameterOptimization(boolean flag) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
        _doParameterOptimization = flag;
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
     * The contents of a <xsl:with-param> elements are either in the element's
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
     * 'select' attribute (this has precedence) or in the element body.
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
    public void parseContents(Parser parser) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
        final String name = getAttribute("name");
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
        if (name.length() > 0) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
            if (!XML11Char.isXML11ValidQName(name)) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
                ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, name,
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
                                            this);
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
                parser.reportError(Constants.ERROR, err);
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
            setName(parser.getQNameIgnoreDefaultNs(name));
7f561c08de6b Initial load
duke
parents:
diff changeset
   131
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   132
        else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   133
            reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name");
7f561c08de6b Initial load
duke
parents:
diff changeset
   134
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   135
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
        final String select = getAttribute("select");
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
        if (select.length() > 0) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   138
            _select = parser.parseExpression(this, "select", null);
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   140
7f561c08de6b Initial load
duke
parents:
diff changeset
   141
        parseChildren(parser);
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   145
     * Type-check either the select attribute or the element body, depending
7f561c08de6b Initial load
duke
parents:
diff changeset
   146
     * on which is in use.
7f561c08de6b Initial load
duke
parents:
diff changeset
   147
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   148
    public Type typeCheck(SymbolTable stable) throws TypeCheckError {
7f561c08de6b Initial load
duke
parents:
diff changeset
   149
        if (_select != null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   150
            final Type tselect = _select.typeCheck(stable);
7f561c08de6b Initial load
duke
parents:
diff changeset
   151
            if (tselect instanceof ReferenceType == false) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   152
                _select = new CastExpr(_select, Type.Reference);
7f561c08de6b Initial load
duke
parents:
diff changeset
   153
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   154
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   155
        else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
            typeCheckContents(stable);
7f561c08de6b Initial load
duke
parents:
diff changeset
   157
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   158
        return Type.Void;
7f561c08de6b Initial load
duke
parents:
diff changeset
   159
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   160
7f561c08de6b Initial load
duke
parents:
diff changeset
   161
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   162
     * Compile the value of the parameter, which is either in an expression in
7f561c08de6b Initial load
duke
parents:
diff changeset
   163
     * a 'select' attribute, or in the with-param element's body
7f561c08de6b Initial load
duke
parents:
diff changeset
   164
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   165
    public void translateValue(ClassGenerator classGen,
7f561c08de6b Initial load
duke
parents:
diff changeset
   166
                               MethodGenerator methodGen) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   167
        // Compile expression is 'select' attribute if present
7f561c08de6b Initial load
duke
parents:
diff changeset
   168
        if (_select != null) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   169
            _select.translate(classGen, methodGen);
7f561c08de6b Initial load
duke
parents:
diff changeset
   170
            _select.startIterator(classGen, methodGen);
7f561c08de6b Initial load
duke
parents:
diff changeset
   171
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   172
        // If not, compile result tree from parameter body if present.
36486
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   173
        // Store result tree into local variable for releasing it later
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   174
        else if (hasContents()) {
36486
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   175
            final InstructionList il = methodGen.getInstructionList();
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   176
            compileResultTree(classGen, methodGen);
36486
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   177
            _domAdapter = methodGen.addLocalVariable2("@" + _escapedName, Type.ResultTree.toJCType(), il.getEnd());
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   178
            il.append(DUP);
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   179
            il.append(new ASTORE(_domAdapter.getIndex()));
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   180
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   181
        // If neither are present then store empty string in parameter slot
7f561c08de6b Initial load
duke
parents:
diff changeset
   182
        else {
7f561c08de6b Initial load
duke
parents:
diff changeset
   183
            final ConstantPoolGen cpg = classGen.getConstantPool();
7f561c08de6b Initial load
duke
parents:
diff changeset
   184
            final InstructionList il = methodGen.getInstructionList();
7f561c08de6b Initial load
duke
parents:
diff changeset
   185
            il.append(new PUSH(cpg, Constants.EMPTYSTRING));
7f561c08de6b Initial load
duke
parents:
diff changeset
   186
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   187
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   188
7f561c08de6b Initial load
duke
parents:
diff changeset
   189
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   190
     * This code generates a sequence of bytecodes that call the
7f561c08de6b Initial load
duke
parents:
diff changeset
   191
     * addParameter() method in AbstractTranslet. The method call will add
7f561c08de6b Initial load
duke
parents:
diff changeset
   192
     * (or update) the parameter frame with the new parameter value.
7f561c08de6b Initial load
duke
parents:
diff changeset
   193
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   194
    public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   195
        final ConstantPoolGen cpg = classGen.getConstantPool();
7f561c08de6b Initial load
duke
parents:
diff changeset
   196
        final InstructionList il = methodGen.getInstructionList();
7f561c08de6b Initial load
duke
parents:
diff changeset
   197
7f561c08de6b Initial load
duke
parents:
diff changeset
   198
        // Translate the value and put it on the stack
7f561c08de6b Initial load
duke
parents:
diff changeset
   199
        if (_doParameterOptimization) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   200
            translateValue(classGen, methodGen);
7f561c08de6b Initial load
duke
parents:
diff changeset
   201
            return;
7f561c08de6b Initial load
duke
parents:
diff changeset
   202
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   203
7f561c08de6b Initial load
duke
parents:
diff changeset
   204
        // Make name acceptable for use as field name in class
7f561c08de6b Initial load
duke
parents:
diff changeset
   205
        String name = Util.escape(getEscapedName());
7f561c08de6b Initial load
duke
parents:
diff changeset
   206
7f561c08de6b Initial load
duke
parents:
diff changeset
   207
        // Load reference to the translet (method is in AbstractTranslet)
7f561c08de6b Initial load
duke
parents:
diff changeset
   208
        il.append(classGen.loadTranslet());
7f561c08de6b Initial load
duke
parents:
diff changeset
   209
7f561c08de6b Initial load
duke
parents:
diff changeset
   210
        // Load the name of the parameter
7f561c08de6b Initial load
duke
parents:
diff changeset
   211
        il.append(new PUSH(cpg, name)); // TODO: namespace ?
7f561c08de6b Initial load
duke
parents:
diff changeset
   212
        // Generete the value of the parameter (use value in 'select' by def.)
7f561c08de6b Initial load
duke
parents:
diff changeset
   213
        translateValue(classGen, methodGen);
7f561c08de6b Initial load
duke
parents:
diff changeset
   214
        // Mark this parameter value is not being the default value
7f561c08de6b Initial load
duke
parents:
diff changeset
   215
        il.append(new PUSH(cpg, false));
7f561c08de6b Initial load
duke
parents:
diff changeset
   216
        // Pass the parameter to the template
7f561c08de6b Initial load
duke
parents:
diff changeset
   217
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
7f561c08de6b Initial load
duke
parents:
diff changeset
   218
                                                     ADD_PARAMETER,
7f561c08de6b Initial load
duke
parents:
diff changeset
   219
                                                     ADD_PARAMETER_SIG)));
7f561c08de6b Initial load
duke
parents:
diff changeset
   220
        il.append(POP); // cleanup stack
7f561c08de6b Initial load
duke
parents:
diff changeset
   221
    }
36486
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   222
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   223
    /**
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   224
     * Release the compiled result tree.
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   225
     */
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   226
    public void releaseResultTree(ClassGenerator classGen, MethodGenerator methodGen) {
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   227
        if (_domAdapter != null) {
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   228
            final ConstantPoolGen cpg = classGen.getConstantPool();
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   229
            final InstructionList il = methodGen.getInstructionList();
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   230
            if (classGen.getStylesheet().callsNodeset() && classGen.getDOMClass().equals(MULTI_DOM_CLASS)) {
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   231
                final int removeDA = cpg.addMethodref(MULTI_DOM_CLASS, "removeDOMAdapter", "(" + DOM_ADAPTER_SIG + ")V");
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   232
                il.append(methodGen.loadDOM());
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   233
                il.append(new CHECKCAST(cpg.addClass(MULTI_DOM_CLASS)));
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   234
                il.append(new ALOAD(_domAdapter.getIndex()));
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   235
                il.append(new CHECKCAST(cpg.addClass(DOM_ADAPTER_CLASS)));
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   236
                il.append(new INVOKEVIRTUAL(removeDA));
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   237
            }
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   238
            final int release = cpg.addInterfaceMethodref(DOM_IMPL_CLASS, "release", "()V");
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   239
            il.append(new ALOAD(_domAdapter.getIndex()));
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   240
            il.append(new INVOKEINTERFACE(release, 1));
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   241
            _domAdapter = null;
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   242
         }
b84e564d2358 8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents: 25868
diff changeset
   243
     }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   244
}