1.1 --- a/generator.py Sat Nov 26 23:05:45 2016 +0100
1.2 +++ b/generator.py Sat Nov 26 23:07:09 2016 +0100
1.3 @@ -783,6 +783,18 @@
1.4 encode_literal_constant_value(attr)))
1.5 continue
1.6
1.7 + # Special cases.
1.8 +
1.9 + elif attrname in ("__fname__", "__name__"):
1.10 + path = ref.get_origin()
1.11 + local_number = self.importer.all_constants[path][path]
1.12 + constant_name = "$c%d" % local_number
1.13 + attr_path = "%s.%s" % (path, constant_name)
1.14 + constant_number = self.optimiser.constant_numbers[attr_path]
1.15 + constant_value = "__const%d" % constant_number
1.16 + structure.append("%s /* %s */" % (constant_value, attrname))
1.17 + continue
1.18 +
1.19 structure.append(self.encode_member(origin, attrname, attr, kind))
1.20
1.21 def encode_member(self, path, name, ref, structure_type):
1.22 @@ -813,16 +825,6 @@
1.23 attr_path = encode_predefined_reference("%s.%s" % (path, name))
1.24 return "{&%s, &%s} /* %s */" % (attr_path, attr_path, name)
1.25
1.26 - # Special cases.
1.27 -
1.28 - if name == "__name__":
1.29 - local_number = self.importer.all_constants[path][path]
1.30 - constant_name = "$c%d" % local_number
1.31 - attr_path = "%s.%s" % (path, constant_name)
1.32 - constant_number = self.optimiser.constant_numbers[attr_path]
1.33 - constant_value = "__const%d" % constant_number
1.34 - return "%s /* %s */" % (constant_value, name)
1.35 -
1.36 # General undetermined members.
1.37
1.38 if kind in ("<var>", "<instance>"):