- \r
- } else {\r
- //\r
- // Get the node value and set visit flag as true.\r
- //\r
- stackList.get(stackList.size() - 1).isVisit = true;\r
- String[] libClassList = this.libInstanceMap.get(stackList\r
- .get(stackSize).nodeId);\r
- //\r
- // Push the node dependence library instance to the stack.\r
- //\r
- if (libClassList != null) {\r
- for (int j = 0; j < libClassList.length; j++) {\r
- libInstanceId = this.libClassMap.get(libClassList[j]);\r
- if (libInstanceId != null\r
- && !isInLibInstance(orderList, libInstanceId)) {\r
- //\r
- // If and only if the currently library instance\r
- // is not in stack and it have constructor or \r
- // destructor function, push this library \r
- // instacne in stack.\r
- //\r
- if (!isInStackList(stackList, this.libClassMap\r
- .get(libClassList[j])) && isHaveConsDestructor(libInstanceId)) {\r
- stackList.add(new Node(this.libClassMap\r
- .get(libClassList[j]), false));\r
- }\r
- }\r
+\r
+ HashSet<ModuleIdentification> consumedBy = libInstanceConsumedBy.get(libInstance);\r
+ if (consumedBy.size() == 0) {\r
+ continue;\r
+ }\r
+\r
+ ModuleIdentification[] consumedByList = consumedBy.toArray(new ModuleIdentification[consumedBy.size()]);\r
+ for (int j = 0; j < consumedByList.length; ++j) {\r
+ ModuleIdentification consumer = consumedByList[j];\r
+ if (consumer.hasConstructor()) {\r
+ continue;\r
+ }\r
+\r
+ //\r
+ // if there's no constructor in the library instance's consumer,\r
+ // remove it from the consumer list\r
+ //\r
+ consumedBy.remove(consumer);\r
+ circularlyConsumed = false;\r
+ if (consumedBy.size() == 0) {\r
+ noConsumerList.addLast(libInstance);\r
+ break;\r