- File:
-
- 1 edited
-
doc/working/exception/translate.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/working/exception/translate.c
rf1a10a7 rc529a24 1 1 /* Translation rules for exception handling code, from Cforall to C. 2 2 * 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. 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. 8 6 * 9 7 * Most of these exist only after translation (in C code). The first (the … … 17 15 // Currently it is a typedef for int, but later it will be a new type. 18 16 typedef int exception; 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 17 24 18 void __throw_terminate(exception except) __attribute__((noreturn)); … … 122 116 } 123 117 int match1(exception except) { 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; 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; 137 127 } 138 128 __try_terminate(try1, catch1, match1); … … 161 151 { 162 152 bool handle1(exception except) { 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; 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 } 178 164 } 179 165 struct __try_resume_node data = … … 244 230 } 245 231 bool handle1(exception except) { 246 { 247 if (dynamic_cast__SomeException(except)) { 248 fiddleThing(); 249 return true; 250 } 251 } 252 return false; 232 if (dynamic_cast__SomeException(except)) { 233 fiddleThing(); 234 return true; 235 } else { 236 return false; 237 } 253 238 } 254 239 struct __cleanup_hook generated_name … … 288 273 { 289 274 bool handle1() { 290 { 291 if (dynamic_cast__OtherException(except)) { 292 twiddleWidget(); 293 return true; 294 } 275 if (dynamic_cast__OtherException(except)) { 276 twiddleWidget(); 277 return true; 295 278 } 296 279 return false; … … 314 297 } 315 298 int match1(exception except) { 316 { 317 if (dynamic_cast__SomeException(except)) { 318 return 1; 319 } 299 if (dynamic_cast__SomeException(except)) { 300 return 1; 320 301 } 321 302 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.