summaryrefslogtreecommitdiff
path: root/Tools/Source/MigrationTools
diff options
context:
space:
mode:
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2006-09-13 07:00:19 +0000
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2006-09-13 07:00:19 +0000
commit9f98dbb76f35e416868230c43259ed579b3dffee (patch)
tree6f735d65337be74505063faa681ad3c7cce1e469 /Tools/Source/MigrationTools
parent8cc59d2c51988f3be716684aef884f84a60ed77e (diff)
downloadedk2-9f98dbb76f35e416868230c43259ed579b3dffee.zip
edk2-9f98dbb76f35e416868230c43259ed579b3dffee.tar.gz
edk2-9f98dbb76f35e416868230c43259ed579b3dffee.tar.bz2
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
Diffstat (limited to 'Tools/Source/MigrationTools')
-rw-r--r--Tools/Source/MigrationTools/org/tianocore/migration/Macro.java1
-rw-r--r--Tools/Source/MigrationTools/org/tianocore/migration/ModuleInfo.java1
-rw-r--r--Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java109
3 files changed, 65 insertions, 46 deletions
diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/Macro.java b/Tools/Source/MigrationTools/org/tianocore/migration/Macro.java
index b58e590..bd10b5a 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 19c0dfe..791ccd2 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<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>();
diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java b/Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java
index 678dbcb..3325f15 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<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);
@@ -289,7 +249,64 @@ 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");