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:
		@@ -41,8 +41,8 @@ EfiDriverLib,EfiLibReportStatusCode,ReportStatusCode,ReportStatusCodeLib,MdePkg
 | 
				
			|||||||
EfiDriverLib,ReportStatusCodeWithDevicePath,ReportStatusCodeWithDevicePath,ReportStatusCodeLib,MdePkg
 | 
					EfiDriverLib,ReportStatusCodeWithDevicePath,ReportStatusCodeWithDevicePath,ReportStatusCodeLib,MdePkg
 | 
				
			||||||
EfiDriverLib,EFI_FIELD_OFFSET,EFI_FIELD_OFFSET,BaseLib,MdePkg
 | 
					EfiDriverLib,EFI_FIELD_OFFSET,EFI_FIELD_OFFSET,BaseLib,MdePkg
 | 
				
			||||||
EfiDriverLib,EFI_LIST,LIST_ENTRY,BaseLib,MdePkg
 | 
					EfiDriverLib,EFI_LIST,LIST_ENTRY,BaseLib,MdePkg
 | 
				
			||||||
EfiDriverLib,EFI_LIST_ENTRY,LIST_ENTRY,BaseLib,MdePkg
 | 
					EfiDriverLib,EFI_LIST_ENTRY,LIST_ENTRY    ,BaseLib,MdePkg
 | 
				
			||||||
EfiDriverLib,EFI_LIST_NODE,LIST_ENTRY,BaseLib,MdePkg
 | 
					EfiDriverLib,EFI_LIST_NODE,LIST_ENTRY    ,BaseLib,MdePkg
 | 
				
			||||||
EfiDriverLib,FLOCK,EFI_LOCK,UefiLib,MdePkg
 | 
					EfiDriverLib,FLOCK,EFI_LOCK,UefiLib,MdePkg
 | 
				
			||||||
EfiDriverLib,GetFirstNode,GetFirstNode,BaseLib,MdePkg
 | 
					EfiDriverLib,GetFirstNode,GetFirstNode,BaseLib,MdePkg
 | 
				
			||||||
EfiDriverLib,GetNextNode,GetNextNode,BaseLib,MdePkg
 | 
					EfiDriverLib,GetNextNode,GetNextNode,BaseLib,MdePkg
 | 
				
			||||||
 
 | 
				
			|||||||
		
		
			
  | 
@@ -35,6 +35,7 @@ public class Macro {
 | 
				
			|||||||
        String temp = null;
 | 
					        String temp = null;
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        temp = mtr.group();
 | 
					        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 (MigrationTool.db.hasMacro(temp)) {                    // only changed macros registered, because the database of macro has only changed ones
 | 
				
			||||||
            if (!unmacro.contains(temp)) {
 | 
					            if (!unmacro.contains(temp)) {
 | 
				
			||||||
                mi.hashnonlocalmacro.add(temp);
 | 
					                mi.hashnonlocalmacro.add(temp);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,6 +41,7 @@ public final class ModuleInfo {
 | 
				
			|||||||
    public final Set<String> hashnonlocalmacro = new HashSet<String>();
 | 
					    public final Set<String> hashnonlocalmacro = new HashSet<String>();
 | 
				
			||||||
    public final Set<String> hashEFIcall = new HashSet<String>();
 | 
					    public final Set<String> hashEFIcall = new HashSet<String>();
 | 
				
			||||||
    public final Set<String> hashr8only = 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> hashrequiredr9libs = new HashSet<String>();    // hashrequiredr9libs is now all added in SourceFileReplacer 
 | 
				
			||||||
    public final Set<String> guid = new HashSet<String>();
 | 
					    public final Set<String> guid = new HashSet<String>();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -53,7 +53,7 @@ public final class SourceFileReplacer implements Common.ForDoAll {
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    private class IdleLaplace extends Common.Laplace {
 | 
					    private class IdleLaplace extends Common.Laplace {
 | 
				
			||||||
        public String operation(String wholeline) {
 | 
					        public String operation(String wholeline) {
 | 
				
			||||||
            return wholeline;
 | 
					            return replaceLibrary (wholeline, mi.hashmacro);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        public boolean recognize(String filename) {
 | 
					        public boolean recognize(String filename) {
 | 
				
			||||||
@@ -105,51 +105,11 @@ public final class SourceFileReplacer implements Common.ForDoAll {
 | 
				
			|||||||
            if (Common.find (wholeline, "\\bgDS\\b")) {
 | 
					            if (Common.find (wholeline, "\\bgDS\\b")) {
 | 
				
			||||||
                mi.hashrequiredr9libs.add ("DxeServicesTableLib");
 | 
					                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
 | 
					            // Converting macro
 | 
				
			||||||
            it = mi.hashnonlocalmacro.iterator();
 | 
					            wholeline = replaceMacro (wholeline, mi.hashnonlocalmacro);
 | 
				
			||||||
            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));
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Converting guid
 | 
					            // Converting guid
 | 
				
			||||||
            replaceGuid(wholeline, mi.guid, "guid", fileguid);
 | 
					            replaceGuid(wholeline, mi.guid, "guid", fileguid);
 | 
				
			||||||
@@ -290,6 +250,63 @@ public final class SourceFileReplacer implements Common.ForDoAll {
 | 
				
			|||||||
        return templine;
 | 
					        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 {
 | 
					    private final void addr8only() throws Exception {
 | 
				
			||||||
        String paragraph = null;
 | 
					        String paragraph = null;
 | 
				
			||||||
        String line = Common.file2string(MigrationTool.db.DatabasePath + File.separator + "R8Lib.c");
 | 
					        String line = Common.file2string(MigrationTool.db.DatabasePath + File.separator + "R8Lib.c");
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user