diff --git a/src/compiler.zig b/src/compiler.zig index ac6030a..cd8eb85 100644 --- a/src/compiler.zig +++ b/src/compiler.zig @@ -113,6 +113,11 @@ var rules = []ParseRule{ ParseRule{}, }; +pub const Local = struct { + name: tokens.Token, + depth: i32, +}; + pub const Compiler = struct { src: []const u8, stdout: vm.StdOut, @@ -123,6 +128,10 @@ pub const Compiler = struct { debug_flag: bool = false, vmach: *vm.VM, + locals: [256]Local, + localCount: u8 = 0, + scopeDepth: u8 = 0, + pub fn init( allocator: *Allocator, chunk: *chunks.Chunk, @@ -139,6 +148,12 @@ pub const Compiler = struct { .parser = Parser{}, .debug_flag = debug_flag, .vmach = vmach, + + // local variable resolution + .locals = []Local{Local{ + .name = Token{}, + .depth = -1, + }} ** 256, }; }