mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-02 08:01:11 +03:00
Implement static array -> static array cast. Fixes #223.
dynamic array -> static array is still misssing!
This commit is contained in:
parent
b8b9c41827
commit
d251e5d1f4
1 changed files with 20 additions and 1 deletions
|
@ -939,7 +939,26 @@ DValue* DtoCastArray(Loc& loc, DValue* u, Type* to)
|
|||
else if (totype->ty == Tsarray) {
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "to sarray" << '\n';
|
||||
assert(0);
|
||||
|
||||
if (fromtype->ty == Tsarray) {
|
||||
LLValue* uval = u->getRVal();
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "uvalTy = " << *uval->getType() << '\n';
|
||||
|
||||
assert(isaPointer(uval->getType()));
|
||||
const LLArrayType* arrty = isaArray(uval->getType()->getContainedType(0));
|
||||
|
||||
if(arrty->getNumElements()*fromtype->nextOf()->size() % totype->nextOf()->size() != 0)
|
||||
{
|
||||
error(loc, "invalid cast from '%s' to '%s', the element sizes don't line up", fromtype->toChars(), totype->toChars());
|
||||
fatal();
|
||||
}
|
||||
|
||||
rval = DtoBitCast(uval, getPtrToType(tolltype));
|
||||
}
|
||||
else
|
||||
assert(0 && "Cast to static array not implemented!");
|
||||
}
|
||||
else if (totype->ty == Tbool) {
|
||||
// return (arr.ptr !is null)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue