source: libcfa/src/enum.hfa @ 115ac1ce

Last change on this file since 115ac1ce was 259012e, checked in by Peter A. Buhr <pabuhr@…>, 4 months ago

put back quasi_void print

  • Property mode set to 100644
File size: 1.0 KB
RevLine 
[72713e5]1#pragma once
2
[85855b0]3#include "iostream.hfa"
4
[d5efcb7]5forall( E ) trait Bounded {
[85855b0]6    E lowerBound();
7    E upperBound();
8};
9
[d5efcb7]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 );
[85855b0]15};
16
17// Design one
[d5efcb7]18forall( E, V | Serial(E) ) trait CfaEnum {
19    char * label( E e );
20    unsigned int posn( E e );
21    V value( E e );
[85855b0]22};
23
[d5efcb7]24// I/O
[85855b0]25
[d5efcb7]26forall( ostype & | basic_ostream(ostype), E, V | CfaEnum(E, V) ) {
27        ostype & ?|?( ostype &, E );
28        OSTYPE_VOID( E );
29}
30
[259012e]31forall( ostype & | basic_ostream(ostype), E | CfaEnum(E, quasi_void) )
32ostype & ?|?( ostype &, E );
[85855b0]33
34// Design two <- should go for this if we have change the cost model
35// forall(E | Serial(E)) trait CfaEnum {
[5eb3f65]36//     char * label(E e);
37//     unsigned int posn(E e);
[85855b0]38// };
39
40// forall(E, V| CfaEnum(E)) trait TypedEnum {
[5eb3f65]41//     V value(E e);
[85855b0]42// };
[525f7ad]43
[d5efcb7]44forall( E, V | CfaEnum(E, V) ) {                                                // relational operators
[525f7ad]45    int ?==?(E, E);
[d5efcb7]46    int ?!=?(E, E);
[525f7ad]47    int ?<?(E, E);
[d5efcb7]48    int ?<=?(E, E);
[525f7ad]49    int ?>?(E, E);
[d5efcb7]50    int ?>=?(E, E);
[5eb3f65]51}
Note: See TracBrowser for help on using the repository browser.