mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-08 11:56:12 +03:00
Run postblit constructors for elements of an array.
This commit is contained in:
parent
44593f6220
commit
023b55a772
7 changed files with 162 additions and 35 deletions
|
@ -385,7 +385,7 @@ void DtoLeaveMonitor(LLValue* v)
|
|||
|
||||
// is this a good approach at all ?
|
||||
|
||||
void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs)
|
||||
void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs, int op)
|
||||
{
|
||||
Logger::println("DtoAssign(...);\n");
|
||||
LOG_SCOPE;
|
||||
|
@ -411,11 +411,17 @@ void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs)
|
|||
else if (t->ty == Tarray) {
|
||||
// lhs is slice
|
||||
if (DSliceValue* s = lhs->isSlice()) {
|
||||
if (DSliceValue* s2 = rhs->isSlice()) {
|
||||
DtoArrayCopySlices(s, s2);
|
||||
Type *elemType = t->nextOf()->toBasetype();
|
||||
if (elemType->equals(t2)) {
|
||||
DtoArrayInit(loc, s, rhs, op);
|
||||
}
|
||||
else if (t->nextOf()->toBasetype()->equals(t2)) {
|
||||
DtoArrayInit(loc, s, rhs);
|
||||
#if DMDV2
|
||||
else if (op != -1 && op != TOKblit && arrayNeedsPostblit(elemType)) {
|
||||
DtoArrayAssign(s, rhs, op);
|
||||
}
|
||||
#endif
|
||||
else if (DSliceValue *s2 = rhs->isSlice()) {
|
||||
DtoArrayCopySlices(s, s2);
|
||||
}
|
||||
else {
|
||||
DtoArrayCopyToSlice(s, rhs);
|
||||
|
@ -440,13 +446,19 @@ void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs)
|
|||
}
|
||||
}
|
||||
else if (t->ty == Tsarray) {
|
||||
// T[n] = T[n]
|
||||
if (DtoType(lhs->getType()) == DtoType(rhs->getType())) {
|
||||
DtoStaticArrayCopy(lhs->getLVal(), rhs->getRVal());
|
||||
}
|
||||
Type *elemType = t->nextOf()->toBasetype();
|
||||
// T[n] = T
|
||||
else if (t->nextOf()->toBasetype()->equals(t2)) {
|
||||
DtoArrayInit(loc, lhs, rhs);
|
||||
if (elemType->equals(t2)) {
|
||||
DtoArrayInit(loc, lhs, rhs, op);
|
||||
}
|
||||
#if DMDV2
|
||||
else if (op != -1 && op != TOKblit && arrayNeedsPostblit(elemType)) {
|
||||
DtoArrayAssign(lhs, rhs, op);
|
||||
}
|
||||
#endif
|
||||
// T[n] = T[n]
|
||||
else if (DtoType(lhs->getType()) == DtoType(rhs->getType())) {
|
||||
DtoStaticArrayCopy(lhs->getLVal(), rhs->getRVal());
|
||||
}
|
||||
// T[n] = T[] - generally only generated by frontend in rare cases
|
||||
else if (t2->ty == Tarray && t->nextOf()->toBasetype()->equals(t2->nextOf()->toBasetype())) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue