annotate dmd/TypeInfoDeclaration.d @ 114:e28b18c23469

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