]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/VfrCompile/VfrSyntax.g
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Source / C / VfrCompile / VfrSyntax.g
index 4b0a43606eacb6917d8682798628b3936aecd4a5..04fe030b61d5bbc376b1214b78a877149041f28c 100644 (file)
@@ -1,14 +1,8 @@
 /*++ @file\r
 Vfr Syntax\r
 \r
-Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 --*/\r
 \r
@@ -64,7 +58,7 @@ VfrParserStart (
 //\r
 // Define a lexical class for parsing quoted strings. Basically\r
 // starts with a double quote, and ends with a double quote that\r
-// is not preceeded with a backslash.\r
+// is not preceded with a backslash.\r
 //\r
 #lexclass QUOTED_STRING\r
 #token TheString            "~[\"]*\"" << mode (START); >>\r
@@ -1214,7 +1208,7 @@ vfrStatementVarStoreNameValue :
   ;\r
 \r
 //\r
-// keep classDeinition and validClassNames for compatibility but not generate\r
+// keep classDefinition and validClassNames for compatibility but not generate\r
 // any IFR object\r
 //\r
 classDefinition[UINT16 & Class] :\r
@@ -4086,7 +4080,15 @@ vfrStatementInvalidSaveRestoreDefaults :
 // Root expression extension function called by other function.\r
 //\r
 vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :\r
-  << if ($RootLevel == 0) {mCIfrOpHdrIndex ++; if (mCIfrOpHdrIndex >= MAX_IFR_EXPRESSION_DEPTH) _PCATCH (VFR_RETURN_INVALID_PARAMETER, 0, "The depth of expression exceeds the max supported level 8!"); _CLEAR_SAVED_OPHDR ();} >>\r
+                                                       <<\r
+                                                          if ($RootLevel == 0) {\r
+                                                            mCIfrOpHdrIndex ++;\r
+                                                            if (mCIfrOpHdrIndex >= MAX_IFR_EXPRESSION_DEPTH) {\r
+                                                              _PCATCH (VFR_RETURN_INVALID_PARAMETER, 0, "The depth of expression exceeds the max supported level 8!");\r
+                                                            }\r
+                                                            _INIT_OPHDR_COND ();\r
+                                                          }\r
+                                                       >>\r
   andTerm[$RootLevel, $ExpOpCount]\r
   (\r
     L:OR andTerm[$RootLevel, $ExpOpCount]              << $ExpOpCount++; CIfrOr OObj(L->getLine()); >>\r
@@ -4113,7 +4115,7 @@ vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :
 \r
 //\r
 // Add new sub function for the sub expression extension to remember the ExpOpCount\r
-// This funciton is only called by sub expression.\r
+// This function is only called by sub expression.\r
 //\r
 vfrStatementExpressionSub [UINT32 RootLevel, UINT32 & ExpOpCount] :\r
   andTerm[$RootLevel, $ExpOpCount]\r
@@ -4990,6 +4992,7 @@ private:
   UINT8               mCIfrOpHdrIndex;\r
   VOID                _SAVE_OPHDR_COND (IN CIfrOpHeader &, IN BOOLEAN, UINT32 LineNo = 0);\r
   VOID                _CLEAR_SAVED_OPHDR (VOID);\r
+  VOID                _INIT_OPHDR_COND (VOID);\r
   BOOLEAN             _SET_SAVED_OPHDR_SCOPE (VOID);\r
 \r
 \r
@@ -5079,6 +5082,15 @@ EfiVfrParser::_SAVE_OPHDR_COND (
   }\r
 }\r
 \r
+VOID\r
+EfiVfrParser::_INIT_OPHDR_COND (\r
+  VOID\r
+  )\r
+{\r
+  mCIfrOpHdr[mCIfrOpHdrIndex]       = NULL;\r
+  mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = 0;\r
+}\r
+\r
 VOID\r
 EfiVfrParser::_CLEAR_SAVED_OPHDR (\r
   VOID\r
@@ -5086,9 +5098,8 @@ EfiVfrParser::_CLEAR_SAVED_OPHDR (
 {\r
   if (mCIfrOpHdr[mCIfrOpHdrIndex] != NULL) {\r
     delete mCIfrOpHdr[mCIfrOpHdrIndex];\r
-    mCIfrOpHdr[mCIfrOpHdrIndex]     = NULL;\r
+    mCIfrOpHdr[mCIfrOpHdrIndex] = NULL;\r
   }\r
-  mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = 0;\r
 }\r
 \r
 BOOLEAN\r
@@ -5305,7 +5316,7 @@ EfiVfrParser::_STOU8 (
     }\r
     if((IsHex && ((Value/16) != PreviousValue)) || (!IsHex && ((Value/10) != PreviousValue))) {\r
       sprintf(ErrorMsg, "Overflow: Value %s is too large to store in a UINT8", OrigString);\r
-      gCVfrErrorHandle.HandleWarning (VFR_WARNING_STRING_TO_UINT_OVERFLOW, LineNum, ErrorMsg);\r
+      mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (VFR_RETURN_STRING_TO_UINT_OVERFLOW, LineNum, ErrorMsg);\r
     }\r
   }\r
 \r
@@ -5342,7 +5353,7 @@ EfiVfrParser::_STOU16 (
     }\r
     if((IsHex && ((Value/16) != PreviousValue)) || (!IsHex && ((Value/10) != PreviousValue))) {\r
       sprintf(ErrorMsg, "Overflow: Value %s is too large to store in a UINT16", OrigString);\r
-      gCVfrErrorHandle.HandleWarning (VFR_WARNING_STRING_TO_UINT_OVERFLOW, LineNum, ErrorMsg);\r
+      mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (VFR_RETURN_STRING_TO_UINT_OVERFLOW, LineNum, ErrorMsg);\r
     }\r
   }\r
 \r
@@ -5379,7 +5390,7 @@ EfiVfrParser::_STOU32 (
     }\r
     if((IsHex && ((Value/16) != PreviousValue)) || (!IsHex && ((Value/10) != PreviousValue ))) {\r
       sprintf(ErrorMsg, "Overflow: Value %s is too large to store in a UINT32", OrigString);\r
-      gCVfrErrorHandle.HandleWarning (VFR_WARNING_STRING_TO_UINT_OVERFLOW, LineNum, ErrorMsg);\r
+      mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (VFR_RETURN_STRING_TO_UINT_OVERFLOW, LineNum, ErrorMsg);\r
     }\r
   }\r
 \r
@@ -5415,7 +5426,7 @@ EfiVfrParser::_STOU64 (
     }\r
     if((IsHex && ((Value/16) != PreviousValue)) || ((!IsHex && (Value/10) != PreviousValue))) {\r
       sprintf(ErrorMsg, "Overflow: Value %s is too large to store in a UINT64", OrigString);\r
-      gCVfrErrorHandle.HandleWarning (VFR_WARNING_STRING_TO_UINT_OVERFLOW, LineNum, ErrorMsg);\r
+      mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (VFR_RETURN_STRING_TO_UINT_OVERFLOW, LineNum, ErrorMsg);\r
     }\r
   }\r
 \r
@@ -5598,7 +5609,7 @@ EfiVfrParser::_DeclareDefaultFrameworkVarStore (
       VSEObj.SetAttributes (0x00000002); //hardcode EFI_VARIABLE_BOOTSERVICE_ACCESS attribute\r
       VSEObj.SetGuid (&pNode->mGuid);\r
       VSEObj.SetVarStoreId (pNode->mVarStoreId);\r
-      // Generate old efi varstore storage structure for compatiable with old "VarEqVal" opcode,\r
+      // Generate old efi varstore storage structure for compatible with old "VarEqVal" opcode,\r
       // which is 3 bytes less than new structure define in UEFI Spec 2.3.1.\r
       VSEObj.SetBinaryLength (sizeof (EFI_IFR_VARSTORE_EFI) - 3);\r
 #ifdef VFREXP_DEBUG\r