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