diff options
author | Brad Beckmann <Brad.Beckmann@amd.com> | 2015-07-20 09:15:18 -0500 |
---|---|---|
committer | Brad Beckmann <Brad.Beckmann@amd.com> | 2015-07-20 09:15:18 -0500 |
commit | 8a54adc2a55c9858cb536fac3a9cd92bc47ce778 (patch) | |
tree | ad482d891914407192f8aa568711baecfe92e83c /src/mem/slicc/ast/FuncDeclAST.py | |
parent | 0d00cbc97b47344e12e9eb943efb9ca29db66898 (diff) | |
download | gem5-8a54adc2a55c9858cb536fac3a9cd92bc47ce778.tar.xz |
slicc: enable overloading in functions not in classes
For many years the slicc symbol table has supported overloaded functions in
external classes. This patch extends that support to functions that are not
part of classes (a.k.a. no parent). For example, this support allows slicc
to understand that mapAddressToRange is overloaded and the NodeID is an
optional parameter.
Diffstat (limited to 'src/mem/slicc/ast/FuncDeclAST.py')
-rw-r--r-- | src/mem/slicc/ast/FuncDeclAST.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/mem/slicc/ast/FuncDeclAST.py b/src/mem/slicc/ast/FuncDeclAST.py index 052d9f05e..47ae7076e 100644 --- a/src/mem/slicc/ast/FuncDeclAST.py +++ b/src/mem/slicc/ast/FuncDeclAST.py @@ -74,9 +74,20 @@ class FuncDeclAST(DeclAST): self.symtab.popFrame() + func_name_args = self.ident + + if parent is None: + for arg in self.formals: + from slicc.ast import FormalParamAST + if isinstance(arg, FormalParamAST): + arg_name = arg.type_ast.ident + else: + arg_name = arg + func_name_args += "_" + str(arg_name) + machine = self.state_machine - func = Func(self.symtab, self.ident, self.location, return_type, - types, params, str(body), self.pairs) + func = Func(self.symtab, func_name_args, self.ident, self.location, + return_type, types, params, str(body), self.pairs) if parent is not None: if not parent.addFunc(func): |