From: <zy...@us...> - 2008-09-01 06:32:49
|
Revision: 5279 http://jython.svn.sourceforge.net/jython/?rev=5279&view=rev Author: zyasoft Date: 2008-09-01 06:32:39 +0000 (Mon, 01 Sep 2008) Log Message: ----------- The compile builtin function now can take an AST node, as produced by a previous usage of compile with the compiler flag _ast.PyCF_ONLY_AST. Generally this would be after some modification of the AST itself. Another 2.6 feature. Modified Paths: -------------- trunk/jython/src/org/python/core/Py.java trunk/jython/src/org/python/core/__builtin__.java Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2008-09-01 04:21:27 UTC (rev 5278) +++ trunk/jython/src/org/python/core/Py.java 2008-09-01 06:32:39 UTC (rev 5279) @@ -1677,7 +1677,16 @@ } return Py.compile_flags(node, getName(), filename, true, printResults, cflags); } - + + public static PyObject compile_flags(modType node, String filename, + String kind, CompilerFlags cflags) { + boolean printResults = false; + if (kind.equals("single")) { + printResults = true; + } + return Py.compile_flags(node, getName(), filename, true, printResults, cflags); + } + public static PyObject compile_flags(String data, String filename, String kind, @@ -1941,7 +1950,6 @@ return (PyObject[]) objs.getArray(); } } - /** @deprecated */ class FixedFileWrapper extends StdoutWrapper { Modified: trunk/jython/src/org/python/core/__builtin__.java =================================================================== --- trunk/jython/src/org/python/core/__builtin__.java 2008-09-01 04:21:27 UTC (rev 5278) +++ trunk/jython/src/org/python/core/__builtin__.java 2008-09-01 06:32:39 UTC (rev 5279) @@ -5,6 +5,7 @@ import java.util.Iterator; import java.util.Map; +import org.python.antlr.ast.modType; import org.python.core.util.RelativeFile; import org.python.expose.ExposedGet; @@ -459,6 +460,10 @@ return Py.compile_flags(data, filename, kind, Py.getCompilerFlags()); } + public static PyObject compile(modType node, String filename, String kind) { + return Py.compile_flags(node, filename, kind, Py.getCompilerFlags()); + } + public static PyObject compile(String data, String filename, String kind, int flags, boolean dont_inherit) { if ((flags & ~PyTableCode.CO_ALL_FEATURES) != 0) { throw Py.ValueError("compile(): unrecognised flags"); @@ -466,6 +471,13 @@ return Py.compile_flags(data, filename, kind, Py.getCompilerFlags(flags, dont_inherit)); } + public static PyObject compile(modType node, String filename, String kind, int flags, boolean dont_inherit) { + if ((flags & ~PyTableCode.CO_ALL_FEATURES) != 0) { + throw Py.ValueError("compile(): unrecognised flags"); + } + return Py.compile_flags(node, filename, kind, Py.getCompilerFlags(flags, dont_inherit)); + } + public static void delattr(PyObject o, String n) { o.__delattr__(n); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |