[Compiler-sig] FYI: python/nondist/src/Compiler
Mark Hammond
mhammond@skippinet.com.au
Tue, 22 Feb 2000 09:44:33 +1100
[Jeremy writes]
> Do tell! What is this other project?
If I told you, I would have to kill you! :-)
> MH> So, I had a think about reusing some of this framework for other
> MH> compilers, and come to the conclusion that not as much as I had
> MH> hoped can be shared ( But still enough that it makes it
> MH> worthwhile. I can see the P2C directory stuff being shared,
> MH> along with the basic tree stuff you have.
>
> It depends what the next steps for any of these compilers are. The
> code I have checked in is pretty primitive; there isn't much to share,
> just because there isn't much there at all.
The "problem" I saw was simply that your code is very tied to Python
byte-code - which is what you would expect for a byte-code compiler :-)
Your code shares quite a bit of logic with (say) P2C, but it is sprinkled in
the middle of the emit() calls - ie, while the general logic is the same, I
couldnt see an obvious way to remove the knowledge of the specific
interpreter/vm you are targetting.
> I hope to refactor the pyassem module and revise the code generator a
> bit. Instead of emitting straight-line code, with refs -- misnamed
> StackRefs -- to other locations in the instruction stream, I would
> like to generate code blocks that contain references to other blocks.
> This intermediate representation would be more amenable to analysis
> and still easy to generate bytecode from.
What is your intention with this compiler? To be an emulation of the
existing compiler or to become an (optionally) optimizing compiler?
> I had hoped to do some dataflow analysis, but won't have time to work
> on it in the near future. It's also possible that Jon Riehl will
> release his dataflow code soon, which might make sense to incorporate
> as part of the standard tool suite.
Cool! What I personally have a need for is some sort of "name/type
tracking" - at this stage limited to simple assignments within a scoped
block. Eg:
class C: pass
c = C()
d = c
I would dearly like a system that could tell me that c and d are instances
of the class C.
But I also recognize how quickly that becomes a general type inferencing
problem, and I dont have the time to get sidetracked by that right now
(especially when a few very smart people have already stated their intention
:-) So Im just punting that for now :-)
Mark.