annotate dmd/TypeTypedef.d @ 64:4290d870944a

More fixes
author korDen
date Mon, 23 Aug 2010 20:29:15 +0400
parents cab4c37afb89
children f708f0452e81
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.TypeTypedef;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
3 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.TypedefDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.MOD;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.Id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.Expression;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.ArrayTypes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.MATCH;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.TypeSArray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.CppMangleState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.TypeInfoDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.TypeInfoTypedefDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.TY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 import dmd.backend.TYPE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 import dmd.backend.dt_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 class TypeTypedef : Type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 TypedefDeclaration sym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 this(TypedefDeclaration sym)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 super(Ttypedef);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 this.sym = sym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 version (DumbClone) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 Type clone()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 Type syntaxCopy()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 ulong size(Loc loc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 return sym.basetype.size(loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 uint alignsize()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 string toChars()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 Type semantic(Loc loc, Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 //printf("TypeTypedef::semantic(%s), sem = %d\n", toChars(), sym->sem);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 sym.semantic(sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 return merge();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 Dsymbol toDsymbol(Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 return sym;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 void toDecoBuffer(OutBuffer buf, int flag)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 Type.toDecoBuffer(buf, flag);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 string name = sym.mangle();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 buf.printf("%s", name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 Expression dotExp(Scope sc, Expression e, Identifier ident)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 version (LOGDOTEXP) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 printf("TypeTypedef.dotExp(e = '%s', ident = '%s') '%s'\n", e.toChars(), ident.toChars(), toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 if (ident is Id.init_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 return Type.dotExp(sc, e, ident);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 return sym.basetype.dotExp(sc, e, ident);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 Expression getProperty(Loc loc, Identifier ident)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 {
64
4290d870944a More fixes
korDen
parents: 63
diff changeset
101 version (LOGDOTEXP) {
4290d870944a More fixes
korDen
parents: 63
diff changeset
102 printf("TypeTypedef.getProperty(ident = '%s') '%s'\n", ident.toChars(), toChars());
4290d870944a More fixes
korDen
parents: 63
diff changeset
103 }
4290d870944a More fixes
korDen
parents: 63
diff changeset
104 if (ident == Id.init_)
4290d870944a More fixes
korDen
parents: 63
diff changeset
105 {
4290d870944a More fixes
korDen
parents: 63
diff changeset
106 return Type.getProperty(loc, ident);
4290d870944a More fixes
korDen
parents: 63
diff changeset
107 }
4290d870944a More fixes
korDen
parents: 63
diff changeset
108 return sym.basetype.getProperty(loc, ident);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 bool isbit()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 bool isintegral()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 //printf("TypeTypedef::isintegral()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 //printf("sym = '%s'\n", sym->toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 //printf("basetype = '%s'\n", sym->basetype->toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 return sym.basetype.isintegral();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 bool isfloating()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 return sym.basetype.isfloating();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 bool isreal()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 return sym.basetype.isreal();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 bool isimaginary()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 return sym.basetype.isimaginary();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 bool iscomplex()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 return sym.basetype.iscomplex();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 bool isscalar()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 return sym.basetype.isscalar();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 bool isunsigned()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 return sym.basetype.isunsigned();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 bool checkBoolean()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 {
64
4290d870944a More fixes
korDen
parents: 63
diff changeset
156 return sym.basetype.checkBoolean();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 int isAssignable()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 return sym.basetype.isAssignable();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 Type toBasetype()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 if (sym.inuse)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 sym.error("circular definition");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 sym.basetype = Type.terror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 return Type.terror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 sym.inuse = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 Type t = sym.basetype.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 sym.inuse = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 t = t.addMod(mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 MATCH implicitConvTo(Type to)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 MATCH m;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 //printf("TypeTypedef::implicitConvTo(to = %s) %s\n", to->toChars(), toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 if (equals(to))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 m = MATCHexact; // exact match
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 else if (sym.basetype.implicitConvTo(to))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 m = MATCHconvert; // match with conversions
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 else if (ty == to.ty && sym == (cast(TypeTypedef)to).sym)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 m = constConv(to);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 m = MATCHnomatch; // no match
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 return m;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 MATCH constConv(Type to)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 {
53
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 0
diff changeset
199 if (equals(to))
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 0
diff changeset
200 return MATCHexact;
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 0
diff changeset
201 if (ty == to.ty && sym == (cast(TypeTypedef)to).sym)
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 0
diff changeset
202 return sym.basetype.implicitConvTo((cast(TypeTypedef)to).sym.basetype);
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 0
diff changeset
203 return MATCHnomatch;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 Expression defaultInit(Loc loc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 Type bt;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 version (LOGDEFAULTINIT) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 printf("TypeTypedef::defaultInit() '%s'\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 if (sym.init)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 //sym->init->toExpression()->print();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 return sym.init.toExpression();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 bt = sym.basetype;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 e = bt.defaultInit(loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 e.type = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 while (bt.ty == Tsarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 TypeSArray tsa = cast(TypeSArray)bt;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 e.type = tsa.next;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 bt = tsa.next.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 bool isZeroInit(Loc loc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 if (sym.init)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 if (sym.init.isVoidInitializer())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 return true; // initialize voids to 0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 Expression e = sym.init.toExpression();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 if (e && e.isBool(false))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 return true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 return false; // assume not
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 if (sym.inuse)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 sym.error("circular definition");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 sym.basetype = Type.terror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 sym.inuse = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 bool result = sym.basetype.isZeroInit(loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 sym.inuse = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 return result;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 dt_t** toDt(dt_t** pdt)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 if (sym.init)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 dt_t* dt = sym.init.toDt();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 while (*pdt)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 pdt = &((*pdt).DTnext);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 *pdt = dt;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 return pdt;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 sym.basetype.toDt(pdt);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 return pdt;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 MATCH deduceType(Scope sc, Type tparam, TemplateParameters parameters, Objects dedtypes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 {
63
cab4c37afb89 A bunch of implementations
korDen
parents: 53
diff changeset
273 // Extra check
cab4c37afb89 A bunch of implementations
korDen
parents: 53
diff changeset
274 if (tparam && tparam.ty == Ttypedef)
cab4c37afb89 A bunch of implementations
korDen
parents: 53
diff changeset
275 {
cab4c37afb89 A bunch of implementations
korDen
parents: 53
diff changeset
276 TypeTypedef tp = cast(TypeTypedef)tparam;
cab4c37afb89 A bunch of implementations
korDen
parents: 53
diff changeset
277
cab4c37afb89 A bunch of implementations
korDen
parents: 53
diff changeset
278 if (sym != tp.sym)
cab4c37afb89 A bunch of implementations
korDen
parents: 53
diff changeset
279 return MATCHnomatch;
cab4c37afb89 A bunch of implementations
korDen
parents: 53
diff changeset
280 }
cab4c37afb89 A bunch of implementations
korDen
parents: 53
diff changeset
281 return Type.deduceType(sc, tparam, parameters, dedtypes);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284 TypeInfoDeclaration getTypeInfoDeclaration()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286 return new TypeInfoTypedefDeclaration(this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
288
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289 bool hasPointers()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
291 return toBasetype().hasPointers();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
292 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
293
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
294 Type toHeadMutable()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
295 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
296 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
297 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
298
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
299 version (CPP_MANGLE) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
300 void toCppMangle(OutBuffer buf, CppMangleState* cms)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
301 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
302 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
303 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
304 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
305
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
306 type* toCtype()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
307 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
308 return sym.basetype.toCtype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
309 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
310
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
311 type* toCParamtype()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
312 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
313 return sym.basetype.toCParamtype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
315 }