Mercurial > projects > ddmd
annotate dmd/StorageClassDeclaration.d @ 114:e28b18c23469
added a module dmd.common for commonly used stuff
it currently holds code for consistency checking of predefined versions
also added a VisualD project file
author | Trass3r |
---|---|
date | Wed, 01 Sep 2010 18:21:58 +0200 |
parents | 7e0d548de9e6 |
children | 60bb0fe4563e |
rev | line source |
---|---|
0 | 1 module dmd.StorageClassDeclaration; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.AttribDeclaration; |
5 import dmd.Array; | |
6 import dmd.TOK; | |
7 import dmd.Token; | |
8 import dmd.Scope; | |
9 import dmd.Dsymbol; | |
10 import dmd.OutBuffer; | |
11 import dmd.HdrGenState; | |
12 import dmd.STC; | |
13 | |
14 class StorageClassDeclaration: AttribDeclaration | |
15 { | |
16 STC stc; | |
17 | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
18 this(STC stc, Dsymbols decl) |
0 | 19 { |
20 super(decl); | |
21 | |
22 this.stc = stc; | |
23 } | |
24 | |
72 | 25 override Dsymbol syntaxCopy(Dsymbol s) |
0 | 26 { |
51 | 27 StorageClassDeclaration scd; |
28 | |
29 assert(!s); | |
30 scd = new StorageClassDeclaration(stc, Dsymbol.arraySyntaxCopy(decl)); | |
31 return scd; | |
0 | 32 } |
33 | |
72 | 34 override void setScope(Scope sc) |
0 | 35 { |
36 if (decl) | |
37 { | |
38 STC scstc = sc.stc; | |
39 | |
40 /* These sets of storage classes are mutually exclusive, | |
41 * so choose the innermost or most recent one. | |
42 */ | |
43 if (stc & (STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCextern | STC.STCmanifest)) | |
44 scstc &= ~(STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCextern | STC.STCmanifest); | |
45 if (stc & (STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCtls | STC.STCmanifest | STC.STCgshared)) | |
46 scstc &= ~(STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCtls | STC.STCmanifest | STC.STCgshared); | |
47 if (stc & (STC.STCconst | STC.STCimmutable | STC.STCmanifest)) | |
48 scstc &= ~(STC.STCconst | STC.STCimmutable | STC.STCmanifest); | |
49 if (stc & (STC.STCgshared | STC.STCshared | STC.STCtls)) | |
50 scstc &= ~(STC.STCgshared | STC.STCshared | STC.STCtls); | |
51 scstc |= stc; | |
52 | |
53 setScopeNewSc(sc, scstc, sc.linkage, sc.protection, sc.explicitProtection, sc.structalign); | |
54 } | |
55 } | |
56 | |
72 | 57 override void semantic(Scope sc) |
0 | 58 { |
59 if (decl) | |
60 { | |
61 STC scstc = sc.stc; | |
62 | |
63 /* These sets of storage classes are mutually exclusive, | |
64 * so choose the innermost or most recent one. | |
65 */ | |
66 if (stc & (STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCextern | STC.STCmanifest)) | |
67 scstc &= ~(STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCextern | STC.STCmanifest); | |
68 if (stc & (STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCtls | STC.STCmanifest | STC.STCgshared)) | |
69 scstc &= ~(STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCtls | STC.STCmanifest | STC.STCgshared); | |
70 if (stc & (STC.STCconst | STC.STCimmutable | STC.STCmanifest)) | |
71 scstc &= ~(STC.STCconst | STC.STCimmutable | STC.STCmanifest); | |
72 if (stc & (STC.STCgshared | STC.STCshared | STC.STCtls)) | |
73 scstc &= ~(STC.STCgshared | STC.STCshared | STC.STCtls); | |
74 scstc |= stc; | |
75 | |
76 semanticNewSc(sc, scstc, sc.linkage, sc.protection, sc.explicitProtection, sc.structalign); | |
77 } | |
78 } | |
79 | |
72 | 80 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 81 { |
82 assert(false); | |
83 } | |
84 | |
85 static void stcToCBuffer(OutBuffer buf, int stc) | |
86 { | |
87 struct SCstring | |
88 { | |
89 int stc; | |
90 TOK tok; | |
91 }; | |
92 | |
93 static SCstring[] table = | |
94 [ | |
95 { STCauto, TOKauto }, | |
96 { STCscope, TOKscope }, | |
97 { STCstatic, TOKstatic }, | |
98 { STCextern, TOKextern }, | |
99 { STCconst, TOKconst }, | |
100 { STCfinal, TOKfinal }, | |
101 { STCabstract, TOKabstract }, | |
102 { STCsynchronized, TOKsynchronized }, | |
103 { STCdeprecated, TOKdeprecated }, | |
104 { STCoverride, TOKoverride }, | |
105 { STClazy, TOKlazy }, | |
106 { STCalias, TOKalias }, | |
107 { STCout, TOKout }, | |
108 { STCin, TOKin }, | |
109 /// version (DMDV2) { | |
110 /// { STCimmutable, TOKimmutable }, | |
111 /// { STCshared, TOKshared }, | |
112 /// { STCnothrow, TOKnothrow }, | |
113 /// { STCpure, TOKpure }, | |
114 /// { STCref, TOKref }, | |
115 /// { STCtls, TOKtls }, | |
116 /// { STCgshared, TOKgshared }, | |
117 /// } | |
118 ]; | |
119 | |
120 for (int i = 0; i < table.length; i++) | |
121 { | |
122 if (stc & table[i].stc) | |
123 { | |
124 buf.writestring(Token.toChars(table[i].tok)); | |
125 buf.writeByte(' '); | |
126 } | |
127 } | |
128 } | |
72 | 129 } |