1.1 --- a/templates/native/str.c Mon Mar 06 22:29:36 2017 +0100
1.2 +++ b/templates/native/str.c Tue Mar 07 00:28:18 2017 +0100
1.3 @@ -28,16 +28,13 @@
1.4
1.5 /* String operations. */
1.6
1.7 -__attr __fn_native_str_str_add(__attr __args[])
1.8 +__attr __fn_native_str_str_add(__attr __self, __attr _data, __attr other, __attr _size, __attr othersize)
1.9 {
1.10 - __attr * const _data = &__args[1];
1.11 - __attr * const other = &__args[2];
1.12 - __attr * const _size = &__args[3];
1.13 - __attr * const othersize = &__args[4];
1.14 - /* _data, other interpreted as string */
1.15 - char *s = _data->strvalue;
1.16 - char *o = other->strvalue;
1.17 - int ss = _size->intvalue, os = othersize->intvalue;
1.18 + /* _data, other interpreted as string.__data__ */
1.19 + char *s = _data.strvalue;
1.20 + char *o = other.strvalue;
1.21 + /* _size, othersize interpreted as int.__data__ */
1.22 + int ss = _size.intvalue, os = othersize.intvalue;
1.23 int n = ss + os;
1.24 char *r = (char *) __ALLOCATE(n + 1, sizeof(char));
1.25
1.26 @@ -48,76 +45,64 @@
1.27 return __new_str(r, n);
1.28 }
1.29
1.30 -__attr __fn_native_str_str_chr(__attr __args[])
1.31 +__attr __fn_native_str_str_chr(__attr __self, __attr _data)
1.32 {
1.33 - __attr * const _data = &__args[1];
1.34 - /* _data interpreted as int */
1.35 - int n = _data->intvalue;
1.36 + /* _data interpreted as int.__data__ */
1.37 + int n = _data.intvalue;
1.38 char *s = (char *) __ALLOCATE(2, sizeof(char));
1.39
1.40 s[0] = (char) n;
1.41 return __new_str(s, 1);
1.42 }
1.43
1.44 -__attr __fn_native_str_str_lt(__attr __args[])
1.45 +__attr __fn_native_str_str_lt(__attr __self, __attr _data, __attr other)
1.46 {
1.47 - __attr * const _data = &__args[1];
1.48 - __attr * const other = &__args[2];
1.49 - /* _data, other interpreted as string */
1.50 - char *s = _data->strvalue;
1.51 - char *o = other->strvalue;
1.52 + /* _data, other interpreted as string.__data__ */
1.53 + char *s = _data.strvalue;
1.54 + char *o = other.strvalue;
1.55
1.56 /* NOTE: Using simple byte-level string operations. */
1.57 return strcmp(s, o) < 0 ? __builtins___boolean_True : __builtins___boolean_False;
1.58 }
1.59
1.60 -__attr __fn_native_str_str_gt(__attr __args[])
1.61 +__attr __fn_native_str_str_gt(__attr __self, __attr _data, __attr other)
1.62 {
1.63 - __attr * const _data = &__args[1];
1.64 - __attr * const other = &__args[2];
1.65 - /* _data, other interpreted as string */
1.66 - char *s = _data->strvalue;
1.67 - char *o = other->strvalue;
1.68 + /* _data, other interpreted as string.__data__ */
1.69 + char *s = _data.strvalue;
1.70 + char *o = other.strvalue;
1.71
1.72 /* NOTE: Using simple byte-level string operations. */
1.73 return strcmp(s, o) > 0 ? __builtins___boolean_True : __builtins___boolean_False;
1.74 }
1.75
1.76 -__attr __fn_native_str_str_eq(__attr __args[])
1.77 +__attr __fn_native_str_str_eq(__attr __self, __attr _data, __attr other)
1.78 {
1.79 - __attr * const _data = &__args[1];
1.80 - __attr * const other = &__args[2];
1.81 - /* _data, other interpreted as string */
1.82 - char *s = _data->strvalue;
1.83 - char *o = other->strvalue;
1.84 + /* _data, other interpreted as string.__data__ */
1.85 + char *s = _data.strvalue;
1.86 + char *o = other.strvalue;
1.87
1.88 /* NOTE: Using simple byte-level string operations. */
1.89 return strcmp(s, o) == 0 ? __builtins___boolean_True : __builtins___boolean_False;
1.90 }
1.91
1.92 -__attr __fn_native_str_str_ord(__attr __args[])
1.93 +__attr __fn_native_str_str_ord(__attr __self, __attr _data)
1.94 {
1.95 - __attr * const _data = &__args[1];
1.96 - /* _data interpreted as string */
1.97 - char *s = _data->strvalue;
1.98 + /* _data interpreted as string.__data__ */
1.99 + char *s = _data.strvalue;
1.100
1.101 return __new_int((unsigned int) s[0]);
1.102 }
1.103
1.104 -__attr __fn_native_str_str_substr(__attr __args[])
1.105 +__attr __fn_native_str_str_substr(__attr __self, __attr _data, __attr start, __attr end, __attr step)
1.106 {
1.107 - __attr * const _data = &__args[1];
1.108 - __attr * const start = &__args[2];
1.109 - __attr * const end = &__args[3];
1.110 - __attr * const step = &__args[4];
1.111 - /* _data interpreted as string */
1.112 - char *s = _data->strvalue, *sub;
1.113 - /* start.__data__ interpreted as int */
1.114 - int istart = __load_via_object(start->value, __data__).intvalue;
1.115 - /* end.__data__ interpreted as int */
1.116 - int iend = __load_via_object(end->value, __data__).intvalue;
1.117 - /* step.__data__ interpreted as int */
1.118 - int istep = __load_via_object(step->value, __data__).intvalue;
1.119 + /* _data interpreted as string.__data__ */
1.120 + char *s = _data.strvalue, *sub;
1.121 + /* start interpreted as int */
1.122 + int istart = __load_via_object(start.value, __data__).intvalue;
1.123 + /* end interpreted as int */
1.124 + int iend = __load_via_object(end.value, __data__).intvalue;
1.125 + /* step interpreted as int */
1.126 + int istep = __load_via_object(step.value, __data__).intvalue;
1.127
1.128 /* Calculate the size of the substring. */
1.129 size_t resultsize = ((iend - istart - (istep > 0 ? 1 : -1)) / istep) + 1;