minijs is a JavaScript bytecode virtual machine implemented in Go. It converts JavaScript code into bytecode for execution and, with high compatibility with Go, can be seamlessly embedded into various Go-based applications.
- Bytecode Execution: Optimizes performance by converting JavaScript code into bytecode and executing it in a virtual machine.
- High Compatibility with Go: Developed in Go, making it easy to integrate into Go-based applications.
minijs runs in a Go environment. You can clone the repository and build it using the following commands:
git clone https://github.com/siyul-park/minijs.git
cd minijs
make build
You can execute JavaScript code interactively in the REPL (Read-Eval-Print Loop).
minijs
> 'b'+'a'+ +'a'+'a'
"baNaNa"
To print the corresponding bytecode, use the -print-bytecode
flag.
minijs --print-bytecode
> 'b'+'a'+ +'a'+'a'
section .text:
global _main
_main:
cload 0x00000000 0x00000001
cload 0x00000002 0x00000001
cadd
cload 0x00000002 0x00000001
ctof64
f64toc
cadd
cload 0x00000002 0x00000001
cadd
.section .data:
b
a
"baNaNa"
When executing a file, minijs applies optimization processes to make the bytecode more efficient. To run a JavaScript file, use the following command:
minijs bababa.js
To print the bytecode while executing a file, use the -print-bytecode
flag.
minijs -print-bytecode bababa.js
section .text:
global _main
_main:
cload 0x00000000 0x00000006
pop
.section .data:
baNaNa