mirror of https://github.com/acidanthera/audk.git
BaseTools: move regular expression compile out of function call.
move to the root of the file and dont recompile. Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
parent
663b9e061e
commit
38504ad3e3
|
@ -41,6 +41,8 @@ ERR_EMPTY_EXPR = 'Empty expression is not allowed.'
|
||||||
ERR_IN_OPERAND = 'Macro after IN operator can only be: $(FAMILY), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).'
|
ERR_IN_OPERAND = 'Macro after IN operator can only be: $(FAMILY), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).'
|
||||||
|
|
||||||
__ValidString = re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$')
|
__ValidString = re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$')
|
||||||
|
_ReLabel = re.compile('LABEL\((\w+)\)')
|
||||||
|
_ReOffset = re.compile('OFFSET_OF\((\w+)\)')
|
||||||
|
|
||||||
## SplitString
|
## SplitString
|
||||||
# Split string to list according double quote
|
# Split string to list according double quote
|
||||||
|
@ -896,13 +898,11 @@ class ValueExpressionEx(ValueExpression):
|
||||||
PcdValueList = SplitPcdValueString(PcdValue.strip()[1:-1])
|
PcdValueList = SplitPcdValueString(PcdValue.strip()[1:-1])
|
||||||
LabelDict = {}
|
LabelDict = {}
|
||||||
NewPcdValueList = []
|
NewPcdValueList = []
|
||||||
ReLabel = re.compile('LABEL\((\w+)\)')
|
|
||||||
ReOffset = re.compile('OFFSET_OF\((\w+)\)')
|
|
||||||
LabelOffset = 0
|
LabelOffset = 0
|
||||||
for Index, Item in enumerate(PcdValueList):
|
for Index, Item in enumerate(PcdValueList):
|
||||||
# compute byte offset of every LABEL
|
# compute byte offset of every LABEL
|
||||||
LabelList = ReLabel.findall(Item)
|
LabelList = _ReLabel.findall(Item)
|
||||||
Item = ReLabel.sub('', Item)
|
Item = _ReLabel.sub('', Item)
|
||||||
Item = Item.strip()
|
Item = Item.strip()
|
||||||
if LabelList:
|
if LabelList:
|
||||||
for Label in LabelList:
|
for Label in LabelList:
|
||||||
|
@ -929,11 +929,11 @@ class ValueExpressionEx(ValueExpression):
|
||||||
# for LABEL parse
|
# for LABEL parse
|
||||||
Item = Item.strip()
|
Item = Item.strip()
|
||||||
try:
|
try:
|
||||||
Item = ReLabel.sub('', Item)
|
Item = _ReLabel.sub('', Item)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
OffsetList = ReOffset.findall(Item)
|
OffsetList = _ReOffset.findall(Item)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
for Offset in OffsetList:
|
for Offset in OffsetList:
|
||||||
|
|
Loading…
Reference in New Issue