1.1 --- a/generator.py Tue Dec 06 15:12:04 2016 +0100
1.2 +++ b/generator.py Tue Dec 06 17:49:39 2016 +0100
1.3 @@ -56,11 +56,7 @@
1.4 # NOTE: These must be synchronised with the library.
1.5
1.6 function_type = "__builtins__.core.function"
1.7 - memory_error_type = "__builtins__.core.MemoryError"
1.8 - overflow_error_type = "__builtins__.core.OverflowError"
1.9 - type_error_type = "__builtins__.core.TypeError"
1.10 type_type = "__builtins__.core.type"
1.11 - zero_division_error_type = "__builtins__.core.ZeroDivisionError"
1.12
1.13 predefined_constant_members = (
1.14 ("__builtins__.boolean", "False"),
1.15 @@ -360,10 +356,6 @@
1.16
1.17 #define __FUNCTION_TYPE %s
1.18 #define __FUNCTION_INSTANCE_SIZE %s
1.19 -#define __MEMORY_ERROR_INSTANTIATOR %s
1.20 -#define __OVERFLOW_ERROR_INSTANTIATOR %s
1.21 -#define __TYPE_ERROR_INSTANTIATOR %s
1.22 -#define __ZERO_DIVISION_ERROR_INSTANTIATOR %s
1.23 #define __TYPE_CLASS_TYPE %s
1.24 #define __TYPE_CLASS_POS %s
1.25 #define __TYPE_CLASS_CODE %s
1.26 @@ -371,10 +363,6 @@
1.27 #endif /* __PROGTYPES_H__ */""" % (
1.28 encode_path(self.function_type),
1.29 encode_size("<instance>", self.function_type),
1.30 - encode_instantiator_pointer(self.memory_error_type),
1.31 - encode_instantiator_pointer(self.overflow_error_type),
1.32 - encode_instantiator_pointer(self.type_error_type),
1.33 - encode_instantiator_pointer(self.zero_division_error_type),
1.34 encode_path(self.type_type),
1.35 encode_symbol("pos", encode_type_attribute(self.type_type)),
1.36 encode_symbol("code", encode_type_attribute(self.type_type)),
2.1 --- a/templates/progops.c Tue Dec 06 15:12:04 2016 +0100
2.2 +++ b/templates/progops.c Tue Dec 06 17:49:39 2016 +0100
2.3 @@ -58,7 +58,6 @@
2.4 }
2.5
2.6 #ifdef __HAVE___builtins___dict_dict
2.7 -
2.8 void __newdata_mapping(__attr args[], unsigned int number)
2.9 {
2.10 __attr dict = args[0];
2.11 @@ -76,36 +75,44 @@
2.12 __fn___builtins___dict_dict___init__(callargs);
2.13 args[0] = dict;
2.14 }
2.15 -
2.16 #endif /* __HAVE___builtins___dict_dict */
2.17
2.18 /* Helpers for raising errors within common operations. */
2.19
2.20 +#ifdef __HAVE___builtins___exception_io_IOError
2.21 +void __raise_io_error()
2.22 +{
2.23 + __attr args[1];
2.24 + __attr exc = __new___builtins___exception_io_IOError(args);
2.25 + __Raise(exc);
2.26 +}
2.27 +#endif /* __HAVE___builtins___exception_io_IOError */
2.28 +
2.29 void __raise_memory_error()
2.30 {
2.31 __attr args[1];
2.32 - __attr exc = __MEMORY_ERROR_INSTANTIATOR(args);
2.33 + __attr exc = __new___builtins___core_MemoryError(args);
2.34 __Raise(exc);
2.35 }
2.36
2.37 void __raise_overflow_error()
2.38 {
2.39 __attr args[1];
2.40 - __attr exc = __OVERFLOW_ERROR_INSTANTIATOR(args);
2.41 + __attr exc = __new___builtins___core_OverflowError(args);
2.42 __Raise(exc);
2.43 }
2.44
2.45 void __raise_type_error()
2.46 {
2.47 __attr args[1];
2.48 - __attr exc = __TYPE_ERROR_INSTANTIATOR(args);
2.49 + __attr exc = __new___builtins___core_TypeError(args);
2.50 __Raise(exc);
2.51 }
2.52
2.53 void __raise_zero_division_error()
2.54 {
2.55 __attr args[1];
2.56 - __attr exc = __ZERO_DIVISION_ERROR_INSTANTIATOR(args);
2.57 + __attr exc = __new___builtins___core_ZeroDivisionError(args);
2.58 __Raise(exc);
2.59 }
2.60
3.1 --- a/templates/progops.h Tue Dec 06 15:12:04 2016 +0100
3.2 +++ b/templates/progops.h Tue Dec 06 17:49:39 2016 +0100
3.3 @@ -11,10 +11,16 @@
3.4
3.5 void __newdata_sequence(__attr args[], unsigned int number);
3.6
3.7 +#ifdef __HAVE___builtins___dict_dict
3.8 void __newdata_mapping(__attr args[], unsigned int number);
3.9 +#endif /* __HAVE___builtins___dict_dict */
3.10
3.11 /* Exception raising. */
3.12
3.13 +#ifdef __HAVE___builtins___exception_io_IOError
3.14 +void __raise_io_error();
3.15 +#endif /* __HAVE___builtins___exception_io_IOError */
3.16 +
3.17 void __raise_memory_error();
3.18 void __raise_overflow_error();
3.19 void __raise_zero_division_error();