aboutsummaryrefslogtreecommitdiff
path: root/src/astgen.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/astgen.zig
parent939bd52c8a389993ab168ec9bb88c4e395045ac7 (diff)
downloadzig-1634d45f1d53c8d7bfefa56ab4d2fa4cc8218b6d.tar.gz
zig-1634d45f1d53c8d7bfefa56ab4d2fa4cc8218b6d.zip
stage2: add compile log statement (#7191)
Diffstat (limited to 'src/astgen.zig')
-rw-r--r--src/astgen.zig13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/astgen.zig b/src/astgen.zig
index 622a18c443..ed5281ba42 100644
--- a/src/astgen.zig
+++ b/src/astgen.zig
@@ -2248,6 +2248,17 @@ fn import(mod: *Module, scope: *Scope, call: *ast.Node.BuiltinCall) InnerError!*
return addZIRUnOp(mod, scope, src, .import, target);
}
+fn compileLog(mod: *Module, scope: *Scope, call: *ast.Node.BuiltinCall) InnerError!*zir.Inst {
+ const tree = scope.tree();
+ const arena = scope.arena();
+ const src = tree.token_locs[call.builtin_token].start;
+ const params = call.params();
+ var targets = try arena.alloc(*zir.Inst, params.len);
+ for (params) |param, param_i|
+ targets[param_i] = try expr(mod, scope, .none, param);
+ return addZIRInst(mod, scope, src, zir.Inst.CompileLog, .{ .to_log = targets }, .{});
+}
+
fn typeOf(mod: *Module, scope: *Scope, rl: ResultLoc, call: *ast.Node.BuiltinCall) InnerError!*zir.Inst {
const tree = scope.tree();
const arena = scope.arena();
@@ -2291,6 +2302,8 @@ fn builtinCall(mod: *Module, scope: *Scope, rl: ResultLoc, call: *ast.Node.Built
return rlWrap(mod, scope, rl, try addZIRNoOp(mod, scope, src, .breakpoint));
} else if (mem.eql(u8, builtin_name, "@import")) {
return rlWrap(mod, scope, rl, try import(mod, scope, call));
+ } else if (mem.eql(u8, builtin_name, "@compileLog")) {
+ return compileLog(mod, scope, call);
} else {
return mod.failTok(scope, call.builtin_token, "invalid builtin function: '{}'", .{builtin_name});
}