Changeset 35ba584c
- Timestamp:
- Jun 15, 2017, 5:12:41 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 974bcdd, cc3e4d0
- Parents:
- cdd1695
- Location:
- doc/working/exception
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/working/exception/impl/exception.c
rcdd1695 r35ba584c 73 73 } 74 74 75 // Example throw routine76 75 void __throw_terminate( int val ) { 77 76 // Store the current exception … … 107 106 printf("UNWIND ERROR %d after raise exception\n", ret); 108 107 abort(); 108 } 109 110 // Nesting this the other way would probably be faster. 111 void __rethrow_terminate(void) { 112 // DEBUG 113 printf("Rethrowing termination exception\n"); 114 115 __throw_terminate(shared_stack.current_exception); 109 116 } 110 117 -
doc/working/exception/impl/exception.h
rcdd1695 r35ba584c 8 8 // These might be given simpler names and made public. 9 9 void __throw_terminate(exception except) __attribute__((noreturn)); 10 void __rethrow_terminate(void) __attribute__((noreturn)); 10 11 void __throw_resume(exception except); 11 12 … … 22 23 23 24 24 // When I have it working in a single threaded environment. 25 26 /* The following code is temperary. How exceptions interact with coroutines 27 * and threads means that... well I'm going to get it working ignoring those 28 * first, then get it working with concurrency. 29 */ 25 30 struct shared_stack_t { 26 31 //struct lock lock; -
doc/working/exception/impl/test-main.c
rcdd1695 r35ba584c 289 289 // Terminate Rethrow: 290 290 // I don't have an implementation for this. 291 void reterminate() { 292 { 293 void fn_try1() { 294 void fn_try2() { 295 terminate(1); 296 } 297 void fn_catch2(int index, exception except) { 298 switch (index) { 299 case 1: 300 printf("reterminate 2 caught and " 301 "will rethrow exception 1\n"); 302 __rethrow_terminate(); 303 break; 304 default: 305 printf("INVALID INDEX in reterminate 2: %d (%d)\n", 306 index, except); 307 } 308 } 309 int fn_match2(exception except) { 310 if (1 == except) { 311 return 1; 312 } else { 313 return 0; 314 } 315 } 316 __try_terminate(fn_try2, fn_catch2, fn_match2); 317 } 318 void fn_catch1(int index, exception except) { 319 switch (index) { 320 case 1: 321 printf("reterminate 1 caught exception 1\n"); 322 break; 323 default: 324 printf("INVALID INDEX in reterminate 1: %d (%d)\n", 325 index, except); 326 } 327 } 328 int fn_match1(exception except) { 329 if (1 == except) { 330 return 1; 331 } else { 332 return 0; 333 } 334 } 335 __try_terminate(fn_try1, fn_catch1, fn_match1); 336 } 337 } 291 338 292 339 // Resume Rethrow: … … 428 475 terminate_swapped(); printf("\n"); 429 476 resume_swapped(); printf("\n"); 477 reterminate(); printf("\n"); 430 478 reresume(); printf("\n"); 431 479 fee(); printf("\n"); -
doc/working/exception/translate.c
rcdd1695 r35ba584c 54 54 55 55 __throw_resume(exception_instance); 56 57 58 59 // Rethrows (inside matching handlers): 60 "Cforall" 61 62 throw; 63 64 resume; 65 66 "C" 67 68 __rethrow_terminate(); 69 70 return false; 56 71 57 72
Note: See TracChangeset
for help on using the changeset viewer.