< prev index next >
jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/VariableBase.java
Print this page
@@ -1,8 +1,7 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * 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,29 +14,30 @@
* 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: VariableBase.java,v 1.5 2005/09/28 13:48:18 pvedula Exp $
- */
package com.sun.org.apache.xalan.internal.xsltc.compiler;
import java.util.Vector;
+import com.sun.org.apache.bcel.internal.generic.CHECKCAST;
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
import com.sun.org.apache.bcel.internal.generic.Instruction;
import com.sun.org.apache.bcel.internal.generic.InstructionList;
+import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE;
import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL;
+import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
import com.sun.org.apache.bcel.internal.generic.LocalVariableGen;
import com.sun.org.apache.bcel.internal.generic.NEW;
import com.sun.org.apache.bcel.internal.generic.PUSH;
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.NodeSetType;
+import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
import com.sun.org.apache.xml.internal.utils.XML11Char;
/**
@@ -58,14 +58,11 @@
protected Instruction _storeInstruction; // Instruction to load JVM variable
protected Expression _select; // Reference to variable expression
protected String select; // Textual repr. of variable expr.
// References to this variable (when local)
- protected Vector _refs = new Vector(2);
-
- // Dependencies to other variables/parameters (for globals only)
- protected Vector _dependencies = null;
+ protected Vector<VariableRefBase> _refs = new Vector<>(2);
// Used to make sure parameter field is not added twice
protected boolean _ignore = false;
/**
@@ -90,11 +87,11 @@
* purpose.
*/
public void copyReferences(VariableBase var) {
final int size = _refs.size();
for (int i = 0; i < size; i++) {
- var.addReference((VariableRefBase) _refs.get(i));
+ var.addReference(_refs.get(i));
}
}
/**
* Map this variable to a register
@@ -110,12 +107,28 @@
/**
* Remove the mapping of this variable to a register.
* Called when we leave the AST scope of the variable's declaration
*/
- public void unmapRegister(MethodGenerator methodGen) {
+ public void unmapRegister(ClassGenerator classGen, MethodGenerator methodGen) {
if (_local != null) {
+ if (_type instanceof ResultTreeType) {
+ final ConstantPoolGen cpg = classGen.getConstantPool();
+ final InstructionList il = methodGen.getInstructionList();
+ if (classGen.getStylesheet().callsNodeset() && classGen.getDOMClass().equals(MULTI_DOM_CLASS)) {
+ final int removeDA = cpg.addMethodref(MULTI_DOM_CLASS, "removeDOMAdapter", "(" + DOM_ADAPTER_SIG + ")V");
+ il.append(methodGen.loadDOM());
+ il.append(new CHECKCAST(cpg.addClass(MULTI_DOM_CLASS)));
+ il.append(loadInstruction());
+ il.append(new CHECKCAST(cpg.addClass(DOM_ADAPTER_CLASS)));
+ il.append(new INVOKEVIRTUAL(removeDA));
+ }
+ final int release = cpg.addInterfaceMethodref(DOM_IMPL_CLASS, "release", "()V");
+ il.append(loadInstruction());
+ il.append(new INVOKEINTERFACE(release, 1));
+ }
+
_local.setEnd(methodGen.getInstructionList().getEnd());
methodGen.removeLocalVariable(_local);
_refs = null;
_local = null;
}
@@ -124,11 +137,10 @@
/**
* Returns an instruction for loading the value of this variable onto
* the JVM stack.
*/
public Instruction loadInstruction() {
- final Instruction instr = _loadInstruction;
if (_loadInstruction == null) {
_loadInstruction = _type.LOAD(_local.getIndex());
}
return _loadInstruction;
}
@@ -136,11 +148,10 @@
/**
* Returns an instruction for storing a value from the JVM stack
* into this variable.
*/
public Instruction storeInstruction() {
- final Instruction instr = _storeInstruction;
if (_storeInstruction == null) {
_storeInstruction = _type.STORE(_local.getIndex());
}
return _storeInstruction;
}
< prev index next >