All Projects → soywiz-archive → wasm2kt

soywiz-archive / wasm2kt

Licence: MIT License
Web Assembly to Kotlin and Java converter. Allows to compile a C or C++ program/library, and generate a Kotlin or Java program/library.

Programming Languages

WebAssembly
147 projects
kotlin
9241 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to wasm2kt

Wasm2kt
Web Assembly to Kotlin and Java converter. Allows to compile a C or C++ program/library, and generate a Kotlin or Java program/library.
Stars: ✭ 18 (-10%)
Mutual labels:  converter, jvm, wasm
jvm
Pure Rust implementation of the JVM 7 specification
Stars: ✭ 27 (+35%)
Mutual labels:  jvm, wasm
Asmble
Compile WebAssembly to JVM and other WASM tools
Stars: ✭ 466 (+2230%)
Mutual labels:  jvm, wasm
Modfy.video
A video transcoder and converter built using Web Assembly and FFMPEG to transcode and convert videos right in your browser while protecting your privacy
Stars: ✭ 283 (+1315%)
Mutual labels:  converter, wasm
Tfjs
A WebGL accelerated JavaScript library for training and deploying ML models.
Stars: ✭ 15,834 (+79070%)
Mutual labels:  wasm, web-assembly
pigmnts
🎨 Color palette generator from an image using WebAssesmbly and Rust
Stars: ✭ 38 (+90%)
Mutual labels:  wasm, web-assembly
Classpy
GUI tool for investigating Java class files
Stars: ✭ 854 (+4170%)
Mutual labels:  jvm, wasm
wasm.cljc
Spec compliant WebAssembly compiler, decompiler, and generator
Stars: ✭ 178 (+790%)
Mutual labels:  jvm, wasm
wasm-adventure
My adventure into the marvelous world of Web Assembly
Stars: ✭ 49 (+145%)
Mutual labels:  wasm, web-assembly
BatchEncoder
BatchEncoder is an audio files conversion software.
Stars: ✭ 145 (+625%)
Mutual labels:  converter, transcoding
webp-wasm
Webp image convertor (webassembly, works offline in browser)
Stars: ✭ 18 (-10%)
Mutual labels:  converter, wasm
Wasmite
Now WebAssembly has proper testing, unit-testing and debugging 🤗
Stars: ✭ 20 (+0%)
Mutual labels:  wasm, wasm-bytecode
iokk
International Obfuscated Kotlin Contest
Stars: ✭ 56 (+180%)
Mutual labels:  jvm
jnigi
Golang Java JNI library
Stars: ✭ 92 (+360%)
Mutual labels:  jvm
Algorithm-Math
算法 & 数学知识 & 重拾基础知识系列文章编写和收集
Stars: ✭ 19 (-5%)
Mutual labels:  jvm
obsidian-link-converter
Obsidian Plugin to scan all your links in your vault and convert them to your desired format.
Stars: ✭ 44 (+120%)
Mutual labels:  converter
Java-Rule-Book
Basic concepts of Java to answer any question about how Java works
Stars: ✭ 36 (+80%)
Mutual labels:  jvm
gearoenix
Cross-platform C++ 3D game engine.
Stars: ✭ 33 (+65%)
Mutual labels:  wasm
probes-api
Software Activity Metering - Probes Open API
Stars: ✭ 31 (+55%)
Mutual labels:  jvm
delta
DDD-centric event-sourcing library for the JVM
Stars: ✭ 15 (-25%)
Mutual labels:  jvm

Build Status

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:

echo -e "#include <stdio.h>\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:

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<String>) = Module.main(args)" >> hello.kt
chmod +x hello.kt

Now you can run it using kscript for example:

kscript hello.kt

Compile

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].