aboutsummaryrefslogtreecommitdiff
path: root/src/zir.zig
diff options
context:
space:
mode:
authorg-w1 <58830309+g-w1@users.noreply.github.com>2020-12-25 19:40:49 -0500
committerGitHub <noreply@github.com>2020-12-26 02:40:49 +0200
commit1634d45f1d53c8d7bfefa56ab4d2fa4cc8218b6d (patch)
tree85ec2c108a227da13542385d601364d7394e853b /src/zir.zig
parent939bd52c8a389993ab168ec9bb88c4e395045ac7 (diff)
downloadzig-1634d45f1d53c8d7bfefa56ab4d2fa4cc8218b6d.tar.gz
zig-1634d45f1d53c8d7bfefa56ab4d2fa4cc8218b6d.zip
stage2: add compile log statement (#7191)
Diffstat (limited to 'src/zir.zig')
-rw-r--r--src/zir.zig23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/zir.zig b/src/zir.zig
index f4f52cbc0f..982c98ddc9 100644
--- a/src/zir.zig
+++ b/src/zir.zig
@@ -122,6 +122,8 @@ pub const Inst = struct {
coerce_to_ptr_elem,
/// Emit an error message and fail compilation.
compileerror,
+ /// Log compile time variables and emit an error message.
+ compilelog,
/// Conditional branch. Splits control flow based on a boolean condition value.
condbr,
/// Special case, has no textual representation.
@@ -386,6 +388,7 @@ pub const Inst = struct {
.declval_in_module => DeclValInModule,
.coerce_result_block_ptr => CoerceResultBlockPtr,
.compileerror => CompileError,
+ .compilelog => CompileLog,
.loop => Loop,
.@"const" => Const,
.str => Str,
@@ -513,6 +516,7 @@ pub const Inst = struct {
.slice_start,
.import,
.switch_range,
+ .compilelog,
.typeof_peer,
=> false,
@@ -707,6 +711,19 @@ pub const Inst = struct {
kw_args: struct {},
};
+ pub const CompileLog = struct {
+ pub const base_tag = Tag.compilelog;
+ base: Inst,
+
+ positionals: struct {
+ to_log: []*Inst,
+ },
+ kw_args: struct {
+ /// If we have seen it already so don't make another error
+ seen: bool = false,
+ },
+ };
+
pub const Const = struct {
pub const base_tag = Tag.@"const";
base: Inst,
@@ -1925,7 +1942,7 @@ const EmitZIR = struct {
.sema_failure,
.sema_failure_retryable,
.dependency_failure,
- => if (self.old_module.failed_decls.get(ir_decl)) |err_msg| {
+ => if (self.old_module.failed_decls.get(ir_decl)) |err_msg_list| {
const fail_inst = try self.arena.allocator.create(Inst.CompileError);
fail_inst.* = .{
.base = .{
@@ -1933,7 +1950,7 @@ const EmitZIR = struct {
.tag = Inst.CompileError.base_tag,
},
.positionals = .{
- .msg = try self.arena.allocator.dupe(u8, err_msg.msg),
+ .msg = try self.arena.allocator.dupe(u8, err_msg_list.items[0].msg),
},
.kw_args = .{},
};
@@ -2055,7 +2072,7 @@ const EmitZIR = struct {
try self.emitBody(body, &inst_table, &instructions);
},
.sema_failure => {
- const err_msg = self.old_module.failed_decls.get(module_fn.owner_decl).?;
+ 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);
fail_inst.* = .{
.base = .{