Ignore:
Timestamp:
Jun 16, 2017, 9:07:33 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

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

    r4aa2fb2 r42b0d73  
    1717
    1818void __throw_terminate(exception except) __attribute__((noreturn));
     19void __rethrow_terminate() __attribute__((noreturn));
    1920void __throw_resume(exception except);
    2021
     
    2728        bool (*try_to_handle)(exception except);
    2829};
     30
     31void __try_resume_cleanup(struct __try_resume_node * node);
    2932
    3033struct __cleanup_hook {};
     
    147150void try_resume() {
    148151        {
    149                 bool catch1(exception except) {
     152                bool handle1(exception except) {
    150153                        OtherException inner_except;
    151154                        if (dynamic_cast__SomeException(except)) {
     
    161164                }
    162165                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};
    164167                stack.except.top_resume = &data;
    165168
     
    204207
    205208
    206 // Combining the Above:
     209// Resume + Finally:
     210"Cforall"
     211
     212void 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
     226void 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:
    207253"Cforall"
    208254
     
    226272void try_all() {
    227273        {
     274                bool handle1() {
     275                        if (dynamic_cast__OtherException(except)) {
     276                                twiddleWidget();
     277                                return true;
     278                        }
     279                        return false;
     280                }
    228281                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
    229287                        insideTry();
    230288                }
     
    244302                        return 0;
    245303                }
    246                 bool catch2() {
    247                         if (dynamic_cast__OtherException(except)) {
    248                                 twiddleWidget();
    249                                 return true;
    250                         }
    251                         return false;
    252                 }
    253304                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();
    257305
    258306                        twiddleWidget();
    259307                }
    260 
    261                 struct __try_resume_node generated_name =
    262                         {.next = stack.except.top_resume, .try_to_handle = catch2};
    263                 stack.except.top_resume = &data;
    264308                struct __cleanup_hook generated_name
    265309                        __attribute__((cleanup(finally1)));
Note: See TracChangeset for help on using the changeset viewer.