annotate dmd/TypeTypedef.d @ 72:2e2a5c3f943a

reduced warnings by adding override to the methods think this also normalizes different line endings used all over the place
author Trass3r
date Sat, 28 Aug 2010 16:19:48 +0200
parents f708f0452e81
children ef02e2e203c2
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
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
43 override Type syntaxCopy()
0
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
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
48 override ulong size(Loc loc)
0
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
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
53 override uint alignsize()
0
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
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
58 override string toChars()
0
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
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
63 override Type semantic(Loc loc, Scope sc)
0
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
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
70 override Dsymbol toDsymbol(Scope sc)
0
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
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
75 override void toDecoBuffer(OutBuffer buf, int flag)
0
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
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
82 override void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 {
67
f708f0452e81 some of the backend/codegen stuff implemented
korDen
parents: 64
diff changeset
84 //printf("TypeTypedef.toCBuffer2() '%s'\n", sym.toChars());
f708f0452e81 some of the backend/codegen stuff implemented
korDen
parents: 64
diff changeset
85 if (mod != this.mod)
f708f0452e81 some of the backend/codegen stuff implemented
korDen
parents: 64
diff changeset
86 {
f708f0452e81 some of the backend/codegen stuff implemented
korDen
parents: 64
diff changeset
87 toCBuffer3(buf, hgs, mod);
f708f0452e81 some of the backend/codegen stuff implemented
korDen
parents: 64
diff changeset
88 return;
f708f0452e81 some of the backend/codegen stuff implemented
korDen
parents: 64
diff changeset
89 }
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 buf.writestring(sym.toChars());
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
94 override Expression dotExp(Scope sc, Expression e, Identifier ident)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 version (LOGDOTEXP) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 printf("TypeTypedef.dotExp(e = '%s', ident = '%s') '%s'\n", e.toChars(), ident.toChars(), toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 if (ident is Id.init_)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 return Type.dotExp(sc, e, ident);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 return sym.basetype.dotExp(sc, e, ident);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
106 override Expression getProperty(Loc loc, Identifier ident)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 {
64
4290d870944a More fixes
korDen
parents: 63
diff changeset
108 version (LOGDOTEXP) {
4290d870944a More fixes
korDen
parents: 63
diff changeset
109 printf("TypeTypedef.getProperty(ident = '%s') '%s'\n", ident.toChars(), toChars());
4290d870944a More fixes
korDen
parents: 63
diff changeset
110 }
4290d870944a More fixes
korDen
parents: 63
diff changeset
111 if (ident == Id.init_)
4290d870944a More fixes
korDen
parents: 63
diff changeset
112 {
4290d870944a More fixes
korDen
parents: 63
diff changeset
113 return Type.getProperty(loc, ident);
4290d870944a More fixes
korDen
parents: 63
diff changeset
114 }
4290d870944a More fixes
korDen
parents: 63
diff changeset
115 return sym.basetype.getProperty(loc, ident);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 bool isbit()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
123 override bool isintegral()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 //printf("TypeTypedef::isintegral()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 //printf("sym = '%s'\n", sym->toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 //printf("basetype = '%s'\n", sym->basetype->toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 return sym.basetype.isintegral();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
131 override bool isfloating()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 return sym.basetype.isfloating();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
136 override bool isreal()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 return sym.basetype.isreal();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
141 override bool isimaginary()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 return sym.basetype.isimaginary();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
146 override bool iscomplex()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 return sym.basetype.iscomplex();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
151 override bool isscalar()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 return sym.basetype.isscalar();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
156 override bool isunsigned()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 return sym.basetype.isunsigned();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
161 override bool checkBoolean()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 {
64
4290d870944a More fixes
korDen
parents: 63
diff changeset
163 return sym.basetype.checkBoolean();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
166 override int isAssignable()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 return sym.basetype.isAssignable();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
171 override Type toBasetype()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 if (sym.inuse)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 sym.error("circular definition");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 sym.basetype = Type.terror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 return Type.terror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 sym.inuse = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 Type t = sym.basetype.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 sym.inuse = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 t = t.addMod(mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
186 override MATCH implicitConvTo(Type to)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 MATCH m;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 //printf("TypeTypedef::implicitConvTo(to = %s) %s\n", to->toChars(), toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 if (equals(to))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 m = MATCHexact; // exact match
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 else if (sym.basetype.implicitConvTo(to))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 m = MATCHconvert; // match with conversions
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 else if (ty == to.ty && sym == (cast(TypeTypedef)to).sym)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 m = constConv(to);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 m = MATCHnomatch; // no match
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 return m;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
204 override MATCH constConv(Type to)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 {
53
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 0
diff changeset
206 if (equals(to))
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 0
diff changeset
207 return MATCHexact;
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 0
diff changeset
208 if (ty == to.ty && sym == (cast(TypeTypedef)to).sym)
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 0
diff changeset
209 return sym.basetype.implicitConvTo((cast(TypeTypedef)to).sym.basetype);
a8b50ff7f201 ForeachStatement.syntaxCopy
korDen
parents: 0
diff changeset
210 return MATCHnomatch;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
213 override Expression defaultInit(Loc loc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 Type bt;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 version (LOGDEFAULTINIT) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 printf("TypeTypedef::defaultInit() '%s'\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 if (sym.init)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 //sym->init->toExpression()->print();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 return sym.init.toExpression();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 bt = sym.basetype;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 e = bt.defaultInit(loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 e.type = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 while (bt.ty == Tsarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 TypeSArray tsa = cast(TypeSArray)bt;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 e.type = tsa.next;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 bt = tsa.next.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
238 override bool isZeroInit(Loc loc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 if (sym.init)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 if (sym.init.isVoidInitializer())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 return true; // initialize voids to 0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 Expression e = sym.init.toExpression();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 if (e && e.isBool(false))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 return true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 return false; // assume not
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 if (sym.inuse)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 sym.error("circular definition");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 sym.basetype = Type.terror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 sym.inuse = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 bool result = sym.basetype.isZeroInit(loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 sym.inuse = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 return result;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
262 override dt_t** toDt(dt_t** pdt)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 if (sym.init)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 dt_t* dt = sym.init.toDt();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 while (*pdt)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 pdt = &((*pdt).DTnext);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 *pdt = dt;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 return pdt;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 sym.basetype.toDt(pdt);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 return pdt;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
278 override MATCH deduceType(Scope sc, Type tparam, TemplateParameters parameters, Objects dedtypes)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279 {
63
cab4c37afb89 A bunch of implementations
korDen
parents: 53
diff changeset
280 // Extra check
cab4c37afb89 A bunch of implementations
korDen
parents: 53
diff changeset
281 if (tparam && tparam.ty == Ttypedef)
cab4c37afb89 A bunch of implementations
korDen
parents: 53
diff changeset
282 {
cab4c37afb89 A bunch of implementations
korDen
parents: 53
diff changeset
283 TypeTypedef tp = cast(TypeTypedef)tparam;
cab4c37afb89 A bunch of implementations
korDen
parents: 53
diff changeset
284
cab4c37afb89 A bunch of implementations
korDen
parents: 53
diff changeset
285 if (sym != tp.sym)
cab4c37afb89 A bunch of implementations
korDen
parents: 53
diff changeset
286 return MATCHnomatch;
cab4c37afb89 A bunch of implementations
korDen
parents: 53
diff changeset
287 }
cab4c37afb89 A bunch of implementations
korDen
parents: 53
diff changeset
288 return Type.deduceType(sc, tparam, parameters, dedtypes);
0
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 TypeInfoDeclaration getTypeInfoDeclaration()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
292 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
293 return new TypeInfoTypedefDeclaration(this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
294 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
295
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 67
diff changeset
296 override bool hasPointers()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
297 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
298 return toBasetype().hasPointers();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
299 }
10317f0c89a5 Initial commit
korDen
parents:
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 }