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

  • 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.

主站蜘蛛池模板: 海兴县| 台湾省| 博湖县| 洱源县| 沂源县| 神木县| 锡林郭勒盟| 嵩明县| 临夏县| 盖州市| 杭州市| 舟山市| 平山县| 阿尔山市| 醴陵市| 新泰市| 新干县| 碌曲县| 彭阳县| 曲水县| 鄂尔多斯市| 敦煌市| 湖南省| 大荔县| 临夏县| 神木县| 江门市| 香河县| 云南省| 德惠市| 永康市| 日土县| 东乌珠穆沁旗| 任丘市| 常山县| 时尚| 历史| 和平县| 广西| 津市市| 武定县|