annotate dmd/InterfaceDeclaration.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.InterfaceDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 89
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.ClassDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.DsymbolTable;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.STC;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.TY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.LINK;
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 125
diff changeset
11 import dmd.Parameter;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.TypeTuple;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.PROT;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.TypeClass;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.ArrayTypes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.Global;
22
fd4acc376c45 Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
21 import dmd.Module;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 import dmd.BaseClass;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 import dmd.Id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 import dmd.backend.Symbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 import dmd.backend.TYM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 import dmd.backend.dt_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 import dmd.codegen.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 import dmd.backend.SC;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 import dmd.backend.FL;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 import dmd.backend.LIST;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 import dmd.backend.SFL;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
35 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
36
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 class InterfaceDeclaration : ClassDeclaration
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 {
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 178
diff changeset
39 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
40
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 bool cpp; // true if this is a C++ interface
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 this(Loc loc, Identifier id, BaseClasses baseclasses)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 176
diff changeset
46 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 super(loc, id, baseclasses);
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
48
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 if (id is Id.IUnknown) // IUnknown is the root of all COM interfaces
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 com = true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 cpp = true; // IUnknown is also a C++ interface
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 }
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
55
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
56 override Dsymbol syntaxCopy(Dsymbol s)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 {
123
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
58 InterfaceDeclaration id;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
59
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
60 if (s)
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
61 id = cast(InterfaceDeclaration)s;
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
62 else
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
63 id = new InterfaceDeclaration(loc, ident, null);
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
64
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
65 ClassDeclaration.syntaxCopy(id);
9e39c7de8438 Make dmd test suite compile
korDen
parents: 114
diff changeset
66 return id;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 }
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
68
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
69 override void semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 //printf("InterfaceDeclaration.semantic(%s), type = %p\n", toChars(), type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 if (inuse)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 if (!sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 sc = scope_;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 if (!parent && sc.parent && !sc.parent.isModule())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 parent = sc.parent;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 type = type.semantic(loc, sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 handle = type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 if (!members) // if forward reference
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
84 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 //printf("\tinterface '%s' is forward referenced\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 if (symtab) // if already done
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
89 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 if (!scope_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 symtab = new DsymbolTable();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 Scope scx = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 if (scope_)
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
98 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 sc = scope_;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 scx = scope_; // save so we don't make redundant copies
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 scope_ = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 if (sc.stc & STC.STCdeprecated)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 isdeprecated = true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 // Expand any tuples in baseclasses[]
89
37b95c347975 Fixed an obscure bug with i variable being reused
korDen
parents: 87
diff changeset
110 for (size_t i = 0; i < baseclasses.dim; )
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
111 {
125
767a01c2a272 BaseClasses -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 123
diff changeset
112 auto b = baseclasses[0];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 b.type = b.type.semantic(loc, sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 Type tb = b.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 if (tb.ty == TY.Ttuple)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 { TypeTuple tup = cast(TypeTuple)tb;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 PROT protection = b.protection;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 baseclasses.remove(i);
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 125
diff changeset
120 size_t dim = Parameter.dim(tup.arguments);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 for (size_t j = 0; j < dim; j++)
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 125
diff changeset
122 { auto arg = Parameter.getNth(tup.arguments, j);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 b = new BaseClass(arg.type, protection);
125
767a01c2a272 BaseClasses -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 123
diff changeset
124 baseclasses.insert(i + j, b);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 i++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 if (!baseclasses.dim && sc.linkage == LINK.LINKcpp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 cpp = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 // Check for errors, handle forward references
89
37b95c347975 Fixed an obscure bug with i variable being reused
korDen
parents: 87
diff changeset
135 for (size_t i = 0; i < baseclasses.dim; )
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
136 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 TypeClass tc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 BaseClass b;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 Type tb;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140
125
767a01c2a272 BaseClasses -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 123
diff changeset
141 b = baseclasses[i];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 b.type = b.type.semantic(loc, sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 tb = b.type.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 if (tb.ty == TY.Tclass)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 tc = cast(TypeClass)tb;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 tc = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 if (!tc || !tc.sym.isInterfaceDeclaration())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 error("base type must be interface, not %s", b.type.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 baseclasses.remove(i);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 continue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 // Check for duplicate interfaces
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 for (size_t j = 0; j < i; j++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 {
125
767a01c2a272 BaseClasses -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 123
diff changeset
159 auto b2 = baseclasses[j];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 if (b2.base is tc.sym)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 error("inherits from duplicate interface %s", b2.base.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 b.base = tc.sym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 if (b.base == this || isBaseOf2(b.base))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 error("circular inheritance of interface");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 baseclasses.remove(i);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 continue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 if (!b.base.symtab)
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
172 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 // Try to resolve forward reference
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 if (sc.mustsemantic && b.base.scope_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 b.base.semantic(null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 if (!b.base.symtab || b.base.scope_ || b.base.inuse)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 //error("forward reference of base class %s", baseClass.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 // Forward reference of base, try again later
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 //printf("\ttry later, forward reference of base %s\n", b.base.toChars());
87
b17640f0e4e8 Fixed a bug with a Scope.this(Scope enclosing) being called instead of Scope.clone() method (as a copy ctor replacement)
korDen
parents: 77
diff changeset
182 scope_ = scx ? scx : sc.clone();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 scope_.setNoFree();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 scope_.module_.addDeferredSemantic(this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 // Inherit const/invariant from base class
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 storage_class |= b.base.storage_class & STC.STC_TYPECTOR;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 i++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 interfaces_dim = baseclasses.dim;
125
767a01c2a272 BaseClasses -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 123
diff changeset
196 interfaces = baseclasses.ptr;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 interfaceSemantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 if (vtblOffset())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 vtbl.push(cast(void*)this); // leave room at vtbl[0] for classinfo
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 // Cat together the vtbl[]'s from base interfaces
89
37b95c347975 Fixed an obscure bug with i variable being reused
korDen
parents: 87
diff changeset
204 for (size_t i = 0; i < interfaces_dim; i++)
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
205 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 BaseClass b = interfaces[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 // Skip if b has already appeared
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 for (int k = 0; k < i; k++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 {
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 125
diff changeset
211 if (b == interfaces[k])
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 goto Lcontinue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 // Copy vtbl[] from base class
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 if (b.base.vtblOffset())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 { int d = b.base.vtbl.dim;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 if (d > 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 vtbl.reserve(d - 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 for (int j = 1; j < d; j++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 vtbl.push(b.base.vtbl.data[j]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 vtbl.append(b.base.vtbl);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 Lcontinue:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 ;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 protection = sc.protection;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 storage_class |= sc.stc & STC.STC_TYPECTOR;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236
77
ad4792a1cfd6 more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 72
diff changeset
237 foreach(Dsymbol s; members)
13
427f8aa74d28 On the road to make Phobos compilable
korDen
parents: 0
diff changeset
238 s.addMember(sc, this, true);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 sc = sc.push(this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 sc.stc &= ~(STC.STCfinal | STC.STCauto | STC.STCscope | STC.STCstatic |
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 STC.STCabstract | STC.STCdeprecated | STC.STC_TYPECTOR | STC.STCtls | STC.STCgshared);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 sc.stc |= storage_class & STC.STC_TYPECTOR;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 sc.parent = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 if (isCOMinterface())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 sc.linkage = LINK.LINKwindows;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 else if (isCPPinterface())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 sc.linkage = LINK.LINKcpp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 sc.structalign = 8;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 structalign = sc.structalign;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 sc.offset = PTRSIZE * 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 inuse++;
77
ad4792a1cfd6 more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 72
diff changeset
253 foreach(Dsymbol s; members)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 s.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 inuse--;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 //members.print();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 sc.pop();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 //printf("-InterfaceDeclaration.semantic(%s), type = %p\n", toChars(), type);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 }
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
260
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
261 override bool isBaseOf(ClassDeclaration cd, int* poffset)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 uint j;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 //printf("%s.InterfaceDeclaration.isBaseOf(cd = '%s')\n", toChars(), cd.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 assert(!baseClass);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 for (j = 0; j < cd.interfaces_dim; j++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 BaseClass b = cd.interfaces[j];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 //printf("\tbase %s\n", b.base.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 if (this == b.base)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 //printf("\tfound at offset %d\n", b.offset);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 if (poffset)
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
276 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 *poffset = b.offset;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278 if (j && cd.isInterfaceDeclaration())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279 *poffset = OFFSET_RUNTIME;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281 return true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 if (isBaseOf(b, poffset))
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
284 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 if (j && poffset && cd.isInterfaceDeclaration())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286 *poffset = OFFSET_RUNTIME;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 return true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
288 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
291 if (cd.baseClass && isBaseOf(cd.baseClass, poffset))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
292 return true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
293
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
294 if (poffset)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
295 *poffset = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
296 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
297 }
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
298
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
299 bool isBaseOf(BaseClass bc, int* poffset)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
300 {
64
4290d870944a More fixes
korDen
parents: 23
diff changeset
301 //printf("%s.InterfaceDeclaration.isBaseOf(bc = '%s')\n", toChars(), bc.base.toChars());
4290d870944a More fixes
korDen
parents: 23
diff changeset
302 for (uint j = 0; j < bc.baseInterfaces.length; j++)
4290d870944a More fixes
korDen
parents: 23
diff changeset
303 {
4290d870944a More fixes
korDen
parents: 23
diff changeset
304 BaseClass b = bc.baseInterfaces[j];
4290d870944a More fixes
korDen
parents: 23
diff changeset
305
4290d870944a More fixes
korDen
parents: 23
diff changeset
306 if (this == b.base)
4290d870944a More fixes
korDen
parents: 23
diff changeset
307 {
4290d870944a More fixes
korDen
parents: 23
diff changeset
308 if (poffset)
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
309 {
64
4290d870944a More fixes
korDen
parents: 23
diff changeset
310 *poffset = b.offset;
4290d870944a More fixes
korDen
parents: 23
diff changeset
311 if (j && bc.base.isInterfaceDeclaration())
4290d870944a More fixes
korDen
parents: 23
diff changeset
312 *poffset = OFFSET_RUNTIME;
4290d870944a More fixes
korDen
parents: 23
diff changeset
313 }
166
d8565fbd755c Moved object and classinfo from ClassDeclaration to Global (as part of getting rid of the global state)
korDen
parents: 130
diff changeset
314 return true;
64
4290d870944a More fixes
korDen
parents: 23
diff changeset
315 }
4290d870944a More fixes
korDen
parents: 23
diff changeset
316 if (isBaseOf(b, poffset))
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
317 {
64
4290d870944a More fixes
korDen
parents: 23
diff changeset
318 if (j && poffset && bc.base.isInterfaceDeclaration())
4290d870944a More fixes
korDen
parents: 23
diff changeset
319 *poffset = OFFSET_RUNTIME;
166
d8565fbd755c Moved object and classinfo from ClassDeclaration to Global (as part of getting rid of the global state)
korDen
parents: 130
diff changeset
320 return true;
64
4290d870944a More fixes
korDen
parents: 23
diff changeset
321 }
4290d870944a More fixes
korDen
parents: 23
diff changeset
322 }
4290d870944a More fixes
korDen
parents: 23
diff changeset
323 if (poffset)
4290d870944a More fixes
korDen
parents: 23
diff changeset
324 *poffset = 0;
166
d8565fbd755c Moved object and classinfo from ClassDeclaration to Global (as part of getting rid of the global state)
korDen
parents: 130
diff changeset
325 return false;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
326 }
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
327
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
328 override string kind()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
329 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
330 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
331 }
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
332
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
333 /****************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
334 * Determine if slot 0 of the vtbl[] is reserved for something else.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
335 * For class objects, yes, this is where the ClassInfo ptr goes.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
336 * For COM interfaces, no.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
337 * For non-COM interfaces, yes, this is where the Interface ptr goes.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
338 */
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
339 override int vtblOffset()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
340 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
341 if (isCOMinterface() || isCPPinterface())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
342 return 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
343 return 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
344 }
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
345
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
346 version (DMDV2) {
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
347 override bool isCPPinterface()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
348 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
349 return cpp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
350 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
351 }
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
352 override bool isCOMinterface()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
353 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
354 return com;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
355 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
356
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
357 override void toObjFile(int multiobj) // compile to .obj file
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
358 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
359 uint offset;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
360 Symbol* sinit;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
361 SC scclass;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
362
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
363 //printf("InterfaceDeclaration.toObjFile('%s')\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
364
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
365 if (!members)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
366 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
367
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
368 if (global.params.symdebug)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
369 toDebug();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
370
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
371 scclass = SCglobal;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
372 if (inTemplateInstance())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
373 scclass = SCcomdat;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
374
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
375 // Put out the members
77
ad4792a1cfd6 more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 72
diff changeset
376 foreach(Dsymbol member; members)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
377 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
378 if (!member.isFuncDeclaration())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
379 member.toObjFile(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
380 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
381
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
382 // Generate C symbols
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
383 toSymbol();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
384
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
385 //////////////////////////////////////////////
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
386
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
387 // Put out the TypeInfo
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
388 type.getTypeInfo(null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
389 type.vtinfo.toObjFile(multiobj);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
390
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
391 //////////////////////////////////////////////
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
392
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
393 // Put out the ClassInfo
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
394 csym.Sclass = scclass;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
395 csym.Sfl = FLdata;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
396
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
397 /* The layout is:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
398 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
399 void **vptr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
400 monitor_t monitor;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
401 byte[] initializer; // static initialization data
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
402 char[] name; // class name
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
403 void *[] vtbl;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
404 Interface[] interfaces;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
405 Object *base; // base class
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
406 void *destructor;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
407 void *invariant; // class invariant
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
408 uint flags;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
409 void *deallocator;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
410 OffsetTypeInfo[] offTi;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
411 void *defaultConstructor;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
412 #if DMDV2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
413 const(MemberInfo[]) function(string) xgetMembers; // module getMembers() function
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
414 #endif
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 125
diff changeset
415 //TypeInfo typeinfo;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
416 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
417 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
418 dt_t *dt = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
419
166
d8565fbd755c Moved object and classinfo from ClassDeclaration to Global (as part of getting rid of the global state)
korDen
parents: 130
diff changeset
420 if (global.classinfo)
d8565fbd755c Moved object and classinfo from ClassDeclaration to Global (as part of getting rid of the global state)
korDen
parents: 130
diff changeset
421 dtxoff(&dt, global.classinfo.toVtblSymbol(), 0, TYnptr); // vtbl for ClassInfo
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
422 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
423 dtdword(&dt, 0); // BUG: should be an assert()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
424 dtdword(&dt, 0); // monitor
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
425
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
426 // initializer[]
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
427 dtdword(&dt, 0); // size
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
428 dtdword(&dt, 0); // initializer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
429
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
430 // name[]
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
431 string name = toPrettyChars();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
432 size_t namelen = name.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
433 dtdword(&dt, namelen);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
434 dtabytes(&dt, TYnptr, 0, namelen + 1, toStringz(name));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
435
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
436 // vtbl[]
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
437 dtdword(&dt, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
438 dtdword(&dt, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
439
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
440 // vtblInterfaces.data[]
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
441 dtdword(&dt, vtblInterfaces.dim);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
442 if (vtblInterfaces.dim)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
443 {
166
d8565fbd755c Moved object and classinfo from ClassDeclaration to Global (as part of getting rid of the global state)
korDen
parents: 130
diff changeset
444 if (global.classinfo)
d8565fbd755c Moved object and classinfo from ClassDeclaration to Global (as part of getting rid of the global state)
korDen
parents: 130
diff changeset
445 assert(global.classinfo.structsize == CLASSINFO_SIZE);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
446 offset = CLASSINFO_SIZE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
447 dtxoff(&dt, csym, offset, TYnptr); // (*)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
448 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
449 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
450 dtdword(&dt, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
451
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
452 // base
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
453 assert(!baseClass);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
454 dtdword(&dt, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
455
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
456 // dtor
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
457 dtdword(&dt, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
458
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
459 // invariant
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
460 dtdword(&dt, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
461
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
462 // flags
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
463 dtdword(&dt, 4 | isCOMinterface() | 32);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
464
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
465 // deallocator
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
466 dtdword(&dt, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
467
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
468 // offTi[]
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
469 dtdword(&dt, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
470 dtdword(&dt, 0); // null for now, fix later
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
471
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
472 // defaultConstructor
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
473 dtdword(&dt, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
474
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
475 version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
476 // xgetMembers
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
477 dtdword(&dt, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
478 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
479
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 125
diff changeset
480 //dtxoff(&dt, type.vtinfo.toSymbol(), 0, TYnptr); // typeinfo
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
481
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
482 //////////////////////////////////////////////
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
483
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
484 // Put out vtblInterfaces.data[]. Must immediately follow csym, because
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
485 // of the fixup (*)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
486
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
487 offset += vtblInterfaces.dim * (4 * PTRSIZE);
125
767a01c2a272 BaseClasses -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 123
diff changeset
488 foreach (b; vtblInterfaces)
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
489 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
490 ClassDeclaration id = b.base;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
491
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
492 // ClassInfo
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
493 dtxoff(&dt, id.toSymbol(), 0, TYnptr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
494
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
495 // vtbl[]
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
496 dtdword(&dt, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
497 dtdword(&dt, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
498
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
499 // this offset
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
500 dtdword(&dt, b.offset);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
501 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
502
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
503 csym.Sdt = dt;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
504 version (ELFOBJ) {
22
fd4acc376c45 Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
505 csym.Sseg = Segment.CDATA;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
506 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
507 version (MACHOBJ) {
22
fd4acc376c45 Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
508 csym.Sseg = Segment.DATA;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
509 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
510 outdata(csym);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
511 if (isExport())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
512 obj_export(csym,0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
513 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
514
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
515 /*************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
516 * Create the "InterfaceInfo" symbol
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
517 */
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
518 override Symbol* toSymbol()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
519 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
520 if (!csym)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
521 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
522 Symbol *s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
523
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 166
diff changeset
524 s = toSymbolX("__Interface", SCextern, global.scc.Stype, "Z");
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
525 s.Sfl = FLextern;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
526 s.Sflags |= SFLnodebug;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
527 csym = s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
528 slist_add(s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
529 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
530 return csym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
531 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
532
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 64
diff changeset
533 override InterfaceDeclaration isInterfaceDeclaration() { return this; }
22
fd4acc376c45 Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
534 }