bug-fixing for predicate exp check.
authorjlin16 <jlin16@7335b38e-4728-0410-8992-fb3ffe349368>
Tue, 1 Apr 2008 10:28:28 +0000 (10:28 +0000)
committerjlin16 <jlin16@7335b38e-4728-0410-8992-fb3ffe349368>
Tue, 1 Apr 2008 10:28:28 +0000 (10:28 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1097 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/Ecc/c.py

index ed84a2e..bcc0c37 100644 (file)
@@ -236,7 +236,7 @@ def GetFunctionList():
             FuncDef.Modifier += '*'\r
             DeclText = DeclText.lstrip('*').strip()\r
         \r
-        FuncDef.Declarator = FuncDef.Declarator.replace('*', '')\r
+        FuncDef.Declarator = FuncDef.Declarator.lstrip('*')\r
         DeclSplitList = FuncDef.Declarator.split('(')\r
         if len(DeclSplitList) < 2:\r
             continue\r
@@ -255,6 +255,18 @@ def GetFunctionList():
         \r
     return FuncObjList\r
 \r
+def GetFileModificationTimeFromDB(FullFileName):\r
+    TimeValue = 0.0\r
+    Db = GetDB()\r
+    SqlStatement = """ select TimeStamp\r
+                       from File\r
+                       where FullPath = \'%s\'\r
+                   """ % (FullFileName)\r
+    ResultSet = Db.TblFile.Exec(SqlStatement)\r
+    for Result in ResultSet:\r
+        TimeValue = Result[0]\r
+    return TimeValue\r
+\r
 def CollectSourceCodeDataIntoDB(RootDir):\r
     FileObjList = []\r
     tuple = os.walk(RootDir)\r
@@ -266,7 +278,6 @@ def CollectSourceCodeDataIntoDB(RootDir):
             continue\r
         for f in filenames:\r
             FullName = os.path.join(dirpath, f)\r
-            \r
             if os.path.splitext(f)[1] in ('.h', '.c'):\r
                 EdkLogger.info("Parsing " + FullName)\r
                 model = f.endswith('c') and DataClass.MODEL_FILE_C or DataClass.MODEL_FILE_H\r
@@ -285,8 +296,9 @@ def CollectSourceCodeDataIntoDB(RootDir):
                 FileObj = DataClass.FileClass(-1, BaseName, Ext, DirName, FullName, model, ModifiedTime, GetFunctionList(), GetIdentifierList(), [])\r
                 FileObjList.append(FileObj)\r
                 collector.CleanFileProfileBuffer()   \r
+    \r
     if len(ParseErrorFileList) > 0:\r
-        EdkLogger.info("Found error during parsing:\n\t%s\n" % "\n\t".join(ParseErrorFileList))\r
+        EdkLogger.info("Found unrecoverable error during parsing:\n\t%s\n" % "\n\t".join(ParseErrorFileList))\r
     \r
     Db = GetDB()    \r
     for file in FileObjList:    \r
@@ -294,9 +306,11 @@ def CollectSourceCodeDataIntoDB(RootDir):
 \r
     Db.UpdateIdentifierBelongsToFunction()\r
 \r
-def GetTableID(FullFileName, ErrorMsgList = []):\r
+def GetTableID(FullFileName, ErrorMsgList = None):\r
+    if ErrorMsgList == None:\r
+        ErrorMsgList = []\r
+        \r
     Db = GetDB()\r
-    \r
     SqlStatement = """ select ID\r
                        from File\r
                        where FullPath = '%s'\r
@@ -379,16 +393,25 @@ def GetPredicateListFromPredicateExpStr(PES):
     PredicateBegin = 0\r
     #PredicateEnd = 0\r
     LogicOpPos = -1\r
+    p = GetFuncDeclPattern()\r
     while i < len(PES) - 1:\r
         if (PES[i].isalpha() or PES[i] == '_') and LogicOpPos > PredicateBegin:\r
             PredicateBegin = i\r
         if (PES[i] == '&' and PES[i+1] == '&') or (PES[i] == '|' and PES[i+1] == '|'):\r
             LogicOpPos = i\r
-            PredicateList.append(PES[PredicateBegin:i].rstrip(';').rstrip(')').strip())\r
+            Exp = PES[PredicateBegin:i].strip()\r
+            if p.match(Exp):\r
+                PredicateList.append(Exp)\r
+            else:\r
+                PredicateList.append(Exp.rstrip(';').rstrip(')').strip())\r
         i += 1\r
     \r
     if PredicateBegin > LogicOpPos:\r
-        PredicateList.append(PES[PredicateBegin:len(PES)].rstrip(';').rstrip(')').strip())\r
+        Exp = PES[PredicateBegin:len(PES)].strip()\r
+        if p.match(Exp):\r
+            PredicateList.append(Exp)\r
+        else:\r
+            PredicateList.append(Exp.rstrip(';').rstrip(')').strip())\r
     return PredicateList\r
     \r
 def GetPredicateVariable(Lvalue):\r
@@ -441,7 +464,7 @@ def SplitPredicateByOp(Str, Op):
         if Index == -1:\r
             return [Name]\r
         \r
-        if Str[Index - 1].isalnum() or Str[Index - 1].isspace():\r
+        if Str[Index - 1].isalnum() or Str[Index - 1].isspace() or Str[Index - 1] == ')':\r
             Name = Str[0:Index].strip()\r
             Value = Str[Index + len(Op):].strip()\r
             return [Name, Value]   \r
@@ -619,17 +642,23 @@ def GetFinalTypeValue(Type, FieldName, TypedefDict, SUDict):
             continue\r
         if not Field[Index - 1].isalnum():\r
             if Index + len(FieldName) == len(Field):\r
-                return GetPredicateVariable(Field[0:Index])[0]\r
+                Type = GetPredicateVariable(Field[0:Index])\r
+                if len(Type) == 0:\r
+                    return Field[0:Index]\r
+                return Type[0]\r
             else:\r
                 if not Field[Index + len(FieldName) + 1].isalnum():\r
-                    return GetPredicateVariable(Field[0:Index])[0]\r
+                    Type = GetPredicateVariable(Field[0:Index])\r
+                    if len(Type) == 0:\r
+                        return Field[0:Index]\r
+                    return Type[0]\r
     return None\r
     \r
 \r
 def GetTypeInfo(RefList, Modifier, FullFileName):\r
     TypedefDict = GetTypedefDict(FullFileName)\r
     SUDict = GetSUDict(FullFileName)\r
-    Type = GetReturnTypeFromModifier(Modifier).rstrip('*')\r
+    Type = GetReturnTypeFromModifier(Modifier).rstrip('*').strip()\r
     Index = 0\r
     while Index < len(RefList):\r
         FieldName = RefList[Index]\r
@@ -1189,6 +1218,8 @@ def CheckNonBooleanValueComparison(FullFileName):
             continue\r
         \r
         for Exp in GetPredicateListFromPredicateExpStr(Str[0]):\r
+            if p.match(Exp):\r
+                continue\r
             PredInfo = SplitPredicateStr(Exp)\r
             if PredInfo[1] == None:\r
                 PredVarList = GetPredicateVariable(PredInfo[0][0])\r