Mercurial > projects > ddmd
annotate dmd/AggregateDeclaration.d @ 96:acd69f84627e
further work
author | Trass3r |
---|---|
date | Tue, 31 Aug 2010 02:12:15 +0200 |
parents | 37b95c347975 |
children | e28b18c23469 |
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 //printf("AggregateDeclaration.semantic3(%s)\n", toChars()); | |
211 if (members) | |
212 { | |
213 sc = sc.push(this); | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
214 foreach(Dsymbol s; members) |
0 | 215 s.semantic3(sc); |
216 sc.pop(); | |
217 } | |
218 } | |
219 | |
72 | 220 override void inlineScan() |
0 | 221 { |
222 //printf("AggregateDeclaration.inlineScan(%s)\n", toChars()); | |
223 if (members) | |
224 { | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
225 foreach(Dsymbol s; members) |
0 | 226 { |
227 //printf("inline scan aggregate symbol '%s'\n", s.toChars()); | |
228 s.inlineScan(); | |
229 } | |
230 } | |
231 } | |
232 | |
72 | 233 override uint size(Loc loc) |
0 | 234 { |
235 //printf("AggregateDeclaration.size() = %d\n", structsize); | |
236 if (!members) | |
237 error(loc, "unknown size"); | |
238 | |
239 if (sizeok != 1) | |
240 { | |
241 error(loc, "no size yet for forward reference"); | |
242 //*(char*)0=0; | |
243 } | |
244 | |
245 return structsize; | |
246 } | |
247 | |
248 /**************************** | |
249 * Do byte or word alignment as necessary. | |
250 * Align sizes of 0, as we may not know array sizes yet. | |
251 */ | |
252 static void alignmember(uint salign, uint size, uint* poffset) | |
253 { | |
254 //printf("salign = %d, size = %d, offset = %d\n",salign,size,offset); | |
255 if (salign > 1) | |
256 { | |
257 assert(size != 3); | |
258 int sa = size; | |
259 if (sa == 0 || salign < sa) | |
260 sa = salign; | |
261 *poffset = (*poffset + sa - 1) & ~(sa - 1); | |
262 } | |
263 //printf("result = %d\n",offset); | |
264 } | |
265 | |
72 | 266 override Type getType() |
0 | 267 { |
268 return type; | |
269 } | |
270 | |
271 void addField(Scope sc, VarDeclaration v) | |
272 { | |
273 uint memsize; // size of member | |
274 uint memalignsize; // size of member for alignment purposes | |
275 uint xalign; // alignment boundaries | |
276 | |
277 //printf("AggregateDeclaration.addField('%s') %s\n", v.toChars(), toChars()); | |
278 assert(!(v.storage_class & (STC.STCstatic | STC.STCextern | STC.STCparameter | STC.STCtls))); | |
279 | |
280 // Check for forward referenced types which will fail the size() call | |
281 Type t = v.type.toBasetype(); | |
282 if (v.storage_class & STC.STCref) | |
283 { // References are the size of a pointer | |
284 t = Type.tvoidptr; | |
285 } | |
286 if (t.ty == TY.Tstruct /*&& isStructDeclaration()*/) | |
287 { TypeStruct ts = cast(TypeStruct)t; | |
288 version (DMDV2) { | |
289 if (ts.sym == this) | |
290 { | |
291 error("cannot have field %s with same struct type", v.toChars()); | |
292 } | |
293 } | |
294 | |
295 if (ts.sym.sizeok != 1) | |
296 { | |
297 sizeok = 2; // cannot finish; flag as forward referenced | |
298 return; | |
299 } | |
300 } | |
301 if (t.ty == TY.Tident) | |
302 { | |
303 sizeok = 2; // cannot finish; flag as forward referenced | |
304 return; | |
305 } | |
306 | |
307 memsize = cast(uint)t.size(loc); /// | |
308 memalignsize = t.alignsize(); | |
309 xalign = t.memalign(sc.structalign); | |
310 alignmember(xalign, memalignsize, &sc.offset); | |
311 v.offset = sc.offset; | |
312 sc.offset += memsize; | |
313 if (sc.offset > structsize) | |
314 structsize = sc.offset; | |
315 if (sc.structalign < memalignsize) | |
316 memalignsize = sc.structalign; | |
317 if (alignsize < memalignsize) | |
318 alignsize = memalignsize; | |
319 //printf("\talignsize = %d\n", alignsize); | |
320 | |
321 v.storage_class |= STC.STCfield; | |
322 //printf(" addField '%s' to '%s' at offset %d, size = %d\n", v.toChars(), toChars(), v.offset, memsize); | |
79 | 323 fields.push(v); |
0 | 324 } |
325 | |
72 | 326 override bool isDeprecated() // is aggregate deprecated? |
0 | 327 { |
328 return isdeprecated; | |
329 } | |
330 | |
331 /***************************************** | |
332 * Create inclusive destructor for struct/class by aggregating | |
333 * all the destructors in dtors[] with the destructors for | |
334 * all the members. | |
335 * Note the close similarity with StructDeclaration.buildPostBlit(), | |
336 * and the ordering changes (runs backward instead of forwards). | |
337 */ | |
338 FuncDeclaration buildDtor(Scope sc) | |
339 { | |
340 //printf("AggregateDeclaration.buildDtor() %s\n", toChars()); | |
341 Expression e = null; | |
342 | |
79 | 343 version (DMDV2) |
344 { | |
84
be2ab491772e
Expressions -> Vector!Expression
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
79
diff
changeset
|
345 foreach (size_t i, VarDeclaration v; fields) |
0 | 346 { |
347 assert(v && v.storage_class & STC.STCfield); | |
348 if (v.storage_class & STC.STCref) | |
349 continue; | |
350 Type tv = v.type.toBasetype(); | |
351 size_t dim = 1; | |
352 while (tv.ty == TY.Tsarray) | |
353 { TypeSArray ta = cast(TypeSArray)tv; | |
354 dim *= (cast(TypeSArray)tv).dim.toInteger(); | |
355 tv = tv.nextOf().toBasetype(); | |
356 } | |
357 if (tv.ty == TY.Tstruct) | |
358 { TypeStruct ts = cast(TypeStruct)tv; | |
359 StructDeclaration sd = ts.sym; | |
360 if (sd.dtor) | |
361 { | |
362 Expression ex; | |
363 | |
364 // this.v | |
365 ex = new ThisExp(Loc(0)); | |
366 ex = new DotVarExp(Loc(0), ex, v, 0); | |
367 | |
368 if (dim == 1) | |
369 { | |
370 // this.v.dtor() | |
371 ex = new DotVarExp(Loc(0), ex, sd.dtor, 0); | |
372 ex = new CallExp(Loc(0), ex); | |
373 } | |
374 else | |
375 { | |
376 // Typeinfo.destroy(cast(void*)&this.v); | |
377 Expression ea = new AddrExp(Loc(0), ex); | |
378 ea = new CastExp(Loc(0), ea, Type.tvoid.pointerTo()); | |
379 | |
380 Expression et = v.type.getTypeInfo(sc); | |
381 et = new DotIdExp(Loc(0), et, Id.destroy); | |
382 | |
383 ex = new CallExp(Loc(0), et, ea); | |
384 } | |
385 e = Expression.combine(ex, e); // combine in reverse order | |
386 } | |
387 } | |
388 } | |
389 | |
390 /* Build our own "destructor" which executes e | |
391 */ | |
392 if (e) | |
393 { | |
394 //printf("Building __fieldDtor()\n"); | |
395 DtorDeclaration dd = new DtorDeclaration(Loc(0), Loc(0), Lexer.idPool("__fieldDtor")); | |
396 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
|
397 dtors.shift(dd); |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
72
diff
changeset
|
398 members.push(dd); |
0 | 399 dd.semantic(sc); |
400 } | |
401 } | |
402 | |
403 switch (dtors.dim) | |
404 { | |
405 case 0: | |
406 return null; | |
407 | |
408 case 1: | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
409 return cast(FuncDeclaration)dtors[0]; |
0 | 410 |
411 default: | |
412 e = null; | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
413 foreach(FuncDeclaration fd; dtors) |
0 | 414 { |
415 Expression ex = new ThisExp(Loc(0)); | |
416 ex = new DotVarExp(Loc(0), ex, fd, 0); | |
417 ex = new CallExp(Loc(0), ex); | |
418 e = Expression.combine(ex, e); | |
419 } | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
420 auto dd = new DtorDeclaration(Loc(0), Loc(0), Lexer.idPool("__aggrDtor")); |
0 | 421 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
|
422 members.push(dd); |
0 | 423 dd.semantic(sc); |
424 return dd; | |
425 } | |
426 } | |
427 | |
428 /**************************************** | |
429 * Returns true if there's an extra member which is the 'this' | |
430 * pointer to the enclosing context (enclosing aggregate or function) | |
431 */ | |
432 bool isNested() | |
433 { | |
434 return isnested; | |
435 } | |
436 | |
72 | 437 override void emitComment(Scope sc) |
0 | 438 { |
439 assert(false); | |
440 } | |
441 | |
79 | 442 override void toJsonBuffer(OutBuffer buf) |
443 { | |
444 //writef("AggregateDeclaration.toJsonBuffer()\n"); | |
445 buf.writestring("{\n"); | |
446 | |
447 JsonProperty(buf, Pname, toChars()); | |
448 JsonProperty(buf, Pkind, kind()); | |
449 if (comment) | |
450 JsonProperty(buf, Pcomment, comment); | |
451 if (loc.linnum) | |
452 JsonProperty(buf, Pline, loc.linnum); | |
453 | |
454 ClassDeclaration cd = isClassDeclaration(); | |
455 if (cd) | |
456 { | |
457 if (cd.baseClass) | |
458 { | |
459 JsonProperty(buf, "base", cd.baseClass.toChars()); | |
460 } | |
461 if (cd.interfaces_dim) | |
462 { | |
463 JsonString(buf, "interfaces"); | |
464 buf.writestring(" : [\n"); | |
465 size_t offset = buf.offset; | |
466 for (int i = 0; i < cd.interfaces_dim; i++) | |
467 { | |
468 BaseClass b = cd.interfaces[i]; | |
469 if (offset != buf.offset) | |
470 { | |
96 | 471 buf.writestring(",\n"); |
79 | 472 offset = buf.offset; |
473 } | |
474 JsonString(buf, b.base.toChars()); | |
475 } | |
96 | 476 JsonRemoveComma(buf); |
79 | 477 buf.writestring("],\n"); |
478 } | |
479 } | |
480 | |
481 JsonString(buf, Pmembers); | |
482 buf.writestring(" : [\n"); | |
483 size_t offset = buf.offset; | |
484 foreach (Dsymbol s; members) | |
485 { | |
486 if (offset != buf.offset) | |
487 { | |
96 | 488 buf.writestring(",\n"); |
79 | 489 offset = buf.offset; |
490 } | |
491 s.toJsonBuffer(buf); | |
492 } | |
96 | 493 JsonRemoveComma(buf); |
79 | 494 buf.writestring("]\n"); |
495 | |
496 buf.writestring("}\n"); | |
497 } | |
498 | |
72 | 499 override void toDocBuffer(OutBuffer buf) |
0 | 500 { |
501 assert(false); | |
502 } | |
503 | |
504 // For access checking | |
505 PROT getAccess(Dsymbol smember) // determine access to smember | |
506 { | |
507 assert(false); | |
508 } | |
509 | |
510 /**************************************** | |
511 * Determine if this is the same or friend of cd. | |
512 */ | |
513 bool isFriendOf(AggregateDeclaration cd) | |
514 { | |
515 version (LOG) { | |
516 printf("AggregateDeclaration.isFriendOf(this = '%s', cd = '%s')\n", toChars(), cd ? cd.toChars() : "null"); | |
517 } | |
518 if (this is cd) | |
519 return true; | |
520 | |
521 // Friends if both are in the same module | |
522 //if (toParent() == cd.toParent()) | |
523 if (cd && getModule() == cd.getModule()) | |
524 { | |
525 version (LOG) { | |
526 printf("\tin same module\n"); | |
527 } | |
528 return true; | |
529 } | |
530 | |
531 version (LOG) { | |
532 printf("\tnot friend\n"); | |
533 } | |
534 return false; | |
535 } | |
536 | |
537 /********************************** | |
538 * Determine if smember has access to private members of this declaration. | |
539 */ | |
540 bool hasPrivateAccess(Dsymbol smember) // does smember have private access to members of this class? | |
541 { | |
542 if (smember) | |
543 { | |
544 AggregateDeclaration cd = null; | |
545 Dsymbol smemberparent = smember.toParent(); | |
546 if (smemberparent) | |
547 cd = smemberparent.isAggregateDeclaration(); | |
548 | |
549 version (LOG) { | |
550 printf("AggregateDeclaration::hasPrivateAccess(class %s, member %s)\n", toChars(), smember.toChars()); | |
551 } | |
552 | |
553 if (this == cd) // smember is a member of this class | |
554 { | |
555 version (LOG) { | |
556 printf("\tyes 1\n"); | |
557 } | |
558 return true; // so we get private access | |
559 } | |
560 | |
561 // If both are members of the same module, grant access | |
562 while (true) | |
563 { | |
564 Dsymbol sp = smember.toParent(); | |
565 if (sp.isFuncDeclaration() && smember.isFuncDeclaration()) | |
566 smember = sp; | |
567 else | |
568 break; | |
569 } | |
570 if (!cd && toParent() == smember.toParent()) | |
571 { | |
572 version (LOG) { | |
573 printf("\tyes 2\n"); | |
574 } | |
575 return true; | |
576 } | |
577 if (!cd && getModule() == smember.getModule()) | |
578 { | |
579 version (LOG) { | |
580 printf("\tyes 3\n"); | |
581 } | |
582 return true; | |
583 } | |
584 } | |
585 version (LOG) { | |
586 printf("\tno\n"); | |
587 } | |
588 return false; | |
589 } | |
590 | |
591 /******************************* | |
592 * Do access check for member of this class, this class being the | |
593 * type of the 'this' pointer used to access smember. | |
594 */ | |
595 void accessCheck(Loc loc, Scope sc, Dsymbol smember) | |
596 { | |
597 bool result; | |
598 | |
599 FuncDeclaration f = sc.func; | |
600 AggregateDeclaration cdscope = sc.getStructClassScope(); | |
601 PROT access; | |
602 | |
603 version (LOG) { | |
604 printf("AggregateDeclaration.accessCheck() for %s.%s in function %s() in scope %s\n", toChars(), smember.toChars(), f ? f.toChars() : null, cdscope ? cdscope.toChars() : null); | |
605 } | |
606 | |
607 Dsymbol smemberparent = smember.toParent(); | |
608 if (!smemberparent || !smemberparent.isAggregateDeclaration()) | |
609 { | |
610 version (LOG) { | |
611 printf("not an aggregate member\n"); | |
612 } | |
613 return; // then it is accessible | |
614 } | |
615 | |
616 // BUG: should enable this check | |
617 //assert(smember.parent.isBaseOf(this, null)); | |
618 | |
619 if (smemberparent == this) | |
620 { | |
621 PROT access2 = smember.prot(); | |
622 | |
623 result = access2 >= PROT.PROTpublic || | |
624 hasPrivateAccess(f) || | |
625 isFriendOf(cdscope) || | |
626 (access2 == PROT.PROTpackage && hasPackageAccess(sc, this)); | |
627 | |
628 version (LOG) { | |
629 printf("result1 = %d\n", result); | |
630 } | |
631 } | |
632 else if ((access = this.getAccess(smember)) >= PROT.PROTpublic) | |
633 { | |
634 result = true; | |
635 version (LOG) { | |
636 printf("result2 = %d\n", result); | |
637 } | |
638 } | |
639 else if (access == PROT.PROTpackage && hasPackageAccess(sc, this)) | |
640 { | |
641 result = true; | |
642 version (LOG) { | |
643 printf("result3 = %d\n", result); | |
644 } | |
645 } | |
646 else | |
647 { | |
648 result = accessCheckX(smember, f, this, cdscope); | |
649 version (LOG) { | |
650 printf("result4 = %d\n", result); | |
651 } | |
652 } | |
653 if (!result) | |
654 { | |
655 error(loc, "member %s is not accessible", smember.toChars()); | |
656 halt(); | |
657 } | |
658 } | |
659 | |
72 | 660 override PROT prot() |
0 | 661 { |
662 assert(false); | |
663 } | |
664 | |
665 // Back end | |
666 Symbol* stag; // tag symbol for debug data | |
667 Symbol* sinit; | |
668 | |
669 Symbol* toInitializer() | |
670 { | |
671 Symbol* s; | |
672 Classsym* stag; | |
673 | |
674 if (!sinit) | |
675 { | |
676 stag = fake_classsym(Id.ClassInfo); | |
677 s = toSymbolX("__init", SC.SCextern, stag.Stype, "Z"); | |
678 s.Sfl = FL.FLextern; | |
679 s.Sflags |= SFL.SFLnodebug; | |
680 slist_add(s); | |
681 sinit = s; | |
682 } | |
683 | |
684 return sinit; | |
685 } | |
686 | |
72 | 687 override AggregateDeclaration isAggregateDeclaration() { return this; } |
16
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
688 } |