1.1 --- a/generator.py Thu Nov 04 23:44:29 2021 +0100 1.2 +++ b/generator.py Tue Aug 29 01:46:23 2023 +0200 1.3 @@ -3,7 +3,7 @@ 1.4 """ 1.5 Generate C code from object layouts and other deduced information. 1.6 1.7 -Copyright (C) 2015-2019, 2021 Paul Boddie <paul@boddie.org.uk> 1.8 +Copyright (C) 2015-2019, 2021, 2023 Paul Boddie <paul@boddie.org.uk> 1.9 1.10 This program is free software; you can redistribute it and/or modify it under 1.11 the terms of the GNU General Public License as published by the Free Software 1.12 @@ -40,6 +40,10 @@ 1.13 1.14 "A code generator." 1.15 1.16 + # Generated functions employ result target and context parameters. 1.17 + 1.18 + extra_args = 2 1.19 + 1.20 # NOTE: These must be synchronised with the library. 1.21 1.22 dict_type = "__builtins__.dict.dict" 1.23 @@ -315,11 +319,12 @@ 1.24 self.write_instance_structure(f_decls, path) 1.25 extra_function_instances.append(path) 1.26 1.27 - # Write function declarations. 1.28 - # Signature: __attr <name>(...); 1.29 + # Write function declarations, including result target and 1.30 + # context parameters. 1.31 + # Signature: __attr <name>(__attr, __attr, ...); 1.32 1.33 parameters = self.importer.function_parameters[path] 1.34 - l = ["__attr"] * (len(parameters) + 1) 1.35 + l = ["__attr"] * (len(parameters) + self.extra_args) 1.36 print >>f_signatures, "__attr %s(%s);" % (encode_function_pointer(path), ", ".join(l)) 1.37 1.38 # Generate parameter table size data. 1.39 @@ -903,7 +908,7 @@ 1.40 1.41 parameters = self.importer.function_parameters[path] 1.42 defaults = self.importer.function_defaults.get(path) 1.43 - num_parameters = len(parameters) + 1 1.44 + num_parameters = len(parameters) + self.extra_args 1.45 return num_parameters - (defaults and len(defaults) or 0), num_parameters 1.46 1.47 def get_static_attributes(self, kind, name, attrnames): 1.48 @@ -1270,9 +1275,9 @@ 1.49 1.50 if path == self.int_type: 1.51 print >>f_code, """\ 1.52 -__attr %s(__attr __self, __attr number_or_string, __attr base) 1.53 +__attr %s(__attr __result, __attr __self, __attr number_or_string, __attr base) 1.54 { 1.55 - return __fn___builtins___int_new_int(__NULL, number_or_string, base); 1.56 + return __fn___builtins___int_new_int(__NULL, __NULL, number_or_string, base); 1.57 } 1.58 """ % ( 1.59 encode_instantiator_pointer(path), 1.60 @@ -1285,9 +1290,9 @@ 1.61 1.62 elif path == self.string_type: 1.63 print >>f_code, """\ 1.64 -__attr %s(__attr __self, __attr obj) 1.65 +__attr %s(__attr __result, __attr __self, __attr obj) 1.66 { 1.67 - return __fn___builtins___str_new_str(__NULL, obj); 1.68 + return __fn___builtins___str_new_str(__NULL, __NULL, obj); 1.69 } 1.70 """ % ( 1.71 encode_instantiator_pointer(path), 1.72 @@ -1297,9 +1302,9 @@ 1.73 1.74 else: 1.75 print >>f_code, """\ 1.76 -__attr %s(__attr __self%s) 1.77 +__attr %s(__attr __result, __attr __self%s) 1.78 { 1.79 - return %s(__NEWINSTANCE(%s)%s); 1.80 + return %s(__NULL, __NEWINSTANCE(%s)%s); 1.81 } 1.82 """ % ( 1.83 encode_instantiator_pointer(path), 1.84 @@ -1309,9 +1314,9 @@ 1.85 parameters and ", %s" % ", ".join(parameters) or "" 1.86 ) 1.87 1.88 - # Signature: __new_typename(__attr __self, ...) 1.89 + # Signature: __new_typename(__attr __result, __attr __self, ...) 1.90 1.91 - print >>f_signatures, "__attr %s(__attr __self%s);" % ( 1.92 + print >>f_signatures, "__attr %s(__attr __result, __attr __self%s);" % ( 1.93 encode_instantiator_pointer(path), 1.94 l and ", %s" % ", ".join(l) or "" 1.95 ) 1.96 @@ -1358,7 +1363,7 @@ 1.97 1.98 fprintf(stderr, "Program terminated due to exception: %%s.\\n", 1.99 __load_via_object( 1.100 - __VALUE(%s(__NULL, __tmp_exc.arg)), 1.101 + __VALUE(%s(__NULL, __NULL, __tmp_exc.arg)), 1.102 __data__).strvalue); 1.103 return 1; 1.104 }
2.1 --- a/templates/native/buffer.c Thu Nov 04 23:44:29 2021 +0100 2.2 +++ b/templates/native/buffer.c Tue Aug 29 01:46:23 2023 +0200 2.3 @@ -1,6 +1,6 @@ 2.4 /* Native functions for buffer operations. 2.5 2.6 -Copyright (C) 2016, 2017, 2021 Paul Boddie <paul@boddie.org.uk> 2.7 +Copyright (C) 2016, 2017, 2021, 2023 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 @@ -26,7 +26,7 @@ 2.12 #include "progtypes.h" 2.13 #include "main.h" 2.14 2.15 -__attr __fn_native_buffer_buffer_str(__attr __self, __attr _data) 2.16 +__attr __fn_native_buffer_buffer_str(__attr __result, __attr __self, __attr _data) 2.17 { 2.18 /* _data interpreted as buffer.__data__ */ 2.19 __fragment *data = _data.seqvalue;
3.1 --- a/templates/native/buffer.h Thu Nov 04 23:44:29 2021 +0100 3.2 +++ b/templates/native/buffer.h Tue Aug 29 01:46:23 2023 +0200 3.3 @@ -1,6 +1,6 @@ 3.4 /* Native functions for buffer operations. 3.5 3.6 -Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk> 3.7 +Copyright (C) 2016, 2017, 2023 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 @@ -23,7 +23,7 @@ 3.12 3.13 /* Buffer operations. */ 3.14 3.15 -__attr __fn_native_buffer_buffer_str(__attr __self, __attr _data); 3.16 +__attr __fn_native_buffer_buffer_str(__attr __result, __attr __self, __attr _data); 3.17 3.18 /* Module initialisation. */ 3.19
4.1 --- a/templates/native/common.c Thu Nov 04 23:44:29 2021 +0100 4.2 +++ b/templates/native/common.c Tue Aug 29 01:46:23 2023 +0200 4.3 @@ -1,6 +1,6 @@ 4.4 /* Common operations for native functions. 4.5 4.6 -Copyright (C) 2016, 2017, 2018, 2021 Paul Boddie <paul@boddie.org.uk> 4.7 +Copyright (C) 2016, 2017, 2018, 2021, 2023 Paul Boddie <paul@boddie.org.uk> 4.8 4.9 This program is free software; you can redistribute it and/or modify it under 4.10 the terms of the GNU General Public License as published by the Free Software 4.11 @@ -44,12 +44,33 @@ 4.12 return attr; 4.13 } 4.14 4.15 -__attr __new_float(double n) 4.16 +/* Temporary result target. */ 4.17 + 4.18 +__attr __new_float(__attr __result, double n) 4.19 { 4.20 - /* Create a new float and set the trailing data. */ 4.21 - __attr attr = __NEWINSTANCEIM(__builtins___float_float); 4.22 + __attr attr; 4.23 + 4.24 + /* Identify any suitable target for value replacement. The assumption is 4.25 + that locally referenced float objects are always replaceable since they 4.26 + will be appropriately initialised. */ 4.27 + 4.28 + __ref obj = __VALUE(__result); 4.29 + int replace = (obj != NULL) && __is_instance(obj) && (__get_class(obj) == &__builtins___float_float); 4.30 + 4.31 + if (replace) 4.32 + attr = __result; 4.33 + 4.34 + /* Alternatively, create a new float. */ 4.35 + else 4.36 + attr = __NEWINSTANCEIM(__builtins___float_float); 4.37 + 4.38 + /* Set the trailing data, replacing an existing value if applicable. */ 4.39 __set_trailing_data(attr, __builtins___float_float, n); 4.40 - return attr; 4.41 + 4.42 + if (replace) 4.43 + return __REPLACEMENT(attr); 4.44 + else 4.45 + return attr; 4.46 } 4.47 4.48 __fragment *__fragment_append(__fragment *data, __attr value)
5.1 --- a/templates/native/common.h Thu Nov 04 23:44:29 2021 +0100 5.2 +++ b/templates/native/common.h Tue Aug 29 01:46:23 2023 +0200 5.3 @@ -1,6 +1,6 @@ 5.4 /* Common operations for native functions. 5.5 5.6 -Copyright (C) 2016, 2017, 2018, 2021 Paul Boddie <paul@boddie.org.uk> 5.7 +Copyright (C) 2016, 2017, 2018, 2021, 2023 Paul Boddie <paul@boddie.org.uk> 5.8 5.9 This program is free software; you can redistribute it and/or modify it under 5.10 the terms of the GNU General Public License as published by the Free Software 5.11 @@ -29,7 +29,7 @@ 5.12 5.13 __attr __new_str(char *s, __int size); 5.14 __attr __new_list(__fragment *f); 5.15 -__attr __new_float(double n); 5.16 +__attr __new_float(__attr __result, double n); 5.17 __fragment *__fragment_append(__fragment *data, __attr value); 5.18 5.19 #endif /* __NATIVE_COMMON_H__ */
6.1 --- a/templates/native/float.c Thu Nov 04 23:44:29 2021 +0100 6.2 +++ b/templates/native/float.c Tue Aug 29 01:46:23 2023 +0200 6.3 @@ -1,6 +1,6 @@ 6.4 /* Native functions for floating point operations. 6.5 6.6 -Copyright (C) 2016, 2017, 2018, 2019 Paul Boddie <paul@boddie.org.uk> 6.7 +Copyright (C) 2016, 2017, 2018, 2019, 2023 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 @@ -65,54 +65,54 @@ 6.12 6.13 /* Floating point operations. Exceptions are raised in the signal handler. */ 6.14 6.15 -__attr __fn_native_float_float_add(__attr __self, __attr self, __attr other) 6.16 +__attr __fn_native_float_float_add(__attr __result, __attr __self, __attr self, __attr other) 6.17 { 6.18 /* self and other interpreted as float */ 6.19 double i = __TOFLOAT(self); 6.20 double j = __TOFLOAT(other); 6.21 - return __new_float(i + j); 6.22 + return __new_float(__result, i + j); 6.23 } 6.24 6.25 -__attr __fn_native_float_float_sub(__attr __self, __attr self, __attr other) 6.26 +__attr __fn_native_float_float_sub(__attr __result, __attr __self, __attr self, __attr other) 6.27 { 6.28 /* self and other interpreted as float */ 6.29 double i = __TOFLOAT(self); 6.30 double j = __TOFLOAT(other); 6.31 - return __new_float(i - j); 6.32 + return __new_float(__result, i - j); 6.33 } 6.34 6.35 -__attr __fn_native_float_float_mul(__attr __self, __attr self, __attr other) 6.36 +__attr __fn_native_float_float_mul(__attr __result, __attr __self, __attr self, __attr other) 6.37 { 6.38 /* self and other interpreted as float */ 6.39 double i = __TOFLOAT(self); 6.40 double j = __TOFLOAT(other); 6.41 - return __new_float(i * j); 6.42 + return __new_float(__result, i * j); 6.43 } 6.44 6.45 -__attr __fn_native_float_float_div(__attr __self, __attr self, __attr other) 6.46 +__attr __fn_native_float_float_div(__attr __result, __attr __self, __attr self, __attr other) 6.47 { 6.48 /* self and other interpreted as float */ 6.49 double i = __TOFLOAT(self); 6.50 double j = __TOFLOAT(other); 6.51 - return __new_float(i / j); 6.52 + return __new_float(__result, i / j); 6.53 } 6.54 6.55 -__attr __fn_native_float_float_mod(__attr __self, __attr self, __attr other) 6.56 +__attr __fn_native_float_float_mod(__attr __result, __attr __self, __attr self, __attr other) 6.57 { 6.58 /* self and other interpreted as float */ 6.59 double i = __TOFLOAT(self); 6.60 double j = __TOFLOAT(other); 6.61 - return __new_float(fmod(i, j)); 6.62 + return __new_float(__result, fmod(i, j)); 6.63 } 6.64 6.65 -__attr __fn_native_float_float_neg(__attr __self, __attr self) 6.66 +__attr __fn_native_float_float_neg(__attr __result, __attr __self, __attr self) 6.67 { 6.68 /* self interpreted as float */ 6.69 double i = __TOFLOAT(self); 6.70 - return __new_float(-i); 6.71 + return __new_float(__result, -i); 6.72 } 6.73 6.74 -__attr __fn_native_float_float_pow(__attr __self, __attr self, __attr other) 6.75 +__attr __fn_native_float_float_pow(__attr __result, __attr __self, __attr self, __attr other) 6.76 { 6.77 /* self and other interpreted as float */ 6.78 double i = __TOFLOAT(self); 6.79 @@ -128,10 +128,10 @@ 6.80 __raise_overflow_error(); 6.81 6.82 /* Return the result. */ 6.83 - return __new_float(result); 6.84 + return __new_float(__result, result); 6.85 } 6.86 6.87 -__attr __fn_native_float_float_le(__attr __self, __attr self, __attr other) 6.88 +__attr __fn_native_float_float_le(__attr __result, __attr __self, __attr self, __attr other) 6.89 { 6.90 /* self and other interpreted as float */ 6.91 double i = __TOFLOAT(self); 6.92 @@ -141,7 +141,7 @@ 6.93 return i <= j ? __builtins___boolean_True : __builtins___boolean_False; 6.94 } 6.95 6.96 -__attr __fn_native_float_float_lt(__attr __self, __attr self, __attr other) 6.97 +__attr __fn_native_float_float_lt(__attr __result, __attr __self, __attr self, __attr other) 6.98 { 6.99 /* self and other interpreted as float */ 6.100 double i = __TOFLOAT(self); 6.101 @@ -151,7 +151,7 @@ 6.102 return i < j ? __builtins___boolean_True : __builtins___boolean_False; 6.103 } 6.104 6.105 -__attr __fn_native_float_float_ge(__attr __self, __attr self, __attr other) 6.106 +__attr __fn_native_float_float_ge(__attr __result, __attr __self, __attr self, __attr other) 6.107 { 6.108 /* self and other interpreted as float */ 6.109 double i = __TOFLOAT(self); 6.110 @@ -161,7 +161,7 @@ 6.111 return i >= j ? __builtins___boolean_True : __builtins___boolean_False; 6.112 } 6.113 6.114 -__attr __fn_native_float_float_gt(__attr __self, __attr self, __attr other) 6.115 +__attr __fn_native_float_float_gt(__attr __result, __attr __self, __attr self, __attr other) 6.116 { 6.117 /* self and other interpreted as float */ 6.118 double i = __TOFLOAT(self); 6.119 @@ -171,7 +171,7 @@ 6.120 return i > j ? __builtins___boolean_True : __builtins___boolean_False; 6.121 } 6.122 6.123 -__attr __fn_native_float_float_eq(__attr __self, __attr self, __attr other) 6.124 +__attr __fn_native_float_float_eq(__attr __result, __attr __self, __attr self, __attr other) 6.125 { 6.126 /* self and other interpreted as float */ 6.127 double i = __TOFLOAT(self); 6.128 @@ -181,7 +181,7 @@ 6.129 return i == j ? __builtins___boolean_True : __builtins___boolean_False; 6.130 } 6.131 6.132 -__attr __fn_native_float_float_ne(__attr __self, __attr self, __attr other) 6.133 +__attr __fn_native_float_float_ne(__attr __result, __attr __self, __attr self, __attr other) 6.134 { 6.135 /* self and other interpreted as float */ 6.136 double i = __TOFLOAT(self); 6.137 @@ -191,7 +191,7 @@ 6.138 return i != j ? __builtins___boolean_True : __builtins___boolean_False; 6.139 } 6.140 6.141 -__attr __fn_native_float_float_str(__attr __self, __attr self) 6.142 +__attr __fn_native_float_float_str(__attr __result, __attr __self, __attr self) 6.143 { 6.144 /* self interpreted as float */ 6.145 double i = __TOFLOAT(self); 6.146 @@ -200,7 +200,7 @@ 6.147 return format_number(i, 64); 6.148 } 6.149 6.150 -__attr __fn_native_float_float_int(__attr __self, __attr self) 6.151 +__attr __fn_native_float_float_int(__attr __result, __attr __self, __attr self) 6.152 { 6.153 /* self interpreted as float */ 6.154 double i = __TOFLOAT(self);
7.1 --- a/templates/native/float.h Thu Nov 04 23:44:29 2021 +0100 7.2 +++ b/templates/native/float.h Tue Aug 29 01:46:23 2023 +0200 7.3 @@ -1,6 +1,6 @@ 7.4 /* Native functions for floating point operations. 7.5 7.6 -Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 7.7 +Copyright (C) 2018, 2023 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 @@ -23,23 +23,23 @@ 7.12 7.13 /* Floating point operations. */ 7.14 7.15 -__attr __fn_native_float_float_add(__attr __self, __attr self, __attr other); 7.16 -__attr __fn_native_float_float_sub(__attr __self, __attr self, __attr other); 7.17 -__attr __fn_native_float_float_mul(__attr __self, __attr self, __attr other); 7.18 -__attr __fn_native_float_float_div(__attr __self, __attr self, __attr other); 7.19 -__attr __fn_native_float_float_mod(__attr __self, __attr self, __attr other); 7.20 -__attr __fn_native_float_float_neg(__attr __self, __attr self); 7.21 -__attr __fn_native_float_float_pow(__attr __self, __attr self, __attr other); 7.22 +__attr __fn_native_float_float_add(__attr __result, __attr __self, __attr self, __attr other); 7.23 +__attr __fn_native_float_float_sub(__attr __result, __attr __self, __attr self, __attr other); 7.24 +__attr __fn_native_float_float_mul(__attr __result, __attr __self, __attr self, __attr other); 7.25 +__attr __fn_native_float_float_div(__attr __result, __attr __self, __attr self, __attr other); 7.26 +__attr __fn_native_float_float_mod(__attr __result, __attr __self, __attr self, __attr other); 7.27 +__attr __fn_native_float_float_neg(__attr __result, __attr __self, __attr self); 7.28 +__attr __fn_native_float_float_pow(__attr __result, __attr __self, __attr self, __attr other); 7.29 7.30 -__attr __fn_native_float_float_le(__attr __self, __attr self, __attr other); 7.31 -__attr __fn_native_float_float_lt(__attr __self, __attr self, __attr other); 7.32 -__attr __fn_native_float_float_ge(__attr __self, __attr self, __attr other); 7.33 -__attr __fn_native_float_float_gt(__attr __self, __attr self, __attr other); 7.34 -__attr __fn_native_float_float_eq(__attr __self, __attr self, __attr other); 7.35 -__attr __fn_native_float_float_ne(__attr __self, __attr self, __attr other); 7.36 +__attr __fn_native_float_float_le(__attr __result, __attr __self, __attr self, __attr other); 7.37 +__attr __fn_native_float_float_lt(__attr __result, __attr __self, __attr self, __attr other); 7.38 +__attr __fn_native_float_float_ge(__attr __result, __attr __self, __attr self, __attr other); 7.39 +__attr __fn_native_float_float_gt(__attr __result, __attr __self, __attr self, __attr other); 7.40 +__attr __fn_native_float_float_eq(__attr __result, __attr __self, __attr self, __attr other); 7.41 +__attr __fn_native_float_float_ne(__attr __result, __attr __self, __attr self, __attr other); 7.42 7.43 -__attr __fn_native_float_float_str(__attr __self, __attr self); 7.44 -__attr __fn_native_float_float_int(__attr __self, __attr self); 7.45 +__attr __fn_native_float_float_str(__attr __result, __attr __self, __attr self); 7.46 +__attr __fn_native_float_float_int(__attr __result, __attr __self, __attr self); 7.47 7.48 /* Module initialisation. */ 7.49
8.1 --- a/templates/native/iconv.c Thu Nov 04 23:44:29 2021 +0100 8.2 +++ b/templates/native/iconv.c Tue Aug 29 01:46:23 2023 +0200 8.3 @@ -1,6 +1,6 @@ 8.4 /* Native functions for character set conversion. 8.5 8.6 -Copyright (C) 2016, 2017, 2021 Paul Boddie <paul@boddie.org.uk> 8.7 +Copyright (C) 2016, 2017, 2021, 2023 Paul Boddie <paul@boddie.org.uk> 8.8 8.9 This program is free software; you can redistribute it and/or modify it under 8.10 the terms of the GNU General Public License as published by the Free Software 8.11 @@ -33,20 +33,20 @@ 8.12 static void __raise_incomplete_sequence_error(__attr value, __attr arg) 8.13 { 8.14 #ifdef __HAVE_posix_iconv_IncompleteSequenceError 8.15 - __Raise(__new_posix_iconv_IncompleteSequenceError(__NULL, value, arg)); 8.16 + __Raise(__new_posix_iconv_IncompleteSequenceError(__NULL, __NULL, value, arg)); 8.17 #endif /* __HAVE_posix_iconv_IncompleteSequenceError */ 8.18 } 8.19 8.20 static void __raise_invalid_sequence_error(__attr value, __attr arg) 8.21 { 8.22 #ifdef __HAVE_posix_iconv_InvalidSequenceError 8.23 - __Raise(__new_posix_iconv_InvalidSequenceError(__NULL, value, arg)); 8.24 + __Raise(__new_posix_iconv_InvalidSequenceError(__NULL, __NULL, value, arg)); 8.25 #endif /* __HAVE_posix_iconv_InvalidSequenceError */ 8.26 } 8.27 8.28 /* Character set conversion. */ 8.29 8.30 -__attr __fn_native_iconv_iconv(__attr __self, __attr cd, __attr state) 8.31 +__attr __fn_native_iconv_iconv(__attr __result, __attr __self, __attr cd, __attr state) 8.32 { 8.33 /* cd interpreted as iconv_t */ 8.34 iconv_t c = (iconv_t) cd.datavalue; 8.35 @@ -117,7 +117,7 @@ 8.36 return __builtins___none_None; 8.37 } 8.38 8.39 -__attr __fn_native_iconv_iconv_close(__attr __self, __attr cd) 8.40 +__attr __fn_native_iconv_iconv_close(__attr __result, __attr __self, __attr cd) 8.41 { 8.42 /* cd interpreted as iconv_t */ 8.43 iconv_t c = (iconv_t) cd.datavalue; 8.44 @@ -130,7 +130,7 @@ 8.45 return __builtins___none_None; 8.46 } 8.47 8.48 -__attr __fn_native_iconv_iconv_open(__attr __self, __attr tocode, __attr fromcode) 8.49 +__attr __fn_native_iconv_iconv_open(__attr __result, __attr __self, __attr tocode, __attr fromcode) 8.50 { 8.51 /* tocode.__data__ interpreted as string */ 8.52 char *t = __load_via_object(__VALUE(tocode), __data__).strvalue; 8.53 @@ -151,7 +151,7 @@ 8.54 return attr; 8.55 } 8.56 8.57 -__attr __fn_native_iconv_iconv_reset(__attr __self, __attr cd) 8.58 +__attr __fn_native_iconv_iconv_reset(__attr __result, __attr __self, __attr cd) 8.59 { 8.60 /* cd interpreted as iconv_t */ 8.61 iconv_t c = (iconv_t) cd.datavalue;
9.1 --- a/templates/native/iconv.h Thu Nov 04 23:44:29 2021 +0100 9.2 +++ b/templates/native/iconv.h Tue Aug 29 01:46:23 2023 +0200 9.3 @@ -1,6 +1,6 @@ 9.4 /* Native functions for character set conversion. 9.5 9.6 -Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk> 9.7 +Copyright (C) 2016, 2017, 2023 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 @@ -23,10 +23,10 @@ 9.12 9.13 /* Input/output. */ 9.14 9.15 -__attr __fn_native_iconv_iconv(__attr __self, __attr cd, __attr state); 9.16 -__attr __fn_native_iconv_iconv_close(__attr __self, __attr cd); 9.17 -__attr __fn_native_iconv_iconv_open(__attr __self, __attr tocode, __attr fromcode); 9.18 -__attr __fn_native_iconv_iconv_reset(__attr __self, __attr cd); 9.19 +__attr __fn_native_iconv_iconv(__attr __result, __attr __self, __attr cd, __attr state); 9.20 +__attr __fn_native_iconv_iconv_close(__attr __result, __attr __self, __attr cd); 9.21 +__attr __fn_native_iconv_iconv_open(__attr __result, __attr __self, __attr tocode, __attr fromcode); 9.22 +__attr __fn_native_iconv_iconv_reset(__attr __result, __attr __self, __attr cd); 9.23 9.24 /* Module initialisation. */ 9.25
10.1 --- a/templates/native/identity.c Thu Nov 04 23:44:29 2021 +0100 10.2 +++ b/templates/native/identity.c Tue Aug 29 01:46:23 2023 +0200 10.3 @@ -1,6 +1,6 @@ 10.4 /* Native functions for identity operations. 10.5 10.6 -Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk> 10.7 +Copyright (C) 2016, 2017, 2023 Paul Boddie <paul@boddie.org.uk> 10.8 10.9 This program is free software; you can redistribute it and/or modify it under 10.10 the terms of the GNU General Public License as published by the Free Software 10.11 @@ -26,14 +26,14 @@ 10.12 10.13 /* Identity testing. */ 10.14 10.15 -__attr __fn_native_identity_is_(__attr __self, __attr x, __attr y) 10.16 +__attr __fn_native_identity_is_(__attr __result, __attr __self, __attr x, __attr y) 10.17 { 10.18 /* NOTE: value member assumed equivalent to intvalue for comparison. */ 10.19 10.20 return x.value == y.value ? __builtins___boolean_True : __builtins___boolean_False; 10.21 } 10.22 10.23 -__attr __fn_native_identity_is_not(__attr __self, __attr x, __attr y) 10.24 +__attr __fn_native_identity_is_not(__attr __result, __attr __self, __attr x, __attr y) 10.25 { 10.26 /* NOTE: value member assumed equivalent to intvalue for comparison. */ 10.27
11.1 --- a/templates/native/identity.h Thu Nov 04 23:44:29 2021 +0100 11.2 +++ b/templates/native/identity.h Tue Aug 29 01:46:23 2023 +0200 11.3 @@ -1,6 +1,6 @@ 11.4 /* Native functions for identity operations. 11.5 11.6 -Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk> 11.7 +Copyright (C) 2016, 2017, 2023 Paul Boddie <paul@boddie.org.uk> 11.8 11.9 This program is free software; you can redistribute it and/or modify it under 11.10 the terms of the GNU General Public License as published by the Free Software 11.11 @@ -23,8 +23,8 @@ 11.12 11.13 /* Identity testing. */ 11.14 11.15 -__attr __fn_native_identity_is_(__attr __self, __attr x, __attr y); 11.16 -__attr __fn_native_identity_is_not(__attr __self, __attr x, __attr y); 11.17 +__attr __fn_native_identity_is_(__attr __result, __attr __self, __attr x, __attr y); 11.18 +__attr __fn_native_identity_is_not(__attr __result, __attr __self, __attr x, __attr y); 11.19 11.20 /* Module initialisation. */ 11.21
12.1 --- a/templates/native/int.c Thu Nov 04 23:44:29 2021 +0100 12.2 +++ b/templates/native/int.c Tue Aug 29 01:46:23 2023 +0200 12.3 @@ -1,6 +1,6 @@ 12.4 /* Native functions for integer operations. 12.5 12.6 -Copyright (C) 2016, 2017, 2018, 2021 Paul Boddie <paul@boddie.org.uk> 12.7 +Copyright (C) 2016, 2017, 2018, 2021, 2023 Paul Boddie <paul@boddie.org.uk> 12.8 12.9 This program is free software; you can redistribute it and/or modify it under 12.10 the terms of the GNU General Public License as published by the Free Software 12.11 @@ -31,12 +31,12 @@ 12.12 12.13 /* Integer operations. */ 12.14 12.15 -__attr __fn_native_int_is_int(__attr __self, __attr obj) 12.16 +__attr __fn_native_int_is_int(__attr __result, __attr __self, __attr obj) 12.17 { 12.18 return __INTEGER(obj) ? __builtins___boolean_True : __builtins___boolean_False; 12.19 } 12.20 12.21 -__attr __fn_native_int_int_add(__attr __self, __attr self, __attr other) 12.22 +__attr __fn_native_int_int_add(__attr __result, __attr __self, __attr self, __attr other) 12.23 { 12.24 /* self and other interpreted as int */ 12.25 __int i = __TOINT(self); 12.26 @@ -52,7 +52,7 @@ 12.27 return __new_int(i + j); 12.28 } 12.29 12.30 -__attr __fn_native_int_int_sub(__attr __self, __attr self, __attr other) 12.31 +__attr __fn_native_int_int_sub(__attr __result, __attr __self, __attr self, __attr other) 12.32 { 12.33 /* self and other interpreted as int */ 12.34 __int i = __TOINT(self); 12.35 @@ -68,7 +68,7 @@ 12.36 return __new_int(i - j); 12.37 } 12.38 12.39 -__attr __fn_native_int_int_mul(__attr __self, __attr self, __attr other) 12.40 +__attr __fn_native_int_int_mul(__attr __result, __attr __self, __attr self, __attr other) 12.41 { 12.42 /* self and other interpreted as int */ 12.43 __int i = __TOINT(self); 12.44 @@ -86,7 +86,7 @@ 12.45 return __new_int(i * j); 12.46 } 12.47 12.48 -__attr __fn_native_int_int_div(__attr __self, __attr self, __attr other) 12.49 +__attr __fn_native_int_int_div(__attr __result, __attr __self, __attr self, __attr other) 12.50 { 12.51 /* self and other interpreted as int */ 12.52 __int i = __TOINT(self); 12.53 @@ -102,7 +102,7 @@ 12.54 return __new_int(i / j); 12.55 } 12.56 12.57 -__attr __fn_native_int_int_mod(__attr __self, __attr self, __attr other) 12.58 +__attr __fn_native_int_int_mod(__attr __result, __attr __self, __attr self, __attr other) 12.59 { 12.60 /* self and other interpreted as int */ 12.61 __int i = __TOINT(self); 12.62 @@ -118,7 +118,7 @@ 12.63 return __new_int(i % j); 12.64 } 12.65 12.66 -__attr __fn_native_int_int_neg(__attr __self, __attr self) 12.67 +__attr __fn_native_int_int_neg(__attr __result, __attr __self, __attr self) 12.68 { 12.69 /* self interpreted as int */ 12.70 __int i = __TOINT(self); 12.71 @@ -131,7 +131,7 @@ 12.72 return __new_int(-i); 12.73 } 12.74 12.75 -__attr __fn_native_int_int_pow(__attr __self, __attr self, __attr other) 12.76 +__attr __fn_native_int_int_pow(__attr __result, __attr __self, __attr self, __attr other) 12.77 { 12.78 /* self and other interpreted as int */ 12.79 __int i = __TOINT(self); 12.80 @@ -154,7 +154,7 @@ 12.81 return __new_int(k); 12.82 } 12.83 12.84 -__attr __fn_native_int_int_and(__attr __self, __attr self, __attr other) 12.85 +__attr __fn_native_int_int_and(__attr __result, __attr __self, __attr self, __attr other) 12.86 { 12.87 /* self and other interpreted as int */ 12.88 __int i = __TOINT(self); 12.89 @@ -165,7 +165,7 @@ 12.90 return __new_int(i & j); 12.91 } 12.92 12.93 -__attr __fn_native_int_int_not(__attr __self, __attr self) 12.94 +__attr __fn_native_int_int_not(__attr __result, __attr __self, __attr self) 12.95 { 12.96 /* self interpreted as int */ 12.97 __int i = __TOINT(self); 12.98 @@ -174,7 +174,7 @@ 12.99 return __new_int(~i); 12.100 } 12.101 12.102 -__attr __fn_native_int_int_or(__attr __self, __attr self, __attr other) 12.103 +__attr __fn_native_int_int_or(__attr __result, __attr __self, __attr self, __attr other) 12.104 { 12.105 /* self and other interpreted as int */ 12.106 __int i = __TOINT(self); 12.107 @@ -185,7 +185,7 @@ 12.108 return __new_int(i | j); 12.109 } 12.110 12.111 -__attr __fn_native_int_int_xor(__attr __self, __attr self, __attr other) 12.112 +__attr __fn_native_int_int_xor(__attr __result, __attr __self, __attr self, __attr other) 12.113 { 12.114 /* self and other interpreted as int */ 12.115 __int i = __TOINT(self); 12.116 @@ -196,7 +196,7 @@ 12.117 return __new_int(i ^ j); 12.118 } 12.119 12.120 -__attr __fn_native_int_int_lshift(__attr __self, __attr self, __attr other) 12.121 +__attr __fn_native_int_int_lshift(__attr __result, __attr __self, __attr self, __attr other) 12.122 { 12.123 /* self and other interpreted as int */ 12.124 __int i = __TOINT(self); 12.125 @@ -207,7 +207,7 @@ 12.126 return __new_int(i << j); 12.127 } 12.128 12.129 -__attr __fn_native_int_int_rshift(__attr __self, __attr self, __attr other) 12.130 +__attr __fn_native_int_int_rshift(__attr __result, __attr __self, __attr self, __attr other) 12.131 { 12.132 /* self and other interpreted as int */ 12.133 __int i = __TOINT(self); 12.134 @@ -218,7 +218,7 @@ 12.135 return __new_int(i >> j); 12.136 } 12.137 12.138 -__attr __fn_native_int_int_le(__attr __self, __attr self, __attr other) 12.139 +__attr __fn_native_int_int_le(__attr __result, __attr __self, __attr self, __attr other) 12.140 { 12.141 /* self and other interpreted as int */ 12.142 __int i = __TOINT(self); 12.143 @@ -228,7 +228,7 @@ 12.144 return i <= j ? __builtins___boolean_True : __builtins___boolean_False; 12.145 } 12.146 12.147 -__attr __fn_native_int_int_lt(__attr __self, __attr self, __attr other) 12.148 +__attr __fn_native_int_int_lt(__attr __result, __attr __self, __attr self, __attr other) 12.149 { 12.150 /* self and other interpreted as int */ 12.151 __int i = __TOINT(self); 12.152 @@ -238,7 +238,7 @@ 12.153 return i < j ? __builtins___boolean_True : __builtins___boolean_False; 12.154 } 12.155 12.156 -__attr __fn_native_int_int_ge(__attr __self, __attr self, __attr other) 12.157 +__attr __fn_native_int_int_ge(__attr __result, __attr __self, __attr self, __attr other) 12.158 { 12.159 /* self and other interpreted as int */ 12.160 __int i = __TOINT(self); 12.161 @@ -248,7 +248,7 @@ 12.162 return i >= j ? __builtins___boolean_True : __builtins___boolean_False; 12.163 } 12.164 12.165 -__attr __fn_native_int_int_gt(__attr __self, __attr self, __attr other) 12.166 +__attr __fn_native_int_int_gt(__attr __result, __attr __self, __attr self, __attr other) 12.167 { 12.168 /* self and other interpreted as int */ 12.169 __int i = __TOINT(self); 12.170 @@ -258,7 +258,7 @@ 12.171 return i > j ? __builtins___boolean_True : __builtins___boolean_False; 12.172 } 12.173 12.174 -__attr __fn_native_int_int_eq(__attr __self, __attr self, __attr other) 12.175 +__attr __fn_native_int_int_eq(__attr __result, __attr __self, __attr self, __attr other) 12.176 { 12.177 /* self and other interpreted as int */ 12.178 __int i = __TOINT(self); 12.179 @@ -268,7 +268,7 @@ 12.180 return i == j ? __builtins___boolean_True : __builtins___boolean_False; 12.181 } 12.182 12.183 -__attr __fn_native_int_int_ne(__attr __self, __attr self, __attr other) 12.184 +__attr __fn_native_int_int_ne(__attr __result, __attr __self, __attr self, __attr other) 12.185 { 12.186 /* self and other interpreted as int */ 12.187 __int i = __TOINT(self); 12.188 @@ -278,7 +278,7 @@ 12.189 return i != j ? __builtins___boolean_True : __builtins___boolean_False; 12.190 } 12.191 12.192 -__attr __fn_native_int_int_str(__attr __self, __attr self) 12.193 +__attr __fn_native_int_int_str(__attr __result, __attr __self, __attr self) 12.194 { 12.195 /* self interpreted as int */ 12.196 __int i = __TOINT(self); 12.197 @@ -294,12 +294,12 @@ 12.198 return __new_str(s, strlen(s)); 12.199 } 12.200 12.201 -__attr __fn_native_int_int_float(__attr __self, __attr self) 12.202 +__attr __fn_native_int_int_float(__attr __result, __attr __self, __attr self) 12.203 { 12.204 /* self interpreted as int */ 12.205 int i = __TOINT(self); 12.206 12.207 - return __new_float((double) i); 12.208 + return __new_float(__result, (double) i); 12.209 } 12.210 12.211 /* Module initialisation. */
13.1 --- a/templates/native/int.h Thu Nov 04 23:44:29 2021 +0100 13.2 +++ b/templates/native/int.h Tue Aug 29 01:46:23 2023 +0200 13.3 @@ -1,6 +1,6 @@ 13.4 /* Native functions for integer operations. 13.5 13.6 -Copyright (C) 2016, 2017, 2018 Paul Boddie <paul@boddie.org.uk> 13.7 +Copyright (C) 2016, 2017, 2018, 2023 Paul Boddie <paul@boddie.org.uk> 13.8 13.9 This program is free software; you can redistribute it and/or modify it under 13.10 the terms of the GNU General Public License as published by the Free Software 13.11 @@ -23,32 +23,32 @@ 13.12 13.13 /* Integer operations. */ 13.14 13.15 -__attr __fn_native_int_is_int(__attr __self, __attr obj); 13.16 -__attr __fn_native_int_int_add(__attr __self, __attr _data, __attr other); 13.17 -__attr __fn_native_int_int_sub(__attr __self, __attr _data, __attr other); 13.18 -__attr __fn_native_int_int_mul(__attr __self, __attr _data, __attr other); 13.19 -__attr __fn_native_int_int_div(__attr __self, __attr _data, __attr other); 13.20 -__attr __fn_native_int_int_mod(__attr __self, __attr _data, __attr other); 13.21 -__attr __fn_native_int_int_neg(__attr __self, __attr _data); 13.22 -__attr __fn_native_int_int_pow(__attr __self, __attr _data, __attr other); 13.23 +__attr __fn_native_int_is_int(__attr __result, __attr __self, __attr obj); 13.24 +__attr __fn_native_int_int_add(__attr __result, __attr __self, __attr _data, __attr other); 13.25 +__attr __fn_native_int_int_sub(__attr __result, __attr __self, __attr _data, __attr other); 13.26 +__attr __fn_native_int_int_mul(__attr __result, __attr __self, __attr _data, __attr other); 13.27 +__attr __fn_native_int_int_div(__attr __result, __attr __self, __attr _data, __attr other); 13.28 +__attr __fn_native_int_int_mod(__attr __result, __attr __self, __attr _data, __attr other); 13.29 +__attr __fn_native_int_int_neg(__attr __result, __attr __self, __attr _data); 13.30 +__attr __fn_native_int_int_pow(__attr __result, __attr __self, __attr _data, __attr other); 13.31 13.32 -__attr __fn_native_int_int_and(__attr __self, __attr _data, __attr other); 13.33 -__attr __fn_native_int_int_not(__attr __self, __attr _data); 13.34 -__attr __fn_native_int_int_or(__attr __self, __attr _data, __attr other); 13.35 -__attr __fn_native_int_int_xor(__attr __self, __attr _data, __attr other); 13.36 +__attr __fn_native_int_int_and(__attr __result, __attr __self, __attr _data, __attr other); 13.37 +__attr __fn_native_int_int_not(__attr __result, __attr __self, __attr _data); 13.38 +__attr __fn_native_int_int_or(__attr __result, __attr __self, __attr _data, __attr other); 13.39 +__attr __fn_native_int_int_xor(__attr __result, __attr __self, __attr _data, __attr other); 13.40 13.41 -__attr __fn_native_int_int_lshift(__attr __self, __attr _data, __attr other); 13.42 -__attr __fn_native_int_int_rshift(__attr __self, __attr _data, __attr other); 13.43 +__attr __fn_native_int_int_lshift(__attr __result, __attr __self, __attr _data, __attr other); 13.44 +__attr __fn_native_int_int_rshift(__attr __result, __attr __self, __attr _data, __attr other); 13.45 13.46 -__attr __fn_native_int_int_eq(__attr __self, __attr _data, __attr other); 13.47 -__attr __fn_native_int_int_ge(__attr __self, __attr _data, __attr other); 13.48 -__attr __fn_native_int_int_gt(__attr __self, __attr _data, __attr other); 13.49 -__attr __fn_native_int_int_le(__attr __self, __attr _data, __attr other); 13.50 -__attr __fn_native_int_int_lt(__attr __self, __attr _data, __attr other); 13.51 -__attr __fn_native_int_int_ne(__attr __self, __attr _data, __attr other); 13.52 +__attr __fn_native_int_int_eq(__attr __result, __attr __self, __attr _data, __attr other); 13.53 +__attr __fn_native_int_int_ge(__attr __result, __attr __self, __attr _data, __attr other); 13.54 +__attr __fn_native_int_int_gt(__attr __result, __attr __self, __attr _data, __attr other); 13.55 +__attr __fn_native_int_int_le(__attr __result, __attr __self, __attr _data, __attr other); 13.56 +__attr __fn_native_int_int_lt(__attr __result, __attr __self, __attr _data, __attr other); 13.57 +__attr __fn_native_int_int_ne(__attr __result, __attr __self, __attr _data, __attr other); 13.58 13.59 -__attr __fn_native_int_int_str(__attr __self, __attr _data); 13.60 -__attr __fn_native_int_int_float(__attr __self, __attr _data); 13.61 +__attr __fn_native_int_int_str(__attr __result, __attr __self, __attr _data); 13.62 +__attr __fn_native_int_int_float(__attr __result, __attr __self, __attr _data); 13.63 13.64 /* Module initialisation. */ 13.65
14.1 --- a/templates/native/introspection.c Thu Nov 04 23:44:29 2021 +0100 14.2 +++ b/templates/native/introspection.c Tue Aug 29 01:46:23 2023 +0200 14.3 @@ -1,6 +1,6 @@ 14.4 /* Native functions for introspection operations. 14.5 14.6 -Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk> 14.7 +Copyright (C) 2016, 2017, 2023 Paul Boddie <paul@boddie.org.uk> 14.8 14.9 This program is free software; you can redistribute it and/or modify it under 14.10 the terms of the GNU General Public License as published by the Free Software 14.11 @@ -26,7 +26,7 @@ 14.12 14.13 /* Introspection. */ 14.14 14.15 -__attr __fn_native_introspection_object_getattr(__attr __self, __attr obj, __attr name, __attr _default) 14.16 +__attr __fn_native_introspection_object_getattr(__attr __result, __attr __self, __attr obj, __attr name, __attr _default) 14.17 { 14.18 /* name interpreted as string */ 14.19 __attr key = __load_via_object(__VALUE(name), __key__); 14.20 @@ -54,7 +54,7 @@ 14.21 return out; 14.22 } 14.23 14.24 -__attr __fn_native_introspection_isinstance(__attr __self, __attr obj, __attr cls) 14.25 +__attr __fn_native_introspection_isinstance(__attr __result, __attr __self, __attr obj, __attr cls) 14.26 { 14.27 /* cls must be a class. */ 14.28 if (__is_instance_subclass(__VALUE(obj), cls)) 14.29 @@ -63,7 +63,7 @@ 14.30 return __builtins___boolean_False; 14.31 } 14.32 14.33 -__attr __fn_native_introspection_issubclass(__attr __self, __attr obj, __attr cls) 14.34 +__attr __fn_native_introspection_issubclass(__attr __result, __attr __self, __attr obj, __attr cls) 14.35 { 14.36 /* obj and cls must be classes. */ 14.37 if (__is_subclass(__VALUE(obj), cls))
15.1 --- a/templates/native/introspection.h Thu Nov 04 23:44:29 2021 +0100 15.2 +++ b/templates/native/introspection.h Tue Aug 29 01:46:23 2023 +0200 15.3 @@ -1,6 +1,6 @@ 15.4 /* Native functions for introspection. 15.5 15.6 -Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk> 15.7 +Copyright (C) 2016, 2017, 2023 Paul Boddie <paul@boddie.org.uk> 15.8 15.9 This program is free software; you can redistribute it and/or modify it under 15.10 the terms of the GNU General Public License as published by the Free Software 15.11 @@ -23,9 +23,9 @@ 15.12 15.13 /* Introspection. */ 15.14 15.15 -__attr __fn_native_introspection_object_getattr(__attr __self, __attr obj, __attr name, __attr _default); 15.16 -__attr __fn_native_introspection_isinstance(__attr __self, __attr obj, __attr cls); 15.17 -__attr __fn_native_introspection_issubclass(__attr __self, __attr obj, __attr cls); 15.18 +__attr __fn_native_introspection_object_getattr(__attr __result, __attr __self, __attr obj, __attr name, __attr _default); 15.19 +__attr __fn_native_introspection_isinstance(__attr __result, __attr __self, __attr obj, __attr cls); 15.20 +__attr __fn_native_introspection_issubclass(__attr __result, __attr __self, __attr obj, __attr cls); 15.21 15.22 /* Module initialisation. */ 15.23
16.1 --- a/templates/native/io.c Thu Nov 04 23:44:29 2021 +0100 16.2 +++ b/templates/native/io.c Tue Aug 29 01:46:23 2023 +0200 16.3 @@ -1,6 +1,6 @@ 16.4 /* Native functions for input/output. 16.5 16.6 -Copyright (C) 2016, 2017, 2021 Paul Boddie <paul@boddie.org.uk> 16.7 +Copyright (C) 2016, 2017, 2021, 2023 Paul Boddie <paul@boddie.org.uk> 16.8 16.9 This program is free software; you can redistribute it and/or modify it under 16.10 the terms of the GNU General Public License as published by the Free Software 16.11 @@ -31,7 +31,7 @@ 16.12 16.13 /* Input/output. */ 16.14 16.15 -__attr __fn_native_io_fclose(__attr __self, __attr fp) 16.16 +__attr __fn_native_io_fclose(__attr __result, __attr __self, __attr fp) 16.17 { 16.18 /* fp interpreted as FILE reference */ 16.19 FILE *f = (FILE *) fp.datavalue; 16.20 @@ -43,7 +43,7 @@ 16.21 return __builtins___none_None; 16.22 } 16.23 16.24 -__attr __fn_native_io_fflush(__attr __self, __attr fp) 16.25 +__attr __fn_native_io_fflush(__attr __result, __attr __self, __attr fp) 16.26 { 16.27 /* fp interpreted as FILE reference */ 16.28 FILE *f = (FILE *) fp.datavalue; 16.29 @@ -55,7 +55,7 @@ 16.30 return __builtins___none_None; 16.31 } 16.32 16.33 -__attr __fn_native_io_fopen(__attr __self, __attr filename, __attr mode) 16.34 +__attr __fn_native_io_fopen(__attr __result, __attr __self, __attr filename, __attr mode) 16.35 { 16.36 /* filename.__data__ interpreted as string */ 16.37 char *fn = __load_via_object(__VALUE(filename), __data__).strvalue; 16.38 @@ -85,7 +85,7 @@ 16.39 return __builtins___none_None; 16.40 } 16.41 16.42 -__attr __fn_native_io_fdopen(__attr __self, __attr fd, __attr mode) 16.43 +__attr __fn_native_io_fdopen(__attr __result, __attr __self, __attr fd, __attr mode) 16.44 { 16.45 /* fd interpreted as int */ 16.46 int i = __TOINT(fd); 16.47 @@ -115,7 +115,7 @@ 16.48 return __builtins___none_None; 16.49 } 16.50 16.51 -__attr __fn_native_io_fread(__attr __self, __attr fp, __attr size) 16.52 +__attr __fn_native_io_fread(__attr __result, __attr __self, __attr fp, __attr size) 16.53 { 16.54 /* fp interpreted as FILE reference */ 16.55 FILE *f = (FILE *) fp.datavalue; 16.56 @@ -143,7 +143,7 @@ 16.57 return __new_str(s, have_read); 16.58 } 16.59 16.60 -__attr __fn_native_io_fwrite(__attr __self, __attr fp, __attr str) 16.61 +__attr __fn_native_io_fwrite(__attr __result, __attr __self, __attr fp, __attr str) 16.62 { 16.63 /* fp interpreted as FILE reference */ 16.64 FILE *f = (FILE *) fp.datavalue; 16.65 @@ -165,7 +165,7 @@ 16.66 return __builtins___none_None; 16.67 } 16.68 16.69 -__attr __fn_native_io_close(__attr __self, __attr fd) 16.70 +__attr __fn_native_io_close(__attr __result, __attr __self, __attr fd) 16.71 { 16.72 /* fd interpreted as int */ 16.73 int i = __TOINT(fd); 16.74 @@ -177,7 +177,7 @@ 16.75 return __builtins___none_None; 16.76 } 16.77 16.78 -__attr __fn_native_io_read(__attr __self, __attr fd, __attr n) 16.79 +__attr __fn_native_io_read(__attr __result, __attr __self, __attr fd, __attr n) 16.80 { 16.81 /* fd interpreted as int */ 16.82 int i = __TOINT(fd); 16.83 @@ -200,7 +200,7 @@ 16.84 return __new_str(s, have_read); 16.85 } 16.86 16.87 -__attr __fn_native_io_write(__attr __self, __attr fd, __attr str) 16.88 +__attr __fn_native_io_write(__attr __result, __attr __self, __attr fd, __attr str) 16.89 { 16.90 /* fd interpreted as int */ 16.91 int i = __TOINT(fd);
17.1 --- a/templates/native/io.h Thu Nov 04 23:44:29 2021 +0100 17.2 +++ b/templates/native/io.h Tue Aug 29 01:46:23 2023 +0200 17.3 @@ -1,6 +1,6 @@ 17.4 /* Native functions for input/output. 17.5 17.6 -Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk> 17.7 +Copyright (C) 2016, 2017, 2023 Paul Boddie <paul@boddie.org.uk> 17.8 17.9 This program is free software; you can redistribute it and/or modify it under 17.10 the terms of the GNU General Public License as published by the Free Software 17.11 @@ -23,15 +23,15 @@ 17.12 17.13 /* Input/output. */ 17.14 17.15 -__attr __fn_native_io_fclose(__attr __self, __attr fp); 17.16 -__attr __fn_native_io_fflush(__attr __self, __attr fp); 17.17 -__attr __fn_native_io_fopen(__attr __self, __attr filename, __attr mode); 17.18 -__attr __fn_native_io_fdopen(__attr __self, __attr fd, __attr mode); 17.19 -__attr __fn_native_io_fread(__attr __self, __attr fp, __attr size); 17.20 -__attr __fn_native_io_fwrite(__attr __self, __attr fp, __attr str); 17.21 -__attr __fn_native_io_close(__attr __self, __attr fd); 17.22 -__attr __fn_native_io_read(__attr __self, __attr fd, __attr n); 17.23 -__attr __fn_native_io_write(__attr __self, __attr fd, __attr str); 17.24 +__attr __fn_native_io_fclose(__attr __result, __attr __self, __attr fp); 17.25 +__attr __fn_native_io_fflush(__attr __result, __attr __self, __attr fp); 17.26 +__attr __fn_native_io_fopen(__attr __result, __attr __self, __attr filename, __attr mode); 17.27 +__attr __fn_native_io_fdopen(__attr __result, __attr __self, __attr fd, __attr mode); 17.28 +__attr __fn_native_io_fread(__attr __result, __attr __self, __attr fp, __attr size); 17.29 +__attr __fn_native_io_fwrite(__attr __result, __attr __self, __attr fp, __attr str); 17.30 +__attr __fn_native_io_close(__attr __result, __attr __self, __attr fd); 17.31 +__attr __fn_native_io_read(__attr __result, __attr __self, __attr fd, __attr n); 17.32 +__attr __fn_native_io_write(__attr __result, __attr __self, __attr fd, __attr str); 17.33 17.34 /* Module initialisation. */ 17.35
18.1 --- a/templates/native/limits.c Thu Nov 04 23:44:29 2021 +0100 18.2 +++ b/templates/native/limits.c Tue Aug 29 01:46:23 2023 +0200 18.3 @@ -1,6 +1,6 @@ 18.4 /* Native functions for limit definition. 18.5 18.6 -Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk> 18.7 +Copyright (C) 2016, 2017, 2023 Paul Boddie <paul@boddie.org.uk> 18.8 18.9 This program is free software; you can redistribute it and/or modify it under 18.10 the terms of the GNU General Public License as published by the Free Software 18.11 @@ -27,12 +27,12 @@ 18.12 18.13 /* Limit definition. */ 18.14 18.15 -__attr __fn_native_limits_get_maxint(__attr __self) 18.16 +__attr __fn_native_limits_get_maxint(__attr __result, __attr __self) 18.17 { 18.18 return __new_int(__MAXINT); 18.19 } 18.20 18.21 -__attr __fn_native_limits_get_minint(__attr __self) 18.22 +__attr __fn_native_limits_get_minint(__attr __result, __attr __self) 18.23 { 18.24 return __new_int(__MININT); 18.25 }
19.1 --- a/templates/native/limits.h Thu Nov 04 23:44:29 2021 +0100 19.2 +++ b/templates/native/limits.h Tue Aug 29 01:46:23 2023 +0200 19.3 @@ -1,6 +1,6 @@ 19.4 /* Native functions for limit definition. 19.5 19.6 -Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk> 19.7 +Copyright (C) 2016, 2017, 2023 Paul Boddie <paul@boddie.org.uk> 19.8 19.9 This program is free software; you can redistribute it and/or modify it under 19.10 the terms of the GNU General Public License as published by the Free Software 19.11 @@ -23,8 +23,8 @@ 19.12 19.13 /* Limit definition. */ 19.14 19.15 -__attr __fn_native_limits_get_maxint(__attr __self); 19.16 -__attr __fn_native_limits_get_minint(__attr __self); 19.17 +__attr __fn_native_limits_get_maxint(__attr __result, __attr __self); 19.18 +__attr __fn_native_limits_get_minint(__attr __result, __attr __self); 19.19 19.20 /* Module initialisation. */ 19.21
20.1 --- a/templates/native/list.c Thu Nov 04 23:44:29 2021 +0100 20.2 +++ b/templates/native/list.c Tue Aug 29 01:46:23 2023 +0200 20.3 @@ -1,6 +1,6 @@ 20.4 /* Native functions for list operations. 20.5 20.6 -Copyright (C) 2016, 2017, 2021 Paul Boddie <paul@boddie.org.uk> 20.7 +Copyright (C) 2016, 2017, 2021, 2023 Paul Boddie <paul@boddie.org.uk> 20.8 20.9 This program is free software; you can redistribute it and/or modify it under 20.10 the terms of the GNU General Public License as published by the Free Software 20.11 @@ -27,7 +27,7 @@ 20.12 20.13 /* List operations. */ 20.14 20.15 -__attr __fn_native_list_list_init(__attr __self, __attr size) 20.16 +__attr __fn_native_list_list_init(__attr __result, __attr __self, __attr size) 20.17 { 20.18 /* size interpreted as int */ 20.19 __int n = __TOINT(size); 20.20 @@ -37,7 +37,7 @@ 20.21 return attr; 20.22 } 20.23 20.24 -__attr __fn_native_list_list_setsize(__attr __self, __attr _data, __attr size) 20.25 +__attr __fn_native_list_list_setsize(__attr __result, __attr __self, __attr _data, __attr size) 20.26 { 20.27 /* _data interpreted as list.__data__ */ 20.28 __fragment *data = _data.seqvalue; 20.29 @@ -48,7 +48,7 @@ 20.30 return __builtins___none_None; 20.31 } 20.32 20.33 -__attr __fn_native_list_list_append(__attr __self, __attr self, __attr value) 20.34 +__attr __fn_native_list_list_append(__attr __result, __attr __self, __attr self, __attr value) 20.35 { 20.36 /* self.__data__ interpreted as list */ 20.37 __fragment *data = __load_via_object(__VALUE(self), __data__).seqvalue; 20.38 @@ -60,7 +60,7 @@ 20.39 return __builtins___none_None; 20.40 } 20.41 20.42 -__attr __fn_native_list_list_concat(__attr __self, __attr self, __attr other) 20.43 +__attr __fn_native_list_list_concat(__attr __result, __attr __self, __attr self, __attr other) 20.44 { 20.45 /* self, interpreted as list, other interpreted as list.__data__ */ 20.46 __fragment *data = __load_via_object(__VALUE(self), __data__).seqvalue; 20.47 @@ -88,7 +88,7 @@ 20.48 return __builtins___none_None; 20.49 } 20.50 20.51 -__attr __fn_native_list_list_len(__attr self, __attr _data) 20.52 +__attr __fn_native_list_list_len(__attr __result, __attr __self, __attr _data) 20.53 { 20.54 /* _data interpreted as list.__data__ */ 20.55 __int size = _data.seqvalue->size; 20.56 @@ -97,12 +97,12 @@ 20.57 return __new_int(size); 20.58 } 20.59 20.60 -__attr __fn_native_list_list_nonempty(__attr __self, __attr _data) 20.61 +__attr __fn_native_list_list_nonempty(__attr __result, __attr __self, __attr _data) 20.62 { 20.63 return _data.seqvalue->size ? __builtins___boolean_True : __builtins___boolean_False; 20.64 } 20.65 20.66 -__attr __fn_native_list_list_element(__attr __self, __attr _data, __attr index) 20.67 +__attr __fn_native_list_list_element(__attr __result, __attr __self, __attr _data, __attr index) 20.68 { 20.69 /* _data interpreted as list.__data__ */ 20.70 __attr *elements = _data.seqvalue->attrs; 20.71 @@ -112,7 +112,7 @@ 20.72 return elements[i]; 20.73 } 20.74 20.75 -__attr __fn_native_list_list_setelement(__attr __self, __attr _data, __attr index, __attr value) 20.76 +__attr __fn_native_list_list_setelement(__attr __result, __attr __self, __attr _data, __attr index, __attr value) 20.77 { 20.78 /* _data interpreted as list.__data__ */ 20.79 __attr *elements = _data.seqvalue->attrs;
21.1 --- a/templates/native/list.h Thu Nov 04 23:44:29 2021 +0100 21.2 +++ b/templates/native/list.h Tue Aug 29 01:46:23 2023 +0200 21.3 @@ -1,6 +1,6 @@ 21.4 /* Native functions for list operations. 21.5 21.6 -Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk> 21.7 +Copyright (C) 2016, 2017, 2023 Paul Boddie <paul@boddie.org.uk> 21.8 21.9 This program is free software; you can redistribute it and/or modify it under 21.10 the terms of the GNU General Public License as published by the Free Software 21.11 @@ -23,14 +23,14 @@ 21.12 21.13 /* List operations. */ 21.14 21.15 -__attr __fn_native_list_list_init(__attr __self, __attr size); 21.16 -__attr __fn_native_list_list_setsize(__attr __self, __attr _data, __attr size); 21.17 -__attr __fn_native_list_list_append(__attr __self, __attr self, __attr value); 21.18 -__attr __fn_native_list_list_concat(__attr __self, __attr self, __attr other); 21.19 -__attr __fn_native_list_list_len(__attr self, __attr _data); 21.20 -__attr __fn_native_list_list_nonempty(__attr __self, __attr _data); 21.21 -__attr __fn_native_list_list_element(__attr __self, __attr _data, __attr index); 21.22 -__attr __fn_native_list_list_setelement(__attr __self, __attr _data, __attr index, __attr value); 21.23 +__attr __fn_native_list_list_init(__attr __result, __attr __self, __attr size); 21.24 +__attr __fn_native_list_list_setsize(__attr __result, __attr __self, __attr _data, __attr size); 21.25 +__attr __fn_native_list_list_append(__attr __result, __attr __self, __attr self, __attr value); 21.26 +__attr __fn_native_list_list_concat(__attr __result, __attr __self, __attr self, __attr other); 21.27 +__attr __fn_native_list_list_len(__attr __result, __attr __self, __attr _data); 21.28 +__attr __fn_native_list_list_nonempty(__attr __result, __attr __self, __attr _data); 21.29 +__attr __fn_native_list_list_element(__attr __result, __attr __self, __attr _data, __attr index); 21.30 +__attr __fn_native_list_list_setelement(__attr __result, __attr __self, __attr _data, __attr index, __attr value); 21.31 21.32 /* Module initialisation. */ 21.33
22.1 --- a/templates/native/locale.c Thu Nov 04 23:44:29 2021 +0100 22.2 +++ b/templates/native/locale.c Tue Aug 29 01:46:23 2023 +0200 22.3 @@ -1,6 +1,6 @@ 22.4 /* Native functions for locale handling. 22.5 22.6 -Copyright (C) 2016, 2017, 2021 Paul Boddie <paul@boddie.org.uk> 22.7 +Copyright (C) 2016, 2017, 2021, 2023 Paul Boddie <paul@boddie.org.uk> 22.8 22.9 This program is free software; you can redistribute it and/or modify it under 22.10 the terms of the GNU General Public License as published by the Free Software 22.11 @@ -29,7 +29,7 @@ 22.12 22.13 /* Locales. */ 22.14 22.15 -__attr __fn_native_locale_getlocale(__attr __self, __attr category) 22.16 +__attr __fn_native_locale_getlocale(__attr __result, __attr __self, __attr category) 22.17 { 22.18 /* category interpreted as int */ 22.19 int cat = __TOINT(category); 22.20 @@ -48,7 +48,7 @@ 22.21 return __new_str(result, length); 22.22 } 22.23 22.24 -__attr __fn_native_locale_setlocale(__attr __self, __attr category, __attr value) 22.25 +__attr __fn_native_locale_setlocale(__attr __result, __attr __self, __attr category, __attr value) 22.26 { 22.27 /* category interpreted as int */ 22.28 int cat = __TOINT(category);
23.1 --- a/templates/native/locale.h Thu Nov 04 23:44:29 2021 +0100 23.2 +++ b/templates/native/locale.h Tue Aug 29 01:46:23 2023 +0200 23.3 @@ -1,6 +1,6 @@ 23.4 /* Native functions for locale handling. 23.5 23.6 -Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk> 23.7 +Copyright (C) 2016, 2017, 2023 Paul Boddie <paul@boddie.org.uk> 23.8 23.9 This program is free software; you can redistribute it and/or modify it under 23.10 the terms of the GNU General Public License as published by the Free Software 23.11 @@ -23,8 +23,8 @@ 23.12 23.13 /* Input/output. */ 23.14 23.15 -__attr __fn_native_locale_getlocale(__attr __self, __attr category); 23.16 -__attr __fn_native_locale_setlocale(__attr __self, __attr category, __attr value); 23.17 +__attr __fn_native_locale_getlocale(__attr __result, __attr __self, __attr category); 23.18 +__attr __fn_native_locale_setlocale(__attr __result, __attr __self, __attr category, __attr value); 23.19 23.20 /* Module initialisation. */ 23.21
24.1 --- a/templates/native/program.c Thu Nov 04 23:44:29 2021 +0100 24.2 +++ b/templates/native/program.c Tue Aug 29 01:46:23 2023 +0200 24.3 @@ -1,6 +1,6 @@ 24.4 /* Native functions for program operations. 24.5 24.6 -Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk> 24.7 +Copyright (C) 2016, 2017, 2023 Paul Boddie <paul@boddie.org.uk> 24.8 24.9 This program is free software; you can redistribute it and/or modify it under 24.10 the terms of the GNU General Public License as published by the Free Software 24.11 @@ -26,7 +26,7 @@ 24.12 24.13 /* Method binding. */ 24.14 24.15 -__attr __fn_native_program_get_using(__attr __self, __attr callable, __attr instance) 24.16 +__attr __fn_native_program_get_using(__attr __result, __attr __self, __attr callable, __attr instance) 24.17 { 24.18 return __test_context(instance, callable); 24.19 }
25.1 --- a/templates/native/program.h Thu Nov 04 23:44:29 2021 +0100 25.2 +++ b/templates/native/program.h Tue Aug 29 01:46:23 2023 +0200 25.3 @@ -1,6 +1,6 @@ 25.4 /* Native functions for program operations. 25.5 25.6 -Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk> 25.7 +Copyright (C) 2016, 2017, 2023 Paul Boddie <paul@boddie.org.uk> 25.8 25.9 This program is free software; you can redistribute it and/or modify it under 25.10 the terms of the GNU General Public License as published by the Free Software 25.11 @@ -21,7 +21,7 @@ 25.12 25.13 /* Method binding. */ 25.14 25.15 -__attr __fn_native_program_get_using(__attr __self, __attr callable, __attr instance); 25.16 +__attr __fn_native_program_get_using(__attr __result, __attr __self, __attr callable, __attr instance); 25.17 25.18 /* Module initialisation. */ 25.19
26.1 --- a/templates/native/str.c Thu Nov 04 23:44:29 2021 +0100 26.2 +++ b/templates/native/str.c Tue Aug 29 01:46:23 2023 +0200 26.3 @@ -1,6 +1,6 @@ 26.4 /* Native functions for string operations. 26.5 26.6 -Copyright (C) 2016, 2017, 2021 Paul Boddie <paul@boddie.org.uk> 26.7 +Copyright (C) 2016, 2017, 2021, 2023 Paul Boddie <paul@boddie.org.uk> 26.8 26.9 This program is free software; you can redistribute it and/or modify it under 26.10 the terms of the GNU General Public License as published by the Free Software 26.11 @@ -28,7 +28,7 @@ 26.12 26.13 /* String operations. */ 26.14 26.15 -__attr __fn_native_str_str_add(__attr __self, __attr _data, __attr other, __attr _size, __attr othersize) 26.16 +__attr __fn_native_str_str_add(__attr __result, __attr __self, __attr _data, __attr other, __attr _size, __attr othersize) 26.17 { 26.18 /* _data, other interpreted as string.__data__ */ 26.19 char *s = _data.strvalue; 26.20 @@ -45,7 +45,7 @@ 26.21 return __new_str(r, n); 26.22 } 26.23 26.24 -__attr __fn_native_str_str_chr(__attr __self, __attr _data) 26.25 +__attr __fn_native_str_str_chr(__attr __result, __attr __self, __attr _data) 26.26 { 26.27 /* data interpreted as int */ 26.28 int n = __TOINT(_data); 26.29 @@ -55,7 +55,7 @@ 26.30 return __new_str(s, 1); 26.31 } 26.32 26.33 -__attr __fn_native_str_str_lt(__attr __self, __attr _data, __attr other) 26.34 +__attr __fn_native_str_str_lt(__attr __result, __attr __self, __attr _data, __attr other) 26.35 { 26.36 /* _data, other interpreted as string.__data__ */ 26.37 char *s = _data.strvalue; 26.38 @@ -65,7 +65,7 @@ 26.39 return strcmp(s, o) < 0 ? __builtins___boolean_True : __builtins___boolean_False; 26.40 } 26.41 26.42 -__attr __fn_native_str_str_gt(__attr __self, __attr _data, __attr other) 26.43 +__attr __fn_native_str_str_gt(__attr __result, __attr __self, __attr _data, __attr other) 26.44 { 26.45 /* _data, other interpreted as string.__data__ */ 26.46 char *s = _data.strvalue; 26.47 @@ -75,7 +75,7 @@ 26.48 return strcmp(s, o) > 0 ? __builtins___boolean_True : __builtins___boolean_False; 26.49 } 26.50 26.51 -__attr __fn_native_str_str_eq(__attr __self, __attr _data, __attr other) 26.52 +__attr __fn_native_str_str_eq(__attr __result, __attr __self, __attr _data, __attr other) 26.53 { 26.54 /* _data, other interpreted as string.__data__ */ 26.55 char *s = _data.strvalue; 26.56 @@ -85,7 +85,7 @@ 26.57 return strcmp(s, o) == 0 ? __builtins___boolean_True : __builtins___boolean_False; 26.58 } 26.59 26.60 -__attr __fn_native_str_str_ord(__attr __self, __attr _data) 26.61 +__attr __fn_native_str_str_ord(__attr __result, __attr __self, __attr _data) 26.62 { 26.63 /* _data interpreted as string.__data__ */ 26.64 char *s = _data.strvalue; 26.65 @@ -93,12 +93,12 @@ 26.66 return __new_int((__int) s[0]); 26.67 } 26.68 26.69 -__attr __fn_native_str_str_size(__attr __self, __attr _size) 26.70 +__attr __fn_native_str_str_size(__attr __result, __attr __self, __attr _size) 26.71 { 26.72 return __new_int(_size.sizevalue); 26.73 } 26.74 26.75 -__attr __fn_native_str_str_substr(__attr __self, __attr _data, __attr start, __attr end, __attr step) 26.76 +__attr __fn_native_str_str_substr(__attr __result, __attr __self, __attr _data, __attr start, __attr end, __attr step) 26.77 { 26.78 /* _data interpreted as string.__data__ */ 26.79 char *s = _data.strvalue, *sub;
27.1 --- a/templates/native/str.h Thu Nov 04 23:44:29 2021 +0100 27.2 +++ b/templates/native/str.h Tue Aug 29 01:46:23 2023 +0200 27.3 @@ -1,6 +1,6 @@ 27.4 /* Native functions for string operations. 27.5 27.6 -Copyright (C) 2016, 2017, 2021 Paul Boddie <paul@boddie.org.uk> 27.7 +Copyright (C) 2016, 2017, 2021, 2023 Paul Boddie <paul@boddie.org.uk> 27.8 27.9 This program is free software; you can redistribute it and/or modify it under 27.10 the terms of the GNU General Public License as published by the Free Software 27.11 @@ -21,14 +21,14 @@ 27.12 27.13 /* String operations. */ 27.14 27.15 -__attr __fn_native_str_str_add(__attr __self, __attr _data, __attr other, __attr _size, __attr othersize); 27.16 -__attr __fn_native_str_str_chr(__attr __self, __attr _data); 27.17 -__attr __fn_native_str_str_lt(__attr __self, __attr _data, __attr other); 27.18 -__attr __fn_native_str_str_gt(__attr __self, __attr _data, __attr other); 27.19 -__attr __fn_native_str_str_eq(__attr __self, __attr _data, __attr other); 27.20 -__attr __fn_native_str_str_ord(__attr __self, __attr _data); 27.21 -__attr __fn_native_str_str_size(__attr __self); 27.22 -__attr __fn_native_str_str_substr(__attr __self, __attr _data, __attr start, __attr end, __attr step); 27.23 +__attr __fn_native_str_str_add(__attr __result, __attr __self, __attr _data, __attr other, __attr _size, __attr othersize); 27.24 +__attr __fn_native_str_str_chr(__attr __result, __attr __self, __attr _data); 27.25 +__attr __fn_native_str_str_lt(__attr __result, __attr __self, __attr _data, __attr other); 27.26 +__attr __fn_native_str_str_gt(__attr __result, __attr __self, __attr _data, __attr other); 27.27 +__attr __fn_native_str_str_eq(__attr __result, __attr __self, __attr _data, __attr other); 27.28 +__attr __fn_native_str_str_ord(__attr __result, __attr __self, __attr _data); 27.29 +__attr __fn_native_str_str_size(__attr __result, __attr __self); 27.30 +__attr __fn_native_str_str_substr(__attr __result, __attr __self, __attr _data, __attr start, __attr end, __attr step); 27.31 27.32 /* Module initialisation. */ 27.33
28.1 --- a/templates/native/system.c Thu Nov 04 23:44:29 2021 +0100 28.2 +++ b/templates/native/system.c Tue Aug 29 01:46:23 2023 +0200 28.3 @@ -1,6 +1,6 @@ 28.4 /* Native functions for system operations. 28.5 28.6 -Copyright (C) 2016, 2017, 2021 Paul Boddie <paul@boddie.org.uk> 28.7 +Copyright (C) 2016, 2017, 2021, 2023 Paul Boddie <paul@boddie.org.uk> 28.8 28.9 This program is free software; you can redistribute it and/or modify it under 28.10 the terms of the GNU General Public License as published by the Free Software 28.11 @@ -27,19 +27,19 @@ 28.12 28.13 /* Environment support. */ 28.14 28.15 -__attr __fn_native_system_exit(__attr __self, __attr status) 28.16 +__attr __fn_native_system_exit(__attr __result, __attr __self, __attr status) 28.17 { 28.18 exit(__TOINT(status)); 28.19 return __builtins___none_None; 28.20 } 28.21 28.22 -__attr __fn_native_system_get_argv(__attr __self) 28.23 +__attr __fn_native_system_get_argv(__attr __result, __attr __self) 28.24 { 28.25 /* NOTE: To be written. */ 28.26 return __builtins___none_None; 28.27 } 28.28 28.29 -__attr __fn_native_system_get_path(__attr __self) 28.30 +__attr __fn_native_system_get_path(__attr __result, __attr __self) 28.31 { 28.32 /* NOTE: To be written. */ 28.33 return __builtins___none_None;
29.1 --- a/templates/native/system.h Thu Nov 04 23:44:29 2021 +0100 29.2 +++ b/templates/native/system.h Tue Aug 29 01:46:23 2023 +0200 29.3 @@ -1,6 +1,6 @@ 29.4 /* Native functions for system operations. 29.5 29.6 -Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk> 29.7 +Copyright (C) 2016, 2017, 2023 Paul Boddie <paul@boddie.org.uk> 29.8 29.9 This program is free software; you can redistribute it and/or modify it under 29.10 the terms of the GNU General Public License as published by the Free Software 29.11 @@ -23,9 +23,9 @@ 29.12 29.13 /* Environment support. */ 29.14 29.15 -__attr __fn_native_system_exit(__attr __self, __attr status); 29.16 -__attr __fn_native_system_get_argv(__attr __self); 29.17 -__attr __fn_native_system_get_path(__attr __self); 29.18 +__attr __fn_native_system_exit(__attr __result, __attr __self, __attr status); 29.19 +__attr __fn_native_system_get_argv(__attr __result, __attr __self); 29.20 +__attr __fn_native_system_get_path(__attr __result, __attr __self); 29.21 29.22 /* Module initialisation. */ 29.23
30.1 --- a/templates/native/tuple.c Thu Nov 04 23:44:29 2021 +0100 30.2 +++ b/templates/native/tuple.c Tue Aug 29 01:46:23 2023 +0200 30.3 @@ -1,6 +1,6 @@ 30.4 /* Native functions for tuple operations. 30.5 30.6 -Copyright (C) 2016, 2017, 2021 Paul Boddie <paul@boddie.org.uk> 30.7 +Copyright (C) 2016, 2017, 2021, 2023 Paul Boddie <paul@boddie.org.uk> 30.8 30.9 This program is free software; you can redistribute it and/or modify it under 30.10 the terms of the GNU General Public License as published by the Free Software 30.11 @@ -29,7 +29,7 @@ 30.12 30.13 static __fragment __empty_fragment = {.size=0, .capacity=0}; 30.14 30.15 -__attr __fn_native_tuple_tuple_init(__attr __self, __attr size) 30.16 +__attr __fn_native_tuple_tuple_init(__attr __result, __attr __self, __attr size) 30.17 { 30.18 /* size interpreted as int */ 30.19 __int n = __TOINT(size);
31.1 --- a/templates/native/tuple.h Thu Nov 04 23:44:29 2021 +0100 31.2 +++ b/templates/native/tuple.h Tue Aug 29 01:46:23 2023 +0200 31.3 @@ -1,6 +1,6 @@ 31.4 /* Native functions for tuple operations. 31.5 31.6 -Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk> 31.7 +Copyright (C) 2016, 2017, 2023 Paul Boddie <paul@boddie.org.uk> 31.8 31.9 This program is free software; you can redistribute it and/or modify it under 31.10 the terms of the GNU General Public License as published by the Free Software 31.11 @@ -23,7 +23,7 @@ 31.12 31.13 /* List operations. */ 31.14 31.15 -__attr __fn_native_tuple_tuple_init(__attr __self, __attr size); 31.16 +__attr __fn_native_tuple_tuple_init(__attr __result, __attr __self, __attr size); 31.17 31.18 /* Module initialisation. */ 31.19
32.1 --- a/templates/native/unicode.c Thu Nov 04 23:44:29 2021 +0100 32.2 +++ b/templates/native/unicode.c Tue Aug 29 01:46:23 2023 +0200 32.3 @@ -1,6 +1,6 @@ 32.4 /* Native functions for Unicode operations. 32.5 32.6 -Copyright (C) 2016, 2017, 2021 Paul Boddie <paul@boddie.org.uk> 32.7 +Copyright (C) 2016, 2017, 2021, 2023 Paul Boddie <paul@boddie.org.uk> 32.8 32.9 This program is free software; you can redistribute it and/or modify it under 32.10 the terms of the GNU General Public License as published by the Free Software 32.11 @@ -69,7 +69,7 @@ 32.12 32.13 /* Unicode operations. */ 32.14 32.15 -__attr __fn_native_unicode_unicode_len(__attr __self, __attr _data, __attr _size) 32.16 +__attr __fn_native_unicode_unicode_len(__attr __result, __attr __self, __attr _data, __attr _size) 32.17 { 32.18 /* _data interpreted as string.__data__ */ 32.19 char *s = _data.strvalue; 32.20 @@ -85,7 +85,7 @@ 32.21 return __new_int(c); 32.22 } 32.23 32.24 -__attr __fn_native_unicode_unicode_ord(__attr __self, __attr _data, __attr _size) 32.25 +__attr __fn_native_unicode_unicode_ord(__attr __result, __attr __self, __attr _data, __attr _size) 32.26 { 32.27 /* _data interpreted as string.__data__ */ 32.28 char *s = _data.strvalue; 32.29 @@ -119,7 +119,7 @@ 32.30 return __new_int(c); 32.31 } 32.32 32.33 -__attr __fn_native_unicode_unicode_substr(__attr __self, __attr _data, __attr _size, __attr start, __attr end, __attr step) 32.34 +__attr __fn_native_unicode_unicode_substr(__attr __result, __attr __self, __attr _data, __attr _size, __attr start, __attr end, __attr step) 32.35 { 32.36 /* _data interpreted as string.__data__ */ 32.37 char *s = _data.strvalue, *sub; 32.38 @@ -193,7 +193,7 @@ 32.39 return __new_str(sub, resultsize); 32.40 } 32.41 32.42 -__attr __fn_native_unicode_unicode_unichr(__attr __self, __attr value) 32.43 +__attr __fn_native_unicode_unicode_unichr(__attr __result, __attr __self, __attr value) 32.44 { 32.45 /* value interpreted as int */ 32.46 int i = __TOINT(value);
33.1 --- a/templates/native/unicode.h Thu Nov 04 23:44:29 2021 +0100 33.2 +++ b/templates/native/unicode.h Tue Aug 29 01:46:23 2023 +0200 33.3 @@ -1,6 +1,6 @@ 33.4 /* Native functions for Unicode operations. 33.5 33.6 -Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk> 33.7 +Copyright (C) 2016, 2017, 2023 Paul Boddie <paul@boddie.org.uk> 33.8 33.9 This program is free software; you can redistribute it and/or modify it under 33.10 the terms of the GNU General Public License as published by the Free Software 33.11 @@ -21,10 +21,10 @@ 33.12 33.13 /* Unicode operations. */ 33.14 33.15 -__attr __fn_native_unicode_unicode_len(__attr __self, __attr _data, __attr _size); 33.16 -__attr __fn_native_unicode_unicode_ord(__attr __self, __attr _data, __attr _size); 33.17 -__attr __fn_native_unicode_unicode_substr(__attr __self, __attr _data, __attr _size, __attr start, __attr end, __attr step); 33.18 -__attr __fn_native_unicode_unicode_unichr(__attr __self, __attr value); 33.19 +__attr __fn_native_unicode_unicode_len(__attr __result, __attr __self, __attr _data, __attr _size); 33.20 +__attr __fn_native_unicode_unicode_ord(__attr __result, __attr __self, __attr _data, __attr _size); 33.21 +__attr __fn_native_unicode_unicode_substr(__attr __result, __attr __self, __attr _data, __attr _size, __attr start, __attr end, __attr step); 33.22 +__attr __fn_native_unicode_unicode_unichr(__attr __result, __attr __self, __attr value); 33.23 33.24 /* Module initialisation. */ 33.25
34.1 --- a/templates/ops.c Thu Nov 04 23:44:29 2021 +0100 34.2 +++ b/templates/ops.c Tue Aug 29 01:46:23 2023 +0200 34.3 @@ -1,6 +1,6 @@ 34.4 /* Common operations. 34.5 34.6 -Copyright (C) 2015, 2016, 2017, 2018 Paul Boddie <paul@boddie.org.uk> 34.7 +Copyright (C) 2015, 2016, 2017, 2018, 2023 Paul Boddie <paul@boddie.org.uk> 34.8 34.9 This program is free software; you can redistribute it and/or modify it under 34.10 the terms of the GNU General Public License as published by the Free Software 34.11 @@ -447,3 +447,38 @@ 34.12 memcpy(copy, obj, size); 34.13 return copy; 34.14 } 34.15 + 34.16 +/* Return a suitable attribute for a local. For locals that support value 34.17 + replacement, a copied object may be returned in certain cases. 34.18 + NOTE: Only floats are currently supported for value replacement. */ 34.19 + 34.20 +void __set_local(volatile __attr *local, __attr attr) 34.21 +{ 34.22 + __ref obj; 34.23 + 34.24 + /* Value already replaced in target by an operation. */ 34.25 + 34.26 + if (__REPLACING(attr)) 34.27 + return; 34.28 + 34.29 + obj = __VALUE(attr); 34.30 + 34.31 + /* Value not replaceable, suitable for direct propagation to a local. */ 34.32 + 34.33 + if ((obj == NULL) || !__is_instance(obj) || (__get_class(obj) != &__builtins___float_float)) 34.34 + *local = attr; 34.35 + 34.36 + /* Value is replaceable and should be copied to avoid inadvertent 34.37 + sharing. */ 34.38 + 34.39 + else 34.40 + *local = __ATTRVALUE(__COPY(obj, sizeof(__obj___builtins___float_float))); 34.41 +} 34.42 + 34.43 +/* Make sure that attributes indicating value replacement are usable as 34.44 + arguments. */ 34.45 + 34.46 +__attr __to_arg(__attr attr) 34.47 +{ 34.48 + return __REPLACING(attr) ? __REPLACED(attr) : attr; 34.49 +}
35.1 --- a/templates/ops.h Thu Nov 04 23:44:29 2021 +0100 35.2 +++ b/templates/ops.h Tue Aug 29 01:46:23 2023 +0200 35.3 @@ -1,6 +1,6 @@ 35.4 /* Common operations. 35.5 35.6 -Copyright (C) 2015, 2016, 2017, 2018 Paul Boddie <paul@boddie.org.uk> 35.7 +Copyright (C) 2015, 2016, 2017, 2018, 2023 Paul Boddie <paul@boddie.org.uk> 35.8 35.9 This program is free software; you can redistribute it and/or modify it under 35.10 the terms of the GNU General Public License as published by the Free Software 35.11 @@ -136,7 +136,7 @@ 35.12 35.13 __ref __ISFUNC(__ref obj); 35.14 35.15 -#define __ISNULL(__ATTR) (!__ATTR.value) 35.16 +#define __ISNULL(__ATTR) (!(__ATTR).value) 35.17 35.18 /* Attribute codes and positions for type objects. */ 35.19 35.20 @@ -153,4 +153,9 @@ 35.21 35.22 __ref __COPY(__ref obj, int size); 35.23 35.24 +/* Result target administration for potential value replacement. */ 35.25 + 35.26 +void __set_local(volatile __attr *local, __attr attr); 35.27 +__attr __to_arg(__attr attr); 35.28 + 35.29 #endif /* __OPS_H__ */
36.1 --- a/templates/progops.c Thu Nov 04 23:44:29 2021 +0100 36.2 +++ b/templates/progops.c Tue Aug 29 01:46:23 2023 +0200 36.3 @@ -1,6 +1,6 @@ 36.4 /* Operations depending on program specifics. 36.5 36.6 -Copyright (C) 2015-2019, 2021 Paul Boddie <paul@boddie.org.uk> 36.7 +Copyright (C) 2015-2019, 2021, 2023 Paul Boddie <paul@boddie.org.uk> 36.8 36.9 This program is free software; you can redistribute it and/or modify it under 36.10 the terms of the GNU General Public License as published by the Free Software 36.11 @@ -44,7 +44,7 @@ 36.12 36.13 __attr __new_wrapper(__attr context, __attr attr) 36.14 { 36.15 - return __new___builtins___core_wrapper(__NULL, context, attr); 36.16 + return __new___builtins___core_wrapper(__NULL, __NULL, context, attr); 36.17 } 36.18 36.19 /* Generic internal data allocation. */ 36.20 @@ -113,7 +113,7 @@ 36.21 36.22 /* Call __init__ with the dict object and list argument. */ 36.23 36.24 - __fn___builtins___dict_dict___init__(self, tmp); 36.25 + __fn___builtins___dict_dict___init__(__NULL, self, tmp); 36.26 return self; 36.27 } 36.28 #endif /* __HAVE___builtins___dict_dict */ 36.29 @@ -123,73 +123,73 @@ 36.30 void __raise_eof_error() 36.31 { 36.32 #ifdef __HAVE___builtins___exception_io_EOFError 36.33 - __Raise(__new___builtins___exception_io_EOFError(__NULL)); 36.34 + __Raise(__new___builtins___exception_io_EOFError(__NULL, __NULL)); 36.35 #endif /* __HAVE___builtins___exception_io_EOFError */ 36.36 } 36.37 36.38 void __raise_floating_point_error() 36.39 { 36.40 - __Raise(__new___builtins___core_FloatingPointError(__NULL)); 36.41 + __Raise(__new___builtins___core_FloatingPointError(__NULL, __NULL)); 36.42 } 36.43 36.44 void __raise_io_error(__attr value) 36.45 { 36.46 #ifdef __HAVE___builtins___exception_io_IOError 36.47 - __Raise(__new___builtins___exception_io_IOError(__NULL, value)); 36.48 + __Raise(__new___builtins___exception_io_IOError(__NULL, __NULL, value)); 36.49 #endif /* __HAVE___builtins___exception_io_IOError */ 36.50 } 36.51 36.52 void __raise_memory_error() 36.53 { 36.54 - __Raise(__new___builtins___core_MemoryError(__NULL)); 36.55 + __Raise(__new___builtins___core_MemoryError(__NULL, __NULL)); 36.56 } 36.57 36.58 void __raise_os_error(__attr value, __attr arg) 36.59 { 36.60 #ifdef __HAVE___builtins___exception_system_OSError 36.61 - __Raise(__new___builtins___exception_system_OSError(__NULL, value, arg)); 36.62 + __Raise(__new___builtins___exception_system_OSError(__NULL, __NULL, value, arg)); 36.63 #endif /* __HAVE___builtins___exception_system_OSError */ 36.64 } 36.65 36.66 void __raise_overflow_error() 36.67 { 36.68 - __Raise(__new___builtins___core_OverflowError(__NULL)); 36.69 + __Raise(__new___builtins___core_OverflowError(__NULL, __NULL)); 36.70 } 36.71 36.72 void __raise_unbound_method_error() 36.73 { 36.74 - __Raise(__new___builtins___core_UnboundMethodInvocation(__NULL)); 36.75 + __Raise(__new___builtins___core_UnboundMethodInvocation(__NULL, __NULL)); 36.76 } 36.77 36.78 void __raise_type_error() 36.79 { 36.80 - __Raise(__new___builtins___core_TypeError(__NULL)); 36.81 + __Raise(__new___builtins___core_TypeError(__NULL, __NULL)); 36.82 } 36.83 36.84 void __raise_underflow_error() 36.85 { 36.86 - __Raise(__new___builtins___core_UnderflowError(__NULL)); 36.87 + __Raise(__new___builtins___core_UnderflowError(__NULL, __NULL)); 36.88 } 36.89 36.90 void __raise_value_error(__attr value) 36.91 { 36.92 #ifdef __HAVE___builtins___exception_base_ValueError 36.93 - __Raise(__new___builtins___exception_base_ValueError(__NULL, value)); 36.94 + __Raise(__new___builtins___exception_base_ValueError(__NULL, __NULL, value)); 36.95 #endif /* __HAVE___builtins___exception_base_ValueError */ 36.96 } 36.97 36.98 void __raise_zero_division_error() 36.99 { 36.100 - __Raise(__new___builtins___core_ZeroDivisionError(__NULL)); 36.101 + __Raise(__new___builtins___core_ZeroDivisionError(__NULL, __NULL)); 36.102 } 36.103 36.104 /* Helper for raising exception instances. */ 36.105 36.106 __attr __ensure_instance(__attr arg) 36.107 { 36.108 - /* Reserve space for the instance. */ 36.109 + /* Reserve space for the result target and instance. */ 36.110 36.111 - __attr args[1] = {__NULL}; 36.112 + __attr args[2] = {__NULL, __NULL}; 36.113 36.114 /* Return instances as provided. */ 36.115 36.116 @@ -199,7 +199,7 @@ 36.117 /* Invoke non-instances to produce instances. */ 36.118 36.119 else 36.120 - return __invoke(arg, 0, 0, 0, 0, 1, args); 36.121 + return __invoke(arg, 0, 0, 0, 0, 2, args); 36.122 } 36.123 36.124 /* Generic invocation operations. */ 36.125 @@ -294,16 +294,20 @@ 36.126 36.127 return __call_with_args( 36.128 always_callable ? 36.129 - __get_function_unwrapped(allargs[0], target) : 36.130 - __check_and_get_function_unwrapped(allargs[0], target), 36.131 + 36.132 + /* Remember that the arguments start with the result target and then 36.133 + the context. */ 36.134 + 36.135 + __get_function_unwrapped(allargs[1], target) : 36.136 + __check_and_get_function_unwrapped(allargs[1], target), 36.137 allargs, max); 36.138 } 36.139 36.140 /* Error routines. */ 36.141 36.142 -__attr __unbound_method(__attr __self) 36.143 +__attr __unbound_method(__attr __result, __attr __self) 36.144 { 36.145 - __Raise(__new___builtins___core_UnboundMethodInvocation(__NULL)); 36.146 + __Raise(__new___builtins___core_UnboundMethodInvocation(__NULL, __NULL)); 36.147 return __builtins___none_None; /* superfluous */ 36.148 } 36.149 36.150 @@ -336,5 +340,5 @@ 36.151 36.152 return value == (__ref) &__predefined___builtins___boolean_True ? 1 : 36.153 value == (__ref) &__predefined___builtins___boolean_False ? 0 : 36.154 - __VALUE(__fn___builtins___boolean_bool(__NULL, attr)) == (__ref) &__predefined___builtins___boolean_True; 36.155 + __VALUE(__fn___builtins___boolean_bool(__NULL, __NULL, attr)) == (__ref) &__predefined___builtins___boolean_True; 36.156 }
37.1 --- a/templates/progops.h Thu Nov 04 23:44:29 2021 +0100 37.2 +++ b/templates/progops.h Tue Aug 29 01:46:23 2023 +0200 37.3 @@ -1,6 +1,6 @@ 37.4 /* Operations depending on program specifics. 37.5 37.6 -Copyright (C) 2015-2019, 2021 Paul Boddie <paul@boddie.org.uk> 37.7 +Copyright (C) 2015-2019, 2021, 2023 Paul Boddie <paul@boddie.org.uk> 37.8 37.9 This program is free software; you can redistribute it and/or modify it under 37.10 the terms of the GNU General Public License as published by the Free Software 37.11 @@ -71,7 +71,7 @@ 37.12 37.13 /* Error routines. */ 37.14 37.15 -__attr __unbound_method(__attr __self); 37.16 +__attr __unbound_method(__attr __result, __attr __self); 37.17 37.18 /* Generic operations depending on specific program details. */ 37.19 37.20 @@ -86,7 +86,7 @@ 37.21 #define __INSTANCETABLE(CLS) (__InstanceTable_##CLS) 37.22 #define __NEWINSTANCE(CLS) __new(&__INSTANCETABLE(CLS), &CLS, __INSTANCESIZE(CLS), 0) 37.23 #define __NEWINSTANCEIM(CLS) __new(&__INSTANCETABLE(CLS), &CLS, __INSTANCESIZE(CLS), 1) 37.24 -#define __ISINSTANCE(ATTR, TYPE) __BOOL(__fn_native_introspection_isinstance(__NULL, ATTR, TYPE)) 37.25 +#define __ISINSTANCE(ATTR, TYPE) __BOOL(__fn_native_introspection_isinstance(__NULL, __NULL, ATTR, TYPE)) 37.26 37.27 /* Operations for accessing trailing data. */ 37.28
38.1 --- a/templates/types.h Thu Nov 04 23:44:29 2021 +0100 38.2 +++ b/templates/types.h Tue Aug 29 01:46:23 2023 +0200 38.3 @@ -1,6 +1,6 @@ 38.4 /* Runtime types. 38.5 38.6 -Copyright (C) 2015-2019, 2021 Paul Boddie <paul@boddie.org.uk> 38.7 +Copyright (C) 2015-2019, 2021, 2023 Paul Boddie <paul@boddie.org.uk> 38.8 38.9 This program is free software; you can redistribute it and/or modify it under 38.10 the terms of the GNU General Public License as published by the Free Software 38.11 @@ -75,6 +75,10 @@ 38.12 38.13 typedef ssize_t __int; 38.14 38.15 +/* Introduce a tagged pointer type. */ 38.16 + 38.17 +typedef uintptr_t __ref_tagged; 38.18 + 38.19 /* Attribute value interpretations. */ 38.20 38.21 typedef union __attr 38.22 @@ -83,6 +87,7 @@ 38.23 38.24 __ref value; /* attribute value */ 38.25 __int intvalue; /* integer value data (shifted value, tagged) */ 38.26 + __ref_tagged refvalue; /* attribute value with tag */ 38.27 38.28 /* Special case attribute members. */ 38.29 38.30 @@ -127,8 +132,8 @@ 38.31 38.32 #define __NUM_TAG_BITS 2 38.33 #define __TAG_INT 0b01 38.34 -#define __TAG_MASK 0b11 38.35 -#define __INTEGER(ATTR) (((ATTR).intvalue & __TAG_MASK) == __TAG_INT) 38.36 +#define __TAG_REPLACING 0b10 38.37 +#define __INTEGER(ATTR) ((ATTR).intvalue & __TAG_INT) 38.38 38.39 /* Attribute value setting. */ 38.40 38.41 @@ -143,6 +148,12 @@ 38.42 #define __MAXINT ((((__int) 1) << ((sizeof(__int) * 8) - 1 - __NUM_TAG_BITS)) - 1) 38.43 #define __MININT (-(((__int) 1) << ((sizeof(__int) * 8) - 1 - __NUM_TAG_BITS))) 38.44 38.45 +/* Attribute carrying replacement value. */ 38.46 + 38.47 +#define __REPLACEMENT(ATTR) ((__attr) {.refvalue=(((__ref_tagged) (ATTR).value) | __TAG_REPLACING)}) 38.48 +#define __REPLACED(ATTR) ((__attr) {.value=((__ref) ((ATTR).refvalue & ~__TAG_REPLACING))}) 38.49 +#define __REPLACING(ATTR) ((ATTR).refvalue & __TAG_REPLACING) 38.50 + 38.51 /* Argument lists. */ 38.52 38.53 #define __ARGS(...) ((__attr[]) {__VA_ARGS__})
39.1 --- a/translator.py Thu Nov 04 23:44:29 2021 +0100 39.2 +++ b/translator.py Tue Aug 29 01:46:23 2023 +0200 39.3 @@ -3,7 +3,7 @@ 39.4 """ 39.5 Translate programs. 39.6 39.7 -Copyright (C) 2015, 2016, 2017, 2018 Paul Boddie <paul@boddie.org.uk> 39.8 +Copyright (C) 2015, 2016, 2017, 2018, 2023 Paul Boddie <paul@boddie.org.uk> 39.9 39.10 This program is free software; you can redistribute it and/or modify it under 39.11 the terms of the GNU General Public License as published by the Free Software 39.12 @@ -493,7 +493,7 @@ 39.13 # Names and attributes are assigned the entire expression. 39.14 39.15 if isinstance(n, compiler.ast.AssName): 39.16 - name_ref = self.process_name_node(n, self.process_structure_node(expr)) 39.17 + name_ref = self.process_name_node(n, expr, True) 39.18 self.statement(name_ref) 39.19 39.20 # Employ guards after assignments if required. 39.21 @@ -858,6 +858,9 @@ 39.22 self.max_context_index = 0 39.23 self.accessor_index = 0 39.24 self.max_accessor_index = 0 39.25 + self.result_target = 0 39.26 + self.max_result_target = 0 39.27 + self.result_target_name = None 39.28 39.29 # Volatile locals for exception handling. 39.30 39.31 @@ -1280,6 +1283,19 @@ 39.32 if stores_accessor: 39.33 self.record_temp("__tmp_values") 39.34 39.35 + # Employ result targets only in functions. 39.36 + 39.37 + if self.in_function: 39.38 + if self.result_target_name: 39.39 + result_target = self.result_target_name 39.40 + self.result_target_name = None 39.41 + else: 39.42 + result_target = "__tmp_results[%d]" % self.result_target 39.43 + self.record_temp("__tmp_results") 39.44 + self.next_result() 39.45 + else: 39.46 + result_target = "__NULL" 39.47 + 39.48 # Arguments are presented in a temporary frame array with any context 39.49 # always being the first argument. Where it would be unused, it may be 39.50 # set to null. 39.51 @@ -1292,7 +1308,10 @@ 39.52 else: 39.53 context_arg = "__NULL" 39.54 39.55 - args = [context_arg] 39.56 + # Start with result target and context arguments for each invocation. 39.57 + 39.58 + args = [result_target, context_arg] 39.59 + argstart = 2 39.60 39.61 # Complete the array with null values, permitting tests for a complete 39.62 # set of arguments. 39.63 @@ -1323,6 +1342,13 @@ 39.64 for i, arg in enumerate(n.args): 39.65 argexpr = self.process_structure_node(arg) 39.66 39.67 + # Convert any attributes indicating value replacement. 39.68 + 39.69 + if isinstance(argexpr, InvocationResult): 39.70 + argexprstr = "__to_arg(%s)" % argexpr 39.71 + else: 39.72 + argexprstr = str(argexpr) 39.73 + 39.74 # Store a keyword argument, either in the argument list or 39.75 # in a separate keyword argument list for subsequent lookup. 39.76 39.77 @@ -1337,12 +1363,12 @@ 39.78 except ValueError: 39.79 raise TranslateError("Argument %s is not recognised." % arg.name, 39.80 self.get_namespace_path(), n) 39.81 - args[argnum+1] = str(argexpr) 39.82 + args[argnum+argstart] = argexprstr 39.83 39.84 # Otherwise, store the details in a separate collection. 39.85 39.86 else: 39.87 - kwargs.append(str(argexpr)) 39.88 + kwargs.append(argexprstr) 39.89 kwcodes.append("{%s, %s}" % ( 39.90 encode_ppos(arg.name), encode_pcode(arg.name))) 39.91 39.92 @@ -1351,7 +1377,7 @@ 39.93 39.94 else: 39.95 try: 39.96 - args[i+1] = str(argexpr) 39.97 + args[i+argstart] = argexprstr 39.98 except IndexError: 39.99 raise TranslateError("Too many arguments specified.", 39.100 self.get_namespace_path(), n) 39.101 @@ -1375,8 +1401,8 @@ 39.102 39.103 for i, (argname, default) in enumerate(function_defaults): 39.104 argnum = parameters.index(argname) 39.105 - if not args[argnum+1]: 39.106 - args[argnum+1] = "__GETDEFAULT(%s, %d)" % (target_structure, i) 39.107 + if not args[argnum+argstart]: 39.108 + args[argnum+argstart] = "__GETDEFAULT(%s, %d)" % (target_structure, i) 39.109 39.110 elif known_parameters: 39.111 39.112 @@ -1387,7 +1413,7 @@ 39.113 i = len(n.args) 39.114 pos = i - (num_parameters - num_defaults) 39.115 while i < num_parameters: 39.116 - args[i+1] = "__GETDEFAULT(%s.value, %d)" % (target_var, pos) 39.117 + args[i+argstart] = "__GETDEFAULT(%s.value, %d)" % (target_var, pos) 39.118 i += 1 39.119 pos += 1 39.120 39.121 @@ -1400,10 +1426,10 @@ 39.122 # Encode the arguments. 39.123 39.124 # Where literal instantiation is occurring, add an argument indicating 39.125 - # the number of values. The context is excluded. 39.126 + # the number of values. The result target and context are excluded. 39.127 39.128 if literal_instantiation: 39.129 - argstr = "%d, %s" % (len(args) - 1, ", ".join(args[1:])) 39.130 + argstr = "%d, %s" % (len(args) - 2, ", ".join(args[2:])) 39.131 else: 39.132 argstr = ", ".join(args) 39.133 39.134 @@ -1492,6 +1518,13 @@ 39.135 len(args), "__ARGS(%s)" % argstr)) 39.136 return InvocationResult(stages) 39.137 39.138 + def next_result(self): 39.139 + 39.140 + "Allocate the next result target storage." 39.141 + 39.142 + self.result_target += 1 39.143 + self.max_result_target = max(self.result_target, self.max_result_target) 39.144 + 39.145 def next_target(self): 39.146 39.147 "Allocate the next function target storage." 39.148 @@ -1605,7 +1638,7 @@ 39.149 39.150 return LogicalOperationResult(results, conjunction) 39.151 39.152 - def process_name_node(self, n, expr=None): 39.153 + def process_name_node(self, n, expr=None, process_expr=False): 39.154 39.155 "Process the given name node 'n' with the optional assignment 'expr'." 39.156 39.157 @@ -1672,6 +1705,19 @@ 39.158 if expr and self.in_function and not is_global and self.in_try_except: 39.159 self.make_volatile(n.name) 39.160 39.161 + # Set the replacement target for local objects. 39.162 + # Note that this will not apply to all local objects, with only floats 39.163 + # supporting replaceable values. 39.164 + 39.165 + if expr and self.in_function and not is_global: 39.166 + self.result_target_name = encode_path(n.name) 39.167 + 39.168 + # Expression processing is deferred until after any result target has 39.169 + # been set. 39.170 + 39.171 + if process_expr: 39.172 + expr = self.process_structure_node(expr) 39.173 + 39.174 # Qualified names are used for resolved static references or for 39.175 # static namespace members. The reference should be configured to return 39.176 # such names. 39.177 @@ -1746,7 +1792,11 @@ 39.178 39.179 "Process the given return node 'n'." 39.180 39.181 + if self.in_function: 39.182 + self.result_target_name = "__result" 39.183 + 39.184 expr = self.process_structure_node(n.value) or PredefinedConstantRef("None") 39.185 + 39.186 if self.in_try_finally or self.in_try_except: 39.187 self.writestmt("__Return(%s);" % expr) 39.188 else: 39.189 @@ -2145,6 +2195,7 @@ 39.190 # Generate any self reference. 39.191 39.192 l = [] 39.193 + l.append("__attr __result") 39.194 39.195 if self.is_method(name): 39.196 l.append("__attr self") 39.197 @@ -2178,6 +2229,9 @@ 39.198 39.199 # Add temporary variable usage details. 39.200 39.201 + if self.uses_temp(name, "__tmp_results"): 39.202 + self.writeline("__attr __tmp_results[%d] = {0};" % self.max_result_target) 39.203 + 39.204 if self.uses_temp(name, "__tmp_private_context"): 39.205 self.writeline("__attr __tmp_private_context;") 39.206 if self.uses_temp(name, "__tmp_target_value"):
40.1 --- a/transresults.py Thu Nov 04 23:44:29 2021 +0100 40.2 +++ b/transresults.py Tue Aug 29 01:46:23 2023 +0200 40.3 @@ -3,7 +3,7 @@ 40.4 """ 40.5 Translation result abstractions. 40.6 40.7 -Copyright (C) 2016, 2017, 2018 Paul Boddie <paul@boddie.org.uk> 40.8 +Copyright (C) 2016, 2017, 2018, 2023 Paul Boddie <paul@boddie.org.uk> 40.9 40.10 This program is free software; you can redistribute it and/or modify it under 40.11 the terms of the GNU General Public License as published by the Free Software 40.12 @@ -20,7 +20,8 @@ 40.13 """ 40.14 40.15 from common import first, InstructionSequence 40.16 -from encoders import encode_instructions, encode_literal_constant, encode_path 40.17 +from encoders import encode_instructions, encode_literal_constant, encode_path, \ 40.18 + encode_symbol 40.19 from results import ConstantValueRef, InstanceRef, LiteralSequenceRef, NameRef, \ 40.20 ResolvedNameRef, Result 40.21 40.22 @@ -112,9 +113,10 @@ 40.23 encode_path(parent), attrname, self.expr) 40.24 40.25 # All other assignments involve the names as they were given. 40.26 + # To support value replacement, a special operation is used. 40.27 40.28 else: 40.29 - return "%s = %s" % (attrname, self.expr) 40.30 + return "__set_local(&%s, %s)" % (attrname, self.expr) 40.31 40.32 # Expressions. 40.33