aboutsummaryrefslogtreecommitdiff
path: root/src/ir_print.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-12-17 16:06:48 -0500
committerAndrew Kelley <superjoe30@gmail.com>2016-12-17 16:16:17 -0500
commit12fcbecbf8a1c8496354b909e0de2a69600115a9 (patch)
tree4c625d36661db5860196763f8d952753f12d1fd4 /src/ir_print.cpp
parent3a3cc7bf76eab3ef239991e686c114baeaf4672e (diff)
downloadzig-12fcbecbf8a1c8496354b909e0de2a69600115a9.tar.gz
zig-12fcbecbf8a1c8496354b909e0de2a69600115a9.zip
IR: add more instructions
* MaybeWrap * TestErr * UnwrapErrCode * UnwrapErrPayload * ErrUnionTypeChild * ErrWrapCode * ErrWrapPayload
Diffstat (limited to 'src/ir_print.cpp')
-rw-r--r--src/ir_print.cpp74
1 files changed, 66 insertions, 8 deletions
diff --git a/src/ir_print.cpp b/src/ir_print.cpp
index 8f9001edbd..85cbd67ba7 100644
--- a/src/ir_print.cpp
+++ b/src/ir_print.cpp
@@ -295,14 +295,6 @@ static const char *ir_un_op_id_str(IrUnOp op_id) {
return "?";
case IrUnOpError:
return "%";
- case IrUnOpUnwrapError:
- return "%%";
- case IrUnOpUnwrapMaybe:
- return "??";
- case IrUnOpMaybeReturn:
- return "?return";
- case IrUnOpErrorReturn:
- return "%return";
}
zig_unreachable();
}
@@ -855,6 +847,51 @@ static void ir_print_overflow_op(IrPrint *irp, IrInstructionOverflowOp *instruct
fprintf(irp->f, ")");
}
+static void ir_print_test_err(IrPrint *irp, IrInstructionTestErr *instruction) {
+ fprintf(irp->f, "@testError(");
+ ir_print_other_instruction(irp, instruction->value);
+ fprintf(irp->f, ")");
+}
+
+static void ir_print_err_union_type_child(IrPrint *irp, IrInstructionErrUnionTypeChild *instruction) {
+ fprintf(irp->f, "@errorUnionTypeChild(");
+ ir_print_other_instruction(irp, instruction->type_value);
+ fprintf(irp->f, ")");
+}
+
+static void ir_print_unwrap_err_code(IrPrint *irp, IrInstructionUnwrapErrCode *instruction) {
+ fprintf(irp->f, "@unwrapErrorCode(");
+ ir_print_other_instruction(irp, instruction->value);
+ fprintf(irp->f, ")");
+}
+
+static void ir_print_unwrap_err_payload(IrPrint *irp, IrInstructionUnwrapErrPayload *instruction) {
+ fprintf(irp->f, "@unwrapErrorPayload(");
+ ir_print_other_instruction(irp, instruction->value);
+ fprintf(irp->f, ")");
+ if (!instruction->safety_check_on) {
+ fprintf(irp->f, " // no safety");
+ }
+}
+
+static void ir_print_maybe_wrap(IrPrint *irp, IrInstructionMaybeWrap *instruction) {
+ fprintf(irp->f, "@maybeWrap(");
+ ir_print_other_instruction(irp, instruction->value);
+ fprintf(irp->f, ")");
+}
+
+static void ir_print_err_wrap_code(IrPrint *irp, IrInstructionErrWrapCode *instruction) {
+ fprintf(irp->f, "@errWrapCode(");
+ ir_print_other_instruction(irp, instruction->value);
+ fprintf(irp->f, ")");
+}
+
+static void ir_print_err_wrap_payload(IrPrint *irp, IrInstructionErrWrapPayload *instruction) {
+ fprintf(irp->f, "@errWrapPayload(");
+ ir_print_other_instruction(irp, instruction->value);
+ fprintf(irp->f, ")");
+}
+
static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) {
ir_print_prefix(irp, instruction);
switch (instruction->id) {
@@ -1067,6 +1104,27 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) {
case IrInstructionIdOverflowOp:
ir_print_overflow_op(irp, (IrInstructionOverflowOp *)instruction);
break;
+ case IrInstructionIdTestErr:
+ ir_print_test_err(irp, (IrInstructionTestErr *)instruction);
+ break;
+ case IrInstructionIdUnwrapErrCode:
+ ir_print_unwrap_err_code(irp, (IrInstructionUnwrapErrCode *)instruction);
+ break;
+ case IrInstructionIdUnwrapErrPayload:
+ ir_print_unwrap_err_payload(irp, (IrInstructionUnwrapErrPayload *)instruction);
+ break;
+ case IrInstructionIdErrUnionTypeChild:
+ ir_print_err_union_type_child(irp, (IrInstructionErrUnionTypeChild *)instruction);
+ break;
+ case IrInstructionIdMaybeWrap:
+ ir_print_maybe_wrap(irp, (IrInstructionMaybeWrap *)instruction);
+ break;
+ case IrInstructionIdErrWrapCode:
+ ir_print_err_wrap_code(irp, (IrInstructionErrWrapCode *)instruction);
+ break;
+ case IrInstructionIdErrWrapPayload:
+ ir_print_err_wrap_payload(irp, (IrInstructionErrWrapPayload *)instruction);
+ break;
}
fprintf(irp->f, "\n");
}