diff options
author | Nathan Binkert <nate@binkert.org> | 2010-03-10 16:22:26 -0800 |
---|---|---|
committer | Nathan Binkert <nate@binkert.org> | 2010-03-10 16:22:26 -0800 |
commit | cf86532857ba1e199db6ff16541e7242c6225ff0 (patch) | |
tree | e107e443364bd326d791d2c19e126986cf4aa022 /src/mem/slicc/symbols | |
parent | 1068ca85d0a29bfa71dc6a21a8d6c8888dce4bc3 (diff) | |
download | gem5-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/mem/slicc/symbols')
-rw-r--r-- | src/mem/slicc/symbols/Func.py | 4 | ||||
-rw-r--r-- | src/mem/slicc/symbols/StateMachine.py | 22 | ||||
-rw-r--r-- | src/mem/slicc/symbols/SymbolTable.py | 13 | ||||
-rw-r--r-- | src/mem/slicc/symbols/Type.py | 10 |
4 files changed, 26 insertions, 23 deletions
diff --git a/src/mem/slicc/symbols/Func.py b/src/mem/slicc/symbols/Func.py index 5c812a96f..a05f0a03b 100644 --- a/src/mem/slicc/symbols/Func.py +++ b/src/mem/slicc/symbols/Func.py @@ -25,8 +25,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from m5.util import code_formatter - from slicc.symbols.Symbol import Symbol from slicc.symbols.Type import Type @@ -71,7 +69,7 @@ class Func(Symbol): if "external" in self: return - code = code_formatter() + code = self.symtab.codeFormatter() # Header code(''' diff --git a/src/mem/slicc/symbols/StateMachine.py b/src/mem/slicc/symbols/StateMachine.py index b5c12fe25..5da42a6d5 100644 --- a/src/mem/slicc/symbols/StateMachine.py +++ b/src/mem/slicc/symbols/StateMachine.py @@ -25,7 +25,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from m5.util import code_formatter, orderdict +from m5.util import orderdict from slicc.symbols.Symbol import Symbol from slicc.symbols.Var import Var @@ -150,7 +150,7 @@ class StateMachine(Symbol): func.writeCodeFiles(path) def printControllerPython(self, path): - code = code_formatter() + code = self.symtab.codeFormatter() ident = self.ident py_ident = "%s_Controller" % ident c_ident = "%s_Controller" % self.ident @@ -180,7 +180,7 @@ class $py_ident(RubyController): def printControllerHH(self, path): '''Output the method declarations for the class declaration''' - code = code_formatter() + code = self.symtab.codeFormatter() ident = self.ident c_ident = "%s_Controller" % self.ident @@ -301,7 +301,7 @@ static int m_num_controllers; def printControllerCC(self, path): '''Output the actions for performing the actions''' - code = code_formatter() + code = self.symtab.codeFormatter() ident = self.ident c_ident = "%s_Controller" % self.ident @@ -641,7 +641,7 @@ void $c_ident::${{action.ident}}(const Address& addr) def printCWakeup(self, path): '''Output the wakeup loop for the events''' - code = code_formatter() + code = self.symtab.codeFormatter() ident = self.ident code(''' @@ -696,7 +696,7 @@ void ${ident}_Controller::wakeup() def printCSwitch(self, path): '''Output switch statement for transition table''' - code = code_formatter() + code = self.symtab.codeFormatter() ident = self.ident code(''' @@ -778,7 +778,7 @@ TransitionResult ${ident}_Controller::doTransitionWorker(${ident}_Event event, $ case_string = "%s_State_%s, %s_Event_%s" % \ (self.ident, trans.state.ident, self.ident, trans.event.ident) - case = code_formatter() + case = self.symtab.codeFormatter() # Only set next_state if it changes if trans.state != trans.nextState: ns_ident = trans.nextState.ident @@ -853,7 +853,7 @@ if (!%s.areNSlotsAvailable(%s)) { code.write(path, "%s_Transitions.cc" % self.ident) def printProfilerHH(self, path): - code = code_formatter() + code = self.symtab.codeFormatter() ident = self.ident code(''' @@ -888,7 +888,7 @@ class ${ident}_Profiler { code.write(path, "%s_Profiler.hh" % self.ident) def printProfilerCC(self, path): - code = code_formatter() + code = self.symtab.codeFormatter() ident = self.ident code(''' @@ -967,7 +967,7 @@ void ${ident}_Profiler::dumpStats(ostream& out) const # ************************** def frameRef(self, click_href, click_target, over_href, over_target_num, text): - code = code_formatter(fix_newlines=False) + code = self.symtab.codeFormatter(fix_newlines=False) code("""<A href=\"$click_href\" target=\"$click_target\" onMouseOver=\"if (parent.frames[$over_target_num].location != parent.location + '$over_href') { parent.frames[$over_target_num].location='$over_href' }\" >${{html.formatShorthand(text)}}</A>""") return str(code) @@ -998,7 +998,7 @@ void ${ident}_Profiler::dumpStats(ostream& out) const code.write(path, name) def printHTMLTransitions(self, path, active_state): - code = code_formatter() + code = self.symtab.codeFormatter() code(''' <HTML><BODY link="blue" vlink="blue"> diff --git a/src/mem/slicc/symbols/SymbolTable.py b/src/mem/slicc/symbols/SymbolTable.py index deb971eb9..dd45ac06c 100644 --- a/src/mem/slicc/symbols/SymbolTable.py +++ b/src/mem/slicc/symbols/SymbolTable.py @@ -33,7 +33,9 @@ from slicc.symbols.Type import Type from slicc.util import Location class SymbolTable(object): - def __init__(self): + def __init__(self, slicc): + self.slicc = slicc + self.sym_vec = [] self.sym_map_vec = [ {} ] self.machine_components = {} @@ -52,6 +54,9 @@ class SymbolTable(object): def __repr__(self): return "[SymbolTable]" # FIXME + def codeFormatter(self, *args, **kwargs): + return self.slicc.codeFormatter(*args, **kwargs) + def newSymbol(self, sym): self.registerSym(str(sym), sym) self.sym_vec.append(sym) @@ -118,7 +123,7 @@ class SymbolTable(object): yield symbol def writeCodeFiles(self, path): - code = code_formatter() + code = self.codeFormatter() code(''' /** Auto generated C++ code started by $__file__:$__line__ */ @@ -140,7 +145,7 @@ class SymbolTable(object): else: name = "empty.html" - code = code_formatter() + code = self.codeFormatter() code(''' <html> <head> @@ -154,7 +159,7 @@ class SymbolTable(object): ''') code.write(path, "index.html") - code = code_formatter() + code = self.codeFormatter() code("<HTML></HTML>") code.write(path, "empty.html") diff --git a/src/mem/slicc/symbols/Type.py b/src/mem/slicc/symbols/Type.py index 41032e233..3f39ec208 100644 --- a/src/mem/slicc/symbols/Type.py +++ b/src/mem/slicc/symbols/Type.py @@ -25,7 +25,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from m5.util import code_formatter, orderdict +from m5.util import orderdict from slicc.util import PairContainer from slicc.symbols.Symbol import Symbol @@ -191,7 +191,7 @@ class Type(Symbol): self.printTypeCC(path) def printTypeHH(self, path): - code = code_formatter() + code = self.symtab.codeFormatter() code(''' /** \\file ${{self.c_ident}}.hh * @@ -375,7 +375,7 @@ ostream& operator<<(ostream& out, const ${{self.c_ident}}& obj) code.write(path, "%s.hh" % self.c_ident) def printTypeCC(self, path): - code = code_formatter() + code = self.symtab.codeFormatter() code(''' /** \\file ${{self.c_ident}}.cc @@ -412,7 +412,7 @@ void ${{self.c_ident}}::print(ostream& out) const code.write(path, "%s.cc" % self.c_ident) def printEnumHH(self, path): - code = code_formatter() + code = self.symtab.codeFormatter() code(''' /** \\file ${{self.c_ident}}.hh * @@ -470,7 +470,7 @@ ostream& operator<<(ostream& out, const ${{self.c_ident}}& obj); code.write(path, "%s.hh" % self.c_ident) def printEnumCC(self, path): - code = code_formatter() + code = self.symtab.codeFormatter() code(''' /** \\file ${{self.c_ident}}.hh * |