mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10217 from ethereum/ewasm-main
[ewasm] Allow compiling Yul without "main"
This commit is contained in:
commit
bf40857018
@ -663,9 +663,11 @@ bytes BinaryTransform::globalSection(vector<wasm::GlobalVariableDeclaration> con
|
|||||||
|
|
||||||
bytes BinaryTransform::exportSection(map<string, size_t> const& _functionIDs)
|
bytes BinaryTransform::exportSection(map<string, size_t> const& _functionIDs)
|
||||||
{
|
{
|
||||||
bytes result = lebEncode(2);
|
bool hasMain = _functionIDs.count("main");
|
||||||
|
bytes result = lebEncode(hasMain ? 2 : 1);
|
||||||
result += encodeName("memory") + toBytes(Export::Memory) + lebEncode(0);
|
result += encodeName("memory") + toBytes(Export::Memory) + lebEncode(0);
|
||||||
result += encodeName("main") + toBytes(Export::Function) + lebEncode(_functionIDs.at("main"));
|
if (hasMain)
|
||||||
|
result += encodeName("main") + toBytes(Export::Function) + lebEncode(_functionIDs.at("main"));
|
||||||
return makeSection(Section::EXPORT, move(result));
|
return makeSection(Section::EXPORT, move(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,8 +56,13 @@ string TextTransform::run(wasm::Module const& _module)
|
|||||||
|
|
||||||
// allocate one 64k page of memory and make it available to the Ethereum client
|
// allocate one 64k page of memory and make it available to the Ethereum client
|
||||||
ret += " (memory $memory (export \"memory\") 1)\n";
|
ret += " (memory $memory (export \"memory\") 1)\n";
|
||||||
// export the main function
|
for (auto const& f: _module.functions)
|
||||||
ret += " (export \"main\" (func $main))\n";
|
if (f.name == "main")
|
||||||
|
{
|
||||||
|
// export the main function
|
||||||
|
ret += " (export \"main\" (func $main))\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
for (auto const& g: _module.globals)
|
for (auto const& g: _module.globals)
|
||||||
ret += " (global $" + g.variableName + " (mut " + encodeType(g.type) + ") (" + encodeType(g.type) + ".const 0))\n";
|
ret += " (global $" + g.variableName + " (mut " + encodeType(g.type) + ") (" + encodeType(g.type) + ".const 0))\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user