authorgravatar for jacoblevgw@gmail.comJacob G-W <jacoblevgw@gmail.com> 2020-12-26 12:01:14-05:00
committergravatar for jacoblevgw@gmail.comJacob G-W <jacoblevgw@gmail.com> 2020-12-26 12:01:14-05:00
logaf80240678112276cedd5c5247b843fa101186b0
tree70c10ae578d5dfd4f83d38b51050845dfb60c7ac
parentd6e9862049c069bcfcafdef3f3e7de842ba44cbd

make compileError use an UnOp since its operand is just a *Inst


2 files changed, 12 insertions(+), 22 deletions(-)

src/zir.zig+10-20
...@@ -300,6 +300,7 @@ pub const Inst = struct {...@@ -300,6 +300,7 @@ pub const Inst = struct {
300 => NoOp,300 => NoOp,
301301
302 .boolnot,302 .boolnot,
303 .compileerror,
303 .deref,304 .deref,
304 .@"return",305 .@"return",
305 .isnull,306 .isnull,
...@@ -387,7 +388,6 @@ pub const Inst = struct {...@@ -387,7 +388,6 @@ pub const Inst = struct {
387 .declval => DeclVal,388 .declval => DeclVal,
388 .declval_in_module => DeclValInModule,389 .declval_in_module => DeclValInModule,
389 .coerce_result_block_ptr => CoerceResultBlockPtr,390 .coerce_result_block_ptr => CoerceResultBlockPtr,
390 .compileerror => CompileError,
391 .compilelog => CompileLog,391 .compilelog => CompileLog,
392 .loop => Loop,392 .loop => Loop,
393 .@"const" => Const,393 .@"const" => Const,
...@@ -701,16 +701,6 @@ pub const Inst = struct {...@@ -701,16 +701,6 @@ pub const Inst = struct {
701 kw_args: struct {},701 kw_args: struct {},
702 };702 };
703703
704 pub const CompileError = struct {
705 pub const base_tag = Tag.compileerror;
706 base: Inst,
707
708 positionals: struct {
709 msg: *Inst,
710 },
711 kw_args: struct {},
712 };
713
714 pub const CompileLog = struct {704 pub const CompileLog = struct {
715 pub const base_tag = Tag.compilelog;705 pub const base_tag = Tag.compilelog;
716 base: Inst,706 base: Inst,
...@@ -1943,14 +1933,14 @@ const EmitZIR = struct {...@@ -1943,14 +1933,14 @@ const EmitZIR = struct {
1943 .sema_failure_retryable,1933 .sema_failure_retryable,
1944 .dependency_failure,1934 .dependency_failure,
1945 => if (self.old_module.failed_decls.get(ir_decl)) |err_msg_list| {1935 => if (self.old_module.failed_decls.get(ir_decl)) |err_msg_list| {
1946 const fail_inst = try self.arena.allocator.create(Inst.CompileError);1936 const fail_inst = try self.arena.allocator.create(Inst.UnOp);
1947 fail_inst.* = .{1937 fail_inst.* = .{
1948 .base = .{1938 .base = .{
1949 .src = ir_decl.src(),1939 .src = ir_decl.src(),
1950 .tag = Inst.CompileError.base_tag,1940 .tag = .compileerror,
1951 },1941 },
1952 .positionals = .{1942 .positionals = .{
1953 .msg = blk: {1943 .operand = blk: {
1954 const msg_str = try self.arena.allocator.dupe(u8, err_msg_list.items[0].msg);1944 const msg_str = try self.arena.allocator.dupe(u8, err_msg_list.items[0].msg);
19551945
1956 const str_inst = try self.arena.allocator.create(Inst.Str);1946 const str_inst = try self.arena.allocator.create(Inst.Str);
...@@ -2088,14 +2078,14 @@ const EmitZIR = struct {...@@ -2088,14 +2078,14 @@ const EmitZIR = struct {
2088 },2078 },
2089 .sema_failure => {2079 .sema_failure => {
2090 const err_msg = self.old_module.failed_decls.get(module_fn.owner_decl).?.items[0];2080 const err_msg = self.old_module.failed_decls.get(module_fn.owner_decl).?.items[0];
2091 const fail_inst = try self.arena.allocator.create(Inst.CompileError);2081 const fail_inst = try self.arena.allocator.create(Inst.UnOp);
2092 fail_inst.* = .{2082 fail_inst.* = .{
2093 .base = .{2083 .base = .{
2094 .src = src,2084 .src = src,
2095 .tag = Inst.CompileError.base_tag,2085 .tag = .compileerror,
2096 },2086 },
2097 .positionals = .{2087 .positionals = .{
2098 .msg = blk: {2088 .operand = blk: {
2099 const msg_str = try self.arena.allocator.dupe(u8, err_msg.msg);2089 const msg_str = try self.arena.allocator.dupe(u8, err_msg.msg);
21002090
2101 const str_inst = try self.arena.allocator.create(Inst.Str);2091 const str_inst = try self.arena.allocator.create(Inst.Str);
...@@ -2117,14 +2107,14 @@ const EmitZIR = struct {...@@ -2117,14 +2107,14 @@ const EmitZIR = struct {
2117 try instructions.append(&fail_inst.base);2107 try instructions.append(&fail_inst.base);
2118 },2108 },
2119 .dependency_failure => {2109 .dependency_failure => {
2120 const fail_inst = try self.arena.allocator.create(Inst.CompileError);2110 const fail_inst = try self.arena.allocator.create(Inst.UnOp);
2121 fail_inst.* = .{2111 fail_inst.* = .{
2122 .base = .{2112 .base = .{
2123 .src = src,2113 .src = src,
2124 .tag = Inst.CompileError.base_tag,2114 .tag = .compileerror,
2125 },2115 },
2126 .positionals = .{2116 .positionals = .{
2127 .msg = blk: {2117 .operand = blk: {
2128 const msg_str = try self.arena.allocator.dupe(u8, "depends on another failed Decl");2118 const msg_str = try self.arena.allocator.dupe(u8, "depends on another failed Decl");
21292119
2130 const str_inst = try self.arena.allocator.create(Inst.Str);2120 const str_inst = try self.arena.allocator.create(Inst.Str);
src/zir_sema.zig+2-2
...@@ -486,8 +486,8 @@ fn analyzeInstExport(mod: *Module, scope: *Scope, export_inst: *zir.Inst.Export)...@@ -486,8 +486,8 @@ fn analyzeInstExport(mod: *Module, scope: *Scope, export_inst: *zir.Inst.Export)
486 return mod.constVoid(scope, export_inst.base.src);486 return mod.constVoid(scope, export_inst.base.src);
487}487}
488488
489fn analyzeInstCompileError(mod: *Module, scope: *Scope, inst: *zir.Inst.CompileError) InnerError!*Inst {489fn analyzeInstCompileError(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst {
490 const msg = try resolveConstString(mod, scope, inst.positionals.msg);490 const msg = try resolveConstString(mod, scope, inst.positionals.operand);
491 return mod.fail(scope, inst.base.src, "{}", .{msg});491 return mod.fail(scope, inst.base.src, "{}", .{msg});
492}492}
493493