1 个不稳定版本

0.1.0 2021年11月13日

#1235WebAssembly

MIT 许可证

48KB
1K SLoC

chasm-rs

这个crate是针对chasm语言的单一遍历编译器到WebAssembly。

chasm是由Colin Eberhardt创建的非常简单的语言,链接,用于介绍编译器的基本构建块,并揭示一些WebAssembly的内部工作原理。这是在Rust中的编译器实现。

用法

在Cargo.toml中指定依赖项

[dependencies]
chasm-rs = "0.1.0"

然后简单地调用 chasm_rs::compile 来编译源代码到一个WebAssembly模块

let source = "
    var y = 0
    while (y < 100)
        var x = 0
        while (x < 100)
            c = ((y/100)*255)
            setpixel (x, y, c)
            x = (x + 1)
        endwhile
        y = (y + 1)
    endwhile";

let wasm = chasm_rs::compile(source);

assert!(wasm.is_ok());

关于

许可证

版权 © 2021, Rodrigodd. 在 MIT 许可证 下发布。

依赖项

~2MB
~18K SLoC