Ignore:
Timestamp:
Apr 12, 2021, 5:16:45 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
a1b9bc3
Parents:
56c8b86 (diff), 73f4d08 (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
  • tests/exceptions/data-except.cfa

    r56c8b86 rfe63ae6  
    33#include <exception.hfa>
    44
    5 DATA_EXCEPTION(paired)(
     5EHM_EXCEPTION(paired)(
    66        int first;
    77        int second;
    88);
    99
    10 void ?{}(paired & this, int first, int second) {
    11         VTABLE_INIT(this, paired);
    12         this.first = first;
    13         this.second = second;
    14 }
     10EHM_VIRTUAL_TABLE(paired, paired_vt);
    1511
    16 const char * paired_msg(paired * this) {
    17         return "paired";
    18 }
    19 
    20 VTABLE_INSTANCE(paired)(paired_msg);
    21 
    22 void throwPaired(int first, int second) {
    23         paired exc = {first, second};
     12const char * virtual_msg(paired * this) {
     13        return this->virtual_table->msg(this);
    2414}
    2515
    2616int main(int argc, char * argv[]) {
    27         paired except = {3, 13};
     17        paired except = {&paired_vt, 3, 13};
    2818
    2919        try {
    3020                throw except;
    3121        } catch (paired * exc) {
    32                 printf("%s(%d, %d)\n", paired_msg(exc), exc->first, exc->second);
     22                printf("%s(%d, %d)\n", virtual_msg(exc), exc->first, exc->second);
    3323                ++exc->first;
    3424        }
    3525
    36         printf("%s(%d, %d)\n", paired_msg(&except), except.first, except.second);
     26        printf("%s(%d, %d)\n", virtual_msg(&except), except.first, except.second);
    3727
    3828        try {
    3929                throwResume except;
    4030        } catchResume (paired * exc) {
    41                 printf("%s(%d, %d)\n", paired_msg(exc), exc->first, exc->second);
     31                printf("%s(%d, %d)\n", virtual_msg(exc), exc->first, exc->second);
    4232                ++exc->first;
    4333        }
    4434
    45         printf("%s(%d, %d)\n", paired_msg(&except), except.first, except.second);
     35        printf("%s(%d, %d)\n", virtual_msg(&except), except.first, except.second);
    4636}
Note: See TracChangeset for help on using the changeset viewer.