[Laszlo-checkins] r13577 - in openlaszlo/branches/4.3: . WEB-INF/lps/server/src/org/openlaszlo/compiler

ptw@openlaszlo.org ptw at openlaszlo.org
Wed Apr 1 14:26:52 PDT 2009


Author: ptw
Date: 2009-04-01 14:26:49 -0700 (Wed, 01 Apr 2009)
New Revision: 13577

Modified:
   openlaszlo/branches/4.3/
   openlaszlo/branches/4.3/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassModel.java
Log:
Merged revisions 13572 via svnmerge from 
http://svn.openlaszlo.org/openlaszlo/trunk

.......
  r13572 | ptw | 2009-04-01 15:21:38 -0400 (Wed, 01 Apr 2009) | 28 lines
  
  Change 20090401-ptw-K by ptw at dueling-banjos.home on 2009-04-01 14:26:40 EDT
      in /Users/ptw/OpenLaszlo/trunk-3
      for http://svn.openlaszlo.org/openlaszlo/trunk
  
  Summary: The last nail for LPP-7750?
  
  Bugs Fixed: LPP-7750 Many warnings and errors with LZOs
  
  Technical Reviewer: hminsky (pending)
  QA Reviewer: mdemmon (pending)
  
  Details:
      Remove the bogus methods getMerged*, which can't work because the
      compiler does not know all classes at compile time (it does not
      know the structure of the LFC-implemented classes and it does not
      know the structure of classes that will come from libraries).
  
      Define a new predicate inheritsClassChildren that tells whether
      the super class has (or could have, for classes we don't know)
      children.
  
      Fix the optimization for merging superclass children into a
      class to use the new predicate and be correct.
  
  Tests:
      Test case from bug report
.......



Property changes on: openlaszlo/branches/4.3
___________________________________________________________________
Name: svnmerge-integrated
   - /openlaszlo/branches/4.1:1-10153 /openlaszlo/branches/4.2:1-12154,12181,13205 /openlaszlo/branches/devildog:1-8432 /openlaszlo/branches/pagan-deities:1-7955,8825,10756-10920,10922-10928,10930-10935,11151,11207,11554,13476 /openlaszlo/branches/paperpie:1-6504,6506-6574,6576-7135,7137-7235 /openlaszlo/branches/wafflecone:1-5746,5818-6068,6070-6205,6207-6213,6216-6265,6267-6368,6370-6431,6433-6450,6497,6509,6661,7097,7872 /openlaszlo/trunk:1-13548,13554,13557,13559,13562,13566,13573,13575
   + /openlaszlo/branches/4.1:1-10153 /openlaszlo/branches/4.2:1-12154,12181,13205 /openlaszlo/branches/devildog:1-8432 /openlaszlo/branches/pagan-deities:1-7955,8825,10756-10920,10922-10928,10930-10935,11151,11207,11554,13476 /openlaszlo/branches/paperpie:1-6504,6506-6574,6576-7135,7137-7235 /openlaszlo/branches/wafflecone:1-5746,5818-6068,6070-6205,6207-6213,6216-6265,6267-6368,6370-6431,6433-6450,6497,6509,6661,7097,7872 /openlaszlo/trunk:1-13548,13554,13557,13559,13562,13566,13572-13573,13575

Modified: openlaszlo/branches/4.3/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassModel.java
===================================================================
--- openlaszlo/branches/4.3/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassModel.java	2009-04-01 21:19:28 UTC (rev 13576)
+++ openlaszlo/branches/4.3/WEB-INF/lps/server/src/org/openlaszlo/compiler/ClassModel.java	2009-04-01 21:26:49 UTC (rev 13577)
@@ -218,19 +218,24 @@
     //
     // Before you output this, see if it is necessary:  will this node
     // end up with children at all?
-    if (getMergedChildren().size() > 0) {
-      // TODO: [2008-05-30 ptw] We don't output the merged children,
-      // on the belief that is is more efficient to build the merged
-      // list at runtime, but this should be measured.
+    boolean hasChildren = (! nodeModel.getChildren().isEmpty());
+    boolean inheritsChildren = inheritsChildren();
+    if (hasChildren || inheritsChildren) {
       String children = ScriptCompiler.objectAsJavascript(nodeModel.childrenMaps());
-      // class#classChildren now class.children
-      nodeModel.setClassAttribute("children", "LzNode.mergeChildren(" + children + ", " + superClassName + "['children'])");
+      if (inheritsChildren) {
+        // NOTE: [2009-04-01 ptw] We don't compute the merged children
+        // at compile time, because we may not know them (superclass
+        // may be loaded from a library).  It might be possible to
+        // optimize this when we know the superclass.
+        nodeModel.setClassAttribute("children", "LzNode.mergeChildren(" + children + ", " + superClassName + "['children'])");
+      } else {
+        nodeModel.setClassAttribute("children", children);
+      }
     }
 
     // Declare all instance vars and methods, save initialization
     // in <class>.attributes
-    Map attrs = nodeModel.getAttrs(); // classModel.getMergedAttributes();
-    Map setters = getMergedSetters();
+    Map attrs = nodeModel.getAttrs();
     Map decls = new LinkedHashMap();
     Map inits = new LinkedHashMap();
     boolean isstate = isSubclassOf(schema.getClassModel("state"));
@@ -258,11 +263,11 @@
         // magic merging, the value has to be installed as an init,
         // otherwise it should be installed as a decl
         //
-        // TODO: [2008-03-15 ptw] This won't work until we know
-        // (in the classModel) the setters for the built-in
-        // classes, so we install as an init for now and this is
-        // fixed up in LzNode by installing inits that have no
-        // setters when the arguments are merged
+        // TODO: [2008-03-15 ptw] This won't work until we know (in
+        // the classModel) the setters for all the superclasses
+        // (built-in and in libraries), so we install as an init for
+        // now and this is fixed up in LzNode by installing inits that
+        // have no setters when the arguments are merged
         if (true) { // (! (value instanceof String))  || setters.containsKey(key) || isstate) {
           // If this is a re-declared attribute, we just init it,
           // don't re-declare it
@@ -376,38 +381,25 @@
       return superclass;
   }
 
-  private List mergedChildren;
-
-  List getMergedChildren() {
-    if (mergedChildren != null) { return mergedChildren; }
-    if (nodeModel == null) { return mergedChildren = new Vector(); }
-    List merged = mergedChildren = new Vector(superclass.getMergedChildren());
-    merged.addAll(nodeModel.getChildren());
-    return merged;
+  // A class needs to merge its children if its superclass has
+  // children, or its superclass is in a library (in which case, we
+  // just don't know)
+  boolean inheritsChildren() {
+    // No LFC class has children
+    if (superclass.builtin) { return false; }
+    // If we don't know, we have to assume true
+    if (superclass.nodeModel == null) { return true; }
+    // Otherwise ask them
+    return ((! superclass.nodeModel.getChildren().isEmpty()) ||
+            superclass.inheritsChildren());
   }
 
-  private Map mergedAttributes;
-
-  Map getMergedAttributes() {
-    if (mergedAttributes != null) { return mergedAttributes; }
-    if (nodeModel == null) { return mergedAttributes = new LinkedHashMap(); }
-    Map merged = mergedAttributes = new LinkedHashMap(superclass.getMergedAttributes());
-    // Merge in the our attributes, omitting methods
-    for (Iterator i = nodeModel.getAttrs().entrySet().iterator(); i.hasNext(); ) {
-      Map.Entry entry = (Map.Entry) i.next();
-      String key = (String) entry.getKey();
-      Object value = entry.getValue();
-      if ("LzNode._ignoreAttribute".equals(value)) {
-        merged.remove(key);
-      } else if (! (value instanceof Method)) {
-        merged.put(key, value);
-      }
-    }
-    return merged;
-  }
-
   private Map mergedMethods;
 
+  // NOTE: [2009-03-31 ptw] This information is incomplete.  It only
+  // knows the methods the tag compiler has added.  It does _not_ know
+  // methods that may have come from a library (only the schema knows
+  // those, assuming it has parsed the interface).
   Map getMergedMethods() {
     if (mergedMethods != null) { return mergedMethods; }
     if (nodeModel == null) { return mergedMethods = new LinkedHashMap(); }
@@ -424,22 +416,6 @@
     return merged;
   }
 
-  private Map mergedSetters;
-
-  Map getMergedSetters() {
-    if (mergedSetters != null) { return mergedSetters; }
-    if (nodeModel == null) { return mergedSetters = new LinkedHashMap(); }
-    Map merged = mergedSetters = new LinkedHashMap(superclass.getMergedSetters());
-    // Merge in the our setters
-    for (Iterator i = nodeModel.getSetters().entrySet().iterator(); i.hasNext(); ) {
-      Map.Entry entry = (Map.Entry) i.next();
-      String key = (String) entry.getKey();
-      Object value = entry.getValue();
-      merged.put(key, value);
-    }
-    return merged;
-  }
-
     /** This is really the LZX tag name */
     public String getClassName () {
      return this.tagName;



More information about the Laszlo-checkins mailing list