source: doc/theses/andrew_beach_MMath/code/cond-match.cfa@ 1f45c7d

ADT ast-experimental enum forall-pointer-decay jacob/cs343-translation new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since 1f45c7d was ea593a3, checked in by Andrew Beach <ajbeach@…>, 4 years ago

First draft of all the exception benchmarks. There is an issue with the Cforall linking.

  • Property mode set to 100644
File size: 624 bytes
Line 
1// Conditional Match (or Re-Raise)
2#include <exception.hfa>
3#include <stdlib.h>
4
5EHM_EXCEPTION(empty_exception)();
6
7EHM_VIRTUAL_TABLE(empty_exception, empty_vt);
8
9bool should_catch = false;
10
11void throw_exception() {
12 throw (empty_exception){&empty_vt};
13}
14
15void cond_catch() {
16 try {
17 throw_exception();
18 } catch (empty_exception * exc ; should_catch) {
19 // ...
20 }
21}
22
23int main(int argc, char * argv[]) {
24 unsigned int times = 1;
25 if (2 < argc) {
26 times = strtol(argv[1], 0p, 10);
27 }
28
29 for (unsigned int count = 0 ; count < times ; ++count) {
30 try {
31 cond_catch();
32 } catch (empty_exception * exc) {
33 // ...
34 }
35 }
36}
Note: See TracBrowser for help on using the repository browser.