From b704abdd75c3b6a031626d23e2bd22b8cdc8b2b5 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 19 Jun 2019 18:17:50 +0200 Subject: [PATCH] Some eWasm boilerplate code. --- libyul/backends/wasm/EWasmToText.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libyul/backends/wasm/EWasmToText.cpp b/libyul/backends/wasm/EWasmToText.cpp index a0d552d11..4e2bf5c2b 100644 --- a/libyul/backends/wasm/EWasmToText.cpp +++ b/libyul/backends/wasm/EWasmToText.cpp @@ -34,9 +34,18 @@ string EWasmToText::run( vector 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) ret += " (global $" + g.variableName + " (mut i64) (i64.const 0))\n"; + ret += "\n"; for (auto const& f: _functions) ret += transform(f) + "\n"; return move(ret) + ")\n";