From 9f98dbb76f35e416868230c43259ed579b3dffee Mon Sep 17 00:00:00 2001 From: qhuang8 Date: Wed, 13 Sep 2006 07:00:19 +0000 Subject: [PATCH] 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 --- Tools/Conf/Migration/Library.csv | 4 +- .../org/tianocore/migration/Macro.java | 1 + .../org/tianocore/migration/ModuleInfo.java | 1 + .../migration/SourceFileReplacer.java | 109 ++++++++++-------- 4 files changed, 67 insertions(+), 48 deletions(-) diff --git a/Tools/Conf/Migration/Library.csv b/Tools/Conf/Migration/Library.csv index f1b30c9574..fcb0f12cc6 100644 --- a/Tools/Conf/Migration/Library.csv +++ b/Tools/Conf/Migration/Library.csv @@ -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 diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/Macro.java b/Tools/Source/MigrationTools/org/tianocore/migration/Macro.java index b58e5903c5..bd10b5a251 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/Macro.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/Macro.java @@ -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); diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java b/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java index 19c0dfedd1..791ccd23fa 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java @@ -41,6 +41,7 @@ public final class ModuleInfo { public final Set hashnonlocalmacro = new HashSet(); public final Set hashEFIcall = new HashSet(); public final Set hashr8only = new HashSet(); + public final Set hashmacro = new HashSet(); public final Set hashrequiredr9libs = new HashSet(); // hashrequiredr9libs is now all added in SourceFileReplacer public final Set guid = new HashSet(); diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java b/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java index 678dbcb275..3325f15044 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java @@ -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 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 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); @@ -289,7 +249,64 @@ public final class SourceFileReplacer implements Common.ForDoAll { } return templine; } - + + private final String replaceMacro (String wholeline, Set symbolSet) { + String r8thing; + String r9thing; + Iterator 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 symbolSet) { + boolean addr8 = false; + // start replacing names + String r8thing; + String r9thing; + Iterator 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 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"); -- 2.39.2