Changeset ecfd758 for tests/exceptions/polymorphic.cfa
- Timestamp:
- Apr 9, 2021, 2:11:43 PM (2 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b91bfde
- Parents:
- e07b589
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/exceptions/polymorphic.cfa
re07b589 recfd758 3 3 #include <exception.hfa> 4 4 5 FORALL_TRIVIAL_EXCEPTION(proxy, (T), (T)); 6 FORALL_TRIVIAL_INSTANCE(proxy, (U), (U)) 5 EHM_FORALL_EXCEPTION(proxy, (T&), (T))(); 7 6 8 const char * msg(proxy(int) * this) { return "proxy(int)"; } 9 const char * msg(proxy(char) * this) { return "proxy(char)"; } 10 POLY_VTABLE_INSTANCE(proxy, int)(msg); 11 POLY_VTABLE_INSTANCE(proxy, char)(msg); 7 EHM_FORALL_VIRTUAL_TABLE(proxy, (int), proxy_int); 8 EHM_FORALL_VIRTUAL_TABLE(proxy, (char), proxy_char); 12 9 13 10 void proxy_test(void) { 11 proxy(int) an_int = {&proxy_int}; 12 proxy(char) a_char = {&proxy_char}; 13 14 14 try { 15 throw (proxy(int)){};15 throw an_int; 16 16 } catch (proxy(int) *) { 17 17 printf("terminate catch\n"); … … 19 19 20 20 try { 21 throwResume (proxy(char)){};21 throwResume a_char; 22 22 } catchResume (proxy(char) *) { 23 23 printf("resume catch\n"); … … 25 25 26 26 try { 27 throw (proxy(char)){};27 throw a_char; 28 28 } catch (proxy(int) *) { 29 29 printf("caught proxy(int)\n"); … … 33 33 } 34 34 35 FORALL_DATA_EXCEPTION(cell, (T), (T))(35 EHM_FORALL_EXCEPTION(cell, (T), (T))( 36 36 T data; 37 37 ); 38 38 39 FORALL_DATA_INSTANCE(cell, (T), (T)) 40 41 const char * msg(cell(int) * this) { return "cell(int)"; } 42 const char * msg(cell(char) * this) { return "cell(char)"; } 43 const char * msg(cell(bool) * this) { return "cell(bool)"; } 44 POLY_VTABLE_INSTANCE(cell, int)(msg); 45 POLY_VTABLE_INSTANCE(cell, char)(msg); 46 POLY_VTABLE_INSTANCE(cell, bool)(msg); 39 EHM_FORALL_VIRTUAL_TABLE(cell, (int), int_cell); 40 EHM_FORALL_VIRTUAL_TABLE(cell, (char), char_cell); 41 EHM_FORALL_VIRTUAL_TABLE(cell, (bool), bool_cell); 47 42 48 43 void cell_test(void) { 49 44 try { 50 cell(int) except; 51 except.data = -7; 45 cell(int) except = {&int_cell, -7}; 52 46 throw except; 53 47 } catch (cell(int) * error) { … … 56 50 57 51 try { 58 cell(bool) ball; 59 ball.data = false; 52 cell(bool) ball = {&bool_cell, false}; 60 53 throwResume ball; 61 54 printf("%i\n", ball.data);
Note: See TracChangeset
for help on using the changeset viewer.