mirror of
https://github.com/mii443/wasmer.git
synced 2025-08-22 16:35:33 +00:00
feat(api): Update WAT version
Also, rename all occurrences of `set_local` to `local.set`, `get_local` to `local.get` and `anyfunc` to `funcref`
This commit is contained in:
@ -38,7 +38,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
(block
|
||||
(loop
|
||||
(call $add_to_counter (i32.const 1))
|
||||
(set_local $x (i32.sub (get_local $x) (i32.const 1)))
|
||||
(local.set $x (i32.sub (get_local $x) (i32.const 1)))
|
||||
(br_if 1 (i32.eq (get_local $x) (i32.const 0)))
|
||||
(br 0)))
|
||||
call $get_counter)
|
||||
|
@ -40,7 +40,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
(block
|
||||
(loop
|
||||
(call $add_to_counter (i32.const 1))
|
||||
(set_local $x (i32.sub (get_local $x) (i32.const 1)))
|
||||
(local.set $x (i32.sub (get_local $x) (i32.const 1)))
|
||||
(br_if 1 (i32.eq (get_local $x) (i32.const 0)))
|
||||
(br 0)))
|
||||
call $get_counter)
|
||||
|
@ -32,7 +32,7 @@ derivative = { version = "^2" }
|
||||
bytes = "1"
|
||||
tracing = { version = "0.1" }
|
||||
# - Optional shared dependencies.
|
||||
wat = { version = "=1.0.71", optional = true }
|
||||
wat = { version = "=1.216.0", optional = true }
|
||||
rustc-demangle = "0.1"
|
||||
shared-buffer = { workspace = true }
|
||||
|
||||
|
2
lib/api/src/js/externals/table.rs
vendored
2
lib/api/src/js/externals/table.rs
vendored
@ -42,7 +42,7 @@ impl Table {
|
||||
if let Some(max) = ty.maximum {
|
||||
js_sys::Reflect::set(&descriptor, &"maximum".into(), &max.into())?;
|
||||
}
|
||||
js_sys::Reflect::set(&descriptor, &"element".into(), &"anyfunc".into())?;
|
||||
js_sys::Reflect::set(&descriptor, &"element".into(), &"funcref".into())?;
|
||||
|
||||
let js_table = js_sys::WebAssembly::Table::new(&descriptor)?;
|
||||
let table = VMTable::new(js_table, ty);
|
||||
|
0
lib/api/src/lib.rs
Executable file → Normal file
0
lib/api/src/lib.rs
Executable file → Normal file
@ -35,7 +35,7 @@ fn imports() -> Result<(), String> {
|
||||
let wat = r#"(module
|
||||
(import "host" "func" (func))
|
||||
(import "host" "memory" (memory 1))
|
||||
(import "host" "table" (table 1 anyfunc))
|
||||
(import "host" "table" (table 1 funcref))
|
||||
(import "host" "global" (global i32))
|
||||
)"#;
|
||||
let module = Module::new(&store, wat).map_err(|e| format!("{e:?}"))?;
|
||||
|
@ -253,7 +253,7 @@ pub unsafe extern "C" fn wasm_module_exports(
|
||||
/// "(module\n"
|
||||
/// " (import \"ns\" \"function\" (func))\n"
|
||||
/// " (import \"ns\" \"global\" (global f32))\n"
|
||||
/// " (import \"ns\" \"table\" (table 1 2 anyfunc))\n"
|
||||
/// " (import \"ns\" \"table\" (table 1 2 funcref))\n"
|
||||
/// " (import \"ns\" \"memory\" (memory 3 4)))"
|
||||
/// );
|
||||
/// wasm_byte_vec_t wasm;
|
||||
@ -668,7 +668,7 @@ mod tests {
|
||||
"(module\n"
|
||||
" (import \"ns\" \"function\" (func))\n"
|
||||
" (import \"ns\" \"global\" (global f32))\n"
|
||||
" (import \"ns\" \"table\" (table 1 2 anyfunc))\n"
|
||||
" (import \"ns\" \"table\" (table 1 2 funcref))\n"
|
||||
" (import \"ns\" \"memory\" (memory 3 4)))"
|
||||
);
|
||||
wasm_byte_vec_t wasm;
|
||||
|
@ -1,6 +1,6 @@
|
||||
(module
|
||||
(func (export "func") (param i32 f64 f32) (result i32) (unreachable))
|
||||
(global (export "global") f64 (f64.const 0))
|
||||
(table (export "table") 0 50 anyfunc)
|
||||
(table (export "table") 0 50 funcref)
|
||||
(memory (export "memory") 1)
|
||||
)
|
||||
|
@ -111,41 +111,41 @@ fn complex_loop(mut config: crate::Config) -> Result<()> {
|
||||
(local $l0 i32)
|
||||
block $B0
|
||||
i32.const 0
|
||||
set_local $l0
|
||||
local.set $l0
|
||||
loop $L1
|
||||
get_local $l0
|
||||
get_local $p0
|
||||
local.get $l0
|
||||
local.get $p0
|
||||
i32.lt_s
|
||||
i32.eqz
|
||||
br_if $B0
|
||||
get_local $l0
|
||||
local.get $l0
|
||||
i32.const 1
|
||||
i32.rem_s
|
||||
i32.const 0
|
||||
i32.eq
|
||||
if $I2
|
||||
get_local $p1
|
||||
get_local $l0
|
||||
local.get $p1
|
||||
local.get $l0
|
||||
i32.add
|
||||
set_local $p1
|
||||
local.set $p1
|
||||
else
|
||||
get_local $p1
|
||||
get_local $l0
|
||||
local.get $p1
|
||||
local.get $l0
|
||||
i32.mul
|
||||
set_local $p1
|
||||
local.set $p1
|
||||
end
|
||||
get_local $l0
|
||||
local.get $l0
|
||||
i32.const 1
|
||||
i32.add
|
||||
set_local $l0
|
||||
local.set $l0
|
||||
br $L1
|
||||
unreachable
|
||||
end
|
||||
unreachable
|
||||
end
|
||||
get_local $p1)
|
||||
local.get $p1)
|
||||
(func $f1 (type $t1))
|
||||
(table $table (export "table") 1 anyfunc)
|
||||
(table $table (export "table") 1 funcref)
|
||||
(memory $memory (export "memory") 0)
|
||||
(global $g0 i32 (i32.const 8))
|
||||
(elem (i32.const 0) $f1))
|
||||
|
Reference in New Issue
Block a user