summaryrefslogtreecommitdiff
path: root/src/mem/slicc/symbols
diff options
context:
space:
mode:
authorBrad Beckmann <Brad.Beckmann@amd.com>2015-07-20 09:15:18 -0500
committerBrad Beckmann <Brad.Beckmann@amd.com>2015-07-20 09:15:18 -0500
commit8a54adc2a55c9858cb536fac3a9cd92bc47ce778 (patch)
treead482d891914407192f8aa568711baecfe92e83c /src/mem/slicc/symbols
parent0d00cbc97b47344e12e9eb943efb9ca29db66898 (diff)
downloadgem5-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/symbols')
-rw-r--r--src/mem/slicc/symbols/Func.py7
-rw-r--r--src/mem/slicc/symbols/Transition.py2
2 files changed, 5 insertions, 4 deletions
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}}
}
diff --git a/src/mem/slicc/symbols/Transition.py b/src/mem/slicc/symbols/Transition.py
index 9ecd6c54b..856d3f4b0 100644
--- a/src/mem/slicc/symbols/Transition.py
+++ b/src/mem/slicc/symbols/Transition.py
@@ -40,7 +40,7 @@ class Transition(Symbol):
# check to make sure there is a getNextState function declared
found = False
for func in machine.functions:
- if func.c_ident == 'getNextState':
+ if func.c_ident == 'getNextState_Address':
found = True
break
if found == False: