summaryrefslogtreecommitdiff
path: root/src/python/m5
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2010-03-10 16:22:26 -0800
committerNathan Binkert <nate@binkert.org>2010-03-10 16:22:26 -0800
commitcf86532857ba1e199db6ff16541e7242c6225ff0 (patch)
treee107e443364bd326d791d2c19e126986cf4aa022 /src/python/m5
parent1068ca85d0a29bfa71dc6a21a8d6c8888dce4bc3 (diff)
downloadgem5-cf86532857ba1e199db6ff16541e7242c6225ff0.tar.xz
slicc: have a central mechanism for creating a code_formatter.
This makes it easier to add global variables like protocol
Diffstat (limited to 'src/python/m5')
-rw-r--r--src/python/m5/util/code_formatter.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/python/m5/util/code_formatter.py b/src/python/m5/util/code_formatter.py
index 396fe0e52..47106e0d9 100644
--- a/src/python/m5/util/code_formatter.py
+++ b/src/python/m5/util/code_formatter.py
@@ -55,15 +55,14 @@ class lookup(object):
if item == '__line__':
return self.frame.f_lineno
+ if self.formatter.locals and item in self.frame.f_locals:
+ return self.frame.f_locals[item]
+
if item in self.dict:
return self.dict[item]
- if self.formatter.locals or self.formatter.globals:
- if self.formatter.locals and item in self.frame.f_locals:
- return self.frame.f_locals[item]
-
- if self.formatter.globals and item in self.frame.f_globals:
- return self.frame.f_globals[item]
+ if self.formatter.globals and item in self.frame.f_globals:
+ return self.frame.f_globals[item]
if item in __builtin__.__dict__:
return __builtin__.__dict__[item]
@@ -124,7 +123,7 @@ class code_formatter(object):
self._dict = {}
self._indent_level = 0
self._indent_spaces = 4
- self.globals = kwargs.pop('globals',type(self).globals)
+ self.globals = kwargs.pop('globals', type(self).globals)
self.locals = kwargs.pop('locals', type(self).locals)
self._fix_newlines = \
kwargs.pop('fix_newlines', type(self).fix_newlines)