Mercurial > projects > ddmd
annotate dmd/AttribDeclaration.d @ 79:43073c7c7769
updated to 2.035
also implemented a few missing functions
still crashes in Import.importAll though
author | Trass3r |
---|---|
date | Mon, 30 Aug 2010 03:57:51 +0200 |
parents | ad4792a1cfd6 |
children | e95073e26356 |
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 | |
50 newsc = new Scope(sc); | |
51 newsc.offset = sc.offset; | |
52 newsc.scopesym = sc.scopesym; | |
53 newsc.flags &= ~SCOPE.SCOPEfree; | |
54 newsc.stc = stc; | |
55 newsc.linkage = linkage; | |
56 newsc.protection = protection; | |
57 newsc.explicitProtection = explicitProtection; | |
58 newsc.structalign = structalign; | |
59 } | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
60 foreach(Dsymbol s; decl) |
0 | 61 s.setScope(newsc); // yes, the only difference from semanticNewSc() |
62 if (newsc != sc) | |
63 { | |
64 sc.offset = newsc.offset; | |
65 newsc.pop(); | |
66 } | |
67 } | |
68 } | |
69 | |
70 void semanticNewSc(Scope sc, STC stc, LINK linkage, PROT protection, int explicitProtection, uint structalign) | |
71 { | |
72 if (decl) | |
73 { | |
74 Scope newsc = sc; | |
75 if (stc != sc.stc || linkage != sc.linkage || protection != sc.protection || explicitProtection != sc.explicitProtection || structalign != sc.structalign) | |
76 { | |
77 // create new one for changes | |
78 newsc = new Scope(sc); | |
79 newsc.offset = sc.offset; | |
80 newsc.scopesym = sc.scopesym; | |
81 newsc.flags &= ~SCOPE.SCOPEfree; | |
82 newsc.stc = stc; | |
83 newsc.linkage = linkage; | |
84 newsc.protection = protection; | |
85 newsc.explicitProtection = explicitProtection; | |
86 newsc.structalign = structalign; | |
87 } | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
88 foreach(Dsymbol s; decl) |
0 | 89 s.semantic(newsc); |
90 if (newsc != sc) | |
91 { | |
92 sc.offset = newsc.offset; | |
93 newsc.pop(); | |
94 } | |
95 } | |
96 } | |
97 | |
72 | 98 override void semantic(Scope sc) |
0 | 99 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
100 auto d = include(sc, null); |
0 | 101 |
102 //printf("\tAttribDeclaration::semantic '%s', d = %p\n",toChars(), d); | |
103 if (d) | |
104 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
105 foreach(s; d) |
0 | 106 s.semantic(sc); |
107 } | |
108 } | |
109 | |
72 | 110 override void semantic2(Scope sc) |
0 | 111 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
112 auto d = include(sc, null); |
0 | 113 |
114 if (d) | |
115 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
116 foreach(s; d) |
0 | 117 s.semantic2(sc); |
118 } | |
119 } | |
120 | |
72 | 121 override void semantic3(Scope sc) |
0 | 122 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
123 auto d = include(sc, null); |
0 | 124 |
125 if (d) | |
126 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
127 foreach(s; d) |
0 | 128 s.semantic3(sc); |
129 } | |
130 } | |
131 | |
72 | 132 override void inlineScan() |
0 | 133 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
134 auto d = include(null, null); |
0 | 135 |
136 if (d) | |
137 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
138 foreach(s; d) |
0 | 139 { |
140 //printf("AttribDeclaration.inlineScan %s\n", s.toChars()); | |
141 s.inlineScan(); | |
142 } | |
143 } | |
144 } | |
145 | |
79 | 146 override void addComment(string comment) |
0 | 147 { |
148 if (comment !is null) | |
149 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
150 auto d = include(null, null); |
0 | 151 if (d) |
152 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
153 foreach(s; d) |
0 | 154 { |
155 //printf("AttribDeclaration::addComment %s\n", s.toChars()); | |
156 s.addComment(comment); | |
157 } | |
158 } | |
159 } | |
160 } | |
161 | |
72 | 162 override void emitComment(Scope sc) |
0 | 163 { |
164 assert(false); | |
165 } | |
166 | |
72 | 167 override string kind() |
0 | 168 { |
169 assert(false); | |
170 } | |
171 | |
72 | 172 override bool oneMember(Dsymbol* ps) |
0 | 173 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
174 auto d = include(null, null); |
49 | 175 |
176 return Dsymbol.oneMembers(d, ps); | |
0 | 177 } |
178 | |
72 | 179 override bool hasPointers() |
0 | 180 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
181 auto d = include(null, null); |
0 | 182 |
183 if (d) | |
184 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
185 foreach(s; d) |
0 | 186 { |
187 if (s.hasPointers()) | |
188 return true; | |
189 } | |
190 } | |
191 | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
192 return false; |
0 | 193 } |
194 | |
72 | 195 override void checkCtorConstInit() |
0 | 196 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
197 auto d = include(null, null); |
0 | 198 if (d) |
199 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
200 foreach(s; d) |
0 | 201 s.checkCtorConstInit(); |
202 } | |
203 } | |
204 | |
72 | 205 override void addLocalClass(ClassDeclarations aclasses) |
0 | 206 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
207 auto d = include(null, null); |
0 | 208 if (d) |
209 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
210 foreach(s; d) |
0 | 211 s.addLocalClass(aclasses); |
212 } | |
213 } | |
214 | |
72 | 215 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 216 { |
217 assert(false); | |
218 } | |
79 | 219 |
220 override void toJsonBuffer(OutBuffer buf) | |
221 { | |
222 //writef("AttribDeclaration.toJsonBuffer()\n"); | |
223 | |
224 Dsymbols d = include(null, null); | |
225 | |
226 if (d) | |
227 { | |
228 foreach (Dsymbol s; d) | |
229 { | |
230 //writef("AttribDeclaration.toJsonBuffer %s\n", s.toChars()); | |
231 s.toJsonBuffer(buf); | |
232 } | |
233 } | |
234 } | |
235 | |
72 | 236 override AttribDeclaration isAttribDeclaration() { return this; } |
0 | 237 |
72 | 238 override void toObjFile(int multiobj) // compile to .obj file |
0 | 239 { |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
240 auto d = include(null, null); |
0 | 241 |
242 if (d) | |
243 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
244 foreach(s; d) |
0 | 245 s.toObjFile(multiobj); |
246 } | |
247 } | |
248 | |
72 | 249 override int cvMember(ubyte* p) |
0 | 250 { |
251 assert(false); | |
252 } | |
72 | 253 } |