SIL: Give SILFunction context generic params and a mapTypeInContext method.

For now, steal the context generic params from the SILFunctionType, and borrow ArchetypeBuilder's implementation of mapTypeInContext for AST decl contexts. This should eventually be an independent property.

Swift SVN r11811
This commit is contained in:
Joe Groff
2014-01-02 05:47:39 +00:00
parent e8a6014f09
commit cdc2b34a80
2 changed files with 41 additions and 0 deletions

View File

@@ -63,6 +63,9 @@ private:
/// The lowered type of the function.
CanSILFunctionType LoweredType;
/// The context archetypes of the function.
GenericParamList *ContextGenericParams;
/// The collection of all BasicBlocks in the SILFunction. Empty for external
/// function references.
BlockListType BlockList;
@@ -168,6 +171,32 @@ public:
/// Get this function's transparent attribute.
IsTransparent_t isTransparent() const { return IsTransparent_t(Transparent); }
void setTransparent(IsTransparent_t isT) { Transparent = isT; }
/// Retrieve the generic parameter list containing the contextual archetypes
/// of the function.
///
/// FIXME: We should remove this in favor of lazy archetype instantiation
/// using the 'getArchetype' and 'mapTypeIntoContext' interfaces.
GenericParamList *getContextGenericParams() const {
return ContextGenericParams;
}
void setContextGenericParams(GenericParamList *params) {
ContextGenericParams = params;
}
/// Map the given type, which is based on an interface SILFunctionType and may
/// therefore be dependent, to a type based on the context archetypes of this
/// SILFunction.
Type mapTypeIntoContext(Type type) const;
/// Map the given type, which is based on an interface SILFunctionType and may
/// therefore be dependent, to a type based on the context archetypes of this
/// SILFunction.
SILType mapTypeIntoContext(SILType type) const {
return SILType::getPrimitiveType(
mapTypeIntoContext(type.getSwiftRValueType())->getCanonicalType(),
type.getCategory());
}
//===--------------------------------------------------------------------===//
// Block List Access