Mercurial > projects > ddmd
annotate dmd/AggregateDeclaration.d @ 84:be2ab491772e
Expressions -> Vector!Expression
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Mon, 30 Aug 2010 16:12:19 +0100 |
parents | 43073c7c7769 |
children | 37b95c347975 |
rev | line source |
---|---|
0 | 1 module dmd.AggregateDeclaration; |
2 | |
3 import dmd.ScopeDsymbol; | |
4 import dmd.Type; | |
5 import dmd.Id; | |
6 import dmd.ExpStatement; | |
7 import dmd.AddrExp; | |
8 import dmd.CastExp; | |
9 import dmd.TypeSArray; | |
10 import dmd.DotVarExp; | |
11 import dmd.TypeStruct; | |
12 import dmd.StructDeclaration; | |
13 import dmd.Declaration; | |
14 import dmd.TypeClass; | |
15 import dmd.TOK; | |
16 import dmd.ThisExp; | |
17 import dmd.PROT; | |
18 import dmd.Expression; | |
19 import dmd.STC; | |
20 import dmd.DotIdExp; | |
21 import dmd.CallExp; | |
22 import dmd.DtorDeclaration; | |
23 import dmd.Lexer; | |
24 import dmd.TY; | |
25 import dmd.Array; | |
26 import dmd.ArrayTypes; | |
27 import dmd.VarDeclaration; | |
28 import dmd.InvariantDeclaration; | |
29 import dmd.NewDeclaration; | |
30 import dmd.DeleteDeclaration; | |
31 import dmd.CtorDeclaration; | |
32 import dmd.FuncDeclaration; | |
33 import dmd.Identifier; | |
79 | 34 import dmd.Json; |
0 | 35 import dmd.Loc; |
36 import dmd.Dsymbol; | |
37 import dmd.Scope; | |
38 import dmd.OutBuffer; | |
39 import dmd.ClassDeclaration; | |
40 import dmd.BaseClass; | |
41 import dmd.Util; | |
42 | |
43 import dmd.backend.Symbol; | |
44 import dmd.backend.Classsym; | |
45 import dmd.backend.Util; | |
46 import dmd.backend.LIST; | |
47 import dmd.backend.SC; | |
48 import dmd.backend.FL; | |
49 import dmd.backend.SFL; | |
50 import dmd.codegen.Util; | |
51 | |
52 /**************************************** | |
53 * Determine if scope sc has package level access to s. | |
54 */ | |
55 | |
56 bool hasPackageAccess(Scope sc, Dsymbol s) | |
57 { | |
58 version (LOG) { | |
59 printf("hasPackageAccess(s = '%s', sc = '%p')\n", s.toChars(), sc); | |
60 } | |
61 | |
62 for (; s; s = s.parent) | |
63 { | |
64 if (s.isPackage() && !s.isModule()) | |
65 break; | |
66 } | |
67 version (LOG) { | |
68 if (s) | |
69 printf("\tthis is in package '%s'\n", s.toChars()); | |
70 } | |
71 | |
72 if (s && s == sc.module_.parent) | |
73 { | |
74 version (LOG) { | |
75 printf("\ts is in same package as sc\n"); | |
76 } | |
77 return true; | |
78 } | |
79 | |
80 | |
81 version (LOG) { | |
82 printf("\tno package access\n"); | |
83 } | |
84 | |
85 return false; | |
86 } | |
87 | |
88 /******************************************************** | |
89 * Helper function for ClassDeclaration.accessCheck() | |
90 * Returns: | |
91 * 0 no access | |
92 * 1 access | |
93 */ | |
94 | |
95 bool accessCheckX(Dsymbol smember, Dsymbol sfunc, AggregateDeclaration dthis, AggregateDeclaration cdscope) | |
96 { | |
97 assert(dthis); | |
98 | |
99 static if (false) { | |
100 writef("accessCheckX for %s.%s in function %s() in scope %s\n", dthis.toChars(), smember.toChars(), sfunc ? sfunc.toChars() : "null", cdscope ? cdscope.toChars() : "null"); | |
101 } | |
102 if (dthis.hasPrivateAccess(sfunc) || dthis.isFriendOf(cdscope)) | |
103 { | |
104 if (smember.toParent() == dthis) | |
105 return true; | |
106 else | |
107 { | |
108 ClassDeclaration cdthis = dthis.isClassDeclaration(); | |
109 if (cdthis) | |
110 { | |
111 for (int i = 0; i < cdthis.baseclasses.dim; i++) | |
112 { | |
113 BaseClass b = cast(BaseClass)cdthis.baseclasses.data[i]; | |
114 PROT access = b.base.getAccess(smember); | |
115 | |
116 if (access >= PROT.PROTprotected || accessCheckX(smember, sfunc, b.base, cdscope)) | |
117 return true; | |
118 } | |
119 } | |
120 } | |
121 } | |
122 else | |
123 { | |
124 if (smember.toParent() != dthis) | |
125 { | |
126 ClassDeclaration cdthis = dthis.isClassDeclaration(); | |
127 if (cdthis) | |
128 { | |
129 for (int i = 0; i < cdthis.baseclasses.dim; i++) | |
130 { | |
131 BaseClass b = cast(BaseClass)cdthis.baseclasses.data[i]; | |
132 | |
133 if (accessCheckX(smember, sfunc, b.base, cdscope)) | |
134 return true; | |
135 } | |
136 } | |
137 } | |
138 } | |
139 | |
140 return false; | |
141 } | |
142 | |
143 class AggregateDeclaration : ScopeDsymbol | |
144 { | |
145 Type type; | |
146 uint storage_class; | |
147 PROT protection = PROT.PROTpublic; | |
148 Type handle; // 'this' type | |
149 uint structsize; // size of struct | |
150 uint alignsize; // size of struct for alignment purposes | |
151 uint structalign; // struct member alignment in effect | |
152 int hasUnions; // set if aggregate has overlapping fields | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
79
diff
changeset
|
153 VarDeclarations fields; // VarDeclaration fields |
0 | 154 uint sizeok; // set when structsize contains valid data |
155 // 0: no size | |
156 // 1: size is correct | |
157 // 2: cannot determine size; fwd referenced | |
158 bool isdeprecated; // true if deprecated | |
159 | |
160 bool isnested; // true if is nested | |
161 VarDeclaration vthis; // 'this' parameter if this aggregate is nested | |
162 | |
163 // Special member functions | |
164 InvariantDeclaration inv; // invariant | |
165 NewDeclaration aggNew; // allocator | |
166 DeleteDeclaration aggDelete; // deallocator | |
167 | |
168 version (DMDV2) { | |
169 //CtorDeclaration *ctor; | |
170 Dsymbol ctor; // CtorDeclaration or TemplateDeclaration | |
171 CtorDeclaration defaultCtor; // default constructor | |
172 Dsymbol aliasthis; // forward unresolved lookups to aliasthis | |
173 } | |
174 | |
175 FuncDeclarations dtors; // Array of destructors | |
176 FuncDeclaration dtor; // aggregate destructor | |
177 | |
178 version (IN_GCC) { | |
179 Array methods; // flat list of all methods for debug information | |
180 } | |
181 | |
182 this(Loc loc, Identifier id) | |
183 { | |
184 super(id); | |
185 this.loc = loc; | |
186 | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
79
diff
changeset
|
187 fields = new VarDeclarations(); /// |
0 | 188 dtors = new FuncDeclarations(); |
189 } | |
190 | |
72 | 191 override void semantic2(Scope sc) |
0 | 192 { |
193 //printf("AggregateDeclaration.semantic2(%s)\n", toChars()); | |
194 if (scope_ && members) | |
195 { | |
196 error("has forward references"); | |
197 return; | |
198 } | |
199 if (members) | |
200 { | |
201 sc = sc.push(this); | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
202 foreach(Dsymbol s; members) |
0 | 203 s.semantic2(sc); |
204 sc.pop(); | |
205 } | |
206 } | |
207 | |
72 | 208 override void semantic3(Scope sc) |
0 | 209 { |
210 int i; | |
211 | |
212 //printf("AggregateDeclaration.semantic3(%s)\n", toChars()); | |
213 if (members) | |
214 { | |
215 sc = sc.push(this); | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
216 foreach(Dsymbol s; members) |
0 | 217 s.semantic3(sc); |
218 sc.pop(); | |
219 } | |
220 } | |
221 | |
72 | 222 override void inlineScan() |
0 | 223 { |
224 int i; | |
225 | |
226 //printf("AggregateDeclaration.inlineScan(%s)\n", toChars()); | |
227 if (members) | |
228 { | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
229 foreach(Dsymbol s; members) |
0 | 230 { |
231 //printf("inline scan aggregate symbol '%s'\n", s.toChars()); | |
232 s.inlineScan(); | |
233 } | |
234 } | |
235 } | |
236 | |
72 | 237 override uint size(Loc loc) |
0 | 238 { |
239 //printf("AggregateDeclaration.size() = %d\n", structsize); | |
240 if (!members) | |
241 error(loc, "unknown size"); | |
242 | |
243 if (sizeok != 1) | |
244 { | |
245 error(loc, "no size yet for forward reference"); | |
246 //*(char*)0=0; | |
247 } | |
248 | |
249 return structsize; | |
250 } | |
251 | |
252 /**************************** | |
253 * Do byte or word alignment as necessary. | |
254 * Align sizes of 0, as we may not know array sizes yet. | |
255 */ | |
256 static void alignmember(uint salign, uint size, uint* poffset) | |
257 { | |
258 //printf("salign = %d, size = %d, offset = %d\n",salign,size,offset); | |
259 if (salign > 1) | |
260 { | |
261 assert(size != 3); | |
262 int sa = size; | |
263 if (sa == 0 || salign < sa) | |
264 sa = salign; | |
265 *poffset = (*poffset + sa - 1) & ~(sa - 1); | |
266 } | |
267 //printf("result = %d\n",offset); | |
268 } | |
269 | |
72 | 270 override Type getType() |
0 | 271 { |
272 return type; | |
273 } | |
274 | |
275 void addField(Scope sc, VarDeclaration v) | |
276 { | |
277 uint memsize; // size of member | |
278 uint memalignsize; // size of member for alignment purposes | |
279 uint xalign; // alignment boundaries | |
280 | |
281 //printf("AggregateDeclaration.addField('%s') %s\n", v.toChars(), toChars()); | |
282 assert(!(v.storage_class & (STC.STCstatic | STC.STCextern | STC.STCparameter | STC.STCtls))); | |
283 | |
284 // Check for forward referenced types which will fail the size() call | |
285 Type t = v.type.toBasetype(); | |
286 if (v.storage_class & STC.STCref) | |
287 { // References are the size of a pointer | |
288 t = Type.tvoidptr; | |
289 } | |
290 if (t.ty == TY.Tstruct /*&& isStructDeclaration()*/) | |
291 { TypeStruct ts = cast(TypeStruct)t; | |
292 version (DMDV2) { | |
293 if (ts.sym == this) | |
294 { | |
295 error("cannot have field %s with same struct type", v.toChars()); | |
296 } | |
297 } | |
298 | |
299 if (ts.sym.sizeok != 1) | |
300 { | |
301 sizeok = 2; // cannot finish; flag as forward referenced | |
302 return; | |
303 } | |
304 } | |
305 if (t.ty == TY.Tident) | |
306 { | |
307 sizeok = 2; // cannot finish; flag as forward referenced | |
308 return; | |
309 } | |
310 | |
311 memsize = cast(uint)t.size(loc); /// | |
312 memalignsize = t.alignsize(); | |
313 xalign = t.memalign(sc.structalign); | |
314 alignmember(xalign, memalignsize, &sc.offset); | |
315 v.offset = sc.offset; | |
316 sc.offset += memsize; | |
317 if (sc.offset > structsize) | |
318 structsize = sc.offset; | |
319 if (sc.structalign < memalignsize) | |
320 memalignsize = sc.structalign; | |
321 if (alignsize < memalignsize) | |
322 alignsize = memalignsize; | |
323 //printf("\talignsize = %d\n", alignsize); | |
324 | |
325 v.storage_class |= STC.STCfield; | |
326 //printf(" addField '%s' to '%s' at offset %d, size = %d\n", v.toChars(), toChars(), v.offset, memsize); | |
79 | 327 fields.push(v); |
0 | 328 } |
329 | |
72 | 330 override bool isDeprecated() // is aggregate deprecated? |
0 | 331 { |
332 return isdeprecated; | |
333 } | |
334 | |
335 /***************************************** | |
336 * Create inclusive destructor for struct/class by aggregating | |
337 * all the destructors in dtors[] with the destructors for | |
338 * all the members. | |
339 * Note the close similarity with StructDeclaration.buildPostBlit(), | |
340 * and the ordering changes (runs backward instead of forwards). | |
341 */ | |
342 FuncDeclaration buildDtor(Scope sc) | |
343 { | |
344 //printf("AggregateDeclaration.buildDtor() %s\n", toChars()); | |
345 Expression e = null; | |
346 | |
79 | 347 version (DMDV2) |
348 { | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
79
diff
changeset
|
349 foreach (size_t i, VarDeclaration v; fields) |
0 | 350 { |
351 assert(v && v.storage_class & STC.STCfield); | |
352 if (v.storage_class & STC.STCref) | |
353 continue; | |
354 Type tv = v.type.toBasetype(); | |
355 size_t dim = 1; | |
356 while (tv.ty == TY.Tsarray) | |
357 { TypeSArray ta = cast(TypeSArray)tv; | |
358 dim *= (cast(TypeSArray)tv).dim.toInteger(); | |
359 tv = tv.nextOf().toBasetype(); | |
360 } | |
361 if (tv.ty == TY.Tstruct) | |
362 { TypeStruct ts = cast(TypeStruct)tv; | |
363 StructDeclaration sd = ts.sym; | |
364 if (sd.dtor) | |
365 { | |
366 Expression ex; | |
367 | |
368 // this.v | |
369 ex = new ThisExp(Loc(0)); | |
370 ex = new DotVarExp(Loc(0), ex, v, 0); | |
371 | |
372 if (dim == 1) | |
373 { | |
374 // this.v.dtor() | |
375 ex = new DotVarExp(Loc(0), ex, sd.dtor, 0); | |
376 ex = new CallExp(Loc(0), ex); | |
377 } | |
378 else | |
379 { | |
380 // Typeinfo.destroy(cast(void*)&this.v); | |
381 Expression ea = new AddrExp(Loc(0), ex); | |
382 ea = new CastExp(Loc(0), ea, Type.tvoid.pointerTo()); | |
383 | |
384 Expression et = v.type.getTypeInfo(sc); | |
385 et = new DotIdExp(Loc(0), et, Id.destroy); | |
386 | |
387 ex = new CallExp(Loc(0), et, ea); | |
388 } | |
389 e = Expression.combine(ex, e); // combine in reverse order | |
390 } | |
391 } | |
392 } | |
393 | |
394 /* Build our own "destructor" which executes e | |
395 */ | |
396 if (e) | |
397 { | |
398 //printf("Building __fieldDtor()\n"); | |
399 DtorDeclaration dd = new DtorDeclaration(Loc(0), Loc(0), Lexer.idPool("__fieldDtor")); | |
400 dd.fbody = new ExpStatement(Loc(0), e); | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
401 dtors.shift(dd); |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
402 members.push(dd); |
0 | 403 dd.semantic(sc); |
404 } | |
405 } | |
406 | |
407 switch (dtors.dim) | |
408 { | |
409 case 0: | |
410 return null; | |
411 | |
412 case 1: | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
413 return cast(FuncDeclaration)dtors[0]; |
0 | 414 |
415 default: | |
416 e = null; | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
417 foreach(FuncDeclaration fd; dtors) |
0 | 418 { |
419 Expression ex = new ThisExp(Loc(0)); | |
420 ex = new DotVarExp(Loc(0), ex, fd, 0); | |
421 ex = new CallExp(Loc(0), ex); | |
422 e = Expression.combine(ex, e); | |
423 } | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
424 auto dd = new DtorDeclaration(Loc(0), Loc(0), Lexer.idPool("__aggrDtor")); |
0 | 425 dd.fbody = new ExpStatement(Loc(0), e); |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
426 members.push(dd); |
0 | 427 dd.semantic(sc); |
428 return dd; | |
429 } | |
430 } | |
431 | |
432 /**************************************** | |
433 * Returns true if there's an extra member which is the 'this' | |
434 * pointer to the enclosing context (enclosing aggregate or function) | |
435 */ | |
436 bool isNested() | |
437 { | |
438 return isnested; | |
439 } | |
440 | |
72 | 441 override void emitComment(Scope sc) |
0 | 442 { |
443 assert(false); | |
444 } | |
445 | |
79 | 446 override void toJsonBuffer(OutBuffer buf) |
447 { | |
448 //writef("AggregateDeclaration.toJsonBuffer()\n"); | |
449 buf.writestring("{\n"); | |
450 | |
451 JsonProperty(buf, Pname, toChars()); | |
452 JsonProperty(buf, Pkind, kind()); | |
453 if (comment) | |
454 JsonProperty(buf, Pcomment, comment); | |
455 if (loc.linnum) | |
456 JsonProperty(buf, Pline, loc.linnum); | |
457 | |
458 ClassDeclaration cd = isClassDeclaration(); | |
459 if (cd) | |
460 { | |
461 if (cd.baseClass) | |
462 { | |
463 JsonProperty(buf, "base", cd.baseClass.toChars()); | |
464 } | |
465 if (cd.interfaces_dim) | |
466 { | |
467 JsonString(buf, "interfaces"); | |
468 buf.writestring(" : [\n"); | |
469 size_t offset = buf.offset; | |
470 for (int i = 0; i < cd.interfaces_dim; i++) | |
471 { | |
472 BaseClass b = cd.interfaces[i]; | |
473 if (offset != buf.offset) | |
474 { | |
475 buf.writestring(","); | |
476 offset = buf.offset; | |
477 } | |
478 JsonString(buf, b.base.toChars()); | |
479 } | |
480 buf.writestring("],\n"); | |
481 } | |
482 } | |
483 | |
484 JsonString(buf, Pmembers); | |
485 buf.writestring(" : [\n"); | |
486 size_t offset = buf.offset; | |
487 foreach (Dsymbol s; members) | |
488 { | |
489 if (offset != buf.offset) | |
490 { | |
491 buf.writestring(","); | |
492 offset = buf.offset; | |
493 } | |
494 s.toJsonBuffer(buf); | |
495 } | |
496 buf.writestring("]\n"); | |
497 | |
498 buf.writestring("}\n"); | |
499 } | |
500 | |
72 | 501 override void toDocBuffer(OutBuffer buf) |
0 | 502 { |
503 assert(false); | |
504 } | |
505 | |
506 // For access checking | |
507 PROT getAccess(Dsymbol smember) // determine access to smember | |
508 { | |
509 assert(false); | |
510 } | |
511 | |
512 /**************************************** | |
513 * Determine if this is the same or friend of cd. | |
514 */ | |
515 bool isFriendOf(AggregateDeclaration cd) | |
516 { | |
517 version (LOG) { | |
518 printf("AggregateDeclaration.isFriendOf(this = '%s', cd = '%s')\n", toChars(), cd ? cd.toChars() : "null"); | |
519 } | |
520 if (this is cd) | |
521 return true; | |
522 | |
523 // Friends if both are in the same module | |
524 //if (toParent() == cd.toParent()) | |
525 if (cd && getModule() == cd.getModule()) | |
526 { | |
527 version (LOG) { | |
528 printf("\tin same module\n"); | |
529 } | |
530 return true; | |
531 } | |
532 | |
533 version (LOG) { | |
534 printf("\tnot friend\n"); | |
535 } | |
536 return false; | |
537 } | |
538 | |
539 /********************************** | |
540 * Determine if smember has access to private members of this declaration. | |
541 */ | |
542 bool hasPrivateAccess(Dsymbol smember) // does smember have private access to members of this class? | |
543 { | |
544 if (smember) | |
545 { | |
546 AggregateDeclaration cd = null; | |
547 Dsymbol smemberparent = smember.toParent(); | |
548 if (smemberparent) | |
549 cd = smemberparent.isAggregateDeclaration(); | |
550 | |
551 version (LOG) { | |
552 printf("AggregateDeclaration::hasPrivateAccess(class %s, member %s)\n", toChars(), smember.toChars()); | |
553 } | |
554 | |
555 if (this == cd) // smember is a member of this class | |
556 { | |
557 version (LOG) { | |
558 printf("\tyes 1\n"); | |
559 } | |
560 return true; // so we get private access | |
561 } | |
562 | |
563 // If both are members of the same module, grant access | |
564 while (true) | |
565 { | |
566 Dsymbol sp = smember.toParent(); | |
567 if (sp.isFuncDeclaration() && smember.isFuncDeclaration()) | |
568 smember = sp; | |
569 else | |
570 break; | |
571 } | |
572 if (!cd && toParent() == smember.toParent()) | |
573 { | |
574 version (LOG) { | |
575 printf("\tyes 2\n"); | |
576 } | |
577 return true; | |
578 } | |
579 if (!cd && getModule() == smember.getModule()) | |
580 { | |
581 version (LOG) { | |
582 printf("\tyes 3\n"); | |
583 } | |
584 return true; | |
585 } | |
586 } | |
587 version (LOG) { | |
588 printf("\tno\n"); | |
589 } | |
590 return false; | |
591 } | |
592 | |
593 /******************************* | |
594 * Do access check for member of this class, this class being the | |
595 * type of the 'this' pointer used to access smember. | |
596 */ | |
597 void accessCheck(Loc loc, Scope sc, Dsymbol smember) | |
598 { | |
599 bool result; | |
600 | |
601 FuncDeclaration f = sc.func; | |
602 AggregateDeclaration cdscope = sc.getStructClassScope(); | |
603 PROT access; | |
604 | |
605 version (LOG) { | |
606 printf("AggregateDeclaration.accessCheck() for %s.%s in function %s() in scope %s\n", toChars(), smember.toChars(), f ? f.toChars() : null, cdscope ? cdscope.toChars() : null); | |
607 } | |
608 | |
609 Dsymbol smemberparent = smember.toParent(); | |
610 if (!smemberparent || !smemberparent.isAggregateDeclaration()) | |
611 { | |
612 version (LOG) { | |
613 printf("not an aggregate member\n"); | |
614 } | |
615 return; // then it is accessible | |
616 } | |
617 | |
618 // BUG: should enable this check | |
619 //assert(smember.parent.isBaseOf(this, null)); | |
620 | |
621 if (smemberparent == this) | |
622 { | |
623 PROT access2 = smember.prot(); | |
624 | |
625 result = access2 >= PROT.PROTpublic || | |
626 hasPrivateAccess(f) || | |
627 isFriendOf(cdscope) || | |
628 (access2 == PROT.PROTpackage && hasPackageAccess(sc, this)); | |
629 | |
630 version (LOG) { | |
631 printf("result1 = %d\n", result); | |
632 } | |
633 } | |
634 else if ((access = this.getAccess(smember)) >= PROT.PROTpublic) | |
635 { | |
636 result = true; | |
637 version (LOG) { | |
638 printf("result2 = %d\n", result); | |
639 } | |
640 } | |
641 else if (access == PROT.PROTpackage && hasPackageAccess(sc, this)) | |
642 { | |
643 result = true; | |
644 version (LOG) { | |
645 printf("result3 = %d\n", result); | |
646 } | |
647 } | |
648 else | |
649 { | |
650 result = accessCheckX(smember, f, this, cdscope); | |
651 version (LOG) { | |
652 printf("result4 = %d\n", result); | |
653 } | |
654 } | |
655 if (!result) | |
656 { | |
657 error(loc, "member %s is not accessible", smember.toChars()); | |
658 halt(); | |
659 } | |
660 } | |
661 | |
72 | 662 override PROT prot() |
0 | 663 { |
664 assert(false); | |
665 } | |
666 | |
667 // Back end | |
668 Symbol* stag; // tag symbol for debug data | |
669 Symbol* sinit; | |
670 | |
671 Symbol* toInitializer() | |
672 { | |
673 Symbol* s; | |
674 Classsym* stag; | |
675 | |
676 if (!sinit) | |
677 { | |
678 stag = fake_classsym(Id.ClassInfo); | |
679 s = toSymbolX("__init", SC.SCextern, stag.Stype, "Z"); | |
680 s.Sfl = FL.FLextern; | |
681 s.Sflags |= SFL.SFLnodebug; | |
682 slist_add(s); | |
683 sinit = s; | |
684 } | |
685 | |
686 return sinit; | |
687 } | |
688 | |
72 | 689 override AggregateDeclaration isAggregateDeclaration() { return this; } |
16
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
690 } |