diff options
author | jwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-12-22 01:30:56 +0000 |
---|---|---|
committer | jwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-12-22 01:30:56 +0000 |
commit | 3dc87a3e784234dbab51cb57ade43417af987167 (patch) | |
tree | 61c94039afd6e5785ebf978ba26379301b21aab7 | |
parent | af2efcafd4974000a9dfe0f09aa78dcda70aba78 (diff) | |
download | edk2-platforms-3dc87a3e784234dbab51cb57ade43417af987167.tar.xz |
Fixed the issue in the library instance constructor calling sequence
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2127 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r-- | Tools/Java/Source/GenBuild/org/tianocore/build/autogen/AutogenLibOrder.java | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/Tools/Java/Source/GenBuild/org/tianocore/build/autogen/AutogenLibOrder.java b/Tools/Java/Source/GenBuild/org/tianocore/build/autogen/AutogenLibOrder.java index e14df92fe8..9674c5de08 100644 --- a/Tools/Java/Source/GenBuild/org/tianocore/build/autogen/AutogenLibOrder.java +++ b/Tools/Java/Source/GenBuild/org/tianocore/build/autogen/AutogenLibOrder.java @@ -18,8 +18,12 @@ package org.tianocore.build.autogen; import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Stack;
+import java.util.HashSet;
import org.apache.xmlbeans.XmlObject;
import org.tianocore.build.exception.AutoGenException;
@@ -142,7 +146,7 @@ public class AutogenLibOrder { @return List which content the ordered library instance.
**/
- List<ModuleIdentification> orderLibInstance() {
+ List<ModuleIdentification> orderLibInstance1() {
List<ModuleIdentification> orderList = new ArrayList<ModuleIdentification>();
//
// Stack of node which track the library instance name ant its visiting
@@ -207,7 +211,7 @@ public class AutogenLibOrder { // instacne in stack.
//
if (!isInStackList(stackList, this.libClassMap
- .get(libClassList[j])) && isHaveConsDestructor(libInstanceId)) {
+ .get(libClassList[j])) /* && isHaveConsDestructor(libInstanceId) */) {
stackList.add(new Node(this.libClassMap
.get(libClassList[j]), false));
}
@@ -215,11 +219,64 @@ public class AutogenLibOrder { }
}
}
+ System.out.println("################################################");
+ for (int ii = 0; ii < orderList.size(); ++ii) {
+ System.out.println(" " + orderList.get(ii));
+ }
+ }
+ }
+ return orderList;
+ }
+
+ List<ModuleIdentification> orderLibInstance() {
+ LinkedList<ModuleIdentification> orderList = new LinkedList<ModuleIdentification>();
+ for (int i = 0; i < libInstanceList.size(); ++i) {
+ ModuleIdentification current = libInstanceList.get(i).libId;
+ int insertPoint = orderList.size();
+ for (int j = 0; j < orderList.size(); ++j) {
+ ModuleIdentification old = orderList.get(j);
+ //System.out.println("### old = " + old);
+ if (consumes(current, old)) {
+ insertPoint = j + 1;
+ } else if (consumes(old, current)) {
+ insertPoint = j;
+ break;
+ }
}
+ orderList.add(insertPoint, current);
+// System.out.println("################################################");
+// for (int ii = 0; ii < orderList.size(); ++ii) {
+// System.out.println(" " + orderList.get(ii));
+// }
}
+
return orderList;
}
+ boolean consumes(ModuleIdentification lib1, ModuleIdentification lib2) {
+ //System.out.println("$$$ lib1 = " + lib1);
+ LinkedList<ModuleIdentification> stack = new LinkedList<ModuleIdentification>();
+ stack.add(lib1);
+ int j = 0;
+ while (j < stack.size()) {
+ ModuleIdentification lib = stack.get(j++);
+ String[] consumedClasses = libInstanceMap.get(lib);
+ for (int i = 0; i < consumedClasses.length; ++i) {
+ ModuleIdentification consumedLib = libClassMap.get(consumedClasses[i]);
+ //System.out.println("$$$ class = " + consumedClasses[i]);
+ //System.out.println("$$$ insta = " + consumedLib);
+ if (consumedLib == lib2) {
+ //System.out.println(lib1 + "\n consumes\n" + lib2 + "\n");
+ return true;
+ }
+ if (consumedLib != null && !stack.contains(consumedLib)) {
+ stack.offer(consumedLib);
+ }
+ }
+ }
+ return false;
+ }
+
/**
isInLibInstance
|