1.1 --- a/templates/native/list.c Mon Mar 06 22:29:36 2017 +0100
1.2 +++ b/templates/native/list.c Tue Mar 07 00:28:18 2017 +0100
1.3 @@ -27,51 +27,44 @@
1.4
1.5 /* List operations. */
1.6
1.7 -__attr __fn_native_list_list_init(__attr __args[])
1.8 +__attr __fn_native_list_list_init(__attr __self, __attr size)
1.9 {
1.10 - __attr * const size = &__args[1];
1.11 - /* size.__data__ interpreted as int */
1.12 - unsigned int n = __load_via_object(size->value, __data__).intvalue;
1.13 + /* size interpreted as int */
1.14 + unsigned int n = __load_via_object(size.value, __data__).intvalue;
1.15 __attr attr = {.seqvalue=__new_fragment(n)};
1.16
1.17 /* Return the __data__ attribute. */
1.18 return attr;
1.19 }
1.20
1.21 -__attr __fn_native_list_list_setsize(__attr __args[])
1.22 +__attr __fn_native_list_list_setsize(__attr __self, __attr _data, __attr size)
1.23 {
1.24 - __attr * const _data = &__args[1];
1.25 - __attr * const size = &__args[2];
1.26 - /* _data interpreted as list */
1.27 - __fragment *data = _data->seqvalue;
1.28 - /* size.__data__ interpreted as int */
1.29 - unsigned int n = __load_via_object(size->value, __data__).intvalue;
1.30 + /* _data interpreted as list.__data__ */
1.31 + __fragment *data = _data.seqvalue;
1.32 + /* size interpreted as int */
1.33 + unsigned int n = __load_via_object(size.value, __data__).intvalue;
1.34
1.35 data->size = n;
1.36 return __builtins___none_None;
1.37 }
1.38
1.39 -__attr __fn_native_list_list_append(__attr __args[])
1.40 +__attr __fn_native_list_list_append(__attr __self, __attr self, __attr value)
1.41 {
1.42 - __attr * const self = &__args[1];
1.43 - __attr * const value = &__args[2];
1.44 - /* self.__data__ interpreted as list */
1.45 - __fragment *data = __load_via_object(self->value, __data__).seqvalue;
1.46 + /* self interpreted as list */
1.47 + __fragment *data = __load_via_object(self.value, __data__).seqvalue;
1.48 __fragment *newdata = __fragment_append(data, value);
1.49
1.50 /* Replace the __data__ attribute if appropriate. */
1.51 if (newdata != data)
1.52 - __store_via_object(self->value, __data__, ((__attr) {.seqvalue=newdata}));
1.53 + __store_via_object(self.value, __data__, ((__attr) {.seqvalue=newdata}));
1.54 return __builtins___none_None;
1.55 }
1.56
1.57 -__attr __fn_native_list_list_concat(__attr __args[])
1.58 +__attr __fn_native_list_list_concat(__attr __self, __attr self, __attr other)
1.59 {
1.60 - __attr * const self = &__args[1];
1.61 - __attr * const other = &__args[2];
1.62 - /* self.__data__, other interpreted as list */
1.63 - __fragment *data = __load_via_object(self->value, __data__).seqvalue;
1.64 - __fragment *other_data = other->seqvalue;
1.65 + /* self, interpreted as list, other interpreted as list.__data__ */
1.66 + __fragment *data = __load_via_object(self.value, __data__).seqvalue;
1.67 + __fragment *other_data = other.seqvalue;
1.68 __fragment *newdata = data;
1.69 unsigned int size = data->size, capacity = data->capacity;
1.70 unsigned int other_size = other_data->size;
1.71 @@ -91,51 +84,43 @@
1.72
1.73 /* Replace the __data__ attribute if appropriate. */
1.74 if (newdata != data)
1.75 - __store_via_object(self->value, __data__, ((__attr) {.seqvalue=newdata}));
1.76 + __store_via_object(self.value, __data__, ((__attr) {.seqvalue=newdata}));
1.77 return __builtins___none_None;
1.78 }
1.79
1.80 -__attr __fn_native_list_list_len(__attr __args[])
1.81 +__attr __fn_native_list_list_len(__attr self, __attr _data)
1.82 {
1.83 - __attr * const _data = &__args[1];
1.84 - /* _data interpreted as fragment */
1.85 - unsigned int size = _data->seqvalue->size;
1.86 + /* _data interpreted as list.__data__ */
1.87 + unsigned int size = _data.seqvalue->size;
1.88
1.89 /* Return the new integer. */
1.90 return __new_int(size);
1.91 }
1.92
1.93 -__attr __fn_native_list_list_nonempty(__attr __args[])
1.94 +__attr __fn_native_list_list_nonempty(__attr __self, __attr _data)
1.95 {
1.96 - __attr * const _data = &__args[1];
1.97 -
1.98 - return _data->seqvalue->size ? __builtins___boolean_True : __builtins___boolean_False;
1.99 + return _data.seqvalue->size ? __builtins___boolean_True : __builtins___boolean_False;
1.100 }
1.101
1.102 -__attr __fn_native_list_list_element(__attr __args[])
1.103 +__attr __fn_native_list_list_element(__attr __self, __attr _data, __attr index)
1.104 {
1.105 - __attr * const _data = &__args[1];
1.106 - __attr * const index = &__args[2];
1.107 - /* _data interpreted as fragment */
1.108 - __attr *elements = _data->seqvalue->attrs;
1.109 - /* index.__data__ interpreted as int */
1.110 - int i = __load_via_object(index->value, __data__).intvalue;
1.111 + /* _data interpreted as list.__data__ */
1.112 + __attr *elements = _data.seqvalue->attrs;
1.113 + /* index interpreted as int */
1.114 + int i = __load_via_object(index.value, __data__).intvalue;
1.115
1.116 return elements[i];
1.117 }
1.118
1.119 -__attr __fn_native_list_list_setelement(__attr __args[])
1.120 +__attr __fn_native_list_list_setelement(__attr __self, __attr _data, __attr index, __attr value)
1.121 {
1.122 - __attr * const _data = &__args[1];
1.123 - __attr * const index = &__args[2];
1.124 - __attr * const value = &__args[3];
1.125 - /* _data interpreted as fragment */
1.126 - __attr *elements = _data->seqvalue->attrs;
1.127 - /* index.__data__ interpreted as int */
1.128 - int i = __load_via_object(index->value, __data__).intvalue;
1.129 + /* _data interpreted as list.__data__ */
1.130 + __attr *elements = _data.seqvalue->attrs;
1.131 + /* index interpreted as int */
1.132 + int i = __load_via_object(index.value, __data__).intvalue;
1.133
1.134 /* Set the element. */
1.135 - elements[i] = *value;
1.136 + elements[i] = value;
1.137 return __builtins___none_None;
1.138 }
1.139