A PermutationResult is now integrally tied to a Permutation.

Suggested by: spoon
Patch by: me
Review by: spoon (TBR)



git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@6499 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardLinkerContext.java b/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardLinkerContext.java
index 967ee85..52c7ccc 100644
--- a/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardLinkerContext.java
+++ b/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardLinkerContext.java
@@ -268,7 +268,7 @@
       result = new StandardCompilationResult(strongName, js,
           permutationResult.getSerializedSymbolMap(),
           permutationResult.getStatementRanges(),
-          permutationResult.getPermutationId());
+          permutationResult.getPermutation().getId());
       resultsByStrongName.put(result.getStrongName(), result);
       artifacts.add(result);
     }
diff --git a/dev/core/src/com/google/gwt/dev/CompilePerms.java b/dev/core/src/com/google/gwt/dev/CompilePerms.java
index c64151c..69676ae 100644
--- a/dev/core/src/com/google/gwt/dev/CompilePerms.java
+++ b/dev/core/src/com/google/gwt/dev/CompilePerms.java
@@ -184,9 +184,7 @@
   public static PermutationResult compile(TreeLogger logger,
       Permutation permutation, UnifiedAst unifiedAst)
       throws UnableToCompleteException {
-    return unifiedAst.compilePermutation(logger,
-        permutation.getRebindAnswers(), permutation.getPropertyOracles(),
-        permutation.getId());
+    return unifiedAst.compilePermutation(logger, permutation);
   }
 
   /**
diff --git a/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java b/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
index 99d34a3..1a1aa8f 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
@@ -32,6 +32,7 @@
 import com.google.gwt.core.ext.soyc.impl.SplitPointRecorder;
 import com.google.gwt.core.ext.soyc.impl.StoryRecorder;
 import com.google.gwt.core.linker.SoycReportLinker;
+import com.google.gwt.dev.Permutation;
 import com.google.gwt.dev.cfg.ModuleDef;
 import com.google.gwt.dev.jdt.RebindPermutationOracle;
 import com.google.gwt.dev.jdt.WebModeCompilerFrontEnd;
@@ -148,17 +149,18 @@
   private static class PermutationResultImpl implements PermutationResult {
     private final ArtifactSet artifacts = new ArtifactSet();
     private final byte[][] js;
-    private final int permutationId;
+    private Permutation permutation;
     private final byte[] serializedSymbolMap;
     private final StatementRanges[] statementRanges;
 
-    public PermutationResultImpl(String[] js, SymbolData[] symbolMap,
-        StatementRanges[] statementRanges, int permutationId) {
+    public PermutationResultImpl(String[] js, Permutation permutation,
+        SymbolData[] symbolMap, StatementRanges[] statementRanges) {
       byte[][] bytes = new byte[js.length][];
       for (int i = 0; i < js.length; ++i) {
         bytes[i] = Util.getBytes(js[i]);
       }
       this.js = bytes;
+      this.permutation = permutation;
       try {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         Util.writeObjectToStream(baos, (Object) symbolMap);
@@ -168,7 +170,6 @@
             e);
       }
       this.statementRanges = statementRanges;
-      this.permutationId = permutationId;
     }
 
     public ArtifactSet getArtifacts() {
@@ -179,8 +180,8 @@
       return js;
     }
 
-    public int getPermutationId() {
-      return permutationId;
+    public Permutation getPermutation() {
+      return permutation;
     }
 
     public byte[] getSerializedSymbolMap() {
@@ -198,20 +199,17 @@
    * @param logger the logger to use
    * @param unifiedAst the result of a
    *          {@link #precompile(TreeLogger, WebModeCompilerFrontEnd, String[], JJSOptions, boolean)}
-   * @param rebindAnswers the set of rebind answers to resolve all outstanding
-   *          rebind decisions for this permutation
-   * @param propertyOracles all property oracles corresponding to this
-   *          permutation
-   * @param permutationId the unique id of this permutation
+   * @param permutation the permutation to compile
    * @return the output JavaScript
    * @throws UnableToCompleteException if an error other than
    *           {@link OutOfMemoryError} occurs
    */
   public static PermutationResult compilePermutation(TreeLogger logger,
-      UnifiedAst unifiedAst, Map<String, String> rebindAnswers,
-      PropertyOracle[] propertyOracles, int permutationId)
+      UnifiedAst unifiedAst, Permutation permutation)
       throws UnableToCompleteException {
-
+    PropertyOracle[] propertyOracles = permutation.getPropertyOracles();
+    int permutationId = permutation.getId();
+    Map<String, String> rebindAnswers = permutation.getRebindAnswers();
     int printId = permutationId + 1;
     logger.log(TreeLogger.INFO, "Compiling permutation " + printId + "...");
     long permStart = System.currentTimeMillis();
@@ -356,8 +354,8 @@
       generateJavaScriptCode(options, jsProgram, map, js, ranges,
           sizeBreakdowns, sourceInfoMaps, splitBlocks);
 
-      PermutationResult toReturn = new PermutationResultImpl(js,
-          makeSymbolMap(symbolTable), ranges, permutationId);
+      PermutationResult toReturn = new PermutationResultImpl(js, permutation,
+          makeSymbolMap(symbolTable), ranges);
       toReturn.getArtifacts().addAll(
           makeSoycArtifacts(logger, permutationId, jprogram, js,
               sizeBreakdowns, sourceInfoMaps, dependencies, map, obfuscateMap));
diff --git a/dev/core/src/com/google/gwt/dev/jjs/PermutationResult.java b/dev/core/src/com/google/gwt/dev/jjs/PermutationResult.java
index 3c88f4b..28002ff 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/PermutationResult.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/PermutationResult.java
@@ -17,6 +17,7 @@
 
 import com.google.gwt.core.ext.linker.ArtifactSet;
 import com.google.gwt.core.ext.linker.StatementRanges;
+import com.google.gwt.dev.Permutation;
 
 import java.io.Serializable;
 
@@ -24,6 +25,7 @@
  * An extensible return type for the results of compiling a single permutation.
  */
 public interface PermutationResult extends Serializable {
+
   /**
    * Returns any Artifacts that may have been created as a result of compiling
    * the permutation.
@@ -36,10 +38,10 @@
   byte[][] getJs();
 
   /**
-   * The ID of the permutation.
+   * Returns the associated permutation.
    */
-  int getPermutationId();
-  
+  Permutation getPermutation();
+
   /**
    * The symbol map for the permutation.
    */
diff --git a/dev/core/src/com/google/gwt/dev/jjs/UnifiedAst.java b/dev/core/src/com/google/gwt/dev/jjs/UnifiedAst.java
index a33b8e8..8f3bfb4 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/UnifiedAst.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/UnifiedAst.java
@@ -15,9 +15,9 @@
  */
 package com.google.gwt.dev.jjs;
 
-import com.google.gwt.core.ext.PropertyOracle;
 import com.google.gwt.core.ext.TreeLogger;
 import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.dev.Permutation;
 import com.google.gwt.dev.jjs.ast.JProgram;
 import com.google.gwt.dev.js.ast.JsProgram;
 import com.google.gwt.dev.util.PerfLogger;
@@ -29,7 +29,6 @@
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
 import java.util.Collections;
-import java.util.Map;
 import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
@@ -148,20 +147,15 @@
    * Compiles a particular permutation.
    * 
    * @param logger the logger to use
-   * @param rebindAnswers the set of rebind answers to resolve all outstanding
-   *          rebind decisions for this permutation
-   * @param propertyOracles all property oracles corresponding to this
-   *          permutation
-   * @param permutationId the unique id of this permutation
+   * @param permutation the permutation to compile
    * @return the permutation result
    * @throws UnableToCompleteException if an error other than
    *           {@link OutOfMemoryError} occurs
    */
   public PermutationResult compilePermutation(TreeLogger logger,
-      Map<String, String> rebindAnswers, PropertyOracle[] propertyOracles,
-      int permutationId) throws UnableToCompleteException {
+      Permutation permutation) throws UnableToCompleteException {
     return JavaToJavaScriptCompiler.compilePermutation(logger, this,
-        rebindAnswers, propertyOracles, permutationId);
+        permutation);
   }
 
   /**