comparison dmd/TypeInfoDeclaration.d @ 0:10317f0c89a5

Initial commit
author korDen
date Sat, 24 Oct 2009 08:42:06 +0400
parents
children fd4acc376c45
comparison
equal deleted inserted replaced
-1:000000000000 0:10317f0c89a5
1 module dmd.TypeInfoDeclaration;
2
3 import dmd.VarDeclaration;
4 import dmd.Type;
5 import dmd.Dsymbol;
6 import dmd.Scope;
7 import dmd.Loc;
8 import dmd.STC;
9 import dmd.PROT;
10 import dmd.LINK;
11
12 import dmd.backend.Symbol;
13 import dmd.backend.dt_t;
14 import dmd.backend.DT;
15 import dmd.backend.SC;
16 import dmd.backend.FL;
17 import dmd.backend.glue;
18 import dmd.backend.Util;
19 import dmd.backend.TYPE;
20
21 import core.stdc.stdio;
22
23 class TypeInfoDeclaration : VarDeclaration
24 {
25 Type tinfo;
26
27 this(Type tinfo, int internal)
28 {
29 super(Loc(0), Type.typeinfo.type, tinfo.getTypeInfoIdent(internal), null);
30 this.tinfo = tinfo;
31 storage_class = STC.STCstatic | STC.STCgshared;
32 protection = PROT.PROTpublic;
33 linkage = LINK.LINKc;
34 }
35
36 version (DumbClone) {
37 } else {
38 Type clone()
39 {
40 assert(false);
41 }
42 }
43 Dsymbol syntaxCopy(Dsymbol)
44 {
45 assert(false);
46 }
47
48 void semantic(Scope sc)
49 {
50 assert(false);
51 }
52
53 void emitComment(Scope sc)
54 {
55 assert(false);
56 }
57
58 Symbol* toSymbol()
59 {
60 //printf("TypeInfoDeclaration::toSymbol(%s), linkage = %d\n", toChars(), linkage);
61 return VarDeclaration.toSymbol();
62 }
63
64 void toObjFile(int multiobj) // compile to .obj file
65 {
66 Symbol* s;
67 uint sz;
68 Dsymbol parent;
69
70 //printf("TypeInfoDeclaration.toObjFile(%p '%s') protection %d\n", this, toChars(), protection);
71
72 if (multiobj)
73 {
74 obj_append(this);
75 return;
76 }
77
78 s = toSymbol();
79 sz = cast(uint)type.size();
80
81 parent = this.toParent();
82 s.Sclass = SC.SCcomdat;
83 s.Sfl = FL.FLdata;
84
85 toDt(&s.Sdt);
86
87 dt_optimize(s.Sdt);
88
89 // See if we can convert a comdat to a comdef,
90 // which saves on exe file space.
91 if (s.Sclass == SC.SCcomdat &&
92 s.Sdt.dt == DT.DT_azeros &&
93 s.Sdt.DTnext == null)
94 {
95 s.Sclass = SC.SCglobal;
96 s.Sdt.dt = DT.DT_common;
97 }
98
99 version (XXX) { ///ELFOBJ || MACHOBJ // Burton
100 if (s.Sdt && s.Sdt.dt == DT_azeros && s.Sdt.DTnext == null)
101 s.Sseg = Segment.UDATA;
102 else
103 s.Sseg = Segment.DATA;
104 }
105 outdata(s);
106 if (isExport())
107 obj_export(s,0);
108 }
109
110 void toDt(dt_t** pdt)
111 {
112 assert(false);
113 }
114 }