MCPcopy Create free account
hub / github.com/beefytech/Beef / AreSplatsCompatible

Method AreSplatsCompatible

IDEHelper/Compiler/BfModuleTypeUtils.cpp:13216–13252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13214}
13215
13216bool BfModule::AreSplatsCompatible(BfType* fromType, BfType* toType, bool* outNeedsMemberCasting)
13217{
13218 if ((fromType->IsTypeInstance()) && (!fromType->IsSplattable()))
13219 return false;
13220 if ((toType->IsTypeInstance()) && (!toType->IsSplattable()))
13221 return false;
13222
13223 auto _GetTypes = [&](BfType* type, Array<BfType*>& types)
13224 {
13225 BfTypeUtils::SplatIterate([&](BfType* memberType) { types.Add(memberType); }, type);
13226 };
13227
13228 Array<BfType*> fromTypes;
13229 _GetTypes(fromType, fromTypes);
13230 Array<BfType*> toTypes;
13231 _GetTypes(toType, toTypes);
13232
13233 if (toTypes.size() > fromTypes.size())
13234 return false;
13235
13236 for (int i = 0; i < toTypes.size(); i++)
13237 {
13238 BfType* fromMemberType = fromTypes[i];
13239 BfType* toMemberType = toTypes[i];
13240
13241 if (fromMemberType != toMemberType)
13242 {
13243 if ((outNeedsMemberCasting != NULL) &&
13244 (fromMemberType->IsIntPtrable()) && (toMemberType->IsIntPtrable()))
13245 *outNeedsMemberCasting = true;
13246 else
13247 return false;
13248 }
13249 }
13250
13251 return true;
13252}
13253
13254BfType* BfModule::GetClosestNumericCastType(const BfTypedValue& typedVal, BfType* wantType)
13255{

Callers 1

GetUnionInnerTypeMethod · 0.80

Calls 5

IsTypeInstanceMethod · 0.45
IsSplattableMethod · 0.45
AddMethod · 0.45
sizeMethod · 0.45
IsIntPtrableMethod · 0.45

Tested by

no test coverage detected