comparison dmd/StorageClassDeclaration.d @ 131:206db751bd4c

dmdfe 2.037 compiles now
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Fri, 10 Sep 2010 00:27:37 +0100
parents 60bb0fe4563e
children 96c0fff6897d
comparison
equal deleted inserted replaced
130:60bb0fe4563e 131:206db751bd4c
8 import dmd.Scope; 8 import dmd.Scope;
9 import dmd.Dsymbol; 9 import dmd.Dsymbol;
10 import dmd.OutBuffer; 10 import dmd.OutBuffer;
11 import dmd.HdrGenState; 11 import dmd.HdrGenState;
12 import dmd.STC; 12 import dmd.STC;
13 import dmd.Id;
14 import dmd.Identifier;
13 15
14 class StorageClassDeclaration: AttribDeclaration 16 class StorageClassDeclaration: AttribDeclaration
15 { 17 {
16 STC stc; 18 StorageClass stc;
17 19
18 this(STC stc, Dsymbols decl) 20 this(StorageClass stc, Dsymbols decl)
19 { 21 {
20 super(decl); 22 super(decl);
21 23
22 this.stc = stc; 24 this.stc = stc;
23 } 25 }
33 35
34 override void setScope(Scope sc) 36 override void setScope(Scope sc)
35 { 37 {
36 if (decl) 38 if (decl)
37 { 39 {
38 STC scstc = sc.stc; 40 StorageClass scstc = sc.stc;
39 41
40 /* These sets of storage classes are mutually exclusive, 42 /* These sets of storage classes are mutually exclusive,
41 * so choose the innermost or most recent one. 43 * so choose the innermost or most recent one.
42 */ 44 */
43 if (stc & (STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCextern | STC.STCmanifest)) 45 if (stc & (STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCextern | STC.STCmanifest))
46 scstc &= ~(STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCtls | STC.STCmanifest | STC.STCgshared); 48 scstc &= ~(STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCtls | STC.STCmanifest | STC.STCgshared);
47 if (stc & (STC.STCconst | STC.STCimmutable | STC.STCmanifest)) 49 if (stc & (STC.STCconst | STC.STCimmutable | STC.STCmanifest))
48 scstc &= ~(STC.STCconst | STC.STCimmutable | STC.STCmanifest); 50 scstc &= ~(STC.STCconst | STC.STCimmutable | STC.STCmanifest);
49 if (stc & (STC.STCgshared | STC.STCshared | STC.STCtls)) 51 if (stc & (STC.STCgshared | STC.STCshared | STC.STCtls))
50 scstc &= ~(STC.STCgshared | STC.STCshared | STC.STCtls); 52 scstc &= ~(STC.STCgshared | STC.STCshared | STC.STCtls);
51 if (stc & (STC.STCsafe | STC.STCtrusted | STC.STCsystem)) 53 if (stc & (STCsafe | STCtrusted | STCsystem))
52 scstc &= ~(STC.STCsafe | STC.STCtrusted | STC.STCsystem); 54 scstc &= ~(STCsafe | STCtrusted | STCsystem);
53 scstc |= stc; 55 scstc |= stc;
54 56
55 setScopeNewSc(sc, scstc, sc.linkage, sc.protection, sc.explicitProtection, sc.structalign); 57 setScopeNewSc(sc, scstc, sc.linkage, sc.protection, sc.explicitProtection, sc.structalign);
56 } 58 }
57 } 59 }
58 60
59 override void semantic(Scope sc) 61 override void semantic(Scope sc)
60 { 62 {
61 if (decl) 63 if (decl)
62 { 64 {
63 STC scstc = sc.stc; 65 StorageClass scstc = sc.stc;
64 66
65 /* These sets of storage classes are mutually exclusive, 67 /* These sets of storage classes are mutually exclusive,
66 * so choose the innermost or most recent one. 68 * so choose the innermost or most recent one.
67 */ 69 */
68 if (stc & (STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCextern | STC.STCmanifest)) 70 if (stc & (STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCextern | STC.STCmanifest))
71 scstc &= ~(STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCtls | STC.STCmanifest | STC.STCgshared); 73 scstc &= ~(STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCtls | STC.STCmanifest | STC.STCgshared);
72 if (stc & (STC.STCconst | STC.STCimmutable | STC.STCmanifest)) 74 if (stc & (STC.STCconst | STC.STCimmutable | STC.STCmanifest))
73 scstc &= ~(STC.STCconst | STC.STCimmutable | STC.STCmanifest); 75 scstc &= ~(STC.STCconst | STC.STCimmutable | STC.STCmanifest);
74 if (stc & (STC.STCgshared | STC.STCshared | STC.STCtls)) 76 if (stc & (STC.STCgshared | STC.STCshared | STC.STCtls))
75 scstc &= ~(STC.STCgshared | STC.STCshared | STC.STCtls); 77 scstc &= ~(STC.STCgshared | STC.STCshared | STC.STCtls);
76 if (stc & (STC.STCsafe | STC.STCtrusted | STC.STCsystem)) 78 if (stc & (STCsafe | STCtrusted | STCsystem))
77 scstc &= ~(STC.STCsafe | STC.STCtrusted | STC.STCsystem); 79 scstc &= ~(STCsafe | STCtrusted | STCsystem);
78 scstc |= stc; 80 scstc |= stc;
79 81
80 semanticNewSc(sc, scstc, sc.linkage, sc.protection, sc.explicitProtection, sc.structalign); 82 semanticNewSc(sc, scstc, sc.linkage, sc.protection, sc.explicitProtection, sc.structalign);
81 } 83 }
82 } 84 }
84 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) 86 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
85 { 87 {
86 assert(false); 88 assert(false);
87 } 89 }
88 90
89 static void stcToCBuffer(OutBuffer buf, int stc) 91 static void stcToCBuffer(OutBuffer buf, StorageClass stc)
90 { 92 {
91 struct SCstring 93 struct SCstring
92 { 94 {
93 int stc; 95 StorageClass stc;
94 TOK tok; 96 TOK tok;
95 }; 97 };
96 98
97 static SCstring[] table = 99 static SCstring[] table =
98 [ 100 [
130 { 132 {
131 enum TOK tok = table[i].tok; 133 enum TOK tok = table[i].tok;
132 if (tok == TOKat) 134 if (tok == TOKat)
133 { Identifier id; 135 { Identifier id;
134 136
135 if (stc & STC.STCproperty) 137 if (stc & STCproperty)
136 id = Id.property; 138 id = Id.property;
137 else if (stc & STCsafe) 139 else if (stc & STCsafe)
138 id = Id.safe; 140 id = Id.safe;
139 else if (stc & STCtrusted) 141 else if (stc & STCtrusted)
140 id = Id.trusted; 142 id = Id.trusted;