diff 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
line wrap: on
line diff
--- a/dmd/statement.c	Mon Jul 21 20:36:03 2008 +0200
+++ b/dmd/statement.c	Tue Jul 22 19:24:40 2008 +0200
@@ -1598,11 +1598,24 @@
 		/* Call:
 		 *	_aaApply(aggr, keysize, flde)
 		 */
-		if (dim == 2)
-		    fdapply = FuncDeclaration::genCfunc(Type::tindex, "_aaApply2");
-		else
-		    fdapply = FuncDeclaration::genCfunc(Type::tindex, "_aaApply");
-        fdapply->runTimeHack = true;
+		//LLVMDC: Build arguments.
+		Arguments* args = new Arguments;
+		args->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
+		args->push(new Argument(STCin, Type::tsize_t, NULL, NULL));
+		if (dim == 2) {
+		    Arguments* dgargs = new Arguments;
+		    dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
+		    dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
+		    TypeDelegate* dgty = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd));
+		    args->push(new Argument(STCin, dgty, NULL, NULL));
+		    fdapply = FuncDeclaration::genCfunc(args, Type::tindex, "_aaApply2");
+		} else {
+		    Arguments* dgargs = new Arguments;
+		    dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
+		    TypeDelegate* dgty = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd));
+		    args->push(new Argument(STCin, dgty, NULL, NULL));
+		    fdapply = FuncDeclaration::genCfunc(args, Type::tindex, "_aaApply");
+		}
 		ec = new VarExp(0, fdapply);
 		Expressions *exps = new Expressions();
 		exps->push(aggr);
@@ -1643,8 +1656,23 @@
 		const char *r = (op == TOKforeach_reverse) ? "R" : "";
 		int j = sprintf(fdname, "_aApply%s%.*s%d", r, 2, fntab[flag], dim);
 		assert(j < sizeof(fdname));
-		fdapply = FuncDeclaration::genCfunc(Type::tindex, fdname);
-        fdapply->runTimeHack = true;
+		//LLVMDC: Build arguments.
+		Arguments* args = new Arguments;
+		args->push(new Argument(STCin, Type::tvoid->arrayOf(), NULL, NULL));
+		if (dim == 2) {
+		    Arguments* dgargs = new Arguments;
+		    dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
+		    dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
+		    TypeDelegate* dgty = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd));
+		    args->push(new Argument(STCin, dgty, NULL, NULL));
+		    fdapply = FuncDeclaration::genCfunc(args, Type::tindex, fdname);
+		} else {
+		    Arguments* dgargs = new Arguments;
+		    dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
+		    TypeDelegate* dgty = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd));
+		    args->push(new Argument(STCin, dgty, NULL, NULL));
+		    fdapply = FuncDeclaration::genCfunc(args, Type::tindex, fdname);
+		}
 
 		ec = new VarExp(0, fdapply);
 		Expressions *exps = new Expressions();