1.1 --- a/templates/progops.c Tue Mar 07 17:32:14 2017 +0100
1.2 +++ b/templates/progops.c Tue Mar 07 18:10:00 2017 +0100
1.3 @@ -33,13 +33,13 @@
1.4 __ref obj = (__ref) __ALLOCATE(1, size);
1.5 obj->table = table;
1.6 obj->pos = __INSTANCEPOS;
1.7 - __store_via_object(obj, __class__, (__attr) {.value=cls});
1.8 + __store_via_object(obj, __class__, __ATTRVALUE(cls));
1.9 return (__attr) {.value=obj};
1.10 }
1.11
1.12 __attr __new_wrapper(__ref context, __attr attr)
1.13 {
1.14 - return __new___builtins___core_wrapper((__attr[]) {__NULL, {.value=context}, attr});
1.15 + return __new___builtins___core_wrapper(__NULL, __ATTRVALUE(context), attr);
1.16 }
1.17
1.18 /* Generic internal data allocation. */
1.19 @@ -57,43 +57,40 @@
1.20 return data;
1.21 }
1.22
1.23 -void __newdata_sequence(__attr args[], unsigned int number)
1.24 +__attr __newdata_sequence(__attr self, __attr args[], unsigned int number)
1.25 {
1.26 /* Calculate the size of the fragment. */
1.27
1.28 __fragment *data = __new_fragment(number);
1.29 __attr attr = {.seqvalue=data};
1.30 - unsigned int i, j;
1.31 + unsigned int i;
1.32
1.33 - /* Copy the given number of values, starting from the second element. */
1.34 + /* Copy the given number of values. */
1.35
1.36 - for (i = 1, j = 0; i <= number; i++, j++)
1.37 - data->attrs[j] = args[i];
1.38 + for (i = 0; i <= number; i++)
1.39 + data->attrs[i] = args[i];
1.40
1.41 data->size = number;
1.42
1.43 /* Store a reference to the data in the object's __data__ attribute. */
1.44
1.45 - __store_via_object(args[0].value, __data__, attr);
1.46 + __store_via_object(self.value, __data__, attr);
1.47 + return self;
1.48 }
1.49
1.50 #ifdef __HAVE___builtins___dict_dict
1.51 -void __newdata_mapping(__attr args[], unsigned int number)
1.52 +__attr __newdata_mapping(__attr self, __attr args[], unsigned int number)
1.53 {
1.54 - __attr dict = args[0];
1.55 __attr callargs[2];
1.56
1.57 /* Create a temporary list using the arguments. */
1.58
1.59 - __newliteral___builtins___list_list(args, number);
1.60 + __attr tmp = __newliteral___builtins___list_list(args, number);
1.61
1.62 /* Call __init__ with the dict object and list argument. */
1.63
1.64 - callargs[0] = dict;
1.65 - callargs[1] = args[0];
1.66 -
1.67 - __fn___builtins___dict_dict___init__(callargs);
1.68 - args[0] = dict;
1.69 + __fn___builtins___dict_dict___init__(self, tmp);
1.70 + return self;
1.71 }
1.72 #endif /* __HAVE___builtins___dict_dict */
1.73
1.74 @@ -102,56 +99,42 @@
1.75 void __raise_eof_error()
1.76 {
1.77 #ifdef __HAVE___builtins___exception_io_EOFError
1.78 - __attr args[1];
1.79 - __attr exc = __new___builtins___exception_io_EOFError(args);
1.80 - __Raise(exc);
1.81 + __Raise(__new___builtins___exception_io_EOFError(__NULL));
1.82 #endif /* __HAVE___builtins___exception_io_EOFError */
1.83 }
1.84
1.85 void __raise_io_error(__attr value)
1.86 {
1.87 #ifdef __HAVE___builtins___exception_io_IOError
1.88 - __attr args[2] = {__NULL, value};
1.89 - __attr exc = __new___builtins___exception_io_IOError(args);
1.90 - __Raise(exc);
1.91 + __Raise(__new___builtins___exception_io_IOError(__NULL, value));
1.92 #endif /* __HAVE___builtins___exception_io_IOError */
1.93 }
1.94
1.95 void __raise_memory_error()
1.96 {
1.97 - __attr args[1];
1.98 - __attr exc = __new___builtins___core_MemoryError(args);
1.99 - __Raise(exc);
1.100 + __Raise(__new___builtins___core_MemoryError(__NULL));
1.101 }
1.102
1.103 void __raise_os_error(__attr value, __attr arg)
1.104 {
1.105 #ifdef __HAVE___builtins___exception_system_OSError
1.106 - __attr args[3] = {__NULL, value, arg};
1.107 - __attr exc = __new___builtins___exception_system_OSError(args);
1.108 - __Raise(exc);
1.109 + __Raise(__new___builtins___exception_system_OSError(__NULL, value, arg));
1.110 #endif /* __HAVE___builtins___exception_system_OSError */
1.111 }
1.112
1.113 void __raise_overflow_error()
1.114 {
1.115 - __attr args[1];
1.116 - __attr exc = __new___builtins___core_OverflowError(args);
1.117 - __Raise(exc);
1.118 + __Raise(__new___builtins___core_OverflowError(__NULL));
1.119 }
1.120
1.121 void __raise_type_error()
1.122 {
1.123 - __attr args[1];
1.124 - __attr exc = __new___builtins___core_TypeError(args);
1.125 - __Raise(exc);
1.126 + __Raise(__new___builtins___core_TypeError(__NULL));
1.127 }
1.128
1.129 void __raise_zero_division_error()
1.130 {
1.131 - __attr args[1];
1.132 - __attr exc = __new___builtins___core_ZeroDivisionError(args);
1.133 - __Raise(exc);
1.134 + __Raise(__new___builtins___core_ZeroDivisionError(__NULL));
1.135 }
1.136
1.137 /* Helper for raising exception instances. */
1.138 @@ -266,9 +249,7 @@
1.139
1.140 __attr __unbound_method(__attr __self)
1.141 {
1.142 - __attr excargs[1];
1.143 - __attr exc = __new___builtins___core_UnboundMethodInvocation(excargs);
1.144 - __Raise(exc);
1.145 + __Raise(__new___builtins___core_UnboundMethodInvocation(__NULL));
1.146 return __builtins___none_None; /* superfluous */
1.147 }
1.148