Ignore:
Timestamp:
Apr 9, 2021, 2:11:43 PM (2 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/polymorphic.cfa

    re07b589 recfd758  
    33#include <exception.hfa>
    44
    5 FORALL_TRIVIAL_EXCEPTION(proxy, (T), (T));
    6 FORALL_TRIVIAL_INSTANCE(proxy, (U), (U))
     5EHM_FORALL_EXCEPTION(proxy, (T&), (T))();
    76
    8 const char * msg(proxy(int) * this) { return "proxy(int)"; }
    9 const char * msg(proxy(char) * this) { return "proxy(char)"; }
    10 POLY_VTABLE_INSTANCE(proxy, int)(msg);
    11 POLY_VTABLE_INSTANCE(proxy, char)(msg);
     7EHM_FORALL_VIRTUAL_TABLE(proxy, (int), proxy_int);
     8EHM_FORALL_VIRTUAL_TABLE(proxy, (char), proxy_char);
    129
    1310void proxy_test(void) {
     11        proxy(int) an_int = {&proxy_int};
     12        proxy(char) a_char = {&proxy_char};
     13
    1414    try {
    15                 throw (proxy(int)){};
     15                throw an_int;
    1616        } catch (proxy(int) *) {
    1717                printf("terminate catch\n");
     
    1919
    2020        try {
    21                 throwResume (proxy(char)){};
     21                throwResume a_char;
    2222        } catchResume (proxy(char) *) {
    2323                printf("resume catch\n");
     
    2525
    2626        try {
    27                 throw (proxy(char)){};
     27                throw a_char;
    2828        } catch (proxy(int) *) {
    2929                printf("caught proxy(int)\n");
     
    3333}
    3434
    35 FORALL_DATA_EXCEPTION(cell, (T), (T))(
     35EHM_FORALL_EXCEPTION(cell, (T), (T))(
    3636        T data;
    3737);
    3838
    39 FORALL_DATA_INSTANCE(cell, (T), (T))
    40 
    41 const char * msg(cell(int) * this) { return "cell(int)"; }
    42 const char * msg(cell(char) * this) { return "cell(char)"; }
    43 const char * msg(cell(bool) * this) { return "cell(bool)"; }
    44 POLY_VTABLE_INSTANCE(cell, int)(msg);
    45 POLY_VTABLE_INSTANCE(cell, char)(msg);
    46 POLY_VTABLE_INSTANCE(cell, bool)(msg);
     39EHM_FORALL_VIRTUAL_TABLE(cell, (int), int_cell);
     40EHM_FORALL_VIRTUAL_TABLE(cell, (char), char_cell);
     41EHM_FORALL_VIRTUAL_TABLE(cell, (bool), bool_cell);
    4742
    4843void cell_test(void) {
    4944        try {
    50                 cell(int) except;
    51                 except.data = -7;
     45                cell(int) except = {&int_cell, -7};
    5246                throw except;
    5347        } catch (cell(int) * error) {
     
    5650
    5751        try {
    58                 cell(bool) ball;
    59                 ball.data = false;
     52                cell(bool) ball = {&bool_cell, false};
    6053                throwResume ball;
    6154                printf("%i\n", ball.data);
Note: See TracChangeset for help on using the changeset viewer.