upgrade enum discriminants

This commit is contained in:
2026-07-17 20:32:12 +02:00
parent 866e28adb8
commit cedc63b28b
19 changed files with 3168 additions and 96 deletions
+19
View File
@@ -254,6 +254,19 @@ Global :: struct {
diagnostic: source.Diagnostic_Id,
}
Enum_Value :: struct {
expr: Expr_Id,
span: source.Span,
explicit: bool,
}
Enum_Declaration :: struct {
type: types.Type,
pkg: Package_Id,
file: File_Id,
values: []Enum_Value,
}
Import :: struct {
span: source.Span,
alias: symbol.Id,
@@ -326,6 +339,7 @@ Module :: struct {
statements: [dynamic]Stmt,
functions: [dynamic]Function,
globals: [dynamic]Global,
enum_declarations: [dynamic]Enum_Declaration,
imports: [dynamic]Import,
aliases: [dynamic]Declaration_Alias,
files: [dynamic]File,
@@ -347,6 +361,7 @@ init_module :: proc(allocator := context.allocator) -> Module {
module.statements.allocator = allocator
module.functions.allocator = allocator
module.globals.allocator = allocator
module.enum_declarations.allocator = allocator
module.imports.allocator = allocator
module.aliases.allocator = allocator
module.files.allocator = allocator
@@ -382,6 +397,9 @@ destroy_module :: proc(module: ^Module) {
for global in module.globals {
delete(global.link_name, module.allocator)
}
for declaration in module.enum_declarations {
delete(declaration.values, module.allocator)
}
for pkg in module.packages {
delete(pkg.path, module.allocator)
}
@@ -400,6 +418,7 @@ destroy_module :: proc(module: ^Module) {
delete(module.statements)
delete(module.functions)
delete(module.globals)
delete(module.enum_declarations)
delete(module.imports)
delete(module.aliases)
delete(module.files)