feat: trait 接口系统 — trait Show { fn method } + extend Trait Struct { }

This commit is contained in:
2026-06-06 16:41:21 +08:00
parent 9169796b77
commit b3b3d285f9
9 changed files with 126 additions and 12 deletions
+8
View File
@@ -274,3 +274,11 @@ AstNode* ast_make_use_decl(void* alloc, const char* path, const char* item, Sour
n->as.use_decl.item = item;
return n;
}
AstNode* ast_make_trait_decl(void* alloc, const char* name, AstNode** methods, size_t count, SourceLoc loc) {
NEW(alloc, AST_TRAIT_DECL);
n->as.trait_decl.name = name;
n->as.trait_decl.methods = methods;
n->as.trait_decl.method_count = count;
return n;
}