summaryrefslogtreecommitdiffstats
path: root/Lib/compiler
Commit message (Collapse)AuthorAgeFilesLines
* complete rewriteJeremy Hylton2000-03-162-800/+831
| | | | | | | | | code generator uses flowgraph as intermediate representation. the old rep uses a list with explicit "StackRefs" to indicate the target of jumps. pyassem converts flowgraph to bytecode, breaks up individual steps of generating bytecode
* simplify visitor walker classJeremy Hylton2000-03-161-32/+22
| | | | | | - remove postorder - remove protocol for automatically walking children based on visitor method return value; now only walks if there is no method
* fix list.append problemsJeremy Hylton2000-03-161-3/+3
|
* change name of Set method: items -> elements (avoids confusion withJeremy Hylton2000-03-161-1/+1
| | | | dict)
* import compile function form pycodegenJeremy Hylton2000-03-061-0/+4
|
* rename compile.py to pycodegen.pyJeremy Hylton2000-03-061-176/+25
| | | | | | | | | | fix imports remove parse functions and visitor code track name change: Classdef to Class add some comments and tweak order of visitXXX methods get rid of if __name__ == "__main__ section
* add a doc stringJeremy Hylton2000-03-061-0/+20
| | | | import some useful functions from contained modules
* fix import to refer to compiler packageJeremy Hylton2000-03-061-1/+1
|
* revise arguments for addCode method on lnotab. take several numbersJeremy Hylton2000-03-061-10/+13
| | | | that are internally converted to chars, rather than taking a string.
* change node Classdef to ClassJeremy Hylton2000-03-062-24/+25
| | | | | | | add doc string to transformer module add two helper functions: parse(buf) -> AST parseFile(path) -> AST
* factor out the tree walking/visitor code that was in compile.pyJeremy Hylton2000-03-061-0/+127
|
* satisfy the tabnanny (thanks to MH for noticing the problem)Jeremy Hylton2000-02-212-98/+98
|
* changes to _lookupNameJeremy Hylton2000-02-171-14/+13
| | | | | | - removed now (happily) unused second arg - need to verify results of [].index are correct; for building consts, need to have same value and same type, e.g. 2 not the same as 2L
* the previous quick hack to fix def foo((x,y)) failed on some casesJeremy Hylton2000-02-172-16/+48
| | | | | | | | | | | | | | | (big surprise). new solution is a little less hackish. Code gen adds a TupleArg instance in the argument slot. The tuple arg includes a copy of the names that it is responsble for binding. The PyAssembler uses this information to calculate the correct argcount. all fix this wacky case: del (a, ((b,), c)), d which is the same as: del a, b, c, d (Can't wait for Guido to tell me why.) solution uses findOp which walks a tree to find out whether it contains OP_ASSIGN or OP_DELETE or ...
* add varargs and kwargs flags to Lambda nodesJeremy Hylton2000-02-171-0/+5
|
* satisfy the tabnannyJeremy Hylton2000-02-171-197/+199
| | | | fix broken references to filename var in generateXXX methods
* support for arglists with implicit tuple unpacksJeremy Hylton2000-02-161-15/+61
| | | | | | | | | | | | | | - added a number of support methods to generate code just before the body - hack protocol for communicating number of args to PyAssembler fix TryExcept generation for case where exception handler has no body fix visitAssAttr add comment about incomplete visitAssName stop using the ExampleASTVisitor change script invocation to accept a list of .py files (e.g. Lib/*.py)
* more robust assignment of lineno for keyword argsJeremy Hylton2000-02-161-3/+3
| | | | | | | | get the lineno from the name of the keyword arg example of case that didn't work-- def foo(x, y, a = None, b = None):
* fix argcount generation for arg lists containing tuple unpacksJeremy Hylton2000-02-161-2/+13
| | | | this is sort of a hack
* add flatten helper functionJeremy Hylton2000-02-161-0/+11
|
* finish first impl of code generatorJeremy Hylton2000-02-151-12/+70
| | | | | add support for nodes TryExcept, TryFinally, Sliceobj fix visitSubscript to properly handle x[a,b,c]
* fix creation of Ellipsis nodeJeremy Hylton2000-02-151-1/+1
|
* add a little debugging support when new.code raises SystemErrorJeremy Hylton2000-02-151-5/+21
|
* add line numbers to nodes in the except clause (when possible)Jeremy Hylton2000-02-151-1/+3
|
* tidy up tryexcept and tryfinally nodesJeremy Hylton2000-02-151-14/+20
|
* edit a doc stringJeremy Hylton2000-02-141-1/+6
| | | | (real intent is to test out rsync install)
* get rid of spurious printJeremy Hylton2000-02-141-1/+0
|
* looks like everything is working except for try/except (pystoneJeremy Hylton2000-02-141-6/+14
| | | | compiles correctly)
* LeftShift & RightShift: fix reprs, change attr names to left and rightJeremy Hylton2000-02-141-10/+10
| | | | (so they are common with other binary ops)
* rename several of the generic attribute names for nodes. new node attrs are:Jeremy Hylton2000-02-141-12/+12
| | | | | | Exec: expr, locals, globals Dict: items Assert: test, fail
* (), [], and {} should not be represented as constant expressions, theyJeremy Hylton2000-02-141-3/+3
| | | | should be calls to BUILD_ ops for these types with no arguments
* split compile.py into two filesJeremy Hylton2000-02-142-536/+623
| | | | | add StackDepthFinder (and remove push/pop from CodeGen) add several nodes, including Ellipsis, Bit&|^, Exec
* change MODULE_NAMESPACE/FUNCTION_NAMESPACE stuff to have a single flagJeremy Hylton2000-02-121-34/+87
| | | | | | | | | | | | | | | | | named OPTIMIZED, which matches compile.c and makes more sense for classes revamp call signature for PythonVMCode.__init__; doesn't really matter 'cuz this code is going to be refactored out of existence add generateClassCode and modify Func & Lambda generation add support for nodes Classdef, Keyword, fix CallFunc to generate right op arg when calling w/ keywords add ugly hack to properly compute offsets when the same stack ref is used multiple times
* add support for Lambda nodesJeremy Hylton2000-02-111-8/+28
| | | | | | | change resolution of local name ops (LOAD_FAST). i think it makes sense now. if it is an argument or a local var name that it used, it must be in varnames. if it is a local var name that is used, it must also be in names
* add loop handling viaJeremy Hylton2000-02-101-13/+63
| | | | | | | Loop object to handle StackRegs loops stack attr on CodeGenreeator to hold the current loop object add support for nodes While, Break, Continue
* add an __len__ to Set and StackJeremy Hylton2000-02-101-0/+4
|
* add namespace attr to CodeGenerator, can be either MODULE_NAMESPACE orJeremy Hylton2000-02-101-22/+35
| | | | | | | | | | | FUNCTION_NAMESPACE. initialize in __init__ and reset in generateFunctionCode. replace direct issue of STORE_FAST, STORE_GLOBAL, etc. with call to storeName; same for loadName and deleteName the new {store,load,delete}Name methods use the namespace attr and the local variable stack to determine the correct bytecode to issue
* add ExampleASTVisitor:Jeremy Hylton2000-02-101-55/+199
| | | | | | | | | | | | | | | | | | | | | | * prints out examples of nodes that are handled by visitor. simply a development convenience remove NestedCodeGenerator -- it was bogus after all replace with generateFunctionCode, a method to call to generate code for a function instead of a top-level module fix impl of visitDiscard (most pop stack) emit lineno for pass handle the following new node types: Import, From, Getattr, Subscript, Slice, AssAttr, AssTuple, Mod, Not, And, Or, List LocalNameFinder: remove names declared as globals for locals PythonVMCode: pass arg names to constructor, force varnames to contain them all (even if they aren't referenced) add -q option on command line to disable stdout
* add remove method to setJeremy Hylton2000-02-101-0/+2
|
* add optional verbose arg to walk function. it overrides the globalJeremy Hylton2000-02-081-29/+137
| | | | | | | | | | | | | | | | VERBOSE setting for the ASTVisitor add getopt handling for one or more -v args rename ForwardRef to StackRef, because it isn't necessarily directional CodeGenerator: * add assertStackEmpty method. prints warning if stack is not empty when it should be * define methods for AssName, UNARY_*, For PythonVMCode: * fix mix up between hasjrel and hasjabs for address calculation
* make all unary operators have a single child node called exprJeremy Hylton2000-02-081-4/+4
|
* add spaces to comparison names is not and not in to match disJeremy Hylton2000-02-081-2/+2
|
* now produces valid pyc files for a least a trivial subset of theJeremy Hylton2000-02-081-80/+306
| | | | | | | | | | | | | | | | | language. CodeGenerator: * modify to track stack depth * add emit method that call's PythonVMCode's makeCodeObject * thread filenames through in hackish way * set flags for code objects for modules and functions XXX the docs for the flags seem out of date and/or incomplete PythonVMCode: * add doc string describing the elements of a real code object LineAddrTable: * creates an lnotab (no quite correctly though)
* constants from transformerJeremy Hylton2000-02-081-0/+9
|
* move constants out of transformer so that they can be shared with astJeremy Hylton2000-02-082-8/+9
| | | | add varargs and kwargs attributes to Function nodes
* rapid evolution towards producing real .pyc files (even though I don'tJeremy Hylton2000-02-041-11/+176
| | | | | | | | | | | | | | | | | handle most of the language syntax yet) create NestedCodeGenerator used to generator the separate code object that needs to be passed as an argument to MAKE_FUNCTION when a def stmt is found (probably useful for class too) change CodeGenerator.visitFunction to use the NestedCG add CompiledModule class to handle creation of .pyc (pretty minimal for now) add makeCodeObject method to PythonVMCode that replaces symbolic names with indexes into slots of the code code. the design of this class will probably need to be revised.
* checking in initial weekend's workJeremy Hylton2000-02-042-0/+424
| | | | | | | | | compile.py: ASTVisitor framework plus bits of a code generator that should be bug-for-buf compatible with compile.c misc.py: Set and Stack helpers test.py: a bit of simple sample code that compile.py will work on
* make p2c a packageJeremy Hylton2000-02-041-0/+0
|
* three files from the p2c cvs tree. the message here indicates theJeremy Hylton2000-02-042-0/+1893
revision number the p2c cvs tree. COPYRIGHT: 1.1 ast.py: 1.3 transformer.py: 1.11