Changeset 525f7ad for libcfa/src


Ignore:
Timestamp:
Jun 19, 2024, 3:20:39 PM (15 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
57e43cd
Parents:
1725989
Message:
  1. Add count_e( enum_name ), a pseudo function that return the number of element in an enum; 2. Implementation of enum range loop.
Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/enum.cfa

    r1725989 r525f7ad  
    1313    return os | type_name(e) | "." | labelE(e);
    1414}
     15
     16forall(ostype & | basic_ostream(ostype), E, V| CfaEnum(E, V)) {
     17    int ?==?(E l, E r) { return posE(l) == posE(r); }
     18    int ?<=?(E l, E r) { return posE(l) <= posE(r); }
     19    int ?>=?(E l, E r) { return posE(l) >= posE(r); }
     20    int ?<?(E l, E r) { return posE(l) < posE(r); }
     21    int ?>?(E l, E r) { return posE(l) > posE(r); }
     22}
  • libcfa/src/enum.hfa

    r1725989 r525f7ad  
    3838//     V valueE(E e);
    3939// };
     40
     41forall(ostype & | basic_ostream(ostype), E, V| CfaEnum(E, V)) {
     42    int ?==?(E, E);
     43    int ?<=?(E, E);
     44    int ?>=?(E, E);
     45    int ?<?(E, E);
     46    int ?>?(E, E);
     47
     48        // E ++?( E & lhs );
     49        // E ?++( E & lhs );
     50}
Note: See TracChangeset for help on using the changeset viewer.