[Laszlo-dev] For Review: Change 20090320-dda-M Summary: Initial implementation of catcherrors for DHTML

Donald Anderson dda at ddanderson.com
Mon Mar 23 14:50:38 PDT 2009


Change 20090320-dda-M by dda at lester-2.local on 2009-03-20 16:17:11 EDT
     in /Users/dda/laszlo/src/svn/openlaszlo/trunk-b
     for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Initial implementation of catcherrors for DHTML

New Features:

Bugs Fixed: LPP-7824: Add compiler option to turn on catch-errors  
(currently swf9) in DHTML

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

Documentation:

Release Notes:
     The property name for catcherrors has changed.
     Now, if you set compiler.catcherrors=true in your lps.properties  
file,
     you will enable catcherrors behavior.  This works for SWF9 and  
DHTML runtimes.
     The property used to be called compiler.swf9.catcherrors; that  
property is now ignored.

Details:
     This changeset enables the catcherrors code for DHTML.

     - The property name to drive the feature has changed (see Release  
Notes above)

     - Fixed a mistake in matchingAncestor() so that it now works as  
advertised.

     - For DHTML, I attempted to use the $lzsc$runtime class  
(currently only enabled for SWF9),
       but that class was not able to successfully call  
reportSourceWarning in DHTML.
       For the time being, I'm calling $reportSourceWarning directly  
in DHTML.
       A TODO has been left in, we should either find a way to resolve  
this or call
       reportSourceWarning directly for all runtimes.

     - The implementation continues to use Compiler.PassThroughNodes  
for the fragments that implement
       the variable declaration and try/catch block.  Without this,  
I've encountered problems probably
       related to an ordering problem - the references to the  
rewritten variable names are changed before
       the variable in the try block is created.  (not sure about  
this).  At any rate, DHTML continues
       to use PassThroughNodes.  One consequence is that a  
'warnUndefinedReferences' pragma is inserted
       into the parsedFragment and is not removed.  So this change  
moves a change in SWF9ParseTreePrinter
       into ParseTreePrinter - pragmas are shown as commented (also  
fixed a newline error when moving that!)
       This allows the pragma to appear in the final AST.  Better long  
term solutions are to remove the pragmas or
       better, solve the underlying problem that requires  
PassThroughNodes.

Tests:
   1. For regression, the usual {smokecheck,weather,lzpix} x  
{swf9,swf8,dhtml} -- with catcherrors enabled.
   Note that I did not build the LFC with catcherrors enabled, we'll  
save that for another day.

   2. For functionality, here is the minimal test case I use:

<canvas debug="true">
   <simplelayout spacing="10" axis="y" />

   <method name="canvas_f">
    t1.setText("Before exception");
    throwexcept(7,0);
    t2.setText("After exception");
   </method>
   <method name="returnnull">
    return null;
   </method>
   <method name="throwexcept" args="w, x">
   // an array reference of a non array gives an exception
   return w + x + returnnull().foo;
  </method>

   <button name="b1" onclick="this.parent.canvas_f()" width="100"  
height="30" y="10">Press me</button>
   <text name="t1" bgcolor="#ccffcc" width="100" height="30" y="50"/>
   <text name="t2" bgcolor="#ccffcc" width="100" height="30" y="100"/>
<script>
</script>
</canvas>

In SWF8, this gives:
WARNING @LPP-7270g.lzx#14: reference to undefined property 'foo'
In SWF9, this gives:
ERROR @LPP-7270g.lzx#12: TypeError: Error #1009
In DHTML, this now gives:
ERROR @LPP-7270g.lzx#12: TypeError: Null value

For SWF9/DHTML, the line number refers to the top of the function, as  
the try/catch
block applies to the entire function.

Files:
M      WEB-INF/lps/config/lps.properties
M      WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/ 
SWF9ParseTreePrinter.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
M      WEB-INF/lps/server/src/org/openlaszlo/sc/ParseTreePrinter.java

Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20090320-dda-M.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/20090323/309481a4/attachment-0001.html


More information about the Laszlo-dev mailing list