1.1 --- a/generator.py Mon Jan 30 22:32:38 2017 +0100
1.2 +++ b/generator.py Mon Jan 30 22:34:46 2017 +0100
1.3 @@ -20,7 +20,7 @@
1.4 """
1.5
1.6 from common import CommonOutput, get_builtin_module, get_builtin_type
1.7 -from encoders import encode_bound_reference, encode_function_pointer, \
1.8 +from encoders import encode_function_pointer, \
1.9 encode_instantiator_pointer, \
1.10 encode_literal_constant, encode_literal_constant_member, \
1.11 encode_literal_constant_size, encode_literal_constant_value, \
1.12 @@ -282,20 +282,15 @@
1.13
1.14 if parent_kind == "<class>":
1.15
1.16 - # A bound version of a method.
1.17 + # A method.
1.18
1.19 - structure = self.populate_function(path, function_instance_attrs, False)
1.20 - self.write_structure(f_decls, f_defs, encode_bound_reference(path), table_name, structure)
1.21 -
1.22 - # An unbound version of a method.
1.23 -
1.24 - structure = self.populate_function(path, function_instance_attrs, True)
1.25 + structure = self.populate_function(path, function_instance_attrs)
1.26 self.write_structure(f_decls, f_defs, path, table_name, structure)
1.27
1.28 else:
1.29 # A normal function.
1.30
1.31 - structure = self.populate_function(path, function_instance_attrs, False)
1.32 + structure = self.populate_function(path, function_instance_attrs)
1.33 self.write_structure(f_decls, f_defs, path, table_name, structure)
1.34
1.35 # Functions with defaults need to declare instance structures.
1.36 @@ -821,32 +816,27 @@
1.37 name, pos = value
1.38 table.append((encode_symbol("pcode", name), pos))
1.39
1.40 - def populate_function(self, path, function_instance_attrs, unbound=False):
1.41 + def populate_function(self, path, function_instance_attrs):
1.42
1.43 """
1.44 Populate a structure for the function with the given 'path'. The given
1.45 - 'attrs' provide the instance attributes, and if 'unbound' is set to a
1.46 - true value, an unbound method structure is produced (as opposed to a
1.47 - callable bound method structure).
1.48 + 'attrs' provide the instance attributes.
1.49 """
1.50
1.51 structure = []
1.52 - self.populate_structure(Reference("<function>", path), function_instance_attrs, "<instance>", structure, unbound)
1.53 + self.populate_structure(Reference("<function>", path), function_instance_attrs, "<instance>", structure)
1.54
1.55 # Append default members.
1.56
1.57 self.append_defaults(path, structure)
1.58 return structure
1.59
1.60 - def populate_structure(self, ref, attrs, kind, structure, unbound=False):
1.61 + def populate_structure(self, ref, attrs, kind, structure):
1.62
1.63 """
1.64 Traverse the attributes in the determined order for the structure having
1.65 the given 'ref' whose members are provided by the 'attrs' mapping, in a
1.66 structure of the given 'kind', adding entries to the object 'structure'.
1.67 - If 'unbound' is set to a true value, an unbound method function pointer
1.68 - will be employed, with a reference to the bound method incorporated into
1.69 - the special __fn__ attribute.
1.70 """
1.71
1.72 # Populate function instance structures for functions.
1.73 @@ -877,29 +867,21 @@
1.74
1.75 if attrname == "__fn__":
1.76
1.77 - # Provide bound method references and the unbound function
1.78 - # pointer if populating methods in a class.
1.79 -
1.80 - bound_attr = None
1.81 -
1.82 - # Classes offer instantiators.
1.83 + # Classes offer instantiators which can be called without a
1.84 + # context.
1.85
1.86 if kind == "<class>":
1.87 attr = encode_instantiator_pointer(attr)
1.88 -
1.89 - # Methods offers references to bound versions and an unbound
1.90 - # method function.
1.91 + unbound_attr = attr
1.92
1.93 - elif unbound:
1.94 - bound_attr = encode_bound_reference(attr)
1.95 - attr = "__unbound_method"
1.96 -
1.97 - # Other functions just offer function pointers.
1.98 + # Provide bound method and unbound function pointers if
1.99 + # populating methods in a class.
1.100
1.101 else:
1.102 attr = encode_function_pointer(attr)
1.103 + unbound_attr = "__unbound_method"
1.104
1.105 - structure.append("{.b=%s, .fn=%s}" % (bound_attr and "&%s" % bound_attr or "0", attr))
1.106 + structure.append("{.inv=%s, .fn=%s}" % (unbound_attr, attr))
1.107 continue
1.108
1.109 # Special argument specification member.