JavaScript-Duktape
view release on metacpan or search on metacpan
lib/JavaScript/Duktape/C/lib/duktape.c view on Meta::CPAN
* top, and will be replaced by another error value based on the return
* value of the error handler.
*
* The helper calls duk_handle_call() recursively in protected mode.
* Before that call happens, no longjmps should happen; as a consequence,
* we must assume that the valstack contains enough temporary space for
* arguments and such.
*
* While the error handler runs, any errors thrown will not trigger a
* recursive error handler call (this is implemented using a heap level
* flag which will "follow" through any coroutines resumed inside the
* error handler). If the error handler is not callable or throws an
* error, the resulting error replaces the original error (for Duktape
* internal errors, duk_error_throw.c further substitutes this error with
* a DoubleError which is not ideal). This would be easy to change and
* even signal to the caller.
*
* The user error handler is stored in 'Duktape.errCreate' or
* 'Duktape.errThrow' depending on whether we're augmenting the error at
* creation or throw time. There are several alternatives to this approach,
* see doc/error-objects.rst for discussion.
lib/JavaScript/Duktape/C/lib/duktape.c view on Meta::CPAN
duk__handle_yield(thr, resumer, resumer->valstack_top - 2);
thr = NULL; /* 'thr' invalidated by call */
#if 0
thr = resumer; /* not needed */
#endif
DUK_DD(DUK_DDPRINT("-> return not caught, thread terminated; handle like yield, restart execution in resumer"));
return DUK__RETHAND_RESTART;
#else
/* Without coroutine support this case should never happen. */
DUK_ERROR_INTERNAL(thr);
DUK_WO_NORETURN(return 0;);
#endif
}
/*
* Executor interrupt handling
*
* The handler is called whenever the interrupt countdown reaches zero
* (or below). The handler must perform whatever checks are activated,
lib/JavaScript/Duktape/C/lib/duktape.c view on Meta::CPAN
/*
* ECMAScript bytecode executor.
*
* Resume execution for the current thread from its current activation.
* Returns when execution would return from the entry level activation,
* leaving a single return value on top of the stack. Function calls
* and thread resumptions are handled internally. If an error occurs,
* a longjmp() with type DUK_LJ_TYPE_THROW is called on the entry level
* setjmp() jmpbuf.
*
* ECMAScript function calls and coroutine resumptions are handled
* internally (by the outer executor function) without recursive C calls.
* Other function calls are handled using duk_handle_call(), increasing
* C recursion depth.
*
* Abrupt completions (= long control tranfers) are handled either
* directly by reconfiguring relevant stacks and restarting execution,
* or via a longjmp. Longjmp-free handling is preferable for performance
* (especially Emscripten performance), and is used for: break, continue,
* and return.
*
lib/JavaScript/Duktape/C/lib/duktape.h view on Meta::CPAN
DUK_EXTERNAL_DECL duk_int_t duk_pcall_prop(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t nargs);
DUK_EXTERNAL_DECL void duk_new(duk_context *ctx, duk_idx_t nargs);
DUK_EXTERNAL_DECL duk_int_t duk_pnew(duk_context *ctx, duk_idx_t nargs);
DUK_EXTERNAL_DECL duk_int_t duk_safe_call(duk_context *ctx, duk_safe_call_function func, void *udata, duk_idx_t nargs, duk_idx_t nrets);
/*
* Thread management
*/
/* There are currently no native functions to yield/resume, due to the internal
* limitations on coroutine handling. These will be added later.
*/
/*
* Compilation and evaluation
*/
DUK_EXTERNAL_DECL duk_int_t duk_eval_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags);
DUK_EXTERNAL_DECL duk_int_t duk_compile_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags);
/* plain */
( run in 0.546 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )