Mercurial > projects > ldc
comparison gen/toir.cpp @ 591:e6bcc4d9e5ff
Add _d_newarrayvT and _d_newarraymvT to create arrays without initialization.
Adjust DtoNewDynArray to use DtoArrayInit for initialization of new arrays.
Make Type::tvoid->defaultInit() not error.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sun, 14 Sep 2008 10:13:50 +0200 |
parents | 23538d0f0d5b |
children | 5fb7ed0ac580 |
comparison
equal
deleted
inserted
replaced
590:1ecb43102d12 | 591:e6bcc4d9e5ff |
---|---|
1450 assert(arguments->dim >= 1); | 1450 assert(arguments->dim >= 1); |
1451 if (arguments->dim == 1) | 1451 if (arguments->dim == 1) |
1452 { | 1452 { |
1453 DValue* sz = ((Expression*)arguments->data[0])->toElem(p); | 1453 DValue* sz = ((Expression*)arguments->data[0])->toElem(p); |
1454 // allocate & init | 1454 // allocate & init |
1455 return DtoNewDynArray(newtype, sz, true); | 1455 return DtoNewDynArray(loc, newtype, sz, true); |
1456 } | 1456 } |
1457 else | 1457 else |
1458 { | 1458 { |
1459 size_t ndims = arguments->dim; | 1459 size_t ndims = arguments->dim; |
1460 std::vector<DValue*> dims(ndims); | 1460 std::vector<DValue*> dims(ndims); |
1461 for (size_t i=0; i<ndims; ++i) | 1461 for (size_t i=0; i<ndims; ++i) |
1462 dims[i] = ((Expression*)arguments->data[i])->toElem(p); | 1462 dims[i] = ((Expression*)arguments->data[i])->toElem(p); |
1463 return DtoNewMulDimDynArray(newtype, &dims[0], ndims, true); | 1463 return DtoNewMulDimDynArray(loc, newtype, &dims[0], ndims, true); |
1464 } | 1464 } |
1465 } | 1465 } |
1466 // new static array | 1466 // new static array |
1467 else if (ntype->ty == Tsarray) | 1467 else if (ntype->ty == Tsarray) |
1468 { | 1468 { |