From 71d95c6597bbca6ef44ba8a2a401c28c19a32bbb Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 21 Nov 2016 03:08:24 -0500 Subject: IR: support unwrap maybe operation --- src/ir_print.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/ir_print.cpp') diff --git a/src/ir_print.cpp b/src/ir_print.cpp index c65334d0d7..fffe33588a 100644 --- a/src/ir_print.cpp +++ b/src/ir_print.cpp @@ -497,6 +497,20 @@ static void ir_print_size_of(IrPrint *irp, IrInstructionSizeOf *instruction) { fprintf(irp->f, ")"); } +static void ir_print_test_null(IrPrint *irp, IrInstructionTestNull *instruction) { + fprintf(irp->f, "*"); + ir_print_other_instruction(irp, instruction->value); + fprintf(irp->f, " == null"); +} + +static void ir_print_unwrap_maybe(IrPrint *irp, IrInstructionUnwrapMaybe *instruction) { + fprintf(irp->f, "&??*"); + ir_print_other_instruction(irp, instruction->value); + if (!instruction->safety_check_on) { + fprintf(irp->f, " // no safety"); + } +} + static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) { ir_print_prefix(irp, instruction); switch (instruction->id) { @@ -592,6 +606,12 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) { case IrInstructionIdSizeOf: ir_print_size_of(irp, (IrInstructionSizeOf *)instruction); break; + case IrInstructionIdTestNull: + ir_print_test_null(irp, (IrInstructionTestNull *)instruction); + break; + case IrInstructionIdUnwrapMaybe: + ir_print_unwrap_maybe(irp, (IrInstructionUnwrapMaybe *)instruction); + break; case IrInstructionIdSwitchBr: zig_panic("TODO print more IR instructions"); } -- cgit v1.2.3