ECC: No longer store struct/union which lies in the typedef pattern; add predicate...
authorjlin16 <jlin16@7335b38e-4728-0410-8992-fb3ffe349368>
Wed, 11 Jun 2008 07:21:07 +0000 (07:21 +0000)
committerjlin16 <jlin16@7335b38e-4728-0410-8992-fb3ffe349368>
Wed, 11 Jun 2008 07:21:07 +0000 (07:21 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1254 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/Ecc/c.py

index b9aeec4..70bbf62 100644 (file)
@@ -66,6 +66,12 @@ def GetIdType(Str):
         Type = DataClass.MODEL_UNKNOWN\r
     return Type\r
 \r
+def SuOccurInTypedef (Su, TdList):\r
+    for Td in TdList:\r
+        if Su.StartPos[0] >= Td.StartPos[0] and Su.EndPos[0] <= Td.EndPos[0]:\r
+            return True\r
+    return False\r
+\r
 def GetIdentifierList():\r
     IdList = []\r
     for comment in FileProfile.CommentList:\r
@@ -188,6 +194,8 @@ def GetIdentifierList():
         IdList.append(IdEnum)\r
         \r
     for su in FileProfile.StructUnionDefinitionList:\r
+        if SuOccurInTypedef(su, FileProfile.TypedefDefinitionList):\r
+            continue\r
         Type = DataClass.MODEL_IDENTIFIER_STRUCTURE\r
         SkipLen = 6\r
         if su.Content.startswith('union'):\r
@@ -217,13 +225,16 @@ def GetIdentifierList():
             if StarPos != -1:\r
                 Modifier += ' ' + TmpStr[0:StarPos]\r
             while TmpStr[StarPos] == '*':\r
-                Modifier += ' ' + '*'\r
+#                Modifier += ' ' + '*'\r
                 StarPos += 1\r
             TmpStr = TmpStr[StarPos:].strip()\r
             RBPos = TmpStr.find(')')\r
             Name = TmpStr[0:RBPos]\r
             Value = 'FP' + TmpStr[RBPos + 1:]\r
-            \r
+        else:\r
+            while Name.startswith('*'):\r
+                Value += ' ' + '*'\r
+                Name = Name.lstrip('*').strip()\r
         IdTd = DataClass.IdentifierClass(-1, Modifier, '', Name, Value, DataClass.MODEL_IDENTIFIER_TYPEDEF, -1, -1, td.StartPos[0],td.StartPos[1],td.EndPos[0],td.EndPos[1])\r
         IdList.append(IdTd)\r
         \r
@@ -487,7 +498,7 @@ def GetTableID(FullFileName, ErrorMsgList = None):
     Db = GetDB()\r
     SqlStatement = """ select ID\r
                        from File\r
-                       where FullPath = '%s'\r
+                       where FullPath like '%s'\r
                    """ % FullFileName\r
     \r
     ResultSet = Db.TblFile.Exec(SqlStatement)\r
@@ -508,9 +519,7 @@ def GetIncludeFileList(FullFileName):
     if IFList != None:\r
         return IFList\r
     \r
-    ErrorMsgList = []\r
-    \r
-    FileID = GetTableID(FullFileName, ErrorMsgList)\r
+    FileID = GetTableID(FullFileName)\r
     if FileID < 0:\r
         return []\r
     \r
@@ -527,6 +536,7 @@ def GetIncludeFileList(FullFileName):
 def GetFullPathOfIncludeFile(Str, IncludePathList):\r
     for IncludePath in IncludePathList:\r
         FullPath = os.path.join(IncludePath, Str)\r
+        FullPath = os.path.normpath(FullPath)\r
         if os.path.exists(FullPath):\r
             return FullPath\r
     return None\r
@@ -574,7 +584,9 @@ def GetPredicateListFromPredicateExpStr(PES):
         if (PES[i] == '&' and PES[i+1] == '&') or (PES[i] == '|' and PES[i+1] == '|'):\r
             LogicOpPos = i\r
             Exp = PES[PredicateBegin:i].strip()\r
-            if p.match(Exp):\r
+            # Exp may contain '.' or '->'\r
+            TmpExp = Exp.replace('.', '').replace('->', '')\r
+            if p.match(TmpExp):\r
                 PredicateList.append(Exp)\r
             else:\r
                 PredicateList.append(Exp.rstrip(';').rstrip(')').strip())\r
@@ -586,7 +598,9 @@ def GetPredicateListFromPredicateExpStr(PES):
                 break\r
             PredicateBegin += 1\r
         Exp = PES[PredicateBegin:len(PES)].strip()\r
-        if p.match(Exp):\r
+        # Exp may contain '.' or '->'\r
+        TmpExp = Exp.replace('.', '').replace('->', '')\r
+        if p.match(TmpExp):\r
             PredicateList.append(Exp)\r
         else:\r
             PredicateList.append(Exp.rstrip(';').rstrip(')').strip())\r
@@ -616,15 +630,17 @@ def GetCNameList(Lvalue):
             break\r
         \r
         \r
-        Index = Lvalue[VarEnd:].find('.')\r
-        if Index > 0:\r
-            SearchBegin += VarEnd + Index\r
-        else:\r
-            Index = Lvalue[VarEnd:].find('->')\r
-            if Index > 0:\r
-                SearchBegin += VarEnd + Index\r
-            else:\r
+        DotIndex = Lvalue[VarEnd:].find('.')\r
+        ArrowIndex = Lvalue[VarEnd:].find('->')\r
+        if DotIndex == -1 and ArrowIndex == -1:\r
                 break\r
+        elif DotIndex == -1 and ArrowIndex != -1:\r
+            SearchBegin = VarEnd + ArrowIndex\r
+        elif ArrowIndex == -1 and DotIndex != -1:\r
+            SearchBegin = VarEnd + DotIndex\r
+        else:\r
+            SearchBegin = VarEnd + ((DotIndex < ArrowIndex) and DotIndex or ArrowIndex) \r
+            \r
         i = SearchBegin\r
         VarStart = -1\r
         VarEnd = -1\r
@@ -650,6 +666,11 @@ def SplitPredicateByOp(Str, Op):
         TmpStr = Str[0:Index - 1]\r
 \r
 def SplitPredicateStr(Str):\r
+    p = GetFuncDeclPattern()\r
+    TmpStr = Str.replace('.', '').replace('->', '')\r
+    if p.match(TmpStr):\r
+        return [[Str, None], None]\r
+    \r
     PredPartList = SplitPredicateByOp(Str, '==')\r
     if len(PredPartList) > 1:\r
         return [PredPartList, '==']\r