[Laszlo-checkins] r8195 - in openlaszlo/branches/devildog/WEB-INF/lps/server: sc/src/org/openlaszlo/sc/parser src/org/openlaszlo/sc

dda@openlaszlo.org dda at openlaszlo.org
Thu Mar 6 08:23:47 PST 2008


Author: dda
Date: 2008-03-06 08:23:39 -0800 (Thu, 06 Mar 2008)
New Revision: 8195

Modified:
   openlaszlo/branches/devildog/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTModifiedDefinition.java
   openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9External.java
Log:
Change 20080306-dda-c by dda at lester.local on 2008-03-06 10:50:52 EST
    in /Users/dda/laszlo/src/svn/openlaszlo/branches/devildogm
    for http://svn.openlaszlo.org/openlaszlo/branches/devildog

Summary: SWF9: fix functions nested within functions

New Features:

Bugs Fixed: LPP-5555

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

Documentation:

Release Notes:

Details:
    Error occured because the a parse tree for the inner function was:
       ModifiedDefinition
         FunctionDefinition(func)
    This is transformed to be as if it was written like this func = function () { ... };
    The transformation moves everything under the FunctionDefinition into a FunctionExpression clause,
    and replaces the FunctionDefinition by an empty expression.  The EmptyExpression was
    not correctly handled by the checks on ModifiedDefinition.  We now allow EmptyExpression,
    but verify that there are no modifiers (like public/static/final) on the inner function.

    Also fixed setting the default canvas height if it is not set in the options.
    This permits simple test cases to be run to completion on the command line.

Tests:



Modified: openlaszlo/branches/devildog/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTModifiedDefinition.java
===================================================================
--- openlaszlo/branches/devildog/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTModifiedDefinition.java	2008-03-06 16:23:15 UTC (rev 8194)
+++ openlaszlo/branches/devildog/WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTModifiedDefinition.java	2008-03-06 16:23:39 UTC (rev 8195)
@@ -110,6 +110,15 @@
         if (isDynamic)
             throw new ParseException("cannot use dynamic on variable: " + subnode);
     }
+    // A function is nested if it is declared within another function
+    private void verifyNestedFunction(SimpleNode subnode) {
+        if (isStatic || isFinal || isDynamic || isOverride || !access.equals(DEFAULT_ACCESS)) {
+            throw new ParseException("cannot use keywords: " + toJavascriptString() + " on nested function");
+        }
+        if (namespace != null) {
+            throw new ParseException("cannot use namespace (" + namespace + ") on nested function");
+        }
+    }
     private void verifyClass(SimpleNode subnode) {
         if (isOverride)
             throw new ParseException("cannot use override on class: " + subnode);
@@ -121,6 +130,9 @@
             verifyFunction(subnode);
         else if (subnode instanceof ASTClassDefinition)
             verifyClass(subnode);
+        // A nested function leaves behind an empty expression
+        else if (subnode instanceof ASTEmptyExpression)
+            verifyNestedFunction(subnode);
         else
             throw new ParseException("unexpected type at top level: " + subnode);
     }

Modified: openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9External.java
===================================================================
--- openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9External.java	2008-03-06 16:23:15 UTC (rev 8194)
+++ openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9External.java	2008-03-06 16:23:39 UTC (rev 8195)
@@ -623,7 +623,7 @@
     if (!buildSharedLibrary) {
       cmd.add("-default-size");
       cmd.add(options.get(Compiler.CANVAS_WIDTH, "800"));
-      cmd.add(options.get(Compiler.CANVAS_HEIGHT));
+      cmd.add(options.get(Compiler.CANVAS_HEIGHT, "600"));
       cmd.add("-library-path+=" + getLFCLibrary());
     }
     else {



More information about the Laszlo-checkins mailing list