Last change
on this file since 55ba259e was d5efcb7, checked in by Peter A. Buhr <pabuhr@…>, 16 months ago |
first attempt at updating enum auxiliary operations
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[72713e5] | 1 | #pragma once
|
---|
| 2 |
|
---|
[85855b0] | 3 | #include "iostream.hfa"
|
---|
| 4 |
|
---|
[d5efcb7] | 5 | forall( E ) trait Bounded {
|
---|
[85855b0] | 6 | E lowerBound();
|
---|
| 7 | E upperBound();
|
---|
| 8 | };
|
---|
| 9 |
|
---|
[d5efcb7] | 10 | forall( 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] | 18 | forall( E, V | Serial(E) ) trait CfaEnum {
|
---|
| 19 | char * label( E e );
|
---|
| 20 | unsigned int posn( E e );
|
---|
| 21 | V value( E e );
|
---|
| 22 | char * type_name( E e );
|
---|
| 23 | // bool scoped( E e );
|
---|
[85855b0] | 24 | };
|
---|
| 25 |
|
---|
[d5efcb7] | 26 | // I/O
|
---|
[85855b0] | 27 |
|
---|
[d5efcb7] | 28 | forall( ostype & | basic_ostream(ostype), E, V | CfaEnum(E, V) ) {
|
---|
| 29 | ostype & ?|?( ostype &, E );
|
---|
| 30 | OSTYPE_VOID( E );
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | //forall( ostype & | basic_ostream(ostype), E | CfaEnum(E, quasi_void) )
|
---|
| 34 | //ostype & ?|?( ostype &, E );
|
---|
[85855b0] | 35 |
|
---|
| 36 | // Design two <- should go for this if we have change the cost model
|
---|
| 37 | // forall(E | Serial(E)) trait CfaEnum {
|
---|
[5eb3f65] | 38 | // char * label(E e);
|
---|
| 39 | // unsigned int posn(E e);
|
---|
[85855b0] | 40 | // };
|
---|
| 41 |
|
---|
| 42 | // forall(E, V| CfaEnum(E)) trait TypedEnum {
|
---|
[5eb3f65] | 43 | // V value(E e);
|
---|
[85855b0] | 44 | // };
|
---|
[525f7ad] | 45 |
|
---|
[d5efcb7] | 46 | forall( E, V | CfaEnum(E, V) ) { // relational operators
|
---|
[525f7ad] | 47 | int ?==?(E, E);
|
---|
[d5efcb7] | 48 | int ?!=?(E, E);
|
---|
[525f7ad] | 49 | int ?<?(E, E);
|
---|
[d5efcb7] | 50 | int ?<=?(E, E);
|
---|
[525f7ad] | 51 | int ?>?(E, E);
|
---|
[d5efcb7] | 52 | int ?>=?(E, E);
|
---|
[5eb3f65] | 53 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.