summaryrefslogtreecommitdiffstats
path: root/Lib/compiler/pycodegen.py
Commit message (Collapse)AuthorAgeFilesLines
* Patch #1638243: the compiler package is now able to correctly compileGeorg Brandl2007-01-271-0/+2
| | | | | a with statement; previously, executing code containing a with statement compiled by the compiler package crashed the interpreter.
* Remove trailing comma.Georg Brandl2006-10-291-1/+1
|
* Bug #1586448: the compiler module now emits the same bytecode forGeorg Brandl2006-10-291-7/+5
| | | | | list comprehensions as the builtin compiler, using the LIST_APPEND opcode.
* Fix a bug in the ``compiler`` package that caused invalid code to beNeil Schemenauer2006-08-161-5/+14
| | | | generated for generator expressions.
* Fix the 'compiler' package to generate correct code for MAKE_CLOSURE.Neil Schemenauer2006-08-041-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.
* Get rid of __context__, per the latest changes to PEP 343 and python-devGuido van Rossum2006-05-021-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.
* Teach the compiler module about augmented assignment to tuple subscriptsNick Coghlan2006-03-141-4/+2
|
* Um, I thought I'd already checked this in.Guido van Rossum2006-03-101-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.
* Fix compiler breakage related to absolute importsNeal Norwitz2006-03-031-2/+2
|
* Hopefully this removes all vestiges of CO_GENERATOR_ALLOWED that canNeal Norwitz2006-03-031-3/+1
| | | | be removed in 2.x.
* Add support for absolute/relative imports and if/else expressions:Thomas Wouters2006-03-031-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.
* Update the compiler package to compile the with-statement.Guido van Rossum2006-02-281-0/+41
| | | | Jeremy, please review!
* No need for types, use isinstanceNeal Norwitz2005-11-251-5/+4
|
* Whitespace normalization.Tim Peters2004-08-201-1/+1
|
* This is Mark Russell's patch:Michael W. Hudson2004-08-171-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)
* SF patch 836879.Jeremy Hylton2004-08-071-21/+19
| | | | Don't generate code for asserts in -O mode.
* Whitespace normalization.Tim Peters2004-08-041-2/+2
|
* PEP-0318, @decorator-style. In Guido's words:Anthony Baxter2004-08-021-0/+10
| | | | | "@ seems the syntax that everybody can hate equally" Implementation by Mark Russell, from SF #979728.
* Whitespace normalization.Tim Peters2004-07-071-1/+1
|
* SF patch #872326: Generator expression implementationRaymond Hettinger2004-05-191-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.
* Remove unused instance attributes.Neil Schemenauer2004-03-211-2/+0
|
* Jacob Hallen cornered me here at EuroPython and got me to look atMichael W. Hudson2003-06-271-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.
* Replace all but one explicit emit('SET_LINENO') with call to set_lineno().Jeremy Hylton2002-12-311-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).
* SF patch [ 597919 ] compiler package and SET_LINENOJeremy Hylton2002-12-311-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.
* Fixing bugGustavo Niemeyer2002-12-161-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.
* Remove uses of string module and stat.ST_MODENeal Norwitz2002-06-061-5/+3
|
* Whitespace normalization.Tim Peters2002-02-161-1/+1
|
* Merge of the release22 branch changes back into the trunk.Barry Warsaw2001-12-211-3/+9
|
* Fix [ #484645 ] little bug in pycodegen.pyJeremy Hylton2001-11-271-1/+1
|
* Fix SF bug #479186: compiler generates bad code for "del"Jeremy Hylton2001-11-091-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.
* Whitespace normalization.Tim Peters2001-10-181-19/+19
|
* API change:Jeremy Hylton2001-09-171-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.
* Last set of change to get regression tests to passJeremy Hylton2001-09-171-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
* Handle more syntax errors.Jeremy Hylton2001-09-171-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.
* support true divisionJeremy Hylton2001-09-171-1/+3
|
* Add code generator for yield stmtJeremy Hylton2001-09-141-0/+5
|
* Various sundry changes for 2.2 compatibilityJeremy Hylton2001-09-141-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.
* Fix _convert_NAME() so that it doesn't store locals for class bodies.Jeremy Hylton2001-08-301-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
* spurious popJeremy Hylton2001-08-301-1/+0
|
* Track the block stack more reasonably in order to handle continue inJeremy Hylton2001-08-291-13/+45
| | | | | | | | try/except or try/finally. Previous versions had only track SETUP_LOOP blocks and ignored the exception part. This meant that it allowed continue inside a try/except but generated buggy code. Now it does the right thing.
* Generate SET_LINENO for list and tuple literals when the open parenJeremy Hylton2001-08-291-1/+3
| | | | | | | starts a new line. Also fix undetected typo in visitDict() -- uncovered by recent change to add lineno attrs to atoms.
* Support // and //=Jeremy Hylton2001-08-291-1/+6
| | | | | | | Generate SET_LINENO for del statements. Define klass=1 for PyFlowGraph constructor for a class statement. A class has no varnames.
* Make sure the JUMP_ABSOLUTE and POP_BLOCK at the end of a for loop areJeremy Hylton2001-08-281-1/+1
| | | | contiguous.
* Generate FOR_ITER-based loops instead of old FOR_LOOP-based loopsJeremy Hylton2001-08-281-5/+9
|
* Handle private namesJeremy Hylton2001-08-271-13/+24
| | | | | | | | | | | | | | | | | | | (Hard to believe these were never handled before) Add misc.mangle() that mangles based on the rules in compile.c. XXX Need to test the corner cases Update CodeGenerator with a class_name attribute bound to None. If a particular instance is created within a class scope, the instance's class_name is bound to that class's name. Add mangle() method to CodeGenerator that mangles if the class_name has a class_name in it. Modify the FunctionCodeGenerator family to handle an extra argument-- the class_name. Wrap all name ops and attrnames in calls to self.mangle()
* emit SET_LINENO for augmented assignmentsJeremy Hylton2001-08-271-0/+4
|
* Many changes -- bug fixes and sundry improvementsJeremy Hylton2001-08-271-33/+30
| | | | | | | | | | | | | | | | Make nested scopes enabled by default Add is_constant_false() helper so that compiled code and symbols are consistent with builtin compiler's handling of "if 0:" Fix doc string handling to be consistent with recent change that eliminates the doc string from the Module's node attribute. Add fix to print handling from Evan & Shane. Track change to visitor api by making "verbose" explicit. Comment out setting CO_NESTED flag (it's unnecessary in 2.2).
* Pop loop off the loop stack before handling the loop's else clause.Jeremy Hylton2001-04-121-4/+4
| | | | | | Otherwise, continue/break will attempt to affect the wrong loop. A few more fiddles to get the SET_LINENOs consistent across compilers.
* Use new _implicitNameOp() to generate name op code for list comprehensions.Jeremy Hylton2001-04-121-4/+17
| | | | | | | | | Always emit a SET_LINENO 0 at the beginning of the module. The builtin compiler does this, and it's much easier to compare bytecode generated by the two compilers if they both do. Move the SET_LINENO inside the FOR_LOOP block for list comprehensions. Also for compat. with builtin compiler.
* Add support for visitAssAttr to findOp().Jeremy Hylton2001-04-121-1/+1
|