| ... | @@ -356,6 +356,28 @@ static void ir_ref_var(ZigVar *var) { | ... | @@ -356,6 +356,28 @@ static void ir_ref_var(ZigVar *var) { |
| 356 | var->ref_count += 1; | 356 | var->ref_count += 1; |
| 357 | } | 357 | } |
| 358 | | 358 | |
| | 359 | ZigType *ir_analyze_type_expr(IrAnalyze *ira, Scope *scope, AstNode *node) { |
| | 360 | ConstExprValue *result = ir_eval_const_value( ira->codegen |
| | 361 | , scope |
| | 362 | , node |
| | 363 | , ira->codegen->builtin_types.entry_type |
| | 364 | , ira->new_irb.exec->backward_branch_count |
| | 365 | , ira->new_irb.exec->backward_branch_quota |
| | 366 | , nullptr |
| | 367 | , nullptr |
| | 368 | , node |
| | 369 | , nullptr |
| | 370 | , ira->new_irb.exec |
| | 371 | , nullptr |
| | 372 | ); |
| | 373 | |
| | 374 | if (type_is_invalid(result->type)) |
| | 375 | return ira->codegen->builtin_types.entry_invalid; |
| | 376 | |
| | 377 | assert(result->special != ConstValSpecialRuntime); |
| | 378 | return result->data.x_type; |
| | 379 | } |
| | 380 | |
| 359 | static IrBasicBlock *ir_create_basic_block(IrBuilder *irb, Scope *scope, const char *name_hint) { | 381 | static IrBasicBlock *ir_create_basic_block(IrBuilder *irb, Scope *scope, const char *name_hint) { |
| 360 | IrBasicBlock *result = allocate<IrBasicBlock>(1); | 382 | IrBasicBlock *result = allocate<IrBasicBlock>(1); |
| 361 | result->scope = scope; | 383 | result->scope = scope; |
| ... | @@ -13875,7 +13897,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node | ... | @@ -13875,7 +13897,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node |
| 13875 | IrInstruction *casted_arg; | 13897 | IrInstruction *casted_arg; |
| 13876 | if (param_decl_node->data.param_decl.var_token == nullptr) { | 13898 | if (param_decl_node->data.param_decl.var_token == nullptr) { |
| 13877 | AstNode *param_type_node = param_decl_node->data.param_decl.type; | 13899 | AstNode *param_type_node = param_decl_node->data.param_decl.type; |
| 13878 | ZigType *param_type = analyze_type_expr(ira->codegen, *exec_scope, param_type_node); | 13900 | ZigType *param_type = ir_analyze_type_expr(ira, *exec_scope, param_type_node); |
| 13879 | if (type_is_invalid(param_type)) | 13901 | if (type_is_invalid(param_type)) |
| 13880 | return false; | 13902 | return false; |
| 13881 | | 13903 | |
| ... | @@ -13915,7 +13937,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -13915,7 +13937,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 13915 | } else { | 13937 | } else { |
| 13916 | if (param_decl_node->data.param_decl.var_token == nullptr) { | 13938 | if (param_decl_node->data.param_decl.var_token == nullptr) { |
| 13917 | AstNode *param_type_node = param_decl_node->data.param_decl.type; | 13939 | AstNode *param_type_node = param_decl_node->data.param_decl.type; |
| 13918 | ZigType *param_type = analyze_type_expr(ira->codegen, *child_scope, param_type_node); | 13940 | ZigType *param_type = ir_analyze_type_expr(ira, *child_scope, param_type_node); |
| 13919 | if (type_is_invalid(param_type)) | 13941 | if (type_is_invalid(param_type)) |
| 13920 | return false; | 13942 | return false; |
| 13921 | | 13943 | |
| ... | @@ -14296,7 +14318,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call | ... | @@ -14296,7 +14318,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call |
| 14296 | } | 14318 | } |
| 14297 | | 14319 | |
| 14298 | AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; | 14320 | AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; |
| 14299 | ZigType *specified_return_type = analyze_type_expr(ira->codegen, exec_scope, return_type_node); | 14321 | ZigType *specified_return_type = ir_analyze_type_expr(ira, exec_scope, return_type_node); |
| 14300 | if (type_is_invalid(specified_return_type)) | 14322 | if (type_is_invalid(specified_return_type)) |
| 14301 | return ira->codegen->invalid_instruction; | 14323 | return ira->codegen->invalid_instruction; |
| 14302 | ZigType *return_type; | 14324 | ZigType *return_type; |
| ... | @@ -14532,7 +14554,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call | ... | @@ -14532,7 +14554,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call |
| 14532 | | 14554 | |
| 14533 | if (fn_proto_node->data.fn_proto.return_var_token == nullptr) { | 14555 | if (fn_proto_node->data.fn_proto.return_var_token == nullptr) { |
| 14534 | AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; | 14556 | AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; |
| 14535 | ZigType *specified_return_type = analyze_type_expr(ira->codegen, impl_fn->child_scope, return_type_node); | 14557 | ZigType *specified_return_type = ir_analyze_type_expr(ira, impl_fn->child_scope, return_type_node); |
| 14536 | if (type_is_invalid(specified_return_type)) | 14558 | if (type_is_invalid(specified_return_type)) |
| 14537 | return ira->codegen->invalid_instruction; | 14559 | return ira->codegen->invalid_instruction; |
| 14538 | if (fn_proto_node->data.fn_proto.auto_err_set) { | 14560 | if (fn_proto_node->data.fn_proto.auto_err_set) { |
| ... | @@ -14559,7 +14581,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call | ... | @@ -14559,7 +14581,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call |
| 14559 | if (call_instruction->is_async) { | 14581 | if (call_instruction->is_async) { |
| 14560 | AstNode *async_allocator_type_node = fn_proto_node->data.fn_proto.async_allocator_type; | 14582 | AstNode *async_allocator_type_node = fn_proto_node->data.fn_proto.async_allocator_type; |
| 14561 | if (async_allocator_type_node != nullptr) { | 14583 | if (async_allocator_type_node != nullptr) { |
| 14562 | ZigType *async_allocator_type = analyze_type_expr(ira->codegen, impl_fn->child_scope, async_allocator_type_node); | 14584 | ZigType *async_allocator_type = ir_analyze_type_expr(ira, impl_fn->child_scope, async_allocator_type_node); |
| 14563 | if (type_is_invalid(async_allocator_type)) | 14585 | if (type_is_invalid(async_allocator_type)) |
| 14564 | return ira->codegen->invalid_instruction; | 14586 | return ira->codegen->invalid_instruction; |
| 14565 | inst_fn_type_id.async_allocator_type = async_allocator_type; | 14587 | inst_fn_type_id.async_allocator_type = async_allocator_type; |