aboutsummaryrefslogtreecommitdiff
path: root/src/ir_print.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-11-21 03:08:24 -0500
committerAndrew Kelley <superjoe30@gmail.com>2016-11-21 03:08:24 -0500
commit71d95c6597bbca6ef44ba8a2a401c28c19a32bbb (patch)
tree01285870db232a793bb25ffbce594515d653fa6f /src/ir_print.cpp
parentb47e2fa0604a5c785d9ed7d16c8086ecf99357f7 (diff)
downloadzig-71d95c6597bbca6ef44ba8a2a401c28c19a32bbb.tar.gz
zig-71d95c6597bbca6ef44ba8a2a401c28c19a32bbb.zip
IR: support unwrap maybe operation
Diffstat (limited to 'src/ir_print.cpp')
-rw-r--r--src/ir_print.cpp20
1 files changed, 20 insertions, 0 deletions
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");
}