wasm2kt

所属分类:工具库
开发工具:WebAssembly
文件大小:0KB
下载次数:0
上传日期:2023-06-09 13:20:58
上 传 者sh-1993
说明:  Web Assembly到Kotlin和Java转换器。允许编译C或C++程序库,并生成Kotlin或Java程序库。,
(Web Assembly to Kotlin and Java converter. Allows to compile a C or C++ program library, and generate a Kotlin or Java program library.,)

文件列表:
LICENSE (1083, 2023-06-09)
build.gradle (1256, 2023-06-09)
gradle/ (0, 2023-06-09)
gradle/wrapper/ (0, 2023-06-09)
gradle/wrapper/gradle-wrapper.jar (55616, 2023-06-09)
gradle/wrapper/gradle-wrapper.properties (202, 2023-06-09)
gradlew (5917, 2023-06-09)
gradlew.bat (2842, 2023-06-09)
ref/ (0, 2023-06-09)
ref/library_syscall.js (63839, 2023-06-09)
ref/syscalls.txt (9827, 2023-06-09)
samples/ (0, 2023-06-09)
samples/nanosvg/ (0, 2023-06-09)
samples/nanosvg/23.svg (96719, 2023-06-09)
samples/nanosvg/build.sh (89, 2023-06-09)
samples/nanosvg/example2.c (2242, 2023-06-09)
samples/nanosvg/nanosvg.h (78051, 2023-06-09)
samples/nanosvg/nanosvgrast.h (38358, 2023-06-09)
samples/nanosvg/stb_image_write.h (18542, 2023-06-09)
samples/newformat/ (0, 2023-06-09)
samples/newformat/wasm-program.c (243, 2023-06-09)
samples/newformat/wasm-program.wasm (8028, 2023-06-09)
samples/newformat/wasm-program.wasm.map (6581, 2023-06-09)
samples/newformat/wasm-program.wat (110956, 2023-06-09)
settings.gradle (30, 2023-06-09)
src/ (0, 2023-06-09)
src/main/ (0, 2023-06-09)
src/main/kotlin/ (0, 2023-06-09)
src/main/kotlin/com/ (0, 2023-06-09)
src/main/kotlin/com/soywiz/ (0, 2023-06-09)
src/main/kotlin/com/soywiz/wasm/ (0, 2023-06-09)
src/main/kotlin/com/soywiz/wasm/StackToAst.kt (12529, 2023-06-09)
src/main/kotlin/com/soywiz/wasm/Wasm.kt (2952, 2023-06-09)
src/main/kotlin/com/soywiz/wasm/WasmFunc.kt (1315, 2023-06-09)
src/main/kotlin/com/soywiz/wasm/WasmInstruction.kt (2131, 2023-06-09)
... ...

[![Build Status](https://travis-ci.org/soywiz/wasm2kt.svg?branch=master)](https://travis-ci.org/soywiz/wasm2kt) ### Summary This project allows to convert WASM (Web Assembly) from its binary format into Kotlin code. This allow for example to compile C or C++ libraries and use them in Kotlin common in any supported target including JVM, JS and Native. The converter itself is written in kotlin. ### How to use Generate a Hello World in WASM: ```bash echo -e "#include \nint main() { printf(\"hello world\\\n\"); for (int n = 0; n < 10; n++) printf(\"%d,\", n); printf(\"\\\n\"); return 0; }" > hello.c docker run --rm -v $(pwd):/src -t apiaryio/emcc:1.37 emconfigure emcc hello.c -o hello -O3 -s WASM=1 ``` This will generate a `hello.wasm` file. After that, you can use this project to generate a kotlin executable `kt` file from it: ```bash echo '#!/usr/bin/env kscript' > hello.kt cat src/main/kotlin/com/soywiz/wasm/WasmModule.kt >> hello.kt ./wasm2kt.kts hello.wasm >> hello.kt echo -e "fun main(args: Array) = Module.main(args)" >> hello.kt chmod +x hello.kt ``` Now you can run it using kscript for example: ```bash kscript hello.kt ``` ### Compile ```bash wasm2kt.kts -lang kotlin -class Example a.out.wast > Example.kt JAVA_OPTS="-Xmx2g -Xms128M" kotlinc Example.kt ``` ### What's working * WAST parsing * WASM parsing * generating code from WAST generated by `emcc -O0 -g4` * buggy generating code from WAST generated by `emcc -O3 -g4` * buggy generated code from wasm ### TO DO * remaining fixes * implementing remaining syscalls * kotlin-common generator * migrate code to kotlin-common * generate a kotlin.js version of the generator and publish as a service online

近期下载者

相关文件


收藏者