1.1 --- a/templates/progops.c Sat Nov 06 17:06:01 2021 +0100
1.2 +++ b/templates/progops.c Sun Nov 07 01:18:51 2021 +0100
1.3 @@ -44,7 +44,7 @@
1.4
1.5 __attr __new_wrapper(__attr context, __attr attr)
1.6 {
1.7 - return __new___builtins___core_wrapper(__NULL, context, attr);
1.8 + return __new___builtins___core_wrapper(__NULL, __NULL, context, attr);
1.9 }
1.10
1.11 /* Generic internal data allocation. */
1.12 @@ -113,7 +113,7 @@
1.13
1.14 /* Call __init__ with the dict object and list argument. */
1.15
1.16 - __fn___builtins___dict_dict___init__(self, tmp);
1.17 + __fn___builtins___dict_dict___init__(__NULL, self, tmp);
1.18 return self;
1.19 }
1.20 #endif /* __HAVE___builtins___dict_dict */
1.21 @@ -123,73 +123,73 @@
1.22 void __raise_eof_error()
1.23 {
1.24 #ifdef __HAVE___builtins___exception_io_EOFError
1.25 - __Raise(__new___builtins___exception_io_EOFError(__NULL));
1.26 + __Raise(__new___builtins___exception_io_EOFError(__NULL, __NULL));
1.27 #endif /* __HAVE___builtins___exception_io_EOFError */
1.28 }
1.29
1.30 void __raise_floating_point_error()
1.31 {
1.32 - __Raise(__new___builtins___core_FloatingPointError(__NULL));
1.33 + __Raise(__new___builtins___core_FloatingPointError(__NULL, __NULL));
1.34 }
1.35
1.36 void __raise_io_error(__attr value)
1.37 {
1.38 #ifdef __HAVE___builtins___exception_io_IOError
1.39 - __Raise(__new___builtins___exception_io_IOError(__NULL, value));
1.40 + __Raise(__new___builtins___exception_io_IOError(__NULL, __NULL, value));
1.41 #endif /* __HAVE___builtins___exception_io_IOError */
1.42 }
1.43
1.44 void __raise_memory_error()
1.45 {
1.46 - __Raise(__new___builtins___core_MemoryError(__NULL));
1.47 + __Raise(__new___builtins___core_MemoryError(__NULL, __NULL));
1.48 }
1.49
1.50 void __raise_os_error(__attr value, __attr arg)
1.51 {
1.52 #ifdef __HAVE___builtins___exception_system_OSError
1.53 - __Raise(__new___builtins___exception_system_OSError(__NULL, value, arg));
1.54 + __Raise(__new___builtins___exception_system_OSError(__NULL, __NULL, value, arg));
1.55 #endif /* __HAVE___builtins___exception_system_OSError */
1.56 }
1.57
1.58 void __raise_overflow_error()
1.59 {
1.60 - __Raise(__new___builtins___core_OverflowError(__NULL));
1.61 + __Raise(__new___builtins___core_OverflowError(__NULL, __NULL));
1.62 }
1.63
1.64 void __raise_unbound_method_error()
1.65 {
1.66 - __Raise(__new___builtins___core_UnboundMethodInvocation(__NULL));
1.67 + __Raise(__new___builtins___core_UnboundMethodInvocation(__NULL, __NULL));
1.68 }
1.69
1.70 void __raise_type_error()
1.71 {
1.72 - __Raise(__new___builtins___core_TypeError(__NULL));
1.73 + __Raise(__new___builtins___core_TypeError(__NULL, __NULL));
1.74 }
1.75
1.76 void __raise_underflow_error()
1.77 {
1.78 - __Raise(__new___builtins___core_UnderflowError(__NULL));
1.79 + __Raise(__new___builtins___core_UnderflowError(__NULL, __NULL));
1.80 }
1.81
1.82 void __raise_value_error(__attr value)
1.83 {
1.84 #ifdef __HAVE___builtins___exception_base_ValueError
1.85 - __Raise(__new___builtins___exception_base_ValueError(__NULL, value));
1.86 + __Raise(__new___builtins___exception_base_ValueError(__NULL, __NULL, value));
1.87 #endif /* __HAVE___builtins___exception_base_ValueError */
1.88 }
1.89
1.90 void __raise_zero_division_error()
1.91 {
1.92 - __Raise(__new___builtins___core_ZeroDivisionError(__NULL));
1.93 + __Raise(__new___builtins___core_ZeroDivisionError(__NULL, __NULL));
1.94 }
1.95
1.96 /* Helper for raising exception instances. */
1.97
1.98 -__attr __ensure_instance(__attr arg)
1.99 +__attr __ensure_instance(__attr __stack, __attr arg)
1.100 {
1.101 - /* Reserve space for the instance. */
1.102 + /* Reserve space for the stack and instance. */
1.103
1.104 - __attr args[1] = {__NULL};
1.105 + __attr args[2] = {__stack, __NULL};
1.106
1.107 /* Return instances as provided. */
1.108
1.109 @@ -199,7 +199,7 @@
1.110 /* Invoke non-instances to produce instances. */
1.111
1.112 else
1.113 - return __invoke(arg, 0, 0, 0, 0, 1, args);
1.114 + return __invoke(arg, 0, 0, 0, 0, 2, args);
1.115 }
1.116
1.117 /* Generic invocation operations. */
1.118 @@ -207,8 +207,10 @@
1.119 /* Invoke the given callable, supplying keyword argument details in the given
1.120 codes and arguments arrays, indicating the number of arguments described.
1.121 The number of positional arguments is specified, and such arguments then
1.122 - follow as conventional function arguments. Typically, at least one argument
1.123 - is specified, starting with any context argument.
1.124 + follow as conventional function arguments.
1.125 +
1.126 + Typically, at least two arguments are specified, starting with the stack
1.127 + argument and any context argument.
1.128 */
1.129
1.130 __attr __invoke(__attr callable, int always_callable,
1.131 @@ -220,10 +222,13 @@
1.132 __attr target = __unwrap_callable(callable);
1.133
1.134 /* Obtain the __args__ special member, referencing the parameter table. */
1.135 - /* Refer to the table and minimum/maximum. */
1.136
1.137 const __ptable *ptable = __check_and_load_via_object(__VALUE(target), __args__).ptable;
1.138 - const unsigned int min = ptable->min, max = ptable->max;
1.139 +
1.140 + /* Refer to the table and minimum/maximum, adjusting for the stack
1.141 + argument. */
1.142 +
1.143 + unsigned int min = ptable->min + 1, max = ptable->max + 1;
1.144
1.145 /* Reserve enough space for the arguments. */
1.146
1.147 @@ -269,15 +274,20 @@
1.148
1.149 /* Check the table entry against the supplied argument details.
1.150 Set the argument but only if it does not overwrite positional
1.151 - arguments. */
1.152 - /* NOTE: Should use a more specific exception. */
1.153 + arguments. Here, the position is adjusted for the stack
1.154 + argument. */
1.155
1.156 - if ((pos == -1) || (pos < nargs))
1.157 + if ((pos == -1) || (pos + 1 < nargs))
1.158 + {
1.159 + /* NOTE: Should use a more specific exception. */
1.160 +
1.161 __raise_type_error();
1.162 + }
1.163
1.164 - /* Set the argument using the appropriate position. */
1.165 + /* Set the argument using the appropriate position, adjusting for
1.166 + the stack argument. */
1.167
1.168 - allargs[pos] = kwargs[kwpos];
1.169 + allargs[pos + 1] = kwargs[kwpos];
1.170 }
1.171
1.172 /* Fill the defaults. */
1.173 @@ -290,20 +300,21 @@
1.174 }
1.175
1.176 /* Call with the prepared arguments via a special adaptor function that
1.177 - converts the array to an argument list. */
1.178 + converts the array to an argument list. The stack argument occupies
1.179 + position #0, with the context occupying position #1. */
1.180
1.181 return __call_with_args(
1.182 always_callable ?
1.183 - __get_function_unwrapped(allargs[0], target) :
1.184 - __check_and_get_function_unwrapped(allargs[0], target),
1.185 + __get_function_unwrapped(allargs[1], target) :
1.186 + __check_and_get_function_unwrapped(allargs[1], target),
1.187 allargs, max);
1.188 }
1.189
1.190 /* Error routines. */
1.191
1.192 -__attr __unbound_method(__attr __self)
1.193 +__attr __unbound_method(__attr __stack, __attr __self)
1.194 {
1.195 - __Raise(__new___builtins___core_UnboundMethodInvocation(__NULL));
1.196 + __Raise(__new___builtins___core_UnboundMethodInvocation(__stack, __NULL));
1.197 return __builtins___none_None; /* superfluous */
1.198 }
1.199
1.200 @@ -336,7 +347,8 @@
1.201
1.202 return value == (__ref) &__predefined___builtins___boolean_True ? 1 :
1.203 value == (__ref) &__predefined___builtins___boolean_False ? 0 :
1.204 - __VALUE(__fn___builtins___boolean_bool(__NULL, attr)) == (__ref) &__predefined___builtins___boolean_True;
1.205 + __VALUE(__fn___builtins___boolean_bool(__NULL, __NULL, attr)) ==
1.206 + (__ref) &__predefined___builtins___boolean_True;
1.207 }
1.208
1.209 /* Conversion of trailing data to an integer. */