mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
wasm/BinaryTransform: Make global/function/type maps constant
This commit is contained in:
parent
4b1ea93b41
commit
adbd4be151
@ -253,13 +253,13 @@ bytes makeSection(Section _section, bytes _data)
|
||||
|
||||
bytes BinaryTransform::run(Module const& _module)
|
||||
{
|
||||
BinaryTransform bt;
|
||||
|
||||
map<Type, vector<string>> const types = typeToFunctionMap(_module.imports, _module.functions);
|
||||
|
||||
bt.m_globals = enumerateGlobals(_module);
|
||||
bt.m_functions = enumerateFunctions(_module);
|
||||
bt.m_functionTypes = enumerateFunctionTypes(types);
|
||||
BinaryTransform bt(
|
||||
enumerateGlobals(_module),
|
||||
enumerateFunctions(_module),
|
||||
enumerateFunctionTypes(types)
|
||||
);
|
||||
|
||||
yulAssert(bt.m_globals.size() == _module.globals.size(), "");
|
||||
yulAssert(bt.m_functions.size() == _module.imports.size() + _module.functions.size(), "");
|
||||
@ -576,7 +576,7 @@ bytes BinaryTransform::importSection(
|
||||
encodeName(import.module) +
|
||||
encodeName(import.externalName) +
|
||||
toBytes(importKind) +
|
||||
lebEncode(m_functionTypes[import.internalName]);
|
||||
lebEncode(m_functionTypes.at(import.internalName));
|
||||
}
|
||||
return makeSection(Section::IMPORT, std::move(result));
|
||||
}
|
||||
|
@ -55,6 +55,16 @@ public:
|
||||
bytes operator()(wasm::FunctionDefinition const& _function);
|
||||
|
||||
private:
|
||||
BinaryTransform(
|
||||
std::map<std::string, size_t> _globals,
|
||||
std::map<std::string, size_t> _functions,
|
||||
std::map<std::string, size_t> _functionTypes
|
||||
):
|
||||
m_globals(std::move(_globals)),
|
||||
m_functions(std::move(_functions)),
|
||||
m_functionTypes(std::move(_functionTypes))
|
||||
{}
|
||||
|
||||
using Type = std::pair<std::vector<std::uint8_t>, std::vector<std::uint8_t>>;
|
||||
static Type typeOf(wasm::FunctionImport const& _import);
|
||||
static Type typeOf(wasm::FunctionDefinition const& _funDef);
|
||||
@ -89,10 +99,11 @@ private:
|
||||
|
||||
static bytes encodeName(std::string const& _name);
|
||||
|
||||
std::map<std::string, size_t> const m_globals;
|
||||
std::map<std::string, size_t> const m_functions;
|
||||
std::map<std::string, size_t> const m_functionTypes;
|
||||
|
||||
std::map<std::string, size_t> m_locals;
|
||||
std::map<std::string, size_t> m_globals;
|
||||
std::map<std::string, size_t> m_functions;
|
||||
std::map<std::string, size_t> m_functionTypes;
|
||||
std::vector<std::string> m_labels;
|
||||
std::map<std::string, std::pair<size_t, size_t>> m_subModulePosAndSize;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user