|
19 | 19 | namespace swift {
|
20 | 20 |
|
21 | 21 | /// The name of the standard library, which is a reserved module name.
|
22 |
| -constexpr static const char STDLIB_NAME[] = "Swift"; |
| 22 | +constexpr static const StringLiteral STDLIB_NAME = "Swift"; |
23 | 23 | /// The name of the Onone support library, which is a reserved module name.
|
24 |
| -constexpr static const char SWIFT_ONONE_SUPPORT[] = "SwiftOnoneSupport"; |
| 24 | +constexpr static const StringLiteral SWIFT_ONONE_SUPPORT = "SwiftOnoneSupport"; |
25 | 25 | /// The name of the SwiftShims module, which contains private stdlib decls.
|
26 |
| -constexpr static const char SWIFT_SHIMS_NAME[] = "SwiftShims"; |
| 26 | +constexpr static const StringLiteral SWIFT_SHIMS_NAME = "SwiftShims"; |
27 | 27 | /// The name of the Builtin module, which contains Builtin functions.
|
28 |
| -constexpr static const char BUILTIN_NAME[] = "Builtin"; |
| 28 | +constexpr static const StringLiteral BUILTIN_NAME = "Builtin"; |
29 | 29 | /// The prefix of module names used by LLDB to capture Swift expressions
|
30 |
| -constexpr static const char LLDB_EXPRESSIONS_MODULE_NAME_PREFIX[] = |
| 30 | +constexpr static const StringLiteral LLDB_EXPRESSIONS_MODULE_NAME_PREFIX = |
31 | 31 | "__lldb_expr_";
|
32 | 32 |
|
33 | 33 | /// The name of the fake module used to hold imported Objective-C things.
|
34 |
| -constexpr static const char MANGLING_MODULE_OBJC[] = "__C"; |
| 34 | +constexpr static const StringLiteral MANGLING_MODULE_OBJC = "__C"; |
35 | 35 | /// The name of the fake module used to hold synthesized ClangImporter things.
|
36 |
| -constexpr static const char MANGLING_MODULE_CLANG_IMPORTER[] = |
| 36 | +constexpr static const StringLiteral MANGLING_MODULE_CLANG_IMPORTER = |
37 | 37 | "__C_Synthesized";
|
38 | 38 |
|
| 39 | +constexpr static const StringLiteral SEMANTICS_PROGRAMTERMINATION_POINT = |
| 40 | + "programtermination_point"; |
| 41 | + |
39 | 42 | /// The name of the Builtin type prefix
|
40 |
| -constexpr static const char BUILTIN_TYPE_NAME_PREFIX[] = "Builtin."; |
| 43 | +constexpr static const StringLiteral BUILTIN_TYPE_NAME_PREFIX = "Builtin."; |
| 44 | + |
| 45 | +/// A composition class containing a StringLiteral for the names of |
| 46 | +/// Swift builtins. The reason we use this is to ensure that we when |
| 47 | +/// necessary slice off the "Builtin." prefix from these names in a |
| 48 | +/// constexpr way from a global constant string. |
| 49 | +/// |
| 50 | +/// NOTE: StringLiteral is a weird class to compose with. For this to |
| 51 | +/// work properly, one must always initialize these classes using an |
| 52 | +/// initializer list as shown below. |
| 53 | +struct BuiltinNameStringLiteral { |
| 54 | + const StringLiteral literal; |
| 55 | + |
| 56 | + constexpr operator StringRef() const { return literal; } |
| 57 | + constexpr const StringRef getWithoutPrefix() const { |
| 58 | + return literal.drop_front(BUILTIN_TYPE_NAME_PREFIX.size()); |
| 59 | + } |
| 60 | +}; |
| 61 | + |
41 | 62 | /// The name of the Builtin type for Int
|
42 |
| -constexpr static const char BUILTIN_TYPE_NAME_INT[] = "Builtin.Int"; |
| 63 | +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_INT = { |
| 64 | + "Builtin.Int"}; |
43 | 65 | /// The name of the Builtin type for Int8
|
44 |
| -constexpr static const char BUILTIN_TYPE_NAME_INT8[] = "Builtin.Int8"; |
| 66 | +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_INT8 = { |
| 67 | + "Builtin.Int8"}; |
45 | 68 | /// The name of the Builtin type for Int16
|
46 |
| -constexpr static const char BUILTIN_TYPE_NAME_INT16[] = "Builtin.Int16"; |
| 69 | +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_INT16 = { |
| 70 | + "Builtin.Int16"}; |
47 | 71 | /// The name of the Builtin type for Int32
|
48 |
| -constexpr static const char BUILTIN_TYPE_NAME_INT32[] = "Builtin.Int32"; |
| 72 | +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_INT32 = { |
| 73 | + "Builtin.Int32"}; |
49 | 74 | /// The name of the Builtin type for Int64
|
50 |
| -constexpr static const char BUILTIN_TYPE_NAME_INT64[] = "Builtin.Int64"; |
| 75 | +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_INT64 = { |
| 76 | + "Builtin.Int64"}; |
51 | 77 | /// The name of the Builtin type for Int128
|
52 |
| -constexpr static const char BUILTIN_TYPE_NAME_INT128[] = "Builtin.Int128"; |
| 78 | +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_INT128 = { |
| 79 | + "Builtin.Int128"}; |
53 | 80 | /// The name of the Builtin type for Int256
|
54 |
| -constexpr static const char BUILTIN_TYPE_NAME_INT256[] = "Builtin.Int256"; |
| 81 | +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_INT256 = { |
| 82 | + "Builtin.Int256"}; |
55 | 83 | /// The name of the Builtin type for Int512
|
56 |
| -constexpr static const char BUILTIN_TYPE_NAME_INT512[] = "Builtin.Int512"; |
| 84 | +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_INT512 = { |
| 85 | + "Builtin.Int512"}; |
57 | 86 | /// The name of the Builtin type for IntLiteral
|
58 |
| -constexpr static const char BUILTIN_TYPE_NAME_INTLITERAL[] = |
59 |
| - "Builtin.IntLiteral"; |
60 |
| -/// The name of the Builtin type for Float |
61 |
| -constexpr static const char BUILTIN_TYPE_NAME_FLOAT[] = "Builtin.FPIEEE"; |
| 87 | +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_INTLITERAL = { |
| 88 | + "Builtin.IntLiteral"}; |
| 89 | +/// The name of the Builtin type for IEEE Floating point types. |
| 90 | +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_FLOAT = { |
| 91 | + "Builtin.FPIEEE"}; |
| 92 | +// The name of the builtin type for power pc specific floating point types. |
| 93 | +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_FLOAT_PPC = { |
| 94 | + "Builtin.FPPPC"}; |
62 | 95 | /// The name of the Builtin type for NativeObject
|
63 |
| -constexpr static const char BUILTIN_TYPE_NAME_NATIVEOBJECT[] = |
64 |
| - "Builtin.NativeObject"; |
| 96 | +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_NATIVEOBJECT = { |
| 97 | + "Builtin.NativeObject"}; |
65 | 98 | /// The name of the Builtin type for BridgeObject
|
66 |
| -constexpr static const char BUILTIN_TYPE_NAME_BRIDGEOBJECT[] = |
67 |
| - "Builtin.BridgeObject"; |
| 99 | +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_BRIDGEOBJECT = { |
| 100 | + "Builtin.BridgeObject"}; |
68 | 101 | /// The name of the Builtin type for RawPointer
|
69 |
| -constexpr static const char BUILTIN_TYPE_NAME_RAWPOINTER[] = |
70 |
| - "Builtin.RawPointer"; |
| 102 | +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_RAWPOINTER = { |
| 103 | + "Builtin.RawPointer"}; |
71 | 104 | /// The name of the Builtin type for UnsafeValueBuffer
|
72 |
| -constexpr static const char BUILTIN_TYPE_NAME_UNSAFEVALUEBUFFER[] = |
73 |
| - "Builtin.UnsafeValueBuffer"; |
| 105 | +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_UNSAFEVALUEBUFFER = |
| 106 | + {"Builtin.UnsafeValueBuffer"}; |
74 | 107 | /// The name of the Builtin type for UnknownObject
|
75 |
| -constexpr static const char BUILTIN_TYPE_NAME_UNKNOWNOBJECT[] = |
76 |
| - "Builtin.UnknownObject"; |
| 108 | +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_UNKNOWNOBJECT = { |
| 109 | + "Builtin.UnknownObject"}; |
77 | 110 | /// The name of the Builtin type for Vector
|
78 |
| -constexpr static const char BUILTIN_TYPE_NAME_VEC[] = "Builtin.Vec"; |
| 111 | +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_VEC = { |
| 112 | + "Builtin.Vec"}; |
79 | 113 | /// The name of the Builtin type for SILToken
|
80 |
| -constexpr static const char BUILTIN_TYPE_NAME_SILTOKEN[] = "Builtin.SILToken"; |
| 114 | +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_SILTOKEN = { |
| 115 | + "Builtin.SILToken"}; |
81 | 116 | /// The name of the Builtin type for Word
|
82 |
| -constexpr static const char BUILTIN_TYPE_NAME_WORD[] = "Builtin.Word"; |
83 |
| -constexpr static StringLiteral SEMANTICS_PROGRAMTERMINATION_POINT = |
84 |
| - "programtermination_point"; |
| 117 | +constexpr static BuiltinNameStringLiteral BUILTIN_TYPE_NAME_WORD = { |
| 118 | + "Builtin.Word"}; |
| 119 | + |
85 | 120 | } // end namespace swift
|
86 | 121 |
|
87 | 122 | #endif // SWIFT_STRINGS_H
|
0 commit comments