mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Generic outer type fixes, 'in' fixes
This commit is contained in:
parent
27a792e559
commit
89b597c913
6 changed files with 67 additions and 26 deletions
|
@ -6592,7 +6592,7 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, const BfTypedValu
|
|||
if (!mModule->mCompiler->mIsResolveOnly)
|
||||
sCallIdx++;
|
||||
int callIdx = sCallIdx;
|
||||
if (callIdx == 0x000020F9)
|
||||
if (callIdx == 0x000015CB)
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
@ -7356,15 +7356,28 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, const BfTypedValu
|
|||
|
||||
if ((wantType->IsRef()) && (!argValue.mType->IsRef()) &&
|
||||
(((callFlags & BfCreateCallFlags_AllowImplicitRef) != 0) || (wantType->IsIn())))
|
||||
argValue = mModule->ToRef(argValue, (BfRefType*)wantType);
|
||||
|
||||
if (mModule->mCurMethodState != NULL)
|
||||
{
|
||||
SetAndRestoreValue<BfScopeData*> prevScopeData(mModule->mCurMethodState->mOverrideScope, boxScopeData);
|
||||
argValue = mModule->Cast(refNode, argValue, wantType);
|
||||
auto underlyingType = wantType->GetUnderlyingType();
|
||||
if (mModule->mCurMethodState != NULL)
|
||||
{
|
||||
SetAndRestoreValue<BfScopeData*> prevScopeData(mModule->mCurMethodState->mOverrideScope, boxScopeData);
|
||||
argValue = mModule->Cast(refNode, argValue, underlyingType);
|
||||
}
|
||||
else
|
||||
argValue = mModule->Cast(refNode, argValue, underlyingType);
|
||||
if (argValue)
|
||||
argValue = mModule->ToRef(argValue, (BfRefType*)wantType);
|
||||
}
|
||||
else
|
||||
argValue = mModule->Cast(refNode, argValue, wantType);
|
||||
{
|
||||
if (mModule->mCurMethodState != NULL)
|
||||
{
|
||||
SetAndRestoreValue<BfScopeData*> prevScopeData(mModule->mCurMethodState->mOverrideScope, boxScopeData);
|
||||
argValue = mModule->Cast(refNode, argValue, wantType);
|
||||
}
|
||||
else
|
||||
argValue = mModule->Cast(refNode, argValue, wantType);
|
||||
}
|
||||
|
||||
if (!argValue)
|
||||
{
|
||||
|
|
|
@ -10917,7 +10917,7 @@ StringT<128> BfModule::MethodToString(BfMethodInstance* methodInst, BfMethodName
|
|||
methodName += methodInst->GetParamName(paramIdx);
|
||||
|
||||
auto paramInitializer = methodInst->GetParamInitializer(paramIdx);
|
||||
if (paramInitializer != NULL)
|
||||
if ((paramInitializer != NULL) && ((methodNameFlags & BfMethodNameFlag_NoAst) == 0))
|
||||
{
|
||||
methodName += " = ";
|
||||
methodName += paramInitializer->ToString();
|
||||
|
@ -12120,7 +12120,8 @@ BfTypedValue BfModule::ToRef(BfTypedValue typedValue, BfRefType* refType)
|
|||
if (refType->mRefKind == BfRefType::RefKind_Mut)
|
||||
refType = CreateRefType(typedValue.mType);
|
||||
|
||||
typedValue = MakeAddressable(typedValue);
|
||||
if (!typedValue.mType->IsValuelessType())
|
||||
typedValue = MakeAddressable(typedValue, false, true);
|
||||
return BfTypedValue(typedValue.mValue, refType);
|
||||
}
|
||||
|
||||
|
@ -12377,12 +12378,13 @@ void BfModule::AggregateSplatIntoAddr(BfTypedValue typedValue, BfIRValue addrVal
|
|||
checkTypeLambda(typedValue.mType, addrVal);
|
||||
}
|
||||
|
||||
BfTypedValue BfModule::MakeAddressable(BfTypedValue typedVal, bool forceMutable)
|
||||
BfTypedValue BfModule::MakeAddressable(BfTypedValue typedVal, bool forceMutable, bool forceAddressable)
|
||||
{
|
||||
bool wasReadOnly = typedVal.IsReadOnly();
|
||||
|
||||
if ((typedVal.mType->IsValueType()) &&
|
||||
(!typedVal.mType->IsValuelessType()))
|
||||
if ((forceAddressable) ||
|
||||
((typedVal.mType->IsValueType()) &&
|
||||
(!typedVal.mType->IsValuelessType())))
|
||||
{
|
||||
wasReadOnly = true; // Any non-addr is implicitly read-only
|
||||
|
||||
|
|
|
@ -1658,7 +1658,7 @@ public:
|
|||
BfTypedValue PrepareConst(BfTypedValue& typedValue);
|
||||
void AggregateSplatIntoAddr(BfTypedValue typedValue, BfIRValue addrVal);
|
||||
BfTypedValue AggregateSplat(BfTypedValue typedValue, BfIRValue* valueArrPtr = NULL);
|
||||
BfTypedValue MakeAddressable(BfTypedValue typedValue, bool forceMutable = false);
|
||||
BfTypedValue MakeAddressable(BfTypedValue typedValue, bool forceMutable = false, bool forceAddressable = false);
|
||||
BfTypedValue RemoveReadOnly(BfTypedValue typedValue);
|
||||
BfTypedValue CopyValue(const BfTypedValue& typedValue);
|
||||
BfIRValue ExtractSplatValue(BfTypedValue typedValue, int componentIdx, BfType* wantType = NULL, bool* isAddr = NULL);
|
||||
|
|
|
@ -10649,18 +10649,21 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
|||
|
||||
genericTypeInst->mTypeDef = typeDef;
|
||||
|
||||
auto parentTypeInstance = outerTypeInstance;
|
||||
if ((parentTypeInstance != NULL) && (parentTypeInstance->IsTypeAlias()))
|
||||
parentTypeInstance = (BfTypeInstance*)GetOuterType(parentTypeInstance)->ToTypeInstance();
|
||||
if ((parentTypeInstance != NULL) && (parentTypeInstance->IsGenericTypeInstance()))
|
||||
{
|
||||
genericTypeInst->mGenericTypeInfo->mMaxGenericDepth = BF_MAX(genericTypeInst->mGenericTypeInfo->mMaxGenericDepth, parentTypeInstance->mGenericTypeInfo->mMaxGenericDepth);
|
||||
for (int i = 0; i < startDefGenericParamIdx; i++)
|
||||
if (commonOuterType != NULL)
|
||||
{
|
||||
auto parentTypeInstance = outerTypeInstance;
|
||||
if ((parentTypeInstance != NULL) && (parentTypeInstance->IsTypeAlias()))
|
||||
parentTypeInstance = (BfTypeInstance*)GetOuterType(parentTypeInstance)->ToTypeInstance();
|
||||
if ((parentTypeInstance != NULL) && (parentTypeInstance->IsGenericTypeInstance()))
|
||||
{
|
||||
genericTypeInst->mGenericTypeInfo->mGenericParams.push_back(parentTypeInstance->mGenericTypeInfo->mGenericParams[i]->AddRef());
|
||||
genericTypeInst->mGenericTypeInfo->mTypeGenericArguments.push_back(parentTypeInstance->mGenericTypeInfo->mTypeGenericArguments[i]);
|
||||
auto typeGenericArg = genericTypeInst->mGenericTypeInfo->mTypeGenericArguments[i];
|
||||
genericTypeInst->mGenericTypeInfo->mIsUnspecialized |= typeGenericArg->IsGenericParam() || typeGenericArg->IsUnspecializedType();
|
||||
genericTypeInst->mGenericTypeInfo->mMaxGenericDepth = BF_MAX(genericTypeInst->mGenericTypeInfo->mMaxGenericDepth, parentTypeInstance->mGenericTypeInfo->mMaxGenericDepth);
|
||||
for (int i = 0; i < startDefGenericParamIdx; i++)
|
||||
{
|
||||
genericTypeInst->mGenericTypeInfo->mGenericParams.push_back(parentTypeInstance->mGenericTypeInfo->mGenericParams[i]->AddRef());
|
||||
genericTypeInst->mGenericTypeInfo->mTypeGenericArguments.push_back(parentTypeInstance->mGenericTypeInfo->mTypeGenericArguments[i]);
|
||||
auto typeGenericArg = genericTypeInst->mGenericTypeInfo->mTypeGenericArguments[i];
|
||||
genericTypeInst->mGenericTypeInfo->mIsUnspecialized |= typeGenericArg->IsGenericParam() || typeGenericArg->IsUnspecializedType();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13912,7 +13915,7 @@ void BfModule::DoTypeToString(StringImpl& str, BfType* resolvedType, BfTypeNameF
|
|||
return;
|
||||
}
|
||||
str += "method reference ";
|
||||
str += MethodToString(methodInstance);
|
||||
str += MethodToString(methodInstance, BfMethodNameFlag_NoAst);
|
||||
return;
|
||||
}
|
||||
else if (resolvedType->IsTypeInstance())
|
||||
|
|
|
@ -62,7 +62,8 @@ enum BfMethodNameFlags : uint8
|
|||
BfMethodNameFlag_OmitTypeName = 2,
|
||||
BfMethodNameFlag_IncludeReturnType = 4,
|
||||
BfMethodNameFlag_OmitParams = 8,
|
||||
BfMethodNameFlag_IncludeMut = 0x10
|
||||
BfMethodNameFlag_IncludeMut = 0x10,
|
||||
BfMethodNameFlag_NoAst = 0x20
|
||||
};
|
||||
|
||||
enum BfGetMethodInstanceFlags : uint16
|
||||
|
|
|
@ -104,6 +104,23 @@ namespace Tests
|
|||
return total;
|
||||
}
|
||||
|
||||
struct Valueless
|
||||
{
|
||||
}
|
||||
|
||||
public static void InCallPtr(in char8* val)
|
||||
{
|
||||
}
|
||||
|
||||
public static void InCallObj(in Object val)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void InCallValueless(in Valueless val)
|
||||
{
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void TestBasics()
|
||||
{
|
||||
|
@ -127,6 +144,11 @@ namespace Tests
|
|||
Test.Assert(self.Method5b(sa, sa2, sa3) == sa3);
|
||||
|
||||
Test.Assert(AddFloats(1.0f, 2, 3) == 6.0f);
|
||||
|
||||
InCallPtr("ABC");
|
||||
InCallObj("Hey");
|
||||
Valueless valueless;
|
||||
InCallValueless(valueless);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue