Mercurial > projects > ddmd
annotate dmd/AttribDeclaration.d @ 82:e95073e26356
fixed a hack I used as a lack of copy ctor in D
author | korDen |
---|---|
date | Mon, 30 Aug 2010 18:38:35 +0400 |
parents | 43073c7c7769 |
children | e28b18c23469 |
rev | line source |
---|---|
0 | 1 module dmd.AttribDeclaration; |
2 | |
3 import dmd.Dsymbol; | |
4 import dmd.Array; | |
5 import dmd.Scope; | |
6 import dmd.ScopeDsymbol; | |
7 import dmd.LINK; | |
8 import dmd.STC; | |
9 import dmd.PROT; | |
10 import dmd.ArrayTypes; | |
11 import dmd.OutBuffer; | |
12 import dmd.HdrGenState; | |
13 | |
14 class AttribDeclaration : Dsymbol | |
15 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
16 Dsymbols decl; // array of Dsymbol's |
0 | 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(Dsymbols decl) |
0 | 19 { |
20 this.decl = decl; | |
21 } | |
22 | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
23 Dsymbols include(Scope sc, ScopeDsymbol sd) |
0 | 24 { |
25 return decl; | |
26 } | |
27 | |
72 | 28 override bool addMember(Scope sc, ScopeDsymbol sd, bool memnum) |
0 | 29 { |
30 bool m = false; | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
31 auto d = include(sc, sd); |
0 | 32 |
33 if (d) | |
34 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
35 foreach(s; d) |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
36 m |= s.addMember(sc, sd, m | memnum); |
0 | 37 } |
38 | |
39 return m; | |
40 } | |
41 | |
42 void setScopeNewSc(Scope sc, STC stc, LINK linkage, PROT protection, int explicitProtection, uint structalign) | |
43 { | |
44 if (decl) | |
45 { | |
46 Scope newsc = sc; | |
47 if (stc != sc.stc || linkage != sc.linkage || protection != sc.protection || explicitProtection != sc.explicitProtection || structalign != sc.structalign) | |
48 { | |
49 // create new one for changes | |
82 | 50 newsc = sc.clone(); |
0 | 51 newsc.flags &= ~SCOPE.SCOPEfree; |
52 newsc.stc = stc; | |
53 newsc.linkage = linkage; | |
54 newsc.protection = protection; | |
55 newsc.explicitProtection = explicitProtection; | |
56 newsc.structalign = structalign; | |
57 } | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
58 foreach(Dsymbol s; decl) |
0 | 59 s.setScope(newsc); // yes, the only difference from semanticNewSc() |
60 if (newsc != sc) | |
61 { | |
62 sc.offset = newsc.offset; | |
63 newsc.pop(); | |
64 } | |
65 } | |
66 } | |
67 | |
68 void semanticNewSc(Scope sc, STC stc, LINK linkage, PROT protection, int explicitProtection, uint structalign) | |
69 { | |
70 if (decl) | |
71 { | |
72 Scope newsc = sc; | |
73 if (stc != sc.stc || linkage != sc.linkage || protection != sc.protection || explicitProtection != sc.explicitProtection || structalign != sc.structalign) | |
74 { | |
75 // create new one for changes | |
82 | 76 newsc = sc.clone(); |
0 | 77 newsc.flags &= ~SCOPE.SCOPEfree; |
78 newsc.stc = stc; | |
79 newsc.linkage = linkage; | |
80 newsc.protection = protection; | |
81 newsc.explicitProtection = explicitProtection; | |
82 newsc.structalign = structalign; | |
83 } | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
84 foreach(Dsymbol s; decl) |
0 | 85 s.semantic(newsc); |
86 if (newsc != sc) | |
87 { | |
88 sc.offset = newsc.offset; | |
89 newsc.pop(); | |
90 } | |
91 } | |
92 } | |
93 | |
72 | 94 override void semantic(Scope sc) |
0 | 95 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
96 auto d = include(sc, null); |
0 | 97 |
98 //printf("\tAttribDeclaration::semantic '%s', d = %p\n",toChars(), d); | |
99 if (d) | |
100 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
101 foreach(s; d) |
0 | 102 s.semantic(sc); |
103 } | |
104 } | |
105 | |
72 | 106 override void semantic2(Scope sc) |
0 | 107 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
108 auto d = include(sc, null); |
0 | 109 |
110 if (d) | |
111 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
112 foreach(s; d) |
0 | 113 s.semantic2(sc); |
114 } | |
115 } | |
116 | |
72 | 117 override void semantic3(Scope sc) |
0 | 118 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
119 auto d = include(sc, null); |
0 | 120 |
121 if (d) | |
122 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
123 foreach(s; d) |
0 | 124 s.semantic3(sc); |
125 } | |
126 } | |
127 | |
72 | 128 override void inlineScan() |
0 | 129 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
130 auto d = include(null, null); |
0 | 131 |
132 if (d) | |
133 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
134 foreach(s; d) |
0 | 135 { |
136 //printf("AttribDeclaration.inlineScan %s\n", s.toChars()); | |
137 s.inlineScan(); | |
138 } | |
139 } | |
140 } | |
141 | |
79 | 142 override void addComment(string comment) |
0 | 143 { |
144 if (comment !is null) | |
145 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
146 auto d = include(null, null); |
0 | 147 if (d) |
148 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
149 foreach(s; d) |
0 | 150 { |
151 //printf("AttribDeclaration::addComment %s\n", s.toChars()); | |
152 s.addComment(comment); | |
153 } | |
154 } | |
155 } | |
156 } | |
157 | |
72 | 158 override void emitComment(Scope sc) |
0 | 159 { |
160 assert(false); | |
161 } | |
162 | |
72 | 163 override string kind() |
0 | 164 { |
165 assert(false); | |
166 } | |
167 | |
72 | 168 override bool oneMember(Dsymbol* ps) |
0 | 169 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
170 auto d = include(null, null); |
49 | 171 |
172 return Dsymbol.oneMembers(d, ps); | |
0 | 173 } |
174 | |
72 | 175 override bool hasPointers() |
0 | 176 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
177 auto d = include(null, null); |
0 | 178 |
179 if (d) | |
180 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
181 foreach(s; d) |
0 | 182 { |
183 if (s.hasPointers()) | |
184 return true; | |
185 } | |
186 } | |
187 | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
188 return false; |
0 | 189 } |
190 | |
72 | 191 override void checkCtorConstInit() |
0 | 192 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
193 auto d = include(null, null); |
0 | 194 if (d) |
195 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
196 foreach(s; d) |
0 | 197 s.checkCtorConstInit(); |
198 } | |
199 } | |
200 | |
72 | 201 override void addLocalClass(ClassDeclarations aclasses) |
0 | 202 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
203 auto d = include(null, null); |
0 | 204 if (d) |
205 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
206 foreach(s; d) |
0 | 207 s.addLocalClass(aclasses); |
208 } | |
209 } | |
210 | |
72 | 211 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 212 { |
213 assert(false); | |
214 } | |
79 | 215 |
216 override void toJsonBuffer(OutBuffer buf) | |
217 { | |
218 //writef("AttribDeclaration.toJsonBuffer()\n"); | |
219 | |
220 Dsymbols d = include(null, null); | |
221 | |
222 if (d) | |
223 { | |
224 foreach (Dsymbol s; d) | |
225 { | |
226 //writef("AttribDeclaration.toJsonBuffer %s\n", s.toChars()); | |
227 s.toJsonBuffer(buf); | |
228 } | |
229 } | |
230 } | |
231 | |
72 | 232 override AttribDeclaration isAttribDeclaration() { return this; } |
0 | 233 |
72 | 234 override void toObjFile(int multiobj) // compile to .obj file |
0 | 235 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
236 auto d = include(null, null); |
0 | 237 |
238 if (d) | |
239 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
240 foreach(s; d) |
0 | 241 s.toObjFile(multiobj); |
242 } | |
243 } | |
244 | |
72 | 245 override int cvMember(ubyte* p) |
0 | 246 { |
247 assert(false); | |
248 } | |
72 | 249 } |