mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-12 05:14:10 +02:00
Fixed some var usage
This commit is contained in:
parent
54fa1e0811
commit
e1656865bb
3 changed files with 24 additions and 37 deletions
|
@ -1098,7 +1098,7 @@ void BfModule::EnsureIRBuilder(bool dbgVerifyCodeGen)
|
||||||
// code as we walk the AST
|
// code as we walk the AST
|
||||||
//mBfIRBuilder->mDbgVerifyCodeGen = true;
|
//mBfIRBuilder->mDbgVerifyCodeGen = true;
|
||||||
if (
|
if (
|
||||||
(mModuleName == "-")
|
(mModuleName == "IDE_ui_LaunchDialog")
|
||||||
//|| (mModuleName == "System_Internal")
|
//|| (mModuleName == "System_Internal")
|
||||||
//|| (mModuleName == "vdata")
|
//|| (mModuleName == "vdata")
|
||||||
//|| (mModuleName == "Hey_Dude_Bro_TestClass")
|
//|| (mModuleName == "Hey_Dude_Bro_TestClass")
|
||||||
|
@ -2441,12 +2441,6 @@ void BfModule::SetElementType(BfAstNode* astNode, BfSourceElementType elementTyp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfModule::SetHadVarUsage()
|
|
||||||
{
|
|
||||||
mHadVarUsage = true;
|
|
||||||
mHadBuildError = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPersistent)
|
BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPersistent)
|
||||||
{
|
{
|
||||||
BP_ZONE("BfModule::Fail");
|
BP_ZONE("BfModule::Fail");
|
||||||
|
@ -3340,7 +3334,6 @@ BfType* BfModule::ResolveVarFieldType(BfTypeInstance* typeInstance, BfFieldInsta
|
||||||
if ((!field->mIsStatic) && (typeDef->mIsStatic))
|
if ((!field->mIsStatic) && (typeDef->mIsStatic))
|
||||||
{
|
{
|
||||||
AssertErrorState();
|
AssertErrorState();
|
||||||
SetHadVarUsage();
|
|
||||||
return GetPrimitiveType(BfTypeCode_Var);
|
return GetPrimitiveType(BfTypeCode_Var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3360,7 +3353,6 @@ BfType* BfModule::ResolveVarFieldType(BfTypeInstance* typeInstance, BfFieldInsta
|
||||||
fieldModule->Fail(StrFormat("Field '%s.%s' creates a type inference cycle", TypeToString(fieldOwner).c_str(), fieldDef->mName.c_str()), fieldDef->mTypeRef, true);
|
fieldModule->Fail(StrFormat("Field '%s.%s' creates a type inference cycle", TypeToString(fieldOwner).c_str(), fieldDef->mName.c_str()), fieldDef->mTypeRef, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetHadVarUsage();
|
|
||||||
return GetPrimitiveType(BfTypeCode_Var);
|
return GetPrimitiveType(BfTypeCode_Var);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3374,7 +3366,6 @@ BfType* BfModule::ResolveVarFieldType(BfTypeInstance* typeInstance, BfFieldInsta
|
||||||
{
|
{
|
||||||
if ((field->mTypeRef->IsA<BfVarTypeReference>()) || (field->mTypeRef->IsA<BfLetTypeReference>()))
|
if ((field->mTypeRef->IsA<BfVarTypeReference>()) || (field->mTypeRef->IsA<BfLetTypeReference>()))
|
||||||
Fail("Implicitly-typed fields must be initialized", field->GetRefNode());
|
Fail("Implicitly-typed fields must be initialized", field->GetRefNode());
|
||||||
SetHadVarUsage();
|
|
||||||
return GetPrimitiveType(BfTypeCode_Var);
|
return GetPrimitiveType(BfTypeCode_Var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9855,6 +9846,11 @@ BfTypedValue BfModule::LoadValue(BfTypedValue typedValue, BfAstNode* refNode, bo
|
||||||
BfIRValue loadedVal = typedValue.mValue;
|
BfIRValue loadedVal = typedValue.mValue;
|
||||||
if (loadedVal)
|
if (loadedVal)
|
||||||
{
|
{
|
||||||
|
if (typedValue.mType->IsVar())
|
||||||
|
{
|
||||||
|
return BfTypedValue(loadedVal, typedValue.mType, false);
|
||||||
|
}
|
||||||
|
|
||||||
/*if (isVolatile)
|
/*if (isVolatile)
|
||||||
mBfIRBuilder->CreateFence(BfIRFenceType_AcquireRelease);*/
|
mBfIRBuilder->CreateFence(BfIRFenceType_AcquireRelease);*/
|
||||||
PopulateType(typedValue.mType, BfPopulateType_Data);
|
PopulateType(typedValue.mType, BfPopulateType_Data);
|
||||||
|
@ -11551,6 +11547,11 @@ void BfModule::HadSlotCountDependency()
|
||||||
|
|
||||||
BfTypedValue BfModule::ReferenceStaticField(BfFieldInstance* fieldInstance)
|
BfTypedValue BfModule::ReferenceStaticField(BfFieldInstance* fieldInstance)
|
||||||
{
|
{
|
||||||
|
if (fieldInstance->mResolvedType->IsVar())
|
||||||
|
{
|
||||||
|
NOP;
|
||||||
|
}
|
||||||
|
|
||||||
if (mIsScratchModule)
|
if (mIsScratchModule)
|
||||||
{
|
{
|
||||||
// Just fake it for the extern and unspecialized modules
|
// Just fake it for the extern and unspecialized modules
|
||||||
|
@ -11875,11 +11876,6 @@ BfIRValue BfModule::AllocLocalVariable(BfType* type, const StringImpl& name, boo
|
||||||
|
|
||||||
void BfModule::DoAddLocalVariable(BfLocalVariable* localVar)
|
void BfModule::DoAddLocalVariable(BfLocalVariable* localVar)
|
||||||
{
|
{
|
||||||
if (localVar->mResolvedType->IsVar())
|
|
||||||
{
|
|
||||||
BF_ASSERT((mCurMethodInstance->mIsUnspecialized) || (mCurMethodState->mClosureState != NULL) || (mHadVarUsage));
|
|
||||||
}
|
|
||||||
|
|
||||||
localVar->mLocalVarIdx = (int)mCurMethodState->mLocals.size();
|
localVar->mLocalVarIdx = (int)mCurMethodState->mLocals.size();
|
||||||
mCurMethodState->mLocals.push_back(localVar);
|
mCurMethodState->mLocals.push_back(localVar);
|
||||||
|
|
||||||
|
@ -12046,8 +12042,6 @@ void BfModule::CreateDIRetVal()
|
||||||
|
|
||||||
if ((mCurMethodState->mRetVal) || (mCurMethodState->mRetValAddr))
|
if ((mCurMethodState->mRetVal) || (mCurMethodState->mRetValAddr))
|
||||||
{
|
{
|
||||||
BF_ASSERT((!mBfIRBuilder->mIgnoreWrites) || (mHadVarUsage));
|
|
||||||
|
|
||||||
BfType* dbgType = mCurMethodInstance->mReturnType;
|
BfType* dbgType = mCurMethodInstance->mReturnType;
|
||||||
BfIRValue dbgValue = mCurMethodState->mRetVal.mValue;
|
BfIRValue dbgValue = mCurMethodState->mRetVal.mValue;
|
||||||
if (mCurMethodInstance->HasStructRet())
|
if (mCurMethodInstance->HasStructRet())
|
||||||
|
@ -13196,7 +13190,6 @@ void BfModule::CreateStaticCtor()
|
||||||
continue;
|
continue;
|
||||||
if (fieldInst->mResolvedType->IsVar())
|
if (fieldInst->mResolvedType->IsVar())
|
||||||
{
|
{
|
||||||
BF_ASSERT(mHadVarUsage);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto assignValue = GetFieldInitializerValue(fieldInst);
|
auto assignValue = GetFieldInitializerValue(fieldInst);
|
||||||
|
|
|
@ -1689,8 +1689,8 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BfLogSysM("Setting revision. Type: %p Revision: %d\n", typeInstance, mRevision);
|
//BfLogSysM("Setting revision. Type: %p Revision: %d\n", typeInstance, mRevision);
|
||||||
typeInstance->mRevision = mRevision;
|
//typeInstance->mRevision = mRevision;
|
||||||
|
|
||||||
// Temporarily allow us to derive from private classes, to avoid infinite loop from TypeIsSubTypeOf
|
// Temporarily allow us to derive from private classes, to avoid infinite loop from TypeIsSubTypeOf
|
||||||
SetAndRestoreValue<bool> prevSkipTypeProtectionChecks(typeInstance->mSkipTypeProtectionChecks, true);
|
SetAndRestoreValue<bool> prevSkipTypeProtectionChecks(typeInstance->mSkipTypeProtectionChecks, true);
|
||||||
|
@ -2286,7 +2286,6 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
// Failed, just put in placeholder 'var'
|
// Failed, just put in placeholder 'var'
|
||||||
AssertErrorState();
|
AssertErrorState();
|
||||||
resolvedFieldType = GetPrimitiveType(BfTypeCode_Var);
|
resolvedFieldType = GetPrimitiveType(BfTypeCode_Var);
|
||||||
SetHadVarUsage();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8693,9 +8692,6 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp
|
||||||
// * <-> Var
|
// * <-> Var
|
||||||
if ((typedVal.mType->IsVar()) || (toType->IsVar()))
|
if ((typedVal.mType->IsVar()) || (toType->IsVar()))
|
||||||
{
|
{
|
||||||
BF_ASSERT(((mCurMethodInstance != NULL) && (mCurMethodInstance->mIsUnspecialized)) ||
|
|
||||||
((mCurMethodState != NULL) && (mCurMethodState->mClosureState != NULL)) ||
|
|
||||||
(mHadVarUsage));
|
|
||||||
return GetDefaultValue(toType);
|
return GetDefaultValue(toType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1386,7 +1386,6 @@ BfLocalVariable* BfModule::HandleVariableDeclaration(BfVariableDeclaration* varD
|
||||||
if (!initValue)
|
if (!initValue)
|
||||||
{
|
{
|
||||||
initValue = GetDefaultTypedValue(GetPrimitiveType(BfTypeCode_Var));
|
initValue = GetDefaultTypedValue(GetPrimitiveType(BfTypeCode_Var));
|
||||||
SetHadVarUsage();
|
|
||||||
}
|
}
|
||||||
if (initValue.mType->IsNull())
|
if (initValue.mType->IsNull())
|
||||||
{
|
{
|
||||||
|
@ -5456,7 +5455,6 @@ void BfModule::Visit(BfForEachStatement* forEachStmt)
|
||||||
else if (isVarEnumerator)
|
else if (isVarEnumerator)
|
||||||
{
|
{
|
||||||
// Generic method or mixin decl
|
// Generic method or mixin decl
|
||||||
BF_ASSERT(mBfIRBuilder->mIgnoreWrites || mHadVarUsage);
|
|
||||||
}
|
}
|
||||||
else if (!target.mType->IsTypeInstance())
|
else if (!target.mType->IsTypeInstance())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue