Ignore:
Timestamp:
Oct 23, 2020, 9:08:09 PM (3 years ago)
Author:
Fangren Yu <f37yu@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
c532847
Parents:
37b7d95 (diff), 3aec25f (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 into master

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/exception.hfa

    r37b7d95 re7d6968  
    9595// visible anywhere you use the instantiation of the exception is used.
    9696#define POLY_VTABLE_DECLARATION(exception_name, ...) \
    97         void mark_exception(exception_name(__VA_ARGS__) *); \
     97        VTABLE_TYPE(exception_name)(__VA_ARGS__) const & get_exception_vtable(exception_name(__VA_ARGS__) *); \
    9898        extern VTABLE_TYPE(exception_name)(__VA_ARGS__) VTABLE_NAME(exception_name)
    9999
     
    125125#define VTABLE_ASSERTION(exception_name, parameters) \
    126126        { VTABLE_TYPE(exception_name) parameters VTABLE_NAME(exception_name); }
     127
     128// IS_EXCEPTION(exception_name [, (...parameters)])
     129// IS_RESUMPTION_EXCEPTION(exception_name [, (parameters...)])
     130// IS_TERMINATION_EXCEPTION(exception_name [, (parameters...)])
     131// Create an assertion that exception_name, possibly with the qualifing parameters, is the given
     132// kind of exception with the standard vtable with the same parameters if applicable.
     133#define IS_EXCEPTION(...) _IS_EXCEPTION(is_exception, __VA_ARGS__, , ~)
     134#define IS_RESUMPTION_EXCEPTION(...) _IS_EXCEPTION(is_resumption_exception, __VA_ARGS__, , ~)
     135#define IS_TERMINATION_EXCEPTION(...) _IS_EXCEPTION(is_termination_exception, __VA_ARGS__, , ~)
    127136
    128137// All internal helper macros begin with an underscore.
     
    160169
    161170#define _FORALL_CTOR0_DECLARATION(exception_name, assertions, parameters) \
    162         forall(_UNPACK assertions | VTABLE_ASSERTION(exception_name, parameters) ) \
     171        forall(_UNPACK assertions | \
     172                is_exception(exception_name parameters, VTABLE_TYPE(exception_name) parameters)) \
    163173        void ?{}(exception_name parameters & this)
    164174
    165175#define _FORALL_CTOR0_INSTANCE(exception_name, assertions, parameters) \
    166176        _FORALL_CTOR0_DECLARATION(exception_name, assertions, parameters) { \
    167                 VTABLE_INIT(this, exception_name); \
     177                (this).virtual_table = &get_exception_vtable(&this); \
    168178        }
    169179
     
    185195#define _VTABLE_DECLARATION(exception_name, parent_name, ...) \
    186196        struct exception_name; \
    187         void mark_exception(exception_name *); \
    188197        VTABLE_TYPE(exception_name); \
     198        VTABLE_TYPE(exception_name) const & get_exception_vtable(exception_name *); \
    189199        extern VTABLE_TYPE(exception_name) VTABLE_NAME(exception_name); \
    190200        VTABLE_TYPE(exception_name) { \
     
    197207
    198208#define _VTABLE_INSTANCE(exception_name, parent_name, ...) \
    199         void mark_exception(exception_name *) {} \
     209        VTABLE_TYPE(exception_name) const & get_exception_vtable(exception_name *) { \
     210                return VTABLE_NAME(exception_name); \
     211        } \
    200212        void _GLUE2(exception_name,_copy)(exception_name * this, exception_name * other) { \
    201213                *this = *other; \
     
    218230
    219231#define _POLY_VTABLE_INSTANCE(exception_name, parent_name, ...) \
    220         void mark_exception(exception_name(__VA_ARGS__) *) {} \
     232        extern VTABLE_TYPE(exception_name)(__VA_ARGS__) VTABLE_NAME(exception_name); \
     233        VTABLE_TYPE(exception_name)(__VA_ARGS__) const & get_exception_vtable( \
     234                        exception_name(__VA_ARGS__) *) { \
     235                return VTABLE_NAME(exception_name); \
     236        } \
    221237        void _GLUE2(exception_name,_copy)( \
    222238                        exception_name(__VA_ARGS__) * this, exception_name(__VA_ARGS__) * other) { \
     
    227243                _GLUE2(exception_name,_copy), ^?{}, \
    228244                _CLOSE
     245
     246#define _IS_EXCEPTION(kind, exception_name, parameters, ...) \
     247        kind(exception_name parameters, VTABLE_TYPE(exception_name) parameters)
Note: See TracChangeset for help on using the changeset viewer.