diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-17 10:32:30 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-17 10:32:30 +0000 |
| commit | 377a1fd2eadd2a70cd27f13e2fee6e96c8706a51 (patch) | |
| tree | c05665f26b3434359cf4ae7720e8f9111a322522 /include/cps/FunctionGen.h | |
| parent | f5246db6d045ffb86d6717e1b1c37f03bcb2b75b (diff) | |
feat(codegen): overload global functions and procedures
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'include/cps/FunctionGen.h')
| -rw-r--r-- | include/cps/FunctionGen.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/include/cps/FunctionGen.h b/include/cps/FunctionGen.h index eb4a839..c168e1c 100644 --- a/include/cps/FunctionGen.h +++ b/include/cps/FunctionGen.h @@ -36,6 +36,10 @@ struct ParamSig { // back from LLVM types. struct FuncSig { std::string Name; + std::string LinkName; + std::string ParamKey; + bool IsOverload = false; + const PrototypeAST *Prototype = nullptr; std::string ReturnTypeName; std::vector<ParamSig> Params; size_t OwnerUnit = 0; @@ -63,7 +67,10 @@ private: int &DiagnosticLine; void reportError(const char *Fmt, ...); - IdentifierMap<FuncSig> Signatures; + IdentifierMap<std::vector<FuncSig>> Signatures; + IdentifierMap<std::pair<std::string, size_t>> LinkIndex; + std::map<const PrototypeAST *, std::string> PrototypeLinks; + std::map<size_t, std::string> UnitPaths; size_t CurrentUnit = 0; std::function<bool(size_t)> Visible; ArrayParamBinder BindArrayParam; @@ -89,9 +96,11 @@ public: RegisterCopy = std::move(Registrar); } - void setCurrentUnit(size_t Unit) { CurrentUnit = Unit; } + void setCurrentUnit(size_t Unit, const std::string &Path) { CurrentUnit = Unit; UnitPaths[Unit] = Path; } void setVisibility(std::function<bool(size_t)> Predicate) { Visible = std::move(Predicate); } - const FuncSig *getSignature(const std::string &Name) const; + std::vector<const FuncSig *> getOverloads(const std::string &Name) const; + bool hasFunction(const std::string &Name) const { return !getOverloads(Name).empty(); } + const FuncSig *getSignatureByLink(const std::string &Name) const; llvm::Function *emitPrototype(PrototypeAST *Proto); |
