Open Jayatubi opened 7 years ago
After review the code I found the b_exec
has already handled pre-compiled AST internally. However, since b_exec
is not public I have to expose it manually somehow.
hi! currently v7_exec_file will recognize the header of the precompiled file (filename extension is not significant):
$ ./v7 -c test.js >test.jsc
$ ./v7 test.jsc
Do you need to exec a precompiled script from memory?
Yes. What I want to is to execute the bytecode from memory. I have wrapped another interface v7_exec_bytes
to accept another src_len
argument, instead of the strlen
.
It would be perfect If the the interface could be official supported.
enum v7_err v7_exec_bytes(struct v7 *v7, const char *js_code, size_t src_len, v7_val_t *res) {
return b_exec(v7, js_code, src_len, NULL, V7_UNDEFINED, V7_UNDEFINED,
V7_UNDEFINED, 0, 0, 0, res);
}
yes, it makes sense; there are other reasons where the user doesn't have a null terminated string. The rest of the API always accepts string+len
Can I pre-compile the javascript code via
v7_compile
and then directly load the byte code and execute? I haven't found any interface that could deal with the generate byte code.