1.1 --- a/generator.py Fri Nov 11 00:05:34 2016 +0100
1.2 +++ b/generator.py Fri Nov 11 17:53:06 2016 +0100
1.3 @@ -667,9 +667,8 @@
1.4 callable bound method structure).
1.5 """
1.6
1.7 - cls = self.function_type
1.8 structure = []
1.9 - self.populate_structure(Reference("<instance>", cls), function_instance_attrs, "<instance>", structure, unbound)
1.10 + self.populate_structure(Reference("<function>", path), function_instance_attrs, "<instance>", structure, unbound)
1.11
1.12 # Append default members.
1.13
1.14 @@ -687,9 +686,24 @@
1.15 the special __fn__ attribute.
1.16 """
1.17
1.18 - origin = ref.get_origin()
1.19 + # Populate function instance structures for functions.
1.20 +
1.21 + if ref.has_kind("<function>"):
1.22 + origin = self.function_type
1.23 + structure_ref = Reference("<instance>", self.function_type)
1.24 +
1.25 + # Otherwise, just populate the appropriate structures.
1.26
1.27 - for attrname in self.optimiser.structures[ref]:
1.28 + else:
1.29 + origin = ref.get_origin()
1.30 + structure_ref = ref
1.31 +
1.32 + # Refer to instantiator function tables for classes, specific function
1.33 + # tables for individual functions.
1.34 +
1.35 + ptable = encode_tablename("<function>", ref.get_origin())
1.36 +
1.37 + for attrname in self.optimiser.structures[structure_ref]:
1.38
1.39 # Handle gaps in the structure.
1.40
1.41 @@ -733,7 +747,7 @@
1.42 # Special argument specification member.
1.43
1.44 elif attrname == "__args__":
1.45 - structure.append("{.min=%s, .ptable=&%s}" % (attr, encode_tablename("<function>", origin)))
1.46 + structure.append("{.min=%s, .ptable=&%s}" % (attr, ptable))
1.47 continue
1.48
1.49 # Special internal data member.