Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/39275 )
Change subject: arch: Wrap InstObjParams with a class and not a function.
......................................................................
arch: Wrap InstObjParams with a class and not a function.
When parsing an ISA description, the InstObjParams class needs to have a
reference to the current parser. It does that by exposing a wrapper to
the description rather than the actual InstObjParams class. That wrapper
injects an additional argument into the InstObjParams constructor.
Originally, the wrapper which injectect the additional argument was a
function which masqueraded as a class. That made it impossible to
subclass InstObjParams.
Instead, this change replaces that function wrapper with a class
wrapper, and injects the extra argument in the __init__ method. This
preserves the fact that the InstObjParams name refers to a class, and
allows any sort of interaction that's normally allowed with a class like
subclassing.
Change-Id: I550ea2e60eadac3c7c0b9afa7d71f4607b49a5d2
---
M src/arch/isa_parser/isa_parser.py
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/arch/isa_parser/isa_parser.py
b/src/arch/isa_parser/isa_parser.py
index 9ca813e..a0b9f74 100755
--- a/src/arch/isa_parser/isa_parser.py
+++ b/src/arch/isa_parser/isa_parser.py
@@ -1436,11 +1436,12 @@
# END OF GRAMMAR RULES
def updateExportContext(self):
-
- # create a continuation that allows us to grab the current parser
- def wrapInstObjParams(*args):
- return InstObjParams(self, *args)
- self.exportContext['InstObjParams'] = wrapInstObjParams
+ # Create a wrapper class that allows us to grab the current parser.
+ class InstObjParamsWrapper(InstObjParams):
+ def __init__(iop, *args, **kwargs):
+ super(InstObjParamsWrapper, iop).__init__(
+ self, *args, **kwargs)
+ self.exportContext['InstObjParams'] = InstObjParamsWrapper
self.exportContext.update(self.templateMap)
def defFormat(self, id, params, code, lineno):
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/39275
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I550ea2e60eadac3c7c0b9afa7d71f4607b49a5d2
Gerrit-Change-Number: 39275
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s