comparison dmd/statement.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 a7a26f538d6e
children d632801b15f0
comparison
equal deleted inserted replaced
377:4731f3eed1f0 378:d8234836b40f
1596 error("foreach: value must be type %s, not %s", taa->nextOf()->toChars(), arg->type->toChars()); 1596 error("foreach: value must be type %s, not %s", taa->nextOf()->toChars(), arg->type->toChars());
1597 1597
1598 /* Call: 1598 /* Call:
1599 * _aaApply(aggr, keysize, flde) 1599 * _aaApply(aggr, keysize, flde)
1600 */ 1600 */
1601 if (dim == 2) 1601 //LLVMDC: Build arguments.
1602 fdapply = FuncDeclaration::genCfunc(Type::tindex, "_aaApply2"); 1602 Arguments* args = new Arguments;
1603 else 1603 args->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
1604 fdapply = FuncDeclaration::genCfunc(Type::tindex, "_aaApply"); 1604 args->push(new Argument(STCin, Type::tsize_t, NULL, NULL));
1605 fdapply->runTimeHack = true; 1605 if (dim == 2) {
1606 Arguments* dgargs = new Arguments;
1607 dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
1608 dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
1609 TypeDelegate* dgty = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd));
1610 args->push(new Argument(STCin, dgty, NULL, NULL));
1611 fdapply = FuncDeclaration::genCfunc(args, Type::tindex, "_aaApply2");
1612 } else {
1613 Arguments* dgargs = new Arguments;
1614 dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
1615 TypeDelegate* dgty = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd));
1616 args->push(new Argument(STCin, dgty, NULL, NULL));
1617 fdapply = FuncDeclaration::genCfunc(args, Type::tindex, "_aaApply");
1618 }
1606 ec = new VarExp(0, fdapply); 1619 ec = new VarExp(0, fdapply);
1607 Expressions *exps = new Expressions(); 1620 Expressions *exps = new Expressions();
1608 exps->push(aggr); 1621 exps->push(aggr);
1609 size_t keysize = taa->key->size(); 1622 size_t keysize = taa->key->size();
1610 keysize = (keysize + 3) & ~3; 1623 keysize = (keysize + 3) & ~3;
1641 default: assert(0); 1654 default: assert(0);
1642 } 1655 }
1643 const char *r = (op == TOKforeach_reverse) ? "R" : ""; 1656 const char *r = (op == TOKforeach_reverse) ? "R" : "";
1644 int j = sprintf(fdname, "_aApply%s%.*s%d", r, 2, fntab[flag], dim); 1657 int j = sprintf(fdname, "_aApply%s%.*s%d", r, 2, fntab[flag], dim);
1645 assert(j < sizeof(fdname)); 1658 assert(j < sizeof(fdname));
1646 fdapply = FuncDeclaration::genCfunc(Type::tindex, fdname); 1659 //LLVMDC: Build arguments.
1647 fdapply->runTimeHack = true; 1660 Arguments* args = new Arguments;
1661 args->push(new Argument(STCin, Type::tvoid->arrayOf(), NULL, NULL));
1662 if (dim == 2) {
1663 Arguments* dgargs = new Arguments;
1664 dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
1665 dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
1666 TypeDelegate* dgty = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd));
1667 args->push(new Argument(STCin, dgty, NULL, NULL));
1668 fdapply = FuncDeclaration::genCfunc(args, Type::tindex, fdname);
1669 } else {
1670 Arguments* dgargs = new Arguments;
1671 dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
1672 TypeDelegate* dgty = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd));
1673 args->push(new Argument(STCin, dgty, NULL, NULL));
1674 fdapply = FuncDeclaration::genCfunc(args, Type::tindex, fdname);
1675 }
1648 1676
1649 ec = new VarExp(0, fdapply); 1677 ec = new VarExp(0, fdapply);
1650 Expressions *exps = new Expressions(); 1678 Expressions *exps = new Expressions();
1651 if (tab->ty == Tsarray) 1679 if (tab->ty == Tsarray)
1652 aggr = aggr->castTo(sc, tn->arrayOf()); 1680 aggr = aggr->castTo(sc, tn->arrayOf());