class Function:
- __id = 0
+ # 0-3 are reserved to memcpy, malloc, free, and realloc
+ __id = 4
def __init__(self, type, name, args, call = '', fail = None, sideeffects=True):
self.id = Function.__id
def visit(self, visitor, *args, **kwargs):
return visitor.visit_polymorphic(self, *args, **kwargs)
+ def iterswitch(self):
+ cases = [['default']]
+ types = [self.default_type]
+
+ for expr, type in self.switch_types:
+ case = 'case %s' % expr
+ try:
+ i = types.index(type)
+ except ValueError:
+ cases.append([case])
+ types.append(type)
+ else:
+ cases[i].append(case)
+
+ return zip(cases, types)
+
class Visitor: