Reviewers: zundel, jbrosenberg,

Message:
Just a few things I ran into doing some other work.


http://gwt-code-reviews.appspot.com/1446802/diff/1/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardSymbolData.java
File
dev/core/src/com/google/gwt/core/ext/linker/impl/StandardSymbolData.java
(right):

http://gwt-code-reviews.appspot.com/1446802/diff/1/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardSymbolData.java#newcode140
dev/core/src/com/google/gwt/core/ext/linker/impl/StandardSymbolData.java:140:
return isClass() ? className : getJsniIdent();
Fields looked bad in the debugger.

http://gwt-code-reviews.appspot.com/1446802/diff/1/dev/core/src/com/google/gwt/dev/jjs/ast/JNewArray.java
File dev/core/src/com/google/gwt/dev/jjs/ast/JNewArray.java (left):

http://gwt-code-reviews.appspot.com/1446802/diff/1/dev/core/src/com/google/gwt/dev/jjs/ast/JNewArray.java#oldcode30
dev/core/src/com/google/gwt/dev/jjs/ast/JNewArray.java:30:
Way too much memory used here in the most common cases.

http://gwt-code-reviews.appspot.com/1446802/diff/1/dev/core/src/com/google/gwt/dev/jjs/ast/JNewArray.java#oldcode78
dev/core/src/com/google/gwt/dev/jjs/ast/JNewArray.java:78: return
(JArrayType) type.getUnderlyingType();
Forgotten cleanup.

http://gwt-code-reviews.appspot.com/1446802/diff/1/dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java
File dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java (left):

http://gwt-code-reviews.appspot.com/1446802/diff/1/dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java#oldcode777
dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java:777: boolean
nestedSuper = superClass.isNestedType() && !superClass.isStatic();
Was using this same code everywhere.

http://gwt-code-reviews.appspot.com/1446802/diff/1/dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java#oldcode2498
dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java:2498:
nestedBinding = (NestedTypeBinding) targetBinding;
This was actually blowing up on cross-unit enclosed object
instantiations, because the BinaryTypeBinding was not a
NestedTypeBinding, which is a subclass of SourceTypeBinding.

http://gwt-code-reviews.appspot.com/1446802/diff/1/dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRebinds.java
File dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRebinds.java
(left):

http://gwt-code-reviews.appspot.com/1446802/diff/1/dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRebinds.java#oldcode123
dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRebinds.java:123: if
(node instanceof HasName) {
Always true, just a little cleanup while I was porting this code over.



Please review this at http://gwt-code-reviews.appspot.com/1446802/

Affected files:
  M dev/core/src/com/google/gwt/core/ext/linker/impl/StandardSymbolData.java
  M dev/core/src/com/google/gwt/dev/jjs/ast/JNewArray.java
  M dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java
  M dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRebinds.java


Index: dev/core/src/com/google/gwt/core/ext/linker/impl/StandardSymbolData.java diff --git a/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardSymbolData.java b/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardSymbolData.java index 5112b94d9fb6c602ce60870ff9c4152538ff8a18..fc57185dca0fedcee3dffb30df51502bdda86d04 100644 --- a/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardSymbolData.java +++ b/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardSymbolData.java
@@ -137,7 +137,7 @@ public class StandardSymbolData implements SymbolData {

   @Override
   public String toString() {
-    return methodSig != null ? methodSig : className;
+    return isClass() ? className : getJsniIdent();
   }

   private void readObject(ObjectInputStream in) throws IOException,
Index: dev/core/src/com/google/gwt/dev/jjs/ast/JNewArray.java
diff --git a/dev/core/src/com/google/gwt/dev/jjs/ast/JNewArray.java b/dev/core/src/com/google/gwt/dev/jjs/ast/JNewArray.java index 4ceec032292124fac09ac161b5e466cefd500739..21e2f47a4a42653c3c009c26ea0d1fcb1c48d228 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/ast/JNewArray.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/ast/JNewArray.java
@@ -16,8 +16,8 @@
 package com.google.gwt.dev.jjs.ast;

 import com.google.gwt.dev.jjs.SourceInfo;
+import com.google.gwt.dev.util.collect.Lists;

-import java.util.ArrayList;
 import java.util.List;

 /**
@@ -26,8 +26,6 @@ import java.util.List;
 public class JNewArray extends JExpression {

public static JNewArray createDims(SourceInfo info, JArrayType arrayType, List<JExpression> dims) {
-    List<JClassLiteral> classLiterals = new ArrayList<JClassLiteral>();
-
     // Produce all class literals that will eventually get generated.
     int realDims = 0;
     for (JExpression dim : dims) {
@@ -37,11 +35,12 @@ public class JNewArray extends JExpression {
       ++realDims;
     }

+    List<JClassLiteral> classLiterals = Lists.create();
     JType cur = arrayType;
     for (int i = 0; i < realDims; ++i) {
       // Walk down each type from most dims to least.
       JClassLiteral classLit = new JClassLiteral(info.makeChild(), cur);
-      classLiterals.add(classLit);
+      classLiterals = Lists.add(classLiterals, classLit);
       cur = ((JArrayType) cur).getElementType();
     }
     return new JNewArray(info, arrayType, dims, null, classLiterals);
@@ -49,8 +48,8 @@ public class JNewArray extends JExpression {

public static JNewArray createInitializers(SourceInfo info, JArrayType arrayType,
       List<JExpression> initializers) {
-    List<JClassLiteral> classLiterals = new ArrayList<JClassLiteral>();
-    classLiterals.add(new JClassLiteral(info.makeChild(), arrayType));
+    List<JClassLiteral> classLiterals =
+        Lists.create(new JClassLiteral(info.makeChild(), arrayType));
return new JNewArray(info, arrayType, null, initializers, classLiterals);
   }

@@ -75,7 +74,7 @@ public class JNewArray extends JExpression {
   }

   public JArrayType getArrayType() {
-    return (JArrayType) type.getUnderlyingType();
+    return type;
   }

   /**
Index: dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java b/dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java index 1d4519d98fabbf5813e46550ced87f6706e560d2..3a0559f08b55c8e7dcde0d398ec737d979722c95 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java
@@ -659,7 +659,7 @@ public class GwtAstBuilder {
          */
         if (!hasExplicitThis) {
ReferenceBinding declaringClass = (ReferenceBinding) x.binding.declaringClass.erasure();
-          if (declaringClass instanceof NestedTypeBinding) {
+          if (isNested(declaringClass)) {
NestedTypeBinding nestedBinding = (NestedTypeBinding) declaringClass;
             if (nestedBinding.enclosingInstances != null) {
for (SyntheticArgumentBinding arg : nestedBinding.enclosingInstances) {
@@ -774,7 +774,7 @@ public class GwtAstBuilder {
         if (x.isSuperAccess()) {
           JExpression qualifier = pop(x.qualification);
           ReferenceBinding superClass = x.binding.declaringClass;
- boolean nestedSuper = superClass.isNestedType() && !superClass.isStatic();
+          boolean nestedSuper = isNested(superClass);
           if (nestedSuper) {
processSuperCallThisArgs(superClass, call, qualifier, x.qualification);
           }
@@ -785,7 +785,7 @@ public class GwtAstBuilder {
         } else {
           assert (x.qualification == null);
           ReferenceBinding declaringClass = x.binding.declaringClass;
- boolean nested = declaringClass.isNestedType() && !declaringClass.isStatic();
+          boolean nested = isNested(declaringClass);
           if (nested) {
             processThisCallThisArgs(declaringClass, call);
           }
@@ -1559,7 +1559,8 @@ public class GwtAstBuilder {

         // Map synthetic arguments for outer this.
ReferenceBinding declaringClass = (ReferenceBinding) x.binding.declaringClass.erasure();
-        if (declaringClass.isNestedType() && !declaringClass.isStatic()) {
+        boolean isNested = isNested(declaringClass);
+        if (isNested) {
NestedTypeBinding nestedBinding = (NestedTypeBinding) declaringClass;
           if (nestedBinding.enclosingInstances != null) {
for (int i = 0; i < nestedBinding.enclosingInstances.length; ++i) {
@@ -1577,7 +1578,7 @@ public class GwtAstBuilder {
         }

         // Map synthetic arguments for locals.
-        if (declaringClass.isNestedType() && !declaringClass.isStatic()) {
+        if (isNested) {
           // add synthetic args for locals
NestedTypeBinding nestedBinding = (NestedTypeBinding) declaringClass;
           // add synthetic args for outer this and locals
@@ -1892,7 +1893,7 @@ public class GwtAstBuilder {
        */
       int index = 0;
       SourceTypeBinding binding = x.binding;
-      if (binding.isNestedType() && !binding.isStatic()) {
+      if (isNested(binding)) {
         // add synthetic fields for outer this and locals
         assert (type instanceof JClassType);
         NestedTypeBinding nestedBinding = (NestedTypeBinding) binding;
@@ -2493,24 +2494,20 @@ public class GwtAstBuilder {

       // Synthetic args for inner classes
ReferenceBinding targetBinding = (ReferenceBinding) b.declaringClass.erasure();
-      NestedTypeBinding nestedBinding = null;
-      if (targetBinding.isNestedType() && !targetBinding.isStatic()) {
-        nestedBinding = (NestedTypeBinding) targetBinding;
-      }
-      if (nestedBinding != null) {
+      boolean isNested = isNested(targetBinding);
+      if (isNested) {
         // Synthetic this args for inner classes
-        if (nestedBinding.enclosingInstances != null) {
+        if (targetBinding.syntheticEnclosingInstanceTypes() != null) {
           ReferenceBinding checkedTargetType =
targetBinding.isAnonymousType() ? (ReferenceBinding) targetBinding.superclass()
                   .erasure() : targetBinding;
ReferenceBinding targetEnclosingType = checkedTargetType.enclosingType(); - for (SyntheticArgumentBinding arg : nestedBinding.enclosingInstances) {
-            TypeBinding argType = arg.type.erasure();
+ for (ReferenceBinding argType : targetBinding.syntheticEnclosingInstanceTypes()) {
+            argType = (ReferenceBinding) argType.erasure();
             if (qualifier != null && argType == targetEnclosingType) {
               call.addArg(qualExpr);
             } else {
-              JExpression thisRef =
- makeThisReference(info, (ReferenceBinding) argType, false, scope); + JExpression thisRef = makeThisReference(info, argType, false, scope);
               call.addArg(thisRef);
             }
           }
@@ -2521,10 +2518,10 @@ public class GwtAstBuilder {
       call.addArgs(arguments);

       // Synthetic args for inner classes
-      if (nestedBinding != null) {
+      if (isNested) {
         // Synthetic locals for local classes
-        if (nestedBinding.outerLocalVariables != null) {
- for (SyntheticArgumentBinding arg : nestedBinding.outerLocalVariables) {
+        if (targetBinding.syntheticOuterLocalVariables() != null) {
+ for (SyntheticArgumentBinding arg : targetBinding.syntheticOuterLocalVariables()) { LocalVariableBinding targetVariable = arg.actualOuterLocalVariable; VariableBinding[] path = scope.getEmulationPath(targetVariable);
             assert path.length == 1;
@@ -2819,6 +2816,10 @@ public class GwtAstBuilder {
     return stringInterner.intern(s);
   }

+  static boolean isNested(ReferenceBinding binding) {
+    return binding.isNestedType() && !binding.isStatic();
+  }
+
   /**
    * Returns <code>true</code> if JDT optimized the condition to
    * <code>false</code>.
@@ -3071,6 +3072,7 @@ public class GwtAstBuilder {
JDeclaredType enclosingType = (JDeclaredType) typeMap.get(declaringClass);
     assert !enclosingType.isExternal();
     JMethod method;
+    boolean isNested = isNested(declaringClass);
     if (x.isConstructor()) {
       method = new JConstructor(info, (JClassType) enclosingType);
       if (x.binding.declaringClass.isEnum()) {
@@ -3081,7 +3083,7 @@ public class GwtAstBuilder {
             method));
       }
       // add synthetic args for outer this
-      if (declaringClass.isNestedType() && !declaringClass.isStatic()) {
+      if (isNested) {
NestedTypeBinding nestedBinding = (NestedTypeBinding) declaringClass;
         if (nestedBinding.enclosingInstances != null) {
for (int i = 0; i < nestedBinding.enclosingInstances.length; ++i) {
@@ -3105,7 +3107,7 @@ public class GwtAstBuilder {
     createParameters(method, x);

     if (x.isConstructor()) {
-      if (declaringClass.isNestedType() && !declaringClass.isStatic()) {
+      if (isNested) {
         // add synthetic args for locals
NestedTypeBinding nestedBinding = (NestedTypeBinding) declaringClass;
         // add synthetic args for outer this and locals
Index: dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRebinds.java
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRebinds.java b/dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRebinds.java index 60e46492102c46328c2537fa4460cee6d0d843d4..94056eeba80cb675a04b3a954b3b3a3381549f66 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRebinds.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/ReplaceRebinds.java
@@ -100,45 +100,35 @@ public class ReplaceRebinds {
       JStringLiteral stringLiteral = (JStringLiteral) arg0;
       String stringValue = stringLiteral.getValue();

-      HasName named = null;
+      JNode node = null;

       JDeclaredType refType;
       JsniRef ref = JsniRef.parse(stringValue);

       if (ref != null) {
         final List<String> errors = new ArrayList<String>();
-        JNode node =
- JsniRefLookup.findJsniRefTarget(ref, program, new JsniRefLookup.ErrorReporter() {
-              public void reportError(String error) {
-                errors.add(error);
-              }
-            });
-
+ node = JsniRefLookup.findJsniRefTarget(ref, program, new JsniRefLookup.ErrorReporter() {
+          public void reportError(String error) {
+            errors.add(error);
+          }
+        });
         if (!errors.isEmpty()) {
           for (String error : errors) {
             logger.log(TreeLogger.ERROR, error);
           }
         }
-
-        if (node instanceof HasName) {
-          named = (HasName) node;
-        }
-
       } else {
         // See if it's just @foo.Bar, which would result in the class seed
-        refType =
+        node =
program.getFromTypeMap(stringValue.charAt(0) == '@' ? stringValue.substring(1)
                 : stringValue);
-        if (refType != null) {
-          named = refType;
-        }
       }
-
-      if (named == null) {
+      if (node == null) {
         // Not found, must be null
         ctx.replaceMe(JNullLiteral.INSTANCE);
       } else {
- ctx.replaceMe(new JNameOf(x.getSourceInfo(), program.getTypeJavaLangString(), named)); + ctx.replaceMe(new JNameOf(x.getSourceInfo(), program.getTypeJavaLangString(),
+            (HasName) node));
       }
     }
   }


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

Reply via email to