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

dda@openlaszlo.org dda at openlaszlo.org
Fri Feb 20 08:37:15 PST 2009


Author: dda
Date: 2009-02-20 08:37:13 -0800 (Fri, 20 Feb 2009)
New Revision: 12970

Modified:
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/ParseTreePrinter.java
Log:
Change 20090216-dda-V by dda at lester-2.local on 2009-02-16 12:11:27 EST
    in /Users/dda/laszlo/src/svn/openlaszlo/trunk-b
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: SWF9: Fix comma separated global declaration

New Features:

Bugs Fixed: [LPP-7746] SWF9: comma separated global var declarations don't compile

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

Documentation:

Release Notes:

Details:
    (second review: modified details and updated code comments)

    In DHTML and SWF9, variable statements can be processed and replaced by empty expressions.
    This changeset fixes the unparser so it knows to drop empty expressions in a variable declaration list.
    This was not noticed testing with single variables 'var foo', as the unparser generated a comma separated
    list of expressions - one blank expression, comma separated, still yielded a blank result.

    The alternative of enforcing that the AST not allow ASTEmptyExpressions under variable statements is
    awkward.  This involves more processing at the parent variable statement, rather than each variable expression,
    and a similar replacement happens in multiple places.

Tests:
    The test case from the JIRA now compiles.  Same test case with mix of initialized and uninitialized vars compiles.
    The usual regression tests: smokecheck, lzpix, weather on swf9,swf8,dhtml



Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/ParseTreePrinter.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/ParseTreePrinter.java	2009-02-20 16:00:00 UTC (rev 12969)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/ParseTreePrinter.java	2009-02-20 16:37:13 UTC (rev 12970)
@@ -1,7 +1,7 @@
 /* -*- mode: Java; c-basic-offset: 2; -*- */
 
 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
-* Copyright 2001-2008 Laszlo Systems, Inc.  All Rights Reserved.              *
+* Copyright 2001-2009 Laszlo Systems, Inc.  All Rights Reserved.              *
 * Use is subject to license terms.                                            *
 * J_LZ_COPYRIGHT_END *********************************************************/
 
@@ -178,6 +178,20 @@
   }
 
   /**
+   * Return a list of strings with any empty or null strings removed
+   */
+  public String[] removeEmptyStrings(String[] strings) {
+    int len = strings.length;
+    List list = new ArrayList();
+    for (int i = 0; i < len; i++) {
+      if (strings[i] != null && unannotate(strings[i]).trim().length() > 0) {
+        list.add(strings[i]);
+      }
+    }
+    return (String[])list.toArray(new String[0]);
+  }
+
+  /**
    * Perform any actions that need to happen before
    * children are visited.  May be overridden.
    */
@@ -879,7 +893,11 @@
   }
   
   public String visitVariableDeclarationList(SimpleNode node, String[] children) {
-    return join(COMMA, children);
+    // As declarations are processed by the generator, they
+    // are sometimes replaced by ASTEmptyExpressions.
+    // The resulting empty strings need to be removed
+    // to avoid emitting adjacent commas.
+    return join(COMMA, removeEmptyStrings(children));
   }
 
   public String visitTryStatement(SimpleNode node, String[] children) {



More information about the Laszlo-checkins mailing list