1.1 --- a/templates/native/buffer.c Sun Feb 26 21:47:56 2017 +0100
1.2 +++ b/templates/native/buffer.c Mon Feb 27 00:55:52 2017 +0100
1.3 @@ -37,7 +37,7 @@
1.4
1.5 /* Calculate the size of the string. */
1.6 for (i = 0; i < data->size; i++)
1.7 - size += __load_via_object(data->attrs[i].value, __pos___size__).intvalue;
1.8 + size += __load_via_object(data->attrs[i].value, __ATTRPOS(__size__)).intvalue;
1.9
1.10 /* Reserve space for a new string. */
1.11 s = (char *) __ALLOCATE(size + 1, sizeof(char));
1.12 @@ -45,8 +45,8 @@
1.13 /* Build a single string from the buffer contents. */
1.14 for (i = 0, j = 0; i < data->size; i++)
1.15 {
1.16 - o = __load_via_object(data->attrs[i].value, __pos___data__);
1.17 - n = __load_via_object(data->attrs[i].value, __pos___size__).intvalue;
1.18 + o = __load_via_object(data->attrs[i].value, __ATTRPOS(__data__));
1.19 + n = __load_via_object(data->attrs[i].value, __ATTRPOS(__size__)).intvalue;
1.20 memcpy(s + j, o.strvalue, n); /* does not null terminate but final byte should be zero */
1.21 j += n;
1.22 }
2.1 --- a/templates/native/common.c Sun Feb 26 21:47:56 2017 +0100
2.2 +++ b/templates/native/common.c Mon Feb 27 00:55:52 2017 +0100
2.3 @@ -30,7 +30,7 @@
2.4 {
2.5 /* Create a new integer and mutate the __data__ attribute. */
2.6 __attr attr = __NEWINSTANCE(__builtins___int_int);
2.7 - attr.value->attrs[__pos___data__].intvalue = i;
2.8 + attr.value->attrs[__ATTRPOS(__data__)].intvalue = i;
2.9 return attr;
2.10 }
2.11
2.12 @@ -38,9 +38,9 @@
2.13 {
2.14 /* Create a new string and mutate the __data__, __size__ and __key__ attributes. */
2.15 __attr attr = __NEWINSTANCE(__builtins___str_string);
2.16 - attr.value->attrs[__pos___data__].strvalue = s;
2.17 - attr.value->attrs[__pos___size__].intvalue = size;
2.18 - attr.value->attrs[__pos___key__] = __NULL;
2.19 + attr.value->attrs[__ATTRPOS(__data__)].strvalue = s;
2.20 + attr.value->attrs[__ATTRPOS(__size__)].intvalue = size;
2.21 + attr.value->attrs[__ATTRPOS(__key__)] = __NULL;
2.22 return attr;
2.23 }
2.24
2.25 @@ -48,7 +48,7 @@
2.26 {
2.27 /* Create a new list and mutate the __data__ attribute. */
2.28 __attr attr = __NEWINSTANCE(__builtins___list_list);
2.29 - attr.value->attrs[__pos___data__].seqvalue = f;
2.30 + attr.value->attrs[__ATTRPOS(__data__)].seqvalue = f;
2.31 return attr;
2.32 }
2.33
3.1 --- a/templates/native/iconv.c Sun Feb 26 21:47:56 2017 +0100
3.2 +++ b/templates/native/iconv.c Mon Feb 27 00:55:52 2017 +0100
3.3 @@ -57,13 +57,13 @@
3.4 /* cd interpreted as iconv_t */
3.5 iconv_t c = (iconv_t) cd->datavalue;
3.6 /* state.__data__ interpreted as list */
3.7 - __fragment *f = __load_via_object(state->value, __pos___data__).seqvalue;
3.8 + __fragment *f = __load_via_object(state->value, __ATTRPOS(__data__)).seqvalue;
3.9
3.10 /* Obtain the string, start position, and remaining bytes from the state. */
3.11
3.12 - char *inbuf = __load_via_object(f->attrs[0].value, __pos___data__).strvalue;
3.13 - int start = __load_via_object(f->attrs[1].value, __pos___data__).intvalue;
3.14 - int remaining = __load_via_object(f->attrs[2].value, __pos___data__).intvalue;
3.15 + char *inbuf = __load_via_object(f->attrs[0].value, __ATTRPOS(__data__)).strvalue;
3.16 + int start = __load_via_object(f->attrs[1].value, __ATTRPOS(__data__)).intvalue;
3.17 + int remaining = __load_via_object(f->attrs[2].value, __ATTRPOS(__data__)).intvalue;
3.18
3.19 /* Allocate a string for the output buffer using the remaining input size
3.20 as a guide. */
3.21 @@ -142,9 +142,9 @@
3.22 __attr * const tocode = &__args[1];
3.23 __attr * const fromcode = &__args[2];
3.24 /* tocode.__data__ interpreted as string */
3.25 - char *t = __load_via_object(tocode->value, __pos___data__).strvalue;
3.26 + char *t = __load_via_object(tocode->value, __ATTRPOS(__data__)).strvalue;
3.27 /* fromcode.__data__ interpreted as string */
3.28 - char *f = __load_via_object(fromcode->value, __pos___data__).strvalue;
3.29 + char *f = __load_via_object(fromcode->value, __ATTRPOS(__data__)).strvalue;
3.30 iconv_t result;
3.31 __attr attr;
3.32
4.1 --- a/templates/native/introspection.c Sun Feb 26 21:47:56 2017 +0100
4.2 +++ b/templates/native/introspection.c Mon Feb 27 00:55:52 2017 +0100
4.3 @@ -32,7 +32,7 @@
4.4 __attr * const name = &__args[2];
4.5 __attr * const _default = &__args[3];
4.6 /* name.__data__ interpreted as string */
4.7 - __attr key = __load_via_object(name->value, __pos___key__);
4.8 + __attr key = __load_via_object(name->value, __ATTRPOS(__key__));
4.9 __attr out;
4.10
4.11 if ((key.code == 0) && (key.pos == 0))
5.1 --- a/templates/native/io.c Sun Feb 26 21:47:56 2017 +0100
5.2 +++ b/templates/native/io.c Mon Feb 27 00:55:52 2017 +0100
5.3 @@ -62,9 +62,9 @@
5.4 __attr * const filename = &__args[1];
5.5 __attr * const mode = &__args[2];
5.6 /* filename.__data__ interpreted as string */
5.7 - char *fn = __load_via_object(filename->value, __pos___data__).strvalue;
5.8 + char *fn = __load_via_object(filename->value, __ATTRPOS(__data__)).strvalue;
5.9 /* mode.__data__ interpreted as string */
5.10 - char *s = __load_via_object(mode->value, __pos___data__).strvalue;
5.11 + char *s = __load_via_object(mode->value, __ATTRPOS(__data__)).strvalue;
5.12 FILE *f;
5.13 __attr attr;
5.14
5.15 @@ -94,9 +94,9 @@
5.16 __attr * const fd = &__args[1];
5.17 __attr * const mode = &__args[2];
5.18 /* fd.__data__ interpreted as int */
5.19 - int i = __load_via_object(fd->value, __pos___data__).intvalue;
5.20 + int i = __load_via_object(fd->value, __ATTRPOS(__data__)).intvalue;
5.21 /* mode.__data__ interpreted as string */
5.22 - char *s = __load_via_object(mode->value, __pos___data__).strvalue;
5.23 + char *s = __load_via_object(mode->value, __ATTRPOS(__data__)).strvalue;
5.24 FILE *f;
5.25 __attr attr;
5.26
5.27 @@ -128,7 +128,7 @@
5.28 /* fp interpreted as FILE reference */
5.29 FILE *f = (FILE *) fp->datavalue;
5.30 /* size.__data__ interpreted as int */
5.31 - int to_read = __load_via_object(size->value, __pos___data__).intvalue;
5.32 + int to_read = __load_via_object(size->value, __ATTRPOS(__data__)).intvalue;
5.33 char buf[to_read];
5.34 size_t have_read;
5.35 int error;
5.36 @@ -158,9 +158,9 @@
5.37 /* fp interpreted as FILE reference */
5.38 FILE *f = (FILE *) fp->datavalue;
5.39 /* str.__data__ interpreted as string */
5.40 - char *s = __load_via_object(str->value, __pos___data__).strvalue;
5.41 + char *s = __load_via_object(str->value, __ATTRPOS(__data__)).strvalue;
5.42 /* str.__size__ interpreted as int */
5.43 - int to_write = __load_via_object(str->value, __pos___size__).intvalue;
5.44 + int to_write = __load_via_object(str->value, __ATTRPOS(__size__)).intvalue;
5.45 size_t have_written = fwrite(s, sizeof(char), to_write, f);
5.46 int error;
5.47
5.48 @@ -179,7 +179,7 @@
5.49 {
5.50 __attr * const fd = &__args[1];
5.51 /* fd.__data__ interpreted as int */
5.52 - int i = __load_via_object(fd->value, __pos___data__).intvalue;
5.53 + int i = __load_via_object(fd->value, __ATTRPOS(__data__)).intvalue;
5.54
5.55 errno = 0;
5.56 if (close(i) == -1)
5.57 @@ -193,9 +193,9 @@
5.58 __attr * const fd = &__args[1];
5.59 __attr * const n = &__args[2];
5.60 /* fd.__data__ interpreted as int */
5.61 - int i = __load_via_object(fd->value, __pos___data__).intvalue;
5.62 + int i = __load_via_object(fd->value, __ATTRPOS(__data__)).intvalue;
5.63 /* n.__data__ interpreted as int */
5.64 - int to_read = __load_via_object(n->value, __pos___data__).intvalue;
5.65 + int to_read = __load_via_object(n->value, __ATTRPOS(__data__)).intvalue;
5.66 char buf[to_read];
5.67 ssize_t have_read;
5.68 char *s;
5.69 @@ -218,11 +218,11 @@
5.70 __attr * const fd = &__args[1];
5.71 __attr * const str = &__args[2];
5.72 /* fd.__data__ interpreted as int */
5.73 - int i = __load_via_object(fd->value, __pos___data__).intvalue;
5.74 + int i = __load_via_object(fd->value, __ATTRPOS(__data__)).intvalue;
5.75 /* str.__data__ interpreted as string */
5.76 - char *s = __load_via_object(str->value, __pos___data__).strvalue;
5.77 + char *s = __load_via_object(str->value, __ATTRPOS(__data__)).strvalue;
5.78 /* str.__size__ interpreted as int */
5.79 - int size = __load_via_object(str->value, __pos___size__).intvalue;
5.80 + int size = __load_via_object(str->value, __ATTRPOS(__size__)).intvalue;
5.81 ssize_t have_written;
5.82
5.83 errno = 0;
6.1 --- a/templates/native/list.c Sun Feb 26 21:47:56 2017 +0100
6.2 +++ b/templates/native/list.c Mon Feb 27 00:55:52 2017 +0100
6.3 @@ -1,6 +1,6 @@
6.4 /* Native functions for list operations.
6.5
6.6 -Copyright (C) 2016 Paul Boddie <paul@boddie.org.uk>
6.7 +Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk>
6.8
6.9 This program is free software; you can redistribute it and/or modify it under
6.10 the terms of the GNU General Public License as published by the Free Software
6.11 @@ -31,7 +31,7 @@
6.12 {
6.13 __attr * const size = &__args[1];
6.14 /* size.__data__ interpreted as int */
6.15 - unsigned int n = __load_via_object(size->value, __pos___data__).intvalue;
6.16 + unsigned int n = __load_via_object(size->value, __ATTRPOS(__data__)).intvalue;
6.17 __attr attr = {.seqvalue=__new_fragment(n)};
6.18
6.19 /* Return the __data__ attribute. */
6.20 @@ -45,7 +45,7 @@
6.21 /* _data interpreted as list */
6.22 __fragment *data = _data->seqvalue;
6.23 /* size.__data__ interpreted as int */
6.24 - unsigned int n = __load_via_object(size->value, __pos___data__).intvalue;
6.25 + unsigned int n = __load_via_object(size->value, __ATTRPOS(__data__)).intvalue;
6.26
6.27 data->size = n;
6.28 return __builtins___none_None;
6.29 @@ -56,12 +56,12 @@
6.30 __attr * const self = &__args[1];
6.31 __attr * const value = &__args[2];
6.32 /* self.__data__ interpreted as list */
6.33 - __fragment *data = __load_via_object(self->value, __pos___data__).seqvalue;
6.34 + __fragment *data = __load_via_object(self->value, __ATTRPOS(__data__)).seqvalue;
6.35 __fragment *newdata = __fragment_append(data, value);
6.36
6.37 /* Replace the __data__ attribute if appropriate. */
6.38 if (newdata != data)
6.39 - __store_via_object(self->value, __pos___data__, ((__attr) {.seqvalue=newdata}));
6.40 + __store_via_object(self->value, __ATTRPOS(__data__), ((__attr) {.seqvalue=newdata}));
6.41 return __builtins___none_None;
6.42 }
6.43
6.44 @@ -70,7 +70,7 @@
6.45 __attr * const self = &__args[1];
6.46 __attr * const other = &__args[2];
6.47 /* self.__data__, other interpreted as list */
6.48 - __fragment *data = __load_via_object(self->value, __pos___data__).seqvalue;
6.49 + __fragment *data = __load_via_object(self->value, __ATTRPOS(__data__)).seqvalue;
6.50 __fragment *other_data = other->seqvalue;
6.51 __fragment *newdata = data;
6.52 unsigned int size = data->size, capacity = data->capacity;
6.53 @@ -92,7 +92,7 @@
6.54
6.55 /* Replace the __data__ attribute if appropriate. */
6.56 if (newdata != data)
6.57 - __store_via_object(self->value, __pos___data__, ((__attr) {.seqvalue=newdata}));
6.58 + __store_via_object(self->value, __ATTRPOS(__data__), ((__attr) {.seqvalue=newdata}));
6.59 return __builtins___none_None;
6.60 }
6.61
6.62 @@ -120,7 +120,7 @@
6.63 /* _data interpreted as fragment */
6.64 __attr *elements = _data->seqvalue->attrs;
6.65 /* index.__data__ interpreted as int */
6.66 - int i = __load_via_object(index->value, __pos___data__).intvalue;
6.67 + int i = __load_via_object(index->value, __ATTRPOS(__data__)).intvalue;
6.68
6.69 return elements[i];
6.70 }
6.71 @@ -133,7 +133,7 @@
6.72 /* _data interpreted as fragment */
6.73 __attr *elements = _data->seqvalue->attrs;
6.74 /* index.__data__ interpreted as int */
6.75 - int i = __load_via_object(index->value, __pos___data__).intvalue;
6.76 + int i = __load_via_object(index->value, __ATTRPOS(__data__)).intvalue;
6.77
6.78 /* Set the element. */
6.79 elements[i] = *value;
7.1 --- a/templates/native/locale.c Sun Feb 26 21:47:56 2017 +0100
7.2 +++ b/templates/native/locale.c Mon Feb 27 00:55:52 2017 +0100
7.3 @@ -1,6 +1,6 @@
7.4 /* Native functions for locale handling.
7.5
7.6 -Copyright (C) 2016 Paul Boddie <paul@boddie.org.uk>
7.7 +Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk>
7.8
7.9 This program is free software; you can redistribute it and/or modify it under
7.10 the terms of the GNU General Public License as published by the Free Software
7.11 @@ -33,7 +33,7 @@
7.12 {
7.13 __attr * const category = &__args[1];
7.14 /* category.__data__ interpreted as int */
7.15 - int cat = __load_via_object(category->value, __pos___data__).intvalue;
7.16 + int cat = __load_via_object(category->value, __ATTRPOS(__data__)).intvalue;
7.17 char *result, *out;
7.18 size_t length;
7.19
7.20 @@ -54,9 +54,9 @@
7.21 __attr * const category = &__args[1];
7.22 __attr * const value = &__args[2];
7.23 /* category.__data__ interpreted as int */
7.24 - int cat = __load_via_object(category->value, __pos___data__).intvalue;
7.25 + int cat = __load_via_object(category->value, __ATTRPOS(__data__)).intvalue;
7.26 /* value.__data__ interpreted as string */
7.27 - char *s = __load_via_object(value->value, __pos___data__).strvalue;
7.28 + char *s = __load_via_object(value->value, __ATTRPOS(__data__)).strvalue;
7.29 char *result, *out;
7.30 size_t length;
7.31
8.1 --- a/templates/native/str.c Sun Feb 26 21:47:56 2017 +0100
8.2 +++ b/templates/native/str.c Mon Feb 27 00:55:52 2017 +0100
8.3 @@ -113,11 +113,11 @@
8.4 /* _data interpreted as string */
8.5 char *s = _data->strvalue, *sub;
8.6 /* start.__data__ interpreted as int */
8.7 - int istart = __load_via_object(start->value, __pos___data__).intvalue;
8.8 + int istart = __load_via_object(start->value, __ATTRPOS(__data__)).intvalue;
8.9 /* end.__data__ interpreted as int */
8.10 - int iend = __load_via_object(end->value, __pos___data__).intvalue;
8.11 + int iend = __load_via_object(end->value, __ATTRPOS(__data__)).intvalue;
8.12 /* step.__data__ interpreted as int */
8.13 - int istep = __load_via_object(step->value, __pos___data__).intvalue;
8.14 + int istep = __load_via_object(step->value, __ATTRPOS(__data__)).intvalue;
8.15
8.16 /* Calculate the size of the substring. */
8.17 size_t resultsize = ((iend - istart - (istep > 0 ? 1 : -1)) / istep) + 1;
9.1 --- a/templates/native/system.c Sun Feb 26 21:47:56 2017 +0100
9.2 +++ b/templates/native/system.c Mon Feb 27 00:55:52 2017 +0100
9.3 @@ -1,6 +1,6 @@
9.4 /* Native functions for system operations.
9.5
9.6 -Copyright (C) 2016 Paul Boddie <paul@boddie.org.uk>
9.7 +Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk>
9.8
9.9 This program is free software; you can redistribute it and/or modify it under
9.10 the terms of the GNU General Public License as published by the Free Software
9.11 @@ -31,7 +31,7 @@
9.12 {
9.13 __attr * const status = &__args[1];
9.14
9.15 - exit(__load_via_object(status->value, __pos___data__).intvalue);
9.16 + exit(__load_via_object(status->value, __ATTRPOS(__data__)).intvalue);
9.17 return __builtins___none_None;
9.18 }
9.19
10.1 --- a/templates/native/unicode.c Sun Feb 26 21:47:56 2017 +0100
10.2 +++ b/templates/native/unicode.c Mon Feb 27 00:55:52 2017 +0100
10.3 @@ -135,11 +135,11 @@
10.4 /* _size interpreted as int */
10.5 int ss = _size->intvalue;
10.6 /* start.__data__ interpreted as int */
10.7 - int istart = __load_via_object(start->value, __pos___data__).intvalue;
10.8 + int istart = __load_via_object(start->value, __ATTRPOS(__data__)).intvalue;
10.9 /* end.__data__ interpreted as int */
10.10 - int iend = __load_via_object(end->value, __pos___data__).intvalue;
10.11 + int iend = __load_via_object(end->value, __ATTRPOS(__data__)).intvalue;
10.12 /* step.__data__ interpreted as int */
10.13 - int istep = __load_via_object(step->value, __pos___data__).intvalue;
10.14 + int istep = __load_via_object(step->value, __ATTRPOS(__data__)).intvalue;
10.15
10.16 /* Calculate the number of characters. */
10.17 size_t nchar = ((iend - istart - (istep > 0 ? 1 : -1)) / istep) + 1;