1 //===-- runtime/derived-api.cpp
2 //-----------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "derived-api.h"
11 #include "derived.h"
12 #include "descriptor.h"
13 #include "terminator.h"
14 #include "type-info.h"
15 
16 namespace Fortran::runtime {
17 
18 extern "C" {
19 
RTNAME(Initialize)20 void RTNAME(Initialize)(
21     const Descriptor &descriptor, const char *sourceFile, int sourceLine) {
22   if (const DescriptorAddendum * addendum{descriptor.Addendum()}) {
23     if (const auto *derived{addendum->derivedType()}) {
24       if (!derived->noInitializationNeeded()) {
25         Terminator terminator{sourceFile, sourceLine};
26         Initialize(descriptor, *derived, terminator);
27       }
28     }
29   }
30 }
31 
RTNAME(Destroy)32 void RTNAME(Destroy)(const Descriptor &descriptor) {
33   if (const DescriptorAddendum * addendum{descriptor.Addendum()}) {
34     if (const auto *derived{addendum->derivedType()}) {
35       if (!derived->noDestructionNeeded()) {
36         Destroy(descriptor, true, *derived);
37       }
38     }
39   }
40 }
41 
42 // TODO: Assign()
43 
44 } // extern "C"
45 } // namespace Fortran::runtime
46