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