This commit is contained in:
agra
2026-02-12 16:23:42 +02:00
parent 1087bd1977
commit dab162bfe4
13 changed files with 1190 additions and 775 deletions

View File

@@ -23,6 +23,8 @@ pub const Symbol = struct {
ty: ?Type,
def_span: Span,
scope_depth: u32,
/// null = defined in the current file. Non-null = absolute path of the origin file.
origin: ?[]const u8 = null,
};
pub const Reference = struct {
@@ -521,6 +523,11 @@ pub const Analyzer = struct {
});
}
/// Pre-register an imported symbol so references in this file can resolve to it.
pub fn preRegisterSymbol(self: *Analyzer, sym: Symbol) !void {
try self.symbols.append(self.allocator, sym);
}
fn resolveIdentifier(self: *Analyzer, name: []const u8, span: Span) !void {
// Search backwards to find the most recent declaration with this name
// that is at or above the current scope depth.