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:
@@ -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 "";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user