@@ -294,12 +294,12 @@ static std::shared_ptr<CompileTimeValue> extractCompileTimeValue(Expr *expr) {
294
294
295
295
if (functionKind == ExprKind::DeclRef) {
296
296
auto declRefExpr = cast<DeclRefExpr>(callExpr->getFn ());
297
- auto caseName =
297
+ auto identifier =
298
298
declRefExpr->getDecl ()->getName ().getBaseIdentifier ().str ().str ();
299
299
300
300
std::vector<FunctionParameter> parameters =
301
301
extractFunctionArguments (callExpr->getArgs ());
302
- return std::make_shared<FunctionCallValue>(caseName , parameters);
302
+ return std::make_shared<FunctionCallValue>(identifier , parameters);
303
303
}
304
304
305
305
if (functionKind == ExprKind::ConstructorRefCall) {
@@ -313,12 +313,33 @@ static std::shared_ptr<CompileTimeValue> extractCompileTimeValue(Expr *expr) {
313
313
auto fn = dotSyntaxCallExpr->getFn ();
314
314
if (fn->getKind () == ExprKind::DeclRef) {
315
315
auto declRefExpr = cast<DeclRefExpr>(fn);
316
- auto caseName =
316
+ auto baseIdentifierName =
317
317
declRefExpr->getDecl ()->getName ().getBaseIdentifier ().str ().str ();
318
318
319
319
std::vector<FunctionParameter> parameters =
320
320
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
+ }
322
343
}
323
344
}
324
345
@@ -836,6 +857,27 @@ void writeValue(llvm::json::OStream &JSON,
836
857
break ;
837
858
}
838
859
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
+
839
881
case CompileTimeValue::ValueKind::MemberReference: {
840
882
auto memberReferenceValue = cast<MemberReferenceValue>(value);
841
883
JSON.attribute (" valueKind" , " MemberReference" );
@@ -846,6 +888,7 @@ void writeValue(llvm::json::OStream &JSON,
846
888
});
847
889
break ;
848
890
}
891
+
849
892
case CompileTimeValue::ValueKind::InterpolatedString: {
850
893
auto interpolatedStringValue = cast<InterpolatedStringLiteralValue>(value);
851
894
JSON.attribute (" valueKind" , " InterpolatedStringLiteral" );
@@ -1049,14 +1092,11 @@ createBuilderCompileTimeValue(CustomAttr *AttachedResultBuilder,
1049
1092
void writeSingleBuilderMemberElement (
1050
1093
llvm::json::OStream &JSON, std::shared_ptr<CompileTimeValue> Element) {
1051
1094
switch (Element.get ()->getKind ()) {
1052
- case CompileTimeValue::ValueKind::Enum: {
1053
- auto enumValue = cast<EnumValue>(Element.get ());
1054
- if (enumValue->getIdentifier () == " buildExpression" ) {
1055
- if (enumValue->getParameters ().has_value ()) {
1056
- auto params = enumValue->getParameters ().value ();
1057
- for (auto FP : params) {
1058
- writeValue (JSON, FP.Value );
1059
- }
1095
+ case CompileTimeValue::ValueKind::StaticFunctionCall: {
1096
+ auto staticFunctionCallValue = cast<StaticFunctionCallValue>(Element.get ());
1097
+ if (staticFunctionCallValue->getLabel () == " buildExpression" ) {
1098
+ for (auto FP : staticFunctionCallValue->getParameters ()) {
1099
+ writeValue (JSON, FP.Value );
1060
1100
}
1061
1101
}
1062
1102
break ;
0 commit comments