mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Fixed throw error
This commit is contained in:
parent
4adec702c7
commit
b094bf4002
1 changed files with 1 additions and 21 deletions
|
@ -3581,27 +3581,7 @@ void BfModule::Visit(BfThrowStatement* throwStmt)
|
|||
|
||||
UpdateSrcPos(throwStmt->mThrowToken);
|
||||
auto throwValue = CreateValueFromExpression(throwStmt->mExpression);
|
||||
if (throwValue)
|
||||
{
|
||||
//TODO: Actually call some sort of 'ExceptionThrown' function
|
||||
auto internalType = ResolveTypeDef(mCompiler->mInternalTypeDef);
|
||||
PopulateType(internalType);
|
||||
auto moduleMethodInstance = GetMethodByName(internalType->ToTypeInstance(), "Throw");
|
||||
if (!moduleMethodInstance)
|
||||
Fail("Internal error: System.Internal doesn't contain Throw method");
|
||||
else
|
||||
{
|
||||
auto exType = moduleMethodInstance.mMethodInstance->GetParamType(0);
|
||||
|
||||
auto exTypedValue = Cast(throwStmt->mExpression, throwValue, exType);
|
||||
if ((exTypedValue) && (!mCompiler->IsSkippingExtraResolveChecks()))
|
||||
{
|
||||
SizedArray<BfIRValue, 1> llvmArgs;
|
||||
llvmArgs.push_back(exTypedValue.mValue);
|
||||
mBfIRBuilder->CreateCall(moduleMethodInstance.mFunc, llvmArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
Fail("Exceptions are not supported", throwStmt->mThrowToken);
|
||||
|
||||
if (mCurMethodInstance->mReturnType->IsVoid())
|
||||
EmitReturn(BfIRValue());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue