Changeset bf4fe05 for libcfa


Ignore:
Timestamp:
May 13, 2024, 7:07:06 AM (5 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
ca4f2b2
Parents:
ec20ab9 (diff), 5f225f5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

fix merge

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/enum.cfa

    rec20ab9 rbf4fe05  
     1#include "enum.hfa"
     2
     3#pragma GCC visibility push(default)
     4
     5forall(T, E| TypedEnum(T, E)) {
     6    // constructors
     7
     8    // comparison
     9    int ?==?(E l, E r) { return posE(l) == posE(r); }
     10    int ?!=?(E l, E r) { return posE(l) != posE(r); }
     11    int ?!=?(E l, zero_t) { return !( posE(l) == 0 ); }
     12    int ?<?(E l, E r) { return posE(l) < posE(r); }
     13    int ?<=?(E l, E r) { return posE(l) <= posE(r); }
     14    int ?>?(E l, E r) { return posE(l) > posE(r); }
     15    int ?>=?(E l, E r) {  return posE(l) >= posE(r); }
     16}
  • libcfa/src/enum.hfa

    rec20ab9 rbf4fe05  
    11#pragma once
    22
    3 forall( E ) trait Bounded {
    4         E lowerBound();
    5         E upperBound();
    6 };
     3forall(T) { // T is the based type of enum(T)
     4    forall(E) trait Bounded {
     5        E lowerBound();
     6        E upperBound();
     7    };
    78
    8 forall( E | Bounded( E ) ) trait Serial {
    9         unsigned fromInstance( E e );
    10         E fromInt( unsigned int posn );
    11         E succ( E e );
    12         E pred( E e );
    13 };
     9    forall(E| Bounded(T, E)) trait Serial {
     10        unsigned fromInstance(E e);
     11        E fromInt(unsigned i);
     12        E succ(E e);
     13        E pred(E e);
     14    };
    1415
    15 forall( E, T ) trait TypedEnum {
    16         T valueE( E e );
    17         char * labelE( E e );
    18         unsigned int posE( E e );
    19 };
     16    // Opague Enum + TypedEnum
     17    forall(E | Serial(T, E)) trait CfaEnum {
     18        char * labelE(E e);
     19        unsigned int posE(E e);
     20    };
    2021
    21 forall( E, T | TypedEnum( E, T ) ) {
    22         // comparison
    23         int ?==?( E l, E r );                                                           // true if l and r are same enumerators   
    24         int ?!=?( E l, E r );                                                           // true if l and r are different enumerators
    25         int ?!=?( E l, zero_t );                                                        // true if l is not the first enumerator           
    26         int ?<?( E l, E r );                                                            // true if l is an enuemerator before r   
    27         int ?<=?( E l, E r );                                                           // true if l before or the same as r               
    28         int ?>?( E l, E r );                                                            // true if l is an enuemrator after r     
    29         int ?>=?( E l, E r );                                                           // true if l after or the same as r         
     22    forall(E| CfaEnum(T, E)) trait TypedEnum {
     23        T valueE(E e);
     24    };
     25
     26        forall(E | TypedEnum(T, E)) {
     27                // comparison
     28                int ?==?(E l, E r);                                                             // true if l and r are same enumerators
     29                int ?!=?(E l, E r);                                                             // true if l and r are different enumerators
     30                int ?!=?(E l, zero_t);                                                  // true if l is not the first enumerator
     31                int ?<?(E l, E r);                                                              // true if l is an enuemerator before r
     32                int ?<=?(E l, E r);                                                             // true if l before or the same as r
     33                int ?>?(E l, E r);                                                              // true if l is an enuemrator after r
     34                int ?>=?(E l, E r);                                                             // true if l after or the same as r
     35        }
    3036}
Note: See TracChangeset for help on using the changeset viewer.