mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[ewasm] Clarify custom section handling in BinaryTransform
This commit is contained in:
parent
9230ddf110
commit
e41700e5f7
@ -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(
|
||||
|
@ -112,6 +112,8 @@ private:
|
||||
std::map<std::string, size_t> const m_globalIDs;
|
||||
std::map<std::string, size_t> const m_functionIDs;
|
||||
std::map<std::string, size_t> const m_functionTypes;
|
||||
/// The map of submodules, where the pair refers to the [offset, length]. The offset is
|
||||
/// an absolute offset within the resulting assembled bytecode.
|
||||
std::map<std::string, std::pair<size_t, size_t>> const m_subModulePosAndSize;
|
||||
|
||||
std::map<std::string, size_t> m_locals;
|
||||
|
Loading…
Reference in New Issue
Block a user