Mercurial > projects > ddmd
comparison dmd/SliceExp.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 | 4290d870944a |
children | be2ab491772e |
comparison
equal
deleted
inserted
replaced
71:8e24ef1dd139 | 72:2e2a5c3f943a |
---|---|
66 super(loc, TOK.TOKslice, SliceExp.sizeof, e1); | 66 super(loc, TOK.TOKslice, SliceExp.sizeof, e1); |
67 this.upr = upr; | 67 this.upr = upr; |
68 this.lwr = lwr; | 68 this.lwr = lwr; |
69 } | 69 } |
70 | 70 |
71 Expression syntaxCopy() | 71 override Expression syntaxCopy() |
72 { | 72 { |
73 Expression lwr = null; | 73 Expression lwr = null; |
74 if (this.lwr) | 74 if (this.lwr) |
75 lwr = this.lwr.syntaxCopy(); | 75 lwr = this.lwr.syntaxCopy(); |
76 | 76 |
79 upr = this.upr.syntaxCopy(); | 79 upr = this.upr.syntaxCopy(); |
80 | 80 |
81 return new SliceExp(loc, e1.syntaxCopy(), lwr, upr); | 81 return new SliceExp(loc, e1.syntaxCopy(), lwr, upr); |
82 } | 82 } |
83 | 83 |
84 Expression semantic(Scope sc) | 84 override Expression semantic(Scope sc) |
85 { | 85 { |
86 Expression e; | 86 Expression e; |
87 AggregateDeclaration ad; | 87 AggregateDeclaration ad; |
88 //FuncDeclaration fd; | 88 //FuncDeclaration fd; |
89 ScopeDsymbol sym; | 89 ScopeDsymbol sym; |
258 error("%s cannot be sliced with []", s); | 258 error("%s cannot be sliced with []", s); |
259 e = new ErrorExp(); | 259 e = new ErrorExp(); |
260 return e; | 260 return e; |
261 } | 261 } |
262 | 262 |
263 void checkEscape() | 263 override void checkEscape() |
264 { | 264 { |
265 e1.checkEscape(); | 265 e1.checkEscape(); |
266 } | 266 } |
267 | 267 |
268 version (DMDV2) { | 268 version (DMDV2) { |
269 int isLvalue() | 269 override int isLvalue() |
270 { | 270 { |
271 return 1; | 271 return 1; |
272 } | 272 } |
273 } | 273 } |
274 Expression toLvalue(Scope sc, Expression e) | 274 override Expression toLvalue(Scope sc, Expression e) |
275 { | 275 { |
276 return this; | 276 return this; |
277 } | 277 } |
278 | 278 |
279 Expression modifiableLvalue(Scope sc, Expression e) | 279 override Expression modifiableLvalue(Scope sc, Expression e) |
280 { | 280 { |
281 error("slice expression %s is not a modifiable lvalue", toChars()); | 281 error("slice expression %s is not a modifiable lvalue", toChars()); |
282 return this; | 282 return this; |
283 } | 283 } |
284 | 284 |
285 void toCBuffer(OutBuffer buf, HdrGenState* hgs) | 285 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
286 { | 286 { |
287 expToCBuffer(buf, hgs, e1, precedence[op]); | 287 expToCBuffer(buf, hgs, e1, precedence[op]); |
288 buf.writeByte('['); | 288 buf.writeByte('['); |
289 if (upr || lwr) | 289 if (upr || lwr) |
290 { | 290 { |
299 buf.writestring("length"); // BUG: should be array.length | 299 buf.writestring("length"); // BUG: should be array.length |
300 } | 300 } |
301 buf.writeByte(']'); | 301 buf.writeByte(']'); |
302 } | 302 } |
303 | 303 |
304 Expression optimize(int result) | 304 override Expression optimize(int result) |
305 { | 305 { |
306 Expression e; | 306 Expression e; |
307 | 307 |
308 //printf("SliceExp::optimize(result = %d) %s\n", result, toChars()); | 308 //printf("SliceExp::optimize(result = %d) %s\n", result, toChars()); |
309 e = this; | 309 e = this; |
327 e = this; | 327 e = this; |
328 //printf("-SliceExp::optimize() %s\n", e->toChars()); | 328 //printf("-SliceExp::optimize() %s\n", e->toChars()); |
329 return e; | 329 return e; |
330 } | 330 } |
331 | 331 |
332 Expression interpret(InterState istate) | 332 override Expression interpret(InterState istate) |
333 { | 333 { |
334 Expression e; | 334 Expression e; |
335 Expression e1; | 335 Expression e1; |
336 Expression lwr; | 336 Expression lwr; |
337 Expression upr; | 337 Expression upr; |
369 | 369 |
370 Lcant: | 370 Lcant: |
371 return EXP_CANT_INTERPRET; | 371 return EXP_CANT_INTERPRET; |
372 } | 372 } |
373 | 373 |
374 void dump(int indent) | 374 override void dump(int indent) |
375 { | 375 { |
376 assert(false); | 376 assert(false); |
377 } | 377 } |
378 | 378 |
379 elem* toElem(IRState* irs) | 379 override elem* toElem(IRState* irs) |
380 { | 380 { |
381 elem* e; | 381 elem* e; |
382 Type t1; | 382 Type t1; |
383 | 383 |
384 //printf("SliceExp.toElem()\n"); | 384 //printf("SliceExp.toElem()\n"); |
485 | 485 |
486 el_setLoc(e,loc); | 486 el_setLoc(e,loc); |
487 return e; | 487 return e; |
488 } | 488 } |
489 | 489 |
490 void scanForNestedRef(Scope sc) | 490 override void scanForNestedRef(Scope sc) |
491 { | 491 { |
492 e1.scanForNestedRef(sc); | 492 e1.scanForNestedRef(sc); |
493 | 493 |
494 if (lengthVar) | 494 if (lengthVar) |
495 { | 495 { |
500 lwr.scanForNestedRef(sc); | 500 lwr.scanForNestedRef(sc); |
501 if (upr) | 501 if (upr) |
502 upr.scanForNestedRef(sc); | 502 upr.scanForNestedRef(sc); |
503 } | 503 } |
504 | 504 |
505 void buildArrayIdent(OutBuffer buf, Expressions arguments) | 505 override void buildArrayIdent(OutBuffer buf, Expressions arguments) |
506 { | 506 { |
507 buf.writestring("Slice"); | 507 buf.writestring("Slice"); |
508 arguments.shift(cast(void*)this); | 508 arguments.shift(cast(void*)this); |
509 } | 509 } |
510 | 510 |
511 Expression buildArrayLoop(Arguments fparams) | 511 override Expression buildArrayLoop(Arguments fparams) |
512 { | 512 { |
513 Identifier id = Identifier.generateId("p", fparams.dim); | 513 Identifier id = Identifier.generateId("p", fparams.dim); |
514 Argument param = new Argument(STCconst, type, id, null); | 514 Argument param = new Argument(STCconst, type, id, null); |
515 fparams.shift(cast(void*)param); | 515 fparams.shift(cast(void*)param); |
516 Expression e = new IdentifierExp(Loc(0), id); | 516 Expression e = new IdentifierExp(Loc(0), id); |
519 arguments.push(cast(void*)index); | 519 arguments.push(cast(void*)index); |
520 e = new ArrayExp(Loc(0), e, arguments); | 520 e = new ArrayExp(Loc(0), e, arguments); |
521 return e; | 521 return e; |
522 } | 522 } |
523 | 523 |
524 int inlineCost(InlineCostState* ics) | 524 override int inlineCost(InlineCostState* ics) |
525 { | 525 { |
526 int cost = 1 + e1.inlineCost(ics); | 526 int cost = 1 + e1.inlineCost(ics); |
527 if (lwr) | 527 if (lwr) |
528 cost += lwr.inlineCost(ics); | 528 cost += lwr.inlineCost(ics); |
529 if (upr) | 529 if (upr) |
530 cost += upr.inlineCost(ics); | 530 cost += upr.inlineCost(ics); |
531 return cost; | 531 return cost; |
532 } | 532 } |
533 | 533 |
534 Expression doInline(InlineDoState ids) | 534 override Expression doInline(InlineDoState ids) |
535 { | 535 { |
536 SliceExp are = cast(SliceExp)copy(); | 536 SliceExp are = cast(SliceExp)copy(); |
537 | 537 |
538 are.e1 = e1.doInline(ids); | 538 are.e1 = e1.doInline(ids); |
539 | 539 |
572 if (upr) | 572 if (upr) |
573 are.upr = upr.doInline(ids); | 573 are.upr = upr.doInline(ids); |
574 return are; | 574 return are; |
575 } | 575 } |
576 | 576 |
577 Expression inlineScan(InlineScanState* iss) | 577 override Expression inlineScan(InlineScanState* iss) |
578 { | 578 { |
579 e1 = e1.inlineScan(iss); | 579 e1 = e1.inlineScan(iss); |
580 if (lwr) | 580 if (lwr) |
581 lwr = lwr.inlineScan(iss); | 581 lwr = lwr.inlineScan(iss); |
582 if (upr) | 582 if (upr) |