Mercurial > projects > ldc
changeset 1426:ae70c438b281
Allow complex -> integral casts.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Thu, 28 May 2009 20:26:26 +0200 |
parents | 925779c19395 |
children | 087dafe5262a |
files | gen/complex.cpp |
diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/gen/complex.cpp Thu May 28 02:28:30 2009 +0200 +++ b/gen/complex.cpp Thu May 28 20:26:26 2009 +0200 @@ -438,11 +438,19 @@ DImValue* im = new DImValue(to, impart); return DtoCastFloat(loc, im, to); } - else if (to->isfloating()) { + else if (to->isfloating() || to->isintegral()) { // FIXME: this loads both values, even when we only need one LLValue* v = val->getRVal(); LLValue* repart = gIR->ir->CreateExtractValue(v, 0, ".re_part"); - DImValue* re = new DImValue(to, repart); + Type *extractty; + if (vty->ty == Tcomplex32) { + extractty = Type::tfloat32; + } else if (vty->ty == Tcomplex64) { + extractty = Type::tfloat64; + } else if (vty->ty == Tcomplex80) { + extractty = Type::tfloat80; + } + DImValue* re = new DImValue(extractty, repart); return DtoCastFloat(loc, re, to); } else if (to->ty == Tbool) {