comparison dmd/mtype.c @ 378:d8234836b40f

Get rid of runTimeHack and instead add proper argument info to the frontend declatation.
author Christian Kamm <kamm incasoftware de>
date Tue, 22 Jul 2008 19:24:40 +0200
parents 3c4460b988bd
children d632801b15f0
comparison
equal deleted inserted replaced
377:4731f3eed1f0 378:d8234836b40f
1534 Expressions *arguments; 1534 Expressions *arguments;
1535 char *nm; 1535 char *nm;
1536 static char *name[2] = { "_adReverseChar", "_adReverseWchar" }; 1536 static char *name[2] = { "_adReverseChar", "_adReverseWchar" };
1537 1537
1538 nm = name[n->ty == Twchar]; 1538 nm = name[n->ty == Twchar];
1539 fd = FuncDeclaration::genCfunc(Type::tvoid->arrayOf(), nm); 1539 //LLVMDC: Build arguments.
1540 fd->runTimeHack = true; 1540 Arguments* args = new Arguments;
1541 Type* arrty = n->ty == Twchar ? Type::tchar->arrayOf() : Type::twchar->arrayOf();
1542 args->push(new Argument(STCin, arrty, NULL, NULL));
1543 fd = FuncDeclaration::genCfunc(args, Type::tvoid->arrayOf(), nm);
1544
1541 ec = new VarExp(0, fd); 1545 ec = new VarExp(0, fd);
1542 e = e->castTo(sc, n->arrayOf()); // convert to dynamic array 1546 e = e->castTo(sc, n->arrayOf()); // convert to dynamic array
1543 arguments = new Expressions(); 1547 arguments = new Expressions();
1544 arguments->push(e); 1548 arguments->push(e);
1545 e = new CallExp(e->loc, ec, arguments); 1549 e = new CallExp(e->loc, ec, arguments);
1552 Expressions *arguments; 1556 Expressions *arguments;
1553 char *nm; 1557 char *nm;
1554 static char *name[2] = { "_adSortChar", "_adSortWchar" }; 1558 static char *name[2] = { "_adSortChar", "_adSortWchar" };
1555 1559
1556 nm = name[n->ty == Twchar]; 1560 nm = name[n->ty == Twchar];
1557 fd = FuncDeclaration::genCfunc(Type::tvoid->arrayOf(), nm); 1561 //LLVMDC: Build arguments.
1558 fd->runTimeHack = true; 1562 Arguments* args = new Arguments;
1563 Type* arrty = n->ty == Twchar ? Type::tchar->arrayOf() : Type::twchar->arrayOf();
1564 args->push(new Argument(STCin, arrty, NULL, NULL));
1565 fd = FuncDeclaration::genCfunc(args, Type::tvoid->arrayOf(), nm);
1566
1559 ec = new VarExp(0, fd); 1567 ec = new VarExp(0, fd);
1560 e = e->castTo(sc, n->arrayOf()); // convert to dynamic array 1568 e = e->castTo(sc, n->arrayOf()); // convert to dynamic array
1561 arguments = new Expressions(); 1569 arguments = new Expressions();
1562 arguments->push(e); 1570 arguments->push(e);
1563 e = new CallExp(e->loc, ec, arguments); 1571 e = new CallExp(e->loc, ec, arguments);
1571 int size = next->size(e->loc); 1579 int size = next->size(e->loc);
1572 int dup; 1580 int dup;
1573 1581
1574 assert(size); 1582 assert(size);
1575 dup = (ident == Id::dup); 1583 dup = (ident == Id::dup);
1576 fd = FuncDeclaration::genCfunc(Type::tvoid->arrayOf(), dup ? Id::adDup : Id::adReverse); 1584 //LLVMDC: Build arguments.
1577 fd->runTimeHack = true; 1585 Arguments* args = new Arguments;
1586 if(dup) {
1587 args->push(new Argument(STCin, Type::typeinfo->type, NULL, NULL));
1588 args->push(new Argument(STCin, Type::tvoid->arrayOf(), NULL, NULL));
1589 } else {
1590 args->push(new Argument(STCin, Type::tvoid->arrayOf(), NULL, NULL));
1591 args->push(new Argument(STCin, Type::tsize_t, NULL, NULL));
1592 }
1593 fd = FuncDeclaration::genCfunc(args, Type::tvoid->arrayOf(), dup ? Id::adDup : Id::adReverse);
1578 ec = new VarExp(0, fd); 1594 ec = new VarExp(0, fd);
1579 e = e->castTo(sc, n->arrayOf()); // convert to dynamic array 1595 e = e->castTo(sc, n->arrayOf()); // convert to dynamic array
1580 arguments = new Expressions(); 1596 arguments = new Expressions();
1581 if (dup) 1597 if (dup)
1582 arguments->push(getTypeInfo(sc)); 1598 arguments->push(getTypeInfo(sc));
1590 { 1606 {
1591 Expression *ec; 1607 Expression *ec;
1592 FuncDeclaration *fd; 1608 FuncDeclaration *fd;
1593 Expressions *arguments; 1609 Expressions *arguments;
1594 1610
1595 fd = FuncDeclaration::genCfunc(Type::tvoid->arrayOf(), 1611 //LLVMDC: Build arguments.
1612 Arguments* args = new Arguments;
1613 args->push(new Argument(STCin, Type::tvoid->arrayOf(), NULL, NULL));
1614 args->push(new Argument(STCin, Type::typeinfo->type, NULL, NULL));
1615 fd = FuncDeclaration::genCfunc(args, Type::tvoid->arrayOf(),
1596 (char*)(n->ty == Tbit ? "_adSortBit" : "_adSort")); 1616 (char*)(n->ty == Tbit ? "_adSortBit" : "_adSort"));
1597 fd->runTimeHack = true;
1598 ec = new VarExp(0, fd); 1617 ec = new VarExp(0, fd);
1599 e = e->castTo(sc, n->arrayOf()); // convert to dynamic array 1618 e = e->castTo(sc, n->arrayOf()); // convert to dynamic array
1600 arguments = new Expressions(); 1619 arguments = new Expressions();
1601 arguments->push(e); 1620 arguments->push(e);
1602 if (next->ty != Tbit) 1621 if (next->ty != Tbit)
2266 { 2285 {
2267 Expression *ec; 2286 Expression *ec;
2268 FuncDeclaration *fd; 2287 FuncDeclaration *fd;
2269 Expressions *arguments; 2288 Expressions *arguments;
2270 2289
2271 fd = FuncDeclaration::genCfunc(Type::tsize_t, Id::aaLen); 2290 //LLVMDC: Build arguments.
2272 fd->runTimeHack = true; 2291 Arguments* args = new Arguments;
2292 args->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
2293 fd = FuncDeclaration::genCfunc(args, Type::tsize_t, Id::aaLen);
2273 ec = new VarExp(0, fd); 2294 ec = new VarExp(0, fd);
2274 arguments = new Expressions(); 2295 arguments = new Expressions();
2275 arguments->push(e); 2296 arguments->push(e);
2276 e = new CallExp(e->loc, ec, arguments); 2297 e = new CallExp(e->loc, ec, arguments);
2277 e->type = fd->type->next; 2298 e->type = fd->type->next;
2282 FuncDeclaration *fd; 2303 FuncDeclaration *fd;
2283 Expressions *arguments; 2304 Expressions *arguments;
2284 int size = key->size(e->loc); 2305 int size = key->size(e->loc);
2285 2306
2286 assert(size); 2307 assert(size);
2287 fd = FuncDeclaration::genCfunc(Type::tvoid->arrayOf(), Id::aaKeys); 2308 //LLVMDC: Build arguments.
2288 fd->runTimeHack = true; 2309 Arguments* args = new Arguments;
2310 args->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
2311 args->push(new Argument(STCin, Type::tsize_t, NULL, NULL));
2312 fd = FuncDeclaration::genCfunc(args, Type::tvoid->arrayOf(), Id::aaKeys);
2289 ec = new VarExp(0, fd); 2313 ec = new VarExp(0, fd);
2290 arguments = new Expressions(); 2314 arguments = new Expressions();
2291 arguments->push(e); 2315 arguments->push(e);
2292 arguments->push(new IntegerExp(0, size, Type::tsize_t)); 2316 arguments->push(new IntegerExp(0, size, Type::tsize_t));
2293 e = new CallExp(e->loc, ec, arguments); 2317 e = new CallExp(e->loc, ec, arguments);
2297 { 2321 {
2298 Expression *ec; 2322 Expression *ec;
2299 FuncDeclaration *fd; 2323 FuncDeclaration *fd;
2300 Expressions *arguments; 2324 Expressions *arguments;
2301 2325
2302 fd = FuncDeclaration::genCfunc(Type::tvoid->arrayOf(), Id::aaValues); 2326 //LLVMDC: Build arguments.
2303 fd->runTimeHack = true; 2327 Arguments* args = new Arguments;
2328 args->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
2329 args->push(new Argument(STCin, Type::tsize_t, NULL, NULL));
2330 args->push(new Argument(STCin, Type::tsize_t, NULL, NULL));
2331 fd = FuncDeclaration::genCfunc(args, Type::tvoid->arrayOf(), Id::aaValues);
2304 ec = new VarExp(0, fd); 2332 ec = new VarExp(0, fd);
2305 arguments = new Expressions(); 2333 arguments = new Expressions();
2306 arguments->push(e); 2334 arguments->push(e);
2307 size_t keysize = key->size(e->loc); 2335 size_t keysize = key->size(e->loc);
2308 keysize = (keysize + 4 - 1) & ~(4 - 1); 2336 keysize = (keysize + 4 - 1) & ~(4 - 1);
2315 { 2343 {
2316 Expression *ec; 2344 Expression *ec;
2317 FuncDeclaration *fd; 2345 FuncDeclaration *fd;
2318 Expressions *arguments; 2346 Expressions *arguments;
2319 2347
2320 fd = FuncDeclaration::genCfunc(Type::tvoid->pointerTo(), Id::aaRehash); 2348 //LLVMDC: Build arguments.
2321 fd->runTimeHack = true; 2349 Arguments* args = new Arguments;
2350 args->push(new Argument(STCin, Type::tvoidptr->pointerTo(), NULL, NULL));
2351 args->push(new Argument(STCin, Type::typeinfo->type, NULL, NULL));
2352 fd = FuncDeclaration::genCfunc(args, Type::tvoid->pointerTo(), Id::aaRehash);
2322 ec = new VarExp(0, fd); 2353 ec = new VarExp(0, fd);
2323 arguments = new Expressions(); 2354 arguments = new Expressions();
2324 arguments->push(e->addressOf(sc)); 2355 arguments->push(e->addressOf(sc));
2325 arguments->push(key->getInternalTypeInfo(sc)); 2356 arguments->push(key->getInternalTypeInfo(sc));
2326 e = new CallExp(e->loc, ec, arguments); 2357 e = new CallExp(e->loc, ec, arguments);