From: Ype K. <yk...@xs...> - 2002-03-04 19:41:48
|
Joshua, >I'm interested in learning more about how jythonc works. I see that it produces an intermediate file which is then compiled to bytecode with javac. > >A few questions come to mind: > >Did the creators consider using Java as an intermediate, rather than generating bytecode directly (OK, Java source code is easier to produce, but isn't it possible to compile non-Java directly to bytecode?) Iirc, the early versions of JPython compiled to java and did not incorparate a byte code generator. Current versions include a byte code generator. You can see the java code generated by the jython compiler by using an option to jythonc. >Why is the absolute path of the *.py file embedded into the generated *.java file, and thence in the bytecode? What use could that be, considering that we can certainly move class files around? This is to allow a __file__ attribute on some standard objects (ao. on modules). In case you need to move a *$py.class file around it is generally better to move the *.py file and recompile it. >More generally: Is there any documentation available about how jythonc works? Apart from the jythonc things on www.jython.org there is not much documentation. In case you know about compilers, the code is quite readable and object oriented to the bone. It also helps to be familiar with java's class file format. The parser is generated from a syntax description and it calls the later stages of the compiler using a visitor pattern with a visit method for every python syntax construct. One area that I don't quite understand it the compilation of local python variables to local java variables. It works great nonetheless. Regards, Ype -- |