| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/de/docs/WebAssembly/Reference/Control_flow/if...else | [Back] [Original] |
Get to know MDN better
Dieser Inhalt wurde automatisch aus dem Englischen bersetzt, und kann Fehler enthalten. Erfahre mehr ber dieses Experiment.
Die if-Anweisung fhrt eine Anweisung aus, wenn das letzte Element auf dem Stack wahr (ungleich null) ist. Wenn die Bedingung falsch (0) ist, kann eine andere Anweisung ausgefhrt werden.
(module
;; import the browser console object, you'll need to pass this in from JavaScript
(import "console" "log" (func $log (param i32)))
(func
i32.const 0 ;; change to positive number (true) if you want to run the if block
(if
(then
i32.const 1
call $log ;; should log '1'
)
(else
i32.const 0
call $log ;; should log '0'
)
)
)
(start 1) ;; run the first function automatically
)
const url = "{%wasm-url%}";
await WebAssembly.instantiateStreaming(fetch(url), { console });
i32.const 0
(if
(then
;; do something
)
(else
;; do something else
)
)
Um Rckgabewerte auf dem Stack zu belassen, fgen Sie die result-Anweisung hinzu.
i32.const 0
(if (result i32)
(then
;; do something
(i32.const 1)
)
(else
;; do something else
(i32.const 2)
)
)
(drop)
| Instruktion | Binrcode |
|---|---|
if |
0x04 |
else |
0x05 |
| Spezifikation |
|---|
| WebAssembly Core Specification # control-instructions%E2%91%A8 |
Der Bauplan fr ein besseres Internet.
Teile dieses Inhalts sind 19982026 von einzelnen mozilla.org-Mitwirkenden. Inhalte sind verfgbar unter einer Creative-Commons-Lizenz.
| Web Proxy Viewer | New URL | Original Page |