source: libcfa/src/enum.hfa @ 3eb5f993

Last change on this file since 3eb5f993 was 85855b0, checked in by JiadaL <j82liang@…>, 5 months ago
  1. Implement enum cast; 2. Change valueE so that opague enum returns quasi_void; 3. change enum hiding interpretation and pass visiting scheme
  • Property mode set to 100644
File size: 831 bytes
RevLine 
[72713e5]1#pragma once
2
[85855b0]3#include "iostream.hfa"
4
5forall(E) trait Bounded {
6    E lowerBound();
7    E upperBound();
8};
9
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);
15};
16
17// Design one
18forall(E, V | Serial(E)) trait CfaEnum {
19    char* labelE(E e);
20    unsigned int posE(E e);
21    V valueE(E e);
22    char* type_name(E e);
23};
24
25forall(ostype & | basic_ostream(ostype), E, V| CfaEnum(E, V))
26ostype & ?|?(ostype&, E);
27
28forall(ostype & | basic_ostream(ostype), E| CfaEnum(E, quasi_void))
29ostype & ?|?(ostype&, E);
30
31// Design two <- should go for this if we have change the cost model
32// forall(E | Serial(E)) trait CfaEnum {
33//     char* labelE(E e);
34//     unsigned int posE(E e);
35// };
36
37// forall(E, V| CfaEnum(E)) trait TypedEnum {
38//     V valueE(E e);
39// };
Note: See TracBrowser for help on using the repository browser.