1.1 --- a/translator.py Mon Dec 05 17:19:12 2016 +0100
1.2 +++ b/translator.py Mon Dec 05 17:21:35 2016 +0100
1.3 @@ -774,10 +774,21 @@
1.4
1.5 "Process the given class node 'n'."
1.6
1.7 + class_name = self.get_object_path(n.name)
1.8 +
1.9 + # Where a class is set conditionally or where the name may refer to
1.10 + # different values, assign the name.
1.11 +
1.12 + ref = self.importer.identify(class_name)
1.13 +
1.14 + if not ref.static():
1.15 + self.process_assignment_for_object(
1.16 + n.name, make_expression("((__attr) {0, &%s})" %
1.17 + encode_path(class_name)))
1.18 +
1.19 self.enter_namespace(n.name)
1.20
1.21 if self.have_object():
1.22 - class_name = self.get_namespace_path()
1.23 self.write_comment("Class: %s" % class_name)
1.24
1.25 self.initialise_inherited_members(class_name)
1.26 @@ -800,6 +811,11 @@
1.27 if ref:
1.28 continue
1.29
1.30 + # Ignore special type attributes.
1.31 +
1.32 + if is_type_attribute(name):
1.33 + continue
1.34 +
1.35 # Reference inherited attributes.
1.36
1.37 ref = self.importer.identify(path)
1.38 @@ -941,11 +957,11 @@
1.39 ref = self.importer.identify(objpath)
1.40
1.41 if self.in_conditional or self.in_function:
1.42 - self.process_assignment_for_function(original_name, compiler.ast.Name(name))
1.43 + self.process_assignment_for_object(original_name, compiler.ast.Name(name))
1.44 elif not ref.static():
1.45 context = self.is_method(objpath)
1.46
1.47 - self.process_assignment_for_function(original_name,
1.48 + self.process_assignment_for_object(original_name,
1.49 make_expression("((__attr) {%s, &%s})" % (
1.50 context and "&%s" % encode_path(context) or "0",
1.51 encode_path(objpath))))