Commit 2c104e67 authored by Robert Bradshaw's avatar Robert Bradshaw

Only define used ctuples.

parent 39cae5e9
......@@ -6595,6 +6595,7 @@ class TupleNode(SequenceNode):
self.generate_sequence_packing_code(code)
code.put_giveref(self.py_result())
else:
self.type.entry.used = True
self.generate_sequence_packing_code(code)
......
......@@ -721,6 +721,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
pass
elif type.is_struct_or_union or type.is_cpp_class:
self.generate_struct_union_predeclaration(entry, code)
elif type.is_ctuple and entry.used:
self.generate_struct_union_predeclaration(entry.type.struct_entry, code)
elif type.is_extension_type:
self.generate_objstruct_predeclaration(type, code)
# Actual declarations
......@@ -734,6 +736,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self.generate_enum_definition(entry, code)
elif type.is_struct_or_union:
self.generate_struct_union_definition(entry, code)
elif type.is_ctuple and entry.used:
self.generate_struct_union_definition(entry.type.struct_entry, code)
elif type.is_cpp_class:
self.generate_cpp_class_definition(entry, code)
elif type.is_extension_type:
......
......@@ -1172,7 +1172,8 @@ class CTupleBaseTypeNode(CBaseTypeNode):
return PyrexType.error_type
component_types.append(type)
type = PyrexTypes.c_tuple_type(component_types)
env.declare_tuple_type(self.pos, type)
entry = env.declare_tuple_type(self.pos, type)
entry.used = True
return type
......
......@@ -607,7 +607,7 @@ class Scope(object):
return entry
def declare_tuple_type(self, pos, type):
self.outer_scope.declare_tuple_type(pos, type)
return self.outer_scope.declare_tuple_type(pos, type)
def declare_var(self, name, type, pos,
cname = None, visibility = 'private',
......@@ -1070,9 +1070,11 @@ class ModuleScope(Scope):
scope = StructOrUnionScope(cname)
for ix, component in enumerate(type.components):
scope.declare_var(name="f%s" % ix, type=component, pos=pos)
entry = self.declare_struct_or_union(cname, 'struct', scope, typedef_flag=True, pos=pos, cname=cname)
entry.used = True
type.struct = entry
struct_entry = self.declare_struct_or_union(cname + '_struct', 'struct', scope, typedef_flag=True, pos=pos, cname=cname)
self.type_entries.remove(struct_entry)
type.struct_entry = struct_entry
type.entry = self.declare_type(cname, type, pos, cname)
return type.entry
def declare_builtin(self, name, pos):
if not hasattr(builtins, name) \
......
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