| 53 | } |
| 54 | |
| 55 | StringBox 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 | |
| 103 | const ReferenceInfo::Component* ReferenceInfo::begin() const { |
| 104 | return _components.data(); |