Mercurial > projects > ldc
diff gen/toir.cpp @ 715:30b42a283c8e
Removed TypeOpaque from DMD.
Changed runtime functions taking opaque[] to void[].
Implemented proper type painting, to avoid "resizing" array casts in runtime calls that previously took opaque[].
Implemented dynamic arrays as first class types, this implements proper ABI for these types on x86.
Added dwarf region end after call to assert function, fixes some problems with llvm not allowing this to be missing.
Reverted change to WithStatement from rev [704] it breaks MiniD, mini/with2.d needs to be fixed some other way...
Fixed tango bug 1339 in runtime, problem with _adReverseChar on invalid UTF-8.
Disabled .bc generation in the compiler runtime part, genobj.d triggers some llvm bug when using debug info. the .o seems to work fine.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Wed, 22 Oct 2008 14:55:33 +0200 |
parents | 5a2983f97498 |
children | 7261ff0f95ff |
line wrap: on
line diff
--- a/gen/toir.cpp Wed Oct 22 13:48:54 2008 +0200 +++ b/gen/toir.cpp Wed Oct 22 14:55:33 2008 +0200 @@ -783,21 +783,26 @@ Logger::print("CastExp::toElem: %s | %s\n", toChars(), type->toChars()); LOG_SCOPE; + // get the value to cast DValue* u = e1->toElem(p); - DValue* v = DtoCast(loc, u, to); - // force d type to this->type - v->getType() = type; - - if (v->isSlice()) { - // only valid as rvalue! + + // cast it to the 'to' type, if necessary + DValue* v = u; + if (!to->equals(e1->type)) + v = DtoCast(loc, u, to); + + // paint the type, if necessary + if (!type->equals(to)) + v = DtoPaintType(loc, v, type); + + // slices are not valid lvalues + if (v->isSlice()) return v; - } - + // if we're casting a lvalue, keep it around, we might be in a lvalue cast. else if(u->isLVal()) return new DLRValue(u, v); - - else - return v; + // otherwise just return the new value + return v; } ////////////////////////////////////////////////////////////////////////////////////////// @@ -811,7 +816,7 @@ const LLType* lltype = DtoType(type); if(!isaPointer(c->getType()) || !isaPointer(lltype)) { - error("can only cast pointers to pointers at compile time, not %s to %s", type->toChars(), e1->type->toChars()); + error("can only cast pointers to pointers at code generation time, not %s to %s", type->toChars(), e1->type->toChars()); fatal(); } @@ -1552,8 +1557,8 @@ else if (et->ty == Tarray) { DtoDeleteArray(dval); - if (!dval->isSlice()) - DtoSetArrayToNull(dval->getRVal()); + if (dval->isLVal()) + DtoSetArrayToNull(dval->getLVal()); } // unknown/invalid else