MCPcopy Create free account
hub / github.com/Snapchat/Valdi / toFunctionIdentifier

Method toFunctionIdentifier

valdi_core/src/valdi_core/cpp/Utils/ReferenceInfo.cpp:55–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55StringBox ReferenceInfo::toFunctionIdentifier() const {
56 auto it = rbegin();
57 auto end = rend();
58
59 std::string functionName;
60
61 while (it != end) {
62 const auto& component = *it;
63 std::string componentStr;
64
65 switch (component.type) {
66 case Component::Type::Unknown:
67 componentStr = "<anon>";
68 break;
69 case Component::Type::Property:
70 if (component.hasAssignedName) {
71 componentStr = getNameForComponent(component).slowToString();
72 } else {
73 componentStr = "<anon>";
74 }
75 break;
76 case Component::Type::ReturnValue:
77 componentStr = "<r>";
78 break;
79 case Component::Type::ParameterValue:
80 componentStr = fmt::format("<p{}>", component.index);
81 break;
82 case Component::Type::ArrayItem:
83 componentStr = fmt::format("[{}]", component.index);
84 break;
85 }
86
87 if (functionName.empty()) {
88 functionName = std::move(componentStr);
89 } else {
90 functionName.append(1, '.');
91 functionName += componentStr;
92 }
93 it++;
94 }
95
96 if (functionName.empty()) {
97 functionName = "<anon>";
98 }
99
100 return StringCache::getGlobal().makeString(std::move(functionName));
101}
102
103const ReferenceInfo::Component* ReferenceInfo::begin() const {
104 return _components.data();

Callers 3

TESTFunction · 0.80

Calls 5

getGlobalFunction · 0.85
slowToStringMethod · 0.80
makeStringMethod · 0.80
appendMethod · 0.65
emptyMethod · 0.45

Tested by 1

TESTFunction · 0.64