selfhost: add @[Drop] attribute for user-defined structs

- ast.bux: add isDrop field to Decl
- parser.bux: parse @[Drop] attribute and attach to struct Decls
- hir_lower.bux: auto-drop now looks for TypeName_Drop for any type
- Test: _test_drop_user verifies Buffer_Drop is auto-called
This commit is contained in:
2026-06-10 13:32:40 +03:00
parent d6f0a30948
commit 0a41ce85f4
3 changed files with 17 additions and 2 deletions
+6
View File
@@ -2164,6 +2164,12 @@ func Lcx_BuildAutoDropFree(ctx: *LowerCtx, typeName: String) -> String {
return String_Concat(String_Concat("Map_Drop_", kType), String_Concat("_", vType));
}
}
// User-defined types with @[Drop]: look for TypeName_Drop function
let dropName: String = String_Concat(typeName, "_Drop");
let dropSym: Symbol = Scope_Lookup(ctx.scope, dropName);
if dropSym.decl != null as *Decl {
return dropName;
}
return "";
}