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/FuncCallExprAST.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/FuncCallExprAST.py')
-rw-r--r-- | src/mem/slicc/ast/FuncCallExprAST.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mem/slicc/ast/FuncCallExprAST.py b/src/mem/slicc/ast/FuncCallExprAST.py index 8aebad336..9336a2297 100644 --- a/src/mem/slicc/ast/FuncCallExprAST.py +++ b/src/mem/slicc/ast/FuncCallExprAST.py @@ -80,12 +80,18 @@ class FuncCallExprAST(ExprAST): code("APPEND_TRANSITION_COMMENT($0)", self.exprs[0].inline()) return self.symtab.find("void", Type) + func_name_args = self.proc_name + + for expr in self.exprs: + actual_type,param_code = expr.inline(True) + func_name_args += "_" + str(actual_type.ident) + # Look up the function in the symbol table - func = self.symtab.find(self.proc_name, Func) + func = self.symtab.find(func_name_args, Func) # Check the types and get the code for the parameters if func is None: - self.error("Unrecognized function name: '%s'", self.proc_name) + self.error("Unrecognized function name: '%s'", func_name_args) if len(self.exprs) != len(func.param_types): self.error("Wrong number of arguments passed to function : '%s'" +\ @@ -193,7 +199,7 @@ if (!(${{cvec[0]}})) { params += str(param_code); fix = code.nofix() - code('(${{func.c_ident}}($params))') + code('(${{func.c_name}}($params))') code.fix(fix) return func.return_type |