# HG changeset patch # User Paul Boddie # Date 1487357199 -3600 # Node ID 0b24363cbf9c19781f7242d7ee115a97e133314e # Parent 6eaa4b2f2534e45fad07127c7125fd35dce1ede0 Reintroduced a private context variable where the context is not used for invocations. diff -r 6eaa4b2f2534 -r 0b24363cbf9c optimiser.py --- a/optimiser.py Fri Feb 17 18:52:18 2017 +0100 +++ b/optimiser.py Fri Feb 17 19:46:39 2017 +0100 @@ -466,8 +466,12 @@ # Set the context, if appropriate. if remaining == 1 and final_method != "assign" and context == "final-accessor": - emit(("", accessor)) - accessor = context_var = "" + if final_method in ("access-invoke", "static-invoke"): + emit(("", accessor)) + accessor = context_var = "" + else: + emit(("", accessor)) + accessor = context_var = "" # Perform the access only if not achieved directly. @@ -493,8 +497,12 @@ # Set the context, if appropriate. if remaining == 1 and final_method != "assign" and context == "final-accessor": - emit(("", accessor)) - accessor = context_var = "" + if final_method in ("access-invoke", "static-invoke"): + emit(("", accessor)) + accessor = context_var = "" + else: + emit(("", accessor)) + accessor = context_var = "" # Perform the access only if not achieved directly. diff -r 6eaa4b2f2534 -r 0b24363cbf9c templates/ops.h --- a/templates/ops.h Fri Feb 17 18:52:18 2017 +0100 +++ b/templates/ops.h Fri Feb 17 19:46:39 2017 +0100 @@ -75,6 +75,7 @@ #define __get_context(__TARGET) (__tmp_contexts[__TARGET]) #define __set_context(__TARGET, __ATTR) (__tmp_contexts[__TARGET] = (__ATTR).value) +#define __set_private_context(__ATTR) (__tmp_private_context = (__ATTR).value) #define __set_accessor(__ATTR) (__tmp_value = (__ATTR).value) #define __set_target_accessor(__ATTR) (__tmp_target_value = (__ATTR).value) diff -r 6eaa4b2f2534 -r 0b24363cbf9c translator.py --- a/translator.py Fri Feb 17 18:52:18 2017 +0100 +++ b/translator.py Fri Feb 17 19:46:39 2017 +0100 @@ -741,6 +741,8 @@ temp_subs = { "" : "__tmp_contexts", "" : "__tmp_contexts", + "" : "__tmp_private_context", + "" : "__tmp_private_context", "" : "__tmp_value", "" : "__tmp_target_value", "" : "__tmp_value", @@ -750,6 +752,7 @@ op_subs = { "" : "__get_context", "" : "__set_context", + "" : "__set_private_context", "" : "__set_accessor", "" : "__set_target_accessor", } @@ -1374,11 +1377,11 @@ # Methods accessed via unidentified accessors are obtained. elif function: - self.record_temp("__tmp_contexts") self.record_temp("__tmp_targets") if context_required: if have_access_context: + self.record_temp("__tmp_contexts") stages.append("__get_function(__tmp_contexts[%d], __tmp_targets[%d])" % ( self.function_target, self.function_target)) else: @@ -1942,6 +1945,8 @@ # Add temporary variable usage details. + if self.uses_temp(name, "__tmp_private_context"): + self.writeline("__ref __tmp_private_context;") if self.uses_temp(name, "__tmp_value"): self.writeline("__ref __tmp_value;") if self.uses_temp(name, "__tmp_target_value"):