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 {...@@ -706,7 +706,7 @@ pub const Inst = struct {
706 base: Inst,706 base: Inst,
707707
708 positionals: struct {708 positionals: struct {
709 msg: []const u8,709 msg: *Inst,
710 },710 },
711 kw_args: struct {},711 kw_args: struct {},
712 };712 };
...@@ -1950,7 +1950,23 @@ const EmitZIR = struct {...@@ -1950,7 +1950,23 @@ const EmitZIR = struct {
1950 .tag = Inst.CompileError.base_tag,1950 .tag = Inst.CompileError.base_tag,
1951 },1951 },
1952 .positionals = .{1952 .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 },
1954 },1970 },
1955 .kw_args = .{},1971 .kw_args = .{},
1956 };1972 };
...@@ -2080,7 +2096,22 @@ const EmitZIR = struct {...@@ -2080,7 +2096,22 @@ const EmitZIR = struct {
2080 .tag = Inst.CompileError.base_tag,2096 .tag = Inst.CompileError.base_tag,
2081 },2097 },
2082 .positionals = .{2098 .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 },
2084 },2115 },
2085 .kw_args = .{},2116 .kw_args = .{},
2086 };2117 };
...@@ -2094,7 +2125,22 @@ const EmitZIR = struct {...@@ -2094,7 +2125,22 @@ const EmitZIR = struct {
2094 .tag = Inst.CompileError.base_tag,2125 .tag = Inst.CompileError.base_tag,
2095 },2126 },
2096 .positionals = .{2127 .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 },
2098 },2144 },
2099 .kw_args = .{},2145 .kw_args = .{},
2100 };2146 };
src/zir_sema.zig+2-1
...@@ -487,7 +487,8 @@ fn analyzeInstExport(mod: *Module, scope: *Scope, export_inst: *zir.Inst.Export)...@@ -487,7 +487,8 @@ fn analyzeInstExport(mod: *Module, scope: *Scope, export_inst: *zir.Inst.Export)
487}487}
488488
489fn analyzeInstCompileError(mod: *Module, scope: *Scope, inst: *zir.Inst.CompileError) InnerError!*Inst {489fn 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});
491}492}
492493
493fn analyzeInstCompileLog(mod: *Module, scope: *Scope, inst: *zir.Inst.CompileLog) InnerError!*Inst {494fn analyzeInstCompileLog(mod: *Module, scope: *Scope, inst: *zir.Inst.CompileLog) InnerError!*Inst {