mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Added more PreFails
This commit is contained in:
parent
af274d1790
commit
4e3442d437
2 changed files with 57 additions and 25 deletions
|
@ -8462,6 +8462,7 @@ BfTypedValue BfExprEvaluator::MatchMethod(BfAstNode* targetSrc, BfMethodBoundExp
|
|||
{
|
||||
if ((!resolvedTypeInstance->IsStruct()) && (!resolvedTypeInstance->IsTypedPrimitive()))
|
||||
{
|
||||
if (mModule->PreFail())
|
||||
mModule->Fail("Objects must be allocated through 'new' or 'scope'", targetSrc);
|
||||
return BfTypedValue();
|
||||
}
|
||||
|
@ -8747,9 +8748,15 @@ BfTypedValue BfExprEvaluator::MatchMethod(BfAstNode* targetSrc, BfMethodBoundExp
|
|||
// Would have caused a parsing error
|
||||
}
|
||||
else if (target.mType != NULL)
|
||||
{
|
||||
if (mModule->PreFail())
|
||||
mModule->Fail(StrFormat("Method '%s' does not exist in type '%s'", methodName.c_str(), mModule->TypeToString(target.mType).c_str()), targetSrc);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mModule->PreFail())
|
||||
mModule->Fail(StrFormat("Method '%s' does not exist", methodName.c_str()), targetSrc);
|
||||
}
|
||||
return BfTypedValue();
|
||||
}
|
||||
|
||||
|
@ -15898,6 +15905,7 @@ void BfExprEvaluator::DoInvocation(BfAstNode* target, BfMethodBoundExpression* m
|
|||
else
|
||||
{
|
||||
gaveUnqualifiedDotError = true;
|
||||
if (mModule->PreFail())
|
||||
mModule->Fail(StrFormat("Cannot use inferred constructor on type '%s'", mModule->TypeToString(expectingType).c_str()), memberRefExpression->mDotToken);
|
||||
}
|
||||
}
|
||||
|
@ -18868,6 +18876,8 @@ void BfExprEvaluator::DoMemberReference(BfMemberReferenceExpression* memberRefEx
|
|||
}
|
||||
else if (memberRefExpr->mMemberName != NULL)
|
||||
findName = memberRefExpr->mMemberName->ToString();
|
||||
else if (memberRefExpr->mDotToken != NULL)
|
||||
mModule->FailAfter("Member name expected", memberRefExpr->mDotToken);
|
||||
|
||||
defer
|
||||
(
|
||||
|
@ -18938,12 +18948,14 @@ void BfExprEvaluator::DoMemberReference(BfMemberReferenceExpression* memberRefEx
|
|||
{
|
||||
if (mExpectingType == NULL)
|
||||
{
|
||||
if (mModule->PreFail())
|
||||
mModule->Fail("Unqualified dot syntax can only be used when the result type can be inferred", nameRefNode);
|
||||
return;
|
||||
}
|
||||
|
||||
if (expectingTypeInst == NULL)
|
||||
{
|
||||
if (mModule->PreFail())
|
||||
mModule->Fail(StrFormat("Unqualified dot syntax cannot be used with type '%s'", mModule->TypeToString(mExpectingType).c_str()), nameRefNode);
|
||||
return;
|
||||
}
|
||||
|
@ -19054,8 +19066,11 @@ void BfExprEvaluator::DoMemberReference(BfMemberReferenceExpression* memberRefEx
|
|||
}
|
||||
|
||||
if (mResult.mType == NULL)
|
||||
{
|
||||
if (mModule->PreFail())
|
||||
mModule->Fail("Unable to find member", nameRefNode);
|
||||
}
|
||||
}
|
||||
|
||||
if ((isNullCondLookup) && (mPropDef == NULL))
|
||||
mResult = GetResult();
|
||||
|
@ -19064,7 +19079,7 @@ void BfExprEvaluator::DoMemberReference(BfMemberReferenceExpression* memberRefEx
|
|||
{
|
||||
if (outCascadeValue != NULL)
|
||||
*outCascadeValue = thisValue;
|
||||
else
|
||||
else if (mModule->PreFail())
|
||||
mModule->Fail("Unexpected cascade operation. Chaining can only be used for method invocations", memberRefExpr->mDotToken);
|
||||
}
|
||||
}
|
||||
|
@ -21381,6 +21396,7 @@ void BfExprEvaluator::PerformBinaryOperation(BfAstNode* leftExpression, BfAstNod
|
|||
(binaryOp != BfBinaryOp_LessThan) && (binaryOp != BfBinaryOp_LessThanOrEqual) &&
|
||||
(binaryOp != BfBinaryOp_GreaterThan) && (binaryOp != BfBinaryOp_GreaterThanOrEqual))
|
||||
{
|
||||
if (mModule->PreFail())
|
||||
mModule->Fail("Invalid operation on pointers", opToken);
|
||||
return;
|
||||
}
|
||||
|
@ -21397,6 +21413,7 @@ void BfExprEvaluator::PerformBinaryOperation(BfAstNode* leftExpression, BfAstNod
|
|||
{
|
||||
if (!BfBinOpEqualityCheck(binaryOp))
|
||||
{
|
||||
if (mModule->PreFail())
|
||||
mModule->Fail(StrFormat("Invalid operation between '%s' and null", mModule->TypeToString(resultType).c_str()), opToken);
|
||||
return;
|
||||
}
|
||||
|
@ -21634,9 +21651,12 @@ void BfExprEvaluator::PerformBinaryOperation(BfAstNode* leftExpression, BfAstNod
|
|||
return;
|
||||
}
|
||||
|
||||
if (mModule->PreFail())
|
||||
{
|
||||
mModule->Fail(StrFormat("Operator '%s' cannot be applied to operands of type '%s'",
|
||||
BfGetOpName(binaryOp),
|
||||
mModule->TypeToString(leftValue.mType).c_str()), opToken);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
@ -21886,6 +21906,7 @@ void BfExprEvaluator::PerformBinaryOperation(BfType* resultType, BfIRValue convL
|
|||
mModule->GetPrimitiveType(BfTypeCode_Boolean));
|
||||
break;
|
||||
default:
|
||||
if (mModule->PreFail())
|
||||
mModule->Fail("Invalid operation for booleans", opToken);
|
||||
break;
|
||||
}
|
||||
|
@ -21895,6 +21916,7 @@ void BfExprEvaluator::PerformBinaryOperation(BfType* resultType, BfIRValue convL
|
|||
|
||||
if ((!resultType->IsIntegral()) && (!resultType->IsFloat()))
|
||||
{
|
||||
if (mModule->PreFail())
|
||||
mModule->Fail(StrFormat("Cannot perform operation on type '%s'", mModule->TypeToString(resultType).c_str()), opToken);
|
||||
return;
|
||||
}
|
||||
|
@ -22052,6 +22074,7 @@ void BfExprEvaluator::PerformBinaryOperation(BfType* resultType, BfIRValue convL
|
|||
}
|
||||
break;
|
||||
default:
|
||||
if (mModule->PreFail())
|
||||
mModule->Fail("Invalid operation", opToken);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -8072,7 +8072,10 @@ BfTypedValue BfModule::CreateValueFromExpression(BfExprEvaluator& exprEvaluator,
|
|||
if ((flags & BfEvalExprFlags_InferReturnType) != 0)
|
||||
return exprEvaluator.mResult;
|
||||
if (!mCompiler->mPassInstance->HasFailed())
|
||||
{
|
||||
if (PreFail())
|
||||
Fail("INTERNAL ERROR: No expression result returned but no error caught in expression evaluator", expr);
|
||||
}
|
||||
return BfTypedValue();
|
||||
}
|
||||
auto typedVal = exprEvaluator.mResult;
|
||||
|
@ -12068,6 +12071,12 @@ BfTypedValue BfModule::ExtractValue(BfTypedValue typedValue, BfFieldInstance* fi
|
|||
|
||||
if (fieldInstance == wantFieldInstance)
|
||||
{
|
||||
if (fieldInstance->mResolvedType->IsValuelessType())
|
||||
{
|
||||
retVal = GetDefaultTypedValue(fieldInstance->mResolvedType);
|
||||
break;
|
||||
}
|
||||
|
||||
bool isAddr = false;
|
||||
BfIRValue val = ExtractSplatValue(typedValue, componentIdx, fieldInstance->mResolvedType, &isAddr);
|
||||
retVal = BfTypedValue(val, fieldInstance->mResolvedType,
|
||||
|
@ -21381,13 +21390,17 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool
|
|||
SetAndRestoreValue<bool> prevIgnoreWrites(mBfIRBuilder->mIgnoreWrites, mWantsIRIgnoreWrites || mCurMethodInstance->mIsUnspecialized || mCurTypeInstance->mResolvingVarField);
|
||||
SetAndRestoreValue<bool> prevIsCapturingMethodMatchInfo;
|
||||
SetAndRestoreValue<bool> prevAllowLockYield(mContext->mAllowLockYield, false);
|
||||
SetAndRestoreValue<BfMethodState*> prevMethodState(mCurMethodState, NULL);
|
||||
|
||||
if (mCompiler->IsAutocomplete())
|
||||
prevIsCapturingMethodMatchInfo.Init(mCompiler->mResolvePassData->mAutoComplete->mIsCapturingMethodMatchInfo, false);
|
||||
|
||||
if (mCurMethodInstance->mMethodInstanceGroup->mOnDemandKind == BfMethodOnDemandKind_NoDecl_AwaitingReference)
|
||||
mCurMethodInstance->mMethodInstanceGroup->mOnDemandKind = BfMethodOnDemandKind_Decl_AwaitingReference;
|
||||
|
||||
BfMethodState methodState;
|
||||
SetAndRestoreValue<BfMethodState*> prevMethodState(mCurMethodState, &methodState);
|
||||
methodState.mTempKind = BfMethodState::TempKind_Static;
|
||||
|
||||
defer({ mCurMethodInstance->mHasBeenDeclared = true; });
|
||||
|
||||
// If we are doing this then we may end up creating methods when var types are unknown still, failing on splat/zero-sized info
|
||||
|
@ -21890,10 +21903,6 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool
|
|||
Fail("Cannot specify a default value for a 'params' parameter", refNode);
|
||||
}
|
||||
|
||||
BfMethodState methodState;
|
||||
SetAndRestoreValue<BfMethodState*> prevMethodState(mCurMethodState, &methodState);
|
||||
methodState.mTempKind = BfMethodState::TempKind_Static;
|
||||
|
||||
BfTypedValue defaultValue;
|
||||
if (resolvedParamType->IsConstExprValue())
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue