1.1 --- a/translator.py Mon Feb 13 21:49:59 2017 +0100
1.2 +++ b/translator.py Tue Feb 14 00:17:39 2017 +0100
1.3 @@ -740,6 +740,7 @@
1.4
1.5 temp_subs = {
1.6 "<context>" : "__tmp_context",
1.7 + "<set_context>" : "__tmp_context",
1.8 "<accessor>" : "__tmp_value",
1.9 "<target_accessor>" : "__tmp_target_value",
1.10 "<set_accessor>" : "__tmp_value",
1.11 @@ -747,6 +748,7 @@
1.12 }
1.13
1.14 op_subs = {
1.15 + "<set_context>" : "__set_context",
1.16 "<set_accessor>" : "__set_accessor",
1.17 "<set_target_accessor>" : "__set_target_accessor",
1.18 }
1.19 @@ -1165,6 +1167,7 @@
1.20 # Invocation requirements.
1.21
1.22 context_required = True
1.23 + have_access_context = isinstance(expr, AttrResult)
1.24 parameters = None
1.25
1.26 # Obtain details of the callable and of its parameters.
1.27 @@ -1235,8 +1238,11 @@
1.28 # set to null.
1.29
1.30 if context_required:
1.31 - self.record_temp("__tmp_targets")
1.32 - args = ["__CONTEXT_AS_VALUE(__tmp_targets[%d])" % self.function_target]
1.33 + if have_access_context:
1.34 + args = ["(__attr) {.value=__tmp_context}"]
1.35 + else:
1.36 + self.record_temp("__tmp_targets")
1.37 + args = ["__CONTEXT_AS_VALUE(__tmp_targets[%d])" % self.function_target]
1.38 else:
1.39 args = ["__NULL"]
1.40
1.41 @@ -1347,8 +1353,12 @@
1.42 self.record_temp("__tmp_targets")
1.43
1.44 if context_required:
1.45 - stages.append("__get_function(__CONTEXT_AS_VALUE(__tmp_targets[%d]).value, __tmp_targets[%d])" % (
1.46 - self.function_target, self.function_target))
1.47 + if have_access_context:
1.48 + stages.append("__get_function(__tmp_context, __tmp_targets[%d])" % (
1.49 + self.function_target))
1.50 + else:
1.51 + stages.append("__get_function(__CONTEXT_AS_VALUE(__tmp_targets[%d]).value, __tmp_targets[%d])" % (
1.52 + self.function_target, 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__")))