diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-24 18:01:36 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-24 18:01:36 +0000 |
| commit | 0900667401415a0914b8a1510543c7c7eaf32e53 (patch) | |
| tree | e61c43059f880878bc59259e82c5ab6665b20dbd /lib/CodeGen/Designator.cc | |
| parent | 034ab48c5f30b0e6f402766b4c1bcf36661e16cd (diff) | |
feat(overload): select overloads by return type as well as parameters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib/CodeGen/Designator.cc')
| -rw-r--r-- | lib/CodeGen/Designator.cc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/CodeGen/Designator.cc b/lib/CodeGen/Designator.cc index 6737937..d790d27 100644 --- a/lib/CodeGen/Designator.cc +++ b/lib/CodeGen/Designator.cc @@ -96,16 +96,17 @@ bool CodeGen::isRegisteredMethod(const std::string &Class, const PrototypeAST *M } const FuncSig *CodeGen::resolveMethod(const std::string &Class, const std::string &Name, - const std::vector<std::unique_ptr<ExprAST>> &Args) { + const std::vector<std::unique_ptr<ExprAST>> &Args, + const ResultContext *Context) { const auto *Methods = findMethod(Class, Name); if (!Methods) { reportError("Type %s has no method %s", Class.c_str(), Name.c_str()); return nullptr; } - return resolveCall(Methods->front()->getProto()->getLinkName(), Args); + return resolveCall(Methods->front()->getProto()->getLinkName(), Args, nullptr, Context); } -Value *CodeGen::emitMemberCall(MemberCallExprAST *Call) { +Value *CodeGen::emitMemberCall(MemberCallExprAST *Call, const ResultContext *Context) { SaveAndRestore<int> Location(DiagnosticLine, Call->getLine()); LValueInfo Receiver; if (isObjectLValue(Call->getReceiver())) { @@ -120,14 +121,15 @@ Value *CodeGen::emitMemberCall(MemberCallExprAST *Call) { if (!Receiver.Addr) return nullptr; } return emitMethodCall(Receiver.TypeName, Receiver.Addr, Call->getMethod(), - Call->getArgs(), Call->getLine()); + Call->getArgs(), Call->getLine(), Context); } Value *CodeGen::emitMethodCall(const std::string &Class, Value *Receiver, const std::string &Name, - const std::vector<std::unique_ptr<ExprAST>> &ArgExprs, int Line) { + const std::vector<std::unique_ptr<ExprAST>> &ArgExprs, int Line, + const ResultContext *Context) { SaveAndRestore<int> Location(DiagnosticLine, Line); - const FuncSig *Sig = resolveMethod(Class, Name, ArgExprs); + const FuncSig *Sig = resolveMethod(Class, Name, ArgExprs, Context); if (!Sig) return nullptr; const PrototypeAST *Method = Sig->Prototype; if (!Method->isPublic() && !sameIdentifier(CurrentClass, Class)) { |
