Ignore:
Timestamp:
Jan 19, 2021, 8:44:29 PM (3 years ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
dafbde8
Parents:
2f47ea4
Message:

Converting the project to use the new syntax for otype, dtype and ttytpe.

Changed prelude (gen), libcfa and test suite to use it. Added a simple deprecation rule of the old syntax to the parser; we might wish to support both syntaxes "officially," like with an extra CLI switch, but this measure should serve as a simple reminder for our team to try the new syntax.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/stdlib.hfa

    r2f47ea4 rfd54fef  
    4848        else return (T *)alignment( _Alignof(T), dim, sizeof(T) )
    4949
    50 static inline forall( dtype T | sized(T) ) {
     50static inline forall( T & | sized(T) ) {
    5151        // CFA safe equivalents, i.e., implicit size specification
    5252
     
    108108
    109109        1. Replace the current forall-block that contains defintions of S_fill and S_realloc with following:
    110                 forall( dtype T | sized(T) ) {
     110                forall( T & | sized(T) ) {
    111111                        union  U_fill           { char c; T * a; T t; };
    112112                        struct S_fill           { char tag; U_fill(T) fill; };
     
    151151typedef struct S_resize                 { inline void *;  }     T_resize;
    152152
    153 forall( dtype T ) {
     153forall( T & ) {
    154154        struct S_fill           { char tag; char c; size_t size; T * at; char t[50]; };
    155155        struct S_realloc        { inline T *; };
     
    159159static inline T_resize  ?`resize  ( void * a )  { return (T_resize){a}; }
    160160
    161 static inline forall( dtype T | sized(T) ) {
     161static inline forall( T & | sized(T) ) {
    162162        S_fill(T) ?`fill ( T t ) {
    163163                S_fill(T) ret = { 't' };
     
    207207        } // $alloc_internal
    208208
    209         forall( ttype TT | { T * $alloc_internal( void *, T *, size_t, size_t, S_fill(T), TT ); } ) {
     209        forall( TT... | { T * $alloc_internal( void *, T *, size_t, size_t, S_fill(T), TT ); } ) {
    210210
    211211                T * $alloc_internal( void *       , T * Realloc, size_t Align, size_t Dim, S_fill(T) Fill, T_resize Resize, TT rest) {
     
    236236} // distribution T
    237237
    238 static inline forall( dtype T | sized(T) ) {
     238static inline forall( T & | sized(T) ) {
    239239        // CFA safe initialization/copy, i.e., implicit size specification, non-array types
    240240        T * memset( T * dest, char fill ) {
     
    257257
    258258// CFA deallocation for multiple objects
    259 static inline forall( dtype T )                                                 // FIX ME, problems with 0p in list
     259static inline forall( T & )                                                     // FIX ME, problems with 0p in list
    260260void free( T * ptr ) {
    261261        free( (void *)ptr );                                                            // C free
    262262} // free
    263 static inline forall( dtype T, ttype TT | { void free( TT ); } )
     263static inline forall( T &, TT... | { void free( TT ); } )
    264264void free( T * ptr, TT rest ) {
    265265        free( ptr );
     
    268268
    269269// CFA allocation/deallocation and constructor/destructor, non-array types
    270 static inline forall( dtype T | sized(T), ttype TT | { void ?{}( T &, TT ); } )
     270static inline forall( T & | sized(T), TT... | { void ?{}( T &, TT ); } )
    271271T * new( TT p ) {
    272272        return &(*(T *)malloc()){ p };                                                  // run constructor
    273273} // new
    274274
    275 static inline forall( dtype T | { void ^?{}( T & ); } )
     275static inline forall( T & | { void ^?{}( T & ); } )
    276276void delete( T * ptr ) {
    277277        // special case for 0-sized object => always call destructor
     
    281281        free( ptr );                                                                            // always call free
    282282} // delete
    283 static inline forall( dtype T, ttype TT | { void ^?{}( T & ); void delete( TT ); } )
     283static inline forall( T &, TT... | { void ^?{}( T & ); void delete( TT ); } )
    284284void delete( T * ptr, TT rest ) {
    285285        delete( ptr );
     
    288288
    289289// CFA allocation/deallocation and constructor/destructor, array types
    290 forall( dtype T | sized(T), ttype TT | { void ?{}( T &, TT ); } ) T * anew( size_t dim, TT p );
    291 forall( dtype T | sized(T) | { void ^?{}( T & ); } ) void adelete( T arr[] );
    292 forall( dtype T | sized(T) | { void ^?{}( T & ); }, ttype TT | { void adelete( TT ); } ) void adelete( T arr[], TT rest );
     290forall( T & | sized(T), TT... | { void ?{}( T &, TT ); } ) T * anew( size_t dim, TT p );
     291forall( T & | sized(T) | { void ^?{}( T & ); } ) void adelete( T arr[] );
     292forall( T & | sized(T) | { void ^?{}( T & ); }, TT... | { void adelete( TT ); } ) void adelete( T arr[], TT rest );
    293293
    294294//---------------------------------------
     
    330330//---------------------------------------
    331331
    332 forall( otype E | { int ?<?( E, E ); } ) {
     332forall( E | { int ?<?( E, E ); } ) {
    333333        E * bsearch( E key, const E * vals, size_t dim );
    334334        size_t bsearch( E key, const E * vals, size_t dim );
     
    339339} // distribution
    340340
    341 forall( otype K, otype E | { int ?<?( K, K ); K getKey( const E & ); } ) {
     341forall( K, E | { int ?<?( K, K ); K getKey( const E & ); } ) {
    342342        E * bsearch( K key, const E * vals, size_t dim );
    343343        size_t bsearch( K key, const E * vals, size_t dim );
     
    348348} // distribution
    349349
    350 forall( otype E | { int ?<?( E, E ); } ) {
     350forall( E | { int ?<?( E, E ); } ) {
    351351        void qsort( E * vals, size_t dim );
    352352} // distribution
Note: See TracChangeset for help on using the changeset viewer.