| ... | ... | @@ -3986,48 +3986,44 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn) !void { |
| 3986 | 3986 | param_inst.* = &arg_inst.base; |
| 3987 | 3987 | } |
| 3988 | 3988 | |
| 3989 | | var f = false; |
| 3990 | | if (f) { |
| 3991 | | return error.AnalysisFail; |
| 3992 | | } |
| 3993 | | @panic("TODO reimplement analyzeFnBody now that ZIR is whole-file"); |
| 3994 | | |
| 3995 | | //var sema: Sema = .{ |
| 3996 | | // .mod = mod, |
| 3997 | | // .gpa = mod.gpa, |
| 3998 | | // .arena = &arena.allocator, |
| 3999 | | // .code = func.zir, |
| 4000 | | // .inst_map = try mod.gpa.alloc(*ir.Inst, func.zir.instructions.len), |
| 4001 | | // .owner_decl = decl, |
| 4002 | | // .namespace = decl.namespace, |
| 4003 | | // .func = func, |
| 4004 | | // .owner_func = func, |
| 4005 | | // .param_inst_list = param_inst_list, |
| 4006 | | //}; |
| 4007 | | //defer mod.gpa.free(sema.inst_map); |
| 4008 | | |
| 4009 | | //var inner_block: Scope.Block = .{ |
| 4010 | | // .parent = null, |
| 4011 | | // .sema = &sema, |
| 4012 | | // .src_decl = decl, |
| 4013 | | // .instructions = .{}, |
| 4014 | | // .inlining = null, |
| 4015 | | // .is_comptime = false, |
| 4016 | | //}; |
| 4017 | | //defer inner_block.instructions.deinit(mod.gpa); |
| 4018 | | |
| 4019 | | //// AIR currently requires the arg parameters to be the first N instructions |
| 4020 | | //try inner_block.instructions.appendSlice(mod.gpa, param_inst_list); |
| 4021 | | |
| 4022 | | //func.state = .in_progress; |
| 4023 | | //log.debug("set {s} to in_progress", .{decl.name}); |
| 4024 | | |
| 4025 | | //_ = try sema.root(&inner_block); |
| 4026 | | |
| 4027 | | //const instructions = try arena.allocator.dupe(*ir.Inst, inner_block.instructions.items); |
| 4028 | | //func.state = .success; |
| 4029 | | //func.body = .{ .instructions = instructions }; |
| 4030 | | //log.debug("set {s} to success", .{decl.name}); |
| 3989 | const zir = decl.namespace.file_scope.zir; |
| 3990 | |
| 3991 | var sema: Sema = .{ |
| 3992 | .mod = mod, |
| 3993 | .gpa = mod.gpa, |
| 3994 | .arena = &arena.allocator, |
| 3995 | .code = zir, |
| 3996 | .inst_map = try mod.gpa.alloc(*ir.Inst, zir.instructions.len), |
| 3997 | .owner_decl = decl, |
| 3998 | .namespace = decl.namespace, |
| 3999 | .func = func, |
| 4000 | .owner_func = func, |
| 4001 | .param_inst_list = param_inst_list, |
| 4002 | }; |
| 4003 | defer mod.gpa.free(sema.inst_map); |
| 4004 | |
| 4005 | var inner_block: Scope.Block = .{ |
| 4006 | .parent = null, |
| 4007 | .sema = &sema, |
| 4008 | .src_decl = decl, |
| 4009 | .instructions = .{}, |
| 4010 | .inlining = null, |
| 4011 | .is_comptime = false, |
| 4012 | }; |
| 4013 | defer inner_block.instructions.deinit(mod.gpa); |
| 4014 | |
| 4015 | // AIR currently requires the arg parameters to be the first N instructions |
| 4016 | try inner_block.instructions.appendSlice(mod.gpa, param_inst_list); |
| 4017 | |
| 4018 | func.state = .in_progress; |
| 4019 | log.debug("set {s} to in_progress", .{decl.name}); |
| 4020 | |
| 4021 | try sema.analyzeFnBody(&inner_block, func.zir_body_inst); |
| 4022 | |
| 4023 | const instructions = try arena.allocator.dupe(*ir.Inst, inner_block.instructions.items); |
| 4024 | func.state = .success; |
| 4025 | func.body = .{ .instructions = instructions }; |
| 4026 | log.debug("set {s} to success", .{decl.name}); |
| 4031 | 4027 | } |
| 4032 | 4028 | |
| 4033 | 4029 | fn markOutdatedDecl(mod: *Module, decl: *Decl) !void { |