mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Added IncludeAllMethods
This commit is contained in:
parent
fbe2407ffb
commit
93facda6b2
2 changed files with 24 additions and 8 deletions
|
@ -120,12 +120,14 @@ namespace System
|
||||||
[AttributeUsage(.Class | .Struct | .Interface | .Method | .Constructor)]
|
[AttributeUsage(.Class | .Struct | .Interface | .Method | .Constructor)]
|
||||||
public struct AlwaysIncludeAttribute : Attribute
|
public struct AlwaysIncludeAttribute : Attribute
|
||||||
{
|
{
|
||||||
bool mAssumeInstantiated;
|
|
||||||
|
|
||||||
public bool AssumeInstantiated
|
public bool AssumeInstantiated
|
||||||
{
|
{
|
||||||
get { return mAssumeInstantiated; }
|
set { }
|
||||||
set mut { mAssumeInstantiated = value; }
|
}
|
||||||
|
|
||||||
|
public bool IncludeAllMethods
|
||||||
|
{
|
||||||
|
set { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3643,6 +3643,8 @@ void BfModule::DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance)
|
||||||
implRequired = true;
|
implRequired = true;
|
||||||
declRequired = true;
|
declRequired = true;
|
||||||
}
|
}
|
||||||
|
if (typeInstance->mIncludeAllMethods)
|
||||||
|
implRequired = true;
|
||||||
|
|
||||||
if (typeInstance->IsInterface())
|
if (typeInstance->IsInterface())
|
||||||
declRequired = true;
|
declRequired = true;
|
||||||
|
@ -8319,7 +8321,9 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp
|
||||||
{
|
{
|
||||||
if ((genericParamInst->mGenericParamFlags & (BfGenericParamFlag_Class | BfGenericParamFlag_StructPtr)) ||
|
if ((genericParamInst->mGenericParamFlags & (BfGenericParamFlag_Class | BfGenericParamFlag_StructPtr)) ||
|
||||||
((genericParamInst->mTypeConstraint != NULL) &&
|
((genericParamInst->mTypeConstraint != NULL) &&
|
||||||
((genericParamInst->mTypeConstraint->IsPointer()) || (genericParamInst->mTypeConstraint->IsObjectOrInterface()))))
|
((genericParamInst->mTypeConstraint->IsPointer()) ||
|
||||||
|
(genericParamInst->mTypeConstraint->IsInstanceOf(mCompiler->mFunctionTypeDef)) ||
|
||||||
|
(genericParamInst->mTypeConstraint->IsObjectOrInterface()))))
|
||||||
{
|
{
|
||||||
return GetDefaultValue(toType);
|
return GetDefaultValue(toType);
|
||||||
}
|
}
|
||||||
|
@ -8371,6 +8375,7 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp
|
||||||
auto genericParamInst = GetGenericParamInstance((BfGenericParamType*)toType);
|
auto genericParamInst = GetGenericParamInstance((BfGenericParamType*)toType);
|
||||||
if (genericParamInst->mGenericParamFlags & BfGenericParamFlag_Var)
|
if (genericParamInst->mGenericParamFlags & BfGenericParamFlag_Var)
|
||||||
return GetDefaultValue(toType);
|
return GetDefaultValue(toType);
|
||||||
|
|
||||||
if (typedVal.mType->IsNull())
|
if (typedVal.mType->IsNull())
|
||||||
{
|
{
|
||||||
bool allowCast = (genericParamInst->mGenericParamFlags & BfGenericParamFlag_Class) || (genericParamInst->mGenericParamFlags & BfGenericParamFlag_StructPtr);
|
bool allowCast = (genericParamInst->mGenericParamFlags & BfGenericParamFlag_Class) || (genericParamInst->mGenericParamFlags & BfGenericParamFlag_StructPtr);
|
||||||
|
@ -8385,9 +8390,18 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp
|
||||||
auto castedVal = CastToValue(srcNode, typedVal, genericParamInst->mTypeConstraint, (BfCastFlags)(castFlags | BfCastFlags_SilentFail));
|
auto castedVal = CastToValue(srcNode, typedVal, genericParamInst->mTypeConstraint, (BfCastFlags)(castFlags | BfCastFlags_SilentFail));
|
||||||
if (castedVal)
|
if (castedVal)
|
||||||
return castedVal;
|
return castedVal;
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: WHy did we do 'GetDefaultValue'? This messes up setting up method param defaults, which is important for inferring const generic params
|
if (explicitCast)
|
||||||
//return GetDefaultValue(toType);
|
{
|
||||||
|
if ((genericParamInst->mGenericParamFlags & BfGenericParamFlag_StructPtr) ||
|
||||||
|
((genericParamInst->mTypeConstraint != NULL) && genericParamInst->mTypeConstraint->IsInstanceOf(mCompiler->mFunctionTypeDef)))
|
||||||
|
{
|
||||||
|
auto voidPtrType = CreatePointerType(GetPrimitiveType(BfTypeCode_None));
|
||||||
|
auto castedVal = CastToValue(srcNode, typedVal, voidPtrType, (BfCastFlags)(castFlags | BfCastFlags_SilentFail));
|
||||||
|
if (castedVal)
|
||||||
|
return castedVal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue