Changeset 236f133 for libcfa


Ignore:
Timestamp:
Jul 11, 2024, 3:04:34 PM (5 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
9c447e2
Parents:
9d5eacb
Message:

Remove quasi_void for enums. The idea of quasi_void from Mike was to get around some resolution problem that enum pick function defines for Bounded over CfaEnum/TypedEnum?. But it is not clear that how often this can happen, and cfa might change the cast function scheme in the future. (change cost comparison scheme) Deprecate quasi_void for now so that enum traits looks cleaner without the dummy type for opaque enums

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/enum.cfa

    r9d5eacb r236f133  
    1010} // scmp
    1111
    12 forall( istype & | istream( istype ), E, V | CfaEnum( E, V ) )
     12forall( istype & | istream( istype ), E | CfaEnum( E ) )
    1313istype & ?|?( istype & is, E & e ) {
    1414//      printf( "here0\n" );
     
    7070}
    7171
    72 forall( ostype & | ostream( ostype ), E, V | CfaEnum( E, V ) ) {
     72// forall( ostype & | ostream( ostype ), E | CfaEnum( E, quasi_void ) ) {
     73//      ostype & ?|?( ostype & os, E e ) {
     74//              return os | label( e );
     75//      }
     76//      OSTYPE_VOID_IMPL( E )
     77// }
     78
     79forall( ostype & | ostream( ostype ), E | CfaEnum( E ) ) {
    7380        ostype & ?|?( ostype & os, E e ) {
    7481                return os | label( e );
     
    7784}
    7885
    79 forall( ostype & | ostream( ostype ), E | CfaEnum( E, quasi_void ) ) {
    80         ostype & ?|?( ostype & os, E e ) {
    81                 return os | label( e );
    82         }
    83         OSTYPE_VOID_IMPL( E )
    84 }
     86//
  • libcfa/src/enum.hfa

    r9d5eacb r236f133  
    1515};
    1616
    17 // Design one
    18 forall( E, V | Serial( E ) ) trait CfaEnum {
     17forall( E | Serial( E ) ) trait CfaEnum {
    1918    const char * label( E e );
    2019    unsigned int posn( E e );
     20};
     21
     22forall( E, V | CfaEnum( E ) ) trait TypedEnum {
    2123    V value( E e );
    2224};
     
    2426// I/O
    2527
    26 forall( istype & | istream( istype ), E, V | CfaEnum( E, V ) )
     28forall( istype & | istream( istype ), E | CfaEnum( E ) )
    2729istype & ?|?( istype &, E & );
    2830
    29 forall( ostype & | ostream( ostype ), E, V | CfaEnum( E, V ) ) {
     31forall( ostype & | ostream( ostype ), E | CfaEnum( E ) ) {
    3032        ostype & ?|?( ostype &, E );
    3133        OSTYPE_VOID( E );
    3234}
    3335
    34 forall( ostype & | ostream( ostype ), E | CfaEnum( E, quasi_void ) ) {
    35         ostype & ?|?( ostype &, E );
    36         OSTYPE_VOID( E );
    37 }
     36// forall( ostype & | ostream( ostype ), E | CfaEnum( E, quasi_void ) ) {
     37//      ostype & ?|?( ostype &, E );
     38//      OSTYPE_VOID( E );
     39// }
    3840
    3941// Design two <- should go for this if we have change the cost model
     
    4850
    4951static inline
    50 forall( E, V | CfaEnum( E, V ) ) {
     52forall( E | CfaEnum( E ) ) {
    5153    int ?==?( E l, E r ) { return posn( l ) == posn( r ); }     // relational operators
    5254    int ?!=?( E l, E r ) { return posn( l ) != posn( r ); }
Note: See TracChangeset for help on using the changeset viewer.