mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Soften splat error in BfModule::Cast
This commit is contained in:
parent
a5a7e6efe0
commit
0c6bf2d6b5
3 changed files with 37 additions and 5 deletions
|
@ -3536,6 +3536,26 @@ void BfModule::FatalError(const StringImpl& error, const char* file, int line)
|
|||
BfpSystem_FatalError(fullError.c_str(), "FATAL MODULE ERROR");
|
||||
}
|
||||
|
||||
void BfModule::InternalError(const StringImpl& error, BfAstNode* refNode, const char* file, int line)
|
||||
{
|
||||
String fullError = error;
|
||||
|
||||
if (file != NULL)
|
||||
fullError += StrFormat(" at %s:%d", file, line);
|
||||
|
||||
fullError += StrFormat("\nModule: %s", mModuleName.c_str());
|
||||
|
||||
if (mCurTypeInstance != NULL)
|
||||
fullError += StrFormat("\nType: %s", TypeToString(mCurTypeInstance).c_str());
|
||||
if (mCurMethodInstance != NULL)
|
||||
fullError += StrFormat("\nMethod: %s", MethodToString(mCurMethodInstance).c_str());
|
||||
|
||||
if ((mCurFilePosition.mFileInstance != NULL) && (mCurFilePosition.mFileInstance->mParser != NULL))
|
||||
fullError += StrFormat("\nSource Location: %s:%d", mCurFilePosition.mFileInstance->mParser->mFileName.c_str(), mCurFilePosition.mCurLine + 1);
|
||||
|
||||
Fail(String("INTERNAL ERROR: ") + fullError, refNode);
|
||||
}
|
||||
|
||||
void BfModule::NotImpl(BfAstNode* astNode)
|
||||
{
|
||||
Fail("INTERNAL ERROR: Not implemented", astNode);
|
||||
|
@ -23579,11 +23599,16 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool
|
|||
auto typeDef = typeInstance->mTypeDef;
|
||||
auto methodDef = mCurMethodInstance->mMethodDef;
|
||||
|
||||
BF_ASSERT(methodDef->mName != "__ASSERTNAME");
|
||||
if (methodDef->mName == "__FATALERRORNAME")
|
||||
BFMODULE_FATAL(this, "__FATALERRORNAME");
|
||||
if (methodDef->mName == "__STACKOVERFLOW")
|
||||
StackOverflow();
|
||||
if (methodDef->mName.StartsWith('_'))
|
||||
{
|
||||
BF_ASSERT(methodDef->mName != "__ASSERTNAME");
|
||||
if (methodDef->mName == "__FATALERRORNAME")
|
||||
BFMODULE_FATAL(this, "__FATALERRORNAME");
|
||||
if (methodDef->mName == "__STACKOVERFLOW")
|
||||
StackOverflow();
|
||||
if (methodDef->mName == "__INTERNALERROR")
|
||||
InternalError("Bad method name", methodDef->GetRefNode());
|
||||
}
|
||||
|
||||
if (typeInstance->IsClosure())
|
||||
{
|
||||
|
|
|
@ -1605,6 +1605,7 @@ public:
|
|||
|
||||
public:
|
||||
void FatalError(const StringImpl& error, const char* file = NULL, int line = -1);
|
||||
void InternalError(const StringImpl& error, BfAstNode* refNode = NULL, const char* file = NULL, int line = -1);
|
||||
void NotImpl(BfAstNode* astNode);
|
||||
void AddMethodReference(const BfMethodRef& methodRef, BfGetMethodInstanceFlags flags = BfGetMethodInstanceFlag_None);
|
||||
bool CheckProtection(BfProtection protection, BfTypeDef* checkType, bool allowProtected, bool allowPrivate);
|
||||
|
|
|
@ -14857,6 +14857,12 @@ BfTypedValue BfModule::Cast(BfAstNode* srcNode, const BfTypedValue& typedVal, Bf
|
|||
{
|
||||
if (typedVal.IsSplat())
|
||||
{
|
||||
if ((!toStructTypeInstance->IsSplattable()) && (toStructTypeInstance->mInstSize != 0))
|
||||
{
|
||||
InternalError("typedVal.IsSplat(), but !toStructTypeInstance->IsSplattable() && toStructTypeInstance->mInstSize != 0", srcNode);
|
||||
return GetDefaultTypedValue(toType, true, BfDefaultValueKind_Addr);
|
||||
}
|
||||
|
||||
BF_ASSERT(toStructTypeInstance->IsSplattable() || (toStructTypeInstance->mInstSize == 0));
|
||||
return BfTypedValue(typedVal.mValue, toStructTypeInstance, typedVal.IsThis() ? BfTypedValueKind_ThisSplatHead : BfTypedValueKind_SplatHead);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue