常量

const 指令用于声明数字。

试一试

(module
  (import "console" "log" (func $log (param i32)))
  (func $main

    i32.const 10 ;; load a number onto the stack
    call $log ;; log the number

  )
  (start $main)
)
const url = "{%wasm-url%}";
await WebAssembly.instantiateStreaming(fetch(url), { console });

语法

wat
;; push `5` onto the stack
i32.const 5
指令 二进制操作码
i32.const 0x41
i64.const 0x42
f32.const 0x43
f64.const 0x44