mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 20:12:21 +02:00
Added support for C-style vararg methods
This commit is contained in:
parent
89e6b0d577
commit
7741344fd2
16 changed files with 129 additions and 68 deletions
|
@ -597,7 +597,7 @@ BfMethodDef* BfDefBuilder::CreateMethodDef(BfMethodDeclaration* methodDeclaratio
|
|||
bool didDefaultsError = false;
|
||||
bool hadParams = false;
|
||||
bool hasDefault = false;
|
||||
for (int paramIdx = 0; paramIdx < (int) methodDeclaration->mParams.size(); paramIdx++)
|
||||
for (int paramIdx = 0; paramIdx < (int)methodDeclaration->mParams.size(); paramIdx++)
|
||||
{
|
||||
BfParameterDeclaration* paramDecl = methodDeclaration->mParams[paramIdx];
|
||||
|
||||
|
@ -612,6 +612,17 @@ BfMethodDef* BfDefBuilder::CreateMethodDef(BfMethodDeclaration* methodDeclaratio
|
|||
else //
|
||||
paramDef->mParamKind = BfParamKind_Params;
|
||||
|
||||
if (auto dotTypeRef = BfNodeDynCast<BfDotTypeReference>(paramDef->mTypeRef))
|
||||
{
|
||||
if (dotTypeRef->mDotToken->mToken == BfToken_DotDotDot)
|
||||
{
|
||||
if (paramIdx == (int)methodDeclaration->mParams.size() - 1)
|
||||
paramDef->mParamKind = BfParamKind_VarArgs;
|
||||
else
|
||||
Fail("Varargs specifier must be the last parameter", methodDef->mParams[paramIdx - 1]->mParamDeclaration);
|
||||
}
|
||||
}
|
||||
|
||||
if (paramDef->mParamDeclaration != NULL)
|
||||
{
|
||||
if (paramDef->mParamKind == BfParamKind_Params)
|
||||
|
@ -622,7 +633,7 @@ BfMethodDef* BfDefBuilder::CreateMethodDef(BfMethodDeclaration* methodDeclaratio
|
|||
{
|
||||
methodDef->mParams[paramIdx - 1]->mParamKind = BfParamKind_Normal;
|
||||
hadParams = false;
|
||||
Fail("Params parameter must be the last parameter", methodDef->mParams[paramIdx - 1]->mParamDeclaration);
|
||||
Fail("Params parameter must be the last parameter", methodDef->mParams[paramIdx - 1]->mParamDeclaration);
|
||||
}
|
||||
|
||||
if (paramDef->mParamDeclaration->mInitializer != NULL)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue