Mercurial > projects > ddmd
annotate dmd/TypeInfoDeclaration.d @ 114:e28b18c23469
added a module dmd.common for commonly used stuff
it currently holds code for consistency checking of predefined versions
also added a VisualD project file
author | Trass3r |
---|---|
date | Wed, 01 Sep 2010 18:21:58 +0200 |
parents | 8e1e220cebb3 |
children | af724d3510d7 |
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; | |
79 | 11 import dmd.OutBuffer; |
0 | 12 import dmd.PROT; |
13 import dmd.LINK; | |
14 | |
15 import dmd.backend.Symbol; | |
16 import dmd.backend.dt_t; | |
17 import dmd.backend.DT; | |
18 import dmd.backend.SC; | |
19 import dmd.backend.FL; | |
20 import dmd.backend.glue; | |
21 import dmd.backend.Util; | |
22 import dmd.backend.TYPE; | |
72 | 23 |
0 | 24 import core.stdc.stdio; |
25 | |
26 class TypeInfoDeclaration : VarDeclaration | |
27 { | |
100 | 28 Type tinfo; |
0 | 29 |
100 | 30 this(Type tinfo, int internal) |
0 | 31 { |
32 super(Loc(0), Type.typeinfo.type, tinfo.getTypeInfoIdent(internal), null); | |
33 this.tinfo = tinfo; | |
34 storage_class = STC.STCstatic | STC.STCgshared; | |
35 protection = PROT.PROTpublic; | |
36 linkage = LINK.LINKc; | |
37 } | |
38 | |
39 version (DumbClone) { | |
40 } else { | |
41 Type clone() | |
42 { | |
43 assert(false); | |
44 } | |
45 } | |
100 | 46 override Dsymbol syntaxCopy(Dsymbol) |
0 | 47 { |
100 | 48 assert(false); // should never be produced by syntax |
49 return null; | |
0 | 50 } |
51 | |
100 | 52 override void semantic(Scope sc) |
0 | 53 { |
100 | 54 assert(linkage == LINKc); |
0 | 55 } |
56 | |
100 | 57 override void emitComment(Scope sc) |
0 | 58 { |
59 } | |
60 | |
100 | 61 override Symbol* toSymbol() |
0 | 62 { |
63 //printf("TypeInfoDeclaration::toSymbol(%s), linkage = %d\n", toChars(), linkage); | |
64 return VarDeclaration.toSymbol(); | |
65 } | |
66 | |
79 | 67 override void toJsonBuffer(OutBuffer buf) |
68 { | |
69 } | |
70 | |
100 | 71 override void toObjFile(int multiobj) // compile to .obj file |
0 | 72 { |
73 Symbol* s; | |
74 uint sz; | |
75 Dsymbol parent; | |
76 | |
77 //printf("TypeInfoDeclaration.toObjFile(%p '%s') protection %d\n", this, toChars(), protection); | |
78 | |
79 if (multiobj) | |
80 { | |
81 obj_append(this); | |
82 return; | |
83 } | |
84 | |
85 s = toSymbol(); | |
86 sz = cast(uint)type.size(); | |
87 | |
88 parent = this.toParent(); | |
89 s.Sclass = SC.SCcomdat; | |
90 s.Sfl = FL.FLdata; | |
91 | |
92 toDt(&s.Sdt); | |
93 | |
94 dt_optimize(s.Sdt); | |
95 | |
96 // See if we can convert a comdat to a comdef, | |
97 // which saves on exe file space. | |
98 if (s.Sclass == SC.SCcomdat && | |
99 s.Sdt.dt == DT.DT_azeros && | |
100 s.Sdt.DTnext == null) | |
101 { | |
102 s.Sclass = SC.SCglobal; | |
103 s.Sdt.dt = DT.DT_common; | |
104 } | |
105 | |
22
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
106 version (ELFOBJ_OR_MACHOBJ) { ///ELFOBJ || MACHOBJ // Burton |
0 | 107 if (s.Sdt && s.Sdt.dt == DT_azeros && s.Sdt.DTnext == null) |
108 s.Sseg = Segment.UDATA; | |
109 else | |
110 s.Sseg = Segment.DATA; | |
111 } | |
112 outdata(s); | |
113 if (isExport()) | |
114 obj_export(s,0); | |
115 } | |
116 | |
100 | 117 void toDt(dt_t** pdt) |
0 | 118 { |
119 assert(false); | |
120 } | |
72 | 121 } |