Mercurial > projects > ddmd
annotate dmd/TypeInfoDeclaration.d @ 178:e3afd1303184
Many small bugs fixed
Made all classes derive from TObject to detect memory leaks (functionality is disabled for now)
Began work on overriding backend memory allocations (to avoid memory leaks)
author | korDen |
---|---|
date | Sun, 17 Oct 2010 07:42:00 +0400 |
parents | af724d3510d7 |
children | b0d41ff5e0df |
rev | line source |
---|---|
0 | 1 module dmd.TypeInfoDeclaration; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.VarDeclaration; |
5 import dmd.Type; | |
6 import dmd.Dsymbol; | |
22
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
7 import dmd.Module; |
0 | 8 import dmd.Scope; |
9 import dmd.Loc; | |
10 import dmd.STC; | |
174 | 11 import dmd.Global; |
79 | 12 import dmd.OutBuffer; |
0 | 13 import dmd.PROT; |
14 import dmd.LINK; | |
15 | |
16 import dmd.backend.Symbol; | |
17 import dmd.backend.dt_t; | |
18 import dmd.backend.DT; | |
19 import dmd.backend.SC; | |
20 import dmd.backend.FL; | |
21 import dmd.backend.glue; | |
22 import dmd.backend.Util; | |
23 import dmd.backend.TYPE; | |
72 | 24 |
0 | 25 import core.stdc.stdio; |
26 | |
27 class TypeInfoDeclaration : VarDeclaration | |
28 { | |
100 | 29 Type tinfo; |
0 | 30 |
100 | 31 this(Type tinfo, int internal) |
0 | 32 { |
178 | 33 register(); |
174 | 34 super(Loc(0), global.typeinfo.type, tinfo.getTypeInfoIdent(internal), null); |
0 | 35 this.tinfo = tinfo; |
36 storage_class = STC.STCstatic | STC.STCgshared; | |
37 protection = PROT.PROTpublic; | |
38 linkage = LINK.LINKc; | |
39 } | |
174 | 40 |
100 | 41 override Dsymbol syntaxCopy(Dsymbol) |
0 | 42 { |
100 | 43 assert(false); // should never be produced by syntax |
44 return null; | |
0 | 45 } |
46 | |
100 | 47 override void semantic(Scope sc) |
0 | 48 { |
100 | 49 assert(linkage == LINKc); |
0 | 50 } |
51 | |
100 | 52 override void emitComment(Scope sc) |
0 | 53 { |
54 } | |
55 | |
100 | 56 override Symbol* toSymbol() |
0 | 57 { |
58 //printf("TypeInfoDeclaration::toSymbol(%s), linkage = %d\n", toChars(), linkage); | |
59 return VarDeclaration.toSymbol(); | |
60 } | |
61 | |
79 | 62 override void toJsonBuffer(OutBuffer buf) |
63 { | |
64 } | |
65 | |
100 | 66 override void toObjFile(int multiobj) // compile to .obj file |
0 | 67 { |
68 Symbol* s; | |
69 uint sz; | |
70 Dsymbol parent; | |
71 | |
72 //printf("TypeInfoDeclaration.toObjFile(%p '%s') protection %d\n", this, toChars(), protection); | |
73 | |
74 if (multiobj) | |
75 { | |
76 obj_append(this); | |
77 return; | |
78 } | |
79 | |
80 s = toSymbol(); | |
81 sz = cast(uint)type.size(); | |
82 | |
83 parent = this.toParent(); | |
84 s.Sclass = SC.SCcomdat; | |
85 s.Sfl = FL.FLdata; | |
86 | |
87 toDt(&s.Sdt); | |
88 | |
89 dt_optimize(s.Sdt); | |
90 | |
91 // See if we can convert a comdat to a comdef, | |
92 // which saves on exe file space. | |
93 if (s.Sclass == SC.SCcomdat && | |
94 s.Sdt.dt == DT.DT_azeros && | |
95 s.Sdt.DTnext == null) | |
96 { | |
97 s.Sclass = SC.SCglobal; | |
98 s.Sdt.dt = DT.DT_common; | |
99 } | |
100 | |
22
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
101 version (ELFOBJ_OR_MACHOBJ) { ///ELFOBJ || MACHOBJ // Burton |
0 | 102 if (s.Sdt && s.Sdt.dt == DT_azeros && s.Sdt.DTnext == null) |
103 s.Sseg = Segment.UDATA; | |
104 else | |
105 s.Sseg = Segment.DATA; | |
106 } | |
107 outdata(s); | |
108 if (isExport()) | |
109 obj_export(s,0); | |
110 } | |
111 | |
100 | 112 void toDt(dt_t** pdt) |
0 | 113 { |
114 assert(false); | |
115 } | |
72 | 116 } |