Mercurial > projects > dang
diff sema/DType.d @ 58:fc62c5296a1c new_gen
Add types to our Exp
author | Anders Halager <halager@gmail.com> |
---|---|
date | Mon, 28 Apr 2008 21:51:39 +0200 |
parents | 79cb0afafabe |
children | 9f8131676242 |
line wrap: on
line diff
--- a/sema/DType.d Mon Apr 28 21:47:01 2008 +0200 +++ b/sema/DType.d Mon Apr 28 21:51:39 2008 +0200 @@ -55,6 +55,12 @@ Location getLoc() { return loc; } int byteSize() { return 0; } + /** + Can this type legally be converted to that type with no casts? + True for short -> int etc. + */ + bool hasImplicitConversionTo(DType that) { return false; } + static DInteger Bool, Byte, UByte, Short, UShort, @@ -92,6 +98,13 @@ override int byteSize() { return bits / 8; } + override bool hasImplicitConversionTo(DType that) + { + if (auto o = cast(DInteger)that) + return this.bits >= o.bits; + return false; + } + int bits; bool unsigned; } @@ -123,7 +136,9 @@ DType typeOf(char[] name) { - return members[name].type; + if (auto res = name in members) + return res.type; + return null; } DStructMember[char[]] members;