Changeset 42b0d73 for doc/working/exception/translate.c
- Timestamp:
- Jun 16, 2017, 9:07:33 PM (7 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:
- 436c0de, e1c1829, ec35498
- Parents:
- 4aa2fb2 (diff), e1055441 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/working/exception/translate.c
r4aa2fb2 r42b0d73 17 17 18 18 void __throw_terminate(exception except) __attribute__((noreturn)); 19 void __rethrow_terminate() __attribute__((noreturn)); 19 20 void __throw_resume(exception except); 20 21 … … 27 28 bool (*try_to_handle)(exception except); 28 29 }; 30 31 void __try_resume_cleanup(struct __try_resume_node * node); 29 32 30 33 struct __cleanup_hook {}; … … 147 150 void try_resume() { 148 151 { 149 bool catch1(exception except) {152 bool handle1(exception except) { 150 153 OtherException inner_except; 151 154 if (dynamic_cast__SomeException(except)) { … … 161 164 } 162 165 struct __try_resume_node data = 163 {.next = stack.except.top_resume, .try_to_handle = catch1};166 {.next = stack.except.top_resume, .try_to_handle = handle1}; 164 167 stack.except.top_resume = &data; 165 168 … … 204 207 205 208 206 // Combining the Above: 209 // Resume + Finally: 210 "Cforall" 211 212 void try_resume_finally() { 213 try { 214 insideTry(); 215 } 216 catch resume (SomeException) { 217 fiddleThing(); 218 } 219 finally { 220 twiddleWidget(); 221 } 222 } 223 224 "C" 225 226 void try_resume_finally() { 227 { 228 void finally1() { 229 twiddleWidget(); 230 } 231 bool handle1(exception except) { 232 if (dynamic_cast__SomeException(except)) { 233 fiddleThing(); 234 return true; 235 } else { 236 return false; 237 } 238 } 239 struct __cleanup_hook generated_name 240 __attribute__((cleanup(finally1))); 241 242 struct __try_resume_node data = 243 {.next = stack.except.top_resume, .try_to_handle = handle1}; 244 stack.except.top_resume = &data; 245 246 struct __cleanup_hook generated_name 247 __attribute__((cleanup(__try_resume_cleanup))); 248 } 249 } 250 251 252 // Terminate + Resume + Finally: 207 253 "Cforall" 208 254 … … 226 272 void try_all() { 227 273 { 274 bool handle1() { 275 if (dynamic_cast__OtherException(except)) { 276 twiddleWidget(); 277 return true; 278 } 279 return false; 280 } 228 281 void try1 () { 282 struct __try_resume_node generated_name = 283 {.next = stack.except.top_resume, .try_to_handle = handle1} 284 __attribute__((cleanup(__try_resume_cleanup))); 285 stack.except.top_resume = &data; 286 229 287 insideTry(); 230 288 } … … 244 302 return 0; 245 303 } 246 bool catch2() {247 if (dynamic_cast__OtherException(except)) {248 twiddleWidget();249 return true;250 }251 return false;252 }253 304 void finally1() { 254 // Finally, because of timing, also works for resume.255 // However this might not actually be better in any way.256 __try_resume_cleanup();257 305 258 306 twiddleWidget(); 259 307 } 260 261 struct __try_resume_node generated_name =262 {.next = stack.except.top_resume, .try_to_handle = catch2};263 stack.except.top_resume = &data;264 308 struct __cleanup_hook generated_name 265 309 __attribute__((cleanup(finally1)));
Note: See TracChangeset
for help on using the changeset viewer.