[Laszlo-checkins] r14124 - in openlaszlo/trunk: WEB-INF/lps/lfc/compiler WEB-INF/lps/server/src/org/openlaszlo/sc test

ptw@openlaszlo.org ptw at openlaszlo.org
Fri Jun 12 09:53:40 PDT 2009


Author: ptw
Date: 2009-06-12 09:53:37 -0700 (Fri, 12 Jun 2009)
New Revision: 14124

Added:
   openlaszlo/trunk/test/lpp-8264.lzx
Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/compiler/Class.lzs
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/CommonGenerator.java
Log:
Change 20090612-ptw-C by ptw at dueling-banjos.home on 2009-06-12 08:30:10 EDT
    in /Users/ptw/OpenLaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Be more careful in Class/nextMethod with compiler-private attributes

Bugs Fixed: LPP-8264 No OL debugger in IE7, DHTML

Technical Reviewer: hminsky (pending)
QA Reviewer: lhenrywilkins at laszlosystems.com (pending)

Details:
    test/lpp-8264.lzx:  Contrived test to provoke the problem.  The
    "real" test is for Lorien to run webtop with these changes.

    Class.lzx, CommonGenerator.java: Renamed the compiler-private
    properties of methods from `superclass.*` to `$superclass.*`.
    User programs should not be using properties starting with `$` --
    they are reserved for the compiler.  Made the compiler
    optimization of super calls safer, and call to a non-existent
    super method a no-op (that issues and error in debug mode).

    Hopefully this will help find the _real_ bug.

Tests:
    Checked in a 'contrived' test that elicits a fatal error in dhtml
    IE7.  With these changes, you now get an error in the LZX debugger
    instead of halting



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/compiler/Class.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/compiler/Class.lzs	2009-06-12 16:50:23 UTC (rev 14123)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/compiler/Class.lzs	2009-06-12 16:53:37 UTC (rev 14124)
@@ -64,8 +64,8 @@
       if (! (value instanceof Function)) continue;
 
       var xtor = this.constructor;
-      if (value.hasOwnProperty('superclasses')) {
-        var os = value.superclasses, found = false;
+      if (value.hasOwnProperty('$superclasses')) {
+        var os = value.$superclasses, found = false;
         for (var j = os.length - 1; j >= 0; j--) {
           if (os[j] === xtor) {
             found = true;
@@ -73,14 +73,14 @@
           }
         }
         if (! found) {
-          value.superclasses.push(xtor);
+          value.$superclasses.push(xtor);
         }
-      } else if (value.hasOwnProperty('superclass') && value.superclass !== xtor) {
-        var superclass = value.superclass;
-        delete value.superclass;
-        value.superclasses = [ superclass, xtor ];
+      } else if (value.hasOwnProperty('$superclass') && value.$superclass !== xtor) {
+        var $superclass = value.$superclass;
+        delete value.$superclass;
+        value.$superclasses = [ $superclass, xtor ];
       } else {
-        value.superclass = xtor;
+        value.$superclass = xtor;
       }
       if ($debug) {
         if (! value._dbg_typename) {
@@ -149,12 +149,12 @@
   */
 Instance.prototype.addProperty('nextMethod', function nextMethod (currentMethod, nextMethodName) {
   var next;
-  if (currentMethod.hasOwnProperty('superclass')) {
-    next = currentMethod.superclass.prototype[nextMethodName];
-  } else {
-    var superclasses = currentMethod.superclasses;
-    for (var i = superclasses.length - 1; i >= 0; i--) {
-      var sc = superclasses[i];
+  if (currentMethod.hasOwnProperty('$superclass')) {
+    next = currentMethod.$superclass.prototype[nextMethodName];
+  } else if (currentMethod.hasOwnProperty('$superclasses')) {
+    var $superclasses = currentMethod.$superclasses;
+    for (var i = $superclasses.length - 1; i >= 0; i--) {
+      var sc = $superclasses[i];
       if (this instanceof sc) {
         next = sc.prototype[nextMethodName];
         break;
@@ -162,9 +162,11 @@
     }
   }
   // TODO: [2006-05-21 ptw] Call this.noNextMethod(nextMethodName, currentMethod)
-  if ($debug) {
-    if (! next) {
-      Debug.error('No next method %s in %w', nextMethodName, currentMethod);
+  if (! next) {
+    next = function () {
+      if ($debug) {
+        Debug.error('super.%s is undefined in %w', nextMethodName, currentMethod);
+      }
     }
   }
   return next;

Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/CommonGenerator.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/CommonGenerator.java	2009-06-12 16:50:23 UTC (rev 14123)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/CommonGenerator.java	2009-06-12 16:53:37 UTC (rev 14124)
@@ -1006,7 +1006,7 @@
     SimpleNode args = children[2];
     String name;
     String ca = null;
-    String pattern = "(arguments.callee.superclass?arguments.callee.superclass.prototype[_1]:this.nextMethod(arguments.callee, _1)).call(this, _2)";
+    String pattern = "((arguments.callee['$superclass']&&arguments.callee.$superclass.prototype[_1])||this.nextMethod(arguments.callee, _1)).call(this, _2)";
     if (fname instanceof ASTEmptyExpression) {
       // super with no selector is the constructor, which will be
       // renamed to $lzsc$initialize in translateClassDirective to
@@ -1049,9 +1049,9 @@
     if (ca == null) {
       ;
     } else if ("call".equals(ca)) {
-      pattern = "(arguments.callee.superclass?arguments.callee.superclass.prototype[_1]:this.nextMethod(arguments.callee, _1)).call(_2)";
+      pattern = "((arguments.callee['$superclass']&&arguments.callee.$superclass.prototype[_1])||this.nextMethod(arguments.callee, _1)).call(_2)";
     } else if ("apply".equals(ca)) {
-      pattern = "(arguments.callee.superclass?arguments.callee.superclass.prototype[_1]:this.nextMethod(arguments.callee, _1)).apply(_2)";
+      pattern = "((arguments.callee['$superclass']&&arguments.callee.$superclass.prototype[_1])||this.nextMethod(arguments.callee, _1)).apply(_2)";
     } else {
       assert false: "Unhandled super call " + ca;
     }

Added: openlaszlo/trunk/test/lpp-8264.lzx


Property changes on: openlaszlo/trunk/test/lpp-8264.lzx
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native



More information about the Laszlo-checkins mailing list