mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed append ctors in classes with emissions
This commit is contained in:
parent
f8f95e9de3
commit
86a80f4d18
1 changed files with 34 additions and 30 deletions
|
@ -2056,38 +2056,42 @@ void BfDefBuilder::FinishTypeDef(bool wantsToString)
|
||||||
{
|
{
|
||||||
mCurTypeDef->mHasAppendCtor = true;
|
mCurTypeDef->mHasAppendCtor = true;
|
||||||
|
|
||||||
auto methodDef = new BfMethodDef();
|
bool isHandled = !method->mParams.IsEmpty() && method->mParams[0]->mParamKind == BfParamKind_AppendIdx;
|
||||||
mCurTypeDef->mMethods.Insert(methodIdx + 1, methodDef);
|
if (!isHandled)
|
||||||
BF_ASSERT(mCurDeclaringTypeDef != NULL);
|
|
||||||
methodDef->mDeclaringType = mCurDeclaringTypeDef;
|
|
||||||
methodDef->mName = BF_METHODNAME_CALCAPPEND;
|
|
||||||
methodDef->mProtection = BfProtection_Public;
|
|
||||||
methodDef->mMethodType = BfMethodType_CtorCalcAppend;
|
|
||||||
methodDef->mIsMutating = method->mIsMutating;
|
|
||||||
methodDef->mIsNoSplat = true;
|
|
||||||
|
|
||||||
methodDef->mMethodDeclaration = method->mMethodDeclaration;
|
|
||||||
methodDef->mReturnTypeRef = mSystem->mDirectIntTypeRef;
|
|
||||||
methodDef->mIsStatic = true;
|
|
||||||
methodDef->mBody = method->mBody;
|
|
||||||
methodDef->mAddedAfterEmit = mIsComptime;
|
|
||||||
|
|
||||||
for (auto param : method->mParams)
|
|
||||||
{
|
{
|
||||||
BfParameterDef* newParam = new BfParameterDef();
|
auto methodDef = new BfMethodDef();
|
||||||
newParam->mName = param->mName;
|
mCurTypeDef->mMethods.Insert(methodIdx + 1, methodDef);
|
||||||
newParam->mNamePrefixCount = param->mNamePrefixCount;
|
BF_ASSERT(mCurDeclaringTypeDef != NULL);
|
||||||
newParam->mTypeRef = param->mTypeRef;
|
methodDef->mDeclaringType = mCurDeclaringTypeDef;
|
||||||
newParam->mMethodGenericParamIdx = param->mMethodGenericParamIdx;
|
methodDef->mName = BF_METHODNAME_CALCAPPEND;
|
||||||
methodDef->mParams.push_back(newParam);
|
methodDef->mProtection = BfProtection_Public;
|
||||||
}
|
methodDef->mMethodType = BfMethodType_CtorCalcAppend;
|
||||||
|
methodDef->mIsMutating = method->mIsMutating;
|
||||||
|
methodDef->mIsNoSplat = true;
|
||||||
|
|
||||||
// Insert a 'appendIdx'
|
methodDef->mMethodDeclaration = method->mMethodDeclaration;
|
||||||
BfParameterDef* newParam = new BfParameterDef();
|
methodDef->mReturnTypeRef = mSystem->mDirectIntTypeRef;
|
||||||
newParam->mName = "appendIdx";
|
methodDef->mIsStatic = true;
|
||||||
newParam->mTypeRef = mSystem->mDirectRefIntTypeRef;
|
methodDef->mBody = method->mBody;
|
||||||
newParam->mParamKind = BfParamKind_AppendIdx;
|
methodDef->mAddedAfterEmit = mIsComptime;
|
||||||
method->mParams.Insert(0, newParam);
|
|
||||||
|
for (auto param : method->mParams)
|
||||||
|
{
|
||||||
|
BfParameterDef* newParam = new BfParameterDef();
|
||||||
|
newParam->mName = param->mName;
|
||||||
|
newParam->mNamePrefixCount = param->mNamePrefixCount;
|
||||||
|
newParam->mTypeRef = param->mTypeRef;
|
||||||
|
newParam->mMethodGenericParamIdx = param->mMethodGenericParamIdx;
|
||||||
|
methodDef->mParams.push_back(newParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert a 'appendIdx'
|
||||||
|
BfParameterDef* newParam = new BfParameterDef();
|
||||||
|
newParam->mName = "appendIdx";
|
||||||
|
newParam->mTypeRef = mSystem->mDirectRefIntTypeRef;
|
||||||
|
newParam->mParamKind = BfParamKind_AppendIdx;
|
||||||
|
method->mParams.Insert(0, newParam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue