diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-21 05:43:35 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-21 05:43:35 +0000 |
| commit | dd5bbae055fd34ce2e12ef63f8a261c6b15dc83e (patch) | |
| tree | 757e367daacf92c50148eb42d7bda97ba33ed3fb /lib/CodeGen | |
| parent | c682f983b0dce3acba76d1f08719a26b9c52c5ec (diff) | |
feat(parser): parse TEMPLATE declarations, template ids and parameter packs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib/CodeGen')
| -rw-r--r-- | lib/CodeGen/CodeGen.cc | 7 | ||||
| -rw-r--r-- | lib/CodeGen/StatementGen.cc | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/CodeGen/CodeGen.cc b/lib/CodeGen/CodeGen.cc index 30b6131..641b424 100644 --- a/lib/CodeGen/CodeGen.cc +++ b/lib/CodeGen/CodeGen.cc @@ -6,6 +6,7 @@ #include "cps/ExceptionHandler.h" #include "Builtins.h" #include "cps/TypeAST.h" +#include "cps/TemplateAST.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Verifier.h" #include <cstdarg> @@ -209,7 +210,11 @@ void CodeGen::compile(const std::vector<SourceUnit> &Sources) { for (const auto &S : Sources[I].Statements) { SaveAndRestore<int> Location(DiagnosticLine, S->getLine()); std::string TypeName; - if (auto *F = dynamic_cast<FunctionDefAST*>(S.get())) { + if (auto *T = dynamic_cast<TemplateDeclAST*>(S.get())) { + auto *Function = T->getFunction(); + Reserve(T->getName(), Function != nullptr, Function && Function->getProto()->isOverload()); + Templates[T->getName()].push_back({T, I}); + } else if (auto *F = dynamic_cast<FunctionDefAST*>(S.get())) { Reserve(F->getProto()->getName(), true, F->getProto()->isOverload()); if (sameIdentifier(F->getProto()->getName(), "MAIN")) { if (Entry) reportError("Multiple MAIN definitions in %s and %s", diff --git a/lib/CodeGen/StatementGen.cc b/lib/CodeGen/StatementGen.cc index 5b60d29..6bc4ec4 100644 --- a/lib/CodeGen/StatementGen.cc +++ b/lib/CodeGen/StatementGen.cc @@ -5,6 +5,7 @@ #include "cps/MemoryHandler.h" #include "cps/ExceptionHandler.h" #include "cps/TypeAST.h" +#include "cps/TemplateAST.h" using namespace llvm; using namespace cps; @@ -18,6 +19,7 @@ void CodeGen::emitStmt(StmtAST *Stmt) { void CodeGen::emitStmtImpl(StmtAST *Stmt) { SaveAndRestore<int> Location(DiagnosticLine, Stmt && Stmt->getLine() ? Stmt->getLine() : DiagnosticLine); if (!Stmt) return; + if (dynamic_cast<TemplateDeclAST*>(Stmt)) return; if (dynamic_cast<IncludeStmtAST*>(Stmt)) return; if (dynamic_cast<GlobalBlockAST*>(Stmt)) return; |
