annotate dmd/TypeInfoDeclaration.d @ 0:10317f0c89a5

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