Mercurial > projects > ddmd
comparison dmd/StringExp.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 | df6d0f967680 |
comparison
equal
deleted
inserted
replaced
71:8e24ef1dd139 | 72:2e2a5c3f943a |
---|---|
60 this.sz = 1; | 60 this.sz = 1; |
61 this.committed = 0; | 61 this.committed = 0; |
62 this.postfix = postfix; | 62 this.postfix = postfix; |
63 } | 63 } |
64 | 64 |
65 bool equals(Object o) | 65 override bool equals(Object o) |
66 { | 66 { |
67 Expression e; | 67 Expression e; |
68 //printf("StringExp.equals('%s')\n", o.toChars()); | 68 //printf("StringExp.equals('%s')\n", o.toChars()); |
69 if (o && ((e = isExpression(o)) !is null)) | 69 if (o && ((e = isExpression(o)) !is null)) |
70 { | 70 { |
75 } | 75 } |
76 | 76 |
77 return false; | 77 return false; |
78 } | 78 } |
79 | 79 |
80 string toChars() | 80 override string toChars() |
81 { | 81 { |
82 scope OutBuffer buf = new OutBuffer(); | 82 scope OutBuffer buf = new OutBuffer(); |
83 HdrGenState hgs; | 83 HdrGenState hgs; |
84 char *p; | 84 char *p; |
85 | 85 |
87 toCBuffer(buf, &hgs); | 87 toCBuffer(buf, &hgs); |
88 buf.writeByte(0); | 88 buf.writeByte(0); |
89 return buf.extractString(); | 89 return buf.extractString(); |
90 } | 90 } |
91 | 91 |
92 Expression semantic(Scope sc) | 92 override Expression semantic(Scope sc) |
93 { | 93 { |
94 version (LOGSEMANTIC) { | 94 version (LOGSEMANTIC) { |
95 printf("StringExp.semantic() %s\n", toChars()); | 95 printf("StringExp.semantic() %s\n", toChars()); |
96 } | 96 } |
97 if (!type) | 97 if (!type) |
166 //printf("type = %s\n", type.toChars()); | 166 //printf("type = %s\n", type.toChars()); |
167 } | 167 } |
168 return this; | 168 return this; |
169 } | 169 } |
170 | 170 |
171 Expression interpret(InterState istate) | 171 override Expression interpret(InterState istate) |
172 { | 172 { |
173 version (LOG) { | 173 version (LOG) { |
174 printf("StringExp.interpret() %.*s\n", toChars()); | 174 printf("StringExp.interpret() %.*s\n", toChars()); |
175 } | 175 } |
176 return this; | 176 return this; |
241 return se; | 241 return se; |
242 } | 242 } |
243 return this; | 243 return this; |
244 } | 244 } |
245 | 245 |
246 Expression implicitCastTo(Scope sc, Type t) | 246 override Expression implicitCastTo(Scope sc, Type t) |
247 { | 247 { |
248 //printf("StringExp.implicitCastTo(%s of type %s) => %s\n", toChars(), type.toChars(), t.toChars()); | 248 //printf("StringExp.implicitCastTo(%s of type %s) => %s\n", toChars(), type.toChars(), t.toChars()); |
249 ubyte committed = this.committed; | 249 ubyte committed = this.committed; |
250 Expression e = Expression.implicitCastTo(sc, t); | 250 Expression e = Expression.implicitCastTo(sc, t); |
251 if (e.op == TOK.TOKstring) | 251 if (e.op == TOK.TOKstring) |
254 (cast(StringExp)e).committed = committed; | 254 (cast(StringExp)e).committed = committed; |
255 } | 255 } |
256 return e; | 256 return e; |
257 } | 257 } |
258 | 258 |
259 MATCH implicitConvTo(Type t) | 259 override MATCH implicitConvTo(Type t) |
260 { | 260 { |
261 MATCH m; | 261 MATCH m; |
262 | 262 |
263 static if (false) { | 263 static if (false) { |
264 printf("StringExp.implicitConvTo(this=%s, committed=%d, type=%s, t=%s)\n", | 264 printf("StringExp.implicitConvTo(this=%s, committed=%d, type=%s, t=%s)\n", |
336 | 336 |
337 static uint X(TY tf, TY tt) { | 337 static uint X(TY tf, TY tt) { |
338 return ((tf) * 256 + (tt)); | 338 return ((tf) * 256 + (tt)); |
339 } | 339 } |
340 | 340 |
341 Expression castTo(Scope sc, Type t) | 341 override Expression castTo(Scope sc, Type t) |
342 { | 342 { |
343 /* This follows copy-on-write; any changes to 'this' | 343 /* This follows copy-on-write; any changes to 'this' |
344 * will result in a copy. | 344 * will result in a copy. |
345 * The this.string member is considered immutable. | 345 * The this.string member is considered immutable. |
346 */ | 346 */ |
575 Expression e = new CastExp(loc, se, t); | 575 Expression e = new CastExp(loc, se, t); |
576 e.type = t; // so semantic() won't be run on e | 576 e.type = t; // so semantic() won't be run on e |
577 return e; | 577 return e; |
578 } | 578 } |
579 | 579 |
580 int opCmp(Object obj) | 580 override int opCmp(Object obj) |
581 { | 581 { |
582 // Used to sort case statement expressions so we can do an efficient lookup | 582 // Used to sort case statement expressions so we can do an efficient lookup |
583 StringExp se2 = cast(StringExp)(obj); | 583 StringExp se2 = cast(StringExp)(obj); |
584 | 584 |
585 // This is a kludge so isExpression() in template.c will return 5 | 585 // This is a kludge so isExpression() in template.c will return 5 |
633 } | 633 } |
634 | 634 |
635 return len1 - len2; | 635 return len1 - len2; |
636 } | 636 } |
637 | 637 |
638 bool isBool(bool result) | 638 override bool isBool(bool result) |
639 { | 639 { |
640 assert(false); | 640 assert(false); |
641 } | 641 } |
642 | 642 |
643 uint charAt(size_t i) | 643 uint charAt(size_t i) |
663 break; | 663 break; |
664 } | 664 } |
665 return value; | 665 return value; |
666 } | 666 } |
667 | 667 |
668 void toCBuffer(OutBuffer buf, HdrGenState* hgs) | 668 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
669 { | 669 { |
670 buf.writeByte('"'); | 670 buf.writeByte('"'); |
671 for (size_t i = 0; i < len; i++) | 671 for (size_t i = 0; i < len; i++) |
672 { | 672 { |
673 uint c = charAt(i); | 673 uint c = charAt(i); |
696 buf.writeByte('"'); | 696 buf.writeByte('"'); |
697 if (postfix) | 697 if (postfix) |
698 buf.writeByte(postfix); | 698 buf.writeByte(postfix); |
699 } | 699 } |
700 | 700 |
701 void toMangleBuffer(OutBuffer buf) | 701 override void toMangleBuffer(OutBuffer buf) |
702 { | 702 { |
703 char m; | 703 char m; |
704 OutBuffer tmp = new OutBuffer(); | 704 OutBuffer tmp = new OutBuffer(); |
705 string p; | 705 string p; |
706 dchar c; | 706 dchar c; |
749 buf.printf("%d_", qlen); | 749 buf.printf("%d_", qlen); |
750 for (size_t i = 0; i < qlen; i++) | 750 for (size_t i = 0; i < qlen; i++) |
751 buf.printf("%02x", q[i]); | 751 buf.printf("%02x", q[i]); |
752 } | 752 } |
753 | 753 |
754 elem* toElem(IRState* irs) | 754 override elem* toElem(IRState* irs) |
755 { | 755 { |
756 elem* e; | 756 elem* e; |
757 Type tb = type.toBasetype(); | 757 Type tb = type.toBasetype(); |
758 | 758 |
759 static if (false) { | 759 static if (false) { |
856 } | 856 } |
857 el_setLoc(e,loc); | 857 el_setLoc(e,loc); |
858 return e; | 858 return e; |
859 } | 859 } |
860 | 860 |
861 dt_t** toDt(dt_t** pdt) | 861 override dt_t** toDt(dt_t** pdt) |
862 { | 862 { |
863 //printf("StringExp.toDt() '%s', type = %s\n", toChars(), type.toChars()); | 863 //printf("StringExp.toDt() '%s', type = %s\n", toChars(), type.toChars()); |
864 Type t = type.toBasetype(); | 864 Type t = type.toBasetype(); |
865 | 865 |
866 // BUG: should implement some form of static string pooling | 866 // BUG: should implement some form of static string pooling |