# This file is used to parse and evaluate expression in directive or PCD value.\r
#\r
# Copyright (c) 2011 - 2018, 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
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
## Import Modules\r
#\r
from Common.GlobalData import *\r
from CommonDataClass.Exceptions import BadExpression\r
from CommonDataClass.Exceptions import WrnExpression\r
-from .Misc import GuidStringToGuidStructureString, ParseFieldValue\r
+from .Misc import GuidStringToGuidStructureString, ParseFieldValue,CopyDict\r
import Common.EdkLogger as EdkLogger\r
import copy\r
from Common.DataType import *\r
__ValidString = re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$')\r
_ReLabel = re.compile('LABEL\((\w+)\)')\r
_ReOffset = re.compile('OFFSET_OF\((\w+)\)')\r
-PcdPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_]*\.[_a-zA-Z][0-9A-Za-z_]*$')\r
+PcdPattern = re.compile(r'^[_a-zA-Z][0-9A-Za-z_]*\.[_a-zA-Z][0-9A-Za-z_]*$')\r
\r
## SplitString\r
# Split string to list according double quote\r
#\r
# The symbol table including PCD and macro mapping\r
#\r
- self._Symb = copy.deepcopy(SymbolTable)\r
+ self._Symb = CopyDict(SymbolTable)\r
self._Symb.update(self.LogicalOperators)\r
self._Idx = 0\r
self._Len = len(self._Expr)\r
else:\r
Val = Val3\r
continue\r
+ #\r
+ # PEP 238 -- Changing the Division Operator\r
+ # x/y to return a reasonable approximation of the mathematical result of the division ("true division")\r
+ # x//y to return the floor ("floor division")\r
+ #\r
+ if Op == '/':\r
+ Op = '//'\r
try:\r
Val = self.Eval(Op, Val, EvalFunc())\r
except WrnExpression as Warn:\r
if TmpValue.bit_length() == 0:\r
PcdValue = '{0x00}'\r
else:\r
- for I in range((TmpValue.bit_length() + 7) / 8):\r
+ for I in range((TmpValue.bit_length() + 7) // 8):\r
TmpList.append('0x%02x' % ((TmpValue >> I * 8) & 0xff))\r
PcdValue = '{' + ', '.join(TmpList) + '}'\r
except:\r
Size += ItemSize\r
\r
if Size > 0:\r
- PcdValue = '{' + ','.join(AllPcdValueList) + '}'\r
+ PcdValue = '{' + ', '.join(AllPcdValueList) + '}'\r
else:\r
raise BadExpression("Type: %s, Value: %s, %s"%(self.PcdType, PcdValue, Value))\r
\r