[Laszlo-dev] For Review: Change 20090108-dda-O Summary: Remove references to 'this' in static functions

Donald Anderson dda at ddanderson.com
Thu Jan 8 14:30:38 PST 2009


Tucker, this has a flaw (as you'll see) but it does work, you might  
want to take it depending on
how time critical it is.  I can work on finding/fixing the flaw  
tomorrow too.

- Don

Change 20090108-dda-O by dda at lester.local on 2009-01-08 06:25:08 EST
     in /Users/dda/laszlo/src/svn/openlaszlo/trunk-c
     for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Remove references to 'this' in static functions

New Features:

Bugs Fixed: LPP-7514 (Compilation error when setting  
compiler.swf9.catcherrors=true in lps.properties)

Technical Reviewer: ptw (pending)
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
     The implementation of catchFunctionExceptions (catcherrors) was  
blind to static functions,
     'this' cannot be used in static functions.

     To tell that a function is static, this changeset peeks up the  
tree to the parent
     of the function node, which should be a ASTModifiedDefinition  
('moddef'), and checks the static
     flag there.  A shortcut in copying part of the tree without the  
moddef
     needed to be fixed, to do that, a 'shallow copy' function was  
added to the moddef class.
     Though this change is required for the static detection to work  
in SWF9,
     it also causes problems for SWF8 compilation (**), so has
     been disabled for SWF8.  A TODO has been left in the code.

     An alternate way of detecting static-ness is to set a 'static'  
property in the options.
     I had tried in addressing LPP-5813 (not yet completed), and had  
some trouble getting
     it to work.  It's not clear which one is cleaner, but the one  
that works wins for me.

     This fix is slightly more encompassing than it needs to be, it  
also disables any possibility
     of applying the WITH_THIS directive within a static function.   
This should always be
     correct.  Changing that to be narrower did not affect the SWF8  
problem.

     (**) If the moddef copy is used with SWF8 applications, this  
apparently triggers an
     error in the code generator..  A difference of disassembled swf  
files shows that the
     errant file is missing pop instructions at the end of functions,  
like this:

***************
*** 4109,4115 ****
         end // of function

       end
-     pop
       push 'toString', '_root'
       getVariable
       with
--- 4089,4094 ----


Tests:
     (dhtml,swf8,swf9) x (lzpix,weather,smokecheck,hello) x (enable  
catcherrors, disable catcherrors)

Files:
M      WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/CommonGenerator.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/CodeGenerator.java
M      WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ 
ASTModifiedDefinition.java

Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20090108-dda-O.tar



--

Don Anderson
Java/C/C++, Berkeley DB, systems consultant

voice: 617-306-2057
email: dda at ddanderson.com
www: http://www.ddanderson.com





-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.openlaszlo.org/pipermail/laszlo-dev/attachments/20090108/ecef13f3/attachment.html


More information about the Laszlo-dev mailing list