mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed invalid ObjectAccessCheck on null constant
This commit is contained in:
parent
76cd261b80
commit
7bc9b7af0a
1 changed files with 22 additions and 12 deletions
|
@ -9167,6 +9167,8 @@ void BfModule::EmitObjectAccessCheck(BfTypedValue typedVal)
|
||||||
auto constant = mBfIRBuilder->GetConstant(typedVal.mValue);
|
auto constant = mBfIRBuilder->GetConstant(typedVal.mValue);
|
||||||
if (constant->mTypeCode == BfTypeCode_NullPtr)
|
if (constant->mTypeCode == BfTypeCode_NullPtr)
|
||||||
return;
|
return;
|
||||||
|
if (constant->mConstType == BfConstType_BitCastNull)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool emitObjectAccessCheck = mCompiler->mOptions.mEmitObjectAccessCheck;
|
bool emitObjectAccessCheck = mCompiler->mOptions.mEmitObjectAccessCheck;
|
||||||
|
@ -11226,7 +11228,7 @@ BfTypedValue BfModule::LoadValue(BfTypedValue typedValue, BfAstNode* refNode, bo
|
||||||
{
|
{
|
||||||
auto globalVar = (BfGlobalVar*)constantValue;
|
auto globalVar = (BfGlobalVar*)constantValue;
|
||||||
if (globalVar->mName[0] == '#')
|
if (globalVar->mName[0] == '#')
|
||||||
{
|
{
|
||||||
BfTypedValue result = GetCompilerFieldValue(globalVar->mName);
|
BfTypedValue result = GetCompilerFieldValue(globalVar->mName);
|
||||||
if (result)
|
if (result)
|
||||||
return result;
|
return result;
|
||||||
|
@ -13039,6 +13041,19 @@ void BfModule::HadSlotCountDependency()
|
||||||
|
|
||||||
BfTypedValue BfModule::GetCompilerFieldValue(const StringImpl& str)
|
BfTypedValue BfModule::GetCompilerFieldValue(const StringImpl& str)
|
||||||
{
|
{
|
||||||
|
if (str == "#IsConstEval")
|
||||||
|
{
|
||||||
|
return BfTypedValue(mBfIRBuilder->CreateConst(BfTypeCode_Boolean, mIsConstModule ? 1 : 0), GetPrimitiveType(BfTypeCode_Boolean));
|
||||||
|
}
|
||||||
|
if (str == "#ModuleName")
|
||||||
|
{
|
||||||
|
return BfTypedValue(GetStringObjectValue(mModuleName), ResolveTypeDef(mCompiler->mStringTypeDef));
|
||||||
|
}
|
||||||
|
if (str == "#ProjectName")
|
||||||
|
{
|
||||||
|
if (mProject != NULL)
|
||||||
|
return BfTypedValue(GetStringObjectValue(mProject->mName), ResolveTypeDef(mCompiler->mStringTypeDef));
|
||||||
|
}
|
||||||
if (str == "#TimeLocal")
|
if (str == "#TimeLocal")
|
||||||
{
|
{
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
|
@ -17631,7 +17646,7 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
||||||
|
|
||||||
if (mCurMethodState == NULL) // Only do initial classify for the 'outer' method state, not any local methods or lambdas
|
if (mCurMethodState == NULL) // Only do initial classify for the 'outer' method state, not any local methods or lambdas
|
||||||
{
|
{
|
||||||
if ((mCompiler->mIsResolveOnly) && (methodDef->mBody != NULL) && (!mCurTypeInstance->IsBoxed()) &&
|
if ((mCompiler->mIsResolveOnly) && (!mIsConstModule) && (methodDef->mBody != NULL) && (!mCurTypeInstance->IsBoxed()) &&
|
||||||
(methodDef->mBody->IsFromParser(mCompiler->mResolvePassData->mParser)) && (mCompiler->mResolvePassData->mSourceClassifier != NULL))
|
(methodDef->mBody->IsFromParser(mCompiler->mResolvePassData->mParser)) && (mCompiler->mResolvePassData->mSourceClassifier != NULL))
|
||||||
{
|
{
|
||||||
mCompiler->mResolvePassData->mSourceClassifier->VisitChildNoRef(methodDef->mBody);
|
mCompiler->mResolvePassData->mSourceClassifier->VisitChildNoRef(methodDef->mBody);
|
||||||
|
@ -18569,11 +18584,6 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
||||||
if ((methodDef != NULL) && (propertyDeclaration != NULL) && (propertyDeclaration->mExternSpecifier != NULL))
|
if ((methodDef != NULL) && (propertyDeclaration != NULL) && (propertyDeclaration->mExternSpecifier != NULL))
|
||||||
hasExternSpecifier = true;
|
hasExternSpecifier = true;
|
||||||
|
|
||||||
if ((methodDef->mMethodType == BfMethodType_CtorNoBody) && (mModuleName == "Atma_Framework_Window"))
|
|
||||||
{
|
|
||||||
NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allocate, clear, set classVData
|
// Allocate, clear, set classVData
|
||||||
|
|
||||||
if ((methodDef->mMethodType == BfMethodType_Ctor) && (methodDef->mIsStatic))
|
if ((methodDef->mMethodType == BfMethodType_Ctor) && (methodDef->mIsStatic))
|
||||||
|
@ -18585,7 +18595,7 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
||||||
skipBody = true;
|
skipBody = true;
|
||||||
skipEndChecks = true;
|
skipEndChecks = true;
|
||||||
|
|
||||||
if (HasCompiledOutput())
|
if ((HasCompiledOutput()) || (mIsConstModule))
|
||||||
{
|
{
|
||||||
// Clear out DebugLoc - to mark the ".addr" code as part of prologue
|
// Clear out DebugLoc - to mark the ".addr" code as part of prologue
|
||||||
mBfIRBuilder->ClearDebugLocation();
|
mBfIRBuilder->ClearDebugLocation();
|
||||||
|
@ -18853,7 +18863,7 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
||||||
else if ((mCurTypeInstance->IsEnum()) && (!mCurTypeInstance->IsBoxed()) && (methodDef->mName == BF_METHODNAME_TO_STRING))
|
else if ((mCurTypeInstance->IsEnum()) && (!mCurTypeInstance->IsBoxed()) && (methodDef->mName == BF_METHODNAME_TO_STRING))
|
||||||
{
|
{
|
||||||
auto enumType = ResolveTypeDef(mCompiler->mEnumTypeDef);
|
auto enumType = ResolveTypeDef(mCompiler->mEnumTypeDef);
|
||||||
if (HasCompiledOutput())
|
if ((HasCompiledOutput()) || (mIsConstModule))
|
||||||
{
|
{
|
||||||
EmitEnumToStringBody();
|
EmitEnumToStringBody();
|
||||||
}
|
}
|
||||||
|
@ -18866,7 +18876,7 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
||||||
else if ((mCurTypeInstance->IsTuple()) && (!mCurTypeInstance->IsBoxed()) && (methodDef->mName == BF_METHODNAME_TO_STRING))
|
else if ((mCurTypeInstance->IsTuple()) && (!mCurTypeInstance->IsBoxed()) && (methodDef->mName == BF_METHODNAME_TO_STRING))
|
||||||
{
|
{
|
||||||
auto enumType = ResolveTypeDef(mCompiler->mEnumTypeDef);
|
auto enumType = ResolveTypeDef(mCompiler->mEnumTypeDef);
|
||||||
if (HasCompiledOutput())
|
if ((HasCompiledOutput()) || (mIsConstModule))
|
||||||
{
|
{
|
||||||
EmitTupleToStringBody();
|
EmitTupleToStringBody();
|
||||||
}
|
}
|
||||||
|
@ -18908,7 +18918,7 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
||||||
{
|
{
|
||||||
mBfIRBuilder->CreateRetVoid();
|
mBfIRBuilder->CreateRetVoid();
|
||||||
}
|
}
|
||||||
else if (HasCompiledOutput())
|
else if ((HasCompiledOutput()) || (mIsConstModule))
|
||||||
{
|
{
|
||||||
String autoPropName = typeDef->GetAutoPropertyName(propertyDeclaration);
|
String autoPropName = typeDef->GetAutoPropertyName(propertyDeclaration);
|
||||||
BfFieldInstance* fieldInstance = GetFieldByName(mCurTypeInstance, autoPropName);
|
BfFieldInstance* fieldInstance = GetFieldByName(mCurTypeInstance, autoPropName);
|
||||||
|
@ -22517,7 +22527,7 @@ bool BfModule::SlotVirtualMethod(BfMethodInstance* methodInstance, BfAmbiguityCo
|
||||||
if ((iMethodPtr->mKind != BfMethodRefKind_AmbiguousRef) && (iMethodPtr->mTypeInstance != NULL))
|
if ((iMethodPtr->mKind != BfMethodRefKind_AmbiguousRef) && (iMethodPtr->mTypeInstance != NULL))
|
||||||
{
|
{
|
||||||
auto prevMethod = (BfMethodInstance*)*iMethodPtr;
|
auto prevMethod = (BfMethodInstance*)*iMethodPtr;
|
||||||
if ((mCompiler->mIsResolveOnly) && (prevMethod == methodInstance))
|
if ((mCompiler->mIsResolveOnly) && (prevMethod == methodInstance) && (!mIsConstModule))
|
||||||
{
|
{
|
||||||
// When autocompletion regenerates a single method body but not the whole type then
|
// When autocompletion regenerates a single method body but not the whole type then
|
||||||
// we will see ourselves in the vtable already
|
// we will see ourselves in the vtable already
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue