Re: More jython progress.
Finn Bock <[email protected]> Thu, 23 May 2002 19:13:32 +0200
| Newsgroups | gmane.comp.python.compiler |
|---|---|
| Message-ID | <[email protected]> |
[Eric C. Newton] >>In jython we have a scope analyzer that analyze a module and return >>symboltables for module, class and function levels. I guess CPython must >>also have some such thing. > > The python version of the compiler has such a pass: compiler.symbols I didn't know that. Thank you for the info. >>Similar we have future analyzer. Should we define a public API to this? > > What does the future analyzer do? It simply return an object with properties 'nested_scope' and 'division' (in 2.1). It indicate which 'from __future__ import xxx' statement that was discovered in the module. >>The sequences in the asdl becomes java arrays. That means that the >>elements in a sequence can be changed but the length of the sequence >>can't. I think we should ban all attempts to modify the sequences. > > I'm modifying the tree structure in only one case in PyChecker2, and I > think I can live without it. The tree can still be modified, it is just the sequences that can't. It is perfectly valid to assign a new sequence (list or tuple) to a sequence attribute. I just want us to ban appending (and deleting) nodes to a sequence. > I'm adding attributes to the tree _everywhere_. As PyChecker2 grinds > over the tree, it adds discovered information to the tree (things like > type information and cross-references). I can probably live without > it by tracking the information somewhere else. Yeah, but you want to live without the ability to add new class instance attributes? In the old SimpleNode AST tree jython had over time added several attributes to the nodes (such as scope info). So it obviously is usefull. If we decide that the AST node must support attributes then I can also add it to jython. I can simple do a kind of deepcopy of the tree that returns real class instances in place of the java instances. It will just make the AST tree building from python a little slower. I don't think such dynamic attributes will survice across several compiler passes. If f.ex a peephole optimizer is implemented in C the tree must be pickled, optimized and unpickled. All dynamic attributes will be lost. Thank you for your comments. regards, finn