@@ -4661,21 +4661,6 @@ static IrInstruction *ir_gen_err_assert_ok(IrBuilder *irb, Scope *scope, AstNode
4661
4661
return ir_build_load_ptr(irb, scope, source_node, payload_ptr);
4662
4662
}
4663
4663
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
-
4679
4664
static IrInstruction *ir_gen_bool_not(IrBuilder *irb, Scope *scope, AstNode *node) {
4680
4665
assert(node->type == NodeTypePrefixOpExpr);
4681
4666
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
4705
4690
return ir_lval_wrap(irb, scope, ir_gen_prefix_op_id(irb, scope, node, IrUnOpNegationWrap), lval);
4706
4691
case PrefixOpOptional:
4707
4692
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);
4710
4693
case PrefixOpAddrOf: {
4711
4694
AstNode *expr_node = node->data.prefix_op_expr.primary_expr;
4712
4695
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
6541
6524
return ir_build_load_ptr(irb, scope, node, ptr_instruction);
6542
6525
}
6543
6526
case NodeTypePtrDeref: {
6544
- assert(node->type == NodeTypePtrDeref);
6545
6527
AstNode *expr_node = node->data.ptr_deref_expr.target;
6546
6528
IrInstruction *value = ir_gen_node_extra(irb, expr_node, scope, lval);
6547
6529
if (value == irb->codegen->invalid_instruction)
6548
6530
return value;
6549
6531
6550
6532
return ir_build_un_op(irb, scope, node, IrUnOpDereference, value);
6551
6533
}
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
+ }
6552
6547
case NodeTypeThisLiteral:
6553
6548
return ir_lval_wrap(irb, scope, ir_gen_this_literal(irb, scope, node), lval);
6554
6549
case NodeTypeBoolLiteral:
0 commit comments