comparison sema/DType.d @ 120:7d0898f77685

Implement the cast expression - works for integers and real/float/double
author Anders Halager <halager@gmail.com>
date Sun, 25 May 2008 20:18:55 +0200
parents c0b531362ca6
children ed815b31479b
comparison
equal deleted inserted replaced
119:c0b531362ca6 120:7d0898f77685
250 super(name, bits, unsigned); 250 super(name, bits, unsigned);
251 } 251 }
252 252
253 override bool hasImplicitConversionTo(DType that) 253 override bool hasImplicitConversionTo(DType that)
254 { 254 {
255 if (auto o = cast(DInteger)that) 255 if (that.isInteger() || that.isReal())
256 return true; 256 return true;
257 return false; 257 return false;
258 } 258 }
259 259
260 override bool isInteger() { return true; } 260 override bool isInteger() { return true; }
268 super(name, bits, false); 268 super(name, bits, false);
269 } 269 }
270 270
271 override bool hasImplicitConversionTo(DType that) 271 override bool hasImplicitConversionTo(DType that)
272 { 272 {
273 if (auto o = cast(DInteger)that) 273 if (that.isInteger() || that.isReal())
274 return true;
275 if (auto o = cast(DReal)that)
276 return true; 274 return true;
277 return false; 275 return false;
278 } 276 }
279 277
280 override bool isReal() { return true; } 278 override bool isReal() { return true; }