Changeset 03ac869 for libcfa/src
- Timestamp:
- May 8, 2024, 4:41:33 PM (6 months ago)
- Branches:
- master
- Children:
- 41c8312
- Parents:
- 0843ba6
- Location:
- libcfa/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/enum.cfa
r0843ba6 r03ac869 2 2 #include "fstream.hfa" 3 3 4 forall(E, T| TypedEnum(E, T)) { 4 #pragma GCC visibility push(default) 5 6 forall(T, E| TypedEnum(T, E)) { 5 7 // constructors 6 8 7 9 // comparison 8 10 int ?==?(E l, E r) { return posE(l) == posE(r); } 9 int ?!=?(E l, E r) { return !(l ==r); }11 int ?!=?(E l, E r) { return posE(l) != posE(r); } 10 12 int ?!=?(E l, zero_t) { return !( posE(l) == 0 ); } 11 13 int ?<?(E l, E r) { return posE(l) < posE(r); } … … 13 15 int ?>?(E l, E r) { return posE(l) > posE(r); } 14 16 int ?>=?(E l, E r) { return posE(l) >= posE(r); } 15 16 // for testing; To be removed17 // #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 17 } -
libcfa/src/enum.hfa
r0843ba6 r03ac869 7 7 }; 8 8 9 forall(E| Bounded( E, T)) trait Serial {9 forall(E| Bounded(T, E)) trait Serial { 10 10 unsigned fromInstance(E e); 11 11 E fromInt(unsigned i); … … 15 15 16 16 // Opague Enum + TypedEnum 17 forall(E | Serial( E, T)) trait CfaEnum {17 forall(E | Serial(T, E)) trait CfaEnum { 18 18 char * labelE(E e); 19 19 unsigned int posE(E e); 20 20 }; 21 21 22 forall(E | CfaEnum(E, T)) trait TypedEnum {22 forall(E| CfaEnum(T, E)) trait TypedEnum { 23 23 T valueE(E e); 24 24 }; 25 26 forall(E | TypedEnum(E, T)) {27 // comparison28 int ?==?(E l, E r);29 int ?!=?(E l, E r);30 int ?!=?(E l, zero_t);31 int ?<?(E l, E r);32 int ?<=?(E l, E r);33 int ?>?(E l, E r);34 int ?>=?(E l, E r);35 36 // for testing; To be removed37 // char * typeEnumString(E e);38 char * typeEnumString(E e);39 }40 25 } 41 26 27 28 forall(T, E | TypedEnum(T, E)) { 29 // comparison 30 int ?==?(E l, E r); 31 int ?!=?(E l, E r); 32 int ?!=?(E l, zero_t); 33 int ?<?(E l, E r); 34 int ?<=?(E l, E r); 35 int ?>?(E l, E r); 36 int ?>=?(E l, E r); 37 }
Note: See TracChangeset
for help on using the changeset viewer.