# HG changeset patch # User Paul Boddie # Date 1487445606 -3600 # Node ID 60c18e54c8dbbf417c44b2edb927ea4aed103780 # Parent 767f7ac69ef2d2e6e69f045dc2866f90a88695d6 Introduced a context test that sets a local context for static attributes. diff -r 767f7ac69ef2 -r 60c18e54c8db encoders.py --- a/encoders.py Sat Feb 18 20:13:47 2017 +0100 +++ b/encoders.py Sat Feb 18 20:20:06 2017 +0100 @@ -207,7 +207,7 @@ ) static_ops = ( - "__load_static_ignore", "__load_static_replace", "__load_static_test", + "__load_static_ignore", "__load_static_replace", "__load_static_test", "", ) context_values = ( @@ -215,7 +215,7 @@ ) context_ops = ( - "", "", "", + "", "", "", "", ) reference_acting_ops = attribute_ops + checked_ops + typename_ops @@ -286,7 +286,7 @@ # Add context storage information to certain operations. - elif op in context_ops: + if op in context_ops: a.insert(0, context_index) # Define any argument string. diff -r 767f7ac69ef2 -r 60c18e54c8db optimiser.py --- a/optimiser.py Sat Feb 18 20:13:47 2017 +0100 +++ b/optimiser.py Sat Feb 18 20:20:06 2017 +0100 @@ -531,8 +531,10 @@ # Wrap accesses in context operations. if context_test == "test": - if final_method in ("static", "static-invoke"): + if final_method == "static": emit(("__load_static_test", context_var, origin)) + elif final_method == "static-invoke": + emit(("", context_var, origin)) elif final_method == "access-invoke": emit(("", context_var, accessor)) else: diff -r 767f7ac69ef2 -r 60c18e54c8db templates/ops.h --- a/templates/ops.h Sat Feb 18 20:13:47 2017 +0100 +++ b/templates/ops.h Sat Feb 18 20:20:06 2017 +0100 @@ -77,6 +77,10 @@ #define __test_context_set(__TARGET, __CONTEXT, __ATTR) \ (__test_context_update(__CONTEXT, __ATTR) ? (__set_context(__TARGET, (__attr) {.value=__CONTEXT}), __ATTR) : __ATTR) +#define __test_context_static(__TARGET, __CONTEXT, __REF) \ + (__test_context_update(__CONTEXT, (__attr) {.value=__REF}) ? \ + (__set_context(__TARGET, (__attr) {.value=__CONTEXT}), (__attr) {.value=__REF}) : (__attr) {.value=__REF}) + #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) diff -r 767f7ac69ef2 -r 60c18e54c8db translator.py --- a/translator.py Sat Feb 18 20:13:47 2017 +0100 +++ b/translator.py Sat Feb 18 20:20:06 2017 +0100 @@ -790,6 +790,7 @@ "" : "__tmp_contexts", "" : "__tmp_contexts", + "" : "__tmp_contexts", "" : "__tmp_contexts", "" : "__tmp_private_context", "" : "__tmp_value", @@ -799,6 +800,7 @@ self.op_subs = { "" : "__get_context", "" : "__test_context_set", + "" : "__test_context_static", "" : "__set_context", "" : "__set_private_context", "" : "__set_accessor",