Mercurial > projects > ddmd
annotate dmd/TypeInfoDeclaration.d @ 187:b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
author | Abscissa |
---|---|
date | Tue, 07 Jun 2011 23:37:34 -0400 |
parents | e3afd1303184 |
children |
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 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
27 import dmd.DDMDExtensions; |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
28 |
0 | 29 class TypeInfoDeclaration : VarDeclaration |
30 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
31 mixin insertMemberExtension!(typeof(this)); |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
178
diff
changeset
|
32 |
100 | 33 Type tinfo; |
0 | 34 |
100 | 35 this(Type tinfo, int internal) |
0 | 36 { |
178 | 37 register(); |
174 | 38 super(Loc(0), global.typeinfo.type, tinfo.getTypeInfoIdent(internal), null); |
0 | 39 this.tinfo = tinfo; |
40 storage_class = STC.STCstatic | STC.STCgshared; | |
41 protection = PROT.PROTpublic; | |
42 linkage = LINK.LINKc; | |
43 } | |
174 | 44 |
100 | 45 override Dsymbol syntaxCopy(Dsymbol) |
0 | 46 { |
100 | 47 assert(false); // should never be produced by syntax |
48 return null; | |
0 | 49 } |
50 | |
100 | 51 override void semantic(Scope sc) |
0 | 52 { |
100 | 53 assert(linkage == LINKc); |
0 | 54 } |
55 | |
100 | 56 override void emitComment(Scope sc) |
0 | 57 { |
58 } | |
59 | |
100 | 60 override Symbol* toSymbol() |
0 | 61 { |
62 //printf("TypeInfoDeclaration::toSymbol(%s), linkage = %d\n", toChars(), linkage); | |
63 return VarDeclaration.toSymbol(); | |
64 } | |
65 | |
79 | 66 override void toJsonBuffer(OutBuffer buf) |
67 { | |
68 } | |
69 | |
100 | 70 override void toObjFile(int multiobj) // compile to .obj file |
0 | 71 { |
72 Symbol* s; | |
73 uint sz; | |
74 Dsymbol parent; | |
75 | |
76 //printf("TypeInfoDeclaration.toObjFile(%p '%s') protection %d\n", this, toChars(), protection); | |
77 | |
78 if (multiobj) | |
79 { | |
80 obj_append(this); | |
81 return; | |
82 } | |
83 | |
84 s = toSymbol(); | |
85 sz = cast(uint)type.size(); | |
86 | |
87 parent = this.toParent(); | |
88 s.Sclass = SC.SCcomdat; | |
89 s.Sfl = FL.FLdata; | |
90 | |
91 toDt(&s.Sdt); | |
92 | |
93 dt_optimize(s.Sdt); | |
94 | |
95 // See if we can convert a comdat to a comdef, | |
96 // which saves on exe file space. | |
97 if (s.Sclass == SC.SCcomdat && | |
98 s.Sdt.dt == DT.DT_azeros && | |
99 s.Sdt.DTnext == null) | |
100 { | |
101 s.Sclass = SC.SCglobal; | |
102 s.Sdt.dt = DT.DT_common; | |
103 } | |
104 | |
22
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
105 version (ELFOBJ_OR_MACHOBJ) { ///ELFOBJ || MACHOBJ // Burton |
0 | 106 if (s.Sdt && s.Sdt.dt == DT_azeros && s.Sdt.DTnext == null) |
107 s.Sseg = Segment.UDATA; | |
108 else | |
109 s.Sseg = Segment.DATA; | |
110 } | |
111 outdata(s); | |
112 if (isExport()) | |
113 obj_export(s,0); | |
114 } | |
115 | |
100 | 116 void toDt(dt_t** pdt) |
0 | 117 { |
118 assert(false); | |
119 } | |
72 | 120 } |