summaryrefslogtreecommitdiff
path: root/Lib/compiler/pycodegen.py
AgeCommit message (Collapse)AuthorLines
2012-07-02Issue #15212: fix typo in compiler module (rename SC_GLOBAL_EXPLICT to ↵Antoine Pitrou-2/+2
SC_GLOBAL_EXPLICIT). Patch by Arfrever.
2010-01-11Issue #2333: Backport set and dict comprehensions syntax.Alexandre Vassalotti-0/+49
2010-01-09Issue #2335: Backport set literals syntax from Python 3.x.Alexandre Vassalotti-0/+6
2010-01-04Issue #7092: Fix the DeprecationWarnings emitted by the standard libraryAntoine Pitrou-2/+2
when using the -3 flag. Patch by Florent Xicluna.
2009-02-28Backport r69961 to trunk, replacing JUMP_IF_{TRUE,FALSE} withJeffrey Yasskin-35/+12
POP_JUMP_IF_{TRUE,FALSE} and JUMP_IF_{TRUE,FALSE}_OR_POP. This avoids executing a POP_TOP on each conditional and sometimes allows the peephole optimizer to skip a JUMP_ABSOLUTE entirely. It speeds up list comprehensions significantly.
2009-02-07Issue #999042: The Python compiler now handles explict global statementsNeil Schemenauer-2/+5
correctly (should be assigned using STORE_GLOBAL opcode). This was done by having the system table differentiate between explict and implicit globals.
2009-02-07Make names generated for 'with' variables match the built-in compiler.Neil Schemenauer-1/+1
2009-02-06Overhaul Lib/compiler block ordering. The previous code was filled withNeil Schemenauer-1/+1
hacks. The new code is based on issue #2472 posted by Antoine Pitrou. I did some further cleanups of the pyassem code and optimized the block ordering pass.
2008-12-17Issue #2183: Simplify and optimize bytecode for list comprehensions.Antoine Pitrou-11/+1
2008-03-19Fixed compiler module so __future__ print_function is compilable.Eric Smith-1/+3
2008-03-07Speed up with statements by storing the __exit__ method on the stack instead ↵Nick Coghlan-4/+1
of in a temp variable (bumps the magic number for pyc files)
2007-01-27Patch #1638243: the compiler package is now able to correctly compileGeorg Brandl-0/+2
a with statement; previously, executing code containing a with statement compiled by the compiler package crashed the interpreter.
2006-10-29Remove trailing comma.Georg Brandl-1/+1
2006-10-29Bug #1586448: the compiler module now emits the same bytecode forGeorg Brandl-7/+5
list comprehensions as the builtin compiler, using the LIST_APPEND opcode.
2006-08-16Fix a bug in the ``compiler`` package that caused invalid code to beNeil Schemenauer-5/+14
generated for generator expressions.
2006-08-04Fix the 'compiler' package to generate correct code for MAKE_CLOSURE.Neil Schemenauer-26/+13
In the 2.5 development cycle, MAKE_CLOSURE as changed to take free variables as a tuple rather than as individual items on the stack. Closes patch #1534084.
2006-05-02Get rid of __context__, per the latest changes to PEP 343 and python-devGuido van Rossum-2/+0
discussion. There are two places of documentation that still mention __context__: Doc/lib/libstdtypes.tex -- I wasn't quite sure how to rewrite that without spending a whole lot of time thinking about it; and whatsnew, which Andrew usually likes to change himself.
2006-03-14Teach the compiler module about augmented assignment to tuple subscriptsNick Coghlan-4/+2
2006-03-10Um, I thought I'd already checked this in.Guido van Rossum-2/+0
Anyway, this is the changes to the with-statement so that __exit__ must return a true value in order for a pending exception to be ignored. The PEP (343) is already updated.
2006-03-03Fix compiler breakage related to absolute importsNeal Norwitz-2/+2
2006-03-03Hopefully this removes all vestiges of CO_GENERATOR_ALLOWED that canNeal Norwitz-3/+1
be removed in 2.x.
2006-03-03Add support for absolute/relative imports and if/else expressions:Thomas Wouters-2/+26
- regenerate ast.py - add future flags for absolute-import and with-statement so they (hopefully) properly get set in code-object flags - try out if/else expressions in actual code for the hell of it. Seems to generate the same kind of bytecode as the normal compiler.
2006-02-28Update the compiler package to compile the with-statement.Guido van Rossum-0/+41
Jeremy, please review!
2005-11-25No need for types, use isinstanceNeal Norwitz-5/+4
2004-08-20Whitespace normalization.Tim Peters-1/+1
2004-08-17This is Mark Russell's patch:Michael W. Hudson-2/+2
[ 1009560 ] Fix @decorator evaluation order From the description: Changes in this patch: - Change Grammar/Grammar to require newlines between adjacent decorators. - Fix order of evaluation of decorators in the C (compile.c) and python (Lib/compiler/pycodegen.py) compilers - Add better order of evaluation check to test_decorators.py (test_eval_order) - Update the decorator documentation in the reference manual (improve description of evaluation order and update syntax description) and the comment: Used Brett's evaluation order (see http://mail.python.org/pipermail/python-dev/2004-August/047835.html) (I'm checking this in for Anthony who was having problems getting SF to talk to him)
2004-08-07SF patch 836879.Jeremy Hylton-21/+19
Don't generate code for asserts in -O mode.
2004-08-04Whitespace normalization.Tim Peters-2/+2
2004-08-02PEP-0318, @decorator-style. In Guido's words:Anthony Baxter-0/+10
"@ seems the syntax that everybody can hate equally" Implementation by Mark Russell, from SF #979728.
2004-07-07Whitespace normalization.Tim Peters-1/+1
2004-05-19SF patch #872326: Generator expression implementationRaymond Hettinger-0/+89
(Code contributed by Jiwon Seo.) The documentation portion of the patch is being re-worked and will be checked-in soon. Likewise, PEP 289 will be updated to reflect Guido's rationale for the design decisions on binding behavior (as described in in his patch comments and in discussions on python-dev). The test file, test_genexps.py, is written in doctest format and is meant to exercise all aspects of the the patch. Further additions are welcome from everyone. Please stress test this new feature as much as possible before the alpha release.
2004-03-21Remove unused instance attributes.Neil Schemenauer-2/+0
2003-06-27Jacob Hallen cornered me here at EuroPython and got me to look atMichael W. Hudson-1/+5
patch: [ 750008 ] 'compiler' module bug with 'import foo.bar as baz' which I'm now checking in. after import foo.bar as baz, baz would refer to foo.
2002-12-31Replace all but one explicit emit('SET_LINENO') with call to set_lineno().Jeremy Hylton-8/+2
Remove broken code in visitDict(). I assume the code was trying to add set lineno events for each line of a dict constructor, but I think it was using the wrong object (node instead of k or v).
2002-12-31SF patch [ 597919 ] compiler package and SET_LINENOJeremy Hylton-27/+28
A variety of changes from Michael Hudson to get the compiler working with 2.3. The primary change is the handling of SET_LINENO: # The set_lineno() function and the explicit emit() calls for # SET_LINENO below are only used to generate the line number table. # As of Python 2.3, the interpreter does not have a SET_LINENO # instruction. pyassem treats SET_LINENO opcodes as a special case. A few other small changes: - Remove unused code from pycodegen and pyassem. - Fix error handling in parsermodule. When PyParser_SimplerParseString() fails, it sets an exception with detailed info. The parsermodule was clobbering that exception and replacing it was a generic "could not parse string" exception. Keep the original exception.
2002-12-16Fixing bugGustavo Niemeyer-2/+2
[#448679] Left to right * Python/compile.c (com_dictmaker): Reordered evaluation of dictionaries to follow strict LTR evaluation. * Lib/compiler/pycodegen.py (CodeGenerator.visitDict): Reordered evaluation of dictionaries to follow strict LTR evaluation. * Doc/ref/ref5.tex Documented the general LTR evaluation order idea. * Misc/NEWS Documented change in evaluation order of dictionaries.
2002-06-06Remove uses of string module and stat.ST_MODENeal Norwitz-5/+3
2002-02-16Whitespace normalization.Tim Peters-1/+1
2001-12-21Merge of the release22 branch changes back into the trunk.Barry Warsaw-3/+9
2001-11-27Fix [ #484645 ] little bug in pycodegen.pyJeremy Hylton-1/+1
2001-11-09Fix SF bug #479186: compiler generates bad code for "del"Jeremy Hylton-0/+1
Fix by Neil Schemenauer. Visit the Subscript node when trying to find the operation for a statement. XXX Not sure if there are other nodes that should be visited.
2001-10-18Whitespace normalization.Tim Peters-19/+19
2001-09-17API change:Jeremy Hylton-5/+95
compile() becomes replacement for builtin compile() compileFile() generates a .pyc from a .py both are exported in __init__ compiler.parse() gets optional second argument to specify compilation mode, e.g. single, eval, exec Add AbstractCompileMode as parent class and Module, Expression, and Interactive as concrete subclasses. Each corresponds to a compilation mode. THe AbstractCompileMode instances in turn delegate to CodeGeneration subclasses specialized for their particular functions -- ModuleCodeGenerator, ExpressionCodeGeneration, InteractiveCodeGenerator.
2001-09-17Last set of change to get regression tests to passJeremy Hylton-1/+1
Remove the only test in the syntax module. It ends up that the transformer must handle this error case. In the transformer, check for a list compression in com_assign_list() by looking for a list_for node where a comma is expected. In pycodegen.compile() re-raise the SyntaxError rather than catching it and exiting
2001-09-17Handle more syntax errors.Jeremy Hylton-29/+32
Invoke compiler.syntax.check() after building AST. If a SyntaxError occurs, print the error and exit without generating a .pyc file. Refactor code to use compiler.misc.set_filename() rather than passing filename argument around to each CodeGenerator instance.
2001-09-17support true divisionJeremy Hylton-1/+3
2001-09-14Add code generator for yield stmtJeremy Hylton-0/+5
2001-09-14Various sundry changes for 2.2 compatibilityJeremy Hylton-133/+89
Remove the option to have nested scopes or old LGB scopes. This has a large impact on the code base, by removing the need for two variants of each CodeGenerator. Add a get_module() method to CodeGenerator objects, used to get the future features for the current module. Set CO_GENERATOR, CO_GENERATOR_ALLOWED, and CO_FUTURE_DIVISION flags as appropriate. Attempt to fix the value of nlocals in newCodeObject(), assuming that nlocals is 0 if CO_NEWLOCALS is not defined.
2001-08-30Fix _convert_NAME() so that it doesn't store locals for class bodies.Jeremy Hylton-4/+7
Fix list comp code generation -- emit GET_ITER instead of Const(0) after the list. Add CO_GENERATOR flag to generators. Get CO_xxx flags from the new module
2001-08-30spurious popJeremy Hylton-1/+0