1.1 --- a/templates/native/common.c Sat Nov 06 01:05:42 2021 +0100
1.2 +++ b/templates/native/common.c Sat Nov 06 17:06:01 2021 +0100
1.3 @@ -31,7 +31,7 @@
1.4 /* Create a new int and set the trailing data. */
1.5 __attr attr = __NEWINSTANCEIM(__builtins___int_int);
1.6 __set_trailing_data(attr, __builtins___int_int, n);
1.7 - return attr;
1.8 + return __TO_MUTABLE(attr);
1.9 }
1.10
1.11 __attr __new_str(char *s, __int size)
1.12 @@ -57,7 +57,7 @@
1.13 /* Create a new float and set the trailing data. */
1.14 __attr attr = __NEWINSTANCEIM(__builtins___float_float);
1.15 __set_trailing_data(attr, __builtins___float_float, n);
1.16 - return attr;
1.17 + return __TO_MUTABLE(attr);
1.18 }
1.19
1.20 __fragment *__fragment_append(__fragment *data, __attr value)
2.1 --- a/templates/ops.c Sat Nov 06 01:05:42 2021 +0100
2.2 +++ b/templates/ops.c Sat Nov 06 17:06:01 2021 +0100
2.3 @@ -1,6 +1,6 @@
2.4 /* Common operations.
2.5
2.6 -Copyright (C) 2015, 2016, 2017, 2018, 2021 Paul Boddie <paul@boddie.org.uk>
2.7 +Copyright (C) 2015-2018, 2021 Paul Boddie <paul@boddie.org.uk>
2.8
2.9 This program is free software; you can redistribute it and/or modify it under
2.10 the terms of the GNU General Public License as published by the Free Software
2.11 @@ -27,7 +27,7 @@
2.12
2.13 __ref __VALUE(__attr attr)
2.14 {
2.15 - return attr.value;
2.16 + return (__ref) (attr.rawvalue & (~__TAG_MASK));
2.17 }
2.18
2.19 /* Basic structure tests. */
3.1 --- a/templates/ops.h Sat Nov 06 01:05:42 2021 +0100
3.2 +++ b/templates/ops.h Sat Nov 06 17:06:01 2021 +0100
3.3 @@ -1,6 +1,6 @@
3.4 /* Common operations.
3.5
3.6 -Copyright (C) 2015, 2016, 2017, 2018 Paul Boddie <paul@boddie.org.uk>
3.7 +Copyright (C) 2015-2018, 2021 Paul Boddie <paul@boddie.org.uk>
3.8
3.9 This program is free software; you can redistribute it and/or modify it under
3.10 the terms of the GNU General Public License as published by the Free Software
3.11 @@ -136,7 +136,7 @@
3.12
3.13 __ref __ISFUNC(__ref obj);
3.14
3.15 -#define __ISNULL(__ATTR) (!__ATTR.value)
3.16 +#define __ISNULL(__ATTR) (!(__ATTR.rawvalue & (~__TAG_MASK)))
3.17
3.18 /* Attribute codes and positions for type objects. */
3.19
4.1 --- a/templates/progops.c Sat Nov 06 01:05:42 2021 +0100
4.2 +++ b/templates/progops.c Sat Nov 06 17:06:01 2021 +0100
4.3 @@ -332,7 +332,7 @@
4.4 /* Test against True and False explicitly. If necessary, invoke the bool
4.5 function with the object and test against True. */
4.6
4.7 - value = attr.value;
4.8 + value = __VALUE(attr);
4.9
4.10 return value == (__ref) &__predefined___builtins___boolean_True ? 1 :
4.11 value == (__ref) &__predefined___builtins___boolean_False ? 0 :
5.1 --- a/templates/progops.h Sat Nov 06 01:05:42 2021 +0100
5.2 +++ b/templates/progops.h Sat Nov 06 17:06:01 2021 +0100
5.3 @@ -90,8 +90,8 @@
5.4
5.5 /* Operations for accessing trailing data. */
5.6
5.7 -#define __get_trailing_data(ATTR, TYPE) (((__OBJTYPE(TYPE) *) ((ATTR).value))->trailing)
5.8 -#define __set_trailing_data(ATTR, TYPE, VALUE) ((__OBJTYPE(TYPE) *) ((ATTR).value))->trailing = VALUE;
5.9 +#define __get_trailing_data(ATTR, TYPE) (((__OBJTYPE(TYPE) *) (__VALUE(ATTR)))->trailing)
5.10 +#define __set_trailing_data(ATTR, TYPE, VALUE) ((__OBJTYPE(TYPE) *) (__VALUE(ATTR)))->trailing = VALUE;
5.11
5.12 /* Specialised trailing data functions. */
5.13
6.1 --- a/templates/types.h Sat Nov 06 01:05:42 2021 +0100
6.2 +++ b/templates/types.h Sat Nov 06 17:06:01 2021 +0100
6.3 @@ -130,15 +130,12 @@
6.4
6.5 /* Attribute interpretation. */
6.6
6.7 -#define __NUM_TAG_BITS 2
6.8 -#define __TAG_INT 0b01
6.9 -#define __TAG_FLOAT 0b10
6.10 -#define __TAG_MASK 0b11
6.11 +#define __NUM_TAG_BITS 1
6.12 +#define __TAG_MUTABLE 0b1
6.13 +#define __TAG_MASK 0b1
6.14
6.15 -#if 0
6.16 -#define __INTEGER(ATTR) (((ATTR).rawvalue & __TAG_MASK) == __TAG_INT)
6.17 -#define __FLOAT(ATTR) (((ATTR).rawvalue & __TAG_MASK) == __TAG_FLOAT)
6.18 -#endif
6.19 +#define __MUTABLE(ATTR) (((ATTR).rawvalue & __TAG_MASK) == __TAG_MUTABLE)
6.20 +#define __TO_MUTABLE(ATTR) ((__attr) (((ATTR).rawvalue & (~__TAG_MASK)) | __TAG_MUTABLE))
6.21
6.22 /* Attribute value setting. */
6.23