Gabe Black has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/48365 )
4 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the
submitted one.
Change subject: scons,python,sim: Eliminate a redundant member of
EmbeddedPython.
......................................................................
scons,python,sim: Eliminate a redundant member of EmbeddedPython.
The filename member was just a less specific version of the abspath
member, and can be replaced by it to simplify things a little.
Change-Id: I61b312f2c356045e03462159e3232ac717954669
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48365
Tested-by: kokoro <[email protected]>
Reviewed-by: Jason Lowe-Power <[email protected]>
Maintainer: Jason Lowe-Power <[email protected]>
---
M src/SConscript
M src/python/importer.py
M src/sim/init.cc
M src/sim/init.hh
4 files changed, 12 insertions(+), 18 deletions(-)
Approvals:
Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/SConscript b/src/SConscript
index 2c941ca..31c82c1 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -363,16 +363,14 @@
assert ext == '.py'
if package:
- path = package.split('.')
+ modpath = package.split('.')
else:
- path = []
+ modpath = []
- modpath = path[:]
if modname != '__init__':
modpath += [ modname ]
modpath = '.'.join(modpath)
- arcpath = path + [ basename ]
abspath = self.snode.abspath
if not os.path.exists(abspath):
abspath = self.tnode.abspath
@@ -380,7 +378,6 @@
self.package = package
self.modname = modname
self.modpath = modpath
- self.arcname = os.path.join(*arcpath)
self.abspath = abspath
self.cpp = File(self.filename + '.cc')
@@ -1235,7 +1232,6 @@
# into a global list.
code('''
EmbeddedPython embedded_module_info(
- ${{c_str(pysource.arcname)}},
${{c_str(pysource.abspath)}},
${{c_str(pysource.modpath)}},
embedded_module_data,
diff --git a/src/python/importer.py b/src/python/importer.py
index ccedf48..7fa1641 100644
--- a/src/python/importer.py
+++ b/src/python/importer.py
@@ -46,23 +46,23 @@
override_var = os.environ.get('M5_OVERRIDE_PY_SOURCE', 'false')
self.override = (override_var.lower() in ('true', 'yes'))
- def add_module(self, filename, abspath, modpath, code):
+ def add_module(self, abspath, modpath, code):
if modpath in self.modules:
raise AttributeError("%s already found in importer" % modpath)
- self.modules[modpath] = (filename, abspath, code)
+ self.modules[modpath] = (abspath, code)
def find_spec(self, fullname, path, target=None):
if fullname not in self.modules:
return None
- srcfile, abspath, code = self.modules[fullname]
+ abspath, code = self.modules[fullname]
if self.override and os.path.exists(abspath):
src = open(abspath, 'r').read()
code = compile(src, abspath, 'exec')
- is_package = (os.path.basename(srcfile) == '__init__.py')
+ is_package = (os.path.basename(abspath) == '__init__.py')
spec = importlib.util.spec_from_loader(
name=fullname, loader=ByteCodeLoader(code),
is_package=is_package)
diff --git a/src/sim/init.cc b/src/sim/init.cc
index afecd73..0c69958 100644
--- a/src/sim/init.cc
+++ b/src/sim/init.cc
@@ -75,10 +75,9 @@
EmbeddedPython *EmbeddedPython::importer = NULL;
PyObject *EmbeddedPython::importerModule = NULL;
-EmbeddedPython::EmbeddedPython(const char *filename, const char *abspath,
- const char *modpath, const unsigned char *code, int zlen, int len)
- : filename(filename), abspath(abspath), modpath(modpath), code(code),
- zlen(zlen), len(len)
+EmbeddedPython::EmbeddedPython(const char *abspath, const char *modpath,
+ const unsigned char *code, int zlen, int len)
+ : abspath(abspath), modpath(modpath), code(code), zlen(zlen), len(len)
{
// if we've added the importer keep track of it because we need it
// to bootstrap.
@@ -117,7 +116,7 @@
{
PyObject *code = getCode();
PyObject *result = PyObject_CallMethod(importerModule,
PyCC("add_module"),
- PyCC("sssO"), filename, abspath, modpath, code);
+ PyCC("ssO"), abspath, modpath, code);
if (!result) {
PyErr_Print();
return false;
diff --git a/src/sim/init.hh b/src/sim/init.hh
index a20d3b6..c2f4cf2 100644
--- a/src/sim/init.hh
+++ b/src/sim/init.hh
@@ -62,15 +62,14 @@
*/
struct EmbeddedPython
{
- const char *filename;
const char *abspath;
const char *modpath;
const uint8_t *code;
int zlen;
int len;
- EmbeddedPython(const char *filename, const char *abspath,
- const char *modpath, const uint8_t *code, int zlen, int
len);
+ EmbeddedPython(const char *abspath, const char *modpath,
+ const uint8_t *code, int zlen, int len);
PyObject *getCode() const;
bool addModule() const;
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/48365
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: I61b312f2c356045e03462159e3232ac717954669
Gerrit-Change-Number: 48365
Gerrit-PatchSet: 11
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s