ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since 55ad35c was
ea593a3,
checked in by Andrew Beach <ajbeach@…>, 3 years ago
|
First draft of all the exception benchmarks. There is an issue with the Cforall linking.
|
-
Property mode set to
100644
|
File size:
843 bytes
|
Line | |
---|
1 | // Throw Across Destructor |
---|
2 | #include <exception.hfa> |
---|
3 | #include <stdlib.hfa> |
---|
4 | |
---|
5 | EHM_EXCEPTION(empty_exception)(); |
---|
6 | |
---|
7 | EHM_VIRTUAL_TABLE(empty_exception, empty_vt); |
---|
8 | |
---|
9 | struct WithDestructor {}; |
---|
10 | |
---|
11 | void ^?{}(WithDestructor & this) { |
---|
12 | // ... |
---|
13 | } |
---|
14 | |
---|
15 | void unwind_destructor(unsigned int frames) { |
---|
16 | if (frames) { |
---|
17 | |
---|
18 | WithDestructor object; |
---|
19 | unwind_destructor(frames - 1); |
---|
20 | } else { |
---|
21 | throwResume (empty_exception){&empty_vt}; |
---|
22 | } |
---|
23 | } |
---|
24 | |
---|
25 | int main(int argc, char * argv[]) { |
---|
26 | unsigned int times = 1; |
---|
27 | unsigned int total_frames = 1; |
---|
28 | if (2 < argc) { |
---|
29 | times = strtol(argv[1], 0p, 10); |
---|
30 | } |
---|
31 | if (3 < argc) { |
---|
32 | total_frames = strtol(argv[2], 0p, 10); |
---|
33 | } |
---|
34 | |
---|
35 | for (int count = 0 ; count < times ; ++count) { |
---|
36 | try { |
---|
37 | unwind_destructor(total_frames); |
---|
38 | } catchResume (empty_exception *) { |
---|
39 | // ... |
---|
40 | } |
---|
41 | } |
---|
42 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.