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

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.

主站蜘蛛池模板: 中宁县| 黎城县| 罗山县| 固原市| 巴马| 诸城市| 独山县| 南充市| 呼和浩特市| 翁牛特旗| 台南市| 集贤县| 莱芜市| 丹江口市| 南华县| 昌都县| 商南县| 子长县| 阳城县| 东乡族自治县| 通辽市| 澎湖县| 来宾市| 屏东县| 湘潭市| 拜泉县| 贵德县| 万盛区| 古田县| 明光市| 唐海县| 永宁县| 南京市| 佳木斯市| 合阳县| 盘山县| 谢通门县| 霸州市| 永昌县| 杂多县| 池州市|