Define an API for, and implement, runtime support for arbitrary assignment of one descriptor's data to another, with full support for (re)allocation of allocatables with finalization when necessary, user-defined derived type assignment TBP calls, and intrinsic (default) componentwise assignment of derived type instances with allocation of automatic components. Also clean up API and implementation of finalization/destruction using knowledge gained while studying edge cases for assignment in the 2018 standard. The look-up procedure for special procedure bindings in derived types has been optimized from O(N) to O(1) since it will probably matter more. This required some analysis in runtime derived type description table construction in semantics and some changes to the table schemata. Executable Fortran tests have been developed; they'll be added to the test base once they can be lowered and run by f18. Differential Revision: https://reviews.llvm.org/D107678
36 lines
1.2 KiB
C++
36 lines
1.2 KiB
C++
//===-- runtime/derived.h -------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Internal runtime utilities for derived type operations.
|
|
|
|
#ifndef FLANG_RUNTIME_DERIVED_H_
|
|
#define FLANG_RUNTIME_DERIVED_H_
|
|
|
|
namespace Fortran::runtime::typeInfo {
|
|
class DerivedType;
|
|
}
|
|
|
|
namespace Fortran::runtime {
|
|
class Descriptor;
|
|
class Terminator;
|
|
|
|
// Perform default component initialization, allocate automatic components.
|
|
// Returns a STAT= code (0 when all's well).
|
|
int Initialize(const Descriptor &, const typeInfo::DerivedType &, Terminator &,
|
|
bool hasStat = false, const Descriptor *errMsg = nullptr);
|
|
|
|
// Call FINAL subroutines, if any
|
|
void Finalize(const Descriptor &, const typeInfo::DerivedType &derived);
|
|
|
|
// Call FINAL subroutines, deallocate allocatable & automatic components.
|
|
// Does not deallocate the original descriptor.
|
|
void Destroy(const Descriptor &, bool finalize, const typeInfo::DerivedType &);
|
|
|
|
} // namespace Fortran::runtime
|
|
#endif // FLANG_RUNTIME_DERIVED_H_
|