1.1 --- a/templates/native/int.c Thu Nov 04 23:44:29 2021 +0100
1.2 +++ b/templates/native/int.c Tue Aug 29 01:46:23 2023 +0200
1.3 @@ -1,6 +1,6 @@
1.4 /* Native functions for integer operations.
1.5
1.6 -Copyright (C) 2016, 2017, 2018, 2021 Paul Boddie <paul@boddie.org.uk>
1.7 +Copyright (C) 2016, 2017, 2018, 2021, 2023 Paul Boddie <paul@boddie.org.uk>
1.8
1.9 This program is free software; you can redistribute it and/or modify it under
1.10 the terms of the GNU General Public License as published by the Free Software
1.11 @@ -31,12 +31,12 @@
1.12
1.13 /* Integer operations. */
1.14
1.15 -__attr __fn_native_int_is_int(__attr __self, __attr obj)
1.16 +__attr __fn_native_int_is_int(__attr __result, __attr __self, __attr obj)
1.17 {
1.18 return __INTEGER(obj) ? __builtins___boolean_True : __builtins___boolean_False;
1.19 }
1.20
1.21 -__attr __fn_native_int_int_add(__attr __self, __attr self, __attr other)
1.22 +__attr __fn_native_int_int_add(__attr __result, __attr __self, __attr self, __attr other)
1.23 {
1.24 /* self and other interpreted as int */
1.25 __int i = __TOINT(self);
1.26 @@ -52,7 +52,7 @@
1.27 return __new_int(i + j);
1.28 }
1.29
1.30 -__attr __fn_native_int_int_sub(__attr __self, __attr self, __attr other)
1.31 +__attr __fn_native_int_int_sub(__attr __result, __attr __self, __attr self, __attr other)
1.32 {
1.33 /* self and other interpreted as int */
1.34 __int i = __TOINT(self);
1.35 @@ -68,7 +68,7 @@
1.36 return __new_int(i - j);
1.37 }
1.38
1.39 -__attr __fn_native_int_int_mul(__attr __self, __attr self, __attr other)
1.40 +__attr __fn_native_int_int_mul(__attr __result, __attr __self, __attr self, __attr other)
1.41 {
1.42 /* self and other interpreted as int */
1.43 __int i = __TOINT(self);
1.44 @@ -86,7 +86,7 @@
1.45 return __new_int(i * j);
1.46 }
1.47
1.48 -__attr __fn_native_int_int_div(__attr __self, __attr self, __attr other)
1.49 +__attr __fn_native_int_int_div(__attr __result, __attr __self, __attr self, __attr other)
1.50 {
1.51 /* self and other interpreted as int */
1.52 __int i = __TOINT(self);
1.53 @@ -102,7 +102,7 @@
1.54 return __new_int(i / j);
1.55 }
1.56
1.57 -__attr __fn_native_int_int_mod(__attr __self, __attr self, __attr other)
1.58 +__attr __fn_native_int_int_mod(__attr __result, __attr __self, __attr self, __attr other)
1.59 {
1.60 /* self and other interpreted as int */
1.61 __int i = __TOINT(self);
1.62 @@ -118,7 +118,7 @@
1.63 return __new_int(i % j);
1.64 }
1.65
1.66 -__attr __fn_native_int_int_neg(__attr __self, __attr self)
1.67 +__attr __fn_native_int_int_neg(__attr __result, __attr __self, __attr self)
1.68 {
1.69 /* self interpreted as int */
1.70 __int i = __TOINT(self);
1.71 @@ -131,7 +131,7 @@
1.72 return __new_int(-i);
1.73 }
1.74
1.75 -__attr __fn_native_int_int_pow(__attr __self, __attr self, __attr other)
1.76 +__attr __fn_native_int_int_pow(__attr __result, __attr __self, __attr self, __attr other)
1.77 {
1.78 /* self and other interpreted as int */
1.79 __int i = __TOINT(self);
1.80 @@ -154,7 +154,7 @@
1.81 return __new_int(k);
1.82 }
1.83
1.84 -__attr __fn_native_int_int_and(__attr __self, __attr self, __attr other)
1.85 +__attr __fn_native_int_int_and(__attr __result, __attr __self, __attr self, __attr other)
1.86 {
1.87 /* self and other interpreted as int */
1.88 __int i = __TOINT(self);
1.89 @@ -165,7 +165,7 @@
1.90 return __new_int(i & j);
1.91 }
1.92
1.93 -__attr __fn_native_int_int_not(__attr __self, __attr self)
1.94 +__attr __fn_native_int_int_not(__attr __result, __attr __self, __attr self)
1.95 {
1.96 /* self interpreted as int */
1.97 __int i = __TOINT(self);
1.98 @@ -174,7 +174,7 @@
1.99 return __new_int(~i);
1.100 }
1.101
1.102 -__attr __fn_native_int_int_or(__attr __self, __attr self, __attr other)
1.103 +__attr __fn_native_int_int_or(__attr __result, __attr __self, __attr self, __attr other)
1.104 {
1.105 /* self and other interpreted as int */
1.106 __int i = __TOINT(self);
1.107 @@ -185,7 +185,7 @@
1.108 return __new_int(i | j);
1.109 }
1.110
1.111 -__attr __fn_native_int_int_xor(__attr __self, __attr self, __attr other)
1.112 +__attr __fn_native_int_int_xor(__attr __result, __attr __self, __attr self, __attr other)
1.113 {
1.114 /* self and other interpreted as int */
1.115 __int i = __TOINT(self);
1.116 @@ -196,7 +196,7 @@
1.117 return __new_int(i ^ j);
1.118 }
1.119
1.120 -__attr __fn_native_int_int_lshift(__attr __self, __attr self, __attr other)
1.121 +__attr __fn_native_int_int_lshift(__attr __result, __attr __self, __attr self, __attr other)
1.122 {
1.123 /* self and other interpreted as int */
1.124 __int i = __TOINT(self);
1.125 @@ -207,7 +207,7 @@
1.126 return __new_int(i << j);
1.127 }
1.128
1.129 -__attr __fn_native_int_int_rshift(__attr __self, __attr self, __attr other)
1.130 +__attr __fn_native_int_int_rshift(__attr __result, __attr __self, __attr self, __attr other)
1.131 {
1.132 /* self and other interpreted as int */
1.133 __int i = __TOINT(self);
1.134 @@ -218,7 +218,7 @@
1.135 return __new_int(i >> j);
1.136 }
1.137
1.138 -__attr __fn_native_int_int_le(__attr __self, __attr self, __attr other)
1.139 +__attr __fn_native_int_int_le(__attr __result, __attr __self, __attr self, __attr other)
1.140 {
1.141 /* self and other interpreted as int */
1.142 __int i = __TOINT(self);
1.143 @@ -228,7 +228,7 @@
1.144 return i <= j ? __builtins___boolean_True : __builtins___boolean_False;
1.145 }
1.146
1.147 -__attr __fn_native_int_int_lt(__attr __self, __attr self, __attr other)
1.148 +__attr __fn_native_int_int_lt(__attr __result, __attr __self, __attr self, __attr other)
1.149 {
1.150 /* self and other interpreted as int */
1.151 __int i = __TOINT(self);
1.152 @@ -238,7 +238,7 @@
1.153 return i < j ? __builtins___boolean_True : __builtins___boolean_False;
1.154 }
1.155
1.156 -__attr __fn_native_int_int_ge(__attr __self, __attr self, __attr other)
1.157 +__attr __fn_native_int_int_ge(__attr __result, __attr __self, __attr self, __attr other)
1.158 {
1.159 /* self and other interpreted as int */
1.160 __int i = __TOINT(self);
1.161 @@ -248,7 +248,7 @@
1.162 return i >= j ? __builtins___boolean_True : __builtins___boolean_False;
1.163 }
1.164
1.165 -__attr __fn_native_int_int_gt(__attr __self, __attr self, __attr other)
1.166 +__attr __fn_native_int_int_gt(__attr __result, __attr __self, __attr self, __attr other)
1.167 {
1.168 /* self and other interpreted as int */
1.169 __int i = __TOINT(self);
1.170 @@ -258,7 +258,7 @@
1.171 return i > j ? __builtins___boolean_True : __builtins___boolean_False;
1.172 }
1.173
1.174 -__attr __fn_native_int_int_eq(__attr __self, __attr self, __attr other)
1.175 +__attr __fn_native_int_int_eq(__attr __result, __attr __self, __attr self, __attr other)
1.176 {
1.177 /* self and other interpreted as int */
1.178 __int i = __TOINT(self);
1.179 @@ -268,7 +268,7 @@
1.180 return i == j ? __builtins___boolean_True : __builtins___boolean_False;
1.181 }
1.182
1.183 -__attr __fn_native_int_int_ne(__attr __self, __attr self, __attr other)
1.184 +__attr __fn_native_int_int_ne(__attr __result, __attr __self, __attr self, __attr other)
1.185 {
1.186 /* self and other interpreted as int */
1.187 __int i = __TOINT(self);
1.188 @@ -278,7 +278,7 @@
1.189 return i != j ? __builtins___boolean_True : __builtins___boolean_False;
1.190 }
1.191
1.192 -__attr __fn_native_int_int_str(__attr __self, __attr self)
1.193 +__attr __fn_native_int_int_str(__attr __result, __attr __self, __attr self)
1.194 {
1.195 /* self interpreted as int */
1.196 __int i = __TOINT(self);
1.197 @@ -294,12 +294,12 @@
1.198 return __new_str(s, strlen(s));
1.199 }
1.200
1.201 -__attr __fn_native_int_int_float(__attr __self, __attr self)
1.202 +__attr __fn_native_int_int_float(__attr __result, __attr __self, __attr self)
1.203 {
1.204 /* self interpreted as int */
1.205 int i = __TOINT(self);
1.206
1.207 - return __new_float((double) i);
1.208 + return __new_float(__result, (double) i);
1.209 }
1.210
1.211 /* Module initialisation. */