From 8a54adc2a55c9858cb536fac3a9cd92bc47ce778 Mon Sep 17 00:00:00 2001 From: Brad Beckmann Date: Mon, 20 Jul 2015 09:15:18 -0500 Subject: 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. --- src/mem/slicc/ast/FuncCallExprAST.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/mem/slicc/ast/FuncCallExprAST.py') 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 -- cgit v1.2.3