From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1F68D2115C07B for ; Fri, 28 Sep 2018 14:55:27 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Sep 2018 14:55:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,316,1534834800"; d="scan'208";a="77256338" Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.149]) by orsmga008.jf.intel.com with ESMTP; 28 Sep 2018 14:54:35 -0700 From: Jaben Carsey To: edk2-devel@lists.01.org Date: Fri, 28 Sep 2018 14:54:29 -0700 Message-Id: <24dad7ff606315ca9e0a0d777a240a54e64cc5b4.1538171557.git.jaben.carsey@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 Subject: [PATCH v2 4/7] BaseTools/GenFds: remove MacroDict parameter X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Sep 2018 21:55:27 -0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The MacroDict parameter goes around in circles through 4 functions without use. 1. GetSectionData calls into GetLeafSection, otherwise doesn’t use MacroDict 2. GetLeafSection calls into GetFileStatement, otherwise doesn’t use MacroDict 3. GetFileStatement calls into GetFilePart, otherwise doesn’t use MacroDict 4. GetFilePart calls into GetSectionData, otherwise doesn’t use MacroDict Go to 1 and repeat forever. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/GenFds/FdfParser.py | 48 +++++++------------- 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index fa82d8f174d5..f8fefdc2e737 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -2113,12 +2113,12 @@ class FdfParser: if FvObj.FvNameString == 'TRUE' and not FvObj.FvNameGuid: raise Warning("FvNameString found but FvNameGuid was not found", self.FileName, self.CurrentLineNumber) - self._GetAprioriSection(FvObj, FvObj.DefineVarDict.copy()) - self._GetAprioriSection(FvObj, FvObj.DefineVarDict.copy()) + self._GetAprioriSection(FvObj) + self._GetAprioriSection(FvObj) while True: isInf = self._GetInfStatement(FvObj) - isFile = self._GetFileStatement(FvObj, MacroDict = FvObj.DefineVarDict.copy()) + isFile = self._GetFileStatement(FvObj) if not isInf and not isFile: break @@ -2353,11 +2353,10 @@ class FdfParser: # # @param self The object pointer # @param FvObj for whom apriori is got - # @param MacroDict dictionary used to replace macro # @retval True Successfully find apriori statement # @retval False Not able to find apriori statement # - def _GetAprioriSection(self, FvObj, MacroDict = {}): + def _GetAprioriSection(self, FvObj): if not self._IsKeyword("APRIORI"): return False @@ -2372,7 +2371,6 @@ class FdfParser: AprSectionObj.AprioriType = AprType self._GetDefineStatements(AprSectionObj) - MacroDict.update(AprSectionObj.DefineVarDict) while True: IsInf = self._GetInfStatement(AprSectionObj) @@ -2526,11 +2524,10 @@ class FdfParser: # # @param self The object pointer # @param Obj for whom FILE statement is got - # @param MacroDict dictionary used to replace macro # @retval True Successfully find FILE statement # @retval False Not able to find FILE statement # - def _GetFileStatement(self, Obj, ForCapsule = False, MacroDict = {}): + def _GetFileStatement(self, Obj, ForCapsule = False): if not self._IsKeyword("FILE"): return False @@ -2561,7 +2558,7 @@ class FdfParser: FfsFileObj.NameGuid = self._Token - self._GetFilePart(FfsFileObj, MacroDict.copy()) + self._GetFilePart(FfsFileObj) if ForCapsule: capsuleFfs = CapsuleFfs() @@ -2608,9 +2605,8 @@ class FdfParser: # # @param self The object pointer # @param FfsFileObj for whom component is got - # @param MacroDict dictionary used to replace macro # - def _GetFilePart(self, FfsFileObj, MacroDict = {}): + def _GetFilePart(self, FfsFileObj): self._GetFileOpts(FfsFileObj) if not self._IsToken("{"): @@ -2645,11 +2641,11 @@ class FdfParser: elif self._Token in {TAB_DEFINE, "APRIORI", "SECTION"}: self._UndoToken() - self._GetSectionData(FfsFileObj, MacroDict) + self._GetSectionData(FfsFileObj) elif hasattr(FfsFileObj, 'FvFileType') and FfsFileObj.FvFileType == 'RAW': self._UndoToken() - self._GetRAWData(FfsFileObj, MacroDict) + self._GetRAWData(FfsFileObj) else: FfsFileObj.CurrentLineNum = self.CurrentLineNumber @@ -2666,9 +2662,8 @@ class FdfParser: # # @param self The object pointer # @param FfsFileObj for whom section is got - # @param MacroDict dictionary used to replace macro # - def _GetRAWData(self, FfsFileObj, MacroDict = {}): + def _GetRAWData(self, FfsFileObj): FfsFileObj.FileName = [] FfsFileObj.SubAlignment = [] while True: @@ -2756,26 +2751,18 @@ class FdfParser: return False - ## _GetFilePart() method + ## _GetSectionData() method # # Get section data for FILE statement # # @param self The object pointer # @param FfsFileObj for whom section is got - # @param MacroDict dictionary used to replace macro # - def _GetSectionData(self, FfsFileObj, MacroDict = {}): - Dict = {} - Dict.update(MacroDict) - + def _GetSectionData(self, FfsFileObj): self._GetDefineStatements(FfsFileObj) - Dict.update(FfsFileObj.DefineVarDict) - self._GetAprioriSection(FfsFileObj, Dict.copy()) - self._GetAprioriSection(FfsFileObj, Dict.copy()) - while True: - IsLeafSection = self._GetLeafSection(FfsFileObj, Dict) + IsLeafSection = self._GetLeafSection(FfsFileObj) IsEncapSection = self._GetEncapsulationSec(FfsFileObj) if not IsLeafSection and not IsEncapSection: break @@ -2786,11 +2773,10 @@ class FdfParser: # # @param self The object pointer # @param Obj for whom leaf section is got - # @param MacroDict dictionary used to replace macro # @retval True Successfully find section statement # @retval False Not able to find section statement # - def _GetLeafSection(self, Obj, MacroDict = {}): + def _GetLeafSection(self, Obj): OldPos = self.GetFileBufferPos() if not self._IsKeyword("SECTION"): @@ -2861,17 +2847,15 @@ class FdfParser: FvObj = FV() FvObj.UiFvName = FvName.upper() self._GetDefineStatements(FvObj) - MacroDict.update(FvObj.DefineVarDict) + self._GetBlockStatement(FvObj) self._GetSetStatements(FvObj) self._GetFvAlignment(FvObj) self._GetFvAttributes(FvObj) - self._GetAprioriSection(FvObj, MacroDict.copy()) - self._GetAprioriSection(FvObj, MacroDict.copy()) while True: IsInf = self._GetInfStatement(FvObj) - IsFile = self._GetFileStatement(FvObj, MacroDict.copy()) + IsFile = self._GetFileStatement(FvObj) if not IsInf and not IsFile: break -- 2.16.2.windows.1