<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jan 11, 2009, at 1:52 PM, P T Withington wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>I think here:<br><br><blockquote type="cite"> boolean withThis = options.getBoolean(Compiler.WITH_THIS) && !isStatic;<br></blockquote><br>You should be saying:<br><br> // If the locals are not remapped, we assume we are in a runtime<br> // that already does implicit this in methods...<br> boolean withThis = options.getBoolean(Compiler.WITH_THIS) && !isStatic && remaplocals();<br><br>(removing the remaplocals() test from here:<br><br><blockquote type="cite"> if ((! free.isEmpty()) && withThis && remapLocals()) {<br></blockquote><br>where it is now redundant. Basically, you turn off withThis if you already have implicit this, right?<br><br>And here:<br><br><blockquote type="cite"> if (isStatic) {<br></blockquote><blockquote type="cite"> frag += " { _1 }}).call(null);";<br></blockquote><blockquote type="cite"> }<br></blockquote><blockquote type="cite"> else {<br></blockquote><blockquote type="cite"> frag += " with (this) { _1 }}).call(this);";<br></blockquote><blockquote type="cite"> }<br></blockquote><br>you should be using `withThis` not `isStatic`, otherwise you are unnecessarily inserting a `with (this)` in the try closure.</div></blockquote><div><br></div>Although these seem good to me, if I make these changes, all the SWF9 applications I create come up blank.</div><div>I can investigate tomorrow.</div><div><br><blockquote type="cite"><div><br><br>And, if you don't need to wrap a `with (this)` around the body, remind me again why the body has to be put in a closure at all?</div></blockquote><div><br></div><div>It doesn't strictly have to be a closure, but this seemed the cleanest way to preserve the behavior of return statements.</div><div>And if there is no 'return' statement and one is required, we want to issue an error just like SWF9 does.</div><div>I have annotated LPP-7514 with the chain of thought and test cases that led to the use of closures.</div><div><br></div><div>- Don</div><div><br></div><br><blockquote type="cite"><div>On 2009-01-11, at 11:14EST, Donald Anderson wrote:<br><br><blockquote type="cite">Change 20090111-dda-y by <a href="mailto:dda@lester.local">dda@lester.local</a> on 2009-01-11 10:54:15 EST<br></blockquote><blockquote type="cite"> in /Users/dda/laszlo/src/svn/openlaszlo/trunk-c<br></blockquote><blockquote type="cite"> for <a href="http://svn.openlaszlo.org/openlaszlo/trunk">http://svn.openlaszlo.org/openlaszlo/trunk</a><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Summary: Remove references to 'this' in static functions (revised 2)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">New Features:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Bugs Fixed: LPP-7514 (Compilation error when setting compiler.swf9.catcherrors=true in lps.properties)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Technical Reviewer: ptw (pending)<br></blockquote><blockquote type="cite">QA Reviewer: (pending)<br></blockquote><blockquote type="cite">Doc Reviewer: (pending)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Documentation:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Release Notes:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Details:<br></blockquote><blockquote type="cite"> ** This changeset under consideration for 4.2.0.1<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> [This changeset is a second revision of an earlier changeset, to ensure the new test case<br></blockquote><blockquote type="cite"> listed in the JIRA runs correctly. Everything indicated under Tests has been retested with this revision.]<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> The implementation of catchFunctionExceptions (catcherrors) was blind to static functions,<br></blockquote><blockquote type="cite"> 'this' cannot be used in static functions.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> To tell that a function is static, this changeset peeks up the tree to the parent<br></blockquote><blockquote type="cite"> of the function node, which should be a ASTModifiedDefinition ('moddef'), and checks the static<br></blockquote><blockquote type="cite"> flag there. A shortcut in copying part of the tree without the moddef<br></blockquote><blockquote type="cite"> needed to be fixed, to do that, a 'shallow copy' function was added to the moddef class.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> An alternate way of detecting static-ness is to set a 'static' property in the options.<br></blockquote><blockquote type="cite"> I had tried in addressing LPP-5813 (not yet completed), and had some trouble getting<br></blockquote><blockquote type="cite"> it to work. It's not clear which one is cleaner, but the one that works wins for me.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> This fix is slightly more encompassing than it needs to be, it also disables any possibility<br></blockquote><blockquote type="cite"> of applying the WITH_THIS directive within a static function. This should always be<br></blockquote><blockquote type="cite"> correct.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> This changeset also fixes a bug in that previously, ASTFunctionExpressions were not<br></blockquote><blockquote type="cite"> considered for the 'try/catch' treatment. This effectively excluded state methods,<br></blockquote><blockquote type="cite"> and probably some other important cases. Fixing this exposed an error in smoketest<br></blockquote><blockquote type="cite"> (only shown when catcherrors is true).<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> Tests: 880 Failures: 1 Errors: 1<br></blockquote><blockquote type="cite"> TestFailure: «<IntentionalErrors>»/testUndefinedErrors failed: Total number of expected errors: expected 1 got 0<br></blockquote><blockquote type="cite"> TestError: «<IntentionalErrors>»/testUndefinedErrors failed: Wrong error: expected «function» got 'testing: 1, 2, 3'<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> ptw believes this test case should be rewritten: That error is because that test is using arguments.callee to fake a closure (which is not going to work because the transform moves the code to an inner closure, and arguments.callee no longer gets it to the original function.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Tests:<br></blockquote><blockquote type="cite"> (dhtml,swf8,swf9) x (lzpix,weather,smokecheck,hello) x (enable catcherrors, disable catcherrors)<br></blockquote><blockquote type="cite"> -- smokecheck error for swf9 x smokecheck x (enable catcherrors) as noted above.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Files:<br></blockquote><blockquote type="cite">M WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java<br></blockquote><blockquote type="cite">M WEB-INF/lps/server/src/org/openlaszlo/sc/CommonGenerator.java<br></blockquote><blockquote type="cite">M WEB-INF/lps/server/src/org/openlaszlo/sc/CodeGenerator.java<br></blockquote><blockquote type="cite">M WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTModifiedDefinition.java<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Changeset: <a href="http://svn.openlaszlo.org/openlaszlo/patches/20090111-dda-y.tar">http://svn.openlaszlo.org/openlaszlo/patches/20090111-dda-y.tar</a><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">--<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Don Anderson<br></blockquote><blockquote type="cite">Java/C/C++, Berkeley DB, systems consultant<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">voice: 617-306-2057<br></blockquote><blockquote type="cite">email: <a href="mailto:dda@ddanderson.com">dda@ddanderson.com</a><br></blockquote><blockquote type="cite">www: <a href="http://www.ddanderson.com">http://www.ddanderson.com</a><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><br></div></blockquote></div><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; "><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-306-2057<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></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"> </div><br></body></html>