comparison src/dil/Enums.d @ 806:bcb74c9b895c

Moved out files in the trunk folder to the root.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sun, 09 Mar 2008 00:12:19 +0100
parents trunk/src/dil/Enums.d@3b34f6a95a27
children
comparison
equal deleted inserted replaced
805:a3fab8b74a7d 806:bcb74c9b895c
1 /++
2 Author: Aziz Köksal
3 License: GPL3
4 +/
5 module dil.Enums;
6
7 import common;
8
9 /// Enumeration of storage classes.
10 enum StorageClass
11 {
12 None = 0,
13 Abstract = 1,
14 Auto = 1<<2,
15 Const = 1<<3,
16 Deprecated = 1<<4,
17 Extern = 1<<5,
18 Final = 1<<6,
19 Invariant = 1<<7,
20 Override = 1<<8,
21 Scope = 1<<9,
22 Static = 1<<10,
23 Synchronized = 1<<11,
24 In = 1<<12,
25 Out = 1<<13,
26 Ref = 1<<14,
27 Lazy = 1<<15,
28 Variadic = 1<<16,
29 }
30
31 /// Enumeration of protection attributes.
32 enum Protection
33 {
34 None,
35 Private/+ = 1+/,
36 Protected/+ = 1<<1+/,
37 Package/+ = 1<<2+/,
38 Public/+ = 1<<3+/,
39 Export/+ = 1<<4+/
40 }
41
42 /// Enumeration of linkage types.
43 enum LinkageType
44 {
45 None,
46 C,
47 Cpp,
48 D,
49 Windows,
50 Pascal,
51 System
52 }
53
54 /// Returns the string for prot.
55 string toString(Protection prot)
56 {
57 switch (prot)
58 { alias Protection P;
59 case P.None: return "";
60 case P.Private: return "private";
61 case P.Protected: return "protected";
62 case P.Package: return "package";
63 case P.Public: return "public";
64 case P.Export: return "export";
65 default:
66 assert(0);
67 }
68 }
69
70 /// Returns the string of a storage class. Only one bit may be set.
71 string toString(StorageClass stc)
72 {
73 switch (stc)
74 { alias StorageClass SC;
75 case SC.Abstract: return "abstract";
76 case SC.Auto: return "auto";
77 case SC.Const: return "const";
78 case SC.Deprecated: return "deprecated";
79 case SC.Extern: return "extern";
80 case SC.Final: return "final";
81 case SC.Invariant: return "invariant";
82 case SC.Override: return "override";
83 case SC.Scope: return "scope";
84 case SC.Static: return "static";
85 case SC.Synchronized: return "synchronized";
86 case SC.In: return "in";
87 case SC.Out: return "out";
88 case SC.Ref: return "ref";
89 case SC.Lazy: return "lazy";
90 case SC.Variadic: return "variadic";
91 default:
92 assert(0);
93 }
94 }
95
96 /// Returns the strings for stc. Any number of bits may be set.
97 string[] toStrings(StorageClass stc)
98 {
99 string[] result;
100 for (auto i = StorageClass.max; i; i >>= 1)
101 if (stc & i)
102 result ~= toString(i);
103 return result;
104 }
105
106 /// Returns the string for ltype.
107 string toString(LinkageType ltype)
108 {
109 switch (ltype)
110 { alias LinkageType LT;
111 case LT.None: return "";
112 case LT.C: return "C";
113 case LT.Cpp: return "Cpp";
114 case LT.D: return "D";
115 case LT.Windows: return "Windows";
116 case LT.Pascal: return "Pascal";
117 case LT.System: return "System";
118 default:
119 assert(0);
120 }
121 }