Commit af80240678

g-w1 <jacoblevgw@gmail.com>
2020-12-26 18:01:14
make compileError use an UnOp since its operand is just a *Inst
1 parent d6e9862
Changed files (2)
src/zir.zig
@@ -300,6 +300,7 @@ pub const Inst = struct {
                 => NoOp,
 
                 .boolnot,
+                .compileerror,
                 .deref,
                 .@"return",
                 .isnull,
@@ -387,7 +388,6 @@ pub const Inst = struct {
                 .declval => DeclVal,
                 .declval_in_module => DeclValInModule,
                 .coerce_result_block_ptr => CoerceResultBlockPtr,
-                .compileerror => CompileError,
                 .compilelog => CompileLog,
                 .loop => Loop,
                 .@"const" => Const,
@@ -701,16 +701,6 @@ pub const Inst = struct {
         kw_args: struct {},
     };
 
-    pub const CompileError = struct {
-        pub const base_tag = Tag.compileerror;
-        base: Inst,
-
-        positionals: struct {
-            msg: *Inst,
-        },
-        kw_args: struct {},
-    };
-
     pub const CompileLog = struct {
         pub const base_tag = Tag.compilelog;
         base: Inst,
@@ -1943,14 +1933,14 @@ const EmitZIR = struct {
                 .sema_failure_retryable,
                 .dependency_failure,
                 => if (self.old_module.failed_decls.get(ir_decl)) |err_msg_list| {
-                    const fail_inst = try self.arena.allocator.create(Inst.CompileError);
+                    const fail_inst = try self.arena.allocator.create(Inst.UnOp);
                     fail_inst.* = .{
                         .base = .{
                             .src = ir_decl.src(),
-                            .tag = Inst.CompileError.base_tag,
+                            .tag = .compileerror,
                         },
                         .positionals = .{
-                            .msg = blk: {
+                            .operand = 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);
@@ -2088,14 +2078,14 @@ const EmitZIR = struct {
             },
             .sema_failure => {
                 const err_msg = self.old_module.failed_decls.get(module_fn.owner_decl).?.items[0];
-                const fail_inst = try self.arena.allocator.create(Inst.CompileError);
+                const fail_inst = try self.arena.allocator.create(Inst.UnOp);
                 fail_inst.* = .{
                     .base = .{
                         .src = src,
-                        .tag = Inst.CompileError.base_tag,
+                        .tag = .compileerror,
                     },
                     .positionals = .{
-                        .msg = blk: {
+                        .operand = blk: {
                             const msg_str = try self.arena.allocator.dupe(u8, err_msg.msg);
 
                             const str_inst = try self.arena.allocator.create(Inst.Str);
@@ -2117,14 +2107,14 @@ const EmitZIR = struct {
                 try instructions.append(&fail_inst.base);
             },
             .dependency_failure => {
-                const fail_inst = try self.arena.allocator.create(Inst.CompileError);
+                const fail_inst = try self.arena.allocator.create(Inst.UnOp);
                 fail_inst.* = .{
                     .base = .{
                         .src = src,
-                        .tag = Inst.CompileError.base_tag,
+                        .tag = .compileerror,
                     },
                     .positionals = .{
-                        .msg = blk: {
+                        .operand = 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);
src/zir_sema.zig
@@ -486,8 +486,8 @@ fn analyzeInstExport(mod: *Module, scope: *Scope, export_inst: *zir.Inst.Export)
     return mod.constVoid(scope, export_inst.base.src);
 }
 
-fn analyzeInstCompileError(mod: *Module, scope: *Scope, inst: *zir.Inst.CompileError) InnerError!*Inst {
-    const msg = try resolveConstString(mod, scope, inst.positionals.msg);
+fn analyzeInstCompileError(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst {
+    const msg = try resolveConstString(mod, scope, inst.positionals.operand);
     return mod.fail(scope, inst.base.src, "{}", .{msg});
 }