Changeset 4f4ae60 for libcfa/prelude


Ignore:
Timestamp:
Dec 23, 2024, 2:41:11 PM (4 weeks ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
a6b48f6
Parents:
43299af
Message:

Added prelude-inline.cfa to the standard library. This should now have the single copy of many functions defined in the prelude.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/prelude/builtins.c

    r43299af r4f4ae60  
    2727// Defined destructor in the case that non-generated code wants to use __Destructor.
    2828forall( T & )
    29 static inline void ^?{}( __Destructor(T) & x ) {
     29inline void ^?{}( __Destructor(T) & x ) {
    3030        if ( x.object && x.dtor ) {
    3131                x.dtor( x.object );
     
    5252
    5353forall( T & )
    54 static inline T & identity( T & i ) {
     54inline T & identity( T & i ) {
    5555        return i;
    5656}
     
    6161};
    6262
    63 static inline void  ?{}( generator$ & this ) { ((int&)this) = 0; }
    64 static inline void ^?{}( generator$ & ) {}
     63inline void  ?{}( generator$ & this ) { ((int&)this) = 0; }
     64inline void ^?{}( generator$ & ) {}
    6565
    6666forall( T & )
     
    7171
    7272forall( T & | is_generator( T ) )
    73 static inline T & resume( T & gen ) {
     73inline T & resume( T & gen ) {
    7474        main( gen );
    7575        return gen;
     
    9393// C11 reference manual Section 6.5.16 (page 101): "An assignment expression has the value of the left operand after the
    9494// assignment, but is not an lvalue." Hence, return a value not a reference.
    95 static inline {
     95inline {
    9696        forall( T& | is_value(T) | { T ?+=?( T &, one_t ); } )
    9797        T ++?( T & x ) { return x += 1; }
     
    116116#if defined(__SIZEOF_INT128__)
    117117// constructor for 128-bit numbers (all constants are unsigned as +/- are operators)
    118 static inline void ?{}( unsigned int128 & this, unsigned long int h, unsigned long int l ) {
     118inline void ?{}( unsigned int128 & this, unsigned long int h, unsigned long int l ) {
    119119        this = (unsigned int128)h << 64 | (unsigned int128)l;
    120120} // ?{}
     
    133133} // extern "C"
    134134
    135 static inline {                                                                                 // wrappers
     135inline {
    136136        float ?\?( float x, float y ) { return powf( x, y ); }
    137137        double ?\?( double x, double y ) { return pow( x, y ); }
     
    156156} // distribution
    157157
    158 static inline {
     158inline {
    159159        int ?\=?( int & x, unsigned int y ) { x = x \ y; return x; }
    160160        long int ?\=?( long int & x, unsigned long int y ) { x = x \ y; return x; }
     
    189189};
    190190
    191 static inline
    192 forall( E | Serial( E ) ) {
     191inline forall( E | Serial( E ) ) {
    193192        E fromInt( int i ) {
    194193                E upper = upperBound();
     
    222221}
    223222
    224 static inline
    225 forall( E | CfaEnum( E ) ) {
     223inline forall( E | CfaEnum( E ) ) {
    226224        int ?==?( E l, E r ) { return posn( l ) == posn( r ); }
    227225        int ?!=?( E l, E r ) { return posn( l ) != posn( r ); }
     
    232230}
    233231
    234 static inline
    235 forall( E | Serial( E ) ) {
     232inline forall( E | Serial( E ) ) {
    236233        E ?+=?( E & l, one_t ) {
    237234                int pos = fromInstance( l );
Note: See TracChangeset for help on using the changeset viewer.