From 39661855c0816ac248be437704c76f58359cb5f0 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Sat, 17 Oct 2026 06:52:23 +0000 Subject: feat(classes): construct declared objects and nested fields and arrays Co-Authored-By: Claude Opus 5.5 --- lib/CodeGen/Designator.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'lib/CodeGen/Designator.cc') diff --git a/lib/CodeGen/Designator.cc b/lib/CodeGen/Designator.cc index 13eb25f..1ebd158 100644 --- a/lib/CodeGen/Designator.cc +++ b/lib/CodeGen/Designator.cc @@ -78,18 +78,25 @@ Value *CodeGen::emitMemberCall(MemberCallExprAST *Call) { SaveAndRestore Location(DiagnosticLine, Call->getLine()); LValueInfo Receiver; if (!emitLValue(Call->getReceiver(), Receiver)) return nullptr; - const PrototypeAST *Method = findMethod(Receiver.TypeName, Call->getMethod()); + return emitMethodCall(Receiver.TypeName, Receiver.Addr, Call->getMethod(), + Call->getArgs(), Call->getLine()); +} + +Value *CodeGen::emitMethodCall(const std::string &Class, Value *Receiver, + const std::string &Name, + const std::vector> &ArgExprs, int Line) { + SaveAndRestore Location(DiagnosticLine, Line); + const PrototypeAST *Method = findMethod(Class, Name); if (!Method) { - reportError("Type %s has no method %s", Receiver.TypeName.c_str(), Call->getMethod().c_str()); + reportError("Type %s has no method %s", Class.c_str(), Name.c_str()); return nullptr; } - if (!Method->isPublic() && !sameIdentifier(CurrentClass, Receiver.TypeName)) { - reportError("Cannot access private method %s of type %s", - Call->getMethod().c_str(), Receiver.TypeName.c_str()); + if (!Method->isPublic() && !sameIdentifier(CurrentClass, Class)) { + reportError("Cannot access private method %s of type %s", Name.c_str(), Class.c_str()); return nullptr; } - std::vector Args = {Receiver.Addr}; - if (!marshalCallArgs(Method->getLinkName(), Call->getArgs(), Call->getLine(), Args)) return nullptr; + std::vector Args = {Receiver}; + if (!marshalCallArgs(Method->getLinkName(), ArgExprs, Line, Args)) return nullptr; return FuncGen->emitCall(Method->getLinkName(), Args); } -- cgit v1.3.1-4-g156e