Mercurial > projects > ldc
comparison gen/llvmhelpers.cpp @ 758:f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 11 Nov 2008 01:38:48 +0100 |
parents | 2c730d530c98 |
children | 5696a7167b21 |
comparison
equal
deleted
inserted
replaced
757:2c730d530c98 | 758:f04dde6e882c |
---|---|
408 // lhs is slice | 408 // lhs is slice |
409 if (DSliceValue* s = lhs->isSlice()) { | 409 if (DSliceValue* s = lhs->isSlice()) { |
410 if (DSliceValue* s2 = rhs->isSlice()) { | 410 if (DSliceValue* s2 = rhs->isSlice()) { |
411 DtoArrayCopySlices(s, s2); | 411 DtoArrayCopySlices(s, s2); |
412 } | 412 } |
413 else if (t->next->toBasetype()->equals(t2)) { | 413 else if (t->nextOf()->toBasetype()->equals(t2)) { |
414 DtoArrayInit(loc, s, rhs); | 414 DtoArrayInit(loc, s, rhs); |
415 } | 415 } |
416 else { | 416 else { |
417 DtoArrayCopyToSlice(s, rhs); | 417 DtoArrayCopyToSlice(s, rhs); |
418 } | 418 } |
439 // T[n] = T[n] | 439 // T[n] = T[n] |
440 if (DtoType(lhs->getType()) == DtoType(rhs->getType())) { | 440 if (DtoType(lhs->getType()) == DtoType(rhs->getType())) { |
441 DtoStaticArrayCopy(lhs->getLVal(), rhs->getRVal()); | 441 DtoStaticArrayCopy(lhs->getLVal(), rhs->getRVal()); |
442 } | 442 } |
443 // T[n] = T | 443 // T[n] = T |
444 else if (t->next->toBasetype()->equals(t2)) { | 444 else if (t->nextOf()->toBasetype()->equals(t2)) { |
445 DtoArrayInit(loc, lhs, rhs); | 445 DtoArrayInit(loc, lhs, rhs); |
446 } | 446 } |
447 // T[n] = T[] - generally only generated by frontend in rare cases | 447 // T[n] = T[] - generally only generated by frontend in rare cases |
448 else if (t2->ty == Tarray && t->next->toBasetype()->equals(t2->next->toBasetype())) { | 448 else if (t2->ty == Tarray && t->nextOf()->toBasetype()->equals(t2->nextOf()->toBasetype())) { |
449 DtoMemCpy(lhs->getLVal(), DtoArrayPtr(rhs), DtoArrayLen(rhs)); | 449 DtoMemCpy(lhs->getLVal(), DtoArrayPtr(rhs), DtoArrayLen(rhs)); |
450 } else { | 450 } else { |
451 assert(0 && "Unimplemented static array assign!"); | 451 assert(0 && "Unimplemented static array assign!"); |
452 } | 452 } |
453 } | 453 } |
529 } | 529 } |
530 // dynamic array | 530 // dynamic array |
531 else if (basety == Tarray) | 531 else if (basety == Tarray) |
532 { | 532 { |
533 LLValue* len = DtoConstSize_t(0); | 533 LLValue* len = DtoConstSize_t(0); |
534 LLValue* ptr = getNullPtr(getPtrToType(DtoType(basetype->next))); | 534 LLValue* ptr = getNullPtr(getPtrToType(DtoType(basetype->nextOf()))); |
535 return new DSliceValue(type, len, ptr); | 535 return new DSliceValue(type, len, ptr); |
536 } | 536 } |
537 // delegate | 537 // delegate |
538 else if (basety == Tdelegate) | 538 else if (basety == Tdelegate) |
539 { | 539 { |
741 | 741 |
742 if (from->ty == Tarray) | 742 if (from->ty == Tarray) |
743 { | 743 { |
744 Type* at = to->toBasetype(); | 744 Type* at = to->toBasetype(); |
745 assert(at->ty == Tarray); | 745 assert(at->ty == Tarray); |
746 Type* elem = at->next->pointerTo(); | 746 Type* elem = at->nextOf()->pointerTo(); |
747 if (DSliceValue* slice = val->isSlice()) | 747 if (DSliceValue* slice = val->isSlice()) |
748 { | 748 { |
749 return new DSliceValue(to, slice->len, DtoBitCast(slice->ptr, DtoType(elem))); | 749 return new DSliceValue(to, slice->len, DtoBitCast(slice->ptr, DtoType(elem))); |
750 } | 750 } |
751 else if (val->isLVal()) | 751 else if (val->isLVal()) |
1186 DtoAnnotation(declaration->toChars()); | 1186 DtoAnnotation(declaration->toChars()); |
1187 | 1187 |
1188 Logger::println("vdtype = %s", vd->type->toChars()); | 1188 Logger::println("vdtype = %s", vd->type->toChars()); |
1189 | 1189 |
1190 // referenced by nested delegate? | 1190 // referenced by nested delegate? |
1191 #if DMDV2 | |
1192 if (vd->nestedrefs.dim) { | |
1193 #else | |
1191 if (vd->nestedref) { | 1194 if (vd->nestedref) { |
1195 #endif | |
1192 Logger::println("has nestedref set"); | 1196 Logger::println("has nestedref set"); |
1193 assert(vd->ir.irLocal); | 1197 assert(vd->ir.irLocal); |
1194 | 1198 |
1195 // alloca as usual if no value already | 1199 // alloca as usual if no value already |
1196 if (!vd->ir.irLocal->value) | 1200 if (!vd->ir.irLocal->value) |
1328 | 1332 |
1329 // we don't handle aliases either | 1333 // we don't handle aliases either |
1330 assert(!var->aliassym); | 1334 assert(!var->aliassym); |
1331 | 1335 |
1332 // referenced by nested function? | 1336 // referenced by nested function? |
1337 #if DMDV2 | |
1338 if (var->nestedrefs.dim) | |
1339 #else | |
1333 if (var->nestedref) | 1340 if (var->nestedref) |
1341 #endif | |
1334 { | 1342 { |
1335 assert(var->ir.irLocal); | 1343 assert(var->ir.irLocal); |
1336 assert(!var->ir.irLocal->value); | 1344 assert(!var->ir.irLocal->value); |
1337 | 1345 |
1338 // alloca | 1346 // alloca |
1517 if (t->equals(expbase)) | 1525 if (t->equals(expbase)) |
1518 break; | 1526 break; |
1519 assert(t->ty == Tsarray); | 1527 assert(t->ty == Tsarray); |
1520 TypeSArray* tsa = (TypeSArray*)t; | 1528 TypeSArray* tsa = (TypeSArray*)t; |
1521 dims.push_back(tsa->dim->toInteger()); | 1529 dims.push_back(tsa->dim->toInteger()); |
1522 assert(t->next); | 1530 assert(t->nextOf()); |
1523 t = t->next->toBasetype(); | 1531 t = t->nextOf()->toBasetype(); |
1524 } | 1532 } |
1525 | 1533 |
1526 size_t i = dims.size(); | 1534 size_t i = dims.size(); |
1527 assert(i); | 1535 assert(i); |
1528 | 1536 |