Changeset c333ed2 for libcfa


Ignore:
Timestamp:
May 7, 2024, 7:04:17 PM (17 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
0b6c1c9
Parents:
164a6b6
Message:

Remove intermeidate type (enum attribute type); remove replacePseudoFunc (has been migrated to resolver)

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/enum.cfa

    r164a6b6 rc333ed2  
     1#include "enum.hfa"
     2#include "fstream.hfa"
     3
     4forall(E, T| TypedEnum(E, T)) {
     5    // constructors
     6
     7    // comparison
     8    int ?==?(E l, E r) { return posE(l) == posE(r); }
     9    int ?!=?(E l, E r) { return !(l == r); }
     10    int ?!=?(E l, zero_t) { return !( posE(l) == 0 ); }
     11    int ?<?(E l, E r) { return posE(l) < posE(r); }
     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
     16    // for testing; To be removed
     17    // #include <string.h>
     18    char * typeEnumString(E e) {
     19        // char* out = malloc(sizeof(char) * (5 + strlen(labelE(e) + 1)));
     20        // return strcat(strcat(out, "Enum "), labelE(e));
     21        return labelE(e);
     22    }
     23}
  • libcfa/src/enum.hfa

    r164a6b6 rc333ed2  
    66};
    77
    8 forall(E | Bounded(E)) trait Serial {
     8forall(E, T| Bounded(E)) trait Serial {
    99    unsigned fromInstance(E e);
    1010    E fromInt(unsigned i);
     
    1313};
    1414
    15 forall(E, T) trait TypedEnum {
    16     T valueE(E e);
     15// Opague Enum + TypedEnum
     16forall(E, T | Serial(E, T)) trait CfaEnum {
    1717    char * labelE(E e);
    1818    unsigned int posE(E e);
     19};
     20
     21forall(E, T | CfaEnum(E, T)) trait TypedEnum {
     22    T valueE(E e);
    1923};
    2024
     
    2832    int ?>?(E l, E r);
    2933    int ?>=?(E l, E r);
     34
     35    // for testing; To be removed
     36    char * typeEnumString(E e);
    3037}
Note: See TracChangeset for help on using the changeset viewer.