You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(107) |
Dec
(67) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(76) |
Feb
(125) |
Mar
(72) |
Apr
(13) |
May
(18) |
Jun
(12) |
Jul
(129) |
Aug
(47) |
Sep
(1) |
Oct
(36) |
Nov
(128) |
Dec
(124) |
2002 |
Jan
(59) |
Feb
|
Mar
(14) |
Apr
(14) |
May
(72) |
Jun
(9) |
Jul
(3) |
Aug
(5) |
Sep
(18) |
Oct
(65) |
Nov
(28) |
Dec
(12) |
2003 |
Jan
(10) |
Feb
(2) |
Mar
(4) |
Apr
(33) |
May
(21) |
Jun
(9) |
Jul
(29) |
Aug
(34) |
Sep
(4) |
Oct
(8) |
Nov
(15) |
Dec
(4) |
2004 |
Jan
(26) |
Feb
(12) |
Mar
(11) |
Apr
(9) |
May
(7) |
Jun
|
Jul
(5) |
Aug
|
Sep
(3) |
Oct
(7) |
Nov
(1) |
Dec
(10) |
2005 |
Jan
(2) |
Feb
(72) |
Mar
(16) |
Apr
(39) |
May
(48) |
Jun
(97) |
Jul
(57) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(100) |
Dec
(24) |
2006 |
Jan
(15) |
Feb
(34) |
Mar
(33) |
Apr
(31) |
May
(79) |
Jun
(64) |
Jul
(41) |
Aug
(64) |
Sep
(31) |
Oct
(46) |
Nov
(55) |
Dec
(37) |
2007 |
Jan
(32) |
Feb
(61) |
Mar
(11) |
Apr
(58) |
May
(46) |
Jun
(30) |
Jul
(94) |
Aug
(93) |
Sep
(86) |
Oct
(69) |
Nov
(125) |
Dec
(177) |
2008 |
Jan
(169) |
Feb
(97) |
Mar
(74) |
Apr
(113) |
May
(120) |
Jun
(334) |
Jul
(215) |
Aug
(237) |
Sep
(72) |
Oct
(189) |
Nov
(126) |
Dec
(160) |
2009 |
Jan
(180) |
Feb
(45) |
Mar
(98) |
Apr
(140) |
May
(151) |
Jun
(71) |
Jul
(107) |
Aug
(119) |
Sep
(73) |
Oct
(121) |
Nov
(14) |
Dec
(6) |
2010 |
Jan
(13) |
Feb
(9) |
Mar
(10) |
Apr
(64) |
May
(3) |
Jun
(16) |
Jul
(7) |
Aug
(23) |
Sep
(17) |
Oct
(37) |
Nov
(5) |
Dec
(8) |
2011 |
Jan
(10) |
Feb
(11) |
Mar
(77) |
Apr
(11) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <fwi...@us...> - 2008-11-22 19:18:57
|
Revision: 5598 http://jython.svn.sourceforge.net/jython/?rev=5598&view=rev Author: fwierzbicki Date: 2008-11-22 19:18:53 +0000 (Sat, 22 Nov 2008) Log Message: ----------- Fixes bug http://bugs.jython.org/issue1174 which reveals a corner case where CompilerFlags can come out as null. Not positive that we should be passing the "flags" value down when there is no frame, but this is probably right. Put an XXX in so it can be looked at again later. Modified Paths: -------------- trunk/jython/src/org/python/core/Py.java Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2008-11-21 14:59:28 UTC (rev 5597) +++ trunk/jython/src/org/python/core/Py.java 2008-11-22 19:18:53 UTC (rev 5598) @@ -1674,6 +1674,9 @@ PyFrame frame = Py.getFrame(); if (frame != null && frame.f_code != null) { cflags = new CompilerFlags(frame.f_code.co_flags | flags); + } else { + //XXX: should this really pass flags or not? + cflags = new CompilerFlags(flags); } } return cflags; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-11-21 14:59:32
|
Revision: 5597 http://jython.svn.sourceforge.net/jython/?rev=5597&view=rev Author: fwierzbicki Date: 2008-11-21 14:59:28 +0000 (Fri, 21 Nov 2008) Log Message: ----------- More experimentation with ast -- adding internalGet* methods. The idea being that the main parser and compiler will interact with the ast nodes only through constructors and internalGet* methods, while Python code will interact with ast code through regular get* and set* methods which will be able to translate from Python to node types. Modified Paths: -------------- branches/astwrite/ast/asdl_antlr.py branches/astwrite/src/org/python/antlr/GrammarActions.java branches/astwrite/src/org/python/antlr/ast/Assert.java branches/astwrite/src/org/python/antlr/ast/Assign.java branches/astwrite/src/org/python/antlr/ast/Attribute.java branches/astwrite/src/org/python/antlr/ast/AugAssign.java branches/astwrite/src/org/python/antlr/ast/BinOp.java branches/astwrite/src/org/python/antlr/ast/BoolOp.java branches/astwrite/src/org/python/antlr/ast/Call.java branches/astwrite/src/org/python/antlr/ast/ClassDef.java branches/astwrite/src/org/python/antlr/ast/Compare.java branches/astwrite/src/org/python/antlr/ast/Delete.java branches/astwrite/src/org/python/antlr/ast/Dict.java branches/astwrite/src/org/python/antlr/ast/Exec.java branches/astwrite/src/org/python/antlr/ast/Expr.java branches/astwrite/src/org/python/antlr/ast/Expression.java branches/astwrite/src/org/python/antlr/ast/ExtSlice.java branches/astwrite/src/org/python/antlr/ast/For.java branches/astwrite/src/org/python/antlr/ast/FunctionDef.java branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java branches/astwrite/src/org/python/antlr/ast/Global.java branches/astwrite/src/org/python/antlr/ast/If.java branches/astwrite/src/org/python/antlr/ast/IfExp.java branches/astwrite/src/org/python/antlr/ast/Import.java branches/astwrite/src/org/python/antlr/ast/ImportFrom.java branches/astwrite/src/org/python/antlr/ast/Index.java branches/astwrite/src/org/python/antlr/ast/Interactive.java branches/astwrite/src/org/python/antlr/ast/Lambda.java branches/astwrite/src/org/python/antlr/ast/List.java branches/astwrite/src/org/python/antlr/ast/ListComp.java branches/astwrite/src/org/python/antlr/ast/Module.java branches/astwrite/src/org/python/antlr/ast/Name.java branches/astwrite/src/org/python/antlr/ast/Num.java branches/astwrite/src/org/python/antlr/ast/Print.java branches/astwrite/src/org/python/antlr/ast/Raise.java branches/astwrite/src/org/python/antlr/ast/Repr.java branches/astwrite/src/org/python/antlr/ast/Return.java branches/astwrite/src/org/python/antlr/ast/Slice.java branches/astwrite/src/org/python/antlr/ast/Str.java branches/astwrite/src/org/python/antlr/ast/Subscript.java branches/astwrite/src/org/python/antlr/ast/Suite.java branches/astwrite/src/org/python/antlr/ast/TryExcept.java branches/astwrite/src/org/python/antlr/ast/TryFinally.java branches/astwrite/src/org/python/antlr/ast/Tuple.java branches/astwrite/src/org/python/antlr/ast/UnaryOp.java branches/astwrite/src/org/python/antlr/ast/While.java branches/astwrite/src/org/python/antlr/ast/With.java branches/astwrite/src/org/python/antlr/ast/Yield.java branches/astwrite/src/org/python/antlr/ast/aliasType.java branches/astwrite/src/org/python/antlr/ast/argumentsType.java branches/astwrite/src/org/python/antlr/ast/comprehensionType.java branches/astwrite/src/org/python/antlr/ast/excepthandlerType.java branches/astwrite/src/org/python/antlr/ast/keywordType.java branches/astwrite/src/org/python/compiler/ArgListCompiler.java branches/astwrite/src/org/python/compiler/CodeCompiler.java branches/astwrite/src/org/python/compiler/Future.java branches/astwrite/src/org/python/compiler/ScopesCompiler.java Property Changed: ---------------- branches/astwrite/src/org/python/antlr/ast/ branches/astwrite/src/org/python/compiler/ Modified: branches/astwrite/ast/asdl_antlr.py =================================================================== --- branches/astwrite/ast/asdl_antlr.py 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/ast/asdl_antlr.py 2008-11-21 14:59:28 UTC (rev 5597) @@ -409,7 +409,7 @@ def visitField(self, field, depth): self.emit("private %s;" % self.fieldDef(field, True), depth) - self.emit("public %s get%s() {" % (self.javaType(field, True), + self.emit("public %s getInternal%s() {" % (self.javaType(field, True), str(field.name).capitalize()), depth) self.emit("return %s;" % field.name, depth+1) self.emit("}", depth) Modified: branches/astwrite/src/org/python/antlr/GrammarActions.java =================================================================== --- branches/astwrite/src/org/python/antlr/GrammarActions.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/GrammarActions.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -135,7 +135,7 @@ List<exprType> result = new ArrayList<exprType>(); if (etype != null) { if (etype instanceof Tuple) { - return ((Tuple)etype).getElts(); + return ((Tuple)etype).getInternalElts(); } result.add(etype); } @@ -314,10 +314,10 @@ } if (tree instanceof GeneratorExp) { GeneratorExp g = (GeneratorExp)tree; - recurseSetContext(g.getElt(), context); + recurseSetContext(g.getInternalElt(), context); } else if (tree instanceof ListComp) { ListComp lc = (ListComp)tree; - recurseSetContext(lc.getElt(), context); + recurseSetContext(lc.getInternalElt(), context); } else if (!(tree instanceof ListComp)) { for (int i=0; i<tree.getChildCount(); i++) { recurseSetContext(tree.getChild(i), context); @@ -357,7 +357,7 @@ checkAssign(castExpr(e.get(0))); if (e.get(0) instanceof Name) { Name arg = (Name)e.get(0); - k.add(new keywordType(arg, arg.getId(), castExpr(e.get(1)))); + k.add(new keywordType(arg, arg.getInternalId(), castExpr(e.get(1)))); } else { errorHandler.error("keyword must be a name", (PythonTree)e.get(0)); } @@ -588,26 +588,26 @@ exprType negate(PythonTree t, exprType o) { if (o instanceof Num) { Num num = (Num)o; - if (num.getN() instanceof PyInteger) { - int v = ((PyInteger)num.getN()).getValue(); + if (num.getInternalN() instanceof PyInteger) { + int v = ((PyInteger)num.getInternalN()).getValue(); if (v > 0) { num.setN(new PyInteger(-v)); return num; } - } else if (num.getN() instanceof PyLong) { - BigInteger v = ((PyLong)num.getN()).getValue(); + } else if (num.getInternalN() instanceof PyLong) { + BigInteger v = ((PyLong)num.getInternalN()).getValue(); if (v.compareTo(BigInteger.ZERO) == 1) { num.setN(new PyLong(v.negate())); return num; } - } else if (num.getN() instanceof PyFloat) { - double v = ((PyFloat)num.getN()).getValue(); + } else if (num.getInternalN() instanceof PyFloat) { + double v = ((PyFloat)num.getInternalN()).getValue(); if (v > 0) { num.setN(new PyFloat(-v)); return num; } - } else if (num.getN() instanceof PyComplex) { - double v = ((PyComplex)num.getN()).imag; + } else if (num.getInternalN() instanceof PyComplex) { + double v = ((PyComplex)num.getInternalN()).imag; if (v > 0) { num.setN(new PyComplex(0,-v)); return num; @@ -631,7 +631,7 @@ } void checkAssign(exprType e) { - if (e instanceof Name && ((Name)e).getId().equals("None")) { + if (e instanceof Name && ((Name)e).getInternalId().equals("None")) { errorHandler.error("assignment to None", e); } else if (e instanceof GeneratorExp) { errorHandler.error("can't assign to generator expression", e); @@ -653,7 +653,7 @@ errorHandler.error("can't assign to conditional expression", e); } else if (e instanceof Tuple) { //XXX: performance problem? Any way to do this better? - List<exprType> elts = ((Tuple)e).getElts(); + List<exprType> elts = ((Tuple)e).getInternalElts(); if (elts.size() == 0) { errorHandler.error("can't assign to ()", e); } @@ -662,7 +662,7 @@ } } else if (e instanceof org.python.antlr.ast.List) { //XXX: performance problem? Any way to do this better? - List<exprType> elts = ((org.python.antlr.ast.List)e).getElts(); + List<exprType> elts = ((org.python.antlr.ast.List)e).getInternalElts(); for (int i=0;i<elts.size();i++) { checkAssign(elts.get(i)); } @@ -781,7 +781,7 @@ for (Object o : sltypes) { if (o instanceof Index) { Index i = (Index)o; - etypes.add(i.getValue()); + etypes.add(i.getInternalValue()); } else { extslice = true; break; Property changes on: branches/astwrite/src/org/python/antlr/ast ___________________________________________________________________ Modified: svn:ignore - .comprehensionType.java.swp + .comprehensionType.java.swp .If.java.swp Modified: branches/astwrite/src/org/python/antlr/ast/Assert.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Assert.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Assert.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Assert extends stmtType { private exprType test; - public exprType getTest() { + public exprType getInternalTest() { return test; } public void setTest(exprType test) { @@ -17,7 +17,7 @@ } private exprType msg; - public exprType getMsg() { + public exprType getInternalMsg() { return msg; } public void setMsg(exprType msg) { Modified: branches/astwrite/src/org/python/antlr/ast/Assign.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Assign.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Assign.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Assign extends stmtType { private ListWrapper<exprType> targets; - public ListWrapper<exprType> getTargets() { + public ListWrapper<exprType> getInternalTargets() { return targets; } public void setTargets(java.util.List<exprType> targets) { @@ -17,7 +17,7 @@ } private exprType value; - public exprType getValue() { + public exprType getInternalValue() { return value; } public void setValue(exprType value) { Modified: branches/astwrite/src/org/python/antlr/ast/Attribute.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Attribute.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Attribute.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Attribute extends exprType implements Context { private exprType value; - public exprType getValue() { + public exprType getInternalValue() { return value; } public void setValue(exprType value) { @@ -17,7 +17,7 @@ } private String attr; - public String getAttr() { + public String getInternalAttr() { return attr; } public void setAttr(String attr) { @@ -25,7 +25,7 @@ } private expr_contextType ctx; - public expr_contextType getCtx() { + public expr_contextType getInternalCtx() { return ctx; } public void setCtx(expr_contextType ctx) { Modified: branches/astwrite/src/org/python/antlr/ast/AugAssign.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/AugAssign.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/AugAssign.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class AugAssign extends stmtType { private exprType target; - public exprType getTarget() { + public exprType getInternalTarget() { return target; } public void setTarget(exprType target) { @@ -17,7 +17,7 @@ } private operatorType op; - public operatorType getOp() { + public operatorType getInternalOp() { return op; } public void setOp(operatorType op) { @@ -25,7 +25,7 @@ } private exprType value; - public exprType getValue() { + public exprType getInternalValue() { return value; } public void setValue(exprType value) { Modified: branches/astwrite/src/org/python/antlr/ast/BinOp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/BinOp.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/BinOp.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class BinOp extends exprType { private exprType left; - public exprType getLeft() { + public exprType getInternalLeft() { return left; } public void setLeft(exprType left) { @@ -17,7 +17,7 @@ } private operatorType op; - public operatorType getOp() { + public operatorType getInternalOp() { return op; } public void setOp(operatorType op) { @@ -25,7 +25,7 @@ } private exprType right; - public exprType getRight() { + public exprType getInternalRight() { return right; } public void setRight(exprType right) { Modified: branches/astwrite/src/org/python/antlr/ast/BoolOp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/BoolOp.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/BoolOp.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class BoolOp extends exprType { private boolopType op; - public boolopType getOp() { + public boolopType getInternalOp() { return op; } public void setOp(boolopType op) { @@ -17,7 +17,7 @@ } private ListWrapper<exprType> values; - public ListWrapper<exprType> getValues() { + public ListWrapper<exprType> getInternalValues() { return values; } public void setValues(java.util.List<exprType> values) { Modified: branches/astwrite/src/org/python/antlr/ast/Call.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Call.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Call.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Call extends exprType { private exprType func; - public exprType getFunc() { + public exprType getInternalFunc() { return func; } public void setFunc(exprType func) { @@ -17,7 +17,7 @@ } private ListWrapper<exprType> args; - public ListWrapper<exprType> getArgs() { + public ListWrapper<exprType> getInternalArgs() { return args; } public void setArgs(java.util.List<exprType> args) { @@ -25,7 +25,7 @@ } private ListWrapper<keywordType> keywords; - public ListWrapper<keywordType> getKeywords() { + public ListWrapper<keywordType> getInternalKeywords() { return keywords; } public void setKeywords(java.util.List<keywordType> keywords) { @@ -33,7 +33,7 @@ } private exprType starargs; - public exprType getStarargs() { + public exprType getInternalStarargs() { return starargs; } public void setStarargs(exprType starargs) { @@ -41,7 +41,7 @@ } private exprType kwargs; - public exprType getKwargs() { + public exprType getInternalKwargs() { return kwargs; } public void setKwargs(exprType kwargs) { Modified: branches/astwrite/src/org/python/antlr/ast/ClassDef.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/ClassDef.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/ClassDef.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class ClassDef extends stmtType { private String name; - public String getName() { + public String getInternalName() { return name; } public void setName(String name) { @@ -17,7 +17,7 @@ } private ListWrapper<exprType> bases; - public ListWrapper<exprType> getBases() { + public ListWrapper<exprType> getInternalBases() { return bases; } public void setBases(java.util.List<exprType> bases) { @@ -25,7 +25,7 @@ } private ListWrapper<stmtType> body; - public ListWrapper<stmtType> getBody() { + public ListWrapper<stmtType> getInternalBody() { return body; } public void setBody(java.util.List<stmtType> body) { @@ -33,7 +33,7 @@ } private ListWrapper<exprType> decorators; - public ListWrapper<exprType> getDecorators() { + public ListWrapper<exprType> getInternalDecorators() { return decorators; } public void setDecorators(java.util.List<exprType> decorators) { Modified: branches/astwrite/src/org/python/antlr/ast/Compare.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Compare.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Compare.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Compare extends exprType { private exprType left; - public exprType getLeft() { + public exprType getInternalLeft() { return left; } public void setLeft(exprType left) { @@ -17,7 +17,7 @@ } private ListWrapper<cmpopType> ops; - public ListWrapper<cmpopType> getOps() { + public ListWrapper<cmpopType> getInternalOps() { return ops; } public void setOps(java.util.List<cmpopType> ops) { @@ -25,7 +25,7 @@ } private ListWrapper<exprType> comparators; - public ListWrapper<exprType> getComparators() { + public ListWrapper<exprType> getInternalComparators() { return comparators; } public void setComparators(java.util.List<exprType> comparators) { Modified: branches/astwrite/src/org/python/antlr/ast/Delete.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Delete.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Delete.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Delete extends stmtType { private ListWrapper<exprType> targets; - public ListWrapper<exprType> getTargets() { + public ListWrapper<exprType> getInternalTargets() { return targets; } public void setTargets(java.util.List<exprType> targets) { Modified: branches/astwrite/src/org/python/antlr/ast/Dict.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Dict.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Dict.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Dict extends exprType { private ListWrapper<exprType> keys; - public ListWrapper<exprType> getKeys() { + public ListWrapper<exprType> getInternalKeys() { return keys; } public void setKeys(java.util.List<exprType> keys) { @@ -17,7 +17,7 @@ } private ListWrapper<exprType> values; - public ListWrapper<exprType> getValues() { + public ListWrapper<exprType> getInternalValues() { return values; } public void setValues(java.util.List<exprType> values) { Modified: branches/astwrite/src/org/python/antlr/ast/Exec.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Exec.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Exec.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Exec extends stmtType { private exprType body; - public exprType getBody() { + public exprType getInternalBody() { return body; } public void setBody(exprType body) { @@ -17,7 +17,7 @@ } private exprType globals; - public exprType getGlobals() { + public exprType getInternalGlobals() { return globals; } public void setGlobals(exprType globals) { @@ -25,7 +25,7 @@ } private exprType locals; - public exprType getLocals() { + public exprType getInternalLocals() { return locals; } public void setLocals(exprType locals) { Modified: branches/astwrite/src/org/python/antlr/ast/Expr.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Expr.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Expr.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Expr extends stmtType { private exprType value; - public exprType getValue() { + public exprType getInternalValue() { return value; } public void setValue(exprType value) { Modified: branches/astwrite/src/org/python/antlr/ast/Expression.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Expression.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Expression.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Expression extends modType { private exprType body; - public exprType getBody() { + public exprType getInternalBody() { return body; } public void setBody(exprType body) { Modified: branches/astwrite/src/org/python/antlr/ast/ExtSlice.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/ExtSlice.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/ExtSlice.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class ExtSlice extends sliceType { private ListWrapper<sliceType> dims; - public ListWrapper<sliceType> getDims() { + public ListWrapper<sliceType> getInternalDims() { return dims; } public void setDims(java.util.List<sliceType> dims) { Modified: branches/astwrite/src/org/python/antlr/ast/For.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/For.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/For.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class For extends stmtType { private exprType target; - public exprType getTarget() { + public exprType getInternalTarget() { return target; } public void setTarget(exprType target) { @@ -17,7 +17,7 @@ } private exprType iter; - public exprType getIter() { + public exprType getInternalIter() { return iter; } public void setIter(exprType iter) { @@ -25,7 +25,7 @@ } private ListWrapper<stmtType> body; - public ListWrapper<stmtType> getBody() { + public ListWrapper<stmtType> getInternalBody() { return body; } public void setBody(java.util.List<stmtType> body) { @@ -33,7 +33,7 @@ } private ListWrapper<stmtType> orelse; - public ListWrapper<stmtType> getOrelse() { + public ListWrapper<stmtType> getInternalOrelse() { return orelse; } public void setOrelse(java.util.List<stmtType> orelse) { Modified: branches/astwrite/src/org/python/antlr/ast/FunctionDef.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/FunctionDef.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/FunctionDef.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class FunctionDef extends stmtType { private String name; - public String getName() { + public String getInternalName() { return name; } public void setName(String name) { @@ -17,7 +17,7 @@ } private argumentsType args; - public argumentsType getArgs() { + public argumentsType getInternalArgs() { return args; } public void setArgs(argumentsType args) { @@ -25,7 +25,7 @@ } private ListWrapper<stmtType> body; - public ListWrapper<stmtType> getBody() { + public ListWrapper<stmtType> getInternalBody() { return body; } public void setBody(java.util.List<stmtType> body) { @@ -33,7 +33,7 @@ } private ListWrapper<exprType> decorators; - public ListWrapper<exprType> getDecorators() { + public ListWrapper<exprType> getInternalDecorators() { return decorators; } public void setDecorators(java.util.List<exprType> decorators) { Modified: branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class GeneratorExp extends exprType { private exprType elt; - public exprType getElt() { + public exprType getInternalElt() { return elt; } public void setElt(exprType elt) { @@ -17,7 +17,7 @@ } private ListWrapper<comprehensionType> generators; - public ListWrapper<comprehensionType> getGenerators() { + public ListWrapper<comprehensionType> getInternalGenerators() { return generators; } public void setGenerators(java.util.List<comprehensionType> generators) { Modified: branches/astwrite/src/org/python/antlr/ast/Global.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Global.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Global.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Global extends stmtType { private ListWrapper<String> names; - public ListWrapper<String> getNames() { + public ListWrapper<String> getInternalNames() { return names; } public void setNames(java.util.List<String> names) { Modified: branches/astwrite/src/org/python/antlr/ast/If.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/If.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/If.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class If extends stmtType { private exprType test; - public exprType getTest() { + public exprType getInternalTest() { return test; } public void setTest(exprType test) { @@ -17,7 +17,7 @@ } private ListWrapper<stmtType> body; - public ListWrapper<stmtType> getBody() { + public ListWrapper<stmtType> getInternalBody() { return body; } public void setBody(java.util.List<stmtType> body) { @@ -25,7 +25,7 @@ } private ListWrapper<stmtType> orelse; - public ListWrapper<stmtType> getOrelse() { + public ListWrapper<stmtType> getInternalOrelse() { return orelse; } public void setOrelse(java.util.List<stmtType> orelse) { Modified: branches/astwrite/src/org/python/antlr/ast/IfExp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/IfExp.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/IfExp.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class IfExp extends exprType { private exprType test; - public exprType getTest() { + public exprType getInternalTest() { return test; } public void setTest(exprType test) { @@ -17,7 +17,7 @@ } private exprType body; - public exprType getBody() { + public exprType getInternalBody() { return body; } public void setBody(exprType body) { @@ -25,7 +25,7 @@ } private exprType orelse; - public exprType getOrelse() { + public exprType getInternalOrelse() { return orelse; } public void setOrelse(exprType orelse) { Modified: branches/astwrite/src/org/python/antlr/ast/Import.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Import.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Import.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Import extends stmtType { private ListWrapper<aliasType> names; - public ListWrapper<aliasType> getNames() { + public ListWrapper<aliasType> getInternalNames() { return names; } public void setNames(java.util.List<aliasType> names) { Modified: branches/astwrite/src/org/python/antlr/ast/ImportFrom.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/ImportFrom.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/ImportFrom.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class ImportFrom extends stmtType { private String module; - public String getModule() { + public String getInternalModule() { return module; } public void setModule(String module) { @@ -17,7 +17,7 @@ } private ListWrapper<aliasType> names; - public ListWrapper<aliasType> getNames() { + public ListWrapper<aliasType> getInternalNames() { return names; } public void setNames(java.util.List<aliasType> names) { @@ -25,7 +25,7 @@ } private int level; - public int getLevel() { + public int getInternalLevel() { return level; } public void setLevel(int level) { Modified: branches/astwrite/src/org/python/antlr/ast/Index.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Index.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Index.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Index extends sliceType { private exprType value; - public exprType getValue() { + public exprType getInternalValue() { return value; } public void setValue(exprType value) { Modified: branches/astwrite/src/org/python/antlr/ast/Interactive.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Interactive.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Interactive.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Interactive extends modType { private ListWrapper<stmtType> body; - public ListWrapper<stmtType> getBody() { + public ListWrapper<stmtType> getInternalBody() { return body; } public void setBody(java.util.List<stmtType> body) { Modified: branches/astwrite/src/org/python/antlr/ast/Lambda.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Lambda.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Lambda.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Lambda extends exprType { private argumentsType args; - public argumentsType getArgs() { + public argumentsType getInternalArgs() { return args; } public void setArgs(argumentsType args) { @@ -17,7 +17,7 @@ } private exprType body; - public exprType getBody() { + public exprType getInternalBody() { return body; } public void setBody(exprType body) { Modified: branches/astwrite/src/org/python/antlr/ast/List.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/List.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/List.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class List extends exprType implements Context { private ListWrapper<exprType> elts; - public ListWrapper<exprType> getElts() { + public ListWrapper<exprType> getInternalElts() { return elts; } public void setElts(java.util.List<exprType> elts) { @@ -17,7 +17,7 @@ } private expr_contextType ctx; - public expr_contextType getCtx() { + public expr_contextType getInternalCtx() { return ctx; } public void setCtx(expr_contextType ctx) { Modified: branches/astwrite/src/org/python/antlr/ast/ListComp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/ListComp.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/ListComp.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class ListComp extends exprType { private exprType elt; - public exprType getElt() { + public exprType getInternalElt() { return elt; } public void setElt(exprType elt) { @@ -17,7 +17,7 @@ } private ListWrapper<comprehensionType> generators; - public ListWrapper<comprehensionType> getGenerators() { + public ListWrapper<comprehensionType> getInternalGenerators() { return generators; } public void setGenerators(java.util.List<comprehensionType> generators) { Modified: branches/astwrite/src/org/python/antlr/ast/Module.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Module.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Module.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Module extends modType { private ListWrapper<stmtType> body; - public ListWrapper<stmtType> getBody() { + public ListWrapper<stmtType> getInternalBody() { return body; } public void setBody(java.util.List<stmtType> body) { Modified: branches/astwrite/src/org/python/antlr/ast/Name.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Name.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Name.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Name extends exprType implements Context { private String id; - public String getId() { + public String getInternalId() { return id; } public void setId(String id) { @@ -17,7 +17,7 @@ } private expr_contextType ctx; - public expr_contextType getCtx() { + public expr_contextType getInternalCtx() { return ctx; } public void setCtx(expr_contextType ctx) { Modified: branches/astwrite/src/org/python/antlr/ast/Num.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Num.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Num.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Num extends exprType { private Object n; - public Object getN() { + public Object getInternalN() { return n; } public void setN(Object n) { Modified: branches/astwrite/src/org/python/antlr/ast/Print.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Print.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Print.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Print extends stmtType { private exprType dest; - public exprType getDest() { + public exprType getInternalDest() { return dest; } public void setDest(exprType dest) { @@ -17,7 +17,7 @@ } private ListWrapper<exprType> values; - public ListWrapper<exprType> getValues() { + public ListWrapper<exprType> getInternalValues() { return values; } public void setValues(java.util.List<exprType> values) { @@ -25,7 +25,7 @@ } private boolean nl; - public boolean getNl() { + public boolean getInternalNl() { return nl; } public void setNl(boolean nl) { Modified: branches/astwrite/src/org/python/antlr/ast/Raise.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Raise.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Raise.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Raise extends stmtType { private exprType excepttype; - public exprType getExcepttype() { + public exprType getInternalExcepttype() { return excepttype; } public void setExcepttype(exprType excepttype) { @@ -17,7 +17,7 @@ } private exprType inst; - public exprType getInst() { + public exprType getInternalInst() { return inst; } public void setInst(exprType inst) { @@ -25,7 +25,7 @@ } private exprType tback; - public exprType getTback() { + public exprType getInternalTback() { return tback; } public void setTback(exprType tback) { Modified: branches/astwrite/src/org/python/antlr/ast/Repr.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Repr.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Repr.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Repr extends exprType { private exprType value; - public exprType getValue() { + public exprType getInternalValue() { return value; } public void setValue(exprType value) { Modified: branches/astwrite/src/org/python/antlr/ast/Return.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Return.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Return.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Return extends stmtType { private exprType value; - public exprType getValue() { + public exprType getInternalValue() { return value; } public void setValue(exprType value) { Modified: branches/astwrite/src/org/python/antlr/ast/Slice.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Slice.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Slice.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Slice extends sliceType { private exprType lower; - public exprType getLower() { + public exprType getInternalLower() { return lower; } public void setLower(exprType lower) { @@ -17,7 +17,7 @@ } private exprType upper; - public exprType getUpper() { + public exprType getInternalUpper() { return upper; } public void setUpper(exprType upper) { @@ -25,7 +25,7 @@ } private exprType step; - public exprType getStep() { + public exprType getInternalStep() { return step; } public void setStep(exprType step) { Modified: branches/astwrite/src/org/python/antlr/ast/Str.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Str.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Str.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Str extends exprType { private Object s; - public Object getS() { + public Object getInternalS() { return s; } public void setS(Object s) { Modified: branches/astwrite/src/org/python/antlr/ast/Subscript.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Subscript.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Subscript.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Subscript extends exprType implements Context { private exprType value; - public exprType getValue() { + public exprType getInternalValue() { return value; } public void setValue(exprType value) { @@ -17,7 +17,7 @@ } private sliceType slice; - public sliceType getSlice() { + public sliceType getInternalSlice() { return slice; } public void setSlice(sliceType slice) { @@ -25,7 +25,7 @@ } private expr_contextType ctx; - public expr_contextType getCtx() { + public expr_contextType getInternalCtx() { return ctx; } public void setCtx(expr_contextType ctx) { Modified: branches/astwrite/src/org/python/antlr/ast/Suite.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Suite.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Suite.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Suite extends modType { private ListWrapper<stmtType> body; - public ListWrapper<stmtType> getBody() { + public ListWrapper<stmtType> getInternalBody() { return body; } public void setBody(java.util.List<stmtType> body) { Modified: branches/astwrite/src/org/python/antlr/ast/TryExcept.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/TryExcept.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/TryExcept.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class TryExcept extends stmtType { private ListWrapper<stmtType> body; - public ListWrapper<stmtType> getBody() { + public ListWrapper<stmtType> getInternalBody() { return body; } public void setBody(java.util.List<stmtType> body) { @@ -17,7 +17,7 @@ } private ListWrapper<excepthandlerType> handlers; - public ListWrapper<excepthandlerType> getHandlers() { + public ListWrapper<excepthandlerType> getInternalHandlers() { return handlers; } public void setHandlers(java.util.List<excepthandlerType> handlers) { @@ -25,7 +25,7 @@ } private ListWrapper<stmtType> orelse; - public ListWrapper<stmtType> getOrelse() { + public ListWrapper<stmtType> getInternalOrelse() { return orelse; } public void setOrelse(java.util.List<stmtType> orelse) { Modified: branches/astwrite/src/org/python/antlr/ast/TryFinally.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/TryFinally.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/TryFinally.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class TryFinally extends stmtType { private ListWrapper<stmtType> body; - public ListWrapper<stmtType> getBody() { + public ListWrapper<stmtType> getInternalBody() { return body; } public void setBody(java.util.List<stmtType> body) { @@ -17,7 +17,7 @@ } private ListWrapper<stmtType> finalbody; - public ListWrapper<stmtType> getFinalbody() { + public ListWrapper<stmtType> getInternalFinalbody() { return finalbody; } public void setFinalbody(java.util.List<stmtType> finalbody) { Modified: branches/astwrite/src/org/python/antlr/ast/Tuple.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Tuple.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Tuple.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Tuple extends exprType implements Context { private ListWrapper<exprType> elts; - public ListWrapper<exprType> getElts() { + public ListWrapper<exprType> getInternalElts() { return elts; } public void setElts(java.util.List<exprType> elts) { @@ -17,7 +17,7 @@ } private expr_contextType ctx; - public expr_contextType getCtx() { + public expr_contextType getInternalCtx() { return ctx; } public void setCtx(expr_contextType ctx) { Modified: branches/astwrite/src/org/python/antlr/ast/UnaryOp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/UnaryOp.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/UnaryOp.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class UnaryOp extends exprType { private unaryopType op; - public unaryopType getOp() { + public unaryopType getInternalOp() { return op; } public void setOp(unaryopType op) { @@ -17,7 +17,7 @@ } private exprType operand; - public exprType getOperand() { + public exprType getInternalOperand() { return operand; } public void setOperand(exprType operand) { Modified: branches/astwrite/src/org/python/antlr/ast/While.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/While.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/While.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class While extends stmtType { private exprType test; - public exprType getTest() { + public exprType getInternalTest() { return test; } public void setTest(exprType test) { @@ -17,7 +17,7 @@ } private ListWrapper<stmtType> body; - public ListWrapper<stmtType> getBody() { + public ListWrapper<stmtType> getInternalBody() { return body; } public void setBody(java.util.List<stmtType> body) { @@ -25,7 +25,7 @@ } private ListWrapper<stmtType> orelse; - public ListWrapper<stmtType> getOrelse() { + public ListWrapper<stmtType> getInternalOrelse() { return orelse; } public void setOrelse(java.util.List<stmtType> orelse) { Modified: branches/astwrite/src/org/python/antlr/ast/With.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/With.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/With.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class With extends stmtType { private exprType context_expr; - public exprType getContext_expr() { + public exprType getInternalContext_expr() { return context_expr; } public void setContext_expr(exprType context_expr) { @@ -17,7 +17,7 @@ } private exprType optional_vars; - public exprType getOptional_vars() { + public exprType getInternalOptional_vars() { return optional_vars; } public void setOptional_vars(exprType optional_vars) { @@ -25,7 +25,7 @@ } private ListWrapper<stmtType> body; - public ListWrapper<stmtType> getBody() { + public ListWrapper<stmtType> getInternalBody() { return body; } public void setBody(java.util.List<stmtType> body) { Modified: branches/astwrite/src/org/python/antlr/ast/Yield.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Yield.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/Yield.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class Yield extends exprType { private exprType value; - public exprType getValue() { + public exprType getInternalValue() { return value; } public void setValue(exprType value) { Modified: branches/astwrite/src/org/python/antlr/ast/aliasType.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/aliasType.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/aliasType.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class aliasType extends PythonTree { private String name; - public String getName() { + public String getInternalName() { return name; } public void setName(String name) { @@ -17,7 +17,7 @@ } private String asname; - public String getAsname() { + public String getInternalAsname() { return asname; } public void setAsname(String asname) { Modified: branches/astwrite/src/org/python/antlr/ast/argumentsType.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/argumentsType.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/argumentsType.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class argumentsType extends PythonTree { private ListWrapper<exprType> args; - public ListWrapper<exprType> getArgs() { + public ListWrapper<exprType> getInternalArgs() { return args; } public void setArgs(java.util.List<exprType> args) { @@ -17,7 +17,7 @@ } private String vararg; - public String getVararg() { + public String getInternalVararg() { return vararg; } public void setVararg(String vararg) { @@ -25,7 +25,7 @@ } private String kwarg; - public String getKwarg() { + public String getInternalKwarg() { return kwarg; } public void setKwarg(String kwarg) { @@ -33,7 +33,7 @@ } private ListWrapper<exprType> defaults; - public ListWrapper<exprType> getDefaults() { + public ListWrapper<exprType> getInternalDefaults() { return defaults; } public void setDefaults(java.util.List<exprType> defaults) { Modified: branches/astwrite/src/org/python/antlr/ast/comprehensionType.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/comprehensionType.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/comprehensionType.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class comprehensionType extends PythonTree { private exprType target; - public exprType getTarget() { + public exprType getInternalTarget() { return target; } public void setTarget(exprType target) { @@ -17,7 +17,7 @@ } private exprType iter; - public exprType getIter() { + public exprType getInternalIter() { return iter; } public void setIter(exprType iter) { @@ -25,7 +25,7 @@ } private ListWrapper<exprType> ifs; - public ListWrapper<exprType> getIfs() { + public ListWrapper<exprType> getInternalIfs() { return ifs; } public void setIfs(java.util.List<exprType> ifs) { Modified: branches/astwrite/src/org/python/antlr/ast/excepthandlerType.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/excepthandlerType.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/excepthandlerType.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class excepthandlerType extends PythonTree { private exprType excepttype; - public exprType getExcepttype() { + public exprType getInternalExcepttype() { return excepttype; } public void setExcepttype(exprType excepttype) { @@ -17,7 +17,7 @@ } private exprType name; - public exprType getName() { + public exprType getInternalName() { return name; } public void setName(exprType name) { @@ -25,7 +25,7 @@ } private ListWrapper<stmtType> body; - public ListWrapper<stmtType> getBody() { + public ListWrapper<stmtType> getInternalBody() { return body; } public void setBody(java.util.List<stmtType> body) { @@ -33,7 +33,7 @@ } private int lineno; - public int getLineno() { + public int getInternalLineno() { return lineno; } public void setLineno(int lineno) { @@ -41,7 +41,7 @@ } private int col_offset; - public int getCol_offset() { + public int getInternalCol_offset() { return col_offset; } public void setCol_offset(int col_offset) { Modified: branches/astwrite/src/org/python/antlr/ast/keywordType.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/keywordType.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/antlr/ast/keywordType.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -9,7 +9,7 @@ public class keywordType extends PythonTree { private String arg; - public String getArg() { + public String getInternalArg() { return arg; } public void setArg(String arg) { @@ -17,7 +17,7 @@ } private exprType value; - public exprType getValue() { + public exprType getInternalValue() { return value; } public void setValue(exprType value) { Property changes on: branches/astwrite/src/org/python/compiler ___________________________________________________________________ Modified: svn:ignore - .AppleDouble *.class + .AppleDouble *.class .CodeCompiler.java.swp .ArgListCompiler.java.swp .ScopesCompiler.java.swp Modified: branches/astwrite/src/org/python/compiler/ArgListCompiler.java =================================================================== --- branches/astwrite/src/org/python/compiler/ArgListCompiler.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/compiler/ArgListCompiler.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -40,10 +40,10 @@ } public void appendInitCode(Suite node) { - int n = node.getBody().size(); + int n = node.getInternalBody().size(); List<stmtType> newtree = new ArrayList<stmtType>(); newtree.addAll(init_code); - newtree.addAll(node.getBody()); + newtree.addAll(node.getInternalBody()); node.setBody(newtree); } @@ -52,60 +52,60 @@ } public void visitArgs(argumentsType args) throws Exception { - for (int i = 0; i < args.getArgs().size(); i++) { - String name = (String) visit(args.getArgs().get(i)); + for (int i = 0; i < args.getInternalArgs().size(); i++) { + String name = (String) visit(args.getInternalArgs().get(i)); names.add(name); - if (args.getArgs().get(i) instanceof Tuple) { + if (args.getInternalArgs().get(i) instanceof Tuple) { List<exprType> targets = new ArrayList<exprType>(); - targets.add(args.getArgs().get(i)); - Assign ass = new Assign(args.getArgs().get(i), + targets.add(args.getInternalArgs().get(i)); + Assign ass = new Assign(args.getInternalArgs().get(i), targets, - new Name(args.getArgs().get(i), name, expr_contextType.Load)); + new Name(args.getInternalArgs().get(i), name, expr_contextType.Load)); init_code.add(ass); } } - if (args.getVararg() != null) { + if (args.getInternalVararg() != null) { arglist = true; - names.add(args.getVararg()); + names.add(args.getInternalVararg()); } - if (args.getKwarg() != null) { + if (args.getInternalKwarg() != null) { keywordlist = true; - names.add(args.getKwarg()); + names.add(args.getInternalKwarg()); } - defaults = args.getDefaults(); + defaults = args.getInternalDefaults(); for (int i = 0; i < defaults.size(); i++) { if (defaults.get(i) == null) throw new ParseException( "non-default argument follows default argument", - args.getArgs().get(args.getArgs().size() - defaults.size() + i)); + args.getInternalArgs().get(args.getInternalArgs().size() - defaults.size() + i)); } } @Override public Object visitName(Name node) throws Exception { //FIXME: do we need Store and Param, or just Param? - if (node.getCtx() != expr_contextType.Store && node.getCtx() != expr_contextType.Param) { + if (node.getInternalCtx() != expr_contextType.Store && node.getInternalCtx() != expr_contextType.Param) { return null; } - if (fpnames.contains(node.getId())) { + if (fpnames.contains(node.getInternalId())) { throw new ParseException("duplicate argument name found: " + - node.getId(), node); + node.getInternalId(), node); } - fpnames.add(node.getId()); - return node.getId(); + fpnames.add(node.getInternalId()); + return node.getInternalId(); } @Override public Object visitTuple(Tuple node) throws Exception { StringBuffer name = new StringBuffer("("); - int n = node.getElts().size(); + int n = node.getInternalElts().size(); for (int i = 0; i < n-1; i++) { - name.append(visit(node.getElts().get(i))); + name.append(visit(node.getInternalElts().get(i))); name.append(", "); } - name.append(visit(node.getElts().get(n - 1))); + name.append(visit(node.getInternalElts().get(n - 1))); name.append(")"); return name.toString(); } Modified: branches/astwrite/src/org/python/compiler/CodeCompiler.java =================================================================== --- branches/astwrite/src/org/python/compiler/CodeCompiler.java 2008-11-21 02:00:11 UTC (rev 5596) +++ branches/astwrite/src/org/python/compiler/CodeCompiler.java 2008-11-21 14:59:28 UTC (rev 5597) @@ -297,13 +297,13 @@ public Object visitModule(org.python.antlr.ast.Module suite) throws Exception { - if (suite.getBody().size() > 0 && - suite.getBody().get(0) instanceof Expr && - ((Expr) suite.getBody().get(0)).getValue() instanceof Str) + if (suite.getInternalBody().size() > 0 && + suite.getInternalBody().get(0) instanceof Expr && + ((Expr) suite.getInternalBody().get(0)).getInternalValue() instanceof Str) { loadFrame(); code.ldc("__doc__"); - visit(((Expr) suite.getBody().get(0)).getValue()); + visit(((Expr) suite.getInternalBody().get(0)).getInternalValue()); code.invokevirtual("org/python/core/PyFrame", "setglobal", "(" +$str ... [truncated message content] |
From: <pj...@us...> - 2008-11-21 02:00:18
|
Revision: 5596 http://jython.svn.sourceforge.net/jython/?rev=5596&view=rev Author: pjenvey Date: 2008-11-21 02:00:11 +0000 (Fri, 21 Nov 2008) Log Message: ----------- fix handling of null prefix/exec_prefix values now that they're PyObjects fixes #1173 thanks boisgera Modified Paths: -------------- trunk/jython/src/org/python/core/PySystemState.java Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2008-11-20 23:44:08 UTC (rev 5595) +++ trunk/jython/src/org/python/core/PySystemState.java 2008-11-21 02:00:11 UTC (rev 5596) @@ -459,8 +459,12 @@ } catch (Exception exc) { } } - PySystemState.prefix = Py.newString(prefix); - PySystemState.exec_prefix = Py.newString(exec_prefix); + if (prefix != null) { + PySystemState.prefix = Py.newString(prefix); + } + if (exec_prefix != null) { + PySystemState.exec_prefix = Py.newString(exec_prefix); + } try { String jythonpath = System.getenv("JYTHONPATH"); if (jythonpath != null) { @@ -626,7 +630,7 @@ } cachedir = new File(props.getProperty(PYTHON_CACHEDIR, CACHEDIR_DEFAULT_NAME)); if (!cachedir.isAbsolute()) { - cachedir = new File(prefix.toString(), cachedir.getPath()); + cachedir = new File(prefix == null ? null : prefix.toString(), cachedir.getPath()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-11-20 23:44:14
|
Revision: 5595 http://jython.svn.sourceforge.net/jython/?rev=5595&view=rev Author: fwierzbicki Date: 2008-11-20 23:44:08 +0000 (Thu, 20 Nov 2008) Log Message: ----------- Oops missed a spot for wrapping with ListWrapper. Modified Paths: -------------- branches/astwrite/ast/asdl_antlr.py branches/astwrite/src/org/python/antlr/ast/Assign.java branches/astwrite/src/org/python/antlr/ast/BoolOp.java branches/astwrite/src/org/python/antlr/ast/Call.java branches/astwrite/src/org/python/antlr/ast/ClassDef.java branches/astwrite/src/org/python/antlr/ast/Compare.java branches/astwrite/src/org/python/antlr/ast/Delete.java branches/astwrite/src/org/python/antlr/ast/Dict.java branches/astwrite/src/org/python/antlr/ast/ExtSlice.java branches/astwrite/src/org/python/antlr/ast/For.java branches/astwrite/src/org/python/antlr/ast/FunctionDef.java branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java branches/astwrite/src/org/python/antlr/ast/Global.java branches/astwrite/src/org/python/antlr/ast/If.java branches/astwrite/src/org/python/antlr/ast/Import.java branches/astwrite/src/org/python/antlr/ast/ImportFrom.java branches/astwrite/src/org/python/antlr/ast/Interactive.java branches/astwrite/src/org/python/antlr/ast/List.java branches/astwrite/src/org/python/antlr/ast/ListComp.java branches/astwrite/src/org/python/antlr/ast/Module.java branches/astwrite/src/org/python/antlr/ast/Print.java branches/astwrite/src/org/python/antlr/ast/Suite.java branches/astwrite/src/org/python/antlr/ast/TryExcept.java branches/astwrite/src/org/python/antlr/ast/TryFinally.java branches/astwrite/src/org/python/antlr/ast/Tuple.java branches/astwrite/src/org/python/antlr/ast/While.java branches/astwrite/src/org/python/antlr/ast/With.java branches/astwrite/src/org/python/antlr/ast/argumentsType.java branches/astwrite/src/org/python/antlr/ast/comprehensionType.java branches/astwrite/src/org/python/antlr/ast/excepthandlerType.java Modified: branches/astwrite/ast/asdl_antlr.py =================================================================== --- branches/astwrite/ast/asdl_antlr.py 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/ast/asdl_antlr.py 2008-11-20 23:44:08 UTC (rev 5595) @@ -291,8 +291,15 @@ def javaConstructorHelper(self, fields, depth): for f in fields: - self.emit("this.%s = %s;" % (f.name, f.name), depth+1) - #self.emit("set%s(%s);" % (str(f.name).capitalize(), f.name), depth+1) + #XXX: old version: + #self.emit("this.%s = %s;" % (f.name, f.name), depth+1) + #XXX: code cut and pasted from visitField + if f.seq: + self.emit("this.%s = new %s(%s);" % (f.name, + self.javaType(f, True), f.name), depth+1) + else: + self.emit("this.%s = %s;" % (f.name, f.name), depth+1) + fparg = self.fieldDef(f) not_simple = True Modified: branches/astwrite/src/org/python/antlr/ast/Assign.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Assign.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/Assign.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -29,7 +29,7 @@ public String[] get_fields() { return fields; } public Assign(java.util.List<exprType> targets, exprType value) { - this.targets = targets; + this.targets = new ListWrapper<exprType>(targets); if (targets != null) { for(PythonTree t : targets) { addChild(t); @@ -42,7 +42,7 @@ public Assign(Token token, java.util.List<exprType> targets, exprType value) { super(token); - this.targets = targets; + this.targets = new ListWrapper<exprType>(targets); if (targets != null) { for(PythonTree t : targets) { addChild(t); @@ -55,7 +55,7 @@ public Assign(int ttype, Token token, java.util.List<exprType> targets, exprType value) { super(ttype, token); - this.targets = targets; + this.targets = new ListWrapper<exprType>(targets); if (targets != null) { for(PythonTree t : targets) { addChild(t); @@ -68,7 +68,7 @@ public Assign(PythonTree tree, java.util.List<exprType> targets, exprType value) { super(tree); - this.targets = targets; + this.targets = new ListWrapper<exprType>(targets); if (targets != null) { for(PythonTree t : targets) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/BoolOp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/BoolOp.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/BoolOp.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -30,7 +30,7 @@ public BoolOp(boolopType op, java.util.List<exprType> values) { this.op = op; - this.values = values; + this.values = new ListWrapper<exprType>(values); if (values != null) { for(PythonTree t : values) { addChild(t); @@ -41,7 +41,7 @@ public BoolOp(Token token, boolopType op, java.util.List<exprType> values) { super(token); this.op = op; - this.values = values; + this.values = new ListWrapper<exprType>(values); if (values != null) { for(PythonTree t : values) { addChild(t); @@ -53,7 +53,7 @@ java.util.List<exprType> values) { super(ttype, token); this.op = op; - this.values = values; + this.values = new ListWrapper<exprType>(values); if (values != null) { for(PythonTree t : values) { addChild(t); @@ -65,7 +65,7 @@ values) { super(tree); this.op = op; - this.values = values; + this.values = new ListWrapper<exprType>(values); if (values != null) { for(PythonTree t : values) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/Call.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Call.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/Call.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -58,13 +58,13 @@ java.util.List<keywordType> keywords, exprType starargs, exprType kwargs) { this.func = func; addChild(func); - this.args = args; + this.args = new ListWrapper<exprType>(args); if (args != null) { for(PythonTree t : args) { addChild(t); } } - this.keywords = keywords; + this.keywords = new ListWrapper<keywordType>(keywords); if (keywords != null) { for(PythonTree t : keywords) { addChild(t); @@ -81,13 +81,13 @@ super(token); this.func = func; addChild(func); - this.args = args; + this.args = new ListWrapper<exprType>(args); if (args != null) { for(PythonTree t : args) { addChild(t); } } - this.keywords = keywords; + this.keywords = new ListWrapper<keywordType>(keywords); if (keywords != null) { for(PythonTree t : keywords) { addChild(t); @@ -105,13 +105,13 @@ super(ttype, token); this.func = func; addChild(func); - this.args = args; + this.args = new ListWrapper<exprType>(args); if (args != null) { for(PythonTree t : args) { addChild(t); } } - this.keywords = keywords; + this.keywords = new ListWrapper<keywordType>(keywords); if (keywords != null) { for(PythonTree t : keywords) { addChild(t); @@ -128,13 +128,13 @@ super(tree); this.func = func; addChild(func); - this.args = args; + this.args = new ListWrapper<exprType>(args); if (args != null) { for(PythonTree t : args) { addChild(t); } } - this.keywords = keywords; + this.keywords = new ListWrapper<keywordType>(keywords); if (keywords != null) { for(PythonTree t : keywords) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/ClassDef.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/ClassDef.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/ClassDef.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -48,19 +48,19 @@ public ClassDef(String name, java.util.List<exprType> bases, java.util.List<stmtType> body, java.util.List<exprType> decorators) { this.name = name; - this.bases = bases; + this.bases = new ListWrapper<exprType>(bases); if (bases != null) { for(PythonTree t : bases) { addChild(t); } } - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.decorators = decorators; + this.decorators = new ListWrapper<exprType>(decorators); if (decorators != null) { for(PythonTree t : decorators) { addChild(t); @@ -72,19 +72,19 @@ java.util.List<stmtType> body, java.util.List<exprType> decorators) { super(token); this.name = name; - this.bases = bases; + this.bases = new ListWrapper<exprType>(bases); if (bases != null) { for(PythonTree t : bases) { addChild(t); } } - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.decorators = decorators; + this.decorators = new ListWrapper<exprType>(decorators); if (decorators != null) { for(PythonTree t : decorators) { addChild(t); @@ -97,19 +97,19 @@ java.util.List<exprType> decorators) { super(ttype, token); this.name = name; - this.bases = bases; + this.bases = new ListWrapper<exprType>(bases); if (bases != null) { for(PythonTree t : bases) { addChild(t); } } - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.decorators = decorators; + this.decorators = new ListWrapper<exprType>(decorators); if (decorators != null) { for(PythonTree t : decorators) { addChild(t); @@ -121,19 +121,19 @@ bases, java.util.List<stmtType> body, java.util.List<exprType> decorators) { super(tree); this.name = name; - this.bases = bases; + this.bases = new ListWrapper<exprType>(bases); if (bases != null) { for(PythonTree t : bases) { addChild(t); } } - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.decorators = decorators; + this.decorators = new ListWrapper<exprType>(decorators); if (decorators != null) { for(PythonTree t : decorators) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/Compare.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Compare.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/Compare.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -41,8 +41,8 @@ java.util.List<exprType> comparators) { this.left = left; addChild(left); - this.ops = ops; - this.comparators = comparators; + this.ops = new ListWrapper<cmpopType>(ops); + this.comparators = new ListWrapper<exprType>(comparators); if (comparators != null) { for(PythonTree t : comparators) { addChild(t); @@ -55,8 +55,8 @@ super(token); this.left = left; addChild(left); - this.ops = ops; - this.comparators = comparators; + this.ops = new ListWrapper<cmpopType>(ops); + this.comparators = new ListWrapper<exprType>(comparators); if (comparators != null) { for(PythonTree t : comparators) { addChild(t); @@ -69,8 +69,8 @@ super(ttype, token); this.left = left; addChild(left); - this.ops = ops; - this.comparators = comparators; + this.ops = new ListWrapper<cmpopType>(ops); + this.comparators = new ListWrapper<exprType>(comparators); if (comparators != null) { for(PythonTree t : comparators) { addChild(t); @@ -83,8 +83,8 @@ super(tree); this.left = left; addChild(left); - this.ops = ops; - this.comparators = comparators; + this.ops = new ListWrapper<cmpopType>(ops); + this.comparators = new ListWrapper<exprType>(comparators); if (comparators != null) { for(PythonTree t : comparators) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/Delete.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Delete.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/Delete.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -21,7 +21,7 @@ public String[] get_fields() { return fields; } public Delete(java.util.List<exprType> targets) { - this.targets = targets; + this.targets = new ListWrapper<exprType>(targets); if (targets != null) { for(PythonTree t : targets) { addChild(t); @@ -31,7 +31,7 @@ public Delete(Token token, java.util.List<exprType> targets) { super(token); - this.targets = targets; + this.targets = new ListWrapper<exprType>(targets); if (targets != null) { for(PythonTree t : targets) { addChild(t); @@ -41,7 +41,7 @@ public Delete(int ttype, Token token, java.util.List<exprType> targets) { super(ttype, token); - this.targets = targets; + this.targets = new ListWrapper<exprType>(targets); if (targets != null) { for(PythonTree t : targets) { addChild(t); @@ -51,7 +51,7 @@ public Delete(PythonTree tree, java.util.List<exprType> targets) { super(tree); - this.targets = targets; + this.targets = new ListWrapper<exprType>(targets); if (targets != null) { for(PythonTree t : targets) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/Dict.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Dict.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/Dict.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -30,13 +30,13 @@ public Dict(java.util.List<exprType> keys, java.util.List<exprType> values) { - this.keys = keys; + this.keys = new ListWrapper<exprType>(keys); if (keys != null) { for(PythonTree t : keys) { addChild(t); } } - this.values = values; + this.values = new ListWrapper<exprType>(values); if (values != null) { for(PythonTree t : values) { addChild(t); @@ -47,13 +47,13 @@ public Dict(Token token, java.util.List<exprType> keys, java.util.List<exprType> values) { super(token); - this.keys = keys; + this.keys = new ListWrapper<exprType>(keys); if (keys != null) { for(PythonTree t : keys) { addChild(t); } } - this.values = values; + this.values = new ListWrapper<exprType>(values); if (values != null) { for(PythonTree t : values) { addChild(t); @@ -64,13 +64,13 @@ public Dict(int ttype, Token token, java.util.List<exprType> keys, java.util.List<exprType> values) { super(ttype, token); - this.keys = keys; + this.keys = new ListWrapper<exprType>(keys); if (keys != null) { for(PythonTree t : keys) { addChild(t); } } - this.values = values; + this.values = new ListWrapper<exprType>(values); if (values != null) { for(PythonTree t : values) { addChild(t); @@ -81,13 +81,13 @@ public Dict(PythonTree tree, java.util.List<exprType> keys, java.util.List<exprType> values) { super(tree); - this.keys = keys; + this.keys = new ListWrapper<exprType>(keys); if (keys != null) { for(PythonTree t : keys) { addChild(t); } } - this.values = values; + this.values = new ListWrapper<exprType>(values); if (values != null) { for(PythonTree t : values) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/ExtSlice.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/ExtSlice.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/ExtSlice.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -21,7 +21,7 @@ public String[] get_fields() { return fields; } public ExtSlice(java.util.List<sliceType> dims) { - this.dims = dims; + this.dims = new ListWrapper<sliceType>(dims); if (dims != null) { for(PythonTree t : dims) { addChild(t); @@ -31,7 +31,7 @@ public ExtSlice(Token token, java.util.List<sliceType> dims) { super(token); - this.dims = dims; + this.dims = new ListWrapper<sliceType>(dims); if (dims != null) { for(PythonTree t : dims) { addChild(t); @@ -41,7 +41,7 @@ public ExtSlice(int ttype, Token token, java.util.List<sliceType> dims) { super(ttype, token); - this.dims = dims; + this.dims = new ListWrapper<sliceType>(dims); if (dims != null) { for(PythonTree t : dims) { addChild(t); @@ -51,7 +51,7 @@ public ExtSlice(PythonTree tree, java.util.List<sliceType> dims) { super(tree); - this.dims = dims; + this.dims = new ListWrapper<sliceType>(dims); if (dims != null) { for(PythonTree t : dims) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/For.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/For.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/For.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -51,13 +51,13 @@ addChild(target); this.iter = iter; addChild(iter); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.orelse = orelse; + this.orelse = new ListWrapper<stmtType>(orelse); if (orelse != null) { for(PythonTree t : orelse) { addChild(t); @@ -72,13 +72,13 @@ addChild(target); this.iter = iter; addChild(iter); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.orelse = orelse; + this.orelse = new ListWrapper<stmtType>(orelse); if (orelse != null) { for(PythonTree t : orelse) { addChild(t); @@ -93,13 +93,13 @@ addChild(target); this.iter = iter; addChild(iter); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.orelse = orelse; + this.orelse = new ListWrapper<stmtType>(orelse); if (orelse != null) { for(PythonTree t : orelse) { addChild(t); @@ -114,13 +114,13 @@ addChild(target); this.iter = iter; addChild(iter); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.orelse = orelse; + this.orelse = new ListWrapper<stmtType>(orelse); if (orelse != null) { for(PythonTree t : orelse) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/FunctionDef.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/FunctionDef.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/FunctionDef.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -49,13 +49,13 @@ java.util.List<stmtType> body, java.util.List<exprType> decorators) { this.name = name; this.args = args; - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.decorators = decorators; + this.decorators = new ListWrapper<exprType>(decorators); if (decorators != null) { for(PythonTree t : decorators) { addChild(t); @@ -68,13 +68,13 @@ super(token); this.name = name; this.args = args; - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.decorators = decorators; + this.decorators = new ListWrapper<exprType>(decorators); if (decorators != null) { for(PythonTree t : decorators) { addChild(t); @@ -87,13 +87,13 @@ super(ttype, token); this.name = name; this.args = args; - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.decorators = decorators; + this.decorators = new ListWrapper<exprType>(decorators); if (decorators != null) { for(PythonTree t : decorators) { addChild(t); @@ -106,13 +106,13 @@ super(tree); this.name = name; this.args = args; - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.decorators = decorators; + this.decorators = new ListWrapper<exprType>(decorators); if (decorators != null) { for(PythonTree t : decorators) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -32,7 +32,7 @@ generators) { this.elt = elt; addChild(elt); - this.generators = generators; + this.generators = new ListWrapper<comprehensionType>(generators); if (generators != null) { for(PythonTree t : generators) { addChild(t); @@ -45,7 +45,7 @@ super(token); this.elt = elt; addChild(elt); - this.generators = generators; + this.generators = new ListWrapper<comprehensionType>(generators); if (generators != null) { for(PythonTree t : generators) { addChild(t); @@ -58,7 +58,7 @@ super(ttype, token); this.elt = elt; addChild(elt); - this.generators = generators; + this.generators = new ListWrapper<comprehensionType>(generators); if (generators != null) { for(PythonTree t : generators) { addChild(t); @@ -71,7 +71,7 @@ super(tree); this.elt = elt; addChild(elt); - this.generators = generators; + this.generators = new ListWrapper<comprehensionType>(generators); if (generators != null) { for(PythonTree t : generators) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/Global.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Global.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/Global.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -21,22 +21,22 @@ public String[] get_fields() { return fields; } public Global(java.util.List<String> names) { - this.names = names; + this.names = new ListWrapper<String>(names); } public Global(Token token, java.util.List<String> names) { super(token); - this.names = names; + this.names = new ListWrapper<String>(names); } public Global(int ttype, Token token, java.util.List<String> names) { super(ttype, token); - this.names = names; + this.names = new ListWrapper<String>(names); } public Global(PythonTree tree, java.util.List<String> names) { super(tree); - this.names = names; + this.names = new ListWrapper<String>(names); } public String toString() { Modified: branches/astwrite/src/org/python/antlr/ast/If.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/If.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/If.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -41,13 +41,13 @@ java.util.List<stmtType> orelse) { this.test = test; addChild(test); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.orelse = orelse; + this.orelse = new ListWrapper<stmtType>(orelse); if (orelse != null) { for(PythonTree t : orelse) { addChild(t); @@ -60,13 +60,13 @@ super(token); this.test = test; addChild(test); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.orelse = orelse; + this.orelse = new ListWrapper<stmtType>(orelse); if (orelse != null) { for(PythonTree t : orelse) { addChild(t); @@ -79,13 +79,13 @@ super(ttype, token); this.test = test; addChild(test); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.orelse = orelse; + this.orelse = new ListWrapper<stmtType>(orelse); if (orelse != null) { for(PythonTree t : orelse) { addChild(t); @@ -98,13 +98,13 @@ super(tree); this.test = test; addChild(test); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.orelse = orelse; + this.orelse = new ListWrapper<stmtType>(orelse); if (orelse != null) { for(PythonTree t : orelse) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/Import.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Import.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/Import.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -21,7 +21,7 @@ public String[] get_fields() { return fields; } public Import(java.util.List<aliasType> names) { - this.names = names; + this.names = new ListWrapper<aliasType>(names); if (names != null) { for(PythonTree t : names) { addChild(t); @@ -31,7 +31,7 @@ public Import(Token token, java.util.List<aliasType> names) { super(token); - this.names = names; + this.names = new ListWrapper<aliasType>(names); if (names != null) { for(PythonTree t : names) { addChild(t); @@ -41,7 +41,7 @@ public Import(int ttype, Token token, java.util.List<aliasType> names) { super(ttype, token); - this.names = names; + this.names = new ListWrapper<aliasType>(names); if (names != null) { for(PythonTree t : names) { addChild(t); @@ -51,7 +51,7 @@ public Import(PythonTree tree, java.util.List<aliasType> names) { super(tree); - this.names = names; + this.names = new ListWrapper<aliasType>(names); if (names != null) { for(PythonTree t : names) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/ImportFrom.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/ImportFrom.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/ImportFrom.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -40,7 +40,7 @@ public ImportFrom(String module, java.util.List<aliasType> names, int level) { this.module = module; - this.names = names; + this.names = new ListWrapper<aliasType>(names); if (names != null) { for(PythonTree t : names) { addChild(t); @@ -53,7 +53,7 @@ names, int level) { super(token); this.module = module; - this.names = names; + this.names = new ListWrapper<aliasType>(names); if (names != null) { for(PythonTree t : names) { addChild(t); @@ -66,7 +66,7 @@ java.util.List<aliasType> names, int level) { super(ttype, token); this.module = module; - this.names = names; + this.names = new ListWrapper<aliasType>(names); if (names != null) { for(PythonTree t : names) { addChild(t); @@ -79,7 +79,7 @@ names, int level) { super(tree); this.module = module; - this.names = names; + this.names = new ListWrapper<aliasType>(names); if (names != null) { for(PythonTree t : names) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/Interactive.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Interactive.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/Interactive.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -21,7 +21,7 @@ public String[] get_fields() { return fields; } public Interactive(java.util.List<stmtType> body) { - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); @@ -31,7 +31,7 @@ public Interactive(Token token, java.util.List<stmtType> body) { super(token); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); @@ -41,7 +41,7 @@ public Interactive(int ttype, Token token, java.util.List<stmtType> body) { super(ttype, token); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); @@ -51,7 +51,7 @@ public Interactive(PythonTree tree, java.util.List<stmtType> body) { super(tree); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/List.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/List.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/List.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -29,7 +29,7 @@ public String[] get_fields() { return fields; } public List(java.util.List<exprType> elts, expr_contextType ctx) { - this.elts = elts; + this.elts = new ListWrapper<exprType>(elts); if (elts != null) { for(PythonTree t : elts) { addChild(t); @@ -41,7 +41,7 @@ public List(Token token, java.util.List<exprType> elts, expr_contextType ctx) { super(token); - this.elts = elts; + this.elts = new ListWrapper<exprType>(elts); if (elts != null) { for(PythonTree t : elts) { addChild(t); @@ -53,7 +53,7 @@ public List(int ttype, Token token, java.util.List<exprType> elts, expr_contextType ctx) { super(ttype, token); - this.elts = elts; + this.elts = new ListWrapper<exprType>(elts); if (elts != null) { for(PythonTree t : elts) { addChild(t); @@ -65,7 +65,7 @@ public List(PythonTree tree, java.util.List<exprType> elts, expr_contextType ctx) { super(tree); - this.elts = elts; + this.elts = new ListWrapper<exprType>(elts); if (elts != null) { for(PythonTree t : elts) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/ListComp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/ListComp.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/ListComp.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -32,7 +32,7 @@ { this.elt = elt; addChild(elt); - this.generators = generators; + this.generators = new ListWrapper<comprehensionType>(generators); if (generators != null) { for(PythonTree t : generators) { addChild(t); @@ -45,7 +45,7 @@ super(token); this.elt = elt; addChild(elt); - this.generators = generators; + this.generators = new ListWrapper<comprehensionType>(generators); if (generators != null) { for(PythonTree t : generators) { addChild(t); @@ -58,7 +58,7 @@ super(ttype, token); this.elt = elt; addChild(elt); - this.generators = generators; + this.generators = new ListWrapper<comprehensionType>(generators); if (generators != null) { for(PythonTree t : generators) { addChild(t); @@ -71,7 +71,7 @@ super(tree); this.elt = elt; addChild(elt); - this.generators = generators; + this.generators = new ListWrapper<comprehensionType>(generators); if (generators != null) { for(PythonTree t : generators) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/Module.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Module.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/Module.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -21,7 +21,7 @@ public String[] get_fields() { return fields; } public Module(java.util.List<stmtType> body) { - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); @@ -31,7 +31,7 @@ public Module(Token token, java.util.List<stmtType> body) { super(token); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); @@ -41,7 +41,7 @@ public Module(int ttype, Token token, java.util.List<stmtType> body) { super(ttype, token); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); @@ -51,7 +51,7 @@ public Module(PythonTree tree, java.util.List<stmtType> body) { super(tree); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/Print.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Print.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/Print.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -40,7 +40,7 @@ public Print(exprType dest, java.util.List<exprType> values, boolean nl) { this.dest = dest; addChild(dest); - this.values = values; + this.values = new ListWrapper<exprType>(values); if (values != null) { for(PythonTree t : values) { addChild(t); @@ -54,7 +54,7 @@ super(token); this.dest = dest; addChild(dest); - this.values = values; + this.values = new ListWrapper<exprType>(values); if (values != null) { for(PythonTree t : values) { addChild(t); @@ -68,7 +68,7 @@ super(ttype, token); this.dest = dest; addChild(dest); - this.values = values; + this.values = new ListWrapper<exprType>(values); if (values != null) { for(PythonTree t : values) { addChild(t); @@ -82,7 +82,7 @@ super(tree); this.dest = dest; addChild(dest); - this.values = values; + this.values = new ListWrapper<exprType>(values); if (values != null) { for(PythonTree t : values) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/Suite.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Suite.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/Suite.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -21,7 +21,7 @@ public String[] get_fields() { return fields; } public Suite(java.util.List<stmtType> body) { - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); @@ -31,7 +31,7 @@ public Suite(Token token, java.util.List<stmtType> body) { super(token); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); @@ -41,7 +41,7 @@ public Suite(int ttype, Token token, java.util.List<stmtType> body) { super(ttype, token); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); @@ -51,7 +51,7 @@ public Suite(PythonTree tree, java.util.List<stmtType> body) { super(tree); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/TryExcept.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/TryExcept.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/TryExcept.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -40,19 +40,19 @@ public TryExcept(java.util.List<stmtType> body, java.util.List<excepthandlerType> handlers, java.util.List<stmtType> orelse) { - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.handlers = handlers; + this.handlers = new ListWrapper<excepthandlerType>(handlers); if (handlers != null) { for(PythonTree t : handlers) { addChild(t); } } - this.orelse = orelse; + this.orelse = new ListWrapper<stmtType>(orelse); if (orelse != null) { for(PythonTree t : orelse) { addChild(t); @@ -64,19 +64,19 @@ java.util.List<excepthandlerType> handlers, java.util.List<stmtType> orelse) { super(token); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.handlers = handlers; + this.handlers = new ListWrapper<excepthandlerType>(handlers); if (handlers != null) { for(PythonTree t : handlers) { addChild(t); } } - this.orelse = orelse; + this.orelse = new ListWrapper<stmtType>(orelse); if (orelse != null) { for(PythonTree t : orelse) { addChild(t); @@ -88,19 +88,19 @@ java.util.List<excepthandlerType> handlers, java.util.List<stmtType> orelse) { super(ttype, token); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.handlers = handlers; + this.handlers = new ListWrapper<excepthandlerType>(handlers); if (handlers != null) { for(PythonTree t : handlers) { addChild(t); } } - this.orelse = orelse; + this.orelse = new ListWrapper<stmtType>(orelse); if (orelse != null) { for(PythonTree t : orelse) { addChild(t); @@ -112,19 +112,19 @@ java.util.List<excepthandlerType> handlers, java.util.List<stmtType> orelse) { super(tree); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.handlers = handlers; + this.handlers = new ListWrapper<excepthandlerType>(handlers); if (handlers != null) { for(PythonTree t : handlers) { addChild(t); } } - this.orelse = orelse; + this.orelse = new ListWrapper<stmtType>(orelse); if (orelse != null) { for(PythonTree t : orelse) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/TryFinally.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/TryFinally.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/TryFinally.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -30,13 +30,13 @@ public TryFinally(java.util.List<stmtType> body, java.util.List<stmtType> finalbody) { - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.finalbody = finalbody; + this.finalbody = new ListWrapper<stmtType>(finalbody); if (finalbody != null) { for(PythonTree t : finalbody) { addChild(t); @@ -47,13 +47,13 @@ public TryFinally(Token token, java.util.List<stmtType> body, java.util.List<stmtType> finalbody) { super(token); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.finalbody = finalbody; + this.finalbody = new ListWrapper<stmtType>(finalbody); if (finalbody != null) { for(PythonTree t : finalbody) { addChild(t); @@ -64,13 +64,13 @@ public TryFinally(int ttype, Token token, java.util.List<stmtType> body, java.util.List<stmtType> finalbody) { super(ttype, token); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.finalbody = finalbody; + this.finalbody = new ListWrapper<stmtType>(finalbody); if (finalbody != null) { for(PythonTree t : finalbody) { addChild(t); @@ -81,13 +81,13 @@ public TryFinally(PythonTree tree, java.util.List<stmtType> body, java.util.List<stmtType> finalbody) { super(tree); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.finalbody = finalbody; + this.finalbody = new ListWrapper<stmtType>(finalbody); if (finalbody != null) { for(PythonTree t : finalbody) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/Tuple.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Tuple.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/Tuple.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -29,7 +29,7 @@ public String[] get_fields() { return fields; } public Tuple(java.util.List<exprType> elts, expr_contextType ctx) { - this.elts = elts; + this.elts = new ListWrapper<exprType>(elts); if (elts != null) { for(PythonTree t : elts) { addChild(t); @@ -41,7 +41,7 @@ public Tuple(Token token, java.util.List<exprType> elts, expr_contextType ctx) { super(token); - this.elts = elts; + this.elts = new ListWrapper<exprType>(elts); if (elts != null) { for(PythonTree t : elts) { addChild(t); @@ -53,7 +53,7 @@ public Tuple(int ttype, Token token, java.util.List<exprType> elts, expr_contextType ctx) { super(ttype, token); - this.elts = elts; + this.elts = new ListWrapper<exprType>(elts); if (elts != null) { for(PythonTree t : elts) { addChild(t); @@ -65,7 +65,7 @@ public Tuple(PythonTree tree, java.util.List<exprType> elts, expr_contextType ctx) { super(tree); - this.elts = elts; + this.elts = new ListWrapper<exprType>(elts); if (elts != null) { for(PythonTree t : elts) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/While.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/While.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/While.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -41,13 +41,13 @@ java.util.List<stmtType> orelse) { this.test = test; addChild(test); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.orelse = orelse; + this.orelse = new ListWrapper<stmtType>(orelse); if (orelse != null) { for(PythonTree t : orelse) { addChild(t); @@ -60,13 +60,13 @@ super(token); this.test = test; addChild(test); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.orelse = orelse; + this.orelse = new ListWrapper<stmtType>(orelse); if (orelse != null) { for(PythonTree t : orelse) { addChild(t); @@ -79,13 +79,13 @@ super(ttype, token); this.test = test; addChild(test); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.orelse = orelse; + this.orelse = new ListWrapper<stmtType>(orelse); if (orelse != null) { for(PythonTree t : orelse) { addChild(t); @@ -98,13 +98,13 @@ super(tree); this.test = test; addChild(test); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); } } - this.orelse = orelse; + this.orelse = new ListWrapper<stmtType>(orelse); if (orelse != null) { for(PythonTree t : orelse) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/With.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/With.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/With.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -44,7 +44,7 @@ addChild(context_expr); this.optional_vars = optional_vars; addChild(optional_vars); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); @@ -59,7 +59,7 @@ addChild(context_expr); this.optional_vars = optional_vars; addChild(optional_vars); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); @@ -74,7 +74,7 @@ addChild(context_expr); this.optional_vars = optional_vars; addChild(optional_vars); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); @@ -89,7 +89,7 @@ addChild(context_expr); this.optional_vars = optional_vars; addChild(optional_vars); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/argumentsType.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/argumentsType.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/argumentsType.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -47,7 +47,7 @@ public argumentsType(java.util.List<exprType> args, String vararg, String kwarg, java.util.List<exprType> defaults) { - this.args = args; + this.args = new ListWrapper<exprType>(args); if (args != null) { for(PythonTree t : args) { addChild(t); @@ -55,7 +55,7 @@ } this.vararg = vararg; this.kwarg = kwarg; - this.defaults = defaults; + this.defaults = new ListWrapper<exprType>(defaults); if (defaults != null) { for(PythonTree t : defaults) { addChild(t); @@ -66,7 +66,7 @@ public argumentsType(Token token, java.util.List<exprType> args, String vararg, String kwarg, java.util.List<exprType> defaults) { super(token); - this.args = args; + this.args = new ListWrapper<exprType>(args); if (args != null) { for(PythonTree t : args) { addChild(t); @@ -74,7 +74,7 @@ } this.vararg = vararg; this.kwarg = kwarg; - this.defaults = defaults; + this.defaults = new ListWrapper<exprType>(defaults); if (defaults != null) { for(PythonTree t : defaults) { addChild(t); @@ -85,7 +85,7 @@ public argumentsType(int ttype, Token token, java.util.List<exprType> args, String vararg, String kwarg, java.util.List<exprType> defaults) { super(ttype, token); - this.args = args; + this.args = new ListWrapper<exprType>(args); if (args != null) { for(PythonTree t : args) { addChild(t); @@ -93,7 +93,7 @@ } this.vararg = vararg; this.kwarg = kwarg; - this.defaults = defaults; + this.defaults = new ListWrapper<exprType>(defaults); if (defaults != null) { for(PythonTree t : defaults) { addChild(t); @@ -104,7 +104,7 @@ public argumentsType(PythonTree tree, java.util.List<exprType> args, String vararg, String kwarg, java.util.List<exprType> defaults) { super(tree); - this.args = args; + this.args = new ListWrapper<exprType>(args); if (args != null) { for(PythonTree t : args) { addChild(t); @@ -112,7 +112,7 @@ } this.vararg = vararg; this.kwarg = kwarg; - this.defaults = defaults; + this.defaults = new ListWrapper<exprType>(defaults); if (defaults != null) { for(PythonTree t : defaults) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/comprehensionType.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/comprehensionType.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/comprehensionType.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -43,7 +43,7 @@ addChild(target); this.iter = iter; addChild(iter); - this.ifs = ifs; + this.ifs = new ListWrapper<exprType>(ifs); if (ifs != null) { for(PythonTree t : ifs) { addChild(t); @@ -58,7 +58,7 @@ addChild(target); this.iter = iter; addChild(iter); - this.ifs = ifs; + this.ifs = new ListWrapper<exprType>(ifs); if (ifs != null) { for(PythonTree t : ifs) { addChild(t); @@ -73,7 +73,7 @@ addChild(target); this.iter = iter; addChild(iter); - this.ifs = ifs; + this.ifs = new ListWrapper<exprType>(ifs); if (ifs != null) { for(PythonTree t : ifs) { addChild(t); @@ -88,7 +88,7 @@ addChild(target); this.iter = iter; addChild(iter); - this.ifs = ifs; + this.ifs = new ListWrapper<exprType>(ifs); if (ifs != null) { for(PythonTree t : ifs) { addChild(t); Modified: branches/astwrite/src/org/python/antlr/ast/excepthandlerType.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/excepthandlerType.java 2008-11-20 22:22:29 UTC (rev 5594) +++ branches/astwrite/src/org/python/antlr/ast/excepthandlerType.java 2008-11-20 23:44:08 UTC (rev 5595) @@ -60,7 +60,7 @@ addChild(excepttype); this.name = name; addChild(name); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); @@ -77,7 +77,7 @@ addChild(excepttype); this.name = name; addChild(name); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); @@ -94,7 +94,7 @@ addChild(excepttype); this.name = name; addChild(name); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); @@ -111,7 +111,7 @@ addChild(excepttype); this.name = name; addChild(name); - this.body = body; + this.body = new ListWrapper<stmtType>(body); if (body != null) { for(PythonTree t : body) { addChild(t); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-11-20 22:22:35
|
Revision: 5594 http://jython.svn.sourceforge.net/jython/?rev=5594&view=rev Author: fwierzbicki Date: 2008-11-20 22:22:29 +0000 (Thu, 20 Nov 2008) Log Message: ----------- Experimenting with a class I'm calling "ListWrapper" for the moment. The idea is to expose something like a Python list for ast writing from Python code without actually using PyList. I don't want to use PyList because everything would need to be PyObject -- which I am trying to avoid in the ast for now. Anyway, like I said this is experimental. Modified Paths: -------------- branches/astwrite/Lib/test/test_ast.py branches/astwrite/ast/asdl_antlr.py branches/astwrite/src/org/python/antlr/ast/Assert.java branches/astwrite/src/org/python/antlr/ast/Assign.java branches/astwrite/src/org/python/antlr/ast/Attribute.java branches/astwrite/src/org/python/antlr/ast/AugAssign.java branches/astwrite/src/org/python/antlr/ast/BinOp.java branches/astwrite/src/org/python/antlr/ast/BoolOp.java branches/astwrite/src/org/python/antlr/ast/Break.java branches/astwrite/src/org/python/antlr/ast/Call.java branches/astwrite/src/org/python/antlr/ast/ClassDef.java branches/astwrite/src/org/python/antlr/ast/Compare.java branches/astwrite/src/org/python/antlr/ast/Continue.java branches/astwrite/src/org/python/antlr/ast/Delete.java branches/astwrite/src/org/python/antlr/ast/Dict.java branches/astwrite/src/org/python/antlr/ast/Ellipsis.java branches/astwrite/src/org/python/antlr/ast/Exec.java branches/astwrite/src/org/python/antlr/ast/Expr.java branches/astwrite/src/org/python/antlr/ast/Expression.java branches/astwrite/src/org/python/antlr/ast/ExtSlice.java branches/astwrite/src/org/python/antlr/ast/For.java branches/astwrite/src/org/python/antlr/ast/FunctionDef.java branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java branches/astwrite/src/org/python/antlr/ast/Global.java branches/astwrite/src/org/python/antlr/ast/If.java branches/astwrite/src/org/python/antlr/ast/IfExp.java branches/astwrite/src/org/python/antlr/ast/Import.java branches/astwrite/src/org/python/antlr/ast/ImportFrom.java branches/astwrite/src/org/python/antlr/ast/Index.java branches/astwrite/src/org/python/antlr/ast/Interactive.java branches/astwrite/src/org/python/antlr/ast/Lambda.java branches/astwrite/src/org/python/antlr/ast/List.java branches/astwrite/src/org/python/antlr/ast/ListComp.java branches/astwrite/src/org/python/antlr/ast/Module.java branches/astwrite/src/org/python/antlr/ast/Name.java branches/astwrite/src/org/python/antlr/ast/Num.java branches/astwrite/src/org/python/antlr/ast/Pass.java branches/astwrite/src/org/python/antlr/ast/Print.java branches/astwrite/src/org/python/antlr/ast/Raise.java branches/astwrite/src/org/python/antlr/ast/Repr.java branches/astwrite/src/org/python/antlr/ast/Return.java branches/astwrite/src/org/python/antlr/ast/Slice.java branches/astwrite/src/org/python/antlr/ast/Str.java branches/astwrite/src/org/python/antlr/ast/Subscript.java branches/astwrite/src/org/python/antlr/ast/Suite.java branches/astwrite/src/org/python/antlr/ast/TryExcept.java branches/astwrite/src/org/python/antlr/ast/TryFinally.java branches/astwrite/src/org/python/antlr/ast/Tuple.java branches/astwrite/src/org/python/antlr/ast/UnaryOp.java branches/astwrite/src/org/python/antlr/ast/VisitorBase.java branches/astwrite/src/org/python/antlr/ast/While.java branches/astwrite/src/org/python/antlr/ast/With.java branches/astwrite/src/org/python/antlr/ast/Yield.java branches/astwrite/src/org/python/antlr/ast/aliasType.java branches/astwrite/src/org/python/antlr/ast/argumentsType.java branches/astwrite/src/org/python/antlr/ast/comprehensionType.java branches/astwrite/src/org/python/antlr/ast/excepthandlerType.java branches/astwrite/src/org/python/antlr/ast/exprType.java branches/astwrite/src/org/python/antlr/ast/keywordType.java branches/astwrite/src/org/python/antlr/ast/modType.java branches/astwrite/src/org/python/antlr/ast/sliceType.java branches/astwrite/src/org/python/antlr/ast/stmtType.java Added Paths: ----------- branches/astwrite/src/org/python/antlr/ListWrapper.java Property Changed: ---------------- branches/astwrite/src/org/python/antlr/ branches/astwrite/src/org/python/antlr/ast/ Modified: branches/astwrite/Lib/test/test_ast.py =================================================================== --- branches/astwrite/Lib/test/test_ast.py 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/Lib/test/test_ast.py 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,5 +1,5 @@ -#Taken and modified from CPython's release25-maint branch, revision 62446. -import sys,os, itertools +import sys, itertools, unittest +from test import test_support import ast if sys.platform.startswith('java'): @@ -7,7 +7,7 @@ ast_list = java.util.List get_symbol_key = lambda op: op - + def get_class_name(t): result = t.__class__.__name__ if result in ("expr_contextType", @@ -34,15 +34,16 @@ return t elif isinstance(t, ast_list): return [to_tuple(e) for e in t] - result = [get_class_name(t)] + result = [t.__class__.__name__] if hasattr(t, 'lineno') and hasattr(t, 'col_offset'): result.append((t.lineno, t.col_offset)) - if not hasattr(t, '_fields') or t._fields is None: + if t._fields is None: return tuple(result) for f in t._fields: result.append(to_tuple(getattr(t, f))) return tuple(result) + # These tests are compiled through "exec" # There should be atleast one test per statement exec_tests = [ @@ -146,49 +147,179 @@ # TODO: expr_context, slice, boolop, operator, unaryop, cmpop, comprehension # excepthandler, arguments, keywords, alias -if __name__=='__main__' and sys.argv[1:] == ['-g']: - for statements, kind in ((exec_tests, "exec"), (single_tests, "single"), - (eval_tests, "eval")): - print kind+"_results = [" - for s in statements: - print repr(to_tuple(compile(s, "?", kind, 0x400)))+"," - print "]" - print "run_tests()" - raise SystemExit +class AST_Tests(unittest.TestCase): -def test_order(ast_node, parent_pos): - - if (not isinstance(ast_node, ast.AST) - or not hasattr(ast_node, '_fields') - or ast_node._fields == None): + def _assert_order(self, ast_node, parent_pos): + if not isinstance(ast_node, ast.AST) or ast_node._fields is None: return - if isinstance(ast_node, (ast.expr, ast.stmt, ast.excepthandler)): - node_pos = (ast_node.lineno, ast_node.col_offset) - assert node_pos >= parent_pos, (node_pos, parent_pos) - parent_pos = (ast_node.lineno, ast_node.col_offset) - for name in ast_node._fields: - value = getattr(ast_node, name) - if isinstance(value, ast_list): - for child in value: - test_order(child, parent_pos) - elif value != None: - test_order(value, parent_pos) + if isinstance(ast_node, (ast.expr, ast.stmt, ast.excepthandler)): + node_pos = (ast_node.lineno, ast_node.col_offset) + self.assert_(node_pos >= parent_pos) + parent_pos = (ast_node.lineno, ast_node.col_offset) + for name in ast_node._fields: + value = getattr(ast_node, name) + if isinstance(value, ast_list): + for child in value: + self._assert_order(child, parent_pos) + elif value is not None: + self._assert_order(value, parent_pos) -def run_tests(): - for input, output, kind in ((exec_tests, exec_results, "exec"), - (single_tests, single_results, "single"), - (eval_tests, eval_results, "eval")): - for i, o in itertools.izip(input, output): - ast_tree = compile(i, "?", kind, 0x400) - assert to_tuple(ast_tree) == o, "expected %s, got %s" % ( - o, to_tuple(ast_tree)) - test_order(ast_tree, (0, 0)) + def test_snippets(self): + for input, output, kind in ((exec_tests, exec_results, "exec"), + (single_tests, single_results, "single"), + (eval_tests, eval_results, "eval")): + for i, o in itertools.izip(input, output): + ast_tree = compile(i, "?", kind, ast.PyCF_ONLY_AST) + self.assertEquals(to_tuple(ast_tree), o) + self._assert_order(ast_tree, (0, 0)) -# XXX: AugStore added for Jython. Short term it is too hard to emit just "Store" as CPython does. + def test_nodeclasses(self): + x = ast.BinOp(1, 2, 3, lineno=0) + self.assertEquals(x.left, 1) + self.assertEquals(x.op, 2) + self.assertEquals(x.right, 3) + self.assertEquals(x.lineno, 0) + + # node raises exception when not given enough arguments + self.assertRaises(TypeError, ast.BinOp, 1, 2) + + # can set attributes through kwargs too + x = ast.BinOp(left=1, op=2, right=3, lineno=0) + self.assertEquals(x.left, 1) + self.assertEquals(x.op, 2) + self.assertEquals(x.right, 3) + self.assertEquals(x.lineno, 0) + + # this used to fail because Sub._fields was None + x = ast.Sub() + + def test_pickling(self): + import pickle + mods = [pickle] + try: + import cPickle + mods.append(cPickle) + except ImportError: + pass + protocols = [0, 1, 2] + for mod in mods: + for protocol in protocols: + for ast in (compile(i, "?", "exec", 0x400) for i in exec_tests): + ast2 = mod.loads(mod.dumps(ast, protocol)) + self.assertEquals(to_tuple(ast2), to_tuple(ast)) + + +class ASTHelpers_Test(unittest.TestCase): + + def test_parse(self): + a = ast.parse('foo(1 + 1)') + b = compile('foo(1 + 1)', '<unknown>', 'exec', ast.PyCF_ONLY_AST) + self.assertEqual(ast.dump(a), ast.dump(b)) + + def test_dump(self): + node = ast.parse('spam(eggs, "and cheese")') + self.assertEqual(ast.dump(node), + "Module(body=[Expr(value=Call(func=Name(id='spam', ctx=Load()), " + "args=[Name(id='eggs', ctx=Load()), Str(s='and cheese')], " + "keywords=[], starargs=None, kwargs=None))])" + ) + self.assertEqual(ast.dump(node, annotate_fields=False), + "Module([Expr(Call(Name('spam', Load()), [Name('eggs', Load()), " + "Str('and cheese')], [], None, None))])" + ) + self.assertEqual(ast.dump(node, include_attributes=True), + "Module(body=[Expr(value=Call(func=Name(id='spam', ctx=Load(), " + "lineno=1, col_offset=0), args=[Name(id='eggs', ctx=Load(), " + "lineno=1, col_offset=5), Str(s='and cheese', lineno=1, " + "col_offset=11)], keywords=[], starargs=None, kwargs=None, " + "lineno=1, col_offset=0), lineno=1, col_offset=0)])" + ) + + def test_copy_location(self): + src = ast.parse('1 + 1', mode='eval') + src.body.right = ast.copy_location(ast.Num(2), src.body.right) + self.assertEqual(ast.dump(src, include_attributes=True), + 'Expression(body=BinOp(left=Num(n=1, lineno=1, col_offset=0), ' + 'op=Add(), right=Num(n=2, lineno=1, col_offset=4), lineno=1, ' + 'col_offset=0))' + ) + + def test_fix_missing_locations(self): + src = ast.parse('write("spam")') + src.body.append(ast.Expr(ast.Call(ast.Name('spam', ast.Load()), + [ast.Str('eggs')], [], None, None))) + self.assertEqual(src, ast.fix_missing_locations(src)) + self.assertEqual(ast.dump(src, include_attributes=True), + "Module(body=[Expr(value=Call(func=Name(id='write', ctx=Load(), " + "lineno=1, col_offset=0), args=[Str(s='spam', lineno=1, " + "col_offset=6)], keywords=[], starargs=None, kwargs=None, " + "lineno=1, col_offset=0), lineno=1, col_offset=0), " + "Expr(value=Call(func=Name(id='spam', ctx=Load(), lineno=1, " + "col_offset=0), args=[Str(s='eggs', lineno=1, col_offset=0)], " + "keywords=[], starargs=None, kwargs=None, lineno=1, " + "col_offset=0), lineno=1, col_offset=0)])" + ) + + def test_increment_lineno(self): + src = ast.parse('1 + 1', mode='eval') + self.assertEqual(ast.increment_lineno(src, n=3), src) + self.assertEqual(ast.dump(src, include_attributes=True), + 'Expression(body=BinOp(left=Num(n=1, lineno=4, col_offset=0), ' + 'op=Add(), right=Num(n=1, lineno=4, col_offset=4), lineno=4, ' + 'col_offset=0))' + ) + + def test_iter_fields(self): + node = ast.parse('foo()', mode='eval') + d = dict(ast.iter_fields(node.body)) + self.assertEqual(d.pop('func').id, 'foo') + self.assertEqual(d, {'keywords': [], 'kwargs': None, + 'args': [], 'starargs': None}) + + def test_iter_child_nodes(self): + node = ast.parse("spam(23, 42, eggs='leek')", mode='eval') + self.assertEqual(len(list(ast.iter_child_nodes(node.body))), 4) + iterator = ast.iter_child_nodes(node.body) + self.assertEqual(next(iterator).id, 'spam') + self.assertEqual(next(iterator).n, 23) + self.assertEqual(next(iterator).n, 42) + self.assertEqual(ast.dump(next(iterator)), + "keyword(arg='eggs', value=Str(s='leek'))" + ) + + def test_get_docstring(self): + node = ast.parse('def foo():\n """line one\n line two"""') + self.assertEqual(ast.get_docstring(node.body[0]), + 'line one\nline two') + + def test_literal_eval(self): + self.assertEqual(ast.literal_eval('[1, 2, 3]'), [1, 2, 3]) + self.assertEqual(ast.literal_eval('{"foo": 42}'), {"foo": 42}) + self.assertEqual(ast.literal_eval('(True, False, None)'), (True, False, None)) + self.assertRaises(ValueError, ast.literal_eval, 'foo()') + + +def test_main(): + test_support.run_unittest(AST_Tests, ASTHelpers_Test) + +def main(): + if __name__ != '__main__': + return + if sys.argv[1:] == ['-g']: + for statements, kind in ((exec_tests, "exec"), (single_tests, "single"), + (eval_tests, "eval")): + print kind+"_results = [" + for s in statements: + print repr(to_tuple(compile(s, "?", kind, 0x400)))+"," + print "]" + print "main()" + raise SystemExit + test_main() + #### EVERYTHING BELOW IS GENERATED ##### exec_results = [ ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, []), [('Pass', (1, 9))], [])]), -('Module', [('ClassDef', (1, 0), 'C', [], [('Pass', (1, 8))],[])]), +('Module', [('ClassDef', (1, 0), 'C', [], [('Pass', (1, 8))], [])]), ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, []), [('Return', (1, 8), ('Num', (1, 15), 1))], [])]), ('Module', [('Delete', (1, 0), [('Name', (1, 4), 'v', ('Del',))])]), ('Module', [('Assign', (1, 0), [('Name', (1, 0), 'v', ('Store',))], ('Num', (1, 4), 1))]), @@ -198,7 +329,7 @@ ('Module', [('While', (1, 0), ('Name', (1, 6), 'v', ('Load',)), [('Pass', (1, 8))], [])]), ('Module', [('If', (1, 0), ('Name', (1, 3), 'v', ('Load',)), [('Pass', (1, 5))], [])]), ('Module', [('Raise', (1, 0), ('Name', (1, 6), 'Exception', ('Load',)), ('Str', (1, 17), 'string'), None)]), -('Module', [('TryExcept', (1, 0), [('Pass', (2, 2))], [('excepthandler', (3, 0), ('Name', (3, 7), 'Exception', ('Load',)), None, [('Pass', (4, 2))], 3, 0)], [])]), +('Module', [('TryExcept', (1, 0), [('Pass', (2, 2))], [('ExceptHandler', (3, 0), ('Name', (3, 7), 'Exception', ('Load',)), None, [('Pass', (4, 2))])], [])]), ('Module', [('TryFinally', (1, 0), [('Pass', (2, 2))], [('Pass', (4, 2))])]), ('Module', [('Assert', (1, 0), ('Name', (1, 7), 'v', ('Load',)), None)]), ('Module', [('Import', (1, 0), [('alias', 'sys', None)])]), @@ -233,4 +364,4 @@ ('Expression', ('Tuple', (1, 0), [('Num', (1, 0), 1), ('Num', (1, 2), 2), ('Num', (1, 4), 3)], ('Load',))), ('Expression', ('Call', (1, 0), ('Attribute', (1, 0), ('Attribute', (1, 0), ('Attribute', (1, 0), ('Name', (1, 0), 'a', ('Load',)), 'b', ('Load',)), 'c', ('Load',)), 'd', ('Load',)), [('Subscript', (1, 8), ('Attribute', (1, 8), ('Name', (1, 8), 'a', ('Load',)), 'b', ('Load',)), ('Slice', ('Num', (1, 12), 1), ('Num', (1, 14), 2), None), ('Load',))], [], None, None)), ] -run_tests() +main() Modified: branches/astwrite/ast/asdl_antlr.py =================================================================== --- branches/astwrite/ast/asdl_antlr.py 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/ast/asdl_antlr.py 2008-11-20 22:22:29 UTC (rev 5594) @@ -57,6 +57,7 @@ print >> self.file, 'package org.python.antlr.ast;' if refersToPythonTree: print >> self.file, 'import org.python.antlr.PythonTree;' + print >> self.file, 'import org.python.antlr.ListWrapper;' print >> self.file, 'import org.antlr.runtime.CommonToken;' print >> self.file, 'import org.antlr.runtime.Token;' if useDataOutput: @@ -291,6 +292,7 @@ def javaConstructorHelper(self, fields, depth): for f in fields: self.emit("this.%s = %s;" % (f.name, f.name), depth+1) + #self.emit("set%s(%s);" % (str(f.name).capitalize(), f.name), depth+1) fparg = self.fieldDef(f) not_simple = True @@ -399,14 +401,18 @@ self.emit("", 0) def visitField(self, field, depth): - self.emit("private %s;" % self.fieldDef(field), depth) - self.emit("public %s get%s() {" % (self.javaType(field), + self.emit("private %s;" % self.fieldDef(field, True), depth) + self.emit("public %s get%s() {" % (self.javaType(field, True), str(field.name).capitalize()), depth) self.emit("return %s;" % field.name, depth+1) self.emit("}", depth) self.emit("public void set%s(%s) {" % (str(field.name).capitalize(), self.fieldDef(field)), depth) - self.emit("this.%s = %s;" % (field.name, field.name), depth+1) + if field.seq: + self.emit("this.%s = new %s(%s);" % (field.name, + self.javaType(field, True), field.name), depth+1) + else: + self.emit("this.%s = %s;" % (field.name, field.name), depth+1) self.emit("}", depth) self.emit("", 0) @@ -420,16 +426,20 @@ 'PythonTree' : 'PythonTree', # also for antlr type } - def fieldDef(self, field): - jtype = self.javaType(field) + def fieldDef(self, field, wrapper=False): + jtype = self.javaType(field, wrapper) name = field.name return "%s %s" % (jtype, name) - def javaType(self, field): + def javaType(self, field, wrapper=False): jtype = str(field.type) jtype = self.bltinnames.get(jtype, jtype + 'Type') if field.seq: - return "java.util.List<%s>" % jtype + if wrapper: + return "ListWrapper<%s>" % jtype + else: + return "java.util.List<%s>" % jtype + return jtype class VisitorVisitor(EmitVisitor): Property changes on: branches/astwrite/src/org/python/antlr ___________________________________________________________________ Added: svn:ignore + .ListWrapper.java.swp Added: branches/astwrite/src/org/python/antlr/ListWrapper.java =================================================================== --- branches/astwrite/src/org/python/antlr/ListWrapper.java (rev 0) +++ branches/astwrite/src/org/python/antlr/ListWrapper.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -0,0 +1,213 @@ +package org.python.antlr; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import org.python.core.PyObject; + +public class ListWrapper<E> implements List<E> { + + private List<E> list; + + public ListWrapper(List<E> list) { + this.list = list; + } + + public boolean containsAll(Collection c) { + return containsAll(c); + } + + public boolean removeAll(Collection c) { + return list.removeAll(c); + } + + public boolean retainAll(Collection c) { + return list.retainAll(c); + } + + public boolean add(E e) { + return list.add(e); + } + + public void add(int index, E e) { + list.add(index, e); + } + + public boolean addAll(Collection c) { + return list.addAll(c); + } + + public boolean addAll(int index, Collection c) { + return list.addAll(index, c); + } + + public void clear() { + list.clear(); + } + + public boolean contains(Object elem) { + return list.contains(elem); + } + + public E get(int index) { + return list.get(index); + } + + public int indexOf(Object elem) { + return list.indexOf(elem); + } + + public boolean isEmpty() { + return list.isEmpty(); + } + + public int lastIndexOf(Object elem) { + return list.lastIndexOf(elem); + } + + public E remove(int index) { + return list.remove(index); + } + + public boolean remove(Object o) { + return list.remove(o); + } + + public E set(int index, E element) { + return list.set(index, element); + } + + public int size() { + return list.size(); + } + + public Object[] toArray() { + return list.toArray(); + } + + public Object[] toArray(Object[] a) { + return list.toArray(a); + } + + public Iterator iterator() { + return list.iterator(); + } + + public ListIterator listIterator() { + return list.listIterator(); + } + + public ListIterator listIterator(int index) { + return list.listIterator(index); + } + + public List subList(int fromIndex, int toIndex) { + return list.subList(fromIndex, toIndex); + } + + public ListWrapper __add__(Object o) { + List newList = new ArrayList(); + newList.addAll(list); + newList.add(o); + return new ListWrapper(newList); + } + + public void __iadd__(PyObject o) { + extend(o); + } + + public int __len__() { + return list.size(); + } + + public boolean __contains__(Object o) { + return list.contains(o); + } + + public PyObject __imul__(PyObject o) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public PyObject __iter__() { + throw new UnsupportedOperationException("Not supported yet."); + } + + public PyObject __mul__(PyObject o) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public PyObject __radd__(PyObject o) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public PyObject __rmul__(PyObject o) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void append(PyObject o) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public int count(PyObject o) { + throw new UnsupportedOperationException("Not supported yet."); + } + + protected void del(int i) { + throw new UnsupportedOperationException("Not supported yet."); + } + + protected void delRange(int start, int stop, int step) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void extend(PyObject o) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public int index(PyObject o) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public int index(PyObject o, int start) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public int index(PyObject o, int start, int stop) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void insert(int index, PyObject o) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public PyObject pop() { + throw new UnsupportedOperationException("Not supported yet."); + } + + public PyObject pop(int n) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void remove(PyObject o) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void reverse() { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void sort(PyObject compare) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void sort() { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void sort(PyObject cmp, PyObject key, PyObject reverse) { + throw new UnsupportedOperationException("Not supported yet."); + } + +} Property changes on: branches/astwrite/src/org/python/antlr/ast ___________________________________________________________________ Added: svn:ignore + .comprehensionType.java.swp Modified: branches/astwrite/src/org/python/antlr/ast/Assert.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Assert.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Assert.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; Modified: branches/astwrite/src/org/python/antlr/ast/Assign.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Assign.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Assign.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,18 +1,19 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; import java.io.IOException; public class Assign extends stmtType { - private java.util.List<exprType> targets; - public java.util.List<exprType> getTargets() { + private ListWrapper<exprType> targets; + public ListWrapper<exprType> getTargets() { return targets; } public void setTargets(java.util.List<exprType> targets) { - this.targets = targets; + this.targets = new ListWrapper<exprType>(targets); } private exprType value; Modified: branches/astwrite/src/org/python/antlr/ast/Attribute.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Attribute.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Attribute.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; Modified: branches/astwrite/src/org/python/antlr/ast/AugAssign.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/AugAssign.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/AugAssign.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; Modified: branches/astwrite/src/org/python/antlr/ast/BinOp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/BinOp.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/BinOp.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; Modified: branches/astwrite/src/org/python/antlr/ast/BoolOp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/BoolOp.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/BoolOp.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; @@ -15,12 +16,12 @@ this.op = op; } - private java.util.List<exprType> values; - public java.util.List<exprType> getValues() { + private ListWrapper<exprType> values; + public ListWrapper<exprType> getValues() { return values; } public void setValues(java.util.List<exprType> values) { - this.values = values; + this.values = new ListWrapper<exprType>(values); } Modified: branches/astwrite/src/org/python/antlr/ast/Break.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Break.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Break.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; Modified: branches/astwrite/src/org/python/antlr/ast/Call.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Call.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Call.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; @@ -15,20 +16,20 @@ this.func = func; } - private java.util.List<exprType> args; - public java.util.List<exprType> getArgs() { + private ListWrapper<exprType> args; + public ListWrapper<exprType> getArgs() { return args; } public void setArgs(java.util.List<exprType> args) { - this.args = args; + this.args = new ListWrapper<exprType>(args); } - private java.util.List<keywordType> keywords; - public java.util.List<keywordType> getKeywords() { + private ListWrapper<keywordType> keywords; + public ListWrapper<keywordType> getKeywords() { return keywords; } public void setKeywords(java.util.List<keywordType> keywords) { - this.keywords = keywords; + this.keywords = new ListWrapper<keywordType>(keywords); } private exprType starargs; Modified: branches/astwrite/src/org/python/antlr/ast/ClassDef.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/ClassDef.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/ClassDef.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; @@ -15,28 +16,28 @@ this.name = name; } - private java.util.List<exprType> bases; - public java.util.List<exprType> getBases() { + private ListWrapper<exprType> bases; + public ListWrapper<exprType> getBases() { return bases; } public void setBases(java.util.List<exprType> bases) { - this.bases = bases; + this.bases = new ListWrapper<exprType>(bases); } - private java.util.List<stmtType> body; - public java.util.List<stmtType> getBody() { + private ListWrapper<stmtType> body; + public ListWrapper<stmtType> getBody() { return body; } public void setBody(java.util.List<stmtType> body) { - this.body = body; + this.body = new ListWrapper<stmtType>(body); } - private java.util.List<exprType> decorators; - public java.util.List<exprType> getDecorators() { + private ListWrapper<exprType> decorators; + public ListWrapper<exprType> getDecorators() { return decorators; } public void setDecorators(java.util.List<exprType> decorators) { - this.decorators = decorators; + this.decorators = new ListWrapper<exprType>(decorators); } Modified: branches/astwrite/src/org/python/antlr/ast/Compare.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Compare.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Compare.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; @@ -15,20 +16,20 @@ this.left = left; } - private java.util.List<cmpopType> ops; - public java.util.List<cmpopType> getOps() { + private ListWrapper<cmpopType> ops; + public ListWrapper<cmpopType> getOps() { return ops; } public void setOps(java.util.List<cmpopType> ops) { - this.ops = ops; + this.ops = new ListWrapper<cmpopType>(ops); } - private java.util.List<exprType> comparators; - public java.util.List<exprType> getComparators() { + private ListWrapper<exprType> comparators; + public ListWrapper<exprType> getComparators() { return comparators; } public void setComparators(java.util.List<exprType> comparators) { - this.comparators = comparators; + this.comparators = new ListWrapper<exprType>(comparators); } Modified: branches/astwrite/src/org/python/antlr/ast/Continue.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Continue.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Continue.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; Modified: branches/astwrite/src/org/python/antlr/ast/Delete.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Delete.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Delete.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,18 +1,19 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; import java.io.IOException; public class Delete extends stmtType { - private java.util.List<exprType> targets; - public java.util.List<exprType> getTargets() { + private ListWrapper<exprType> targets; + public ListWrapper<exprType> getTargets() { return targets; } public void setTargets(java.util.List<exprType> targets) { - this.targets = targets; + this.targets = new ListWrapper<exprType>(targets); } Modified: branches/astwrite/src/org/python/antlr/ast/Dict.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Dict.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Dict.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,26 +1,27 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; import java.io.IOException; public class Dict extends exprType { - private java.util.List<exprType> keys; - public java.util.List<exprType> getKeys() { + private ListWrapper<exprType> keys; + public ListWrapper<exprType> getKeys() { return keys; } public void setKeys(java.util.List<exprType> keys) { - this.keys = keys; + this.keys = new ListWrapper<exprType>(keys); } - private java.util.List<exprType> values; - public java.util.List<exprType> getValues() { + private ListWrapper<exprType> values; + public ListWrapper<exprType> getValues() { return values; } public void setValues(java.util.List<exprType> values) { - this.values = values; + this.values = new ListWrapper<exprType>(values); } Modified: branches/astwrite/src/org/python/antlr/ast/Ellipsis.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Ellipsis.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Ellipsis.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; Modified: branches/astwrite/src/org/python/antlr/ast/Exec.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Exec.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Exec.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; Modified: branches/astwrite/src/org/python/antlr/ast/Expr.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Expr.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Expr.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; Modified: branches/astwrite/src/org/python/antlr/ast/Expression.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Expression.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Expression.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; Modified: branches/astwrite/src/org/python/antlr/ast/ExtSlice.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/ExtSlice.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/ExtSlice.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,18 +1,19 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; import java.io.IOException; public class ExtSlice extends sliceType { - private java.util.List<sliceType> dims; - public java.util.List<sliceType> getDims() { + private ListWrapper<sliceType> dims; + public ListWrapper<sliceType> getDims() { return dims; } public void setDims(java.util.List<sliceType> dims) { - this.dims = dims; + this.dims = new ListWrapper<sliceType>(dims); } Modified: branches/astwrite/src/org/python/antlr/ast/For.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/For.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/For.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; @@ -23,20 +24,20 @@ this.iter = iter; } - private java.util.List<stmtType> body; - public java.util.List<stmtType> getBody() { + private ListWrapper<stmtType> body; + public ListWrapper<stmtType> getBody() { return body; } public void setBody(java.util.List<stmtType> body) { - this.body = body; + this.body = new ListWrapper<stmtType>(body); } - private java.util.List<stmtType> orelse; - public java.util.List<stmtType> getOrelse() { + private ListWrapper<stmtType> orelse; + public ListWrapper<stmtType> getOrelse() { return orelse; } public void setOrelse(java.util.List<stmtType> orelse) { - this.orelse = orelse; + this.orelse = new ListWrapper<stmtType>(orelse); } Modified: branches/astwrite/src/org/python/antlr/ast/FunctionDef.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/FunctionDef.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/FunctionDef.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; @@ -23,20 +24,20 @@ this.args = args; } - private java.util.List<stmtType> body; - public java.util.List<stmtType> getBody() { + private ListWrapper<stmtType> body; + public ListWrapper<stmtType> getBody() { return body; } public void setBody(java.util.List<stmtType> body) { - this.body = body; + this.body = new ListWrapper<stmtType>(body); } - private java.util.List<exprType> decorators; - public java.util.List<exprType> getDecorators() { + private ListWrapper<exprType> decorators; + public ListWrapper<exprType> getDecorators() { return decorators; } public void setDecorators(java.util.List<exprType> decorators) { - this.decorators = decorators; + this.decorators = new ListWrapper<exprType>(decorators); } Modified: branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; @@ -15,12 +16,12 @@ this.elt = elt; } - private java.util.List<comprehensionType> generators; - public java.util.List<comprehensionType> getGenerators() { + private ListWrapper<comprehensionType> generators; + public ListWrapper<comprehensionType> getGenerators() { return generators; } public void setGenerators(java.util.List<comprehensionType> generators) { - this.generators = generators; + this.generators = new ListWrapper<comprehensionType>(generators); } Modified: branches/astwrite/src/org/python/antlr/ast/Global.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Global.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Global.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,18 +1,19 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; import java.io.IOException; public class Global extends stmtType { - private java.util.List<String> names; - public java.util.List<String> getNames() { + private ListWrapper<String> names; + public ListWrapper<String> getNames() { return names; } public void setNames(java.util.List<String> names) { - this.names = names; + this.names = new ListWrapper<String>(names); } Modified: branches/astwrite/src/org/python/antlr/ast/If.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/If.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/If.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; @@ -15,20 +16,20 @@ this.test = test; } - private java.util.List<stmtType> body; - public java.util.List<stmtType> getBody() { + private ListWrapper<stmtType> body; + public ListWrapper<stmtType> getBody() { return body; } public void setBody(java.util.List<stmtType> body) { - this.body = body; + this.body = new ListWrapper<stmtType>(body); } - private java.util.List<stmtType> orelse; - public java.util.List<stmtType> getOrelse() { + private ListWrapper<stmtType> orelse; + public ListWrapper<stmtType> getOrelse() { return orelse; } public void setOrelse(java.util.List<stmtType> orelse) { - this.orelse = orelse; + this.orelse = new ListWrapper<stmtType>(orelse); } Modified: branches/astwrite/src/org/python/antlr/ast/IfExp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/IfExp.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/IfExp.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; Modified: branches/astwrite/src/org/python/antlr/ast/Import.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Import.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Import.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,18 +1,19 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; import java.io.IOException; public class Import extends stmtType { - private java.util.List<aliasType> names; - public java.util.List<aliasType> getNames() { + private ListWrapper<aliasType> names; + public ListWrapper<aliasType> getNames() { return names; } public void setNames(java.util.List<aliasType> names) { - this.names = names; + this.names = new ListWrapper<aliasType>(names); } Modified: branches/astwrite/src/org/python/antlr/ast/ImportFrom.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/ImportFrom.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/ImportFrom.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; @@ -15,12 +16,12 @@ this.module = module; } - private java.util.List<aliasType> names; - public java.util.List<aliasType> getNames() { + private ListWrapper<aliasType> names; + public ListWrapper<aliasType> getNames() { return names; } public void setNames(java.util.List<aliasType> names) { - this.names = names; + this.names = new ListWrapper<aliasType>(names); } private int level; Modified: branches/astwrite/src/org/python/antlr/ast/Index.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Index.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Index.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; Modified: branches/astwrite/src/org/python/antlr/ast/Interactive.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Interactive.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Interactive.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,18 +1,19 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; import java.io.IOException; public class Interactive extends modType { - private java.util.List<stmtType> body; - public java.util.List<stmtType> getBody() { + private ListWrapper<stmtType> body; + public ListWrapper<stmtType> getBody() { return body; } public void setBody(java.util.List<stmtType> body) { - this.body = body; + this.body = new ListWrapper<stmtType>(body); } Modified: branches/astwrite/src/org/python/antlr/ast/Lambda.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Lambda.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Lambda.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; Modified: branches/astwrite/src/org/python/antlr/ast/List.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/List.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/List.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,18 +1,19 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; import java.io.IOException; public class List extends exprType implements Context { - private java.util.List<exprType> elts; - public java.util.List<exprType> getElts() { + private ListWrapper<exprType> elts; + public ListWrapper<exprType> getElts() { return elts; } public void setElts(java.util.List<exprType> elts) { - this.elts = elts; + this.elts = new ListWrapper<exprType>(elts); } private expr_contextType ctx; Modified: branches/astwrite/src/org/python/antlr/ast/ListComp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/ListComp.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/ListComp.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; @@ -15,12 +16,12 @@ this.elt = elt; } - private java.util.List<comprehensionType> generators; - public java.util.List<comprehensionType> getGenerators() { + private ListWrapper<comprehensionType> generators; + public ListWrapper<comprehensionType> getGenerators() { return generators; } public void setGenerators(java.util.List<comprehensionType> generators) { - this.generators = generators; + this.generators = new ListWrapper<comprehensionType>(generators); } Modified: branches/astwrite/src/org/python/antlr/ast/Module.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Module.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Module.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,18 +1,19 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; import java.io.IOException; public class Module extends modType { - private java.util.List<stmtType> body; - public java.util.List<stmtType> getBody() { + private ListWrapper<stmtType> body; + public ListWrapper<stmtType> getBody() { return body; } public void setBody(java.util.List<stmtType> body) { - this.body = body; + this.body = new ListWrapper<stmtType>(body); } Modified: branches/astwrite/src/org/python/antlr/ast/Name.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Name.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Name.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; Modified: branches/astwrite/src/org/python/antlr/ast/Num.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Num.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Num.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; Modified: branches/astwrite/src/org/python/antlr/ast/Pass.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Pass.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Pass.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; Modified: branches/astwrite/src/org/python/antlr/ast/Print.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Print.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Print.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; @@ -15,12 +16,12 @@ this.dest = dest; } - private java.util.List<exprType> values; - public java.util.List<exprType> getValues() { + private ListWrapper<exprType> values; + public ListWrapper<exprType> getValues() { return values; } public void setValues(java.util.List<exprType> values) { - this.values = values; + this.values = new ListWrapper<exprType>(values); } private boolean nl; Modified: branches/astwrite/src/org/python/antlr/ast/Raise.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Raise.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Raise.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; Modified: branches/astwrite/src/org/python/antlr/ast/Repr.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Repr.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Repr.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; Modified: branches/astwrite/src/org/python/antlr/ast/Return.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Return.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Return.java 2008-11-20 22:22:29 UTC (rev 5594) @@ -1,6 +1,7 @@ // Autogenerated AST node package org.python.antlr.ast; import org.python.antlr.PythonTree; +import org.python.antlr.ListWrapper; import org.antlr.runtime.CommonToken; import org.antlr.runtime.Token; import java.io.DataOutputStream; Modified: branches/astwrite/src/org/python/antlr/ast/Slice.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Slice.java 2008-11-20 18:52:08 UTC (rev 5593) +++ branches/astwrite/src/org/python/antlr/ast/Slice.java 2... [truncated message content] |
From: <pj...@us...> - 2008-11-20 18:52:12
|
Revision: 5593 http://jython.svn.sourceforge.net/jython/?rev=5593&view=rev Author: pjenvey Date: 2008-11-20 18:52:08 +0000 (Thu, 20 Nov 2008) Log Message: ----------- hardcode PyString encode results instead of letting java2py return unicode fixes #1177 thanks jcflack Modified Paths: -------------- trunk/jython/src/org/python/modules/_codecs.java Modified: trunk/jython/src/org/python/modules/_codecs.java =================================================================== --- trunk/jython/src/org/python/modules/_codecs.java 2008-11-18 20:21:20 UTC (rev 5592) +++ trunk/jython/src/org/python/modules/_codecs.java 2008-11-20 18:52:08 UTC (rev 5593) @@ -53,7 +53,7 @@ } private static PyTuple encode_tuple(String s, int len) { - return new PyTuple(Py.java2py(s), Py.newInteger(len)); + return new PyTuple(new PyString(s), Py.newInteger(len)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-11-18 20:21:23
|
Revision: 5592 http://jython.svn.sourceforge.net/jython/?rev=5592&view=rev Author: fwierzbicki Date: 2008-11-18 20:21:20 +0000 (Tue, 18 Nov 2008) Log Message: ----------- Changes all field access on ast nodes to get/set access. One unfortunate wrinkle: getType() is actually part of Antlr's Tree interface, so for the moment I have changed the two "type" fields (Raise and excepthandler) to excepttype. Modified Paths: -------------- branches/astwrite/ast/Python.asdl branches/astwrite/ast/asdl_antlr.py branches/astwrite/grammar/Python.g branches/astwrite/src/org/python/antlr/GrammarActions.java branches/astwrite/src/org/python/antlr/ast/Assert.java branches/astwrite/src/org/python/antlr/ast/Assign.java branches/astwrite/src/org/python/antlr/ast/Attribute.java branches/astwrite/src/org/python/antlr/ast/AugAssign.java branches/astwrite/src/org/python/antlr/ast/BinOp.java branches/astwrite/src/org/python/antlr/ast/BoolOp.java branches/astwrite/src/org/python/antlr/ast/Call.java branches/astwrite/src/org/python/antlr/ast/ClassDef.java branches/astwrite/src/org/python/antlr/ast/Compare.java branches/astwrite/src/org/python/antlr/ast/Delete.java branches/astwrite/src/org/python/antlr/ast/Dict.java branches/astwrite/src/org/python/antlr/ast/Exec.java branches/astwrite/src/org/python/antlr/ast/Expr.java branches/astwrite/src/org/python/antlr/ast/Expression.java branches/astwrite/src/org/python/antlr/ast/ExtSlice.java branches/astwrite/src/org/python/antlr/ast/For.java branches/astwrite/src/org/python/antlr/ast/FunctionDef.java branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java branches/astwrite/src/org/python/antlr/ast/Global.java branches/astwrite/src/org/python/antlr/ast/If.java branches/astwrite/src/org/python/antlr/ast/IfExp.java branches/astwrite/src/org/python/antlr/ast/Import.java branches/astwrite/src/org/python/antlr/ast/ImportFrom.java branches/astwrite/src/org/python/antlr/ast/Index.java branches/astwrite/src/org/python/antlr/ast/Interactive.java branches/astwrite/src/org/python/antlr/ast/Lambda.java branches/astwrite/src/org/python/antlr/ast/List.java branches/astwrite/src/org/python/antlr/ast/ListComp.java branches/astwrite/src/org/python/antlr/ast/Module.java branches/astwrite/src/org/python/antlr/ast/Name.java branches/astwrite/src/org/python/antlr/ast/Num.java branches/astwrite/src/org/python/antlr/ast/Print.java branches/astwrite/src/org/python/antlr/ast/Raise.java branches/astwrite/src/org/python/antlr/ast/Repr.java branches/astwrite/src/org/python/antlr/ast/Return.java branches/astwrite/src/org/python/antlr/ast/Slice.java branches/astwrite/src/org/python/antlr/ast/Str.java branches/astwrite/src/org/python/antlr/ast/Subscript.java branches/astwrite/src/org/python/antlr/ast/Suite.java branches/astwrite/src/org/python/antlr/ast/TryExcept.java branches/astwrite/src/org/python/antlr/ast/TryFinally.java branches/astwrite/src/org/python/antlr/ast/Tuple.java branches/astwrite/src/org/python/antlr/ast/UnaryOp.java branches/astwrite/src/org/python/antlr/ast/While.java branches/astwrite/src/org/python/antlr/ast/With.java branches/astwrite/src/org/python/antlr/ast/Yield.java branches/astwrite/src/org/python/antlr/ast/aliasType.java branches/astwrite/src/org/python/antlr/ast/argumentsType.java branches/astwrite/src/org/python/antlr/ast/comprehensionType.java branches/astwrite/src/org/python/antlr/ast/excepthandlerType.java branches/astwrite/src/org/python/antlr/ast/keywordType.java branches/astwrite/src/org/python/compiler/ArgListCompiler.java branches/astwrite/src/org/python/compiler/CodeCompiler.java branches/astwrite/src/org/python/compiler/Future.java branches/astwrite/src/org/python/compiler/ScopesCompiler.java Modified: branches/astwrite/ast/Python.asdl =================================================================== --- branches/astwrite/ast/Python.asdl 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/ast/Python.asdl 2008-11-18 20:21:20 UTC (rev 5592) @@ -29,7 +29,7 @@ | With(expr context_expr, expr? optional_vars, stmt* body) -- 'type' is a bad name - | Raise(expr? type, expr? inst, expr? tback) + | Raise(expr? excepttype, expr? inst, expr? tback) | TryExcept(stmt* body, excepthandler* handlers, stmt* orelse) | TryFinally(stmt* body, stmt* finalbody) | Assert(expr test, expr? msg) @@ -102,7 +102,7 @@ -- TODO(jhylton): Figure out if there is a better way to handle -- lineno and col_offset fields, particularly when -- ast is exposed to Python. - excepthandler = (expr? type, expr? name, stmt* body, int lineno, + excepthandler = (expr? excepttype, expr? name, stmt* body, int lineno, int col_offset) arguments = (expr* args, identifier? vararg, Modified: branches/astwrite/ast/asdl_antlr.py =================================================================== --- branches/astwrite/ast/asdl_antlr.py 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/ast/asdl_antlr.py 2008-11-18 20:21:20 UTC (rev 5592) @@ -399,7 +399,16 @@ self.emit("", 0) def visitField(self, field, depth): - self.emit("public %s;" % self.fieldDef(field), depth) + self.emit("private %s;" % self.fieldDef(field), depth) + self.emit("public %s get%s() {" % (self.javaType(field), + str(field.name).capitalize()), depth) + self.emit("return %s;" % field.name, depth+1) + self.emit("}", depth) + self.emit("public void set%s(%s) {" % (str(field.name).capitalize(), + self.fieldDef(field)), depth) + self.emit("this.%s = %s;" % (field.name, field.name), depth+1) + self.emit("}", depth) + self.emit("", 0) bltinnames = { 'int' : 'int', Modified: branches/astwrite/grammar/Python.g =================================================================== --- branches/astwrite/grammar/Python.g 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/grammar/Python.g 2008-11-18 20:21:20 UTC (rev 5592) @@ -1189,16 +1189,16 @@ } if (o instanceof Call) { Call c = (Call)o; - c.func = $etype; + c.setFunc($etype); $etype = c; } else if (o instanceof Subscript) { Subscript c = (Subscript)o; - c.value = $etype; + c.setValue($etype); $etype = c; } else if (o instanceof Attribute) { Attribute c = (Attribute)o; c.setCharStartIndex($etype.getCharStartIndex()); - c.value = $etype; + c.setValue($etype); $etype = c; } } Modified: branches/astwrite/src/org/python/antlr/GrammarActions.java =================================================================== --- branches/astwrite/src/org/python/antlr/GrammarActions.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/GrammarActions.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -135,7 +135,7 @@ List<exprType> result = new ArrayList<exprType>(); if (etype != null) { if (etype instanceof Tuple) { - return ((Tuple)etype).elts; + return ((Tuple)etype).getElts(); } result.add(etype); } @@ -314,10 +314,10 @@ } if (tree instanceof GeneratorExp) { GeneratorExp g = (GeneratorExp)tree; - recurseSetContext(g.elt, context); + recurseSetContext(g.getElt(), context); } else if (tree instanceof ListComp) { ListComp lc = (ListComp)tree; - recurseSetContext(lc.elt, context); + recurseSetContext(lc.getElt(), context); } else if (!(tree instanceof ListComp)) { for (int i=0; i<tree.getChildCount(); i++) { recurseSetContext(tree.getChild(i), context); @@ -357,7 +357,7 @@ checkAssign(castExpr(e.get(0))); if (e.get(0) instanceof Name) { Name arg = (Name)e.get(0); - k.add(new keywordType(arg, arg.id, castExpr(e.get(1)))); + k.add(new keywordType(arg, arg.getId(), castExpr(e.get(1)))); } else { errorHandler.error("keyword must be a name", (PythonTree)e.get(0)); } @@ -588,28 +588,28 @@ exprType negate(PythonTree t, exprType o) { if (o instanceof Num) { Num num = (Num)o; - if (num.n instanceof PyInteger) { - int v = ((PyInteger)num.n).getValue(); + if (num.getN() instanceof PyInteger) { + int v = ((PyInteger)num.getN()).getValue(); if (v > 0) { - num.n = new PyInteger(-v); + num.setN(new PyInteger(-v)); return num; } - } else if (num.n instanceof PyLong) { - BigInteger v = ((PyLong)num.n).getValue(); + } else if (num.getN() instanceof PyLong) { + BigInteger v = ((PyLong)num.getN()).getValue(); if (v.compareTo(BigInteger.ZERO) == 1) { - num.n = new PyLong(v.negate()); + num.setN(new PyLong(v.negate())); return num; } - } else if (num.n instanceof PyFloat) { - double v = ((PyFloat)num.n).getValue(); + } else if (num.getN() instanceof PyFloat) { + double v = ((PyFloat)num.getN()).getValue(); if (v > 0) { - num.n = new PyFloat(-v); + num.setN(new PyFloat(-v)); return num; } - } else if (num.n instanceof PyComplex) { - double v = ((PyComplex)num.n).imag; + } else if (num.getN() instanceof PyComplex) { + double v = ((PyComplex)num.getN()).imag; if (v > 0) { - num.n = new PyComplex(0,-v); + num.setN(new PyComplex(0,-v)); return num; } } @@ -631,7 +631,7 @@ } void checkAssign(exprType e) { - if (e instanceof Name && ((Name)e).id.equals("None")) { + if (e instanceof Name && ((Name)e).getId().equals("None")) { errorHandler.error("assignment to None", e); } else if (e instanceof GeneratorExp) { errorHandler.error("can't assign to generator expression", e); @@ -653,7 +653,7 @@ errorHandler.error("can't assign to conditional expression", e); } else if (e instanceof Tuple) { //XXX: performance problem? Any way to do this better? - List<exprType> elts = ((Tuple)e).elts; + List<exprType> elts = ((Tuple)e).getElts(); if (elts.size() == 0) { errorHandler.error("can't assign to ()", e); } @@ -662,7 +662,7 @@ } } else if (e instanceof org.python.antlr.ast.List) { //XXX: performance problem? Any way to do this better? - List<exprType> elts = ((org.python.antlr.ast.List)e).elts; + List<exprType> elts = ((org.python.antlr.ast.List)e).getElts(); for (int i=0;i<elts.size();i++) { checkAssign(elts.get(i)); } @@ -781,7 +781,7 @@ for (Object o : sltypes) { if (o instanceof Index) { Index i = (Index)o; - etypes.add(i.value); + etypes.add(i.getValue()); } else { extslice = true; break; Modified: branches/astwrite/src/org/python/antlr/ast/Assert.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Assert.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Assert.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,9 +7,23 @@ import java.io.IOException; public class Assert extends stmtType { - public exprType test; - public exprType msg; + private exprType test; + public exprType getTest() { + return test; + } + public void setTest(exprType test) { + this.test = test; + } + private exprType msg; + public exprType getMsg() { + return msg; + } + public void setMsg(exprType msg) { + this.msg = msg; + } + + private final static String[] fields = new String[] {"test", "msg"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Assign.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Assign.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Assign.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,9 +7,23 @@ import java.io.IOException; public class Assign extends stmtType { - public java.util.List<exprType> targets; - public exprType value; + private java.util.List<exprType> targets; + public java.util.List<exprType> getTargets() { + return targets; + } + public void setTargets(java.util.List<exprType> targets) { + this.targets = targets; + } + private exprType value; + public exprType getValue() { + return value; + } + public void setValue(exprType value) { + this.value = value; + } + + private final static String[] fields = new String[] {"targets", "value"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Attribute.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Attribute.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Attribute.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,10 +7,31 @@ import java.io.IOException; public class Attribute extends exprType implements Context { - public exprType value; - public String attr; - public expr_contextType ctx; + private exprType value; + public exprType getValue() { + return value; + } + public void setValue(exprType value) { + this.value = value; + } + private String attr; + public String getAttr() { + return attr; + } + public void setAttr(String attr) { + this.attr = attr; + } + + private expr_contextType ctx; + public expr_contextType getCtx() { + return ctx; + } + public void setCtx(expr_contextType ctx) { + this.ctx = ctx; + } + + private final static String[] fields = new String[] {"value", "attr", "ctx"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/AugAssign.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/AugAssign.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/AugAssign.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,10 +7,31 @@ import java.io.IOException; public class AugAssign extends stmtType { - public exprType target; - public operatorType op; - public exprType value; + private exprType target; + public exprType getTarget() { + return target; + } + public void setTarget(exprType target) { + this.target = target; + } + private operatorType op; + public operatorType getOp() { + return op; + } + public void setOp(operatorType op) { + this.op = op; + } + + private exprType value; + public exprType getValue() { + return value; + } + public void setValue(exprType value) { + this.value = value; + } + + private final static String[] fields = new String[] {"target", "op", "value"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/BinOp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/BinOp.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/BinOp.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,10 +7,31 @@ import java.io.IOException; public class BinOp extends exprType { - public exprType left; - public operatorType op; - public exprType right; + private exprType left; + public exprType getLeft() { + return left; + } + public void setLeft(exprType left) { + this.left = left; + } + private operatorType op; + public operatorType getOp() { + return op; + } + public void setOp(operatorType op) { + this.op = op; + } + + private exprType right; + public exprType getRight() { + return right; + } + public void setRight(exprType right) { + this.right = right; + } + + private final static String[] fields = new String[] {"left", "op", "right"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/BoolOp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/BoolOp.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/BoolOp.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,9 +7,23 @@ import java.io.IOException; public class BoolOp extends exprType { - public boolopType op; - public java.util.List<exprType> values; + private boolopType op; + public boolopType getOp() { + return op; + } + public void setOp(boolopType op) { + this.op = op; + } + private java.util.List<exprType> values; + public java.util.List<exprType> getValues() { + return values; + } + public void setValues(java.util.List<exprType> values) { + this.values = values; + } + + private final static String[] fields = new String[] {"op", "values"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Call.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Call.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Call.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,12 +7,47 @@ import java.io.IOException; public class Call extends exprType { - public exprType func; - public java.util.List<exprType> args; - public java.util.List<keywordType> keywords; - public exprType starargs; - public exprType kwargs; + private exprType func; + public exprType getFunc() { + return func; + } + public void setFunc(exprType func) { + this.func = func; + } + private java.util.List<exprType> args; + public java.util.List<exprType> getArgs() { + return args; + } + public void setArgs(java.util.List<exprType> args) { + this.args = args; + } + + private java.util.List<keywordType> keywords; + public java.util.List<keywordType> getKeywords() { + return keywords; + } + public void setKeywords(java.util.List<keywordType> keywords) { + this.keywords = keywords; + } + + private exprType starargs; + public exprType getStarargs() { + return starargs; + } + public void setStarargs(exprType starargs) { + this.starargs = starargs; + } + + private exprType kwargs; + public exprType getKwargs() { + return kwargs; + } + public void setKwargs(exprType kwargs) { + this.kwargs = kwargs; + } + + private final static String[] fields = new String[] {"func", "args", "keywords", "starargs", "kwargs"}; Modified: branches/astwrite/src/org/python/antlr/ast/ClassDef.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/ClassDef.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/ClassDef.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,11 +7,39 @@ import java.io.IOException; public class ClassDef extends stmtType { - public String name; - public java.util.List<exprType> bases; - public java.util.List<stmtType> body; - public java.util.List<exprType> decorators; + private String name; + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + private java.util.List<exprType> bases; + public java.util.List<exprType> getBases() { + return bases; + } + public void setBases(java.util.List<exprType> bases) { + this.bases = bases; + } + + private java.util.List<stmtType> body; + public java.util.List<stmtType> getBody() { + return body; + } + public void setBody(java.util.List<stmtType> body) { + this.body = body; + } + + private java.util.List<exprType> decorators; + public java.util.List<exprType> getDecorators() { + return decorators; + } + public void setDecorators(java.util.List<exprType> decorators) { + this.decorators = decorators; + } + + private final static String[] fields = new String[] {"name", "bases", "body", "decorators"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Compare.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Compare.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Compare.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,10 +7,31 @@ import java.io.IOException; public class Compare extends exprType { - public exprType left; - public java.util.List<cmpopType> ops; - public java.util.List<exprType> comparators; + private exprType left; + public exprType getLeft() { + return left; + } + public void setLeft(exprType left) { + this.left = left; + } + private java.util.List<cmpopType> ops; + public java.util.List<cmpopType> getOps() { + return ops; + } + public void setOps(java.util.List<cmpopType> ops) { + this.ops = ops; + } + + private java.util.List<exprType> comparators; + public java.util.List<exprType> getComparators() { + return comparators; + } + public void setComparators(java.util.List<exprType> comparators) { + this.comparators = comparators; + } + + private final static String[] fields = new String[] {"left", "ops", "comparators"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Delete.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Delete.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Delete.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,8 +7,15 @@ import java.io.IOException; public class Delete extends stmtType { - public java.util.List<exprType> targets; + private java.util.List<exprType> targets; + public java.util.List<exprType> getTargets() { + return targets; + } + public void setTargets(java.util.List<exprType> targets) { + this.targets = targets; + } + private final static String[] fields = new String[] {"targets"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Dict.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Dict.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Dict.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,9 +7,23 @@ import java.io.IOException; public class Dict extends exprType { - public java.util.List<exprType> keys; - public java.util.List<exprType> values; + private java.util.List<exprType> keys; + public java.util.List<exprType> getKeys() { + return keys; + } + public void setKeys(java.util.List<exprType> keys) { + this.keys = keys; + } + private java.util.List<exprType> values; + public java.util.List<exprType> getValues() { + return values; + } + public void setValues(java.util.List<exprType> values) { + this.values = values; + } + + private final static String[] fields = new String[] {"keys", "values"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Exec.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Exec.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Exec.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,10 +7,31 @@ import java.io.IOException; public class Exec extends stmtType { - public exprType body; - public exprType globals; - public exprType locals; + private exprType body; + public exprType getBody() { + return body; + } + public void setBody(exprType body) { + this.body = body; + } + private exprType globals; + public exprType getGlobals() { + return globals; + } + public void setGlobals(exprType globals) { + this.globals = globals; + } + + private exprType locals; + public exprType getLocals() { + return locals; + } + public void setLocals(exprType locals) { + this.locals = locals; + } + + private final static String[] fields = new String[] {"body", "globals", "locals"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Expr.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Expr.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Expr.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,8 +7,15 @@ import java.io.IOException; public class Expr extends stmtType { - public exprType value; + private exprType value; + public exprType getValue() { + return value; + } + public void setValue(exprType value) { + this.value = value; + } + private final static String[] fields = new String[] {"value"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Expression.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Expression.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Expression.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,8 +7,15 @@ import java.io.IOException; public class Expression extends modType { - public exprType body; + private exprType body; + public exprType getBody() { + return body; + } + public void setBody(exprType body) { + this.body = body; + } + private final static String[] fields = new String[] {"body"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/ExtSlice.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/ExtSlice.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/ExtSlice.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,8 +7,15 @@ import java.io.IOException; public class ExtSlice extends sliceType { - public java.util.List<sliceType> dims; + private java.util.List<sliceType> dims; + public java.util.List<sliceType> getDims() { + return dims; + } + public void setDims(java.util.List<sliceType> dims) { + this.dims = dims; + } + private final static String[] fields = new String[] {"dims"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/For.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/For.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/For.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,11 +7,39 @@ import java.io.IOException; public class For extends stmtType { - public exprType target; - public exprType iter; - public java.util.List<stmtType> body; - public java.util.List<stmtType> orelse; + private exprType target; + public exprType getTarget() { + return target; + } + public void setTarget(exprType target) { + this.target = target; + } + private exprType iter; + public exprType getIter() { + return iter; + } + public void setIter(exprType iter) { + this.iter = iter; + } + + private java.util.List<stmtType> body; + public java.util.List<stmtType> getBody() { + return body; + } + public void setBody(java.util.List<stmtType> body) { + this.body = body; + } + + private java.util.List<stmtType> orelse; + public java.util.List<stmtType> getOrelse() { + return orelse; + } + public void setOrelse(java.util.List<stmtType> orelse) { + this.orelse = orelse; + } + + private final static String[] fields = new String[] {"target", "iter", "body", "orelse"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/FunctionDef.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/FunctionDef.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/FunctionDef.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,11 +7,39 @@ import java.io.IOException; public class FunctionDef extends stmtType { - public String name; - public argumentsType args; - public java.util.List<stmtType> body; - public java.util.List<exprType> decorators; + private String name; + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + private argumentsType args; + public argumentsType getArgs() { + return args; + } + public void setArgs(argumentsType args) { + this.args = args; + } + + private java.util.List<stmtType> body; + public java.util.List<stmtType> getBody() { + return body; + } + public void setBody(java.util.List<stmtType> body) { + this.body = body; + } + + private java.util.List<exprType> decorators; + public java.util.List<exprType> getDecorators() { + return decorators; + } + public void setDecorators(java.util.List<exprType> decorators) { + this.decorators = decorators; + } + + private final static String[] fields = new String[] {"name", "args", "body", "decorators"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,9 +7,23 @@ import java.io.IOException; public class GeneratorExp extends exprType { - public exprType elt; - public java.util.List<comprehensionType> generators; + private exprType elt; + public exprType getElt() { + return elt; + } + public void setElt(exprType elt) { + this.elt = elt; + } + private java.util.List<comprehensionType> generators; + public java.util.List<comprehensionType> getGenerators() { + return generators; + } + public void setGenerators(java.util.List<comprehensionType> generators) { + this.generators = generators; + } + + private final static String[] fields = new String[] {"elt", "generators"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Global.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Global.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Global.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,8 +7,15 @@ import java.io.IOException; public class Global extends stmtType { - public java.util.List<String> names; + private java.util.List<String> names; + public java.util.List<String> getNames() { + return names; + } + public void setNames(java.util.List<String> names) { + this.names = names; + } + private final static String[] fields = new String[] {"names"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/If.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/If.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/If.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,10 +7,31 @@ import java.io.IOException; public class If extends stmtType { - public exprType test; - public java.util.List<stmtType> body; - public java.util.List<stmtType> orelse; + private exprType test; + public exprType getTest() { + return test; + } + public void setTest(exprType test) { + this.test = test; + } + private java.util.List<stmtType> body; + public java.util.List<stmtType> getBody() { + return body; + } + public void setBody(java.util.List<stmtType> body) { + this.body = body; + } + + private java.util.List<stmtType> orelse; + public java.util.List<stmtType> getOrelse() { + return orelse; + } + public void setOrelse(java.util.List<stmtType> orelse) { + this.orelse = orelse; + } + + private final static String[] fields = new String[] {"test", "body", "orelse"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/IfExp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/IfExp.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/IfExp.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,10 +7,31 @@ import java.io.IOException; public class IfExp extends exprType { - public exprType test; - public exprType body; - public exprType orelse; + private exprType test; + public exprType getTest() { + return test; + } + public void setTest(exprType test) { + this.test = test; + } + private exprType body; + public exprType getBody() { + return body; + } + public void setBody(exprType body) { + this.body = body; + } + + private exprType orelse; + public exprType getOrelse() { + return orelse; + } + public void setOrelse(exprType orelse) { + this.orelse = orelse; + } + + private final static String[] fields = new String[] {"test", "body", "orelse"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Import.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Import.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Import.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,8 +7,15 @@ import java.io.IOException; public class Import extends stmtType { - public java.util.List<aliasType> names; + private java.util.List<aliasType> names; + public java.util.List<aliasType> getNames() { + return names; + } + public void setNames(java.util.List<aliasType> names) { + this.names = names; + } + private final static String[] fields = new String[] {"names"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/ImportFrom.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/ImportFrom.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/ImportFrom.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,10 +7,31 @@ import java.io.IOException; public class ImportFrom extends stmtType { - public String module; - public java.util.List<aliasType> names; - public int level; + private String module; + public String getModule() { + return module; + } + public void setModule(String module) { + this.module = module; + } + private java.util.List<aliasType> names; + public java.util.List<aliasType> getNames() { + return names; + } + public void setNames(java.util.List<aliasType> names) { + this.names = names; + } + + private int level; + public int getLevel() { + return level; + } + public void setLevel(int level) { + this.level = level; + } + + private final static String[] fields = new String[] {"module", "names", "level"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Index.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Index.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Index.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,8 +7,15 @@ import java.io.IOException; public class Index extends sliceType { - public exprType value; + private exprType value; + public exprType getValue() { + return value; + } + public void setValue(exprType value) { + this.value = value; + } + private final static String[] fields = new String[] {"value"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Interactive.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Interactive.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Interactive.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,8 +7,15 @@ import java.io.IOException; public class Interactive extends modType { - public java.util.List<stmtType> body; + private java.util.List<stmtType> body; + public java.util.List<stmtType> getBody() { + return body; + } + public void setBody(java.util.List<stmtType> body) { + this.body = body; + } + private final static String[] fields = new String[] {"body"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Lambda.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Lambda.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Lambda.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,9 +7,23 @@ import java.io.IOException; public class Lambda extends exprType { - public argumentsType args; - public exprType body; + private argumentsType args; + public argumentsType getArgs() { + return args; + } + public void setArgs(argumentsType args) { + this.args = args; + } + private exprType body; + public exprType getBody() { + return body; + } + public void setBody(exprType body) { + this.body = body; + } + + private final static String[] fields = new String[] {"args", "body"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/List.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/List.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/List.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,9 +7,23 @@ import java.io.IOException; public class List extends exprType implements Context { - public java.util.List<exprType> elts; - public expr_contextType ctx; + private java.util.List<exprType> elts; + public java.util.List<exprType> getElts() { + return elts; + } + public void setElts(java.util.List<exprType> elts) { + this.elts = elts; + } + private expr_contextType ctx; + public expr_contextType getCtx() { + return ctx; + } + public void setCtx(expr_contextType ctx) { + this.ctx = ctx; + } + + private final static String[] fields = new String[] {"elts", "ctx"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/ListComp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/ListComp.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/ListComp.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,9 +7,23 @@ import java.io.IOException; public class ListComp extends exprType { - public exprType elt; - public java.util.List<comprehensionType> generators; + private exprType elt; + public exprType getElt() { + return elt; + } + public void setElt(exprType elt) { + this.elt = elt; + } + private java.util.List<comprehensionType> generators; + public java.util.List<comprehensionType> getGenerators() { + return generators; + } + public void setGenerators(java.util.List<comprehensionType> generators) { + this.generators = generators; + } + + private final static String[] fields = new String[] {"elt", "generators"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Module.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Module.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Module.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,8 +7,15 @@ import java.io.IOException; public class Module extends modType { - public java.util.List<stmtType> body; + private java.util.List<stmtType> body; + public java.util.List<stmtType> getBody() { + return body; + } + public void setBody(java.util.List<stmtType> body) { + this.body = body; + } + private final static String[] fields = new String[] {"body"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Name.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Name.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Name.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,9 +7,23 @@ import java.io.IOException; public class Name extends exprType implements Context { - public String id; - public expr_contextType ctx; + private String id; + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + private expr_contextType ctx; + public expr_contextType getCtx() { + return ctx; + } + public void setCtx(expr_contextType ctx) { + this.ctx = ctx; + } + + private final static String[] fields = new String[] {"id", "ctx"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Num.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Num.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Num.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,8 +7,15 @@ import java.io.IOException; public class Num extends exprType { - public Object n; + private Object n; + public Object getN() { + return n; + } + public void setN(Object n) { + this.n = n; + } + private final static String[] fields = new String[] {"n"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Print.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Print.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Print.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,10 +7,31 @@ import java.io.IOException; public class Print extends stmtType { - public exprType dest; - public java.util.List<exprType> values; - public boolean nl; + private exprType dest; + public exprType getDest() { + return dest; + } + public void setDest(exprType dest) { + this.dest = dest; + } + private java.util.List<exprType> values; + public java.util.List<exprType> getValues() { + return values; + } + public void setValues(java.util.List<exprType> values) { + this.values = values; + } + + private boolean nl; + public boolean getNl() { + return nl; + } + public void setNl(boolean nl) { + this.nl = nl; + } + + private final static String[] fields = new String[] {"dest", "values", "nl"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Raise.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Raise.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Raise.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,49 +7,71 @@ import java.io.IOException; public class Raise extends stmtType { - public exprType type; - public exprType inst; - public exprType tback; + private exprType excepttype; + public exprType getExcepttype() { + return excepttype; + } + public void setExcepttype(exprType excepttype) { + this.excepttype = excepttype; + } - private final static String[] fields = new String[] {"type", "inst", + private exprType inst; + public exprType getInst() { + return inst; + } + public void setInst(exprType inst) { + this.inst = inst; + } + + private exprType tback; + public exprType getTback() { + return tback; + } + public void setTback(exprType tback) { + this.tback = tback; + } + + + private final static String[] fields = new String[] {"excepttype", "inst", "tback"}; public String[] get_fields() { return fields; } - public Raise(exprType type, exprType inst, exprType tback) { - this.type = type; - addChild(type); + public Raise(exprType excepttype, exprType inst, exprType tback) { + this.excepttype = excepttype; + addChild(excepttype); this.inst = inst; addChild(inst); this.tback = tback; addChild(tback); } - public Raise(Token token, exprType type, exprType inst, exprType tback) { + public Raise(Token token, exprType excepttype, exprType inst, exprType + tback) { super(token); - this.type = type; - addChild(type); + this.excepttype = excepttype; + addChild(excepttype); this.inst = inst; addChild(inst); this.tback = tback; addChild(tback); } - public Raise(int ttype, Token token, exprType type, exprType inst, exprType - tback) { + public Raise(int ttype, Token token, exprType excepttype, exprType inst, + exprType tback) { super(ttype, token); - this.type = type; - addChild(type); + this.excepttype = excepttype; + addChild(excepttype); this.inst = inst; addChild(inst); this.tback = tback; addChild(tback); } - public Raise(PythonTree tree, exprType type, exprType inst, exprType tback) - { + public Raise(PythonTree tree, exprType excepttype, exprType inst, exprType + tback) { super(tree); - this.type = type; - addChild(type); + this.excepttype = excepttype; + addChild(excepttype); this.inst = inst; addChild(inst); this.tback = tback; @@ -62,8 +84,8 @@ public String toStringTree() { StringBuffer sb = new StringBuffer("Raise("); - sb.append("type="); - sb.append(dumpThis(type)); + sb.append("excepttype="); + sb.append(dumpThis(excepttype)); sb.append(","); sb.append("inst="); sb.append(dumpThis(inst)); @@ -80,8 +102,8 @@ } public void traverse(VisitorIF visitor) throws Exception { - if (type != null) - type.accept(visitor); + if (excepttype != null) + excepttype.accept(visitor); if (inst != null) inst.accept(visitor); if (tback != null) Modified: branches/astwrite/src/org/python/antlr/ast/Repr.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Repr.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Repr.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,8 +7,15 @@ import java.io.IOException; public class Repr extends exprType { - public exprType value; + private exprType value; + public exprType getValue() { + return value; + } + public void setValue(exprType value) { + this.value = value; + } + private final static String[] fields = new String[] {"value"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Return.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Return.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Return.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,8 +7,15 @@ import java.io.IOException; public class Return extends stmtType { - public exprType value; + private exprType value; + public exprType getValue() { + return value; + } + public void setValue(exprType value) { + this.value = value; + } + private final static String[] fields = new String[] {"value"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Slice.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Slice.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Slice.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,10 +7,31 @@ import java.io.IOException; public class Slice extends sliceType { - public exprType lower; - public exprType upper; - public exprType step; + private exprType lower; + public exprType getLower() { + return lower; + } + public void setLower(exprType lower) { + this.lower = lower; + } + private exprType upper; + public exprType getUpper() { + return upper; + } + public void setUpper(exprType upper) { + this.upper = upper; + } + + private exprType step; + public exprType getStep() { + return step; + } + public void setStep(exprType step) { + this.step = step; + } + + private final static String[] fields = new String[] {"lower", "upper", "step"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Str.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Str.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Str.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,8 +7,15 @@ import java.io.IOException; public class Str extends exprType { - public Object s; + private Object s; + public Object getS() { + return s; + } + public void setS(Object s) { + this.s = s; + } + private final static String[] fields = new String[] {"s"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Subscript.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Subscript.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Subscript.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,10 +7,31 @@ import java.io.IOException; public class Subscript extends exprType implements Context { - public exprType value; - public sliceType slice; - public expr_contextType ctx; + private exprType value; + public exprType getValue() { + return value; + } + public void setValue(exprType value) { + this.value = value; + } + private sliceType slice; + public sliceType getSlice() { + return slice; + } + public void setSlice(sliceType slice) { + this.slice = slice; + } + + private expr_contextType ctx; + public expr_contextType getCtx() { + return ctx; + } + public void setCtx(expr_contextType ctx) { + this.ctx = ctx; + } + + private final static String[] fields = new String[] {"value", "slice", "ctx"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Suite.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Suite.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Suite.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,8 +7,15 @@ import java.io.IOException; public class Suite extends modType { - public java.util.List<stmtType> body; + private java.util.List<stmtType> body; + public java.util.List<stmtType> getBody() { + return body; + } + public void setBody(java.util.List<stmtType> body) { + this.body = body; + } + private final static String[] fields = new String[] {"body"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/TryExcept.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/TryExcept.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/TryExcept.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,10 +7,31 @@ import java.io.IOException; public class TryExcept extends stmtType { - public java.util.List<stmtType> body; - public java.util.List<excepthandlerType> handlers; - public java.util.List<stmtType> orelse; + private java.util.List<stmtType> body; + public java.util.List<stmtType> getBody() { + return body; + } + public void setBody(java.util.List<stmtType> body) { + this.body = body; + } + private java.util.List<excepthandlerType> handlers; + public java.util.List<excepthandlerType> getHandlers() { + return handlers; + } + public void setHandlers(java.util.List<excepthandlerType> handlers) { + this.handlers = handlers; + } + + private java.util.List<stmtType> orelse; + public java.util.List<stmtType> getOrelse() { + return orelse; + } + public void setOrelse(java.util.List<stmtType> orelse) { + this.orelse = orelse; + } + + private final static String[] fields = new String[] {"body", "handlers", "orelse"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/TryFinally.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/TryFinally.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/TryFinally.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,9 +7,23 @@ import java.io.IOException; public class TryFinally extends stmtType { - public java.util.List<stmtType> body; - public java.util.List<stmtType> finalbody; + private java.util.List<stmtType> body; + public java.util.List<stmtType> getBody() { + return body; + } + public void setBody(java.util.List<stmtType> body) { + this.body = body; + } + private java.util.List<stmtType> finalbody; + public java.util.List<stmtType> getFinalbody() { + return finalbody; + } + public void setFinalbody(java.util.List<stmtType> finalbody) { + this.finalbody = finalbody; + } + + private final static String[] fields = new String[] {"body", "finalbody"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/Tuple.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Tuple.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/Tuple.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,9 +7,23 @@ import java.io.IOException; public class Tuple extends exprType implements Context { - public java.util.List<exprType> elts; - public expr_contextType ctx; + private java.util.List<exprType> elts; + public java.util.List<exprType> getElts() { + return elts; + } + public void setElts(java.util.List<exprType> elts) { + this.elts = elts; + } + private expr_contextType ctx; + public expr_contextType getCtx() { + return ctx; + } + public void setCtx(expr_contextType ctx) { + this.ctx = ctx; + } + + private final static String[] fields = new String[] {"elts", "ctx"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/UnaryOp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/UnaryOp.java 2008-11-18 16:02:41 UTC (rev 5591) +++ branches/astwrite/src/org/python/antlr/ast/UnaryOp.java 2008-11-18 20:21:20 UTC (rev 5592) @@ -7,9 +7,23 @@ import java.io.IOException; public class UnaryOp extends exprType { - public unaryopType op; - public exprType operand; + private unaryopType op; + public unaryopType getOp() { + return op; + } + public void setOp(unaryopType op) { + this.op = op; + } + private exprType operand; + public exprType getOperand() { + return operand; + } + public void setOperand(exprType operand) { + this.operand = operand; + } + + private final static String[] fields = new String[] {"op", "operand"}; public String[] get_fields() { return fields; } Modified: branches/astwrite/src/org/python/antlr/ast/While.java ===================================================... [truncated message content] |
From: <fwi...@us...> - 2008-11-18 16:02:43
|
Revision: 5591 http://jython.svn.sourceforge.net/jython/?rev=5591&view=rev Author: fwierzbicki Date: 2008-11-18 16:02:41 +0000 (Tue, 18 Nov 2008) Log Message: ----------- extract javaType def from fieldDef Modified Paths: -------------- branches/astwrite/ast/asdl_antlr.py Modified: branches/astwrite/ast/asdl_antlr.py =================================================================== --- branches/astwrite/ast/asdl_antlr.py 2008-11-18 03:02:15 UTC (rev 5590) +++ branches/astwrite/ast/asdl_antlr.py 2008-11-18 16:02:41 UTC (rev 5591) @@ -412,12 +412,16 @@ } def fieldDef(self, field): + jtype = self.javaType(field) + name = field.name + return "%s %s" % (jtype, name) + + def javaType(self, field): jtype = str(field.type) jtype = self.bltinnames.get(jtype, jtype + 'Type') - name = field.name if field.seq: - return "java.util.List<%(jtype)s> %(name)s" % locals() - return "%(jtype)s %(name)s" % locals() + return "java.util.List<%s>" % jtype + return jtype class VisitorVisitor(EmitVisitor): def __init__(self, dir): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-11-18 03:02:19
|
Revision: 5590 http://jython.svn.sourceforge.net/jython/?rev=5590&view=rev Author: fwierzbicki Date: 2008-11-18 03:02:15 +0000 (Tue, 18 Nov 2008) Log Message: ----------- AugStore->Store Modified Paths: -------------- branches/astwrite/Lib/test/test_ast.py Modified: branches/astwrite/Lib/test/test_ast.py =================================================================== --- branches/astwrite/Lib/test/test_ast.py 2008-11-18 02:01:05 UTC (rev 5589) +++ branches/astwrite/Lib/test/test_ast.py 2008-11-18 03:02:15 UTC (rev 5590) @@ -192,7 +192,7 @@ ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, []), [('Return', (1, 8), ('Num', (1, 15), 1))], [])]), ('Module', [('Delete', (1, 0), [('Name', (1, 4), 'v', ('Del',))])]), ('Module', [('Assign', (1, 0), [('Name', (1, 0), 'v', ('Store',))], ('Num', (1, 4), 1))]), -('Module', [('AugAssign', (1, 0), ('Name', (1, 0), 'v', ('AugStore',)), ('Add',), ('Num', (1, 5), 1))]), +('Module', [('AugAssign', (1, 0), ('Name', (1, 0), 'v', ('Store',)), ('Add',), ('Num', (1, 5), 1))]), ('Module', [('Print', (1, 0), ('Name', (1, 8), 'f', ('Load',)), [('Num', (1, 11), 1)], False)]), ('Module', [('For', (1, 0), ('Name', (1, 4), 'v', ('Store',)), ('Name', (1, 9), 'v', ('Load',)), [('Pass', (1, 11))], [])]), ('Module', [('While', (1, 0), ('Name', (1, 6), 'v', ('Load',)), [('Pass', (1, 8))], [])]), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-11-18 02:01:10
|
Revision: 5589 http://jython.svn.sourceforge.net/jython/?rev=5589&view=rev Author: fwierzbicki Date: 2008-11-18 02:01:05 +0000 (Tue, 18 Nov 2008) Log Message: ----------- Accidently checked int 2.6 test_ast.py on the last one. Not ready for that yet. Also small fix for ast.py. Modified Paths: -------------- branches/astwrite/Lib/ast.py branches/astwrite/Lib/test/test_ast.py Modified: branches/astwrite/Lib/ast.py =================================================================== --- branches/astwrite/Lib/ast.py 2008-11-18 00:15:21 UTC (rev 5588) +++ branches/astwrite/Lib/ast.py 2008-11-18 02:01:05 UTC (rev 5589) @@ -30,9 +30,9 @@ from _ast import __version__ if sys.platform.startswith('java'): - import array + import java.util.List - ast_list = array.ArrayType + ast_list = java.util.List def get_class_name(t): result = t.__class__.__name__ Modified: branches/astwrite/Lib/test/test_ast.py =================================================================== --- branches/astwrite/Lib/test/test_ast.py 2008-11-18 00:15:21 UTC (rev 5588) +++ branches/astwrite/Lib/test/test_ast.py 2008-11-18 02:01:05 UTC (rev 5589) @@ -1,22 +1,48 @@ -import sys, itertools, unittest -from test import test_support +#Taken and modified from CPython's release25-maint branch, revision 62446. +import sys,os, itertools import ast +if sys.platform.startswith('java'): + import java.util.List + + ast_list = java.util.List + get_symbol_key = lambda op: op + + def get_class_name(t): + result = t.__class__.__name__ + if result in ("expr_contextType", + "boolopType", + "unaryopType", + "cmpopType", + "operatorType"): + result = str(t) + if result == "AugLoad": + result = "Load" + elif result == "AugStore": + result = "Store" + elif result.endswith("Type"): + result = result[:-4] + return result + +else: + ast_list = list + get_symbol_key = type + get_class_name = lambda node: node.__class__.__name__ + def to_tuple(t): if t is None or isinstance(t, (basestring, int, long, complex)): return t - elif isinstance(t, list): + elif isinstance(t, ast_list): return [to_tuple(e) for e in t] - result = [t.__class__.__name__] + result = [get_class_name(t)] if hasattr(t, 'lineno') and hasattr(t, 'col_offset'): result.append((t.lineno, t.col_offset)) - if t._fields is None: + if not hasattr(t, '_fields') or t._fields is None: return tuple(result) for f in t._fields: result.append(to_tuple(getattr(t, f))) return tuple(result) - # These tests are compiled through "exec" # There should be atleast one test per statement exec_tests = [ @@ -120,189 +146,59 @@ # TODO: expr_context, slice, boolop, operator, unaryop, cmpop, comprehension # excepthandler, arguments, keywords, alias -class AST_Tests(unittest.TestCase): +if __name__=='__main__' and sys.argv[1:] == ['-g']: + for statements, kind in ((exec_tests, "exec"), (single_tests, "single"), + (eval_tests, "eval")): + print kind+"_results = [" + for s in statements: + print repr(to_tuple(compile(s, "?", kind, 0x400)))+"," + print "]" + print "run_tests()" + raise SystemExit - def _assert_order(self, ast_node, parent_pos): - if not isinstance(ast_node, ast.AST) or ast_node._fields is None: +def test_order(ast_node, parent_pos): + + if (not isinstance(ast_node, ast.AST) + or not hasattr(ast_node, '_fields') + or ast_node._fields == None): return - if isinstance(ast_node, (ast.expr, ast.stmt, ast.excepthandler)): - node_pos = (ast_node.lineno, ast_node.col_offset) - self.assert_(node_pos >= parent_pos) - parent_pos = (ast_node.lineno, ast_node.col_offset) - for name in ast_node._fields: - value = getattr(ast_node, name) - if isinstance(value, list): - for child in value: - self._assert_order(child, parent_pos) - elif value is not None: - self._assert_order(value, parent_pos) + if isinstance(ast_node, (ast.expr, ast.stmt, ast.excepthandler)): + node_pos = (ast_node.lineno, ast_node.col_offset) + assert node_pos >= parent_pos, (node_pos, parent_pos) + parent_pos = (ast_node.lineno, ast_node.col_offset) + for name in ast_node._fields: + value = getattr(ast_node, name) + if isinstance(value, ast_list): + for child in value: + test_order(child, parent_pos) + elif value != None: + test_order(value, parent_pos) - def test_snippets(self): - for input, output, kind in ((exec_tests, exec_results, "exec"), - (single_tests, single_results, "single"), - (eval_tests, eval_results, "eval")): - for i, o in itertools.izip(input, output): - ast_tree = compile(i, "?", kind, ast.PyCF_ONLY_AST) - self.assertEquals(to_tuple(ast_tree), o) - self._assert_order(ast_tree, (0, 0)) +def run_tests(): + for input, output, kind in ((exec_tests, exec_results, "exec"), + (single_tests, single_results, "single"), + (eval_tests, eval_results, "eval")): + for i, o in itertools.izip(input, output): + ast_tree = compile(i, "?", kind, 0x400) + assert to_tuple(ast_tree) == o, "expected %s, got %s" % ( + o, to_tuple(ast_tree)) + test_order(ast_tree, (0, 0)) - def test_nodeclasses(self): - x = ast.BinOp(1, 2, 3, lineno=0) - self.assertEquals(x.left, 1) - self.assertEquals(x.op, 2) - self.assertEquals(x.right, 3) - self.assertEquals(x.lineno, 0) - - # node raises exception when not given enough arguments - self.assertRaises(TypeError, ast.BinOp, 1, 2) - - # can set attributes through kwargs too - x = ast.BinOp(left=1, op=2, right=3, lineno=0) - self.assertEquals(x.left, 1) - self.assertEquals(x.op, 2) - self.assertEquals(x.right, 3) - self.assertEquals(x.lineno, 0) - - # this used to fail because Sub._fields was None - x = ast.Sub() - - def test_pickling(self): - import pickle - mods = [pickle] - try: - import cPickle - mods.append(cPickle) - except ImportError: - pass - protocols = [0, 1, 2] - for mod in mods: - for protocol in protocols: - for ast in (compile(i, "?", "exec", 0x400) for i in exec_tests): - ast2 = mod.loads(mod.dumps(ast, protocol)) - self.assertEquals(to_tuple(ast2), to_tuple(ast)) - - -class ASTHelpers_Test(unittest.TestCase): - - def test_parse(self): - a = ast.parse('foo(1 + 1)') - b = compile('foo(1 + 1)', '<unknown>', 'exec', ast.PyCF_ONLY_AST) - self.assertEqual(ast.dump(a), ast.dump(b)) - - def test_dump(self): - node = ast.parse('spam(eggs, "and cheese")') - self.assertEqual(ast.dump(node), - "Module(body=[Expr(value=Call(func=Name(id='spam', ctx=Load()), " - "args=[Name(id='eggs', ctx=Load()), Str(s='and cheese')], " - "keywords=[], starargs=None, kwargs=None))])" - ) - self.assertEqual(ast.dump(node, annotate_fields=False), - "Module([Expr(Call(Name('spam', Load()), [Name('eggs', Load()), " - "Str('and cheese')], [], None, None))])" - ) - self.assertEqual(ast.dump(node, include_attributes=True), - "Module(body=[Expr(value=Call(func=Name(id='spam', ctx=Load(), " - "lineno=1, col_offset=0), args=[Name(id='eggs', ctx=Load(), " - "lineno=1, col_offset=5), Str(s='and cheese', lineno=1, " - "col_offset=11)], keywords=[], starargs=None, kwargs=None, " - "lineno=1, col_offset=0), lineno=1, col_offset=0)])" - ) - - def test_copy_location(self): - src = ast.parse('1 + 1', mode='eval') - src.body.right = ast.copy_location(ast.Num(2), src.body.right) - self.assertEqual(ast.dump(src, include_attributes=True), - 'Expression(body=BinOp(left=Num(n=1, lineno=1, col_offset=0), ' - 'op=Add(), right=Num(n=2, lineno=1, col_offset=4), lineno=1, ' - 'col_offset=0))' - ) - - def test_fix_missing_locations(self): - src = ast.parse('write("spam")') - src.body.append(ast.Expr(ast.Call(ast.Name('spam', ast.Load()), - [ast.Str('eggs')], [], None, None))) - self.assertEqual(src, ast.fix_missing_locations(src)) - self.assertEqual(ast.dump(src, include_attributes=True), - "Module(body=[Expr(value=Call(func=Name(id='write', ctx=Load(), " - "lineno=1, col_offset=0), args=[Str(s='spam', lineno=1, " - "col_offset=6)], keywords=[], starargs=None, kwargs=None, " - "lineno=1, col_offset=0), lineno=1, col_offset=0), " - "Expr(value=Call(func=Name(id='spam', ctx=Load(), lineno=1, " - "col_offset=0), args=[Str(s='eggs', lineno=1, col_offset=0)], " - "keywords=[], starargs=None, kwargs=None, lineno=1, " - "col_offset=0), lineno=1, col_offset=0)])" - ) - - def test_increment_lineno(self): - src = ast.parse('1 + 1', mode='eval') - self.assertEqual(ast.increment_lineno(src, n=3), src) - self.assertEqual(ast.dump(src, include_attributes=True), - 'Expression(body=BinOp(left=Num(n=1, lineno=4, col_offset=0), ' - 'op=Add(), right=Num(n=1, lineno=4, col_offset=4), lineno=4, ' - 'col_offset=0))' - ) - - def test_iter_fields(self): - node = ast.parse('foo()', mode='eval') - d = dict(ast.iter_fields(node.body)) - self.assertEqual(d.pop('func').id, 'foo') - self.assertEqual(d, {'keywords': [], 'kwargs': None, - 'args': [], 'starargs': None}) - - def test_iter_child_nodes(self): - node = ast.parse("spam(23, 42, eggs='leek')", mode='eval') - self.assertEqual(len(list(ast.iter_child_nodes(node.body))), 4) - iterator = ast.iter_child_nodes(node.body) - self.assertEqual(next(iterator).id, 'spam') - self.assertEqual(next(iterator).n, 23) - self.assertEqual(next(iterator).n, 42) - self.assertEqual(ast.dump(next(iterator)), - "keyword(arg='eggs', value=Str(s='leek'))" - ) - - def test_get_docstring(self): - node = ast.parse('def foo():\n """line one\n line two"""') - self.assertEqual(ast.get_docstring(node.body[0]), - 'line one\nline two') - - def test_literal_eval(self): - self.assertEqual(ast.literal_eval('[1, 2, 3]'), [1, 2, 3]) - self.assertEqual(ast.literal_eval('{"foo": 42}'), {"foo": 42}) - self.assertEqual(ast.literal_eval('(True, False, None)'), (True, False, None)) - self.assertRaises(ValueError, ast.literal_eval, 'foo()') - - -def test_main(): - test_support.run_unittest(AST_Tests, ASTHelpers_Test) - -def main(): - if __name__ != '__main__': - return - if sys.argv[1:] == ['-g']: - for statements, kind in ((exec_tests, "exec"), (single_tests, "single"), - (eval_tests, "eval")): - print kind+"_results = [" - for s in statements: - print repr(to_tuple(compile(s, "?", kind, 0x400)))+"," - print "]" - print "main()" - raise SystemExit - test_main() - +# XXX: AugStore added for Jython. Short term it is too hard to emit just "Store" as CPython does. #### EVERYTHING BELOW IS GENERATED ##### exec_results = [ ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, []), [('Pass', (1, 9))], [])]), -('Module', [('ClassDef', (1, 0), 'C', [], [('Pass', (1, 8))], [])]), +('Module', [('ClassDef', (1, 0), 'C', [], [('Pass', (1, 8))],[])]), ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, []), [('Return', (1, 8), ('Num', (1, 15), 1))], [])]), ('Module', [('Delete', (1, 0), [('Name', (1, 4), 'v', ('Del',))])]), ('Module', [('Assign', (1, 0), [('Name', (1, 0), 'v', ('Store',))], ('Num', (1, 4), 1))]), -('Module', [('AugAssign', (1, 0), ('Name', (1, 0), 'v', ('Store',)), ('Add',), ('Num', (1, 5), 1))]), +('Module', [('AugAssign', (1, 0), ('Name', (1, 0), 'v', ('AugStore',)), ('Add',), ('Num', (1, 5), 1))]), ('Module', [('Print', (1, 0), ('Name', (1, 8), 'f', ('Load',)), [('Num', (1, 11), 1)], False)]), ('Module', [('For', (1, 0), ('Name', (1, 4), 'v', ('Store',)), ('Name', (1, 9), 'v', ('Load',)), [('Pass', (1, 11))], [])]), ('Module', [('While', (1, 0), ('Name', (1, 6), 'v', ('Load',)), [('Pass', (1, 8))], [])]), ('Module', [('If', (1, 0), ('Name', (1, 3), 'v', ('Load',)), [('Pass', (1, 5))], [])]), ('Module', [('Raise', (1, 0), ('Name', (1, 6), 'Exception', ('Load',)), ('Str', (1, 17), 'string'), None)]), -('Module', [('TryExcept', (1, 0), [('Pass', (2, 2))], [('ExceptHandler', (3, 0), ('Name', (3, 7), 'Exception', ('Load',)), None, [('Pass', (4, 2))])], [])]), +('Module', [('TryExcept', (1, 0), [('Pass', (2, 2))], [('excepthandler', (3, 0), ('Name', (3, 7), 'Exception', ('Load',)), None, [('Pass', (4, 2))], 3, 0)], [])]), ('Module', [('TryFinally', (1, 0), [('Pass', (2, 2))], [('Pass', (4, 2))])]), ('Module', [('Assert', (1, 0), ('Name', (1, 7), 'v', ('Load',)), None)]), ('Module', [('Import', (1, 0), [('alias', 'sys', None)])]), @@ -337,4 +233,4 @@ ('Expression', ('Tuple', (1, 0), [('Num', (1, 0), 1), ('Num', (1, 2), 2), ('Num', (1, 4), 3)], ('Load',))), ('Expression', ('Call', (1, 0), ('Attribute', (1, 0), ('Attribute', (1, 0), ('Attribute', (1, 0), ('Name', (1, 0), 'a', ('Load',)), 'b', ('Load',)), 'c', ('Load',)), 'd', ('Load',)), [('Subscript', (1, 8), ('Attribute', (1, 8), ('Name', (1, 8), 'a', ('Load',)), 'b', ('Load',)), ('Slice', ('Num', (1, 12), 1), ('Num', (1, 14), 2), None), ('Load',))], [], None, None)), ] -main() +run_tests() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-11-18 00:15:26
|
Revision: 5588 http://jython.svn.sourceforge.net/jython/?rev=5588&view=rev Author: fwierzbicki Date: 2008-11-18 00:15:21 +0000 (Tue, 18 Nov 2008) Log Message: ----------- Tweaked test_ast for Lists. Modified Paths: -------------- branches/astwrite/Lib/test/test_ast.py Modified: branches/astwrite/Lib/test/test_ast.py =================================================================== --- branches/astwrite/Lib/test/test_ast.py 2008-11-17 21:50:26 UTC (rev 5587) +++ branches/astwrite/Lib/test/test_ast.py 2008-11-18 00:15:21 UTC (rev 5588) @@ -1,36 +1,22 @@ -#Taken and modified from CPython's release25-maint branch, revision 62446. -import sys,os, itertools +import sys, itertools, unittest +from test import test_support import ast -def get_class_name(t): - result = t.__class__.__name__ - if os.name.startswith('java'): - if result in ("expr_contextType", - "boolopType", - "unaryopType", - "cmpopType", - "operatorType"): - result = t.name() - else: - result = result.split(".")[-1] - if result.endswith("Type"): - result = result[:-4] - return result - def to_tuple(t): if t is None or isinstance(t, (basestring, int, long, complex)): return t - elif hasattr(t, '__iter__'): + elif isinstance(t, list): return [to_tuple(e) for e in t] - result = [get_class_name(t)] + result = [t.__class__.__name__] if hasattr(t, 'lineno') and hasattr(t, 'col_offset'): result.append((t.lineno, t.col_offset)) - if not hasattr(t, '_fields') or t._fields is None: + if t._fields is None: return tuple(result) for f in t._fields: result.append(to_tuple(getattr(t, f))) return tuple(result) + # These tests are compiled through "exec" # There should be atleast one test per statement exec_tests = [ @@ -134,59 +120,189 @@ # TODO: expr_context, slice, boolop, operator, unaryop, cmpop, comprehension # excepthandler, arguments, keywords, alias -if __name__=='__main__' and sys.argv[1:] == ['-g']: - for statements, kind in ((exec_tests, "exec"), (single_tests, "single"), - (eval_tests, "eval")): - print kind+"_results = [" - for s in statements: - print repr(to_tuple(compile(s, "?", kind, 0x400)))+"," - print "]" - print "run_tests()" - raise SystemExit +class AST_Tests(unittest.TestCase): -def test_order(ast_node, parent_pos): - - if (not isinstance(ast_node, ast.AST) - or not hasattr(ast_node, '_fields') - or ast_node._fields == None): + def _assert_order(self, ast_node, parent_pos): + if not isinstance(ast_node, ast.AST) or ast_node._fields is None: return - if isinstance(ast_node, (ast.expr, ast.stmt, ast.excepthandler)): - node_pos = (ast_node.lineno, ast_node.col_offset) - assert node_pos >= parent_pos, (node_pos, parent_pos) - parent_pos = (ast_node.lineno, ast_node.col_offset) - for name in ast_node._fields: - value = getattr(ast_node, name) - if hasattr(value, '__iter__'): - for child in value: - test_order(child, parent_pos) - elif value != None: - test_order(value, parent_pos) + if isinstance(ast_node, (ast.expr, ast.stmt, ast.excepthandler)): + node_pos = (ast_node.lineno, ast_node.col_offset) + self.assert_(node_pos >= parent_pos) + parent_pos = (ast_node.lineno, ast_node.col_offset) + for name in ast_node._fields: + value = getattr(ast_node, name) + if isinstance(value, list): + for child in value: + self._assert_order(child, parent_pos) + elif value is not None: + self._assert_order(value, parent_pos) -def run_tests(): - for input, output, kind in ((exec_tests, exec_results, "exec"), - (single_tests, single_results, "single"), - (eval_tests, eval_results, "eval")): - for i, o in itertools.izip(input, output): - ast_tree = compile(i, "?", kind, 0x400) - assert to_tuple(ast_tree) == o, "expected %s, got %s" % ( - o, to_tuple(ast_tree)) - test_order(ast_tree, (0, 0)) + def test_snippets(self): + for input, output, kind in ((exec_tests, exec_results, "exec"), + (single_tests, single_results, "single"), + (eval_tests, eval_results, "eval")): + for i, o in itertools.izip(input, output): + ast_tree = compile(i, "?", kind, ast.PyCF_ONLY_AST) + self.assertEquals(to_tuple(ast_tree), o) + self._assert_order(ast_tree, (0, 0)) -# XXX: AugStore added for Jython. Short term it is too hard to emit just "Store" as CPython does. + def test_nodeclasses(self): + x = ast.BinOp(1, 2, 3, lineno=0) + self.assertEquals(x.left, 1) + self.assertEquals(x.op, 2) + self.assertEquals(x.right, 3) + self.assertEquals(x.lineno, 0) + + # node raises exception when not given enough arguments + self.assertRaises(TypeError, ast.BinOp, 1, 2) + + # can set attributes through kwargs too + x = ast.BinOp(left=1, op=2, right=3, lineno=0) + self.assertEquals(x.left, 1) + self.assertEquals(x.op, 2) + self.assertEquals(x.right, 3) + self.assertEquals(x.lineno, 0) + + # this used to fail because Sub._fields was None + x = ast.Sub() + + def test_pickling(self): + import pickle + mods = [pickle] + try: + import cPickle + mods.append(cPickle) + except ImportError: + pass + protocols = [0, 1, 2] + for mod in mods: + for protocol in protocols: + for ast in (compile(i, "?", "exec", 0x400) for i in exec_tests): + ast2 = mod.loads(mod.dumps(ast, protocol)) + self.assertEquals(to_tuple(ast2), to_tuple(ast)) + + +class ASTHelpers_Test(unittest.TestCase): + + def test_parse(self): + a = ast.parse('foo(1 + 1)') + b = compile('foo(1 + 1)', '<unknown>', 'exec', ast.PyCF_ONLY_AST) + self.assertEqual(ast.dump(a), ast.dump(b)) + + def test_dump(self): + node = ast.parse('spam(eggs, "and cheese")') + self.assertEqual(ast.dump(node), + "Module(body=[Expr(value=Call(func=Name(id='spam', ctx=Load()), " + "args=[Name(id='eggs', ctx=Load()), Str(s='and cheese')], " + "keywords=[], starargs=None, kwargs=None))])" + ) + self.assertEqual(ast.dump(node, annotate_fields=False), + "Module([Expr(Call(Name('spam', Load()), [Name('eggs', Load()), " + "Str('and cheese')], [], None, None))])" + ) + self.assertEqual(ast.dump(node, include_attributes=True), + "Module(body=[Expr(value=Call(func=Name(id='spam', ctx=Load(), " + "lineno=1, col_offset=0), args=[Name(id='eggs', ctx=Load(), " + "lineno=1, col_offset=5), Str(s='and cheese', lineno=1, " + "col_offset=11)], keywords=[], starargs=None, kwargs=None, " + "lineno=1, col_offset=0), lineno=1, col_offset=0)])" + ) + + def test_copy_location(self): + src = ast.parse('1 + 1', mode='eval') + src.body.right = ast.copy_location(ast.Num(2), src.body.right) + self.assertEqual(ast.dump(src, include_attributes=True), + 'Expression(body=BinOp(left=Num(n=1, lineno=1, col_offset=0), ' + 'op=Add(), right=Num(n=2, lineno=1, col_offset=4), lineno=1, ' + 'col_offset=0))' + ) + + def test_fix_missing_locations(self): + src = ast.parse('write("spam")') + src.body.append(ast.Expr(ast.Call(ast.Name('spam', ast.Load()), + [ast.Str('eggs')], [], None, None))) + self.assertEqual(src, ast.fix_missing_locations(src)) + self.assertEqual(ast.dump(src, include_attributes=True), + "Module(body=[Expr(value=Call(func=Name(id='write', ctx=Load(), " + "lineno=1, col_offset=0), args=[Str(s='spam', lineno=1, " + "col_offset=6)], keywords=[], starargs=None, kwargs=None, " + "lineno=1, col_offset=0), lineno=1, col_offset=0), " + "Expr(value=Call(func=Name(id='spam', ctx=Load(), lineno=1, " + "col_offset=0), args=[Str(s='eggs', lineno=1, col_offset=0)], " + "keywords=[], starargs=None, kwargs=None, lineno=1, " + "col_offset=0), lineno=1, col_offset=0)])" + ) + + def test_increment_lineno(self): + src = ast.parse('1 + 1', mode='eval') + self.assertEqual(ast.increment_lineno(src, n=3), src) + self.assertEqual(ast.dump(src, include_attributes=True), + 'Expression(body=BinOp(left=Num(n=1, lineno=4, col_offset=0), ' + 'op=Add(), right=Num(n=1, lineno=4, col_offset=4), lineno=4, ' + 'col_offset=0))' + ) + + def test_iter_fields(self): + node = ast.parse('foo()', mode='eval') + d = dict(ast.iter_fields(node.body)) + self.assertEqual(d.pop('func').id, 'foo') + self.assertEqual(d, {'keywords': [], 'kwargs': None, + 'args': [], 'starargs': None}) + + def test_iter_child_nodes(self): + node = ast.parse("spam(23, 42, eggs='leek')", mode='eval') + self.assertEqual(len(list(ast.iter_child_nodes(node.body))), 4) + iterator = ast.iter_child_nodes(node.body) + self.assertEqual(next(iterator).id, 'spam') + self.assertEqual(next(iterator).n, 23) + self.assertEqual(next(iterator).n, 42) + self.assertEqual(ast.dump(next(iterator)), + "keyword(arg='eggs', value=Str(s='leek'))" + ) + + def test_get_docstring(self): + node = ast.parse('def foo():\n """line one\n line two"""') + self.assertEqual(ast.get_docstring(node.body[0]), + 'line one\nline two') + + def test_literal_eval(self): + self.assertEqual(ast.literal_eval('[1, 2, 3]'), [1, 2, 3]) + self.assertEqual(ast.literal_eval('{"foo": 42}'), {"foo": 42}) + self.assertEqual(ast.literal_eval('(True, False, None)'), (True, False, None)) + self.assertRaises(ValueError, ast.literal_eval, 'foo()') + + +def test_main(): + test_support.run_unittest(AST_Tests, ASTHelpers_Test) + +def main(): + if __name__ != '__main__': + return + if sys.argv[1:] == ['-g']: + for statements, kind in ((exec_tests, "exec"), (single_tests, "single"), + (eval_tests, "eval")): + print kind+"_results = [" + for s in statements: + print repr(to_tuple(compile(s, "?", kind, 0x400)))+"," + print "]" + print "main()" + raise SystemExit + test_main() + #### EVERYTHING BELOW IS GENERATED ##### exec_results = [ ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, []), [('Pass', (1, 9))], [])]), -('Module', [('ClassDef', (1, 0), 'C', [], [('Pass', (1, 8))],[])]), +('Module', [('ClassDef', (1, 0), 'C', [], [('Pass', (1, 8))], [])]), ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, []), [('Return', (1, 8), ('Num', (1, 15), 1))], [])]), ('Module', [('Delete', (1, 0), [('Name', (1, 4), 'v', ('Del',))])]), ('Module', [('Assign', (1, 0), [('Name', (1, 0), 'v', ('Store',))], ('Num', (1, 4), 1))]), -('Module', [('AugAssign', (1, 0), ('Name', (1, 0), 'v', ('AugStore',)), ('Add',), ('Num', (1, 5), 1))]), +('Module', [('AugAssign', (1, 0), ('Name', (1, 0), 'v', ('Store',)), ('Add',), ('Num', (1, 5), 1))]), ('Module', [('Print', (1, 0), ('Name', (1, 8), 'f', ('Load',)), [('Num', (1, 11), 1)], False)]), ('Module', [('For', (1, 0), ('Name', (1, 4), 'v', ('Store',)), ('Name', (1, 9), 'v', ('Load',)), [('Pass', (1, 11))], [])]), ('Module', [('While', (1, 0), ('Name', (1, 6), 'v', ('Load',)), [('Pass', (1, 8))], [])]), ('Module', [('If', (1, 0), ('Name', (1, 3), 'v', ('Load',)), [('Pass', (1, 5))], [])]), ('Module', [('Raise', (1, 0), ('Name', (1, 6), 'Exception', ('Load',)), ('Str', (1, 17), 'string'), None)]), -('Module', [('TryExcept', (1, 0), [('Pass', (2, 2))], [('excepthandler', (3, 0), ('Name', (3, 7), 'Exception', ('Load',)), None, [('Pass', (4, 2))], 3, 0)], [])]), +('Module', [('TryExcept', (1, 0), [('Pass', (2, 2))], [('ExceptHandler', (3, 0), ('Name', (3, 7), 'Exception', ('Load',)), None, [('Pass', (4, 2))])], [])]), ('Module', [('TryFinally', (1, 0), [('Pass', (2, 2))], [('Pass', (4, 2))])]), ('Module', [('Assert', (1, 0), ('Name', (1, 7), 'v', ('Load',)), None)]), ('Module', [('Import', (1, 0), [('alias', 'sys', None)])]), @@ -221,4 +337,4 @@ ('Expression', ('Tuple', (1, 0), [('Num', (1, 0), 1), ('Num', (1, 2), 2), ('Num', (1, 4), 3)], ('Load',))), ('Expression', ('Call', (1, 0), ('Attribute', (1, 0), ('Attribute', (1, 0), ('Attribute', (1, 0), ('Name', (1, 0), 'a', ('Load',)), 'b', ('Load',)), 'c', ('Load',)), 'd', ('Load',)), [('Subscript', (1, 8), ('Attribute', (1, 8), ('Name', (1, 8), 'a', ('Load',)), 'b', ('Load',)), ('Slice', ('Num', (1, 12), 1), ('Num', (1, 14), 2), None), ('Load',))], [], None, None)), ] -run_tests() +main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-11-17 21:50:28
|
Revision: 5587 http://jython.svn.sourceforge.net/jython/?rev=5587&view=rev Author: fwierzbicki Date: 2008-11-17 21:50:26 +0000 (Mon, 17 Nov 2008) Log Message: ----------- Now checking in output of asdl_antlr.py. Modified Paths: -------------- branches/astwrite/src/org/python/antlr/ast/Assign.java branches/astwrite/src/org/python/antlr/ast/BoolOp.java branches/astwrite/src/org/python/antlr/ast/Call.java branches/astwrite/src/org/python/antlr/ast/ClassDef.java branches/astwrite/src/org/python/antlr/ast/Compare.java branches/astwrite/src/org/python/antlr/ast/Delete.java branches/astwrite/src/org/python/antlr/ast/Dict.java branches/astwrite/src/org/python/antlr/ast/ExtSlice.java branches/astwrite/src/org/python/antlr/ast/For.java branches/astwrite/src/org/python/antlr/ast/FunctionDef.java branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java branches/astwrite/src/org/python/antlr/ast/Global.java branches/astwrite/src/org/python/antlr/ast/If.java branches/astwrite/src/org/python/antlr/ast/Import.java branches/astwrite/src/org/python/antlr/ast/ImportFrom.java branches/astwrite/src/org/python/antlr/ast/Interactive.java branches/astwrite/src/org/python/antlr/ast/List.java branches/astwrite/src/org/python/antlr/ast/ListComp.java branches/astwrite/src/org/python/antlr/ast/Module.java branches/astwrite/src/org/python/antlr/ast/Print.java branches/astwrite/src/org/python/antlr/ast/Suite.java branches/astwrite/src/org/python/antlr/ast/TryExcept.java branches/astwrite/src/org/python/antlr/ast/TryFinally.java branches/astwrite/src/org/python/antlr/ast/Tuple.java branches/astwrite/src/org/python/antlr/ast/While.java branches/astwrite/src/org/python/antlr/ast/With.java branches/astwrite/src/org/python/antlr/ast/argumentsType.java branches/astwrite/src/org/python/antlr/ast/comprehensionType.java branches/astwrite/src/org/python/antlr/ast/excepthandlerType.java Modified: branches/astwrite/src/org/python/antlr/ast/Assign.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Assign.java 2008-11-17 21:48:50 UTC (rev 5586) +++ branches/astwrite/src/org/python/antlr/ast/Assign.java 2008-11-17 21:50:26 UTC (rev 5587) @@ -7,53 +7,56 @@ import java.io.IOException; public class Assign extends stmtType { - public exprType[] targets; + public java.util.List<exprType> targets; public exprType value; private final static String[] fields = new String[] {"targets", "value"}; public String[] get_fields() { return fields; } - public Assign(exprType[] targets, exprType value) { + public Assign(java.util.List<exprType> targets, exprType value) { this.targets = targets; if (targets != null) { - for(int itargets=0;itargets<targets.length;itargets++) { - addChild(targets[itargets]); + for(PythonTree t : targets) { + addChild(t); } } this.value = value; addChild(value); } - public Assign(Token token, exprType[] targets, exprType value) { + public Assign(Token token, java.util.List<exprType> targets, exprType + value) { super(token); this.targets = targets; if (targets != null) { - for(int itargets=0;itargets<targets.length;itargets++) { - addChild(targets[itargets]); + for(PythonTree t : targets) { + addChild(t); } } this.value = value; addChild(value); } - public Assign(int ttype, Token token, exprType[] targets, exprType value) { + public Assign(int ttype, Token token, java.util.List<exprType> targets, + exprType value) { super(ttype, token); this.targets = targets; if (targets != null) { - for(int itargets=0;itargets<targets.length;itargets++) { - addChild(targets[itargets]); + for(PythonTree t : targets) { + addChild(t); } } this.value = value; addChild(value); } - public Assign(PythonTree tree, exprType[] targets, exprType value) { + public Assign(PythonTree tree, java.util.List<exprType> targets, exprType + value) { super(tree); this.targets = targets; if (targets != null) { - for(int itargets=0;itargets<targets.length;itargets++) { - addChild(targets[itargets]); + for(PythonTree t : targets) { + addChild(t); } } this.value = value; @@ -82,9 +85,9 @@ public void traverse(VisitorIF visitor) throws Exception { if (targets != null) { - for (int i = 0; i < targets.length; i++) { - if (targets[i] != null) - targets[i].accept(visitor); + for (PythonTree t : targets) { + if (t != null) + t.accept(visitor); } } if (value != null) Modified: branches/astwrite/src/org/python/antlr/ast/BoolOp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/BoolOp.java 2008-11-17 21:48:50 UTC (rev 5586) +++ branches/astwrite/src/org/python/antlr/ast/BoolOp.java 2008-11-17 21:50:26 UTC (rev 5587) @@ -8,50 +8,52 @@ public class BoolOp extends exprType { public boolopType op; - public exprType[] values; + public java.util.List<exprType> values; private final static String[] fields = new String[] {"op", "values"}; public String[] get_fields() { return fields; } - public BoolOp(boolopType op, exprType[] values) { + public BoolOp(boolopType op, java.util.List<exprType> values) { this.op = op; this.values = values; if (values != null) { - for(int ivalues=0;ivalues<values.length;ivalues++) { - addChild(values[ivalues]); + for(PythonTree t : values) { + addChild(t); } } } - public BoolOp(Token token, boolopType op, exprType[] values) { + public BoolOp(Token token, boolopType op, java.util.List<exprType> values) { super(token); this.op = op; this.values = values; if (values != null) { - for(int ivalues=0;ivalues<values.length;ivalues++) { - addChild(values[ivalues]); + for(PythonTree t : values) { + addChild(t); } } } - public BoolOp(int ttype, Token token, boolopType op, exprType[] values) { + public BoolOp(int ttype, Token token, boolopType op, + java.util.List<exprType> values) { super(ttype, token); this.op = op; this.values = values; if (values != null) { - for(int ivalues=0;ivalues<values.length;ivalues++) { - addChild(values[ivalues]); + for(PythonTree t : values) { + addChild(t); } } } - public BoolOp(PythonTree tree, boolopType op, exprType[] values) { + public BoolOp(PythonTree tree, boolopType op, java.util.List<exprType> + values) { super(tree); this.op = op; this.values = values; if (values != null) { - for(int ivalues=0;ivalues<values.length;ivalues++) { - addChild(values[ivalues]); + for(PythonTree t : values) { + addChild(t); } } } @@ -78,9 +80,9 @@ public void traverse(VisitorIF visitor) throws Exception { if (values != null) { - for (int i = 0; i < values.length; i++) { - if (values[i] != null) - values[i].accept(visitor); + for (PythonTree t : values) { + if (t != null) + t.accept(visitor); } } } Modified: branches/astwrite/src/org/python/antlr/ast/Call.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Call.java 2008-11-17 21:48:50 UTC (rev 5586) +++ branches/astwrite/src/org/python/antlr/ast/Call.java 2008-11-17 21:50:26 UTC (rev 5587) @@ -8,8 +8,8 @@ public class Call extends exprType { public exprType func; - public exprType[] args; - public keywordType[] keywords; + public java.util.List<exprType> args; + public java.util.List<keywordType> keywords; public exprType starargs; public exprType kwargs; @@ -18,20 +18,20 @@ "starargs", "kwargs"}; public String[] get_fields() { return fields; } - public Call(exprType func, exprType[] args, keywordType[] keywords, - exprType starargs, exprType kwargs) { + public Call(exprType func, java.util.List<exprType> args, + java.util.List<keywordType> keywords, exprType starargs, exprType kwargs) { this.func = func; addChild(func); this.args = args; if (args != null) { - for(int iargs=0;iargs<args.length;iargs++) { - addChild(args[iargs]); + for(PythonTree t : args) { + addChild(t); } } this.keywords = keywords; if (keywords != null) { - for(int ikeywords=0;ikeywords<keywords.length;ikeywords++) { - addChild(keywords[ikeywords]); + for(PythonTree t : keywords) { + addChild(t); } } this.starargs = starargs; @@ -40,21 +40,21 @@ addChild(kwargs); } - public Call(Token token, exprType func, exprType[] args, keywordType[] - keywords, exprType starargs, exprType kwargs) { + public Call(Token token, exprType func, java.util.List<exprType> args, + java.util.List<keywordType> keywords, exprType starargs, exprType kwargs) { super(token); this.func = func; addChild(func); this.args = args; if (args != null) { - for(int iargs=0;iargs<args.length;iargs++) { - addChild(args[iargs]); + for(PythonTree t : args) { + addChild(t); } } this.keywords = keywords; if (keywords != null) { - for(int ikeywords=0;ikeywords<keywords.length;ikeywords++) { - addChild(keywords[ikeywords]); + for(PythonTree t : keywords) { + addChild(t); } } this.starargs = starargs; @@ -63,21 +63,22 @@ addChild(kwargs); } - public Call(int ttype, Token token, exprType func, exprType[] args, - keywordType[] keywords, exprType starargs, exprType kwargs) { + public Call(int ttype, Token token, exprType func, java.util.List<exprType> + args, java.util.List<keywordType> keywords, exprType starargs, exprType + kwargs) { super(ttype, token); this.func = func; addChild(func); this.args = args; if (args != null) { - for(int iargs=0;iargs<args.length;iargs++) { - addChild(args[iargs]); + for(PythonTree t : args) { + addChild(t); } } this.keywords = keywords; if (keywords != null) { - for(int ikeywords=0;ikeywords<keywords.length;ikeywords++) { - addChild(keywords[ikeywords]); + for(PythonTree t : keywords) { + addChild(t); } } this.starargs = starargs; @@ -86,21 +87,21 @@ addChild(kwargs); } - public Call(PythonTree tree, exprType func, exprType[] args, keywordType[] - keywords, exprType starargs, exprType kwargs) { + public Call(PythonTree tree, exprType func, java.util.List<exprType> args, + java.util.List<keywordType> keywords, exprType starargs, exprType kwargs) { super(tree); this.func = func; addChild(func); this.args = args; if (args != null) { - for(int iargs=0;iargs<args.length;iargs++) { - addChild(args[iargs]); + for(PythonTree t : args) { + addChild(t); } } this.keywords = keywords; if (keywords != null) { - for(int ikeywords=0;ikeywords<keywords.length;ikeywords++) { - addChild(keywords[ikeywords]); + for(PythonTree t : keywords) { + addChild(t); } } this.starargs = starargs; @@ -142,15 +143,15 @@ if (func != null) func.accept(visitor); if (args != null) { - for (int i = 0; i < args.length; i++) { - if (args[i] != null) - args[i].accept(visitor); + for (PythonTree t : args) { + if (t != null) + t.accept(visitor); } } if (keywords != null) { - for (int i = 0; i < keywords.length; i++) { - if (keywords[i] != null) - keywords[i].accept(visitor); + for (PythonTree t : keywords) { + if (t != null) + t.accept(visitor); } } if (starargs != null) Modified: branches/astwrite/src/org/python/antlr/ast/ClassDef.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/ClassDef.java 2008-11-17 21:48:50 UTC (rev 5586) +++ branches/astwrite/src/org/python/antlr/ast/ClassDef.java 2008-11-17 21:50:26 UTC (rev 5587) @@ -8,105 +8,106 @@ public class ClassDef extends stmtType { public String name; - public exprType[] bases; - public stmtType[] body; - public exprType[] decorators; + public java.util.List<exprType> bases; + public java.util.List<stmtType> body; + public java.util.List<exprType> decorators; private final static String[] fields = new String[] {"name", "bases", "body", "decorators"}; public String[] get_fields() { return fields; } - public ClassDef(String name, exprType[] bases, stmtType[] body, exprType[] - decorators) { + public ClassDef(String name, java.util.List<exprType> bases, + java.util.List<stmtType> body, java.util.List<exprType> decorators) { this.name = name; this.bases = bases; if (bases != null) { - for(int ibases=0;ibases<bases.length;ibases++) { - addChild(bases[ibases]); + for(PythonTree t : bases) { + addChild(t); } } this.body = body; if (body != null) { - for(int ibody=0;ibody<body.length;ibody++) { - addChild(body[ibody]); + for(PythonTree t : body) { + addChild(t); } } this.decorators = decorators; if (decorators != null) { - for(int idecorators=0;idecorators<decorators.length;idecorators++) { - addChild(decorators[idecorators]); + for(PythonTree t : decorators) { + addChild(t); } } } - public ClassDef(Token token, String name, exprType[] bases, stmtType[] - body, exprType[] decorators) { + public ClassDef(Token token, String name, java.util.List<exprType> bases, + java.util.List<stmtType> body, java.util.List<exprType> decorators) { super(token); this.name = name; this.bases = bases; if (bases != null) { - for(int ibases=0;ibases<bases.length;ibases++) { - addChild(bases[ibases]); + for(PythonTree t : bases) { + addChild(t); } } this.body = body; if (body != null) { - for(int ibody=0;ibody<body.length;ibody++) { - addChild(body[ibody]); + for(PythonTree t : body) { + addChild(t); } } this.decorators = decorators; if (decorators != null) { - for(int idecorators=0;idecorators<decorators.length;idecorators++) { - addChild(decorators[idecorators]); + for(PythonTree t : decorators) { + addChild(t); } } } - public ClassDef(int ttype, Token token, String name, exprType[] bases, - stmtType[] body, exprType[] decorators) { + public ClassDef(int ttype, Token token, String name, + java.util.List<exprType> bases, java.util.List<stmtType> body, + java.util.List<exprType> decorators) { super(ttype, token); this.name = name; this.bases = bases; if (bases != null) { - for(int ibases=0;ibases<bases.length;ibases++) { - addChild(bases[ibases]); + for(PythonTree t : bases) { + addChild(t); } } this.body = body; if (body != null) { - for(int ibody=0;ibody<body.length;ibody++) { - addChild(body[ibody]); + for(PythonTree t : body) { + addChild(t); } } this.decorators = decorators; if (decorators != null) { - for(int idecorators=0;idecorators<decorators.length;idecorators++) { - addChild(decorators[idecorators]); + for(PythonTree t : decorators) { + addChild(t); } } } - public ClassDef(PythonTree tree, String name, exprType[] bases, stmtType[] - body, exprType[] decorators) { + public ClassDef(PythonTree tree, String name, java.util.List<exprType> + bases, java.util.List<stmtType> body, java.util.List<exprType> decorators) { super(tree); this.name = name; this.bases = bases; if (bases != null) { - for(int ibases=0;ibases<bases.length;ibases++) { - addChild(bases[ibases]); + for(PythonTree t : bases) { + addChild(t); } } this.body = body; if (body != null) { - for(int ibody=0;ibody<body.length;ibody++) { - addChild(body[ibody]); + for(PythonTree t : body) { + addChild(t); } } this.decorators = decorators; if (decorators != null) { - for(int idecorators=0;idecorators<decorators.length;idecorators++) { - addChild(decorators[idecorators]); + for(PythonTree t : decorators) { + addChild(t); } } } @@ -139,21 +140,21 @@ public void traverse(VisitorIF visitor) throws Exception { if (bases != null) { - for (int i = 0; i < bases.length; i++) { - if (bases[i] != null) - bases[i].accept(visitor); + for (PythonTree t : bases) { + if (t != null) + t.accept(visitor); } } if (body != null) { - for (int i = 0; i < body.length; i++) { - if (body[i] != null) - body[i].accept(visitor); + for (PythonTree t : body) { + if (t != null) + t.accept(visitor); } } if (decorators != null) { - for (int i = 0; i < decorators.length; i++) { - if (decorators[i] != null) - decorators[i].accept(visitor); + for (PythonTree t : decorators) { + if (t != null) + t.accept(visitor); } } } Modified: branches/astwrite/src/org/python/antlr/ast/Compare.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Compare.java 2008-11-17 21:48:50 UTC (rev 5586) +++ branches/astwrite/src/org/python/antlr/ast/Compare.java 2008-11-17 21:50:26 UTC (rev 5587) @@ -8,67 +8,64 @@ public class Compare extends exprType { public exprType left; - public cmpopType[] ops; - public exprType[] comparators; + public java.util.List<cmpopType> ops; + public java.util.List<exprType> comparators; private final static String[] fields = new String[] {"left", "ops", "comparators"}; public String[] get_fields() { return fields; } - public Compare(exprType left, cmpopType[] ops, exprType[] comparators) { + public Compare(exprType left, java.util.List<cmpopType> ops, + java.util.List<exprType> comparators) { this.left = left; addChild(left); this.ops = ops; this.comparators = comparators; if (comparators != null) { - for(int - icomparators=0;icomparators<comparators.length;icomparators++) { - addChild(comparators[icomparators]); + for(PythonTree t : comparators) { + addChild(t); } } } - public Compare(Token token, exprType left, cmpopType[] ops, exprType[] - comparators) { + public Compare(Token token, exprType left, java.util.List<cmpopType> ops, + java.util.List<exprType> comparators) { super(token); this.left = left; addChild(left); this.ops = ops; this.comparators = comparators; if (comparators != null) { - for(int - icomparators=0;icomparators<comparators.length;icomparators++) { - addChild(comparators[icomparators]); + for(PythonTree t : comparators) { + addChild(t); } } } - public Compare(int ttype, Token token, exprType left, cmpopType[] ops, - exprType[] comparators) { + public Compare(int ttype, Token token, exprType left, + java.util.List<cmpopType> ops, java.util.List<exprType> comparators) { super(ttype, token); this.left = left; addChild(left); this.ops = ops; this.comparators = comparators; if (comparators != null) { - for(int - icomparators=0;icomparators<comparators.length;icomparators++) { - addChild(comparators[icomparators]); + for(PythonTree t : comparators) { + addChild(t); } } } - public Compare(PythonTree tree, exprType left, cmpopType[] ops, exprType[] - comparators) { + public Compare(PythonTree tree, exprType left, java.util.List<cmpopType> + ops, java.util.List<exprType> comparators) { super(tree); this.left = left; addChild(left); this.ops = ops; this.comparators = comparators; if (comparators != null) { - for(int - icomparators=0;icomparators<comparators.length;icomparators++) { - addChild(comparators[icomparators]); + for(PythonTree t : comparators) { + addChild(t); } } } @@ -100,9 +97,9 @@ if (left != null) left.accept(visitor); if (comparators != null) { - for (int i = 0; i < comparators.length; i++) { - if (comparators[i] != null) - comparators[i].accept(visitor); + for (PythonTree t : comparators) { + if (t != null) + t.accept(visitor); } } } Modified: branches/astwrite/src/org/python/antlr/ast/Delete.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Delete.java 2008-11-17 21:48:50 UTC (rev 5586) +++ branches/astwrite/src/org/python/antlr/ast/Delete.java 2008-11-17 21:50:26 UTC (rev 5587) @@ -7,46 +7,46 @@ import java.io.IOException; public class Delete extends stmtType { - public exprType[] targets; + public java.util.List<exprType> targets; private final static String[] fields = new String[] {"targets"}; public String[] get_fields() { return fields; } - public Delete(exprType[] targets) { + public Delete(java.util.List<exprType> targets) { this.targets = targets; if (targets != null) { - for(int itargets=0;itargets<targets.length;itargets++) { - addChild(targets[itargets]); + for(PythonTree t : targets) { + addChild(t); } } } - public Delete(Token token, exprType[] targets) { + public Delete(Token token, java.util.List<exprType> targets) { super(token); this.targets = targets; if (targets != null) { - for(int itargets=0;itargets<targets.length;itargets++) { - addChild(targets[itargets]); + for(PythonTree t : targets) { + addChild(t); } } } - public Delete(int ttype, Token token, exprType[] targets) { + public Delete(int ttype, Token token, java.util.List<exprType> targets) { super(ttype, token); this.targets = targets; if (targets != null) { - for(int itargets=0;itargets<targets.length;itargets++) { - addChild(targets[itargets]); + for(PythonTree t : targets) { + addChild(t); } } } - public Delete(PythonTree tree, exprType[] targets) { + public Delete(PythonTree tree, java.util.List<exprType> targets) { super(tree); this.targets = targets; if (targets != null) { - for(int itargets=0;itargets<targets.length;itargets++) { - addChild(targets[itargets]); + for(PythonTree t : targets) { + addChild(t); } } } @@ -70,9 +70,9 @@ public void traverse(VisitorIF visitor) throws Exception { if (targets != null) { - for (int i = 0; i < targets.length; i++) { - if (targets[i] != null) - targets[i].accept(visitor); + for (PythonTree t : targets) { + if (t != null) + t.accept(visitor); } } } Modified: branches/astwrite/src/org/python/antlr/ast/Dict.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Dict.java 2008-11-17 21:48:50 UTC (rev 5586) +++ branches/astwrite/src/org/python/antlr/ast/Dict.java 2008-11-17 21:50:26 UTC (rev 5587) @@ -7,71 +7,75 @@ import java.io.IOException; public class Dict extends exprType { - public exprType[] keys; - public exprType[] values; + public java.util.List<exprType> keys; + public java.util.List<exprType> values; private final static String[] fields = new String[] {"keys", "values"}; public String[] get_fields() { return fields; } - public Dict(exprType[] keys, exprType[] values) { + public Dict(java.util.List<exprType> keys, java.util.List<exprType> values) + { this.keys = keys; if (keys != null) { - for(int ikeys=0;ikeys<keys.length;ikeys++) { - addChild(keys[ikeys]); + for(PythonTree t : keys) { + addChild(t); } } this.values = values; if (values != null) { - for(int ivalues=0;ivalues<values.length;ivalues++) { - addChild(values[ivalues]); + for(PythonTree t : values) { + addChild(t); } } } - public Dict(Token token, exprType[] keys, exprType[] values) { + public Dict(Token token, java.util.List<exprType> keys, + java.util.List<exprType> values) { super(token); this.keys = keys; if (keys != null) { - for(int ikeys=0;ikeys<keys.length;ikeys++) { - addChild(keys[ikeys]); + for(PythonTree t : keys) { + addChild(t); } } this.values = values; if (values != null) { - for(int ivalues=0;ivalues<values.length;ivalues++) { - addChild(values[ivalues]); + for(PythonTree t : values) { + addChild(t); } } } - public Dict(int ttype, Token token, exprType[] keys, exprType[] values) { + public Dict(int ttype, Token token, java.util.List<exprType> keys, + java.util.List<exprType> values) { super(ttype, token); this.keys = keys; if (keys != null) { - for(int ikeys=0;ikeys<keys.length;ikeys++) { - addChild(keys[ikeys]); + for(PythonTree t : keys) { + addChild(t); } } this.values = values; if (values != null) { - for(int ivalues=0;ivalues<values.length;ivalues++) { - addChild(values[ivalues]); + for(PythonTree t : values) { + addChild(t); } } } - public Dict(PythonTree tree, exprType[] keys, exprType[] values) { + public Dict(PythonTree tree, java.util.List<exprType> keys, + java.util.List<exprType> values) { super(tree); this.keys = keys; if (keys != null) { - for(int ikeys=0;ikeys<keys.length;ikeys++) { - addChild(keys[ikeys]); + for(PythonTree t : keys) { + addChild(t); } } this.values = values; if (values != null) { - for(int ivalues=0;ivalues<values.length;ivalues++) { - addChild(values[ivalues]); + for(PythonTree t : values) { + addChild(t); } } } @@ -98,15 +102,15 @@ public void traverse(VisitorIF visitor) throws Exception { if (keys != null) { - for (int i = 0; i < keys.length; i++) { - if (keys[i] != null) - keys[i].accept(visitor); + for (PythonTree t : keys) { + if (t != null) + t.accept(visitor); } } if (values != null) { - for (int i = 0; i < values.length; i++) { - if (values[i] != null) - values[i].accept(visitor); + for (PythonTree t : values) { + if (t != null) + t.accept(visitor); } } } Modified: branches/astwrite/src/org/python/antlr/ast/ExtSlice.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/ExtSlice.java 2008-11-17 21:48:50 UTC (rev 5586) +++ branches/astwrite/src/org/python/antlr/ast/ExtSlice.java 2008-11-17 21:50:26 UTC (rev 5587) @@ -7,46 +7,46 @@ import java.io.IOException; public class ExtSlice extends sliceType { - public sliceType[] dims; + public java.util.List<sliceType> dims; private final static String[] fields = new String[] {"dims"}; public String[] get_fields() { return fields; } - public ExtSlice(sliceType[] dims) { + public ExtSlice(java.util.List<sliceType> dims) { this.dims = dims; if (dims != null) { - for(int idims=0;idims<dims.length;idims++) { - addChild(dims[idims]); + for(PythonTree t : dims) { + addChild(t); } } } - public ExtSlice(Token token, sliceType[] dims) { + public ExtSlice(Token token, java.util.List<sliceType> dims) { super(token); this.dims = dims; if (dims != null) { - for(int idims=0;idims<dims.length;idims++) { - addChild(dims[idims]); + for(PythonTree t : dims) { + addChild(t); } } } - public ExtSlice(int ttype, Token token, sliceType[] dims) { + public ExtSlice(int ttype, Token token, java.util.List<sliceType> dims) { super(ttype, token); this.dims = dims; if (dims != null) { - for(int idims=0;idims<dims.length;idims++) { - addChild(dims[idims]); + for(PythonTree t : dims) { + addChild(t); } } } - public ExtSlice(PythonTree tree, sliceType[] dims) { + public ExtSlice(PythonTree tree, java.util.List<sliceType> dims) { super(tree); this.dims = dims; if (dims != null) { - for(int idims=0;idims<dims.length;idims++) { - addChild(dims[idims]); + for(PythonTree t : dims) { + addChild(t); } } } @@ -70,9 +70,9 @@ public void traverse(VisitorIF visitor) throws Exception { if (dims != null) { - for (int i = 0; i < dims.length; i++) { - if (dims[i] != null) - dims[i].accept(visitor); + for (PythonTree t : dims) { + if (t != null) + t.accept(visitor); } } } Modified: branches/astwrite/src/org/python/antlr/ast/For.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/For.java 2008-11-17 21:48:50 UTC (rev 5586) +++ branches/astwrite/src/org/python/antlr/ast/For.java 2008-11-17 21:50:26 UTC (rev 5587) @@ -9,35 +9,35 @@ public class For extends stmtType { public exprType target; public exprType iter; - public stmtType[] body; - public stmtType[] orelse; + public java.util.List<stmtType> body; + public java.util.List<stmtType> orelse; private final static String[] fields = new String[] {"target", "iter", "body", "orelse"}; public String[] get_fields() { return fields; } - public For(exprType target, exprType iter, stmtType[] body, stmtType[] - orelse) { + public For(exprType target, exprType iter, java.util.List<stmtType> body, + java.util.List<stmtType> orelse) { this.target = target; addChild(target); this.iter = iter; addChild(iter); this.body = body; if (body != null) { - for(int ibody=0;ibody<body.length;ibody++) { - addChild(body[ibody]); + for(PythonTree t : body) { + addChild(t); } } this.orelse = orelse; if (orelse != null) { - for(int iorelse=0;iorelse<orelse.length;iorelse++) { - addChild(orelse[iorelse]); + for(PythonTree t : orelse) { + addChild(t); } } } - public For(Token token, exprType target, exprType iter, stmtType[] body, - stmtType[] orelse) { + public For(Token token, exprType target, exprType iter, + java.util.List<stmtType> body, java.util.List<stmtType> orelse) { super(token); this.target = target; addChild(target); @@ -45,20 +45,20 @@ addChild(iter); this.body = body; if (body != null) { - for(int ibody=0;ibody<body.length;ibody++) { - addChild(body[ibody]); + for(PythonTree t : body) { + addChild(t); } } this.orelse = orelse; if (orelse != null) { - for(int iorelse=0;iorelse<orelse.length;iorelse++) { - addChild(orelse[iorelse]); + for(PythonTree t : orelse) { + addChild(t); } } } public For(int ttype, Token token, exprType target, exprType iter, - stmtType[] body, stmtType[] orelse) { + java.util.List<stmtType> body, java.util.List<stmtType> orelse) { super(ttype, token); this.target = target; addChild(target); @@ -66,20 +66,20 @@ addChild(iter); this.body = body; if (body != null) { - for(int ibody=0;ibody<body.length;ibody++) { - addChild(body[ibody]); + for(PythonTree t : body) { + addChild(t); } } this.orelse = orelse; if (orelse != null) { - for(int iorelse=0;iorelse<orelse.length;iorelse++) { - addChild(orelse[iorelse]); + for(PythonTree t : orelse) { + addChild(t); } } } - public For(PythonTree tree, exprType target, exprType iter, stmtType[] - body, stmtType[] orelse) { + public For(PythonTree tree, exprType target, exprType iter, + java.util.List<stmtType> body, java.util.List<stmtType> orelse) { super(tree); this.target = target; addChild(target); @@ -87,14 +87,14 @@ addChild(iter); this.body = body; if (body != null) { - for(int ibody=0;ibody<body.length;ibody++) { - addChild(body[ibody]); + for(PythonTree t : body) { + addChild(t); } } this.orelse = orelse; if (orelse != null) { - for(int iorelse=0;iorelse<orelse.length;iorelse++) { - addChild(orelse[iorelse]); + for(PythonTree t : orelse) { + addChild(t); } } } @@ -131,15 +131,15 @@ if (iter != null) iter.accept(visitor); if (body != null) { - for (int i = 0; i < body.length; i++) { - if (body[i] != null) - body[i].accept(visitor); + for (PythonTree t : body) { + if (t != null) + t.accept(visitor); } } if (orelse != null) { - for (int i = 0; i < orelse.length; i++) { - if (orelse[i] != null) - orelse[i].accept(visitor); + for (PythonTree t : orelse) { + if (t != null) + t.accept(visitor); } } } Modified: branches/astwrite/src/org/python/antlr/ast/FunctionDef.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/FunctionDef.java 2008-11-17 21:48:50 UTC (rev 5586) +++ branches/astwrite/src/org/python/antlr/ast/FunctionDef.java 2008-11-17 21:50:26 UTC (rev 5587) @@ -9,84 +9,84 @@ public class FunctionDef extends stmtType { public String name; public argumentsType args; - public stmtType[] body; - public exprType[] decorators; + public java.util.List<stmtType> body; + public java.util.List<exprType> decorators; private final static String[] fields = new String[] {"name", "args", "body", "decorators"}; public String[] get_fields() { return fields; } - public FunctionDef(String name, argumentsType args, stmtType[] body, - exprType[] decorators) { + public FunctionDef(String name, argumentsType args, + java.util.List<stmtType> body, java.util.List<exprType> decorators) { this.name = name; this.args = args; this.body = body; if (body != null) { - for(int ibody=0;ibody<body.length;ibody++) { - addChild(body[ibody]); + for(PythonTree t : body) { + addChild(t); } } this.decorators = decorators; if (decorators != null) { - for(int idecorators=0;idecorators<decorators.length;idecorators++) { - addChild(decorators[idecorators]); + for(PythonTree t : decorators) { + addChild(t); } } } - public FunctionDef(Token token, String name, argumentsType args, stmtType[] - body, exprType[] decorators) { + public FunctionDef(Token token, String name, argumentsType args, + java.util.List<stmtType> body, java.util.List<exprType> decorators) { super(token); this.name = name; this.args = args; this.body = body; if (body != null) { - for(int ibody=0;ibody<body.length;ibody++) { - addChild(body[ibody]); + for(PythonTree t : body) { + addChild(t); } } this.decorators = decorators; if (decorators != null) { - for(int idecorators=0;idecorators<decorators.length;idecorators++) { - addChild(decorators[idecorators]); + for(PythonTree t : decorators) { + addChild(t); } } } public FunctionDef(int ttype, Token token, String name, argumentsType args, - stmtType[] body, exprType[] decorators) { + java.util.List<stmtType> body, java.util.List<exprType> decorators) { super(ttype, token); this.name = name; this.args = args; this.body = body; if (body != null) { - for(int ibody=0;ibody<body.length;ibody++) { - addChild(body[ibody]); + for(PythonTree t : body) { + addChild(t); } } this.decorators = decorators; if (decorators != null) { - for(int idecorators=0;idecorators<decorators.length;idecorators++) { - addChild(decorators[idecorators]); + for(PythonTree t : decorators) { + addChild(t); } } } public FunctionDef(PythonTree tree, String name, argumentsType args, - stmtType[] body, exprType[] decorators) { + java.util.List<stmtType> body, java.util.List<exprType> decorators) { super(tree); this.name = name; this.args = args; this.body = body; if (body != null) { - for(int ibody=0;ibody<body.length;ibody++) { - addChild(body[ibody]); + for(PythonTree t : body) { + addChild(t); } } this.decorators = decorators; if (decorators != null) { - for(int idecorators=0;idecorators<decorators.length;idecorators++) { - addChild(decorators[idecorators]); + for(PythonTree t : decorators) { + addChild(t); } } } @@ -121,15 +121,15 @@ if (args != null) args.accept(visitor); if (body != null) { - for (int i = 0; i < body.length; i++) { - if (body[i] != null) - body[i].accept(visitor); + for (PythonTree t : body) { + if (t != null) + t.accept(visitor); } } if (decorators != null) { - for (int i = 0; i < decorators.length; i++) { - if (decorators[i] != null) - decorators[i].accept(visitor); + for (PythonTree t : decorators) { + if (t != null) + t.accept(visitor); } } } Modified: branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java 2008-11-17 21:48:50 UTC (rev 5586) +++ branches/astwrite/src/org/python/antlr/ast/GeneratorExp.java 2008-11-17 21:50:26 UTC (rev 5587) @@ -8,57 +8,58 @@ public class GeneratorExp extends exprType { public exprType elt; - public comprehensionType[] generators; + public java.util.List<comprehensionType> generators; private final static String[] fields = new String[] {"elt", "generators"}; public String[] get_fields() { return fields; } - public GeneratorExp(exprType elt, comprehensionType[] generators) { + public GeneratorExp(exprType elt, java.util.List<comprehensionType> + generators) { this.elt = elt; addChild(elt); this.generators = generators; if (generators != null) { - for(int igenerators=0;igenerators<generators.length;igenerators++) { - addChild(generators[igenerators]); + for(PythonTree t : generators) { + addChild(t); } } } - public GeneratorExp(Token token, exprType elt, comprehensionType[] - generators) { + public GeneratorExp(Token token, exprType elt, + java.util.List<comprehensionType> generators) { super(token); this.elt = elt; addChild(elt); this.generators = generators; if (generators != null) { - for(int igenerators=0;igenerators<generators.length;igenerators++) { - addChild(generators[igenerators]); + for(PythonTree t : generators) { + addChild(t); } } } public GeneratorExp(int ttype, Token token, exprType elt, - comprehensionType[] generators) { + java.util.List<comprehensionType> generators) { super(ttype, token); this.elt = elt; addChild(elt); this.generators = generators; if (generators != null) { - for(int igenerators=0;igenerators<generators.length;igenerators++) { - addChild(generators[igenerators]); + for(PythonTree t : generators) { + addChild(t); } } } - public GeneratorExp(PythonTree tree, exprType elt, comprehensionType[] - generators) { + public GeneratorExp(PythonTree tree, exprType elt, + java.util.List<comprehensionType> generators) { super(tree); this.elt = elt; addChild(elt); this.generators = generators; if (generators != null) { - for(int igenerators=0;igenerators<generators.length;igenerators++) { - addChild(generators[igenerators]); + for(PythonTree t : generators) { + addChild(t); } } } @@ -87,9 +88,9 @@ if (elt != null) elt.accept(visitor); if (generators != null) { - for (int i = 0; i < generators.length; i++) { - if (generators[i] != null) - generators[i].accept(visitor); + for (PythonTree t : generators) { + if (t != null) + t.accept(visitor); } } } Modified: branches/astwrite/src/org/python/antlr/ast/Global.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Global.java 2008-11-17 21:48:50 UTC (rev 5586) +++ branches/astwrite/src/org/python/antlr/ast/Global.java 2008-11-17 21:50:26 UTC (rev 5587) @@ -7,26 +7,26 @@ import java.io.IOException; public class Global extends stmtType { - public String[] names; + public java.util.List<String> names; private final static String[] fields = new String[] {"names"}; public String[] get_fields() { return fields; } - public Global(String[] names) { + public Global(java.util.List<String> names) { this.names = names; } - public Global(Token token, String[] names) { + public Global(Token token, java.util.List<String> names) { super(token); this.names = names; } - public Global(int ttype, Token token, String[] names) { + public Global(int ttype, Token token, java.util.List<String> names) { super(ttype, token); this.names = names; } - public Global(PythonTree tree, String[] names) { + public Global(PythonTree tree, java.util.List<String> names) { super(tree); this.names = names; } Modified: branches/astwrite/src/org/python/antlr/ast/If.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/If.java 2008-11-17 21:48:50 UTC (rev 5586) +++ branches/astwrite/src/org/python/antlr/ast/If.java 2008-11-17 21:50:26 UTC (rev 5587) @@ -8,82 +8,84 @@ public class If extends stmtType { public exprType test; - public stmtType[] body; - public stmtType[] orelse; + public java.util.List<stmtType> body; + public java.util.List<stmtType> orelse; private final static String[] fields = new String[] {"test", "body", "orelse"}; public String[] get_fields() { return fields; } - public If(exprType test, stmtType[] body, stmtType[] orelse) { + public If(exprType test, java.util.List<stmtType> body, + java.util.List<stmtType> orelse) { this.test = test; addChild(test); this.body = body; if (body != null) { - for(int ibody=0;ibody<body.length;ibody++) { - addChild(body[ibody]); + for(PythonTree t : body) { + addChild(t); } } this.orelse = orelse; if (orelse != null) { - for(int iorelse=0;iorelse<orelse.length;iorelse++) { - addChild(orelse[iorelse]); + for(PythonTree t : orelse) { + addChild(t); } } } - public If(Token token, exprType test, stmtType[] body, stmtType[] orelse) { + public If(Token token, exprType test, java.util.List<stmtType> body, + java.util.List<stmtType> orelse) { super(token); this.test = test; addChild(test); this.body = body; if (body != null) { - for(int ibody=0;ibody<body.length;ibody++) { - addChild(body[ibody]); + for(PythonTree t : body) { + addChild(t); } } this.orelse = orelse; if (orelse != null) { - for(int iorelse=0;iorelse<orelse.length;iorelse++) { - addChild(orelse[iorelse]); + for(PythonTree t : orelse) { + addChild(t); } } } - public If(int ttype, Token token, exprType test, stmtType[] body, - stmtType[] orelse) { + public If(int ttype, Token token, exprType test, java.util.List<stmtType> + body, java.util.List<stmtType> orelse) { super(ttype, token); this.test = test; addChild(test); this.body = body; if (body != null) { - for(int ibody=0;ibody<body.length;ibody++) { - addChild(body[ibody]); + for(PythonTree t : body) { + addChild(t); } } this.orelse = orelse; if (orelse != null) { - for(int iorelse=0;iorelse<orelse.length;iorelse++) { - addChild(orelse[iorelse]); + for(PythonTree t : orelse) { + addChild(t); } } } - public If(PythonTree tree, exprType test, stmtType[] body, stmtType[] - orelse) { + public If(PythonTree tree, exprType test, java.util.List<stmtType> body, + java.util.List<stmtType> orelse) { super(tree); this.test = test; addChild(test); this.body = body; if (body != null) { - for(int ibody=0;ibody<body.length;ibody++) { - addChild(body[ibody]); + for(PythonTree t : body) { + addChild(t); } } this.orelse = orelse; if (orelse != null) { - for(int iorelse=0;iorelse<orelse.length;iorelse++) { - addChild(orelse[iorelse]); + for(PythonTree t : orelse) { + addChild(t); } } } @@ -115,15 +117,15 @@ if (test != null) test.accept(visitor); if (body != null) { - for (int i = 0; i < body.length; i++) { - if (body[i] != null) - body[i].accept(visitor); + for (PythonTree t : body) { + if (t != null) + t.accept(visitor); } } if (orelse != null) { - for (int i = 0; i < orelse.length; i++) { - if (orelse[i] != null) - orelse[i].accept(visitor); + for (PythonTree t : orelse) { + if (t != null) + t.accept(visitor); } } } Modified: branches/astwrite/src/org/python/antlr/ast/Import.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Import.java 2008-11-17 21:48:50 UTC (rev 5586) +++ branches/astwrite/src/org/python/antlr/ast/Import.java 2008-11-17 21:50:26 UTC (rev 5587) @@ -7,46 +7,46 @@ import java.io.IOException; public class Import extends stmtType { - public aliasType[] names; + public java.util.List<aliasType> names; private final static String[] fields = new String[] {"names"}; public String[] get_fields() { return fields; } - public Import(aliasType[] names) { + public Import(java.util.List<aliasType> names) { this.names = names; if (names != null) { - for(int inames=0;inames<names.length;inames++) { - addChild(names[inames]); + for(PythonTree t : names) { + addChild(t); } } } - public Import(Token token, aliasType[] names) { + public Import(Token token, java.util.List<aliasType> names) { super(token); this.names = names; if (names != null) { - for(int inames=0;inames<names.length;inames++) { - addChild(names[inames]); + for(PythonTree t : names) { + addChild(t); } } } - public Import(int ttype, Token token, aliasType[] names) { + public Import(int ttype, Token token, java.util.List<aliasType> names) { super(ttype, token); this.names = names; if (names != null) { - for(int inames=0;inames<names.length;inames++) { - addChild(names[inames]); + for(PythonTree t : names) { + addChild(t); } } } - public Import(PythonTree tree, aliasType[] names) { + public Import(PythonTree tree, java.util.List<aliasType> names) { super(tree); this.names = names; if (names != null) { - for(int inames=0;inames<names.length;inames++) { - addChild(names[inames]); + for(PythonTree t : names) { + addChild(t); } } } @@ -70,9 +70,9 @@ public void traverse(VisitorIF visitor) throws Exception { if (names != null) { - for (int i = 0; i < names.length; i++) { - if (names[i] != null) - names[i].accept(visitor); + for (PythonTree t : names) { + if (t != null) + t.accept(visitor); } } } Modified: branches/astwrite/src/org/python/antlr/ast/ImportFrom.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/ImportFrom.java 2008-11-17 21:48:50 UTC (rev 5586) +++ branches/astwrite/src/org/python/antlr/ast/ImportFrom.java 2008-11-17 21:50:26 UTC (rev 5587) @@ -8,58 +8,59 @@ public class ImportFrom extends stmtType { public String module; - public aliasType[] names; + public java.util.List<aliasType> names; public int level; private final static String[] fields = new String[] {"module", "names", "level"}; public String[] get_fields() { return fields; } - public ImportFrom(String module, aliasType[] names, int level) { + public ImportFrom(String module, java.util.List<aliasType> names, int + level) { this.module = module; this.names = names; if (names != null) { - for(int inames=0;inames<names.length;inames++) { - addChild(names[inames]); + for(PythonTree t : names) { + addChild(t); } } this.level = level; } - public ImportFrom(Token token, String module, aliasType[] names, int level) - { + public ImportFrom(Token token, String module, java.util.List<aliasType> + names, int level) { super(token); this.module = module; this.names = names; if (names != null) { - for(int inames=0;inames<names.length;inames++) { - addChild(names[inames]); + for(PythonTree t : names) { + addChild(t); } } this.level = level; } - public ImportFrom(int ttype, Token token, String module, aliasType[] names, - int level) { + public ImportFrom(int ttype, Token token, String module, + java.util.List<aliasType> names, int level) { super(ttype, token); this.module = module; this.names = names; if (names != null) { - for(int inames=0;inames<names.length;inames++) { - addChild(names[inames]); + for(PythonTree t : names) { + addChild(t); } } this.level = level; } - public ImportFrom(PythonTree tree, String module, aliasType[] names, int - level) { + public ImportFrom(PythonTree tree, String module, java.util.List<aliasType> + names, int level) { super(tree); this.module = module; this.names = names; if (names != null) { - for(int inames=0;inames<names.length;inames++) { - addChild(names[inames]); + for(PythonTree t : names) { + addChild(t); } } this.level = level; @@ -90,9 +91,9 @@ public void traverse(VisitorIF visitor) throws Exception { if (names != null) { - for (int i = 0; i < names.length; i++) { - if (names[i] != null) - names[i].accept(visitor); + for (PythonTree t : names) { + if (t != null) + t.accept(visitor); } } } Modified: branches/astwrite/src/org/python/antlr/ast/Interactive.java =================================================================== --- branches/astwrite/src/org/python/antlr/ast/Interactive.java 2008-11-17 21:48:50 UTC (rev 5586) +++ branches/astwrite/src/org/python/antlr/ast/Interactive.java 2008-11-17 21:50:26 UTC (rev 5587) @@ -7,46 +7,46 @@ import java.io.IOException; public class Interactive extends modType { - public stmtType[] body; + public java.util.List<stmtType> body; private final static String[] fields = new String[] {"body"}; public String[] get_fields() { return fields; } - public Interactive(stmtType[] body) { + public Interactive(java.util.List<stmtType> body) { this.body = body; if (body != null) { - for(int ibody=0;ibody<body.length;ibody++) { - addChild(body[ibody]); + for(PythonTree t : body) { + addChild(t); } } } - public Interactive(Token token, stmtType[] body) { + public Interactive(Token token, java.util.List<stmtType> body) { super(token); this.body = body; if (body != null) { - for(int ibody=0;ibody<body.length;ibody++) { - addChild(body[ibody]); + for(PythonTree t : body) { + addChild(t); } } } - public Interactive(int ttype, Token token, stmtType[] body) { + public Interactive(int ttype, Token token, java.util.List<stmtType> body) { super(ttype, token); this.body = body; if (body != null) { - for(int ibody=0;ibody<body.length;ibody++) { - addChild(body[ibody]); + for(PythonTree t : body) { + addChild(t); } } } - public Interactive(PythonTree tree, stmtType[] body) { + public Interactive(PythonTree tree, java.util.List<stmtType> body) { super(tree); this.body = body; if (body != null) { - for(int ibody=0;ibody<body.l... [truncated message content] |
From: <fwi...@us...> - 2008-11-17 21:48:55
|
Revision: 5586 http://jython.svn.sourceforge.net/jython/?rev=5586&view=rev Author: fwierzbicki Date: 2008-11-17 21:48:50 +0000 (Mon, 17 Nov 2008) Log Message: ----------- First pass at converting all arrays in ast/* to Lists. Checking in without running asdl_antlr.py for clarity of changes. Modified Paths: -------------- branches/astwrite/ast/asdl_antlr.py branches/astwrite/grammar/Python.g branches/astwrite/src/org/python/antlr/GrammarActions.java branches/astwrite/src/org/python/compiler/ArgListCompiler.java branches/astwrite/src/org/python/compiler/CodeCompiler.java branches/astwrite/src/org/python/compiler/Future.java branches/astwrite/src/org/python/compiler/Module.java branches/astwrite/src/org/python/compiler/ProxyMaker.java branches/astwrite/src/org/python/compiler/ScopesCompiler.java Modified: branches/astwrite/ast/asdl_antlr.py =================================================================== --- branches/astwrite/ast/asdl_antlr.py 2008-11-17 21:20:25 UTC (rev 5585) +++ branches/astwrite/ast/asdl_antlr.py 2008-11-17 21:48:50 UTC (rev 5586) @@ -292,16 +292,16 @@ for f in fields: self.emit("this.%s = %s;" % (f.name, f.name), depth+1) fparg = self.fieldDef(f) - #if field.typedef and field.typedef.simple: + not_simple = True if f.typedef is not None and f.typedef.simple: not_simple = False #For now ignoring String -- will want to revisit - if not_simple and not fparg.startswith("String"): + if not_simple and fparg.find("String") == -1: if f.seq: self.emit("if (%s != null) {" % f.name, depth+1); - self.emit("for(int i%(name)s=0;i%(name)s<%(name)s.length;i%(name)s++) {" % {"name":f.name}, depth+2) - self.emit("addChild(%s[i%s]);" % (f.name, f.name), depth+3) + self.emit("for(PythonTree t : %(name)s) {" % {"name":f.name}, depth+2) + self.emit("addChild(t);", depth+3) self.emit("}", depth+2) self.emit("}", depth+1) elif str(f.type) == "expr": @@ -386,10 +386,10 @@ continue if f.seq: self.emit('if (%s != null) {' % f.name, depth+1) - self.emit('for (int i = 0; i < %s.length; i++) {' % f.name, + self.emit('for (PythonTree t : %s) {' % f.name, depth+2) - self.emit('if (%s[i] != null)' % f.name, depth+3) - self.emit('%s[i].accept(visitor);' % f.name, depth+4) + self.emit('if (t != null)', depth+3) + self.emit('t.accept(visitor);', depth+4) self.emit('}', depth+2) self.emit('}', depth+1) else: @@ -415,8 +415,9 @@ jtype = str(field.type) jtype = self.bltinnames.get(jtype, jtype + 'Type') name = field.name - seq = field.seq and "[]" or "" - return "%(jtype)s%(seq)s %(name)s" % locals() + if field.seq: + return "java.util.List<%(jtype)s> %(name)s" % locals() + return "%(jtype)s %(name)s" % locals() class VisitorVisitor(EmitVisitor): def __init__(self, dir): Modified: branches/astwrite/grammar/Python.g =================================================================== --- branches/astwrite/grammar/Python.g 2008-11-17 21:20:25 UTC (rev 5585) +++ branches/astwrite/grammar/Python.g 2008-11-17 21:48:50 UTC (rev 5586) @@ -277,7 +277,7 @@ $single_input.tree = mtype; } : NEWLINE* EOF { - mtype = new Interactive($single_input.start, new stmtType[0]); + mtype = new Interactive($single_input.start, new ArrayList<stmtType>()); } | simple_stmt NEWLINE* EOF { mtype = new Interactive($single_input.start, actions.castStmts($simple_stmt.stypes)); @@ -424,7 +424,7 @@ parameters returns [argumentsType args] : LPAREN (varargslist {$args = $varargslist.args;} - | { $args = new argumentsType($parameters.start, new exprType[0], null, null, new exprType[0]); + | { $args = new argumentsType($parameters.start, new ArrayList<exprType>(), null, null, new ArrayList<exprType>()); } ) RPAREN @@ -597,7 +597,7 @@ | RIGHTSHIFT t2=printlist2 -> ^(PRINT<Print>[$PRINT, actions.castExpr($t2.elts.get(0)), actions.castExprs($t2.elts, 1), $t2.newline]) | - -> ^(PRINT<Print>[$PRINT, null, new exprType[0\], false]) + -> ^(PRINT<Print>[$PRINT, null, new ArrayList<exprType>(), false]) ) ; @@ -730,10 +730,10 @@ ; //import_as_names: import_as_name (',' import_as_name)* [','] -import_as_names returns [aliasType[\] atypes] +import_as_names returns [List<aliasType> atypes] : n+=import_as_name (COMMA! n+=import_as_name)* { - $atypes = (aliasType[])$n.toArray(new aliasType[$n.size()]); + $atypes = $n; } ; @@ -762,10 +762,10 @@ ; //dotted_as_names: dotted_as_name (',' dotted_as_name)* -dotted_as_names returns [aliasType[\] atypes] +dotted_as_names returns [List<aliasType> atypes] : d+=dotted_as_name (COMMA! d+=dotted_as_name)* { - $atypes = (aliasType[])$d.toArray(new aliasType[$d.size()]); + $atypes = $d; } ; @@ -828,7 +828,7 @@ (e2=elif_clause[$iftest] -> ^(ELIF<If>[$iftest, actions.castExpr($test.tree), actions.castStmts($suite.stypes), actions.makeElse($e2.stypes, $e2.tree)]) | - -> ^(ELIF<If>[$iftest, actions.castExpr($test.tree), actions.castStmts($suite.stypes), new stmtType[0\]]) + -> ^(ELIF<If>[$iftest, actions.castExpr($test.tree), actions.castStmts($suite.stypes), new ArrayList<stmtType>()]) ) ; @@ -1223,14 +1223,14 @@ | testlist_gexp -> testlist_gexp | - -> ^(LPAREN<Tuple>[$LPAREN, new exprType[0\], $expr::ctype]) + -> ^(LPAREN<Tuple>[$LPAREN, new ArrayList<exprType>(), $expr::ctype]) ) RPAREN | LBRACK (listmaker[$LBRACK] -> listmaker | - -> ^(LBRACK<org.python.antlr.ast.List>[$LBRACK, new exprType[0\], $expr::ctype]) + -> ^(LBRACK<org.python.antlr.ast.List>[$LBRACK, new ArrayList<exprType>(), $expr::ctype]) ) RBRACK | LCURLY @@ -1238,7 +1238,7 @@ -> ^(LCURLY<Dict>[$LCURLY, actions.castExprs($dictmaker.keys), actions.castExprs($dictmaker.values)]) | - -> ^(LCURLY<Dict>[$LCURLY, new exprType[0\], new exprType[0\]]) + -> ^(LCURLY<Dict>[$LCURLY, new ArrayList<exprType>(), new ArrayList<exprType>()]) ) RCURLY | lb=BACKQUOTE testlist[expr_contextType.Load] rb=BACKQUOTE @@ -1270,8 +1270,7 @@ (list_for[gens] { Collections.reverse(gens); - comprehensionType[] c = - (comprehensionType[])gens.toArray(new comprehensionType[gens.size()]); + List<comprehensionType> c = gens; etype = new ListComp($listmaker.start, actions.castExpr($t.get(0)), c); } | (options {greedy=true;}:COMMA t+=test[$expr::ctype])* @@ -1301,7 +1300,7 @@ | (gen_for[gens] { Collections.reverse(gens); - comprehensionType[] c = (comprehensionType[])gens.toArray(new comprehensionType[gens.size()]); + List<comprehensionType> c = gens; exprType e = actions.castExpr($t.get(0)); if (e instanceof Context) { ((Context)e).setContext(expr_contextType.Load); @@ -1324,7 +1323,7 @@ { argumentsType a = $varargslist.args; if (a == null) { - a = new argumentsType($LAMBDA, new exprType[0], null, null, new exprType[0]); + a = new argumentsType($LAMBDA, new ArrayList<exprType>(), null, null, new ArrayList<exprType>()); } etype = new Lambda($LAMBDA, a, actions.castExpr($test.tree)); } @@ -1337,7 +1336,7 @@ -> ^(LPAREN<Call>[$begin, actions.castExpr($tree), actions.castExprs($arglist.args), actions.makeKeywords($arglist.keywords), $arglist.starargs, $arglist.kwargs]) | - -> ^(LPAREN<Call>[$begin, actions.castExpr($tree), new exprType[0\], new keywordType[0\], null, null]) + -> ^(LPAREN<Call>[$begin, actions.castExpr($tree), new ArrayList<exprType>(), new ArrayList<keywordType>(), null, null]) ) RPAREN | LBRACK subscriptlist[$begin] RBRACK @@ -1405,7 +1404,7 @@ //not in CPython's Grammar file //Needed as an exprlist that does not produce tuples for del_stmt. -del_list returns [exprType[\] etypes] +del_list returns [List<exprType> etypes] : e+=expr[expr_contextType.Del] (options {k=2;}: COMMA e+=expr[expr_contextType.Del])* (COMMA)? { $etypes = actions.makeDeleteList($e); @@ -1490,7 +1489,10 @@ : t1=test[expr_contextType.Load] ((ASSIGN t2=test[expr_contextType.Load]) { - $kws.add(new exprType[]{actions.castExpr($t1.tree), actions.castExpr($t2.tree)}); + List<exprType> exprs = new ArrayList<exprType>(); + exprs.add(actions.castExpr($t1.tree)); + exprs.add(actions.castExpr($t2.tree)); + $kws.add(exprs); } | gen_for[$gens] { @@ -1499,7 +1501,7 @@ } $genarg = true; Collections.reverse($gens); - comprehensionType[] c = (comprehensionType[])$gens.toArray(new comprehensionType[$gens.size()]); + List<comprehensionType> c = $gens; arguments.add(new GeneratorExp($t1.start, actions.castExpr($t1.tree), c)); } | { @@ -1523,11 +1525,9 @@ list_for [List gens] : FOR exprlist[expr_contextType.Store] IN testlist[expr_contextType.Load] (list_iter[gens])? { - exprType[] e; + List<exprType> e = new ArrayList<exprType>(); if ($list_iter.etype != null) { - e = new exprType[]{$list_iter.etype}; - } else { - e = new exprType[0]; + e.add($list_iter.etype); } gens.add(new comprehensionType($FOR, $exprlist.etype, actions.castExpr($testlist.tree), e)); } @@ -1554,11 +1554,9 @@ gen_for [List gens] : FOR exprlist[expr_contextType.Store] IN or_test[expr_contextType.Load] gen_iter[gens]? { - exprType[] e; + List<exprType> e = new ArrayList<exprType>(); if ($gen_iter.etype != null) { - e = new exprType[]{$gen_iter.etype}; - } else { - e = new exprType[0]; + e.add($gen_iter.etype); } gens.add(new comprehensionType($FOR, $exprlist.etype, actions.castExpr($or_test.tree), e)); } Modified: branches/astwrite/src/org/python/antlr/GrammarActions.java =================================================================== --- branches/astwrite/src/org/python/antlr/GrammarActions.java 2008-11-17 21:20:25 UTC (rev 5585) +++ branches/astwrite/src/org/python/antlr/GrammarActions.java 2008-11-17 21:48:50 UTC (rev 5586) @@ -118,33 +118,36 @@ return lev.size(); } - aliasType[] makeStarAlias(Token t) { - return new aliasType[]{new aliasType(t, "*", null)}; + List<aliasType> makeStarAlias(Token t) { + List<aliasType> result = new ArrayList<aliasType>(); + result.add(new aliasType(t, "*", null)); + return result; } - aliasType[] makeAliases(aliasType[] atypes) { + List<aliasType> makeAliases(List<aliasType> atypes) { if (atypes == null) { - return new aliasType[0]; + return new ArrayList<aliasType>(); } return atypes; } - exprType[] makeBases(exprType etype) { + List<exprType> makeBases(exprType etype) { + List<exprType> result = new ArrayList<exprType>(); if (etype != null) { if (etype instanceof Tuple) { return ((Tuple)etype).elts; } - return new exprType[]{etype}; + result.add(etype); } - return new exprType[0]; + return result; } - String[] makeNames(List names) { + List<String> makeNames(List names) { List<String> s = new ArrayList<String>(); for(int i=0;i<names.size();i++) { s.add(((Token)names.get(i)).getText()); } - return s.toArray(new String[s.size()]); + return s; } void errorGenExpNotSoleArg(PythonTree t) { @@ -162,13 +165,13 @@ } - exprType[] castExprs(List exprs) { + List<exprType> castExprs(List exprs) { return castExprs(exprs, 0); } - exprType[] castExprs(List exprs, int start) { + List<exprType> castExprs(List exprs, int start) { + List<exprType> result = new ArrayList<exprType>(); if (exprs != null) { - List<exprType> result = new ArrayList<exprType>(); for (int i=start; i<exprs.size(); i++) { Object o = exprs.get(i); if (o instanceof exprType) { @@ -177,18 +180,19 @@ result.add((exprType)((PythonParser.test_return)o).tree); } } - return result.toArray(new exprType[result.size()]); } - return new exprType[0]; + return result; } - stmtType[] makeElse(List elseSuite, PythonTree elif) { + List<stmtType> makeElse(List elseSuite, PythonTree elif) { if (elseSuite != null) { return castStmts(elseSuite); } else if (elif == null) { - return new stmtType[0]; + return new ArrayList<stmtType>(); } - return new stmtType[]{(stmtType)elif}; + List <stmtType> s = new ArrayList<stmtType>(); + s.add((stmtType)elif); + return s; } stmtType castStmt(Object o) { @@ -202,19 +206,22 @@ return null; } - stmtType[] castStmts(PythonTree t) { - return new stmtType[]{(stmtType)t}; + List<stmtType> castStmts(PythonTree t) { + stmtType s = (stmtType)t; + List<stmtType> stmts = new ArrayList<stmtType>(); + stmts.add(s); + return stmts; } - stmtType[] castStmts(List stmts) { + List<stmtType> castStmts(List stmts) { if (stmts != null) { List<stmtType> result = new ArrayList<stmtType>(); for (Object o:stmts) { result.add(castStmt(o)); } - return (stmtType[])result.toArray(new stmtType[result.size()]); + return result; } - return new stmtType[0]; + return new ArrayList<stmtType>(); } exprType makeDottedAttr(Token nameToken, List attrs) { @@ -231,8 +238,8 @@ if (test == null) { return errorHandler.errorStmt(new PythonTree(t)); } - stmtType[] o = castStmts(orelse); - stmtType[] b = castStmts(body); + List<stmtType> o = castStmts(orelse); + List<stmtType> b = castStmts(body); return new While(t, test, b, o); } @@ -242,27 +249,28 @@ } cantBeNone(target); - stmtType[] o = castStmts(orelse); - stmtType[] b = castStmts(body); + List<stmtType> o = castStmts(orelse); + List<stmtType> b = castStmts(body); return new For(t, target, iter, b, o); } stmtType makeTryExcept(Token t, List body, List handlers, List orelse, List finBody) { - stmtType[] b = castStmts(body); - excepthandlerType[] e = (excepthandlerType[])handlers.toArray(new excepthandlerType[handlers.size()]); - stmtType[] o = castStmts(orelse); + List<stmtType> b = castStmts(body); + List<excepthandlerType> e = handlers; + List<stmtType> o = castStmts(orelse); stmtType te = new TryExcept(t, b, e, o); if (finBody == null) { return te; } - stmtType[] f = castStmts(finBody); - stmtType[] mainBody = new stmtType[]{te}; + List<stmtType> f = castStmts(finBody); + List<stmtType> mainBody = new ArrayList<stmtType>(); + mainBody.add(te); return new TryFinally(t, mainBody, f); } TryFinally makeTryFinally(Token t, List body, List finBody) { - stmtType[] b = castStmts(body); - stmtType[] f = castStmts(finBody); + List<stmtType> b = castStmts(body); + List<stmtType> f = castStmts(finBody); return new TryFinally(t, b, f); } @@ -275,21 +283,21 @@ if (args != null) { a = args; } else { - a = new argumentsType(t, new exprType[0], null, null, new exprType[0]); + a = new argumentsType(t, new ArrayList<exprType>(), null, null, new ArrayList<exprType>()); } - stmtType[] s = castStmts(funcStatements); - exprType[] d = castExprs(decorators); + List<stmtType> s = castStmts(funcStatements); + List<exprType> d = castExprs(decorators); return new FunctionDef(t, nameToken.getText(), a, s, d); } - exprType[] makeAssignTargets(exprType lhs, List rhs) { - exprType[] e = new exprType[rhs.size()]; + List<exprType> makeAssignTargets(exprType lhs, List rhs) { + List<exprType> e = new ArrayList<exprType>(); checkAssign(lhs); - e[0] = lhs; + e.add(lhs); for(int i=0;i<rhs.size() - 1;i++) { exprType r = castExpr(rhs.get(i)); checkAssign(r); - e[i + 1] = r; + e.add(r); } return e; } @@ -320,8 +328,8 @@ argumentsType makeArgumentsType(Token t, List params, Token snameToken, Token knameToken, List defaults) { - exprType[] p = castExprs(params); - exprType[] d = castExprs(defaults); + List<exprType> p = castExprs(params); + List<exprType> d = castExprs(defaults); String s; String k; if (snameToken == null) { @@ -337,26 +345,25 @@ return new argumentsType(t, p, s, k, d); } - exprType[] extractArgs(List args) { + List<exprType> extractArgs(List args) { return castExprs(args); } - keywordType[] makeKeywords(List args) { + List<keywordType> makeKeywords(List args) { List<keywordType> k = new ArrayList<keywordType>(); if (args != null) { for(int i=0;i<args.size();i++) { - exprType[] e = (exprType[])args.get(i); - checkAssign(e[0]); - if (e[0] instanceof Name) { - Name arg = (Name)e[0]; - k.add(new keywordType(arg, arg.id, e[1])); + List e = (List)args.get(i); + checkAssign(castExpr(e.get(0))); + if (e.get(0) instanceof Name) { + Name arg = (Name)e.get(0); + k.add(new keywordType(arg, arg.id, castExpr(e.get(1)))); } else { - errorHandler.error("keyword must be a name", e[0]); + errorHandler.error("keyword must be a name", (PythonTree)e.get(0)); } } - return k.toArray(new keywordType[k.size()]); } - return new keywordType[0]; + return k; } Object makeFloat(Token t) { @@ -488,7 +495,7 @@ //FROM Walker: modType makeMod(PythonTree t, List stmts) { - stmtType[] s = castStmts(stmts); + List<stmtType> s = castStmts(stmts); return new Module(t, s); } @@ -497,7 +504,7 @@ } modType makeInteractive(PythonTree t, List stmts) { - stmtType[] s = castStmts(stmts); + List<stmtType> s = castStmts(stmts); return new Interactive(t, s); } @@ -506,29 +513,30 @@ return errorHandler.errorStmt(t); } cantBeNone(nameToken); - exprType[] b = castExprs(bases); - stmtType[] s = castStmts(body); - exprType[] d = castExprs(decorators); + List<exprType> b = castExprs(bases); + List<stmtType> s = castStmts(body); + List<exprType> d = castExprs(decorators); return new ClassDef(t, nameToken.getText(), b, s, d); } stmtType makeTryExcept(PythonTree t, List body, List handlers, List orelse, List finBody) { - stmtType[] b = castStmts(body); - excepthandlerType[] e = (excepthandlerType[])handlers.toArray(new excepthandlerType[handlers.size()]); - stmtType[] o = castStmts(orelse); + List<stmtType> b = castStmts(body); + List<excepthandlerType> e = handlers; + List<stmtType> o = castStmts(orelse); stmtType te = new TryExcept(t, b, e, o); if (finBody == null) { return te; } - stmtType[] f = castStmts(finBody); - stmtType[] mainBody = new stmtType[]{te}; + List<stmtType> f = castStmts(finBody); + List<stmtType> mainBody = new ArrayList<stmtType>(); + mainBody.add(te); return new TryFinally(t, mainBody, f); } TryFinally makeTryFinally(PythonTree t, List body, List finBody) { - stmtType[] b = castStmts(body); - stmtType[] f = castStmts(finBody); + List<stmtType> b = castStmts(body); + List<stmtType> f = castStmts(finBody); return new TryFinally(t, b, f); } @@ -536,8 +544,8 @@ if (test == null) { return errorHandler.errorStmt(t); } - stmtType[] o = castStmts(orelse); - stmtType[] b = castStmts(body); + List<stmtType> o = castStmts(orelse); + List<stmtType> b = castStmts(body); return new If(t, test, b, o); } @@ -545,8 +553,8 @@ if (test == null) { return errorHandler.errorStmt(t); } - stmtType[] o = castStmts(orelse); - stmtType[] b = castStmts(body); + List<stmtType> o = castStmts(orelse); + List<stmtType> b = castStmts(body); return new While(t, test, b, o); } @@ -555,8 +563,8 @@ return errorHandler.errorStmt(t); } cantBeNone(target); - stmtType[] o = castStmts(orelse); - stmtType[] b = castStmts(body); + List<stmtType> o = castStmts(orelse); + List<stmtType> b = castStmts(body); return new For(t, target, iter, b, o); } @@ -568,8 +576,8 @@ if (func == null) { return errorHandler.errorExpr(new PythonTree(t)); } - keywordType[] k = makeKeywords(keywords); - exprType[] a = castExprs(args); + List<keywordType> k = makeKeywords(keywords); + List<exprType> a = castExprs(args); return new Call(t, func, a, k, starargs, kwargs); } @@ -645,27 +653,27 @@ errorHandler.error("can't assign to conditional expression", e); } else if (e instanceof Tuple) { //XXX: performance problem? Any way to do this better? - exprType[] elts = ((Tuple)e).elts; - if (elts.length == 0) { + List<exprType> elts = ((Tuple)e).elts; + if (elts.size() == 0) { errorHandler.error("can't assign to ()", e); } - for (int i=0;i<elts.length;i++) { - checkAssign(elts[i]); + for (int i=0;i<elts.size();i++) { + checkAssign(elts.get(i)); } } else if (e instanceof org.python.antlr.ast.List) { //XXX: performance problem? Any way to do this better? - exprType[] elts = ((org.python.antlr.ast.List)e).elts; - for (int i=0;i<elts.length;i++) { - checkAssign(elts[i]); + List<exprType> elts = ((org.python.antlr.ast.List)e).elts; + for (int i=0;i<elts.size();i++) { + checkAssign(elts.get(i)); } } } - exprType[] makeDeleteList(List e) { - exprType[] exprs = castExprs(e); - for(int i=0;i<exprs.length;i++) { - if (exprs[i] instanceof Call) { - errorHandler.error("can't delete function call", exprs[i]); + List<exprType> makeDeleteList(List e) { + List<exprType> exprs = castExprs(e); + for(exprType expr : exprs) { + if (expr instanceof Call) { + errorHandler.error("can't delete function call", expr); } } return exprs; @@ -706,15 +714,14 @@ } } - cmpopType[] makeCmpOps(List cmps) { + List<cmpopType> makeCmpOps(List cmps) { + List<cmpopType> result = new ArrayList<cmpopType>(); if (cmps != null) { - List<cmpopType> result = new ArrayList<cmpopType>(); for (Object o: cmps) { result.add((cmpopType)o); } - return result.toArray(new cmpopType[result.size()]); } - return new cmpopType[0]; + return result; } BoolOp makeBoolOp(PythonTree left, boolopType op, List right) { @@ -743,15 +750,14 @@ return current; } - sliceType[] castSlices(List slices) { + List<sliceType> castSlices(List slices) { + List<sliceType> result = new ArrayList<sliceType>(); if (slices != null) { - List<sliceType> result = new ArrayList<sliceType>(); for (Object o:slices) { result.add(castSlice(o)); } - return (sliceType[])result.toArray(new sliceType[result.size()]); } - return new sliceType[0]; + return result; } sliceType castSlice(Object o) { @@ -770,7 +776,7 @@ boolean extslice = false; if (isTuple) { - sliceType[] st; + List<sliceType> st; List etypes = new ArrayList(); for (Object o : sltypes) { if (o instanceof Index) { @@ -782,7 +788,7 @@ } } if (!extslice) { - exprType[] es = (exprType[])etypes.toArray(new exprType[etypes.size()]); + List<exprType> es = etypes; exprType t = new Tuple(begin, es, expr_contextType.Load); s = new Index(begin, t); } @@ -792,7 +798,7 @@ extslice = true; } if (extslice) { - sliceType[] st = castSlices(sltypes);//.toArray(new sliceType[sltypes.size()]); + List<sliceType> st = castSlices(sltypes);//.toArray(new sliceType[sltypes.size()]); s = new ExtSlice(begin, st); } return s; Modified: branches/astwrite/src/org/python/compiler/ArgListCompiler.java =================================================================== --- branches/astwrite/src/org/python/compiler/ArgListCompiler.java 2008-11-17 21:20:25 UTC (rev 5585) +++ branches/astwrite/src/org/python/compiler/ArgListCompiler.java 2008-11-17 21:48:50 UTC (rev 5586) @@ -2,7 +2,8 @@ package org.python.compiler; -import java.util.Vector; +import java.util.ArrayList; +import java.util.List; import org.python.antlr.ParseException; import org.python.antlr.Visitor; @@ -18,64 +19,66 @@ public class ArgListCompiler extends Visitor { public boolean arglist, keywordlist; - public exprType[] defaults; - public Vector names; - public Vector fpnames; - public Vector init_code; + public List<exprType> defaults; + public List<String> names; + public List<String> fpnames; + public List<stmtType> init_code; public ArgListCompiler() { arglist = keywordlist = false; defaults = null; - names = new Vector(); - fpnames = new Vector(); - init_code = new Vector(); + names = new ArrayList<String>(); + fpnames = new ArrayList<String>(); + init_code = new ArrayList<stmtType>(); } public void reset() { arglist = keywordlist = false; defaults = null; - names.removeAllElements(); - init_code.removeAllElements(); + names.clear(); + init_code.clear(); } public void appendInitCode(Suite node) { - int n = node.body.length; - stmtType[] newtree = new stmtType[init_code.size() + n]; - init_code.copyInto(newtree); - System.arraycopy(node.body, 0, newtree, init_code.size(), n); + int n = node.body.size(); + List<stmtType> newtree = new ArrayList<stmtType>(); + newtree.addAll(init_code); + newtree.addAll(node.body); node.body = newtree; } - public exprType[] getDefaults() { + public List<exprType> getDefaults() { return defaults; } public void visitArgs(argumentsType args) throws Exception { - for (int i = 0; i < args.args.length; i++) { - String name = (String) visit(args.args[i]); - names.addElement(name); - if (args.args[i] instanceof Tuple) { - Assign ass = new Assign(args.args[i], - new exprType[] { args.args[i] }, - new Name(args.args[i], name, expr_contextType.Load)); - init_code.addElement(ass); + for (int i = 0; i < args.args.size(); i++) { + String name = (String) visit(args.args.get(i)); + names.add(name); + if (args.args.get(i) instanceof Tuple) { + List<exprType> targets = new ArrayList<exprType>(); + targets.add(args.args.get(i)); + Assign ass = new Assign(args.args.get(i), + targets, + new Name(args.args.get(i), name, expr_contextType.Load)); + init_code.add(ass); } } if (args.vararg != null) { arglist = true; - names.addElement(args.vararg); + names.add(args.vararg); } if (args.kwarg != null) { keywordlist = true; - names.addElement(args.kwarg); + names.add(args.kwarg); } defaults = args.defaults; - for (int i = 0; i < defaults.length; i++) { - if (defaults[i] == null) + for (int i = 0; i < defaults.size(); i++) { + if (defaults.get(i) == null) throw new ParseException( "non-default argument follows default argument", - args.args[args.args.length - defaults.length + i]); + args.args.get(args.args.size() - defaults.size() + i)); } } @@ -90,19 +93,19 @@ throw new ParseException("duplicate argument name found: " + node.id, node); } - fpnames.addElement(node.id); + fpnames.add(node.id); return node.id; } @Override public Object visitTuple(Tuple node) throws Exception { StringBuffer name = new StringBuffer("("); - int n = node.elts.length; + int n = node.elts.size(); for (int i = 0; i < n-1; i++) { - name.append(visit(node.elts[i])); + name.append(visit(node.elts.get(i))); name.append(", "); } - name.append(visit(node.elts[n - 1])); + name.append(visit(node.elts.get(n - 1))); name.append(")"); return name.toString(); } Modified: branches/astwrite/src/org/python/compiler/CodeCompiler.java =================================================================== --- branches/astwrite/src/org/python/compiler/CodeCompiler.java 2008-11-17 21:20:25 UTC (rev 5585) +++ branches/astwrite/src/org/python/compiler/CodeCompiler.java 2008-11-17 21:48:50 UTC (rev 5586) @@ -4,6 +4,8 @@ import java.io.IOException; import java.util.Hashtable; +import java.util.ArrayList; +import java.util.Collection; import java.util.Map; import java.util.Stack; import java.util.Vector; @@ -60,6 +62,7 @@ import org.python.antlr.ast.While; import org.python.antlr.ast.With; import org.python.antlr.ast.Yield; +import org.python.antlr.ast.aliasType; import org.python.antlr.ast.cmpopType; import org.python.antlr.ast.comprehensionType; import org.python.antlr.ast.excepthandlerType; @@ -294,13 +297,13 @@ public Object visitModule(org.python.antlr.ast.Module suite) throws Exception { - if (suite.body.length > 0 && - suite.body[0] instanceof Expr && - ((Expr)suite.body[0]).value instanceof Str) + if (suite.body.size() > 0 && + suite.body.get(0) instanceof Expr && + ((Expr)suite.body.get(0)).value instanceof Str) { loadFrame(); code.ldc("__doc__"); - visit(((Expr) suite.body[0]).value); + visit(((Expr) suite.body.get(0)).value); code.invokevirtual("org/python/core/PyFrame", "setglobal", "(" +$str + $pyObj + ")V"); } if (module.setFile) { @@ -322,13 +325,13 @@ return visitReturn(new Return(node, node.body), true); } - public int makeArray(PythonTree[] nodes) throws Exception { + public int makeArray(java.util.List<? extends PythonTree> nodes) throws Exception { int n; if (nodes == null) n = 0; else - n = nodes.length; + n = nodes.size(); int array = code.getLocal("[Lorg/python/core/PyObject;"); if (n == 0) { @@ -340,7 +343,7 @@ code.astore(array); for(int i=0; i<n; i++) { - visit(nodes[i]); + visit(nodes.get(i)); code.aload(array); code.swap(); code.iconst(i); @@ -351,11 +354,11 @@ return array; } - public void getDocString(stmtType[] suite) throws Exception { - if (suite.length > 0 && suite[0] instanceof Expr && - ((Expr) suite[0]).value instanceof Str) + public void getDocString(java.util.List<stmtType> suite) throws Exception { + if (suite.size() > 0 && suite.get(0) instanceof Expr && + ((Expr) suite.get(0)).value instanceof Str) { - visit(((Expr) suite[0]).value); + visit(((Expr) suite.get(0)).value); } else { code.aconst_null(); } @@ -426,11 +429,13 @@ return null; } - private void doDecorators(stmtType node, exprType[] decs, String name) throws Exception { - if (decs.length > 0) { + private void doDecorators(stmtType node, java.util.List<exprType> decs, String name) throws Exception { + if (decs.size() > 0) { exprType currentExpr = new Name(node, name, expr_contextType.Load); - for (int i=decs.length - 1;i > -1;i--) { - currentExpr = new Call(node, decs[i], new exprType[]{currentExpr}, new keywordType[0], null, null); + for (int i=decs.size() - 1;i > -1;i--) { + java.util.List args = new ArrayList(); + args.add(currentExpr); + currentExpr = new Call(node, decs.get(i), args, new ArrayList<keywordType>(), null, null); } visit(currentExpr); set(new Name(node, name, expr_contextType.Store)); @@ -454,8 +459,8 @@ public Object visitAssign(Assign node) throws Exception { setline(node); visit(node.value); - if (node.targets.length == 1) { - set(node.targets[0]); + if (node.targets.size() == 1) { + set(node.targets.get(0)); } else { int tmp = storeTop(); for (exprType target : node.targets) { @@ -475,7 +480,7 @@ visit(node.dest); tmp = storeTop(); } - if (node.values == null || node.values.length == 0) { + if (node.values == null || node.values.size() == 0) { if (node.dest != null) { code.aload(tmp); code.invokestatic("org/python/core/Py", "printlnv", "(" + $pyObj + ")V"); @@ -483,18 +488,18 @@ code.invokestatic("org/python/core/Py", "println", "()V"); } } else { - for (int i = 0; i < node.values.length; i++) { + for (int i = 0; i < node.values.size(); i++) { if (node.dest != null) { code.aload(tmp); - visit(node.values[i]); - if (node.nl && i == node.values.length - 1) { + visit(node.values.get(i)); + if (node.nl && i == node.values.size() - 1) { code.invokestatic("org/python/core/Py", "println", "(" + $pyObj + $pyObj + ")V"); } else { code.invokestatic("org/python/core/Py", "printComma", "(" + $pyObj + $pyObj + ")V"); } } else { - visit(node.values[i]); - if (node.nl && i == node.values.length - 1) { + visit(node.values.get(i)); + if (node.nl && i == node.values.size() - 1) { code.invokestatic("org/python/core/Py", "println", "(" + $pyObj + ")V"); } else { code.invokestatic("org/python/core/Py", "printComma", "(" + $pyObj + ")V"); @@ -786,16 +791,16 @@ @Override public Object visitImport(Import node) throws Exception { setline(node); - for (int i = 0; i < node.names.length; i++) { + for (aliasType alias : node.names) { String asname = null; - if (node.names[i].asname != null) { - String name = node.names[i].name; - asname = node.names[i].asname; + if (alias.asname != null) { + String name = alias.name; + asname = alias.asname; code.ldc(name); loadFrame(); code.invokestatic("org/python/core/imp", "importOneAs", "(" + $str + $pyFrame + ")" + $pyObj); } else { - String name = node.names[i].name; + String name = alias.name; asname = name; if (asname.indexOf('.') > 0) asname = asname.substring(0, asname.indexOf('.')); @@ -803,7 +808,7 @@ loadFrame(); code.invokestatic("org/python/core/imp", "importOne", "(" + $str + $pyFrame + ")" + $pyObj); } - set(new Name(node.names[i], asname, expr_contextType.Store)); + set(new Name(alias, asname, expr_contextType.Store)); } return null; } @@ -814,8 +819,10 @@ Future.checkFromFuture(node); // future stmt support setline(node); code.ldc(node.module); - //Note: parser does not allow node.names.length == 0 - if (node.names.length == 1 && node.names[0].name.equals("*")) { + java.util.List<aliasType> names = node.names; + if (names == null || names.size() == 0) { + throw new ParseException("Internel parser error", node); + } else if (names.size() == 1 && names.get(0).name.equals("*")) { if (node.level > 0) { throw new ParseException("'import *' not allowed with 'from .'", node); } @@ -839,15 +846,15 @@ loadFrame(); code.invokestatic("org/python/core/imp", "importAll", "(" + $str + $pyFrame + ")V"); } else { - String[] fromNames = new String[node.names.length]; - String[] asnames = new String[node.names.length]; - for (int i = 0; i < node.names.length; i++) { - fromNames[i] = node.names[i].name; - asnames[i] = node.names[i].asname; - if (asnames[i] == null) - asnames[i] = fromNames[i]; + java.util.List<String> fromNames = new ArrayList<String>();//[names.size()]; + java.util.List<String> asnames = new ArrayList<String>();//[names.size()]; + for (int i = 0; i < names.size(); i++) { + fromNames.add(names.get(i).name); + asnames.add(names.get(i).asname); + if (asnames.get(i) == null) + asnames.set(i, fromNames.get(i)); } - int strArray = makeStrings(code, fromNames, fromNames.length); + int strArray = makeStrings(code, fromNames); code.aload(strArray); code.freeLocal(strArray); @@ -864,11 +871,11 @@ } code.invokestatic("org/python/core/imp", "importFrom", "(" + $str + $strArr + $pyFrame + "I" + ")" + $pyObjArr); int tmp = storeTop(); - for (int i = 0; i < node.names.length; i++) { + for (int i = 0; i < names.size(); i++) { code.aload(tmp); code.iconst(i); code.aaload(); - set(new Name(node.names[i], asnames[i], expr_contextType.Store)); + set(new Name(names.get(i), asnames.get(i), expr_contextType.Store)); } code.freeLocal(tmp); } @@ -1122,8 +1129,8 @@ TryExcept node, int index) throws Exception { - for (int i = 0; i < node.handlers.length; i++) { - excepthandlerType handler = node.handlers[i]; + for (int i = 0; i < node.handlers.size(); i++) { + excepthandlerType handler = node.handlers.get(i); //setline(name); Label end_of_self = new Label(); @@ -1135,7 +1142,7 @@ code.invokestatic("org/python/core/Py", "matchException", "(" + $pyExc + $pyObj + ")Z"); code.ifeq(end_of_self); } else { - if (i != node.handlers.length-1) { + if (i != node.handlers.size()-1) { throw new ParseException( "default 'except:' must be last", handler); } @@ -1312,10 +1319,9 @@ return suite(node.body); } - public Object suite(stmtType[] stmts) throws Exception { - int n = stmts.length; - for(int i = 0; i < n; i++) { - Object exit = visit(stmts[i]); + public Object suite(java.util.List<stmtType> stmts) throws Exception { + for(stmtType s: stmts) { + Object exit = visit(s); if (exit != null) return Exit; } @@ -1325,8 +1331,8 @@ @Override public Object visitBoolOp(BoolOp node) throws Exception { Label end = new Label(); - visit(node.values[0]); - for (int i = 1; i < node.values.length; i++) { + visit(node.values.get(0)); + for (int i = 1; i < node.values.size(); i++) { code.dup(); code.invokevirtual("org/python/core/PyObject", "__nonzero__", "()Z"); switch (node.op) { @@ -1338,7 +1344,7 @@ break; } code.pop(); - visit(node.values[i]); + visit(node.values.get(i)); } code.label(end); return null; @@ -1354,24 +1360,24 @@ visit(node.left); code.astore(last); - int n = node.ops.length; + int n = node.ops.size(); for(int i = 0; i < n - 1; i++) { - visit(node.comparators[i]); + visit(node.comparators.get(i)); code.aload(last); code.swap(); code.dup(); code.astore(last); - visitCmpop(node.ops[i]); + visitCmpop(node.ops.get(i)); code.dup(); code.astore(result); code.invokevirtual("org/python/core/PyObject", "__nonzero__", "()Z"); code.ifeq(end); } - visit(node.comparators[n-1]); + visit(node.comparators.get(n-1)); code.aload(last); code.swap(); - visitCmpop(node.ops[n-1]); + visitCmpop(node.ops.get(n-1)); if (n > 1) { code.astore(result); @@ -1488,23 +1494,32 @@ } - public static int makeStrings(Code c, String[] names, int n) + public static int makeStrings(Code c, Collection<String> names) throws IOException { - c.iconst(n); + int n = 0; + if (names != null) { + c.iconst(names.size()); + } else { + c.iconst_0(); + } c.anewarray("java/lang/String"); int strings = c.getLocal("[Ljava/lang/String;"); c.astore(strings); - for (int i=0; i<n; i++) { - c.aload(strings); - c.iconst(i); - c.ldc(names[i]); - c.aastore(); + if (names != null) { + int i = 0; + for (String name : names) { + c.aload(strings); + c.iconst(i); + c.ldc(name); + c.aastore(); + i++; + } } return strings; } - public Object invokeNoKeywords(Attribute node, PythonTree[] values) + public Object invokeNoKeywords(Attribute node, java.util.List<exprType> values) throws Exception { String name = getName(node.attr); @@ -1512,34 +1527,34 @@ code.ldc(name); code.invokevirtual("org/python/core/PyObject", "__getattr__", "(" + $str + ")" + $pyObj); - switch (values.length) { + switch (values.size()) { case 0: stackConsume(); // target code.invokevirtual("org/python/core/PyObject", "__call__", "()" + $pyObj); break; case 1: - visit(values[0]); + visit(values.get(0)); stackConsume(); // target code.invokevirtual("org/python/core/PyObject", "__call__", "(" + $pyObj + ")" + $pyObj); break; case 2: - visit(values[0]); stackProduce(); - visit(values[1]); + visit(values.get(0)); stackProduce(); + visit(values.get(1)); stackConsume(2); // target + arguments code.invokevirtual("org/python/core/PyObject", "__call__", "(" + $pyObj + $pyObj + ")" + $pyObj); break; case 3: - visit(values[0]); stackProduce(); - visit(values[1]); stackProduce(); - visit(values[2]); + visit(values.get(0)); stackProduce(); + visit(values.get(1)); stackProduce(); + visit(values.get(2)); stackConsume(3); // target + arguments code.invokevirtual("org/python/core/PyObject", "__call__", "(" + $pyObj + $pyObj + $pyObj + ")" + $pyObj); break; case 4: - visit(values[0]); stackProduce(); - visit(values[1]); stackProduce(); - visit(values[2]); stackProduce(); - visit(values[3]); + visit(values.get(0)); stackProduce(); + visit(values.get(1)); stackProduce(); + visit(values.get(2)); stackProduce(); + visit(values.get(3)); stackConsume(4); // target + arguments code.invokevirtual("org/python/core/PyObject", "__call__", "(" + $pyObj + $pyObj + $pyObj + $pyObj + ")" + $pyObj); break; @@ -1557,17 +1572,17 @@ @Override public Object visitCall(Call node) throws Exception { - String[] keys = new String[node.keywords.length]; - exprType[] values = new exprType[node.args.length + keys.length]; - for (int i = 0; i < node.args.length; i++) { - values[i] = node.args[i]; + java.util.List<String> keys = new ArrayList<String>();//[node.keywords.size()]; + java.util.List<exprType> values = new ArrayList<exprType>();//[node.args.size() + keys.size()]; + for (int i = 0; i < node.args.size(); i++) { + values.add(node.args.get(i)); } - for (int i = 0; i < node.keywords.length; i++) { - keys[i] = node.keywords[i].arg; - values[node.args.length + i] = node.keywords[i].value; + for (int i = 0; i < node.keywords.size(); i++) { + keys.add(node.keywords.get(i).arg); + values.add(node.keywords.get(i).value); } - if ((node.keywords == null || node.keywords.length == 0)&& node.starargs == null && + if ((node.keywords == null || node.keywords.size() == 0)&& node.starargs == null && node.kwargs == null && node.func instanceof Attribute) { return invokeNoKeywords((Attribute) node.func, values); @@ -1577,7 +1592,7 @@ if (node.starargs != null || node.kwargs != null) { int argArray = makeArray(values); - int strArray = makeStrings(code, keys, keys.length); + int strArray = makeStrings(code, keys); if (node.starargs == null) code.aconst_null(); else @@ -1599,9 +1614,9 @@ stackConsume(3); // target + starargs + kwargs code.invokevirtual("org/python/core/PyObject", "_callextra", "(" + $pyObjArr + $strArr + $pyObj + $pyObj + ")" + $pyObj); - } else if (keys.length > 0) { + } else if (keys.size() > 0) { int argArray = makeArray(values); - int strArray = makeStrings(code, keys, keys.length); + int strArray = makeStrings(code, keys); code.aload(argArray); code.aload(strArray); code.freeLocal(argArray); @@ -1609,34 +1624,34 @@ stackConsume(); // target code.invokevirtual("org/python/core/PyObject", "__call__", "(" + $pyObjArr + $strArr + ")" + $pyObj); } else { - switch (values.length) { + switch (values.size()) { case 0: stackConsume(); // target code.invokevirtual("org/python/core/PyObject", "__call__", "()" + $pyObj); break; case 1: - visit(values[0]); + visit(values.get(0)); stackConsume(); // target code.invokevirtual("org/python/core/PyObject", "__call__", "(" + $pyObj + ")" + $pyObj); break; case 2: - visit(values[0]); stackProduce(); - visit(values[1]); + visit(values.get(0)); stackProduce(); + visit(values.get(1)); stackConsume(2); // target + arguments code.invokevirtual("org/python/core/PyObject", "__call__", "(" + $pyObj + $pyObj + ")" + $pyObj); break; case 3: - visit(values[0]); stackProduce(); - visit(values[1]); stackProduce(); - visit(values[2]); + visit(values.get(0)); stackProduce(); + visit(values.get(1)); stackProduce(); + visit(values.get(2)); stackConsume(3); // target + arguments code.invokevirtual("org/python/core/PyObject", "__call__", "(" + $pyObj + $pyObj + $pyObj + ")" + $pyObj); break; case 4: - visit(values[0]); stackProduce(); - visit(values[1]); stackProduce(); - visit(values[2]); stackProduce(); - visit(values[3]); + visit(values.get(0)); stackProduce(); + visit(values.get(1)); stackProduce(); + visit(values.get(2)); stackProduce(); + visit(values.get(3)); stackConsume(4); // target + arguments code.invokevirtual("org/python/core/PyObject", "__call__", "(" + $pyObj + $pyObj + $pyObj + $pyObj + ")" + $pyObj); break; @@ -1789,28 +1804,28 @@ return null; } - public Object seqSet(exprType[] nodes) throws Exception { + public Object seqSet(java.util.List<exprType> nodes) throws Exception { code.aload(temporary); - code.iconst(nodes.length); + code.iconst(nodes.size()); code.invokestatic("org/python/core/Py", "unpackSequence", "(" + $pyObj + "I)" + $pyObjArr); int tmp = code.getLocal("[org/python/core/PyObject"); code.astore(tmp); - for (int i = 0; i < nodes.length; i++) { + for (int i = 0; i < nodes.size(); i++) { code.aload(tmp); code.iconst(i); code.aaload(); - set(nodes[i]); + set(nodes.get(i)); } code.freeLocal(tmp); return null; } - public Object seqDel(exprType[] nodes) throws Exception { - for (int i = 0; i < nodes.length; i++) { - visit(nodes[i]); + public Object seqDel(java.util.List<exprType> nodes) throws Exception { + for (exprType e: nodes) { + visit(e); } return null; } @@ -1866,29 +1881,37 @@ set(new Name(node, tmp_append, expr_contextType.Store)); + java.util.List<exprType> args = new ArrayList<exprType>(); + args.add(node.elt); stmtType n = new Expr(node, new Call(node, new Name(node, tmp_append, expr_contextType.Load), - new exprType[] { node.elt }, - new keywordType[0], null, null)); + args, + new ArrayList<keywordType>(), null, null)); - for (int i = node.generators.length - 1; i >= 0; i--) { - comprehensionType lc = node.generators[i]; - for (int j = lc.ifs.length - 1; j >= 0; j--) { - n = new If(lc.ifs[j], lc.ifs[j], new stmtType[] { n }, new stmtType[0]); + for (int i = node.generators.size() - 1; i >= 0; i--) { + comprehensionType lc = node.generators.get(i); + for (int j = lc.ifs.size() - 1; j >= 0; j--) { + java.util.List<stmtType> body = new ArrayList<stmtType>(); + body.add(n); + n = new If(lc.ifs.get(j), lc.ifs.get(j), body, new ArrayList<stmtType>()); } - n = new For(lc, lc.target, lc.iter, new stmtType[] { n }, new stmtType[0]); + java.util.List<stmtType> body = new ArrayList<stmtType>(); + body.add(n); + n = new For(lc, lc.target, lc.iter, body, new ArrayList<stmtType>()); } visit(n); - visit(new Delete(n, new exprType[] { new Name(n, tmp_append, expr_contextType.Del) })); + java.util.List<exprType> targets = new ArrayList<exprType>(); + targets.add(new Name(n, tmp_append, expr_contextType.Del)); + visit(new Delete(n, targets)); return null; } @Override public Object visitDict(Dict node) throws Exception { - PythonTree[] elts = new PythonTree[node.keys.length * 2]; - for (int i = 0; i < node.keys.length; i++) { - elts[i * 2] = node.keys[i]; - elts[i * 2 + 1] = node.values[i]; + java.util.List<PythonTree> elts = new ArrayList<PythonTree>(); + for (int i = 0; i < node.keys.size(); i++) { + elts.add(node.keys.get(i)); + elts.add(node.values.get(i)); } int content = makeArray(elts); @@ -1912,8 +1935,9 @@ String name = "<lambda>"; //Add a return node onto the outside of suite; - modType retSuite = new Suite(node, new stmtType[] { - new Return(node, node.body) }); + java.util.List<stmtType> bod = new ArrayList<stmtType>(); + bod.add(new Return(node, node.body)); + modType retSuite = new Suite(node, bod); setline(node); @@ -2172,7 +2196,7 @@ ScopeInfo scope = module.getScopeInfo(node); - int emptyArray = makeArray(new exprType[0]); + int emptyArray = makeArray(new ArrayList<exprType>()); code.aload(emptyArray); code.freeLocal(emptyArray); @@ -2182,20 +2206,26 @@ stmtType n = new Expr(node, new Yield(node, node.elt)); exprType iter = null; - for (int i = node.generators.length - 1; i >= 0; i--) { - comprehensionType comp = node.generators[i]; - for (int j = comp.ifs.length - 1; j >= 0; j--) { - n = new If(comp.ifs[j], comp.ifs[j], new stmtType[] { n }, new stmtType[0]); + for (int i = node.generators.size() - 1; i >= 0; i--) { + comprehensionType comp = node.generators.get(i); + for (int j = comp.ifs.size() - 1; j >= 0; j--) { + java.util.List<stmtType> bod = new ArrayList<stmtType>(); + bod.add(n); + n = new If(comp.ifs.get(j), comp.ifs.get(j), bod, new ArrayList<stmtType>()); } + java.util.List<stmtType> bod = new ArrayList<stmtType>(); + bod.add(n); if (i != 0) { - n = new For(comp, comp.target, comp.iter, new stmtType[] { n }, new stmtType[0]); + n = new For(comp, comp.target, comp.iter, bod, new ArrayList<stmtType>()); } else { - n = new For(comp, comp.target, new Name(node, bound_exp, expr_contextType.Load), new stmtType[] { n }, new stmtType[0]); + n = new For(comp, comp.target, new Name(node, bound_exp, expr_contextType.Load), bod, new ArrayList<stmtType>()); iter = comp.iter; } } - module.PyCode(new Suite(node, new stmtType[]{n}), tmp_append, true, + java.util.List<stmtType> bod = new ArrayList<stmtType>(); + bod.add(n); + module.PyCode(new Suite(node, bod), tmp_append, true, className, false, false, node.getLine(), scope, cflags).get(code); @@ -2214,7 +2244,9 @@ code.invokevirtual("org/python/core/PyObject", "__iter__", "()Lorg/python/core/PyObject;"); code.invokevirtual("org/python/core/PyObject", "__call__", "(" + $pyObj + ")" + $pyObj); - visit(new Delete(n, new exprType[] { new Name(n, tmp_append, expr_contextType.Del) })); + java.util.List<exprType> targets = new ArrayList<exprType>(); + targets.add(new Name(n, tmp_append, expr_contextType.Del)); + visit(new Delete(n, targets)); return null; } Modified: branches/astwrite/src/org/python/compiler/Future.java =================================================================== --- branches/astwrite/src/org/python/compiler/Future.java 2008-11-17 21:20:25 UTC (rev 5585) +++ branches/astwrite/src/org/python/compiler/Future.java 2008-11-17 21:48:50 UTC (rev 5586) @@ -2,10 +2,17 @@ package org.python.compiler; -import org.python.antlr.*; -import org.python.antlr.ast.*; +import org.python.antlr.ParseException; +import org.python.antlr.ast.ImportFrom; +import org.python.antlr.ast.Expr; +import org.python.antlr.ast.Interactive; import org.python.antlr.ast.Module; +import org.python.antlr.ast.Str; +import org.python.antlr.ast.modType; +import org.python.antlr.ast.stmtType; +import java.util.List; + public class Future { private boolean division = false; @@ -17,13 +24,13 @@ private boolean check(ImportFrom cand) throws Exception { if (!cand.module.equals(FUTURE)) return false; - int n = cand.names.length; + int n = cand.names.size(); if (n == 0) { throw new ParseException( "future statement does not support import *",cand); } for (int i = 0; i < n; i++) { - String feature = cand.names[i].name; + String feature = cand.names.get(i).name; // *known* features if (feature.equals("nested_scopes")) { continue; @@ -63,11 +70,11 @@ division = cflags.division; } int beg = 0; - stmtType[] suite = null; + List<stmtType> suite = null; if (node instanceof Module) { suite = ((Module) node).body; - if (suite.length > 0 && suite[0] instanceof Expr && - ((Expr) suite[0]).value instanceof Str) { + if (suite.size() > 0 && suite.get(0) instanceof Expr && + ((Expr) suite.get(0)).value instanceof Str) { beg++; } } else if (node instanceof Interactive) { @@ -76,8 +83,8 @@ return; } - for (int i = beg; i < suite.length; i++) { - ... [truncated message content] |
From: <fwi...@us...> - 2008-11-17 21:20:26
|
Revision: 5585 http://jython.svn.sourceforge.net/jython/?rev=5585&view=rev Author: fwierzbicki Date: 2008-11-17 21:20:25 +0000 (Mon, 17 Nov 2008) Log Message: ----------- branch to create writable ast. Added Paths: ----------- branches/astwrite/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-11-17 20:06:56
|
Revision: 5584 http://jython.svn.sourceforge.net/jython/?rev=5584&view=rev Author: pjenvey Date: 2008-11-17 20:06:51 +0000 (Mon, 17 Nov 2008) Log Message: ----------- relax the test ensuring SO_{RCV,SND}BUF matches the *exact* value we set it to after a connection was established. only for the BSDs, but we may not want to assume this anywhere Modified Paths: -------------- trunk/jython/Lib/test/test_socket.py Modified: trunk/jython/Lib/test/test_socket.py =================================================================== --- trunk/jython/Lib/test/test_socket.py 2008-11-17 20:05:55 UTC (rev 5583) +++ trunk/jython/Lib/test/test_socket.py 2008-11-17 20:06:51 UTC (rev 5584) @@ -7,6 +7,7 @@ import errno import Queue +import platform import select import socket import struct @@ -20,6 +21,8 @@ HOST = 'localhost' MSG = 'Michael Gilfix was here\n' EIGHT_BIT_MSG = 'Bh\xed Al\xe1in \xd3 Cinn\xe9ide anseo\n' +os_name = platform.java_ver()[3][0] +is_bsd = os_name == 'Mac OS X' or 'BSD' in os_name try: True @@ -548,6 +551,7 @@ sock.close() def _testTCPClientOption(self, option, values): + sock = None try: # First listen on a server socket, so that the connection won't be refused. server_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) @@ -560,12 +564,21 @@ # First bind, so that the SO_REUSEADDR setting propagates sock.bind( (HOST, PORT+1) ) sock.connect( (HOST, PORT) ) - self.failUnlessEqual(sock.getsockopt(socket.SOL_SOCKET, option), values[-1], \ - "Option value '%s'='%s' did not propagate to implementation socket" % (option, values[-1])) + msg = "Option value '%s'='%s' did not propagate to implementation socket" % (option, values[-1]) + if is_bsd and option in (socket.SO_RCVBUF, socket.SO_SNDBUF): + # XXX: there's no guarantee that bufsize will be the + # exact setsockopt value, particularly after + # establishing a connection. seems it will be *at least* + # the values we test (which are rather small) on + # BSDs. may need to relax this on other platforms also + self.assert_(sock.getsockopt(socket.SOL_SOCKET, option) >= values[-1], msg) + else: + self.failUnlessEqual(sock.getsockopt(socket.SOL_SOCKET, option), values[-1], msg) self._testSetAndGetOption(sock, option, values) finally: server_sock.close() - sock.close() + if sock: + sock.close() def _testTCPServerOption(self, option, values): try: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-11-17 20:06:01
|
Revision: 5583 http://jython.svn.sourceforge.net/jython/?rev=5583&view=rev Author: pjenvey Date: 2008-11-17 20:05:55 +0000 (Mon, 17 Nov 2008) Log Message: ----------- o allow Socket{TCP,UDP}Test HOST/PORT to be overriden per class o use a different port than test_socket for test_select as test_socket sockopt tests don't REUSEADDR Modified Paths: -------------- trunk/jython/Lib/test/test_select.py trunk/jython/Lib/test/test_socket.py Modified: trunk/jython/Lib/test/test_select.py =================================================================== --- trunk/jython/Lib/test/test_select.py 2008-11-16 22:52:56 UTC (rev 5582) +++ trunk/jython/Lib/test/test_select.py 2008-11-17 20:05:55 UTC (rev 5583) @@ -1,21 +1,18 @@ """ AMAK: 20050515: This module is the test_select.py from cpython 2.4, ported to jython + unittest """ - -try: - object -except NameError: - class object: pass - import errno +import os import select import socket - -import os import sys -from test import test_support +import test_socket import unittest +from test import test_support +HOST = test_socket.HOST +PORT = test_socket.PORT + 100 + class SelectWrapper: def __init__(self): @@ -140,11 +137,11 @@ # # using the test_socket thread based server/client management, for convenience. # - -import test_socket - class ThreadedPollClientSocket(test_socket.ThreadedTCPSocketTest): + HOST = HOST + PORT = PORT + def testSocketRegisteredBeforeConnected(self): self.cli_conn = self.serv.accept() @@ -158,7 +155,7 @@ self.failIf(self.cli in result_sockets, "Unconnected client socket should not have been selectable") # Now connect the socket, but DO NOT register it again self.cli.setblocking(0) - self.cli.connect( (test_socket.HOST, test_socket.PORT) ) + self.cli.connect( (self.HOST, self.PORT) ) # Now poll again, to check that the poll object has recognised that the socket is now connected result_list = poll_object.poll(timeout) result_sockets = [r[0] for r in result_list] @@ -169,7 +166,7 @@ def _testSocketMustBeNonBlocking(self): self.cli.setblocking(1) - self.cli.connect( (test_socket.HOST, test_socket.PORT) ) + self.cli.connect( (self.HOST, self.PORT) ) timeout = 1000 # milliseconds poll_object = select.poll() try: Modified: trunk/jython/Lib/test/test_socket.py =================================================================== --- trunk/jython/Lib/test/test_socket.py 2008-11-16 22:52:56 UTC (rev 5582) +++ trunk/jython/Lib/test/test_socket.py 2008-11-17 20:05:55 UTC (rev 5583) @@ -28,10 +28,13 @@ class SocketTCPTest(unittest.TestCase): + HOST = HOST + PORT = PORT + def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - self.serv.bind((HOST, PORT)) + self.serv.bind((self.HOST, self.PORT)) self.serv.listen(1) def tearDown(self): @@ -40,10 +43,13 @@ class SocketUDPTest(unittest.TestCase): + HOST = HOST + PORT = PORT + def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - self.serv.bind((HOST, PORT)) + self.serv.bind((self.HOST, self.PORT)) def tearDown(self): self.serv.close() @@ -196,7 +202,7 @@ def clientSetUp(self): ThreadedTCPSocketTest.clientSetUp(self) - self.cli.connect((HOST, PORT)) + self.cli.connect((self.HOST, self.PORT)) self.serv_conn = self.cli def clientTearDown(self): @@ -796,7 +802,7 @@ self.assertEqual(msg, MSG) def _testSendtoAndRecv(self): - self.cli.sendto(MSG, 0, (HOST, PORT)) + self.cli.sendto(MSG, 0, (self.HOST, self.PORT)) def testSendtoAndRecvTimeoutMode(self): # Need to test again in timeout mode, which follows @@ -807,7 +813,7 @@ def _testSendtoAndRecvTimeoutMode(self): self.cli.settimeout(10) - self.cli.sendto(MSG, 0, (HOST, PORT)) + self.cli.sendto(MSG, 0, (self.HOST, self.PORT)) def testRecvFrom(self): # Testing recvfrom() over UDP @@ -815,7 +821,7 @@ self.assertEqual(msg, MSG) def _testRecvFrom(self): - self.cli.sendto(MSG, 0, (HOST, PORT)) + self.cli.sendto(MSG, 0, (self.HOST, self.PORT)) def testRecvFromTimeoutMode(self): # Need to test again in timeout mode, which follows @@ -826,7 +832,7 @@ def _testRecvFromTimeoutMode(self): self.cli.settimeout(10) - self.cli.sendto(MSG, 0, (HOST, PORT)) + self.cli.sendto(MSG, 0, (self.HOST, self.PORT)) def testSendtoEightBitSafe(self): # This test is necessary because java only supports signed bytes @@ -834,7 +840,7 @@ self.assertEqual(msg, EIGHT_BIT_MSG) def _testSendtoEightBitSafe(self): - self.cli.sendto(EIGHT_BIT_MSG, 0, (HOST, PORT)) + self.cli.sendto(EIGHT_BIT_MSG, 0, (self.HOST, self.PORT)) def testSendtoEightBitSafeTimeoutMode(self): # Need to test again in timeout mode, which follows @@ -845,7 +851,7 @@ def _testSendtoEightBitSafeTimeoutMode(self): self.cli.settimeout(10) - self.cli.sendto(EIGHT_BIT_MSG, 0, (HOST, PORT)) + self.cli.sendto(EIGHT_BIT_MSG, 0, (self.HOST, self.PORT)) class UDPBroadcastTest(ThreadedUDPSocketTest): @@ -854,13 +860,13 @@ self.serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) def testBroadcast(self): - self.serv.bind( ("<broadcast>", PORT) ) + self.serv.bind( ("<broadcast>", self.PORT) ) msg = self.serv.recv(len(EIGHT_BIT_MSG)) self.assertEqual(msg, EIGHT_BIT_MSG) def _testBroadcast(self): self.cli.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) - self.cli.sendto(EIGHT_BIT_MSG, ("<broadcast>", PORT) ) + self.cli.sendto(EIGHT_BIT_MSG, ("<broadcast>", self.PORT) ) class BasicSocketPairTest(SocketPairTest): @@ -927,7 +933,7 @@ def _testAcceptConnection(self): # Make a connection to the server - self.cli.connect((HOST, PORT)) + self.cli.connect((self.HOST, self.PORT)) # # AMAK: 20070311 @@ -942,7 +948,7 @@ def _testBlockingConnect(self): # Testing blocking connect self.cli.settimeout(10) - self.cli.connect((HOST, PORT)) + self.cli.connect((self.HOST, self.PORT)) def testNonBlockingConnect(self): # Testing non-blocking connect @@ -951,7 +957,7 @@ def _testNonBlockingConnect(self): # Testing non-blocking connect self.cli.setblocking(0) - result = self.cli.connect_ex((HOST, PORT)) + result = self.cli.connect_ex((self.HOST, self.PORT)) rfds, wfds, xfds = select.select([], [self.cli], []) self.failUnless(self.cli in wfds) try: @@ -970,13 +976,13 @@ def _testConnectWithLocalBind(self): # Testing blocking connect with local bind - cli_port = PORT - 1 + cli_port = self.PORT - 1 while True: # Keep trying until a local port is available self.cli.settimeout(1) - self.cli.bind( (HOST, cli_port) ) + self.cli.bind( (self.HOST, cli_port) ) try: - self.cli.connect((HOST, PORT)) + self.cli.connect((self.HOST, self.PORT)) break except socket.error, se: # cli_port is in use (maybe in TIME_WAIT state from a @@ -1004,7 +1010,7 @@ self.fail("Non-blocking socket with data should been in read list.") def _testRecvData(self): - self.cli.connect((HOST, PORT)) + self.cli.connect((self.HOST, self.PORT)) self.cli.send(MSG) def testRecvNoData(self): @@ -1019,7 +1025,7 @@ self.fail("Non-blocking recv of no data should have raised socket.error.") def _testRecvNoData(self): - self.cli.connect((HOST, PORT)) + self.cli.connect((self.HOST, self.PORT)) time.sleep(0.1) class NonBlockingUDPTests(ThreadedUDPSocketTest): pass @@ -1067,7 +1073,7 @@ self.cli_file = self.cli.makefile('wb') self.cli_file.close() try: - self.cli.sendto(MSG, 0, (HOST, PORT)) + self.cli.sendto(MSG, 0, (self.HOST, self.PORT)) except Exception, x: self.fail("Closing file wrapper appears to have closed underlying socket: %s" % str(x)) @@ -1079,7 +1085,7 @@ def _testCloseSocketDoesNotCloseFile(self): try: - self.cli.sendto(MSG, 0, (HOST, PORT)) + self.cli.sendto(MSG, 0, (self.HOST, self.PORT)) except Exception, x: self.fail("Closing file wrapper appears to have closed underlying socket: %s" % str(x)) @@ -1488,7 +1494,7 @@ pass def _testUnicodeHostname(self): - self.cli.connect((unicode(HOST), PORT)) + self.cli.connect((unicode(self.HOST), self.PORT)) class TestInvalidUsage(unittest.TestCase): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-11-16 22:53:00
|
Revision: 5582 http://jython.svn.sourceforge.net/jython/?rev=5582&view=rev Author: pjenvey Date: 2008-11-16 22:52:56 +0000 (Sun, 16 Nov 2008) Log Message: ----------- fix another binop corner case -- trigger the binop 'flip' when left_type < right_type (in terms of the reversed mro) instead of left_type != right_type Modified Paths: -------------- trunk/jython/Lib/test/test_descr_jy.py trunk/jython/src/org/python/core/PyObject.java trunk/jython/src/org/python/core/PyType.java Modified: trunk/jython/Lib/test/test_descr_jy.py =================================================================== --- trunk/jython/Lib/test/test_descr_jy.py 2008-11-14 22:54:53 UTC (rev 5581) +++ trunk/jython/Lib/test/test_descr_jy.py 2008-11-16 22:52:56 UTC (rev 5582) @@ -208,7 +208,22 @@ raises(bexc, bexc_msg, lambda : func(B())) self.assertEqual(func(C()), cresult) + def test_overriding_base_binop(self): + class MulBase(object): + def __init__(self, value): + self.value = value + def __mul__(self, other): + return self.value * other.value + def __rmul__(self, other): + return other.value * self.value + class DoublerBase(MulBase): + def __mul__(self, other): + return 2 * (self.value * other.value) + class AnotherDoubler(DoublerBase): + pass + self.assertEquals(DoublerBase(2) * AnotherDoubler(3), 12) + class InPlaceTestCase(unittest.TestCase): def test_iadd(self): Modified: trunk/jython/src/org/python/core/PyObject.java =================================================================== --- trunk/jython/src/org/python/core/PyObject.java 2008-11-14 22:54:53 UTC (rev 5581) +++ trunk/jython/src/org/python/core/PyObject.java 2008-11-16 22:52:56 UTC (rev 5582) @@ -1771,14 +1771,14 @@ * test_descr.subclass_right_op. */ PyObject o1 = this; - PyObject[] where = new PyObject[1]; - PyObject where1 = null, where2 = null; - PyObject impl1 = t1.lookup_where(left, where); + int[] where = new int[1]; + int where1, where2; + PyObject impl1 = t1.lookup_where_index(left, where); where1 = where[0]; - PyObject impl2 = t2.lookup_where(right, where); + PyObject impl2 = t2.lookup_where_index(right, where); where2 = where[0]; - if (impl2 != null && where1 != where2 && (t2.isSubType(t1) || - isStrUnicodeSpecialCase(t1, t2, op))) { + if (impl2 != null && where1 < where2 && (t2.isSubType(t1) || + isStrUnicodeSpecialCase(t1, t2, op))) { PyObject tmp = o1; o1 = o2; o2 = tmp; Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2008-11-14 22:54:53 UTC (rev 5581) +++ trunk/jython/src/org/python/core/PyType.java 2008-11-16 22:52:56 UTC (rev 5582) @@ -825,6 +825,34 @@ return null; } + /** + * Like lookup but also provides (in where[0]) the index of the type in the reversed + * mro -- that is, how many subtypes away from the base object the type is. + * + * @param name attribute name (must be interned) + * @param where an int[] with a length of at least 1 + * @return found PyObject or null + */ + public PyObject lookup_where_index(String name, int[] where) { + PyObject[] mro = this.mro; + if (mro == null) { + return null; + } + int i = mro.length; + for (PyObject t : mro) { + i--; + PyObject dict = t.fastGetDict(); + if (dict != null) { + PyObject obj = dict.__finditem__(name); + if (obj != null) { + where[0] = i; + return obj; + } + } + } + return null; + } + public PyObject super_lookup(PyType ref, String name) { PyObject[] mro = this.mro; if (mro == null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-11-14 22:54:58
|
Revision: 5581 http://jython.svn.sourceforge.net/jython/?rev=5581&view=rev Author: fwierzbicki Date: 2008-11-14 22:54:53 +0000 (Fri, 14 Nov 2008) Log Message: ----------- Fix for http://bugs.jython.org/issue1141. __builtin__.__import__ had subtle differences with CPython. These differences would cause problems for those who wish to override __builtin__.__import__ statement: import hell.first_circle - CPython: ('hell.first_circle', None) - old Jython: ('hell.first_circle', ()) statement: import hell.first_circle as limbo - CPython: ('hell.first_circle', None) - old Jython: ('hell.first_circle', ('*',)) Also note that the second import statement with an "as" would return the head module instead of the tail module, the opposite of what CPython does. Modified Paths: -------------- trunk/jython/Lib/test/test_import_jy.py trunk/jython/src/org/python/core/__builtin__.java trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/Lib/test/test_import_jy.py =================================================================== --- trunk/jython/Lib/test/test_import_jy.py 2008-11-14 17:53:21 UTC (rev 5580) +++ trunk/jython/Lib/test/test_import_jy.py 2008-11-14 22:54:53 UTC (rev 5581) @@ -96,9 +96,46 @@ self.assertEquals(bytecode, read(init_compiled), 'bytecode was recompiled') +class OverrideBuiltinsImportTestCase(unittest.TestCase): + def test_override(self): + tests = [ + ("import os.path" , "('os.path', None, -1, 'os')" ), + ("import os.path as path2", "('os.path', None, -1, 'os')" ), + ("from os.path import *" , "('os.path', ('*',), -1, 'posixpath')"), + ("from os.path import join", + "('os.path', ('join',), -1, 'posixpath')"), + ("from os.path import join as join2", + "('os.path', ('join',), -1, 'posixpath')"), + ("from os.path import join as join2, split as split2", + "('os.path', ('join', 'split'), -1, 'posixpath')"), + ] + import sys + # Replace __builtin__.__import__ to trace the calls + import __builtin__ + oldimp = __builtin__.__import__ + try: + def __import__(name, globs, locs, fromlist, level=-1): + mod = oldimp(name, globs, locs, fromlist, level) + globs["result"] = str((name, fromlist, level, mod.__name__)) + raise ImportError + + __builtin__.__import__ = __import__ + failed = 0 + for statement, expected in tests: + try: + c = compile(statement, "<unknown>", "exec") + exec c in locals(), globals() + raise Exception("ImportError expected.") + except ImportError: + pass + self.assertEquals(expected, result) + finally: + __builtin__.__import__ = oldimp + def test_main(): - test_support.run_unittest(MislabeledImportTestCase) + test_classes = [MislabeledImportTestCase, OverrideBuiltinsImportTestCase] + test_support.run_unittest(*test_classes) if __name__ == '__main__': test_main() Modified: trunk/jython/src/org/python/core/__builtin__.java =================================================================== --- trunk/jython/src/org/python/core/__builtin__.java 2008-11-14 17:53:21 UTC (rev 5580) +++ trunk/jython/src/org/python/core/__builtin__.java 2008-11-14 22:54:53 UTC (rev 5581) @@ -1266,7 +1266,8 @@ PyObject globals = ap.getPyObject(1, null); PyObject fromlist = ap.getPyObject(3, Py.EmptyTuple); int level = ap.getInt(4, imp.DEFAULT_LEVEL); - return imp.importName(module.intern(), fromlist.__len__() == 0, globals, fromlist, level); + return imp.importName(module.intern(), fromlist == Py.None || fromlist.__len__() == 0, + globals, fromlist, level); } } Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2008-11-14 17:53:21 UTC (rev 5580) +++ trunk/jython/src/org/python/core/imp.java 2008-11-14 22:54:53 UTC (rev 5581) @@ -754,7 +754,7 @@ */ public static PyObject importOne(String mod, PyFrame frame) { PyObject module = __builtin__.__import__(mod, frame.f_globals, frame - .getLocals(), Py.EmptyTuple); + .getLocals(), Py.None); return module; } @@ -764,7 +764,19 @@ */ public static PyObject importOneAs(String mod, PyFrame frame) { PyObject module = __builtin__.__import__(mod, frame.f_globals, frame - .getLocals(), getStarArg()); + .getLocals(), Py.None); + int dot = mod.indexOf('.'); + while (dot != -1) { + int dot2 = mod.indexOf('.', dot + 1); + String name; + if (dot2 == -1) { + name = mod.substring(dot + 1); + } else { + name = mod.substring(dot + 1, dot2); + } + module = module.__getattr__(name); + dot = dot2; + } return module; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-11-14 17:53:30
|
Revision: 5580 http://jython.svn.sourceforge.net/jython/?rev=5580&view=rev Author: fwierzbicki Date: 2008-11-14 17:53:21 +0000 (Fri, 14 Nov 2008) Log Message: ----------- Remove very old commented out code from imp.java. Modified Paths: -------------- trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2008-11-14 16:07:43 UTC (rev 5579) +++ trunk/jython/src/org/python/core/imp.java 2008-11-14 17:53:21 UTC (rev 5580) @@ -755,10 +755,6 @@ public static PyObject importOne(String mod, PyFrame frame) { PyObject module = __builtin__.__import__(mod, frame.f_globals, frame .getLocals(), Py.EmptyTuple); - /* - * int dot = mod.indexOf('.'); if (dot != -1) { mod = mod.substring(0, - * dot).intern(); } - */ return module; } @@ -769,7 +765,6 @@ public static PyObject importOneAs(String mod, PyFrame frame) { PyObject module = __builtin__.__import__(mod, frame.f_globals, frame .getLocals(), getStarArg()); - // frame.setlocal(asname, module); return module; } @@ -924,9 +919,6 @@ name = name.substring(dot + 1, name.length()).intern(); } - // This should be better "protected" - // ((PyStringMap)nm.__dict__).clear(); - nm.__setattr__("__name__", new PyString(modName)); PyObject ret = find_module(name, modName, path); modules.__setitem__(modName, ret); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-11-14 16:07:45
|
Revision: 5579 http://jython.svn.sourceforge.net/jython/?rev=5579&view=rev Author: fwierzbicki Date: 2008-11-14 16:07:43 +0000 (Fri, 14 Nov 2008) Log Message: ----------- Fix for NPE's and a weird Antlr error that can occur when Antlr is allowed to recover from parser errrors (for example, when ListErrorHandler is used). Modified Paths: -------------- trunk/jython/grammar/Python.g Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2008-11-14 07:35:53 UTC (rev 5578) +++ trunk/jython/grammar/Python.g 2008-11-14 16:07:43 UTC (rev 5579) @@ -307,7 +307,10 @@ $file_input.tree = mtype; } : (NEWLINE - | stmt {stypes.addAll($stmt.stypes);} + | stmt { + if ($stmt.stypes != null) + {stypes.addAll($stmt.stypes);} + } )* EOF { mtype = new Module($file_input.start, actions.castStmts(stypes)); } @@ -937,10 +940,11 @@ $stypes = $simple_stmt.stypes; } | NEWLINE INDENT - (stmt - { + (stmt { + if ($stmt.stypes != null) { $stypes.addAll($stmt.stypes); } + } )+ DEDENT ; @@ -1119,6 +1123,14 @@ -> $left ) ; + // This only happens when Antlr is allowed to do error recovery (for example if ListErrorHandler + // is used. It is at least possible that this is a bug in Antlr itself, so this needs further + // investigation. To reproduce, set errorHandler to ListErrorHandler and try to parse "[". + catch [RewriteCardinalityException rce] { + PythonTree badNode = (PythonTree)adaptor.errorNode(input, retval.start, input.LT(-1), null); + retval.tree = badNode; + errorHandler.error("Internal Parser Error", badNode); + } arith_op returns [operatorType op] : PLUS {$op = operatorType.Add;} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-11-14 07:36:05
|
Revision: 5578 http://jython.svn.sourceforge.net/jython/?rev=5578&view=rev Author: pjenvey Date: 2008-11-14 07:35:53 +0000 (Fri, 14 Nov 2008) Log Message: ----------- bring in constantine (0.3dev r80) for better errnos Modified Paths: -------------- trunk/jython/Lib/os.py trunk/jython/Lib/subprocess.py trunk/jython/Lib/test/test_chdir.py trunk/jython/Lib/test/test_fileno.py trunk/jython/build.xml trunk/jython/src/org/python/core/Py.java trunk/jython/src/org/python/core/io/FileIO.java trunk/jython/src/org/python/core/io/IOBase.java trunk/jython/src/org/python/core/io/ServerSocketIO.java trunk/jython/src/org/python/modules/_py_compile.java trunk/jython/src/org/python/modules/errno.java Added Paths: ----------- trunk/jython/extlibs/constantine.jar Modified: trunk/jython/Lib/os.py =================================================================== --- trunk/jython/Lib/os.py 2008-11-14 00:28:42 UTC (rev 5577) +++ trunk/jython/Lib/os.py 2008-11-14 07:35:53 UTC (rev 5578) @@ -46,6 +46,7 @@ import stat as _stat import sys from java.io import File +from org.python.constantine.platform import Errno from org.python.core.io import FileDescriptors, FileIO, IOBase from org.python.core.Py import newString as asPyString @@ -101,7 +102,7 @@ err = getattr(errno, error.name(), None) if err is None: raise OSError('%s: %s' % (error, msg)) - raise OSError(err, errno.strerror(err), msg) + raise OSError(err, strerror(err), msg) def unimplementedError(self, method_name): raise NotImplementedError(method_name) def warn(self, warning_id, msg, rest): @@ -246,9 +247,9 @@ """ realpath = _path.realpath(path) if not _path.exists(realpath): - raise OSError(errno.ENOENT, errno.strerror(errno.ENOENT), path) + raise OSError(errno.ENOENT, strerror(errno.ENOENT), path) if not _path.isdir(realpath): - raise OSError(errno.ENOTDIR, errno.strerror(errno.ENOTDIR), path) + raise OSError(errno.ENOTDIR, strerror(errno.ENOTDIR), path) sys.setCurrentWorkingDir(realpath) def listdir(path): @@ -275,7 +276,7 @@ # catch not found errors explicitly here, for now abs_path = sys.getPath(path) if not File(abs_path).exists(): - raise OSError(errno.ENOENT, errno.strerror(errno.ENOENT), path) + raise OSError(errno.ENOENT, strerror(errno.ENOENT), path) _posix.chmod(abs_path, mode) def mkdir(path, mode='ignored'): @@ -292,7 +293,7 @@ err = errno.EEXIST else: err = 0 - msg = errno.strerror(err) if err else "couldn't make directory" + msg = strerror(err) if err else "couldn't make directory" raise OSError(err, msg, path) def makedirs(path, mode='ignored'): @@ -371,9 +372,9 @@ Remove a directory.""" f = File(sys.getPath(path)) if not f.exists(): - raise OSError(errno.ENOENT, errno.strerror(errno.ENOENT), path) + raise OSError(errno.ENOENT, strerror(errno.ENOENT), path) elif not f.isDirectory(): - raise OSError(errno.ENOTDIR, errno.strerror(errno.ENOTDIR), path) + raise OSError(errno.ENOTDIR, strerror(errno.ENOTDIR), path) elif not f.delete(): raise OSError(0, "couldn't delete directory", path) @@ -409,10 +410,17 @@ """ if not isinstance(code, (int, long)): raise TypeError('an integer is required') - try: - return errno.strerror(code) - except KeyError: + constant = Errno.valueOf(code) + if constant is Errno.__UNKNOWN_CONSTANT__: return 'Unknown error: %d' % code + if constant.name() == constant.description(): + # XXX: have constantine handle this fallback + # Fake constant or just lacks a description, fallback to Linux's + from org.python.constantine.platform.linux import Errno as LinuxErrno + constant = getattr(LinuxErrno, constant.name(), None) + if not constant: + return 'Unknown error: %d' % code + return asPyString(constant.toString()) def access(path, mode): """access(path, mode) -> True if granted, False otherwise @@ -459,7 +467,7 @@ raise f = File(abs_path) if not f.exists(): - raise OSError(errno.ENOENT, errno.strerror(errno.ENOENT), path) + raise OSError(errno.ENOENT, strerror(errno.ENOENT), path) size = f.length() mtime = f.lastModified() / 1000.0 mode = 0 @@ -509,7 +517,7 @@ # Not a link, only now can we determine if it exists (because # File.exists() returns False for dead links) if not f.exists(): - raise OSError(errno.ENOENT, errno.strerror(errno.ENOENT), path) + raise OSError(errno.ENOENT, strerror(errno.ENOENT), path) return stat(path) def utime(path, times): @@ -550,12 +558,12 @@ if (len(mode) and mode[0] or '') not in 'rwa': raise ValueError("invalid file mode '%s'" % mode) if rawio.closed(): - raise OSError(errno.EBADF, errno.strerror(errno.EBADF)) + raise OSError(errno.EBADF, strerror(errno.EBADF)) try: fp = FileDescriptors.wrap(rawio, mode, bufsize) except IOError: - raise OSError(errno.EINVAL, errno.strerror(errno.EINVAL)) + raise OSError(errno.EINVAL, strerror(errno.EINVAL)) return fp def ftruncate(fd, length): @@ -567,7 +575,7 @@ try: rawio.truncate(length) except Exception, e: - raise IOError(errno.EBADF, errno.strerror(errno.EBADF)) + raise IOError(errno.EBADF, strerror(errno.EBADF)) def lseek(fd, pos, how): """lseek(fd, pos, how) -> newpos @@ -593,10 +601,10 @@ appending = flag & O_APPEND if updating and writing: - raise OSError(errno.EINVAL, errno.strerror(errno.EINVAL), filename) + raise OSError(errno.EINVAL, strerror(errno.EINVAL), filename) if not creating and not path.exists(filename): - raise OSError(errno.ENOENT, errno.strerror(errno.ENOENT), filename) + raise OSError(errno.ENOENT, strerror(errno.ENOENT), filename) if not writing: if updating: @@ -611,7 +619,7 @@ if exclusive and creating: try: if not File(sys.getPath(filename)).createNewFile(): - raise OSError(errno.EEXIST, errno.strerror(errno.EEXIST), + raise OSError(errno.EEXIST, strerror(errno.EEXIST), filename) except java.io.IOException, ioe: raise OSError(ioe) @@ -627,8 +635,8 @@ fchannel = RandomAccessFile(sys.getPath(filename), 'rws').getChannel() except FileNotFoundException, fnfe: if path.isdir(filename): - raise OSError(errno.EISDIR, errno.strerror(errno.EISDIR)) - raise OSError(errno.ENOENT, errno.strerror(errno.ENOENT), filename) + raise OSError(errno.EISDIR, strerror(errno.EISDIR)) + raise OSError(errno.ENOENT, strerror(errno.ENOENT), filename) return FileIO(fchannel, mode) return FileIO(filename, mode) @@ -659,7 +667,7 @@ try: return func(*args, **kwargs) except: - raise OSError(errno.EBADF, errno.strerror(errno.EBADF)) + raise OSError(errno.EBADF, strerror(errno.EBADF)) if _name == 'posix' and _native_posix: def link(src, dst): Modified: trunk/jython/Lib/subprocess.py =================================================================== --- trunk/jython/Lib/subprocess.py 2008-11-14 00:28:42 UTC (rev 5577) +++ trunk/jython/Lib/subprocess.py 2008-11-14 07:35:53 UTC (rev 5578) @@ -1169,9 +1169,9 @@ if cwd is None: cwd = os.getcwd() elif not os.path.exists(cwd): - raise OSError(errno.ENOENT, errno.strerror(errno.ENOENT), cwd) + raise OSError(errno.ENOENT, os.strerror(errno.ENOENT), cwd) elif not os.path.isdir(cwd): - raise OSError(errno.ENOTDIR, errno.strerror(errno.ENOENT), cwd) + raise OSError(errno.ENOTDIR, os.strerror(errno.ENOENT), cwd) builder.directory(java.io.File(cwd)) # Let Java manage redirection of stderr to stdout (it's more Modified: trunk/jython/Lib/test/test_chdir.py =================================================================== --- trunk/jython/Lib/test/test_chdir.py 2008-11-14 00:28:42 UTC (rev 5577) +++ trunk/jython/Lib/test/test_chdir.py 2008-11-14 07:35:53 UTC (rev 5578) @@ -177,10 +177,11 @@ def test_invalid_chdir(self): raises(OSError, - '[Errno 2] No such file or directory: %r' % self.filename1, + '[Errno 2] %s: %r' % (os.strerror(2), self.filename1), os.chdir, self.filename1) open(self.filename1, 'w').close() - raises(OSError, '[Errno 20] Not a directory: %r' % self.filename1, + raises(OSError, + '[Errno 20] %s: %r' % (os.strerror(20), self.filename1), os.chdir, self.filename1) Modified: trunk/jython/Lib/test/test_fileno.py =================================================================== --- trunk/jython/Lib/test/test_fileno.py 2008-11-14 00:28:42 UTC (rev 5577) +++ trunk/jython/Lib/test/test_fileno.py 2008-11-14 07:35:53 UTC (rev 5578) @@ -31,8 +31,7 @@ self.assertEqual(os.path.getsize(self.filename), 0) self.fp.close() - raises(IOError, '[Errno 9] Bad file descriptor', - os.ftruncate, self.fd, 0) + raises(IOError, 9, os.ftruncate, self.fd, 0) def test_lseek(self): self.assertEqual(os.lseek(self.fd, 0, 1), 0) @@ -40,8 +39,7 @@ os.lseek(self.fd, 7, 0) self.assertEqual(os.read(self.fd, 7), 'filenos') self.fp.close() - raises(OSError, '[Errno 9] Bad file descriptor', - os.lseek, self.fd, 0, 1) + raises(OSError, 9, os.lseek, self.fd, 0, 1) def test_read(self): self.fp.write('jython filenos') @@ -50,16 +48,14 @@ self.assertEqual(os.read(self.fd, 7), 'jython ') self.assertEqual(os.read(self.fd, 99), 'filenos') self.fp.close() - raises(OSError, '[Errno 9] Bad file descriptor', - os.read, self.fd, 1) + raises(OSError, 9, os.read, self.fd, 1) def test_write(self): os.write(self.fd, 'jython filenos') self.fp.seek(0) self.assertEqual(self.fp.read(), 'jython filenos') self.fp.close() - raises(OSError, '[Errno 9] Bad file descriptor', - os.write, self.fd, 'The Larch') + raises(OSError, 9, os.write, self.fd, 'The Larch') class TestOsOpenTestCase(unittest.TestCase): @@ -96,8 +92,7 @@ # falls back to read only without O_WRONLY/O_RDWR self.fd = os.open(self.filename, os.O_APPEND) - raises(OSError, '[Errno 9] Bad file descriptor', - os.write, self.fd, 'new') + raises(OSError, 9, os.write, self.fd, 'new') # Acts as append on windows (seeks to the end) os.lseek(self.fd, 0, 0) self.assertEquals(os.read(self.fd, len('jython filenos')), 'jython filenos') @@ -105,8 +100,7 @@ # falls back to read only without O_WRONLY/O_RDWR self.fd = os.open(self.filename, os.O_CREAT) - raises(OSError, '[Errno 9] Bad file descriptor', - os.write, self.fd, 'new') + raises(OSError, 9, os.write, self.fd, 'new') self.assertEquals(os.read(self.fd, len('jython filenos')), 'jython filenos') os.close(self.fd) @@ -133,8 +127,7 @@ self.fd = os.open(self.filename, os.O_TRUNC | os.O_WRONLY) self.assertEquals(os.path.getsize(self.filename), 0) os.write(self.fd, 'write only truncated') - raises(OSError, '[Errno 9] Bad file descriptor', - os.read, self.fd, 99) + raises(OSError, 9, os.read, self.fd, 99) os.close(self.fd) fd = open(self.filename) @@ -146,8 +139,7 @@ # falls back to read only without O_WRONLY/O_RDWR, but truncates self.fd = os.open(self.filename, os.O_TRUNC) self.assertEquals(os.path.getsize(self.filename), 0) - raises(OSError, '[Errno 9] Bad file descriptor', - os.write, self.fd, 'new') + raises(OSError, 9, os.write, self.fd, 'new') self.assertEquals(os.read(self.fd, 99), '') os.close(self.fd) @@ -159,8 +151,7 @@ # append with no write falls back to read, but still truncates self.fd = os.open(self.filename, os.O_TRUNC | os.O_APPEND) self.assertEquals(os.path.getsize(self.filename), 0) - raises(OSError, '[Errno 9] Bad file descriptor', - os.write, self.fd, 'new') + raises(OSError, 9, os.write, self.fd, 'new') os.close(self.fd) fp = open(self.filename, 'w') @@ -172,26 +163,23 @@ def test_open_exclusive(self): self.assert_(not os.path.exists(self.filename)) # fails without O_CREAT - raises(OSError, '[Errno 2] No such file or directory: %r' % \ - self.filename, - os.open, self.filename, os.O_EXCL) + raises(OSError, (2, self.filename), os.open, self.filename, os.O_EXCL) self.assert_(not os.path.exists(self.filename)) # creates, read only self.fd = os.open(self.filename, os.O_EXCL | os.O_CREAT) self.assert_(os.path.exists(self.filename)) - raises(OSError, '[Errno 9] Bad file descriptor', - os.write, self.fd, 'jython') + raises(OSError, 9, os.write, self.fd, 'jython') self.assertEquals(os.read(self.fd, 99), '') os.close(self.fd) # not exclusive unless creating os.close(os.open(self.filename, os.O_EXCL)) - raises(OSError, '[Errno 17] File exists: %r' % self.filename, + raises(OSError, (17, self.filename), os.open, self.filename, os.O_CREAT | os.O_EXCL) - raises(OSError, '[Errno 17] File exists: %r' % self.filename, + raises(OSError, (17, self.filename), os.open, self.filename, os.O_CREAT | os.O_WRONLY | os.O_EXCL) - raises(OSError, '[Errno 17] File exists: %r' % self.filename, + raises(OSError, (17, self.filename), os.open, self.filename, os.O_CREAT | os.O_RDWR | os.O_EXCL) os.remove(self.filename) @@ -208,8 +196,7 @@ self.fd = os.open(self.filename, os.O_SYNC | os.O_WRONLY | os.O_CREAT) self.assert_(os.path.exists(self.filename)) os.write(self.fd, 'jython') - raises(OSError, '[Errno 9] Bad file descriptor', - os.read, self.fd, 99) + raises(OSError, 9, os.read, self.fd, 99) os.close(self.fd) os.remove(self.filename) @@ -232,12 +219,11 @@ def test_bad_open(self): for mode in (os.O_WRONLY, os.O_WRONLY, os.O_RDWR): - raises(OSError, '[Errno 2] No such file or directory: %r' % \ - self.filename, os.open, self.filename, mode) + raises(OSError, (2, self.filename), os.open, self.filename, mode) open(self.filename, 'w').close() - raises(OSError, '[Errno 22] Invalid argument: %r' % self.filename, + raises(OSError, (22, self.filename), os.open, self.filename, os.O_WRONLY | os.O_RDWR) @@ -321,12 +307,26 @@ def raises(exc, expected, callable, *args): + """Ensure the specified call raises exc. + + expected is compared against the exception message if not None. It + can be a str, an errno or a 2 item tuple of errno/filename. The + latter two being for comparison against EnvironmentErrors. + """ + if expected: + if isinstance(expected, str): + msg = expected + else: + errno = expected[0] if isinstance(expected, tuple) else expected + msg = '[Errno %d] %s' % (errno, os.strerror(errno)) + if isinstance(expected, tuple): + msg += ': %r' % expected[1] try: callable(*args) - except exc, msg: - if expected is not None and str(msg) != expected: + except exc, val: + if expected and str(val) != msg: raise test_support.TestFailed( - "Message %r, expected %r" % (str(msg), expected)) + "Message %r, expected %r" % (str(value), msg)) else: raise test_support.TestFailed("Expected %s" % exc) Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2008-11-14 00:28:42 UTC (rev 5577) +++ trunk/jython/build.xml 2008-11-14 07:35:53 UTC (rev 5578) @@ -525,6 +525,8 @@ <zipfileset src="extlibs/jna-posix.jar"/> <!-- <rule pattern="com.sun.jna.**" result="org.python.jna.@1"/> --> <rule pattern="org.jruby.ext.posix.**" result="org.python.posix.@1"/> + <zipfileset src="extlibs/constantine.jar"/> + <rule pattern="com.kenai.constantine.**" result="org.python.constantine.@1"/> </jarjar> <unjar src="${output.dir}/jarjar.jar" dest="${jarjar.dir}"> <patternset> Added: trunk/jython/extlibs/constantine.jar =================================================================== (Binary files differ) Property changes on: trunk/jython/extlibs/constantine.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2008-11-14 00:28:42 UTC (rev 5577) +++ trunk/jython/src/org/python/core/Py.java 2008-11-14 07:35:53 UTC (rev 5578) @@ -4,6 +4,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -22,11 +23,11 @@ import java.util.Set; import org.python.antlr.ast.modType; +import org.python.constantine.platform.Errno; import org.python.compiler.Module; import org.python.core.adapter.ClassicPyObjectAdapter; import org.python.core.adapter.ExtensiblePyObjectAdapter; import org.python.core.util.StringUtil; -import org.python.modules.errno; public final class Py { @@ -144,14 +145,15 @@ } public static PyObject IOError; - public static PyException IOError(java.io.IOException ioe) { + public static PyException IOError(IOException ioe) { String message = ioe.getMessage(); if (message == null) { message = ioe.getClass().getName(); } - if (ioe instanceof java.io.FileNotFoundException) { - message = "File not found - " + message; - return IOError(errno.ENOENT, message); + if (ioe instanceof FileNotFoundException) { + PyTuple args = new PyTuple(Py.newInteger(Errno.ENOENT.value()), + Py.newString("File not found - " + message)); + return new PyException(Py.IOError, args); } return new PyException(Py.IOError, message); } @@ -160,10 +162,18 @@ return new PyException(Py.IOError, message); } - public static PyException IOError(int errno, String message) { - PyTuple args = new PyTuple(new PyInteger(errno), new PyString(message)); + public static PyException IOError(Errno errno) { + PyObject args = new PyTuple(Py.newInteger(errno.value()), + Py.newString(errno.description())); return new PyException(Py.IOError, args); } + + public static PyException IOError(Errno errno, String filename) { + PyObject args = new PyTuple(Py.newInteger(errno.value()), + Py.newString(errno.description()), Py.newString(filename)); + return new PyException(Py.IOError, args); + } + public static PyObject KeyError; public static PyException KeyError(String message) { Modified: trunk/jython/src/org/python/core/io/FileIO.java =================================================================== --- trunk/jython/src/org/python/core/io/FileIO.java 2008-11-14 00:28:42 UTC (rev 5577) +++ trunk/jython/src/org/python/core/io/FileIO.java 2008-11-14 07:35:53 UTC (rev 5578) @@ -12,11 +12,11 @@ import java.nio.channels.Channels; import java.nio.channels.FileChannel; +import org.python.constantine.platform.Errno; import org.python.core.imp; import org.python.core.Py; import org.python.core.PyObject; import org.python.core.util.RelativeFile; -import org.python.modules.errno; /** * Raw I/O implementation for OS files. @@ -67,13 +67,13 @@ fileChannel = file.getChannel(); } catch (FileNotFoundException fnfe) { if (fullPath.isDirectory()) { - throw Py.IOError(errno.EISDIR, "Is a directory"); + throw Py.IOError(Errno.EISDIR, name); } if ((writing && !fullPath.canWrite()) || fnfe.getMessage().endsWith("(Permission denied)")) { - throw Py.IOError(errno.EACCES, "Permission denied: '" + name + "'"); + throw Py.IOError(Errno.EACCES, name); } - throw Py.IOError(errno.ENOENT, "No such file or directory: '" + name + "'"); + throw Py.IOError(Errno.ENOENT, name); } initPosition(); @@ -289,7 +289,7 @@ pos += fileChannel.size(); break; default: - throw Py.IOError(errno.EINVAL, "invalid whence value"); + throw Py.IOError(Errno.EINVAL); } fileChannel.position(pos); return pos; Modified: trunk/jython/src/org/python/core/io/IOBase.java =================================================================== --- trunk/jython/src/org/python/core/io/IOBase.java 2008-11-14 00:28:42 UTC (rev 5577) +++ trunk/jython/src/org/python/core/io/IOBase.java 2008-11-14 07:35:53 UTC (rev 5578) @@ -1,9 +1,9 @@ /* Copyright (c) 2007 Jython Developers */ package org.python.core.io; +import org.python.constantine.platform.Errno; import org.python.core.Py; import org.python.core.PyException; -import org.python.modules.errno; /** * Base class for all I/O classes. @@ -148,7 +148,7 @@ */ public void checkReadable() { if (!readable()) { - throw Py.IOError(errno.EBADF, "Bad file descriptor"); + throw Py.IOError(Errno.EBADF); } } @@ -167,7 +167,7 @@ */ public void checkWritable() { if (!writable()) { - throw Py.IOError(errno.EBADF, "Bad file descriptor"); + throw Py.IOError(Errno.EBADF); } } Modified: trunk/jython/src/org/python/core/io/ServerSocketIO.java =================================================================== --- trunk/jython/src/org/python/core/io/ServerSocketIO.java 2008-11-14 00:28:42 UTC (rev 5577) +++ trunk/jython/src/org/python/core/io/ServerSocketIO.java 2008-11-14 07:35:53 UTC (rev 5578) @@ -6,8 +6,8 @@ import java.nio.channels.Channel; import java.nio.channels.ServerSocketChannel; +import org.python.constantine.platform.Errno; import org.python.core.Py; -import org.python.modules.errno; /** * Raw I/O implementation for server sockets. @@ -34,14 +34,14 @@ public int readinto(ByteBuffer buf) { checkClosed(); checkReadable(); - throw Py.IOError(errno.ENOTCONN, "Socket is not connected"); + throw Py.IOError(Errno.ENOTCONN); } /** {@inheritDoc} */ public int write(ByteBuffer buf) { checkClosed(); checkWritable(); - throw Py.IOError(errno.EBADF, "Bad file descriptor"); + throw Py.IOError(Errno.EBADF); } /** {@inheritDoc} */ Modified: trunk/jython/src/org/python/modules/_py_compile.java =================================================================== --- trunk/jython/src/org/python/modules/_py_compile.java 2008-11-14 00:28:42 UTC (rev 5577) +++ trunk/jython/src/org/python/modules/_py_compile.java 2008-11-14 07:35:53 UTC (rev 5578) @@ -3,6 +3,7 @@ import java.io.File; +import org.python.constantine.platform.Errno; import org.python.core.Py; import org.python.core.PyList; import org.python.core.PyString; @@ -20,7 +21,7 @@ File file = new File(filename); if (!file.exists()) { - throw Py.IOError(errno.ENOENT, "No such file or directory: '" + filename + "'"); + throw Py.IOError(Errno.ENOENT, filename); } String name = file.getName(); int dot = name.lastIndexOf('.'); Modified: trunk/jython/src/org/python/modules/errno.java =================================================================== --- trunk/jython/src/org/python/modules/errno.java 2008-11-14 00:28:42 UTC (rev 5577) +++ trunk/jython/src/org/python/modules/errno.java 2008-11-14 07:35:53 UTC (rev 5578) @@ -1,288 +1,63 @@ +/* Copyright (c) Jython Developers */ package org.python.modules; -import org.python.core.*; +import org.python.constantine.Constant; +import org.python.constantine.ConstantSet; +import org.python.core.ClassDictInit; +import org.python.core.Py; +import org.python.core.PyDictionary; +import org.python.core.PyObject; +import org.python.core.PyString; +import org.python.core.imp; /** - * This file contains autogenerated error codes from:<br/> - * <b>Python 2.2.1 (#5, Oct 7 2002, 09:20:38) [GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-97)]</b> + * The Python errno module. * - * @author brian zimmer - * @version 2.2.1 - * @copyright 2002 brian zimmer + * Errno constants can be accessed from Java code via + * {@link org.python.constantine.platform.Errno}, e.g. Errno.ENOENT. */ -public final class errno implements ClassDictInit { +public class errno implements ClassDictInit { - private errno() {} + public static final PyString __doc__ = Py.newString( + "This module makes available standard errno system symbols.\n\n" + + "The value of each symbol is the corresponding integer value,\n" + + "e.g., on most systems, errno.ENOENT equals the integer 2.\n\n" + + "The dictionary errno.errorcode maps numeric codes to symbol names,\n" + + "e.g., errno.errorcode[2] could be the string 'ENOENT'.\n\n" + + "Symbols that are not relevant to the underlying system are not defined.\n\n" + + "To map error codes to error messages, use the function os.strerror(),\n" + + "e.g. os.strerror(2) could return 'No such file or directory'."); - public static final int EPERM = 1; - public static final int ENOENT = 2; - public static final int ESRCH = 3; - public static final int EINTR = 4; - public static final int EIO = 5; - public static final int ENXIO = 6; - public static final int E2BIG = 7; - public static final int ENOEXEC = 8; - public static final int EBADF = 9; - public static final int ECHILD = 10; - public static final int EAGAIN = 11; - public static final int EWOULDBLOCK = 11; - public static final int ENOMEM = 12; - public static final int EACCES = 13; - public static final int EFAULT = 14; - public static final int ENOTBLK = 15; - public static final int EBUSY = 16; - public static final int EEXIST = 17; - public static final int EXDEV = 18; - public static final int ENODEV = 19; - public static final int ENOTDIR = 20; - public static final int EISDIR = 21; - public static final int EINVAL = 22; - public static final int ENFILE = 23; - public static final int EMFILE = 24; - public static final int ENOTTY = 25; - public static final int ETXTBSY = 26; - public static final int EFBIG = 27; - public static final int ENOSPC = 28; - public static final int ESPIPE = 29; - public static final int EROFS = 30; - public static final int EMLINK = 31; - public static final int EPIPE = 32; - public static final int EDOM = 33; - public static final int ERANGE = 34; - public static final int EDEADLK = 35; - public static final int EDEADLOCK = 35; - public static final int ENAMETOOLONG = 36; - public static final int ENOLCK = 37; - public static final int ENOSYS = 38; - public static final int ENOTEMPTY = 39; - public static final int ELOOP = 40; - public static final int ENOMSG = 42; - public static final int EIDRM = 43; - public static final int ECHRNG = 44; - public static final int EL2NSYNC = 45; - public static final int EL3HLT = 46; - public static final int EL3RST = 47; - public static final int ELNRNG = 48; - public static final int EUNATCH = 49; - public static final int ENOCSI = 50; - public static final int EL2HLT = 51; - public static final int EBADE = 52; - public static final int EBADR = 53; - public static final int EXFULL = 54; - public static final int ENOANO = 55; - public static final int EBADRQC = 56; - public static final int EBADSLT = 57; - public static final int EBFONT = 59; - public static final int ENOSTR = 60; - public static final int ENODATA = 61; - public static final int ETIME = 62; - public static final int ENOSR = 63; - public static final int ENONET = 64; - public static final int ENOPKG = 65; - public static final int EREMOTE = 66; - public static final int ENOLINK = 67; - public static final int EADV = 68; - public static final int ESRMNT = 69; - public static final int ECOMM = 70; - public static final int EPROTO = 71; - public static final int EMULTIHOP = 72; - public static final int EDOTDOT = 73; - public static final int EBADMSG = 74; - public static final int EOVERFLOW = 75; - public static final int ENOTUNIQ = 76; - public static final int EBADFD = 77; - public static final int EREMCHG = 78; - public static final int ELIBACC = 79; - public static final int ELIBBAD = 80; - public static final int ELIBSCN = 81; - public static final int ELIBMAX = 82; - public static final int ELIBEXEC = 83; - public static final int EILSEQ = 84; - public static final int ERESTART = 85; - public static final int ESTRPIPE = 86; - public static final int EUSERS = 87; - public static final int ENOTSOCK = 88; - public static final int EDESTADDRREQ = 89; - public static final int EMSGSIZE = 90; - public static final int EPROTOTYPE = 91; - public static final int ENOPROTOOPT = 92; - public static final int EPROTONOSUPPORT = 93; - public static final int ESOCKTNOSUPPORT = 94; - public static final int EOPNOTSUPP = 95; - public static final int EPFNOSUPPORT = 96; - public static final int EAFNOSUPPORT = 97; - public static final int EADDRINUSE = 98; - public static final int EADDRNOTAVAIL = 99; - public static final int ENETDOWN = 100; - public static final int ENETUNREACH = 101; - public static final int ENETRESET = 102; - public static final int ECONNABORTED = 103; - public static final int ECONNRESET = 104; - public static final int ENOBUFS = 105; - public static final int EISCONN = 106; - public static final int ENOTCONN = 107; - public static final int ESHUTDOWN = 108; - public static final int ETOOMANYREFS = 109; - public static final int ETIMEDOUT = 110; - public static final int ECONNREFUSED = 111; - public static final int EHOSTDOWN = 112; - public static final int EHOSTUNREACH = 113; - public static final int EALREADY = 114; - public static final int EINPROGRESS = 115; - public static final int ESTALE = 116; - public static final int EUCLEAN = 117; - public static final int ENOTNAM = 118; - public static final int ENAVAIL = 119; - public static final int EISNAM = 120; - public static final int EREMOTEIO = 121; - public static final int EDQUOT = 122; - - // AMAK: Starting a new series of jython specific error numbers - public static final int ESOCKISBLOCKING = 20000; - public static final int EGETADDRINFOFAILED = 20001; - + /** Reverse mapping of codes to names. */ public static final PyObject errorcode = new PyDictionary(); - private static final PyObject strerror = new PyDictionary(); - public static void classDictInit(PyObject dict) throws PyIgnoreMethodTag { - addcode(dict, EPERM, "EPERM", "Operation not permitted"); - addcode(dict, ENOENT, "ENOENT", "No such file or directory"); - addcode(dict, ESRCH, "ESRCH", "No such process"); - addcode(dict, EINTR, "EINTR", "Interrupted system call"); - addcode(dict, EIO, "EIO", "Input/output error"); - addcode(dict, ENXIO, "ENXIO", "Device not configured"); - addcode(dict, E2BIG, "E2BIG", "Argument list too long"); - addcode(dict, ENOEXEC, "ENOEXEC", "Exec format error"); - addcode(dict, EBADF, "EBADF", "Bad file descriptor"); - addcode(dict, ECHILD, "ECHILD", "No child processes"); - addcode(dict, EAGAIN, "EAGAIN", "Resource temporarily unavailable"); - addcode(dict, EWOULDBLOCK, "EWOULDBLOCK", "Resource temporarily unavailable"); - addcode(dict, ENOMEM, "ENOMEM", "Cannot allocate memory"); - addcode(dict, EACCES, "EACCES", "Permission denied"); - addcode(dict, EFAULT, "EFAULT", "Bad address"); - addcode(dict, ENOTBLK, "ENOTBLK", "Block device required"); - addcode(dict, EBUSY, "EBUSY", "Device or resource busy"); - addcode(dict, EEXIST, "EEXIST", "File exists"); - addcode(dict, EXDEV, "EXDEV", "Invalid cross-device link"); - addcode(dict, ENODEV, "ENODEV", "No such device"); - addcode(dict, ENOTDIR, "ENOTDIR", "Not a directory"); - addcode(dict, EISDIR, "EISDIR", "Is a directory"); - addcode(dict, EINVAL, "EINVAL", "Invalid argument"); - addcode(dict, ENFILE, "ENFILE", "Too many open files in system"); - addcode(dict, EMFILE, "EMFILE", "Too many open files"); - addcode(dict, ENOTTY, "ENOTTY", "Inappropriate ioctl for device"); - addcode(dict, ETXTBSY, "ETXTBSY", "Text file busy"); - addcode(dict, EFBIG, "EFBIG", "File too large"); - addcode(dict, ENOSPC, "ENOSPC", "No space left on device"); - addcode(dict, ESPIPE, "ESPIPE", "Illegal seek"); - addcode(dict, EROFS, "EROFS", "Read-only file system"); - addcode(dict, EMLINK, "EMLINK", "Too many links"); - addcode(dict, EPIPE, "EPIPE", "Broken pipe"); - addcode(dict, EDOM, "EDOM", "Numerical argument out of domain"); - addcode(dict, ERANGE, "ERANGE", "Numerical result out of range"); - addcode(dict, EDEADLK, "EDEADLK", "Resource deadlock avoided"); - addcode(dict, EDEADLOCK, "EDEADLOCK", "Resource deadlock avoided"); - addcode(dict, ENAMETOOLONG, "ENAMETOOLONG", "File name too long"); - addcode(dict, ENOLCK, "ENOLCK", "No locks available"); - addcode(dict, ENOSYS, "ENOSYS", "Function not implemented"); - addcode(dict, ENOTEMPTY, "ENOTEMPTY", "Directory not empty"); - addcode(dict, ELOOP, "ELOOP", "Too many levels of symbolic links"); - addcode(dict, ENOMSG, "ENOMSG", "No message of desired type"); - addcode(dict, EIDRM, "EIDRM", "Identifier removed"); - addcode(dict, ECHRNG, "ECHRNG", "Channel number out of range"); - addcode(dict, EL2NSYNC, "EL2NSYNC", "Level 2 not synchronized"); - addcode(dict, EL3HLT, "EL3HLT", "Level 3 halted"); - addcode(dict, EL3RST, "EL3RST", "Level 3 reset"); - addcode(dict, ELNRNG, "ELNRNG", "Link number out of range"); - addcode(dict, EUNATCH, "EUNATCH", "Protocol driver not attached"); - addcode(dict, ENOCSI, "ENOCSI", "No CSI structure available"); - addcode(dict, EL2HLT, "EL2HLT", "Level 2 halted"); - addcode(dict, EBADE, "EBADE", "Invalid exchange"); - addcode(dict, EBADR, "EBADR", "Invalid request descriptor"); - addcode(dict, EXFULL, "EXFULL", "Exchange full"); - addcode(dict, ENOANO, "ENOANO", "No anode"); - addcode(dict, EBADRQC, "EBADRQC", "Invalid request code"); - addcode(dict, EBADSLT, "EBADSLT", "Invalid slot"); - addcode(dict, EBFONT, "EBFONT", "Bad font file format"); - addcode(dict, ENOSTR, "ENOSTR", "Device not a stream"); - addcode(dict, ENODATA, "ENODATA", "No data available"); - addcode(dict, ETIME, "ETIME", "Timer expired"); - addcode(dict, ENOSR, "ENOSR", "Out of streams resources"); - addcode(dict, ENONET, "ENONET", "Machine is not on the network"); - addcode(dict, ENOPKG, "ENOPKG", "Package not installed"); - addcode(dict, EREMOTE, "EREMOTE", "Object is remote"); - addcode(dict, ENOLINK, "ENOLINK", "Link has been severed"); - addcode(dict, EADV, "EADV", "Advertise error"); - addcode(dict, ESRMNT, "ESRMNT", "Srmount error"); - addcode(dict, ECOMM, "ECOMM", "Communication error on send"); - addcode(dict, EPROTO, "EPROTO", "Protocol error"); - addcode(dict, EMULTIHOP, "EMULTIHOP", "Multihop attempted"); - addcode(dict, EDOTDOT, "EDOTDOT", "RFS specific error"); - addcode(dict, EBADMSG, "EBADMSG", "Bad message"); - addcode(dict, EOVERFLOW, "EOVERFLOW", "Value too large for defined data type"); - addcode(dict, ENOTUNIQ, "ENOTUNIQ", "Name not unique on network"); - addcode(dict, EBADFD, "EBADFD", "File descriptor in bad state"); - addcode(dict, EREMCHG, "EREMCHG", "Remote address changed"); - addcode(dict, ELIBACC, "ELIBACC", "Can not access a needed shared library"); - addcode(dict, ELIBBAD, "ELIBBAD", "Accessing a corrupted shared library"); - addcode(dict, ELIBSCN, "ELIBSCN", ".lib section in a.out corrupted"); - addcode(dict, ELIBMAX, "ELIBMAX", "Attempting to link in too many shared libraries"); - addcode(dict, ELIBEXEC, "ELIBEXEC", "Cannot exec a shared library directly"); - addcode(dict, EILSEQ, "EILSEQ", "Invalid or incomplete multibyte or wide character"); - addcode(dict, ERESTART, "ERESTART", "Interrupted system call should be restarted"); - addcode(dict, ESTRPIPE, "ESTRPIPE", "Streams pipe error"); - addcode(dict, EUSERS, "EUSERS", "Too many users"); - addcode(dict, ENOTSOCK, "ENOTSOCK", "Socket operation on non-socket"); - addcode(dict, EDESTADDRREQ, "EDESTADDRREQ", "Destination address required"); - addcode(dict, EMSGSIZE, "EMSGSIZE", "Message too long"); - addcode(dict, EPROTOTYPE, "EPROTOTYPE", "Protocol wrong type for socket"); - addcode(dict, ENOPROTOOPT, "ENOPROTOOPT", "Protocol not available"); - addcode(dict, EPROTONOSUPPORT, "EPROTONOSUPPORT", "Protocol not supported"); - addcode(dict, ESOCKTNOSUPPORT, "ESOCKTNOSUPPORT", "Socket type not supported"); - addcode(dict, EOPNOTSUPP, "EOPNOTSUPP", "Operation not supported"); - addcode(dict, EPFNOSUPPORT, "EPFNOSUPPORT", "Protocol family not supported"); - addcode(dict, EAFNOSUPPORT, "EAFNOSUPPORT", "Address family not supported by protocol"); - addcode(dict, EADDRINUSE, "EADDRINUSE", "Address already in use"); - addcode(dict, EADDRNOTAVAIL, "EADDRNOTAVAIL", "Cannot assign requested address"); - addcode(dict, ENETDOWN, "ENETDOWN", "Network is down"); - addcode(dict, ENETUNREACH, "ENETUNREACH", "Network is unreachable"); - addcode(dict, ENETRESET, "ENETRESET", "Network dropped connection on reset"); - addcode(dict, ECONNABORTED, "ECONNABORTED", "Software caused connection abort"); - addcode(dict, ECONNRESET, "ECONNRESET", "Connection reset by peer"); - addcode(dict, ENOBUFS, "ENOBUFS", "No buffer space available"); - addcode(dict, EISCONN, "EISCONN", "Transport endpoint is already connected"); - addcode(dict, ENOTCONN, "ENOTCONN", "Transport endpoint is not connected"); - addcode(dict, ESHUTDOWN, "ESHUTDOWN", "Cannot send after transport endpoint shutdown"); - addcode(dict, ETOOMANYREFS, "ETOOMANYREFS", "Too many references: cannot splice"); - addcode(dict, ETIMEDOUT, "ETIMEDOUT", "Connection timed out"); - addcode(dict, ECONNREFUSED, "ECONNREFUSED", "Connection refused"); - addcode(dict, EHOSTDOWN, "EHOSTDOWN", "Host is down"); - addcode(dict, EHOSTUNREACH, "EHOSTUNREACH", "No route to host"); - addcode(dict, EALREADY, "EALREADY", "Operation already in progress"); - addcode(dict, EINPROGRESS, "EINPROGRESS", "Operation now in progress"); - addcode(dict, ESTALE, "ESTALE", "Stale NFS file handle"); - addcode(dict, EUCLEAN, "EUCLEAN", "Structure needs cleaning"); - addcode(dict, ENOTNAM, "ENOTNAM", "Not a XENIX named type file"); - addcode(dict, ENAVAIL, "ENAVAIL", "No XENIX semaphores available"); - addcode(dict, EISNAM, "EISNAM", "Is a named type file"); - addcode(dict, EREMOTEIO, "EREMOTEIO", "Remote I/O error"); - addcode(dict, EDQUOT, "EDQUOT", "Disk quota exceeded"); + public static void classDictInit(PyObject dict) { + for (Constant constant : ConstantSet.getConstantSet("Errno")) { + addCode(dict, constant.name(), constant.value(), constant.toString()); + } + // XXX: necessary? + addCode(dict, "ESOCKISBLOCKING", 20000, "Socket is in blocking mode"); + addCode(dict, "EGETADDRINFOFAILED", 20001, "getaddrinfo failed"); - // AMAK: starting a new series of jython specific errors - addcode(dict, ESOCKISBLOCKING, "ESOCKISBLOCKING", "Socket is in blocking mode"); - addcode(dict, EGETADDRINFOFAILED, "EGETADDRINFOFAILED", "getaddrinfo failed"); + // Hide from Python + dict.__setitem__("classDictInit", null); } - public static PyObject strerror(PyObject error) { - return strerror.__getitem__(error); + private static void addCode(PyObject dict, String name, int code, String message) { + PyObject nameObj = Py.newString(name); + PyObject codeObj = Py.newInteger(code); + dict.__setitem__(nameObj, codeObj); + errorcode.__setitem__(codeObj, nameObj); } - private static void addcode(PyObject dict, int errno, - String err, String msg) { - PyObject errno_o = Py.newInteger(errno); - PyObject err_o = Py.newString(err); - strerror.__setitem__(errno_o, Py.newString(msg)); - errorcode.__setitem__(errno_o, err_o); - dict.__setitem__(err_o, errno_o); + /** + * @deprecated Use org.python.core.constantine.Errno.valueOf(code).toString() (or + * os.strerror from Python) instead. + */ + @Deprecated + public static PyObject strerror(PyObject code) { + Py.warning(Py.DeprecationWarning, + "The errno.strerror function is deprecated, use os.strerror."); + return imp.load("os").__getattr__("strerror").__call__(code); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-11-14 00:28:51
|
Revision: 5577 http://jython.svn.sourceforge.net/jython/?rev=5577&view=rev Author: fwierzbicki Date: 2008-11-14 00:28:42 +0000 (Fri, 14 Nov 2008) Log Message: ----------- Thanks to Tor Norbye for this bug fix. This was also found via NetBeans. Modified Paths: -------------- trunk/jython/Lib/posixpath.py Modified: trunk/jython/Lib/posixpath.py =================================================================== --- trunk/jython/Lib/posixpath.py 2008-11-14 00:02:12 UTC (rev 5576) +++ trunk/jython/Lib/posixpath.py 2008-11-14 00:28:42 UTC (rev 5577) @@ -241,7 +241,7 @@ s2 = os.fstat(fp2) return samestat(s1, s2) - __all__append("sameopenfile") + __all__.append("sameopenfile") if os._native_posix: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-11-14 00:02:21
|
Revision: 5576 http://jython.svn.sourceforge.net/jython/?rev=5576&view=rev Author: pjenvey Date: 2008-11-14 00:02:12 +0000 (Fri, 14 Nov 2008) Log Message: ----------- fix itertools.chain stopping short with two empty iters in a row Modified Paths: -------------- trunk/jython/Lib/test/test_iter_jy.py trunk/jython/src/org/python/modules/itertools.java Modified: trunk/jython/Lib/test/test_iter_jy.py =================================================================== --- trunk/jython/Lib/test/test_iter_jy.py 2008-11-12 19:33:58 UTC (rev 5575) +++ trunk/jython/Lib/test/test_iter_jy.py 2008-11-14 00:02:12 UTC (rev 5576) @@ -2,6 +2,7 @@ Made for Jython. """ +import itertools from test import test_support import unittest @@ -23,7 +24,10 @@ return str(index) + '!' self.assertEqual(iter(MyStr('ab')).next(), '0!') + def test_chain(self): + self.assertEqual(list(itertools.chain([], [], ['foo'])), ['foo']) + def test_main(): test_support.run_unittest(IterTestCase) Modified: trunk/jython/src/org/python/modules/itertools.java =================================================================== --- trunk/jython/src/org/python/modules/itertools.java 2008-11-12 19:33:58 UTC (rev 5575) +++ trunk/jython/src/org/python/modules/itertools.java 2008-11-14 00:02:12 UTC (rev 5576) @@ -161,20 +161,14 @@ int iteratorIndex = 0; public PyObject __iternext__() { - if (iteratorIndex >= iterators.length) { - return null; - } - PyObject obj = nextElement(iterators[iteratorIndex]); - - if (obj == null) { - // increase the iteratorIndex and see if we have more - // iterators to work with - iteratorIndex++; - if (iteratorIndex < iterators.length) { - obj = nextElement(iterators[iteratorIndex]); + PyObject next = null; + for (; iteratorIndex < iterators.length; iteratorIndex++) { + next = nextElement(iterators[iteratorIndex]); + if (next != null) { + break; } } - return obj; + return next; } }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-11-12 19:34:01
|
Revision: 5575 http://jython.svn.sourceforge.net/jython/?rev=5575&view=rev Author: fwierzbicki Date: 2008-11-12 19:33:58 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Oops, try #2. That's what I get for doing this w/o having eclipse installed for verification. Modified Paths: -------------- trunk/jython/.classpath Modified: trunk/jython/.classpath =================================================================== --- trunk/jython/.classpath 2008-11-12 19:32:40 UTC (rev 5574) +++ trunk/jython/.classpath 2008-11-12 19:33:58 UTC (rev 5575) @@ -14,6 +14,6 @@ <classpathentry kind="lib" path="extlibs/servlet-api-2.5.jar"/> <classpathentry kind="lib" path="build/jarjar"/> <classpathentry kind="var" path="ANT_HOME/lib/ant.jar"/> - <classpathentry kind="lib" path="extlibs/antlr-runtime-3.1.1.jar"/> + <classpathentry kind="lib" path="extlibs/antlr-3.1.1-runtime.jar"/> <classpathentry kind="output" path="bugtests/classes"/> </classpath> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-11-12 19:32:43
|
Revision: 5574 http://jython.svn.sourceforge.net/jython/?rev=5574&view=rev Author: fwierzbicki Date: 2008-11-12 19:32:40 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Hopefully helping for eclipse users :). Modified Paths: -------------- trunk/jython/.classpath Modified: trunk/jython/.classpath =================================================================== --- trunk/jython/.classpath 2008-11-12 19:10:54 UTC (rev 5573) +++ trunk/jython/.classpath 2008-11-12 19:32:40 UTC (rev 5574) @@ -14,6 +14,6 @@ <classpathentry kind="lib" path="extlibs/servlet-api-2.5.jar"/> <classpathentry kind="lib" path="build/jarjar"/> <classpathentry kind="var" path="ANT_HOME/lib/ant.jar"/> - <classpathentry kind="lib" path="extlibs/antlr-runtime-3.1.jar"/> + <classpathentry kind="lib" path="extlibs/antlr-runtime-3.1.1.jar"/> <classpathentry kind="output" path="bugtests/classes"/> </classpath> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |