Skip to content

Commit 14f82c5

Browse files
authored
Update wabt to 1.0.27 (#81)
* Update wabt to 1.0.27 * Update wabt features * Fix msvc build by using a proper flag.
1 parent 11febd2 commit 14f82c5

5 files changed

Lines changed: 113 additions & 6 deletions

File tree

src/lib.rs

Lines changed: 95 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,16 @@ impl Features {
186186
self.enable_sign_extension();
187187
self.enable_simd();
188188
self.enable_threads();
189+
self.enable_function_references();
189190
self.enable_multi_value();
190191
self.enable_tail_call();
191192
self.enable_bulk_memory();
192193
self.enable_reference_types();
193194
self.enable_annotations();
195+
self.enable_gc();
196+
self.enable_memory64();
197+
self.enable_multi_memory();
198+
self.enable_extended_const();
194199
}
195200

196201
pub fn exceptions_enabled(&self) -> bool {
@@ -283,6 +288,21 @@ impl Features {
283288
}
284289
}
285290

291+
pub fn function_references_enabled(&self) -> bool {
292+
unsafe { ffi::wabt_function_references_enabled(self.raw) }
293+
}
294+
pub fn enable_function_references(&mut self) {
295+
self.set_function_references_enabled(true);
296+
}
297+
pub fn disable_function_references(&mut self) {
298+
self.set_function_references_enabled(false);
299+
}
300+
pub fn set_function_references_enabled(&mut self, value: bool) {
301+
unsafe {
302+
ffi::wabt_set_function_references_enabled(self.raw, value.into());
303+
}
304+
}
305+
286306
pub fn multi_value_enabled(&self) -> bool {
287307
unsafe { ffi::wabt_multi_value_enabled(self.raw) }
288308
}
@@ -357,6 +377,66 @@ impl Features {
357377
ffi::wabt_set_annotations_enabled(self.raw, value.into());
358378
}
359379
}
380+
381+
pub fn gc_enabled(&self) -> bool {
382+
unsafe { ffi::wabt_gc_enabled(self.raw) }
383+
}
384+
pub fn enable_gc(&mut self) {
385+
self.set_gc_enabled(true);
386+
}
387+
pub fn disable_gc(&mut self) {
388+
self.set_gc_enabled(false);
389+
}
390+
pub fn set_gc_enabled(&mut self, value: bool) {
391+
unsafe {
392+
ffi::wabt_set_gc_enabled(self.raw, value.into());
393+
}
394+
}
395+
396+
pub fn memory64_enabled(&self) -> bool {
397+
unsafe { ffi::wabt_memory64_enabled(self.raw) }
398+
}
399+
pub fn enable_memory64(&mut self) {
400+
self.set_memory64_enabled(true);
401+
}
402+
pub fn disable_memory64(&mut self) {
403+
self.set_memory64_enabled(false);
404+
}
405+
pub fn set_memory64_enabled(&mut self, value: bool) {
406+
unsafe {
407+
ffi::wabt_set_memory64_enabled(self.raw, value.into());
408+
}
409+
}
410+
411+
pub fn multi_memory_enabled(&self) -> bool {
412+
unsafe { ffi::wabt_multi_memory_enabled(self.raw) }
413+
}
414+
pub fn enable_multi_memory(&mut self) {
415+
self.set_multi_memory_enabled(true);
416+
}
417+
pub fn disable_mutli_memory(&mut self) {
418+
self.set_multi_memory_enabled(false);
419+
}
420+
pub fn set_multi_memory_enabled(&mut self, value: bool) {
421+
unsafe {
422+
ffi::wabt_set_multi_memory_enabled(self.raw, value.into());
423+
}
424+
}
425+
426+
pub fn extended_const_enabled(&self) -> bool {
427+
unsafe { ffi::wabt_extended_const_enabled(self.raw) }
428+
}
429+
pub fn enable_extended_const(&mut self) {
430+
self.set_extended_const_enabled(true);
431+
}
432+
pub fn disable_extended_const(&mut self) {
433+
self.set_extended_const_enabled(false);
434+
}
435+
pub fn set_extended_const_enabled(&mut self, value: bool) {
436+
unsafe {
437+
ffi::wabt_set_extended_const_enabled(self.raw, value.into());
438+
}
439+
}
360440
}
361441

362442
impl Drop for Features {
@@ -1218,18 +1298,30 @@ impl Drop for WabtWriteScriptResult {
12181298
}
12191299

12201300
#[test]
1221-
fn features() {
1301+
fn features_wasm_simd_enabled() {
1302+
// simd is enabled by default.
12221303
let example_wat = r#"
12231304
(module
12241305
(func $simd (result v128)
12251306
(v128.const i8x16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)
12261307
return)
12271308
)"#;
1309+
assert!(wat2wasm(example_wat).is_ok());
1310+
}
1311+
1312+
#[test]
1313+
fn features_wasm_features_annotations_disabled() {
1314+
let example_wat = r#"
1315+
(module
1316+
(func (@name "some func") (result i32)
1317+
i32.const 42
1318+
return)
1319+
)"#;
12281320

12291321
assert!(wat2wasm(example_wat).is_err());
12301322

12311323
let mut features = Features::new();
1232-
features.enable_simd();
1324+
features.enable_annotations();
12331325
assert!(wat2wasm_with_features(example_wat, features).is_ok());
12341326
}
12351327

@@ -1242,7 +1334,7 @@ fn module() {
12421334
(memory (data "hi"))
12431335
(type (func (param i32) (result i32)))
12441336
(start 1)
1245-
(table 0 1 anyfunc)
1337+
(table 0 1 funcref)
12461338
(func)
12471339
(func (type 1)
12481340
i32.const 42

src/script/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//! (func (export "sub") (param $x i32) (param $y i32) (result i32)
1818
//! ;; return x - y;
1919
//! (i32.sub
20-
//! (get_local $x) (get_local $y)
20+
//! (local.get $x) (local.get $y)
2121
//! )
2222
//! )
2323
//! )

wabt-sys/build.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ git submodule update --init --recursive",
8282
println!("cargo:rerun-if-changed=wabt/src/emscripten-helpers.cc");
8383

8484
let mut cfg = cc::Build::new();
85+
if cfg.get_compiler().is_like_msvc() {
86+
cfg.flag("/std:c++17");
87+
} else {
88+
cfg.flag("-std=c++17");
89+
}
90+
8591
cfg.file("wabt/src/emscripten-helpers.cc")
8692
.file("wabt_shim.cc")
8793
.include("wabt")
@@ -91,7 +97,6 @@ git submodule update --init --recursive",
9197
.cpp_link_stdlib(None)
9298
.warnings(false)
9399
.cpp(true)
94-
.flag("-std=c++11")
95100
.compile("wabt_shim");
96101
}
97102

wabt-sys/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ extern "C" {
3434
pub fn wabt_set_simd_enabled(features: *mut Features, enabled: c_int);
3535
pub fn wabt_threads_enabled(features: *const Features) -> bool;
3636
pub fn wabt_set_threads_enabled(features: *mut Features, enabled: c_int);
37+
pub fn wabt_function_references_enabled(features: *const Features) -> bool;
38+
pub fn wabt_set_function_references_enabled(features: *const Features, enabled: c_int);
3739
pub fn wabt_multi_value_enabled(features: *const Features) -> bool;
3840
pub fn wabt_set_multi_value_enabled(features: *mut Features, enabled: c_int);
3941
pub fn wabt_tail_call_enabled(features: *const Features) -> bool;
@@ -44,6 +46,14 @@ extern "C" {
4446
pub fn wabt_set_reference_types_enabled(features: *mut Features, enabled: c_int);
4547
pub fn wabt_annotations_enabled(features: *const Features) -> bool;
4648
pub fn wabt_set_annotations_enabled(features: *mut Features, enabled: c_int);
49+
pub fn wabt_gc_enabled(features: *const Features) -> bool;
50+
pub fn wabt_set_gc_enabled(features: *mut Features, enabled: c_int);
51+
pub fn wabt_memory64_enabled(features: *const Features) -> bool;
52+
pub fn wabt_set_memory64_enabled(features: *mut Features, enabled: c_int);
53+
pub fn wabt_multi_memory_enabled(features: *const Features) -> bool;
54+
pub fn wabt_set_multi_memory_enabled(features: *mut Features, enabled: c_int);
55+
pub fn wabt_extended_const_enabled(features: *const Features) -> bool;
56+
pub fn wabt_set_extended_const_enabled(features: *mut Features, enabled: c_int);
4757

4858
pub fn wabt_destroy_features(features: *mut Features);
4959

wabt-sys/wabt

Submodule wabt updated 1000 files

0 commit comments

Comments
 (0)