diff --git a/core/src/main/java/org/teavm/dependency/DependencyAnalyzer.java b/core/src/main/java/org/teavm/dependency/DependencyAnalyzer.java index 96c3e98b6..042018743 100644 --- a/core/src/main/java/org/teavm/dependency/DependencyAnalyzer.java +++ b/core/src/main/java/org/teavm/dependency/DependencyAnalyzer.java @@ -75,7 +75,7 @@ public class DependencyAnalyzer implements DependencyInfo { private CachedMapper classCache; private List listeners = new ArrayList<>(); private ServiceRepository services; - private Deque pendingTransitions = new ArrayDeque<>(); + private Deque pendingTransitions = new ArrayDeque<>(); private Deque tasks = new ArrayDeque<>(); private Queue deferredTasks = new ArrayDeque<>(); List types = new ArrayList<>(); @@ -275,7 +275,7 @@ public class DependencyAnalyzer implements DependencyInfo { } } - void schedulePropagation(DependencyNodeToNodeTransition consumer, DependencyType type) { + void schedulePropagation(Transition consumer, DependencyType type) { if (!consumer.destination.filter(type)) { return; } @@ -294,7 +294,7 @@ public class DependencyAnalyzer implements DependencyInfo { } } - void schedulePropagation(DependencyNodeToNodeTransition consumer, DependencyType[] types) { + void schedulePropagation(Transition consumer, DependencyType[] types) { if (types.length == 0) { return; } @@ -630,7 +630,7 @@ public class DependencyAnalyzer implements DependencyInfo { private void processNodeToNodeTransitionQueue() { while (!pendingTransitions.isEmpty()) { - DependencyNodeToNodeTransition transition = pendingTransitions.remove(); + Transition transition = pendingTransitions.remove(); IntSet pendingTypes = transition.pendingTypes; transition.pendingTypes = null; if (pendingTypes.size() == 1) { diff --git a/core/src/main/java/org/teavm/dependency/DependencyNode.java b/core/src/main/java/org/teavm/dependency/DependencyNode.java index 22b291e8b..5ee8c062e 100644 --- a/core/src/main/java/org/teavm/dependency/DependencyNode.java +++ b/core/src/main/java/org/teavm/dependency/DependencyNode.java @@ -36,8 +36,8 @@ public class DependencyNode implements ValueDependencyInfo { DependencyAnalyzer dependencyAnalyzer; List followers; TypeSet typeSet; - ObjectObjectHashMap transitions; - ObjectArrayList transitionList; + ObjectObjectHashMap transitions; + ObjectArrayList transitionList; String tag; private DependencyNode arrayItemNode; private DependencyNode classValueNode; @@ -78,15 +78,15 @@ public class DependencyNode implements ValueDependencyInfo { } } - ObjectArrayList transitions = new ObjectArrayList<>(typeSet.getTransitions()); + ObjectArrayList transitions = new ObjectArrayList<>(typeSet.getTransitions()); List consumerEntries = typeSet.getConsumers(); if (action != null) { action.run(); } - for (ObjectCursor cursor : transitions) { - DependencyNodeToNodeTransition transition = cursor.value; + for (ObjectCursor cursor : transitions) { + Transition transition = cursor.value; if (transition.source.filter(type) && transition.filterType(type)) { dependencyAnalyzer.schedulePropagation(transition, type); } @@ -156,15 +156,15 @@ public class DependencyNode implements ValueDependencyInfo { } } - ObjectArrayList transitions = new ObjectArrayList<>(typeSet.getTransitions()); + ObjectArrayList transitions = new ObjectArrayList<>(typeSet.getTransitions()); List consumerEntries = typeSet.getConsumers(); if (action != null) { action.run(); } - for (ObjectCursor cursor : transitions) { - DependencyNodeToNodeTransition transition = cursor.value; + for (ObjectCursor cursor : transitions) { + Transition transition = cursor.value; DependencyType[] typesToPropagate = newTypes; if (transition.source.typeFilter != null || transition.filter != null) { int j = 0; @@ -276,7 +276,7 @@ public class DependencyNode implements ValueDependencyInfo { return; } - DependencyNodeToNodeTransition transition = new DependencyNodeToNodeTransition(this, node, filter); + Transition transition = new Transition(this, node, filter); transitions.put(node, transition); transitionList.add(transition); if (DependencyAnalyzer.shouldLog) { @@ -358,8 +358,7 @@ public class DependencyNode implements ValueDependencyInfo { return; } - for (DependencyNodeToNodeTransition transition : classNodeParent.transitionList - .toArray(DependencyNodeToNodeTransition.class)) { + for (Transition transition : classNodeParent.transitionList.toArray(Transition.class)) { connect(transition.destination.getClassValueNode()); } } @@ -370,7 +369,7 @@ public class DependencyNode implements ValueDependencyInfo { } } - private void propagateTypes(DependencyNodeToNodeTransition transition) { + private void propagateTypes(Transition transition) { if (typeSet != null) { dependencyAnalyzer.schedulePropagation(transition, getTypesInternal()); } @@ -522,8 +521,8 @@ public class DependencyNode implements ValueDependencyInfo { } if (node.transitions != null) { - for (ObjectCursor cursor : node.transitionList) { - DependencyNodeToNodeTransition transition = cursor.value; + for (ObjectCursor cursor : node.transitionList) { + Transition transition = cursor.value; if (transition.filter == null && transition.destination.typeSet == typeSet && !visited.contains(transition.destination) && transition.isDestSubsetOfSrc()) { stack.push(transition.destination); diff --git a/core/src/main/java/org/teavm/dependency/DependencyNodeToNodeTransition.java b/core/src/main/java/org/teavm/dependency/Transition.java similarity index 96% rename from core/src/main/java/org/teavm/dependency/DependencyNodeToNodeTransition.java rename to core/src/main/java/org/teavm/dependency/Transition.java index a111d1f13..c2f526c5b 100644 --- a/core/src/main/java/org/teavm/dependency/DependencyNodeToNodeTransition.java +++ b/core/src/main/java/org/teavm/dependency/Transition.java @@ -22,7 +22,7 @@ import java.util.Collection; import org.teavm.model.ClassReaderSource; import org.teavm.model.ValueType; -class DependencyNodeToNodeTransition { +class Transition { DependencyNode source; DependencyNode destination; DependencyTypeFilter filter; @@ -30,7 +30,7 @@ class DependencyNodeToNodeTransition { IntHashSet pendingTypes; byte destSubsetOfSrc; - DependencyNodeToNodeTransition(DependencyNode source, DependencyNode destination, DependencyTypeFilter filter) { + Transition(DependencyNode source, DependencyNode destination, DependencyTypeFilter filter) { this.source = source; this.destination = destination; this.filter = filter; @@ -79,7 +79,7 @@ class DependencyNodeToNodeTransition { } boolean shouldMergeDomains() { - if (filter != null) { + if (filter != null || !isDestSubsetOfSrc()) { return false; } if (destination.typeSet == null) { diff --git a/core/src/main/java/org/teavm/dependency/TypeSet.java b/core/src/main/java/org/teavm/dependency/TypeSet.java index 15e81bd29..e603a0b2d 100644 --- a/core/src/main/java/org/teavm/dependency/TypeSet.java +++ b/core/src/main/java/org/teavm/dependency/TypeSet.java @@ -34,7 +34,7 @@ class TypeSet { private int typesCount; Set domain = new LinkedHashSet<>(); - ObjectArrayList transitions; + ObjectArrayList transitions; ArrayList consumers; TypeSet(DependencyAnalyzer dependencyAnalyzer, DependencyNode origin) { @@ -154,13 +154,13 @@ class TypeSet { consumers = null; } - ObjectArrayList getTransitions() { + ObjectArrayList getTransitions() { if (transitions == null) { transitions = new ObjectArrayList<>(domain.size() * 2); for (DependencyNode node : domain) { if (node.transitions != null) { - for (ObjectCursor cursor : node.transitionList) { - DependencyNodeToNodeTransition transition = cursor.value; + for (ObjectCursor cursor : node.transitionList) { + Transition transition = cursor.value; if (transition.filter != null || transition.destination.typeSet != this) { transitions.add(transition); }