@@ -294,12 +294,12 @@ static std::shared_ptr<CompileTimeValue> extractCompileTimeValue(Expr *expr) {
294294
295295 if (functionKind == ExprKind::DeclRef) {
296296 auto declRefExpr = cast<DeclRefExpr>(callExpr->getFn ());
297- auto caseName =
297+ auto identifier =
298298 declRefExpr->getDecl ()->getName ().getBaseIdentifier ().str ().str ();
299299
300300 std::vector<FunctionParameter> parameters =
301301 extractFunctionArguments (callExpr->getArgs ());
302- return std::make_shared<FunctionCallValue>(caseName , parameters);
302+ return std::make_shared<FunctionCallValue>(identifier , parameters);
303303 }
304304
305305 if (functionKind == ExprKind::ConstructorRefCall) {
@@ -313,12 +313,33 @@ static std::shared_ptr<CompileTimeValue> extractCompileTimeValue(Expr *expr) {
313313 auto fn = dotSyntaxCallExpr->getFn ();
314314 if (fn->getKind () == ExprKind::DeclRef) {
315315 auto declRefExpr = cast<DeclRefExpr>(fn);
316- auto caseName =
316+ auto baseIdentifierName =
317317 declRefExpr->getDecl ()->getName ().getBaseIdentifier ().str ().str ();
318318
319319 std::vector<FunctionParameter> parameters =
320320 extractFunctionArguments (callExpr->getArgs ());
321- return std::make_shared<EnumValue>(caseName, parameters);
321+
322+ auto declRef = dotSyntaxCallExpr->getFn ()->getReferencedDecl ();
323+ switch (declRef.getDecl ()->getKind ()) {
324+ case DeclKind::EnumElement: {
325+ return std::make_shared<EnumValue>(baseIdentifierName, parameters);
326+ }
327+
328+ case DeclKind::Func: {
329+ auto identifier = declRefExpr->getDecl ()
330+ ->getName ()
331+ .getBaseIdentifier ()
332+ .str ()
333+ .str ();
334+
335+ return std::make_shared<StaticFunctionCallValue>(
336+ identifier, callExpr->getType (), parameters);
337+ }
338+
339+ default : {
340+ break ;
341+ }
342+ }
322343 }
323344 }
324345
@@ -836,6 +857,27 @@ void writeValue(llvm::json::OStream &JSON,
836857 break ;
837858 }
838859
860+ case CompileTimeValue::ValueKind::StaticFunctionCall: {
861+ auto staticFunctionCallValue = cast<StaticFunctionCallValue>(value);
862+
863+ JSON.attribute (" valueKind" , " StaticFunctionCall" );
864+ JSON.attributeObject (" value" , [&]() {
865+ JSON.attribute (" type" , toFullyQualifiedTypeNameString (
866+ staticFunctionCallValue->getType ()));
867+ JSON.attribute (" memberLabel" , staticFunctionCallValue->getLabel ());
868+ JSON.attributeArray (" arguments" , [&] {
869+ for (auto FP : staticFunctionCallValue->getParameters ()) {
870+ JSON.object ([&] {
871+ JSON.attribute (" label" , FP.Label );
872+ JSON.attribute (" type" , toFullyQualifiedTypeNameString (FP.Type ));
873+ writeValue (JSON, FP.Value );
874+ });
875+ }
876+ });
877+ });
878+ break ;
879+ }
880+
839881 case CompileTimeValue::ValueKind::MemberReference: {
840882 auto memberReferenceValue = cast<MemberReferenceValue>(value);
841883 JSON.attribute (" valueKind" , " MemberReference" );
@@ -846,6 +888,7 @@ void writeValue(llvm::json::OStream &JSON,
846888 });
847889 break ;
848890 }
891+
849892 case CompileTimeValue::ValueKind::InterpolatedString: {
850893 auto interpolatedStringValue = cast<InterpolatedStringLiteralValue>(value);
851894 JSON.attribute (" valueKind" , " InterpolatedStringLiteral" );
@@ -1062,14 +1105,11 @@ createBuilderCompileTimeValue(CustomAttr *AttachedResultBuilder,
10621105void writeSingleBuilderMemberElement (
10631106 llvm::json::OStream &JSON, std::shared_ptr<CompileTimeValue> Element) {
10641107 switch (Element.get ()->getKind ()) {
1065- case CompileTimeValue::ValueKind::Enum: {
1066- auto enumValue = cast<EnumValue>(Element.get ());
1067- if (enumValue->getIdentifier () == " buildExpression" ) {
1068- if (enumValue->getParameters ().has_value ()) {
1069- auto params = enumValue->getParameters ().value ();
1070- for (auto FP : params) {
1071- writeValue (JSON, FP.Value );
1072- }
1108+ case CompileTimeValue::ValueKind::StaticFunctionCall: {
1109+ auto staticFunctionCallValue = cast<StaticFunctionCallValue>(Element.get ());
1110+ if (staticFunctionCallValue->getLabel () == " buildExpression" ) {
1111+ for (auto FP : staticFunctionCallValue->getParameters ()) {
1112+ writeValue (JSON, FP.Value );
10731113 }
10741114 }
10751115 break ;
0 commit comments