1.1 --- a/optimiser.py Tue Feb 14 00:17:39 2017 +0100
1.2 +++ b/optimiser.py Fri Feb 17 16:30:37 2017 +0100
1.3 @@ -535,15 +535,24 @@
1.4 if final_method == "static":
1.5 emit(("__load_static_replace", context_var, origin))
1.6
1.7 + # Omit the context update operation where the target is static
1.8 + # and the context is recorded separately.
1.9 +
1.10 + elif final_method == "static-invoke":
1.11 + pass
1.12 +
1.13 # Only update any context if no separate context is used.
1.14
1.15 - elif final_method not in ("access-invoke", "static-invoke"):
1.16 + elif final_method != "access-invoke":
1.17 emit(("__update_context", context_var, accessor))
1.18
1.19 else:
1.20 emit(accessor)
1.21
1.22 - elif final_method not in ("assign", "static-assign"):
1.23 + # Omit the accessor for assignments and for invocations of static
1.24 + # targets.
1.25 +
1.26 + elif final_method not in ("assign", "static-assign", "static-invoke"):
1.27 emit(accessor)
1.28
1.29 self.access_instructions[access_location] = instructions
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/tests/nested_calls.py Fri Feb 17 16:30:37 2017 +0100
2.3 @@ -0,0 +1,15 @@
2.4 +class C:
2.5 + def __init__(self, x):
2.6 + self.x = x
2.7 +
2.8 + def value(self):
2.9 + return self.x
2.10 +
2.11 + def length(self):
2.12 + return self.double(self.value())
2.13 +
2.14 + def double(self, x):
2.15 + return x * 2
2.16 +
2.17 +c = C(3)
2.18 +print c.length() # 6
3.1 --- a/translator.py Tue Feb 14 00:17:39 2017 +0100
3.2 +++ b/translator.py Fri Feb 17 16:30:37 2017 +0100
3.3 @@ -1339,8 +1339,11 @@
3.4 # Without a known specific callable, the expression provides the target.
3.5
3.6 if not target or context_required:
3.7 - self.record_temp("__tmp_targets")
3.8 - stages.append("__tmp_targets[%d] = %s" % (self.function_target, expr))
3.9 + if target:
3.10 + stages.append(str(expr))
3.11 + else:
3.12 + self.record_temp("__tmp_targets")
3.13 + stages.append("__tmp_targets[%d] = %s" % (self.function_target, expr))
3.14
3.15 # Any specific callable is then obtained.
3.16