mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-15 05:16:30 +00:00
Fix JavaScript interpreter example
This commit is contained in:
parent
bfa8581537
commit
6f35bd47ab
2 changed files with 6 additions and 3 deletions
|
@ -10,6 +10,7 @@
|
|||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
|
@ -39,6 +40,7 @@ int main(int argc, char *argv[]) {
|
|||
struct stat st;
|
||||
const char *code;
|
||||
duk_context *ctx;
|
||||
showcrashreports();
|
||||
ctx = duk_create_heap_default();
|
||||
duk_push_c_function(ctx, NativePrint, DUK_VARARGS);
|
||||
duk_put_global_string(ctx, "NativePrint");
|
||||
|
@ -47,7 +49,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
CHECK_NE(-1, (fd = open("zip:examples/hello.js", O_RDONLY)));
|
||||
CHECK_NE(-1, fstat(fd, &st));
|
||||
CHECK_NOTNULL((code = gc(malloc(st.st_size))));
|
||||
CHECK_NOTNULL((code = gc(calloc(1, st.st_size + 1))));
|
||||
CHECK_EQ(st.st_size, read(fd, code, st.st_size));
|
||||
CHECK_NE(-1, close(fd));
|
||||
|
||||
|
|
5
third_party/duktape/duk_js_compiler.c
vendored
5
third_party/duktape/duk_js_compiler.c
vendored
|
@ -1278,8 +1278,9 @@ DUK_LOCAL void duk__convert_to_func_template(duk_compiler_ctx *comp_ctx) {
|
|||
(1u << 12) /* slot B is a target (default: source) */
|
||||
#define DUK__EMIT_FLAG_C_IS_TARGET \
|
||||
(1u << 13) /* slot C is a target (default: source) */
|
||||
#define DUK__EMIT_FLAG_BC_REGCONST (1u << 14) /* slots B and C are reg/const \
|
||||
*/
|
||||
#define DUK__EMIT_FLAG_BC_REGCONST \
|
||||
(1u << 14) /* slots B and C are reg/const \
|
||||
*/
|
||||
#define DUK__EMIT_FLAG_RESERVE_JUMPSLOT \
|
||||
(1u << 15) /* reserve a jumpslot after instr before target spilling, used \
|
||||
for NEXTENUM */
|
||||
|
|
Loading…
Add table
Reference in a new issue