Mercurial > projects > ldc
comparison gen/toir.cpp @ 335:17b844102023 trunk
[svn r356] Fixed problem with array length assignment introduced in [355]
author | lindquist |
---|---|
date | Sat, 12 Jul 2008 17:04:36 +0200 |
parents | 20446d22f832 |
children | aaade6ded589 |
comparison
equal
deleted
inserted
replaced
334:20446d22f832 | 335:17b844102023 |
---|---|
561 DValue* AssignExp::toElem(IRState* p) | 561 DValue* AssignExp::toElem(IRState* p) |
562 { | 562 { |
563 Logger::print("AssignExp::toElem: %s | %s = %s\n", toChars(), e1->type->toChars(), e2->type ? e2->type->toChars() : 0); | 563 Logger::print("AssignExp::toElem: %s | %s = %s\n", toChars(), e1->type->toChars(), e2->type ? e2->type->toChars() : 0); |
564 LOG_SCOPE; | 564 LOG_SCOPE; |
565 | 565 |
566 if (e1->op == TOKarraylength) | |
567 { | |
568 Logger::println("performing array.length assignment"); | |
569 ArrayLengthExp *ale = (ArrayLengthExp *)e1; | |
570 DValue* arr = ale->e1->toElem(p); | |
571 DVarValue arrval(ale->e1->type, arr->getLVal(), true); | |
572 DValue* newlen = e2->toElem(p); | |
573 DSliceValue* slice = DtoResizeDynArray(arrval.getType(), &arrval, newlen); | |
574 DtoAssign(&arrval, slice); | |
575 return newlen; | |
576 } | |
577 | |
578 Logger::println("performing normal assignment"); | |
579 | |
566 DValue* l = e1->toElem(p); | 580 DValue* l = e1->toElem(p); |
567 DValue* r = e2->toElem(p); | 581 DValue* r = e2->toElem(p); |
568 | 582 DtoAssign(l, r); |
569 Logger::println("performing assignment"); | |
570 | |
571 DImValue* im = r->isIm(); | |
572 if (!im || !im->inPlace()) { | |
573 Logger::println("assignment not inplace"); | |
574 if (DArrayLenValue* al = l->isArrayLen()) | |
575 { | |
576 DLRValue* arrlenval = l->isLRValue(); | |
577 assert(arrlenval); | |
578 DVarValue arrval(arrlenval->getLType(), arrlenval->getLVal(), true); | |
579 DSliceValue* slice = DtoResizeDynArray(arrval.getType(), &arrval, r); | |
580 DtoAssign(&arrval, slice); | |
581 } | |
582 else | |
583 { | |
584 DtoAssign(l, r); | |
585 } | |
586 } | |
587 | 583 |
588 if (l->isSlice() || l->isComplex()) | 584 if (l->isSlice() || l->isComplex()) |
589 return l; | 585 return l; |
590 | 586 |
591 LLValue* v; | 587 LLValue* v; |
1943 { | 1939 { |
1944 Logger::print("ArrayLengthExp::toElem: %s | %s\n", toChars(), type->toChars()); | 1940 Logger::print("ArrayLengthExp::toElem: %s | %s\n", toChars(), type->toChars()); |
1945 LOG_SCOPE; | 1941 LOG_SCOPE; |
1946 | 1942 |
1947 DValue* u = e1->toElem(p); | 1943 DValue* u = e1->toElem(p); |
1948 Logger::println("e1 = %s", e1->type->toChars()); | 1944 return new DImValue(type, DtoArrayLen(u)); |
1949 | |
1950 return new DArrayLenValue(e1->type, u->getLVal(), type, DtoArrayLen(u)); | |
1951 } | 1945 } |
1952 | 1946 |
1953 ////////////////////////////////////////////////////////////////////////////////////////// | 1947 ////////////////////////////////////////////////////////////////////////////////////////// |
1954 | 1948 |
1955 DValue* AssertExp::toElem(IRState* p) | 1949 DValue* AssertExp::toElem(IRState* p) |