# (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 m5.util import makeDir
from slicc.generate import html
from slicc.symbols.StateMachine import StateMachine
self.sym_map_vec = [ {} ]
self.machine_components = {}
- pairs = {}
- pairs["enumeration"] = "yes"
- MachineType = Type(self, "MachineType", Location("init", 0), pairs)
- self.newSymbol(MachineType)
-
pairs = {}
pairs["primitive"] = "yes"
pairs["external"] = "yes"
- void = Type(self, "void", Location("init", 0), pairs)
+ location = Location("init", 0, no_warning=not slicc.verbose)
+ void = Type(self, "void", location, pairs)
self.newSymbol(void)
def __repr__(self):
if id in self.sym_map_vec[-1]:
sym.error("Symbol '%s' redeclared in same scope.", id)
+ for sym_map in self.sym_map_vec:
+ if id in sym_map:
+ if type(sym_map[id]) != type(sym):
+ sym.error("Conflicting declaration of Symbol '%s'", id)
+
# FIXME - warn on masking of a declaration in a previous frame
self.sym_map_vec[-1][id] = sym
if types is not None:
if not isinstance(symbol, types):
- symbol.error("Symbol '%s' is not of types '%s'.",
- symbol,
- types)
+ continue # there could be a name clash with other symbol
+ # so rather than producing an error, keep trying
return symbol
if isinstance(symbol, type):
yield symbol
- def writeCodeFiles(self, path):
+ def writeCodeFiles(self, path, includes):
+ makeDir(path)
+
code = self.codeFormatter()
- code('''
-/** Auto generated C++ code started by $__file__:$__line__ */
+ code('/** Auto generated C++ code started by $__file__:$__line__ */')
+
+ for include_path in includes:
+ code('#include "${{include_path}}"')
-#include "mem/ruby/slicc_interface/RubySlicc_includes.hh"
-''')
for symbol in self.sym_vec:
if isinstance(symbol, Type) and not symbol.isPrimitive:
code('#include "mem/protocol/${{symbol.c_ident}}.hh"')
code.write(path, "Types.hh")
for symbol in self.sym_vec:
- symbol.writeCodeFiles(path)
+ symbol.writeCodeFiles(path, includes)
def writeHTMLFiles(self, path):
+ makeDir(path)
+
machines = list(self.getAllType(StateMachine))
if len(machines) > 1:
name = "%s_table.html" % machines[0].ident