Last change
on this file since 73d0e3f4 was
73d0e3f4,
checked in by JiadaL <j82liang@…>, 4 months ago
|
Current enum has bug when use as a reference as in ?++. Change TranslateEnumRange? to use succ and pred instead. Will look back into the reference problem
|
-
Property mode set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | #pragma once |
---|
2 | |
---|
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 { |
---|
19 | char * label( E e ); |
---|
20 | unsigned int posn( E e ); |
---|
21 | V value( E e ); |
---|
22 | }; |
---|
23 | |
---|
24 | // I/O |
---|
25 | |
---|
26 | forall( ostype & | basic_ostream(ostype), E, V | CfaEnum(E, V) ) { |
---|
27 | ostype & ?|?( ostype &, E ); |
---|
28 | OSTYPE_VOID( E ); |
---|
29 | } |
---|
30 | |
---|
31 | forall( ostype & | basic_ostream(ostype), E | CfaEnum(E, quasi_void) ) |
---|
32 | ostype & ?|?( ostype &, E ); |
---|
33 | |
---|
34 | // Design two <- should go for this if we have change the cost model |
---|
35 | // forall(E | Serial(E)) trait CfaEnum { |
---|
36 | // char * label(E e); |
---|
37 | // unsigned int posn(E e); |
---|
38 | // }; |
---|
39 | |
---|
40 | // forall(E, V| CfaEnum(E)) trait TypedEnum { |
---|
41 | // V value(E e); |
---|
42 | // }; |
---|
43 | |
---|
44 | forall( E, V | CfaEnum(E, V) ) { // relational operators |
---|
45 | int ?==?(E, E); |
---|
46 | int ?!=?(E, E); |
---|
47 | int ?<?(E, E); |
---|
48 | int ?<=?(E, E); |
---|
49 | int ?>?(E, E); |
---|
50 | int ?>=?(E, E); |
---|
51 | |
---|
52 | int ++?(E&); |
---|
53 | int ?++(E&); |
---|
54 | int --?(E&); |
---|
55 | int ?--(E&); |
---|
56 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.