SymbolTable.py (6794:b431ec0ad43d) SymbolTable.py (6877:2a1a3d916ca8)
1# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
2# Copyright (c) 2009 The Hewlett-Packard Development Company
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 119 unchanged lines hidden (view full) ---

128 if isinstance(symbol, Type) and not symbol.isPrimitive:
129 code('#include "mem/protocol/${{symbol.c_ident}}.hh"')
130
131 code.write(path, "Types.hh")
132
133 for symbol in self.sym_vec:
134 symbol.writeCodeFiles(path)
135
1# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
2# Copyright (c) 2009 The Hewlett-Packard Development Company
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 119 unchanged lines hidden (view full) ---

128 if isinstance(symbol, Type) and not symbol.isPrimitive:
129 code('#include "mem/protocol/${{symbol.c_ident}}.hh"')
130
131 code.write(path, "Types.hh")
132
133 for symbol in self.sym_vec:
134 symbol.writeCodeFiles(path)
135
136 self.writeControllerFactory(path)
137
138 def writeControllerFactory(self, path):
139 code = code_formatter()
140
141 code('''
142/** \\file ControllerFactory.hh
143 * Auto generatred C++ code started by $__file__:$__line__
144 */
145
146#ifndef CONTROLLERFACTORY_H
147#define CONTROLLERFACTORY_H
148
149#include <string>
150class Network;
151class AbstractController;
152
153class ControllerFactory {
154 public:
155 static AbstractController *createController(const std::string &controller_type, const std::string &name);
156};
157#endif // CONTROLLERFACTORY_H''')
158 code.write(path, "ControllerFactory.hh")
159
160 code = code_formatter()
161 code('''
162/** \\file ControllerFactory.cc
163 * Auto generatred C++ code started by $__file__:$__line__
164 */
165
166#include "mem/protocol/ControllerFactory.hh"
167#include "mem/ruby/slicc_interface/AbstractController.hh"
168#include "mem/protocol/MachineType.hh"
169''')
170
171 controller_types = []
172 for symbol in self.getAllType(StateMachine):
173 code('#include "mem/protocol/${{symbol.ident}}_Controller.hh"')
174 controller_types.append(symbol.ident)
175
176 code('''
177AbstractController *ControllerFactory::createController(const std::string &controller_type, const std::string &name) {
178''')
179
180 for ct in controller_types:
181 code('''
182 if (controller_type == "$ct")
183 return new ${ct}_Controller(name);
184''')
185
186 code('''
187 assert(0); // invalid controller type
188 return NULL;
189}
190''')
191 code.write(path, "ControllerFactory.cc")
192
193 def writeHTMLFiles(self, path):
194 machines = list(self.getAllType(StateMachine))
195 if len(machines) > 1:
196 name = "%s_table.html" % machines[0].ident
197 else:
198 name = "empty.html"
199
200 code = code_formatter()

--- 21 unchanged lines hidden ---
136 def writeHTMLFiles(self, path):
137 machines = list(self.getAllType(StateMachine))
138 if len(machines) > 1:
139 name = "%s_table.html" % machines[0].ident
140 else:
141 name = "empty.html"
142
143 code = code_formatter()

--- 21 unchanged lines hidden ---