Changeset 69c5c00 for libcfa/src
- Timestamp:
- Oct 7, 2020, 6:08:35 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 6fbe9a5
- Parents:
- 41b8ea4
- Location:
- libcfa/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/coroutine.cfa
r41b8ea4 r69c5c00 47 47 48 48 //----------------------------------------------------------------------------- 49 FORALL_DATA_INSTANCE(CoroutineCancelled, 50 (dtype coroutine_t | sized(coroutine_t)), (coroutine_t)) 49 FORALL_DATA_INSTANCE(CoroutineCancelled, (dtype coroutine_t), (coroutine_t)) 51 50 52 51 struct __cfaehm_node { … … 59 58 void mark_exception(CoroutineCancelled(T) *) {} 60 59 61 forall(dtype T | sized(T))60 forall(dtype T) 62 61 void copy(CoroutineCancelled(T) * dst, CoroutineCancelled(T) * src) { 63 62 dst->the_coroutine = src->the_coroutine; … … 77 76 exception_t * except = (exception_t *)(1 + (__cfaehm_node *)desc->cancellation); 78 77 78 // TODO: Remove explitate vtable set once trac#186 is fixed. 79 79 CoroutineCancelled(T) except; 80 except.virtual_table = &get_exception_vtable(&except); 80 81 except.the_coroutine = &cor; 81 82 except.the_exception = except; -
libcfa/src/concurrency/coroutine.hfa
r41b8ea4 r69c5c00 22 22 //----------------------------------------------------------------------------- 23 23 // Exception thrown from resume when a coroutine stack is cancelled. 24 // Should not have to be be sized (see trac #196). 25 FORALL_DATA_EXCEPTION(CoroutineCancelled, 26 (dtype coroutine_t | sized(coroutine_t)), (coroutine_t)) ( 24 FORALL_DATA_EXCEPTION(CoroutineCancelled, (dtype coroutine_t), (coroutine_t)) ( 27 25 coroutine_t * the_coroutine; 28 26 exception_t * the_exception; … … 30 28 31 29 forall(dtype T) 32 void mark_exception(CoroutineCancelled(T) *);33 34 forall(dtype T | sized(T))35 30 void copy(CoroutineCancelled(T) * dst, CoroutineCancelled(T) * src); 36 31 … … 42 37 // Anything that implements this trait can be resumed. 43 38 // Anything that is resumed is a coroutine. 44 trait is_coroutine(dtype T | sized(T)45 | is_resumption_exception(CoroutineCancelled(T) )46 | VTABLE_ASSERTION(CoroutineCancelled,(T))) {39 trait is_coroutine(dtype T 40 | is_resumption_exception(CoroutineCancelled(T), 41 CoroutineCancelled_vtable(T))) { 47 42 void main(T & this); 48 43 $coroutine * get_coroutine(T & this); -
libcfa/src/exception.h
r41b8ea4 r69c5c00 76 76 // implemented in the .c file either so they all have to be inline. 77 77 78 trait is_exception(dtype exceptT ) {78 trait is_exception(dtype exceptT, dtype virtualT) { 79 79 /* The first field must be a pointer to a virtual table. 80 * That virtual table must be a decendent of the base exception virtual tab $80 * That virtual table must be a decendent of the base exception virtual table. 81 81 */ 82 v oid mark_exception(exceptT *);83 // This is never used and should be a no-op.82 virtualT const & get_exception_vtable(exceptT *); 83 // Always returns the virtual table for this type (associated types hack). 84 84 }; 85 85 86 trait is_termination_exception(dtype exceptT | is_exception(exceptT)) {86 trait is_termination_exception(dtype exceptT, dtype virtualT | is_exception(exceptT, virtualT)) { 87 87 void defaultTerminationHandler(exceptT &); 88 88 }; 89 89 90 trait is_resumption_exception(dtype exceptT | is_exception(exceptT)) {90 trait is_resumption_exception(dtype exceptT, dtype virtualT | is_exception(exceptT, virtualT)) { 91 91 void defaultResumptionHandler(exceptT &); 92 92 }; 93 93 94 forall(dtype exceptT | is_termination_exception(exceptT))94 forall(dtype exceptT, dtype virtualT | is_termination_exception(exceptT, virtualT)) 95 95 static inline void $throw(exceptT & except) { 96 96 __cfaehm_throw_terminate( … … 100 100 } 101 101 102 forall(dtype exceptT | is_resumption_exception(exceptT))102 forall(dtype exceptT, dtype virtualT | is_resumption_exception(exceptT, virtualT)) 103 103 static inline void $throwResume(exceptT & except) { 104 104 __cfaehm_throw_resume( … … 108 108 } 109 109 110 forall(dtype exceptT | is_exception(exceptT))110 forall(dtype exceptT, dtype virtualT | is_exception(exceptT, virtualT)) 111 111 static inline void cancel_stack(exceptT & except) __attribute__((noreturn)) { 112 112 __cfaehm_cancel_stack( (exception_t *)&except ); 113 113 } 114 114 115 forall(dtype exceptT | is_exception(exceptT))115 forall(dtype exceptT, dtype virtualT | is_exception(exceptT, virtualT)) 116 116 static inline void defaultTerminationHandler(exceptT & except) { 117 117 return cancel_stack( except ); 118 118 } 119 119 120 forall(dtype exceptT | is_exception(exceptT))120 forall(dtype exceptT, dtype virtualT | is_exception(exceptT, virtualT)) 121 121 static inline void defaultResumptionHandler(exceptT & except) { 122 122 throw except; -
libcfa/src/exception.hfa
r41b8ea4 r69c5c00 95 95 // visible anywhere you use the instantiation of the exception is used. 96 96 #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__) *); \ 98 98 extern VTABLE_TYPE(exception_name)(__VA_ARGS__) VTABLE_NAME(exception_name) 99 99 … … 160 160 161 161 #define _FORALL_CTOR0_DECLARATION(exception_name, assertions, parameters) \ 162 forall(_UNPACK assertions | VTABLE_ASSERTION(exception_name, parameters) ) \ 162 forall(_UNPACK assertions | \ 163 is_exception(exception_name parameters, VTABLE_TYPE(exception_name) parameters)) \ 163 164 void ?{}(exception_name parameters & this) 164 165 165 166 #define _FORALL_CTOR0_INSTANCE(exception_name, assertions, parameters) \ 166 167 _FORALL_CTOR0_DECLARATION(exception_name, assertions, parameters) { \ 167 VTABLE_INIT(this, exception_name); \168 (this).virtual_table = &get_exception_vtable(&this); \ 168 169 } 169 170 … … 185 186 #define _VTABLE_DECLARATION(exception_name, parent_name, ...) \ 186 187 struct exception_name; \ 187 void mark_exception(exception_name *); \188 188 VTABLE_TYPE(exception_name); \ 189 VTABLE_TYPE(exception_name) const & get_exception_vtable(exception_name *); \ 189 190 extern VTABLE_TYPE(exception_name) VTABLE_NAME(exception_name); \ 190 191 VTABLE_TYPE(exception_name) { \ … … 197 198 198 199 #define _VTABLE_INSTANCE(exception_name, parent_name, ...) \ 199 void mark_exception(exception_name *) {} \ 200 VTABLE_TYPE(exception_name) const & get_exception_vtable(exception_name *) { \ 201 return VTABLE_NAME(exception_name); \ 202 } \ 200 203 void _GLUE2(exception_name,_copy)(exception_name * this, exception_name * other) { \ 201 204 *this = *other; \ … … 218 221 219 222 #define _POLY_VTABLE_INSTANCE(exception_name, parent_name, ...) \ 220 void mark_exception(exception_name(__VA_ARGS__) *) {} \ 223 extern VTABLE_TYPE(exception_name)(__VA_ARGS__) VTABLE_NAME(exception_name); \ 224 VTABLE_TYPE(exception_name)(__VA_ARGS__) const & get_exception_vtable( \ 225 exception_name(__VA_ARGS__) *) { \ 226 return VTABLE_NAME(exception_name); \ 227 } \ 221 228 void _GLUE2(exception_name,_copy)( \ 222 229 exception_name(__VA_ARGS__) * this, exception_name(__VA_ARGS__) * other) { \
Note:
See TracChangeset
for help on using the changeset viewer.