You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mo...@apache.org on 2001/06/28 17:36:50 UTC
cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util MethodGenerator.java NodeSortRecordGenerator.java ResultTreeType.java TestGenerator.java
morten 01/06/28 08:36:48
Modified: java/src/org/apache/xalan/xsltc/compiler Predicate.java
Step.java Stylesheet.java VariableRef.java
java/src/org/apache/xalan/xsltc/compiler/util
MethodGenerator.java NodeSortRecordGenerator.java
ResultTreeType.java TestGenerator.java
Log:
Various bugfixes in the way auxiliary classes access variables/fields in
the main translet class. Fixes a few VAR tests and customer tests.
Pmorten@xml.apache.orgR:
Revision Changes Path
1.5 +8 -5 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Predicate.java
Index: Predicate.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Predicate.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Predicate.java 2001/06/27 14:34:01 1.4
+++ Predicate.java 2001/06/28 15:36:14 1.5
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Predicate.java,v 1.4 2001/06/27 14:34:01 morten Exp $
+ * @(#)$Id: Predicate.java,v 1.5 2001/06/28 15:36:14 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -154,15 +154,16 @@
Type texp = _exp.typeCheck(stable);
- // We need explicit type information for reference types
+ // We need explicit type information for reference types - no good!
if (texp instanceof ReferenceType) {
throw new TypeCheckError(this);
}
- // Result tree fragments need to be type-casted to a numerical type
- // in cases where they are used in position filters.
+ // A result tree fragment should not be cast directly to a number type,
+ // but rather to a boolean value, and then to a numer (0 or 1).
+ // Ref. section 11.2 of the XSLT 1.0 spec
if (texp instanceof ResultTreeType) {
- _exp = new CastExpr(_exp, Type.String); // Costly!!!!
+ _exp = new CastExpr(_exp, Type.Boolean);
_exp = new CastExpr(_exp, Type.Real);
texp = _exp.typeCheck(stable);
}
@@ -170,6 +171,7 @@
// Numerical types will be converted to a position filter
if (texp instanceof NumberType) {
+ // Cast any numerical types to an integer
if (texp instanceof IntType == false) {
_exp = new CastExpr(_exp, Type.Int);
}
@@ -207,6 +209,7 @@
return _type = Type.NodeSet;
}
}
+ // All other types will be handled as boolean values
else if (texp instanceof BooleanType == false) {
_exp = new CastExpr(_exp, Type.Boolean);
}
1.4 +5 -1 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Step.java
Index: Step.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Step.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Step.java 2001/06/17 12:23:31 1.3
+++ Step.java 2001/06/28 15:36:17 1.4
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Step.java,v 1.3 2001/06/17 12:23:31 curcuru Exp $
+ * @(#)$Id: Step.java,v 1.4 2001/06/28 15:36:17 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -390,6 +390,10 @@
il.append(methodGen.loadCurrentNode());
il.append(classGen.loadTranslet());
+ if (classGen.isExternal()) {
+ final String className = classGen.getClassName();
+ il.append(new CHECKCAST(cpg.addClass(className)));
+ }
il.append(new INVOKESPECIAL(initCNLI));
}
}
1.9 +2 -2 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Stylesheet.java
Index: Stylesheet.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Stylesheet.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Stylesheet.java 2001/06/11 12:03:34 1.8
+++ Stylesheet.java 2001/06/28 15:36:19 1.9
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: Stylesheet.java,v 1.8 2001/06/11 12:03:34 morten Exp $
+ * @(#)$Id: Stylesheet.java,v 1.9 2001/06/28 15:36:19 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -608,7 +608,7 @@
if (classGen.containsMethod("stripSpace",
"(Lorg/apache/xalan/xsltc/DOM;II)Z") != null) {
il.append(toplevel.loadDOM());
- il.append(new ALOAD(0));
+ il.append(classGen.loadTranslet());
il.append(new INVOKEVIRTUAL(setFilter));
}
1.2 +27 -33 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/VariableRef.java
Index: VariableRef.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/VariableRef.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- VariableRef.java 2001/04/17 18:51:51 1.1
+++ VariableRef.java 2001/06/28 15:36:21 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: VariableRef.java,v 1.1 2001/04/17 18:51:51 sboag Exp $
+ * @(#)$Id: VariableRef.java,v 1.2 2001/06/28 15:36:21 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -119,45 +119,39 @@
final Type varType = _variable.getType();
final String varName = _variable.getName().getLocalPart();
+ if (varType.implementedAsMethod()) {
+ // Fall-through for variables that are implemented as methods
+ return;
+ }
+
if (_variable.isLocal()) {
- if (varType.implementedAsMethod() == false) {
- if (classGen.isExternal() || _escaped) {
- il.append(classGen.loadTranslet());
- il.append(new PUSH(cpg, _variable.getStackIndex()));
- final int getVar = cpg.addMethodref(TRANSLET_CLASS,
- GET_VARIABLE,
- GET_VARIABLE_SIG);
- il.append(new INVOKEVIRTUAL(getVar));
- _type.translateUnBox(classGen, methodGen);
- }
- else {
- il.append(_variable.loadInstruction());
- _variable.removeReference(this, methodGen);
- }
+ if (classGen.isExternal() || _escaped) {
+ il.append(classGen.loadTranslet());
+ il.append(new PUSH(cpg, _variable.getStackIndex()));
+ final int getVar = cpg.addMethodref(TRANSLET_CLASS,
+ GET_VARIABLE,
+ GET_VARIABLE_SIG);
+ il.append(new INVOKEVIRTUAL(getVar));
+ _type.translateUnBox(classGen, methodGen);
}
else {
- // falls through -> result trees + variables
+ il.append(_variable.loadInstruction());
+ _variable.removeReference(this, methodGen);
}
}
else {
- if (varType.implementedAsMethod() == false) {
- final String className = classGen.getClassName();
- String signature = varType.toSignature();
- if (signature.equals(DOM_IMPL_SIG))
- signature = classGen.getDOMClassSig();
-
- il.append(classGen.loadTranslet());
-
- // If inside a predicate we must cast this ref down
- if (classGen.isExternal()) {
- il.append(new CHECKCAST(cpg.addClass(className)));
- }
- il.append(new GETFIELD(cpg.addFieldref(className,
- varName, signature)));
- }
- else {
- // falls through -> result trees + variables
+ final String className = classGen.getClassName();
+ String signature = varType.toSignature();
+ if (signature.equals(DOM_IMPL_SIG))
+ signature = classGen.getDOMClassSig();
+ il.append(classGen.loadTranslet());
+
+ // If inside a predicate we must cast this ref down
+ if (classGen.isExternal()) {
+ il.append(new CHECKCAST(cpg.addClass(className)));
}
+ il.append(new GETFIELD(cpg.addFieldref(className,
+ varName, signature)));
}
}
}
1.3 +5 -1 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/MethodGenerator.java
Index: MethodGenerator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/MethodGenerator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MethodGenerator.java 2001/05/21 15:12:51 1.2
+++ MethodGenerator.java 2001/06/28 15:36:31 1.3
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: MethodGenerator.java,v 1.2 2001/05/21 15:12:51 morten Exp $
+ * @(#)$Id: MethodGenerator.java,v 1.3 2001/06/28 15:36:31 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -324,6 +324,10 @@
/** by default context node is the same as current node. MK437 */
public Instruction loadContextNode() {
return loadCurrentNode();
+ }
+
+ public Instruction storeContextNode() {
+ return storeCurrentNode();
}
public int getLocalIndex(String name) {
1.2 +3 -2 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/NodeSortRecordGenerator.java
Index: NodeSortRecordGenerator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/NodeSortRecordGenerator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NodeSortRecordGenerator.java 2001/04/17 18:52:18 1.1
+++ NodeSortRecordGenerator.java 2001/06/28 15:36:33 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: NodeSortRecordGenerator.java,v 1.1 2001/04/17 18:52:18 sboag Exp $
+ * @(#)$Id: NodeSortRecordGenerator.java,v 1.2 2001/06/28 15:36:33 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -87,7 +87,7 @@
* The index of the translet pointer within the execution of
* the test method.
*/
- public Instruction aloadTranslet() {
+ public Instruction loadTranslet() {
return _aloadTranslet;
}
@@ -98,4 +98,5 @@
public boolean isExternal() {
return true;
}
+
}
1.4 +10 -10 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ResultTreeType.java
Index: ResultTreeType.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ResultTreeType.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ResultTreeType.java 2001/06/17 12:23:35 1.3
+++ ResultTreeType.java 2001/06/28 15:36:35 1.4
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: ResultTreeType.java,v 1.3 2001/06/17 12:23:35 curcuru Exp $
+ * @(#)$Id: ResultTreeType.java,v 1.4 2001/06/28 15:36:35 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -173,12 +173,16 @@
if (classGen.isExternal()) {
il.append(new CHECKCAST(cpg.addClass(className)));
}
-
- //il.append(methodGen.loadDOM());
+ il.append(DUP);
+ /*
il.append(classGen.loadTranslet());
+ if (classGen.isExternal()) {
+ il.append(new CHECKCAST(cpg.addClass(className)));
+ }
+ */
il.append(new GETFIELD(cpg.addFieldref(className, "_dom",
classGen.getDOMClassSig())));
-
+
// Create a new instance of a StringValueHandler
int index = cpg.addMethodref(STRING_VALUE_HANDLER, "<init>", "()V");
il.append(new NEW(cpg.addClass(STRING_VALUE_HANDLER)));
@@ -194,12 +198,8 @@
il.append(new ASTORE(handler.getIndex()));
// Call the method that implements this result tree
- index = cpg.addMethodref(className,
- _methodName,
- "("
- + DOM_CLASS_SIG
- + TRANSLET_OUTPUT_SIG
- +")V");
+ index = cpg.addMethodref(className, _methodName,
+ "("+ DOM_CLASS_SIG+ TRANSLET_OUTPUT_SIG+")V");
il.append(new INVOKEVIRTUAL(index));
// Restore new handler and call getValue()
1.2 +7 -1 xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/TestGenerator.java
Index: TestGenerator.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/TestGenerator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestGenerator.java 2001/04/17 18:52:21 1.1
+++ TestGenerator.java 2001/06/28 15:36:39 1.2
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: TestGenerator.java,v 1.1 2001/04/17 18:52:21 sboag Exp $
+ * @(#)$Id: TestGenerator.java,v 1.2 2001/06/28 15:36:39 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -77,6 +77,7 @@
private final Instruction _iloadCurrent;
private final Instruction _iloadContext;
private final Instruction _istoreCurrent;
+ private final Instruction _istoreContext;
private final Instruction _astoreIterator;
private final Instruction _aloadIterator;
@@ -90,6 +91,7 @@
_iloadCurrent = new ILOAD(CURRENT_NODE_INDEX);
_istoreCurrent = new ISTORE(CURRENT_NODE_INDEX);
_iloadContext = new ILOAD(CONTEXT_NODE_INDEX);
+ _istoreContext = new ILOAD(CONTEXT_NODE_INDEX);
_astoreIterator = new ASTORE(ITERATOR_INDEX);
_aloadIterator = new ALOAD(ITERATOR_INDEX);
}
@@ -117,6 +119,10 @@
/** by default context node is the same as current node. MK437 */
public Instruction loadContextNode() {
return _iloadContext;
+ }
+
+ public Instruction storeContextNode() {
+ return _istoreContext;
}
public Instruction storeCurrentNode() {
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org