[Laszlo-checkins] r8838 - openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc

dda@openlaszlo.org dda at openlaszlo.org
Wed Apr 23 16:11:26 PDT 2008


Author: dda
Date: 2008-04-23 16:11:22 -0700 (Wed, 23 Apr 2008)
New Revision: 8838

Modified:
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
Log:
Change 20080423-dda-7 by dda at lester.local on 2008-04-23 17:11:40 EDT
    in /Users/dda/laszlo/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: SWF9: Provide simple workaround for mixins that use unknown super classes

New Features:

Bugs Fixed: LPP-5841

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

Documentation:

Release Notes:

Details:
    When a mixin uses a superclass not known in the current compilation, instead
    of rejecting this, we allow a simple workaround: the mixin must be coded with
    a constructor, and the programmer takes responsibility for the constructor
    working with whatever superclasses the mixin can be used with.

    Conversely, if there is no mixin constructor, then either the superclass must be known in the current
    compilation, or there may be no superclass.

    A more sophisticated solution (having real knowledge of all potential superclasses) awaits
    for another time.

Tests:
    Ran regression tests: smokecheck,weather,lzpix  X  swf8,dhtml
    Tried some simple tests for functionality:

      ====
      mixin DrawviewShared { 
        var floobar;
          function DrawviewShared () { 
            super(); 
            floobar = 42;
          } 
      }
      
      class mydrawview extends LzView with DrawviewShared {
      }
      
      //Uncommenting this should give an error - we must supply
      // a constructor for badbad if we use it with an 'unknown'
      // superclass like LzView.
      
      //class mybad extends LzView with badbad {
      //}

      mixin badbad {
        // no constructor
      }
      ====



Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java	2008-04-23 22:06:15 UTC (rev 8837)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java	2008-04-23 23:11:22 UTC (rev 8838)
@@ -360,9 +360,10 @@
 
       if (ref.realsuper != null) {
         superClass = (SimpleNode)classes.get(ref.realsuper);
-        if (superClass == null) {
-          throw new CompilerError("Superclass " + ref.realsuper + " not defined for mixin: " + ref.mixinname);
-        }
+
+        // If superClass is null, then we don't know anything about
+        // it: it may be in an included library, etc.  For that case,
+        // we currently require the caller to provide a constructor.
       }
       result.set(result.size(), createInterstitial(mixin, isname, ref, superClass));
     }
@@ -518,6 +519,15 @@
     ischildren[3] = newIdentifier(mixref.mixinname);
     System.arraycopy(mixinchildren, 4, ischildren, 4, origlen - 4);
     if (mixinconstructor == null) {
+      if (supernode == null && mixref.realsuper != null) {
+
+        // For an unknown superclass, we require the mixin programmer
+        // to provide a constructor that handles all the cases it
+        // might be used.  This is a temporary measure - we currently
+        // have no knowledge of superclasses that live in other libraries.
+
+        throw new CompilerError("Superclass " + mixref.realsuper + " used by mixin not defined, and no constructor supplied for mixin: " + mixref.mixinname);
+      }
       ischildren[origlen] = createInterstitialConstructor(isname, supernode);
     }
     



More information about the Laszlo-checkins mailing list