- Timestamp:
- Jun 22, 2017, 11:26:19 AM (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:
- 9c90718
- Parents:
- 2c37f34
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/working/exception/translate.c
r2c37f34 rf1a10a7 1 1 /* Translation rules for exception handling code, from Cforall to C. 2 2 * 3 * Note that these are not final. Names, syntax and the exact translation 4 * will be updated. The first section is the shared definitions, not generated 5 * by the local translations but used by the translated code. 3 * Reminder: This is not final. Besides names and things it is also going very 4 * much for correctness and simplisity over efficiency. 5 * 6 * The first section is the shared definitions, not generated by the local 7 * translations but used by the translated code. 6 8 * 7 9 * Most of these exist only after translation (in C code). The first (the … … 16 18 typedef int exception; 17 19 20 // Will have to be availibe to user. Consider new name. Requires tagged types. 21 forall(dtype parent | tagged(parent), dtype child | tagged(child)) 22 parent *dynamic_cast(child *); 23 18 24 void __throw_terminate(exception except) __attribute__((noreturn)); 19 25 void __rethrow_terminate() __attribute__((noreturn)); … … 116 122 } 117 123 int match1(exception except) { 118 OtherException inner_except; 119 if (dynamic_cast__SomeException(except)) { 120 return 1; 121 } 122 else if ( (inner_except = dynamic_cast__OtherException(except)) && 123 inner_except.priority > 3) { 124 return 2; 125 } 126 else return 0; 124 { 125 if (dynamic_cast__SomeException(except)) { 126 return 1; 127 } 128 } 129 { 130 OtherException err; 131 if ( (err = dynamic_cast__OtherException(except)) && 132 err.priority > 3) { 133 return 2; 134 } 135 } 136 return 0; 127 137 } 128 138 __try_terminate(try1, catch1, match1); … … 151 161 { 152 162 bool handle1(exception except) { 153 OtherException inner_except; 154 if (dynamic_cast__SomeException(except)) { 155 fiddleThing(); 156 return true; 157 } else if (dynamic_cast__OtherException(except) && 158 inner_except.priority > 3) { 159 twiddleWidget(); 160 return true; 161 } else { 162 return false; 163 } 163 { 164 if (dynamic_cast__SomeException(except)) { 165 fiddleThing(); 166 return true; 167 } 168 } 169 { 170 OtherException err; 171 if ( ( err = dynamic_cast__OtherException(except) ) && 172 err.priority > 3) { 173 twiddleWidget(); 174 return true; 175 } 176 } 177 return false; 164 178 } 165 179 struct __try_resume_node data = … … 230 244 } 231 245 bool handle1(exception except) { 232 if (dynamic_cast__SomeException(except)) { 233 fiddleThing(); 234 return true; 235 } else { 236 return false; 237 } 246 { 247 if (dynamic_cast__SomeException(except)) { 248 fiddleThing(); 249 return true; 250 } 251 } 252 return false; 238 253 } 239 254 struct __cleanup_hook generated_name … … 273 288 { 274 289 bool handle1() { 275 if (dynamic_cast__OtherException(except)) { 276 twiddleWidget(); 277 return true; 290 { 291 if (dynamic_cast__OtherException(except)) { 292 twiddleWidget(); 293 return true; 294 } 278 295 } 279 296 return false; … … 297 314 } 298 315 int match1(exception except) { 299 if (dynamic_cast__SomeException(except)) { 300 return 1; 316 { 317 if (dynamic_cast__SomeException(except)) { 318 return 1; 319 } 301 320 } 302 321 return 0;
Note: See TracChangeset
for help on using the changeset viewer.