Index: src/wasm/wasm-js.cc |
diff --git a/src/wasm/wasm-js.cc b/src/wasm/wasm-js.cc |
index b443610449aea77b91b0601055a1ed7b827fc839..8a4b06d9253a7451a104a8486f45377bc185bbd5 100644 |
--- a/src/wasm/wasm-js.cc |
+++ b/src/wasm/wasm-js.cc |
@@ -262,6 +262,36 @@ void WebAssemblyModuleImports(const v8::FunctionCallbackInfo<v8::Value>& args) { |
return_value.Set(Utils::ToLocal(imports)); |
} |
+void WebAssemblyModuleExports(const v8::FunctionCallbackInfo<v8::Value>& args) { |
+ HandleScope scope(args.GetIsolate()); |
+ v8::Isolate* isolate = args.GetIsolate(); |
+ i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
+ |
+ ErrorThrower thrower(i_isolate, "WebAssembly.Module.exports()"); |
+ |
+ if (args.Length() < 1) { |
+ thrower.TypeError("Argument 0 must be a WebAssembly.Module"); |
+ return; |
+ } |
+ |
+ Local<Context> context = isolate->GetCurrentContext(); |
+ i::Handle<i::Context> i_context = Utils::OpenHandle(*context); |
+ if (!BrandCheck(isolate, Utils::OpenHandle(*args[0]), |
+ i::Handle<i::Symbol>(i_context->wasm_module_sym()), |
+ "Argument 0 must be a WebAssembly.Module")) { |
+ return; |
+ } |
+ |
+ Local<Object> module_obj = Local<Object>::Cast(args[0]); |
+ i::Handle<i::WasmModuleObject> i_module_obj = |
+ i::Handle<i::WasmModuleObject>::cast(v8::Utils::OpenHandle(*module_obj)); |
+ |
+ i::Handle<i::JSArray> exports = i::wasm::GetExports(i_isolate, i_module_obj); |
+ |
+ v8::ReturnValue<v8::Value> return_value = args.GetReturnValue(); |
+ return_value.Set(Utils::ToLocal(exports)); |
+} |
+ |
void WebAssemblyInstanceCtor(const v8::FunctionCallbackInfo<v8::Value>& args) { |
HandleScope scope(args.GetIsolate()); |
v8::Isolate* isolate = args.GetIsolate(); |
@@ -753,6 +783,8 @@ void WasmJs::InstallWasmConstructors(Isolate* isolate, |
module_constructor, DONT_ENUM); |
InstallFunc(isolate, module_constructor, "imports", WebAssemblyModuleImports, |
1); |
+ InstallFunc(isolate, module_constructor, "exports", WebAssemblyModuleExports, |
+ 1); |
// Setup Instance |
Handle<JSFunction> instance_constructor = |