santiagopg 2003/01/13 14:02:59
Modified: java/src/org/apache/xalan/xsltc/compiler Tag: xslt20
AbsoluteLocationPath.java AbsolutePathPattern.java
AlternativePattern.java AncestorPattern.java
ApplyImports.java ApplyTemplates.java
Attribute.java AttributeSet.java
AttributeValue.java AttributeValueTemplate.java
BinOpExpr.java CallTemplate.java CastExpr.java
Choose.java Comment.java Copy.java CopyOf.java
DecimalFormatting.java EqualityExpr.java
Fallback.java FilterExpr.java FilterParentPath.java
FilteredAbsoluteLocationPath.java ForEach.java
ForwardPositionExpr.java FunctionCall.java If.java
Import.java Include.java Key.java
LiteralAttribute.java LiteralElement.java
LogicalExpr.java Message.java NamespaceAlias.java
Number.java Otherwise.java Output.java Param.java
ParentLocationPath.java ParentPattern.java
Parser.java Predicate.java
ProcessingInstruction.java RelationalExpr.java
Sort.java Step.java StepPattern.java
Stylesheet.java SyntaxTreeNode.java Template.java
Text.java TopLevelElement.java TransletOutput.java
UnaryOpExpr.java UnionPathExpr.java
UnsupportedElement.java UseAttributeSets.java
ValueOf.java Variable.java VariableBase.java
When.java Whitespace.java WithParam.java XSLTC.java
XslAttribute.java XslElement.java
java/src/org/apache/xalan/xsltc/compiler/xpath Tag: xslt20
XPathParser.java
Added: java/src/org/apache/xalan/xsltc/compiler Tag: xslt20
CompilerContext.java CompilerContextImpl.java
StaticContext.java StaticContextImpl.java
Log:
A number of global changes in preparation for the implementation of
the 2.0 specs. Definition of a static context and a compiler
context.
Revision Changes Path
No revision
No revision
1.5.8.1.2.1 +6 -13
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AbsoluteLocationPath.java
Index: AbsoluteLocationPath.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AbsoluteLocationPath.java,v
retrieving revision 1.5.8.1
retrieving revision 1.5.8.1.2.1
diff -u -r1.5.8.1 -r1.5.8.1.2.1
--- AbsoluteLocationPath.java 14 Aug 2002 19:21:32 -0000 1.5.8.1
+++ AbsoluteLocationPath.java 13 Jan 2003 22:02:51 -0000 1.5.8.1.2.1
@@ -68,7 +68,7 @@
import org.apache.xalan.xsltc.compiler.util.*;
final class AbsoluteLocationPath extends Expression {
- private Expression _path; // may be null
+ private Expression _path; // may be null
public AbsoluteLocationPath() {
_path = null;
@@ -81,22 +81,15 @@
}
}
- public void setParser(Parser parser) {
- super.setParser(parser);
- if (_path != null) {
- _path.setParser(parser);
- }
- }
-
public Expression getPath() {
return(_path);
}
-
+
public String toString() {
return "AbsoluteLocationPath(" +
(_path != null ? _path.toString() : "null") + ')';
}
-
+
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
if (_path != null) {
final Type ptype = _path.typeCheck(stable);
@@ -104,9 +97,9 @@
_path = new CastExpr(_path, Type.NodeSet);
}
}
- return _type = Type.NodeSet;
+ return _type = Type.NodeSet;
}
-
+
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
1.6.2.1.2.1 +10 -16
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AbsolutePathPattern.java
Index: AbsolutePathPattern.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AbsolutePathPattern.java,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.1.2.1
diff -u -r1.6.2.1 -r1.6.2.1.2.1
--- AbsolutePathPattern.java 14 Aug 2002 19:21:32 -0000 1.6.2.1
+++ AbsolutePathPattern.java 13 Jan 2003 22:02:51 -0000 1.6.2.1.2.1
@@ -80,12 +80,6 @@
}
}
- public void setParser(Parser parser) {
- super.setParser(parser);
- if (_left != null)
- _left.setParser(parser);
- }
-
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
return _left == null ? Type.Root : _left.typeCheck(stable);
}
@@ -93,24 +87,24 @@
public boolean isWildcard() {
return false;
}
-
+
public StepPattern getKernelPattern() {
return _left != null ? _left.getKernelPattern() : null;
}
-
+
public void reduceKernelPattern() {
_left.reduceKernelPattern();
}
-
+
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
if (_left != null) {
if (_left instanceof StepPattern) {
- final LocalVariableGen local =
+ final LocalVariableGen local =
// absolute path pattern temporary
- methodGen.addLocalVariable2("apptmp",
+ methodGen.addLocalVariable2("apptmp",
Util.getJCRefType(NODE_SIG),
il.getEnd());
il.append(DUP);
@@ -134,20 +128,20 @@
InstructionHandle begin = il.append(methodGen.loadDOM());
il.append(SWAP);
il.append(new INVOKEINTERFACE(getParent, 2));
- if (_left instanceof AncestorPattern) {
+ if (_left instanceof AncestorPattern) {
il.append(methodGen.loadDOM());
il.append(SWAP);
}
il.append(new INVOKEINTERFACE(getType, 2));
il.append(new PUSH(cpg, DOM.ROOT));
-
+
final BranchHandle skip = il.append(new IF_ICMPEQ(null));
_falseList.add(il.append(new GOTO_W(null)));
skip.setTarget(il.append(NOP));
if (_left != null) {
_left.backPatchTrueList(begin);
-
+
/*
* If _left is an ancestor pattern, backpatch this pattern's false
* list to the loop that searches for more ancestors.
@@ -159,7 +153,7 @@
_falseList.append(_left._falseList);
}
}
-
+
public String toString() {
return "absolutePathPattern(" + (_left != null ? _left.toString() :
")");
}
1.2.8.1.2.1 +4 -10
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AlternativePattern.java
Index: AlternativePattern.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AlternativePattern.java,v
retrieving revision 1.2.8.1
retrieving revision 1.2.8.1.2.1
diff -u -r1.2.8.1 -r1.2.8.1.2.1
--- AlternativePattern.java 14 Aug 2002 19:21:32 -0000 1.2.8.1
+++ AlternativePattern.java 13 Jan 2003 22:02:51 -0000 1.2.8.1.2.1
@@ -70,7 +70,7 @@
final class AlternativePattern extends Pattern {
private final Pattern _left;
private final Pattern _right;
-
+
/**
* Construct an alternative pattern. The method <code>setParent</code>
* should not be called in this case.
@@ -79,13 +79,7 @@
_left = left;
_right = right;
}
-
- public void setParser(Parser parser) {
- super.setParser(parser);
- _left.setParser(parser);
- _right.setParser(parser);
- }
-
+
public Pattern getLeft() {
return _left;
}
@@ -106,7 +100,7 @@
public double getPriority() {
double left = _left.getPriority();
double right = _right.getPriority();
-
+
if (left < right)
return(left);
else
1.6.2.1.2.1 +11 -19
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AncestorPattern.java
Index: AncestorPattern.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AncestorPattern.java,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.1.2.1
diff -u -r1.6.2.1 -r1.6.2.1.2.1
--- AncestorPattern.java 14 Aug 2002 19:21:32 -0000 1.6.2.1
+++ AncestorPattern.java 13 Jan 2003 22:02:51 -0000 1.6.2.1.2.1
@@ -73,7 +73,7 @@
private final Pattern _left; // may be null
private final RelativePathPattern _right;
private InstructionHandle _loop;
-
+
public AncestorPattern(RelativePathPattern right) {
this(null, right);
}
@@ -85,24 +85,16 @@
left.setParent(this);
}
}
-
+
public InstructionHandle getLoopHandle() {
return _loop;
}
- public void setParser(Parser parser) {
- super.setParser(parser);
- if (_left != null) {
- _left.setParser(parser);
- }
- _right.setParser(parser);
- }
-
public boolean isWildcard() {
//!!! can be wildcard
return false;
}
-
+
public StepPattern getKernelPattern() {
return _right.getKernelPattern();
}
@@ -110,7 +102,7 @@
public void reduceKernelPattern() {
_right.reduceKernelPattern();
}
-
+
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
if (_left != null) {
_left.typeCheck(stable);
@@ -123,7 +115,7 @@
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- /*
+ /*
* The scope of this local var must be the entire method since
* a another pattern may decide to jump back into the loop
*/
@@ -157,7 +149,7 @@
GET_PARENT,
GET_PARENT_SIG);
parent = il.append(new INVOKEINTERFACE(getParent, 2));
-
+
il.append(DUP);
il.append(storeLocal);
_falseList.add(il.append(new IFEQ(null)));
@@ -167,7 +159,7 @@
final SyntaxTreeNode p = getParent();
if (p == null || p instanceof Instruction ||
- p instanceof TopLevelElement)
+ p instanceof TopLevelElement)
{
// do nothing
}
@@ -183,13 +175,13 @@
exit.setTarget(il.append(NOP));
_left.backPatchFalseList(_loop);
- _trueList.append(_left._trueList);
+ _trueList.append(_left._trueList);
}
else {
il.append(POP2);
}
-
- /*
+
+ /*
* If _right is an ancestor pattern, backpatch this pattern's false
* list to the loop that searches for more ancestors.
*/
1.10.2.1.2.2 +6 -14
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.10.2.1.2.1
retrieving revision 1.10.2.1.2.2
diff -u -r1.10.2.1.2.1 -r1.10.2.1.2.2
--- ApplyImports.java 10 Jan 2003 16:50:38 -0000 1.10.2.1.2.1
+++ ApplyImports.java 13 Jan 2003 22:02:51 -0000 1.10.2.1.2.2
@@ -77,16 +77,6 @@
private String _functionName;
private int _precedence;
- public void display(int indent) {
- indent(indent);
- Util.println("ApplyTemplates");
- indent(indent + IndentIncrement);
- if (_modeName != null) {
- indent(indent + IndentIncrement);
- Util.println("mode " + _modeName);
- }
- }
-
/**
* Returns true if this <xsl:apply-imports/> element has parameters
*/
@@ -132,7 +122,9 @@
/**
* Parse the attributes and contents of an <xsl:apply-imports/> element.
*/
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
+
// Indicate to the top-level stylesheet that all templates must be
// compiled into separate methods.
Stylesheet stylesheet = getStylesheet();
@@ -153,7 +145,7 @@
final Mode mode = stylesheet.getMode(_modeName);
_functionName = mode.functionName(minPrecedence, maxPrecedence);
- parseChildren(parser); // with-params
+ parseContents(ccontext); // with-params
}
/**
@@ -166,7 +158,7 @@
/**
* Translate call-template. A parameter frame is pushed only if
- * some template in the stylesheet uses parameters.
+ * some template in the stylesheet uses parameters.
*/
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
final Stylesheet stylesheet = classGen.getStylesheet();
1.14.2.1.2.3 +11 -22
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ApplyTemplates.java
Index: ApplyTemplates.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ApplyTemplates.java,v
retrieving revision 1.14.2.1.2.2
retrieving revision 1.14.2.1.2.3
diff -u -r1.14.2.1.2.2 -r1.14.2.1.2.3
--- ApplyTemplates.java 10 Jan 2003 16:50:38 -0000 1.14.2.1.2.2
+++ ApplyTemplates.java 13 Jan 2003 22:02:51 -0000 1.14.2.1.2.3
@@ -81,44 +81,33 @@
private Type _type = null;
private QName _modeName;
private String _functionName;
-
- public void display(int indent) {
- indent(indent);
- Util.println("ApplyTemplates");
- indent(indent + IndentIncrement);
- Util.println("select " + _select.toString());
- if (_modeName != null) {
- indent(indent + IndentIncrement);
- Util.println("mode " + _modeName);
- }
- }
public boolean hasWithParams() {
return hasContents();
}
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
final String select = getAttribute("select");
final String mode = getAttribute("mode");
-
+
if (select.length() > 0) {
_select = parser.parseExpression(this, "select", null);
// Wrap _select in a ForwardPositionExpr
final Expression fpe = new ForwardPositionExpr(_select);
_select.setParent(fpe);
- fpe.setParser(_select.getParser());
_select = fpe;
}
-
+
if (mode.length() > 0) {
_modeName = parser.getQNameIgnoreDefaultNs(mode);
}
-
+
// instantiate Mode if needed, cache (apply temp) function name
_functionName =
parser.getTopLevelStylesheet().getMode(_modeName).functionName();
- parseChildren(parser);// with-params
+ parseContents(ccontext);// with-params
}
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
@@ -142,7 +131,7 @@
/**
* Translate call-template. A parameter frame is pushed only if
- * some template in the stylesheet uses parameters.
+ * some template in the stylesheet uses parameters.
*/
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
boolean setStartNodeCalled = false;
@@ -183,7 +172,7 @@
getParser().reportError(WARNING, err);
}
// Put the result tree (a DOM adapter) on the stack
- _select.translate(classGen, methodGen);
+ _select.translate(classGen, methodGen);
// Get back the DOM and iterator (not just iterator!!!)
_type.translateTo(classGen, methodGen, Type.NodeSet);
}
@@ -200,7 +189,7 @@
NODE_ITERATOR_SIG);
il.append(methodGen.loadCurrentNode());
il.append(new INVOKEINTERFACE(setStartNode,2));
- setStartNodeCalled = true;
+ setStartNodeCalled = true;
}
else {
if (_select == null)
@@ -222,7 +211,7 @@
_functionName,
applyTemplatesSig);
il.append(new INVOKEVIRTUAL(applyTemplates));
-
+
// Pop parameter frame
if (stylesheet.hasLocalParams() || hasContents()) {
il.append(classGen.loadTranslet());
1.4.12.1.2.1 +4 -9
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Attribute.java
Index: Attribute.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Attribute.java,v
retrieving revision 1.4.12.1
retrieving revision 1.4.12.1.2.1
diff -u -r1.4.12.1 -r1.4.12.1.2.1
--- Attribute.java 14 Aug 2002 19:21:32 -0000 1.4.12.1
+++ Attribute.java 13 Jan 2003 22:02:51 -0000 1.4.12.1.2.1
@@ -67,16 +67,11 @@
final class Attribute extends Instruction {
private QName _name;
-
- public void display(int indent) {
- indent(indent);
- Util.println("Attribute " + _name);
- displayContents(indent + IndentIncrement);
- }
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
_name = parser.getQName(getAttribute("name"));
- parseChildren(parser);
+ parseContents(ccontext);
//!!! add text nodes
//!!! take care of value templates
}
1.12.2.1.2.3 +8 -7
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AttributeSet.java
Index: AttributeSet.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AttributeSet.java,v
retrieving revision 1.12.2.1.2.2
retrieving revision 1.12.2.1.2.3
diff -u -r1.12.2.1.2.2 -r1.12.2.1.2.3
--- AttributeSet.java 10 Jan 2003 16:50:38 -0000 1.12.2.1.2.2
+++ AttributeSet.java 13 Jan 2003 22:02:51 -0000 1.12.2.1.2.3
@@ -80,14 +80,14 @@
// This prefix is used for the method name of attribute set methods
private static final String AttributeSetPrefix = "$as$";
-
+
// Element contents
private QName _name;
private UseAttributeSets _useSets;
private AttributeSet _mergeSet;
private String _method;
private boolean _ignore = false;
-
+
/**
* Returns the QName of this attribute set
*/
@@ -117,8 +117,9 @@
* Parse the contents of this attribute set. Recognised attributes are
* "name" (required) and "use-attribute-sets" (optional).
*/
- public void parseContents(Parser parser) {
-
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
+
// Get this attribute set's name
_name = parser.getQNameIgnoreDefaultNs(getAttribute("name"));
if ((_name == null) || (_name.equals(EMPTYSTRING))) {
@@ -140,7 +141,7 @@
SyntaxTreeNode child = (SyntaxTreeNode)contents.get(i);
if (child instanceof XslAttribute) {
parser.getSymbolTable().setCurrentNode(child);
- child.parseContents(parser);
+ child.parse(ccontext);
}
else if (child instanceof Text) {
// ignore
@@ -212,7 +213,7 @@
}
final InstructionList il = methodGen.getInstructionList();
il.append(RETURN);
-
+
methodGen.stripAttributes(true);
methodGen.setMaxLocals();
methodGen.setMaxStack();
1.2.2.1.2.1 +1 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AttributeValue.java
Index: AttributeValue.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AttributeValue.java,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.1.2.1
diff -u -r1.2.2.1 -r1.2.2.1.2.1
--- AttributeValue.java 14 Aug 2002 19:21:32 -0000 1.2.2.1
+++ AttributeValue.java 13 Jan 2003 22:02:51 -0000 1.2.2.1.2.1
@@ -78,7 +78,6 @@
}
else {
result = new SimpleAttributeValue(text);
- result.setParser(parser);
result.setParent(parent);
}
return result;
1.6.2.1.2.2 +1 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AttributeValueTemplate.java
Index: AttributeValueTemplate.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AttributeValueTemplate.java,v
retrieving revision 1.6.2.1.2.1
retrieving revision 1.6.2.1.2.2
diff -u -r1.6.2.1.2.1 -r1.6.2.1.2.2
--- AttributeValueTemplate.java 10 Jan 2003 16:50:38 -0000
1.6.2.1.2.1
+++ AttributeValueTemplate.java 13 Jan 2003 22:02:51 -0000
1.6.2.1.2.2
@@ -76,7 +76,6 @@
SyntaxTreeNode parent)
{
setParent(parent);
- setParser(parser);
if (check(value, parser)) {
parseAVTemplate(0, value, parser);
}
1.7.8.1.2.2 +6 -12
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/BinOpExpr.java
Index: BinOpExpr.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/BinOpExpr.java,v
retrieving revision 1.7.8.1.2.1
retrieving revision 1.7.8.1.2.2
diff -u -r1.7.8.1.2.1 -r1.7.8.1.2.2
--- BinOpExpr.java 10 Jan 2003 16:50:38 -0000 1.7.8.1.2.1
+++ BinOpExpr.java 13 Jan 2003 22:02:51 -0000 1.7.8.1.2.2
@@ -73,14 +73,14 @@
public static final int TIMES = 2;
public static final int DIV = 3;
public static final int MOD = 4;
-
+
private static final String[] Ops = {
"+", "-", "*", "/", "%"
};
private int _op;
private Expression _left, _right;
-
+
public BinOpExpr(int op, Expression left, Expression right) {
_op = op;
(_left = left).setParent(this);
@@ -97,18 +97,12 @@
return false;
}
- public void setParser(Parser parser) {
- super.setParser(parser);
- _left.setParser(parser);
- _right.setParser(parser);
- }
-
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
- final Type tleft = _left.typeCheck(stable);
+ final Type tleft = _left.typeCheck(stable);
final Type tright = _right.typeCheck(stable);
final MethodType ptype = lookupPrimop(stable, Ops[_op],
new MethodType(Type.Void,
- tleft, tright));
+ tleft, tright));
if (ptype != null) {
final Type arg1 = (Type) ptype.argsType().get(0);
if (!arg1.identicalTo(tleft)) {
@@ -154,4 +148,4 @@
public String toString() {
return Ops[_op] + '(' + _left + ", " + _right + ')';
}
-}
+}
1.10.2.1.2.1 +8 -14
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CallTemplate.java
Index: CallTemplate.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CallTemplate.java,v
retrieving revision 1.10.2.1
retrieving revision 1.10.2.1.2.1
diff -u -r1.10.2.1 -r1.10.2.1.2.1
--- CallTemplate.java 14 Aug 2002 19:21:32 -0000 1.10.2.1
+++ CallTemplate.java 13 Jan 2003 22:02:51 -0000 1.10.2.1.2.1
@@ -75,22 +75,16 @@
final class CallTemplate extends Instruction {
private QName _name;
- public void display(int indent) {
- indent(indent);
- System.out.print("CallTemplate");
- Util.println(" name " + _name);
- displayContents(indent + IndentIncrement);
- }
-
public boolean hasWithParams() {
return elementCount() > 0;
}
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
_name = parser.getQNameIgnoreDefaultNs(getAttribute("name"));
- parseChildren(parser);
+ parseContents(ccontext);
}
-
+
/**
* Verify that a template with this name exists.
*/
@@ -120,7 +114,7 @@
if (stylesheet.hasLocalParams() || hasContents()) {
// Push parameter frame
- final int push = cpg.addMethodref(TRANSLET_CLASS,
+ final int push = cpg.addMethodref(TRANSLET_CLASS,
PUSH_PARAM_FRAME,
PUSH_PARAM_FRAME_SIG);
il.append(classGen.loadTranslet());
@@ -146,7 +140,7 @@
+ TRANSLET_OUTPUT_SIG
+ NODE_SIG
+")V")));
-
+
if (stylesheet.hasLocalParams() || hasContents()) {
// Pop parameter frame
@@ -157,4 +151,4 @@
il.append(new INVOKEVIRTUAL(pop));
}
}
-}
+}
1.14.2.1.2.3 +1 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CastExpr.java
Index: CastExpr.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CastExpr.java,v
retrieving revision 1.14.2.1.2.2
retrieving revision 1.14.2.1.2.3
diff -u -r1.14.2.1.2.2 -r1.14.2.1.2.3
--- CastExpr.java 10 Jan 2003 16:50:38 -0000 1.14.2.1.2.2
+++ CastExpr.java 13 Jan 2003 22:02:51 -0000 1.14.2.1.2.3
@@ -163,7 +163,6 @@
}
// check if conversion is valid
- setParser(left.getParser());
setParent(left.getParent());
left.setParent(this);
typeCheck(left.getParser().getSymbolTable());
1.6.8.1.2.2 +4 -14
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Choose.java
Index: Choose.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Choose.java,v
retrieving revision 1.6.8.1.2.1
retrieving revision 1.6.8.1.2.2
diff -u -r1.6.8.1.2.1 -r1.6.8.1.2.2
--- Choose.java 10 Jan 2003 16:50:38 -0000 1.6.8.1.2.1
+++ Choose.java 13 Jan 2003 22:02:51 -0000 1.6.8.1.2.2
@@ -74,16 +74,6 @@
final class Choose extends Instruction {
/**
- * Display the element contents (a lot of when's and an otherwise)
- */
- public void display(int indent) {
- indent(indent);
- Util.println("Choose");
- indent(indent + IndentIncrement);
- displayContents(indent + IndentIncrement);
- }
-
- /**
* Translate this Choose element. Generate a test-chain for the various
* <xsl:when> elements and default to the <xsl:otherwise> if present.
*/
@@ -145,7 +135,7 @@
InstructionHandle truec = il.getEnd();
- if (nextElement != null)
+ if (nextElement != null)
nextElement.setTarget(il.append(NOP));
test.translateDesynthesized(classGen, methodGen);
@@ -157,7 +147,7 @@
test._falseList.add(il.append(new IFEQ(null)));
}
}
- catch (TypeCheckError e) {
+ catch (TypeCheckError e) {
// handled later!
}
}
@@ -178,7 +168,7 @@
test.backPatchFalseList(exit = il.append(NOP));
test.backPatchTrueList(truec.getNext());
}
-
+
// Translate any <xsl:otherwise> element
if (otherwise != null) {
nextElement.setTarget(il.append(NOP));
1.4.8.1.2.2 +3 -3
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Comment.java
Index: Comment.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Comment.java,v
retrieving revision 1.4.8.1.2.1
retrieving revision 1.4.8.1.2.2
diff -u -r1.4.8.1.2.1 -r1.4.8.1.2.2
--- Comment.java 10 Jan 2003 16:50:38 -0000 1.4.8.1.2.1
+++ Comment.java 13 Jan 2003 22:02:51 -0000 1.4.8.1.2.2
@@ -80,8 +80,8 @@
final class Comment extends Instruction {
- public void parseContents(Parser parser) {
- parseChildren(parser);
+ public void parse(CompilerContext ccontext) {
+ parseContents(ccontext);
}
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
1.7.8.1.2.2 +8 -14
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Copy.java
Index: Copy.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Copy.java,v
retrieving revision 1.7.8.1.2.1
retrieving revision 1.7.8.1.2.2
diff -u -r1.7.8.1.2.1 -r1.7.8.1.2.2
--- Copy.java 10 Jan 2003 16:50:38 -0000 1.7.8.1.2.1
+++ Copy.java 13 Jan 2003 22:02:51 -0000 1.7.8.1.2.2
@@ -77,20 +77,14 @@
final class Copy extends Instruction {
private UseAttributeSets _useSets;
-
- public void parseContents(Parser parser) {
+
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
final String useSets = getAttribute("use-attribute-sets");
if (useSets.length() > 0) {
_useSets = new UseAttributeSets(useSets, parser);
}
- parseChildren(parser);
- }
-
- public void display(int indent) {
- indent(indent);
- Util.println("Copy");
- indent(indent + IndentIncrement);
- displayContents(indent + IndentIncrement);
+ parseContents(ccontext);
}
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
@@ -100,7 +94,7 @@
typeCheckContents(stable);
return Type.Void;
}
-
+
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
@@ -123,7 +117,7 @@
"("
+ NODE_SIG
+ TRANSLET_OUTPUT_SIG
- + ")" + STRING_SIG);
+ + ")" + STRING_SIG);
il.append(new INVOKEINTERFACE(cpy, 3));
il.append(DUP);
il.append(new ASTORE(name.getIndex()));
@@ -167,7 +161,7 @@
il.append(methodGen.loadHandler());
il.append(new ALOAD(name.getIndex()));
il.append(methodGen.endElement());
-
+
final InstructionHandle end = il.append(NOP);
ifBlock1.setTarget(end);
ifBlock3.setTarget(end);
1.10.8.1.2.1 +13 -18
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CopyOf.java
Index: CopyOf.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CopyOf.java,v
retrieving revision 1.10.8.1
retrieving revision 1.10.8.1.2.1
diff -u -r1.10.8.1 -r1.10.8.1.2.1
--- CopyOf.java 14 Aug 2002 19:21:32 -0000 1.10.8.1
+++ CopyOf.java 13 Jan 2003 22:02:51 -0000 1.10.8.1.2.1
@@ -74,15 +74,10 @@
final class CopyOf extends Instruction {
private Expression _select;
-
- public void display(int indent) {
- indent(indent);
- Util.println("CopyOf");
- indent(indent + IndentIncrement);
- Util.println("select " + _select.toString());
- }
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
+
_select = parser.parseExpression(this, "select", null);
// make sure required attribute(s) have been set
if (_select.isDummy()) {
@@ -90,21 +85,21 @@
return;
}
}
-
+
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
final Type tselect = _select.typeCheck(stable);
if (tselect instanceof NodeType ||
tselect instanceof NodeSetType ||
tselect instanceof ReferenceType ||
tselect instanceof ResultTreeType) {
- // falls through
+ // falls through
}
else {
_select = new CastExpr(_select, Type.String);
}
return Type.Void;
}
-
+
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
@@ -120,7 +115,7 @@
il.append(methodGen.loadDOM());
// push NodeIterator
- _select.translate(classGen, methodGen);
+ _select.translate(classGen, methodGen);
_select.startResetIterator(classGen, methodGen);
// call copy from the DOM 'library'
@@ -129,12 +124,12 @@
}
else if (tselect instanceof NodeType) {
il.append(methodGen.loadDOM());
- _select.translate(classGen, methodGen);
+ _select.translate(classGen, methodGen);
il.append(methodGen.loadHandler());
il.append(new INVOKEINTERFACE(cpy2, 3));
}
else if (tselect instanceof ResultTreeType) {
- _select.translate(classGen, methodGen);
+ _select.translate(classGen, methodGen);
// We want the whole tree, so we start with the root node
il.append(ICONST_1);
il.append(methodGen.loadHandler());
@@ -146,9 +141,9 @@
il.append(methodGen.loadCurrentNode());
il.append(methodGen.loadDOM());
final int copy = cpg.addMethodref(BASIS_LIBRARY_CLASS, "copy",
- "("
- + OBJECT_SIG
- + TRANSLET_OUTPUT_SIG
+ "("
+ + OBJECT_SIG
+ + TRANSLET_OUTPUT_SIG
+ NODE_SIG
+ DOM_INTF_SIG
+ ")V");
1.9.2.1.2.1 +6 -4
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/DecimalFormatting.java
Index: DecimalFormatting.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/DecimalFormatting.java,v
retrieving revision 1.9.2.1
retrieving revision 1.9.2.1.2.1
diff -u -r1.9.2.1 -r1.9.2.1.2.1
--- DecimalFormatting.java 14 Aug 2002 19:21:32 -0000 1.9.2.1
+++ DecimalFormatting.java 13 Jan 2003 22:02:51 -0000 1.9.2.1.2.1
@@ -96,7 +96,9 @@
/**
* Parse the name of the <xsl:decimal-formatting/> element
*/
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
+
// Get the name of these decimal formatting symbols
_name = parser.getQNameIgnoreDefaultNs(getAttribute("name"));
if (_name == null) {
@@ -122,7 +124,7 @@
ConstantPoolGen cpg = classGen.getConstantPool();
InstructionList il = methodGen.getInstructionList();
-
+
// DecimalFormatSymbols.<init>();
final int init = cpg.addMethodref(DFS_CLASS, "<init>", "()V");
@@ -154,7 +156,7 @@
il.append(new PUSH(cpg, "Infinity"));
il.append(new INVOKEVIRTUAL(inf));
}
-
+
final int nAttributes = _attributes.getLength();
for (int i = 0; i < nAttributes; i++) {
final String name = _attributes.getQName(i);
1.9.2.1.2.2 +15 -21
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/EqualityExpr.java
Index: EqualityExpr.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/EqualityExpr.java,v
retrieving revision 1.9.2.1.2.1
retrieving revision 1.9.2.1.2.2
diff -u -r1.9.2.1.2.1 -r1.9.2.1.2.2
--- EqualityExpr.java 2 Dec 2002 15:51:16 -0000 1.9.2.1.2.1
+++ EqualityExpr.java 13 Jan 2003 22:02:51 -0000 1.9.2.1.2.2
@@ -75,19 +75,13 @@
private final int _op;
private Expression _left;
private Expression _right;
-
+
public EqualityExpr(int op, Expression left, Expression right) {
_op = op;
(_left = left).setParent(this);
(_right = right).setParent(this);
}
- public void setParser(Parser parser) {
- super.setParser(parser);
- _left.setParser(parser);
- _right.setParser(parser);
- }
-
public String toString() {
return Operators.names[_op] + '(' + _left + ", " + _right + ')';
}
@@ -130,7 +124,7 @@
* Typing rules: see XSLT Reference by M. Kay page 345.
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
- final Type tleft = _left.typeCheck(stable);
+ final Type tleft = _left.typeCheck(stable);
final Type tright = _right.typeCheck(stable);
if (tleft.isSimple() && tright.isSimple()) {
@@ -141,7 +135,7 @@
else if (tright instanceof BooleanType) {
_left = new CastExpr(_left, Type.Boolean);
}
- else if (tleft instanceof NumberType ||
+ else if (tleft instanceof NumberType ||
tright instanceof NumberType) {
_left = new CastExpr(_left, Type.Real);
_right = new CastExpr(_right, Type.Real);
@@ -176,7 +170,7 @@
else if (tleft instanceof NodeSetType && tright instanceof NodeType) {
swapArguments(); // for compare(Node, NodeSet)
}
- else {
+ else {
// At least one argument is of type node, node-set or result-tree
// Promote an expression of type node to node-set
@@ -210,7 +204,7 @@
if (tleft instanceof BooleanType) {
_left.translate(classGen, methodGen);
_right.translate(classGen, methodGen);
- _falseList.add(il.append(_op == Operators.EQ ?
+ _falseList.add(il.append(_op == Operators.EQ ?
(BranchInstruction)new IF_ICMPNE(null) :
(BranchInstruction)new IF_ICMPEQ(null)));
}
@@ -220,12 +214,12 @@
if (tleft instanceof RealType) {
il.append(DCMPG);
- _falseList.add(il.append(_op == Operators.EQ ?
- (BranchInstruction)new IFNE(null) :
+ _falseList.add(il.append(_op == Operators.EQ ?
+ (BranchInstruction)new IFNE(null) :
(BranchInstruction)new IFEQ(null)));
}
else {
- _falseList.add(il.append(_op == Operators.EQ ?
+ _falseList.add(il.append(_op == Operators.EQ ?
(BranchInstruction)new IF_ICMPNE(null)
:
(BranchInstruction)new
IF_ICMPEQ(null)));
}
@@ -265,7 +259,7 @@
}
BranchHandle truec, falsec;
-
+
if (tleft instanceof ResultTreeType) {
if (tright instanceof BooleanType) {
_right.translate(classGen, methodGen);
@@ -282,8 +276,8 @@
_right.translate(classGen, methodGen);
il.append(DCMPG);
- falsec = il.append(_op == Operators.EQ ?
- (BranchInstruction) new IFNE(null) :
+ falsec = il.append(_op == Operators.EQ ?
+ (BranchInstruction) new IFNE(null) :
(BranchInstruction) new IFEQ(null));
il.append(ICONST_1);
truec = il.append(new GOTO(null));
@@ -337,7 +331,7 @@
final int cmp = cpg.addMethodref(BASIS_LIBRARY_CLASS,
"compare",
"("
- + tleft.toSignature()
+ + tleft.toSignature()
+ tright.toSignature()
+ "I"
+ DOM_INTF_SIG
@@ -354,7 +348,7 @@
// Cast a result tree to a string to use an existing compare
if (tright instanceof ResultTreeType) {
- tright.translateTo(classGen, methodGen, Type.String);
+ tright.translateTo(classGen, methodGen, Type.String);
tright = Type.String;
}
@@ -365,7 +359,7 @@
final int compare = cpg.addMethodref(BASIS_LIBRARY_CLASS,
"compare",
"("
- + tleft.toSignature()
+ + tleft.toSignature()
+ tright.toSignature()
+ "I"
+ DOM_INTF_SIG
1.4.8.1.2.2 +3 -3
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Fallback.java
Index: Fallback.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Fallback.java,v
retrieving revision 1.4.8.1.2.1
retrieving revision 1.4.8.1.2.2
diff -u -r1.4.8.1.2.1 -r1.4.8.1.2.2
--- Fallback.java 10 Jan 2003 16:50:39 -0000 1.4.8.1.2.1
+++ Fallback.java 13 Jan 2003 22:02:51 -0000 1.4.8.1.2.2
@@ -105,8 +105,8 @@
* Parse contents only if this fallback element is put in place of
* some unsupported element or non-XSLTC extension element
*/
- public void parseContents(Parser parser) {
- if (_active) parseChildren(parser);
+ public void parse(CompilerContext ccontext) {
+ if (_active) parseContents(ccontext);
}
/**
1.6.8.1.2.2 +2 -5
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FilterExpr.java
Index: FilterExpr.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FilterExpr.java,v
retrieving revision 1.6.8.1.2.1
retrieving revision 1.6.8.1.2.2
diff -u -r1.6.8.1.2.1 -r1.6.8.1.2.2
--- FilterExpr.java 10 Jan 2003 16:50:39 -0000 1.6.8.1.2.1
+++ FilterExpr.java 13 Jan 2003 22:02:51 -0000 1.6.8.1.2.2
@@ -88,14 +88,11 @@
return _primary;
}
- public void setParser(Parser parser) {
- super.setParser(parser);
- _primary.setParser(parser);
+ public void setParent(Parser parser) {
if (_predicates != null) {
final int n = _predicates.size();
for (int i = 0; i < n; i++) {
final Expression exp = (Expression)_predicates.get(i);
- exp.setParser(parser);
exp.setParent(this);
}
}
1.10.2.1.2.1 +5 -11
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FilterParentPath.java
Index: FilterParentPath.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FilterParentPath.java,v
retrieving revision 1.10.2.1
retrieving revision 1.10.2.1.2.1
diff -u -r1.10.2.1 -r1.10.2.1.2.1
--- FilterParentPath.java 14 Aug 2002 19:21:32 -0000 1.10.2.1
+++ FilterParentPath.java 13 Jan 2003 22:02:51 -0000 1.10.2.1.2.1
@@ -79,13 +79,7 @@
(_path = path).setParent(this);
(_filterExpr = filterExpr).setParent(this);
}
-
- public void setParser(Parser parser) {
- super.setParser(parser);
- _filterExpr.setParser(parser);
- _path.setParser(parser);
- }
-
+
public String toString() {
return "FilterParentPath(" + _filterExpr + ", " + _path + ')';
}
@@ -95,7 +89,7 @@
}
/**
- * Type check a FilterParentPath. If the filter is not a node-set add a
+ * Type check a FilterParentPath. If the filter is not a node-set add a
* cast to node-set only if it is of reference type. This type coercion
is
* needed for expressions like $x/LINE where $x is a parameter reference.
*/
@@ -124,9 +118,9 @@
_path = new CastExpr(_path, Type.NodeSet);
}
- return _type = Type.NodeSet;
+ return _type = Type.NodeSet;
}
-
+
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
1.3.8.1.2.1 +7 -14
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FilteredAbsoluteLocationPath.java
Index: FilteredAbsoluteLocationPath.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FilteredAbsoluteLocationPath.java,v
retrieving revision 1.3.8.1
retrieving revision 1.3.8.1.2.1
diff -u -r1.3.8.1 -r1.3.8.1.2.1
--- FilteredAbsoluteLocationPath.java 14 Aug 2002 19:21:32 -0000 1.3.8.1
+++ FilteredAbsoluteLocationPath.java 13 Jan 2003 22:02:51 -0000
1.3.8.1.2.1
@@ -56,7 +56,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
- * @author G. Todd Miller
+ * @author G. Todd Miller
*
*/
@@ -67,7 +67,7 @@
import org.apache.xalan.xsltc.compiler.util.*;
final class FilteredAbsoluteLocationPath extends Expression {
- private Expression _path; // may be null
+ private Expression _path; // may be null
public FilteredAbsoluteLocationPath() {
_path = null;
@@ -80,22 +80,15 @@
}
}
- public void setParser(Parser parser) {
- super.setParser(parser);
- if (_path != null) {
- _path.setParser(parser);
- }
- }
-
public Expression getPath() {
return(_path);
}
-
+
public String toString() {
return "FilteredAbsoluteLocationPath(" +
(_path != null ? _path.toString() : "null") + ')';
}
-
+
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
if (_path != null) {
final Type ptype = _path.typeCheck(stable);
@@ -103,9 +96,9 @@
_path = new CastExpr(_path, Type.NodeSet);
}
}
- return _type = Type.NodeSet;
+ return _type = Type.NodeSet;
}
-
+
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
1.12.8.1.2.3 +9 -17
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ForEach.java
Index: ForEach.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ForEach.java,v
retrieving revision 1.12.8.1.2.2
retrieving revision 1.12.8.1.2.3
diff -u -r1.12.8.1.2.2 -r1.12.8.1.2.3
--- ForEach.java 10 Jan 2003 16:50:39 -0000 1.12.8.1.2.2
+++ ForEach.java 13 Jan 2003 22:02:51 -0000 1.12.8.1.2.3
@@ -77,22 +77,15 @@
import org.apache.xalan.xsltc.compiler.util.*;
final class ForEach extends Instruction {
-
private Expression _select;
private Type _type;
- public void display(int indent) {
- indent(indent);
- Util.println("ForEach");
- indent(indent + IndentIncrement);
- Util.println("select " + _select.toString());
- displayContents(indent + IndentIncrement);
- }
-
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
+
_select = parser.parseExpression(this, "select", null);
- parseChildren(parser);
+ parseContents(ccontext);
// make sure required attribute(s) have been set
if (_select.isDummy()) {
@@ -102,11 +95,10 @@
// Wrap _select in a ForwardPositionExpr
final Expression fpe = new ForwardPositionExpr(_select);
_select.setParent(fpe);
- fpe.setParser(_select.getParser());
_select = fpe;
}
}
-
+
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
_type = _select.typeCheck(stable);
@@ -129,7 +121,7 @@
// Save current node and current iterator on the stack
il.append(methodGen.loadCurrentNode());
il.append(methodGen.loadIterator());
-
+
// Collect sort objects associated with this instruction
final ArrayList sortObjects = new ArrayList();
Iterator children = iterator();
@@ -184,7 +176,7 @@
final InstructionHandle loop = il.append(NOP);
translateContents(classGen, methodGen);
-
+
nextNode.setTarget(il.append(methodGen.loadIterator()));
il.append(methodGen.nextNode());
il.append(DUP);
@@ -193,7 +185,7 @@
// Restore current DOM (if result tree was used instead for this loop)
if ((_type != null) && (_type instanceof ResultTreeType)) {
- il.append(methodGen.storeDOM());
+ il.append(methodGen.storeDOM());
}
// Restore current node and current iterator from the stack
1.1.2.2 +3 -8
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ForwardPositionExpr.java
Index: ForwardPositionExpr.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ForwardPositionExpr.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- ForwardPositionExpr.java 2 Dec 2002 15:51:16 -0000 1.1.2.1
+++ ForwardPositionExpr.java 13 Jan 2003 22:02:51 -0000 1.1.2.2
@@ -73,11 +73,6 @@
_expr = expr;
}
- public void setParser(Parser parser) {
- super.setParser(parser);
- _expr.setParser(parser);
- }
-
public String toString() {
return "forward-position-expr(" + _expr + ")";
}
@@ -85,7 +80,7 @@
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
return (_type = _expr.typeCheck(stable));
}
-
+
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
_expr.translate(classGen, methodGen);
@@ -93,7 +88,7 @@
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
- final int init = cpg.addMethodref(FORWARD_POSITION_ITERATOR,
+ final int init = cpg.addMethodref(FORWARD_POSITION_ITERATOR,
"<init>", "(" + NODE_ITERATOR_SIG + ")V");
il.append(new NEW(cpg.addClass(FORWARD_POSITION_ITERATOR)));
il.append(DUP_X1);
1.22.2.1.2.3 +2 -4
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FunctionCall.java
Index: FunctionCall.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FunctionCall.java,v
retrieving revision 1.22.2.1.2.2
retrieving revision 1.22.2.1.2.3
diff -u -r1.22.2.1.2.2 -r1.22.2.1.2.3
--- FunctionCall.java 10 Jan 2003 16:50:40 -0000 1.22.2.1.2.2
+++ FunctionCall.java 13 Jan 2003 22:02:51 -0000 1.22.2.1.2.3
@@ -298,13 +298,11 @@
return(_fname.toString());
}
- public void setParser(Parser parser) {
- super.setParser(parser);
+ public void setParent(Parser parser) {
if (_arguments != null) {
final int n = _arguments.size();
for (int i = 0; i < n; i++) {
final Expression exp = (Expression)_arguments.get(i);
- exp.setParser(parser);
exp.setParent(this);
}
}
1.10.2.1.2.2 +5 -15
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/If.java
Index: If.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/If.java,v
retrieving revision 1.10.2.1.2.1
retrieving revision 1.10.2.1.2.2
diff -u -r1.10.2.1.2.1 -r1.10.2.1.2.2
--- If.java 2 Dec 2002 15:51:16 -0000 1.10.2.1.2.1
+++ If.java 13 Jan 2003 22:02:52 -0000 1.10.2.1.2.2
@@ -78,21 +78,11 @@
private boolean _ignore = false;
/**
- * Display the contents of this element
- */
- public void display(int indent) {
- indent(indent);
- Util.println("If");
- indent(indent + IndentIncrement);
- System.out.print("test ");
- Util.println(_test.toString());
- displayContents(indent + IndentIncrement);
- }
-
- /**
* Parse the "test" expression and contents of this element.
*/
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
+
// Parse the "test" expression
_test = parser.parseExpression(this, "test", null);
@@ -109,7 +99,7 @@
_ignore = !((Boolean) result).booleanValue();
}
- parseChildren(parser);
+ parseContents(ccontext);
}
/**
1.16.2.1.2.3 +7 -6
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Import.java
Index: Import.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Import.java,v
retrieving revision 1.16.2.1.2.2
retrieving revision 1.16.2.1.2.3
diff -u -r1.16.2.1.2.2 -r1.16.2.1.2.3
--- Import.java 10 Jan 2003 16:50:40 -0000 1.16.2.1.2.2
+++ Import.java 13 Jan 2003 22:02:52 -0000 1.16.2.1.2.3
@@ -87,7 +87,8 @@
return _imported;
}
- public void parseContents(final Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
final Stylesheet context = parser.getCurrentStylesheet();
try {
@@ -117,7 +118,7 @@
// Return if we could not resolve the URL
if (input == null) {
- final ErrorMsg msg =
+ final ErrorMsg msg =
new ErrorMsg(ErrorMsg.FILE_NOT_FOUND_ERR, docToLoad, this);
parser.reportError(Constants.FATAL, msg);
return;
@@ -140,7 +141,7 @@
_imported.setImportPrecedence(currPrecedence);
context.setImportPrecedence(nextPrecedence);
parser.setCurrentStylesheet(_imported);
- _imported.parseContents(parser);
+ _imported.parse(ccontext);
final Iterator elements = _imported.iterator();
final Stylesheet topStylesheet = parser.getTopLevelStylesheet();
@@ -166,11 +167,11 @@
parser.setCurrentStylesheet(context);
}
}
-
+
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
return Type.Void;
}
-
+
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
// do nothing
}
1.19.2.1.2.3 +9 -8
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Include.java
Index: Include.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Include.java,v
retrieving revision 1.19.2.1.2.2
retrieving revision 1.19.2.1.2.3
diff -u -r1.19.2.1.2.2 -r1.19.2.1.2.3
--- Include.java 10 Jan 2003 16:50:40 -0000 1.19.2.1.2.2
+++ Include.java 13 Jan 2003 22:02:52 -0000 1.19.2.1.2.3
@@ -87,7 +87,8 @@
return _included;
}
- public void parseContents(final Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
final Stylesheet context = parser.getCurrentStylesheet();
String docToLoad = getAttribute("href");
@@ -137,7 +138,7 @@
// Return if we could not resolve the URL
if (input == null) {
- final ErrorMsg msg =
+ final ErrorMsg msg =
new ErrorMsg(ErrorMsg.FILE_NOT_FOUND_ERR, docToLoad, this);
parser.reportError(Constants.FATAL, msg);
return;
@@ -159,7 +160,7 @@
final int precedence = context.getImportPrecedence();
_included.setImportPrecedence(precedence);
parser.setCurrentStylesheet(_included);
- _included.parseContents(parser);
+ _included.parse(ccontext);
final Iterator elements = _included.iterator();
final Stylesheet topStylesheet = parser.getTopLevelStylesheet();
@@ -182,7 +183,7 @@
// Update systemId in parent stylesheet for error reporting
context.setSystemId(getAttribute("href"));
- final ErrorMsg msg =
+ final ErrorMsg msg =
new ErrorMsg(ErrorMsg.FILE_NOT_FOUND_ERR, docToLoad, this);
parser.reportError(Constants.FATAL, msg);
}
@@ -190,7 +191,7 @@
// Update systemId in parent stylesheet for error reporting
context.setSystemId(getAttribute("href"));
- final ErrorMsg msg =
+ final ErrorMsg msg =
new ErrorMsg(ErrorMsg.FILE_NOT_FOUND_ERR, docToLoad, this);
parser.reportError(Constants.FATAL, msg);
}
@@ -201,11 +202,11 @@
parser.setCurrentStylesheet(context);
}
}
-
+
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
return Type.Void;
}
-
+
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
// do nothing
}
1.11.2.1.2.2 +10 -9
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Key.java
Index: Key.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Key.java,v
retrieving revision 1.11.2.1.2.1
retrieving revision 1.11.2.1.2.2
diff -u -r1.11.2.1.2.1 -r1.11.2.1.2.2
--- Key.java 2 Dec 2002 15:51:16 -0000 1.11.2.1.2.1
+++ Key.java 13 Jan 2003 22:02:52 -0000 1.11.2.1.2.2
@@ -84,7 +84,7 @@
/**
* The pattern to match starting at the root node.
*/
- private Pattern _match;
+ private Pattern _match;
/**
* The expression that generates the values for this key.
@@ -100,7 +100,8 @@
* Parse the <xsl:key> element and attributes
* @param parser A reference to the stylesheet parser
*/
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
// Get the required attributes and parser XPath expressions
_name = parser.getQNameIgnoreDefaultNs(getAttribute("name"));
@@ -137,7 +138,7 @@
// Cast node values to string values (except for nodesets)
_useType = _use.typeCheck(stable);
if (_useType instanceof StringType == false &&
- _useType instanceof NodeSetType == false)
+ _useType instanceof NodeSetType == false)
{
_use = new CastExpr(_use, Type.String);
}
@@ -233,7 +234,7 @@
il.append(methodGen.loadIterator());
// Get an iterator for all nodes in the DOM
- il.append(methodGen.loadDOM());
+ il.append(methodGen.loadDOM());
il.append(new PUSH(cpg,Axis.DESCENDANT));
il.append(new INVOKEINTERFACE(git, 2));
@@ -251,7 +252,7 @@
_match.translate(classGen, methodGen);
_match.synthesize(classGen, methodGen); // Leaves 0 or 1 on stack
final BranchHandle skipNode = il.append(new IFEQ(null));
-
+
// If this is a node-set we must go through each node in the set
if (_useType instanceof NodeSetType) {
// Pass current node as parameter (we're indexing on that node)
@@ -265,10 +266,10 @@
_use.translate(classGen, methodGen);
il.append(new INVOKEVIRTUAL(key));
}
-
+
// Get the next node from the iterator and do loop again...
final InstructionHandle skip = il.append(NOP);
-
+
il.append(methodGen.loadIterator());
il.append(methodGen.nextNode());
il.append(DUP);
@@ -278,7 +279,7 @@
// Restore current node and current iterator from the stack
il.append(methodGen.storeIterator());
il.append(methodGen.storeCurrentNode());
-
+
nextNode.setTarget(skip);
skipNode.setTarget(skip);
}
1.4.8.1.2.1 +1 -6
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LiteralAttribute.java
Index: LiteralAttribute.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LiteralAttribute.java,v
retrieving revision 1.4.8.1
retrieving revision 1.4.8.1.2.1
diff -u -r1.4.8.1 -r1.4.8.1.2.1
--- LiteralAttribute.java 14 Aug 2002 19:21:32 -0000 1.4.8.1
+++ LiteralAttribute.java 13 Jan 2003 22:02:52 -0000 1.4.8.1.2.1
@@ -84,11 +84,6 @@
_value = AttributeValue.create(this, value, parser);
}
- public void display(int indent) {
- indent(indent);
- Util.println("LiteralAttribute name=" + _name + " value=" + _value);
- }
-
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
_value.typeCheck(stable);
typeCheckContents(stable);
1.18.2.1.2.2 +8 -15
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LiteralElement.java
Index: LiteralElement.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LiteralElement.java,v
retrieving revision 1.18.2.1.2.1
retrieving revision 1.18.2.1.2.2
diff -u -r1.18.2.1.2.1 -r1.18.2.1.2.2
--- LiteralElement.java 10 Jan 2003 16:50:40 -0000 1.18.2.1.2.1
+++ LiteralElement.java 13 Jan 2003 22:02:52 -0000 1.18.2.1.2.2
@@ -93,15 +93,6 @@
}
/**
- * Displays the contents of this literal element
- */
- public void display(int indent) {
- indent(indent);
- Util.println("LiteralElement name = " + _name);
- displayContents(indent + IndentIncrement);
- }
-
- /**
* Returns the namespace URI for which a prefix is pointing to
*/
private String accessedNamespace(String prefix) {
@@ -254,7 +245,9 @@
* Determines the final QName for the element and its attributes.
* Registers all namespaces that are used by the element/attributes
*/
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
+
final SymbolTable stable = parser.getSymbolTable();
stable.setCurrentNode(this);
@@ -306,7 +299,7 @@
LiteralAttribute attr = new LiteralAttribute(name, val, parser);
addAttribute(attr);
attr.setParent(this);
- attr.parseContents(parser);
+ attr.parse(ccontext);
}
}
@@ -323,7 +316,7 @@
}
}
- parseChildren(parser);
+ parseContents(ccontext);
// Process all attributes and register all namespaces they use
for (int i = 0; i < count; i++) {
@@ -365,10 +358,10 @@
// The value of an attribute may depend on a (sibling) variable
for (int i = 0; i < elementCount(); i++) {
- final SyntaxTreeNode item = (SyntaxTreeNode) get(i);
+ final SyntaxTreeNode item = get(i);
if (item instanceof Variable) {
item.translate(classGen, methodGen);
- removeElement(item); // avoid translating it twice
+ remove(item); // avoid translating it twice
}
}
1.10.2.1.2.3 +6 -16
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LogicalExpr.java
Index: LogicalExpr.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LogicalExpr.java,v
retrieving revision 1.10.2.1.2.2
retrieving revision 1.10.2.1.2.3
diff -u -r1.10.2.1.2.2 -r1.10.2.1.2.3
--- LogicalExpr.java 10 Jan 2003 16:50:40 -0000 1.10.2.1.2.2
+++ LogicalExpr.java 13 Jan 2003 22:02:52 -0000 1.10.2.1.2.3
@@ -72,7 +72,7 @@
public static final int OR = 0;
public static final int AND = 1;
-
+
private final int _op; // operator
private Expression _left; // first operand
private Expression _right; // second operand
@@ -100,7 +100,7 @@
}
/**
- * Returns an object representing the compile-time evaluation
+ * Returns an object representing the compile-time evaluation
* of an expression. We are only using this for function-available
* and element-available at this time.
*/
@@ -132,16 +132,6 @@
}
/**
- * Override the SyntaxTreeNode.setParser() method to make sure that the
- * parser is set for sub-expressions
- */
- public void setParser(Parser parser) {
- super.setParser(parser);
- _left.setParser(parser);
- _right.setParser(parser);
- }
-
- /**
* Returns a string describing this expression
*/
public String toString() {
@@ -153,7 +143,7 @@
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
// Get the left and right operand types
- Type tleft = _left.typeCheck(stable);
+ Type tleft = _left.typeCheck(stable);
Type tright = _right.typeCheck(stable);
// Check if the operator supports the two operand types
@@ -236,7 +226,7 @@
else {
_trueList.append(_right._trueList);
}
- }
+ }
// Compile OR-expression
else {
// Translate left-hand side expression and produce true/false list
@@ -251,7 +241,7 @@
_left._trueList.backPatch(ih);
_left._falseList.backPatch(ih.getNext());
-
+
_falseList.append(_right._falseList);
_trueList.add(ih).append(_right._trueList);
}
1.6.8.1.2.1 +3 -3
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Message.java
Index: Message.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Message.java,v
retrieving revision 1.6.8.1
retrieving revision 1.6.8.1.2.1
diff -u -r1.6.8.1 -r1.6.8.1.2.1
--- Message.java 14 Aug 2002 19:21:33 -0000 1.6.8.1
+++ Message.java 13 Jan 2003 22:02:52 -0000 1.6.8.1.2.1
@@ -74,12 +74,12 @@
final class Message extends Instruction {
private boolean _terminate = false;
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
String termstr = getAttribute("terminate");
if (termstr != null) {
_terminate = termstr.equals("yes");
}
- parseChildren(parser);
+ parseContents(ccontext);
}
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
1.4.8.1.2.2 +6 -5
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/NamespaceAlias.java
Index: NamespaceAlias.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/NamespaceAlias.java,v
retrieving revision 1.4.8.1.2.1
retrieving revision 1.4.8.1.2.2
diff -u -r1.4.8.1.2.1 -r1.4.8.1.2.2
--- NamespaceAlias.java 10 Jan 2003 16:50:40 -0000 1.4.8.1.2.1
+++ NamespaceAlias.java 13 Jan 2003 22:02:52 -0000 1.4.8.1.2.2
@@ -75,21 +75,22 @@
private String sPrefix;
private String rPrefix;
-
+
/*
* The namespace alias definitions given here have an impact only on
* literal elements and literal attributes.
*/
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
sPrefix = getAttribute("stylesheet-prefix");
rPrefix = getAttribute("result-prefix");
parser.getSymbolTable().addPrefixAlias(sPrefix,rPrefix);
}
-
+
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
return Type.Void;
}
-
+
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
// do nada
}
1.9.2.1.2.3 +4 -3
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Number.java
Index: Number.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Number.java,v
retrieving revision 1.9.2.1.2.2
retrieving revision 1.9.2.1.2.3
diff -u -r1.9.2.1.2.2 -r1.9.2.1.2.3
--- Number.java 10 Jan 2003 16:50:40 -0000 1.9.2.1.2.2
+++ Number.java 13 Jan 2003 22:02:52 -0000 1.9.2.1.2.3
@@ -147,8 +147,9 @@
// -- End Closure interface ----------------------
- public void parseContents(Parser parser) {
- final int count = _attributes.getLength();
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
+ final int count = _attributes.getLength();
for (int i = 0; i < count; i++) {
final String name = _attributes.getQName(i);
1.3.12.1.2.1 +2 -8
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Otherwise.java
Index: Otherwise.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Otherwise.java,v
retrieving revision 1.3.12.1
retrieving revision 1.3.12.1.2.1
diff -u -r1.3.12.1 -r1.3.12.1.2.1
--- Otherwise.java 14 Aug 2002 19:21:33 -0000 1.3.12.1
+++ Otherwise.java 13 Jan 2003 22:02:52 -0000 1.3.12.1.2.1
@@ -68,13 +68,7 @@
import org.apache.xalan.xsltc.compiler.util.*;
final class Otherwise extends Instruction {
- public void display(int indent) {
- indent(indent);
- Util.println("Otherwise");
- indent(indent + IndentIncrement);
- displayContents(indent + IndentIncrement);
- }
-
+
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
typeCheckContents(stable);
return Type.Void;
1.16.2.1.2.3 +6 -13
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Output.java
Index: Output.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Output.java,v
retrieving revision 1.16.2.1.2.2
retrieving revision 1.16.2.1.2.3
diff -u -r1.16.2.1.2.2 -r1.16.2.1.2.3
--- Output.java 10 Jan 2003 16:50:41 -0000 1.16.2.1.2.2
+++ Output.java 13 Jan 2003 22:02:52 -0000 1.16.2.1.2.3
@@ -104,14 +104,6 @@
private final static String HTML_VERSION = "4.0";
/**
- * Displays the contents of this element (for debugging)
- */
- public void display(int indent) {
- indent(indent);
- Util.println("Output " + _method);
- }
-
- /**
* Disables this <xsl:output> element in case where there are some other
* <xsl:output> element (from a different imported/included stylesheet)
* with higher precedence.
@@ -135,7 +127,8 @@
/**
* Scans the attribute list for the xsl:output instruction
*/
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
final Properties outputProperties = new Properties();
// Ask the parser if it wants this <xsl:output> element
@@ -174,7 +167,7 @@
try {
// Create a write to verify encoding support
OutputStreamWriter writer =
- new OutputStreamWriter(System.out,
+ new OutputStreamWriter(System.out,
StreamOutput.getCanonicalEncoding(_encoding));
}
catch (java.io.UnsupportedEncodingException e) {
@@ -239,7 +232,7 @@
if (_cdataToMerge != null) {
_cdata = _cdata + _cdataToMerge;
}
- outputProperties.setProperty(OutputKeys.CDATA_SECTION_ELEMENTS,
+ outputProperties.setProperty(OutputKeys.CDATA_SECTION_ELEMENTS,
_cdata);
}
@@ -349,7 +342,7 @@
il.append(DUP);
il.append(new PUSH(cpg, _doctypePublic));
il.append(new PUTFIELD(field));
-
+
// Add 'medye-type' decaration to output - if used
if (_mediaType != null) {
field = cpg.addFieldref(TRANSLET_CLASS, "_mediaType", STRING_SIG);
1.19.8.1.2.3 +5 -17
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Param.java
Index: Param.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Param.java,v
retrieving revision 1.19.8.1.2.2
retrieving revision 1.19.8.1.2.3
diff -u -r1.19.8.1.2.2 -r1.19.8.1.2.3
--- Param.java 10 Jan 2003 16:50:41 -0000 1.19.8.1.2.2
+++ Param.java 13 Jan 2003 22:02:52 -0000 1.19.8.1.2.3
@@ -87,26 +87,14 @@
}
/**
- * Display variable in a full AST dump
- */
- public void display(int indent) {
- indent(indent);
- System.out.println("param " + _name);
- if (_select != null) {
- indent(indent + IndentIncrement);
- System.out.println("select " + _select.toString());
- }
- displayContents(indent + IndentIncrement);
- }
-
- /**
* Parse the contents of the <xsl:param> element. This method must read
* the 'name' (required) and 'select' (optional) attributes.
*/
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
// Parse 'name' and 'select' attributes plus parameter contents
- super.parseContents(parser);
+ super.parse(ccontext);
// Add a ref to this param to its enclosing construct
final SyntaxTreeNode parent = getParent();
@@ -150,7 +138,7 @@
*/
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
if (_select != null) {
- _type = _select.typeCheck(stable);
+ _type = _select.typeCheck(stable);
if (_type instanceof ReferenceType == false) {
_select = new CastExpr(_select, Type.Reference);
}
1.19.2.1.2.2 +3 -9
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParentLocationPath.java
Index: ParentLocationPath.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParentLocationPath.java,v
retrieving revision 1.19.2.1.2.1
retrieving revision 1.19.2.1.2.2
diff -u -r1.19.2.1.2.1 -r1.19.2.1.2.2
--- ParentLocationPath.java 2 Dec 2002 15:51:17 -0000 1.19.2.1.2.1
+++ ParentLocationPath.java 13 Jan 2003 22:02:52 -0000 1.19.2.1.2.2
@@ -86,7 +86,7 @@
_axisMismatch = checkAxisMismatch();
}
}
-
+
public void setAxis(int axis) {
_path.setAxis(axis);
}
@@ -103,12 +103,6 @@
return(_step);
}
- public void setParser(Parser parser) {
- super.setParser(parser);
- _step.setParser(parser);
- _path.setParser(parser);
- }
-
public String toString() {
return "ParentLocationPath(" + _path + ", " + _step + ')';
}
@@ -119,7 +113,7 @@
if (_axisMismatch) enableNodeOrdering();
- return _type = Type.NodeSet;
+ return _type = Type.NodeSet;
}
public void enableNodeOrdering() {
1.5.2.1.2.1 +12 -18
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParentPattern.java
Index: ParentPattern.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParentPattern.java,v
retrieving revision 1.5.2.1
retrieving revision 1.5.2.1.2.1
diff -u -r1.5.2.1 -r1.5.2.1.2.1
--- ParentPattern.java 14 Aug 2002 19:21:33 -0000 1.5.2.1
+++ ParentPattern.java 13 Jan 2003 22:02:52 -0000 1.5.2.1.2.1
@@ -70,26 +70,20 @@
final class ParentPattern extends RelativePathPattern {
private final Pattern _left;
private final RelativePathPattern _right;
-
+
public ParentPattern(Pattern left, RelativePathPattern right) {
(_left = left).setParent(this);
(_right = right).setParent(this);
}
- public void setParser(Parser parser) {
- super.setParser(parser);
- _left.setParser(parser);
- _right.setParser(parser);
- }
-
public boolean isWildcard() {
return false;
}
-
+
public StepPattern getKernelPattern() {
return _right.getKernelPattern();
}
-
+
public void reduceKernelPattern() {
_right.reduceKernelPattern();
}
@@ -103,10 +97,10 @@
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
final LocalVariableGen local =
- methodGen.addLocalVariable2("ppt",
+ methodGen.addLocalVariable2("ppt",
Util.getJCRefType(NODE_SIG),
il.getEnd());
-
+
final org.apache.bcel.generic.Instruction loadLocal =
new ILOAD(local.getIndex());
final org.apache.bcel.generic.Instruction storeLocal =
@@ -119,9 +113,9 @@
else if (_right instanceof StepPattern) {
il.append(DUP);
il.append(storeLocal);
-
+
_right.translate(classGen, methodGen);
-
+
il.append(methodGen.loadDOM());
local.setEnd(il.append(loadLocal));
}
@@ -140,15 +134,15 @@
il.append(new INVOKEINTERFACE(getParent, 2));
final SyntaxTreeNode p = getParent();
- if (p == null || p instanceof Instruction ||
- p instanceof TopLevelElement)
+ if (p == null || p instanceof Instruction ||
+ p instanceof TopLevelElement)
{
_left.translate(classGen, methodGen);
}
else {
il.append(DUP);
il.append(storeLocal);
-
+
_left.translate(classGen, methodGen);
il.append(methodGen.loadDOM());
@@ -156,7 +150,7 @@
}
methodGen.removeLocalVariable(local);
-
+
/*
* If _right is an ancestor pattern, backpatch _left false
* list to the loop that searches for more ancestors.
1.51.2.1.2.3 +5 -8
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java
Index: Parser.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java,v
retrieving revision 1.51.2.1.2.2
retrieving revision 1.51.2.1.2.3
diff -u -r1.51.2.1.2.2 -r1.51.2.1.2.3
--- Parser.java 10 Jan 2003 16:50:41 -0000 1.51.2.1.2.2
+++ Parser.java 13 Jan 2003 22:02:52 -0000 1.51.2.1.2.3
@@ -391,7 +391,6 @@
element.addPrefixMapping(EMPTYSTRING, EMPTYSTRING);
}
}
- stylesheet.setParser(this);
return stylesheet;
}
catch (ClassCastException e) {
@@ -401,12 +400,12 @@
}
/**
- * Instanciates a SAX2 parser and generate the AST from the input.
+ * Instantiates a SAX2 parser and generate the AST from the input.
*/
public void createAST(Stylesheet stylesheet) {
try {
if (stylesheet != null) {
- stylesheet.parseContents(this);
+ stylesheet.parse(CompilerContextImpl.getInstance());
final int precedence = stylesheet.getImportPrecedence();
final Iterator elements = stylesheet.iterator();
while (elements.hasNext()) {
@@ -935,7 +934,6 @@
final Class clazz = Class.forName(className);
node = (SyntaxTreeNode)clazz.newInstance();
node.setQName(qname);
- node.setParser(this);
if (_locator != null) {
node.setLineNumber(_locator.getLineNumber());
}
@@ -1102,7 +1100,6 @@
if (result != null) {
final SyntaxTreeNode node = (SyntaxTreeNode)result.value;
if (node != null) {
- node.setParser(this);
node.setParent(parent);
node.setLineNumber(line);
// System.out.println("e = " + text + " " + node);
@@ -1119,7 +1116,6 @@
}
// Return a dummy pattern (which is an expression)
- SyntaxTreeNode.Dummy.setParser(this);
return SyntaxTreeNode.Dummy;
}
@@ -1312,7 +1308,8 @@
// Ignore text nodes that occur directly under <xsl:stylesheet>
if (parent instanceof Stylesheet) return;
- SyntaxTreeNode bro = parent.lastChild();
+ // Get last element of parent
+ SyntaxTreeNode bro = parent.get(parent.elementCount() - 1);
if ((bro != null) && (bro instanceof Text)) {
Text text = (Text)bro;
if (!text.isTextElement()) {
1.24.2.1.2.3 +1 -7
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.24.2.1.2.2
retrieving revision 1.24.2.1.2.3
diff -u -r1.24.2.1.2.2 -r1.24.2.1.2.3
--- Predicate.java 10 Jan 2003 16:50:41 -0000 1.24.2.1.2.2
+++ Predicate.java 13 Jan 2003 22:02:52 -0000 1.24.2.1.2.3
@@ -90,11 +90,6 @@
(_exp = exp).setParent(this);
}
- public void setParser(Parser parser) {
- super.setParser(parser);
- _exp.setParser(parser);
- }
-
public boolean isNthDescendant() {
return _nthDescendant;
}
@@ -252,7 +247,6 @@
final QName position =
getParser().getQNameIgnoreDefaultNs("position");
final PositionCall positionCall = new PositionCall(position);
- positionCall.setParser(getParser());
positionCall.setParent(this);
_exp = new EqualityExpr(EqualityExpr.EQ, positionCall, _exp);
1.7.2.1.2.1 +8 -6
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ProcessingInstruction.java
Index: ProcessingInstruction.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ProcessingInstruction.java,v
retrieving revision 1.7.2.1
retrieving revision 1.7.2.1.2.1
diff -u -r1.7.2.1 -r1.7.2.1.2.1
--- ProcessingInstruction.java 14 Aug 2002 19:21:33 -0000 1.7.2.1
+++ ProcessingInstruction.java 13 Jan 2003 22:02:52 -0000
1.7.2.1.2.1
@@ -70,14 +70,16 @@
final class ProcessingInstruction extends Instruction {
private AttributeValue _name; // name treated as AVT (7.1.3)
-
- public void parseContents(Parser parser) {
+
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
+
final String name = getAttribute("name");
_name = AttributeValue.create(this, name, parser);
if (name.equals("xml")) {
reportError(this, parser, ErrorMsg.ILLEGAL_PI_ERR, "xml");
}
- parseChildren(parser);
+ parseContents(ccontext);
}
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
@@ -93,7 +95,7 @@
// Save the current handler base on the stack
il.append(methodGen.loadHandler());
il.append(DUP); // first arg to "attributes" call
-
+
// push attribute name
_name.translate(classGen, methodGen);// 2nd arg
@@ -114,7 +116,7 @@
// call "processingInstruction"
final int processingInstruction =
cpg.addInterfaceMethodref(TRANSLET_OUTPUT_INTERFACE,
- "processingInstruction",
+ "processingInstruction",
"(" + STRING_SIG + STRING_SIG + ")V");
il.append(new INVOKEINTERFACE(processingInstruction, 3));
// Restore old handler base from stack
1.12.8.1.2.3 +16 -22
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/RelationalExpr.java
Index: RelationalExpr.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/RelationalExpr.java,v
retrieving revision 1.12.8.1.2.2
retrieving revision 1.12.8.1.2.3
diff -u -r1.12.8.1.2.2 -r1.12.8.1.2.3
--- RelationalExpr.java 10 Jan 2003 16:50:41 -0000 1.12.8.1.2.2
+++ RelationalExpr.java 13 Jan 2003 22:02:52 -0000 1.12.8.1.2.3
@@ -72,19 +72,13 @@
final class RelationalExpr extends Expression implements Operators {
private int _op;
private Expression _left, _right;
-
+
public RelationalExpr(int op, Expression left, Expression right) {
_op = op;
(_left = left).setParent(this);
(_right = right).setParent(this);
}
- public void setParser(Parser parser) {
- super.setParser(parser);
- _left.setParser(parser);
- _right.setParser(parser);
- }
-
/**
* Returns true if this expressions contains a call to position(). This
is
* needed for context changes in node steps containing multiple
predicates.
@@ -111,16 +105,16 @@
}
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
- Type tleft = _left.typeCheck(stable);
+ Type tleft = _left.typeCheck(stable);
Type tright = _right.typeCheck(stable);
//bug fix # 2838, cast to reals if both are result tree fragments
if (tleft instanceof ResultTreeType &&
- tright instanceof ResultTreeType )
+ tright instanceof ResultTreeType )
{
_right = new CastExpr(_right, Type.Real);
_left = new CastExpr(_left, Type.Real);
- return _type = Type.Boolean;
+ return _type = Type.Boolean;
}
// If one is of reference type, then convert the other too
@@ -142,7 +136,7 @@
typeR = var.getType();
}
}
- // bug fix # 2838
+ // bug fix # 2838
if (typeL == null)
type = typeR;
else if (typeR == null)
@@ -196,8 +190,8 @@
// Lookup the table of primops to find the best match
MethodType ptype = lookupPrimop(stable, Operators.names[_op],
- new MethodType(Type.Void,
- tleft, tright));
+ new MethodType(Type.Void,
+ tleft, tright));
if (ptype != null) {
Type arg1 = (Type) ptype.argsType().get(0);
@@ -206,7 +200,7 @@
}
Type arg2 = (Type) ptype.argsType().get(1);
if (!arg2.identicalTo(tright)) {
- _right = new CastExpr(_right, arg1);
+ _right = new CastExpr(_right, arg1);
}
return _type = ptype.resultType();
}
@@ -229,7 +223,7 @@
int index = cpg.addMethodref(BASIS_LIBRARY_CLASS, "compare",
"("
- + _left.getType().toSignature()
+ + _left.getType().toSignature()
+ _right.getType().toSignature()
+ "I"
+ DOM_INTF_SIG
@@ -258,7 +252,7 @@
// TODO: optimize if one of the args is 0
boolean tozero = false;
- Type tleft = _left.getType();
+ Type tleft = _left.getType();
if (tleft instanceof RealType) {
il.append(tleft.CMP(_op == LT || _op == LE));
@@ -268,21 +262,21 @@
switch (_op) {
case LT:
- bi = tleft.GE(tozero);
+ bi = tleft.GE(tozero);
break;
-
+
case GT:
bi = tleft.LE(tozero);
break;
-
+
case LE:
bi = tleft.GT(tozero);
break;
-
+
case GE:
bi = tleft.LT(tozero);
break;
-
+
default:
ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_RELAT_OP_ERR,this);
getParser().reportError(Constants.FATAL, msg);
1.15.2.1.2.3 +3 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Sort.java
Index: Sort.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Sort.java,v
retrieving revision 1.15.2.1.2.2
retrieving revision 1.15.2.1.2.3
diff -u -r1.15.2.1.2.2 -r1.15.2.1.2.3
--- Sort.java 10 Jan 2003 16:50:41 -0000 1.15.2.1.2.2
+++ Sort.java 13 Jan 2003 22:02:52 -0000 1.15.2.1.2.3
@@ -147,7 +147,8 @@
/**
* Parse the attributes of the xsl:sort element
*/
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
final SyntaxTreeNode parent = getParent();
if (!(parent instanceof ApplyTemplates) &&
1.37.2.1.2.3 +1 -3
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.37.2.1.2.2
retrieving revision 1.37.2.1.2.3
diff -u -r1.37.2.1.2.2 -r1.37.2.1.2.3
--- Step.java 10 Jan 2003 16:50:41 -0000 1.37.2.1.2.2
+++ Step.java 13 Jan 2003 22:02:53 -0000 1.37.2.1.2.3
@@ -106,12 +106,10 @@
* Set the parser for this element and all child predicates
*/
public void setParser(Parser parser) {
- super.setParser(parser);
if (_predicates != null) {
final int n = _predicates.size();
for (int i = 0; i < n; i++) {
final Predicate exp = (Predicate)_predicates.get(i);
- exp.setParser(parser);
exp.setParent(this);
}
}
1.17.2.1.2.3 +33 -35
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/StepPattern.java
Index: StepPattern.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/StepPattern.java,v
retrieving revision 1.17.2.1.2.2
retrieving revision 1.17.2.1.2.3
diff -u -r1.17.2.1.2.2 -r1.17.2.1.2.3
--- StepPattern.java 10 Jan 2003 16:50:42 -0000 1.17.2.1.2.2
+++ StepPattern.java 13 Jan 2003 22:02:53 -0000 1.17.2.1.2.3
@@ -93,13 +93,11 @@
_predicates = predicates;
}
- public void setParser(Parser parser) {
- super.setParser(parser);
+ public void setParent(Parser parser) {
if (_predicates != null) {
final int n = _predicates.size();
for (int i = 0; i < n; i++) {
final Predicate exp = (Predicate)_predicates.get(i);
- exp.setParser(parser);
exp.setParent(this);
}
}
@@ -108,11 +106,11 @@
public int getNodeType() {
return _nodeType;
}
-
+
public StepPattern getKernelPattern() {
return this;
}
-
+
public boolean isWildcard() {
return _isEpsilon && hasPredicates() == false;
}
@@ -121,7 +119,7 @@
_predicates = predicates;
return(this);
}
-
+
protected boolean hasPredicates() {
return _predicates != null && _predicates.size() > 0;
}
@@ -141,7 +139,7 @@
}
}
}
-
+
public int getAxis() {
return _axis;
}
@@ -149,19 +147,19 @@
public void reduceKernelPattern() {
_isEpsilon = true;
}
-
+
public String toString() {
final StringBuffer buffer = new StringBuffer("stepPattern(\"");
buffer.append(Axis.names[_axis])
.append("\", ")
- .append(_isEpsilon ?
+ .append(_isEpsilon ?
("epsilon{" + Integer.toString(_nodeType) + "}") :
Integer.toString(_nodeType));
if (_predicates != null)
buffer.append(", ").append(_predicates.toString());
return buffer.append(')').toString();
}
-
+
private int analyzeCases() {
boolean noContext = true;
final int n = _predicates.size();
@@ -216,18 +214,18 @@
return _axis == Axis.CHILD ? Type.Element : Type.Attribute;
}
- private void translateKernel(ClassGenerator classGen,
+ private void translateKernel(ClassGenerator classGen,
MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
-
+
if (_nodeType == DOM.ELEMENT) {
final int check = cpg.addInterfaceMethodref(DOM_INTF,
"isElement", "(I)Z");
il.append(methodGen.loadDOM());
il.append(SWAP);
il.append(new INVOKEINTERFACE(check, 2));
-
+
// Need to allow for long jumps here
final BranchHandle icmp = il.append(new IFNE(null));
_falseList.add(il.append(new GOTO_W(null)));
@@ -239,7 +237,7 @@
il.append(methodGen.loadDOM());
il.append(SWAP);
il.append(new INVOKEINTERFACE(check, 2));
-
+
// Need to allow for long jumps here
final BranchHandle icmp = il.append(new IFNE(null));
_falseList.add(il.append(new GOTO_W(null)));
@@ -253,7 +251,7 @@
il.append(SWAP);
il.append(new INVOKEINTERFACE(getType, 2));
il.append(new PUSH(cpg, _nodeType));
-
+
// Need to allow for long jumps here
final BranchHandle icmp = il.append(new IF_ICMPEQ(null));
_falseList.add(il.append(new GOTO_W(null)));
@@ -261,7 +259,7 @@
}
}
- private void translateNoContext(ClassGenerator classGen,
+ private void translateNoContext(ClassGenerator classGen,
MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
@@ -304,7 +302,7 @@
skipFalse.setTarget(il.append(NOP));
}
- private void translateSimpleContext(ClassGenerator classGen,
+ private void translateSimpleContext(ClassGenerator classGen,
MethodGenerator methodGen) {
int index;
final ConstantPoolGen cpg = classGen.getConstantPool();
@@ -312,7 +310,7 @@
// Store matching node into a local variable
LocalVariableGen match;
- match = methodGen.addLocalVariable("step_pattern_tmp1",
+ match = methodGen.addLocalVariable("step_pattern_tmp1",
Util.getJCRefType(NODE_SIG),
il.getEnd(), null);
il.append(new ISTORE(match.getIndex()));
@@ -328,7 +326,7 @@
il.append(methodGen.loadIterator());
// Create a new matching iterator using the matching node
- index = cpg.addMethodref(MATCHING_ITERATOR, "<init>",
+ index = cpg.addMethodref(MATCHING_ITERATOR, "<init>",
"(I" + NODE_ITERATOR_SIG + ")V");
il.append(new NEW(cpg.addClass(MATCHING_ITERATOR)));
il.append(DUP);
@@ -342,7 +340,7 @@
index = cpg.addInterfaceMethodref(DOM_INTF, GET_PARENT, GET_PARENT_SIG);
il.append(new INVOKEINTERFACE(index, 2));
- // Start the iterator with the parent
+ // Start the iterator with the parent
il.append(methodGen.setStartNode());
// Overwrite current iterator and current node
@@ -350,7 +348,7 @@
il.append(new ILOAD(match.getIndex()));
il.append(methodGen.storeCurrentNode());
- // Translate the expression of the predicate
+ // Translate the expression of the predicate
Predicate pred = (Predicate) _predicates.get(0);
Expression exp = pred.getExpr();
exp.translateDesynthesized(classGen, methodGen);
@@ -371,7 +369,7 @@
skipFalse.setTarget(il.append(NOP));
}
- private void translateGeneralContext(ClassGenerator classGen,
+ private void translateGeneralContext(ClassGenerator classGen,
MethodGenerator methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
@@ -382,25 +380,25 @@
final String iteratorName = getNextFieldName();
// Store node on the stack into a local variable
- node = methodGen.addLocalVariable("step_pattern_tmp1",
+ node = methodGen.addLocalVariable("step_pattern_tmp1",
Util.getJCRefType(NODE_SIG),
il.getEnd(), null);
il.append(new ISTORE(node.getIndex()));
// Create a new local to store the iterator
- iter = methodGen.addLocalVariable("step_pattern_tmp2",
+ iter = methodGen.addLocalVariable("step_pattern_tmp2",
Util.getJCRefType(NODE_ITERATOR_SIG),
il.getEnd(), null);
// Add a new private field if this is the main class
if (!classGen.isExternal()) {
final Field iterator =
- new Field(ACC_PRIVATE,
+ new Field(ACC_PRIVATE,
cpg.addUtf8(iteratorName),
cpg.addUtf8(NODE_ITERATOR_SIG),
null, cpg.getConstantPool());
classGen.addField(iterator);
- iteratorIndex = cpg.addFieldref(classGen.getClassName(),
+ iteratorIndex = cpg.addFieldref(classGen.getClassName(),
iteratorName,
NODE_ITERATOR_SIG);
@@ -410,7 +408,7 @@
il.append(new ASTORE(iter.getIndex()));
ifBlock = il.append(new IFNONNULL(null));
il.append(classGen.loadTranslet());
- }
+ }
// Compile the step created at type checking time
_step.translate(classGen, methodGen);
@@ -435,17 +433,17 @@
il.append(SWAP);
il.append(methodGen.setStartNode());
- /*
+ /*
* Inline loop:
*
* int node2;
- * while ((node2 = iter.next()) != NodeIterator.END
+ * while ((node2 = iter.next()) != NodeIterator.END
* && node2 < node);
- * return node2 == node;
+ * return node2 == node;
*/
BranchHandle skipNext;
InstructionHandle begin, next;
- node2 = methodGen.addLocalVariable("step_pattern_tmp3",
+ node2 = methodGen.addLocalVariable("step_pattern_tmp3",
Util.getJCRefType(NODE_SIG),
il.getEnd(), null);
@@ -466,7 +464,7 @@
skipNext.setTarget(begin);
}
-
+
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
final ConstantPoolGen cpg = classGen.getConstantPool();
final InstructionList il = methodGen.getInstructionList();
@@ -476,11 +474,11 @@
case NO_CONTEXT:
translateNoContext(classGen, methodGen);
break;
-
+
case SIMPLE_CONTEXT:
translateSimpleContext(classGen, methodGen);
break;
-
+
default:
translateGeneralContext(classGen, methodGen);
break;
1.43.2.1.2.3 +13 -13
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.43.2.1.2.2
retrieving revision 1.43.2.1.2.3
diff -u -r1.43.2.1.2.2 -r1.43.2.1.2.3
--- Stylesheet.java 10 Jan 2003 16:50:42 -0000 1.43.2.1.2.2
+++ Stylesheet.java 13 Jan 2003 22:02:53 -0000 1.43.2.1.2.3
@@ -236,10 +236,12 @@
return false;
}
+/* Removing setParser() - where is _name set?
public void setParser(Parser parser) {
super.setParser(parser);
_name = makeStylesheetName("__stylesheet_");
}
+*/
public void setParentStylesheet(Stylesheet parent) {
_parentStylesheet = parent;
@@ -354,7 +356,8 @@
* entry to the symbol table mapping the name <tt>__stylesheet_</tt>
* to an instance of this class.
*/
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
final SymbolTable stable = parser.getSymbolTable();
/*
@@ -387,18 +390,21 @@
if (_simplified) {
stable.excludeURI(XSLT_URI);
Template template = new Template();
- template.parseSimplified(this, parser);
+ StaticContextImpl scontextImpl = getStaticContext();
+ // TODO: update static context - scontextImpl.addStylesheet()
+ template.parseSimplified(ccontext);
}
// Parse the children of this node
else {
- parseOwnChildren(parser);
+ parseOwnChildren(ccontext);
}
}
/**
* Parse all direct children of the <xsl:stylesheet/> element.
*/
- public final void parseOwnChildren(Parser parser) {
+ public final void parseOwnChildren(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
final ArrayList contents = getContents();
final int count = contents.size();
@@ -409,7 +415,7 @@
if ((child instanceof VariableBase) ||
(child instanceof NamespaceAlias)) {
parser.getSymbolTable().setCurrentNode(child);
- child.parseContents(parser);
+ child.parse(ccontext);
}
}
@@ -419,7 +425,7 @@
if (!(child instanceof VariableBase) &&
!(child instanceof NamespaceAlias)) {
parser.getSymbolTable().setCurrentNode(child);
- child.parseContents(parser);
+ child.parse(ccontext);
}
// All template code should be compiled as methods if the
@@ -1017,12 +1023,6 @@
public int addVariable(Variable global) {
_globals.add(global);
return _globals.size() - 1;
- }
-
- public void display(int indent) {
- indent(indent);
- Util.println("Stylesheet");
- displayContents(indent + IndentIncrement);
}
// do we need this wrapper ?????
1.20.2.1.2.3 +169 -406
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java
Index: SyntaxTreeNode.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java,v
retrieving revision 1.20.2.1.2.2
retrieving revision 1.20.2.1.2.3
diff -u -r1.20.2.1.2.2 -r1.20.2.1.2.3
--- SyntaxTreeNode.java 10 Jan 2003 16:50:42 -0000 1.20.2.1.2.2
+++ SyntaxTreeNode.java 13 Jan 2003 22:02:53 -0000 1.20.2.1.2.3
@@ -77,28 +77,8 @@
import org.apache.bcel.generic.*;
import org.apache.xalan.xsltc.compiler.util.*;
-
public abstract class SyntaxTreeNode implements Constants {
- // -- The following should be moved to CompilerContext ---------------
-
- /**
- * Reference to the parser object
- */
- private Parser _parser;
-
- /**
- * A reference to the containing stylesheet (an ancestor).
- */
- private Stylesheet _stylesheet;
-
- /**
- * A reference to the containing template (an ancestor)
- */
- private Template _template;
-
- // -------------------------------------------------------------------
-
/**
* A reference to this node's parent or null it outermost.
*/
@@ -133,8 +113,7 @@
* A "sentinel" that is used to denote unrecognised syntaxt
* tree nodes.
*/
- protected static final SyntaxTreeNode Dummy
- = new AbsolutePathPattern(null); // TODO: use a different class
+ protected static final SyntaxTreeNode Dummy = new Text();
/**
* Creates a new SyntaxTreeNode with a 'null' QName and no source file
@@ -166,13 +145,15 @@
}
/**
- * Returns a reference to the static context using this node as
- * current.
+ * Returns 'true' if this syntax tree node is the Sentinal node.
+ * @return 'true' if this syntax tree node is the Sentinal node.
*/
- public StaticContextImpl getStaticContext() {
- return StaticContextImpl.getInstance(this);
+ protected final boolean isDummy() {
+ return this == Dummy;
}
+ // -- Line number info ----------------------------------------------
+
/**
* Set the source file line number for this element
* @param line The source file line number.
@@ -189,6 +170,8 @@
return _line;
}
+ // -- Node's qname -----------------------------------------------
+
/**
* Set the QName for the syntax tree node.
* @param qname The QName for the syntax tree node
@@ -212,13 +195,15 @@
* @param qname The QName for the syntax tree node
*/
protected QName getQName() {
- return(_qname);
+ return _qname;
}
+ // -- Node's attributes ------------------------------------------
+
/**
* Set the attributes for this SyntaxTreeNode.
- * @param attributes Attributes for the element. Must be passed in as an
- * implementation of org.xml.sax.Attributes.
+ *
+ * @param attributes Attributes for the element.
*/
protected void setAttributes(Attributes attributes) {
_attributes = attributes;
@@ -226,8 +211,10 @@
/**
* Returns a value for an attribute from the source element.
+ *
* @param qname The QName of the attribute to return.
- * @return The value of the attribute of name 'qname'.
+ * @return The value of the attribute of name 'qname' or the
+ * empty string if the attribute is not present.
*/
protected String getAttribute(String qname) {
if (_attributes == null) {
@@ -243,20 +230,24 @@
}
/**
- * Returns a list of all attributes declared for the element represented
by
- * this syntax tree node.
+ * Returns a list of all attributes declared for the element
+ * represented by this syntax tree node.
+ *
* @return Attributes for this syntax tree node
*/
protected Attributes getAttributes() {
- return(_attributes);
+ return _attributes;
}
+ // -- Node's NS declarations -------------------------------------
+
/**
* Sets the prefix mapping for the namespaces that were declared in this
* element. This does not include all prefix mappings in scope, so one
* may have to check ancestor elements to get all mappings that are in
* in scope. The prefixes must be passed in as a HashMap that maps
* namespace prefixes (String objects) to namespace URIs (also String).
+ *
* @param mapping The HashMap containing the mappings.
*/
protected void setPrefixMapping(HashMap mapping) {
@@ -268,6 +259,7 @@
* for this element. This does not include all prefix mappings in scope,
* so one may have to check ancestor elements to get all mappings that
are
* in in scope.
+ *
* @return Prefix mappings (for this element only).
*/
protected HashMap getPrefixMapping() {
@@ -276,254 +268,101 @@
/**
* Adds a single prefix mapping to this syntax tree node.
+ *
* @param prefix Namespace prefix.
* @param uri Namespace URI.
*/
protected void addPrefixMapping(String prefix, String uri) {
- if (_prefixMapping == null)
+ if (_prefixMapping == null) {
_prefixMapping = new HashMap();
- _prefixMapping.put(prefix, uri);
- }
-
- /**
- * Returns any namespace URI that is in scope for a given prefix. This
- * method checks namespace mappings for this element, and if necessary
- * for ancestor elements as well (ie. if the prefix maps to an URI in
this
- * scope then you'll definately get the URI from this method).
- * @param prefix Namespace prefix.
- * @return Namespace URI.
- */
- protected String lookupNamespace(String prefix) {
- // Initialise the output (default is 'null' for undefined)
- String uri = null;
-
- // First look up the prefix/uri mapping in our own hashtable...
- if (_prefixMapping != null)
- uri = (String)_prefixMapping.get(prefix);
- // ... but if we can't find it there we ask our parent for the mapping
- if ((uri == null) && (_parent != null)) {
- uri = _parent.lookupNamespace(prefix);
- if ((prefix == Constants.EMPTYSTRING) && (uri == null))
- uri = Constants.EMPTYSTRING;
}
- // ... and then we return whatever URI we've got.
- return(uri);
- }
-
- /**
- * Returns any namespace prefix that is mapped to a prefix in the current
- * scope. This method checks namespace mappings for this element, and if
- * necessary for ancestor elements as well (ie. if the URI is declared
- * within the current scope then you'll definately get the prefix from
- * this method). Note that this is a very slow method and consequentially
- * it should only be used strictly when needed.
- * @param uri Namespace URI.
- * @return Namespace prefix.
- */
- protected String lookupPrefix(String uri) {
- // Initialise the output (default is 'null' for undefined)
- String prefix = null;
-
- // First look up the prefix/uri mapping in our own hashtable...
- if ((_prefixMapping != null) &&
- (_prefixMapping.containsValue(uri))) {
- Iterator prefixes = _prefixMapping.keySet().iterator();
- while (prefixes.hasNext()) {
- prefix = (String)prefixes.next();
- String mapsTo = (String)_prefixMapping.get(prefix);
- if (mapsTo.equals(uri)) return(prefix);
- }
- }
- // ... but if we can't find it there we ask our parent for the mapping
- else if (_parent != null) {
- prefix = _parent.lookupPrefix(uri);
- if ((uri == Constants.EMPTYSTRING) && (prefix == null))
- prefix = Constants.EMPTYSTRING;
- }
- return(prefix);
- }
-
- /**
- * Set this node's parser. The parser (the XSLT parser) gives this
- * syntax tree node access to the symbol table and XPath parser.
- * @param parser The XSLT parser.
- */
- protected void setParser(Parser parser) {
- _parser = parser;
+ _prefixMapping.put(prefix, uri);
}
- /**
- * Returns this node's XSLT parser.
- * @return The XSLT parser.
- */
- public final Parser getParser() {
- return _parser;
- }
+ // -- Node's parent ----------------------------------------------
/**
- * Set this syntax tree node's parent node
+ * Set this syntax tree node's parent node.
+ *
* @param parent The parent node.
*/
protected void setParent(SyntaxTreeNode parent) {
- if (_parent == null)
- _parent = parent;
+ _parent = parent;
}
/**
* Returns this syntax tree node's parent node.
+ *
* @return The parent syntax tree node.
*/
protected final SyntaxTreeNode getParent() {
return _parent;
}
- /**
- * Returns 'true' if this syntax tree node is the Sentinal node.
- * @return 'true' if this syntax tree node is the Sentinal node.
- */
- protected final boolean isDummy() {
- return this == Dummy;
- }
-
- /**
- * Get the import precedence of this element. The import precedence
equals
- * the import precedence of the stylesheet in which this element occured.
- * @return The import precedence of this syntax tree node.
- */
- protected int getImportPrecedence() {
- Stylesheet stylesheet = getStylesheet();
- if (stylesheet == null) return Integer.MIN_VALUE;
- return stylesheet.getImportPrecedence();
- }
-
- /**
- * Get the Stylesheet node that represents the <xsl:stylesheet/> element
- * that this node occured under.
- * @return The Stylesheet ancestor node of this node.
- */
- public Stylesheet getStylesheet() {
- if (_stylesheet == null) {
- SyntaxTreeNode parent = this;
- while (parent != null) {
- if (parent instanceof Stylesheet)
- return((Stylesheet)parent);
- parent = parent.getParent();
- }
- _stylesheet = (Stylesheet)parent;
- }
- return(_stylesheet);
- }
-
- /**
- * Get the Template node that represents the <xsl:template/> element
- * that this node occured under. Note that this method will return 'null'
- * for nodes that represent top-level elements.
- * @return The Template ancestor node of this node or 'null'.
- */
- protected Template getTemplate() {
- if (_template == null) {
- SyntaxTreeNode parent = this;
- while ((parent != null) && (!(parent instanceof Template)))
- parent = parent.getParent();
- _template = (Template)parent;
- }
- return(_template);
- }
-
- /**
- * Returns a reference to the XSLTC (XSLT compiler) in use.
- * @return XSLTC - XSLT compiler.
- */
- protected final XSLTC getXSLTC() {
- return _parser.getXSLTC();
- }
-
- /**
- * Returns the XSLT parser's symbol table.
- * @return Symbol table.
- */
- protected final SymbolTable getSymbolTable() {
- return (_parser == null) ? null : _parser.getSymbolTable();
- }
+ // -- parse() ----------------------------------------------
/**
* Parse the contents of this syntax tree nodes (child nodes, XPath
- * expressions, patterns and functions). The default behaviour is to
parser
- * the syntax tree node's children (since there are no common
expressions,
- * patterns, etc. that can be handled in this base class.
- * @param parser reference to the XSLT parser
+ * expressions, patterns and functions). The default behaviour is to
+ * parser the syntax tree node's children.
*/
- public void parseContents(Parser parser) {
- parseChildren(parser);
+ public void parse(CompilerContext ccontext) {
+ parseContents(ccontext);
}
/**
* Parse all children of this syntax tree node. This method is normally
- * called by the parseContents() method.
- * @param parser reference to the XSLT parser
+ * called by the parse() method.
*/
- protected final void parseChildren(Parser parser) {
-
- ArrayList locals = null; // only create when needed
+ protected final void parseContents(CompilerContext ccontext) {
+ ArrayList locals = null;
+ StaticContextImpl scontext = getStaticContext();
final int count = _contents.size();
- for (int i=0; i<count; i++) {
- SyntaxTreeNode child = (SyntaxTreeNode)_contents.get(i);
- parser.getSymbolTable().setCurrentNode(child);
- child.parseContents(parser);
- // if variable or parameter, add it to scope
- final QName varOrParamName = updateScope(parser, child);
- if (varOrParamName != null) {
- if (locals == null) {
- locals = new ArrayList(2);
- }
- locals.add(varOrParamName);
- }
+ for (int i = 0; i < count; i++) {
+ SyntaxTreeNode child = (SyntaxTreeNode) _contents.get(i);
+ child.parse(ccontext);
+
+ // Is variable or parameter?
+ if (child instanceof VariableBase) {
+ final VariableBase var = (VariableBase) child;
+ scontext.addVariable(var);
+ if (locals == null) {
+ locals = new ArrayList(2);
+ }
+ // Collect all var names to be removed
+ locals.add(var.getName());
+ }
}
- parser.getSymbolTable().setCurrentNode(this);
-
- // after the last element, remove any locals from scope
+ // After the last node, remove any locals from scope
if (locals != null) {
final int nLocals = locals.size();
for (int i = 0; i < nLocals; i++) {
- parser.removeVariable((QName)locals.get(i));
+ scontext.removeVariable((QName) locals.get(i));
}
}
}
- /**
- * Add a node to the current scope and return name of a variable or
- * parameter if the node represents a variable or a parameter.
- */
- protected QName updateScope(Parser parser, SyntaxTreeNode node) {
- if (node instanceof Variable) {
- final Variable var = (Variable)node;
- parser.addVariable(var);
- return var.getName();
- }
- else if (node instanceof Param) {
- final Param param = (Param)node;
- parser.addParameter(param);
- return param.getName();
- }
- else {
- return null;
- }
- }
+ // -- typeCheck() ---------------------------------------------------
/**
- * Type check the children of this node. The type check phase may add
- * coercions (CastExpr) to the AST.
+ * Type check the children of this node. The type check phase may
+ * add coercions (CastExpr) to the AST.
+ *
* @param stable The compiler/parser's symbol table
*/
- public abstract Type typeCheck(SymbolTable stable) throws TypeCheckError;
+ public abstract Type typeCheck(SymbolTable stable)
+ throws TypeCheckError;
/**
* Call typeCheck() on all child syntax tree nodes.
+ *
* @param stable The compiler/parser's symbol table
*/
- protected Type typeCheckContents(SymbolTable stable) throws
TypeCheckError {
+ protected Type typeCheckContents(SymbolTable stable)
+ throws TypeCheckError
+ {
final int n = elementCount();
for (int i = 0; i < n; i++) {
SyntaxTreeNode item = (SyntaxTreeNode)_contents.get(i);
@@ -532,8 +371,11 @@
return Type.Void;
}
+ // -- translate() ---------------------------------------------------
+
/**
* Translate this abstract syntax tree node into JVM bytecodes.
+ *
* @param classGen BCEL Java class generator
* @param methodGen BCEL Java method generator
*/
@@ -542,6 +384,7 @@
/**
* Call translate() on all child syntax tree nodes.
+ *
* @param classGen BCEL Java class generator
* @param methodGen BCEL Java method generator
*/
@@ -567,109 +410,28 @@
}
}
+ // -- Node's import precedence -----------------------------------
+
/**
- * Utility method used by parameters and variables to store result trees
- * @param classGen BCEL Java class generator
- * @param methodGen BCEL Java method generator
+ * Get the import precedence of this element. The import precedence
equals
+ * the import precedence of the stylesheet in which this element occured.
+ * @return The import precedence of this syntax tree node.
*/
- protected void compileResultTree(ClassGenerator classGen,
- MethodGenerator methodGen)
- {
- final ConstantPoolGen cpg = classGen.getConstantPool();
- final InstructionList il = methodGen.getInstructionList();
- final Stylesheet stylesheet = classGen.getStylesheet();
-
- // Save the current handler base on the stack
- il.append(methodGen.loadHandler());
-
- final String DOM_CLASS = classGen.getDOMClass();
-
- // Create new instance of DOM class
- int index = cpg.addMethodref(DOM_IMPL, "<init>", "(I)V");
- il.append(new NEW(cpg.addClass(DOM_IMPL)));
- il.append(DUP);
- il.append(DUP);
- il.append(new PUSH(cpg, RTF_INITIAL_SIZE));
- il.append(new INVOKESPECIAL(index));
-
- // Overwrite old handler with DOM handler
- index = cpg.addMethodref(DOM_IMPL,
- "getOutputDomBuilder",
- "()" + TRANSLET_OUTPUT_SIG);
-
- il.append(new INVOKEVIRTUAL(index));
- il.append(DUP);
- il.append(methodGen.storeHandler());
-
- // Call startDocument on the new handler
- il.append(methodGen.startDocument());
-
- // Instantiate result tree fragment
- translateContents(classGen, methodGen);
-
- // Call endDocument on the new handler
- il.append(methodGen.loadHandler());
- il.append(methodGen.endDocument());
-
- // Check if we need to wrap the DOMImpl object in a DOMAdapter object
- if (!DOM_CLASS.equals(DOM_IMPL_CLASS)) {
- // new org.apache.xalan.xsltc.dom.DOMAdapter(DOMImpl,String[]);
- index = cpg.addMethodref(DOM_ADAPTER_CLASS,
- "<init>",
- "("+DOM_IMPL_SIG+
- "["+STRING_SIG+
- "["+STRING_SIG+")V");
- il.append(new NEW(cpg.addClass(DOM_ADAPTER_CLASS)));
- il.append(new DUP_X1());
- il.append(SWAP);
-
- /*
- * Give the DOM adapter an empty type mapping if the nodeset
- * extension function is never called.
- */
- if (!stylesheet.callsNodeset()) {
- il.append(new ICONST(0));
- il.append(new ANEWARRAY(cpg.addClass(STRING)));
- il.append(DUP);
- il.append(new INVOKESPECIAL(index));
- }
- else {
- // Push name arrays on the stack
- il.append(ALOAD_0);
- il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS,
- NAMES_INDEX,
- NAMES_INDEX_SIG)));
- il.append(ALOAD_0);
- il.append(new GETFIELD(cpg.addFieldref(TRANSLET_CLASS,
- NAMESPACE_INDEX,
- NAMESPACE_INDEX_SIG)));
-
- // Initialized DOM adapter
- il.append(new INVOKESPECIAL(index));
-
- // Add DOM adapter to MultiDOM class by calling addDOMAdapter()
- il.append(DUP);
- il.append(methodGen.loadDOM());
- il.append(new CHECKCAST(cpg.addClass(classGen.getDOMClass())));
- il.append(SWAP);
- index = cpg.addMethodref(MULTI_DOM_CLASS,
- "addDOMAdapter",
- "(" + DOM_ADAPTER_SIG + ")I");
- il.append(new INVOKEVIRTUAL(index));
- il.append(POP); // ignore mask returned by addDOMAdapter
- }
- }
-
- // Restore old handler base from stack
- il.append(SWAP);
- il.append(methodGen.storeHandler());
+ protected int getImportPrecedence() {
+ Stylesheet stylesheet = getStylesheet();
+ if (stylesheet == null) return Integer.MIN_VALUE;
+ return stylesheet.getImportPrecedence();
}
+ // -- Dependency on evaluation context ------------------------------
+
/**
- * Returns true if this expression/instruction depends on the context. By
- * default, every expression/instruction depends on the context unless it
- * overrides this method. Currently used to determine if result trees are
- * compiled using procedures or little DOMs (result tree fragments).
+ * Returns true if this expression/instruction depends on the context.
+ * By default, every expression/instruction depends on the context
+ * unless it overrides this method. Currently used to determine if
+ * result trees are compiled using procedures or little DOMs (result
+ * tree fragments).
+ *
* @return 'true' if this node depends on the context.
*/
protected boolean contextDependent() {
@@ -677,8 +439,9 @@
}
/**
- * Return true if any of the expressions/instructions in the contents of
- * this node is context dependent.
+ * Return true if any of the expressions/instructions in the contents
+ * of this node is context dependent.
+ *
* @return 'true' if the contents of this node is context dependent.
*/
protected boolean dependentContents() {
@@ -692,61 +455,63 @@
return false;
}
+ // -- Adding/removing children --------------------------------------
+
/**
- * Adds a child node to this syntax tree node.
+ * Adds a child node to this syntax tree node. The node will be
+ * appended to the contents list.
+ *
* @param element is the new child node.
*/
- protected final void add(SyntaxTreeNode element) {
- _contents.add(element);
- element.setParent(this);
+ protected final void add(SyntaxTreeNode node) {
+ _contents.add(node);
+ node.setParent(this);
}
/**
- * Inserts the first child node of this syntax tree node. The existing
- * children are shifted back one position.
+ * Inserts a node at a given position by shifting zero or more
+ * nodes.
+ *
* @param element is the new child node.
*/
- protected final void setFirstElement(SyntaxTreeNode element) {
- _contents.set(0, element);
- element.setParent(this);
+ protected final void add(int index, SyntaxTreeNode node) {
+ _contents.add(index, node);
+ node.setParent(this);
}
/**
* Removed a child node of this syntax tree node.
+ *
* @param element is the child node to remove.
*/
- protected final void removeElement(SyntaxTreeNode element) {
- _contents.remove(element);
- element.setParent(null);
+ protected final void remove(SyntaxTreeNode node) {
+ _contents.remove(node);
+ node.setParent(null);
}
/**
- * Returns a ArrayList containing all the child nodes of this node.
- * @return A ArrayList containing all the child nodes of this node.
+ * Returns a ArrayList containing all the children nodes.
*/
protected final ArrayList getContents() {
return _contents;
}
/**
- * Tells you if this node has any child nodes.
- * @return 'true' if this node has any children.
+ * Queries a node to see if it has any children.
*/
protected final boolean hasContents() {
- return elementCount() > 0;
+ return (elementCount() > 0);
}
/**
* Returns the number of children this node has.
- * @return Number of child nodes.
*/
protected final int elementCount() {
return _contents.size();
}
/**
- * Returns an Iterator of all child nodes of this node.
- * @return An Iterator of all child nodes of this node.
+ * Returns an Iterator containing all the children nodes.
*/
protected final Iterator iterator() {
return _contents.iterator();
@@ -754,88 +519,86 @@
/**
* Returns a child node at a given position.
+ *
* @param pos The child node's position.
- * @return The child node.
*/
- protected final Object get(int pos) {
- return _contents.get(pos);
+ protected final SyntaxTreeNode get(int n) {
+ return (SyntaxTreeNode) _contents.get(n);
}
- /**
- * Returns this element's last child
- * @return The child node.
- */
- protected final SyntaxTreeNode lastChild() {
- final int n = _contents.size();
- if (n == 0) return null;
- return (SyntaxTreeNode)_contents.get(n);
- }
+ // -- Convenient methods to get compiler/static contexts ------------
/**
- * Displays the contents of this syntax tree node (to stdout).
- * This method is intended for debugging _only_, and should be overridden
- * by all syntax tree node implementations.
- * @param indent Indentation level for syntax tree levels.
+ * Returns a reference to the static context using this node as
+ * current.
*/
- public void display(int indent) {
- displayContents(indent);
+ public StaticContextImpl getStaticContext() {
+ return StaticContextImpl.getInstance(this);
}
/**
- * Displays the contents of this syntax tree node (to stdout).
- * This method is intended for debugging _only_ !!!
- * @param indent Indentation level for syntax tree levels.
+ * Returns a reference to the compiler context.
*/
- protected void displayContents(int indent) {
- final int n = elementCount();
- for (int i = 0; i < n; i++) {
- SyntaxTreeNode item = (SyntaxTreeNode)_contents.get(i);
- item.display(indent);
- }
+ public CompilerContextImpl getCompilerContext() {
+ return CompilerContextImpl.getInstance();
}
- /**
- * Set the indentation level for debug output.
- * @param indent Indentation level for syntax tree levels.
- */
- protected final void indent(int indent) {
- System.out.print(new String(_spaces, 0, indent));
- }
+ // -------------------------------------------------------------------
+ // -- The following are just TEMPS - should go away -----------------
+ // -------------------------------------------------------------------
- /**
- * Report an error to the parser.
- * @param element The element in which the error occured (normally 'this'
- * but it could also be an expression/pattern/etc.)
- * @param parser The XSLT parser to report the error to.
- * @param error The error code (from util/ErrorMsg).
- * @param message Any additional error message.
- */
+ // TEMP - this should go away !
protected void reportError(SyntaxTreeNode element, Parser parser,
int errorCode, String message) {
final ErrorMsg error = new ErrorMsg(errorCode, message, element);
parser.reportError(Constants.ERROR, error);
}
- /**
- * Report a recoverable error to the parser.
- * @param element The element in which the error occured (normally 'this'
- * but it could also be an expression/pattern/etc.)
- * @param parser The XSLT parser to report the error to.
- * @param error The error code (from util/ErrorMsg).
- * @param message Any additional error message.
- */
+ // TEMP - this should go away !
protected void reportWarning(SyntaxTreeNode element, Parser parser,
int errorCode, String message) {
final ErrorMsg error = new ErrorMsg(errorCode, message, element);
parser.reportError(Constants.WARNING, error);
}
- // -- Pretty printing ------------------------------------------------
- // These two are used for indenting nodes in the AST (debug output)
- protected static final int IndentIncrement = 4;
- private static final char[] _spaces =
- "
".toCharArray();
+ // TEMP - this should go away !
+ public final Parser getParser() {
+ return CompilerContextImpl.getInstance().getParser();
+ }
+ // TEMP - this should go away !
+ protected final XSLTC getXSLTC() {
+ return getCompilerContext().getXSLTC();
+ }
+
+ // TEMP - this should go away !
+ protected final SymbolTable getSymbolTable() {
+ return null;
+ }
-}
+ // TEMP - this should go away !
+ protected Template getTemplate() {
+ return getStaticContext().getCurrentTemplate();
+ }
+
+ // TEMP - this should go away !
+ public Stylesheet getStylesheet() {
+ return getStaticContext().getStylesheet();
+ }
+
+ // TEMP - this should go away !
+ protected String lookupNamespace(String prefix) {
+ return getStaticContext().getNamespace(prefix);
+ }
+
+ // TEMP - this should go away !
+ protected String lookupPrefix(String uri) {
+ return getStaticContext().getPrefix(uri);
+ }
+
+ // TEMP - this should go away !
+ protected void compileResultTree(ClassGenerator classGen,
+ MethodGenerator methodGen) {
+ }
+}
\ No newline at end of file
1.17.2.1.2.3 +8 -25
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Template.java
Index: Template.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Template.java,v
retrieving revision 1.17.2.1.2.2
retrieving revision 1.17.2.1.2.3
diff -u -r1.17.2.1.2.2 -r1.17.2.1.2.3
--- Template.java 10 Jan 2003 16:50:42 -0000 1.17.2.1.2.2
+++ Template.java 13 Jan 2003 22:02:53 -0000 1.17.2.1.2.3
@@ -157,26 +157,7 @@
return 0;
}
- public void display(int indent) {
- Util.println('\n');
- indent(indent);
- if (_name != null) {
- indent(indent);
- Util.println("name = " + _name);
- }
- else if (_pattern != null) {
- indent(indent);
- Util.println("match = " + _pattern.toString());
- }
- if (_mode != null) {
- indent(indent);
- Util.println("mode = " + _mode);
- }
- displayContents(indent + IndentIncrement);
- }
-
private boolean resolveNamedTemplates(Template other, Parser parser) {
-
if (other == null) return true;
SymbolTable stable = parser.getSymbolTable();
@@ -204,12 +185,12 @@
return _stylesheet;
}
- public void parseContents(Parser parser) {
-
+ public void parse(CompilerContext ccontext) {
final String name = getAttribute("name");
final String mode = getAttribute("mode");
final String match = getAttribute("match");
final String priority = getAttribute("priority");
+ final Parser parser = ccontext.getParser();
_stylesheet = super.getStylesheet();
@@ -248,7 +229,7 @@
}
parser.setTemplate(this); // set current template
- parseChildren(parser);
+ parseContents(ccontext);
parser.setTemplate(null); // clear template
}
@@ -264,7 +245,9 @@
* o) set the empty Stylesheet as our parent
* o) set this template as the Stylesheet's only child
*/
- public void parseSimplified(Stylesheet stylesheet, Parser parser) {
+ public void parseSimplified(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
+ final Stylesheet stylesheet = getStaticContext().getStylesheet();
_stylesheet = stylesheet;
setParent(stylesheet);
@@ -282,7 +265,7 @@
root.setParent(this);
contents.set(0, this);
parser.setTemplate(this);
- root.parseContents(parser);
+ root.parse(ccontext);
parser.setTemplate(null);
}
}
1.12.2.1.2.2 +5 -10
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Text.java
Index: Text.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Text.java,v
retrieving revision 1.12.2.1.2.1
retrieving revision 1.12.2.1.2.2
diff -u -r1.12.2.1.2.1 -r1.12.2.1.2.2
--- Text.java 10 Jan 2003 16:50:42 -0000 1.12.2.1.2.1
+++ Text.java 13 Jan 2003 22:02:53 -0000 1.12.2.1.2.2
@@ -112,18 +112,13 @@
_text = _text + text;
}
- public void display(int indent) {
- indent(indent);
- Util.println("Text");
- indent(indent + IndentIncrement);
- Util.println(_text);
- }
-
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
+
final String str = getAttribute("disable-output-escaping");
if ((str != null) && (str.equals("yes"))) _escaping = false;
- parseChildren(parser);
+ parseContents(ccontext);
if (_text == null) {
if (_textElement) {
1.4.8.1.2.2 +2 -8
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/TopLevelElement.java
Index: TopLevelElement.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/TopLevelElement.java,v
retrieving revision 1.4.8.1.2.1
retrieving revision 1.4.8.1.2.2
diff -u -r1.4.8.1.2.1 -r1.4.8.1.2.2
--- TopLevelElement.java 10 Jan 2003 16:50:42 -0000 1.4.8.1.2.1
+++ TopLevelElement.java 13 Jan 2003 22:02:53 -0000 1.4.8.1.2.2
@@ -84,7 +84,7 @@
getClass(), this);
getParser().reportError(FATAL, msg);
}
-
+
/**
* Translate this node into a fresh instruction list.
* The original instruction list is saved and restored.
@@ -96,11 +96,5 @@
translate(classGen, methodGen);
methodGen.setInstructionList(save);
return result;
- }
-
- public void display(int indent) {
- indent(indent);
- Util.println("TopLevelElement");
- displayContents(indent + IndentIncrement);
}
}
1.7.8.1.2.2 +13 -19
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/TransletOutput.java
Index: TransletOutput.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/TransletOutput.java,v
retrieving revision 1.7.8.1.2.1
retrieving revision 1.7.8.1.2.2
diff -u -r1.7.8.1.2.1 -r1.7.8.1.2.2
--- TransletOutput.java 2 Dec 2002 15:51:18 -0000 1.7.8.1.2.1
+++ TransletOutput.java 13 Jan 2003 22:02:53 -0000 1.7.8.1.2.2
@@ -72,21 +72,15 @@
private boolean _append;
/**
- * Displays the contents of this <xsltc:output> element.
- */
- public void display(int indent) {
- indent(indent);
- Util.println("TransletOutput: " + _filename);
- }
-
- /**
* Parse the contents of this <xsltc:output> element. The only attribute
* we recognise is the 'file' attribute that contains teh output
filename.
*/
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
+
// Get the output filename from the 'file' attribute
String filename = getAttribute("file");
-
+
// If the 'append' attribute is set to "yes" or "true",
// the output is appended to the file.
String append = getAttribute("append");
@@ -98,17 +92,17 @@
// Save filename as an attribute value template
_filename = AttributeValue.create(this, filename, parser);
-
+
if (append != null && (append.toLowerCase().equals("yes") ||
append.toLowerCase().equals("true"))) {
- _append = true;
+ _append = true;
}
else
_append = false;
-
- parseChildren(parser);
+
+ parseContents(ccontext);
}
-
+
/**
* Type checks the 'file' attribute (must be able to convert it to a
str).
*/
@@ -120,7 +114,7 @@
typeCheckContents(stable);
return Type.Void;
}
-
+
/**
* Compile code that opens the give file for output, dumps the contents
of
* the element to the file, then closes the file.
@@ -131,7 +125,7 @@
// Save the current output handler on the stack
il.append(methodGen.loadHandler());
-
+
final int open = cpg.addMethodref(TRANSLET_CLASS,
"openOutputHandler",
"(" + STRING_SIG + "Z)" +
@@ -149,7 +143,7 @@
// Overwrite current handler
il.append(methodGen.storeHandler());
-
+
// Translate contents with substituted handler
translateContents(classGen, methodGen);
1.4.8.1.2.2 +5 -10
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/UnaryOpExpr.java
Index: UnaryOpExpr.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/UnaryOpExpr.java,v
retrieving revision 1.4.8.1.2.1
retrieving revision 1.4.8.1.2.2
diff -u -r1.4.8.1.2.1 -r1.4.8.1.2.2
--- UnaryOpExpr.java 10 Jan 2003 16:50:42 -0000 1.4.8.1.2.1
+++ UnaryOpExpr.java 13 Jan 2003 22:02:53 -0000 1.4.8.1.2.2
@@ -69,7 +69,7 @@
final class UnaryOpExpr extends Expression {
private Expression _left;
-
+
public UnaryOpExpr(Expression left) {
(_left = left).setParent(this);
}
@@ -82,17 +82,12 @@
return(_left.hasPositionCall());
}
- public void setParser(Parser parser) {
- super.setParser(parser);
- _left.setParser(parser);
- }
-
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
- final Type tleft = _left.typeCheck(stable);
+ final Type tleft = _left.typeCheck(stable);
final MethodType ptype = lookupPrimop(stable, "u-",
new MethodType(Type.Void,
- tleft));
-
+ tleft));
+
if (ptype != null) {
final Type arg1 = (Type) ptype.argsType().get(0);
if (!arg1.identicalTo(tleft)) {
1.6.8.1.2.2 +6 -8
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/UnionPathExpr.java
Index: UnionPathExpr.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/UnionPathExpr.java,v
retrieving revision 1.6.8.1.2.1
retrieving revision 1.6.8.1.2.2
diff -u -r1.6.8.1.2.1 -r1.6.8.1.2.2
--- UnionPathExpr.java 10 Jan 2003 16:50:42 -0000 1.6.8.1.2.1
+++ UnionPathExpr.java 13 Jan 2003 22:02:53 -0000 1.6.8.1.2.2
@@ -81,21 +81,19 @@
// linearization for top level UnionPathExprs
private Expression[] _components;
-
+
public UnionPathExpr(Expression pathExpr, Expression rest) {
_pathExpr = pathExpr;
_rest = rest;
}
- public void setParser(Parser parser) {
- super.setParser(parser);
+ public void setParent(Parser parser) {
// find all expressions in this Union
final ArrayList components = new ArrayList();
flatten(components);
final int size = components.size();
_components = (Expression[])components.toArray(new Expression[size]);
for (int i = 0; i < size; i++) {
- _components[i].setParser(parser);
_components[i].setParent(this);
if (_components[i] instanceof Step) {
final Step step = (Step)_components[i];
@@ -113,7 +111,7 @@
// No need to reverse anything if another expression lies on top of this
if (getParent() instanceof Expression) _reverse = false;
}
-
+
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
final int length = _components.length;
for (int i = 0; i < length; i++) {
@@ -121,13 +119,13 @@
_components[i] = new CastExpr(_components[i], Type.NodeSet);
}
}
- return _type = Type.NodeSet;
+ return _type = Type.NodeSet;
}
public String toString() {
return "union(" + _pathExpr + ", " + _rest + ')';
}
-
+
private void flatten(ArrayList components) {
components.add(_pathExpr);
if (_rest != null) {
1.3.8.1.2.2 +3 -14
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/UnsupportedElement.java
Index: UnsupportedElement.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/UnsupportedElement.java,v
retrieving revision 1.3.8.1.2.1
retrieving revision 1.3.8.1.2.2
diff -u -r1.3.8.1.2.1 -r1.3.8.1.2.2
--- UnsupportedElement.java 10 Jan 2003 16:50:42 -0000 1.3.8.1.2.1
+++ UnsupportedElement.java 13 Jan 2003 22:02:53 -0000 1.3.8.1.2.2
@@ -102,17 +102,6 @@
}
/**
- * Displays the contents of this element
- */
- public void display(int indent) {
- indent(indent);
- Util.println("Unsupported element = " + _qname.getNamespace() +
- ":" + _qname.getLocalPart());
- displayContents(indent + IndentIncrement);
- }
-
-
- /**
* Scan all descendants and find the first xsl:fallback element (if any)
*/
private SyntaxTreeNode findFallback(SyntaxTreeNode root) {
@@ -139,11 +128,11 @@
/**
* Find any fallback in the descendant nodes; then activate & parse it
*/
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
_fallback = (Fallback)findFallback(this);
if (_fallback != null) {
_fallback.activate();
- _fallback.parseContents(parser);
+ _fallback.parse(ccontext);
}
}
1.8.2.1.2.2 +2 -3
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/UseAttributeSets.java
Index: UseAttributeSets.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/UseAttributeSets.java,v
retrieving revision 1.8.2.1.2.1
retrieving revision 1.8.2.1.2.2
diff -u -r1.8.2.1.2.1 -r1.8.2.1.2.2
--- UseAttributeSets.java 10 Jan 2003 16:50:42 -0000 1.8.2.1.2.1
+++ UseAttributeSets.java 13 Jan 2003 22:02:53 -0000 1.8.2.1.2.2
@@ -86,7 +86,6 @@
* Constructur - define initial attribute sets to use
*/
public UseAttributeSets(String setNames, Parser parser) {
- setParser(parser);
addAttributeSets(setNames);
}
@@ -99,7 +98,7 @@
if ((setNames != null) && (!setNames.equals(Constants.EMPTYSTRING))) {
final StringTokenizer tokens = new StringTokenizer(setNames);
while (tokens.hasMoreTokens()) {
- final QName qname =
+ final QName qname =
getParser().getQNameIgnoreDefaultNs(tokens.nextToken());
_sets.add(qname);
}
1.7.8.1.2.1 +5 -11
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ValueOf.java
Index: ValueOf.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ValueOf.java,v
retrieving revision 1.7.8.1
retrieving revision 1.7.8.1.2.1
diff -u -r1.7.8.1 -r1.7.8.1.2.1
--- ValueOf.java 14 Aug 2002 19:21:34 -0000 1.7.8.1
+++ ValueOf.java 13 Jan 2003 22:02:53 -0000 1.7.8.1.2.1
@@ -73,15 +73,9 @@
final class ValueOf extends Instruction {
private Expression _select;
private boolean _escaping = true;
-
- public void display(int indent) {
- indent(indent);
- Util.println("ValueOf");
- indent(indent + IndentIncrement);
- Util.println("select " + _select.toString());
- }
-
- public void parseContents(Parser parser) {
+
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
_select = parser.parseExpression(this, "select", null);
// make sure required attribute(s) have been set
@@ -118,7 +112,7 @@
// Translate the contents.
il.append(classGen.loadTranslet());
- _select.translate(classGen, methodGen);
+ _select.translate(classGen, methodGen);
il.append(methodGen.loadHandler());
il.append(new INVOKEVIRTUAL(characters));
1.22.8.1.2.3 +6 -4
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Variable.java
Index: Variable.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Variable.java,v
retrieving revision 1.22.8.1.2.2
retrieving revision 1.22.8.1.2.3
diff -u -r1.22.8.1.2.2 -r1.22.8.1.2.3
--- Variable.java 10 Jan 2003 16:50:42 -0000 1.22.8.1.2.2
+++ Variable.java 13 Jan 2003 22:02:53 -0000 1.22.8.1.2.3
@@ -84,9 +84,11 @@
/**
* Parse the contents of the variable
*/
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
+
// Parse 'name' and 'select' attributes plus parameter contents
- super.parseContents(parser);
+ super.parse(ccontext);
// Add a ref to this var to its enclosing construct
SyntaxTreeNode parent = getParent();
@@ -205,7 +207,7 @@
// Global variables are store in class fields
if (classGen.containsField(name) == null) {
- classGen.addField(new Field(ACC_PUBLIC,
+ classGen.addField(new Field(ACC_PUBLIC,
cpg.addUtf8(name),
cpg.addUtf8(signature),
null, cpg.getConstantPool()));
1.16.2.1.2.2 +5 -16
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/VariableBase.java
Index: VariableBase.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/VariableBase.java,v
retrieving revision 1.16.2.1.2.1
retrieving revision 1.16.2.1.2.2
diff -u -r1.16.2.1.2.1 -r1.16.2.1.2.2
--- VariableBase.java 10 Jan 2003 16:50:43 -0000 1.16.2.1.2.1
+++ VariableBase.java 13 Jan 2003 22:02:53 -0000 1.16.2.1.2.2
@@ -191,19 +191,6 @@
}
/**
- * Display variable in a full AST dump
- */
- public void display(int indent) {
- indent(indent);
- System.out.println("Variable " + _name);
- if (_select != null) {
- indent(indent + IndentIncrement);
- System.out.println("select " + _select.toString());
- }
- displayContents(indent + IndentIncrement);
- }
-
- /**
* Returns the type of the variable
*/
public Type getType() {
@@ -244,7 +231,9 @@
/**
* Parse the contents of the <xsl:decimal-format> element.
*/
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
+
// Get the 'name attribute
String name = getAttribute("name");
if (name == null) name = EMPTYSTRING;
@@ -270,7 +259,7 @@
}
// Children must be parsed first -> static scoping
- parseChildren(parser);
+ parseContents(ccontext);
}
/**
1.10.2.1.2.2 +5 -12
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/When.java
Index: When.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/When.java,v
retrieving revision 1.10.2.1.2.1
retrieving revision 1.10.2.1.2.2
diff -u -r1.10.2.1.2.1 -r1.10.2.1.2.2
--- When.java 2 Dec 2002 15:51:19 -0000 1.10.2.1.2.1
+++ When.java 13 Jan 2003 22:02:53 -0000 1.10.2.1.2.2
@@ -71,15 +71,6 @@
private Expression _test;
private boolean _ignore = false;
- public void display(int indent) {
- indent(indent);
- Util.println("When");
- indent(indent + IndentIncrement);
- System.out.print("test ");
- Util.println(_test.toString());
- displayContents(indent + IndentIncrement);
- }
-
public Expression getTest() {
return _test;
}
@@ -88,7 +79,9 @@
return(_ignore);
}
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
+
_test = parser.parseExpression(this, "test", null);
// Ignore xsl:if when test is false (function-available() and
@@ -98,7 +91,7 @@
_ignore = !((Boolean) result).booleanValue();
}
- parseChildren(parser);
+ parseContents(ccontext);
// Make sure required attribute(s) have been set
if (_test.isDummy()) {
1.7.8.1.2.2 +4 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Whitespace.java
Index: Whitespace.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Whitespace.java,v
retrieving revision 1.7.8.1.2.1
retrieving revision 1.7.8.1.2.2
diff -u -r1.7.8.1.2.1 -r1.7.8.1.2.2
--- Whitespace.java 10 Jan 2003 16:50:43 -0000 1.7.8.1.2.1
+++ Whitespace.java 13 Jan 2003 22:02:53 -0000 1.7.8.1.2.2
@@ -159,7 +159,9 @@
* Parse the attributes of the xsl:strip/preserve-space element.
* The element should have not contents (ignored if any).
*/
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
+
// Determine if this is an xsl:strip- or preserve-space element
_action = _qname.getLocalPart().endsWith("strip-space")
? STRIP_SPACE : PRESERVE_SPACE;
1.10.8.1.2.1 +7 -18
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/WithParam.java
Index: WithParam.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/WithParam.java,v
retrieving revision 1.10.8.1
retrieving revision 1.10.8.1.2.1
diff -u -r1.10.8.1 -r1.10.8.1.2.1
--- WithParam.java 14 Aug 2002 19:21:34 -0000 1.10.8.1
+++ WithParam.java 13 Jan 2003 22:02:53 -0000 1.10.8.1.2.1
@@ -76,23 +76,12 @@
private Expression _select;
/**
- * Displays the contents of this element
- */
- public void display(int indent) {
- indent(indent);
- Util.println("with-param " + _name);
- if (_select != null) {
- indent(indent + IndentIncrement);
- Util.println("select " + _select.toString());
- }
- displayContents(indent + IndentIncrement);
- }
-
- /**
* The contents of a <xsl:with-param> elements are either in the
element's
* 'select' attribute (this has precedence) or in the element body.
*/
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
+
final String name = getAttribute("name");
if (name.length() > 0) {
_name = parser.getQName(name);
@@ -100,13 +89,13 @@
else {
reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "name");
}
-
+
final String select = getAttribute("select");
if (select.length() > 0) {
_select = parser.parseExpression(this, "select", null);
}
-
- parseChildren(parser);
+
+ parseContents(ccontext);
}
/**
1.42.2.1.2.3 +5 -1
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java
Index: XSLTC.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java,v
retrieving revision 1.42.2.1.2.2
retrieving revision 1.42.2.1.2.3
diff -u -r1.42.2.1.2.2 -r1.42.2.1.2.3
--- XSLTC.java 10 Jan 2003 16:50:43 -0000 1.42.2.1.2.2
+++ XSLTC.java 13 Jan 2003 22:02:53 -0000 1.42.2.1.2.3
@@ -162,6 +162,10 @@
_parser = new Parser(this);
}
+ public Parser getParser() {
+ return _parser;
+ }
+
/**
* Only for user by the internal TrAX implementation.
*/
1.18.2.1.2.2 +10 -18
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XslAttribute.java
Index: XslAttribute.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XslAttribute.java,v
retrieving revision 1.18.2.1.2.1
retrieving revision 1.18.2.1.2.2
diff -u -r1.18.2.1.2.1 -r1.18.2.1.2.2
--- XslAttribute.java 10 Jan 2003 16:50:43 -0000 1.18.2.1.2.1
+++ XslAttribute.java 13 Jan 2003 22:02:53 -0000 1.18.2.1.2.2
@@ -86,19 +86,11 @@
}
/**
- * Displays the contents of the attribute
- */
- public void display(int indent) {
- indent(indent);
- Util.println("Attribute " + _name);
- displayContents(indent + IndentIncrement);
- }
-
- /**
* Parses the attribute's contents. Special care taken for namespaces.
*/
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
boolean generated = false;
+ final Parser parser = ccontext.getParser();
final SymbolTable stable = parser.getSymbolTable();
String name = getAttribute("name");
@@ -147,7 +139,7 @@
_namespace = new AttributeValueTemplate(namespace, parser,
this);
}
}
-
+
// Common handling for namespaces:
if (_namespace != null) {
// Generate prefix if we have none
@@ -167,9 +159,9 @@
name = _prefix + ":" + qname.getLocalPart();
/*
- * TODO: The namespace URI must be passed to the parent
- * element but we don't yet know what the actual URI is
- * (as we only know it as an attribute value template).
+ * TODO: The namespace URI must be passed to the parent
+ * element but we don't yet know what the actual URI is
+ * (as we only know it as an attribute value template).
*/
if ((parent instanceof LiteralElement) && (!generated)) {
((LiteralElement)parent).registerNamespace(_prefix,
@@ -188,9 +180,9 @@
}
_name = AttributeValue.create(this, name, parser);
- parseChildren(parser);
+ parseContents(ccontext);
}
-
+
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
if (!_ignore) {
_name.typeCheck(stable);
@@ -224,7 +216,7 @@
// Save the current handler base on the stack
il.append(methodGen.loadHandler());
il.append(DUP); // first arg to "attributes" call
-
+
// Push attribute name
_name.translate(classGen, methodGen);// 2nd arg
1.17.2.1.2.3 +16 -24
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XslElement.java
Index: XslElement.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XslElement.java,v
retrieving revision 1.17.2.1.2.2
retrieving revision 1.17.2.1.2.3
diff -u -r1.17.2.1.2.2 -r1.17.2.1.2.3
--- XslElement.java 10 Jan 2003 16:50:43 -0000 1.17.2.1.2.2
+++ XslElement.java 13 Jan 2003 22:02:53 -0000 1.17.2.1.2.3
@@ -77,19 +77,10 @@
private String _prefix;
private boolean _ignore = false;
private boolean _isLiteralName = true;
- private AttributeValueTemplate _name;
+ private AttributeValueTemplate _name;
private AttributeValueTemplate _namespace;
/**
- * Displays the contents of the element
- */
- public void display(int indent) {
- indent(indent);
- Util.println("Element " + _name);
- displayContents(indent + IndentIncrement);
- }
-
- /**
* This method is now deprecated. The new implemation of this class
* never declares the default NS.
*/
@@ -112,7 +103,7 @@
/**
* Simple check to determine if qname is legal. If it returns false
- * then <param>str</param> is illegal; if it returns true then
+ * then <param>str</param> is illegal; if it returns true then
* <param>str</param> may or may not be legal.
*/
private boolean isLegalName(String str) {
@@ -130,7 +121,8 @@
return true;
}
- public void parseContents(Parser parser) {
+ public void parse(CompilerContext ccontext) {
+ final Parser parser = ccontext.getParser();
final SymbolTable stable = parser.getSymbolTable();
// Handle the 'name' attribute
@@ -139,7 +131,7 @@
ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_ELEM_NAME_ERR,
name, this);
parser.reportError(WARNING, msg);
- parseChildren(parser);
+ parseContents(ccontext);
_ignore = true; // Ignore the element if the QName is invalid
return;
}
@@ -154,7 +146,7 @@
ErrorMsg msg = new ErrorMsg(ErrorMsg.ILLEGAL_ELEM_NAME_ERR,
name, this);
parser.reportError(WARNING, msg);
- parseChildren(parser);
+ parseContents(ccontext);
_ignore = true; // Ignore the element if the QName is
invalid
return;
}
@@ -162,18 +154,18 @@
final QName qname = parser.getQNameSafe(name);
String prefix = qname.getPrefix();
String local = qname.getLocalPart();
-
+
if (prefix == null) {
prefix = EMPTYSTRING;
}
if (!hasAttribute("namespace")) {
- namespace = lookupNamespace(prefix);
+ namespace = lookupNamespace(prefix);
if (namespace == null) {
ErrorMsg err = new ErrorMsg(ErrorMsg.NAMESPACE_UNDEF_ERR,
prefix, this);
parser.reportError(WARNING, err);
- parseChildren(parser);
+ parseContents(ccontext);
_ignore = true; // Ignore the element if prefix is
undeclared
return;
}
@@ -209,10 +201,10 @@
final String useSets = getAttribute("use-attribute-sets");
if (useSets.length() > 0) {
- setFirstElement(new UseAttributeSets(useSets, parser));
+ add(0, new UseAttributeSets(useSets, parser));
}
- parseChildren(parser);
+ parseContents(ccontext);
}
/**
@@ -264,7 +256,7 @@
* evaluates the avt for the name, (ii) checks for a prefix in the name
* (iii) generates a new prefix and create a new qname when necessary
* (iv) calls startElement() on the handler (v) looks up a uri in the XML
- * when the prefix is not known at compile time (vi) calls namespace()
+ * when the prefix is not known at compile time (vi) calls namespace()
* on the handler (vii) evaluates the contents (viii) calls endElement().
*/
public void translate(ClassGenerator classGen, MethodGenerator
methodGen) {
@@ -299,9 +291,9 @@
// Invoke BasisLibrary.startXslElement()
il.append(new INVOKESTATIC(
cpg.addMethodref(BASIS_LIBRARY_CLASS, "startXslElement",
- "(" + STRING_SIG
- + STRING_SIG
- + TRANSLET_OUTPUT_SIG
+ "(" + STRING_SIG
+ + STRING_SIG
+ + TRANSLET_OUTPUT_SIG
+ DOM_INTF_SIG + "I)" + STRING_SIG)));
}
No revision
No revision
1.1.2.1 +92 -0
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Attic/CompilerContext.java
1.1.2.1 +173 -0
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Attic/CompilerContextImpl.java
1.1.2.1 +177 -0
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Attic/StaticContext.java
1.1.2.1 +545 -0
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Attic/StaticContextImpl.java
No revision
No revision
1.1.2.2 +13 -5
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath/Attic/XPathParser.java
Index: XPathParser.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath/Attic/XPathParser.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- XPathParser.java 5 Dec 2002 20:27:16 -0000 1.1.2.1
+++ XPathParser.java 13 Jan 2003 22:02:59 -0000 1.1.2.2
@@ -64,6 +64,7 @@
import java.io.StringReader;
import org.apache.xpath.parser.*;
+import org.apache.xpath.Expression;
public class XPathParser {
@@ -93,12 +94,19 @@
public static void main(String[] args) {
try {
- Node tree;
+ SimpleNode tree;
System.out.println("AST = " +
(tree = new XPathParser().parseExpression("a/b")));
- ((SimpleNode)tree.jjtGetChild(0)).dump("|") ;
- System.out.println("done");
- }
+ tree = (SimpleNode) tree.jjtGetChild(0);
+ tree.dump("|");
+
+ System.out.println("\n------------------\n");
+
+ if (tree instanceof Expression) {
+ SimpleXPathVisitor visitor = new SimpleXPathVisitor();
+ ((Expression) tree).callVisitors(null, visitor);
+ }
+ }
catch (Exception e) {
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]