summaryrefslogtreecommitdiff
path: root/src/mem/slicc/ast
diff options
context:
space:
mode:
authorTony Gutierrez <anthony.gutierrez@amd.com>2015-07-20 09:15:18 -0500
committerTony Gutierrez <anthony.gutierrez@amd.com>2015-07-20 09:15:18 -0500
commita3177645773b8eb4b835050c395554d3e2b4664a (patch)
tree793299969de1562785063448ac12f9e06ac164e3 /src/mem/slicc/ast
parent3f68884c0e432cdc241ed0442e19ade0d74aa6f4 (diff)
downloadgem5-a3177645773b8eb4b835050c395554d3e2b4664a.tar.xz
ruby: slicc: have a static MachineType
This patch is imported from reviewboard patch 2551 by Nilay. This patch moves from a dynamically defined MachineType to a statically defined one. The need for this patch was felt since a dynamically defined type prevents us from having types for which no machine definition may exist. The following changes have been made: i. each machine definition now uses a type from the MachineType enumeration instead of any random identifier. This required changing the grammar and the *.sm files. ii. MachineType enumeration defined statically in RubySlicc_Exports.sm. * * * normal protocol fixes for nilay's parser machine type fix
Diffstat (limited to 'src/mem/slicc/ast')
-rw-r--r--src/mem/slicc/ast/DeclListAST.py5
-rw-r--r--src/mem/slicc/ast/MachineAST.py12
2 files changed, 4 insertions, 13 deletions
diff --git a/src/mem/slicc/ast/DeclListAST.py b/src/mem/slicc/ast/DeclListAST.py
index 36c520070..4ba41ed6c 100644
--- a/src/mem/slicc/ast/DeclListAST.py
+++ b/src/mem/slicc/ast/DeclListAST.py
@@ -46,8 +46,5 @@ class DeclListAST(AST):
def generate(self):
for decl in self.decls:
- decl.generate()
-
- def findMachines(self):
- for decl in self.decls:
decl.findMachines()
+ decl.generate()
diff --git a/src/mem/slicc/ast/MachineAST.py b/src/mem/slicc/ast/MachineAST.py
index 4487b094e..c67d0e695 100644
--- a/src/mem/slicc/ast/MachineAST.py
+++ b/src/mem/slicc/ast/MachineAST.py
@@ -29,10 +29,10 @@ from slicc.ast.DeclAST import DeclAST
from slicc.symbols import StateMachine, Type
class MachineAST(DeclAST):
- def __init__(self, slicc, ident, pairs_ast, config_parameters, decls):
+ def __init__(self, slicc, mtype, pairs_ast, config_parameters, decls):
super(MachineAST, self).__init__(slicc, pairs_ast)
- self.ident = ident
+ self.ident = mtype.value
self.pairs_ast = pairs_ast
self.config_parameters = config_parameters
self.decls = decls
@@ -72,11 +72,5 @@ class MachineAST(DeclAST):
def findMachines(self):
mtype = self.ident
machine_type = self.symtab.find("MachineType", Type)
- pairs = self.pairs_ast.pairs
-
- pairs["Primary"] = True
- if not machine_type.addEnum(mtype, pairs):
+ if not machine_type.checkEnum(mtype):
self.error("Duplicate machine name: %s:%s" % (machine_type, mtype))
-
- # Generate code for all the internal decls
- self.decls.findMachines()