@@ -883,13 +883,13 @@ class BooleanLiteralExpr : public LiteralExpr {
883883 }
884884};
885885
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"'.
889887class StringLiteralExpr : public LiteralExpr {
890888 StringRef Val;
891889 SourceRange Range;
892-
890+ ConcreteDeclRef BuiltinInitializer;
891+ ConcreteDeclRef Initializer;
892+
893893public:
894894 // / The encoding that should be used for the string literal.
895895 enum Encoding : unsigned {
@@ -926,6 +926,32 @@ class StringLiteralExpr : public LiteralExpr {
926926 return StringLiteralExprBits.IsSingleExtendedGraphemeCluster ;
927927 }
928928
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+
929955 static bool classof (const Expr *E) {
930956 return E->getKind () == ExprKind::StringLiteral;
931957 }
@@ -978,7 +1004,9 @@ class MagicIdentifierLiteralExpr : public LiteralExpr {
9781004 };
9791005private:
9801006 SourceLoc Loc;
981-
1007+ ConcreteDeclRef BuiltinInitializer;
1008+ ConcreteDeclRef Initializer;
1009+
9821010public:
9831011 MagicIdentifierLiteralExpr (Kind kind, SourceLoc loc, bool implicit = false )
9841012 : LiteralExpr(ExprKind::MagicIdentifierLiteral, implicit), Loc(loc) {
@@ -1031,6 +1059,40 @@ class MagicIdentifierLiteralExpr : public LiteralExpr {
10311059 = static_cast <unsigned >(encoding);
10321060 }
10331061
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+
10341096 static bool classof (const Expr *E) {
10351097 return E->getKind () == ExprKind::MagicIdentifierLiteral;
10361098 }
0 commit comments