[Laszlo-checkins] r12787 - in openlaszlo/trunk: WEB-INF/lps/server/src/org/openlaszlo/sc lps/components/rpc

dda@openlaszlo.org dda at openlaszlo.org
Sat Feb 7 11:44:37 PST 2009


Author: dda
Date: 2009-02-07 11:44:33 -0800 (Sat, 07 Feb 2009)
New Revision: 12787

Modified:
   openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
   openlaszlo/trunk/lps/components/rpc/javarpc.lzx
   openlaszlo/trunk/lps/components/rpc/soap.lzx
   openlaszlo/trunk/lps/components/rpc/xmlrpc.lzx
Log:
Change 20090206-dda-z by dda at lester-2.local on 2009-02-06 22:16:07 EST
    in /Users/dda/laszlo/src/svn/openlaszlo/trunk-g/test
    for http://svn.openlaszlo.org/openlaszlo/trunk/test

Summary: With catcherrors=true, disable try/catch/closure when 'arguments' is used.

New Features:

Bugs Fixed: LPP-7721 [xml-rpc is not working when "compiler.swf9.catcherrors=true"]

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

Documentation:

Release Notes:

Details:
    ** for consideration in 4.2.0.1

    'arguments' refers to the arguments passed to the enclosing function, and allows some
    clever examination of arguments dynamically.  With catcherrors=true, an additional
    function closure is wrapped around each function within a try/catch, and the extra
    function thwarts the use of 'arguments' within the body of the original function.
    To avoid such problems, we disable catcherrors for any functions that refer to
    the magic 'arguments'.  This allows us to remove the workaround pragmas added
    to lps/components (which also disabled catcherrors, but for specific functions)
    As a bonus, smokecheck now passes with catcherrors enabled.

    It's true that now a small percentage of functions will not have the try/catch wrapping
    that used to have it.  However, such functions should be relative rare, will probably
    be in component code rather than user code, and if in user code, would probably not
    be a top level function.  Any such functions that are not top level functions would
    will be under the control of a higher level try/catch block.  Finally, any such functions
    that we now don't wrap may well have been broken under the previous implementation.

Tests:
  With catcherrors=true: 
      {smokecheck,lzpix,weather} x {swf8,swf9,dhtml} 
  Verified that testcase submitted with LPP-7721 works.
  Verified that Tucker's test case from LPP-7514 works. (illustrating that an error in a function
    is ignored, allowing the function to return 'normally' and execution to continue).



Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java	2009-02-07 14:58:57 UTC (rev 12786)
+++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java	2009-02-07 19:44:33 UTC (rev 12787)
@@ -1235,13 +1235,15 @@
     // not propogated to our caller.
     // To preserve return types, we implement this with a closure,
     // but that introduces restrictions:
-    // We cannot put a super call in a closure.
-    // Having another function closure within a closure apparently
-    // causes problems accessing certain variables for the flex compiler.
+    // - We cannot put a super call in a closure.
+    // - Having another function closure within a closure apparently
+    //   causes problems accessing certain variables for the flex compiler.
+    // - We cannot put code that references 'arguments' into a closure.
     boolean tryAll = options.getBoolean(Compiler.CATCH_FUNCTION_EXCEPTIONS)
       && matchingAncestor(node, ASTFunctionExpression.class, false) == null
       && matchingDescendant(node, ASTSuperCallExpression.class, false) == null
       && matchingDescendant(node, ASTFunctionExpression.class, false) == null
+      && matchingIdentifier(node, "arguments") == null
       && functionName != null;
       
     String tryType = "";
@@ -1585,6 +1587,26 @@
     return null;
   }
 
+  // walk down the AST and find a match of an identifier with a name
+  SimpleNode matchingIdentifier(SimpleNode node, String identName) {
+    if (node == null) {
+      return null;
+    }
+    else if (node instanceof ASTIdentifier && ((ASTIdentifier)node).getName().equals(identName)) {
+      return node;
+    }
+    else {
+      SimpleNode[] children = node.getChildren();
+      for (int i=0; i<children.length; i++) {
+        SimpleNode result = matchingIdentifier(children[i], identName);
+        if (result != null) {
+          return result;
+        }
+      }
+    }
+    return null;
+  }
+
   SimpleNode translateLiteralNode(SimpleNode node) {
     return node;
   }

Modified: openlaszlo/trunk/lps/components/rpc/javarpc.lzx
===================================================================
--- openlaszlo/trunk/lps/components/rpc/javarpc.lzx	2009-02-07 14:58:57 UTC (rev 12786)
+++ openlaszlo/trunk/lps/components/rpc/javarpc.lzx	2009-02-07 19:44:33 UTC (rev 12787)
@@ -161,7 +161,6 @@
 
                 var DOREQ = stubinfo['doreq'] ? stubinfo['doreq'] : false;
                 var DORES = stubinfo['dores'] ? stubinfo['dores'] : false;
-#pragma "catchFunctionExceptions=false"
                 var stubfunc = function (){
                    var args = arguments.callee.args;
                    return LzJavaRPCService.invoke(

Modified: openlaszlo/trunk/lps/components/rpc/soap.lzx
===================================================================
--- openlaszlo/trunk/lps/components/rpc/soap.lzx	2009-02-07 14:58:57 UTC (rev 12786)
+++ openlaszlo/trunk/lps/components/rpc/soap.lzx	2009-02-07 19:44:33 UTC (rev 12787)
@@ -99,7 +99,6 @@
            // "service": "MathService",
            // "wsdl": "http://www.dotnetjunkies.com/quickstart/aspplus......./mathservice.asmx?WSDL"},
            //                                            args.superclass.secure,
-#pragma "catchFunctionExceptions=false"
            var stubfunc = function (){
                var args = arguments.callee.args;
                return LzSOAPService.invoke(

Modified: openlaszlo/trunk/lps/components/rpc/xmlrpc.lzx
===================================================================
--- openlaszlo/trunk/lps/components/rpc/xmlrpc.lzx	2009-02-07 14:58:57 UTC (rev 12786)
+++ openlaszlo/trunk/lps/components/rpc/xmlrpc.lzx	2009-02-07 19:44:33 UTC (rev 12787)
@@ -31,7 +31,6 @@
 
                 // create proxy for a particular funcname only once.
                 if ( this.proxy[method] == null ) {
-#pragma "catchFunctionExceptions=false"
                     this.proxy[method] = function (paramArr, delegate) {
                         var args = arguments.callee.args;
                         LzXMLRPCService.invoke(delegate, paramArr, 



More information about the Laszlo-checkins mailing list