1.1 --- a/templates/progops.c Thu Nov 04 23:44:29 2021 +0100
1.2 +++ b/templates/progops.c Tue Aug 29 01:46:23 2023 +0200
1.3 @@ -1,6 +1,6 @@
1.4 /* Operations depending on program specifics.
1.5
1.6 -Copyright (C) 2015-2019, 2021 Paul Boddie <paul@boddie.org.uk>
1.7 +Copyright (C) 2015-2019, 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 @@ -44,7 +44,7 @@
1.12
1.13 __attr __new_wrapper(__attr context, __attr attr)
1.14 {
1.15 - return __new___builtins___core_wrapper(__NULL, context, attr);
1.16 + return __new___builtins___core_wrapper(__NULL, __NULL, context, attr);
1.17 }
1.18
1.19 /* Generic internal data allocation. */
1.20 @@ -113,7 +113,7 @@
1.21
1.22 /* Call __init__ with the dict object and list argument. */
1.23
1.24 - __fn___builtins___dict_dict___init__(self, tmp);
1.25 + __fn___builtins___dict_dict___init__(__NULL, self, tmp);
1.26 return self;
1.27 }
1.28 #endif /* __HAVE___builtins___dict_dict */
1.29 @@ -123,73 +123,73 @@
1.30 void __raise_eof_error()
1.31 {
1.32 #ifdef __HAVE___builtins___exception_io_EOFError
1.33 - __Raise(__new___builtins___exception_io_EOFError(__NULL));
1.34 + __Raise(__new___builtins___exception_io_EOFError(__NULL, __NULL));
1.35 #endif /* __HAVE___builtins___exception_io_EOFError */
1.36 }
1.37
1.38 void __raise_floating_point_error()
1.39 {
1.40 - __Raise(__new___builtins___core_FloatingPointError(__NULL));
1.41 + __Raise(__new___builtins___core_FloatingPointError(__NULL, __NULL));
1.42 }
1.43
1.44 void __raise_io_error(__attr value)
1.45 {
1.46 #ifdef __HAVE___builtins___exception_io_IOError
1.47 - __Raise(__new___builtins___exception_io_IOError(__NULL, value));
1.48 + __Raise(__new___builtins___exception_io_IOError(__NULL, __NULL, value));
1.49 #endif /* __HAVE___builtins___exception_io_IOError */
1.50 }
1.51
1.52 void __raise_memory_error()
1.53 {
1.54 - __Raise(__new___builtins___core_MemoryError(__NULL));
1.55 + __Raise(__new___builtins___core_MemoryError(__NULL, __NULL));
1.56 }
1.57
1.58 void __raise_os_error(__attr value, __attr arg)
1.59 {
1.60 #ifdef __HAVE___builtins___exception_system_OSError
1.61 - __Raise(__new___builtins___exception_system_OSError(__NULL, value, arg));
1.62 + __Raise(__new___builtins___exception_system_OSError(__NULL, __NULL, value, arg));
1.63 #endif /* __HAVE___builtins___exception_system_OSError */
1.64 }
1.65
1.66 void __raise_overflow_error()
1.67 {
1.68 - __Raise(__new___builtins___core_OverflowError(__NULL));
1.69 + __Raise(__new___builtins___core_OverflowError(__NULL, __NULL));
1.70 }
1.71
1.72 void __raise_unbound_method_error()
1.73 {
1.74 - __Raise(__new___builtins___core_UnboundMethodInvocation(__NULL));
1.75 + __Raise(__new___builtins___core_UnboundMethodInvocation(__NULL, __NULL));
1.76 }
1.77
1.78 void __raise_type_error()
1.79 {
1.80 - __Raise(__new___builtins___core_TypeError(__NULL));
1.81 + __Raise(__new___builtins___core_TypeError(__NULL, __NULL));
1.82 }
1.83
1.84 void __raise_underflow_error()
1.85 {
1.86 - __Raise(__new___builtins___core_UnderflowError(__NULL));
1.87 + __Raise(__new___builtins___core_UnderflowError(__NULL, __NULL));
1.88 }
1.89
1.90 void __raise_value_error(__attr value)
1.91 {
1.92 #ifdef __HAVE___builtins___exception_base_ValueError
1.93 - __Raise(__new___builtins___exception_base_ValueError(__NULL, value));
1.94 + __Raise(__new___builtins___exception_base_ValueError(__NULL, __NULL, value));
1.95 #endif /* __HAVE___builtins___exception_base_ValueError */
1.96 }
1.97
1.98 void __raise_zero_division_error()
1.99 {
1.100 - __Raise(__new___builtins___core_ZeroDivisionError(__NULL));
1.101 + __Raise(__new___builtins___core_ZeroDivisionError(__NULL, __NULL));
1.102 }
1.103
1.104 /* Helper for raising exception instances. */
1.105
1.106 __attr __ensure_instance(__attr arg)
1.107 {
1.108 - /* Reserve space for the instance. */
1.109 + /* Reserve space for the result target and instance. */
1.110
1.111 - __attr args[1] = {__NULL};
1.112 + __attr args[2] = {__NULL, __NULL};
1.113
1.114 /* Return instances as provided. */
1.115
1.116 @@ -199,7 +199,7 @@
1.117 /* Invoke non-instances to produce instances. */
1.118
1.119 else
1.120 - return __invoke(arg, 0, 0, 0, 0, 1, args);
1.121 + return __invoke(arg, 0, 0, 0, 0, 2, args);
1.122 }
1.123
1.124 /* Generic invocation operations. */
1.125 @@ -294,16 +294,20 @@
1.126
1.127 return __call_with_args(
1.128 always_callable ?
1.129 - __get_function_unwrapped(allargs[0], target) :
1.130 - __check_and_get_function_unwrapped(allargs[0], target),
1.131 +
1.132 + /* Remember that the arguments start with the result target and then
1.133 + the context. */
1.134 +
1.135 + __get_function_unwrapped(allargs[1], target) :
1.136 + __check_and_get_function_unwrapped(allargs[1], target),
1.137 allargs, max);
1.138 }
1.139
1.140 /* Error routines. */
1.141
1.142 -__attr __unbound_method(__attr __self)
1.143 +__attr __unbound_method(__attr __result, __attr __self)
1.144 {
1.145 - __Raise(__new___builtins___core_UnboundMethodInvocation(__NULL));
1.146 + __Raise(__new___builtins___core_UnboundMethodInvocation(__NULL, __NULL));
1.147 return __builtins___none_None; /* superfluous */
1.148 }
1.149
1.150 @@ -336,5 +340,5 @@
1.151
1.152 return value == (__ref) &__predefined___builtins___boolean_True ? 1 :
1.153 value == (__ref) &__predefined___builtins___boolean_False ? 0 :
1.154 - __VALUE(__fn___builtins___boolean_bool(__NULL, attr)) == (__ref) &__predefined___builtins___boolean_True;
1.155 + __VALUE(__fn___builtins___boolean_bool(__NULL, __NULL, attr)) == (__ref) &__predefined___builtins___boolean_True;
1.156 }