[Laszlo-dev] For Review: Change 20070919-dda-V Summary: script compiler refactoring
Donald Anderson
dda at ddanderson.com
Wed Sep 19 15:00:17 PDT 2007
Change 20070919-dda-V by dda at freddie.local on 2007-09-19 17:35:41 EDT
in /Users/dda/laszlo/src/svn/openlaszlo/trunk/WEB-INF/lps/server/
src/org/openlaszlo/sc
for http://svn.openlaszlo.org/openlaszlo/trunk/WEB-INF/lps/
server/src/org/openlaszlo/sc
Summary: script compiler refactoring
New Features:
No externally visible changes. A rearrangement of source code to
allow for better
sharing between modules, and separation of most of the platform
independent parts of the compiler.
This more easily allows various future work (e.g. SWF9) to proceed
in parallel with
general maintenance changes.
Bugs Fixed:
Technical Reviewer: ptw
QA Reviewer: (pending)
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
Added a new class CommonGenerator that is the base class of
JavascriptGenerator and CodeGenerator. Methods from the two
subclasses that are textually the same, or can be easily coerced
to be the same are now only in CommonGenerator.
Data members and internal classes that are identical are
also now in the base class.
To get even greater sharing, many methods (like virtually all the
visit* methods) that had signature changes in JavascriptGenerator
(that is, they return 'SimpleNode' rather than void), have changed
across the board to return SimpleNode. That is, these functions
return
the possibly modified node that is visited. In the
CodeGenerator class, this
concept is generally not used, so even though this class plays
by the
same rules, return values from such methods are ultimately ignored.
But this gives a lot more code sharing and many more functions
could be moved
to CommonGenerator.
Likewise, methods that visit expressions that used to be declared
returning boolean in CodeGenerator now must return SimpleNode.
The backwards-seeming translation is that 'true' corresponds to
null,
and false corresponds to the existing node. Doing it this way
gets the maximum code sharing, it clearly reflects the way that
the code was originally transformed after splitting.
CommonGenerator also implements a new interface: ASTVisitor,
which is
the union of all the visit* methods (returning a SimpleNode, of
course). This allows methods in CommonGenerator (esp.
visitStatement)
to freely call any other visit* method, whether or not it is
actually
defined in CommonGenerator.
Most of these changes listed above are almost mechanical using the
indicated strategy; only occasionally were small (equivalent)
coding
changes introduced, and then only if a method was otherwise
identical.
More elaborate code sharing is possible, and was attempted, but
such changes tended to inhibit overall readability and
maintainability.
Tests:
built all files in lps/includes/lfc with the previous compiler
(without
these changes) using the flags "--option
generatePredictableTemps=true".
built the same files with the new compiler (with these changes).
All *.js files compare exactly, all *.lzl files were disassembled,
and the output from that compares exactly.
Files:
M JavascriptGenerator.java
A CommonGenerator.java
A ASTVisitor.java
M CodeGenerator.java
Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20070919-dda-
V.tar
--
Don Anderson
Java/C/C++, Berkeley DB, systems consultant
Voice: 617-547-7881
Email: dda at ddanderson.com
WWW: http://www.ddanderson.com
More information about the Laszlo-dev
mailing list