diff options
| author | Nic Gaffney <gaffney_nic@protonmail.com> | 2025-02-18 16:44:48 -0600 |
|---|---|---|
| committer | Nic Gaffney <gaffney_nic@protonmail.com> | 2025-02-18 16:44:48 -0600 |
| commit | 8f2595c71bce8d2f14de334d6e1b6378cc9f7cbf (patch) | |
| tree | 6d6ca8b19c42d26bc965ac851eac643d3f1e4e5e /src/symtable.zig | |
| parent | c77c9a42cd048a9f68aedf4fed5bfa8a2a4051d6 (diff) | |
| download | calico-8f2595c71bce8d2f14de334d6e1b6378cc9f7cbf.tar.gz | |
Pre-repair
Diffstat (limited to 'src/symtable.zig')
| -rw-r--r-- | src/symtable.zig | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/symtable.zig b/src/symtable.zig index 60e871c..8a5bd8a 100644 --- a/src/symtable.zig +++ b/src/symtable.zig @@ -80,6 +80,7 @@ pub const SymbolTable = struct { const scope = try self.allocator.create(Scope); scope.par = self.scope; scope.symbs = std.StringHashMap(Symbol).init(self.allocator); + // scope.symbs = self.scope.?.symbs; const stable: *SymbolTable = try self.allocator.create(SymbolTable); stable.* = .{ .scope = scope, @@ -88,7 +89,7 @@ pub const SymbolTable = struct { return stable; } - pub fn parent(self: SymbolTable) ?*SymbolTable { + pub fn parent(self: SymbolTable) ?*Scope { if (self.scope) |scope| if (scope.par) |par| return par; @@ -101,6 +102,7 @@ pub const SymbolTable = struct { } pub fn get(self: SymbolTable, ident: []const u8) ?Symbol { + if (!self.contains(ident)) if (self.parent()) |par| return par.symbs.get(ident); if (self.scope) |scope| return scope.symbs.get(ident); return null; } @@ -174,6 +176,7 @@ pub const Populator = struct { if (value.expr.typ) |typ| typ else pars.TypeIdent{ .ident = "i32", .list = false }, false, ); + std.debug.print("Value: {s}\nSymbol: {any}\n", .{ value.ident.ident, symbol }); if (!try table.insert(value.ident.ident, symbol)) return error.FailedToInsert; }, .block => { @@ -245,6 +248,7 @@ pub const Populator = struct { }; return value.toSymb(); } + std.debug.print("Unknown Type: {s}\n", .{typ.ident}); return error.UnknownType; } }; |
