From: Giacomo Travaglini Date: Thu, 5 Mar 2020 15:34:34 +0000 (+0000) Subject: arch: Bring closure out of p_global_let X-Git-Tag: v20.0.0.0~344 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=39df0e4f32a1f91a2dea2e5112826d40adc4d409;p=gem5.git arch: Bring closure out of p_global_let The python interpreter might complain when exec() (the function, not the python2 keyword) is used in a function and the function contains a nested block. See: https://www.python.org/dev/peps/pep-0227/ The patch is moving the nested function out of p_global_let. Change-Id: Idb3a08a8cd42455af1e5ec2c3ec8f8a1438047d3 Signed-off-by: Giacomo Travaglini Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26303 Tested-by: kokoro Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power --- diff --git a/src/arch/isa_parser.py b/src/arch/isa_parser.py index b33517485..f35083f71 100755 --- a/src/arch/isa_parser.py +++ b/src/arch/isa_parser.py @@ -2006,20 +2006,23 @@ class ISAParser(Grammar): kwargs = { t[2]+'_output' : self.process_output(t[3]) } GenCode(self, **kwargs).emit() + def make_split(self): + def _split(sec): + return self.split(sec) + return _split + # global let blocks 'let {{...}}' (Python code blocks) are # executed directly when seen. Note that these execute in a # special variable context 'exportContext' to prevent the code # from polluting this script's namespace. def p_global_let(self, t): 'global_let : LET CODELIT SEMI' - def _split(sec): - return self.split(sec) self.updateExportContext() self.exportContext["header_output"] = '' self.exportContext["decoder_output"] = '' self.exportContext["exec_output"] = '' self.exportContext["decode_block"] = '' - self.exportContext["split"] = _split + self.exportContext["split"] = self.make_split() split_setup = ''' def wrap(func): def split(sec):