source: tests/exceptions/data-except.cfa @ 262deda0

ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationpthread-emulationqualifiedEnum
Last change on this file since 262deda0 was ecfd758, checked in by Andrew Beach <ajbeach@…>, 3 years ago

Major exception update, seperating type-ids from virtual tables. The major interface changes are done. There is a regression of ?Cancelled(T) to Some?Cancelled. There is some bits of code for the new verion of the ?Cancelled(T) interface already there. Not connected yet but I just reached the limit of what I wanted to do in one commit and then spent over a day cleaning up, so it will replace Some?Cancelled in a future commit.

  • Property mode set to 100644
File size: 776 bytes
Line 
1// Test exceptions that add data but no functionality.
2
3#include <exception.hfa>
4
5EHM_EXCEPTION(paired)(
6        int first;
7        int second;
8);
9
10EHM_VIRTUAL_TABLE(paired, paired_vt);
11
12const char * virtual_msg(paired * this) {
13        return this->virtual_table->msg(this);
14}
15
16int main(int argc, char * argv[]) {
17        paired except = {&paired_vt, 3, 13};
18
19        try {
20                throw except;
21        } catch (paired * exc) {
22                printf("%s(%d, %d)\n", virtual_msg(exc), exc->first, exc->second);
23                ++exc->first;
24        }
25
26        printf("%s(%d, %d)\n", virtual_msg(&except), except.first, except.second);
27
28        try {
29                throwResume except;
30        } catchResume (paired * exc) {
31                printf("%s(%d, %d)\n", virtual_msg(exc), exc->first, exc->second);
32                ++exc->first;
33        }
34
35        printf("%s(%d, %d)\n", virtual_msg(&except), except.first, except.second);
36}
Note: See TracBrowser for help on using the repository browser.