annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.StorageClassDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 74
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.AttribDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Array;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.Token;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.STC;
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
13 import dmd.Id;
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
14 import dmd.Identifier;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 class StorageClassDeclaration: AttribDeclaration
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 {
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
18 StorageClass stc;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
20 this(StorageClass stc, Dsymbols decl)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 super(decl);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 this.stc = stc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 51
diff changeset
27 override Dsymbol syntaxCopy(Dsymbol s)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 {
51
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 0
diff changeset
29 StorageClassDeclaration scd;
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 0
diff changeset
30
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 0
diff changeset
31 assert(!s);
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 0
diff changeset
32 scd = new StorageClassDeclaration(stc, Dsymbol.arraySyntaxCopy(decl));
b7d29f613539 StaticAssertStatement.syntaxCopy
korDen
parents: 0
diff changeset
33 return scd;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 51
diff changeset
36 override void setScope(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 if (decl)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 {
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
40 StorageClass scstc = sc.stc;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 /* These sets of storage classes are mutually exclusive,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 * so choose the innermost or most recent one.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 if (stc & (STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCextern | STC.STCmanifest))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 scstc &= ~(STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCextern | STC.STCmanifest);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 if (stc & (STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCtls | STC.STCmanifest | STC.STCgshared))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 scstc &= ~(STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCtls | STC.STCmanifest | STC.STCgshared);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 if (stc & (STC.STCconst | STC.STCimmutable | STC.STCmanifest))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 scstc &= ~(STC.STCconst | STC.STCimmutable | STC.STCmanifest);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 if (stc & (STC.STCgshared | STC.STCshared | STC.STCtls))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 scstc &= ~(STC.STCgshared | STC.STCshared | STC.STCtls);
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
53 if (stc & (STCsafe | STCtrusted | STCsystem))
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
54 scstc &= ~(STCsafe | STCtrusted | STCsystem);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 scstc |= stc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 setScopeNewSc(sc, scstc, sc.linkage, sc.protection, sc.explicitProtection, sc.structalign);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 51
diff changeset
61 override void semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 if (decl)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 {
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
65 StorageClass scstc = sc.stc;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 /* These sets of storage classes are mutually exclusive,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 * so choose the innermost or most recent one.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 if (stc & (STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCextern | STC.STCmanifest))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 scstc &= ~(STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCextern | STC.STCmanifest);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 if (stc & (STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCtls | STC.STCmanifest | STC.STCgshared))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 scstc &= ~(STC.STCauto | STC.STCscope | STC.STCstatic | STC.STCtls | STC.STCmanifest | STC.STCgshared);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 if (stc & (STC.STCconst | STC.STCimmutable | STC.STCmanifest))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 scstc &= ~(STC.STCconst | STC.STCimmutable | STC.STCmanifest);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 if (stc & (STC.STCgshared | STC.STCshared | STC.STCtls))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 scstc &= ~(STC.STCgshared | STC.STCshared | STC.STCtls);
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
78 if (stc & (STCsafe | STCtrusted | STCsystem))
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
79 scstc &= ~(STCsafe | STCtrusted | STCsystem);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 scstc |= stc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 semanticNewSc(sc, scstc, sc.linkage, sc.protection, sc.explicitProtection, sc.structalign);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 51
diff changeset
86 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
91 static void stcToCBuffer(OutBuffer buf, StorageClass stc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 struct SCstring
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 {
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
95 StorageClass stc;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 TOK tok;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 };
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 static SCstring[] table =
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 [
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 { STCauto, TOKauto },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 { STCscope, TOKscope },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 { STCstatic, TOKstatic },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 { STCextern, TOKextern },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 { STCconst, TOKconst },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 { STCfinal, TOKfinal },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 { STCabstract, TOKabstract },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 { STCsynchronized, TOKsynchronized },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 { STCdeprecated, TOKdeprecated },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 { STCoverride, TOKoverride },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 { STClazy, TOKlazy },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 { STCalias, TOKalias },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 { STCout, TOKout },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 { STCin, TOKin },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 /// version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 /// { STCimmutable, TOKimmutable },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 /// { STCshared, TOKshared },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 /// { STCnothrow, TOKnothrow },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 /// { STCpure, TOKpure },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 /// { STCref, TOKref },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 /// { STCtls, TOKtls },
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 /// { STCgshared, TOKgshared },
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
123 /// { STCproperty, TOKat },
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
124 /// { STCsafe, TOKat },
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
125 /// { STCtrusted, TOKat },
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 /// }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 ];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 for (int i = 0; i < table.length; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 if (stc & table[i].stc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 {
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
133 enum TOK tok = table[i].tok;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
134 if (tok == TOKat)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
135 { Identifier id;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
136
131
206db751bd4c dmdfe 2.037 compiles now
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 130
diff changeset
137 if (stc & STCproperty)
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
138 id = Id.property;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
139 else if (stc & STCsafe)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
140 id = Id.safe;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
141 else if (stc & STCtrusted)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
142 id = Id.trusted;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
143 else
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
144 assert(0);
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
145 buf.writestring(id.toChars());
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
146 }
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
147 else
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
148 buf.writestring(Token.toChars(tok));
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 buf.writeByte(' ');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 51
diff changeset
153 }