Changeset 8a97248
- Timestamp:
- Feb 3, 2023, 1:28:36 PM (22 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 2125443a
- Parents:
- 7a24d76
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/prelude/builtins.c
r7a24d76 r8a97248 10 10 // Created On : Fri Jul 21 16:21:03 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 14 08:45:54 202113 // Update Count : 13 312 // Last Modified On : Thu Feb 2 11:33:56 2023 13 // Update Count : 135 14 14 // 15 15 … … 64 64 static inline void ^?{}(generator$ &) {} 65 65 66 trait is_generator(T &) { 66 forall( T & ) 67 trait is_generator { 67 68 void main(T & this); 68 69 generator$ * get_generator(T & this); -
libcfa/prelude/prelude-gen.cc
r7a24d76 r8a97248 10 10 // Created On : Sat Feb 16 08:44:58 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Apr 2 17:18:24 201913 // Update Count : 3 712 // Last Modified On : Thu Feb 2 11:40:01 2023 13 // Update Count : 38 14 14 // 15 15 … … 159 159 int main() { 160 160 cout << "# 2 \"prelude.cfa\" // needed for error messages from this file" << endl; 161 cout << " trait sized(T &){};" << endl;161 cout << "forall( T & ) trait sized {};" << endl; 162 162 163 163 cout << "//////////////////////////" << endl; -
libcfa/src/bits/containers.hfa
r7a24d76 r8a97248 10 10 // Created On : Tue Oct 31 16:38:50 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jan 15 07:42:35 202013 // Update Count : 2 812 // Last Modified On : Thu Feb 2 11:33:08 2023 13 // Update Count : 29 14 14 15 15 #pragma once … … 69 69 70 70 #ifdef __cforall 71 trait is_node(T &) { 71 forall( T & ) 72 trait is_node { 72 73 T *& get_next( T & ); 73 74 }; -
libcfa/src/concurrency/coroutine.hfa
r7a24d76 r8a97248 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 6 16:33:16 202213 // Update Count : 1 212 // Last Modified On : Thu Feb 2 11:31:42 2023 13 // Update Count : 13 14 14 // 15 15 … … 38 38 // Anything that implements this trait can be resumed. 39 39 // Anything that is resumed is a coroutine. 40 trait is_coroutine(T & | IS_RESUMPTION_EXCEPTION(CoroutineCancelled(T))) { 40 forall( T & | IS_RESUMPTION_EXCEPTION(CoroutineCancelled(T)) ) 41 trait is_coroutine { 41 42 void main(T & this); 42 43 coroutine$ * get_coroutine(T & this); -
libcfa/src/concurrency/locks.hfa
r7a24d76 r8a97248 640 640 //----------------------------------------------------------------------------- 641 641 // is_blocking_lock 642 trait is_blocking_lock(L & | sized(L)) { 642 forall( L & | sized(L) ) 643 trait is_blocking_lock { 643 644 // For synchronization locks to use when acquiring 644 645 void on_notify( L &, struct thread$ * ); -
libcfa/src/concurrency/monitor.hfa
r7a24d76 r8a97248 10 10 // Created On : Thd Feb 23 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 4 07:55:32 201913 // Update Count : 1 112 // Last Modified On : Thu Feb 2 11:29:21 2023 13 // Update Count : 12 14 14 // 15 15 … … 22 22 #include "stdlib.hfa" 23 23 24 trait is_monitor(T &) { 24 forall( T & ) 25 trait is_monitor { 25 26 monitor$ * get_monitor( T & ); 26 27 void ^?{}( T & mutex ); -
libcfa/src/concurrency/mutex.hfa
r7a24d76 r8a97248 12 12 // Created On : Fri May 25 01:24:09 2018 13 13 // Last Modified By : Peter A. Buhr 14 // Last Modified On : Wed Dec 4 09:16:53 201915 // Update Count : 114 // Last Modified On : Thu Feb 2 11:46:08 2023 15 // Update Count : 2 16 16 // 17 17 … … 70 70 void unlock(recursive_mutex_lock & this) __attribute__((deprecated("use concurrency/locks.hfa instead"))); 71 71 72 trait is_lock(L & | sized(L)) { 72 forall( L & | sized(L) ) 73 trait is_lock { 73 74 void lock (L &); 74 75 void unlock(L &); -
libcfa/src/concurrency/thread.hfa
r7a24d76 r8a97248 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Nov 22 22:18:34 202213 // Update Count : 3 512 // Last Modified On : Thu Feb 2 11:27:59 2023 13 // Update Count : 37 14 14 // 15 15 … … 27 27 //----------------------------------------------------------------------------- 28 28 // thread trait 29 trait is_thread(T &) { 29 forall( T & ) 30 trait is_thread { 30 31 void ^?{}(T& mutex this); 31 32 void main(T& this); -
libcfa/src/containers/list.hfa
r7a24d76 r8a97248 9 9 // Author : Michael Brooks 10 10 // Created On : Wed Apr 22 18:00:00 2020 11 // Last Modified By : Michael Brooks12 // Last Modified On : Wed Apr 22 18:00:00 202013 // Update Count : 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 11:32:26 2023 13 // Update Count : 2 14 14 // 15 15 … … 23 23 }; 24 24 25 trait embedded( tOuter &, tMid &, tInner & ) { 25 forall( tOuter &, tMid &, tInner & ) 26 trait embedded { 26 27 tytagref( tMid, tInner ) ?`inner( tOuter & ); 27 28 }; -
libcfa/src/containers/vector.hfa
r7a24d76 r8a97248 10 10 // Created On : Tue Jul 5 18:00:07 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 17 11:02:46 202013 // Update Count : 412 // Last Modified On : Thu Feb 2 11:41:24 2023 13 // Update Count : 5 14 14 // 15 15 … … 50 50 //------------------------------------------------------------------------------ 51 51 //Declaration 52 trait allocator_c(T, allocator_t)53 {52 forall( T, allocator_t ) 53 trait allocator_c { 54 54 void realloc_storage(allocator_t*, size_t); 55 55 T* data(allocator_t*); -
libcfa/src/exception.h
r7a24d76 r8a97248 9 9 // Author : Andrew Beach 10 10 // Created On : Mon Jun 26 15:11:00 2017 11 // Last Modified By : Andrew Beach12 // Last Modified On : Th r Apr 8 15:20:00 202113 // Update Count : 1 211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 11:20:19 2023 13 // Update Count : 13 14 14 // 15 15 … … 101 101 // implemented in the .c file either so they all have to be inline. 102 102 103 trait is_exception(exceptT &, virtualT &) { 103 forall( exceptT &, virtualT & ) 104 trait is_exception { 104 105 /* The first field must be a pointer to a virtual table. 105 106 * That virtual table must be a decendent of the base exception virtual table. … … 109 110 }; 110 111 111 trait is_termination_exception(exceptT &, virtualT & | is_exception(exceptT, virtualT)) { 112 forall( exceptT &, virtualT & | is_exception(exceptT, virtualT) ) 113 trait is_termination_exception { 112 114 void defaultTerminationHandler(exceptT &); 113 115 }; 114 116 115 trait is_resumption_exception(exceptT &, virtualT & | is_exception(exceptT, virtualT)) { 117 forall( exceptT &, virtualT & | is_exception(exceptT, virtualT) ) 118 trait is_resumption_exception { 116 119 void defaultResumptionHandler(exceptT &); 117 120 }; -
libcfa/src/iostream.hfa
r7a24d76 r8a97248 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Oct 10 10:02:07 202113 // Update Count : 4 0712 // Last Modified On : Thu Feb 2 11:25:39 2023 13 // Update Count : 410 14 14 // 15 15 … … 22 22 23 23 24 trait basic_ostream( ostype & ) { 24 forall( ostype & ) 25 trait basic_ostream { 25 26 // private 26 27 bool sepPrt$( ostype & ); // get separator state (on/off) … … 51 52 }; // basic_ostream 52 53 53 trait ostream( ostype & | basic_ostream( ostype ) ) { 54 forall( ostype & | basic_ostream( ostype ) ) 55 trait ostream { 54 56 bool fail( ostype & ); // operation failed? 55 57 void clear( ostype & ); … … 60 62 }; // ostream 61 63 62 // trait writeable( T ) { 64 // forall( T ) 65 // trait writeable { 63 66 // forall( ostype & | ostream( ostype ) ) ostype & ?|?( ostype &, T ); 64 67 // }; // writeable 65 68 66 trait writeable( T, ostype & | ostream( ostype ) ) { 69 forall( T, ostype & | ostream( ostype ) ) 70 trait writeable { 67 71 ostype & ?|?( ostype &, T ); 68 72 }; // writeable … … 290 294 291 295 292 trait basic_istream( istype & ) { 296 forall( istype & ) 297 trait basic_istream { 293 298 // private 294 299 bool getANL$( istype & ); // get scan newline (on/off) … … 302 307 }; // basic_istream 303 308 304 trait istream( istype & | basic_istream( istype ) ) { 309 forall( istype & | basic_istream( istype ) ) 310 trait istream { 305 311 bool fail( istype & ); 306 312 void clear( istype & ); … … 310 316 }; // istream 311 317 312 trait readable( T ) { 318 forall( T ) 319 trait readable { 313 320 forall( istype & | istream( istype ) ) istype & ?|?( istype &, T ); 314 321 }; // readable -
libcfa/src/iterator.hfa
r7a24d76 r8a97248 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 7 08:37:25 201713 // Update Count : 1 012 // Last Modified On : Thu Feb 2 11:21:50 2023 13 // Update Count : 11 14 14 // 15 15 … … 17 17 18 18 // An iterator can be used to traverse a data structure. 19 trait iterator( iterator_type, elt_type ) { 19 forall( iterator_type, elt_type ) 20 trait iterator { 20 21 // point to the next element 21 22 // iterator_type ?++( iterator_type & ); … … 31 32 }; 32 33 33 trait iterator_for( iterator_type, collection_type, elt_type | iterator( iterator_type, elt_type ) ) { 34 forall( iterator_type, collection_type, elt_type | iterator( iterator_type, elt_type ) ) 35 trait iterator_for { 34 36 // [ iterator_type begin, iterator_type end ] get_iterators( collection_type ); 35 37 iterator_type begin( collection_type ); -
libcfa/src/math.trait.hfa
r7a24d76 r8a97248 10 10 // Created On : Fri Jul 16 15:40:52 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 20 17:47:19 202113 // Update Count : 1912 // Last Modified On : Thu Feb 2 11:36:56 2023 13 // Update Count : 20 14 14 // 15 15 16 16 #pragma once 17 17 18 trait Not( U ) { 18 forall( U ) 19 trait Not { 19 20 void ?{}( U &, zero_t ); 20 21 int !?( U ); 21 22 }; // Not 22 23 23 trait Equality( T | Not( T ) ) { 24 forall( T | Not( T ) ) 25 trait Equality { 24 26 int ?==?( T, T ); 25 27 int ?!=?( T, T ); 26 28 }; // Equality 27 29 28 trait Relational( U | Equality( U ) ) { 30 forall( U | Equality( U ) ) 31 trait Relational { 29 32 int ?<?( U, U ); 30 33 int ?<=?( U, U ); … … 33 36 }; // Relational 34 37 35 trait Signed( T ) { 38 forall ( T ) 39 trait Signed { 36 40 T +?( T ); 37 41 T -?( T ); … … 39 43 }; // Signed 40 44 41 trait Additive( U | Signed( U ) ) { 45 forall( U | Signed( U ) ) 46 trait Additive { 42 47 U ?+?( U, U ); 43 48 U ?-?( U, U ); … … 46 51 }; // Additive 47 52 48 trait Incdec( T | Additive( T ) ) { 53 forall( T | Additive( T ) ) 54 trait Incdec { 49 55 void ?{}( T &, one_t ); 50 56 // T ?++( T & ); … … 54 60 }; // Incdec 55 61 56 trait Multiplicative( U | Incdec( U ) ) { 62 forall( U | Incdec( U ) ) 63 trait Multiplicative { 57 64 U ?*?( U, U ); 58 65 U ?/?( U, U ); … … 61 68 }; // Multiplicative 62 69 63 trait Arithmetic( T | Relational( T ) | Multiplicative( T ) ) { 70 forall( T | Relational( T ) | Multiplicative( T ) ) 71 trait Arithmetic { 64 72 }; // Arithmetic 65 73 -
libcfa/src/stdlib.hfa
r7a24d76 r8a97248 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Dec 11 18:25:53 202213 // Update Count : 76 512 // Last Modified On : Thu Feb 2 11:30:04 2023 13 // Update Count : 766 14 14 // 15 15 … … 404 404 // calls( sprng ); 405 405 406 trait basic_prng( PRNG &, R ) { 406 forall( PRNG &, R ) 407 trait basic_prng { 407 408 void set_seed( PRNG & prng, R seed ); // set seed 408 409 R get_seed( PRNG & prng ); // get seed -
src/Common/SemanticError.h
r7a24d76 r8a97248 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 4 14:08:26 202213 // Update Count : 3 512 // Last Modified On : Thu Feb 2 10:59:10 2023 13 // Update Count : 36 14 14 // 15 15 … … 54 54 55 55 constexpr WarningData WarningFormats[] = { 56 {"self-assign" , Severity::Warn , "self assignment of expression: %s" }, 57 {"reference-conversion" , Severity::Warn , "rvalue to reference conversion of rvalue: %s" }, 58 {"qualifiers-zero_t-one_t", Severity::Warn , "questionable use of type qualifier %s with %s" }, 59 {"aggregate-forward-decl" , Severity::Warn , "forward declaration of nested aggregate: %s" }, 60 {"superfluous-decl" , Severity::Warn , "declaration does not allocate storage: %s" }, 61 {"superfluous-else" , Severity::Warn , "else clause never executed for empty loop conditional" }, 62 {"gcc-attributes" , Severity::Warn , "invalid attribute: %s" }, 63 {"c++-like-copy" , Severity::Warn , "Constructor from reference is not a valid copy constructor" }, 56 {"self-assign" , Severity::Warn , "self assignment of expression: %s" }, 57 {"reference-conversion" , Severity::Warn , "rvalue to reference conversion of rvalue: %s" }, 58 {"qualifiers-zero_t-one_t" , Severity::Warn , "questionable use of type qualifier %s with %s" }, 59 {"aggregate-forward-decl" , Severity::Warn , "forward declaration of nested aggregate: %s" }, 60 {"superfluous-decl" , Severity::Warn , "declaration does not allocate storage: %s" }, 61 {"superfluous-else" , Severity::Warn , "else clause never executed for empty loop conditional" }, 62 {"gcc-attributes" , Severity::Warn , "invalid attribute: %s" }, 63 {"c++-like-copy" , Severity::Warn , "Constructor from reference is not a valid copy constructor" }, 64 {"depreciated-trait-syntax" , Severity::Warn , "trait type-parameters are now specified using the forall clause" }, 64 65 }; 65 66 … … 73 74 GccAttributes, 74 75 CppCopy, 76 DeprecTraitSyntax, 75 77 NUMBER_OF_WARNINGS, // This MUST be the last warning 76 78 }; -
src/Parser/parser.yy
r7a24d76 r8a97248 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jan 31 08:55:11202313 // Update Count : 586 112 // Last Modified On : Thu Feb 2 21:36:16 2023 13 // Update Count : 5865 14 14 // 15 15 … … 2979 2979 trait_specifier: // CFA 2980 2980 TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' '}' 2981 { $$ = DeclarationNode::newTrait( $2, $4, nullptr ); } 2982 | forall TRAIT identifier_or_type_name '{' '}' // alternate 2981 { 2982 SemanticWarning( yylloc, Warning::DeprecTraitSyntax, "" ); 2983 $$ = DeclarationNode::newTrait( $2, $4, nullptr ); 2984 } 2985 | forall TRAIT identifier_or_type_name '{' '}' // alternate 2983 2986 { $$ = DeclarationNode::newTrait( $3, $1, nullptr ); } 2984 2987 | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}' 2985 { $$ = DeclarationNode::newTrait( $2, $4, $8 ); } 2988 { 2989 SemanticWarning( yylloc, Warning::DeprecTraitSyntax, "" ); 2990 $$ = DeclarationNode::newTrait( $2, $4, $8 ); 2991 } 2986 2992 | forall TRAIT identifier_or_type_name '{' push trait_declaration_list pop '}' // alternate 2987 2993 { $$ = DeclarationNode::newTrait( $3, $1, $6 ); } -
tests/forall.cfa
r7a24d76 r8a97248 10 10 // Created On : Wed May 9 08:48:15 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 5 10:06:08 202113 // Update Count : 3 612 // Last Modified On : Thu Feb 2 15:28:45 2023 13 // Update Count : 38 14 14 // 15 15 … … 56 56 } 57 57 58 trait sumable( T ){58 forall( T ) trait sumable { 59 59 void ?{}( T &, zero_t ); // 0 literal constructor 60 60 T ?+?( T, T ); // assortment of additions … … 64 64 }; // sumable 65 65 66 forall( T | sumable( T ) ) // use trait66 forall( T | sumable( T ) ) // use trait 67 67 T sum( size_t size, T a[] ) { 68 68 T total = 0; // initialize by 0 constructor
Note: See TracChangeset
for help on using the changeset viewer.