Changes in / [6437ce4:ac9ba12]


Ignore:
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/exception.c

    r6437ce4 rac9ba12  
    8585        __cfadbg_print_safe(exception, "Throwing resumption exception\n");
    8686
    87         {
    88                 __attribute__((cleanup(reset_top_resume)))
    89                 struct __cfaehm_try_resume_node * original_head = context->top_resume;
    90                 struct __cfaehm_try_resume_node * current = context->top_resume;
    91 
    92                 for ( ; current ; current = current->next) {
    93                         context->top_resume = current->next;
    94                         if (current->handler(except)) {
    95                                 return;
    96                         }
     87        __attribute__((cleanup(reset_top_resume)))
     88        struct __cfaehm_try_resume_node * original_head = context->top_resume;
     89        struct __cfaehm_try_resume_node * current = context->top_resume;
     90
     91        for ( ; current ; current = current->next) {
     92                context->top_resume = current->next;
     93                if (current->handler(except)) {
     94                        return;
    9795                }
    98         } // End the search and return to the top of the stack.
     96        }
    9997
    10098        // No handler found, fall back to the default operation.
  • tests/exceptions/.expect/defaults.txt

    r6437ce4 rac9ba12  
    33jump default handler.
    44Catch unhandled_exception.
    5 cross terminate throw
    6 cross terminate default
    7 cross terminate catch
    8 cross resume throw
    9 cross resume default
    10 cross resume catch
  • tests/exceptions/defaults.cfa

    r6437ce4 rac9ba12  
    3030                throwResume (log_message){(char *)"Should be printed.\n"};
    3131        } catchResume (log_message * this) {
    32                 printf("%s", this->virtual_table->msg(this));
     32                printf(this->virtual_table->msg(this));
    3333        }
    3434        // But we don't have to:
     
    6969}
    7070
    71 TRIVIAL_EXCEPTION(second);
    72 
    73 void cross_test(void) {
    74         void defaultTerminationHandler(first &) {
    75                 printf("cross terminate default\n");
    76                 throw (second){};
    77         }
    78         void defaultResumptionHandler(first &) {
    79                 printf("cross resume default\n");
    80                 throwResume (second){};
    81         }
    82         try {
    83                 printf("cross terminate throw\n");
    84                 throw (first){};
    85         } catch (second *) {
    86                 printf("cross terminate catch\n");
    87         }
    88         try {
    89                 printf("cross resume throw\n");
    90                 throwResume (first){};
    91         } catchResume (second *) {
    92                 printf("cross resume catch\n");
    93         }
    94 }
    95 
    9671int main(int argc, char * argv[]) {
    9772        log_test();
    9873        jump_test();
    9974        unhandled_test();
    100         cross_test();
    10175}
Note: See TracChangeset for help on using the changeset viewer.