@@ -3949,6 +3949,12 @@ namespace {
3949
3949
}
3950
3950
3951
3951
void addDestructorFunction () {
3952
+ if (IGM.Context .LangOpts .hasFeature (Feature::Embedded)) {
3953
+ auto dtorRef = SILDeclRef (Target->getDestructor (), SILDeclRef::Kind::Deallocator);
3954
+ addReifiedVTableEntry (dtorRef);
3955
+ return ;
3956
+ }
3957
+
3952
3958
if (asImpl ().getFieldLayout ().hasObjCImplementation ())
3953
3959
return ;
3954
3960
@@ -4967,6 +4973,36 @@ void irgen::emitClassMetadata(IRGenModule &IGM, ClassDecl *classDecl,
4967
4973
}
4968
4974
}
4969
4975
4976
+ void irgen::emitEmbeddedClassMetadata (IRGenModule &IGM, ClassDecl *classDecl,
4977
+ const ClassLayout &fragileLayout) {
4978
+ PrettyStackTraceDecl stackTraceRAII (" emitting metadata for" , classDecl);
4979
+ assert (!classDecl->isForeign ());
4980
+
4981
+ // Set up a dummy global to stand in for the metadata object while we produce
4982
+ // relative references.
4983
+ ConstantInitBuilder builder (IGM);
4984
+ auto init = builder.beginStruct ();
4985
+ init.setPacked (true );
4986
+
4987
+ auto strategy = IGM.getClassMetadataStrategy (classDecl);
4988
+ assert (strategy == ClassMetadataStrategy::FixedOrUpdate ||
4989
+ strategy == ClassMetadataStrategy::Fixed);
4990
+
4991
+ FixedClassMetadataBuilder metadataBuilder (IGM, classDecl, init,
4992
+ fragileLayout);
4993
+ metadataBuilder.layout ();
4994
+ bool canBeConstant = metadataBuilder.canBeConstant ();
4995
+ metadataBuilder.createMetadataAccessFunction ();
4996
+
4997
+ CanType declaredType = classDecl->getDeclaredType ()->getCanonicalType ();
4998
+
4999
+ StringRef section{};
5000
+ bool isPattern = false ;
5001
+ auto var = IGM.defineTypeMetadata (declaredType, isPattern, canBeConstant,
5002
+ init.finishAndCreateFuture (), section);
5003
+ (void )var;
5004
+ }
5005
+
4970
5006
void irgen::emitSpecializedGenericClassMetadata (IRGenModule &IGM, CanType type,
4971
5007
ClassDecl &decl) {
4972
5008
assert (decl.isGenericContext ());
0 commit comments