Revision: 6430
Author: [email protected]
Date: Tue Oct 20 16:10:57 2009
Log: Cherry pick tr...@6429 Bugfix when rewriting static calls with  
JMultiExpr qualifiers

svn merge --ignore-ancestry -c 6429  
https://google-web-toolkit.googlecode.com/svn/trunk .


http://code.google.com/p/google-web-toolkit/source/detail?r=6430

Modified:
  /releases/2.0/branch-info.txt
  /releases/2.0/dev/core/src/com/google/gwt/dev/jjs/impl/MakeCallsStatic.java

=======================================
--- /releases/2.0/branch-info.txt       Mon Oct 19 12:30:46 2009
+++ /releases/2.0/branch-info.txt       Tue Oct 20 16:10:57 2009
@@ -10,6 +10,5 @@

  Merges to this branch:

-
-The next merge into trunk will be:
-svn merge -r6420:????  
https://google-web-toolkit.googlecode.com/svn/releases/2.0 .
+tr...@6429 was merged into this branch, Bugfix when rewriting static calls  
with JMultiExpr qualifiers
+    svn merge --ignore_ancestry -c 6429  
https://google-web-toolkit.googlecode.com/svn/trunk .
=======================================
---  
/releases/2.0/dev/core/src/com/google/gwt/dev/jjs/impl/MakeCallsStatic.java     
 
Mon Apr 20 15:21:46 2009
+++  
/releases/2.0/dev/core/src/com/google/gwt/dev/jjs/impl/MakeCallsStatic.java     
 
Tue Oct 20 16:10:57 2009
@@ -19,6 +19,7 @@
  import com.google.gwt.dev.jjs.ast.Context;
  import com.google.gwt.dev.jjs.ast.JAbstractMethodBody;
  import com.google.gwt.dev.jjs.ast.JClassType;
+import com.google.gwt.dev.jjs.ast.JExpression;
  import com.google.gwt.dev.jjs.ast.JMethod;
  import com.google.gwt.dev.jjs.ast.JMethodBody;
  import com.google.gwt.dev.jjs.ast.JMethodCall;
@@ -31,6 +32,7 @@
  import com.google.gwt.dev.jjs.ast.JThisRef;
  import com.google.gwt.dev.jjs.ast.JType;
  import com.google.gwt.dev.jjs.ast.JVisitor;
+import com.google.gwt.dev.jjs.ast.js.JMultiExpression;
  import com.google.gwt.dev.jjs.ast.js.JsniMethodBody;
  import com.google.gwt.dev.js.ast.JsContext;
  import com.google.gwt.dev.js.ast.JsExpression;
@@ -320,15 +322,31 @@
      return new MakeCallsStatic(program).execImpl();
    }

-  static JMethodCall makeStaticCall(JMethodCall x, JMethod newMethod) {
+  static JExpression makeStaticCall(JMethodCall x, JMethod newMethod) {
      // Update the call site
      JMethodCall newCall = new JMethodCall(x.getSourceInfo().makeChild(
          MakeCallsStatic.class, "Devirtualized function call"), null,  
newMethod);

-    // The qualifier becomes the first arg
-    newCall.addArg(x.getInstance());
-    newCall.addArgs(x.getArgs());
-    return newCall;
+    /*
+     * If the qualifier is a JMultiExpression, invoke on the last value.  
This
+     * ensures that clinits maintain the same execution order relative to
+     * parameters in deeply-inlined scenarios.
+     */
+    // (a, b).foo() --> (a, foo(b))
+    if (x.getInstance() instanceof JMultiExpression) {
+      JMultiExpression multi = (JMultiExpression) x.getInstance();
+      int lastIndex = multi.exprs.size() - 1;
+      newCall.addArg(multi.exprs.get(lastIndex));
+      newCall.addArgs(x.getArgs());
+      multi.exprs.set(lastIndex, newCall);
+      return multi;
+    } else {
+      // The qualifier becomes the first arg
+      // a.foo(b) --> foo(a,b)
+      newCall.addArg(x.getInstance());
+      newCall.addArgs(x.getArgs());
+      return newCall;
+    }
    }

    protected Set<JMethod> toBeMadeStatic = new HashSet<JMethod>();

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to