mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 20:12:21 +02:00
Fixed auto-prop issues
This commit is contained in:
parent
a17f8961b0
commit
6ae5d2e7aa
3 changed files with 39 additions and 47 deletions
|
@ -1382,7 +1382,7 @@ void BfAutoComplete::CheckIdentifier(BfIdentifierNode* identifierNode, bool isIn
|
||||||
"delegate", "delete", "do", "else", "false", "finally",
|
"delegate", "delete", "do", "else", "false", "finally",
|
||||||
"fixed", "for", "function", "if", "implicit", "in", "internal", "is", "new", "mixin", "null",
|
"fixed", "for", "function", "if", "implicit", "in", "internal", "is", "new", "mixin", "null",
|
||||||
"out", "params", "ref", "rettype", "return",
|
"out", "params", "ref", "rettype", "return",
|
||||||
"sealed", "sizeof", "scope", "static", "strideof", "struct", "switch", /*"this",*/ "throw", "try", "true", "typeof", "unchecked",
|
"sealed", "sizeof", "scope", "static", "strideof", "struct", "switch", /*"this",*/ "try", "true", "typeof", "unchecked",
|
||||||
"using", "var", "virtual", "volatile", "where", "while",
|
"using", "var", "virtual", "volatile", "where", "while",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14227,11 +14227,6 @@ void BfModule::SetupIRMethod(BfMethodInstance* methodInstance, BfIRFunction func
|
||||||
argIdx++;
|
argIdx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (methodDef->mName == "Hello")
|
|
||||||
{
|
|
||||||
NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (argIdx < argCount)
|
while (argIdx < argCount)
|
||||||
{
|
{
|
||||||
while ((paramIdx != -1) && (methodInstance->IsParamSkipped(paramIdx)))
|
while ((paramIdx != -1) && (methodInstance->IsParamSkipped(paramIdx)))
|
||||||
|
@ -15143,11 +15138,6 @@ void BfModule::EmitGCMarkValue(BfTypedValue markVal, BfModuleMethodInstance mark
|
||||||
if (markVal.mType != methodOwner)
|
if (markVal.mType != methodOwner)
|
||||||
markVal = Cast(NULL, markVal, methodOwner);
|
markVal = Cast(NULL, markVal, methodOwner);
|
||||||
|
|
||||||
if (markMemberMethodInstance.mMethodInstance->mIdHash == 0x1500000236LL)
|
|
||||||
{
|
|
||||||
NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
exprEvaluator.PushThis(NULL, markVal, markMemberMethodInstance.mMethodInstance, args);
|
exprEvaluator.PushThis(NULL, markVal, markMemberMethodInstance.mMethodInstance, args);
|
||||||
exprEvaluator.CreateCall(markMemberMethodInstance.mMethodInstance, markMemberMethodInstance.mFunc, false, args);
|
exprEvaluator.CreateCall(markMemberMethodInstance.mMethodInstance, markMemberMethodInstance.mFunc, false, args);
|
||||||
}
|
}
|
||||||
|
@ -17427,40 +17417,14 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
||||||
skipBody = true;
|
skipBody = true;
|
||||||
skipEndChecks = true;
|
skipEndChecks = true;
|
||||||
}
|
}
|
||||||
else if (HasCompiledOutput())
|
else
|
||||||
{
|
{
|
||||||
if ((methodDef->mName == BF_METHODNAME_MARKMEMBERS) || (methodDef->mName == BF_METHODNAME_MARKMEMBERS_STATIC))
|
|
||||||
{
|
|
||||||
if (mCompiler->mOptions.mEnableRealtimeLeakCheck)
|
|
||||||
{
|
|
||||||
EmitGCMarkMembers();
|
|
||||||
}
|
|
||||||
else if (!mCurTypeInstance->IsObject())
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (methodDef->mName == BF_METHODNAME_FIND_TLS_MEMBERS)
|
|
||||||
{
|
|
||||||
if (mCompiler->mOptions.mEnableRealtimeLeakCheck)
|
|
||||||
{
|
|
||||||
EmitGCFindTLSMembers();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!skipBody)
|
|
||||||
{
|
|
||||||
bool isEmptyBodied = BfNodeDynCast<BfTokenNode>(methodDef->mBody) != NULL;
|
|
||||||
|
|
||||||
if (isEmptyBodied) // Generate autoProperty things
|
|
||||||
{
|
|
||||||
auto propertyDeclaration = methodDef->GetPropertyDeclaration();
|
auto propertyDeclaration = methodDef->GetPropertyDeclaration();
|
||||||
if ((propertyDeclaration != NULL) && (!typeDef->HasAutoProperty(propertyDeclaration)))
|
if ((propertyDeclaration != NULL) && (!typeDef->HasAutoProperty(propertyDeclaration)))
|
||||||
{
|
{
|
||||||
if ((!mCurTypeInstance->IsInterface()) && (!hasExternSpecifier))
|
if ((!mCurTypeInstance->IsInterface()) && (!hasExternSpecifier))
|
||||||
Fail("Body expected", methodDef->mBody);
|
Fail("Body expected", methodDef->mBody);
|
||||||
}
|
}
|
||||||
else if (methodDef->mMethodType == BfMethodType_PropertyGetter)
|
else if (methodDef->mMethodType == BfMethodType_PropertyGetter)
|
||||||
{
|
{
|
||||||
if (methodInstance->mReturnType->IsValuelessType())
|
if (methodInstance->mReturnType->IsValuelessType())
|
||||||
|
@ -17488,8 +17452,8 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
||||||
else if (mCurTypeInstance->IsObject())
|
else if (mCurTypeInstance->IsObject())
|
||||||
lookupValue = BfTypedValue(mBfIRBuilder->CreateInBoundsGEP(GetThis().mValue, 0, fieldInstance->mDataIdx), fieldInstance->mResolvedType, true);
|
lookupValue = BfTypedValue(mBfIRBuilder->CreateInBoundsGEP(GetThis().mValue, 0, fieldInstance->mDataIdx), fieldInstance->mResolvedType, true);
|
||||||
else
|
else
|
||||||
lookupValue = ExtractValue(GetThis(), fieldInstance, fieldInstance->mFieldIdx);
|
lookupValue = ExtractValue(GetThis(), fieldInstance, fieldInstance->mFieldIdx);
|
||||||
lookupValue = LoadOrAggregateValue(lookupValue);
|
lookupValue = LoadOrAggregateValue(lookupValue);
|
||||||
CreateReturn(lookupValue.mValue);
|
CreateReturn(lookupValue.mValue);
|
||||||
EmitLifetimeEnds(&mCurMethodState->mHeadScope);
|
EmitLifetimeEnds(&mCurMethodState->mHeadScope);
|
||||||
}
|
}
|
||||||
|
@ -17509,7 +17473,11 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
||||||
}
|
}
|
||||||
else if (methodDef->mMethodType == BfMethodType_PropertySetter)
|
else if (methodDef->mMethodType == BfMethodType_PropertySetter)
|
||||||
{
|
{
|
||||||
if (!mCompiler->IsAutocomplete())
|
if (!methodDef->mIsMutating)
|
||||||
|
{
|
||||||
|
Fail("Auto-setter must be marked as 'mut'", methodDef->GetRefNode(), true);
|
||||||
|
}
|
||||||
|
else if (!mCompiler->IsAutocomplete())
|
||||||
{
|
{
|
||||||
String autoPropName = typeDef->GetAutoPropertyName(propertyDeclaration);
|
String autoPropName = typeDef->GetAutoPropertyName(propertyDeclaration);
|
||||||
BfFieldInstance* fieldInstance = GetFieldByName(mCurTypeInstance, autoPropName);
|
BfFieldInstance* fieldInstance = GetFieldByName(mCurTypeInstance, autoPropName);
|
||||||
|
@ -17529,13 +17497,13 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
||||||
BF_FATAL("Should not happen");
|
BF_FATAL("Should not happen");
|
||||||
}
|
}
|
||||||
if (mCurTypeInstance->IsObject())
|
if (mCurTypeInstance->IsObject())
|
||||||
thisValue = LoadValue(thisValue);
|
thisValue = LoadValue(thisValue);
|
||||||
lookupAddr = mBfIRBuilder->CreateInBoundsGEP(thisValue.mValue, 0, fieldInstance->mDataIdx);
|
lookupAddr = mBfIRBuilder->CreateInBoundsGEP(thisValue.mValue, 0, fieldInstance->mDataIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
BfExprEvaluator exprEvaluator(this);
|
BfExprEvaluator exprEvaluator(this);
|
||||||
auto localVal = exprEvaluator.LoadLocal(lastParam);
|
auto localVal = exprEvaluator.LoadLocal(lastParam);
|
||||||
localVal = LoadOrAggregateValue(localVal);
|
localVal = LoadOrAggregateValue(localVal);
|
||||||
mBfIRBuilder->CreateStore(localVal.mValue, lookupAddr);
|
mBfIRBuilder->CreateStore(localVal.mValue, lookupAddr);
|
||||||
}
|
}
|
||||||
else if (!fieldInstance->mResolvedType->IsValuelessType())
|
else if (!fieldInstance->mResolvedType->IsValuelessType())
|
||||||
|
@ -17545,7 +17513,31 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ((methodDef->mName == BF_METHODNAME_MARKMEMBERS) || (methodDef->mName == BF_METHODNAME_MARKMEMBERS_STATIC))
|
||||||
|
{
|
||||||
|
if (mCompiler->mOptions.mEnableRealtimeLeakCheck)
|
||||||
|
{
|
||||||
|
if (HasCompiledOutput())
|
||||||
|
EmitGCMarkMembers();
|
||||||
|
}
|
||||||
|
else if (!mCurTypeInstance->IsObject())
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (methodDef->mName == BF_METHODNAME_FIND_TLS_MEMBERS)
|
||||||
|
{
|
||||||
|
if (mCompiler->mOptions.mEnableRealtimeLeakCheck)
|
||||||
|
{
|
||||||
|
if (HasCompiledOutput())
|
||||||
|
EmitGCFindTLSMembers();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if (!skipBody)
|
||||||
|
{
|
||||||
|
bool isEmptyBodied = BfNodeDynCast<BfTokenNode>(methodDef->mBody) != NULL;
|
||||||
|
|
||||||
if ((!mCurMethodInstance->mReturnType->IsValuelessType()) && (!isEmptyBodied))
|
if ((!mCurMethodInstance->mReturnType->IsValuelessType()) && (!isEmptyBodied))
|
||||||
{
|
{
|
||||||
|
|
|
@ -790,7 +790,7 @@ bool BfTypeDef::HasAutoProperty(BfPropertyDeclaration* propertyDeclaration)
|
||||||
|
|
||||||
for (auto methodDeclaration : propertyDeclaration->mMethods)
|
for (auto methodDeclaration : propertyDeclaration->mMethods)
|
||||||
{
|
{
|
||||||
if (BfNodeDynCast<BfTokenNode>(methodDeclaration->mBody) != NULL)
|
if (methodDeclaration->mBody == NULL)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue