Commit ab629168 authored by Stefan Behnel's avatar Stefan Behnel

fix C name redefinition: names must be uniquified at the module scope, local...

fix C name redefinition: names must be uniquified at the module scope, local scope is not enough as it may not have a unique name itself
parent 4523a8ab
...@@ -306,13 +306,17 @@ class Scope(object): ...@@ -306,13 +306,17 @@ class Scope(object):
#return self.parent_scope.mangle(prefix, self.name) #return self.parent_scope.mangle(prefix, self.name)
def next_id(self, name=None): def next_id(self, name=None):
# Return a cname fragment that is unique for this scope. # Return a cname fragment that is unique for this module
counters = self.global_scope().id_counters
try: try:
count = self.id_counters[name] + 1 count = counters[name] + 1
except KeyError: except KeyError:
count = 0 count = 0
self.id_counters[name] = count counters[name] = count
if name: if name:
if not count:
# unique names don't need a suffix, reoccurrences will get one
return name
return '%s%d' % (name, count) return '%s%d' % (name, count)
else: else:
return '%d' % count return '%d' % count
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment