annotate dmd/TypeTypedef.d @ 135:af1bebfd96a4 dmd2037

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