Lines Matching refs:stmt

64 static struct token *parse_if_statement(struct token *token, struct statement *stmt);
65 static struct token *parse_return_statement(struct token *token, struct statement *stmt);
66 static struct token *parse_loop_iterator(struct token *token, struct statement *stmt);
67 static struct token *parse_default_statement(struct token *token, struct statement *stmt);
68 static struct token *parse_case_statement(struct token *token, struct statement *stmt);
69 static struct token *parse_switch_statement(struct token *token, struct statement *stmt);
70 static struct token *parse_for_statement(struct token *token, struct statement *stmt);
71 static struct token *parse_while_statement(struct token *token, struct statement *stmt);
72 static struct token *parse_do_statement(struct token *token, struct statement *stmt);
73 static struct token *parse_goto_statement(struct token *token, struct statement *stmt);
74 static struct token *parse_context_statement(struct token *token, struct statement *stmt);
75 static struct token *parse_range_statement(struct token *token, struct statement *stmt);
76 static struct token *parse_asm_statement(struct token *token, struct statement *stmt);
665 struct statement *stmt = __alloc_statement(0); in alloc_statement() local
666 stmt->type = type; in alloc_statement()
667 stmt->pos = pos; in alloc_statement()
668 return stmt; in alloc_statement()
2079 static struct token *parse_asm_operands(struct token *token, struct statement *stmt, in parse_asm_operands() argument
2100 static struct token *parse_asm_clobbers(struct token *token, struct statement *stmt, in parse_asm_clobbers() argument
2113 static struct token *parse_asm_labels(struct token *token, struct statement *stmt, in parse_asm_labels() argument
2129 static struct token *parse_asm_statement(struct token *token, struct statement *stmt) in parse_asm_statement() argument
2134 stmt->type = STMT_ASM; in parse_asm_statement()
2144 token = parse_expression(token, &stmt->asm_string); in parse_asm_statement()
2146 token = parse_asm_operands(token, stmt, &stmt->asm_outputs); in parse_asm_statement()
2148 token = parse_asm_operands(token, stmt, &stmt->asm_inputs); in parse_asm_statement()
2150 token = parse_asm_clobbers(token, stmt, &stmt->asm_clobbers); in parse_asm_statement()
2152 token = parse_asm_labels(token, stmt, &stmt->asm_labels); in parse_asm_statement()
2196 struct statement *stmt; in make_statement() local
2200 stmt = alloc_statement(expr->pos, STMT_EXPRESSION); in make_statement()
2201 stmt->expression = expr; in make_statement()
2202 return stmt; in make_statement()
2214 static void start_iterator(struct statement *stmt) in start_iterator() argument
2218 start_symbol_scope(stmt->pos); in start_iterator()
2219 cont = alloc_symbol(stmt->pos, SYM_NODE); in start_iterator()
2221 brk = alloc_symbol(stmt->pos, SYM_NODE); in start_iterator()
2224 stmt->type = STMT_ITERATOR; in start_iterator()
2225 stmt->iterator_break = brk; in start_iterator()
2226 stmt->iterator_continue = cont; in start_iterator()
2231 static void end_iterator(struct statement *stmt) in end_iterator() argument
2239 struct statement *stmt = alloc_statement(sym->pos, STMT_COMPOUND); in start_function() local
2247 stmt->ret = ret; in start_function()
2253 return stmt; in start_function()
2274 static void start_switch(struct statement *stmt) in start_switch() argument
2278 start_symbol_scope(stmt->pos); in start_switch()
2279 brk = alloc_symbol(stmt->pos, SYM_NODE); in start_switch()
2282 switch_case = alloc_symbol(stmt->pos, SYM_NODE); in start_switch()
2284 switch_case->stmt = stmt; in start_switch()
2286 stmt->type = STMT_SWITCH; in start_switch()
2287 stmt->switch_break = brk; in start_switch()
2288 stmt->switch_case = switch_case; in start_switch()
2294 static void end_switch(struct statement *stmt) in end_switch() argument
2296 if (!stmt->switch_case->symbol_list) in end_switch()
2297 warning(stmt->pos, "switch with no cases"); in end_switch()
2301 static void add_case_statement(struct statement *stmt) in add_case_statement() argument
2307 sparse_error(stmt->pos, "not in switch scope"); in add_case_statement()
2308 stmt->type = STMT_NONE; in add_case_statement()
2311 sym = alloc_symbol(stmt->pos, SYM_NODE); in add_case_statement()
2313 sym->stmt = stmt; in add_case_statement()
2314 stmt->case_label = sym; in add_case_statement()
2318 static struct token *parse_return_statement(struct token *token, struct statement *stmt) in parse_return_statement() argument
2324 stmt->type = STMT_RETURN; in parse_return_statement()
2325 stmt->ret_target = target; in parse_return_statement()
2326 return expression_statement(token->next, &stmt->ret_value); in parse_return_statement()
2340 static struct token *parse_for_statement(struct token *token, struct statement *stmt) in parse_for_statement() argument
2346 start_iterator(stmt); in parse_for_statement()
2364 stmt->iterator_syms = syms; in parse_for_statement()
2365 stmt->iterator_pre_statement = make_statement(e1); in parse_for_statement()
2366 stmt->iterator_pre_condition = e2; in parse_for_statement()
2367 stmt->iterator_post_statement = make_statement(e3); in parse_for_statement()
2368 stmt->iterator_post_condition = NULL; in parse_for_statement()
2369 stmt->iterator_statement = iterator; in parse_for_statement()
2370 end_iterator(stmt); in parse_for_statement()
2375 static struct token *parse_while_statement(struct token *token, struct statement *stmt) in parse_while_statement() argument
2380 start_iterator(stmt); in parse_while_statement()
2384 stmt->iterator_pre_condition = expr; in parse_while_statement()
2385 stmt->iterator_post_condition = NULL; in parse_while_statement()
2386 stmt->iterator_statement = iterator; in parse_while_statement()
2387 end_iterator(stmt); in parse_while_statement()
2392 static struct token *parse_do_statement(struct token *token, struct statement *stmt) in parse_do_statement() argument
2397 start_iterator(stmt); in parse_do_statement()
2405 stmt->iterator_post_condition = expr; in parse_do_statement()
2406 stmt->iterator_statement = iterator; in parse_do_statement()
2407 end_iterator(stmt); in parse_do_statement()
2415 static struct token *parse_if_statement(struct token *token, struct statement *stmt) in parse_if_statement() argument
2417 stmt->type = STMT_IF; in parse_if_statement()
2418 token = parens_expression(token->next, &stmt->if_conditional, "after if"); in parse_if_statement()
2419 token = statement(token, &stmt->if_true); in parse_if_statement()
2424 return statement(token->next, &stmt->if_false); in parse_if_statement()
2427 static inline struct token *case_statement(struct token *token, struct statement *stmt) in case_statement() argument
2429 stmt->type = STMT_CASE; in case_statement()
2431 add_case_statement(stmt); in case_statement()
2432 return statement(token, &stmt->case_statement); in case_statement()
2435 static struct token *parse_case_statement(struct token *token, struct statement *stmt) in parse_case_statement() argument
2437 token = parse_expression(token->next, &stmt->case_expression); in parse_case_statement()
2439 token = parse_expression(token->next, &stmt->case_to); in parse_case_statement()
2440 return case_statement(token, stmt); in parse_case_statement()
2443 static struct token *parse_default_statement(struct token *token, struct statement *stmt) in parse_default_statement() argument
2445 return case_statement(token->next, stmt); in parse_default_statement()
2448 static struct token *parse_loop_iterator(struct token *token, struct statement *stmt) in parse_loop_iterator() argument
2451 stmt->type = STMT_GOTO; in parse_loop_iterator()
2452 stmt->goto_label = target; in parse_loop_iterator()
2454 sparse_error(stmt->pos, "break/continue not in iterator scope"); in parse_loop_iterator()
2458 static struct token *parse_switch_statement(struct token *token, struct statement *stmt) in parse_switch_statement() argument
2460 stmt->type = STMT_SWITCH; in parse_switch_statement()
2461 start_switch(stmt); in parse_switch_statement()
2462 token = parens_expression(token->next, &stmt->switch_expression, "after 'switch'"); in parse_switch_statement()
2463 token = statement(token, &stmt->switch_statement); in parse_switch_statement()
2464 end_switch(stmt); in parse_switch_statement()
2468 static struct token *parse_goto_statement(struct token *token, struct statement *stmt) in parse_goto_statement() argument
2470 stmt->type = STMT_GOTO; in parse_goto_statement()
2473 token = parse_expression(token->next, &stmt->goto_expression); in parse_goto_statement()
2474 add_statement(&function_computed_goto_list, stmt); in parse_goto_statement()
2476 stmt->goto_label = label_symbol(token); in parse_goto_statement()
2484 static struct token *parse_context_statement(struct token *token, struct statement *stmt) in parse_context_statement() argument
2486 stmt->type = STMT_CONTEXT; in parse_context_statement()
2489 token = assignment_expression(token, &stmt->expression); in parse_context_statement()
2490 if (!stmt->expression) in parse_context_statement()
2494 stmt->context = stmt->expression; in parse_context_statement()
2495 token = assignment_expression(token, &stmt->expression); in parse_context_statement()
2496 if (!stmt->expression) in parse_context_statement()
2503 static struct token *parse_range_statement(struct token *token, struct statement *stmt) in parse_range_statement() argument
2505 stmt->type = STMT_RANGE; in parse_range_statement()
2508 token = assignment_expression(token, &stmt->range_expression); in parse_range_statement()
2510 token = assignment_expression(token, &stmt->range_low); in parse_range_statement()
2512 token = assignment_expression(token, &stmt->range_high); in parse_range_statement()
2519 struct statement *stmt = alloc_statement(token->pos, STMT_NONE); in statement() local
2521 *tree = stmt; in statement()
2525 return s->op->statement(token, stmt); in statement()
2530 if (s->stmt) { in statement()
2531 sparse_error(stmt->pos, "label '%s' redefined", show_ident(s->ident)); in statement()
2535 stmt->type = STMT_LABEL; in statement()
2536 stmt->label_identifier = s; in statement()
2537 s->stmt = stmt; in statement()
2538 return statement(token, &stmt->label_statement); in statement()
2543 stmt->type = STMT_COMPOUND; in statement()
2544 start_symbol_scope(stmt->pos); in statement()
2545 token = compound_statement(token->next, stmt); in statement()
2551 stmt->type = STMT_EXPRESSION; in statement()
2552 return expression_statement(token, &stmt->expression); in statement()
2579 struct statement * stmt; in statement_list() local
2593 stmt = alloc_statement(token->pos, STMT_DECLARATION); in statement_list()
2594 token = external_declaration(token, &stmt->declaration, NULL); in statement_list()
2597 token = statement(token, &stmt); in statement_list()
2599 add_statement(list, stmt); in statement_list()
2652 struct token *compound_statement(struct token *token, struct statement *stmt) in compound_statement() argument
2654 token = statement_list(token, &stmt->stmts); in compound_statement()
2807 struct statement *stmt, **p; in parse_function_body() local
2817 p = &base_type->stmt; in parse_function_body()
2829 stmt = start_function(decl); in parse_function_body()
2831 *p = stmt; in parse_function_body()
2836 token = compound_statement(token->next, stmt); in parse_function_body()
2868 FOR_EACH_PTR(function_computed_goto_list, stmt) { in parse_function_body()
2869 stmt->target_list = function_computed_target_list; in parse_function_body()
2870 } END_FOR_EACH_PTR(stmt); in parse_function_body()
2949 struct statement *stmt; in toplevel_asm_declaration() local
2952 stmt = alloc_statement(token->pos, STMT_NONE); in toplevel_asm_declaration()
2953 fn->stmt = stmt; in toplevel_asm_declaration()
2955 token = parse_asm_statement(token, stmt); in toplevel_asm_declaration()