aboutsummaryrefslogtreecommitdiff
path: root/src/ir_print.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-12-20 01:50:32 -0500
committerAndrew Kelley <superjoe30@gmail.com>2016-12-20 01:50:32 -0500
commit1f6dacbb2f9a91a20309b271a31e781f11f81819 (patch)
tree418c311fc703a4163ebf16cc90e89346b5113785 /src/ir_print.cpp
parentc10ae8622bc07baeea1fb81522b01fc6e953eaf6 (diff)
downloadzig-1f6dacbb2f9a91a20309b271a31e781f11f81819.tar.gz
zig-1f6dacbb2f9a91a20309b271a31e781f11f81819.zip
IR: enum init support
Diffstat (limited to 'src/ir_print.cpp')
-rw-r--r--src/ir_print.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/ir_print.cpp b/src/ir_print.cpp
index 7ebae91d5a..c723da4726 100644
--- a/src/ir_print.cpp
+++ b/src/ir_print.cpp
@@ -183,6 +183,13 @@ static void ir_print_const_value(IrPrint *irp, TypeTableEntry *type_entry, Const
fprintf(irp->f, "(pure error constant)");
return;
}
+ case TypeTableEntryIdEnumTag:
+ {
+ TypeTableEntry *enum_type = type_entry->data.enum_tag.enum_type;
+ TypeEnumField *field = &enum_type->data.enumeration.fields[const_val->data.x_bignum.data.x_uint];
+ fprintf(irp->f, "%s.%s", buf_ptr(&enum_type->name), buf_ptr(field->name));
+ return;
+ }
}
zig_unreachable();
}
@@ -911,6 +918,12 @@ static void ir_print_test_comptime(IrPrint *irp, IrInstructionTestComptime *inst
fprintf(irp->f, ")");
}
+static void ir_print_init_enum(IrPrint *irp, IrInstructionInitEnum *instruction) {
+ fprintf(irp->f, "%s.%s { ", buf_ptr(&instruction->enum_type->name), buf_ptr(instruction->field->name));
+ ir_print_other_instruction(irp, instruction->init_value);
+ fprintf(irp->f, "{");
+}
+
static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) {
ir_print_prefix(irp, instruction);
switch (instruction->id) {
@@ -1147,6 +1160,9 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) {
case IrInstructionIdTestComptime:
ir_print_test_comptime(irp, (IrInstructionTestComptime *)instruction);
break;
+ case IrInstructionIdInitEnum:
+ ir_print_init_enum(irp, (IrInstructionInitEnum *)instruction);
+ break;
}
fprintf(irp->f, "\n");
}