diff options
| author | Linus Torvalds <torvalds@home.osdl.org> | 2003-08-02 20:37:16 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:01:00 -0700 |
| commit | bdfb7140eaa2700fd3f9db4b46bb3fb9a5d537f7 (patch) | |
| tree | f4722c40b145cb596e3fe3a18c3f32113831b4a3 | |
| parent | 09ff8b4f71fe3013ec9086261ef02715be139492 (diff) | |
| download | sparse-dev-bdfb7140eaa2700fd3f9db4b46bb3fb9a5d537f7.tar.gz | |
More conversion from "iterate()" to an explicit FOR_EACH_PTR()
loop.
In particular, this cleans up the compound statement return
type handling a lot. It's just a lot more obvious with the
straigth loop, and no indirection through an iterator function.
| -rw-r--r-- | evaluate.c | 39 | ||||
| -rw-r--r-- | scope.c | 7 |
2 files changed, 27 insertions, 19 deletions
@@ -1399,20 +1399,6 @@ struct symbol *evaluate_expression(struct expression *expr) return NULL; } -static void evaluate_one_statement(struct statement *stmt, void *_last, int flags) -{ - struct symbol **last = _last; - struct symbol *type = evaluate_statement(stmt); - - if (flags & ITERATE_LAST) - *last = type; -} - -static void evaluate_one_symbol(struct symbol *sym, void *unused, int flags) -{ - evaluate_symbol(sym); -} - void check_duplicates(struct symbol *sym) { struct symbol *next = sym; @@ -1456,7 +1442,12 @@ struct symbol *evaluate_symbol(struct symbol *sym) /* And finally, evaluate the body of the symbol too */ if (base_type->type == SYM_FN) { - symbol_iterate(base_type->arguments, evaluate_one_symbol, NULL); + struct symbol *s; + + FOR_EACH_PTR(base_type->arguments, s) { + evaluate_symbol(s); + } END_FOR_EACH_PTR; + if (base_type->stmt) { current_fn = base_type; current_contextmask = sym->ctype.contextmask; @@ -1525,10 +1516,24 @@ struct symbol *evaluate_statement(struct statement *stmt) return evaluate_expression(stmt->expression); case STMT_COMPOUND: { + struct statement *s; struct symbol *type = NULL; - symbol_iterate(stmt->syms, evaluate_one_symbol, NULL); + struct symbol *sym; + + /* Evaluate each symbol in the compound statement */ + FOR_EACH_PTR(stmt->syms, sym) { + evaluate_symbol(sym); + } END_FOR_EACH_PTR; evaluate_symbol(stmt->ret); - statement_iterate(stmt->stmts, evaluate_one_statement, &type); + + /* + * Then, evaluate each statement, making the type of the + * compound statement be the type of the last statement + */ + type = NULL; + FOR_EACH_PTR(stmt->stmts, s) { + type = evaluate_statement(s); + } END_FOR_EACH_PTR; return type; } case STMT_IF: @@ -45,7 +45,7 @@ void start_function_scope(void) start_scope(&block_scope); } -static void remove_symbol_scope(struct symbol *sym, void *data, int flags) +static void remove_symbol_scope(struct symbol *sym) { struct symbol **ptr = sym->id_list; @@ -58,10 +58,13 @@ static void end_scope(struct scope **s) { struct scope *scope = *s; struct symbol_list *symbols = scope->symbols; + struct symbol *sym; *s = scope->next; scope->symbols = NULL; - symbol_iterate(symbols, remove_symbol_scope, NULL); + FOR_EACH_PTR(symbols, sym) { + remove_symbol_scope(sym); + } END_FOR_EACH_PTR; } void end_symbol_scope(void) |
