1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Added support for C-style vararg methods

This commit is contained in:
Brian Fiete 2020-02-11 07:34:47 -08:00
parent 89e6b0d577
commit 7741344fd2
16 changed files with 129 additions and 68 deletions

View file

@ -202,7 +202,7 @@ class BeFunctionType : public BeType
public:
String mName;
BeType* mReturnType;
std::vector<BeFunctionTypeParam> mParams;
Array<BeFunctionTypeParam> mParams;
bool mIsVarArg;
virtual void HashContent(BeHashContext& hashCtx) override

View file

@ -1935,7 +1935,7 @@ void BeIRCodeGen::HandleNextCmd()
}
break;
case BfIRCmd_CreateFunctionType:
{
{
CMD_PARAM(BeType*, resultType);
CMD_PARAM(CmdParamVec<BeType*>, paramTypes);
CMD_PARAM(bool, isVarArg);

View file

@ -1960,6 +1960,14 @@ String BeModule::ToString(BeFunction* wantFunc)
dc.mSeenNames[param.mName] = 0;
str += "%" + param.mName;
}
if (funcType->mIsVarArg)
{
if (!funcType->mParams.IsEmpty())
str += ", ";
str += "...";
}
str += ")";
if (func->mAlwaysInline)
@ -2917,6 +2925,14 @@ void BeModule::ToString(StringImpl& str, BeType* type)
str += ", ";
ToString(str, funcType->mParams[paramIdx].mType);
}
if (funcType->mIsVarArg)
{
if (!funcType->mParams.IsEmpty())
str += ", ";
str += "...";
}
str += ")";
return;
}