1.1 --- a/templates/ops.c Sat Feb 18 18:52:04 2017 +0100
1.2 +++ b/templates/ops.c Sat Feb 18 20:13:47 2017 +0100
1.3 @@ -198,14 +198,16 @@
1.4
1.5 /* Context-related operations. */
1.6
1.7 -__attr __test_context(__ref context, __attr attr)
1.8 +int __test_context_update(__ref context, __attr attr)
1.9 {
1.10 + /* Return whether the context should be updated for the attribute. */
1.11 +
1.12 __ref attrcontext = __CONTEXT_AS_VALUE(attr).value;
1.13
1.14 /* Preserve any existing null or instance context. */
1.15
1.16 if ((attrcontext == 0) || __is_instance(attrcontext))
1.17 - return attr;
1.18 + return 0;
1.19
1.20 /* Test any instance context against the context employed by the
1.21 attribute. */
1.22 @@ -213,7 +215,7 @@
1.23 if (__is_instance(context))
1.24 {
1.25 if (__test_common_instance(context, __TYPEPOS(attrcontext), __TYPECODE(attrcontext)))
1.26 - return __update_context(context, attr);
1.27 + return 1;
1.28 else
1.29 __raise_type_error();
1.30 }
1.31 @@ -221,11 +223,21 @@
1.32 /* Test for access to a type class attribute using a type instance. */
1.33
1.34 if (__test_specific_type(attrcontext, &__TYPE_CLASS_TYPE) && __is_type_instance(context))
1.35 - return __update_context(context, attr);
1.36 + return 1;
1.37
1.38 /* Otherwise, preserve the attribute as retrieved. */
1.39
1.40 - return attr;
1.41 + return 0;
1.42 +}
1.43 +
1.44 +__attr __test_context(__ref context, __attr attr)
1.45 +{
1.46 + /* Update the context or return the unchanged attribute. */
1.47 +
1.48 + if (__test_context_update(context, attr))
1.49 + return __update_context(context, attr);
1.50 + else
1.51 + return attr;
1.52 }
1.53
1.54 __attr __update_context(__ref context, __attr attr)