Add a convenience function to map a CanType+StructDecl to the mapped

CanType.  This doesn't really fit on SILBuilder, but until StructType 
and BoundGenericStructType are merged, this will do.


Swift SVN r9336
This commit is contained in:
Chris Lattner
2013-10-14 23:42:41 +00:00
parent d8676b7bbe
commit a6cde9cd8d
2 changed files with 19 additions and 10 deletions

View File

@@ -17,6 +17,12 @@ using namespace swift;
// SILBuilder Implementation
//===----------------------------------------------------------------------===//
CanType SILBuilder::getStructFieldType(CanType Ty, VarDecl *Field) {
return Ty->getTypeOfMember(Field->getModuleContext(), Field, nullptr)
->getCanonicalType();
}
SILType SILBuilder::getTupleElementType(SILType Ty, unsigned EltNo,
SILValueCategory Cat) {
TupleType *TT = Ty.getAs<TupleType>();
@@ -27,9 +33,7 @@ SILType SILBuilder::getTupleElementType(SILType Ty, unsigned EltNo,
SILType SILBuilder::getStructFieldType(SILType Ty, VarDecl *Field,
SILValueCategory Cat) {
assert(Field->getDeclContext() == Ty.getStructOrBoundGenericStruct());
auto FieldTy = Ty.getSwiftRValueType()
->getTypeOfMember(Field->getModuleContext(), Field, nullptr)
->getCanonicalType();
auto FieldTy = getStructFieldType(Ty.getSwiftRValueType(), Field);
return SILType::getPrimitiveType(FieldTy, Cat);
}