-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMetadata.swift
More file actions
40 lines (33 loc) · 810 Bytes
/
Copy pathMetadata.swift
File metadata and controls
40 lines (33 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import SwiftTypeSystem
public struct Metadata: TypeProtocol, Layout {
public typealias System = Runtime
typealias Layout = Kind
let pointer: UnsafeRawPointer
init(_ ptr: UnsafeRawPointer) {
self.pointer = ptr
}
}
extension Metadata {
public var kind: Kind {
layout
}
}
extension Metadata {
/// The structure of the type, which mirrors the spelling of the type as
/// written in the language.
public var structure: StructuralType<Metadata> {
switch kind {
case .tuple:
let elts = TupleMetadata(pointer).map {
TupleTypeElement<Runtime>(
// We can technically dig this out from the labels string in tuple.
name: nil,
type: $0.type
)
}
return .tuple(elts)
default:
return .placeholder
}
}
}