From 301b832e9795f59117e7bedcac13f9c36487dec5 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Thu, 4 Aug 2022 21:07:55 -0700 Subject: [PATCH] expr: remove unused parameters from 'Exdisc_t.convertf' I guess when I committed 17479ab6569d40a4778870f712226aa7916f3ca3 it was not obvious to me that this is entirely part of private internal interfaces and the callback signature involved is not exposed publicly. --- lib/expr/exeval.c | 32 ++++++++------------------------ lib/expr/exgram.h | 8 ++++---- lib/expr/expr.h | 2 +- lib/gvpr/compile.c | 9 +-------- 4 files changed, 14 insertions(+), 37 deletions(-) diff --git a/lib/expr/exeval.c b/lib/expr/exeval.c index 752e2bd40..2d35b5f85 100644 --- a/lib/expr/exeval.c +++ b/lib/expr/exeval.c @@ -1083,9 +1083,7 @@ xConvert(Expr_t * ex, Exnode_t * expr, int type, Extype_t v, { *tmp = *expr->data.operand.left; tmp->data.constant.value = v; - if (ex->disc->convertf(ex, tmp, type, expr->data.operand.right - ? expr->data.operand.right->data.variable.symbol - : NULL, 0, ex->disc)) { + if (ex->disc->convertf(tmp, type, 0)) { exerror("%s: cannot convert %s value to %s", expr->data.operand.left->data.variable.symbol->name, extypename(ex, expr->data.operand.left->type), extypename(ex, type)); @@ -1701,9 +1699,7 @@ eval(Expr_t* ex, Exnode_t* expr, void* env) { tmp.data.constant.value.string = exprintf(ex->ve, "%g", v.floating); } - else if (ex->disc->convertf(ex, &tmp, STRING, expr->data.operand.right - ? expr->data.operand.right->data.variable.symbol - : NULL, 0, ex->disc)) { + else if (ex->disc->convertf(&tmp, STRING, 0)) { tmp.data.constant.value.string = exprintf(ex->ve, "%g", v.floating); } tmp.type = STRING; @@ -1711,9 +1707,7 @@ eval(Expr_t* ex, Exnode_t* expr, void* env) case F2X: tmp = *expr->data.operand.left; tmp.data.constant.value = v; - if (ex->disc->convertf(ex, &tmp, expr->type, expr->data.operand.right - ? expr->data.operand.right->data.variable.symbol - : NULL, 0, ex->disc)) + if (ex->disc->convertf(&tmp, expr->type, 0)) exerror("%s: cannot convert floating value to external", tmp.data.variable.symbol->name); tmp.type = expr->type; return tmp.data.constant.value; @@ -1856,9 +1850,7 @@ eval(Expr_t* ex, Exnode_t* expr, void* env) str = exprintf(ex->ve, "%lld", (long long)v.integer); tmp.data.constant.value.string = str; } - else if (ex->disc->convertf(ex, &tmp, STRING, expr->data.operand.right - ? expr->data.operand.right->data.variable.symbol - : NULL, 0, ex->disc)) { + else if (ex->disc->convertf(&tmp, STRING, 0)) { char *str = NULL; if (expr->data.operand.left->type == UNSIGNED) str = exprintf(ex->ve, "%llu", (unsigned long long)v.integer); @@ -1871,9 +1863,7 @@ eval(Expr_t* ex, Exnode_t* expr, void* env) case I2X: tmp = *expr->data.operand.left; tmp.data.constant.value = v; - if (ex->disc->convertf(ex, &tmp, expr->type, expr->data.operand.right - ? expr->data.operand.right->data.variable.symbol - : NULL, 0, ex->disc)) + if (ex->disc->convertf(&tmp, expr->type, 0)) exerror("%s: cannot convert integer value to external", tmp.data.variable.symbol->name); tmp.type = expr->type; return tmp.data.constant.value; @@ -1951,9 +1941,7 @@ eval(Expr_t* ex, Exnode_t* expr, void* env) case S2F: tmp = *expr->data.operand.left; tmp.data.constant.value = v; - if (ex->disc->convertf(ex, &tmp, FLOATING, expr->data.operand.right - ? expr->data.operand.right->data.variable.symbol - : NULL, 0, ex->disc)) + if (ex->disc->convertf(&tmp, FLOATING, 0)) { tmp.data.constant.value.floating = strtod(v.string, &e); if (*e) @@ -1964,9 +1952,7 @@ eval(Expr_t* ex, Exnode_t* expr, void* env) case S2I: tmp = *expr->data.operand.left; tmp.data.constant.value = v; - if (ex->disc->convertf(ex, &tmp, INTEGER, expr->data.operand.right - ? expr->data.operand.right->data.variable.symbol - : NULL, 0, ex->disc)) + if (ex->disc->convertf(&tmp, INTEGER, 0)) { if (v.string) { tmp.data.constant.value.integer = strtoll(v.string, &e, 0); @@ -1981,9 +1967,7 @@ eval(Expr_t* ex, Exnode_t* expr, void* env) case S2X: tmp = *expr->data.operand.left; tmp.data.constant.value = v; - if (ex->disc->convertf(ex, &tmp, expr->type, expr->data.operand.right - ? expr->data.operand.right->data.variable.symbol - : NULL, 0, ex->disc)) + if (ex->disc->convertf(&tmp, expr->type, 0)) exerror("%s: cannot convert string value to external", tmp.data.variable.symbol->name); tmp.type = expr->type; return tmp.data.constant.value; diff --git a/lib/expr/exgram.h b/lib/expr/exgram.h index 680bd5c49..ae67380ed 100644 --- a/lib/expr/exgram.h +++ b/lib/expr/exgram.h @@ -464,7 +464,7 @@ excast(Expr_t* p, Exnode_t* x, int type, Exnode_t* xref, int arg) Exid_t *sym = (xref ? xref->data.variable.symbol : NULL); if (EXTERNAL(t2t)) { int a = (arg ? arg : 1); - if ((*p->disc->convertf) (p, x, type, sym, a, p->disc) < 0) { + if ((*p->disc->convertf) (x, type, a) < 0) { if (xref) { if ((sym->lex == FUNCTION) && arg) exerror ("%s: cannot use value of type %s as argument %d in function %s", @@ -494,10 +494,10 @@ excast(Expr_t* p, Exnode_t* x, int type, Exnode_t* xref, int arg) case X2X: if (xref && xref->op == ID) { - if ((*p->disc->convertf)(p, x, type, xref->data.variable.symbol, arg, p->disc) < 0) + if ((*p->disc->convertf)(x, type, arg) < 0) exerror("%s: cannot cast constant %s to %s", xref->data.variable.symbol->name, extypename(p, x->type), extypename(p, type)); } - else if ((*p->disc->convertf)(p, x, type, NULL, arg, p->disc) < 0) + else if ((*p->disc->convertf)(x, type, arg) < 0) exerror("cannot cast constant %s to %s", extypename(p, x->type), extypename(p, type)); break; case F2I: @@ -785,7 +785,7 @@ preprint(Exnode_t* args) { if (x->arg->op == CONSTANT && x->arg->data.constant.reference && expr.program->disc->convertf) { - if ((*expr.program->disc->convertf)(expr.program, x->arg, STRING, x->arg->data.constant.reference, 0, expr.program->disc) < 0) + if ((*expr.program->disc->convertf)(x->arg, STRING, 0) < 0) exerror("cannot convert string format argument"); else x->arg->data.constant.value.string = vmstrdup(expr.program->vm, x->arg->data.constant.value.string); } diff --git a/lib/expr/expr.h b/lib/expr/expr.h index fe6aa21c9..013bf19ab 100644 --- a/lib/expr/expr.h +++ b/lib/expr/expr.h @@ -202,7 +202,7 @@ struct Exdisc_s /* discipline */ char* type; /* pathfind() type */ int (*castf)(Expr_t*, Exnode_t*, const char*, int, Exid_t*, int, Exdisc_t*); /* unknown cast function */ - int (*convertf)(Expr_t*, Exnode_t*, int, Exid_t*, int, Exdisc_t*); + int (*convertf)(Exnode_t*, int, int); /* type conversion function */ int (*binaryf) (Expr_t *, Exnode_t *, Exnode_t *, Exnode_t *, int, Exdisc_t *); /* binary operator function */ diff --git a/lib/gvpr/compile.c b/lib/gvpr/compile.c index 2f3fdca41..cdf42bb3d 100644 --- a/lib/gvpr/compile.c +++ b/lib/gvpr/compile.c @@ -2136,14 +2136,7 @@ static int stringOf(Expr_t * prog, Exnode_t * x, int arg, Exdisc_t* disc) * If arg is > 0, conversion unnecessary; just report possibility. * In particular, assume x != 0 if arg == 0. */ -static int -convert(Expr_t * prog, Exnode_t * x, int type, - Exid_t * xref, int arg, Exdisc_t * disc) -{ - (void)prog; - (void)xref; - (void)disc; - +static int convert(Exnode_t *x, int type, int arg) { Agobj_t *objp; int ret = -1; -- 2.40.0