diff options
| author | g-w1 <jacoblevgw@gmail.com> | 2020-12-26 11:11:29 -0500 |
|---|---|---|
| committer | g-w1 <jacoblevgw@gmail.com> | 2020-12-26 11:13:13 -0500 |
| commit | 504c78c022567439d2ac43096ae19fc558bce8fc (patch) | |
| tree | 746abd3109fb8e348907e6969f7b391711bd8d10 /src | |
| parent | 641bf4c46eb2d5c1f3e95898ed74848a56e0d999 (diff) | |
| download | zig-504c78c022567439d2ac43096ae19fc558bce8fc.tar.gz zig-504c78c022567439d2ac43096ae19fc558bce8fc.zip | |
change zir definition to use *Inst instead of []const u8
Diffstat (limited to 'src')
| -rw-r--r-- | src/zir.zig | 54 | ||||
| -rw-r--r-- | src/zir_sema.zig | 3 |
2 files changed, 52 insertions, 5 deletions
diff --git a/src/zir.zig b/src/zir.zig index 982c98ddc9..927dfa4a21 100644 --- a/src/zir.zig +++ b/src/zir.zig @@ -706,7 +706,7 @@ pub const Inst = struct { base: Inst, positionals: struct { - msg: []const u8, + msg: *Inst, }, kw_args: struct {}, }; @@ -1950,7 +1950,23 @@ const EmitZIR = struct { .tag = Inst.CompileError.base_tag, }, .positionals = .{ - .msg = try self.arena.allocator.dupe(u8, err_msg_list.items[0].msg), + + .msg = blk: { + const msg_str = try self.arena.allocator.dupe(u8, err_msg_list.items[0].msg); + + const str_inst = try self.arena.allocator.create(Inst.Str); + str_inst.* = .{ + .base = .{ + .src = ir_decl.src(), + .tag = Inst.Str.base_tag, + }, + .positionals = .{ + .bytes = msg_str, + }, + .kw_args = .{}, + }; + break :blk &str_inst.base; + }, }, .kw_args = .{}, }; @@ -2080,7 +2096,22 @@ const EmitZIR = struct { .tag = Inst.CompileError.base_tag, }, .positionals = .{ - .msg = try self.arena.allocator.dupe(u8, err_msg.msg), + .msg = blk: { + const msg_str = try self.arena.allocator.dupe(u8, err_msg.msg); + + const str_inst = try self.arena.allocator.create(Inst.Str); + str_inst.* = .{ + .base = .{ + .src = src, + .tag = Inst.Str.base_tag, + }, + .positionals = .{ + .bytes = msg_str, + }, + .kw_args = .{}, + }; + break :blk &str_inst.base; + }, }, .kw_args = .{}, }; @@ -2094,7 +2125,22 @@ const EmitZIR = struct { .tag = Inst.CompileError.base_tag, }, .positionals = .{ - .msg = try self.arena.allocator.dupe(u8, "depends on another failed Decl"), + .msg = blk: { + const msg_str = try self.arena.allocator.dupe(u8, "depends on another failed Decl"); + + const str_inst = try self.arena.allocator.create(Inst.Str); + str_inst.* = .{ + .base = .{ + .src = src, + .tag = Inst.Str.base_tag, + }, + .positionals = .{ + .bytes = msg_str, + }, + .kw_args = .{}, + }; + break :blk &str_inst.base; + }, }, .kw_args = .{}, }; diff --git a/src/zir_sema.zig b/src/zir_sema.zig index 16f2297ee6..cbb3dfc3fb 100644 --- a/src/zir_sema.zig +++ b/src/zir_sema.zig @@ -487,7 +487,8 @@ fn analyzeInstExport(mod: *Module, scope: *Scope, export_inst: *zir.Inst.Export) } fn analyzeInstCompileError(mod: *Module, scope: *Scope, inst: *zir.Inst.CompileError) InnerError!*Inst { - return mod.fail(scope, inst.base.src, "{}", .{inst.positionals.msg}); + const msg = try resolveConstString(mod,scope,inst.positionals.msg); + return mod.fail(scope, inst.base.src, "{}", .{msg}); } fn analyzeInstCompileLog(mod: *Module, scope: *Scope, inst: *zir.Inst.CompileLog) InnerError!*Inst { |
