1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 20:12:21 +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

@ -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")
@ -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");
@ -3340,7 +3334,6 @@ BfType* BfModule::ResolveVarFieldType(BfTypeInstance* typeInstance, BfFieldInsta
if ((!field->mIsStatic) && (typeDef->mIsStatic))
{
AssertErrorState();
SetHadVarUsage();
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);
}
SetHadVarUsage();
return GetPrimitiveType(BfTypeCode_Var);
}
}
@ -3374,7 +3366,6 @@ BfType* BfModule::ResolveVarFieldType(BfTypeInstance* typeInstance, BfFieldInsta
{
if ((field->mTypeRef->IsA<BfVarTypeReference>()) || (field->mTypeRef->IsA<BfLetTypeReference>()))
Fail("Implicitly-typed fields must be initialized", field->GetRefNode());
SetHadVarUsage();
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);
@ -12046,8 +12042,6 @@ 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())
@ -13196,7 +13190,6 @@ void BfModule::CreateStaticCtor()
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);
@ -2286,7 +2286,6 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
// Failed, just put in placeholder 'var'
AssertErrorState();
resolvedFieldType = GetPrimitiveType(BfTypeCode_Var);
SetHadVarUsage();
}
}
@ -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

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