aboutsummaryrefslogtreecommitdiff
path: root/src/ir_print.cpp
diff options
context:
space:
mode:
authorJimmi Holst Christensen <jimmiholstchristensen@gmail.com>2018-04-19 22:43:41 +0200
committerGitHub <noreply@github.com>2018-04-19 22:43:41 +0200
commitcc35f085cad8a8da1b08ecaf6681f097aca7b604 (patch)
tree2d64dc990fb6897a33a99117c034f125e8a96800 /src/ir_print.cpp
parent06909ceaab8ecb33d1f41049870797a3ae721610 (diff)
parent72bf9d90cc5fa4384ca7db1e5bbd4b9445e63bd3 (diff)
downloadzig-cc35f085cad8a8da1b08ecaf6681f097aca7b604.tar.gz
zig-cc35f085cad8a8da1b08ecaf6681f097aca7b604.zip
Merge pull request #934 from zig-lang/adding-builtin-field
Added @field builtin function
Diffstat (limited to 'src/ir_print.cpp')
-rw-r--r--src/ir_print.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/ir_print.cpp b/src/ir_print.cpp
index 45b666ae73..a77ae244d4 100644
--- a/src/ir_print.cpp
+++ b/src/ir_print.cpp
@@ -358,9 +358,18 @@ static void ir_print_ptr_type_child(IrPrint *irp, IrInstructionPtrTypeChild *ins
}
static void ir_print_field_ptr(IrPrint *irp, IrInstructionFieldPtr *instruction) {
- fprintf(irp->f, "fieldptr ");
- ir_print_other_instruction(irp, instruction->container_ptr);
- fprintf(irp->f, ".%s", buf_ptr(instruction->field_name));
+ if (instruction->field_name_buffer) {
+ fprintf(irp->f, "fieldptr ");
+ ir_print_other_instruction(irp, instruction->container_ptr);
+ fprintf(irp->f, ".%s", buf_ptr(instruction->field_name_buffer));
+ } else {
+ assert(instruction->field_name_expr);
+ fprintf(irp->f, "@field(");
+ ir_print_other_instruction(irp, instruction->container_ptr);
+ fprintf(irp->f, ", ");
+ ir_print_other_instruction(irp, instruction->field_name_expr);
+ fprintf(irp->f, ")");
+ }
}
static void ir_print_struct_field_ptr(IrPrint *irp, IrInstructionStructFieldPtr *instruction) {