diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-02-19 02:57:48 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-19 02:57:48 -0500 |
| commit | 2e1c16d64979c15604b90128fbd63d26ab4b796d (patch) | |
| tree | a6cea3b541c8902a8a6b63a17e2b4a2b076a1b08 /src/Module.zig | |
| parent | 09d93ec845f2f1adaefc512fccaeaa0ea8beed61 (diff) | |
| parent | 4e1e5ab6221b72ef2be9f1fb40c2e6d1235718fe (diff) | |
| download | zig-2e1c16d64979c15604b90128fbd63d26ab4b796d.tar.gz zig-2e1c16d64979c15604b90128fbd63d26ab4b796d.zip | |
Merge pull request #10924 from ziglang/air-independence-day
AIR independence day
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/Module.zig b/src/Module.zig index 524e8402cd..15e90ab068 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -1370,6 +1370,14 @@ pub const Fn = struct { /// ZIR instruction. zir_body_inst: Zir.Inst.Index, + /// Prefer to use `getParamName` to access this because of the future improvement + /// we want to do mentioned in the TODO below. + /// Stored in gpa. + /// TODO: change param ZIR instructions to be embedded inside the function + /// ZIR instruction instead of before it, so that `zir_body_inst` can be used to + /// determine param names rather than redundantly storing them here. + param_names: []const [:0]const u8, + /// Relative to owner Decl. lbrace_line: u32, /// Relative to owner Decl. @@ -1466,6 +1474,18 @@ pub const Fn = struct { gpa.destroy(node); it = next; } + + for (func.param_names) |param_name| { + gpa.free(param_name); + } + gpa.free(func.param_names); + } + + pub fn getParamName(func: Fn, index: u32) [:0]const u8 { + // TODO rework ZIR of parameters so that this function looks up + // param names in ZIR instead of redundantly saving them into Fn. + // const zir = func.owner_decl.getFileScope().zir; + return func.param_names[index]; } }; @@ -4606,15 +4626,11 @@ pub fn analyzeFnBody(mod: *Module, decl: *Decl, func: *Fn, arena: Allocator) Sem runtime_param_index += 1; continue; } - const ty_ref = try sema.addType(param_type); const arg_index = @intCast(u32, sema.air_instructions.len); inner_block.instructions.appendAssumeCapacity(arg_index); sema.air_instructions.appendAssumeCapacity(.{ .tag = .arg, - .data = .{ .ty_str = .{ - .ty = ty_ref, - .str = param.name, - } }, + .data = .{ .ty = param_type }, }); sema.inst_map.putAssumeCapacityNoClobber(inst, Air.indexToRef(arg_index)); total_param_index += 1; |
