Skip to content

Commit e67b961

Browse files
committed
SIL: Add getTypeExpansionContext to SILFunction
1 parent 6b3e1b3 commit e67b961

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

include/swift/SIL/SILFunction.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,14 @@ class SILFunction
342342
CanSILFunctionType getLoweredFunctionType() const {
343343
return LoweredType;
344344
}
345+
CanSILFunctionType
346+
getLoweredFunctionTypeInContext(TypeExpansionContext context) const;
347+
348+
SILType getLoweredTypeInContext(TypeExpansionContext context) const {
349+
return SILType::getPrimitiveObjectType(
350+
getLoweredFunctionTypeInContext(context));
351+
}
352+
345353
SILFunctionConventions getConventions() const {
346354
return SILFunctionConventions(LoweredType, getModule());
347355
}
@@ -491,6 +499,11 @@ class SILFunction
491499
: ResilienceExpansion::Maximal);
492500
}
493501

502+
// Returns the type expansion context to be used inside this function.
503+
TypeExpansionContext getTypeExpansionContext() const {
504+
return TypeExpansionContext(*this);
505+
}
506+
494507
const Lowering::TypeLowering &
495508
getTypeLowering(Lowering::AbstractionPattern orig, Type subst);
496509

lib/SIL/SILFunction.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,34 +235,34 @@ bool SILFunction::isNoReturnFunction() const {
235235
const TypeLowering &
236236
SILFunction::getTypeLowering(AbstractionPattern orig, Type subst) {
237237
return getModule().Types.getTypeLowering(orig, subst,
238-
getResilienceExpansion());
238+
TypeExpansionContext(*this));
239239
}
240240

241241
const TypeLowering &SILFunction::getTypeLowering(Type t) const {
242-
return getModule().Types.getTypeLowering(t, getResilienceExpansion());
242+
return getModule().Types.getTypeLowering(t, TypeExpansionContext(*this));
243243
}
244244

245245
SILType
246246
SILFunction::getLoweredType(AbstractionPattern orig, Type subst) const {
247247
return getModule().Types.getLoweredType(orig, subst,
248-
getResilienceExpansion());
248+
TypeExpansionContext(*this));
249249
}
250250

251251
SILType SILFunction::getLoweredType(Type t) const {
252-
return getModule().Types.getLoweredType(t, getResilienceExpansion());
252+
return getModule().Types.getLoweredType(t, TypeExpansionContext(*this));
253253
}
254254

255255
SILType SILFunction::getLoweredLoadableType(Type t) const {
256256
auto &M = getModule();
257-
return M.Types.getLoweredLoadableType(t, getResilienceExpansion(), M);
257+
return M.Types.getLoweredLoadableType(t, TypeExpansionContext(*this), M);
258258
}
259259

260260
const TypeLowering &SILFunction::getTypeLowering(SILType type) const {
261-
return getModule().Types.getTypeLowering(type, getResilienceExpansion());
261+
return getModule().Types.getTypeLowering(type, TypeExpansionContext(*this));
262262
}
263263

264264
bool SILFunction::isTypeABIAccessible(SILType type) const {
265-
return getModule().isTypeABIAccessible(type, getResilienceExpansion());
265+
return getModule().isTypeABIAccessible(type, TypeExpansionContext(*this));
266266
}
267267

268268
bool SILFunction::isWeakImported() const {

0 commit comments

Comments
 (0)