<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><p style="margin: 0.0px 0.0px 0.0px 0.0px">Change 20081121-dda-q by <a href="mailto:dda@lester.local">dda@lester.local</a> on 2008-11-21 10:21:40 EST</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>in /Users/dda/laszlo/src/svn/openlaszlo/trunk-g</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>for <a href="http://svn.openlaszlo.org/openlaszlo/trunk">http://svn.openlaszlo.org/openlaszlo/trunk</a></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">Summary: Add ability to insert try/catch blocks around functions</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">New Features:<span class="Apple-converted-space"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">Bugs Fixed: LPP-7270 (swf9: debugger hanging)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">Technical Reviewer: ptw (pending)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">QA Reviewer: (pending)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">Doc Reviewer: (pending)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">Documentation:</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">Release Notes:</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">Details:</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>This requested feature makes SWF9 similar like SWF8 and DHTML in the face of</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>exceptions - in those systems, the exceptions are caught at the top level, and</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>the program allowed to continue.<span class="Apple-converted-space"> </span>In our case, we catch the exceptions within</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>every function body, report the error to the debug console, and return from the function.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">.<span class="Apple-converted-space"> </span>To enable the feature, compile with -DcatchFunctionExceptions=true</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>Some compilation problems were found in trying to use this feature with smokecheck.lzx</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>for SWF9, so for the moment, this is not tied to the debug switch, but must be</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>enabled explicitly.<span class="Apple-converted-space"> </span>This may be fixed soon.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>The basic premise is to change the ORIGINAL CONTENTS of a function to this:</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>var $lzsc$ret:* = 0;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>try {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>$lzsc$ret = (function<span class="Apple-converted-space"> </span>() {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>with (this) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>//ORIGINAL CONTENTS</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>}}).call(this)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>catch ($lzsc$e) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>$lzsc$runtime.reportException("LPP-7270.lzx", 5, $lzsc$e)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>finally {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>return $lzsc$ret</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>with the slight variation that if the original function is declared to return a type,</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>then the closure is also typed e.g. function (): String { ...</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>This construct has the property that it will compile almost any contents the same,</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>preserving return values and reporting the same compiler errors, including paths</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>that do not return a value.<span class="Apple-converted-space"> </span>For some reason, if the ORIGINAL CONTENTS contains a closure,<span class="Apple-converted-space"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>the flex compiler will report errors that attributes and even globals</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>cannot be seen within that closure.<span class="Apple-converted-space"> </span>So this transformation is not done when</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>the function contains a closure.<span class="Apple-converted-space"> </span>Also, super() calls cannot be pushed into a closure, so the</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>transformation is not done if a super call is contained.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>A toString() function was added to ASTFormalParameterList to show the return type of the function.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>catchFunctionExceptions=false is added to the build scripts for the LFC.<span class="Apple-converted-space"> </span>This is technically</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>not needed at the moment, but when we attach the catchFunctionExceptions option to the debug</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>option, it will be.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">Tests:</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>Regression (swf8,swf9,dhtml) x (smokecheck,lzpix,weather)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>This change tested using the following test program, compiling with both</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>-DcatchFunctionExceptions=true and false, observing generated compiler output</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>for both cases, and running it with both cases.<span class="Apple-converted-space"> </span>Only the catchFunctionExceptions=true</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>allows the program to proceed after an exception.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>test program:<span class="Apple-converted-space"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span><!-- ================================= --></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span><canvas debug="true"></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span><simplelayout spacing="10" axis="y" /></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span><class name="mywindow" width="300"></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span><button onclick="this.parent.parent.canvas_f()" >BaseClass mywindow</button></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span></class></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><span class="Apple-converted-space"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span><method name="canvas_f"></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>Debug.info("1 zebra");</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>Debug.info("2");</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>t1.setText("Before exception");</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>Debug.info("3...?");</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>throwexcept(7,0);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>Debug.info("4!!");</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>t2.setText("After exception");</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span></method></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span><button name="b1" onclick="this.parent.canvas_f()" width="100" height="30" y="10">Press me</button></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span><text name="t1" bgcolor="#ccffcc" width="100" height="30" y="50"/></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span><text name="t2" bgcolor="#ccffcc" width="100" height="30" y="100"/></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span><mywindow bgcolor="#cc8c8c"/></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span><script></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>function throwexcept(w, x) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>// divide by zero doesn't give an exception, but</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>// an array reference of a non array will.</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>return w[x]/x;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span></script></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span></canvas></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px"><span class="Apple-converted-space"> </span><!-- ================================= --></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">Files:</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">M<span class="Apple-converted-space"> </span>WEB-INF/lps/lfc/buildlfc</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">M<span class="Apple-converted-space"> </span>WEB-INF/lps/lfc/buildlfcdebug</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">M<span class="Apple-converted-space"> </span>WEB-INF/lps/lfc/build.xml</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">M<span class="Apple-converted-space"> </span>WEB-INF/lps/lfc/compiler/LzRuntime.lzs</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">M<span class="Apple-converted-space"> </span>WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">M<span class="Apple-converted-space"> </span>WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">M<span class="Apple-converted-space"> </span>WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTFormalParameterList.java</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px">Changeset: <a href="http://svn.openlaszlo.org/openlaszlo/patches/20081121-dda-q.tar">http://svn.openlaszlo.org/openlaszlo/patches/20081121-dda-q.tar</a></p>
<br><br><div> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br class="Apple-interchange-newline">--</div><div><br>Don Anderson<br>Java/C/C++, Berkeley DB, systems consultant<br><br>voice: 617-547-7881<br>email: <a href="mailto:dda@ddanderson.com">dda@ddanderson.com</a><br>www: <a href="http://www.ddanderson.com/">http://www.ddanderson.com</a><br></div></div></span></span><br class="Apple-interchange-newline"></div></span></div></span><br class="Apple-interchange-newline"> </div><br></body></html>