diff options
Diffstat (limited to 'src/symtable.zig')
| -rw-r--r-- | src/symtable.zig | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/symtable.zig b/src/symtable.zig index 72eecc7..f37ee12 100644 --- a/src/symtable.zig +++ b/src/symtable.zig @@ -159,8 +159,9 @@ pub const Populator = struct { switch (node.*) { .Stmt => |stmt| { const table: *SymbolTable = stmt.symtable; - try switch (stmt.kind) { + switch (stmt.kind) { .defVar => |variable| { + std.debug.print("Populated {s}\n", .{variable.ident.ident}); const symbol: Symbol = try self.buildValueSymb( table, if (variable.expr.typ) |typ| typ else pars.TypeIdent{ .ident = "i32", .list = false }, @@ -174,12 +175,17 @@ pub const Populator = struct { if (value.expr.typ) |typ| typ else pars.TypeIdent{ .ident = "i32", .list = false }, false, ); + std.debug.print("Populated {s}\n", .{value.ident.ident}); if (!try table.insert(value.ident.ident, symbol)) return error.FailedToInsert; }, .block => { const children = try stmt.children(self.allocator); defer self.allocator.free(children); - for (children) |child| try self.populateSymtable(&child); + std.debug.print("Populated Block\n", .{}); + for (children) |child| { + std.debug.print("Child: {d}\n", .{child.Stmt.id}); + try self.populateSymtable(&child); + } }, .function => |fun| { const symbol: Symbol = try self.buildFunctionSymb( @@ -187,12 +193,14 @@ pub const Populator = struct { fun.args, fun.retType, ); + std.debug.print("Populated Function {s}\n", .{fun.ident.ident}); if (!try table.insert(fun.ident.ident, symbol)) return error.FailedToInsert; + const children = try stmt.children(self.allocator); + for (children) |child| try self.populateSymtable(&child); }, - .exit => {}, - else => error.Unimplemented, - }; + else => {}, + } }, else => { for (try node.children(self.allocator)) |child| |
