diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-30 14:23:32 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-30 14:23:32 +0000 |
| commit | 4cb0d9b196008bc55dbfcdac1f9211dbbc879895 (patch) | |
| tree | 0d95a2682ef26455483c4bb9222e1dff0d5c8e69 /lib/CodeGen/FunctionGen.cc | |
| parent | 63109537383fa58c6a1db95f275d6b5de63b0015 (diff) | |
feat(types): support implicit single-argument constructors
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib/CodeGen/FunctionGen.cc')
| -rw-r--r-- | lib/CodeGen/FunctionGen.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/CodeGen/FunctionGen.cc b/lib/CodeGen/FunctionGen.cc index a0c520d..7aa5d46 100644 --- a/lib/CodeGen/FunctionGen.cc +++ b/lib/CodeGen/FunctionGen.cc @@ -130,6 +130,15 @@ const FuncSig *FunctionGen::selectDefaultReturn(const std::vector<const FuncSig // Copy-constructor, operator, MAIN and name-collision rules for a // FUNCTION/PROCEDURE prototype; reports the first violation. bool FunctionGen::validatePrototype(PrototypeAST *Proto) { + if (Proto->isImplicit()) { + const auto &P = Proto->getParams(); + if (Proto->getOwnerClass().empty() || !sameIdentifier(Proto->getName(), "NEW") || + !sameIdentifier(Proto->getReturnType(), "VOID") || P.size() != 1 || + P[0].Mode != PassMode::ByVal || P[0].IsArray || P[0].IsPack) { + reportError("IMPLICIT requires a CLASS constructor NEW with one BYVAL non-array parameter"); + return false; + } + } if (Proto->isDefaultReturn()) { const TypeInfo *Return = Types.resolve(Proto->getReturnType()); if (!Proto->isOverload() || (Return && Return->isVoid())) { @@ -213,6 +222,7 @@ Function *FunctionGen::emitPrototype(PrototypeAST *Proto) { Sig.OwnerUnit = CurrentUnit; Sig.Name = Proto->getLinkName(); Sig.IsOverload = Proto->isOverload(); + Sig.IsImplicit = Proto->isImplicit(); Sig.IsDefaultReturn = Proto->isDefaultReturn(); Sig.Prototype = Proto; Sig.ReturnTypeName = Proto->getReturnType(); |
