source: libcfa/src/enum.cfa @ 011c29e

Last change on this file since 011c29e was 73d0e3f4, checked in by JiadaL <j82liang@…>, 3 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.0 KB
Line 
1#include "enum.hfa"
2#include "fstream.hfa"
3
4#pragma GCC visibility push(default)
5
6forall( ostype & | basic_ostream(ostype), E, V | CfaEnum(E, V) ) {
7        ostype & ?|?( ostype& os, E e ) {
8                return os | label( e );
9        }
10        OSTYPE_VOID_IMPL( E )
11}
12
13forall( ostype & | basic_ostream(ostype), E | CfaEnum(E, quasi_void) )
14ostype & ?|?( ostype & os, E e ) {
15    return os | label( e );
16}
17
18forall( E, V | CfaEnum(E, V) ) {                                                // relational operators
19    int ?==?(E l, E r) { return posn(l) == posn(r); }
20    int ?!=?(E l, E r) { return posn(l) != posn(r); }
21    int ?<?(E l, E r) { return posn(l) < posn(r); }
22    int ?<=?(E l, E r) { return posn(l) <= posn(r); }
23    int ?>?(E l, E r) { return posn(l) > posn(r); }
24    int ?>=?(E l, E r) { return posn(l) >= posn(r); }
25
26    E ++?(E& l) {
27        l = succ(l);
28        return l;
29    }
30   
31    E ?++(E& l) {
32        E ret = l;
33        l = succ(l);
34        return ret;
35    }
36
37    E --?(E& l) {
38        l = pred(l);
39        return l;
40    }
41
42    E ?--(E& l) {
43        E ret = l;
44        l = pred(l);
45        return ret;
46    }
47}
Note: See TracBrowser for help on using the repository browser.