|
13 | 13 | // This file implements routines for converting Swift AST interface types to |
14 | 14 | // rewrite system terms. |
15 | 15 | // |
| 16 | +// A type parameter in Swift is a GenericTypeParamType wrapped in zero or |
| 17 | +// more DependentMemberTypes. DependentMemberTypes come in two flavors, |
| 18 | +// "unresolved" and "resolved". Unresolved DependentMemberTypes store an |
| 19 | +// identifier. Resolved DependentMemberTypes store an associated type |
| 20 | +// declaration. |
| 21 | +// |
| 22 | +// In the rewrite system, unresolved DependentMemberTypes map to name symbols; |
| 23 | +// resolved DependentMemberTypes map to associated type symbols. |
| 24 | +// |
| 25 | +// The mapping of the root generic parameter depends on the specific usage: |
| 26 | +// |
| 27 | +// - If the type is understood to be the subject type of a requirement in a |
| 28 | +// protocol, the root generic parameter, which must equal τ_0_0, maps to a |
| 29 | +// protocol symbol for the protocol in question. |
| 30 | +// |
| 31 | +// - If the type is part of a top-level generic signature, the root generic |
| 32 | +// parameter maps to the corresponding generic parameter symbol. |
| 33 | +// |
| 34 | +// - If the type was derived from a superclass or concrete type symbol, the |
| 35 | +// root generic parameter, which must equal τ_0_N for some N, maps to the |
| 36 | +// Nth substitution stored in the superclass or concrete type symbol. |
| 37 | +// |
16 | 38 | // The rewrite system's reduction order differs from the canonical type order |
17 | 39 | // used by Swift's ABI and name mangling. What this means in practice is that |
18 | 40 | // converting a canonical type to a term does not necessarily produce a |
|
36 | 58 | // their module names, if the unqualified names are the same). In the reduction |
37 | 59 | // order, we want P1 < P2 to also hold if P1 inherits from P2. |
38 | 60 | // |
| 61 | +// The following diagram shows the relationship between the two directions of |
| 62 | +// the type to term mapping: |
| 63 | +// |
| 64 | +// --------------------- |
| 65 | +// / Non-canonical Type / |
| 66 | +// --------------------- |
| 67 | +// | |
| 68 | +// v |
| 69 | +// +------------------+ |
| 70 | +// | getTermForType() | |
| 71 | +// +------------------+ |
| 72 | +// | |
| 73 | +// v |
| 74 | +// --------------------- |
| 75 | +// / Non-canonical Term / |
| 76 | +// --------------------- |
| 77 | +// | |
| 78 | +// v |
| 79 | +// +------------+ |
| 80 | +// | simplify() | |
| 81 | +// +------------+ |
| 82 | +// | |
| 83 | +// v |
| 84 | +// ----------------- |
| 85 | +// / Canonical Term / |
| 86 | +// ----------------- |
| 87 | +// | |
| 88 | +// v |
| 89 | +// +------------------+ |
| 90 | +// | getTypeForTerm() | |
| 91 | +// +------------------+ |
| 92 | +// | |
| 93 | +// v |
| 94 | +// ----------------- |
| 95 | +// / Canonical Type / |
| 96 | +// ----------------- |
| 97 | +// |
39 | 98 | //===----------------------------------------------------------------------===// |
40 | 99 |
|
41 | 100 | #include "swift/AST/Decl.h" |
|
0 commit comments