From ee00f647750f23e6c24e67424bafab39b244c835 Mon Sep 17 00:00:00 2001
From: Sam Clegg <sbc@chromium.org>
Date: Mon, 21 Sep 2020 16:39:46 -0700
Subject: wasm2js: Support exported tables (#3152)

---
 test/wasm2js/dynamicLibrary.2asm.js.opt | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

(limited to 'test/wasm2js/dynamicLibrary.2asm.js.opt')

diff --git a/test/wasm2js/dynamicLibrary.2asm.js.opt b/test/wasm2js/dynamicLibrary.2asm.js.opt
index 71fa441ed..d8f0ec348 100644
--- a/test/wasm2js/dynamicLibrary.2asm.js.opt
+++ b/test/wasm2js/dynamicLibrary.2asm.js.opt
@@ -1,6 +1,17 @@
 import { memoryBase } from 'env';
 import { tableBase } from 'env';
 
+function Table(ret) {
+  // grow method not included; table is not growable
+  ret.set = function(i, func) {
+    this[i] = func;
+  };
+  ret.get = function(i) {
+    return this[i];
+  };
+  return ret;
+}
+
 function asmFunc(global, env, buffer) {
  var memory = env.memory;
  var HEAP8 = new global.Int8Array(buffer);
@@ -29,7 +40,7 @@ function asmFunc(global, env, buffer) {
   
  }
  
- var FUNCTION_TABLE = [];
+ var FUNCTION_TABLE = new Table(new Array(10));
  FUNCTION_TABLE[import$tableBase + 0] = foo;
  FUNCTION_TABLE[import$tableBase + 1] = foo;
  function __wasm_memory_size() {
@@ -37,7 +48,8 @@ function asmFunc(global, env, buffer) {
  }
  
  return {
-  "baz": foo
+  "baz": foo, 
+  "tab": FUNCTION_TABLE
  };
 }
 
-- 
cgit v1.2.3