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
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
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 100
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.VarDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
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
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.STC;
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
11 import dmd.Global;
79
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
12 import dmd.OutBuffer;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.PROT;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.LINK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.backend.Symbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.backend.dt_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.backend.DT;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.backend.SC;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.backend.FL;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import dmd.backend.glue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 import dmd.backend.TYPE;
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
24
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 import core.stdc.stdio;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 class TypeInfoDeclaration : VarDeclaration
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 {
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
29 Type tinfo;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
31 this(Type tinfo, int internal)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 {
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
33 super(Loc(0), global.typeinfo.type, tinfo.getTypeInfoIdent(internal), null);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 this.tinfo = tinfo;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 storage_class = STC.STCstatic | STC.STCgshared;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 protection = PROT.PROTpublic;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 linkage = LINK.LINKc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 }
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
39
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 version (DumbClone) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 Type clone()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 }
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
47 override Dsymbol syntaxCopy(Dsymbol)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 {
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
49 assert(false); // should never be produced by syntax
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
50 return null;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
53 override void semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 {
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
55 assert(linkage == LINKc);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
58 override void emitComment(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
62 override Symbol* toSymbol()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 //printf("TypeInfoDeclaration::toSymbol(%s), linkage = %d\n", toChars(), linkage);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 return VarDeclaration.toSymbol();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67
79
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
68 override void toJsonBuffer(OutBuffer buf)
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
69 {
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
70 }
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
71
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
72 override void toObjFile(int multiobj) // compile to .obj file
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 Symbol* s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 uint sz;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 Dsymbol parent;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 //printf("TypeInfoDeclaration.toObjFile(%p '%s') protection %d\n", this, toChars(), protection);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 if (multiobj)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 obj_append(this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 s = toSymbol();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 sz = cast(uint)type.size();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 parent = this.toParent();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 s.Sclass = SC.SCcomdat;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 s.Sfl = FL.FLdata;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 toDt(&s.Sdt);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 dt_optimize(s.Sdt);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 // See if we can convert a comdat to a comdef,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 // which saves on exe file space.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 if (s.Sclass == SC.SCcomdat &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 s.Sdt.dt == DT.DT_azeros &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 s.Sdt.DTnext == null)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 s.Sclass = SC.SCglobal;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 s.Sdt.dt = DT.DT_common;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
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
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 if (s.Sdt && s.Sdt.dt == DT_azeros && s.Sdt.DTnext == null)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 s.Sseg = Segment.UDATA;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 s.Sseg = Segment.DATA;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 outdata(s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 if (isExport())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 obj_export(s,0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
118 void toDt(dt_t** pdt)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
122 }