@@ -287,13 +287,25 @@ static std::shared_ptr<CompileTimeValue> extractCompileTimeValue(Expr *expr) {
287287
288288 case ExprKind::Call: {
289289 auto callExpr = cast<CallExpr>(expr);
290- if (callExpr->getFn ()->getKind () == ExprKind::ConstructorRefCall) {
290+ auto functionKind = callExpr->getFn ()->getKind ();
291+
292+ if (functionKind == ExprKind::DeclRef) {
293+ auto declRefExpr = cast<DeclRefExpr>(callExpr->getFn ());
294+ auto caseName =
295+ declRefExpr->getDecl ()->getName ().getBaseIdentifier ().str ().str ();
296+
297+ std::vector<FunctionParameter> parameters =
298+ extractFunctionArguments (callExpr->getArgs ());
299+ return std::make_shared<FunctionCallValue>(caseName, parameters);
300+ }
301+
302+ if (functionKind == ExprKind::ConstructorRefCall) {
291303 std::vector<FunctionParameter> parameters =
292304 extractFunctionArguments (callExpr->getArgs ());
293305 return std::make_shared<InitCallValue>(callExpr->getType (), parameters);
294306 }
295307
296- if (callExpr-> getFn ()-> getKind () == ExprKind::DotSyntaxCall) {
308+ if (functionKind == ExprKind::DotSyntaxCall) {
297309 auto dotSyntaxCallExpr = cast<DotSyntaxCallExpr>(callExpr->getFn ());
298310 auto fn = dotSyntaxCallExpr->getFn ();
299311 if (fn->getKind () == ExprKind::DeclRef) {
@@ -409,6 +421,38 @@ static std::shared_ptr<CompileTimeValue> extractCompileTimeValue(Expr *expr) {
409421 return extractCompileTimeValue (injectIntoOptionalExpr->getSubExpr ());
410422 }
411423
424+ case ExprKind::Load: {
425+ auto loadExpr = cast<LoadExpr>(expr);
426+ return extractCompileTimeValue (loadExpr->getSubExpr ());
427+ }
428+
429+ case ExprKind::MemberRef: {
430+ auto memberExpr = cast<MemberRefExpr>(expr);
431+ if (isa<TypeExpr>(memberExpr->getBase ())) {
432+ auto baseTypeExpr = cast<TypeExpr>(memberExpr->getBase ());
433+ auto label = memberExpr->getDecl ().getDecl ()->getBaseIdentifier ().str ();
434+ return std::make_shared<MemberReferenceValue>(
435+ baseTypeExpr->getInstanceType (), label.str ());
436+ }
437+ break ;
438+ }
439+
440+ case ExprKind::InterpolatedStringLiteral: {
441+ auto interpolatedStringExpr = cast<InterpolatedStringLiteralExpr>(expr);
442+ auto tapExpr = interpolatedStringExpr->getAppendingExpr ();
443+ auto &Ctx = tapExpr->getVar ()->getASTContext ();
444+
445+ std::vector<std::shared_ptr<CompileTimeValue>> segments;
446+ interpolatedStringExpr->forEachSegment (
447+ Ctx, [&](bool isInterpolation, CallExpr *segment) -> void {
448+ auto arg = segment->getArgs ()->get (0 );
449+ auto expr = arg.getExpr ();
450+ segments.push_back (extractCompileTimeValue (expr));
451+ });
452+
453+ return std::make_shared<InterpolatedStringLiteralValue>(segments);
454+ }
455+
412456 default : {
413457 break ;
414458 }
@@ -733,23 +777,69 @@ void writeValue(llvm::json::OStream &JSON,
733777 break ;
734778 }
735779
736- case CompileTimeValue::KeyPath: {
737- auto keyPathValue = cast<KeyPathValue>(value);
738- JSON.attribute (" valueKind" , " KeyPath" );
739- JSON.attributeObject (" value" , [&]() {
740- JSON.attribute (" path" , keyPathValue->getPath ());
741- JSON.attribute (" rootType" , toFullyQualifiedTypeNameString (keyPathValue->getRootType ()));
742- JSON.attributeArray (" components" , [&] {
743- auto components = keyPathValue->getComponents ();
744- for (auto c : components) {
780+ case CompileTimeValue::ValueKind::KeyPath: {
781+ auto keyPathValue = cast<KeyPathValue>(value);
782+ JSON.attribute (" valueKind" , " KeyPath" );
783+ JSON.attributeObject (" value" , [&]() {
784+ JSON.attribute (" path" , keyPathValue->getPath ());
785+ JSON.attribute (" rootType" , toFullyQualifiedTypeNameString (
786+ keyPathValue->getRootType ()));
787+ JSON.attributeArray (" components" , [&] {
788+ auto components = keyPathValue->getComponents ();
789+ for (auto c : components) {
790+ JSON.object ([&] {
791+ JSON.attribute (" label" , c.Label );
792+ JSON.attribute (" type" , toFullyQualifiedTypeNameString (c.Type ));
793+ });
794+ }
795+ });
796+ });
797+ break ;
798+ }
799+
800+ case CompileTimeValue::ValueKind::FunctionCall: {
801+ auto functionCallValue = cast<FunctionCallValue>(value);
802+ JSON.attribute (" valueKind" , " FunctionCall" );
803+ JSON.attributeObject (" value" , [&]() {
804+ JSON.attribute (" name" , functionCallValue->getIdentifier ());
805+ if (functionCallValue->getParameters ().has_value ()) {
806+ auto params = functionCallValue->getParameters ().value ();
807+ JSON.attributeArray (" arguments" , [&] {
808+ for (auto FP : params) {
745809 JSON.object ([&] {
746- JSON.attribute (" label" , c.Label );
747- JSON.attribute (" type" , toFullyQualifiedTypeNameString (c.Type ));
810+ JSON.attribute (" label" , FP.Label );
811+ JSON.attribute (" type" , toFullyQualifiedTypeNameString (FP.Type ));
812+ writeValue (JSON, FP.Value );
748813 });
749814 }
750815 });
816+ }
817+ });
818+ break ;
819+ }
820+
821+ case CompileTimeValue::ValueKind::MemberReference: {
822+ auto memberReferenceValue = cast<MemberReferenceValue>(value);
823+ JSON.attribute (" valueKind" , " MemberReference" );
824+ JSON.attributeObject (" value" , [&]() {
825+ JSON.attribute (" baseType" , toFullyQualifiedTypeNameString (
826+ memberReferenceValue->getBaseType ()));
827+ JSON.attribute (" memberLabel" , memberReferenceValue->getMemberLabel ());
828+ });
829+ break ;
830+ }
831+ case CompileTimeValue::ValueKind::InterpolatedString: {
832+ auto interpolatedStringValue = cast<InterpolatedStringLiteralValue>(value);
833+ JSON.attribute (" valueKind" , " InterpolatedStringLiteral" );
834+ JSON.attributeObject (" value" , [&]() {
835+ JSON.attributeArray (" segments" , [&] {
836+ auto segments = interpolatedStringValue->getSegments ();
837+ for (auto s : segments) {
838+ JSON.object ([&] { writeValue (JSON, s); });
839+ }
751840 });
752- break ;
841+ });
842+ break ;
753843 }
754844
755845 case CompileTimeValue::ValueKind::Runtime: {
0 commit comments