1.1 --- a/templates/ops.c Sat Mar 04 23:48:19 2017 +0100
1.2 +++ b/templates/ops.c Sun Mar 05 18:08:19 2017 +0100
1.3 @@ -23,6 +23,18 @@
1.4 #include "progconsts.h"
1.5 #include "progtypes.h"
1.6
1.7 +/* Basic structure tests. */
1.8 +
1.9 +static inline int __WITHIN(__ref obj, int pos)
1.10 +{
1.11 + return pos < obj->table->size;
1.12 +}
1.13 +
1.14 +static inline int __HASATTR(__ref obj, int pos, int code)
1.15 +{
1.16 + return __WITHIN(obj, pos) && (obj->table->attrs[pos] == code);
1.17 +}
1.18 +
1.19 /* Direct access and manipulation of static objects. */
1.20
1.21 __attr __load_static_ignore(__ref obj)
1.22 @@ -83,6 +95,16 @@
1.23 return obj->pos == __INSTANCEPOS;
1.24 }
1.25
1.26 +int __is_subclass(__ref obj, __attr cls)
1.27 +{
1.28 + return __HASATTR(obj, __TYPEPOS(cls.value), __TYPECODE(cls.value));
1.29 +}
1.30 +
1.31 +int __is_instance_subclass(__ref obj, __attr cls)
1.32 +{
1.33 + return __is_instance(obj) && __HASATTR(__get_class(obj), __TYPEPOS(cls.value), __TYPECODE(cls.value));
1.34 +}
1.35 +
1.36 int __is_type_instance(__ref obj)
1.37 {
1.38 return __HASATTR(__get_class(obj), __TYPE_CLASS_POS, __TYPE_CLASS_CODE);
1.39 @@ -317,18 +339,6 @@
1.40 return __unbound_method;
1.41 }
1.42
1.43 -/* Basic structure tests. */
1.44 -
1.45 -int __WITHIN(__ref obj, int pos)
1.46 -{
1.47 - return pos < obj->table->size;
1.48 -}
1.49 -
1.50 -int __HASATTR(__ref obj, int pos, int code)
1.51 -{
1.52 - return __WITHIN(obj, pos) && (obj->table->attrs[pos] == code);
1.53 -}
1.54 -
1.55 /* Parameter position operations. */
1.56
1.57 int __HASPARAM(const __ptable *ptable, int ppos, int pcode)