Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create JavaScript array without using new keyword. #1987

Merged
merged 7 commits into from
Feb 7, 2020
2 changes: 1 addition & 1 deletion crates/anyref-xform/tests/table.wat
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
(table (;0;) 2 funcref)
(table (;1;) 32 anyref)
(export "func" (table 0))
(elem (;0;) (i32.const 0) $foo $closure0 anyref shim))
(elem (;0;) (i32.const 0) func $foo $closure0 anyref shim))
;)
4 changes: 2 additions & 2 deletions crates/cli-support/src/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,8 @@ impl<'a> Context<'a> {
return;
}
assert!(!self.config.anyref);
self.global(&format!("const heap = new Array({});", INITIAL_HEAP_OFFSET));
self.global("heap.fill(undefined);");
self.global(&format!("const heap = [];"));
self.global(&format!("heap.length = {};", INITIAL_HEAP_OFFSET));
self.global(&format!("heap.push({});", INITIAL_HEAP_VALUES.join(", ")));
}

Expand Down
2 changes: 1 addition & 1 deletion crates/cli/tests/reference/anyref-empty.wat
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(type (;0;) (func))
(import "./reference_test.js" "__wbindgen_init_anyref_table" (func (;0;) (type 0)))
(table (;0;) 32 anyref)
(memory (;0;) 17)
(memory (;0;) 16)
(export "memory" (memory 0))
(export "__wbindgen_export_0" (table 0))
(export "__wbindgen_start" (func 0)))
2 changes: 1 addition & 1 deletion crates/cli/tests/reference/empty.wat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(module
(memory (;0;) 17)
(memory (;0;) 16)
(export "memory" (memory 0)))
4 changes: 2 additions & 2 deletions crates/cli/tests/reference/import-catch.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as wasm from './reference_test_bg.wasm';

const heap = new Array(32);
const heap = [];

heap.fill(undefined);
heap.length = 32;

heap.push(undefined, null, true, false);

Expand Down