@@ -883,13 +883,13 @@ class BooleanLiteralExpr : public LiteralExpr {
883
883
}
884
884
};
885
885
886
- // / StringLiteralExpr - String literal, like '"foo"'. After semantic
887
- // / analysis assigns types, this is guaranteed to only have a
888
- // / BuiltinRawPointerType.
886
+ // / StringLiteralExpr - String literal, like '"foo"'.
889
887
class StringLiteralExpr : public LiteralExpr {
890
888
StringRef Val;
891
889
SourceRange Range;
892
-
890
+ ConcreteDeclRef BuiltinInitializer;
891
+ ConcreteDeclRef Initializer;
892
+
893
893
public:
894
894
// / The encoding that should be used for the string literal.
895
895
enum Encoding : unsigned {
@@ -926,6 +926,32 @@ class StringLiteralExpr : public LiteralExpr {
926
926
return StringLiteralExprBits.IsSingleExtendedGraphemeCluster ;
927
927
}
928
928
929
+ // / Retrieve the builtin initializer that will be used to construct the string
930
+ // / literal.
931
+ // /
932
+ // / Any type-checked string literal will have a builtin initializer, which is
933
+ // / called first to form a concrete Swift type.
934
+ ConcreteDeclRef getBuiltinInitializer () const { return BuiltinInitializer; }
935
+
936
+ // / Set the builtin initializer that will be used to construct the string
937
+ // / literal.
938
+ void setBuiltinInitializer (ConcreteDeclRef builtinInitializer) {
939
+ BuiltinInitializer = builtinInitializer;
940
+ }
941
+
942
+ // / Retrieve the initializer that will be used to construct the string
943
+ // / literal from the result of the initializer.
944
+ // /
945
+ // / Only string literals that have no builtin literal conformance will have
946
+ // / this initializer, which will be called on the result of the builtin
947
+ // / initializer.
948
+ ConcreteDeclRef getInitializer () const { return Initializer; }
949
+
950
+ // / Set the initializer that will be used to construct the string literal.
951
+ void setInitializer (ConcreteDeclRef initializer) {
952
+ Initializer = initializer;
953
+ }
954
+
929
955
static bool classof (const Expr *E) {
930
956
return E->getKind () == ExprKind::StringLiteral;
931
957
}
@@ -978,7 +1004,9 @@ class MagicIdentifierLiteralExpr : public LiteralExpr {
978
1004
};
979
1005
private:
980
1006
SourceLoc Loc;
981
-
1007
+ ConcreteDeclRef BuiltinInitializer;
1008
+ ConcreteDeclRef Initializer;
1009
+
982
1010
public:
983
1011
MagicIdentifierLiteralExpr (Kind kind, SourceLoc loc, bool implicit = false )
984
1012
: LiteralExpr(ExprKind::MagicIdentifierLiteral, implicit), Loc(loc) {
@@ -1031,6 +1059,40 @@ class MagicIdentifierLiteralExpr : public LiteralExpr {
1031
1059
= static_cast <unsigned >(encoding);
1032
1060
}
1033
1061
1062
+ // / Retrieve the builtin initializer that will be used to construct the string
1063
+ // / literal.
1064
+ // /
1065
+ // / Any type-checked string literal will have a builtin initializer, which is
1066
+ // / called first to form a concrete Swift type.
1067
+ ConcreteDeclRef getBuiltinInitializer () const {
1068
+ assert (isString () && " Magic identifier literal is not a string" );
1069
+ return BuiltinInitializer;
1070
+ }
1071
+
1072
+ // / Set the builtin initializer that will be used to construct the string
1073
+ // / literal.
1074
+ void setBuiltinInitializer (ConcreteDeclRef builtinInitializer) {
1075
+ assert (isString () && " Magic identifier literal is not a string" );
1076
+ BuiltinInitializer = builtinInitializer;
1077
+ }
1078
+
1079
+ // / Retrieve the initializer that will be used to construct the string
1080
+ // / literal from the result of the initializer.
1081
+ // /
1082
+ // / Only string literals that have no builtin literal conformance will have
1083
+ // / this initializer, which will be called on the result of the builtin
1084
+ // / initializer.
1085
+ ConcreteDeclRef getInitializer () const {
1086
+ assert (isString () && " Magic identifier literal is not a string" );
1087
+ return Initializer;
1088
+ }
1089
+
1090
+ // / Set the initializer that will be used to construct the string literal.
1091
+ void setInitializer (ConcreteDeclRef initializer) {
1092
+ assert (isString () && " Magic identifier literal is not a string" );
1093
+ Initializer = initializer;
1094
+ }
1095
+
1034
1096
static bool classof (const Expr *E) {
1035
1097
return E->getKind () == ExprKind::MagicIdentifierLiteral;
1036
1098
}
0 commit comments