ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since 42cd451e was
046a890,
checked in by Andrew Beach <ajbeach@…>, 4 years ago
|
That should get default operations working for throws. More tests to come.
|
-
Property mode set to
100644
|
File size:
937 bytes
|
Rev | Line | |
---|
[e68d092] | 1 | // Test exceptions that add data but no functionality. |
---|
| 2 | |
---|
| 3 | #include <exception.hfa> |
---|
| 4 | |
---|
| 5 | DATA_EXCEPTION(paired)( |
---|
| 6 | int first; |
---|
| 7 | int second; |
---|
| 8 | ); |
---|
| 9 | |
---|
| 10 | void ?{}(paired & this, int first, int second) { |
---|
| 11 | VTABLE_INIT(this, paired); |
---|
| 12 | this.first = first; |
---|
| 13 | this.second = second; |
---|
| 14 | } |
---|
| 15 | |
---|
| 16 | const char * paired_msg(paired * this) { |
---|
| 17 | return "paired"; |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | VTABLE_INSTANCE(paired)(paired_msg); |
---|
| 21 | |
---|
| 22 | void throwPaired(int first, int second) { |
---|
| 23 | paired exc = {first, second}; |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | int main(int argc, char * argv[]) { |
---|
| 27 | paired except = {3, 13}; |
---|
| 28 | |
---|
| 29 | try { |
---|
[046a890] | 30 | throw except; |
---|
[e68d092] | 31 | } catch (paired * exc) { |
---|
| 32 | printf("%s(%d, %d)\n", paired_msg(exc), exc->first, exc->second); |
---|
| 33 | ++exc->first; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | printf("%s(%d, %d)\n", paired_msg(&except), except.first, except.second); |
---|
| 37 | |
---|
| 38 | try { |
---|
[046a890] | 39 | throwResume except; |
---|
[e68d092] | 40 | } catchResume (paired * exc) { |
---|
| 41 | printf("%s(%d, %d)\n", paired_msg(exc), exc->first, exc->second); |
---|
| 42 | ++exc->first; |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | printf("%s(%d, %d)\n", paired_msg(&except), except.first, except.second); |
---|
| 46 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.