From 967b315be5e9aa274ea4111953d0f7a213db8a04 Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Fri, 23 Aug 2024 17:53:58 +0200 Subject: [PATCH] Add qualified constructor invocation --- oscar64/Parser.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/oscar64/Parser.cpp b/oscar64/Parser.cpp index 2ebfd6c..ec507d5 100644 --- a/oscar64/Parser.cpp +++ b/oscar64/Parser.cpp @@ -5014,6 +5014,9 @@ Declaration* Parser::ParseQualIdent(void) { Declaration* ndec = dec->mScope->Lookup(mScanner->mTokenIdent, SLEVEL_USING); + if (!ndec && dec->mType == DT_TYPE_STRUCT && dec->mIdent == mScanner->mTokenIdent) + ndec = dec->mScope->Lookup(mScanner->mTokenIdent->PreMangle("+")); + if (ndec) dec = ndec; else @@ -5821,7 +5824,13 @@ Expression* Parser::ParseSimpleExpression(bool lhs, bool tid) { Expression* nexp = new Expression(mScanner->mLocation, EX_TYPECAST); nexp->mDecType = exp->mDecType; - nexp->mLeft = ParsePrefixExpression(false); + if (ConsumeTokenIf(TK_OPEN_PARENTHESIS)) + { + nexp->mLeft = ParseListExpression(false); + ConsumeToken(TK_CLOSE_PARENTHESIS); + } + else + nexp->mLeft = ParsePrefixExpression(false); nexp = CheckOperatorOverload(nexp); exp = nexp->ConstantFold(mErrors, mDataSection); } @@ -6685,6 +6694,14 @@ Expression* Parser::ParsePostfixExpression(bool lhs) } else if (mScanner->mToken == TK_OPEN_PARENTHESIS) { + // Explicit constructor invocation + if (exp->mType == EX_CONSTANT && exp->mDecValue->mType == DT_CONST_FUNCTION && exp->mDecValue->mIdent && exp->mDecValue->mIdent->mString[0] == '+') + { + exp->mType = EX_TYPE; + exp->mDecType = exp->mDecType->mParams->mBase->mBase; + exp->mDecValue = nullptr; + } + if (exp->mType == EX_TYPE) { Expression * pexp = nullptr;