@@ -104,7 +104,9 @@ class RemoteASTContextImpl {
104
104
getDeclForRemoteNominalTypeDescriptor (RemoteAddress descriptor) = 0 ;
105
105
virtual Result<RemoteAddress>
106
106
getHeapMetadataForObject (RemoteAddress object) = 0 ;
107
- virtual Result<std::pair<Type, RemoteAddress>>
107
+ virtual OpenedExistential
108
+ getDynamicTypeAndAddressForError (RemoteAddress object) = 0 ;
109
+ virtual OpenedExistential
108
110
getDynamicTypeAndAddressForExistential (RemoteAddress object,
109
111
Type staticType) = 0 ;
110
112
@@ -476,7 +478,7 @@ class RemoteASTContextConcreteImpl final : public RemoteASTContextImpl {
476
478
return getFailure<RemoteAddress>();
477
479
}
478
480
479
- Result<std::pair<Type, RemoteAddress>>
481
+ OpenedExistential
480
482
getDynamicTypeAndAddressClassExistential (RemoteAddress object) {
481
483
auto pointerval = Reader.readPointerValue (object.getAddressData ());
482
484
if (!pointerval)
@@ -491,13 +493,18 @@ class RemoteASTContextConcreteImpl final : public RemoteASTContextImpl {
491
493
RemoteAddress (*pointerval));
492
494
}
493
495
494
- Result<std::pair<Type, RemoteAddress>>
495
- getDynamicTypeAndAddressErrorExistential (RemoteAddress object) {
496
- auto pointerval = Reader.readPointerValue (object.getAddressData ());
497
- if (!pointerval)
498
- return getFailure<std::pair<Type, RemoteAddress>>();
496
+ OpenedExistential
497
+ getDynamicTypeAndAddressErrorExistential (RemoteAddress object,
498
+ bool dereference=true ) {
499
+ if (dereference) {
500
+ auto pointerval = Reader.readPointerValue (object.getAddressData ());
501
+ if (!pointerval)
502
+ return getFailure<std::pair<Type, RemoteAddress>>();
503
+ object = RemoteAddress (*pointerval);
504
+ }
505
+
499
506
auto result =
500
- Reader.readMetadataAndValueErrorExistential (RemoteAddress (*pointerval) );
507
+ Reader.readMetadataAndValueErrorExistential (object );
501
508
if (!result)
502
509
return getFailure<std::pair<Type, RemoteAddress>>();
503
510
@@ -525,7 +532,7 @@ class RemoteASTContextConcreteImpl final : public RemoteASTContextImpl {
525
532
std::move (valueAddress));
526
533
}
527
534
528
- Result<std::pair<Type, RemoteAddress>>
535
+ OpenedExistential
529
536
getDynamicTypeAndAddressOpaqueExistential (RemoteAddress object) {
530
537
auto result = Reader.readMetadataAndValueOpaqueExistential (object);
531
538
if (!result)
@@ -553,7 +560,7 @@ class RemoteASTContextConcreteImpl final : public RemoteASTContextImpl {
553
560
std::move (valueAddress));
554
561
}
555
562
556
- Result<std::pair<Type, RemoteAddress>>
563
+ OpenedExistential
557
564
getDynamicTypeAndAddressExistentialMetatype (RemoteAddress object) {
558
565
// The value of the address is just the input address.
559
566
// The type is obtained through the following sequence of steps:
@@ -573,11 +580,20 @@ class RemoteASTContextConcreteImpl final : public RemoteASTContextImpl {
573
580
std::move (object));
574
581
}
575
582
583
+ // / Resolve the dynamic type and the value address of an error existential
584
+ // / object, Unlike getDynamicTypeAndAddressForExistential(), this function
585
+ // / takes the address of the instance and not the address of the reference.
586
+ OpenedExistential
587
+ getDynamicTypeAndAddressForError (RemoteAddress object) override {
588
+ return getDynamicTypeAndAddressErrorExistential (object,
589
+ /* dereference=*/ false );
590
+ }
591
+
576
592
// / Resolve the dynamic type and the value address of an existential,
577
593
// / given its address and its static type. For class and error existentials,
578
594
// / this API takes a pointer to the instance reference rather than the
579
595
// / instance reference itself.
580
- Result<std::pair<Type, RemoteAddress>>
596
+ OpenedExistential
581
597
getDynamicTypeAndAddressForExistential (RemoteAddress object,
582
598
Type staticType) override {
583
599
// If this is not an existential, give up.
@@ -658,7 +674,13 @@ RemoteASTContext::getHeapMetadataForObject(remote::RemoteAddress address) {
658
674
return asImpl (Impl)->getHeapMetadataForObject (address);
659
675
}
660
676
661
- Result<std::pair<Type, remote::RemoteAddress>>
677
+ OpenedExistential
678
+ RemoteASTContext::getDynamicTypeAndAddressForError (
679
+ remote::RemoteAddress address) {
680
+ return asImpl (Impl)->getDynamicTypeAndAddressForError (address);
681
+ }
682
+
683
+ OpenedExistential
662
684
RemoteASTContext::getDynamicTypeAndAddressForExistential (
663
685
remote::RemoteAddress address, Type staticType) {
664
686
return asImpl (Impl)->getDynamicTypeAndAddressForExistential (address,
0 commit comments