[fa4805f] | 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
|
---|
[86d5ba7c] | 11 | // Last Modified By : Andrew Beach
|
---|
| 12 | // Last Modified On : Fri Jul 27 12:42:00 2017
|
---|
| 13 | // Update Count : 4
|
---|
[fa4805f] | 14 | //
|
---|
| 15 |
|
---|
[6b0b624] | 16 | #pragma once
|
---|
[fa4805f] | 17 |
|
---|
| 18 |
|
---|
| 19 | #ifdef __CFORALL__
|
---|
[0fc9756b] | 20 | extern "C" {
|
---|
[fa4805f] | 21 | #endif
|
---|
| 22 |
|
---|
[86d5ba7c] | 23 | #if 1
|
---|
| 24 | typedef int exception;
|
---|
| 25 | #else
|
---|
| 26 | struct exception_t;
|
---|
| 27 | struct exception_t_vtable {
|
---|
| 28 | struct exception_t_vtable const * parent;
|
---|
| 29 | size_t size;
|
---|
| 30 | void (*copy)(struct exception_t *this, struct exception_t * other);
|
---|
| 31 | void (*free)(struct exception_t *this);
|
---|
| 32 | const char (*msg)(struct exception_t *this);
|
---|
| 33 | };
|
---|
| 34 | struct exception_t {
|
---|
| 35 | struct exception_vtable const * virtual_table;
|
---|
| 36 | };
|
---|
| 37 | typedef struct exception_t exception;
|
---|
| 38 | #endif
|
---|
| 39 |
|
---|
| 40 |
|
---|
[fa4805f] | 41 | // Used in throw statement translation.
|
---|
[38ac6ec] | 42 | void __cfaehm__throw_terminate(exception * except) __attribute__((noreturn));
|
---|
| 43 | void __cfaehm__rethrow_terminate() __attribute__((noreturn));
|
---|
| 44 | void __cfaehm__throw_resume(exception * except);
|
---|
[fa4805f] | 45 |
|
---|
| 46 | // Function catches termination exceptions.
|
---|
| 47 | void __cfaehm__try_terminate(
|
---|
| 48 | void (*try_block)(),
|
---|
| 49 | void (*catch_block)(int index, exception * except),
|
---|
| 50 | int (*match_block)(exception * except));
|
---|
| 51 |
|
---|
[86d5ba7c] | 52 | // Clean-up the exception in catch blocks.
|
---|
| 53 | void __cfaehm__cleanup_terminate(exception ** except);
|
---|
| 54 |
|
---|
[fa4805f] | 55 | // Data structure creates a list of resume handlers.
|
---|
| 56 | struct __cfaehm__try_resume_node {
|
---|
[307a732] | 57 | struct __cfaehm__try_resume_node * next;
|
---|
[fa4805f] | 58 | int (*handler)(exception * except);
|
---|
| 59 | };
|
---|
| 60 |
|
---|
[86d5ba7c] | 61 | // These act as constructor and destructor for the resume node.
|
---|
[fa4805f] | 62 | void __cfaehm__try_resume_setup(
|
---|
[307a732] | 63 | struct __cfaehm__try_resume_node * node,
|
---|
[fa4805f] | 64 | int (*handler)(exception * except));
|
---|
| 65 | void __cfaehm__try_resume_cleanup(
|
---|
[307a732] | 66 | struct __cfaehm__try_resume_node * node);
|
---|
[fa4805f] | 67 |
|
---|
| 68 | // Check for a standard way to call fake deconstructors.
|
---|
[86d5ba7c] | 69 | struct __cfaehm__cleanup_hook {};
|
---|
[fa4805f] | 70 |
|
---|
| 71 | #ifdef __CFORALL__
|
---|
| 72 | }
|
---|
| 73 | #endif
|
---|