1.1 --- a/translator.py Sat Mar 25 21:58:51 2017 +0100
1.2 +++ b/translator.py Sat Mar 25 22:00:14 2017 +0100
1.3 @@ -557,6 +557,7 @@
1.4
1.5 context_index = self.function_target - 1
1.6 context_identity = None
1.7 + context_identity_verified = False
1.8 final_identity = None
1.9
1.10 # Obtain encoded versions of each instruction, accumulating temporary
1.11 @@ -566,14 +567,15 @@
1.12
1.13 # Intercept a special instruction identifying the context.
1.14
1.15 - if instruction[0] == "<context_identity>":
1.16 + if instruction[0] in ("<context_identity>", "<context_identity_verified>"):
1.17 context_identity, _substituted = encode_access_instruction_arg(instruction[1], subs, instruction[0], context_index)
1.18 + context_identity_verified = instruction[0] == "<context_identity_verified>"
1.19 continue
1.20
1.21 # Intercept a special instruction identifying the target. The value
1.22 # is not encoded since it is used internally.
1.23
1.24 - if instruction[0] == "<final_identity>":
1.25 + elif instruction[0] == "<final_identity>":
1.26 final_identity = instruction[1]
1.27 continue
1.28
1.29 @@ -597,7 +599,7 @@
1.30 refs = [ref]
1.31
1.32 del self.attrs[0]
1.33 - return AttrResult(output, refs, location, context_identity)
1.34 + return AttrResult(output, refs, location, context_identity, context_identity_verified)
1.35
1.36 def init_substitutions(self):
1.37
1.38 @@ -1065,6 +1067,7 @@
1.39 context_required = True
1.40 have_access_context = isinstance(expr, AttrResult)
1.41 context_identity = have_access_context and expr.context()
1.42 + context_verified = have_access_context and expr.context_verified()
1.43 parameters = None
1.44 num_parameters = None
1.45 num_defaults = None
1.46 @@ -1353,20 +1356,26 @@
1.47 elif function:
1.48 if context_required:
1.49 if have_access_context:
1.50 - stages.append("__get_function(%s, %s)" % (
1.51 - context_identity, target_var))
1.52 + if context_verified:
1.53 + stages.append("__get_function_member(%s)" % target_var)
1.54 + else:
1.55 + stages.append("__get_function(%s, %s)" % (
1.56 + context_identity, target_var))
1.57 else:
1.58 stages.append("__get_function(__CONTEXT_AS_VALUE(%s), %s)" % (
1.59 context_var, target_var))
1.60 else:
1.61 - stages.append("__load_via_object(__VALUE(%s), __fn__).fn" % target_var)
1.62 + stages.append("_get_function_member(%s)" % target_var)
1.63
1.64 # With known parameters, the target can be tested.
1.65
1.66 elif known_parameters:
1.67 context_arg = context_required and args[0] or "__NULL"
1.68 if self.always_callable(refs):
1.69 - stages.append("__get_function(%s, %s)" % (context_arg, target_var))
1.70 + if context_verified:
1.71 + stages.append("__get_function_member(%s)" % target_var)
1.72 + else:
1.73 + stages.append("__get_function(%s, %s)" % (context_arg, target_var))
1.74 else:
1.75 stages.append("__check_and_get_function(%s, %s)" % (context_arg, target_var))
1.76