source: doc/theses/andrew_beach_MMath/code/throw-other.cfa @ ea593a3

enumforall-pointer-decayjacob/cs343-translationnew-ast-unique-expr
Last change on this file since ea593a3 was ea593a3, checked in by Andrew Beach <ajbeach@…>, 12 months ago

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

  • Property mode set to 100644
File size: 748 bytes
Line 
1// Throw Across Other Handler
2#include <exception.hfa>
3#include <stdlib.hfa>
4
5EHM_EXCEPTION(empty_exception)();
6
7EHM_VIRTUAL_TABLE(empty_exception, empty_vt);
8
9EHM_EXCEPTION(not_raised_exception)();
10
11void unwind_other(unsigned int frames) {
12        if (frames) {
13                try {
14                        unwind_other(frames - 1);
15                } catch (not_raised_exception *) {
16                        // ...
17                }
18        } else {
19                throw (empty_exception){&empty_vt};
20        }
21}
22
23int main(int argc, char * argv[]) {
24        unsigned int times = 1;
25        unsigned int total_frames = 1;
26        if (2 < argc) {
27                times = strtol(argv[1], 0p, 10);
28        }
29        if (3 < argc) {
30                total_frames = strtol(argv[2], 0p, 10);
31        }
32
33        for (int count = 0 ; count < times ; ++count) {
34                try {
35                        unwind_other(total_frames);
36                } catch (empty_exception *) {
37                        // ...
38                }
39        }
40}
Note: See TracBrowser for help on using the repository browser.