else:
value = self.name
entry = env.declare_const(self.name, enum_entry.type,
- value, self.pos, cname = self.cname)
+ value, self.pos, cname = self.cname, visibility = enum_entry.visibility)
enum_entry.enum_values.append(entry)
"""
This transformation tries to turn long if statements into C switch statements.
The requirement is that every clause be an (or of) var == value, where the var
- is common among all clauses and both var and value are not Python objects.
+ is common among all clauses and both var and value are ints.
"""
def extract_conditions(self, cond):
return node
elif common_var is not None and not is_common_value(var, common_var):
return node
+ elif not var.type.is_int or sum([not cond.type.is_int for cond in conditions]):
+ return node
else:
common_var = var
cases.append(Nodes.SwitchCaseNode(pos = if_clause.pos,
def qualify_name(self, name):
return "%s.%s" % (self.qualified_name, name)
- def declare_const(self, name, type, value, pos, cname = None):
+ def declare_const(self, name, type, value, pos, cname = None, visibility = 'private'):
# Add an entry for a named constant.
if not cname:
if self.in_cinclude:
cname = name
else:
cname = self.mangle(Naming.enum_prefix, name)
- entry = self.declare(name, cname, type, pos, 'private')
+ entry = self.declare(name, cname, type, pos, visibility)
entry.is_const = 1
entry.value = value
return entry