annotate dmd/TypeInfoDeclaration.d @ 178:e3afd1303184

Many small bugs fixed Made all classes derive from TObject to detect memory leaks (functionality is disabled for now) Began work on overriding backend memory allocations (to avoid memory leaks)
author korDen
date Sun, 17 Oct 2010 07:42:00 +0400
parents af724d3510d7
children b0d41ff5e0df
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 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 174
diff changeset
33 register();
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
34 super(Loc(0), global.typeinfo.type, tinfo.getTypeInfoIdent(internal), null);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 this.tinfo = tinfo;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 storage_class = STC.STCstatic | STC.STCgshared;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 protection = PROT.PROTpublic;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 linkage = LINK.LINKc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 }
174
af724d3510d7 lot os toCBuffer methods implemented
korDen
parents: 114
diff changeset
40
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
41 override Dsymbol syntaxCopy(Dsymbol)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 {
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
43 assert(false); // should never be produced by syntax
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
44 return null;
0
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 void semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 {
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
49 assert(linkage == LINKc);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
52 override void emitComment(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 {
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 Symbol* toSymbol()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 //printf("TypeInfoDeclaration::toSymbol(%s), linkage = %d\n", toChars(), linkage);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 return VarDeclaration.toSymbol();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61
79
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
62 override void toJsonBuffer(OutBuffer buf)
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
63 {
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
64 }
43073c7c7769 updated to 2.035
Trass3r
parents: 72
diff changeset
65
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
66 override void toObjFile(int multiobj) // compile to .obj file
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 Symbol* s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 uint sz;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 Dsymbol parent;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 //printf("TypeInfoDeclaration.toObjFile(%p '%s') protection %d\n", this, toChars(), protection);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 if (multiobj)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 obj_append(this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 s = toSymbol();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 sz = cast(uint)type.size();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 parent = this.toParent();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 s.Sclass = SC.SCcomdat;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 s.Sfl = FL.FLdata;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 toDt(&s.Sdt);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 dt_optimize(s.Sdt);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 // See if we can convert a comdat to a comdef,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 // which saves on exe file space.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 if (s.Sclass == SC.SCcomdat &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 s.Sdt.dt == DT.DT_azeros &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 s.Sdt.DTnext == null)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 s.Sclass = SC.SCglobal;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 s.Sdt.dt = DT.DT_common;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100
22
fd4acc376c45 Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
101 version (ELFOBJ_OR_MACHOBJ) { ///ELFOBJ || MACHOBJ // Burton
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 if (s.Sdt && s.Sdt.dt == DT_azeros && s.Sdt.DTnext == null)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 s.Sseg = Segment.UDATA;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 s.Sseg = Segment.DATA;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 outdata(s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 if (isExport())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 obj_export(s,0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111
100
8e1e220cebb3 implemented missing methods
Trass3r
parents: 79
diff changeset
112 void toDt(dt_t** pdt)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 22
diff changeset
116 }