From 07bc6f3abd6f1b16d3b7476a84aa127b56bb1233 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Fri, 23 Jul 2004 22:35:45 -0700 Subject: [PATCH] [PATCH] evaluate_conditional() prepared for FP preparation for FP - we will be replacing conversions from FP to boolean with explicit foo != 0.0 and !foo with foo == 0.0; that way a bunch of places won't have to think of FP at all and uses of FP in boolean contexts are rare enough to warrant that. So we switch evaluate_conditional() to getting a struct expression **, which will allow such rewriting. --- evaluate.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/evaluate.c b/evaluate.c index 0d31721c..990a5957 100644 --- a/evaluate.c +++ b/evaluate.c @@ -551,9 +551,10 @@ static struct symbol *evaluate_sub(struct expression *expr) #define is_safe_type(type) ((type)->ctype.modifiers & MOD_SAFE) -static struct symbol *evaluate_conditional(struct expression *expr) +static struct symbol *evaluate_conditional(struct expression **p) { struct symbol *ctype; + struct expression *expr = *p; if (!expr) return NULL; @@ -570,9 +571,9 @@ static struct symbol *evaluate_conditional(struct expression *expr) static struct symbol *evaluate_logical(struct expression *expr) { - if (!evaluate_conditional(expr->left)) + if (!evaluate_conditional(&expr->left)) return NULL; - if (!evaluate_conditional(expr->right)) + if (!evaluate_conditional(&expr->right)) return NULL; expr->ctype = &bool_ctype; @@ -1713,7 +1714,7 @@ struct symbol *evaluate_expression(struct expression *expr) warn(expr->pos, "bitfield generated by parser"); return NULL; case EXPR_CONDITIONAL: - if (!evaluate_conditional(expr->conditional)) + if (!evaluate_conditional(&expr->conditional)) return NULL; if (!evaluate_expression(expr->cond_false)) return NULL; @@ -1827,13 +1828,12 @@ struct symbol *evaluate_return_expression(struct statement *stmt) static void evaluate_if_statement(struct statement *stmt) { - struct expression *expr = stmt->if_conditional; struct symbol *ctype; - if (!expr) + if (!stmt->if_conditional) return; - ctype = evaluate_conditional(expr); + ctype = evaluate_conditional(&stmt->if_conditional); if (!ctype) return; @@ -1879,8 +1879,8 @@ struct symbol *evaluate_statement(struct statement *stmt) evaluate_if_statement(stmt); return NULL; case STMT_ITERATOR: - evaluate_conditional(stmt->iterator_pre_condition); - evaluate_conditional(stmt->iterator_post_condition); + evaluate_conditional(&stmt->iterator_pre_condition); + evaluate_conditional(&stmt->iterator_post_condition); evaluate_statement(stmt->iterator_pre_statement); evaluate_statement(stmt->iterator_statement); evaluate_statement(stmt->iterator_post_statement); -- 2.11.4.GIT