From eb56e934a5a7cbd9858473c1bb659d47ab130105 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Fri, 4 Jan 2013 05:38:35 +0100 Subject: [PATCH] Restore original Parameter::ForeachDg signature. Having two functions is not pretty, but shorter than messing around with a custom context object, and much, MUCH better than requiring a lot of changes to the rest of the code base. --- dmd2/func.c | 2 +- dmd2/mtype.c | 36 +++++++++++++++++++++++++----------- dmd2/mtype.h | 4 ++-- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/dmd2/func.c b/dmd2/func.c index 3c20e5b4..7a7b55bc 100644 --- a/dmd2/func.c +++ b/dmd2/func.c @@ -149,7 +149,7 @@ Dsymbol *FuncDeclaration::syntaxCopy(Dsymbol *s) } #if IN_LLVM -static int outToRefDg(void *ctx, size_t n, Parameter *p, int flags) +static int outToRefDg(void *ctx, size_t n, Parameter *p) { if (p->storageClass & STCout) { diff --git a/dmd2/mtype.c b/dmd2/mtype.c index 3f7dcbbf..37ac5bc8 100644 --- a/dmd2/mtype.c +++ b/dmd2/mtype.c @@ -9716,19 +9716,33 @@ void Parameter::argsToCBuffer(OutBuffer *buf, HdrGenState *hgs, Parameters *argu buf->writeByte(')'); } -static const int mangleFlag = 0x01; - -static int argsToDecoBufferDg(void *ctx, size_t n, Parameter *arg, int flags) +static int argsToDecoBufferDg(void *ctx, size_t n, Parameter *arg) { - arg->toDecoBuffer((OutBuffer *)ctx, flags & mangleFlag); +#if IN_LLVM + arg->toDecoBuffer((OutBuffer *)ctx, false); +#else + arg->toDecoBuffer((OutBuffer *)ctx); +#endif return 0; } +#if IN_LLVM +static int argsToDecoBufferDg2(void *ctx, size_t n, Parameter *arg) +{ + arg->toDecoBuffer((OutBuffer *)ctx, true); + return 0; +} +#endif + void Parameter::argsToDecoBuffer(OutBuffer *buf, Parameters *arguments, bool mangle) { //printf("Parameter::argsToDecoBuffer()\n"); // Write argument types - foreach(arguments, &argsToDecoBufferDg, buf, 0, mangle ? mangleFlag : 0); +#if IN_LLVM + foreach(arguments, mangle ? &argsToDecoBufferDg2 : &argsToDecoBufferDg, buf); +#else + foreach(arguments, &argsToDecoBufferDg, buf); +#endif } /**************************************** @@ -9736,7 +9750,7 @@ void Parameter::argsToDecoBuffer(OutBuffer *buf, Parameters *arguments, bool man * (i.e. it has auto or alias parameters) */ -static int isTPLDg(void *ctx, size_t n, Parameter *arg, int) +static int isTPLDg(void *ctx, size_t n, Parameter *arg) { if (arg->storageClass & (STCalias | STCauto | STCstatic)) return 1; @@ -9817,7 +9831,7 @@ void Parameter::toDecoBuffer(OutBuffer *buf, bool mangle) * Determine number of arguments, folding in tuples. */ -static int dimDg(void *ctx, size_t n, Parameter *, int) +static int dimDg(void *ctx, size_t n, Parameter *) { ++*(size_t *)ctx; return 0; @@ -9844,7 +9858,7 @@ struct GetNthParamCtx Parameter *arg; }; -static int getNthParamDg(void *ctx, size_t n, Parameter *arg, int) +static int getNthParamDg(void *ctx, size_t n, Parameter *arg) { GetNthParamCtx *p = (GetNthParamCtx *)ctx; if (n == p->nth) @@ -9869,7 +9883,7 @@ Parameter *Parameter::getNth(Parameters *args, size_t nth, size_t *pn) * calculating dim and calling N times getNth. */ -int Parameter::foreach(Parameters *args, Parameter::ForeachDg dg, void *ctx, size_t *pn, int flags) +int Parameter::foreach(Parameters *args, Parameter::ForeachDg dg, void *ctx, size_t *pn) { assert(dg); if (!args) @@ -9883,10 +9897,10 @@ int Parameter::foreach(Parameters *args, Parameter::ForeachDg dg, void *ctx, siz if (t->ty == Ttuple) { TypeTuple *tu = (TypeTuple *)t; - result = foreach(tu->arguments, dg, ctx, &n, flags); + result = foreach(tu->arguments, dg, ctx, &n); } else - result = dg(ctx, n++, arg, flags); + result = dg(ctx, n++, arg); if (result) break; diff --git a/dmd2/mtype.h b/dmd2/mtype.h index a60d70cc..50142416 100644 --- a/dmd2/mtype.h +++ b/dmd2/mtype.h @@ -1075,8 +1075,8 @@ struct Parameter : Object static size_t dim(Parameters *arguments); static Parameter *getNth(Parameters *arguments, size_t nth, size_t *pn = NULL); - typedef int (*ForeachDg)(void *ctx, size_t paramidx, Parameter *param, int flags); - static int foreach(Parameters *args, ForeachDg dg, void *ctx, size_t *pn=NULL, int flags = 0); + typedef int (*ForeachDg)(void *ctx, size_t paramidx, Parameter *param); + static int foreach(Parameters *args, ForeachDg dg, void *ctx, size_t *pn=NULL); }; extern int PTRSIZE;