Changeset d5efcb7 for libcfa/src


Ignore:
Timestamp:
Jun 25, 2024, 10:53:13 PM (11 days ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
55ba259e, d3aa55e9
Parents:
343c8be
Message:

first attempt at updating enum auxiliary operations

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/enum.cfa

    r343c8be rd5efcb7  
    44#pragma GCC visibility push(default)
    55
    6 forall(ostype & | basic_ostream(ostype), E, V| CfaEnum(E, V))
    7 ostype & ?|?(ostype& os, E e) {
    8     return os | type_name(e) | "." | label(e);
     6forall( ostype & | basic_ostream(ostype), E, V | CfaEnum(E, V) ) {
     7        ostype & ?|?( ostype& os, E e ) {
     8//              if ( scoped( e ) ) os | type_name( e ) | '.' | nonl;
     9                return os | label( e );
     10        }
     11        OSTYPE_VOID_IMPL( E )
    912}
    1013
    11 forall(ostype & | basic_ostream(ostype), E| CfaEnum(E, quasi_void))
    12 ostype & ?|?(ostype& os, E e) {
    13     return os | type_name(e) | "." | label(e);
     14// forall( ostype & | basic_ostream(ostype), E | CfaEnum(E, quasi_void) )
     15// ostype & ?|?( ostype & os, E e ) {
     16// //    return os | type_name(e) | "." | label(e);
     17//     return os | label( e );
     18// }
     19
     20forall( E, V | CfaEnum(E, V) ) {                                                // relational operators
     21    int ?==?(E l, E r) { return posn(l) == posn(r); }
     22    int ?!=?(E l, E r) { return posn(l) != posn(r); }
     23    int ?<?(E l, E r) { return posn(l) < posn(r); }
     24    int ?<=?(E l, E r) { return posn(l) <= posn(r); }
     25    int ?>?(E l, E r) { return posn(l) > posn(r); }
     26    int ?>=?(E l, E r) { return posn(l) >= posn(r); }
    1427}
    15 
    16 forall(ostype & | basic_ostream(ostype), E, V| CfaEnum(E, V)) {
    17     int ?==?(E l, E r) { return posn(l) == posn(r); }
    18     int ?<=?(E l, E r) { return posn(l) <= posn(r); }
    19     int ?>=?(E l, E r) { return posn(l) >= posn(r); }
    20     int ?<?(E l, E r) { return posn(l) < posn(r); }
    21     int ?>?(E l, E r) { return posn(l) > posn(r); }
    22 }
  • libcfa/src/enum.hfa

    r343c8be rd5efcb7  
    33#include "iostream.hfa"
    44
    5 forall(E) trait Bounded {
     5forall( E ) trait Bounded {
    66    E lowerBound();
    77    E upperBound();
    88};
    99
    10 forall(E | Bounded(E)) trait Serial {
    11     unsigned fromInstance(E e);
    12     E fromInt(unsigned i);
    13     E succ(E e);
    14     E pred(E e);
     10forall( E | Bounded(E) ) trait Serial {
     11    unsigned fromInstance( E e );
     12    E fromInt( unsigned i );
     13    E succ( E e );
     14    E pred( E e );
    1515};
    1616
    1717// Design one
    18 forall(E, V | Serial(E)) trait CfaEnum {
    19     char * label(E e);
    20     unsigned int posn(E e);
    21     V value(E e);
    22     char * type_name(E e);
     18forall( E, V | Serial(E) ) trait CfaEnum {
     19    char * label( E e );
     20    unsigned int posn( E e );
     21    V value( E e );
     22    char * type_name( E e );
     23//    bool scoped( E e );
    2324};
    2425
    25 forall(ostype & | basic_ostream(ostype), E, V | CfaEnum(E, V))
    26 ostype & ?|?(ostype&, E);
     26// I/O
    2727
    28 forall(ostype & | basic_ostream(ostype), E| CfaEnum(E, quasi_void))
    29 ostype & ?|?(ostype&, E);
     28forall( ostype & | basic_ostream(ostype), E, V | CfaEnum(E, V) ) {
     29        ostype & ?|?( ostype &, E );
     30        OSTYPE_VOID( E );
     31}
     32
     33//forall( ostype & | basic_ostream(ostype), E | CfaEnum(E, quasi_void) )
     34//ostype & ?|?( ostype &, E );
    3035
    3136// Design two <- should go for this if we have change the cost model
     
    3944// };
    4045
    41 forall(ostype & | basic_ostream(ostype), E, V| CfaEnum(E, V)) {
     46forall( E, V | CfaEnum(E, V) ) {                                                // relational operators
    4247    int ?==?(E, E);
     48    int ?!=?(E, E);
     49    int ?<?(E, E);
    4350    int ?<=?(E, E);
     51    int ?>?(E, E);
    4452    int ?>=?(E, E);
    45     int ?<?(E, E);
    46     int ?>?(E, E);
    47 
    48         // E ++?( E & lhs );
    49         // E ?++( E & lhs );
    5053}
Note: See TracChangeset for help on using the changeset viewer.