Mercurial > projects > ddmd
annotate dmd/TypeInfoDeclaration.d @ 174:af724d3510d7
lot os toCBuffer methods implemented
moved shared Type.* stuff into Global
author | korDen |
---|---|
date | Sun, 10 Oct 2010 03:47:23 +0400 |
parents | e28b18c23469 |
children | e3afd1303184 |
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 { |
174 | 33 super(Loc(0), global.typeinfo.type, tinfo.getTypeInfoIdent(internal), null); |
0 | 34 this.tinfo = tinfo; |
35 storage_class = STC.STCstatic | STC.STCgshared; | |
36 protection = PROT.PROTpublic; | |
37 linkage = LINK.LINKc; | |
38 } | |
174 | 39 |
0 | 40 version (DumbClone) { |
41 } else { | |
42 Type clone() | |
43 { | |
44 assert(false); | |
45 } | |
46 } | |
100 | 47 override Dsymbol syntaxCopy(Dsymbol) |
0 | 48 { |
100 | 49 assert(false); // should never be produced by syntax |
50 return null; | |
0 | 51 } |
52 | |
100 | 53 override void semantic(Scope sc) |
0 | 54 { |
100 | 55 assert(linkage == LINKc); |
0 | 56 } |
57 | |
100 | 58 override void emitComment(Scope sc) |
0 | 59 { |
60 } | |
61 | |
100 | 62 override Symbol* toSymbol() |
0 | 63 { |
64 //printf("TypeInfoDeclaration::toSymbol(%s), linkage = %d\n", toChars(), linkage); | |
65 return VarDeclaration.toSymbol(); | |
66 } | |
67 | |
79 | 68 override void toJsonBuffer(OutBuffer buf) |
69 { | |
70 } | |
71 | |
100 | 72 override void toObjFile(int multiobj) // compile to .obj file |
0 | 73 { |
74 Symbol* s; | |
75 uint sz; | |
76 Dsymbol parent; | |
77 | |
78 //printf("TypeInfoDeclaration.toObjFile(%p '%s') protection %d\n", this, toChars(), protection); | |
79 | |
80 if (multiobj) | |
81 { | |
82 obj_append(this); | |
83 return; | |
84 } | |
85 | |
86 s = toSymbol(); | |
87 sz = cast(uint)type.size(); | |
88 | |
89 parent = this.toParent(); | |
90 s.Sclass = SC.SCcomdat; | |
91 s.Sfl = FL.FLdata; | |
92 | |
93 toDt(&s.Sdt); | |
94 | |
95 dt_optimize(s.Sdt); | |
96 | |
97 // See if we can convert a comdat to a comdef, | |
98 // which saves on exe file space. | |
99 if (s.Sclass == SC.SCcomdat && | |
100 s.Sdt.dt == DT.DT_azeros && | |
101 s.Sdt.DTnext == null) | |
102 { | |
103 s.Sclass = SC.SCglobal; | |
104 s.Sdt.dt = DT.DT_common; | |
105 } | |
106 | |
22
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
107 version (ELFOBJ_OR_MACHOBJ) { ///ELFOBJ || MACHOBJ // Burton |
0 | 108 if (s.Sdt && s.Sdt.dt == DT_azeros && s.Sdt.DTnext == null) |
109 s.Sseg = Segment.UDATA; | |
110 else | |
111 s.Sseg = Segment.DATA; | |
112 } | |
113 outdata(s); | |
114 if (isExport()) | |
115 obj_export(s,0); | |
116 } | |
117 | |
100 | 118 void toDt(dt_t** pdt) |
0 | 119 { |
120 assert(false); | |
121 } | |
72 | 122 } |