[ewasm] Clarify custom section handling in BinaryTransform

This commit is contained in:
Alex Beregszaszi
2020-11-09 17:47:01 +00:00
parent 9230ddf110
commit e41700e5f7
2 changed files with 9 additions and 5 deletions
+7 -5
View File
@@ -305,13 +305,15 @@ bytes BinaryTransform::run(Module const& _module)
ret += exportSection(functionIDs);
map<string, pair<size_t, size_t>> subModulePosAndSize;
for (auto const& sub: _module.subModules)
for (auto const& [name, module]: _module.subModules)
{
// TODO should we prefix and / or shorten the name?
bytes data = BinaryTransform::run(sub.second);
size_t length = data.size();
ret += customSection(sub.first, move(data));
subModulePosAndSize[sub.first] = {ret.size() - length, length};
bytes data = BinaryTransform::run(module);
size_t const length = data.size();
ret += customSection(name, move(data));
// Skip all the previous sections and the size field of this current custom section.
size_t const offset = ret.size() - length;
subModulePosAndSize[name] = {offset, length};
}
BinaryTransform bt(