ytalwar 2005/02/09 14:45:15
Modified: java/src/org/apache/xalan/xsltc/compiler/util
ClassGenerator.java
java/src/org/apache/xalan/xsltc/compiler Mode.java
ApplyImports.java
Log:
Fix for XALANJ-1417
position() method when template is imported.
Revision Changes Path
1.9 +15 -3
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ClassGenerator.java
Index: ClassGenerator.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ClassGenerator.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ClassGenerator.java 15 Dec 2004 17:35:40 -0000 1.8
+++ ClassGenerator.java 9 Feb 2005 22:45:15 -0000 1.9
@@ -52,7 +52,8 @@
private final String _domClass;
private final String _domClassSig;
private final String _applyTemplatesSig;
-
+ private final String _applyTemplatesSigForImport;
+
public ClassGenerator(String class_name, String super_class_name,
String file_name,
int access_flags, String[] interfaces,
@@ -75,7 +76,14 @@
+ Constants.DOM_INTF_SIG
+ Constants.NODE_ITERATOR_SIG
+ Constants.TRANSLET_OUTPUT_SIG
- + ")V";
+ + ")V";
+
+ _applyTemplatesSigForImport = "("
+ + Constants.DOM_INTF_SIG
+ + Constants.NODE_ITERATOR_SIG
+ + Constants.TRANSLET_OUTPUT_SIG
+ + Constants.NODE_FIELD_SIG
+ + ")V";
}
public final Parser getParser() {
@@ -109,6 +117,10 @@
public final String getApplyTemplatesSig() {
return _applyTemplatesSig;
}
+
+ public final String getApplyTemplatesSigForImport() {
+ return _applyTemplatesSigForImport;
+ }
/**
* Returns <tt>true</tt> or <tt>false</tt> depending on whether
1.35 +9 -18
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Mode.java
Index: Mode.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Mode.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- Mode.java 15 Dec 2004 17:35:38 -0000 1.34
+++ Mode.java 9 Feb 2005 22:45:15 -0000 1.35
@@ -1126,15 +1126,17 @@
// Create the applyTemplates() method
final org.apache.bcel.generic.Type[] argTypes =
- new org.apache.bcel.generic.Type[3];
+ new org.apache.bcel.generic.Type[4];
argTypes[0] = Util.getJCRefType(DOM_INTF_SIG);
argTypes[1] = Util.getJCRefType(NODE_ITERATOR_SIG);
argTypes[2] = Util.getJCRefType(TRANSLET_OUTPUT_SIG);
+ argTypes[3] = org.apache.bcel.generic.Type.INT;
- final String[] argNames = new String[3];
+ final String[] argNames = new String[4];
argNames[0] = DOCUMENT_PNAME;
argNames[1] = ITERATOR_PNAME;
argNames[2] = TRANSLET_OUTPUT_PNAME;
+ argNames[3] = NODE_PNAME;
final InstructionList mainIL = new InstructionList();
final MethodGenerator methodGen =
@@ -1152,6 +1154,9 @@
mainIL.getEnd());
_currentIndex = current.getIndex();
+ mainIL.append(new ILOAD(methodGen.getLocalIndex(NODE_PNAME)));
+ mainIL.append(new ISTORE(_currentIndex));
+
// Create the "body" instruction list that will eventually hold the
// code for the entire method (other ILs will be appended).
final InstructionList body = new InstructionList();
@@ -1160,16 +1165,7 @@
// Create an instruction list that contains the default next-node
// iteration
final InstructionList ilLoop = new InstructionList();
- ilLoop.append(methodGen.loadIterator());
- ilLoop.append(methodGen.nextNode());
- ilLoop.append(DUP);
- ilLoop.append(new ISTORE(_currentIndex));
-
- // The body of this code can get very large - large than can be handled
- // by a single IFNE(body.getStart()) instruction - need workaround:
- final BranchHandle ifeq = ilLoop.append(new IFLT(null));
- final BranchHandle loop = ilLoop.append(new GOTO_W(null));
- ifeq.setTarget(ilLoop.append(RETURN)); // applyTemplates() ends here!
+ ilLoop.append(RETURN);
final InstructionHandle ihLoop = ilLoop.getStart();
// Compile default handling of elements (traverse children)
@@ -1216,12 +1212,8 @@
// Do tests for id() and key() patterns first
InstructionList ilKey = null;
if (_idxTestSeq != null) {
- loop.setTarget(_idxTestSeq.compile(classGen, methodGen,
body.getStart()));
ilKey = _idxTestSeq.getInstructionList();
}
- else {
- loop.setTarget(body.getStart());
- }
// If there is a match on node() we need to replace ihElem
// and ihText if the priority of node() is higher
@@ -1412,7 +1404,6 @@
body.append(ilText);
// putting together constituent instruction lists
- mainIL.append(new GOTO_W(ihLoop));
mainIL.append(body);
// fall through to ilLoop
mainIL.append(ilLoop);
1.15 +4 -10
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ApplyImports.java
Index: ApplyImports.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ApplyImports.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ApplyImports.java 10 Apr 2004 19:00:44 -0000 1.14
+++ ApplyImports.java 9 Feb 2005 22:45:15 -0000 1.15
@@ -112,15 +112,9 @@
// Push the arguments that are passed to applyTemplates()
il.append(classGen.loadTranslet());
il.append(methodGen.loadDOM());
- // Wrap the current node inside an iterator
- int init = cpg.addMethodref(SINGLETON_ITERATOR,
- "<init>", "("+NODE_SIG+")V");
- il.append(new NEW(cpg.addClass(SINGLETON_ITERATOR)));
- il.append(DUP);
- il.append(methodGen.loadCurrentNode());
- il.append(new INVOKESPECIAL(init));
-
+ il.append(methodGen.loadIterator());
il.append(methodGen.loadHandler());
+ il.append(methodGen.loadCurrentNode());
// Push a new parameter frame in case imported template might expect
// parameters. The apply-imports has nothing that it can pass.
@@ -144,7 +138,7 @@
// Construct the translet class-name and the signature of the method
final String className = classGen.getStylesheet().getClassName();
- final String signature = classGen.getApplyTemplatesSig();
+ final String signature = classGen.getApplyTemplatesSigForImport();
final int applyTemplates = cpg.addMethodref(className,
functionName,
signature);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]