@@ -4661,21 +4661,6 @@ static IrInstruction *ir_gen_err_assert_ok(IrBuilder *irb, Scope *scope, AstNode
46614661 return ir_build_load_ptr(irb, scope, source_node, payload_ptr);
46624662}
46634663
4664- static IrInstruction *ir_gen_maybe_assert_ok(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval) {
4665- assert(node->type == NodeTypePrefixOpExpr);
4666- AstNode *expr_node = node->data.prefix_op_expr.primary_expr;
4667-
4668- IrInstruction *maybe_ptr = ir_gen_node_extra(irb, expr_node, scope, LVAL_PTR);
4669- if (maybe_ptr == irb->codegen->invalid_instruction)
4670- return irb->codegen->invalid_instruction;
4671-
4672- IrInstruction *unwrapped_ptr = ir_build_unwrap_maybe(irb, scope, node, maybe_ptr, true);
4673- if (lval.is_ptr)
4674- return unwrapped_ptr;
4675-
4676- return ir_build_load_ptr(irb, scope, node, unwrapped_ptr);
4677- }
4678-
46794664static IrInstruction *ir_gen_bool_not(IrBuilder *irb, Scope *scope, AstNode *node) {
46804665 assert(node->type == NodeTypePrefixOpExpr);
46814666 AstNode *expr_node = node->data.prefix_op_expr.primary_expr;
@@ -4705,8 +4690,6 @@ static IrInstruction *ir_gen_prefix_op_expr(IrBuilder *irb, Scope *scope, AstNod
47054690 return ir_lval_wrap(irb, scope, ir_gen_prefix_op_id(irb, scope, node, IrUnOpNegationWrap), lval);
47064691 case PrefixOpOptional:
47074692 return ir_lval_wrap(irb, scope, ir_gen_prefix_op_id(irb, scope, node, IrUnOpOptional), lval);
4708- case PrefixOpUnwrapOptional:
4709- return ir_gen_maybe_assert_ok(irb, scope, node, lval);
47104693 case PrefixOpAddrOf: {
47114694 AstNode *expr_node = node->data.prefix_op_expr.primary_expr;
47124695 return ir_lval_wrap(irb, scope, ir_gen_node_extra(irb, expr_node, scope, LVAL_PTR), lval);
@@ -6541,14 +6524,26 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop
65416524 return ir_build_load_ptr(irb, scope, node, ptr_instruction);
65426525 }
65436526 case NodeTypePtrDeref: {
6544- assert(node->type == NodeTypePtrDeref);
65456527 AstNode *expr_node = node->data.ptr_deref_expr.target;
65466528 IrInstruction *value = ir_gen_node_extra(irb, expr_node, scope, lval);
65476529 if (value == irb->codegen->invalid_instruction)
65486530 return value;
65496531
65506532 return ir_build_un_op(irb, scope, node, IrUnOpDereference, value);
65516533 }
6534+ case NodeTypeUnwrapOptional: {
6535+ AstNode *expr_node = node->data.unwrap_optional.expr;
6536+
6537+ IrInstruction *maybe_ptr = ir_gen_node_extra(irb, expr_node, scope, LVAL_PTR);
6538+ if (maybe_ptr == irb->codegen->invalid_instruction)
6539+ return irb->codegen->invalid_instruction;
6540+
6541+ IrInstruction *unwrapped_ptr = ir_build_unwrap_maybe(irb, scope, node, maybe_ptr, true);
6542+ if (lval.is_ptr)
6543+ return unwrapped_ptr;
6544+
6545+ return ir_build_load_ptr(irb, scope, node, unwrapped_ptr);
6546+ }
65526547 case NodeTypeThisLiteral:
65536548 return ir_lval_wrap(irb, scope, ir_gen_this_literal(irb, scope, node), lval);
65546549 case NodeTypeBoolLiteral:
0 commit comments