From eadbee2041bba1cd03b24d8f30161025af8e3590 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 15 Jul 2021 15:52:06 -0700 Subject: stage2: first pass at printing AIR/Liveness to text * some instructions are not implemented yet * fix off-by-1 in Air.getMainBody * Compilation: use `@import("builtin")` rather than `std.builtin` for the values that are different for different build configurations. * Sema: avoid calling `addType` in between air_instructions.ensureUnusedCapacity and corresponding appendAssumeCapacity because it can possibly add an instruction. * Value: functions print their names --- src/Module.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index fb514ccbd2..f452824d33 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -3551,7 +3551,8 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn) SemaError!Air { try sema.analyzeFnBody(&inner_block, func.zir_body_inst); // Copy the block into place and mark that as the main block. - try sema.air_extra.ensureUnusedCapacity(gpa, inner_block.instructions.items.len + 1); + try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len + + inner_block.instructions.items.len); const main_block_index = sema.addExtraAssumeCapacity(Air.Block{ .body_len = @intCast(u32, inner_block.instructions.items.len), }); -- cgit v1.2.3