17
17
18
18
namespace Fortran ::runtime {
19
19
20
+ enum AssignFlags {
21
+ NoAssignFlags = 0 ,
22
+ MaybeReallocate = 1 << 0 ,
23
+ NeedFinalization = 1 << 1 ,
24
+ CanBeDefinedAssignment = 1 << 2 ,
25
+ ComponentCanBeDefinedAssignment = 1 << 3 ,
26
+ ExplicitLengthCharacterLHS = 1 << 4 ,
27
+ PolymorphicLHS = 1 << 5 ,
28
+ DeallocateLHS = 1 << 6
29
+ };
30
+
20
31
// Predicate: is the left-hand side of an assignment an allocated allocatable
21
32
// that must be deallocated?
22
33
static inline RT_API_ATTRS bool MustDeallocateLHS (
@@ -239,8 +250,8 @@ static RT_API_ATTRS void BlankPadCharacterAssignment(Descriptor &to,
239
250
// of elements, but their shape need not to conform (the assignment is done in
240
251
// element sequence order). This facilitates some internal usages, like when
241
252
// dealing with array constructors.
242
- RT_API_ATTRS void Assign (Descriptor &to, const Descriptor &from,
243
- Terminator &terminator, int flags, MemmoveFct memmoveFct ) {
253
+ RT_API_ATTRS static void Assign (
254
+ Descriptor &to, const Descriptor &from, Terminator &terminator, int flags) {
244
255
bool mustDeallocateLHS{(flags & DeallocateLHS) ||
245
256
MustDeallocateLHS (to, from, terminator, flags)};
246
257
DescriptorAddendum *toAddendum{to.Addendum ()};
@@ -412,14 +423,14 @@ RT_API_ATTRS void Assign(Descriptor &to, const Descriptor &from,
412
423
Assign (toCompDesc, fromCompDesc, terminator, nestedFlags);
413
424
} else { // Component has intrinsic type; simply copy raw bytes
414
425
std::size_t componentByteSize{comp.SizeInBytes (to)};
415
- memmoveFct (to.Element <char >(toAt) + comp.offset (),
426
+ Fortran::runtime::memmove (to.Element <char >(toAt) + comp.offset (),
416
427
from.Element <const char >(fromAt) + comp.offset (),
417
428
componentByteSize);
418
429
}
419
430
break ;
420
431
case typeInfo::Component::Genre::Pointer: {
421
432
std::size_t componentByteSize{comp.SizeInBytes (to)};
422
- memmoveFct (to.Element <char >(toAt) + comp.offset (),
433
+ Fortran::runtime::memmove (to.Element <char >(toAt) + comp.offset (),
423
434
from.Element <const char >(fromAt) + comp.offset (),
424
435
componentByteSize);
425
436
} break ;
@@ -465,14 +476,14 @@ RT_API_ATTRS void Assign(Descriptor &to, const Descriptor &from,
465
476
const auto &procPtr{
466
477
*procPtrDesc.ZeroBasedIndexedElement <typeInfo::ProcPtrComponent>(
467
478
k)};
468
- memmoveFct (to.Element <char >(toAt) + procPtr.offset ,
479
+ Fortran::runtime::memmove (to.Element <char >(toAt) + procPtr.offset ,
469
480
from.Element <const char >(fromAt) + procPtr.offset ,
470
481
sizeof (typeInfo::ProcedurePointer));
471
482
}
472
483
}
473
484
} else { // intrinsic type, intrinsic assignment
474
485
if (isSimpleMemmove ()) {
475
- memmoveFct (to.raw ().base_addr , from.raw ().base_addr ,
486
+ Fortran::runtime::memmove (to.raw ().base_addr , from.raw ().base_addr ,
476
487
toElements * toElementBytes);
477
488
} else if (toElementBytes > fromElementBytes) { // blank padding
478
489
switch (to.type ().raw ()) {
@@ -496,8 +507,8 @@ RT_API_ATTRS void Assign(Descriptor &to, const Descriptor &from,
496
507
} else { // elemental copies, possibly with character truncation
497
508
for (std::size_t n{toElements}; n-- > 0 ;
498
509
to.IncrementSubscripts (toAt), from.IncrementSubscripts (fromAt)) {
499
- memmoveFct (to.Element <char >(toAt), from. Element < const char >(fromAt ),
500
- toElementBytes);
510
+ Fortran::runtime::memmove (to.Element <char >(toAt),
511
+ from. Element < const char >(fromAt), toElementBytes);
501
512
}
502
513
}
503
514
}
0 commit comments