1. WebAssembly
  2. 参考
  3. WebAssembly 控制流指令
  4. Drop

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Drop

drop 指令,从栈中弹出一个值,并丢弃它。

尝试一下

(module
 (import "console" "log" (func $log (param i32)))
 (func $main
 ;; 将两个值加载进栈中
 i32.const 10
 i32.const 20
 ;; 丢弃栈顶项(`20`)
 drop
 call $log ;; 打印栈顶值(`10`)
 )
 (start $main)
)
const url = "{%wasm-url%}";
await WebAssembly.instantiateStreaming(fetch(url), { console });

语法

wat
;; 将多个值推入栈中
i32.const 1
i32.const 2
i32.const 3
;; 丢弃栈顶项(`3`)
drop
;; 现在栈顶项是 `2`
指令 二进制操作码
drop 0x1a

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.

AltStyle によって変換されたページ (->オリジナル) /