comparison gen/arrays.cpp @ 1643:8f121883bce8

Apply patch from klickverbot. This is his 'proper fix' patch for bug #395.
author Kelly Wilson <wilsonk cpsc.ucalgary.ca>
date Mon, 08 Mar 2010 23:37:40 -0700
parents 0de4525a9ed6
children 40bd4a0d4870
comparison
equal deleted inserted replaced
1642:f49cb50c6064 1643:8f121883bce8
530 530
531 return new DSliceValue(arrayType, newdim->getRVal(), newptr); 531 return new DSliceValue(arrayType, newdim->getRVal(), newptr);
532 } 532 }
533 533
534 ////////////////////////////////////////////////////////////////////////////////////////// 534 //////////////////////////////////////////////////////////////////////////////////////////
535 void DtoCatAssignElement(Type* arrayType, DValue* array, Expression* exp) 535 void DtoCatAssignElement(Loc& loc, Type* arrayType, DValue* array, Expression* exp)
536 { 536 {
537 Logger::println("DtoCatAssignElement"); 537 Logger::println("DtoCatAssignElement");
538 LOG_SCOPE; 538 LOG_SCOPE;
539 539
540 assert(array); 540 assert(array);
541 541
542 DValue *expVal = exp->toElem(gIR); 542 LLValue *valueToAppend = makeLValue(loc, exp->toElem(gIR));
543 LLValue *valueToAppend;
544 if (expVal->isLVal())
545 valueToAppend = expVal->getLVal();
546 else {
547 valueToAppend = DtoAlloca(expVal->getType(), ".appendingElementOnStack");
548 DVarValue lval(expVal->getType(), valueToAppend);
549 Loc loc;
550 DtoAssign(loc, &lval, expVal);
551 }
552 543
553 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_arrayappendcT"); 544 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_arrayappendcT");
554 LLSmallVector<LLValue*,3> args; 545 LLSmallVector<LLValue*,3> args;
555 args.push_back(DtoTypeInfoOf(arrayType)); 546 args.push_back(DtoTypeInfoOf(arrayType));
556 args.push_back(DtoBitCast(array->getLVal(), getVoidPtrType())); 547 args.push_back(DtoBitCast(array->getLVal(), getVoidPtrType()));