summaryrefslogtreecommitdiffstats
path: root/Lib/compiler
Commit message (Collapse)AuthorAgeFilesLines
* SF patch #701494: more apply removalsRaymond Hettinger2003-04-061-1/+1
|
* Whitespace normalization.Tim Peters2003-03-071-1/+1
|
* Remove debugging prints.Michael W. Hudson2003-01-031-2/+0
|
* 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-314-44/+69
| | | | | | | | | | | | | | | | | 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-063-11/+7
|
* Fix com_arglist() and update grammar fragment.Jeremy Hylton2002-04-191-6/+3
| | | | | | | | | | | | | | | | | SF bug #522264 reported by Evelyn Mitchell. The code included a comment about "STAR STAR" which was translated into the code as the bogus attribute token.STARSTAR. This name never caused an attribute error because it was never retrieved. The code was based on an old version of the grammar that specified kwargs as two tokens ('*' '*'). I checked as far back as 2.1 and didn't find this production. The fix is simple, because token.DOUBLESTAR is the only token allowed. Also update the grammar fragment in com_arglist(). XXX I'll bet lots of other grammar fragments in comments are out of date, probably in this module and in compile.c.
* Remove more out-of-date comments and clarify explanation of visit().Jeremy Hylton2002-04-181-7/+1
|
* Remove out-of-date explanation in doc strings,Jeremy Hylton2002-04-181-3/+1
| | | | as reported by Eric C. Newton.
* Patch #522279: transformer.py nodes shadows global.Martin v. Löwis2002-02-281-3/+3
|
* Patch #521714: fix pychecker warnings in ast.py.Martin v. Löwis2002-02-231-124/+124
|
* Whitespace normalization.Tim Peters2002-02-161-1/+1
|
* Merge of the release22 branch changes back into the trunk.Barry Warsaw2001-12-214-4/+27
|
* 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-189-56/+53
|
* Vastly improved stacksize calculation.Jeremy Hylton2001-10-171-18/+51
| | | | | | | | | | | | | | | | | | | | | There are now no known cases where the compiler package computes a stack depth lower than the one computed by the builtin compiler. (To achieve this state, we had to fix bugs in both compilers :-). The chief change is to do the depth calculations with respect to basic blocks. The stack effect of block is calculated. Then the flow graph is traversed using breadth-first search to find the max weight path through the graph. Had to fix the StackDepthTracker to calculate the right info for several opcodes: LOAD_ATTR, CALL_FUNCTION (and friends), MAKE_CLOSURE, and DUP_TOPX. XXX Still need to handle free variables in MAKE_CLOSURE. XXX There are still a lot of places where the computed stack depth is larger than for the builtin compiler. These won't cause the interpreter to overflow the frame, but they waste space.
* Handle testlist_safe as if it were testlist.Jeremy Hylton2001-10-171-0/+4
|
* Fix comment typoAndrew M. Kuchling2001-09-271-1/+1
|
* API change:Jeremy Hylton2001-09-173-10/+109
| | | | | | | | | | | | | | | | | | 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.
* Re-created after change to astgen to calculate hardest_arg correctlyJeremy Hylton2001-09-171-577/+603
|
* Last set of change to get regression tests to passJeremy Hylton2001-09-173-5/+10
| | | | | | | | | | | 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-172-29/+77
| | | | | | | | 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.
* Add utility to set filename attribute on all nodesJeremy Hylton2001-09-171-0/+9
|
* support true divisionJeremy Hylton2001-09-171-1/+3
|
* Add code generator for yield stmtJeremy Hylton2001-09-141-0/+5
|
* del no longer necessary now that new module is goneJeremy Hylton2001-09-141-2/+0
|
* Various sundry changes for 2.2 compatibilityJeremy Hylton2001-09-142-137/+94
| | | | | | | | | | | | | | | 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.
* The object-being sliced in an assignment to a slice is referenced, notJeremy Hylton2001-09-141-2/+2
| | | | | | | bound. When a Yield() node is visited, assign to the generator attribute of the scope, not the visitor.
* the new new doesn't define CO_xxx as the old new didJeremy Hylton2001-09-141-1/+9
|
* the names attribute of Global is not a nodeJeremy Hylton2001-09-141-1/+1
|
* Fix _convert_NAME() so that it doesn't store locals for class bodies.Jeremy Hylton2001-08-303-15/+15
| | | | | | | | | 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.
* Improve stack depth computation for try/except and try/finallyJeremy Hylton2001-08-291-1/+4
| | | | Add CONTINUE_LOOP to the list of unconditional transfers
* Add __getitem__() handler for use by visitContinue()Jeremy Hylton2001-08-291-0/+2
|
* 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.
* Make sure that atoms (Tuple, List, etc.) have lineno attributesJeremy Hylton2001-08-291-2/+4
|
* Fix off-by-one errors in code to find depth of stack.Jeremy Hylton2001-08-291-3/+3
| | | | | XXX The code is still widely inaccurate, but most (all?) of the time it's an overestimate.
* Undo change from list to dict for handling varnames, consts, etc.Jeremy Hylton2001-08-291-49/+22
| | | | | | | | | | As the doc string for _lookupName() explains: This routine uses a list instead of a dictionary, because a dictionary can't store two different keys if the keys have the same value but different types, e.g. 2 and 2L. The compiler must treat these two separately, so it does an explicit type comparison before comparing the values.
* Change default() to use getChildNodes() instead of getChildren()Jeremy Hylton2001-08-291-3/+2
|
* 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.
* Add support for // and //=.Jeremy Hylton2001-08-291-5/+16
| | | | | | | | Avoid if/elif/elif/else tests where the final else is supposed to handle exactly one case instead of all other cases. When the list of operators is extended, the catchall else treats all new operators as the last operator in the set of tests. Instead, raise an exception if an unexpected operator occurs.
* Add generator detection to symbol table.Jeremy Hylton2001-08-291-9/+35
| | | | | Fix bug in handling of statements like "l[x:y] = 2". The visitor was treating this as assignments to l, x, and y!
* Modify name conversion to be (hopefully) a bit more efficient.Jeremy Hylton2001-08-291-17/+52
| | | | | | | | Use a dictionary instead of a list to map objects to their offsets in a const/name tuple of a code object. XXX The conversion is perhaps incomplete, in that we shouldn't have to do the list2dict to start.
* Revise implementations of getChildren() and getChildNodes().Jeremy Hylton2001-08-291-100/+602
| | | | | | | | | | | | | | | | Add support for floor division (// and //=) The implementation of getChildren() and getChildNodes() is intended to be faster, because it avoids calling flatten() on every return value. But it's not clear that it is a lot faster, because constructing a tuple with just the right values ends up being slow. (Too many attribute lookups probably.) The ast.txt file is much more complicated, with funny characters at the ends of names (*, &, !) to indicate the types of each child node. The astgen script is also much more complex, making me wonder if it's still useful.
* Don't include doc string of class in its code childJeremy Hylton2001-08-291-0/+5
|
* Make sure the JUMP_ABSOLUTE and POP_BLOCK at the end of a for loop areJeremy Hylton2001-08-281-1/+1
| | | | contiguous.
* XXX_NAME ops should affect varnamesJeremy Hylton2001-08-281-1/+4
| | | | | | varnames should list all the local variables (with arguments first). The XXX_NAME ops typically occur at the module level and assignment ops should create locals.