尝试折腾了下 WebAssembly 的 AST
发布于 8 年前 作者 jiyinyiyong 6381 次浏览 来自 分享

在 V2EX 发了长长的帖子, 似乎没人理, 大家到 WebAssembly 兴趣好像不怎么样 http://v2ex.com/t/228991 我大概就是发现有 Node.js 核心团队成员在搞 wasm-ast 的项目, 定义了 AST 于是把我的 Cirru 代码编译过去了… 虽然技术含量挺低的, 但是探探路还是可以的 然后现在可以全局安装 cirru-wasm-cli 这个模块, 运行下面这样的代码:

\ (void main) ()
  i32.store (addr.from_64 (i64.const 0)) (i32.const 0x6c6c6568)
  i32.store (addr.from_64 (i64.const 4)) (i32.const 0x6177206f)
  i32.store (addr.from_64 (i64.const 8)) (i32.const 0x000a6d73)

  std::print
    addr.from_64 (i64.const 0)
    addr.from_64 (i64.const 11)

export main

当然底层实际上用那个大神的 wasm-jit 跑的, C++ 实现的 JIT, 跟我没啥关系 感兴趣的同学可以戳戳 V2EX 那个链接

1 回复
回到顶部