summaryrefslogtreecommitdiff
path: root/src/mem/slicc/symbols
diff options
context:
space:
mode:
authorNilay Vaish <nilay@cs.wisc.edu>2014-09-01 16:55:44 -0500
committerNilay Vaish <nilay@cs.wisc.edu>2014-09-01 16:55:44 -0500
commitb1d3873ec52692b0442666718da4175379697bb2 (patch)
treecff299c0befcef4f843272e1e9f633060fa8c815 /src/mem/slicc/symbols
parent3202ec98e713d3f997e6b47f06451236c565f706 (diff)
downloadgem5-b1d3873ec52692b0442666718da4175379697bb2.tar.xz
ruby: slicc: improve the grammar
This patch changes the grammar for SLICC so as to remove some of the redundant / duplicate rules. In particular rules for object/variable declaration and class member declaration have been unified. Similarly, the rules for a general function and a class method have been unified. One more change is in the priority of two rules. The first rule is on declaring a function with all the params typed and named. The second rule is on declaring a function with all the params only typed. Earlier the second rule had a higher priority. Now the first rule has a higher priority.
Diffstat (limited to 'src/mem/slicc/symbols')
-rw-r--r--src/mem/slicc/symbols/StateMachine.py1
-rw-r--r--src/mem/slicc/symbols/Type.py37
2 files changed, 9 insertions, 29 deletions
diff --git a/src/mem/slicc/symbols/StateMachine.py b/src/mem/slicc/symbols/StateMachine.py
index 6048383a5..2cda3a49d 100644
--- a/src/mem/slicc/symbols/StateMachine.py
+++ b/src/mem/slicc/symbols/StateMachine.py
@@ -120,6 +120,7 @@ class StateMachine(Symbol):
self.functions.append(func)
def addObject(self, obj):
+ self.symtab.registerSym(str(obj), obj)
self.objects.append(obj)
def addType(self, type):
diff --git a/src/mem/slicc/symbols/Type.py b/src/mem/slicc/symbols/Type.py
index 764173916..d9bd85c01 100644
--- a/src/mem/slicc/symbols/Type.py
+++ b/src/mem/slicc/symbols/Type.py
@@ -43,11 +43,6 @@ class Enumeration(PairContainer):
super(Enumeration, self).__init__(pairs)
self.ident = ident
-class Method(object):
- def __init__(self, return_type, param_types):
- self.return_type = return_type
- self.param_types = param_types
-
class Type(Symbol):
def __init__(self, table, ident, location, pairs, machine=None):
super(Type, self).__init__(table, ident, location, pairs)
@@ -96,12 +91,7 @@ class Type(Symbol):
self.statePermPairs = []
self.data_members = orderdict()
-
- # Methods
self.methods = {}
- self.functions = {}
-
- # Enums
self.enums = orderdict()
@property
@@ -160,23 +150,12 @@ class Type(Symbol):
def statePermPairAdd(self, state_name, perm_name):
self.statePermPairs.append([state_name, perm_name])
- def addMethod(self, name, return_type, param_type_vec):
- ident = self.methodId(name, param_type_vec)
- if ident in self.methods:
- return False
-
- self.methods[ident] = Method(return_type, param_type_vec)
- return True
-
- # Ideally either this function or the one above should exist. But
- # methods and functions have different structures right now.
- # Hence, these are different, at least for the time being.
def addFunc(self, func):
ident = self.methodId(func.ident, func.param_types)
- if ident in self.functions:
+ if ident in self.methods:
return False
- self.functions[ident] = func
+ self.methods[ident] = func
return True
def addEnum(self, ident, pairs):
@@ -379,9 +358,9 @@ set${{dm.ident}}(const ${{dm.type.c_ident}}& local_${{dm.ident}})
code('$const${{dm.type.c_ident}} m_${{dm.ident}}$init;')
- # Prototypes for functions defined for the Type
- for item in self.functions:
- proto = self.functions[item].prototype
+ # Prototypes for methods defined for the Type
+ for item in self.methods:
+ proto = self.methods[item].prototype
if proto:
code('$proto')
@@ -442,9 +421,9 @@ ${{self.c_ident}}::print(ostream& out) const
out << "]";
}''')
- # print the code for the functions in the type
- for item in self.functions:
- code(self.functions[item].generateCode())
+ # print the code for the methods in the type
+ for item in self.methods:
+ code(self.methods[item].generateCode())
code.write(path, "%s.cc" % self.c_ident)