mattn / anko

Scriptable interpreter written in golang
http://play-anko.appspot.com/
MIT License
1.47k stars 118 forks source link

Bytecode #230

Closed Lobarr closed 6 years ago

Lobarr commented 6 years ago

Does anko compile to bytecode and would it be possible to execute bytecode in the vm?

MichaelS11 commented 6 years ago

Seems beyond the scope of Anko

Lobarr commented 6 years ago

Okay, Thanks

alaingilbert commented 5 years ago

@Lobarr I made an encoder/decoder for anko. So basically, you can compile your source into a binary format and execute it:

anko -o myapp myapp.ank   # compile 'myapp.ank' into binary file 'myapp'
anko myapp                # execute the compiled binary 'myapp'

or if you use it as a library, I added the following methods:

func (e *Env) Compile(src string) ([]byte, error) {}
func (e *Env) ExecuteCompiled(src []byte) (interface{}, error) {}

Concept: source -> ast -> encoded AST in binary file Then encoded -> ast -> execute

My goal was to have "closed-source" sharable scripts that are executable at runtime. Ping me, if you want to know more.


PS: I'm also working on having compile-time errors instead of runtime errors.