Ignore:
Timestamp:
Apr 9, 2021, 2:11:43 PM (3 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
b91bfde
Parents:
e07b589
Message:

Major exception update, seperating type-ids from virtual tables. The major interface changes are done. There is a regression of ?Cancelled(T) to Some?Cancelled. There is some bits of code for the new verion of the ?Cancelled(T) interface already there. Not connected yet but I just reached the limit of what I wanted to do in one commit and then spent over a day cleaning up, so it will replace Some?Cancelled in a future commit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/exceptions/resume.cfa

    re07b589 recfd758  
    44#include "except-io.hfa"
    55
    6 TRIVIAL_EXCEPTION(yin);
    7 TRIVIAL_EXCEPTION(yang);
    8 TRIVIAL_EXCEPTION(zen);
    9 TRIVIAL_EXCEPTION(moment_of, zen);
     6EHM_EXCEPTION(yin)();
     7EHM_EXCEPTION(yang)();
     8EHM_EXCEPTION(zen)();
     9
     10EHM_VIRTUAL_TABLE(yin, yin_vt);
     11EHM_VIRTUAL_TABLE(yang, yang_vt);
     12EHM_VIRTUAL_TABLE(zen, zen_vt);
    1013
    1114void in_void(void);
    1215
    1316int main(int argc, char * argv[]) {
     17        yin a_yin = {&yin_vt};
     18        yang a_yang = {&yang_vt};
     19        zen a_zen = {&zen_vt};
     20
    1421        // The simple throw catchResume test.
    1522        try {
    1623                loud_exit a = "simple try clause";
    1724                printf("simple throw\n");
    18                 throwResume (zen){};
     25                throwResume a_zen;
    1926                printf("end of try clause\n");
    2027        } catchResume (zen * error) {
     
    2633        // Throw catch-all test.
    2734        try {
    28                 throwResume (zen){};
     35                throwResume a_zen;
    2936        } catchResume (exception_t * error) {
    3037                printf("catch-all\n");
    31         }
    32         printf("\n");
    33 
    34         // Catch a parent of the given exception.
    35         try {
    36                 printf("throwing child exception\n");
    37                 throwResume (moment_of){};
    38         } catchResume (zen *) {
    39                 printf("inner parent match\n");
    40         } catchResume (moment_of *) {
    41                 printf("outer exact match\n");
    4238        }
    4339        printf("\n");
     
    4642        try {
    4743                try {
    48                         throwResume (yin){};
     44                        throwResume a_yin;
    4945                } catchResume (zen *) {
    5046                        printf("caught yin as zen\n");
     
    6258                        loud_exit a = "rethrow inner try";
    6359                        printf("rethrow inner try\n");
    64                         throwResume (zen){};
     60                        throwResume a_zen;
    6561                } catchResume (zen *) {
    6662                        loud_exit a = "rethrowing catch clause";
     
    7773        try {
    7874                try {
    79                         throwResume (yin){};
     75                        throwResume a_yin;
    8076                } catchResume (yin *) {
    8177                        printf("caught yin, will throw yang\n");
    82                         throwResume (yang){};
     78                        throwResume a_yang;
    8379                } catchResume (yang *) {
    8480                        printf("caught exception from same try\n");
     
    9389                try {
    9490                        printf("throwing first exception\n");
    95                         throwResume (yin){};
     91                        throwResume a_yin;
    9692                } catchResume (yin *) {
    9793                        printf("caught first exception\n");
    9894                        try {
    9995                                printf("throwing second exception\n");
    100                                 throwResume (yang){};
     96                                throwResume a_yang;
    10197                        } catchResume (yang *) {
    10298                                printf("caught second exception\n");
     
    114110        try {
    115111                try {
    116                         throwResume (zen){};
    117                         throwResume (zen){};
     112                        throwResume a_zen;
     113                        throwResume a_zen;
    118114                } catchResume (zen *) {
    119115                        printf("inner catch\n");
    120116                }
    121                 throwResume (zen){};
     117                throwResume a_zen;
    122118        } catchResume (zen *) {
    123119                printf("outer catch\n");
     
    130126// Do a throw and rethrow in a void function.
    131127void in_void(void) {
     128    zen a_zen = {&zen_vt};
    132129        try {
    133130                try {
    134131                        printf("throw\n");
    135                         throwResume (zen){};
     132                        throwResume a_zen;
    136133                } catchResume (zen *) {
    137134                        printf("rethrow\n");
Note: See TracChangeset for help on using the changeset viewer.