官术网_书友最值得收藏!

  • Learn WebAssembly
  • Mike Rourke
  • 170字
  • 2021-08-13 15:38:55

C code to Wat

The upper-left pane in the following screenshot contains a simple C function that adds 2 to the number specified as a parameter. The lower-left pane contains the corresponding Wat:

C function and the corresponding Wat

If this looks familiar, it's because this same code was used for the explanation of Wat's s-expressions in the beginning of this chapter. Digging a little deeper, you can see how the C code corresponds to the Wat output. The addTwo() function is exported from the module as a string on line 5. Line 5 also contains (func $addTwo), which references the $addTwo function on line 6. Line 6 specifies that a single parameter of type i32 (an integer) can be passed in and the result returned is also an i32. Pressing the Build button in the upper-right corner (or above the C/C++ editor) will compile the C code into a Wasm file. The Wasm will be available for download or interaction with JavaScript once the build is completed.

主站蜘蛛池模板: 施秉县| 绥中县| 固原市| 长顺县| 太仓市| 炉霍县| 吉安县| 陇川县| 贞丰县| 张家口市| 凤阳县| 香港| 昔阳县| 梧州市| 松潘县| 洛南县| 阿拉善盟| 绥中县| 德江县| 廊坊市| 邛崃市| 宁晋县| 永和县| 乌拉特前旗| 木里| 高邮市| 华蓥市| 大兴区| 平远县| 巴中市| 民权县| 大邑县| 麻栗坡县| 南丹县| 元谋县| 襄樊市| 安仁县| 观塘区| 无为县| 望都县| 宣城市|