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

Fixed some var usage

This commit is contained in:
Brian Fiete 2019-11-02 06:02:36 -07:00
parent 54fa1e0811
commit e1656865bb
3 changed files with 24 additions and 37 deletions

View file

@ -794,12 +794,12 @@ BfModule::BfModule(BfContext* context, const StringImpl& moduleName)
mModuleOptions = NULL;
mLastUsedRevision = -1;
mUsedSlotCount = -1;
mIsReified = true;
mReifyQueued = false;
mIsSpecialModule = false;
mIsScratchModule = false;
mIsSpecializedMethodModuleRoot = false; // There may be mNextAltModules extending from this
mIsSpecializedMethodModuleRoot = false; // There may be mNextAltModules extending from this
mHadBuildError = false;
mHadBuildWarning = false;
mIgnoreErrors = false;
@ -1098,7 +1098,7 @@ void BfModule::EnsureIRBuilder(bool dbgVerifyCodeGen)
// code as we walk the AST
//mBfIRBuilder->mDbgVerifyCodeGen = true;
if (
(mModuleName == "-")
(mModuleName == "IDE_ui_LaunchDialog")
//|| (mModuleName == "System_Internal")
//|| (mModuleName == "vdata")
//|| (mModuleName == "Hey_Dude_Bro_TestClass")
@ -1149,7 +1149,7 @@ void BfModule::StartNewRevision(RebuildKind rebuildKind, bool force)
return;
mHadBuildError = false;
mHadBuildWarning = false;
mHadBuildWarning = false;
mExtensionCount = 0;
mRevision = mCompiler->mRevision;
mRebuildIdx++;
@ -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)
{
BP_ZONE("BfModule::Fail");
@ -3339,8 +3333,7 @@ BfType* BfModule::ResolveVarFieldType(BfTypeInstance* typeInstance, BfFieldInsta
if ((!field->mIsStatic) && (typeDef->mIsStatic))
{
AssertErrorState();
SetHadVarUsage();
AssertErrorState();
return GetPrimitiveType(BfTypeCode_Var);
}
@ -3359,8 +3352,7 @@ BfType* BfModule::ResolveVarFieldType(BfTypeInstance* typeInstance, BfFieldInsta
SetAndRestoreValue<bool> prevIgnoreError(fieldModule->mIgnoreErrors, false);
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);
}
}
@ -3373,8 +3365,7 @@ BfType* BfModule::ResolveVarFieldType(BfTypeInstance* typeInstance, BfFieldInsta
if ((field->mInitializer == NULL) && (!isDeclType))
{
if ((field->mTypeRef->IsA<BfVarTypeReference>()) || (field->mTypeRef->IsA<BfLetTypeReference>()))
Fail("Implicitly-typed fields must be initialized", field->GetRefNode());
SetHadVarUsage();
Fail("Implicitly-typed fields must be initialized", field->GetRefNode());
return GetPrimitiveType(BfTypeCode_Var);
}
@ -9855,6 +9846,11 @@ BfTypedValue BfModule::LoadValue(BfTypedValue typedValue, BfAstNode* refNode, bo
BfIRValue loadedVal = typedValue.mValue;
if (loadedVal)
{
if (typedValue.mType->IsVar())
{
return BfTypedValue(loadedVal, typedValue.mType, false);
}
/*if (isVolatile)
mBfIRBuilder->CreateFence(BfIRFenceType_AcquireRelease);*/
PopulateType(typedValue.mType, BfPopulateType_Data);
@ -11551,6 +11547,11 @@ void BfModule::HadSlotCountDependency()
BfTypedValue BfModule::ReferenceStaticField(BfFieldInstance* fieldInstance)
{
if (fieldInstance->mResolvedType->IsVar())
{
NOP;
}
if (mIsScratchModule)
{
// 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)
{
if (localVar->mResolvedType->IsVar())
{
BF_ASSERT((mCurMethodInstance->mIsUnspecialized) || (mCurMethodState->mClosureState != NULL) || (mHadVarUsage));
}
localVar->mLocalVarIdx = (int)mCurMethodState->mLocals.size();
mCurMethodState->mLocals.push_back(localVar);
@ -12045,9 +12041,7 @@ void BfModule::CreateDIRetVal()
}*/
if ((mCurMethodState->mRetVal) || (mCurMethodState->mRetValAddr))
{
BF_ASSERT((!mBfIRBuilder->mIgnoreWrites) || (mHadVarUsage));
{
BfType* dbgType = mCurMethodInstance->mReturnType;
BfIRValue dbgValue = mCurMethodState->mRetVal.mValue;
if (mCurMethodInstance->HasStructRet())
@ -13195,8 +13189,7 @@ void BfModule::CreateStaticCtor()
if (!fieldInst->mFieldIncluded)
continue;
if (fieldInst->mResolvedType->IsVar())
{
BF_ASSERT(mHadVarUsage);
{
continue;
}
auto assignValue = GetFieldInitializerValue(fieldInst);

View file

@ -1689,8 +1689,8 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
}
}
BfLogSysM("Setting revision. Type: %p Revision: %d\n", typeInstance, mRevision);
typeInstance->mRevision = mRevision;
//BfLogSysM("Setting revision. Type: %p Revision: %d\n", typeInstance, mRevision);
//typeInstance->mRevision = mRevision;
// Temporarily allow us to derive from private classes, to avoid infinite loop from TypeIsSubTypeOf
SetAndRestoreValue<bool> prevSkipTypeProtectionChecks(typeInstance->mSkipTypeProtectionChecks, true);
@ -2285,8 +2285,7 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
{
// Failed, just put in placeholder 'var'
AssertErrorState();
resolvedFieldType = GetPrimitiveType(BfTypeCode_Var);
SetHadVarUsage();
resolvedFieldType = GetPrimitiveType(BfTypeCode_Var);
}
}
@ -8693,9 +8692,6 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp
// * <-> Var
if ((typedVal.mType->IsVar()) || (toType->IsVar()))
{
BF_ASSERT(((mCurMethodInstance != NULL) && (mCurMethodInstance->mIsUnspecialized)) ||
((mCurMethodState != NULL) && (mCurMethodState->mClosureState != NULL)) ||
(mHadVarUsage));
return GetDefaultValue(toType);
}

View file

@ -1385,8 +1385,7 @@ BfLocalVariable* BfModule::HandleVariableDeclaration(BfVariableDeclaration* varD
}
if (!initValue)
{
initValue = GetDefaultTypedValue(GetPrimitiveType(BfTypeCode_Var));
SetHadVarUsage();
initValue = GetDefaultTypedValue(GetPrimitiveType(BfTypeCode_Var));
}
if (initValue.mType->IsNull())
{
@ -5455,8 +5454,7 @@ void BfModule::Visit(BfForEachStatement* forEachStmt)
}
else if (isVarEnumerator)
{
// Generic method or mixin decl
BF_ASSERT(mBfIRBuilder->mIgnoreWrites || mHadVarUsage);
// Generic method or mixin decl
}
else if (!target.mType->IsTypeInstance())
{