Mercurial > projects > ddmd
comparison dmd/AssocArrayLiteralExp.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 | ee3a9f34dc48 |
children | be2ab491772e |
comparison
equal
deleted
inserted
replaced
71:8e24ef1dd139 | 72:2e2a5c3f943a |
---|---|
39 assert(keys.dim == values.dim); | 39 assert(keys.dim == values.dim); |
40 this.keys = keys; | 40 this.keys = keys; |
41 this.values = values; | 41 this.values = values; |
42 } | 42 } |
43 | 43 |
44 Expression syntaxCopy() | 44 override Expression syntaxCopy() |
45 { | 45 { |
46 return new AssocArrayLiteralExp(loc, | 46 return new AssocArrayLiteralExp(loc, |
47 arraySyntaxCopy(keys), arraySyntaxCopy(values)); | 47 arraySyntaxCopy(keys), arraySyntaxCopy(values)); |
48 } | 48 } |
49 | 49 |
50 Expression semantic(Scope sc) | 50 override Expression semantic(Scope sc) |
51 { | 51 { |
52 Expression e; | 52 Expression e; |
53 Type tkey = null; | 53 Type tkey = null; |
54 Type tvalue = null; | 54 Type tvalue = null; |
55 | 55 |
107 type = new TypeAArray(tvalue, tkey); | 107 type = new TypeAArray(tvalue, tkey); |
108 type = type.semantic(loc, sc); | 108 type = type.semantic(loc, sc); |
109 return this; | 109 return this; |
110 } | 110 } |
111 | 111 |
112 bool isBool(bool result) | 112 override bool isBool(bool result) |
113 { | 113 { |
114 size_t dim = keys.dim; | 114 size_t dim = keys.dim; |
115 return result ? (dim != 0) : (dim == 0); | 115 return result ? (dim != 0) : (dim == 0); |
116 } | 116 } |
117 | 117 |
118 elem* toElem(IRState* irs) | 118 override elem* toElem(IRState* irs) |
119 { | 119 { |
120 elem* e; | 120 elem* e; |
121 size_t dim; | 121 size_t dim; |
122 | 122 |
123 //printf("AssocArrayLiteralExp.toElem() %s\n", toChars()); | 123 //printf("AssocArrayLiteralExp.toElem() %s\n", toChars()); |
168 | 168 |
169 el_setLoc(e,loc); | 169 el_setLoc(e,loc); |
170 return e; | 170 return e; |
171 } | 171 } |
172 | 172 |
173 bool checkSideEffect(int flag) | 173 override bool checkSideEffect(int flag) |
174 { | 174 { |
175 bool f = false; | 175 bool f = false; |
176 | 176 |
177 for (size_t i = 0; i < keys.dim; i++) | 177 for (size_t i = 0; i < keys.dim; i++) |
178 { Expression key = cast(Expression)keys.data[i]; | 178 { Expression key = cast(Expression)keys.data[i]; |
184 if (flag == 0 && f == 0) | 184 if (flag == 0 && f == 0) |
185 Expression.checkSideEffect(0); | 185 Expression.checkSideEffect(0); |
186 return f; | 186 return f; |
187 } | 187 } |
188 | 188 |
189 void toCBuffer(OutBuffer buf, HdrGenState* hgs) | 189 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
190 { | 190 { |
191 buf.writeByte('['); | 191 buf.writeByte('['); |
192 for (size_t i = 0; i < keys.dim; i++) | 192 for (size_t i = 0; i < keys.dim; i++) |
193 { Expression key = cast(Expression)keys.data[i]; | 193 { Expression key = cast(Expression)keys.data[i]; |
194 Expression value = cast(Expression)values.data[i]; | 194 Expression value = cast(Expression)values.data[i]; |
200 expToCBuffer(buf, hgs, value, PREC.PREC_assign); | 200 expToCBuffer(buf, hgs, value, PREC.PREC_assign); |
201 } | 201 } |
202 buf.writeByte(']'); | 202 buf.writeByte(']'); |
203 } | 203 } |
204 | 204 |
205 void toMangleBuffer(OutBuffer buf) | 205 override void toMangleBuffer(OutBuffer buf) |
206 { | 206 { |
207 size_t dim = keys.dim; | 207 size_t dim = keys.dim; |
208 buf.printf("A%u", dim); | 208 buf.printf("A%u", dim); |
209 for (size_t i = 0; i < dim; i++) | 209 for (size_t i = 0; i < dim; i++) |
210 { Expression key = cast(Expression)keys.data[i]; | 210 { Expression key = cast(Expression)keys.data[i]; |
213 key.toMangleBuffer(buf); | 213 key.toMangleBuffer(buf); |
214 value.toMangleBuffer(buf); | 214 value.toMangleBuffer(buf); |
215 } | 215 } |
216 } | 216 } |
217 | 217 |
218 void scanForNestedRef(Scope sc) | 218 override void scanForNestedRef(Scope sc) |
219 { | 219 { |
220 assert(false); | 220 assert(false); |
221 } | 221 } |
222 | 222 |
223 Expression optimize(int result) | 223 override Expression optimize(int result) |
224 { | 224 { |
225 assert(keys.dim == values.dim); | 225 assert(keys.dim == values.dim); |
226 for (size_t i = 0; i < keys.dim; i++) | 226 for (size_t i = 0; i < keys.dim; i++) |
227 { | 227 { |
228 Expression e = cast(Expression)keys.data[i]; | 228 Expression e = cast(Expression)keys.data[i]; |
235 values.data[i] = cast(void*)e; | 235 values.data[i] = cast(void*)e; |
236 } | 236 } |
237 return this; | 237 return this; |
238 } | 238 } |
239 | 239 |
240 Expression interpret(InterState istate) | 240 override Expression interpret(InterState istate) |
241 { | 241 { |
242 Expressions keysx = keys; | 242 Expressions keysx = keys; |
243 Expressions valuesx = values; | 243 Expressions valuesx = values; |
244 | 244 |
245 version (LOG) { | 245 version (LOG) { |
327 if (valuesx != values) | 327 if (valuesx != values) |
328 delete values; | 328 delete values; |
329 return EXP_CANT_INTERPRET; | 329 return EXP_CANT_INTERPRET; |
330 } | 330 } |
331 | 331 |
332 MATCH implicitConvTo(Type t) | 332 override MATCH implicitConvTo(Type t) |
333 { | 333 { |
334 MATCH result = MATCHexact; | 334 MATCH result = MATCHexact; |
335 | 335 |
336 Type typeb = type.toBasetype(); | 336 Type typeb = type.toBasetype(); |
337 Type tb = t.toBasetype(); | 337 Type tb = t.toBasetype(); |
356 } | 356 } |
357 else | 357 else |
358 return Expression.implicitConvTo(t); | 358 return Expression.implicitConvTo(t); |
359 } | 359 } |
360 | 360 |
361 Expression castTo(Scope sc, Type t) | 361 override Expression castTo(Scope sc, Type t) |
362 { | 362 { |
363 if (type == t) | 363 if (type == t) |
364 return this; | 364 return this; |
365 AssocArrayLiteralExp e = this; | 365 AssocArrayLiteralExp e = this; |
366 Type typeb = type.toBasetype(); | 366 Type typeb = type.toBasetype(); |
386 } | 386 } |
387 L1: | 387 L1: |
388 return e.Expression.castTo(sc, t); | 388 return e.Expression.castTo(sc, t); |
389 } | 389 } |
390 | 390 |
391 bool canThrow() | 391 override bool canThrow() |
392 { | 392 { |
393 return true; | 393 return true; |
394 } | 394 } |
395 | 395 |
396 int inlineCost(InlineCostState* ics) | 396 override int inlineCost(InlineCostState* ics) |
397 { | 397 { |
398 assert(false); | 398 assert(false); |
399 } | 399 } |
400 | 400 |
401 Expression doInline(InlineDoState ids) | 401 override Expression doInline(InlineDoState ids) |
402 { | 402 { |
403 assert(false); | 403 assert(false); |
404 } | 404 } |
405 | 405 |
406 Expression inlineScan(InlineScanState* iss) | 406 override Expression inlineScan(InlineScanState* iss) |
407 { | 407 { |
408 assert(false); | 408 assert(false); |
409 } | 409 } |
410 } | 410 } |