Skip to content

Commit 9f33d3e

Browse files
authored
Merge pull request #69556 from augusto2112/builtin-interface
Add interface for lookup up of externally stored type descriptors
2 parents 6dafae8 + f09f518 commit 9f33d3e

File tree

6 files changed

+896
-662
lines changed

6 files changed

+896
-662
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//===--------------- DescriptorFinder.h -------------------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef SWIFT_REFLECTION_DESCRIPTOR_FINDER_H
14+
#define SWIFT_REFLECTION_DESCRIPTOR_FINDER_H
15+
16+
#include "llvm/ADT/StringRef.h"
17+
18+
namespace swift {
19+
namespace reflection {
20+
21+
class TypeRef;
22+
23+
/// An abstract interface for a builtin type descriptor.
24+
struct BuiltinTypeDescriptorBase {
25+
const uint32_t Size;
26+
const uint32_t Alignment;
27+
const uint32_t Stride;
28+
const uint32_t NumExtraInhabitants;
29+
const bool IsBitwiseTakable;
30+
31+
BuiltinTypeDescriptorBase(uint32_t Size, uint32_t Alignment, uint32_t Stride,
32+
uint32_t NumExtraInhabitants, bool IsBitwiseTakable)
33+
: Size(Size), Alignment(Alignment), Stride(Stride),
34+
NumExtraInhabitants(NumExtraInhabitants),
35+
IsBitwiseTakable(IsBitwiseTakable) {}
36+
37+
virtual ~BuiltinTypeDescriptorBase(){};
38+
39+
virtual llvm::StringRef getMangledTypeName() = 0;
40+
};
41+
42+
/// Interface for finding type descriptors. Implementors may provide descriptors
43+
/// that live inside or outside reflection metadata.
44+
struct DescriptorFinder {
45+
virtual ~DescriptorFinder(){};
46+
47+
virtual std::unique_ptr<BuiltinTypeDescriptorBase>
48+
getBuiltinTypeDescriptor(const TypeRef *TR) = 0;
49+
};
50+
51+
} // namespace reflection
52+
} // namespace swift
53+
#endif

include/swift/RemoteInspection/ReflectionContext.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "swift/Concurrency/Actor.h"
3131
#include "swift/Remote/MemoryReader.h"
3232
#include "swift/Remote/MetadataReader.h"
33+
#include "swift/RemoteInspection/DescriptorFinder.h"
3334
#include "swift/RemoteInspection/GenericMetadataCacheEntry.h"
3435
#include "swift/RemoteInspection/Records.h"
3536
#include "swift/RemoteInspection/RuntimeInternals.h"
@@ -214,8 +215,9 @@ class ReflectionContext
214215

215216
explicit ReflectionContext(
216217
std::shared_ptr<MemoryReader> reader,
217-
remote::ExternalTypeRefCache *externalCache = nullptr)
218-
: super(std::move(reader), *this, externalCache) {}
218+
remote::ExternalTypeRefCache *externalCache = nullptr,
219+
reflection::DescriptorFinder *descriptorFinder = nullptr)
220+
: super(std::move(reader), *this, externalCache, descriptorFinder) {}
219221

220222
ReflectionContext(const ReflectionContext &other) = delete;
221223
ReflectionContext &operator=(const ReflectionContext &other) = delete;

include/swift/RemoteInspection/TypeLowering.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "llvm/Support/Casting.h"
2424
#include "swift/Remote/MetadataReader.h"
2525
#include "swift/Remote/TypeInfoProvider.h"
26+
#include "swift/RemoteInspection/DescriptorFinder.h"
2627

2728
#include <memory>
2829

@@ -174,7 +175,7 @@ class BuiltinTypeInfo : public TypeInfo {
174175

175176
public:
176177
explicit BuiltinTypeInfo(TypeRefBuilder &builder,
177-
RemoteRef<BuiltinTypeDescriptor> descriptor);
178+
BuiltinTypeDescriptorBase &descriptor);
178179

179180
/// Construct an empty builtin type info.
180181
BuiltinTypeInfo()

0 commit comments

Comments
 (0)