annotate dmd/TypeTypedef.d @ 182:b64060ab22df

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