1.1 --- a/templates/native/introspection.c Fri Jan 20 23:59:15 2017 +0100
1.2 +++ b/templates/native/introspection.c Sat Jan 21 00:01:25 2017 +0100
1.3 @@ -33,11 +33,28 @@
1.4 __attr * const _default = &__args[3];
1.5 /* name.__data__ interpreted as string */
1.6 __attr key = __load_via_object(name->value, __pos___key__);
1.7 + __attr out;
1.8
1.9 if ((key.code == 0) && (key.pos == 0))
1.10 return *_default;
1.11 - else
1.12 - return __check_and_load_via_any(obj->value, key.pos, key.code);
1.13 +
1.14 + /* Attempt to get the attribute from the object. */
1.15 +
1.16 + out = __check_and_load_via_object_null(obj->value, key.pos, key.code);
1.17 + if (out.value == 0)
1.18 + {
1.19 + /* Inspect the object's class if this failed. */
1.20 +
1.21 + out = __check_and_load_via_class(obj->value, key.pos, key.code);
1.22 + if (out.value == 0)
1.23 + return *_default;
1.24 +
1.25 + /* Update the context to the object if it is a method. */
1.26 +
1.27 + return __replace_context(obj->value, out);
1.28 + }
1.29 +
1.30 + return out;
1.31 }
1.32
1.33 static int __issubclass(__ref obj, __attr cls)
2.1 --- a/templates/ops.c Fri Jan 20 23:59:15 2017 +0100
2.2 +++ b/templates/ops.c Sat Jan 21 00:01:25 2017 +0100
2.3 @@ -122,7 +122,7 @@
2.4
2.5 /* Attribute testing and retrieval operations. */
2.6
2.7 -static __attr __check_and_load_via_object_null(__ref obj, int pos, int code)
2.8 +__attr __check_and_load_via_object_null(__ref obj, int pos, int code)
2.9 {
2.10 if (__HASATTR(obj, pos, code))
2.11 return __load_via_object(obj, pos);
3.1 --- a/templates/ops.h Fri Jan 20 23:59:15 2017 +0100
3.2 +++ b/templates/ops.h Sat Jan 21 00:01:25 2017 +0100
3.3 @@ -57,6 +57,7 @@
3.4
3.5 __attr __check_and_load_via_class(__ref obj, int pos, int code);
3.6 __attr __check_and_load_via_object(__ref obj, int pos, int code);
3.7 +__attr __check_and_load_via_object_null(__ref obj, int pos, int code);
3.8 __attr __check_and_load_via_any(__ref obj, int pos, int code);
3.9
3.10 /* Attribute testing and storage operations. */