ADT
ast-experimental
enum
forall-pointer-decay
jacob/cs343-translation
new-ast-unique-expr
pthread-emulation
qualifiedEnum
Last change
on this file since 4ae968e 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
|
Rev | Line | |
---|
[ea593a3] | 1 | // Conditional Match (or Re-Raise)
|
---|
| 2 | #include <exception.hfa>
|
---|
| 3 | #include <stdlib.h>
|
---|
| 4 |
|
---|
| 5 | EHM_EXCEPTION(empty_exception)();
|
---|
| 6 |
|
---|
| 7 | EHM_VIRTUAL_TABLE(empty_exception, empty_vt);
|
---|
| 8 |
|
---|
| 9 | bool should_catch = false;
|
---|
| 10 |
|
---|
| 11 | void throw_exception() {
|
---|
| 12 | throw (empty_exception){&empty_vt};
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | void cond_catch() {
|
---|
| 16 | try {
|
---|
| 17 | throw_exception();
|
---|
| 18 | } catch (empty_exception * exc ; should_catch) {
|
---|
| 19 | // ...
|
---|
| 20 | }
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | int 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.