Change 20091020-ptw-P by [email protected] on 2009-10-20 12:13:17 EDT
     in /Users/ptw/OpenLaszlo/trunk
     for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Remove platform dependence from tag compiler (step 1 of n)

Bugs Fixed:
LPP-5813 JS1 class back end needs to implement lexical scoping of  
class members (partial)

Technical Reviewer: hminsky (pending)
QA Reviewer: max (pending)

Release Notes:

     The script compiler now (partially) models class declarations to
     help discover instance references in methods and insert the `with
     (this)` block that makes them work.  Because instance references
     were not previously detected when compiling the LFC, for now we
     warn if a free reference will be interpreted as an instance
     reference when compiling the LFC.

Details:

     The overall idea is that the script compiler should know the
     difference between a function and a method and for methods it
     should know the class that method belongs to and hence should be
     able to resolve references to instance properties.  Methods are
     detected in the parser and given a new AST type to distinguish
     them from functions through the compiler.  This implementation is
     a step forward, although not a complete solution.  It does,
     however, remove one of the main remaining platform dependencies
     from the tag compiler, which brings us a step closer to being able
     to write platform-independent .lzo's.

     LzDebug.lzs: Error noticed in passing in `explainStyleBindings`.

     LzDebug.js: Fix global references that are now shadowed by
     instance properties.

     PropertyReference, JS2Doc, : ASTMethodDeclaration gets same  
treatment as
     ASTFunctionDeclaration.

     JavascriptGenerator, CodeGenerator, CommonGenerator:  Move global
     management to CommonGenerator.  Note classes and global vars in
     global table.

     JavascriptGenerator, CodeGenerator, ASTVisitor,
     JavascriptCompressor, ParseTreePrinter, ASTModifiedDefinition:
     Handle methods as declarations, and as expressions when they
     appear in a class plist.

     JavascriptGenerator, CodeGenerator: Remove the unneeded (and
     kludgey) isExpressionType assertion.  Extend
     translateFunctionInternal to know the differnce between a function
     and a method.  For withThis calculation, when the class
     description is known and complete, use it to sort the free
     references into free and instance references and only output `with
     (this)` when there are instance references.  Warn if there are
     apparent instance references in the LFC, as they were surely not
     intended (since this is a new feature for LFC code).

     variableAnalyzer:  Learn about conditional computation so the free
     set is correct for conditional compiles.  Correct the computation
     of free references in super calls and array literals.  Note that a
     catch clause introduces a local variable.

     CommonGenerator:  Add ClassDescriptor to track instance properties
     for withThis analysis.  The instance properties of superclasses
     are lazily computed as the compiler is still 1-pass and there may
     be forward references.  The withThis analyzer will fall back to
     conservatively treating all free references as possible instance
     references if the class description is incomplete when needed.
     Create a class context around the translation of a class
     declaration and not the class description in the context so it can
     be retrieved by translateFunctionInternal when translating a
     method in the class.  Simplify the translation of a method for
     plist by simply inserting the method declaration and relying on
     the expression translator to translate it as an expression.

     SWF9Generator:  Work with, but ignore the above changes, since the
     FLEX compiler already does the class/instance analysis for us.

     TranslationContext:  Add new context type for class and property
     CLASS_DESCRIPTION.

     NodeModel:  Remove platform-specific withThis injection.

     Parser:  Add MethoDeclaration AST that is the same as a
     FunctionDeclaration, but detected lexically at the top level of a
     ClassDeclaration.

Tests:
     smokecheck on all platforms, diff of compiler output (LFC and
     smokecheck)

Files:
M      WEB-INF/lps/lfc/debugger/LzDebug.lzs
M      WEB-INF/lps/lfc/debugger/platform/dhtml/LzDebug.js
M      WEB-INF/lps/server/src/org/openlaszlo/js2doc/ 
PropertyReference.java
M      WEB-INF/lps/server/src/org/openlaszlo/js2doc/JS2Doc.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/VariableAnalyzer.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/CommonGenerator.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/TranslationContext.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/ASTVisitor.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/CodeGenerator.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/ 
JavascriptCompressor.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/ParseTreePrinter.java
M      WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
M      WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
M      WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ 
ASTModifiedDefinition.java

Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20091020-ptw-P.tar
_______________________________________________
Laszlo-reviews mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-reviews

Reply via email to