| ... | ... | @@ -21,15 +21,15 @@ struct Stage1AstGen { |
| 21 | 21 | bool in_c_import_scope; |
| 22 | 22 | }; |
| 23 | 23 | |
| 24 | | static IrInstSrc *ir_gen_node(Stage1AstGen *ag, AstNode *node, Scope *scope); |
| 25 | | static IrInstSrc *ir_gen_node_extra(Stage1AstGen *ag, AstNode *node, Scope *scope, LVal lval, |
| 24 | static IrInstSrc *astgen_node(Stage1AstGen *ag, AstNode *node, Scope *scope); |
| 25 | static IrInstSrc *astgen_node_extra(Stage1AstGen *ag, AstNode *node, Scope *scope, LVal lval, |
| 26 | 26 | ResultLoc *result_loc); |
| 27 | 27 | |
| 28 | 28 | static IrInstSrc *ir_lval_wrap(Stage1AstGen *ag, Scope *scope, IrInstSrc *value, LVal lval, |
| 29 | 29 | ResultLoc *result_loc); |
| 30 | 30 | static IrInstSrc *ir_expr_wrap(Stage1AstGen *ag, Scope *scope, IrInstSrc *inst, |
| 31 | 31 | ResultLoc *result_loc); |
| 32 | | static IrInstSrc *ir_gen_union_init_expr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, |
| 32 | static IrInstSrc *astgen_union_init_expr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, |
| 33 | 33 | IrInstSrc *union_type, IrInstSrc *field_name, AstNode *expr_node, |
| 34 | 34 | LVal lval, ResultLoc *parent_result_loc); |
| 35 | 35 | static ResultLocCast *ir_build_cast_result_loc(Stage1AstGen *ag, IrInstSrc *dest_type, |
| ... | ... | @@ -2890,7 +2890,7 @@ static IrInstSrc *ir_mark_gen(IrInstSrc *instruction) { |
| 2890 | 2890 | return instruction; |
| 2891 | 2891 | } |
| 2892 | 2892 | |
| 2893 | | static bool ir_gen_defers_for_block(Stage1AstGen *ag, Scope *inner_scope, Scope *outer_scope, bool *is_noreturn, IrInstSrc *err_value) { |
| 2893 | static bool astgen_defers_for_block(Stage1AstGen *ag, Scope *inner_scope, Scope *outer_scope, bool *is_noreturn, IrInstSrc *err_value) { |
| 2894 | 2894 | Scope *scope = inner_scope; |
| 2895 | 2895 | if (is_noreturn != nullptr) *is_noreturn = false; |
| 2896 | 2896 | while (scope != outer_scope) { |
| ... | ... | @@ -2941,7 +2941,7 @@ static bool ir_gen_defers_for_block(Stage1AstGen *ag, Scope *inner_scope, Scope |
| 2941 | 2941 | defer_expr_scope = err_var->child_scope; |
| 2942 | 2942 | } |
| 2943 | 2943 | |
| 2944 | | IrInstSrc *defer_expr_value = ir_gen_node(ag, defer_expr_node, defer_expr_scope); |
| 2944 | IrInstSrc *defer_expr_value = astgen_node(ag, defer_expr_node, defer_expr_scope); |
| 2945 | 2945 | if (defer_expr_value == ag->codegen->invalid_inst_src) |
| 2946 | 2946 | return ag->codegen->invalid_inst_src; |
| 2947 | 2947 | |
| ... | ... | @@ -3011,7 +3011,7 @@ static ScopeDeferExpr *get_scope_defer_expr(Scope *scope) { |
| 3011 | 3011 | return nullptr; |
| 3012 | 3012 | } |
| 3013 | 3013 | |
| 3014 | | static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { |
| 3014 | static IrInstSrc *astgen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { |
| 3015 | 3015 | assert(node->type == NodeTypeReturnExpr); |
| 3016 | 3016 | |
| 3017 | 3017 | ScopeDeferExpr *scope_defer_expr = get_scope_defer_expr(scope); |
| ... | ... | @@ -3038,7 +3038,7 @@ static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L |
| 3038 | 3038 | // Temporarily set this so that if we return a type it gets the name of the function |
| 3039 | 3039 | ZigFn *prev_name_fn = ag->exec->name_fn; |
| 3040 | 3040 | ag->exec->name_fn = ag->fn; |
| 3041 | | return_value = ir_gen_node_extra(ag, expr_node, scope, LValNone, &result_loc_ret->base); |
| 3041 | return_value = astgen_node_extra(ag, expr_node, scope, LValNone, &result_loc_ret->base); |
| 3042 | 3042 | ag->exec->name_fn = prev_name_fn; |
| 3043 | 3043 | if (return_value == ag->codegen->invalid_inst_src) |
| 3044 | 3044 | return ag->codegen->invalid_inst_src; |
| ... | ... | @@ -3054,7 +3054,7 @@ static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L |
| 3054 | 3054 | bool have_err_defers = defer_counts[ReturnKindError] > 0; |
| 3055 | 3055 | if (!have_err_defers && !ag->codegen->have_err_ret_tracing) { |
| 3056 | 3056 | // only generate unconditional defers |
| 3057 | | if (!ir_gen_defers_for_block(ag, scope, outer_scope, nullptr, nullptr)) |
| 3057 | if (!astgen_defers_for_block(ag, scope, outer_scope, nullptr, nullptr)) |
| 3058 | 3058 | return ag->codegen->invalid_inst_src; |
| 3059 | 3059 | IrInstSrc *result = ir_build_return_src(ag, scope, node, nullptr); |
| 3060 | 3060 | result_loc_ret->base.source_instruction = result; |
| ... | ... | @@ -3078,7 +3078,7 @@ static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L |
| 3078 | 3078 | Stage1ZirBasicBlock *ret_stmt_block = ir_create_basic_block(ag, scope, "RetStmt"); |
| 3079 | 3079 | |
| 3080 | 3080 | ir_set_cursor_at_end_and_append_block(ag, err_block); |
| 3081 | | if (!ir_gen_defers_for_block(ag, scope, outer_scope, nullptr, return_value)) |
| 3081 | if (!astgen_defers_for_block(ag, scope, outer_scope, nullptr, return_value)) |
| 3082 | 3082 | return ag->codegen->invalid_inst_src; |
| 3083 | 3083 | if (ag->codegen->have_err_ret_tracing && !should_inline) { |
| 3084 | 3084 | ir_build_save_err_ret_addr_src(ag, scope, node); |
| ... | ... | @@ -3086,7 +3086,7 @@ static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L |
| 3086 | 3086 | ir_build_br(ag, scope, node, ret_stmt_block, is_comptime); |
| 3087 | 3087 | |
| 3088 | 3088 | ir_set_cursor_at_end_and_append_block(ag, ok_block); |
| 3089 | | if (!ir_gen_defers_for_block(ag, scope, outer_scope, nullptr, nullptr)) |
| 3089 | if (!astgen_defers_for_block(ag, scope, outer_scope, nullptr, nullptr)) |
| 3090 | 3090 | return ag->codegen->invalid_inst_src; |
| 3091 | 3091 | ir_build_br(ag, scope, node, ret_stmt_block, is_comptime); |
| 3092 | 3092 | |
| ... | ... | @@ -3098,7 +3098,7 @@ static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L |
| 3098 | 3098 | case ReturnKindError: |
| 3099 | 3099 | { |
| 3100 | 3100 | assert(expr_node); |
| 3101 | | IrInstSrc *err_union_ptr = ir_gen_node_extra(ag, expr_node, scope, LValPtr, nullptr); |
| 3101 | IrInstSrc *err_union_ptr = astgen_node_extra(ag, expr_node, scope, LValPtr, nullptr); |
| 3102 | 3102 | if (err_union_ptr == ag->codegen->invalid_inst_src) |
| 3103 | 3103 | return ag->codegen->invalid_inst_src; |
| 3104 | 3104 | IrInstSrc *is_err_val = ir_build_test_err_src(ag, scope, node, err_union_ptr, true, false); |
| ... | ... | @@ -3126,7 +3126,7 @@ static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L |
| 3126 | 3126 | ir_build_end_expr(ag, scope, node, err_val, &result_loc_ret->base); |
| 3127 | 3127 | |
| 3128 | 3128 | bool is_noreturn = false; |
| 3129 | | if (!ir_gen_defers_for_block(ag, scope, outer_scope, &is_noreturn, err_val)) { |
| 3129 | if (!astgen_defers_for_block(ag, scope, outer_scope, &is_noreturn, err_val)) { |
| 3130 | 3130 | return ag->codegen->invalid_inst_src; |
| 3131 | 3131 | } |
| 3132 | 3132 | if (!is_noreturn) { |
| ... | ... | @@ -3260,7 +3260,7 @@ static bool is_duplicate_label(CodeGen *g, Scope *scope, AstNode *node, Buf *nam |
| 3260 | 3260 | return false; |
| 3261 | 3261 | } |
| 3262 | 3262 | |
| 3263 | | static IrInstSrc *ir_gen_block(Stage1AstGen *ag, Scope *parent_scope, AstNode *block_node, LVal lval, |
| 3263 | static IrInstSrc *astgen_block(Stage1AstGen *ag, Scope *parent_scope, AstNode *block_node, LVal lval, |
| 3264 | 3264 | ResultLoc *result_loc) |
| 3265 | 3265 | { |
| 3266 | 3266 | assert(block_node->type == NodeTypeBlock); |
| ... | ... | @@ -3313,7 +3313,7 @@ static IrInstSrc *ir_gen_block(Stage1AstGen *ag, Scope *parent_scope, AstNode *b |
| 3313 | 3313 | for (size_t i = 0; i < block_node->data.block.statements.length; i += 1) { |
| 3314 | 3314 | AstNode *statement_node = block_node->data.block.statements.at(i); |
| 3315 | 3315 | |
| 3316 | | IrInstSrc *statement_value = ir_gen_node(ag, statement_node, child_scope); |
| 3316 | IrInstSrc *statement_value = astgen_node(ag, statement_node, child_scope); |
| 3317 | 3317 | if (statement_value == ag->codegen->invalid_inst_src) { |
| 3318 | 3318 | // keep generating all the elements of the block in case of error, |
| 3319 | 3319 | // we want to collect other compile errors |
| ... | ... | @@ -3381,7 +3381,7 @@ static IrInstSrc *ir_gen_block(Stage1AstGen *ag, Scope *parent_scope, AstNode *b |
| 3381 | 3381 | |
| 3382 | 3382 | bool is_return_from_fn = block_node == ag->main_block_node; |
| 3383 | 3383 | if (!is_return_from_fn) { |
| 3384 | | if (!ir_gen_defers_for_block(ag, child_scope, outer_block_scope, nullptr, nullptr)) |
| 3384 | if (!astgen_defers_for_block(ag, child_scope, outer_block_scope, nullptr, nullptr)) |
| 3385 | 3385 | return ag->codegen->invalid_inst_src; |
| 3386 | 3386 | } |
| 3387 | 3387 | |
| ... | ... | @@ -3407,19 +3407,19 @@ static IrInstSrc *ir_gen_block(Stage1AstGen *ag, Scope *parent_scope, AstNode *b |
| 3407 | 3407 | result_loc_ret->base.id = ResultLocIdReturn; |
| 3408 | 3408 | ir_build_reset_result(ag, parent_scope, block_node, &result_loc_ret->base); |
| 3409 | 3409 | ir_mark_gen(ir_build_end_expr(ag, parent_scope, block_node, result, &result_loc_ret->base)); |
| 3410 | | if (!ir_gen_defers_for_block(ag, child_scope, outer_block_scope, nullptr, nullptr)) |
| 3410 | if (!astgen_defers_for_block(ag, child_scope, outer_block_scope, nullptr, nullptr)) |
| 3411 | 3411 | return ag->codegen->invalid_inst_src; |
| 3412 | 3412 | return ir_mark_gen(ir_build_return_src(ag, child_scope, result->base.source_node, result)); |
| 3413 | 3413 | } |
| 3414 | 3414 | |
| 3415 | | static IrInstSrc *ir_gen_bin_op_id(Stage1AstGen *ag, Scope *scope, AstNode *node, IrBinOp op_id) { |
| 3415 | static IrInstSrc *astgen_bin_op_id(Stage1AstGen *ag, Scope *scope, AstNode *node, IrBinOp op_id) { |
| 3416 | 3416 | Scope *inner_scope = scope; |
| 3417 | 3417 | if (op_id == IrBinOpArrayCat || op_id == IrBinOpArrayMult) { |
| 3418 | 3418 | inner_scope = create_comptime_scope(ag->codegen, node, scope); |
| 3419 | 3419 | } |
| 3420 | 3420 | |
| 3421 | | IrInstSrc *op1 = ir_gen_node(ag, node->data.bin_op_expr.op1, inner_scope); |
| 3422 | | IrInstSrc *op2 = ir_gen_node(ag, node->data.bin_op_expr.op2, inner_scope); |
| 3421 | IrInstSrc *op1 = astgen_node(ag, node->data.bin_op_expr.op1, inner_scope); |
| 3422 | IrInstSrc *op2 = astgen_node(ag, node->data.bin_op_expr.op2, inner_scope); |
| 3423 | 3423 | |
| 3424 | 3424 | if (op1 == ag->codegen->invalid_inst_src || op2 == ag->codegen->invalid_inst_src) |
| 3425 | 3425 | return ag->codegen->invalid_inst_src; |
| ... | ... | @@ -3427,9 +3427,9 @@ static IrInstSrc *ir_gen_bin_op_id(Stage1AstGen *ag, Scope *scope, AstNode *node |
| 3427 | 3427 | return ir_build_bin_op(ag, scope, node, op_id, op1, op2, true); |
| 3428 | 3428 | } |
| 3429 | 3429 | |
| 3430 | | static IrInstSrc *ir_gen_merge_err_sets(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3431 | | IrInstSrc *op1 = ir_gen_node(ag, node->data.bin_op_expr.op1, scope); |
| 3432 | | IrInstSrc *op2 = ir_gen_node(ag, node->data.bin_op_expr.op2, scope); |
| 3430 | static IrInstSrc *astgen_merge_err_sets(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3431 | IrInstSrc *op1 = astgen_node(ag, node->data.bin_op_expr.op1, scope); |
| 3432 | IrInstSrc *op2 = astgen_node(ag, node->data.bin_op_expr.op2, scope); |
| 3433 | 3433 | |
| 3434 | 3434 | if (op1 == ag->codegen->invalid_inst_src || op2 == ag->codegen->invalid_inst_src) |
| 3435 | 3435 | return ag->codegen->invalid_inst_src; |
| ... | ... | @@ -3441,8 +3441,8 @@ static IrInstSrc *ir_gen_merge_err_sets(Stage1AstGen *ag, Scope *scope, AstNode |
| 3441 | 3441 | return ir_build_merge_err_sets(ag, scope, node, op1, op2, type_name); |
| 3442 | 3442 | } |
| 3443 | 3443 | |
| 3444 | | static IrInstSrc *ir_gen_assign(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3445 | | IrInstSrc *lvalue = ir_gen_node_extra(ag, node->data.bin_op_expr.op1, scope, LValAssign, nullptr); |
| 3444 | static IrInstSrc *astgen_assign(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3445 | IrInstSrc *lvalue = astgen_node_extra(ag, node->data.bin_op_expr.op1, scope, LValAssign, nullptr); |
| 3446 | 3446 | if (lvalue == ag->codegen->invalid_inst_src) |
| 3447 | 3447 | return ag->codegen->invalid_inst_src; |
| 3448 | 3448 | |
| ... | ... | @@ -3452,7 +3452,7 @@ static IrInstSrc *ir_gen_assign(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3452 | 3452 | ir_ref_instruction(lvalue, ag->current_basic_block); |
| 3453 | 3453 | ir_build_reset_result(ag, scope, node, &result_loc_inst->base); |
| 3454 | 3454 | |
| 3455 | | IrInstSrc *rvalue = ir_gen_node_extra(ag, node->data.bin_op_expr.op2, scope, LValNone, |
| 3455 | IrInstSrc *rvalue = astgen_node_extra(ag, node->data.bin_op_expr.op2, scope, LValNone, |
| 3456 | 3456 | &result_loc_inst->base); |
| 3457 | 3457 | if (rvalue == ag->codegen->invalid_inst_src) |
| 3458 | 3458 | return ag->codegen->invalid_inst_src; |
| ... | ... | @@ -3460,12 +3460,12 @@ static IrInstSrc *ir_gen_assign(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3460 | 3460 | return ir_build_const_void(ag, scope, node); |
| 3461 | 3461 | } |
| 3462 | 3462 | |
| 3463 | | static IrInstSrc *ir_gen_assign_op(Stage1AstGen *ag, Scope *scope, AstNode *node, IrBinOp op_id) { |
| 3464 | | IrInstSrc *lvalue = ir_gen_node_extra(ag, node->data.bin_op_expr.op1, scope, LValAssign, nullptr); |
| 3463 | static IrInstSrc *astgen_assign_op(Stage1AstGen *ag, Scope *scope, AstNode *node, IrBinOp op_id) { |
| 3464 | IrInstSrc *lvalue = astgen_node_extra(ag, node->data.bin_op_expr.op1, scope, LValAssign, nullptr); |
| 3465 | 3465 | if (lvalue == ag->codegen->invalid_inst_src) |
| 3466 | 3466 | return lvalue; |
| 3467 | 3467 | IrInstSrc *op1 = ir_build_load_ptr(ag, scope, node->data.bin_op_expr.op1, lvalue); |
| 3468 | | IrInstSrc *op2 = ir_gen_node(ag, node->data.bin_op_expr.op2, scope); |
| 3468 | IrInstSrc *op2 = astgen_node(ag, node->data.bin_op_expr.op2, scope); |
| 3469 | 3469 | if (op2 == ag->codegen->invalid_inst_src) |
| 3470 | 3470 | return op2; |
| 3471 | 3471 | IrInstSrc *result = ir_build_bin_op(ag, scope, node, op_id, op1, op2, true); |
| ... | ... | @@ -3473,10 +3473,10 @@ static IrInstSrc *ir_gen_assign_op(Stage1AstGen *ag, Scope *scope, AstNode *node |
| 3473 | 3473 | return ir_build_const_void(ag, scope, node); |
| 3474 | 3474 | } |
| 3475 | 3475 | |
| 3476 | | static IrInstSrc *ir_gen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3476 | static IrInstSrc *astgen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3477 | 3477 | assert(node->type == NodeTypeBinOpExpr); |
| 3478 | 3478 | |
| 3479 | | IrInstSrc *val1 = ir_gen_node(ag, node->data.bin_op_expr.op1, scope); |
| 3479 | IrInstSrc *val1 = astgen_node(ag, node->data.bin_op_expr.op1, scope); |
| 3480 | 3480 | if (val1 == ag->codegen->invalid_inst_src) |
| 3481 | 3481 | return ag->codegen->invalid_inst_src; |
| 3482 | 3482 | Stage1ZirBasicBlock *post_val1_block = ag->current_basic_block; |
| ... | ... | @@ -3496,7 +3496,7 @@ static IrInstSrc *ir_gen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3496 | 3496 | ir_build_cond_br(ag, scope, node, val1, true_block, false_block, is_comptime); |
| 3497 | 3497 | |
| 3498 | 3498 | ir_set_cursor_at_end_and_append_block(ag, false_block); |
| 3499 | | IrInstSrc *val2 = ir_gen_node(ag, node->data.bin_op_expr.op2, scope); |
| 3499 | IrInstSrc *val2 = astgen_node(ag, node->data.bin_op_expr.op2, scope); |
| 3500 | 3500 | if (val2 == ag->codegen->invalid_inst_src) |
| 3501 | 3501 | return ag->codegen->invalid_inst_src; |
| 3502 | 3502 | Stage1ZirBasicBlock *post_val2_block = ag->current_basic_block; |
| ... | ... | @@ -3515,10 +3515,10 @@ static IrInstSrc *ir_gen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3515 | 3515 | return ir_build_phi(ag, scope, node, 2, incoming_blocks, incoming_values, nullptr); |
| 3516 | 3516 | } |
| 3517 | 3517 | |
| 3518 | | static IrInstSrc *ir_gen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3518 | static IrInstSrc *astgen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3519 | 3519 | assert(node->type == NodeTypeBinOpExpr); |
| 3520 | 3520 | |
| 3521 | | IrInstSrc *val1 = ir_gen_node(ag, node->data.bin_op_expr.op1, scope); |
| 3521 | IrInstSrc *val1 = astgen_node(ag, node->data.bin_op_expr.op1, scope); |
| 3522 | 3522 | if (val1 == ag->codegen->invalid_inst_src) |
| 3523 | 3523 | return ag->codegen->invalid_inst_src; |
| 3524 | 3524 | Stage1ZirBasicBlock *post_val1_block = ag->current_basic_block; |
| ... | ... | @@ -3538,7 +3538,7 @@ static IrInstSrc *ir_gen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3538 | 3538 | ir_build_cond_br(ag, scope, node, val1, true_block, false_block, is_comptime); |
| 3539 | 3539 | |
| 3540 | 3540 | ir_set_cursor_at_end_and_append_block(ag, true_block); |
| 3541 | | IrInstSrc *val2 = ir_gen_node(ag, node->data.bin_op_expr.op2, scope); |
| 3541 | IrInstSrc *val2 = astgen_node(ag, node->data.bin_op_expr.op2, scope); |
| 3542 | 3542 | if (val2 == ag->codegen->invalid_inst_src) |
| 3543 | 3543 | return ag->codegen->invalid_inst_src; |
| 3544 | 3544 | Stage1ZirBasicBlock *post_val2_block = ag->current_basic_block; |
| ... | ... | @@ -3591,7 +3591,7 @@ static ResultLocPeerParent *ir_build_binary_result_peers(Stage1AstGen *ag, IrIns |
| 3591 | 3591 | return peer_parent; |
| 3592 | 3592 | } |
| 3593 | 3593 | |
| 3594 | | static IrInstSrc *ir_gen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval, |
| 3594 | static IrInstSrc *astgen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval, |
| 3595 | 3595 | ResultLoc *result_loc) |
| 3596 | 3596 | { |
| 3597 | 3597 | assert(node->type == NodeTypeBinOpExpr); |
| ... | ... | @@ -3599,7 +3599,7 @@ static IrInstSrc *ir_gen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode * |
| 3599 | 3599 | AstNode *op1_node = node->data.bin_op_expr.op1; |
| 3600 | 3600 | AstNode *op2_node = node->data.bin_op_expr.op2; |
| 3601 | 3601 | |
| 3602 | | IrInstSrc *maybe_ptr = ir_gen_node_extra(ag, op1_node, parent_scope, LValPtr, nullptr); |
| 3602 | IrInstSrc *maybe_ptr = astgen_node_extra(ag, op1_node, parent_scope, LValPtr, nullptr); |
| 3603 | 3603 | if (maybe_ptr == ag->codegen->invalid_inst_src) |
| 3604 | 3604 | return ag->codegen->invalid_inst_src; |
| 3605 | 3605 | |
| ... | ... | @@ -3622,7 +3622,7 @@ static IrInstSrc *ir_gen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode * |
| 3622 | 3622 | result_loc, is_comptime); |
| 3623 | 3623 | |
| 3624 | 3624 | ir_set_cursor_at_end_and_append_block(ag, null_block); |
| 3625 | | IrInstSrc *null_result = ir_gen_node_extra(ag, op2_node, parent_scope, LValNone, |
| 3625 | IrInstSrc *null_result = astgen_node_extra(ag, op2_node, parent_scope, LValNone, |
| 3626 | 3626 | &peer_parent->peers.at(0)->base); |
| 3627 | 3627 | if (null_result == ag->codegen->invalid_inst_src) |
| 3628 | 3628 | return ag->codegen->invalid_inst_src; |
| ... | ... | @@ -3648,24 +3648,24 @@ static IrInstSrc *ir_gen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode * |
| 3648 | 3648 | return ir_lval_wrap(ag, parent_scope, phi, lval, result_loc); |
| 3649 | 3649 | } |
| 3650 | 3650 | |
| 3651 | | static IrInstSrc *ir_gen_error_union(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { |
| 3651 | static IrInstSrc *astgen_error_union(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { |
| 3652 | 3652 | assert(node->type == NodeTypeBinOpExpr); |
| 3653 | 3653 | |
| 3654 | 3654 | AstNode *op1_node = node->data.bin_op_expr.op1; |
| 3655 | 3655 | AstNode *op2_node = node->data.bin_op_expr.op2; |
| 3656 | 3656 | |
| 3657 | | IrInstSrc *err_set = ir_gen_node(ag, op1_node, parent_scope); |
| 3657 | IrInstSrc *err_set = astgen_node(ag, op1_node, parent_scope); |
| 3658 | 3658 | if (err_set == ag->codegen->invalid_inst_src) |
| 3659 | 3659 | return ag->codegen->invalid_inst_src; |
| 3660 | 3660 | |
| 3661 | | IrInstSrc *payload = ir_gen_node(ag, op2_node, parent_scope); |
| 3661 | IrInstSrc *payload = astgen_node(ag, op2_node, parent_scope); |
| 3662 | 3662 | if (payload == ag->codegen->invalid_inst_src) |
| 3663 | 3663 | return ag->codegen->invalid_inst_src; |
| 3664 | 3664 | |
| 3665 | 3665 | return ir_build_error_union(ag, parent_scope, node, err_set, payload); |
| 3666 | 3666 | } |
| 3667 | 3667 | |
| 3668 | | static IrInstSrc *ir_gen_bin_op(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { |
| 3668 | static IrInstSrc *astgen_bin_op(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { |
| 3669 | 3669 | assert(node->type == NodeTypeBinOpExpr); |
| 3670 | 3670 | |
| 3671 | 3671 | BinOpType bin_op_type = node->data.bin_op_expr.bin_op; |
| ... | ... | @@ -3673,90 +3673,90 @@ static IrInstSrc *ir_gen_bin_op(Stage1AstGen *ag, Scope *scope, AstNode *node, L |
| 3673 | 3673 | case BinOpTypeInvalid: |
| 3674 | 3674 | zig_unreachable(); |
| 3675 | 3675 | case BinOpTypeAssign: |
| 3676 | | return ir_lval_wrap(ag, scope, ir_gen_assign(ag, scope, node), lval, result_loc); |
| 3676 | return ir_lval_wrap(ag, scope, astgen_assign(ag, scope, node), lval, result_loc); |
| 3677 | 3677 | case BinOpTypeAssignTimes: |
| 3678 | | return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpMult), lval, result_loc); |
| 3678 | return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpMult), lval, result_loc); |
| 3679 | 3679 | case BinOpTypeAssignTimesWrap: |
| 3680 | | return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpMultWrap), lval, result_loc); |
| 3680 | return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpMultWrap), lval, result_loc); |
| 3681 | 3681 | case BinOpTypeAssignDiv: |
| 3682 | | return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpDivUnspecified), lval, result_loc); |
| 3682 | return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpDivUnspecified), lval, result_loc); |
| 3683 | 3683 | case BinOpTypeAssignMod: |
| 3684 | | return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpRemUnspecified), lval, result_loc); |
| 3684 | return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpRemUnspecified), lval, result_loc); |
| 3685 | 3685 | case BinOpTypeAssignPlus: |
| 3686 | | return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpAdd), lval, result_loc); |
| 3686 | return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpAdd), lval, result_loc); |
| 3687 | 3687 | case BinOpTypeAssignPlusWrap: |
| 3688 | | return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpAddWrap), lval, result_loc); |
| 3688 | return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpAddWrap), lval, result_loc); |
| 3689 | 3689 | case BinOpTypeAssignMinus: |
| 3690 | | return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpSub), lval, result_loc); |
| 3690 | return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpSub), lval, result_loc); |
| 3691 | 3691 | case BinOpTypeAssignMinusWrap: |
| 3692 | | return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpSubWrap), lval, result_loc); |
| 3692 | return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpSubWrap), lval, result_loc); |
| 3693 | 3693 | case BinOpTypeAssignBitShiftLeft: |
| 3694 | | return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpBitShiftLeftLossy), lval, result_loc); |
| 3694 | return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpBitShiftLeftLossy), lval, result_loc); |
| 3695 | 3695 | case BinOpTypeAssignBitShiftRight: |
| 3696 | | return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpBitShiftRightLossy), lval, result_loc); |
| 3696 | return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpBitShiftRightLossy), lval, result_loc); |
| 3697 | 3697 | case BinOpTypeAssignBitAnd: |
| 3698 | | return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpBinAnd), lval, result_loc); |
| 3698 | return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpBinAnd), lval, result_loc); |
| 3699 | 3699 | case BinOpTypeAssignBitXor: |
| 3700 | | return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpBinXor), lval, result_loc); |
| 3700 | return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpBinXor), lval, result_loc); |
| 3701 | 3701 | case BinOpTypeAssignBitOr: |
| 3702 | | return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpBinOr), lval, result_loc); |
| 3702 | return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpBinOr), lval, result_loc); |
| 3703 | 3703 | case BinOpTypeBoolOr: |
| 3704 | | return ir_lval_wrap(ag, scope, ir_gen_bool_or(ag, scope, node), lval, result_loc); |
| 3704 | return ir_lval_wrap(ag, scope, astgen_bool_or(ag, scope, node), lval, result_loc); |
| 3705 | 3705 | case BinOpTypeBoolAnd: |
| 3706 | | return ir_lval_wrap(ag, scope, ir_gen_bool_and(ag, scope, node), lval, result_loc); |
| 3706 | return ir_lval_wrap(ag, scope, astgen_bool_and(ag, scope, node), lval, result_loc); |
| 3707 | 3707 | case BinOpTypeCmpEq: |
| 3708 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpCmpEq), lval, result_loc); |
| 3708 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpCmpEq), lval, result_loc); |
| 3709 | 3709 | case BinOpTypeCmpNotEq: |
| 3710 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpCmpNotEq), lval, result_loc); |
| 3710 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpCmpNotEq), lval, result_loc); |
| 3711 | 3711 | case BinOpTypeCmpLessThan: |
| 3712 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpCmpLessThan), lval, result_loc); |
| 3712 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpCmpLessThan), lval, result_loc); |
| 3713 | 3713 | case BinOpTypeCmpGreaterThan: |
| 3714 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpCmpGreaterThan), lval, result_loc); |
| 3714 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpCmpGreaterThan), lval, result_loc); |
| 3715 | 3715 | case BinOpTypeCmpLessOrEq: |
| 3716 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpCmpLessOrEq), lval, result_loc); |
| 3716 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpCmpLessOrEq), lval, result_loc); |
| 3717 | 3717 | case BinOpTypeCmpGreaterOrEq: |
| 3718 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpCmpGreaterOrEq), lval, result_loc); |
| 3718 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpCmpGreaterOrEq), lval, result_loc); |
| 3719 | 3719 | case BinOpTypeBinOr: |
| 3720 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpBinOr), lval, result_loc); |
| 3720 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpBinOr), lval, result_loc); |
| 3721 | 3721 | case BinOpTypeBinXor: |
| 3722 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpBinXor), lval, result_loc); |
| 3722 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpBinXor), lval, result_loc); |
| 3723 | 3723 | case BinOpTypeBinAnd: |
| 3724 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpBinAnd), lval, result_loc); |
| 3724 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpBinAnd), lval, result_loc); |
| 3725 | 3725 | case BinOpTypeBitShiftLeft: |
| 3726 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpBitShiftLeftLossy), lval, result_loc); |
| 3726 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpBitShiftLeftLossy), lval, result_loc); |
| 3727 | 3727 | case BinOpTypeBitShiftRight: |
| 3728 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpBitShiftRightLossy), lval, result_loc); |
| 3728 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpBitShiftRightLossy), lval, result_loc); |
| 3729 | 3729 | case BinOpTypeAdd: |
| 3730 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpAdd), lval, result_loc); |
| 3730 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpAdd), lval, result_loc); |
| 3731 | 3731 | case BinOpTypeAddWrap: |
| 3732 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpAddWrap), lval, result_loc); |
| 3732 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpAddWrap), lval, result_loc); |
| 3733 | 3733 | case BinOpTypeSub: |
| 3734 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpSub), lval, result_loc); |
| 3734 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpSub), lval, result_loc); |
| 3735 | 3735 | case BinOpTypeSubWrap: |
| 3736 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpSubWrap), lval, result_loc); |
| 3736 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpSubWrap), lval, result_loc); |
| 3737 | 3737 | case BinOpTypeMult: |
| 3738 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpMult), lval, result_loc); |
| 3738 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpMult), lval, result_loc); |
| 3739 | 3739 | case BinOpTypeMultWrap: |
| 3740 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpMultWrap), lval, result_loc); |
| 3740 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpMultWrap), lval, result_loc); |
| 3741 | 3741 | case BinOpTypeDiv: |
| 3742 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpDivUnspecified), lval, result_loc); |
| 3742 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpDivUnspecified), lval, result_loc); |
| 3743 | 3743 | case BinOpTypeMod: |
| 3744 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpRemUnspecified), lval, result_loc); |
| 3744 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpRemUnspecified), lval, result_loc); |
| 3745 | 3745 | case BinOpTypeArrayCat: |
| 3746 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpArrayCat), lval, result_loc); |
| 3746 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpArrayCat), lval, result_loc); |
| 3747 | 3747 | case BinOpTypeArrayMult: |
| 3748 | | return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpArrayMult), lval, result_loc); |
| 3748 | return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpArrayMult), lval, result_loc); |
| 3749 | 3749 | case BinOpTypeMergeErrorSets: |
| 3750 | | return ir_lval_wrap(ag, scope, ir_gen_merge_err_sets(ag, scope, node), lval, result_loc); |
| 3750 | return ir_lval_wrap(ag, scope, astgen_merge_err_sets(ag, scope, node), lval, result_loc); |
| 3751 | 3751 | case BinOpTypeUnwrapOptional: |
| 3752 | | return ir_gen_orelse(ag, scope, node, lval, result_loc); |
| 3752 | return astgen_orelse(ag, scope, node, lval, result_loc); |
| 3753 | 3753 | case BinOpTypeErrorUnion: |
| 3754 | | return ir_lval_wrap(ag, scope, ir_gen_error_union(ag, scope, node), lval, result_loc); |
| 3754 | return ir_lval_wrap(ag, scope, astgen_error_union(ag, scope, node), lval, result_loc); |
| 3755 | 3755 | } |
| 3756 | 3756 | zig_unreachable(); |
| 3757 | 3757 | } |
| 3758 | 3758 | |
| 3759 | | static IrInstSrc *ir_gen_int_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3759 | static IrInstSrc *astgen_int_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3760 | 3760 | assert(node->type == NodeTypeIntLiteral); |
| 3761 | 3761 | |
| 3762 | 3762 | RootStruct *root_struct = node->owner->data.structure.root_struct; |
| ... | ... | @@ -3765,7 +3765,7 @@ static IrInstSrc *ir_gen_int_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3765 | 3765 | return ir_build_const_bigint(ag, scope, node, bigint); |
| 3766 | 3766 | } |
| 3767 | 3767 | |
| 3768 | | static IrInstSrc *ir_gen_float_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3768 | static IrInstSrc *astgen_float_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3769 | 3769 | Error err; |
| 3770 | 3770 | assert(node->type == NodeTypeFloatLiteral); |
| 3771 | 3771 | |
| ... | ... | @@ -3782,7 +3782,7 @@ static IrInstSrc *ir_gen_float_lit(Stage1AstGen *ag, Scope *scope, AstNode *node |
| 3782 | 3782 | return ir_build_const_bigfloat(ag, scope, node, bigfloat); |
| 3783 | 3783 | } |
| 3784 | 3784 | |
| 3785 | | static IrInstSrc *ir_gen_char_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3785 | static IrInstSrc *astgen_char_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3786 | 3786 | Error err; |
| 3787 | 3787 | assert(node->type == NodeTypeCharLiteral); |
| 3788 | 3788 | |
| ... | ... | @@ -3802,13 +3802,15 @@ static IrInstSrc *ir_gen_char_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3802 | 3802 | return ir_build_const_uint(ag, scope, node, codepoint); |
| 3803 | 3803 | } |
| 3804 | 3804 | |
| 3805 | | static IrInstSrc *ir_gen_null_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3805 | static IrInstSrc *astgen_null_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3806 | 3806 | assert(node->type == NodeTypeNullLiteral); |
| 3807 | 3807 | |
| 3808 | 3808 | return ir_build_const_null(ag, scope, node); |
| 3809 | 3809 | } |
| 3810 | 3810 | |
| 3811 | | static IrInstSrc *ir_gen_symbol(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { |
| 3811 | static IrInstSrc *astgen_identifier(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 3812 | ResultLoc *result_loc) |
| 3813 | { |
| 3812 | 3814 | Error err; |
| 3813 | 3815 | assert(node->type == NodeTypeIdentifier); |
| 3814 | 3816 | |
| ... | ... | @@ -3877,13 +3879,13 @@ static IrInstSrc *ir_gen_symbol(Stage1AstGen *ag, Scope *scope, AstNode *node, L |
| 3877 | 3879 | return ir_build_undeclared_identifier(ag, scope, node, variable_name); |
| 3878 | 3880 | } |
| 3879 | 3881 | |
| 3880 | | static IrInstSrc *ir_gen_array_access(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 3882 | static IrInstSrc *astgen_array_access(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 3881 | 3883 | ResultLoc *result_loc) |
| 3882 | 3884 | { |
| 3883 | 3885 | assert(node->type == NodeTypeArrayAccessExpr); |
| 3884 | 3886 | |
| 3885 | 3887 | AstNode *array_ref_node = node->data.array_access_expr.array_ref_expr; |
| 3886 | | IrInstSrc *array_ref_instruction = ir_gen_node_extra(ag, array_ref_node, scope, LValPtr, nullptr); |
| 3888 | IrInstSrc *array_ref_instruction = astgen_node_extra(ag, array_ref_node, scope, LValPtr, nullptr); |
| 3887 | 3889 | if (array_ref_instruction == ag->codegen->invalid_inst_src) |
| 3888 | 3890 | return array_ref_instruction; |
| 3889 | 3891 | |
| ... | ... | @@ -3894,7 +3896,7 @@ static IrInstSrc *ir_gen_array_access(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 3894 | 3896 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(ag, usize_type_inst, no_result_loc()); |
| 3895 | 3897 | |
| 3896 | 3898 | AstNode *subscript_node = node->data.array_access_expr.subscript; |
| 3897 | | IrInstSrc *subscript_value = ir_gen_node_extra(ag, subscript_node, scope, LValNone, &result_loc_cast->base); |
| 3899 | IrInstSrc *subscript_value = astgen_node_extra(ag, subscript_node, scope, LValNone, &result_loc_cast->base); |
| 3898 | 3900 | if (subscript_value == ag->codegen->invalid_inst_src) |
| 3899 | 3901 | return ag->codegen->invalid_inst_src; |
| 3900 | 3902 | |
| ... | ... | @@ -3909,20 +3911,20 @@ static IrInstSrc *ir_gen_array_access(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 3909 | 3911 | return ir_expr_wrap(ag, scope, load_ptr, result_loc); |
| 3910 | 3912 | } |
| 3911 | 3913 | |
| 3912 | | static IrInstSrc *ir_gen_field_access(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3914 | static IrInstSrc *astgen_field_access(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3913 | 3915 | assert(node->type == NodeTypeFieldAccessExpr); |
| 3914 | 3916 | |
| 3915 | 3917 | AstNode *container_ref_node = node->data.field_access_expr.struct_expr; |
| 3916 | 3918 | Buf *field_name = node->data.field_access_expr.field_name; |
| 3917 | 3919 | |
| 3918 | | IrInstSrc *container_ref_instruction = ir_gen_node_extra(ag, container_ref_node, scope, LValPtr, nullptr); |
| 3920 | IrInstSrc *container_ref_instruction = astgen_node_extra(ag, container_ref_node, scope, LValPtr, nullptr); |
| 3919 | 3921 | if (container_ref_instruction == ag->codegen->invalid_inst_src) |
| 3920 | 3922 | return container_ref_instruction; |
| 3921 | 3923 | |
| 3922 | 3924 | return ir_build_field_ptr(ag, scope, node, container_ref_instruction, field_name, false); |
| 3923 | 3925 | } |
| 3924 | 3926 | |
| 3925 | | static IrInstSrc *ir_gen_overflow_op(Stage1AstGen *ag, Scope *scope, AstNode *node, IrOverflowOp op) { |
| 3927 | static IrInstSrc *astgen_overflow_op(Stage1AstGen *ag, Scope *scope, AstNode *node, IrOverflowOp op) { |
| 3926 | 3928 | assert(node->type == NodeTypeFnCallExpr); |
| 3927 | 3929 | |
| 3928 | 3930 | AstNode *type_node = node->data.fn_call_expr.params.at(0); |
| ... | ... | @@ -3931,26 +3933,26 @@ static IrInstSrc *ir_gen_overflow_op(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 3931 | 3933 | AstNode *result_ptr_node = node->data.fn_call_expr.params.at(3); |
| 3932 | 3934 | |
| 3933 | 3935 | |
| 3934 | | IrInstSrc *type_value = ir_gen_node(ag, type_node, scope); |
| 3936 | IrInstSrc *type_value = astgen_node(ag, type_node, scope); |
| 3935 | 3937 | if (type_value == ag->codegen->invalid_inst_src) |
| 3936 | 3938 | return ag->codegen->invalid_inst_src; |
| 3937 | 3939 | |
| 3938 | | IrInstSrc *op1 = ir_gen_node(ag, op1_node, scope); |
| 3940 | IrInstSrc *op1 = astgen_node(ag, op1_node, scope); |
| 3939 | 3941 | if (op1 == ag->codegen->invalid_inst_src) |
| 3940 | 3942 | return ag->codegen->invalid_inst_src; |
| 3941 | 3943 | |
| 3942 | | IrInstSrc *op2 = ir_gen_node(ag, op2_node, scope); |
| 3944 | IrInstSrc *op2 = astgen_node(ag, op2_node, scope); |
| 3943 | 3945 | if (op2 == ag->codegen->invalid_inst_src) |
| 3944 | 3946 | return ag->codegen->invalid_inst_src; |
| 3945 | 3947 | |
| 3946 | | IrInstSrc *result_ptr = ir_gen_node(ag, result_ptr_node, scope); |
| 3948 | IrInstSrc *result_ptr = astgen_node(ag, result_ptr_node, scope); |
| 3947 | 3949 | if (result_ptr == ag->codegen->invalid_inst_src) |
| 3948 | 3950 | return ag->codegen->invalid_inst_src; |
| 3949 | 3951 | |
| 3950 | 3952 | return ir_build_overflow_op_src(ag, scope, node, op, type_value, op1, op2, result_ptr); |
| 3951 | 3953 | } |
| 3952 | 3954 | |
| 3953 | | static IrInstSrc *ir_gen_mul_add(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3955 | static IrInstSrc *astgen_mul_add(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 3954 | 3956 | assert(node->type == NodeTypeFnCallExpr); |
| 3955 | 3957 | |
| 3956 | 3958 | AstNode *type_node = node->data.fn_call_expr.params.at(0); |
| ... | ... | @@ -3958,26 +3960,26 @@ static IrInstSrc *ir_gen_mul_add(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3958 | 3960 | AstNode *op2_node = node->data.fn_call_expr.params.at(2); |
| 3959 | 3961 | AstNode *op3_node = node->data.fn_call_expr.params.at(3); |
| 3960 | 3962 | |
| 3961 | | IrInstSrc *type_value = ir_gen_node(ag, type_node, scope); |
| 3963 | IrInstSrc *type_value = astgen_node(ag, type_node, scope); |
| 3962 | 3964 | if (type_value == ag->codegen->invalid_inst_src) |
| 3963 | 3965 | return ag->codegen->invalid_inst_src; |
| 3964 | 3966 | |
| 3965 | | IrInstSrc *op1 = ir_gen_node(ag, op1_node, scope); |
| 3967 | IrInstSrc *op1 = astgen_node(ag, op1_node, scope); |
| 3966 | 3968 | if (op1 == ag->codegen->invalid_inst_src) |
| 3967 | 3969 | return ag->codegen->invalid_inst_src; |
| 3968 | 3970 | |
| 3969 | | IrInstSrc *op2 = ir_gen_node(ag, op2_node, scope); |
| 3971 | IrInstSrc *op2 = astgen_node(ag, op2_node, scope); |
| 3970 | 3972 | if (op2 == ag->codegen->invalid_inst_src) |
| 3971 | 3973 | return ag->codegen->invalid_inst_src; |
| 3972 | 3974 | |
| 3973 | | IrInstSrc *op3 = ir_gen_node(ag, op3_node, scope); |
| 3975 | IrInstSrc *op3 = astgen_node(ag, op3_node, scope); |
| 3974 | 3976 | if (op3 == ag->codegen->invalid_inst_src) |
| 3975 | 3977 | return ag->codegen->invalid_inst_src; |
| 3976 | 3978 | |
| 3977 | 3979 | return ir_build_mul_add_src(ag, scope, node, type_value, op1, op2, op3); |
| 3978 | 3980 | } |
| 3979 | 3981 | |
| 3980 | | static IrInstSrc *ir_gen_this(Stage1AstGen *ag, Scope *orig_scope, AstNode *node) { |
| 3982 | static IrInstSrc *astgen_this(Stage1AstGen *ag, Scope *orig_scope, AstNode *node) { |
| 3981 | 3983 | for (Scope *it_scope = orig_scope; it_scope != nullptr; it_scope = it_scope->parent) { |
| 3982 | 3984 | if (it_scope->id == ScopeIdDecls) { |
| 3983 | 3985 | ScopeDecls *decls_scope = (ScopeDecls *)it_scope; |
| ... | ... | @@ -3992,7 +3994,7 @@ static IrInstSrc *ir_gen_this(Stage1AstGen *ag, Scope *orig_scope, AstNode *node |
| 3992 | 3994 | zig_unreachable(); |
| 3993 | 3995 | } |
| 3994 | 3996 | |
| 3995 | | static IrInstSrc *ir_gen_async_call(Stage1AstGen *ag, Scope *scope, AstNode *await_node, AstNode *call_node, |
| 3997 | static IrInstSrc *astgen_async_call(Stage1AstGen *ag, Scope *scope, AstNode *await_node, AstNode *call_node, |
| 3996 | 3998 | LVal lval, ResultLoc *result_loc) |
| 3997 | 3999 | { |
| 3998 | 4000 | if (call_node->data.fn_call_expr.params.length != 4) { |
| ... | ... | @@ -4003,17 +4005,17 @@ static IrInstSrc *ir_gen_async_call(Stage1AstGen *ag, Scope *scope, AstNode *awa |
| 4003 | 4005 | } |
| 4004 | 4006 | |
| 4005 | 4007 | AstNode *bytes_node = call_node->data.fn_call_expr.params.at(0); |
| 4006 | | IrInstSrc *bytes = ir_gen_node(ag, bytes_node, scope); |
| 4008 | IrInstSrc *bytes = astgen_node(ag, bytes_node, scope); |
| 4007 | 4009 | if (bytes == ag->codegen->invalid_inst_src) |
| 4008 | 4010 | return bytes; |
| 4009 | 4011 | |
| 4010 | 4012 | AstNode *ret_ptr_node = call_node->data.fn_call_expr.params.at(1); |
| 4011 | | IrInstSrc *ret_ptr = ir_gen_node(ag, ret_ptr_node, scope); |
| 4013 | IrInstSrc *ret_ptr = astgen_node(ag, ret_ptr_node, scope); |
| 4012 | 4014 | if (ret_ptr == ag->codegen->invalid_inst_src) |
| 4013 | 4015 | return ret_ptr; |
| 4014 | 4016 | |
| 4015 | 4017 | AstNode *fn_ref_node = call_node->data.fn_call_expr.params.at(2); |
| 4016 | | IrInstSrc *fn_ref = ir_gen_node(ag, fn_ref_node, scope); |
| 4018 | IrInstSrc *fn_ref = astgen_node(ag, fn_ref_node, scope); |
| 4017 | 4019 | if (fn_ref == ag->codegen->invalid_inst_src) |
| 4018 | 4020 | return fn_ref; |
| 4019 | 4021 | |
| ... | ... | @@ -4028,7 +4030,7 @@ static IrInstSrc *ir_gen_async_call(Stage1AstGen *ag, Scope *scope, AstNode *awa |
| 4028 | 4030 | IrInstSrc **args = heap::c_allocator.allocate<IrInstSrc*>(arg_count); |
| 4029 | 4031 | for (size_t i = 0; i < arg_count; i += 1) { |
| 4030 | 4032 | AstNode *arg_node = args_node->data.container_init_expr.entries.at(i); |
| 4031 | | IrInstSrc *arg = ir_gen_node(ag, arg_node, scope); |
| 4033 | IrInstSrc *arg = astgen_node(ag, arg_node, scope); |
| 4032 | 4034 | if (arg == ag->codegen->invalid_inst_src) |
| 4033 | 4035 | return arg; |
| 4034 | 4036 | args[i] = arg; |
| ... | ... | @@ -4043,7 +4045,7 @@ static IrInstSrc *ir_gen_async_call(Stage1AstGen *ag, Scope *scope, AstNode *awa |
| 4043 | 4045 | return ag->codegen->invalid_inst_src; |
| 4044 | 4046 | } |
| 4045 | 4047 | } |
| 4046 | | IrInstSrc *args = ir_gen_node(ag, args_node, scope); |
| 4048 | IrInstSrc *args = astgen_node(ag, args_node, scope); |
| 4047 | 4049 | if (args == ag->codegen->invalid_inst_src) |
| 4048 | 4050 | return args; |
| 4049 | 4051 | |
| ... | ... | @@ -4051,11 +4053,11 @@ static IrInstSrc *ir_gen_async_call(Stage1AstGen *ag, Scope *scope, AstNode *awa |
| 4051 | 4053 | return ir_lval_wrap(ag, scope, call, lval, result_loc); |
| 4052 | 4054 | } |
| 4053 | 4055 | |
| 4054 | | static IrInstSrc *ir_gen_fn_call_with_args(Stage1AstGen *ag, Scope *scope, AstNode *source_node, |
| 4056 | static IrInstSrc *astgen_fn_call_with_args(Stage1AstGen *ag, Scope *scope, AstNode *source_node, |
| 4055 | 4057 | AstNode *fn_ref_node, CallModifier modifier, IrInstSrc *options, |
| 4056 | 4058 | AstNode **args_ptr, size_t args_len, LVal lval, ResultLoc *result_loc) |
| 4057 | 4059 | { |
| 4058 | | IrInstSrc *fn_ref = ir_gen_node(ag, fn_ref_node, scope); |
| 4060 | IrInstSrc *fn_ref = astgen_node(ag, fn_ref_node, scope); |
| 4059 | 4061 | if (fn_ref == ag->codegen->invalid_inst_src) |
| 4060 | 4062 | return fn_ref; |
| 4061 | 4063 | |
| ... | ... | @@ -4071,7 +4073,7 @@ static IrInstSrc *ir_gen_fn_call_with_args(Stage1AstGen *ag, Scope *scope, AstNo |
| 4071 | 4073 | ir_build_reset_result(ag, scope, source_node, no_result); |
| 4072 | 4074 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(ag, arg_type, no_result); |
| 4073 | 4075 | |
| 4074 | | IrInstSrc *arg = ir_gen_node_extra(ag, arg_node, scope, LValNone, &result_loc_cast->base); |
| 4076 | IrInstSrc *arg = astgen_node_extra(ag, arg_node, scope, LValNone, &result_loc_cast->base); |
| 4075 | 4077 | if (arg == ag->codegen->invalid_inst_src) |
| 4076 | 4078 | return arg; |
| 4077 | 4079 | |
| ... | ... | @@ -4088,7 +4090,7 @@ static IrInstSrc *ir_gen_fn_call_with_args(Stage1AstGen *ag, Scope *scope, AstNo |
| 4088 | 4090 | return ir_lval_wrap(ag, scope, fn_call, lval, result_loc); |
| 4089 | 4091 | } |
| 4090 | 4092 | |
| 4091 | | static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 4093 | static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 4092 | 4094 | ResultLoc *result_loc) |
| 4093 | 4095 | { |
| 4094 | 4096 | assert(node->type == NodeTypeFnCallExpr); |
| ... | ... | @@ -4130,7 +4132,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4130 | 4132 | return ag->codegen->invalid_inst_src; |
| 4131 | 4133 | } else if (arg_count == 1) { |
| 4132 | 4134 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4133 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, sub_scope); |
| 4135 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, sub_scope); |
| 4134 | 4136 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4135 | 4137 | return arg0_value; |
| 4136 | 4138 | |
| ... | ... | @@ -4139,7 +4141,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4139 | 4141 | IrInstSrc **args = heap::c_allocator.allocate<IrInstSrc*>(arg_count); |
| 4140 | 4142 | for (size_t i = 0; i < arg_count; i += 1) { |
| 4141 | 4143 | AstNode *arg_node = node->data.fn_call_expr.params.at(i); |
| 4142 | | IrInstSrc *arg = ir_gen_node(ag, arg_node, sub_scope); |
| 4144 | IrInstSrc *arg = astgen_node(ag, arg_node, sub_scope); |
| 4143 | 4145 | if (arg == ag->codegen->invalid_inst_src) |
| 4144 | 4146 | return ag->codegen->invalid_inst_src; |
| 4145 | 4147 | args[i] = arg; |
| ... | ... | @@ -4152,7 +4154,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4152 | 4154 | case BuiltinFnIdSetCold: |
| 4153 | 4155 | { |
| 4154 | 4156 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4155 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4157 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4156 | 4158 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4157 | 4159 | return arg0_value; |
| 4158 | 4160 | |
| ... | ... | @@ -4162,7 +4164,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4162 | 4164 | case BuiltinFnIdSetRuntimeSafety: |
| 4163 | 4165 | { |
| 4164 | 4166 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4165 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4167 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4166 | 4168 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4167 | 4169 | return arg0_value; |
| 4168 | 4170 | |
| ... | ... | @@ -4172,7 +4174,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4172 | 4174 | case BuiltinFnIdSetFloatMode: |
| 4173 | 4175 | { |
| 4174 | 4176 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4175 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4177 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4176 | 4178 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4177 | 4179 | return arg0_value; |
| 4178 | 4180 | |
| ... | ... | @@ -4183,7 +4185,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4183 | 4185 | case BuiltinFnIdBitSizeof: |
| 4184 | 4186 | { |
| 4185 | 4187 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4186 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4188 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4187 | 4189 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4188 | 4190 | return arg0_value; |
| 4189 | 4191 | |
| ... | ... | @@ -4193,7 +4195,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4193 | 4195 | case BuiltinFnIdImport: |
| 4194 | 4196 | { |
| 4195 | 4197 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4196 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4198 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4197 | 4199 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4198 | 4200 | return arg0_value; |
| 4199 | 4201 | |
| ... | ... | @@ -4208,7 +4210,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4208 | 4210 | case BuiltinFnIdCInclude: |
| 4209 | 4211 | { |
| 4210 | 4212 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4211 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4213 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4212 | 4214 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4213 | 4215 | return arg0_value; |
| 4214 | 4216 | |
| ... | ... | @@ -4223,12 +4225,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4223 | 4225 | case BuiltinFnIdCDefine: |
| 4224 | 4226 | { |
| 4225 | 4227 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4226 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4228 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4227 | 4229 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4228 | 4230 | return arg0_value; |
| 4229 | 4231 | |
| 4230 | 4232 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4231 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4233 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4232 | 4234 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4233 | 4235 | return arg1_value; |
| 4234 | 4236 | |
| ... | ... | @@ -4243,7 +4245,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4243 | 4245 | case BuiltinFnIdCUndef: |
| 4244 | 4246 | { |
| 4245 | 4247 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4246 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4248 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4247 | 4249 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4248 | 4250 | return arg0_value; |
| 4249 | 4251 | |
| ... | ... | @@ -4258,7 +4260,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4258 | 4260 | case BuiltinFnIdCompileErr: |
| 4259 | 4261 | { |
| 4260 | 4262 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4261 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4263 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4262 | 4264 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4263 | 4265 | return arg0_value; |
| 4264 | 4266 | |
| ... | ... | @@ -4271,7 +4273,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4271 | 4273 | |
| 4272 | 4274 | for (size_t i = 0; i < actual_param_count; i += 1) { |
| 4273 | 4275 | AstNode *arg_node = node->data.fn_call_expr.params.at(i); |
| 4274 | | args[i] = ir_gen_node(ag, arg_node, scope); |
| 4276 | args[i] = astgen_node(ag, arg_node, scope); |
| 4275 | 4277 | if (args[i] == ag->codegen->invalid_inst_src) |
| 4276 | 4278 | return ag->codegen->invalid_inst_src; |
| 4277 | 4279 | } |
| ... | ... | @@ -4282,7 +4284,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4282 | 4284 | case BuiltinFnIdErrName: |
| 4283 | 4285 | { |
| 4284 | 4286 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4285 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4287 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4286 | 4288 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4287 | 4289 | return arg0_value; |
| 4288 | 4290 | |
| ... | ... | @@ -4292,7 +4294,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4292 | 4294 | case BuiltinFnIdEmbedFile: |
| 4293 | 4295 | { |
| 4294 | 4296 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4295 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4297 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4296 | 4298 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4297 | 4299 | return arg0_value; |
| 4298 | 4300 | |
| ... | ... | @@ -4303,32 +4305,32 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4303 | 4305 | case BuiltinFnIdCmpxchgStrong: |
| 4304 | 4306 | { |
| 4305 | 4307 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4306 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4308 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4307 | 4309 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4308 | 4310 | return arg0_value; |
| 4309 | 4311 | |
| 4310 | 4312 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4311 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4313 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4312 | 4314 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4313 | 4315 | return arg1_value; |
| 4314 | 4316 | |
| 4315 | 4317 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 4316 | | IrInstSrc *arg2_value = ir_gen_node(ag, arg2_node, scope); |
| 4318 | IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope); |
| 4317 | 4319 | if (arg2_value == ag->codegen->invalid_inst_src) |
| 4318 | 4320 | return arg2_value; |
| 4319 | 4321 | |
| 4320 | 4322 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); |
| 4321 | | IrInstSrc *arg3_value = ir_gen_node(ag, arg3_node, scope); |
| 4323 | IrInstSrc *arg3_value = astgen_node(ag, arg3_node, scope); |
| 4322 | 4324 | if (arg3_value == ag->codegen->invalid_inst_src) |
| 4323 | 4325 | return arg3_value; |
| 4324 | 4326 | |
| 4325 | 4327 | AstNode *arg4_node = node->data.fn_call_expr.params.at(4); |
| 4326 | | IrInstSrc *arg4_value = ir_gen_node(ag, arg4_node, scope); |
| 4328 | IrInstSrc *arg4_value = astgen_node(ag, arg4_node, scope); |
| 4327 | 4329 | if (arg4_value == ag->codegen->invalid_inst_src) |
| 4328 | 4330 | return arg4_value; |
| 4329 | 4331 | |
| 4330 | 4332 | AstNode *arg5_node = node->data.fn_call_expr.params.at(5); |
| 4331 | | IrInstSrc *arg5_value = ir_gen_node(ag, arg5_node, scope); |
| 4333 | IrInstSrc *arg5_value = astgen_node(ag, arg5_node, scope); |
| 4332 | 4334 | if (arg5_value == ag->codegen->invalid_inst_src) |
| 4333 | 4335 | return arg5_value; |
| 4334 | 4336 | |
| ... | ... | @@ -4340,7 +4342,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4340 | 4342 | case BuiltinFnIdFence: |
| 4341 | 4343 | { |
| 4342 | 4344 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4343 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4345 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4344 | 4346 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4345 | 4347 | return arg0_value; |
| 4346 | 4348 | |
| ... | ... | @@ -4350,12 +4352,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4350 | 4352 | case BuiltinFnIdReduce: |
| 4351 | 4353 | { |
| 4352 | 4354 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4353 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4355 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4354 | 4356 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4355 | 4357 | return arg0_value; |
| 4356 | 4358 | |
| 4357 | 4359 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4358 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4360 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4359 | 4361 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4360 | 4362 | return arg1_value; |
| 4361 | 4363 | |
| ... | ... | @@ -4365,12 +4367,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4365 | 4367 | case BuiltinFnIdDivExact: |
| 4366 | 4368 | { |
| 4367 | 4369 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4368 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4370 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4369 | 4371 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4370 | 4372 | return arg0_value; |
| 4371 | 4373 | |
| 4372 | 4374 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4373 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4375 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4374 | 4376 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4375 | 4377 | return arg1_value; |
| 4376 | 4378 | |
| ... | ... | @@ -4380,12 +4382,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4380 | 4382 | case BuiltinFnIdDivTrunc: |
| 4381 | 4383 | { |
| 4382 | 4384 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4383 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4385 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4384 | 4386 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4385 | 4387 | return arg0_value; |
| 4386 | 4388 | |
| 4387 | 4389 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4388 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4390 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4389 | 4391 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4390 | 4392 | return arg1_value; |
| 4391 | 4393 | |
| ... | ... | @@ -4395,12 +4397,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4395 | 4397 | case BuiltinFnIdDivFloor: |
| 4396 | 4398 | { |
| 4397 | 4399 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4398 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4400 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4399 | 4401 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4400 | 4402 | return arg0_value; |
| 4401 | 4403 | |
| 4402 | 4404 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4403 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4405 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4404 | 4406 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4405 | 4407 | return arg1_value; |
| 4406 | 4408 | |
| ... | ... | @@ -4410,12 +4412,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4410 | 4412 | case BuiltinFnIdRem: |
| 4411 | 4413 | { |
| 4412 | 4414 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4413 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4415 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4414 | 4416 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4415 | 4417 | return arg0_value; |
| 4416 | 4418 | |
| 4417 | 4419 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4418 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4420 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4419 | 4421 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4420 | 4422 | return arg1_value; |
| 4421 | 4423 | |
| ... | ... | @@ -4425,12 +4427,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4425 | 4427 | case BuiltinFnIdMod: |
| 4426 | 4428 | { |
| 4427 | 4429 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4428 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4430 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4429 | 4431 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4430 | 4432 | return arg0_value; |
| 4431 | 4433 | |
| 4432 | 4434 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4433 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4435 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4434 | 4436 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4435 | 4437 | return arg1_value; |
| 4436 | 4438 | |
| ... | ... | @@ -4453,7 +4455,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4453 | 4455 | case BuiltinFnIdRound: |
| 4454 | 4456 | { |
| 4455 | 4457 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4456 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4458 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4457 | 4459 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4458 | 4460 | return arg0_value; |
| 4459 | 4461 | |
| ... | ... | @@ -4463,12 +4465,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4463 | 4465 | case BuiltinFnIdTruncate: |
| 4464 | 4466 | { |
| 4465 | 4467 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4466 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4468 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4467 | 4469 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4468 | 4470 | return arg0_value; |
| 4469 | 4471 | |
| 4470 | 4472 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4471 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4473 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4472 | 4474 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4473 | 4475 | return arg1_value; |
| 4474 | 4476 | |
| ... | ... | @@ -4478,12 +4480,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4478 | 4480 | case BuiltinFnIdIntCast: |
| 4479 | 4481 | { |
| 4480 | 4482 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4481 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4483 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4482 | 4484 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4483 | 4485 | return arg0_value; |
| 4484 | 4486 | |
| 4485 | 4487 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4486 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4488 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4487 | 4489 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4488 | 4490 | return arg1_value; |
| 4489 | 4491 | |
| ... | ... | @@ -4493,12 +4495,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4493 | 4495 | case BuiltinFnIdFloatCast: |
| 4494 | 4496 | { |
| 4495 | 4497 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4496 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4498 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4497 | 4499 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4498 | 4500 | return arg0_value; |
| 4499 | 4501 | |
| 4500 | 4502 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4501 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4503 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4502 | 4504 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4503 | 4505 | return arg1_value; |
| 4504 | 4506 | |
| ... | ... | @@ -4508,12 +4510,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4508 | 4510 | case BuiltinFnIdErrSetCast: |
| 4509 | 4511 | { |
| 4510 | 4512 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4511 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4513 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4512 | 4514 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4513 | 4515 | return arg0_value; |
| 4514 | 4516 | |
| 4515 | 4517 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4516 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4518 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4517 | 4519 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4518 | 4520 | return arg1_value; |
| 4519 | 4521 | |
| ... | ... | @@ -4523,12 +4525,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4523 | 4525 | case BuiltinFnIdIntToFloat: |
| 4524 | 4526 | { |
| 4525 | 4527 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4526 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4528 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4527 | 4529 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4528 | 4530 | return arg0_value; |
| 4529 | 4531 | |
| 4530 | 4532 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4531 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4533 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4532 | 4534 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4533 | 4535 | return arg1_value; |
| 4534 | 4536 | |
| ... | ... | @@ -4538,12 +4540,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4538 | 4540 | case BuiltinFnIdFloatToInt: |
| 4539 | 4541 | { |
| 4540 | 4542 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4541 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4543 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4542 | 4544 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4543 | 4545 | return arg0_value; |
| 4544 | 4546 | |
| 4545 | 4547 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4546 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4548 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4547 | 4549 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4548 | 4550 | return arg1_value; |
| 4549 | 4551 | |
| ... | ... | @@ -4553,7 +4555,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4553 | 4555 | case BuiltinFnIdErrToInt: |
| 4554 | 4556 | { |
| 4555 | 4557 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4556 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4558 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4557 | 4559 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4558 | 4560 | return arg0_value; |
| 4559 | 4561 | |
| ... | ... | @@ -4563,7 +4565,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4563 | 4565 | case BuiltinFnIdIntToErr: |
| 4564 | 4566 | { |
| 4565 | 4567 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4566 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4568 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4567 | 4569 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4568 | 4570 | return arg0_value; |
| 4569 | 4571 | |
| ... | ... | @@ -4573,7 +4575,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4573 | 4575 | case BuiltinFnIdBoolToInt: |
| 4574 | 4576 | { |
| 4575 | 4577 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4576 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4578 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4577 | 4579 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4578 | 4580 | return arg0_value; |
| 4579 | 4581 | |
| ... | ... | @@ -4583,12 +4585,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4583 | 4585 | case BuiltinFnIdVectorType: |
| 4584 | 4586 | { |
| 4585 | 4587 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4586 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4588 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4587 | 4589 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4588 | 4590 | return arg0_value; |
| 4589 | 4591 | |
| 4590 | 4592 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4591 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4593 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4592 | 4594 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4593 | 4595 | return arg1_value; |
| 4594 | 4596 | |
| ... | ... | @@ -4598,22 +4600,22 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4598 | 4600 | case BuiltinFnIdShuffle: |
| 4599 | 4601 | { |
| 4600 | 4602 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4601 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4603 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4602 | 4604 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4603 | 4605 | return arg0_value; |
| 4604 | 4606 | |
| 4605 | 4607 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4606 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4608 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4607 | 4609 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4608 | 4610 | return arg1_value; |
| 4609 | 4611 | |
| 4610 | 4612 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 4611 | | IrInstSrc *arg2_value = ir_gen_node(ag, arg2_node, scope); |
| 4613 | IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope); |
| 4612 | 4614 | if (arg2_value == ag->codegen->invalid_inst_src) |
| 4613 | 4615 | return arg2_value; |
| 4614 | 4616 | |
| 4615 | 4617 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); |
| 4616 | | IrInstSrc *arg3_value = ir_gen_node(ag, arg3_node, scope); |
| 4618 | IrInstSrc *arg3_value = astgen_node(ag, arg3_node, scope); |
| 4617 | 4619 | if (arg3_value == ag->codegen->invalid_inst_src) |
| 4618 | 4620 | return arg3_value; |
| 4619 | 4621 | |
| ... | ... | @@ -4624,12 +4626,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4624 | 4626 | case BuiltinFnIdSplat: |
| 4625 | 4627 | { |
| 4626 | 4628 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4627 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4629 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4628 | 4630 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4629 | 4631 | return arg0_value; |
| 4630 | 4632 | |
| 4631 | 4633 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4632 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4634 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4633 | 4635 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4634 | 4636 | return arg1_value; |
| 4635 | 4637 | |
| ... | ... | @@ -4640,17 +4642,17 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4640 | 4642 | case BuiltinFnIdMemcpy: |
| 4641 | 4643 | { |
| 4642 | 4644 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4643 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4645 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4644 | 4646 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4645 | 4647 | return arg0_value; |
| 4646 | 4648 | |
| 4647 | 4649 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4648 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4650 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4649 | 4651 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4650 | 4652 | return arg1_value; |
| 4651 | 4653 | |
| 4652 | 4654 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 4653 | | IrInstSrc *arg2_value = ir_gen_node(ag, arg2_node, scope); |
| 4655 | IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope); |
| 4654 | 4656 | if (arg2_value == ag->codegen->invalid_inst_src) |
| 4655 | 4657 | return arg2_value; |
| 4656 | 4658 | |
| ... | ... | @@ -4660,17 +4662,17 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4660 | 4662 | case BuiltinFnIdMemset: |
| 4661 | 4663 | { |
| 4662 | 4664 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4663 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4665 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4664 | 4666 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4665 | 4667 | return arg0_value; |
| 4666 | 4668 | |
| 4667 | 4669 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4668 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4670 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4669 | 4671 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4670 | 4672 | return arg1_value; |
| 4671 | 4673 | |
| 4672 | 4674 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 4673 | | IrInstSrc *arg2_value = ir_gen_node(ag, arg2_node, scope); |
| 4675 | IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope); |
| 4674 | 4676 | if (arg2_value == ag->codegen->invalid_inst_src) |
| 4675 | 4677 | return arg2_value; |
| 4676 | 4678 | |
| ... | ... | @@ -4680,7 +4682,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4680 | 4682 | case BuiltinFnIdWasmMemorySize: |
| 4681 | 4683 | { |
| 4682 | 4684 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4683 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4685 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4684 | 4686 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4685 | 4687 | return arg0_value; |
| 4686 | 4688 | |
| ... | ... | @@ -4690,12 +4692,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4690 | 4692 | case BuiltinFnIdWasmMemoryGrow: |
| 4691 | 4693 | { |
| 4692 | 4694 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4693 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4695 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4694 | 4696 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4695 | 4697 | return arg0_value; |
| 4696 | 4698 | |
| 4697 | 4699 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4698 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4700 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4699 | 4701 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4700 | 4702 | return arg1_value; |
| 4701 | 4703 | |
| ... | ... | @@ -4705,12 +4707,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4705 | 4707 | case BuiltinFnIdField: |
| 4706 | 4708 | { |
| 4707 | 4709 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4708 | | IrInstSrc *arg0_value = ir_gen_node_extra(ag, arg0_node, scope, LValPtr, nullptr); |
| 4710 | IrInstSrc *arg0_value = astgen_node_extra(ag, arg0_node, scope, LValPtr, nullptr); |
| 4709 | 4711 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4710 | 4712 | return arg0_value; |
| 4711 | 4713 | |
| 4712 | 4714 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4713 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4715 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4714 | 4716 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4715 | 4717 | return arg1_value; |
| 4716 | 4718 | |
| ... | ... | @@ -4726,12 +4728,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4726 | 4728 | case BuiltinFnIdHasField: |
| 4727 | 4729 | { |
| 4728 | 4730 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4729 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4731 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4730 | 4732 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4731 | 4733 | return arg0_value; |
| 4732 | 4734 | |
| 4733 | 4735 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4734 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4736 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4735 | 4737 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4736 | 4738 | return arg1_value; |
| 4737 | 4739 | |
| ... | ... | @@ -4741,7 +4743,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4741 | 4743 | case BuiltinFnIdTypeInfo: |
| 4742 | 4744 | { |
| 4743 | 4745 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4744 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4746 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4745 | 4747 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4746 | 4748 | return arg0_value; |
| 4747 | 4749 | |
| ... | ... | @@ -4751,7 +4753,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4751 | 4753 | case BuiltinFnIdType: |
| 4752 | 4754 | { |
| 4753 | 4755 | AstNode *arg_node = node->data.fn_call_expr.params.at(0); |
| 4754 | | IrInstSrc *arg = ir_gen_node(ag, arg_node, scope); |
| 4756 | IrInstSrc *arg = astgen_node(ag, arg_node, scope); |
| 4755 | 4757 | if (arg == ag->codegen->invalid_inst_src) |
| 4756 | 4758 | return arg; |
| 4757 | 4759 | |
| ... | ... | @@ -4773,7 +4775,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4773 | 4775 | return ir_lval_wrap(ag, scope, ir_build_handle_src(ag, scope, node), lval, result_loc); |
| 4774 | 4776 | case BuiltinFnIdFrameType: { |
| 4775 | 4777 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4776 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4778 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4777 | 4779 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4778 | 4780 | return arg0_value; |
| 4779 | 4781 | |
| ... | ... | @@ -4782,7 +4784,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4782 | 4784 | } |
| 4783 | 4785 | case BuiltinFnIdFrameSize: { |
| 4784 | 4786 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4785 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4787 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4786 | 4788 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4787 | 4789 | return arg0_value; |
| 4788 | 4790 | |
| ... | ... | @@ -4792,7 +4794,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4792 | 4794 | case BuiltinFnIdAlignOf: |
| 4793 | 4795 | { |
| 4794 | 4796 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4795 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4797 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4796 | 4798 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4797 | 4799 | return arg0_value; |
| 4798 | 4800 | |
| ... | ... | @@ -4800,19 +4802,19 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4800 | 4802 | return ir_lval_wrap(ag, scope, align_of, lval, result_loc); |
| 4801 | 4803 | } |
| 4802 | 4804 | case BuiltinFnIdAddWithOverflow: |
| 4803 | | return ir_lval_wrap(ag, scope, ir_gen_overflow_op(ag, scope, node, IrOverflowOpAdd), lval, result_loc); |
| 4805 | return ir_lval_wrap(ag, scope, astgen_overflow_op(ag, scope, node, IrOverflowOpAdd), lval, result_loc); |
| 4804 | 4806 | case BuiltinFnIdSubWithOverflow: |
| 4805 | | return ir_lval_wrap(ag, scope, ir_gen_overflow_op(ag, scope, node, IrOverflowOpSub), lval, result_loc); |
| 4807 | return ir_lval_wrap(ag, scope, astgen_overflow_op(ag, scope, node, IrOverflowOpSub), lval, result_loc); |
| 4806 | 4808 | case BuiltinFnIdMulWithOverflow: |
| 4807 | | return ir_lval_wrap(ag, scope, ir_gen_overflow_op(ag, scope, node, IrOverflowOpMul), lval, result_loc); |
| 4809 | return ir_lval_wrap(ag, scope, astgen_overflow_op(ag, scope, node, IrOverflowOpMul), lval, result_loc); |
| 4808 | 4810 | case BuiltinFnIdShlWithOverflow: |
| 4809 | | return ir_lval_wrap(ag, scope, ir_gen_overflow_op(ag, scope, node, IrOverflowOpShl), lval, result_loc); |
| 4811 | return ir_lval_wrap(ag, scope, astgen_overflow_op(ag, scope, node, IrOverflowOpShl), lval, result_loc); |
| 4810 | 4812 | case BuiltinFnIdMulAdd: |
| 4811 | | return ir_lval_wrap(ag, scope, ir_gen_mul_add(ag, scope, node), lval, result_loc); |
| 4813 | return ir_lval_wrap(ag, scope, astgen_mul_add(ag, scope, node), lval, result_loc); |
| 4812 | 4814 | case BuiltinFnIdTypeName: |
| 4813 | 4815 | { |
| 4814 | 4816 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4815 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4817 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4816 | 4818 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4817 | 4819 | return arg0_value; |
| 4818 | 4820 | |
| ... | ... | @@ -4822,7 +4824,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4822 | 4824 | case BuiltinFnIdPanic: |
| 4823 | 4825 | { |
| 4824 | 4826 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4825 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4827 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4826 | 4828 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4827 | 4829 | return arg0_value; |
| 4828 | 4830 | |
| ... | ... | @@ -4832,12 +4834,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4832 | 4834 | case BuiltinFnIdPtrCast: |
| 4833 | 4835 | { |
| 4834 | 4836 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4835 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4837 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4836 | 4838 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4837 | 4839 | return arg0_value; |
| 4838 | 4840 | |
| 4839 | 4841 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4840 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4842 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4841 | 4843 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4842 | 4844 | return arg1_value; |
| 4843 | 4845 | |
| ... | ... | @@ -4847,7 +4849,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4847 | 4849 | case BuiltinFnIdBitCast: |
| 4848 | 4850 | { |
| 4849 | 4851 | AstNode *dest_type_node = node->data.fn_call_expr.params.at(0); |
| 4850 | | IrInstSrc *dest_type = ir_gen_node(ag, dest_type_node, scope); |
| 4852 | IrInstSrc *dest_type = astgen_node(ag, dest_type_node, scope); |
| 4851 | 4853 | if (dest_type == ag->codegen->invalid_inst_src) |
| 4852 | 4854 | return dest_type; |
| 4853 | 4855 | |
| ... | ... | @@ -4861,7 +4863,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4861 | 4863 | ir_build_reset_result(ag, scope, node, &result_loc_bit_cast->base); |
| 4862 | 4864 | |
| 4863 | 4865 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4864 | | IrInstSrc *arg1_value = ir_gen_node_extra(ag, arg1_node, scope, LValNone, |
| 4866 | IrInstSrc *arg1_value = astgen_node_extra(ag, arg1_node, scope, LValNone, |
| 4865 | 4867 | &result_loc_bit_cast->base); |
| 4866 | 4868 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4867 | 4869 | return arg1_value; |
| ... | ... | @@ -4872,14 +4874,14 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4872 | 4874 | case BuiltinFnIdAs: |
| 4873 | 4875 | { |
| 4874 | 4876 | AstNode *dest_type_node = node->data.fn_call_expr.params.at(0); |
| 4875 | | IrInstSrc *dest_type = ir_gen_node(ag, dest_type_node, scope); |
| 4877 | IrInstSrc *dest_type = astgen_node(ag, dest_type_node, scope); |
| 4876 | 4878 | if (dest_type == ag->codegen->invalid_inst_src) |
| 4877 | 4879 | return dest_type; |
| 4878 | 4880 | |
| 4879 | 4881 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(ag, dest_type, result_loc); |
| 4880 | 4882 | |
| 4881 | 4883 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4882 | | IrInstSrc *arg1_value = ir_gen_node_extra(ag, arg1_node, scope, LValNone, |
| 4884 | IrInstSrc *arg1_value = astgen_node_extra(ag, arg1_node, scope, LValNone, |
| 4883 | 4885 | &result_loc_cast->base); |
| 4884 | 4886 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4885 | 4887 | return arg1_value; |
| ... | ... | @@ -4890,12 +4892,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4890 | 4892 | case BuiltinFnIdIntToPtr: |
| 4891 | 4893 | { |
| 4892 | 4894 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4893 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4895 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4894 | 4896 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4895 | 4897 | return arg0_value; |
| 4896 | 4898 | |
| 4897 | 4899 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4898 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4900 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4899 | 4901 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4900 | 4902 | return arg1_value; |
| 4901 | 4903 | |
| ... | ... | @@ -4905,7 +4907,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4905 | 4907 | case BuiltinFnIdPtrToInt: |
| 4906 | 4908 | { |
| 4907 | 4909 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4908 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4910 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4909 | 4911 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4910 | 4912 | return arg0_value; |
| 4911 | 4913 | |
| ... | ... | @@ -4915,7 +4917,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4915 | 4917 | case BuiltinFnIdTagName: |
| 4916 | 4918 | { |
| 4917 | 4919 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4918 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4920 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4919 | 4921 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4920 | 4922 | return arg0_value; |
| 4921 | 4923 | |
| ... | ... | @@ -4925,17 +4927,17 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4925 | 4927 | case BuiltinFnIdFieldParentPtr: |
| 4926 | 4928 | { |
| 4927 | 4929 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4928 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4930 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4929 | 4931 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4930 | 4932 | return arg0_value; |
| 4931 | 4933 | |
| 4932 | 4934 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4933 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4935 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4934 | 4936 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4935 | 4937 | return arg1_value; |
| 4936 | 4938 | |
| 4937 | 4939 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 4938 | | IrInstSrc *arg2_value = ir_gen_node(ag, arg2_node, scope); |
| 4940 | IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope); |
| 4939 | 4941 | if (arg2_value == ag->codegen->invalid_inst_src) |
| 4940 | 4942 | return arg2_value; |
| 4941 | 4943 | |
| ... | ... | @@ -4946,12 +4948,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4946 | 4948 | case BuiltinFnIdByteOffsetOf: |
| 4947 | 4949 | { |
| 4948 | 4950 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4949 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4951 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4950 | 4952 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4951 | 4953 | return arg0_value; |
| 4952 | 4954 | |
| 4953 | 4955 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4954 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4956 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4955 | 4957 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4956 | 4958 | return arg1_value; |
| 4957 | 4959 | |
| ... | ... | @@ -4961,12 +4963,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4961 | 4963 | case BuiltinFnIdBitOffsetOf: |
| 4962 | 4964 | { |
| 4963 | 4965 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 4964 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 4966 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 4965 | 4967 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 4966 | 4968 | return arg0_value; |
| 4967 | 4969 | |
| 4968 | 4970 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 4969 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 4971 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 4970 | 4972 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 4971 | 4973 | return arg1_value; |
| 4972 | 4974 | |
| ... | ... | @@ -4980,7 +4982,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4980 | 4982 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(ag, options_type_inst, no_result_loc()); |
| 4981 | 4983 | |
| 4982 | 4984 | AstNode *options_node = node->data.fn_call_expr.params.at(0); |
| 4983 | | IrInstSrc *options_inner = ir_gen_node_extra(ag, options_node, scope, |
| 4985 | IrInstSrc *options_inner = astgen_node_extra(ag, options_node, scope, |
| 4984 | 4986 | LValNone, &result_loc_cast->base); |
| 4985 | 4987 | if (options_inner == ag->codegen->invalid_inst_src) |
| 4986 | 4988 | return options_inner; |
| ... | ... | @@ -4992,7 +4994,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 4992 | 4994 | if (args_node->data.container_init_expr.kind == ContainerInitKindArray || |
| 4993 | 4995 | args_node->data.container_init_expr.entries.length == 0) |
| 4994 | 4996 | { |
| 4995 | | return ir_gen_fn_call_with_args(ag, scope, node, |
| 4997 | return astgen_fn_call_with_args(ag, scope, node, |
| 4996 | 4998 | fn_ref_node, CallModifierNone, options, |
| 4997 | 4999 | args_node->data.container_init_expr.entries.items, |
| 4998 | 5000 | args_node->data.container_init_expr.entries.length, |
| ... | ... | @@ -5003,11 +5005,11 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5003 | 5005 | return ag->codegen->invalid_inst_src; |
| 5004 | 5006 | } |
| 5005 | 5007 | } else { |
| 5006 | | IrInstSrc *fn_ref = ir_gen_node(ag, fn_ref_node, scope); |
| 5008 | IrInstSrc *fn_ref = astgen_node(ag, fn_ref_node, scope); |
| 5007 | 5009 | if (fn_ref == ag->codegen->invalid_inst_src) |
| 5008 | 5010 | return fn_ref; |
| 5009 | 5011 | |
| 5010 | | IrInstSrc *args = ir_gen_node(ag, args_node, scope); |
| 5012 | IrInstSrc *args = astgen_node(ag, args_node, scope); |
| 5011 | 5013 | if (args == ag->codegen->invalid_inst_src) |
| 5012 | 5014 | return args; |
| 5013 | 5015 | |
| ... | ... | @@ -5016,16 +5018,16 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5016 | 5018 | } |
| 5017 | 5019 | } |
| 5018 | 5020 | case BuiltinFnIdAsyncCall: |
| 5019 | | return ir_gen_async_call(ag, scope, nullptr, node, lval, result_loc); |
| 5021 | return astgen_async_call(ag, scope, nullptr, node, lval, result_loc); |
| 5020 | 5022 | case BuiltinFnIdShlExact: |
| 5021 | 5023 | { |
| 5022 | 5024 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5023 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 5025 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 5024 | 5026 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5025 | 5027 | return arg0_value; |
| 5026 | 5028 | |
| 5027 | 5029 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5028 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 5030 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 5029 | 5031 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 5030 | 5032 | return arg1_value; |
| 5031 | 5033 | |
| ... | ... | @@ -5035,12 +5037,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5035 | 5037 | case BuiltinFnIdShrExact: |
| 5036 | 5038 | { |
| 5037 | 5039 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5038 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 5040 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 5039 | 5041 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5040 | 5042 | return arg0_value; |
| 5041 | 5043 | |
| 5042 | 5044 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5043 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 5045 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 5044 | 5046 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 5045 | 5047 | return arg1_value; |
| 5046 | 5048 | |
| ... | ... | @@ -5050,7 +5052,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5050 | 5052 | case BuiltinFnIdSetEvalBranchQuota: |
| 5051 | 5053 | { |
| 5052 | 5054 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5053 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 5055 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 5054 | 5056 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5055 | 5057 | return arg0_value; |
| 5056 | 5058 | |
| ... | ... | @@ -5060,12 +5062,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5060 | 5062 | case BuiltinFnIdAlignCast: |
| 5061 | 5063 | { |
| 5062 | 5064 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5063 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 5065 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 5064 | 5066 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5065 | 5067 | return arg0_value; |
| 5066 | 5068 | |
| 5067 | 5069 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5068 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 5070 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 5069 | 5071 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 5070 | 5072 | return arg1_value; |
| 5071 | 5073 | |
| ... | ... | @@ -5074,13 +5076,13 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5074 | 5076 | } |
| 5075 | 5077 | case BuiltinFnIdThis: |
| 5076 | 5078 | { |
| 5077 | | IrInstSrc *this_inst = ir_gen_this(ag, scope, node); |
| 5079 | IrInstSrc *this_inst = astgen_this(ag, scope, node); |
| 5078 | 5080 | return ir_lval_wrap(ag, scope, this_inst, lval, result_loc); |
| 5079 | 5081 | } |
| 5080 | 5082 | case BuiltinFnIdSetAlignStack: |
| 5081 | 5083 | { |
| 5082 | 5084 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5083 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 5085 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 5084 | 5086 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5085 | 5087 | return arg0_value; |
| 5086 | 5088 | |
| ... | ... | @@ -5095,12 +5097,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5095 | 5097 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(ag, options_type_inst, no_result_loc()); |
| 5096 | 5098 | |
| 5097 | 5099 | AstNode *target_node = node->data.fn_call_expr.params.at(0); |
| 5098 | | IrInstSrc *target_value = ir_gen_node(ag, target_node, scope); |
| 5100 | IrInstSrc *target_value = astgen_node(ag, target_node, scope); |
| 5099 | 5101 | if (target_value == ag->codegen->invalid_inst_src) |
| 5100 | 5102 | return target_value; |
| 5101 | 5103 | |
| 5102 | 5104 | AstNode *options_node = node->data.fn_call_expr.params.at(1); |
| 5103 | | IrInstSrc *options_value = ir_gen_node_extra(ag, options_node, |
| 5105 | IrInstSrc *options_value = astgen_node_extra(ag, options_node, |
| 5104 | 5106 | scope, LValNone, &result_loc_cast->base); |
| 5105 | 5107 | if (options_value == ag->codegen->invalid_inst_src) |
| 5106 | 5108 | return options_value; |
| ... | ... | @@ -5119,12 +5121,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5119 | 5121 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(ag, options_type_inst, no_result_loc()); |
| 5120 | 5122 | |
| 5121 | 5123 | AstNode *type_node = node->data.fn_call_expr.params.at(0); |
| 5122 | | IrInstSrc *type_value = ir_gen_node(ag, type_node, scope); |
| 5124 | IrInstSrc *type_value = astgen_node(ag, type_node, scope); |
| 5123 | 5125 | if (type_value == ag->codegen->invalid_inst_src) |
| 5124 | 5126 | return type_value; |
| 5125 | 5127 | |
| 5126 | 5128 | AstNode *options_node = node->data.fn_call_expr.params.at(1); |
| 5127 | | IrInstSrc *options_value = ir_gen_node_extra(ag, options_node, |
| 5129 | IrInstSrc *options_value = astgen_node_extra(ag, options_node, |
| 5128 | 5130 | scope, LValNone, &result_loc_cast->base); |
| 5129 | 5131 | if (options_value == ag->codegen->invalid_inst_src) |
| 5130 | 5132 | return options_value; |
| ... | ... | @@ -5144,27 +5146,27 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5144 | 5146 | case BuiltinFnIdAtomicRmw: |
| 5145 | 5147 | { |
| 5146 | 5148 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5147 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 5149 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 5148 | 5150 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5149 | 5151 | return arg0_value; |
| 5150 | 5152 | |
| 5151 | 5153 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5152 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 5154 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 5153 | 5155 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 5154 | 5156 | return arg1_value; |
| 5155 | 5157 | |
| 5156 | 5158 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 5157 | | IrInstSrc *arg2_value = ir_gen_node(ag, arg2_node, scope); |
| 5159 | IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope); |
| 5158 | 5160 | if (arg2_value == ag->codegen->invalid_inst_src) |
| 5159 | 5161 | return arg2_value; |
| 5160 | 5162 | |
| 5161 | 5163 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); |
| 5162 | | IrInstSrc *arg3_value = ir_gen_node(ag, arg3_node, scope); |
| 5164 | IrInstSrc *arg3_value = astgen_node(ag, arg3_node, scope); |
| 5163 | 5165 | if (arg3_value == ag->codegen->invalid_inst_src) |
| 5164 | 5166 | return arg3_value; |
| 5165 | 5167 | |
| 5166 | 5168 | AstNode *arg4_node = node->data.fn_call_expr.params.at(4); |
| 5167 | | IrInstSrc *arg4_value = ir_gen_node(ag, arg4_node, scope); |
| 5169 | IrInstSrc *arg4_value = astgen_node(ag, arg4_node, scope); |
| 5168 | 5170 | if (arg4_value == ag->codegen->invalid_inst_src) |
| 5169 | 5171 | return arg4_value; |
| 5170 | 5172 | |
| ... | ... | @@ -5175,17 +5177,17 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5175 | 5177 | case BuiltinFnIdAtomicLoad: |
| 5176 | 5178 | { |
| 5177 | 5179 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5178 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 5180 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 5179 | 5181 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5180 | 5182 | return arg0_value; |
| 5181 | 5183 | |
| 5182 | 5184 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5183 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 5185 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 5184 | 5186 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 5185 | 5187 | return arg1_value; |
| 5186 | 5188 | |
| 5187 | 5189 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 5188 | | IrInstSrc *arg2_value = ir_gen_node(ag, arg2_node, scope); |
| 5190 | IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope); |
| 5189 | 5191 | if (arg2_value == ag->codegen->invalid_inst_src) |
| 5190 | 5192 | return arg2_value; |
| 5191 | 5193 | |
| ... | ... | @@ -5195,22 +5197,22 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5195 | 5197 | case BuiltinFnIdAtomicStore: |
| 5196 | 5198 | { |
| 5197 | 5199 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5198 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 5200 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 5199 | 5201 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5200 | 5202 | return arg0_value; |
| 5201 | 5203 | |
| 5202 | 5204 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5203 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 5205 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 5204 | 5206 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 5205 | 5207 | return arg1_value; |
| 5206 | 5208 | |
| 5207 | 5209 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 5208 | | IrInstSrc *arg2_value = ir_gen_node(ag, arg2_node, scope); |
| 5210 | IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope); |
| 5209 | 5211 | if (arg2_value == ag->codegen->invalid_inst_src) |
| 5210 | 5212 | return arg2_value; |
| 5211 | 5213 | |
| 5212 | 5214 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); |
| 5213 | | IrInstSrc *arg3_value = ir_gen_node(ag, arg3_node, scope); |
| 5215 | IrInstSrc *arg3_value = astgen_node(ag, arg3_node, scope); |
| 5214 | 5216 | if (arg3_value == ag->codegen->invalid_inst_src) |
| 5215 | 5217 | return arg3_value; |
| 5216 | 5218 | |
| ... | ... | @@ -5221,12 +5223,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5221 | 5223 | case BuiltinFnIdIntToEnum: |
| 5222 | 5224 | { |
| 5223 | 5225 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5224 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 5226 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 5225 | 5227 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5226 | 5228 | return arg0_value; |
| 5227 | 5229 | |
| 5228 | 5230 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5229 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 5231 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 5230 | 5232 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 5231 | 5233 | return arg1_value; |
| 5232 | 5234 | |
| ... | ... | @@ -5236,7 +5238,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5236 | 5238 | case BuiltinFnIdEnumToInt: |
| 5237 | 5239 | { |
| 5238 | 5240 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5239 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 5241 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 5240 | 5242 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5241 | 5243 | return arg0_value; |
| 5242 | 5244 | |
| ... | ... | @@ -5250,12 +5252,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5250 | 5252 | case BuiltinFnIdBitReverse: |
| 5251 | 5253 | { |
| 5252 | 5254 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5253 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 5255 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 5254 | 5256 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5255 | 5257 | return arg0_value; |
| 5256 | 5258 | |
| 5257 | 5259 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5258 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 5260 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 5259 | 5261 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 5260 | 5262 | return arg1_value; |
| 5261 | 5263 | |
| ... | ... | @@ -5284,12 +5286,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5284 | 5286 | case BuiltinFnIdHasDecl: |
| 5285 | 5287 | { |
| 5286 | 5288 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5287 | | IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope); |
| 5289 | IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope); |
| 5288 | 5290 | if (arg0_value == ag->codegen->invalid_inst_src) |
| 5289 | 5291 | return arg0_value; |
| 5290 | 5292 | |
| 5291 | 5293 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5292 | | IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope); |
| 5294 | IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope); |
| 5293 | 5295 | if (arg1_value == ag->codegen->invalid_inst_src) |
| 5294 | 5296 | return arg1_value; |
| 5295 | 5297 | |
| ... | ... | @@ -5299,18 +5301,18 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode |
| 5299 | 5301 | case BuiltinFnIdUnionInit: |
| 5300 | 5302 | { |
| 5301 | 5303 | AstNode *union_type_node = node->data.fn_call_expr.params.at(0); |
| 5302 | | IrInstSrc *union_type_inst = ir_gen_node(ag, union_type_node, scope); |
| 5304 | IrInstSrc *union_type_inst = astgen_node(ag, union_type_node, scope); |
| 5303 | 5305 | if (union_type_inst == ag->codegen->invalid_inst_src) |
| 5304 | 5306 | return union_type_inst; |
| 5305 | 5307 | |
| 5306 | 5308 | AstNode *name_node = node->data.fn_call_expr.params.at(1); |
| 5307 | | IrInstSrc *name_inst = ir_gen_node(ag, name_node, scope); |
| 5309 | IrInstSrc *name_inst = astgen_node(ag, name_node, scope); |
| 5308 | 5310 | if (name_inst == ag->codegen->invalid_inst_src) |
| 5309 | 5311 | return name_inst; |
| 5310 | 5312 | |
| 5311 | 5313 | AstNode *init_node = node->data.fn_call_expr.params.at(2); |
| 5312 | 5314 | |
| 5313 | | return ir_gen_union_init_expr(ag, scope, node, union_type_inst, name_inst, init_node, |
| 5315 | return astgen_union_init_expr(ag, scope, node, union_type_inst, name_inst, init_node, |
| 5314 | 5316 | lval, result_loc); |
| 5315 | 5317 | } |
| 5316 | 5318 | case BuiltinFnIdSrc: |
| ... | ... | @@ -5334,13 +5336,13 @@ static ScopeNoSuspend *get_scope_nosuspend(Scope *scope) { |
| 5334 | 5336 | return nullptr; |
| 5335 | 5337 | } |
| 5336 | 5338 | |
| 5337 | | static IrInstSrc *ir_gen_fn_call(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 5339 | static IrInstSrc *astgen_fn_call(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 5338 | 5340 | ResultLoc *result_loc) |
| 5339 | 5341 | { |
| 5340 | 5342 | assert(node->type == NodeTypeFnCallExpr); |
| 5341 | 5343 | |
| 5342 | 5344 | if (node->data.fn_call_expr.modifier == CallModifierBuiltin) |
| 5343 | | return ir_gen_builtin_fn_call(ag, scope, node, lval, result_loc); |
| 5345 | return astgen_builtin_fn_call(ag, scope, node, lval, result_loc); |
| 5344 | 5346 | |
| 5345 | 5347 | bool is_nosuspend = get_scope_nosuspend(scope) != nullptr; |
| 5346 | 5348 | CallModifier modifier = node->data.fn_call_expr.modifier; |
| ... | ... | @@ -5349,16 +5351,16 @@ static IrInstSrc *ir_gen_fn_call(Stage1AstGen *ag, Scope *scope, AstNode *node, |
| 5349 | 5351 | } |
| 5350 | 5352 | |
| 5351 | 5353 | AstNode *fn_ref_node = node->data.fn_call_expr.fn_ref_expr; |
| 5352 | | return ir_gen_fn_call_with_args(ag, scope, node, fn_ref_node, modifier, |
| 5354 | return astgen_fn_call_with_args(ag, scope, node, fn_ref_node, modifier, |
| 5353 | 5355 | nullptr, node->data.fn_call_expr.params.items, node->data.fn_call_expr.params.length, lval, result_loc); |
| 5354 | 5356 | } |
| 5355 | 5357 | |
| 5356 | | static IrInstSrc *ir_gen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 5358 | static IrInstSrc *astgen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 5357 | 5359 | ResultLoc *result_loc) |
| 5358 | 5360 | { |
| 5359 | 5361 | assert(node->type == NodeTypeIfBoolExpr); |
| 5360 | 5362 | |
| 5361 | | IrInstSrc *condition = ir_gen_node(ag, node->data.if_bool_expr.condition, scope); |
| 5363 | IrInstSrc *condition = astgen_node(ag, node->data.if_bool_expr.condition, scope); |
| 5362 | 5364 | if (condition == ag->codegen->invalid_inst_src) |
| 5363 | 5365 | return ag->codegen->invalid_inst_src; |
| 5364 | 5366 | |
| ... | ... | @@ -5384,7 +5386,7 @@ static IrInstSrc *ir_gen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 5384 | 5386 | ir_set_cursor_at_end_and_append_block(ag, then_block); |
| 5385 | 5387 | |
| 5386 | 5388 | Scope *subexpr_scope = create_runtime_scope(ag->codegen, node, scope, is_comptime); |
| 5387 | | IrInstSrc *then_expr_result = ir_gen_node_extra(ag, then_node, subexpr_scope, lval, |
| 5389 | IrInstSrc *then_expr_result = astgen_node_extra(ag, then_node, subexpr_scope, lval, |
| 5388 | 5390 | &peer_parent->peers.at(0)->base); |
| 5389 | 5391 | if (then_expr_result == ag->codegen->invalid_inst_src) |
| 5390 | 5392 | return ag->codegen->invalid_inst_src; |
| ... | ... | @@ -5395,7 +5397,7 @@ static IrInstSrc *ir_gen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 5395 | 5397 | ir_set_cursor_at_end_and_append_block(ag, else_block); |
| 5396 | 5398 | IrInstSrc *else_expr_result; |
| 5397 | 5399 | if (else_node) { |
| 5398 | | else_expr_result = ir_gen_node_extra(ag, else_node, subexpr_scope, lval, &peer_parent->peers.at(1)->base); |
| 5400 | else_expr_result = astgen_node_extra(ag, else_node, subexpr_scope, lval, &peer_parent->peers.at(1)->base); |
| 5399 | 5401 | if (else_expr_result == ag->codegen->invalid_inst_src) |
| 5400 | 5402 | return ag->codegen->invalid_inst_src; |
| 5401 | 5403 | } else { |
| ... | ... | @@ -5418,19 +5420,19 @@ static IrInstSrc *ir_gen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 5418 | 5420 | return ir_expr_wrap(ag, scope, phi, result_loc); |
| 5419 | 5421 | } |
| 5420 | 5422 | |
| 5421 | | static IrInstSrc *ir_gen_prefix_op_id_lval(Stage1AstGen *ag, Scope *scope, AstNode *node, IrUnOp op_id, LVal lval) { |
| 5423 | static IrInstSrc *astgen_prefix_op_id_lval(Stage1AstGen *ag, Scope *scope, AstNode *node, IrUnOp op_id, LVal lval) { |
| 5422 | 5424 | assert(node->type == NodeTypePrefixOpExpr); |
| 5423 | 5425 | AstNode *expr_node = node->data.prefix_op_expr.primary_expr; |
| 5424 | 5426 | |
| 5425 | | IrInstSrc *value = ir_gen_node_extra(ag, expr_node, scope, lval, nullptr); |
| 5427 | IrInstSrc *value = astgen_node_extra(ag, expr_node, scope, lval, nullptr); |
| 5426 | 5428 | if (value == ag->codegen->invalid_inst_src) |
| 5427 | 5429 | return value; |
| 5428 | 5430 | |
| 5429 | 5431 | return ir_build_un_op(ag, scope, node, op_id, value); |
| 5430 | 5432 | } |
| 5431 | 5433 | |
| 5432 | | static IrInstSrc *ir_gen_prefix_op_id(Stage1AstGen *ag, Scope *scope, AstNode *node, IrUnOp op_id) { |
| 5433 | | return ir_gen_prefix_op_id_lval(ag, scope, node, op_id, LValNone); |
| 5434 | static IrInstSrc *astgen_prefix_op_id(Stage1AstGen *ag, Scope *scope, AstNode *node, IrUnOp op_id) { |
| 5435 | return astgen_prefix_op_id_lval(ag, scope, node, op_id, LValNone); |
| 5434 | 5436 | } |
| 5435 | 5437 | |
| 5436 | 5438 | static IrInstSrc *ir_expr_wrap(Stage1AstGen *ag, Scope *scope, IrInstSrc *inst, ResultLoc *result_loc) { |
| ... | ... | @@ -5499,7 +5501,7 @@ static Error token_number_literal_u32(Stage1AstGen *ag, AstNode *source_node, |
| 5499 | 5501 | |
| 5500 | 5502 | } |
| 5501 | 5503 | |
| 5502 | | static IrInstSrc *ir_gen_pointer_type(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 5504 | static IrInstSrc *astgen_pointer_type(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 5503 | 5505 | Error err; |
| 5504 | 5506 | assert(node->type == NodeTypePointerType); |
| 5505 | 5507 | |
| ... | ... | @@ -5516,7 +5518,7 @@ static IrInstSrc *ir_gen_pointer_type(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 5516 | 5518 | |
| 5517 | 5519 | IrInstSrc *sentinel; |
| 5518 | 5520 | if (sentinel_expr != nullptr) { |
| 5519 | | sentinel = ir_gen_node(ag, sentinel_expr, scope); |
| 5521 | sentinel = astgen_node(ag, sentinel_expr, scope); |
| 5520 | 5522 | if (sentinel == ag->codegen->invalid_inst_src) |
| 5521 | 5523 | return sentinel; |
| 5522 | 5524 | } else { |
| ... | ... | @@ -5525,14 +5527,14 @@ static IrInstSrc *ir_gen_pointer_type(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 5525 | 5527 | |
| 5526 | 5528 | IrInstSrc *align_value; |
| 5527 | 5529 | if (align_expr != nullptr) { |
| 5528 | | align_value = ir_gen_node(ag, align_expr, scope); |
| 5530 | align_value = astgen_node(ag, align_expr, scope); |
| 5529 | 5531 | if (align_value == ag->codegen->invalid_inst_src) |
| 5530 | 5532 | return align_value; |
| 5531 | 5533 | } else { |
| 5532 | 5534 | align_value = nullptr; |
| 5533 | 5535 | } |
| 5534 | 5536 | |
| 5535 | | IrInstSrc *child_type = ir_gen_node(ag, expr_node, scope); |
| 5537 | IrInstSrc *child_type = astgen_node(ag, expr_node, scope); |
| 5536 | 5538 | if (child_type == ag->codegen->invalid_inst_src) |
| 5537 | 5539 | return child_type; |
| 5538 | 5540 | |
| ... | ... | @@ -5564,10 +5566,10 @@ static IrInstSrc *ir_gen_pointer_type(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 5564 | 5566 | ptr_len, sentinel, align_value, bit_offset_start, host_int_bytes, is_allow_zero); |
| 5565 | 5567 | } |
| 5566 | 5568 | |
| 5567 | | static IrInstSrc *ir_gen_catch_unreachable(Stage1AstGen *ag, Scope *scope, AstNode *source_node, |
| 5569 | static IrInstSrc *astgen_catch_unreachable(Stage1AstGen *ag, Scope *scope, AstNode *source_node, |
| 5568 | 5570 | AstNode *expr_node, LVal lval, ResultLoc *result_loc) |
| 5569 | 5571 | { |
| 5570 | | IrInstSrc *err_union_ptr = ir_gen_node_extra(ag, expr_node, scope, LValPtr, nullptr); |
| 5572 | IrInstSrc *err_union_ptr = astgen_node_extra(ag, expr_node, scope, LValPtr, nullptr); |
| 5571 | 5573 | if (err_union_ptr == ag->codegen->invalid_inst_src) |
| 5572 | 5574 | return ag->codegen->invalid_inst_src; |
| 5573 | 5575 | |
| ... | ... | @@ -5582,18 +5584,18 @@ static IrInstSrc *ir_gen_catch_unreachable(Stage1AstGen *ag, Scope *scope, AstNo |
| 5582 | 5584 | return ir_expr_wrap(ag, scope, load_ptr, result_loc); |
| 5583 | 5585 | } |
| 5584 | 5586 | |
| 5585 | | static IrInstSrc *ir_gen_bool_not(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 5587 | static IrInstSrc *astgen_bool_not(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 5586 | 5588 | assert(node->type == NodeTypePrefixOpExpr); |
| 5587 | 5589 | AstNode *expr_node = node->data.prefix_op_expr.primary_expr; |
| 5588 | 5590 | |
| 5589 | | IrInstSrc *value = ir_gen_node(ag, expr_node, scope); |
| 5591 | IrInstSrc *value = astgen_node(ag, expr_node, scope); |
| 5590 | 5592 | if (value == ag->codegen->invalid_inst_src) |
| 5591 | 5593 | return ag->codegen->invalid_inst_src; |
| 5592 | 5594 | |
| 5593 | 5595 | return ir_build_bool_not(ag, scope, node, value); |
| 5594 | 5596 | } |
| 5595 | 5597 | |
| 5596 | | static IrInstSrc *ir_gen_prefix_op_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 5598 | static IrInstSrc *astgen_prefix_op_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 5597 | 5599 | ResultLoc *result_loc) |
| 5598 | 5600 | { |
| 5599 | 5601 | assert(node->type == NodeTypePrefixOpExpr); |
| ... | ... | @@ -5604,24 +5606,24 @@ static IrInstSrc *ir_gen_prefix_op_expr(Stage1AstGen *ag, Scope *scope, AstNode |
| 5604 | 5606 | case PrefixOpInvalid: |
| 5605 | 5607 | zig_unreachable(); |
| 5606 | 5608 | case PrefixOpBoolNot: |
| 5607 | | return ir_lval_wrap(ag, scope, ir_gen_bool_not(ag, scope, node), lval, result_loc); |
| 5609 | return ir_lval_wrap(ag, scope, astgen_bool_not(ag, scope, node), lval, result_loc); |
| 5608 | 5610 | case PrefixOpBinNot: |
| 5609 | | return ir_lval_wrap(ag, scope, ir_gen_prefix_op_id(ag, scope, node, IrUnOpBinNot), lval, result_loc); |
| 5611 | return ir_lval_wrap(ag, scope, astgen_prefix_op_id(ag, scope, node, IrUnOpBinNot), lval, result_loc); |
| 5610 | 5612 | case PrefixOpNegation: |
| 5611 | | return ir_lval_wrap(ag, scope, ir_gen_prefix_op_id(ag, scope, node, IrUnOpNegation), lval, result_loc); |
| 5613 | return ir_lval_wrap(ag, scope, astgen_prefix_op_id(ag, scope, node, IrUnOpNegation), lval, result_loc); |
| 5612 | 5614 | case PrefixOpNegationWrap: |
| 5613 | | return ir_lval_wrap(ag, scope, ir_gen_prefix_op_id(ag, scope, node, IrUnOpNegationWrap), lval, result_loc); |
| 5615 | return ir_lval_wrap(ag, scope, astgen_prefix_op_id(ag, scope, node, IrUnOpNegationWrap), lval, result_loc); |
| 5614 | 5616 | case PrefixOpOptional: |
| 5615 | | return ir_lval_wrap(ag, scope, ir_gen_prefix_op_id(ag, scope, node, IrUnOpOptional), lval, result_loc); |
| 5617 | return ir_lval_wrap(ag, scope, astgen_prefix_op_id(ag, scope, node, IrUnOpOptional), lval, result_loc); |
| 5616 | 5618 | case PrefixOpAddrOf: { |
| 5617 | 5619 | AstNode *expr_node = node->data.prefix_op_expr.primary_expr; |
| 5618 | | return ir_lval_wrap(ag, scope, ir_gen_node_extra(ag, expr_node, scope, LValPtr, nullptr), lval, result_loc); |
| 5620 | return ir_lval_wrap(ag, scope, astgen_node_extra(ag, expr_node, scope, LValPtr, nullptr), lval, result_loc); |
| 5619 | 5621 | } |
| 5620 | 5622 | } |
| 5621 | 5623 | zig_unreachable(); |
| 5622 | 5624 | } |
| 5623 | 5625 | |
| 5624 | | static IrInstSrc *ir_gen_union_init_expr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, |
| 5626 | static IrInstSrc *astgen_union_init_expr(Stage1AstGen *ag, Scope *scope, AstNode *source_node, |
| 5625 | 5627 | IrInstSrc *union_type, IrInstSrc *field_name, AstNode *expr_node, |
| 5626 | 5628 | LVal lval, ResultLoc *parent_result_loc) |
| 5627 | 5629 | { |
| ... | ... | @@ -5635,7 +5637,7 @@ static IrInstSrc *ir_gen_union_init_expr(Stage1AstGen *ag, Scope *scope, AstNode |
| 5635 | 5637 | ir_ref_instruction(field_ptr, ag->current_basic_block); |
| 5636 | 5638 | ir_build_reset_result(ag, scope, expr_node, &result_loc_inst->base); |
| 5637 | 5639 | |
| 5638 | | IrInstSrc *expr_value = ir_gen_node_extra(ag, expr_node, scope, LValNone, |
| 5640 | IrInstSrc *expr_value = astgen_node_extra(ag, expr_node, scope, LValNone, |
| 5639 | 5641 | &result_loc_inst->base); |
| 5640 | 5642 | if (expr_value == ag->codegen->invalid_inst_src) |
| 5641 | 5643 | return expr_value; |
| ... | ... | @@ -5646,7 +5648,7 @@ static IrInstSrc *ir_gen_union_init_expr(Stage1AstGen *ag, Scope *scope, AstNode |
| 5646 | 5648 | return ir_lval_wrap(ag, scope, init_union, lval, parent_result_loc); |
| 5647 | 5649 | } |
| 5648 | 5650 | |
| 5649 | | static IrInstSrc *ir_gen_container_init_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 5651 | static IrInstSrc *astgen_container_init_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 5650 | 5652 | ResultLoc *parent_result_loc) |
| 5651 | 5653 | { |
| 5652 | 5654 | assert(node->type == NodeTypeContainerInitExpr); |
| ... | ... | @@ -5667,14 +5669,14 @@ static IrInstSrc *ir_gen_container_init_expr(Stage1AstGen *ag, Scope *scope, Ast |
| 5667 | 5669 | } |
| 5668 | 5670 | IrInstSrc *sentinel; |
| 5669 | 5671 | if (container_init_expr->type->data.inferred_array_type.sentinel != nullptr) { |
| 5670 | | sentinel = ir_gen_node(ag, container_init_expr->type->data.inferred_array_type.sentinel, scope); |
| 5672 | sentinel = astgen_node(ag, container_init_expr->type->data.inferred_array_type.sentinel, scope); |
| 5671 | 5673 | if (sentinel == ag->codegen->invalid_inst_src) |
| 5672 | 5674 | return sentinel; |
| 5673 | 5675 | } else { |
| 5674 | 5676 | sentinel = nullptr; |
| 5675 | 5677 | } |
| 5676 | 5678 | |
| 5677 | | IrInstSrc *elem_type = ir_gen_node(ag, |
| 5679 | IrInstSrc *elem_type = astgen_node(ag, |
| 5678 | 5680 | container_init_expr->type->data.inferred_array_type.child_type, scope); |
| 5679 | 5681 | if (elem_type == ag->codegen->invalid_inst_src) |
| 5680 | 5682 | return elem_type; |
| ... | ... | @@ -5682,7 +5684,7 @@ static IrInstSrc *ir_gen_container_init_expr(Stage1AstGen *ag, Scope *scope, Ast |
| 5682 | 5684 | IrInstSrc *item_count_inst = ir_build_const_usize(ag, scope, node, item_count); |
| 5683 | 5685 | container_type = ir_build_array_type(ag, scope, node, item_count_inst, sentinel, elem_type); |
| 5684 | 5686 | } else { |
| 5685 | | container_type = ir_gen_node(ag, container_init_expr->type, scope); |
| 5687 | container_type = astgen_node(ag, container_init_expr->type, scope); |
| 5686 | 5688 | if (container_type == ag->codegen->invalid_inst_src) |
| 5687 | 5689 | return container_type; |
| 5688 | 5690 | } |
| ... | ... | @@ -5721,7 +5723,7 @@ static IrInstSrc *ir_gen_container_init_expr(Stage1AstGen *ag, Scope *scope, Ast |
| 5721 | 5723 | ir_ref_instruction(field_ptr, ag->current_basic_block); |
| 5722 | 5724 | ir_build_reset_result(ag, scope, expr_node, &result_loc_inst->base); |
| 5723 | 5725 | |
| 5724 | | IrInstSrc *expr_value = ir_gen_node_extra(ag, expr_node, scope, LValNone, |
| 5726 | IrInstSrc *expr_value = astgen_node_extra(ag, expr_node, scope, LValNone, |
| 5725 | 5727 | &result_loc_inst->base); |
| 5726 | 5728 | if (expr_value == ag->codegen->invalid_inst_src) |
| 5727 | 5729 | return expr_value; |
| ... | ... | @@ -5758,7 +5760,7 @@ static IrInstSrc *ir_gen_container_init_expr(Stage1AstGen *ag, Scope *scope, Ast |
| 5758 | 5760 | ir_ref_instruction(elem_ptr, ag->current_basic_block); |
| 5759 | 5761 | ir_build_reset_result(ag, scope, expr_node, &result_loc_inst->base); |
| 5760 | 5762 | |
| 5761 | | IrInstSrc *expr_value = ir_gen_node_extra(ag, expr_node, scope, LValNone, |
| 5763 | IrInstSrc *expr_value = astgen_node_extra(ag, expr_node, scope, LValNone, |
| 5762 | 5764 | &result_loc_inst->base); |
| 5763 | 5765 | if (expr_value == ag->codegen->invalid_inst_src) |
| 5764 | 5766 | return expr_value; |
| ... | ... | @@ -5812,7 +5814,7 @@ static void build_decl_var_and_init(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 5812 | 5814 | ir_build_var_decl_src(ag, scope, source_node, var, nullptr, alloca); |
| 5813 | 5815 | } |
| 5814 | 5816 | |
| 5815 | | static IrInstSrc *ir_gen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 5817 | static IrInstSrc *astgen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 5816 | 5818 | assert(node->type == NodeTypeVariableDeclaration); |
| 5817 | 5819 | |
| 5818 | 5820 | AstNodeVariableDeclaration *variable_declaration = &node->data.variable_declaration; |
| ... | ... | @@ -5827,7 +5829,7 @@ static IrInstSrc *ir_gen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 5827 | 5829 | |
| 5828 | 5830 | IrInstSrc *type_instruction; |
| 5829 | 5831 | if (variable_declaration->type != nullptr) { |
| 5830 | | type_instruction = ir_gen_node(ag, variable_declaration->type, comptime_scope); |
| 5832 | type_instruction = astgen_node(ag, variable_declaration->type, comptime_scope); |
| 5831 | 5833 | if (type_instruction == ag->codegen->invalid_inst_src) |
| 5832 | 5834 | return type_instruction; |
| 5833 | 5835 | } else { |
| ... | ... | @@ -5853,7 +5855,7 @@ static IrInstSrc *ir_gen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 5853 | 5855 | |
| 5854 | 5856 | IrInstSrc *align_value = nullptr; |
| 5855 | 5857 | if (variable_declaration->align_expr != nullptr) { |
| 5856 | | align_value = ir_gen_node(ag, variable_declaration->align_expr, comptime_scope); |
| 5858 | align_value = astgen_node(ag, variable_declaration->align_expr, comptime_scope); |
| 5857 | 5859 | if (align_value == ag->codegen->invalid_inst_src) |
| 5858 | 5860 | return align_value; |
| 5859 | 5861 | } |
| ... | ... | @@ -5888,7 +5890,7 @@ static IrInstSrc *ir_gen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 5888 | 5890 | // so that the struct or enum from the init expression inherits the name. |
| 5889 | 5891 | Buf *old_exec_name = ag->exec->name; |
| 5890 | 5892 | ag->exec->name = variable_declaration->symbol; |
| 5891 | | IrInstSrc *init_value = ir_gen_node_extra(ag, variable_declaration->expr, init_scope, |
| 5893 | IrInstSrc *init_value = astgen_node_extra(ag, variable_declaration->expr, init_scope, |
| 5892 | 5894 | LValNone, init_result_loc); |
| 5893 | 5895 | ag->exec->name = old_exec_name; |
| 5894 | 5896 | |
| ... | ... | @@ -5904,7 +5906,7 @@ static IrInstSrc *ir_gen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 5904 | 5906 | return ir_build_var_decl_src(ag, scope, node, var, align_value, alloca); |
| 5905 | 5907 | } |
| 5906 | 5908 | |
| 5907 | | static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 5909 | static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 5908 | 5910 | ResultLoc *result_loc) |
| 5909 | 5911 | { |
| 5910 | 5912 | assert(node->type == NodeTypeWhileExpr); |
| ... | ... | @@ -5942,7 +5944,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 5942 | 5944 | payload_scope = subexpr_scope; |
| 5943 | 5945 | } |
| 5944 | 5946 | ScopeExpr *spill_scope = create_expr_scope(ag->codegen, node, payload_scope); |
| 5945 | | IrInstSrc *err_val_ptr = ir_gen_node_extra(ag, node->data.while_expr.condition, subexpr_scope, |
| 5947 | IrInstSrc *err_val_ptr = astgen_node_extra(ag, node->data.while_expr.condition, subexpr_scope, |
| 5946 | 5948 | LValPtr, nullptr); |
| 5947 | 5949 | if (err_val_ptr == ag->codegen->invalid_inst_src) |
| 5948 | 5950 | return err_val_ptr; |
| ... | ... | @@ -5990,8 +5992,8 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 5990 | 5992 | |
| 5991 | 5993 | // Note the body block of the loop is not the place that lval and result_loc are used - |
| 5992 | 5994 | // it's actually in break statements, handled similarly to return statements. |
| 5993 | | // That is why we set those values in loop_scope above and not in this ir_gen_node call. |
| 5994 | | IrInstSrc *body_result = ir_gen_node(ag, node->data.while_expr.body, &loop_scope->base); |
| 5995 | // That is why we set those values in loop_scope above and not in this astgen_node call. |
| 5996 | IrInstSrc *body_result = astgen_node(ag, node->data.while_expr.body, &loop_scope->base); |
| 5995 | 5997 | if (body_result == ag->codegen->invalid_inst_src) |
| 5996 | 5998 | return body_result; |
| 5997 | 5999 | |
| ... | ... | @@ -6006,7 +6008,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6006 | 6008 | |
| 6007 | 6009 | if (continue_expr_node) { |
| 6008 | 6010 | ir_set_cursor_at_end_and_append_block(ag, continue_block); |
| 6009 | | IrInstSrc *expr_result = ir_gen_node(ag, continue_expr_node, payload_scope); |
| 6011 | IrInstSrc *expr_result = astgen_node(ag, continue_expr_node, payload_scope); |
| 6010 | 6012 | if (expr_result == ag->codegen->invalid_inst_src) |
| 6011 | 6013 | return expr_result; |
| 6012 | 6014 | if (!instr_is_unreachable(expr_result)) { |
| ... | ... | @@ -6032,7 +6034,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6032 | 6034 | } |
| 6033 | 6035 | ResultLocPeer *peer_result = create_peer_result(peer_parent); |
| 6034 | 6036 | peer_parent->peers.append(peer_result); |
| 6035 | | IrInstSrc *else_result = ir_gen_node_extra(ag, else_node, err_scope, lval, &peer_result->base); |
| 6037 | IrInstSrc *else_result = astgen_node_extra(ag, else_node, err_scope, lval, &peer_result->base); |
| 6036 | 6038 | if (else_result == ag->codegen->invalid_inst_src) |
| 6037 | 6039 | return else_result; |
| 6038 | 6040 | if (!instr_is_unreachable(else_result)) |
| ... | ... | @@ -6063,7 +6065,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6063 | 6065 | true, false, false, is_comptime); |
| 6064 | 6066 | Scope *child_scope = payload_var->child_scope; |
| 6065 | 6067 | ScopeExpr *spill_scope = create_expr_scope(ag->codegen, node, child_scope); |
| 6066 | | IrInstSrc *maybe_val_ptr = ir_gen_node_extra(ag, node->data.while_expr.condition, subexpr_scope, |
| 6068 | IrInstSrc *maybe_val_ptr = astgen_node_extra(ag, node->data.while_expr.condition, subexpr_scope, |
| 6067 | 6069 | LValPtr, nullptr); |
| 6068 | 6070 | if (maybe_val_ptr == ag->codegen->invalid_inst_src) |
| 6069 | 6071 | return maybe_val_ptr; |
| ... | ... | @@ -6108,8 +6110,8 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6108 | 6110 | |
| 6109 | 6111 | // Note the body block of the loop is not the place that lval and result_loc are used - |
| 6110 | 6112 | // it's actually in break statements, handled similarly to return statements. |
| 6111 | | // That is why we set those values in loop_scope above and not in this ir_gen_node call. |
| 6112 | | IrInstSrc *body_result = ir_gen_node(ag, node->data.while_expr.body, &loop_scope->base); |
| 6113 | // That is why we set those values in loop_scope above and not in this astgen_node call. |
| 6114 | IrInstSrc *body_result = astgen_node(ag, node->data.while_expr.body, &loop_scope->base); |
| 6113 | 6115 | if (body_result == ag->codegen->invalid_inst_src) |
| 6114 | 6116 | return body_result; |
| 6115 | 6117 | |
| ... | ... | @@ -6124,7 +6126,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6124 | 6126 | |
| 6125 | 6127 | if (continue_expr_node) { |
| 6126 | 6128 | ir_set_cursor_at_end_and_append_block(ag, continue_block); |
| 6127 | | IrInstSrc *expr_result = ir_gen_node(ag, continue_expr_node, child_scope); |
| 6129 | IrInstSrc *expr_result = astgen_node(ag, continue_expr_node, child_scope); |
| 6128 | 6130 | if (expr_result == ag->codegen->invalid_inst_src) |
| 6129 | 6131 | return expr_result; |
| 6130 | 6132 | if (!instr_is_unreachable(expr_result)) { |
| ... | ... | @@ -6142,7 +6144,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6142 | 6144 | } |
| 6143 | 6145 | ResultLocPeer *peer_result = create_peer_result(peer_parent); |
| 6144 | 6146 | peer_parent->peers.append(peer_result); |
| 6145 | | else_result = ir_gen_node_extra(ag, else_node, scope, lval, &peer_result->base); |
| 6147 | else_result = astgen_node_extra(ag, else_node, scope, lval, &peer_result->base); |
| 6146 | 6148 | if (else_result == ag->codegen->invalid_inst_src) |
| 6147 | 6149 | return else_result; |
| 6148 | 6150 | if (!instr_is_unreachable(else_result)) |
| ... | ... | @@ -6166,7 +6168,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6166 | 6168 | return ir_expr_wrap(ag, scope, phi, result_loc); |
| 6167 | 6169 | } else { |
| 6168 | 6170 | ir_set_cursor_at_end_and_append_block(ag, cond_block); |
| 6169 | | IrInstSrc *cond_val = ir_gen_node(ag, node->data.while_expr.condition, scope); |
| 6171 | IrInstSrc *cond_val = astgen_node(ag, node->data.while_expr.condition, scope); |
| 6170 | 6172 | if (cond_val == ag->codegen->invalid_inst_src) |
| 6171 | 6173 | return cond_val; |
| 6172 | 6174 | Stage1ZirBasicBlock *after_cond_block = ag->current_basic_block; |
| ... | ... | @@ -6204,8 +6206,8 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6204 | 6206 | |
| 6205 | 6207 | // Note the body block of the loop is not the place that lval and result_loc are used - |
| 6206 | 6208 | // it's actually in break statements, handled similarly to return statements. |
| 6207 | | // That is why we set those values in loop_scope above and not in this ir_gen_node call. |
| 6208 | | IrInstSrc *body_result = ir_gen_node(ag, node->data.while_expr.body, &loop_scope->base); |
| 6209 | // That is why we set those values in loop_scope above and not in this astgen_node call. |
| 6210 | IrInstSrc *body_result = astgen_node(ag, node->data.while_expr.body, &loop_scope->base); |
| 6209 | 6211 | if (body_result == ag->codegen->invalid_inst_src) |
| 6210 | 6212 | return body_result; |
| 6211 | 6213 | |
| ... | ... | @@ -6220,7 +6222,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6220 | 6222 | |
| 6221 | 6223 | if (continue_expr_node) { |
| 6222 | 6224 | ir_set_cursor_at_end_and_append_block(ag, continue_block); |
| 6223 | | IrInstSrc *expr_result = ir_gen_node(ag, continue_expr_node, subexpr_scope); |
| 6225 | IrInstSrc *expr_result = astgen_node(ag, continue_expr_node, subexpr_scope); |
| 6224 | 6226 | if (expr_result == ag->codegen->invalid_inst_src) |
| 6225 | 6227 | return expr_result; |
| 6226 | 6228 | if (!instr_is_unreachable(expr_result)) { |
| ... | ... | @@ -6239,7 +6241,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6239 | 6241 | ResultLocPeer *peer_result = create_peer_result(peer_parent); |
| 6240 | 6242 | peer_parent->peers.append(peer_result); |
| 6241 | 6243 | |
| 6242 | | else_result = ir_gen_node_extra(ag, else_node, subexpr_scope, lval, &peer_result->base); |
| 6244 | else_result = astgen_node_extra(ag, else_node, subexpr_scope, lval, &peer_result->base); |
| 6243 | 6245 | if (else_result == ag->codegen->invalid_inst_src) |
| 6244 | 6246 | return else_result; |
| 6245 | 6247 | if (!instr_is_unreachable(else_result)) |
| ... | ... | @@ -6264,7 +6266,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6264 | 6266 | } |
| 6265 | 6267 | } |
| 6266 | 6268 | |
| 6267 | | static IrInstSrc *ir_gen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval, |
| 6269 | static IrInstSrc *astgen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval, |
| 6268 | 6270 | ResultLoc *result_loc) |
| 6269 | 6271 | { |
| 6270 | 6272 | assert(node->type == NodeTypeForExpr); |
| ... | ... | @@ -6283,7 +6285,7 @@ static IrInstSrc *ir_gen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 6283 | 6285 | |
| 6284 | 6286 | ScopeExpr *spill_scope = create_expr_scope(ag->codegen, node, parent_scope); |
| 6285 | 6287 | |
| 6286 | | IrInstSrc *array_val_ptr = ir_gen_node_extra(ag, array_node, &spill_scope->base, LValPtr, nullptr); |
| 6288 | IrInstSrc *array_val_ptr = astgen_node_extra(ag, array_node, &spill_scope->base, LValPtr, nullptr); |
| 6287 | 6289 | if (array_val_ptr == ag->codegen->invalid_inst_src) |
| 6288 | 6290 | return array_val_ptr; |
| 6289 | 6291 | |
| ... | ... | @@ -6362,8 +6364,8 @@ static IrInstSrc *ir_gen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 6362 | 6364 | |
| 6363 | 6365 | // Note the body block of the loop is not the place that lval and result_loc are used - |
| 6364 | 6366 | // it's actually in break statements, handled similarly to return statements. |
| 6365 | | // That is why we set those values in loop_scope above and not in this ir_gen_node call. |
| 6366 | | IrInstSrc *body_result = ir_gen_node(ag, body_node, &loop_scope->base); |
| 6367 | // That is why we set those values in loop_scope above and not in this astgen_node call. |
| 6368 | IrInstSrc *body_result = astgen_node(ag, body_node, &loop_scope->base); |
| 6367 | 6369 | if (body_result == ag->codegen->invalid_inst_src) |
| 6368 | 6370 | return ag->codegen->invalid_inst_src; |
| 6369 | 6371 | |
| ... | ... | @@ -6390,7 +6392,7 @@ static IrInstSrc *ir_gen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 6390 | 6392 | } |
| 6391 | 6393 | ResultLocPeer *peer_result = create_peer_result(peer_parent); |
| 6392 | 6394 | peer_parent->peers.append(peer_result); |
| 6393 | | else_result = ir_gen_node_extra(ag, else_node, parent_scope, LValNone, &peer_result->base); |
| 6395 | else_result = astgen_node_extra(ag, else_node, parent_scope, LValNone, &peer_result->base); |
| 6394 | 6396 | if (else_result == ag->codegen->invalid_inst_src) |
| 6395 | 6397 | return else_result; |
| 6396 | 6398 | if (!instr_is_unreachable(else_result)) |
| ... | ... | @@ -6415,19 +6417,25 @@ static IrInstSrc *ir_gen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 6415 | 6417 | return ir_lval_wrap(ag, parent_scope, phi, lval, result_loc); |
| 6416 | 6418 | } |
| 6417 | 6419 | |
| 6418 | | static IrInstSrc *ir_gen_bool_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 6420 | static IrInstSrc *astgen_bool_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 6419 | 6421 | assert(node->type == NodeTypeBoolLiteral); |
| 6420 | 6422 | return ir_build_const_bool(ag, scope, node, node->data.bool_literal.value); |
| 6421 | 6423 | } |
| 6422 | 6424 | |
| 6423 | | static IrInstSrc *ir_gen_enum_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 6425 | static IrInstSrc *astgen_enum_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 6424 | 6426 | assert(node->type == NodeTypeEnumLiteral); |
| 6425 | | RootStruct *root_struct = node->owner->data.structure.root_struct; |
| 6426 | | Buf *name = token_identifier_buf(root_struct, node->main_token + 1); |
| 6427 | | return ir_build_const_enum_literal(ag, scope, node, name); |
| 6427 | // Currently, stage1 runs astgen for every comptime function call, |
| 6428 | // resulting the allocation here wasting memory. As a workaround until |
| 6429 | // the code is adjusted to make astgen run only once per source node, |
| 6430 | // we memoize the result into the AST here. |
| 6431 | if (node->data.enum_literal.name == nullptr) { |
| 6432 | RootStruct *root_struct = node->owner->data.structure.root_struct; |
| 6433 | node->data.enum_literal.name = token_identifier_buf(root_struct, node->main_token + 1); |
| 6434 | } |
| 6435 | return ir_build_const_enum_literal(ag, scope, node, node->data.enum_literal.name); |
| 6428 | 6436 | } |
| 6429 | 6437 | |
| 6430 | | static IrInstSrc *ir_gen_string_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 6438 | static IrInstSrc *astgen_string_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 6431 | 6439 | Error err; |
| 6432 | 6440 | assert(node->type == NodeTypeStringLiteral); |
| 6433 | 6441 | |
| ... | ... | @@ -6465,10 +6473,11 @@ static IrInstSrc *ir_gen_string_literal(Stage1AstGen *ag, Scope *scope, AstNode |
| 6465 | 6473 | } else { |
| 6466 | 6474 | zig_unreachable(); |
| 6467 | 6475 | } |
| 6476 | |
| 6468 | 6477 | return ir_build_const_str_lit(ag, scope, node, str); |
| 6469 | 6478 | } |
| 6470 | 6479 | |
| 6471 | | static IrInstSrc *ir_gen_array_type(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 6480 | static IrInstSrc *astgen_array_type(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 6472 | 6481 | assert(node->type == NodeTypeArrayType); |
| 6473 | 6482 | |
| 6474 | 6483 | AstNode *size_node = node->data.array_type.size; |
| ... | ... | @@ -6483,7 +6492,7 @@ static IrInstSrc *ir_gen_array_type(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6483 | 6492 | |
| 6484 | 6493 | IrInstSrc *sentinel; |
| 6485 | 6494 | if (sentinel_expr != nullptr) { |
| 6486 | | sentinel = ir_gen_node(ag, sentinel_expr, comptime_scope); |
| 6495 | sentinel = astgen_node(ag, sentinel_expr, comptime_scope); |
| 6487 | 6496 | if (sentinel == ag->codegen->invalid_inst_src) |
| 6488 | 6497 | return sentinel; |
| 6489 | 6498 | } else { |
| ... | ... | @@ -6508,11 +6517,11 @@ static IrInstSrc *ir_gen_array_type(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6508 | 6517 | return ag->codegen->invalid_inst_src; |
| 6509 | 6518 | } |
| 6510 | 6519 | |
| 6511 | | IrInstSrc *size_value = ir_gen_node(ag, size_node, comptime_scope); |
| 6520 | IrInstSrc *size_value = astgen_node(ag, size_node, comptime_scope); |
| 6512 | 6521 | if (size_value == ag->codegen->invalid_inst_src) |
| 6513 | 6522 | return size_value; |
| 6514 | 6523 | |
| 6515 | | IrInstSrc *child_type = ir_gen_node(ag, child_type_node, comptime_scope); |
| 6524 | IrInstSrc *child_type = astgen_node(ag, child_type_node, comptime_scope); |
| 6516 | 6525 | if (child_type == ag->codegen->invalid_inst_src) |
| 6517 | 6526 | return child_type; |
| 6518 | 6527 | |
| ... | ... | @@ -6520,14 +6529,14 @@ static IrInstSrc *ir_gen_array_type(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6520 | 6529 | } else { |
| 6521 | 6530 | IrInstSrc *align_value; |
| 6522 | 6531 | if (align_expr != nullptr) { |
| 6523 | | align_value = ir_gen_node(ag, align_expr, comptime_scope); |
| 6532 | align_value = astgen_node(ag, align_expr, comptime_scope); |
| 6524 | 6533 | if (align_value == ag->codegen->invalid_inst_src) |
| 6525 | 6534 | return align_value; |
| 6526 | 6535 | } else { |
| 6527 | 6536 | align_value = nullptr; |
| 6528 | 6537 | } |
| 6529 | 6538 | |
| 6530 | | IrInstSrc *child_type = ir_gen_node(ag, child_type_node, comptime_scope); |
| 6539 | IrInstSrc *child_type = astgen_node(ag, child_type_node, comptime_scope); |
| 6531 | 6540 | if (child_type == ag->codegen->invalid_inst_src) |
| 6532 | 6541 | return child_type; |
| 6533 | 6542 | |
| ... | ... | @@ -6536,14 +6545,14 @@ static IrInstSrc *ir_gen_array_type(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6536 | 6545 | } |
| 6537 | 6546 | } |
| 6538 | 6547 | |
| 6539 | | static IrInstSrc *ir_gen_anyframe_type(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 6548 | static IrInstSrc *astgen_anyframe_type(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 6540 | 6549 | assert(node->type == NodeTypeAnyFrameType); |
| 6541 | 6550 | |
| 6542 | 6551 | AstNode *payload_type_node = node->data.anyframe_type.payload_type; |
| 6543 | 6552 | IrInstSrc *payload_type_value = nullptr; |
| 6544 | 6553 | |
| 6545 | 6554 | if (payload_type_node != nullptr) { |
| 6546 | | payload_type_value = ir_gen_node(ag, payload_type_node, scope); |
| 6555 | payload_type_value = astgen_node(ag, payload_type_node, scope); |
| 6547 | 6556 | if (payload_type_value == ag->codegen->invalid_inst_src) |
| 6548 | 6557 | return payload_type_value; |
| 6549 | 6558 | |
| ... | ... | @@ -6552,16 +6561,16 @@ static IrInstSrc *ir_gen_anyframe_type(Stage1AstGen *ag, Scope *scope, AstNode * |
| 6552 | 6561 | return ir_build_anyframe_type(ag, scope, node, payload_type_value); |
| 6553 | 6562 | } |
| 6554 | 6563 | |
| 6555 | | static IrInstSrc *ir_gen_undefined_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 6564 | static IrInstSrc *astgen_undefined_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 6556 | 6565 | assert(node->type == NodeTypeUndefinedLiteral); |
| 6557 | 6566 | return ir_build_const_undefined(ag, scope, node); |
| 6558 | 6567 | } |
| 6559 | 6568 | |
| 6560 | | static IrInstSrc *ir_gen_asm_expr(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 6569 | static IrInstSrc *astgen_asm_expr(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 6561 | 6570 | assert(node->type == NodeTypeAsmExpr); |
| 6562 | 6571 | AstNodeAsmExpr *asm_expr = &node->data.asm_expr; |
| 6563 | 6572 | |
| 6564 | | IrInstSrc *asm_template = ir_gen_node(ag, asm_expr->asm_template, scope); |
| 6573 | IrInstSrc *asm_template = astgen_node(ag, asm_expr->asm_template, scope); |
| 6565 | 6574 | if (asm_template == ag->codegen->invalid_inst_src) |
| 6566 | 6575 | return ag->codegen->invalid_inst_src; |
| 6567 | 6576 | |
| ... | ... | @@ -6601,7 +6610,7 @@ static IrInstSrc *ir_gen_asm_expr(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 6601 | 6610 | if (asm_output->return_type) { |
| 6602 | 6611 | return_count += 1; |
| 6603 | 6612 | |
| 6604 | | IrInstSrc *return_type = ir_gen_node(ag, asm_output->return_type, scope); |
| 6613 | IrInstSrc *return_type = astgen_node(ag, asm_output->return_type, scope); |
| 6605 | 6614 | if (return_type == ag->codegen->invalid_inst_src) |
| 6606 | 6615 | return ag->codegen->invalid_inst_src; |
| 6607 | 6616 | if (return_count > 1) { |
| ... | ... | @@ -6612,7 +6621,7 @@ static IrInstSrc *ir_gen_asm_expr(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 6612 | 6621 | output_types[i] = return_type; |
| 6613 | 6622 | } else { |
| 6614 | 6623 | Buf *variable_name = asm_output->variable_name; |
| 6615 | | // TODO there is some duplication here with ir_gen_symbol. I need to do a full audit of how |
| 6624 | // TODO there is some duplication here with astgen_identifier. I need to do a full audit of how |
| 6616 | 6625 | // inline assembly works. https://github.com/ziglang/zig/issues/215 |
| 6617 | 6626 | ZigVar *var = find_variable(ag->codegen, scope, variable_name, nullptr); |
| 6618 | 6627 | if (var) { |
| ... | ... | @@ -6635,7 +6644,7 @@ static IrInstSrc *ir_gen_asm_expr(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 6635 | 6644 | } |
| 6636 | 6645 | for (size_t i = 0; i < asm_expr->input_list.length; i += 1) { |
| 6637 | 6646 | AsmInput *asm_input = asm_expr->input_list.at(i); |
| 6638 | | IrInstSrc *input_value = ir_gen_node(ag, asm_input->expr, scope); |
| 6647 | IrInstSrc *input_value = astgen_node(ag, asm_input->expr, scope); |
| 6639 | 6648 | if (input_value == ag->codegen->invalid_inst_src) |
| 6640 | 6649 | return ag->codegen->invalid_inst_src; |
| 6641 | 6650 | |
| ... | ... | @@ -6646,7 +6655,7 @@ static IrInstSrc *ir_gen_asm_expr(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 6646 | 6655 | output_vars, return_count, is_volatile, false); |
| 6647 | 6656 | } |
| 6648 | 6657 | |
| 6649 | | static IrInstSrc *ir_gen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 6658 | static IrInstSrc *astgen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 6650 | 6659 | ResultLoc *result_loc) |
| 6651 | 6660 | { |
| 6652 | 6661 | assert(node->type == NodeTypeIfOptional); |
| ... | ... | @@ -6660,7 +6669,7 @@ static IrInstSrc *ir_gen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod |
| 6660 | 6669 | ScopeExpr *spill_scope = create_expr_scope(ag->codegen, expr_node, scope); |
| 6661 | 6670 | spill_scope->spill_harder = true; |
| 6662 | 6671 | |
| 6663 | | IrInstSrc *maybe_val_ptr = ir_gen_node_extra(ag, expr_node, &spill_scope->base, LValPtr, nullptr); |
| 6672 | IrInstSrc *maybe_val_ptr = astgen_node_extra(ag, expr_node, &spill_scope->base, LValPtr, nullptr); |
| 6664 | 6673 | if (maybe_val_ptr == ag->codegen->invalid_inst_src) |
| 6665 | 6674 | return maybe_val_ptr; |
| 6666 | 6675 | |
| ... | ... | @@ -6701,7 +6710,7 @@ static IrInstSrc *ir_gen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod |
| 6701 | 6710 | } else { |
| 6702 | 6711 | var_scope = subexpr_scope; |
| 6703 | 6712 | } |
| 6704 | | IrInstSrc *then_expr_result = ir_gen_node_extra(ag, then_node, var_scope, lval, |
| 6713 | IrInstSrc *then_expr_result = astgen_node_extra(ag, then_node, var_scope, lval, |
| 6705 | 6714 | &peer_parent->peers.at(0)->base); |
| 6706 | 6715 | if (then_expr_result == ag->codegen->invalid_inst_src) |
| 6707 | 6716 | return then_expr_result; |
| ... | ... | @@ -6712,7 +6721,7 @@ static IrInstSrc *ir_gen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod |
| 6712 | 6721 | ir_set_cursor_at_end_and_append_block(ag, else_block); |
| 6713 | 6722 | IrInstSrc *else_expr_result; |
| 6714 | 6723 | if (else_node) { |
| 6715 | | else_expr_result = ir_gen_node_extra(ag, else_node, subexpr_scope, lval, &peer_parent->peers.at(1)->base); |
| 6724 | else_expr_result = astgen_node_extra(ag, else_node, subexpr_scope, lval, &peer_parent->peers.at(1)->base); |
| 6716 | 6725 | if (else_expr_result == ag->codegen->invalid_inst_src) |
| 6717 | 6726 | return else_expr_result; |
| 6718 | 6727 | } else { |
| ... | ... | @@ -6735,7 +6744,7 @@ static IrInstSrc *ir_gen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod |
| 6735 | 6744 | return ir_expr_wrap(ag, scope, phi, result_loc); |
| 6736 | 6745 | } |
| 6737 | 6746 | |
| 6738 | | static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 6747 | static IrInstSrc *astgen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 6739 | 6748 | ResultLoc *result_loc) |
| 6740 | 6749 | { |
| 6741 | 6750 | assert(node->type == NodeTypeIfErrorExpr); |
| ... | ... | @@ -6748,7 +6757,7 @@ static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6748 | 6757 | Buf *var_symbol = node->data.if_err_expr.var_symbol; |
| 6749 | 6758 | Buf *err_symbol = node->data.if_err_expr.err_symbol; |
| 6750 | 6759 | |
| 6751 | | IrInstSrc *err_val_ptr = ir_gen_node_extra(ag, target_node, scope, LValPtr, nullptr); |
| 6760 | IrInstSrc *err_val_ptr = astgen_node_extra(ag, target_node, scope, LValPtr, nullptr); |
| 6752 | 6761 | if (err_val_ptr == ag->codegen->invalid_inst_src) |
| 6753 | 6762 | return err_val_ptr; |
| 6754 | 6763 | |
| ... | ... | @@ -6784,7 +6793,7 @@ static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6784 | 6793 | } else { |
| 6785 | 6794 | var_scope = subexpr_scope; |
| 6786 | 6795 | } |
| 6787 | | IrInstSrc *then_expr_result = ir_gen_node_extra(ag, then_node, var_scope, lval, |
| 6796 | IrInstSrc *then_expr_result = astgen_node_extra(ag, then_node, var_scope, lval, |
| 6788 | 6797 | &peer_parent->peers.at(0)->base); |
| 6789 | 6798 | if (then_expr_result == ag->codegen->invalid_inst_src) |
| 6790 | 6799 | return then_expr_result; |
| ... | ... | @@ -6810,7 +6819,7 @@ static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6810 | 6819 | } else { |
| 6811 | 6820 | err_var_scope = subexpr_scope; |
| 6812 | 6821 | } |
| 6813 | | else_expr_result = ir_gen_node_extra(ag, else_node, err_var_scope, lval, &peer_parent->peers.at(1)->base); |
| 6822 | else_expr_result = astgen_node_extra(ag, else_node, err_var_scope, lval, &peer_parent->peers.at(1)->base); |
| 6814 | 6823 | if (else_expr_result == ag->codegen->invalid_inst_src) |
| 6815 | 6824 | return else_expr_result; |
| 6816 | 6825 | } else { |
| ... | ... | @@ -6833,7 +6842,7 @@ static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6833 | 6842 | return ir_expr_wrap(ag, scope, phi, result_loc); |
| 6834 | 6843 | } |
| 6835 | 6844 | |
| 6836 | | static bool ir_gen_switch_prong_expr(Stage1AstGen *ag, Scope *scope, AstNode *switch_node, AstNode *prong_node, |
| 6845 | static bool astgen_switch_prong_expr(Stage1AstGen *ag, Scope *scope, AstNode *switch_node, AstNode *prong_node, |
| 6837 | 6846 | Stage1ZirBasicBlock *end_block, IrInstSrc *is_comptime, IrInstSrc *var_is_comptime, |
| 6838 | 6847 | IrInstSrc *target_value_ptr, IrInstSrc **prong_values, size_t prong_values_len, |
| 6839 | 6848 | ZigList<Stage1ZirBasicBlock *> *incoming_blocks, ZigList<IrInstSrc *> *incoming_values, |
| ... | ... | @@ -6877,7 +6886,7 @@ static bool ir_gen_switch_prong_expr(Stage1AstGen *ag, Scope *scope, AstNode *sw |
| 6877 | 6886 | child_scope = scope; |
| 6878 | 6887 | } |
| 6879 | 6888 | |
| 6880 | | IrInstSrc *expr_result = ir_gen_node_extra(ag, expr_node, child_scope, lval, result_loc); |
| 6889 | IrInstSrc *expr_result = astgen_node_extra(ag, expr_node, child_scope, lval, result_loc); |
| 6881 | 6890 | if (expr_result == ag->codegen->invalid_inst_src) |
| 6882 | 6891 | return false; |
| 6883 | 6892 | if (!instr_is_unreachable(expr_result)) |
| ... | ... | @@ -6887,13 +6896,13 @@ static bool ir_gen_switch_prong_expr(Stage1AstGen *ag, Scope *scope, AstNode *sw |
| 6887 | 6896 | return true; |
| 6888 | 6897 | } |
| 6889 | 6898 | |
| 6890 | | static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 6899 | static IrInstSrc *astgen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 6891 | 6900 | ResultLoc *result_loc) |
| 6892 | 6901 | { |
| 6893 | 6902 | assert(node->type == NodeTypeSwitchExpr); |
| 6894 | 6903 | |
| 6895 | 6904 | AstNode *target_node = node->data.switch_expr.expr; |
| 6896 | | IrInstSrc *target_value_ptr = ir_gen_node_extra(ag, target_node, scope, LValPtr, nullptr); |
| 6905 | IrInstSrc *target_value_ptr = astgen_node_extra(ag, target_node, scope, LValPtr, nullptr); |
| 6897 | 6906 | if (target_value_ptr == ag->codegen->invalid_inst_src) |
| 6898 | 6907 | return target_value_ptr; |
| 6899 | 6908 | IrInstSrc *target_value = ir_build_switch_target(ag, scope, node, target_value_ptr); |
| ... | ... | @@ -6949,11 +6958,11 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6949 | 6958 | AstNode *start_node = item_node->data.switch_range.start; |
| 6950 | 6959 | AstNode *end_node = item_node->data.switch_range.end; |
| 6951 | 6960 | |
| 6952 | | IrInstSrc *start_value = ir_gen_node(ag, start_node, comptime_scope); |
| 6961 | IrInstSrc *start_value = astgen_node(ag, start_node, comptime_scope); |
| 6953 | 6962 | if (start_value == ag->codegen->invalid_inst_src) |
| 6954 | 6963 | return ag->codegen->invalid_inst_src; |
| 6955 | 6964 | |
| 6956 | | IrInstSrc *end_value = ir_gen_node(ag, end_node, comptime_scope); |
| 6965 | IrInstSrc *end_value = astgen_node(ag, end_node, comptime_scope); |
| 6957 | 6966 | if (end_value == ag->codegen->invalid_inst_src) |
| 6958 | 6967 | return ag->codegen->invalid_inst_src; |
| 6959 | 6968 | |
| ... | ... | @@ -6973,7 +6982,7 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6973 | 6982 | ok_bit = both_ok; |
| 6974 | 6983 | } |
| 6975 | 6984 | } else { |
| 6976 | | IrInstSrc *item_value = ir_gen_node(ag, item_node, comptime_scope); |
| 6985 | IrInstSrc *item_value = astgen_node(ag, item_node, comptime_scope); |
| 6977 | 6986 | if (item_value == ag->codegen->invalid_inst_src) |
| 6978 | 6987 | return ag->codegen->invalid_inst_src; |
| 6979 | 6988 | |
| ... | ... | @@ -7007,7 +7016,7 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 7007 | 7016 | } |
| 7008 | 7017 | peer_parent->peers.append(this_peer_result_loc); |
| 7009 | 7018 | ir_set_cursor_at_end_and_append_block(ag, range_block_yes); |
| 7010 | | if (!ir_gen_switch_prong_expr(ag, subexpr_scope, node, prong_node, end_block, |
| 7019 | if (!astgen_switch_prong_expr(ag, subexpr_scope, node, prong_node, end_block, |
| 7011 | 7020 | is_comptime, var_is_comptime, target_value_ptr, nullptr, 0, |
| 7012 | 7021 | &incoming_blocks, &incoming_values, nullptr, LValNone, &this_peer_result_loc->base)) |
| 7013 | 7022 | { |
| ... | ... | @@ -7058,7 +7067,7 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 7058 | 7067 | } |
| 7059 | 7068 | peer_parent->peers.append(this_peer_result_loc); |
| 7060 | 7069 | ir_set_cursor_at_end_and_append_block(ag, else_block); |
| 7061 | | if (!ir_gen_switch_prong_expr(ag, subexpr_scope, node, prong_node, end_block, |
| 7070 | if (!astgen_switch_prong_expr(ag, subexpr_scope, node, prong_node, end_block, |
| 7062 | 7071 | is_comptime, var_is_comptime, target_value_ptr, nullptr, 0, &incoming_blocks, &incoming_values, |
| 7063 | 7072 | &switch_else_var, LValNone, &this_peer_result_loc->base)) |
| 7064 | 7073 | { |
| ... | ... | @@ -7088,7 +7097,7 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 7088 | 7097 | AstNode *item_node = prong_node->data.switch_prong.items.at(item_i); |
| 7089 | 7098 | assert(item_node->type != NodeTypeSwitchRange); |
| 7090 | 7099 | |
| 7091 | | IrInstSrc *item_value = ir_gen_node(ag, item_node, comptime_scope); |
| 7100 | IrInstSrc *item_value = astgen_node(ag, item_node, comptime_scope); |
| 7092 | 7101 | if (item_value == ag->codegen->invalid_inst_src) |
| 7093 | 7102 | return ag->codegen->invalid_inst_src; |
| 7094 | 7103 | |
| ... | ... | @@ -7109,7 +7118,7 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 7109 | 7118 | } |
| 7110 | 7119 | peer_parent->peers.append(this_peer_result_loc); |
| 7111 | 7120 | ir_set_cursor_at_end_and_append_block(ag, prong_block); |
| 7112 | | if (!ir_gen_switch_prong_expr(ag, subexpr_scope, node, prong_node, end_block, |
| 7121 | if (!astgen_switch_prong_expr(ag, subexpr_scope, node, prong_node, end_block, |
| 7113 | 7122 | is_comptime, var_is_comptime, target_value_ptr, items, prong_item_count, |
| 7114 | 7123 | &incoming_blocks, &incoming_values, nullptr, LValNone, &this_peer_result_loc->base)) |
| 7115 | 7124 | { |
| ... | ... | @@ -7165,23 +7174,23 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 7165 | 7174 | return ir_lval_wrap(ag, scope, result_instruction, lval, result_loc); |
| 7166 | 7175 | } |
| 7167 | 7176 | |
| 7168 | | static IrInstSrc *ir_gen_comptime(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval) { |
| 7177 | static IrInstSrc *astgen_comptime(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval) { |
| 7169 | 7178 | assert(node->type == NodeTypeCompTime); |
| 7170 | 7179 | |
| 7171 | 7180 | Scope *child_scope = create_comptime_scope(ag->codegen, node, parent_scope); |
| 7172 | 7181 | // purposefully pass null for result_loc and let EndExpr handle it |
| 7173 | | return ir_gen_node_extra(ag, node->data.comptime_expr.expr, child_scope, lval, nullptr); |
| 7182 | return astgen_node_extra(ag, node->data.comptime_expr.expr, child_scope, lval, nullptr); |
| 7174 | 7183 | } |
| 7175 | 7184 | |
| 7176 | | static IrInstSrc *ir_gen_nosuspend(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval) { |
| 7185 | static IrInstSrc *astgen_nosuspend(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval) { |
| 7177 | 7186 | assert(node->type == NodeTypeNoSuspend); |
| 7178 | 7187 | |
| 7179 | 7188 | Scope *child_scope = create_nosuspend_scope(ag->codegen, node, parent_scope); |
| 7180 | 7189 | // purposefully pass null for result_loc and let EndExpr handle it |
| 7181 | | return ir_gen_node_extra(ag, node->data.nosuspend_expr.expr, child_scope, lval, nullptr); |
| 7190 | return astgen_node_extra(ag, node->data.nosuspend_expr.expr, child_scope, lval, nullptr); |
| 7182 | 7191 | } |
| 7183 | 7192 | |
| 7184 | | static IrInstSrc *ir_gen_return_from_block(Stage1AstGen *ag, Scope *break_scope, AstNode *node, ScopeBlock *block_scope) { |
| 7193 | static IrInstSrc *astgen_return_from_block(Stage1AstGen *ag, Scope *break_scope, AstNode *node, ScopeBlock *block_scope) { |
| 7185 | 7194 | IrInstSrc *is_comptime; |
| 7186 | 7195 | if (ir_should_inline(ag->exec, break_scope)) { |
| 7187 | 7196 | is_comptime = ir_build_const_bool(ag, break_scope, node, true); |
| ... | ... | @@ -7194,7 +7203,7 @@ static IrInstSrc *ir_gen_return_from_block(Stage1AstGen *ag, Scope *break_scope, |
| 7194 | 7203 | ResultLocPeer *peer_result = create_peer_result(block_scope->peer_parent); |
| 7195 | 7204 | block_scope->peer_parent->peers.append(peer_result); |
| 7196 | 7205 | |
| 7197 | | result_value = ir_gen_node_extra(ag, node->data.break_expr.expr, break_scope, block_scope->lval, |
| 7206 | result_value = astgen_node_extra(ag, node->data.break_expr.expr, break_scope, block_scope->lval, |
| 7198 | 7207 | &peer_result->base); |
| 7199 | 7208 | if (result_value == ag->codegen->invalid_inst_src) |
| 7200 | 7209 | return ag->codegen->invalid_inst_src; |
| ... | ... | @@ -7203,7 +7212,7 @@ static IrInstSrc *ir_gen_return_from_block(Stage1AstGen *ag, Scope *break_scope, |
| 7203 | 7212 | } |
| 7204 | 7213 | |
| 7205 | 7214 | Stage1ZirBasicBlock *dest_block = block_scope->end_block; |
| 7206 | | if (!ir_gen_defers_for_block(ag, break_scope, dest_block->scope, nullptr, nullptr)) |
| 7215 | if (!astgen_defers_for_block(ag, break_scope, dest_block->scope, nullptr, nullptr)) |
| 7207 | 7216 | return ag->codegen->invalid_inst_src; |
| 7208 | 7217 | |
| 7209 | 7218 | block_scope->incoming_blocks->append(ag->current_basic_block); |
| ... | ... | @@ -7211,7 +7220,7 @@ static IrInstSrc *ir_gen_return_from_block(Stage1AstGen *ag, Scope *break_scope, |
| 7211 | 7220 | return ir_build_br(ag, break_scope, node, dest_block, is_comptime); |
| 7212 | 7221 | } |
| 7213 | 7222 | |
| 7214 | | static IrInstSrc *ir_gen_break(Stage1AstGen *ag, Scope *break_scope, AstNode *node) { |
| 7223 | static IrInstSrc *astgen_break(Stage1AstGen *ag, Scope *break_scope, AstNode *node) { |
| 7215 | 7224 | assert(node->type == NodeTypeBreak); |
| 7216 | 7225 | |
| 7217 | 7226 | // Search up the scope. We'll find one of these things first: |
| ... | ... | @@ -7250,7 +7259,7 @@ static IrInstSrc *ir_gen_break(Stage1AstGen *ag, Scope *break_scope, AstNode *no |
| 7250 | 7259 | { |
| 7251 | 7260 | assert(this_block_scope->end_block != nullptr); |
| 7252 | 7261 | this_block_scope->name_used = true; |
| 7253 | | return ir_gen_return_from_block(ag, break_scope, node, this_block_scope); |
| 7262 | return astgen_return_from_block(ag, break_scope, node, this_block_scope); |
| 7254 | 7263 | } |
| 7255 | 7264 | } else if (search_scope->id == ScopeIdSuspend) { |
| 7256 | 7265 | add_node_error(ag->codegen, node, buf_sprintf("cannot break out of suspend block")); |
| ... | ... | @@ -7271,7 +7280,7 @@ static IrInstSrc *ir_gen_break(Stage1AstGen *ag, Scope *break_scope, AstNode *no |
| 7271 | 7280 | ResultLocPeer *peer_result = create_peer_result(loop_scope->peer_parent); |
| 7272 | 7281 | loop_scope->peer_parent->peers.append(peer_result); |
| 7273 | 7282 | |
| 7274 | | result_value = ir_gen_node_extra(ag, node->data.break_expr.expr, break_scope, |
| 7283 | result_value = astgen_node_extra(ag, node->data.break_expr.expr, break_scope, |
| 7275 | 7284 | loop_scope->lval, &peer_result->base); |
| 7276 | 7285 | if (result_value == ag->codegen->invalid_inst_src) |
| 7277 | 7286 | return ag->codegen->invalid_inst_src; |
| ... | ... | @@ -7280,7 +7289,7 @@ static IrInstSrc *ir_gen_break(Stage1AstGen *ag, Scope *break_scope, AstNode *no |
| 7280 | 7289 | } |
| 7281 | 7290 | |
| 7282 | 7291 | Stage1ZirBasicBlock *dest_block = loop_scope->break_block; |
| 7283 | | if (!ir_gen_defers_for_block(ag, break_scope, dest_block->scope, nullptr, nullptr)) |
| 7292 | if (!astgen_defers_for_block(ag, break_scope, dest_block->scope, nullptr, nullptr)) |
| 7284 | 7293 | return ag->codegen->invalid_inst_src; |
| 7285 | 7294 | |
| 7286 | 7295 | loop_scope->incoming_blocks->append(ag->current_basic_block); |
| ... | ... | @@ -7288,7 +7297,7 @@ static IrInstSrc *ir_gen_break(Stage1AstGen *ag, Scope *break_scope, AstNode *no |
| 7288 | 7297 | return ir_build_br(ag, break_scope, node, dest_block, is_comptime); |
| 7289 | 7298 | } |
| 7290 | 7299 | |
| 7291 | | static IrInstSrc *ir_gen_continue(Stage1AstGen *ag, Scope *continue_scope, AstNode *node) { |
| 7300 | static IrInstSrc *astgen_continue(Stage1AstGen *ag, Scope *continue_scope, AstNode *node) { |
| 7292 | 7301 | assert(node->type == NodeTypeContinue); |
| 7293 | 7302 | |
| 7294 | 7303 | // Search up the scope. We'll find one of these things first: |
| ... | ... | @@ -7342,17 +7351,17 @@ static IrInstSrc *ir_gen_continue(Stage1AstGen *ag, Scope *continue_scope, AstNo |
| 7342 | 7351 | runtime_scopes.deinit(); |
| 7343 | 7352 | |
| 7344 | 7353 | Stage1ZirBasicBlock *dest_block = loop_scope->continue_block; |
| 7345 | | if (!ir_gen_defers_for_block(ag, continue_scope, dest_block->scope, nullptr, nullptr)) |
| 7354 | if (!astgen_defers_for_block(ag, continue_scope, dest_block->scope, nullptr, nullptr)) |
| 7346 | 7355 | return ag->codegen->invalid_inst_src; |
| 7347 | 7356 | return ir_mark_gen(ir_build_br(ag, continue_scope, node, dest_block, is_comptime)); |
| 7348 | 7357 | } |
| 7349 | 7358 | |
| 7350 | | static IrInstSrc *ir_gen_error_type(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 7359 | static IrInstSrc *astgen_error_type(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 7351 | 7360 | assert(node->type == NodeTypeErrorType); |
| 7352 | 7361 | return ir_build_const_type(ag, scope, node, ag->codegen->builtin_types.entry_global_error_set); |
| 7353 | 7362 | } |
| 7354 | 7363 | |
| 7355 | | static IrInstSrc *ir_gen_defer(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { |
| 7364 | static IrInstSrc *astgen_defer(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { |
| 7356 | 7365 | assert(node->type == NodeTypeDefer); |
| 7357 | 7366 | |
| 7358 | 7367 | ScopeDefer *defer_child_scope = create_defer_scope(ag->codegen, node, parent_scope); |
| ... | ... | @@ -7364,7 +7373,7 @@ static IrInstSrc *ir_gen_defer(Stage1AstGen *ag, Scope *parent_scope, AstNode *n |
| 7364 | 7373 | return ir_build_const_void(ag, parent_scope, node); |
| 7365 | 7374 | } |
| 7366 | 7375 | |
| 7367 | | static IrInstSrc *ir_gen_slice(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { |
| 7376 | static IrInstSrc *astgen_slice(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { |
| 7368 | 7377 | assert(node->type == NodeTypeSliceExpr); |
| 7369 | 7378 | |
| 7370 | 7379 | AstNodeSliceExpr *slice_expr = &node->data.slice_expr; |
| ... | ... | @@ -7373,17 +7382,17 @@ static IrInstSrc *ir_gen_slice(Stage1AstGen *ag, Scope *scope, AstNode *node, LV |
| 7373 | 7382 | AstNode *end_node = slice_expr->end; |
| 7374 | 7383 | AstNode *sentinel_node = slice_expr->sentinel; |
| 7375 | 7384 | |
| 7376 | | IrInstSrc *ptr_value = ir_gen_node_extra(ag, array_node, scope, LValPtr, nullptr); |
| 7385 | IrInstSrc *ptr_value = astgen_node_extra(ag, array_node, scope, LValPtr, nullptr); |
| 7377 | 7386 | if (ptr_value == ag->codegen->invalid_inst_src) |
| 7378 | 7387 | return ag->codegen->invalid_inst_src; |
| 7379 | 7388 | |
| 7380 | | IrInstSrc *start_value = ir_gen_node(ag, start_node, scope); |
| 7389 | IrInstSrc *start_value = astgen_node(ag, start_node, scope); |
| 7381 | 7390 | if (start_value == ag->codegen->invalid_inst_src) |
| 7382 | 7391 | return ag->codegen->invalid_inst_src; |
| 7383 | 7392 | |
| 7384 | 7393 | IrInstSrc *end_value; |
| 7385 | 7394 | if (end_node) { |
| 7386 | | end_value = ir_gen_node(ag, end_node, scope); |
| 7395 | end_value = astgen_node(ag, end_node, scope); |
| 7387 | 7396 | if (end_value == ag->codegen->invalid_inst_src) |
| 7388 | 7397 | return ag->codegen->invalid_inst_src; |
| 7389 | 7398 | } else { |
| ... | ... | @@ -7392,7 +7401,7 @@ static IrInstSrc *ir_gen_slice(Stage1AstGen *ag, Scope *scope, AstNode *node, LV |
| 7392 | 7401 | |
| 7393 | 7402 | IrInstSrc *sentinel_value; |
| 7394 | 7403 | if (sentinel_node) { |
| 7395 | | sentinel_value = ir_gen_node(ag, sentinel_node, scope); |
| 7404 | sentinel_value = astgen_node(ag, sentinel_node, scope); |
| 7396 | 7405 | if (sentinel_value == ag->codegen->invalid_inst_src) |
| 7397 | 7406 | return ag->codegen->invalid_inst_src; |
| 7398 | 7407 | } else { |
| ... | ... | @@ -7404,7 +7413,7 @@ static IrInstSrc *ir_gen_slice(Stage1AstGen *ag, Scope *scope, AstNode *node, LV |
| 7404 | 7413 | return ir_lval_wrap(ag, scope, slice, lval, result_loc); |
| 7405 | 7414 | } |
| 7406 | 7415 | |
| 7407 | | static IrInstSrc *ir_gen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval, |
| 7416 | static IrInstSrc *astgen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval, |
| 7408 | 7417 | ResultLoc *result_loc) |
| 7409 | 7418 | { |
| 7410 | 7419 | assert(node->type == NodeTypeCatchExpr); |
| ... | ... | @@ -7420,14 +7429,14 @@ static IrInstSrc *ir_gen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *n |
| 7420 | 7429 | add_node_error(ag->codegen, var_node, buf_sprintf("unused variable: '%s'", buf_ptr(var_name))); |
| 7421 | 7430 | return ag->codegen->invalid_inst_src; |
| 7422 | 7431 | } |
| 7423 | | return ir_gen_catch_unreachable(ag, parent_scope, node, op1_node, lval, result_loc); |
| 7432 | return astgen_catch_unreachable(ag, parent_scope, node, op1_node, lval, result_loc); |
| 7424 | 7433 | } |
| 7425 | 7434 | |
| 7426 | 7435 | |
| 7427 | 7436 | ScopeExpr *spill_scope = create_expr_scope(ag->codegen, op1_node, parent_scope); |
| 7428 | 7437 | spill_scope->spill_harder = true; |
| 7429 | 7438 | |
| 7430 | | IrInstSrc *err_union_ptr = ir_gen_node_extra(ag, op1_node, &spill_scope->base, LValPtr, nullptr); |
| 7439 | IrInstSrc *err_union_ptr = astgen_node_extra(ag, op1_node, &spill_scope->base, LValPtr, nullptr); |
| 7431 | 7440 | if (err_union_ptr == ag->codegen->invalid_inst_src) |
| 7432 | 7441 | return ag->codegen->invalid_inst_src; |
| 7433 | 7442 | |
| ... | ... | @@ -7465,7 +7474,7 @@ static IrInstSrc *ir_gen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *n |
| 7465 | 7474 | } else { |
| 7466 | 7475 | err_scope = subexpr_scope; |
| 7467 | 7476 | } |
| 7468 | | IrInstSrc *err_result = ir_gen_node_extra(ag, op2_node, err_scope, LValNone, &peer_parent->peers.at(0)->base); |
| 7477 | IrInstSrc *err_result = astgen_node_extra(ag, op2_node, err_scope, LValNone, &peer_parent->peers.at(0)->base); |
| 7469 | 7478 | if (err_result == ag->codegen->invalid_inst_src) |
| 7470 | 7479 | return ag->codegen->invalid_inst_src; |
| 7471 | 7480 | Stage1ZirBasicBlock *after_err_block = ag->current_basic_block; |
| ... | ... | @@ -7535,7 +7544,7 @@ Buf *get_anon_type_name(CodeGen *codegen, Stage1Zir *exec, const char *kind_name |
| 7535 | 7544 | } |
| 7536 | 7545 | } |
| 7537 | 7546 | |
| 7538 | | static IrInstSrc *ir_gen_container_decl(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { |
| 7547 | static IrInstSrc *astgen_container_decl(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { |
| 7539 | 7548 | assert(node->type == NodeTypeContainerDecl); |
| 7540 | 7549 | |
| 7541 | 7550 | ContainerKind kind = node->data.container_decl.kind; |
| ... | ... | @@ -7564,7 +7573,7 @@ static IrInstSrc *ir_gen_container_decl(Stage1AstGen *ag, Scope *parent_scope, A |
| 7564 | 7573 | return ir_build_const_type(ag, parent_scope, node, container_type); |
| 7565 | 7574 | } |
| 7566 | 7575 | |
| 7567 | | static IrInstSrc *ir_gen_err_set_decl(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { |
| 7576 | static IrInstSrc *astgen_err_set_decl(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { |
| 7568 | 7577 | assert(node->type == NodeTypeErrorSetDecl); |
| 7569 | 7578 | |
| 7570 | 7579 | uint32_t err_count = node->data.err_set_decl.decls.length; |
| ... | ... | @@ -7615,7 +7624,7 @@ static IrInstSrc *ir_gen_err_set_decl(Stage1AstGen *ag, Scope *parent_scope, Ast |
| 7615 | 7624 | return ir_build_const_type(ag, parent_scope, node, err_set_type); |
| 7616 | 7625 | } |
| 7617 | 7626 | |
| 7618 | | static IrInstSrc *ir_gen_fn_proto(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { |
| 7627 | static IrInstSrc *astgen_fn_proto(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { |
| 7619 | 7628 | assert(node->type == NodeTypeFnProto); |
| 7620 | 7629 | |
| 7621 | 7630 | size_t param_count = node->data.fn_proto.params.length; |
| ... | ... | @@ -7630,7 +7639,7 @@ static IrInstSrc *ir_gen_fn_proto(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 7630 | 7639 | } |
| 7631 | 7640 | if (param_node->data.param_decl.anytype_token == 0) { |
| 7632 | 7641 | AstNode *type_node = param_node->data.param_decl.type; |
| 7633 | | IrInstSrc *type_value = ir_gen_node(ag, type_node, parent_scope); |
| 7642 | IrInstSrc *type_value = astgen_node(ag, type_node, parent_scope); |
| 7634 | 7643 | if (type_value == ag->codegen->invalid_inst_src) |
| 7635 | 7644 | return ag->codegen->invalid_inst_src; |
| 7636 | 7645 | param_types[i] = type_value; |
| ... | ... | @@ -7641,14 +7650,14 @@ static IrInstSrc *ir_gen_fn_proto(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 7641 | 7650 | |
| 7642 | 7651 | IrInstSrc *align_value = nullptr; |
| 7643 | 7652 | if (node->data.fn_proto.align_expr != nullptr) { |
| 7644 | | align_value = ir_gen_node(ag, node->data.fn_proto.align_expr, parent_scope); |
| 7653 | align_value = astgen_node(ag, node->data.fn_proto.align_expr, parent_scope); |
| 7645 | 7654 | if (align_value == ag->codegen->invalid_inst_src) |
| 7646 | 7655 | return ag->codegen->invalid_inst_src; |
| 7647 | 7656 | } |
| 7648 | 7657 | |
| 7649 | 7658 | IrInstSrc *callconv_value = nullptr; |
| 7650 | 7659 | if (node->data.fn_proto.callconv_expr != nullptr) { |
| 7651 | | callconv_value = ir_gen_node(ag, node->data.fn_proto.callconv_expr, parent_scope); |
| 7660 | callconv_value = astgen_node(ag, node->data.fn_proto.callconv_expr, parent_scope); |
| 7652 | 7661 | if (callconv_value == ag->codegen->invalid_inst_src) |
| 7653 | 7662 | return ag->codegen->invalid_inst_src; |
| 7654 | 7663 | } |
| ... | ... | @@ -7657,7 +7666,7 @@ static IrInstSrc *ir_gen_fn_proto(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 7657 | 7666 | if (node->data.fn_proto.return_type == nullptr) { |
| 7658 | 7667 | return_type = ir_build_const_type(ag, parent_scope, node, ag->codegen->builtin_types.entry_void); |
| 7659 | 7668 | } else { |
| 7660 | | return_type = ir_gen_node(ag, node->data.fn_proto.return_type, parent_scope); |
| 7669 | return_type = astgen_node(ag, node->data.fn_proto.return_type, parent_scope); |
| 7661 | 7670 | if (return_type == ag->codegen->invalid_inst_src) |
| 7662 | 7671 | return ag->codegen->invalid_inst_src; |
| 7663 | 7672 | } |
| ... | ... | @@ -7665,17 +7674,17 @@ static IrInstSrc *ir_gen_fn_proto(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 7665 | 7674 | return ir_build_fn_proto(ag, parent_scope, node, param_types, align_value, callconv_value, return_type, is_var_args); |
| 7666 | 7675 | } |
| 7667 | 7676 | |
| 7668 | | static IrInstSrc *ir_gen_resume(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 7677 | static IrInstSrc *astgen_resume(Stage1AstGen *ag, Scope *scope, AstNode *node) { |
| 7669 | 7678 | assert(node->type == NodeTypeResume); |
| 7670 | 7679 | |
| 7671 | | IrInstSrc *target_inst = ir_gen_node_extra(ag, node->data.resume_expr.expr, scope, LValPtr, nullptr); |
| 7680 | IrInstSrc *target_inst = astgen_node_extra(ag, node->data.resume_expr.expr, scope, LValPtr, nullptr); |
| 7672 | 7681 | if (target_inst == ag->codegen->invalid_inst_src) |
| 7673 | 7682 | return ag->codegen->invalid_inst_src; |
| 7674 | 7683 | |
| 7675 | 7684 | return ir_build_resume_src(ag, scope, node, target_inst); |
| 7676 | 7685 | } |
| 7677 | 7686 | |
| 7678 | | static IrInstSrc *ir_gen_await_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 7687 | static IrInstSrc *astgen_await_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, |
| 7679 | 7688 | ResultLoc *result_loc) |
| 7680 | 7689 | { |
| 7681 | 7690 | assert(node->type == NodeTypeAwaitExpr); |
| ... | ... | @@ -7690,7 +7699,7 @@ static IrInstSrc *ir_gen_await_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 7690 | 7699 | if (entry != nullptr) { |
| 7691 | 7700 | BuiltinFnEntry *builtin_fn = entry->value; |
| 7692 | 7701 | if (builtin_fn->id == BuiltinFnIdAsyncCall) { |
| 7693 | | return ir_gen_async_call(ag, scope, node, expr_node, lval, result_loc); |
| 7702 | return astgen_async_call(ag, scope, node, expr_node, lval, result_loc); |
| 7694 | 7703 | } |
| 7695 | 7704 | } |
| 7696 | 7705 | } |
| ... | ... | @@ -7709,7 +7718,7 @@ static IrInstSrc *ir_gen_await_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 7709 | 7718 | return ag->codegen->invalid_inst_src; |
| 7710 | 7719 | } |
| 7711 | 7720 | |
| 7712 | | IrInstSrc *target_inst = ir_gen_node_extra(ag, expr_node, scope, LValPtr, nullptr); |
| 7721 | IrInstSrc *target_inst = astgen_node_extra(ag, expr_node, scope, LValPtr, nullptr); |
| 7713 | 7722 | if (target_inst == ag->codegen->invalid_inst_src) |
| 7714 | 7723 | return ag->codegen->invalid_inst_src; |
| 7715 | 7724 | |
| ... | ... | @@ -7717,7 +7726,7 @@ static IrInstSrc *ir_gen_await_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 7717 | 7726 | return ir_lval_wrap(ag, scope, await_inst, lval, result_loc); |
| 7718 | 7727 | } |
| 7719 | 7728 | |
| 7720 | | static IrInstSrc *ir_gen_suspend(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { |
| 7729 | static IrInstSrc *astgen_suspend(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) { |
| 7721 | 7730 | assert(node->type == NodeTypeSuspend); |
| 7722 | 7731 | |
| 7723 | 7732 | if (!ag->fn) { |
| ... | ... | @@ -7742,7 +7751,7 @@ static IrInstSrc *ir_gen_suspend(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 7742 | 7751 | IrInstSrcSuspendBegin *begin = ir_build_suspend_begin_src(ag, parent_scope, node); |
| 7743 | 7752 | ScopeSuspend *suspend_scope = create_suspend_scope(ag->codegen, node, parent_scope); |
| 7744 | 7753 | Scope *child_scope = &suspend_scope->base; |
| 7745 | | IrInstSrc *susp_res = ir_gen_node(ag, node->data.suspend.block, child_scope); |
| 7754 | IrInstSrc *susp_res = astgen_node(ag, node->data.suspend.block, child_scope); |
| 7746 | 7755 | if (susp_res == ag->codegen->invalid_inst_src) |
| 7747 | 7756 | return ag->codegen->invalid_inst_src; |
| 7748 | 7757 | ir_mark_gen(ir_build_check_statement_is_void(ag, child_scope, node->data.suspend.block, susp_res)); |
| ... | ... | @@ -7750,7 +7759,7 @@ static IrInstSrc *ir_gen_suspend(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 7750 | 7759 | return ir_mark_gen(ir_build_suspend_finish_src(ag, parent_scope, node, begin)); |
| 7751 | 7760 | } |
| 7752 | 7761 | |
| 7753 | | static IrInstSrc *ir_gen_node_raw(Stage1AstGen *ag, AstNode *node, Scope *scope, |
| 7762 | static IrInstSrc *astgen_node_raw(Stage1AstGen *ag, AstNode *node, Scope *scope, |
| 7754 | 7763 | LVal lval, ResultLoc *result_loc) |
| 7755 | 7764 | { |
| 7756 | 7765 | assert(scope); |
| ... | ... | @@ -7766,40 +7775,40 @@ static IrInstSrc *ir_gen_node_raw(Stage1AstGen *ag, AstNode *node, Scope *scope, |
| 7766 | 7775 | case NodeTypeTestDecl: |
| 7767 | 7776 | zig_unreachable(); |
| 7768 | 7777 | case NodeTypeBlock: |
| 7769 | | return ir_gen_block(ag, scope, node, lval, result_loc); |
| 7778 | return astgen_block(ag, scope, node, lval, result_loc); |
| 7770 | 7779 | case NodeTypeGroupedExpr: |
| 7771 | | return ir_gen_node_raw(ag, node->data.grouped_expr, scope, lval, result_loc); |
| 7780 | return astgen_node_raw(ag, node->data.grouped_expr, scope, lval, result_loc); |
| 7772 | 7781 | case NodeTypeBinOpExpr: |
| 7773 | | return ir_gen_bin_op(ag, scope, node, lval, result_loc); |
| 7782 | return astgen_bin_op(ag, scope, node, lval, result_loc); |
| 7774 | 7783 | case NodeTypeIntLiteral: |
| 7775 | | return ir_lval_wrap(ag, scope, ir_gen_int_lit(ag, scope, node), lval, result_loc); |
| 7784 | return ir_lval_wrap(ag, scope, astgen_int_lit(ag, scope, node), lval, result_loc); |
| 7776 | 7785 | case NodeTypeFloatLiteral: |
| 7777 | | return ir_lval_wrap(ag, scope, ir_gen_float_lit(ag, scope, node), lval, result_loc); |
| 7786 | return ir_lval_wrap(ag, scope, astgen_float_lit(ag, scope, node), lval, result_loc); |
| 7778 | 7787 | case NodeTypeCharLiteral: |
| 7779 | | return ir_lval_wrap(ag, scope, ir_gen_char_lit(ag, scope, node), lval, result_loc); |
| 7788 | return ir_lval_wrap(ag, scope, astgen_char_lit(ag, scope, node), lval, result_loc); |
| 7780 | 7789 | case NodeTypeIdentifier: |
| 7781 | | return ir_gen_symbol(ag, scope, node, lval, result_loc); |
| 7790 | return astgen_identifier(ag, scope, node, lval, result_loc); |
| 7782 | 7791 | case NodeTypeFnCallExpr: |
| 7783 | | return ir_gen_fn_call(ag, scope, node, lval, result_loc); |
| 7792 | return astgen_fn_call(ag, scope, node, lval, result_loc); |
| 7784 | 7793 | case NodeTypeIfBoolExpr: |
| 7785 | | return ir_gen_if_bool_expr(ag, scope, node, lval, result_loc); |
| 7794 | return astgen_if_bool_expr(ag, scope, node, lval, result_loc); |
| 7786 | 7795 | case NodeTypePrefixOpExpr: |
| 7787 | | return ir_gen_prefix_op_expr(ag, scope, node, lval, result_loc); |
| 7796 | return astgen_prefix_op_expr(ag, scope, node, lval, result_loc); |
| 7788 | 7797 | case NodeTypeContainerInitExpr: |
| 7789 | | return ir_gen_container_init_expr(ag, scope, node, lval, result_loc); |
| 7798 | return astgen_container_init_expr(ag, scope, node, lval, result_loc); |
| 7790 | 7799 | case NodeTypeVariableDeclaration: |
| 7791 | | return ir_gen_var_decl(ag, scope, node); |
| 7800 | return astgen_var_decl(ag, scope, node); |
| 7792 | 7801 | case NodeTypeWhileExpr: |
| 7793 | | return ir_gen_while_expr(ag, scope, node, lval, result_loc); |
| 7802 | return astgen_while_expr(ag, scope, node, lval, result_loc); |
| 7794 | 7803 | case NodeTypeForExpr: |
| 7795 | | return ir_gen_for_expr(ag, scope, node, lval, result_loc); |
| 7804 | return astgen_for_expr(ag, scope, node, lval, result_loc); |
| 7796 | 7805 | case NodeTypeArrayAccessExpr: |
| 7797 | | return ir_gen_array_access(ag, scope, node, lval, result_loc); |
| 7806 | return astgen_array_access(ag, scope, node, lval, result_loc); |
| 7798 | 7807 | case NodeTypeReturnExpr: |
| 7799 | | return ir_gen_return(ag, scope, node, lval, result_loc); |
| 7808 | return astgen_return(ag, scope, node, lval, result_loc); |
| 7800 | 7809 | case NodeTypeFieldAccessExpr: |
| 7801 | 7810 | { |
| 7802 | | IrInstSrc *ptr_instruction = ir_gen_field_access(ag, scope, node); |
| 7811 | IrInstSrc *ptr_instruction = astgen_field_access(ag, scope, node); |
| 7803 | 7812 | if (ptr_instruction == ag->codegen->invalid_inst_src) |
| 7804 | 7813 | return ptr_instruction; |
| 7805 | 7814 | if (lval == LValPtr || lval == LValAssign) |
| ... | ... | @@ -7815,7 +7824,7 @@ static IrInstSrc *ir_gen_node_raw(Stage1AstGen *ag, AstNode *node, Scope *scope, |
| 7815 | 7824 | if (child_lval == LValAssign) |
| 7816 | 7825 | child_lval = LValPtr; |
| 7817 | 7826 | |
| 7818 | | IrInstSrc *value = ir_gen_node_extra(ag, expr_node, scope, child_lval, nullptr); |
| 7827 | IrInstSrc *value = astgen_node_extra(ag, expr_node, scope, child_lval, nullptr); |
| 7819 | 7828 | if (value == ag->codegen->invalid_inst_src) |
| 7820 | 7829 | return value; |
| 7821 | 7830 | |
| ... | ... | @@ -7828,7 +7837,7 @@ static IrInstSrc *ir_gen_node_raw(Stage1AstGen *ag, AstNode *node, Scope *scope, |
| 7828 | 7837 | case NodeTypeUnwrapOptional: { |
| 7829 | 7838 | AstNode *expr_node = node->data.unwrap_optional.expr; |
| 7830 | 7839 | |
| 7831 | | IrInstSrc *maybe_ptr = ir_gen_node_extra(ag, expr_node, scope, LValPtr, nullptr); |
| 7840 | IrInstSrc *maybe_ptr = astgen_node_extra(ag, expr_node, scope, LValPtr, nullptr); |
| 7832 | 7841 | if (maybe_ptr == ag->codegen->invalid_inst_src) |
| 7833 | 7842 | return ag->codegen->invalid_inst_src; |
| 7834 | 7843 | |
| ... | ... | @@ -7840,59 +7849,59 @@ static IrInstSrc *ir_gen_node_raw(Stage1AstGen *ag, AstNode *node, Scope *scope, |
| 7840 | 7849 | return ir_expr_wrap(ag, scope, load_ptr, result_loc); |
| 7841 | 7850 | } |
| 7842 | 7851 | case NodeTypeBoolLiteral: |
| 7843 | | return ir_lval_wrap(ag, scope, ir_gen_bool_literal(ag, scope, node), lval, result_loc); |
| 7852 | return ir_lval_wrap(ag, scope, astgen_bool_literal(ag, scope, node), lval, result_loc); |
| 7844 | 7853 | case NodeTypeArrayType: |
| 7845 | | return ir_lval_wrap(ag, scope, ir_gen_array_type(ag, scope, node), lval, result_loc); |
| 7854 | return ir_lval_wrap(ag, scope, astgen_array_type(ag, scope, node), lval, result_loc); |
| 7846 | 7855 | case NodeTypePointerType: |
| 7847 | | return ir_lval_wrap(ag, scope, ir_gen_pointer_type(ag, scope, node), lval, result_loc); |
| 7856 | return ir_lval_wrap(ag, scope, astgen_pointer_type(ag, scope, node), lval, result_loc); |
| 7848 | 7857 | case NodeTypeAnyFrameType: |
| 7849 | | return ir_lval_wrap(ag, scope, ir_gen_anyframe_type(ag, scope, node), lval, result_loc); |
| 7858 | return ir_lval_wrap(ag, scope, astgen_anyframe_type(ag, scope, node), lval, result_loc); |
| 7850 | 7859 | case NodeTypeStringLiteral: |
| 7851 | | return ir_lval_wrap(ag, scope, ir_gen_string_literal(ag, scope, node), lval, result_loc); |
| 7860 | return ir_lval_wrap(ag, scope, astgen_string_literal(ag, scope, node), lval, result_loc); |
| 7852 | 7861 | case NodeTypeUndefinedLiteral: |
| 7853 | | return ir_lval_wrap(ag, scope, ir_gen_undefined_literal(ag, scope, node), lval, result_loc); |
| 7862 | return ir_lval_wrap(ag, scope, astgen_undefined_literal(ag, scope, node), lval, result_loc); |
| 7854 | 7863 | case NodeTypeAsmExpr: |
| 7855 | | return ir_lval_wrap(ag, scope, ir_gen_asm_expr(ag, scope, node), lval, result_loc); |
| 7864 | return ir_lval_wrap(ag, scope, astgen_asm_expr(ag, scope, node), lval, result_loc); |
| 7856 | 7865 | case NodeTypeNullLiteral: |
| 7857 | | return ir_lval_wrap(ag, scope, ir_gen_null_literal(ag, scope, node), lval, result_loc); |
| 7866 | return ir_lval_wrap(ag, scope, astgen_null_literal(ag, scope, node), lval, result_loc); |
| 7858 | 7867 | case NodeTypeIfErrorExpr: |
| 7859 | | return ir_gen_if_err_expr(ag, scope, node, lval, result_loc); |
| 7868 | return astgen_if_err_expr(ag, scope, node, lval, result_loc); |
| 7860 | 7869 | case NodeTypeIfOptional: |
| 7861 | | return ir_gen_if_optional_expr(ag, scope, node, lval, result_loc); |
| 7870 | return astgen_if_optional_expr(ag, scope, node, lval, result_loc); |
| 7862 | 7871 | case NodeTypeSwitchExpr: |
| 7863 | | return ir_gen_switch_expr(ag, scope, node, lval, result_loc); |
| 7872 | return astgen_switch_expr(ag, scope, node, lval, result_loc); |
| 7864 | 7873 | case NodeTypeCompTime: |
| 7865 | | return ir_expr_wrap(ag, scope, ir_gen_comptime(ag, scope, node, lval), result_loc); |
| 7874 | return ir_expr_wrap(ag, scope, astgen_comptime(ag, scope, node, lval), result_loc); |
| 7866 | 7875 | case NodeTypeNoSuspend: |
| 7867 | | return ir_expr_wrap(ag, scope, ir_gen_nosuspend(ag, scope, node, lval), result_loc); |
| 7876 | return ir_expr_wrap(ag, scope, astgen_nosuspend(ag, scope, node, lval), result_loc); |
| 7868 | 7877 | case NodeTypeErrorType: |
| 7869 | | return ir_lval_wrap(ag, scope, ir_gen_error_type(ag, scope, node), lval, result_loc); |
| 7878 | return ir_lval_wrap(ag, scope, astgen_error_type(ag, scope, node), lval, result_loc); |
| 7870 | 7879 | case NodeTypeBreak: |
| 7871 | | return ir_lval_wrap(ag, scope, ir_gen_break(ag, scope, node), lval, result_loc); |
| 7880 | return ir_lval_wrap(ag, scope, astgen_break(ag, scope, node), lval, result_loc); |
| 7872 | 7881 | case NodeTypeContinue: |
| 7873 | | return ir_lval_wrap(ag, scope, ir_gen_continue(ag, scope, node), lval, result_loc); |
| 7882 | return ir_lval_wrap(ag, scope, astgen_continue(ag, scope, node), lval, result_loc); |
| 7874 | 7883 | case NodeTypeUnreachable: |
| 7875 | 7884 | return ir_build_unreachable(ag, scope, node); |
| 7876 | 7885 | case NodeTypeDefer: |
| 7877 | | return ir_lval_wrap(ag, scope, ir_gen_defer(ag, scope, node), lval, result_loc); |
| 7886 | return ir_lval_wrap(ag, scope, astgen_defer(ag, scope, node), lval, result_loc); |
| 7878 | 7887 | case NodeTypeSliceExpr: |
| 7879 | | return ir_gen_slice(ag, scope, node, lval, result_loc); |
| 7888 | return astgen_slice(ag, scope, node, lval, result_loc); |
| 7880 | 7889 | case NodeTypeCatchExpr: |
| 7881 | | return ir_gen_catch(ag, scope, node, lval, result_loc); |
| 7890 | return astgen_catch(ag, scope, node, lval, result_loc); |
| 7882 | 7891 | case NodeTypeContainerDecl: |
| 7883 | | return ir_lval_wrap(ag, scope, ir_gen_container_decl(ag, scope, node), lval, result_loc); |
| 7892 | return ir_lval_wrap(ag, scope, astgen_container_decl(ag, scope, node), lval, result_loc); |
| 7884 | 7893 | case NodeTypeFnProto: |
| 7885 | | return ir_lval_wrap(ag, scope, ir_gen_fn_proto(ag, scope, node), lval, result_loc); |
| 7894 | return ir_lval_wrap(ag, scope, astgen_fn_proto(ag, scope, node), lval, result_loc); |
| 7886 | 7895 | case NodeTypeErrorSetDecl: |
| 7887 | | return ir_lval_wrap(ag, scope, ir_gen_err_set_decl(ag, scope, node), lval, result_loc); |
| 7896 | return ir_lval_wrap(ag, scope, astgen_err_set_decl(ag, scope, node), lval, result_loc); |
| 7888 | 7897 | case NodeTypeResume: |
| 7889 | | return ir_lval_wrap(ag, scope, ir_gen_resume(ag, scope, node), lval, result_loc); |
| 7898 | return ir_lval_wrap(ag, scope, astgen_resume(ag, scope, node), lval, result_loc); |
| 7890 | 7899 | case NodeTypeAwaitExpr: |
| 7891 | | return ir_gen_await_expr(ag, scope, node, lval, result_loc); |
| 7900 | return astgen_await_expr(ag, scope, node, lval, result_loc); |
| 7892 | 7901 | case NodeTypeSuspend: |
| 7893 | | return ir_lval_wrap(ag, scope, ir_gen_suspend(ag, scope, node), lval, result_loc); |
| 7902 | return ir_lval_wrap(ag, scope, astgen_suspend(ag, scope, node), lval, result_loc); |
| 7894 | 7903 | case NodeTypeEnumLiteral: |
| 7895 | | return ir_lval_wrap(ag, scope, ir_gen_enum_literal(ag, scope, node), lval, result_loc); |
| 7904 | return ir_lval_wrap(ag, scope, astgen_enum_literal(ag, scope, node), lval, result_loc); |
| 7896 | 7905 | case NodeTypeInferredArrayType: |
| 7897 | 7906 | add_node_error(ag->codegen, node, |
| 7898 | 7907 | buf_sprintf("inferred array size invalid here")); |
| ... | ... | @@ -7910,7 +7919,7 @@ ResultLoc *no_result_loc(void) { |
| 7910 | 7919 | return &result_loc_none->base; |
| 7911 | 7920 | } |
| 7912 | 7921 | |
| 7913 | | static IrInstSrc *ir_gen_node_extra(Stage1AstGen *ag, AstNode *node, Scope *scope, LVal lval, |
| 7922 | static IrInstSrc *astgen_node_extra(Stage1AstGen *ag, AstNode *node, Scope *scope, LVal lval, |
| 7914 | 7923 | ResultLoc *result_loc) |
| 7915 | 7924 | { |
| 7916 | 7925 | if (lval == LValAssign) { |
| ... | ... | @@ -8018,7 +8027,7 @@ static IrInstSrc *ir_gen_node_extra(Stage1AstGen *ag, AstNode *node, Scope *scop |
| 8018 | 8027 | } else { |
| 8019 | 8028 | child_scope = &create_expr_scope(ag->codegen, node, scope)->base; |
| 8020 | 8029 | } |
| 8021 | | IrInstSrc *result = ir_gen_node_raw(ag, node, child_scope, lval, result_loc); |
| 8030 | IrInstSrc *result = astgen_node_raw(ag, node, child_scope, lval, result_loc); |
| 8022 | 8031 | if (result == ag->codegen->invalid_inst_src) { |
| 8023 | 8032 | if (ag->exec->first_err_trace_msg == nullptr) { |
| 8024 | 8033 | ag->exec->first_err_trace_msg = ag->codegen->trace_err; |
| ... | ... | @@ -8027,8 +8036,8 @@ static IrInstSrc *ir_gen_node_extra(Stage1AstGen *ag, AstNode *node, Scope *scop |
| 8027 | 8036 | return result; |
| 8028 | 8037 | } |
| 8029 | 8038 | |
| 8030 | | static IrInstSrc *ir_gen_node(Stage1AstGen *ag, AstNode *node, Scope *scope) { |
| 8031 | | return ir_gen_node_extra(ag, node, scope, LValNone, nullptr); |
| 8039 | static IrInstSrc *astgen_node(Stage1AstGen *ag, AstNode *node, Scope *scope) { |
| 8040 | return astgen_node_extra(ag, node, scope, LValNone, nullptr); |
| 8032 | 8041 | } |
| 8033 | 8042 | |
| 8034 | 8043 | bool stage1_astgen(CodeGen *codegen, AstNode *node, Scope *scope, Stage1Zir *stage1_zir, |
| ... | ... | @@ -8050,7 +8059,7 @@ bool stage1_astgen(CodeGen *codegen, AstNode *node, Scope *scope, Stage1Zir *sta |
| 8050 | 8059 | // Entry block gets a reference because we enter it to begin. |
| 8051 | 8060 | ir_ref_bb(ag->current_basic_block); |
| 8052 | 8061 | |
| 8053 | | IrInstSrc *result = ir_gen_node_extra(ag, node, scope, LValNone, nullptr); |
| 8062 | IrInstSrc *result = astgen_node_extra(ag, node, scope, LValNone, nullptr); |
| 8054 | 8063 | |
| 8055 | 8064 | if (result == ag->codegen->invalid_inst_src) |
| 8056 | 8065 | return false; |