summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wasm2asm.h11
-rw-r--r--test/emcc_O2_hello_world.2asm.js20
-rw-r--r--test/hello_world.2asm.js3
-rw-r--r--test/min.2asm.js3
-rw-r--r--test/unit.2asm.js3
5 files changed, 39 insertions, 1 deletions
diff --git a/src/wasm2asm.h b/src/wasm2asm.h
index 62baf1b54..9921c3e3e 100644
--- a/src/wasm2asm.h
+++ b/src/wasm2asm.h
@@ -165,6 +165,7 @@ private:
void addBasics(Ref ast);
void addImport(Ref ast, Import *import);
void addTables(Ref ast, Module *wasm);
+ void addExports(Ref ast, Module *wasm);
};
Ref Wasm2AsmBuilder::processWasm(Module* wasm) {
@@ -194,8 +195,8 @@ Ref Wasm2AsmBuilder::processWasm(Module* wasm) {
asmFunc[3]->push_back(processFunction(func));
}
addTables(asmFunc[3], wasm);
- // table XXX
// memory XXX
+ addExports(asmFunc[3], wasm);
return ret;
}
@@ -288,6 +289,14 @@ void Wasm2AsmBuilder::addTables(Ref ast, Module *wasm) {
}
}
+void Wasm2AsmBuilder::addExports(Ref ast, Module *wasm) {
+ Ref exports = ValueBuilder::makeObject();
+ for (auto export_ : wasm->exports) {
+ ValueBuilder::appendToObject(exports, fromName(export_->name), ValueBuilder::makeName(fromName(export_->value)));
+ }
+ ast->push_back(ValueBuilder::makeStatement(ValueBuilder::makeReturn(exports)));
+}
+
Ref Wasm2AsmBuilder::processFunction(Function* func) {
Ref ret = ValueBuilder::makeFunction(fromName(func->name));
frees.clear();
diff --git a/test/emcc_O2_hello_world.2asm.js b/test/emcc_O2_hello_world.2asm.js
index 09ee16196..2dfc2bfdc 100644
--- a/test/emcc_O2_hello_world.2asm.js
+++ b/test/emcc_O2_hello_world.2asm.js
@@ -2530,5 +2530,25 @@ function asmFunc(global, env, buffer) {
var FUNCTION_TABLE_ii = [b0, ___stdio_close, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0, b0];
var FUNCTION_TABLE_iiii = [b1, b1, b1, b1, ___stdout_write, ___stdio_seek, b1, ___stdio_write, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1];
var FUNCTION_TABLE_vi = [b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, _cleanup_418, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2];
+ return {
+ "_free": _free,
+ "_main": _main,
+ "_memset": _memset,
+ "_malloc": _malloc,
+ "_memcpy": _memcpy,
+ "_fflush": _fflush,
+ "___errno_location": ___errno_location,
+ "runPostSets": runPostSets,
+ "stackAlloc": stackAlloc,
+ "stackSave": stackSave,
+ "stackRestore": stackRestore,
+ "establishStackSpace": establishStackSpace,
+ "setThrew": setThrew,
+ "setTempRet0": setTempRet0,
+ "getTempRet0": getTempRet0,
+ "dynCall_ii": dynCall_ii,
+ "dynCall_iiii": dynCall_iiii,
+ "dynCall_vi": dynCall_vi
+ };
}
diff --git a/test/hello_world.2asm.js b/test/hello_world.2asm.js
index 48b0538c8..f4998576b 100644
--- a/test/hello_world.2asm.js
+++ b/test/hello_world.2asm.js
@@ -15,5 +15,8 @@ function asmFunc(global, env, buffer) {
return x + y | 0 | 0;
}
+ return {
+ "add": add
+ };
}
diff --git a/test/min.2asm.js b/test/min.2asm.js
index c1cd2b64c..7a3cdc174 100644
--- a/test/min.2asm.js
+++ b/test/min.2asm.js
@@ -25,5 +25,8 @@ function asmFunc(global, env, buffer) {
n = wasm2asm_f32$0;
}
+ return {
+ "floats": floats
+ };
}
diff --git a/test/unit.2asm.js b/test/unit.2asm.js
index b705e1e64..88ab681e1 100644
--- a/test/unit.2asm.js
+++ b/test/unit.2asm.js
@@ -214,5 +214,8 @@ function asmFunc(global, env, buffer) {
var FUNCTION_TABLE_d = [importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles];
var FUNCTION_TABLE_v = [z, big_negative, z, z, w, w, z, w, z, neg, z, z, z, z, z, z];
+ return {
+ "big_negative": big_negative
+ };
}