Movatterモバイル変換


[0]ホーム

URL:


  1. WebAssembly
  2. Reference
  3. WebAssembly variable instructions
  4. global

global: Wasm text instruction

Theglobal instruction declares a new global variable.

Try it

(module  (import "console" "log" (func $log (param i32)))  ;; import a global variable from js  (global $from_js (import "env" "from_js") i32)  ;; create a global variable  (global $from_wasm i32 (i32.const 10))  (func $main    ;; load both global variables onto the stack    global.get $from_js    global.get $from_wasm    i32.add ;; add up both globals    call $log ;; log the result  )  (start $main))
const url = "{%wasm-url%}";const from_js = new WebAssembly.Global({ value: "i32", mutable: false }, 5);await WebAssembly.instantiateStreaming(fetch(url), {  console,  env: { from_js },});

Syntax

wat
;; declare new variable named $val of type i32(global $val i32)

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp