Changeset 1633:5c0cebff9be8
- Timestamp:
- 02/14/10 04:11:05 (2 years ago)
- Files:
-
- gen/arrays.cpp (modified) (5 diffs)
- gen/arrays.h (modified) (1 diff)
- gen/runtime.cpp (modified) (1 diff)
- gen/toir.cpp (modified) (8 diffs)
- tango-0.99.9.patch (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gen/arrays.cpp
r1571 r1633 475 475 // build dims 476 476 LLValue* dimsArg = DtoArrayAlloca(Type::tsize_t, ndims, ".newdims"); 477 LLValue* firstDim = NULL; 477 LLValue* firstDim = NULL; 478 478 for (size_t i=0; i<ndims; ++i) 479 479 { … … 533 533 534 534 ////////////////////////////////////////////////////////////////////////////////////////// 535 DSliceValue* DtoCatAssignElement(DValue* array, Expression* exp)535 void DtoCatAssignElement(Type* arrayType, DValue* array, Expression* exp) 536 536 { 537 537 Logger::println("DtoCatAssignElement"); … … 540 540 assert(array); 541 541 542 LLValue* idx = DtoArrayLen(array); 543 LLValue* one = DtoConstSize_t(1); 544 LLValue* len = gIR->ir->CreateAdd(idx,one,"tmp"); 545 546 DValue* newdim = new DImValue(Type::tsize_t, len); 547 DSliceValue* slice = DtoResizeDynArray(array->getType(), array, newdim); 548 549 LLValue* ptr = slice->ptr; 550 ptr = llvm::GetElementPtrInst::Create(ptr, idx, "tmp", gIR->scopebb()); 551 552 DValue* dptr = new DVarValue(exp->type, ptr); 553 554 DValue* e = exp->toElem(gIR); 555 556 DtoAssign(exp->loc, dptr, e); 557 558 return slice; 542 DValue *expVal = exp->toElem(gIR); 543 LLValue *valueToAppend; 544 if (expVal->isLVal()) 545 valueToAppend = expVal->getLVal(); 546 else { 547 valueToAppend = DtoAlloca(expVal->getType(), ".appendingElementOnStack"); 548 DtoStore(expVal->getRVal(), valueToAppend); 549 } 550 551 LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_arrayappendcT"); 552 LLSmallVector<LLValue*,3> args; 553 args.push_back(DtoTypeInfoOf(arrayType)); 554 args.push_back(DtoBitCast(array->getLVal(), getVoidPtrType())); 555 args.push_back(DtoBitCast(valueToAppend, getVoidPtrType())); 556 557 gIR->CreateCallOrInvoke(fn, args.begin(), args.end(), ".appendedArray"); 559 558 } 560 559 … … 981 980 if (Logger::enabled()) 982 981 Logger::cout() << "to sarray" << '\n'; 983 982 984 983 size_t tosize = ((TypeSArray*)totype)->dim->toInteger(); 985 984 … … 1005 1004 DConstValue index(Type::tsize_t, DtoConstSize_t(i)); 1006 1005 DtoArrayBoundsCheck(loc, u, &index, false); 1007 1006 1008 1007 rval = DtoArrayPtr(u); 1009 rval = DtoBitCast(rval, getPtrToType(tolltype)); 1008 rval = DtoBitCast(rval, getPtrToType(tolltype)); 1010 1009 } 1011 1010 } gen/arrays.h
r1228 r1633 25 25 DSliceValue* DtoResizeDynArray(Type* arrayType, DValue* array, DValue* newdim); 26 26 27 DSliceValue* DtoCatAssignElement(DValue* arr, Expression* exp);27 void DtoCatAssignElement(Type* type, DValue* arr, Expression* exp); 28 28 DSliceValue* DtoCatAssignArray(DValue* arr, Expression* exp); 29 29 DSliceValue* DtoCatArrays(Type* type, Expression* e1, Expression* e2); gen/runtime.cpp
r1572 r1633 327 327 } 328 328 329 // void* _d_arrayappendcT(TypeInfo ti, void* array, void* element) 330 { 331 llvm::StringRef fname("_d_arrayappendcT"); 332 std::vector<const LLType*> types; 333 types.push_back(typeInfoTy); 334 types.push_back(voidPtrTy); 335 types.push_back(voidPtrTy); 336 const llvm::FunctionType* fty = llvm::FunctionType::get(rt_array(byteTy), types, false); 337 llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); 338 } 339 329 340 // Object _d_allocclass(ClassInfo ci) 330 341 { gen/toir.cpp
r1595 r1633 625 625 if ((t1->ty == Tarray || t1->ty == Tsarray) && 626 626 (t2->ty == Tarray || t2->ty == Tsarray) 627 ) 627 ) 628 628 { 629 629 base->error("Array operation %s not recognized", base->toChars()); … … 1014 1014 } 1015 1015 else if ( 1016 e1->op == TOKstructliteral || 1016 e1->op == TOKstructliteral || 1017 1017 e1->op == TOKslice) 1018 1018 { … … 1139 1139 // 1140 1140 bool vtbllookup = fdecl->isAbstract() || (!fdecl->isFinal() && fdecl->isVirtual()); 1141 1141 1142 1142 // even virtual functions are looked up directly if super or DotTypeExp 1143 1143 // are used, thus we need to walk through the this expression and check … … 1151 1151 break; 1152 1152 } 1153 1153 1154 1154 // 1155 1155 // look up function … … 1238 1238 } 1239 1239 else if (e1type->ty == Tsarray) { 1240 if(global.params.useArrayBounds) 1240 if(global.params.useArrayBounds) 1241 1241 DtoArrayBoundsCheck(loc, l, r, false); 1242 1242 arrptr = DtoGEP(l->getRVal(), zero, r->getRVal()); 1243 1243 } 1244 1244 else if (e1type->ty == Tarray) { 1245 if(global.params.useArrayBounds) 1245 if(global.params.useArrayBounds) 1246 1246 DtoArrayBoundsCheck(loc, l, r, false); 1247 1247 arrptr = DtoArrayPtr(l); … … 1770 1770 // class invariants 1771 1771 if( 1772 global.params.useInvariants && 1772 global.params.useInvariants && 1773 1773 condty->ty == Tclass && 1774 1774 !((TypeClass*)condty)->sym->isInterfaceDeclaration()) … … 1781 1781 // struct invariants 1782 1782 else if( 1783 global.params.useInvariants && 1783 global.params.useInvariants && 1784 1784 condty->ty == Tpointer && condty->nextOf()->ty == Tstruct && 1785 1785 (invdecl = ((TypeStruct*)condty->nextOf())->sym->inv) != NULL) … … 2235 2235 2236 2236 if (e2type == elemtype) { 2237 DSliceValue* slice = DtoCatAssignElement(l,e2); 2238 DtoAssign(loc, l, slice); 2237 DtoCatAssignElement(e1type, l, e2); 2239 2238 } 2240 2239 else if (e1type == e2type) {

