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