package-type imports

This commit is contained in:
2026-06-10 00:08:33 +02:00
parent 087fdb45d5
commit d6e03b6f08
104 changed files with 1799 additions and 273 deletions
+44
View File
@@ -26,6 +26,7 @@ Expr_Kind :: enum {
Expr :: struct {
kind: Expr_Kind,
span: source.Span,
qualifier: string,
text: string,
integer: i64,
left: int,
@@ -61,6 +62,8 @@ Stmt :: struct {
Function :: struct {
span: source.Span,
name: string,
pkg: int,
file: int,
c_abi: bool,
params: []Param,
result: Type_Syntax,
@@ -71,17 +74,45 @@ Function :: struct {
Global :: struct {
span: source.Span,
name: string,
pkg: int,
file: int,
type: Type_Syntax,
immutable: bool,
expr: int,
diagnostic: int,
}
Import :: struct {
span: source.Span,
alias: string,
path: string,
pkg: int,
file: int,
target: int,
valid: bool,
used: bool,
diagnostic: int,
}
File :: struct {
source: int,
pkg: int,
}
Package :: struct {
path: string,
name: string,
available: bool,
}
Module :: struct {
exprs: [dynamic]Expr,
statements: [dynamic]Stmt,
functions: [dynamic]Function,
globals: [dynamic]Global,
imports: [dynamic]Import,
files: [dynamic]File,
packages: [dynamic]Package,
allocator: mem.Allocator,
}
@@ -92,6 +123,9 @@ init_module :: proc(allocator := context.allocator) -> Module {
module.statements.allocator = allocator
module.functions.allocator = allocator
module.globals.allocator = allocator
module.imports.allocator = allocator
module.files.allocator = allocator
module.packages.allocator = allocator
return module
}
@@ -103,8 +137,18 @@ destroy_module :: proc(module: ^Module) {
delete(function.params, module.allocator)
delete(function.body, module.allocator)
}
for import_item in module.imports {
delete(import_item.path, module.allocator)
}
for pkg in module.packages {
delete(pkg.path, module.allocator)
delete(pkg.name, module.allocator)
}
delete(module.exprs)
delete(module.statements)
delete(module.functions)
delete(module.globals)
delete(module.imports)
delete(module.files)
delete(module.packages)
}