changeset d609cd948ca0 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=d609cd948ca0
description:
        code_formatter: make it easier to insert whitespace
        a newline by just doing "code()". indent() and dedent() now take a
        "count" parameter to indent/dedent multiple levels.

diffstat:

 src/mem/slicc/symbols/StateMachine.py |   6 +++---
 src/python/m5/util/code_formatter.py  |  20 ++++++++++++--------
 2 files changed, 15 insertions(+), 11 deletions(-)

diffs (63 lines):

diff -r 146caf930da0 -r d609cd948ca0 src/mem/slicc/symbols/StateMachine.py
--- a/src/mem/slicc/symbols/StateMachine.py     Thu Sep 09 14:15:40 2010 -0700
+++ b/src/mem/slicc/symbols/StateMachine.py     Thu Sep 09 14:15:41 2010 -0700
@@ -559,17 +559,17 @@
 
 
         # Set the queue consumers
-        code.insert_newline()
+        code()
         for port in self.in_ports:
             code('${{port.code}}.setConsumer(this);')
 
         # Set the queue descriptions
-        code.insert_newline()
+        code()
         for port in self.in_ports:
             code('${{port.code}}.setDescription("[Version " + 
to_string(m_version) + ", $ident, $port]");')
 
         # Initialize the transition profiling
-        code.insert_newline()
+        code()
         for trans in self.transitions:
             # Figure out if we stall
             stall = False
diff -r 146caf930da0 -r d609cd948ca0 src/python/m5/util/code_formatter.py
--- a/src/python/m5/util/code_formatter.py      Thu Sep 09 14:15:40 2010 -0700
+++ b/src/python/m5/util/code_formatter.py      Thu Sep 09 14:15:41 2010 -0700
@@ -131,12 +131,12 @@
         if args:
             self.__call__(args)
 
-    def indent(self):
-        self._indent_level += self._indent_spaces
+    def indent(self, count=1):
+        self._indent_level += self._indent_spaces * count
 
-    def dedent(self):
-        assert self._indent_level >= self._indent_spaces
-        self._indent_level -= self._indent_spaces
+    def dedent(self, count=1):
+        assert self._indent_level >= (self._indent_spaces * count)
+        self._indent_level -= self._indent_spaces * count
 
     def fix(self, status):
         previous = self._fix_newlines
@@ -200,10 +200,14 @@
 
             initial_newline = False
 
-    def insert_newline(self):
-        self._data.append('\n')
+    def __call__(self, *args, **kwargs):
+        if not args:
+            self._data.append('\n')
+            return
 
-    def __call__(self, format, *args, **kwargs):
+        format = args[0]
+        args = args[1:]
+
         frame = inspect.currentframe().f_back
 
         l = lookup(self, frame, *args, **kwargs)
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to