Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/working/exception/translate.c

    rf1a10a7 rc529a24  
    11/* Translation rules for exception handling code, from Cforall to C.
    22 *
    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.
    86 *
    97 * Most of these exist only after translation (in C code). The first (the
     
    1715// Currently it is a typedef for int, but later it will be a new type.
    1816typedef 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 *);
    2317
    2418void __throw_terminate(exception except) __attribute__((noreturn));
     
    122116                }
    123117                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;
    137127                }
    138128                __try_terminate(try1, catch1, match1);
     
    161151        {
    162152                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                        }
    178164                }
    179165                struct __try_resume_node data =
     
    244230                }
    245231                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                        }
    253238                }
    254239                struct __cleanup_hook generated_name
     
    288273        {
    289274                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;
    295278                        }
    296279                        return false;
     
    314297                }
    315298                int match1(exception except) {
    316                         {
    317                                 if (dynamic_cast__SomeException(except)) {
    318                                         return 1;
    319                                 }
     299                        if (dynamic_cast__SomeException(except)) {
     300                                return 1;
    320301                        }
    321302                        return 0;
Note: See TracChangeset for help on using the changeset viewer.