src/share/classes/com/sun/tools/javac/comp/Infer.java

changeset 1608
133a0a0c2cbc
parent 1562
2154ed9ff6c8
child 1628
5ddecb91d843
equal deleted inserted replaced
1607:bd49e0304281 1608:133a0a0c2cbc
1214 * variables to be solved. Then Tarjan is used to found all connected components 1214 * variables to be solved. Then Tarjan is used to found all connected components
1215 * in the graph. For each component containing more than one node, a super node is 1215 * in the graph. For each component containing more than one node, a super node is
1216 * created, effectively replacing the original cyclic nodes. 1216 * created, effectively replacing the original cyclic nodes.
1217 */ 1217 */
1218 void initNodes() { 1218 void initNodes() {
1219 ArrayList<Node> nodes = new ArrayList<Node>(); 1219 nodes = new ArrayList<Node>();
1220 for (Type t : inferenceContext.restvars()) { 1220 for (Type t : inferenceContext.restvars()) {
1221 nodes.add(new Node(t)); 1221 nodes.add(new Node(t));
1222 } 1222 }
1223 for (Node n_i : nodes) { 1223 for (Node n_i : nodes) {
1224 Type i = n_i.data.first(); 1224 Type i = n_i.data.first();
1233 n_j.deps.add(n_i); 1233 n_j.deps.add(n_i);
1234 } 1234 }
1235 } 1235 }
1236 } 1236 }
1237 } 1237 }
1238 this.nodes = new ArrayList<Node>(); 1238 ArrayList<Node> acyclicNodes = new ArrayList<Node>();
1239 for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) { 1239 for (List<? extends Node> conSubGraph : GraphUtils.tarjan(nodes)) {
1240 if (conSubGraph.length() > 1) { 1240 if (conSubGraph.length() > 1) {
1241 Node root = conSubGraph.head; 1241 Node root = conSubGraph.head;
1242 root.mergeWith(conSubGraph.tail); 1242 root.mergeWith(conSubGraph.tail);
1243 for (Node n : conSubGraph) { 1243 for (Node n : conSubGraph) {
1244 notifyUpdate(n, root); 1244 notifyUpdate(n, root);
1245 } 1245 }
1246 } 1246 }
1247 this.nodes.add(conSubGraph.head); 1247 acyclicNodes.add(conSubGraph.head);
1248 } 1248 }
1249 nodes = acyclicNodes;
1249 } 1250 }
1250 1251
1251 /** 1252 /**
1252 * Debugging: dot representation of this graph 1253 * Debugging: dot representation of this graph
1253 */ 1254 */

mercurial