mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed const expr creation during box checking
This commit is contained in:
parent
7e0c25ef8f
commit
006e738f69
2 changed files with 14 additions and 7 deletions
|
@ -1647,7 +1647,7 @@ public:
|
||||||
BfUnknownSizedArrayType* CreateUnknownSizedArrayType(BfType* resolvedType, BfType* sizeParam);
|
BfUnknownSizedArrayType* CreateUnknownSizedArrayType(BfType* resolvedType, BfType* sizeParam);
|
||||||
BfPointerType* CreatePointerType(BfType* resolvedType);
|
BfPointerType* CreatePointerType(BfType* resolvedType);
|
||||||
BfPointerType* CreatePointerType(BfTypeReference* typeRef);
|
BfPointerType* CreatePointerType(BfTypeReference* typeRef);
|
||||||
BfConstExprValueType* CreateConstExprValueType(const BfTypedValue& typedValue);
|
BfConstExprValueType* CreateConstExprValueType(const BfTypedValue& typedValue, bool allowCreate = true);
|
||||||
BfBoxedType* CreateBoxedType(BfType* resolvedTypeRef, bool allowCreate = true);
|
BfBoxedType* CreateBoxedType(BfType* resolvedTypeRef, bool allowCreate = true);
|
||||||
BfTypeInstance* CreateTupleType(const BfTypeVector& fieldTypes, const Array<String>& fieldNames, bool allowVar = false);
|
BfTypeInstance* CreateTupleType(const BfTypeVector& fieldTypes, const Array<String>& fieldNames, bool allowVar = false);
|
||||||
BfTypeInstance* SantizeTupleType(BfTypeInstance* tupleType);
|
BfTypeInstance* SantizeTupleType(BfTypeInstance* tupleType);
|
||||||
|
|
|
@ -4939,8 +4939,11 @@ BfPointerType* BfModule::CreatePointerType(BfType* resolvedType)
|
||||||
return resolvedPointerType;
|
return resolvedPointerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
BfConstExprValueType* BfModule::CreateConstExprValueType(const BfTypedValue& typedValue)
|
BfConstExprValueType* BfModule::CreateConstExprValueType(const BfTypedValue& typedValue, bool allowCreate)
|
||||||
{
|
{
|
||||||
|
BfPopulateType populateType = allowCreate ? BfPopulateType_Data : BfPopulateType_Identity;
|
||||||
|
BfResolveTypeRefFlags resolveFlags = allowCreate ? BfResolveTypeRefFlag_None : BfResolveTypeRefFlag_NoCreate;
|
||||||
|
|
||||||
auto variant = TypedValueToVariant(NULL, typedValue);
|
auto variant = TypedValueToVariant(NULL, typedValue);
|
||||||
if (variant.mTypeCode == BfTypeCode_None)
|
if (variant.mTypeCode == BfTypeCode_None)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -4950,11 +4953,12 @@ BfConstExprValueType* BfModule::CreateConstExprValueType(const BfTypedValue& typ
|
||||||
constExprValueType->mType = typedValue.mType;
|
constExprValueType->mType = typedValue.mType;
|
||||||
constExprValueType->mValue = variant;
|
constExprValueType->mValue = variant;
|
||||||
|
|
||||||
auto resolvedConstExprValueType = (BfConstExprValueType*)ResolveType(constExprValueType);
|
auto resolvedConstExprValueType = (BfConstExprValueType*)ResolveType(constExprValueType, populateType, resolveFlags);
|
||||||
if (resolvedConstExprValueType != constExprValueType)
|
if (resolvedConstExprValueType != constExprValueType)
|
||||||
mContext->mConstExprValueTypePool.GiveBack(constExprValueType);
|
mContext->mConstExprValueTypePool.GiveBack(constExprValueType);
|
||||||
|
|
||||||
BF_ASSERT(resolvedConstExprValueType->mValue.mInt64 == constExprValueType->mValue.mInt64);
|
if (resolvedConstExprValueType != NULL)
|
||||||
|
BF_ASSERT(resolvedConstExprValueType->mValue.mInt64 == constExprValueType->mValue.mInt64);
|
||||||
|
|
||||||
return resolvedConstExprValueType;
|
return resolvedConstExprValueType;
|
||||||
}
|
}
|
||||||
|
@ -5410,7 +5414,10 @@ BfBoxedType* BfModule::CreateBoxedType(BfType* resolvedTypeRef, bool allowCreate
|
||||||
BfTypeVector typeVector;
|
BfTypeVector typeVector;
|
||||||
typeVector.Add(sizedArrayType->mElementType);
|
typeVector.Add(sizedArrayType->mElementType);
|
||||||
auto sizeValue = BfTypedValue(GetConstValue(sizedArrayType->mElementCount), GetPrimitiveType(BfTypeCode_IntPtr));
|
auto sizeValue = BfTypedValue(GetConstValue(sizedArrayType->mElementCount), GetPrimitiveType(BfTypeCode_IntPtr));
|
||||||
typeVector.Add(CreateConstExprValueType(sizeValue));
|
auto sizeValueType = CreateConstExprValueType(sizeValue, allowCreate);
|
||||||
|
if (sizeValueType == NULL)
|
||||||
|
return NULL;
|
||||||
|
typeVector.Add(sizeValueType);
|
||||||
resolvedTypeRef = ResolveTypeDef(mCompiler->mSizedArrayTypeDef, typeVector, populateType, resolveFlags);
|
resolvedTypeRef = ResolveTypeDef(mCompiler->mSizedArrayTypeDef, typeVector, populateType, resolveFlags);
|
||||||
if (resolvedTypeRef == NULL)
|
if (resolvedTypeRef == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue