mirror of
https://github.com/ziglang/zig.git
synced 2026-01-04 20:43:19 +00:00
change zir definition to use *Inst instead of []const u8
This commit is contained in:
parent
641bf4c46e
commit
504c78c022
54
src/zir.zig
54
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 = .{},
|
||||
};
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user