aboutsummaryrefslogtreecommitdiff
path: root/src/ir_print.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-03-18 11:24:58 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-03-18 11:28:43 -0400
commitfa7c64ccd511703fef9971c4d07c447c9aeda49c (patch)
tree6f41eb742160ec1584b6adb719ec1327f9e3c831 /src/ir_print.cpp
parentaf536ac343564e5120f99cbf3b7fc9efa984eb93 (diff)
downloadzig-fa7c64ccd511703fef9971c4d07c447c9aeda49c.tar.gz
zig-fa7c64ccd511703fef9971c4d07c447c9aeda49c.zip
lazy analysis of top level declarations
previously, we had lazy analysis of top level declarations, but if a declaration was referenced within a compile-time if or switch statement, that would still add the top level declaration to the resolution queue. now we have a declref ir instruction, which is only resolved if we analyze the instruction. this takes into account comptime branching. closes #270
Diffstat (limited to 'src/ir_print.cpp')
-rw-r--r--src/ir_print.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/ir_print.cpp b/src/ir_print.cpp
index b5f5a16983..8365aec050 100644
--- a/src/ir_print.cpp
+++ b/src/ir_print.cpp
@@ -849,6 +849,13 @@ static void ir_print_set_global_section(IrPrint *irp, IrInstructionSetGlobalSect
fprintf(irp->f, ")");
}
+static void ir_print_decl_ref(IrPrint *irp, IrInstructionDeclRef *instruction) {
+ const char *ptr_str = instruction->lval.is_ptr ? "ptr " : "";
+ const char *const_str = instruction->lval.is_const ? "const " : "";
+ const char *volatile_str = instruction->lval.is_volatile ? "volatile " : "";
+ fprintf(irp->f, "declref %s%s%s%s", const_str, volatile_str, ptr_str, buf_ptr(instruction->tld->name));
+}
+
static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) {
ir_print_prefix(irp, instruction);
switch (instruction->id) {
@@ -1121,6 +1128,9 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) {
case IrInstructionIdSetGlobalSection:
ir_print_set_global_section(irp, (IrInstructionSetGlobalSection *)instruction);
break;
+ case IrInstructionIdDeclRef:
+ ir_print_decl_ref(irp, (IrInstructionDeclRef *)instruction);
+ break;
}
fprintf(irp->f, "\n");
}