summaryrefslogtreecommitdiff
path: root/src/mem/slicc/ast/FuncDeclAST.py
diff options
context:
space:
mode:
authorNilay Vaish <nilay@cs.wisc.edu>2012-10-15 17:27:16 -0500
committerNilay Vaish <nilay@cs.wisc.edu>2012-10-15 17:27:16 -0500
commit3e607f146f4c8acac6b42e61a0e6295f52f408a4 (patch)
treee0274a4eab977e9662a9dc22126f726518d8213f /src/mem/slicc/ast/FuncDeclAST.py
parentc7b0901b97a86eb2d61e4ddd96a73a9d777a57c1 (diff)
downloadgem5-3e607f146f4c8acac6b42e61a0e6295f52f408a4.tar.xz
ruby: allow function definition in slicc structs
This patch adds support for function definitions to appear in slicc structs. This is required for supporting functional accesses for different types of messages. Subsequent patches will use this to development.
Diffstat (limited to 'src/mem/slicc/ast/FuncDeclAST.py')
-rw-r--r--src/mem/slicc/ast/FuncDeclAST.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/mem/slicc/ast/FuncDeclAST.py b/src/mem/slicc/ast/FuncDeclAST.py
index 54b0f2c59..1d7e2c3ff 100644
--- a/src/mem/slicc/ast/FuncDeclAST.py
+++ b/src/mem/slicc/ast/FuncDeclAST.py
@@ -43,7 +43,7 @@ class FuncDeclAST(DeclAST):
def files(self, parent=None):
return set()
- def generate(self):
+ def generate(self, parent = None):
types = []
params = []
void_type = self.symtab.find("void", Type)
@@ -71,9 +71,16 @@ class FuncDeclAST(DeclAST):
machine = self.state_machine
func = Func(self.symtab, self.ident, self.location, return_type,
- types, params, str(body), self.pairs, machine)
+ types, params, str(body), self.pairs)
- if machine is not None:
+ if parent is not None:
+ if not parent.addFunc(func):
+ self.error("Duplicate method: %s:%s()" % (parent, self.ident))
+ func.class_name = parent.c_ident
+
+ elif machine is not None:
machine.addFunc(func)
+ func.isInternalMachineFunc = True
+ func.class_name = "%s_Controller" % machine
else:
self.symtab.newSymbol(func)