Ecc/c.py: change procedure names to be more meaningful; fix the one-level variable...
authorjlin16 <jlin16@7335b38e-4728-0410-8992-fb3ffe349368>
Wed, 2 Apr 2008 08:36:43 +0000 (08:36 +0000)
committerjlin16 <jlin16@7335b38e-4728-0410-8992-fb3ffe349368>
Wed, 2 Apr 2008 08:36:43 +0000 (08:36 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1104 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/Ecc/c.py

index bcc0c37..92b81e6 100644 (file)
@@ -395,7 +395,7 @@ def GetPredicateListFromPredicateExpStr(PES):
     LogicOpPos = -1\r
     p = GetFuncDeclPattern()\r
     while i < len(PES) - 1:\r
-        if (PES[i].isalpha() or PES[i] == '_') and LogicOpPos > PredicateBegin:\r
+        if (PES[i].isalnum() 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
@@ -407,6 +407,10 @@ def GetPredicateListFromPredicateExpStr(PES):
         i += 1\r
     \r
     if PredicateBegin > LogicOpPos:\r
+        while PredicateBegin < len(PES):\r
+            if PES[PredicateBegin].isalnum() or PES[PredicateBegin] == '_':\r
+                break\r
+            PredicateBegin += 1\r
         Exp = PES[PredicateBegin:len(PES)].strip()\r
         if p.match(Exp):\r
             PredicateList.append(Exp)\r
@@ -414,7 +418,7 @@ def GetPredicateListFromPredicateExpStr(PES):
             PredicateList.append(Exp.rstrip(';').rstrip(')').strip())\r
     return PredicateList\r
     \r
-def GetPredicateVariable(Lvalue):\r
+def GetCNameList(Lvalue):\r
     Lvalue += ' '\r
     i = 0\r
     SearchBegin = 0\r
@@ -511,7 +515,7 @@ def PatternInModifier(Modifier, SubStr):
             return True\r
     return False\r
 \r
-def GetReturnTypeFromModifier(ModifierStr):\r
+def GetDataTypeFromModifier(ModifierStr):\r
     MList = ModifierStr.split()\r
     for M in MList:\r
         if M in EccGlobalData.gConfig.ModifierList:\r
@@ -642,13 +646,13 @@ def GetFinalTypeValue(Type, FieldName, TypedefDict, SUDict):
             continue\r
         if not Field[Index - 1].isalnum():\r
             if Index + len(FieldName) == len(Field):\r
-                Type = GetPredicateVariable(Field[0:Index])\r
+                Type = GetCNameList(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
-                    Type = GetPredicateVariable(Field[0:Index])\r
+                    Type = GetCNameList(Field[0:Index])\r
                     if len(Type) == 0:\r
                         return Field[0:Index]\r
                     return Type[0]\r
@@ -658,7 +662,7 @@ def GetFinalTypeValue(Type, FieldName, TypedefDict, SUDict):
 def GetTypeInfo(RefList, Modifier, FullFileName):\r
     TypedefDict = GetTypedefDict(FullFileName)\r
     SUDict = GetSUDict(FullFileName)\r
-    Type = GetReturnTypeFromModifier(Modifier).rstrip('*').strip()\r
+    Type = GetDataTypeFromModifier(Modifier).rstrip('*').strip()\r
     Index = 0\r
     while Index < len(RefList):\r
         FieldName = RefList[Index]\r
@@ -688,6 +692,9 @@ def GetVarInfo(PredVarList, FuncRecord, FullFileName):
         if len(PredVarList) > 1:\r
             Type = GetTypeInfo(PredVarList[1:], Result[0], FullFileName)\r
             return Type\r
+        else:\r
+            Type = GetDataTypeFromModifier(Result[0])\r
+            return Type\r
                 \r
     # search function parameters second\r
     ParamList = GetParamList(FuncRecord[2])\r
@@ -696,6 +703,9 @@ def GetVarInfo(PredVarList, FuncRecord, FullFileName):
             if len(PredVarList) > 1:\r
                 Type = GetTypeInfo(PredVarList[1:], Param.Modifier, FullFileName)\r
                 return Type\r
+            else:\r
+                Type = GetDataTypeFromModifier(Param.Modifier)\r
+                return Type\r
           \r
     # search global variable next\r
     SqlStatement = """ select Modifier, ID\r
@@ -708,6 +718,9 @@ def GetVarInfo(PredVarList, FuncRecord, FullFileName):
         if len(PredVarList) > 1:\r
             Type = GetTypeInfo(PredVarList[1:], Result[0], FullFileName)\r
             return Type\r
+        else:\r
+            Type = GetDataTypeFromModifier(Result[0])\r
+            return Type\r
     \r
     # search variable in include files\r
     IncludeFileList = GetAllIncludeFiles(FullFileName)\r
@@ -727,6 +740,9 @@ def GetVarInfo(PredVarList, FuncRecord, FullFileName):
             if len(PredVarList) > 1:\r
                 Type = GetTypeInfo(PredVarList[1:], Result[0], FullFileName)\r
                 return Type\r
+            else:\r
+                Type = GetDataTypeFromModifier(Result[0])\r
+                return Type\r
 \r
 def CheckFuncLayoutReturnType(FullFileName):\r
     ErrorMsgList = []\r
@@ -743,7 +759,7 @@ def CheckFuncLayoutReturnType(FullFileName):
                    """ % (FileTable, DataClass.MODEL_IDENTIFIER_FUNCTION_DECLARATION)\r
     ResultSet = Db.TblFile.Exec(SqlStatement)\r
     for Result in ResultSet:\r
-        ReturnType = GetReturnTypeFromModifier(Result[0])\r
+        ReturnType = GetDataTypeFromModifier(Result[0])\r
         if len(ReturnType) == 0:\r
             PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_RETURN_TYPE, '', FileTable, Result[1])\r
             continue\r
@@ -760,7 +776,7 @@ def CheckFuncLayoutReturnType(FullFileName):
                    """ % (FileID)\r
     ResultSet = Db.TblFile.Exec(SqlStatement)\r
     for Result in ResultSet:\r
-        ReturnType = GetReturnTypeFromModifier(Result[0])\r
+        ReturnType = GetDataTypeFromModifier(Result[0])\r
         if len(ReturnType) == 0:\r
             PrintErrorMsg(ERROR_C_FUNCTION_LAYOUT_CHECK_RETURN_TYPE, '', 'Function', Result[1])\r
             continue\r
@@ -786,7 +802,7 @@ def CheckFuncLayoutModifier(FullFileName):
                    """ % (FileTable, DataClass.MODEL_IDENTIFIER_FUNCTION_DECLARATION)\r
     ResultSet = Db.TblFile.Exec(SqlStatement)\r
     for Result in ResultSet:\r
-        ReturnType = GetReturnTypeFromModifier(Result[0])\r
+        ReturnType = GetDataTypeFromModifier(Result[0])\r
         if len(ReturnType) == 0:\r
             continue\r
         Index = Result[0].find(ReturnType)\r
@@ -799,7 +815,7 @@ def CheckFuncLayoutModifier(FullFileName):
                    """ % (FileID)\r
     ResultSet = Db.TblFile.Exec(SqlStatement)\r
     for Result in ResultSet:\r
-        ReturnType = GetReturnTypeFromModifier(Result[0])\r
+        ReturnType = GetDataTypeFromModifier(Result[0])\r
         if len(ReturnType) == 0:\r
             continue\r
         Index = Result[0].find(ReturnType)\r
@@ -1168,7 +1184,7 @@ def CheckPointerNullComparison(FullFileName):
         for Exp in GetPredicateListFromPredicateExpStr(Str[0]):\r
             PredInfo = SplitPredicateStr(Exp)\r
             if PredInfo[1] == None:\r
-                PredVarList = GetPredicateVariable(PredInfo[0][0])\r
+                PredVarList = GetCNameList(PredInfo[0][0])\r
                 # No variable found, maybe value first? like (0 == VarName)\r
                 if len(PredVarList) == 0:\r
                     continue\r
@@ -1222,7 +1238,7 @@ def CheckNonBooleanValueComparison(FullFileName):
                 continue\r
             PredInfo = SplitPredicateStr(Exp)\r
             if PredInfo[1] == None:\r
-                PredVarList = GetPredicateVariable(PredInfo[0][0])\r
+                PredVarList = GetCNameList(PredInfo[0][0])\r
                 # No variable found, maybe value first? like (0 == VarName)\r
                 if len(PredVarList) == 0:\r
                     continue\r
@@ -1274,7 +1290,7 @@ def CheckBooleanValueComparison(FullFileName):
         for Exp in GetPredicateListFromPredicateExpStr(Str[0]):\r
             PredInfo = SplitPredicateStr(Exp)\r
             if PredInfo[1] in ('==', '!=') and PredInfo[0][1] in ('TRUE', 'FALSE'):\r
-                PredVarList = GetPredicateVariable(PredInfo[0][0])\r
+                PredVarList = GetCNameList(PredInfo[0][0])\r
                 # No variable found, maybe value first? like (0 == VarName)\r
                 if len(PredVarList) == 0:\r
                     continue\r