diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-21 06:14:00 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-21 06:14:00 +0000 |
| commit | db8c7f14d2f74c3db205782acf8222cb7d91a047 (patch) | |
| tree | 31b6e17c0cb818ba0cc700cd1e0ca896a6b9156f /include/cps/CodeGen.h | |
| parent | 25ae363250e479701ed532c55c255e043c8240da (diff) | |
feat(codegen): instantiate class templates
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'include/cps/CodeGen.h')
| -rw-r--r-- | include/cps/CodeGen.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/cps/CodeGen.h b/include/cps/CodeGen.h index 23487f6..4730585 100644 --- a/include/cps/CodeGen.h +++ b/include/cps/CodeGen.h @@ -26,6 +26,7 @@ class ExceptionHandler; class CastExprAST; class NewExprAST; class TemplateDeclAST; +class ClassTypeDeclAST; class CodeGen { std::unique_ptr<llvm::LLVMContext> TheContext; @@ -43,6 +44,7 @@ class CodeGen { TemplateDeclAST *Decl; std::string Arguments; std::unique_ptr<FunctionDefAST> Function; + std::unique_ptr<ClassTypeDeclAST> Class; const FuncSig *Signature; size_t OwnerUnit; size_t RequesterUnit; @@ -52,6 +54,10 @@ class CodeGen { std::map<const TemplateDeclAST *, IdentifierMap<SymbolInfo>> TemplateSymbols; size_t NextTemplateBody = 0; unsigned TemplateDepth = 0; + bool TypePrePass = false; + bool SpeculativeTemplateResolution = false; + IdentifierSet FailedTemplateTypes; + std::vector<size_t> DeferredClassPrototypes; bool hasCallable(const std::string &Name) const; bool hasFunctionTemplate(const std::string &Name) const; void validateTemplates(); @@ -59,6 +65,10 @@ class CodeGen { const FuncSig *instantiateFunction(const TemplateDefinition &Definition, const IdentifierMap<std::vector<std::string>> &Bindings); void drainTemplateBodies(); + const TypeInfo *instantiateClass(const std::string &Name); + std::optional<std::string> canonicalTemplateArgument(const std::string &Name); + void emitClassPrototypes(ClassTypeDeclAST *Class); + void emitDeferredClassPrototypes(); std::vector<IdentifierMap<SymbolInfo>> Exports; bool isVisible(size_t Owner) const; void selectUnit(size_t Unit); @@ -170,6 +180,7 @@ class CodeGen { // TYPE-system registration (Designator.cc) and operators (TypeCheckGen.cc). void runTypePrePass(const std::vector<std::unique_ptr<StmtAST>> &Statements, int Phase); + void registerClassMethods(ClassTypeDeclAST *Class); llvm::Value *emitUserKindBinaryOp(int Op, llvm::Value *L, const TypeInfo *LT, llvm::Value *R, const TypeInfo *RT, int Line); |
