aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-08-07 21:07:40 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-08-07 22:02:42 +0200
commitb0bd7d895a023b2ff71231ae7c1c5aee690f8a2a (patch)
treebb25771b3112384795b0316d1899e76320ba67ad
parent0819ba9b1047fb8cf9d094fedb3d1fb94e7d3bfa (diff)
downloadsparse-b0bd7d895a023b2ff71231ae7c1c5aee690f8a2a.tar.gz
export evaluate_arguments()
evaluate_arguments() is local to evaluate.c but the same functionality is needed for builtins. So, in order to not duplicate this code: *) change slightly its interface to accept the expected types as a list *) make this function extern. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--evaluate.c7
-rw-r--r--evaluate.h7
2 files changed, 10 insertions, 4 deletions
diff --git a/evaluate.c b/evaluate.c
index dddea761..7c63cc60 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -2333,14 +2333,13 @@ static struct symbol *evaluate_alignof(struct expression *expr)
return size_t_ctype;
}
-static int evaluate_arguments(struct symbol *fn, struct expression_list *head)
+int evaluate_arguments(struct symbol_list *argtypes, struct expression_list *head)
{
struct expression *expr;
- struct symbol_list *argument_types = fn->arguments;
struct symbol *argtype;
int i = 1;
- PREPARE_PTR_LIST(argument_types, argtype);
+ PREPARE_PTR_LIST(argtypes, argtype);
FOR_EACH_PTR (head, expr) {
struct expression **p = THIS_ADDRESS(expr);
struct symbol *ctype, *target;
@@ -3149,7 +3148,7 @@ static struct symbol *evaluate_call(struct expression *expr)
if (!sym->op->args(expr))
return NULL;
} else {
- if (!evaluate_arguments(ctype, arglist))
+ if (!evaluate_arguments(ctype->arguments, arglist))
return NULL;
args = expression_list_size(expr->args);
fnargs = symbol_list_size(ctype->arguments);
diff --git a/evaluate.h b/evaluate.h
index f68f7fb7..a16e9703 100644
--- a/evaluate.h
+++ b/evaluate.h
@@ -2,6 +2,7 @@
#define EVALUATE_H
struct expression;
+struct expression_list;
struct statement;
struct symbol;
struct symbol_list;
@@ -25,4 +26,10 @@ struct symbol *evaluate_statement(struct statement *stmt);
// @list: the list of the symbol to be evaluated
void evaluate_symbol_list(struct symbol_list *list);
+///
+// evaluate the arguments of a function
+// @argtypes: the list of the types in the prototype
+// @args: the list of the effective arguments
+int evaluate_arguments(struct symbol_list *argtypes, struct expression_list *args);
+
#endif