From 3dc87a3e784234dbab51cb57ade43417af987167 Mon Sep 17 00:00:00 2001 From: jwang36 Date: Fri, 22 Dec 2006 01:30:56 +0000 Subject: [PATCH] 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 --- .../build/autogen/AutogenLibOrder.java | 61 ++++++++++++++++++- 1 file 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 orderLibInstance() { + List orderLibInstance1() { List orderList = new ArrayList(); // // 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 orderLibInstance() { + LinkedList orderList = new LinkedList(); + 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 stack = new LinkedList(); + 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