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/symbols/Func.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/mem/slicc/symbols/Func.py') diff --git a/src/mem/slicc/symbols/Func.py b/src/mem/slicc/symbols/Func.py index a52b6bbcc..d50d0309f 100644 --- a/src/mem/slicc/symbols/Func.py +++ b/src/mem/slicc/symbols/Func.py @@ -29,7 +29,7 @@ from slicc.symbols.Symbol import Symbol from slicc.symbols.Type import Type class Func(Symbol): - def __init__(self, table, ident, location, return_type, param_types, + def __init__(self, table, ident, name, location, return_type, param_types, param_strings, body, pairs): super(Func, self).__init__(table, ident, location, pairs) self.return_type = return_type @@ -38,6 +38,7 @@ class Func(Symbol): self.body = body self.isInternalMachineFunc = False self.c_ident = ident + self.c_name = name self.class_name = "" def __repr__(self): @@ -55,7 +56,7 @@ class Func(Symbol): elif "return_by_pointer" in self and self.return_type != void_type: return_type += "*" - return "%s %s(%s);" % (return_type, self.c_ident, + return "%s %s(%s);" % (return_type, self.c_name, ", ".join(self.param_strings)) def writeCodeFiles(self, path, includes): @@ -80,7 +81,7 @@ class Func(Symbol): code(''' $return_type -${{self.class_name}}::${{self.c_ident}}($params) +${{self.class_name}}::${{self.c_name}}($params) { ${{self.body}} } -- cgit v1.2.3