Merge pull request #6970 from ethereum/ewasmBoilerplate

Some eWasm boilerplate code.
This commit is contained in:
chriseth 2019-06-19 19:12:48 +02:00 committed by GitHub
commit d4a6844e64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,9 +34,18 @@ string EWasmToText::run(
vector<wasm::FunctionDefinition> const& _functions vector<wasm::FunctionDefinition> const& _functions
) )
{ {
string ret = "(module\n\n"; string ret = "(module\n";
// TODO Add all the interface functions:
// ret += " (import \"ethereum\" \"getBalance\" (func $getBalance (param i32 i32)))\n";
// allocate one 64k page of memory and make it available to the Ethereum client
ret += " (memory $memory (export \"memory\") 1)\n";
// export the main function
ret += " (export \"main\" (func $main))\n";
for (auto const& g: _globals) for (auto const& g: _globals)
ret += " (global $" + g.variableName + " (mut i64) (i64.const 0))\n"; ret += " (global $" + g.variableName + " (mut i64) (i64.const 0))\n";
ret += "\n";
for (auto const& f: _functions) for (auto const& f: _functions)
ret += transform(f) + "\n"; ret += transform(f) + "\n";
return move(ret) + ")\n"; return move(ret) + ")\n";