Disentangles CompilationResult from Permutation. http://gwt-code-reviews.appspot.com/194801 Review by: bobv git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@7724 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/core/ext/linker/CompilationResult.java b/dev/core/src/com/google/gwt/core/ext/linker/CompilationResult.java index 7ce343a..cd0d96a 100644 --- a/dev/core/src/com/google/gwt/core/ext/linker/CompilationResult.java +++ b/dev/core/src/com/google/gwt/core/ext/linker/CompilationResult.java
@@ -16,7 +16,6 @@ package com.google.gwt.core.ext.linker; import com.google.gwt.core.ext.Linker; -import com.google.gwt.dev.Permutation; import java.util.Map; import java.util.SortedMap; @@ -27,12 +26,9 @@ * result in identical JavaScript. */ public abstract class CompilationResult extends Artifact<CompilationResult> { - private final Permutation permutation; - protected CompilationResult(Class<? extends Linker> linkerType, - Permutation permutation) { + protected CompilationResult(Class<? extends Linker> linkerType) { super(linkerType); - this.permutation = permutation; } /** @@ -48,18 +44,9 @@ public abstract String[] getJavaScript(); /** - * Return the permutation that compiled to this result. - */ - public Permutation getPermutation() { - return permutation; - } - - /** * Returns the permutation ID. */ - public int getPermutationId() { - return getPermutation().getId(); - } + public abstract int getPermutationId(); /** * Provides values for {@link SelectionProperty} instances that are not
diff --git a/dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java b/dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java index c5d332a..45ce6c3 100644 --- a/dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java +++ b/dev/core/src/com/google/gwt/core/ext/linker/impl/SelectionScriptLinker.java
@@ -26,8 +26,6 @@ import com.google.gwt.core.ext.linker.ScriptReference; import com.google.gwt.core.ext.linker.SelectionProperty; import com.google.gwt.core.ext.linker.StylesheetReference; -import com.google.gwt.dev.cfg.BindingProperty; -import com.google.gwt.dev.cfg.StaticPropertyOracle; import com.google.gwt.dev.util.Util; import com.google.gwt.dev.util.collect.HashSet; import com.google.gwt.dev.util.collect.Lists; @@ -163,8 +161,7 @@ + result.getStrongName() + File.separator + i + FRAGMENT_EXTENSION)); } - toReturn.addAll(emitSelectionInformation(result.getPermutation().getId(), - result.getStrongName(), result.getPermutation().getPropertyOracles())); + toReturn.addAll(emitSelectionInformation(result.getStrongName(), result)); return toReturn; } @@ -434,18 +431,14 @@ } } - private List<Artifact<?>> emitSelectionInformation(int id, String strongName, - StaticPropertyOracle[] staticPropertyOracles) { + private List<Artifact<?>> emitSelectionInformation(String strongName, + CompilationResult result) { List<Artifact<?>> emitted = new ArrayList<Artifact<?>>(); - for (int propOracleId = 0; propOracleId < staticPropertyOracles.length; propOracleId++) { - StaticPropertyOracle propOracle = staticPropertyOracles[propOracleId]; + for (SortedMap<SelectionProperty, String> propertyMap : result.getPropertyMap()) { TreeMap<String, String> propMap = new TreeMap<String, String>(); - - BindingProperty[] orderedProps = propOracle.getOrderedProps(); - String[] orderedPropValues = propOracle.getOrderedPropValues(); - for (int i = 0; i < orderedProps.length; i++) { - propMap.put(orderedProps[i].getName(), orderedPropValues[i]); + for (Map.Entry<SelectionProperty, String> entry : propertyMap.entrySet()) { + propMap.put(entry.getKey().getName(), entry.getValue()); } emitted.add(new SelectionInformation(strongName, propMap)); }
diff --git a/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardCompilationResult.java b/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardCompilationResult.java index b80f8bb..c8776a0 100644 --- a/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardCompilationResult.java +++ b/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardCompilationResult.java
@@ -19,7 +19,6 @@ import com.google.gwt.core.ext.linker.SelectionProperty; import com.google.gwt.core.ext.linker.StatementRanges; import com.google.gwt.core.ext.linker.SymbolData; -import com.google.gwt.dev.Permutation; import com.google.gwt.dev.jjs.PermutationResult; import com.google.gwt.dev.util.DiskCache; import com.google.gwt.dev.util.Util; @@ -84,18 +83,20 @@ private final long symbolToken; + private final int permutationId; + public StandardCompilationResult(PermutationResult permutationResult) { - super(StandardLinkerContext.class, permutationResult.getPermutation()); + super(StandardLinkerContext.class); byte[][] js = permutationResult.getJs(); - strongName = Util.computeStrongName(js); + this.strongName = Util.computeStrongName(js); byte[] serializedSymbolMap = permutationResult.getSerializedSymbolMap(); - statementRanges = permutationResult.getStatementRanges(); - Permutation permutation = permutationResult.getPermutation(); - jsToken = new long[js.length]; + this.statementRanges = permutationResult.getStatementRanges(); + this.permutationId = permutationResult.getPermutation().getId(); + this.jsToken = new long[js.length]; for (int i = 0; i < jsToken.length; ++i) { jsToken[i] = diskCache.writeByteArray(js[i]); } - symbolToken = diskCache.writeByteArray(serializedSymbolMap); + this.symbolToken = diskCache.writeByteArray(serializedSymbolMap); } /** @@ -119,6 +120,11 @@ } @Override + public int getPermutationId() { + return permutationId; + } + + @Override public SortedSet<SortedMap<SelectionProperty, String>> getPropertyMap() { return Collections.unmodifiableSortedSet(propertyValues); }