10#if defined(DUK_CMDLINE_FANCY)
11#define DUK_CMDLINE_LINENOISE
12#define DUK_CMDLINE_LINENOISE_COMPLETION
13#define DUK_CMDLINE_RLIMIT
14#define DUK_CMDLINE_SIGNAL
17#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || \
18 defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
20#define _CRT_SECURE_NO_WARNINGS
21#if defined(_MSC_VER) && (_MSC_VER < 1900)
27#define snprintf _snprintf
31#define GREET_CODE(variant) \
32 "print('((o) Duktape" variant " ' + " \
33 "Math.floor(Duktape.version / 10000) + '.' + " \
34 "Math.floor(Duktape.version / 100) % 100 + '.' + " \
35 "Duktape.version % 100" \
36 ", '(" DUK_GIT_DESCRIBE ")');"
41#if defined(DUK_CMDLINE_SIGNAL)
44#if defined(DUK_CMDLINE_RLIMIT)
45#include <sys/resource.h>
47#if defined(DUK_CMDLINE_LINENOISE)
50#if defined(DUK_CMDLINE_FILEIO)
53#if defined(EMSCRIPTEN)
54#include <emscripten.h>
56#if defined(DUK_CMDLINE_ALLOC_LOGGING)
57#include "duk_alloc_logging.h"
59#if defined(DUK_CMDLINE_ALLOC_TORTURE)
60#include "duk_alloc_torture.h"
62#if defined(DUK_CMDLINE_ALLOC_HYBRID)
63#include "duk_alloc_hybrid.h"
67#if defined(DUK_CMDLINE_AJSHEAP)
69void ajsheap_init(
void);
70void ajsheap_free(
void);
71void ajsheap_dump(
void);
73void ajsheap_start_exec_timeout(
void);
74void ajsheap_clear_exec_timeout(
void);
75void *ajsheap_alloc_wrapped(
void *udata,
duk_size_t size);
76void *ajsheap_realloc_wrapped(
void *udata,
void *ptr,
duk_size_t size);
77void ajsheap_free_wrapped(
void *udata,
void *ptr);
79void *AJS_Realloc(
void *udata,
void *ptr,
duk_size_t size);
80void AJS_Free(
void *udata,
void *ptr);
83#if defined(DUK_CMDLINE_DEBUGGER_SUPPORT)
84#include "duk_trans_socket.h"
87#define MEM_LIMIT_NORMAL (128*1024*1024)
88#define MEM_LIMIT_HIGH (2047*1024*1024)
89#define LINEBUF_SIZE 65536
94#if defined(DUK_CMDLINE_DEBUGGER_SUPPORT)
95static int debugger_reattach = 0;
102#if defined(DUK_CMDLINE_RLIMIT)
103static void set_resource_limits(rlim_t mem_limit_value) {
107 rc = getrlimit(RLIMIT_AS, &lim);
109 fprintf(stderr,
"Warning: cannot read RLIMIT_AS\n");
113 if (lim.rlim_max < mem_limit_value) {
114 fprintf(stderr,
"Warning: rlim_max < mem_limit_value (%d < %d)\n", (
int) lim.rlim_max, (
int) mem_limit_value);
118 lim.rlim_cur = mem_limit_value;
119 lim.rlim_max = mem_limit_value;
121 rc = setrlimit(RLIMIT_AS, &lim);
123 fprintf(stderr,
"Warning: setrlimit failed\n");
128 fprintf(stderr,
"Set RLIMIT_AS to %d\n", (
int) mem_limit_value);
133#if defined(DUK_CMDLINE_SIGNAL)
135 fprintf(stderr,
"Got signal %d\n", x);
140 (void) signal(SIGPIPE, SIG_IGN);
174 const char *src_data;
193 if (src_data !=
NULL && src_len >= 2 && src_data[0] == (
char) 0xff) {
213 const char *filename;
219#if defined(EMSCRIPTEN)
220 if (filename[0] ==
'/') {
221 snprintf(fnbuf,
sizeof(fnbuf),
"%s", filename);
223 snprintf(fnbuf,
sizeof(fnbuf),
"/working/%s", filename);
226 snprintf(fnbuf,
sizeof(fnbuf),
"%s", filename);
228 fnbuf[
sizeof(fnbuf) - 1] = (
char) 0;
230 f = fopen(fnbuf,
"wb");
234 wrote =
fwrite(bc_ptr, 1, (
size_t) bc_len, f);
236 if (wrote != bc_len) {
252#if defined(DUK_CMDLINE_AJSHEAP)
253 ajsheap_start_exec_timeout();
259#if defined(DUK_CMDLINE_AJSHEAP)
260 ajsheap_clear_exec_timeout();
300#if defined(DUK_CMDLINE_LINENOISE_COMPLETION)
303static int completion_idpart(
unsigned char c) {
305 if ((c >= (
unsigned char)
'a' && c <= (
unsigned char)
'z') ||
306 (c >= (
unsigned char)
'A' && c <= (
unsigned char)
'Z') ||
307 (c >= (
unsigned char)
'0' && c <= (
unsigned char)
'9') ||
308 c == (
unsigned char)
'$' || c == (
unsigned char)
'_') {
314static int completion_digit(
unsigned char c) {
315 return (c >= (
unsigned char)
'0' && c <= (
unsigned char)
'9');
321 const unsigned char *p;
322 const unsigned char *p_curr;
323 const unsigned char *p_end;
326 linenoiseCompletions *lc;
331 p_end = p_curr + len;
337 while (p_curr <= p_end) {
340 while (p < p_end && p[0] != (
unsigned char)
'.') {
347 fprintf(stderr,
"Completion check: '%s'\n", prefix);
361 fprintf(stderr,
"Key: %s\n", key ? key :
"");
372 if (completion_digit(key[0])) {
380 if (strlen(prefix) == 0) {
387 }
else if (prefix && strcmp(key, prefix) == 0) {
394 }
else if (prefix && strncmp(key, prefix, strlen(prefix)) == 0) {
422static void linenoise_completion(
const char *buf, linenoiseCompletions *lc) {
424 const unsigned char *p_start;
425 const unsigned char *p_end;
426 const unsigned char *p;
432 ctx = completion_ctx;
437 p_start = (
const unsigned char *) buf;
438 p_end = (
const unsigned char *) (buf + strlen(buf));
445 while (--p >= p_start) {
446 if (p[0] == (
unsigned char)
'.') {
450 if (!completion_idpart(p[-1])) {
454 }
else if (!completion_idpart(p[0])) {
462 if (p < p_start || p >= p_end) {
473 fprintf(stderr,
"Completion starting point: '%s'\n", p);
481 rc =
duk_safe_call(ctx, linenoise_completion_lookup, 3 , 1 );
501 buf = (
char *)
malloc(1024);
512 avail = bufsz - bufoff;
517 fprintf(stderr,
"resizing read buffer: %ld -> %ld\n", (
long) bufsz, (
long) (bufsz * 2));
519 newsz = bufsz + (bufsz >> 2) + 1024;
520 buf_new = (
char *)
realloc(buf, newsz);
528 avail = bufsz - bufoff;
530 fprintf(stderr,
"reading input: buf=%p bufsz=%ld bufoff=%ld avail=%ld\n",
531 (
void *) buf, (
long) bufsz, (
long) bufoff, (
long) avail);
534 got =
fread((
void *) (buf + bufoff), (
size_t) 1, avail, f);
536 fprintf(stderr,
"got=%ld\n", (
long) got);
551#if defined(EMSCRIPTEN)
552 if (bufoff >= 16384) {
556 for (i = 16; i < bufoff / 8; i++) {
561 for (j = 1; j < nloops; j++) {
562 if (memcmp((
void *) buf, (
void *) (buf + i * j), i) != 0) {
568 fprintf(stderr,
"emscripten workaround: detect looping at index %ld, verified with %ld loops\n", (
long) i, (
long) (nloops - 1));
591#if defined(DUK_CMDLINE_AJSHEAP)
592 ajsheap_clear_exec_timeout();
615 fprintf(stderr,
"error in executing file %s\n", filename);
630#if defined(EMSCRIPTEN)
631 if (filename[0] ==
'/') {
632 snprintf(fnbuf,
sizeof(fnbuf),
"%s", filename);
634 snprintf(fnbuf,
sizeof(fnbuf),
"/working/%s", filename);
637 snprintf(fnbuf,
sizeof(fnbuf),
"%s", filename);
639 fnbuf[
sizeof(fnbuf) - 1] = (
char) 0;
641 f = fopen(fnbuf,
"rb");
643 fprintf(stderr,
"failed to open source file: %s\n", filename);
648 retval =
handle_fh(ctx, f, filename, bytecode_filename);
669#if defined(DUK_CMDLINE_AJSHEAP)
670 ajsheap_clear_exec_timeout();
683#if defined(DUK_CMDLINE_LINENOISE)
685 const char *prompt =
"duk> ";
693 linenoiseSetMultiLine(1);
694 linenoiseHistorySetMaxLen(64);
695#if defined(DUK_CMDLINE_LINENOISE_COMPLETION)
696 linenoiseSetCompletionCallback(linenoise_completion);
701 linenoiseFree(buffer);
705#if defined(DUK_CMDLINE_LINENOISE_COMPLETION)
706 completion_ctx = ctx;
708 buffer = linenoise(prompt);
709#if defined(DUK_CMDLINE_LINENOISE_COMPLETION)
710 completion_ctx =
NULL;
717 if (buffer && buffer[0] != (
char) 0) {
718 linenoiseHistoryAdd(buffer);
729#if defined(DUK_CMDLINE_AJSHEAP)
730 ajsheap_clear_exec_timeout();
734 linenoiseFree(buffer);
748 linenoiseFree(buffer);
756 const char *prompt =
"duk> ";
767 fprintf(stderr,
"failed to allocated a line buffer\n");
776 fwrite(prompt, 1, strlen(prompt), stdout);
780 int c = fgetc(stdin);
784 }
else if (c ==
'\n') {
787 fprintf(stderr,
"line too long\n");
792 buffer[idx++] = (char) c;
804#if defined(DUK_CMDLINE_AJSHEAP)
805 ajsheap_clear_exec_timeout();
831#if defined(DUK_CMDLINE_FILEIO)
844 fn, (
long) errno, strerror(errno));
847 rc = fseek(f, 0, SEEK_END);
851 fn, (
long) errno, strerror(errno));
853 len = (size_t) ftell(f);
854 rc = fseek(f, 0, SEEK_SET);
858 fn, (
long) errno, strerror(errno));
862 for (off = 0; off < len;) {
864 got =
fread((
void *) (buf + off), 1, len - off, f);
898 fn, (
long) errno, strerror(errno));
903 for (off = 0; off < len;) {
905 got =
fwrite((
const void *) (buf + off), 1, len - off, f);
929#if defined(DUK_CMDLINE_DEBUGGER_SUPPORT)
943 if (cmd && strcmp(cmd,
"CommandLine") == 0) {
960static void debugger_detached(
void *udata) {
963 fprintf(stderr,
"Debugger detached, udata: %p\n", (
void *) udata);
971 if (debugger_reattach) {
975 fprintf(stderr,
"Debugger reconnected, call duk_debugger_attach()\n");
994#define ALLOC_DEFAULT 0
995#define ALLOC_LOGGING 1
996#define ALLOC_TORTURE 2
997#define ALLOC_HYBRID 3
998#define ALLOC_AJSHEAP 4
1007#if defined(DUK_CMDLINE_ALLOC_LOGGING)
1011 (
void *) 0xdeadbeef,
1014 fprintf(stderr,
"Warning: option --alloc-logging ignored, no logging allocator support\n");
1019#if defined(DUK_CMDLINE_ALLOC_TORTURE)
1023 (
void *) 0xdeadbeef,
1026 fprintf(stderr,
"Warning: option --alloc-torture ignored, no torture allocator support\n");
1031#if defined(DUK_CMDLINE_ALLOC_HYBRID)
1034 fprintf(stderr,
"Failed to init hybrid allocator\n");
1044 fprintf(stderr,
"Warning: option --alloc-hybrid ignored, no hybrid allocator support\n");
1049#if defined(DUK_CMDLINE_AJSHEAP)
1053 ajsheap_log ? ajsheap_alloc_wrapped : AJS_Alloc,
1054 ajsheap_log ? ajsheap_realloc_wrapped : AJS_Realloc,
1055 ajsheap_log ? ajsheap_free_wrapped : AJS_Free,
1056 (
void *) 0xdeadbeef,
1060 fprintf(stderr,
"Warning: option --alloc-ajsheap ignored, no ajsheap allocator support\n");
1069 fprintf(stderr,
"Failed to create Duktape heap\n");
1074#if defined(DUK_CMDLINE_AJSHEAP)
1076 fprintf(stdout,
"Pool dump after heap creation\n");
1081#if defined(DUK_CMDLINE_AJSHEAP)
1083 ajsheap_register(ctx);
1087#if defined(DUK_CMDLINE_FILEIO)
1095#if defined(DUK_CMDLINE_DEBUGGER_SUPPORT)
1096 fprintf(stderr,
"Debugger enabled, create socket and wait for connection\n");
1100 fprintf(stderr,
"Debugger connected, call duk_debugger_attach() and then execute requested file(s)/eval\n");
1112 fprintf(stderr,
"Warning: option --debugger ignored, no debugger support\n");
1120 for (i = 0; i < 60; i++) {
1121 printf(
"cooperate: %d\n", i);
1132 (void) alloc_provider;
1134#if defined(DUK_CMDLINE_AJSHEAP)
1136 fprintf(stdout,
"Pool dump before duk_destroy_heap(), before forced gc\n");
1141 fprintf(stdout,
"Pool dump before duk_destroy_heap(), after forced gc\n");
1150#if defined(DUK_CMDLINE_AJSHEAP)
1152 fprintf(stdout,
"Pool dump after duk_destroy_heap() (should have zero allocs)\n");
1168 int interactive = 0;
1169 int memlimit_high = 1;
1171 int ajsheap_log = 0;
1173 int recreate_heap = 0;
1174 int no_heap_destroy = 0;
1177 const char *compile_filename =
NULL;
1183#if defined(EMSCRIPTEN)
1207 FS.mkdir(
"/working");
1208 FS.mount(NODEFS, { root:
"." },
"/working");
1210 console.log(
"Failed to mount NODEFS /working: " + e);
1223 FS.mount(NODEFS, { root:
"/tmp" },
"/tmp");
1225 console.log(
"Failed to mount NODEFS /tmp: " + e);
1230#if defined(DUK_CMDLINE_AJSHEAP)
1239#if defined(DUK_CMDLINE_SIGNAL)
1250 for (i = 1; i < argc; i++) {
1251 char *
arg = argv[i];
1255 if (strcmp(
arg,
"--restrict-memory") == 0) {
1257 }
else if (strcmp(
arg,
"-i") == 0) {
1259 }
else if (strcmp(
arg,
"-c") == 0) {
1260 if (i == argc - 1) {
1264 compile_filename = argv[i];
1265 }
else if (strcmp(
arg,
"-e") == 0) {
1267 if (i == argc - 1) {
1271 }
else if (strcmp(
arg,
"--alloc-default") == 0) {
1273 }
else if (strcmp(
arg,
"--alloc-logging") == 0) {
1275 }
else if (strcmp(
arg,
"--alloc-torture") == 0) {
1277 }
else if (strcmp(
arg,
"--alloc-hybrid") == 0) {
1279 }
else if (strcmp(
arg,
"--alloc-ajsheap") == 0) {
1281 }
else if (strcmp(
arg,
"--ajsheap-log") == 0) {
1283 }
else if (strcmp(
arg,
"--debugger") == 0) {
1285#if defined(DUK_CMDLINE_DEBUGGER_SUPPORT)
1286 }
else if (strcmp(
arg,
"--reattach") == 0) {
1287 debugger_reattach = 1;
1289 }
else if (strcmp(
arg,
"--recreate-heap") == 0) {
1291 }
else if (strcmp(
arg,
"--no-heap-destroy") == 0) {
1292 no_heap_destroy = 1;
1293 }
else if (strcmp(
arg,
"--verbose") == 0) {
1295 }
else if (strcmp(
arg,
"--run-stdin") == 0) {
1297 }
else if (strlen(
arg) >= 1 &&
arg[0] ==
'-') {
1303 if (!have_files && !have_eval && !run_stdin) {
1311#if defined(DUK_CMDLINE_RLIMIT)
1314 if (memlimit_high == 0) {
1315 fprintf(stderr,
"Warning: option --restrict-memory ignored, no rlimit support\n");
1330 for (i = 1; i < argc; i++) {
1331 char *
arg = argv[i];
1334 }
else if (strlen(
arg) == 2 && strcmp(
arg,
"-e") == 0) {
1336 if (i == argc - 1) {
1346 }
else if (strlen(
arg) == 2 && strcmp(
arg,
"-c") == 0) {
1349 }
else if (strlen(
arg) >= 1 &&
arg[0] ==
'-') {
1354 fprintf(stderr,
"*** Executing file: %s\n",
arg);
1363 if (recreate_heap) {
1365 fprintf(stderr,
"*** Recreating heap...\n");
1379 if (
handle_fh(ctx, stdin,
"stdin", compile_filename) != 0) {
1384 if (recreate_heap) {
1386 fprintf(stderr,
"*** Recreating heap...\n");
1412 fprintf(stderr,
"Cleaning up...\n");
1416 if (ctx && no_heap_destroy) {
1419 if (ctx && !no_heap_destroy) {
1431 fprintf(stderr,
"Usage: duk [options] [<filenames>]\n"
1433 " -i enter interactive mode after executing argument file(s) / eval code\n"
1434 " -e CODE evaluate code\n"
1435 " -c FILE compile into bytecode (use with only one file argument)\n"
1436 " --run-stdin treat stdin like a file, i.e. compile full input (not line by line)\n"
1437 " --verbose verbose messages to stderr\n"
1438 " --restrict-memory use lower memory limit (used by test runner)\n"
1439 " --alloc-default use Duktape default allocator\n"
1440#
if defined(DUK_CMDLINE_ALLOC_LOGGING)
1441 " --alloc-logging use logging allocator (writes to /tmp)\n"
1443#
if defined(DUK_CMDLINE_ALLOC_TORTURE)
1444 " --alloc-torture use torture allocator\n"
1446#
if defined(DUK_CMDLINE_ALLOC_HYBRID)
1447 " --alloc-hybrid use hybrid allocator\n"
1449#
if defined(DUK_CMDLINE_AJSHEAP)
1450 " --alloc-ajsheap use ajsheap allocator (enabled by default with 'ajduk')\n"
1451 " --ajsheap-log write alloc log to /tmp/ajduk-alloc-log.txt\n"
1453#
if defined(DUK_CMDLINE_DEBUGGER_SUPPORT)
1454 " --debugger start example debugger\n"
1455 " --reattach automatically reattach debugger on detach\n"
1457 " --recreate-heap recreate heap after every file\n"
1458 " --no-heap-destroy force GC, but don't destroy heap at end (leak testing)\n"
1460 "If <filename> is omitted, interactive mode is started automatically.\n");
CURL_EXTERN int void * arg
void * duk_realloc_hybrid(void *udata, void *ptr, duk_size_t size)
void * duk_alloc_hybrid_init(void)
void * duk_alloc_hybrid(void *udata, duk_size_t size)
void duk_free_hybrid(void *udata, void *ptr)
void * duk_alloc_logging(void *udata, duk_size_t size)
void * duk_realloc_logging(void *udata, void *ptr, duk_size_t size)
void duk_free_logging(void *udata, void *ptr)
void * duk_realloc_torture(void *udata, void *ptr, duk_size_t size)
void duk_free_torture(void *udata, void *ptr)
void * duk_alloc_torture(void *udata, duk_size_t size)
static void print_pop_error(duk_context *ctx, FILE *f)
static int handle_file(duk_context *ctx, const char *filename, const char *bytecode_filename)
static int handle_eval(duk_context *ctx, char *code)
static duk_context * create_duktape_heap(int alloc_provider, int debugger, int ajsheap_log)
static void destroy_duktape_heap(duk_context *ctx, int alloc_provider)
static int handle_interactive(duk_context *ctx)
static int handle_fh(duk_context *ctx, FILE *f, const char *filename, const char *bytecode_filename)
#define GREET_CODE(variant)
static int interactive_mode
static int wrapped_compile_execute(duk_context *ctx)
static int get_stack_raw(duk_context *ctx)
void duk_trans_socket_read_flush_cb(void *udata)
duk_size_t duk_trans_socket_read_cb(void *udata, char *buffer, duk_size_t length)
void duk_trans_socket_finish(void)
duk_size_t duk_trans_socket_write_cb(void *udata, const char *buffer, duk_size_t length)
void duk_trans_socket_write_flush_cb(void *udata)
duk_size_t duk_trans_socket_peek_cb(void *udata)
void duk_trans_socket_waitconn(void)
void duk_trans_socket_init(void)
duk_small_int_t duk_ret_t
duk_int_fast32_t duk_int_t
duk_uint_fast32_t duk_uint_t
DUK_EXTERNAL void duk_enum(duk_context *ctx, duk_idx_t obj_index, duk_uint_t enum_flags)
DUK_EXTERNAL void duk_concat(duk_context *ctx, duk_idx_t count)
DUK_EXTERNAL const char * duk_push_string(duk_context *ctx, const char *str)
DUK_EXTERNAL void duk_debugger_cooperate(duk_context *ctx)
DUK_EXTERNAL duk_bool_t duk_put_global_string(duk_context *ctx, const char *key)
DUK_EXTERNAL duk_bool_t duk_next(duk_context *ctx, duk_idx_t enum_index, duk_bool_t get_value)
DUK_EXTERNAL duk_idx_t duk_require_top_index(duk_context *ctx)
DUK_EXTERNAL void duk_debugger_detach(duk_context *ctx)
DUK_EXTERNAL duk_bool_t duk_has_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key)
DUK_EXTERNAL const char * duk_push_lstring(duk_context *ctx, const char *str, duk_size_t len)
DUK_EXTERNAL void duk_remove(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL duk_idx_t duk_push_c_function(duk_context *ctx, duk_c_function func, duk_int_t nargs)
DUK_EXTERNAL void duk_dup_top(duk_context *ctx)
DUK_EXTERNAL void duk_replace(duk_context *ctx, duk_idx_t to_index)
DUK_EXTERNAL void duk_push_pointer(duk_context *ctx, void *val)
DUK_EXTERNAL void * duk_require_pointer(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL const char * duk_get_string(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL duk_bool_t duk_is_object(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL duk_bool_t duk_debugger_notify(duk_context *ctx, duk_idx_t nvalues)
DUK_EXTERNAL void * duk_require_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size)
DUK_EXTERNAL duk_int_t duk_safe_call(duk_context *ctx, duk_safe_call_function func, duk_idx_t nargs, duk_idx_t nrets)
DUK_EXTERNAL void duk_load_function(duk_context *ctx)
DUK_EXTERNAL void duk_push_uint(duk_context *ctx, duk_uint_t val)
DUK_EXTERNAL void duk_gc(duk_context *ctx, duk_uint_t flags)
DUK_EXTERNAL void duk_call_method(duk_context *ctx, duk_idx_t nargs)
DUK_EXTERNAL duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key)
DUK_EXTERNAL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_index)
DUK_EXTERNAL const char * duk_push_sprintf(duk_context *ctx, const char *fmt,...)
DUK_EXTERNAL void duk_destroy_heap(duk_context *ctx)
DUK_EXTERNAL const char * duk_require_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
DUK_EXTERNAL void duk_push_global_object(duk_context *ctx)
DUK_EXTERNAL void duk_to_object(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL const char * duk_to_string(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL void duk_pop(duk_context *ctx)
DUK_EXTERNAL duk_bool_t duk_check_stack(duk_context *ctx, duk_idx_t extra)
DUK_EXTERNAL void duk_debugger_attach_custom(duk_context *ctx, duk_debug_read_function read_cb, duk_debug_write_function write_cb, duk_debug_peek_function peek_cb, duk_debug_read_flush_function read_flush_cb, duk_debug_write_flush_function write_flush_cb, duk_debug_request_function request_cb, duk_debug_detached_function detached_cb, void *udata)
DUK_EXTERNAL void duk_dump_function(duk_context *ctx)
DUK_EXTERNAL duk_bool_t duk_is_string(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL duk_uint_t duk_require_uint(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL const char * duk_require_string(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL duk_context * duk_create_heap(duk_alloc_function alloc_func, duk_realloc_function realloc_func, duk_free_function free_func, void *heap_udata, duk_fatal_function fatal_handler)
#define DUK_ERR_TYPE_ERROR
#define duk_to_buffer(ctx, index, out_size)
#define duk_push_fixed_buffer(ctx, size)
#define duk_safe_to_string(ctx, index)
#define duk_eval_string(ctx, src)
#define duk_create_heap_default()
#define duk_is_error(ctx, index)
#define duk_compile_lstring_filename(ctx, flags, buf, len)
#define DUK_ENUM_INCLUDE_NONENUMERABLE
static void usage(const char *message)
static void error(LoadState *S, const char *why)
static void set_sigint_handler(void)
static void my_sighandler(int x)