mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-05 15:56:00 +02:00
Added error/warning panel, region support
This commit is contained in:
parent
c63edcbf87
commit
8970ebcd93
33 changed files with 454 additions and 130 deletions
|
@ -3482,6 +3482,22 @@ void BfCompiler::ProcessAutocompleteTempType()
|
|||
BF_ASSERT(mResolvePassData->mAutoComplete->mDefMethod == NULL);
|
||||
if (autoComplete->mResolveType == BfResolveType_GetNavigationData)
|
||||
{
|
||||
for (auto node : mResolvePassData->mParser->mSidechannelRootNode->mChildArr)
|
||||
{
|
||||
if (auto preprocNode = BfNodeDynCast<BfPreprocessorNode>(node))
|
||||
{
|
||||
if (preprocNode->mCommand->Equals("region"))
|
||||
{
|
||||
if (!autoCompleteResultString.empty())
|
||||
autoCompleteResultString += "\n";
|
||||
autoCompleteResultString += "#";
|
||||
preprocNode->mArgument->ToString(autoCompleteResultString);
|
||||
mContext->mScratchModule->UpdateSrcPos(preprocNode, (BfSrcPosFlags)(BfSrcPosFlag_NoSetDebugLoc | BfSrcPosFlag_Force));
|
||||
autoCompleteResultString += StrFormat("\tregion\t%d\t%d", module->mCurFilePosition.mCurLine, module->mCurFilePosition.mCurColumn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto tempTypeDef : mResolvePassData->mAutoCompleteTempTypes)
|
||||
{
|
||||
String typeName = tempTypeDef->ToString();
|
||||
|
|
|
@ -195,7 +195,7 @@ void BfDefBuilder::ParseGenericParams(BfGenericParamsDeclaration* genericParamsD
|
|||
{
|
||||
if (genericParams[checkParamsIdx]->mName == name)
|
||||
{
|
||||
mPassInstance->Fail("Duplicate generic param name", genericParamNode);
|
||||
Fail("Duplicate generic param name", genericParamNode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ void BfDefBuilder::ParseGenericParams(BfGenericParamsDeclaration* genericParamsD
|
|||
{
|
||||
if (externConstraintDefs == NULL)
|
||||
{
|
||||
mPassInstance->Fail("Cannot find generic parameter in constraint", genericConstraint->mTypeRef);
|
||||
Fail("Cannot find generic parameter in constraint", genericConstraint->mTypeRef);
|
||||
|
||||
if (genericParams.IsEmpty())
|
||||
continue;
|
||||
|
@ -307,9 +307,9 @@ void BfDefBuilder::ParseGenericParams(BfGenericParamsDeclaration* genericParamsD
|
|||
prevFlagName = "struct*";
|
||||
|
||||
if (prevFlagName == name)
|
||||
mPassInstance->Fail(StrFormat("Cannot specify '%s' twice", prevFlagName.c_str()), constraintNode);
|
||||
Fail(StrFormat("Cannot specify '%s' twice", prevFlagName.c_str()), constraintNode);
|
||||
else
|
||||
mPassInstance->Fail(StrFormat("Cannot specify both '%s' and '%s'", prevFlagName.c_str(), name.c_str()), constraintNode);
|
||||
Fail(StrFormat("Cannot specify both '%s' and '%s'", prevFlagName.c_str(), name.c_str()), constraintNode);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -347,7 +347,7 @@ void BfDefBuilder::ParseGenericParams(BfGenericParamsDeclaration* genericParamsD
|
|||
auto constraintType = BfNodeDynCast<BfTypeReference>(constraintNode);
|
||||
if (constraintType == NULL)
|
||||
{
|
||||
mPassInstance->Fail("Invalid constraint", constraintNode);
|
||||
Fail("Invalid constraint", constraintNode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ void BfDefBuilder::ParseGenericParams(BfGenericParamsDeclaration* genericParamsD
|
|||
}
|
||||
else
|
||||
{
|
||||
mPassInstance->Fail("Type assignment must be the first constraint", genericConstraint->mColonToken);
|
||||
Fail("Type assignment must be the first constraint", genericConstraint->mColonToken);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,22 +453,22 @@ BfMethodDef* BfDefBuilder::CreateMethodDef(BfMethodDeclaration* methodDeclaratio
|
|||
if (mCurTypeDef->mTypeCode == BfTypeCode_Interface)
|
||||
{
|
||||
if ((methodDef->mIsConcrete) && (!mCurTypeDef->mIsConcrete))
|
||||
mPassInstance->Fail("Only interfaces declared as 'concrete' can be declare methods as 'concrete'. Consider adding 'concrete' to the interface declaration.", methodDeclaration->mVirtualSpecifier);
|
||||
Fail("Only interfaces declared as 'concrete' can be declare methods as 'concrete'. Consider adding 'concrete' to the interface declaration.", methodDeclaration->mVirtualSpecifier);
|
||||
//if (!methodDef->mIsConcrete)
|
||||
//mPassInstance->Fail(StrFormat("Interfaces methods cannot be declared as '%s'", methodDeclaration->mVirtualSpecifier->ToString().c_str()), methodDeclaration->mVirtualSpecifier);
|
||||
//Fail(StrFormat("Interfaces methods cannot be declared as '%s'", methodDeclaration->mVirtualSpecifier->ToString().c_str()), methodDeclaration->mVirtualSpecifier);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (methodDef->mIsConcrete)
|
||||
mPassInstance->Fail("Only interfaces methods can be declared as 'concrete'", methodDeclaration->mVirtualSpecifier);
|
||||
Fail("Only interfaces methods can be declared as 'concrete'", methodDeclaration->mVirtualSpecifier);
|
||||
}
|
||||
|
||||
if (methodDef->mIsAbstract)
|
||||
{
|
||||
if ((!mCurTypeDef->mIsAbstract) && (mCurTypeDef->mTypeCode != BfTypeCode_Interface))
|
||||
mPassInstance->Fail("Method is abstract but it is contained in non-abstract class", methodDeclaration);
|
||||
Fail("Method is abstract but it is contained in non-abstract class", methodDeclaration);
|
||||
if (methodDeclaration->mBody != NULL)
|
||||
mPassInstance->Fail("Abstract method cannot declare a body", methodDeclaration);
|
||||
Fail("Abstract method cannot declare a body", methodDeclaration);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -513,7 +513,7 @@ BfMethodDef* BfDefBuilder::CreateMethodDef(BfMethodDeclaration* methodDeclaratio
|
|||
methodDef->mMethodType = BfMethodType_Operator;
|
||||
/*if (propertyDecl->mStaticSpecifier == NULL)
|
||||
{
|
||||
mPassInstance->Fail("Operators must be declared as static", methodDeclaration);
|
||||
Fail("Operators must be declared as static", methodDeclaration);
|
||||
}*/
|
||||
|
||||
String declError;
|
||||
|
@ -531,7 +531,7 @@ BfMethodDef* BfDefBuilder::CreateMethodDef(BfMethodDeclaration* methodDeclaratio
|
|||
}
|
||||
if (!declError.empty())
|
||||
{
|
||||
mPassInstance->Fail(StrFormat("Operator must be declared %s", declError.c_str()), operatorDecl->mOperatorToken);
|
||||
Fail(StrFormat("Operator must be declared %s", declError.c_str()), operatorDecl->mOperatorToken);
|
||||
}
|
||||
}
|
||||
else if ((mCurTypeDef->mIsDelegate) || (mCurTypeDef->mIsFunction))
|
||||
|
@ -560,7 +560,7 @@ BfMethodDef* BfDefBuilder::CreateMethodDef(BfMethodDeclaration* methodDeclaratio
|
|||
methodDef->mName = methodDeclaration->mNameNode->ToString();
|
||||
methodDef->mMethodType = BfMethodType_Mixin;
|
||||
/*if (!methodDef->mIsStatic)
|
||||
mPassInstance->Fail("Mixin must be declared static", methodDeclaration->mMixinSpecifier);*/
|
||||
Fail("Mixin must be declared static", methodDeclaration->mMixinSpecifier);*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -612,7 +612,7 @@ BfMethodDef* BfDefBuilder::CreateMethodDef(BfMethodDeclaration* methodDeclaratio
|
|||
{
|
||||
methodDef->mParams[paramIdx - 1]->mParamKind = BfParamKind_Normal;
|
||||
hadParams = false;
|
||||
mPassInstance->Fail("Params parameter must be the last parameter", methodDef->mParams[paramIdx - 1]->mParamDeclaration);
|
||||
Fail("Params parameter must be the last parameter", methodDef->mParams[paramIdx - 1]->mParamDeclaration);
|
||||
}
|
||||
|
||||
if (paramDef->mParamDeclaration->mInitializer != NULL)
|
||||
|
@ -620,7 +620,7 @@ BfMethodDef* BfDefBuilder::CreateMethodDef(BfMethodDeclaration* methodDeclaratio
|
|||
else if (hasDefault)
|
||||
{
|
||||
if (!didDefaultsError)
|
||||
mPassInstance->Fail("Optional parameters must appear after all required parameters", methodDef->mParams[paramIdx - 1]->mParamDeclaration);
|
||||
Fail("Optional parameters must appear after all required parameters", methodDef->mParams[paramIdx - 1]->mParamDeclaration);
|
||||
didDefaultsError = true;
|
||||
}
|
||||
}
|
||||
|
@ -632,6 +632,14 @@ BfMethodDef* BfDefBuilder::CreateMethodDef(BfMethodDeclaration* methodDeclaratio
|
|||
return methodDef;
|
||||
}
|
||||
|
||||
BfError* BfDefBuilder::Fail(const StringImpl& errorStr, BfAstNode* refNode)
|
||||
{
|
||||
auto error = mPassInstance->Fail(errorStr, refNode);
|
||||
if (error != NULL)
|
||||
error->mProject = mCurSource->mProject;
|
||||
return error;
|
||||
}
|
||||
|
||||
void BfDefBuilder::Visit(BfMethodDeclaration* methodDeclaration)
|
||||
{
|
||||
if (mCurTypeDef == NULL)
|
||||
|
@ -742,7 +750,7 @@ void BfDefBuilder::ParseAttributes(BfAttributeDirective* attributes, BfMethodDef
|
|||
{
|
||||
if (methodDef->mParams.size() != 2)
|
||||
{
|
||||
mPassInstance->Fail("Commutable attributes can only be applied to methods with two arguments", attributes->mAttributeTypeRef);
|
||||
Fail("Commutable attributes can only be applied to methods with two arguments", attributes->mAttributeTypeRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -790,7 +798,7 @@ void BfDefBuilder::Visit(BfPropertyDeclaration* propertyDeclaration)
|
|||
|
||||
if (propertyDeclaration->mConstSpecifier != NULL)
|
||||
{
|
||||
mPassInstance->Fail("Const properties are not allowed", propertyDeclaration->mConstSpecifier);
|
||||
Fail("Const properties are not allowed", propertyDeclaration->mConstSpecifier);
|
||||
}
|
||||
|
||||
HashNode(*mSignatureHashCtx, propertyDeclaration, propertyDeclaration->mDefinitionBlock);
|
||||
|
@ -871,7 +879,7 @@ void BfDefBuilder::Visit(BfPropertyDeclaration* propertyDeclaration)
|
|||
{
|
||||
BfProtection newProtection = GetProtection(methodDeclaration->mProtectionSpecifier);
|
||||
if (newProtection > methodDef->mProtection)
|
||||
mPassInstance->Fail(StrFormat("the accessibility modifier of the 'get' accessor must be more restrictive than the property or indexer '%s'", propertyDef->mName.c_str()),
|
||||
Fail(StrFormat("the accessibility modifier of the 'get' accessor must be more restrictive than the property or indexer '%s'", propertyDef->mName.c_str()),
|
||||
methodDeclaration->mProtectionSpecifier);
|
||||
methodDef->mProtection = newProtection;
|
||||
}
|
||||
|
@ -997,7 +1005,7 @@ void BfDefBuilder::Visit(BfFieldDeclaration* fieldDeclaration)
|
|||
// This check is a bit of a hack to determine the difference between a "MemberType mMember" and a proper case entry of "mMember(TupleType)"
|
||||
if (!isEnumEntryDecl)
|
||||
{
|
||||
mPassInstance->Fail("Non-static field declarations are not allowed in enums", fieldDeclaration);
|
||||
Fail("Non-static field declarations are not allowed in enums", fieldDeclaration);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1231,7 +1239,7 @@ void BfDefBuilder::Visit(BfTypeDeclaration* typeDeclaration)
|
|||
mCurTypeDef->mName = mSystem->GetAtom(typeDeclaration->mNameNode->ToString());
|
||||
if (mCurTypeDef->mName->mIsSystemType)
|
||||
{
|
||||
mPassInstance->Fail(StrFormat("Type name '%s' is reserved", typeDeclaration->mNameNode->ToString().c_str()), typeDeclaration->mNameNode);
|
||||
Fail(StrFormat("Type name '%s' is reserved", typeDeclaration->mNameNode->ToString().c_str()), typeDeclaration->mNameNode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1245,7 +1253,7 @@ void BfDefBuilder::Visit(BfTypeDeclaration* typeDeclaration)
|
|||
if ((outerTypeDef == NULL) && (typeDeclaration->mProtectionSpecifier->GetToken() != BfToken_Public))
|
||||
{
|
||||
//CS1527
|
||||
mPassInstance->Fail("Elements defined in a namespace cannot be explicitly declared as private, protected, or protected internal", typeDeclaration->mProtectionSpecifier);
|
||||
Fail("Elements defined in a namespace cannot be explicitly declared as private, protected, or protected internal", typeDeclaration->mProtectionSpecifier);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1677,13 +1685,13 @@ void BfDefBuilder::FinishTypeDef(bool wantsToString)
|
|||
{
|
||||
if (hasStaticCtor)
|
||||
{
|
||||
mPassInstance->Fail("Only one static constructor is allowed", method->mMethodDeclaration);
|
||||
Fail("Only one static constructor is allowed", method->mMethodDeclaration);
|
||||
method->mIsStatic = false;
|
||||
}
|
||||
|
||||
if (method->mParams.size() != 0)
|
||||
{
|
||||
mPassInstance->Fail("Static constructor cannot declare parameters", method->mMethodDeclaration);
|
||||
Fail("Static constructor cannot declare parameters", method->mMethodDeclaration);
|
||||
method->mIsStatic = false;
|
||||
}
|
||||
|
||||
|
@ -1740,7 +1748,7 @@ void BfDefBuilder::FinishTypeDef(bool wantsToString)
|
|||
{
|
||||
if (hasStaticDtor)
|
||||
{
|
||||
mPassInstance->Fail("Only one static constructor is allowed", method->mMethodDeclaration);
|
||||
Fail("Only one static constructor is allowed", method->mMethodDeclaration);
|
||||
method->mIsStatic = false;
|
||||
}
|
||||
|
||||
|
@ -1750,14 +1758,14 @@ void BfDefBuilder::FinishTypeDef(bool wantsToString)
|
|||
{
|
||||
if (hasDtor)
|
||||
{
|
||||
mPassInstance->Fail("Only one destructor is allowed", method->mMethodDeclaration);
|
||||
Fail("Only one destructor is allowed", method->mMethodDeclaration);
|
||||
method->mIsStatic = false;
|
||||
}
|
||||
hasDtor = true;
|
||||
}
|
||||
|
||||
if (method->mParams.size() != 0)
|
||||
mPassInstance->Fail("Destructors cannot declare parameters", method->GetMethodDeclaration()->mParams[0]);
|
||||
Fail("Destructors cannot declare parameters", method->GetMethodDeclaration()->mParams[0]);
|
||||
}
|
||||
else if (method->mMethodType == BfMethodType_Normal)
|
||||
{
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
void ParseAttributes(BfAttributeDirective* attributes, BfMethodDef* methodDef);
|
||||
void ParseAttributes(BfAttributeDirective* attributes, BfTypeDef* typeDef);
|
||||
BfMethodDef* CreateMethodDef(BfMethodDeclaration* methodDecl, BfMethodDef* outerMethodDef = NULL);
|
||||
BfError* Fail(const StringImpl& errorStr, BfAstNode* refNode);
|
||||
|
||||
public:
|
||||
BfDefBuilder(BfSystem* bfSystem);
|
||||
|
|
|
@ -2839,7 +2839,7 @@ BfTypedValue BfExprEvaluator::LookupIdentifier(BfAstNode* refNode, const StringI
|
|||
varSkipCount--;
|
||||
}
|
||||
|
||||
if (varDecl->mNotCaptured)
|
||||
if ((varDecl != NULL) && (varDecl->mNotCaptured))
|
||||
{
|
||||
mModule->Fail("Local variable is not captured", refNode);
|
||||
}
|
||||
|
|
|
@ -2610,6 +2610,7 @@ BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPers
|
|||
}
|
||||
if (bfError != NULL)
|
||||
{
|
||||
bfError->mProject = mProject;
|
||||
bfError->mIsPersistent = isPersistent;
|
||||
bfError->mIsWhileSpecializing = isWhileSpecializing;
|
||||
|
||||
|
@ -2629,7 +2630,10 @@ BfError* BfModule::FailAfter(const StringImpl& error, BfAstNode* refNode)
|
|||
refNode = BfNodeToNonTemporary(refNode);
|
||||
|
||||
mHadBuildError = true;
|
||||
return mCompiler->mPassInstance->FailAfter(error, refNode);
|
||||
BfError* bfError = mCompiler->mPassInstance->FailAfter(error, refNode);
|
||||
if (bfError != NULL)
|
||||
bfError->mProject = mProject;
|
||||
return bfError;
|
||||
}
|
||||
|
||||
BfError* BfModule::Warn(int warningNum, const StringImpl& warning, BfAstNode* refNode, bool isPersistent)
|
||||
|
@ -2692,6 +2696,7 @@ BfError* BfModule::Warn(int warningNum, const StringImpl& warning, BfAstNode* re
|
|||
BfError* bfError = mCompiler->mPassInstance->WarnAt(warningNum, warning, refNode->GetSourceData(), refNode->GetSrcStart(), refNode->GetSrcLength());
|
||||
if (bfError != NULL)
|
||||
{
|
||||
bfError->mProject = mProject;
|
||||
AddFailType(mCurTypeInstance);
|
||||
|
||||
mHadBuildWarning = true;
|
||||
|
|
|
@ -197,15 +197,18 @@ BfAstNode* BfReducer::Fail(const StringImpl& errorMsg, BfAstNode* refNode)
|
|||
mStmtHasError = true;
|
||||
if (mPassInstance->HasLastFailedAt(refNode)) // No duplicate failures
|
||||
return NULL;
|
||||
mPassInstance->Fail(errorMsg, refNode);
|
||||
auto error = mPassInstance->Fail(errorMsg, refNode);
|
||||
if (error != NULL)
|
||||
error->mProject = mSource->mProject;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BfAstNode* BfReducer::FailAfter(const StringImpl& errorMsg, BfAstNode* prevNode)
|
||||
{
|
||||
mStmtHasError = true;
|
||||
mPassInstance->FailAfter(errorMsg, prevNode);
|
||||
|
||||
auto error = mPassInstance->FailAfter(errorMsg, prevNode);
|
||||
if (error != NULL)
|
||||
error->mProject = mSource->mProject;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -4053,11 +4056,11 @@ BfAstNode* BfReducer::DoCreateStatement(BfAstNode* node, CreateStmtFlags createS
|
|||
if ((unaryOperatorExpr->mOp == BfUnaryOp_Ref) || (unaryOperatorExpr->mOp == BfUnaryOp_Mut) || (unaryOperatorExpr->mOp == BfUnaryOp_Out))
|
||||
{
|
||||
if (unaryOperatorExpr->mOp == BfUnaryOp_Ref)
|
||||
mPassInstance->Fail("Cannot use 'ref' in this context", unaryOperatorExpr);
|
||||
Fail("Cannot use 'ref' in this context", unaryOperatorExpr);
|
||||
else if (unaryOperatorExpr->mOp == BfUnaryOp_Mut)
|
||||
mPassInstance->Fail("Cannot use 'mut' in this context", unaryOperatorExpr);
|
||||
Fail("Cannot use 'mut' in this context", unaryOperatorExpr);
|
||||
else
|
||||
mPassInstance->Fail("Cannot use 'out' in this context", unaryOperatorExpr);
|
||||
Fail("Cannot use 'out' in this context", unaryOperatorExpr);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -4246,7 +4249,7 @@ BfAstNode* BfReducer::CreateStatement(BfAstNode* node, CreateStmtFlags createStm
|
|||
auto nextNode = mVisitorPos.GetNext();
|
||||
if (nextNode != NULL)
|
||||
{
|
||||
mPassInstance->FailAfter("Semicolon expected", expr);
|
||||
FailAfter("Semicolon expected", expr);
|
||||
}
|
||||
|
||||
return expr;
|
||||
|
@ -4295,7 +4298,9 @@ BfAstNode* BfReducer::CreateStatement(BfAstNode* node, CreateStmtFlags createStm
|
|||
if (((createStmtFlags & CreateStmtFlags_AllowUnterminatedExpression) != 0) && (origStmtNode->IsA<BfExpression>()) && (nextNode == NULL))
|
||||
return stmt;
|
||||
|
||||
mPassInstance->FailAfterAt("Semicolon expected", node->GetSourceData(), stmt->GetSrcEnd() - 1);
|
||||
auto error = mPassInstance->FailAfterAt("Semicolon expected", node->GetSourceData(), stmt->GetSrcEnd() - 1);
|
||||
if (error != NULL)
|
||||
error->mProject = mSource->mProject;
|
||||
mPrevStmtHadError = true;
|
||||
return stmt;
|
||||
}
|
||||
|
@ -4881,7 +4886,7 @@ BfTypeReference* BfReducer::DoCreateTypeRef(BfAstNode* firstNode, CreateTypeRefF
|
|||
|
||||
if ((!doAddType) && (isBoundName))
|
||||
{
|
||||
mPassInstance->FailAfter("Expected type", genericInstance);
|
||||
FailAfter("Expected type", genericInstance);
|
||||
}
|
||||
if ((doAddType) && (!isUnboundName))
|
||||
{
|
||||
|
@ -5539,7 +5544,7 @@ BfAstNode* BfReducer::ReadTypeMember(BfTokenNode* tokenNode, int depth)
|
|||
innerType->mAttributes = attributes;
|
||||
return innerType;
|
||||
}
|
||||
mPassInstance->Fail("Invalid target for attributes", memberNode);
|
||||
Fail("Invalid target for attributes", memberNode);
|
||||
return memberNode;
|
||||
}
|
||||
|
||||
|
@ -8595,9 +8600,9 @@ BfTokenNode* BfReducer::ParseMethodParams(BfAstNode* node, SizedArrayImpl<BfPara
|
|||
{
|
||||
auto node = mVisitorPos.Get(errIdx);
|
||||
if (auto token = BfNodeDynCast<BfTokenNode>(node))
|
||||
mPassInstance->Fail("Unexpected token", node);
|
||||
Fail("Unexpected token", node);
|
||||
else
|
||||
mPassInstance->Fail("Unexpected identifier", node);
|
||||
Fail("Unexpected identifier", node);
|
||||
AddErrorNode(node);
|
||||
}
|
||||
|
||||
|
|
|
@ -5568,7 +5568,7 @@ void BfModule::Visit(BfForEachStatement* forEachStmt)
|
|||
autoComplete->CheckTypeRef(forEachStmt->mVariableTypeRef, false);
|
||||
varType = ResolveTypeRef(forEachStmt->mVariableTypeRef, BfPopulateType_Data, BfResolveTypeRefFlag_AllowRef);
|
||||
}
|
||||
|
||||
|
||||
if (varType == NULL)
|
||||
varType = mContext->mBfObjectType;
|
||||
bool isArray = target.mType->IsArray();
|
||||
|
@ -5979,6 +5979,9 @@ void BfModule::Visit(BfForEachStatement* forEachStmt)
|
|||
|
||||
scopeData.mIsLoop = true;
|
||||
|
||||
if ((autoComplete != NULL) && (forEachStmt->mVariableTypeRef != NULL))
|
||||
autoComplete->CheckVarResolution(forEachStmt->mVariableTypeRef, varType);
|
||||
|
||||
if (isArray || isSizedArray)
|
||||
mBfIRBuilder->CreateStore(GetConstValue(0), itr.mValue);
|
||||
|
||||
|
|
|
@ -1391,17 +1391,21 @@ BfError* BfPassInstance::Fail(const StringImpl& error)
|
|||
return mErrors.back();
|
||||
}
|
||||
|
||||
BfError* BfPassInstance::Fail(const StringImpl& error, BfAstNode* refNode)
|
||||
BfError* BfPassInstance::Fail(const StringImpl& errorStr, BfAstNode* refNode)
|
||||
{
|
||||
BP_ZONE("BfPassInstance::Fail");
|
||||
|
||||
BfError* error = NULL;
|
||||
|
||||
mFailedIdx++;
|
||||
if ((refNode == NULL) || (refNode->IsTemporary()))
|
||||
return Fail(error);
|
||||
error = Fail(errorStr);
|
||||
else if (refNode->IsA<BfBlock>())
|
||||
return FailAt(error, refNode->GetSourceData(), refNode->GetSrcStart(), 1);
|
||||
error = FailAt(errorStr, refNode->GetSourceData(), refNode->GetSrcStart(), 1);
|
||||
else
|
||||
return FailAt(error, refNode->GetSourceData(), refNode->GetSrcStart(), refNode->GetSrcLength());
|
||||
error = FailAt(errorStr, refNode->GetSourceData(), refNode->GetSrcStart(), refNode->GetSrcLength());
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
BfError* BfPassInstance::FailAfter(const StringImpl& error, BfAstNode* refNode)
|
||||
|
@ -1504,7 +1508,7 @@ BfError* BfPassInstance::WarnAt(int warningNumber, const StringImpl& warning, Bf
|
|||
if ((int)mErrors.size() > 1)
|
||||
errorStart += StrFormat("(%d)", mErrors.size());
|
||||
if (warningNumber > 0)
|
||||
errorStart += StrFormat(": CS%04d", warningNumber);
|
||||
errorStart += StrFormat(": BF%04d", warningNumber);
|
||||
MessageAt(":warn", errorStart + ": " + warning, bfParser, srcIdx);
|
||||
}
|
||||
return errorVal;
|
||||
|
@ -3334,7 +3338,8 @@ BF_EXPORT int BF_CALLTYPE BfPassInstance_GetErrorCount(BfPassInstance* bfPassIns
|
|||
return (int)bfPassInstance->mErrors.size();
|
||||
}
|
||||
|
||||
BF_EXPORT const char* BF_CALLTYPE BfPassInstance_GetErrorData(BfPassInstance* bfPassInstance, int errorIdx, bool& outIsWarning, bool& outIsAfter, bool& outIsDeferred, bool& outIsWhileSpecializing, bool& outIsPersistent, int& outSrcStart, int& outSrcEnd, int& outMoreInfoCount)
|
||||
BF_EXPORT const char* BF_CALLTYPE BfPassInstance_GetErrorData(BfPassInstance* bfPassInstance, int errorIdx, int& outCode, bool& outIsWarning, bool& outIsAfter, bool& outIsDeferred, bool& outIsWhileSpecializing, bool& outIsPersistent,
|
||||
char*& projectName, char*& fileName, int& outSrcStart, int& outSrcEnd, int* outLine, int* outColumn, int& outMoreInfoCount)
|
||||
{
|
||||
BfError* bfError = bfPassInstance->mErrors[errorIdx];
|
||||
outIsWarning = bfError->mIsWarning;
|
||||
|
@ -3342,13 +3347,33 @@ BF_EXPORT const char* BF_CALLTYPE BfPassInstance_GetErrorData(BfPassInstance* bf
|
|||
outIsDeferred = bfError->mIsDeferred;
|
||||
outIsWhileSpecializing = bfError->mIsWhileSpecializing;
|
||||
outIsPersistent = bfError->mIsPersistent;
|
||||
outCode = bfError->mWarningNumber;
|
||||
if (bfError->mProject != NULL)
|
||||
projectName = (char*)bfError->mProject->mName.c_str();
|
||||
if (bfError->mSource != NULL)
|
||||
{
|
||||
String* srcFileName;
|
||||
if (bfPassInstance->mSourceFileNameMap.TryGetValue(bfError->mSource, &srcFileName))
|
||||
{
|
||||
fileName = (char*)srcFileName->c_str();
|
||||
}
|
||||
|
||||
if (outLine != NULL)
|
||||
{
|
||||
auto parserData = bfError->mSource->ToParserData();
|
||||
if (parserData != NULL)
|
||||
{
|
||||
parserData->GetLineCharAtIdx(bfError->mSrcStart, *outLine, *outColumn);
|
||||
}
|
||||
}
|
||||
}
|
||||
outSrcStart = bfError->mSrcStart;
|
||||
outSrcEnd = bfError->mSrcEnd;
|
||||
outMoreInfoCount = (int)bfError->mMoreInfo.size();
|
||||
return bfError->mError.c_str();
|
||||
}
|
||||
|
||||
BF_EXPORT const char* BfPassInstance_Error_GetMoreInfoData(BfPassInstance* bfPassInstance, int errorIdx, int moreInfoIdx, char*& fileName, int& srcStart, int& srcEnd)
|
||||
BF_EXPORT const char* BfPassInstance_Error_GetMoreInfoData(BfPassInstance* bfPassInstance, int errorIdx, int moreInfoIdx, char*& fileName, int& srcStart, int& srcEnd, int* outLine, int* outColumn)
|
||||
{
|
||||
BfError* rootError = bfPassInstance->mErrors[errorIdx];
|
||||
BfMoreInfo* moreInfo = rootError->mMoreInfo[moreInfoIdx];
|
||||
|
|
|
@ -1114,17 +1114,19 @@ public:
|
|||
bool mIsPersistent;
|
||||
bool mIsWhileSpecializing;
|
||||
bool mIgnore;
|
||||
BfProject* mProject;
|
||||
String mError;
|
||||
int mWarningNumber;
|
||||
Array<BfMoreInfo*> mMoreInfo;
|
||||
|
||||
public:
|
||||
BfError()
|
||||
{
|
||||
{
|
||||
mIsAfter = false;
|
||||
mIsPersistent = false;
|
||||
mIsWhileSpecializing = false;
|
||||
mIgnore = false;
|
||||
mProject = NULL;
|
||||
mWarningNumber = 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue