String[] libClassDeclList = null;\r
String[] libClassConsmList = null;\r
\r
- libInstanceList = new ModuleIdentification[libraryList.length];\r
+ libInstanceList = libraryList;\r
for (int i = 0; i < libraryList.length; i++) {\r
libInstance = libraryList[i];\r
- libInstanceList[i] = libInstance;\r
//\r
- // Add libraryInstance in to libInstanceList.\r
+ // Fetch the constructor & destructor.\r
// \r
Map<String, XmlObject> libDoc = GlobalData.getDoc(libInstance, arch);\r
SurfaceAreaQuery saq = new SurfaceAreaQuery(libDoc);\r
libInstance.setDestructor(saq.getLibDestructorName());\r
\r
//\r
- // Add library instance and consumed library class list to\r
- // libInstanceConsumes.\r
+ // Create library class consume database.\r
//\r
libClassConsmList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, arch);\r
if (libClassConsmList != null) {\r
- /*\r
- String[] classStr = new String[libClassConsmList.length];\r
- for (int k = 0; k < libClassConsmList.length; k++) {\r
- classStr[k] = libClassConsmList[k];\r
- }\r
- */\r
if (this.libInstanceConsumes.containsKey(libInstance)) {\r
throw new AutoGenException(\r
libraryList[i].getName()\r
}\r
\r
//\r
- // Add library class and library instance map.\r
+ // Create library class implementer database\r
//\r
libClassDeclList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, arch);\r
if (libClassDeclList != null) {\r
}\r
}\r
\r
+ //\r
+ // Create a consumed-by database \r
+ // \r
for (Iterator it = libClassProducer.keySet().iterator(); it.hasNext();) {\r
String className = (String)it.next();\r
libInstance = libClassProducer.get(className);\r
orderLibInstance\r
\r
This function reorder the library instance according the library class \r
- dependency.\r
+ dependency, using DAG anaylysis algothim\r
\r
@return List which content the ordered library instance.\r
**/\r
LinkedList<ModuleIdentification> orderList = new LinkedList<ModuleIdentification>();\r
LinkedList<ModuleIdentification> noConsumerList = new LinkedList<ModuleIdentification>();\r
\r
+ //\r
+ // First, add the library instance without consumers to the Q\r
+ // \r
for (int i = 0; i < libInstanceList.length; ++i) {\r
if (libInstanceConsumedBy.get(libInstanceList[i]).size() == 0) {\r
noConsumerList.add(libInstanceList[i]);\r
}\r
}\r
\r
+ //\r
+ // Append the remaining library instance to the end of sorted list\r
+ // \r
for (int i = 0; i < libInstanceList.length; ++i) {\r
if (!orderList.contains(libInstanceList[i])) {\r
orderList.add(libInstanceList[i]);\r
public void setModuleType(String moduleType) {\r
this.moduleType = moduleType;\r
}\r
- \r
+\r
+ /**\r
+ @return String The module name\r
+ **/\r
public String getName() {\r
return name;\r
}\r
\r
+ /**\r
+ @return boolean\r
+ **/\r
public boolean hasConstructor() {\r
return constructor != "";\r
}\r
\r
+ /**\r
+ @return boolean\r
+ */\r
public boolean hasDestructor() {\r
return destructor != "";\r
}\r
\r
+ /**\r
+ Set the constructor function name if this module is a library\r
+\r
+ @param name\r
+ */\r
public void setConstructor(String name) {\r
if (name != null) {\r
constructor = name;\r
}\r
}\r
\r
+ /**\r
+ Set the destructor function name if this module is a library\r
+\r
+ @param name\r
+ */\r
public void setDestructor(String name) {\r
if (name != null) {\r
destructor = name;\r