1 | // |
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo |
---|
3 | // |
---|
4 | // The contents of this file are covered under the licence agreement in the |
---|
5 | // file "LICENCE" distributed with Cforall. |
---|
6 | // |
---|
7 | // exception.h -- Builtins for exception handling. |
---|
8 | // |
---|
9 | // Author : Andrew Beach |
---|
10 | // Created On : Mon Jun 26 15:11:00 2017 |
---|
11 | // Last Modified By : Andrew Beach |
---|
12 | // Last Modified On : Thr Aug 17 15:44:00 2017 |
---|
13 | // Update Count : 6 |
---|
14 | // |
---|
15 | |
---|
16 | #pragma once |
---|
17 | |
---|
18 | |
---|
19 | #ifdef __CFORALL__ |
---|
20 | extern "C" { |
---|
21 | #endif |
---|
22 | |
---|
23 | struct __cfaehm__base_exception_t; |
---|
24 | typedef struct __cfaehm__base_exception_t exception; |
---|
25 | struct __cfaehm__base_exception_t_vtable { |
---|
26 | const struct __cfaehm__base_exception_t_vtable * parent; |
---|
27 | size_t size; |
---|
28 | void (*copy)(struct __cfaehm__base_exception_t *this, |
---|
29 | struct __cfaehm__base_exception_t * other); |
---|
30 | void (*free)(struct __cfaehm__base_exception_t *this); |
---|
31 | const char (*msg)(struct __cfaehm__base_exception_t *this); |
---|
32 | }; |
---|
33 | struct __cfaehm__base_exception_t { |
---|
34 | struct __cfaehm__base_exception_t_vtable const * virtual_table; |
---|
35 | }; |
---|
36 | extern struct __cfaehm__base_exception_t_vtable |
---|
37 | ___cfaehm__base_exception_t_vtable_instance; |
---|
38 | |
---|
39 | |
---|
40 | // Used in throw statement translation. |
---|
41 | void __cfaehm__throw_terminate(exception * except) __attribute__((noreturn)); |
---|
42 | void __cfaehm__rethrow_terminate() __attribute__((noreturn)); |
---|
43 | void __cfaehm__throw_resume(exception * except); |
---|
44 | |
---|
45 | // Function catches termination exceptions. |
---|
46 | void __cfaehm__try_terminate( |
---|
47 | void (*try_block)(), |
---|
48 | void (*catch_block)(int index, exception * except), |
---|
49 | int (*match_block)(exception * except)); |
---|
50 | |
---|
51 | // Clean-up the exception in catch blocks. |
---|
52 | void __cfaehm__cleanup_terminate(void * except); |
---|
53 | |
---|
54 | // Data structure creates a list of resume handlers. |
---|
55 | struct __cfaehm__try_resume_node { |
---|
56 | struct __cfaehm__try_resume_node * next; |
---|
57 | _Bool (*handler)(exception * except); |
---|
58 | }; |
---|
59 | |
---|
60 | // These act as constructor and destructor for the resume node. |
---|
61 | void __cfaehm__try_resume_setup( |
---|
62 | struct __cfaehm__try_resume_node * node, |
---|
63 | _Bool (*handler)(exception * except)); |
---|
64 | void __cfaehm__try_resume_cleanup( |
---|
65 | struct __cfaehm__try_resume_node * node); |
---|
66 | |
---|
67 | // Check for a standard way to call fake deconstructors. |
---|
68 | struct __cfaehm__cleanup_hook {}; |
---|
69 | |
---|
70 | #ifdef __CFORALL__ |
---|
71 | } |
---|
72 | #endif |
---|