Mercurial > projects > ddmd
comparison dmd/IntegerExp.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 | ef02e2e203c2 |
comparison
equal
deleted
inserted
replaced
71:8e24ef1dd139 | 72:2e2a5c3f943a |
---|---|
47 super(Loc(0), TOK.TOKint64, IntegerExp.sizeof); | 47 super(Loc(0), TOK.TOKint64, IntegerExp.sizeof); |
48 this.type = Type.tint32; | 48 this.type = Type.tint32; |
49 this.value = value; | 49 this.value = value; |
50 } | 50 } |
51 | 51 |
52 bool equals(Object o) | 52 override bool equals(Object o) |
53 { | 53 { |
54 IntegerExp ne; | 54 IntegerExp ne; |
55 | 55 |
56 if (this == o || | 56 if (this == o || |
57 ((cast(Expression)o).op == TOKint64 && | 57 ((cast(Expression)o).op == TOKint64 && |
61 return 1; | 61 return 1; |
62 | 62 |
63 return 0; | 63 return 0; |
64 } | 64 } |
65 | 65 |
66 Expression semantic(Scope sc) | 66 override Expression semantic(Scope sc) |
67 { | 67 { |
68 if (!type) | 68 if (!type) |
69 { | 69 { |
70 // Determine what the type of this number is | 70 // Determine what the type of this number is |
71 ulong number = value; | 71 ulong number = value; |
82 type = type.semantic(loc, sc); | 82 type = type.semantic(loc, sc); |
83 } | 83 } |
84 return this; | 84 return this; |
85 } | 85 } |
86 | 86 |
87 Expression interpret(InterState istate) | 87 override Expression interpret(InterState istate) |
88 { | 88 { |
89 version (LOG) { | 89 version (LOG) { |
90 printf("IntegerExp.interpret() %s\n", toChars()); | 90 printf("IntegerExp.interpret() %s\n", toChars()); |
91 } | 91 } |
92 return this; | 92 return this; |
93 } | 93 } |
94 | 94 |
95 string toChars() | 95 override string toChars() |
96 { | 96 { |
97 static if (true) { | 97 static if (true) { |
98 return Expression.toChars(); | 98 return Expression.toChars(); |
99 } else { | 99 } else { |
100 static char buffer[value.sizeof * 3 + 1]; | 100 static char buffer[value.sizeof * 3 + 1]; |
101 int len = sprintf(buffer.ptr, "%jd", value); | 101 int len = sprintf(buffer.ptr, "%jd", value); |
102 return buffer[0..len].idup; | 102 return buffer[0..len].idup; |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 void dump(int indent) | 106 override void dump(int indent) |
107 { | 107 { |
108 assert(false); | 108 assert(false); |
109 } | 109 } |
110 | 110 |
111 IntRange getIntRange() | 111 override IntRange getIntRange() |
112 { | 112 { |
113 IntRange ir; | 113 IntRange ir; |
114 ir.imin = value & type.sizemask(); | 114 ir.imin = value & type.sizemask(); |
115 ir.imax = ir.imin; | 115 ir.imax = ir.imin; |
116 return ir; | 116 return ir; |
117 } | 117 } |
118 | 118 |
119 ulong toInteger() | 119 override ulong toInteger() |
120 { | 120 { |
121 Type t; | 121 Type t; |
122 | 122 |
123 t = type; | 123 t = type; |
124 while (t) | 124 while (t) |
175 break; | 175 break; |
176 } | 176 } |
177 return value; | 177 return value; |
178 } | 178 } |
179 | 179 |
180 real toReal() | 180 override real toReal() |
181 { | 181 { |
182 Type t; | 182 Type t; |
183 | 183 |
184 toInteger(); | 184 toInteger(); |
185 t = type.toBasetype(); | 185 t = type.toBasetype(); |
187 return cast(real)cast(ulong)value; | 187 return cast(real)cast(ulong)value; |
188 else | 188 else |
189 return cast(real)cast(long)value; | 189 return cast(real)cast(long)value; |
190 } | 190 } |
191 | 191 |
192 real toImaginary() | 192 override real toImaginary() |
193 { | 193 { |
194 assert(false); | 194 assert(false); |
195 } | 195 } |
196 | 196 |
197 Complex!(real) toComplex() | 197 override Complex!(real) toComplex() |
198 { | 198 { |
199 assert(false); | 199 assert(false); |
200 } | 200 } |
201 | 201 |
202 int isConst() | 202 override int isConst() |
203 { | 203 { |
204 return 1; | 204 return 1; |
205 } | 205 } |
206 | 206 |
207 bool isBool(bool result) | 207 override bool isBool(bool result) |
208 { | 208 { |
209 return result ? value != 0 : value == 0; | 209 return result ? value != 0 : value == 0; |
210 } | 210 } |
211 | 211 |
212 MATCH implicitConvTo(Type t) | 212 override MATCH implicitConvTo(Type t) |
213 { | 213 { |
214 static if (false) { | 214 static if (false) { |
215 printf("IntegerExp.implicitConvTo(this=%s, type=%s, t=%s)\n", | 215 printf("IntegerExp.implicitConvTo(this=%s, type=%s, t=%s)\n", |
216 toChars(), type.toChars(), t.toChars()); | 216 toChars(), type.toChars(), t.toChars()); |
217 } | 217 } |
402 Lno: | 402 Lno: |
403 //printf("MATCHnomatch\n"); | 403 //printf("MATCHnomatch\n"); |
404 return MATCH.MATCHnomatch; | 404 return MATCH.MATCHnomatch; |
405 } | 405 } |
406 | 406 |
407 void toCBuffer(OutBuffer buf, HdrGenState* hgs) | 407 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
408 { | 408 { |
409 long v = toInteger(); | 409 long v = toInteger(); |
410 | 410 |
411 if (type) | 411 if (type) |
412 { | 412 { |
518 buf.printf("0x%jx", v); | 518 buf.printf("0x%jx", v); |
519 else | 519 else |
520 buf.printf("%jd", v); | 520 buf.printf("%jd", v); |
521 } | 521 } |
522 | 522 |
523 void toMangleBuffer(OutBuffer buf) | 523 override void toMangleBuffer(OutBuffer buf) |
524 { | 524 { |
525 if (cast(long)value < 0) | 525 if (cast(long)value < 0) |
526 buf.printf("N%d", -value); | 526 buf.printf("N%d", -value); |
527 else | 527 else |
528 buf.printf("%d", value); | 528 buf.printf("%d", value); |
529 } | 529 } |
530 | 530 |
531 Expression toLvalue(Scope sc, Expression e) | 531 override Expression toLvalue(Scope sc, Expression e) |
532 { | 532 { |
533 if (!e) | 533 if (!e) |
534 e = this; | 534 e = this; |
535 else if (!loc.filename) | 535 else if (!loc.filename) |
536 loc = e.loc; | 536 loc = e.loc; |
537 e.error("constant %s is not an lvalue", e.toChars()); | 537 e.error("constant %s is not an lvalue", e.toChars()); |
538 return this; | 538 return this; |
539 } | 539 } |
540 | 540 |
541 elem* toElem(IRState* irs) | 541 override elem* toElem(IRState* irs) |
542 { | 542 { |
543 elem* e = el_long(type.totym(), value); | 543 elem* e = el_long(type.totym(), value); |
544 el_setLoc(e,loc); | 544 el_setLoc(e,loc); |
545 return e; | 545 return e; |
546 } | 546 } |
547 | 547 |
548 dt_t** toDt(dt_t** pdt) | 548 override dt_t** toDt(dt_t** pdt) |
549 { | 549 { |
550 //printf("IntegerExp.toDt() %d\n", op); | 550 //printf("IntegerExp.toDt() %d\n", op); |
551 uint sz = cast(uint)type.size(); | 551 uint sz = cast(uint)type.size(); |
552 if (value == 0) | 552 if (value == 0) |
553 pdt = dtnzeros(pdt, sz); | 553 pdt = dtnzeros(pdt, sz); |