| 11 | using namespace WasmVM::Parse; |
| 12 | |
| 13 | std::unordered_map<index_t, index_t> ParseContext::reorder_map(IndexSpace& space) { |
| 14 | std::unordered_map<index_t, index_t> result; |
| 15 | std::queue<index_t> indices; |
| 16 | for (index_t i = 0; i < space.records.size(); ++i) { |
| 17 | if (space.records[i] == IndexSpace::Type::Import) { |
| 18 | result[i] = result.size(); |
| 19 | } else { |
| 20 | indices.push(i); |
| 21 | } |
| 22 | } |
| 23 | while (!indices.empty()) { |
| 24 | result[indices.front()] = result.size(); |
| 25 | indices.pop(); |
| 26 | } |
| 27 | return result; |
| 28 | } |
| 29 | |
| 30 | void ParseContext::post_process() { |
| 31 | std::unordered_map<index_t, index_t> typemap; |