annotate dmd/TypeInfoDeclaration.d @ 187:b0d41ff5e0df

Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
author Abscissa
date Tue, 07 Jun 2011 23:37:34 -0400
parents e3afd1303184
children
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
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
27 import dmd.DDMDExtensions;
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
28
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 class TypeInfoDeclaration : VarDeclaration
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 {
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
31 mixin insertMemberExtension!(typeof(this));
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
32
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
33 Type tinfo;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
35 this(Type tinfo, int internal)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 174
diff changeset
37 register();
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
38 super(Loc(0), global.typeinfo.type, tinfo.getTypeInfoIdent(internal), null);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 this.tinfo = tinfo;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 storage_class = STC.STCstatic | STC.STCgshared;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 protection = PROT.PROTpublic;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 linkage = LINK.LINKc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 }
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
44
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
45 override Dsymbol syntaxCopy(Dsymbol)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 {
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
47 assert(false); // should never be produced by syntax
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
48 return null;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
51 override void semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 {
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
53 assert(linkage == LINKc);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
56 override void emitComment(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
60 override Symbol* toSymbol()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 //printf("TypeInfoDeclaration::toSymbol(%s), linkage = %d\n", toChars(), linkage);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 return VarDeclaration.toSymbol();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65
79
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
66 override void toJsonBuffer(OutBuffer buf)
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
67 {
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
68 }
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
69
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
70 override void toObjFile(int multiobj) // compile to .obj file
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 Symbol* s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 uint sz;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 Dsymbol parent;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 //printf("TypeInfoDeclaration.toObjFile(%p '%s') protection %d\n", this, toChars(), protection);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 if (multiobj)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 obj_append(this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 s = toSymbol();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 sz = cast(uint)type.size();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 parent = this.toParent();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 s.Sclass = SC.SCcomdat;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 s.Sfl = FL.FLdata;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 toDt(&s.Sdt);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 dt_optimize(s.Sdt);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 // See if we can convert a comdat to a comdef,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 // which saves on exe file space.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 if (s.Sclass == SC.SCcomdat &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 s.Sdt.dt == DT.DT_azeros &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 s.Sdt.DTnext == null)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 s.Sclass = SC.SCglobal;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 s.Sdt.dt = DT.DT_common;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104
22
fd4acc376c45 Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
105 version (ELFOBJ_OR_MACHOBJ) { ///ELFOBJ || MACHOBJ // Burton
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 if (s.Sdt && s.Sdt.dt == DT_azeros && s.Sdt.DTnext == null)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 s.Sseg = Segment.UDATA;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 s.Sseg = Segment.DATA;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 outdata(s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 if (isExport())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 obj_export(s,0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
116 void toDt(dt_t** pdt)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
120 }