Enhance recognizing Macro/Type defined in Library.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1525 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qhuang8 2006-09-13 07:00:19 +00:00
parent 8cc59d2c51
commit 9f98dbb76f
4 changed files with 67 additions and 48 deletions

View File

@ -41,8 +41,8 @@ EfiDriverLib,EfiLibReportStatusCode,ReportStatusCode,ReportStatusCodeLib,MdePkg
EfiDriverLib,ReportStatusCodeWithDevicePath,ReportStatusCodeWithDevicePath,ReportStatusCodeLib,MdePkg
EfiDriverLib,EFI_FIELD_OFFSET,EFI_FIELD_OFFSET,BaseLib,MdePkg
EfiDriverLib,EFI_LIST,LIST_ENTRY,BaseLib,MdePkg
EfiDriverLib,EFI_LIST_ENTRY,LIST_ENTRY,BaseLib,MdePkg
EfiDriverLib,EFI_LIST_NODE,LIST_ENTRY,BaseLib,MdePkg
EfiDriverLib,EFI_LIST_ENTRY,LIST_ENTRY ,BaseLib,MdePkg
EfiDriverLib,EFI_LIST_NODE,LIST_ENTRY ,BaseLib,MdePkg
EfiDriverLib,FLOCK,EFI_LOCK,UefiLib,MdePkg
EfiDriverLib,GetFirstNode,GetFirstNode,BaseLib,MdePkg
EfiDriverLib,GetNextNode,GetNextNode,BaseLib,MdePkg

1 R8.5LibClass R8.5Lib R9Lib R9LibClass Package
41 EfiDriverLib ReportStatusCodeWithDevicePath ReportStatusCodeWithDevicePath ReportStatusCodeLib MdePkg
42 EfiDriverLib EFI_FIELD_OFFSET EFI_FIELD_OFFSET BaseLib MdePkg
43 EfiDriverLib EFI_LIST LIST_ENTRY BaseLib MdePkg
44 EfiDriverLib EFI_LIST_ENTRY LIST_ENTRY LIST_ENTRY BaseLib MdePkg
45 EfiDriverLib EFI_LIST_NODE LIST_ENTRY LIST_ENTRY BaseLib MdePkg
46 EfiDriverLib FLOCK EFI_LOCK UefiLib MdePkg
47 EfiDriverLib GetFirstNode GetFirstNode BaseLib MdePkg
48 EfiDriverLib GetNextNode GetNextNode BaseLib MdePkg

View File

@ -35,6 +35,7 @@ public class Macro {
String temp = null;
temp = mtr.group();
mi.hashmacro.add(temp);
if (MigrationTool.db.hasMacro(temp)) { // only changed macros registered, because the database of macro has only changed ones
if (!unmacro.contains(temp)) {
mi.hashnonlocalmacro.add(temp);

View File

@ -41,6 +41,7 @@ public final class ModuleInfo {
public final Set<String> hashnonlocalmacro = new HashSet<String>();
public final Set<String> hashEFIcall = new HashSet<String>();
public final Set<String> hashr8only = new HashSet<String>();
public final Set<String> hashmacro = new HashSet<String>();
public final Set<String> hashrequiredr9libs = new HashSet<String>(); // hashrequiredr9libs is now all added in SourceFileReplacer
public final Set<String> guid = new HashSet<String>();

View File

@ -53,7 +53,7 @@ public final class SourceFileReplacer implements Common.ForDoAll {
private class IdleLaplace extends Common.Laplace {
public String operation(String wholeline) {
return wholeline;
return replaceLibrary (wholeline, mi.hashmacro);
}
public boolean recognize(String filename) {
@ -105,51 +105,11 @@ public final class SourceFileReplacer implements Common.ForDoAll {
if (Common.find (wholeline, "\\bgDS\\b")) {
mi.hashrequiredr9libs.add ("DxeServicesTableLib");
}
// start replacing names
String r8thing;
String r9thing;
Iterator<String> it;
// Converting non-locla function
it = mi.hashnonlocalfunc.iterator();
while (it.hasNext()) {
r8thing = it.next();
mi.hashrequiredr9libs.add(MigrationTool.db.getR9Lib(r8thing)); // add a library here
r8tor9 temp;
if ((r9thing = MigrationTool.db.getR9Func(r8thing)) != null) {
if (!r8thing.equals(r9thing)) {
if (wholeline.contains(r8thing)) {
wholeline = wholeline.replaceAll(r8thing, r9thing);
filefunc.add(new r8tor9(r8thing, r9thing));
Iterator<r8tor9> rt = filefunc.iterator();
while (rt.hasNext()) {
temp = rt.next();
if (MigrationTool.db.r8only.contains(temp.r8thing)) {
filer8only.add(r8thing);
mi.hashr8only.add(r8thing);
addr8 = true;
}
}
}
}
}
} //is any of the guids changed?
if (addr8 == true) {
wholeline = addincludefile(wholeline, "\"R8Lib.h\"");
}
wholeline = replaceLibrary (wholeline, mi.hashnonlocalfunc);
wholeline = replaceLibrary (wholeline, mi.hashmacro);
// Converting macro
it = mi.hashnonlocalmacro.iterator();
while (it.hasNext()) { //macros are all assumed MdePkg currently
r8thing = it.next();
//mi.hashrequiredr9libs.add(MigrationTool.db.getR9Lib(r8thing));
if ((r9thing = MigrationTool.db.getR9Macro(r8thing)) != null) {
if (wholeline.contains(r8thing)) {
wholeline = wholeline.replaceAll(r8thing, r9thing);
filemacro.add(new r8tor9(r8thing, r9thing));
}
}
}
wholeline = replaceMacro (wholeline, mi.hashnonlocalmacro);
// Converting guid
replaceGuid(wholeline, mi.guid, "guid", fileguid);
@ -290,6 +250,63 @@ public final class SourceFileReplacer implements Common.ForDoAll {
return templine;
}
private final String replaceMacro (String wholeline, Set<String> symbolSet) {
String r8thing;
String r9thing;
Iterator<String> it;
it = symbolSet.iterator();
while (it.hasNext()) { //macros are all assumed MdePkg currently
r8thing = it.next();
System.out.println (r8thing);
//mi.hashrequiredr9libs.add(MigrationTool.db.getR9Lib(r8thing));
if ((r9thing = MigrationTool.db.getR9Macro(r8thing)) != null) {
if (wholeline.contains(r8thing)) {
wholeline = wholeline.replaceAll(r8thing, r9thing);
filemacro.add(new r8tor9(r8thing, r9thing));
}
}
}
return wholeline;
}
private final String replaceLibrary (String wholeline, Set<String> symbolSet) {
boolean addr8 = false;
// start replacing names
String r8thing;
String r9thing;
Iterator<String> it;
// Converting non-locla function
it = symbolSet.iterator();
while (it.hasNext()) {
r8thing = it.next();
mi.hashrequiredr9libs.add(MigrationTool.db.getR9Lib(r8thing)); // add a library here
r8tor9 temp;
if ((r9thing = MigrationTool.db.getR9Func(r8thing)) != null) {
if (!r8thing.equals(r9thing)) {
if (wholeline.contains(r8thing)) {
wholeline = wholeline.replaceAll(r8thing, r9thing);
filefunc.add(new r8tor9(r8thing, r9thing));
Iterator<r8tor9> rt = filefunc.iterator();
while (rt.hasNext()) {
temp = rt.next();
if (MigrationTool.db.r8only.contains(temp.r8thing)) {
filer8only.add(r8thing);
mi.hashr8only.add(r8thing);
addr8 = true;
}
}
}
}
}
} //is any of the guids changed?
if (addr8 == true) {
wholeline = addincludefile(wholeline, "\"R8Lib.h\"");
}
return wholeline;
}
private final void addr8only() throws Exception {
String paragraph = null;
String line = Common.file2string(MigrationTool.db.DatabasePath + File.separator + "R8Lib.c");