Mercurial > projects > ldc
comparison dmd/mtype.c @ 127:facc562f5674 trunk
[svn r131] Fixed #11
All associative array properties now work as they should.
Fixed problems with some cases of array.length and array.ptr.
Fixed some problems with array properties.
Fixed 'in' contracts.
author | lindquist |
---|---|
date | Fri, 30 Nov 2007 12:56:52 +0100 |
parents | 9c79b61fb638 |
children | a7dfa0ed966c |
comparison
equal
deleted
inserted
replaced
126:a2c2c3c1a73d | 127:facc562f5674 |
---|---|
1511 Expressions *arguments; | 1511 Expressions *arguments; |
1512 char *nm; | 1512 char *nm; |
1513 static char *name[2] = { "_adReverseChar", "_adReverseWchar" }; | 1513 static char *name[2] = { "_adReverseChar", "_adReverseWchar" }; |
1514 | 1514 |
1515 nm = name[n->ty == Twchar]; | 1515 nm = name[n->ty == Twchar]; |
1516 fd = FuncDeclaration::genCfunc(Type::tindex, nm); | 1516 fd = FuncDeclaration::genCfunc(Type::tvoid->arrayOf(), nm); |
1517 fd->llvmRunTimeHack = true; | 1517 fd->llvmRunTimeHack = true; |
1518 ((TypeFunction*)fd->type)->llvmRetInPtr = true; | |
1519 ec = new VarExp(0, fd); | 1518 ec = new VarExp(0, fd); |
1520 e = e->castTo(sc, n->arrayOf()); // convert to dynamic array | 1519 e = e->castTo(sc, n->arrayOf()); // convert to dynamic array |
1521 arguments = new Expressions(); | 1520 arguments = new Expressions(); |
1522 arguments->push(e); | 1521 arguments->push(e); |
1523 e = new CallExp(e->loc, ec, arguments); | 1522 e = new CallExp(e->loc, ec, arguments); |
1530 Expressions *arguments; | 1529 Expressions *arguments; |
1531 char *nm; | 1530 char *nm; |
1532 static char *name[2] = { "_adSortChar", "_adSortWchar" }; | 1531 static char *name[2] = { "_adSortChar", "_adSortWchar" }; |
1533 | 1532 |
1534 nm = name[n->ty == Twchar]; | 1533 nm = name[n->ty == Twchar]; |
1535 fd = FuncDeclaration::genCfunc(Type::tindex, nm); | 1534 fd = FuncDeclaration::genCfunc(Type::tvoid->arrayOf(), nm); |
1536 fd->llvmRunTimeHack = true; | 1535 fd->llvmRunTimeHack = true; |
1537 ((TypeFunction*)fd->type)->llvmRetInPtr = true; | |
1538 ec = new VarExp(0, fd); | 1536 ec = new VarExp(0, fd); |
1539 e = e->castTo(sc, n->arrayOf()); // convert to dynamic array | 1537 e = e->castTo(sc, n->arrayOf()); // convert to dynamic array |
1540 arguments = new Expressions(); | 1538 arguments = new Expressions(); |
1541 arguments->push(e); | 1539 arguments->push(e); |
1542 e = new CallExp(e->loc, ec, arguments); | 1540 e = new CallExp(e->loc, ec, arguments); |
1550 int size = next->size(e->loc); | 1548 int size = next->size(e->loc); |
1551 int dup; | 1549 int dup; |
1552 | 1550 |
1553 assert(size); | 1551 assert(size); |
1554 dup = (ident == Id::dup); | 1552 dup = (ident == Id::dup); |
1555 fd = FuncDeclaration::genCfunc(Type::tindex, dup ? Id::adDup : Id::adReverse); | 1553 fd = FuncDeclaration::genCfunc(Type::tvoid->arrayOf(), dup ? Id::adDup : Id::adReverse); |
1556 fd->llvmRunTimeHack = true; | 1554 fd->llvmRunTimeHack = true; |
1557 ((TypeFunction*)fd->type)->llvmRetInPtr = true; | |
1558 ec = new VarExp(0, fd); | 1555 ec = new VarExp(0, fd); |
1559 e = e->castTo(sc, n->arrayOf()); // convert to dynamic array | 1556 e = e->castTo(sc, n->arrayOf()); // convert to dynamic array |
1560 arguments = new Expressions(); | 1557 arguments = new Expressions(); |
1561 if (dup) | 1558 if (dup) |
1562 arguments->push(getTypeInfo(sc)); | 1559 arguments->push(getTypeInfo(sc)); |
1570 { | 1567 { |
1571 Expression *ec; | 1568 Expression *ec; |
1572 FuncDeclaration *fd; | 1569 FuncDeclaration *fd; |
1573 Expressions *arguments; | 1570 Expressions *arguments; |
1574 | 1571 |
1575 fd = FuncDeclaration::genCfunc(tint32->arrayOf(), | 1572 fd = FuncDeclaration::genCfunc(Type::tvoid->arrayOf(), |
1576 (char*)(n->ty == Tbit ? "_adSortBit" : "_adSort")); | 1573 (char*)(n->ty == Tbit ? "_adSortBit" : "_adSort")); |
1577 fd->llvmRunTimeHack = true; | 1574 fd->llvmRunTimeHack = true; |
1578 ((TypeFunction*)fd->type)->llvmRetInPtr = true; | |
1579 ec = new VarExp(0, fd); | 1575 ec = new VarExp(0, fd); |
1580 e = e->castTo(sc, n->arrayOf()); // convert to dynamic array | 1576 e = e->castTo(sc, n->arrayOf()); // convert to dynamic array |
1581 arguments = new Expressions(); | 1577 arguments = new Expressions(); |
1582 arguments->push(e); | 1578 arguments->push(e); |
1583 if (next->ty != Tbit) | 1579 if (next->ty != Tbit) |
2275 Expression *ec; | 2271 Expression *ec; |
2276 FuncDeclaration *fd; | 2272 FuncDeclaration *fd; |
2277 Expressions *arguments; | 2273 Expressions *arguments; |
2278 | 2274 |
2279 fd = FuncDeclaration::genCfunc(Type::tsize_t, Id::aaLen); | 2275 fd = FuncDeclaration::genCfunc(Type::tsize_t, Id::aaLen); |
2276 fd->llvmRunTimeHack = true; | |
2280 ec = new VarExp(0, fd); | 2277 ec = new VarExp(0, fd); |
2281 arguments = new Expressions(); | 2278 arguments = new Expressions(); |
2282 arguments->push(e); | 2279 arguments->push(e); |
2283 e = new CallExp(e->loc, ec, arguments); | 2280 e = new CallExp(e->loc, ec, arguments); |
2284 e->type = fd->type->next; | 2281 e->type = fd->type->next; |
2289 FuncDeclaration *fd; | 2286 FuncDeclaration *fd; |
2290 Expressions *arguments; | 2287 Expressions *arguments; |
2291 int size = key->size(e->loc); | 2288 int size = key->size(e->loc); |
2292 | 2289 |
2293 assert(size); | 2290 assert(size); |
2294 fd = FuncDeclaration::genCfunc(Type::tindex, Id::aaKeys); | 2291 fd = FuncDeclaration::genCfunc(Type::tvoid->arrayOf(), Id::aaKeys); |
2292 fd->llvmRunTimeHack = true; | |
2295 ec = new VarExp(0, fd); | 2293 ec = new VarExp(0, fd); |
2296 arguments = new Expressions(); | 2294 arguments = new Expressions(); |
2297 arguments->push(e); | 2295 arguments->push(e); |
2298 arguments->push(new IntegerExp(0, size, Type::tsize_t)); | 2296 arguments->push(new IntegerExp(0, size, Type::tsize_t)); |
2299 e = new CallExp(e->loc, ec, arguments); | 2297 e = new CallExp(e->loc, ec, arguments); |
2303 { | 2301 { |
2304 Expression *ec; | 2302 Expression *ec; |
2305 FuncDeclaration *fd; | 2303 FuncDeclaration *fd; |
2306 Expressions *arguments; | 2304 Expressions *arguments; |
2307 | 2305 |
2308 fd = FuncDeclaration::genCfunc(Type::tindex, Id::aaValues); | 2306 fd = FuncDeclaration::genCfunc(Type::tvoid->arrayOf(), Id::aaValues); |
2307 fd->llvmRunTimeHack = true; | |
2309 ec = new VarExp(0, fd); | 2308 ec = new VarExp(0, fd); |
2310 arguments = new Expressions(); | 2309 arguments = new Expressions(); |
2311 arguments->push(e); | 2310 arguments->push(e); |
2312 size_t keysize = key->size(e->loc); | 2311 size_t keysize = key->size(e->loc); |
2313 keysize = (keysize + 3) & ~3; // BUG: 64 bit pointers? | 2312 keysize = (keysize + 4 - 1) & ~(4 - 1); |
2314 arguments->push(new IntegerExp(0, keysize, Type::tsize_t)); | 2313 arguments->push(new IntegerExp(0, keysize, Type::tsize_t)); |
2315 arguments->push(new IntegerExp(0, next->size(e->loc), Type::tsize_t)); | 2314 arguments->push(new IntegerExp(0, next->size(e->loc), Type::tsize_t)); |
2316 e = new CallExp(e->loc, ec, arguments); | 2315 e = new CallExp(e->loc, ec, arguments); |
2317 e->type = next->arrayOf(); | 2316 e->type = next->arrayOf(); |
2318 } | 2317 } |
2320 { | 2319 { |
2321 Expression *ec; | 2320 Expression *ec; |
2322 FuncDeclaration *fd; | 2321 FuncDeclaration *fd; |
2323 Expressions *arguments; | 2322 Expressions *arguments; |
2324 | 2323 |
2325 fd = FuncDeclaration::genCfunc(Type::tint64, Id::aaRehash); | 2324 fd = FuncDeclaration::genCfunc(Type::tvoid->pointerTo(), Id::aaRehash); |
2325 fd->llvmRunTimeHack = true; | |
2326 ec = new VarExp(0, fd); | 2326 ec = new VarExp(0, fd); |
2327 arguments = new Expressions(); | 2327 arguments = new Expressions(); |
2328 arguments->push(e->addressOf(sc)); | 2328 arguments->push(e->addressOf(sc)); |
2329 arguments->push(key->getInternalTypeInfo(sc)); | 2329 arguments->push(key->getInternalTypeInfo(sc)); |
2330 e = new CallExp(e->loc, ec, arguments); | 2330 e = new CallExp(e->loc, ec, arguments); |