Preprocessing for set up aliasing.
| 41 | |
| 42 | // Preprocessing for set up aliasing. |
| 43 | void resolveRegister(std::map<std::string, std::string> &Alias, |
| 44 | simdjson::dom::array &CmdArray) { |
| 45 | std::string_view OrgName; |
| 46 | uint64_t LastModLine = 0; |
| 47 | for (const simdjson::dom::object &Cmd : CmdArray) { |
| 48 | std::string_view CmdType = Cmd["type"]; |
| 49 | if (CmdType == "module"sv) { |
| 50 | // Record last module in order |
| 51 | if (Cmd["name"].get(OrgName)) { |
| 52 | OrgName = {}; |
| 53 | } |
| 54 | LastModLine = Cmd["line"]; |
| 55 | } else if (CmdType == "register"sv) { |
| 56 | std::string_view NewNameStr = Cmd["as"]; |
| 57 | std::string_view Value; |
| 58 | if (!Cmd["name"].get(Value)) { |
| 59 | // Register command records the original name. Set aliasing. |
| 60 | Alias.emplace(std::string(Value), std::string(NewNameStr)); |
| 61 | } else { |
| 62 | // Register command does not record the original name. Get name from the |
| 63 | // module. |
| 64 | if (OrgName.empty()) { |
| 65 | // Module has no origin name. Alias to the latest anonymous module. |
| 66 | Alias.emplace(std::to_string(LastModLine), NewNameStr); |
| 67 | } else { |
| 68 | // Module has origin name. Replace to aliased one. |
| 69 | Alias.emplace(std::string(OrgName), NewNameStr); |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | SpecTest::CommandID resolveCommand(std::string_view Name) { |
| 77 | static const std::unordered_map<std::string_view, SpecTest::CommandID, |
no test coverage detected