diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-08-07 21:07:40 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-08-07 22:02:42 +0200 |
commit | b0bd7d895a023b2ff71231ae7c1c5aee690f8a2a (patch) | |
tree | bb25771b3112384795b0316d1899e76320ba67ad | |
parent | 0819ba9b1047fb8cf9d094fedb3d1fb94e7d3bfa (diff) | |
download | sparse-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.c | 7 | ||||
-rw-r--r-- | evaluate.h | 7 |
2 files changed, 10 insertions, 4 deletions
@@ -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); @@ -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 |