Cljs2goClojureScript 的 Go 編譯器
Cljs2go 是 ClojureScript 轉(zhuǎn)換為 Go 的編譯器。
ClojureScript 轉(zhuǎn)換到 Go,不是分支出來,而是直接覆蓋到 ClojureScript 上。Go 是從 cljs.go.compiler 上發(fā)行出去,而 cljs.go.compiler 是 cljs.compiler 的一個補丁版本。在運行時,會提供簡單的 JS 兼容以避免接觸 cljs.core,這些 js 和 goog 包不打算對用戶開放使用。
一旦編譯器開始工作,該計劃將提供第二個猴子補?。╩onkey patch),這回是提供 Java 依賴,像 java.io.File 和其他 Clojure 副本,clojure.java.io。此補丁可以將編譯器本身編譯成 Go。這既不會改變運行時編譯程序的特點,也不會引入 eval,它只是充分利用了 Go 來建造管道。
示例代碼:
# Clone and build the Go packages: $ go get github.com/hraberg/cljs2go # The repo itself lives under src by convention: $ cd $GOPATH/src/github.com/hraberg/cljs2go # go test, for Go tests checked into git, both generated and handwritten ones: $ go test -v ./... # To re-generate the tests from ClojureScript (this might dirty the repo): $ lein test # (This also generates and runs some tests under target/generated which aren't checked in.) # To re-generate the Go for ClojureScript itself: $ go generate
評論
圖片
表情
