FLANG
derived.h
1//===-- runtime/derived.h -------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// Internal runtime utilities for derived type operations.
10
11#ifndef FORTRAN_RUNTIME_DERIVED_H_
12#define FORTRAN_RUNTIME_DERIVED_H_
13
14#include "flang/Common/api-attrs.h"
15
16namespace Fortran::runtime::typeInfo {
17class DerivedType;
18}
19
20namespace Fortran::runtime {
21class Descriptor;
22class Terminator;
23
24// Perform default component initialization, allocate automatic components.
25// Returns a STAT= code (0 when all's well).
26RT_API_ATTRS int Initialize(const Descriptor &, const typeInfo::DerivedType &,
27 Terminator &, bool hasStat = false, const Descriptor *errMsg = nullptr);
28
29// Initializes an object clone from the original object.
30// Each allocatable member of the clone is allocated with the same bounds as
31// in the original object, if it is also allocated in it.
32// Returns a STAT= code (0 when all's well).
33RT_API_ATTRS int InitializeClone(const Descriptor &, const Descriptor &,
34 const typeInfo::DerivedType &, Terminator &, bool hasStat = false,
35 const Descriptor *errMsg = nullptr);
36
37// Call FINAL subroutines, if any
38RT_API_ATTRS void Finalize(
39 const Descriptor &, const typeInfo::DerivedType &derived, Terminator *);
40
41// Call FINAL subroutines, deallocate allocatable & automatic components.
42// Does not deallocate the original descriptor.
43RT_API_ATTRS void Destroy(const Descriptor &, bool finalize,
44 const typeInfo::DerivedType &, Terminator *);
45
46// Return true if the passed descriptor is for a derived type
47// entity that has a dynamic (allocatable, automatic) component.
48RT_API_ATTRS bool HasDynamicComponent(const Descriptor &);
49
50} // namespace Fortran::runtime
51#endif // FORTRAN_RUNTIME_DERIVED_H_