Last change
on this file since 72abc90a was
64eeb06,
checked in by Peter A. Buhr <pabuhr@…>, 3 months ago
|
change basic_ostream to ostream, first attempt of enumeration input
|
-
Property mode set to
100644
|
File size:
1.2 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 | |
---|
[64eeb06] | 10 | forall( E | Bounded( E ) ) trait Serial { |
---|
[d5efcb7] | 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 |
---|
[64eeb06] | 18 | forall( E, V | Serial( E ) ) trait CfaEnum { |
---|
[d5efcb7] | 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 | |
---|
[64eeb06] | 26 | forall( istype & | istream( istype ), E, V | CfaEnum( E, V ) ) |
---|
| 27 | istype & ?|?( istype &, E ); |
---|
| 28 | |
---|
| 29 | forall( ostype & | ostream( ostype ), E, V | CfaEnum( E, V ) ) { |
---|
[d5efcb7] | 30 | ostype & ?|?( ostype &, E ); |
---|
| 31 | OSTYPE_VOID( E ); |
---|
| 32 | } |
---|
| 33 | |
---|
[64eeb06] | 34 | forall( ostype & | ostream( ostype ), E | CfaEnum( E, quasi_void ) ) { |
---|
| 35 | ostype & ?|?( ostype &, E ); |
---|
| 36 | OSTYPE_VOID( E ); |
---|
| 37 | } |
---|
[85855b0] | 38 | |
---|
| 39 | // Design two <- should go for this if we have change the cost model |
---|
[64eeb06] | 40 | // forall( E | Serial( E ) ) trait CfaEnum { |
---|
| 41 | // char * label( E e ); |
---|
| 42 | // unsigned int posn( E e ); |
---|
[85855b0] | 43 | // }; |
---|
| 44 | |
---|
[64eeb06] | 45 | // forall( E, V| CfaEnum( E)) trait TypedEnum { |
---|
| 46 | // V value( E e); |
---|
[85855b0] | 47 | // }; |
---|
[525f7ad] | 48 | |
---|
[64eeb06] | 49 | forall( E, V | CfaEnum( E, V ) ) { // relational operators |
---|
| 50 | int ?==?( E, E ); |
---|
| 51 | int ?!=?( E, E ); |
---|
| 52 | int ?<?( E, E ); |
---|
| 53 | int ?<=?( E, E ); |
---|
| 54 | int ?>?( E, E ); |
---|
| 55 | int ?>=?( E, E ); |
---|
| 56 | |
---|
| 57 | int ++?( E &); |
---|
| 58 | int ?++( E &); |
---|
| 59 | int --?( E &); |
---|
| 60 | int ?--( E &); |
---|
| 61 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.