Mercurial > projects > ldc
comparison gen/toir.cpp @ 286:a3b7c19c866c trunk
[svn r307] Fixed: multidimensional new expressions now work. Eg.:
auto ma = new int[][] (3,9);
author | lindquist |
---|---|
date | Sat, 21 Jun 2008 04:47:14 +0200 |
parents | 70c370e97944 |
children | 068cb3c60afb |
comparison
equal
deleted
inserted
replaced
285:297690b5d4a5 | 286:a3b7c19c866c |
---|---|
1897 else if (ntype->ty == Tarray) | 1897 else if (ntype->ty == Tarray) |
1898 { | 1898 { |
1899 Logger::println("new dynamic array: %s", newtype->toChars()); | 1899 Logger::println("new dynamic array: %s", newtype->toChars()); |
1900 // get dim | 1900 // get dim |
1901 assert(arguments); | 1901 assert(arguments); |
1902 assert(arguments->dim == 1); | 1902 assert(arguments->dim >= 1); |
1903 DValue* sz = ((Expression*)arguments->data[0])->toElem(p); | 1903 if (arguments->dim == 1) |
1904 // allocate & init | 1904 { |
1905 return DtoNewDynArray(newtype, sz, true); | 1905 DValue* sz = ((Expression*)arguments->data[0])->toElem(p); |
1906 // allocate & init | |
1907 return DtoNewDynArray(newtype, sz, true); | |
1908 } | |
1909 else | |
1910 { | |
1911 size_t ndims = arguments->dim; | |
1912 std::vector<DValue*> dims(ndims); | |
1913 for (size_t i=0; i<ndims; ++i) | |
1914 dims[i] = ((Expression*)arguments->data[i])->toElem(p); | |
1915 return DtoNewMulDimDynArray(newtype, &dims[0], ndims, true); | |
1916 } | |
1906 } | 1917 } |
1907 // new static array | 1918 // new static array |
1908 else if (ntype->ty == Tsarray) | 1919 else if (ntype->ty == Tsarray) |
1909 { | 1920 { |
1910 assert(0); | 1921 assert(0); |