authorgravatar for jacoblevgw@gmail.comJacob G-W <jacoblevgw@gmail.com> 2020-12-26 11:11:29-05:00
committergravatar for jacoblevgw@gmail.comJacob G-W <jacoblevgw@gmail.com> 2020-12-26 11:13:13-05:00
log504c78c022567439d2ac43096ae19fc558bce8fc
tree746abd3109fb8e348907e6969f7b391711bd8d10
parent641bf4c46eb2d5c1f3e95898ed74848a56e0d999

change zir definition to use *Inst instead of []const u8


2 files changed, 52 insertions(+), 5 deletions(-)

src/zir.zig+50-4
......@@ -706,7 +706,7 @@ pub const Inst = struct {
706706 base: Inst,
707707
708708 positionals: struct {
709 msg: []const u8,
709 msg: *Inst,
710710 },
711711 kw_args: struct {},
712712 };
......@@ -1950,7 +1950,23 @@ const EmitZIR = struct {
19501950 .tag = Inst.CompileError.base_tag,
19511951 },
19521952 .positionals = .{
1953 .msg = try self.arena.allocator.dupe(u8, err_msg_list.items[0].msg),
1953
1954 .msg = blk: {
1955 const msg_str = try self.arena.allocator.dupe(u8, err_msg_list.items[0].msg);
1956
1957 const str_inst = try self.arena.allocator.create(Inst.Str);
1958 str_inst.* = .{
1959 .base = .{
1960 .src = ir_decl.src(),
1961 .tag = Inst.Str.base_tag,
1962 },
1963 .positionals = .{
1964 .bytes = msg_str,
1965 },
1966 .kw_args = .{},
1967 };
1968 break :blk &str_inst.base;
1969 },
19541970 },
19551971 .kw_args = .{},
19561972 };
......@@ -2080,7 +2096,22 @@ const EmitZIR = struct {
20802096 .tag = Inst.CompileError.base_tag,
20812097 },
20822098 .positionals = .{
2083 .msg = try self.arena.allocator.dupe(u8, err_msg.msg),
2099 .msg = blk: {
2100 const msg_str = try self.arena.allocator.dupe(u8, err_msg.msg);
2101
2102 const str_inst = try self.arena.allocator.create(Inst.Str);
2103 str_inst.* = .{
2104 .base = .{
2105 .src = src,
2106 .tag = Inst.Str.base_tag,
2107 },
2108 .positionals = .{
2109 .bytes = msg_str,
2110 },
2111 .kw_args = .{},
2112 };
2113 break :blk &str_inst.base;
2114 },
20842115 },
20852116 .kw_args = .{},
20862117 };
......@@ -2094,7 +2125,22 @@ const EmitZIR = struct {
20942125 .tag = Inst.CompileError.base_tag,
20952126 },
20962127 .positionals = .{
2097 .msg = try self.arena.allocator.dupe(u8, "depends on another failed Decl"),
2128 .msg = blk: {
2129 const msg_str = try self.arena.allocator.dupe(u8, "depends on another failed Decl");
2130
2131 const str_inst = try self.arena.allocator.create(Inst.Str);
2132 str_inst.* = .{
2133 .base = .{
2134 .src = src,
2135 .tag = Inst.Str.base_tag,
2136 },
2137 .positionals = .{
2138 .bytes = msg_str,
2139 },
2140 .kw_args = .{},
2141 };
2142 break :blk &str_inst.base;
2143 },
20982144 },
20992145 .kw_args = .{},
21002146 };
src/zir_sema.zig+2-1
......@@ -487,7 +487,8 @@ fn analyzeInstExport(mod: *Module, scope: *Scope, export_inst: *zir.Inst.Export)
487487}
488488
489489fn analyzeInstCompileError(mod: *Module, scope: *Scope, inst: *zir.Inst.CompileError) InnerError!*Inst {
490 return mod.fail(scope, inst.base.src, "{}", .{inst.positionals.msg});
490 const msg = try resolveConstString(mod,scope,inst.positionals.msg);
491 return mod.fail(scope, inst.base.src, "{}", .{msg});
491492}
492493
493494fn analyzeInstCompileLog(mod: *Module, scope: *Scope, inst: *zir.Inst.CompileLog) InnerError!*Inst {