default struct fields

This commit is contained in:
2026-07-18 16:23:47 +02:00
parent e889a99e55
commit 9eb7476522
10 changed files with 191 additions and 11 deletions
+11
View File
@@ -304,6 +304,14 @@ Declaration_Alias :: struct {
diagnostic: source.Diagnostic_Id,
}
Struct_Field_Default :: struct {
record: Type_Syntax,
field: symbol.Id,
expr: Expr_Id,
pkg: Package_Id,
file: File_Id,
}
File :: struct {
source: source.Source_Id,
pkg: Package_Id,
@@ -357,6 +365,7 @@ Module :: struct {
c_trampolines: [dynamic]Trampoline,
strings: [dynamic]string,
type_fields: [dynamic]types.Field,
struct_field_defaults: [dynamic]Struct_Field_Default,
type_uses: [dynamic]Type_Use,
type_store: types.Store,
allocator: mem.Allocator,
@@ -379,6 +388,7 @@ init_module :: proc(allocator := context.allocator) -> Module {
module.c_trampolines.allocator = allocator
module.strings.allocator = allocator
module.type_fields.allocator = allocator
module.struct_field_defaults.allocator = allocator
module.type_uses.allocator = allocator
return module
}
@@ -436,6 +446,7 @@ destroy_module :: proc(module: ^Module) {
delete(module.c_trampolines)
delete(module.strings)
delete(module.type_fields)
delete(module.struct_field_defaults)
delete(module.type_uses)
types.destroy_store(&module.type_store)
}