On 2009-12-02, at 13:57, Rami Ojares / AMG Oy wrote: > What is the compiler currently doing? > My quess is something like this. > > 1) XML parser is used to build some sort of javascript source from lzx files > 2) Then this is combined with the core laszlo files and the combination is > some sort of version of ecma edition 4. > 3) Using some compiler compiler like antlr or similar AST is created. > 4) And using various techniques (mostly manual hacks :) from this AST the > source/bytecode file(s) are generated for the chosen runtime. > > Was this quess in the right direction?
Essentially correct. The swf8 back-end walks the AST generating a byte-code stream. There is a byte-code peephole optimizer that optimizes pushes and constants. The DHTML back-end walks the AST transforming "js2" to ecma3 and then unparses it. The unparser uses most of the known Javascript compression techniques to minimize the uploaded file. The swf9/10 back-end walks the AST transforming the "js2" to as3 and unparses it. That unparser knows the rules about splitting classes into files for the flex compiler. So, basically, our "js2" acts as the intermediate language for the XML compiler, allowing the back-ends that target js-like platforms to be relatively simple variations on a theme. This is a pretty standard compiler path, using pretty standard compiler techniques. Except since we are not compiling down to a hardware, we don't feel compelled to use an RTL for our intermediate language. > What is the compiler compiler you are using? JavaCC. I have no idea if that is a good or bad choice. It was at the time the project started. The compiler was originally written mostly in Jython, which was great for the initial project. Some time in the deep-dark past, I re-wrote the whole thing (rather painfully) into Java, to try to speed it up. It could surely do with another rewrite...
