From b28384fed1ce638e8b00b72dba974e9fd7e55eb4 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Wed, 28 Oct 2026 13:36:16 +0000 Subject: feat(overload): support default return types Co-Authored-By: Claude Opus 5.5 --- include/cps/FunctionAST.h | 3 +++ include/cps/FunctionGen.h | 2 ++ include/cps/Lexer.h | 1 + 3 files changed, 6 insertions(+) (limited to 'include') diff --git a/include/cps/FunctionAST.h b/include/cps/FunctionAST.h index 9188015..5280d58 100644 --- a/include/cps/FunctionAST.h +++ b/include/cps/FunctionAST.h @@ -35,6 +35,7 @@ class PrototypeAST { std::string OwnerClass; bool IsPublic; bool IsVariadic = false; + bool IsDefaultReturn = false; int Operator = 0; public: @@ -49,6 +50,8 @@ public: const std::vector &getParams() const { return Params; } const std::string &getReturnType() const { return ReturnType; } bool isOverload() const { return IsOverload; } + bool isDefaultReturn() const { return IsDefaultReturn; } + void setDefaultReturn(bool V) { IsDefaultReturn = V; } int getOperator() const { return Operator; } void setOperator(int Op) { Operator = Op; } bool isExternal() const { return IsExternal; } diff --git a/include/cps/FunctionGen.h b/include/cps/FunctionGen.h index c3c530b..5e895fe 100644 --- a/include/cps/FunctionGen.h +++ b/include/cps/FunctionGen.h @@ -42,6 +42,7 @@ struct FuncSig { std::string ParamKey; std::string ReturnKey; bool IsOverload = false; + bool IsDefaultReturn = false; const PrototypeAST *Prototype = nullptr; std::string ReturnTypeName; std::vector Params; @@ -122,6 +123,7 @@ public: void setVisibility(std::function Predicate) { Visible = std::move(Predicate); } std::vector getOverloads(const std::string &Name, bool AllUnits = false) const; static bool isReservedRuntimeName(const std::string &Name); + static const FuncSig *selectDefaultReturn(const std::vector &Candidates); bool hasFunction(const std::string &Name) const { return !getOverloads(Name).empty(); } const FuncSig *getSignatureByLink(const std::string &Name) const; diff --git a/include/cps/Lexer.h b/include/cps/Lexer.h index 3d057a3..1268582 100644 --- a/include/cps/Lexer.h +++ b/include/cps/Lexer.h @@ -79,6 +79,7 @@ enum Token { tok_call = -406, tok_byref = -407, tok_byval = -408, + tok_default = -409, tok_openfile = -500, tok_readfile = -501, -- cgit v1.3.1-4-g156e