1.1 --- a/translator.py Mon Jan 30 22:32:38 2017 +0100
1.2 +++ b/translator.py Mon Jan 30 22:34:46 2017 +0100
1.3 @@ -22,7 +22,7 @@
1.4 from common import CommonModule, CommonOutput, InstructionSequence, \
1.5 first, get_builtin_module, get_builtin_type, init_item, \
1.6 predefined_constants
1.7 -from encoders import encode_access_instruction, encode_bound_reference, \
1.8 +from encoders import encode_access_instruction, \
1.9 encode_function_pointer, encode_literal_constant, \
1.10 encode_literal_instantiator, encode_instantiator_pointer, \
1.11 encode_instructions, \
1.12 @@ -1072,10 +1072,7 @@
1.13 # Handle bound methods.
1.14
1.15 if not instance_name:
1.16 - if self.is_method(objpath):
1.17 - instance_name = "&%s" % encode_bound_reference(objpath)
1.18 - else:
1.19 - instance_name = "&%s" % encode_path(objpath)
1.20 + instance_name = "&%s" % encode_path(objpath)
1.21
1.22 # Where defaults are involved but cannot be identified, obtain a new
1.23 # instance of the lambda and populate the defaults.
1.24 @@ -1164,7 +1161,7 @@
1.25 if expr.has_kind("<class>"):
1.26 instantiation = objpath
1.27 target = encode_instantiator_pointer(objpath)
1.28 - target_structure = "&%s" % encode_bound_reference("%s.__init__" % objpath)
1.29 + target_structure = "&%s" % encode_path("%s.__init__" % objpath)
1.30 context_required = False
1.31
1.32 # Only plain functions and bound methods employ function pointers.
1.33 @@ -1188,9 +1185,7 @@
1.34 # Access bound method defaults even if it is not clear whether
1.35 # the accessor is appropriate.
1.36
1.37 - target_structure = self.is_method(objpath) and \
1.38 - "&%s" % encode_bound_reference(objpath) or \
1.39 - "&%s" % encode_path(objpath)
1.40 + target_structure = "&%s" % encode_path(objpath)
1.41
1.42 # Other targets are retrieved at run-time.
1.43
1.44 @@ -1309,8 +1304,12 @@
1.45
1.46 elif function:
1.47 self.record_temp("__tmp_targets")
1.48 - stages.append("__load_via_object(__tmp_targets[%d].value, %s).fn" % (
1.49 - self.function_target, encode_symbol("pos", "__fn__")))
1.50 +
1.51 + if context_required:
1.52 + stages.append("__get_function(__tmp_targets[%d])" % self.function_target)
1.53 + else:
1.54 + stages.append("__load_via_object(__tmp_targets[%d].value, %s).fn" % (
1.55 + self.function_target, encode_symbol("pos", "__fn__")))
1.56
1.57 # With a known target, the function is obtained directly and called.
1.58 # By putting the invocation at the end of the final element in the