| 1564 | } |
| 1565 | |
| 1566 | BfIRValue BfModule::GetDefaultValue(BfType* type) |
| 1567 | { |
| 1568 | PopulateType(type, BfPopulateType_Data); |
| 1569 | mBfIRBuilder->PopulateType(type, BfIRPopulateType_Declaration); |
| 1570 | |
| 1571 | if (type->IsTypedPrimitive()) |
| 1572 | { |
| 1573 | auto underlyingType = type->GetUnderlyingType(); |
| 1574 | if (underlyingType == NULL) |
| 1575 | return mBfIRBuilder->CreateConst(BfTypeCode_Int64, 0); |
| 1576 | return GetDefaultValue(type->GetUnderlyingType()); |
| 1577 | } |
| 1578 | |
| 1579 | if (type->IsPointer() || type->IsObjectOrInterface() || type->IsGenericParam() || type->IsVar() || type->IsRef() || type->IsNull() || |
| 1580 | type->IsModifiedTypeType() || type->IsConcreteInterfaceType()) |
| 1581 | return mBfIRBuilder->CreateConstNull(mBfIRBuilder->MapType(type)); |
| 1582 | if ((type->IsIntegral()) || (type->IsBoolean())) |
| 1583 | { |
| 1584 | auto primType = (BfPrimitiveType*)type; |
| 1585 | return mBfIRBuilder->CreateConst(primType->mTypeDef->mTypeCode, (uint64)0); |
| 1586 | } |
| 1587 | if (type->IsFloat()) |
| 1588 | { |
| 1589 | auto primType = (BfPrimitiveType*)type; |
| 1590 | return mBfIRBuilder->CreateConst(primType->mTypeDef->mTypeCode, 0.0); |
| 1591 | } |
| 1592 | return mBfIRBuilder->CreateConstAggZero(mBfIRBuilder->MapType(type)); |
| 1593 | } |
| 1594 | |
| 1595 | BfTypedValue BfModule::GetFakeTypedValue(BfType* type) |
| 1596 | { |
no test coverage detected