commit fb96795852df56d9489e898e44dcb7e5fea98760
parent 1b9f1f054fb615d258beaaf0d971380e1d29b0c3
Author: Thomas Vigouroux <thomas.vigouroux@univ-grenoble-alpes.fr>
Date: Fri, 14 Jun 2024 13:42:27 +0200
feat(compile): track enclosing compiler
Diffstat:
1 file changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/compile.zig b/src/compile.zig
@@ -24,6 +24,8 @@ pub const Compiler = struct {
sym_map: std.StringHashMap(Storage),
scope_depth: u32,
+ enclosing: ?*const Compiler = null,
+
pub fn init(all: std.mem.Allocator, val: *v.Value) !Self {
return Self{
.all = all,
@@ -355,6 +357,7 @@ pub const Compiler = struct {
var inner = try Compiler.init(self.all, lst[3]);
defer inner.deinit();
+ inner.enclosing = self;
inner.func.name = lst[1].val.symbol;
inner.func.arity = @intCast(arity);