godzilla icon indicating copy to clipboard operation
godzilla copied to clipboard

compiling Automerge JS to golang

Open ghost opened this issue 6 years ago • 2 comments

Would you have time to have a quick look at this code and tell me if you see it as clean enough to port ?

Its a CRDT package written in JS.

https://github.com/automerge/automerge/tree/master/src

ghost avatar Apr 11 '18 12:04 ghost

@jingweno I got the basic setup going.

My aim with all this is to convert some JS code to golang with no dependencies in the final golang code.

I might not fully understand but why is outputted golang code dependent on "github.com/jingweno/godzilla/runtime".
Its not really a transpiler, but a runtime reflection / AST based interpreter ?

Please let me know

echo "console.log('Hello, Godzilla')" | $(GODZILLA_BINPATH)/godzilla build --debug --output 


package main

import (
        . "github.com/jingweno/godzilla/runtime"
)

func main() {
        global := NewDefaultContext().Global
        _ = global

        // line 1: console.log("Hello, Godzilla")
        Console_Log([]Object{JSString("Hello, Godzilla")})
}

ghost avatar Apr 11 '18 16:04 ghost

As you see this is Golang source code with no interpretation. Just calling Console_Log and wrapping the JS types to corresponding types from Godzilla. I'm not looked the code of this library, just look to the example which you mentioned.

misha-plus avatar Mar 11 '20 09:03 misha-plus