Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
duktape.c File Reference
#include "duktape.h"

Go to the source code of this file.

Data Structures

struct  duk_jmpbuf
 
struct  duk_tval_struct
 
struct  duk_bitdecoder_ctx
 
struct  duk_bitencoder_ctx
 
struct  duk_bufwriter_ctx
 
struct  duk_token
 
struct  duk_re_token
 
struct  duk_lexer_point
 
struct  duk_lexer_codepoint
 
struct  duk_lexer_ctx
 
struct  duk_ispec
 
struct  duk_ivalue
 
struct  duk_compiler_instr
 
struct  duk_labelinfo
 
struct  duk_compiler_func
 
struct  duk_compiler_ctx
 
struct  duk_re_matcher_ctx
 
struct  duk_re_compiler_ctx
 
struct  duk_heaphdr
 
struct  duk_heaphdr_string
 
struct  duk_hstring
 
struct  duk_hstring_external
 
struct  duk_propaccessor
 
union  duk_propvalue
 
struct  duk_propdesc
 
struct  duk_hobject
 
struct  duk_hcompiledfunction
 
struct  duk_hnativefunction
 
struct  duk_hbufferobject
 
struct  duk_activation
 
struct  duk_catcher
 
struct  duk_hthread
 
struct  duk_hbuffer
 
struct  duk_hbuffer_fixed
 
struct  duk_hbuffer_dynamic
 
struct  duk_hbuffer_external
 
struct  duk_breakpoint
 
struct  duk_strcache
 
struct  duk_ljstate
 
struct  duk_strtab_entry
 
struct  duk_heap
 
struct  duk_json_enc_ctx
 
struct  duk_json_dec_ctx
 
struct  duk__compile_raw_args
 
struct  duk_internal_thread_state
 
struct  duk__transform_context
 
struct  duk__compiler_stkstate
 
struct  duk__id_lookup_result
 
struct  duk__exp_limits
 
struct  duk__bigint
 
struct  duk__numconv_stringify_ctx
 
struct  duk__re_disjunction_info
 

Macros

#define DUK_INTERNAL_H_INCLUDED
 
#define DUK_COMPILING_DUKTAPE
 
#define DUK_REPLACEMENTS_H_INCLUDED
 
#define DUK_JMPBUF_H_INCLUDED
 
#define DUK_EXCEPTION_H_INCLUDED
 
#define DUK_FORWDECL_H_INCLUDED
 
#define DUK_TVAL_H_INCLUDED
 
#define DUK__TAG_NUMBER   0 /* not exposed */
 
#define DUK_TAG_UNDEFINED   2
 
#define DUK_TAG_NULL   3
 
#define DUK_TAG_BOOLEAN   4
 
#define DUK_TAG_POINTER   5
 
#define DUK_TAG_LIGHTFUNC   6
 
#define DUK_TAG_UNUSED   7 /* marker; not actual tagged type */
 
#define DUK_TAG_STRING   8 /* first heap allocated, match bit boundary */
 
#define DUK_TAG_OBJECT   9
 
#define DUK_TAG_BUFFER   10
 
#define DUK_TVAL_SET_UNDEFINED(tv)
 
#define DUK_TVAL_SET_UNUSED(tv)
 
#define DUK_TVAL_SET_NULL(tv)
 
#define DUK_TVAL_SET_BOOLEAN(tv, val)
 
#define DUK_TVAL_SET_DOUBLE(tv, d)    DUK_TVAL_SET_NUMBER((tv), (d))
 
#define DUK_TVAL_SET_FASTINT(tv, val)    DUK_TVAL_SET_NUMBER((tv), (duk_double_t) (val)) /* XXX: fast int-to-double */
 
#define DUK_TVAL_SET_FASTINT_U32(tv, val)    DUK_TVAL_SET_NUMBER((tv), (duk_double_t) (val))
 
#define DUK_TVAL_SET_FASTINT_I32(tv, val)    DUK_TVAL_SET_NUMBER((tv), (duk_double_t) (val))
 
#define DUK_TVAL_SET_NUMBER(tv, val)
 
#define DUK_TVAL_SET_NUMBER_CHKFAST(tv, d)    DUK_TVAL_SET_NUMBER((tv), (d))
 
#define DUK_TVAL_CHKFAST_INPLACE(v)   do { } while (0)
 
#define DUK_TVAL_SET_POINTER(tv, hptr)
 
#define DUK_TVAL_SET_LIGHTFUNC(tv, fp, flags)
 
#define DUK_TVAL_SET_STRING(tv, hptr)
 
#define DUK_TVAL_SET_OBJECT(tv, hptr)
 
#define DUK_TVAL_SET_BUFFER(tv, hptr)
 
#define DUK_TVAL_SET_NAN(tv)
 
#define DUK_TVAL_SET_TVAL(v, x)   do { *(v) = *(x); } while (0)
 
#define DUK_TVAL_GET_BOOLEAN(tv)   ((tv)->v.i)
 
#define DUK_TVAL_GET_NUMBER(tv)   ((tv)->v.d)
 
#define DUK_TVAL_GET_DOUBLE(tv)   ((tv)->v.d)
 
#define DUK_TVAL_GET_POINTER(tv)   ((tv)->v.voidptr)
 
#define DUK_TVAL_GET_LIGHTFUNC(tv, out_fp, out_flags)
 
#define DUK_TVAL_GET_LIGHTFUNC_FUNCPTR(tv)   ((tv)->v.lightfunc)
 
#define DUK_TVAL_GET_LIGHTFUNC_FLAGS(tv)   ((duk_uint32_t) ((tv)->v_extra))
 
#define DUK_TVAL_GET_STRING(tv)   ((tv)->v.hstring)
 
#define DUK_TVAL_GET_OBJECT(tv)   ((tv)->v.hobject)
 
#define DUK_TVAL_GET_BUFFER(tv)   ((tv)->v.hbuffer)
 
#define DUK_TVAL_GET_HEAPHDR(tv)   ((tv)->v.heaphdr)
 
#define DUK_TVAL_GET_TAG(tv)   ((tv)->t)
 
#define DUK_TVAL_IS_UNDEFINED(tv)   ((tv)->t == DUK_TAG_UNDEFINED)
 
#define DUK_TVAL_IS_UNUSED(tv)   ((tv)->t == DUK_TAG_UNUSED)
 
#define DUK_TVAL_IS_NULL(tv)   ((tv)->t == DUK_TAG_NULL)
 
#define DUK_TVAL_IS_BOOLEAN(tv)   ((tv)->t == DUK_TAG_BOOLEAN)
 
#define DUK_TVAL_IS_BOOLEAN_TRUE(tv)   (((tv)->t == DUK_TAG_BOOLEAN) && ((tv)->v.i != 0))
 
#define DUK_TVAL_IS_BOOLEAN_FALSE(tv)   (((tv)->t == DUK_TAG_BOOLEAN) && ((tv)->v.i == 0))
 
#define DUK_TVAL_IS_NUMBER(tv)   ((tv)->t == DUK__TAG_NUMBER)
 
#define DUK_TVAL_IS_DOUBLE(v)   DUK_TVAL_IS_NUMBER((v))
 
#define DUK_TVAL_IS_POINTER(tv)   ((tv)->t == DUK_TAG_POINTER)
 
#define DUK_TVAL_IS_LIGHTFUNC(tv)   ((tv)->t == DUK_TAG_LIGHTFUNC)
 
#define DUK_TVAL_IS_STRING(tv)   ((tv)->t == DUK_TAG_STRING)
 
#define DUK_TVAL_IS_OBJECT(tv)   ((tv)->t == DUK_TAG_OBJECT)
 
#define DUK_TVAL_IS_BUFFER(tv)   ((tv)->t == DUK_TAG_BUFFER)
 
#define DUK_TVAL_IS_HEAP_ALLOCATED(tv)   ((tv)->t & 0x08)
 
#define DUK_TVAL_SET_BOOLEAN_TRUE(v)   DUK_TVAL_SET_BOOLEAN(v, 1)
 
#define DUK_TVAL_SET_BOOLEAN_FALSE(v)   DUK_TVAL_SET_BOOLEAN(v, 0)
 
#define DUK_LFUNC_FLAGS_GET_MAGIC(lf_flags)    ((((duk_int32_t) (lf_flags)) << 16) >> 24)
 
#define DUK_LFUNC_FLAGS_GET_LENGTH(lf_flags)    (((lf_flags) >> 4) & 0x0f)
 
#define DUK_LFUNC_FLAGS_GET_NARGS(lf_flags)    ((lf_flags) & 0x0f)
 
#define DUK_LFUNC_FLAGS_PACK(magic, length, nargs)    (((magic) & 0xff) << 8) | ((length) << 4) | (nargs)
 
#define DUK_LFUNC_NARGS_VARARGS   0x0f /* varargs marker */
 
#define DUK_LFUNC_NARGS_MIN   0x00
 
#define DUK_LFUNC_NARGS_MAX   0x0e /* max, excl. varargs marker */
 
#define DUK_LFUNC_LENGTH_MIN   0x00
 
#define DUK_LFUNC_LENGTH_MAX   0x0f
 
#define DUK_LFUNC_MAGIC_MIN   (-0x80)
 
#define DUK_LFUNC_MAGIC_MAX   0x7f
 
#define DUK_BUILTINS_H_INCLUDED
 
#define DUK_STRIDX_UC_UNDEFINED   0 /* 'Undefined' */
 
#define DUK_HEAP_STRING_UC_UNDEFINED(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_UNDEFINED)
 
#define DUK_HTHREAD_STRING_UC_UNDEFINED(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_UNDEFINED)
 
#define DUK_STRIDX_UC_NULL   1 /* 'Null' */
 
#define DUK_HEAP_STRING_UC_NULL(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_NULL)
 
#define DUK_HTHREAD_STRING_UC_NULL(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_NULL)
 
#define DUK_STRIDX_UC_ARGUMENTS   2 /* 'Arguments' */
 
#define DUK_HEAP_STRING_UC_ARGUMENTS(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_ARGUMENTS)
 
#define DUK_HTHREAD_STRING_UC_ARGUMENTS(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_ARGUMENTS)
 
#define DUK_STRIDX_UC_OBJECT   3 /* 'Object' */
 
#define DUK_HEAP_STRING_UC_OBJECT(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_OBJECT)
 
#define DUK_HTHREAD_STRING_UC_OBJECT(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_OBJECT)
 
#define DUK_STRIDX_UC_FUNCTION   4 /* 'Function' */
 
#define DUK_HEAP_STRING_UC_FUNCTION(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_FUNCTION)
 
#define DUK_HTHREAD_STRING_UC_FUNCTION(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_FUNCTION)
 
#define DUK_STRIDX_ARRAY   5 /* 'Array' */
 
#define DUK_HEAP_STRING_ARRAY(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ARRAY)
 
#define DUK_HTHREAD_STRING_ARRAY(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ARRAY)
 
#define DUK_STRIDX_UC_STRING   6 /* 'String' */
 
#define DUK_HEAP_STRING_UC_STRING(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_STRING)
 
#define DUK_HTHREAD_STRING_UC_STRING(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_STRING)
 
#define DUK_STRIDX_UC_BOOLEAN   7 /* 'Boolean' */
 
#define DUK_HEAP_STRING_UC_BOOLEAN(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_BOOLEAN)
 
#define DUK_HTHREAD_STRING_UC_BOOLEAN(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_BOOLEAN)
 
#define DUK_STRIDX_UC_NUMBER   8 /* 'Number' */
 
#define DUK_HEAP_STRING_UC_NUMBER(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_NUMBER)
 
#define DUK_HTHREAD_STRING_UC_NUMBER(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_NUMBER)
 
#define DUK_STRIDX_DATE   9 /* 'Date' */
 
#define DUK_HEAP_STRING_DATE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DATE)
 
#define DUK_HTHREAD_STRING_DATE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DATE)
 
#define DUK_STRIDX_REG_EXP   10 /* 'RegExp' */
 
#define DUK_HEAP_STRING_REG_EXP(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_REG_EXP)
 
#define DUK_HTHREAD_STRING_REG_EXP(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_REG_EXP)
 
#define DUK_STRIDX_UC_ERROR   11 /* 'Error' */
 
#define DUK_HEAP_STRING_UC_ERROR(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_ERROR)
 
#define DUK_HTHREAD_STRING_UC_ERROR(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_ERROR)
 
#define DUK_STRIDX_MATH   12 /* 'Math' */
 
#define DUK_HEAP_STRING_MATH(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_MATH)
 
#define DUK_HTHREAD_STRING_MATH(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_MATH)
 
#define DUK_STRIDX_JSON   13 /* 'JSON' */
 
#define DUK_HEAP_STRING_JSON(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON)
 
#define DUK_HTHREAD_STRING_JSON(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON)
 
#define DUK_STRIDX_EMPTY_STRING   14 /* '' */
 
#define DUK_HEAP_STRING_EMPTY_STRING(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EMPTY_STRING)
 
#define DUK_HTHREAD_STRING_EMPTY_STRING(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EMPTY_STRING)
 
#define DUK_STRIDX_ARRAY_BUFFER   15 /* 'ArrayBuffer' */
 
#define DUK_HEAP_STRING_ARRAY_BUFFER(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ARRAY_BUFFER)
 
#define DUK_HTHREAD_STRING_ARRAY_BUFFER(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ARRAY_BUFFER)
 
#define DUK_STRIDX_DATA_VIEW   16 /* 'DataView' */
 
#define DUK_HEAP_STRING_DATA_VIEW(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DATA_VIEW)
 
#define DUK_HTHREAD_STRING_DATA_VIEW(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DATA_VIEW)
 
#define DUK_STRIDX_INT8_ARRAY   17 /* 'Int8Array' */
 
#define DUK_HEAP_STRING_INT8_ARRAY(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT8_ARRAY)
 
#define DUK_HTHREAD_STRING_INT8_ARRAY(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT8_ARRAY)
 
#define DUK_STRIDX_UINT8_ARRAY   18 /* 'Uint8Array' */
 
#define DUK_HEAP_STRING_UINT8_ARRAY(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UINT8_ARRAY)
 
#define DUK_HTHREAD_STRING_UINT8_ARRAY(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UINT8_ARRAY)
 
#define DUK_STRIDX_UINT8_CLAMPED_ARRAY   19 /* 'Uint8ClampedArray' */
 
#define DUK_HEAP_STRING_UINT8_CLAMPED_ARRAY(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UINT8_CLAMPED_ARRAY)
 
#define DUK_HTHREAD_STRING_UINT8_CLAMPED_ARRAY(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UINT8_CLAMPED_ARRAY)
 
#define DUK_STRIDX_INT16_ARRAY   20 /* 'Int16Array' */
 
#define DUK_HEAP_STRING_INT16_ARRAY(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT16_ARRAY)
 
#define DUK_HTHREAD_STRING_INT16_ARRAY(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT16_ARRAY)
 
#define DUK_STRIDX_UINT16_ARRAY   21 /* 'Uint16Array' */
 
#define DUK_HEAP_STRING_UINT16_ARRAY(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UINT16_ARRAY)
 
#define DUK_HTHREAD_STRING_UINT16_ARRAY(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UINT16_ARRAY)
 
#define DUK_STRIDX_INT32_ARRAY   22 /* 'Int32Array' */
 
#define DUK_HEAP_STRING_INT32_ARRAY(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT32_ARRAY)
 
#define DUK_HTHREAD_STRING_INT32_ARRAY(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT32_ARRAY)
 
#define DUK_STRIDX_UINT32_ARRAY   23 /* 'Uint32Array' */
 
#define DUK_HEAP_STRING_UINT32_ARRAY(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UINT32_ARRAY)
 
#define DUK_HTHREAD_STRING_UINT32_ARRAY(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UINT32_ARRAY)
 
#define DUK_STRIDX_FLOAT32_ARRAY   24 /* 'Float32Array' */
 
#define DUK_HEAP_STRING_FLOAT32_ARRAY(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FLOAT32_ARRAY)
 
#define DUK_HTHREAD_STRING_FLOAT32_ARRAY(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FLOAT32_ARRAY)
 
#define DUK_STRIDX_FLOAT64_ARRAY   25 /* 'Float64Array' */
 
#define DUK_HEAP_STRING_FLOAT64_ARRAY(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FLOAT64_ARRAY)
 
#define DUK_HTHREAD_STRING_FLOAT64_ARRAY(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FLOAT64_ARRAY)
 
#define DUK_STRIDX_GLOBAL   26 /* 'global' */
 
#define DUK_HEAP_STRING_GLOBAL(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_GLOBAL)
 
#define DUK_HTHREAD_STRING_GLOBAL(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_GLOBAL)
 
#define DUK_STRIDX_OBJ_ENV   27 /* 'ObjEnv' */
 
#define DUK_HEAP_STRING_OBJ_ENV(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_OBJ_ENV)
 
#define DUK_HTHREAD_STRING_OBJ_ENV(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_OBJ_ENV)
 
#define DUK_STRIDX_DEC_ENV   28 /* 'DecEnv' */
 
#define DUK_HEAP_STRING_DEC_ENV(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DEC_ENV)
 
#define DUK_HTHREAD_STRING_DEC_ENV(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DEC_ENV)
 
#define DUK_STRIDX_UC_BUFFER   29 /* 'Buffer' */
 
#define DUK_HEAP_STRING_UC_BUFFER(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_BUFFER)
 
#define DUK_HTHREAD_STRING_UC_BUFFER(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_BUFFER)
 
#define DUK_STRIDX_UC_POINTER   30 /* 'Pointer' */
 
#define DUK_HEAP_STRING_UC_POINTER(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_POINTER)
 
#define DUK_HTHREAD_STRING_UC_POINTER(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_POINTER)
 
#define DUK_STRIDX_UC_THREAD   31 /* 'Thread' */
 
#define DUK_HEAP_STRING_UC_THREAD(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_THREAD)
 
#define DUK_HTHREAD_STRING_UC_THREAD(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_THREAD)
 
#define DUK_STRIDX_EVAL   32 /* 'eval' */
 
#define DUK_HEAP_STRING_EVAL(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EVAL)
 
#define DUK_HTHREAD_STRING_EVAL(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EVAL)
 
#define DUK_STRIDX_DEFINE_PROPERTY   33 /* 'defineProperty' */
 
#define DUK_HEAP_STRING_DEFINE_PROPERTY(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DEFINE_PROPERTY)
 
#define DUK_HTHREAD_STRING_DEFINE_PROPERTY(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DEFINE_PROPERTY)
 
#define DUK_STRIDX_VALUE   34 /* 'value' */
 
#define DUK_HEAP_STRING_VALUE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_VALUE)
 
#define DUK_HTHREAD_STRING_VALUE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_VALUE)
 
#define DUK_STRIDX_WRITABLE   35 /* 'writable' */
 
#define DUK_HEAP_STRING_WRITABLE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WRITABLE)
 
#define DUK_HTHREAD_STRING_WRITABLE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WRITABLE)
 
#define DUK_STRIDX_CONFIGURABLE   36 /* 'configurable' */
 
#define DUK_HEAP_STRING_CONFIGURABLE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CONFIGURABLE)
 
#define DUK_HTHREAD_STRING_CONFIGURABLE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CONFIGURABLE)
 
#define DUK_STRIDX_ENUMERABLE   37 /* 'enumerable' */
 
#define DUK_HEAP_STRING_ENUMERABLE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ENUMERABLE)
 
#define DUK_HTHREAD_STRING_ENUMERABLE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ENUMERABLE)
 
#define DUK_STRIDX_JOIN   38 /* 'join' */
 
#define DUK_HEAP_STRING_JOIN(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JOIN)
 
#define DUK_HTHREAD_STRING_JOIN(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JOIN)
 
#define DUK_STRIDX_TO_LOCALE_STRING   39 /* 'toLocaleString' */
 
#define DUK_HEAP_STRING_TO_LOCALE_STRING(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_LOCALE_STRING)
 
#define DUK_HTHREAD_STRING_TO_LOCALE_STRING(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_LOCALE_STRING)
 
#define DUK_STRIDX_VALUE_OF   40 /* 'valueOf' */
 
#define DUK_HEAP_STRING_VALUE_OF(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_VALUE_OF)
 
#define DUK_HTHREAD_STRING_VALUE_OF(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_VALUE_OF)
 
#define DUK_STRIDX_TO_UTC_STRING   41 /* 'toUTCString' */
 
#define DUK_HEAP_STRING_TO_UTC_STRING(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_UTC_STRING)
 
#define DUK_HTHREAD_STRING_TO_UTC_STRING(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_UTC_STRING)
 
#define DUK_STRIDX_TO_ISO_STRING   42 /* 'toISOString' */
 
#define DUK_HEAP_STRING_TO_ISO_STRING(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_ISO_STRING)
 
#define DUK_HTHREAD_STRING_TO_ISO_STRING(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_ISO_STRING)
 
#define DUK_STRIDX_TO_GMT_STRING   43 /* 'toGMTString' */
 
#define DUK_HEAP_STRING_TO_GMT_STRING(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_GMT_STRING)
 
#define DUK_HTHREAD_STRING_TO_GMT_STRING(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_GMT_STRING)
 
#define DUK_STRIDX_SOURCE   44 /* 'source' */
 
#define DUK_HEAP_STRING_SOURCE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SOURCE)
 
#define DUK_HTHREAD_STRING_SOURCE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SOURCE)
 
#define DUK_STRIDX_IGNORE_CASE   45 /* 'ignoreCase' */
 
#define DUK_HEAP_STRING_IGNORE_CASE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IGNORE_CASE)
 
#define DUK_HTHREAD_STRING_IGNORE_CASE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IGNORE_CASE)
 
#define DUK_STRIDX_MULTILINE   46 /* 'multiline' */
 
#define DUK_HEAP_STRING_MULTILINE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_MULTILINE)
 
#define DUK_HTHREAD_STRING_MULTILINE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_MULTILINE)
 
#define DUK_STRIDX_LAST_INDEX   47 /* 'lastIndex' */
 
#define DUK_HEAP_STRING_LAST_INDEX(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LAST_INDEX)
 
#define DUK_HTHREAD_STRING_LAST_INDEX(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LAST_INDEX)
 
#define DUK_STRIDX_ESCAPED_EMPTY_REGEXP   48 /* '(?:)' */
 
#define DUK_HEAP_STRING_ESCAPED_EMPTY_REGEXP(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ESCAPED_EMPTY_REGEXP)
 
#define DUK_HTHREAD_STRING_ESCAPED_EMPTY_REGEXP(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ESCAPED_EMPTY_REGEXP)
 
#define DUK_STRIDX_INDEX   49 /* 'index' */
 
#define DUK_HEAP_STRING_INDEX(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INDEX)
 
#define DUK_HTHREAD_STRING_INDEX(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INDEX)
 
#define DUK_STRIDX_PROTOTYPE   50 /* 'prototype' */
 
#define DUK_HEAP_STRING_PROTOTYPE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PROTOTYPE)
 
#define DUK_HTHREAD_STRING_PROTOTYPE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PROTOTYPE)
 
#define DUK_STRIDX_CONSTRUCTOR   51 /* 'constructor' */
 
#define DUK_HEAP_STRING_CONSTRUCTOR(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CONSTRUCTOR)
 
#define DUK_HTHREAD_STRING_CONSTRUCTOR(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CONSTRUCTOR)
 
#define DUK_STRIDX_MESSAGE   52 /* 'message' */
 
#define DUK_HEAP_STRING_MESSAGE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_MESSAGE)
 
#define DUK_HTHREAD_STRING_MESSAGE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_MESSAGE)
 
#define DUK_STRIDX_LC_BOOLEAN   53 /* 'boolean' */
 
#define DUK_HEAP_STRING_LC_BOOLEAN(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_BOOLEAN)
 
#define DUK_HTHREAD_STRING_LC_BOOLEAN(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_BOOLEAN)
 
#define DUK_STRIDX_LC_NUMBER   54 /* 'number' */
 
#define DUK_HEAP_STRING_LC_NUMBER(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_NUMBER)
 
#define DUK_HTHREAD_STRING_LC_NUMBER(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_NUMBER)
 
#define DUK_STRIDX_LC_STRING   55 /* 'string' */
 
#define DUK_HEAP_STRING_LC_STRING(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_STRING)
 
#define DUK_HTHREAD_STRING_LC_STRING(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_STRING)
 
#define DUK_STRIDX_LC_OBJECT   56 /* 'object' */
 
#define DUK_HEAP_STRING_LC_OBJECT(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_OBJECT)
 
#define DUK_HTHREAD_STRING_LC_OBJECT(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_OBJECT)
 
#define DUK_STRIDX_LC_UNDEFINED   57 /* 'undefined' */
 
#define DUK_HEAP_STRING_LC_UNDEFINED(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_UNDEFINED)
 
#define DUK_HTHREAD_STRING_LC_UNDEFINED(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_UNDEFINED)
 
#define DUK_STRIDX_NAN   58 /* 'NaN' */
 
#define DUK_HEAP_STRING_NAN(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_NAN)
 
#define DUK_HTHREAD_STRING_NAN(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_NAN)
 
#define DUK_STRIDX_INFINITY   59 /* 'Infinity' */
 
#define DUK_HEAP_STRING_INFINITY(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INFINITY)
 
#define DUK_HTHREAD_STRING_INFINITY(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INFINITY)
 
#define DUK_STRIDX_MINUS_INFINITY   60 /* '-Infinity' */
 
#define DUK_HEAP_STRING_MINUS_INFINITY(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_MINUS_INFINITY)
 
#define DUK_HTHREAD_STRING_MINUS_INFINITY(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_MINUS_INFINITY)
 
#define DUK_STRIDX_MINUS_ZERO   61 /* '-0' */
 
#define DUK_HEAP_STRING_MINUS_ZERO(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_MINUS_ZERO)
 
#define DUK_HTHREAD_STRING_MINUS_ZERO(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_MINUS_ZERO)
 
#define DUK_STRIDX_COMMA   62 /* ',' */
 
#define DUK_HEAP_STRING_COMMA(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_COMMA)
 
#define DUK_HTHREAD_STRING_COMMA(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_COMMA)
 
#define DUK_STRIDX_SPACE   63 /* ' ' */
 
#define DUK_HEAP_STRING_SPACE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SPACE)
 
#define DUK_HTHREAD_STRING_SPACE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SPACE)
 
#define DUK_STRIDX_NEWLINE_4SPACE   64 /* '\n ' */
 
#define DUK_HEAP_STRING_NEWLINE_4SPACE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_NEWLINE_4SPACE)
 
#define DUK_HTHREAD_STRING_NEWLINE_4SPACE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_NEWLINE_4SPACE)
 
#define DUK_STRIDX_BRACKETED_ELLIPSIS   65 /* '[...]' */
 
#define DUK_HEAP_STRING_BRACKETED_ELLIPSIS(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BRACKETED_ELLIPSIS)
 
#define DUK_HTHREAD_STRING_BRACKETED_ELLIPSIS(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BRACKETED_ELLIPSIS)
 
#define DUK_STRIDX_INVALID_DATE   66 /* 'Invalid Date' */
 
#define DUK_HEAP_STRING_INVALID_DATE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INVALID_DATE)
 
#define DUK_HTHREAD_STRING_INVALID_DATE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INVALID_DATE)
 
#define DUK_STRIDX_LC_ARGUMENTS   67 /* 'arguments' */
 
#define DUK_HEAP_STRING_LC_ARGUMENTS(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_ARGUMENTS)
 
#define DUK_HTHREAD_STRING_LC_ARGUMENTS(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_ARGUMENTS)
 
#define DUK_STRIDX_CALLEE   68 /* 'callee' */
 
#define DUK_HEAP_STRING_CALLEE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CALLEE)
 
#define DUK_HTHREAD_STRING_CALLEE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CALLEE)
 
#define DUK_STRIDX_CALLER   69 /* 'caller' */
 
#define DUK_HEAP_STRING_CALLER(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CALLER)
 
#define DUK_HTHREAD_STRING_CALLER(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CALLER)
 
#define DUK_STRIDX_HAS   70 /* 'has' */
 
#define DUK_HEAP_STRING_HAS(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_HAS)
 
#define DUK_HTHREAD_STRING_HAS(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_HAS)
 
#define DUK_STRIDX_GET   71 /* 'get' */
 
#define DUK_HEAP_STRING_GET(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_GET)
 
#define DUK_HTHREAD_STRING_GET(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_GET)
 
#define DUK_STRIDX_DELETE_PROPERTY   72 /* 'deleteProperty' */
 
#define DUK_HEAP_STRING_DELETE_PROPERTY(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DELETE_PROPERTY)
 
#define DUK_HTHREAD_STRING_DELETE_PROPERTY(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DELETE_PROPERTY)
 
#define DUK_STRIDX_ENUMERATE   73 /* 'enumerate' */
 
#define DUK_HEAP_STRING_ENUMERATE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ENUMERATE)
 
#define DUK_HTHREAD_STRING_ENUMERATE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ENUMERATE)
 
#define DUK_STRIDX_OWN_KEYS   74 /* 'ownKeys' */
 
#define DUK_HEAP_STRING_OWN_KEYS(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_OWN_KEYS)
 
#define DUK_HTHREAD_STRING_OWN_KEYS(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_OWN_KEYS)
 
#define DUK_STRIDX_SET_PROTOTYPE_OF   75 /* 'setPrototypeOf' */
 
#define DUK_HEAP_STRING_SET_PROTOTYPE_OF(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SET_PROTOTYPE_OF)
 
#define DUK_HTHREAD_STRING_SET_PROTOTYPE_OF(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SET_PROTOTYPE_OF)
 
#define DUK_STRIDX___PROTO__   76 /* '__proto__' */
 
#define DUK_HEAP_STRING___PROTO__(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX___PROTO__)
 
#define DUK_HTHREAD_STRING___PROTO__(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX___PROTO__)
 
#define DUK_STRIDX_REQUIRE   77 /* 'require' */
 
#define DUK_HEAP_STRING_REQUIRE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_REQUIRE)
 
#define DUK_HTHREAD_STRING_REQUIRE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_REQUIRE)
 
#define DUK_STRIDX_ID   78 /* 'id' */
 
#define DUK_HEAP_STRING_ID(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ID)
 
#define DUK_HTHREAD_STRING_ID(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ID)
 
#define DUK_STRIDX_EXPORTS   79 /* 'exports' */
 
#define DUK_HEAP_STRING_EXPORTS(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EXPORTS)
 
#define DUK_HTHREAD_STRING_EXPORTS(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EXPORTS)
 
#define DUK_STRIDX_FILENAME   80 /* 'filename' */
 
#define DUK_HEAP_STRING_FILENAME(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FILENAME)
 
#define DUK_HTHREAD_STRING_FILENAME(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FILENAME)
 
#define DUK_STRIDX_TO_STRING   81 /* 'toString' */
 
#define DUK_HEAP_STRING_TO_STRING(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_STRING)
 
#define DUK_HTHREAD_STRING_TO_STRING(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_STRING)
 
#define DUK_STRIDX_TO_JSON   82 /* 'toJSON' */
 
#define DUK_HEAP_STRING_TO_JSON(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_JSON)
 
#define DUK_HTHREAD_STRING_TO_JSON(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_JSON)
 
#define DUK_STRIDX_TYPE   83 /* 'type' */
 
#define DUK_HEAP_STRING_TYPE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TYPE)
 
#define DUK_HTHREAD_STRING_TYPE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TYPE)
 
#define DUK_STRIDX_DATA   84 /* 'data' */
 
#define DUK_HEAP_STRING_DATA(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DATA)
 
#define DUK_HTHREAD_STRING_DATA(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DATA)
 
#define DUK_STRIDX_LENGTH   85 /* 'length' */
 
#define DUK_HEAP_STRING_LENGTH(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LENGTH)
 
#define DUK_HTHREAD_STRING_LENGTH(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LENGTH)
 
#define DUK_STRIDX_BYTE_LENGTH   86 /* 'byteLength' */
 
#define DUK_HEAP_STRING_BYTE_LENGTH(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BYTE_LENGTH)
 
#define DUK_HTHREAD_STRING_BYTE_LENGTH(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BYTE_LENGTH)
 
#define DUK_STRIDX_BYTE_OFFSET   87 /* 'byteOffset' */
 
#define DUK_HEAP_STRING_BYTE_OFFSET(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BYTE_OFFSET)
 
#define DUK_HTHREAD_STRING_BYTE_OFFSET(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BYTE_OFFSET)
 
#define DUK_STRIDX_BYTES_PER_ELEMENT   88 /* 'BYTES_PER_ELEMENT' */
 
#define DUK_HEAP_STRING_BYTES_PER_ELEMENT(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BYTES_PER_ELEMENT)
 
#define DUK_HTHREAD_STRING_BYTES_PER_ELEMENT(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BYTES_PER_ELEMENT)
 
#define DUK_STRIDX_SET   89 /* 'set' */
 
#define DUK_HEAP_STRING_SET(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SET)
 
#define DUK_HTHREAD_STRING_SET(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SET)
 
#define DUK_STRIDX_STACK   90 /* 'stack' */
 
#define DUK_HEAP_STRING_STACK(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_STACK)
 
#define DUK_HTHREAD_STRING_STACK(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_STACK)
 
#define DUK_STRIDX_PC   91 /* 'pc' */
 
#define DUK_HEAP_STRING_PC(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PC)
 
#define DUK_HTHREAD_STRING_PC(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PC)
 
#define DUK_STRIDX_LINE_NUMBER   92 /* 'lineNumber' */
 
#define DUK_HEAP_STRING_LINE_NUMBER(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LINE_NUMBER)
 
#define DUK_HTHREAD_STRING_LINE_NUMBER(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LINE_NUMBER)
 
#define DUK_STRIDX_INT_TRACEDATA   93 /* '\xffTracedata' */
 
#define DUK_HEAP_STRING_INT_TRACEDATA(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_TRACEDATA)
 
#define DUK_HTHREAD_STRING_INT_TRACEDATA(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_TRACEDATA)
 
#define DUK_STRIDX_NAME   94 /* 'name' */
 
#define DUK_HEAP_STRING_NAME(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_NAME)
 
#define DUK_HTHREAD_STRING_NAME(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_NAME)
 
#define DUK_STRIDX_FILE_NAME   95 /* 'fileName' */
 
#define DUK_HEAP_STRING_FILE_NAME(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FILE_NAME)
 
#define DUK_HTHREAD_STRING_FILE_NAME(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FILE_NAME)
 
#define DUK_STRIDX_LC_BUFFER   96 /* 'buffer' */
 
#define DUK_HEAP_STRING_LC_BUFFER(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_BUFFER)
 
#define DUK_HTHREAD_STRING_LC_BUFFER(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_BUFFER)
 
#define DUK_STRIDX_LC_POINTER   97 /* 'pointer' */
 
#define DUK_HEAP_STRING_LC_POINTER(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_POINTER)
 
#define DUK_HTHREAD_STRING_LC_POINTER(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_POINTER)
 
#define DUK_STRIDX_INT_VALUE   98 /* '\xffValue' */
 
#define DUK_HEAP_STRING_INT_VALUE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_VALUE)
 
#define DUK_HTHREAD_STRING_INT_VALUE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_VALUE)
 
#define DUK_STRIDX_INT_NEXT   99 /* '\xffNext' */
 
#define DUK_HEAP_STRING_INT_NEXT(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_NEXT)
 
#define DUK_HTHREAD_STRING_INT_NEXT(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_NEXT)
 
#define DUK_STRIDX_INT_BYTECODE   100 /* '\xffBytecode' */
 
#define DUK_HEAP_STRING_INT_BYTECODE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_BYTECODE)
 
#define DUK_HTHREAD_STRING_INT_BYTECODE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_BYTECODE)
 
#define DUK_STRIDX_INT_FORMALS   101 /* '\xffFormals' */
 
#define DUK_HEAP_STRING_INT_FORMALS(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_FORMALS)
 
#define DUK_HTHREAD_STRING_INT_FORMALS(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_FORMALS)
 
#define DUK_STRIDX_INT_VARMAP   102 /* '\xffVarmap' */
 
#define DUK_HEAP_STRING_INT_VARMAP(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_VARMAP)
 
#define DUK_HTHREAD_STRING_INT_VARMAP(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_VARMAP)
 
#define DUK_STRIDX_INT_LEXENV   103 /* '\xffLexenv' */
 
#define DUK_HEAP_STRING_INT_LEXENV(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_LEXENV)
 
#define DUK_HTHREAD_STRING_INT_LEXENV(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_LEXENV)
 
#define DUK_STRIDX_INT_VARENV   104 /* '\xffVarenv' */
 
#define DUK_HEAP_STRING_INT_VARENV(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_VARENV)
 
#define DUK_HTHREAD_STRING_INT_VARENV(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_VARENV)
 
#define DUK_STRIDX_INT_SOURCE   105 /* '\xffSource' */
 
#define DUK_HEAP_STRING_INT_SOURCE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_SOURCE)
 
#define DUK_HTHREAD_STRING_INT_SOURCE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_SOURCE)
 
#define DUK_STRIDX_INT_PC2LINE   106 /* '\xffPc2line' */
 
#define DUK_HEAP_STRING_INT_PC2LINE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_PC2LINE)
 
#define DUK_HTHREAD_STRING_INT_PC2LINE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_PC2LINE)
 
#define DUK_STRIDX_INT_ARGS   107 /* '\xffArgs' */
 
#define DUK_HEAP_STRING_INT_ARGS(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_ARGS)
 
#define DUK_HTHREAD_STRING_INT_ARGS(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_ARGS)
 
#define DUK_STRIDX_INT_MAP   108 /* '\xffMap' */
 
#define DUK_HEAP_STRING_INT_MAP(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_MAP)
 
#define DUK_HTHREAD_STRING_INT_MAP(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_MAP)
 
#define DUK_STRIDX_INT_FINALIZER   109 /* '\xffFinalizer' */
 
#define DUK_HEAP_STRING_INT_FINALIZER(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_FINALIZER)
 
#define DUK_HTHREAD_STRING_INT_FINALIZER(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_FINALIZER)
 
#define DUK_STRIDX_INT_HANDLER   110 /* '\xffHandler' */
 
#define DUK_HEAP_STRING_INT_HANDLER(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_HANDLER)
 
#define DUK_HTHREAD_STRING_INT_HANDLER(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_HANDLER)
 
#define DUK_STRIDX_INT_CALLEE   111 /* '\xffCallee' */
 
#define DUK_HEAP_STRING_INT_CALLEE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_CALLEE)
 
#define DUK_HTHREAD_STRING_INT_CALLEE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_CALLEE)
 
#define DUK_STRIDX_INT_THREAD   112 /* '\xffThread' */
 
#define DUK_HEAP_STRING_INT_THREAD(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_THREAD)
 
#define DUK_HTHREAD_STRING_INT_THREAD(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_THREAD)
 
#define DUK_STRIDX_INT_REGBASE   113 /* '\xffRegbase' */
 
#define DUK_HEAP_STRING_INT_REGBASE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_REGBASE)
 
#define DUK_HTHREAD_STRING_INT_REGBASE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_REGBASE)
 
#define DUK_STRIDX_INT_TARGET   114 /* '\xffTarget' */
 
#define DUK_HEAP_STRING_INT_TARGET(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_TARGET)
 
#define DUK_HTHREAD_STRING_INT_TARGET(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_TARGET)
 
#define DUK_STRIDX_INT_THIS   115 /* '\xffThis' */
 
#define DUK_HEAP_STRING_INT_THIS(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_THIS)
 
#define DUK_HTHREAD_STRING_INT_THIS(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_THIS)
 
#define DUK_STRIDX_COMPILE   116 /* 'compile' */
 
#define DUK_HEAP_STRING_COMPILE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_COMPILE)
 
#define DUK_HTHREAD_STRING_COMPILE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_COMPILE)
 
#define DUK_STRIDX_INPUT   117 /* 'input' */
 
#define DUK_HEAP_STRING_INPUT(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INPUT)
 
#define DUK_HTHREAD_STRING_INPUT(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INPUT)
 
#define DUK_STRIDX_ERR_CREATE   118 /* 'errCreate' */
 
#define DUK_HEAP_STRING_ERR_CREATE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ERR_CREATE)
 
#define DUK_HTHREAD_STRING_ERR_CREATE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ERR_CREATE)
 
#define DUK_STRIDX_ERR_THROW   119 /* 'errThrow' */
 
#define DUK_HEAP_STRING_ERR_THROW(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ERR_THROW)
 
#define DUK_HTHREAD_STRING_ERR_THROW(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ERR_THROW)
 
#define DUK_STRIDX_MOD_SEARCH   120 /* 'modSearch' */
 
#define DUK_HEAP_STRING_MOD_SEARCH(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_MOD_SEARCH)
 
#define DUK_HTHREAD_STRING_MOD_SEARCH(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_MOD_SEARCH)
 
#define DUK_STRIDX_MOD_LOADED   121 /* 'modLoaded' */
 
#define DUK_HEAP_STRING_MOD_LOADED(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_MOD_LOADED)
 
#define DUK_HTHREAD_STRING_MOD_LOADED(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_MOD_LOADED)
 
#define DUK_STRIDX_ENV   122 /* 'env' */
 
#define DUK_HEAP_STRING_ENV(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ENV)
 
#define DUK_HTHREAD_STRING_ENV(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ENV)
 
#define DUK_STRIDX_HEX   123 /* 'hex' */
 
#define DUK_HEAP_STRING_HEX(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_HEX)
 
#define DUK_HTHREAD_STRING_HEX(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_HEX)
 
#define DUK_STRIDX_BASE64   124 /* 'base64' */
 
#define DUK_HEAP_STRING_BASE64(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BASE64)
 
#define DUK_HTHREAD_STRING_BASE64(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BASE64)
 
#define DUK_STRIDX_JX   125 /* 'jx' */
 
#define DUK_HEAP_STRING_JX(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JX)
 
#define DUK_HTHREAD_STRING_JX(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JX)
 
#define DUK_STRIDX_JC   126 /* 'jc' */
 
#define DUK_HEAP_STRING_JC(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JC)
 
#define DUK_HTHREAD_STRING_JC(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JC)
 
#define DUK_STRIDX_RESUME   127 /* 'resume' */
 
#define DUK_HEAP_STRING_RESUME(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_RESUME)
 
#define DUK_HTHREAD_STRING_RESUME(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_RESUME)
 
#define DUK_STRIDX_FMT   128 /* 'fmt' */
 
#define DUK_HEAP_STRING_FMT(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FMT)
 
#define DUK_HTHREAD_STRING_FMT(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FMT)
 
#define DUK_STRIDX_RAW   129 /* 'raw' */
 
#define DUK_HEAP_STRING_RAW(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_RAW)
 
#define DUK_HTHREAD_STRING_RAW(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_RAW)
 
#define DUK_STRIDX_LC_TRACE   130 /* 'trace' */
 
#define DUK_HEAP_STRING_LC_TRACE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_TRACE)
 
#define DUK_HTHREAD_STRING_LC_TRACE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_TRACE)
 
#define DUK_STRIDX_LC_DEBUG   131 /* 'debug' */
 
#define DUK_HEAP_STRING_LC_DEBUG(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_DEBUG)
 
#define DUK_HTHREAD_STRING_LC_DEBUG(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_DEBUG)
 
#define DUK_STRIDX_LC_INFO   132 /* 'info' */
 
#define DUK_HEAP_STRING_LC_INFO(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_INFO)
 
#define DUK_HTHREAD_STRING_LC_INFO(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_INFO)
 
#define DUK_STRIDX_LC_WARN   133 /* 'warn' */
 
#define DUK_HEAP_STRING_LC_WARN(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_WARN)
 
#define DUK_HTHREAD_STRING_LC_WARN(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_WARN)
 
#define DUK_STRIDX_LC_ERROR   134 /* 'error' */
 
#define DUK_HEAP_STRING_LC_ERROR(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_ERROR)
 
#define DUK_HTHREAD_STRING_LC_ERROR(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_ERROR)
 
#define DUK_STRIDX_LC_FATAL   135 /* 'fatal' */
 
#define DUK_HEAP_STRING_LC_FATAL(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_FATAL)
 
#define DUK_HTHREAD_STRING_LC_FATAL(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_FATAL)
 
#define DUK_STRIDX_LC_N   136 /* 'n' */
 
#define DUK_HEAP_STRING_LC_N(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_N)
 
#define DUK_HTHREAD_STRING_LC_N(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_N)
 
#define DUK_STRIDX_LC_L   137 /* 'l' */
 
#define DUK_HEAP_STRING_LC_L(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_L)
 
#define DUK_HTHREAD_STRING_LC_L(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_L)
 
#define DUK_STRIDX_CLOG   138 /* 'clog' */
 
#define DUK_HEAP_STRING_CLOG(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CLOG)
 
#define DUK_HTHREAD_STRING_CLOG(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CLOG)
 
#define DUK_STRIDX_TO_LOG_STRING   139 /* 'toLogString' */
 
#define DUK_HEAP_STRING_TO_LOG_STRING(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_LOG_STRING)
 
#define DUK_HTHREAD_STRING_TO_LOG_STRING(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_LOG_STRING)
 
#define DUK_STRIDX_JSON_EXT_UNDEFINED   140 /* '{"_undef":true}' */
 
#define DUK_HEAP_STRING_JSON_EXT_UNDEFINED(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_UNDEFINED)
 
#define DUK_HTHREAD_STRING_JSON_EXT_UNDEFINED(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_UNDEFINED)
 
#define DUK_STRIDX_JSON_EXT_NAN   141 /* '{"_nan":true}' */
 
#define DUK_HEAP_STRING_JSON_EXT_NAN(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_NAN)
 
#define DUK_HTHREAD_STRING_JSON_EXT_NAN(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_NAN)
 
#define DUK_STRIDX_JSON_EXT_POSINF   142 /* '{"_inf":true}' */
 
#define DUK_HEAP_STRING_JSON_EXT_POSINF(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_POSINF)
 
#define DUK_HTHREAD_STRING_JSON_EXT_POSINF(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_POSINF)
 
#define DUK_STRIDX_JSON_EXT_NEGINF   143 /* '{"_ninf":true}' */
 
#define DUK_HEAP_STRING_JSON_EXT_NEGINF(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_NEGINF)
 
#define DUK_HTHREAD_STRING_JSON_EXT_NEGINF(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_NEGINF)
 
#define DUK_STRIDX_JSON_EXT_FUNCTION1   144 /* '{"_func":true}' */
 
#define DUK_HEAP_STRING_JSON_EXT_FUNCTION1(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_FUNCTION1)
 
#define DUK_HTHREAD_STRING_JSON_EXT_FUNCTION1(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_FUNCTION1)
 
#define DUK_STRIDX_JSON_EXT_FUNCTION2   145 /* '{_func:true}' */
 
#define DUK_HEAP_STRING_JSON_EXT_FUNCTION2(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_FUNCTION2)
 
#define DUK_HTHREAD_STRING_JSON_EXT_FUNCTION2(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_FUNCTION2)
 
#define DUK_STRIDX_BREAK   146 /* 'break' */
 
#define DUK_HEAP_STRING_BREAK(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BREAK)
 
#define DUK_HTHREAD_STRING_BREAK(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BREAK)
 
#define DUK_STRIDX_CASE   147 /* 'case' */
 
#define DUK_HEAP_STRING_CASE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CASE)
 
#define DUK_HTHREAD_STRING_CASE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CASE)
 
#define DUK_STRIDX_CATCH   148 /* 'catch' */
 
#define DUK_HEAP_STRING_CATCH(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CATCH)
 
#define DUK_HTHREAD_STRING_CATCH(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CATCH)
 
#define DUK_STRIDX_CONTINUE   149 /* 'continue' */
 
#define DUK_HEAP_STRING_CONTINUE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CONTINUE)
 
#define DUK_HTHREAD_STRING_CONTINUE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CONTINUE)
 
#define DUK_STRIDX_DEBUGGER   150 /* 'debugger' */
 
#define DUK_HEAP_STRING_DEBUGGER(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DEBUGGER)
 
#define DUK_HTHREAD_STRING_DEBUGGER(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DEBUGGER)
 
#define DUK_STRIDX_DEFAULT   151 /* 'default' */
 
#define DUK_HEAP_STRING_DEFAULT(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DEFAULT)
 
#define DUK_HTHREAD_STRING_DEFAULT(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DEFAULT)
 
#define DUK_STRIDX_DELETE   152 /* 'delete' */
 
#define DUK_HEAP_STRING_DELETE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DELETE)
 
#define DUK_HTHREAD_STRING_DELETE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DELETE)
 
#define DUK_STRIDX_DO   153 /* 'do' */
 
#define DUK_HEAP_STRING_DO(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DO)
 
#define DUK_HTHREAD_STRING_DO(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DO)
 
#define DUK_STRIDX_ELSE   154 /* 'else' */
 
#define DUK_HEAP_STRING_ELSE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ELSE)
 
#define DUK_HTHREAD_STRING_ELSE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ELSE)
 
#define DUK_STRIDX_FINALLY   155 /* 'finally' */
 
#define DUK_HEAP_STRING_FINALLY(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FINALLY)
 
#define DUK_HTHREAD_STRING_FINALLY(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FINALLY)
 
#define DUK_STRIDX_FOR   156 /* 'for' */
 
#define DUK_HEAP_STRING_FOR(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FOR)
 
#define DUK_HTHREAD_STRING_FOR(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FOR)
 
#define DUK_STRIDX_LC_FUNCTION   157 /* 'function' */
 
#define DUK_HEAP_STRING_LC_FUNCTION(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_FUNCTION)
 
#define DUK_HTHREAD_STRING_LC_FUNCTION(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_FUNCTION)
 
#define DUK_STRIDX_IF   158 /* 'if' */
 
#define DUK_HEAP_STRING_IF(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IF)
 
#define DUK_HTHREAD_STRING_IF(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IF)
 
#define DUK_STRIDX_IN   159 /* 'in' */
 
#define DUK_HEAP_STRING_IN(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IN)
 
#define DUK_HTHREAD_STRING_IN(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IN)
 
#define DUK_STRIDX_INSTANCEOF   160 /* 'instanceof' */
 
#define DUK_HEAP_STRING_INSTANCEOF(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INSTANCEOF)
 
#define DUK_HTHREAD_STRING_INSTANCEOF(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INSTANCEOF)
 
#define DUK_STRIDX_NEW   161 /* 'new' */
 
#define DUK_HEAP_STRING_NEW(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_NEW)
 
#define DUK_HTHREAD_STRING_NEW(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_NEW)
 
#define DUK_STRIDX_RETURN   162 /* 'return' */
 
#define DUK_HEAP_STRING_RETURN(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_RETURN)
 
#define DUK_HTHREAD_STRING_RETURN(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_RETURN)
 
#define DUK_STRIDX_SWITCH   163 /* 'switch' */
 
#define DUK_HEAP_STRING_SWITCH(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SWITCH)
 
#define DUK_HTHREAD_STRING_SWITCH(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SWITCH)
 
#define DUK_STRIDX_THIS   164 /* 'this' */
 
#define DUK_HEAP_STRING_THIS(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_THIS)
 
#define DUK_HTHREAD_STRING_THIS(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_THIS)
 
#define DUK_STRIDX_THROW   165 /* 'throw' */
 
#define DUK_HEAP_STRING_THROW(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_THROW)
 
#define DUK_HTHREAD_STRING_THROW(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_THROW)
 
#define DUK_STRIDX_TRY   166 /* 'try' */
 
#define DUK_HEAP_STRING_TRY(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TRY)
 
#define DUK_HTHREAD_STRING_TRY(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TRY)
 
#define DUK_STRIDX_TYPEOF   167 /* 'typeof' */
 
#define DUK_HEAP_STRING_TYPEOF(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TYPEOF)
 
#define DUK_HTHREAD_STRING_TYPEOF(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TYPEOF)
 
#define DUK_STRIDX_VAR   168 /* 'var' */
 
#define DUK_HEAP_STRING_VAR(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_VAR)
 
#define DUK_HTHREAD_STRING_VAR(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_VAR)
 
#define DUK_STRIDX_CONST   169 /* 'const' */
 
#define DUK_HEAP_STRING_CONST(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CONST)
 
#define DUK_HTHREAD_STRING_CONST(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CONST)
 
#define DUK_STRIDX_VOID   170 /* 'void' */
 
#define DUK_HEAP_STRING_VOID(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_VOID)
 
#define DUK_HTHREAD_STRING_VOID(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_VOID)
 
#define DUK_STRIDX_WHILE   171 /* 'while' */
 
#define DUK_HEAP_STRING_WHILE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WHILE)
 
#define DUK_HTHREAD_STRING_WHILE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WHILE)
 
#define DUK_STRIDX_WITH   172 /* 'with' */
 
#define DUK_HEAP_STRING_WITH(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WITH)
 
#define DUK_HTHREAD_STRING_WITH(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WITH)
 
#define DUK_STRIDX_CLASS   173 /* 'class' */
 
#define DUK_HEAP_STRING_CLASS(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CLASS)
 
#define DUK_HTHREAD_STRING_CLASS(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CLASS)
 
#define DUK_STRIDX_ENUM   174 /* 'enum' */
 
#define DUK_HEAP_STRING_ENUM(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ENUM)
 
#define DUK_HTHREAD_STRING_ENUM(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ENUM)
 
#define DUK_STRIDX_EXPORT   175 /* 'export' */
 
#define DUK_HEAP_STRING_EXPORT(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EXPORT)
 
#define DUK_HTHREAD_STRING_EXPORT(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EXPORT)
 
#define DUK_STRIDX_EXTENDS   176 /* 'extends' */
 
#define DUK_HEAP_STRING_EXTENDS(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EXTENDS)
 
#define DUK_HTHREAD_STRING_EXTENDS(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EXTENDS)
 
#define DUK_STRIDX_IMPORT   177 /* 'import' */
 
#define DUK_HEAP_STRING_IMPORT(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IMPORT)
 
#define DUK_HTHREAD_STRING_IMPORT(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IMPORT)
 
#define DUK_STRIDX_SUPER   178 /* 'super' */
 
#define DUK_HEAP_STRING_SUPER(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SUPER)
 
#define DUK_HTHREAD_STRING_SUPER(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SUPER)
 
#define DUK_STRIDX_LC_NULL   179 /* 'null' */
 
#define DUK_HEAP_STRING_LC_NULL(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_NULL)
 
#define DUK_HTHREAD_STRING_LC_NULL(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_NULL)
 
#define DUK_STRIDX_TRUE   180 /* 'true' */
 
#define DUK_HEAP_STRING_TRUE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TRUE)
 
#define DUK_HTHREAD_STRING_TRUE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TRUE)
 
#define DUK_STRIDX_FALSE   181 /* 'false' */
 
#define DUK_HEAP_STRING_FALSE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FALSE)
 
#define DUK_HTHREAD_STRING_FALSE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FALSE)
 
#define DUK_STRIDX_IMPLEMENTS   182 /* 'implements' */
 
#define DUK_HEAP_STRING_IMPLEMENTS(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IMPLEMENTS)
 
#define DUK_HTHREAD_STRING_IMPLEMENTS(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IMPLEMENTS)
 
#define DUK_STRIDX_INTERFACE   183 /* 'interface' */
 
#define DUK_HEAP_STRING_INTERFACE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INTERFACE)
 
#define DUK_HTHREAD_STRING_INTERFACE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INTERFACE)
 
#define DUK_STRIDX_LET   184 /* 'let' */
 
#define DUK_HEAP_STRING_LET(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LET)
 
#define DUK_HTHREAD_STRING_LET(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LET)
 
#define DUK_STRIDX_PACKAGE   185 /* 'package' */
 
#define DUK_HEAP_STRING_PACKAGE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PACKAGE)
 
#define DUK_HTHREAD_STRING_PACKAGE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PACKAGE)
 
#define DUK_STRIDX_PRIVATE   186 /* 'private' */
 
#define DUK_HEAP_STRING_PRIVATE(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PRIVATE)
 
#define DUK_HTHREAD_STRING_PRIVATE(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PRIVATE)
 
#define DUK_STRIDX_PROTECTED   187 /* 'protected' */
 
#define DUK_HEAP_STRING_PROTECTED(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PROTECTED)
 
#define DUK_HTHREAD_STRING_PROTECTED(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PROTECTED)
 
#define DUK_STRIDX_PUBLIC   188 /* 'public' */
 
#define DUK_HEAP_STRING_PUBLIC(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PUBLIC)
 
#define DUK_HTHREAD_STRING_PUBLIC(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PUBLIC)
 
#define DUK_STRIDX_STATIC   189 /* 'static' */
 
#define DUK_HEAP_STRING_STATIC(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_STATIC)
 
#define DUK_HTHREAD_STRING_STATIC(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_STATIC)
 
#define DUK_STRIDX_YIELD   190 /* 'yield' */
 
#define DUK_HEAP_STRING_YIELD(heap)   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_YIELD)
 
#define DUK_HTHREAD_STRING_YIELD(thr)   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_YIELD)
 
#define DUK_HEAP_NUM_STRINGS   191
 
#define DUK_STRIDX_START_RESERVED   146
 
#define DUK_STRIDX_START_STRICT_RESERVED   182
 
#define DUK_STRIDX_END_RESERVED   191 /* exclusive endpoint */
 
#define DUK_STRDATA_MAX_STRLEN   17
 
#define DUK_STRDATA_DATA_LENGTH   1049
 
#define DUK_BUILTIN_INITJS_DATA_LENGTH   204
 
#define DUK_BIDX_GLOBAL   0
 
#define DUK_BIDX_GLOBAL_ENV   1
 
#define DUK_BIDX_OBJECT_CONSTRUCTOR   2
 
#define DUK_BIDX_OBJECT_PROTOTYPE   3
 
#define DUK_BIDX_FUNCTION_CONSTRUCTOR   4
 
#define DUK_BIDX_FUNCTION_PROTOTYPE   5
 
#define DUK_BIDX_ARRAY_CONSTRUCTOR   6
 
#define DUK_BIDX_ARRAY_PROTOTYPE   7
 
#define DUK_BIDX_STRING_CONSTRUCTOR   8
 
#define DUK_BIDX_STRING_PROTOTYPE   9
 
#define DUK_BIDX_BOOLEAN_CONSTRUCTOR   10
 
#define DUK_BIDX_BOOLEAN_PROTOTYPE   11
 
#define DUK_BIDX_NUMBER_CONSTRUCTOR   12
 
#define DUK_BIDX_NUMBER_PROTOTYPE   13
 
#define DUK_BIDX_DATE_CONSTRUCTOR   14
 
#define DUK_BIDX_DATE_PROTOTYPE   15
 
#define DUK_BIDX_REGEXP_CONSTRUCTOR   16
 
#define DUK_BIDX_REGEXP_PROTOTYPE   17
 
#define DUK_BIDX_ERROR_CONSTRUCTOR   18
 
#define DUK_BIDX_ERROR_PROTOTYPE   19
 
#define DUK_BIDX_EVAL_ERROR_CONSTRUCTOR   20
 
#define DUK_BIDX_EVAL_ERROR_PROTOTYPE   21
 
#define DUK_BIDX_RANGE_ERROR_CONSTRUCTOR   22
 
#define DUK_BIDX_RANGE_ERROR_PROTOTYPE   23
 
#define DUK_BIDX_REFERENCE_ERROR_CONSTRUCTOR   24
 
#define DUK_BIDX_REFERENCE_ERROR_PROTOTYPE   25
 
#define DUK_BIDX_SYNTAX_ERROR_CONSTRUCTOR   26
 
#define DUK_BIDX_SYNTAX_ERROR_PROTOTYPE   27
 
#define DUK_BIDX_TYPE_ERROR_CONSTRUCTOR   28
 
#define DUK_BIDX_TYPE_ERROR_PROTOTYPE   29
 
#define DUK_BIDX_URI_ERROR_CONSTRUCTOR   30
 
#define DUK_BIDX_URI_ERROR_PROTOTYPE   31
 
#define DUK_BIDX_MATH   32
 
#define DUK_BIDX_JSON   33
 
#define DUK_BIDX_TYPE_ERROR_THROWER   34
 
#define DUK_BIDX_PROXY_CONSTRUCTOR   35
 
#define DUK_BIDX_DUKTAPE   36
 
#define DUK_BIDX_THREAD_CONSTRUCTOR   37
 
#define DUK_BIDX_THREAD_PROTOTYPE   38
 
#define DUK_BIDX_BUFFER_CONSTRUCTOR   39
 
#define DUK_BIDX_BUFFER_PROTOTYPE   40
 
#define DUK_BIDX_POINTER_CONSTRUCTOR   41
 
#define DUK_BIDX_POINTER_PROTOTYPE   42
 
#define DUK_BIDX_LOGGER_CONSTRUCTOR   43
 
#define DUK_BIDX_LOGGER_PROTOTYPE   44
 
#define DUK_BIDX_DOUBLE_ERROR   45
 
#define DUK_BIDX_ARRAYBUFFER_CONSTRUCTOR   46
 
#define DUK_BIDX_ARRAYBUFFER_PROTOTYPE   47
 
#define DUK_BIDX_DATAVIEW_CONSTRUCTOR   48
 
#define DUK_BIDX_DATAVIEW_PROTOTYPE   49
 
#define DUK_BIDX_TYPEDARRAY_PROTOTYPE   50
 
#define DUK_BIDX_INT8ARRAY_CONSTRUCTOR   51
 
#define DUK_BIDX_INT8ARRAY_PROTOTYPE   52
 
#define DUK_BIDX_UINT8ARRAY_CONSTRUCTOR   53
 
#define DUK_BIDX_UINT8ARRAY_PROTOTYPE   54
 
#define DUK_BIDX_UINT8CLAMPEDARRAY_CONSTRUCTOR   55
 
#define DUK_BIDX_UINT8CLAMPEDARRAY_PROTOTYPE   56
 
#define DUK_BIDX_INT16ARRAY_CONSTRUCTOR   57
 
#define DUK_BIDX_INT16ARRAY_PROTOTYPE   58
 
#define DUK_BIDX_UINT16ARRAY_CONSTRUCTOR   59
 
#define DUK_BIDX_UINT16ARRAY_PROTOTYPE   60
 
#define DUK_BIDX_INT32ARRAY_CONSTRUCTOR   61
 
#define DUK_BIDX_INT32ARRAY_PROTOTYPE   62
 
#define DUK_BIDX_UINT32ARRAY_CONSTRUCTOR   63
 
#define DUK_BIDX_UINT32ARRAY_PROTOTYPE   64
 
#define DUK_BIDX_FLOAT32ARRAY_CONSTRUCTOR   65
 
#define DUK_BIDX_FLOAT32ARRAY_PROTOTYPE   66
 
#define DUK_BIDX_FLOAT64ARRAY_CONSTRUCTOR   67
 
#define DUK_BIDX_FLOAT64ARRAY_PROTOTYPE   68
 
#define DUK_BIDX_NODEJS_BUFFER_CONSTRUCTOR   69
 
#define DUK_BIDX_NODEJS_BUFFER_PROTOTYPE   70
 
#define DUK_NUM_BUILTINS   71
 
#define DUK_NUM_BIDX_BUILTINS   71
 
#define DUK_NUM_ALL_BUILTINS   71
 
#define DUK_UTIL_H_INCLUDED
 
#define DUK_UTIL_MIN_HASH_PRIME   17 /* must match genhashsizes.py */
 
#define DUK_UTIL_GET_HASH_PROBE_STEP(hash)   (duk_util_probe_steps[(hash) & 0x1f])
 
#define DUK_RAW_WRITE_U8(ptr, val)
 
#define DUK_RAW_WRITE_U16_BE(ptr, val)   duk_raw_write_u16_be(&(ptr), (duk_uint16_t) (val))
 
#define DUK_RAW_WRITE_U32_BE(ptr, val)   duk_raw_write_u32_be(&(ptr), (duk_uint32_t) (val))
 
#define DUK_RAW_WRITE_DOUBLE_BE(ptr, val)   duk_raw_write_double_be(&(ptr), (duk_double_t) (val))
 
#define DUK_RAW_WRITE_XUTF8(ptr, val)
 
#define DUK_RAW_WRITE_CESU8(ptr, val)
 
#define DUK_RAW_READ_U8(ptr)   ((duk_uint8_t) (*(ptr)++))
 
#define DUK_RAW_READ_U16_BE(ptr)   duk_raw_read_u16_be(&(ptr));
 
#define DUK_RAW_READ_U32_BE(ptr)   duk_raw_read_u32_be(&(ptr));
 
#define DUK_RAW_READ_DOUBLE_BE(ptr)   duk_raw_read_double_be(&(ptr));
 
#define DUK_BW_SPARE_ADD   64
 
#define DUK_BW_SPARE_SHIFT   4 /* 2^4 -> 1/16 = 6.25% spare */
 
#define DUK_BW_INIT_PUSHBUF(thr, bw_ctx, sz)
 
#define DUK_BW_INIT_WITHBUF(thr, bw_ctx, buf)
 
#define DUK_BW_COMPACT(thr, bw_ctx)
 
#define DUK_BW_PUSH_AS_STRING(thr, bw_ctx)
 
#define DUK_BW_ASSERT_VALID_EXPR(thr, bw_ctx)
 
#define DUK_BW_ASSERT_VALID(thr, bw_ctx)
 
#define DUK_BW_GET_PTR(thr, bw_ctx)    ((bw_ctx)->p)
 
#define DUK_BW_SET_PTR(thr, bw_ctx, ptr)
 
#define DUK_BW_ADD_PTR(thr, bw_ctx, delta)
 
#define DUK_BW_GET_BASEPTR(thr, bw_ctx)    ((bw_ctx)->p_base)
 
#define DUK_BW_GET_LIMITPTR(thr, bw_ctx)    ((bw_ctx)->p_limit)
 
#define DUK_BW_GET_SIZE(thr, bw_ctx)    ((duk_size_t) ((bw_ctx)->p - (bw_ctx)->p_base))
 
#define DUK_BW_SET_SIZE(thr, bw_ctx, sz)
 
#define DUK_BW_RESET_SIZE(thr, bw_ctx)
 
#define DUK_BW_GET_BUFFER(thr, bw_ctx)    ((bw_ctx)->buf)
 
#define DUK_BW_ENSURE(thr, bw_ctx, sz)
 
#define DUK_BW_ENSURE_RAW(thr, bw_ctx, sz, ptr)
 
#define DUK_BW_ENSURE_GETPTR(thr, bw_ctx, sz)    DUK_BW_ENSURE_RAW((thr), (bw_ctx), (sz), (bw_ctx)->p)
 
#define DUK_BW_ASSERT_SPACE_EXPR(thr, bw_ctx, sz)
 
#define DUK_BW_ASSERT_SPACE(thr, bw_ctx, sz)
 
#define DUK_BW_SETPTR_AND_COMPACT(thr, bw_ctx, ptr)
 
#define DUK_BW_WRITE_RAW_U8(thr, bw_ctx, val)
 
#define DUK_BW_WRITE_RAW_U8_2(thr, bw_ctx, val1, val2)
 
#define DUK_BW_WRITE_RAW_U8_3(thr, bw_ctx, val1, val2, val3)
 
#define DUK_BW_WRITE_RAW_U8_4(thr, bw_ctx, val1, val2, val3, val4)
 
#define DUK_BW_WRITE_RAW_U8_5(thr, bw_ctx, val1, val2, val3, val4, val5)
 
#define DUK_BW_WRITE_RAW_U8_6(thr, bw_ctx, val1, val2, val3, val4, val5, val6)
 
#define DUK_BW_WRITE_RAW_XUTF8(thr, bw_ctx, cp)
 
#define DUK_BW_WRITE_RAW_CESU8(thr, bw_ctx, cp)
 
#define DUK_BW_WRITE_RAW_BYTES(thr, bw_ctx, valptr, valsz)
 
#define DUK_BW_WRITE_RAW_CSTRING(thr, bw_ctx, val)
 
#define DUK_BW_WRITE_RAW_HSTRING(thr, bw_ctx, val)
 
#define DUK_BW_WRITE_RAW_HBUFFER(thr, bw_ctx, val)
 
#define DUK_BW_WRITE_RAW_HBUFFER_FIXED(thr, bw_ctx, val)
 
#define DUK_BW_WRITE_RAW_HBUFFER_DYNAMIC(thr, bw_ctx, val)
 
#define DUK_BW_WRITE_RAW_SLICE(thr, bw, dst_off, dst_len)    duk_bw_write_raw_slice((thr), (bw), (dst_off), (dst_len))
 
#define DUK_BW_INSERT_RAW_BYTES(thr, bw, dst_off, buf, len)    duk_bw_insert_raw_bytes((thr), (bw), (dst_off), (buf), (len))
 
#define DUK_BW_INSERT_RAW_SLICE(thr, bw, dst_off, src_off, len)    duk_bw_insert_raw_slice((thr), (bw), (dst_off), (src_off), (len))
 
#define DUK_BW_INSERT_RAW_AREA(thr, bw, off, len)    duk_bw_insert_raw_area((thr), (bw), (off), (len))
 
#define DUK_BW_REMOVE_RAW_SLICE(thr, bw, off, len)    duk_bw_remove_raw_slice((thr), (bw), (off), (len))
 
#define DUK_BW_WRITE_ENSURE_U8(thr, bw_ctx, val)
 
#define DUK_BW_WRITE_ENSURE_U8_2(thr, bw_ctx, val1, val2)
 
#define DUK_BW_WRITE_ENSURE_U8_3(thr, bw_ctx, val1, val2, val3)
 
#define DUK_BW_WRITE_ENSURE_U8_4(thr, bw_ctx, val1, val2, val3, val4)
 
#define DUK_BW_WRITE_ENSURE_U8_5(thr, bw_ctx, val1, val2, val3, val4, val5)
 
#define DUK_BW_WRITE_ENSURE_U8_6(thr, bw_ctx, val1, val2, val3, val4, val5, val6)
 
#define DUK_BW_WRITE_ENSURE_XUTF8(thr, bw_ctx, cp)
 
#define DUK_BW_WRITE_ENSURE_CESU8(thr, bw_ctx, cp)
 
#define DUK_BW_WRITE_ENSURE_BYTES(thr, bw_ctx, valptr, valsz)
 
#define DUK_BW_WRITE_ENSURE_CSTRING(thr, bw_ctx, val)
 
#define DUK_BW_WRITE_ENSURE_HSTRING(thr, bw_ctx, val)
 
#define DUK_BW_WRITE_ENSURE_HBUFFER(thr, bw_ctx, val)
 
#define DUK_BW_WRITE_ENSURE_HBUFFER_FIXED(thr, bw_ctx, val)
 
#define DUK_BW_WRITE_ENSURE_HBUFFER_DYNAMIC(thr, bw_ctx, val)
 
#define DUK_BW_WRITE_ENSURE_SLICE(thr, bw, dst_off, dst_len)    duk_bw_write_ensure_slice((thr), (bw), (dst_off), (dst_len))
 
#define DUK_BW_INSERT_ENSURE_BYTES(thr, bw, dst_off, buf, len)    duk_bw_insert_ensure_bytes((thr), (bw), (dst_off), (buf), (len))
 
#define DUK_BW_INSERT_ENSURE_SLICE(thr, bw, dst_off, src_off, len)    duk_bw_insert_ensure_slice((thr), (bw), (dst_off), (src_off), (len))
 
#define DUK_BW_INSERT_ENSURE_AREA(thr, bw, off, len)
 
#define DUK_BW_REMOVE_ENSURE_SLICE(thr, bw, off, len)
 
#define DUK_ERRMSG_H_INCLUDED
 
#define DUK_STR_INTERNAL_ERROR   duk_str_internal_error
 
#define DUK_STR_INVALID_COUNT   duk_str_invalid_count
 
#define DUK_STR_INVALID_CALL_ARGS   duk_str_invalid_call_args
 
#define DUK_STR_NOT_CONSTRUCTABLE   duk_str_not_constructable
 
#define DUK_STR_NOT_CALLABLE   duk_str_not_callable
 
#define DUK_STR_NOT_EXTENSIBLE   duk_str_not_extensible
 
#define DUK_STR_NOT_WRITABLE   duk_str_not_writable
 
#define DUK_STR_NOT_CONFIGURABLE   duk_str_not_configurable
 
#define DUK_STR_INVALID_CONTEXT   duk_str_invalid_context
 
#define DUK_STR_INVALID_INDEX   duk_str_invalid_call_args
 
#define DUK_STR_PUSH_BEYOND_ALLOC_STACK   duk_str_push_beyond_alloc_stack
 
#define DUK_STR_NOT_UNDEFINED   duk_str_unexpected_type
 
#define DUK_STR_NOT_NULL   duk_str_unexpected_type
 
#define DUK_STR_NOT_BOOLEAN   duk_str_unexpected_type
 
#define DUK_STR_NOT_NUMBER   duk_str_unexpected_type
 
#define DUK_STR_NOT_STRING   duk_str_unexpected_type
 
#define DUK_STR_NOT_OBJECT   duk_str_unexpected_type
 
#define DUK_STR_NOT_POINTER   duk_str_unexpected_type
 
#define DUK_STR_NOT_BUFFER   duk_str_not_buffer /* still in use with verbose messages */
 
#define DUK_STR_UNEXPECTED_TYPE   duk_str_unexpected_type
 
#define DUK_STR_NOT_THREAD   duk_str_unexpected_type
 
#define DUK_STR_NOT_COMPILEDFUNCTION   duk_str_unexpected_type
 
#define DUK_STR_NOT_NATIVEFUNCTION   duk_str_unexpected_type
 
#define DUK_STR_NOT_C_FUNCTION   duk_str_unexpected_type
 
#define DUK_STR_NOT_FUNCTION   duk_str_unexpected_type
 
#define DUK_STR_NOT_REGEXP   duk_str_unexpected_type
 
#define DUK_STR_DEFAULTVALUE_COERCE_FAILED   duk_str_defaultvalue_coerce_failed
 
#define DUK_STR_NUMBER_OUTSIDE_RANGE   duk_str_number_outside_range
 
#define DUK_STR_NOT_OBJECT_COERCIBLE   duk_str_not_object_coercible
 
#define DUK_STR_STRING_TOO_LONG   duk_str_string_too_long
 
#define DUK_STR_BUFFER_TOO_LONG   duk_str_buffer_too_long
 
#define DUK_STR_SPRINTF_TOO_LONG   duk_str_sprintf_too_long
 
#define DUK_STR_ALLOC_FAILED   duk_str_alloc_failed
 
#define DUK_STR_POP_TOO_MANY   duk_str_pop_too_many
 
#define DUK_STR_WRONG_BUFFER_TYPE   duk_str_wrong_buffer_type
 
#define DUK_STR_ENCODE_FAILED   duk_str_encode_failed
 
#define DUK_STR_DECODE_FAILED   duk_str_decode_failed
 
#define DUK_STR_NO_SOURCECODE   duk_str_no_sourcecode
 
#define DUK_STR_CONCAT_RESULT_TOO_LONG   duk_str_concat_result_too_long
 
#define DUK_STR_UNIMPLEMENTED   duk_str_unimplemented
 
#define DUK_STR_UNSUPPORTED   duk_str_unsupported
 
#define DUK_STR_ARRAY_LENGTH_OVER_2G   duk_str_array_length_over_2g
 
#define DUK_STR_FMT_PTR   duk_str_fmt_ptr
 
#define DUK_STR_FMT_INVALID_JSON   duk_str_fmt_invalid_json
 
#define DUK_STR_JSONDEC_RECLIMIT   duk_str_jsondec_reclimit
 
#define DUK_STR_JSONENC_RECLIMIT   duk_str_jsonenc_reclimit
 
#define DUK_STR_CYCLIC_INPUT   duk_str_cyclic_input
 
#define DUK_STR_PROXY_REVOKED   duk_str_proxy_revoked
 
#define DUK_STR_INVALID_BASE   duk_str_invalid_base
 
#define DUK_STR_STRICT_CALLER_READ   duk_str_strict_caller_read
 
#define DUK_STR_PROXY_REJECTED   duk_str_proxy_rejected
 
#define DUK_STR_INVALID_ARRAY_LENGTH   duk_str_invalid_array_length
 
#define DUK_STR_ARRAY_LENGTH_WRITE_FAILED   duk_str_array_length_write_failed
 
#define DUK_STR_ARRAY_LENGTH_NOT_WRITABLE   duk_str_array_length_not_writable
 
#define DUK_STR_SETTER_UNDEFINED   duk_str_setter_undefined
 
#define DUK_STR_REDEFINE_VIRT_PROP   duk_str_redefine_virt_prop
 
#define DUK_STR_INVALID_DESCRIPTOR   duk_str_invalid_descriptor
 
#define DUK_STR_PROPERTY_IS_VIRTUAL   duk_str_property_is_virtual
 
#define DUK_STR_PARSE_ERROR   duk_str_parse_error
 
#define DUK_STR_DUPLICATE_LABEL   duk_str_duplicate_label
 
#define DUK_STR_INVALID_LABEL   duk_str_invalid_label
 
#define DUK_STR_INVALID_ARRAY_LITERAL   duk_str_invalid_array_literal
 
#define DUK_STR_INVALID_OBJECT_LITERAL   duk_str_invalid_object_literal
 
#define DUK_STR_INVALID_VAR_DECLARATION   duk_str_invalid_var_declaration
 
#define DUK_STR_CANNOT_DELETE_IDENTIFIER   duk_str_cannot_delete_identifier
 
#define DUK_STR_INVALID_EXPRESSION   duk_str_invalid_expression
 
#define DUK_STR_INVALID_LVALUE   duk_str_invalid_lvalue
 
#define DUK_STR_EXPECTED_IDENTIFIER   duk_str_expected_identifier
 
#define DUK_STR_EMPTY_EXPR_NOT_ALLOWED   duk_str_empty_expr_not_allowed
 
#define DUK_STR_INVALID_FOR   duk_str_invalid_for
 
#define DUK_STR_INVALID_SWITCH   duk_str_invalid_switch
 
#define DUK_STR_INVALID_BREAK_CONT_LABEL   duk_str_invalid_break_cont_label
 
#define DUK_STR_INVALID_RETURN   duk_str_invalid_return
 
#define DUK_STR_INVALID_TRY   duk_str_invalid_try
 
#define DUK_STR_INVALID_THROW   duk_str_invalid_throw
 
#define DUK_STR_WITH_IN_STRICT_MODE   duk_str_with_in_strict_mode
 
#define DUK_STR_FUNC_STMT_NOT_ALLOWED   duk_str_func_stmt_not_allowed
 
#define DUK_STR_UNTERMINATED_STMT   duk_str_unterminated_stmt
 
#define DUK_STR_INVALID_ARG_NAME   duk_str_invalid_arg_name
 
#define DUK_STR_INVALID_FUNC_NAME   duk_str_invalid_func_name
 
#define DUK_STR_INVALID_GETSET_NAME   duk_str_invalid_getset_name
 
#define DUK_STR_FUNC_NAME_REQUIRED   duk_str_func_name_required
 
#define DUK_STR_INVALID_QUANTIFIER_NO_ATOM   duk_str_invalid_quantifier_no_atom
 
#define DUK_STR_INVALID_QUANTIFIER_VALUES   duk_str_invalid_quantifier_values
 
#define DUK_STR_QUANTIFIER_TOO_MANY_COPIES   duk_str_quantifier_too_many_copies
 
#define DUK_STR_UNEXPECTED_CLOSING_PAREN   duk_str_unexpected_closing_paren
 
#define DUK_STR_UNEXPECTED_END_OF_PATTERN   duk_str_unexpected_end_of_pattern
 
#define DUK_STR_UNEXPECTED_REGEXP_TOKEN   duk_str_unexpected_regexp_token
 
#define DUK_STR_INVALID_REGEXP_FLAGS   duk_str_invalid_regexp_flags
 
#define DUK_STR_INVALID_BACKREFS   duk_str_invalid_backrefs
 
#define DUK_STR_VALSTACK_LIMIT   duk_str_valstack_limit
 
#define DUK_STR_CALLSTACK_LIMIT   duk_str_callstack_limit
 
#define DUK_STR_CATCHSTACK_LIMIT   duk_str_catchstack_limit
 
#define DUK_STR_PROTOTYPE_CHAIN_LIMIT   duk_str_prototype_chain_limit
 
#define DUK_STR_BOUND_CHAIN_LIMIT   duk_str_bound_chain_limit
 
#define DUK_STR_C_CALLSTACK_LIMIT   duk_str_c_callstack_limit
 
#define DUK_STR_COMPILER_RECURSION_LIMIT   duk_str_compiler_recursion_limit
 
#define DUK_STR_BYTECODE_LIMIT   duk_str_bytecode_limit
 
#define DUK_STR_REG_LIMIT   duk_str_reg_limit
 
#define DUK_STR_TEMP_LIMIT   duk_str_temp_limit
 
#define DUK_STR_CONST_LIMIT   duk_str_const_limit
 
#define DUK_STR_FUNC_LIMIT   duk_str_func_limit
 
#define DUK_STR_REGEXP_COMPILER_RECURSION_LIMIT   duk_str_regexp_compiler_recursion_limit
 
#define DUK_STR_REGEXP_EXECUTOR_RECURSION_LIMIT   duk_str_regexp_executor_recursion_limit
 
#define DUK_STR_REGEXP_EXECUTOR_STEP_LIMIT   duk_str_regexp_executor_step_limit
 
#define DUK_JS_BYTECODE_H_INCLUDED
 
#define DUK_DEC_OP(x)   ((x) & 0x3fUL)
 
#define DUK_DEC_A(x)   (((x) >> 6) & 0xffUL)
 
#define DUK_DEC_B(x)   (((x) >> 14) & 0x1ffUL)
 
#define DUK_DEC_C(x)   (((x) >> 23) & 0x1ffUL)
 
#define DUK_DEC_BC(x)   (((x) >> 14) & 0x3ffffUL)
 
#define DUK_DEC_ABC(x)   (((x) >> 6) & 0x3ffffffUL)
 
#define DUK_ENC_OP(op)   ((duk_instr_t) (op))
 
#define DUK_ENC_OP_ABC(op, abc)
 
#define DUK_ENC_OP_A_BC(op, a, bc)
 
#define DUK_ENC_OP_A_B_C(op, a, b, c)
 
#define DUK_ENC_OP_A_B(op, a, b)   DUK_ENC_OP_A_B_C(op,a,b,0)
 
#define DUK_ENC_OP_A(op, a)   DUK_ENC_OP_A_B_C(op,a,0,0)
 
#define DUK_BC_OP_MIN   0
 
#define DUK_BC_OP_MAX   0x3fL
 
#define DUK_BC_A_MIN   0
 
#define DUK_BC_A_MAX   0xffL
 
#define DUK_BC_B_MIN   0
 
#define DUK_BC_B_MAX   0x1ffL
 
#define DUK_BC_C_MIN   0
 
#define DUK_BC_C_MAX   0x1ffL
 
#define DUK_BC_BC_MIN   0
 
#define DUK_BC_BC_MAX   0x3ffffL
 
#define DUK_BC_ABC_MIN   0
 
#define DUK_BC_ABC_MAX   0x3ffffffL
 
#define DUK_BC_EXTRAOP_MIN   DUK_BC_A_MIN
 
#define DUK_BC_EXTRAOP_MAX   DUK_BC_A_MAX
 
#define DUK_OP_LDREG   0
 
#define DUK_OP_STREG   1
 
#define DUK_OP_LDCONST   2
 
#define DUK_OP_LDINT   3
 
#define DUK_OP_LDINTX   4
 
#define DUK_OP_MPUTOBJ   5
 
#define DUK_OP_MPUTOBJI   6
 
#define DUK_OP_MPUTARR   7
 
#define DUK_OP_MPUTARRI   8
 
#define DUK_OP_NEW   9
 
#define DUK_OP_NEWI   10
 
#define DUK_OP_REGEXP   11
 
#define DUK_OP_CSREG   12
 
#define DUK_OP_CSREGI   13
 
#define DUK_OP_GETVAR   14
 
#define DUK_OP_PUTVAR   15
 
#define DUK_OP_DECLVAR   16
 
#define DUK_OP_DELVAR   17
 
#define DUK_OP_CSVAR   18
 
#define DUK_OP_CSVARI   19
 
#define DUK_OP_CLOSURE   20
 
#define DUK_OP_GETPROP   21
 
#define DUK_OP_PUTPROP   22
 
#define DUK_OP_DELPROP   23
 
#define DUK_OP_CSPROP   24
 
#define DUK_OP_CSPROPI   25
 
#define DUK_OP_ADD   26
 
#define DUK_OP_SUB   27
 
#define DUK_OP_MUL   28
 
#define DUK_OP_DIV   29
 
#define DUK_OP_MOD   30
 
#define DUK_OP_BAND   31
 
#define DUK_OP_BOR   32
 
#define DUK_OP_BXOR   33
 
#define DUK_OP_BASL   34
 
#define DUK_OP_BLSR   35
 
#define DUK_OP_BASR   36
 
#define DUK_OP_EQ   37
 
#define DUK_OP_NEQ   38
 
#define DUK_OP_SEQ   39
 
#define DUK_OP_SNEQ   40
 
#define DUK_OP_GT   41
 
#define DUK_OP_GE   42
 
#define DUK_OP_LT   43
 
#define DUK_OP_LE   44
 
#define DUK_OP_IF   45
 
#define DUK_OP_JUMP   46
 
#define DUK_OP_RETURN   47
 
#define DUK_OP_CALL   48
 
#define DUK_OP_CALLI   49
 
#define DUK_OP_TRYCATCH   50
 
#define DUK_OP_EXTRA   51
 
#define DUK_OP_PREINCR   52 /* pre/post opcode values have constraints, */
 
#define DUK_OP_PREDECR   53 /* see duk_js_executor.c */
 
#define DUK_OP_POSTINCR   54
 
#define DUK_OP_POSTDECR   55
 
#define DUK_OP_PREINCV   56
 
#define DUK_OP_PREDECV   57
 
#define DUK_OP_POSTINCV   58
 
#define DUK_OP_POSTDECV   59
 
#define DUK_OP_PREINCP   60
 
#define DUK_OP_PREDECP   61
 
#define DUK_OP_POSTINCP   62
 
#define DUK_OP_POSTDECP   63
 
#define DUK_OP_NONE   64 /* dummy value used as marker */
 
#define DUK_EXTRAOP_NOP   0
 
#define DUK_EXTRAOP_INVALID   1
 
#define DUK_EXTRAOP_LDTHIS   2
 
#define DUK_EXTRAOP_LDUNDEF   3
 
#define DUK_EXTRAOP_LDNULL   4
 
#define DUK_EXTRAOP_LDTRUE   5
 
#define DUK_EXTRAOP_LDFALSE   6
 
#define DUK_EXTRAOP_NEWOBJ   7
 
#define DUK_EXTRAOP_NEWARR   8
 
#define DUK_EXTRAOP_SETALEN   9
 
#define DUK_EXTRAOP_TYPEOF   10
 
#define DUK_EXTRAOP_TYPEOFID   11
 
#define DUK_EXTRAOP_INITENUM   12
 
#define DUK_EXTRAOP_NEXTENUM   13
 
#define DUK_EXTRAOP_INITSET   14
 
#define DUK_EXTRAOP_INITSETI   15
 
#define DUK_EXTRAOP_INITGET   16
 
#define DUK_EXTRAOP_INITGETI   17
 
#define DUK_EXTRAOP_ENDTRY   18
 
#define DUK_EXTRAOP_ENDCATCH   19
 
#define DUK_EXTRAOP_ENDFIN   20
 
#define DUK_EXTRAOP_THROW   21
 
#define DUK_EXTRAOP_INVLHS   22
 
#define DUK_EXTRAOP_UNM   23
 
#define DUK_EXTRAOP_UNP   24
 
#define DUK_EXTRAOP_DEBUGGER   25
 
#define DUK_EXTRAOP_BREAK   26
 
#define DUK_EXTRAOP_CONTINUE   27
 
#define DUK_EXTRAOP_BNOT   28
 
#define DUK_EXTRAOP_LNOT   29
 
#define DUK_EXTRAOP_INSTOF   30
 
#define DUK_EXTRAOP_IN   31
 
#define DUK_EXTRAOP_LABEL   32
 
#define DUK_EXTRAOP_ENDLABEL   33
 
#define DUK_BC_CALL_FLAG_TAILCALL   (1 << 0)
 
#define DUK_BC_CALL_FLAG_EVALCALL   (1 << 1)
 
#define DUK_BC_TRYCATCH_FLAG_HAVE_CATCH   (1 << 0)
 
#define DUK_BC_TRYCATCH_FLAG_HAVE_FINALLY   (1 << 1)
 
#define DUK_BC_TRYCATCH_FLAG_CATCH_BINDING   (1 << 2)
 
#define DUK_BC_TRYCATCH_FLAG_WITH_BINDING   (1 << 3)
 
#define DUK_BC_RETURN_FLAG_HAVE_RETVAL   (1 << 0)
 
#define DUK_BC_DECLVAR_FLAG_UNDEF_VALUE   (1 << 4) /* use 'undefined' for value automatically */
 
#define DUK_BC_DECLVAR_FLAG_FUNC_DECL   (1 << 5) /* function declaration */
 
#define DUK_BC_REGLIMIT   256 /* if B/C is >= this value, refers to a const */
 
#define DUK_BC_ISREG(x)   ((x) < DUK_BC_REGLIMIT)
 
#define DUK_BC_ISCONST(x)   ((x) >= DUK_BC_REGLIMIT)
 
#define DUK_BC_LDINT_BIAS   (1L << 17)
 
#define DUK_BC_LDINTX_SHIFT   18
 
#define DUK_BC_JUMP_BIAS   (1L << 25)
 
#define DUK_LEXER_H_INCLUDED
 
#define DUK_LEXER_INITCTX(ctx)   duk_lexer_initctx((ctx))
 
#define DUK_LEXER_SETPOINT(ctx, pt)   duk_lexer_setpoint((ctx), (pt))
 
#define DUK_LEXER_GETPOINT(ctx, pt)
 
#define DUK_LEXER_WINDOW_SIZE   6
 
#define DUK_LEXER_BUFFER_SIZE   64
 
#define DUK_TOK_MINVAL   0
 
#define DUK_TOK_EOF   0
 
#define DUK_TOK_IDENTIFIER   1
 
#define DUK_TOK_START_RESERVED   2
 
#define DUK_TOK_BREAK   2
 
#define DUK_TOK_CASE   3
 
#define DUK_TOK_CATCH   4
 
#define DUK_TOK_CONTINUE   5
 
#define DUK_TOK_DEBUGGER   6
 
#define DUK_TOK_DEFAULT   7
 
#define DUK_TOK_DELETE   8
 
#define DUK_TOK_DO   9
 
#define DUK_TOK_ELSE   10
 
#define DUK_TOK_FINALLY   11
 
#define DUK_TOK_FOR   12
 
#define DUK_TOK_FUNCTION   13
 
#define DUK_TOK_IF   14
 
#define DUK_TOK_IN   15
 
#define DUK_TOK_INSTANCEOF   16
 
#define DUK_TOK_NEW   17
 
#define DUK_TOK_RETURN   18
 
#define DUK_TOK_SWITCH   19
 
#define DUK_TOK_THIS   20
 
#define DUK_TOK_THROW   21
 
#define DUK_TOK_TRY   22
 
#define DUK_TOK_TYPEOF   23
 
#define DUK_TOK_VAR   24
 
#define DUK_TOK_CONST   25
 
#define DUK_TOK_VOID   26
 
#define DUK_TOK_WHILE   27
 
#define DUK_TOK_WITH   28
 
#define DUK_TOK_CLASS   29
 
#define DUK_TOK_ENUM   30
 
#define DUK_TOK_EXPORT   31
 
#define DUK_TOK_EXTENDS   32
 
#define DUK_TOK_IMPORT   33
 
#define DUK_TOK_SUPER   34
 
#define DUK_TOK_NULL   35
 
#define DUK_TOK_TRUE   36
 
#define DUK_TOK_FALSE   37
 
#define DUK_TOK_START_STRICT_RESERVED   38 /* inclusive */
 
#define DUK_TOK_IMPLEMENTS   38
 
#define DUK_TOK_INTERFACE   39
 
#define DUK_TOK_LET   40
 
#define DUK_TOK_PACKAGE   41
 
#define DUK_TOK_PRIVATE   42
 
#define DUK_TOK_PROTECTED   43
 
#define DUK_TOK_PUBLIC   44
 
#define DUK_TOK_STATIC   45
 
#define DUK_TOK_YIELD   46
 
#define DUK_TOK_END_RESERVED   47 /* exclusive */
 
#define DUK_TOK_GET   47
 
#define DUK_TOK_SET   48
 
#define DUK_TOK_LCURLY   49
 
#define DUK_TOK_RCURLY   50
 
#define DUK_TOK_LBRACKET   51
 
#define DUK_TOK_RBRACKET   52
 
#define DUK_TOK_LPAREN   53
 
#define DUK_TOK_RPAREN   54
 
#define DUK_TOK_PERIOD   55
 
#define DUK_TOK_SEMICOLON   56
 
#define DUK_TOK_COMMA   57
 
#define DUK_TOK_LT   58
 
#define DUK_TOK_GT   59
 
#define DUK_TOK_LE   60
 
#define DUK_TOK_GE   61
 
#define DUK_TOK_EQ   62
 
#define DUK_TOK_NEQ   63
 
#define DUK_TOK_SEQ   64
 
#define DUK_TOK_SNEQ   65
 
#define DUK_TOK_ADD   66
 
#define DUK_TOK_SUB   67
 
#define DUK_TOK_MUL   68
 
#define DUK_TOK_DIV   69
 
#define DUK_TOK_MOD   70
 
#define DUK_TOK_INCREMENT   71
 
#define DUK_TOK_DECREMENT   72
 
#define DUK_TOK_ALSHIFT   73 /* named "arithmetic" because result is signed */
 
#define DUK_TOK_ARSHIFT   74
 
#define DUK_TOK_RSHIFT   75
 
#define DUK_TOK_BAND   76
 
#define DUK_TOK_BOR   77
 
#define DUK_TOK_BXOR   78
 
#define DUK_TOK_LNOT   79
 
#define DUK_TOK_BNOT   80
 
#define DUK_TOK_LAND   81
 
#define DUK_TOK_LOR   82
 
#define DUK_TOK_QUESTION   83
 
#define DUK_TOK_COLON   84
 
#define DUK_TOK_EQUALSIGN   85
 
#define DUK_TOK_ADD_EQ   86
 
#define DUK_TOK_SUB_EQ   87
 
#define DUK_TOK_MUL_EQ   88
 
#define DUK_TOK_DIV_EQ   89
 
#define DUK_TOK_MOD_EQ   90
 
#define DUK_TOK_ALSHIFT_EQ   91
 
#define DUK_TOK_ARSHIFT_EQ   92
 
#define DUK_TOK_RSHIFT_EQ   93
 
#define DUK_TOK_BAND_EQ   94
 
#define DUK_TOK_BOR_EQ   95
 
#define DUK_TOK_BXOR_EQ   96
 
#define DUK_TOK_NUMBER   97
 
#define DUK_TOK_STRING   98
 
#define DUK_TOK_REGEXP   99
 
#define DUK_TOK_MAXVAL   99 /* inclusive */
 
#define DUK_STRIDX_TO_TOK(x)   ((x) - DUK_STRIDX_START_RESERVED + DUK_TOK_START_RESERVED)
 
#define DUK_RETOK_EOF   0
 
#define DUK_RETOK_DISJUNCTION   1
 
#define DUK_RETOK_QUANTIFIER   2
 
#define DUK_RETOK_ASSERT_START   3
 
#define DUK_RETOK_ASSERT_END   4
 
#define DUK_RETOK_ASSERT_WORD_BOUNDARY   5
 
#define DUK_RETOK_ASSERT_NOT_WORD_BOUNDARY   6
 
#define DUK_RETOK_ASSERT_START_POS_LOOKAHEAD   7
 
#define DUK_RETOK_ASSERT_START_NEG_LOOKAHEAD   8
 
#define DUK_RETOK_ATOM_PERIOD   9
 
#define DUK_RETOK_ATOM_CHAR   10
 
#define DUK_RETOK_ATOM_DIGIT   11
 
#define DUK_RETOK_ATOM_NOT_DIGIT   12
 
#define DUK_RETOK_ATOM_WHITE   13
 
#define DUK_RETOK_ATOM_NOT_WHITE   14
 
#define DUK_RETOK_ATOM_WORD_CHAR   15
 
#define DUK_RETOK_ATOM_NOT_WORD_CHAR   16
 
#define DUK_RETOK_ATOM_BACKREFERENCE   17
 
#define DUK_RETOK_ATOM_START_CAPTURE_GROUP   18
 
#define DUK_RETOK_ATOM_START_NONCAPTURE_GROUP   19
 
#define DUK_RETOK_ATOM_START_CHARCLASS   20
 
#define DUK_RETOK_ATOM_START_CHARCLASS_INVERTED   21
 
#define DUK_RETOK_ATOM_END_GROUP   22
 
#define DUK_LEXER_TEMP_BUF_LIMIT   256
 
#define DUK_RE_QUANTIFIER_INFINITE   ((duk_uint32_t) 0xffffffffUL)
 
#define DUK_JS_COMPILER_H_INCLUDED
 
#define DUK_COMPILER_TOKEN_LIMIT   100000000L /* 1e8: protects against deeply nested inner functions */
 
#define DUK_COMPILER_PEEPHOLE_MAXITER   3
 
#define DUK_COMPILER_MAX_BYTECODE_LENGTH   (256L * 1024L * 1024L) /* 1 GB */
 
#define DUK_IVAL_NONE   0 /* no value */
 
#define DUK_IVAL_PLAIN   1 /* register, constant, or value */
 
#define DUK_IVAL_ARITH   2 /* binary arithmetic; DUK_OP_ADD, DUK_OP_EQ, other binary ops */
 
#define DUK_IVAL_ARITH_EXTRAOP   3 /* binary arithmetic using extraops; DUK_EXTRAOP_INSTOF etc */
 
#define DUK_IVAL_PROP   4 /* property access */
 
#define DUK_IVAL_VAR   5 /* variable access */
 
#define DUK_ISPEC_NONE   0 /* no value */
 
#define DUK_ISPEC_VALUE   1 /* value resides in 'valstack_idx' */
 
#define DUK_ISPEC_REGCONST   2 /* value resides in a register or constant */
 
#define DUK_JS_CONST_MARKER   0x80000000UL
 
#define DUK_LABEL_FLAG_ALLOW_BREAK   (1 << 0)
 
#define DUK_LABEL_FLAG_ALLOW_CONTINUE   (1 << 1)
 
#define DUK_DECL_TYPE_VAR   0
 
#define DUK_DECL_TYPE_FUNC   1
 
#define DUK_JS_COMPILE_FLAG_EVAL   (1 << 0) /* source is eval code (not global) */
 
#define DUK_JS_COMPILE_FLAG_STRICT   (1 << 1) /* strict outer context */
 
#define DUK_JS_COMPILE_FLAG_FUNCEXPR   (1 << 2) /* source is a function expression (used for Function constructor) */
 
#define DUK_REGEXP_H_INCLUDED
 
#define DUK_RE_MAX_ATOM_COPIES   1000
 
#define DUK_RE_COMPILE_TOKEN_LIMIT   100000000L /* 1e8 */
 
#define DUK_RE_EXECUTE_STEPS_LIMIT   1000000000L /* 1e9 */
 
#define DUK_REOP_MATCH   1
 
#define DUK_REOP_CHAR   2
 
#define DUK_REOP_PERIOD   3
 
#define DUK_REOP_RANGES   4
 
#define DUK_REOP_INVRANGES   5
 
#define DUK_REOP_JUMP   6
 
#define DUK_REOP_SPLIT1   7
 
#define DUK_REOP_SPLIT2   8
 
#define DUK_REOP_SQMINIMAL   9
 
#define DUK_REOP_SQGREEDY   10
 
#define DUK_REOP_SAVE   11
 
#define DUK_REOP_WIPERANGE   12
 
#define DUK_REOP_LOOKPOS   13
 
#define DUK_REOP_LOOKNEG   14
 
#define DUK_REOP_BACKREFERENCE   15
 
#define DUK_REOP_ASSERT_START   16
 
#define DUK_REOP_ASSERT_END   17
 
#define DUK_REOP_ASSERT_WORD_BOUNDARY   18
 
#define DUK_REOP_ASSERT_NOT_WORD_BOUNDARY   19
 
#define DUK_RE_FLAG_GLOBAL   (1 << 0)
 
#define DUK_RE_FLAG_IGNORE_CASE   (1 << 1)
 
#define DUK_RE_FLAG_MULTILINE   (1 << 2)
 
#define DUK_HEAPHDR_H_INCLUDED
 
#define DUK_HEAPHDR_FLAGS_TYPE_MASK   0x00000003UL
 
#define DUK_HEAPHDR_FLAGS_FLAG_MASK   (~DUK_HEAPHDR_FLAGS_TYPE_MASK)
 
#define DUK_HEAPHDR_FLAGS_HEAP_START   2 /* 5 heap flags */
 
#define DUK_HEAPHDR_FLAGS_USER_START   7 /* 25 user flags */
 
#define DUK_HEAPHDR_HEAP_FLAG_NUMBER(n)   (DUK_HEAPHDR_FLAGS_HEAP_START + (n))
 
#define DUK_HEAPHDR_USER_FLAG_NUMBER(n)   (DUK_HEAPHDR_FLAGS_USER_START + (n))
 
#define DUK_HEAPHDR_HEAP_FLAG(n)   (1UL << (DUK_HEAPHDR_FLAGS_HEAP_START + (n)))
 
#define DUK_HEAPHDR_USER_FLAG(n)   (1UL << (DUK_HEAPHDR_FLAGS_USER_START + (n)))
 
#define DUK_HEAPHDR_FLAG_REACHABLE   DUK_HEAPHDR_HEAP_FLAG(0) /* mark-and-sweep: reachable */
 
#define DUK_HEAPHDR_FLAG_TEMPROOT   DUK_HEAPHDR_HEAP_FLAG(1) /* mark-and-sweep: children not processed */
 
#define DUK_HEAPHDR_FLAG_FINALIZABLE   DUK_HEAPHDR_HEAP_FLAG(2) /* mark-and-sweep: finalizable (on current pass) */
 
#define DUK_HEAPHDR_FLAG_FINALIZED   DUK_HEAPHDR_HEAP_FLAG(3) /* mark-and-sweep: finalized (on previous pass) */
 
#define DUK_HEAPHDR_FLAG_READONLY   DUK_HEAPHDR_HEAP_FLAG(4) /* read-only object, in code section */
 
#define DUK_HTYPE_MIN   1
 
#define DUK_HTYPE_STRING   1
 
#define DUK_HTYPE_OBJECT   2
 
#define DUK_HTYPE_BUFFER   3
 
#define DUK_HTYPE_MAX   3
 
#define DUK_HEAPHDR_GET_NEXT(heap, h)   ((h)->h_next)
 
#define DUK_HEAPHDR_SET_NEXT(heap, h, val)
 
#define DUK_HEAPHDR_GET_PREV(heap, h)   ((h)->h_prev)
 
#define DUK_HEAPHDR_SET_PREV(heap, h, val)
 
#define DUK_HEAPHDR_GET_REFCOUNT(h)   ((h)->h_refcount)
 
#define DUK_HEAPHDR_SET_REFCOUNT(h, val)
 
#define DUK_HEAPHDR_PREINC_REFCOUNT(h)   (++(h)->h_refcount) /* result: updated refcount */
 
#define DUK_HEAPHDR_PREDEC_REFCOUNT(h)   (--(h)->h_refcount) /* result: updated refcount */
 
#define DUK_HEAPHDR_GET_FLAGS_RAW(h)   ((h)->h_flags)
 
#define DUK_HEAPHDR_GET_FLAGS(h)   ((h)->h_flags & DUK_HEAPHDR_FLAGS_FLAG_MASK)
 
#define DUK_HEAPHDR_SET_FLAGS(h, val)
 
#define DUK_HEAPHDR_GET_TYPE(h)   ((h)->h_flags & DUK_HEAPHDR_FLAGS_TYPE_MASK)
 
#define DUK_HEAPHDR_SET_TYPE(h, val)
 
#define DUK_HEAPHDR_HTYPE_VALID(h)
 
#define DUK_HEAPHDR_SET_TYPE_AND_FLAGS(h, tval, fval)
 
#define DUK_HEAPHDR_SET_FLAG_BITS(h, bits)
 
#define DUK_HEAPHDR_CLEAR_FLAG_BITS(h, bits)
 
#define DUK_HEAPHDR_CHECK_FLAG_BITS(h, bits)   (((h)->h_flags & (bits)) != 0)
 
#define DUK_HEAPHDR_SET_REACHABLE(h)   DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_REACHABLE)
 
#define DUK_HEAPHDR_CLEAR_REACHABLE(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_REACHABLE)
 
#define DUK_HEAPHDR_HAS_REACHABLE(h)   DUK_HEAPHDR_CHECK_FLAG_BITS((h),DUK_HEAPHDR_FLAG_REACHABLE)
 
#define DUK_HEAPHDR_SET_TEMPROOT(h)   DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_TEMPROOT)
 
#define DUK_HEAPHDR_CLEAR_TEMPROOT(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_TEMPROOT)
 
#define DUK_HEAPHDR_HAS_TEMPROOT(h)   DUK_HEAPHDR_CHECK_FLAG_BITS((h),DUK_HEAPHDR_FLAG_TEMPROOT)
 
#define DUK_HEAPHDR_SET_FINALIZABLE(h)   DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZABLE)
 
#define DUK_HEAPHDR_CLEAR_FINALIZABLE(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZABLE)
 
#define DUK_HEAPHDR_HAS_FINALIZABLE(h)   DUK_HEAPHDR_CHECK_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZABLE)
 
#define DUK_HEAPHDR_SET_FINALIZED(h)   DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZED)
 
#define DUK_HEAPHDR_CLEAR_FINALIZED(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZED)
 
#define DUK_HEAPHDR_HAS_FINALIZED(h)   DUK_HEAPHDR_CHECK_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZED)
 
#define DUK_HEAPHDR_SET_READONLY(h)   DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_READONLY)
 
#define DUK_HEAPHDR_CLEAR_READONLY(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_READONLY)
 
#define DUK_HEAPHDR_HAS_READONLY(h)   DUK_HEAPHDR_CHECK_FLAG_BITS((h),DUK_HEAPHDR_FLAG_READONLY)
 
#define DUK_HEAPHDR_GET_FLAG_RANGE(h, m, n)   (((h)->h_flags >> (m)) & ((1UL << (n)) - 1UL))
 
#define DUK_HEAPHDR_SET_FLAG_RANGE(h, m, n, v)
 
#define DUK_HEAPHDR_INIT_NULLS(h)
 
#define DUK_HEAPHDR_STRING_INIT_NULLS(h)   /* currently nop */
 
#define DUK_ASSERT_HEAPHDR_LINKS(heap, h)   do {} while (0)
 
#define DUK_TVAL_NEEDS_REFCOUNT_UPDATE(tv)   DUK_TVAL_IS_HEAP_ALLOCATED((tv))
 
#define DUK_HEAPHDR_NEEDS_REFCOUNT_UPDATE(h)   1
 
#define DUK_TVAL_INCREF_FAST(thr, tv)
 
#define DUK_TVAL_DECREF_FAST(thr, tv)
 
#define DUK_HEAPHDR_INCREF_FAST(thr, h)
 
#define DUK_HEAPHDR_DECREF_FAST(thr, h)
 
#define DUK_TVAL_INCREF_SLOW(thr, tv)
 
#define DUK_TVAL_DECREF_SLOW(thr, tv)
 
#define DUK_HEAPHDR_INCREF_SLOW(thr, h)
 
#define DUK_HEAPHDR_DECREF_SLOW(thr, h)
 
#define DUK_TVAL_INCREF(thr, tv)   DUK_TVAL_INCREF_FAST((thr),(tv))
 
#define DUK_TVAL_DECREF(thr, tv)   DUK_TVAL_DECREF_FAST((thr),(tv))
 
#define DUK_HEAPHDR_INCREF(thr, h)   DUK_HEAPHDR_INCREF_FAST((thr),(h))
 
#define DUK_HEAPHDR_DECREF(thr, h)   DUK_HEAPHDR_DECREF_FAST((thr),(h))
 
#define DUK_HSTRING_INCREF(thr, h)   DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))
 
#define DUK_HSTRING_DECREF(thr, h)   DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) (h))
 
#define DUK_HOBJECT_INCREF(thr, h)   DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))
 
#define DUK_HOBJECT_DECREF(thr, h)   DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) (h))
 
#define DUK_HBUFFER_INCREF(thr, h)   DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))
 
#define DUK_HBUFFER_DECREF(thr, h)   DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) (h))
 
#define DUK_HCOMPILEDFUNCTION_INCREF(thr, h)   DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)
 
#define DUK_HCOMPILEDFUNCTION_DECREF(thr, h)   DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) &(h)->obj)
 
#define DUK_HNATIVEFUNCTION_INCREF(thr, h)   DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)
 
#define DUK_HNATIVEFUNCTION_DECREF(thr, h)   DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) &(h)->obj)
 
#define DUK_HBUFFEROBJECT_INCREF(thr, h)   DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)
 
#define DUK_HBUFFEROBJECT_DECREF(thr, h)   DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) &(h)->obj)
 
#define DUK_HTHREAD_INCREF(thr, h)   DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)
 
#define DUK_HTHREAD_DECREF(thr, h)   DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) &(h)->obj)
 
#define DUK_HOBJECT_INCREF_ALLOWNULL(thr, h)
 
#define DUK_HOBJECT_DECREF_ALLOWNULL(thr, h)
 
#define DUK_TVAL_SET_UNDEFINED_UPDREF_ALT0(thr, tvptr_dst)
 
#define DUK_TVAL_SET_UNUSED_UPDREF_ALT0(thr, tvptr_dst)
 
#define DUK_TVAL_SET_NULL_UPDREF_ALT0(thr, tvptr_dst)
 
#define DUK_TVAL_SET_BOOLEAN_UPDREF_ALT0(thr, tvptr_dst, newval)
 
#define DUK_TVAL_SET_NUMBER_UPDREF_ALT0(thr, tvptr_dst, newval)
 
#define DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF_ALT0(thr, tvptr_dst, newval)
 
#define DUK_TVAL_SET_DOUBLE_UPDREF_ALT0(thr, tvptr_dst, newval)
 
#define DUK_TVAL_SET_NAN_UPDREF_ALT0(thr, tvptr_dst)
 
#define DUK_TVAL_SET_DOUBLE_CAST_UPDREF(thr, tvptr_dst, newval)    DUK_TVAL_SET_DOUBLE_UPDREF((thr), (tvptr_dst), (duk_double_t) (newval))
 
#define DUK_TVAL_SET_LIGHTFUNC_UPDREF_ALT0(thr, tvptr_dst, lf_v, lf_fp, lf_flags)
 
#define DUK_TVAL_SET_STRING_UPDREF_ALT0(thr, tvptr_dst, newval)
 
#define DUK_TVAL_SET_OBJECT_UPDREF_ALT0(thr, tvptr_dst, newval)
 
#define DUK_TVAL_SET_BUFFER_UPDREF_ALT0(thr, tvptr_dst, newval)
 
#define DUK_TVAL_SET_POINTER_UPDREF_ALT0(thr, tvptr_dst, newval)
 
#define DUK_TVAL_SET_TVAL_UPDREF_ALT0(thr, tvptr_dst, tvptr_src)
 
#define DUK_TVAL_SET_TVAL_UPDREF_ALT1(thr, tvptr_dst, tvptr_src)
 
#define DUK_TVAL_SET_UNDEFINED_UPDREF   DUK_TVAL_SET_UNDEFINED_UPDREF_ALT0
 
#define DUK_TVAL_SET_UNUSED_UPDREF   DUK_TVAL_SET_UNUSED_UPDREF_ALT0
 
#define DUK_TVAL_SET_NULL_UPDREF   DUK_TVAL_SET_NULL_UPDREF_ALT0
 
#define DUK_TVAL_SET_BOOLEAN_UPDREF   DUK_TVAL_SET_BOOLEAN_UPDREF_ALT0
 
#define DUK_TVAL_SET_NUMBER_UPDREF   DUK_TVAL_SET_NUMBER_UPDREF_ALT0
 
#define DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF   DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF_ALT0
 
#define DUK_TVAL_SET_DOUBLE_UPDREF   DUK_TVAL_SET_DOUBLE_UPDREF_ALT0
 
#define DUK_TVAL_SET_NAN_UPDREF   DUK_TVAL_SET_NAN_UPDREF_ALT0
 
#define DUK_TVAL_SET_FASTINT_UPDREF   DUK_TVAL_SET_DOUBLE_CAST_UPDREF /* XXX: fast int-to-double */
 
#define DUK_TVAL_SET_FASTINT_I32_UPDREF   DUK_TVAL_SET_DOUBLE_CAST_UPDREF
 
#define DUK_TVAL_SET_FASTINT_U32_UPDREF   DUK_TVAL_SET_DOUBLE_CAST_UPDREF
 
#define DUK_TVAL_SET_LIGHTFUNC_UPDREF   DUK_TVAL_SET_LIGHTFUNC_UPDREF_ALT0
 
#define DUK_TVAL_SET_STRING_UPDREF   DUK_TVAL_SET_STRING_UPDREF_ALT0
 
#define DUK_TVAL_SET_OBJECT_UPDREF   DUK_TVAL_SET_OBJECT_UPDREF_ALT0
 
#define DUK_TVAL_SET_BUFFER_UPDREF   DUK_TVAL_SET_BUFFER_UPDREF_ALT0
 
#define DUK_TVAL_SET_POINTER_UPDREF   DUK_TVAL_SET_POINTER_UPDREF_ALT0
 
#define DUK_TVAL_SET_TVAL_UPDREF   DUK_TVAL_SET_TVAL_UPDREF_ALT1
 
#define DUK_TVAL_SET_TVAL_UPDREF_FAST   DUK_TVAL_SET_TVAL_UPDREF_ALT1
 
#define DUK_TVAL_SET_TVAL_UPDREF_SLOW   DUK_TVAL_SET_TVAL_UPDREF_ALT0
 
#define DUK_API_INTERNAL_H_INCLUDED
 
#define DUK_PUSH_SPRINTF_INITIAL_SIZE   256L
 
#define DUK_PUSH_SPRINTF_SANITY_LIMIT   (1L * 1024L * 1024L * 1024L)
 
#define DUK_ERRCODE_FLAG_NOBLAME_FILELINE   (1L << 24)
 
#define DUK_VSRESIZE_FLAG_SHRINK   (1 << 0)
 
#define DUK_VSRESIZE_FLAG_COMPACT   (1 << 1)
 
#define DUK_VSRESIZE_FLAG_THROW   (1 << 2)
 
#define duk_push_u64(ctx, val)    duk_push_number((ctx), (duk_double_t) (val))
 
#define duk_push_i64(ctx, val)    duk_push_number((ctx), (duk_double_t) (val))
 
#define duk_push_u32(ctx, val)    duk_push_uint((ctx), (duk_uint_t) (val))
 
#define duk_push_i32(ctx, val)    duk_push_int((ctx), (duk_int_t) (val))
 
#define duk_push_idx(ctx, val)    duk_push_int((ctx), (duk_int_t) (val))
 
#define duk_push_uarridx(ctx, val)    duk_push_uint((ctx), (duk_uint_t) (val))
 
#define duk_push_size_t(ctx, val)    duk_push_uint((ctx), (duk_uint_t) (val)) /* XXX: assumed to fit for now */
 
#define duk_push_hthread(ctx, h)    duk_push_hobject((ctx), (duk_hobject *) (h))
 
#define duk_push_hcompiledfunction(ctx, h)    duk_push_hobject((ctx), (duk_hobject *) (h))
 
#define duk_push_hnativefunction(ctx, h)    duk_push_hobject((ctx), (duk_hobject *) (h))
 
#define duk_xdef_prop_wec(ctx, obj_index)    duk_xdef_prop((ctx), (obj_index), DUK_PROPDESC_FLAGS_WEC)
 
#define duk_xdef_prop_index_wec(ctx, obj_index, arr_index)    duk_xdef_prop_index((ctx), (obj_index), (arr_index), DUK_PROPDESC_FLAGS_WEC)
 
#define duk_xdef_prop_stridx_wec(ctx, obj_index, stridx)    duk_xdef_prop_stridx((ctx), (obj_index), (stridx), DUK_PROPDESC_FLAGS_WEC)
 
#define DUK_ASSERT_VALID_NEGIDX(ctx, idx)    (DUK_ASSERT_EXPR((idx) < 0), DUK_ASSERT_EXPR(duk_is_valid_index((ctx), (idx))))
 
#define DUK_ASSERT_VALID_POSIDX(ctx, idx)    (DUK_ASSERT_EXPR((idx) >= 0), DUK_ASSERT_EXPR(duk_is_valid_index((ctx), (idx))))
 
#define DUK_GET_TVAL_NEGIDX(ctx, idx)    (DUK_ASSERT_VALID_NEGIDX((ctx),(idx)), ((duk_hthread *) (ctx))->valstack_top + (idx))
 
#define DUK_GET_TVAL_POSIDX(ctx, idx)    (DUK_ASSERT_VALID_POSIDX((ctx),(idx)), ((duk_hthread *) (ctx))->valstack_bottom + (idx))
 
#define DUK_GET_HOBJECT_NEGIDX(ctx, idx)    (DUK_ASSERT_VALID_NEGIDX((ctx),(idx)), DUK_TVAL_GET_OBJECT(((duk_hthread *) (ctx))->valstack_top + (idx)))
 
#define DUK_GET_HOBJECT_POSIDX(ctx, idx)    (DUK_ASSERT_VALID_POSIDX((ctx),(idx)), DUK_TVAL_GET_OBJECT(((duk_hthread *) (ctx))->valstack_bottom + (idx)))
 
#define DUK_HSTRING_H_INCLUDED
 
#define DUK_HSTRING_MAX_BYTELEN   (0x7fffffffUL)
 
#define DUK_HSTRING_FLAG_ASCII   DUK_HEAPHDR_USER_FLAG(0) /* string is ASCII, clen == blen */
 
#define DUK_HSTRING_FLAG_ARRIDX   DUK_HEAPHDR_USER_FLAG(1) /* string is a valid array index */
 
#define DUK_HSTRING_FLAG_INTERNAL   DUK_HEAPHDR_USER_FLAG(2) /* string is internal */
 
#define DUK_HSTRING_FLAG_RESERVED_WORD   DUK_HEAPHDR_USER_FLAG(3) /* string is a reserved word (non-strict) */
 
#define DUK_HSTRING_FLAG_STRICT_RESERVED_WORD   DUK_HEAPHDR_USER_FLAG(4) /* string is a reserved word (strict) */
 
#define DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS   DUK_HEAPHDR_USER_FLAG(5) /* string is 'eval' or 'arguments' */
 
#define DUK_HSTRING_FLAG_EXTDATA   DUK_HEAPHDR_USER_FLAG(6) /* string data is external (duk_hstring_external) */
 
#define DUK_HSTRING_HAS_ASCII(x)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII)
 
#define DUK_HSTRING_HAS_ARRIDX(x)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX)
 
#define DUK_HSTRING_HAS_INTERNAL(x)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_INTERNAL)
 
#define DUK_HSTRING_HAS_RESERVED_WORD(x)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_RESERVED_WORD)
 
#define DUK_HSTRING_HAS_STRICT_RESERVED_WORD(x)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD)
 
#define DUK_HSTRING_HAS_EVAL_OR_ARGUMENTS(x)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS)
 
#define DUK_HSTRING_HAS_EXTDATA(x)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA)
 
#define DUK_HSTRING_SET_ASCII(x)   DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII)
 
#define DUK_HSTRING_SET_ARRIDX(x)   DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX)
 
#define DUK_HSTRING_SET_INTERNAL(x)   DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_INTERNAL)
 
#define DUK_HSTRING_SET_RESERVED_WORD(x)   DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_RESERVED_WORD)
 
#define DUK_HSTRING_SET_STRICT_RESERVED_WORD(x)   DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD)
 
#define DUK_HSTRING_SET_EVAL_OR_ARGUMENTS(x)   DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS)
 
#define DUK_HSTRING_SET_EXTDATA(x)   DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA)
 
#define DUK_HSTRING_CLEAR_ASCII(x)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII)
 
#define DUK_HSTRING_CLEAR_ARRIDX(x)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX)
 
#define DUK_HSTRING_CLEAR_INTERNAL(x)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_INTERNAL)
 
#define DUK_HSTRING_CLEAR_RESERVED_WORD(x)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_RESERVED_WORD)
 
#define DUK_HSTRING_CLEAR_STRICT_RESERVED_WORD(x)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD)
 
#define DUK_HSTRING_CLEAR_EVAL_OR_ARGUMENTS(x)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS)
 
#define DUK_HSTRING_CLEAR_EXTDATA(x)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA)
 
#define DUK_HSTRING_IS_ASCII(x)   DUK_HSTRING_HAS_ASCII((x))
 
#define DUK_HSTRING_IS_EMPTY(x)   (DUK_HSTRING_GET_BYTELEN((x)) == 0)
 
#define DUK_HSTRING_GET_HASH(x)   ((x)->hash)
 
#define DUK_HSTRING_SET_HASH(x, v)
 
#define DUK_HSTRING_GET_BYTELEN(x)   ((x)->blen)
 
#define DUK_HSTRING_SET_BYTELEN(x, v)
 
#define DUK_HSTRING_GET_CHARLEN(x)   ((x)->clen)
 
#define DUK_HSTRING_SET_CHARLEN(x, v)
 
#define DUK_HSTRING_GET_DATA(x)    ((const duk_uint8_t *) ((x) + 1))
 
#define DUK_HSTRING_GET_DATA_END(x)    (DUK_HSTRING_GET_DATA((x)) + (x)->blen)
 
#define DUK_HSTRING_NO_ARRAY_INDEX   (0xffffffffUL)
 
#define DUK_HSTRING_GET_ARRIDX_FAST(h)    (DUK_HSTRING_HAS_ARRIDX((h)) ? duk_js_to_arrayindex_string_helper((h)) : DUK_HSTRING_NO_ARRAY_INDEX)
 
#define DUK_HSTRING_GET_ARRIDX_SLOW(h)    (duk_js_to_arrayindex_string_helper((h)))
 
#define DUK_HOBJECT_H_INCLUDED
 
#define DUK_HOBJECT_FLAG_EXTENSIBLE   DUK_HEAPHDR_USER_FLAG(0) /* object is extensible */
 
#define DUK_HOBJECT_FLAG_CONSTRUCTABLE   DUK_HEAPHDR_USER_FLAG(1) /* object is constructable */
 
#define DUK_HOBJECT_FLAG_BOUND   DUK_HEAPHDR_USER_FLAG(2) /* object established using Function.prototype.bind() */
 
#define DUK_HOBJECT_FLAG_COMPILEDFUNCTION   DUK_HEAPHDR_USER_FLAG(4) /* object is a compiled function (duk_hcompiledfunction) */
 
#define DUK_HOBJECT_FLAG_NATIVEFUNCTION   DUK_HEAPHDR_USER_FLAG(5) /* object is a native function (duk_hnativefunction) */
 
#define DUK_HOBJECT_FLAG_BUFFEROBJECT   DUK_HEAPHDR_USER_FLAG(6) /* object is a buffer object (duk_hbufferobject) (always exotic) */
 
#define DUK_HOBJECT_FLAG_THREAD   DUK_HEAPHDR_USER_FLAG(7) /* object is a thread (duk_hthread) */
 
#define DUK_HOBJECT_FLAG_ARRAY_PART   DUK_HEAPHDR_USER_FLAG(8) /* object has an array part (a_size may still be 0) */
 
#define DUK_HOBJECT_FLAG_STRICT   DUK_HEAPHDR_USER_FLAG(9) /* function: function object is strict */
 
#define DUK_HOBJECT_FLAG_NOTAIL   DUK_HEAPHDR_USER_FLAG(10) /* function: function must not be tail called */
 
#define DUK_HOBJECT_FLAG_NEWENV   DUK_HEAPHDR_USER_FLAG(11) /* function: create new environment when called (see duk_hcompiledfunction) */
 
#define DUK_HOBJECT_FLAG_NAMEBINDING   DUK_HEAPHDR_USER_FLAG(12) /* function: create binding for func name (function templates only, used for named function expressions) */
 
#define DUK_HOBJECT_FLAG_CREATEARGS   DUK_HEAPHDR_USER_FLAG(13) /* function: create an arguments object on function call */
 
#define DUK_HOBJECT_FLAG_ENVRECCLOSED   DUK_HEAPHDR_USER_FLAG(14) /* envrec: (declarative) record is closed */
 
#define DUK_HOBJECT_FLAG_EXOTIC_ARRAY   DUK_HEAPHDR_USER_FLAG(15) /* 'Array' object, array length and index exotic behavior */
 
#define DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ   DUK_HEAPHDR_USER_FLAG(16) /* 'String' object, array index exotic behavior */
 
#define DUK_HOBJECT_FLAG_EXOTIC_ARGUMENTS   DUK_HEAPHDR_USER_FLAG(17) /* 'Arguments' object and has arguments exotic behavior (non-strict callee) */
 
#define DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC   DUK_HEAPHDR_USER_FLAG(18) /* Duktape/C (nativefunction) object, exotic 'length' */
 
#define DUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ   DUK_HEAPHDR_USER_FLAG(19) /* 'Proxy' object */
 
#define DUK_HOBJECT_FLAG_CLASS_BASE   DUK_HEAPHDR_USER_FLAG_NUMBER(20)
 
#define DUK_HOBJECT_FLAG_CLASS_BITS   5
 
#define DUK_HOBJECT_GET_CLASS_NUMBER(h)    DUK_HEAPHDR_GET_FLAG_RANGE(&(h)->hdr, DUK_HOBJECT_FLAG_CLASS_BASE, DUK_HOBJECT_FLAG_CLASS_BITS)
 
#define DUK_HOBJECT_SET_CLASS_NUMBER(h, v)    DUK_HEAPHDR_SET_FLAG_RANGE(&(h)->hdr, DUK_HOBJECT_FLAG_CLASS_BASE, DUK_HOBJECT_FLAG_CLASS_BITS, (v))
 
#define DUK_HOBJECT_GET_CLASS_MASK(h)    (1UL << DUK_HEAPHDR_GET_FLAG_RANGE(&(h)->hdr, DUK_HOBJECT_FLAG_CLASS_BASE, DUK_HOBJECT_FLAG_CLASS_BITS))
 
#define DUK_HOBJECT_CLASS_AS_FLAGS(v)   (((duk_uint_t) (v)) << DUK_HOBJECT_FLAG_CLASS_BASE)
 
#define DUK_HOBJECT_CLASS_UNUSED   0
 
#define DUK_HOBJECT_CLASS_ARGUMENTS   1
 
#define DUK_HOBJECT_CLASS_ARRAY   2
 
#define DUK_HOBJECT_CLASS_BOOLEAN   3
 
#define DUK_HOBJECT_CLASS_DATE   4
 
#define DUK_HOBJECT_CLASS_ERROR   5
 
#define DUK_HOBJECT_CLASS_FUNCTION   6
 
#define DUK_HOBJECT_CLASS_JSON   7
 
#define DUK_HOBJECT_CLASS_MATH   8
 
#define DUK_HOBJECT_CLASS_NUMBER   9
 
#define DUK_HOBJECT_CLASS_OBJECT   10
 
#define DUK_HOBJECT_CLASS_REGEXP   11
 
#define DUK_HOBJECT_CLASS_STRING   12
 
#define DUK_HOBJECT_CLASS_GLOBAL   13
 
#define DUK_HOBJECT_CLASS_OBJENV   14 /* custom */
 
#define DUK_HOBJECT_CLASS_DECENV   15 /* custom */
 
#define DUK_HOBJECT_CLASS_BUFFER   16 /* custom; implies DUK_HOBJECT_IS_BUFFEROBJECT */
 
#define DUK_HOBJECT_CLASS_POINTER   17 /* custom */
 
#define DUK_HOBJECT_CLASS_THREAD   18 /* custom; implies DUK_HOBJECT_IS_THREAD */
 
#define DUK_HOBJECT_CLASS_ARRAYBUFFER   19 /* implies DUK_HOBJECT_IS_BUFFEROBJECT */
 
#define DUK_HOBJECT_CLASS_DATAVIEW   20
 
#define DUK_HOBJECT_CLASS_INT8ARRAY   21
 
#define DUK_HOBJECT_CLASS_UINT8ARRAY   22
 
#define DUK_HOBJECT_CLASS_UINT8CLAMPEDARRAY   23
 
#define DUK_HOBJECT_CLASS_INT16ARRAY   24
 
#define DUK_HOBJECT_CLASS_UINT16ARRAY   25
 
#define DUK_HOBJECT_CLASS_INT32ARRAY   26
 
#define DUK_HOBJECT_CLASS_UINT32ARRAY   27
 
#define DUK_HOBJECT_CLASS_FLOAT32ARRAY   28
 
#define DUK_HOBJECT_CLASS_FLOAT64ARRAY   29
 
#define DUK_HOBJECT_CLASS_MAX   29
 
#define DUK_HOBJECT_CMASK_ALL   ((1UL << (DUK_HOBJECT_CLASS_MAX + 1)) - 1UL)
 
#define DUK_HOBJECT_CMASK_UNUSED   (1UL << DUK_HOBJECT_CLASS_UNUSED)
 
#define DUK_HOBJECT_CMASK_ARGUMENTS   (1UL << DUK_HOBJECT_CLASS_ARGUMENTS)
 
#define DUK_HOBJECT_CMASK_ARRAY   (1UL << DUK_HOBJECT_CLASS_ARRAY)
 
#define DUK_HOBJECT_CMASK_BOOLEAN   (1UL << DUK_HOBJECT_CLASS_BOOLEAN)
 
#define DUK_HOBJECT_CMASK_DATE   (1UL << DUK_HOBJECT_CLASS_DATE)
 
#define DUK_HOBJECT_CMASK_ERROR   (1UL << DUK_HOBJECT_CLASS_ERROR)
 
#define DUK_HOBJECT_CMASK_FUNCTION   (1UL << DUK_HOBJECT_CLASS_FUNCTION)
 
#define DUK_HOBJECT_CMASK_JSON   (1UL << DUK_HOBJECT_CLASS_JSON)
 
#define DUK_HOBJECT_CMASK_MATH   (1UL << DUK_HOBJECT_CLASS_MATH)
 
#define DUK_HOBJECT_CMASK_NUMBER   (1UL << DUK_HOBJECT_CLASS_NUMBER)
 
#define DUK_HOBJECT_CMASK_OBJECT   (1UL << DUK_HOBJECT_CLASS_OBJECT)
 
#define DUK_HOBJECT_CMASK_REGEXP   (1UL << DUK_HOBJECT_CLASS_REGEXP)
 
#define DUK_HOBJECT_CMASK_STRING   (1UL << DUK_HOBJECT_CLASS_STRING)
 
#define DUK_HOBJECT_CMASK_GLOBAL   (1UL << DUK_HOBJECT_CLASS_GLOBAL)
 
#define DUK_HOBJECT_CMASK_OBJENV   (1UL << DUK_HOBJECT_CLASS_OBJENV)
 
#define DUK_HOBJECT_CMASK_DECENV   (1UL << DUK_HOBJECT_CLASS_DECENV)
 
#define DUK_HOBJECT_CMASK_BUFFER   (1UL << DUK_HOBJECT_CLASS_BUFFER)
 
#define DUK_HOBJECT_CMASK_POINTER   (1UL << DUK_HOBJECT_CLASS_POINTER)
 
#define DUK_HOBJECT_CMASK_THREAD   (1UL << DUK_HOBJECT_CLASS_THREAD)
 
#define DUK_HOBJECT_CMASK_ARRAYBUFFER   (1UL << DUK_HOBJECT_CLASS_ARRAYBUFFER)
 
#define DUK_HOBJECT_CMASK_DATAVIEW   (1UL << DUK_HOBJECT_CLASS_DATAVIEW)
 
#define DUK_HOBJECT_CMASK_INT8ARRAY   (1UL << DUK_HOBJECT_CLASS_INT8ARRAY)
 
#define DUK_HOBJECT_CMASK_UINT8ARRAY   (1UL << DUK_HOBJECT_CLASS_UINT8ARRAY)
 
#define DUK_HOBJECT_CMASK_UINT8CLAMPEDARRAY   (1UL << DUK_HOBJECT_CLASS_UINT8CLAMPEDARRAY)
 
#define DUK_HOBJECT_CMASK_INT16ARRAY   (1UL << DUK_HOBJECT_CLASS_INT16ARRAY)
 
#define DUK_HOBJECT_CMASK_UINT16ARRAY   (1UL << DUK_HOBJECT_CLASS_UINT16ARRAY)
 
#define DUK_HOBJECT_CMASK_INT32ARRAY   (1UL << DUK_HOBJECT_CLASS_INT32ARRAY)
 
#define DUK_HOBJECT_CMASK_UINT32ARRAY   (1UL << DUK_HOBJECT_CLASS_UINT32ARRAY)
 
#define DUK_HOBJECT_CMASK_FLOAT32ARRAY   (1UL << DUK_HOBJECT_CLASS_FLOAT32ARRAY)
 
#define DUK_HOBJECT_CMASK_FLOAT64ARRAY   (1UL << DUK_HOBJECT_CLASS_FLOAT64ARRAY)
 
#define DUK_HOBJECT_CMASK_ALL_BUFFEROBJECTS
 
#define DUK_HOBJECT_IS_OBJENV(h)   (DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_OBJENV)
 
#define DUK_HOBJECT_IS_DECENV(h)   (DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_DECENV)
 
#define DUK_HOBJECT_IS_ENV(h)   (DUK_HOBJECT_IS_OBJENV((h)) || DUK_HOBJECT_IS_DECENV((h)))
 
#define DUK_HOBJECT_IS_ARRAY(h)   (DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_ARRAY)
 
#define DUK_HOBJECT_IS_COMPILEDFUNCTION(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_COMPILEDFUNCTION)
 
#define DUK_HOBJECT_IS_NATIVEFUNCTION(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NATIVEFUNCTION)
 
#define DUK_HOBJECT_IS_BUFFEROBJECT(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BUFFEROBJECT)
 
#define DUK_HOBJECT_IS_THREAD(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_THREAD)
 
#define DUK_HOBJECT_IS_NONBOUND_FUNCTION(h)
 
#define DUK_HOBJECT_IS_FUNCTION(h)
 
#define DUK_HOBJECT_IS_CALLABLE(h)
 
#define DUK_HOBJECT_EXOTIC_BEHAVIOR_FLAGS
 
#define DUK_HOBJECT_HAS_EXOTIC_BEHAVIOR(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_EXOTIC_BEHAVIOR_FLAGS)
 
#define DUK_HOBJECT_HAS_EXTENSIBLE(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXTENSIBLE)
 
#define DUK_HOBJECT_HAS_CONSTRUCTABLE(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_CONSTRUCTABLE)
 
#define DUK_HOBJECT_HAS_BOUND(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BOUND)
 
#define DUK_HOBJECT_HAS_COMPILEDFUNCTION(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_COMPILEDFUNCTION)
 
#define DUK_HOBJECT_HAS_NATIVEFUNCTION(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NATIVEFUNCTION)
 
#define DUK_HOBJECT_HAS_BUFFEROBJECT(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BUFFEROBJECT)
 
#define DUK_HOBJECT_HAS_THREAD(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_THREAD)
 
#define DUK_HOBJECT_HAS_ARRAY_PART(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_ARRAY_PART)
 
#define DUK_HOBJECT_HAS_STRICT(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_STRICT)
 
#define DUK_HOBJECT_HAS_NOTAIL(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NOTAIL)
 
#define DUK_HOBJECT_HAS_NEWENV(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NEWENV)
 
#define DUK_HOBJECT_HAS_NAMEBINDING(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NAMEBINDING)
 
#define DUK_HOBJECT_HAS_CREATEARGS(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_CREATEARGS)
 
#define DUK_HOBJECT_HAS_ENVRECCLOSED(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_ENVRECCLOSED)
 
#define DUK_HOBJECT_HAS_EXOTIC_ARRAY(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_ARRAY)
 
#define DUK_HOBJECT_HAS_EXOTIC_STRINGOBJ(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ)
 
#define DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_ARGUMENTS)
 
#define DUK_HOBJECT_HAS_EXOTIC_DUKFUNC(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC)
 
#define DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(h)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ)
 
#define DUK_HOBJECT_SET_EXTENSIBLE(h)   DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXTENSIBLE)
 
#define DUK_HOBJECT_SET_CONSTRUCTABLE(h)   DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_CONSTRUCTABLE)
 
#define DUK_HOBJECT_SET_BOUND(h)   DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BOUND)
 
#define DUK_HOBJECT_SET_COMPILEDFUNCTION(h)   DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_COMPILEDFUNCTION)
 
#define DUK_HOBJECT_SET_NATIVEFUNCTION(h)   DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NATIVEFUNCTION)
 
#define DUK_HOBJECT_SET_BUFFEROBJECT(h)   DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BUFFEROBJECT)
 
#define DUK_HOBJECT_SET_THREAD(h)   DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_THREAD)
 
#define DUK_HOBJECT_SET_ARRAY_PART(h)   DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_ARRAY_PART)
 
#define DUK_HOBJECT_SET_STRICT(h)   DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_STRICT)
 
#define DUK_HOBJECT_SET_NOTAIL(h)   DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NOTAIL)
 
#define DUK_HOBJECT_SET_NEWENV(h)   DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NEWENV)
 
#define DUK_HOBJECT_SET_NAMEBINDING(h)   DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NAMEBINDING)
 
#define DUK_HOBJECT_SET_CREATEARGS(h)   DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_CREATEARGS)
 
#define DUK_HOBJECT_SET_ENVRECCLOSED(h)   DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_ENVRECCLOSED)
 
#define DUK_HOBJECT_SET_EXOTIC_ARRAY(h)   DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_ARRAY)
 
#define DUK_HOBJECT_SET_EXOTIC_STRINGOBJ(h)   DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ)
 
#define DUK_HOBJECT_SET_EXOTIC_ARGUMENTS(h)   DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_ARGUMENTS)
 
#define DUK_HOBJECT_SET_EXOTIC_DUKFUNC(h)   DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC)
 
#define DUK_HOBJECT_SET_EXOTIC_PROXYOBJ(h)   DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ)
 
#define DUK_HOBJECT_CLEAR_EXTENSIBLE(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXTENSIBLE)
 
#define DUK_HOBJECT_CLEAR_CONSTRUCTABLE(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_CONSTRUCTABLE)
 
#define DUK_HOBJECT_CLEAR_BOUND(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BOUND)
 
#define DUK_HOBJECT_CLEAR_COMPILEDFUNCTION(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_COMPILEDFUNCTION)
 
#define DUK_HOBJECT_CLEAR_NATIVEFUNCTION(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NATIVEFUNCTION)
 
#define DUK_HOBJECT_CLEAR_BUFFEROBJECT(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BUFFEROBJECT)
 
#define DUK_HOBJECT_CLEAR_THREAD(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_THREAD)
 
#define DUK_HOBJECT_CLEAR_ARRAY_PART(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_ARRAY_PART)
 
#define DUK_HOBJECT_CLEAR_STRICT(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_STRICT)
 
#define DUK_HOBJECT_CLEAR_NOTAIL(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NOTAIL)
 
#define DUK_HOBJECT_CLEAR_NEWENV(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NEWENV)
 
#define DUK_HOBJECT_CLEAR_NAMEBINDING(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NAMEBINDING)
 
#define DUK_HOBJECT_CLEAR_CREATEARGS(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_CREATEARGS)
 
#define DUK_HOBJECT_CLEAR_ENVRECCLOSED(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_ENVRECCLOSED)
 
#define DUK_HOBJECT_CLEAR_EXOTIC_ARRAY(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_ARRAY)
 
#define DUK_HOBJECT_CLEAR_EXOTIC_STRINGOBJ(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ)
 
#define DUK_HOBJECT_CLEAR_EXOTIC_ARGUMENTS(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_ARGUMENTS)
 
#define DUK_HOBJECT_CLEAR_EXOTIC_DUKFUNC(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC)
 
#define DUK_HOBJECT_CLEAR_EXOTIC_PROXYOBJ(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ)
 
#define DUK_PROPDESC_FLAG_WRITABLE   (1 << 0) /* E5 Section 8.6.1 */
 
#define DUK_PROPDESC_FLAG_ENUMERABLE   (1 << 1) /* E5 Section 8.6.1 */
 
#define DUK_PROPDESC_FLAG_CONFIGURABLE   (1 << 2) /* E5 Section 8.6.1 */
 
#define DUK_PROPDESC_FLAG_ACCESSOR   (1 << 3) /* accessor */
 
#define DUK_PROPDESC_FLAG_VIRTUAL
 
#define DUK_PROPDESC_FLAGS_MASK
 
#define DUK_PROPDESC_FLAG_NO_OVERWRITE   (1 << 4) /* internal define property: skip write silently if exists */
 
#define DUK_PROPDESC_FLAGS_NONE   0
 
#define DUK_PROPDESC_FLAGS_W   (DUK_PROPDESC_FLAG_WRITABLE)
 
#define DUK_PROPDESC_FLAGS_E   (DUK_PROPDESC_FLAG_ENUMERABLE)
 
#define DUK_PROPDESC_FLAGS_C   (DUK_PROPDESC_FLAG_CONFIGURABLE)
 
#define DUK_PROPDESC_FLAGS_WE   (DUK_PROPDESC_FLAG_WRITABLE | DUK_PROPDESC_FLAG_ENUMERABLE)
 
#define DUK_PROPDESC_FLAGS_WC   (DUK_PROPDESC_FLAG_WRITABLE | DUK_PROPDESC_FLAG_CONFIGURABLE)
 
#define DUK_PROPDESC_FLAGS_EC   (DUK_PROPDESC_FLAG_ENUMERABLE | DUK_PROPDESC_FLAG_CONFIGURABLE)
 
#define DUK_PROPDESC_FLAGS_WEC
 
#define DUK_GETDESC_FLAG_PUSH_VALUE   (1 << 0) /* push value to stack */
 
#define DUK_GETDESC_FLAG_IGNORE_PROTOLOOP   (1 << 1) /* don't throw for prototype loop */
 
#define DUK_ASSERT_HOBJECT_VALID(h)
 
#define DUK_HOBJECT_GET_PROPS(heap, h)    ((h)->props)
 
#define DUK_HOBJECT_SET_PROPS(heap, h, x)
 
#define DUK_HOBJECT_E_FLAG_PADDING(e_sz)   ((8 - (e_sz)) & 0x07)
 
#define DUK_HOBJECT_E_GET_KEY_BASE(heap, h)
 
#define DUK_HOBJECT_E_GET_VALUE_BASE(heap, h)
 
#define DUK_HOBJECT_E_GET_FLAGS_BASE(heap, h)
 
#define DUK_HOBJECT_A_GET_BASE(heap, h)
 
#define DUK_HOBJECT_H_GET_BASE(heap, h)
 
#define DUK_HOBJECT_P_COMPUTE_SIZE(n_ent, n_arr, n_hash)
 
#define DUK_HOBJECT_P_SET_REALLOC_PTRS(p_base, set_e_k, set_e_pv, set_e_f, set_a, set_h, n_ent, n_arr, n_hash)
 
#define DUK_HOBJECT_P_ALLOC_SIZE(h)    DUK_HOBJECT_P_COMPUTE_SIZE(DUK_HOBJECT_GET_ESIZE((h)), DUK_HOBJECT_GET_ASIZE((h)), DUK_HOBJECT_GET_HSIZE((h)))
 
#define DUK_HOBJECT_E_GET_KEY(heap, h, i)   (DUK_HOBJECT_E_GET_KEY_BASE((heap), (h))[(i)])
 
#define DUK_HOBJECT_E_GET_KEY_PTR(heap, h, i)   (&DUK_HOBJECT_E_GET_KEY_BASE((heap), (h))[(i)])
 
#define DUK_HOBJECT_E_GET_VALUE(heap, h, i)   (DUK_HOBJECT_E_GET_VALUE_BASE((heap), (h))[(i)])
 
#define DUK_HOBJECT_E_GET_VALUE_PTR(heap, h, i)   (&DUK_HOBJECT_E_GET_VALUE_BASE((heap), (h))[(i)])
 
#define DUK_HOBJECT_E_GET_VALUE_TVAL(heap, h, i)   (DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).v)
 
#define DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(heap, h, i)   (&DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).v)
 
#define DUK_HOBJECT_E_GET_VALUE_GETTER(heap, h, i)   (DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).a.get)
 
#define DUK_HOBJECT_E_GET_VALUE_GETTER_PTR(heap, h, i)   (&DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).a.get)
 
#define DUK_HOBJECT_E_GET_VALUE_SETTER(heap, h, i)   (DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).a.set)
 
#define DUK_HOBJECT_E_GET_VALUE_SETTER_PTR(heap, h, i)   (&DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).a.set)
 
#define DUK_HOBJECT_E_GET_FLAGS(heap, h, i)   (DUK_HOBJECT_E_GET_FLAGS_BASE((heap), (h))[(i)])
 
#define DUK_HOBJECT_E_GET_FLAGS_PTR(heap, h, i)   (&DUK_HOBJECT_E_GET_FLAGS_BASE((heap), (h))[(i)])
 
#define DUK_HOBJECT_A_GET_VALUE(heap, h, i)   (DUK_HOBJECT_A_GET_BASE((heap), (h))[(i)])
 
#define DUK_HOBJECT_A_GET_VALUE_PTR(heap, h, i)   (&DUK_HOBJECT_A_GET_BASE((heap), (h))[(i)])
 
#define DUK_HOBJECT_H_GET_INDEX(heap, h, i)   (DUK_HOBJECT_H_GET_BASE((heap), (h))[(i)])
 
#define DUK_HOBJECT_H_GET_INDEX_PTR(heap, h, i)   (&DUK_HOBJECT_H_GET_BASE((heap), (h))[(i)])
 
#define DUK_HOBJECT_E_SET_KEY(heap, h, i, k)
 
#define DUK_HOBJECT_E_SET_VALUE(heap, h, i, v)
 
#define DUK_HOBJECT_E_SET_VALUE_TVAL(heap, h, i, v)
 
#define DUK_HOBJECT_E_SET_VALUE_GETTER(heap, h, i, v)
 
#define DUK_HOBJECT_E_SET_VALUE_SETTER(heap, h, i, v)
 
#define DUK_HOBJECT_E_SET_FLAGS(heap, h, i, f)
 
#define DUK_HOBJECT_A_SET_VALUE(heap, h, i, v)
 
#define DUK_HOBJECT_A_SET_VALUE_TVAL(heap, h, i, v)    DUK_HOBJECT_A_SET_VALUE((heap), (h), (i), (v)) /* alias for above */
 
#define DUK_HOBJECT_H_SET_INDEX(heap, h, i, v)
 
#define DUK_HOBJECT_E_SET_FLAG_BITS(heap, h, i, mask)
 
#define DUK_HOBJECT_E_CLEAR_FLAG_BITS(heap, h, i, mask)
 
#define DUK_HOBJECT_E_SLOT_IS_WRITABLE(heap, h, i)   ((DUK_HOBJECT_E_GET_FLAGS((heap), (h), (i)) & DUK_PROPDESC_FLAG_WRITABLE) != 0)
 
#define DUK_HOBJECT_E_SLOT_IS_ENUMERABLE(heap, h, i)   ((DUK_HOBJECT_E_GET_FLAGS((heap), (h), (i)) & DUK_PROPDESC_FLAG_ENUMERABLE) != 0)
 
#define DUK_HOBJECT_E_SLOT_IS_CONFIGURABLE(heap, h, i)   ((DUK_HOBJECT_E_GET_FLAGS((heap), (h), (i)) & DUK_PROPDESC_FLAG_CONFIGURABLE) != 0)
 
#define DUK_HOBJECT_E_SLOT_IS_ACCESSOR(heap, h, i)   ((DUK_HOBJECT_E_GET_FLAGS((heap), (h), (i)) & DUK_PROPDESC_FLAG_ACCESSOR) != 0)
 
#define DUK_HOBJECT_E_SLOT_SET_WRITABLE(heap, h, i)   DUK_HOBJECT_E_SET_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_WRITABLE)
 
#define DUK_HOBJECT_E_SLOT_SET_ENUMERABLE(heap, h, i)   DUK_HOBJECT_E_SET_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_ENUMERABLE)
 
#define DUK_HOBJECT_E_SLOT_SET_CONFIGURABLE(heap, h, i)   DUK_HOBJECT_E_SET_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_CONFIGURABLE)
 
#define DUK_HOBJECT_E_SLOT_SET_ACCESSOR(heap, h, i)   DUK_HOBJECT_E_SET_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_ACCESSOR)
 
#define DUK_HOBJECT_E_SLOT_CLEAR_WRITABLE(heap, h, i)   DUK_HOBJECT_E_CLEAR_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_WRITABLE)
 
#define DUK_HOBJECT_E_SLOT_CLEAR_ENUMERABLE(heap, h, i)   DUK_HOBJECT_E_CLEAR_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_ENUMERABLE)
 
#define DUK_HOBJECT_E_SLOT_CLEAR_CONFIGURABLE(heap, h, i)   DUK_HOBJECT_E_CLEAR_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_CONFIGURABLE)
 
#define DUK_HOBJECT_E_SLOT_CLEAR_ACCESSOR(heap, h, i)   DUK_HOBJECT_E_CLEAR_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_ACCESSOR)
 
#define DUK_PROPDESC_IS_WRITABLE(p)   (((p)->flags & DUK_PROPDESC_FLAG_WRITABLE) != 0)
 
#define DUK_PROPDESC_IS_ENUMERABLE(p)   (((p)->flags & DUK_PROPDESC_FLAG_ENUMERABLE) != 0)
 
#define DUK_PROPDESC_IS_CONFIGURABLE(p)   (((p)->flags & DUK_PROPDESC_FLAG_CONFIGURABLE) != 0)
 
#define DUK_PROPDESC_IS_ACCESSOR(p)   (((p)->flags & DUK_PROPDESC_FLAG_ACCESSOR) != 0)
 
#define DUK_HOBJECT_HASHIDX_UNUSED   0xffffffffUL
 
#define DUK_HOBJECT_HASHIDX_DELETED   0xfffffffeUL
 
#define DUK_HOBJECT_GET_ESIZE(h)   ((h)->e_size)
 
#define DUK_HOBJECT_SET_ESIZE(h, v)   do { (h)->e_size = (v); } while (0)
 
#define DUK_HOBJECT_GET_ENEXT(h)   ((h)->e_next)
 
#define DUK_HOBJECT_SET_ENEXT(h, v)   do { (h)->e_next = (v); } while (0)
 
#define DUK_HOBJECT_POSTINC_ENEXT(h)   ((h)->e_next++)
 
#define DUK_HOBJECT_GET_ASIZE(h)   ((h)->a_size)
 
#define DUK_HOBJECT_SET_ASIZE(h, v)   do { (h)->a_size = (v); } while (0)
 
#define DUK_HOBJECT_GET_HSIZE(h)   ((h)->h_size)
 
#define DUK_HOBJECT_SET_HSIZE(h, v)   do { (h)->h_size = (v); } while (0)
 
#define DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY   10000L
 
#define DUK_HOBJECT_BOUND_CHAIN_SANITY   10000L
 
#define DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(n)   duk_class_number_to_stridx[(n)]
 
#define DUK_HOBJECT_GET_CLASS_STRING(heap, h)
 
#define DUK_HOBJECT_GET_PROTOTYPE(heap, h)    ((h)->prototype)
 
#define DUK_HOBJECT_SET_PROTOTYPE(heap, h, x)
 
#define DUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, h, p)   duk_hobject_set_prototype_updref((thr), (h), (p))
 
#define DUK_HOBJECT_MAX_PROPERTIES   0x7fffffffUL /* 2**31-1 ~= 2G properties */
 
#define DUK_HOBJECT_E_USE_HASH_LIMIT   32
 
#define DUK_HOBJECT_H_SIZE_DIVISOR   4 /* hash size approx. 1.25 times entries size */
 
#define DUK_HOBJECT_A_FAST_RESIZE_LIMIT   9 /* 112.5%, i.e. new size less than 12.5% higher -> fast resize */
 
#define DUK_HOBJECT_A_ABANDON_LIMIT   2 /* 25%, i.e. less than 25% used -> abandon */
 
#define DUK_HOBJECT_ALIGN_TARGET   8
 
#define DUK_HOBJECT_E_MIN_GROW_ADD   16
 
#define DUK_HOBJECT_E_MIN_GROW_DIVISOR   8 /* 2^3 -> 1/8 = 12.5% min growth */
 
#define DUK_HOBJECT_A_MIN_GROW_ADD   16
 
#define DUK_HOBJECT_A_MIN_GROW_DIVISOR   8 /* 2^3 -> 1/8 = 12.5% min growth */
 
#define DUK_HOBJECT_HASH_INITIAL(hash, h_size)   ((hash) % (h_size))
 
#define DUK_HOBJECT_HASH_PROBE_STEP(hash)   DUK_UTIL_GET_HASH_PROBE_STEP((hash))
 
#define DUK_PC2LINE_SKIP   64
 
#define DUK_PC2LINE_MAX_DIFF_LENGTH   (((DUK_PC2LINE_SKIP - 1) * 35 + 7) / 8)
 
#define duk_hobject_get_internal_value_tval_ptr(heap, obj)    duk_hobject_find_existing_entry_tval_ptr((heap), (obj), DUK_HEAP_STRING_INT_VALUE((heap)))
 
#define DUK_DELPROP_FLAG_THROW   (1 << 0)
 
#define DUK_DELPROP_FLAG_FORCE   (1 << 1)
 
#define DUK_HCOMPILEDFUNCTION_H_INCLUDED
 
#define DUK_HCOMPILEDFUNCTION_GET_DATA(heap, h)    ((duk_hbuffer_fixed *) (void *) (h)->data)
 
#define DUK_HCOMPILEDFUNCTION_SET_DATA(heap, h, v)
 
#define DUK_HCOMPILEDFUNCTION_GET_FUNCS(heap, h)    ((h)->funcs)
 
#define DUK_HCOMPILEDFUNCTION_SET_FUNCS(heap, h, v)
 
#define DUK_HCOMPILEDFUNCTION_GET_BYTECODE(heap, h)    ((h)->bytecode)
 
#define DUK_HCOMPILEDFUNCTION_SET_BYTECODE(heap, h, v)
 
#define DUK_HCOMPILEDFUNCTION_GET_BUFFER_BASE(heap, h)    DUK_HBUFFER_FIXED_GET_DATA_PTR((heap), DUK_HCOMPILEDFUNCTION_GET_DATA((heap), (h)))
 
#define DUK_HCOMPILEDFUNCTION_GET_CONSTS_BASE(heap, h)    ((duk_tval *) (void *) DUK_HCOMPILEDFUNCTION_GET_BUFFER_BASE((heap), (h)))
 
#define DUK_HCOMPILEDFUNCTION_GET_FUNCS_BASE(heap, h)    DUK_HCOMPILEDFUNCTION_GET_FUNCS((heap), (h))
 
#define DUK_HCOMPILEDFUNCTION_GET_CODE_BASE(heap, h)    DUK_HCOMPILEDFUNCTION_GET_BYTECODE((heap), (h))
 
#define DUK_HCOMPILEDFUNCTION_GET_CONSTS_END(heap, h)    ((duk_tval *) (void *) DUK_HCOMPILEDFUNCTION_GET_FUNCS((heap), (h)))
 
#define DUK_HCOMPILEDFUNCTION_GET_FUNCS_END(heap, h)    ((duk_hobject **) (void *) DUK_HCOMPILEDFUNCTION_GET_BYTECODE((heap), (h)))
 
#define DUK_HCOMPILEDFUNCTION_GET_CODE_END(heap, h)
 
#define DUK_HCOMPILEDFUNCTION_GET_CONSTS_SIZE(heap, h)
 
#define DUK_HCOMPILEDFUNCTION_GET_FUNCS_SIZE(heap, h)
 
#define DUK_HCOMPILEDFUNCTION_GET_CODE_SIZE(heap, h)
 
#define DUK_HCOMPILEDFUNCTION_GET_CONSTS_COUNT(heap, h)    ((duk_size_t) (DUK_HCOMPILEDFUNCTION_GET_CONSTS_SIZE((heap), (h)) / sizeof(duk_tval)))
 
#define DUK_HCOMPILEDFUNCTION_GET_FUNCS_COUNT(heap, h)    ((duk_size_t) (DUK_HCOMPILEDFUNCTION_GET_FUNCS_SIZE((heap), (h)) / sizeof(duk_hobject *)))
 
#define DUK_HCOMPILEDFUNCTION_GET_CODE_COUNT(heap, h)    ((duk_size_t) (DUK_HCOMPILEDFUNCTION_GET_CODE_SIZE((heap), (h)) / sizeof(duk_instr_t)))
 
#define DUK_HNATIVEFUNCTION_H_INCLUDED
 
#define DUK_HNATIVEFUNCTION_NARGS_VARARGS   ((duk_int16_t) -1)
 
#define DUK_HNATIVEFUNCTION_NARGS_MAX   ((duk_int16_t) 0x7fff)
 
#define DUK_HBUFFEROBJECT_H_INCLUDED
 
#define DUK_HBUFFEROBJECT_ELEM_UINT8   0
 
#define DUK_HBUFFEROBJECT_ELEM_UINT8CLAMPED   1
 
#define DUK_HBUFFEROBJECT_ELEM_INT8   2
 
#define DUK_HBUFFEROBJECT_ELEM_UINT16   3
 
#define DUK_HBUFFEROBJECT_ELEM_INT16   4
 
#define DUK_HBUFFEROBJECT_ELEM_UINT32   5
 
#define DUK_HBUFFEROBJECT_ELEM_INT32   6
 
#define DUK_HBUFFEROBJECT_ELEM_FLOAT32   7
 
#define DUK_HBUFFEROBJECT_ELEM_FLOAT64   8
 
#define DUK_HBUFFEROBJECT_ELEM_MAX   8
 
#define DUK_ASSERT_HBUFFEROBJECT_VALID(h)
 
#define DUK_HBUFFEROBJECT_GET_SLICE_BASE(heap, h)
 
#define DUK_HBUFFEROBJECT_FULL_SLICE(h)
 
#define DUK_HBUFFEROBJECT_VALID_SLICE(h)
 
#define DUK_HBUFFEROBJECT_VALID_BYTEOFFSET_INCL(h, off)
 
#define DUK_HBUFFEROBJECT_VALID_BYTEOFFSET_EXCL(h, off)
 
#define DUK_HBUFFEROBJECT_CLAMP_BYTELENGTH(h, len)
 
#define DUK_HTHREAD_H_INCLUDED
 
#define DUK_VALSTACK_GROW_STEP   128 /* roughly 1 kiB */
 
#define DUK_VALSTACK_SHRINK_THRESHOLD   256 /* roughly 2 kiB */
 
#define DUK_VALSTACK_SHRINK_SPARE   64 /* roughly 0.5 kiB */
 
#define DUK_VALSTACK_INITIAL_SIZE   128 /* roughly 1.0 kiB -> but rounds up to DUK_VALSTACK_GROW_STEP in practice */
 
#define DUK_VALSTACK_INTERNAL_EXTRA
 
#define DUK_VALSTACK_API_ENTRY_MINIMUM   DUK_API_ENTRY_STACK
 
#define DUK_VALSTACK_DEFAULT_MAX   1000000L
 
#define DUK_CALLSTACK_GROW_STEP   8 /* roughly 256 bytes */
 
#define DUK_CALLSTACK_SHRINK_THRESHOLD   16 /* roughly 512 bytes */
 
#define DUK_CALLSTACK_SHRINK_SPARE   8 /* roughly 256 bytes */
 
#define DUK_CALLSTACK_INITIAL_SIZE   8
 
#define DUK_CALLSTACK_DEFAULT_MAX   10000L
 
#define DUK_CATCHSTACK_GROW_STEP   4 /* roughly 64 bytes */
 
#define DUK_CATCHSTACK_SHRINK_THRESHOLD   8 /* roughly 128 bytes */
 
#define DUK_CATCHSTACK_SHRINK_SPARE   4 /* roughly 64 bytes */
 
#define DUK_CATCHSTACK_INITIAL_SIZE   4
 
#define DUK_CATCHSTACK_DEFAULT_MAX   10000L
 
#define DUK_ACT_FLAG_STRICT   (1 << 0) /* function executes in strict mode */
 
#define DUK_ACT_FLAG_TAILCALLED   (1 << 1) /* activation has tail called one or more times */
 
#define DUK_ACT_FLAG_CONSTRUCT   (1 << 2) /* function executes as a constructor (called via "new") */
 
#define DUK_ACT_FLAG_PREVENT_YIELD   (1 << 3) /* activation prevents yield (native call or "new") */
 
#define DUK_ACT_FLAG_DIRECT_EVAL   (1 << 4) /* activation is a direct eval call */
 
#define DUK_ACT_FLAG_BREAKPOINT_ACTIVE   (1 << 5) /* activation has active breakpoint(s) */
 
#define DUK_ACT_GET_FUNC(act)   ((act)->func)
 
#define DUK_TB_FLAG_NOBLAME_FILELINE   (1 << 0) /* don't report __FILE__ / __LINE__ as fileName/lineNumber */
 
#define DUK_CAT_TYPE_MASK   0x0000000fUL
 
#define DUK_CAT_TYPE_BITS   4
 
#define DUK_CAT_LABEL_MASK   0xffffff00UL
 
#define DUK_CAT_LABEL_BITS   24
 
#define DUK_CAT_LABEL_SHIFT   8
 
#define DUK_CAT_FLAG_CATCH_ENABLED   (1 << 4) /* catch part will catch */
 
#define DUK_CAT_FLAG_FINALLY_ENABLED   (1 << 5) /* finally part will catch */
 
#define DUK_CAT_FLAG_CATCH_BINDING_ENABLED   (1 << 6) /* request to create catch binding */
 
#define DUK_CAT_FLAG_LEXENV_ACTIVE   (1 << 7) /* catch or with binding is currently active */
 
#define DUK_CAT_TYPE_UNKNOWN   0
 
#define DUK_CAT_TYPE_TCF   1
 
#define DUK_CAT_TYPE_LABEL   2
 
#define DUK_CAT_GET_TYPE(c)   ((c)->flags & DUK_CAT_TYPE_MASK)
 
#define DUK_CAT_GET_LABEL(c)   (((c)->flags & DUK_CAT_LABEL_MASK) >> DUK_CAT_LABEL_SHIFT)
 
#define DUK_CAT_HAS_CATCH_ENABLED(c)   ((c)->flags & DUK_CAT_FLAG_CATCH_ENABLED)
 
#define DUK_CAT_HAS_FINALLY_ENABLED(c)   ((c)->flags & DUK_CAT_FLAG_FINALLY_ENABLED)
 
#define DUK_CAT_HAS_CATCH_BINDING_ENABLED(c)   ((c)->flags & DUK_CAT_FLAG_CATCH_BINDING_ENABLED)
 
#define DUK_CAT_HAS_LEXENV_ACTIVE(c)   ((c)->flags & DUK_CAT_FLAG_LEXENV_ACTIVE)
 
#define DUK_CAT_SET_CATCH_ENABLED(c)
 
#define DUK_CAT_SET_FINALLY_ENABLED(c)
 
#define DUK_CAT_SET_CATCH_BINDING_ENABLED(c)
 
#define DUK_CAT_SET_LEXENV_ACTIVE(c)
 
#define DUK_CAT_CLEAR_CATCH_ENABLED(c)
 
#define DUK_CAT_CLEAR_FINALLY_ENABLED(c)
 
#define DUK_CAT_CLEAR_CATCH_BINDING_ENABLED(c)
 
#define DUK_CAT_CLEAR_LEXENV_ACTIVE(c)
 
#define DUK_HTHREAD_GET_STRING(thr, idx)    ((thr)->strs[(idx)])
 
#define DUK_HTHREAD_GET_CURRENT_ACTIVATION(thr)   (&(thr)->callstack[(thr)->callstack_top - 1])
 
#define DUK_HTHREAD_STATE_INACTIVE   1 /* thread not currently running */
 
#define DUK_HTHREAD_STATE_RUNNING   2 /* thread currently running (only one at a time) */
 
#define DUK_HTHREAD_STATE_RESUMED   3 /* thread resumed another thread (active but not running) */
 
#define DUK_HTHREAD_STATE_YIELDED   4 /* thread has yielded */
 
#define DUK_HTHREAD_STATE_TERMINATED   5 /* thread has terminated */
 
#define DUK_ASSERT_CTX_VSSIZE(ctx)
 
#define DUK_ASSERT_CTX_VALID(ctx)
 
#define DUK_HBUFFER_H_INCLUDED
 
#define DUK_HBUFFER_FLAG_DYNAMIC   DUK_HEAPHDR_USER_FLAG(0) /* buffer is behind a pointer, dynamic or external */
 
#define DUK_HBUFFER_FLAG_EXTERNAL   DUK_HEAPHDR_USER_FLAG(1) /* buffer pointer is to an externally allocated buffer */
 
#define DUK_HBUFFER_HAS_DYNAMIC(x)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HBUFFER_FLAG_DYNAMIC)
 
#define DUK_HBUFFER_HAS_EXTERNAL(x)   DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HBUFFER_FLAG_EXTERNAL)
 
#define DUK_HBUFFER_SET_DYNAMIC(x)   DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HBUFFER_FLAG_DYNAMIC)
 
#define DUK_HBUFFER_SET_EXTERNAL(x)   DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HBUFFER_FLAG_EXTERNAL)
 
#define DUK_HBUFFER_CLEAR_DYNAMIC(x)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HBUFFER_FLAG_DYNAMIC)
 
#define DUK_HBUFFER_CLEAR_EXTERNAL(x)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HBUFFER_FLAG_EXTERNAL)
 
#define DUK_HBUFFER_MAX_BYTELEN   (0x7ffffffeUL)
 
#define DUK_HBUFFER_GET_SIZE(x)   (((duk_hbuffer *) (x))->size)
 
#define DUK_HBUFFER_SET_SIZE(x, v)
 
#define DUK_HBUFFER_ADD_SIZE(x, dv)
 
#define DUK_HBUFFER_SUB_SIZE(x, dv)
 
#define DUK_HBUFFER_FIXED_GET_SIZE(x)   DUK_HBUFFER_GET_SIZE((duk_hbuffer *) (x))
 
#define DUK_HBUFFER_FIXED_SET_SIZE(x, v)   DUK_HBUFFER_SET_SIZE((duk_hbuffer *) (x))
 
#define DUK_HBUFFER_DYNAMIC_GET_SIZE(x)   DUK_HBUFFER_GET_SIZE((duk_hbuffer *) (x))
 
#define DUK_HBUFFER_DYNAMIC_SET_SIZE(x, v)   DUK_HBUFFER_SET_SIZE((duk_hbuffer *) (x), (v))
 
#define DUK_HBUFFER_DYNAMIC_ADD_SIZE(x, dv)   DUK_HBUFFER_ADD_SIZE((duk_hbuffer *) (x), (dv))
 
#define DUK_HBUFFER_DYNAMIC_SUB_SIZE(x, dv)   DUK_HBUFFER_SUB_SIZE((duk_hbuffer *) (x), (dv))
 
#define DUK_HBUFFER_EXTERNAL_GET_SIZE(x)   DUK_HBUFFER_GET_SIZE((duk_hbuffer *) (x))
 
#define DUK_HBUFFER_EXTERNAL_SET_SIZE(x, v)   DUK_HBUFFER_SET_SIZE((duk_hbuffer *) (x), (v))
 
#define DUK_HBUFFER_FIXED_GET_DATA_PTR(heap, x)   ((duk_uint8_t *) (((duk_hbuffer_fixed *) (x)) + 1))
 
#define DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(heap, x)   ((x)->curr_alloc)
 
#define DUK_HBUFFER_DYNAMIC_SET_DATA_PTR(heap, x, v)
 
#define DUK_HBUFFER_DYNAMIC_SET_DATA_PTR_NULL(heap, x)
 
#define DUK_HBUFFER_EXTERNAL_GET_DATA_PTR(heap, x)    ((void *) (x)->curr_alloc)
 
#define DUK_HBUFFER_EXTERNAL_SET_DATA_PTR(heap, x, v)
 
#define DUK_HBUFFER_EXTERNAL_SET_DATA_PTR_NULL(heap, x)
 
#define DUK_HBUFFER_GET_DATA_PTR(heap, x)
 
#define DUK_HEAP_H_INCLUDED
 
#define DUK_HEAP_FLAG_MARKANDSWEEP_RUNNING   (1 << 0) /* mark-and-sweep is currently running */
 
#define DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED   (1 << 1) /* mark-and-sweep marking reached a recursion limit and must use multi-pass marking */
 
#define DUK_HEAP_FLAG_REFZERO_FREE_RUNNING   (1 << 2) /* refcount code is processing refzero list */
 
#define DUK_HEAP_FLAG_ERRHANDLER_RUNNING   (1 << 3) /* an error handler (user callback to augment/replace error) is running */
 
#define DUK_HEAP_FLAG_INTERRUPT_RUNNING   (1 << 4) /* executor interrupt running (used to avoid nested interrupts) */
 
#define DUK_HEAP_FLAG_FINALIZER_NORESCUE   (1 << 5) /* heap destruction ongoing, finalizer rescue no longer possible */
 
#define DUK__HEAP_HAS_FLAGS(heap, bits)   ((heap)->flags & (bits))
 
#define DUK__HEAP_SET_FLAGS(heap, bits)
 
#define DUK__HEAP_CLEAR_FLAGS(heap, bits)
 
#define DUK_HEAP_HAS_MARKANDSWEEP_RUNNING(heap)   DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RUNNING)
 
#define DUK_HEAP_HAS_MARKANDSWEEP_RECLIMIT_REACHED(heap)   DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED)
 
#define DUK_HEAP_HAS_REFZERO_FREE_RUNNING(heap)   DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_REFZERO_FREE_RUNNING)
 
#define DUK_HEAP_HAS_ERRHANDLER_RUNNING(heap)   DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_ERRHANDLER_RUNNING)
 
#define DUK_HEAP_HAS_INTERRUPT_RUNNING(heap)   DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_INTERRUPT_RUNNING)
 
#define DUK_HEAP_HAS_FINALIZER_NORESCUE(heap)   DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_FINALIZER_NORESCUE)
 
#define DUK_HEAP_SET_MARKANDSWEEP_RUNNING(heap)   DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RUNNING)
 
#define DUK_HEAP_SET_MARKANDSWEEP_RECLIMIT_REACHED(heap)   DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED)
 
#define DUK_HEAP_SET_REFZERO_FREE_RUNNING(heap)   DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_REFZERO_FREE_RUNNING)
 
#define DUK_HEAP_SET_ERRHANDLER_RUNNING(heap)   DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_ERRHANDLER_RUNNING)
 
#define DUK_HEAP_SET_INTERRUPT_RUNNING(heap)   DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_INTERRUPT_RUNNING)
 
#define DUK_HEAP_SET_FINALIZER_NORESCUE(heap)   DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_FINALIZER_NORESCUE)
 
#define DUK_HEAP_CLEAR_MARKANDSWEEP_RUNNING(heap)   DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RUNNING)
 
#define DUK_HEAP_CLEAR_MARKANDSWEEP_RECLIMIT_REACHED(heap)   DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED)
 
#define DUK_HEAP_CLEAR_REFZERO_FREE_RUNNING(heap)   DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_REFZERO_FREE_RUNNING)
 
#define DUK_HEAP_CLEAR_ERRHANDLER_RUNNING(heap)   DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_ERRHANDLER_RUNNING)
 
#define DUK_HEAP_CLEAR_INTERRUPT_RUNNING(heap)   DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_INTERRUPT_RUNNING)
 
#define DUK_HEAP_CLEAR_FINALIZER_NORESCUE(heap)   DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_FINALIZER_NORESCUE)
 
#define DUK_LJ_TYPE_UNKNOWN   0 /* unused */
 
#define DUK_LJ_TYPE_THROW   1 /* value1 -> error object */
 
#define DUK_LJ_TYPE_YIELD   2 /* value1 -> yield value, iserror -> error / normal */
 
#define DUK_LJ_TYPE_RESUME   3 /* value1 -> resume value, value2 -> resumee thread, iserror -> error/normal */
 
#define DUK_LJ_TYPE_BREAK   4 /* value1 -> label number, pseudo-type to indicate a break continuation (for ENDFIN) */
 
#define DUK_LJ_TYPE_CONTINUE   5 /* value1 -> label number, pseudo-type to indicate a continue continuation (for ENDFIN) */
 
#define DUK_LJ_TYPE_RETURN   6 /* value1 -> return value, pseudo-type to indicate a return continuation (for ENDFIN) */
 
#define DUK_LJ_TYPE_NORMAL   7 /* no value, pseudo-type to indicate a normal continuation (for ENDFIN) */
 
#define DUK_MS_FLAG_EMERGENCY   (1 << 0) /* emergency mode: try extra hard */
 
#define DUK_MS_FLAG_NO_STRINGTABLE_RESIZE   (1 << 1) /* don't resize stringtable (but may sweep it); needed during stringtable resize */
 
#define DUK_MS_FLAG_NO_OBJECT_COMPACTION   (1 << 2) /* don't compact objects; needed during object property allocation resize */
 
#define DUK_MS_FLAG_NO_FINALIZERS   (1 << 3) /* don't run finalizers; leave finalizable objects in finalize_list for next round */
 
#define DUK_MS_FLAG_SKIP_FINALIZERS   (1 << 4) /* don't run finalizers; queue finalizable objects back to heap_allocated */
 
#define DUK_HEAP_SWITCH_THREAD(heap, newthr)
 
#define DUK_HEAP_MARK_AND_SWEEP_TRIGGER_MULT   12800L /* 50x heap size */
 
#define DUK_HEAP_MARK_AND_SWEEP_TRIGGER_ADD   1024L
 
#define DUK_HEAP_MARK_AND_SWEEP_TRIGGER_SKIP   256L
 
#define DUK_HEAP_STRCACHE_SIZE   4
 
#define DUK_HEAP_STRINGCACHE_NOCACHE_LIMIT   16 /* strings up to the this length are not cached */
 
#define DUK_HEAP_INSERT_INTO_HEAP_ALLOCATED(heap, hdr)   duk_heap_insert_into_heap_allocated((heap),(hdr))
 
#define DUK_STRTAB_INITIAL_SIZE   17
 
#define DUK_STRTAB_DELETED_MARKER(heap)   ((duk_hstring *) heap)
 
#define DUK_STRTAB_MIN_FREE_DIVISOR   4 /* load factor max 75% */
 
#define DUK_STRTAB_MIN_USED_DIVISOR   4 /* load factor min 25% */
 
#define DUK_STRTAB_GROW_ST_SIZE(n)   ((n) + (n)) /* used entries + approx 100% -> reset load to 50% */
 
#define DUK_STRTAB_U32_MAX_STRLEN   10 /* 4'294'967'295 */
 
#define DUK_STRTAB_HIGHEST_32BIT_PRIME   0xfffffffbUL
 
#define DUK_STRTAB_HASH_INITIAL(hash, h_size)   ((hash) % (h_size))
 
#define DUK_STRTAB_HASH_PROBE_STEP(hash)   DUK_UTIL_GET_HASH_PROBE_STEP((hash))
 
#define DUK_STRTAB_CHAIN_SIZE   DUK_USE_STRTAB_CHAIN_SIZE
 
#define DUK_HEAP_GET_STRING(heap, idx)    ((heap)->strs[(idx)])
 
#define DUK_ALLOC_RAW(heap, size)    ((heap)->alloc_func((heap)->heap_udata, (size)))
 
#define DUK_REALLOC_RAW(heap, ptr, newsize)    ((heap)->realloc_func((heap)->heap_udata, (void *) (ptr), (newsize)))
 
#define DUK_FREE_RAW(heap, ptr)    ((heap)->free_func((heap)->heap_udata, (void *) (ptr)))
 
#define DUK_ALLOC(heap, size)   duk_heap_mem_alloc((heap), (size))
 
#define DUK_ALLOC_ZEROED(heap, size)   duk_heap_mem_alloc_zeroed((heap), (size))
 
#define DUK_REALLOC(heap, ptr, newsize)   duk_heap_mem_realloc((heap), (ptr), (newsize))
 
#define DUK_REALLOC_INDIRECT(heap, cb, ud, newsize)   duk_heap_mem_realloc_indirect((heap), (cb), (ud), (newsize))
 
#define DUK_FREE(heap, ptr)   duk_heap_mem_free((heap), (ptr))
 
#define DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_LIMIT
 
#define DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_EMERGENCY_LIMIT
 
#define DUK_HEAP_MAX_BREAKPOINTS   16
 
#define DUK_HEAP_DBG_RATELIMIT_OPCODES   4000
 
#define DUK_HEAP_DBG_RATELIMIT_MILLISECS   200
 
#define DUK_STEP_TYPE_NONE   0
 
#define DUK_STEP_TYPE_INTO   1
 
#define DUK_STEP_TYPE_OVER   2
 
#define DUK_STEP_TYPE_OUT   3
 
#define DUK_DEBUGGER_H_INCLUDED
 
#define DUK_DBG_IB_EOM   0x00
 
#define DUK_DBG_IB_REQUEST   0x01
 
#define DUK_DBG_IB_REPLY   0x02
 
#define DUK_DBG_IB_ERROR   0x03
 
#define DUK_DBG_IB_NOTIFY   0x04
 
#define DUK_DBG_IB_INT4   0x10
 
#define DUK_DBG_IB_STR4   0x11
 
#define DUK_DBG_IB_STR2   0x12
 
#define DUK_DBG_IB_BUF4   0x13
 
#define DUK_DBG_IB_BUF2   0x14
 
#define DUK_DBG_IB_UNUSED   0x15
 
#define DUK_DBG_IB_UNDEFINED   0x16
 
#define DUK_DBG_IB_NULL   0x17
 
#define DUK_DBG_IB_TRUE   0x18
 
#define DUK_DBG_IB_FALSE   0x19
 
#define DUK_DBG_IB_NUMBER   0x1a
 
#define DUK_DBG_IB_OBJECT   0x1b
 
#define DUK_DBG_IB_POINTER   0x1c
 
#define DUK_DBG_IB_LIGHTFUNC   0x1d
 
#define DUK_DBG_IB_HEAPPTR   0x1e
 
#define DUK_DBG_ERR_UNKNOWN   0x00
 
#define DUK_DBG_ERR_UNSUPPORTED   0x01
 
#define DUK_DBG_ERR_TOOMANY   0x02
 
#define DUK_DBG_ERR_NOTFOUND   0x03
 
#define DUK_DBG_ERR_APPLICATION   0x04
 
#define DUK_DBG_CMD_STATUS   0x01
 
#define DUK_DBG_CMD_PRINT   0x02
 
#define DUK_DBG_CMD_ALERT   0x03
 
#define DUK_DBG_CMD_LOG   0x04
 
#define DUK_DBG_CMD_THROW   0x05
 
#define DUK_DBG_CMD_DETACHING   0x06
 
#define DUK_DBG_CMD_APPNOTIFY   0x07
 
#define DUK_DBG_CMD_BASICINFO   0x10
 
#define DUK_DBG_CMD_TRIGGERSTATUS   0x11
 
#define DUK_DBG_CMD_PAUSE   0x12
 
#define DUK_DBG_CMD_RESUME   0x13
 
#define DUK_DBG_CMD_STEPINTO   0x14
 
#define DUK_DBG_CMD_STEPOVER   0x15
 
#define DUK_DBG_CMD_STEPOUT   0x16
 
#define DUK_DBG_CMD_LISTBREAK   0x17
 
#define DUK_DBG_CMD_ADDBREAK   0x18
 
#define DUK_DBG_CMD_DELBREAK   0x19
 
#define DUK_DBG_CMD_GETVAR   0x1a
 
#define DUK_DBG_CMD_PUTVAR   0x1b
 
#define DUK_DBG_CMD_GETCALLSTACK   0x1c
 
#define DUK_DBG_CMD_GETLOCALS   0x1d
 
#define DUK_DBG_CMD_EVAL   0x1e
 
#define DUK_DBG_CMD_DETACH   0x1f
 
#define DUK_DBG_CMD_DUMPHEAP   0x20
 
#define DUK_DBG_CMD_GETBYTECODE   0x21
 
#define DUK_DBG_CMD_APPREQUEST   0x22
 
#define DUK_DBG_CMD_GETHEAPOBJINFO   0x23
 
#define DUK_DBG_CMD_GETOBJPROPDESC   0x24
 
#define DUK_DBG_CMD_GETOBJPROPDESCRANGE   0x25
 
#define DUK_DBG_PROPFLAG_INTERNAL   (1 << 8)
 
#define DUK_DEBUG_H_INCLUDED
 
#define DUK_D(x)   do { } while (0) /* omit */
 
#define DUK_DD(x)   do { } while (0) /* omit */
 
#define DUK_DDD(x)   do { } while (0) /* omit */
 
#define DUK_DPRINT   0 && /* args go here as a comma expression in parens */
 
#define DUK_DDPRINT   0 && /* args */
 
#define DUK_DDDPRINT   0 && /* args */
 
#define DUK_ERROR_H_INCLUDED
 
#define DUK_ERROR(thr, err, msg)
 
#define DUK_ERROR_RAW(thr, file, line, err, msg)
 
#define DUK_ERROR_FMT1(thr, err, fmt, arg1)
 
#define DUK_ERROR_RAW_FMT1(thr, file, line, err, fmt, arg1)
 
#define DUK_ERROR_FMT2(thr, err, fmt, arg1, arg2)
 
#define DUK_ERROR_RAW_FMT2(thr, file, line, err, fmt, arg1, arg2)
 
#define DUK_ERROR_FMT3(thr, err, fmt, arg1, arg2, arg3)
 
#define DUK_ERROR_RAW_FMT3(thr, file, line, err, fmt, arg1, arg2, arg3)
 
#define DUK_ERROR_FMT4(thr, err, fmt, arg1, arg2, arg3, arg4)
 
#define DUK_ERROR_RAW_FMT4(thr, file, line, err, fmt, arg1, arg2, arg3, arg4)
 
#define DUK_PANIC(code, msg)   duk_default_panic_handler((code),(msg))
 
#define DUK_ASSERT(x)   do { /* assertion omitted */ } while (0)
 
#define DUK_ASSERT_EXPR(x)   ((void) 0)
 
#define DUK_ASSERT_DISABLE(x)   do { /* assertion disabled */ } while (0)
 
#define DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR(h)   /* no refcount check */
 
#define DUK_ASSERT_REFCOUNT_NONZERO_TVAL(tv)   /* no refcount check */
 
#define DUK_ASSERT_TOP(ctx, n)   DUK_ASSERT((duk_idx_t) duk_get_top((ctx)) == (duk_idx_t) (n))
 
#define DUK_ASSERT_DOUBLE_IS_NORMALIZED(dval)   /* nop */
 
#define DUK_VALSTACK_ASSERT_EXTRA
 
#define DUK_ASSERT_VALSTACK_SPACE(thr, n)   /* no valstack space check */
 
#define DUK_ERROR_REQUIRE_TYPE_INDEX(thr, index, expectname, lowmemstr)
 
#define DUK_ERROR_UNIMPLEMENTED(thr, msg)
 
#define DUK_ERROR_UNIMPLEMENTED_DEFMSG(thr)
 
#define DUK_ERROR_UNSUPPORTED(thr, msg)
 
#define DUK_ERROR_INTERNAL(thr, msg)
 
#define DUK_ERROR_INTERNAL_DEFMSG(thr)
 
#define DUK_ERROR_ALLOC(thr, msg)
 
#define DUK_ERROR_ALLOC_DEFMSG(thr)
 
#define DUK_ERROR_API_INDEX(thr, index)
 
#define DUK_ERROR_API(thr, msg)
 
#define DUK_ERROR_RANGE(thr, msg)
 
#define DUK_ERROR_SYNTAX(thr, msg)
 
#define DUK_ERROR_TYPE(thr, msg)
 
#define DUK_UNICODE_H_INCLUDED
 
#define DUK_UNICODE_MAX_XUTF8_LENGTH   7 /* up to 36 bit codepoints */
 
#define DUK_UNICODE_MAX_XUTF8_BMP_LENGTH   3 /* all codepoints up to U+FFFF */
 
#define DUK_UNICODE_MAX_CESU8_LENGTH   6 /* all codepoints up to U+10FFFF */
 
#define DUK_UNICODE_MAX_CESU8_BMP_LENGTH   3 /* all codepoints up to U+FFFF */
 
#define DUK_UNICODE_CP_ZWNJ   0x200cL /* zero-width non-joiner */
 
#define DUK_UNICODE_CP_ZWJ   0x200dL /* zero-width joiner */
 
#define DUK_UNICODE_CP_REPLACEMENT_CHARACTER   0xfffdL /* http://en.wikipedia.org/wiki/Replacement_character#Replacement_character */
 
#define DUK_ASC_NUL   0x00
 
#define DUK_ASC_SOH   0x01
 
#define DUK_ASC_STX   0x02
 
#define DUK_ASC_ETX   0x03
 
#define DUK_ASC_EOT   0x04
 
#define DUK_ASC_ENQ   0x05
 
#define DUK_ASC_ACK   0x06
 
#define DUK_ASC_BEL   0x07
 
#define DUK_ASC_BS   0x08
 
#define DUK_ASC_HT   0x09
 
#define DUK_ASC_LF   0x0a
 
#define DUK_ASC_VT   0x0b
 
#define DUK_ASC_FF   0x0c
 
#define DUK_ASC_CR   0x0d
 
#define DUK_ASC_SO   0x0e
 
#define DUK_ASC_SI   0x0f
 
#define DUK_ASC_DLE   0x10
 
#define DUK_ASC_DC1   0x11
 
#define DUK_ASC_DC2   0x12
 
#define DUK_ASC_DC3   0x13
 
#define DUK_ASC_DC4   0x14
 
#define DUK_ASC_NAK   0x15
 
#define DUK_ASC_SYN   0x16
 
#define DUK_ASC_ETB   0x17
 
#define DUK_ASC_CAN   0x18
 
#define DUK_ASC_EM   0x19
 
#define DUK_ASC_SUB   0x1a
 
#define DUK_ASC_ESC   0x1b
 
#define DUK_ASC_FS   0x1c
 
#define DUK_ASC_GS   0x1d
 
#define DUK_ASC_RS   0x1e
 
#define DUK_ASC_US   0x1f
 
#define DUK_ASC_SPACE   0x20
 
#define DUK_ASC_EXCLAMATION   0x21
 
#define DUK_ASC_DOUBLEQUOTE   0x22
 
#define DUK_ASC_HASH   0x23
 
#define DUK_ASC_DOLLAR   0x24
 
#define DUK_ASC_PERCENT   0x25
 
#define DUK_ASC_AMP   0x26
 
#define DUK_ASC_SINGLEQUOTE   0x27
 
#define DUK_ASC_LPAREN   0x28
 
#define DUK_ASC_RPAREN   0x29
 
#define DUK_ASC_STAR   0x2a
 
#define DUK_ASC_PLUS   0x2b
 
#define DUK_ASC_COMMA   0x2c
 
#define DUK_ASC_MINUS   0x2d
 
#define DUK_ASC_PERIOD   0x2e
 
#define DUK_ASC_SLASH   0x2f
 
#define DUK_ASC_0   0x30
 
#define DUK_ASC_1   0x31
 
#define DUK_ASC_2   0x32
 
#define DUK_ASC_3   0x33
 
#define DUK_ASC_4   0x34
 
#define DUK_ASC_5   0x35
 
#define DUK_ASC_6   0x36
 
#define DUK_ASC_7   0x37
 
#define DUK_ASC_8   0x38
 
#define DUK_ASC_9   0x39
 
#define DUK_ASC_COLON   0x3a
 
#define DUK_ASC_SEMICOLON   0x3b
 
#define DUK_ASC_LANGLE   0x3c
 
#define DUK_ASC_EQUALS   0x3d
 
#define DUK_ASC_RANGLE   0x3e
 
#define DUK_ASC_QUESTION   0x3f
 
#define DUK_ASC_ATSIGN   0x40
 
#define DUK_ASC_UC_A   0x41
 
#define DUK_ASC_UC_B   0x42
 
#define DUK_ASC_UC_C   0x43
 
#define DUK_ASC_UC_D   0x44
 
#define DUK_ASC_UC_E   0x45
 
#define DUK_ASC_UC_F   0x46
 
#define DUK_ASC_UC_G   0x47
 
#define DUK_ASC_UC_H   0x48
 
#define DUK_ASC_UC_I   0x49
 
#define DUK_ASC_UC_J   0x4a
 
#define DUK_ASC_UC_K   0x4b
 
#define DUK_ASC_UC_L   0x4c
 
#define DUK_ASC_UC_M   0x4d
 
#define DUK_ASC_UC_N   0x4e
 
#define DUK_ASC_UC_O   0x4f
 
#define DUK_ASC_UC_P   0x50
 
#define DUK_ASC_UC_Q   0x51
 
#define DUK_ASC_UC_R   0x52
 
#define DUK_ASC_UC_S   0x53
 
#define DUK_ASC_UC_T   0x54
 
#define DUK_ASC_UC_U   0x55
 
#define DUK_ASC_UC_V   0x56
 
#define DUK_ASC_UC_W   0x57
 
#define DUK_ASC_UC_X   0x58
 
#define DUK_ASC_UC_Y   0x59
 
#define DUK_ASC_UC_Z   0x5a
 
#define DUK_ASC_LBRACKET   0x5b
 
#define DUK_ASC_BACKSLASH   0x5c
 
#define DUK_ASC_RBRACKET   0x5d
 
#define DUK_ASC_CARET   0x5e
 
#define DUK_ASC_UNDERSCORE   0x5f
 
#define DUK_ASC_GRAVE   0x60
 
#define DUK_ASC_LC_A   0x61
 
#define DUK_ASC_LC_B   0x62
 
#define DUK_ASC_LC_C   0x63
 
#define DUK_ASC_LC_D   0x64
 
#define DUK_ASC_LC_E   0x65
 
#define DUK_ASC_LC_F   0x66
 
#define DUK_ASC_LC_G   0x67
 
#define DUK_ASC_LC_H   0x68
 
#define DUK_ASC_LC_I   0x69
 
#define DUK_ASC_LC_J   0x6a
 
#define DUK_ASC_LC_K   0x6b
 
#define DUK_ASC_LC_L   0x6c
 
#define DUK_ASC_LC_M   0x6d
 
#define DUK_ASC_LC_N   0x6e
 
#define DUK_ASC_LC_O   0x6f
 
#define DUK_ASC_LC_P   0x70
 
#define DUK_ASC_LC_Q   0x71
 
#define DUK_ASC_LC_R   0x72
 
#define DUK_ASC_LC_S   0x73
 
#define DUK_ASC_LC_T   0x74
 
#define DUK_ASC_LC_U   0x75
 
#define DUK_ASC_LC_V   0x76
 
#define DUK_ASC_LC_W   0x77
 
#define DUK_ASC_LC_X   0x78
 
#define DUK_ASC_LC_Y   0x79
 
#define DUK_ASC_LC_Z   0x7a
 
#define DUK_ASC_LCURLY   0x7b
 
#define DUK_ASC_PIPE   0x7c
 
#define DUK_ASC_RCURLY   0x7d
 
#define DUK_ASC_TILDE   0x7e
 
#define DUK_ASC_DEL   0x7f
 
#define DUK_JSON_H_INCLUDED
 
#define DUK_JSON_FLAG_ASCII_ONLY   (1 << 0) /* escape any non-ASCII characters */
 
#define DUK_JSON_FLAG_AVOID_KEY_QUOTES   (1 << 1) /* avoid key quotes when key is an ASCII Identifier */
 
#define DUK_JSON_FLAG_EXT_CUSTOM   (1 << 2) /* extended types: custom encoding */
 
#define DUK_JSON_FLAG_EXT_COMPATIBLE   (1 << 3) /* extended types: compatible encoding */
 
#define DUK_JSON_ENC_REQSTACK   32
 
#define DUK_JSON_DEC_REQSTACK   32
 
#define DUK_JSON_ENC_LOOPARRAY   64
 
#define DUK_JS_H_INCLUDED
 
#define DUK_CALL_FLAG_IGNORE_RECLIMIT   (1 << 0) /* duk_handle_call_xxx: call ignores C recursion limit (for errhandler calls) */
 
#define DUK_CALL_FLAG_CONSTRUCTOR_CALL   (1 << 1) /* duk_handle_call_xxx: constructor call (i.e. called as 'new Foo()') */
 
#define DUK_CALL_FLAG_IS_RESUME   (1 << 2) /* duk_handle_ecma_call_setup: setup for a resume() */
 
#define DUK_CALL_FLAG_IS_TAILCALL   (1 << 3) /* duk_handle_ecma_call_setup: setup for a tail call */
 
#define DUK_CALL_FLAG_DIRECT_EVAL   (1 << 4) /* call is a direct eval call */
 
#define DUK_EQUALS_FLAG_SAMEVALUE   (1 << 0) /* use SameValue instead of non-strict equality */
 
#define DUK_EQUALS_FLAG_STRICT   (1 << 1) /* use strict equality instead of non-strict equality */
 
#define DUK_COMPARE_FLAG_EVAL_LEFT_FIRST   (1 << 0) /* eval left argument first */
 
#define DUK_COMPARE_FLAG_NEGATE   (1 << 1) /* negate result */
 
#define duk_js_equals(thr, tv_x, tv_y)    duk_js_equals_helper((thr), (tv_x), (tv_y), 0)
 
#define duk_js_strict_equals(tv_x, tv_y)    duk_js_equals_helper(NULL, (tv_x), (tv_y), DUK_EQUALS_FLAG_STRICT)
 
#define duk_js_samevalue(tv_x, tv_y)    duk_js_equals_helper(NULL, (tv_x), (tv_y), DUK_EQUALS_FLAG_SAMEVALUE)
 
#define duk_js_lessthan(thr, tv_x, tv_y)    duk_js_compare_helper((thr), (tv_x), (tv_Y), DUK_COMPARE_FLAG_EVAL_LEFT_FIRST)
 
#define duk_js_greaterthan(thr, tv_x, tv_y)    duk_js_compare_helper((thr), (tv_y), (tv_x), 0)
 
#define duk_js_lessthanorequal(thr, tv_x, tv_y)    duk_js_compare_helper((thr), (tv_y), (tv_x), DUK_COMPARE_FLAG_NEGATE)
 
#define duk_js_greaterthanorequal(thr, tv_x, tv_y)    duk_js_compare_helper((thr), (tv_x), (tv_y), DUK_COMPARE_FLAG_EVAL_LEFT_FIRST | DUK_COMPARE_FLAG_NEGATE)
 
#define DUK_NUMCONV_H_INCLUDED
 
#define DUK_N2S_FLAG_FIXED_FORMAT   (1 << 0)
 
#define DUK_N2S_FLAG_FORCE_EXP   (1 << 1)
 
#define DUK_N2S_FLAG_NO_ZERO_PAD   (1 << 2)
 
#define DUK_N2S_FLAG_FRACTION_DIGITS   (1 << 3)
 
#define DUK_S2N_MAX_EXPONENT   1000000000
 
#define DUK_S2N_FLAG_TRIM_WHITE   (1 << 0)
 
#define DUK_S2N_FLAG_ALLOW_EXP   (1 << 1)
 
#define DUK_S2N_FLAG_ALLOW_GARBAGE   (1 << 2)
 
#define DUK_S2N_FLAG_ALLOW_PLUS   (1 << 3)
 
#define DUK_S2N_FLAG_ALLOW_MINUS   (1 << 4)
 
#define DUK_S2N_FLAG_ALLOW_INF   (1 << 5)
 
#define DUK_S2N_FLAG_ALLOW_FRAC   (1 << 6)
 
#define DUK_S2N_FLAG_ALLOW_NAKED_FRAC   (1 << 7)
 
#define DUK_S2N_FLAG_ALLOW_EMPTY_FRAC   (1 << 8)
 
#define DUK_S2N_FLAG_ALLOW_EMPTY_AS_ZERO   (1 << 9)
 
#define DUK_S2N_FLAG_ALLOW_LEADING_ZERO   (1 << 10)
 
#define DUK_S2N_FLAG_ALLOW_AUTO_HEX_INT   (1 << 11)
 
#define DUK_S2N_FLAG_ALLOW_AUTO_OCT_INT   (1 << 12)
 
#define DUK_BUILTIN_PROTOS_H_INCLUDED
 
#define DUK_BI_DATE_ISO8601_BUFSIZE   48
 
#define DUK_BI_COMMONJS_MODULE_ID_LIMIT   256
 
#define DUK_SELFTEST_H_INCLUDED
 
#define DUK__ERRFMT_BUFSIZE   256 /* size for formatting buffers */
 
#define DUK__HASH_SIZE_RATIO   1177 /* floor(1.15 * (1 << 10)) */
 
#define DUK__SER_MARKER   0xff
 
#define DUK__SER_VERSION   0x00
 
#define DUK__SER_STRING   0x00
 
#define DUK__SER_NUMBER   0x01
 
#define DUK__BYTECODE_INITIAL_ALLOC   256
 
#define DUK__ASSERT_LEFT(n)
 
#define DUK__CHECK_SPACE()
 
#define DUK__PACK_ARGS(classnum, protobidx, elemtype, elemshift, isview)    (((classnum) << 24) | ((protobidx) << 16) | ((elemtype) << 8) | ((elemshift) << 4) | (isview))
 
#define DUK__READABLE_STRING_MAXCHARS   32
 
#define DUK__ARRAY_MID_JOIN_LIMIT   4096
 
#define DUK__ITER_EVERY   0
 
#define DUK__ITER_SOME   1
 
#define DUK__ITER_FOREACH   2
 
#define DUK__ITER_MAP   3
 
#define DUK__ITER_FILTER   4
 
#define DUK__FLD_8BIT   0
 
#define DUK__FLD_16BIT   1
 
#define DUK__FLD_32BIT   2
 
#define DUK__FLD_FLOAT   3
 
#define DUK__FLD_DOUBLE   4
 
#define DUK__FLD_VARINT   5
 
#define DUK__FLD_BIGENDIAN   (1 << 3)
 
#define DUK__FLD_SIGNED   (1 << 4)
 
#define DUK__FLD_TYPEDARRAY   (1 << 5)
 
#define DUK__DPRINT_PARTS_AND_DPARTS(parts, dparts)
 
#define DUK__DPRINT_PARTS(parts)
 
#define DUK__DPRINT_DPARTS(dparts)
 
#define DUK__YEAR(x)   ((duk_uint8_t) ((x) - 1970))
 
#define DUK__NUM_ISO8601_PARSER_PARTS   9
 
#define DUK__PI_YEAR   0
 
#define DUK__PI_MONTH   1
 
#define DUK__PI_DAY   2
 
#define DUK__PI_HOUR   3
 
#define DUK__PI_MINUTE   4
 
#define DUK__PI_SECOND   5
 
#define DUK__PI_MILLISECOND   6
 
#define DUK__PI_TZHOUR   7
 
#define DUK__PI_TZMINUTE   8
 
#define DUK__PM_YEAR   (1 << DUK__PI_YEAR)
 
#define DUK__PM_MONTH   (1 << DUK__PI_MONTH)
 
#define DUK__PM_DAY   (1 << DUK__PI_DAY)
 
#define DUK__PM_HOUR   (1 << DUK__PI_HOUR)
 
#define DUK__PM_MINUTE   (1 << DUK__PI_MINUTE)
 
#define DUK__PM_SECOND   (1 << DUK__PI_SECOND)
 
#define DUK__PM_MILLISECOND   (1 << DUK__PI_MILLISECOND)
 
#define DUK__PM_TZHOUR   (1 << DUK__PI_TZHOUR)
 
#define DUK__PM_TZMINUTE   (1 << DUK__PI_TZMINUTE)
 
#define DUK__SI_PLUS   0
 
#define DUK__SI_MINUS   1
 
#define DUK__SI_T   2
 
#define DUK__SI_SPACE   3
 
#define DUK__SI_COLON   4
 
#define DUK__SI_PERIOD   5
 
#define DUK__SI_Z   6
 
#define DUK__SI_NUL   7
 
#define DUK__SM_PLUS   (1 << DUK__SI_PLUS)
 
#define DUK__SM_MINUS   (1 << DUK__SI_MINUS)
 
#define DUK__SM_T   (1 << DUK__SI_T)
 
#define DUK__SM_SPACE   (1 << DUK__SI_SPACE)
 
#define DUK__SM_COLON   (1 << DUK__SI_COLON)
 
#define DUK__SM_PERIOD   (1 << DUK__SI_PERIOD)
 
#define DUK__SM_Z   (1 << DUK__SI_Z)
 
#define DUK__SM_NUL   (1 << DUK__SI_NUL)
 
#define DUK__CF_NEG   (1 << 0) /* continue matching, set neg_tzoffset flag */
 
#define DUK__CF_ACCEPT   (1 << 1) /* accept string */
 
#define DUK__CF_ACCEPT_NUL   (1 << 2) /* accept string if next char is NUL (otherwise reject) */
 
#define DUK__PACK_RULE(partmask, sepmask, nextpart, flags)
 
#define DUK__UNPACK_RULE(rule, var_nextidx, var_flags)
 
#define DUK__RULE_MASK_PART_SEP   0x1ffffUL
 
#define DUK__LOCAL_TZOFFSET_MAXITER   4
 
#define DUK__WEEKDAY_MOD_ADDER   (20000000 * 7) /* 0x08583b00 */
 
#define DUK__STRPTIME_BUF_SIZE   64
 
#define DUK__STRFTIME_BUF_SIZE   64
 
#define DUK__OUTPUT_TYPE_TRACEBACK   (-1)
 
#define DUK__OUTPUT_TYPE_FILENAME   0
 
#define DUK__OUTPUT_TYPE_LINENUMBER   1
 
#define DUK__MKBITS(a, b, c, d, e, f, g, h)
 
#define DUK__CHECK_BITMASK(table, cp)   ((table)[(cp) >> 3] & (1 << ((cp) & 0x07)))
 
#define DUK__IDX_REQUESTED_ID   0 /* Module id requested */
 
#define DUK__IDX_REQUIRE   1 /* Current require() function */
 
#define DUK__IDX_REQUIRE_ID   2 /* The base ID of the current require() function, resolution base */
 
#define DUK__IDX_RESOLVED_ID   3 /* Resolved, normalized absolute module ID */
 
#define DUK__IDX_LASTCOMP   4 /* Last component name in resolved path */
 
#define DUK__IDX_DUKTAPE   5 /* Duktape object */
 
#define DUK__IDX_MODLOADED   6 /* Duktape.modLoaded[] module cache */
 
#define DUK__IDX_UNDEFINED   7 /* 'undefined', artifact of lookup */
 
#define DUK__IDX_FRESH_REQUIRE   8 /* New require() function for module, updated resolution base */
 
#define DUK__IDX_EXPORTS   9 /* Default exports table */
 
#define DUK__IDX_MODULE   10 /* Module object containing module.exports, etc */
 
#define DUK__JSON_DECSTR_BUFSIZE   128
 
#define DUK__JSON_DECSTR_CHUNKSIZE   64
 
#define DUK__JSON_ENCSTR_CHUNKSIZE   64
 
#define DUK__JSON_STRINGIFY_BUFSIZE   128
 
#define DUK__JSON_MAX_ESC_LEN   10 /* '\Udeadbeef' */
 
#define DUK__EMIT_1(js_ctx, ch)   duk__emit_1((js_ctx), (duk_uint_fast8_t) (ch))
 
#define DUK__EMIT_2(js_ctx, ch1, ch2)   duk__emit_2((js_ctx), (duk_uint_fast8_t) (ch1), (duk_uint_fast8_t) (ch2))
 
#define DUK__EMIT_HSTR(js_ctx, h)   duk__emit_hstring((js_ctx), (h))
 
#define DUK__EMIT_CSTR(js_ctx, p)   duk__emit_cstring((js_ctx), (p))
 
#define DUK__EMIT_STRIDX(js_ctx, i)   duk__emit_stridx((js_ctx), (i))
 
#define DUK__UNEMIT_1(js_ctx)   duk__unemit_1((js_ctx))
 
#define DUK__MKESC(nybbles, esc1, esc2)
 
#define DUK__BITPACK_LETTER_LIMIT   26
 
#define DUK__BITPACK_UNDERSCORE   26
 
#define DUK__BITPACK_FF   27
 
#define DUK__BITPACK_SWITCH1   29
 
#define DUK__BITPACK_SWITCH   30
 
#define DUK__BITPACK_SEVENBIT   31
 
#define DUK__VOLUNTARY_PERIODIC_GC(heap)
 
#define DUK__HASH_INITIAL(hash, h_size)   DUK_STRTAB_HASH_INITIAL((hash),(h_size))
 
#define DUK__HASH_PROBE_STEP(hash)   DUK_STRTAB_HASH_PROBE_STEP((hash))
 
#define DUK__DELETED_MARKER(heap)   DUK_STRTAB_DELETED_MARKER((heap))
 
#define DUK__PREVENT_MS_SIDE_EFFECTS(heap)
 
#define DUK__ENUM_START_INDEX   2
 
#define DUK__NO_ARRAY_INDEX   DUK_HSTRING_NO_ARRAY_INDEX
 
#define DUK__HASH_INITIAL(hash, h_size)   DUK_HOBJECT_HASH_INITIAL((hash),(h_size))
 
#define DUK__HASH_PROBE_STEP(hash)   DUK_HOBJECT_HASH_PROBE_STEP((hash))
 
#define DUK__HASH_UNUSED   DUK_HOBJECT_HASHIDX_UNUSED
 
#define DUK__HASH_DELETED   DUK_HOBJECT_HASHIDX_DELETED
 
#define DUK__VALSTACK_SPACE   10
 
#define DUK__VALSTACK_PROXY_LOOKUP   20
 
#define DUK__CLASS_BITS   5
 
#define DUK__BIDX_BITS   7
 
#define DUK__STRIDX_BITS   9 /* XXX: try to optimize to 8 (would now be possible, <200 used) */
 
#define DUK__NATIDX_BITS   8
 
#define DUK__NUM_NORMAL_PROPS_BITS   6
 
#define DUK__NUM_FUNC_PROPS_BITS   6
 
#define DUK__PROP_FLAGS_BITS   3
 
#define DUK__STRING_LENGTH_BITS   8
 
#define DUK__STRING_CHAR_BITS   7
 
#define DUK__LENGTH_PROP_BITS   3
 
#define DUK__NARGS_BITS   3
 
#define DUK__PROP_TYPE_BITS   3
 
#define DUK__MAGIC_BITS   16
 
#define DUK__NARGS_VARARGS_MARKER   0x07
 
#define DUK__NO_CLASS_MARKER   0x00 /* 0 = DUK_HOBJECT_CLASS_UNUSED */
 
#define DUK__NO_BIDX_MARKER   0x7f
 
#define DUK__NO_STRIDX_MARKER   0xff
 
#define DUK__PROP_TYPE_DOUBLE   0
 
#define DUK__PROP_TYPE_STRING   1
 
#define DUK__PROP_TYPE_STRIDX   2
 
#define DUK__PROP_TYPE_BUILTIN   3
 
#define DUK__PROP_TYPE_UNDEFINED   4
 
#define DUK__PROP_TYPE_BOOLEAN_TRUE   5
 
#define DUK__PROP_TYPE_BOOLEAN_FALSE   6
 
#define DUK__PROP_TYPE_ACCESSOR   7
 
#define DUK__CONST_MARKER   DUK_JS_CONST_MARKER
 
#define DUK__MAX_ARRAY_INIT_VALUES   20
 
#define DUK__MAX_OBJECT_INIT_PAIRS   10
 
#define DUK__GETCONST_MAX_CONSTS_CHECK   256
 
#define DUK__MAX_CONSTS   DUK_BC_BC_MAX
 
#define DUK__MAX_FUNCS   DUK_BC_BC_MAX
 
#define DUK__MAX_TEMPS   0xffffL
 
#define DUK__BC_INITIAL_INSTS   256
 
#define DUK__RECURSION_INCREASE(comp_ctx, thr)
 
#define DUK__RECURSION_DECREASE(comp_ctx, thr)
 
#define DUK__COMPILE_ENTRY_SLOTS   8
 
#define DUK__FUNCTION_INIT_REQUIRE_SLOTS   16
 
#define DUK__FUNCTION_BODY_REQUIRE_SLOTS   16
 
#define DUK__PARSE_STATEMENTS_SLOTS   16
 
#define DUK__PARSE_EXPR_SLOTS   16
 
#define DUK__BP_INVALID   0 /* always terminates led() */
 
#define DUK__BP_EOF   2
 
#define DUK__BP_CLOSING   4 /* token closes expression, e.g. ')', ']' */
 
#define DUK__BP_FOR_EXPR   DUK__BP_CLOSING /* bp to use when parsing a top level Expression */
 
#define DUK__BP_COMMA   6
 
#define DUK__BP_ASSIGNMENT   8
 
#define DUK__BP_CONDITIONAL   10
 
#define DUK__BP_LOR   12
 
#define DUK__BP_LAND   14
 
#define DUK__BP_BOR   16
 
#define DUK__BP_BXOR   18
 
#define DUK__BP_BAND   20
 
#define DUK__BP_EQUALITY   22
 
#define DUK__BP_RELATIONAL   24
 
#define DUK__BP_SHIFT   26
 
#define DUK__BP_ADDITIVE   28
 
#define DUK__BP_MULTIPLICATIVE   30
 
#define DUK__BP_POSTFIX   32
 
#define DUK__BP_CALL   34
 
#define DUK__BP_MEMBER   36
 
#define DUK__TOKEN_LBP_BP_MASK   0x1f
 
#define DUK__TOKEN_LBP_FLAG_NO_REGEXP   (1 << 5) /* regexp literal must not follow this token */
 
#define DUK__TOKEN_LBP_FLAG_TERMINATES   (1 << 6) /* terminates expression; e.g. post-increment/-decrement */
 
#define DUK__TOKEN_LBP_FLAG_UNUSED   (1 << 7) /* spare */
 
#define DUK__TOKEN_LBP_GET_BP(x)   ((duk_small_uint_t) (((x) & DUK__TOKEN_LBP_BP_MASK) * 2))
 
#define DUK__MK_LBP(bp)   ((bp) >> 1) /* bp is assumed to be even */
 
#define DUK__MK_LBP_FLAGS(bp, flags)   (((bp) >> 1) | (flags))
 
#define DUK__EMIT_FLAG_NO_SHUFFLE_A   (1 << 8)
 
#define DUK__EMIT_FLAG_NO_SHUFFLE_B   (1 << 9)
 
#define DUK__EMIT_FLAG_NO_SHUFFLE_C   (1 << 10)
 
#define DUK__EMIT_FLAG_A_IS_SOURCE   (1 << 11) /* slot A is a source (default: target) */
 
#define DUK__EMIT_FLAG_B_IS_TARGET   (1 << 12) /* slot B is a target (default: source) */
 
#define DUK__EMIT_FLAG_C_IS_TARGET   (1 << 13) /* slot C is a target (default: source) */
 
#define DUK__EMIT_FLAG_B_IS_TARGETSOURCE   (1 << 14) /* slot B is both a target and a source (used by extraops like DUK_EXTRAOP_INSTOF */
 
#define DUK__EMIT_FLAG_RESERVE_JUMPSLOT   (1 << 15) /* reserve a jumpslot after instr before target spilling, used for NEXTENUM */
 
#define DUK__ISREG(comp_ctx, x)   (((x) & DUK__CONST_MARKER) == 0)
 
#define DUK__ISCONST(comp_ctx, x)   (((x) & DUK__CONST_MARKER) != 0)
 
#define DUK__ISTEMP(comp_ctx, x)   (DUK__ISREG((comp_ctx), (x)) && (duk_regconst_t) (x) >= (duk_regconst_t) ((comp_ctx)->curr_func.temp_first))
 
#define DUK__GETTEMP(comp_ctx)   ((comp_ctx)->curr_func.temp_next)
 
#define DUK__SETTEMP(comp_ctx, x)   ((comp_ctx)->curr_func.temp_next = (x)) /* dangerous: must only lower (temp_max not updated) */
 
#define DUK__SETTEMP_CHECKMAX(comp_ctx, x)   duk__settemp_checkmax((comp_ctx),(x))
 
#define DUK__ALLOCTEMP(comp_ctx)   duk__alloctemp((comp_ctx))
 
#define DUK__ALLOCTEMPS(comp_ctx, count)   duk__alloctemps((comp_ctx),(count))
 
#define DUK__IVAL_FLAG_ALLOW_CONST   (1 << 0) /* allow a constant to be returned */
 
#define DUK__IVAL_FLAG_REQUIRE_TEMP   (1 << 1) /* require a (mutable) temporary as a result (or a const if allowed) */
 
#define DUK__IVAL_FLAG_REQUIRE_SHORT   (1 << 2) /* require a short (8-bit) reg/const which fits into bytecode B/C slot */
 
#define DUK__DUMP_ISPEC(comp_ctx, x)   do {} while (0)
 
#define DUK__DUMP_IVALUE(comp_ctx, x)   do {} while (0)
 
#define DUK__OBJ_LIT_KEY_PLAIN   (1 << 0) /* key encountered as a plain property */
 
#define DUK__OBJ_LIT_KEY_GET   (1 << 1) /* key encountered as a getter */
 
#define DUK__OBJ_LIT_KEY_SET   (1 << 2) /* key encountered as a setter */
 
#define DUK__EXPR_RBP_MASK   0xff
 
#define DUK__EXPR_FLAG_REJECT_IN   (1 << 8) /* reject 'in' token (used for for-in) */
 
#define DUK__EXPR_FLAG_ALLOW_EMPTY   (1 << 9) /* allow empty expression */
 
#define DUK__EXPR_FLAG_REQUIRE_INIT   (1 << 10) /* require initializer for var/const */
 
#define DUK__HAS_VAL   (1 << 0) /* stmt has non-empty value */
 
#define DUK__HAS_TERM   (1 << 1) /* stmt has explicit/implicit semicolon terminator */
 
#define DUK__ALLOW_AUTO_SEMI_ALWAYS   (1 << 2) /* allow automatic semicolon even without lineterm (compatibility) */
 
#define DUK__STILL_PROLOGUE   (1 << 3) /* statement does not terminate directive prologue */
 
#define DUK__IS_TERMINAL   (1 << 4) /* statement is guaranteed to be terminal (control doesn't flow to next statement) */
 
#define DUK__LONGJMP_RESTART   0 /* state updated, restart bytecode execution */
 
#define DUK__LONGJMP_RETHROW   1 /* exit bytecode executor by rethrowing an error to caller */
 
#define DUK__RETHAND_RESTART   0 /* state updated, restart bytecode execution */
 
#define DUK__RETHAND_FINISHED   1 /* exit bytecode execution with return value */
 
#define DUK__FUN()   ((duk_hcompiledfunction *) DUK_ACT_GET_FUNC((thr)->callstack + (thr)->callstack_top - 1))
 
#define DUK__STRICT()   (DUK_HOBJECT_HAS_STRICT((duk_hobject *) DUK__FUN()))
 
#define DUK__REG(x)   (*(thr->valstack_bottom + (x)))
 
#define DUK__REGP(x)   (thr->valstack_bottom + (x))
 
#define DUK__CONST(x)   (*(consts + (x)))
 
#define DUK__CONSTP(x)   (consts + (x))
 
#define DUK__RCISREG(x)   (((x) & 0x100) == 0)
 
#define DUK__REGCONST(x)   (*((DUK__RCISREG((x)) ? thr->valstack_bottom : consts2) + (x)))
 
#define DUK__REGCONSTP(x)   ((DUK__RCISREG((x)) ? thr->valstack_bottom : consts2) + (x))
 
#define DUK__INTERNAL_ERROR(msg)
 
#define DUK__SYNC_CURR_PC()
 
#define DUK__SYNC_AND_NULL_CURR_PC()
 
#define DUK__MAX_RE_DECESC_DIGITS   9
 
#define DUK__MAX_RE_QUANT_DIGITS   9 /* Does not allow e.g. 2**31-1, but one more would allow overflows of u32. */
 
#define DUK__ISDIGIT(x)   ((x) >= DUK_ASC_0 && (x) <= DUK_ASC_9)
 
#define DUK__ISHEXDIGIT(x)   duk__is_hex_digit((x))
 
#define DUK__ISOCTDIGIT(x)   ((x) >= DUK_ASC_0 && (x) <= DUK_ASC_7)
 
#define DUK__ISDIGIT03(x)   ((x) >= DUK_ASC_0 && (x) <= DUK_ASC_3)
 
#define DUK__ISDIGIT47(x)   ((x) >= DUK_ASC_4 && (x) <= DUK_ASC_7)
 
#define DUK__LOOKUP(lex_ctx, index)   ((lex_ctx)->window[(index)].codepoint)
 
#define DUK__ADVANCECHARS(lex_ctx, count)   duk__advance_bytes((lex_ctx), (count) * sizeof(duk_lexer_codepoint))
 
#define DUK__ADVANCEBYTES(lex_ctx, count)   duk__advance_bytes((lex_ctx), (count))
 
#define DUK__INITBUFFER(lex_ctx)   duk__initbuffer((lex_ctx))
 
#define DUK__APPENDBUFFER(lex_ctx, x)   duk__appendbuffer((lex_ctx), (duk_codepoint_t) (x))
 
#define DUK__L0()   DUK__LOOKUP(lex_ctx, 0)
 
#define DUK__L1()   DUK__LOOKUP(lex_ctx, 1)
 
#define DUK__L2()   DUK__LOOKUP(lex_ctx, 2)
 
#define DUK__L3()   DUK__LOOKUP(lex_ctx, 3)
 
#define DUK__L4()   DUK__LOOKUP(lex_ctx, 4)
 
#define DUK__L5()   DUK__LOOKUP(lex_ctx, 5)
 
#define DUK__ADVTOK(advbytes, tok)   ((((advbytes) * sizeof(duk_lexer_codepoint)) << 8) + (tok))
 
#define DUK__IEEE_DOUBLE_EXP_BIAS   1023
 
#define DUK__IEEE_DOUBLE_EXP_MIN   (-1022) /* biased exp == 0 -> denormal, exp -1022 */
 
#define DUK__DIGITCHAR(x)   duk_lc_digits[(x)]
 
#define DUK__BI_MAX_PARTS   37 /* 37x32 = 1184 bits */
 
#define DUK__BI_PRINT(name, x)
 
#define DUK__MAX_OUTPUT_DIGITS   1040 /* (Number.MAX_VALUE).toString(2).length == 1024, + spare */
 
#define DUK__MAX_FORMATTED_LENGTH   1040 /* (-Number.MAX_VALUE).toString(2).length == 1025, + spare */
 
#define DUK__NUMCONV_CTX_NUM_BIGINTS   7
 
#define DUK__NUMCONV_CTX_BIGINTS_SIZE   (sizeof(duk__bigint) * DUK__NUMCONV_CTX_NUM_BIGINTS)
 
#define DUK__DRAGON4_OUTPUT_PREINC(nc_ctx, preinc_idx, x)
 
#define DUK__NO_EXP   (65536) /* arbitrary marker, outside valid exp range */
 
#define DUK__RE_INITIAL_BUFSIZE   64
 
#define DUK__RE_BUFLEN(re_ctx)    DUK_BW_GET_SIZE(re_ctx->thr, &re_ctx->bw)
 
#define DUK__UPDATE_RND(rnd)
 
#define DUK__RND_BIT(rnd)   ((rnd) >> 31) /* only use the highest bit */
 

Typedefs

typedef struct duk_jmpbuf duk_jmpbuf
 
typedef struct duk_heaphdr duk_heaphdr
 
typedef struct duk_heaphdr_string duk_heaphdr_string
 
typedef struct duk_hstring duk_hstring
 
typedef struct duk_hstring_external duk_hstring_external
 
typedef struct duk_hobject duk_hobject
 
typedef struct duk_hcompiledfunction duk_hcompiledfunction
 
typedef struct duk_hnativefunction duk_hnativefunction
 
typedef struct duk_hbufferobject duk_hbufferobject
 
typedef struct duk_hthread duk_hthread
 
typedef struct duk_hbuffer duk_hbuffer
 
typedef struct duk_hbuffer_fixed duk_hbuffer_fixed
 
typedef struct duk_hbuffer_dynamic duk_hbuffer_dynamic
 
typedef struct duk_hbuffer_external duk_hbuffer_external
 
typedef struct duk_propaccessor duk_propaccessor
 
typedef union duk_propvalue duk_propvalue
 
typedef struct duk_propdesc duk_propdesc
 
typedef struct duk_heap duk_heap
 
typedef struct duk_breakpoint duk_breakpoint
 
typedef struct duk_activation duk_activation
 
typedef struct duk_catcher duk_catcher
 
typedef struct duk_strcache duk_strcache
 
typedef struct duk_ljstate duk_ljstate
 
typedef struct duk_strtab_entry duk_strtab_entry
 
typedef struct duk_bitdecoder_ctx duk_bitdecoder_ctx
 
typedef struct duk_bitencoder_ctx duk_bitencoder_ctx
 
typedef struct duk_bufwriter_ctx duk_bufwriter_ctx
 
typedef struct duk_token duk_token
 
typedef struct duk_re_token duk_re_token
 
typedef struct duk_lexer_point duk_lexer_point
 
typedef struct duk_lexer_ctx duk_lexer_ctx
 
typedef struct duk_lexer_codepoint duk_lexer_codepoint
 
typedef struct duk_compiler_instr duk_compiler_instr
 
typedef struct duk_compiler_func duk_compiler_func
 
typedef struct duk_compiler_ctx duk_compiler_ctx
 
typedef struct duk_re_matcher_ctx duk_re_matcher_ctx
 
typedef struct duk_re_compiler_ctx duk_re_compiler_ctx
 
typedef struct duk_tval_struct duk_tval
 
typedef duk_uint32_t duk_instr_t
 
typedef void(* duk_re_range_callback) (void *user, duk_codepoint_t r1, duk_codepoint_t r2, duk_bool_t direct)
 
typedef duk_uint32_t duk_regconst_t
 
typedef duk_int32_t duk_reg_t
 
typedef void *(* duk_mem_getptr) (duk_heap *heap, void *ud)
 
typedef struct duk__compile_raw_args duk__compile_raw_args
 
typedef struct duk_internal_thread_state duk_internal_thread_state
 
typedef duk_double_t(* duk__toint_coercer) (duk_hthread *thr, duk_tval *tv)
 
typedef void(* duk__transform_callback) (duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp)
 
typedef double(* duk__one_arg_func) (double)
 
typedef double(* duk__two_arg_func) (double, double)
 

Functions

DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_function_constructor (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_constructor (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_constructor (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_boolean_constructor (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_number_constructor (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_constructor (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_constructor (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_error_constructor_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_type_error_thrower (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_proxy_constructor (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_thread_constructor (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_constructor (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_pointer_constructor (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_logger_constructor (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_arraybuffer_constructor (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_dataview_constructor (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_typedarray_constructor (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_constructor (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_eval (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_int (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_float (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_is_nan (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_is_finite (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_decode_uri (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_decode_uri_component (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_encode_uri (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_encode_uri_component (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_escape (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_unescape (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_print_helper (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_require (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_getprototype_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_setprototype_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_get_own_property_descriptor (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_keys_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_create (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_define_property (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_define_properties (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_seal_freeze_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_prevent_extensions (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_is_sealed_frozen_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_is_extensible (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_to_string (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_to_locale_string (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_value_of (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_has_own_property (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_is_prototype_of (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_property_is_enumerable (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype_to_string (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype_apply (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype_call (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype_bind (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_constructor_is_array (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_to_string (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_join_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_concat (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_pop (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_push (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_reverse (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_shift (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_slice (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_sort (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_splice (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_unshift (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_indexof_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_iter_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_reduce_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_constructor_from_char_code (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_to_string (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_char_at (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_char_code_at (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_concat (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_indexof_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_locale_compare (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_match (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_replace (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_search (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_slice (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_split (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_substring (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_caseconv_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_trim (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_substr (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_boolean_prototype_tostring_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_string (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_locale_string (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_value_of (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_fixed (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_exponential (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_precision (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_constructor_parse (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_constructor_utc (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_constructor_now (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_tostring_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_to_json (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_value_of (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_get_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_get_timezone_offset (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_set_time (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_set_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_prototype_exec (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_prototype_test (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_prototype_to_string (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_stack_getter (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_stack_setter (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_filename_getter (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_filename_setter (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_linenumber_getter (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_linenumber_setter (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_to_string (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_onearg_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_twoarg_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_max (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_min (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_random (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_json_object_parse (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_json_object_stringify (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_info (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_act (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_gc (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_fin (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_enc (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_dec (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_compact (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_thread_yield (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_thread_resume (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_thread_current (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_prototype_tostring_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_pointer_prototype_tostring_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_logger_prototype_fmt (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_logger_prototype_raw (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_logger_prototype_log_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_arraybuffer_isview (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_slice_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_readfield (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_writefield (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_typedarray_set (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_concat (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_is_encoding (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_is_buffer (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_byte_length (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_compare_shared (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_tostring (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_tojson (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_fill (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_copy (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_write (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_uint32_t duk_util_get_hash_prime (duk_uint32_t size)
 
DUK_INTERNAL_DECL duk_int32_t duk_bd_decode (duk_bitdecoder_ctx *ctx, duk_small_int_t bits)
 
DUK_INTERNAL_DECL duk_small_int_t duk_bd_decode_flag (duk_bitdecoder_ctx *ctx)
 
DUK_INTERNAL_DECL duk_int32_t duk_bd_decode_flagged (duk_bitdecoder_ctx *ctx, duk_small_int_t bits, duk_int32_t def_value)
 
DUK_INTERNAL_DECL void duk_be_encode (duk_bitencoder_ctx *ctx, duk_uint32_t data, duk_small_int_t bits)
 
DUK_INTERNAL_DECL void duk_be_finish (duk_bitencoder_ctx *ctx)
 
DUK_INTERNAL_DECL duk_uint32_t duk_util_tinyrandom_get_bits (duk_hthread *thr, duk_small_int_t n)
 
DUK_INTERNAL_DECL duk_double_t duk_util_tinyrandom_get_double (duk_hthread *thr)
 
DUK_INTERNAL_DECL void duk_bw_init (duk_hthread *thr, duk_bufwriter_ctx *bw_ctx, duk_hbuffer_dynamic *h_buf)
 
DUK_INTERNAL_DECL void duk_bw_init_pushbuf (duk_hthread *thr, duk_bufwriter_ctx *bw_ctx, duk_size_t buf_size)
 
DUK_INTERNAL_DECL duk_uint8_t * duk_bw_resize (duk_hthread *thr, duk_bufwriter_ctx *bw_ctx, duk_size_t sz)
 
DUK_INTERNAL_DECL void duk_bw_compact (duk_hthread *thr, duk_bufwriter_ctx *bw_ctx)
 
DUK_INTERNAL_DECL void duk_bw_write_raw_slice (duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t src_off, duk_size_t len)
 
DUK_INTERNAL_DECL void duk_bw_write_ensure_slice (duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t src_off, duk_size_t len)
 
DUK_INTERNAL_DECL void duk_bw_insert_raw_bytes (duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t dst_off, const duk_uint8_t *buf, duk_size_t len)
 
DUK_INTERNAL_DECL void duk_bw_insert_ensure_bytes (duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t dst_off, const duk_uint8_t *buf, duk_size_t len)
 
DUK_INTERNAL_DECL void duk_bw_insert_raw_slice (duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t dst_off, duk_size_t src_off, duk_size_t len)
 
DUK_INTERNAL_DECL void duk_bw_insert_ensure_slice (duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t dst_off, duk_size_t src_off, duk_size_t len)
 
DUK_INTERNAL_DECL duk_uint8_t * duk_bw_insert_raw_area (duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t off, duk_size_t len)
 
DUK_INTERNAL_DECL duk_uint8_t * duk_bw_insert_ensure_area (duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t off, duk_size_t len)
 
DUK_INTERNAL_DECL void duk_bw_remove_raw_slice (duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t off, duk_size_t len)
 
DUK_INTERNAL_DECL duk_uint16_t duk_raw_read_u16_be (duk_uint8_t **p)
 
DUK_INTERNAL_DECL duk_uint32_t duk_raw_read_u32_be (duk_uint8_t **p)
 
DUK_INTERNAL_DECL duk_double_t duk_raw_read_double_be (duk_uint8_t **p)
 
DUK_INTERNAL_DECL void duk_raw_write_u16_be (duk_uint8_t **p, duk_uint16_t val)
 
DUK_INTERNAL_DECL void duk_raw_write_u32_be (duk_uint8_t **p, duk_uint32_t val)
 
DUK_INTERNAL_DECL void duk_raw_write_double_be (duk_uint8_t **p, duk_double_t val)
 
DUK_INTERNAL_DECL void duk_lexer_initctx (duk_lexer_ctx *lex_ctx)
 
DUK_INTERNAL_DECL void duk_lexer_setpoint (duk_lexer_ctx *lex_ctx, duk_lexer_point *pt)
 
DUK_INTERNAL_DECL void duk_lexer_parse_js_input_element (duk_lexer_ctx *lex_ctx, duk_token *out_token, duk_bool_t strict_mode, duk_bool_t regexp_mode)
 
DUK_INTERNAL_DECL void duk_lexer_parse_re_token (duk_lexer_ctx *lex_ctx, duk_re_token *out_token)
 
DUK_INTERNAL_DECL void duk_lexer_parse_re_ranges (duk_lexer_ctx *lex_ctx, duk_re_range_callback gen_range, void *userdata)
 
DUK_INTERNAL_DECL void duk_js_compile (duk_hthread *thr, const duk_uint8_t *src_buffer, duk_size_t src_length, duk_small_uint_t flags)
 
DUK_INTERNAL_DECL void duk_regexp_compile (duk_hthread *thr)
 
DUK_INTERNAL_DECL void duk_regexp_create_instance (duk_hthread *thr)
 
DUK_INTERNAL_DECL void duk_regexp_match (duk_hthread *thr)
 
DUK_INTERNAL_DECL void duk_regexp_match_force_global (duk_hthread *thr)
 
DUK_INTERNAL_DECL duk_bool_t duk_valstack_resize_raw (duk_context *ctx, duk_size_t min_new_size, duk_small_uint_t flags)
 
DUK_INTERNAL_DECL duk_tvalduk_get_tval (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL duk_tvalduk_require_tval (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL void duk_push_tval (duk_context *ctx, duk_tval *tv)
 
DUK_INTERNAL_DECL void duk_push_this_check_object_coercible (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_hobjectduk_push_this_coercible_to_object (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_hstringduk_push_this_coercible_to_string (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_tvalduk_get_borrowed_this_tval (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_hstringduk_get_hstring (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL duk_hobjectduk_get_hobject (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL duk_hbufferduk_get_hbuffer (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL duk_hthreadduk_get_hthread (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL duk_hcompiledfunctionduk_get_hcompiledfunction (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL duk_hnativefunctionduk_get_hnativefunction (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL duk_hobjectduk_get_hobject_with_class (duk_context *ctx, duk_idx_t index, duk_small_uint_t classnum)
 
DUK_INTERNAL_DECL duk_hobjectduk_get_hobject_or_lfunc_coerce (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL duk_hstringduk_to_hstring (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL void duk_to_object_class_string_top (duk_context *ctx)
 
DUK_INTERNAL_DECL void duk_push_hobject_class_string (duk_context *ctx, duk_hobject *h)
 
DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped_raw (duk_context *ctx, duk_idx_t index, duk_int_t minval, duk_int_t maxval, duk_bool_t *out_clamped)
 
DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped (duk_context *ctx, duk_idx_t index, duk_int_t minval, duk_int_t maxval)
 
DUK_INTERNAL_DECL duk_int_t duk_to_int_check_range (duk_context *ctx, duk_idx_t index, duk_int_t minval, duk_int_t maxval)
 
DUK_INTERNAL_DECL duk_uint8_t duk_to_uint8clamped (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL duk_hstringduk_require_hstring (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL duk_hobjectduk_require_hobject (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL duk_hbufferduk_require_hbuffer (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL duk_hthreadduk_require_hthread (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL duk_hcompiledfunctionduk_require_hcompiledfunction (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL duk_hnativefunctionduk_require_hnativefunction (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL duk_hobjectduk_require_hobject_with_class (duk_context *ctx, duk_idx_t index, duk_small_uint_t classnum)
 
DUK_INTERNAL_DECL duk_hobjectduk_require_hobject_or_lfunc (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL duk_hobjectduk_require_hobject_or_lfunc_coerce (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL void duk_push_hstring (duk_context *ctx, duk_hstring *h)
 
DUK_INTERNAL_DECL void duk_push_hstring_stridx (duk_context *ctx, duk_small_int_t stridx)
 
DUK_INTERNAL_DECL void duk_push_hobject (duk_context *ctx, duk_hobject *h)
 
DUK_INTERNAL_DECL void duk_push_hbuffer (duk_context *ctx, duk_hbuffer *h)
 
DUK_INTERNAL_DECL void duk_push_hobject_bidx (duk_context *ctx, duk_small_int_t builtin_idx)
 
DUK_INTERNAL_DECL duk_idx_t duk_push_object_helper (duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_small_int_t prototype_bidx)
 
DUK_INTERNAL_DECL duk_idx_t duk_push_object_helper_proto (duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_hobject *proto)
 
DUK_INTERNAL_DECL duk_idx_t duk_push_object_internal (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_idx_t duk_push_compiledfunction (duk_context *ctx)
 
DUK_INTERNAL_DECL void duk_push_c_function_noexotic (duk_context *ctx, duk_c_function func, duk_int_t nargs)
 
DUK_INTERNAL_DECL void duk_push_c_function_noconstruct_noexotic (duk_context *ctx, duk_c_function func, duk_int_t nargs)
 
DUK_INTERNAL_DECL void duk_push_string_funcptr (duk_context *ctx, duk_uint8_t *ptr, duk_size_t sz)
 
DUK_INTERNAL_DECL void duk_push_lightfunc_name (duk_context *ctx, duk_tval *tv)
 
DUK_INTERNAL_DECL void duk_push_lightfunc_tostring (duk_context *ctx, duk_tval *tv)
 
DUK_INTERNAL_DECL duk_hbufferobjectduk_push_bufferobject_raw (duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_small_int_t prototype_bidx)
 
DUK_INTERNAL_DECL const char * duk_push_string_readable (duk_context *ctx, duk_idx_t index)
 
DUK_INTERNAL_DECL const char * duk_push_string_tval_readable (duk_context *ctx, duk_tval *tv)
 
DUK_INTERNAL_DECL duk_bool_t duk_get_prop_stridx (duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx)
 
DUK_INTERNAL_DECL duk_bool_t duk_put_prop_stridx (duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx)
 
DUK_INTERNAL_DECL duk_bool_t duk_del_prop_stridx (duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx)
 
DUK_INTERNAL_DECL duk_bool_t duk_has_prop_stridx (duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx)
 
DUK_INTERNAL_DECL duk_bool_t duk_get_prop_stridx_boolean (duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_bool_t *out_has_prop)
 
DUK_INTERNAL_DECL void duk_xdef_prop (duk_context *ctx, duk_idx_t obj_index, duk_small_uint_t desc_flags)
 
DUK_INTERNAL_DECL void duk_xdef_prop_index (duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index, duk_small_uint_t desc_flags)
 
DUK_INTERNAL_DECL void duk_xdef_prop_stridx (duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_uint_t desc_flags)
 
DUK_INTERNAL_DECL void duk_xdef_prop_stridx_builtin (duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_int_t builtin_idx, duk_small_uint_t desc_flags)
 
DUK_INTERNAL_DECL void duk_xdef_prop_stridx_thrower (duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_uint_t desc_flags)
 
DUK_INTERNAL_DECL void duk_set_length (duk_context *ctx, duk_idx_t index, duk_size_t length)
 
DUK_INTERNAL_DECL duk_ucodepoint_t duk_hstring_char_code_at_raw (duk_hthread *thr, duk_hstring *h, duk_uint_t pos)
 
DUK_INTERNAL_DECL duk_hobjectduk_hobject_alloc (duk_heap *heap, duk_uint_t hobject_flags)
 
DUK_INTERNAL_DECL duk_hcompiledfunctionduk_hcompiledfunction_alloc (duk_heap *heap, duk_uint_t hobject_flags)
 
DUK_INTERNAL_DECL duk_hnativefunctionduk_hnativefunction_alloc (duk_heap *heap, duk_uint_t hobject_flags)
 
DUK_INTERNAL duk_hbufferobjectduk_hbufferobject_alloc (duk_heap *heap, duk_uint_t hobject_flags)
 
DUK_INTERNAL_DECL duk_hthreadduk_hthread_alloc (duk_heap *heap, duk_uint_t hobject_flags)
 
DUK_INTERNAL_DECL void duk_hobject_find_existing_entry (duk_heap *heap, duk_hobject *obj, duk_hstring *key, duk_int_t *e_idx, duk_int_t *h_idx)
 
DUK_INTERNAL_DECL duk_tvalduk_hobject_find_existing_entry_tval_ptr (duk_heap *heap, duk_hobject *obj, duk_hstring *key)
 
DUK_INTERNAL_DECL duk_tvalduk_hobject_find_existing_entry_tval_ptr_and_attrs (duk_heap *heap, duk_hobject *obj, duk_hstring *key, duk_int_t *out_attrs)
 
DUK_INTERNAL_DECL duk_tvalduk_hobject_find_existing_array_entry_tval_ptr (duk_heap *heap, duk_hobject *obj, duk_uarridx_t i)
 
DUK_INTERNAL_DECL duk_bool_t duk_hobject_get_own_propdesc (duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *out_desc, duk_small_uint_t flags)
 
DUK_INTERNAL_DECL duk_bool_t duk_hobject_getprop (duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key)
 
DUK_INTERNAL_DECL duk_bool_t duk_hobject_putprop (duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key, duk_tval *tv_val, duk_bool_t throw_flag)
 
DUK_INTERNAL_DECL duk_bool_t duk_hobject_delprop (duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key, duk_bool_t throw_flag)
 
DUK_INTERNAL_DECL duk_bool_t duk_hobject_hasprop (duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key)
 
DUK_INTERNAL_DECL duk_bool_t duk_hobject_delprop_raw (duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_small_uint_t flags)
 
DUK_INTERNAL_DECL duk_bool_t duk_hobject_hasprop_raw (duk_hthread *thr, duk_hobject *obj, duk_hstring *key)
 
DUK_INTERNAL_DECL void duk_hobject_define_property_internal (duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_small_uint_t flags)
 
DUK_INTERNAL_DECL void duk_hobject_define_property_internal_arridx (duk_hthread *thr, duk_hobject *obj, duk_uarridx_t arr_idx, duk_small_uint_t flags)
 
DUK_INTERNAL_DECL void duk_hobject_define_accessor_internal (duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_hobject *getter, duk_hobject *setter, duk_small_uint_t propflags)
 
DUK_INTERNAL_DECL void duk_hobject_set_length (duk_hthread *thr, duk_hobject *obj, duk_uint32_t length)
 
DUK_INTERNAL_DECL void duk_hobject_set_length_zero (duk_hthread *thr, duk_hobject *obj)
 
DUK_INTERNAL_DECL duk_uint32_t duk_hobject_get_length (duk_hthread *thr, duk_hobject *obj)
 
DUK_INTERNAL_DECL void duk_hobject_prepare_property_descriptor (duk_context *ctx, duk_idx_t idx_in, duk_uint_t *out_defprop_flags, duk_idx_t *out_idx_value, duk_hobject **out_getter, duk_hobject **out_setter)
 
DUK_INTERNAL_DECL void duk_hobject_define_property_helper (duk_context *ctx, duk_uint_t defprop_flags, duk_hobject *obj, duk_hstring *key, duk_idx_t idx_value, duk_hobject *get, duk_hobject *set)
 
DUK_INTERNAL_DECL duk_ret_t duk_hobject_object_get_own_property_descriptor (duk_context *ctx)
 
DUK_INTERNAL_DECL void duk_hobject_object_seal_freeze_helper (duk_hthread *thr, duk_hobject *obj, duk_bool_t is_freeze)
 
DUK_INTERNAL_DECL duk_bool_t duk_hobject_object_is_sealed_frozen_helper (duk_hthread *thr, duk_hobject *obj, duk_bool_t is_frozen)
 
DUK_INTERNAL_DECL duk_bool_t duk_hobject_object_ownprop_helper (duk_context *ctx, duk_small_uint_t required_desc_flags)
 
DUK_INTERNAL_DECL duk_bool_t duk_hobject_get_internal_value (duk_heap *heap, duk_hobject *obj, duk_tval *tv)
 
DUK_INTERNAL_DECL duk_hstringduk_hobject_get_internal_value_string (duk_heap *heap, duk_hobject *obj)
 
DUK_INTERNAL_DECL void duk_hobject_compact_props (duk_hthread *thr, duk_hobject *obj)
 
DUK_INTERNAL_DECL duk_bool_t duk_hobject_proxy_check (duk_hthread *thr, duk_hobject *obj, duk_hobject **out_target, duk_hobject **out_handler)
 
DUK_INTERNAL_DECL duk_hobjectduk_hobject_resolve_proxy_target (duk_hthread *thr, duk_hobject *obj)
 
DUK_INTERNAL_DECL void duk_hobject_enumerator_create (duk_context *ctx, duk_small_uint_t enum_flags)
 
DUK_INTERNAL_DECL duk_ret_t duk_hobject_get_enumerated_keys (duk_context *ctx, duk_small_uint_t enum_flags)
 
DUK_INTERNAL_DECL duk_bool_t duk_hobject_enumerator_next (duk_context *ctx, duk_bool_t get_value)
 
DUK_INTERNAL_DECL void duk_hobject_set_prototype_updref (duk_hthread *thr, duk_hobject *h, duk_hobject *p)
 
DUK_INTERNAL_DECL void duk_hobject_run_finalizer (duk_hthread *thr, duk_hobject *obj)
 
DUK_INTERNAL_DECL void duk_hobject_pc2line_pack (duk_hthread *thr, duk_compiler_instr *instrs, duk_uint_fast32_t length)
 
DUK_INTERNAL_DECL duk_uint_fast32_t duk_hobject_pc2line_query (duk_context *ctx, duk_idx_t idx_func, duk_uint_fast32_t pc)
 
DUK_INTERNAL_DECL duk_bool_t duk_hobject_prototype_chain_contains (duk_hthread *thr, duk_hobject *h, duk_hobject *p, duk_bool_t ignore_loop)
 
DUK_INTERNAL_DECL duk_uint_t duk_hbufferobject_clamp_bytelength (duk_hbufferobject *h_bufobj, duk_uint_t len)
 
DUK_INTERNAL_DECL void duk_hbufferobject_push_validated_read (duk_context *ctx, duk_hbufferobject *h_bufobj, duk_uint8_t *p, duk_small_uint_t elem_size)
 
DUK_INTERNAL_DECL void duk_hbufferobject_validated_write (duk_context *ctx, duk_hbufferobject *h_bufobj, duk_uint8_t *p, duk_small_uint_t elem_size)
 
DUK_INTERNAL_DECL void duk_hthread_copy_builtin_objects (duk_hthread *thr_from, duk_hthread *thr_to)
 
DUK_INTERNAL_DECL void duk_hthread_create_builtin_objects (duk_hthread *thr)
 
DUK_INTERNAL_DECL duk_bool_t duk_hthread_init_stacks (duk_heap *heap, duk_hthread *thr)
 
DUK_INTERNAL_DECL void duk_hthread_terminate (duk_hthread *thr)
 
DUK_INTERNAL_DECL void duk_hthread_callstack_grow (duk_hthread *thr)
 
DUK_INTERNAL_DECL void duk_hthread_callstack_shrink_check (duk_hthread *thr)
 
DUK_INTERNAL_DECL void duk_hthread_callstack_unwind (duk_hthread *thr, duk_size_t new_top)
 
DUK_INTERNAL_DECL void duk_hthread_catchstack_grow (duk_hthread *thr)
 
DUK_INTERNAL_DECL void duk_hthread_catchstack_shrink_check (duk_hthread *thr)
 
DUK_INTERNAL_DECL void duk_hthread_catchstack_unwind (duk_hthread *thr, duk_size_t new_top)
 
DUK_INTERNAL_DECL duk_activationduk_hthread_get_current_activation (duk_hthread *thr)
 
DUK_INTERNAL_DECL void * duk_hthread_get_valstack_ptr (duk_heap *heap, void *ud)
 
DUK_INTERNAL_DECL void * duk_hthread_get_callstack_ptr (duk_heap *heap, void *ud)
 
DUK_INTERNAL_DECL void * duk_hthread_get_catchstack_ptr (duk_heap *heap, void *ud)
 
DUK_INTERNAL_DECL duk_uint_fast32_t duk_hthread_get_act_prev_pc (duk_hthread *thr, duk_activation *act)
 
DUK_INTERNAL_DECL void duk_hthread_sync_currpc (duk_hthread *thr)
 
DUK_INTERNAL_DECL void duk_hthread_sync_and_null_currpc (duk_hthread *thr)
 
DUK_INTERNAL_DECL duk_hbufferduk_hbuffer_alloc (duk_heap *heap, duk_size_t size, duk_small_uint_t flags, void **out_bufdata)
 
DUK_INTERNAL_DECL void * duk_hbuffer_get_dynalloc_ptr (duk_heap *heap, void *ud)
 
DUK_INTERNAL_DECL void duk_hbuffer_resize (duk_hthread *thr, duk_hbuffer_dynamic *buf, duk_size_t new_size)
 
DUK_INTERNAL_DECL void duk_hbuffer_reset (duk_hthread *thr, duk_hbuffer_dynamic *buf)
 
DUK_INTERNAL_DECL duk_heapduk_heap_alloc (duk_alloc_function alloc_func, duk_realloc_function realloc_func, duk_free_function free_func, void *heap_udata, duk_fatal_function fatal_func)
 
DUK_INTERNAL_DECL void duk_heap_free (duk_heap *heap)
 
DUK_INTERNAL_DECL void duk_free_hobject_inner (duk_heap *heap, duk_hobject *h)
 
DUK_INTERNAL_DECL void duk_free_hbuffer_inner (duk_heap *heap, duk_hbuffer *h)
 
DUK_INTERNAL_DECL void duk_free_hstring_inner (duk_heap *heap, duk_hstring *h)
 
DUK_INTERNAL_DECL void duk_heap_free_heaphdr_raw (duk_heap *heap, duk_heaphdr *hdr)
 
DUK_INTERNAL_DECL void duk_heap_insert_into_heap_allocated (duk_heap *heap, duk_heaphdr *hdr)
 
DUK_INTERNAL_DECL void duk_heap_remove_any_from_heap_allocated (duk_heap *heap, duk_heaphdr *hdr)
 
DUK_INTERNAL_DECL duk_hstringduk_heap_string_intern (duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen)
 
DUK_INTERNAL_DECL duk_hstringduk_heap_string_intern_checked (duk_hthread *thr, const duk_uint8_t *str, duk_uint32_t len)
 
DUK_INTERNAL_DECL duk_hstringduk_heap_string_intern_u32 (duk_heap *heap, duk_uint32_t val)
 
DUK_INTERNAL_DECL duk_hstringduk_heap_string_intern_u32_checked (duk_hthread *thr, duk_uint32_t val)
 
DUK_INTERNAL_DECL void duk_heap_string_remove (duk_heap *heap, duk_hstring *h)
 
DUK_INTERNAL_DECL void duk_heap_force_strtab_resize (duk_heap *heap)
 
DUK_INTERNAL void duk_heap_free_strtab (duk_heap *heap)
 
DUK_INTERNAL_DECL void duk_heap_strcache_string_remove (duk_heap *heap, duk_hstring *h)
 
DUK_INTERNAL_DECL duk_uint_fast32_t duk_heap_strcache_offset_char2byte (duk_hthread *thr, duk_hstring *h, duk_uint_fast32_t char_offset)
 
DUK_INTERNAL_DECL void * duk_default_alloc_function (void *udata, duk_size_t size)
 
DUK_INTERNAL_DECL void * duk_default_realloc_function (void *udata, void *ptr, duk_size_t newsize)
 
DUK_INTERNAL_DECL void duk_default_free_function (void *udata, void *ptr)
 
DUK_INTERNAL_DECL void * duk_heap_mem_alloc (duk_heap *heap, duk_size_t size)
 
DUK_INTERNAL_DECL void * duk_heap_mem_alloc_zeroed (duk_heap *heap, duk_size_t size)
 
DUK_INTERNAL_DECL void * duk_heap_mem_realloc (duk_heap *heap, void *ptr, duk_size_t newsize)
 
DUK_INTERNAL_DECL void * duk_heap_mem_realloc_indirect (duk_heap *heap, duk_mem_getptr cb, void *ud, duk_size_t newsize)
 
DUK_INTERNAL_DECL void duk_heap_mem_free (duk_heap *heap, void *ptr)
 
DUK_INTERNAL_DECL void duk_tval_decref (duk_hthread *thr, duk_tval *tv)
 
DUK_INTERNAL_DECL void duk_heaphdr_decref (duk_hthread *thr, duk_heaphdr *h)
 
DUK_INTERNAL_DECL void duk_heaphdr_decref_allownull (duk_hthread *thr, duk_heaphdr *h)
 
DUK_INTERNAL_DECL void duk_heaphdr_refzero (duk_hthread *thr, duk_heaphdr *h)
 
DUK_INTERNAL_DECL void duk_heaphdr_refcount_finalize (duk_hthread *thr, duk_heaphdr *hdr)
 
DUK_INTERNAL_DECL duk_bool_t duk_heap_mark_and_sweep (duk_heap *heap, duk_small_uint_t flags)
 
DUK_INTERNAL_DECL duk_uint32_t duk_heap_hashstring (duk_heap *heap, const duk_uint8_t *str, duk_size_t len)
 
 DUK_NORETURN (DUK_INTERNAL_DECL void duk_err_handle_error(duk_hthread *thr, const char *filename, duk_uint_t line_and_code, const char *msg))
 
 DUK_NORETURN (DUK_INTERNAL_DECL void duk_err_handle_error_fmt(duk_hthread *thr, const char *filename, duk_uint_t line_and_code, const char *fmt,...))
 
 DUK_NORETURN (DUK_INTERNAL_DECL void duk_err_create_and_throw(duk_hthread *thr, duk_errcode_t code, const char *msg, const char *filename, duk_int_t line))
 
 DUK_NORETURN (DUK_INTERNAL_DECL void duk_error_throw_from_negative_rc(duk_hthread *thr, duk_ret_t rc))
 
DUK_INTERNAL_DECL void duk_err_augment_error_create (duk_hthread *thr, duk_hthread *thr_callstack, const char *filename, duk_int_t line, duk_bool_t noblame_fileline)
 
DUK_INTERNAL_DECL void duk_err_augment_error_throw (duk_hthread *thr)
 
 DUK_NORETURN (DUK_INTERNAL_DECL void duk_err_require_type_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t index, const char *expect_name))
 
 DUK_NORETURN (DUK_INTERNAL_DECL void duk_err_api_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t index))
 
 DUK_NORETURN (DUK_INTERNAL_DECL void duk_err_api(duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message))
 
 DUK_NORETURN (DUK_INTERNAL_DECL void duk_err_unimplemented_defmsg(duk_hthread *thr, const char *filename, duk_int_t linenumber))
 
 DUK_NORETURN (DUK_INTERNAL_DECL void duk_err_longjmp(duk_hthread *thr))
 
 DUK_NORETURN (DUK_INTERNAL_DECL void duk_default_fatal_handler(duk_context *ctx, duk_errcode_t code, const char *msg))
 
 DUK_NORETURN (DUK_INTERNAL_DECL void duk_default_panic_handler(duk_errcode_t code, const char *msg))
 
DUK_INTERNAL_DECL void duk_err_setup_heap_ljstate (duk_hthread *thr, duk_small_int_t lj_type)
 
DUK_INTERNAL_DECL duk_hobjectduk_error_prototype_from_code (duk_hthread *thr, duk_errcode_t err_code)
 
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_get_xutf8_length (duk_ucodepoint_t cp)
 
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_encode_xutf8 (duk_ucodepoint_t cp, duk_uint8_t *out)
 
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_encode_cesu8 (duk_ucodepoint_t cp, duk_uint8_t *out)
 
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_decode_xutf8 (duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end, duk_ucodepoint_t *out_cp)
 
DUK_INTERNAL_DECL duk_ucodepoint_t duk_unicode_decode_xutf8_checked (duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end)
 
DUK_INTERNAL_DECL duk_size_t duk_unicode_unvalidated_utf8_length (const duk_uint8_t *data, duk_size_t blen)
 
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_whitespace (duk_codepoint_t cp)
 
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_line_terminator (duk_codepoint_t cp)
 
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_identifier_start (duk_codepoint_t cp)
 
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_identifier_part (duk_codepoint_t cp)
 
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_letter (duk_codepoint_t cp)
 
DUK_INTERNAL_DECL void duk_unicode_case_convert_string (duk_hthread *thr, duk_bool_t uppercase)
 
DUK_INTERNAL_DECL duk_codepoint_t duk_unicode_re_canonicalize_char (duk_hthread *thr, duk_codepoint_t cp)
 
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_re_is_wordchar (duk_codepoint_t cp)
 
DUK_INTERNAL_DECL duk_bool_t duk_js_toboolean (duk_tval *tv)
 
DUK_INTERNAL_DECL duk_double_t duk_js_tonumber (duk_hthread *thr, duk_tval *tv)
 
DUK_INTERNAL_DECL duk_double_t duk_js_tointeger_number (duk_double_t x)
 
DUK_INTERNAL_DECL duk_double_t duk_js_tointeger (duk_hthread *thr, duk_tval *tv)
 
DUK_INTERNAL_DECL duk_uint32_t duk_js_touint32 (duk_hthread *thr, duk_tval *tv)
 
DUK_INTERNAL_DECL duk_int32_t duk_js_toint32 (duk_hthread *thr, duk_tval *tv)
 
DUK_INTERNAL_DECL duk_uint16_t duk_js_touint16 (duk_hthread *thr, duk_tval *tv)
 
DUK_INTERNAL_DECL duk_small_int_t duk_js_to_arrayindex_raw_string (const duk_uint8_t *str, duk_uint32_t blen, duk_uarridx_t *out_idx)
 
DUK_INTERNAL_DECL duk_uarridx_t duk_js_to_arrayindex_string_helper (duk_hstring *h)
 
DUK_INTERNAL_DECL duk_bool_t duk_js_equals_helper (duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_int_t flags)
 
DUK_INTERNAL_DECL duk_small_int_t duk_js_data_compare (const duk_uint8_t *buf1, const duk_uint8_t *buf2, duk_size_t len1, duk_size_t len2)
 
DUK_INTERNAL_DECL duk_small_int_t duk_js_string_compare (duk_hstring *h1, duk_hstring *h2)
 
DUK_INTERNAL_DECL duk_bool_t duk_js_compare_helper (duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_int_t flags)
 
DUK_INTERNAL_DECL duk_bool_t duk_js_instanceof (duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y)
 
DUK_INTERNAL_DECL duk_bool_t duk_js_in (duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y)
 
DUK_INTERNAL_DECL duk_hstringduk_js_typeof (duk_hthread *thr, duk_tval *tv_x)
 
DUK_INTERNAL_DECL duk_bool_t duk_js_getvar_envrec (duk_hthread *thr, duk_hobject *env, duk_hstring *name, duk_bool_t throw_flag)
 
DUK_INTERNAL_DECL duk_bool_t duk_js_getvar_activation (duk_hthread *thr, duk_activation *act, duk_hstring *name, duk_bool_t throw_flag)
 
DUK_INTERNAL_DECL void duk_js_putvar_envrec (duk_hthread *thr, duk_hobject *env, duk_hstring *name, duk_tval *val, duk_bool_t strict)
 
DUK_INTERNAL_DECL void duk_js_putvar_activation (duk_hthread *thr, duk_activation *act, duk_hstring *name, duk_tval *val, duk_bool_t strict)
 
DUK_INTERNAL_DECL duk_bool_t duk_js_delvar_activation (duk_hthread *thr, duk_activation *act, duk_hstring *name)
 
DUK_INTERNAL_DECL duk_bool_t duk_js_declvar_activation (duk_hthread *thr, duk_activation *act, duk_hstring *name, duk_tval *val, duk_small_int_t prop_flags, duk_bool_t is_func_decl)
 
DUK_INTERNAL_DECL void duk_js_init_activation_environment_records_delayed (duk_hthread *thr, duk_activation *act)
 
DUK_INTERNAL_DECL void duk_js_close_environment_record (duk_hthread *thr, duk_hobject *env, duk_hobject *func, duk_size_t regbase)
 
DUK_INTERNAL_DECL duk_hobjectduk_create_activation_environment_record (duk_hthread *thr, duk_hobject *func, duk_size_t idx_bottom)
 
DUK_INTERNAL_DECL void duk_js_push_closure (duk_hthread *thr, duk_hcompiledfunction *fun_temp, duk_hobject *outer_var_env, duk_hobject *outer_lex_env, duk_bool_t add_auto_proto)
 
DUK_INTERNAL_DECL duk_int_t duk_handle_call_protected (duk_hthread *thr, duk_idx_t num_stack_args, duk_small_uint_t call_flags)
 
DUK_INTERNAL_DECL void duk_handle_call_unprotected (duk_hthread *thr, duk_idx_t num_stack_args, duk_small_uint_t call_flags)
 
DUK_INTERNAL_DECL duk_int_t duk_handle_safe_call (duk_hthread *thr, duk_safe_call_function func, duk_idx_t num_stack_args, duk_idx_t num_stack_res)
 
DUK_INTERNAL_DECL duk_bool_t duk_handle_ecma_call_setup (duk_hthread *thr, duk_idx_t num_stack_args, duk_small_uint_t call_flags)
 
DUK_INTERNAL_DECL void duk_js_execute_bytecode (duk_hthread *exec_thr)
 
DUK_INTERNAL_DECL void duk_numconv_stringify (duk_context *ctx, duk_small_int_t radix, duk_small_int_t digits, duk_small_uint_t flags)
 
DUK_INTERNAL_DECL void duk_numconv_parse (duk_context *ctx, duk_small_int_t radix, duk_small_uint_t flags)
 
DUK_INTERNAL_DECL void duk_bi_date_timeval_to_parts (duk_double_t d, duk_int_t *parts, duk_double_t *dparts, duk_small_uint_t flags)
 
DUK_INTERNAL_DECL duk_double_t duk_bi_date_get_timeval_from_dparts (duk_double_t *dparts, duk_small_uint_t flags)
 
DUK_INTERNAL_DECL void duk_bi_date_format_timeval (duk_double_t timeval, duk_uint8_t *out_buf)
 
DUK_INTERNAL_DECL duk_bool_t duk_bi_date_is_leap_year (duk_int_t year)
 
DUK_INTERNAL_DECL duk_bool_t duk_bi_date_timeval_in_valid_range (duk_double_t x)
 
DUK_INTERNAL_DECL duk_bool_t duk_bi_date_year_in_valid_range (duk_double_t year)
 
DUK_INTERNAL_DECL duk_bool_t duk_bi_date_timeval_in_leeway_range (duk_double_t x)
 
DUK_INTERNAL_DECL duk_double_t duk_bi_date_get_now_time (duk_context *ctx)
 
DUK_INTERNAL_DECL duk_int_t duk_bi_date_get_local_tzoffset_gmtime (duk_double_t d)
 
DUK_INTERNAL_DECL void duk_bi_json_parse_helper (duk_context *ctx, duk_idx_t idx_value, duk_idx_t idx_reviver, duk_small_uint_t flags)
 
DUK_INTERNAL_DECL void duk_bi_json_stringify_helper (duk_context *ctx, duk_idx_t idx_value, duk_idx_t idx_replacer, duk_idx_t idx_space, duk_small_uint_t flags)
 
DUK_INTERNAL int duk_repl_fpclassify (double x)
 
DUK_INTERNAL int duk_repl_signbit (double x)
 
DUK_INTERNAL int duk_repl_isfinite (double x)
 
DUK_INTERNAL int duk_repl_isnan (double x)
 
DUK_INTERNAL int duk_repl_isinf (double x)
 
DUK_INTERNAL void duk_err_handle_error_fmt (duk_hthread *thr, const char *filename, duk_uint_t line_and_code, const char *fmt,...)
 
DUK_INTERNAL void duk_err_handle_error (duk_hthread *thr, const char *filename, duk_uint_t line_and_code, const char *msg)
 
DUK_INTERNAL void duk_err_require_type_index (duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t index, const char *expect_name)
 
DUK_INTERNAL void duk_err_range (duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message)
 
DUK_INTERNAL void duk_err_api_index (duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t index)
 
DUK_INTERNAL void duk_err_api (duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message)
 
DUK_INTERNAL void duk_err_unimplemented_defmsg (duk_hthread *thr, const char *filename, duk_int_t linenumber)
 
DUK_INTERNAL void duk_err_internal_defmsg (duk_hthread *thr, const char *filename, duk_int_t linenumber)
 
DUK_INTERNAL void duk_err_internal (duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message)
 
DUK_INTERNAL void duk_err_alloc (duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message)
 
DUK_INTERNAL void duk_default_fatal_handler (duk_context *ctx, duk_errcode_t code, const char *msg)
 
DUK_INTERNAL void duk_default_panic_handler (duk_errcode_t code, const char *msg)
 
DUK_LOCAL duk_uint32_t duk__uni_decode_value (duk_bitdecoder_ctx *bd_ctx)
 
DUK_LOCAL duk_small_int_t duk__uni_range_match (const duk_uint8_t *unitab, duk_size_t unilen, duk_codepoint_t cp)
 
DUK_LOCAL duk_codepoint_t duk__slow_case_conversion (duk_hthread *thr, duk_bufwriter_ctx *bw, duk_codepoint_t cp, duk_bitdecoder_ctx *bd_ctx)
 
DUK_LOCAL duk_codepoint_t duk__case_transform_helper (duk_hthread *thr, duk_bufwriter_ctx *bw, duk_codepoint_t cp, duk_codepoint_t prev, duk_codepoint_t next, duk_bool_t uppercase)
 
DUK_EXTERNAL void * duk_resize_buffer (duk_context *ctx, duk_idx_t index, duk_size_t new_size)
 
DUK_EXTERNAL void * duk_steal_buffer (duk_context *ctx, duk_idx_t index, duk_size_t *out_size)
 
DUK_EXTERNAL void duk_config_buffer (duk_context *ctx, duk_idx_t index, void *ptr, duk_size_t len)
 
DUK_LOCAL duk_uint8_t * duk__load_string_raw (duk_context *ctx, duk_uint8_t *p)
 
DUK_LOCAL duk_uint8_t * duk__load_buffer_raw (duk_context *ctx, duk_uint8_t *p)
 
DUK_LOCAL duk_uint8_t * duk__dump_hstring_raw (duk_uint8_t *p, duk_hstring *h)
 
DUK_LOCAL duk_uint8_t * duk__dump_hbuffer_raw (duk_hthread *thr, duk_uint8_t *p, duk_hbuffer *h)
 
DUK_LOCAL duk_uint8_t * duk__dump_string_prop (duk_hthread *thr, duk_uint8_t *p, duk_bufwriter_ctx *bw_ctx, duk_hobject *func, duk_small_uint_t stridx)
 
DUK_LOCAL duk_uint8_t * duk__dump_buffer_prop (duk_hthread *thr, duk_uint8_t *p, duk_bufwriter_ctx *bw_ctx, duk_hobject *func, duk_small_uint_t stridx)
 
DUK_LOCAL duk_uint8_t * duk__dump_uint32_prop (duk_hthread *thr, duk_uint8_t *p, duk_bufwriter_ctx *bw_ctx, duk_hobject *func, duk_small_uint_t stridx, duk_uint32_t def_value)
 
DUK_LOCAL duk_uint8_t * duk__dump_varmap (duk_hthread *thr, duk_uint8_t *p, duk_bufwriter_ctx *bw_ctx, duk_hobject *func)
 
DUK_LOCAL duk_uint8_t * duk__dump_formals (duk_hthread *thr, duk_uint8_t *p, duk_bufwriter_ctx *bw_ctx, duk_hobject *func)
 
static duk_uint8_t * duk__dump_func (duk_context *ctx, duk_hcompiledfunction *func, duk_bufwriter_ctx *bw_ctx, duk_uint8_t *p)
 
static duk_uint8_t * duk__load_func (duk_context *ctx, duk_uint8_t *p, duk_uint8_t *p_end)
 
DUK_EXTERNAL void duk_dump_function (duk_context *ctx)
 
DUK_EXTERNAL void duk_load_function (duk_context *ctx)
 
DUK_LOCAL void duk__call_prop_prep_stack (duk_context *ctx, duk_idx_t normalized_obj_index, duk_idx_t nargs)
 
DUK_EXTERNAL void duk_call (duk_context *ctx, duk_idx_t nargs)
 
DUK_EXTERNAL void duk_call_method (duk_context *ctx, duk_idx_t nargs)
 
DUK_EXTERNAL void duk_call_prop (duk_context *ctx, duk_idx_t obj_index, duk_idx_t nargs)
 
DUK_EXTERNAL duk_int_t duk_pcall (duk_context *ctx, duk_idx_t nargs)
 
DUK_EXTERNAL duk_int_t duk_pcall_method (duk_context *ctx, duk_idx_t nargs)
 
DUK_LOCAL duk_ret_t duk__pcall_prop_raw (duk_context *ctx)
 
DUK_EXTERNAL duk_int_t duk_pcall_prop (duk_context *ctx, duk_idx_t obj_index, duk_idx_t nargs)
 
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_new (duk_context *ctx, duk_idx_t nargs)
 
DUK_LOCAL duk_ret_t duk__pnew_helper (duk_context *ctx)
 
DUK_EXTERNAL duk_int_t duk_pnew (duk_context *ctx, duk_idx_t nargs)
 
DUK_EXTERNAL duk_bool_t duk_is_constructor_call (duk_context *ctx)
 
DUK_EXTERNAL duk_bool_t duk_is_strict_call (duk_context *ctx)
 
DUK_EXTERNAL duk_int_t duk_get_current_magic (duk_context *ctx)
 
DUK_EXTERNAL duk_int_t duk_get_magic (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void duk_set_magic (duk_context *ctx, duk_idx_t index, duk_int_t magic)
 
DUK_LOCAL const duk_uint8_t * duk__prep_codec_arg (duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
 
DUK_LOCAL void duk__base64_encode_helper (const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst)
 
DUK_LOCAL duk_bool_t duk__base64_decode_helper (const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst, duk_uint8_t **out_dst_final)
 
DUK_EXTERNAL const char * duk_base64_encode (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void duk_base64_decode (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL const char * duk_hex_encode (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void duk_hex_decode (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL const char * duk_json_encode (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void duk_json_decode (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_int_t duk_eval_raw (duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags)
 
DUK_LOCAL duk_ret_t duk__do_compile (duk_context *ctx)
 
DUK_EXTERNAL duk_int_t duk_compile_raw (duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags)
 
DUK_EXTERNAL void duk_push_context_dump (duk_context *ctx)
 
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_debugger_detach (duk_context *ctx)
 
DUK_EXTERNAL void duk_debugger_cooperate (duk_context *ctx)
 
DUK_EXTERNAL duk_bool_t duk_debugger_notify (duk_context *ctx, duk_idx_t nvalues)
 
DUK_EXTERNAL void duk_debugger_pause (duk_context *ctx)
 
DUK_EXTERNAL duk_contextduk_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)
 
DUK_EXTERNAL void duk_destroy_heap (duk_context *ctx)
 
DUK_EXTERNAL void duk_suspend (duk_context *ctx, duk_thread_state *state)
 
DUK_EXTERNAL void duk_resume (duk_context *ctx, const duk_thread_state *state)
 
DUK_EXTERNAL void duk_set_global_object (duk_context *ctx)
 
DUK_EXTERNAL void duk_log_va (duk_context *ctx, duk_int_t level, const char *fmt, va_list ap)
 
DUK_EXTERNAL void duk_log (duk_context *ctx, duk_int_t level, const char *fmt,...)
 
DUK_EXTERNAL void * duk_alloc_raw (duk_context *ctx, duk_size_t size)
 
DUK_EXTERNAL void duk_free_raw (duk_context *ctx, void *ptr)
 
DUK_EXTERNAL void * duk_realloc_raw (duk_context *ctx, void *ptr, duk_size_t size)
 
DUK_EXTERNAL void * duk_alloc (duk_context *ctx, duk_size_t size)
 
DUK_EXTERNAL void duk_free (duk_context *ctx, void *ptr)
 
DUK_EXTERNAL void * duk_realloc (duk_context *ctx, void *ptr, duk_size_t size)
 
DUK_EXTERNAL void duk_get_memory_functions (duk_context *ctx, duk_memory_functions *out_funcs)
 
DUK_EXTERNAL void duk_gc (duk_context *ctx, duk_uint_t flags)
 
DUK_EXTERNAL duk_bool_t duk_get_prop (duk_context *ctx, duk_idx_t obj_index)
 
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_index (duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index)
 
DUK_LOCAL duk_bool_t duk__put_prop_shared (duk_context *ctx, duk_idx_t obj_idx, duk_idx_t idx_key)
 
DUK_EXTERNAL duk_bool_t duk_put_prop (duk_context *ctx, duk_idx_t obj_idx)
 
DUK_EXTERNAL duk_bool_t duk_put_prop_string (duk_context *ctx, duk_idx_t obj_idx, const char *key)
 
DUK_EXTERNAL duk_bool_t duk_put_prop_index (duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx)
 
DUK_EXTERNAL duk_bool_t duk_del_prop (duk_context *ctx, duk_idx_t obj_index)
 
DUK_EXTERNAL duk_bool_t duk_del_prop_string (duk_context *ctx, duk_idx_t obj_index, const char *key)
 
DUK_EXTERNAL duk_bool_t duk_del_prop_index (duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index)
 
DUK_EXTERNAL duk_bool_t duk_has_prop (duk_context *ctx, duk_idx_t obj_index)
 
DUK_EXTERNAL duk_bool_t duk_has_prop_string (duk_context *ctx, duk_idx_t obj_index, const char *key)
 
DUK_EXTERNAL duk_bool_t duk_has_prop_index (duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index)
 
DUK_EXTERNAL void duk_def_prop (duk_context *ctx, duk_idx_t obj_index, duk_uint_t flags)
 
DUK_EXTERNAL void duk_compact (duk_context *ctx, duk_idx_t obj_index)
 
DUK_EXTERNAL void duk_enum (duk_context *ctx, duk_idx_t obj_index, duk_uint_t enum_flags)
 
DUK_EXTERNAL duk_bool_t duk_next (duk_context *ctx, duk_idx_t enum_index, duk_bool_t get_value)
 
DUK_EXTERNAL void duk_put_function_list (duk_context *ctx, duk_idx_t obj_index, const duk_function_list_entry *funcs)
 
DUK_EXTERNAL void duk_put_number_list (duk_context *ctx, duk_idx_t obj_index, const duk_number_list_entry *numbers)
 
DUK_EXTERNAL duk_bool_t duk_get_global_string (duk_context *ctx, const char *key)
 
DUK_EXTERNAL duk_bool_t duk_put_global_string (duk_context *ctx, const char *key)
 
DUK_EXTERNAL void duk_get_prototype (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void duk_set_prototype (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void duk_get_finalizer (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void duk_set_finalizer (duk_context *ctx, duk_idx_t index)
 
DUK_LOCAL_DECL duk_idx_t duk__push_c_function_raw (duk_context *ctx, duk_c_function func, duk_idx_t nargs, duk_uint_t flags)
 
DUK_LOCAL_DECL duk_heaphdrduk__get_tagged_heaphdr_raw (duk_context *ctx, duk_idx_t index, duk_uint_t tag)
 
DUK_LOCAL duk_int_t duk__api_coerce_d2i (duk_context *ctx, duk_idx_t index, duk_bool_t require)
 
DUK_LOCAL duk_uint_t duk__api_coerce_d2ui (duk_context *ctx, duk_idx_t index, duk_bool_t require)
 
DUK_EXTERNAL duk_idx_t duk_normalize_index (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_idx_t duk_require_normalize_index (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_is_valid_index (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void duk_require_valid_index (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_idx_t duk_get_top (duk_context *ctx)
 
DUK_EXTERNAL void duk_set_top (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_idx_t duk_get_top_index (duk_context *ctx)
 
DUK_EXTERNAL duk_idx_t duk_require_top_index (duk_context *ctx)
 
DUK_LOCAL duk_bool_t duk__resize_valstack (duk_context *ctx, duk_size_t new_size)
 
DUK_EXTERNAL duk_bool_t duk_check_stack (duk_context *ctx, duk_idx_t extra)
 
DUK_EXTERNAL void duk_require_stack (duk_context *ctx, duk_idx_t extra)
 
DUK_EXTERNAL duk_bool_t duk_check_stack_top (duk_context *ctx, duk_idx_t top)
 
DUK_EXTERNAL void duk_require_stack_top (duk_context *ctx, duk_idx_t top)
 
DUK_EXTERNAL void duk_swap (duk_context *ctx, duk_idx_t index1, duk_idx_t index2)
 
DUK_EXTERNAL void duk_swap_top (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void duk_dup (duk_context *ctx, duk_idx_t from_index)
 
DUK_EXTERNAL void duk_dup_top (duk_context *ctx)
 
DUK_EXTERNAL void duk_insert (duk_context *ctx, duk_idx_t to_index)
 
DUK_EXTERNAL void duk_replace (duk_context *ctx, duk_idx_t to_index)
 
DUK_EXTERNAL void duk_copy (duk_context *ctx, duk_idx_t from_index, duk_idx_t to_index)
 
DUK_EXTERNAL void duk_remove (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void duk_xcopymove_raw (duk_context *to_ctx, duk_context *from_ctx, duk_idx_t count, duk_bool_t is_copy)
 
DUK_EXTERNAL void duk_require_undefined (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void duk_require_null (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_get_boolean (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_require_boolean (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_double_t duk_get_number (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_double_t duk_require_number (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_int_t duk_get_int (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_uint_t duk_get_uint (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_int_t duk_require_int (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_get_lstring (duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
 
DUK_EXTERNAL const char * duk_require_lstring (duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
 
DUK_EXTERNAL const char * duk_get_string (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL const char * duk_require_string (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void * duk_get_pointer (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void * duk_require_pointer (duk_context *ctx, duk_idx_t index)
 
DUK_LOCAL void * duk__get_buffer_helper (duk_context *ctx, duk_idx_t index, duk_size_t *out_size, duk_bool_t throw_flag)
 
DUK_EXTERNAL void * duk_get_buffer (duk_context *ctx, duk_idx_t index, duk_size_t *out_size)
 
DUK_EXTERNAL void * duk_require_buffer (duk_context *ctx, duk_idx_t index, duk_size_t *out_size)
 
DUK_LOCAL void * duk__get_buffer_data_helper (duk_context *ctx, duk_idx_t index, duk_size_t *out_size, duk_bool_t throw_flag)
 
DUK_EXTERNAL void * duk_get_buffer_data (duk_context *ctx, duk_idx_t index, duk_size_t *out_size)
 
DUK_EXTERNAL void * duk_require_buffer_data (duk_context *ctx, duk_idx_t index, duk_size_t *out_size)
 
DUK_EXTERNAL duk_c_function duk_get_c_function (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_c_function duk_require_c_function (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void duk_require_function (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_contextduk_get_context (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_contextduk_require_context (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void * duk_get_heapptr (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void * duk_require_heapptr (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_size_t duk_get_length (duk_context *ctx, duk_idx_t index)
 
DUK_LOCAL duk_bool_t duk__defaultvalue_coerce_attempt (duk_context *ctx, duk_idx_t index, duk_small_int_t func_stridx)
 
DUK_EXTERNAL void duk_to_defaultvalue (duk_context *ctx, duk_idx_t index, duk_int_t hint)
 
DUK_EXTERNAL void duk_to_undefined (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void duk_to_null (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void duk_to_primitive (duk_context *ctx, duk_idx_t index, duk_int_t hint)
 
DUK_EXTERNAL duk_bool_t duk_to_boolean (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_double_t duk_to_number (duk_context *ctx, duk_idx_t index)
 
DUK_LOCAL duk_double_t duk__to_int_uint_helper (duk_context *ctx, duk_idx_t index, duk__toint_coercer coerce_func)
 
DUK_EXTERNAL duk_int_t duk_to_int (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_uint_t duk_to_uint (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_int32_t duk_to_int32 (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_uint32_t duk_to_uint32 (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_uint16_t duk_to_uint16 (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL const char * duk_to_lstring (duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
 
DUK_LOCAL duk_ret_t duk__safe_to_string_raw (duk_context *ctx)
 
DUK_EXTERNAL const char * duk_safe_to_lstring (duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
 
DUK_EXTERNAL const char * duk_to_string (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void * duk_to_buffer_raw (duk_context *ctx, duk_idx_t index, duk_size_t *out_size, duk_uint_t mode)
 
DUK_EXTERNAL void * duk_to_pointer (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void duk_to_object (duk_context *ctx, duk_idx_t index)
 
DUK_LOCAL duk_bool_t duk__tag_check (duk_context *ctx, duk_idx_t index, duk_small_uint_t tag)
 
DUK_LOCAL duk_bool_t duk__obj_flag_any_default_false (duk_context *ctx, duk_idx_t index, duk_uint_t flag_mask)
 
DUK_EXTERNAL duk_int_t duk_get_type (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_check_type (duk_context *ctx, duk_idx_t index, duk_int_t type)
 
DUK_EXTERNAL duk_uint_t duk_get_type_mask (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_check_type_mask (duk_context *ctx, duk_idx_t index, duk_uint_t mask)
 
DUK_EXTERNAL duk_bool_t duk_is_undefined (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_is_null (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_is_null_or_undefined (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_is_boolean (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_is_number (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_is_nan (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_is_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_is_buffer (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_is_buffer_data (duk_context *ctx, duk_idx_t idx)
 
DUK_EXTERNAL duk_bool_t duk_is_pointer (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_is_lightfunc (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_is_array (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_is_function (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_is_c_function (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_is_ecmascript_function (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_is_bound_function (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_is_thread (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_is_fixed_buffer (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_is_dynamic_buffer (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_bool_t duk_is_external_buffer (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_errcode_t duk_get_error_code (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL void duk_push_undefined (duk_context *ctx)
 
DUK_EXTERNAL void duk_push_null (duk_context *ctx)
 
DUK_EXTERNAL void duk_push_boolean (duk_context *ctx, duk_bool_t val)
 
DUK_EXTERNAL void duk_push_true (duk_context *ctx)
 
DUK_EXTERNAL void duk_push_false (duk_context *ctx)
 
DUK_EXTERNAL void duk_push_number (duk_context *ctx, duk_double_t val)
 
DUK_EXTERNAL void duk_push_int (duk_context *ctx, duk_int_t val)
 
DUK_EXTERNAL void duk_push_uint (duk_context *ctx, duk_uint_t val)
 
DUK_EXTERNAL void duk_push_nan (duk_context *ctx)
 
DUK_EXTERNAL const char * duk_push_lstring (duk_context *ctx, const char *str, duk_size_t len)
 
DUK_EXTERNAL const char * duk_push_string (duk_context *ctx, const char *str)
 
DUK_EXTERNAL const char * duk_push_string_file_raw (duk_context *ctx, const char *path, duk_uint_t flags)
 
DUK_EXTERNAL void duk_push_pointer (duk_context *ctx, void *val)
 
DUK_LOCAL void duk__push_this_helper (duk_context *ctx, duk_small_uint_t check_object_coercible)
 
DUK_EXTERNAL void duk_push_this (duk_context *ctx)
 
DUK_EXTERNAL void duk_push_current_function (duk_context *ctx)
 
DUK_EXTERNAL void duk_push_current_thread (duk_context *ctx)
 
DUK_EXTERNAL void duk_push_global_object (duk_context *ctx)
 
DUK_LOCAL void duk__push_stash (duk_context *ctx)
 
DUK_EXTERNAL void duk_push_heap_stash (duk_context *ctx)
 
DUK_EXTERNAL void duk_push_global_stash (duk_context *ctx)
 
DUK_EXTERNAL void duk_push_thread_stash (duk_context *ctx, duk_context *target_ctx)
 
DUK_LOCAL duk_int_t duk__try_push_vsprintf (duk_context *ctx, void *buf, duk_size_t sz, const char *fmt, va_list ap)
 
DUK_EXTERNAL const char * duk_push_vsprintf (duk_context *ctx, const char *fmt, va_list ap)
 
DUK_EXTERNAL const char * duk_push_sprintf (duk_context *ctx, const char *fmt,...)
 
DUK_EXTERNAL duk_idx_t duk_push_object (duk_context *ctx)
 
DUK_EXTERNAL duk_idx_t duk_push_array (duk_context *ctx)
 
DUK_EXTERNAL duk_idx_t duk_push_thread_raw (duk_context *ctx, duk_uint_t flags)
 
DUK_EXTERNAL duk_idx_t duk_push_c_function (duk_context *ctx, duk_c_function func, duk_int_t nargs)
 
DUK_EXTERNAL duk_idx_t duk_push_c_lightfunc (duk_context *ctx, duk_c_function func, duk_idx_t nargs, duk_idx_t length, duk_int_t magic)
 
DUK_EXTERNAL void duk_push_buffer_object (duk_context *ctx, duk_idx_t idx_buffer, duk_size_t byte_offset, duk_size_t byte_length, duk_uint_t flags)
 
DUK_EXTERNAL duk_idx_t duk_push_error_object_va_raw (duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, va_list ap)
 
DUK_EXTERNAL duk_idx_t duk_push_error_object_raw (duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt,...)
 
DUK_EXTERNAL duk_idx_t duk_push_error_object_stash (duk_context *ctx, duk_errcode_t err_code, const char *fmt,...)
 
DUK_EXTERNAL void * duk_push_buffer_raw (duk_context *ctx, duk_size_t size, duk_small_uint_t flags)
 
DUK_EXTERNAL duk_idx_t duk_push_heapptr (duk_context *ctx, void *ptr)
 
DUK_EXTERNAL void duk_pop_n (duk_context *ctx, duk_idx_t count)
 
DUK_EXTERNAL void duk_pop (duk_context *ctx)
 
DUK_EXTERNAL void duk_pop_2 (duk_context *ctx)
 
DUK_EXTERNAL void duk_pop_3 (duk_context *ctx)
 
DUK_EXTERNAL void duk_throw (duk_context *ctx)
 
DUK_EXTERNAL void duk_fatal (duk_context *ctx, duk_errcode_t err_code, const char *err_msg)
 
DUK_EXTERNAL void duk_error_va_raw (duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, va_list ap)
 
DUK_EXTERNAL void duk_error_raw (duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt,...)
 
DUK_EXTERNAL void duk_error_stash (duk_context *ctx, duk_errcode_t err_code, const char *fmt,...)
 
DUK_EXTERNAL duk_bool_t duk_equals (duk_context *ctx, duk_idx_t index1, duk_idx_t index2)
 
DUK_EXTERNAL duk_bool_t duk_strict_equals (duk_context *ctx, duk_idx_t index1, duk_idx_t index2)
 
DUK_EXTERNAL duk_bool_t duk_instanceof (duk_context *ctx, duk_idx_t index1, duk_idx_t index2)
 
DUK_LOCAL void duk__push_hstring_readable_unicode (duk_context *ctx, duk_hstring *h_input)
 
DUK_LOCAL void duk__concat_and_join_helper (duk_context *ctx, duk_idx_t count_in, duk_bool_t is_join)
 
DUK_EXTERNAL void duk_concat (duk_context *ctx, duk_idx_t count)
 
DUK_EXTERNAL void duk_join (duk_context *ctx, duk_idx_t count)
 
DUK_EXTERNAL void duk_decode_string (duk_context *ctx, duk_idx_t index, duk_decode_char_function callback, void *udata)
 
DUK_EXTERNAL void duk_map_string (duk_context *ctx, duk_idx_t index, duk_map_char_function callback, void *udata)
 
DUK_EXTERNAL void duk_substring (duk_context *ctx, duk_idx_t index, duk_size_t start_offset, duk_size_t end_offset)
 
DUK_EXTERNAL void duk_trim (duk_context *ctx, duk_idx_t index)
 
DUK_EXTERNAL duk_codepoint_t duk_char_code_at (duk_context *ctx, duk_idx_t index, duk_size_t char_offset)
 
DUK_EXTERNAL void duk_get_var (duk_context *ctx)
 
DUK_EXTERNAL void duk_put_var (duk_context *ctx)
 
DUK_EXTERNAL duk_bool_t duk_del_var (duk_context *ctx)
 
DUK_EXTERNAL duk_bool_t duk_has_var (duk_context *ctx)
 
DUK_LOCAL duk_uint32_t duk__push_this_obj_len_u32 (duk_context *ctx)
 
DUK_LOCAL duk_uint32_t duk__push_this_obj_len_u32_limited (duk_context *ctx)
 
DUK_LOCAL duk_small_int_t duk__array_sort_compare (duk_context *ctx, duk_int_t idx1, duk_int_t idx2)
 
DUK_LOCAL void duk__array_sort_swap (duk_context *ctx, duk_int_t l, duk_int_t r)
 
DUK_LOCAL void duk__array_qsort (duk_context *ctx, duk_int_t lo, duk_int_t hi)
 
DUK_LOCAL duk_hbufferobjectduk__getrequire_bufobj_this (duk_context *ctx, duk_bool_t throw_flag)
 
DUK_LOCAL duk_hbufferobjectduk__get_bufobj_this (duk_context *ctx)
 
DUK_LOCAL duk_hbufferobjectduk__require_bufobj_this (duk_context *ctx)
 
DUK_LOCAL duk_hbufferobjectduk__require_bufobj_value (duk_context *ctx, duk_idx_t index)
 
DUK_LOCAL void duk__set_bufobj_buffer (duk_context *ctx, duk_hbufferobject *h_bufobj, duk_hbuffer *h_val)
 
DUK_LOCAL duk_hbufferobjectduk__push_arraybuffer_with_length (duk_context *ctx, duk_uint_t len)
 
DUK_LOCAL void duk__resolve_offset_opt_length (duk_context *ctx, duk_hbufferobject *h_bufarg, duk_idx_t idx_offset, duk_idx_t idx_length, duk_uint_t *out_offset, duk_uint_t *out_length, duk_bool_t throw_flag)
 
DUK_LOCAL void duk__clamp_startend_nonegidx_noshift (duk_context *ctx, duk_hbufferobject *h_bufobj, duk_idx_t idx_start, duk_idx_t idx_end, duk_int_t *out_start_offset, duk_int_t *out_end_offset)
 
DUK_LOCAL void duk__clamp_startend_negidx_shifted (duk_context *ctx, duk_hbufferobject *h_bufobj, duk_idx_t idx_start, duk_idx_t idx_end, duk_int_t *out_start_offset, duk_int_t *out_end_offset)
 
DUK_LOCAL_DECL duk_double_t duk__push_this_get_timeval_tzoffset (duk_context *ctx, duk_small_uint_t flags, duk_int_t *out_tzoffset)
 
DUK_LOCAL_DECL duk_double_t duk__push_this_get_timeval (duk_context *ctx, duk_small_uint_t flags)
 
DUK_LOCAL_DECL void duk__twodigit_year_fixup (duk_context *ctx, duk_idx_t idx_val)
 
DUK_LOCAL_DECL duk_ret_t duk__set_this_timeval_from_dparts (duk_context *ctx, duk_double_t *dparts, duk_small_uint_t flags)
 
DUK_LOCAL duk_bool_t duk__parse_string_iso8601_subset (duk_context *ctx, const char *str)
 
DUK_LOCAL duk_ret_t duk__parse_string (duk_context *ctx, const char *str)
 
DUK_LOCAL duk_double_t duk__timeclip (duk_double_t x)
 
DUK_LOCAL duk_int_t duk__div_floor (duk_int_t a, duk_int_t b)
 
DUK_LOCAL duk_int_t duk__day_from_year (duk_int_t year)
 
DUK_LOCAL duk_int_t duk__year_from_day (duk_int_t day, duk_small_int_t *out_day_within_year)
 
DUK_LOCAL duk_double_t duk__make_day (duk_double_t year, duk_double_t month, duk_double_t day)
 
DUK_LOCAL void duk__format_parts_iso8601 (duk_int_t *parts, duk_int_t tzoffset, duk_small_uint_t flags, duk_uint8_t *out_buf)
 
DUK_LOCAL duk_ret_t duk__to_string_helper (duk_context *ctx, duk_small_uint_t flags)
 
DUK_LOCAL duk_ret_t duk__get_part_helper (duk_context *ctx, duk_small_uint_t flags_and_idx)
 
DUK_LOCAL duk_ret_t duk__set_part_helper (duk_context *ctx, duk_small_uint_t flags_and_maxnargs)
 
DUK_LOCAL void duk__set_parts_from_args (duk_context *ctx, duk_double_t *dparts, duk_idx_t nargs)
 
DUK_LOCAL duk_small_uint_t duk__date_get_indirect_magic (duk_context *ctx)
 
DUK_LOCAL duk_ret_t duk__error_getter_helper (duk_context *ctx, duk_small_int_t output_type)
 
DUK_LOCAL duk_ret_t duk__error_setter_helper (duk_context *ctx, duk_small_uint_t stridx_key)
 
DUK_LOCAL duk_small_int_t duk__decode_hex_escape (const duk_uint8_t *p, duk_small_int_t n)
 
DUK_LOCAL int duk__transform_helper (duk_context *ctx, duk__transform_callback callback, const void *udata)
 
DUK_LOCAL void duk__transform_callback_encode_uri (duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp)
 
DUK_LOCAL void duk__transform_callback_decode_uri (duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp)
 
DUK_LOCAL void duk__transform_callback_escape (duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp)
 
DUK_LOCAL void duk__transform_callback_unescape (duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp)
 
DUK_LOCAL void duk__bi_global_resolve_module_id (duk_context *ctx, const char *req_id, const char *mod_id)
 
DUK_LOCAL_DECL void duk__dec_syntax_error (duk_json_dec_ctx *js_ctx)
 
DUK_LOCAL_DECL void duk__dec_eat_white (duk_json_dec_ctx *js_ctx)
 
DUK_LOCAL_DECL duk_uint8_t duk__dec_peek (duk_json_dec_ctx *js_ctx)
 
DUK_LOCAL_DECL duk_uint8_t duk__dec_get (duk_json_dec_ctx *js_ctx)
 
DUK_LOCAL_DECL duk_uint8_t duk__dec_get_nonwhite (duk_json_dec_ctx *js_ctx)
 
DUK_LOCAL_DECL duk_uint_fast32_t duk__dec_decode_hex_escape (duk_json_dec_ctx *js_ctx, duk_small_uint_t n)
 
DUK_LOCAL_DECL void duk__dec_req_stridx (duk_json_dec_ctx *js_ctx, duk_small_uint_t stridx)
 
DUK_LOCAL_DECL void duk__dec_string (duk_json_dec_ctx *js_ctx)
 
DUK_LOCAL_DECL void duk__dec_plain_string (duk_json_dec_ctx *js_ctx)
 
DUK_LOCAL_DECL void duk__dec_pointer (duk_json_dec_ctx *js_ctx)
 
DUK_LOCAL_DECL void duk__dec_buffer (duk_json_dec_ctx *js_ctx)
 
DUK_LOCAL_DECL void duk__dec_number (duk_json_dec_ctx *js_ctx)
 
DUK_LOCAL_DECL void duk__dec_objarr_entry (duk_json_dec_ctx *js_ctx)
 
DUK_LOCAL_DECL void duk__dec_objarr_exit (duk_json_dec_ctx *js_ctx)
 
DUK_LOCAL_DECL void duk__dec_object (duk_json_dec_ctx *js_ctx)
 
DUK_LOCAL_DECL void duk__dec_array (duk_json_dec_ctx *js_ctx)
 
DUK_LOCAL_DECL void duk__dec_value (duk_json_dec_ctx *js_ctx)
 
DUK_LOCAL_DECL void duk__dec_reviver_walk (duk_json_dec_ctx *js_ctx)
 
DUK_LOCAL_DECL void duk__emit_1 (duk_json_enc_ctx *js_ctx, duk_uint_fast8_t ch)
 
DUK_LOCAL_DECL void duk__emit_2 (duk_json_enc_ctx *js_ctx, duk_uint_fast8_t ch1, duk_uint_fast8_t ch2)
 
DUK_LOCAL_DECL void duk__unemit_1 (duk_json_enc_ctx *js_ctx)
 
DUK_LOCAL_DECL void duk__emit_hstring (duk_json_enc_ctx *js_ctx, duk_hstring *h)
 
DUK_LOCAL_DECL void duk__emit_stridx (duk_json_enc_ctx *js_ctx, duk_small_uint_t stridx)
 
DUK_LOCAL_DECL duk_uint8_t * duk__emit_esc_auto_fast (duk_json_enc_ctx *js_ctx, duk_uint_fast32_t cp, duk_uint8_t *q)
 
DUK_LOCAL_DECL void duk__enc_key_autoquote (duk_json_enc_ctx *js_ctx, duk_hstring *k)
 
DUK_LOCAL_DECL void duk__enc_quote_string (duk_json_enc_ctx *js_ctx, duk_hstring *h_str)
 
DUK_LOCAL_DECL void duk__enc_objarr_entry (duk_json_enc_ctx *js_ctx, duk_idx_t *entry_top)
 
DUK_LOCAL_DECL void duk__enc_objarr_exit (duk_json_enc_ctx *js_ctx, duk_idx_t *entry_top)
 
DUK_LOCAL_DECL void duk__enc_object (duk_json_enc_ctx *js_ctx)
 
DUK_LOCAL_DECL void duk__enc_array (duk_json_enc_ctx *js_ctx)
 
DUK_LOCAL_DECL duk_bool_t duk__enc_value (duk_json_enc_ctx *js_ctx, duk_idx_t idx_holder)
 
DUK_LOCAL_DECL duk_bool_t duk__enc_allow_into_proplist (duk_tval *tv)
 
DUK_LOCAL_DECL void duk__enc_double (duk_json_enc_ctx *js_ctx)
 
DUK_LOCAL_DECL void duk__enc_buffer (duk_json_enc_ctx *js_ctx, duk_hbuffer *h)
 
DUK_LOCAL_DECL void duk__enc_pointer (duk_json_enc_ctx *js_ctx, void *ptr)
 
DUK_LOCAL_DECL void duk__enc_bufferobject (duk_json_enc_ctx *js_ctx, duk_hbufferobject *h_bufobj)
 
DUK_LOCAL_DECL void duk__enc_newline_indent (duk_json_enc_ctx *js_ctx, duk_int_t depth)
 
DUK_LOCAL duk_small_int_t duk__dec_string_escape (duk_json_dec_ctx *js_ctx, duk_uint8_t **ext_p)
 
DUK_LOCAL void duk__emit_cstring (duk_json_enc_ctx *js_ctx, const char *str)
 
DUK_LOCAL duk_uint8_t * duk__enc_buffer_data_hex (const duk_uint8_t *src, duk_size_t src_len, duk_uint8_t *dst)
 
DUK_LOCAL void duk__enc_buffer_data (duk_json_enc_ctx *js_ctx, duk_uint8_t *buf_data, duk_size_t buf_len)
 
DUK_LOCAL duk_ret_t duk__math_minmax (duk_context *ctx, duk_double_t initial, duk__two_arg_func min_max)
 
DUK_LOCAL double duk__fmin_fixed (double x, double y)
 
DUK_LOCAL double duk__fmax_fixed (double x, double y)
 
DUK_LOCAL double duk__round_fixed (double x)
 
DUK_LOCAL double duk__pow_fixed (double x, double y)
 
DUK_LOCAL double duk__fabs (double x)
 
DUK_LOCAL double duk__acos (double x)
 
DUK_LOCAL double duk__asin (double x)
 
DUK_LOCAL double duk__atan (double x)
 
DUK_LOCAL double duk__ceil (double x)
 
DUK_LOCAL double duk__cos (double x)
 
DUK_LOCAL double duk__exp (double x)
 
DUK_LOCAL double duk__floor (double x)
 
DUK_LOCAL double duk__log (double x)
 
DUK_LOCAL double duk__sin (double x)
 
DUK_LOCAL double duk__sqrt (double x)
 
DUK_LOCAL double duk__tan (double x)
 
DUK_LOCAL double duk__atan2 (double x, double y)
 
DUK_LOCAL duk_double_t duk__push_this_number_plain (duk_context *ctx)
 
DUK_LOCAL void duk__get_this_regexp (duk_context *ctx)
 
DUK_LOCAL void duk__to_regexp_helper (duk_context *ctx, duk_idx_t index, duk_bool_t force_new)
 
DUK_LOCAL void duk__err_augment_user (duk_hthread *thr, duk_small_uint_t stridx_cb)
 
DUK_LOCAL void duk__add_traceback (duk_hthread *thr, duk_hthread *thr_callstack, const char *c_filename, duk_int_t c_line, duk_bool_t noblame_fileline)
 
DUK_LOCAL void duk__add_compiler_error_line (duk_hthread *thr)
 
DUK_LOCAL void duk__err_augment_builtin_create (duk_hthread *thr, duk_hthread *thr_callstack, const char *c_filename, duk_int_t c_line, duk_small_int_t noblame_fileline, duk_hobject *obj)
 
DUK_INTERNAL void duk_err_longjmp (duk_hthread *thr)
 
DUK_INTERNAL void duk_err_create_and_throw (duk_hthread *thr, duk_errcode_t code, const char *msg, const char *filename, duk_int_t line)
 
DUK_INTERNAL void duk_error_throw_from_negative_rc (duk_hthread *thr, duk_ret_t rc)
 
DUK_LOCAL void duk__free_allocated (duk_heap *heap)
 
DUK_LOCAL void duk__free_refzero_list (duk_heap *heap)
 
DUK_LOCAL void duk__free_markandsweep_finalize_list (duk_heap *heap)
 
DUK_LOCAL void duk__free_stringtable (duk_heap *heap)
 
DUK_LOCAL void duk__free_run_finalizers (duk_heap *heap)
 
DUK_LOCAL duk_bool_t duk__init_heap_strings (duk_heap *heap)
 
DUK_LOCAL duk_bool_t duk__init_heap_thread (duk_heap *heap)
 
DUK_LOCAL_DECL void duk__mark_heaphdr (duk_heap *heap, duk_heaphdr *h)
 
DUK_LOCAL_DECL void duk__mark_tval (duk_heap *heap, duk_tval *tv)
 
DUK_LOCAL duk_hthreadduk__get_temp_hthread (duk_heap *heap)
 
DUK_LOCAL void duk__mark_hstring (duk_heap *heap, duk_hstring *h)
 
DUK_LOCAL void duk__mark_hobject (duk_heap *heap, duk_hobject *h)
 
DUK_LOCAL void duk__mark_roots_heap (duk_heap *heap)
 
DUK_LOCAL void duk__mark_refzero_list (duk_heap *heap)
 
DUK_LOCAL void duk__mark_finalizable (duk_heap *heap)
 
DUK_LOCAL void duk__mark_finalize_list (duk_heap *heap)
 
DUK_LOCAL void duk__handle_temproot (duk_heap *heap, duk_heaphdr *hdr)
 
DUK_LOCAL void duk__mark_temproots_by_heap_scan (duk_heap *heap)
 
DUK_LOCAL void duk__finalize_refcounts (duk_heap *heap)
 
DUK_LOCAL void duk__clear_refzero_list_flags (duk_heap *heap)
 
DUK_LOCAL void duk__clear_finalize_list_flags (duk_heap *heap)
 
DUK_LOCAL void duk__sweep_stringtable_probe (duk_heap *heap, duk_size_t *out_count_keep)
 
DUK_LOCAL void duk__sweep_heap (duk_heap *heap, duk_int_t flags, duk_size_t *out_count_keep)
 
DUK_LOCAL void duk__run_object_finalizers (duk_heap *heap, duk_small_uint_t flags)
 
DUK_LOCAL int duk__protected_compact_object (duk_context *ctx)
 
DUK_LOCAL void duk__compact_object_list (duk_heap *heap, duk_hthread *thr, duk_heaphdr *start)
 
DUK_LOCAL void duk__compact_objects (duk_heap *heap)
 
DUK_LOCAL void duk__run_voluntary_gc (duk_heap *heap)
 
DUK_LOCAL void duk__queue_refzero (duk_heap *heap, duk_heaphdr *hdr)
 
DUK_LOCAL void duk__refcount_finalize_hobject (duk_hthread *thr, duk_hobject *h)
 
DUK_LOCAL void duk__refzero_free_pending (duk_hthread *thr)
 
DUK_LOCAL const duk_uint8_t * duk__scan_forwards (const duk_uint8_t *p, const duk_uint8_t *q, duk_uint_fast32_t n)
 
DUK_LOCAL const duk_uint8_t * duk__scan_backwards (const duk_uint8_t *p, const duk_uint8_t *q, duk_uint_fast32_t n)
 
DUK_LOCAL duk_hstringduk__alloc_init_hstring (duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen, duk_uint32_t strhash, const duk_uint8_t *extdata)
 
DUK_LOCAL duk_int_t duk__count_used_probe (duk_heap *heap)
 
DUK_LOCAL void duk__insert_hstring_probe (duk_heap *heap, duk_hstring **entries, duk_uint32_t size, duk_uint32_t *p_used, duk_hstring *h)
 
DUK_LOCAL duk_hstringduk__find_matching_string_probe (duk_heap *heap, duk_hstring **entries, duk_uint32_t size, const duk_uint8_t *str, duk_uint32_t blen, duk_uint32_t strhash)
 
DUK_LOCAL void duk__remove_matching_hstring_probe (duk_heap *heap, duk_hstring **entries, duk_uint32_t size, duk_hstring *h)
 
DUK_LOCAL duk_bool_t duk__resize_strtab_raw_probe (duk_heap *heap, duk_uint32_t new_size)
 
DUK_LOCAL duk_bool_t duk__resize_strtab_probe (duk_heap *heap)
 
DUK_LOCAL duk_bool_t duk__recheck_strtab_size_probe (duk_heap *heap, duk_uint32_t new_used)
 
DUK_LOCAL duk_hstringduk__do_intern (duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen, duk_uint32_t strhash)
 
DUK_LOCAL duk_hstringduk__do_lookup (duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen, duk_uint32_t *out_strhash)
 
DUK_LOCAL void duk__init_object_parts (duk_heap *heap, duk_hobject *obj, duk_uint_t hobject_flags)
 
DUK_LOCAL void duk__sort_array_indices (duk_hthread *thr, duk_hobject *h_obj)
 
DUK_LOCAL duk_ret_t duk__finalize_helper (duk_context *ctx)
 
DUK_LOCAL duk_uint_fast32_t duk__hobject_pc2line_query_raw (duk_hthread *thr, duk_hbuffer_fixed *buf, duk_uint_fast32_t pc)
 
DUK_LOCAL_DECL duk_bool_t duk__check_arguments_map_for_get (duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *temp_desc)
 
DUK_LOCAL_DECL void duk__check_arguments_map_for_put (duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *temp_desc, duk_bool_t throw_flag)
 
DUK_LOCAL_DECL void duk__check_arguments_map_for_delete (duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *temp_desc)
 
DUK_LOCAL_DECL duk_bool_t duk__handle_put_array_length_smaller (duk_hthread *thr, duk_hobject *obj, duk_uint32_t old_len, duk_uint32_t new_len, duk_bool_t force_flag, duk_uint32_t *out_result_len)
 
DUK_LOCAL_DECL duk_bool_t duk__handle_put_array_length (duk_hthread *thr, duk_hobject *obj)
 
DUK_LOCAL_DECL duk_bool_t duk__get_propdesc (duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *out_desc, duk_small_uint_t flags)
 
DUK_LOCAL_DECL duk_bool_t duk__get_own_propdesc_raw (duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_uint32_t arr_idx, duk_propdesc *out_desc, duk_small_uint_t flags)
 
DUK_LOCAL duk_uint32_t duk__get_old_array_length (duk_hthread *thr, duk_hobject *obj, duk_propdesc *temp_desc)
 
DUK_LOCAL duk_uint32_t duk__tval_number_to_arr_idx (duk_tval *tv)
 
DUK_LOCAL duk_uint32_t duk__push_tval_to_hstring_arr_idx (duk_context *ctx, duk_tval *tv, duk_hstring **out_h)
 
DUK_LOCAL duk_bool_t duk__key_is_lightfunc_ownprop (duk_hthread *thr, duk_hstring *key)
 
DUK_LOCAL duk_uint32_t duk__get_default_h_size (duk_uint32_t e_size)
 
DUK_LOCAL duk_uint32_t duk__get_min_grow_e (duk_uint32_t e_size)
 
DUK_LOCAL duk_uint32_t duk__get_min_grow_a (duk_uint32_t a_size)
 
DUK_LOCAL duk_uint32_t duk__count_used_e_keys (duk_hthread *thr, duk_hobject *obj)
 
DUK_LOCAL void duk__compute_a_stats (duk_hthread *thr, duk_hobject *obj, duk_uint32_t *out_used, duk_uint32_t *out_min_size)
 
DUK_LOCAL duk_bool_t duk__abandon_array_density_check (duk_uint32_t a_used, duk_uint32_t a_size)
 
DUK_LOCAL duk_bool_t duk__abandon_array_slow_check_required (duk_uint32_t arr_idx, duk_uint32_t old_size)
 
DUK_LOCAL duk_bool_t duk__proxy_check_prop (duk_hthread *thr, duk_hobject *obj, duk_small_uint_t stridx_trap, duk_tval *tv_key, duk_hobject **out_target)
 
DUK_LOCAL void duk__realloc_props (duk_hthread *thr, duk_hobject *obj, duk_uint32_t new_e_size, duk_uint32_t new_a_size, duk_uint32_t new_h_size, duk_bool_t abandon_array)
 
DUK_LOCAL void duk__grow_props_for_new_entry_item (duk_hthread *thr, duk_hobject *obj)
 
DUK_LOCAL void duk__grow_props_for_array_item (duk_hthread *thr, duk_hobject *obj, duk_uint32_t highest_arr_idx)
 
DUK_LOCAL void duk__abandon_array_checked (duk_hthread *thr, duk_hobject *obj)
 
DUK_LOCAL duk_bool_t duk__alloc_entry_checked (duk_hthread *thr, duk_hobject *obj, duk_hstring *key)
 
DUK_LOCAL duk_bool_t duk__lookup_arguments_map (duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *temp_desc, duk_hobject **out_map, duk_hobject **out_varenv)
 
DUK_LOCAL duk_tvalduk__getprop_shallow_fastpath_array_tval (duk_hthread *thr, duk_hobject *obj, duk_tval *tv_key)
 
DUK_LOCAL duk_bool_t duk__putprop_shallow_fastpath_array_tval (duk_hthread *thr, duk_hobject *obj, duk_tval *tv_key, duk_tval *tv_val, duk_propdesc *temp_desc)
 
DUK_LOCAL duk_bool_t duk__getprop_fastpath_bufobj_tval (duk_hthread *thr, duk_hobject *obj, duk_tval *tv_key)
 
DUK_LOCAL duk_bool_t duk__putprop_fastpath_bufobj_tval (duk_hthread *thr, duk_hobject *obj, duk_tval *tv_key, duk_tval *tv_val)
 
DUK_LOCAL duk_uint32_t duk__to_new_array_length_checked (duk_hthread *thr)
 
DUK_LOCAL void duk__push_stridx (duk_context *ctx, duk_bitdecoder_ctx *bd)
 
DUK_LOCAL void duk__push_string (duk_context *ctx, duk_bitdecoder_ctx *bd)
 
DUK_LOCAL void duk__push_stridx_or_string (duk_context *ctx, duk_bitdecoder_ctx *bd)
 
DUK_LOCAL void duk__push_double (duk_context *ctx, duk_bitdecoder_ctx *bd)
 
DUK_LOCAL void duk__handle_call_inner (duk_hthread *thr, duk_idx_t num_stack_args, duk_small_uint_t call_flags, duk_idx_t idx_func)
 
DUK_LOCAL void duk__handle_call_error (duk_hthread *thr, duk_size_t entry_valstack_bottom_index, duk_size_t entry_valstack_end, duk_size_t entry_catchstack_top, duk_size_t entry_callstack_top, duk_int_t entry_call_recursion_depth, duk_hthread *entry_curr_thread, duk_uint_fast8_t entry_thread_state, duk_instr_t **entry_ptr_curr_pc, duk_idx_t idx_func, duk_jmpbuf *old_jmpbuf_ptr)
 
DUK_LOCAL void duk__handle_safe_call_inner (duk_hthread *thr, duk_safe_call_function func, duk_idx_t idx_retbase, duk_idx_t num_stack_rets, duk_size_t entry_valstack_bottom_index, duk_size_t entry_callstack_top, duk_size_t entry_catchstack_top)
 
DUK_LOCAL void duk__handle_safe_call_error (duk_hthread *thr, duk_idx_t idx_retbase, duk_idx_t num_stack_rets, duk_size_t entry_valstack_bottom_index, duk_size_t entry_callstack_top, duk_size_t entry_catchstack_top, duk_jmpbuf *old_jmpbuf_ptr)
 
DUK_LOCAL void duk__handle_safe_call_shared (duk_hthread *thr, duk_idx_t idx_retbase, duk_idx_t num_stack_rets, duk_int_t entry_call_recursion_depth, duk_hthread *entry_curr_thread, duk_uint_fast8_t entry_thread_state, duk_instr_t **entry_ptr_curr_pc)
 
DUK_LOCAL void duk__create_arguments_object (duk_hthread *thr, duk_hobject *func, duk_hobject *varenv, duk_idx_t idx_argbase, duk_idx_t num_stack_args)
 
DUK_LOCAL void duk__handle_createargs_for_call (duk_hthread *thr, duk_hobject *func, duk_hobject *env, duk_idx_t num_stack_args)
 
DUK_LOCAL void duk__handle_bound_chain_for_call (duk_hthread *thr, duk_idx_t idx_func, duk_idx_t *p_num_stack_args, duk_bool_t is_constructor_call)
 
DUK_LOCAL void duk__handle_oldenv_for_call (duk_hthread *thr, duk_hobject *func, duk_activation *act)
 
DUK_LOCAL void duk__coerce_effective_this_binding (duk_hthread *thr, duk_hobject *func, duk_idx_t idx_this)
 
DUK_LOCAL duk_hobjectduk__nonbound_func_lookup (duk_context *ctx, duk_idx_t idx_func, duk_idx_t *out_num_stack_args, duk_tval **out_tv_func, duk_small_uint_t call_flags)
 
DUK_LOCAL void duk__adjust_valstack_and_top (duk_hthread *thr, duk_idx_t num_stack_args, duk_idx_t idx_args, duk_idx_t nregs, duk_idx_t nargs, duk_hobject *func)
 
DUK_LOCAL void duk__safe_call_adjust_valstack (duk_hthread *thr, duk_idx_t idx_retbase, duk_idx_t num_stack_rets, duk_idx_t num_actual_rets)
 
DUK_LOCAL duk_idx_t duk__get_idx_func (duk_hthread *thr, duk_idx_t num_stack_args)
 
DUK_LOCAL_DECL void duk__advance_helper (duk_compiler_ctx *comp_ctx, duk_small_int_t expect)
 
DUK_LOCAL_DECL void duk__advance_expect (duk_compiler_ctx *comp_ctx, duk_small_int_t expect)
 
DUK_LOCAL_DECL void duk__advance (duk_compiler_ctx *ctx)
 
DUK_LOCAL_DECL void duk__init_func_valstack_slots (duk_compiler_ctx *comp_ctx)
 
DUK_LOCAL_DECL void duk__reset_func_for_pass2 (duk_compiler_ctx *comp_ctx)
 
DUK_LOCAL_DECL void duk__init_varmap_and_prologue_for_pass2 (duk_compiler_ctx *comp_ctx, duk_reg_t *out_stmt_value_reg)
 
DUK_LOCAL_DECL void duk__convert_to_func_template (duk_compiler_ctx *comp_ctx, duk_bool_t force_no_namebind)
 
DUK_LOCAL_DECL duk_int_t duk__cleanup_varmap (duk_compiler_ctx *comp_ctx)
 
DUK_LOCAL_DECL duk_int_t duk__get_current_pc (duk_compiler_ctx *comp_ctx)
 
DUK_LOCAL_DECL duk_compiler_instrduk__get_instr_ptr (duk_compiler_ctx *comp_ctx, duk_int_t pc)
 
DUK_LOCAL_DECL void duk__emit (duk_compiler_ctx *comp_ctx, duk_instr_t ins)
 
DUK_LOCAL_DECL void duk__emit_a_b_c (duk_compiler_ctx *comp_ctx, duk_small_uint_t op_flags, duk_regconst_t a, duk_regconst_t b, duk_regconst_t c)
 
DUK_LOCAL_DECL void duk__emit_a_b (duk_compiler_ctx *comp_ctx, duk_small_uint_t op_flags, duk_regconst_t a, duk_regconst_t b)
 
DUK_LOCAL_DECL void duk__emit_a_bc (duk_compiler_ctx *comp_ctx, duk_small_uint_t op_flags, duk_regconst_t a, duk_regconst_t bc)
 
DUK_LOCAL_DECL void duk__emit_abc (duk_compiler_ctx *comp_ctx, duk_small_uint_t op, duk_regconst_t abc)
 
DUK_LOCAL_DECL void duk__emit_extraop_b_c (duk_compiler_ctx *comp_ctx, duk_small_uint_t extraop_flags, duk_regconst_t b, duk_regconst_t c)
 
DUK_LOCAL_DECL void duk__emit_extraop_b (duk_compiler_ctx *comp_ctx, duk_small_uint_t extraop_flags, duk_regconst_t b)
 
DUK_LOCAL_DECL void duk__emit_extraop_bc (duk_compiler_ctx *comp_ctx, duk_small_uint_t extraop, duk_regconst_t bc)
 
DUK_LOCAL_DECL void duk__emit_extraop_only (duk_compiler_ctx *comp_ctx, duk_small_uint_t extraop_flags)
 
DUK_LOCAL_DECL void duk__emit_load_int32 (duk_compiler_ctx *comp_ctx, duk_reg_t reg, duk_int32_t val)
 
DUK_LOCAL_DECL void duk__emit_load_int32_noshuffle (duk_compiler_ctx *comp_ctx, duk_reg_t reg, duk_int32_t val)
 
DUK_LOCAL_DECL void duk__emit_jump (duk_compiler_ctx *comp_ctx, duk_int_t target_pc)
 
DUK_LOCAL_DECL duk_int_t duk__emit_jump_empty (duk_compiler_ctx *comp_ctx)
 
DUK_LOCAL_DECL void duk__insert_jump_entry (duk_compiler_ctx *comp_ctx, duk_int_t jump_pc)
 
DUK_LOCAL_DECL void duk__patch_jump (duk_compiler_ctx *comp_ctx, duk_int_t jump_pc, duk_int_t target_pc)
 
DUK_LOCAL_DECL void duk__patch_jump_here (duk_compiler_ctx *comp_ctx, duk_int_t jump_pc)
 
DUK_LOCAL_DECL void duk__patch_trycatch (duk_compiler_ctx *comp_ctx, duk_int_t ldconst_pc, duk_int_t trycatch_pc, duk_regconst_t reg_catch, duk_regconst_t const_varname, duk_small_uint_t flags)
 
DUK_LOCAL_DECL void duk__emit_if_false_skip (duk_compiler_ctx *comp_ctx, duk_regconst_t regconst)
 
DUK_LOCAL_DECL void duk__emit_if_true_skip (duk_compiler_ctx *comp_ctx, duk_regconst_t regconst)
 
DUK_LOCAL_DECL void duk__emit_invalid (duk_compiler_ctx *comp_ctx)
 
DUK_LOCAL_DECL void duk__copy_ispec (duk_compiler_ctx *comp_ctx, duk_ispec *src, duk_ispec *dst)
 
DUK_LOCAL_DECL void duk__copy_ivalue (duk_compiler_ctx *comp_ctx, duk_ivalue *src, duk_ivalue *dst)
 
DUK_LOCAL_DECL duk_bool_t duk__is_whole_get_int32 (duk_double_t x, duk_int32_t *ival)
 
DUK_LOCAL_DECL duk_reg_t duk__alloctemps (duk_compiler_ctx *comp_ctx, duk_small_int_t num)
 
DUK_LOCAL_DECL duk_reg_t duk__alloctemp (duk_compiler_ctx *comp_ctx)
 
DUK_LOCAL_DECL void duk__settemp_checkmax (duk_compiler_ctx *comp_ctx, duk_reg_t temp_next)
 
DUK_LOCAL_DECL duk_regconst_t duk__getconst (duk_compiler_ctx *comp_ctx)
 
DUK_LOCAL_DECL duk_regconst_t duk__ispec_toregconst_raw (duk_compiler_ctx *comp_ctx, duk_ispec *x, duk_reg_t forced_reg, duk_small_uint_t flags)
 
DUK_LOCAL_DECL void duk__ispec_toforcedreg (duk_compiler_ctx *comp_ctx, duk_ispec *x, duk_reg_t forced_reg)
 
DUK_LOCAL_DECL void duk__ivalue_toplain_raw (duk_compiler_ctx *comp_ctx, duk_ivalue *x, duk_reg_t forced_reg)
 
DUK_LOCAL_DECL void duk__ivalue_toplain (duk_compiler_ctx *comp_ctx, duk_ivalue *x)
 
DUK_LOCAL_DECL void duk__ivalue_toplain_ignore (duk_compiler_ctx *comp_ctx, duk_ivalue *x)
 
DUK_LOCAL_DECL duk_regconst_t duk__ivalue_toregconst_raw (duk_compiler_ctx *comp_ctx, duk_ivalue *x, duk_reg_t forced_reg, duk_small_uint_t flags)
 
DUK_LOCAL_DECL duk_reg_t duk__ivalue_toreg (duk_compiler_ctx *comp_ctx, duk_ivalue *x)
 
DUK_LOCAL_DECL void duk__ivalue_toforcedreg (duk_compiler_ctx *comp_ctx, duk_ivalue *x, duk_int_t forced_reg)
 
DUK_LOCAL_DECL duk_regconst_t duk__ivalue_toregconst (duk_compiler_ctx *comp_ctx, duk_ivalue *x)
 
DUK_LOCAL_DECL duk_regconst_t duk__ivalue_totempconst (duk_compiler_ctx *comp_ctx, duk_ivalue *x)
 
DUK_LOCAL_DECL duk_reg_t duk__lookup_active_register_binding (duk_compiler_ctx *comp_ctx)
 
DUK_LOCAL_DECL duk_bool_t duk__lookup_lhs (duk_compiler_ctx *ctx, duk_reg_t *out_reg_varbind, duk_regconst_t *out_rc_varname)
 
DUK_LOCAL_DECL void duk__add_label (duk_compiler_ctx *comp_ctx, duk_hstring *h_label, duk_int_t pc_label, duk_int_t label_id)
 
DUK_LOCAL_DECL void duk__update_label_flags (duk_compiler_ctx *comp_ctx, duk_int_t label_id, duk_small_uint_t flags)
 
DUK_LOCAL_DECL void duk__lookup_active_label (duk_compiler_ctx *comp_ctx, duk_hstring *h_label, duk_bool_t is_break, duk_int_t *out_label_id, duk_int_t *out_label_catch_depth, duk_int_t *out_label_pc, duk_bool_t *out_is_closest)
 
DUK_LOCAL_DECL void duk__reset_labels_to_length (duk_compiler_ctx *comp_ctx, duk_int_t len)
 
DUK_LOCAL_DECL void duk__expr_nud (duk_compiler_ctx *comp_ctx, duk_ivalue *res)
 
DUK_LOCAL_DECL void duk__expr_led (duk_compiler_ctx *comp_ctx, duk_ivalue *left, duk_ivalue *res)
 
DUK_LOCAL_DECL duk_small_uint_t duk__expr_lbp (duk_compiler_ctx *comp_ctx)
 
DUK_LOCAL_DECL duk_bool_t duk__expr_is_empty (duk_compiler_ctx *comp_ctx)
 
DUK_LOCAL_DECL void duk__expr (duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags)
 
DUK_LOCAL_DECL void duk__exprtop (duk_compiler_ctx *ctx, duk_ivalue *res, duk_small_uint_t rbp_flags)
 
DUK_LOCAL_DECL void duk__expr_toforcedreg (duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags, duk_reg_t forced_reg)
 
DUK_LOCAL_DECL duk_regconst_t duk__expr_toregconst (duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags)
 
DUK_LOCAL_DECL void duk__expr_toplain (duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags)
 
DUK_LOCAL_DECL void duk__expr_toplain_ignore (duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags)
 
DUK_LOCAL_DECL duk_reg_t duk__exprtop_toreg (duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags)
 
DUK_LOCAL_DECL void duk__exprtop_toforcedreg (duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags, duk_reg_t forced_reg)
 
DUK_LOCAL_DECL duk_regconst_t duk__exprtop_toregconst (duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags)
 
DUK_LOCAL_DECL duk_int_t duk__parse_arguments (duk_compiler_ctx *comp_ctx, duk_ivalue *res)
 
DUK_LOCAL_DECL void duk__nud_array_literal (duk_compiler_ctx *comp_ctx, duk_ivalue *res)
 
DUK_LOCAL_DECL void duk__nud_object_literal (duk_compiler_ctx *comp_ctx, duk_ivalue *res)
 
DUK_LOCAL_DECL duk_bool_t duk__nud_object_literal_key_check (duk_compiler_ctx *comp_ctx, duk_small_uint_t new_key_flags)
 
DUK_LOCAL_DECL void duk__parse_var_decl (duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t expr_flags, duk_reg_t *out_reg_varbind, duk_regconst_t *out_rc_varname)
 
DUK_LOCAL_DECL void duk__parse_var_stmt (duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t expr_flags)
 
DUK_LOCAL_DECL void duk__parse_for_stmt (duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site)
 
DUK_LOCAL_DECL void duk__parse_switch_stmt (duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site)
 
DUK_LOCAL_DECL void duk__parse_if_stmt (duk_compiler_ctx *comp_ctx, duk_ivalue *res)
 
DUK_LOCAL_DECL void duk__parse_do_stmt (duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site)
 
DUK_LOCAL_DECL void duk__parse_while_stmt (duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site)
 
DUK_LOCAL_DECL void duk__parse_break_or_continue_stmt (duk_compiler_ctx *comp_ctx, duk_ivalue *res)
 
DUK_LOCAL_DECL void duk__parse_return_stmt (duk_compiler_ctx *comp_ctx, duk_ivalue *res)
 
DUK_LOCAL_DECL void duk__parse_throw_stmt (duk_compiler_ctx *comp_ctx, duk_ivalue *res)
 
DUK_LOCAL_DECL void duk__parse_try_stmt (duk_compiler_ctx *comp_ctx, duk_ivalue *res)
 
DUK_LOCAL_DECL void duk__parse_with_stmt (duk_compiler_ctx *comp_ctx, duk_ivalue *res)
 
DUK_LOCAL_DECL void duk__parse_stmt (duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_bool_t allow_source_elem)
 
DUK_LOCAL_DECL duk_int_t duk__stmt_label_site (duk_compiler_ctx *comp_ctx, duk_int_t label_id)
 
DUK_LOCAL_DECL void duk__parse_stmts (duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof)
 
DUK_LOCAL_DECL void duk__parse_func_body (duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_small_int_t expect_token)
 
DUK_LOCAL_DECL void duk__parse_func_formals (duk_compiler_ctx *comp_ctx)
 
DUK_LOCAL_DECL void duk__parse_func_like_raw (duk_compiler_ctx *comp_ctx, duk_bool_t is_decl, duk_bool_t is_setget)
 
DUK_LOCAL_DECL duk_int_t duk__parse_func_like_fnum (duk_compiler_ctx *comp_ctx, duk_bool_t is_decl, duk_bool_t is_setget)
 
DUK_LOCAL void duk__recursion_increase (duk_compiler_ctx *comp_ctx)
 
DUK_LOCAL void duk__recursion_decrease (duk_compiler_ctx *comp_ctx)
 
DUK_LOCAL duk_bool_t duk__hstring_is_eval_or_arguments (duk_compiler_ctx *comp_ctx, duk_hstring *h)
 
DUK_LOCAL duk_bool_t duk__hstring_is_eval_or_arguments_in_strict_mode (duk_compiler_ctx *comp_ctx, duk_hstring *h)
 
DUK_LOCAL void duk__update_lineinfo_currtoken (duk_compiler_ctx *comp_ctx)
 
DUK_LOCAL void duk__emit_load_int32_raw (duk_compiler_ctx *comp_ctx, duk_reg_t reg, duk_int32_t val, duk_small_uint_t op_flags)
 
DUK_LOCAL void duk__peephole_optimize_bytecode (duk_compiler_ctx *comp_ctx)
 
DUK_LOCAL duk_ret_t duk__js_compile_raw (duk_context *ctx)
 
DUK_LOCAL_DECL void duk__js_execute_bytecode_inner (duk_hthread *entry_thread, duk_size_t entry_callstack_top)
 
DUK_LOCAL duk_double_t duk__compute_mod (duk_double_t d1, duk_double_t d2)
 
DUK_LOCAL void duk__vm_arith_add (duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_uint_fast_t idx_z)
 
DUK_LOCAL void duk__vm_arith_binary_op (duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_idx_t idx_z, duk_small_uint_fast_t opcode)
 
DUK_LOCAL void duk__vm_bitwise_binary_op (duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_uint_fast_t idx_z, duk_small_uint_fast_t opcode)
 
DUK_LOCAL void duk__vm_arith_unary_op (duk_hthread *thr, duk_tval *tv_x, duk_idx_t idx_x, duk_small_uint_fast_t opcode)
 
DUK_LOCAL void duk__vm_bitwise_not (duk_hthread *thr, duk_tval *tv_x, duk_uint_fast_t idx_z)
 
DUK_LOCAL void duk__vm_logical_not (duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_z)
 
DUK_LOCAL void duk__reconfig_valstack_ecma_return (duk_hthread *thr, duk_size_t act_idx)
 
DUK_LOCAL void duk__reconfig_valstack_ecma_catcher (duk_hthread *thr, duk_size_t act_idx, duk_size_t cat_idx)
 
DUK_LOCAL void duk__set_catcher_regs (duk_hthread *thr, duk_size_t cat_idx, duk_tval *tv_val_unstable, duk_small_uint_t lj_type)
 
DUK_LOCAL void duk__handle_catch (duk_hthread *thr, duk_size_t cat_idx, duk_tval *tv_val_unstable, duk_small_uint_t lj_type)
 
DUK_LOCAL void duk__handle_finally (duk_hthread *thr, duk_size_t cat_idx, duk_tval *tv_val_unstable, duk_small_uint_t lj_type)
 
DUK_LOCAL void duk__handle_label (duk_hthread *thr, duk_size_t cat_idx, duk_small_uint_t lj_type)
 
DUK_LOCAL void duk__handle_yield (duk_hthread *thr, duk_hthread *resumer, duk_size_t act_idx, duk_tval *tv_val_unstable)
 
DUK_LOCAL duk_small_uint_t duk__handle_longjmp (duk_hthread *thr, duk_hthread *entry_thread, duk_size_t entry_callstack_top)
 
DUK_LOCAL void duk__handle_break_or_continue (duk_hthread *thr, duk_uint_t label_id, duk_small_uint_t lj_type)
 
DUK_LOCAL duk_small_uint_t duk__handle_return (duk_hthread *thr, duk_hthread *entry_thread, duk_size_t entry_callstack_top)
 
DUK_LOCAL void duk__handle_executor_error (duk_heap *heap, duk_hthread *entry_thread, duk_size_t entry_callstack_top, duk_int_t entry_call_recursion_depth, duk_jmpbuf *entry_jmpbuf_ptr)
 
DUK_LOCAL duk_double_t duk__tonumber_string_raw (duk_hthread *thr)
 
DUK_LOCAL duk_double_t duk__toint32_touint32_helper (duk_double_t x, duk_bool_t is_toint32)
 
DUK_LOCAL duk_bool_t duk__js_equals_number (duk_double_t x, duk_double_t y)
 
DUK_LOCAL duk_bool_t duk__js_samevalue_number (duk_double_t x, duk_double_t y)
 
DUK_LOCAL void duk__inc_data_inner_refcounts (duk_hthread *thr, duk_hcompiledfunction *f)
 
DUK_LOCAL duk_bool_t duk__getid_open_decl_env_regs (duk_hthread *thr, duk_hstring *name, duk_hobject *env, duk__id_lookup_result *out)
 
DUK_LOCAL duk_bool_t duk__getid_activation_regs (duk_hthread *thr, duk_hstring *name, duk_activation *act, duk__id_lookup_result *out)
 
DUK_LOCAL duk_bool_t duk__get_identifier_reference (duk_hthread *thr, duk_hobject *env, duk_hstring *name, duk_activation *act, duk_bool_t parents, duk__id_lookup_result *out)
 
DUK_LOCAL duk_bool_t duk__getvar_helper (duk_hthread *thr, duk_hobject *env, duk_activation *act, duk_hstring *name, duk_bool_t throw_flag)
 
DUK_LOCAL void duk__putvar_helper (duk_hthread *thr, duk_hobject *env, duk_activation *act, duk_hstring *name, duk_tval *val, duk_bool_t strict)
 
DUK_LOCAL duk_bool_t duk__delvar_helper (duk_hthread *thr, duk_hobject *env, duk_activation *act, duk_hstring *name)
 
DUK_LOCAL duk_bool_t duk__declvar_helper (duk_hthread *thr, duk_hobject *env, duk_hstring *name, duk_tval *val, duk_small_int_t prop_flags, duk_bool_t is_func_decl)
 
DUK_LOCAL void duk__fill_lexer_buffer (duk_lexer_ctx *lex_ctx, duk_small_uint_t start_offset_bytes)
 
DUK_LOCAL void duk__advance_bytes (duk_lexer_ctx *lex_ctx, duk_small_uint_t count_bytes)
 
DUK_LOCAL void duk__init_lexer_window (duk_lexer_ctx *lex_ctx)
 
DUK_LOCAL void duk__initbuffer (duk_lexer_ctx *lex_ctx)
 
DUK_LOCAL void duk__appendbuffer (duk_lexer_ctx *lex_ctx, duk_codepoint_t x)
 
DUK_LOCAL void duk__internbuffer (duk_lexer_ctx *lex_ctx, duk_idx_t valstack_idx)
 
DUK_LOCAL duk_codepoint_t duk__hexval (duk_lexer_ctx *lex_ctx, duk_codepoint_t x)
 
DUK_LOCAL duk_bool_t duk__is_hex_digit (duk_codepoint_t x)
 
DUK_LOCAL duk_codepoint_t duk__decode_hexesc_from_window (duk_lexer_ctx *lex_ctx, duk_small_int_t lookup_offset)
 
DUK_LOCAL duk_codepoint_t duk__decode_uniesc_from_window (duk_lexer_ctx *lex_ctx, duk_small_int_t lookup_offset)
 
DUK_LOCAL void duk__emit_u16_direct_ranges (duk_lexer_ctx *lex_ctx, duk_re_range_callback gen_range, void *userdata, const duk_uint16_t *ranges, duk_small_int_t num)
 
DUK_LOCAL void duk__bi_normalize (duk__bigint *x)
 
DUK_LOCAL void duk__bi_copy (duk__bigint *x, duk__bigint *y)
 
DUK_LOCAL void duk__bi_set_small (duk__bigint *x, duk_uint32_t v)
 
DUK_LOCAL int duk__bi_compare (duk__bigint *x, duk__bigint *y)
 
DUK_LOCAL void duk__bi_add (duk__bigint *x, duk__bigint *y, duk__bigint *z)
 
DUK_LOCAL void duk__bi_add_small (duk__bigint *x, duk__bigint *y, duk_uint32_t z)
 
DUK_LOCAL void duk__bi_sub (duk__bigint *x, duk__bigint *y, duk__bigint *z)
 
DUK_LOCAL void duk__bi_sub_copy (duk__bigint *x, duk__bigint *y, duk__bigint *t)
 
DUK_LOCAL void duk__bi_mul (duk__bigint *x, duk__bigint *y, duk__bigint *z)
 
DUK_LOCAL void duk__bi_mul_small (duk__bigint *x, duk__bigint *y, duk_uint32_t z)
 
DUK_LOCAL void duk__bi_mul_copy (duk__bigint *x, duk__bigint *y, duk__bigint *t)
 
DUK_LOCAL void duk__bi_mul_small_copy (duk__bigint *x, duk_uint32_t y, duk__bigint *t)
 
DUK_LOCAL int duk__bi_is_even (duk__bigint *x)
 
DUK_LOCAL int duk__bi_is_zero (duk__bigint *x)
 
DUK_LOCAL duk_small_int_t duk__bi_is_2to52 (duk__bigint *x)
 
DUK_LOCAL void duk__bi_twoexp (duk__bigint *x, duk_small_int_t y)
 
DUK_LOCAL void duk__bi_exp_small (duk__bigint *x, duk_small_int_t b, duk_small_int_t y, duk__bigint *t1, duk__bigint *t2)
 
DUK_LOCAL duk_size_t duk__dragon4_format_uint32 (duk_uint8_t *buf, duk_uint32_t x, duk_small_int_t radix)
 
DUK_LOCAL void duk__dragon4_prepare (duk__numconv_stringify_ctx *nc_ctx)
 
DUK_LOCAL void duk__dragon4_scale (duk__numconv_stringify_ctx *nc_ctx)
 
DUK_LOCAL void duk__dragon4_generate (duk__numconv_stringify_ctx *nc_ctx)
 
DUK_LOCAL duk_small_int_t duk__dragon4_fixed_format_round (duk__numconv_stringify_ctx *nc_ctx, duk_small_int_t round_idx)
 
DUK_LOCAL void duk__dragon4_convert_and_push (duk__numconv_stringify_ctx *nc_ctx, duk_context *ctx, duk_small_int_t radix, duk_small_int_t digits, duk_small_uint_t flags, duk_small_int_t neg)
 
DUK_LOCAL void duk__dragon4_double_to_ctx (duk__numconv_stringify_ctx *nc_ctx, duk_double_t x)
 
DUK_LOCAL void duk__dragon4_ctx_to_double (duk__numconv_stringify_ctx *nc_ctx, duk_double_t *x)
 
DUK_LOCAL duk_uint32_t duk__encode_i32 (duk_int32_t x)
 
DUK_LOCAL duk_uint32_t duk__insert_u32 (duk_re_compiler_ctx *re_ctx, duk_uint32_t offset, duk_uint32_t x)
 
DUK_LOCAL duk_uint32_t duk__append_u32 (duk_re_compiler_ctx *re_ctx, duk_uint32_t x)
 
DUK_LOCAL duk_uint32_t duk__insert_i32 (duk_re_compiler_ctx *re_ctx, duk_uint32_t offset, duk_int32_t x)
 
DUK_LOCAL void duk__append_u16_list (duk_re_compiler_ctx *re_ctx, const duk_uint16_t *values, duk_uint32_t count)
 
DUK_LOCAL void duk__insert_slice (duk_re_compiler_ctx *re_ctx, duk_uint32_t offset, duk_uint32_t data_offset, duk_uint32_t data_length)
 
DUK_LOCAL void duk__append_slice (duk_re_compiler_ctx *re_ctx, duk_uint32_t data_offset, duk_uint32_t data_length)
 
DUK_LOCAL void duk__remove_slice (duk_re_compiler_ctx *re_ctx, duk_uint32_t data_offset, duk_uint32_t data_length)
 
DUK_LOCAL duk_uint32_t duk__insert_jump_offset (duk_re_compiler_ctx *re_ctx, duk_uint32_t offset, duk_int32_t skip)
 
DUK_LOCAL duk_uint32_t duk__append_jump_offset (duk_re_compiler_ctx *re_ctx, duk_int32_t skip)
 
DUK_LOCAL void duk__generate_ranges (void *userdata, duk_codepoint_t r1, duk_codepoint_t r2, duk_bool_t direct)
 
DUK_LOCAL void duk__parse_disjunction (duk_re_compiler_ctx *re_ctx, duk_bool_t expect_eof, duk__re_disjunction_info *out_atom_info)
 
DUK_LOCAL duk_uint32_t duk__parse_regexp_flags (duk_hthread *thr, duk_hstring *h)
 
DUK_LOCAL void duk__create_escaped_source (duk_hthread *thr, int idx_pattern)
 
DUK_LOCAL duk_uint32_t duk__bc_get_u32 (duk_re_matcher_ctx *re_ctx, const duk_uint8_t **pc)
 
DUK_LOCAL duk_int32_t duk__bc_get_i32 (duk_re_matcher_ctx *re_ctx, const duk_uint8_t **pc)
 
DUK_LOCAL const duk_uint8_t * duk__utf8_backtrack (duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end, duk_uint_fast32_t count)
 
DUK_LOCAL const duk_uint8_t * duk__utf8_advance (duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end, duk_uint_fast32_t count)
 
DUK_LOCAL duk_codepoint_t duk__inp_get_cp (duk_re_matcher_ctx *re_ctx, const duk_uint8_t **sp)
 
DUK_LOCAL const duk_uint8_t * duk__inp_backtrack (duk_re_matcher_ctx *re_ctx, const duk_uint8_t **sp, duk_uint_fast32_t count)
 
DUK_LOCAL duk_codepoint_t duk__inp_get_prev_cp (duk_re_matcher_ctx *re_ctx, const duk_uint8_t *sp)
 
DUK_LOCAL const duk_uint8_t * duk__match_regexp (duk_re_matcher_ctx *re_ctx, const duk_uint8_t *pc, const duk_uint8_t *sp)
 
DUK_LOCAL void duk__regexp_match_helper (duk_hthread *thr, duk_small_int_t force_global)
 
DUK_LOCAL void duk__bw_update_ptrs (duk_hthread *thr, duk_bufwriter_ctx *bw_ctx, duk_size_t curr_offset, duk_size_t new_length)
 

Variables

const duk_uint8_t duk_unicode_ids_noa [791]
 
const duk_uint8_t duk_unicode_ids_m_let_noa [42]
 
const duk_uint8_t duk_unicode_idp_m_ids_noa [397]
 
const duk_uint8_t duk_unicode_caseconv_uc [1288]
 
const duk_uint8_t duk_unicode_caseconv_lc [616]
 
DUK_INTERNAL const char * duk_str_internal_error = "internal error"
 
DUK_INTERNAL const char * duk_str_invalid_count = "invalid count"
 
DUK_INTERNAL const char * duk_str_invalid_call_args = "invalid call args"
 
DUK_INTERNAL const char * duk_str_not_constructable = "not constructable"
 
DUK_INTERNAL const char * duk_str_not_callable = "not callable"
 
DUK_INTERNAL const char * duk_str_not_extensible = "not extensible"
 
DUK_INTERNAL const char * duk_str_not_writable = "not writable"
 
DUK_INTERNAL const char * duk_str_not_configurable = "not configurable"
 
DUK_INTERNAL const char * duk_str_invalid_context = "invalid context"
 
DUK_INTERNAL const char * duk_str_push_beyond_alloc_stack = "attempt to push beyond currently allocated stack"
 
DUK_INTERNAL const char * duk_str_not_buffer = "not buffer"
 
DUK_INTERNAL const char * duk_str_unexpected_type = "unexpected type"
 
DUK_INTERNAL const char * duk_str_defaultvalue_coerce_failed = "[[DefaultValue]] coerce failed"
 
DUK_INTERNAL const char * duk_str_number_outside_range = "number outside range"
 
DUK_INTERNAL const char * duk_str_not_object_coercible = "not object coercible"
 
DUK_INTERNAL const char * duk_str_string_too_long = "string too long"
 
DUK_INTERNAL const char * duk_str_buffer_too_long = "buffer too long"
 
DUK_INTERNAL const char * duk_str_sprintf_too_long = "sprintf message too long"
 
DUK_INTERNAL const char * duk_str_alloc_failed = "alloc failed"
 
DUK_INTERNAL const char * duk_str_pop_too_many = "attempt to pop too many entries"
 
DUK_INTERNAL const char * duk_str_wrong_buffer_type = "wrong buffer type"
 
DUK_INTERNAL const char * duk_str_encode_failed = "encode failed"
 
DUK_INTERNAL const char * duk_str_decode_failed = "decode failed"
 
DUK_INTERNAL const char * duk_str_no_sourcecode = "no sourcecode"
 
DUK_INTERNAL const char * duk_str_concat_result_too_long = "concat result too long"
 
DUK_INTERNAL const char * duk_str_unimplemented = "unimplemented"
 
DUK_INTERNAL const char * duk_str_unsupported = "unsupported"
 
DUK_INTERNAL const char * duk_str_array_length_over_2g = "array length over 2G"
 
DUK_INTERNAL const char * duk_str_fmt_ptr = "%p"
 
DUK_INTERNAL const char * duk_str_fmt_invalid_json = "invalid json (at offset %ld)"
 
DUK_INTERNAL const char * duk_str_jsondec_reclimit = "json decode recursion limit"
 
DUK_INTERNAL const char * duk_str_jsonenc_reclimit = "json encode recursion limit"
 
DUK_INTERNAL const char * duk_str_cyclic_input = "cyclic input"
 
DUK_INTERNAL const char * duk_str_proxy_revoked = "proxy revoked"
 
DUK_INTERNAL const char * duk_str_invalid_base = "invalid base value"
 
DUK_INTERNAL const char * duk_str_strict_caller_read = "attempt to read strict 'caller'"
 
DUK_INTERNAL const char * duk_str_proxy_rejected = "proxy rejected"
 
DUK_INTERNAL const char * duk_str_invalid_array_length = "invalid array length"
 
DUK_INTERNAL const char * duk_str_array_length_write_failed = "array length write failed"
 
DUK_INTERNAL const char * duk_str_array_length_not_writable = "array length non-writable"
 
DUK_INTERNAL const char * duk_str_setter_undefined = "setter undefined"
 
DUK_INTERNAL const char * duk_str_redefine_virt_prop = "attempt to redefine virtual property"
 
DUK_INTERNAL const char * duk_str_invalid_descriptor = "invalid descriptor"
 
DUK_INTERNAL const char * duk_str_property_is_virtual = "property is virtual"
 
DUK_INTERNAL const char * duk_str_parse_error = "parse error"
 
DUK_INTERNAL const char * duk_str_duplicate_label = "duplicate label"
 
DUK_INTERNAL const char * duk_str_invalid_label = "invalid label"
 
DUK_INTERNAL const char * duk_str_invalid_array_literal = "invalid array literal"
 
DUK_INTERNAL const char * duk_str_invalid_object_literal = "invalid object literal"
 
DUK_INTERNAL const char * duk_str_invalid_var_declaration = "invalid variable declaration"
 
DUK_INTERNAL const char * duk_str_cannot_delete_identifier = "cannot delete identifier"
 
DUK_INTERNAL const char * duk_str_invalid_expression = "invalid expression"
 
DUK_INTERNAL const char * duk_str_invalid_lvalue = "invalid lvalue"
 
DUK_INTERNAL const char * duk_str_expected_identifier = "expected identifier"
 
DUK_INTERNAL const char * duk_str_empty_expr_not_allowed = "empty expression not allowed"
 
DUK_INTERNAL const char * duk_str_invalid_for = "invalid for statement"
 
DUK_INTERNAL const char * duk_str_invalid_switch = "invalid switch statement"
 
DUK_INTERNAL const char * duk_str_invalid_break_cont_label = "invalid break/continue label"
 
DUK_INTERNAL const char * duk_str_invalid_return = "invalid return"
 
DUK_INTERNAL const char * duk_str_invalid_try = "invalid try"
 
DUK_INTERNAL const char * duk_str_invalid_throw = "invalid throw"
 
DUK_INTERNAL const char * duk_str_with_in_strict_mode = "with in strict mode"
 
DUK_INTERNAL const char * duk_str_func_stmt_not_allowed = "function statement not allowed"
 
DUK_INTERNAL const char * duk_str_unterminated_stmt = "unterminated statement"
 
DUK_INTERNAL const char * duk_str_invalid_arg_name = "invalid argument name"
 
DUK_INTERNAL const char * duk_str_invalid_func_name = "invalid function name"
 
DUK_INTERNAL const char * duk_str_invalid_getset_name = "invalid getter/setter name"
 
DUK_INTERNAL const char * duk_str_func_name_required = "function name required"
 
DUK_INTERNAL const char * duk_str_invalid_quantifier_no_atom = "quantifier without preceding atom"
 
DUK_INTERNAL const char * duk_str_invalid_quantifier_values = "quantifier values invalid (qmin > qmax)"
 
DUK_INTERNAL const char * duk_str_quantifier_too_many_copies = "quantifier expansion requires too many atom copies"
 
DUK_INTERNAL const char * duk_str_unexpected_closing_paren = "unexpected closing parenthesis"
 
DUK_INTERNAL const char * duk_str_unexpected_end_of_pattern = "unexpected end of pattern"
 
DUK_INTERNAL const char * duk_str_unexpected_regexp_token = "unexpected token in regexp"
 
DUK_INTERNAL const char * duk_str_invalid_regexp_flags = "invalid regexp flags"
 
DUK_INTERNAL const char * duk_str_invalid_backrefs = "invalid backreference(s)"
 
DUK_INTERNAL const char * duk_str_valstack_limit = "valstack limit"
 
DUK_INTERNAL const char * duk_str_callstack_limit = "callstack limit"
 
DUK_INTERNAL const char * duk_str_catchstack_limit = "catchstack limit"
 
DUK_INTERNAL const char * duk_str_prototype_chain_limit = "prototype chain limit"
 
DUK_INTERNAL const char * duk_str_bound_chain_limit = "function call bound chain limit"
 
DUK_INTERNAL const char * duk_str_c_callstack_limit = "C call stack depth limit"
 
DUK_INTERNAL const char * duk_str_compiler_recursion_limit = "compiler recursion limit"
 
DUK_INTERNAL const char * duk_str_bytecode_limit = "bytecode limit"
 
DUK_INTERNAL const char * duk_str_reg_limit = "register limit"
 
DUK_INTERNAL const char * duk_str_temp_limit = "temp limit"
 
DUK_INTERNAL const char * duk_str_const_limit = "const limit"
 
DUK_INTERNAL const char * duk_str_func_limit = "function limit"
 
DUK_INTERNAL const char * duk_str_regexp_compiler_recursion_limit = "regexp compiler recursion limit"
 
DUK_INTERNAL const char * duk_str_regexp_executor_recursion_limit = "regexp executor recursion limit"
 
DUK_INTERNAL const char * duk_str_regexp_executor_step_limit = "regexp step limit"
 
DUK_INTERNAL const duk_uint8_t duk_strings_data [1049]
 
DUK_INTERNAL const duk_c_function duk_bi_native_functions [149]
 
DUK_INTERNAL const duk_uint8_t duk_initjs_data [204]
 
DUK_INTERNAL const duk_int8_t duk_is_idchar_tab [128]
 
DUK_INTERNAL const duk_uint8_t duk_unicode_xutf8_markers [7]
 
DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_digit [2]
 
DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_white [22]
 
DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_wordchar [8]
 
DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_not_digit [4]
 
DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_not_white [24]
 
DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_not_wordchar [10]
 
DUK_INTERNAL const duk_uint8_t duk_lc_digits [36]
 
DUK_INTERNAL const duk_uint8_t duk_uc_nybbles [16]
 
DUK_INTERNAL const duk_int8_t duk_hex_dectab [256]
 
DUK_INTERNAL const duk_int16_t duk_hex_dectab_shift4 [256]
 
DUK_INTERNAL const duk_uint16_t duk_hex_enctab [256]
 
DUK_INTERNAL const duk_uint8_t duk_base64_enctab [64]
 
DUK_INTERNAL const duk_int8_t duk_base64_dectab [256]
 
DUK_LOCAL const duk_int8_t duk__hash_size_corrections []
 
DUK_INTERNAL duk_uint8_t duk_util_probe_steps [32]
 
DUK_INTERNAL duk_uint8_t duk_class_number_to_stridx [32]
 
DUK_EXTERNAL const char * duk_api_global_filename = NULL
 
DUK_EXTERNAL duk_int_t duk_api_global_line = 0
 
static const duk_uint32_t duk__bufobj_flags_lookup []
 
static const duk_uint8_t duk__buffer_class_from_elemtype [9]
 
static const duk_uint8_t duk__buffer_proto_from_elemtype [9]
 
static const duk_uint8_t duk__buffer_nbytes_from_fldtype [6]
 
static duk_uint16_t duk__buffer_elemtype_copy_compatible [9]
 
DUK_LOCAL duk_uint8_t duk__date_equivyear [14]
 
DUK_LOCAL const duk_uint8_t duk__parse_iso8601_seps []
 
DUK_LOCAL const duk_uint32_t duk__parse_iso8601_control []
 
DUK_LOCAL duk_uint8_t duk__days_in_month [12]
 
static duk_uint16_t duk__date_magics []
 
DUK_LOCAL const duk_uint8_t duk__encode_uriunescaped_table [16]
 
DUK_LOCAL const duk_uint8_t duk__encode_uricomponent_unescaped_table [16]
 
DUK_LOCAL const duk_uint8_t duk__decode_uri_reserved_table [16]
 
DUK_LOCAL const duk_uint8_t duk__decode_uri_component_reserved_table [16]
 
DUK_LOCAL const duk_uint8_t duk__escape_unescaped_table [16]
 
DUK_LOCAL const duk_uint8_t duk__json_quotestr_lookup [256]
 
DUK_LOCAL const duk_uint8_t duk__json_decstr_lookup [256]
 
DUK_LOCAL const duk_uint8_t duk__json_eatwhite_lookup [256]
 
DUK_LOCAL const duk_uint8_t duk__json_decnumber_lookup [256]
 
DUK_LOCAL const duk_uint8_t duk__log_level_strings []
 
DUK_LOCAL const duk__one_arg_func duk__one_arg_funcs []
 
DUK_LOCAL const duk__two_arg_func duk__two_arg_funcs []
 
DUK_LOCAL const duk_uint16_t duk__bufferobject_virtual_props []
 
DUK_LOCAL const duk_uint8_t duk__token_lbp []
 
DUK_LOCAL const duk_uint16_t duk__closure_copy_proplist []
 
DUK_LOCAL const duk_uint8_t duk__str2num_digits_for_radix []
 
DUK_LOCAL const duk__exp_limits duk__str2num_exp_limits []
 

Macro Definition Documentation

◆ DUK__ADVANCEBYTES

#define DUK__ADVANCEBYTES ( lex_ctx,
count )   duk__advance_bytes((lex_ctx), (count))

Definition at line 73408 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK__ADVANCECHARS

#define DUK__ADVANCECHARS ( lex_ctx,
count )   duk__advance_bytes((lex_ctx), (count) * sizeof(duk_lexer_codepoint))

Definition at line 73407 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK__ADVTOK

#define DUK__ADVTOK ( advbytes,
tok )   ((((advbytes) * sizeof(duk_lexer_codepoint)) << 8) + (tok))

Definition at line 73421 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK__ALLOCTEMP

#define DUK__ALLOCTEMP ( comp_ctx)    duk__alloctemp((comp_ctx))

◆ DUK__ALLOCTEMPS

#define DUK__ALLOCTEMPS ( comp_ctx,
count )   duk__alloctemps((comp_ctx),(count))

◆ DUK__ALLOW_AUTO_SEMI_ALWAYS

#define DUK__ALLOW_AUTO_SEMI_ALWAYS   (1 << 2) /* allow automatic semicolon even without lineterm (compatibility) */

Definition at line 62669 of file duktape-1.8.0/src/duktape.c.

◆ DUK__APPENDBUFFER

#define DUK__APPENDBUFFER ( lex_ctx,
x )   duk__appendbuffer((lex_ctx), (duk_codepoint_t) (x))

Definition at line 73410 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK__ARRAY_MID_JOIN_LIMIT

#define DUK__ARRAY_MID_JOIN_LIMIT   4096

Definition at line 20261 of file duktape-1.8.0/src/duktape.c.

◆ DUK__ASSERT_LEFT

#define DUK__ASSERT_LEFT ( n)
Value:
do { \
DUK_ASSERT((duk_size_t) (p_end - p) >= (duk_size_t) (n)); \
} while (0)

Definition at line 12015 of file duktape-1.8.0/src/duktape.c.

12015 p = duk__dump_formals(thr, p, bw_ctx, (duk_hobject *) func);
12016
12017 DUK_DD(DUK_DDPRINT("serialized function %p -> final pointer %p", (void *) func, (void *) p));
DUK_LOCAL duk_uint8_t * duk__dump_formals(duk_hthread *thr, duk_uint8_t *p, duk_bufwriter_ctx *bw_ctx, duk_hobject *func)
#define DUK_DD(x)
#define DUK_DDPRINT

◆ DUK__BC_INITIAL_INSTS

#define DUK__BC_INITIAL_INSTS   256

Definition at line 57764 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BI_MAX_PARTS

#define DUK__BI_MAX_PARTS   37 /* 37x32 = 1184 bits */

Definition at line 75460 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BI_PRINT

#define DUK__BI_PRINT ( name,
x )

Definition at line 75465 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BIDX_BITS

#define DUK__BIDX_BITS   7

Definition at line 53574 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BITPACK_FF

#define DUK__BITPACK_FF   27

Definition at line 41018 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BITPACK_LETTER_LIMIT

#define DUK__BITPACK_LETTER_LIMIT   26

Definition at line 41016 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BITPACK_SEVENBIT

#define DUK__BITPACK_SEVENBIT   31

Definition at line 41021 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BITPACK_SWITCH

#define DUK__BITPACK_SWITCH   30

Definition at line 41020 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BITPACK_SWITCH1

#define DUK__BITPACK_SWITCH1   29

Definition at line 41019 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BITPACK_UNDERSCORE

#define DUK__BITPACK_UNDERSCORE   26

Definition at line 41017 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BP_ADDITIVE

#define DUK__BP_ADDITIVE   28

Definition at line 57972 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BP_ASSIGNMENT

#define DUK__BP_ASSIGNMENT   8

Definition at line 57962 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BP_BAND

#define DUK__BP_BAND   20

Definition at line 57968 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BP_BOR

#define DUK__BP_BOR   16

Definition at line 57966 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BP_BXOR

#define DUK__BP_BXOR   18

Definition at line 57967 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BP_CALL

#define DUK__BP_CALL   34

Definition at line 57975 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BP_CLOSING

#define DUK__BP_CLOSING   4 /* token closes expression, e.g. ')', ']' */

Definition at line 57959 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BP_COMMA

#define DUK__BP_COMMA   6

Definition at line 57961 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_var_decl().

◆ DUK__BP_CONDITIONAL

#define DUK__BP_CONDITIONAL   10

Definition at line 57963 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BP_EOF

#define DUK__BP_EOF   2

Definition at line 57958 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BP_EQUALITY

#define DUK__BP_EQUALITY   22

Definition at line 57969 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BP_FOR_EXPR

#define DUK__BP_FOR_EXPR   DUK__BP_CLOSING /* bp to use when parsing a top level Expression */

Definition at line 57960 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_try_stmt().

◆ DUK__BP_INVALID

#define DUK__BP_INVALID   0 /* always terminates led() */

Definition at line 57957 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BP_LAND

#define DUK__BP_LAND   14

Definition at line 57965 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BP_LOR

#define DUK__BP_LOR   12

Definition at line 57964 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BP_MEMBER

#define DUK__BP_MEMBER   36

Definition at line 57976 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BP_MULTIPLICATIVE

#define DUK__BP_MULTIPLICATIVE   30

Definition at line 57973 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BP_POSTFIX

#define DUK__BP_POSTFIX   32

Definition at line 57974 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BP_RELATIONAL

#define DUK__BP_RELATIONAL   24

Definition at line 57970 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BP_SHIFT

#define DUK__BP_SHIFT   26

Definition at line 57971 of file duktape-1.8.0/src/duktape.c.

◆ DUK__BYTECODE_INITIAL_ALLOC

#define DUK__BYTECODE_INITIAL_ALLOC   256

Definition at line 11669 of file duktape-1.8.0/src/duktape.c.

◆ DUK__CF_ACCEPT

#define DUK__CF_ACCEPT   (1 << 1) /* accept string */

Definition at line 24756 of file duktape-1.8.0/src/duktape.c.

◆ DUK__CF_ACCEPT_NUL

#define DUK__CF_ACCEPT_NUL   (1 << 2) /* accept string if next char is NUL (otherwise reject) */

Definition at line 24757 of file duktape-1.8.0/src/duktape.c.

◆ DUK__CF_NEG

#define DUK__CF_NEG   (1 << 0) /* continue matching, set neg_tzoffset flag */

Definition at line 24755 of file duktape-1.8.0/src/duktape.c.

◆ DUK__CHECK_BITMASK

#define DUK__CHECK_BITMASK ( table,
cp )   ((table)[(cp) >> 3] & (1 << ((cp) & 0x07)))

Definition at line 27826 of file duktape-1.8.0/src/duktape.c.

◆ DUK__CHECK_SPACE

#define DUK__CHECK_SPACE ( )
Value:
do { \
if (DUK_UNLIKELY(thr->valstack_top >= thr->valstack_end)) { \
DUK_ERROR_API(thr, DUK_STR_PUSH_BEYOND_ALLOC_STACK); \
} \
} while (0)
#define DUK_STR_PUSH_BEYOND_ALLOC_STACK

Definition at line 15045 of file duktape-1.8.0/src/duktape.c.

15045
15046#ifndef DUK_USE_VARIADIC_MACROS
15049#endif
duk_int_fast32_t duk_int_t
DUK_EXTERNAL duk_int_t duk_api_global_line
DUK_EXTERNAL const char * duk_api_global_filename
#define NULL
Definition gmacros.h:924

Referenced by duk_dup_top(), and duk_push_undefined().

◆ DUK__CLASS_BITS

#define DUK__CLASS_BITS   5

Definition at line 53573 of file duktape-1.8.0/src/duktape.c.

◆ DUK__COMPILE_ENTRY_SLOTS

#define DUK__COMPILE_ENTRY_SLOTS   8

Definition at line 57779 of file duktape-1.8.0/src/duktape.c.

◆ DUK__CONST

#define DUK__CONST ( x)    (*(consts + (x)))

Definition at line 67525 of file duktape-1.8.0/src/duktape.c.

◆ DUK__CONST_MARKER

#define DUK__CONST_MARKER   DUK_JS_CONST_MARKER

Definition at line 57747 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__ispec_toregconst_raw().

◆ DUK__CONSTP

#define DUK__CONSTP ( x)    (consts + (x))

Definition at line 67526 of file duktape-1.8.0/src/duktape.c.

◆ DUK__DELETED_MARKER

#define DUK__DELETED_MARKER ( heap)    DUK_STRTAB_DELETED_MARKER((heap))

Definition at line 45015 of file duktape-1.8.0/src/duktape.c.

◆ DUK__DIGITCHAR

#define DUK__DIGITCHAR ( x)    duk_lc_digits[(x)]

Definition at line 75404 of file duktape-1.8.0/src/duktape.c.

◆ DUK__DPRINT_DPARTS

#define DUK__DPRINT_DPARTS ( dparts)
Value:
do { \
DUK_D(DUK_DPRINT("dparts: %lf %lf %lf %lf %lf %lf %lf %lf", \
(double) (dparts)[0], (double) (dparts)[1], \
(double) (dparts)[2], (double) (dparts)[3], \
(double) (dparts)[4], (double) (dparts)[5], \
(double) (dparts)[6], (double) (dparts)[7])); \
} while (0)
#define DUK_DPRINT

Definition at line 24660 of file duktape-1.8.0/src/duktape.c.

24660 DUK_D(DUK_DPRINT("parts: %ld %ld %ld %ld %ld %ld %ld %ld, dparts: %lf %lf %lf %lf %lf %lf %lf %lf", \
24661 (long) (parts)[0], (long) (parts)[1], \
24662 (long) (parts)[2], (long) (parts)[3], \
24663 (long) (parts)[4], (long) (parts)[5], \
24664 (long) (parts)[6], (long) (parts)[7], \
24665 (double) (dparts)[0], (double) (dparts)[1], \
24666 (double) (dparts)[2], (double) (dparts)[3], \
#define DUK_D(x)

◆ DUK__DPRINT_PARTS

#define DUK__DPRINT_PARTS ( parts)
Value:
do { \
DUK_D(DUK_DPRINT("parts: %ld %ld %ld %ld %ld %ld %ld %ld", \
(long) (parts)[0], (long) (parts)[1], \
(long) (parts)[2], (long) (parts)[3], \
(long) (parts)[4], (long) (parts)[5], \
(long) (parts)[6], (long) (parts)[7])); \
} while (0)

Definition at line 24653 of file duktape-1.8.0/src/duktape.c.

24653
24654/*
24655 * Other file level defines
24656 */
24657
24658/* Debug macro to print all parts and dparts (used manually because of debug level). */
24659#define DUK__DPRINT_PARTS_AND_DPARTS(parts,dparts) do { \

◆ DUK__DPRINT_PARTS_AND_DPARTS

#define DUK__DPRINT_PARTS_AND_DPARTS ( parts,
dparts )
Value:
do { \
DUK_D(DUK_DPRINT("parts: %ld %ld %ld %ld %ld %ld %ld %ld, dparts: %lf %lf %lf %lf %lf %lf %lf %lf", \
(long) (parts)[0], (long) (parts)[1], \
(long) (parts)[2], (long) (parts)[3], \
(long) (parts)[4], (long) (parts)[5], \
(long) (parts)[6], (long) (parts)[7], \
(double) (dparts)[0], (double) (dparts)[1], \
(double) (dparts)[2], (double) (dparts)[3], \
(double) (dparts)[4], (double) (dparts)[5], \
(double) (dparts)[6], (double) (dparts)[7])); \
} while (0)

Definition at line 24642 of file duktape-1.8.0/src/duktape.c.

24642
24643/* include removed: duk_internal.h */
24644
24645/*
24646 * Forward declarations
24647 */
24648
unsigned int duk_small_uint_t
duk_small_int_t duk_ret_t
DUK_LOCAL_DECL duk_double_t duk__push_this_get_timeval_tzoffset(duk_context *ctx, duk_small_uint_t flags, duk_int_t *out_tzoffset)
DUK_LOCAL_DECL duk_ret_t duk__set_this_timeval_from_dparts(duk_context *ctx, duk_double_t *dparts, duk_small_uint_t flags)
DUK_LOCAL_DECL void duk__twodigit_year_fixup(duk_context *ctx, duk_idx_t idx_val)
DUK_LOCAL_DECL duk_double_t duk__push_this_get_timeval(duk_context *ctx, duk_small_uint_t flags)

◆ DUK__DRAGON4_OUTPUT_PREINC

#define DUK__DRAGON4_OUTPUT_PREINC ( nc_ctx,
preinc_idx,
x )
Value:
do { \
DUK_ASSERT((preinc_idx) - 1 >= 0); \
DUK_ASSERT((preinc_idx) - 1 < DUK__MAX_OUTPUT_DIGITS); \
((nc_ctx)->digits[(preinc_idx) - 1]) = (duk_uint8_t) (x); \
} while (0)
#define DUK__MAX_OUTPUT_DIGITS

Definition at line 76053 of file duktape-1.8.0/src/duktape.c.

76053 duk_small_int_t e; /* exponent for 'f' */
76054 duk_small_int_t b; /* input radix */
76055 duk_small_int_t B; /* output radix */
76056 duk_small_int_t k; /* see algorithm */
76057 duk_small_int_t low_ok; /* see algorithm */

◆ DUK__DUMP_ISPEC

#define DUK__DUMP_ISPEC ( comp_ctx,
x )   do {} while (0)

Definition at line 59526 of file duktape-1.8.0/src/duktape.c.

◆ DUK__DUMP_IVALUE

#define DUK__DUMP_IVALUE ( comp_ctx,
x )   do {} while (0)

Definition at line 59527 of file duktape-1.8.0/src/duktape.c.

◆ DUK__EMIT_1

#define DUK__EMIT_1 ( js_ctx,
ch )   duk__emit_1((js_ctx), (duk_uint_fast8_t) (ch))

Definition at line 30135 of file duktape-1.8.0/src/duktape.c.

◆ DUK__EMIT_2

#define DUK__EMIT_2 ( js_ctx,
ch1,
ch2 )   duk__emit_2((js_ctx), (duk_uint_fast8_t) (ch1), (duk_uint_fast8_t) (ch2))

Definition at line 30136 of file duktape-1.8.0/src/duktape.c.

◆ DUK__EMIT_CSTR

#define DUK__EMIT_CSTR ( js_ctx,
p )   duk__emit_cstring((js_ctx), (p))

Definition at line 30139 of file duktape-1.8.0/src/duktape.c.

◆ DUK__EMIT_FLAG_A_IS_SOURCE

#define DUK__EMIT_FLAG_A_IS_SOURCE   (1 << 11) /* slot A is a source (default: target) */

Definition at line 58722 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_var_decl().

◆ DUK__EMIT_FLAG_B_IS_TARGET

#define DUK__EMIT_FLAG_B_IS_TARGET   (1 << 12) /* slot B is a target (default: source) */

Definition at line 58723 of file duktape-1.8.0/src/duktape.c.

◆ DUK__EMIT_FLAG_B_IS_TARGETSOURCE

#define DUK__EMIT_FLAG_B_IS_TARGETSOURCE   (1 << 14) /* slot B is both a target and a source (used by extraops like DUK_EXTRAOP_INSTOF */

Definition at line 58725 of file duktape-1.8.0/src/duktape.c.

◆ DUK__EMIT_FLAG_C_IS_TARGET

#define DUK__EMIT_FLAG_C_IS_TARGET   (1 << 13) /* slot C is a target (default: source) */

Definition at line 58724 of file duktape-1.8.0/src/duktape.c.

◆ DUK__EMIT_FLAG_NO_SHUFFLE_A

#define DUK__EMIT_FLAG_NO_SHUFFLE_A   (1 << 8)

◆ DUK__EMIT_FLAG_NO_SHUFFLE_B

#define DUK__EMIT_FLAG_NO_SHUFFLE_B   (1 << 9)

Definition at line 58720 of file duktape-1.8.0/src/duktape.c.

◆ DUK__EMIT_FLAG_NO_SHUFFLE_C

#define DUK__EMIT_FLAG_NO_SHUFFLE_C   (1 << 10)

Definition at line 58721 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__emit_invalid().

◆ DUK__EMIT_FLAG_RESERVE_JUMPSLOT

#define DUK__EMIT_FLAG_RESERVE_JUMPSLOT   (1 << 15) /* reserve a jumpslot after instr before target spilling, used for NEXTENUM */

Definition at line 58726 of file duktape-1.8.0/src/duktape.c.

◆ DUK__EMIT_HSTR

#define DUK__EMIT_HSTR ( js_ctx,
h )   duk__emit_hstring((js_ctx), (h))

Definition at line 30137 of file duktape-1.8.0/src/duktape.c.

◆ DUK__EMIT_STRIDX

#define DUK__EMIT_STRIDX ( js_ctx,
i )   duk__emit_stridx((js_ctx), (i))

Definition at line 30141 of file duktape-1.8.0/src/duktape.c.

◆ DUK__ENUM_START_INDEX

#define DUK__ENUM_START_INDEX   2

Definition at line 46405 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__sort_array_indices().

◆ DUK__ERRFMT_BUFSIZE

#define DUK__ERRFMT_BUFSIZE   256 /* size for formatting buffers */

Definition at line 9774 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_err_handle_error().

◆ DUK__EXPR_FLAG_ALLOW_EMPTY

#define DUK__EXPR_FLAG_ALLOW_EMPTY   (1 << 9) /* allow empty expression */

Definition at line 62476 of file duktape-1.8.0/src/duktape.c.

◆ DUK__EXPR_FLAG_REJECT_IN

#define DUK__EXPR_FLAG_REJECT_IN   (1 << 8) /* reject 'in' token (used for for-in) */

Definition at line 62475 of file duktape-1.8.0/src/duktape.c.

◆ DUK__EXPR_FLAG_REQUIRE_INIT

#define DUK__EXPR_FLAG_REQUIRE_INIT   (1 << 10) /* require initializer for var/const */

Definition at line 62477 of file duktape-1.8.0/src/duktape.c.

◆ DUK__EXPR_RBP_MASK

#define DUK__EXPR_RBP_MASK   0xff

Definition at line 62474 of file duktape-1.8.0/src/duktape.c.

◆ DUK__FLD_16BIT

#define DUK__FLD_16BIT   1

Definition at line 24046 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_buffer_readfield().

◆ DUK__FLD_32BIT

#define DUK__FLD_32BIT   2

Definition at line 24047 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_buffer_readfield().

◆ DUK__FLD_8BIT

#define DUK__FLD_8BIT   0

Definition at line 24045 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_buffer_readfield().

◆ DUK__FLD_BIGENDIAN

#define DUK__FLD_BIGENDIAN   (1 << 3)

Definition at line 24051 of file duktape-1.8.0/src/duktape.c.

◆ DUK__FLD_DOUBLE

#define DUK__FLD_DOUBLE   4

Definition at line 24049 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_buffer_readfield().

◆ DUK__FLD_FLOAT

#define DUK__FLD_FLOAT   3

Definition at line 24048 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_buffer_readfield().

◆ DUK__FLD_SIGNED

#define DUK__FLD_SIGNED   (1 << 4)

Definition at line 24052 of file duktape-1.8.0/src/duktape.c.

◆ DUK__FLD_TYPEDARRAY

#define DUK__FLD_TYPEDARRAY   (1 << 5)

Definition at line 24053 of file duktape-1.8.0/src/duktape.c.

◆ DUK__FLD_VARINT

#define DUK__FLD_VARINT   5

Definition at line 24050 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_buffer_readfield().

◆ DUK__FUN

#define DUK__FUN ( )    ((duk_hcompiledfunction *) DUK_ACT_GET_FUNC((thr)->callstack + (thr)->callstack_top - 1))

Definition at line 67516 of file duktape-1.8.0/src/duktape.c.

◆ DUK__FUNCTION_BODY_REQUIRE_SLOTS

#define DUK__FUNCTION_BODY_REQUIRE_SLOTS   16

Definition at line 57781 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_func_body().

◆ DUK__FUNCTION_INIT_REQUIRE_SLOTS

#define DUK__FUNCTION_INIT_REQUIRE_SLOTS   16

Definition at line 57780 of file duktape-1.8.0/src/duktape.c.

◆ DUK__GETCONST_MAX_CONSTS_CHECK

#define DUK__GETCONST_MAX_CONSTS_CHECK   256

Definition at line 57754 of file duktape-1.8.0/src/duktape.c.

◆ DUK__GETTEMP

#define DUK__GETTEMP ( comp_ctx)    ((comp_ctx)->curr_func.temp_next)

Definition at line 59490 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_func_body().

◆ DUK__HAS_TERM

#define DUK__HAS_TERM   (1 << 1) /* stmt has explicit/implicit semicolon terminator */

Definition at line 62668 of file duktape-1.8.0/src/duktape.c.

◆ DUK__HAS_VAL

#define DUK__HAS_VAL   (1 << 0) /* stmt has non-empty value */

Definition at line 62667 of file duktape-1.8.0/src/duktape.c.

◆ DUK__HASH_DELETED

#define DUK__HASH_DELETED   DUK_HOBJECT_HASHIDX_DELETED

Definition at line 47482 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__realloc_props().

◆ DUK__HASH_INITIAL [1/2]

#define DUK__HASH_INITIAL ( hash,
h_size )   DUK_STRTAB_HASH_INITIAL((hash),(h_size))

Definition at line 45013 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__realloc_props().

◆ DUK__HASH_INITIAL [2/2]

#define DUK__HASH_INITIAL ( hash,
h_size )   DUK_HOBJECT_HASH_INITIAL((hash),(h_size))

Definition at line 45013 of file duktape-1.8.0/src/duktape.c.

◆ DUK__HASH_PROBE_STEP [1/2]

#define DUK__HASH_PROBE_STEP ( hash)    DUK_STRTAB_HASH_PROBE_STEP((hash))

Definition at line 45014 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__realloc_props().

◆ DUK__HASH_PROBE_STEP [2/2]

#define DUK__HASH_PROBE_STEP ( hash)    DUK_HOBJECT_HASH_PROBE_STEP((hash))

Definition at line 45014 of file duktape-1.8.0/src/duktape.c.

◆ DUK__HASH_SIZE_RATIO

#define DUK__HASH_SIZE_RATIO   1177 /* floor(1.15 * (1 << 10)) */

Definition at line 11350 of file duktape-1.8.0/src/duktape.c.

◆ DUK__HASH_UNUSED

#define DUK__HASH_UNUSED   DUK_HOBJECT_HASHIDX_UNUSED

Definition at line 47481 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__realloc_props().

◆ DUK__HEAP_CLEAR_FLAGS

#define DUK__HEAP_CLEAR_FLAGS ( heap,
bits )
Value:
do { \
(heap)->flags &= ~(bits); \
} while (0)

Definition at line 6701 of file duktape-1.8.0/src/duktape.c.

6701#define DUK_HEAP_FLAG_ERRHANDLER_RUNNING (1 << 3) /* an error handler (user callback to augment/replace error) is running */
6702#define DUK_HEAP_FLAG_INTERRUPT_RUNNING (1 << 4) /* executor interrupt running (used to avoid nested interrupts) */
6703#define DUK_HEAP_FLAG_FINALIZER_NORESCUE (1 << 5) /* heap destruction ongoing, finalizer rescue no longer possible */

◆ DUK__HEAP_HAS_FLAGS

#define DUK__HEAP_HAS_FLAGS ( heap,
bits )   ((heap)->flags & (bits))

Definition at line 6697 of file duktape-1.8.0/src/duktape.c.

◆ DUK__HEAP_SET_FLAGS

#define DUK__HEAP_SET_FLAGS ( heap,
bits )
Value:
do { \
(heap)->flags |= (bits); \
} while (0)

Definition at line 6698 of file duktape-1.8.0/src/duktape.c.

6698#define DUK_HEAP_FLAG_MARKANDSWEEP_RUNNING (1 << 0) /* mark-and-sweep is currently running */
6699#define DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED (1 << 1) /* mark-and-sweep marking reached a recursion limit and must use multi-pass marking */
6700#define DUK_HEAP_FLAG_REFZERO_FREE_RUNNING (1 << 2) /* refcount code is processing refzero list */

◆ DUK__IDX_DUKTAPE

#define DUK__IDX_DUKTAPE   5 /* Duktape object */

Definition at line 28821 of file duktape-1.8.0/src/duktape.c.

◆ DUK__IDX_EXPORTS

#define DUK__IDX_EXPORTS   9 /* Default exports table */

Definition at line 28825 of file duktape-1.8.0/src/duktape.c.

◆ DUK__IDX_FRESH_REQUIRE

#define DUK__IDX_FRESH_REQUIRE   8 /* New require() function for module, updated resolution base */

Definition at line 28824 of file duktape-1.8.0/src/duktape.c.

◆ DUK__IDX_LASTCOMP

#define DUK__IDX_LASTCOMP   4 /* Last component name in resolved path */

Definition at line 28820 of file duktape-1.8.0/src/duktape.c.

◆ DUK__IDX_MODLOADED

#define DUK__IDX_MODLOADED   6 /* Duktape.modLoaded[] module cache */

Definition at line 28822 of file duktape-1.8.0/src/duktape.c.

◆ DUK__IDX_MODULE

#define DUK__IDX_MODULE   10 /* Module object containing module.exports, etc */

Definition at line 28826 of file duktape-1.8.0/src/duktape.c.

◆ DUK__IDX_REQUESTED_ID

#define DUK__IDX_REQUESTED_ID   0 /* Module id requested */

Definition at line 28816 of file duktape-1.8.0/src/duktape.c.

◆ DUK__IDX_REQUIRE

#define DUK__IDX_REQUIRE   1 /* Current require() function */

Definition at line 28817 of file duktape-1.8.0/src/duktape.c.

◆ DUK__IDX_REQUIRE_ID

#define DUK__IDX_REQUIRE_ID   2 /* The base ID of the current require() function, resolution base */

Definition at line 28818 of file duktape-1.8.0/src/duktape.c.

◆ DUK__IDX_RESOLVED_ID

#define DUK__IDX_RESOLVED_ID   3 /* Resolved, normalized absolute module ID */

Definition at line 28819 of file duktape-1.8.0/src/duktape.c.

◆ DUK__IDX_UNDEFINED

#define DUK__IDX_UNDEFINED   7 /* 'undefined', artifact of lookup */

Definition at line 28823 of file duktape-1.8.0/src/duktape.c.

◆ DUK__IEEE_DOUBLE_EXP_BIAS

#define DUK__IEEE_DOUBLE_EXP_BIAS   1023

Definition at line 75401 of file duktape-1.8.0/src/duktape.c.

◆ DUK__IEEE_DOUBLE_EXP_MIN

#define DUK__IEEE_DOUBLE_EXP_MIN   (-1022) /* biased exp == 0 -> denormal, exp -1022 */

Definition at line 75402 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__dragon4_ctx_to_double().

◆ DUK__INITBUFFER

#define DUK__INITBUFFER ( lex_ctx)    duk__initbuffer((lex_ctx))

Definition at line 73409 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK__INTERNAL_ERROR

#define DUK__INTERNAL_ERROR ( msg)
Value:
do { \
DUK_ERROR_INTERNAL(thr, (msg)); \
} while (0)

Definition at line 67542 of file duktape-1.8.0/src/duktape.c.

67542#define DUK__CONST(x) (*(consts + (x)))
67543#define DUK__CONSTP(x) (consts + (x))
67544#if 0

◆ DUK__IS_TERMINAL

#define DUK__IS_TERMINAL   (1 << 4) /* statement is guaranteed to be terminal (control doesn't flow to next statement) */

Definition at line 62671 of file duktape-1.8.0/src/duktape.c.

◆ DUK__ISCONST

#define DUK__ISCONST ( comp_ctx,
x )   (((x) & DUK__CONST_MARKER) != 0)

Definition at line 59488 of file duktape-1.8.0/src/duktape.c.

◆ DUK__ISDIGIT

#define DUK__ISDIGIT ( x)    ((x) >= DUK_ASC_0 && (x) <= DUK_ASC_9)

Definition at line 73399 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK__ISDIGIT03

#define DUK__ISDIGIT03 ( x)    ((x) >= DUK_ASC_0 && (x) <= DUK_ASC_3)

Definition at line 73402 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK__ISDIGIT47

#define DUK__ISDIGIT47 ( x)    ((x) >= DUK_ASC_4 && (x) <= DUK_ASC_7)

Definition at line 73403 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK__ISHEXDIGIT

#define DUK__ISHEXDIGIT ( x)    duk__is_hex_digit((x))

Definition at line 73400 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK__ISOCTDIGIT

#define DUK__ISOCTDIGIT ( x)    ((x) >= DUK_ASC_0 && (x) <= DUK_ASC_7)

Definition at line 73401 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK__ISREG

#define DUK__ISREG ( comp_ctx,
x )   (((x) & DUK__CONST_MARKER) == 0)

Definition at line 59487 of file duktape-1.8.0/src/duktape.c.

◆ DUK__ISTEMP

#define DUK__ISTEMP ( comp_ctx,
x )   (DUK__ISREG((comp_ctx), (x)) && (duk_regconst_t) (x) >= (duk_regconst_t) ((comp_ctx)->curr_func.temp_first))

Definition at line 59489 of file duktape-1.8.0/src/duktape.c.

◆ DUK__ITER_EVERY

#define DUK__ITER_EVERY   0

Definition at line 21419 of file duktape-1.8.0/src/duktape.c.

◆ DUK__ITER_FILTER

#define DUK__ITER_FILTER   4

Definition at line 21423 of file duktape-1.8.0/src/duktape.c.

◆ DUK__ITER_FOREACH

#define DUK__ITER_FOREACH   2

Definition at line 21421 of file duktape-1.8.0/src/duktape.c.

◆ DUK__ITER_MAP

#define DUK__ITER_MAP   3

Definition at line 21422 of file duktape-1.8.0/src/duktape.c.

◆ DUK__ITER_SOME

#define DUK__ITER_SOME   1

Definition at line 21420 of file duktape-1.8.0/src/duktape.c.

◆ DUK__IVAL_FLAG_ALLOW_CONST

#define DUK__IVAL_FLAG_ALLOW_CONST   (1 << 0) /* allow a constant to be returned */

◆ DUK__IVAL_FLAG_REQUIRE_SHORT

#define DUK__IVAL_FLAG_REQUIRE_SHORT   (1 << 2) /* require a short (8-bit) reg/const which fits into bytecode B/C slot */

Definition at line 59502 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__ispec_toregconst_raw().

◆ DUK__IVAL_FLAG_REQUIRE_TEMP

#define DUK__IVAL_FLAG_REQUIRE_TEMP   (1 << 1) /* require a (mutable) temporary as a result (or a const if allowed) */

◆ DUK__JSON_DECSTR_BUFSIZE

#define DUK__JSON_DECSTR_BUFSIZE   128

Definition at line 29114 of file duktape-1.8.0/src/duktape.c.

◆ DUK__JSON_DECSTR_CHUNKSIZE

#define DUK__JSON_DECSTR_CHUNKSIZE   64

Definition at line 29115 of file duktape-1.8.0/src/duktape.c.

◆ DUK__JSON_ENCSTR_CHUNKSIZE

#define DUK__JSON_ENCSTR_CHUNKSIZE   64

Definition at line 29116 of file duktape-1.8.0/src/duktape.c.

◆ DUK__JSON_MAX_ESC_LEN

#define DUK__JSON_MAX_ESC_LEN   10 /* '\Udeadbeef' */

Definition at line 29118 of file duktape-1.8.0/src/duktape.c.

◆ DUK__JSON_STRINGIFY_BUFSIZE

#define DUK__JSON_STRINGIFY_BUFSIZE   128

Definition at line 29117 of file duktape-1.8.0/src/duktape.c.

◆ DUK__L0

#define DUK__L0 ( )    DUK__LOOKUP(lex_ctx, 0)

Definition at line 73413 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK__L1

#define DUK__L1 ( )    DUK__LOOKUP(lex_ctx, 1)

Definition at line 73414 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK__L2

#define DUK__L2 ( )    DUK__LOOKUP(lex_ctx, 2)

Definition at line 73415 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK__L3

#define DUK__L3 ( )    DUK__LOOKUP(lex_ctx, 3)

Definition at line 73416 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK__L4

#define DUK__L4 ( )    DUK__LOOKUP(lex_ctx, 4)

Definition at line 73417 of file duktape-1.8.0/src/duktape.c.

◆ DUK__L5

#define DUK__L5 ( )    DUK__LOOKUP(lex_ctx, 5)

Definition at line 73418 of file duktape-1.8.0/src/duktape.c.

◆ DUK__LENGTH_PROP_BITS

#define DUK__LENGTH_PROP_BITS   3

Definition at line 53582 of file duktape-1.8.0/src/duktape.c.

◆ DUK__LOCAL_TZOFFSET_MAXITER

#define DUK__LOCAL_TZOFFSET_MAXITER   4

Definition at line 25043 of file duktape-1.8.0/src/duktape.c.

◆ DUK__LONGJMP_RESTART

#define DUK__LONGJMP_RESTART   0 /* state updated, restart bytecode execution */

Definition at line 66143 of file duktape-1.8.0/src/duktape.c.

◆ DUK__LONGJMP_RETHROW

#define DUK__LONGJMP_RETHROW   1 /* exit bytecode executor by rethrowing an error to caller */

Definition at line 66144 of file duktape-1.8.0/src/duktape.c.

◆ DUK__LOOKUP

#define DUK__LOOKUP ( lex_ctx,
index )   ((lex_ctx)->window[(index)].codepoint)

Definition at line 73406 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK__MAGIC_BITS

#define DUK__MAGIC_BITS   16

Definition at line 53585 of file duktape-1.8.0/src/duktape.c.

◆ DUK__MAX_ARRAY_INIT_VALUES

#define DUK__MAX_ARRAY_INIT_VALUES   20

Definition at line 57750 of file duktape-1.8.0/src/duktape.c.

◆ DUK__MAX_CONSTS

#define DUK__MAX_CONSTS   DUK_BC_BC_MAX

Definition at line 57759 of file duktape-1.8.0/src/duktape.c.

◆ DUK__MAX_FORMATTED_LENGTH

#define DUK__MAX_FORMATTED_LENGTH   1040 /* (-Number.MAX_VALUE).toString(2).length == 1025, + spare */

Definition at line 76018 of file duktape-1.8.0/src/duktape.c.

◆ DUK__MAX_FUNCS

#define DUK__MAX_FUNCS   DUK_BC_BC_MAX

Definition at line 57760 of file duktape-1.8.0/src/duktape.c.

◆ DUK__MAX_OBJECT_INIT_PAIRS

#define DUK__MAX_OBJECT_INIT_PAIRS   10

Definition at line 57751 of file duktape-1.8.0/src/duktape.c.

◆ DUK__MAX_OUTPUT_DIGITS

#define DUK__MAX_OUTPUT_DIGITS   1040 /* (Number.MAX_VALUE).toString(2).length == 1024, + spare */

Definition at line 76015 of file duktape-1.8.0/src/duktape.c.

◆ DUK__MAX_RE_DECESC_DIGITS

#define DUK__MAX_RE_DECESC_DIGITS   9

Definition at line 73395 of file duktape-1.8.0/src/duktape.c.

◆ DUK__MAX_RE_QUANT_DIGITS

#define DUK__MAX_RE_QUANT_DIGITS   9 /* Does not allow e.g. 2**31-1, but one more would allow overflows of u32. */

Definition at line 73396 of file duktape-1.8.0/src/duktape.c.

◆ DUK__MAX_TEMPS

#define DUK__MAX_TEMPS   0xffffL

Definition at line 57761 of file duktape-1.8.0/src/duktape.c.

◆ DUK__MK_LBP

#define DUK__MK_LBP ( bp)    ((bp) >> 1) /* bp is assumed to be even */

Definition at line 57985 of file duktape-1.8.0/src/duktape.c.

◆ DUK__MK_LBP_FLAGS

#define DUK__MK_LBP_FLAGS ( bp,
flags )   (((bp) >> 1) | (flags))

Definition at line 57986 of file duktape-1.8.0/src/duktape.c.

◆ DUK__MKBITS

#define DUK__MKBITS ( a,
b,
c,
d,
e,
f,
g,
h )
Value:
((duk_uint8_t) ( \
((a) << 0) | ((b) << 1) | ((c) << 2) | ((d) << 3) | \
((e) << 4) | ((f) << 5) | ((g) << 6) | ((h) << 7) \
))

Definition at line 27822 of file duktape-1.8.0/src/duktape.c.

27822 * Global object built-ins
27823 */
27824
27825/* include removed: duk_internal.h */

◆ DUK__MKESC

#define DUK__MKESC ( nybbles,
esc1,
esc2 )
Value:
(((duk_uint_fast32_t) (nybbles)) << 16) | \
(((duk_uint_fast32_t) (esc1)) << 8) | \
((duk_uint_fast32_t) (esc2))
duk_uint32_t duk_uint_fast32_t

Definition at line 30178 of file duktape-1.8.0/src/duktape.c.

30178
30180 duk_hstring *h;
30181
DUK_LOCAL_DECL void duk__emit_stridx(duk_json_enc_ctx *js_ctx, duk_small_uint_t stridx)

◆ DUK__NARGS_BITS

#define DUK__NARGS_BITS   3

Definition at line 53583 of file duktape-1.8.0/src/duktape.c.

◆ DUK__NARGS_VARARGS_MARKER

#define DUK__NARGS_VARARGS_MARKER   0x07

Definition at line 53587 of file duktape-1.8.0/src/duktape.c.

◆ DUK__NATIDX_BITS

#define DUK__NATIDX_BITS   8

Definition at line 53576 of file duktape-1.8.0/src/duktape.c.

◆ DUK__NO_ARRAY_INDEX

◆ DUK__NO_BIDX_MARKER

#define DUK__NO_BIDX_MARKER   0x7f

Definition at line 53589 of file duktape-1.8.0/src/duktape.c.

◆ DUK__NO_CLASS_MARKER

#define DUK__NO_CLASS_MARKER   0x00 /* 0 = DUK_HOBJECT_CLASS_UNUSED */

Definition at line 53588 of file duktape-1.8.0/src/duktape.c.

◆ DUK__NO_EXP

#define DUK__NO_EXP   (65536) /* arbitrary marker, outside valid exp range */

Definition at line 76583 of file duktape-1.8.0/src/duktape.c.

◆ DUK__NO_STRIDX_MARKER

#define DUK__NO_STRIDX_MARKER   0xff

Definition at line 53590 of file duktape-1.8.0/src/duktape.c.

◆ DUK__NUM_FUNC_PROPS_BITS

#define DUK__NUM_FUNC_PROPS_BITS   6

Definition at line 53578 of file duktape-1.8.0/src/duktape.c.

◆ DUK__NUM_ISO8601_PARSER_PARTS

#define DUK__NUM_ISO8601_PARSER_PARTS   9

Definition at line 24710 of file duktape-1.8.0/src/duktape.c.

◆ DUK__NUM_NORMAL_PROPS_BITS

#define DUK__NUM_NORMAL_PROPS_BITS   6

Definition at line 53577 of file duktape-1.8.0/src/duktape.c.

◆ DUK__NUMCONV_CTX_BIGINTS_SIZE

#define DUK__NUMCONV_CTX_BIGINTS_SIZE   (sizeof(duk__bigint) * DUK__NUMCONV_CTX_NUM_BIGINTS)

Definition at line 76022 of file duktape-1.8.0/src/duktape.c.

◆ DUK__NUMCONV_CTX_NUM_BIGINTS

#define DUK__NUMCONV_CTX_NUM_BIGINTS   7

Definition at line 76021 of file duktape-1.8.0/src/duktape.c.

◆ DUK__OBJ_LIT_KEY_GET

#define DUK__OBJ_LIT_KEY_GET   (1 << 1) /* key encountered as a getter */

Definition at line 60452 of file duktape-1.8.0/src/duktape.c.

◆ DUK__OBJ_LIT_KEY_PLAIN

#define DUK__OBJ_LIT_KEY_PLAIN   (1 << 0) /* key encountered as a plain property */

Definition at line 60451 of file duktape-1.8.0/src/duktape.c.

◆ DUK__OBJ_LIT_KEY_SET

#define DUK__OBJ_LIT_KEY_SET   (1 << 2) /* key encountered as a setter */

Definition at line 60453 of file duktape-1.8.0/src/duktape.c.

◆ DUK__OUTPUT_TYPE_FILENAME

#define DUK__OUTPUT_TYPE_FILENAME   0

Definition at line 27186 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__error_getter_helper().

◆ DUK__OUTPUT_TYPE_LINENUMBER

#define DUK__OUTPUT_TYPE_LINENUMBER   1

Definition at line 27187 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__error_getter_helper().

◆ DUK__OUTPUT_TYPE_TRACEBACK

#define DUK__OUTPUT_TYPE_TRACEBACK   (-1)

Definition at line 27185 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PACK_ARGS

#define DUK__PACK_ARGS ( classnum,
protobidx,
elemtype,
elemshift,
isview )    (((classnum) << 24) | ((protobidx) << 16) | ((elemtype) << 8) | ((elemshift) << 4) | (isview))

Definition at line 18931 of file duktape-1.8.0/src/duktape.c.

18932 }
#define DUK_ERROR_ALLOC_DEFMSG(thr)

◆ DUK__PACK_RULE

#define DUK__PACK_RULE ( partmask,
sepmask,
nextpart,
flags )
Value:
((duk_uint32_t) (partmask) + \
(((duk_uint32_t) (sepmask)) << 9) + \
(((duk_uint32_t) (nextpart)) << 17) + \
(((duk_uint32_t) (flags)) << 21))

Definition at line 24759 of file duktape-1.8.0/src/duktape.c.

24759#define DUK__SI_NUL 7
24760
24761/* Parser separator masks. */
24762#define DUK__SM_PLUS (1 << DUK__SI_PLUS)
24763#define DUK__SM_MINUS (1 << DUK__SI_MINUS)

◆ DUK__PARSE_EXPR_SLOTS

#define DUK__PARSE_EXPR_SLOTS   16

Definition at line 57783 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PARSE_STATEMENTS_SLOTS

#define DUK__PARSE_STATEMENTS_SLOTS   16

Definition at line 57782 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PI_DAY

#define DUK__PI_DAY   2

Definition at line 24715 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PI_HOUR

#define DUK__PI_HOUR   3

Definition at line 24716 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PI_MILLISECOND

#define DUK__PI_MILLISECOND   6

Definition at line 24719 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PI_MINUTE

#define DUK__PI_MINUTE   4

Definition at line 24717 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PI_MONTH

#define DUK__PI_MONTH   1

Definition at line 24714 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PI_SECOND

#define DUK__PI_SECOND   5

Definition at line 24718 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PI_TZHOUR

#define DUK__PI_TZHOUR   7

Definition at line 24720 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PI_TZMINUTE

#define DUK__PI_TZMINUTE   8

Definition at line 24721 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PI_YEAR

#define DUK__PI_YEAR   0

Definition at line 24713 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PM_DAY

#define DUK__PM_DAY   (1 << DUK__PI_DAY)

Definition at line 24726 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PM_HOUR

#define DUK__PM_HOUR   (1 << DUK__PI_HOUR)

Definition at line 24727 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PM_MILLISECOND

#define DUK__PM_MILLISECOND   (1 << DUK__PI_MILLISECOND)

Definition at line 24730 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PM_MINUTE

#define DUK__PM_MINUTE   (1 << DUK__PI_MINUTE)

Definition at line 24728 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PM_MONTH

#define DUK__PM_MONTH   (1 << DUK__PI_MONTH)

Definition at line 24725 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PM_SECOND

#define DUK__PM_SECOND   (1 << DUK__PI_SECOND)

Definition at line 24729 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PM_TZHOUR

#define DUK__PM_TZHOUR   (1 << DUK__PI_TZHOUR)

Definition at line 24731 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PM_TZMINUTE

#define DUK__PM_TZMINUTE   (1 << DUK__PI_TZMINUTE)

Definition at line 24732 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PM_YEAR

#define DUK__PM_YEAR   (1 << DUK__PI_YEAR)

Definition at line 24724 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PREVENT_MS_SIDE_EFFECTS

#define DUK__PREVENT_MS_SIDE_EFFECTS ( heap)
Value:
do { \
(heap)->mark_and_sweep_base_flags |= \
DUK_MS_FLAG_NO_STRINGTABLE_RESIZE | /* avoid recursive string table call */ \
DUK_MS_FLAG_NO_FINALIZERS | /* avoid pressure to add/remove strings, invalidation of call data argument, etc. */ \
DUK_MS_FLAG_NO_OBJECT_COMPACTION; /* avoid array abandoning which interns strings */ \
} while (0)
#define DUK_MS_FLAG_NO_OBJECT_COMPACTION
#define DUK_MS_FLAG_NO_FINALIZERS
#define DUK_MS_FLAG_NO_STRINGTABLE_RESIZE

Definition at line 45019 of file duktape-1.8.0/src/duktape.c.

45020 return 0;
45021}
45022#line 1 "duk_heap_stringtable.c"
45023/*
45024 * Heap stringtable handling, string interning.
#define DUK_ERROR_INTERNAL_DEFMSG(thr)

◆ DUK__PROP_FLAGS_BITS

#define DUK__PROP_FLAGS_BITS   3

Definition at line 53579 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PROP_TYPE_ACCESSOR

#define DUK__PROP_TYPE_ACCESSOR   7

Definition at line 53599 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PROP_TYPE_BITS

#define DUK__PROP_TYPE_BITS   3

Definition at line 53584 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PROP_TYPE_BOOLEAN_FALSE

#define DUK__PROP_TYPE_BOOLEAN_FALSE   6

Definition at line 53598 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PROP_TYPE_BOOLEAN_TRUE

#define DUK__PROP_TYPE_BOOLEAN_TRUE   5

Definition at line 53597 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PROP_TYPE_BUILTIN

#define DUK__PROP_TYPE_BUILTIN   3

Definition at line 53595 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PROP_TYPE_DOUBLE

#define DUK__PROP_TYPE_DOUBLE   0

Definition at line 53592 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PROP_TYPE_STRIDX

#define DUK__PROP_TYPE_STRIDX   2

Definition at line 53594 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PROP_TYPE_STRING

#define DUK__PROP_TYPE_STRING   1

Definition at line 53593 of file duktape-1.8.0/src/duktape.c.

◆ DUK__PROP_TYPE_UNDEFINED

#define DUK__PROP_TYPE_UNDEFINED   4

Definition at line 53596 of file duktape-1.8.0/src/duktape.c.

◆ DUK__RCISREG

#define DUK__RCISREG ( x)    (((x) & 0x100) == 0)

Definition at line 67537 of file duktape-1.8.0/src/duktape.c.

◆ DUK__RE_BUFLEN

#define DUK__RE_BUFLEN ( re_ctx)     DUK_BW_GET_SIZE(re_ctx->thr, &re_ctx->bw)

Definition at line 77685 of file duktape-1.8.0/src/duktape.c.

77685 * maximum supported size. This could be done by limiting the maximum
77686 * input string size (assuming an upper bound can be computed for number

Referenced by duk__parse_disjunction().

◆ DUK__RE_INITIAL_BUFSIZE

#define DUK__RE_INITIAL_BUFSIZE   64

Definition at line 77682 of file duktape-1.8.0/src/duktape.c.

◆ DUK__READABLE_STRING_MAXCHARS

#define DUK__READABLE_STRING_MAXCHARS   32

Definition at line 19678 of file duktape-1.8.0/src/duktape.c.

◆ DUK__RECURSION_DECREASE

#define DUK__RECURSION_DECREASE ( comp_ctx,
thr )
Value:
do { \
DUK_DDD(DUK_DDDPRINT("RECURSION DECREASE: %s:%ld", (const char *) DUK_FILE_MACRO, (long) DUK_LINE_MACRO)); \
duk__recursion_decrease((comp_ctx)); \
} while (0)
#define DUK_DDDPRINT

Definition at line 57771 of file duktape-1.8.0/src/duktape.c.

57771#define DUK__GETCONST_MAX_CONSTS_CHECK 256
57772
57773/* These limits are based on bytecode limits. Max temps is limited
57774 * by duk_hcompiledfunction nargs/nregs fields being 16 bits.

Referenced by duk__parse_func_body().

◆ DUK__RECURSION_INCREASE

#define DUK__RECURSION_INCREASE ( comp_ctx,
thr )
Value:
do { \
DUK_DDD(DUK_DDDPRINT("RECURSION INCREASE: %s:%ld", (const char *) DUK_FILE_MACRO, (long) DUK_LINE_MACRO)); \
duk__recursion_increase((comp_ctx)); \
} while (0)

Definition at line 57766 of file duktape-1.8.0/src/duktape.c.

57766/* for array and object literals */
57767#define DUK__MAX_ARRAY_INIT_VALUES 20
57768#define DUK__MAX_OBJECT_INIT_PAIRS 10
57769

Referenced by duk__parse_func_body().

◆ DUK__REG

#define DUK__REG ( x)    (*(thr->valstack_bottom + (x)))

Definition at line 67523 of file duktape-1.8.0/src/duktape.c.

◆ DUK__REGCONST

#define DUK__REGCONST ( x)    (*((DUK__RCISREG((x)) ? thr->valstack_bottom : consts2) + (x)))

Definition at line 67538 of file duktape-1.8.0/src/duktape.c.

◆ DUK__REGCONSTP

#define DUK__REGCONSTP ( x)    ((DUK__RCISREG((x)) ? thr->valstack_bottom : consts2) + (x))

Definition at line 67539 of file duktape-1.8.0/src/duktape.c.

◆ DUK__REGP

#define DUK__REGP ( x)    (thr->valstack_bottom + (x))

Definition at line 67524 of file duktape-1.8.0/src/duktape.c.

◆ DUK__RETHAND_FINISHED

#define DUK__RETHAND_FINISHED   1 /* exit bytecode execution with return value */

Definition at line 66147 of file duktape-1.8.0/src/duktape.c.

◆ DUK__RETHAND_RESTART

#define DUK__RETHAND_RESTART   0 /* state updated, restart bytecode execution */

Definition at line 66146 of file duktape-1.8.0/src/duktape.c.

◆ DUK__RND_BIT

#define DUK__RND_BIT ( rnd)    ((rnd) >> 31) /* only use the highest bit */

Definition at line 86918 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_util_tinyrandom_get_double().

◆ DUK__RULE_MASK_PART_SEP

#define DUK__RULE_MASK_PART_SEP   0x1ffffUL

Definition at line 24770 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SER_MARKER

#define DUK__SER_MARKER   0xff

Definition at line 11665 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SER_NUMBER

#define DUK__SER_NUMBER   0x01

Definition at line 11668 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SER_STRING

#define DUK__SER_STRING   0x00

Definition at line 11667 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SER_VERSION

#define DUK__SER_VERSION   0x00

Definition at line 11666 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SETTEMP

#define DUK__SETTEMP ( comp_ctx,
x )   ((comp_ctx)->curr_func.temp_next = (x)) /* dangerous: must only lower (temp_max not updated) */

◆ DUK__SETTEMP_CHECKMAX

#define DUK__SETTEMP_CHECKMAX ( comp_ctx,
x )   duk__settemp_checkmax((comp_ctx),(x))

◆ DUK__SI_COLON

#define DUK__SI_COLON   4

Definition at line 24739 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SI_MINUS

#define DUK__SI_MINUS   1

Definition at line 24736 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SI_NUL

#define DUK__SI_NUL   7

Definition at line 24742 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SI_PERIOD

#define DUK__SI_PERIOD   5

Definition at line 24740 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SI_PLUS

#define DUK__SI_PLUS   0

Definition at line 24735 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SI_SPACE

#define DUK__SI_SPACE   3

Definition at line 24738 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SI_T

#define DUK__SI_T   2

Definition at line 24737 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SI_Z

#define DUK__SI_Z   6

Definition at line 24741 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SM_COLON

#define DUK__SM_COLON   (1 << DUK__SI_COLON)

Definition at line 24749 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SM_MINUS

#define DUK__SM_MINUS   (1 << DUK__SI_MINUS)

Definition at line 24746 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SM_NUL

#define DUK__SM_NUL   (1 << DUK__SI_NUL)

Definition at line 24752 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SM_PERIOD

#define DUK__SM_PERIOD   (1 << DUK__SI_PERIOD)

Definition at line 24750 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SM_PLUS

#define DUK__SM_PLUS   (1 << DUK__SI_PLUS)

Definition at line 24745 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SM_SPACE

#define DUK__SM_SPACE   (1 << DUK__SI_SPACE)

Definition at line 24748 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SM_T

#define DUK__SM_T   (1 << DUK__SI_T)

Definition at line 24747 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SM_Z

#define DUK__SM_Z   (1 << DUK__SI_Z)

Definition at line 24751 of file duktape-1.8.0/src/duktape.c.

◆ DUK__STILL_PROLOGUE

#define DUK__STILL_PROLOGUE   (1 << 3) /* statement does not terminate directive prologue */

Definition at line 62670 of file duktape-1.8.0/src/duktape.c.

◆ DUK__STRFTIME_BUF_SIZE

#define DUK__STRFTIME_BUF_SIZE   64

Definition at line 26356 of file duktape-1.8.0/src/duktape.c.

◆ DUK__STRICT

#define DUK__STRICT ( )    (DUK_HOBJECT_HAS_STRICT((duk_hobject *) DUK__FUN()))

Definition at line 67518 of file duktape-1.8.0/src/duktape.c.

◆ DUK__STRIDX_BITS

#define DUK__STRIDX_BITS   9 /* XXX: try to optimize to 8 (would now be possible, <200 used) */

Definition at line 53575 of file duktape-1.8.0/src/duktape.c.

◆ DUK__STRING_CHAR_BITS

#define DUK__STRING_CHAR_BITS   7

Definition at line 53581 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__push_double().

◆ DUK__STRING_LENGTH_BITS

#define DUK__STRING_LENGTH_BITS   8

Definition at line 53580 of file duktape-1.8.0/src/duktape.c.

◆ DUK__STRPTIME_BUF_SIZE

#define DUK__STRPTIME_BUF_SIZE   64

Definition at line 26355 of file duktape-1.8.0/src/duktape.c.

◆ DUK__SYNC_AND_NULL_CURR_PC

#define DUK__SYNC_AND_NULL_CURR_PC ( )
Value:
do { \
act = thr->callstack + thr->callstack_top - 1; \
act->curr_pc = curr_pc; \
thr->ptr_curr_pc = NULL; \
} while (0)

Definition at line 67556 of file duktape-1.8.0/src/duktape.c.

67556#define DUK__REGCONSTP(x) ((DUK__RCISREG((x)) ? thr->valstack_bottom : consts2) + (x))
67557
67558#ifdef DUK_USE_VERBOSE_EXECUTOR_ERRORS
67559#define DUK__INTERNAL_ERROR(msg) do { \
67560 DUK_ERROR_INTERNAL(thr, (msg)); \
67561 } while (0)

◆ DUK__SYNC_CURR_PC

#define DUK__SYNC_CURR_PC ( )
Value:
do { \
act = thr->callstack + thr->callstack_top - 1; \
act->curr_pc = curr_pc; \
} while (0)

Definition at line 67551 of file duktape-1.8.0/src/duktape.c.

67551 * DUK_LIKELY/DUK_UNLIKELY increases code footprint and doesn't seem to
67552 * improve performance on x64 (and actually harms performance in some tests).
67553 */
67554#define DUK__RCISREG(x) (((x) & 0x100) == 0)
67555#define DUK__REGCONST(x) (*((DUK__RCISREG((x)) ? thr->valstack_bottom : consts2) + (x)))

◆ DUK__TAG_NUMBER

#define DUK__TAG_NUMBER   0 /* not exposed */

Definition at line 643 of file duktape-1.8.0/src/duktape.c.

◆ DUK__TOKEN_LBP_BP_MASK

#define DUK__TOKEN_LBP_BP_MASK   0x1f

Definition at line 57978 of file duktape-1.8.0/src/duktape.c.

◆ DUK__TOKEN_LBP_FLAG_NO_REGEXP

#define DUK__TOKEN_LBP_FLAG_NO_REGEXP   (1 << 5) /* regexp literal must not follow this token */

Definition at line 57979 of file duktape-1.8.0/src/duktape.c.

◆ DUK__TOKEN_LBP_FLAG_TERMINATES

#define DUK__TOKEN_LBP_FLAG_TERMINATES   (1 << 6) /* terminates expression; e.g. post-increment/-decrement */

Definition at line 57980 of file duktape-1.8.0/src/duktape.c.

◆ DUK__TOKEN_LBP_FLAG_UNUSED

#define DUK__TOKEN_LBP_FLAG_UNUSED   (1 << 7) /* spare */

Definition at line 57981 of file duktape-1.8.0/src/duktape.c.

◆ DUK__TOKEN_LBP_GET_BP

#define DUK__TOKEN_LBP_GET_BP ( x)    ((duk_small_uint_t) (((x) & DUK__TOKEN_LBP_BP_MASK) * 2))

Definition at line 57983 of file duktape-1.8.0/src/duktape.c.

◆ DUK__UNEMIT_1

#define DUK__UNEMIT_1 ( js_ctx)    duk__unemit_1((js_ctx))

Definition at line 30142 of file duktape-1.8.0/src/duktape.c.

◆ DUK__UNPACK_RULE

#define DUK__UNPACK_RULE ( rule,
var_nextidx,
var_flags )
Value:
do { \
(var_nextidx) = (duk_small_uint_t) (((rule) >> 17) & 0x0f); \
(var_flags) = (duk_small_uint_t) ((rule) >> 21); \
} while (0)

Definition at line 24765 of file duktape-1.8.0/src/duktape.c.

24765#define DUK__SM_SPACE (1 << DUK__SI_SPACE)
24766#define DUK__SM_COLON (1 << DUK__SI_COLON)
24767#define DUK__SM_PERIOD (1 << DUK__SI_PERIOD)
24768#define DUK__SM_Z (1 << DUK__SI_Z)

◆ DUK__UPDATE_RND

#define DUK__UPDATE_RND ( rnd)
Value:
do { \
(rnd) += ((rnd) * (rnd)) | 0x05; \
(rnd) = ((rnd) & 0xffffffffU); /* if duk_uint32_t is exactly 32 bits, this is a NOP */ \
} while (0)

Definition at line 86913 of file duktape-1.8.0/src/duktape.c.

86913 h *= DUK__MAGIC_M;
86914 h ^= h >> 15;
86915
86916 return h;

Referenced by duk_util_tinyrandom_get_double().

◆ DUK__VALSTACK_PROXY_LOOKUP

#define DUK__VALSTACK_PROXY_LOOKUP   20

Definition at line 47492 of file duktape-1.8.0/src/duktape.c.

◆ DUK__VALSTACK_SPACE

◆ DUK__VOLUNTARY_PERIODIC_GC

#define DUK__VOLUNTARY_PERIODIC_GC ( heap)
Value:
do { \
(heap)->mark_and_sweep_trigger_counter--; \
if ((heap)->mark_and_sweep_trigger_counter <= 0) { \
duk__run_voluntary_gc(heap); \
} \
} while (0)

Definition at line 43632 of file duktape-1.8.0/src/duktape.c.

43632#endif /* DUK_USE_MARK_AND_SWEEP */
43633#line 1 "duk_heap_memory.c"
43634/*
43635 * Memory allocation handling.
43636 */
43637

◆ DUK__WEEKDAY_MOD_ADDER

#define DUK__WEEKDAY_MOD_ADDER   (20000000 * 7) /* 0x08583b00 */

Definition at line 25051 of file duktape-1.8.0/src/duktape.c.

◆ DUK__YEAR

#define DUK__YEAR ( x)    ((duk_uint8_t) ((x) - 1970))

Definition at line 24673 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ACT_FLAG_BREAKPOINT_ACTIVE

#define DUK_ACT_FLAG_BREAKPOINT_ACTIVE   (1 << 5) /* activation has active breakpoint(s) */

Definition at line 6019 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ACT_FLAG_CONSTRUCT

#define DUK_ACT_FLAG_CONSTRUCT   (1 << 2) /* function executes as a constructor (called via "new") */

Definition at line 6016 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__error_getter_helper().

◆ DUK_ACT_FLAG_DIRECT_EVAL

#define DUK_ACT_FLAG_DIRECT_EVAL   (1 << 4) /* activation is a direct eval call */

Definition at line 6018 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__error_getter_helper().

◆ DUK_ACT_FLAG_PREVENT_YIELD

#define DUK_ACT_FLAG_PREVENT_YIELD   (1 << 3) /* activation prevents yield (native call or "new") */

◆ DUK_ACT_FLAG_STRICT

#define DUK_ACT_FLAG_STRICT   (1 << 0) /* function executes in strict mode */

◆ DUK_ACT_FLAG_TAILCALLED

#define DUK_ACT_FLAG_TAILCALLED   (1 << 1) /* activation has tail called one or more times */

◆ DUK_ACT_GET_FUNC

#define DUK_ACT_GET_FUNC ( act)    ((act)->func)

◆ DUK_ALLOC

#define DUK_ALLOC ( heap,
size )   duk_heap_mem_alloc((heap), (size))

◆ DUK_ALLOC_RAW

#define DUK_ALLOC_RAW ( heap,
size )    ((heap)->alloc_func((heap)->heap_udata, (size)))

Definition at line 6851 of file duktape-1.8.0/src/duktape.c.

6851 ((heap)->strs[(idx)])
6852#endif

Referenced by duk_realloc_raw().

◆ DUK_ALLOC_ZEROED

#define DUK_ALLOC_ZEROED ( heap,
size )   duk_heap_mem_alloc_zeroed((heap), (size))

Definition at line 6892 of file duktape-1.8.0/src/duktape.c.

◆ DUK_API_INTERNAL_H_INCLUDED

#define DUK_API_INTERNAL_H_INCLUDED

Definition at line 4229 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_0

#define DUK_ASC_0   0x30

Definition at line 8119 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_1

#define DUK_ASC_1   0x31

Definition at line 8120 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_2

#define DUK_ASC_2   0x32

Definition at line 8121 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_3

#define DUK_ASC_3   0x33

Definition at line 8122 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_4

#define DUK_ASC_4   0x34

Definition at line 8123 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_5

#define DUK_ASC_5   0x35

Definition at line 8124 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_6

#define DUK_ASC_6   0x36

Definition at line 8125 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_7

#define DUK_ASC_7   0x37

Definition at line 8126 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_8

#define DUK_ASC_8   0x38

Definition at line 8127 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_9

#define DUK_ASC_9   0x39

Definition at line 8128 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_ACK

#define DUK_ASC_ACK   0x06

Definition at line 8077 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_AMP

#define DUK_ASC_AMP   0x26

Definition at line 8109 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_ATSIGN

#define DUK_ASC_ATSIGN   0x40

Definition at line 8135 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_BACKSLASH

#define DUK_ASC_BACKSLASH   0x5c

Definition at line 8163 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__create_escaped_source().

◆ DUK_ASC_BEL

#define DUK_ASC_BEL   0x07

Definition at line 8078 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_BS

#define DUK_ASC_BS   0x08

Definition at line 8079 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_CAN

#define DUK_ASC_CAN   0x18

Definition at line 8095 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_CARET

#define DUK_ASC_CARET   0x5e

Definition at line 8165 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_COLON

#define DUK_ASC_COLON   0x3a

Definition at line 8129 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_COMMA

#define DUK_ASC_COMMA   0x2c

Definition at line 8115 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_CR

#define DUK_ASC_CR   0x0d

Definition at line 8084 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_DC1

#define DUK_ASC_DC1   0x11

Definition at line 8088 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_DC2

#define DUK_ASC_DC2   0x12

Definition at line 8089 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_DC3

#define DUK_ASC_DC3   0x13

Definition at line 8090 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_DC4

#define DUK_ASC_DC4   0x14

Definition at line 8091 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_DEL

#define DUK_ASC_DEL   0x7f

Definition at line 8198 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_DLE

#define DUK_ASC_DLE   0x10

Definition at line 8087 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_DOLLAR

#define DUK_ASC_DOLLAR   0x24

Definition at line 8107 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_DOUBLEQUOTE

#define DUK_ASC_DOUBLEQUOTE   0x22

Definition at line 8105 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_EM

#define DUK_ASC_EM   0x19

Definition at line 8096 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_ENQ

#define DUK_ASC_ENQ   0x05

Definition at line 8076 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_EOT

#define DUK_ASC_EOT   0x04

Definition at line 8075 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_EQUALS

#define DUK_ASC_EQUALS   0x3d

Definition at line 8132 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_ESC

#define DUK_ASC_ESC   0x1b

Definition at line 8098 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_ETB

#define DUK_ASC_ETB   0x17

Definition at line 8094 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_ETX

#define DUK_ASC_ETX   0x03

Definition at line 8074 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_EXCLAMATION

#define DUK_ASC_EXCLAMATION   0x21

Definition at line 8104 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_FF

#define DUK_ASC_FF   0x0c

Definition at line 8083 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_FS

#define DUK_ASC_FS   0x1c

Definition at line 8099 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_GRAVE

#define DUK_ASC_GRAVE   0x60

Definition at line 8167 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_GS

#define DUK_ASC_GS   0x1d

Definition at line 8100 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_HASH

#define DUK_ASC_HASH   0x23

Definition at line 8106 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_HT

#define DUK_ASC_HT   0x09

Definition at line 8080 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_LANGLE

#define DUK_ASC_LANGLE   0x3c

Definition at line 8131 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_LBRACKET

#define DUK_ASC_LBRACKET   0x5b

Definition at line 8162 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_LC_A

#define DUK_ASC_LC_A   0x61

Definition at line 8168 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_B

#define DUK_ASC_LC_B   0x62

Definition at line 8169 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_C

#define DUK_ASC_LC_C   0x63

Definition at line 8170 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_D

#define DUK_ASC_LC_D   0x64

Definition at line 8171 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_E

#define DUK_ASC_LC_E   0x65

Definition at line 8172 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_F

#define DUK_ASC_LC_F   0x66

Definition at line 8173 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_G

#define DUK_ASC_LC_G   0x67

Definition at line 8174 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_H

#define DUK_ASC_LC_H   0x68

Definition at line 8175 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_I

#define DUK_ASC_LC_I   0x69

Definition at line 8176 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_J

#define DUK_ASC_LC_J   0x6a

Definition at line 8177 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_K

#define DUK_ASC_LC_K   0x6b

Definition at line 8178 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_L

#define DUK_ASC_LC_L   0x6c

Definition at line 8179 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_M

#define DUK_ASC_LC_M   0x6d

Definition at line 8180 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_N

#define DUK_ASC_LC_N   0x6e

Definition at line 8181 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_O

#define DUK_ASC_LC_O   0x6f

Definition at line 8182 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_P

#define DUK_ASC_LC_P   0x70

Definition at line 8183 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_Q

#define DUK_ASC_LC_Q   0x71

Definition at line 8184 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_R

#define DUK_ASC_LC_R   0x72

Definition at line 8185 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_S

#define DUK_ASC_LC_S   0x73

Definition at line 8186 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_T

#define DUK_ASC_LC_T   0x74

Definition at line 8187 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_U

#define DUK_ASC_LC_U   0x75

Definition at line 8188 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_V

#define DUK_ASC_LC_V   0x76

Definition at line 8189 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_W

#define DUK_ASC_LC_W   0x77

Definition at line 8190 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_X

#define DUK_ASC_LC_X   0x78

Definition at line 8191 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_Y

#define DUK_ASC_LC_Y   0x79

Definition at line 8192 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LC_Z

#define DUK_ASC_LC_Z   0x7a

Definition at line 8193 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_LCURLY

#define DUK_ASC_LCURLY   0x7b

Definition at line 8194 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_LF

#define DUK_ASC_LF   0x0a

Definition at line 8081 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_LPAREN

#define DUK_ASC_LPAREN   0x28

Definition at line 8111 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_MINUS

#define DUK_ASC_MINUS   0x2d

Definition at line 8116 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_NAK

#define DUK_ASC_NAK   0x15

Definition at line 8092 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_NUL

#define DUK_ASC_NUL   0x00

Definition at line 8071 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_PERCENT

#define DUK_ASC_PERCENT   0x25

Definition at line 8108 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_PERIOD

#define DUK_ASC_PERIOD   0x2e

Definition at line 8117 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_PIPE

#define DUK_ASC_PIPE   0x7c

Definition at line 8195 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_PLUS

#define DUK_ASC_PLUS   0x2b

Definition at line 8114 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_QUESTION

#define DUK_ASC_QUESTION   0x3f

Definition at line 8134 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_RANGLE

#define DUK_ASC_RANGLE   0x3e

Definition at line 8133 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_RBRACKET

#define DUK_ASC_RBRACKET   0x5d

Definition at line 8164 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_RCURLY

#define DUK_ASC_RCURLY   0x7d

Definition at line 8196 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_RPAREN

#define DUK_ASC_RPAREN   0x29

Definition at line 8112 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_RS

#define DUK_ASC_RS   0x1e

Definition at line 8101 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_SEMICOLON

#define DUK_ASC_SEMICOLON   0x3b

Definition at line 8130 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_SI

#define DUK_ASC_SI   0x0f

Definition at line 8086 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_SINGLEQUOTE

#define DUK_ASC_SINGLEQUOTE   0x27

Definition at line 8110 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_SLASH

#define DUK_ASC_SLASH   0x2f

Definition at line 8118 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_SO

#define DUK_ASC_SO   0x0e

Definition at line 8085 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_SOH

#define DUK_ASC_SOH   0x01

Definition at line 8072 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_SPACE

#define DUK_ASC_SPACE   0x20

Definition at line 8103 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_STAR

#define DUK_ASC_STAR   0x2a

Definition at line 8113 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_STX

#define DUK_ASC_STX   0x02

Definition at line 8073 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_SUB

#define DUK_ASC_SUB   0x1a

Definition at line 8097 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_SYN

#define DUK_ASC_SYN   0x16

Definition at line 8093 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_TILDE

#define DUK_ASC_TILDE   0x7e

Definition at line 8197 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_ASC_UC_A

#define DUK_ASC_UC_A   0x41

Definition at line 8136 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_UC_B

#define DUK_ASC_UC_B   0x42

Definition at line 8137 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_logger_constructor().

◆ DUK_ASC_UC_C

#define DUK_ASC_UC_C   0x43

Definition at line 8138 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_logger_constructor().

◆ DUK_ASC_UC_D

#define DUK_ASC_UC_D   0x44

Definition at line 8139 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_logger_constructor().

◆ DUK_ASC_UC_E

#define DUK_ASC_UC_E   0x45

Definition at line 8140 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_logger_constructor().

◆ DUK_ASC_UC_F

#define DUK_ASC_UC_F   0x46

Definition at line 8141 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_logger_constructor().

◆ DUK_ASC_UC_G

#define DUK_ASC_UC_G   0x47

Definition at line 8142 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_logger_constructor().

◆ DUK_ASC_UC_H

#define DUK_ASC_UC_H   0x48

Definition at line 8143 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_UC_I

#define DUK_ASC_UC_I   0x49

Definition at line 8144 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_logger_constructor().

◆ DUK_ASC_UC_J

#define DUK_ASC_UC_J   0x4a

Definition at line 8145 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_UC_K

#define DUK_ASC_UC_K   0x4b

Definition at line 8146 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_UC_L

#define DUK_ASC_UC_L   0x4c

Definition at line 8147 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_logger_constructor().

◆ DUK_ASC_UC_M

#define DUK_ASC_UC_M   0x4d

Definition at line 8148 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_UC_N

#define DUK_ASC_UC_N   0x4e

Definition at line 8149 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_logger_constructor().

◆ DUK_ASC_UC_O

#define DUK_ASC_UC_O   0x4f

Definition at line 8150 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_UC_P

#define DUK_ASC_UC_P   0x50

Definition at line 8151 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_UC_Q

#define DUK_ASC_UC_Q   0x51

Definition at line 8152 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_UC_R

#define DUK_ASC_UC_R   0x52

Definition at line 8153 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_logger_constructor().

◆ DUK_ASC_UC_S

#define DUK_ASC_UC_S   0x53

Definition at line 8154 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_UC_T

#define DUK_ASC_UC_T   0x54

Definition at line 8155 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_logger_constructor().

◆ DUK_ASC_UC_U

#define DUK_ASC_UC_U   0x55

Definition at line 8156 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_UC_V

#define DUK_ASC_UC_V   0x56

Definition at line 8157 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_UC_W

#define DUK_ASC_UC_W   0x57

Definition at line 8158 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_logger_constructor().

◆ DUK_ASC_UC_X

#define DUK_ASC_UC_X   0x58

Definition at line 8159 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_UC_Y

#define DUK_ASC_UC_Y   0x59

Definition at line 8160 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_UC_Z

#define DUK_ASC_UC_Z   0x5a

Definition at line 8161 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_UNDERSCORE

#define DUK_ASC_UNDERSCORE   0x5f

Definition at line 8166 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_US

#define DUK_ASC_US   0x1f

Definition at line 8102 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASC_VT

#define DUK_ASC_VT   0x0b

Definition at line 8082 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASSERT

#define DUK_ASSERT ( x)    do { /* assertion omitted */ } while (0)

Definition at line 7787 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__alloc_init_hstring(), duk__append_jump_offset(), duk__base64_encode_helper(), duk__bi_is_2to52(), duk__coerce_effective_this_binding(), duk__compact_object_list(), duk__create_escaped_source(), duk__dec_decode_hex_escape(), duk__declvar_helper(), duk__delvar_helper(), duk__dump_hbuffer_raw(), duk__enc_buffer(), duk__enc_bufferobject(), duk__err_augment_user(), duk__error_getter_helper(), duk__fill_lexer_buffer(), duk__finalize_helper(), duk__get_buffer_helper(), duk__get_min_grow_e(), duk__get_own_propdesc_raw(), duk__get_propdesc(), duk__getid_open_decl_env_regs(), duk__getprop_shallow_fastpath_array_tval(), duk__getvar_helper(), duk__handle_catch(), duk__handle_executor_error(), duk__hexval(), duk__hstring_is_eval_or_arguments(), duk__inc_data_inner_refcounts(), duk__init_varmap_and_prologue_for_pass2(), duk__ispec_toregconst_raw(), duk__js_samevalue_number(), duk__parse_disjunction(), duk__parse_func_body(), duk__parse_func_formals(), duk__parse_string(), duk__parse_var_decl(), duk__proxy_check_prop(), duk__push_stridx(), duk__put_prop_shared(), duk__putvar_helper(), duk__queue_refzero(), duk__realloc_props(), duk__reconfig_valstack_ecma_return(), duk__resize_valstack(), duk__slow_case_conversion(), duk__sort_array_indices(), duk_bi_boolean_constructor(), duk_bi_boolean_prototype_tostring_shared(), duk_bi_buffer_readfield(), duk_bi_buffer_slice_shared(), duk_bi_duktape_object_info(), duk_bi_regexp_constructor(), duk_bi_string_constructor(), duk_bi_typedarray_set(), duk_bw_init(), duk_bw_insert_raw_area(), duk_bw_write_ensure_slice(), duk_del_prop_stridx(), duk_dup_top(), duk_err_augment_error_create(), duk_err_create_and_throw(), duk_free_hobject_inner(), duk_gc(), duk_get_number(), duk_get_prop_stridx(), duk_get_top(), duk_get_type_mask(), duk_handle_call_protected(), duk_handle_ecma_call_setup(), duk_has_prop_stridx(), duk_hbuffer_reset(), duk_hbuffer_resize(), duk_heap_free_heaphdr_raw(), duk_heap_mem_realloc_indirect(), duk_heap_string_intern_checked(), duk_heap_string_intern_u32_checked(), duk_hobject_define_property_helper(), duk_hobject_define_property_internal(), duk_hobject_find_existing_entry_tval_ptr_and_attrs(), duk_hobject_prepare_property_descriptor(), duk_hobject_putprop(), duk_hstring_char_code_at_raw(), duk_hthread_callstack_grow(), duk_hthread_get_act_prev_pc(), duk_js_instanceof(), duk_js_toboolean(), duk_js_tointeger_number(), duk_lexer_initctx(), duk_lexer_parse_js_input_element(), duk_push_current_thread(), duk_push_hobject_bidx(), duk_push_pointer(), duk_push_string_funcptr(), duk_push_thread_stash(), duk_push_undefined(), duk_put_global_string(), duk_remove(), duk_require_heapptr(), duk_to_boolean(), duk_to_int_clamped_raw(), duk_to_uint16(), duk_to_uint32(), duk_tval_decref(), and duk_unicode_decode_xutf8_checked().

◆ DUK_ASSERT_CTX_VALID

#define DUK_ASSERT_CTX_VALID ( ctx)
Value:
do { \
DUK_ASSERT((ctx) != NULL); \
DUK_ASSERT(DUK_HEAPHDR_GET_TYPE((duk_heaphdr *) (ctx)) == DUK_HTYPE_OBJECT); \
DUK_ASSERT(DUK_HOBJECT_IS_THREAD((duk_hobject *) (ctx))); \
DUK_ASSERT(((duk_hthread *) (ctx))->unused1 == 0); \
DUK_ASSERT(((duk_hthread *) (ctx))->unused2 == 0); \
DUK_ASSERT(((duk_hthread *) (ctx))->valstack != NULL); \
DUK_ASSERT(((duk_hthread *) (ctx))->valstack_end >= ((duk_hthread *) (ctx))->valstack); \
DUK_ASSERT(((duk_hthread *) (ctx))->valstack_top >= ((duk_hthread *) (ctx))->valstack); \
DUK_ASSERT(((duk_hthread *) (ctx))->valstack_top >= ((duk_hthread *) (ctx))->valstack_bottom); \
DUK_ASSERT(((duk_hthread *) (ctx))->valstack_end >= ((duk_hthread *) (ctx))->valstack_top); \
DUK_ASSERT_CTX_VSSIZE((ctx)); \
} while (0)
#define DUK_HEAPHDR_GET_TYPE(h)
#define DUK_HOBJECT_IS_THREAD(h)
#define DUK_HTYPE_OBJECT

Definition at line 6133 of file duktape-1.8.0/src/duktape.c.

6133
6134#if defined(DUK_USE_PREFER_SIZE)
6135#define DUK_ASSERT_CTX_VSSIZE(ctx) /*nop*/
6136#else
6137#define DUK_ASSERT_CTX_VSSIZE(ctx) \
6138 DUK_ASSERT((duk_size_t) (((duk_hthread *) (ctx))->valstack_end - ((duk_hthread *) (ctx))->valstack) == \
6139 ((duk_hthread *) (ctx))->valstack_size)
6140#endif
6141#define DUK_ASSERT_CTX_VALID(ctx) do { \
6142 DUK_ASSERT((ctx) != NULL); \
6143 DUK_ASSERT(DUK_HEAPHDR_GET_TYPE((duk_heaphdr *) (ctx)) == DUK_HTYPE_OBJECT); \
6144 DUK_ASSERT(DUK_HOBJECT_IS_THREAD((duk_hobject *) (ctx))); \
6145 DUK_ASSERT(((duk_hthread *) (ctx))->unused1 == 0); \

Referenced by duk__concat_and_join_helper(), duk__get_buffer_helper(), duk__put_prop_shared(), duk__resize_valstack(), duk_alloc(), duk_alloc_raw(), duk_debugger_pause(), duk_decode_string(), duk_del_prop_stridx(), duk_dup_top(), duk_enum(), duk_free(), duk_gc(), duk_get_hobject_with_class(), duk_get_number(), duk_get_prop_stridx(), duk_get_string(), duk_get_top(), duk_handle_call_protected(), duk_has_prop_stridx(), duk_is_array(), duk_is_buffer_data(), duk_is_c_function(), duk_is_function(), duk_push_buffer_raw(), duk_push_c_function_noconstruct_noexotic(), duk_push_c_function_noexotic(), duk_push_current_thread(), duk_push_hobject_bidx(), duk_push_pointer(), duk_push_string_file_raw(), duk_push_thread_stash(), duk_push_undefined(), duk_push_vsprintf(), duk_put_global_string(), duk_put_number_list(), duk_realloc(), duk_realloc_raw(), duk_remove(), duk_require_heapptr(), duk_require_null(), duk_require_top_index(), duk_set_top(), duk_to_boolean(), duk_to_int_clamped_raw(), duk_to_uint16(), and duk_to_uint32().

◆ DUK_ASSERT_CTX_VSSIZE

#define DUK_ASSERT_CTX_VSSIZE ( ctx)
Value:
DUK_ASSERT((duk_size_t) (((duk_hthread *) (ctx))->valstack_end - ((duk_hthread *) (ctx))->valstack) == \
((duk_hthread *) (ctx))->valstack_size)
#define DUK_ASSERT(x)

Definition at line 6129 of file duktape-1.8.0/src/duktape.c.

6129 * This is used by public API call entrypoints to catch invalid 'ctx' pointers
6130 * as early as possible; invalid 'ctx' pointers cause very odd and difficult to
6131 * diagnose behavior so it's worth checking even when the check is not 100%.

◆ DUK_ASSERT_DISABLE

◆ DUK_ASSERT_DOUBLE_IS_NORMALIZED

#define DUK_ASSERT_DOUBLE_IS_NORMALIZED ( dval)    /* nop */

Definition at line 7825 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASSERT_EXPR

#define DUK_ASSERT_EXPR ( x)    ((void) 0)

Definition at line 7789 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ASSERT_HBUFFEROBJECT_VALID

#define DUK_ASSERT_HBUFFEROBJECT_VALID ( h)
Value:
do { \
DUK_ASSERT((h) != NULL); \
DUK_ASSERT((h)->shift <= 3); \
DUK_ASSERT((h)->elem_type <= DUK_HBUFFEROBJECT_ELEM_MAX); \
DUK_ASSERT(((h)->shift == 0 && (h)->elem_type == DUK_HBUFFEROBJECT_ELEM_UINT8) || \
((h)->shift == 0 && (h)->elem_type == DUK_HBUFFEROBJECT_ELEM_UINT8CLAMPED) || \
((h)->shift == 0 && (h)->elem_type == DUK_HBUFFEROBJECT_ELEM_INT8) || \
((h)->shift == 1 && (h)->elem_type == DUK_HBUFFEROBJECT_ELEM_UINT16) || \
((h)->shift == 1 && (h)->elem_type == DUK_HBUFFEROBJECT_ELEM_INT16) || \
((h)->shift == 2 && (h)->elem_type == DUK_HBUFFEROBJECT_ELEM_UINT32) || \
((h)->shift == 2 && (h)->elem_type == DUK_HBUFFEROBJECT_ELEM_INT32) || \
((h)->shift == 2 && (h)->elem_type == DUK_HBUFFEROBJECT_ELEM_FLOAT32) || \
((h)->shift == 3 && (h)->elem_type == DUK_HBUFFEROBJECT_ELEM_FLOAT64)); \
DUK_ASSERT((h)->is_view == 0 || (h)->is_view == 1); \
DUK_ASSERT(DUK_HOBJECT_IS_BUFFEROBJECT((duk_hobject *) (h))); \
if ((h)->buf == NULL) { \
DUK_ASSERT((h)->offset == 0); \
DUK_ASSERT((h)->length == 0); \
} else { \
/* No assertions for offset or length; in particular, \
* it's OK for length to be longer than underlying \
* buffer. Just ensure they don't wrap when added. \
*/ \
DUK_ASSERT((h)->offset + (h)->length >= (h)->offset); \
} \
} while (0)
#define DUK_HBUFFEROBJECT_ELEM_INT32
#define DUK_HBUFFEROBJECT_ELEM_MAX
#define DUK_HBUFFEROBJECT_ELEM_INT16
#define DUK_HOBJECT_IS_BUFFEROBJECT(h)
#define DUK_HBUFFEROBJECT_ELEM_FLOAT64
#define DUK_HBUFFEROBJECT_ELEM_UINT32
#define DUK_HBUFFEROBJECT_ELEM_UINT16
#define DUK_HBUFFEROBJECT_ELEM_FLOAT32
#define DUK_HBUFFEROBJECT_ELEM_UINT8CLAMPED
#define DUK_HBUFFEROBJECT_ELEM_INT8
#define DUK_HBUFFEROBJECT_ELEM_UINT8

Definition at line 5855 of file duktape-1.8.0/src/duktape.c.

5855#define DUK_HBUFFEROBJECT_ELEM_MAX 8
5856
5857#define DUK_ASSERT_HBUFFEROBJECT_VALID(h) do { \
5858 DUK_ASSERT((h) != NULL); \
5859 DUK_ASSERT((h)->shift <= 3); \
5860 DUK_ASSERT((h)->elem_type <= DUK_HBUFFEROBJECT_ELEM_MAX); \
5861 DUK_ASSERT(((h)->shift == 0 && (h)->elem_type == DUK_HBUFFEROBJECT_ELEM_UINT8) || \
5862 ((h)->shift == 0 && (h)->elem_type == DUK_HBUFFEROBJECT_ELEM_UINT8CLAMPED) || \
5863 ((h)->shift == 0 && (h)->elem_type == DUK_HBUFFEROBJECT_ELEM_INT8) || \
5864 ((h)->shift == 1 && (h)->elem_type == DUK_HBUFFEROBJECT_ELEM_UINT16) || \
5865 ((h)->shift == 1 && (h)->elem_type == DUK_HBUFFEROBJECT_ELEM_INT16) || \
5866 ((h)->shift == 2 && (h)->elem_type == DUK_HBUFFEROBJECT_ELEM_UINT32) || \
5867 ((h)->shift == 2 && (h)->elem_type == DUK_HBUFFEROBJECT_ELEM_INT32) || \
5868 ((h)->shift == 2 && (h)->elem_type == DUK_HBUFFEROBJECT_ELEM_FLOAT32) || \
5869 ((h)->shift == 3 && (h)->elem_type == DUK_HBUFFEROBJECT_ELEM_FLOAT64)); \
5870 DUK_ASSERT((h)->is_view == 0 || (h)->is_view == 1); \
5871 DUK_ASSERT(DUK_HOBJECT_IS_BUFFEROBJECT((duk_hobject *) (h))); \
5872 if ((h)->buf == NULL) { \
5873 DUK_ASSERT((h)->offset == 0); \
5874 DUK_ASSERT((h)->length == 0); \
5875 } else { \
5876 /* No assertions for offset or length; in particular, \
5877 * it's OK for length to be longer than underlying \

Referenced by duk__get_own_propdesc_raw(), duk_bi_typedarray_set(), and duk_hobject_putprop().

◆ DUK_ASSERT_HEAPHDR_LINKS

#define DUK_ASSERT_HEAPHDR_LINKS ( heap,
h )   do {} while (0)

Definition at line 3726 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__init_object_parts(), and duk__queue_refzero().

◆ DUK_ASSERT_HOBJECT_VALID

#define DUK_ASSERT_HOBJECT_VALID ( h)
Value:
do { \
DUK_ASSERT((h) != NULL); \
DUK_ASSERT(!DUK_HOBJECT_IS_CALLABLE((h)) || \
DUK_ASSERT(!DUK_HOBJECT_IS_BUFFEROBJECT((h)) || \
} while (0)
#define DUK_HOBJECT_CLASS_BUFFER
#define DUK_HOBJECT_CLASS_INT32ARRAY
#define DUK_HOBJECT_CLASS_INT16ARRAY
#define DUK_HOBJECT_CLASS_FUNCTION
#define DUK_HOBJECT_CLASS_UINT8CLAMPEDARRAY
#define DUK_HOBJECT_IS_CALLABLE(h)
#define DUK_HOBJECT_CLASS_FLOAT32ARRAY
#define DUK_HOBJECT_CLASS_UINT8ARRAY
#define DUK_HOBJECT_CLASS_UINT32ARRAY
#define DUK_HOBJECT_CLASS_INT8ARRAY
#define DUK_HOBJECT_CLASS_UINT16ARRAY
#define DUK_HOBJECT_GET_CLASS_NUMBER(h)
#define DUK_HOBJECT_CLASS_ARRAYBUFFER
#define DUK_HOBJECT_CLASS_DATAVIEW
#define DUK_HOBJECT_CLASS_FLOAT64ARRAY

Definition at line 4924 of file duktape-1.8.0/src/duktape.c.

4924 */
4925
4926#define DUK_ASSERT_HOBJECT_VALID(h) do { \
4927 DUK_ASSERT((h) != NULL); \
4928 DUK_ASSERT(!DUK_HOBJECT_IS_CALLABLE((h)) || \
4929 DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_FUNCTION); \
4930 DUK_ASSERT(!DUK_HOBJECT_IS_BUFFEROBJECT((h)) || \
4931 (DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_BUFFER || \
4932 DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_ARRAYBUFFER || \
4933 DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_DATAVIEW || \
4934 DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_INT8ARRAY || \
4935 DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_UINT8ARRAY || \
4936 DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_UINT8CLAMPEDARRAY || \
4937 DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_INT16ARRAY || \
4938 DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_UINT16ARRAY || \
4939 DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_INT32ARRAY || \
4940 DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_UINT32ARRAY || \
4941 DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_FLOAT32ARRAY || \

◆ DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR

#define DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR ( h)    /* no refcount check */

◆ DUK_ASSERT_REFCOUNT_NONZERO_TVAL

#define DUK_ASSERT_REFCOUNT_NONZERO_TVAL ( tv)    /* no refcount check */

Definition at line 7813 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__putvar_helper().

◆ DUK_ASSERT_TOP

◆ DUK_ASSERT_VALID_NEGIDX

#define DUK_ASSERT_VALID_NEGIDX ( ctx,
idx )    (DUK_ASSERT_EXPR((idx) < 0), DUK_ASSERT_EXPR(duk_is_valid_index((ctx), (idx))))

Definition at line 4403 of file duktape-1.8.0/src/duktape.c.

4403#define DUK_ASSERT_VALID_NEGIDX(ctx,idx) \
4404 (DUK_ASSERT_EXPR((idx) < 0), DUK_ASSERT_EXPR(duk_is_valid_index((ctx), (idx))))

◆ DUK_ASSERT_VALID_POSIDX

#define DUK_ASSERT_VALID_POSIDX ( ctx,
idx )    (DUK_ASSERT_EXPR((idx) >= 0), DUK_ASSERT_EXPR(duk_is_valid_index((ctx), (idx))))

Definition at line 4405 of file duktape-1.8.0/src/duktape.c.

4405#define DUK_ASSERT_VALID_POSIDX(ctx,idx) \
4406 (DUK_ASSERT_EXPR((idx) >= 0), DUK_ASSERT_EXPR(duk_is_valid_index((ctx), (idx))))

◆ DUK_ASSERT_VALSTACK_SPACE

◆ DUK_BC_A_MAX

#define DUK_BC_A_MAX   0xffL

Definition at line 2582 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_A_MIN

#define DUK_BC_A_MIN   0

Definition at line 2581 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_ABC_MAX

#define DUK_BC_ABC_MAX   0x3ffffffL

Definition at line 2590 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_ABC_MIN

#define DUK_BC_ABC_MIN   0

Definition at line 2589 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_B_MAX

#define DUK_BC_B_MAX   0x1ffL

Definition at line 2584 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_B_MIN

#define DUK_BC_B_MIN   0

Definition at line 2583 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_BC_MAX

#define DUK_BC_BC_MAX   0x3ffffL

Definition at line 2588 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_BC_MIN

#define DUK_BC_BC_MIN   0

Definition at line 2587 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_C_MAX

#define DUK_BC_C_MAX   0x1ffL

Definition at line 2586 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_C_MIN

#define DUK_BC_C_MIN   0

Definition at line 2585 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_CALL_FLAG_EVALCALL

#define DUK_BC_CALL_FLAG_EVALCALL   (1 << 1)

Definition at line 2698 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_CALL_FLAG_TAILCALL

#define DUK_BC_CALL_FLAG_TAILCALL   (1 << 0)

Definition at line 2697 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_DECLVAR_FLAG_FUNC_DECL

#define DUK_BC_DECLVAR_FLAG_FUNC_DECL   (1 << 5) /* function declaration */

◆ DUK_BC_DECLVAR_FLAG_UNDEF_VALUE

#define DUK_BC_DECLVAR_FLAG_UNDEF_VALUE   (1 << 4) /* use 'undefined' for value automatically */

◆ DUK_BC_EXTRAOP_MAX

#define DUK_BC_EXTRAOP_MAX   DUK_BC_A_MAX

Definition at line 2592 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_EXTRAOP_MIN

#define DUK_BC_EXTRAOP_MIN   DUK_BC_A_MIN

Definition at line 2591 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_ISCONST

#define DUK_BC_ISCONST ( x)    ((x) >= DUK_BC_REGLIMIT)

Definition at line 2716 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_ISREG

#define DUK_BC_ISREG ( x)    ((x) < DUK_BC_REGLIMIT)

Definition at line 2715 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_JUMP_BIAS

#define DUK_BC_JUMP_BIAS   (1L << 25)

Definition at line 2719 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_LDINT_BIAS

#define DUK_BC_LDINT_BIAS   (1L << 17)

Definition at line 2717 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__emit_load_int32().

◆ DUK_BC_LDINTX_SHIFT

#define DUK_BC_LDINTX_SHIFT   18

Definition at line 2718 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_OP_MAX

#define DUK_BC_OP_MAX   0x3fL

Definition at line 2580 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_OP_MIN

#define DUK_BC_OP_MIN   0

Definition at line 2579 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_REGLIMIT

#define DUK_BC_REGLIMIT   256 /* if B/C is >= this value, refers to a const */

Definition at line 2714 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_RETURN_FLAG_HAVE_RETVAL

#define DUK_BC_RETURN_FLAG_HAVE_RETVAL   (1 << 0)

Definition at line 2707 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_func_body().

◆ DUK_BC_TRYCATCH_FLAG_CATCH_BINDING

#define DUK_BC_TRYCATCH_FLAG_CATCH_BINDING   (1 << 2)

Definition at line 2703 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_TRYCATCH_FLAG_HAVE_CATCH

#define DUK_BC_TRYCATCH_FLAG_HAVE_CATCH   (1 << 0)

Definition at line 2701 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_TRYCATCH_FLAG_HAVE_FINALLY

#define DUK_BC_TRYCATCH_FLAG_HAVE_FINALLY   (1 << 1)

Definition at line 2702 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BC_TRYCATCH_FLAG_WITH_BINDING

#define DUK_BC_TRYCATCH_FLAG_WITH_BINDING   (1 << 3)

Definition at line 2704 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BI_COMMONJS_MODULE_ID_LIMIT

#define DUK_BI_COMMONJS_MODULE_ID_LIMIT   256

Definition at line 8581 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BI_DATE_ISO8601_BUFSIZE

#define DUK_BI_DATE_ISO8601_BUFSIZE   48

Definition at line 8575 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_ARRAY_CONSTRUCTOR

#define DUK_BIDX_ARRAY_CONSTRUCTOR   6

Definition at line 1642 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_ARRAY_PROTOTYPE

#define DUK_BIDX_ARRAY_PROTOTYPE   7

Definition at line 1643 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_ARRAYBUFFER_CONSTRUCTOR

#define DUK_BIDX_ARRAYBUFFER_CONSTRUCTOR   46

Definition at line 1682 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_ARRAYBUFFER_PROTOTYPE

#define DUK_BIDX_ARRAYBUFFER_PROTOTYPE   47

Definition at line 1683 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_BOOLEAN_CONSTRUCTOR

#define DUK_BIDX_BOOLEAN_CONSTRUCTOR   10

Definition at line 1646 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_BOOLEAN_PROTOTYPE

#define DUK_BIDX_BOOLEAN_PROTOTYPE   11

Definition at line 1647 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_putprop().

◆ DUK_BIDX_BUFFER_CONSTRUCTOR

#define DUK_BIDX_BUFFER_CONSTRUCTOR   39

Definition at line 1675 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_BUFFER_PROTOTYPE

#define DUK_BIDX_BUFFER_PROTOTYPE   40

Definition at line 1676 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_putprop().

◆ DUK_BIDX_DATAVIEW_CONSTRUCTOR

#define DUK_BIDX_DATAVIEW_CONSTRUCTOR   48

Definition at line 1684 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_DATAVIEW_PROTOTYPE

#define DUK_BIDX_DATAVIEW_PROTOTYPE   49

Definition at line 1685 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_DATE_CONSTRUCTOR

#define DUK_BIDX_DATE_CONSTRUCTOR   14

Definition at line 1650 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_DATE_PROTOTYPE

#define DUK_BIDX_DATE_PROTOTYPE   15

Definition at line 1651 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_DOUBLE_ERROR

#define DUK_BIDX_DOUBLE_ERROR   45

Definition at line 1681 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_err_create_and_throw().

◆ DUK_BIDX_DUKTAPE

#define DUK_BIDX_DUKTAPE   36

Definition at line 1672 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__err_augment_user().

◆ DUK_BIDX_ERROR_CONSTRUCTOR

#define DUK_BIDX_ERROR_CONSTRUCTOR   18

Definition at line 1654 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_ERROR_PROTOTYPE

#define DUK_BIDX_ERROR_PROTOTYPE   19

Definition at line 1655 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_err_augment_error_create().

◆ DUK_BIDX_EVAL_ERROR_CONSTRUCTOR

#define DUK_BIDX_EVAL_ERROR_CONSTRUCTOR   20

Definition at line 1656 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_EVAL_ERROR_PROTOTYPE

#define DUK_BIDX_EVAL_ERROR_PROTOTYPE   21

Definition at line 1657 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_FLOAT32ARRAY_CONSTRUCTOR

#define DUK_BIDX_FLOAT32ARRAY_CONSTRUCTOR   65

Definition at line 1701 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_FLOAT32ARRAY_PROTOTYPE

#define DUK_BIDX_FLOAT32ARRAY_PROTOTYPE   66

Definition at line 1702 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_FLOAT64ARRAY_CONSTRUCTOR

#define DUK_BIDX_FLOAT64ARRAY_CONSTRUCTOR   67

Definition at line 1703 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_FLOAT64ARRAY_PROTOTYPE

#define DUK_BIDX_FLOAT64ARRAY_PROTOTYPE   68

Definition at line 1704 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_FUNCTION_CONSTRUCTOR

#define DUK_BIDX_FUNCTION_CONSTRUCTOR   4

Definition at line 1640 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_FUNCTION_PROTOTYPE

#define DUK_BIDX_FUNCTION_PROTOTYPE   5

Definition at line 1641 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_putprop().

◆ DUK_BIDX_GLOBAL

#define DUK_BIDX_GLOBAL   0

◆ DUK_BIDX_GLOBAL_ENV

#define DUK_BIDX_GLOBAL_ENV   1

Definition at line 1637 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__declvar_helper().

◆ DUK_BIDX_INT16ARRAY_CONSTRUCTOR

#define DUK_BIDX_INT16ARRAY_CONSTRUCTOR   57

Definition at line 1693 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_INT16ARRAY_PROTOTYPE

#define DUK_BIDX_INT16ARRAY_PROTOTYPE   58

Definition at line 1694 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_INT32ARRAY_CONSTRUCTOR

#define DUK_BIDX_INT32ARRAY_CONSTRUCTOR   61

Definition at line 1697 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_INT32ARRAY_PROTOTYPE

#define DUK_BIDX_INT32ARRAY_PROTOTYPE   62

Definition at line 1698 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_INT8ARRAY_CONSTRUCTOR

#define DUK_BIDX_INT8ARRAY_CONSTRUCTOR   51

Definition at line 1687 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_INT8ARRAY_PROTOTYPE

#define DUK_BIDX_INT8ARRAY_PROTOTYPE   52

Definition at line 1688 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_JSON

#define DUK_BIDX_JSON   33

Definition at line 1669 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_LOGGER_CONSTRUCTOR

#define DUK_BIDX_LOGGER_CONSTRUCTOR   43

Definition at line 1679 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_LOGGER_PROTOTYPE

#define DUK_BIDX_LOGGER_PROTOTYPE   44

Definition at line 1680 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_MATH

#define DUK_BIDX_MATH   32

Definition at line 1668 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_NODEJS_BUFFER_CONSTRUCTOR

#define DUK_BIDX_NODEJS_BUFFER_CONSTRUCTOR   69

Definition at line 1705 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_NODEJS_BUFFER_PROTOTYPE

#define DUK_BIDX_NODEJS_BUFFER_PROTOTYPE   70

Definition at line 1706 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_NUMBER_CONSTRUCTOR

#define DUK_BIDX_NUMBER_CONSTRUCTOR   12

Definition at line 1648 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_NUMBER_PROTOTYPE

#define DUK_BIDX_NUMBER_PROTOTYPE   13

Definition at line 1649 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_putprop().

◆ DUK_BIDX_OBJECT_CONSTRUCTOR

#define DUK_BIDX_OBJECT_CONSTRUCTOR   2

Definition at line 1638 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_OBJECT_PROTOTYPE

#define DUK_BIDX_OBJECT_PROTOTYPE   3

Definition at line 1639 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_buffer_slice_shared().

◆ DUK_BIDX_POINTER_CONSTRUCTOR

#define DUK_BIDX_POINTER_CONSTRUCTOR   41

Definition at line 1677 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_POINTER_PROTOTYPE

#define DUK_BIDX_POINTER_PROTOTYPE   42

Definition at line 1678 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_putprop().

◆ DUK_BIDX_PROXY_CONSTRUCTOR

#define DUK_BIDX_PROXY_CONSTRUCTOR   35

Definition at line 1671 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_RANGE_ERROR_CONSTRUCTOR

#define DUK_BIDX_RANGE_ERROR_CONSTRUCTOR   22

Definition at line 1658 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_RANGE_ERROR_PROTOTYPE

#define DUK_BIDX_RANGE_ERROR_PROTOTYPE   23

Definition at line 1659 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_REFERENCE_ERROR_CONSTRUCTOR

#define DUK_BIDX_REFERENCE_ERROR_CONSTRUCTOR   24

Definition at line 1660 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_REFERENCE_ERROR_PROTOTYPE

#define DUK_BIDX_REFERENCE_ERROR_PROTOTYPE   25

Definition at line 1661 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_REGEXP_CONSTRUCTOR

#define DUK_BIDX_REGEXP_CONSTRUCTOR   16

Definition at line 1652 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_REGEXP_PROTOTYPE

#define DUK_BIDX_REGEXP_PROTOTYPE   17

Definition at line 1653 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_STRING_CONSTRUCTOR

#define DUK_BIDX_STRING_CONSTRUCTOR   8

Definition at line 1644 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_STRING_PROTOTYPE

#define DUK_BIDX_STRING_PROTOTYPE   9

◆ DUK_BIDX_SYNTAX_ERROR_CONSTRUCTOR

#define DUK_BIDX_SYNTAX_ERROR_CONSTRUCTOR   26

Definition at line 1662 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_SYNTAX_ERROR_PROTOTYPE

#define DUK_BIDX_SYNTAX_ERROR_PROTOTYPE   27

Definition at line 1663 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_THREAD_CONSTRUCTOR

#define DUK_BIDX_THREAD_CONSTRUCTOR   37

Definition at line 1673 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_THREAD_PROTOTYPE

#define DUK_BIDX_THREAD_PROTOTYPE   38

Definition at line 1674 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_TYPE_ERROR_CONSTRUCTOR

#define DUK_BIDX_TYPE_ERROR_CONSTRUCTOR   28

Definition at line 1664 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_TYPE_ERROR_PROTOTYPE

#define DUK_BIDX_TYPE_ERROR_PROTOTYPE   29

Definition at line 1665 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_TYPE_ERROR_THROWER

#define DUK_BIDX_TYPE_ERROR_THROWER   34

Definition at line 1670 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_TYPEDARRAY_PROTOTYPE

#define DUK_BIDX_TYPEDARRAY_PROTOTYPE   50

Definition at line 1686 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_UINT16ARRAY_CONSTRUCTOR

#define DUK_BIDX_UINT16ARRAY_CONSTRUCTOR   59

Definition at line 1695 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_UINT16ARRAY_PROTOTYPE

#define DUK_BIDX_UINT16ARRAY_PROTOTYPE   60

Definition at line 1696 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_UINT32ARRAY_CONSTRUCTOR

#define DUK_BIDX_UINT32ARRAY_CONSTRUCTOR   63

Definition at line 1699 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_UINT32ARRAY_PROTOTYPE

#define DUK_BIDX_UINT32ARRAY_PROTOTYPE   64

Definition at line 1700 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_UINT8ARRAY_CONSTRUCTOR

#define DUK_BIDX_UINT8ARRAY_CONSTRUCTOR   53

Definition at line 1689 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_UINT8ARRAY_PROTOTYPE

#define DUK_BIDX_UINT8ARRAY_PROTOTYPE   54

Definition at line 1690 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_UINT8CLAMPEDARRAY_CONSTRUCTOR

#define DUK_BIDX_UINT8CLAMPEDARRAY_CONSTRUCTOR   55

Definition at line 1691 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_UINT8CLAMPEDARRAY_PROTOTYPE

#define DUK_BIDX_UINT8CLAMPEDARRAY_PROTOTYPE   56

Definition at line 1692 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_URI_ERROR_CONSTRUCTOR

#define DUK_BIDX_URI_ERROR_CONSTRUCTOR   30

Definition at line 1666 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BIDX_URI_ERROR_PROTOTYPE

#define DUK_BIDX_URI_ERROR_PROTOTYPE   31

Definition at line 1667 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BUILTIN_INITJS_DATA_LENGTH

#define DUK_BUILTIN_INITJS_DATA_LENGTH   204

Definition at line 1634 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BUILTIN_PROTOS_H_INCLUDED

#define DUK_BUILTIN_PROTOS_H_INCLUDED

Definition at line 8567 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BUILTINS_H_INCLUDED

#define DUK_BUILTINS_H_INCLUDED

Definition at line 881 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BW_ADD_PTR

#define DUK_BW_ADD_PTR ( thr,
bw_ctx,
delta )
Value:
do { \
(bw_ctx)->p += (delta); \
} while (0)

Definition at line 1902 of file duktape-1.8.0/src/duktape.c.

1902#define DUK_BW_ADD_PTR(thr,bw_ctx,delta) do { \
1903 (bw_ctx)->p += (delta); \
1904 } while (0)

◆ DUK_BW_ASSERT_SPACE

#define DUK_BW_ASSERT_SPACE ( thr,
bw_ctx,
sz )
Value:
do { \
DUK_BW_ASSERT_SPACE_EXPR((thr), (bw_ctx), (sz)); \
} while (0)

Definition at line 1944 of file duktape-1.8.0/src/duktape.c.

1944#define DUK_BW_ASSERT_SPACE(thr,bw_ctx,sz) do { \
1945 DUK_BW_ASSERT_SPACE_EXPR((thr), (bw_ctx), (sz)); \
1946 } while (0)

◆ DUK_BW_ASSERT_SPACE_EXPR

#define DUK_BW_ASSERT_SPACE_EXPR ( thr,
bw_ctx,
sz )
Value:
(DUK_BW_ASSERT_VALID_EXPR((thr), (bw_ctx)), \
DUK_ASSERT_EXPR((duk_size_t) ((bw_ctx)->p_limit - (bw_ctx)->p) >= (duk_size_t) (sz)))
#define DUK_BW_ASSERT_VALID_EXPR(thr, bw_ctx)

Definition at line 1941 of file duktape-1.8.0/src/duktape.c.

1941#define DUK_BW_ASSERT_SPACE_EXPR(thr,bw_ctx,sz) \
1942 (DUK_BW_ASSERT_VALID_EXPR((thr), (bw_ctx)), \
1943 DUK_ASSERT_EXPR((duk_size_t) ((bw_ctx)->p_limit - (bw_ctx)->p) >= (duk_size_t) (sz)))

◆ DUK_BW_ASSERT_VALID

#define DUK_BW_ASSERT_VALID ( thr,
bw_ctx )
Value:
do { \
DUK_BW_ASSERT_VALID_EXPR((thr), (bw_ctx)); \
} while (0)

Definition at line 1891 of file duktape-1.8.0/src/duktape.c.

1891#define DUK_BW_ASSERT_VALID(thr,bw_ctx) do { \
1892 DUK_BW_ASSERT_VALID_EXPR((thr), (bw_ctx)); \
1893 } while (0)

◆ DUK_BW_ASSERT_VALID_EXPR

#define DUK_BW_ASSERT_VALID_EXPR ( thr,
bw_ctx )
Value:
DUK_ASSERT_EXPR((bw_ctx) != NULL && \
(bw_ctx)->buf != NULL && \
((DUK_HBUFFER_DYNAMIC_GET_SIZE((bw_ctx)->buf) == 0) || \
((bw_ctx)->p != NULL && \
(bw_ctx)->p_base != NULL && \
(bw_ctx)->p_limit != NULL && \
(bw_ctx)->p_limit >= (bw_ctx)->p_base && \
(bw_ctx)->p >= (bw_ctx)->p_base && \
(bw_ctx)->p <= (bw_ctx)->p_limit)))
#define DUK_HBUFFER_DYNAMIC_GET_SIZE(x)
#define DUK_ASSERT_EXPR(x)

Definition at line 1881 of file duktape-1.8.0/src/duktape.c.

1881#define DUK_BW_ASSERT_VALID_EXPR(thr,bw_ctx) \
1882 DUK_ASSERT_EXPR((bw_ctx) != NULL && \
1883 (bw_ctx)->buf != NULL && \
1884 ((DUK_HBUFFER_DYNAMIC_GET_SIZE((bw_ctx)->buf) == 0) || \
1885 ((bw_ctx)->p != NULL && \
1886 (bw_ctx)->p_base != NULL && \
1887 (bw_ctx)->p_limit != NULL && \
1888 (bw_ctx)->p_limit >= (bw_ctx)->p_base && \
1889 (bw_ctx)->p >= (bw_ctx)->p_base && \
1890 (bw_ctx)->p <= (bw_ctx)->p_limit)))

◆ DUK_BW_COMPACT

#define DUK_BW_COMPACT ( thr,
bw_ctx )
Value:
do { \
/* Make underlying buffer compact to match DUK_BW_GET_SIZE(). */ \
duk_bw_compact((thr), (bw_ctx)); \
} while (0)

Definition at line 1867 of file duktape-1.8.0/src/duktape.c.

1867#define DUK_BW_COMPACT(thr,bw_ctx) do { \
1868 /* Make underlying buffer compact to match DUK_BW_GET_SIZE(). */ \
1869 duk_bw_compact((thr), (bw_ctx)); \
1870 } while (0)

◆ DUK_BW_ENSURE

#define DUK_BW_ENSURE ( thr,
bw_ctx,
sz )
Value:
do { \
duk_size_t duk__sz, duk__space; \
DUK_BW_ASSERT_VALID((thr), (bw_ctx)); \
duk__sz = (sz); \
duk__space = (duk_size_t) ((bw_ctx)->p_limit - (bw_ctx)->p); \
if (duk__space < duk__sz) { \
(void) duk_bw_resize((thr), (bw_ctx), duk__sz); \
} \
} while (0)
DUK_INTERNAL_DECL duk_uint8_t * duk_bw_resize(duk_hthread *thr, duk_bufwriter_ctx *bw_ctx, duk_size_t sz)

Definition at line 1924 of file duktape-1.8.0/src/duktape.c.

1924#define DUK_BW_ENSURE(thr,bw_ctx,sz) do { \
1925 duk_size_t duk__sz, duk__space; \
1926 DUK_BW_ASSERT_VALID((thr), (bw_ctx)); \
1927 duk__sz = (sz); \
1928 duk__space = (duk_size_t) ((bw_ctx)->p_limit - (bw_ctx)->p); \
1929 if (duk__space < duk__sz) { \
1930 (void) duk_bw_resize((thr), (bw_ctx), duk__sz); \
1931 } \
1932 } while (0)

Referenced by duk_bw_insert_raw_area().

◆ DUK_BW_ENSURE_GETPTR

#define DUK_BW_ENSURE_GETPTR ( thr,
bw_ctx,
sz )    DUK_BW_ENSURE_RAW((thr), (bw_ctx), (sz), (bw_ctx)->p)

Definition at line 1939 of file duktape-1.8.0/src/duktape.c.

1939#define DUK_BW_ENSURE_GETPTR(thr,bw_ctx,sz) \
1940 DUK_BW_ENSURE_RAW((thr), (bw_ctx), (sz), (bw_ctx)->p)

◆ DUK_BW_ENSURE_RAW

#define DUK_BW_ENSURE_RAW ( thr,
bw_ctx,
sz,
ptr )
Value:
(((duk_size_t) ((bw_ctx)->p_limit - (ptr)) >= (sz)) ? \
(ptr) : \
((bw_ctx)->p = (ptr), duk_bw_resize((thr),(bw_ctx),(sz))))

Definition at line 1935 of file duktape-1.8.0/src/duktape.c.

1935#define DUK_BW_ENSURE_RAW(thr,bw_ctx,sz,ptr) \
1936 (((duk_size_t) ((bw_ctx)->p_limit - (ptr)) >= (sz)) ? \
1937 (ptr) : \
1938 ((bw_ctx)->p = (ptr), duk_bw_resize((thr),(bw_ctx),(sz))))

Referenced by duk__create_escaped_source().

◆ DUK_BW_GET_BASEPTR

#define DUK_BW_GET_BASEPTR ( thr,
bw_ctx )    ((bw_ctx)->p_base)

Definition at line 1905 of file duktape-1.8.0/src/duktape.c.

1905#define DUK_BW_GET_BASEPTR(thr,bw_ctx) \
1906 ((bw_ctx)->p_base)

◆ DUK_BW_GET_BUFFER

#define DUK_BW_GET_BUFFER ( thr,
bw_ctx )    ((bw_ctx)->buf)

Definition at line 1919 of file duktape-1.8.0/src/duktape.c.

1919#define DUK_BW_GET_BUFFER(thr,bw_ctx) \
1920 ((bw_ctx)->buf)

◆ DUK_BW_GET_LIMITPTR

#define DUK_BW_GET_LIMITPTR ( thr,
bw_ctx )    ((bw_ctx)->p_limit)

Definition at line 1907 of file duktape-1.8.0/src/duktape.c.

1907#define DUK_BW_GET_LIMITPTR(thr,bw_ctx) \
1908 ((bw_ctx)->p_limit)

◆ DUK_BW_GET_PTR

#define DUK_BW_GET_PTR ( thr,
bw_ctx )    ((bw_ctx)->p)

Definition at line 1897 of file duktape-1.8.0/src/duktape.c.

1897#define DUK_BW_GET_PTR(thr,bw_ctx) \
1898 ((bw_ctx)->p)

Referenced by duk__create_escaped_source().

◆ DUK_BW_GET_SIZE

#define DUK_BW_GET_SIZE ( thr,
bw_ctx )    ((duk_size_t) ((bw_ctx)->p - (bw_ctx)->p_base))

Definition at line 1909 of file duktape-1.8.0/src/duktape.c.

1909#define DUK_BW_GET_SIZE(thr,bw_ctx) \
1910 ((duk_size_t) ((bw_ctx)->p - (bw_ctx)->p_base))

Referenced by duk__emit(), duk_bw_insert_raw_area(), and duk_bw_write_ensure_slice().

◆ DUK_BW_INIT_PUSHBUF

#define DUK_BW_INIT_PUSHBUF ( thr,
bw_ctx,
sz )
Value:
do { \
duk_bw_init_pushbuf((thr), (bw_ctx), (sz)); \
} while (0)

Definition at line 1861 of file duktape-1.8.0/src/duktape.c.

1861#define DUK_BW_INIT_PUSHBUF(thr,bw_ctx,sz) do { \
1862 duk_bw_init_pushbuf((thr), (bw_ctx), (sz)); \
1863 } while (0)

Referenced by duk__create_escaped_source().

◆ DUK_BW_INIT_WITHBUF

#define DUK_BW_INIT_WITHBUF ( thr,
bw_ctx,
buf )
Value:
do { \
duk_bw_init((thr), (bw_ctx), (buf)); \
} while (0)

Definition at line 1864 of file duktape-1.8.0/src/duktape.c.

1864#define DUK_BW_INIT_WITHBUF(thr,bw_ctx,buf) do { \
1865 duk_bw_init((thr), (bw_ctx), (buf)); \
1866 } while (0)

Referenced by duk__appendbuffer().

◆ DUK_BW_INSERT_ENSURE_AREA

#define DUK_BW_INSERT_ENSURE_AREA ( thr,
bw,
off,
len )
Value:
/* Evaluates to (duk_uint8_t *) pointing to start of area. */ \
duk_bw_insert_ensure_area((thr), (bw), (off), (len))

Definition at line 2186 of file duktape-1.8.0/src/duktape.c.

2186#define DUK_BW_INSERT_ENSURE_AREA(thr,bw,off,len) \
2187 /* Evaluates to (duk_uint8_t *) pointing to start of area. */ \
2188 duk_bw_insert_ensure_area((thr), (bw), (off), (len))

◆ DUK_BW_INSERT_ENSURE_BYTES

#define DUK_BW_INSERT_ENSURE_BYTES ( thr,
bw,
dst_off,
buf,
len )    duk_bw_insert_ensure_bytes((thr), (bw), (dst_off), (buf), (len))

Definition at line 2182 of file duktape-1.8.0/src/duktape.c.

2182#define DUK_BW_INSERT_ENSURE_BYTES(thr,bw,dst_off,buf,len) \
2183 duk_bw_insert_ensure_bytes((thr), (bw), (dst_off), (buf), (len))

◆ DUK_BW_INSERT_ENSURE_SLICE

#define DUK_BW_INSERT_ENSURE_SLICE ( thr,
bw,
dst_off,
src_off,
len )    duk_bw_insert_ensure_slice((thr), (bw), (dst_off), (src_off), (len))

Definition at line 2184 of file duktape-1.8.0/src/duktape.c.

2184#define DUK_BW_INSERT_ENSURE_SLICE(thr,bw,dst_off,src_off,len) \
2185 duk_bw_insert_ensure_slice((thr), (bw), (dst_off), (src_off), (len))

◆ DUK_BW_INSERT_RAW_AREA

#define DUK_BW_INSERT_RAW_AREA ( thr,
bw,
off,
len )    duk_bw_insert_raw_area((thr), (bw), (off), (len))

Definition at line 2091 of file duktape-1.8.0/src/duktape.c.

2091#define DUK_BW_INSERT_RAW_AREA(thr,bw,off,len) \
2092 duk_bw_insert_raw_area((thr), (bw), (off), (len))

◆ DUK_BW_INSERT_RAW_BYTES

#define DUK_BW_INSERT_RAW_BYTES ( thr,
bw,
dst_off,
buf,
len )    duk_bw_insert_raw_bytes((thr), (bw), (dst_off), (buf), (len))

Definition at line 2078 of file duktape-1.8.0/src/duktape.c.

2078#define DUK_BW_INSERT_RAW_BYTES(thr,bw,dst_off,buf,len) \
2079 duk_bw_insert_raw_bytes((thr), (bw), (dst_off), (buf), (len))

◆ DUK_BW_INSERT_RAW_SLICE

#define DUK_BW_INSERT_RAW_SLICE ( thr,
bw,
dst_off,
src_off,
len )    duk_bw_insert_raw_slice((thr), (bw), (dst_off), (src_off), (len))

Definition at line 2084 of file duktape-1.8.0/src/duktape.c.

2084#define DUK_BW_INSERT_RAW_SLICE(thr,bw,dst_off,src_off,len) \
2085 duk_bw_insert_raw_slice((thr), (bw), (dst_off), (src_off), (len))

◆ DUK_BW_PUSH_AS_STRING

#define DUK_BW_PUSH_AS_STRING ( thr,
bw_ctx )
Value:
do { \
duk_push_lstring((duk_context *) (thr), \
(const char *) (bw_ctx)->p_base, \
(duk_size_t) ((bw_ctx)->p - (bw_ctx)->p_base)); \
} while (0)

Definition at line 1871 of file duktape-1.8.0/src/duktape.c.

1871#define DUK_BW_PUSH_AS_STRING(thr,bw_ctx) do { \
1872 duk_push_lstring((duk_context *) (thr), \
1873 (const char *) (bw_ctx)->p_base, \
1874 (duk_size_t) ((bw_ctx)->p - (bw_ctx)->p_base)); \
1875 } while (0)

Referenced by duk_lexer_initctx().

◆ DUK_BW_REMOVE_ENSURE_SLICE

#define DUK_BW_REMOVE_ENSURE_SLICE ( thr,
bw,
off,
len )
Value:
/* No difference between raw/ensure because the buffer shrinks. */ \
DUK_BW_REMOVE_RAW_SLICE((thr), (bw), (off), (len))

Definition at line 2189 of file duktape-1.8.0/src/duktape.c.

2189#define DUK_BW_REMOVE_ENSURE_SLICE(thr,bw,off,len) \
2190 /* No difference between raw/ensure because the buffer shrinks. */ \
2191 DUK_BW_REMOVE_RAW_SLICE((thr), (bw), (off), (len))

Referenced by duk__insert_jump_offset().

◆ DUK_BW_REMOVE_RAW_SLICE

#define DUK_BW_REMOVE_RAW_SLICE ( thr,
bw,
off,
len )    duk_bw_remove_raw_slice((thr), (bw), (off), (len))

Definition at line 2095 of file duktape-1.8.0/src/duktape.c.

2095#define DUK_BW_REMOVE_RAW_SLICE(thr,bw,off,len) \
2096 duk_bw_remove_raw_slice((thr), (bw), (off), (len))

◆ DUK_BW_RESET_SIZE

#define DUK_BW_RESET_SIZE ( thr,
bw_ctx )
Value:
do { \
/* Reset to zero size, keep current limit. */ \
(bw_ctx)->p = (bw_ctx)->p_base; \
} while (0)

Definition at line 1915 of file duktape-1.8.0/src/duktape.c.

1915#define DUK_BW_RESET_SIZE(thr,bw_ctx) do { \
1916 /* Reset to zero size, keep current limit. */ \
1917 (bw_ctx)->p = (bw_ctx)->p_base; \
1918 } while (0)

◆ DUK_BW_SET_PTR

#define DUK_BW_SET_PTR ( thr,
bw_ctx,
ptr )
Value:
do { \
(bw_ctx)->p = (ptr); \
} while (0)

Definition at line 1899 of file duktape-1.8.0/src/duktape.c.

1899#define DUK_BW_SET_PTR(thr,bw_ctx,ptr) do { \
1900 (bw_ctx)->p = (ptr); \
1901 } while (0)

◆ DUK_BW_SET_SIZE

#define DUK_BW_SET_SIZE ( thr,
bw_ctx,
sz )
Value:
do { \
DUK_ASSERT((duk_size_t) (sz) <= (duk_size_t) ((bw_ctx)->p - (bw_ctx)->p_base)); \
(bw_ctx)->p = (bw_ctx)->p_base + (sz); \
} while (0)

Definition at line 1911 of file duktape-1.8.0/src/duktape.c.

1911#define DUK_BW_SET_SIZE(thr,bw_ctx,sz) do { \
1912 DUK_ASSERT((duk_size_t) (sz) <= (duk_size_t) ((bw_ctx)->p - (bw_ctx)->p_base)); \
1913 (bw_ctx)->p = (bw_ctx)->p_base + (sz); \
1914 } while (0)

◆ DUK_BW_SETPTR_AND_COMPACT

#define DUK_BW_SETPTR_AND_COMPACT ( thr,
bw_ctx,
ptr )
Value:
do { \
(bw_ctx)->p = (ptr); \
duk_bw_compact((thr), (bw_ctx)); \
} while (0)

Definition at line 1950 of file duktape-1.8.0/src/duktape.c.

1950#define DUK_BW_SETPTR_AND_COMPACT(thr,bw_ctx,ptr) do { \
1951 (bw_ctx)->p = (ptr); \
1952 duk_bw_compact((thr), (bw_ctx)); \
1953 } while (0)

Referenced by duk__create_escaped_source().

◆ DUK_BW_SPARE_ADD

#define DUK_BW_SPARE_ADD   64

Definition at line 1856 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BW_SPARE_SHIFT

#define DUK_BW_SPARE_SHIFT   4 /* 2^4 -> 1/16 = 6.25% spare */

Definition at line 1857 of file duktape-1.8.0/src/duktape.c.

◆ DUK_BW_WRITE_ENSURE_BYTES

#define DUK_BW_WRITE_ENSURE_BYTES ( thr,
bw_ctx,
valptr,
valsz )
Value:
do { \
const void *duk__valptr; \
duk_size_t duk__valsz; \
duk__valptr = (const void *) (valptr); \
duk__valsz = (duk_size_t) (valsz); \
DUK_BW_ENSURE((thr), (bw_ctx), duk__valsz); \
DUK_MEMCPY((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \
(bw_ctx)->p += duk__valsz; \
} while (0)

Definition at line 2133 of file duktape-1.8.0/src/duktape.c.

2133#define DUK_BW_WRITE_ENSURE_BYTES(thr,bw_ctx,valptr,valsz) do { \
2134 const void *duk__valptr; \
2135 duk_size_t duk__valsz; \
2136 duk__valptr = (const void *) (valptr); \
2137 duk__valsz = (duk_size_t) (valsz); \
2138 DUK_BW_ENSURE((thr), (bw_ctx), duk__valsz); \
2139 DUK_MEMCPY((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \
2140 (bw_ctx)->p += duk__valsz; \
2141 } while (0)

◆ DUK_BW_WRITE_ENSURE_CESU8

#define DUK_BW_WRITE_ENSURE_CESU8 ( thr,
bw_ctx,
cp )
Value:
do { \
DUK_BW_ENSURE((thr), (bw_ctx), DUK_UNICODE_MAX_CESU8_LENGTH); \
DUK_BW_WRITE_RAW_CESU8((thr), (bw_ctx), (cp)); \
} while (0)
#define DUK_UNICODE_MAX_CESU8_LENGTH

Definition at line 2128 of file duktape-1.8.0/src/duktape.c.

2128#define DUK_BW_WRITE_ENSURE_CESU8(thr,bw_ctx,cp) do { \
2129 DUK_BW_ENSURE((thr), (bw_ctx), DUK_UNICODE_MAX_CESU8_LENGTH); \
2130 DUK_BW_WRITE_RAW_CESU8((thr), (bw_ctx), (cp)); \
2131 } while (0)

◆ DUK_BW_WRITE_ENSURE_CSTRING

#define DUK_BW_WRITE_ENSURE_CSTRING ( thr,
bw_ctx,
val )
Value:
do { \
const duk_uint8_t *duk__val; \
duk_size_t duk__val_len; \
duk__val = (const duk_uint8_t *) (val); \
duk__val_len = DUK_STRLEN((const char *) duk__val); \
DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \
DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \
(bw_ctx)->p += duk__val_len; \
} while (0)

Definition at line 2142 of file duktape-1.8.0/src/duktape.c.

2142#define DUK_BW_WRITE_ENSURE_CSTRING(thr,bw_ctx,val) do { \
2143 const duk_uint8_t *duk__val; \
2144 duk_size_t duk__val_len; \
2145 duk__val = (const duk_uint8_t *) (val); \
2146 duk__val_len = DUK_STRLEN((const char *) duk__val); \
2147 DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \
2148 DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \
2149 (bw_ctx)->p += duk__val_len; \
2150 } while (0)

Referenced by duk__unemit_1().

◆ DUK_BW_WRITE_ENSURE_HBUFFER

#define DUK_BW_WRITE_ENSURE_HBUFFER ( thr,
bw_ctx,
val )
Value:
do { \
duk_size_t duk__val_len; \
duk__val_len = DUK_HBUFFER_GET_SIZE((val)); \
DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \
DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \
(bw_ctx)->p += duk__val_len; \
} while (0)
#define DUK_HBUFFER_GET_DATA_PTR(heap, x)
#define DUK_HBUFFER_GET_SIZE(x)

Definition at line 2158 of file duktape-1.8.0/src/duktape.c.

2158#define DUK_BW_WRITE_ENSURE_HBUFFER(thr,bw_ctx,val) do { \
2159 duk_size_t duk__val_len; \
2160 duk__val_len = DUK_HBUFFER_GET_SIZE((val)); \
2161 DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \
2162 DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \
2163 (bw_ctx)->p += duk__val_len; \
2164 } while (0)

◆ DUK_BW_WRITE_ENSURE_HBUFFER_DYNAMIC

#define DUK_BW_WRITE_ENSURE_HBUFFER_DYNAMIC ( thr,
bw_ctx,
val )
Value:
do { \
duk_size_t duk__val_len; \
duk__val_len = DUK_HBUFFER_DYNAMIC_GET_SIZE((val)); \
DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \
DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \
(bw_ctx)->p += duk__val_len; \
} while (0)
#define DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(heap, x)

Definition at line 2172 of file duktape-1.8.0/src/duktape.c.

2172#define DUK_BW_WRITE_ENSURE_HBUFFER_DYNAMIC(thr,bw_ctx,val) do { \
2173 duk_size_t duk__val_len; \
2174 duk__val_len = DUK_HBUFFER_DYNAMIC_GET_SIZE((val)); \
2175 DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \
2176 DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \
2177 (bw_ctx)->p += duk__val_len; \
2178 } while (0)

◆ DUK_BW_WRITE_ENSURE_HBUFFER_FIXED

#define DUK_BW_WRITE_ENSURE_HBUFFER_FIXED ( thr,
bw_ctx,
val )
Value:
do { \
duk_size_t duk__val_len; \
duk__val_len = DUK_HBUFFER_FIXED_GET_SIZE((val)); \
DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \
DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \
(bw_ctx)->p += duk__val_len; \
} while (0)
#define DUK_HBUFFER_FIXED_GET_SIZE(x)
#define DUK_HBUFFER_FIXED_GET_DATA_PTR(heap, x)

Definition at line 2165 of file duktape-1.8.0/src/duktape.c.

2165#define DUK_BW_WRITE_ENSURE_HBUFFER_FIXED(thr,bw_ctx,val) do { \
2166 duk_size_t duk__val_len; \
2167 duk__val_len = DUK_HBUFFER_FIXED_GET_SIZE((val)); \
2168 DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \
2169 DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \
2170 (bw_ctx)->p += duk__val_len; \
2171 } while (0)

◆ DUK_BW_WRITE_ENSURE_HSTRING

#define DUK_BW_WRITE_ENSURE_HSTRING ( thr,
bw_ctx,
val )
Value:
do { \
duk_size_t duk__val_len; \
duk__val_len = DUK_HSTRING_GET_BYTELEN((val)); \
DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \
DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \
(bw_ctx)->p += duk__val_len; \
} while (0)
#define DUK_HSTRING_GET_DATA(x)
#define DUK_HSTRING_GET_BYTELEN(x)

Definition at line 2151 of file duktape-1.8.0/src/duktape.c.

2151#define DUK_BW_WRITE_ENSURE_HSTRING(thr,bw_ctx,val) do { \
2152 duk_size_t duk__val_len; \
2153 duk__val_len = DUK_HSTRING_GET_BYTELEN((val)); \
2154 DUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \
2155 DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \
2156 (bw_ctx)->p += duk__val_len; \
2157 } while (0)

◆ DUK_BW_WRITE_ENSURE_SLICE

#define DUK_BW_WRITE_ENSURE_SLICE ( thr,
bw,
dst_off,
dst_len )    duk_bw_write_ensure_slice((thr), (bw), (dst_off), (dst_len))

Definition at line 2180 of file duktape-1.8.0/src/duktape.c.

2180#define DUK_BW_WRITE_ENSURE_SLICE(thr,bw,dst_off,dst_len) \
2181 duk_bw_write_ensure_slice((thr), (bw), (dst_off), (dst_len))

◆ DUK_BW_WRITE_ENSURE_U8

#define DUK_BW_WRITE_ENSURE_U8 ( thr,
bw_ctx,
val )
Value:
do { \
DUK_BW_ENSURE((thr), (bw_ctx), 1); \
DUK_BW_WRITE_RAW_U8((thr), (bw_ctx), (val)); \
} while (0)

Definition at line 2100 of file duktape-1.8.0/src/duktape.c.

2100#define DUK_BW_WRITE_ENSURE_U8(thr,bw_ctx,val) do { \
2101 DUK_BW_ENSURE((thr), (bw_ctx), 1); \
2102 DUK_BW_WRITE_RAW_U8((thr), (bw_ctx), (val)); \
2103 } while (0)

◆ DUK_BW_WRITE_ENSURE_U8_2

#define DUK_BW_WRITE_ENSURE_U8_2 ( thr,
bw_ctx,
val1,
val2 )
Value:
do { \
DUK_BW_ENSURE((thr), (bw_ctx), 2); \
DUK_BW_WRITE_RAW_U8_2((thr), (bw_ctx), (val1), (val2)); \
} while (0)

Definition at line 2104 of file duktape-1.8.0/src/duktape.c.

2104#define DUK_BW_WRITE_ENSURE_U8_2(thr,bw_ctx,val1,val2) do { \
2105 DUK_BW_ENSURE((thr), (bw_ctx), 2); \
2106 DUK_BW_WRITE_RAW_U8_2((thr), (bw_ctx), (val1), (val2)); \
2107 } while (0)

◆ DUK_BW_WRITE_ENSURE_U8_3

#define DUK_BW_WRITE_ENSURE_U8_3 ( thr,
bw_ctx,
val1,
val2,
val3 )
Value:
do { \
DUK_BW_ENSURE((thr), (bw_ctx), 3); \
DUK_BW_WRITE_RAW_U8_3((thr), (bw_ctx), (val1), (val2), (val3)); \
} while (0)

Definition at line 2108 of file duktape-1.8.0/src/duktape.c.

2108#define DUK_BW_WRITE_ENSURE_U8_3(thr,bw_ctx,val1,val2,val3) do { \
2109 DUK_BW_ENSURE((thr), (bw_ctx), 3); \
2110 DUK_BW_WRITE_RAW_U8_3((thr), (bw_ctx), (val1), (val2), (val3)); \
2111 } while (0)

◆ DUK_BW_WRITE_ENSURE_U8_4

#define DUK_BW_WRITE_ENSURE_U8_4 ( thr,
bw_ctx,
val1,
val2,
val3,
val4 )
Value:
do { \
DUK_BW_ENSURE((thr), (bw_ctx), 4); \
DUK_BW_WRITE_RAW_U8_4((thr), (bw_ctx), (val1), (val2), (val3), (val4)); \
} while (0)

Definition at line 2112 of file duktape-1.8.0/src/duktape.c.

2112#define DUK_BW_WRITE_ENSURE_U8_4(thr,bw_ctx,val1,val2,val3,val4) do { \
2113 DUK_BW_ENSURE((thr), (bw_ctx), 4); \
2114 DUK_BW_WRITE_RAW_U8_4((thr), (bw_ctx), (val1), (val2), (val3), (val4)); \
2115 } while (0)

◆ DUK_BW_WRITE_ENSURE_U8_5

#define DUK_BW_WRITE_ENSURE_U8_5 ( thr,
bw_ctx,
val1,
val2,
val3,
val4,
val5 )
Value:
do { \
DUK_BW_ENSURE((thr), (bw_ctx), 5); \
DUK_BW_WRITE_RAW_U8_5((thr), (bw_ctx), (val1), (val2), (val3), (val4), (val5)); \
} while (0)

Definition at line 2116 of file duktape-1.8.0/src/duktape.c.

2116#define DUK_BW_WRITE_ENSURE_U8_5(thr,bw_ctx,val1,val2,val3,val4,val5) do { \
2117 DUK_BW_ENSURE((thr), (bw_ctx), 5); \
2118 DUK_BW_WRITE_RAW_U8_5((thr), (bw_ctx), (val1), (val2), (val3), (val4), (val5)); \
2119 } while (0)

◆ DUK_BW_WRITE_ENSURE_U8_6

#define DUK_BW_WRITE_ENSURE_U8_6 ( thr,
bw_ctx,
val1,
val2,
val3,
val4,
val5,
val6 )
Value:
do { \
DUK_BW_ENSURE((thr), (bw_ctx), 6); \
DUK_BW_WRITE_RAW_U8_6((thr), (bw_ctx), (val1), (val2), (val3), (val4), (val5), (val6)); \
} while (0)

Definition at line 2120 of file duktape-1.8.0/src/duktape.c.

2120#define DUK_BW_WRITE_ENSURE_U8_6(thr,bw_ctx,val1,val2,val3,val4,val5,val6) do { \
2121 DUK_BW_ENSURE((thr), (bw_ctx), 6); \
2122 DUK_BW_WRITE_RAW_U8_6((thr), (bw_ctx), (val1), (val2), (val3), (val4), (val5), (val6)); \
2123 } while (0)

◆ DUK_BW_WRITE_ENSURE_XUTF8

#define DUK_BW_WRITE_ENSURE_XUTF8 ( thr,
bw_ctx,
cp )
Value:
do { \
DUK_BW_ENSURE((thr), (bw_ctx), DUK_UNICODE_MAX_XUTF8_LENGTH); \
DUK_BW_WRITE_RAW_XUTF8((thr), (bw_ctx), (cp)); \
} while (0)
#define DUK_UNICODE_MAX_XUTF8_LENGTH

Definition at line 2124 of file duktape-1.8.0/src/duktape.c.

2124#define DUK_BW_WRITE_ENSURE_XUTF8(thr,bw_ctx,cp) do { \
2125 DUK_BW_ENSURE((thr), (bw_ctx), DUK_UNICODE_MAX_XUTF8_LENGTH); \
2126 DUK_BW_WRITE_RAW_XUTF8((thr), (bw_ctx), (cp)); \
2127 } while (0)

◆ DUK_BW_WRITE_RAW_BYTES

#define DUK_BW_WRITE_RAW_BYTES ( thr,
bw_ctx,
valptr,
valsz )
Value:
do { \
const void *duk__valptr; \
duk_size_t duk__valsz; \
duk__valptr = (const void *) (valptr); \
duk__valsz = (duk_size_t) (valsz); \
DUK_MEMCPY((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \
(bw_ctx)->p += duk__valsz; \
} while (0)

Definition at line 2032 of file duktape-1.8.0/src/duktape.c.

2032#define DUK_BW_WRITE_RAW_BYTES(thr,bw_ctx,valptr,valsz) do { \
2033 const void *duk__valptr; \
2034 duk_size_t duk__valsz; \
2035 duk__valptr = (const void *) (valptr); \
2036 duk__valsz = (duk_size_t) (valsz); \
2037 DUK_MEMCPY((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \
2038 (bw_ctx)->p += duk__valsz; \
2039 } while (0)

◆ DUK_BW_WRITE_RAW_CESU8

#define DUK_BW_WRITE_RAW_CESU8 ( thr,
bw_ctx,
cp )
Value:
do { \
duk_ucodepoint_t duk__cp; \
duk_small_int_t duk__enc_len; \
duk__cp = (duk_ucodepoint_t) (cp); \
DUK_BW_ASSERT_SPACE((thr), (bw_ctx), duk_unicode_get_cesu8_length(duk__cp)); \
duk__enc_len = duk_unicode_encode_cesu8(duk__cp, (bw_ctx)->p); \
(bw_ctx)->p += duk__enc_len; \
} while (0)
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_encode_cesu8(duk_ucodepoint_t cp, duk_uint8_t *out)

Definition at line 2023 of file duktape-1.8.0/src/duktape.c.

2023#define DUK_BW_WRITE_RAW_CESU8(thr,bw_ctx,cp) do { \
2024 duk_ucodepoint_t duk__cp; \
2025 duk_small_int_t duk__enc_len; \
2026 duk__cp = (duk_ucodepoint_t) (cp); \
2027 DUK_BW_ASSERT_SPACE((thr), (bw_ctx), duk_unicode_get_cesu8_length(duk__cp)); \
2028 duk__enc_len = duk_unicode_encode_cesu8(duk__cp, (bw_ctx)->p); \
2029 (bw_ctx)->p += duk__enc_len; \
2030 } while (0)

◆ DUK_BW_WRITE_RAW_CSTRING

#define DUK_BW_WRITE_RAW_CSTRING ( thr,
bw_ctx,
val )
Value:
do { \
const duk_uint8_t *duk__val; \
duk_size_t duk__val_len; \
duk__val = (const duk_uint8_t *) (val); \
duk__val_len = DUK_STRLEN((const char *) duk__val); \
DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \
(bw_ctx)->p += duk__val_len; \
} while (0)

Definition at line 2040 of file duktape-1.8.0/src/duktape.c.

2040#define DUK_BW_WRITE_RAW_CSTRING(thr,bw_ctx,val) do { \
2041 const duk_uint8_t *duk__val; \
2042 duk_size_t duk__val_len; \
2043 duk__val = (const duk_uint8_t *) (val); \
2044 duk__val_len = DUK_STRLEN((const char *) duk__val); \
2045 DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \
2046 (bw_ctx)->p += duk__val_len; \
2047 } while (0)

◆ DUK_BW_WRITE_RAW_HBUFFER

#define DUK_BW_WRITE_RAW_HBUFFER ( thr,
bw_ctx,
val )
Value:
do { \
duk_size_t duk__val_len; \
duk__val_len = DUK_HBUFFER_GET_SIZE((val)); \
DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \
(bw_ctx)->p += duk__val_len; \
} while (0)

Definition at line 2054 of file duktape-1.8.0/src/duktape.c.

2054#define DUK_BW_WRITE_RAW_HBUFFER(thr,bw_ctx,val) do { \
2055 duk_size_t duk__val_len; \
2056 duk__val_len = DUK_HBUFFER_GET_SIZE((val)); \
2057 DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \
2058 (bw_ctx)->p += duk__val_len; \
2059 } while (0)

◆ DUK_BW_WRITE_RAW_HBUFFER_DYNAMIC

#define DUK_BW_WRITE_RAW_HBUFFER_DYNAMIC ( thr,
bw_ctx,
val )
Value:
do { \
duk_size_t duk__val_len; \
duk__val_len = DUK_HBUFFER_DYNAMIC_GET_SIZE((val)); \
DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \
(bw_ctx)->p += duk__val_len; \
} while (0)

Definition at line 2066 of file duktape-1.8.0/src/duktape.c.

2066#define DUK_BW_WRITE_RAW_HBUFFER_DYNAMIC(thr,bw_ctx,val) do { \
2067 duk_size_t duk__val_len; \
2068 duk__val_len = DUK_HBUFFER_DYNAMIC_GET_SIZE((val)); \
2069 DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \
2070 (bw_ctx)->p += duk__val_len; \
2071 } while (0)

◆ DUK_BW_WRITE_RAW_HBUFFER_FIXED

#define DUK_BW_WRITE_RAW_HBUFFER_FIXED ( thr,
bw_ctx,
val )
Value:
do { \
duk_size_t duk__val_len; \
duk__val_len = DUK_HBUFFER_FIXED_GET_SIZE((val)); \
DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \
(bw_ctx)->p += duk__val_len; \
} while (0)

Definition at line 2060 of file duktape-1.8.0/src/duktape.c.

2060#define DUK_BW_WRITE_RAW_HBUFFER_FIXED(thr,bw_ctx,val) do { \
2061 duk_size_t duk__val_len; \
2062 duk__val_len = DUK_HBUFFER_FIXED_GET_SIZE((val)); \
2063 DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \
2064 (bw_ctx)->p += duk__val_len; \
2065 } while (0)

◆ DUK_BW_WRITE_RAW_HSTRING

#define DUK_BW_WRITE_RAW_HSTRING ( thr,
bw_ctx,
val )
Value:
do { \
duk_size_t duk__val_len; \
duk__val_len = DUK_HSTRING_GET_BYTELEN((val)); \
DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \
(bw_ctx)->p += duk__val_len; \
} while (0)

Definition at line 2048 of file duktape-1.8.0/src/duktape.c.

2048#define DUK_BW_WRITE_RAW_HSTRING(thr,bw_ctx,val) do { \
2049 duk_size_t duk__val_len; \
2050 duk__val_len = DUK_HSTRING_GET_BYTELEN((val)); \
2051 DUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \
2052 (bw_ctx)->p += duk__val_len; \
2053 } while (0)

◆ DUK_BW_WRITE_RAW_SLICE

#define DUK_BW_WRITE_RAW_SLICE ( thr,
bw,
dst_off,
dst_len )    duk_bw_write_raw_slice((thr), (bw), (dst_off), (dst_len))

Definition at line 2074 of file duktape-1.8.0/src/duktape.c.

2074#define DUK_BW_WRITE_RAW_SLICE(thr,bw,dst_off,dst_len) \
2075 duk_bw_write_raw_slice((thr), (bw), (dst_off), (dst_len))

◆ DUK_BW_WRITE_RAW_U8

#define DUK_BW_WRITE_RAW_U8 ( thr,
bw_ctx,
val )
Value:
do { \
DUK_BW_ASSERT_SPACE((thr), (bw_ctx), 1); \
*(bw_ctx)->p++ = (duk_uint8_t) (val); \
} while (0)

Definition at line 1961 of file duktape-1.8.0/src/duktape.c.

1961#define DUK_BW_WRITE_RAW_U8(thr,bw_ctx,val) do { \
1962 DUK_BW_ASSERT_SPACE((thr), (bw_ctx), 1); \
1963 *(bw_ctx)->p++ = (duk_uint8_t) (val); \
1964 } while (0)

◆ DUK_BW_WRITE_RAW_U8_2

#define DUK_BW_WRITE_RAW_U8_2 ( thr,
bw_ctx,
val1,
val2 )
Value:
do { \
duk_uint8_t *duk__p; \
DUK_BW_ASSERT_SPACE((thr), (bw_ctx), 2); \
duk__p = (bw_ctx)->p; \
*duk__p++ = (duk_uint8_t) (val1); \
*duk__p++ = (duk_uint8_t) (val2); \
(bw_ctx)->p = duk__p; \
} while (0)

Definition at line 1965 of file duktape-1.8.0/src/duktape.c.

1965#define DUK_BW_WRITE_RAW_U8_2(thr,bw_ctx,val1,val2) do { \
1966 duk_uint8_t *duk__p; \
1967 DUK_BW_ASSERT_SPACE((thr), (bw_ctx), 2); \
1968 duk__p = (bw_ctx)->p; \
1969 *duk__p++ = (duk_uint8_t) (val1); \
1970 *duk__p++ = (duk_uint8_t) (val2); \
1971 (bw_ctx)->p = duk__p; \
1972 } while (0)

◆ DUK_BW_WRITE_RAW_U8_3

#define DUK_BW_WRITE_RAW_U8_3 ( thr,
bw_ctx,
val1,
val2,
val3 )
Value:
do { \
duk_uint8_t *duk__p; \
DUK_BW_ASSERT_SPACE((thr), (bw_ctx), 3); \
duk__p = (bw_ctx)->p; \
*duk__p++ = (duk_uint8_t) (val1); \
*duk__p++ = (duk_uint8_t) (val2); \
*duk__p++ = (duk_uint8_t) (val3); \
(bw_ctx)->p = duk__p; \
} while (0)

Definition at line 1973 of file duktape-1.8.0/src/duktape.c.

1973#define DUK_BW_WRITE_RAW_U8_3(thr,bw_ctx,val1,val2,val3) do { \
1974 duk_uint8_t *duk__p; \
1975 DUK_BW_ASSERT_SPACE((thr), (bw_ctx), 3); \
1976 duk__p = (bw_ctx)->p; \
1977 *duk__p++ = (duk_uint8_t) (val1); \
1978 *duk__p++ = (duk_uint8_t) (val2); \
1979 *duk__p++ = (duk_uint8_t) (val3); \
1980 (bw_ctx)->p = duk__p; \
1981 } while (0)

◆ DUK_BW_WRITE_RAW_U8_4

#define DUK_BW_WRITE_RAW_U8_4 ( thr,
bw_ctx,
val1,
val2,
val3,
val4 )
Value:
do { \
duk_uint8_t *duk__p; \
DUK_BW_ASSERT_SPACE((thr), (bw_ctx), 4); \
duk__p = (bw_ctx)->p; \
*duk__p++ = (duk_uint8_t) (val1); \
*duk__p++ = (duk_uint8_t) (val2); \
*duk__p++ = (duk_uint8_t) (val3); \
*duk__p++ = (duk_uint8_t) (val4); \
(bw_ctx)->p = duk__p; \
} while (0)

Definition at line 1982 of file duktape-1.8.0/src/duktape.c.

1982#define DUK_BW_WRITE_RAW_U8_4(thr,bw_ctx,val1,val2,val3,val4) do { \
1983 duk_uint8_t *duk__p; \
1984 DUK_BW_ASSERT_SPACE((thr), (bw_ctx), 4); \
1985 duk__p = (bw_ctx)->p; \
1986 *duk__p++ = (duk_uint8_t) (val1); \
1987 *duk__p++ = (duk_uint8_t) (val2); \
1988 *duk__p++ = (duk_uint8_t) (val3); \
1989 *duk__p++ = (duk_uint8_t) (val4); \
1990 (bw_ctx)->p = duk__p; \
1991 } while (0)

◆ DUK_BW_WRITE_RAW_U8_5

#define DUK_BW_WRITE_RAW_U8_5 ( thr,
bw_ctx,
val1,
val2,
val3,
val4,
val5 )
Value:
do { \
duk_uint8_t *duk__p; \
DUK_BW_ASSERT_SPACE((thr), (bw_ctx), 5); \
duk__p = (bw_ctx)->p; \
*duk__p++ = (duk_uint8_t) (val1); \
*duk__p++ = (duk_uint8_t) (val2); \
*duk__p++ = (duk_uint8_t) (val3); \
*duk__p++ = (duk_uint8_t) (val4); \
*duk__p++ = (duk_uint8_t) (val5); \
(bw_ctx)->p = duk__p; \
} while (0)

Definition at line 1992 of file duktape-1.8.0/src/duktape.c.

1992#define DUK_BW_WRITE_RAW_U8_5(thr,bw_ctx,val1,val2,val3,val4,val5) do { \
1993 duk_uint8_t *duk__p; \
1994 DUK_BW_ASSERT_SPACE((thr), (bw_ctx), 5); \
1995 duk__p = (bw_ctx)->p; \
1996 *duk__p++ = (duk_uint8_t) (val1); \
1997 *duk__p++ = (duk_uint8_t) (val2); \
1998 *duk__p++ = (duk_uint8_t) (val3); \
1999 *duk__p++ = (duk_uint8_t) (val4); \
2000 *duk__p++ = (duk_uint8_t) (val5); \
2001 (bw_ctx)->p = duk__p; \
2002 } while (0)

◆ DUK_BW_WRITE_RAW_U8_6

#define DUK_BW_WRITE_RAW_U8_6 ( thr,
bw_ctx,
val1,
val2,
val3,
val4,
val5,
val6 )
Value:
do { \
duk_uint8_t *duk__p; \
DUK_BW_ASSERT_SPACE((thr), (bw_ctx), 6); \
duk__p = (bw_ctx)->p; \
*duk__p++ = (duk_uint8_t) (val1); \
*duk__p++ = (duk_uint8_t) (val2); \
*duk__p++ = (duk_uint8_t) (val3); \
*duk__p++ = (duk_uint8_t) (val4); \
*duk__p++ = (duk_uint8_t) (val5); \
*duk__p++ = (duk_uint8_t) (val6); \
(bw_ctx)->p = duk__p; \
} while (0)

Definition at line 2003 of file duktape-1.8.0/src/duktape.c.

2003#define DUK_BW_WRITE_RAW_U8_6(thr,bw_ctx,val1,val2,val3,val4,val5,val6) do { \
2004 duk_uint8_t *duk__p; \
2005 DUK_BW_ASSERT_SPACE((thr), (bw_ctx), 6); \
2006 duk__p = (bw_ctx)->p; \
2007 *duk__p++ = (duk_uint8_t) (val1); \
2008 *duk__p++ = (duk_uint8_t) (val2); \
2009 *duk__p++ = (duk_uint8_t) (val3); \
2010 *duk__p++ = (duk_uint8_t) (val4); \
2011 *duk__p++ = (duk_uint8_t) (val5); \
2012 *duk__p++ = (duk_uint8_t) (val6); \
2013 (bw_ctx)->p = duk__p; \
2014 } while (0)

◆ DUK_BW_WRITE_RAW_XUTF8

#define DUK_BW_WRITE_RAW_XUTF8 ( thr,
bw_ctx,
cp )
Value:
do { \
duk_ucodepoint_t duk__cp; \
duk_small_int_t duk__enc_len; \
duk__cp = (cp); \
DUK_BW_ASSERT_SPACE((thr), (bw_ctx), duk_unicode_get_xutf8_length(duk__cp)); \
duk__enc_len = duk_unicode_encode_xutf8(duk__cp, (bw_ctx)->p); \
(bw_ctx)->p += duk__enc_len; \
} while (0)
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_get_xutf8_length(duk_ucodepoint_t cp)
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_encode_xutf8(duk_ucodepoint_t cp, duk_uint8_t *out)

Definition at line 2015 of file duktape-1.8.0/src/duktape.c.

2015#define DUK_BW_WRITE_RAW_XUTF8(thr,bw_ctx,cp) do { \
2016 duk_ucodepoint_t duk__cp; \
2017 duk_small_int_t duk__enc_len; \
2018 duk__cp = (cp); \
2019 DUK_BW_ASSERT_SPACE((thr), (bw_ctx), duk_unicode_get_xutf8_length(duk__cp)); \
2020 duk__enc_len = duk_unicode_encode_xutf8(duk__cp, (bw_ctx)->p); \
2021 (bw_ctx)->p += duk__enc_len; \
2022 } while (0)

Referenced by duk__case_transform_helper(), duk__slow_case_conversion(), and duk_unicode_case_convert_string().

◆ DUK_CALL_FLAG_CONSTRUCTOR_CALL

#define DUK_CALL_FLAG_CONSTRUCTOR_CALL   (1 << 1) /* duk_handle_call_xxx: constructor call (i.e. called as 'new Foo()') */

Definition at line 8379 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_handle_call_protected().

◆ DUK_CALL_FLAG_DIRECT_EVAL

#define DUK_CALL_FLAG_DIRECT_EVAL   (1 << 4) /* call is a direct eval call */

Definition at line 8382 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CALL_FLAG_IGNORE_RECLIMIT

#define DUK_CALL_FLAG_IGNORE_RECLIMIT   (1 << 0) /* duk_handle_call_xxx: call ignores C recursion limit (for errhandler calls) */

◆ DUK_CALL_FLAG_IS_RESUME

#define DUK_CALL_FLAG_IS_RESUME   (1 << 2) /* duk_handle_ecma_call_setup: setup for a resume() */

Definition at line 8380 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_handle_ecma_call_setup().

◆ DUK_CALL_FLAG_IS_TAILCALL

#define DUK_CALL_FLAG_IS_TAILCALL   (1 << 3) /* duk_handle_ecma_call_setup: setup for a tail call */

Definition at line 8381 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_handle_ecma_call_setup().

◆ DUK_CALLSTACK_DEFAULT_MAX

#define DUK_CALLSTACK_DEFAULT_MAX   10000L

Definition at line 6002 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_err_create_and_throw().

◆ DUK_CALLSTACK_GROW_STEP

#define DUK_CALLSTACK_GROW_STEP   8 /* roughly 256 bytes */

◆ DUK_CALLSTACK_INITIAL_SIZE

#define DUK_CALLSTACK_INITIAL_SIZE   8

Definition at line 6001 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CALLSTACK_SHRINK_SPARE

#define DUK_CALLSTACK_SHRINK_SPARE   8 /* roughly 256 bytes */

Definition at line 6000 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CALLSTACK_SHRINK_THRESHOLD

#define DUK_CALLSTACK_SHRINK_THRESHOLD   16 /* roughly 512 bytes */

Definition at line 5999 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CAT_CLEAR_CATCH_BINDING_ENABLED

#define DUK_CAT_CLEAR_CATCH_BINDING_ENABLED ( c)
Value:
do { \
} while (0)
#define DUK_CAT_FLAG_CATCH_BINDING_ENABLED

Definition at line 6076 of file duktape-1.8.0/src/duktape.c.

6076 } while (0)
6077
6078#define DUK_CAT_CLEAR_CATCH_ENABLED(c) do { \

◆ DUK_CAT_CLEAR_CATCH_ENABLED

#define DUK_CAT_CLEAR_CATCH_ENABLED ( c)
Value:
do { \
(c)->flags &= ~DUK_CAT_FLAG_CATCH_ENABLED; \
} while (0)
#define DUK_CAT_FLAG_CATCH_ENABLED

Definition at line 6070 of file duktape-1.8.0/src/duktape.c.

6070 } while (0)
6071#define DUK_CAT_SET_CATCH_BINDING_ENABLED(c) do { \
6072 (c)->flags |= DUK_CAT_FLAG_CATCH_BINDING_ENABLED; \

◆ DUK_CAT_CLEAR_FINALLY_ENABLED

#define DUK_CAT_CLEAR_FINALLY_ENABLED ( c)
Value:
do { \
(c)->flags &= ~DUK_CAT_FLAG_FINALLY_ENABLED; \
} while (0)
#define DUK_CAT_FLAG_FINALLY_ENABLED

Definition at line 6073 of file duktape-1.8.0/src/duktape.c.

6073 } while (0)
6074#define DUK_CAT_SET_LEXENV_ACTIVE(c) do { \
6075 (c)->flags |= DUK_CAT_FLAG_LEXENV_ACTIVE; \

◆ DUK_CAT_CLEAR_LEXENV_ACTIVE

#define DUK_CAT_CLEAR_LEXENV_ACTIVE ( c)
Value:
do { \
(c)->flags &= ~DUK_CAT_FLAG_LEXENV_ACTIVE; \
} while (0)
#define DUK_CAT_FLAG_LEXENV_ACTIVE

Definition at line 6079 of file duktape-1.8.0/src/duktape.c.

6079 (c)->flags &= ~DUK_CAT_FLAG_CATCH_ENABLED; \
6080 } while (0)
6081#define DUK_CAT_CLEAR_FINALLY_ENABLED(c) do { \

◆ DUK_CAT_FLAG_CATCH_BINDING_ENABLED

#define DUK_CAT_FLAG_CATCH_BINDING_ENABLED   (1 << 6) /* request to create catch binding */

Definition at line 6042 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CAT_FLAG_CATCH_ENABLED

#define DUK_CAT_FLAG_CATCH_ENABLED   (1 << 4) /* catch part will catch */

Definition at line 6040 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CAT_FLAG_FINALLY_ENABLED

#define DUK_CAT_FLAG_FINALLY_ENABLED   (1 << 5) /* finally part will catch */

Definition at line 6041 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CAT_FLAG_LEXENV_ACTIVE

#define DUK_CAT_FLAG_LEXENV_ACTIVE   (1 << 7) /* catch or with binding is currently active */

Definition at line 6043 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CAT_GET_LABEL

#define DUK_CAT_GET_LABEL ( c)    (((c)->flags & DUK_CAT_LABEL_MASK) >> DUK_CAT_LABEL_SHIFT)

Definition at line 6050 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CAT_GET_TYPE

#define DUK_CAT_GET_TYPE ( c)    ((c)->flags & DUK_CAT_TYPE_MASK)

Definition at line 6049 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_handle_ecma_call_setup().

◆ DUK_CAT_HAS_CATCH_BINDING_ENABLED

#define DUK_CAT_HAS_CATCH_BINDING_ENABLED ( c)    ((c)->flags & DUK_CAT_FLAG_CATCH_BINDING_ENABLED)

Definition at line 6054 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CAT_HAS_CATCH_ENABLED

#define DUK_CAT_HAS_CATCH_ENABLED ( c)    ((c)->flags & DUK_CAT_FLAG_CATCH_ENABLED)

Definition at line 6052 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_error_prototype_from_code().

◆ DUK_CAT_HAS_FINALLY_ENABLED

#define DUK_CAT_HAS_FINALLY_ENABLED ( c)    ((c)->flags & DUK_CAT_FLAG_FINALLY_ENABLED)

Definition at line 6053 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CAT_HAS_LEXENV_ACTIVE

#define DUK_CAT_HAS_LEXENV_ACTIVE ( c)    ((c)->flags & DUK_CAT_FLAG_LEXENV_ACTIVE)

Definition at line 6055 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CAT_LABEL_BITS

#define DUK_CAT_LABEL_BITS   24

Definition at line 6037 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CAT_LABEL_MASK

#define DUK_CAT_LABEL_MASK   0xffffff00UL

Definition at line 6036 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CAT_LABEL_SHIFT

#define DUK_CAT_LABEL_SHIFT   8

Definition at line 6038 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CAT_SET_CATCH_BINDING_ENABLED

#define DUK_CAT_SET_CATCH_BINDING_ENABLED ( c)
Value:
do { \
} while (0)

Definition at line 6063 of file duktape-1.8.0/src/duktape.c.

6063#define DUK_CAT_HAS_LEXENV_ACTIVE(c) ((c)->flags & DUK_CAT_FLAG_LEXENV_ACTIVE)
6064
6065#define DUK_CAT_SET_CATCH_ENABLED(c) do { \

◆ DUK_CAT_SET_CATCH_ENABLED

#define DUK_CAT_SET_CATCH_ENABLED ( c)
Value:
do { \
(c)->flags |= DUK_CAT_FLAG_CATCH_ENABLED; \
} while (0)

Definition at line 6057 of file duktape-1.8.0/src/duktape.c.

6057#define DUK_CAT_GET_TYPE(c) ((c)->flags & DUK_CAT_TYPE_MASK)
6058#define DUK_CAT_GET_LABEL(c) (((c)->flags & DUK_CAT_LABEL_MASK) >> DUK_CAT_LABEL_SHIFT)
6059

◆ DUK_CAT_SET_FINALLY_ENABLED

#define DUK_CAT_SET_FINALLY_ENABLED ( c)
Value:
do { \
} while (0)

Definition at line 6060 of file duktape-1.8.0/src/duktape.c.

6060#define DUK_CAT_HAS_CATCH_ENABLED(c) ((c)->flags & DUK_CAT_FLAG_CATCH_ENABLED)
6061#define DUK_CAT_HAS_FINALLY_ENABLED(c) ((c)->flags & DUK_CAT_FLAG_FINALLY_ENABLED)
6062#define DUK_CAT_HAS_CATCH_BINDING_ENABLED(c) ((c)->flags & DUK_CAT_FLAG_CATCH_BINDING_ENABLED)

◆ DUK_CAT_SET_LEXENV_ACTIVE

#define DUK_CAT_SET_LEXENV_ACTIVE ( c)
Value:
do { \
(c)->flags |= DUK_CAT_FLAG_LEXENV_ACTIVE; \
} while (0)

Definition at line 6066 of file duktape-1.8.0/src/duktape.c.

6066 (c)->flags |= DUK_CAT_FLAG_CATCH_ENABLED; \
6067 } while (0)
6068#define DUK_CAT_SET_FINALLY_ENABLED(c) do { \

◆ DUK_CAT_TYPE_BITS

#define DUK_CAT_TYPE_BITS   4

Definition at line 6035 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CAT_TYPE_LABEL

#define DUK_CAT_TYPE_LABEL   2

Definition at line 6047 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_handle_ecma_call_setup().

◆ DUK_CAT_TYPE_MASK

#define DUK_CAT_TYPE_MASK   0x0000000fUL

Definition at line 6034 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CAT_TYPE_TCF

#define DUK_CAT_TYPE_TCF   1

Definition at line 6046 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CAT_TYPE_UNKNOWN

#define DUK_CAT_TYPE_UNKNOWN   0

Definition at line 6045 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CATCHSTACK_DEFAULT_MAX

#define DUK_CATCHSTACK_DEFAULT_MAX   10000L

Definition at line 6008 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CATCHSTACK_GROW_STEP

#define DUK_CATCHSTACK_GROW_STEP   4 /* roughly 64 bytes */

Definition at line 6004 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CATCHSTACK_INITIAL_SIZE

#define DUK_CATCHSTACK_INITIAL_SIZE   4

Definition at line 6007 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CATCHSTACK_SHRINK_SPARE

#define DUK_CATCHSTACK_SHRINK_SPARE   4 /* roughly 64 bytes */

Definition at line 6006 of file duktape-1.8.0/src/duktape.c.

◆ DUK_CATCHSTACK_SHRINK_THRESHOLD

#define DUK_CATCHSTACK_SHRINK_THRESHOLD   8 /* roughly 128 bytes */

Definition at line 6005 of file duktape-1.8.0/src/duktape.c.

◆ DUK_COMPARE_FLAG_EVAL_LEFT_FIRST

#define DUK_COMPARE_FLAG_EVAL_LEFT_FIRST   (1 << 0) /* eval left argument first */

Definition at line 8389 of file duktape-1.8.0/src/duktape.c.

◆ DUK_COMPARE_FLAG_NEGATE

#define DUK_COMPARE_FLAG_NEGATE   (1 << 1) /* negate result */

Definition at line 8390 of file duktape-1.8.0/src/duktape.c.

◆ DUK_COMPILER_MAX_BYTECODE_LENGTH

#define DUK_COMPILER_MAX_BYTECODE_LENGTH   (256L * 1024L * 1024L) /* 1 GB */

Definition at line 3170 of file duktape-1.8.0/src/duktape.c.

◆ DUK_COMPILER_PEEPHOLE_MAXITER

#define DUK_COMPILER_PEEPHOLE_MAXITER   3

Definition at line 3167 of file duktape-1.8.0/src/duktape.c.

◆ DUK_COMPILER_TOKEN_LIMIT

#define DUK_COMPILER_TOKEN_LIMIT   100000000L /* 1e8: protects against deeply nested inner functions */

Definition at line 3164 of file duktape-1.8.0/src/duktape.c.

◆ DUK_COMPILING_DUKTAPE

#define DUK_COMPILING_DUKTAPE

Definition at line 139 of file duktape-1.8.0/src/duktape.c.

◆ DUK_D

◆ DUK_DBG_CMD_ADDBREAK

#define DUK_DBG_CMD_ADDBREAK   0x18

Definition at line 7321 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_ALERT

#define DUK_DBG_CMD_ALERT   0x03

Definition at line 7306 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_APPNOTIFY

#define DUK_DBG_CMD_APPNOTIFY   0x07

Definition at line 7310 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_APPREQUEST

#define DUK_DBG_CMD_APPREQUEST   0x22

Definition at line 7331 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_BASICINFO

#define DUK_DBG_CMD_BASICINFO   0x10

Definition at line 7313 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_DELBREAK

#define DUK_DBG_CMD_DELBREAK   0x19

Definition at line 7322 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_DETACH

#define DUK_DBG_CMD_DETACH   0x1f

Definition at line 7328 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_DETACHING

#define DUK_DBG_CMD_DETACHING   0x06

Definition at line 7309 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_DUMPHEAP

#define DUK_DBG_CMD_DUMPHEAP   0x20

Definition at line 7329 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_EVAL

#define DUK_DBG_CMD_EVAL   0x1e

Definition at line 7327 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_GETBYTECODE

#define DUK_DBG_CMD_GETBYTECODE   0x21

Definition at line 7330 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_GETCALLSTACK

#define DUK_DBG_CMD_GETCALLSTACK   0x1c

Definition at line 7325 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_GETHEAPOBJINFO

#define DUK_DBG_CMD_GETHEAPOBJINFO   0x23

Definition at line 7332 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_GETLOCALS

#define DUK_DBG_CMD_GETLOCALS   0x1d

Definition at line 7326 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_GETOBJPROPDESC

#define DUK_DBG_CMD_GETOBJPROPDESC   0x24

Definition at line 7333 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_GETOBJPROPDESCRANGE

#define DUK_DBG_CMD_GETOBJPROPDESCRANGE   0x25

Definition at line 7334 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_GETVAR

#define DUK_DBG_CMD_GETVAR   0x1a

Definition at line 7323 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_LISTBREAK

#define DUK_DBG_CMD_LISTBREAK   0x17

Definition at line 7320 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_LOG

#define DUK_DBG_CMD_LOG   0x04

Definition at line 7307 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_PAUSE

#define DUK_DBG_CMD_PAUSE   0x12

Definition at line 7315 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_PRINT

#define DUK_DBG_CMD_PRINT   0x02

Definition at line 7305 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_PUTVAR

#define DUK_DBG_CMD_PUTVAR   0x1b

Definition at line 7324 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_RESUME

#define DUK_DBG_CMD_RESUME   0x13

Definition at line 7316 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_STATUS

#define DUK_DBG_CMD_STATUS   0x01

Definition at line 7304 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_STEPINTO

#define DUK_DBG_CMD_STEPINTO   0x14

Definition at line 7317 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_STEPOUT

#define DUK_DBG_CMD_STEPOUT   0x16

Definition at line 7319 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_STEPOVER

#define DUK_DBG_CMD_STEPOVER   0x15

Definition at line 7318 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_THROW

#define DUK_DBG_CMD_THROW   0x05

Definition at line 7308 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_CMD_TRIGGERSTATUS

#define DUK_DBG_CMD_TRIGGERSTATUS   0x11

Definition at line 7314 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_ERR_APPLICATION

#define DUK_DBG_ERR_APPLICATION   0x04

Definition at line 7301 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_ERR_NOTFOUND

#define DUK_DBG_ERR_NOTFOUND   0x03

Definition at line 7300 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_ERR_TOOMANY

#define DUK_DBG_ERR_TOOMANY   0x02

Definition at line 7299 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_ERR_UNKNOWN

#define DUK_DBG_ERR_UNKNOWN   0x00

Definition at line 7297 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_ERR_UNSUPPORTED

#define DUK_DBG_ERR_UNSUPPORTED   0x01

Definition at line 7298 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_BUF2

#define DUK_DBG_IB_BUF2   0x14

Definition at line 7281 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_BUF4

#define DUK_DBG_IB_BUF4   0x13

Definition at line 7280 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_EOM

#define DUK_DBG_IB_EOM   0x00

Definition at line 7270 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_ERROR

#define DUK_DBG_IB_ERROR   0x03

Definition at line 7273 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_FALSE

#define DUK_DBG_IB_FALSE   0x19

Definition at line 7286 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_HEAPPTR

#define DUK_DBG_IB_HEAPPTR   0x1e

Definition at line 7291 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_INT4

#define DUK_DBG_IB_INT4   0x10

Definition at line 7277 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_LIGHTFUNC

#define DUK_DBG_IB_LIGHTFUNC   0x1d

Definition at line 7290 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_NOTIFY

#define DUK_DBG_IB_NOTIFY   0x04

Definition at line 7274 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_NULL

#define DUK_DBG_IB_NULL   0x17

Definition at line 7284 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_NUMBER

#define DUK_DBG_IB_NUMBER   0x1a

Definition at line 7287 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_OBJECT

#define DUK_DBG_IB_OBJECT   0x1b

Definition at line 7288 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_POINTER

#define DUK_DBG_IB_POINTER   0x1c

Definition at line 7289 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_REPLY

#define DUK_DBG_IB_REPLY   0x02

Definition at line 7272 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_REQUEST

#define DUK_DBG_IB_REQUEST   0x01

Definition at line 7271 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_STR2

#define DUK_DBG_IB_STR2   0x12

Definition at line 7279 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_STR4

#define DUK_DBG_IB_STR4   0x11

Definition at line 7278 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_TRUE

#define DUK_DBG_IB_TRUE   0x18

Definition at line 7285 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_UNDEFINED

#define DUK_DBG_IB_UNDEFINED   0x16

Definition at line 7283 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_IB_UNUSED

#define DUK_DBG_IB_UNUSED   0x15

Definition at line 7282 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DBG_PROPFLAG_INTERNAL

#define DUK_DBG_PROPFLAG_INTERNAL   (1 << 8)

Definition at line 7339 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DD

◆ DUK_DDD

◆ DUK_DDDPRINT

◆ DUK_DDPRINT

◆ DUK_DEBUG_H_INCLUDED

#define DUK_DEBUG_H_INCLUDED

Definition at line 7432 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DEBUGGER_H_INCLUDED

#define DUK_DEBUGGER_H_INCLUDED

Definition at line 7265 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DEC_A

#define DUK_DEC_A ( x)    (((x) >> 6) & 0xffUL)

Definition at line 2551 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DEC_ABC

#define DUK_DEC_ABC ( x)    (((x) >> 6) & 0x3ffffffUL)

Definition at line 2555 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DEC_B

#define DUK_DEC_B ( x)    (((x) >> 14) & 0x1ffUL)

Definition at line 2552 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DEC_BC

#define DUK_DEC_BC ( x)    (((x) >> 14) & 0x3ffffUL)

Definition at line 2554 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DEC_C

#define DUK_DEC_C ( x)    (((x) >> 23) & 0x1ffUL)

Definition at line 2553 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DEC_OP

#define DUK_DEC_OP ( x)    ((x) & 0x3fUL)

Definition at line 2550 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DECL_TYPE_FUNC

#define DUK_DECL_TYPE_FUNC   1

◆ DUK_DECL_TYPE_VAR

#define DUK_DECL_TYPE_VAR   0

◆ DUK_DELPROP_FLAG_FORCE

#define DUK_DELPROP_FLAG_FORCE   (1 << 1)

Definition at line 5495 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DELPROP_FLAG_THROW

#define DUK_DELPROP_FLAG_THROW   (1 << 0)

Definition at line 5494 of file duktape-1.8.0/src/duktape.c.

◆ DUK_DPRINT

◆ DUK_ENC_OP

#define DUK_ENC_OP ( op)    ((duk_instr_t) (op))

Definition at line 2557 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ENC_OP_A

#define DUK_ENC_OP_A ( op,
a )   DUK_ENC_OP_A_B_C(op,a,0,0)

Definition at line 2574 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ENC_OP_A_B

#define DUK_ENC_OP_A_B ( op,
a,
b )   DUK_ENC_OP_A_B_C(op,a,b,0)

Definition at line 2573 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ENC_OP_A_B_C

#define DUK_ENC_OP_A_B_C ( op,
a,
b,
c )
Value:
((duk_instr_t) ( \
(((duk_instr_t) (c)) << 23) | \
(((duk_instr_t) (b)) << 14) | \
(((duk_instr_t) (a)) << 6) | \
((duk_instr_t) (op)) \
))
duk_uint32_t duk_instr_t
duk_uint32_t duk_instr_t

Definition at line 2567 of file duktape-1.8.0/src/duktape.c.

2567#define DUK_ENC_OP_A_B_C(op,a,b,c) ((duk_instr_t) ( \
2568 (((duk_instr_t) (c)) << 23) | \
2569 (((duk_instr_t) (b)) << 14) | \
2570 (((duk_instr_t) (a)) << 6) | \
2571 ((duk_instr_t) (op)) \
2572 ))

◆ DUK_ENC_OP_A_BC

#define DUK_ENC_OP_A_BC ( op,
a,
bc )
Value:
((duk_instr_t) ( \
(((duk_instr_t) (bc)) << 14) | \
(((duk_instr_t) (a)) << 6) | \
((duk_instr_t) (op)) \
))

Definition at line 2562 of file duktape-1.8.0/src/duktape.c.

2562#define DUK_ENC_OP_A_BC(op,a,bc) ((duk_instr_t) ( \
2563 (((duk_instr_t) (bc)) << 14) | \
2564 (((duk_instr_t) (a)) << 6) | \
2565 ((duk_instr_t) (op)) \
2566 ))

◆ DUK_ENC_OP_ABC

#define DUK_ENC_OP_ABC ( op,
abc )
Value:
((duk_instr_t) ( \
(((duk_instr_t) (abc)) << 6) | \
((duk_instr_t) (op)) \
))

Definition at line 2558 of file duktape-1.8.0/src/duktape.c.

2558#define DUK_ENC_OP_ABC(op,abc) ((duk_instr_t) ( \
2559 (((duk_instr_t) (abc)) << 6) | \
2560 ((duk_instr_t) (op)) \
2561 ))

◆ DUK_EQUALS_FLAG_SAMEVALUE

#define DUK_EQUALS_FLAG_SAMEVALUE   (1 << 0) /* use SameValue instead of non-strict equality */

Definition at line 8385 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EQUALS_FLAG_STRICT

#define DUK_EQUALS_FLAG_STRICT   (1 << 1) /* use strict equality instead of non-strict equality */

Definition at line 8386 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ERRCODE_FLAG_NOBLAME_FILELINE

#define DUK_ERRCODE_FLAG_NOBLAME_FILELINE   (1L << 24)

Definition at line 4238 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_err_create_and_throw().

◆ DUK_ERRMSG_H_INCLUDED

#define DUK_ERRMSG_H_INCLUDED

Definition at line 2285 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ERROR

#define DUK_ERROR ( thr,
err,
msg )
Value:
do { \
duk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) DUK_LINE_MACRO; \
DUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \
duk_err_handle_error((thr), DUK_FILE_MACRO, (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (msg)); \
} while (0)
duk_uint_fast32_t duk_uint_t

Definition at line 7649 of file duktape-1.8.0/src/duktape.c.

7649 * because vararg call sites are larger than normal, and there are a lot
7650 * of call sites with no formatting.
7651 *
7652 * Note that special formatting provided by debug macros is NOT available.
7653 *

Referenced by duk_js_putvar_envrec().

◆ DUK_ERROR_ALLOC

#define DUK_ERROR_ALLOC ( thr,
msg )
Value:
do { \
duk_err_alloc((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (msg)); \
} while (0)

Definition at line 7891 of file duktape-1.8.0/src/duktape.c.

7891#define DUK_ERROR_UNIMPLEMENTED_DEFMSG(thr) do { \
7892 duk_err_unimplemented_defmsg((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO); \
7893 } while (0)

◆ DUK_ERROR_ALLOC_DEFMSG

#define DUK_ERROR_ALLOC_DEFMSG ( thr)
Value:
do { \
DUK_ERROR_ALLOC((thr), DUK_STR_ALLOC_FAILED); \
} while (0)
#define DUK_STR_ALLOC_FAILED

Definition at line 7894 of file duktape-1.8.0/src/duktape.c.

7894#define DUK_ERROR_UNSUPPORTED(thr,msg) do { \
7895 DUK_ERROR((thr), DUK_ERR_UNSUPPORTED_ERROR, (msg)); \
7896 } while (0)

Referenced by duk__realloc_props().

◆ DUK_ERROR_API

#define DUK_ERROR_API ( thr,
msg )
Value:
do { \
duk_err_api((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (msg)); \
} while (0)

Definition at line 7901 of file duktape-1.8.0/src/duktape.c.

7901#endif
7902#define DUK_ERROR_INTERNAL(thr,msg) do { \
7903 duk_err_internal((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (msg)); \

Referenced by duk__pcall_prop_raw(), duk_debugger_pause(), duk_handle_call_protected(), duk_handle_ecma_call_setup(), duk_is_constructor_call(), and duk_push_sprintf().

◆ DUK_ERROR_API_INDEX

#define DUK_ERROR_API_INDEX ( thr,
index )
Value:
do { \
duk_err_api_index((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (index)); \
} while (0)
guint index

Definition at line 7898 of file duktape-1.8.0/src/duktape.c.

7898#define DUK_ERROR_UNSUPPORTED_DEFMSG(thr) do { \
7899 duk_err_unsupported_defmsg((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO); \
7900 } while (0)

Referenced by duk_get_top().

◆ DUK_ERROR_FMT1

#define DUK_ERROR_FMT1 ( thr,
err,
fmt,
arg1 )
Value:
do { \
duk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) DUK_LINE_MACRO; \
DUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \
duk_err_handle_error_fmt((thr), DUK_FILE_MACRO, (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1)); \
} while (0)

Definition at line 7660 of file duktape-1.8.0/src/duktape.c.

7660
7661/* Because there are quite many call sites, pack error code (require at most
7662 * 8-bit) into a single argument.
7663 */
7664#define DUK_ERROR(thr,err,msg) do { \

Referenced by duk__dec_eat_white(), and duk_handle_call_protected().

◆ DUK_ERROR_FMT2

#define DUK_ERROR_FMT2 ( thr,
err,
fmt,
arg1,
arg2 )
Value:
do { \
duk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) DUK_LINE_MACRO; \
DUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \
duk_err_handle_error_fmt((thr), DUK_FILE_MACRO, (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1), (arg2)); \
} while (0)

Definition at line 7671 of file duktape-1.8.0/src/duktape.c.

7671 DUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \
7672 duk_err_handle_error((thr), (file), (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (msg)); \
7673 } while (0)
7674
7675#define DUK_ERROR_FMT1(thr,err,fmt,arg1) do { \

Referenced by duk_hobject_putprop().

◆ DUK_ERROR_FMT3

#define DUK_ERROR_FMT3 ( thr,
err,
fmt,
arg1,
arg2,
arg3 )
Value:
do { \
duk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) DUK_LINE_MACRO; \
DUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \
duk_err_handle_error_fmt((thr), DUK_FILE_MACRO, (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1), (arg2), (arg3)); \
} while (0)

Definition at line 7682 of file duktape-1.8.0/src/duktape.c.

7682 DUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \
7683 duk_err_handle_error_fmt((thr), (file), (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1)); \
7684 } while (0)
7685
7686#define DUK_ERROR_FMT2(thr,err,fmt,arg1,arg2) do { \

◆ DUK_ERROR_FMT4

#define DUK_ERROR_FMT4 ( thr,
err,
fmt,
arg1,
arg2,
arg3,
arg4 )
Value:
do { \
duk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) DUK_LINE_MACRO; \
DUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \
duk_err_handle_error_fmt((thr), DUK_FILE_MACRO, (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1), (arg2), (arg3), (arg4)); \
} while (0)

Definition at line 7693 of file duktape-1.8.0/src/duktape.c.

7693 DUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \
7694 duk_err_handle_error_fmt((thr), (file), (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1), (arg2)); \
7695 } while (0)
7696
7697#define DUK_ERROR_FMT3(thr,err,fmt,arg1,arg2,arg3) do { \

◆ DUK_ERROR_H_INCLUDED

#define DUK_ERROR_H_INCLUDED

Definition at line 7610 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ERROR_INTERNAL

#define DUK_ERROR_INTERNAL ( thr,
msg )
Value:
do { \
duk_err_internal((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (msg)); \
} while (0)

Definition at line 7885 of file duktape-1.8.0/src/duktape.c.

7885 } while (0)
7886#endif /* DUK_USE_PARANOID_ERRORS */
7887

◆ DUK_ERROR_INTERNAL_DEFMSG

#define DUK_ERROR_INTERNAL_DEFMSG ( thr)
Value:
do { \
duk_err_internal_defmsg((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO); \
} while (0)

Definition at line 7888 of file duktape-1.8.0/src/duktape.c.

7888#define DUK_ERROR_UNIMPLEMENTED(thr,msg) do { \
7889 DUK_ERROR((thr), DUK_ERR_UNIMPLEMENTED_ERROR, (msg)); \
7890 } while (0)

Referenced by duk__parse_func_body().

◆ DUK_ERROR_RANGE

#define DUK_ERROR_RANGE ( thr,
msg )
Value:
do { \
duk_err_range((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (msg)); \
} while (0)

Definition at line 7907 of file duktape-1.8.0/src/duktape.c.

7907 } while (0)
7908#define DUK_ERROR_ALLOC(thr,msg) do { \
7909 duk_err_alloc((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (msg)); \

Referenced by duk__get_propdesc(), duk__init_varmap_and_prologue_for_pass2(), duk__parse_disjunction(), duk__settemp_checkmax(), duk_bi_array_constructor(), duk_hbuffer_resize(), duk_hobject_putprop(), duk_hthread_callstack_grow(), duk_js_instanceof(), duk_lexer_parse_js_input_element(), and duk_to_string().

◆ DUK_ERROR_RAW

#define DUK_ERROR_RAW ( thr,
file,
line,
err,
msg )
Value:
do { \
duk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) (line); \
DUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \
duk_err_handle_error((thr), (file), (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (msg)); \
} while (0)

Definition at line 7654 of file duktape-1.8.0/src/duktape.c.

7654 * The _RAW variants allow the caller to specify file and line. This makes
7655 * it easier to write checked calls which want to use the call site of the
7656 * checked function, not the error macro call inside the checked function.
7657 */
7658
static void error(LoadState *S, const char *why)

Referenced by duk_err_alloc(), and duk_err_internal_defmsg().

◆ DUK_ERROR_RAW_FMT1

#define DUK_ERROR_RAW_FMT1 ( thr,
file,
line,
err,
fmt,
arg1 )
Value:
do { \
duk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) (line); \
DUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \
duk_err_handle_error_fmt((thr), (file), (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1)); \
} while (0)

Definition at line 7665 of file duktape-1.8.0/src/duktape.c.

7665 duk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) DUK_LINE_MACRO; \
7666 DUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \
7667 duk_err_handle_error((thr), DUK_FILE_MACRO, (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (msg)); \
7668 } while (0)
7669#define DUK_ERROR_RAW(thr,file,line,err,msg) do { \

Referenced by duk_err_internal().

◆ DUK_ERROR_RAW_FMT2

#define DUK_ERROR_RAW_FMT2 ( thr,
file,
line,
err,
fmt,
arg1,
arg2 )
Value:
do { \
duk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) (line); \
DUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \
duk_err_handle_error_fmt((thr), (file), (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1), (arg2)); \
} while (0)

Definition at line 7676 of file duktape-1.8.0/src/duktape.c.

7676 duk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) DUK_LINE_MACRO; \
7677 DUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \
7678 duk_err_handle_error_fmt((thr), DUK_FILE_MACRO, (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1)); \
7679 } while (0)
7680#define DUK_ERROR_RAW_FMT1(thr,file,line,err,fmt,arg1) do { \

◆ DUK_ERROR_RAW_FMT3

#define DUK_ERROR_RAW_FMT3 ( thr,
file,
line,
err,
fmt,
arg1,
arg2,
arg3 )
Value:
do { \
duk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) (line); \
DUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \
duk_err_handle_error_fmt((thr), (file), (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1), (arg2), (arg3)); \
} while (0)

Definition at line 7687 of file duktape-1.8.0/src/duktape.c.

7687 duk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) DUK_LINE_MACRO; \
7688 DUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \
7689 duk_err_handle_error_fmt((thr), DUK_FILE_MACRO, (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1), (arg2)); \
7690 } while (0)
7691#define DUK_ERROR_RAW_FMT2(thr,file,line,err,fmt,arg1,arg2) do { \

Referenced by duk_err_api().

◆ DUK_ERROR_RAW_FMT4

#define DUK_ERROR_RAW_FMT4 ( thr,
file,
line,
err,
fmt,
arg1,
arg2,
arg3,
arg4 )
Value:
do { \
duk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) (line); \
DUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \
duk_err_handle_error_fmt((thr), (file), (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1), (arg2), (arg3), (arg4)); \
} while (0)

Definition at line 7698 of file duktape-1.8.0/src/duktape.c.

7698 duk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) DUK_LINE_MACRO; \
7699 DUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \
7700 duk_err_handle_error_fmt((thr), DUK_FILE_MACRO, (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1), (arg2), (arg3)); \
7701 } while (0)
7702#define DUK_ERROR_RAW_FMT3(thr,file,line,err,fmt,arg1,arg2,arg3) do { \

◆ DUK_ERROR_REQUIRE_TYPE_INDEX

#define DUK_ERROR_REQUIRE_TYPE_INDEX ( thr,
index,
expectname,
lowmemstr )
Value:
do { \
duk_err_require_type_index((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (index), (expectname)); \
} while (0)

Definition at line 7866 of file duktape-1.8.0/src/duktape.c.

7866 * The goal is to provide verbose and configurable error messages. Call
7867 * sites should be clean in source code and compile to a small footprint.
7868 * Small footprint is also useful for performance because small cold paths

Referenced by duk_get_heapptr(), duk_get_hobject_with_class(), duk_get_number(), duk_normalize_index(), duk_require_hcompiledfunction(), duk_require_hnativefunction(), duk_require_hthread(), and duk_require_null().

◆ DUK_ERROR_SYNTAX

#define DUK_ERROR_SYNTAX ( thr,
msg )
Value:
do { \
DUK_ERROR((thr), DUK_ERR_SYNTAX_ERROR, (msg)); \
} while (0)
#define DUK_ERR_SYNTAX_ERROR

Definition at line 7911 of file duktape-1.8.0/src/duktape.c.

7911#define DUK_ERROR_ALLOC_DEFMSG(thr) do { \
7912 DUK_ERROR_ALLOC((thr), DUK_STR_ALLOC_FAILED); \
7913 } while (0)

Referenced by duk__init_varmap_and_prologue_for_pass2(), duk__parse_disjunction(), duk__parse_func_body(), duk__parse_func_formals(), duk__parse_try_stmt(), and duk_lexer_parse_js_input_element().

◆ DUK_ERROR_TYPE

#define DUK_ERROR_TYPE ( thr,
msg )
Value:
do { \
DUK_ERROR((thr), DUK_ERR_TYPE_ERROR, (msg)); \
} while (0)

Definition at line 7914 of file duktape-1.8.0/src/duktape.c.

7914/* DUK_ERR_ASSERTION_ERROR: no macros needed */
7915#define DUK_ERROR_API_INDEX(thr,index) do { \
7916 duk_err_api_index((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (index)); \

Referenced by duk_hobject_define_property_helper(), duk_hobject_prepare_property_descriptor(), duk_hobject_putprop(), duk_is_null_or_undefined(), and duk_js_instanceof().

◆ DUK_ERROR_UNIMPLEMENTED

#define DUK_ERROR_UNIMPLEMENTED ( thr,
msg )
Value:
do { \
DUK_ERROR((thr), DUK_ERR_UNIMPLEMENTED_ERROR, (msg)); \
} while (0)
#define DUK_ERR_UNIMPLEMENTED_ERROR

Definition at line 7871 of file duktape-1.8.0/src/duktape.c.

7871 */
7872
7873#if defined(DUK_USE_VERBOSE_ERRORS)

◆ DUK_ERROR_UNIMPLEMENTED_DEFMSG

#define DUK_ERROR_UNIMPLEMENTED_DEFMSG ( thr)
Value:
do { \
duk_err_unimplemented_defmsg((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO); \
} while (0)

Definition at line 7874 of file duktape-1.8.0/src/duktape.c.

7874/* Verbose errors with key/value summaries (non-paranoid) or without key/value
7875 * summaries (paranoid, for some security sensitive environments), the paranoid
7876 * vs. non-paranoid distinction affects only a few specific errors.

◆ DUK_ERROR_UNSUPPORTED

#define DUK_ERROR_UNSUPPORTED ( thr,
msg )
Value:
do { \
DUK_ERROR((thr), DUK_ERR_UNSUPPORTED_ERROR, (msg)); \
} while (0)
#define DUK_ERR_UNSUPPORTED_ERROR

Definition at line 7877 of file duktape-1.8.0/src/duktape.c.

7877 */
7878#if defined(DUK_USE_PARANOID_ERRORS)
7879#define DUK_ERROR_REQUIRE_TYPE_INDEX(thr,index,expectname,lowmemstr) do { \

◆ DUK_EXCEPTION_H_INCLUDED

#define DUK_EXCEPTION_H_INCLUDED

Definition at line 224 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_BNOT

#define DUK_EXTRAOP_BNOT   28

Definition at line 2689 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_BREAK

#define DUK_EXTRAOP_BREAK   26

Definition at line 2687 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_CONTINUE

#define DUK_EXTRAOP_CONTINUE   27

Definition at line 2688 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_DEBUGGER

#define DUK_EXTRAOP_DEBUGGER   25

Definition at line 2686 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_ENDCATCH

#define DUK_EXTRAOP_ENDCATCH   19

Definition at line 2680 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_ENDFIN

#define DUK_EXTRAOP_ENDFIN   20

Definition at line 2681 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_ENDLABEL

#define DUK_EXTRAOP_ENDLABEL   33

Definition at line 2694 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_ENDTRY

#define DUK_EXTRAOP_ENDTRY   18

Definition at line 2679 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_IN

#define DUK_EXTRAOP_IN   31

Definition at line 2692 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_INITENUM

#define DUK_EXTRAOP_INITENUM   12

Definition at line 2673 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_INITGET

#define DUK_EXTRAOP_INITGET   16

Definition at line 2677 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_INITGETI

#define DUK_EXTRAOP_INITGETI   17

Definition at line 2678 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_INITSET

#define DUK_EXTRAOP_INITSET   14

Definition at line 2675 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_INITSETI

#define DUK_EXTRAOP_INITSETI   15

Definition at line 2676 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_INSTOF

#define DUK_EXTRAOP_INSTOF   30

Definition at line 2691 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_INVALID

#define DUK_EXTRAOP_INVALID   1

Definition at line 2662 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_INVLHS

#define DUK_EXTRAOP_INVLHS   22

Definition at line 2683 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_LABEL

#define DUK_EXTRAOP_LABEL   32

Definition at line 2693 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_LDFALSE

#define DUK_EXTRAOP_LDFALSE   6

Definition at line 2667 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__ispec_toregconst_raw().

◆ DUK_EXTRAOP_LDNULL

#define DUK_EXTRAOP_LDNULL   4

Definition at line 2665 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__ispec_toregconst_raw().

◆ DUK_EXTRAOP_LDTHIS

#define DUK_EXTRAOP_LDTHIS   2

Definition at line 2663 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_LDTRUE

#define DUK_EXTRAOP_LDTRUE   5

Definition at line 2666 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__ispec_toregconst_raw().

◆ DUK_EXTRAOP_LDUNDEF

#define DUK_EXTRAOP_LDUNDEF   3

◆ DUK_EXTRAOP_LNOT

#define DUK_EXTRAOP_LNOT   29

Definition at line 2690 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_NEWARR

#define DUK_EXTRAOP_NEWARR   8

Definition at line 2669 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_NEWOBJ

#define DUK_EXTRAOP_NEWOBJ   7

Definition at line 2668 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_NEXTENUM

#define DUK_EXTRAOP_NEXTENUM   13

Definition at line 2674 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_NOP

#define DUK_EXTRAOP_NOP   0

Definition at line 2661 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_SETALEN

#define DUK_EXTRAOP_SETALEN   9

Definition at line 2670 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_THROW

#define DUK_EXTRAOP_THROW   21

Definition at line 2682 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_try_stmt().

◆ DUK_EXTRAOP_TYPEOF

#define DUK_EXTRAOP_TYPEOF   10

Definition at line 2671 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_TYPEOFID

#define DUK_EXTRAOP_TYPEOFID   11

Definition at line 2672 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_UNM

#define DUK_EXTRAOP_UNM   23

Definition at line 2684 of file duktape-1.8.0/src/duktape.c.

◆ DUK_EXTRAOP_UNP

#define DUK_EXTRAOP_UNP   24

Definition at line 2685 of file duktape-1.8.0/src/duktape.c.

◆ DUK_FORWDECL_H_INCLUDED

#define DUK_FORWDECL_H_INCLUDED

Definition at line 239 of file duktape-1.8.0/src/duktape.c.

◆ DUK_FREE

#define DUK_FREE ( heap,
ptr )   duk_heap_mem_free((heap), (ptr))

◆ DUK_FREE_RAW

#define DUK_FREE_RAW ( heap,
ptr )    ((heap)->free_func((heap)->heap_udata, (void *) (ptr)))

Definition at line 6857 of file duktape-1.8.0/src/duktape.c.

6857 */
6858

Referenced by duk_alloc().

◆ DUK_GET_HOBJECT_NEGIDX

#define DUK_GET_HOBJECT_NEGIDX ( ctx,
idx )    (DUK_ASSERT_VALID_NEGIDX((ctx),(idx)), DUK_TVAL_GET_OBJECT(((duk_hthread *) (ctx))->valstack_top + (idx)))

Definition at line 4411 of file duktape-1.8.0/src/duktape.c.

4411#define DUK_GET_HOBJECT_NEGIDX(ctx,idx) \
4412 (DUK_ASSERT_VALID_NEGIDX((ctx),(idx)), DUK_TVAL_GET_OBJECT(((duk_hthread *) (ctx))->valstack_top + (idx)))

◆ DUK_GET_HOBJECT_POSIDX

#define DUK_GET_HOBJECT_POSIDX ( ctx,
idx )    (DUK_ASSERT_VALID_POSIDX((ctx),(idx)), DUK_TVAL_GET_OBJECT(((duk_hthread *) (ctx))->valstack_bottom + (idx)))

Definition at line 4413 of file duktape-1.8.0/src/duktape.c.

4413#define DUK_GET_HOBJECT_POSIDX(ctx,idx) \
4414 (DUK_ASSERT_VALID_POSIDX((ctx),(idx)), DUK_TVAL_GET_OBJECT(((duk_hthread *) (ctx))->valstack_bottom + (idx)))

◆ DUK_GET_TVAL_NEGIDX

#define DUK_GET_TVAL_NEGIDX ( ctx,
idx )    (DUK_ASSERT_VALID_NEGIDX((ctx),(idx)), ((duk_hthread *) (ctx))->valstack_top + (idx))

Definition at line 4407 of file duktape-1.8.0/src/duktape.c.

4407#define DUK_GET_TVAL_NEGIDX(ctx,idx) \
4408 (DUK_ASSERT_VALID_NEGIDX((ctx),(idx)), ((duk_hthread *) (ctx))->valstack_top + (idx))

Referenced by duk_hobject_get_length().

◆ DUK_GET_TVAL_POSIDX

#define DUK_GET_TVAL_POSIDX ( ctx,
idx )    (DUK_ASSERT_VALID_POSIDX((ctx),(idx)), ((duk_hthread *) (ctx))->valstack_bottom + (idx))

Definition at line 4409 of file duktape-1.8.0/src/duktape.c.

4409#define DUK_GET_TVAL_POSIDX(ctx,idx) \
4410 (DUK_ASSERT_VALID_POSIDX((ctx),(idx)), ((duk_hthread *) (ctx))->valstack_bottom + (idx))

Referenced by duk__ispec_toregconst_raw().

◆ DUK_GETDESC_FLAG_IGNORE_PROTOLOOP

#define DUK_GETDESC_FLAG_IGNORE_PROTOLOOP   (1 << 1) /* don't throw for prototype loop */

Definition at line 4916 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__get_propdesc().

◆ DUK_GETDESC_FLAG_PUSH_VALUE

#define DUK_GETDESC_FLAG_PUSH_VALUE   (1 << 0) /* push value to stack */

◆ DUK_HBUFFER_ADD_SIZE

#define DUK_HBUFFER_ADD_SIZE ( x,
dv )
Value:
do { \
(x)->size += (dv); \
} while (0)

Definition at line 6425 of file duktape-1.8.0/src/duktape.c.

6425#define DUK_HBUFFER_SUB_SIZE(x,dv) do { \
6426 (x)->hdr.h_flags -= ((dv) << 16); \
6427 } while (0)

◆ DUK_HBUFFER_CLEAR_DYNAMIC

#define DUK_HBUFFER_CLEAR_DYNAMIC ( x)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HBUFFER_FLAG_DYNAMIC)

Definition at line 6376 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFER_CLEAR_EXTERNAL

#define DUK_HBUFFER_CLEAR_EXTERNAL ( x)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HBUFFER_FLAG_EXTERNAL)

Definition at line 6377 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFER_DECREF

#define DUK_HBUFFER_DECREF ( thr,
h )   DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) (h))

Definition at line 3842 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFER_DYNAMIC_ADD_SIZE

#define DUK_HBUFFER_DYNAMIC_ADD_SIZE ( x,
dv )   DUK_HBUFFER_ADD_SIZE((duk_hbuffer *) (x), (dv))

Definition at line 6438 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFER_DYNAMIC_GET_DATA_PTR

#define DUK_HBUFFER_DYNAMIC_GET_DATA_PTR ( heap,
x )   ((x)->curr_alloc)

Definition at line 6456 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bw_init(), and duk_hbuffer_resize().

◆ DUK_HBUFFER_DYNAMIC_GET_SIZE

#define DUK_HBUFFER_DYNAMIC_GET_SIZE ( x)    DUK_HBUFFER_GET_SIZE((duk_hbuffer *) (x))

Definition at line 6436 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__appendbuffer(), and duk_hbuffer_resize().

◆ DUK_HBUFFER_DYNAMIC_SET_DATA_PTR

#define DUK_HBUFFER_DYNAMIC_SET_DATA_PTR ( heap,
x,
v )
Value:
do { \
(x)->curr_alloc = (void *) (v); \
} while (0)

Definition at line 6457 of file duktape-1.8.0/src/duktape.c.

6457#define DUK_HBUFFER_DYNAMIC_SET_DATA_PTR(heap,x,v) do { \
6458 ((duk_heaphdr *) (x))->h_extra16 = DUK_USE_HEAPPTR_ENC16((heap)->heap_udata, (void *) (v)); \
6459 } while (0)

◆ DUK_HBUFFER_DYNAMIC_SET_DATA_PTR_NULL

#define DUK_HBUFFER_DYNAMIC_SET_DATA_PTR_NULL ( heap,
x )
Value:
do { \
(x)->curr_alloc = (void *) NULL; \
} while (0)

Definition at line 6460 of file duktape-1.8.0/src/duktape.c.

6460#define DUK_HBUFFER_DYNAMIC_SET_DATA_PTR_NULL(heap,x) do { \
6461 ((duk_heaphdr *) (x))->h_extra16 = 0; /* assume 0 <=> NULL */ \
6462 } while (0)

◆ DUK_HBUFFER_DYNAMIC_SET_SIZE

#define DUK_HBUFFER_DYNAMIC_SET_SIZE ( x,
v )   DUK_HBUFFER_SET_SIZE((duk_hbuffer *) (x), (v))

Definition at line 6437 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFER_DYNAMIC_SUB_SIZE

#define DUK_HBUFFER_DYNAMIC_SUB_SIZE ( x,
dv )   DUK_HBUFFER_SUB_SIZE((duk_hbuffer *) (x), (dv))

Definition at line 6439 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFER_EXTERNAL_GET_DATA_PTR

#define DUK_HBUFFER_EXTERNAL_GET_DATA_PTR ( heap,
x )    ((void *) (x)->curr_alloc)

Definition at line 6478 of file duktape-1.8.0/src/duktape.c.

6478 ((void *) (x)->curr_alloc)
6479#define DUK_HBUFFER_EXTERNAL_SET_DATA_PTR(heap,x,v) do { \
#define DUK_HBUFFER_EXTERNAL_SET_DATA_PTR(heap, x, v)

◆ DUK_HBUFFER_EXTERNAL_GET_SIZE

#define DUK_HBUFFER_EXTERNAL_GET_SIZE ( x)    DUK_HBUFFER_GET_SIZE((duk_hbuffer *) (x))

Definition at line 6441 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFER_EXTERNAL_SET_DATA_PTR

#define DUK_HBUFFER_EXTERNAL_SET_DATA_PTR ( heap,
x,
v )
Value:
do { \
(x)->curr_alloc = (void *) (v); \
} while (0)

Definition at line 6480 of file duktape-1.8.0/src/duktape.c.

6480 (x)->curr_alloc = (void *) (v); \
6481 } while (0)
6482#define DUK_HBUFFER_EXTERNAL_SET_DATA_PTR_NULL(heap,x) do { \

◆ DUK_HBUFFER_EXTERNAL_SET_DATA_PTR_NULL

#define DUK_HBUFFER_EXTERNAL_SET_DATA_PTR_NULL ( heap,
x )
Value:
do { \
(x)->curr_alloc = (void *) NULL; \
} while (0)

Definition at line 6483 of file duktape-1.8.0/src/duktape.c.

6483 (x)->curr_alloc = (void *) NULL; \
6484 } while (0)
6485#else

◆ DUK_HBUFFER_EXTERNAL_SET_SIZE

#define DUK_HBUFFER_EXTERNAL_SET_SIZE ( x,
v )   DUK_HBUFFER_SET_SIZE((duk_hbuffer *) (x), (v))

Definition at line 6442 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFER_FIXED_GET_DATA_PTR

#define DUK_HBUFFER_FIXED_GET_DATA_PTR ( heap,
x )   ((duk_uint8_t *) (((duk_hbuffer_fixed *) (x)) + 1))

Definition at line 6444 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFER_FIXED_GET_SIZE

#define DUK_HBUFFER_FIXED_GET_SIZE ( x)    DUK_HBUFFER_GET_SIZE((duk_hbuffer *) (x))

Definition at line 6433 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFER_FIXED_SET_SIZE

#define DUK_HBUFFER_FIXED_SET_SIZE ( x,
v )   DUK_HBUFFER_SET_SIZE((duk_hbuffer *) (x))

Definition at line 6434 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFER_FLAG_DYNAMIC

#define DUK_HBUFFER_FLAG_DYNAMIC   DUK_HEAPHDR_USER_FLAG(0) /* buffer is behind a pointer, dynamic or external */

Definition at line 6367 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFER_FLAG_EXTERNAL

#define DUK_HBUFFER_FLAG_EXTERNAL   DUK_HEAPHDR_USER_FLAG(1) /* buffer pointer is to an externally allocated buffer */

Definition at line 6368 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFER_GET_DATA_PTR

#define DUK_HBUFFER_GET_DATA_PTR ( heap,
x )
Value:
( \
DUK_HBUFFER_HAS_DYNAMIC((x)) ? \
DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((heap), (duk_hbuffer_dynamic *) (x)) : \
)

Definition at line 6505 of file duktape-1.8.0/src/duktape.c.

6506 ) : \
6508 )
6509#else

Referenced by duk__get_own_propdesc_raw(), and duk_hobject_putprop().

◆ DUK_HBUFFER_GET_SIZE

#define DUK_HBUFFER_GET_SIZE ( x)    (((duk_hbuffer *) (x))->size)

◆ DUK_HBUFFER_H_INCLUDED

#define DUK_HBUFFER_H_INCLUDED

Definition at line 6357 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFER_HAS_DYNAMIC

#define DUK_HBUFFER_HAS_DYNAMIC ( x)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HBUFFER_FLAG_DYNAMIC)

Definition at line 6370 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_duktape_object_info(), and duk_hbuffer_resize().

◆ DUK_HBUFFER_HAS_EXTERNAL

#define DUK_HBUFFER_HAS_EXTERNAL ( x)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HBUFFER_FLAG_EXTERNAL)

Definition at line 6371 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_duktape_object_info(), and duk_hbuffer_resize().

◆ DUK_HBUFFER_INCREF

#define DUK_HBUFFER_INCREF ( thr,
h )   DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))

Definition at line 3841 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_buffer_slice_shared().

◆ DUK_HBUFFER_MAX_BYTELEN

#define DUK_HBUFFER_MAX_BYTELEN   (0x7ffffffeUL)

Definition at line 6395 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hbuffer_resize().

◆ DUK_HBUFFER_SET_DYNAMIC

#define DUK_HBUFFER_SET_DYNAMIC ( x)    DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HBUFFER_FLAG_DYNAMIC)

Definition at line 6373 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFER_SET_EXTERNAL

#define DUK_HBUFFER_SET_EXTERNAL ( x)    DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HBUFFER_FLAG_EXTERNAL)

Definition at line 6374 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFER_SET_SIZE

#define DUK_HBUFFER_SET_SIZE ( x,
v )
Value:
do { \
((duk_hbuffer *) (x))->size = (v); \
} while (0)

Definition at line 6422 of file duktape-1.8.0/src/duktape.c.

6422#define DUK_HBUFFER_ADD_SIZE(x,dv) do { \
6423 (x)->hdr.h_flags += ((dv) << 16); \
6424 } while (0)

◆ DUK_HBUFFER_SUB_SIZE

#define DUK_HBUFFER_SUB_SIZE ( x,
dv )
Value:
do { \
(x)->size -= (dv); \
} while (0)

Definition at line 6428 of file duktape-1.8.0/src/duktape.c.

6428#else
6429#define DUK_HBUFFER_GET_SIZE(x) (((duk_hbuffer *) (x))->size)
6430#define DUK_HBUFFER_SET_SIZE(x,v) do { \

◆ DUK_HBUFFEROBJECT_CLAMP_BYTELENGTH

#define DUK_HBUFFEROBJECT_CLAMP_BYTELENGTH ( h,
len )
Value:
(DUK_ASSERT_EXPR((h) != NULL), \
duk_hbufferobject_clamp_bytelength((h), (len)))

Definition at line 5923 of file duktape-1.8.0/src/duktape.c.

5923 * duk_hbufferobject 'length') to the current dynamic buffer limits to
5924 * yield a byte length limit that's safe for memory accesses. This value
5925 * can be invalidated by any side effect because it may trigger a user

Referenced by duk_bi_buffer_readfield(), and duk_bi_buffer_slice_shared().

◆ DUK_HBUFFEROBJECT_DECREF

#define DUK_HBUFFEROBJECT_DECREF ( thr,
h )   DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) &(h)->obj)

Definition at line 3848 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFEROBJECT_ELEM_FLOAT32

#define DUK_HBUFFEROBJECT_ELEM_FLOAT32   7

Definition at line 5851 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFEROBJECT_ELEM_FLOAT64

#define DUK_HBUFFEROBJECT_ELEM_FLOAT64   8

Definition at line 5852 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFEROBJECT_ELEM_INT16

#define DUK_HBUFFEROBJECT_ELEM_INT16   4

Definition at line 5848 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFEROBJECT_ELEM_INT32

#define DUK_HBUFFEROBJECT_ELEM_INT32   6

Definition at line 5850 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFEROBJECT_ELEM_INT8

#define DUK_HBUFFEROBJECT_ELEM_INT8   2

Definition at line 5846 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFEROBJECT_ELEM_MAX

#define DUK_HBUFFEROBJECT_ELEM_MAX   8

Definition at line 5853 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFEROBJECT_ELEM_UINT16

#define DUK_HBUFFEROBJECT_ELEM_UINT16   3

Definition at line 5847 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFEROBJECT_ELEM_UINT32

#define DUK_HBUFFEROBJECT_ELEM_UINT32   5

Definition at line 5849 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFEROBJECT_ELEM_UINT8

#define DUK_HBUFFEROBJECT_ELEM_UINT8   0

Definition at line 5844 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFEROBJECT_ELEM_UINT8CLAMPED

#define DUK_HBUFFEROBJECT_ELEM_UINT8CLAMPED   1

Definition at line 5845 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFEROBJECT_FULL_SLICE

#define DUK_HBUFFEROBJECT_FULL_SLICE ( h)
Value:
(DUK_ASSERT_EXPR((h) != NULL), DUK_ASSERT_EXPR((h)->buf != NULL), \
((h)->offset == 0 && (h)->length == DUK_HBUFFER_GET_SIZE((h)->buf)))

Definition at line 5891 of file duktape-1.8.0/src/duktape.c.

5891/* True if slice is full, i.e. offset is zero and length covers the entire
5892 * buffer. This status may change independently of the duk_hbufferobject if
5893 * the underlying buffer is dynamic and changes without the hbufferobject

◆ DUK_HBUFFEROBJECT_GET_SLICE_BASE

#define DUK_HBUFFEROBJECT_GET_SLICE_BASE ( heap,
h )
Value:
(DUK_ASSERT_EXPR((h) != NULL), DUK_ASSERT_EXPR((h)->buf != NULL), \
(((duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR((heap), (h)->buf)) + (h)->offset))

Definition at line 5882 of file duktape-1.8.0/src/duktape.c.

5882 } while (0)
5883
5884/* Get the current data pointer (caller must ensure buf != NULL) as a

Referenced by duk_bi_buffer_readfield(), duk_bi_buffer_slice_shared(), and duk_bi_typedarray_set().

◆ DUK_HBUFFEROBJECT_H_INCLUDED

#define DUK_HBUFFEROBJECT_H_INCLUDED

Definition at line 5841 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFEROBJECT_INCREF

#define DUK_HBUFFEROBJECT_INCREF ( thr,
h )   DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)

Definition at line 3847 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HBUFFEROBJECT_VALID_BYTEOFFSET_EXCL

#define DUK_HBUFFEROBJECT_VALID_BYTEOFFSET_EXCL ( h,
off )
Value:
(DUK_ASSERT_EXPR((h) != NULL), DUK_ASSERT_EXPR((h)->buf != NULL), \
((h)->offset + (off) <= DUK_HBUFFER_GET_SIZE((h)->buf)))

Definition at line 5913 of file duktape-1.8.0/src/duktape.c.

5913 */
5914#define DUK_HBUFFEROBJECT_VALID_BYTEOFFSET_INCL(h,off) \
5915 (DUK_ASSERT_EXPR((h) != NULL), DUK_ASSERT_EXPR((h)->buf != NULL), \

Referenced by duk__get_own_propdesc_raw(), duk_bi_typedarray_set(), and duk_hobject_putprop().

◆ DUK_HBUFFEROBJECT_VALID_BYTEOFFSET_INCL

#define DUK_HBUFFEROBJECT_VALID_BYTEOFFSET_INCL ( h,
off )
Value:
(DUK_ASSERT_EXPR((h) != NULL), DUK_ASSERT_EXPR((h)->buf != NULL), \
((h)->offset + (off) < DUK_HBUFFER_GET_SIZE((h)->buf)))

Definition at line 5909 of file duktape-1.8.0/src/duktape.c.

5909 * buffer size. This is a safety check which is needed to ensure
5910 * that even a misconfigured duk_hbufferobject never causes memory
5911 * unsafe behavior (e.g. if an underlying dynamic buffer changes
#define check(x)
static void changes(sqlite3_context *context, int NotUsed, sqlite3_value **NotUsed2)
Definition sqlite3.c:117622

◆ DUK_HBUFFEROBJECT_VALID_SLICE

#define DUK_HBUFFEROBJECT_VALID_SLICE ( h)
Value:
(DUK_ASSERT_EXPR((h) != NULL), DUK_ASSERT_EXPR((h)->buf != NULL), \
((h)->offset + (h)->length <= DUK_HBUFFER_GET_SIZE((h)->buf)))

Definition at line 5898 of file duktape-1.8.0/src/duktape.c.

5898 ((h)->offset == 0 && (h)->length == DUK_HBUFFER_GET_SIZE((h)->buf)))
5899
5900/* Validate that the whole slice [0,length[ is contained in the underlying

Referenced by duk_bi_typedarray_set().

◆ DUK_HCOMPILEDFUNCTION_DECREF

#define DUK_HCOMPILEDFUNCTION_DECREF ( thr,
h )   DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) &(h)->obj)

Definition at line 3844 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HCOMPILEDFUNCTION_GET_BUFFER_BASE

#define DUK_HCOMPILEDFUNCTION_GET_BUFFER_BASE ( heap,
h )    DUK_HBUFFER_FIXED_GET_DATA_PTR((heap), DUK_HCOMPILEDFUNCTION_GET_DATA((heap), (h)))

Definition at line 5618 of file duktape-1.8.0/src/duktape.c.

5618
5619/* Note: assumes 'data' is always a fixed buffer */

◆ DUK_HCOMPILEDFUNCTION_GET_BYTECODE

#define DUK_HCOMPILEDFUNCTION_GET_BYTECODE ( heap,
h )    ((h)->bytecode)

Definition at line 5606 of file duktape-1.8.0/src/duktape.c.

5606 (h)->funcs = (v); \
5607 } while (0)
static const luaL_Reg funcs[]

◆ DUK_HCOMPILEDFUNCTION_GET_CODE_BASE

#define DUK_HCOMPILEDFUNCTION_GET_CODE_BASE ( heap,
h )    DUK_HCOMPILEDFUNCTION_GET_BYTECODE((heap), (h))

Definition at line 5627 of file duktape-1.8.0/src/duktape.c.

5628
#define DUK_HCOMPILEDFUNCTION_GET_FUNCS(heap, h)

Referenced by duk_handle_ecma_call_setup(), and duk_hthread_get_act_prev_pc().

◆ DUK_HCOMPILEDFUNCTION_GET_CODE_COUNT

#define DUK_HCOMPILEDFUNCTION_GET_CODE_COUNT ( heap,
h )    ((duk_size_t) (DUK_HCOMPILEDFUNCTION_GET_CODE_SIZE((heap), (h)) / sizeof(duk_instr_t)))

Definition at line 5674 of file duktape-1.8.0/src/duktape.c.

5674 ((duk_size_t) (DUK_HCOMPILEDFUNCTION_GET_FUNCS_SIZE((heap), (h)) / sizeof(duk_hobject *)))
5675
#define DUK_HCOMPILEDFUNCTION_GET_FUNCS_SIZE(heap, h)

◆ DUK_HCOMPILEDFUNCTION_GET_CODE_END

#define DUK_HCOMPILEDFUNCTION_GET_CODE_END ( heap,
h )
Value:
DUK_HBUFFER_GET_SIZE((duk_hbuffer *) DUK_HCOMPILEDFUNCTION_GET_DATA((heap), h))))
#define DUK_HCOMPILEDFUNCTION_GET_DATA(heap, h)

Definition at line 5637 of file duktape-1.8.0/src/duktape.c.

5637
5638/* XXX: double evaluation of DUK_HCOMPILEDFUNCTION_GET_DATA() */
5639#define DUK_HCOMPILEDFUNCTION_GET_CODE_END(heap,h) \

◆ DUK_HCOMPILEDFUNCTION_GET_CODE_SIZE

#define DUK_HCOMPILEDFUNCTION_GET_CODE_SIZE ( heap,
h )
Value:
( \
( \
((const duk_uint8_t *) DUK_HCOMPILEDFUNCTION_GET_CODE_END((heap),(h))) - \
((const duk_uint8_t *) DUK_HCOMPILEDFUNCTION_GET_CODE_BASE((heap),(h))) \
) \
)
#define DUK_HCOMPILEDFUNCTION_GET_CODE_BASE(heap, h)
#define DUK_HCOMPILEDFUNCTION_GET_CODE_END(heap, h)

Definition at line 5659 of file duktape-1.8.0/src/duktape.c.

5659 )
5660
5662 ( \
5663 (duk_size_t) \
5664 ( \
5665 ((const duk_uint8_t *) DUK_HCOMPILEDFUNCTION_GET_CODE_END((heap),(h))) - \
5666 ((const duk_uint8_t *) DUK_HCOMPILEDFUNCTION_GET_CODE_BASE((heap),(h))) \
#define DUK_HCOMPILEDFUNCTION_GET_CODE_SIZE(heap, h)

◆ DUK_HCOMPILEDFUNCTION_GET_CONSTS_BASE

#define DUK_HCOMPILEDFUNCTION_GET_CONSTS_BASE ( heap,
h )    ((duk_tval *) (void *) DUK_HCOMPILEDFUNCTION_GET_BUFFER_BASE((heap), (h)))

◆ DUK_HCOMPILEDFUNCTION_GET_CONSTS_COUNT

#define DUK_HCOMPILEDFUNCTION_GET_CONSTS_COUNT ( heap,
h )    ((duk_size_t) (DUK_HCOMPILEDFUNCTION_GET_CONSTS_SIZE((heap), (h)) / sizeof(duk_tval)))

Definition at line 5668 of file duktape-1.8.0/src/duktape.c.

5668 )
5669

◆ DUK_HCOMPILEDFUNCTION_GET_CONSTS_END

#define DUK_HCOMPILEDFUNCTION_GET_CONSTS_END ( heap,
h )    ((duk_tval *) (void *) DUK_HCOMPILEDFUNCTION_GET_FUNCS((heap), (h)))

Definition at line 5630 of file duktape-1.8.0/src/duktape.c.

5631
#define DUK_HCOMPILEDFUNCTION_GET_BYTECODE(heap, h)

Referenced by duk__inc_data_inner_refcounts().

◆ DUK_HCOMPILEDFUNCTION_GET_CONSTS_SIZE

#define DUK_HCOMPILEDFUNCTION_GET_CONSTS_SIZE ( heap,
h )
Value:
( \
( \
((const duk_uint8_t *) DUK_HCOMPILEDFUNCTION_GET_CONSTS_END((heap), (h))) - \
((const duk_uint8_t *) DUK_HCOMPILEDFUNCTION_GET_CONSTS_BASE((heap), (h))) \
) \
)
#define DUK_HCOMPILEDFUNCTION_GET_CONSTS_BASE(heap, h)
#define DUK_HCOMPILEDFUNCTION_GET_CONSTS_END(heap, h)

Definition at line 5641 of file duktape-1.8.0/src/duktape.c.

5642
5643#define DUK_HCOMPILEDFUNCTION_GET_CONSTS_SIZE(heap,h) \
5644 ( \
5645 (duk_size_t) \
5646 ( \
5647 ((const duk_uint8_t *) DUK_HCOMPILEDFUNCTION_GET_CONSTS_END((heap), (h))) - \
5648 ((const duk_uint8_t *) DUK_HCOMPILEDFUNCTION_GET_CONSTS_BASE((heap), (h))) \

◆ DUK_HCOMPILEDFUNCTION_GET_DATA

#define DUK_HCOMPILEDFUNCTION_GET_DATA ( heap,
h )    ((duk_hbuffer_fixed *) (void *) (h)->data)

Definition at line 5596 of file duktape-1.8.0/src/duktape.c.

5596 } while (0)
5597#else

Referenced by duk__inc_data_inner_refcounts(), and duk_bi_duktape_object_info().

◆ DUK_HCOMPILEDFUNCTION_GET_FUNCS

#define DUK_HCOMPILEDFUNCTION_GET_FUNCS ( heap,
h )    ((h)->funcs)

Definition at line 5601 of file duktape-1.8.0/src/duktape.c.

5601 (h)->data = (duk_hbuffer *) (v); \
5602 } while (0)

◆ DUK_HCOMPILEDFUNCTION_GET_FUNCS_BASE

#define DUK_HCOMPILEDFUNCTION_GET_FUNCS_BASE ( heap,
h )    DUK_HCOMPILEDFUNCTION_GET_FUNCS((heap), (h))

Definition at line 5624 of file duktape-1.8.0/src/duktape.c.

5624 ((duk_tval *) (void *) DUK_HCOMPILEDFUNCTION_GET_BUFFER_BASE((heap), (h)))
5625
#define DUK_HCOMPILEDFUNCTION_GET_BUFFER_BASE(heap, h)

◆ DUK_HCOMPILEDFUNCTION_GET_FUNCS_COUNT

#define DUK_HCOMPILEDFUNCTION_GET_FUNCS_COUNT ( heap,
h )    ((duk_size_t) (DUK_HCOMPILEDFUNCTION_GET_FUNCS_SIZE((heap), (h)) / sizeof(duk_hobject *)))

Definition at line 5671 of file duktape-1.8.0/src/duktape.c.

5671 ((duk_size_t) (DUK_HCOMPILEDFUNCTION_GET_CONSTS_SIZE((heap), (h)) / sizeof(duk_tval)))
5672
struct duk_tval_struct duk_tval
#define DUK_HCOMPILEDFUNCTION_GET_CONSTS_SIZE(heap, h)

◆ DUK_HCOMPILEDFUNCTION_GET_FUNCS_END

#define DUK_HCOMPILEDFUNCTION_GET_FUNCS_END ( heap,
h )    ((duk_hobject **) (void *) DUK_HCOMPILEDFUNCTION_GET_BYTECODE((heap), (h)))

Definition at line 5633 of file duktape-1.8.0/src/duktape.c.

5633 ((duk_tval *) (void *) DUK_HCOMPILEDFUNCTION_GET_FUNCS((heap), (h)))
5634

◆ DUK_HCOMPILEDFUNCTION_GET_FUNCS_SIZE

#define DUK_HCOMPILEDFUNCTION_GET_FUNCS_SIZE ( heap,
h )
Value:
( \
( \
((const duk_uint8_t *) DUK_HCOMPILEDFUNCTION_GET_FUNCS_END((heap), (h))) - \
((const duk_uint8_t *) DUK_HCOMPILEDFUNCTION_GET_FUNCS_BASE((heap), (h))) \
) \
)
#define DUK_HCOMPILEDFUNCTION_GET_FUNCS_BASE(heap, h)
#define DUK_HCOMPILEDFUNCTION_GET_FUNCS_END(heap, h)

Definition at line 5650 of file duktape-1.8.0/src/duktape.c.

5650 )
5651
5653 ( \
5654 (duk_size_t) \
5655 ( \
5656 ((const duk_uint8_t *) DUK_HCOMPILEDFUNCTION_GET_FUNCS_END((heap), (h))) - \
5657 ((const duk_uint8_t *) DUK_HCOMPILEDFUNCTION_GET_FUNCS_BASE((heap), (h))) \

◆ DUK_HCOMPILEDFUNCTION_H_INCLUDED

#define DUK_HCOMPILEDFUNCTION_H_INCLUDED

Definition at line 5571 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HCOMPILEDFUNCTION_INCREF

#define DUK_HCOMPILEDFUNCTION_INCREF ( thr,
h )   DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)

Definition at line 3843 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HCOMPILEDFUNCTION_SET_BYTECODE

#define DUK_HCOMPILEDFUNCTION_SET_BYTECODE ( heap,
h,
v )
Value:
do { \
(h)->bytecode = (v); \
} while (0)

Definition at line 5608 of file duktape-1.8.0/src/duktape.c.

5608#define DUK_HCOMPILEDFUNCTION_GET_BYTECODE(heap,h) \
5609 ((h)->bytecode)
5610#define DUK_HCOMPILEDFUNCTION_SET_BYTECODE(heap,h,v) do { \

◆ DUK_HCOMPILEDFUNCTION_SET_DATA

#define DUK_HCOMPILEDFUNCTION_SET_DATA ( heap,
h,
v )
Value:
do { \
(h)->data = (duk_hbuffer *) (v); \
} while (0)

Definition at line 5598 of file duktape-1.8.0/src/duktape.c.

5598#define DUK_HCOMPILEDFUNCTION_GET_DATA(heap,h) \
5599 ((duk_hbuffer_fixed *) (void *) (h)->data)
5600#define DUK_HCOMPILEDFUNCTION_SET_DATA(heap,h,v) do { \

◆ DUK_HCOMPILEDFUNCTION_SET_FUNCS

#define DUK_HCOMPILEDFUNCTION_SET_FUNCS ( heap,
h,
v )
Value:
do { \
(h)->funcs = (v); \
} while (0)

Definition at line 5603 of file duktape-1.8.0/src/duktape.c.

5603#define DUK_HCOMPILEDFUNCTION_GET_FUNCS(heap,h) \
5604 ((h)->funcs)
5605#define DUK_HCOMPILEDFUNCTION_SET_FUNCS(heap,h,v) do { \

◆ DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_EMERGENCY_LIMIT

#define DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_EMERGENCY_LIMIT
Value:
3 /* Starting from this round, use emergency mode
* for mark-and-sweep.
*/

Definition at line 6903 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_LIMIT

#define DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_LIMIT
Value:
5 /* Retry allocation after mark-and-sweep for this
* many times. A single mark-and-sweep round is
* not guaranteed to free all unreferenced memory
* because of finalization (in fact, ANY number of
* rounds is strictly not enough).
*/

Definition at line 6901 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_CLEAR_ERRHANDLER_RUNNING

#define DUK_HEAP_CLEAR_ERRHANDLER_RUNNING ( heap)    DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_ERRHANDLER_RUNNING)

Definition at line 6722 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_CLEAR_FINALIZER_NORESCUE

#define DUK_HEAP_CLEAR_FINALIZER_NORESCUE ( heap)    DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_FINALIZER_NORESCUE)

Definition at line 6724 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_CLEAR_INTERRUPT_RUNNING

#define DUK_HEAP_CLEAR_INTERRUPT_RUNNING ( heap)    DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_INTERRUPT_RUNNING)

Definition at line 6723 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_CLEAR_MARKANDSWEEP_RECLIMIT_REACHED

#define DUK_HEAP_CLEAR_MARKANDSWEEP_RECLIMIT_REACHED ( heap)    DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED)

Definition at line 6720 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_CLEAR_MARKANDSWEEP_RUNNING

#define DUK_HEAP_CLEAR_MARKANDSWEEP_RUNNING ( heap)    DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RUNNING)

Definition at line 6719 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_CLEAR_REFZERO_FREE_RUNNING

#define DUK_HEAP_CLEAR_REFZERO_FREE_RUNNING ( heap)    DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_REFZERO_FREE_RUNNING)

Definition at line 6721 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_DBG_RATELIMIT_MILLISECS

#define DUK_HEAP_DBG_RATELIMIT_MILLISECS   200

Definition at line 6922 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_DBG_RATELIMIT_OPCODES

#define DUK_HEAP_DBG_RATELIMIT_OPCODES   4000

Definition at line 6919 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_FLAG_ERRHANDLER_RUNNING

#define DUK_HEAP_FLAG_ERRHANDLER_RUNNING   (1 << 3) /* an error handler (user callback to augment/replace error) is running */

Definition at line 6693 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_FLAG_FINALIZER_NORESCUE

#define DUK_HEAP_FLAG_FINALIZER_NORESCUE   (1 << 5) /* heap destruction ongoing, finalizer rescue no longer possible */

Definition at line 6695 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_FLAG_INTERRUPT_RUNNING

#define DUK_HEAP_FLAG_INTERRUPT_RUNNING   (1 << 4) /* executor interrupt running (used to avoid nested interrupts) */

Definition at line 6694 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED

#define DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED   (1 << 1) /* mark-and-sweep marking reached a recursion limit and must use multi-pass marking */

Definition at line 6691 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_FLAG_MARKANDSWEEP_RUNNING

#define DUK_HEAP_FLAG_MARKANDSWEEP_RUNNING   (1 << 0) /* mark-and-sweep is currently running */

Definition at line 6690 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_FLAG_REFZERO_FREE_RUNNING

#define DUK_HEAP_FLAG_REFZERO_FREE_RUNNING   (1 << 2) /* refcount code is processing refzero list */

Definition at line 6692 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_GET_STRING

#define DUK_HEAP_GET_STRING ( heap,
idx )    ((heap)->strs[(idx)])

Definition at line 6842 of file duktape-1.8.0/src/duktape.c.

6842#if defined(DUK_USE_ROM_STRINGS)
6843#define DUK_HEAP_GET_STRING(heap,idx) \

◆ DUK_HEAP_H_INCLUDED

#define DUK_HEAP_H_INCLUDED

Definition at line 6682 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_HAS_ERRHANDLER_RUNNING

#define DUK_HEAP_HAS_ERRHANDLER_RUNNING ( heap)    DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_ERRHANDLER_RUNNING)

Definition at line 6708 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__err_augment_user().

◆ DUK_HEAP_HAS_FINALIZER_NORESCUE

#define DUK_HEAP_HAS_FINALIZER_NORESCUE ( heap)    DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_FINALIZER_NORESCUE)

Definition at line 6710 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_HAS_INTERRUPT_RUNNING

#define DUK_HEAP_HAS_INTERRUPT_RUNNING ( heap)    DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_INTERRUPT_RUNNING)

Definition at line 6709 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_HAS_MARKANDSWEEP_RECLIMIT_REACHED

#define DUK_HEAP_HAS_MARKANDSWEEP_RECLIMIT_REACHED ( heap)    DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED)

Definition at line 6706 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_HAS_MARKANDSWEEP_RUNNING

#define DUK_HEAP_HAS_MARKANDSWEEP_RUNNING ( heap)    DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RUNNING)

Definition at line 6705 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__run_voluntary_gc().

◆ DUK_HEAP_HAS_REFZERO_FREE_RUNNING

#define DUK_HEAP_HAS_REFZERO_FREE_RUNNING ( heap)    DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_REFZERO_FREE_RUNNING)

Definition at line 6707 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_INSERT_INTO_HEAP_ALLOCATED

#define DUK_HEAP_INSERT_INTO_HEAP_ALLOCATED ( heap,
hdr )   duk_heap_insert_into_heap_allocated((heap),(hdr))

Definition at line 6802 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__init_object_parts().

◆ DUK_HEAP_MARK_AND_SWEEP_TRIGGER_ADD

#define DUK_HEAP_MARK_AND_SWEEP_TRIGGER_ADD   1024L

Definition at line 6786 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_MARK_AND_SWEEP_TRIGGER_MULT

#define DUK_HEAP_MARK_AND_SWEEP_TRIGGER_MULT   12800L /* 50x heap size */

Definition at line 6785 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_MARK_AND_SWEEP_TRIGGER_SKIP

#define DUK_HEAP_MARK_AND_SWEEP_TRIGGER_SKIP   256L

Definition at line 6787 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_MAX_BREAKPOINTS

#define DUK_HEAP_MAX_BREAKPOINTS   16

Definition at line 6912 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_NUM_STRINGS

#define DUK_HEAP_NUM_STRINGS   191

◆ DUK_HEAP_SET_ERRHANDLER_RUNNING

#define DUK_HEAP_SET_ERRHANDLER_RUNNING ( heap)    DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_ERRHANDLER_RUNNING)

Definition at line 6715 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__err_augment_user().

◆ DUK_HEAP_SET_FINALIZER_NORESCUE

#define DUK_HEAP_SET_FINALIZER_NORESCUE ( heap)    DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_FINALIZER_NORESCUE)

Definition at line 6717 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_SET_INTERRUPT_RUNNING

#define DUK_HEAP_SET_INTERRUPT_RUNNING ( heap)    DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_INTERRUPT_RUNNING)

Definition at line 6716 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_SET_MARKANDSWEEP_RECLIMIT_REACHED

#define DUK_HEAP_SET_MARKANDSWEEP_RECLIMIT_REACHED ( heap)    DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED)

Definition at line 6713 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_SET_MARKANDSWEEP_RUNNING

#define DUK_HEAP_SET_MARKANDSWEEP_RUNNING ( heap)    DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RUNNING)

Definition at line 6712 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_SET_REFZERO_FREE_RUNNING

#define DUK_HEAP_SET_REFZERO_FREE_RUNNING ( heap)    DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_REFZERO_FREE_RUNNING)

Definition at line 6714 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRCACHE_SIZE

#define DUK_HEAP_STRCACHE_SIZE   4

Definition at line 6798 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_heap_strcache_string_remove().

◆ DUK_HEAP_STRING___PROTO__

#define DUK_HEAP_STRING___PROTO__ ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX___PROTO__)

Definition at line 1115 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_ARRAY

#define DUK_HEAP_STRING_ARRAY ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ARRAY)

Definition at line 902 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_ARRAY_BUFFER

#define DUK_HEAP_STRING_ARRAY_BUFFER ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ARRAY_BUFFER)

Definition at line 932 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_BASE64

#define DUK_HEAP_STRING_BASE64 ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BASE64)

Definition at line 1259 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_BRACKETED_ELLIPSIS

#define DUK_HEAP_STRING_BRACKETED_ELLIPSIS ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BRACKETED_ELLIPSIS)

Definition at line 1082 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_BREAK

#define DUK_HEAP_STRING_BREAK ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BREAK)

Definition at line 1325 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_BYTE_LENGTH

#define DUK_HEAP_STRING_BYTE_LENGTH ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BYTE_LENGTH)

Definition at line 1145 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_BYTE_OFFSET

#define DUK_HEAP_STRING_BYTE_OFFSET ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BYTE_OFFSET)

Definition at line 1148 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_BYTES_PER_ELEMENT

#define DUK_HEAP_STRING_BYTES_PER_ELEMENT ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BYTES_PER_ELEMENT)

Definition at line 1151 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_CALLEE

#define DUK_HEAP_STRING_CALLEE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CALLEE)

Definition at line 1091 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_CALLER

#define DUK_HEAP_STRING_CALLER ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CALLER)

Definition at line 1094 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_CASE

#define DUK_HEAP_STRING_CASE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CASE)

Definition at line 1328 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_CATCH

#define DUK_HEAP_STRING_CATCH ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CATCH)

Definition at line 1331 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_CLASS

#define DUK_HEAP_STRING_CLASS ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CLASS)

Definition at line 1406 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_CLOG

#define DUK_HEAP_STRING_CLOG ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CLOG)

Definition at line 1301 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_COMMA

#define DUK_HEAP_STRING_COMMA ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_COMMA)

Definition at line 1073 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_COMPILE

#define DUK_HEAP_STRING_COMPILE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_COMPILE)

Definition at line 1235 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_CONFIGURABLE

#define DUK_HEAP_STRING_CONFIGURABLE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CONFIGURABLE)

Definition at line 995 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_CONST

#define DUK_HEAP_STRING_CONST ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CONST)

Definition at line 1394 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_CONSTRUCTOR

#define DUK_HEAP_STRING_CONSTRUCTOR ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CONSTRUCTOR)

Definition at line 1040 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_CONTINUE

#define DUK_HEAP_STRING_CONTINUE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CONTINUE)

Definition at line 1334 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_DATA

#define DUK_HEAP_STRING_DATA ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DATA)

Definition at line 1139 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_DATA_VIEW

#define DUK_HEAP_STRING_DATA_VIEW ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DATA_VIEW)

Definition at line 935 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_DATE

#define DUK_HEAP_STRING_DATE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DATE)

Definition at line 914 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_DEBUGGER

#define DUK_HEAP_STRING_DEBUGGER ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DEBUGGER)

Definition at line 1337 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_DEC_ENV

#define DUK_HEAP_STRING_DEC_ENV ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DEC_ENV)

Definition at line 971 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_DEFAULT

#define DUK_HEAP_STRING_DEFAULT ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DEFAULT)

Definition at line 1340 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_DEFINE_PROPERTY

#define DUK_HEAP_STRING_DEFINE_PROPERTY ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DEFINE_PROPERTY)

Definition at line 986 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_DELETE

#define DUK_HEAP_STRING_DELETE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DELETE)

Definition at line 1343 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_DELETE_PROPERTY

#define DUK_HEAP_STRING_DELETE_PROPERTY ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DELETE_PROPERTY)

Definition at line 1103 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_DO

#define DUK_HEAP_STRING_DO ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DO)

Definition at line 1346 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_ELSE

#define DUK_HEAP_STRING_ELSE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ELSE)

Definition at line 1349 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_EMPTY_STRING

#define DUK_HEAP_STRING_EMPTY_STRING ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EMPTY_STRING)

Definition at line 929 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_ENUM

#define DUK_HEAP_STRING_ENUM ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ENUM)

Definition at line 1409 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_ENUMERABLE

#define DUK_HEAP_STRING_ENUMERABLE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ENUMERABLE)

Definition at line 998 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_ENUMERATE

#define DUK_HEAP_STRING_ENUMERATE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ENUMERATE)

Definition at line 1106 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_ENV

#define DUK_HEAP_STRING_ENV ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ENV)

Definition at line 1253 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_ERR_CREATE

#define DUK_HEAP_STRING_ERR_CREATE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ERR_CREATE)

Definition at line 1241 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_ERR_THROW

#define DUK_HEAP_STRING_ERR_THROW ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ERR_THROW)

Definition at line 1244 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_ESCAPED_EMPTY_REGEXP

#define DUK_HEAP_STRING_ESCAPED_EMPTY_REGEXP ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ESCAPED_EMPTY_REGEXP)

Definition at line 1031 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_EVAL

#define DUK_HEAP_STRING_EVAL ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EVAL)

Definition at line 983 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_EXPORT

#define DUK_HEAP_STRING_EXPORT ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EXPORT)

Definition at line 1412 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_EXPORTS

#define DUK_HEAP_STRING_EXPORTS ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EXPORTS)

Definition at line 1124 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_EXTENDS

#define DUK_HEAP_STRING_EXTENDS ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EXTENDS)

Definition at line 1415 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_FALSE

#define DUK_HEAP_STRING_FALSE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FALSE)

Definition at line 1430 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_FILE_NAME

#define DUK_HEAP_STRING_FILE_NAME ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FILE_NAME)

Definition at line 1172 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_FILENAME

#define DUK_HEAP_STRING_FILENAME ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FILENAME)

Definition at line 1127 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_FINALLY

#define DUK_HEAP_STRING_FINALLY ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FINALLY)

Definition at line 1352 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_FLOAT32_ARRAY

#define DUK_HEAP_STRING_FLOAT32_ARRAY ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FLOAT32_ARRAY)

Definition at line 959 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_FLOAT64_ARRAY

#define DUK_HEAP_STRING_FLOAT64_ARRAY ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FLOAT64_ARRAY)

Definition at line 962 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_FMT

#define DUK_HEAP_STRING_FMT ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FMT)

Definition at line 1271 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_FOR

#define DUK_HEAP_STRING_FOR ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FOR)

Definition at line 1355 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_GET

#define DUK_HEAP_STRING_GET ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_GET)

Definition at line 1100 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_GLOBAL

#define DUK_HEAP_STRING_GLOBAL ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_GLOBAL)

Definition at line 965 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_HAS

#define DUK_HEAP_STRING_HAS ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_HAS)

Definition at line 1097 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_HEX

#define DUK_HEAP_STRING_HEX ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_HEX)

Definition at line 1256 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_ID

#define DUK_HEAP_STRING_ID ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ID)

Definition at line 1121 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_IF

#define DUK_HEAP_STRING_IF ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IF)

Definition at line 1361 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_IGNORE_CASE

#define DUK_HEAP_STRING_IGNORE_CASE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IGNORE_CASE)

Definition at line 1022 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_IMPLEMENTS

#define DUK_HEAP_STRING_IMPLEMENTS ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IMPLEMENTS)

Definition at line 1433 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_IMPORT

#define DUK_HEAP_STRING_IMPORT ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IMPORT)

Definition at line 1418 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_IN

#define DUK_HEAP_STRING_IN ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IN)

Definition at line 1364 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INDEX

#define DUK_HEAP_STRING_INDEX ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INDEX)

Definition at line 1034 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INFINITY

#define DUK_HEAP_STRING_INFINITY ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INFINITY)

Definition at line 1064 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INPUT

#define DUK_HEAP_STRING_INPUT ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INPUT)

Definition at line 1238 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INSTANCEOF

#define DUK_HEAP_STRING_INSTANCEOF ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INSTANCEOF)

Definition at line 1367 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT16_ARRAY

#define DUK_HEAP_STRING_INT16_ARRAY ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT16_ARRAY)

Definition at line 947 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT32_ARRAY

#define DUK_HEAP_STRING_INT32_ARRAY ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT32_ARRAY)

Definition at line 953 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT8_ARRAY

#define DUK_HEAP_STRING_INT8_ARRAY ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT8_ARRAY)

Definition at line 938 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT_ARGS

#define DUK_HEAP_STRING_INT_ARGS ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_ARGS)

Definition at line 1208 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT_BYTECODE

#define DUK_HEAP_STRING_INT_BYTECODE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_BYTECODE)

Definition at line 1187 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT_CALLEE

#define DUK_HEAP_STRING_INT_CALLEE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_CALLEE)

Definition at line 1220 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT_FINALIZER

#define DUK_HEAP_STRING_INT_FINALIZER ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_FINALIZER)

Definition at line 1214 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT_FORMALS

#define DUK_HEAP_STRING_INT_FORMALS ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_FORMALS)

Definition at line 1190 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT_HANDLER

#define DUK_HEAP_STRING_INT_HANDLER ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_HANDLER)

Definition at line 1217 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT_LEXENV

#define DUK_HEAP_STRING_INT_LEXENV ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_LEXENV)

Definition at line 1196 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT_MAP

#define DUK_HEAP_STRING_INT_MAP ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_MAP)

Definition at line 1211 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT_NEXT

#define DUK_HEAP_STRING_INT_NEXT ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_NEXT)

Definition at line 1184 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT_PC2LINE

#define DUK_HEAP_STRING_INT_PC2LINE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_PC2LINE)

Definition at line 1205 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT_REGBASE

#define DUK_HEAP_STRING_INT_REGBASE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_REGBASE)

Definition at line 1226 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT_SOURCE

#define DUK_HEAP_STRING_INT_SOURCE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_SOURCE)

Definition at line 1202 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT_TARGET

#define DUK_HEAP_STRING_INT_TARGET ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_TARGET)

Definition at line 1229 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT_THIS

#define DUK_HEAP_STRING_INT_THIS ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_THIS)

Definition at line 1232 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT_THREAD

#define DUK_HEAP_STRING_INT_THREAD ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_THREAD)

Definition at line 1223 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT_TRACEDATA

#define DUK_HEAP_STRING_INT_TRACEDATA ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_TRACEDATA)

Definition at line 1166 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT_VALUE

#define DUK_HEAP_STRING_INT_VALUE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_VALUE)

Definition at line 1181 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT_VARENV

#define DUK_HEAP_STRING_INT_VARENV ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_VARENV)

Definition at line 1199 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INT_VARMAP

#define DUK_HEAP_STRING_INT_VARMAP ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_VARMAP)

Definition at line 1193 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INTERFACE

#define DUK_HEAP_STRING_INTERFACE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INTERFACE)

Definition at line 1436 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_INVALID_DATE

#define DUK_HEAP_STRING_INVALID_DATE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INVALID_DATE)

Definition at line 1085 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_JC

#define DUK_HEAP_STRING_JC ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JC)

Definition at line 1265 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_JOIN

#define DUK_HEAP_STRING_JOIN ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JOIN)

Definition at line 1001 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_JSON

#define DUK_HEAP_STRING_JSON ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON)

Definition at line 926 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_JSON_EXT_FUNCTION1

#define DUK_HEAP_STRING_JSON_EXT_FUNCTION1 ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_FUNCTION1)

Definition at line 1319 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_JSON_EXT_FUNCTION2

#define DUK_HEAP_STRING_JSON_EXT_FUNCTION2 ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_FUNCTION2)

Definition at line 1322 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_JSON_EXT_NAN

#define DUK_HEAP_STRING_JSON_EXT_NAN ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_NAN)

Definition at line 1310 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_JSON_EXT_NEGINF

#define DUK_HEAP_STRING_JSON_EXT_NEGINF ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_NEGINF)

Definition at line 1316 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_JSON_EXT_POSINF

#define DUK_HEAP_STRING_JSON_EXT_POSINF ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_POSINF)

Definition at line 1313 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_JSON_EXT_UNDEFINED

#define DUK_HEAP_STRING_JSON_EXT_UNDEFINED ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_UNDEFINED)

Definition at line 1307 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_JX

#define DUK_HEAP_STRING_JX ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JX)

Definition at line 1262 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LAST_INDEX

#define DUK_HEAP_STRING_LAST_INDEX ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LAST_INDEX)

Definition at line 1028 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LC_ARGUMENTS

#define DUK_HEAP_STRING_LC_ARGUMENTS ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_ARGUMENTS)

Definition at line 1088 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LC_BOOLEAN

#define DUK_HEAP_STRING_LC_BOOLEAN ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_BOOLEAN)

Definition at line 1046 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LC_BUFFER

#define DUK_HEAP_STRING_LC_BUFFER ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_BUFFER)

Definition at line 1175 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LC_DEBUG

#define DUK_HEAP_STRING_LC_DEBUG ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_DEBUG)

Definition at line 1280 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LC_ERROR

#define DUK_HEAP_STRING_LC_ERROR ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_ERROR)

Definition at line 1289 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LC_FATAL

#define DUK_HEAP_STRING_LC_FATAL ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_FATAL)

Definition at line 1292 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LC_FUNCTION

#define DUK_HEAP_STRING_LC_FUNCTION ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_FUNCTION)

Definition at line 1358 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LC_INFO

#define DUK_HEAP_STRING_LC_INFO ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_INFO)

Definition at line 1283 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LC_L

#define DUK_HEAP_STRING_LC_L ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_L)

Definition at line 1298 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LC_N

#define DUK_HEAP_STRING_LC_N ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_N)

Definition at line 1295 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LC_NULL

#define DUK_HEAP_STRING_LC_NULL ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_NULL)

Definition at line 1424 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LC_NUMBER

#define DUK_HEAP_STRING_LC_NUMBER ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_NUMBER)

Definition at line 1049 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LC_OBJECT

#define DUK_HEAP_STRING_LC_OBJECT ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_OBJECT)

Definition at line 1055 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LC_POINTER

#define DUK_HEAP_STRING_LC_POINTER ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_POINTER)

Definition at line 1178 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LC_STRING

#define DUK_HEAP_STRING_LC_STRING ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_STRING)

Definition at line 1052 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LC_TRACE

#define DUK_HEAP_STRING_LC_TRACE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_TRACE)

Definition at line 1277 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LC_UNDEFINED

#define DUK_HEAP_STRING_LC_UNDEFINED ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_UNDEFINED)

Definition at line 1058 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LC_WARN

#define DUK_HEAP_STRING_LC_WARN ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_WARN)

Definition at line 1286 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LENGTH

#define DUK_HEAP_STRING_LENGTH ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LENGTH)

Definition at line 1142 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LET

#define DUK_HEAP_STRING_LET ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LET)

Definition at line 1439 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_LINE_NUMBER

#define DUK_HEAP_STRING_LINE_NUMBER ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LINE_NUMBER)

Definition at line 1163 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_MATH

#define DUK_HEAP_STRING_MATH ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_MATH)

Definition at line 923 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_MESSAGE

#define DUK_HEAP_STRING_MESSAGE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_MESSAGE)

Definition at line 1043 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_MINUS_INFINITY

#define DUK_HEAP_STRING_MINUS_INFINITY ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_MINUS_INFINITY)

Definition at line 1067 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_MINUS_ZERO

#define DUK_HEAP_STRING_MINUS_ZERO ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_MINUS_ZERO)

Definition at line 1070 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_MOD_LOADED

#define DUK_HEAP_STRING_MOD_LOADED ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_MOD_LOADED)

Definition at line 1250 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_MOD_SEARCH

#define DUK_HEAP_STRING_MOD_SEARCH ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_MOD_SEARCH)

Definition at line 1247 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_MULTILINE

#define DUK_HEAP_STRING_MULTILINE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_MULTILINE)

Definition at line 1025 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_NAME

#define DUK_HEAP_STRING_NAME ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_NAME)

Definition at line 1169 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_NAN

#define DUK_HEAP_STRING_NAN ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_NAN)

Definition at line 1061 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_NEW

#define DUK_HEAP_STRING_NEW ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_NEW)

Definition at line 1370 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_NEWLINE_4SPACE

#define DUK_HEAP_STRING_NEWLINE_4SPACE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_NEWLINE_4SPACE)

Definition at line 1079 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_OBJ_ENV

#define DUK_HEAP_STRING_OBJ_ENV ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_OBJ_ENV)

Definition at line 968 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_OWN_KEYS

#define DUK_HEAP_STRING_OWN_KEYS ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_OWN_KEYS)

Definition at line 1109 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_PACKAGE

#define DUK_HEAP_STRING_PACKAGE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PACKAGE)

Definition at line 1442 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_PC

#define DUK_HEAP_STRING_PC ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PC)

Definition at line 1160 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_PRIVATE

#define DUK_HEAP_STRING_PRIVATE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PRIVATE)

Definition at line 1445 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_PROTECTED

#define DUK_HEAP_STRING_PROTECTED ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PROTECTED)

Definition at line 1448 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_PROTOTYPE

#define DUK_HEAP_STRING_PROTOTYPE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PROTOTYPE)

Definition at line 1037 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_PUBLIC

#define DUK_HEAP_STRING_PUBLIC ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PUBLIC)

Definition at line 1451 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_RAW

#define DUK_HEAP_STRING_RAW ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_RAW)

Definition at line 1274 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_REG_EXP

#define DUK_HEAP_STRING_REG_EXP ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_REG_EXP)

Definition at line 917 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_REQUIRE

#define DUK_HEAP_STRING_REQUIRE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_REQUIRE)

Definition at line 1118 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_RESUME

#define DUK_HEAP_STRING_RESUME ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_RESUME)

Definition at line 1268 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_RETURN

#define DUK_HEAP_STRING_RETURN ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_RETURN)

Definition at line 1373 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_SET

#define DUK_HEAP_STRING_SET ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SET)

Definition at line 1154 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_SET_PROTOTYPE_OF

#define DUK_HEAP_STRING_SET_PROTOTYPE_OF ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SET_PROTOTYPE_OF)

Definition at line 1112 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_SOURCE

#define DUK_HEAP_STRING_SOURCE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SOURCE)

Definition at line 1019 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_SPACE

#define DUK_HEAP_STRING_SPACE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SPACE)

Definition at line 1076 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_STACK

#define DUK_HEAP_STRING_STACK ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_STACK)

Definition at line 1157 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_STATIC

#define DUK_HEAP_STRING_STATIC ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_STATIC)

Definition at line 1454 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_SUPER

#define DUK_HEAP_STRING_SUPER ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SUPER)

Definition at line 1421 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_SWITCH

#define DUK_HEAP_STRING_SWITCH ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SWITCH)

Definition at line 1376 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_THIS

#define DUK_HEAP_STRING_THIS ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_THIS)

Definition at line 1379 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_THROW

#define DUK_HEAP_STRING_THROW ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_THROW)

Definition at line 1382 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_TO_GMT_STRING

#define DUK_HEAP_STRING_TO_GMT_STRING ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_GMT_STRING)

Definition at line 1016 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_TO_ISO_STRING

#define DUK_HEAP_STRING_TO_ISO_STRING ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_ISO_STRING)

Definition at line 1013 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_TO_JSON

#define DUK_HEAP_STRING_TO_JSON ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_JSON)

Definition at line 1133 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_TO_LOCALE_STRING

#define DUK_HEAP_STRING_TO_LOCALE_STRING ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_LOCALE_STRING)

Definition at line 1004 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_TO_LOG_STRING

#define DUK_HEAP_STRING_TO_LOG_STRING ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_LOG_STRING)

Definition at line 1304 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_TO_STRING

#define DUK_HEAP_STRING_TO_STRING ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_STRING)

Definition at line 1130 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_TO_UTC_STRING

#define DUK_HEAP_STRING_TO_UTC_STRING ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_UTC_STRING)

Definition at line 1010 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_TRUE

#define DUK_HEAP_STRING_TRUE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TRUE)

Definition at line 1427 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_TRY

#define DUK_HEAP_STRING_TRY ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TRY)

Definition at line 1385 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_TYPE

#define DUK_HEAP_STRING_TYPE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TYPE)

Definition at line 1136 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_TYPEOF

#define DUK_HEAP_STRING_TYPEOF ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TYPEOF)

Definition at line 1388 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_UC_ARGUMENTS

#define DUK_HEAP_STRING_UC_ARGUMENTS ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_ARGUMENTS)

Definition at line 893 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_UC_BOOLEAN

#define DUK_HEAP_STRING_UC_BOOLEAN ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_BOOLEAN)

Definition at line 908 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_UC_BUFFER

#define DUK_HEAP_STRING_UC_BUFFER ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_BUFFER)

Definition at line 974 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_UC_ERROR

#define DUK_HEAP_STRING_UC_ERROR ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_ERROR)

Definition at line 920 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_UC_FUNCTION

#define DUK_HEAP_STRING_UC_FUNCTION ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_FUNCTION)

Definition at line 899 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_UC_NULL

#define DUK_HEAP_STRING_UC_NULL ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_NULL)

Definition at line 890 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_UC_NUMBER

#define DUK_HEAP_STRING_UC_NUMBER ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_NUMBER)

Definition at line 911 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_UC_OBJECT

#define DUK_HEAP_STRING_UC_OBJECT ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_OBJECT)

Definition at line 896 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_UC_POINTER

#define DUK_HEAP_STRING_UC_POINTER ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_POINTER)

Definition at line 977 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_UC_STRING

#define DUK_HEAP_STRING_UC_STRING ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_STRING)

Definition at line 905 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_UC_THREAD

#define DUK_HEAP_STRING_UC_THREAD ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_THREAD)

Definition at line 980 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_UC_UNDEFINED

#define DUK_HEAP_STRING_UC_UNDEFINED ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_UNDEFINED)

Definition at line 887 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_UINT16_ARRAY

#define DUK_HEAP_STRING_UINT16_ARRAY ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UINT16_ARRAY)

Definition at line 950 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_UINT32_ARRAY

#define DUK_HEAP_STRING_UINT32_ARRAY ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UINT32_ARRAY)

Definition at line 956 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_UINT8_ARRAY

#define DUK_HEAP_STRING_UINT8_ARRAY ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UINT8_ARRAY)

Definition at line 941 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_UINT8_CLAMPED_ARRAY

#define DUK_HEAP_STRING_UINT8_CLAMPED_ARRAY ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UINT8_CLAMPED_ARRAY)

Definition at line 944 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_VALUE

#define DUK_HEAP_STRING_VALUE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_VALUE)

Definition at line 989 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_VALUE_OF

#define DUK_HEAP_STRING_VALUE_OF ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_VALUE_OF)

Definition at line 1007 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_VAR

#define DUK_HEAP_STRING_VAR ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_VAR)

Definition at line 1391 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_VOID

#define DUK_HEAP_STRING_VOID ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_VOID)

Definition at line 1397 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_WHILE

#define DUK_HEAP_STRING_WHILE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WHILE)

Definition at line 1400 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_WITH

#define DUK_HEAP_STRING_WITH ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WITH)

Definition at line 1403 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_WRITABLE

#define DUK_HEAP_STRING_WRITABLE ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WRITABLE)

Definition at line 992 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRING_YIELD

#define DUK_HEAP_STRING_YIELD ( heap)    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_YIELD)

Definition at line 1457 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_STRINGCACHE_NOCACHE_LIMIT

#define DUK_HEAP_STRINGCACHE_NOCACHE_LIMIT   16 /* strings up to the this length are not cached */

Definition at line 6799 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAP_SWITCH_THREAD

#define DUK_HEAP_SWITCH_THREAD ( heap,
newthr )
Value:
do { \
(heap)->curr_thread = (newthr); \
} while (0)

Definition at line 6764 of file duktape-1.8.0/src/duktape.c.

6764 * To switch heap->curr_thread, use the macro below so that interrupt counters
6765 * get updated correctly. The macro allows a NULL target thread because that
6766 * happens e.g. in call handling.

◆ DUK_HEAPHDR_CHECK_FLAG_BITS

#define DUK_HEAPHDR_CHECK_FLAG_BITS ( h,
bits )   (((h)->h_flags & (bits)) != 0)

Definition at line 3663 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_CLEAR_FINALIZABLE

#define DUK_HEAPHDR_CLEAR_FINALIZABLE ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZABLE)

Definition at line 3674 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_CLEAR_FINALIZED

#define DUK_HEAPHDR_CLEAR_FINALIZED ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZED)

Definition at line 3678 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_CLEAR_FLAG_BITS

#define DUK_HEAPHDR_CLEAR_FLAG_BITS ( h,
bits )
Value:
do { \
DUK_ASSERT(((bits) & ~(DUK_HEAPHDR_FLAGS_FLAG_MASK)) == 0); \
(h)->h_flags &= ~((bits)); \
} while (0)
#define DUK_HEAPHDR_FLAGS_FLAG_MASK

Definition at line 3658 of file duktape-1.8.0/src/duktape.c.

3658#define DUK_HEAPHDR_CLEAR_FLAG_BITS(h,bits) do { \
3659 DUK_ASSERT(((bits) & ~(DUK_HEAPHDR_FLAGS_FLAG_MASK)) == 0); \
3660 (h)->h_flags &= ~((bits)); \
3661 } while (0)

◆ DUK_HEAPHDR_CLEAR_REACHABLE

#define DUK_HEAPHDR_CLEAR_REACHABLE ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_REACHABLE)

Definition at line 3666 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__mark_temproots_by_heap_scan().

◆ DUK_HEAPHDR_CLEAR_READONLY

#define DUK_HEAPHDR_CLEAR_READONLY ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_READONLY)

Definition at line 3682 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_CLEAR_TEMPROOT

#define DUK_HEAPHDR_CLEAR_TEMPROOT ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_TEMPROOT)

Definition at line 3670 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__mark_temproots_by_heap_scan().

◆ DUK_HEAPHDR_DECREF

#define DUK_HEAPHDR_DECREF ( thr,
h )   DUK_HEAPHDR_DECREF_FAST((thr),(h))

Definition at line 3828 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_DECREF_FAST

#define DUK_HEAPHDR_DECREF_FAST ( thr,
h )
Value:
do { \
duk_heaphdr *duk__h = (duk_heaphdr *) (h); \
DUK_ASSERT(duk__h != NULL); \
DUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(duk__h)); \
DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(duk__h) > 0); \
if (DUK_HEAPHDR_PREDEC_REFCOUNT(duk__h) == 0) { \
duk_heaphdr_refzero((thr), duk__h); \
} \
} \
} while (0)
#define DUK_HEAPHDR_PREDEC_REFCOUNT(h)
#define DUK_HEAPHDR_HTYPE_VALID(h)
#define DUK_HEAPHDR_GET_REFCOUNT(h)
#define DUK_HEAPHDR_NEEDS_REFCOUNT_UPDATE(h)

Definition at line 3792 of file duktape-1.8.0/src/duktape.c.

3792#define DUK_HEAPHDR_DECREF_FAST(thr,h) do { \
3793 duk_heaphdr *duk__h = (duk_heaphdr *) (h); \
3794 DUK_ASSERT(duk__h != NULL); \
3795 DUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(duk__h)); \
3796 DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(duk__h) > 0); \
3797 if (DUK_HEAPHDR_NEEDS_REFCOUNT_UPDATE(duk__h)) { \
3798 if (DUK_HEAPHDR_PREDEC_REFCOUNT(duk__h) == 0) { \
3799 duk_heaphdr_refzero((thr), duk__h); \
3800 } \
3801 } \
3802 } while (0)

◆ DUK_HEAPHDR_DECREF_SLOW

#define DUK_HEAPHDR_DECREF_SLOW ( thr,
h )
Value:
do { \
duk_heaphdr_decref((thr), (duk_heaphdr *) (h)); \
} while (0)

Definition at line 3816 of file duktape-1.8.0/src/duktape.c.

3816#define DUK_HEAPHDR_DECREF_SLOW(thr,h) do { \
3817 duk_heaphdr_decref((thr), (duk_heaphdr *) (h)); \
3818 } while (0)

◆ DUK_HEAPHDR_FLAG_FINALIZABLE

#define DUK_HEAPHDR_FLAG_FINALIZABLE   DUK_HEAPHDR_HEAP_FLAG(2) /* mark-and-sweep: finalizable (on current pass) */

Definition at line 3568 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_FLAG_FINALIZED

#define DUK_HEAPHDR_FLAG_FINALIZED   DUK_HEAPHDR_HEAP_FLAG(3) /* mark-and-sweep: finalized (on previous pass) */

Definition at line 3569 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_FLAG_REACHABLE

#define DUK_HEAPHDR_FLAG_REACHABLE   DUK_HEAPHDR_HEAP_FLAG(0) /* mark-and-sweep: reachable */

Definition at line 3566 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_FLAG_READONLY

#define DUK_HEAPHDR_FLAG_READONLY   DUK_HEAPHDR_HEAP_FLAG(4) /* read-only object, in code section */

Definition at line 3570 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_FLAG_TEMPROOT

#define DUK_HEAPHDR_FLAG_TEMPROOT   DUK_HEAPHDR_HEAP_FLAG(1) /* mark-and-sweep: children not processed */

Definition at line 3567 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_FLAGS_FLAG_MASK

#define DUK_HEAPHDR_FLAGS_FLAG_MASK   (~DUK_HEAPHDR_FLAGS_TYPE_MASK)

Definition at line 3555 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_FLAGS_HEAP_START

#define DUK_HEAPHDR_FLAGS_HEAP_START   2 /* 5 heap flags */

Definition at line 3558 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_FLAGS_TYPE_MASK

#define DUK_HEAPHDR_FLAGS_TYPE_MASK   0x00000003UL

Definition at line 3554 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_FLAGS_USER_START

#define DUK_HEAPHDR_FLAGS_USER_START   7 /* 25 user flags */

Definition at line 3559 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_GET_FLAG_RANGE

#define DUK_HEAPHDR_GET_FLAG_RANGE ( h,
m,
n )   (((h)->h_flags >> (m)) & ((1UL << (n)) - 1UL))

Definition at line 3686 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_GET_FLAGS

#define DUK_HEAPHDR_GET_FLAGS ( h)    ((h)->h_flags & DUK_HEAPHDR_FLAGS_FLAG_MASK)

Definition at line 3633 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_GET_FLAGS_RAW

#define DUK_HEAPHDR_GET_FLAGS_RAW ( h)    ((h)->h_flags)

Definition at line 3631 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_GET_NEXT

#define DUK_HEAPHDR_GET_NEXT ( heap,
h )   ((h)->h_next)

◆ DUK_HEAPHDR_GET_PREV

#define DUK_HEAPHDR_GET_PREV ( heap,
h )   ((h)->h_prev)

Definition at line 3599 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_GET_REFCOUNT

#define DUK_HEAPHDR_GET_REFCOUNT ( h)    ((h)->h_refcount)

Definition at line 3615 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_duktape_object_info().

◆ DUK_HEAPHDR_GET_TYPE

#define DUK_HEAPHDR_GET_TYPE ( h)    ((h)->h_flags & DUK_HEAPHDR_FLAGS_TYPE_MASK)

Definition at line 3638 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_duktape_object_info().

◆ DUK_HEAPHDR_H_INCLUDED

#define DUK_HEAPHDR_H_INCLUDED

Definition at line 3473 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_HAS_FINALIZABLE

#define DUK_HEAPHDR_HAS_FINALIZABLE ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZABLE)

Definition at line 3675 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__mark_finalize_list().

◆ DUK_HEAPHDR_HAS_FINALIZED

#define DUK_HEAPHDR_HAS_FINALIZED ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZED)

Definition at line 3679 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_HAS_REACHABLE

#define DUK_HEAPHDR_HAS_REACHABLE ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS((h),DUK_HEAPHDR_FLAG_REACHABLE)

Definition at line 3667 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_HAS_READONLY

◆ DUK_HEAPHDR_HAS_TEMPROOT

#define DUK_HEAPHDR_HAS_TEMPROOT ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS((h),DUK_HEAPHDR_FLAG_TEMPROOT)

Definition at line 3671 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__mark_temproots_by_heap_scan().

◆ DUK_HEAPHDR_HEAP_FLAG

#define DUK_HEAPHDR_HEAP_FLAG ( n)    (1UL << (DUK_HEAPHDR_FLAGS_HEAP_START + (n)))

Definition at line 3563 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_HEAP_FLAG_NUMBER

#define DUK_HEAPHDR_HEAP_FLAG_NUMBER ( n)    (DUK_HEAPHDR_FLAGS_HEAP_START + (n))

Definition at line 3561 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_HTYPE_VALID

#define DUK_HEAPHDR_HTYPE_VALID ( h)
Value:
( \
DUK_HEAPHDR_GET_TYPE((h)) >= DUK_HTYPE_MIN && \
DUK_HEAPHDR_GET_TYPE((h)) <= DUK_HTYPE_MAX \
)
#define DUK_HTYPE_MIN
#define DUK_HTYPE_MAX

Definition at line 3643 of file duktape-1.8.0/src/duktape.c.

3643#define DUK_HEAPHDR_HTYPE_VALID(h) ( \
3644 DUK_HEAPHDR_GET_TYPE((h)) >= DUK_HTYPE_MIN && \
3645 DUK_HEAPHDR_GET_TYPE((h)) <= DUK_HTYPE_MAX \
3646 )

Referenced by duk_tval_decref().

◆ DUK_HEAPHDR_INCREF

#define DUK_HEAPHDR_INCREF ( thr,
h )   DUK_HEAPHDR_INCREF_FAST((thr),(h))

Definition at line 3827 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_INCREF_FAST

#define DUK_HEAPHDR_INCREF_FAST ( thr,
h )
Value:
do { \
duk_heaphdr *duk__h = (duk_heaphdr *) (h); \
DUK_ASSERT(duk__h != NULL); \
DUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(duk__h)); \
DUK_HEAPHDR_PREINC_REFCOUNT(duk__h); \
} \
} while (0)

Definition at line 3784 of file duktape-1.8.0/src/duktape.c.

3784#define DUK_HEAPHDR_INCREF_FAST(thr,h) do { \
3785 duk_heaphdr *duk__h = (duk_heaphdr *) (h); \
3786 DUK_ASSERT(duk__h != NULL); \
3787 DUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(duk__h)); \
3788 if (DUK_HEAPHDR_NEEDS_REFCOUNT_UPDATE(duk__h)) { \
3789 DUK_HEAPHDR_PREINC_REFCOUNT(duk__h); \
3790 } \
3791 } while (0)

◆ DUK_HEAPHDR_INCREF_SLOW

#define DUK_HEAPHDR_INCREF_SLOW ( thr,
h )
Value:
do { \
duk_heaphdr_incref((duk_heaphdr *) (h)); \
} while (0)

Definition at line 3813 of file duktape-1.8.0/src/duktape.c.

3813#define DUK_HEAPHDR_INCREF_SLOW(thr,h) do { \
3814 duk_heaphdr_incref((duk_heaphdr *) (h)); \
3815 } while (0)

◆ DUK_HEAPHDR_INIT_NULLS

#define DUK_HEAPHDR_INIT_NULLS ( h)
Value:
do { \
DUK_HEAPHDR_SET_NEXT((h), (void *) NULL); \
DUK_HEAPHDR_SET_PREV((h), (void *) NULL); \
} while (0)

Definition at line 3696 of file duktape-1.8.0/src/duktape.c.

3696#define DUK_HEAPHDR_INIT_NULLS(h) do { \
3697 DUK_HEAPHDR_SET_NEXT((h), (void *) NULL); \
3698 DUK_HEAPHDR_SET_PREV((h), (void *) NULL); \
3699 } while (0)

◆ DUK_HEAPHDR_NEEDS_REFCOUNT_UPDATE

#define DUK_HEAPHDR_NEEDS_REFCOUNT_UPDATE ( h)    1

Definition at line 3753 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_PREDEC_REFCOUNT

#define DUK_HEAPHDR_PREDEC_REFCOUNT ( h)    (--(h)->h_refcount) /* result: updated refcount */

Definition at line 3620 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_PREINC_REFCOUNT

#define DUK_HEAPHDR_PREINC_REFCOUNT ( h)    (++(h)->h_refcount) /* result: updated refcount */

Definition at line 3619 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_tval_decref().

◆ DUK_HEAPHDR_SET_FINALIZABLE

#define DUK_HEAPHDR_SET_FINALIZABLE ( h)    DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZABLE)

Definition at line 3673 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_SET_FINALIZED

#define DUK_HEAPHDR_SET_FINALIZED ( h)    DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZED)

Definition at line 3677 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_SET_FLAG_BITS

#define DUK_HEAPHDR_SET_FLAG_BITS ( h,
bits )
Value:
do { \
DUK_ASSERT(((bits) & ~(DUK_HEAPHDR_FLAGS_FLAG_MASK)) == 0); \
(h)->h_flags |= (bits); \
} while (0)

Definition at line 3653 of file duktape-1.8.0/src/duktape.c.

3653#define DUK_HEAPHDR_SET_FLAG_BITS(h,bits) do { \
3654 DUK_ASSERT(((bits) & ~(DUK_HEAPHDR_FLAGS_FLAG_MASK)) == 0); \
3655 (h)->h_flags |= (bits); \
3656 } while (0)

◆ DUK_HEAPHDR_SET_FLAG_RANGE

#define DUK_HEAPHDR_SET_FLAG_RANGE ( h,
m,
n,
v )
Value:
do { \
(h)->h_flags = \
((h)->h_flags & (~(((1UL << (n)) - 1UL) << (m)))) \
| ((v) << (m)); \
} while (0)

Definition at line 3688 of file duktape-1.8.0/src/duktape.c.

3688#define DUK_HEAPHDR_SET_FLAG_RANGE(h,m,n,v) do { \
3689 (h)->h_flags = \
3690 ((h)->h_flags & (~(((1UL << (n)) - 1UL) << (m)))) \
3691 | ((v) << (m)); \
3692 } while (0)

◆ DUK_HEAPHDR_SET_FLAGS

#define DUK_HEAPHDR_SET_FLAGS ( h,
val )
Value:
do { \
(h)->h_flags = ((h)->h_flags & ~(DUK_HEAPHDR_FLAGS_FLAG_MASK)) | (val); \
} while (0)

Definition at line 3634 of file duktape-1.8.0/src/duktape.c.

3634#define DUK_HEAPHDR_SET_FLAGS(h,val) do { \
3635 (h)->h_flags = ((h)->h_flags & ~(DUK_HEAPHDR_FLAGS_FLAG_MASK)) | (val); \
3636 } while (0)

◆ DUK_HEAPHDR_SET_NEXT

#define DUK_HEAPHDR_SET_NEXT ( heap,
h,
val )
Value:
do { \
(h)->h_next = (val); \
} while (0)

Definition at line 3586 of file duktape-1.8.0/src/duktape.c.

3586#define DUK_HEAPHDR_SET_NEXT(heap,h,val) do { \
3587 (h)->h_next = (val); \
3588 } while (0)

Referenced by duk__init_object_parts(), and duk__queue_refzero().

◆ DUK_HEAPHDR_SET_PREV

#define DUK_HEAPHDR_SET_PREV ( heap,
h,
val )
Value:
do { \
(h)->h_prev = (val); \
} while (0)

Definition at line 3600 of file duktape-1.8.0/src/duktape.c.

3600#define DUK_HEAPHDR_SET_PREV(heap,h,val) do { \
3601 (h)->h_prev = (val); \
3602 } while (0)

Referenced by duk__init_object_parts(), and duk__queue_refzero().

◆ DUK_HEAPHDR_SET_REACHABLE

#define DUK_HEAPHDR_SET_REACHABLE ( h)    DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_REACHABLE)

Definition at line 3665 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_SET_READONLY

#define DUK_HEAPHDR_SET_READONLY ( h)    DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_READONLY)

Definition at line 3681 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_SET_REFCOUNT

#define DUK_HEAPHDR_SET_REFCOUNT ( h,
val )
Value:
do { \
(h)->h_refcount = (val); \
} while (0)

Definition at line 3616 of file duktape-1.8.0/src/duktape.c.

3616#define DUK_HEAPHDR_SET_REFCOUNT(h,val) do { \
3617 (h)->h_refcount = (val); \
3618 } while (0)

◆ DUK_HEAPHDR_SET_TEMPROOT

#define DUK_HEAPHDR_SET_TEMPROOT ( h)    DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_TEMPROOT)

Definition at line 3669 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_SET_TYPE

#define DUK_HEAPHDR_SET_TYPE ( h,
val )
Value:
do { \
(h)->h_flags = ((h)->h_flags & ~(DUK_HEAPHDR_FLAGS_TYPE_MASK)) | (val); \
} while (0)
#define DUK_HEAPHDR_FLAGS_TYPE_MASK

Definition at line 3639 of file duktape-1.8.0/src/duktape.c.

3639#define DUK_HEAPHDR_SET_TYPE(h,val) do { \
3640 (h)->h_flags = ((h)->h_flags & ~(DUK_HEAPHDR_FLAGS_TYPE_MASK)) | (val); \
3641 } while (0)

Referenced by duk__init_object_parts().

◆ DUK_HEAPHDR_SET_TYPE_AND_FLAGS

#define DUK_HEAPHDR_SET_TYPE_AND_FLAGS ( h,
tval,
fval )
Value:
do { \
(h)->h_flags = ((tval) & DUK_HEAPHDR_FLAGS_TYPE_MASK) | \
} while (0)

Definition at line 3648 of file duktape-1.8.0/src/duktape.c.

3648#define DUK_HEAPHDR_SET_TYPE_AND_FLAGS(h,tval,fval) do { \
3649 (h)->h_flags = ((tval) & DUK_HEAPHDR_FLAGS_TYPE_MASK) | \
3650 ((fval) & DUK_HEAPHDR_FLAGS_FLAG_MASK); \
3651 } while (0)

Referenced by duk__alloc_init_hstring().

◆ DUK_HEAPHDR_STRING_INIT_NULLS

#define DUK_HEAPHDR_STRING_INIT_NULLS ( h)    /* currently nop */

Definition at line 3706 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__alloc_init_hstring().

◆ DUK_HEAPHDR_USER_FLAG

#define DUK_HEAPHDR_USER_FLAG ( n)    (1UL << (DUK_HEAPHDR_FLAGS_USER_START + (n)))

Definition at line 3564 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HEAPHDR_USER_FLAG_NUMBER

#define DUK_HEAPHDR_USER_FLAG_NUMBER ( n)    (DUK_HEAPHDR_FLAGS_USER_START + (n))

Definition at line 3562 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HNATIVEFUNCTION_DECREF

#define DUK_HNATIVEFUNCTION_DECREF ( thr,
h )   DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) &(h)->obj)

Definition at line 3846 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HNATIVEFUNCTION_H_INCLUDED

#define DUK_HNATIVEFUNCTION_H_INCLUDED

Definition at line 5808 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HNATIVEFUNCTION_INCREF

#define DUK_HNATIVEFUNCTION_INCREF ( thr,
h )   DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)

Definition at line 3845 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HNATIVEFUNCTION_NARGS_MAX

#define DUK_HNATIVEFUNCTION_NARGS_MAX   ((duk_int16_t) 0x7fff)

Definition at line 5811 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HNATIVEFUNCTION_NARGS_VARARGS

#define DUK_HNATIVEFUNCTION_NARGS_VARARGS   ((duk_int16_t) -1)

Definition at line 5810 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__get_own_propdesc_raw().

◆ DUK_HOBJECT_A_ABANDON_LIMIT

#define DUK_HOBJECT_A_ABANDON_LIMIT   2 /* 25%, i.e. less than 25% used -> abandon */

Definition at line 5287 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_A_FAST_RESIZE_LIMIT

#define DUK_HOBJECT_A_FAST_RESIZE_LIMIT   9 /* 112.5%, i.e. new size less than 12.5% higher -> fast resize */

Definition at line 5283 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_A_GET_BASE

#define DUK_HOBJECT_A_GET_BASE ( heap,
h )
Value:
((duk_tval *) (void *) ( \
DUK_HOBJECT_GET_PROPS((heap), (h)) + \
DUK_HOBJECT_GET_ESIZE((h)) * (sizeof(duk_hstring *) + sizeof(duk_propvalue) + sizeof(duk_uint8_t)) + \
DUK_HOBJECT_E_FLAG_PADDING(DUK_HOBJECT_GET_ESIZE((h))) \
))
#define DUK_HOBJECT_GET_ESIZE(h)

Definition at line 5024 of file duktape-1.8.0/src/duktape.c.

5024 DUK_HOBJECT_GET_PROPS((heap), (h)) + DUK_HOBJECT_GET_ESIZE((h)) * (sizeof(duk_hstring *) + sizeof(duk_propvalue)) \
5025 ))
5026#define DUK_HOBJECT_A_GET_BASE(heap,h) \
5027 ((duk_tval *) (void *) ( \
5028 DUK_HOBJECT_GET_PROPS((heap), (h)) + \
5029 DUK_HOBJECT_GET_ESIZE((h)) * (sizeof(duk_hstring *) + sizeof(duk_propvalue) + sizeof(duk_uint8_t)) + \
#define DUK_HOBJECT_GET_PROPS(heap, h)
#define DUK_HOBJECT_A_GET_BASE(heap, h)

Referenced by duk__realloc_props().

◆ DUK_HOBJECT_A_GET_VALUE

#define DUK_HOBJECT_A_GET_VALUE ( heap,
h,
i )   (DUK_HOBJECT_A_GET_BASE((heap), (h))[(i)])

Definition at line 5115 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_A_GET_VALUE_PTR

#define DUK_HOBJECT_A_GET_VALUE_PTR ( heap,
h,
i )   (&DUK_HOBJECT_A_GET_BASE((heap), (h))[(i)])

◆ DUK_HOBJECT_A_MIN_GROW_ADD

#define DUK_HOBJECT_A_MIN_GROW_ADD   16

Definition at line 5305 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_A_MIN_GROW_DIVISOR

#define DUK_HOBJECT_A_MIN_GROW_DIVISOR   8 /* 2^3 -> 1/8 = 12.5% min growth */

Definition at line 5306 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_A_SET_VALUE

#define DUK_HOBJECT_A_SET_VALUE ( heap,
h,
i,
v )
Value:
do { \
DUK_HOBJECT_A_GET_VALUE((heap), (h), (i)) = (v); \
} while (0)

Definition at line 5138 of file duktape-1.8.0/src/duktape.c.

5138 DUK_HOBJECT_E_GET_FLAGS((heap), (h), (i)) = (duk_uint8_t) (f); \
5139 } while (0)
5140#define DUK_HOBJECT_A_SET_VALUE(heap,h,i,v) do { \
#define DUK_HOBJECT_E_GET_FLAGS(heap, h, i)

◆ DUK_HOBJECT_A_SET_VALUE_TVAL

#define DUK_HOBJECT_A_SET_VALUE_TVAL ( heap,
h,
i,
v )    DUK_HOBJECT_A_SET_VALUE((heap), (h), (i), (v)) /* alias for above */

Definition at line 5141 of file duktape-1.8.0/src/duktape.c.

5141 DUK_HOBJECT_A_GET_VALUE((heap), (h), (i)) = (v); \
5142 } while (0)
#define DUK_HOBJECT_A_GET_VALUE(heap, h, i)

◆ DUK_HOBJECT_ALIGN_TARGET

#define DUK_HOBJECT_ALIGN_TARGET   8

Definition at line 5293 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__realloc_props().

◆ DUK_HOBJECT_BOUND_CHAIN_SANITY

#define DUK_HOBJECT_BOUND_CHAIN_SANITY   10000L

Definition at line 5224 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_js_instanceof().

◆ DUK_HOBJECT_CLASS_ARGUMENTS

#define DUK_HOBJECT_CLASS_ARGUMENTS   1

Definition at line 4715 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_ARRAY

#define DUK_HOBJECT_CLASS_ARRAY   2

Definition at line 4716 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_array_prototype_to_string().

◆ DUK_HOBJECT_CLASS_ARRAYBUFFER

#define DUK_HOBJECT_CLASS_ARRAYBUFFER   19 /* implies DUK_HOBJECT_IS_BUFFEROBJECT */

Definition at line 4733 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_AS_FLAGS

◆ DUK_HOBJECT_CLASS_BOOLEAN

#define DUK_HOBJECT_CLASS_BOOLEAN   3

Definition at line 4717 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_BUFFER

#define DUK_HOBJECT_CLASS_BUFFER   16 /* custom; implies DUK_HOBJECT_IS_BUFFEROBJECT */

Definition at line 4730 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_DATAVIEW

#define DUK_HOBJECT_CLASS_DATAVIEW   20

Definition at line 4734 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_DATE

#define DUK_HOBJECT_CLASS_DATE   4

Definition at line 4718 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_DECENV

#define DUK_HOBJECT_CLASS_DECENV   15 /* custom */

Definition at line 4729 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_ERROR

#define DUK_HOBJECT_CLASS_ERROR   5

Definition at line 4719 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_FLOAT32ARRAY

#define DUK_HOBJECT_CLASS_FLOAT32ARRAY   28

Definition at line 4742 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_FLOAT64ARRAY

#define DUK_HOBJECT_CLASS_FLOAT64ARRAY   29

Definition at line 4743 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_FUNCTION

#define DUK_HOBJECT_CLASS_FUNCTION   6

◆ DUK_HOBJECT_CLASS_GLOBAL

#define DUK_HOBJECT_CLASS_GLOBAL   13

Definition at line 4727 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__declvar_helper().

◆ DUK_HOBJECT_CLASS_INT16ARRAY

#define DUK_HOBJECT_CLASS_INT16ARRAY   24

Definition at line 4738 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_INT32ARRAY

#define DUK_HOBJECT_CLASS_INT32ARRAY   26

Definition at line 4740 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_INT8ARRAY

#define DUK_HOBJECT_CLASS_INT8ARRAY   21

Definition at line 4735 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_JSON

#define DUK_HOBJECT_CLASS_JSON   7

Definition at line 4721 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_MATH

#define DUK_HOBJECT_CLASS_MATH   8

Definition at line 4722 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_MAX

#define DUK_HOBJECT_CLASS_MAX   29

Definition at line 4744 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_NUMBER

#define DUK_HOBJECT_CLASS_NUMBER   9

Definition at line 4723 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX

#define DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX ( n)    duk_class_number_to_stridx[(n)]

Definition at line 5231 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_OBJECT

#define DUK_HOBJECT_CLASS_OBJECT   10

Definition at line 4724 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_OBJENV

#define DUK_HOBJECT_CLASS_OBJENV   14 /* custom */

Definition at line 4728 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_POINTER

#define DUK_HOBJECT_CLASS_POINTER   17 /* custom */

Definition at line 4731 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_REGEXP

#define DUK_HOBJECT_CLASS_REGEXP   11

Definition at line 4725 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_regexp_constructor().

◆ DUK_HOBJECT_CLASS_STRING

#define DUK_HOBJECT_CLASS_STRING   12

◆ DUK_HOBJECT_CLASS_THREAD

#define DUK_HOBJECT_CLASS_THREAD   18 /* custom; implies DUK_HOBJECT_IS_THREAD */

Definition at line 4732 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_UINT16ARRAY

#define DUK_HOBJECT_CLASS_UINT16ARRAY   25

Definition at line 4739 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_UINT32ARRAY

#define DUK_HOBJECT_CLASS_UINT32ARRAY   27

Definition at line 4741 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_UINT8ARRAY

#define DUK_HOBJECT_CLASS_UINT8ARRAY   22

Definition at line 4736 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_UINT8CLAMPEDARRAY

#define DUK_HOBJECT_CLASS_UINT8CLAMPEDARRAY   23

Definition at line 4737 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLASS_UNUSED

#define DUK_HOBJECT_CLASS_UNUSED   0

Definition at line 4714 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLEAR_ARRAY_PART

#define DUK_HOBJECT_CLEAR_ARRAY_PART ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_ARRAY_PART)

Definition at line 4873 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__realloc_props().

◆ DUK_HOBJECT_CLEAR_BOUND

#define DUK_HOBJECT_CLEAR_BOUND ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BOUND)

Definition at line 4868 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLEAR_BUFFEROBJECT

#define DUK_HOBJECT_CLEAR_BUFFEROBJECT ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BUFFEROBJECT)

Definition at line 4871 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLEAR_COMPILEDFUNCTION

#define DUK_HOBJECT_CLEAR_COMPILEDFUNCTION ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_COMPILEDFUNCTION)

Definition at line 4869 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLEAR_CONSTRUCTABLE

#define DUK_HOBJECT_CLEAR_CONSTRUCTABLE ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_CONSTRUCTABLE)

Definition at line 4867 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLEAR_CREATEARGS

#define DUK_HOBJECT_CLEAR_CREATEARGS ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_CREATEARGS)

Definition at line 4878 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLEAR_ENVRECCLOSED

#define DUK_HOBJECT_CLEAR_ENVRECCLOSED ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_ENVRECCLOSED)

Definition at line 4879 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLEAR_EXOTIC_ARGUMENTS

#define DUK_HOBJECT_CLEAR_EXOTIC_ARGUMENTS ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_ARGUMENTS)

Definition at line 4882 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLEAR_EXOTIC_ARRAY

#define DUK_HOBJECT_CLEAR_EXOTIC_ARRAY ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_ARRAY)

Definition at line 4880 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLEAR_EXOTIC_DUKFUNC

#define DUK_HOBJECT_CLEAR_EXOTIC_DUKFUNC ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC)

Definition at line 4883 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLEAR_EXOTIC_PROXYOBJ

#define DUK_HOBJECT_CLEAR_EXOTIC_PROXYOBJ ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ)

Definition at line 4884 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLEAR_EXOTIC_STRINGOBJ

#define DUK_HOBJECT_CLEAR_EXOTIC_STRINGOBJ ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ)

Definition at line 4881 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLEAR_EXTENSIBLE

#define DUK_HOBJECT_CLEAR_EXTENSIBLE ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXTENSIBLE)

Definition at line 4866 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLEAR_NAMEBINDING

#define DUK_HOBJECT_CLEAR_NAMEBINDING ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NAMEBINDING)

Definition at line 4877 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLEAR_NATIVEFUNCTION

#define DUK_HOBJECT_CLEAR_NATIVEFUNCTION ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NATIVEFUNCTION)

Definition at line 4870 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLEAR_NEWENV

#define DUK_HOBJECT_CLEAR_NEWENV ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NEWENV)

Definition at line 4876 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLEAR_NOTAIL

#define DUK_HOBJECT_CLEAR_NOTAIL ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NOTAIL)

Definition at line 4875 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLEAR_STRICT

#define DUK_HOBJECT_CLEAR_STRICT ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_STRICT)

Definition at line 4874 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CLEAR_THREAD

#define DUK_HOBJECT_CLEAR_THREAD ( h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_THREAD)

Definition at line 4872 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_ALL

#define DUK_HOBJECT_CMASK_ALL   ((1UL << (DUK_HOBJECT_CLASS_MAX + 1)) - 1UL)

Definition at line 4747 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_ALL_BUFFEROBJECTS

#define DUK_HOBJECT_CMASK_ALL_BUFFEROBJECTS
Value:
#define DUK_HOBJECT_CMASK_INT16ARRAY
#define DUK_HOBJECT_CMASK_ARRAYBUFFER
#define DUK_HOBJECT_CMASK_BUFFER
#define DUK_HOBJECT_CMASK_FLOAT32ARRAY
#define DUK_HOBJECT_CMASK_INT8ARRAY
#define DUK_HOBJECT_CMASK_DATAVIEW
#define DUK_HOBJECT_CMASK_UINT8CLAMPEDARRAY
#define DUK_HOBJECT_CMASK_UINT16ARRAY
#define DUK_HOBJECT_CMASK_UINT8ARRAY
#define DUK_HOBJECT_CMASK_UINT32ARRAY
#define DUK_HOBJECT_CMASK_INT32ARRAY
#define DUK_HOBJECT_CMASK_FLOAT64ARRAY

Definition at line 4779 of file duktape-1.8.0/src/duktape.c.

4779#define DUK_HOBJECT_CMASK_ALL_BUFFEROBJECTS \
4780 (DUK_HOBJECT_CMASK_BUFFER | \
4781 DUK_HOBJECT_CMASK_ARRAYBUFFER | \
4782 DUK_HOBJECT_CMASK_DATAVIEW | \
4783 DUK_HOBJECT_CMASK_INT8ARRAY | \
4784 DUK_HOBJECT_CMASK_UINT8ARRAY | \
4785 DUK_HOBJECT_CMASK_UINT8CLAMPEDARRAY | \
4786 DUK_HOBJECT_CMASK_INT16ARRAY | \
4787 DUK_HOBJECT_CMASK_UINT16ARRAY | \
4788 DUK_HOBJECT_CMASK_INT32ARRAY | \
4789 DUK_HOBJECT_CMASK_UINT32ARRAY | \
4790 DUK_HOBJECT_CMASK_FLOAT32ARRAY | \
4791 DUK_HOBJECT_CMASK_FLOAT64ARRAY)

◆ DUK_HOBJECT_CMASK_ARGUMENTS

#define DUK_HOBJECT_CMASK_ARGUMENTS   (1UL << DUK_HOBJECT_CLASS_ARGUMENTS)

Definition at line 4749 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_ARRAY

#define DUK_HOBJECT_CMASK_ARRAY   (1UL << DUK_HOBJECT_CLASS_ARRAY)

Definition at line 4750 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_ARRAYBUFFER

#define DUK_HOBJECT_CMASK_ARRAYBUFFER   (1UL << DUK_HOBJECT_CLASS_ARRAYBUFFER)

Definition at line 4767 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_BOOLEAN

#define DUK_HOBJECT_CMASK_BOOLEAN   (1UL << DUK_HOBJECT_CLASS_BOOLEAN)

Definition at line 4751 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_BUFFER

#define DUK_HOBJECT_CMASK_BUFFER   (1UL << DUK_HOBJECT_CLASS_BUFFER)

Definition at line 4764 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_DATAVIEW

#define DUK_HOBJECT_CMASK_DATAVIEW   (1UL << DUK_HOBJECT_CLASS_DATAVIEW)

Definition at line 4768 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_DATE

#define DUK_HOBJECT_CMASK_DATE   (1UL << DUK_HOBJECT_CLASS_DATE)

Definition at line 4752 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_DECENV

#define DUK_HOBJECT_CMASK_DECENV   (1UL << DUK_HOBJECT_CLASS_DECENV)

Definition at line 4763 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_ERROR

#define DUK_HOBJECT_CMASK_ERROR   (1UL << DUK_HOBJECT_CLASS_ERROR)

Definition at line 4753 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_FLOAT32ARRAY

#define DUK_HOBJECT_CMASK_FLOAT32ARRAY   (1UL << DUK_HOBJECT_CLASS_FLOAT32ARRAY)

Definition at line 4776 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_FLOAT64ARRAY

#define DUK_HOBJECT_CMASK_FLOAT64ARRAY   (1UL << DUK_HOBJECT_CLASS_FLOAT64ARRAY)

Definition at line 4777 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_FUNCTION

#define DUK_HOBJECT_CMASK_FUNCTION   (1UL << DUK_HOBJECT_CLASS_FUNCTION)

Definition at line 4754 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_GLOBAL

#define DUK_HOBJECT_CMASK_GLOBAL   (1UL << DUK_HOBJECT_CLASS_GLOBAL)

Definition at line 4761 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_INT16ARRAY

#define DUK_HOBJECT_CMASK_INT16ARRAY   (1UL << DUK_HOBJECT_CLASS_INT16ARRAY)

Definition at line 4772 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_INT32ARRAY

#define DUK_HOBJECT_CMASK_INT32ARRAY   (1UL << DUK_HOBJECT_CLASS_INT32ARRAY)

Definition at line 4774 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_INT8ARRAY

#define DUK_HOBJECT_CMASK_INT8ARRAY   (1UL << DUK_HOBJECT_CLASS_INT8ARRAY)

Definition at line 4769 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_JSON

#define DUK_HOBJECT_CMASK_JSON   (1UL << DUK_HOBJECT_CLASS_JSON)

Definition at line 4755 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_MATH

#define DUK_HOBJECT_CMASK_MATH   (1UL << DUK_HOBJECT_CLASS_MATH)

Definition at line 4756 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_NUMBER

#define DUK_HOBJECT_CMASK_NUMBER   (1UL << DUK_HOBJECT_CLASS_NUMBER)

Definition at line 4757 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_OBJECT

#define DUK_HOBJECT_CMASK_OBJECT   (1UL << DUK_HOBJECT_CLASS_OBJECT)

Definition at line 4758 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_OBJENV

#define DUK_HOBJECT_CMASK_OBJENV   (1UL << DUK_HOBJECT_CLASS_OBJENV)

Definition at line 4762 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_POINTER

#define DUK_HOBJECT_CMASK_POINTER   (1UL << DUK_HOBJECT_CLASS_POINTER)

Definition at line 4765 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_REGEXP

#define DUK_HOBJECT_CMASK_REGEXP   (1UL << DUK_HOBJECT_CLASS_REGEXP)

Definition at line 4759 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_STRING

#define DUK_HOBJECT_CMASK_STRING   (1UL << DUK_HOBJECT_CLASS_STRING)

Definition at line 4760 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_THREAD

#define DUK_HOBJECT_CMASK_THREAD   (1UL << DUK_HOBJECT_CLASS_THREAD)

Definition at line 4766 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_UINT16ARRAY

#define DUK_HOBJECT_CMASK_UINT16ARRAY   (1UL << DUK_HOBJECT_CLASS_UINT16ARRAY)

Definition at line 4773 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_UINT32ARRAY

#define DUK_HOBJECT_CMASK_UINT32ARRAY   (1UL << DUK_HOBJECT_CLASS_UINT32ARRAY)

Definition at line 4775 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_UINT8ARRAY

#define DUK_HOBJECT_CMASK_UINT8ARRAY   (1UL << DUK_HOBJECT_CLASS_UINT8ARRAY)

Definition at line 4770 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_UINT8CLAMPEDARRAY

#define DUK_HOBJECT_CMASK_UINT8CLAMPEDARRAY   (1UL << DUK_HOBJECT_CLASS_UINT8CLAMPEDARRAY)

Definition at line 4771 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_CMASK_UNUSED

#define DUK_HOBJECT_CMASK_UNUSED   (1UL << DUK_HOBJECT_CLASS_UNUSED)

Definition at line 4748 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_DECREF

#define DUK_HOBJECT_DECREF ( thr,
h )   DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) (h))

Definition at line 3840 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_DECREF_ALLOWNULL

#define DUK_HOBJECT_DECREF_ALLOWNULL ( thr,
h )
Value:
do { \
if ((h) != NULL) { \
DUK_HEAPHDR_DECREF((thr), (duk_heaphdr *) (h)); \
} \
} while (0)

Definition at line 3860 of file duktape-1.8.0/src/duktape.c.

3860#define DUK_HOBJECT_DECREF_ALLOWNULL(thr,h) do { \
3861 if ((h) != NULL) { \
3862 DUK_HEAPHDR_DECREF((thr), (duk_heaphdr *) (h)); \
3863 } \
3864 } while (0)

Referenced by duk__declvar_helper(), and duk_hobject_define_property_helper().

◆ DUK_HOBJECT_E_CLEAR_FLAG_BITS

#define DUK_HOBJECT_E_CLEAR_FLAG_BITS ( heap,
h,
i,
mask )
Value:
do { \
DUK_HOBJECT_E_GET_FLAGS_BASE((heap), (h))[(i)] &= ~(mask); \
} while (0)
#define mask(n)

Definition at line 5151 of file duktape-1.8.0/src/duktape.c.

5151 } while (0)
5152
5153#define DUK_HOBJECT_E_CLEAR_FLAG_BITS(heap,h,i,mask) do { \

◆ DUK_HOBJECT_E_FLAG_PADDING

#define DUK_HOBJECT_E_FLAG_PADDING ( e_sz)    ((8 - (e_sz)) & 0x07)

Definition at line 5005 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_E_GET_FLAGS

#define DUK_HOBJECT_E_GET_FLAGS ( heap,
h,
i )   (DUK_HOBJECT_E_GET_FLAGS_BASE((heap), (h))[(i)])

◆ DUK_HOBJECT_E_GET_FLAGS_BASE

#define DUK_HOBJECT_E_GET_FLAGS_BASE ( heap,
h )
Value:
((duk_uint8_t *) (void *) ( \
DUK_HOBJECT_GET_PROPS((heap), (h)) + DUK_HOBJECT_GET_ESIZE((h)) * (sizeof(duk_hstring *) + sizeof(duk_propvalue)) \
))

Definition at line 5020 of file duktape-1.8.0/src/duktape.c.

5020 DUK_HOBJECT_GET_PROPS((heap), (h)) \
5021 ))
5022#define DUK_HOBJECT_E_GET_FLAGS_BASE(heap,h) \
5023 ((duk_uint8_t *) (void *) ( \

◆ DUK_HOBJECT_E_GET_FLAGS_PTR

#define DUK_HOBJECT_E_GET_FLAGS_PTR ( heap,
h,
i )   (&DUK_HOBJECT_E_GET_FLAGS_BASE((heap), (h))[(i)])

Definition at line 5114 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_E_GET_KEY

#define DUK_HOBJECT_E_GET_KEY ( heap,
h,
i )   (DUK_HOBJECT_E_GET_KEY_BASE((heap), (h))[(i)])

Definition at line 5103 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__realloc_props(), and duk__sort_array_indices().

◆ DUK_HOBJECT_E_GET_KEY_BASE

#define DUK_HOBJECT_E_GET_KEY_BASE ( heap,
h )
Value:
((duk_hstring **) (void *) ( \
DUK_HOBJECT_GET_PROPS((heap), (h)) + \
DUK_HOBJECT_GET_ESIZE((h)) * sizeof(duk_propvalue) \
))
union duk_propvalue duk_propvalue

Definition at line 5011 of file duktape-1.8.0/src/duktape.c.

5011#error invalid DUK_USE_ALIGN_BY
5012#endif
5013#define DUK_HOBJECT_E_GET_KEY_BASE(heap,h) \
5014 ((duk_hstring **) (void *) ( \
5015 DUK_HOBJECT_GET_PROPS((heap), (h)) + \

Referenced by duk__sort_array_indices().

◆ DUK_HOBJECT_E_GET_KEY_PTR

#define DUK_HOBJECT_E_GET_KEY_PTR ( heap,
h,
i )   (&DUK_HOBJECT_E_GET_KEY_BASE((heap), (h))[(i)])

Definition at line 5104 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__sort_array_indices().

◆ DUK_HOBJECT_E_GET_VALUE

#define DUK_HOBJECT_E_GET_VALUE ( heap,
h,
i )   (DUK_HOBJECT_E_GET_VALUE_BASE((heap), (h))[(i)])

Definition at line 5105 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__realloc_props().

◆ DUK_HOBJECT_E_GET_VALUE_BASE

#define DUK_HOBJECT_E_GET_VALUE_BASE ( heap,
h )
Value:
((duk_propvalue *) (void *) ( \
DUK_HOBJECT_GET_PROPS((heap), (h)) \
))

Definition at line 5016 of file duktape-1.8.0/src/duktape.c.

5016 DUK_HOBJECT_GET_ESIZE((h)) * sizeof(duk_propvalue) \
5017 ))
5018#define DUK_HOBJECT_E_GET_VALUE_BASE(heap,h) \
5019 ((duk_propvalue *) (void *) ( \
#define DUK_HOBJECT_E_GET_VALUE_BASE(heap, h)

◆ DUK_HOBJECT_E_GET_VALUE_GETTER

#define DUK_HOBJECT_E_GET_VALUE_GETTER ( heap,
h,
i )   (DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).a.get)

◆ DUK_HOBJECT_E_GET_VALUE_GETTER_PTR

#define DUK_HOBJECT_E_GET_VALUE_GETTER_PTR ( heap,
h,
i )   (&DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).a.get)

Definition at line 5110 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_E_GET_VALUE_PTR

#define DUK_HOBJECT_E_GET_VALUE_PTR ( heap,
h,
i )   (&DUK_HOBJECT_E_GET_VALUE_BASE((heap), (h))[(i)])

Definition at line 5106 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_E_GET_VALUE_SETTER

#define DUK_HOBJECT_E_GET_VALUE_SETTER ( heap,
h,
i )   (DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).a.set)

◆ DUK_HOBJECT_E_GET_VALUE_SETTER_PTR

#define DUK_HOBJECT_E_GET_VALUE_SETTER_PTR ( heap,
h,
i )   (&DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).a.set)

Definition at line 5112 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_E_GET_VALUE_TVAL

#define DUK_HOBJECT_E_GET_VALUE_TVAL ( heap,
h,
i )   (DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).v)

Definition at line 5107 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_E_GET_VALUE_TVAL_PTR

◆ DUK_HOBJECT_E_MIN_GROW_ADD

#define DUK_HOBJECT_E_MIN_GROW_ADD   16

Definition at line 5301 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_E_MIN_GROW_DIVISOR

#define DUK_HOBJECT_E_MIN_GROW_DIVISOR   8 /* 2^3 -> 1/8 = 12.5% min growth */

Definition at line 5302 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_E_SET_FLAG_BITS

#define DUK_HOBJECT_E_SET_FLAG_BITS ( heap,
h,
i,
mask )
Value:
do { \
DUK_HOBJECT_E_GET_FLAGS_BASE((heap), (h))[(i)] |= (mask); \
} while (0)

Definition at line 5147 of file duktape-1.8.0/src/duktape.c.

5147 } while (0)
5148
5149#define DUK_HOBJECT_E_SET_FLAG_BITS(heap,h,i,mask) do { \

◆ DUK_HOBJECT_E_SET_FLAGS

#define DUK_HOBJECT_E_SET_FLAGS ( heap,
h,
i,
f )
Value:
do { \
DUK_HOBJECT_E_GET_FLAGS((heap), (h), (i)) = (duk_uint8_t) (f); \
} while (0)

Definition at line 5135 of file duktape-1.8.0/src/duktape.c.

5135 DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).a.set = (v); \
5136 } while (0)
5137#define DUK_HOBJECT_E_SET_FLAGS(heap,h,i,f) do { \
#define DUK_HOBJECT_E_GET_VALUE(heap, h, i)

Referenced by duk__declvar_helper(), duk_hobject_define_property_helper(), duk_hobject_define_property_internal(), and duk_hobject_putprop().

◆ DUK_HOBJECT_E_SET_KEY

#define DUK_HOBJECT_E_SET_KEY ( heap,
h,
i,
k )
Value:
do { \
DUK_HOBJECT_E_GET_KEY((heap), (h), (i)) = (k); \
} while (0)

Definition at line 5120 of file duktape-1.8.0/src/duktape.c.

5120#define DUK_HOBJECT_H_GET_INDEX_PTR(heap,h,i) (&DUK_HOBJECT_H_GET_BASE((heap), (h))[(i)])
5121
5122#define DUK_HOBJECT_E_SET_KEY(heap,h,i,k) do { \

◆ DUK_HOBJECT_E_SET_VALUE

#define DUK_HOBJECT_E_SET_VALUE ( heap,
h,
i,
v )
Value:
do { \
DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)) = (v); \
} while (0)

Definition at line 5123 of file duktape-1.8.0/src/duktape.c.

5123 DUK_HOBJECT_E_GET_KEY((heap), (h), (i)) = (k); \
5124 } while (0)
5125#define DUK_HOBJECT_E_SET_VALUE(heap,h,i,v) do { \
#define DUK_HOBJECT_E_GET_KEY(heap, h, i)

◆ DUK_HOBJECT_E_SET_VALUE_GETTER

#define DUK_HOBJECT_E_SET_VALUE_GETTER ( heap,
h,
i,
v )
Value:
do { \
DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).a.get = (v); \
} while (0)

Definition at line 5129 of file duktape-1.8.0/src/duktape.c.

5129 DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).v = (v); \
5130 } while (0)
5131#define DUK_HOBJECT_E_SET_VALUE_GETTER(heap,h,i,v) do { \

Referenced by duk__declvar_helper(), and duk_hobject_define_property_helper().

◆ DUK_HOBJECT_E_SET_VALUE_SETTER

#define DUK_HOBJECT_E_SET_VALUE_SETTER ( heap,
h,
i,
v )
Value:
do { \
DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).a.set = (v); \
} while (0)

Definition at line 5132 of file duktape-1.8.0/src/duktape.c.

5132 DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).a.get = (v); \
5133 } while (0)
5134#define DUK_HOBJECT_E_SET_VALUE_SETTER(heap,h,i,v) do { \

Referenced by duk__declvar_helper(), and duk_hobject_define_property_helper().

◆ DUK_HOBJECT_E_SET_VALUE_TVAL

#define DUK_HOBJECT_E_SET_VALUE_TVAL ( heap,
h,
i,
v )
Value:
do { \
DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).v = (v); \
} while (0)

Definition at line 5126 of file duktape-1.8.0/src/duktape.c.

5126 DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)) = (v); \
5127 } while (0)
5128#define DUK_HOBJECT_E_SET_VALUE_TVAL(heap,h,i,v) do { \

◆ DUK_HOBJECT_E_SLOT_CLEAR_ACCESSOR

#define DUK_HOBJECT_E_SLOT_CLEAR_ACCESSOR ( heap,
h,
i )   DUK_HOBJECT_E_CLEAR_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_ACCESSOR)

Definition at line 5168 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_define_property_helper().

◆ DUK_HOBJECT_E_SLOT_CLEAR_CONFIGURABLE

#define DUK_HOBJECT_E_SLOT_CLEAR_CONFIGURABLE ( heap,
h,
i )   DUK_HOBJECT_E_CLEAR_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_CONFIGURABLE)

Definition at line 5167 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_E_SLOT_CLEAR_ENUMERABLE

#define DUK_HOBJECT_E_SLOT_CLEAR_ENUMERABLE ( heap,
h,
i )   DUK_HOBJECT_E_CLEAR_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_ENUMERABLE)

Definition at line 5166 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_E_SLOT_CLEAR_WRITABLE

#define DUK_HOBJECT_E_SLOT_CLEAR_WRITABLE ( heap,
h,
i )   DUK_HOBJECT_E_CLEAR_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_WRITABLE)

Definition at line 5165 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_define_property_helper().

◆ DUK_HOBJECT_E_SLOT_IS_ACCESSOR

#define DUK_HOBJECT_E_SLOT_IS_ACCESSOR ( heap,
h,
i )   ((DUK_HOBJECT_E_GET_FLAGS((heap), (h), (i)) & DUK_PROPDESC_FLAG_ACCESSOR) != 0)

◆ DUK_HOBJECT_E_SLOT_IS_CONFIGURABLE

#define DUK_HOBJECT_E_SLOT_IS_CONFIGURABLE ( heap,
h,
i )   ((DUK_HOBJECT_E_GET_FLAGS((heap), (h), (i)) & DUK_PROPDESC_FLAG_CONFIGURABLE) != 0)

Definition at line 5157 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_E_SLOT_IS_ENUMERABLE

#define DUK_HOBJECT_E_SLOT_IS_ENUMERABLE ( heap,
h,
i )   ((DUK_HOBJECT_E_GET_FLAGS((heap), (h), (i)) & DUK_PROPDESC_FLAG_ENUMERABLE) != 0)

Definition at line 5156 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_E_SLOT_IS_WRITABLE

#define DUK_HOBJECT_E_SLOT_IS_WRITABLE ( heap,
h,
i )   ((DUK_HOBJECT_E_GET_FLAGS((heap), (h), (i)) & DUK_PROPDESC_FLAG_WRITABLE) != 0)

Definition at line 5155 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_E_SLOT_SET_ACCESSOR

#define DUK_HOBJECT_E_SLOT_SET_ACCESSOR ( heap,
h,
i )   DUK_HOBJECT_E_SET_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_ACCESSOR)

Definition at line 5163 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_define_property_helper().

◆ DUK_HOBJECT_E_SLOT_SET_CONFIGURABLE

#define DUK_HOBJECT_E_SLOT_SET_CONFIGURABLE ( heap,
h,
i )   DUK_HOBJECT_E_SET_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_CONFIGURABLE)

Definition at line 5162 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_E_SLOT_SET_ENUMERABLE

#define DUK_HOBJECT_E_SLOT_SET_ENUMERABLE ( heap,
h,
i )   DUK_HOBJECT_E_SET_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_ENUMERABLE)

Definition at line 5161 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_E_SLOT_SET_WRITABLE

#define DUK_HOBJECT_E_SLOT_SET_WRITABLE ( heap,
h,
i )   DUK_HOBJECT_E_SET_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_WRITABLE)

Definition at line 5160 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_E_USE_HASH_LIMIT

#define DUK_HOBJECT_E_USE_HASH_LIMIT   32

Definition at line 5277 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_EXOTIC_BEHAVIOR_FLAGS

#define DUK_HOBJECT_EXOTIC_BEHAVIOR_FLAGS
Value:

Definition at line 4817 of file duktape-1.8.0/src/duktape.c.

4817#define DUK_HOBJECT_EXOTIC_BEHAVIOR_FLAGS (DUK_HOBJECT_FLAG_EXOTIC_ARRAY | \
4818 DUK_HOBJECT_FLAG_EXOTIC_ARGUMENTS | \
4819 DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ | \
4820 DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC | \
4821 DUK_HOBJECT_FLAG_BUFFEROBJECT | \
4822 DUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ)

◆ DUK_HOBJECT_FLAG_ARRAY_PART

#define DUK_HOBJECT_FLAG_ARRAY_PART   DUK_HEAPHDR_USER_FLAG(8) /* object has an array part (a_size may still be 0) */

Definition at line 4682 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_FLAG_BOUND

#define DUK_HOBJECT_FLAG_BOUND   DUK_HEAPHDR_USER_FLAG(2) /* object established using Function.prototype.bind() */

Definition at line 4677 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_FLAG_BUFFEROBJECT

#define DUK_HOBJECT_FLAG_BUFFEROBJECT   DUK_HEAPHDR_USER_FLAG(6) /* object is a buffer object (duk_hbufferobject) (always exotic) */

Definition at line 4680 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_buffer_slice_shared().

◆ DUK_HOBJECT_FLAG_CLASS_BASE

#define DUK_HOBJECT_FLAG_CLASS_BASE   DUK_HEAPHDR_USER_FLAG_NUMBER(20)

Definition at line 4695 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_FLAG_CLASS_BITS

#define DUK_HOBJECT_FLAG_CLASS_BITS   5

Definition at line 4696 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_FLAG_COMPILEDFUNCTION

#define DUK_HOBJECT_FLAG_COMPILEDFUNCTION   DUK_HEAPHDR_USER_FLAG(4) /* object is a compiled function (duk_hcompiledfunction) */

Definition at line 4678 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_FLAG_CONSTRUCTABLE

#define DUK_HOBJECT_FLAG_CONSTRUCTABLE   DUK_HEAPHDR_USER_FLAG(1) /* object is constructable */

◆ DUK_HOBJECT_FLAG_CREATEARGS

#define DUK_HOBJECT_FLAG_CREATEARGS   DUK_HEAPHDR_USER_FLAG(13) /* function: create an arguments object on function call */

Definition at line 4687 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_FLAG_ENVRECCLOSED

#define DUK_HOBJECT_FLAG_ENVRECCLOSED   DUK_HEAPHDR_USER_FLAG(14) /* envrec: (declarative) record is closed */

Definition at line 4688 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_FLAG_EXOTIC_ARGUMENTS

#define DUK_HOBJECT_FLAG_EXOTIC_ARGUMENTS   DUK_HEAPHDR_USER_FLAG(17) /* 'Arguments' object and has arguments exotic behavior (non-strict callee) */

Definition at line 4691 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_FLAG_EXOTIC_ARRAY

#define DUK_HOBJECT_FLAG_EXOTIC_ARRAY   DUK_HEAPHDR_USER_FLAG(15) /* 'Array' object, array length and index exotic behavior */

Definition at line 4689 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC

#define DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC   DUK_HEAPHDR_USER_FLAG(18) /* Duktape/C (nativefunction) object, exotic 'length' */

Definition at line 4692 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_push_c_function_noexotic().

◆ DUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ

#define DUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ   DUK_HEAPHDR_USER_FLAG(19) /* 'Proxy' object */

Definition at line 4693 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ

#define DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ   DUK_HEAPHDR_USER_FLAG(16) /* 'String' object, array index exotic behavior */

◆ DUK_HOBJECT_FLAG_EXTENSIBLE

◆ DUK_HOBJECT_FLAG_NAMEBINDING

#define DUK_HOBJECT_FLAG_NAMEBINDING   DUK_HEAPHDR_USER_FLAG(12) /* function: create binding for func name (function templates only, used for named function expressions) */

Definition at line 4686 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_FLAG_NATIVEFUNCTION

#define DUK_HOBJECT_FLAG_NATIVEFUNCTION   DUK_HEAPHDR_USER_FLAG(5) /* object is a native function (duk_hnativefunction) */

◆ DUK_HOBJECT_FLAG_NEWENV

#define DUK_HOBJECT_FLAG_NEWENV   DUK_HEAPHDR_USER_FLAG(11) /* function: create new environment when called (see duk_hcompiledfunction) */

◆ DUK_HOBJECT_FLAG_NOTAIL

#define DUK_HOBJECT_FLAG_NOTAIL   DUK_HEAPHDR_USER_FLAG(10) /* function: function must not be tail called */

◆ DUK_HOBJECT_FLAG_STRICT

#define DUK_HOBJECT_FLAG_STRICT   DUK_HEAPHDR_USER_FLAG(9) /* function: function object is strict */

◆ DUK_HOBJECT_FLAG_THREAD

#define DUK_HOBJECT_FLAG_THREAD   DUK_HEAPHDR_USER_FLAG(7) /* object is a thread (duk_hthread) */

Definition at line 4681 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_GET_ASIZE

◆ DUK_HOBJECT_GET_CLASS_MASK

#define DUK_HOBJECT_GET_CLASS_MASK ( h)     (1UL << DUK_HEAPHDR_GET_FLAG_RANGE(&(h)->hdr, DUK_HOBJECT_FLAG_CLASS_BASE, DUK_HOBJECT_FLAG_CLASS_BITS))

Definition at line 4703 of file duktape-1.8.0/src/duktape.c.

4703#define DUK_HOBJECT_GET_CLASS_MASK(h) \
4704 (1UL << DUK_HEAPHDR_GET_FLAG_RANGE(&(h)->hdr, DUK_HOBJECT_FLAG_CLASS_BASE, DUK_HOBJECT_FLAG_CLASS_BITS))

◆ DUK_HOBJECT_GET_CLASS_NUMBER

#define DUK_HOBJECT_GET_CLASS_NUMBER ( h)     DUK_HEAPHDR_GET_FLAG_RANGE(&(h)->hdr, DUK_HOBJECT_FLAG_CLASS_BASE, DUK_HOBJECT_FLAG_CLASS_BITS)

Definition at line 4698 of file duktape-1.8.0/src/duktape.c.

4698#define DUK_HOBJECT_GET_CLASS_NUMBER(h) \
4699 DUK_HEAPHDR_GET_FLAG_RANGE(&(h)->hdr, DUK_HOBJECT_FLAG_CLASS_BASE, DUK_HOBJECT_FLAG_CLASS_BITS)

Referenced by duk__declvar_helper(), and duk_bi_buffer_slice_shared().

◆ DUK_HOBJECT_GET_CLASS_STRING

#define DUK_HOBJECT_GET_CLASS_STRING ( heap,
h )
Value:
(heap), \
)
#define DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(n)
#define DUK_HEAP_GET_STRING(heap, idx)

Definition at line 5233 of file duktape-1.8.0/src/duktape.c.

5233#define DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(n) duk_class_number_to_stridx[(n)]
5234
5235#define DUK_HOBJECT_GET_CLASS_STRING(heap,h) \
5236 DUK_HEAP_GET_STRING( \
5237 (heap), \

Referenced by duk_to_int_clamped_raw().

◆ DUK_HOBJECT_GET_ENEXT

#define DUK_HOBJECT_GET_ENEXT ( h)    ((h)->e_next)

◆ DUK_HOBJECT_GET_ESIZE

#define DUK_HOBJECT_GET_ESIZE ( h)    ((h)->e_size)

Definition at line 5198 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__realloc_props(), and duk_bi_duktape_object_info().

◆ DUK_HOBJECT_GET_HSIZE

#define DUK_HOBJECT_GET_HSIZE ( h)    ((h)->h_size)

Definition at line 5206 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__realloc_props(), and duk_bi_duktape_object_info().

◆ duk_hobject_get_internal_value_tval_ptr

#define duk_hobject_get_internal_value_tval_ptr ( heap,
obj )    duk_hobject_find_existing_entry_tval_ptr((heap), (obj), DUK_HEAP_STRING_INT_VALUE((heap)))

Definition at line 5484 of file duktape-1.8.0/src/duktape.c.

5484 * slot for internal value; this call can then access it directly.
5485 */
int value
Definition lsqlite3.c:2155

◆ DUK_HOBJECT_GET_PROPS

#define DUK_HOBJECT_GET_PROPS ( heap,
h )    ((h)->props)

Definition at line 4954 of file duktape-1.8.0/src/duktape.c.

4954 } while (0)
4955#else

Referenced by duk__realloc_props(), and duk_free_hobject_inner().

◆ DUK_HOBJECT_GET_PROTOTYPE

#define DUK_HOBJECT_GET_PROTOTYPE ( heap,
h )    ((h)->prototype)

◆ DUK_HOBJECT_H_GET_BASE

#define DUK_HOBJECT_H_GET_BASE ( heap,
h )
Value:
((duk_uint32_t *) (void *) ( \
DUK_HOBJECT_GET_PROPS((heap), (h)) + \
DUK_HOBJECT_GET_ESIZE((h)) * (sizeof(duk_hstring *) + sizeof(duk_propvalue) + sizeof(duk_uint8_t)) + \
DUK_HOBJECT_E_FLAG_PADDING(DUK_HOBJECT_GET_ESIZE((h))) + \
DUK_HOBJECT_GET_ASIZE((h)) * sizeof(duk_tval) \
))

Definition at line 5030 of file duktape-1.8.0/src/duktape.c.

5031 ))
5032#define DUK_HOBJECT_H_GET_BASE(heap,h) \
5033 ((duk_uint32_t *) (void *) ( \
5034 DUK_HOBJECT_GET_PROPS((heap), (h)) + \
5035 DUK_HOBJECT_GET_ESIZE((h)) * (sizeof(duk_hstring *) + sizeof(duk_propvalue) + sizeof(duk_uint8_t)) + \
5036 DUK_HOBJECT_E_FLAG_PADDING(DUK_HOBJECT_GET_ESIZE((h))) + \
#define DUK_HOBJECT_E_FLAG_PADDING(e_sz)

◆ DUK_HOBJECT_H_GET_INDEX

#define DUK_HOBJECT_H_GET_INDEX ( heap,
h,
i )   (DUK_HOBJECT_H_GET_BASE((heap), (h))[(i)])

Definition at line 5117 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_H_GET_INDEX_PTR

#define DUK_HOBJECT_H_GET_INDEX_PTR ( heap,
h,
i )   (&DUK_HOBJECT_H_GET_BASE((heap), (h))[(i)])

Definition at line 5118 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_H_INCLUDED

#define DUK_HOBJECT_H_INCLUDED

Definition at line 4670 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_H_SET_INDEX

#define DUK_HOBJECT_H_SET_INDEX ( heap,
h,
i,
v )
Value:
do { \
DUK_HOBJECT_H_GET_INDEX((heap), (h), (i)) = (v); \
} while (0)

Definition at line 5143 of file duktape-1.8.0/src/duktape.c.

5143#define DUK_HOBJECT_A_SET_VALUE_TVAL(heap,h,i,v) \
5144 DUK_HOBJECT_A_SET_VALUE((heap), (h), (i), (v)) /* alias for above */
5145#define DUK_HOBJECT_H_SET_INDEX(heap,h,i,v) do { \

◆ DUK_HOBJECT_H_SIZE_DIVISOR

#define DUK_HOBJECT_H_SIZE_DIVISOR   4 /* hash size approx. 1.25 times entries size */

Definition at line 5280 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__get_min_grow_e().

◆ DUK_HOBJECT_HAS_ARRAY_PART

◆ DUK_HOBJECT_HAS_BOUND

#define DUK_HOBJECT_HAS_BOUND ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BOUND)

Definition at line 4828 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_handle_ecma_call_setup(), and duk_js_instanceof().

◆ DUK_HOBJECT_HAS_BUFFEROBJECT

#define DUK_HOBJECT_HAS_BUFFEROBJECT ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BUFFEROBJECT)

Definition at line 4831 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_HAS_COMPILEDFUNCTION

#define DUK_HOBJECT_HAS_COMPILEDFUNCTION ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_COMPILEDFUNCTION)

Definition at line 4829 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_handle_ecma_call_setup().

◆ DUK_HOBJECT_HAS_CONSTRUCTABLE

#define DUK_HOBJECT_HAS_CONSTRUCTABLE ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_CONSTRUCTABLE)

Definition at line 4827 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_HAS_CREATEARGS

#define DUK_HOBJECT_HAS_CREATEARGS ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_CREATEARGS)

Definition at line 4838 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_handle_ecma_call_setup().

◆ DUK_HOBJECT_HAS_ENVRECCLOSED

#define DUK_HOBJECT_HAS_ENVRECCLOSED ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_ENVRECCLOSED)

Definition at line 4839 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS

◆ DUK_HOBJECT_HAS_EXOTIC_ARRAY

#define DUK_HOBJECT_HAS_EXOTIC_ARRAY ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_ARRAY)

◆ DUK_HOBJECT_HAS_EXOTIC_BEHAVIOR

#define DUK_HOBJECT_HAS_EXOTIC_BEHAVIOR ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_EXOTIC_BEHAVIOR_FLAGS)

Definition at line 4824 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_HAS_EXOTIC_DUKFUNC

#define DUK_HOBJECT_HAS_EXOTIC_DUKFUNC ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC)

Definition at line 4843 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__get_own_propdesc_raw().

◆ DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ

#define DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ)

◆ DUK_HOBJECT_HAS_EXOTIC_STRINGOBJ

#define DUK_HOBJECT_HAS_EXOTIC_STRINGOBJ ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ)

◆ DUK_HOBJECT_HAS_EXTENSIBLE

◆ DUK_HOBJECT_HAS_NAMEBINDING

#define DUK_HOBJECT_HAS_NAMEBINDING ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NAMEBINDING)

Definition at line 4837 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_HAS_NATIVEFUNCTION

#define DUK_HOBJECT_HAS_NATIVEFUNCTION ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NATIVEFUNCTION)

◆ DUK_HOBJECT_HAS_NEWENV

#define DUK_HOBJECT_HAS_NEWENV ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NEWENV)

Definition at line 4836 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_handle_ecma_call_setup().

◆ DUK_HOBJECT_HAS_NOTAIL

#define DUK_HOBJECT_HAS_NOTAIL ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NOTAIL)

Definition at line 4835 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_handle_ecma_call_setup().

◆ DUK_HOBJECT_HAS_STRICT

#define DUK_HOBJECT_HAS_STRICT ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_STRICT)

◆ DUK_HOBJECT_HAS_THREAD

#define DUK_HOBJECT_HAS_THREAD ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_THREAD)

Definition at line 4832 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_HASH_INITIAL

#define DUK_HOBJECT_HASH_INITIAL ( hash,
h_size )   ((hash) % (h_size))

Definition at line 5309 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_HASH_PROBE_STEP

#define DUK_HOBJECT_HASH_PROBE_STEP ( hash)    DUK_UTIL_GET_HASH_PROBE_STEP((hash))

Definition at line 5310 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_HASHIDX_DELETED

#define DUK_HOBJECT_HASHIDX_DELETED   0xfffffffeUL

Definition at line 5176 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_HASHIDX_UNUSED

#define DUK_HOBJECT_HASHIDX_UNUSED   0xffffffffUL

Definition at line 5175 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_INCREF

#define DUK_HOBJECT_INCREF ( thr,
h )   DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))

◆ DUK_HOBJECT_INCREF_ALLOWNULL

#define DUK_HOBJECT_INCREF_ALLOWNULL ( thr,
h )
Value:
do { \
if ((h) != NULL) { \
DUK_HEAPHDR_INCREF((thr), (duk_heaphdr *) (h)); \
} \
} while (0)

Definition at line 3855 of file duktape-1.8.0/src/duktape.c.

3855#define DUK_HOBJECT_INCREF_ALLOWNULL(thr,h) do { \
3856 if ((h) != NULL) { \
3857 DUK_HEAPHDR_INCREF((thr), (duk_heaphdr *) (h)); \
3858 } \
3859 } while (0)

Referenced by duk_hobject_define_property_helper(), and duk_hthread_terminate().

◆ DUK_HOBJECT_IS_ARRAY

#define DUK_HOBJECT_IS_ARRAY ( h)    (DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_ARRAY)

Definition at line 4796 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_IS_BUFFEROBJECT

◆ DUK_HOBJECT_IS_CALLABLE

#define DUK_HOBJECT_IS_CALLABLE ( h)
Value:

Definition at line 4811 of file duktape-1.8.0/src/duktape.c.

4811#define DUK_HOBJECT_IS_CALLABLE(h) DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, \
4812 DUK_HOBJECT_FLAG_BOUND | \
4813 DUK_HOBJECT_FLAG_COMPILEDFUNCTION | \
4814 DUK_HOBJECT_FLAG_NATIVEFUNCTION)

Referenced by duk_hobject_prepare_property_descriptor(), and duk_js_instanceof().

◆ DUK_HOBJECT_IS_COMPILEDFUNCTION

◆ DUK_HOBJECT_IS_DECENV

#define DUK_HOBJECT_IS_DECENV ( h)    (DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_DECENV)

◆ DUK_HOBJECT_IS_ENV

#define DUK_HOBJECT_IS_ENV ( h)    (DUK_HOBJECT_IS_OBJENV((h)) || DUK_HOBJECT_IS_DECENV((h)))

Definition at line 4795 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_IS_FUNCTION

#define DUK_HOBJECT_IS_FUNCTION ( h)
Value:

Definition at line 4806 of file duktape-1.8.0/src/duktape.c.

4806#define DUK_HOBJECT_IS_FUNCTION(h) DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, \
4807 DUK_HOBJECT_FLAG_BOUND | \
4808 DUK_HOBJECT_FLAG_COMPILEDFUNCTION | \
4809 DUK_HOBJECT_FLAG_NATIVEFUNCTION)

◆ DUK_HOBJECT_IS_NATIVEFUNCTION

#define DUK_HOBJECT_IS_NATIVEFUNCTION ( h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NATIVEFUNCTION)

◆ DUK_HOBJECT_IS_NONBOUND_FUNCTION

#define DUK_HOBJECT_IS_NONBOUND_FUNCTION ( h)
Value:

Definition at line 4802 of file duktape-1.8.0/src/duktape.c.

4802#define DUK_HOBJECT_IS_NONBOUND_FUNCTION(h) DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, \
4803 DUK_HOBJECT_FLAG_COMPILEDFUNCTION | \
4804 DUK_HOBJECT_FLAG_NATIVEFUNCTION)

◆ DUK_HOBJECT_IS_OBJENV

#define DUK_HOBJECT_IS_OBJENV ( h)    (DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_OBJENV)

Definition at line 4793 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__declvar_helper().

◆ DUK_HOBJECT_IS_THREAD

◆ DUK_HOBJECT_MAX_PROPERTIES

#define DUK_HOBJECT_MAX_PROPERTIES   0x7fffffffUL /* 2**31-1 ~= 2G properties */

Definition at line 5273 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__realloc_props().

◆ DUK_HOBJECT_P_ALLOC_SIZE

#define DUK_HOBJECT_P_ALLOC_SIZE ( h)     DUK_HOBJECT_P_COMPUTE_SIZE(DUK_HOBJECT_GET_ESIZE((h)), DUK_HOBJECT_GET_ASIZE((h)), DUK_HOBJECT_GET_HSIZE((h)))

Definition at line 5100 of file duktape-1.8.0/src/duktape.c.

5100#endif /* hobject property layout */
5101

Referenced by duk_bi_duktape_object_info().

◆ DUK_HOBJECT_P_COMPUTE_SIZE

#define DUK_HOBJECT_P_COMPUTE_SIZE ( n_ent,
n_arr,
n_hash )
Value:
( \
(n_ent) * (sizeof(duk_hstring *) + sizeof(duk_propvalue) + sizeof(duk_uint8_t)) + \
(n_arr) * sizeof(duk_tval) + \
(n_hash) * sizeof(duk_uint32_t) \
)

Definition at line 5037 of file duktape-1.8.0/src/duktape.c.

5037 DUK_HOBJECT_GET_ASIZE((h)) * sizeof(duk_tval) \
5038 ))
5039#define DUK_HOBJECT_P_COMPUTE_SIZE(n_ent,n_arr,n_hash) \
5040 ( \
5041 (n_ent) * (sizeof(duk_hstring *) + sizeof(duk_propvalue) + sizeof(duk_uint8_t)) + \
5042 DUK_HOBJECT_E_FLAG_PADDING((n_ent)) + \
5043 (n_arr) * sizeof(duk_tval) + \
#define DUK_HOBJECT_P_COMPUTE_SIZE(n_ent, n_arr, n_hash)
#define DUK_HOBJECT_GET_ASIZE(h)

Referenced by duk__realloc_props().

◆ DUK_HOBJECT_P_SET_REALLOC_PTRS

#define DUK_HOBJECT_P_SET_REALLOC_PTRS ( p_base,
set_e_k,
set_e_pv,
set_e_f,
set_a,
set_h,
n_ent,
n_arr,
n_hash )
Value:
do { \
(set_e_pv) = (duk_propvalue *) (void *) (p_base); \
(set_e_k) = (duk_hstring **) (void *) ((set_e_pv) + (n_ent)); \
(set_e_f) = (duk_uint8_t *) (void *) ((set_e_k) + (n_ent)); \
(set_a) = (duk_tval *) (void *) (((duk_uint8_t *) (set_e_f)) + \
sizeof(duk_uint8_t) * (n_ent) + \
(set_h) = (duk_uint32_t *) (void *) ((set_a) + (n_arr)); \
} while (0)

Definition at line 5044 of file duktape-1.8.0/src/duktape.c.

5044 (n_hash) * sizeof(duk_uint32_t) \
5045 )
5046#define DUK_HOBJECT_P_SET_REALLOC_PTRS(p_base,set_e_k,set_e_pv,set_e_f,set_a,set_h,n_ent,n_arr,n_hash) do { \
5047 (set_e_pv) = (duk_propvalue *) (void *) (p_base); \
5048 (set_e_k) = (duk_hstring **) (void *) ((set_e_pv) + (n_ent)); \
5049 (set_e_f) = (duk_uint8_t *) (void *) ((set_e_k) + (n_ent)); \
5050 (set_a) = (duk_tval *) (void *) (((duk_uint8_t *) (set_e_f)) + \
5051 sizeof(duk_uint8_t) * (n_ent) + \
5052 DUK_HOBJECT_E_FLAG_PADDING((n_ent))); \
#define DUK_HOBJECT_P_SET_REALLOC_PTRS(p_base, set_e_k, set_e_pv, set_e_f, set_a, set_h, n_ent, n_arr, n_hash)

Referenced by duk__realloc_props().

◆ DUK_HOBJECT_POSTINC_ENEXT

#define DUK_HOBJECT_POSTINC_ENEXT ( h)    ((h)->e_next++)

Definition at line 5202 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY

#define DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY   10000L

◆ DUK_HOBJECT_SET_ARRAY_PART

#define DUK_HOBJECT_SET_ARRAY_PART ( h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_ARRAY_PART)

Definition at line 4853 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_SET_ASIZE

#define DUK_HOBJECT_SET_ASIZE ( h,
v )   do { (h)->a_size = (v); } while (0)

Definition at line 5204 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__realloc_props().

◆ DUK_HOBJECT_SET_BOUND

#define DUK_HOBJECT_SET_BOUND ( h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BOUND)

Definition at line 4848 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_SET_BUFFEROBJECT

#define DUK_HOBJECT_SET_BUFFEROBJECT ( h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BUFFEROBJECT)

Definition at line 4851 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_SET_CLASS_NUMBER

#define DUK_HOBJECT_SET_CLASS_NUMBER ( h,
v )    DUK_HEAPHDR_SET_FLAG_RANGE(&(h)->hdr, DUK_HOBJECT_FLAG_CLASS_BASE, DUK_HOBJECT_FLAG_CLASS_BITS, (v))

Definition at line 4700 of file duktape-1.8.0/src/duktape.c.

4700#define DUK_HOBJECT_SET_CLASS_NUMBER(h,v) \
4701 DUK_HEAPHDR_SET_FLAG_RANGE(&(h)->hdr, DUK_HOBJECT_FLAG_CLASS_BASE, DUK_HOBJECT_FLAG_CLASS_BITS, (v))

◆ DUK_HOBJECT_SET_COMPILEDFUNCTION

#define DUK_HOBJECT_SET_COMPILEDFUNCTION ( h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_COMPILEDFUNCTION)

Definition at line 4849 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_SET_CONSTRUCTABLE

#define DUK_HOBJECT_SET_CONSTRUCTABLE ( h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_CONSTRUCTABLE)

Definition at line 4847 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_SET_CREATEARGS

#define DUK_HOBJECT_SET_CREATEARGS ( h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_CREATEARGS)

Definition at line 4858 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_SET_ENEXT

#define DUK_HOBJECT_SET_ENEXT ( h,
v )   do { (h)->e_next = (v); } while (0)

Definition at line 5201 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__realloc_props().

◆ DUK_HOBJECT_SET_ENVRECCLOSED

#define DUK_HOBJECT_SET_ENVRECCLOSED ( h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_ENVRECCLOSED)

Definition at line 4859 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_SET_ESIZE

#define DUK_HOBJECT_SET_ESIZE ( h,
v )   do { (h)->e_size = (v); } while (0)

Definition at line 5199 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__realloc_props().

◆ DUK_HOBJECT_SET_EXOTIC_ARGUMENTS

#define DUK_HOBJECT_SET_EXOTIC_ARGUMENTS ( h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_ARGUMENTS)

Definition at line 4862 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_SET_EXOTIC_ARRAY

#define DUK_HOBJECT_SET_EXOTIC_ARRAY ( h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_ARRAY)

Definition at line 4860 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_SET_EXOTIC_DUKFUNC

#define DUK_HOBJECT_SET_EXOTIC_DUKFUNC ( h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC)

Definition at line 4863 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_SET_EXOTIC_PROXYOBJ

#define DUK_HOBJECT_SET_EXOTIC_PROXYOBJ ( h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ)

Definition at line 4864 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_SET_EXOTIC_STRINGOBJ

#define DUK_HOBJECT_SET_EXOTIC_STRINGOBJ ( h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ)

Definition at line 4861 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_SET_EXTENSIBLE

#define DUK_HOBJECT_SET_EXTENSIBLE ( h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXTENSIBLE)

Definition at line 4846 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_SET_HSIZE

#define DUK_HOBJECT_SET_HSIZE ( h,
v )   do { (h)->h_size = (v); } while (0)

Definition at line 5207 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__realloc_props().

◆ DUK_HOBJECT_SET_NAMEBINDING

#define DUK_HOBJECT_SET_NAMEBINDING ( h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NAMEBINDING)

Definition at line 4857 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_SET_NATIVEFUNCTION

#define DUK_HOBJECT_SET_NATIVEFUNCTION ( h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NATIVEFUNCTION)

Definition at line 4850 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_SET_NEWENV

#define DUK_HOBJECT_SET_NEWENV ( h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NEWENV)

Definition at line 4856 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_SET_NOTAIL

#define DUK_HOBJECT_SET_NOTAIL ( h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NOTAIL)

Definition at line 4855 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_SET_PROPS

#define DUK_HOBJECT_SET_PROPS ( heap,
h,
x )
Value:
do { \
(h)->props = (duk_uint8_t *) (x); \
} while (0)

Definition at line 4956 of file duktape-1.8.0/src/duktape.c.

4956#define DUK_HOBJECT_GET_PROPS(heap,h) \
4957 ((h)->props)
4958#define DUK_HOBJECT_SET_PROPS(heap,h,x) do { \

Referenced by duk__init_object_parts(), and duk__realloc_props().

◆ DUK_HOBJECT_SET_PROTOTYPE

#define DUK_HOBJECT_SET_PROTOTYPE ( heap,
h,
x )
Value:
do { \
(h)->prototype = (x); \
} while (0)

Definition at line 5252 of file duktape-1.8.0/src/duktape.c.

5252#define DUK_HOBJECT_GET_PROTOTYPE(heap,h) \
5253 ((h)->prototype)
5254#define DUK_HOBJECT_SET_PROTOTYPE(heap,h,x) do { \

◆ DUK_HOBJECT_SET_PROTOTYPE_UPDREF

#define DUK_HOBJECT_SET_PROTOTYPE_UPDREF ( thr,
h,
p )   duk_hobject_set_prototype_updref((thr), (h), (p))

Definition at line 5258 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_buffer_slice_shared().

◆ DUK_HOBJECT_SET_STRICT

#define DUK_HOBJECT_SET_STRICT ( h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_STRICT)

Definition at line 4854 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HOBJECT_SET_THREAD

#define DUK_HOBJECT_SET_THREAD ( h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_THREAD)

Definition at line 4852 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_CLEAR_ARRIDX

#define DUK_HSTRING_CLEAR_ARRIDX ( x)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX)

Definition at line 4483 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_CLEAR_ASCII

#define DUK_HSTRING_CLEAR_ASCII ( x)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII)

Definition at line 4482 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_CLEAR_EVAL_OR_ARGUMENTS

#define DUK_HSTRING_CLEAR_EVAL_OR_ARGUMENTS ( x)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS)

Definition at line 4487 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_CLEAR_EXTDATA

#define DUK_HSTRING_CLEAR_EXTDATA ( x)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA)

Definition at line 4488 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_CLEAR_INTERNAL

#define DUK_HSTRING_CLEAR_INTERNAL ( x)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_INTERNAL)

Definition at line 4484 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_CLEAR_RESERVED_WORD

#define DUK_HSTRING_CLEAR_RESERVED_WORD ( x)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_RESERVED_WORD)

Definition at line 4485 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_CLEAR_STRICT_RESERVED_WORD

#define DUK_HSTRING_CLEAR_STRICT_RESERVED_WORD ( x)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD)

Definition at line 4486 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_DECREF

#define DUK_HSTRING_DECREF ( thr,
h )   DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) (h))

Definition at line 3838 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_FLAG_ARRIDX

#define DUK_HSTRING_FLAG_ARRIDX   DUK_HEAPHDR_USER_FLAG(1) /* string is a valid array index */

Definition at line 4459 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_FLAG_ASCII

#define DUK_HSTRING_FLAG_ASCII   DUK_HEAPHDR_USER_FLAG(0) /* string is ASCII, clen == blen */

Definition at line 4458 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS

#define DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS   DUK_HEAPHDR_USER_FLAG(5) /* string is 'eval' or 'arguments' */

Definition at line 4463 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_FLAG_EXTDATA

#define DUK_HSTRING_FLAG_EXTDATA   DUK_HEAPHDR_USER_FLAG(6) /* string data is external (duk_hstring_external) */

Definition at line 4464 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__alloc_init_hstring().

◆ DUK_HSTRING_FLAG_INTERNAL

#define DUK_HSTRING_FLAG_INTERNAL   DUK_HEAPHDR_USER_FLAG(2) /* string is internal */

Definition at line 4460 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_FLAG_RESERVED_WORD

#define DUK_HSTRING_FLAG_RESERVED_WORD   DUK_HEAPHDR_USER_FLAG(3) /* string is a reserved word (non-strict) */

Definition at line 4461 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_FLAG_STRICT_RESERVED_WORD

#define DUK_HSTRING_FLAG_STRICT_RESERVED_WORD   DUK_HEAPHDR_USER_FLAG(4) /* string is a reserved word (strict) */

Definition at line 4462 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_GET_ARRIDX_FAST

#define DUK_HSTRING_GET_ARRIDX_FAST ( h)     (DUK_HSTRING_HAS_ARRIDX((h)) ? duk_js_to_arrayindex_string_helper((h)) : DUK_HSTRING_NO_ARRAY_INDEX)

Definition at line 4557 of file duktape-1.8.0/src/duktape.c.

4557#define DUK_HSTRING_GET_ARRIDX_FAST(h) \
4558 (DUK_HSTRING_HAS_ARRIDX((h)) ? duk_js_to_arrayindex_string_helper((h)) : DUK_HSTRING_NO_ARRAY_INDEX)

Referenced by duk__get_propdesc().

◆ DUK_HSTRING_GET_ARRIDX_SLOW

#define DUK_HSTRING_GET_ARRIDX_SLOW ( h)     (duk_js_to_arrayindex_string_helper((h)))

Definition at line 4561 of file duktape-1.8.0/src/duktape.c.

4561#define DUK_HSTRING_GET_ARRIDX_SLOW(h) \
4562 (duk_js_to_arrayindex_string_helper((h)))

Referenced by duk__sort_array_indices(), duk_hobject_define_property_helper(), and duk_hobject_define_property_internal().

◆ DUK_HSTRING_GET_BYTELEN

◆ DUK_HSTRING_GET_CHARLEN

#define DUK_HSTRING_GET_CHARLEN ( x)    ((x)->clen)

◆ DUK_HSTRING_GET_DATA

#define DUK_HSTRING_GET_DATA ( x)     ((const duk_uint8_t *) ((x) + 1))

Definition at line 4544 of file duktape-1.8.0/src/duktape.c.

4544#define DUK_HSTRING_GET_DATA(x) \
4545 ((const duk_uint8_t *) ((x) + 1))

Referenced by duk__create_escaped_source(), duk__dump_hbuffer_raw(), duk__error_getter_helper(), duk_hstring_char_code_at_raw(), and duk_to_int_clamped_raw().

◆ DUK_HSTRING_GET_DATA_END

#define DUK_HSTRING_GET_DATA_END ( x)     (DUK_HSTRING_GET_DATA((x)) + (x)->blen)

Definition at line 4548 of file duktape-1.8.0/src/duktape.c.

4548#define DUK_HSTRING_GET_DATA_END(x) \
4549 (DUK_HSTRING_GET_DATA((x)) + (x)->blen)

◆ DUK_HSTRING_GET_HASH

#define DUK_HSTRING_GET_HASH ( x)    ((x)->hash)

Definition at line 4504 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__alloc_init_hstring(), and duk__realloc_props().

◆ DUK_HSTRING_H_INCLUDED

#define DUK_HSTRING_H_INCLUDED

Definition at line 4435 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_HAS_ARRIDX

#define DUK_HSTRING_HAS_ARRIDX ( x)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX)

Definition at line 4467 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__alloc_init_hstring().

◆ DUK_HSTRING_HAS_ASCII

#define DUK_HSTRING_HAS_ASCII ( x)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII)

Definition at line 4466 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__alloc_init_hstring().

◆ DUK_HSTRING_HAS_EVAL_OR_ARGUMENTS

#define DUK_HSTRING_HAS_EVAL_OR_ARGUMENTS ( x)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS)

Definition at line 4471 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_HAS_EXTDATA

#define DUK_HSTRING_HAS_EXTDATA ( x)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA)

◆ DUK_HSTRING_HAS_INTERNAL

#define DUK_HSTRING_HAS_INTERNAL ( x)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_INTERNAL)

Definition at line 4468 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__alloc_init_hstring().

◆ DUK_HSTRING_HAS_RESERVED_WORD

#define DUK_HSTRING_HAS_RESERVED_WORD ( x)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_RESERVED_WORD)

Definition at line 4469 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_func_body().

◆ DUK_HSTRING_HAS_STRICT_RESERVED_WORD

#define DUK_HSTRING_HAS_STRICT_RESERVED_WORD ( x)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD)

◆ DUK_HSTRING_INCREF

#define DUK_HSTRING_INCREF ( thr,
h )   DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))

Definition at line 3837 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__realloc_props().

◆ DUK_HSTRING_IS_ASCII

#define DUK_HSTRING_IS_ASCII ( x)    DUK_HSTRING_HAS_ASCII((x))

Definition at line 4495 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_IS_EMPTY

#define DUK_HSTRING_IS_EMPTY ( x)    (DUK_HSTRING_GET_BYTELEN((x)) == 0)

Definition at line 4496 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_MAX_BYTELEN

#define DUK_HSTRING_MAX_BYTELEN   (0x7fffffffUL)

Definition at line 4449 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_heap_string_intern_checked().

◆ DUK_HSTRING_NO_ARRAY_INDEX

#define DUK_HSTRING_NO_ARRAY_INDEX   (0xffffffffUL)

Definition at line 4552 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_SET_ARRIDX

#define DUK_HSTRING_SET_ARRIDX ( x)    DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX)

Definition at line 4475 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__alloc_init_hstring().

◆ DUK_HSTRING_SET_ASCII

#define DUK_HSTRING_SET_ASCII ( x)    DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII)

Definition at line 4474 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__alloc_init_hstring().

◆ DUK_HSTRING_SET_BYTELEN

#define DUK_HSTRING_SET_BYTELEN ( x,
v )
Value:
do { \
(x)->blen = (v); \
} while (0)

Definition at line 4528 of file duktape-1.8.0/src/duktape.c.

4528#define DUK_HSTRING_SET_BYTELEN(x,v) do { \
4529 (x)->blen = (v); \
4530 } while (0)

Referenced by duk__alloc_init_hstring().

◆ DUK_HSTRING_SET_CHARLEN

#define DUK_HSTRING_SET_CHARLEN ( x,
v )
Value:
do { \
(x)->clen = (v); \
} while (0)

Definition at line 4532 of file duktape-1.8.0/src/duktape.c.

4532#define DUK_HSTRING_SET_CHARLEN(x,v) do { \
4533 (x)->clen = (v); \
4534 } while (0)

Referenced by duk__alloc_init_hstring().

◆ DUK_HSTRING_SET_EVAL_OR_ARGUMENTS

#define DUK_HSTRING_SET_EVAL_OR_ARGUMENTS ( x)    DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS)

Definition at line 4479 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_SET_EXTDATA

#define DUK_HSTRING_SET_EXTDATA ( x)    DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA)

Definition at line 4480 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_SET_HASH

#define DUK_HSTRING_SET_HASH ( x,
v )
Value:
do { \
(x)->hash = (v); \
} while (0)

Definition at line 4505 of file duktape-1.8.0/src/duktape.c.

4505#define DUK_HSTRING_SET_HASH(x,v) do { \
4506 (x)->hash = (v); \
4507 } while (0)

Referenced by duk__alloc_init_hstring().

◆ DUK_HSTRING_SET_INTERNAL

#define DUK_HSTRING_SET_INTERNAL ( x)    DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_INTERNAL)

Definition at line 4476 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__alloc_init_hstring().

◆ DUK_HSTRING_SET_RESERVED_WORD

#define DUK_HSTRING_SET_RESERVED_WORD ( x)    DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_RESERVED_WORD)

Definition at line 4477 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HSTRING_SET_STRICT_RESERVED_WORD

#define DUK_HSTRING_SET_STRICT_RESERVED_WORD ( x)    DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD)

Definition at line 4478 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_DECREF

#define DUK_HTHREAD_DECREF ( thr,
h )   DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) &(h)->obj)

Definition at line 3850 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_GET_CURRENT_ACTIVATION

#define DUK_HTHREAD_GET_CURRENT_ACTIVATION ( thr)    (&(thr)->callstack[(thr)->callstack_top - 1])

Definition at line 6100 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_GET_STRING

#define DUK_HTHREAD_GET_STRING ( thr,
idx )    ((thr)->strs[(idx)])

Definition at line 6095 of file duktape-1.8.0/src/duktape.c.

6095#if defined(DUK_USE_ROM_STRINGS)
6096#define DUK_HTHREAD_GET_STRING(thr,idx) \

Referenced by duk__err_augment_user(), and duk_lexer_parse_js_input_element().

◆ DUK_HTHREAD_H_INCLUDED

#define DUK_HTHREAD_H_INCLUDED

Definition at line 5975 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_INCREF

#define DUK_HTHREAD_INCREF ( thr,
h )   DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)

Definition at line 3849 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STATE_INACTIVE

#define DUK_HTHREAD_STATE_INACTIVE   1 /* thread not currently running */

Definition at line 6103 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STATE_RESUMED

#define DUK_HTHREAD_STATE_RESUMED   3 /* thread resumed another thread (active but not running) */

Definition at line 6105 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STATE_RUNNING

#define DUK_HTHREAD_STATE_RUNNING   2 /* thread currently running (only one at a time) */

Definition at line 6104 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_handle_ecma_call_setup().

◆ DUK_HTHREAD_STATE_TERMINATED

#define DUK_HTHREAD_STATE_TERMINATED   5 /* thread has terminated */

Definition at line 6107 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STATE_YIELDED

#define DUK_HTHREAD_STATE_YIELDED   4 /* thread has yielded */

Definition at line 6106 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING___PROTO__

#define DUK_HTHREAD_STRING___PROTO__ ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX___PROTO__)

Definition at line 1116 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_ARRAY

#define DUK_HTHREAD_STRING_ARRAY ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ARRAY)

Definition at line 903 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_ARRAY_BUFFER

#define DUK_HTHREAD_STRING_ARRAY_BUFFER ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ARRAY_BUFFER)

Definition at line 933 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_BASE64

#define DUK_HTHREAD_STRING_BASE64 ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BASE64)

Definition at line 1260 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_BRACKETED_ELLIPSIS

#define DUK_HTHREAD_STRING_BRACKETED_ELLIPSIS ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BRACKETED_ELLIPSIS)

Definition at line 1083 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_BREAK

#define DUK_HTHREAD_STRING_BREAK ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BREAK)

Definition at line 1326 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_BYTE_LENGTH

#define DUK_HTHREAD_STRING_BYTE_LENGTH ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BYTE_LENGTH)

Definition at line 1146 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__get_own_propdesc_raw(), and duk_hobject_putprop().

◆ DUK_HTHREAD_STRING_BYTE_OFFSET

#define DUK_HTHREAD_STRING_BYTE_OFFSET ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BYTE_OFFSET)

Definition at line 1149 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__get_own_propdesc_raw(), and duk_hobject_putprop().

◆ DUK_HTHREAD_STRING_BYTES_PER_ELEMENT

#define DUK_HTHREAD_STRING_BYTES_PER_ELEMENT ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BYTES_PER_ELEMENT)

Definition at line 1152 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__get_own_propdesc_raw(), and duk_hobject_putprop().

◆ DUK_HTHREAD_STRING_CALLEE

#define DUK_HTHREAD_STRING_CALLEE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CALLEE)

Definition at line 1092 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_CALLER

#define DUK_HTHREAD_STRING_CALLER ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CALLER)

Definition at line 1095 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_CASE

#define DUK_HTHREAD_STRING_CASE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CASE)

Definition at line 1329 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_CATCH

#define DUK_HTHREAD_STRING_CATCH ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CATCH)

Definition at line 1332 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_CLASS

#define DUK_HTHREAD_STRING_CLASS ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CLASS)

Definition at line 1407 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_CLOG

#define DUK_HTHREAD_STRING_CLOG ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CLOG)

Definition at line 1302 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_COMMA

#define DUK_HTHREAD_STRING_COMMA ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_COMMA)

Definition at line 1074 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_COMPILE

#define DUK_HTHREAD_STRING_COMPILE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_COMPILE)

Definition at line 1236 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_CONFIGURABLE

#define DUK_HTHREAD_STRING_CONFIGURABLE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CONFIGURABLE)

Definition at line 996 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_CONST

#define DUK_HTHREAD_STRING_CONST ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CONST)

Definition at line 1395 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_CONSTRUCTOR

#define DUK_HTHREAD_STRING_CONSTRUCTOR ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CONSTRUCTOR)

Definition at line 1041 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_CONTINUE

#define DUK_HTHREAD_STRING_CONTINUE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CONTINUE)

Definition at line 1335 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_DATA

#define DUK_HTHREAD_STRING_DATA ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DATA)

Definition at line 1140 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_DATA_VIEW

#define DUK_HTHREAD_STRING_DATA_VIEW ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DATA_VIEW)

Definition at line 936 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_DATE

#define DUK_HTHREAD_STRING_DATE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DATE)

Definition at line 915 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_DEBUGGER

#define DUK_HTHREAD_STRING_DEBUGGER ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DEBUGGER)

Definition at line 1338 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_DEC_ENV

#define DUK_HTHREAD_STRING_DEC_ENV ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DEC_ENV)

Definition at line 972 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_DEFAULT

#define DUK_HTHREAD_STRING_DEFAULT ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DEFAULT)

Definition at line 1341 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_DEFINE_PROPERTY

#define DUK_HTHREAD_STRING_DEFINE_PROPERTY ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DEFINE_PROPERTY)

Definition at line 987 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_DELETE

#define DUK_HTHREAD_STRING_DELETE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DELETE)

Definition at line 1344 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_DELETE_PROPERTY

#define DUK_HTHREAD_STRING_DELETE_PROPERTY ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DELETE_PROPERTY)

Definition at line 1104 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_DO

#define DUK_HTHREAD_STRING_DO ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DO)

Definition at line 1347 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_ELSE

#define DUK_HTHREAD_STRING_ELSE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ELSE)

Definition at line 1350 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_EMPTY_STRING

#define DUK_HTHREAD_STRING_EMPTY_STRING ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EMPTY_STRING)

Definition at line 930 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__error_getter_helper().

◆ DUK_HTHREAD_STRING_ENUM

#define DUK_HTHREAD_STRING_ENUM ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ENUM)

Definition at line 1410 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_ENUMERABLE

#define DUK_HTHREAD_STRING_ENUMERABLE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ENUMERABLE)

Definition at line 999 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_ENUMERATE

#define DUK_HTHREAD_STRING_ENUMERATE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ENUMERATE)

Definition at line 1107 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_ENV

#define DUK_HTHREAD_STRING_ENV ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ENV)

Definition at line 1254 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_ERR_CREATE

#define DUK_HTHREAD_STRING_ERR_CREATE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ERR_CREATE)

Definition at line 1242 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_ERR_THROW

#define DUK_HTHREAD_STRING_ERR_THROW ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ERR_THROW)

Definition at line 1245 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_ESCAPED_EMPTY_REGEXP

#define DUK_HTHREAD_STRING_ESCAPED_EMPTY_REGEXP ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ESCAPED_EMPTY_REGEXP)

Definition at line 1032 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_EVAL

#define DUK_HTHREAD_STRING_EVAL ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EVAL)

Definition at line 984 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__putvar_helper().

◆ DUK_HTHREAD_STRING_EXPORT

#define DUK_HTHREAD_STRING_EXPORT ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EXPORT)

Definition at line 1413 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_EXPORTS

#define DUK_HTHREAD_STRING_EXPORTS ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EXPORTS)

Definition at line 1125 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_EXTENDS

#define DUK_HTHREAD_STRING_EXTENDS ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EXTENDS)

Definition at line 1416 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_FALSE

#define DUK_HTHREAD_STRING_FALSE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FALSE)

Definition at line 1431 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_FILE_NAME

#define DUK_HTHREAD_STRING_FILE_NAME ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FILE_NAME)

Definition at line 1173 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_FILENAME

#define DUK_HTHREAD_STRING_FILENAME ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FILENAME)

Definition at line 1128 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_FINALLY

#define DUK_HTHREAD_STRING_FINALLY ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FINALLY)

Definition at line 1353 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_FLOAT32_ARRAY

#define DUK_HTHREAD_STRING_FLOAT32_ARRAY ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FLOAT32_ARRAY)

Definition at line 960 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_FLOAT64_ARRAY

#define DUK_HTHREAD_STRING_FLOAT64_ARRAY ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FLOAT64_ARRAY)

Definition at line 963 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_FMT

#define DUK_HTHREAD_STRING_FMT ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FMT)

Definition at line 1272 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_FOR

#define DUK_HTHREAD_STRING_FOR ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FOR)

Definition at line 1356 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_GET

#define DUK_HTHREAD_STRING_GET ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_GET)

Definition at line 1101 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_GLOBAL

#define DUK_HTHREAD_STRING_GLOBAL ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_GLOBAL)

Definition at line 966 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_HAS

#define DUK_HTHREAD_STRING_HAS ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_HAS)

Definition at line 1098 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_HEX

#define DUK_HTHREAD_STRING_HEX ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_HEX)

Definition at line 1257 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_ID

#define DUK_HTHREAD_STRING_ID ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ID)

Definition at line 1122 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_IF

#define DUK_HTHREAD_STRING_IF ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IF)

Definition at line 1362 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_IGNORE_CASE

#define DUK_HTHREAD_STRING_IGNORE_CASE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IGNORE_CASE)

Definition at line 1023 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_IMPLEMENTS

#define DUK_HTHREAD_STRING_IMPLEMENTS ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IMPLEMENTS)

Definition at line 1434 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_IMPORT

#define DUK_HTHREAD_STRING_IMPORT ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IMPORT)

Definition at line 1419 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_IN

#define DUK_HTHREAD_STRING_IN ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IN)

Definition at line 1365 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INDEX

#define DUK_HTHREAD_STRING_INDEX ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INDEX)

Definition at line 1035 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INFINITY

#define DUK_HTHREAD_STRING_INFINITY ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INFINITY)

Definition at line 1065 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INPUT

#define DUK_HTHREAD_STRING_INPUT ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INPUT)

Definition at line 1239 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INSTANCEOF

#define DUK_HTHREAD_STRING_INSTANCEOF ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INSTANCEOF)

Definition at line 1368 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INT16_ARRAY

#define DUK_HTHREAD_STRING_INT16_ARRAY ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT16_ARRAY)

Definition at line 948 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INT32_ARRAY

#define DUK_HTHREAD_STRING_INT32_ARRAY ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT32_ARRAY)

Definition at line 954 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INT8_ARRAY

#define DUK_HTHREAD_STRING_INT8_ARRAY ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT8_ARRAY)

Definition at line 939 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INT_ARGS

#define DUK_HTHREAD_STRING_INT_ARGS ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_ARGS)

Definition at line 1209 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INT_BYTECODE

#define DUK_HTHREAD_STRING_INT_BYTECODE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_BYTECODE)

Definition at line 1188 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INT_CALLEE

#define DUK_HTHREAD_STRING_INT_CALLEE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_CALLEE)

Definition at line 1221 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__getid_open_decl_env_regs().

◆ DUK_HTHREAD_STRING_INT_FINALIZER

#define DUK_HTHREAD_STRING_INT_FINALIZER ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_FINALIZER)

Definition at line 1215 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INT_FORMALS

#define DUK_HTHREAD_STRING_INT_FORMALS ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_FORMALS)

Definition at line 1191 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INT_HANDLER

#define DUK_HTHREAD_STRING_INT_HANDLER ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_HANDLER)

Definition at line 1218 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INT_LEXENV

#define DUK_HTHREAD_STRING_INT_LEXENV ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_LEXENV)

Definition at line 1197 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INT_MAP

#define DUK_HTHREAD_STRING_INT_MAP ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_MAP)

Definition at line 1212 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INT_NEXT

#define DUK_HTHREAD_STRING_INT_NEXT ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_NEXT)

Definition at line 1185 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INT_PC2LINE

#define DUK_HTHREAD_STRING_INT_PC2LINE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_PC2LINE)

Definition at line 1206 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INT_REGBASE

#define DUK_HTHREAD_STRING_INT_REGBASE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_REGBASE)

Definition at line 1227 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__getid_open_decl_env_regs().

◆ DUK_HTHREAD_STRING_INT_SOURCE

#define DUK_HTHREAD_STRING_INT_SOURCE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_SOURCE)

Definition at line 1203 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INT_TARGET

#define DUK_HTHREAD_STRING_INT_TARGET ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_TARGET)

Definition at line 1230 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__declvar_helper().

◆ DUK_HTHREAD_STRING_INT_THIS

#define DUK_HTHREAD_STRING_INT_THIS ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_THIS)

Definition at line 1233 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INT_THREAD

#define DUK_HTHREAD_STRING_INT_THREAD ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_THREAD)

Definition at line 1224 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__getid_open_decl_env_regs().

◆ DUK_HTHREAD_STRING_INT_TRACEDATA

#define DUK_HTHREAD_STRING_INT_TRACEDATA ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_TRACEDATA)

Definition at line 1167 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INT_VALUE

#define DUK_HTHREAD_STRING_INT_VALUE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_VALUE)

Definition at line 1182 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INT_VARENV

#define DUK_HTHREAD_STRING_INT_VARENV ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_VARENV)

Definition at line 1200 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INT_VARMAP

#define DUK_HTHREAD_STRING_INT_VARMAP ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_VARMAP)

Definition at line 1194 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__getid_open_decl_env_regs().

◆ DUK_HTHREAD_STRING_INTERFACE

#define DUK_HTHREAD_STRING_INTERFACE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INTERFACE)

Definition at line 1437 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_INVALID_DATE

#define DUK_HTHREAD_STRING_INVALID_DATE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INVALID_DATE)

Definition at line 1086 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_JC

#define DUK_HTHREAD_STRING_JC ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JC)

Definition at line 1266 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_JOIN

#define DUK_HTHREAD_STRING_JOIN ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JOIN)

Definition at line 1002 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_JSON

#define DUK_HTHREAD_STRING_JSON ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON)

Definition at line 927 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_JSON_EXT_FUNCTION1

#define DUK_HTHREAD_STRING_JSON_EXT_FUNCTION1 ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_FUNCTION1)

Definition at line 1320 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_JSON_EXT_FUNCTION2

#define DUK_HTHREAD_STRING_JSON_EXT_FUNCTION2 ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_FUNCTION2)

Definition at line 1323 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_JSON_EXT_NAN

#define DUK_HTHREAD_STRING_JSON_EXT_NAN ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_NAN)

Definition at line 1311 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_JSON_EXT_NEGINF

#define DUK_HTHREAD_STRING_JSON_EXT_NEGINF ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_NEGINF)

Definition at line 1317 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_JSON_EXT_POSINF

#define DUK_HTHREAD_STRING_JSON_EXT_POSINF ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_POSINF)

Definition at line 1314 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_JSON_EXT_UNDEFINED

#define DUK_HTHREAD_STRING_JSON_EXT_UNDEFINED ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_UNDEFINED)

Definition at line 1308 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_JX

#define DUK_HTHREAD_STRING_JX ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JX)

Definition at line 1263 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LAST_INDEX

#define DUK_HTHREAD_STRING_LAST_INDEX ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LAST_INDEX)

Definition at line 1029 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LC_ARGUMENTS

#define DUK_HTHREAD_STRING_LC_ARGUMENTS ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_ARGUMENTS)

◆ DUK_HTHREAD_STRING_LC_BOOLEAN

#define DUK_HTHREAD_STRING_LC_BOOLEAN ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_BOOLEAN)

Definition at line 1047 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LC_BUFFER

#define DUK_HTHREAD_STRING_LC_BUFFER ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_BUFFER)

Definition at line 1176 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LC_DEBUG

#define DUK_HTHREAD_STRING_LC_DEBUG ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_DEBUG)

Definition at line 1281 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LC_ERROR

#define DUK_HTHREAD_STRING_LC_ERROR ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_ERROR)

Definition at line 1290 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LC_FATAL

#define DUK_HTHREAD_STRING_LC_FATAL ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_FATAL)

Definition at line 1293 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LC_FUNCTION

#define DUK_HTHREAD_STRING_LC_FUNCTION ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_FUNCTION)

Definition at line 1359 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LC_INFO

#define DUK_HTHREAD_STRING_LC_INFO ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_INFO)

Definition at line 1284 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LC_L

#define DUK_HTHREAD_STRING_LC_L ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_L)

Definition at line 1299 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LC_N

#define DUK_HTHREAD_STRING_LC_N ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_N)

Definition at line 1296 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LC_NULL

#define DUK_HTHREAD_STRING_LC_NULL ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_NULL)

Definition at line 1425 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LC_NUMBER

#define DUK_HTHREAD_STRING_LC_NUMBER ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_NUMBER)

Definition at line 1050 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LC_OBJECT

#define DUK_HTHREAD_STRING_LC_OBJECT ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_OBJECT)

Definition at line 1056 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LC_POINTER

#define DUK_HTHREAD_STRING_LC_POINTER ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_POINTER)

Definition at line 1179 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LC_STRING

#define DUK_HTHREAD_STRING_LC_STRING ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_STRING)

Definition at line 1053 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LC_TRACE

#define DUK_HTHREAD_STRING_LC_TRACE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_TRACE)

Definition at line 1278 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LC_UNDEFINED

#define DUK_HTHREAD_STRING_LC_UNDEFINED ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_UNDEFINED)

Definition at line 1059 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LC_WARN

#define DUK_HTHREAD_STRING_LC_WARN ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_WARN)

Definition at line 1287 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LENGTH

#define DUK_HTHREAD_STRING_LENGTH ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LENGTH)

◆ DUK_HTHREAD_STRING_LET

#define DUK_HTHREAD_STRING_LET ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LET)

Definition at line 1440 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_LINE_NUMBER

#define DUK_HTHREAD_STRING_LINE_NUMBER ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LINE_NUMBER)

Definition at line 1164 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_MATH

#define DUK_HTHREAD_STRING_MATH ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_MATH)

Definition at line 924 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_MESSAGE

#define DUK_HTHREAD_STRING_MESSAGE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_MESSAGE)

Definition at line 1044 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_MINUS_INFINITY

#define DUK_HTHREAD_STRING_MINUS_INFINITY ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_MINUS_INFINITY)

Definition at line 1068 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_MINUS_ZERO

#define DUK_HTHREAD_STRING_MINUS_ZERO ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_MINUS_ZERO)

Definition at line 1071 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_MOD_LOADED

#define DUK_HTHREAD_STRING_MOD_LOADED ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_MOD_LOADED)

Definition at line 1251 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_MOD_SEARCH

#define DUK_HTHREAD_STRING_MOD_SEARCH ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_MOD_SEARCH)

Definition at line 1248 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_MULTILINE

#define DUK_HTHREAD_STRING_MULTILINE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_MULTILINE)

Definition at line 1026 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_NAME

#define DUK_HTHREAD_STRING_NAME ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_NAME)

Definition at line 1170 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_NAN

#define DUK_HTHREAD_STRING_NAN ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_NAN)

Definition at line 1062 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_NEW

#define DUK_HTHREAD_STRING_NEW ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_NEW)

Definition at line 1371 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_NEWLINE_4SPACE

#define DUK_HTHREAD_STRING_NEWLINE_4SPACE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_NEWLINE_4SPACE)

Definition at line 1080 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_OBJ_ENV

#define DUK_HTHREAD_STRING_OBJ_ENV ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_OBJ_ENV)

Definition at line 969 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_OWN_KEYS

#define DUK_HTHREAD_STRING_OWN_KEYS ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_OWN_KEYS)

Definition at line 1110 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_PACKAGE

#define DUK_HTHREAD_STRING_PACKAGE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PACKAGE)

Definition at line 1443 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_PC

#define DUK_HTHREAD_STRING_PC ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PC)

Definition at line 1161 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_PRIVATE

#define DUK_HTHREAD_STRING_PRIVATE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PRIVATE)

Definition at line 1446 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_PROTECTED

#define DUK_HTHREAD_STRING_PROTECTED ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PROTECTED)

Definition at line 1449 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_PROTOTYPE

#define DUK_HTHREAD_STRING_PROTOTYPE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PROTOTYPE)

Definition at line 1038 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_PUBLIC

#define DUK_HTHREAD_STRING_PUBLIC ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PUBLIC)

Definition at line 1452 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_RAW

#define DUK_HTHREAD_STRING_RAW ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_RAW)

Definition at line 1275 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_REG_EXP

#define DUK_HTHREAD_STRING_REG_EXP ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_REG_EXP)

Definition at line 918 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_REQUIRE

#define DUK_HTHREAD_STRING_REQUIRE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_REQUIRE)

Definition at line 1119 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_RESUME

#define DUK_HTHREAD_STRING_RESUME ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_RESUME)

Definition at line 1269 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_RETURN

#define DUK_HTHREAD_STRING_RETURN ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_RETURN)

Definition at line 1374 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_SET

#define DUK_HTHREAD_STRING_SET ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SET)

Definition at line 1155 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_SET_PROTOTYPE_OF

#define DUK_HTHREAD_STRING_SET_PROTOTYPE_OF ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SET_PROTOTYPE_OF)

Definition at line 1113 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_SOURCE

#define DUK_HTHREAD_STRING_SOURCE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SOURCE)

Definition at line 1020 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_SPACE

#define DUK_HTHREAD_STRING_SPACE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SPACE)

Definition at line 1077 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_STACK

#define DUK_HTHREAD_STRING_STACK ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_STACK)

Definition at line 1158 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_STATIC

#define DUK_HTHREAD_STRING_STATIC ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_STATIC)

Definition at line 1455 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_SUPER

#define DUK_HTHREAD_STRING_SUPER ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SUPER)

Definition at line 1422 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_SWITCH

#define DUK_HTHREAD_STRING_SWITCH ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SWITCH)

Definition at line 1377 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_THIS

#define DUK_HTHREAD_STRING_THIS ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_THIS)

Definition at line 1380 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_THROW

#define DUK_HTHREAD_STRING_THROW ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_THROW)

Definition at line 1383 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_TO_GMT_STRING

#define DUK_HTHREAD_STRING_TO_GMT_STRING ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_GMT_STRING)

Definition at line 1017 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_TO_ISO_STRING

#define DUK_HTHREAD_STRING_TO_ISO_STRING ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_ISO_STRING)

Definition at line 1014 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_TO_JSON

#define DUK_HTHREAD_STRING_TO_JSON ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_JSON)

Definition at line 1134 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_TO_LOCALE_STRING

#define DUK_HTHREAD_STRING_TO_LOCALE_STRING ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_LOCALE_STRING)

Definition at line 1005 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_TO_LOG_STRING

#define DUK_HTHREAD_STRING_TO_LOG_STRING ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_LOG_STRING)

Definition at line 1305 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_TO_STRING

#define DUK_HTHREAD_STRING_TO_STRING ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_STRING)

Definition at line 1131 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_TO_UTC_STRING

#define DUK_HTHREAD_STRING_TO_UTC_STRING ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_UTC_STRING)

Definition at line 1011 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_TRUE

#define DUK_HTHREAD_STRING_TRUE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TRUE)

Definition at line 1428 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_TRY

#define DUK_HTHREAD_STRING_TRY ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TRY)

Definition at line 1386 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_TYPE

#define DUK_HTHREAD_STRING_TYPE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TYPE)

Definition at line 1137 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_TYPEOF

#define DUK_HTHREAD_STRING_TYPEOF ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TYPEOF)

Definition at line 1389 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_UC_ARGUMENTS

#define DUK_HTHREAD_STRING_UC_ARGUMENTS ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_ARGUMENTS)

Definition at line 894 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_UC_BOOLEAN

#define DUK_HTHREAD_STRING_UC_BOOLEAN ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_BOOLEAN)

Definition at line 909 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_UC_BUFFER

#define DUK_HTHREAD_STRING_UC_BUFFER ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_BUFFER)

Definition at line 975 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_UC_ERROR

#define DUK_HTHREAD_STRING_UC_ERROR ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_ERROR)

Definition at line 921 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_UC_FUNCTION

#define DUK_HTHREAD_STRING_UC_FUNCTION ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_FUNCTION)

Definition at line 900 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_UC_NULL

#define DUK_HTHREAD_STRING_UC_NULL ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_NULL)

Definition at line 891 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_UC_NUMBER

#define DUK_HTHREAD_STRING_UC_NUMBER ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_NUMBER)

Definition at line 912 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_UC_OBJECT

#define DUK_HTHREAD_STRING_UC_OBJECT ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_OBJECT)

Definition at line 897 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_UC_POINTER

#define DUK_HTHREAD_STRING_UC_POINTER ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_POINTER)

Definition at line 978 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_UC_STRING

#define DUK_HTHREAD_STRING_UC_STRING ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_STRING)

Definition at line 906 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_UC_THREAD

#define DUK_HTHREAD_STRING_UC_THREAD ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_THREAD)

Definition at line 981 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_UC_UNDEFINED

#define DUK_HTHREAD_STRING_UC_UNDEFINED ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_UNDEFINED)

Definition at line 888 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_UINT16_ARRAY

#define DUK_HTHREAD_STRING_UINT16_ARRAY ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UINT16_ARRAY)

Definition at line 951 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_UINT32_ARRAY

#define DUK_HTHREAD_STRING_UINT32_ARRAY ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UINT32_ARRAY)

Definition at line 957 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_UINT8_ARRAY

#define DUK_HTHREAD_STRING_UINT8_ARRAY ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UINT8_ARRAY)

Definition at line 942 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_UINT8_CLAMPED_ARRAY

#define DUK_HTHREAD_STRING_UINT8_CLAMPED_ARRAY ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UINT8_CLAMPED_ARRAY)

Definition at line 945 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_VALUE

#define DUK_HTHREAD_STRING_VALUE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_VALUE)

Definition at line 990 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_VALUE_OF

#define DUK_HTHREAD_STRING_VALUE_OF ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_VALUE_OF)

Definition at line 1008 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_VAR

#define DUK_HTHREAD_STRING_VAR ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_VAR)

Definition at line 1392 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_VOID

#define DUK_HTHREAD_STRING_VOID ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_VOID)

Definition at line 1398 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_WHILE

#define DUK_HTHREAD_STRING_WHILE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WHILE)

Definition at line 1401 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_WITH

#define DUK_HTHREAD_STRING_WITH ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WITH)

Definition at line 1404 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_WRITABLE

#define DUK_HTHREAD_STRING_WRITABLE ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WRITABLE)

Definition at line 993 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTHREAD_STRING_YIELD

#define DUK_HTHREAD_STRING_YIELD ( thr)    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_YIELD)

Definition at line 1458 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTYPE_BUFFER

#define DUK_HTYPE_BUFFER   3

Definition at line 3575 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_duktape_object_info().

◆ DUK_HTYPE_MAX

#define DUK_HTYPE_MAX   3

Definition at line 3576 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTYPE_MIN

#define DUK_HTYPE_MIN   1

Definition at line 3572 of file duktape-1.8.0/src/duktape.c.

◆ DUK_HTYPE_OBJECT

#define DUK_HTYPE_OBJECT   2

◆ DUK_HTYPE_STRING

#define DUK_HTYPE_STRING   1

◆ DUK_INTERNAL_H_INCLUDED

#define DUK_INTERNAL_H_INCLUDED

Definition at line 123 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ISPEC_NONE

#define DUK_ISPEC_NONE   0 /* no value */

Definition at line 3187 of file duktape-1.8.0/src/duktape.c.

◆ DUK_ISPEC_REGCONST

#define DUK_ISPEC_REGCONST   2 /* value resides in a register or constant */

Definition at line 3189 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__ispec_toregconst_raw().

◆ DUK_ISPEC_VALUE

#define DUK_ISPEC_VALUE   1 /* value resides in 'valstack_idx' */

Definition at line 3188 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__expr_led(), and duk__ispec_toregconst_raw().

◆ DUK_IVAL_ARITH

#define DUK_IVAL_ARITH   2 /* binary arithmetic; DUK_OP_ADD, DUK_OP_EQ, other binary ops */

Definition at line 3182 of file duktape-1.8.0/src/duktape.c.

◆ DUK_IVAL_ARITH_EXTRAOP

#define DUK_IVAL_ARITH_EXTRAOP   3 /* binary arithmetic using extraops; DUK_EXTRAOP_INSTOF etc */

Definition at line 3183 of file duktape-1.8.0/src/duktape.c.

◆ DUK_IVAL_NONE

#define DUK_IVAL_NONE   0 /* no value */

Definition at line 3180 of file duktape-1.8.0/src/duktape.c.

◆ DUK_IVAL_PLAIN

#define DUK_IVAL_PLAIN   1 /* register, constant, or value */

Definition at line 3181 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__expr_led().

◆ DUK_IVAL_PROP

#define DUK_IVAL_PROP   4 /* property access */

Definition at line 3184 of file duktape-1.8.0/src/duktape.c.

◆ DUK_IVAL_VAR

#define DUK_IVAL_VAR   5 /* variable access */

Definition at line 3185 of file duktape-1.8.0/src/duktape.c.

◆ DUK_JMPBUF_H_INCLUDED

#define DUK_JMPBUF_H_INCLUDED

Definition at line 201 of file duktape-1.8.0/src/duktape.c.

◆ DUK_JS_BYTECODE_H_INCLUDED

#define DUK_JS_BYTECODE_H_INCLUDED

Definition at line 2522 of file duktape-1.8.0/src/duktape.c.

◆ DUK_JS_COMPILE_FLAG_EVAL

#define DUK_JS_COMPILE_FLAG_EVAL   (1 << 0) /* source is eval code (not global) */

Definition at line 3376 of file duktape-1.8.0/src/duktape.c.

◆ DUK_JS_COMPILE_FLAG_FUNCEXPR

#define DUK_JS_COMPILE_FLAG_FUNCEXPR   (1 << 2) /* source is a function expression (used for Function constructor) */

Definition at line 3378 of file duktape-1.8.0/src/duktape.c.

◆ DUK_JS_COMPILE_FLAG_STRICT

#define DUK_JS_COMPILE_FLAG_STRICT   (1 << 1) /* strict outer context */

Definition at line 3377 of file duktape-1.8.0/src/duktape.c.

◆ DUK_JS_COMPILER_H_INCLUDED

#define DUK_JS_COMPILER_H_INCLUDED

Definition at line 3161 of file duktape-1.8.0/src/duktape.c.

◆ DUK_JS_CONST_MARKER

#define DUK_JS_CONST_MARKER   0x80000000UL

Definition at line 3192 of file duktape-1.8.0/src/duktape.c.

◆ duk_js_equals

#define duk_js_equals ( thr,
tv_x,
tv_y )    duk_js_equals_helper((thr), (tv_x), (tv_y), 0)

Definition at line 8413 of file duktape-1.8.0/src/duktape.c.

DUK_INTERNAL_DECL duk_uint32_t duk_js_touint32(duk_hthread *thr, duk_tval *tv)
DUK_INTERNAL_DECL duk_double_t duk_js_tointeger(duk_hthread *thr, duk_tval *tv)

◆ duk_js_greaterthan

#define duk_js_greaterthan ( thr,
tv_x,
tv_y )    duk_js_compare_helper((thr), (tv_y), (tv_x), 0)

Definition at line 8425 of file duktape-1.8.0/src/duktape.c.

duk_small_int_t duk_bool_t
DUK_INTERNAL_DECL duk_bool_t duk_js_instanceof(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y)
DUK_INTERNAL_DECL duk_bool_t duk_js_compare_helper(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_int_t flags)

◆ duk_js_greaterthanorequal

#define duk_js_greaterthanorequal ( thr,
tv_x,
tv_y )    duk_js_compare_helper((thr), (tv_x), (tv_y), DUK_COMPARE_FLAG_EVAL_LEFT_FIRST | DUK_COMPARE_FLAG_NEGATE)

Definition at line 8433 of file duktape-1.8.0/src/duktape.c.

8434#define duk_js_samevalue(tv_x,tv_y) \
#define DUK_EQUALS_FLAG_STRICT
DUK_INTERNAL_DECL duk_bool_t duk_js_equals_helper(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_int_t flags)

◆ DUK_JS_H_INCLUDED

#define DUK_JS_H_INCLUDED

Definition at line 8375 of file duktape-1.8.0/src/duktape.c.

◆ duk_js_lessthan

#define duk_js_lessthan ( thr,
tv_x,
tv_y )    duk_js_compare_helper((thr), (tv_x), (tv_Y), DUK_COMPARE_FLAG_EVAL_LEFT_FIRST)

Definition at line 8421 of file duktape-1.8.0/src/duktape.c.

8422#if 0 /* unused */
DUK_INTERNAL_DECL duk_small_int_t duk_js_string_compare(duk_hstring *h1, duk_hstring *h2)

◆ duk_js_lessthanorequal

#define duk_js_lessthanorequal ( thr,
tv_x,
tv_y )    duk_js_compare_helper((thr), (tv_y), (tv_x), DUK_COMPARE_FLAG_NEGATE)

Definition at line 8429 of file duktape-1.8.0/src/duktape.c.

8429
8430#define duk_js_equals(thr,tv_x,tv_y) \

◆ duk_js_samevalue

#define duk_js_samevalue ( tv_x,
tv_y )    duk_js_equals_helper(NULL, (tv_x), (tv_y), DUK_EQUALS_FLAG_SAMEVALUE)

Definition at line 8417 of file duktape-1.8.0/src/duktape.c.

8417DUK_INTERNAL_DECL duk_small_int_t duk_js_to_arrayindex_raw_string(const duk_uint8_t *str, duk_uint32_t blen, duk_uarridx_t *out_idx);
DUK_INTERNAL_DECL duk_small_int_t duk_js_to_arrayindex_raw_string(const duk_uint8_t *str, duk_uint32_t blen, duk_uarridx_t *out_idx)
DUK_INTERNAL_DECL duk_uarridx_t duk_js_to_arrayindex_string_helper(duk_hstring *h)

Referenced by duk_hobject_define_property_helper(), and duk_hobject_putprop().

◆ duk_js_strict_equals

#define duk_js_strict_equals ( tv_x,
tv_y )    duk_js_equals_helper(NULL, (tv_x), (tv_y), DUK_EQUALS_FLAG_STRICT)

Definition at line 8415 of file duktape-1.8.0/src/duktape.c.

DUK_INTERNAL_DECL duk_uint16_t duk_js_touint16(duk_hthread *thr, duk_tval *tv)
DUK_INTERNAL_DECL duk_int32_t duk_js_toint32(duk_hthread *thr, duk_tval *tv)

◆ DUK_JSON_DEC_REQSTACK

#define DUK_JSON_DEC_REQSTACK   32

Definition at line 8318 of file duktape-1.8.0/src/duktape.c.

◆ DUK_JSON_ENC_LOOPARRAY

#define DUK_JSON_ENC_LOOPARRAY   64

Definition at line 8321 of file duktape-1.8.0/src/duktape.c.

◆ DUK_JSON_ENC_REQSTACK

#define DUK_JSON_ENC_REQSTACK   32

Definition at line 8315 of file duktape-1.8.0/src/duktape.c.

◆ DUK_JSON_FLAG_ASCII_ONLY

#define DUK_JSON_FLAG_ASCII_ONLY   (1 << 0) /* escape any non-ASCII characters */

Definition at line 8309 of file duktape-1.8.0/src/duktape.c.

◆ DUK_JSON_FLAG_AVOID_KEY_QUOTES

#define DUK_JSON_FLAG_AVOID_KEY_QUOTES   (1 << 1) /* avoid key quotes when key is an ASCII Identifier */

Definition at line 8310 of file duktape-1.8.0/src/duktape.c.

◆ DUK_JSON_FLAG_EXT_COMPATIBLE

#define DUK_JSON_FLAG_EXT_COMPATIBLE   (1 << 3) /* extended types: compatible encoding */

Definition at line 8312 of file duktape-1.8.0/src/duktape.c.

◆ DUK_JSON_FLAG_EXT_CUSTOM

#define DUK_JSON_FLAG_EXT_CUSTOM   (1 << 2) /* extended types: custom encoding */

Definition at line 8311 of file duktape-1.8.0/src/duktape.c.

◆ DUK_JSON_H_INCLUDED

#define DUK_JSON_H_INCLUDED

Definition at line 8306 of file duktape-1.8.0/src/duktape.c.

◆ DUK_LABEL_FLAG_ALLOW_BREAK

#define DUK_LABEL_FLAG_ALLOW_BREAK   (1 << 0)

Definition at line 3238 of file duktape-1.8.0/src/duktape.c.

◆ DUK_LABEL_FLAG_ALLOW_CONTINUE

#define DUK_LABEL_FLAG_ALLOW_CONTINUE   (1 << 1)

Definition at line 3239 of file duktape-1.8.0/src/duktape.c.

◆ DUK_LEXER_BUFFER_SIZE

#define DUK_LEXER_BUFFER_SIZE   64

Definition at line 2761 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__fill_lexer_buffer().

◆ DUK_LEXER_GETPOINT

#define DUK_LEXER_GETPOINT ( ctx,
pt )
Value:
do { (pt)->offset = (ctx)->window[0].offset; \
(pt)->line = (ctx)->window[0].line; } while (0)

Definition at line 2755 of file duktape-1.8.0/src/duktape.c.

2755#define DUK_LEXER_GETPOINT(ctx,pt) do { (pt)->offset = (ctx)->window[0].offset; \
2756 (pt)->line = (ctx)->window[0].line; } while (0)

Referenced by duk__parse_func_body().

◆ DUK_LEXER_H_INCLUDED

#define DUK_LEXER_H_INCLUDED

Definition at line 2728 of file duktape-1.8.0/src/duktape.c.

◆ DUK_LEXER_INITCTX

#define DUK_LEXER_INITCTX ( ctx)    duk_lexer_initctx((ctx))

Definition at line 2751 of file duktape-1.8.0/src/duktape.c.

◆ DUK_LEXER_SETPOINT

#define DUK_LEXER_SETPOINT ( ctx,
pt )   duk_lexer_setpoint((ctx), (pt))

Definition at line 2753 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_func_body().

◆ DUK_LEXER_TEMP_BUF_LIMIT

#define DUK_LEXER_TEMP_BUF_LIMIT   256

Definition at line 3067 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__appendbuffer().

◆ DUK_LEXER_WINDOW_SIZE

#define DUK_LEXER_WINDOW_SIZE   6

Definition at line 2759 of file duktape-1.8.0/src/duktape.c.

◆ DUK_LFUNC_FLAGS_GET_LENGTH

#define DUK_LFUNC_FLAGS_GET_LENGTH ( lf_flags)     (((lf_flags) >> 4) & 0x0f)

Definition at line 850 of file duktape-1.8.0/src/duktape.c.

850#define DUK_LFUNC_FLAGS_GET_LENGTH(lf_flags) \
851 (((lf_flags) >> 4) & 0x0f)

◆ DUK_LFUNC_FLAGS_GET_MAGIC

#define DUK_LFUNC_FLAGS_GET_MAGIC ( lf_flags)     ((((duk_int32_t) (lf_flags)) << 16) >> 24)

Definition at line 848 of file duktape-1.8.0/src/duktape.c.

848#define DUK_LFUNC_FLAGS_GET_MAGIC(lf_flags) \
849 ((((duk_int32_t) (lf_flags)) << 16) >> 24)

◆ DUK_LFUNC_FLAGS_GET_NARGS

#define DUK_LFUNC_FLAGS_GET_NARGS ( lf_flags)     ((lf_flags) & 0x0f)

Definition at line 852 of file duktape-1.8.0/src/duktape.c.

852#define DUK_LFUNC_FLAGS_GET_NARGS(lf_flags) \
853 ((lf_flags) & 0x0f)

◆ DUK_LFUNC_FLAGS_PACK

#define DUK_LFUNC_FLAGS_PACK ( magic,
length,
nargs )    (((magic) & 0xff) << 8) | ((length) << 4) | (nargs)

Definition at line 854 of file duktape-1.8.0/src/duktape.c.

854#define DUK_LFUNC_FLAGS_PACK(magic,length,nargs) \
855 (((magic) & 0xff) << 8) | ((length) << 4) | (nargs)

◆ DUK_LFUNC_LENGTH_MAX

#define DUK_LFUNC_LENGTH_MAX   0x0f

Definition at line 861 of file duktape-1.8.0/src/duktape.c.

◆ DUK_LFUNC_LENGTH_MIN

#define DUK_LFUNC_LENGTH_MIN   0x00

Definition at line 860 of file duktape-1.8.0/src/duktape.c.

◆ DUK_LFUNC_MAGIC_MAX

#define DUK_LFUNC_MAGIC_MAX   0x7f

Definition at line 863 of file duktape-1.8.0/src/duktape.c.

◆ DUK_LFUNC_MAGIC_MIN

#define DUK_LFUNC_MAGIC_MIN   (-0x80)

Definition at line 862 of file duktape-1.8.0/src/duktape.c.

◆ DUK_LFUNC_NARGS_MAX

#define DUK_LFUNC_NARGS_MAX   0x0e /* max, excl. varargs marker */

Definition at line 859 of file duktape-1.8.0/src/duktape.c.

◆ DUK_LFUNC_NARGS_MIN

#define DUK_LFUNC_NARGS_MIN   0x00

Definition at line 858 of file duktape-1.8.0/src/duktape.c.

◆ DUK_LFUNC_NARGS_VARARGS

#define DUK_LFUNC_NARGS_VARARGS   0x0f /* varargs marker */

Definition at line 857 of file duktape-1.8.0/src/duktape.c.

◆ DUK_LJ_TYPE_BREAK

#define DUK_LJ_TYPE_BREAK   4 /* value1 -> label number, pseudo-type to indicate a break continuation (for ENDFIN) */

Definition at line 6734 of file duktape-1.8.0/src/duktape.c.

◆ DUK_LJ_TYPE_CONTINUE

#define DUK_LJ_TYPE_CONTINUE   5 /* value1 -> label number, pseudo-type to indicate a continue continuation (for ENDFIN) */

Definition at line 6735 of file duktape-1.8.0/src/duktape.c.

◆ DUK_LJ_TYPE_NORMAL

#define DUK_LJ_TYPE_NORMAL   7 /* no value, pseudo-type to indicate a normal continuation (for ENDFIN) */

Definition at line 6737 of file duktape-1.8.0/src/duktape.c.

◆ DUK_LJ_TYPE_RESUME

#define DUK_LJ_TYPE_RESUME   3 /* value1 -> resume value, value2 -> resumee thread, iserror -> error/normal */

Definition at line 6733 of file duktape-1.8.0/src/duktape.c.

◆ DUK_LJ_TYPE_RETURN

#define DUK_LJ_TYPE_RETURN   6 /* value1 -> return value, pseudo-type to indicate a return continuation (for ENDFIN) */

Definition at line 6736 of file duktape-1.8.0/src/duktape.c.

◆ DUK_LJ_TYPE_THROW

#define DUK_LJ_TYPE_THROW   1 /* value1 -> error object */

Definition at line 6731 of file duktape-1.8.0/src/duktape.c.

◆ DUK_LJ_TYPE_UNKNOWN

#define DUK_LJ_TYPE_UNKNOWN   0 /* unused */

Definition at line 6730 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_handle_call_protected().

◆ DUK_LJ_TYPE_YIELD

#define DUK_LJ_TYPE_YIELD   2 /* value1 -> yield value, iserror -> error / normal */

Definition at line 6732 of file duktape-1.8.0/src/duktape.c.

◆ DUK_MS_FLAG_EMERGENCY

#define DUK_MS_FLAG_EMERGENCY   (1 << 0) /* emergency mode: try extra hard */

Definition at line 6747 of file duktape-1.8.0/src/duktape.c.

◆ DUK_MS_FLAG_NO_FINALIZERS

#define DUK_MS_FLAG_NO_FINALIZERS   (1 << 3) /* don't run finalizers; leave finalizable objects in finalize_list for next round */

Definition at line 6750 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__realloc_props().

◆ DUK_MS_FLAG_NO_OBJECT_COMPACTION

#define DUK_MS_FLAG_NO_OBJECT_COMPACTION   (1 << 2) /* don't compact objects; needed during object property allocation resize */

Definition at line 6749 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__realloc_props().

◆ DUK_MS_FLAG_NO_STRINGTABLE_RESIZE

#define DUK_MS_FLAG_NO_STRINGTABLE_RESIZE   (1 << 1) /* don't resize stringtable (but may sweep it); needed during stringtable resize */

Definition at line 6748 of file duktape-1.8.0/src/duktape.c.

◆ DUK_MS_FLAG_SKIP_FINALIZERS

#define DUK_MS_FLAG_SKIP_FINALIZERS   (1 << 4) /* don't run finalizers; queue finalizable objects back to heap_allocated */

Definition at line 6751 of file duktape-1.8.0/src/duktape.c.

◆ DUK_N2S_FLAG_FIXED_FORMAT

#define DUK_N2S_FLAG_FIXED_FORMAT   (1 << 0)

Definition at line 8481 of file duktape-1.8.0/src/duktape.c.

◆ DUK_N2S_FLAG_FORCE_EXP

#define DUK_N2S_FLAG_FORCE_EXP   (1 << 1)

Definition at line 8484 of file duktape-1.8.0/src/duktape.c.

◆ DUK_N2S_FLAG_FRACTION_DIGITS

#define DUK_N2S_FLAG_FRACTION_DIGITS   (1 << 3)

Definition at line 8497 of file duktape-1.8.0/src/duktape.c.

◆ DUK_N2S_FLAG_NO_ZERO_PAD

#define DUK_N2S_FLAG_NO_ZERO_PAD   (1 << 2)

Definition at line 8491 of file duktape-1.8.0/src/duktape.c.

◆ DUK_NUM_ALL_BUILTINS

#define DUK_NUM_ALL_BUILTINS   71

Definition at line 1709 of file duktape-1.8.0/src/duktape.c.

◆ DUK_NUM_BIDX_BUILTINS

#define DUK_NUM_BIDX_BUILTINS   71

Definition at line 1708 of file duktape-1.8.0/src/duktape.c.

◆ DUK_NUM_BUILTINS

#define DUK_NUM_BUILTINS   71

Definition at line 1707 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hthread_terminate().

◆ DUK_NUMCONV_H_INCLUDED

#define DUK_NUMCONV_H_INCLUDED

Definition at line 8471 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_ADD

#define DUK_OP_ADD   26

Definition at line 2620 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_BAND

#define DUK_OP_BAND   31

Definition at line 2625 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_BASL

#define DUK_OP_BASL   34

Definition at line 2628 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_BASR

#define DUK_OP_BASR   36

Definition at line 2630 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_BLSR

#define DUK_OP_BLSR   35

Definition at line 2629 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_BOR

#define DUK_OP_BOR   32

Definition at line 2626 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_BXOR

#define DUK_OP_BXOR   33

Definition at line 2627 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_CALL

#define DUK_OP_CALL   48

Definition at line 2642 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_CALLI

#define DUK_OP_CALLI   49

Definition at line 2643 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_CLOSURE

#define DUK_OP_CLOSURE   20

◆ DUK_OP_CSPROP

#define DUK_OP_CSPROP   24

Definition at line 2618 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_CSPROPI

#define DUK_OP_CSPROPI   25

Definition at line 2619 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_CSREG

#define DUK_OP_CSREG   12

Definition at line 2606 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_CSREGI

#define DUK_OP_CSREGI   13

Definition at line 2607 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_CSVAR

#define DUK_OP_CSVAR   18

Definition at line 2612 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_CSVARI

#define DUK_OP_CSVARI   19

Definition at line 2613 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_DECLVAR

#define DUK_OP_DECLVAR   16

◆ DUK_OP_DELPROP

#define DUK_OP_DELPROP   23

Definition at line 2617 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_DELVAR

#define DUK_OP_DELVAR   17

Definition at line 2611 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_DIV

#define DUK_OP_DIV   29

Definition at line 2623 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_EQ

#define DUK_OP_EQ   37

Definition at line 2631 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_EXTRA

#define DUK_OP_EXTRA   51

Definition at line 2645 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_GE

#define DUK_OP_GE   42

Definition at line 2636 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_GETPROP

#define DUK_OP_GETPROP   21

Definition at line 2615 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_GETVAR

#define DUK_OP_GETVAR   14

Definition at line 2608 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_GT

#define DUK_OP_GT   41

Definition at line 2635 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_IF

#define DUK_OP_IF   45

Definition at line 2639 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__emit_invalid().

◆ DUK_OP_JUMP

#define DUK_OP_JUMP   46

Definition at line 2640 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_LDCONST

#define DUK_OP_LDCONST   2

Definition at line 2596 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__ispec_toregconst_raw().

◆ DUK_OP_LDINT

#define DUK_OP_LDINT   3

Definition at line 2597 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__emit_load_int32().

◆ DUK_OP_LDINTX

#define DUK_OP_LDINTX   4

Definition at line 2598 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_LDREG

#define DUK_OP_LDREG   0

Definition at line 2594 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__ispec_toregconst_raw().

◆ DUK_OP_LE

#define DUK_OP_LE   44

Definition at line 2638 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_LT

#define DUK_OP_LT   43

Definition at line 2637 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_MOD

#define DUK_OP_MOD   30

Definition at line 2624 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_MPUTARR

#define DUK_OP_MPUTARR   7

Definition at line 2601 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_MPUTARRI

#define DUK_OP_MPUTARRI   8

Definition at line 2602 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_MPUTOBJ

#define DUK_OP_MPUTOBJ   5

Definition at line 2599 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_MPUTOBJI

#define DUK_OP_MPUTOBJI   6

Definition at line 2600 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_MUL

#define DUK_OP_MUL   28

Definition at line 2622 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_NEQ

#define DUK_OP_NEQ   38

Definition at line 2632 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_NEW

#define DUK_OP_NEW   9

Definition at line 2603 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_NEWI

#define DUK_OP_NEWI   10

Definition at line 2604 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_NONE

#define DUK_OP_NONE   64 /* dummy value used as marker */

Definition at line 2658 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_POSTDECP

#define DUK_OP_POSTDECP   63

Definition at line 2657 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_POSTDECR

#define DUK_OP_POSTDECR   55

Definition at line 2649 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_POSTDECV

#define DUK_OP_POSTDECV   59

Definition at line 2653 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_POSTINCP

#define DUK_OP_POSTINCP   62

Definition at line 2656 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_POSTINCR

#define DUK_OP_POSTINCR   54

Definition at line 2648 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_POSTINCV

#define DUK_OP_POSTINCV   58

Definition at line 2652 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_PREDECP

#define DUK_OP_PREDECP   61

Definition at line 2655 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_PREDECR

#define DUK_OP_PREDECR   53 /* see duk_js_executor.c */

Definition at line 2647 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_PREDECV

#define DUK_OP_PREDECV   57

Definition at line 2651 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_PREINCP

#define DUK_OP_PREINCP   60

Definition at line 2654 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_PREINCR

#define DUK_OP_PREINCR   52 /* pre/post opcode values have constraints, */

Definition at line 2646 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_PREINCV

#define DUK_OP_PREINCV   56

Definition at line 2650 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_PUTPROP

#define DUK_OP_PUTPROP   22

Definition at line 2616 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_PUTVAR

#define DUK_OP_PUTVAR   15

Definition at line 2609 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_var_decl().

◆ DUK_OP_REGEXP

#define DUK_OP_REGEXP   11

Definition at line 2605 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_RETURN

#define DUK_OP_RETURN   47

Definition at line 2641 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_func_body().

◆ DUK_OP_SEQ

#define DUK_OP_SEQ   39

Definition at line 2633 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_SNEQ

#define DUK_OP_SNEQ   40

Definition at line 2634 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_STREG

#define DUK_OP_STREG   1

Definition at line 2595 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_SUB

#define DUK_OP_SUB   27

Definition at line 2621 of file duktape-1.8.0/src/duktape.c.

◆ DUK_OP_TRYCATCH

#define DUK_OP_TRYCATCH   50

Definition at line 2644 of file duktape-1.8.0/src/duktape.c.

◆ DUK_PANIC

#define DUK_PANIC ( code,
msg )   duk_default_panic_handler((code),(msg))

Definition at line 7750 of file duktape-1.8.0/src/duktape.c.

◆ DUK_PC2LINE_MAX_DIFF_LENGTH

#define DUK_PC2LINE_MAX_DIFF_LENGTH   (((DUK_PC2LINE_SKIP - 1) * 35 + 7) / 8)

Definition at line 5319 of file duktape-1.8.0/src/duktape.c.

◆ DUK_PC2LINE_SKIP

#define DUK_PC2LINE_SKIP   64

Definition at line 5316 of file duktape-1.8.0/src/duktape.c.

◆ DUK_PROPDESC_FLAG_ACCESSOR

#define DUK_PROPDESC_FLAG_ACCESSOR   (1 << 3) /* accessor */

◆ DUK_PROPDESC_FLAG_CONFIGURABLE

◆ DUK_PROPDESC_FLAG_ENUMERABLE

#define DUK_PROPDESC_FLAG_ENUMERABLE   (1 << 1) /* E5 Section 8.6.1 */

◆ DUK_PROPDESC_FLAG_NO_OVERWRITE

#define DUK_PROPDESC_FLAG_NO_OVERWRITE   (1 << 4) /* internal define property: skip write silently if exists */

Definition at line 4900 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_define_property_internal().

◆ DUK_PROPDESC_FLAG_VIRTUAL

#define DUK_PROPDESC_FLAG_VIRTUAL
Value:
(1 << 4) /* property is virtual: used in duk_propdesc, never stored
* (used by e.g. buffer virtual properties)
*/

Definition at line 4891 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__get_own_propdesc_raw(), duk_hobject_define_property_helper(), and duk_hobject_putprop().

◆ DUK_PROPDESC_FLAG_WRITABLE

◆ DUK_PROPDESC_FLAGS_C

#define DUK_PROPDESC_FLAGS_C   (DUK_PROPDESC_FLAG_CONFIGURABLE)

Definition at line 4906 of file duktape-1.8.0/src/duktape.c.

◆ DUK_PROPDESC_FLAGS_E

#define DUK_PROPDESC_FLAGS_E   (DUK_PROPDESC_FLAG_ENUMERABLE)

Definition at line 4905 of file duktape-1.8.0/src/duktape.c.

◆ DUK_PROPDESC_FLAGS_EC

#define DUK_PROPDESC_FLAGS_EC   (DUK_PROPDESC_FLAG_ENUMERABLE | DUK_PROPDESC_FLAG_CONFIGURABLE)

Definition at line 4909 of file duktape-1.8.0/src/duktape.c.

◆ DUK_PROPDESC_FLAGS_MASK

#define DUK_PROPDESC_FLAGS_MASK
Value:

Definition at line 4892 of file duktape-1.8.0/src/duktape.c.

4892 * (used by e.g. buffer virtual properties)
4893 */
#define DUK_PROPDESC_FLAGS_MASK

Referenced by duk_hobject_define_property_internal().

◆ DUK_PROPDESC_FLAGS_NONE

#define DUK_PROPDESC_FLAGS_NONE   0

◆ DUK_PROPDESC_FLAGS_W

#define DUK_PROPDESC_FLAGS_W   (DUK_PROPDESC_FLAG_WRITABLE)

Definition at line 4904 of file duktape-1.8.0/src/duktape.c.

◆ DUK_PROPDESC_FLAGS_WC

#define DUK_PROPDESC_FLAGS_WC   (DUK_PROPDESC_FLAG_WRITABLE | DUK_PROPDESC_FLAG_CONFIGURABLE)

Definition at line 4908 of file duktape-1.8.0/src/duktape.c.

◆ DUK_PROPDESC_FLAGS_WE

#define DUK_PROPDESC_FLAGS_WE   (DUK_PROPDESC_FLAG_WRITABLE | DUK_PROPDESC_FLAG_ENUMERABLE)

Definition at line 4907 of file duktape-1.8.0/src/duktape.c.

◆ DUK_PROPDESC_FLAGS_WEC

#define DUK_PROPDESC_FLAGS_WEC
Value:

Definition at line 4910 of file duktape-1.8.0/src/duktape.c.

4910#define DUK_PROPDESC_FLAGS_WC (DUK_PROPDESC_FLAG_WRITABLE | DUK_PROPDESC_FLAG_CONFIGURABLE)
4911#define DUK_PROPDESC_FLAGS_EC (DUK_PROPDESC_FLAG_ENUMERABLE | DUK_PROPDESC_FLAG_CONFIGURABLE)
4912#define DUK_PROPDESC_FLAGS_WEC (DUK_PROPDESC_FLAG_WRITABLE | \

Referenced by duk_hobject_define_property_helper(), duk_hobject_define_property_internal(), and duk_hobject_putprop().

◆ DUK_PROPDESC_IS_ACCESSOR

#define DUK_PROPDESC_IS_ACCESSOR ( p)    (((p)->flags & DUK_PROPDESC_FLAG_ACCESSOR) != 0)

Definition at line 5173 of file duktape-1.8.0/src/duktape.c.

◆ DUK_PROPDESC_IS_CONFIGURABLE

#define DUK_PROPDESC_IS_CONFIGURABLE ( p)    (((p)->flags & DUK_PROPDESC_FLAG_CONFIGURABLE) != 0)

Definition at line 5172 of file duktape-1.8.0/src/duktape.c.

◆ DUK_PROPDESC_IS_ENUMERABLE

#define DUK_PROPDESC_IS_ENUMERABLE ( p)    (((p)->flags & DUK_PROPDESC_FLAG_ENUMERABLE) != 0)

Definition at line 5171 of file duktape-1.8.0/src/duktape.c.

◆ DUK_PROPDESC_IS_WRITABLE

#define DUK_PROPDESC_IS_WRITABLE ( p)    (((p)->flags & DUK_PROPDESC_FLAG_WRITABLE) != 0)

Definition at line 5170 of file duktape-1.8.0/src/duktape.c.

◆ duk_push_hcompiledfunction

#define duk_push_hcompiledfunction ( ctx,
h )    duk_push_hobject((ctx), (duk_hobject *) (h))

Definition at line 4350 of file duktape-1.8.0/src/duktape.c.

4350#define duk_push_hcompiledfunction(ctx,h) \
4351 duk_push_hobject((ctx), (duk_hobject *) (h))

◆ duk_push_hnativefunction

#define duk_push_hnativefunction ( ctx,
h )    duk_push_hobject((ctx), (duk_hobject *) (h))

Definition at line 4352 of file duktape-1.8.0/src/duktape.c.

4352#define duk_push_hnativefunction(ctx,h) \
4353 duk_push_hobject((ctx), (duk_hobject *) (h))

◆ duk_push_hthread

#define duk_push_hthread ( ctx,
h )    duk_push_hobject((ctx), (duk_hobject *) (h))

Definition at line 4348 of file duktape-1.8.0/src/duktape.c.

4348#define duk_push_hthread(ctx,h) \
4349 duk_push_hobject((ctx), (duk_hobject *) (h))

◆ duk_push_i32

#define duk_push_i32 ( ctx,
val )    duk_push_int((ctx), (duk_int_t) (val))

Definition at line 4287 of file duktape-1.8.0/src/duktape.c.

4287#define duk_push_i32(ctx,val) \
4288 duk_push_int((ctx), (duk_int_t) (val))

◆ duk_push_i64

#define duk_push_i64 ( ctx,
val )    duk_push_number((ctx), (duk_double_t) (val))

Definition at line 4281 of file duktape-1.8.0/src/duktape.c.

4281#define duk_push_i64(ctx,val) \
4282 duk_push_number((ctx), (duk_double_t) (val))

Referenced by duk_bi_buffer_readfield().

◆ duk_push_idx

#define duk_push_idx ( ctx,
val )    duk_push_int((ctx), (duk_int_t) (val))

Definition at line 4291 of file duktape-1.8.0/src/duktape.c.

4291#define duk_push_idx(ctx,val) \
4292 duk_push_int((ctx), (duk_int_t) (val))

◆ duk_push_size_t

#define duk_push_size_t ( ctx,
val )    duk_push_uint((ctx), (duk_uint_t) (val)) /* XXX: assumed to fit for now */

Definition at line 4295 of file duktape-1.8.0/src/duktape.c.

4295#define duk_push_size_t(ctx,val) \
4296 duk_push_uint((ctx), (duk_uint_t) (val)) /* XXX: assumed to fit for now */

Referenced by duk_bi_duktape_object_info().

◆ DUK_PUSH_SPRINTF_INITIAL_SIZE

#define DUK_PUSH_SPRINTF_INITIAL_SIZE   256L

Definition at line 4232 of file duktape-1.8.0/src/duktape.c.

◆ DUK_PUSH_SPRINTF_SANITY_LIMIT

#define DUK_PUSH_SPRINTF_SANITY_LIMIT   (1L * 1024L * 1024L * 1024L)

Definition at line 4233 of file duktape-1.8.0/src/duktape.c.

◆ duk_push_u32

#define duk_push_u32 ( ctx,
val )    duk_push_uint((ctx), (duk_uint_t) (val))

Definition at line 4285 of file duktape-1.8.0/src/duktape.c.

4285#define duk_push_u32(ctx,val) \
4286 duk_push_uint((ctx), (duk_uint_t) (val))

Referenced by duk_hobject_define_property_helper(), and duk_hobject_get_length().

◆ duk_push_u64

#define duk_push_u64 ( ctx,
val )    duk_push_number((ctx), (duk_double_t) (val))

Definition at line 4279 of file duktape-1.8.0/src/duktape.c.

4279#define duk_push_u64(ctx,val) \
4280 duk_push_number((ctx), (duk_double_t) (val))

◆ duk_push_uarridx

#define duk_push_uarridx ( ctx,
val )    duk_push_uint((ctx), (duk_uint_t) (val))

Definition at line 4293 of file duktape-1.8.0/src/duktape.c.

4293#define duk_push_uarridx(ctx,val) \
4294 duk_push_uint((ctx), (duk_uint_t) (val))

Referenced by duk__init_varmap_and_prologue_for_pass2().

◆ DUK_RAW_READ_DOUBLE_BE

#define DUK_RAW_READ_DOUBLE_BE ( ptr)    duk_raw_read_double_be(&(ptr));

Definition at line 1822 of file duktape-1.8.0/src/duktape.c.

◆ DUK_RAW_READ_U16_BE

#define DUK_RAW_READ_U16_BE ( ptr)    duk_raw_read_u16_be(&(ptr));

Definition at line 1820 of file duktape-1.8.0/src/duktape.c.

◆ DUK_RAW_READ_U32_BE

#define DUK_RAW_READ_U32_BE ( ptr)    duk_raw_read_u32_be(&(ptr));

Definition at line 1821 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__load_buffer_raw().

◆ DUK_RAW_READ_U8

#define DUK_RAW_READ_U8 ( ptr)    ((duk_uint8_t) (*(ptr)++))

Definition at line 1819 of file duktape-1.8.0/src/duktape.c.

◆ DUK_RAW_WRITE_CESU8

#define DUK_RAW_WRITE_CESU8 ( ptr,
val )
Value:
do { \
/* 'ptr' is evaluated both as LHS and RHS. */ \
duk_uint8_t *duk__ptr; \
duk_small_int_t duk__len; \
duk__ptr = (duk_uint8_t *) (ptr); \
duk__len = duk_unicode_encode_cesu8((duk_ucodepoint_t) (val), duk__ptr); \
duk__ptr += duk__len; \
(ptr) = duk__ptr; \
} while (0)

Definition at line 1809 of file duktape-1.8.0/src/duktape.c.

1809#define DUK_RAW_WRITE_CESU8(ptr,val) do { \
1810 /* 'ptr' is evaluated both as LHS and RHS. */ \
1811 duk_uint8_t *duk__ptr; \
1812 duk_small_int_t duk__len; \
1813 duk__ptr = (duk_uint8_t *) (ptr); \
1814 duk__len = duk_unicode_encode_cesu8((duk_ucodepoint_t) (val), duk__ptr); \
1815 duk__ptr += duk__len; \
1816 (ptr) = duk__ptr; \
1817 } while (0)

◆ DUK_RAW_WRITE_DOUBLE_BE

#define DUK_RAW_WRITE_DOUBLE_BE ( ptr,
val )   duk_raw_write_double_be(&(ptr), (duk_double_t) (val))

Definition at line 1799 of file duktape-1.8.0/src/duktape.c.

◆ DUK_RAW_WRITE_U16_BE

#define DUK_RAW_WRITE_U16_BE ( ptr,
val )   duk_raw_write_u16_be(&(ptr), (duk_uint16_t) (val))

Definition at line 1797 of file duktape-1.8.0/src/duktape.c.

◆ DUK_RAW_WRITE_U32_BE

#define DUK_RAW_WRITE_U32_BE ( ptr,
val )   duk_raw_write_u32_be(&(ptr), (duk_uint32_t) (val))

Definition at line 1798 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__dump_hbuffer_raw().

◆ DUK_RAW_WRITE_U8

#define DUK_RAW_WRITE_U8 ( ptr,
val )
Value:
do { \
*(ptr)++ = (duk_uint8_t) (val); \
} while (0)

Definition at line 1794 of file duktape-1.8.0/src/duktape.c.

1794#define DUK_RAW_WRITE_U8(ptr,val) do { \
1795 *(ptr)++ = (duk_uint8_t) (val); \
1796 } while (0)

◆ DUK_RAW_WRITE_XUTF8

#define DUK_RAW_WRITE_XUTF8 ( ptr,
val )
Value:
do { \
/* 'ptr' is evaluated both as LHS and RHS. */ \
duk_uint8_t *duk__ptr; \
duk_small_int_t duk__len; \
duk__ptr = (duk_uint8_t *) (ptr); \
duk__len = duk_unicode_encode_xutf8((duk_ucodepoint_t) (val), duk__ptr); \
duk__ptr += duk__len; \
(ptr) = duk__ptr; \
} while (0)

Definition at line 1800 of file duktape-1.8.0/src/duktape.c.

1800#define DUK_RAW_WRITE_XUTF8(ptr,val) do { \
1801 /* 'ptr' is evaluated both as LHS and RHS. */ \
1802 duk_uint8_t *duk__ptr; \
1803 duk_small_int_t duk__len; \
1804 duk__ptr = (duk_uint8_t *) (ptr); \
1805 duk__len = duk_unicode_encode_xutf8((duk_ucodepoint_t) (val), duk__ptr); \
1806 duk__ptr += duk__len; \
1807 (ptr) = duk__ptr; \
1808 } while (0)

◆ DUK_RE_COMPILE_TOKEN_LIMIT

#define DUK_RE_COMPILE_TOKEN_LIMIT   100000000L /* 1e8 */

Definition at line 3395 of file duktape-1.8.0/src/duktape.c.

◆ DUK_RE_EXECUTE_STEPS_LIMIT

#define DUK_RE_EXECUTE_STEPS_LIMIT   1000000000L /* 1e9 */

Definition at line 3398 of file duktape-1.8.0/src/duktape.c.

◆ DUK_RE_FLAG_GLOBAL

#define DUK_RE_FLAG_GLOBAL   (1 << 0)

Definition at line 3422 of file duktape-1.8.0/src/duktape.c.

◆ DUK_RE_FLAG_IGNORE_CASE

#define DUK_RE_FLAG_IGNORE_CASE   (1 << 1)

◆ DUK_RE_FLAG_MULTILINE

#define DUK_RE_FLAG_MULTILINE   (1 << 2)

Definition at line 3424 of file duktape-1.8.0/src/duktape.c.

◆ DUK_RE_MAX_ATOM_COPIES

#define DUK_RE_MAX_ATOM_COPIES   1000

Definition at line 3392 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RE_QUANTIFIER_INFINITE

#define DUK_RE_QUANTIFIER_INFINITE   ((duk_uint32_t) 0xffffffffUL)

Definition at line 3086 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REALLOC

#define DUK_REALLOC ( heap,
ptr,
newsize )   duk_heap_mem_realloc((heap), (ptr), (newsize))

Definition at line 6893 of file duktape-1.8.0/src/duktape.c.

◆ DUK_REALLOC_INDIRECT

#define DUK_REALLOC_INDIRECT ( heap,
cb,
ud,
newsize )   duk_heap_mem_realloc_indirect((heap), (cb), (ud), (newsize))

Definition at line 6894 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__resize_valstack(), and duk_hbuffer_resize().

◆ DUK_REALLOC_RAW

#define DUK_REALLOC_RAW ( heap,
ptr,
newsize )    ((heap)->realloc_func((heap)->heap_udata, (void *) (ptr), (newsize)))

Definition at line 6854 of file duktape-1.8.0/src/duktape.c.

6854
6855/*

Referenced by duk_free().

◆ DUK_REGEXP_H_INCLUDED

#define DUK_REGEXP_H_INCLUDED

Definition at line 3389 of file duktape-1.8.0/src/duktape.c.

◆ DUK_REOP_ASSERT_END

#define DUK_REOP_ASSERT_END   17

Definition at line 3417 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REOP_ASSERT_NOT_WORD_BOUNDARY

#define DUK_REOP_ASSERT_NOT_WORD_BOUNDARY   19

Definition at line 3419 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REOP_ASSERT_START

#define DUK_REOP_ASSERT_START   16

Definition at line 3416 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REOP_ASSERT_WORD_BOUNDARY

#define DUK_REOP_ASSERT_WORD_BOUNDARY   18

Definition at line 3418 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REOP_BACKREFERENCE

#define DUK_REOP_BACKREFERENCE   15

Definition at line 3415 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REOP_CHAR

#define DUK_REOP_CHAR   2

Definition at line 3402 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REOP_INVRANGES

#define DUK_REOP_INVRANGES   5

Definition at line 3405 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REOP_JUMP

#define DUK_REOP_JUMP   6

Definition at line 3406 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REOP_LOOKNEG

#define DUK_REOP_LOOKNEG   14

Definition at line 3414 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REOP_LOOKPOS

#define DUK_REOP_LOOKPOS   13

Definition at line 3413 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REOP_MATCH

#define DUK_REOP_MATCH   1

Definition at line 3401 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REOP_PERIOD

#define DUK_REOP_PERIOD   3

Definition at line 3403 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REOP_RANGES

#define DUK_REOP_RANGES   4

Definition at line 3404 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REOP_SAVE

#define DUK_REOP_SAVE   11

Definition at line 3411 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REOP_SPLIT1

#define DUK_REOP_SPLIT1   7

Definition at line 3407 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REOP_SPLIT2

#define DUK_REOP_SPLIT2   8

Definition at line 3408 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REOP_SQGREEDY

#define DUK_REOP_SQGREEDY   10

Definition at line 3410 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REOP_SQMINIMAL

#define DUK_REOP_SQMINIMAL   9

Definition at line 3409 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REOP_WIPERANGE

#define DUK_REOP_WIPERANGE   12

Definition at line 3412 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_REPLACEMENTS_H_INCLUDED

#define DUK_REPLACEMENTS_H_INCLUDED

Definition at line 162 of file duktape-1.8.0/src/duktape.c.

◆ DUK_RETOK_ASSERT_END

#define DUK_RETOK_ASSERT_END   4

Definition at line 3046 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_ASSERT_NOT_WORD_BOUNDARY

#define DUK_RETOK_ASSERT_NOT_WORD_BOUNDARY   6

Definition at line 3048 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_ASSERT_START

#define DUK_RETOK_ASSERT_START   3

Definition at line 3045 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_ASSERT_START_NEG_LOOKAHEAD

#define DUK_RETOK_ASSERT_START_NEG_LOOKAHEAD   8

Definition at line 3050 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_ASSERT_START_POS_LOOKAHEAD

#define DUK_RETOK_ASSERT_START_POS_LOOKAHEAD   7

Definition at line 3049 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_ASSERT_WORD_BOUNDARY

#define DUK_RETOK_ASSERT_WORD_BOUNDARY   5

Definition at line 3047 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_ATOM_BACKREFERENCE

#define DUK_RETOK_ATOM_BACKREFERENCE   17

Definition at line 3059 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_ATOM_CHAR

#define DUK_RETOK_ATOM_CHAR   10

Definition at line 3052 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_ATOM_DIGIT

#define DUK_RETOK_ATOM_DIGIT   11

Definition at line 3053 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_ATOM_END_GROUP

#define DUK_RETOK_ATOM_END_GROUP   22

Definition at line 3064 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_ATOM_NOT_DIGIT

#define DUK_RETOK_ATOM_NOT_DIGIT   12

Definition at line 3054 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_ATOM_NOT_WHITE

#define DUK_RETOK_ATOM_NOT_WHITE   14

Definition at line 3056 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_ATOM_NOT_WORD_CHAR

#define DUK_RETOK_ATOM_NOT_WORD_CHAR   16

Definition at line 3058 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_ATOM_PERIOD

#define DUK_RETOK_ATOM_PERIOD   9

Definition at line 3051 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_ATOM_START_CAPTURE_GROUP

#define DUK_RETOK_ATOM_START_CAPTURE_GROUP   18

Definition at line 3060 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_ATOM_START_CHARCLASS

#define DUK_RETOK_ATOM_START_CHARCLASS   20

Definition at line 3062 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_ATOM_START_CHARCLASS_INVERTED

#define DUK_RETOK_ATOM_START_CHARCLASS_INVERTED   21

Definition at line 3063 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_ATOM_START_NONCAPTURE_GROUP

#define DUK_RETOK_ATOM_START_NONCAPTURE_GROUP   19

Definition at line 3061 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_ATOM_WHITE

#define DUK_RETOK_ATOM_WHITE   13

Definition at line 3055 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_ATOM_WORD_CHAR

#define DUK_RETOK_ATOM_WORD_CHAR   15

Definition at line 3057 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_DISJUNCTION

#define DUK_RETOK_DISJUNCTION   1

Definition at line 3043 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_EOF

#define DUK_RETOK_EOF   0

Definition at line 3042 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_RETOK_QUANTIFIER

#define DUK_RETOK_QUANTIFIER   2

Definition at line 3044 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_S2N_FLAG_ALLOW_AUTO_HEX_INT

#define DUK_S2N_FLAG_ALLOW_AUTO_HEX_INT   (1 << 11)

Definition at line 8545 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_S2N_FLAG_ALLOW_AUTO_OCT_INT

#define DUK_S2N_FLAG_ALLOW_AUTO_OCT_INT   (1 << 12)

Definition at line 8550 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_S2N_FLAG_ALLOW_EMPTY_AS_ZERO

#define DUK_S2N_FLAG_ALLOW_EMPTY_AS_ZERO   (1 << 9)

Definition at line 8537 of file duktape-1.8.0/src/duktape.c.

◆ DUK_S2N_FLAG_ALLOW_EMPTY_FRAC

#define DUK_S2N_FLAG_ALLOW_EMPTY_FRAC   (1 << 8)

Definition at line 8534 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_S2N_FLAG_ALLOW_EXP

#define DUK_S2N_FLAG_ALLOW_EXP   (1 << 1)

◆ DUK_S2N_FLAG_ALLOW_FRAC

#define DUK_S2N_FLAG_ALLOW_FRAC   (1 << 6)

Definition at line 8528 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_S2N_FLAG_ALLOW_GARBAGE

#define DUK_S2N_FLAG_ALLOW_GARBAGE   (1 << 2)

Definition at line 8516 of file duktape-1.8.0/src/duktape.c.

◆ DUK_S2N_FLAG_ALLOW_INF

#define DUK_S2N_FLAG_ALLOW_INF   (1 << 5)

Definition at line 8525 of file duktape-1.8.0/src/duktape.c.

◆ DUK_S2N_FLAG_ALLOW_LEADING_ZERO

#define DUK_S2N_FLAG_ALLOW_LEADING_ZERO   (1 << 10)

Definition at line 8540 of file duktape-1.8.0/src/duktape.c.

◆ DUK_S2N_FLAG_ALLOW_MINUS

#define DUK_S2N_FLAG_ALLOW_MINUS   (1 << 4)

Definition at line 8522 of file duktape-1.8.0/src/duktape.c.

◆ DUK_S2N_FLAG_ALLOW_NAKED_FRAC

#define DUK_S2N_FLAG_ALLOW_NAKED_FRAC   (1 << 7)

Definition at line 8531 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_S2N_FLAG_ALLOW_PLUS

#define DUK_S2N_FLAG_ALLOW_PLUS   (1 << 3)

Definition at line 8519 of file duktape-1.8.0/src/duktape.c.

◆ DUK_S2N_FLAG_TRIM_WHITE

#define DUK_S2N_FLAG_TRIM_WHITE   (1 << 0)

Definition at line 8510 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__tonumber_string_raw().

◆ DUK_S2N_MAX_EXPONENT

#define DUK_S2N_MAX_EXPONENT   1000000000

Definition at line 8507 of file duktape-1.8.0/src/duktape.c.

◆ DUK_SELFTEST_H_INCLUDED

#define DUK_SELFTEST_H_INCLUDED

Definition at line 8636 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STEP_TYPE_INTO

#define DUK_STEP_TYPE_INTO   1

Definition at line 6926 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STEP_TYPE_NONE

#define DUK_STEP_TYPE_NONE   0

Definition at line 6925 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STEP_TYPE_OUT

#define DUK_STEP_TYPE_OUT   3

Definition at line 6928 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STEP_TYPE_OVER

#define DUK_STEP_TYPE_OVER   2

Definition at line 6927 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_ALLOC_FAILED

#define DUK_STR_ALLOC_FAILED   duk_str_alloc_failed

Definition at line 2331 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_ARRAY_LENGTH_NOT_WRITABLE

#define DUK_STR_ARRAY_LENGTH_NOT_WRITABLE   duk_str_array_length_not_writable

Definition at line 2385 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_define_property_helper().

◆ DUK_STR_ARRAY_LENGTH_OVER_2G

#define DUK_STR_ARRAY_LENGTH_OVER_2G   duk_str_array_length_over_2g

Definition at line 2340 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_array_constructor().

◆ DUK_STR_ARRAY_LENGTH_WRITE_FAILED

#define DUK_STR_ARRAY_LENGTH_WRITE_FAILED   duk_str_array_length_write_failed

Definition at line 2384 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_putprop().

◆ DUK_STR_BOUND_CHAIN_LIMIT

#define DUK_STR_BOUND_CHAIN_LIMIT   duk_str_bound_chain_limit

Definition at line 2481 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_js_instanceof().

◆ DUK_STR_BUFFER_TOO_LONG

#define DUK_STR_BUFFER_TOO_LONG   duk_str_buffer_too_long

Definition at line 2329 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_BYTECODE_LIMIT

#define DUK_STR_BYTECODE_LIMIT   duk_str_bytecode_limit

Definition at line 2484 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_C_CALLSTACK_LIMIT

#define DUK_STR_C_CALLSTACK_LIMIT   duk_str_c_callstack_limit

Definition at line 2482 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_CALLSTACK_LIMIT

#define DUK_STR_CALLSTACK_LIMIT   duk_str_callstack_limit

Definition at line 2478 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hthread_callstack_grow().

◆ DUK_STR_CANNOT_DELETE_IDENTIFIER

#define DUK_STR_CANNOT_DELETE_IDENTIFIER   duk_str_cannot_delete_identifier

Definition at line 2411 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_CATCHSTACK_LIMIT

#define DUK_STR_CATCHSTACK_LIMIT   duk_str_catchstack_limit

Definition at line 2479 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_COMPILER_RECURSION_LIMIT

#define DUK_STR_COMPILER_RECURSION_LIMIT   duk_str_compiler_recursion_limit

Definition at line 2483 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_CONCAT_RESULT_TOO_LONG

#define DUK_STR_CONCAT_RESULT_TOO_LONG   duk_str_concat_result_too_long

Definition at line 2337 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_CONST_LIMIT

#define DUK_STR_CONST_LIMIT   duk_str_const_limit

Definition at line 2487 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_CYCLIC_INPUT

#define DUK_STR_CYCLIC_INPUT   duk_str_cyclic_input

Definition at line 2369 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_DECODE_FAILED

#define DUK_STR_DECODE_FAILED   duk_str_decode_failed

Definition at line 2335 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_DEFAULTVALUE_COERCE_FAILED

#define DUK_STR_DEFAULTVALUE_COERCE_FAILED   duk_str_defaultvalue_coerce_failed

Definition at line 2325 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_DUPLICATE_LABEL

#define DUK_STR_DUPLICATE_LABEL   duk_str_duplicate_label

Definition at line 2406 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_EMPTY_EXPR_NOT_ALLOWED

#define DUK_STR_EMPTY_EXPR_NOT_ALLOWED   duk_str_empty_expr_not_allowed

Definition at line 2415 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_ENCODE_FAILED

#define DUK_STR_ENCODE_FAILED   duk_str_encode_failed

Definition at line 2334 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_EXPECTED_IDENTIFIER

#define DUK_STR_EXPECTED_IDENTIFIER   duk_str_expected_identifier

Definition at line 2414 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_FMT_INVALID_JSON

#define DUK_STR_FMT_INVALID_JSON   duk_str_fmt_invalid_json

Definition at line 2366 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__dec_eat_white().

◆ DUK_STR_FMT_PTR

#define DUK_STR_FMT_PTR   duk_str_fmt_ptr

Definition at line 2365 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_FUNC_LIMIT

#define DUK_STR_FUNC_LIMIT   duk_str_func_limit

Definition at line 2488 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_FUNC_NAME_REQUIRED

#define DUK_STR_FUNC_NAME_REQUIRED   duk_str_func_name_required

Definition at line 2428 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_FUNC_STMT_NOT_ALLOWED

#define DUK_STR_FUNC_STMT_NOT_ALLOWED   duk_str_func_stmt_not_allowed

Definition at line 2423 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_INTERNAL_ERROR

#define DUK_STR_INTERNAL_ERROR   duk_str_internal_error

Definition at line 2287 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_INVALID_ARG_NAME

#define DUK_STR_INVALID_ARG_NAME   duk_str_invalid_arg_name

◆ DUK_STR_INVALID_ARRAY_LENGTH

#define DUK_STR_INVALID_ARRAY_LENGTH   duk_str_invalid_array_length

Definition at line 2383 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_INVALID_ARRAY_LITERAL

#define DUK_STR_INVALID_ARRAY_LITERAL   duk_str_invalid_array_literal

Definition at line 2408 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_INVALID_BACKREFS

#define DUK_STR_INVALID_BACKREFS   duk_str_invalid_backrefs

Definition at line 2464 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_INVALID_BASE

#define DUK_STR_INVALID_BASE   duk_str_invalid_base

Definition at line 2380 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_putprop().

◆ DUK_STR_INVALID_BREAK_CONT_LABEL

#define DUK_STR_INVALID_BREAK_CONT_LABEL   duk_str_invalid_break_cont_label

Definition at line 2418 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_INVALID_CALL_ARGS

#define DUK_STR_INVALID_CALL_ARGS   duk_str_invalid_call_args

◆ DUK_STR_INVALID_CONTEXT

#define DUK_STR_INVALID_CONTEXT   duk_str_invalid_context

Definition at line 2307 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_INVALID_COUNT

#define DUK_STR_INVALID_COUNT   duk_str_invalid_count

Definition at line 2288 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_INVALID_DESCRIPTOR

#define DUK_STR_INVALID_DESCRIPTOR   duk_str_invalid_descriptor

◆ DUK_STR_INVALID_EXPRESSION

#define DUK_STR_INVALID_EXPRESSION   duk_str_invalid_expression

Definition at line 2412 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_INVALID_FOR

#define DUK_STR_INVALID_FOR   duk_str_invalid_for

Definition at line 2416 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_INVALID_FUNC_NAME

#define DUK_STR_INVALID_FUNC_NAME   duk_str_invalid_func_name

Definition at line 2426 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_func_body().

◆ DUK_STR_INVALID_GETSET_NAME

#define DUK_STR_INVALID_GETSET_NAME   duk_str_invalid_getset_name

Definition at line 2427 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_INVALID_INDEX

#define DUK_STR_INVALID_INDEX   duk_str_invalid_call_args

Definition at line 2308 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_INVALID_LABEL

#define DUK_STR_INVALID_LABEL   duk_str_invalid_label

Definition at line 2407 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_INVALID_LVALUE

#define DUK_STR_INVALID_LVALUE   duk_str_invalid_lvalue

Definition at line 2413 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_INVALID_OBJECT_LITERAL

#define DUK_STR_INVALID_OBJECT_LITERAL   duk_str_invalid_object_literal

Definition at line 2409 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_INVALID_QUANTIFIER_NO_ATOM

#define DUK_STR_INVALID_QUANTIFIER_NO_ATOM   duk_str_invalid_quantifier_no_atom

Definition at line 2457 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_STR_INVALID_QUANTIFIER_VALUES

#define DUK_STR_INVALID_QUANTIFIER_VALUES   duk_str_invalid_quantifier_values

Definition at line 2458 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_STR_INVALID_REGEXP_FLAGS

#define DUK_STR_INVALID_REGEXP_FLAGS   duk_str_invalid_regexp_flags

Definition at line 2463 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_INVALID_RETURN

#define DUK_STR_INVALID_RETURN   duk_str_invalid_return

Definition at line 2419 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_INVALID_SWITCH

#define DUK_STR_INVALID_SWITCH   duk_str_invalid_switch

Definition at line 2417 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_INVALID_THROW

#define DUK_STR_INVALID_THROW   duk_str_invalid_throw

Definition at line 2421 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_try_stmt().

◆ DUK_STR_INVALID_TRY

#define DUK_STR_INVALID_TRY   duk_str_invalid_try

Definition at line 2420 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_INVALID_VAR_DECLARATION

#define DUK_STR_INVALID_VAR_DECLARATION   duk_str_invalid_var_declaration

Definition at line 2410 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_JSONDEC_RECLIMIT

#define DUK_STR_JSONDEC_RECLIMIT   duk_str_jsondec_reclimit

Definition at line 2367 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_JSONENC_RECLIMIT

#define DUK_STR_JSONENC_RECLIMIT   duk_str_jsonenc_reclimit

Definition at line 2368 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_NO_SOURCECODE

#define DUK_STR_NO_SOURCECODE   duk_str_no_sourcecode

Definition at line 2336 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_NOT_BOOLEAN

#define DUK_STR_NOT_BOOLEAN   duk_str_unexpected_type

Definition at line 2312 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_get_number().

◆ DUK_STR_NOT_BUFFER

#define DUK_STR_NOT_BUFFER   duk_str_not_buffer /* still in use with verbose messages */

Definition at line 2317 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_require_hthread().

◆ DUK_STR_NOT_C_FUNCTION

#define DUK_STR_NOT_C_FUNCTION   duk_str_unexpected_type

Definition at line 2322 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_NOT_CALLABLE

#define DUK_STR_NOT_CALLABLE   duk_str_not_callable

Definition at line 2291 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_NOT_COMPILEDFUNCTION

#define DUK_STR_NOT_COMPILEDFUNCTION   duk_str_unexpected_type

Definition at line 2320 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_require_hnativefunction().

◆ DUK_STR_NOT_CONFIGURABLE

#define DUK_STR_NOT_CONFIGURABLE   duk_str_not_configurable

Definition at line 2294 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_NOT_CONSTRUCTABLE

#define DUK_STR_NOT_CONSTRUCTABLE   duk_str_not_constructable

Definition at line 2290 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_NOT_EXTENSIBLE

#define DUK_STR_NOT_EXTENSIBLE   duk_str_not_extensible

Definition at line 2292 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_putprop().

◆ DUK_STR_NOT_FUNCTION

#define DUK_STR_NOT_FUNCTION   duk_str_unexpected_type

Definition at line 2323 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_get_heapptr().

◆ DUK_STR_NOT_NATIVEFUNCTION

#define DUK_STR_NOT_NATIVEFUNCTION   duk_str_unexpected_type

Definition at line 2321 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_NOT_NULL

#define DUK_STR_NOT_NULL   duk_str_unexpected_type

Definition at line 2311 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_NOT_NUMBER

#define DUK_STR_NOT_NUMBER   duk_str_unexpected_type

Definition at line 2313 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_normalize_index().

◆ DUK_STR_NOT_OBJECT

#define DUK_STR_NOT_OBJECT   duk_str_unexpected_type

Definition at line 2315 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_get_hobject_with_class().

◆ DUK_STR_NOT_OBJECT_COERCIBLE

#define DUK_STR_NOT_OBJECT_COERCIBLE   duk_str_not_object_coercible

Definition at line 2327 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_NOT_POINTER

#define DUK_STR_NOT_POINTER   duk_str_unexpected_type

Definition at line 2316 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_NOT_REGEXP

#define DUK_STR_NOT_REGEXP   duk_str_unexpected_type

Definition at line 2324 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_NOT_STRING

#define DUK_STR_NOT_STRING   duk_str_unexpected_type

Definition at line 2314 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_NOT_THREAD

#define DUK_STR_NOT_THREAD   duk_str_unexpected_type

Definition at line 2319 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_require_hcompiledfunction().

◆ DUK_STR_NOT_UNDEFINED

#define DUK_STR_NOT_UNDEFINED   duk_str_unexpected_type

Definition at line 2310 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_require_null().

◆ DUK_STR_NOT_WRITABLE

#define DUK_STR_NOT_WRITABLE   duk_str_not_writable

Definition at line 2293 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_putprop().

◆ DUK_STR_NUMBER_OUTSIDE_RANGE

#define DUK_STR_NUMBER_OUTSIDE_RANGE   duk_str_number_outside_range

Definition at line 2326 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_to_string().

◆ DUK_STR_PARSE_ERROR

#define DUK_STR_PARSE_ERROR   duk_str_parse_error

Definition at line 2405 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_POP_TOO_MANY

#define DUK_STR_POP_TOO_MANY   duk_str_pop_too_many

Definition at line 2332 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_PROPERTY_IS_VIRTUAL

#define DUK_STR_PROPERTY_IS_VIRTUAL   duk_str_property_is_virtual

Definition at line 2389 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_define_property_helper().

◆ DUK_STR_PROTOTYPE_CHAIN_LIMIT

#define DUK_STR_PROTOTYPE_CHAIN_LIMIT   duk_str_prototype_chain_limit

◆ DUK_STR_PROXY_REJECTED

#define DUK_STR_PROXY_REJECTED   duk_str_proxy_rejected

Definition at line 2382 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_putprop().

◆ DUK_STR_PROXY_REVOKED

#define DUK_STR_PROXY_REVOKED   duk_str_proxy_revoked

Definition at line 2379 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_PUSH_BEYOND_ALLOC_STACK

#define DUK_STR_PUSH_BEYOND_ALLOC_STACK   duk_str_push_beyond_alloc_stack

Definition at line 2309 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_QUANTIFIER_TOO_MANY_COPIES

#define DUK_STR_QUANTIFIER_TOO_MANY_COPIES   duk_str_quantifier_too_many_copies

Definition at line 2459 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_STR_REDEFINE_VIRT_PROP

#define DUK_STR_REDEFINE_VIRT_PROP   duk_str_redefine_virt_prop

Definition at line 2387 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_REG_LIMIT

#define DUK_STR_REG_LIMIT   duk_str_reg_limit

◆ DUK_STR_REGEXP_COMPILER_RECURSION_LIMIT

#define DUK_STR_REGEXP_COMPILER_RECURSION_LIMIT   duk_str_regexp_compiler_recursion_limit

Definition at line 2489 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_STR_REGEXP_EXECUTOR_RECURSION_LIMIT

#define DUK_STR_REGEXP_EXECUTOR_RECURSION_LIMIT   duk_str_regexp_executor_recursion_limit

Definition at line 2490 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_REGEXP_EXECUTOR_STEP_LIMIT

#define DUK_STR_REGEXP_EXECUTOR_STEP_LIMIT   duk_str_regexp_executor_step_limit

Definition at line 2491 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_SETTER_UNDEFINED

#define DUK_STR_SETTER_UNDEFINED   duk_str_setter_undefined

Definition at line 2386 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_putprop().

◆ DUK_STR_SPRINTF_TOO_LONG

#define DUK_STR_SPRINTF_TOO_LONG   duk_str_sprintf_too_long

Definition at line 2330 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_push_sprintf().

◆ DUK_STR_STRICT_CALLER_READ

#define DUK_STR_STRICT_CALLER_READ   duk_str_strict_caller_read

Definition at line 2381 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_STRING_TOO_LONG

#define DUK_STR_STRING_TOO_LONG   duk_str_string_too_long

Definition at line 2328 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_TEMP_LIMIT

#define DUK_STR_TEMP_LIMIT   duk_str_temp_limit

Definition at line 2486 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__settemp_checkmax().

◆ DUK_STR_UNEXPECTED_CLOSING_PAREN

#define DUK_STR_UNEXPECTED_CLOSING_PAREN   duk_str_unexpected_closing_paren

Definition at line 2460 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_STR_UNEXPECTED_END_OF_PATTERN

#define DUK_STR_UNEXPECTED_END_OF_PATTERN   duk_str_unexpected_end_of_pattern

Definition at line 2461 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_STR_UNEXPECTED_REGEXP_TOKEN

#define DUK_STR_UNEXPECTED_REGEXP_TOKEN   duk_str_unexpected_regexp_token

Definition at line 2462 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ DUK_STR_UNEXPECTED_TYPE

#define DUK_STR_UNEXPECTED_TYPE   duk_str_unexpected_type

Definition at line 2318 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_is_null_or_undefined().

◆ DUK_STR_UNIMPLEMENTED

#define DUK_STR_UNIMPLEMENTED   duk_str_unimplemented

Definition at line 2338 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_UNSUPPORTED

#define DUK_STR_UNSUPPORTED   duk_str_unsupported

Definition at line 2339 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_UNTERMINATED_STMT

#define DUK_STR_UNTERMINATED_STMT   duk_str_unterminated_stmt

Definition at line 2424 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_VALSTACK_LIMIT

#define DUK_STR_VALSTACK_LIMIT   duk_str_valstack_limit

Definition at line 2477 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_WITH_IN_STRICT_MODE

#define DUK_STR_WITH_IN_STRICT_MODE   duk_str_with_in_strict_mode

Definition at line 2422 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STR_WRONG_BUFFER_TYPE

#define DUK_STR_WRONG_BUFFER_TYPE   duk_str_wrong_buffer_type

Definition at line 2333 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRDATA_DATA_LENGTH

#define DUK_STRDATA_DATA_LENGTH   1049

Definition at line 1472 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRDATA_MAX_STRLEN

#define DUK_STRDATA_MAX_STRLEN   17

Definition at line 1471 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX___PROTO__

#define DUK_STRIDX___PROTO__   76 /* '__proto__' */

Definition at line 1114 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_ARRAY

#define DUK_STRIDX_ARRAY   5 /* 'Array' */

Definition at line 901 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_ARRAY_BUFFER

#define DUK_STRIDX_ARRAY_BUFFER   15 /* 'ArrayBuffer' */

Definition at line 931 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_BASE64

#define DUK_STRIDX_BASE64   124 /* 'base64' */

Definition at line 1258 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_BRACKETED_ELLIPSIS

#define DUK_STRIDX_BRACKETED_ELLIPSIS   65 /* '[...]' */

Definition at line 1081 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__error_getter_helper().

◆ DUK_STRIDX_BREAK

#define DUK_STRIDX_BREAK   146 /* 'break' */

Definition at line 1324 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_BYTE_LENGTH

#define DUK_STRIDX_BYTE_LENGTH   86 /* 'byteLength' */

Definition at line 1144 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_BYTE_OFFSET

#define DUK_STRIDX_BYTE_OFFSET   87 /* 'byteOffset' */

Definition at line 1147 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_BYTES_PER_ELEMENT

#define DUK_STRIDX_BYTES_PER_ELEMENT   88 /* 'BYTES_PER_ELEMENT' */

Definition at line 1150 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_CALLEE

#define DUK_STRIDX_CALLEE   68 /* 'callee' */

Definition at line 1090 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_CALLER

#define DUK_STRIDX_CALLER   69 /* 'caller' */

Definition at line 1093 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_CASE

#define DUK_STRIDX_CASE   147 /* 'case' */

Definition at line 1327 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_CATCH

#define DUK_STRIDX_CATCH   148 /* 'catch' */

Definition at line 1330 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_CLASS

#define DUK_STRIDX_CLASS   173 /* 'class' */

Definition at line 1405 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_CLOG

#define DUK_STRIDX_CLOG   138 /* 'clog' */

Definition at line 1300 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_COMMA

#define DUK_STRIDX_COMMA   62 /* ',' */

Definition at line 1072 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_COMPILE

#define DUK_STRIDX_COMPILE   116 /* 'compile' */

Definition at line 1234 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_CONFIGURABLE

#define DUK_STRIDX_CONFIGURABLE   36 /* 'configurable' */

◆ DUK_STRIDX_CONST

#define DUK_STRIDX_CONST   169 /* 'const' */

Definition at line 1393 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_CONSTRUCTOR

#define DUK_STRIDX_CONSTRUCTOR   51 /* 'constructor' */

Definition at line 1039 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_CONTINUE

#define DUK_STRIDX_CONTINUE   149 /* 'continue' */

Definition at line 1333 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_DATA

#define DUK_STRIDX_DATA   84 /* 'data' */

Definition at line 1138 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_DATA_VIEW

#define DUK_STRIDX_DATA_VIEW   16 /* 'DataView' */

Definition at line 934 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_DATE

#define DUK_STRIDX_DATE   9 /* 'Date' */

Definition at line 913 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_DEBUGGER

#define DUK_STRIDX_DEBUGGER   150 /* 'debugger' */

Definition at line 1336 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_DEC_ENV

#define DUK_STRIDX_DEC_ENV   28 /* 'DecEnv' */

Definition at line 970 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_DEFAULT

#define DUK_STRIDX_DEFAULT   151 /* 'default' */

Definition at line 1339 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_DEFINE_PROPERTY

#define DUK_STRIDX_DEFINE_PROPERTY   33 /* 'defineProperty' */

Definition at line 985 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_DELETE

#define DUK_STRIDX_DELETE   152 /* 'delete' */

Definition at line 1342 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_DELETE_PROPERTY

#define DUK_STRIDX_DELETE_PROPERTY   72 /* 'deleteProperty' */

Definition at line 1102 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_DO

#define DUK_STRIDX_DO   153 /* 'do' */

Definition at line 1345 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_ELSE

#define DUK_STRIDX_ELSE   154 /* 'else' */

Definition at line 1348 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_EMPTY_STRING

#define DUK_STRIDX_EMPTY_STRING   14 /* '' */

Definition at line 928 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_string_constructor().

◆ DUK_STRIDX_END_RESERVED

#define DUK_STRIDX_END_RESERVED   191 /* exclusive endpoint */

Definition at line 1463 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_STRIDX_ENUM

#define DUK_STRIDX_ENUM   174 /* 'enum' */

Definition at line 1408 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_ENUMERABLE

#define DUK_STRIDX_ENUMERABLE   37 /* 'enumerable' */

◆ DUK_STRIDX_ENUMERATE

#define DUK_STRIDX_ENUMERATE   73 /* 'enumerate' */

Definition at line 1105 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_ENV

#define DUK_STRIDX_ENV   122 /* 'env' */

Definition at line 1252 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_ERR_CREATE

#define DUK_STRIDX_ERR_CREATE   118 /* 'errCreate' */

Definition at line 1240 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_ERR_THROW

#define DUK_STRIDX_ERR_THROW   119 /* 'errThrow' */

Definition at line 1243 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_err_longjmp().

◆ DUK_STRIDX_ESCAPED_EMPTY_REGEXP

#define DUK_STRIDX_ESCAPED_EMPTY_REGEXP   48 /* '(?:)' */

Definition at line 1030 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__create_escaped_source().

◆ DUK_STRIDX_EVAL

#define DUK_STRIDX_EVAL   32 /* 'eval' */

Definition at line 982 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_EXPORT

#define DUK_STRIDX_EXPORT   175 /* 'export' */

Definition at line 1411 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_EXPORTS

#define DUK_STRIDX_EXPORTS   79 /* 'exports' */

Definition at line 1123 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_EXTENDS

#define DUK_STRIDX_EXTENDS   176 /* 'extends' */

Definition at line 1414 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_FALSE

#define DUK_STRIDX_FALSE   181 /* 'false' */

Definition at line 1429 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_FILE_NAME

#define DUK_STRIDX_FILE_NAME   95 /* 'fileName' */

Definition at line 1171 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__error_getter_helper(), and duk_js_push_closure().

◆ DUK_STRIDX_FILENAME

#define DUK_STRIDX_FILENAME   80 /* 'filename' */

Definition at line 1126 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_FINALLY

#define DUK_STRIDX_FINALLY   155 /* 'finally' */

Definition at line 1351 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_FLOAT32_ARRAY

#define DUK_STRIDX_FLOAT32_ARRAY   24 /* 'Float32Array' */

Definition at line 958 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_FLOAT64_ARRAY

#define DUK_STRIDX_FLOAT64_ARRAY   25 /* 'Float64Array' */

Definition at line 961 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_FMT

#define DUK_STRIDX_FMT   128 /* 'fmt' */

Definition at line 1270 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_FOR

#define DUK_STRIDX_FOR   156 /* 'for' */

Definition at line 1354 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_GET

#define DUK_STRIDX_GET   71 /* 'get' */

◆ DUK_STRIDX_GLOBAL

#define DUK_STRIDX_GLOBAL   26 /* 'global' */

Definition at line 964 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_HAS

#define DUK_STRIDX_HAS   70 /* 'has' */

Definition at line 1096 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_HEX

#define DUK_STRIDX_HEX   123 /* 'hex' */

Definition at line 1255 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_ID

#define DUK_STRIDX_ID   78 /* 'id' */

Definition at line 1120 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_IF

#define DUK_STRIDX_IF   158 /* 'if' */

Definition at line 1360 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_IGNORE_CASE

#define DUK_STRIDX_IGNORE_CASE   45 /* 'ignoreCase' */

Definition at line 1021 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_IMPLEMENTS

#define DUK_STRIDX_IMPLEMENTS   182 /* 'implements' */

Definition at line 1432 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_IMPORT

#define DUK_STRIDX_IMPORT   177 /* 'import' */

Definition at line 1417 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_IN

#define DUK_STRIDX_IN   159 /* 'in' */

Definition at line 1363 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INDEX

#define DUK_STRIDX_INDEX   49 /* 'index' */

Definition at line 1033 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INFINITY

#define DUK_STRIDX_INFINITY   59 /* 'Infinity' */

Definition at line 1063 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INPUT

#define DUK_STRIDX_INPUT   117 /* 'input' */

Definition at line 1237 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INSTANCEOF

#define DUK_STRIDX_INSTANCEOF   160 /* 'instanceof' */

Definition at line 1366 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INT16_ARRAY

#define DUK_STRIDX_INT16_ARRAY   20 /* 'Int16Array' */

Definition at line 946 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INT32_ARRAY

#define DUK_STRIDX_INT32_ARRAY   22 /* 'Int32Array' */

Definition at line 952 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INT8_ARRAY

#define DUK_STRIDX_INT8_ARRAY   17 /* 'Int8Array' */

Definition at line 937 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INT_ARGS

#define DUK_STRIDX_INT_ARGS   107 /* '\xffArgs' */

Definition at line 1207 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INT_BYTECODE

#define DUK_STRIDX_INT_BYTECODE   100 /* '\xffBytecode' */

Definition at line 1186 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INT_CALLEE

#define DUK_STRIDX_INT_CALLEE   111 /* '\xffCallee' */

Definition at line 1219 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INT_FINALIZER

#define DUK_STRIDX_INT_FINALIZER   109 /* '\xffFinalizer' */

Definition at line 1213 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__finalize_helper().

◆ DUK_STRIDX_INT_FORMALS

#define DUK_STRIDX_INT_FORMALS   101 /* '\xffFormals' */

Definition at line 1189 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_js_push_closure().

◆ DUK_STRIDX_INT_HANDLER

#define DUK_STRIDX_INT_HANDLER   110 /* '\xffHandler' */

Definition at line 1216 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INT_LEXENV

#define DUK_STRIDX_INT_LEXENV   103 /* '\xffLexenv' */

Definition at line 1195 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INT_MAP

#define DUK_STRIDX_INT_MAP   108 /* '\xffMap' */

Definition at line 1210 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INT_NEXT

#define DUK_STRIDX_INT_NEXT   99 /* '\xffNext' */

Definition at line 1183 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INT_PC2LINE

#define DUK_STRIDX_INT_PC2LINE   106 /* '\xffPc2line' */

Definition at line 1204 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_js_push_closure().

◆ DUK_STRIDX_INT_REGBASE

#define DUK_STRIDX_INT_REGBASE   113 /* '\xffRegbase' */

Definition at line 1225 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INT_SOURCE

#define DUK_STRIDX_INT_SOURCE   105 /* '\xffSource' */

Definition at line 1201 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_js_push_closure().

◆ DUK_STRIDX_INT_TARGET

#define DUK_STRIDX_INT_TARGET   114 /* '\xffTarget' */

Definition at line 1228 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_js_instanceof().

◆ DUK_STRIDX_INT_THIS

#define DUK_STRIDX_INT_THIS   115 /* '\xffThis' */

Definition at line 1231 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INT_THREAD

#define DUK_STRIDX_INT_THREAD   112 /* '\xffThread' */

Definition at line 1222 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INT_TRACEDATA

#define DUK_STRIDX_INT_TRACEDATA   93 /* '\xffTracedata' */

Definition at line 1165 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__error_getter_helper().

◆ DUK_STRIDX_INT_VALUE

#define DUK_STRIDX_INT_VALUE   98 /* '\xffValue' */

◆ DUK_STRIDX_INT_VARENV

#define DUK_STRIDX_INT_VARENV   104 /* '\xffVarenv' */

Definition at line 1198 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INT_VARMAP

#define DUK_STRIDX_INT_VARMAP   102 /* '\xffVarmap' */

Definition at line 1192 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_js_push_closure().

◆ DUK_STRIDX_INTERFACE

#define DUK_STRIDX_INTERFACE   183 /* 'interface' */

Definition at line 1435 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_INVALID_DATE

#define DUK_STRIDX_INVALID_DATE   66 /* 'Invalid Date' */

Definition at line 1084 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_JC

#define DUK_STRIDX_JC   126 /* 'jc' */

Definition at line 1264 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_JOIN

#define DUK_STRIDX_JOIN   38 /* 'join' */

Definition at line 1000 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_JSON

#define DUK_STRIDX_JSON   13 /* 'JSON' */

Definition at line 925 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_JSON_EXT_FUNCTION1

#define DUK_STRIDX_JSON_EXT_FUNCTION1   144 /* '{"_func":true}' */

Definition at line 1318 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_JSON_EXT_FUNCTION2

#define DUK_STRIDX_JSON_EXT_FUNCTION2   145 /* '{_func:true}' */

Definition at line 1321 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_JSON_EXT_NAN

#define DUK_STRIDX_JSON_EXT_NAN   141 /* '{"_nan":true}' */

Definition at line 1309 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_JSON_EXT_NEGINF

#define DUK_STRIDX_JSON_EXT_NEGINF   143 /* '{"_ninf":true}' */

Definition at line 1315 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_JSON_EXT_POSINF

#define DUK_STRIDX_JSON_EXT_POSINF   142 /* '{"_inf":true}' */

Definition at line 1312 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_JSON_EXT_UNDEFINED

#define DUK_STRIDX_JSON_EXT_UNDEFINED   140 /* '{"_undef":true}' */

Definition at line 1306 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_JX

#define DUK_STRIDX_JX   125 /* 'jx' */

Definition at line 1261 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_LAST_INDEX

#define DUK_STRIDX_LAST_INDEX   47 /* 'lastIndex' */

Definition at line 1027 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_LC_ARGUMENTS

#define DUK_STRIDX_LC_ARGUMENTS   67 /* 'arguments' */

◆ DUK_STRIDX_LC_BOOLEAN

#define DUK_STRIDX_LC_BOOLEAN   53 /* 'boolean' */

Definition at line 1045 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_LC_BUFFER

#define DUK_STRIDX_LC_BUFFER   96 /* 'buffer' */

Definition at line 1174 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_buffer_slice_shared().

◆ DUK_STRIDX_LC_DEBUG

#define DUK_STRIDX_LC_DEBUG   131 /* 'debug' */

Definition at line 1279 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_LC_ERROR

#define DUK_STRIDX_LC_ERROR   134 /* 'error' */

Definition at line 1288 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_LC_FATAL

#define DUK_STRIDX_LC_FATAL   135 /* 'fatal' */

Definition at line 1291 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_LC_FUNCTION

#define DUK_STRIDX_LC_FUNCTION   157 /* 'function' */

Definition at line 1357 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_LC_INFO

#define DUK_STRIDX_LC_INFO   132 /* 'info' */

Definition at line 1282 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_LC_L

#define DUK_STRIDX_LC_L   137 /* 'l' */

Definition at line 1297 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_LC_N

#define DUK_STRIDX_LC_N   136 /* 'n' */

Definition at line 1294 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_logger_prototype_fmt().

◆ DUK_STRIDX_LC_NULL

#define DUK_STRIDX_LC_NULL   179 /* 'null' */

Definition at line 1423 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_LC_NUMBER

#define DUK_STRIDX_LC_NUMBER   54 /* 'number' */

Definition at line 1048 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_LC_OBJECT

#define DUK_STRIDX_LC_OBJECT   56 /* 'object' */

Definition at line 1054 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_LC_POINTER

#define DUK_STRIDX_LC_POINTER   97 /* 'pointer' */

Definition at line 1177 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_LC_STRING

#define DUK_STRIDX_LC_STRING   55 /* 'string' */

Definition at line 1051 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_LC_TRACE

#define DUK_STRIDX_LC_TRACE   130 /* 'trace' */

Definition at line 1276 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_LC_UNDEFINED

#define DUK_STRIDX_LC_UNDEFINED   57 /* 'undefined' */

Definition at line 1057 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_LC_WARN

#define DUK_STRIDX_LC_WARN   133 /* 'warn' */

Definition at line 1285 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_LENGTH

#define DUK_STRIDX_LENGTH   85 /* 'length' */

◆ DUK_STRIDX_LET

#define DUK_STRIDX_LET   184 /* 'let' */

Definition at line 1438 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_LINE_NUMBER

#define DUK_STRIDX_LINE_NUMBER   92 /* 'lineNumber' */

Definition at line 1162 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_MATH

#define DUK_STRIDX_MATH   12 /* 'Math' */

Definition at line 922 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_MESSAGE

#define DUK_STRIDX_MESSAGE   52 /* 'message' */

Definition at line 1042 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_MINUS_INFINITY

#define DUK_STRIDX_MINUS_INFINITY   60 /* '-Infinity' */

Definition at line 1066 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_MINUS_ZERO

#define DUK_STRIDX_MINUS_ZERO   61 /* '-0' */

Definition at line 1069 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_MOD_LOADED

#define DUK_STRIDX_MOD_LOADED   121 /* 'modLoaded' */

Definition at line 1249 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_MOD_SEARCH

#define DUK_STRIDX_MOD_SEARCH   120 /* 'modSearch' */

Definition at line 1246 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_MULTILINE

#define DUK_STRIDX_MULTILINE   46 /* 'multiline' */

Definition at line 1024 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_NAME

#define DUK_STRIDX_NAME   94 /* 'name' */

Definition at line 1168 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__error_getter_helper(), and duk_js_push_closure().

◆ DUK_STRIDX_NAN

#define DUK_STRIDX_NAN   58 /* 'NaN' */

Definition at line 1060 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_NEW

#define DUK_STRIDX_NEW   161 /* 'new' */

Definition at line 1369 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_NEWLINE_4SPACE

#define DUK_STRIDX_NEWLINE_4SPACE   64 /* '\n ' */

Definition at line 1078 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__error_getter_helper().

◆ DUK_STRIDX_OBJ_ENV

#define DUK_STRIDX_OBJ_ENV   27 /* 'ObjEnv' */

Definition at line 967 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_OWN_KEYS

#define DUK_STRIDX_OWN_KEYS   74 /* 'ownKeys' */

Definition at line 1108 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_PACKAGE

#define DUK_STRIDX_PACKAGE   185 /* 'package' */

Definition at line 1441 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_PC

#define DUK_STRIDX_PC   91 /* 'pc' */

Definition at line 1159 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_PRIVATE

#define DUK_STRIDX_PRIVATE   186 /* 'private' */

Definition at line 1444 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_PROTECTED

#define DUK_STRIDX_PROTECTED   187 /* 'protected' */

Definition at line 1447 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_PROTOTYPE

#define DUK_STRIDX_PROTOTYPE   50 /* 'prototype' */

Definition at line 1036 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_js_instanceof().

◆ DUK_STRIDX_PUBLIC

#define DUK_STRIDX_PUBLIC   188 /* 'public' */

Definition at line 1450 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_RAW

#define DUK_STRIDX_RAW   129 /* 'raw' */

Definition at line 1273 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_REG_EXP

#define DUK_STRIDX_REG_EXP   10 /* 'RegExp' */

Definition at line 916 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_REQUIRE

#define DUK_STRIDX_REQUIRE   77 /* 'require' */

Definition at line 1117 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_RESUME

#define DUK_STRIDX_RESUME   127 /* 'resume' */

Definition at line 1267 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_RETURN

#define DUK_STRIDX_RETURN   162 /* 'return' */

Definition at line 1372 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_SET

#define DUK_STRIDX_SET   89 /* 'set' */

◆ DUK_STRIDX_SET_PROTOTYPE_OF

#define DUK_STRIDX_SET_PROTOTYPE_OF   75 /* 'setPrototypeOf' */

Definition at line 1111 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_SOURCE

#define DUK_STRIDX_SOURCE   44 /* 'source' */

Definition at line 1018 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_SPACE

#define DUK_STRIDX_SPACE   63 /* ' ' */

Definition at line 1075 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_STACK

#define DUK_STRIDX_STACK   90 /* 'stack' */

Definition at line 1156 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_START_RESERVED

#define DUK_STRIDX_START_RESERVED   146

Definition at line 1461 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_STRIDX_START_STRICT_RESERVED

#define DUK_STRIDX_START_STRICT_RESERVED   182

Definition at line 1462 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_STRIDX_STATIC

#define DUK_STRIDX_STATIC   189 /* 'static' */

Definition at line 1453 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_SUPER

#define DUK_STRIDX_SUPER   178 /* 'super' */

Definition at line 1420 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_SWITCH

#define DUK_STRIDX_SWITCH   163 /* 'switch' */

Definition at line 1375 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_THIS

#define DUK_STRIDX_THIS   164 /* 'this' */

Definition at line 1378 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_THROW

#define DUK_STRIDX_THROW   165 /* 'throw' */

Definition at line 1381 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_TO_GMT_STRING

#define DUK_STRIDX_TO_GMT_STRING   43 /* 'toGMTString' */

Definition at line 1015 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_TO_ISO_STRING

#define DUK_STRIDX_TO_ISO_STRING   42 /* 'toISOString' */

Definition at line 1012 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_TO_JSON

#define DUK_STRIDX_TO_JSON   82 /* 'toJSON' */

Definition at line 1132 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_TO_LOCALE_STRING

#define DUK_STRIDX_TO_LOCALE_STRING   39 /* 'toLocaleString' */

Definition at line 1003 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_TO_LOG_STRING

#define DUK_STRIDX_TO_LOG_STRING   139 /* 'toLogString' */

Definition at line 1303 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_TO_STRING

#define DUK_STRIDX_TO_STRING   81 /* 'toString' */

◆ DUK_STRIDX_TO_TOK

#define DUK_STRIDX_TO_TOK ( x)    ((x) - DUK_STRIDX_START_RESERVED + DUK_TOK_START_RESERVED)

Definition at line 2897 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_STRIDX_TO_UTC_STRING

#define DUK_STRIDX_TO_UTC_STRING   41 /* 'toUTCString' */

Definition at line 1009 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_TRUE

#define DUK_STRIDX_TRUE   180 /* 'true' */

Definition at line 1426 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_TRY

#define DUK_STRIDX_TRY   166 /* 'try' */

Definition at line 1384 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_TYPE

#define DUK_STRIDX_TYPE   83 /* 'type' */

Definition at line 1135 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_TYPEOF

#define DUK_STRIDX_TYPEOF   167 /* 'typeof' */

Definition at line 1387 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_UC_ARGUMENTS

#define DUK_STRIDX_UC_ARGUMENTS   2 /* 'Arguments' */

Definition at line 892 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_UC_BOOLEAN

#define DUK_STRIDX_UC_BOOLEAN   7 /* 'Boolean' */

Definition at line 907 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_UC_BUFFER

#define DUK_STRIDX_UC_BUFFER   29 /* 'Buffer' */

Definition at line 973 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_UC_ERROR

#define DUK_STRIDX_UC_ERROR   11 /* 'Error' */

Definition at line 919 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_UC_FUNCTION

#define DUK_STRIDX_UC_FUNCTION   4 /* 'Function' */

Definition at line 898 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_UC_NULL

#define DUK_STRIDX_UC_NULL   1 /* 'Null' */

Definition at line 889 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_UC_NUMBER

#define DUK_STRIDX_UC_NUMBER   8 /* 'Number' */

Definition at line 910 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_UC_OBJECT

#define DUK_STRIDX_UC_OBJECT   3 /* 'Object' */

Definition at line 895 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_UC_POINTER

#define DUK_STRIDX_UC_POINTER   30 /* 'Pointer' */

Definition at line 976 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_UC_STRING

#define DUK_STRIDX_UC_STRING   6 /* 'String' */

Definition at line 904 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_UC_THREAD

#define DUK_STRIDX_UC_THREAD   31 /* 'Thread' */

Definition at line 979 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_UC_UNDEFINED

#define DUK_STRIDX_UC_UNDEFINED   0 /* 'Undefined' */

Definition at line 886 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_UINT16_ARRAY

#define DUK_STRIDX_UINT16_ARRAY   21 /* 'Uint16Array' */

Definition at line 949 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_UINT32_ARRAY

#define DUK_STRIDX_UINT32_ARRAY   23 /* 'Uint32Array' */

Definition at line 955 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_UINT8_ARRAY

#define DUK_STRIDX_UINT8_ARRAY   18 /* 'Uint8Array' */

Definition at line 940 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_UINT8_CLAMPED_ARRAY

#define DUK_STRIDX_UINT8_CLAMPED_ARRAY   19 /* 'Uint8ClampedArray' */

Definition at line 943 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_VALUE

#define DUK_STRIDX_VALUE   34 /* 'value' */

◆ DUK_STRIDX_VALUE_OF

#define DUK_STRIDX_VALUE_OF   40 /* 'valueOf' */

Definition at line 1006 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_to_undefined().

◆ DUK_STRIDX_VAR

#define DUK_STRIDX_VAR   168 /* 'var' */

Definition at line 1390 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_VOID

#define DUK_STRIDX_VOID   170 /* 'void' */

Definition at line 1396 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_WHILE

#define DUK_STRIDX_WHILE   171 /* 'while' */

Definition at line 1399 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_WITH

#define DUK_STRIDX_WITH   172 /* 'with' */

Definition at line 1402 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRIDX_WRITABLE

#define DUK_STRIDX_WRITABLE   35 /* 'writable' */

◆ DUK_STRIDX_YIELD

#define DUK_STRIDX_YIELD   190 /* 'yield' */

Definition at line 1456 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRTAB_CHAIN_SIZE

#define DUK_STRTAB_CHAIN_SIZE   DUK_USE_STRTAB_CHAIN_SIZE

Definition at line 6827 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRTAB_DELETED_MARKER

#define DUK_STRTAB_DELETED_MARKER ( heap)    ((duk_hstring *) heap)

Definition at line 6812 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRTAB_GROW_ST_SIZE

#define DUK_STRTAB_GROW_ST_SIZE ( n)    ((n) + (n)) /* used entries + approx 100% -> reset load to 50% */

Definition at line 6817 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRTAB_HASH_INITIAL

#define DUK_STRTAB_HASH_INITIAL ( hash,
h_size )   ((hash) % (h_size))

Definition at line 6823 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRTAB_HASH_PROBE_STEP

#define DUK_STRTAB_HASH_PROBE_STEP ( hash)    DUK_UTIL_GET_HASH_PROBE_STEP((hash))

Definition at line 6824 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRTAB_HIGHEST_32BIT_PRIME

#define DUK_STRTAB_HIGHEST_32BIT_PRIME   0xfffffffbUL

Definition at line 6820 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__recheck_strtab_size_probe().

◆ DUK_STRTAB_INITIAL_SIZE

#define DUK_STRTAB_INITIAL_SIZE   17

Definition at line 6809 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRTAB_MIN_FREE_DIVISOR

#define DUK_STRTAB_MIN_FREE_DIVISOR   4 /* load factor max 75% */

Definition at line 6815 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRTAB_MIN_USED_DIVISOR

#define DUK_STRTAB_MIN_USED_DIVISOR   4 /* load factor min 25% */

Definition at line 6816 of file duktape-1.8.0/src/duktape.c.

◆ DUK_STRTAB_U32_MAX_STRLEN

#define DUK_STRTAB_U32_MAX_STRLEN   10 /* 4'294'967'295 */

Definition at line 6819 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_heap_string_intern_u32_checked().

◆ DUK_TAG_BOOLEAN

#define DUK_TAG_BOOLEAN   4

◆ DUK_TAG_BUFFER

#define DUK_TAG_BUFFER   10

◆ DUK_TAG_LIGHTFUNC

◆ DUK_TAG_NULL

◆ DUK_TAG_OBJECT

◆ DUK_TAG_POINTER

#define DUK_TAG_POINTER   5

◆ DUK_TAG_STRING

#define DUK_TAG_STRING   8 /* first heap allocated, match bit boundary */

◆ DUK_TAG_UNDEFINED

#define DUK_TAG_UNDEFINED   2

◆ DUK_TAG_UNUSED

#define DUK_TAG_UNUSED   7 /* marker; not actual tagged type */

Definition at line 652 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TB_FLAG_NOBLAME_FILELINE

#define DUK_TB_FLAG_NOBLAME_FILELINE   (1 << 0) /* don't report __FILE__ / __LINE__ as fileName/lineNumber */

Definition at line 6027 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__error_getter_helper().

◆ DUK_TOK_ADD

#define DUK_TOK_ADD   66

Definition at line 2855 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_ADD_EQ

#define DUK_TOK_ADD_EQ   86

Definition at line 2875 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_ALSHIFT

#define DUK_TOK_ALSHIFT   73 /* named "arithmetic" because result is signed */

Definition at line 2862 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_ALSHIFT_EQ

#define DUK_TOK_ALSHIFT_EQ   91

Definition at line 2880 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_ARSHIFT

#define DUK_TOK_ARSHIFT   74

Definition at line 2863 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_ARSHIFT_EQ

#define DUK_TOK_ARSHIFT_EQ   92

Definition at line 2881 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_BAND

#define DUK_TOK_BAND   76

Definition at line 2865 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_BAND_EQ

#define DUK_TOK_BAND_EQ   94

Definition at line 2883 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_BNOT

#define DUK_TOK_BNOT   80

Definition at line 2869 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_BOR

#define DUK_TOK_BOR   77

Definition at line 2866 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_BOR_EQ

#define DUK_TOK_BOR_EQ   95

Definition at line 2884 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_BREAK

#define DUK_TOK_BREAK   2

Definition at line 2774 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_BXOR

#define DUK_TOK_BXOR   78

Definition at line 2867 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_BXOR_EQ

#define DUK_TOK_BXOR_EQ   96

Definition at line 2885 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_CASE

#define DUK_TOK_CASE   3

Definition at line 2775 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_CATCH

#define DUK_TOK_CATCH   4

Definition at line 2776 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_CLASS

#define DUK_TOK_CLASS   29

Definition at line 2803 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_COLON

#define DUK_TOK_COLON   84

Definition at line 2873 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_COMMA

#define DUK_TOK_COMMA   57

◆ DUK_TOK_CONST

#define DUK_TOK_CONST   25

Definition at line 2797 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_CONTINUE

#define DUK_TOK_CONTINUE   5

Definition at line 2777 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_DEBUGGER

#define DUK_TOK_DEBUGGER   6

Definition at line 2778 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_DECREMENT

#define DUK_TOK_DECREMENT   72

Definition at line 2861 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_DEFAULT

#define DUK_TOK_DEFAULT   7

Definition at line 2779 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_DELETE

#define DUK_TOK_DELETE   8

Definition at line 2780 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_DIV

#define DUK_TOK_DIV   69

Definition at line 2858 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_DIV_EQ

#define DUK_TOK_DIV_EQ   89

Definition at line 2878 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_DO

#define DUK_TOK_DO   9

Definition at line 2781 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_ELSE

#define DUK_TOK_ELSE   10

Definition at line 2782 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_END_RESERVED

#define DUK_TOK_END_RESERVED   47 /* exclusive */

Definition at line 2829 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_ENUM

#define DUK_TOK_ENUM   30

Definition at line 2804 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_EOF

#define DUK_TOK_EOF   0

Definition at line 2767 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_EQ

#define DUK_TOK_EQ   62

Definition at line 2851 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_EQUALSIGN

#define DUK_TOK_EQUALSIGN   85

◆ DUK_TOK_EXPORT

#define DUK_TOK_EXPORT   31

Definition at line 2805 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_EXTENDS

#define DUK_TOK_EXTENDS   32

Definition at line 2806 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_FALSE

#define DUK_TOK_FALSE   37

Definition at line 2815 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_FINALLY

#define DUK_TOK_FINALLY   11

Definition at line 2783 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_FOR

#define DUK_TOK_FOR   12

Definition at line 2784 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_FUNCTION

#define DUK_TOK_FUNCTION   13

Definition at line 2785 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_GE

#define DUK_TOK_GE   61

Definition at line 2850 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_GET

#define DUK_TOK_GET   47

Definition at line 2834 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_GT

#define DUK_TOK_GT   59

Definition at line 2848 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_IDENTIFIER

#define DUK_TOK_IDENTIFIER   1

◆ DUK_TOK_IF

#define DUK_TOK_IF   14

Definition at line 2786 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_IMPLEMENTS

#define DUK_TOK_IMPLEMENTS   38

Definition at line 2819 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_IMPORT

#define DUK_TOK_IMPORT   33

Definition at line 2807 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_IN

#define DUK_TOK_IN   15

Definition at line 2787 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_INCREMENT

#define DUK_TOK_INCREMENT   71

Definition at line 2860 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_INSTANCEOF

#define DUK_TOK_INSTANCEOF   16

Definition at line 2788 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_INTERFACE

#define DUK_TOK_INTERFACE   39

Definition at line 2820 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_LAND

#define DUK_TOK_LAND   81

Definition at line 2870 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_LBRACKET

#define DUK_TOK_LBRACKET   51

Definition at line 2840 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_LCURLY

#define DUK_TOK_LCURLY   49

◆ DUK_TOK_LE

#define DUK_TOK_LE   60

Definition at line 2849 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_LET

#define DUK_TOK_LET   40

Definition at line 2821 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_LNOT

#define DUK_TOK_LNOT   79

Definition at line 2868 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_LOR

#define DUK_TOK_LOR   82

Definition at line 2871 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_LPAREN

#define DUK_TOK_LPAREN   53

Definition at line 2842 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_LT

#define DUK_TOK_LT   58

Definition at line 2847 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_MAXVAL

#define DUK_TOK_MAXVAL   99 /* inclusive */

Definition at line 2894 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_MINVAL

#define DUK_TOK_MINVAL   0

Definition at line 2764 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_MOD

#define DUK_TOK_MOD   70

Definition at line 2859 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_MOD_EQ

#define DUK_TOK_MOD_EQ   90

Definition at line 2879 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_MUL

#define DUK_TOK_MUL   68

Definition at line 2857 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_MUL_EQ

#define DUK_TOK_MUL_EQ   88

Definition at line 2877 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_NEQ

#define DUK_TOK_NEQ   63

Definition at line 2852 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_NEW

#define DUK_TOK_NEW   17

Definition at line 2789 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_NULL

#define DUK_TOK_NULL   35

Definition at line 2813 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_NUMBER

#define DUK_TOK_NUMBER   97

Definition at line 2890 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_PACKAGE

#define DUK_TOK_PACKAGE   41

Definition at line 2822 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_PERIOD

#define DUK_TOK_PERIOD   55

Definition at line 2844 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_PRIVATE

#define DUK_TOK_PRIVATE   42

Definition at line 2823 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_PROTECTED

#define DUK_TOK_PROTECTED   43

Definition at line 2824 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_PUBLIC

#define DUK_TOK_PUBLIC   44

Definition at line 2825 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_QUESTION

#define DUK_TOK_QUESTION   83

Definition at line 2872 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_RBRACKET

#define DUK_TOK_RBRACKET   52

Definition at line 2841 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_RCURLY

#define DUK_TOK_RCURLY   50

Definition at line 2839 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_REGEXP

#define DUK_TOK_REGEXP   99

Definition at line 2892 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_RETURN

#define DUK_TOK_RETURN   18

Definition at line 2790 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_RPAREN

#define DUK_TOK_RPAREN   54

◆ DUK_TOK_RSHIFT

#define DUK_TOK_RSHIFT   75

Definition at line 2864 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_RSHIFT_EQ

#define DUK_TOK_RSHIFT_EQ   93

Definition at line 2882 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_SEMICOLON

#define DUK_TOK_SEMICOLON   56

Definition at line 2845 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_SEQ

#define DUK_TOK_SEQ   64

Definition at line 2853 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_SET

#define DUK_TOK_SET   48

Definition at line 2835 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_SNEQ

#define DUK_TOK_SNEQ   65

Definition at line 2854 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_START_RESERVED

#define DUK_TOK_START_RESERVED   2

Definition at line 2773 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_START_STRICT_RESERVED

#define DUK_TOK_START_STRICT_RESERVED   38 /* inclusive */

Definition at line 2818 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_STATIC

#define DUK_TOK_STATIC   45

Definition at line 2826 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_STRING

#define DUK_TOK_STRING   98

Definition at line 2891 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_SUB

#define DUK_TOK_SUB   67

Definition at line 2856 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_SUB_EQ

#define DUK_TOK_SUB_EQ   87

Definition at line 2876 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ DUK_TOK_SUPER

#define DUK_TOK_SUPER   34

Definition at line 2808 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_SWITCH

#define DUK_TOK_SWITCH   19

Definition at line 2791 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_THIS

#define DUK_TOK_THIS   20

Definition at line 2792 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_THROW

#define DUK_TOK_THROW   21

Definition at line 2793 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_TRUE

#define DUK_TOK_TRUE   36

Definition at line 2814 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_TRY

#define DUK_TOK_TRY   22

Definition at line 2794 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_TYPEOF

#define DUK_TOK_TYPEOF   23

Definition at line 2795 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_VAR

#define DUK_TOK_VAR   24

Definition at line 2796 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_VOID

#define DUK_TOK_VOID   26

Definition at line 2798 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_WHILE

#define DUK_TOK_WHILE   27

Definition at line 2799 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_WITH

#define DUK_TOK_WITH   28

Definition at line 2800 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TOK_YIELD

#define DUK_TOK_YIELD   46

Definition at line 2827 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_CHKFAST_INPLACE

#define DUK_TVAL_CHKFAST_INPLACE ( v)    do { } while (0)

Definition at line 726 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_DECREF

#define DUK_TVAL_DECREF ( thr,
tv )   DUK_TVAL_DECREF_FAST((thr),(tv))

Definition at line 3826 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_define_property_helper().

◆ DUK_TVAL_DECREF_FAST

#define DUK_TVAL_DECREF_FAST ( thr,
tv )
Value:
do { \
duk_tval *duk__tv = (tv); \
DUK_ASSERT(duk__tv != NULL); \
duk_heaphdr *duk__h = DUK_TVAL_GET_HEAPHDR(duk__tv); \
DUK_ASSERT(duk__h != NULL); \
DUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(duk__h)); \
DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(duk__h) > 0); \
if (DUK_HEAPHDR_PREDEC_REFCOUNT(duk__h) == 0) { \
duk_heaphdr_refzero((thr), duk__h); \
} \
} \
} while (0)
#define DUK_TVAL_NEEDS_REFCOUNT_UPDATE(tv)
#define DUK_TVAL_GET_HEAPHDR(tv)

Definition at line 3771 of file duktape-1.8.0/src/duktape.c.

3771#define DUK_TVAL_DECREF_FAST(thr,tv) do { \
3772 duk_tval *duk__tv = (tv); \
3773 DUK_ASSERT(duk__tv != NULL); \
3774 if (DUK_TVAL_NEEDS_REFCOUNT_UPDATE(duk__tv)) { \
3775 duk_heaphdr *duk__h = DUK_TVAL_GET_HEAPHDR(duk__tv); \
3776 DUK_ASSERT(duk__h != NULL); \
3777 DUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(duk__h)); \
3778 DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(duk__h) > 0); \
3779 if (DUK_HEAPHDR_PREDEC_REFCOUNT(duk__h) == 0) { \
3780 duk_heaphdr_refzero((thr), duk__h); \
3781 } \
3782 } \
3783 } while (0)

◆ DUK_TVAL_DECREF_SLOW

#define DUK_TVAL_DECREF_SLOW ( thr,
tv )
Value:
do { \
duk_tval_decref((thr), (tv)); \
} while (0)

Definition at line 3810 of file duktape-1.8.0/src/duktape.c.

3810#define DUK_TVAL_DECREF_SLOW(thr,tv) do { \
3811 duk_tval_decref((thr), (tv)); \
3812 } while (0)

◆ DUK_TVAL_GET_BOOLEAN

#define DUK_TVAL_GET_BOOLEAN ( tv)    ((tv)->v.i)

◆ DUK_TVAL_GET_BUFFER

#define DUK_TVAL_GET_BUFFER ( tv)    ((tv)->v.hbuffer)

Definition at line 794 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_putprop(), and duk_js_toboolean().

◆ DUK_TVAL_GET_DOUBLE

#define DUK_TVAL_GET_DOUBLE ( tv)    ((tv)->v.d)

Definition at line 783 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_js_toboolean(), and duk_js_tointeger_number().

◆ DUK_TVAL_GET_HEAPHDR

#define DUK_TVAL_GET_HEAPHDR ( tv)    ((tv)->v.heaphdr)

◆ DUK_TVAL_GET_LIGHTFUNC

#define DUK_TVAL_GET_LIGHTFUNC ( tv,
out_fp,
out_flags )
Value:
do { \
(out_flags) = (duk_uint32_t) (tv)->v_extra; \
(out_fp) = (tv)->v.lightfunc; \
} while (0)

Definition at line 786 of file duktape-1.8.0/src/duktape.c.

786#define DUK_TVAL_GET_LIGHTFUNC(tv,out_fp,out_flags) do { \
787 (out_flags) = (duk_uint32_t) (tv)->v_extra; \
788 (out_fp) = (tv)->v.lightfunc; \
789 } while (0)

◆ DUK_TVAL_GET_LIGHTFUNC_FLAGS

#define DUK_TVAL_GET_LIGHTFUNC_FLAGS ( tv)    ((duk_uint32_t) ((tv)->v_extra))

Definition at line 791 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_GET_LIGHTFUNC_FUNCPTR

#define DUK_TVAL_GET_LIGHTFUNC_FUNCPTR ( tv)    ((tv)->v.lightfunc)

Definition at line 790 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_GET_NUMBER

#define DUK_TVAL_GET_NUMBER ( tv)    ((tv)->v.d)

◆ DUK_TVAL_GET_OBJECT

#define DUK_TVAL_GET_OBJECT ( tv)    ((tv)->v.hobject)

◆ DUK_TVAL_GET_POINTER

#define DUK_TVAL_GET_POINTER ( tv)    ((tv)->v.voidptr)

Definition at line 785 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_js_toboolean().

◆ DUK_TVAL_GET_STRING

#define DUK_TVAL_GET_STRING ( tv)    ((tv)->v.hstring)

◆ DUK_TVAL_GET_TAG

◆ DUK_TVAL_H_INCLUDED

#define DUK_TVAL_H_INCLUDED

Definition at line 378 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_INCREF

◆ DUK_TVAL_INCREF_FAST

#define DUK_TVAL_INCREF_FAST ( thr,
tv )
Value:
do { \
duk_tval *duk__tv = (tv); \
DUK_ASSERT(duk__tv != NULL); \
duk_heaphdr *duk__h = DUK_TVAL_GET_HEAPHDR(duk__tv); \
DUK_ASSERT(duk__h != NULL); \
DUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(duk__h)); \
DUK_HEAPHDR_PREINC_REFCOUNT(duk__h); \
} \
} while (0)

Definition at line 3761 of file duktape-1.8.0/src/duktape.c.

3761#define DUK_TVAL_INCREF_FAST(thr,tv) do { \
3762 duk_tval *duk__tv = (tv); \
3763 DUK_ASSERT(duk__tv != NULL); \
3764 if (DUK_TVAL_NEEDS_REFCOUNT_UPDATE(duk__tv)) { \
3765 duk_heaphdr *duk__h = DUK_TVAL_GET_HEAPHDR(duk__tv); \
3766 DUK_ASSERT(duk__h != NULL); \
3767 DUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(duk__h)); \
3768 DUK_HEAPHDR_PREINC_REFCOUNT(duk__h); \
3769 } \
3770 } while (0)

◆ DUK_TVAL_INCREF_SLOW

#define DUK_TVAL_INCREF_SLOW ( thr,
tv )
Value:
do { \
duk_tval_incref((tv)); \
} while (0)

Definition at line 3807 of file duktape-1.8.0/src/duktape.c.

3807#define DUK_TVAL_INCREF_SLOW(thr,tv) do { \
3808 duk_tval_incref((tv)); \
3809 } while (0)

◆ DUK_TVAL_IS_BOOLEAN

#define DUK_TVAL_IS_BOOLEAN ( tv)    ((tv)->t == DUK_TAG_BOOLEAN)

◆ DUK_TVAL_IS_BOOLEAN_FALSE

#define DUK_TVAL_IS_BOOLEAN_FALSE ( tv)    (((tv)->t == DUK_TAG_BOOLEAN) && ((tv)->v.i == 0))

Definition at line 804 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_IS_BOOLEAN_TRUE

#define DUK_TVAL_IS_BOOLEAN_TRUE ( tv)    (((tv)->t == DUK_TAG_BOOLEAN) && ((tv)->v.i != 0))

Definition at line 803 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_IS_BUFFER

#define DUK_TVAL_IS_BUFFER ( tv)    ((tv)->t == DUK_TAG_BUFFER)

Definition at line 818 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_IS_DOUBLE

#define DUK_TVAL_IS_DOUBLE ( v)    DUK_TVAL_IS_NUMBER((v))

◆ DUK_TVAL_IS_HEAP_ALLOCATED

#define DUK_TVAL_IS_HEAP_ALLOCATED ( tv)    ((tv)->t & 0x08)

◆ DUK_TVAL_IS_LIGHTFUNC

#define DUK_TVAL_IS_LIGHTFUNC ( tv)    ((tv)->t == DUK_TAG_LIGHTFUNC)

◆ DUK_TVAL_IS_NULL

#define DUK_TVAL_IS_NULL ( tv)    ((tv)->t == DUK_TAG_NULL)

Definition at line 801 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_IS_NUMBER

#define DUK_TVAL_IS_NUMBER ( tv)    ((tv)->t == DUK__TAG_NUMBER)

◆ DUK_TVAL_IS_OBJECT

◆ DUK_TVAL_IS_POINTER

#define DUK_TVAL_IS_POINTER ( tv)    ((tv)->t == DUK_TAG_POINTER)

Definition at line 814 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_IS_STRING

#define DUK_TVAL_IS_STRING ( tv)    ((tv)->t == DUK_TAG_STRING)

Definition at line 816 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_IS_UNDEFINED

#define DUK_TVAL_IS_UNDEFINED ( tv)    ((tv)->t == DUK_TAG_UNDEFINED)

◆ DUK_TVAL_IS_UNUSED

◆ DUK_TVAL_NEEDS_REFCOUNT_UPDATE

#define DUK_TVAL_NEEDS_REFCOUNT_UPDATE ( tv)    DUK_TVAL_IS_HEAP_ALLOCATED((tv))

Definition at line 3752 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_tval_decref().

◆ DUK_TVAL_SET_BOOLEAN

#define DUK_TVAL_SET_BOOLEAN ( tv,
val )
Value:
do { \
(tv)->t = DUK_TAG_BOOLEAN; \
(tv)->v.i = (val); \
} while (0)
#define DUK_TAG_BOOLEAN

Definition at line 676 of file duktape-1.8.0/src/duktape.c.

676#define DUK_TVAL_SET_BOOLEAN(tv,val) do { \
677 (tv)->t = DUK_TAG_BOOLEAN; \
678 (tv)->v.i = (val); \
679 } while (0)

◆ DUK_TVAL_SET_BOOLEAN_FALSE

#define DUK_TVAL_SET_BOOLEAN_FALSE ( v)    DUK_TVAL_SET_BOOLEAN(v, 0)

Definition at line 844 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_SET_BOOLEAN_TRUE

#define DUK_TVAL_SET_BOOLEAN_TRUE ( v)    DUK_TVAL_SET_BOOLEAN(v, 1)

Definition at line 843 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_SET_BOOLEAN_UPDREF

#define DUK_TVAL_SET_BOOLEAN_UPDREF   DUK_TVAL_SET_BOOLEAN_UPDREF_ALT0

Definition at line 4024 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_SET_BOOLEAN_UPDREF_ALT0

#define DUK_TVAL_SET_BOOLEAN_UPDREF_ALT0 ( thr,
tvptr_dst,
newval )
Value:
do { \
duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
DUK_TVAL_SET_BOOLEAN(tv__dst, (newval)); \
DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
} while (0)

Definition at line 3893 of file duktape-1.8.0/src/duktape.c.

3893#define DUK_TVAL_SET_BOOLEAN_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
3894 duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
3895 DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
3896 DUK_TVAL_SET_BOOLEAN(tv__dst, (newval)); \
3897 DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
3898 } while (0)

◆ DUK_TVAL_SET_BUFFER

#define DUK_TVAL_SET_BUFFER ( tv,
hptr )
Value:
do { \
(tv)->t = DUK_TAG_BUFFER; \
(tv)->v.hbuffer = (hptr); \
} while (0)
#define DUK_TAG_BUFFER

Definition at line 750 of file duktape-1.8.0/src/duktape.c.

750#define DUK_TVAL_SET_BUFFER(tv,hptr) do { \
751 (tv)->t = DUK_TAG_BUFFER; \
752 (tv)->v.hbuffer = (hptr); \
753 } while (0)

◆ DUK_TVAL_SET_BUFFER_UPDREF

#define DUK_TVAL_SET_BUFFER_UPDREF   DUK_TVAL_SET_BUFFER_UPDREF_ALT0

Definition at line 4041 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_SET_BUFFER_UPDREF_ALT0

#define DUK_TVAL_SET_BUFFER_UPDREF_ALT0 ( thr,
tvptr_dst,
newval )
Value:
do { \
duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
DUK_TVAL_SET_BUFFER(tv__dst, (newval)); \
DUK_HBUFFER_INCREF((thr), (newval)); \
DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
} while (0)

Definition at line 3971 of file duktape-1.8.0/src/duktape.c.

3971#define DUK_TVAL_SET_BUFFER_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
3972 duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
3973 DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
3974 DUK_TVAL_SET_BUFFER(tv__dst, (newval)); \
3975 DUK_HBUFFER_INCREF((thr), (newval)); \
3976 DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
3977 } while (0)

◆ DUK_TVAL_SET_DOUBLE

#define DUK_TVAL_SET_DOUBLE ( tv,
d )    DUK_TVAL_SET_NUMBER((tv), (d))

Definition at line 712 of file duktape-1.8.0/src/duktape.c.

712#define DUK_TVAL_SET_DOUBLE(tv,d) \
713 DUK_TVAL_SET_NUMBER((tv), (d))

◆ DUK_TVAL_SET_DOUBLE_CAST_UPDREF

#define DUK_TVAL_SET_DOUBLE_CAST_UPDREF ( thr,
tvptr_dst,
newval )    DUK_TVAL_SET_DOUBLE_UPDREF((thr), (tvptr_dst), (duk_double_t) (newval))

Definition at line 3944 of file duktape-1.8.0/src/duktape.c.

3944#define DUK_TVAL_SET_DOUBLE_CAST_UPDREF(thr,tvptr_dst,newval) \
3945 DUK_TVAL_SET_DOUBLE_UPDREF((thr), (tvptr_dst), (duk_double_t) (newval))

◆ DUK_TVAL_SET_DOUBLE_UPDREF

#define DUK_TVAL_SET_DOUBLE_UPDREF   DUK_TVAL_SET_DOUBLE_UPDREF_ALT0

Definition at line 4027 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_SET_DOUBLE_UPDREF_ALT0

#define DUK_TVAL_SET_DOUBLE_UPDREF_ALT0 ( thr,
tvptr_dst,
newval )
Value:
do { \
duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
DUK_TVAL_SET_DOUBLE(tv__dst, (newval)); \
DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
} while (0)

Definition at line 3912 of file duktape-1.8.0/src/duktape.c.

3912#define DUK_TVAL_SET_DOUBLE_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
3913 duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
3914 DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
3915 DUK_TVAL_SET_DOUBLE(tv__dst, (newval)); \
3916 DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
3917 } while (0)

◆ DUK_TVAL_SET_FASTINT

#define DUK_TVAL_SET_FASTINT ( tv,
val )    DUK_TVAL_SET_NUMBER((tv), (duk_double_t) (val)) /* XXX: fast int-to-double */

Definition at line 714 of file duktape-1.8.0/src/duktape.c.

714#define DUK_TVAL_SET_FASTINT(tv,val) \
715 DUK_TVAL_SET_NUMBER((tv), (duk_double_t) (val)) /* XXX: fast int-to-double */

◆ DUK_TVAL_SET_FASTINT_I32

#define DUK_TVAL_SET_FASTINT_I32 ( tv,
val )    DUK_TVAL_SET_NUMBER((tv), (duk_double_t) (val))

Definition at line 718 of file duktape-1.8.0/src/duktape.c.

718#define DUK_TVAL_SET_FASTINT_I32(tv,val) \
719 DUK_TVAL_SET_NUMBER((tv), (duk_double_t) (val))

◆ DUK_TVAL_SET_FASTINT_I32_UPDREF

#define DUK_TVAL_SET_FASTINT_I32_UPDREF   DUK_TVAL_SET_DOUBLE_CAST_UPDREF

Definition at line 4035 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_to_uint32().

◆ DUK_TVAL_SET_FASTINT_U32

#define DUK_TVAL_SET_FASTINT_U32 ( tv,
val )    DUK_TVAL_SET_NUMBER((tv), (duk_double_t) (val))

Definition at line 716 of file duktape-1.8.0/src/duktape.c.

716#define DUK_TVAL_SET_FASTINT_U32(tv,val) \
717 DUK_TVAL_SET_NUMBER((tv), (duk_double_t) (val))

Referenced by duk_hobject_define_property_helper(), and duk_hobject_putprop().

◆ DUK_TVAL_SET_FASTINT_U32_UPDREF

#define DUK_TVAL_SET_FASTINT_U32_UPDREF   DUK_TVAL_SET_DOUBLE_CAST_UPDREF

Definition at line 4036 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__handle_catch(), and duk_to_uint16().

◆ DUK_TVAL_SET_FASTINT_UPDREF

#define DUK_TVAL_SET_FASTINT_UPDREF   DUK_TVAL_SET_DOUBLE_CAST_UPDREF /* XXX: fast int-to-double */

Definition at line 4034 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_SET_LIGHTFUNC

#define DUK_TVAL_SET_LIGHTFUNC ( tv,
fp,
flags )
Value:
do { \
(tv)->t = DUK_TAG_LIGHTFUNC; \
(tv)->v_extra = (flags); \
(tv)->v.lightfunc = (duk_c_function) (fp); \
} while (0)
duk_ret_t(* duk_c_function)(duk_context *ctx)
#define DUK_TAG_LIGHTFUNC

Definition at line 734 of file duktape-1.8.0/src/duktape.c.

734#define DUK_TVAL_SET_LIGHTFUNC(tv,fp,flags) do { \
735 (tv)->t = DUK_TAG_LIGHTFUNC; \
736 (tv)->v_extra = (flags); \
737 (tv)->v.lightfunc = (duk_c_function) (fp); \
738 } while (0)

◆ DUK_TVAL_SET_LIGHTFUNC_UPDREF

#define DUK_TVAL_SET_LIGHTFUNC_UPDREF   DUK_TVAL_SET_LIGHTFUNC_UPDREF_ALT0

Definition at line 4038 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_SET_LIGHTFUNC_UPDREF_ALT0

#define DUK_TVAL_SET_LIGHTFUNC_UPDREF_ALT0 ( thr,
tvptr_dst,
lf_v,
lf_fp,
lf_flags )
Value:
do { \
duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
DUK_TVAL_SET_LIGHTFUNC(tv__dst, (lf_v), (lf_fp), (lf_flags)); \
DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
} while (0)

Definition at line 3948 of file duktape-1.8.0/src/duktape.c.

3948#define DUK_TVAL_SET_LIGHTFUNC_UPDREF_ALT0(thr,tvptr_dst,lf_v,lf_fp,lf_flags) do { \
3949 duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
3950 DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
3951 DUK_TVAL_SET_LIGHTFUNC(tv__dst, (lf_v), (lf_fp), (lf_flags)); \
3952 DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
3953 } while (0)

◆ DUK_TVAL_SET_NAN

#define DUK_TVAL_SET_NAN ( tv)
Value:
do { \
/* in non-packed representation we don't care about which NaN is used */ \
(tv)->t = DUK__TAG_NUMBER; \
(tv)->v.d = DUK_DOUBLE_NAN; \
} while (0)
#define DUK__TAG_NUMBER

Definition at line 755 of file duktape-1.8.0/src/duktape.c.

755#define DUK_TVAL_SET_NAN(tv) do { \
756 /* in non-packed representation we don't care about which NaN is used */ \
757 (tv)->t = DUK__TAG_NUMBER; \
758 (tv)->v.d = DUK_DOUBLE_NAN; \
759 } while (0)

◆ DUK_TVAL_SET_NAN_UPDREF

#define DUK_TVAL_SET_NAN_UPDREF   DUK_TVAL_SET_NAN_UPDREF_ALT0

Definition at line 4028 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_SET_NAN_UPDREF_ALT0

#define DUK_TVAL_SET_NAN_UPDREF_ALT0 ( thr,
tvptr_dst )
Value:
do { \
duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
DUK_TVAL_SET_NAN(tv__dst); \
DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
} while (0)

Definition at line 3918 of file duktape-1.8.0/src/duktape.c.

3918#define DUK_TVAL_SET_NAN_UPDREF_ALT0(thr,tvptr_dst) do { \
3919 duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
3920 DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
3921 DUK_TVAL_SET_NAN(tv__dst); \
3922 DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
3923 } while (0)

◆ DUK_TVAL_SET_NULL

#define DUK_TVAL_SET_NULL ( tv)
Value:
do { \
(tv)->t = DUK_TAG_NULL; \
} while (0)
#define DUK_TAG_NULL

Definition at line 672 of file duktape-1.8.0/src/duktape.c.

672#define DUK_TVAL_SET_NULL(tv) do { \
673 (tv)->t = DUK_TAG_NULL; \
674 } while (0)

◆ DUK_TVAL_SET_NULL_UPDREF

#define DUK_TVAL_SET_NULL_UPDREF   DUK_TVAL_SET_NULL_UPDREF_ALT0

Definition at line 4023 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_SET_NULL_UPDREF_ALT0

#define DUK_TVAL_SET_NULL_UPDREF_ALT0 ( thr,
tvptr_dst )
Value:
do { \
duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
DUK_TVAL_SET_NULL(tv__dst); \
DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
} while (0)

Definition at line 3886 of file duktape-1.8.0/src/duktape.c.

3886#define DUK_TVAL_SET_NULL_UPDREF_ALT0(thr,tvptr_dst) do { \
3887 duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
3888 DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
3889 DUK_TVAL_SET_NULL(tv__dst); \
3890 DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
3891 } while (0)

◆ DUK_TVAL_SET_NUMBER

#define DUK_TVAL_SET_NUMBER ( tv,
val )
Value:
do { \
(tv)->t = DUK__TAG_NUMBER; \
(tv)->v.d = (val); \
} while (0)

Definition at line 720 of file duktape-1.8.0/src/duktape.c.

720#define DUK_TVAL_SET_NUMBER(tv,val) do { \
721 (tv)->t = DUK__TAG_NUMBER; \
722 (tv)->v.d = (val); \
723 } while (0)

◆ DUK_TVAL_SET_NUMBER_CHKFAST

#define DUK_TVAL_SET_NUMBER_CHKFAST ( tv,
d )    DUK_TVAL_SET_NUMBER((tv), (d))

Definition at line 724 of file duktape-1.8.0/src/duktape.c.

724#define DUK_TVAL_SET_NUMBER_CHKFAST(tv,d) \
725 DUK_TVAL_SET_NUMBER((tv), (d))

◆ DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF

#define DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF   DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF_ALT0

Definition at line 4026 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF_ALT0

#define DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF_ALT0 ( thr,
tvptr_dst,
newval )
Value:
do { \
duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
DUK_TVAL_SET_NUMBER_CHKFAST(tv__dst, (newval)); \
DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
} while (0)

Definition at line 3906 of file duktape-1.8.0/src/duktape.c.

3906#define DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
3907 duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
3908 DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
3909 DUK_TVAL_SET_NUMBER_CHKFAST(tv__dst, (newval)); \
3910 DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
3911 } while (0)

◆ DUK_TVAL_SET_NUMBER_UPDREF

#define DUK_TVAL_SET_NUMBER_UPDREF   DUK_TVAL_SET_NUMBER_UPDREF_ALT0

Definition at line 4025 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_SET_NUMBER_UPDREF_ALT0

#define DUK_TVAL_SET_NUMBER_UPDREF_ALT0 ( thr,
tvptr_dst,
newval )
Value:
do { \
duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
DUK_TVAL_SET_NUMBER(tv__dst, (newval)); \
DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
} while (0)

Definition at line 3900 of file duktape-1.8.0/src/duktape.c.

3900#define DUK_TVAL_SET_NUMBER_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
3901 duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
3902 DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
3903 DUK_TVAL_SET_NUMBER(tv__dst, (newval)); \
3904 DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
3905 } while (0)

◆ DUK_TVAL_SET_OBJECT

#define DUK_TVAL_SET_OBJECT ( tv,
hptr )
Value:
do { \
(tv)->t = DUK_TAG_OBJECT; \
(tv)->v.hobject = (hptr); \
} while (0)
#define DUK_TAG_OBJECT

Definition at line 745 of file duktape-1.8.0/src/duktape.c.

745#define DUK_TVAL_SET_OBJECT(tv,hptr) do { \
746 (tv)->t = DUK_TAG_OBJECT; \
747 (tv)->v.hobject = (hptr); \
748 } while (0)

Referenced by duk__coerce_effective_this_binding(), duk__getvar_helper(), duk__putvar_helper(), duk_handle_ecma_call_setup(), duk_hobject_putprop(), and duk_push_hobject_bidx().

◆ DUK_TVAL_SET_OBJECT_UPDREF

#define DUK_TVAL_SET_OBJECT_UPDREF   DUK_TVAL_SET_OBJECT_UPDREF_ALT0

Definition at line 4040 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_SET_OBJECT_UPDREF_ALT0

#define DUK_TVAL_SET_OBJECT_UPDREF_ALT0 ( thr,
tvptr_dst,
newval )
Value:
do { \
duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
DUK_TVAL_SET_OBJECT(tv__dst, (newval)); \
DUK_HOBJECT_INCREF((thr), (newval)); \
DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
} while (0)

Definition at line 3963 of file duktape-1.8.0/src/duktape.c.

3963#define DUK_TVAL_SET_OBJECT_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
3964 duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
3965 DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
3966 DUK_TVAL_SET_OBJECT(tv__dst, (newval)); \
3967 DUK_HOBJECT_INCREF((thr), (newval)); \
3968 DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
3969 } while (0)

◆ DUK_TVAL_SET_POINTER

#define DUK_TVAL_SET_POINTER ( tv,
hptr )
Value:
do { \
(tv)->t = DUK_TAG_POINTER; \
(tv)->v.voidptr = (hptr); \
} while (0)
#define DUK_TAG_POINTER

Definition at line 729 of file duktape-1.8.0/src/duktape.c.

729#define DUK_TVAL_SET_POINTER(tv,hptr) do { \
730 (tv)->t = DUK_TAG_POINTER; \
731 (tv)->v.voidptr = (hptr); \
732 } while (0)

◆ DUK_TVAL_SET_POINTER_UPDREF

#define DUK_TVAL_SET_POINTER_UPDREF   DUK_TVAL_SET_POINTER_UPDREF_ALT0

Definition at line 4042 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_SET_POINTER_UPDREF_ALT0

#define DUK_TVAL_SET_POINTER_UPDREF_ALT0 ( thr,
tvptr_dst,
newval )
Value:
do { \
duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
DUK_TVAL_SET_POINTER(tv__dst, (newval)); \
DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
} while (0)

Definition at line 3979 of file duktape-1.8.0/src/duktape.c.

3979#define DUK_TVAL_SET_POINTER_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
3980 duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
3981 DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
3982 DUK_TVAL_SET_POINTER(tv__dst, (newval)); \
3983 DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
3984 } while (0)

◆ DUK_TVAL_SET_STRING

#define DUK_TVAL_SET_STRING ( tv,
hptr )
Value:
do { \
(tv)->t = DUK_TAG_STRING; \
(tv)->v.hstring = (hptr); \
} while (0)
#define DUK_TAG_STRING

Definition at line 740 of file duktape-1.8.0/src/duktape.c.

740#define DUK_TVAL_SET_STRING(tv,hptr) do { \
741 (tv)->t = DUK_TAG_STRING; \
742 (tv)->v.hstring = (hptr); \
743 } while (0)

Referenced by duk__getvar_helper(), and duk__putvar_helper().

◆ DUK_TVAL_SET_STRING_UPDREF

#define DUK_TVAL_SET_STRING_UPDREF   DUK_TVAL_SET_STRING_UPDREF_ALT0

Definition at line 4039 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_SET_STRING_UPDREF_ALT0

#define DUK_TVAL_SET_STRING_UPDREF_ALT0 ( thr,
tvptr_dst,
newval )
Value:
do { \
duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
DUK_TVAL_SET_STRING(tv__dst, (newval)); \
DUK_HSTRING_INCREF((thr), (newval)); \
DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
} while (0)

Definition at line 3955 of file duktape-1.8.0/src/duktape.c.

3955#define DUK_TVAL_SET_STRING_UPDREF_ALT0(thr,tvptr_dst,newval) do { \
3956 duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
3957 DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
3958 DUK_TVAL_SET_STRING(tv__dst, (newval)); \
3959 DUK_HSTRING_INCREF((thr), (newval)); \
3960 DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
3961 } while (0)

◆ DUK_TVAL_SET_TVAL

#define DUK_TVAL_SET_TVAL ( v,
x )   do { *(v) = *(x); } while (0)

◆ DUK_TVAL_SET_TVAL_UPDREF

◆ DUK_TVAL_SET_TVAL_UPDREF_ALT0

#define DUK_TVAL_SET_TVAL_UPDREF_ALT0 ( thr,
tvptr_dst,
tvptr_src )
Value:
do { \
duk_tval *tv__dst, *tv__src; duk_tval tv__tmp; \
tv__dst = (tvptr_dst); tv__src = (tvptr_src); \
DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
DUK_TVAL_SET_TVAL(tv__dst, tv__src); \
DUK_TVAL_INCREF((thr), tv__src); \
DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
} while (0)

Definition at line 3994 of file duktape-1.8.0/src/duktape.c.

3994#define DUK_TVAL_SET_TVAL_UPDREF_ALT0(thr,tvptr_dst,tvptr_src) do { \
3995 duk_tval *tv__dst, *tv__src; duk_tval tv__tmp; \
3996 tv__dst = (tvptr_dst); tv__src = (tvptr_src); \
3997 DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
3998 DUK_TVAL_SET_TVAL(tv__dst, tv__src); \
3999 DUK_TVAL_INCREF((thr), tv__src); \
4000 DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
4001 } while (0)

◆ DUK_TVAL_SET_TVAL_UPDREF_ALT1

#define DUK_TVAL_SET_TVAL_UPDREF_ALT1 ( thr,
tvptr_dst,
tvptr_src )
Value:
do { \
duk_tval *tv__dst, *tv__src; duk_heaphdr *h__obj; \
tv__dst = (tvptr_dst); tv__src = (tvptr_src); \
DUK_TVAL_INCREF_FAST((thr), tv__src); \
h__obj = DUK_TVAL_GET_HEAPHDR(tv__dst); \
DUK_ASSERT(h__obj != NULL); \
DUK_TVAL_SET_TVAL(tv__dst, tv__src); \
DUK_HEAPHDR_DECREF_FAST((thr), h__obj); /* side effects */ \
} else { \
DUK_TVAL_SET_TVAL(tv__dst, tv__src); \
} \
} while (0)

Definition at line 4006 of file duktape-1.8.0/src/duktape.c.

4006#define DUK_TVAL_SET_TVAL_UPDREF_ALT1(thr,tvptr_dst,tvptr_src) do { \
4007 duk_tval *tv__dst, *tv__src; duk_heaphdr *h__obj; \
4008 tv__dst = (tvptr_dst); tv__src = (tvptr_src); \
4009 DUK_TVAL_INCREF_FAST((thr), tv__src); \
4010 if (DUK_TVAL_NEEDS_REFCOUNT_UPDATE(tv__dst)) { \
4011 h__obj = DUK_TVAL_GET_HEAPHDR(tv__dst); \
4012 DUK_ASSERT(h__obj != NULL); \
4013 DUK_TVAL_SET_TVAL(tv__dst, tv__src); \
4014 DUK_HEAPHDR_DECREF_FAST((thr), h__obj); /* side effects */ \
4015 } else { \
4016 DUK_TVAL_SET_TVAL(tv__dst, tv__src); \
4017 } \
4018 } while (0)

◆ DUK_TVAL_SET_TVAL_UPDREF_FAST

#define DUK_TVAL_SET_TVAL_UPDREF_FAST   DUK_TVAL_SET_TVAL_UPDREF_ALT1

Definition at line 4047 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_SET_TVAL_UPDREF_SLOW

#define DUK_TVAL_SET_TVAL_UPDREF_SLOW   DUK_TVAL_SET_TVAL_UPDREF_ALT0

Definition at line 4048 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_SET_UNDEFINED

#define DUK_TVAL_SET_UNDEFINED ( tv)
Value:
do { \
(tv)->t = DUK_TAG_UNDEFINED; \
} while (0)
#define DUK_TAG_UNDEFINED

Definition at line 664 of file duktape-1.8.0/src/duktape.c.

664#define DUK_TVAL_SET_UNDEFINED(tv) do { \
665 (tv)->t = DUK_TAG_UNDEFINED; \
666 } while (0)

Referenced by duk_hobject_define_property_helper(), duk_hobject_define_property_internal(), and duk_require_undefined().

◆ DUK_TVAL_SET_UNDEFINED_UPDREF

#define DUK_TVAL_SET_UNDEFINED_UPDREF   DUK_TVAL_SET_UNDEFINED_UPDREF_ALT0

Definition at line 4021 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__declvar_helper().

◆ DUK_TVAL_SET_UNDEFINED_UPDREF_ALT0

#define DUK_TVAL_SET_UNDEFINED_UPDREF_ALT0 ( thr,
tvptr_dst )
Value:
do { \
duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
DUK_TVAL_SET_UNDEFINED(tv__dst); \
DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
} while (0)

Definition at line 3872 of file duktape-1.8.0/src/duktape.c.

3872#define DUK_TVAL_SET_UNDEFINED_UPDREF_ALT0(thr,tvptr_dst) do { \
3873 duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
3874 DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
3875 DUK_TVAL_SET_UNDEFINED(tv__dst); \
3876 DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
3877 } while (0)

◆ DUK_TVAL_SET_UNUSED

#define DUK_TVAL_SET_UNUSED ( tv)
Value:
do { \
(tv)->t = DUK_TAG_UNUSED; \
} while (0)
#define DUK_TAG_UNUSED

Definition at line 668 of file duktape-1.8.0/src/duktape.c.

668#define DUK_TVAL_SET_UNUSED(tv) do { \
669 (tv)->t = DUK_TAG_UNUSED; \
670 } while (0)

Referenced by duk__realloc_props().

◆ DUK_TVAL_SET_UNUSED_UPDREF

#define DUK_TVAL_SET_UNUSED_UPDREF   DUK_TVAL_SET_UNUSED_UPDREF_ALT0

Definition at line 4022 of file duktape-1.8.0/src/duktape.c.

◆ DUK_TVAL_SET_UNUSED_UPDREF_ALT0

#define DUK_TVAL_SET_UNUSED_UPDREF_ALT0 ( thr,
tvptr_dst )
Value:
do { \
duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
DUK_TVAL_SET_UNUSED(tv__dst); \
DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
} while (0)

Definition at line 3879 of file duktape-1.8.0/src/duktape.c.

3879#define DUK_TVAL_SET_UNUSED_UPDREF_ALT0(thr,tvptr_dst) do { \
3880 duk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \
3881 DUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \
3882 DUK_TVAL_SET_UNUSED(tv__dst); \
3883 DUK_TVAL_DECREF((thr), &tv__tmp); /* side effects */ \
3884 } while (0)

◆ DUK_UNICODE_CP_REPLACEMENT_CHARACTER

#define DUK_UNICODE_CP_REPLACEMENT_CHARACTER   0xfffdL /* http://en.wikipedia.org/wiki/Replacement_character#Replacement_character */

Definition at line 8058 of file duktape-1.8.0/src/duktape.c.

◆ DUK_UNICODE_CP_ZWJ

#define DUK_UNICODE_CP_ZWJ   0x200dL /* zero-width joiner */

Definition at line 8057 of file duktape-1.8.0/src/duktape.c.

◆ DUK_UNICODE_CP_ZWNJ

#define DUK_UNICODE_CP_ZWNJ   0x200cL /* zero-width non-joiner */

Definition at line 8056 of file duktape-1.8.0/src/duktape.c.

◆ DUK_UNICODE_H_INCLUDED

#define DUK_UNICODE_H_INCLUDED

Definition at line 8038 of file duktape-1.8.0/src/duktape.c.

◆ DUK_UNICODE_MAX_CESU8_BMP_LENGTH

#define DUK_UNICODE_MAX_CESU8_BMP_LENGTH   3 /* all codepoints up to U+FFFF */

Definition at line 8047 of file duktape-1.8.0/src/duktape.c.

◆ DUK_UNICODE_MAX_CESU8_LENGTH

#define DUK_UNICODE_MAX_CESU8_LENGTH   6 /* all codepoints up to U+10FFFF */

Definition at line 8046 of file duktape-1.8.0/src/duktape.c.

◆ DUK_UNICODE_MAX_XUTF8_BMP_LENGTH

#define DUK_UNICODE_MAX_XUTF8_BMP_LENGTH   3 /* all codepoints up to U+FFFF */

Definition at line 8045 of file duktape-1.8.0/src/duktape.c.

◆ DUK_UNICODE_MAX_XUTF8_LENGTH

#define DUK_UNICODE_MAX_XUTF8_LENGTH   7 /* up to 36 bit codepoints */

Definition at line 8044 of file duktape-1.8.0/src/duktape.c.

◆ DUK_UTIL_GET_HASH_PROBE_STEP

#define DUK_UTIL_GET_HASH_PROBE_STEP ( hash)    (duk_util_probe_steps[(hash) & 0x1f])

Definition at line 1742 of file duktape-1.8.0/src/duktape.c.

◆ DUK_UTIL_H_INCLUDED

#define DUK_UTIL_H_INCLUDED

Definition at line 1738 of file duktape-1.8.0/src/duktape.c.

◆ DUK_UTIL_MIN_HASH_PRIME

#define DUK_UTIL_MIN_HASH_PRIME   17 /* must match genhashsizes.py */

Definition at line 1740 of file duktape-1.8.0/src/duktape.c.

◆ DUK_VALSTACK_API_ENTRY_MINIMUM

#define DUK_VALSTACK_API_ENTRY_MINIMUM   DUK_API_ENTRY_STACK

Definition at line 5986 of file duktape-1.8.0/src/duktape.c.

◆ DUK_VALSTACK_ASSERT_EXTRA

#define DUK_VALSTACK_ASSERT_EXTRA
Value:
5 /* this is added to checks to allow for Duktape
* API calls in addition to function's own use
*/

Definition at line 7836 of file duktape-1.8.0/src/duktape.c.

◆ DUK_VALSTACK_DEFAULT_MAX

#define DUK_VALSTACK_DEFAULT_MAX   1000000L

Definition at line 5996 of file duktape-1.8.0/src/duktape.c.

◆ DUK_VALSTACK_GROW_STEP

#define DUK_VALSTACK_GROW_STEP   128 /* roughly 1 kiB */

Definition at line 5981 of file duktape-1.8.0/src/duktape.c.

◆ DUK_VALSTACK_INITIAL_SIZE

#define DUK_VALSTACK_INITIAL_SIZE   128 /* roughly 1.0 kiB -> but rounds up to DUK_VALSTACK_GROW_STEP in practice */

Definition at line 5984 of file duktape-1.8.0/src/duktape.c.

◆ DUK_VALSTACK_INTERNAL_EXTRA

#define DUK_VALSTACK_INTERNAL_EXTRA
Value:
64 /* internal extra elements assumed on function entry,
* always added to user-defined 'extra' for e.g. the
* duk_check_stack() call.
*/

Definition at line 5985 of file duktape-1.8.0/src/duktape.c.

◆ DUK_VALSTACK_SHRINK_SPARE

#define DUK_VALSTACK_SHRINK_SPARE   64 /* roughly 0.5 kiB */

Definition at line 5983 of file duktape-1.8.0/src/duktape.c.

◆ DUK_VALSTACK_SHRINK_THRESHOLD

#define DUK_VALSTACK_SHRINK_THRESHOLD   256 /* roughly 2 kiB */

Definition at line 5982 of file duktape-1.8.0/src/duktape.c.

◆ DUK_VSRESIZE_FLAG_COMPACT

#define DUK_VSRESIZE_FLAG_COMPACT   (1 << 1)

Definition at line 4242 of file duktape-1.8.0/src/duktape.c.

◆ DUK_VSRESIZE_FLAG_SHRINK

#define DUK_VSRESIZE_FLAG_SHRINK   (1 << 0)

Definition at line 4241 of file duktape-1.8.0/src/duktape.c.

◆ DUK_VSRESIZE_FLAG_THROW

#define DUK_VSRESIZE_FLAG_THROW   (1 << 2)

Definition at line 4243 of file duktape-1.8.0/src/duktape.c.

◆ duk_xdef_prop_index_wec

#define duk_xdef_prop_index_wec ( ctx,
obj_index,
arr_index )    duk_xdef_prop_index((ctx), (obj_index), (arr_index), DUK_PROPDESC_FLAGS_WEC)

Definition at line 4390 of file duktape-1.8.0/src/duktape.c.

4390#define duk_xdef_prop_index_wec(ctx,obj_index,arr_index) \
4391 duk_xdef_prop_index((ctx), (obj_index), (arr_index), DUK_PROPDESC_FLAGS_WEC)

Referenced by duk_bi_array_constructor_is_array().

◆ duk_xdef_prop_stridx_wec

#define duk_xdef_prop_stridx_wec ( ctx,
obj_index,
stridx )    duk_xdef_prop_stridx((ctx), (obj_index), (stridx), DUK_PROPDESC_FLAGS_WEC)

Definition at line 4392 of file duktape-1.8.0/src/duktape.c.

4392#define duk_xdef_prop_stridx_wec(ctx,obj_index,stridx) \
4393 duk_xdef_prop_stridx((ctx), (obj_index), (stridx), DUK_PROPDESC_FLAGS_WEC)

◆ duk_xdef_prop_wec

#define duk_xdef_prop_wec ( ctx,
obj_index )    duk_xdef_prop((ctx), (obj_index), DUK_PROPDESC_FLAGS_WEC)

Definition at line 4388 of file duktape-1.8.0/src/duktape.c.

4388#define duk_xdef_prop_wec(ctx,obj_index) \
4389 duk_xdef_prop((ctx), (obj_index), DUK_PROPDESC_FLAGS_WEC)

Typedef Documentation

◆ duk__compile_raw_args

typedef struct duk__compile_raw_args duk__compile_raw_args

Definition at line 13589 of file duktape-1.8.0/src/duktape.c.

◆ duk__one_arg_func

typedef double(* duk__one_arg_func) (double)

Definition at line 32554 of file duktape-1.8.0/src/duktape.c.

◆ duk__toint_coercer

typedef duk_double_t(* duk__toint_coercer) (duk_hthread *thr, duk_tval *tv)

Definition at line 16923 of file duktape-1.8.0/src/duktape.c.

◆ duk__transform_callback

typedef void(* duk__transform_callback) (duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp)

Definition at line 27901 of file duktape-1.8.0/src/duktape.c.

◆ duk__two_arg_func

typedef double(* duk__two_arg_func) (double, double)

Definition at line 32555 of file duktape-1.8.0/src/duktape.c.

◆ duk_activation

typedef struct duk_activation duk_activation

Definition at line 328 of file duktape-1.8.0/src/duktape.c.

◆ duk_bitdecoder_ctx

typedef struct duk_bitdecoder_ctx duk_bitdecoder_ctx

Definition at line 338 of file duktape-1.8.0/src/duktape.c.

◆ duk_bitencoder_ctx

typedef struct duk_bitencoder_ctx duk_bitencoder_ctx

Definition at line 339 of file duktape-1.8.0/src/duktape.c.

◆ duk_breakpoint

typedef struct duk_breakpoint duk_breakpoint

Definition at line 326 of file duktape-1.8.0/src/duktape.c.

◆ duk_bufwriter_ctx

typedef struct duk_bufwriter_ctx duk_bufwriter_ctx

Definition at line 340 of file duktape-1.8.0/src/duktape.c.

◆ duk_catcher

typedef struct duk_catcher duk_catcher

Definition at line 329 of file duktape-1.8.0/src/duktape.c.

◆ duk_compiler_ctx

typedef struct duk_compiler_ctx duk_compiler_ctx

Definition at line 350 of file duktape-1.8.0/src/duktape.c.

◆ duk_compiler_func

typedef struct duk_compiler_func duk_compiler_func

Definition at line 349 of file duktape-1.8.0/src/duktape.c.

◆ duk_compiler_instr

typedef struct duk_compiler_instr duk_compiler_instr

Definition at line 348 of file duktape-1.8.0/src/duktape.c.

◆ duk_hbuffer

typedef struct duk_hbuffer duk_hbuffer

Definition at line 316 of file duktape-1.8.0/src/duktape.c.

◆ duk_hbuffer_dynamic

typedef struct duk_hbuffer_dynamic duk_hbuffer_dynamic

Definition at line 318 of file duktape-1.8.0/src/duktape.c.

◆ duk_hbuffer_external

typedef struct duk_hbuffer_external duk_hbuffer_external

Definition at line 319 of file duktape-1.8.0/src/duktape.c.

◆ duk_hbuffer_fixed

typedef struct duk_hbuffer_fixed duk_hbuffer_fixed

Definition at line 317 of file duktape-1.8.0/src/duktape.c.

◆ duk_hbufferobject

typedef struct duk_hbufferobject duk_hbufferobject

Definition at line 314 of file duktape-1.8.0/src/duktape.c.

◆ duk_hcompiledfunction

typedef struct duk_hcompiledfunction duk_hcompiledfunction

Definition at line 312 of file duktape-1.8.0/src/duktape.c.

◆ duk_heap

typedef struct duk_heap duk_heap

Definition at line 325 of file duktape-1.8.0/src/duktape.c.

◆ duk_heaphdr

typedef struct duk_heaphdr duk_heaphdr

Definition at line 307 of file duktape-1.8.0/src/duktape.c.

◆ duk_heaphdr_string

typedef struct duk_heaphdr_string duk_heaphdr_string

Definition at line 308 of file duktape-1.8.0/src/duktape.c.

◆ duk_hnativefunction

typedef struct duk_hnativefunction duk_hnativefunction

Definition at line 313 of file duktape-1.8.0/src/duktape.c.

◆ duk_hobject

typedef struct duk_hobject duk_hobject

Definition at line 311 of file duktape-1.8.0/src/duktape.c.

◆ duk_hstring

typedef struct duk_hstring duk_hstring

Definition at line 309 of file duktape-1.8.0/src/duktape.c.

◆ duk_hstring_external

typedef struct duk_hstring_external duk_hstring_external

Definition at line 310 of file duktape-1.8.0/src/duktape.c.

◆ duk_hthread

typedef struct duk_hthread duk_hthread

Definition at line 315 of file duktape-1.8.0/src/duktape.c.

◆ duk_instr_t

typedef duk_uint32_t duk_instr_t

Definition at line 2548 of file duktape-1.8.0/src/duktape.c.

◆ duk_internal_thread_state

typedef struct duk_internal_thread_state duk_internal_thread_state

Definition at line 14048 of file duktape-1.8.0/src/duktape.c.

◆ duk_jmpbuf

typedef struct duk_jmpbuf duk_jmpbuf

Definition at line 303 of file duktape-1.8.0/src/duktape.c.

◆ duk_lexer_codepoint

typedef struct duk_lexer_codepoint duk_lexer_codepoint

Definition at line 346 of file duktape-1.8.0/src/duktape.c.

◆ duk_lexer_ctx

typedef struct duk_lexer_ctx duk_lexer_ctx

Definition at line 345 of file duktape-1.8.0/src/duktape.c.

◆ duk_lexer_point

typedef struct duk_lexer_point duk_lexer_point

Definition at line 344 of file duktape-1.8.0/src/duktape.c.

◆ duk_ljstate

typedef struct duk_ljstate duk_ljstate

Definition at line 331 of file duktape-1.8.0/src/duktape.c.

◆ duk_mem_getptr

typedef void *(* duk_mem_getptr) (duk_heap *heap, void *ud)

Definition at line 6889 of file duktape-1.8.0/src/duktape.c.

◆ duk_propaccessor

typedef struct duk_propaccessor duk_propaccessor

Definition at line 321 of file duktape-1.8.0/src/duktape.c.

◆ duk_propdesc

typedef struct duk_propdesc duk_propdesc

Definition at line 323 of file duktape-1.8.0/src/duktape.c.

◆ duk_propvalue

typedef union duk_propvalue duk_propvalue

Definition at line 322 of file duktape-1.8.0/src/duktape.c.

◆ duk_re_compiler_ctx

typedef struct duk_re_compiler_ctx duk_re_compiler_ctx

Definition at line 353 of file duktape-1.8.0/src/duktape.c.

◆ duk_re_matcher_ctx

typedef struct duk_re_matcher_ctx duk_re_matcher_ctx

Definition at line 352 of file duktape-1.8.0/src/duktape.c.

◆ duk_re_range_callback

typedef void(* duk_re_range_callback) (void *user, duk_codepoint_t r1, duk_codepoint_t r2, duk_bool_t direct)

Definition at line 2730 of file duktape-1.8.0/src/duktape.c.

◆ duk_re_token

typedef struct duk_re_token duk_re_token

Definition at line 343 of file duktape-1.8.0/src/duktape.c.

◆ duk_reg_t

typedef duk_int32_t duk_reg_t

Definition at line 3198 of file duktape-1.8.0/src/duktape.c.

◆ duk_regconst_t

typedef duk_uint32_t duk_regconst_t

Definition at line 3195 of file duktape-1.8.0/src/duktape.c.

◆ duk_strcache

typedef struct duk_strcache duk_strcache

Definition at line 330 of file duktape-1.8.0/src/duktape.c.

◆ duk_strtab_entry

typedef struct duk_strtab_entry duk_strtab_entry

Definition at line 332 of file duktape-1.8.0/src/duktape.c.

◆ duk_token

typedef struct duk_token duk_token

Definition at line 342 of file duktape-1.8.0/src/duktape.c.

◆ duk_tval

typedef struct duk_tval_struct duk_tval

Definition at line 620 of file duktape-1.8.0/src/duktape.c.

Function Documentation

◆ duk__abandon_array_checked()

DUK_LOCAL void duk__abandon_array_checked ( duk_hthread * thr,
duk_hobject * obj )

Definition at line 48415 of file duktape-1.8.0/src/duktape.c.

48432 {
48433 duk_uint32_t new_e_size;
48434 duk_uint32_t new_a_size;
48435 duk_uint32_t new_h_size;
48436 duk_uint32_t e_used; /* actually used, non-NULL keys */
48437 duk_uint32_t a_used;
48438 duk_uint32_t a_size;
48439
48440 DUK_ASSERT(thr != NULL);
48441 DUK_ASSERT(obj != NULL);
48442
48443 e_used = duk__count_used_e_keys(thr, obj);
48444 duk__compute_a_stats(thr, obj, &a_used, &a_size);
48445
48446 /*
48447 * Must guarantee all actually used array entries will fit into
48448 * new entry part. Add one growth step to ensure we don't run out
48449 * of space right away.
48450 */
48451
DUK_LOCAL duk_uint32_t duk__count_used_e_keys(duk_hthread *thr, duk_hobject *obj)
DUK_LOCAL void duk__compute_a_stats(duk_hthread *thr, duk_hobject *obj, duk_uint32_t *out_used, duk_uint32_t *out_min_size)

Referenced by duk_hobject_define_property_helper(), and duk_hobject_putprop().

◆ duk__abandon_array_density_check()

DUK_LOCAL duk_bool_t duk__abandon_array_density_check ( duk_uint32_t a_used,
duk_uint32_t a_size )

Definition at line 47689 of file duktape-1.8.0/src/duktape.c.

47690 {
47691 used++;
47692 highest_idx = i;
47693 }
47694 }
47695
47696 /* Initial value for highest_idx is -1 coerced to unsigned. This
47697 * is a bit odd, but (highest_idx + 1) will then wrap to 0 below
47698 * for out_min_size as intended.
47699 */
47700
47701 *out_used = used;
47702 *out_min_size = highest_idx + 1; /* 0 if no used entries */
47703}
47704
47705/* Check array density and indicate whether or not the array part should be abandoned. */
47706DUK_LOCAL duk_bool_t duk__abandon_array_density_check(duk_uint32_t a_used, duk_uint32_t a_size) {
47707 /*
DUK_LOCAL duk_bool_t duk__abandon_array_density_check(duk_uint32_t a_used, duk_uint32_t a_size)

Referenced by duk_hobject_putprop().

◆ duk__abandon_array_slow_check_required()

DUK_LOCAL duk_bool_t duk__abandon_array_slow_check_required ( duk_uint32_t arr_idx,
duk_uint32_t old_size )

Definition at line 47710 of file duktape-1.8.0/src/duktape.c.

47713 :8
47714 * new_used < limit' * (new_size / 8)
47715 *
47716 * Here, new_used = a_used, new_size = a_size.
47717 *
47718 * Note: some callers use approximate values for a_used and/or a_size
47719 * (e.g. dropping a '+1' term). This doesn't affect the usefulness
47720 * of the check, but may confuse debugging.
47721 */
47722
47723 return (a_used < DUK_HOBJECT_A_ABANDON_LIMIT * (a_size >> 3));
47724}
47725
47726/* Fast check for extending array: check whether or not a slow density check is required. */
47727DUK_LOCAL duk_bool_t duk__abandon_array_slow_check_required(duk_uint32_t arr_idx, duk_uint32_t old_size) {
47728 /*
47729 * In a fast check we assume old_size equals old_used (i.e., existing
47730 * array is fully dense).
47731 *
47732 * Slow check if:
47733 *

Referenced by duk_hobject_putprop().

◆ duk__acos()

DUK_LOCAL double duk__acos ( double x)

Definition at line 32738 of file duktape-1.8.0/src/duktape.c.

◆ duk__add_compiler_error_line()

DUK_LOCAL void duk__add_compiler_error_line ( duk_hthread * thr)

Definition at line 40251 of file duktape-1.8.0/src/duktape.c.

40254 :
40255 /* [ ... error lineNumber fileName ] */
40256#if defined(DUK_USE_ASSERTIONS)
40257 DUK_ASSERT(duk_get_top(ctx) == entry_top + 2);
40258#endif
40261}
40262#endif /* !DUK_USE_TRACEBACKS */
40263
40264/*
40265 * Add line number to a compiler error.
40266 */
40267
40269 duk_context *ctx;
40270
40271 /* Append a "(line NNN)" to the "message" property of any error
40272 * thrown during compilation. Usually compilation errors are
40273 * SyntaxErrors but they can also be out-of-memory errors and
40274 * the like.
40275 */
40276
40277 /* [ ... error ] */
40278
40279 ctx = (duk_context *) thr;
40280 DUK_ASSERT(duk_is_object(ctx, -1));
40281
40282 if (!(thr->compile_ctx != NULL && thr->compile_ctx->h_filename != NULL)) {
#define DUK_STRIDX_LINE_NUMBER
#define DUK_STRIDX_FILE_NAME
#define DUK_PROPDESC_FLAG_NO_OVERWRITE
DUK_EXTERNAL duk_bool_t duk_is_object(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL duk_idx_t duk_get_top(duk_context *ctx)
#define DUK_PROPDESC_FLAGS_WC
DUK_LOCAL void duk__add_compiler_error_line(duk_hthread *thr)
DUK_INTERNAL_DECL void duk_xdef_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_uint_t desc_flags)

◆ duk__add_label()

DUK_LOCAL_DECL void duk__add_label ( duk_compiler_ctx * comp_ctx,
duk_hstring * h_label,
duk_int_t pc_label,
duk_int_t label_id )

Definition at line 60252 of file duktape-1.8.0/src/duktape.c.

60253 {
60254 rc_varname = duk__getconst(comp_ctx);
60255 *out_reg_varbind = -1;
60256 *out_rc_varname = rc_varname;
60257 return 0;
60258 }
60259}
60260
60261/*
60262 * Label handling
60263 *
60264 * Labels are initially added with flags prohibiting both break and continue.
60265 * When the statement type is finally uncovered (after potentially multiple
60266 * labels), all the labels are updated to allow/prohibit break and continue.
60267 */
60268
60269DUK_LOCAL void duk__add_label(duk_compiler_ctx *comp_ctx, duk_hstring *h_label, duk_int_t pc_label, duk_int_t label_id) {
60270 duk_hthread *thr = comp_ctx->thr;
60271 duk_context *ctx = (duk_context *) thr;
60272 duk_size_t n;
60273 duk_size_t new_size;
60274 duk_uint8_t *p;
60275 duk_labelinfo *li_start, *li;
60276
60277 /* Duplicate (shadowing) labels are not allowed, except for the empty
60278 * labels (which are used as default labels for switch and iteration
60279 * statements).
60280 *
60281 * We could also allow shadowing of non-empty pending labels without any
60282 * other issues than breaking the required label shadowing requirements
60283 * of the E5 specification, see Section 12.12.
60284 */
60285
60286 p = (duk_uint8_t *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, comp_ctx->curr_func.h_labelinfos);
60287 li_start = (duk_labelinfo *) (void *) p;
60288 li = (duk_labelinfo *) (void *) (p + DUK_HBUFFER_GET_SIZE(comp_ctx->curr_func.h_labelinfos));
60289 n = (duk_size_t) (li - li_start);
60290
60291 while (li > li_start) {
60292 li--;
60293
60294 if (li->h_label == h_label && h_label != DUK_HTHREAD_STRING_EMPTY_STRING(thr)) {
60296 }
60297 }
60298
60299 duk_push_hstring(ctx, h_label);
60300 DUK_ASSERT(n <= DUK_UARRIDX_MAX); /* label limits */
60301 (void) duk_put_prop_index(ctx, comp_ctx->curr_func.labelnames_idx, (duk_uarridx_t) n);
60302
60303 new_size = (n + 1) * sizeof(duk_labelinfo);
60304 duk_hbuffer_resize(thr, comp_ctx->curr_func.h_labelinfos, new_size);
60305 /* XXX: spare handling, slow now */
60306
60307 /* relookup after possible realloc */
60308 p = (duk_uint8_t *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, comp_ctx->curr_func.h_labelinfos);
60309 li_start = (duk_labelinfo *) (void *) p;
60310 DUK_UNREF(li_start); /* silence scan-build warning */
60311 li = (duk_labelinfo *) (void *) (p + DUK_HBUFFER_GET_SIZE(comp_ctx->curr_func.h_labelinfos));
60312 li--;
60313
DUK_INTERNAL_DECL void duk_push_hstring(duk_context *ctx, duk_hstring *h)
DUK_EXTERNAL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx)
DUK_LOCAL_DECL void duk__add_label(duk_compiler_ctx *comp_ctx, duk_hstring *h_label, duk_int_t pc_label, duk_int_t label_id)
#define DUK_ERROR_SYNTAX(thr, msg)
#define DUK_HTHREAD_STRING_EMPTY_STRING(thr)
DUK_LOCAL_DECL duk_regconst_t duk__getconst(duk_compiler_ctx *comp_ctx)
#define DUK_STR_DUPLICATE_LABEL
DUK_INTERNAL_DECL void duk_hbuffer_resize(duk_hthread *thr, duk_hbuffer_dynamic *buf, duk_size_t new_size)

◆ duk__add_traceback()

DUK_LOCAL void duk__add_traceback ( duk_hthread * thr,
duk_hthread * thr_callstack,
const char * c_filename,
duk_int_t c_line,
duk_bool_t noblame_fileline )

Definition at line 40000 of file duktape-1.8.0/src/duktape.c.

40017 {
40018 duk_context *ctx = (duk_context *) thr;
40020 duk_int_t i, i_min;
40021 duk_uarridx_t arr_idx;
40022 duk_double_t d;
40023
40024 DUK_ASSERT(thr != NULL);
40025 DUK_ASSERT(thr_callstack != NULL);
40026 DUK_ASSERT(ctx != NULL);
40027
40028 /* [ ... error ] */
40029
40030 /*
40031 * The traceback format is pretty arcane in an attempt to keep it compact
40032 * and cheap to create. It may change arbitrarily from version to version.
40033 * It should be decoded/accessed through version specific accessors only.
40034 *
40035 * See doc/error-objects.rst.
40036 */
40037
40038 DUK_DDD(DUK_DDDPRINT("adding traceback to object: %!T",
40039 (duk_tval *) duk_get_tval(ctx, -1)));
40040
40041 duk_push_array(ctx); /* XXX: specify array size, as we know it */
40042 arr_idx = 0;
40043
40044 /* Compiler SyntaxErrors (and other errors) come first, and are
40045 * blamed by default (not flagged "noblame").
40046 */
40047 if (thr->compile_ctx != NULL && thr->compile_ctx->h_filename != NULL) {
40049 duk_xdef_prop_index_wec(ctx, -2, arr_idx);
40050 arr_idx++;
40051
40052 duk_push_uint(ctx, (duk_uint_t) thr->compile_ctx->curr_token.start_line); /* (flags<<32) + (line), flags = 0 */
40053 duk_xdef_prop_index_wec(ctx, -2, arr_idx);
40054 arr_idx++;
40055 }
40056
40057 /* Filename/line from C macros (__FILE__, __LINE__) are added as an
40058 * entry with a special format: (string, number). The number contains
40059 * the line and flags.
40060 */
40061
40062 /* XXX: optimize: allocate an array part to the necessary size (upwards
40063 * estimate) and fill in the values directly into the array part; finally
40064 * update 'length'.
40065 */
40066
40067 /* XXX: using duk_put_prop_index() would cause obscure error cases when Array.prototype
40068 * has write-protected array index named properties. This was seen as DoubleErrors
40069 * in e.g. some test262 test cases. Using duk_xdef_prop_index() is better but heavier.
40070 * The best fix is to fill in the tracedata directly into the array part. There are
40071 * no side effect concerns if the array part is allocated directly and only INCREFs
40072 * happen after that.
40073 */
40074
40075 /* [ ... error arr ] */
40076
40077 if (c_filename) {
40078 duk_push_string(ctx, c_filename);
40079 duk_xdef_prop_index_wec(ctx, -2, arr_idx);
40080 arr_idx++;
40081
40082 d = (noblame_fileline ? ((duk_double_t) DUK_TB_FLAG_NOBLAME_FILELINE) * DUK_DOUBLE_2TO32 : 0.0) +
40083 (duk_double_t) c_line;
40084 duk_push_number(ctx, d);
40085 duk_xdef_prop_index_wec(ctx, -2, arr_idx);
40086 arr_idx++;
40087 }
40088
40089 /* traceback depth doesn't take into account the filename/line
40090 * special handling above (intentional)
40091 */
40093 i_min = (thr_callstack->callstack_top > (duk_size_t) depth ? (duk_int_t) (thr_callstack->callstack_top - depth) : 0);
40094 DUK_ASSERT(i_min >= 0);
40095
40096 /* [ ... error arr ] */
40097
40098 DUK_ASSERT(thr_callstack->callstack_top <= DUK_INT_MAX); /* callstack limits */
40099 for (i = (duk_int_t) (thr_callstack->callstack_top - 1); i >= i_min; i--) {
40100 duk_uint32_t pc;
40101
40102 /*
40103 * Note: each API operation potentially resizes the callstack,
40104 * so be careful to re-lookup after every operation. Currently
40105 * these is no issue because we don't store a temporary 'act'
40106 * pointer at all. (This would be a non-issue if we operated
40107 * directly on the array part.)
40108 */
40109
40110 /* [... arr] */
40111
40112 DUK_ASSERT_DISABLE(thr_callstack->callstack[i].pc >= 0); /* unsigned */
40113
40114 /* Add function object. */
40115 duk_push_tval(ctx, &(thr_callstack->callstack + i)->tv_func);
40116 duk_xdef_prop_index_wec(ctx, -2, arr_idx);
40117 arr_idx++;
40118
40119 /* Add a number containing: pc, activation flags.
40120 *
40121 * PC points to next instruction, find offending PC. Note that
40122 * PC == 0 for native code.
40123 */
guint depth
DUK_EXTERNAL const char * duk_push_string(duk_context *ctx, const char *str)
#define DUK_DDD(x)
DUK_INTERNAL_DECL void duk_push_tval(duk_context *ctx, duk_tval *tv)
#define duk_xdef_prop_index_wec(ctx, obj_index, arr_index)
#define DUK_TB_FLAG_NOBLAME_FILELINE
#define DUK_ASSERT_DISABLE(x)
DUK_EXTERNAL void duk_push_uint(duk_context *ctx, duk_uint_t val)
DUK_EXTERNAL void duk_push_number(duk_context *ctx, duk_double_t val)
DUK_EXTERNAL duk_idx_t duk_push_array(duk_context *ctx)
DUK_INTERNAL_DECL duk_tval * duk_get_tval(duk_context *ctx, duk_idx_t index)

◆ duk__adjust_valstack_and_top()

DUK_LOCAL void duk__adjust_valstack_and_top ( duk_hthread * thr,
duk_idx_t num_stack_args,
duk_idx_t idx_args,
duk_idx_t nregs,
duk_idx_t nargs,
duk_hobject * func )

Definition at line 55766 of file duktape-1.8.0/src/duktape.c.

55766 :
55767 DUK_ASSERT(tv_func != NULL);
55768#if defined(DUK_USE_PARANOID_ERRORS)
55770#else
55771 DUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, "%s not callable", duk_push_string_tval_readable(ctx, tv_func));
55772#endif
55774 return NULL; /* never executed */
55775}
55776
55777/*
55778 * Value stack resize and stack top adjustment helper.
55779 *
55780 * XXX: This should all be merged to duk_valstack_resize_raw().
55781 */
55782
55784 duk_idx_t num_stack_args,
55785 duk_idx_t idx_args,
55786 duk_idx_t nregs,
55787 duk_idx_t nargs,
55788 duk_hobject *func) {
55789 duk_context *ctx = (duk_context *) thr;
55790 duk_size_t vs_min_size;
55791 duk_bool_t adjusted_top = 0;
55792
55793 vs_min_size = (thr->valstack_bottom - thr->valstack) + /* bottom of current func */
55794 idx_args; /* bottom of new func */
55795
55796 if (nregs >= 0) {
55797 DUK_ASSERT(nargs >= 0);
55798 DUK_ASSERT(nregs >= nargs);
55799 vs_min_size += nregs;
55800 } else {
55801 /* 'func' wants stack "as is" */
55802 vs_min_size += num_stack_args; /* num entries of new func at entry */
55803 }
55804 if (func == NULL || DUK_HOBJECT_IS_NATIVEFUNCTION(func)) {
55805 vs_min_size += DUK_VALSTACK_API_ENTRY_MINIMUM; /* Duktape/C API guaranteed entries (on top of args) */
55806 }
55807 vs_min_size += DUK_VALSTACK_INTERNAL_EXTRA; /* + spare */
55808
55809 /* XXX: We can't resize the value stack to a size smaller than the
55810 * current top, so the order of the resize and adjusting the stack
55811 * top depends on the current vs. final size of the value stack.
55812 * The operations could be combined to avoid this, but the proper
55813 * fix is to only grow the value stack on a function call, and only
55814 * shrink it (without throwing if the shrink fails) on function
55815 * return.
55816 */
55817
55818 if (vs_min_size < (duk_size_t) (thr->valstack_top - thr->valstack)) {
55819 DUK_DDD(DUK_DDDPRINT(("final size smaller, set top before resize")));
55820
55821 DUK_ASSERT(nregs >= 0); /* can't happen when keeping current stack size */
55822 duk_set_top(ctx, idx_args + nargs); /* clamp anything above nargs */
55823 duk_set_top(ctx, idx_args + nregs); /* extend with undefined */
DUK_INTERNAL_DECL const char * duk_push_string_tval_readable(duk_context *ctx, duk_tval *tv)
#define DUK_STR_NOT_CALLABLE
#define DUK_ERROR_TYPE(thr, msg)
DUK_LOCAL void duk__adjust_valstack_and_top(duk_hthread *thr, duk_idx_t num_stack_args, duk_idx_t idx_args, duk_idx_t nregs, duk_idx_t nargs, duk_hobject *func)
#define DUK_HOBJECT_IS_NATIVEFUNCTION(h)
DUK_EXTERNAL void duk_set_top(duk_context *ctx, duk_idx_t index)
#define DUK_VALSTACK_API_ENTRY_MINIMUM
#define DUK_ERROR_FMT1(thr, err, fmt, arg1)
#define DUK_VALSTACK_INTERNAL_EXTRA

Referenced by duk_handle_ecma_call_setup().

◆ duk__advance()

◆ duk__advance_bytes()

DUK_LOCAL void duk__advance_bytes ( duk_lexer_ctx * lex_ctx,
duk_small_uint_t count_bytes )

Definition at line 73633 of file duktape-1.8.0/src/duktape.c.

73642 : /* clipped codepoint */
73643 error_encoding: /* invalid codepoint encoding or codepoint */
73644 lex_ctx->input_offset = (duk_size_t) (p - lex_ctx->input);
73645 lex_ctx->input_line = input_line;
73646
73647 DUK_ERROR_SYNTAX(lex_ctx->thr, "utf-8 decode failed");
73648}
73649
73650DUK_LOCAL void duk__advance_bytes(duk_lexer_ctx *lex_ctx, duk_small_uint_t count_bytes) {
73651 duk_small_uint_t used_bytes, avail_bytes;
73652
73653 DUK_ASSERT_DISABLE(count_bytes >= 0); /* unsigned */
73655 DUK_ASSERT(lex_ctx->window >= lex_ctx->buffer);
73656 DUK_ASSERT(lex_ctx->window < lex_ctx->buffer + DUK_LEXER_BUFFER_SIZE);
73657 DUK_ASSERT((duk_uint8_t *) lex_ctx->window + count_bytes <= (duk_uint8_t *) lex_ctx->buffer + DUK_LEXER_BUFFER_SIZE * sizeof(duk_lexer_codepoint));
73658
73659 /* Zero 'count' is also allowed to make call sites easier.
#define DUK_LEXER_BUFFER_SIZE
#define DUK_LEXER_WINDOW_SIZE
DUK_LOCAL void duk__advance_bytes(duk_lexer_ctx *lex_ctx, duk_small_uint_t count_bytes)
duk_lexer_codepoint buffer[DUK_LEXER_BUFFER_SIZE]

◆ duk__advance_expect()

DUK_LOCAL_DECL void duk__advance_expect ( duk_compiler_ctx * comp_ctx,
duk_small_int_t expect )

Definition at line 58189 of file duktape-1.8.0/src/duktape.c.

58189 : curr: tok=%ld/%ld,%ld,term=%ld,%!T,%!T "
58190 "prev: tok=%ld/%ld,%ld,term=%ld,%!T,%!T",
58191 (long) comp_ctx->curr_token.t,

Referenced by duk__parse_func_body(), and duk__parse_func_formals().

◆ duk__advance_helper()

DUK_LOCAL_DECL void duk__advance_helper ( duk_compiler_ctx * comp_ctx,
duk_small_int_t expect )

Definition at line 58130 of file duktape-1.8.0/src/duktape.c.

58133 {
58134 DUK_ASSERT(h != NULL);
58135 return (comp_ctx->curr_func.is_strict &&
58137}
58138
58139/*
58140 * Parser duk__advance() token eating functions
58141 */
58142
58143/* XXX: valstack handling is awkward. Add a valstack helper which
58144 * avoids dup():ing; valstack_copy(src, dst)?
58145 */
58146
58148 duk_hthread *thr = comp_ctx->thr;
58149 duk_context *ctx = (duk_context *) thr;
58150 duk_bool_t regexp;
58151
58152 DUK_ASSERT(comp_ctx->curr_token.t >= 0 && comp_ctx->curr_token.t <= DUK_TOK_MAXVAL); /* MAXVAL is inclusive */
58153
58154 /*
58155 * Use current token to decide whether a RegExp can follow.
58156 *
58157 * We can use either 't' or 't_nores'; the latter would not
58158 * recognize keywords. Some keywords can be followed by a
58159 * RegExp (e.g. "return"), so using 't' is better. This is
58160 * not trivial, see doc/compiler.rst.
58161 */
58162
58163 regexp = 1;
58165 regexp = 0;
58166 }
58167 if (comp_ctx->curr_func.reject_regexp_in_adv) {
58168 comp_ctx->curr_func.reject_regexp_in_adv = 0;
58169 regexp = 0;
58170 }
58171
58172 if (expect >= 0 && comp_ctx->curr_token.t != expect) {
58173 DUK_D(DUK_DPRINT("parse error: expect=%ld, got=%ld",
58174 (long) expect, (long) comp_ctx->curr_token.t));
58176 }
58177
58178 /* make current token the previous; need to fiddle with valstack "backing store" */
58179 DUK_MEMCPY(&comp_ctx->prev_token, &comp_ctx->curr_token, sizeof(duk_token));
58180 duk_copy(ctx, comp_ctx->tok11_idx, comp_ctx->tok21_idx);
58181 duk_copy(ctx, comp_ctx->tok12_idx, comp_ctx->tok22_idx);
58182
58183 /* parse new token */
58185 &comp_ctx->curr_token,
58186 comp_ctx->curr_func.is_strict,
DUK_LOCAL const duk_uint8_t duk__token_lbp[]
DUK_INTERNAL_DECL void duk_lexer_parse_js_input_element(duk_lexer_ctx *lex_ctx, duk_token *out_token, duk_bool_t strict_mode, duk_bool_t regexp_mode)
#define DUK_TOK_MAXVAL
DUK_LOCAL_DECL void duk__advance_helper(duk_compiler_ctx *comp_ctx, duk_small_int_t expect)
#define DUK_STR_PARSE_ERROR
DUK_EXTERNAL void duk_copy(duk_context *ctx, duk_idx_t from_index, duk_idx_t to_index)
#define DUK_HSTRING_HAS_EVAL_OR_ARGUMENTS(x)
#define DUK__TOKEN_LBP_FLAG_NO_REGEXP

◆ duk__alloc_entry_checked()

DUK_LOCAL duk_bool_t duk__alloc_entry_checked ( duk_hthread * thr,
duk_hobject * obj,
duk_hstring * key )

Definition at line 48674 of file duktape-1.8.0/src/duktape.c.

48675 {
48676 return NULL;
48677 }
48678 tv = DUK_HOBJECT_A_GET_VALUE_PTR(heap, obj, i);
48679 return tv;
48680}
48681
48682/*
48683 * Allocate and initialize a new entry, resizing the properties allocation
48684 * if necessary. Returns entry index (e_idx) or throws an error if alloc fails.
48685 *
48686 * Sets the key of the entry (increasing the key's refcount), and updates
48687 * the hash part if it exists. Caller must set value and flags, and update
48688 * the entry value refcount. A decref for the previous value is not necessary.
48689 */
48690
48692 duk_uint32_t idx;
48693
48694 DUK_ASSERT(thr != NULL);
48695 DUK_ASSERT(obj != NULL);
48696 DUK_ASSERT(key != NULL);
48698
48699#ifdef DUK_USE_ASSERTIONS
48700 /* key must not already exist in entry part */
48701 {
48703 for (i = 0; i < DUK_HOBJECT_GET_ENEXT(obj); i++) {
48704 DUK_ASSERT(DUK_HOBJECT_E_GET_KEY(thr->heap, obj, i) != key);
48705 }
48706 }
48707#endif
48708
48710 /* only need to guarantee 1 more slot, but allocation growth is in chunks */
48711 DUK_DDD(DUK_DDDPRINT("entry part full, allocate space for one more entry"));
48713 }
48715 idx = DUK_HOBJECT_POSTINC_ENEXT(obj);
48716
48717 /* previous value is assumed to be garbage, so don't touch it */
48718 DUK_HOBJECT_E_SET_KEY(thr->heap, obj, idx, key);
48719 DUK_HSTRING_INCREF(thr, key);
48720
48721#if defined(DUK_USE_HOBJECT_HASH_PART)
48722 if (DUK_UNLIKELY(DUK_HOBJECT_GET_HSIZE(obj) > 0)) {
48723 duk_uint32_t n;
48724 duk_uint32_t i, step;
48725 duk_uint32_t *h_base = DUK_HOBJECT_H_GET_BASE(thr->heap, obj);
48726
48727 n = DUK_HOBJECT_GET_HSIZE(obj);
48730
48731 for (;;) {
48732 duk_uint32_t t = h_base[i];
48733 if (t == DUK__HASH_UNUSED || t == DUK__HASH_DELETED) {
48734 DUK_DDD(DUK_DDDPRINT("duk__alloc_entry_checked() inserted key into hash part, %ld -> %ld",
48735 (long) i, (long) idx));
48736 DUK_ASSERT_DISABLE(i >= 0); /* unsigned */
48738 DUK_ASSERT_DISABLE(idx >= 0);
48740 h_base[i] = idx;
48741 break;
48742 }
48743 DUK_DDD(DUK_DDDPRINT("duk__alloc_entry_checked() miss %ld", (long) i));
#define DUK_HOBJECT_A_GET_VALUE_PTR(heap, h, i)
#define DUK_HOBJECT_POSTINC_ENEXT(h)
DUK_LOCAL void duk__grow_props_for_new_entry_item(duk_hthread *thr, duk_hobject *obj)
#define DUK_HOBJECT_GET_ENEXT(h)
DUK_LOCAL duk_bool_t duk__alloc_entry_checked(duk_hthread *thr, duk_hobject *obj, duk_hstring *key)
#define DUK_HSTRING_GET_HASH(x)
#define DUK_HOBJECT_E_SET_KEY(heap, h, i, k)
#define DUK__HASH_INITIAL(hash, h_size)
#define DUK_HSTRING_INCREF(thr, h)
#define DUK_HOBJECT_GET_HSIZE(h)
#define DUK__HASH_PROBE_STEP(hash)
#define DUK__HASH_UNUSED
#define DUK__HASH_DELETED
#define DUK_HOBJECT_H_GET_BASE(heap, h)

Referenced by duk_hobject_define_property_helper(), duk_hobject_define_property_internal(), and duk_hobject_putprop().

◆ duk__alloc_init_hstring()

DUK_LOCAL duk_hstring * duk__alloc_init_hstring ( duk_heap * heap,
const duk_uint8_t * str,
duk_uint32_t blen,
duk_uint32_t strhash,
const duk_uint8_t * extdata )

Definition at line 45037 of file duktape-1.8.0/src/duktape.c.

45058 {
45059 duk_hstring *res = NULL;
45060 duk_uint8_t *data;
45061 duk_size_t alloc_size;
45063 duk_uint32_t clen;
45064
45065#if defined(DUK_USE_STRLEN16)
45066 /* If blen <= 0xffffUL, clen is also guaranteed to be <= 0xffffUL. */
45067 if (blen > 0xffffUL) {
45068 DUK_D(DUK_DPRINT("16-bit string blen/clen active and blen over 16 bits, reject intern"));
45069 return NULL;
45070 }
45071#endif
45072
45073 if (extdata) {
45074 alloc_size = (duk_size_t) sizeof(duk_hstring_external);
45075 res = (duk_hstring *) DUK_ALLOC(heap, alloc_size);
45076 if (!res) {
45077 goto alloc_error;
45078 }
45079 DUK_MEMZERO(res, sizeof(duk_hstring_external));
45080#if defined(DUK_USE_EXPLICIT_NULL_INIT)
45082#endif
45084
45085 ((duk_hstring_external *) res)->extdata = extdata;
45086 } else {
45087 /* NUL terminate for convenient C access */
45088 alloc_size = (duk_size_t) (sizeof(duk_hstring) + blen + 1);
45089 res = (duk_hstring *) DUK_ALLOC(heap, alloc_size);
45090 if (!res) {
45091 goto alloc_error;
45092 }
45093 DUK_MEMZERO(res, sizeof(duk_hstring));
45094#if defined(DUK_USE_EXPLICIT_NULL_INIT)
45096#endif
45098
45099 data = (duk_uint8_t *) (res + 1);
45100 DUK_MEMCPY(data, str, blen);
45101 data[blen] = (duk_uint8_t) 0;
45102 }
45103
45105 if (duk_js_to_arrayindex_raw_string(str, blen, &dummy)) {
45107 }
45108
45109 /* All strings beginning with 0xff are treated as "internal",
45110 * even strings interned by the user. This allows user code to
45111 * create internal properties too, and makes behavior consistent
45112 * in case user code happens to use a string also used by Duktape
45113 * (such as string has already been interned and has the 'internal'
45114 * flag set).
45115 */
45117 if (blen > 0 && str[0] == (duk_uint8_t) 0xff) {
45119 }
45120
45121 DUK_HSTRING_SET_HASH(res, strhash);
45122 DUK_HSTRING_SET_BYTELEN(res, blen);
45123
45124 clen = (duk_uint32_t) duk_unicode_unvalidated_utf8_length(str, (duk_size_t) blen);
45125 DUK_ASSERT(clen <= blen);
45126#if defined(DUK_USE_HSTRING_CLEN)
45127 DUK_HSTRING_SET_CHARLEN(res, clen);
45128#endif
45129
45130 /* Using an explicit 'ASCII' flag has larger footprint (one call site
45131 * only) but is quite useful for the case when there's no explicit
45132 * 'clen' in duk_hstring.
45133 */
#define DUK_MEMZERO(p, n)
#define DUK_HSTRING_HAS_ASCII(x)
#define DUK_ALLOC(heap, size)
#define DUK_HEAPHDR_STRING_INIT_NULLS(h)
#define DUK_HSTRING_SET_CHARLEN(x, v)
#define DUK_HSTRING_FLAG_EXTDATA
#define DUK_HSTRING_SET_HASH(x, v)
#define DUK_HSTRING_SET_ARRIDX(x)
#define DUK_HSTRING_HAS_INTERNAL(x)
#define DUK_HEAPHDR_SET_TYPE_AND_FLAGS(h, tval, fval)
#define DUK_HSTRING_HAS_ARRIDX(x)
#define DUK_HSTRING_SET_INTERNAL(x)
#define DUK_HSTRING_SET_BYTELEN(x, v)
#define DUK_HTYPE_STRING
DUK_INTERNAL_DECL duk_size_t duk_unicode_unvalidated_utf8_length(const duk_uint8_t *data, duk_size_t blen)

References DUK_ALLOC, DUK_ASSERT, DUK_D, DUK_DDD, DUK_DDDPRINT, DUK_DPRINT, DUK_FREE, DUK_HEAPHDR_SET_TYPE_AND_FLAGS, DUK_HEAPHDR_STRING_INIT_NULLS, DUK_HSTRING_FLAG_EXTDATA, DUK_HSTRING_GET_BYTELEN, DUK_HSTRING_GET_CHARLEN, DUK_HSTRING_GET_HASH, DUK_HSTRING_HAS_ARRIDX, DUK_HSTRING_HAS_ASCII, DUK_HSTRING_HAS_EXTDATA, DUK_HSTRING_HAS_INTERNAL, DUK_HSTRING_SET_ARRIDX, DUK_HSTRING_SET_ASCII, DUK_HSTRING_SET_BYTELEN, DUK_HSTRING_SET_CHARLEN, DUK_HSTRING_SET_HASH, DUK_HSTRING_SET_INTERNAL, DUK_HTYPE_STRING, duk_js_to_arrayindex_raw_string(), DUK_MEMCPY, DUK_MEMZERO, duk_unicode_unvalidated_utf8_length(), dummy, duk_hstring::hdr, and NULL.

◆ duk__alloctemp()

DUK_LOCAL_DECL duk_reg_t duk__alloctemp ( duk_compiler_ctx * comp_ctx)

Definition at line 59589 of file duktape-1.8.0/src/duktape.c.

◆ duk__alloctemps()

DUK_LOCAL_DECL duk_reg_t duk__alloctemps ( duk_compiler_ctx * comp_ctx,
duk_small_int_t num )

Definition at line 59571 of file duktape-1.8.0/src/duktape.c.

59574 {
59575 /* Don't allow negative zero as it will cause trouble with
59576 * LDINT+LDINTX. But positive zero is OK.
59577 */
59578 t = (duk_int32_t) x;
59579 if ((duk_double_t) t == x) {
59580 *ival = t;
59581 return 1;
59582 }
59583 }
59584
59585 return 0;
59586}
59587

◆ duk__api_coerce_d2i()

DUK_LOCAL duk_int_t duk__api_coerce_d2i ( duk_context * ctx,
duk_idx_t index,
duk_bool_t require )

Definition at line 15054 of file duktape-1.8.0/src/duktape.c.

15058 { \
15059 DUK_ASSERT(!(thr->valstack_top >= thr->valstack_end)); \
15060 } while (0)
15061#else
15062#define DUK__CHECK_SPACE() do { \
15063 if (DUK_UNLIKELY(thr->valstack_top >= thr->valstack_end)) { \
15064 DUK_ERROR_API(thr, DUK_STR_PUSH_BEYOND_ALLOC_STACK); \
15065 } \
15066 } while (0)
15067#endif
15068
15070
15072 duk_hthread *thr;
15073 duk_tval *tv;
15075 duk_double_t d;
15076
15077 thr = (duk_hthread *) ctx;
15078
15079 tv = duk_get_tval(ctx, index);
15080 if (tv == NULL) {
15081 goto error_notnumber;
15082 }
15083
15084 /*
15085 * Special cases like NaN and +/- Infinity are handled explicitly
15086 * because a plain C coercion from double to int handles these cases
15087 * in undesirable ways. For instance, NaN may coerce to INT_MIN
15088 * (not zero), and INT_MAX + 1 may coerce to INT_MIN (not INT_MAX).
15089 *
15090 * This double-to-int coercion differs from ToInteger() because it
15091 * has a finite range (ToInteger() allows e.g. +/- Infinity). It
15092 * also differs from ToInt32() because the INT_MIN/INT_MAX clamping
15093 * depends on the size of the int type on the platform. In particular,
15094 * on platforms with a 64-bit int type, the full range is allowed.
15095 */
15096
15097#if defined(DUK_USE_FASTINT)
15098 if (DUK_TVAL_IS_FASTINT(tv)) {
15099 duk_int64_t t = DUK_TVAL_GET_FASTINT(tv);
15100#if (DUK_INT_MAX <= 0x7fffffffL)
15101 /* Clamping only necessary for 32-bit ints. */
15102 if (t < DUK_INT_MIN) {
15103 t = DUK_INT_MIN;
15104 } else if (t > DUK_INT_MAX) {
15105 t = DUK_INT_MAX;
15106 }
15107#endif
15108 return (duk_int_t) t;
15109 }
15110#endif
15111
15112 if (DUK_TVAL_IS_NUMBER(tv)) {
15113 d = DUK_TVAL_GET_NUMBER(tv);
15115 if (c == DUK_FP_NAN) {
15116 return 0;
15117 } else if (d < (duk_double_t) DUK_INT_MIN) {
15118 /* covers -Infinity */
15119 return DUK_INT_MIN;
#define DUK_TVAL_IS_NUMBER(tv)
DUK_LOCAL duk_int_t duk__api_coerce_d2i(duk_context *ctx, duk_idx_t index, duk_bool_t require)
DUK_LOCAL_DECL duk_heaphdr * duk__get_tagged_heaphdr_raw(duk_context *ctx, duk_idx_t index, duk_uint_t tag)
#define DUK_TVAL_GET_NUMBER(tv)

◆ duk__api_coerce_d2ui()

DUK_LOCAL duk_uint_t duk__api_coerce_d2ui ( duk_context * ctx,
duk_idx_t index,
duk_bool_t require )

Definition at line 15121 of file duktape-1.8.0/src/duktape.c.

15123 {
15124 /* coerce towards zero */
15125 return (duk_int_t) d;
15126 }
15127 }
15128
15129 error_notnumber:
15130
15131 if (require) {
15133 /* not reachable */
15134 }
15135 return 0;
15136}
15137
15139 duk_hthread *thr;
15140 duk_tval *tv;
15142 duk_double_t d;
15143
15144 /* Same as above but for unsigned int range. */
15145
15146 thr = (duk_hthread *) ctx;
15147
15148 tv = duk_get_tval(ctx, index);
15149 if (tv == NULL) {
15150 goto error_notnumber;
15151 }
15152
15153#if defined(DUK_USE_FASTINT)
15154 if (DUK_TVAL_IS_FASTINT(tv)) {
15155 duk_int64_t t = DUK_TVAL_GET_FASTINT(tv);
15156 if (t < 0) {
15157 t = 0;
15158 }
15159#if (DUK_UINT_MAX <= 0xffffffffUL)
15160 /* Clamping only necessary for 32-bit ints. */
15161 else if (t > DUK_UINT_MAX) {
15162 t = DUK_UINT_MAX;
15163 }
15164#endif
15165 return (duk_uint_t) t;
15166 }
15167#endif
15168
15169 if (DUK_TVAL_IS_NUMBER(tv)) {
15170 d = DUK_TVAL_GET_NUMBER(tv);
15172 if (c == DUK_FP_NAN) {
15173 return 0;
15174 } else if (d < 0.0) {
15175 /* covers -Infinity */
15176 return (duk_uint_t) 0;
#define DUK_ERROR_REQUIRE_TYPE_INDEX(thr, index, expectname, lowmemstr)
#define DUK_STR_NOT_NUMBER
DUK_LOCAL duk_uint_t duk__api_coerce_d2ui(duk_context *ctx, duk_idx_t index, duk_bool_t require)

◆ duk__append_jump_offset()

DUK_LOCAL duk_uint32_t duk__append_jump_offset ( duk_re_compiler_ctx * re_ctx,
duk_int32_t skip )

◆ duk__append_slice()

DUK_LOCAL void duk__append_slice ( duk_re_compiler_ctx * re_ctx,
duk_uint32_t data_offset,
duk_uint32_t data_length )

Definition at line 77779 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ duk__append_u16_list()

DUK_LOCAL void duk__append_u16_list ( duk_re_compiler_ctx * re_ctx,
const duk_uint16_t * values,
duk_uint32_t count )

Definition at line 77767 of file duktape-1.8.0/src/duktape.c.

77773 {

Referenced by duk__parse_disjunction().

◆ duk__append_u32()

DUK_LOCAL duk_uint32_t duk__append_u32 ( duk_re_compiler_ctx * re_ctx,
duk_uint32_t x )

Definition at line 77747 of file duktape-1.8.0/src/duktape.c.

77747 {
77748 return ((duk_uint32_t) x) * 2;
77749 }
77750}
77751
77752/* XXX: return type should probably be duk_size_t, or explicit checks are needed for
77753 * maximum size.
77754 */

Referenced by duk__generate_ranges(), duk__parse_disjunction(), and duk__remove_slice().

◆ duk__appendbuffer()

DUK_LOCAL void duk__appendbuffer ( duk_lexer_ctx * lex_ctx,
duk_codepoint_t x )

Definition at line 73845 of file duktape-1.8.0/src/duktape.c.

73845 {
73846 /* Reuse buffer as is unless buffer has grown large. */
73848 /* Keep current size */
73849 } else {
73851 }
73852
73853 DUK_BW_INIT_WITHBUF(lex_ctx->thr, &lex_ctx->bw, lex_ctx->buf);
73854}
73855
73856/*
73857 * Append a Unicode codepoint to the temporary byte buffer. Performs
73858 * CESU-8 surrogate pair encoding for codepoints above the BMP.
73859 * Existing surrogate pairs are allowed and also encoded into CESU-8.
#define DUK_LEXER_TEMP_BUF_LIMIT
#define DUK_BW_INIT_WITHBUF(thr, bw_ctx, buf)

References duk_lexer_ctx::buf, duk_lexer_ctx::bw, DUK_BW_INIT_WITHBUF, DUK_HBUFFER_DYNAMIC_GET_SIZE, duk_hbuffer_resize(), DUK_LEXER_TEMP_BUF_LIMIT, and duk_lexer_ctx::thr.

◆ duk__array_qsort()

DUK_LOCAL void duk__array_qsort ( duk_context * ctx,
duk_int_t lo,
duk_int_t hi )

Definition at line 20814 of file duktape-1.8.0/src/duktape.c.

20815 {
20816 *ptr++ = '>';
20817 } else if (i >= lo && i <= hi) {
20818 *ptr++ = '-';
20819 } else {
20820 *ptr++ = ' ';
20821 }
20822 }
20823 *ptr++ = ']';
20824 *ptr++ = '\0';
20825
20826 DUK_DDD(DUK_DDDPRINT("%s (lo=%ld, hi=%ld, pivot=%ld)",
20827 (const char *) buf, (long) lo, (long) hi, (long) pivot));
20828}
20829#endif
20830
20832 duk_hthread *thr = (duk_hthread *) ctx;
20833 duk_int_t p, l, r;
20834
20835 /* The lo/hi indices may be crossed and hi < 0 is possible at entry. */
20836
20837 DUK_DDD(DUK_DDDPRINT("duk__array_qsort: lo=%ld, hi=%ld, obj=%!T",
20838 (long) lo, (long) hi, (duk_tval *) duk_get_tval(ctx, 1)));
20839
20840 DUK_ASSERT_TOP(ctx, 3);
20841
20842 /* In some cases it may be that lo > hi, or hi < 0; these
20843 * degenerate cases happen e.g. for empty arrays, and in
20844 * recursion leaves.
20845 */
20846
20847 /* trivial cases */
20848 if (hi - lo < 1) {
20849 DUK_DDD(DUK_DDDPRINT("degenerate case, return immediately"));
20850 return;
20851 }
20852 DUK_ASSERT(hi > lo);
20853 DUK_ASSERT(hi - lo + 1 >= 2);
20854
20855 /* randomized pivot selection */
20856 p = lo + (duk_util_tinyrandom_get_bits(thr, 30) % (hi - lo + 1)); /* rnd in [lo,hi] */
20857 DUK_ASSERT(p >= lo && p <= hi);
20858 DUK_DDD(DUK_DDDPRINT("lo=%ld, hi=%ld, chose pivot p=%ld",
20859 (long) lo, (long) hi, (long) p));
20860
20861 /* move pivot out of the way */
20862 duk__array_sort_swap(ctx, p, lo);
20863 p = lo;
20864 DUK_DDD(DUK_DDDPRINT("pivot moved out of the way: %!T", (duk_tval *) duk_get_tval(ctx, 1)));
20865
20866 l = lo + 1;
20867 r = hi;
20868 for (;;) {
20869 /* find elements to swap */
20870 for (;;) {
20871 DUK_DDD(DUK_DDDPRINT("left scan: l=%ld, r=%ld, p=%ld",
20872 (long) l, (long) r, (long) p));
20873 if (l >= hi) {
20874 break;
20875 }
20876 if (duk__array_sort_compare(ctx, l, p) >= 0) { /* !(l < p) */
20877 break;
20878 }
20879 l++;
20880 }
20881 for (;;) {
20882 DUK_DDD(DUK_DDDPRINT("right scan: l=%ld, r=%ld, p=%ld",
20883 (long) l, (long) r, (long) p));
20884 if (r <= lo) {
20885 break;
20886 }
20887 if (duk__array_sort_compare(ctx, p, r) >= 0) { /* !(p < r) */
20888 break;
20889 }
20890 r--;
20891 }
20892 if (l >= r) {
20893 goto done;
20894 }
20895 DUK_ASSERT(l < r);
20896
20897 DUK_DDD(DUK_DDDPRINT("swap %ld and %ld", (long) l, (long) r));
20898
20899 duk__array_sort_swap(ctx, l, r);
20900
20901 DUK_DDD(DUK_DDDPRINT("after swap: %!T", (duk_tval *) duk_get_tval(ctx, 1)));
20902 l++;
20903 r--;
20904 }
20905 done:
20906 /* Note that 'l' and 'r' may cross, i.e. r < l */
20907 DUK_ASSERT(l >= lo && l <= hi);
20908 DUK_ASSERT(r >= lo && r <= hi);
20909
20910 /* XXX: there's no explicit recursion bound here now. For the average
DUK_LOCAL void duk__array_sort_swap(duk_context *ctx, duk_int_t l, duk_int_t r)
DUK_INTERNAL_DECL duk_uint32_t duk_util_tinyrandom_get_bits(duk_hthread *thr, duk_small_int_t n)
#define DUK_ASSERT_TOP(ctx, n)
DUK_LOCAL duk_small_int_t duk__array_sort_compare(duk_context *ctx, duk_int_t idx1, duk_int_t idx2)
DUK_LOCAL void duk__array_qsort(duk_context *ctx, duk_int_t lo, duk_int_t hi)

◆ duk__array_sort_compare()

DUK_LOCAL duk_small_int_t duk__array_sort_compare ( duk_context * ctx,
duk_int_t idx1,
duk_int_t idx2 )

Definition at line 20636 of file duktape-1.8.0/src/duktape.c.

20653 {
20654 duk_bool_t have1, have2;
20655 duk_bool_t undef1, undef2;
20656 duk_small_int_t ret;
20657 duk_idx_t idx_obj = 1; /* fixed offsets in valstack */
20658 duk_idx_t idx_fn = 0;
20659 duk_hstring *h1, *h2;
20660
20661 /* Fast exit if indices are identical. This is valid for a non-existent property,
20662 * for an undefined value, and almost always for ToString() coerced comparison of
20663 * arbitrary values (corner cases where this is not the case include e.g. a an
20664 * object with varying ToString() coercion).
20665 *
20666 * The specification does not prohibit "caching" of values read from the array, so
20667 * assuming equality for comparing an index with itself falls into the category of
20668 * "caching".
20669 *
20670 * Also, compareFn may be inconsistent, so skipping a call to compareFn here may
20671 * have an effect on the final result. The specification does not require any
20672 * specific behavior for inconsistent compare functions, so again, this fast path
20673 * is OK.
20674 */
20675
20676 if (idx1 == idx2) {
20677 DUK_DDD(DUK_DDDPRINT("duk__array_sort_compare: idx1=%ld, idx2=%ld -> indices identical, quick exit",
20678 (long) idx1, (long) idx2));
20679 return 0;
20680 }
20681
20682 have1 = duk_get_prop_index(ctx, idx_obj, (duk_uarridx_t) idx1);
20683 have2 = duk_get_prop_index(ctx, idx_obj, (duk_uarridx_t) idx2);
20684
20685 DUK_DDD(DUK_DDDPRINT("duk__array_sort_compare: idx1=%ld, idx2=%ld, have1=%ld, have2=%ld, val1=%!T, val2=%!T",
20686 (long) idx1, (long) idx2, (long) have1, (long) have2,
20687 (duk_tval *) duk_get_tval(ctx, -2), (duk_tval *) duk_get_tval(ctx, -1)));
20688
20689 if (have1) {
20690 if (have2) {
20691 ;
20692 } else {
20693 ret = -1;
20694 goto pop_ret;
20695 }
20696 } else {
20697 if (have2) {
20698 ret = 1;
20699 goto pop_ret;
20700 } else {
20701 ret = 0;
20702 goto pop_ret;
20703 }
20704 }
20705
20706 undef1 = duk_is_undefined(ctx, -2);
20707 undef2 = duk_is_undefined(ctx, -1);
20708 if (undef1) {
20709 if (undef2) {
20710 ret = 0;
20711 goto pop_ret;
20712 } else {
20713 ret = 1;
20714 goto pop_ret;
20715 }
20716 } else {
20717 if (undef2) {
20718 ret = -1;
20719 goto pop_ret;
20720 } else {
20721 ;
20722 }
20723 }
20724
20725 if (!duk_is_undefined(ctx, idx_fn)) {
20726 duk_double_t d;
20727
20728 /* no need to check callable; duk_call() will do that */
20729 duk_dup(ctx, idx_fn); /* -> [ ... x y fn ] */
20730 duk_insert(ctx, -3); /* -> [ ... fn x y ] */
20731 duk_call(ctx, 2); /* -> [ ... res ] */
20732
20733 /* The specification is a bit vague what to do if the return
20734 * value is not a number. Other implementations seem to
20735 * tolerate non-numbers but e.g. V8 won't apparently do a
20736 * ToNumber().
20737 */
20738
20739 /* XXX: best behavior for real world compatibility? */
20740
20741 d = duk_to_number(ctx, -1);
20742 if (d < 0.0) {
20743 ret = -1;
20744 } else if (d > 0.0) {
20745 ret = 1;
20746 } else {
20747 ret = 0;
20748 }
20749
20750 duk_pop(ctx);
20751 DUK_DDD(DUK_DDDPRINT("-> result %ld (from comparefn, after coercion)", (long) ret));
20752 return ret;
DUK_EXTERNAL duk_bool_t duk_is_undefined(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL duk_double_t duk_to_number(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL void duk_dup(duk_context *ctx, duk_idx_t from_index)
DUK_EXTERNAL void duk_insert(duk_context *ctx, duk_idx_t to_index)
DUK_EXTERNAL duk_bool_t duk_get_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index)
DUK_EXTERNAL void duk_call(duk_context *ctx, duk_idx_t nargs)
DUK_EXTERNAL void duk_pop(duk_context *ctx)

◆ duk__array_sort_swap()

DUK_LOCAL void duk__array_sort_swap ( duk_context * ctx,
duk_int_t l,
duk_int_t r )

Definition at line 20754 of file duktape-1.8.0/src/duktape.c.

20765 :
20766 duk_pop_2(ctx);
20767 DUK_DDD(DUK_DDDPRINT("-> result %ld", (long) ret));
20768 return ret;
20769}
20770
20772 duk_bool_t have_l, have_r;
20773 duk_idx_t idx_obj = 1; /* fixed offset in valstack */
20774
20775 if (l == r) {
20776 return;
20777 }
20778
20779 /* swap elements; deal with non-existent elements correctly */
20780 have_l = duk_get_prop_index(ctx, idx_obj, (duk_uarridx_t) l);
DUK_EXTERNAL void duk_pop_2(duk_context *ctx)

◆ duk__asin()

DUK_LOCAL double duk__asin ( double x)

Definition at line 32741 of file duktape-1.8.0/src/duktape.c.

32743 :
32744

◆ duk__atan()

DUK_LOCAL double duk__atan ( double x)

Definition at line 32744 of file duktape-1.8.0/src/duktape.c.

◆ duk__atan2()

DUK_LOCAL double duk__atan2 ( double x,
double y )

Definition at line 32771 of file duktape-1.8.0/src/duktape.c.

32773 {

◆ duk__base64_decode_helper()

DUK_LOCAL duk_bool_t duk__base64_decode_helper ( const duk_uint8_t * src,
duk_size_t srclen,
duk_uint8_t * dst,
duk_uint8_t ** out_dst_final )

Definition at line 13082 of file duktape-1.8.0/src/duktape.c.

13082 {
13083 y = x - 26 + 'a';
13084 } else if (x <= 61) {
13085 y = x - 52 + '0';
13086 } else if (x == 62) {
13087 y = '+';
13088 } else {
13089 y = '/';
13090 }
13091
13092 *dst++ = (duk_uint8_t) y;
13093 }
13094 }
13095}
13096#endif /* DUK_USE_BASE64_FASTPATH */
13097
13098#if defined(DUK_USE_BASE64_FASTPATH)
13099DUK_LOCAL duk_bool_t duk__base64_decode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst, duk_uint8_t **out_dst_final) {
13100 duk_int_t x;
13101 duk_int_t t;
13102 duk_small_uint_t n_equal;
13103 duk_small_uint_t n_chars;
13104 const duk_uint8_t *src_end;
13105 const duk_uint8_t *src_end_safe;
13106
13107 src_end = src + srclen;
13108 src_end_safe = src_end - 4; /* if 'src < src_end_safe', safe to read 4 bytes */
13109
13110 /* Innermost fast path processes 4 valid base-64 characters at a time
13111 * but bails out on whitespace, padding chars ('=') and invalid chars.
13112 * Once the slow path segment has been processed, we return to the
13113 * inner fast path again. This handles e.g. base64 with newlines
13114 * reasonably well because the majority of a line is in the fast path.
13115 */
13116 for (;;) {
13117 /* Fast path, handle units with just actual encoding characters. */
13118
13119 while (src <= src_end_safe) {
13120 /* The lookup byte is intentionally sign extended to (at least)
13121 * 32 bits and then ORed. This ensures that is at least 1 byte
13122 * is negative, the highest bit of 't' will be set at the end
13123 * and we don't need to check every byte.
13124 */
13125 DUK_DDD(DUK_DDDPRINT("fast loop: src=%p, src_end_safe=%p, src_end=%p",
13126 (const void *) src, (const void *) src_end_safe, (const void *) src_end));
13127
13128 t = (duk_int_t) duk_base64_dectab[*src++];
13129 t = (t << 6) | (duk_int_t) duk_base64_dectab[*src++];
13130 t = (t << 6) | (duk_int_t) duk_base64_dectab[*src++];
13131 t = (t << 6) | (duk_int_t) duk_base64_dectab[*src++];
13132
13133 if (DUK_UNLIKELY(t < 0)) {
13134 DUK_DDD(DUK_DDDPRINT("fast loop unit was not clean, process one slow path unit"));
13135 src -= 4;
13136 break;
13137 }
13138
13139 DUK_ASSERT(t <= 0xffffffL);
13140 DUK_ASSERT((t >> 24) == 0);
13141 *dst++ = (duk_uint8_t) (t >> 16);
13142 *dst++ = (duk_uint8_t) ((t >> 8) & 0xff);
13143 *dst++ = (duk_uint8_t) (t & 0xff);
13144 }
13145
13146 /* Handle one slow path unit (or finish if we're done). */
13147
13148 n_equal = 0;
13149 n_chars = 0;
13150 t = 0;
13151 for (;;) {
13152 DUK_DDD(DUK_DDDPRINT("slow loop: src=%p, src_end=%p, n_chars=%ld, n_equal=%ld, t=%ld",
13153 (const void *) src, (const void *) src_end, (long) n_chars, (long) n_equal, (long) t));
13154
13155 if (DUK_UNLIKELY(src >= src_end)) {
13156 goto done; /* two level break */
13157 }
13158
13159 x = duk_base64_dectab[*src++];
13160 if (DUK_UNLIKELY(x < 0)) {
13161 if (x == -2) {
13162 continue; /* allowed ascii whitespace */
13163 } else if (x == -3) {
13164 n_equal++;
13165 t <<= 6;
13166 } else {
13167 DUK_ASSERT(x == -1);
13168 goto error;
13169 }
13170 } else {
13171 DUK_ASSERT(x >= 0 && x <= 63);
13172 if (n_equal > 0) {
13173 /* Don't allow actual chars after equal sign. */
13174 goto error;
13175 }
13176 t = (t << 6) + x;
13177 }
13178
13179 if (DUK_UNLIKELY(n_chars == 3)) {
13180 /* Emit 3 bytes and backtrack if there was padding. There's
13181 * always space for the whole 3 bytes so no check needed.
13182 */
13183 DUK_ASSERT(t <= 0xffffffL);
13184 DUK_ASSERT((t >> 24) == 0);
13185 *dst++ = (duk_uint8_t) (t >> 16);
13186 *dst++ = (duk_uint8_t) ((t >> 8) & 0xff);
13187 *dst++ = (duk_uint8_t) (t & 0xff);
13188
13189 if (DUK_UNLIKELY(n_equal > 0)) {
13190 DUK_ASSERT(n_equal <= 4);
13191
13192 /* There may be whitespace between the equal signs. */
13193 if (n_equal == 1) {
13194 /* XXX= */
13195 dst -= 1;
13196 } else if (n_equal == 2) {
13197 /* XX== */
13198 dst -= 2;
13199 } else {
13200 goto error; /* invalid padding */
13201 }
13202
13203 /* Continue parsing after padding, allows concatenated,
13204 * padded base64.
13205 */
13206 }
13207 break; /* back to fast loop */
13208 } else {
13209 n_chars++;
13210 }
13211 }
13212 }
13213 done:
13214 DUK_DDD(DUK_DDDPRINT("done; src=%p, src_end=%p, n_chars=%ld",
13215 (const void *) src, (const void *) src_end, (long) n_chars));
DUK_LOCAL duk_bool_t duk__base64_decode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst, duk_uint8_t **out_dst_final)
DUK_INTERNAL const duk_int8_t duk_base64_dectab[256]

◆ duk__base64_encode_helper()

DUK_LOCAL void duk__base64_encode_helper ( const duk_uint8_t * src,
duk_size_t srclen,
duk_uint8_t * dst )

Definition at line 12968 of file duktape-1.8.0/src/duktape.c.

12975 {
12976 DUK_ASSERT(duk_is_valid_index(ctx, index)); /* checked by caller */
12977 if (duk_is_buffer(ctx, index)) {
12978 return (const duk_uint8_t *) duk_get_buffer(ctx, index, out_len);
12979 } else {
12980 return (const duk_uint8_t *) duk_to_lstring(ctx, index, out_len);
12981 }
12982}
12983
12984#if defined(DUK_USE_BASE64_FASTPATH)
12985DUK_LOCAL void duk__base64_encode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst) {
12986 duk_uint_t t;
12987 duk_size_t n_full, n_full3, n_final;
12988 const duk_uint8_t *src_end_fast;
12989
12990 n_full = srclen / 3; /* full 3-byte -> 4-char conversions */
12991 n_full3 = n_full * 3;
12992 n_final = srclen - n_full3;
12993 DUK_ASSERT_DISABLE(n_final >= 0);
12994 DUK_ASSERT(n_final <= 2);
12995
12996 src_end_fast = src + n_full3;
12997 while (DUK_UNLIKELY(src != src_end_fast)) {
12998 t = (duk_uint_t) (*src++);
12999 t = (t << 8) + (duk_uint_t) (*src++);
13000 t = (t << 8) + (duk_uint_t) (*src++);
13001
13002 *dst++ = duk_base64_enctab[t >> 18];
13003 *dst++ = duk_base64_enctab[(t >> 12) & 0x3f];
13004 *dst++ = duk_base64_enctab[(t >> 6) & 0x3f];
13005 *dst++ = duk_base64_enctab[t & 0x3f];
13006
13007#if 0 /* Tested: not faster on x64 */
13008 /* aaaaaabb bbbbcccc ccdddddd */
13009 dst[0] = duk_base64_enctab[(src[0] >> 2) & 0x3f];
13010 dst[1] = duk_base64_enctab[((src[0] << 4) & 0x30) | ((src[1] >> 4) & 0x0f)];
13011 dst[2] = duk_base64_enctab[((src[1] << 2) & 0x3f) | ((src[2] >> 6) & 0x03)];
13012 dst[3] = duk_base64_enctab[src[2] & 0x3f];
13013 src += 3; dst += 4;
13014#endif
13015 }
13016
13017 switch (n_final) {
13018 /* case 0: nop */
13019 case 1: {
13020 /* XX== */
13021 t = (duk_uint_t) (*src++);
13022 *dst++ = duk_base64_enctab[t >> 2]; /* XXXXXX-- */
DUK_EXTERNAL duk_bool_t duk_is_valid_index(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL void * duk_get_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size)
DUK_EXTERNAL const char * duk_to_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
DUK_INTERNAL const duk_uint8_t duk_base64_enctab[64]
DUK_EXTERNAL duk_bool_t duk_is_buffer(duk_context *ctx, duk_idx_t index)
DUK_LOCAL void duk__base64_encode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst)

References DUK_ASSERT, duk_get_buffer(), duk_is_buffer(), duk_is_valid_index(), duk_to_lstring(), and index.

◆ duk__bc_get_i32()

DUK_LOCAL duk_int32_t duk__bc_get_i32 ( duk_re_matcher_ctx * re_ctx,
const duk_uint8_t ** pc )

Definition at line 78758 of file duktape-1.8.0/src/duktape.c.

◆ duk__bc_get_u32()

DUK_LOCAL duk_uint32_t duk__bc_get_u32 ( duk_re_matcher_ctx * re_ctx,
const duk_uint8_t ** pc )

Definition at line 78754 of file duktape-1.8.0/src/duktape.c.

◆ duk__bi_add()

DUK_LOCAL void duk__bi_add ( duk__bigint * x,
duk__bigint * y,
duk__bigint * z )

Definition at line 75615 of file duktape-1.8.0/src/duktape.c.

75615 {
75616 tmp += z->v[i];
75617 }
75618 x->v[i] = (duk_uint32_t) (tmp & 0xffffffffUL);
75619 tmp = tmp >> 32;
75620 }
75621 if (tmp != 0U) {
75623 x->v[i++] = (duk_uint32_t) tmp;
75624 }
75625 x->n = i;
75627
75628 /* no need to normalize */
75629 DUK_ASSERT(duk__bi_is_valid(x));
75630}
75631#else /* DUK_USE_64BIT_OPS */
75633 duk_uint32_t carry, tmp1, tmp2;
75634 duk_small_int_t i, ny, nz;
75635
75636 DUK_ASSERT(duk__bi_is_valid(y));
75637 DUK_ASSERT(duk__bi_is_valid(z));
75638
75639 if (z->n > y->n) {
75640 duk__bigint *t;
75641 t = y; y = z; z = t;
75642 }
75643 DUK_ASSERT(y->n >= z->n);
75644
75645 ny = y->n; nz = z->n;
75646 carry = 0U;
75647 for (i = 0; i < ny; i++) {
75648 /* Carry is detected based on wrapping which relies on exact 32-bit
75649 * types.
75650 */
75652 tmp1 = y->v[i];
75653 tmp2 = tmp1;
75654 if (i < nz) {
75655 tmp2 += z->v[i];
75656 }
75657
75658 /* Careful with carry condition:
75659 * - If carry not added: 0x12345678 + 0 + 0xffffffff = 0x12345677 (< 0x12345678)
75660 * - If carry added: 0x12345678 + 1 + 0xffffffff = 0x12345678 (== 0x12345678)
75661 */
75662 if (carry) {
75663 tmp2++;
75664 carry = (tmp2 <= tmp1 ? 1U : 0U);
#define DUK__BI_MAX_PARTS
DUK_LOCAL void duk__bi_add(duk__bigint *x, duk__bigint *y, duk__bigint *z)
duk_uint32_t v[DUK__BI_MAX_PARTS]

References duk__bigint::v.

◆ duk__bi_add_small()

DUK_LOCAL void duk__bi_add_small ( duk__bigint * x,
duk__bigint * y,
duk_uint32_t z )

Definition at line 75668 of file duktape-1.8.0/src/duktape.c.

75671 {
75673 DUK_ASSERT(carry == 1U);
75674 x->v[i++] = carry;
75675 }
75676 x->n = i;
75678

◆ duk__bi_compare()

DUK_LOCAL int duk__bi_compare ( duk__bigint * x,
duk__bigint * y )

Definition at line 75542 of file duktape-1.8.0/src/duktape.c.

75545 {
75546 if (v == 0U) {
75547 x->n = 0;
75548 } else {
75549 x->n = 1;
75550 x->v[0] = v;
75551 }
75552 DUK_ASSERT(duk__bi_is_valid(x));
75553}
75554
75555/* Return value: <0 <=> x < y
75556 * 0 <=> x == y
75557 * >0 <=> x > y
75558 */
75560 duk_small_int_t i, nx, ny;
75561 duk_uint32_t tx, ty;
75562
75563 DUK_ASSERT(duk__bi_is_valid(x));
75564 DUK_ASSERT(duk__bi_is_valid(y));
75565
75566 nx = x->n;
75567 ny = y->n;
75568 if (nx > ny) {
75569 goto ret_gt;
75570 }
75571 if (nx < ny) {
75572 goto ret_lt;
75573 }
75574 for (i = nx - 1; i >= 0; i--) {
75575 tx = x->v[i];
75576 ty = y->v[i];
DUK_LOCAL int duk__bi_compare(duk__bigint *x, duk__bigint *y)

◆ duk__bi_copy()

DUK_LOCAL void duk__bi_copy ( duk__bigint * x,
duk__bigint * y )

Definition at line 75517 of file duktape-1.8.0/src/duktape.c.

75519 {
75521
75522 for (i = x->n - 1; i >= 0; i--) {
75523 if (x->v[i] != 0) {
75524 break;
75525 }
75526 }

References duk__bigint::n, and duk__bigint::v.

Referenced by duk__bi_is_zero().

◆ duk__bi_exp_small()

DUK_LOCAL void duk__bi_exp_small ( duk__bigint * x,
duk_small_int_t b,
duk_small_int_t y,
duk__bigint * t1,
duk__bigint * t2 )

Definition at line 75957 of file duktape-1.8.0/src/duktape.c.

75962 {
75963 duk_small_int_t n, r;
75964
75965 n = (y / 32) + 1;
75966 DUK_ASSERT(n > 0);
75967 r = y % 32;
75968 DUK_MEMZERO((void *) x->v, sizeof(duk_uint32_t) * n);
75969 x->n = n;
75970 x->v[n - 1] = (((duk_uint32_t) 1) << r);
75971}
75972
75973/* x <- b^y; use t1 and t2 as temps */
75975 /* Fast path the binary case */
75976
75977 DUK_ASSERT(x != t1 && x != t2 && t1 != t2); /* distinct bignums, easy mistake to make */
75978 DUK_ASSERT(b >= 0);
75979 DUK_ASSERT(y >= 0);
75980
75981 if (b == 2) {
75982 duk__bi_twoexp(x, y);
75983 return;
75984 }
75985
75986 /* http://en.wikipedia.org/wiki/Exponentiation_by_squaring */
75987
75988 DUK_DDD(DUK_DDDPRINT("exp_small: b=%ld, y=%ld", (long) b, (long) y));
75989
75990 duk__bi_set_small(x, 1);
75991 duk__bi_set_small(t1, b);
DUK_LOCAL void duk__bi_set_small(duk__bigint *x, duk_uint32_t v)
DUK_LOCAL void duk__bi_exp_small(duk__bigint *x, duk_small_int_t b, duk_small_int_t y, duk__bigint *t1, duk__bigint *t2)
DUK_LOCAL void duk__bi_twoexp(duk__bigint *x, duk_small_int_t y)

◆ duk__bi_global_resolve_module_id()

DUK_LOCAL void duk__bi_global_resolve_module_id ( duk_context * ctx,
const char * req_id,
const char * mod_id )

Definition at line 28644 of file duktape-1.8.0/src/duktape.c.

28645 {
28646 DUK_UNREF(ctx);
28647 return 0;
28648}
28649#else /* print provider */
28651 DUK_UNREF(ctx);
28653}
28654#endif /* print provider */
28655
28656/*
28657 * CommonJS require() and modules support
28658 */
28659
28660#if defined(DUK_USE_COMMONJS_MODULES)
28661DUK_LOCAL void duk__bi_global_resolve_module_id(duk_context *ctx, const char *req_id, const char *mod_id) {
28662 duk_hthread *thr = (duk_hthread *) ctx;
28663 duk_uint8_t buf[DUK_BI_COMMONJS_MODULE_ID_LIMIT];
28664 duk_uint8_t *p;
28665 duk_uint8_t *q;
28666 duk_uint8_t *q_last; /* last component */
28667 duk_int_t int_rc;
28668
28669 DUK_ASSERT(req_id != NULL);
28670 /* mod_id may be NULL */
28671
28672 /*
28673 * A few notes on the algorithm:
28674 *
28675 * - Terms are not allowed to begin with a period unless the term
28676 * is either '.' or '..'. This simplifies implementation (and
28677 * is within CommonJS modules specification).
28678 *
28679 * - There are few output bound checks here. This is on purpose:
28680 * the resolution input is length checked and the output is never
28681 * longer than the input. The resolved output is written directly
28682 * over the input because it's never longer than the input at any
28683 * point in the algorithm.
28684 *
28685 * - Non-ASCII characters are processed as individual bytes and
28686 * need no special treatment. However, U+0000 terminates the
28687 * algorithm; this is not an issue because U+0000 is not a
28688 * desirable term character anyway.
28689 */
28690
28691 /*
28692 * Set up the resolution input which is the requested ID directly
28693 * (if absolute or no current module path) or with current module
28694 * ID prepended (if relative and current module path exists).
28695 *
28696 * Suppose current module is 'foo/bar' and relative path is './quux'.
28697 * The 'bar' component must be replaced so the initial input here is
28698 * 'foo/bar/.././quux'.
28699 */
28700
28701 if (mod_id != NULL && req_id[0] == '.') {
28702 int_rc = DUK_SNPRINTF((char *) buf, sizeof(buf), "%s/../%s", mod_id, req_id);
28703 } else {
28704 int_rc = DUK_SNPRINTF((char *) buf, sizeof(buf), "%s", req_id);
28705 }
28706 if (int_rc >= (duk_int_t) sizeof(buf) || int_rc < 0) {
28707 /* Potentially truncated, NUL not guaranteed in any case.
28708 * The (int_rc < 0) case should not occur in practice.
28709 */
28710 DUK_DD(DUK_DDPRINT("resolve error: temporary working module ID doesn't fit into resolve buffer"));
28711 goto resolve_error;
28712 }
28713 DUK_ASSERT(DUK_STRLEN((const char *) buf) < sizeof(buf)); /* at most sizeof(buf) - 1 */
28714
28715 DUK_DDD(DUK_DDDPRINT("input module id: '%s'", (const char *) buf));
28716
28717 /*
28718 * Resolution loop. At the top of the loop we're expecting a valid
28719 * term: '.', '..', or a non-empty identifier not starting with a period.
28720 */
28721
28722 p = buf;
28723 q = buf;
28724 for (;;) {
28726
28727 /* Here 'p' always points to the start of a term.
28728 *
28729 * We can also unconditionally reset q_last here: if this is
28730 * the last (non-empty) term q_last will have the right value
28731 * on loop exit.
28732 */
28733
28734 DUK_ASSERT(p >= q); /* output is never longer than input during resolution */
28735
28736 DUK_DDD(DUK_DDDPRINT("resolve loop top: p -> '%s', q=%p, buf=%p",
28737 (const char *) p, (void *) q, (void *) buf));
28738
28739 q_last = q;
28740
28741 c = *p++;
28742 if (DUK_UNLIKELY(c == 0)) {
28743 DUK_DD(DUK_DDPRINT("resolve error: requested ID must end with a non-empty term"));
28744 goto resolve_error;
28745 } else if (DUK_UNLIKELY(c == '.')) {
28746 c = *p++;
28747 if (c == '/') {
28748 /* Term was '.' and is eaten entirely (including dup slashes). */
28749 goto eat_dup_slashes;
28750 }
28751 if (c == '.' && *p == '/') {
28752 /* Term was '..', backtrack resolved name by one component.
28753 * q[-1] = previous slash (or beyond start of buffer)
28754 * q[-2] = last char of previous component (or beyond start of buffer)
28755 */
28756 p++; /* eat (first) input slash */
28757 DUK_ASSERT(q >= buf);
28758 if (q == buf) {
28759 DUK_DD(DUK_DDPRINT("resolve error: term was '..' but nothing to backtrack"));
28760 goto resolve_error;
28761 }
28762 DUK_ASSERT(*(q - 1) == '/');
28763 q--; /* backtrack to last output slash (dups already eliminated) */
28764 for (;;) {
28765 /* Backtrack to previous slash or start of buffer. */
28766 DUK_ASSERT(q >= buf);
28767 if (q == buf) {
28768 break;
28769 }
28770 if (*(q - 1) == '/') {
28771 break;
28772 }
28773 q--;
28774 }
28775 goto eat_dup_slashes;
28776 }
28777 DUK_DD(DUK_DDPRINT("resolve error: term begins with '.' but is not '.' or '..' (not allowed now)"));
28778 goto resolve_error;
28779 } else if (DUK_UNLIKELY(c == '/')) {
28780 /* e.g. require('/foo'), empty terms not allowed */
28781 DUK_DD(DUK_DDPRINT("resolve error: empty term (not allowed now)"));
28782 goto resolve_error;
28783 } else {
28784 for (;;) {
28785 /* Copy term name until end or '/'. */
28786 *q++ = c;
28787 c = *p++;
28788 if (DUK_UNLIKELY(c == 0)) {
28789 /* This was the last term, and q_last was
28790 * updated to match this term at loop top.
28791 */
28792 goto loop_done;
28793 } else if (DUK_UNLIKELY(c == '/')) {
28794 *q++ = '/';
28795 break;
28796 } else {
28797 /* write on next loop */
28798 }
28799 }
28800 }
28801
28802 eat_dup_slashes:
28803 for (;;) {
28804 /* eat dup slashes */
28805 c = *p;
28806 if (DUK_LIKELY(c != '/')) {
28807 break;
28808 }
28809 p++;
28810 }
28811 }
duk_uint8_t duk_uint_fast8_t
#define DUK_RET_UNSUPPORTED_ERROR
#define DUK_BI_COMMONJS_MODULE_ID_LIMIT
DUK_LOCAL void duk__bi_global_resolve_module_id(duk_context *ctx, const char *req_id, const char *mod_id)
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_print_helper(duk_context *ctx)

References DUK_UNREF.

◆ duk__bi_is_2to52()

DUK_LOCAL duk_small_int_t duk__bi_is_2to52 ( duk__bigint * x)

Definition at line 75938 of file duktape-1.8.0/src/duktape.c.

75939 {
75940 DUK_ASSERT(duk__bi_is_valid(x));
75941 return (x->n == 0) || ((x->v[0] & 0x01) == 0);
75942}

References DUK_ASSERT, duk__bigint::n, and duk__bigint::v.

◆ duk__bi_is_even()

DUK_LOCAL int duk__bi_is_even ( duk__bigint * x)

Definition at line 75922 of file duktape-1.8.0/src/duktape.c.

◆ duk__bi_is_zero()

DUK_LOCAL int duk__bi_is_zero ( duk__bigint * x)

Definition at line 75927 of file duktape-1.8.0/src/duktape.c.

75928 {
75929 duk__bi_mul(t, x, y);
75930 duk__bi_copy(x, t);
DUK_LOCAL void duk__bi_mul(duk__bigint *x, duk__bigint *y, duk__bigint *z)
DUK_LOCAL void duk__bi_copy(duk__bigint *x, duk__bigint *y)

References duk__bi_copy(), and duk__bi_mul().

◆ duk__bi_mul()

DUK_LOCAL void duk__bi_mul ( duk__bigint * x,
duk__bigint * y,
duk__bigint * z )

Definition at line 75784 of file duktape-1.8.0/src/duktape.c.

75795 {
75796 duk__bi_sub(t, x, y);
75797 duk__bi_copy(x, t);
75798}
75799
75800/* x <- y * z */
75802 duk_small_int_t i, j, nx, nz;
75803
75804 DUK_ASSERT(duk__bi_is_valid(y));
75805 DUK_ASSERT(duk__bi_is_valid(z));
75806
75807 nx = y->n + z->n; /* max possible */
75809
75810 if (nx == 0) {
75811 /* Both inputs are zero; cases where only one is zero can go
75812 * through main algorithm.
75813 */
75814 x->n = 0;
75815 return;
75816 }
75817
75818 DUK_MEMZERO((void *) x->v, (size_t) (sizeof(duk_uint32_t) * nx));
75819 x->n = nx;
75820
75821 nz = z->n;
75822 for (i = 0; i < y->n; i++) {
75823#ifdef DUK_USE_64BIT_OPS
75824 duk_uint64_t tmp = 0U;
75825 for (j = 0; j < nz; j++) {
75826 tmp += (duk_uint64_t) y->v[i] * (duk_uint64_t) z->v[j] + x->v[i+j];
75827 x->v[i+j] = (duk_uint32_t) (tmp & 0xffffffffUL);
75828 tmp = tmp >> 32;
75829 }
75830 if (tmp > 0) {
75831 DUK_ASSERT(i + j < nx);
75833 DUK_ASSERT(x->v[i+j] == 0U);
75834 x->v[i+j] = (duk_uint32_t) tmp;
75835 }
75836#else
75837 /*
75838 * Multiply + add + carry for 32-bit components using only 16x16->32
75839 * multiplies and carry detection based on unsigned overflow.
75840 *
75841 * 1st mult, 32-bit: (A*2^16 + B)
75842 * 2nd mult, 32-bit: (C*2^16 + D)
75843 * 3rd add, 32-bit: E
75844 * 4th add, 32-bit: F
75845 *
75846 * (AC*2^16 + B) * (C*2^16 + D) + E + F
75847 * = AC*2^32 + AD*2^16 + BC*2^16 + BD + E + F
75848 * = AC*2^32 + (AD + BC)*2^16 + (BD + E + F)
75849 * = AC*2^32 + AD*2^16 + BC*2^16 + (BD + E + F)
75850 */
75851 duk_uint32_t a, b, c, d, e, f;
75852 duk_uint32_t r, s, t;
75853
75854 a = y->v[i]; b = a & 0xffffUL; a = a >> 16;
75855
75856 f = 0;
75857 for (j = 0; j < nz; j++) {
75858 c = z->v[j]; d = c & 0xffffUL; c = c >> 16;
75859 e = x->v[i+j];
75860
75861 /* build result as: (r << 32) + s: start with (BD + E + F) */
75862 r = 0;
75863 s = b * d;
75864
75865 /* add E */
75866 t = s + e;
75867 if (t < s) { r++; } /* carry */
75868 s = t;
75869
75870 /* add F */
75871 t = s + f;
75872 if (t < s) { r++; } /* carry */
75873 s = t;
75874
75875 /* add BC*2^16 */
75876 t = b * c;
75877 r += (t >> 16);
75878 t = s + ((t & 0xffffUL) << 16);
75879 if (t < s) { r++; } /* carry */
75880 s = t;
75881
75882 /* add AD*2^16 */
75883 t = a * d;
75884 r += (t >> 16);
75885 t = s + ((t & 0xffffUL) << 16);
75886 if (t < s) { r++; } /* carry */
75887 s = t;
75888
75889 /* add AC*2^32 */
75890 t = a * c;
75891 r += t;
75892
75893 DUK_DDD(DUK_DDDPRINT("ab=%08lx cd=%08lx ef=%08lx -> rs=%08lx %08lx",
75894 (unsigned long) y->v[i], (unsigned long) z->v[j],
75895 (unsigned long) x->v[i+j], (unsigned long) r,
DUK_LOCAL void duk__bi_sub(duk__bigint *x, duk__bigint *y, duk__bigint *z)
CURL_EXTERN CURLMcode curl_socket_t s
Definition multi.h:318

Referenced by duk__bi_is_zero().

◆ duk__bi_mul_copy()

DUK_LOCAL void duk__bi_mul_copy ( duk__bigint * x,
duk__bigint * y,
duk__bigint * t )

Definition at line 75911 of file duktape-1.8.0/src/duktape.c.

◆ duk__bi_mul_small()

DUK_LOCAL void duk__bi_mul_small ( duk__bigint * x,
duk__bigint * y,
duk_uint32_t z )

Definition at line 75898 of file duktape-1.8.0/src/duktape.c.

75901 {
75902 DUK_ASSERT(i + j < nx);
75904 DUK_ASSERT(x->v[i+j] == 0U);
75905 x->v[i+j] = (duk_uint32_t) f;
75906 }
75907#endif /* DUK_USE_64BIT_OPS */
75908 }

◆ duk__bi_mul_small_copy()

DUK_LOCAL void duk__bi_mul_small_copy ( duk__bigint * x,
duk_uint32_t y,
duk__bigint * t )

Definition at line 75917 of file duktape-1.8.0/src/duktape.c.

◆ duk__bi_normalize()

DUK_LOCAL void duk__bi_normalize ( duk__bigint * x)

Definition at line 75502 of file duktape-1.8.0/src/duktape.c.

75503 {
75504 p += DUK_SPRINTF(p, " %08lx", (unsigned long) x->v[i]);
75505 }
75506
75507 DUK_DDD(DUK_DDDPRINT("%s: %s", (const char *) name, (const char *) buf));
75508}
75509#endif
75510
75511#ifdef DUK_USE_ASSERTIONS
75512DUK_LOCAL duk_small_int_t duk__bi_is_valid(duk__bigint *x) {
75513 return (duk_small_int_t)
75514 ( ((x->n >= 0) && (x->n <= DUK__BI_MAX_PARTS)) /* is valid size */ &&
const char * name
Definition lsqlite3.c:2154

Referenced by duk__dragon4_ctx_to_double().

◆ duk__bi_set_small()

DUK_LOCAL void duk__bi_set_small ( duk__bigint * x,
duk_uint32_t v )

Definition at line 75528 of file duktape-1.8.0/src/duktape.c.

75534 {
75536

◆ duk__bi_sub()

DUK_LOCAL void duk__bi_sub ( duk__bigint * x,
duk__bigint * y,
duk__bigint * z )

Definition at line 75720 of file duktape-1.8.0/src/duktape.c.

75721 {
75722 tz = z->v[i];
75723 } else {
75724 tz = 0;
75725 }
75726 tmp = (duk_int64_t) ty - (duk_int64_t) tz + tmp;
75727 x->v[i] = (duk_uint32_t) (tmp & 0xffffffffUL);
75728 tmp = tmp >> 32; /* 0 or -1 */
75729 }
75730 DUK_ASSERT(tmp == 0);
75731
75732 x->n = i;
75733 duk__bi_normalize(x); /* need to normalize, may even cancel to 0 */
75734 DUK_ASSERT(duk__bi_is_valid(x));
75735}
75736#else
75738 duk_small_int_t i, ny, nz;
75739 duk_uint32_t tmp1, tmp2, borrow;
75740
75741 DUK_ASSERT(duk__bi_is_valid(y));
75742 DUK_ASSERT(duk__bi_is_valid(z));
75743 DUK_ASSERT(duk__bi_compare(y, z) >= 0);
75744 DUK_ASSERT(y->n >= z->n);
75745
75746 ny = y->n; nz = z->n;
75747 borrow = 0U;
75748 for (i = 0; i < ny; i++) {
75749 /* Borrow is detected based on wrapping which relies on exact 32-bit
75750 * types.
75751 */
75752 tmp1 = y->v[i];
75753 tmp2 = tmp1;
75754 if (i < nz) {
75755 tmp2 -= z->v[i];
75756 }
75757
75758 /* Careful with borrow condition:
75759 * - If borrow not subtracted: 0x12345678 - 0 - 0xffffffff = 0x12345679 (> 0x12345678)
DUK_LOCAL void duk__bi_normalize(duk__bigint *x)

References duk__bigint::v.

◆ duk__bi_sub_copy()

DUK_LOCAL void duk__bi_sub_copy ( duk__bigint * x,
duk__bigint * y,
duk__bigint * t )

Definition at line 75778 of file duktape-1.8.0/src/duktape.c.

75781 {

◆ duk__bi_twoexp()

DUK_LOCAL void duk__bi_twoexp ( duk__bigint * x,
duk_small_int_t y )

Definition at line 75945 of file duktape-1.8.0/src/duktape.c.

◆ duk__bw_update_ptrs()

DUK_LOCAL void duk__bw_update_ptrs ( duk_hthread * thr,
duk_bufwriter_ctx * bw_ctx,
duk_size_t curr_offset,
duk_size_t new_length )

Definition at line 86494 of file duktape-1.8.0/src/duktape.c.

86495 {
86496 duk_be_encode(ctx, 0, npad);
86497 }
86498 DUK_ASSERT(ctx->currbits == 0);
86499}
86500#line 1 "duk_util_bufwriter.c"
86501/*
86502 * Fast buffer writer with spare management.
86503 */
86504
86505/* include removed: duk_internal.h */
86506
DUK_INTERNAL_DECL void duk_be_encode(duk_bitencoder_ctx *ctx, duk_uint32_t data, duk_small_int_t bits)

References duk_be_encode().

◆ duk__call_prop_prep_stack()

DUK_LOCAL void duk__call_prop_prep_stack ( duk_context * ctx,
duk_idx_t normalized_obj_index,
duk_idx_t nargs )

Definition at line 12388 of file duktape-1.8.0/src/duktape.c.

12388 {
12390}
12391
12392#endif /* DUK_USE_BYTECODE_DUMP_SUPPORT */
12393#line 1 "duk_api_call.c"
12394/*
12395 * Calls.
12396 *
12397 * Protected variants should avoid ever throwing an error.
12398 */
12399
12400/* include removed: duk_internal.h */
12401
12402/* Prepare value stack for a method call through an object property.
12403 * May currently throw an error e.g. when getting the property.
12404 */
12405DUK_LOCAL void duk__call_prop_prep_stack(duk_context *ctx, duk_idx_t normalized_obj_index, duk_idx_t nargs) {
12407
12408 DUK_DDD(DUK_DDDPRINT("duk__call_prop_prep_stack, normalized_obj_index=%ld, nargs=%ld, stacktop=%ld",
12409 (long) normalized_obj_index, (long) nargs, (long) duk_get_top(ctx)));
12410
12411 /* [... key arg1 ... argN] */
12412
#define DUK_ERROR_UNSUPPORTED_DEFMSG(thr)
#define DUK_ASSERT_CTX_VALID(ctx)
DUK_LOCAL void duk__call_prop_prep_stack(duk_context *ctx, duk_idx_t normalized_obj_index, duk_idx_t nargs)

References DUK_ERROR_UNSUPPORTED_DEFMSG.

◆ duk__case_transform_helper()

DUK_LOCAL duk_codepoint_t duk__case_transform_helper ( duk_hthread * thr,
duk_bufwriter_ctx * bw,
duk_codepoint_t cp,
duk_codepoint_t prev,
duk_codepoint_t next,
duk_bool_t uppercase )

Definition at line 10845 of file duktape-1.8.0/src/duktape.c.

10845 {
10847 }
10848 return cp;
10849}
10850
10851/*
10852 * Case conversion helper, with context/local sensitivity.
10853 * For proper case conversion, one needs to know the character
10854 * and the preceding and following characters, as well as
10855 * locale/language.
10856 */
10857
10858/* XXX: add 'language' argument when locale/language sensitive rule
10859 * support added.
10860 */
10864 duk_codepoint_t cp,
10865 duk_codepoint_t prev,
10867 duk_bool_t uppercase) {
10868 duk_bitdecoder_ctx bd_ctx;
10869
10870 /* fast path for ASCII */
10871 if (cp < 0x80L) {
10872 /* XXX: there are language sensitive rules for the ASCII range.
10873 * If/when language/locale support is implemented, they need to
10874 * be implemented here for the fast path. There are no context
10875 * sensitive rules for ASCII range.
10876 */
10877
10878 if (uppercase) {
10879 if (cp >= 'a' && cp <= 'z') {
10880 cp = cp - 'a' + 'A';
10881 }
10882 } else {
10883 if (cp >= 'A' && cp <= 'Z') {
10884 cp = cp - 'A' + 'a';
10885 }
10886 }
10887
10888 if (bw != NULL) {
10889 DUK_BW_WRITE_RAW_U8(thr, bw, (duk_uint8_t) cp);
10890 }
10891 return cp;
10892 }
10893
10894 /* context and locale specific rules which cannot currently be represented
10895 * in the caseconv bitstream: hardcoded rules in C
10896 */
10897 if (uppercase) {
10898 /* XXX: turkish / azeri */
10899 } else {
10900 /*
10901 * Final sigma context specific rule. This is a rather tricky
10902 * rule and this handling is probably not 100% correct now.
10903 * The rule is not locale/language specific so it is supported.
10904 */
10905
10906 if (cp == 0x03a3L && /* U+03A3 = GREEK CAPITAL LETTER SIGMA */
10907 duk_unicode_is_letter(prev) && /* prev exists and is not a letter */
10908 !duk_unicode_is_letter(next)) { /* next does not exist or next is not a letter */
10909 /* Capital sigma occurred at "end of word", lowercase to
10910 * U+03C2 = GREEK SMALL LETTER FINAL SIGMA. Otherwise
10911 * fall through and let the normal rules lowercase it to
10912 * U+03C3 = GREEK SMALL LETTER SIGMA.
10913 */
10914 cp = 0x03c2L;
10915 goto singlechar;
10916 }
10917
10918 /* XXX: lithuanian not implemented */
10919 /* XXX: lithuanian, explicit dot rules */
10920 /* XXX: turkish / azeri, lowercase rules */
10921 }
10922
10923 /* 1:1 or special conversions, but not locale/context specific: script generated rules */
10924 DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx));
10925 if (uppercase) {
10926 bd_ctx.data = (const duk_uint8_t *) duk_unicode_caseconv_uc;
10927 bd_ctx.length = (duk_size_t) sizeof(duk_unicode_caseconv_uc);
10928 } else {
const duk_uint8_t duk_unicode_caseconv_uc[1288]
#define DUK_BW_WRITE_RAW_U8(thr, bw_ctx, val)
DUK_LOCAL duk_codepoint_t duk__case_transform_helper(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_codepoint_t cp, duk_codepoint_t prev, duk_codepoint_t next, duk_bool_t uppercase)
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_letter(duk_codepoint_t cp)
#define DUK_BW_WRITE_RAW_XUTF8(thr, bw_ctx, cp)
#define next(ls)

References DUK_BW_WRITE_RAW_XUTF8.

◆ duk__ceil()

DUK_LOCAL double duk__ceil ( double x)

Definition at line 32747 of file duktape-1.8.0/src/duktape.c.

◆ duk__check_arguments_map_for_delete()

DUK_LOCAL_DECL void duk__check_arguments_map_for_delete ( duk_hthread * thr,
duk_hobject * obj,
duk_hstring * key,
duk_propdesc * temp_desc )

Definition at line 48945 of file duktape-1.8.0/src/duktape.c.

48962 {
48963 duk_context *ctx = (duk_context *) thr;
48964 duk_hobject *map;
48965
48967
#define DUK_GETDESC_FLAG_PUSH_VALUE
#define DUK_ASSERT_VALSTACK_SPACE(thr, n)
DUK_INTERNAL_DECL duk_bool_t duk_hobject_get_own_propdesc(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *out_desc, duk_small_uint_t flags)
#define DUK_HTHREAD_STRING_INT_MAP(thr)
#define DUK__VALSTACK_SPACE

◆ duk__check_arguments_map_for_get()

DUK_LOCAL_DECL duk_bool_t duk__check_arguments_map_for_get ( duk_hthread * thr,
duk_hobject * obj,
duk_hstring * key,
duk_propdesc * temp_desc )

Definition at line 48863 of file duktape-1.8.0/src/duktape.c.

48868 : %!dO", (duk_heaphdr *) varenv));
48869
48870 /* success: leave varname in stack */
48871 *out_map = map;
48872 *out_varenv = varenv;
48873 return 1; /* [... varname] */
48874}
48875
48876/* Lookup 'key' from arguments internal 'map', and leave replacement value
48877 * on stack top if mapped (and return non-zero).
48878 * Used in E5 Section 10.6 algorithm for [[GetOwnProperty]] (used by [[Get]]).
48879 */
48880DUK_LOCAL duk_bool_t duk__check_arguments_map_for_get(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *temp_desc) {
48881 duk_context *ctx = (duk_context *) thr;
48882 duk_hobject *map;
48883 duk_hobject *varenv;
48884 duk_hstring *varname;
48885
48886 DUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);
48887
48888 if (!duk__lookup_arguments_map(thr, obj, key, temp_desc, &map, &varenv)) {
48889 DUK_DDD(DUK_DDDPRINT("arguments: key not mapped, no exotic get behavior"));
48890 return 0;
48891 }
48892
48893 /* [... varname] */
48894
48895 varname = duk_require_hstring(ctx, -1);

◆ duk__check_arguments_map_for_put()

DUK_LOCAL_DECL void duk__check_arguments_map_for_put ( duk_hthread * thr,
duk_hobject * obj,
duk_hstring * key,
duk_propdesc * temp_desc,
duk_bool_t throw_flag )

Definition at line 48901 of file duktape-1.8.0/src/duktape.c.

48918 {
48919 duk_context *ctx = (duk_context *) thr;
48920 duk_hobject *map;
48921 duk_hobject *varenv;
48922 duk_hstring *varname;
48923
48925
48926 if (!duk__lookup_arguments_map(thr, obj, key, temp_desc, &map, &varenv)) {
48927 DUK_DDD(DUK_DDDPRINT("arguments: key not mapped, no exotic put behavior"));
48928 return;
48929 }
48930
48931 /* [... put_value varname] */
48932
48933 varname = duk_require_hstring(ctx, -1);
48934 DUK_ASSERT(varname != NULL);
48935 duk_pop(ctx); /* varname is still reachable */
48936
48937 DUK_DDD(DUK_DDDPRINT("arguments object automatic putvar for a bound variable; "
48938 "key=%!O, varname=%!O, value=%!T",
48939 (duk_heaphdr *) key,
DUK_LOCAL duk_bool_t duk__lookup_arguments_map(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *temp_desc, duk_hobject **out_map, duk_hobject **out_varenv)
DUK_INTERNAL_DECL duk_hstring * duk_require_hstring(duk_context *ctx, duk_idx_t index)

Referenced by duk_hobject_putprop().

◆ duk__clamp_startend_negidx_shifted()

DUK_LOCAL void duk__clamp_startend_negidx_shifted ( duk_context * ctx,
duk_hbufferobject * h_bufobj,
duk_idx_t idx_start,
duk_idx_t idx_end,
duk_int_t * out_start_offset,
duk_int_t * out_end_offset )

Definition at line 22057 of file duktape-1.8.0/src/duktape.c.

22079 {
22080 duk_int_t buffer_length;
22081 duk_int_t start_offset;
22082 duk_int_t end_offset;
22083
22084 DUK_ASSERT(out_start_offset != NULL);
22085 DUK_ASSERT(out_end_offset != NULL);
22086
22087 buffer_length = (duk_int_t) h_bufobj->length;
22088 buffer_length >>= h_bufobj->shift; /* as elements */
22089
22090 /* Resolve start/end offset as element indices first; arguments
22091 * at idx_start/idx_end are element offsets. Working with element
22092 * indices first also avoids potential for wrapping.
22093 */
22094
22095 start_offset = duk_to_int(ctx, idx_start);
22096 if (start_offset < 0) {
22097 start_offset = buffer_length + start_offset;
22098 }
22099 if (duk_is_undefined(ctx, idx_end)) {
22100 end_offset = buffer_length;
22101 } else {
22102 end_offset = duk_to_int(ctx, idx_end);
22103 if (end_offset < 0) {
22104 end_offset = buffer_length + end_offset;
22105 }
22106 }
22107 /* Note: start_offset/end_offset can still be < 0 here. */
22108
22109 if (start_offset < 0) {
22110 start_offset = 0;
22111 } else if (start_offset > buffer_length) {
22112 start_offset = buffer_length;
22113 }
22114 if (end_offset < start_offset) {
DUK_EXTERNAL duk_int_t duk_to_int(duk_context *ctx, duk_idx_t index)

Referenced by duk_bi_buffer_slice_shared().

◆ duk__clamp_startend_nonegidx_noshift()

DUK_LOCAL void duk__clamp_startend_nonegidx_noshift ( duk_context * ctx,
duk_hbufferobject * h_bufobj,
duk_idx_t idx_start,
duk_idx_t idx_end,
duk_int_t * out_start_offset,
duk_int_t * out_end_offset )

Definition at line 22015 of file duktape-1.8.0/src/duktape.c.

22023 :
22025}
22026#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
22027
22028#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
22029/* Shared lenient buffer length clamping helper. No negative indices, no
22030 * element/byte shifting.
22031 */
22033 duk_hbufferobject *h_bufobj,
22034 duk_idx_t idx_start,
22035 duk_idx_t idx_end,
22036 duk_int_t *out_start_offset,
22037 duk_int_t *out_end_offset) {
22038 duk_int_t buffer_length;
22039 duk_int_t start_offset;
22040 duk_int_t end_offset;
22041
22042 DUK_ASSERT(out_start_offset != NULL);
22043 DUK_ASSERT(out_end_offset != NULL);
22044
22045 buffer_length = (duk_int_t) h_bufobj->length;
22046
#define DUK_ERROR_RANGE(thr, msg)
DUK_LOCAL void duk__clamp_startend_nonegidx_noshift(duk_context *ctx, duk_hbufferobject *h_bufobj, duk_idx_t idx_start, duk_idx_t idx_end, duk_int_t *out_start_offset, duk_int_t *out_end_offset)
#define DUK_STR_INVALID_CALL_ARGS

◆ duk__cleanup_varmap()

DUK_LOCAL_DECL duk_int_t duk__cleanup_varmap ( duk_compiler_ctx * comp_ctx)

Definition at line 58295 of file duktape-1.8.0/src/duktape.c.

58312 {
58313 duk_hthread *thr = comp_ctx->thr;
58314 duk_context *ctx = (duk_context *) thr;
58315 duk_hobject *h_varmap;
58316 duk_hstring *h_key;
58317 duk_tval *tv;
58318 duk_uint32_t i, e_next;
58319 duk_int_t ret;
58320
58321 /* [ ... varmap ] */
58322
58323 h_varmap = DUK_GET_HOBJECT_NEGIDX(ctx, -1);
58324 DUK_ASSERT(h_varmap != NULL);
58325
58326 ret = 0;
58327 e_next = DUK_HOBJECT_GET_ENEXT(h_varmap);
58328 for (i = 0; i < e_next; i++) {
58329 h_key = DUK_HOBJECT_E_GET_KEY(thr->heap, h_varmap, i);
58330 if (!h_key) {
58331 continue;
58332 }
58333
58334 DUK_ASSERT(!DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, h_varmap, i));
58335
58336 /* The entries can either be register numbers or 'null' values.
58337 * Thus, no need to DECREF them and get side effects. DECREF'ing
58338 * the keys (strings) can cause memory to be freed but no side
58339 * effects as strings don't have finalizers. This is why we can
58340 * rely on the object properties not changing from underneath us.
#define DUK_GET_HOBJECT_NEGIDX(ctx, idx)
#define DUK_HOBJECT_E_SLOT_IS_ACCESSOR(heap, h, i)

◆ duk__clear_finalize_list_flags()

DUK_LOCAL void duk__clear_finalize_list_flags ( duk_heap * heap)

Definition at line 42684 of file duktape-1.8.0/src/duktape.c.

◆ duk__clear_refzero_list_flags()

DUK_LOCAL void duk__clear_refzero_list_flags ( duk_heap * heap)

Definition at line 42657 of file duktape-1.8.0/src/duktape.c.

42660 : %p", (void *) hdr));
42661 duk_heaphdr_refcount_finalize(thr, hdr);
42662 }
42663
42664 hdr = DUK_HEAPHDR_GET_NEXT(heap, hdr);
42665 }
42666}
42667#endif /* DUK_USE_REFERENCE_COUNTING */
42668
42669/*
42670 * Clear (reachable) flags of refzero work list.

◆ duk__coerce_effective_this_binding()

DUK_LOCAL void duk__coerce_effective_this_binding ( duk_hthread * thr,
duk_hobject * func,
duk_idx_t idx_this )

Definition at line 55649 of file duktape-1.8.0/src/duktape.c.

55656 :
55657 *
55658 * - global code: this=global object
55659 * - direct eval: this=copy from eval() caller's this binding
55660 * - other eval: this=global object
55661 *
55662 * Note: this function may cause a recursive function call with arbitrary
55663 * side effects, because ToObject() may be called.
55664 */
55665
55667 duk_hobject *func,
55668 duk_idx_t idx_this) {
55669 duk_context *ctx = (duk_context *) thr;
55670 duk_tval *tv_this;
55671 duk_hobject *obj_global;
55672
55673 if (func == NULL || DUK_HOBJECT_HAS_STRICT(func)) {
55674 /* Lightfuncs are always considered strict. */
55675 DUK_DDD(DUK_DDDPRINT("this binding: strict -> use directly"));
55676 return;
55677 }
55678
55679 /* XXX: byte offset */
55680 tv_this = thr->valstack_bottom + idx_this;
55681 switch (DUK_TVAL_GET_TAG(tv_this)) {
55682 case DUK_TAG_OBJECT:
55683 case DUK_TAG_LIGHTFUNC: /* lightfuncs are treated like objects and not coerced */
55684 DUK_DDD(DUK_DDDPRINT("this binding: non-strict, object -> use directly"));
55685 break;
55686 case DUK_TAG_UNDEFINED:
55687 case DUK_TAG_NULL:
55688 DUK_DDD(DUK_DDDPRINT("this binding: non-strict, undefined/null -> use global object"));
55689 obj_global = thr->builtins[DUK_BIDX_GLOBAL];
55690 /* XXX: avoid this check somehow */
55691 if (DUK_LIKELY(obj_global != NULL)) {
55692 DUK_ASSERT(!DUK_TVAL_IS_HEAP_ALLOCATED(tv_this)); /* no need to decref previous value */
55693 DUK_TVAL_SET_OBJECT(tv_this, obj_global);
DUK_LOCAL void duk__coerce_effective_this_binding(duk_hthread *thr, duk_hobject *func, duk_idx_t idx_this)
#define DUK_TVAL_SET_OBJECT(tv, hptr)
#define DUK_TVAL_GET_TAG(tv)
#define DUK_BIDX_GLOBAL
#define DUK_TVAL_IS_HEAP_ALLOCATED(tv)
#define DUK_HOBJECT_HAS_STRICT(h)

References duk_hthread::builtins, DUK_ASSERT, DUK_BIDX_GLOBAL, DUK_D, DUK_DDD, DUK_DDDPRINT, DUK_DPRINT, DUK_HOBJECT_HAS_STRICT, DUK_HOBJECT_INCREF, DUK_LIKELY, DUK_TAG_LIGHTFUNC, DUK_TAG_NULL, DUK_TAG_OBJECT, DUK_TAG_UNDEFINED, DUK_TVAL_GET_TAG, DUK_TVAL_IS_HEAP_ALLOCATED, DUK_TVAL_SET_OBJECT, NULL, and duk_hthread::valstack_bottom.

Referenced by duk_handle_ecma_call_setup().

◆ duk__compact_object_list()

DUK_LOCAL void duk__compact_object_list ( duk_heap * heap,
duk_hthread * thr,
duk_heaphdr * start )

Definition at line 43137 of file duktape-1.8.0/src/duktape.c.

43142 {
43143 /* XXX: for threads, compact value stack, call stack, catch stack? */
43144
43145 duk_hobject *obj = duk_get_hobject(ctx, -1);
43146 DUK_ASSERT(obj != NULL);
43148 return 0;
43149}
43150
43151#ifdef DUK_USE_DEBUG
43152DUK_LOCAL void duk__compact_object_list(duk_heap *heap, duk_hthread *thr, duk_heaphdr *start, duk_size_t *p_count_check, duk_size_t *p_count_compact, duk_size_t *p_count_bytes_saved) {
43153#else
43155#endif
43156 duk_heaphdr *curr;
43157#ifdef DUK_USE_DEBUG
43158 duk_size_t old_size, new_size;
43159#endif
43160 duk_hobject *obj;
43161
43162 DUK_UNREF(heap);
43163
43164 curr = start;
43165 while (curr) {
43166 DUK_DDD(DUK_DDDPRINT("mark-and-sweep compact: %p", (void *) curr));
43167
43169 goto next;
43170 }
43171 obj = (duk_hobject *) curr;
43172
43173#ifdef DUK_USE_DEBUG
43177#endif
43178
43179 DUK_DD(DUK_DDPRINT("compact object: %p", (void *) obj));
43180 duk_push_hobject((duk_context *) thr, obj);
43181 /* XXX: disable error handlers for duration of compaction? */
43183
43184#ifdef DUK_USE_DEBUG
DUK_LOCAL int duk__protected_compact_object(duk_context *ctx)
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_LOCAL void duk__compact_object_list(duk_heap *heap, duk_hthread *thr, duk_heaphdr *start)
DUK_INTERNAL_DECL void duk_hobject_compact_props(duk_hthread *thr, duk_hobject *obj)
DUK_INTERNAL_DECL duk_hobject * duk_get_hobject(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL void duk_push_hobject(duk_context *ctx, duk_hobject *h)

References DUK_ASSERT, duk_get_hobject(), duk_hobject_compact_props(), and NULL.

◆ duk__compact_objects()

DUK_LOCAL void duk__compact_objects ( duk_heap * heap)

Definition at line 43186 of file duktape-1.8.0/src/duktape.c.

43195 :
43196 curr = DUK_HEAPHDR_GET_NEXT(heap, curr);
43197#ifdef DUK_USE_DEBUG
43198 (*p_count_check)++;
43199#endif
43200 }
43201}
43202
43204 /* XXX: which lists should participate? to be finalized? */
43205#ifdef DUK_USE_DEBUG
43206 duk_size_t count_check = 0;
43207 duk_size_t count_compact = 0;
43208 duk_size_t count_bytes_saved = 0;
43209#endif
43210 duk_hthread *thr;
43211
43212 DUK_DD(DUK_DDPRINT("duk__compact_objects: %p", (void *) heap));
43213
43214 thr = duk__get_temp_hthread(heap);
43215 DUK_ASSERT(thr != NULL);
43216
43217#ifdef DUK_USE_DEBUG
43218 duk__compact_object_list(heap, thr, heap->heap_allocated, &count_check, &count_compact, &count_bytes_saved);
DUK_LOCAL void duk__compact_objects(duk_heap *heap)
#define DUK_HEAPHDR_GET_NEXT(heap, h)
DUK_LOCAL duk_hthread * duk__get_temp_hthread(duk_heap *heap)

◆ duk__compute_a_stats()

DUK_LOCAL void duk__compute_a_stats ( duk_hthread * thr,
duk_hobject * obj,
duk_uint32_t * out_used,
duk_uint32_t * out_min_size )

Definition at line 47659 of file duktape-1.8.0/src/duktape.c.

47663 {
47664 if (*e++) {
47665 n++;
47666 }
47667 }
47668 return (duk_uint32_t) n;
47669}
47670
47671/* Count actually used array part entries and array minimum size.
47672 * NOTE: 'out_min_size' can be computed much faster by starting from the
47673 * end and breaking out early when finding first used entry, but this is
47674 * not needed now.
47675 */
47676DUK_LOCAL void duk__compute_a_stats(duk_hthread *thr, duk_hobject *obj, duk_uint32_t *out_used, duk_uint32_t *out_min_size) {
47678 duk_uint_fast32_t used = 0;
47679 duk_uint_fast32_t highest_idx = (duk_uint_fast32_t) -1; /* see below */
47680 duk_tval *a;
47681
47682 DUK_ASSERT(obj != NULL);
47683 DUK_ASSERT(out_used != NULL);
47684 DUK_ASSERT(out_min_size != NULL);
47685 DUK_UNREF(thr);
47686

Referenced by duk_hobject_putprop().

◆ duk__compute_mod()

DUK_LOCAL duk_double_t duk__compute_mod ( duk_double_t d1,
duk_double_t d2 )

Definition at line 65609 of file duktape-1.8.0/src/duktape.c.

◆ duk__concat_and_join_helper()

DUK_LOCAL void duk__concat_and_join_helper ( duk_context * ctx,
duk_idx_t count_in,
duk_bool_t is_join )

Definition at line 19800 of file duktape-1.8.0/src/duktape.c.

19801 {
19804}
19805#endif /* !DUK_USE_PARANOID_ERRORS */
19806
19807#undef DUK__CHECK_SPACE
19808#undef DUK__PACK_ARGS
19809#undef DUK__READABLE_STRING_MAXCHARS
19810#line 1 "duk_api_string.c"
19811/*
19812 * String manipulation
19813 */
19814
19815/* include removed: duk_internal.h */
19816
19818 duk_hthread *thr = (duk_hthread *) ctx;
19819 duk_uint_t count;
19820 duk_uint_t i;
19821 duk_size_t idx;
19822 duk_size_t len;
19823 duk_hstring *h;
19824 duk_uint8_t *buf;
19825
19827
19828 if (DUK_UNLIKELY(count_in <= 0)) {
19829 if (count_in < 0) {
19831 return;
19832 }
19833 DUK_ASSERT(count_in == 0);
19835 return;
19836 }
19837 count = (duk_uint_t) count_in;
19838
19839 if (is_join) {
19840 duk_size_t t1, t2, limit;
19841 h = duk_to_hstring(ctx, -((duk_idx_t) count) - 1);
19842 DUK_ASSERT(h != NULL);
19843
19844 /* A bit tricky overflow test, see doc/code-issues.rst. */
19846 t2 = (duk_size_t) (count - 1);
19848 if (DUK_UNLIKELY(t2 != 0 && t1 > limit / t2)) {
19849 /* Combined size of separators already overflows */
19850 goto error_overflow;
19851 }
19852 len = (duk_size_t) (t1 * t2);
19853 } else {
19854 len = (duk_size_t) 0;
19855 }
19856
19857 for (i = count; i >= 1; i--) {
19858 duk_size_t new_len;
19859 duk_to_string(ctx, -((duk_idx_t) i));
19860 h = duk_require_hstring(ctx, -((duk_idx_t) i));
19861 new_len = len + (duk_size_t) DUK_HSTRING_GET_BYTELEN(h);
19862
19863 /* Impose a string maximum length, need to handle overflow
19864 * correctly.
19865 */
19866 if (new_len < len || /* wrapped */
19867 new_len > (duk_size_t) DUK_HSTRING_MAX_BYTELEN) {
19868 goto error_overflow;
19869 }
19870 len = new_len;
19871 }
19872
19873 DUK_DDD(DUK_DDDPRINT("join/concat %lu strings, total length %lu bytes",
19874 (unsigned long) count, (unsigned long) len));
19875
19876 /* use stack allocated buffer to ensure reachability in errors (e.g. intern error) */
19877 buf = (duk_uint8_t *) duk_push_fixed_buffer(ctx, len);
19878 DUK_ASSERT(buf != NULL);
19879
19880 /* [... (sep) str1 str2 ... strN buf] */
19881
19882 idx = 0;
19883 for (i = count; i >= 1; i--) {
19884 if (is_join && i != count) {
19885 h = duk_require_hstring(ctx, -((duk_idx_t) count) - 2); /* extra -1 for buffer */
19887 idx += DUK_HSTRING_GET_BYTELEN(h);
19888 }
19889 h = duk_require_hstring(ctx, -((duk_idx_t) i) - 1); /* extra -1 for buffer */
19891 idx += DUK_HSTRING_GET_BYTELEN(h);
19892 }
19893
19894 DUK_ASSERT(idx == len);
19895
19896 /* [... (sep) str1 str2 ... strN buf] */
19897
19898 /* get rid of the strings early to minimize memory use before intern */
19899
19900 if (is_join) {
#define duk_push_fixed_buffer(ctx, size)
DUK_INTERNAL_DECL duk_hstring * duk_to_hstring(duk_context *ctx, duk_idx_t index)
#define DUK_ERROR_API(thr, msg)
#define DUK_STR_INVALID_COUNT
#define DUK_STRIDX_EMPTY_STRING
DUK_LOCAL void duk__concat_and_join_helper(duk_context *ctx, duk_idx_t count_in, duk_bool_t is_join)
#define DUK_HSTRING_MAX_BYTELEN
DUK_INTERNAL_DECL void duk_push_hstring_stridx(duk_context *ctx, duk_small_int_t stridx)
DUK_EXTERNAL const char * duk_to_string(duk_context *ctx, duk_idx_t index)

References DUK_ASSERT_CTX_VALID, duk_get_tval(), duk_push_string_tval_readable(), and index.

Referenced by duk_decode_string().

◆ duk__convert_to_func_template()

DUK_LOCAL_DECL void duk__convert_to_func_template ( duk_compiler_ctx * comp_ctx,
duk_bool_t force_no_namebind )

Definition at line 58346 of file duktape-1.8.0/src/duktape.c.

58349 {
58350 ret++;
58351 }
58352 }
58353
58354 duk_compact(ctx, -1);
58355
58356 return ret;
58357}
58358
58359/* convert duk_compiler_func into a function template, leaving the result
58360 * on top of stack.
58361 */
58362/* XXX: awkward and bloated asm -- use faster internal accesses */
58363DUK_LOCAL void duk__convert_to_func_template(duk_compiler_ctx *comp_ctx, duk_bool_t force_no_namebind) {
58364 duk_compiler_func *func = &comp_ctx->curr_func;
58365 duk_hthread *thr = comp_ctx->thr;
58366 duk_context *ctx = (duk_context *) thr;
58367 duk_hcompiledfunction *h_res;
58368 duk_hbuffer_fixed *h_data;
58369 duk_size_t consts_count;
58370 duk_size_t funcs_count;
58371 duk_size_t code_count;
58372 duk_size_t code_size;
58373 duk_size_t data_size;
58374 duk_size_t i;
58375 duk_tval *p_const;
58376 duk_hobject **p_func;
58377 duk_instr_t *p_instr;
58378 duk_compiler_instr *q_instr;
58379 duk_tval *tv;
58380
58381 DUK_DDD(DUK_DDDPRINT("converting duk_compiler_func to function/template"));
58382
58383 /*
58384 * Push result object and init its flags
58385 */
58386
58387 /* Valstack should suffice here, required on function valstack init */
58388
58389 (void) duk_push_compiledfunction(ctx);
58390 h_res = (duk_hcompiledfunction *) DUK_GET_HOBJECT_NEGIDX(ctx, -1); /* XXX: specific getter */
58391 DUK_ASSERT(h_res != NULL);
58392
58393 if (func->is_function) {
58394 DUK_DDD(DUK_DDDPRINT("function -> set NEWENV"));
58396
58397 if (!func->is_arguments_shadowed) {
58398 /* arguments object would be accessible; note that shadowing
58399 * bindings are arguments or function declarations, neither
58400 * of which are deletable, so this is safe.
58401 */
58402
58403 if (func->id_access_arguments || func->may_direct_eval) {
58404 DUK_DDD(DUK_DDDPRINT("function may access 'arguments' object directly or "
58405 "indirectly -> set CREATEARGS"));
58407 }
58408 }
58409 } else if (func->is_eval && func->is_strict) {
58410 DUK_DDD(DUK_DDDPRINT("strict eval code -> set NEWENV"));
58412 } else {
58413 /* non-strict eval: env is caller's env or global env (direct vs. indirect call)
58414 * global code: env is is global env
58415 */
58416 DUK_DDD(DUK_DDDPRINT("non-strict eval code or global code -> no NEWENV"));
58418 }
58419
58420 if (func->is_function && !func->is_decl && func->h_name != NULL && !force_no_namebind) {
58421 /* Object literal set/get functions have a name (property
58422 * name) but must not have a lexical name binding, see
58423 * test-bug-getset-func-name.js.
58424 */
58425 DUK_DDD(DUK_DDDPRINT("function expression with a name -> set NAMEBINDING"));
58427 }
58428
58429 if (func->is_strict) {
58430 DUK_DDD(DUK_DDDPRINT("function is strict -> set STRICT"));
58432 }
58433
58434 if (func->is_notail) {
58435 DUK_DDD(DUK_DDDPRINT("function is notail -> set NOTAIL"));
58437 }
58438
58439 /*
58440 * Build function fixed size 'data' buffer, which contains bytecode,
58441 * constants, and inner function references.
58442 *
58443 * During the building phase 'data' is reachable but incomplete.
58444 * Only incref's occur during building (no refzero or GC happens),
58445 * so the building process is atomic.
58446 */
58447
58448 consts_count = duk_hobject_get_length(thr, func->h_consts);
58449 funcs_count = duk_hobject_get_length(thr, func->h_funcs) / 3;
58450 code_count = DUK_BW_GET_SIZE(thr, &func->bw_code) / sizeof(duk_compiler_instr);
58451 code_size = code_count * sizeof(duk_instr_t);
58452
58453 data_size = consts_count * sizeof(duk_tval) +
58454 funcs_count * sizeof(duk_hobject *) +
58455 code_size;
58456
58457 DUK_DDD(DUK_DDDPRINT("consts_count=%ld, funcs_count=%ld, code_size=%ld -> "
58458 "data_size=%ld*%ld + %ld*%ld + %ld = %ld",
58459 (long) consts_count, (long) funcs_count, (long) code_size,
58460 (long) consts_count, (long) sizeof(duk_tval),
58461 (long) funcs_count, (long) sizeof(duk_hobject *),
58462 (long) code_size, (long) data_size));
58463
58464 duk_push_fixed_buffer(ctx, data_size);
58465 h_data = (duk_hbuffer_fixed *) duk_get_hbuffer(ctx, -1);
58466 DUK_ASSERT(h_data != NULL);
58467
58468 DUK_HCOMPILEDFUNCTION_SET_DATA(thr->heap, h_res, (duk_hbuffer *) h_data);
58469 DUK_HEAPHDR_INCREF(thr, h_data);
58470
58471 p_const = (duk_tval *) (void *) DUK_HBUFFER_FIXED_GET_DATA_PTR(thr->heap, h_data);
58472 for (i = 0; i < consts_count; i++) {
58473 DUK_ASSERT(i <= DUK_UARRIDX_MAX); /* const limits */
58475 DUK_ASSERT(tv != NULL);
58476 DUK_TVAL_SET_TVAL(p_const, tv);
58477 p_const++;
58478 DUK_TVAL_INCREF(thr, tv); /* may be a string constant */
58479
58480 DUK_DDD(DUK_DDDPRINT("constant: %!T", (duk_tval *) tv));
58481 }
58482
58483 p_func = (duk_hobject **) p_const;
58484 DUK_HCOMPILEDFUNCTION_SET_FUNCS(thr->heap, h_res, p_func);
58485 for (i = 0; i < funcs_count; i++) {
58486 duk_hobject *h;
58487 DUK_ASSERT(i * 3 <= DUK_UARRIDX_MAX); /* func limits */
58489 DUK_ASSERT(tv != NULL);
58491 h = DUK_TVAL_GET_OBJECT(tv);
58492 DUK_ASSERT(h != NULL);
58494 *p_func++ = h;
58495 DUK_HOBJECT_INCREF(thr, h);
58496
58497 DUK_DDD(DUK_DDDPRINT("inner function: %p -> %!iO",
58498 (void *) h, (duk_heaphdr *) h));
58499 }
58500
58501 p_instr = (duk_instr_t *) p_func;
58502 DUK_HCOMPILEDFUNCTION_SET_BYTECODE(thr->heap, h_res, p_instr);
58503
58504 /* copy bytecode instructions one at a time */
58505 q_instr = (duk_compiler_instr *) (void *) DUK_BW_GET_BASEPTR(thr, &func->bw_code);
58506 for (i = 0; i < code_count; i++) {
58507 p_instr[i] = q_instr[i].ins;
58508 }
58509 /* Note: 'q_instr' is still used below */
58510
58511 DUK_ASSERT((duk_uint8_t *) (p_instr + code_count) == DUK_HBUFFER_FIXED_GET_DATA_PTR(thr->heap, h_data) + data_size);
58512
58513 duk_pop(ctx); /* 'data' (and everything in it) is reachable through h_res now */
58514
58515 /*
58516 * Init object properties
58517 *
58518 * Properties should be added in decreasing order of access frequency.
58519 * (Not very critical for function templates.)
58520 */
58521
58522 DUK_DDD(DUK_DDDPRINT("init function properties"));
58523
58524 /* [ ... res ] */
58525
58526 /* _Varmap: omitted if function is guaranteed not to do slow path identifier
58527 * accesses or if it would turn out to be empty of actual register mappings
58528 * after a cleanup. When debugging is enabled, we always need the varmap to
58529 * be able to lookup variables at any point.
58530 */
58531#if defined(DUK_USE_DEBUGGER_SUPPORT)
58532 if (1) {
58533#else
58534 if (func->id_access_slow || /* directly uses slow accesses */
58535 func->may_direct_eval || /* may indirectly slow access through a direct eval */
58536 funcs_count > 0) { /* has inner functions which may slow access (XXX: this can be optimized by looking at the inner functions) */
58537#endif
58538 duk_int_t num_used;
58539 duk_dup(ctx, func->varmap_idx);
58540 num_used = duk__cleanup_varmap(comp_ctx);
58541 DUK_DDD(DUK_DDDPRINT("cleaned up varmap: %!T (num_used=%ld)",
58542 (duk_tval *) duk_get_tval(ctx, -1), (long) num_used));
58543
58544 if (num_used > 0) {
58546 } else {
58547 DUK_DDD(DUK_DDDPRINT("varmap is empty after cleanup -> no need to add"));
58548 duk_pop(ctx);
58549 }
58550 }
58551
58552 /* _Formals: omitted if function is guaranteed not to need a (non-strict) arguments object */
58553 if (1) {
58554 /* XXX: Add a proper condition. If formals list is omitted, recheck
58555 * handling for 'length' in duk_js_push_closure(); it currently relies
58556 * on _Formals being set. Removal may need to be conditional to debugging
58557 * being enabled/disabled too.
58558 */
58559 duk_dup(ctx, func->argnames_idx);
58561 }
58562
58563 /* name */
58564 if (func->h_name) {
58565 duk_push_hstring(ctx, func->h_name);
58567 }
58568
58569 /* _Source */
58570#if defined(DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY)
58571 if (0) {
58572 /* XXX: Currently function source code is not stored, as it is not
58573 * required by the standard. Source code should not be stored by
58574 * default (user should enable it explicitly), and the source should
58575 * probably be compressed with a trivial text compressor; average
58576 * compression of 20-30% is quite easy to achieve even with a trivial
58577 * compressor (RLE + backwards lookup).
58578 *
58579 * Debugging needs source code to be useful: sometimes input code is
58580 * not found in files as it may be generated and then eval()'d, given
58581 * by dynamic C code, etc.
58582 *
58583 * Other issues:
58584 *
58585 * - Need tokenizer indices for start and end to substring
58586 * - Always normalize function declaration part?
58587 * - If we keep _Formals, only need to store body
58588 */
58589
58590 /*
58591 * For global or eval code this is straightforward. For functions
58592 * created with the Function constructor we only get the source for
58593 * the body and must manufacture the "function ..." part.
58594 *
58595 * For instance, for constructed functions (v8):
58596 *
58597 * > a = new Function("foo", "bar", "print(foo)");
58598 * [Function]
58599 * > a.toString()
58600 * 'function anonymous(foo,bar) {\nprint(foo)\n}'
58601 *
58602 * Similarly for e.g. getters (v8):
58603 *
58604 * > x = { get a(foo,bar) { print(foo); } }
58605 * { a: [Getter] }
58606 * > Object.getOwnPropertyDescriptor(x, 'a').get.toString()
58607 * 'function a(foo,bar) { print(foo); }'
58608 */
58609
58610#if 0
58611 duk_push_string(ctx, "XXX");
58613#endif
58614 }
58615#endif /* DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY */
58616
58617 /* _Pc2line */
58618#if defined(DUK_USE_PC2LINE)
58619 if (1) {
58620 /*
58621 * Size-optimized pc->line mapping.
58622 */
58623
58625 duk_hobject_pc2line_pack(thr, q_instr, (duk_uint_fast32_t) code_count); /* -> pushes fixed buffer */
58627
58628 /* XXX: if assertions enabled, walk through all valid PCs
58629 * and check line mapping.
58630 */
58631 }
58632#endif /* DUK_USE_PC2LINE */
58633
58634 /* fileName */
58635 if (comp_ctx->h_filename) {
58636 /*
58637 * Source filename (or equivalent), for identifying thrown errors.
58638 */
58639
58640 duk_push_hstring(ctx, comp_ctx->h_filename);
58642 }
58643
58644 /*
58645 * Init remaining result fields
58646 *
58647 * 'nregs' controls how large a register frame is allocated.
58648 *
58649 * 'nargs' controls how many formal arguments are written to registers:
58650 * r0, ... r(nargs-1). The remaining registers are initialized to
58651 * undefined.
58652 */
58653
58654 DUK_ASSERT(func->temp_max >= 0);
58655 h_res->nregs = (duk_uint16_t) func->temp_max;
58656 h_res->nargs = (duk_uint16_t) duk_hobject_get_length(thr, func->h_argnames);
58657 DUK_ASSERT(h_res->nregs >= h_res->nargs); /* pass2 allocation handles this */
58658#if defined(DUK_USE_DEBUGGER_SUPPORT)
58659 h_res->start_line = (duk_uint32_t) func->min_line;
58660 h_res->end_line = (duk_uint32_t) func->max_line;
58661#endif
58662
58663 DUK_DD(DUK_DDPRINT("converted function: %!ixT",
58664 (duk_tval *) duk_get_tval(ctx, -1)));
58665
58666 /*
58667 * Compact the function template.
58668 */
58669
58670 duk_compact(ctx, -1);
58671
58672 /*
58673 * Debug dumping
58674 */
58675
58676#ifdef DUK_USE_DDDPRINT
58677 {
58679 duk_instr_t *p, *p_start, *p_end;
58680
58681 h = (duk_hcompiledfunction *) duk_get_hobject(ctx, -1);
#define DUK_HCOMPILEDFUNCTION_SET_FUNCS(heap, h, v)
#define DUK_TVAL_SET_TVAL(v, x)
#define DUK_COMPILER_MAX_BYTECODE_LENGTH
DUK_INTERNAL_DECL duk_hbuffer * duk_get_hbuffer(duk_context *ctx, duk_idx_t index)
#define DUK_HCOMPILEDFUNCTION_SET_BYTECODE(heap, h, v)
#define DUK_STRIDX_INT_FORMALS
DUK_LOCAL_DECL void duk__convert_to_func_template(duk_compiler_ctx *comp_ctx, duk_bool_t force_no_namebind)
#define DUK_TVAL_GET_OBJECT(tv)
DUK_EXTERNAL void duk_compact(duk_context *ctx, duk_idx_t obj_index)
#define DUK_HOBJECT_IS_COMPILEDFUNCTION(h)
#define DUK_TVAL_IS_OBJECT(tv)
#define DUK_HOBJECT_SET_CREATEARGS(h)
#define DUK_PROPDESC_FLAGS_NONE
struct duk_compiler_instr duk_compiler_instr
#define DUK_TVAL_INCREF(thr, tv)
#define DUK_HCOMPILEDFUNCTION_SET_DATA(heap, h, v)
#define DUK_BW_GET_BASEPTR(thr, bw_ctx)
#define DUK_HOBJECT_SET_NOTAIL(h)
#define DUK_HOBJECT_SET_STRICT(h)
#define DUK_STRIDX_NAME
#define DUK_BW_GET_SIZE(thr, bw_ctx)
#define DUK_STRIDX_INT_VARMAP
DUK_LOCAL_DECL duk_int_t duk__cleanup_varmap(duk_compiler_ctx *comp_ctx)
DUK_INTERNAL_DECL duk_uint32_t duk_hobject_get_length(duk_hthread *thr, duk_hobject *obj)
#define DUK_HEAPHDR_INCREF(thr, h)
#define DUK_HOBJECT_HAS_NEWENV(h)
#define DUK_STRIDX_INT_PC2LINE
DUK_INTERNAL_DECL duk_tval * duk_hobject_find_existing_array_entry_tval_ptr(duk_heap *heap, duk_hobject *obj, duk_uarridx_t i)
#define DUK_HOBJECT_INCREF(thr, h)
#define DUK_HOBJECT_SET_NAMEBINDING(h)
DUK_INTERNAL_DECL duk_idx_t duk_push_compiledfunction(duk_context *ctx)
#define DUK_STRIDX_INT_SOURCE
DUK_INTERNAL_DECL void duk_hobject_pc2line_pack(duk_hthread *thr, duk_compiler_instr *instrs, duk_uint_fast32_t length)
#define DUK_HOBJECT_SET_NEWENV(h)

◆ duk__copy_ispec()

DUK_LOCAL_DECL void duk__copy_ispec ( duk_compiler_ctx * comp_ctx,
duk_ispec * src,
duk_ispec * dst )

Definition at line 59530 of file duktape-1.8.0/src/duktape.c.

59532 {
59533 DUK_D(DUK_DPRINT("ivalue dump: t=%ld op=%ld "
59534 "x1={t=%ld regconst=0x%08lx valstack_idx=%ld value=%!T} "
59535 "x2={t=%ld regconst=0x%08lx valstack_idx=%ld value=%!T}",
59536 (long) x->t, (long) x->op,

◆ duk__copy_ivalue()

DUK_LOCAL_DECL void duk__copy_ivalue ( duk_compiler_ctx * comp_ctx,
duk_ivalue * src,
duk_ivalue * dst )

Definition at line 59538 of file duktape-1.8.0/src/duktape.c.

59543 {} while (0)
59544#define DUK__DUMP_IVALUE(comp_ctx,x) do {} while (0)
59545#endif
59546
59547DUK_LOCAL void duk__copy_ispec(duk_compiler_ctx *comp_ctx, duk_ispec *src, duk_ispec *dst) {
59548 duk_context *ctx = (duk_context *) comp_ctx->thr;
59549
DUK_LOCAL_DECL void duk__copy_ispec(duk_compiler_ctx *comp_ctx, duk_ispec *src, duk_ispec *dst)

◆ duk__cos()

DUK_LOCAL double duk__cos ( double x)

Definition at line 32750 of file duktape-1.8.0/src/duktape.c.

32752 {

◆ duk__count_used_e_keys()

DUK_LOCAL duk_uint32_t duk__count_used_e_keys ( duk_hthread * thr,
duk_hobject * obj )

Definition at line 47637 of file duktape-1.8.0/src/duktape.c.

47643 {
47644 duk_uint32_t res;
47645
47647
47649 DUK_ASSERT(res >= 1); /* important for callers */
47650 return res;
47651}
47652
#define DUK_HOBJECT_A_MIN_GROW_ADD
#define DUK_HOBJECT_MAX_PROPERTIES
#define DUK_HOBJECT_A_MIN_GROW_DIVISOR

◆ duk__count_used_probe()

DUK_LOCAL duk_int_t duk__count_used_probe ( duk_heap * heap)

Definition at line 45474 of file duktape-1.8.0/src/duktape.c.

45491 {
45492 duk_int_t res = 0;
45493 duk_uint_fast32_t i, n;

◆ duk__create_arguments_object()

DUK_LOCAL void duk__create_arguments_object ( duk_hthread * thr,
duk_hobject * func,
duk_hobject * varenv,
duk_idx_t idx_argbase,
duk_idx_t num_stack_args )

Definition at line 55091 of file duktape-1.8.0/src/duktape.c.

55112 { /* num args starting from idx_argbase */
55113 duk_context *ctx = (duk_context *) thr;
55114 duk_hobject *arg; /* 'arguments' */
55115 duk_hobject *formals; /* formals for 'func' (may be NULL if func is a C function) */
55116 duk_idx_t i_arg;
55117 duk_idx_t i_map;
55118 duk_idx_t i_mappednames;
55119 duk_idx_t i_formals;
55120 duk_idx_t i_argbase;
55121 duk_idx_t n_formals;
55122 duk_idx_t idx;
55123 duk_bool_t need_map;
55124
55125 DUK_DDD(DUK_DDDPRINT("creating arguments object for func=%!iO, varenv=%!iO, "
55126 "idx_argbase=%ld, num_stack_args=%ld",
55127 (duk_heaphdr *) func, (duk_heaphdr *) varenv,
55128 (long) idx_argbase, (long) num_stack_args));
55129
55130 DUK_ASSERT(thr != NULL);
55131 DUK_ASSERT(func != NULL);
55133 DUK_ASSERT(varenv != NULL);
55134 DUK_ASSERT(idx_argbase >= 0); /* assumed to bottom relative */
55135 DUK_ASSERT(num_stack_args >= 0);
55136
55137 need_map = 0;
55138
55139 i_argbase = idx_argbase;
55140 DUK_ASSERT(i_argbase >= 0);
55141
55142 duk_push_hobject(ctx, func);
55144 formals = duk_get_hobject(ctx, -1);
55145 n_formals = 0;
55146 if (formals) {
55148 n_formals = (duk_idx_t) duk_require_int(ctx, -1);
55149 duk_pop(ctx);
55150 }
55151 duk_remove(ctx, -2); /* leave formals on stack for later use */
55152 i_formals = duk_require_top_index(ctx);
55153
55154 DUK_ASSERT(n_formals >= 0);
55155 DUK_ASSERT(formals != NULL || n_formals == 0);
55156
55157 DUK_DDD(DUK_DDDPRINT("func=%!O, formals=%!O, n_formals=%ld",
55158 (duk_heaphdr *) func, (duk_heaphdr *) formals,
55159 (long) n_formals));
55160
55161 /* [ ... formals ] */
55162
55163 /*
55164 * Create required objects:
55165 * - 'arguments' object: array-like, but not an array
55166 * - 'map' object: internal object, tied to 'arguments'
55167 * - 'mappedNames' object: temporary value used during construction
55168 */
55169
55170 i_arg = duk_push_object_helper(ctx,
55175 DUK_ASSERT(i_arg >= 0);
55176 arg = duk_require_hobject(ctx, -1);
55177 DUK_ASSERT(arg != NULL);
55178
55179 i_map = duk_push_object_helper(ctx,
55182 -1); /* no prototype */
55183 DUK_ASSERT(i_map >= 0);
55184
55185 i_mappednames = duk_push_object_helper(ctx,
55188 -1); /* no prototype */
55189 DUK_ASSERT(i_mappednames >= 0);
55190
55191 /* [ ... formals arguments map mappedNames ] */
55192
55193 DUK_DDD(DUK_DDDPRINT("created arguments related objects: "
55194 "arguments at index %ld -> %!O "
55195 "map at index %ld -> %!O "
55196 "mappednames at index %ld -> %!O",
55197 (long) i_arg, (duk_heaphdr *) duk_get_hobject(ctx, i_arg),
55198 (long) i_map, (duk_heaphdr *) duk_get_hobject(ctx, i_map),
55199 (long) i_mappednames, (duk_heaphdr *) duk_get_hobject(ctx, i_mappednames)));
55200
55201 /*
55202 * Init arguments properties, map, etc.
55203 */
55204
55205 duk_push_int(ctx, num_stack_args);
55207
55208 /*
55209 * Init argument related properties
55210 */
55211
55212 /* step 11 */
55213 idx = num_stack_args - 1;
55214 while (idx >= 0) {
55215 DUK_DDD(DUK_DDDPRINT("arg idx %ld, argbase=%ld, argidx=%ld",
55216 (long) idx, (long) i_argbase, (long) (i_argbase + idx)));
55217
55218 DUK_DDD(DUK_DDDPRINT("define arguments[%ld]=arg", (long) idx));
55219 duk_dup(ctx, i_argbase + idx);
55220 duk_xdef_prop_index_wec(ctx, i_arg, (duk_uarridx_t) idx);
55221 DUK_DDD(DUK_DDDPRINT("defined arguments[%ld]=arg", (long) idx));
55222
55223 /* step 11.c is relevant only if non-strict (checked in 11.c.ii) */
55224 if (!DUK_HOBJECT_HAS_STRICT(func) && idx < n_formals) {
55225 DUK_ASSERT(formals != NULL);
55226
55227 DUK_DDD(DUK_DDDPRINT("strict function, index within formals (%ld < %ld)",
55228 (long) idx, (long) n_formals));
55229
55230 duk_get_prop_index(ctx, i_formals, idx);
55231 DUK_ASSERT(duk_is_string(ctx, -1));
55232
55233 duk_dup(ctx, -1); /* [ ... name name ] */
55234
55235 if (!duk_has_prop(ctx, i_mappednames)) {
55236 /* steps 11.c.ii.1 - 11.c.ii.4, but our internal book-keeping
55237 * differs from the reference model
55238 */
55239
55240 /* [ ... name ] */
55241
55242 need_map = 1;
55243
55244 DUK_DDD(DUK_DDDPRINT("set mappednames[%s]=%ld",
55245 (const char *) duk_get_string(ctx, -1),
55246 (long) idx));
55247 duk_dup(ctx, -1); /* name */
55248 duk_push_uint(ctx, (duk_uint_t) idx); /* index */
55249 duk_to_string(ctx, -1);
55250 duk_xdef_prop_wec(ctx, i_mappednames); /* out of spec, must be configurable */
55251
55252 DUK_DDD(DUK_DDDPRINT("set map[%ld]=%s",
55253 (long) idx,
55254 duk_get_string(ctx, -1)));
55255 duk_dup(ctx, -1); /* name */
55256 duk_xdef_prop_index_wec(ctx, i_map, (duk_uarridx_t) idx); /* out of spec, must be configurable */
55257 } else {
55258 /* duk_has_prop() popped the second 'name' */
55259 }
55260
55261 /* [ ... name ] */
55262 duk_pop(ctx); /* pop 'name' */
55263 }
55264
55265 idx--;
55266 }
55267
55268 DUK_DDD(DUK_DDDPRINT("actual arguments processed"));
55269
55270 /* step 12 */
55271 if (need_map) {
55272 DUK_DDD(DUK_DDDPRINT("adding 'map' and 'varenv' to arguments object"));
55273
55274 /* should never happen for a strict callee */
55276
55277 duk_dup(ctx, i_map);
55278 duk_xdef_prop_stridx(ctx, i_arg, DUK_STRIDX_INT_MAP, DUK_PROPDESC_FLAGS_NONE); /* out of spec, don't care */
55279
55280 /* The variable environment for magic variable bindings needs to be
55281 * given by the caller and recorded in the arguments object.
55282 *
55283 * See E5 Section 10.6, the creation of setters/getters.
55284 *
55285 * The variable environment also provides access to the callee, so
55286 * an explicit (internal) callee property is not needed.
55287 */
55288
55289 duk_push_hobject(ctx, varenv);
55290 duk_xdef_prop_stridx(ctx, i_arg, DUK_STRIDX_INT_VARENV, DUK_PROPDESC_FLAGS_NONE); /* out of spec, don't care */
55291 }
55292
55293 /* steps 13-14 */
55294 if (DUK_HOBJECT_HAS_STRICT(func)) {
55295 /* Callee/caller are throwers and are not deletable etc. They
55296 * could be implemented as virtual properties, but currently
55297 * there is no support for virtual properties which are accessors
55298 * (only plain virtual properties). This would not be difficult
55299 * to change in duk_hobject_props, but we can make the throwers
55300 * normal, concrete properties just as easily.
55301 *
55302 * Note that the specification requires that the *same* thrower
55303 * built-in object is used here! See E5 Section 10.6 main
55304 * algoritm, step 14, and Section 13.2.3 which describes the
55305 * thrower. See test case test-arguments-throwers.js.
55306 */
55307
55308 DUK_DDD(DUK_DDDPRINT("strict function, setting caller/callee to throwers"));
55309
55312 } else {
55313 DUK_DDD(DUK_DDDPRINT("non-strict function, setting callee to actual value"));
55314 duk_push_hobject(ctx, func);
55316 }
55317
55318 /* set exotic behavior only after we're done */
55319 if (need_map) {
55320 /* Exotic behaviors are only enabled for arguments objects
55321 * which have a parameter map (see E5 Section 10.6 main
55322 * algorithm, step 12).
55323 *
55324 * In particular, a non-strict arguments object with no
55325 * mapped formals does *NOT* get exotic behavior, even
55326 * for e.g. "caller" property. This seems counterintuitive
55327 * but seems to be the case.
55328 */
55329
55330 /* cannot be strict (never mapped variables) */
55332
55333 DUK_DDD(DUK_DDDPRINT("enabling exotic behavior for arguments object"));
55335 } else {
55336 DUK_DDD(DUK_DDDPRINT("not enabling exotic behavior for arguments object"));
CURL_EXTERN int void * arg
Definition curl.h:2622
#define DUK_HOBJECT_CLASS_OBJECT
#define DUK_BIDX_OBJECT_PROTOTYPE
#define DUK_HOBJECT_SET_EXOTIC_ARGUMENTS(h)
#define duk_xdef_prop_wec(ctx, obj_index)
DUK_EXTERNAL duk_idx_t duk_require_top_index(duk_context *ctx)
DUK_INTERNAL_DECL duk_hobject * duk_require_hobject(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL duk_idx_t duk_push_object_helper(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_small_int_t prototype_bidx)
#define DUK_HOBJECT_CLASS_ARGUMENTS
#define DUK_HOBJECT_IS_NONBOUND_FUNCTION(h)
DUK_EXTERNAL void duk_remove(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL void duk_push_int(duk_context *ctx, duk_int_t val)
#define DUK_HOBJECT_CLASS_AS_FLAGS(v)
DUK_EXTERNAL const char * duk_get_string(duk_context *ctx, duk_idx_t index)
#define DUK_STRIDX_LENGTH
DUK_INTERNAL_DECL duk_bool_t duk_get_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx)
#define DUK_HOBJECT_FLAG_EXTENSIBLE
#define DUK_STRIDX_INT_VARENV
DUK_INTERNAL_DECL void duk_xdef_prop_stridx_thrower(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_uint_t desc_flags)
#define DUK_STRIDX_INT_MAP
#define DUK_STRIDX_CALLEE
DUK_EXTERNAL duk_bool_t duk_is_string(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL duk_int_t duk_require_int(duk_context *ctx, duk_idx_t index)
#define DUK_STRIDX_CALLER
#define DUK_HOBJECT_FLAG_ARRAY_PART
DUK_EXTERNAL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_index)

◆ duk__create_escaped_source()

DUK_LOCAL void duk__create_escaped_source ( duk_hthread * thr,
int idx_pattern )

Definition at line 78487 of file duktape-1.8.0/src/duktape.c.

78488 :)') and otherwise replace unescaped '/' characters
78489 * with '\/' regardless of where they occur in the regexp.
78490 *
78491 * Note that normalization does not seem to be necessary for
78492 * RegExp literals (e.g. '/foo/') because to be acceptable as
78493 * a RegExp literal, the text between forward slashes must
78494 * already match the escaping requirements (e.g. must not contain
78495 * unescaped forward slashes or be empty). Escaping IS needed
78496 * for expressions like 'new Regexp("...", "")' however.
78497 * Currently, we re-escape in either case.
78498 *
78499 * Also note that we process the source here in UTF-8 encoded
78500 * form. This is correct, because any non-ASCII characters are
78501 * passed through without change.
78502 */
78503
78504DUK_LOCAL void duk__create_escaped_source(duk_hthread *thr, int idx_pattern) {
78505 duk_context *ctx = (duk_context *) thr;
78506 duk_hstring *h;
78507 const duk_uint8_t *p;
78508 duk_bufwriter_ctx bw_alloc;
78509 duk_bufwriter_ctx *bw;
78510 duk_uint8_t *q;
78511 duk_size_t i, n;
78512 duk_uint_fast8_t c_prev, c;
78513
78514 h = duk_get_hstring(ctx, idx_pattern);
78515 DUK_ASSERT(h != NULL);
78516 p = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h);
78517 n = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h);
78518
78519 if (n == 0) {
78520 /* return '(?:)' */
78521 duk_push_hstring_stridx(ctx, DUK_STRIDX_ESCAPED_EMPTY_REGEXP);
78522 return;
78523 }
78524
78525 bw = &bw_alloc;
78526 DUK_BW_INIT_PUSHBUF(thr, bw, n);
78527 q = DUK_BW_GET_PTR(thr, bw);
78528
78529 c_prev = (duk_uint_fast8_t) 0;
78530
78531 for (i = 0; i < n; i++) {
78532 c = p[i];

References DUK_ASC_BACKSLASH, DUK_ASSERT, DUK_BW_ENSURE_RAW, DUK_BW_GET_PTR, DUK_BW_INIT_PUSHBUF, DUK_BW_SETPTR_AND_COMPACT, duk_get_hstring(), DUK_HSTRING_GET_BYTELEN, DUK_HSTRING_GET_DATA, duk_push_hstring_stridx(), DUK_STRIDX_ESCAPED_EMPTY_REGEXP, duk_to_string(), and NULL.

◆ duk__date_get_indirect_magic()

◆ duk__day_from_year()

DUK_LOCAL duk_int_t duk__day_from_year ( duk_int_t year)

Definition at line 25108 of file duktape-1.8.0/src/duktape.c.

25111 {
25112 DUK_ASSERT(b > 0);
25113 if (a >= 0) {
25114 return a / b;
25115 } else {
25116 /* e.g. a = -4, b = 5 --> -4 - 5 + 1 / 5 --> -8 / 5 --> -1

◆ duk__dec_array()

DUK_LOCAL_DECL void duk__dec_array ( duk_json_dec_ctx * js_ctx)

Definition at line 29902 of file duktape-1.8.0/src/duktape.c.

29908 : final object is %!T",
29909 (duk_tval *) duk_get_tval(ctx, -1)));
29910
29911 duk__dec_objarr_exit(js_ctx);
29912 return;
29913
29914 syntax_error:
29915 duk__dec_syntax_error(js_ctx);
29916 DUK_UNREACHABLE();
29917}
29918
29919DUK_LOCAL void duk__dec_array(duk_json_dec_ctx *js_ctx) {
29920 duk_context *ctx = (duk_context *) js_ctx->thr;
29921 duk_uarridx_t arr_idx;
29922 duk_uint8_t x;
29923
29924 DUK_DDD(DUK_DDDPRINT("parse_array"));
29925
29926 duk__dec_objarr_entry(js_ctx);
29927
29928 duk_push_array(ctx);
29929
29930 /* Initial '[' has been checked and eaten by caller. */
29931
29932 arr_idx = 0;
29933 for (;;) {
29934 x = duk__dec_get_nonwhite(js_ctx);
29935
29936 DUK_DDD(DUK_DDDPRINT("parse_array: arr=%!T, x=%ld, arr_idx=%ld",
29937 (duk_tval *) duk_get_tval(ctx, -1),
29938 (long) x, (long) arr_idx));
29939
29940 /* handle comma and closing bracket */
29941
29942 if ((x == DUK_ASC_COMMA) && (arr_idx != 0)) {
29943 /* accept comma, expect new value */
29944 ;
29945 } else if (x == DUK_ASC_RBRACKET) {
29946 /* eat closing bracket */
29947 break;
29948 } else if (arr_idx == 0) {
29949 /* accept anything, expect first value (EOF will be
29950 * caught by duk__dec_value() below.
29951 */
29952 js_ctx->p--; /* backtrack (safe) */
29953 } else {
29954 /* catches EOF (NUL) and initial comma */
29955 goto syntax_error;
29956 }
29957
29958 /* parse value */
29959
29960 duk__dec_value(js_ctx);
29961
29962 /* [ ... arr val ] */
29963
29964 duk_xdef_prop_index_wec(ctx, -2, arr_idx);
29965 arr_idx++;
29966 }
29967
29968 /* Must set 'length' explicitly when using duk_xdef_prop_xxx() to

◆ duk__dec_buffer()

DUK_LOCAL_DECL void duk__dec_buffer ( duk_json_dec_ctx * js_ctx)

Definition at line 29674 of file duktape-1.8.0/src/duktape.c.

29684 :
29685 duk__dec_syntax_error(js_ctx);
29687}
29688#endif /* DUK_USE_JX */
29689
29690#ifdef DUK_USE_JX
29692 duk_hthread *thr = js_ctx->thr;
29693 duk_context *ctx = (duk_context *) thr;
29694 const duk_uint8_t *p;
29695 duk_uint8_t *buf;
29696 duk_size_t src_len;
29698
29699 /* Caller has already eaten the first character ('|') which we don't need. */
29700
29701 p = js_ctx->p;
29702
29703 /* XXX: Would be nice to share the fast path loop from duk_hex_decode()
29704 * and avoid creating a temporary buffer. However, there are some
29705 * differences which prevent trivial sharing:
29706 *
29707 * - Pipe char detection
29708 * - EOF detection
29709 * - Unknown length of input and output
29710 *
29711 * The best approach here would be a bufwriter and a reasonaly sized
29712 * safe inner loop (e.g. 64 output bytes at a time).
29713 */
29714
29715 for (;;) {
29716 x = *p;
29717
29718 /* This loop intentionally does not ensure characters are valid
29719 * ([0-9a-fA-F]) because the hex decode call below will do that.
29720 */
29721 if (x == DUK_ASC_PIPE) {
29722 break;
29723 } else if (x <= 0) {
29724 /* NUL term or -1 (EOF), NUL check would suffice */
29725 goto syntax_error;
29726 }
29727 p++;
29728 }
#define DUK_ASC_PIPE
DUK_LOCAL_DECL void duk__dec_syntax_error(duk_json_dec_ctx *js_ctx)
DUK_LOCAL_DECL void duk__dec_buffer(duk_json_dec_ctx *js_ctx)

◆ duk__dec_decode_hex_escape()

DUK_LOCAL_DECL duk_uint_fast32_t duk__dec_decode_hex_escape ( duk_json_dec_ctx * js_ctx,
duk_small_uint_t n )

Definition at line 29347 of file duktape-1.8.0/src/duktape.c.

29348 {
29349 DUK_ASSERT(js_ctx->p <= js_ctx->p_end);
29350 return *js_ctx->p;
29351}
29352
29353DUK_LOCAL duk_uint8_t duk__dec_get(duk_json_dec_ctx *js_ctx) {
29354 DUK_ASSERT(js_ctx->p <= js_ctx->p_end);
29355 return *js_ctx->p++;
29356}
29357
29359 duk__dec_eat_white(js_ctx);
29360 return duk__dec_get(js_ctx);
29361}
29362
29363/* For JX, expressing the whole unsigned 32-bit range matters. */
29366 duk_uint_fast32_t res = 0;
29367 duk_uint8_t x;
29369
29370 for (i = 0; i < n; i++) {
29371 /* XXX: share helper from lexer; duk_lexer.c / hexval(). */
29372
29373 x = duk__dec_get(js_ctx);
29374 DUK_DDD(DUK_DDDPRINT("decode_hex_escape: i=%ld, n=%ld, res=%ld, x=%ld",
29375 (long) i, (long) n, (long) res, (long) x));
29376
29377 /* x == 0x00 (EOF) causes syntax_error */
29378 DUK_ASSERT(duk_hex_dectab[0] == -1);
DUK_LOCAL_DECL duk_uint8_t duk__dec_get_nonwhite(duk_json_dec_ctx *js_ctx)
DUK_LOCAL_DECL duk_uint8_t duk__dec_get(duk_json_dec_ctx *js_ctx)
DUK_LOCAL_DECL duk_uint_fast32_t duk__dec_decode_hex_escape(duk_json_dec_ctx *js_ctx, duk_small_uint_t n)
DUK_LOCAL_DECL void duk__dec_eat_white(duk_json_dec_ctx *js_ctx)
DUK_INTERNAL const duk_int8_t duk_hex_dectab[256]

References DUK_ASSERT, duk_json_dec_ctx::p, and duk_json_dec_ctx::p_end.

◆ duk__dec_eat_white()

DUK_LOCAL_DECL void duk__dec_eat_white ( duk_json_dec_ctx * js_ctx)

Definition at line 29301 of file duktape-1.8.0/src/duktape.c.

29309 {
29310 /* Shared handler to minimize parser size. Cause will be
29311 * hidden, unfortunately, but we'll have an offset which
29312 * is often quite enough.
29313 */
29315 (long) (js_ctx->p - js_ctx->p_start));
29316}
29317
29319 const duk_uint8_t *p;
29320 duk_uint8_t t;
29321
29322 p = js_ctx->p;
29323 for (;;) {
29324 DUK_ASSERT(p <= js_ctx->p_end);
29325 t = *p;
29326
29327#if defined(DUK_USE_JSON_EATWHITE_FASTPATH)
29328 /* This fast path is pretty marginal in practice.
29329 * XXX: candidate for removal.
#define DUK_STR_FMT_INVALID_JSON

References DUK_ERR_SYNTAX_ERROR, DUK_ERROR_FMT1, DUK_STR_FMT_INVALID_JSON, duk_json_dec_ctx::p, duk_json_dec_ctx::p_start, and duk_json_dec_ctx::thr.

◆ duk__dec_get()

DUK_LOCAL_DECL duk_uint8_t duk__dec_get ( duk_json_dec_ctx * js_ctx)

Definition at line 29336 of file duktape-1.8.0/src/duktape.c.

29336 {
29337 /* NUL also comes here. Comparison order matters, 0x20
29338 * is most common whitespace.
29339 */

◆ duk__dec_get_nonwhite()

DUK_LOCAL_DECL duk_uint8_t duk__dec_get_nonwhite ( duk_json_dec_ctx * js_ctx)

Definition at line 29341 of file duktape-1.8.0/src/duktape.c.

◆ duk__dec_number()

DUK_LOCAL_DECL void duk__dec_number ( duk_json_dec_ctx * js_ctx)

Definition at line 29732 of file duktape-1.8.0/src/duktape.c.

29742 :
29743 duk__dec_syntax_error(js_ctx);
29745}
29746#endif /* DUK_USE_JX */
29747
29748/* Parse a number, other than NaN or +/- Infinity */
29750 duk_context *ctx = (duk_context *) js_ctx->thr;
29751 const duk_uint8_t *p_start;
29752 const duk_uint8_t *p;
29753 duk_uint8_t x;
29754 duk_small_uint_t s2n_flags;
29755
29756 DUK_DDD(DUK_DDDPRINT("parse_number"));
29757
29758 p_start = js_ctx->p;
29759
29760 /* First pass parse is very lenient (e.g. allows '1.2.3') and extracts a
29761 * string for strict number parsing.
29762 */
29763
29764 p = js_ctx->p;
29765 for (;;) {
29766 x = *p;
29767
29768 DUK_DDD(DUK_DDDPRINT("parse_number: p_start=%p, p=%p, p_end=%p, x=%ld",
29769 (const void *) p_start, (const void *) p,
29770 (const void *) js_ctx->p_end, (long) x));
29771
29772#if defined(DUK_USE_JSON_DECNUMBER_FASTPATH)
29773 /* This fast path is pretty marginal in practice.
29774 * XXX: candidate for removal.
29775 */
29776 DUK_ASSERT(duk__json_decnumber_lookup[0x00] == 0x00); /* end-of-input breaks */
29777 if (duk__json_decnumber_lookup[x] == 0) {
29778 break;
29779 }
29780#else /* DUK_USE_JSON_DECNUMBER_FASTPATH */
29781 if (!((x >= DUK_ASC_0 && x <= DUK_ASC_9) ||
29782 (x == DUK_ASC_PERIOD || x == DUK_ASC_LC_E ||
29783 x == DUK_ASC_UC_E || x == DUK_ASC_MINUS || x == DUK_ASC_PLUS))) {
29784 /* Plus sign must be accepted for positive exponents
29785 * (e.g. '1.5e+2'). This clause catches NULs.
29786 */
29787 break;
29788 }
29789#endif /* DUK_USE_JSON_DECNUMBER_FASTPATH */
29790 p++; /* safe, because matched (NUL causes a break) */
29791 }
29792 js_ctx->p = p;
29793
29794 DUK_ASSERT(js_ctx->p > p_start);
29795 duk_push_lstring(ctx, (const char *) p_start, (duk_size_t) (p - p_start));
DUK_LOCAL_DECL void duk__dec_number(duk_json_dec_ctx *js_ctx)
#define DUK_ASC_9
DUK_EXTERNAL const char * duk_push_lstring(duk_context *ctx, const char *str, duk_size_t len)
#define DUK_ASC_MINUS
#define DUK_ASC_PLUS
DUK_LOCAL const duk_uint8_t duk__json_decnumber_lookup[256]
#define DUK_ASC_0
#define DUK_ASC_LC_E
#define DUK_ASC_PERIOD
#define DUK_ASC_UC_E

◆ duk__dec_objarr_entry()

DUK_LOCAL_DECL void duk__dec_objarr_entry ( duk_json_dec_ctx * js_ctx)

Definition at line 29797 of file duktape-1.8.0/src/duktape.c.

29801 : string before parsing: %!T",
29802 (duk_tval *) duk_get_tval(ctx, -1)));
29803 duk_numconv_parse(ctx, 10 /*radix*/, s2n_flags);
29804 if (duk_is_nan(ctx, -1)) {
29805 duk__dec_syntax_error(js_ctx);
29806 }
29807 DUK_ASSERT(duk_is_number(ctx, -1));
29808 DUK_DDD(DUK_DDDPRINT("parse_number: final number: %!T",
29809 (duk_tval *) duk_get_tval(ctx, -1)));

◆ duk__dec_objarr_exit()

DUK_LOCAL_DECL void duk__dec_objarr_exit ( duk_json_dec_ctx * js_ctx)

Definition at line 29811 of file duktape-1.8.0/src/duktape.c.

29814 {
29815 duk_context *ctx = (duk_context *) js_ctx->thr;
29817
DUK_EXTERNAL void duk_require_stack(duk_context *ctx, duk_idx_t extra)
#define DUK_JSON_DEC_REQSTACK

◆ duk__dec_object()

DUK_LOCAL_DECL void duk__dec_object ( duk_json_dec_ctx * js_ctx)

Definition at line 29819 of file duktape-1.8.0/src/duktape.c.

29822 {
29824 }
29825 js_ctx->recursion_depth++;
29826}
29827
29829 /* c recursion check */
29830
29831 DUK_ASSERT(js_ctx->recursion_depth > 0);
29832 DUK_ASSERT(js_ctx->recursion_depth <= js_ctx->recursion_limit);
29833 js_ctx->recursion_depth--;
29834}
29835
29837 duk_context *ctx = (duk_context *) js_ctx->thr;
29838 duk_int_t key_count; /* XXX: a "first" flag would suffice */
29839 duk_uint8_t x;
29840
29841 DUK_DDD(DUK_DDDPRINT("parse_object"));
29842
29843 duk__dec_objarr_entry(js_ctx);
29844
29845 duk_push_object(ctx);
29846
29847 /* Initial '{' has been checked and eaten by caller. */
29848
29849 key_count = 0;
29850 for (;;) {
29851 x = duk__dec_get_nonwhite(js_ctx);
29852
29853 DUK_DDD(DUK_DDDPRINT("parse_object: obj=%!T, x=%ld, key_count=%ld",
29854 (duk_tval *) duk_get_tval(ctx, -1),
29855 (long) x, (long) key_count));
29856
29857 /* handle comma and closing brace */
29858
29859 if (x == DUK_ASC_COMMA && key_count > 0) {
29860 /* accept comma, expect new value */
29861 x = duk__dec_get_nonwhite(js_ctx);
29862 } else if (x == DUK_ASC_RCURLY) {
29863 /* eat closing brace */
29864 break;
29865 } else if (key_count == 0) {
29866 /* accept anything, expect first value (EOF will be
29867 * caught by key parsing below.
29868 */
29869 ;
29870 } else {
29871 /* catches EOF (NUL) and initial comma */
29872 goto syntax_error;
29873 }
29874
29875 /* parse key and value */
29876
29877 if (x == DUK_ASC_DOUBLEQUOTE) {
29878 duk__dec_string(js_ctx);
29879#ifdef DUK_USE_JX
29880 } else if (js_ctx->flag_ext_custom &&
29882 duk__dec_plain_string(js_ctx);
29883#endif
29884 } else {
29885 goto syntax_error;
29886 }
29887
29888 /* [ ... obj key ] */
29889
29890 x = duk__dec_get_nonwhite(js_ctx);
29891 if (x != DUK_ASC_COLON) {
29892 goto syntax_error;
29893 }
29894
29895 duk__dec_value(js_ctx);
29896
29897 /* [ ... obj key val ] */
29898
29899 duk_xdef_prop_wec(ctx, -3);
29900
#define DUK_ASC_DOUBLEQUOTE
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_identifier_start(duk_codepoint_t cp)
DUK_LOCAL_DECL void duk__dec_object(duk_json_dec_ctx *js_ctx)
#define DUK_ASC_COLON
#define DUK_STR_JSONDEC_RECLIMIT
DUK_EXTERNAL duk_idx_t duk_push_object(duk_context *ctx)
DUK_LOCAL_DECL void duk__dec_plain_string(duk_json_dec_ctx *js_ctx)
#define DUK_ASC_RCURLY
DUK_LOCAL_DECL void duk__dec_string(duk_json_dec_ctx *js_ctx)
DUK_LOCAL_DECL void duk__dec_objarr_exit(duk_json_dec_ctx *js_ctx)
DUK_LOCAL_DECL void duk__dec_objarr_entry(duk_json_dec_ctx *js_ctx)
#define DUK_ASC_COMMA
DUK_LOCAL_DECL void duk__dec_value(duk_json_dec_ctx *js_ctx)

◆ duk__dec_peek()

DUK_LOCAL_DECL duk_uint8_t duk__dec_peek ( duk_json_dec_ctx * js_ctx)

Definition at line 29331 of file duktape-1.8.0/src/duktape.c.

29332 {
29333 break;
29334 }

◆ duk__dec_plain_string()

DUK_LOCAL_DECL void duk__dec_plain_string ( duk_json_dec_ctx * js_ctx)

Definition at line 29577 of file duktape-1.8.0/src/duktape.c.

29585 :
29586 duk__dec_syntax_error(js_ctx);
29588}
29589
29590#ifdef DUK_USE_JX
29591/* Decode a plain string consisting entirely of identifier characters.
29592 * Used to parse plain keys (e.g. "foo: 123").
29593 */
29595 duk_hthread *thr = js_ctx->thr;
29596 duk_context *ctx = (duk_context *) thr;
29597 const duk_uint8_t *p;
29599
29600 /* Caller has already eaten the first char so backtrack one byte. */
29601
29602 js_ctx->p--; /* safe */
29603 p = js_ctx->p;
29604
29605 /* Here again we parse bytes, and non-ASCII UTF-8 will cause end of
29606 * parsing (which is correct except if there are non-shortest encodings).
29607 * There is also no need to check explicitly for end of input buffer as
29608 * the input is NUL padded and NUL will exit the parsing loop.
29609 *
29610 * Because no unescaping takes place, we can just scan to the end of the
29611 * plain string and intern from the input buffer.
29612 */
29613
29614 for (;;) {
29615 x = *p;
29616

◆ duk__dec_pointer()

DUK_LOCAL_DECL void duk__dec_pointer ( duk_json_dec_ctx * js_ctx)

Definition at line 29620 of file duktape-1.8.0/src/duktape.c.

29623 {
29624 break;
29625 }
29626 p++;
29627 }
29628
29629 duk_push_lstring(ctx, (const char *) js_ctx->p, (duk_size_t) (p - js_ctx->p));
29630 js_ctx->p = p;
29631
29632 /* [ ... str ] */
29633}
29634#endif /* DUK_USE_JX */
29635
29636#ifdef DUK_USE_JX
29638 duk_hthread *thr = js_ctx->thr;
29639 duk_context *ctx = (duk_context *) thr;
29640 const duk_uint8_t *p;
29642 void *voidptr;
29643
29644 /* Caller has already eaten the first character ('(') which we don't need. */
29645
29646 p = js_ctx->p;
29647
29648 for (;;) {
29649 x = *p;
29650
29651 /* Assume that the native representation never contains a closing
29652 * parenthesis.
29653 */
29654
29655 if (x == DUK_ASC_RPAREN) {
29656 break;
29657 } else if (x <= 0) {
29658 /* NUL term or -1 (EOF), NUL check would suffice */
29659 goto syntax_error;
29660 }
29661 p++;
29662 }
29663
29664 /* There is no need to NUL delimit the sscanf() call: trailing garbage is
29665 * ignored and there is always a NUL terminator which will force an error
29666 * if no error is encountered before it. It's possible that the scan
29667 * would scan further than between [js_ctx->p,p[ though and we'd advance
29668 * by less than the scanned value.
29669 *
29670 * Because pointers are platform specific, a failure to scan a pointer
DUK_LOCAL_DECL void duk__dec_pointer(duk_json_dec_ctx *js_ctx)
#define DUK_ASC_RPAREN

◆ duk__dec_req_stridx()

DUK_LOCAL_DECL void duk__dec_req_stridx ( duk_json_dec_ctx * js_ctx,
duk_small_uint_t stridx )

Definition at line 29380 of file duktape-1.8.0/src/duktape.c.

29380 {
29381 res = (res * 16) + t;
29382 } else {
29383 /* catches EOF and invalid digits */
29384 goto syntax_error;
29385 }
29386 }
29387
29388 DUK_DDD(DUK_DDDPRINT("final hex decoded value: %ld", (long) res));
29389 return res;
29390
29391 syntax_error:
29392 duk__dec_syntax_error(js_ctx);
29394 return 0;
29395}
29396
29398 duk_hstring *h;
29399 const duk_uint8_t *p;
29400 duk_uint8_t x, y;
29401
29402 /* First character has already been eaten and checked by the caller.
29403 * We can scan until a NUL in stridx string because no built-in strings
29404 * have internal NULs.
29405 */
29406
29407 DUK_ASSERT_DISABLE(stridx >= 0); /* unsigned */
29409 h = DUK_HTHREAD_GET_STRING(js_ctx->thr, stridx);
29410 DUK_ASSERT(h != NULL);
29411
29412 p = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h) + 1;
29413 DUK_ASSERT(*(js_ctx->p - 1) == *(p - 1)); /* first character has been matched */
29414
29415 for (;;) {
29416 x = *p;
#define DUK_HEAP_NUM_STRINGS
#define DUK_HTHREAD_GET_STRING(thr, idx)
DUK_LOCAL_DECL void duk__dec_req_stridx(duk_json_dec_ctx *js_ctx, duk_small_uint_t stridx)

◆ duk__dec_reviver_walk()

DUK_LOCAL_DECL void duk__dec_reviver_walk ( duk_json_dec_ctx * js_ctx)

Definition at line 30042 of file duktape-1.8.0/src/duktape.c.

30050 :
30051 duk__dec_syntax_error(js_ctx);
30053}
30054
30055/* Recursive value reviver, implements the Walk() algorithm. No C recursion
30056 * check is done here because the initial parsing step will already ensure
30057 * there is a reasonable limit on C recursion depth and hence object depth.
30058 */
30060 duk_context *ctx = (duk_context *) js_ctx->thr;
30061 duk_hobject *h;
30062 duk_uarridx_t i, arr_len;
30063
30064 DUK_DDD(DUK_DDDPRINT("walk: top=%ld, holder=%!T, name=%!T",
30065 (long) duk_get_top(ctx),
30066 (duk_tval *) duk_get_tval(ctx, -2),
30067 (duk_tval *) duk_get_tval(ctx, -1)));
30068
30069 duk_dup_top(ctx);
30070 duk_get_prop(ctx, -3); /* -> [ ... holder name val ] */
30071
30072 h = duk_get_hobject(ctx, -1);
30073 if (h != NULL) {
30075 arr_len = (duk_uarridx_t) duk_get_length(ctx, -1);
30076 for (i = 0; i < arr_len; i++) {
30077 /* [ ... holder name val ] */
30078
30079 DUK_DDD(DUK_DDDPRINT("walk: array, top=%ld, i=%ld, arr_len=%ld, holder=%!T, name=%!T, val=%!T",
30080 (long) duk_get_top(ctx), (long) i, (long) arr_len,
30081 (duk_tval *) duk_get_tval(ctx, -3), (duk_tval *) duk_get_tval(ctx, -2),
30082 (duk_tval *) duk_get_tval(ctx, -1)));
30083
30084 /* XXX: push_uint_string / push_u32_string */
30085 duk_dup_top(ctx);
30086 duk_push_uint(ctx, (duk_uint_t) i);
30087 duk_to_string(ctx, -1); /* -> [ ... holder name val val ToString(i) ] */
30088 duk__dec_reviver_walk(js_ctx); /* -> [ ... holder name val new_elem ] */
30089
30090 if (duk_is_undefined(ctx, -1)) {
30091 duk_pop(ctx);
30092 duk_del_prop_index(ctx, -1, i);
30093 } else {
30094 /* XXX: duk_xdef_prop_index_wec() would be more appropriate
30095 * here but it currently makes some assumptions that might
30096 * not hold (e.g. that previous property is not an accessor).
30097 */
30098 duk_put_prop_index(ctx, -2, i);
30099 }
30100 }
30101 } else {
30102 /* [ ... holder name val ] */
30103 duk_enum(ctx, -1, DUK_ENUM_OWN_PROPERTIES_ONLY /*flags*/);
30104 while (duk_next(ctx, -1 /*enum_index*/, 0 /*get_value*/)) {
30105 DUK_DDD(DUK_DDDPRINT("walk: object, top=%ld, holder=%!T, name=%!T, val=%!T, enum=%!iT, obj_key=%!T",
30106 (long) duk_get_top(ctx), (duk_tval *) duk_get_tval(ctx, -5),
30107 (duk_tval *) duk_get_tval(ctx, -4), (duk_tval *) duk_get_tval(ctx, -3),
30108 (duk_tval *) duk_get_tval(ctx, -2), (duk_tval *) duk_get_tval(ctx, -1)));
30109
30110 /* [ ... holder name val enum obj_key ] */
30111 duk_dup(ctx, -3);
30112 duk_dup(ctx, -2);
30113
30114 /* [ ... holder name val enum obj_key val obj_key ] */
30115 duk__dec_reviver_walk(js_ctx);
30116
30117 /* [ ... holder name val enum obj_key new_elem ] */
30118 if (duk_is_undefined(ctx, -1)) {
30119 duk_pop(ctx);
30120 duk_del_prop(ctx, -3);
30121 } else {
30122 /* XXX: duk_xdef_prop_index_wec() would be more appropriate
30123 * here but it currently makes some assumptions that might
30124 * not hold (e.g. that previous property is not an accessor).
30125 *
30126 * Using duk_put_prop() works incorrectly with '__proto__'
30127 * if the own property with that name has been deleted. This
30128 * does not happen normally, but a clever reviver can trigger
30129 * that, see complex reviver case in: test-bug-json-parse-__proto__.js.
#define DUK_ENUM_OWN_PROPERTIES_ONLY
DUK_EXTERNAL void duk_enum(duk_context *ctx, duk_idx_t obj_index, duk_uint_t enum_flags)
DUK_EXTERNAL duk_bool_t duk_del_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index)
DUK_LOCAL_DECL void duk__dec_reviver_walk(duk_json_dec_ctx *js_ctx)
DUK_EXTERNAL duk_bool_t duk_next(duk_context *ctx, duk_idx_t enum_index, duk_bool_t get_value)
DUK_EXTERNAL duk_size_t duk_get_length(duk_context *ctx, duk_idx_t index)
#define DUK_HOBJECT_CLASS_ARRAY
DUK_EXTERNAL void duk_dup_top(duk_context *ctx)
DUK_EXTERNAL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_index)
DUK_EXTERNAL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_index)

◆ duk__dec_string()

DUK_LOCAL_DECL void duk__dec_string ( duk_json_dec_ctx * js_ctx)

Definition at line 29467 of file duktape-1.8.0/src/duktape.c.

29468 {
29469 return 1; /* syntax error */
29470 }
29471 break;
29472 }
29473#endif /* DUK_USE_JX */
29474 default:
29475 /* catches EOF (0x00) */
29476 return 1; /* syntax error */
29477 }
29478
29479 DUK_RAW_WRITE_XUTF8(*ext_p, cp);
29480
29481 return 0;
29482}
29483
29485 duk_hthread *thr = js_ctx->thr;
29486 duk_context *ctx = (duk_context *) thr;
29487 duk_bufwriter_ctx bw_alloc;
29489 duk_uint8_t *q;
29490
29491 /* '"' was eaten by caller */
29492
29493 /* Note that we currently parse -bytes-, not codepoints.
29494 * All non-ASCII extended UTF-8 will encode to bytes >= 0x80,
29495 * so they'll simply pass through (valid UTF-8 or not).
29496 */
29497
29498 bw = &bw_alloc;
29500 q = DUK_BW_GET_PTR(js_ctx->thr, bw);
29501
29502#if defined(DUK_USE_JSON_DECSTRING_FASTPATH)
29503 for (;;) {
29504 duk_small_uint_t safe;
29505 duk_uint8_t b, x;
29506 const duk_uint8_t *p;
29507
29508 /* Select a safe loop count where no output checks are
29509 * needed assuming we won't encounter escapes. Input
29510 * bound checks are not necessary as a NUL (guaranteed)
29511 * will cause a SyntaxError before we read out of bounds.
29512 */
29513
29515
29516 /* Ensure space for 1:1 output plus one escape. */
29517 q = DUK_BW_ENSURE_RAW(js_ctx->thr, bw, safe + DUK_UNICODE_MAX_XUTF8_LENGTH, q);
29518
29519 p = js_ctx->p; /* temp copy, write back for next loop */
29520 for (;;) {
29521 if (safe == 0) {
29522 js_ctx->p = p;
29523 break;
29524 }
29525 safe--;
29526
29527 /* End of input (NUL) goes through slow path and causes SyntaxError. */
29529
29530 b = *p++;
29532 if (DUK_LIKELY(x != 0)) {
29533 /* Fast path, decode as is. */
29534 *q++ = b;
29535 } else if (b == DUK_ASC_DOUBLEQUOTE) {
29536 js_ctx->p = p;
29537 goto found_quote;
29538 } else if (b == DUK_ASC_BACKSLASH) {
29539 /* We've ensured space for one escaped input; then
29540 * bail out and recheck (this makes escape handling
29541 * quite slow but it's uncommon).
29542 */
29543 js_ctx->p = p;
29544 if (duk__dec_string_escape(js_ctx, &q) != 0) {
29545 goto syntax_error;
29546 }
29547 break;
29548 } else {
29549 js_ctx->p = p;
29550 goto syntax_error;
29551 }
29552 }
29553 }
29554 found_quote:
29555#else /* DUK_USE_JSON_DECSTRING_FASTPATH */
29556 for (;;) {
29557 duk_uint8_t x;
29558
29560
29561 x = duk__dec_get(js_ctx);
29562
29563 if (x == DUK_ASC_DOUBLEQUOTE) {
29564 break;
29565 } else if (x == DUK_ASC_BACKSLASH) {
29566 if (duk__dec_string_escape(js_ctx, &q) != 0) {
29567 goto syntax_error;
29568 }
29569 } else if (x < 0x20) {
29570 /* catches EOF (NUL) */
29571 goto syntax_error;
DUK_LOCAL const duk_uint8_t duk__json_decstr_lookup[256]
#define DUK__JSON_DECSTR_CHUNKSIZE
#define DUK__JSON_DECSTR_BUFSIZE
DUK_LOCAL duk_small_int_t duk__dec_string_escape(duk_json_dec_ctx *js_ctx, duk_uint8_t **ext_p)
#define DUK_ASC_BACKSLASH
#define DUK_BW_ENSURE_RAW(thr, bw_ctx, sz, ptr)
#define DUK_BW_INIT_PUSHBUF(thr, bw_ctx, sz)
#define DUK_BW_GET_PTR(thr, bw_ctx)
#define DUK_RAW_WRITE_XUTF8(ptr, val)

◆ duk__dec_string_escape()

DUK_LOCAL duk_small_int_t duk__dec_string_escape ( duk_json_dec_ctx * js_ctx,
duk_uint8_t ** ext_p )

Definition at line 29418 of file duktape-1.8.0/src/duktape.c.

29421 {
29422 /* Catches EOF of JSON input. */
29423 goto syntax_error;
29424 }
29425 p++;
29426 }
29427
29428 return;
29429
29430 syntax_error:
29431 duk__dec_syntax_error(js_ctx);
29433}
29434
29437
29438 /* EOF (-1) will be cast to an unsigned value first
29439 * and then re-cast for the switch. In any case, it
29440 * will match the default case (syntax error).
29441 */
29442 cp = (duk_uint_fast32_t) duk__dec_get(js_ctx);
29443 switch ((int) cp) {
29444 case DUK_ASC_BACKSLASH: break;
29445 case DUK_ASC_DOUBLEQUOTE: break;
29446 case DUK_ASC_SLASH: break;
29447 case DUK_ASC_LC_T: cp = 0x09; break;
29448 case DUK_ASC_LC_N: cp = 0x0a; break;
29449 case DUK_ASC_LC_R: cp = 0x0d; break;
29450 case DUK_ASC_LC_F: cp = 0x0c; break;
29451 case DUK_ASC_LC_B: cp = 0x08; break;
29452 case DUK_ASC_LC_U: {
29453 cp = duk__dec_decode_hex_escape(js_ctx, 4);
29454 break;
29455 }
29456#ifdef DUK_USE_JX
29457 case DUK_ASC_UC_U: {
29458 if (js_ctx->flag_ext_custom) {
29459 cp = duk__dec_decode_hex_escape(js_ctx, 8);
29460 } else {
29461 return 1; /* syntax error */
29462 }
29463 break;
29464 }
29465 case DUK_ASC_LC_X: {
#define DUK_ASC_SLASH
#define DUK_ASC_LC_N
#define DUK_ASC_LC_U
#define DUK_ASC_LC_X
#define DUK_ASC_LC_B
#define DUK_ASC_LC_R
#define DUK_ASC_LC_F
#define DUK_ASC_UC_U
#define DUK_ASC_LC_T

◆ duk__dec_syntax_error()

DUK_LOCAL_DECL void duk__dec_syntax_error ( duk_json_dec_ctx * js_ctx)

Definition at line 29292 of file duktape-1.8.0/src/duktape.c.

◆ duk__dec_value()

DUK_LOCAL_DECL void duk__dec_value ( duk_json_dec_ctx * js_ctx)

Definition at line 29970 of file duktape-1.8.0/src/duktape.c.

29976 : final array is %!T",
29977 (duk_tval *) duk_get_tval(ctx, -1)));
29978
29979 duk__dec_objarr_exit(js_ctx);
29980 return;
29981
29982 syntax_error:
29983 duk__dec_syntax_error(js_ctx);
29984 DUK_UNREACHABLE();
29985}
29986
29987DUK_LOCAL void duk__dec_value(duk_json_dec_ctx *js_ctx) {
29988 duk_context *ctx = (duk_context *) js_ctx->thr;
29989 duk_uint8_t x;
29990
29991 x = duk__dec_get_nonwhite(js_ctx);
29992
29993 DUK_DDD(DUK_DDDPRINT("parse_value: initial x=%ld", (long) x));
29994
29995 /* Note: duk__dec_req_stridx() backtracks one char */
29996
29997 if (x == DUK_ASC_DOUBLEQUOTE) {
29998 duk__dec_string(js_ctx);
29999 } else if ((x >= DUK_ASC_0 && x <= DUK_ASC_9) || (x == DUK_ASC_MINUS)) {
30000#ifdef DUK_USE_JX
30001 if (js_ctx->flag_ext_custom && x == DUK_ASC_MINUS && duk__dec_peek(js_ctx) == DUK_ASC_UC_I) {
30002 duk__dec_req_stridx(js_ctx, DUK_STRIDX_MINUS_INFINITY); /* "-Infinity", '-' has been eaten */
30003 duk_push_number(ctx, -DUK_DOUBLE_INFINITY);
30004 } else {
30005#else
30006 { /* unconditional block */
30007#endif
30008 /* We already ate 'x', so backup one byte. */
30009 js_ctx->p--; /* safe */
30010 duk__dec_number(js_ctx);
30011 }
30012 } else if (x == DUK_ASC_LC_T) {
30013 duk__dec_req_stridx(js_ctx, DUK_STRIDX_TRUE);
30014 duk_push_true(ctx);
30015 } else if (x == DUK_ASC_LC_F) {
30016 duk__dec_req_stridx(js_ctx, DUK_STRIDX_FALSE);
30017 duk_push_false(ctx);
30018 } else if (x == DUK_ASC_LC_N) {
30019 duk__dec_req_stridx(js_ctx, DUK_STRIDX_LC_NULL);
30020 duk_push_null(ctx);
30021#ifdef DUK_USE_JX
30022 } else if (js_ctx->flag_ext_custom && x == DUK_ASC_LC_U) {
30023 duk__dec_req_stridx(js_ctx, DUK_STRIDX_LC_UNDEFINED);
30024 duk_push_undefined(ctx);
30025 } else if (js_ctx->flag_ext_custom && x == DUK_ASC_UC_N) {
30026 duk__dec_req_stridx(js_ctx, DUK_STRIDX_NAN);
30027 duk_push_nan(ctx);
30028 } else if (js_ctx->flag_ext_custom && x == DUK_ASC_UC_I) {
30029 duk__dec_req_stridx(js_ctx, DUK_STRIDX_INFINITY);
30030 duk_push_number(ctx, DUK_DOUBLE_INFINITY);
30031 } else if (js_ctx->flag_ext_custom && x == DUK_ASC_LPAREN) {
30032 duk__dec_pointer(js_ctx);
30033 } else if (js_ctx->flag_ext_custom && x == DUK_ASC_PIPE) {
30034 duk__dec_buffer(js_ctx);
30035#endif
30036 } else if (x == DUK_ASC_LCURLY) {

◆ duk__declvar_helper()

DUK_LOCAL duk_bool_t duk__declvar_helper ( duk_hthread * thr,
duk_hobject * env,
duk_hstring * name,
duk_tval * val,
duk_small_int_t prop_flags,
duk_bool_t is_func_decl )

Definition at line 73045 of file duktape-1.8.0/src/duktape.c.

73067 {
73068 duk_context *ctx = (duk_context *) thr;
73069 duk_hobject *holder;
73070 duk_bool_t parents;
73072 duk_tval *tv;
73073
73074 DUK_DDD(DUK_DDDPRINT("declvar: thr=%p, env=%p, name=%!O, val=%!T, prop_flags=0x%08lx, is_func_decl=%ld "
73075 "(env -> %!iO)",
73076 (void *) thr, (void *) env, (duk_heaphdr *) name,
73077 (duk_tval *) val, (unsigned long) prop_flags,
73078 (unsigned int) is_func_decl, (duk_heaphdr *) env));
73079
73080 DUK_ASSERT(thr != NULL);
73081 DUK_ASSERT(env != NULL);
73082 DUK_ASSERT(name != NULL);
73083 DUK_ASSERT(val != NULL);
73084
73085 /* Note: in strict mode the compiler should reject explicit
73086 * declaration of 'eval' or 'arguments'. However, internal
73087 * bytecode may declare 'arguments' in the function prologue.
73088 * We don't bother checking (or asserting) for these now.
73089 */
73090
73091 /* Note: val is a stable duk_tval pointer. The caller makes
73092 * a value copy into its stack frame, so 'tv_val' is not subject
73093 * to side effects here.
73094 */
73095
73096 /*
73097 * Check whether already declared.
73098 *
73099 * We need to check whether the binding exists in the environment
73100 * without walking its parents. However, we still need to check
73101 * register-bound identifiers and the prototype chain of an object
73102 * environment target object.
73103 */
73104
73105 parents = 0; /* just check 'env' */
73106 if (duk__get_identifier_reference(thr, env, name, NULL, parents, &ref)) {
73107 duk_int_t e_idx;
73108 duk_int_t h_idx;
73109 duk_small_int_t flags;
73110
73111 /*
73112 * Variable already declared, ignore re-declaration.
73113 * The only exception is the updated behavior of E5.1 for
73114 * global function declarations, E5.1 Section 10.5, step 5.e.
73115 * This behavior does not apply to global variable declarations.
73116 */
73117
73118 if (!(is_func_decl && env == thr->builtins[DUK_BIDX_GLOBAL_ENV])) {
73119 DUK_DDD(DUK_DDDPRINT("re-declare a binding, ignoring"));
73120 return 1; /* 1 -> needs a PUTVAR */
73121 }
73122
73123 /*
73124 * Special behavior in E5.1.
73125 *
73126 * Note that even though parents == 0, the conflicting property
73127 * may be an inherited property (currently our global object's
73128 * prototype is Object.prototype). Step 5.e first operates on
73129 * the existing property (which is potentially in an ancestor)
73130 * and then defines a new property in the global object (and
73131 * never modifies the ancestor).
73132 *
73133 * Also note that this logic would become even more complicated
73134 * if the conflicting property might be a virtual one. Object
73135 * prototype has no virtual properties, though.
73136 *
73137 * XXX: this is now very awkward, rework.
73138 */
73139
73140 DUK_DDD(DUK_DDDPRINT("re-declare a function binding in global object, "
73141 "updated E5.1 processing"));
73142
73143 DUK_ASSERT(ref.holder != NULL);
73144 holder = ref.holder;
73145
73146 /* holder will be set to the target object, not the actual object
73147 * where the property was found (see duk__get_identifier_reference()).
73148 */
73150 DUK_ASSERT(!DUK_HOBJECT_HAS_EXOTIC_ARRAY(holder)); /* global object doesn't have array part */
73151
73152 /* XXX: use a helper for prototype traversal; no loop check here */
73153 /* must be found: was found earlier, and cannot be inherited */
73154 for (;;) {
73155 DUK_ASSERT(holder != NULL);
73156 duk_hobject_find_existing_entry(thr->heap, holder, name, &e_idx, &h_idx);
73157 if (e_idx >= 0) {
73158 break;
73159 }
73160 /* SCANBUILD: NULL pointer dereference, doesn't actually trigger,
73161 * asserted above.
73162 */
73163 holder = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, holder);
73164 }
73165 DUK_ASSERT(holder != NULL);
73166 DUK_ASSERT(e_idx >= 0);
73167 /* SCANBUILD: scan-build produces a NULL pointer dereference warning
73168 * below; it never actually triggers because holder is actually never
73169 * NULL.
73170 */
73171
73172 /* ref.holder is global object, holder is the object with the
73173 * conflicting property.
73174 */
73175
73176 flags = DUK_HOBJECT_E_GET_FLAGS(thr->heap, holder, e_idx);
73177 if (!(flags & DUK_PROPDESC_FLAG_CONFIGURABLE)) {
73178 if (flags & DUK_PROPDESC_FLAG_ACCESSOR) {
73179 DUK_DDD(DUK_DDDPRINT("existing property is a non-configurable "
73180 "accessor -> reject"));
73181 goto fail_existing_attributes;
73182 }
73183 if (!((flags & DUK_PROPDESC_FLAG_WRITABLE) &&
73184 (flags & DUK_PROPDESC_FLAG_ENUMERABLE))) {
73185 DUK_DDD(DUK_DDDPRINT("existing property is a non-configurable "
73186 "plain property which is not writable and "
73187 "enumerable -> reject"));
73188 goto fail_existing_attributes;
73189 }
73190
73191 DUK_DDD(DUK_DDDPRINT("existing property is not configurable but "
73192 "is plain, enumerable, and writable -> "
73193 "allow redeclaration"));
73194 }
73195
73196 if (holder == ref.holder) {
73197 /* XXX: if duk_hobject_define_property_internal() was updated
73198 * to handle a pre-existing accessor property, this would be
73199 * a simple call (like for the ancestor case).
73200 */
73201 DUK_DDD(DUK_DDDPRINT("redefine, offending property in global object itself"));
73202
73203 if (flags & DUK_PROPDESC_FLAG_ACCESSOR) {
73204 duk_hobject *tmp;
73205
73206 tmp = DUK_HOBJECT_E_GET_VALUE_GETTER(thr->heap, holder, e_idx);
73207 DUK_HOBJECT_E_SET_VALUE_GETTER(thr->heap, holder, e_idx, NULL);
73209 DUK_UNREF(tmp);
73210 tmp = DUK_HOBJECT_E_GET_VALUE_SETTER(thr->heap, holder, e_idx);
73211 DUK_HOBJECT_E_SET_VALUE_SETTER(thr->heap, holder, e_idx, NULL);
73213 DUK_UNREF(tmp);
73214 } else {
73215 tv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, holder, e_idx);
73217 }
73218
73219 /* Here val would be potentially invalid if we didn't make
73220 * a value copy at the caller.
73221 */
73222
73223 tv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, holder, e_idx);
73224 DUK_TVAL_SET_TVAL(tv, val);
73225 DUK_TVAL_INCREF(thr, tv);
73226 DUK_HOBJECT_E_SET_FLAGS(thr->heap, holder, e_idx, prop_flags);
73227
73228 DUK_DDD(DUK_DDDPRINT("updated global binding, final result: "
73229 "value -> %!T, prop_flags=0x%08lx",
73230 (duk_tval *) DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, holder, e_idx),
73231 (unsigned long) prop_flags));
73232 } else {
73233 DUK_DDD(DUK_DDDPRINT("redefine, offending property in ancestor"));
73234
73235 DUK_ASSERT(ref.holder == thr->builtins[DUK_BIDX_GLOBAL]);
73236 duk_push_tval(ctx, val);
73237 duk_hobject_define_property_internal(thr, ref.holder, name, prop_flags);
73238 }
73239
73240 return 0;
73241 }
73242
73243 /*
73244 * Not found (in registers or record objects). Declare
73245 * to current variable environment.
73246 */
73247
73248 /*
73249 * Get holder object
73250 */
73251
73252 if (DUK_HOBJECT_IS_DECENV(env)) {
73253 holder = env;
73254 } else {
73256
73258 DUK_ASSERT(tv != NULL);
73260 holder = DUK_TVAL_GET_OBJECT(tv);
73261 DUK_ASSERT(holder != NULL);
73262 }
73263
73264 /*
73265 * Define new property
73266 *
73267 * Note: this may fail if the holder is not extensible.
73268 */
73269
73270 /* XXX: this is awkward as we use an internal method which doesn't handle
73271 * extensibility etc correctly. Basically we'd want to do a [[DefineOwnProperty]]
73272 * or Object.defineProperty() here.
73273 */
73274
#define DUK_HOBJECT_DECREF_ALLOWNULL(thr, h)
#define DUK_HOBJECT_HAS_EXOTIC_ARRAY(h)
#define DUK_HOBJECT_GET_PROTOTYPE(heap, h)
#define DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(heap, h, i)
#define DUK_HOBJECT_IS_OBJENV(h)
#define DUK_HTHREAD_STRING_INT_TARGET(thr)
#define DUK_HOBJECT_E_GET_VALUE_SETTER(heap, h, i)
DUK_INTERNAL_DECL void duk_hobject_define_property_internal(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_small_uint_t flags)
#define DUK_BIDX_GLOBAL_ENV
#define DUK_HOBJECT_CLASS_GLOBAL
#define DUK_HOBJECT_E_SET_VALUE_SETTER(heap, h, i, v)
#define DUK_HOBJECT_E_SET_FLAGS(heap, h, i, f)
#define DUK_HOBJECT_IS_DECENV(h)
DUK_LOCAL duk_bool_t duk__get_identifier_reference(duk_hthread *thr, duk_hobject *env, duk_hstring *name, duk_activation *act, duk_bool_t parents, duk__id_lookup_result *out)
#define DUK_HOBJECT_E_SET_VALUE_GETTER(heap, h, i, v)
#define DUK_TVAL_SET_UNDEFINED_UPDREF
#define DUK_HOBJECT_E_GET_VALUE_GETTER(heap, h, i)
DUK_INTERNAL_DECL void duk_hobject_find_existing_entry(duk_heap *heap, duk_hobject *obj, duk_hstring *key, duk_int_t *e_idx, duk_int_t *h_idx)
DUK_INTERNAL_DECL duk_tval * duk_hobject_find_existing_entry_tval_ptr(duk_heap *heap, duk_hobject *obj, duk_hstring *key)

References duk_hthread::builtins, duk__get_identifier_reference(), DUK_ASSERT, DUK_BIDX_GLOBAL, DUK_BIDX_GLOBAL_ENV, DUK_DDD, DUK_DDDPRINT, DUK_HOBJECT_CLASS_GLOBAL, DUK_HOBJECT_DECREF_ALLOWNULL, duk_hobject_define_property_internal(), DUK_HOBJECT_E_GET_FLAGS, DUK_HOBJECT_E_GET_VALUE_GETTER, DUK_HOBJECT_E_GET_VALUE_SETTER, DUK_HOBJECT_E_GET_VALUE_TVAL_PTR, DUK_HOBJECT_E_SET_FLAGS, DUK_HOBJECT_E_SET_VALUE_GETTER, DUK_HOBJECT_E_SET_VALUE_SETTER, duk_hobject_find_existing_entry(), duk_hobject_find_existing_entry_tval_ptr(), DUK_HOBJECT_GET_CLASS_NUMBER, DUK_HOBJECT_GET_PROTOTYPE, DUK_HOBJECT_HAS_EXOTIC_ARRAY, DUK_HOBJECT_HAS_EXTENSIBLE, DUK_HOBJECT_IS_DECENV, DUK_HOBJECT_IS_OBJENV, DUK_HTHREAD_STRING_INT_TARGET, DUK_PROPDESC_FLAG_ACCESSOR, DUK_PROPDESC_FLAG_CONFIGURABLE, DUK_PROPDESC_FLAG_ENUMERABLE, DUK_PROPDESC_FLAG_WRITABLE, duk_push_tval(), DUK_TVAL_GET_OBJECT, DUK_TVAL_INCREF, DUK_TVAL_IS_OBJECT, DUK_TVAL_SET_TVAL, DUK_TVAL_SET_UNDEFINED_UPDREF, DUK_UNREF, duk_hthread::heap, duk__id_lookup_result::holder, name, and NULL.

◆ duk__decode_hex_escape()

DUK_LOCAL duk_small_int_t duk__decode_hex_escape ( const duk_uint8_t * p,
duk_small_int_t n )

Definition at line 27904 of file duktape-1.8.0/src/duktape.c.

27909 {
27910 duk_hthread *thr;
27911 duk_hstring *h_str;
27913 const duk_uint8_t *p;
27914 const duk_uint8_t *p_start;
27915 const duk_uint8_t *p_end;
27917
27918typedef void (*duk__transform_callback)(duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp);
27919
void(* duk__transform_callback)(duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp)

◆ duk__decode_hexesc_from_window()

DUK_LOCAL duk_codepoint_t duk__decode_hexesc_from_window ( duk_lexer_ctx * lex_ctx,
duk_small_int_t lookup_offset )

Definition at line 73938 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ duk__decode_uniesc_from_window()

DUK_LOCAL duk_codepoint_t duk__decode_uniesc_from_window ( duk_lexer_ctx * lex_ctx,
duk_small_int_t lookup_offset )

Definition at line 73944 of file duktape-1.8.0/src/duktape.c.

73948 {
73949 if (DUK_LIKELY(x >= 0 && x <= 0xff)) {
73950 return (duk_hex_dectab[x] >= 0);

Referenced by duk_lexer_parse_js_input_element().

◆ duk__defaultvalue_coerce_attempt()

DUK_LOCAL duk_bool_t duk__defaultvalue_coerce_attempt ( duk_context * ctx,
duk_idx_t index,
duk_small_int_t func_stridx )

Definition at line 16783 of file duktape-1.8.0/src/duktape.c.

16783 {
16784 return;
16785 }
16786
16787 duk_hobject_set_length(thr, h, (duk_uint32_t) length); /* XXX: typing */
16788}
16789
16790/*
16791 * Conversions and coercions
16792 *
16793 * The conversion/coercions are in-place operations on the value stack.
16794 * Some operations are implemented here directly, while others call a
16795 * helper in duk_js_ops.c after validating arguments.
16796 */
16797
16798/* E5 Section 8.12.8 */
DUK_INTERNAL_DECL void duk_hobject_set_length(duk_hthread *thr, duk_hobject *obj, duk_uint32_t length)

◆ duk__delvar_helper()

DUK_LOCAL duk_bool_t duk__delvar_helper ( duk_hthread * thr,
duk_hobject * env,
duk_activation * act,
duk_hstring * name )

Definition at line 72931 of file duktape-1.8.0/src/duktape.c.

72931 :
72932 * 11.4.1 The delete operator
72933 * 10.2.1.1.5 DeleteBinding (N) [declarative environment record]
72934 * 10.2.1.2.5 DeleteBinding (N) [object environment record]
72935 *
72936 * Variable bindings established inside eval() are deletable (configurable),
72937 * other bindings are not, including variables declared in global level.
72938 * Registers are always non-deletable, and the deletion of other bindings
72939 * is controlled by the configurable flag.
72940 *
72941 * For strict mode code, the 'delete' operator should fail with a compile
72942 * time SyntaxError if applied to identifiers. Hence, no strict mode
72943 * run-time deletion of identifiers should ever happen. This function
72944 * should never be called from strict mode code!
72945 */
72946
72949 duk_hobject *env,
72950 duk_activation *act,
72951 duk_hstring *name) {
72953 duk_bool_t parents;
72954
72955 DUK_DDD(DUK_DDDPRINT("delvar: thr=%p, env=%p, act=%p, name=%!O "
72956 "(env -> %!dO)",
72957 (void *) thr, (void *) env, (void *) act,
72958 (duk_heaphdr *) name, (duk_heaphdr *) env));
72959
72960 DUK_ASSERT(thr != NULL);
72961 DUK_ASSERT(name != NULL);
72962 /* env and act may be NULL */
72963
72965
72966 parents = 1; /* follow parent chain */
72967
72968 if (duk__get_identifier_reference(thr, env, name, act, parents, &ref)) {
72969 if (ref.value && !(ref.attrs & DUK_PROPDESC_FLAG_CONFIGURABLE)) {
72970 /* Identifier found in registers (always non-deletable)
72971 * or declarative environment record and non-configurable.
72972 */
72973 return 0;
72974 }
72975 DUK_ASSERT(ref.holder != NULL);
#define DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR(h)
DUK_LOCAL duk_bool_t duk__delvar_helper(duk_hthread *thr, duk_hobject *env, duk_activation *act, duk_hstring *name)

References duk__id_lookup_result::attrs, duk__get_identifier_reference(), DUK_ASSERT, DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR, DUK_DDD, DUK_DDDPRINT, duk_hobject_delprop_raw(), DUK_PROPDESC_FLAG_CONFIGURABLE, duk__id_lookup_result::holder, name, NULL, and duk__id_lookup_result::value.

◆ duk__div_floor()

DUK_LOCAL duk_int_t duk__div_floor ( duk_int_t a,
duk_int_t b )

Definition at line 25094 of file duktape-1.8.0/src/duktape.c.

25095 {
25096 if (!DUK_ISFINITE(x)) {
25097 return DUK_DOUBLE_NAN;
25098 }
25099
25101 return DUK_DOUBLE_NAN;
25102 }
25103
25105
DUK_INTERNAL_DECL duk_double_t duk_js_tointeger_number(duk_double_t x)
DUK_INTERNAL_DECL duk_bool_t duk_bi_date_timeval_in_valid_range(duk_double_t x)

References duk_bi_date_timeval_in_valid_range(), DUK_DOUBLE_NAN, DUK_ISFINITE, and duk_js_tointeger_number().

◆ duk__do_compile()

DUK_LOCAL duk_ret_t duk__do_compile ( duk_context * ctx)

Definition at line 13643 of file duktape-1.8.0/src/duktape.c.

13644 {
13645 duk_call_method(ctx, 0);
13646 rc = DUK_EXEC_SUCCESS;
13647 }
13648
13649 /* [ ... result/error ] */
13650
13651 got_rc:
13652 if (flags & DUK_COMPILE_NORESULT) {
13653 duk_pop(ctx);
13654 }
13655
13656 return rc;
13657}
13658
13659/* Helper which can be called both directly and with duk_safe_call(). */
13661 duk_hthread *thr = (duk_hthread *) ctx;
13662 duk__compile_raw_args *comp_args;
13663 duk_uint_t flags;
13664 duk_small_uint_t comp_flags;
13665 duk_hcompiledfunction *h_templ;
13666
13668
13669 /* Note: strictness is not inherited from the current Duktape/C
13670 * context. Otherwise it would not be possible to compile
13671 * non-strict code inside a Duktape/C activation (which is
13672 * always strict now). See tests/api/test-eval-strictness.c
13673 * for discussion.
13674 */
13675
13676 /* [ ... source? filename? &comp_args ] (depends on flags) */
13677
13678 comp_args = (duk__compile_raw_args *) duk_require_pointer(ctx, -1);
13679 flags = comp_args->flags;
13680 duk_pop(ctx);
13681
13682 /* [ ... source? filename? ] */
13683
13684 if (flags & DUK_COMPILE_NOFILENAME) {
13685 /* Automatic filename: 'eval' or 'input'. */
13687 }
13688
13689 /* [ ... source? filename ] */
13690
13691 if (!comp_args->src_buffer) {
13692 duk_hstring *h_sourcecode;
13693
13694 h_sourcecode = duk_get_hstring(ctx, -2);
13695 if ((flags & DUK_COMPILE_NOSOURCE) || /* args incorrect */
13696 (h_sourcecode == NULL)) { /* e.g. duk_push_string_file_raw() pushed undefined */
13697 /* XXX: when this error is caused by a nonexistent
13698 * file given to duk_peval_file() or similar, the
13699 * error message is not the best possible.
13700 */
13702 }
13703 DUK_ASSERT(h_sourcecode != NULL);
13704 comp_args->src_buffer = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_sourcecode);
13705 comp_args->src_length = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h_sourcecode);
13706 }
13707 DUK_ASSERT(comp_args->src_buffer != NULL);
13708
13709 /* XXX: unnecessary translation of flags */
13710 comp_flags = 0;
13711 if (flags & DUK_COMPILE_EVAL) {
13712 comp_flags |= DUK_JS_COMPILE_FLAG_EVAL;
13713 }
13714 if (flags & DUK_COMPILE_FUNCTION) {
13715 comp_flags |= DUK_JS_COMPILE_FLAG_EVAL |
13717 }
13718 if (flags & DUK_COMPILE_STRICT) {
13719 comp_flags |= DUK_JS_COMPILE_FLAG_STRICT;
13720 }
13721
13722 /* [ ... source? filename ] */
13723
13724 duk_js_compile(thr, comp_args->src_buffer, comp_args->src_length, comp_flags);
13725
13726 /* [ ... source? func_template ] */
13727
13728 if (flags & DUK_COMPILE_NOSOURCE) {
13729 ;
13730 } else {
13731 duk_remove(ctx, -2);
#define DUK_COMPILE_NORESULT
#define DUK_COMPILE_FUNCTION
#define DUK_COMPILE_NOSOURCE
#define DUK_COMPILE_NOFILENAME
#define DUK_STR_NO_SOURCECODE
#define DUK_JS_COMPILE_FLAG_EVAL
DUK_EXTERNAL void * duk_require_pointer(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL duk_hstring * duk_get_hstring(duk_context *ctx, duk_idx_t index)
#define DUK_JS_COMPILE_FLAG_FUNCEXPR
#define DUK_STRIDX_EVAL
DUK_EXTERNAL void duk_call_method(duk_context *ctx, duk_idx_t nargs)
#define DUK_JS_COMPILE_FLAG_STRICT
#define DUK_STRIDX_INPUT
DUK_LOCAL duk_ret_t duk__do_compile(duk_context *ctx)
DUK_INTERNAL_DECL void duk_js_compile(duk_hthread *thr, const duk_uint8_t *src_buffer, duk_size_t src_length, duk_small_uint_t flags)

◆ duk__do_intern()

DUK_LOCAL duk_hstring * duk__do_intern ( duk_heap * heap,
const duk_uint8_t * str,
duk_uint32_t blen,
duk_uint32_t strhash )

Definition at line 45838 of file duktape-1.8.0/src/duktape.c.

45855 {
45856 duk_hstring *res;
45857 const duk_uint8_t *extdata;
45858#if defined(DUK_USE_MARK_AND_SWEEP)
45859 duk_small_uint_t prev_mark_and_sweep_base_flags;
45860#endif
45861
45862 /* Prevent any side effects on the string table and the caller provided
45863 * str/blen arguments while interning is in progress. For example, if
45864 * the caller provided str/blen from a dynamic buffer, a finalizer might
45865 * resize that dynamic buffer, invalidating the call arguments.
45866 */
45867#if defined(DUK_USE_MARK_AND_SWEEP)
45869 prev_mark_and_sweep_base_flags = heap->mark_and_sweep_base_flags;
45871#endif
45872
45873#if defined(DUK_USE_STRTAB_PROBE)
45874 if (duk__recheck_strtab_size_probe(heap, heap->st_used + 1)) {
45875 goto failed;
45876 }
45877#endif
45878
45879 /* For manual testing only. */
45880#if 0
45881 {
45882 duk_size_t i;
45883 DUK_PRINTF("INTERN: \"");
45884 for (i = 0; i < blen; i++) {
45885 duk_uint8_t x = str[i];
45886 if (x >= 0x20 && x <= 0x7e && x != '"' && x != '\\') {
45887 DUK_PRINTF("%c", (int) x); /* char: use int cast */
45888 } else {
45889 DUK_PRINTF("\\x%02lx", (long) x);
45890 }
45891 }
45892 DUK_PRINTF("\"\n");
45893 }
45894#endif
45895
45896#if defined(DUK_USE_HSTRING_EXTDATA) && defined(DUK_USE_EXTSTR_INTERN_CHECK)
45897 extdata = (const duk_uint8_t *) DUK_USE_EXTSTR_INTERN_CHECK(heap->heap_udata, (void *) DUK_LOSE_CONST(str), (duk_size_t) blen);
45898#else
45899 extdata = (const duk_uint8_t *) NULL;
45900#endif
45901 res = duk__alloc_init_hstring(heap, str, blen, strhash, extdata);
45902 if (!res) {
45903 goto failed;
45904 }
45905
45906#if defined(DUK_USE_STRTAB_CHAIN)
45907 if (duk__insert_hstring_chain(heap, res)) {
45908 /* failed */
45909 DUK_FREE(heap, res);
45910 goto failed;
45911 }
45912#elif defined(DUK_USE_STRTAB_PROBE)
45913 /* guaranteed to succeed */
45915#if defined(DUK_USE_HEAPPTR16)
45916 heap->strtable16,
45917#else
45918 heap->strtable,
45919#endif
45920 heap->st_size,
45921 &heap->st_used,
45922 res);
45923#else
45924#error internal error, invalid strtab options
#define DUK_LOSE_CONST(src)
DUK_LOCAL duk_bool_t duk__recheck_strtab_size_probe(duk_heap *heap, duk_uint32_t new_used)
DUK_LOCAL void duk__insert_hstring_probe(duk_heap *heap, duk_hstring **entries, duk_uint32_t size, duk_uint32_t *p_used, duk_hstring *h)
DUK_LOCAL duk_hstring * duk__alloc_init_hstring(duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen, duk_uint32_t strhash, const duk_uint8_t *extdata)
#define DUK_FREE(heap, ptr)
#define DUK__PREVENT_MS_SIDE_EFFECTS(heap)
duk_small_uint_t mark_and_sweep_base_flags

Referenced by duk_heap_string_intern_checked().

◆ duk__do_lookup()

DUK_LOCAL duk_hstring * duk__do_lookup ( duk_heap * heap,
const duk_uint8_t * str,
duk_uint32_t blen,
duk_uint32_t * out_strhash )

Definition at line 45926 of file duktape-1.8.0/src/duktape.c.

45932 :
45933#if defined(DUK_USE_MARK_AND_SWEEP)
45934 heap->mark_and_sweep_base_flags = prev_mark_and_sweep_base_flags;
45935#endif
45936 return res;
45937
45938 failed:
45939 res = NULL;
45940 goto done;
45941}
45942
45943DUK_LOCAL duk_hstring *duk__do_lookup(duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen, duk_uint32_t *out_strhash) {
45944 duk_hstring *res;
45945
45946 DUK_ASSERT(out_strhash);
45947
45948 *out_strhash = duk_heap_hashstring(heap, str, (duk_size_t) blen);
45949
45950#if defined(DUK_USE_ROM_STRINGS)
45951 {
45953 /* XXX: This is VERY inefficient now, and should be e.g. a
45954 * binary search or perfect hash, to be fixed.
45955 */
45956 for (i = 0; i < (duk_small_uint_t) (sizeof(duk_rom_strings) / sizeof(duk_hstring *)); i++) {
45957 duk_hstring *romstr;
45958 romstr = (duk_hstring *) DUK_LOSE_CONST(duk_rom_strings[i]);
45959 if (blen == DUK_HSTRING_GET_BYTELEN(romstr) &&
45960 DUK_MEMCMP((const void *) str, (const void *) DUK_HSTRING_GET_DATA(romstr), blen) == 0) {
45961 DUK_DD(DUK_DDPRINT("intern check: rom string: %!O, computed hash 0x%08lx, rom hash 0x%08lx",
45962 romstr, (unsigned long) *out_strhash, (unsigned long) DUK_HSTRING_GET_HASH(romstr)));
45963 DUK_ASSERT(*out_strhash == DUK_HSTRING_GET_HASH(romstr));
45964 *out_strhash = DUK_HSTRING_GET_HASH(romstr);
45965 return romstr;
45966 }
45967 }
45968 }
45969#endif /* DUK_USE_ROM_STRINGS */
45970
45971#if defined(DUK_USE_STRTAB_CHAIN)
45972 res = duk__find_matching_string_chain(heap, str, blen, *out_strhash);
DUK_LOCAL duk_hstring * duk__do_lookup(duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen, duk_uint32_t *out_strhash)
DUK_INTERNAL_DECL duk_uint32_t duk_heap_hashstring(duk_heap *heap, const duk_uint8_t *str, duk_size_t len)

Referenced by duk_heap_string_intern_checked().

◆ duk__dragon4_convert_and_push()

DUK_LOCAL void duk__dragon4_convert_and_push ( duk__numconv_stringify_ctx * nc_ctx,
duk_context * ctx,
duk_small_int_t radix,
duk_small_int_t digits,
duk_small_uint_t flags,
duk_small_int_t neg )

Definition at line 76585 of file duktape-1.8.0/src/duktape.c.

76586 : %ld", (long) t));
76587 if (++t < nc_ctx->B) {
76588 DUK_DDD(DUK_DDDPRINT("rounding carry terminated"));
76589 *p = (duk_uint8_t) t;
76590 break;
76591 }
76592
76593 DUK_DDD(DUK_DDDPRINT("wraps, carry to next digit"));
76594 }
76595 }
76596
76597 return ret;
76598}
76599
76600#define DUK__NO_EXP (65536) /* arbitrary marker, outside valid exp range */
76601
76602DUK_LOCAL void duk__dragon4_convert_and_push(duk__numconv_stringify_ctx *nc_ctx,
76603 duk_context *ctx,
76604 duk_small_int_t radix,
76605 duk_small_int_t digits,
76606 duk_small_uint_t flags,
76607 duk_small_int_t neg) {
76608 duk_small_int_t k;
76609 duk_small_int_t pos, pos_end;
76610 duk_small_int_t expt;
76611 duk_small_int_t dig;
76612 duk_uint8_t *q;
76613 duk_uint8_t *buf;
76614
76615 /*
76616 * The string conversion here incorporates all the necessary Ecmascript
76617 * semantics without attempting to be generic. nc_ctx->digits contains
76618 * nc_ctx->count digits (>= 1), with the topmost digit's 'position'
76619 * indicated by nc_ctx->k as follows:
76620 *
76621 * digits="123" count=3 k=0 --> 0.123
76622 * digits="123" count=3 k=1 --> 1.23
76623 * digits="123" count=3 k=5 --> 12300
76624 * digits="123" count=3 k=-1 --> 0.0123
76625 *
76626 * Note that the identifier names used for format selection are different
76627 * in Burger-Dybvig paper and Ecmascript specification (quite confusingly
76628 * so, because e.g. 'k' has a totally different meaning in each). See
76629 * documentation for discussion.
76630 *
76631 * Ecmascript doesn't specify any specific behavior for format selection
76632 * (e.g. when to use exponent notation) for non-base-10 numbers.
76633 *
76634 * The bigint space in the context is reused for string output, as there
76635 * is more than enough space for that (>1kB at the moment), and we avoid
76636 * allocating even more stack.
76637 */
76638
76639 DUK_ASSERT(DUK__NUMCONV_CTX_BIGINTS_SIZE >= DUK__MAX_FORMATTED_LENGTH);
76640 DUK_ASSERT(nc_ctx->count >= 1);
76641
76642 k = nc_ctx->k;
76643 buf = (duk_uint8_t *) &nc_ctx->f; /* XXX: union would be more correct */
76644 q = buf;
76645
76646 /* Exponent handling: if exponent format is used, record exponent value and
76647 * fake k such that one leading digit is generated (e.g. digits=123 -> "1.23").
76648 *
76649 * toFixed() prevents exponent use; otherwise apply a set of criteria to
76650 * match the other API calls (toString(), toPrecision, etc).
76651 */
76652
76653 expt = DUK__NO_EXP;
76654 if (!nc_ctx->abs_pos /* toFixed() */) {
76655 if ((flags & DUK_N2S_FLAG_FORCE_EXP) || /* exponential notation forced */
76656 ((flags & DUK_N2S_FLAG_NO_ZERO_PAD) && /* fixed precision and zero padding would be required */
76657 (k - digits >= 1)) || /* (e.g. k=3, digits=2 -> "12X") */
76658 ((k > 21 || k <= -6) && (radix == 10))) { /* toString() conditions */
76659 DUK_DDD(DUK_DDDPRINT("use exponential notation: k=%ld -> expt=%ld",
76660 (long) k, (long) (k - 1)));
76661 expt = k - 1; /* e.g. 12.3 -> digits="123" k=2 -> 1.23e1 */
76662 k = 1; /* generate mantissa with a single leading whole number digit */
76663 }
76664 }
76665
76666 if (neg) {
76667 *q++ = '-';
76668 }
76669
76670 /* Start position (inclusive) and end position (exclusive) */
76671 pos = (k >= 1 ? k : 1);
76672 if (nc_ctx->is_fixed) {
76673 if (nc_ctx->abs_pos) {
76674 /* toFixed() */
76675 pos_end = -digits;
76676 } else {
76677 pos_end = k - digits;
76678 }
76679 } else {
76680 pos_end = k - nc_ctx->count;
76681 }
76682 if (pos_end > 0) {
76683 pos_end = 0;
76684 }
76685
76686 DUK_DDD(DUK_DDDPRINT("expt=%ld, k=%ld, count=%ld, pos=%ld, pos_end=%ld, is_fixed=%ld, "
76687 "digits=%ld, abs_pos=%ld",
76688 (long) expt, (long) k, (long) nc_ctx->count, (long) pos, (long) pos_end,
76689 (long) nc_ctx->is_fixed, (long) digits, (long) nc_ctx->abs_pos));
76690
76691 /* Digit generation */
76692 while (pos > pos_end) {
76693 DUK_DDD(DUK_DDDPRINT("digit generation: pos=%ld, pos_end=%ld",
76694 (long) pos, (long) pos_end));
76695 if (pos == 0) {
76696 *q++ = (duk_uint8_t) '.';
76697 }
76698 if (pos > k) {
76699 *q++ = (duk_uint8_t) '0';
76700 } else if (pos <= k - nc_ctx->count) {
76701 *q++ = (duk_uint8_t) '0';
76702 } else {
76703 dig = nc_ctx->digits[k - pos];
76704 DUK_ASSERT(dig >= 0 && dig < nc_ctx->B);
76705 *q++ = (duk_uint8_t) DUK__DIGITCHAR(dig);
76706 }
76707
76708 pos--;
76709 }
76710 DUK_ASSERT(pos <= 1);
76711
76712 /* Exponent */
76713 if (expt != DUK__NO_EXP) {
76714 /*
76715 * Exponent notation for non-base-10 numbers isn't specified in Ecmascript
76716 * specification, as it never explicitly turns up: non-decimal numbers can
76717 * only be formatted with Number.prototype.toString([radix]) and for that,
76718 * behavior is not explicitly specified.
76719 *
76720 * Logical choices include formatting the exponent as decimal (e.g. binary
76721 * 100000 as 1e+5) or in current radix (e.g. binary 100000 as 1e+101).
76722 * The Dragon4 algorithm (in the original paper) prints the exponent value
76723 * in the target radix B. However, for radix values 15 and above, the
76724 * exponent separator 'e' is no longer easily parseable. Consider, for
76725 * instance, the number "1.faecee+1c".
76726 */
76727
static int digit(int c)

◆ duk__dragon4_ctx_to_double()

DUK_LOCAL void duk__dragon4_ctx_to_double ( duk__numconv_stringify_ctx * nc_ctx,
duk_double_t * x )

Definition at line 76778 of file duktape-1.8.0/src/duktape.c.

76779 {
76780 /* denormal */
76781 expt = DUK__IEEE_DOUBLE_EXP_MIN - 52;
76782 duk__bi_normalize(&nc_ctx->f);
76783 } else {
76784 /* normal: implicit leading 1-bit */
76785 nc_ctx->f.v[1] |= 0x00100000UL;
76786 expt = expt - DUK__IEEE_DOUBLE_EXP_BIAS - 52;
76787 DUK_ASSERT(duk__bi_is_valid(&nc_ctx->f)); /* true, because v[1] has at least one bit set */
76788 }
76789
76790 DUK_ASSERT(duk__bi_is_valid(&nc_ctx->f));
76791
76792 nc_ctx->e = expt;
76793}
76794
76797 duk_small_int_t expt;
76799 duk_small_int_t bitstart;
76800 duk_small_int_t bitround;
76801 duk_small_int_t bitidx;
76802 duk_small_int_t skip_round;
76803 duk_uint32_t t, v;
76804
76805 DUK_ASSERT(nc_ctx->count == 53 + 1);
76806
76807 /* Sometimes this assert is not true right now; it will be true after
76808 * rounding. See: test-bug-numconv-mantissa-assert.js.
76809 */
76810 DUK_ASSERT_DISABLE(nc_ctx->digits[0] == 1); /* zero handled by caller */
76811
76812 /* Should not be required because the code below always sets both high
76813 * and low parts, but at least gcc-4.4.5 fails to deduce this correctly
76814 * (perhaps because the low part is set (seemingly) conditionally in a
76815 * loop), so this is here to avoid the bogus warning.
76816 */
76817 DUK_MEMZERO((void *) &u, sizeof(u));
76818
76819 /*
76820 * Figure out how generated digits match up with the mantissa,
76821 * and then perform rounding. If mantissa overflows, need to
76822 * recompute the exponent (it is bumped and may overflow to
76823 * infinity).
76824 *
76825 * For normal numbers the leading '1' is hidden and ignored,
76826 * and the last bit is used for rounding:
76827 *
76828 * rounding pt
76829 * <--------52------->|
76830 * 1 x x x x ... x x x x|y ==> x x x x ... x x x x
76831 *
76832 * For denormals, the leading '1' is included in the number,
76833 * and the rounding point is different:
76834 *
76835 * rounding pt
76836 * <--52 or less--->|
76837 * 1 x x x x ... x x|x x y ==> 0 0 ... 1 x x ... x x
76838 *
76839 * The largest denormals will have a mantissa beginning with
76840 * a '1' (the explicit leading bit); smaller denormals will
76841 * have leading zero bits.
76842 *
76843 * If the exponent would become too high, the result becomes
76844 * Infinity. If the exponent is so small that the entire
76845 * mantissa becomes zero, the result becomes zero.
76846 *
76847 * Note: the Dragon4 'k' is off-by-one with respect to the IEEE
76848 * exponent. For instance, k==0 indicates that the leading '1'
76849 * digit is at the first binary fraction position (0.1xxx...);
76850 * the corresponding IEEE exponent would be -1.
76851 */
76852
76853 skip_round = 0;
76854
76855 recheck_exp:
76856
76857 expt = nc_ctx->k - 1; /* IEEE exp without bias */
76858 if (expt > 1023) {
76859 /* Infinity */
76860 bitstart = -255; /* needed for inf: causes mantissa to become zero,
76861 * and rounding to be skipped.
76862 */
76863 expt = 2047;
76864 } else if (expt >= -1022) {
76865 /* normal */
76866 bitstart = 1; /* skip leading digit */
76868 DUK_ASSERT(expt >= 1 && expt <= 2046);
76869 } else {
76870 /* denormal or zero */
76871 bitstart = 1023 + expt; /* expt==-1023 -> bitstart=0 (leading 1);
76872 * expt==-1024 -> bitstart=-1 (one left of leading 1), etc
76873 */
76874 expt = 0;
76875 }
76876 bitround = bitstart + 52;
76877
76878 DUK_DDD(DUK_DDDPRINT("ieee expt=%ld, bitstart=%ld, bitround=%ld",
76879 (long) expt, (long) bitstart, (long) bitround));
76880
76881 if (!skip_round) {
76882 if (duk__dragon4_fixed_format_round(nc_ctx, bitround)) {
76883 /* Corner case: see test-numconv-parse-mant-carry.js. We could
76884 * just bump the exponent and update bitstart, but it's more robust
76885 * to recompute (but avoid rounding twice).
76886 */
76887 DUK_DDD(DUK_DDDPRINT("rounding caused exponent to be bumped, recheck exponent"));
76888 skip_round = 1;
76889 goto recheck_exp;
76890 }
76891 }
76892
76893 /*
76894 * Create mantissa
76895 */
76896
76897 t = 0;
76898 for (i = 0; i < 52; i++) {
76899 bitidx = bitstart + 52 - 1 - i;
76900 if (bitidx >= nc_ctx->count) {
76901 v = 0;
76902 } else if (bitidx < 0) {
76903 v = 0;
76904 } else {
76905 v = nc_ctx->digits[bitidx];
76906 }
76907 DUK_ASSERT(v == 0 || v == 1);
76908 t += v << (i % 32);
76909 if (i == 31) {
76910 /* low 32 bits is complete */
76912 t = 0;
76913 }
76914 }
76915 /* t has high mantissa */
76916
76917 DUK_DDD(DUK_DDDPRINT("mantissa is complete: %08lx %08lx",
76918 (unsigned long) t,
#define DUK_DBLUNION_SET_LOW32(u, v)
#define DUK__IEEE_DOUBLE_EXP_BIAS
DUK_LOCAL void duk__dragon4_ctx_to_double(duk__numconv_stringify_ctx *nc_ctx, duk_double_t *x)
DUK_LOCAL duk_small_int_t duk__dragon4_fixed_format_round(duk__numconv_stringify_ctx *nc_ctx, duk_small_int_t round_idx)
#define DUK__IEEE_DOUBLE_EXP_MIN
duk_uint8_t digits[DUK__MAX_OUTPUT_DIGITS]

References duk__bi_normalize(), DUK__IEEE_DOUBLE_EXP_MIN, and duk__numconv_stringify_ctx::f.

◆ duk__dragon4_double_to_ctx()

DUK_LOCAL void duk__dragon4_double_to_ctx ( duk__numconv_stringify_ctx * nc_ctx,
duk_double_t x )

Definition at line 76733 of file duktape-1.8.0/src/duktape.c.

76734 {
76735 expt_sign = '-';
76736 expt = -expt;
76737 }
76738 *q++ = (duk_uint8_t) expt_sign;
76739 len = duk__dragon4_format_uint32(q, (duk_uint32_t) expt, radix);
76740 q += len;
76741 }
76742
76743 duk_push_lstring(ctx, (const char *) buf, (size_t) (q - buf));
76744}
76745
76746/*
76747 * Conversion helpers
76748 */
76749
76752 duk_uint32_t tmp;
76753 duk_small_int_t expt;
76754
76755 /*
76756 * seeeeeee eeeeffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
76757 * A B C D E F G H
76758 *
76759 * s sign bit
76760 * eee... exponent field
76761 * fff... fraction
76762 *
76763 * ieee value = 1.ffff... * 2^(e - 1023) (normal)
76764 * = 0.ffff... * 2^(-1022) (denormal)
76765 *
76766 * algorithm v = f * b^e
76767 */
76768
76770
76771 nc_ctx->f.n = 2;
76772
76773 tmp = DUK_DBLUNION_GET_LOW32(&u);
76774 nc_ctx->f.v[0] = tmp;
76775 tmp = DUK_DBLUNION_GET_HIGH32(&u);
76776 nc_ctx->f.v[1] = tmp & 0x000fffffUL;
#define DUK_DBLUNION_GET_LOW32(u)
#define DUK_DBLUNION_SET_DOUBLE(u, v)
#define DUK_DBLUNION_GET_HIGH32(u)
DUK_LOCAL void duk__dragon4_double_to_ctx(duk__numconv_stringify_ctx *nc_ctx, duk_double_t x)
DUK_LOCAL duk_size_t duk__dragon4_format_uint32(duk_uint8_t *buf, duk_uint32_t x, duk_small_int_t radix)

◆ duk__dragon4_fixed_format_round()

DUK_LOCAL duk_small_int_t duk__dragon4_fixed_format_round ( duk__numconv_stringify_ctx * nc_ctx,
duk_small_int_t round_idx )

Definition at line 76514 of file duktape-1.8.0/src/duktape.c.

76531 {
76533 duk_uint8_t *p;
76534 duk_uint8_t roundup_limit;
76535 duk_small_int_t ret = 0;
76536
76537 /*
76538 * round_idx points to the digit which is considered for rounding; the
76539 * digit to its left is the final digit of the rounded value. If round_idx
76540 * is zero, rounding will be performed; the result will either be an empty
76541 * rounded value or if carry happens a '1' digit is generated.
76542 */
76543
76544 if (round_idx >= nc_ctx->count) {
76545 DUK_DDD(DUK_DDDPRINT("round_idx out of bounds (%ld >= %ld (count)) -> no rounding",
76546 (long) round_idx, (long) nc_ctx->count));
76547 return 0;
76548 } else if (round_idx < 0) {
76549 DUK_DDD(DUK_DDDPRINT("round_idx out of bounds (%ld < 0) -> no rounding",
76550 (long) round_idx));
76551 return 0;
76552 }
76553
76554 /*
76555 * Round-up limit.
76556 *
76557 * For even values, divides evenly, e.g. 10 -> roundup_limit=5.
76558 *
76559 * For odd values, rounds up, e.g. 3 -> roundup_limit=2.
76560 * If radix is 3, 0/3 -> down, 1/3 -> down, 2/3 -> up.
76561 */
76562 roundup_limit = (duk_uint8_t) ((nc_ctx->B + 1) / 2);
76563
76564 p = &nc_ctx->digits[round_idx];
76565 if (*p >= roundup_limit) {
76566 DUK_DDD(DUK_DDDPRINT("fixed-format rounding carry required"));
76567 /* carry */
76568 for (;;) {
76569 *p = 0;
76570 if (p == &nc_ctx->digits[0]) {
76571 DUK_DDD(DUK_DDDPRINT("carry propagated to first digit -> special case handling"));
76572 DUK_MEMMOVE((void *) (&nc_ctx->digits[1]),
76573 (const void *) (&nc_ctx->digits[0]),
76574 (size_t) (sizeof(char) * nc_ctx->count));
76575 nc_ctx->digits[0] = 1; /* don't increase 'count' */
76576 nc_ctx->k++; /* position of highest digit changed */
76577 nc_ctx->count++; /* number of digits changed */
76578 ret = 1;
76579 break;
76580 }
76581

◆ duk__dragon4_format_uint32()

DUK_LOCAL duk_size_t duk__dragon4_format_uint32 ( duk_uint8_t * buf,
duk_uint32_t x,
duk_small_int_t radix )

Definition at line 76059 of file duktape-1.8.0/src/duktape.c.

76070 { \
76071 DUK_ASSERT((preinc_idx) - 1 >= 0); \
76072 DUK_ASSERT((preinc_idx) - 1 < DUK__MAX_OUTPUT_DIGITS); \
76073 ((nc_ctx)->digits[(preinc_idx) - 1]) = (duk_uint8_t) (x); \
76074 } while (0)
76075
76076DUK_LOCAL duk_size_t duk__dragon4_format_uint32(duk_uint8_t *buf, duk_uint32_t x, duk_small_int_t radix) {
76077 duk_uint8_t *p;
76078 duk_size_t len;
76079 duk_small_int_t dig;
76081
76082 DUK_ASSERT(radix >= 2 && radix <= 36);
76083
76084 /* A 32-bit unsigned integer formats to at most 32 digits (the
76085 * worst case happens with radix == 2). Output the digits backwards,
76086 * and use a memmove() to get them in the right place.
76087 */
76088
76089 p = buf + 32;
76090 for (;;) {

◆ duk__dragon4_generate()

DUK_LOCAL void duk__dragon4_generate ( duk__numconv_stringify_ctx * nc_ctx)

Definition at line 76339 of file duktape-1.8.0/src/duktape.c.

76341 :
76342
76343 if (!nc_ctx->unequal_gaps) {
76344 DUK_DDD(DUK_DDDPRINT("equal gaps, copy m- from m+"));
76345 duk__bi_copy(&nc_ctx->mm, &nc_ctx->mp); /* mm <- mp */
76346 }
76347 nc_ctx->k = k;
76348
76349 DUK_DDD(DUK_DDDPRINT("final k: %ld", (long) k));
76350 DUK__BI_PRINT("r(final)", &nc_ctx->r);
76351 DUK__BI_PRINT("s(final)", &nc_ctx->s);
76352 DUK__BI_PRINT("mp(final)", &nc_ctx->mp);
76353 DUK__BI_PRINT("mm(final)", &nc_ctx->mm);
76354}
76355
76357 duk_small_int_t tc1, tc2; /* terminating conditions */
76358 duk_small_int_t d; /* current digit */
76359 duk_small_int_t count = 0; /* digit count */
76360
76361 /*
76362 * Digit generation loop.
76363 *
76364 * Different termination conditions:
76365 *
76366 * 1. Free format output. Terminate when shortest accurate
76367 * representation found.
76368 *
76369 * 2. Fixed format output, with specific number of digits.
76370 * Ignore termination conditions, terminate when digits
76371 * generated. Caller requests an extra digit and rounds.
76372 *
76373 * 3. Fixed format output, with a specific absolute cut-off
76374 * position (e.g. 10 digits after decimal point). Note
76375 * that we always generate at least one digit, even if
76376 * the digit is below the cut-off point already.
76377 */
76378
76379 for (;;) {
76380 DUK_DDD(DUK_DDDPRINT("generate loop, count=%ld, k=%ld, B=%ld, low_ok=%ld, high_ok=%ld",
76381 (long) count, (long) nc_ctx->k, (long) nc_ctx->B,
76382 (long) nc_ctx->low_ok, (long) nc_ctx->high_ok));
76383 DUK__BI_PRINT("r", &nc_ctx->r);
76384 DUK__BI_PRINT("s", &nc_ctx->s);
76385 DUK__BI_PRINT("m+", &nc_ctx->mp);
76386 DUK__BI_PRINT("m-", &nc_ctx->mm);
76387
76388 /* (quotient-remainder (* r B) s) using a dummy subtraction loop */
76389 duk__bi_mul_small(&nc_ctx->t1, &nc_ctx->r, nc_ctx->B); /* t1 <- (* r B) */
76390 d = 0;
76391 for (;;) {
76392 if (duk__bi_compare(&nc_ctx->t1, &nc_ctx->s) < 0) {
76393 break;
76394 }
76395 duk__bi_sub_copy(&nc_ctx->t1, &nc_ctx->s, &nc_ctx->t2); /* t1 <- t1 - s */
76396 d++;
76397 }
76398 duk__bi_copy(&nc_ctx->r, &nc_ctx->t1); /* r <- (remainder (* r B) s) */
76399 /* d <- (quotient (* r B) s) (in range 0...B-1) */
76400 DUK_DDD(DUK_DDDPRINT("-> d(quot)=%ld", (long) d));
76401 DUK__BI_PRINT("r(rem)", &nc_ctx->r);
76402
76403 duk__bi_mul_small_copy(&nc_ctx->mp, nc_ctx->B, &nc_ctx->t2); /* m+ <- (* m+ B) */
76404 duk__bi_mul_small_copy(&nc_ctx->mm, nc_ctx->B, &nc_ctx->t2); /* m- <- (* m- B) */
76405 DUK__BI_PRINT("mp(upd)", &nc_ctx->mp);
76406 DUK__BI_PRINT("mm(upd)", &nc_ctx->mm);
76407
76408 /* Terminating conditions. For fixed width output, we just ignore the
76409 * terminating conditions (and pretend that tc1 == tc2 == false). The
76410 * the current shortcut for fixed-format output is to generate a few
76411 * extra digits and use rounding (with carry) to finish the output.
76412 */
76413
76414 if (nc_ctx->is_fixed == 0) {
76415 /* free-form */
76416 tc1 = (duk__bi_compare(&nc_ctx->r, &nc_ctx->mm) <= (nc_ctx->low_ok ? 0 : -1));
76417
76418 duk__bi_add(&nc_ctx->t1, &nc_ctx->r, &nc_ctx->mp); /* t1 <- (+ r m+) */
76419 tc2 = (duk__bi_compare(&nc_ctx->t1, &nc_ctx->s) >= (nc_ctx->high_ok ? 0 : 1));
76420
76421 DUK_DDD(DUK_DDDPRINT("tc1=%ld, tc2=%ld", (long) tc1, (long) tc2));
76422 } else {
76423 /* fixed-format */
76424 tc1 = 0;
76425 tc2 = 0;
76426 }
76427
76428 /* Count is incremented before DUK__DRAGON4_OUTPUT_PREINC() call
76429 * on purpose, which is taken into account by the macro.
76430 */
76431 count++;
76432
76433 if (tc1) {
76434 if (tc2) {
76435 /* tc1 = true, tc2 = true */
76436 duk__bi_mul_small(&nc_ctx->t1, &nc_ctx->r, 2);
76437 if (duk__bi_compare(&nc_ctx->t1, &nc_ctx->s) < 0) { /* (< (* r 2) s) */
76438 DUK_DDD(DUK_DDDPRINT("tc1=true, tc2=true, 2r > s: output d --> %ld (k=%ld)",
76439 (long) d, (long) nc_ctx->k));
76440 DUK__DRAGON4_OUTPUT_PREINC(nc_ctx, count, d);
76441 } else {
76442 DUK_DDD(DUK_DDDPRINT("tc1=true, tc2=true, 2r <= s: output d+1 --> %ld (k=%ld)",
76443 (long) (d + 1), (long) nc_ctx->k));
76444 DUK__DRAGON4_OUTPUT_PREINC(nc_ctx, count, d + 1);
76445 }
76446 break;
76447 } else {
76448 /* tc1 = true, tc2 = false */
76449 DUK_DDD(DUK_DDDPRINT("tc1=true, tc2=false: output d --> %ld (k=%ld)",
76450 (long) d, (long) nc_ctx->k));
76451 DUK__DRAGON4_OUTPUT_PREINC(nc_ctx, count, d);
76452 break;
76453 }
76454 } else {
76455 if (tc2) {
76456 /* tc1 = false, tc2 = true */
76457 DUK_DDD(DUK_DDDPRINT("tc1=false, tc2=true: output d+1 --> %ld (k=%ld)",
76458 (long) (d + 1), (long) nc_ctx->k));
76459 DUK__DRAGON4_OUTPUT_PREINC(nc_ctx, count, d + 1);
76460 break;
76461 } else {
76462 /* tc1 = false, tc2 = false */
76463 DUK_DDD(DUK_DDDPRINT("tc1=false, tc2=false: output d --> %ld (k=%ld)",
76464 (long) d, (long) nc_ctx->k));
76465 DUK__DRAGON4_OUTPUT_PREINC(nc_ctx, count, d);
76466
76467 /* r <- r (updated above: r <- (remainder (* r B) s)
76468 * s <- s
76469 * m+ <- m+ (updated above: m+ <- (* m+ B)
76470 * m- <- m- (updated above: m- <- (* m- B)
76471 * B, low_ok, high_ok are fixed
76472 */
76473
76474 /* fall through and continue for-loop */
76475 }
76476 }
76477
76478 /* fixed-format termination conditions */
76479 if (nc_ctx->is_fixed) {
76480 if (nc_ctx->abs_pos) {
76481 int pos = nc_ctx->k - count + 1; /* count is already incremented, take into account */
76482 DUK_DDD(DUK_DDDPRINT("fixed format, absolute: abs pos=%ld, k=%ld, count=%ld, req=%ld",
76483 (long) pos, (long) nc_ctx->k, (long) count, (long) nc_ctx->req_digits));
76484 if (pos <= nc_ctx->req_digits) {
76485 DUK_DDD(DUK_DDDPRINT("digit position reached req_digits, end generate loop"));
76486 break;
76487 }
76488 } else {
76489 DUK_DDD(DUK_DDDPRINT("fixed format, relative: k=%ld, count=%ld, req=%ld",
76490 (long) nc_ctx->k, (long) count, (long) nc_ctx->req_digits));
76491 if (count >= nc_ctx->req_digits) {
76492 DUK_DDD(DUK_DDDPRINT("digit count reached req_digits, end generate loop"));
76493 break;
76494 }
76495 }
76496 }
76497 } /* for */
76498
76499 nc_ctx->count = count;
76500
76501 DUK_DDD(DUK_DDDPRINT("generate finished"));
76502
76503#ifdef DUK_USE_DDDPRINT
DUK_LOCAL void duk__bi_sub_copy(duk__bigint *x, duk__bigint *y, duk__bigint *t)
DUK_LOCAL void duk__bi_mul_small(duk__bigint *x, duk__bigint *y, duk_uint32_t z)
DUK_LOCAL void duk__bi_mul_small_copy(duk__bigint *x, duk_uint32_t y, duk__bigint *t)
DUK_LOCAL void duk__dragon4_generate(duk__numconv_stringify_ctx *nc_ctx)
#define DUK__BI_PRINT(name, x)
#define DUK__DRAGON4_OUTPUT_PREINC(nc_ctx, preinc_idx, x)

◆ duk__dragon4_prepare()

DUK_LOCAL void duk__dragon4_prepare ( duk__numconv_stringify_ctx * nc_ctx)

Definition at line 76092 of file duktape-1.8.0/src/duktape.c.

76098 {
76099 break;
76100 }
76101 }
76102 len = (duk_size_t) ((buf + 32) - p);
76103
76104 DUK_MEMMOVE((void *) buf, (const void *) p, (size_t) len);
76105
76106 return len;
76107}
76108
76110 duk_small_int_t lowest_mantissa;
76111
76112#if 1
76113 /* Assume IEEE round-to-even, so that shorter encoding can be used
76114 * when round-to-even would produce correct result. By removing
76115 * this check (and having low_ok == high_ok == 0) the results would
76116 * still be accurate but in some cases longer than necessary.
76117 */
76118 if (duk__bi_is_even(&nc_ctx->f)) {
76119 DUK_DDD(DUK_DDDPRINT("f is even"));
76120 nc_ctx->low_ok = 1;
76121 nc_ctx->high_ok = 1;
76122 } else {
76123 DUK_DDD(DUK_DDDPRINT("f is odd"));
76124 nc_ctx->low_ok = 0;
76125 nc_ctx->high_ok = 0;
76126 }
76127#else
76128 /* Note: not honoring round-to-even should work but now generates incorrect
76129 * results. For instance, 1e23 serializes to "a000...", i.e. the first digit
76130 * equals the radix (10). Scaling stops one step too early in this case.
76131 * Don't know why this is the case, but since this code path is unused, it
76132 * doesn't matter.
76133 */
76134 nc_ctx->low_ok = 0;
76135 nc_ctx->high_ok = 0;
76136#endif
76137
76138 /* For string-to-number, pretend we never have the lowest mantissa as there
76139 * is no natural "precision" for inputs. Having lowest_mantissa == 0, we'll
76140 * fall into the base cases for both e >= 0 and e < 0.
76141 */
76142 if (nc_ctx->is_s2n) {
76143 lowest_mantissa = 0;
76144 } else {
76145 lowest_mantissa = duk__bi_is_2to52(&nc_ctx->f);
76146 }
76147
76148 nc_ctx->unequal_gaps = 0;
76149 if (nc_ctx->e >= 0) {
76150 /* exponent non-negative (and thus not minimum exponent) */
76151
76152 if (lowest_mantissa) {
76153 /* (>= e 0) AND (= f (expt b (- p 1)))
76154 *
76155 * be <- (expt b e) == b^e
76156 * be1 <- (* be b) == (expt b (+ e 1)) == b^(e+1)
76157 * r <- (* f be1 2) == 2 * f * b^(e+1) [if b==2 -> f * b^(e+2)]
76158 * s <- (* b 2) [if b==2 -> 4]
76159 * m+ <- be1 == b^(e+1)
76160 * m- <- be == b^e
76161 * k <- 0
76162 * B <- B
76163 * low_ok <- round
76164 * high_ok <- round
76165 */
76166
76167 DUK_DDD(DUK_DDDPRINT("non-negative exponent (not smallest exponent); "
76168 "lowest mantissa value for this exponent -> "
76169 "unequal gaps"));
76170
76171 duk__bi_exp_small(&nc_ctx->mm, nc_ctx->b, nc_ctx->e, &nc_ctx->t1, &nc_ctx->t2); /* mm <- b^e */
76172 duk__bi_mul_small(&nc_ctx->mp, &nc_ctx->mm, nc_ctx->b); /* mp <- b^(e+1) */
76173 duk__bi_mul_small(&nc_ctx->t1, &nc_ctx->f, 2);
76174 duk__bi_mul(&nc_ctx->r, &nc_ctx->t1, &nc_ctx->mp); /* r <- (2 * f) * b^(e+1) */
76175 duk__bi_set_small(&nc_ctx->s, nc_ctx->b * 2); /* s <- 2 * b */
76176 nc_ctx->unequal_gaps = 1;
76177 } else {
76178 /* (>= e 0) AND (not (= f (expt b (- p 1))))
76179 *
76180 * be <- (expt b e) == b^e
76181 * r <- (* f be 2) == 2 * f * b^e [if b==2 -> f * b^(e+1)]
76182 * s <- 2
76183 * m+ <- be == b^e
76184 * m- <- be == b^e
76185 * k <- 0
76186 * B <- B
76187 * low_ok <- round
76188 * high_ok <- round
76189 */
76190
76191 DUK_DDD(DUK_DDDPRINT("non-negative exponent (not smallest exponent); "
76192 "not lowest mantissa for this exponent -> "
76193 "equal gaps"));
76194
76195 duk__bi_exp_small(&nc_ctx->mm, nc_ctx->b, nc_ctx->e, &nc_ctx->t1, &nc_ctx->t2); /* mm <- b^e */
76196 duk__bi_copy(&nc_ctx->mp, &nc_ctx->mm); /* mp <- b^e */
76197 duk__bi_mul_small(&nc_ctx->t1, &nc_ctx->f, 2);
76198 duk__bi_mul(&nc_ctx->r, &nc_ctx->t1, &nc_ctx->mp); /* r <- (2 * f) * b^e */
76199 duk__bi_set_small(&nc_ctx->s, 2); /* s <- 2 */
76200 }
76201 } else {
76202 /* When doing string-to-number, lowest_mantissa is always 0 so
76203 * the exponent check, while incorrect, won't matter.
76204 */
76205 if (nc_ctx->e > DUK__IEEE_DOUBLE_EXP_MIN /*not minimum exponent*/ &&
76206 lowest_mantissa /* lowest mantissa for this exponent*/) {
76207 /* r <- (* f b 2) [if b==2 -> (* f 4)]
76208 * s <- (* (expt b (- 1 e)) 2) == b^(1-e) * 2 [if b==2 -> b^(2-e)]
76209 * m+ <- b == 2
76210 * m- <- 1
76211 * k <- 0
76212 * B <- B
76213 * low_ok <- round
76214 * high_ok <- round
76215 */
76216
76217 DUK_DDD(DUK_DDDPRINT("negative exponent; not minimum exponent and "
76218 "lowest mantissa for this exponent -> "
76219 "unequal gaps"));
76220
76221 duk__bi_mul_small(&nc_ctx->r, &nc_ctx->f, nc_ctx->b * 2); /* r <- (2 * b) * f */
76222 duk__bi_exp_small(&nc_ctx->t1, nc_ctx->b, 1 - nc_ctx->e, &nc_ctx->s, &nc_ctx->t2); /* NB: use 's' as temp on purpose */
76223 duk__bi_mul_small(&nc_ctx->s, &nc_ctx->t1, 2); /* s <- b^(1-e) * 2 */
76224 duk__bi_set_small(&nc_ctx->mp, 2);
76225 duk__bi_set_small(&nc_ctx->mm, 1);
76226 nc_ctx->unequal_gaps = 1;
76227 } else {
76228 /* r <- (* f 2)
76229 * s <- (* (expt b (- e)) 2) == b^(-e) * 2 [if b==2 -> b^(1-e)]
76230 * m+ <- 1
76231 * m- <- 1
76232 * k <- 0
DUK_LOCAL int duk__bi_is_even(duk__bigint *x)
DUK_LOCAL duk_small_int_t duk__bi_is_2to52(duk__bigint *x)
DUK_LOCAL void duk__dragon4_prepare(duk__numconv_stringify_ctx *nc_ctx)

◆ duk__dragon4_scale()

DUK_LOCAL void duk__dragon4_scale ( duk__numconv_stringify_ctx * nc_ctx)

Definition at line 76234 of file duktape-1.8.0/src/duktape.c.

76251 {
76252 duk_small_int_t k = 0;
76253
76254 /* This is essentially the 'scale' algorithm, with recursion removed.
76255 * Note that 'k' is either correct immediately, or will move in one
76256 * direction in the loop. There's no need to do the low/high checks
76257 * on every round (like the Scheme algorithm does).
76258 *
76259 * The scheme algorithm finds 'k' and updates 's' simultaneously,
76260 * while the logical algorithm finds 'k' with 's' having its initial
76261 * value, after which 's' is updated separately (see the Burger-Dybvig
76262 * paper, Section 3.1, steps 2 and 3).
76263 *
76264 * The case where m+ == m- (almost always) is optimized for, because
76265 * it reduces the bigint operations considerably and almost always
76266 * applies. The scale loop only needs to work with m+, so this works.
76267 */
76268
76269 /* XXX: this algorithm could be optimized quite a lot by using e.g.
76270 * a logarithm based estimator for 'k' and performing B^n multiplication
76271 * using a lookup table or using some bit-representation based exp
76272 * algorithm. Currently we just loop, with significant performance
76273 * impact for very large and very small numbers.
76274 */
76275
76276 DUK_DDD(DUK_DDDPRINT("scale: B=%ld, low_ok=%ld, high_ok=%ld",
76277 (long) nc_ctx->B, (long) nc_ctx->low_ok, (long) nc_ctx->high_ok));
76278 DUK__BI_PRINT("r(init)", &nc_ctx->r);
76279 DUK__BI_PRINT("s(init)", &nc_ctx->s);
76280 DUK__BI_PRINT("mp(init)", &nc_ctx->mp);
76281 DUK__BI_PRINT("mm(init)", &nc_ctx->mm);
76282
76283 for (;;) {
76284 DUK_DDD(DUK_DDDPRINT("scale loop (inc k), k=%ld", (long) k));
76285 DUK__BI_PRINT("r", &nc_ctx->r);
76286 DUK__BI_PRINT("s", &nc_ctx->s);
76287 DUK__BI_PRINT("m+", &nc_ctx->mp);
76288 DUK__BI_PRINT("m-", &nc_ctx->mm);
76289
76290 duk__bi_add(&nc_ctx->t1, &nc_ctx->r, &nc_ctx->mp); /* t1 = (+ r m+) */
76291 if (duk__bi_compare(&nc_ctx->t1, &nc_ctx->s) >= (nc_ctx->high_ok ? 0 : 1)) {
76292 DUK_DDD(DUK_DDDPRINT("k is too low"));
76293 /* r <- r
76294 * s <- (* s B)
76295 * m+ <- m+
76296 * m- <- m-
76297 * k <- (+ k 1)
76298 */
76299
76300 duk__bi_mul_small_copy(&nc_ctx->s, nc_ctx->B, &nc_ctx->t1);
76301 k++;
76302 } else {
76303 break;
76304 }
76305 }
76306
76307 /* k > 0 -> k was too low, and cannot be too high */
76308 if (k > 0) {
76309 goto skip_dec_k;
76310 }
76311
76312 for (;;) {
76313 DUK_DDD(DUK_DDDPRINT("scale loop (dec k), k=%ld", (long) k));
76314 DUK__BI_PRINT("r", &nc_ctx->r);
76315 DUK__BI_PRINT("s", &nc_ctx->s);
76316 DUK__BI_PRINT("m+", &nc_ctx->mp);
76317 DUK__BI_PRINT("m-", &nc_ctx->mm);
76318
76319 duk__bi_add(&nc_ctx->t1, &nc_ctx->r, &nc_ctx->mp); /* t1 = (+ r m+) */
76320 duk__bi_mul_small(&nc_ctx->t2, &nc_ctx->t1, nc_ctx->B); /* t2 = (* (+ r m+) B) */
76321 if (duk__bi_compare(&nc_ctx->t2, &nc_ctx->s) <= (nc_ctx->high_ok ? -1 : 0)) {
76322 DUK_DDD(DUK_DDDPRINT("k is too high"));
76323 /* r <- (* r B)
76324 * s <- s
76325 * m+ <- (* m+ B)
76326 * m- <- (* m- B)
76327 * k <- (- k 1)
76328 */
76329 duk__bi_mul_small_copy(&nc_ctx->r, nc_ctx->B, &nc_ctx->t1);
76330 duk__bi_mul_small_copy(&nc_ctx->mp, nc_ctx->B, &nc_ctx->t1);
76331 if (nc_ctx->unequal_gaps) {
76332 DUK_DDD(DUK_DDDPRINT("m+ != m- -> need to update m- too"));
76333 duk__bi_mul_small_copy(&nc_ctx->mm, nc_ctx->B, &nc_ctx->t1);
76334 }
76335 k--;
76336 } else {
76337 break;

◆ duk__dump_buffer_prop()

DUK_LOCAL duk_uint8_t * duk__dump_buffer_prop ( duk_hthread * thr,
duk_uint8_t * p,
duk_bufwriter_ctx * bw_ctx,
duk_hobject * func,
duk_small_uint_t stridx )

Definition at line 11750 of file duktape-1.8.0/src/duktape.c.

11754 {
11755 h_str = DUK_TVAL_GET_STRING(tv);
11756 DUK_ASSERT(h_str != NULL);
11757 } else {
11759 DUK_ASSERT(h_str != NULL);
11760 }
11761 DUK_ASSERT(DUK_HSTRING_MAX_BYTELEN <= 0x7fffffffUL); /* ensures no overflow */
11762 p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 4 + DUK_HSTRING_GET_BYTELEN(h_str), p);
11763 p = duk__dump_hstring_raw(p, h_str);
11764 return p;
11765}
11766
#define DUK_TVAL_GET_STRING(tv)
DUK_LOCAL duk_uint8_t * duk__dump_hstring_raw(duk_uint8_t *p, duk_hstring *h)

◆ duk__dump_formals()

DUK_LOCAL duk_uint8_t * duk__dump_formals ( duk_hthread * thr,
duk_uint8_t * p,
duk_bufwriter_ctx * bw_ctx,
duk_hobject * func )

Definition at line 11829 of file duktape-1.8.0/src/duktape.c.

11846 {
11847 duk_tval *tv;
11848
11850 if (tv != NULL && DUK_TVAL_IS_OBJECT(tv)) {
11851 duk_hobject *h;
11853
11854 h = DUK_TVAL_GET_OBJECT(tv);
11855 DUK_ASSERT(h != NULL);
11856
11857 /* We know _Formals is dense and all entries will be in the
11858 * array part. GC and finalizers shouldn't affect _Formals
11859 * so side effects should be fine.
11860 */
11861 for (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ASIZE(h); i++) {
11862 duk_tval *tv_val;
11863 duk_hstring *varname;
11864
11865 tv_val = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, h, i);
11866 DUK_ASSERT(tv_val != NULL);
#define DUK_HTHREAD_STRING_INT_FORMALS(thr)

◆ duk__dump_func()

static duk_uint8_t * duk__dump_func ( duk_context * ctx,
duk_hcompiledfunction * func,
duk_bufwriter_ctx * bw_ctx,
duk_uint8_t * p )
static

Definition at line 11868 of file duktape-1.8.0/src/duktape.c.

11885 {
11886 duk_hthread *thr;
11887 duk_tval *tv, *tv_end;
11888 duk_instr_t *ins, *ins_end;
11889 duk_hobject **fn, **fn_end;
11890 duk_hstring *h_str;
11891 duk_uint32_t count_instr;
11892 duk_uint32_t tmp32;
11893 duk_uint16_t tmp16;
11894 duk_double_t d;
11895
11896 thr = (duk_hthread *) ctx;
11897 DUK_UNREF(ctx);
11898 DUK_UNREF(thr);
11899
11900 DUK_DD(DUK_DDPRINT("dumping function %p to %p: "
11901 "consts=[%p,%p[ (%ld bytes, %ld items), "
11902 "funcs=[%p,%p[ (%ld bytes, %ld items), "
11903 "code=[%p,%p[ (%ld bytes, %ld items)",
11904 (void *) func,
11905 (void *) p,
11906 (void *) DUK_HCOMPILEDFUNCTION_GET_CONSTS_BASE(thr->heap, func),
11907 (void *) DUK_HCOMPILEDFUNCTION_GET_CONSTS_END(thr->heap, func),
11910 (void *) DUK_HCOMPILEDFUNCTION_GET_FUNCS_BASE(thr->heap, func),
11911 (void *) DUK_HCOMPILEDFUNCTION_GET_FUNCS_END(thr->heap, func),
11912 (long) DUK_HCOMPILEDFUNCTION_GET_FUNCS_SIZE(thr->heap, func),
11914 (void *) DUK_HCOMPILEDFUNCTION_GET_CODE_BASE(thr->heap, func),
11915 (void *) DUK_HCOMPILEDFUNCTION_GET_CODE_END(thr->heap, func),
11916 (long) DUK_HCOMPILEDFUNCTION_GET_CODE_SIZE(thr->heap, func),
11917 (long) DUK_HCOMPILEDFUNCTION_GET_CODE_COUNT(thr->heap, func)));
11918
11919 DUK_ASSERT(DUK_USE_ESBC_MAX_BYTES <= 0x7fffffffUL); /* ensures no overflow */
11920 count_instr = (duk_uint32_t) DUK_HCOMPILEDFUNCTION_GET_CODE_COUNT(thr->heap, func);
11921 p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 3 * 4 + 2 * 2 + 3 * 4 + count_instr * 4, p);
11922
11923 /* Fixed header info. */
11924 tmp32 = count_instr;
11925 DUK_RAW_WRITE_U32_BE(p, tmp32);
11926 tmp32 = (duk_uint32_t) DUK_HCOMPILEDFUNCTION_GET_CONSTS_COUNT(thr->heap, func);
11927 DUK_RAW_WRITE_U32_BE(p, tmp32);
11928 tmp32 = (duk_uint32_t) DUK_HCOMPILEDFUNCTION_GET_FUNCS_COUNT(thr->heap, func);
11929 DUK_RAW_WRITE_U32_BE(p, tmp32);
11930 tmp16 = func->nregs;
11931 DUK_RAW_WRITE_U16_BE(p, tmp16);
11932 tmp16 = func->nargs;
11933 DUK_RAW_WRITE_U16_BE(p, tmp16);
11934#if defined(DUK_USE_DEBUGGER_SUPPORT)
11935 tmp32 = func->start_line;
11936 DUK_RAW_WRITE_U32_BE(p, tmp32);
11937 tmp32 = func->end_line;
11938 DUK_RAW_WRITE_U32_BE(p, tmp32);
11939#else
11942#endif
11943 tmp32 = ((duk_heaphdr *) func)->h_flags & DUK_HEAPHDR_FLAGS_FLAG_MASK;
11944 DUK_RAW_WRITE_U32_BE(p, tmp32);
11945
11946 /* Bytecode instructions: endian conversion needed unless
11947 * platform is big endian.
11948 */
11949 ins = DUK_HCOMPILEDFUNCTION_GET_CODE_BASE(thr->heap, func);
11950 ins_end = DUK_HCOMPILEDFUNCTION_GET_CODE_END(thr->heap, func);
11951 DUK_ASSERT((duk_size_t) (ins_end - ins) == (duk_size_t) count_instr);
11952#if defined(DUK_USE_INTEGER_BE)
11953 DUK_MEMCPY((void *) p, (const void *) ins, (size_t) (ins_end - ins));
11954 p += (size_t) (ins_end - ins);
11955#else
11956 while (ins != ins_end) {
11957 tmp32 = (duk_uint32_t) (*ins);
11958 DUK_RAW_WRITE_U32_BE(p, tmp32);
11959 ins++;
11960 }
11961#endif
11962
11963 /* Constants: variable size encoding. */
11965 tv_end = DUK_HCOMPILEDFUNCTION_GET_CONSTS_END(thr->heap, func);
11966 while (tv != tv_end) {
11967 /* constants are strings or numbers now */
11969 DUK_TVAL_IS_NUMBER(tv));
11970
11971 if (DUK_TVAL_IS_STRING(tv)) {
11972 h_str = DUK_TVAL_GET_STRING(tv);
11973 DUK_ASSERT(h_str != NULL);
11974 DUK_ASSERT(DUK_HSTRING_MAX_BYTELEN <= 0x7fffffffUL); /* ensures no overflow */
11975 p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 1 + 4 + DUK_HSTRING_GET_BYTELEN(h_str), p),
11976 *p++ = DUK__SER_STRING;
11977 p = duk__dump_hstring_raw(p, h_str);
11978 } else {
11980 p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 1 + 8, p);
11981 *p++ = DUK__SER_NUMBER;
11982 d = DUK_TVAL_GET_NUMBER(tv);
11984 }
11985 tv++;
11986 }
11987
11988 /* Inner functions recursively. */
11990 fn_end = (duk_hobject **) DUK_HCOMPILEDFUNCTION_GET_FUNCS_END(thr->heap, func);
11991 while (fn != fn_end) {
11992 /* XXX: This causes recursion up to inner function depth
11993 * which is normally not an issue, e.g. mark-and-sweep uses
11994 * a recursion limiter to avoid C stack issues. Avoiding
11995 * this would mean some sort of a work list or just refusing
11996 * to serialize deep functions.
11997 */
11999 p = duk__dump_func(ctx, (duk_hcompiledfunction *) *fn, bw_ctx, p);
12000 fn++;
12001 }
12002
12003 /* Object extra properties.
#define DUK__SER_STRING
#define DUK_RAW_WRITE_U16_BE(ptr, val)
#define DUK_HCOMPILEDFUNCTION_GET_FUNCS_COUNT(heap, h)
#define DUK_HCOMPILEDFUNCTION_GET_CODE_COUNT(heap, h)
#define DUK_TVAL_IS_STRING(tv)
#define DUK_HCOMPILEDFUNCTION_GET_CONSTS_COUNT(heap, h)
#define DUK_RAW_WRITE_DOUBLE_BE(ptr, val)
#define DUK_RAW_WRITE_U32_BE(ptr, val)
#define DUK__SER_NUMBER
static duk_uint8_t * duk__dump_func(duk_context *ctx, duk_hcompiledfunction *func, duk_bufwriter_ctx *bw_ctx, duk_uint8_t *p)

◆ duk__dump_hbuffer_raw()

DUK_LOCAL duk_uint8_t * duk__dump_hbuffer_raw ( duk_hthread * thr,
duk_uint8_t * p,
duk_hbuffer * h )

Definition at line 11713 of file duktape-1.8.0/src/duktape.c.

11713 {
11714 duk_size_t len;
11715 duk_uint32_t tmp32;
11716
11717 DUK_ASSERT(h != NULL);
11718
11719 len = DUK_HSTRING_GET_BYTELEN(h);
11720 DUK_ASSERT(len <= 0xffffffffUL); /* string limits */
11721 tmp32 = (duk_uint32_t) len;
11722 DUK_RAW_WRITE_U32_BE(p, tmp32);
11723 DUK_MEMCPY((void *) p,
11724 (const void *) DUK_HSTRING_GET_DATA(h),
11725 len);
11726 p += len;
11727 return p;
11728}
11729
11730DUK_LOCAL duk_uint8_t *duk__dump_hbuffer_raw(duk_hthread *thr, duk_uint8_t *p, duk_hbuffer *h) {
DUK_LOCAL duk_uint8_t * duk__dump_hbuffer_raw(duk_hthread *thr, duk_uint8_t *p, duk_hbuffer *h)

References DUK_ASSERT, DUK_HSTRING_GET_BYTELEN, DUK_HSTRING_GET_DATA, DUK_MEMCPY, DUK_RAW_WRITE_U32_BE, and NULL.

◆ duk__dump_hstring_raw()

DUK_LOCAL duk_uint8_t * duk__dump_hstring_raw ( duk_uint8_t * p,
duk_hstring * h )

Definition at line 11696 of file duktape-1.8.0/src/duktape.c.

11701 {
11702 duk_uint32_t len;
11703 duk_uint8_t *buf;
11704
11705 len = DUK_RAW_READ_U32_BE(p);
11706 buf = (duk_uint8_t *) duk_push_fixed_buffer(ctx, (duk_size_t) len);
11707 DUK_ASSERT(buf != NULL);
11708 DUK_MEMCPY((void *) buf, (const void *) p, (size_t) len);
11709 p += len;
11710 return p;
11711}
#define DUK_RAW_READ_U32_BE(ptr)

◆ duk__dump_string_prop()

DUK_LOCAL duk_uint8_t * duk__dump_string_prop ( duk_hthread * thr,
duk_uint8_t * p,
duk_bufwriter_ctx * bw_ctx,
duk_hobject * func,
duk_small_uint_t stridx )

Definition at line 11732 of file duktape-1.8.0/src/duktape.c.

◆ duk__dump_uint32_prop()

DUK_LOCAL duk_uint8_t * duk__dump_uint32_prop ( duk_hthread * thr,
duk_uint8_t * p,
duk_bufwriter_ctx * bw_ctx,
duk_hobject * func,
duk_small_uint_t stridx,
duk_uint32_t def_value )

Definition at line 11768 of file duktape-1.8.0/src/duktape.c.

11771 {
11772 duk_hbuffer *h_buf;
11773 h_buf = DUK_TVAL_GET_BUFFER(tv);
11774 DUK_ASSERT(h_buf != NULL);
11775 DUK_ASSERT(DUK_HBUFFER_MAX_BYTELEN <= 0x7fffffffUL); /* ensures no overflow */
11776 p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 4 + DUK_HBUFFER_GET_SIZE(h_buf), p);
11777 p = duk__dump_hbuffer_raw(thr, p, h_buf);
11778 } else {
11779 p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 4, p);
11781 }
#define DUK_HBUFFER_MAX_BYTELEN
#define DUK_TVAL_GET_BUFFER(tv)

◆ duk__dump_varmap()

DUK_LOCAL duk_uint8_t * duk__dump_varmap ( duk_hthread * thr,
duk_uint8_t * p,
duk_bufwriter_ctx * bw_ctx,
duk_hobject * func )

Definition at line 11783 of file duktape-1.8.0/src/duktape.c.

11785 {
11786 duk_tval *tv;
11787 duk_uint32_t val;
11788
11790 if (tv != NULL && DUK_TVAL_IS_NUMBER(tv)) {
11791 val = (duk_uint32_t) DUK_TVAL_GET_NUMBER(tv);
11792 } else {
11793 val = def_value;
11794 }
11795 p = DUK_BW_ENSURE_RAW(thr, bw_ctx, 4, p);
11796 DUK_RAW_WRITE_U32_BE(p, val);
11797 return p;
11798}
11799
11800DUK_LOCAL duk_uint8_t *duk__dump_varmap(duk_hthread *thr, duk_uint8_t *p, duk_bufwriter_ctx *bw_ctx, duk_hobject *func) {
11801 duk_tval *tv;
11802
11804 if (tv != NULL && DUK_TVAL_IS_OBJECT(tv)) {
11805 duk_hobject *h;
11807
11808 h = DUK_TVAL_GET_OBJECT(tv);
11809 DUK_ASSERT(h != NULL);
11810
11811 /* We know _Varmap only has own properties so walk property
11812 * table directly. We also know _Varmap is dense and all
11813 * values are numbers; assert for these. GC and finalizers
11814 * shouldn't affect _Varmap so side effects should be fine.
11815 */
11816 for (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ENEXT(h); i++) {
11817 duk_hstring *key;
11818 duk_tval *tv_val;
11819 duk_uint32_t val;
11820
11821 key = DUK_HOBJECT_E_GET_KEY(thr->heap, h, i);
11822 DUK_ASSERT(key != NULL); /* _Varmap is dense */
11824 tv_val = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, h, i);
11825 DUK_ASSERT(tv_val != NULL);
11826 DUK_ASSERT(DUK_TVAL_IS_NUMBER(tv_val)); /* known to be number; in fact an integer */
11827#if defined(DUK_USE_FASTINT)
#define DUK_HTHREAD_STRING_INT_VARMAP(thr)
DUK_LOCAL duk_uint8_t * duk__dump_varmap(duk_hthread *thr, duk_uint8_t *p, duk_bufwriter_ctx *bw_ctx, duk_hobject *func)

◆ duk__emit()

DUK_LOCAL_DECL void duk__emit ( duk_compiler_ctx * comp_ctx,
duk_instr_t ins )

Definition at line 58747 of file duktape-1.8.0/src/duktape.c.

58749 {
58750 duk_compiler_func *func;
58751 func = &comp_ctx->curr_func;
58752 return (duk_int_t) (DUK_BW_GET_SIZE(comp_ctx->thr, &func->bw_code) / sizeof(duk_compiler_instr));
58753}
58754
58756 DUK_ASSERT(pc >= 0);
58757 DUK_ASSERT((duk_size_t) pc < (duk_size_t) (DUK_BW_GET_SIZE(comp_ctx->thr, &comp_ctx->curr_func.bw_code) / sizeof(duk_compiler_instr)));
58758 return ((duk_compiler_instr *) (void *) DUK_BW_GET_BASEPTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code)) + pc;
58759}
58760
58761/* emit instruction; could return PC but that's not needed in the majority
58762 * of cases.
58763 */
58764DUK_LOCAL void duk__emit(duk_compiler_ctx *comp_ctx, duk_instr_t ins) {
58765#if defined(DUK_USE_PC2LINE)
58766 duk_int_t line;
58767#endif
58768 duk_compiler_instr *instr;
58769
58770 DUK_DDD(DUK_DDDPRINT("duk__emit: 0x%08lx curr_token.start_line=%ld prev_token.start_line=%ld pc=%ld --> %!I",
58771 (unsigned long) ins,
58772 (long) comp_ctx->curr_token.start_line,
58773 (long) comp_ctx->prev_token.start_line,
58774 (long) duk__get_current_pc(comp_ctx),
58775 (duk_instr_t) ins));
58776
58777 instr = (duk_compiler_instr *) (void *) DUK_BW_ENSURE_GETPTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code, sizeof(duk_compiler_instr));
58778 DUK_BW_ADD_PTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code, sizeof(duk_compiler_instr));
58779
58780#if defined(DUK_USE_PC2LINE)
58781 /* The line number tracking is a bit inconsistent right now, which
58782 * affects debugger accuracy. Mostly call sites emit opcodes when
58783 * they have parsed a token (say a terminating semicolon) and called
58784 * duk__advance(). In this case the line number of the previous
58785 * token is the most accurate one (except in prologue where
58786 * prev_token.start_line is 0). This is probably not 100% correct
58787 * right now.
58788 */
58789 /* approximation, close enough */
58790 line = comp_ctx->prev_token.start_line;
58791 if (line == 0) {
58792 line = comp_ctx->curr_token.start_line;
58793 }
58794#endif
58795
58796 instr->ins = ins;
58797#if defined(DUK_USE_PC2LINE)
58798 instr->line = line;
58799#endif
58800#if defined(DUK_USE_DEBUGGER_SUPPORT)
58801 if (line < comp_ctx->curr_func.min_line) {
58802 comp_ctx->curr_func.min_line = line;
58803 }
58804 if (line > comp_ctx->curr_func.max_line) {
58805 comp_ctx->curr_func.max_line = line;
58806 }
58807#endif
58808
58809 /* Limit checks for bytecode byte size and line number. */
58811 goto fail_bc_limit;
58812 }
58813#if defined(DUK_USE_PC2LINE) && defined(DUK_USE_ESBC_LIMITS)
#define DUK_BW_ADD_PTR(thr, bw_ctx, delta)
DUK_LOCAL_DECL void duk__emit(duk_compiler_ctx *comp_ctx, duk_instr_t ins)
DUK_LOCAL_DECL duk_int_t duk__get_current_pc(duk_compiler_ctx *comp_ctx)
DUK_LOCAL_DECL duk_compiler_instr * duk__get_instr_ptr(duk_compiler_ctx *comp_ctx, duk_int_t pc)
#define DUK_BW_ENSURE_GETPTR(thr, bw_ctx, sz)
#define curr_func(L)

References duk_compiler_func::bw_code, duk_compiler_ctx::curr_func, DUK_BW_GET_SIZE, and duk_compiler_ctx::thr.

◆ duk__emit_1()

DUK_LOCAL_DECL void duk__emit_1 ( duk_json_enc_ctx * js_ctx,
duk_uint_fast8_t ch )

Definition at line 30144 of file duktape-1.8.0/src/duktape.c.

30144 : top=%ld, result=%!T",
30145 (long) duk_get_top(ctx), (duk_tval *) duk_get_tval(ctx, -1)));
30146}

◆ duk__emit_2()

DUK_LOCAL_DECL void duk__emit_2 ( duk_json_enc_ctx * js_ctx,
duk_uint_fast8_t ch1,
duk_uint_fast8_t ch2 )

Definition at line 30148 of file duktape-1.8.0/src/duktape.c.

◆ duk__emit_a_b()

DUK_LOCAL_DECL void duk__emit_a_b ( duk_compiler_ctx * comp_ctx,
duk_small_uint_t op_flags,
duk_regconst_t a,
duk_regconst_t b )

Definition at line 59094 of file duktape-1.8.0/src/duktape.c.

59095 {
59096 DUK_ASSERT(a_out < 0);

Referenced by duk__parse_func_body().

◆ duk__emit_a_b_c()

DUK_LOCAL_DECL void duk__emit_a_b_c ( duk_compiler_ctx * comp_ctx,
duk_small_uint_t op_flags,
duk_regconst_t a,
duk_regconst_t b,
duk_regconst_t c )

Definition at line 58846 of file duktape-1.8.0/src/duktape.c.

58848 {
58849 comp_ctx->curr_func.max_line = line;
58850 }
58851#else
58852 DUK_UNREF(comp_ctx);
58853#endif
58854}
58855
58856#if 0 /* unused */
58857DUK_LOCAL void duk__emit_op_only(duk_compiler_ctx *comp_ctx, duk_small_uint_t op) {
58858 duk__emit(comp_ctx, DUK_ENC_OP_ABC(op, 0));
58859}
58860#endif
58861
58862/* Important main primitive. */
58864 duk_instr_t ins = 0;
58865 duk_int_t a_out = -1;
58866 duk_int_t b_out = -1;
58867 duk_int_t c_out = -1;
58868 duk_int_t tmp;
58869
58870 DUK_DDD(DUK_DDDPRINT("emit: op_flags=%04lx, a=%ld, b=%ld, c=%ld",
58871 (unsigned long) op_flags, (long) a, (long) b, (long) c));
58872
58873 /* We could rely on max temp/const checks: if they don't exceed BC
58874 * limit, nothing here can either (just asserts would be enough).
58875 * Currently we check for the limits, which provides additional
58876 * protection against creating invalid bytecode due to compiler
58877 * bugs.
58878 */
58879
58880 DUK_ASSERT_DISABLE((op_flags & 0xff) >= DUK_BC_OP_MIN); /* unsigned */
58881 DUK_ASSERT((op_flags & 0xff) <= DUK_BC_OP_MAX);
58882
58883 /* Input shuffling happens before the actual operation, while output
58884 * shuffling happens afterwards. Output shuffling decisions are still
58885 * made at the same time to reduce branch clutter; output shuffle decisions
58886 * are recorded into X_out variables.
58887 */
58888
58889 /* Slot A */
58890
58891#if defined(DUK_USE_SHUFFLE_TORTURE)
58892 if (a <= DUK_BC_A_MAX && (op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_A)) {
58893#else
58894 if (a <= DUK_BC_A_MAX) {
58895#endif
58896 ;
58897 } else if (op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_A) {
58898 DUK_D(DUK_DPRINT("out of regs: 'a' (reg) needs shuffling but shuffle prohibited, a: %ld", (long) a));
58899 goto error_outofregs;
58900 } else if (a <= DUK_BC_BC_MAX) {
58901 comp_ctx->curr_func.needs_shuffle = 1;
58902 tmp = comp_ctx->curr_func.shuffle1;
58903 if (op_flags & DUK__EMIT_FLAG_A_IS_SOURCE) {
58904 duk__emit(comp_ctx, DUK_ENC_OP_A_BC(DUK_OP_LDREG, tmp, a));
58905 } else {
58906 duk_small_int_t op = op_flags & 0xff;
58907 if (op == DUK_OP_CSVAR || op == DUK_OP_CSREG || op == DUK_OP_CSPROP) {
58908 /* Special handling for call setup instructions. The target
58909 * is expressed indirectly, but there is no output shuffling.
58910 */
58911 DUK_ASSERT((op_flags & DUK__EMIT_FLAG_A_IS_SOURCE) == 0);
58912 duk__emit_load_int32_noshuffle(comp_ctx, tmp, a);
58916 op_flags++; /* indirect opcode follows direct */
58917 } else {
58918 /* Output shuffle needed after main operation */
58919 a_out = a;
58920 }
58921 }
58922 a = tmp;
58923 } else {
58924 DUK_D(DUK_DPRINT("out of regs: 'a' (reg) needs shuffling but does not fit into BC, a: %ld", (long) a));
58925 goto error_outofregs;
58926 }
58927
58928 /* Slot B */
58929
58930 if (b & DUK__CONST_MARKER) {
58931 DUK_ASSERT((op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_B) == 0);
58932 DUK_ASSERT((op_flags & DUK__EMIT_FLAG_B_IS_TARGET) == 0);
58933 DUK_ASSERT((op_flags & 0xff) != DUK_OP_CALL);
58934 DUK_ASSERT((op_flags & 0xff) != DUK_OP_NEW);
58935 b = b & ~DUK__CONST_MARKER;
58936#if defined(DUK_USE_SHUFFLE_TORTURE)
58937 if (0) {
58938#else
58939 if (b <= 0xff) {
58940#endif
58941 ins |= DUK_ENC_OP_A_B_C(0, 0, 0x100, 0); /* const flag for B */
58942 } else if (b <= DUK_BC_BC_MAX) {
58943 comp_ctx->curr_func.needs_shuffle = 1;
58944 tmp = comp_ctx->curr_func.shuffle2;
58945 duk__emit(comp_ctx, DUK_ENC_OP_A_BC(DUK_OP_LDCONST, tmp, b));
58946 b = tmp;
58947 } else {
58948 DUK_D(DUK_DPRINT("out of regs: 'b' (const) needs shuffling but does not fit into BC, b: %ld", (long) b));
58949 goto error_outofregs;
58950 }
58951 } else {
58952#if defined(DUK_USE_SHUFFLE_TORTURE)
58953 if (b <= 0xff && (op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_B)) {
58954#else
58955 if (b <= 0xff) {
58956#endif
58957 ;
58958 } else if (op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_B) {
58959 if (b > DUK_BC_B_MAX) {
58960 /* Note: 0xff != DUK_BC_B_MAX */
58961 DUK_D(DUK_DPRINT("out of regs: 'b' (reg) needs shuffling but shuffle prohibited, b: %ld", (long) b));
58962 goto error_outofregs;
58963 }
58964 } else if (b <= DUK_BC_BC_MAX) {
58965 comp_ctx->curr_func.needs_shuffle = 1;
58966 tmp = comp_ctx->curr_func.shuffle2;
58967 if (op_flags & DUK__EMIT_FLAG_B_IS_TARGET) {
58968 /* Output shuffle needed after main operation */
58969 b_out = b;
58970 }
58971 if (!(op_flags & DUK__EMIT_FLAG_B_IS_TARGET) || (op_flags & DUK__EMIT_FLAG_B_IS_TARGETSOURCE)) {
58972 duk_small_int_t op = op_flags & 0xff;
58973 if (op == DUK_OP_CALL || op == DUK_OP_NEW ||
58974 op == DUK_OP_MPUTOBJ || op == DUK_OP_MPUTARR) {
58975 /* Special handling for CALL/NEW/MPUTOBJ/MPUTARR shuffling.
58976 * For each, slot B identifies the first register of a range
58977 * of registers, so normal shuffling won't work. Instead,
58978 * an indirect version of the opcode is used.
58979 */
58980 DUK_ASSERT((op_flags & DUK__EMIT_FLAG_B_IS_TARGET) == 0);
58981 duk__emit_load_int32_noshuffle(comp_ctx, tmp, b);
58986 op_flags++; /* indirect opcode follows direct */
58987 } else {
58988 duk__emit(comp_ctx, DUK_ENC_OP_A_BC(DUK_OP_LDREG, tmp, b));
58989 }
58990 }
58991 b = tmp;
58992 } else {
58993 DUK_D(DUK_DPRINT("out of regs: 'b' (reg) needs shuffling but does not fit into BC, b: %ld", (long) b));
58994 goto error_outofregs;
58995 }
58996 }
58997
58998 /* Slot C */
58999
59000 if (c & DUK__CONST_MARKER) {
59001 DUK_ASSERT((op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_C) == 0);
59002 DUK_ASSERT((op_flags & DUK__EMIT_FLAG_C_IS_TARGET) == 0);
59003 c = c & ~DUK__CONST_MARKER;
59004#if defined(DUK_USE_SHUFFLE_TORTURE)
59005 if (0) {
59006#else
59007 if (c <= 0xff) {
59008#endif
59009 ins |= DUK_ENC_OP_A_B_C(0, 0, 0, 0x100); /* const flag for C */
59010 } else if (c <= DUK_BC_BC_MAX) {
59011 comp_ctx->curr_func.needs_shuffle = 1;
59012 tmp = comp_ctx->curr_func.shuffle3;
59013 duk__emit(comp_ctx, DUK_ENC_OP_A_BC(DUK_OP_LDCONST, tmp, c));
59014 c = tmp;
59015 } else {
59016 DUK_D(DUK_DPRINT("out of regs: 'c' (const) needs shuffling but does not fit into BC, c: %ld", (long) c));
59017 goto error_outofregs;
59018 }
59019 } else {
59020#if defined(DUK_USE_SHUFFLE_TORTURE)
59021 if (c <= 0xff && (op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_C)) {
59022#else
59023 if (c <= 0xff) {
59024#endif
59025 ;
59026 } else if (op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_C) {
59027 if (c > DUK_BC_C_MAX) {
59028 /* Note: 0xff != DUK_BC_C_MAX */
59029 DUK_D(DUK_DPRINT("out of regs: 'c' (reg) needs shuffling but shuffle prohibited, c: %ld", (long) c));
59030 goto error_outofregs;
59031 }
59032 } else if (c <= DUK_BC_BC_MAX) {
59033 comp_ctx->curr_func.needs_shuffle = 1;
59034 tmp = comp_ctx->curr_func.shuffle3;
59035 if (op_flags & DUK__EMIT_FLAG_C_IS_TARGET) {
59036 /* Output shuffle needed after main operation */
59037 c_out = c;
59038 } else {
59039 duk_small_int_t op = op_flags & 0xff;
59040 if (op == DUK_OP_EXTRA &&
59042 /* Special shuffling for INITGET/INITSET, where slot C
59043 * identifies a register pair and cannot be shuffled
59044 * normally. Use an indirect variant instead.
59045 */
59046 DUK_ASSERT((op_flags & DUK__EMIT_FLAG_C_IS_TARGET) == 0);
59047 duk__emit_load_int32_noshuffle(comp_ctx, tmp, c);
59050 a++; /* indirect opcode follows direct */
59051 } else {
59052 duk__emit(comp_ctx, DUK_ENC_OP_A_BC(DUK_OP_LDREG, tmp, c));
59053 }
59054 }
59055 c = tmp;
59056 } else {
59057 DUK_D(DUK_DPRINT("out of regs: 'c' (reg) needs shuffling but does not fit into BC, c: %ld", (long) c));
59058 goto error_outofregs;
59059 }
59060 }
59061
59062 /* Main operation */
59063
59064 DUK_ASSERT_DISABLE(a >= DUK_BC_A_MIN); /* unsigned */
59066 DUK_ASSERT_DISABLE(b >= DUK_BC_B_MIN); /* unsigned */
59068 DUK_ASSERT_DISABLE(c >= DUK_BC_C_MIN); /* unsigned */
59070
59071 ins |= DUK_ENC_OP_A_B_C(op_flags & 0xff, a, b, c);
59072 duk__emit(comp_ctx, ins);
59073
59074 /* NEXTENUM needs a jump slot right after the main instruction.
59075 * When the JUMP is taken, output spilling is not needed so this
59076 * workaround is possible. The jump slot PC is exceptionally
59077 * plumbed through comp_ctx to minimize call sites.
59078 */
59079 if (op_flags & DUK__EMIT_FLAG_RESERVE_JUMPSLOT) {
59080 comp_ctx->emit_jumpslot_pc = duk__get_current_pc(comp_ctx);
59081 duk__emit_abc(comp_ctx, DUK_OP_JUMP, 0);
59082 }
59083
59084 /* Output shuffling: only one output register is realistically possible.
59085 *
59086 * (Zero would normally be an OK marker value: if the target register
59087 * was zero, it would never be shuffled. But with DUK_USE_SHUFFLE_TORTURE
59088 * this is no longer true, so use -1 as a marker instead.)
59089 */
59090
59091 if (a_out >= 0) {
59092 DUK_ASSERT(b_out < 0);
duk_uint32_t duk_regconst_t
#define DUK__EMIT_FLAG_NO_SHUFFLE_B
#define DUK_OP_JUMP
DUK_LOCAL_DECL void duk__emit_abc(duk_compiler_ctx *comp_ctx, duk_small_uint_t op, duk_regconst_t abc)
#define DUK_OP_MPUTOBJ
#define DUK_OP_LDREG
#define DUK__EMIT_FLAG_B_IS_TARGETSOURCE
#define DUK_ENC_OP_A_B_C(op, a, b, c)
DUK_LOCAL_DECL void duk__emit_load_int32_noshuffle(duk_compiler_ctx *comp_ctx, duk_reg_t reg, duk_int32_t val)
#define DUK_OP_CSREGI
#define DUK_OP_CALL
#define DUK_BC_OP_MAX
#define DUK_BC_BC_MAX
#define DUK_OP_CSVAR
#define DUK_OP_MPUTOBJI
#define DUK_ENC_OP_A_BC(op, a, bc)
#define DUK_OP_MPUTARRI
#define DUK_EXTRAOP_INITSET
DUK_LOCAL_DECL void duk__emit_a_b_c(duk_compiler_ctx *comp_ctx, duk_small_uint_t op_flags, duk_regconst_t a, duk_regconst_t b, duk_regconst_t c)
#define DUK_OP_EXTRA
#define DUK_BC_B_MIN
#define DUK_OP_CSVARI
#define DUK__CONST_MARKER
#define DUK_OP_CSPROP
#define DUK__EMIT_FLAG_NO_SHUFFLE_A
#define DUK_OP_CALLI
#define DUK_ENC_OP_ABC(op, abc)
#define DUK_EXTRAOP_INITSETI
#define DUK_OP_CSREG
#define DUK_OP_CSPROPI
#define DUK_OP_MPUTARR
#define DUK__EMIT_FLAG_A_IS_SOURCE
#define DUK_BC_B_MAX
#define DUK__EMIT_FLAG_B_IS_TARGET
#define DUK__EMIT_FLAG_RESERVE_JUMPSLOT
#define DUK_OP_LDCONST
#define DUK_BC_A_MIN
#define DUK_BC_C_MIN
#define DUK_EXTRAOP_INITGET
#define DUK_OP_NEW
#define DUK_BC_C_MAX
#define DUK__EMIT_FLAG_C_IS_TARGET
#define DUK_BC_A_MAX
#define DUK_EXTRAOP_INITGETI
#define DUK__EMIT_FLAG_NO_SHUFFLE_C
#define DUK_BC_OP_MIN
#define DUK_OP_NEWI

Referenced by duk__emit_invalid(), and duk__init_varmap_and_prologue_for_pass2().

◆ duk__emit_a_bc()

DUK_LOCAL_DECL void duk__emit_a_bc ( duk_compiler_ctx * comp_ctx,
duk_small_uint_t op_flags,
duk_regconst_t a,
duk_regconst_t bc )

Definition at line 59104 of file duktape-1.8.0/src/duktape.c.

59107 :
59109}
59110
59112 duk__emit_a_b_c(comp_ctx, op_flags | DUK__EMIT_FLAG_NO_SHUFFLE_C, a, b, 0);
59113}
59114
59115#if 0 /* unused */
59116DUK_LOCAL void duk__emit_a(duk_compiler_ctx *comp_ctx, int op_flags, int a) {
59118}
59119#endif
59120
59122 duk_instr_t ins;
59123 duk_int_t tmp;
59124
59125 /* allow caller to give a const number with the DUK__CONST_MARKER */
59126 bc = bc & (~DUK__CONST_MARKER);
59127
59128 DUK_ASSERT_DISABLE((op_flags & 0xff) >= DUK_BC_OP_MIN); /* unsigned */
59129 DUK_ASSERT((op_flags & 0xff) <= DUK_BC_OP_MAX);
59130 DUK_ASSERT_DISABLE(bc >= DUK_BC_BC_MIN); /* unsigned */
59132 DUK_ASSERT((bc & DUK__CONST_MARKER) == 0);
59133
59134 if (bc <= DUK_BC_BC_MAX) {
59135 ;
59136 } else {
59137 /* No BC shuffling now. */
59138 goto error_outofregs;
59139 }
59140
59141#if defined(DUK_USE_SHUFFLE_TORTURE)
59142 if (a <= DUK_BC_A_MAX && (op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_A)) {
59143#else
59144 if (a <= DUK_BC_A_MAX) {
59145#endif
59146 ins = DUK_ENC_OP_A_BC(op_flags & 0xff, a, bc);
59147 duk__emit(comp_ctx, ins);
59148 } else if (op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_A) {
59149 goto error_outofregs;
59150 } else if (a <= DUK_BC_BC_MAX) {
59151 comp_ctx->curr_func.needs_shuffle = 1;
DUK_LOCAL_DECL void duk__emit_a_bc(duk_compiler_ctx *comp_ctx, duk_small_uint_t op_flags, duk_regconst_t a, duk_regconst_t bc)
#define DUK_STR_REG_LIMIT
#define DUK_BC_BC_MIN
DUK_LOCAL_DECL void duk__emit_a_b(duk_compiler_ctx *comp_ctx, duk_small_uint_t op_flags, duk_regconst_t a, duk_regconst_t b)

Referenced by duk__emit_load_int32(), duk__init_varmap_and_prologue_for_pass2(), duk__ispec_toregconst_raw(), and duk__parse_var_decl().

◆ duk__emit_abc()

DUK_LOCAL_DECL void duk__emit_abc ( duk_compiler_ctx * comp_ctx,
duk_small_uint_t op,
duk_regconst_t abc )

Definition at line 59153 of file duktape-1.8.0/src/duktape.c.

59154 {
59155 duk__emit(comp_ctx, DUK_ENC_OP_A_BC(DUK_OP_LDREG, tmp, a));
59156 duk__emit(comp_ctx, ins);
59157 } else {
59158 duk__emit(comp_ctx, ins);
59159 duk__emit(comp_ctx, DUK_ENC_OP_A_BC(DUK_OP_STREG, tmp, a));
59160 }
59161 } else {
59162 goto error_outofregs;
59163 }
59164 return;
59165
59166 error_outofregs:
59168}
59169
59171 duk_instr_t ins;
59172
59173 DUK_ASSERT_DISABLE(op >= DUK_BC_OP_MIN); /* unsigned */
59175 DUK_ASSERT_DISABLE(abc >= DUK_BC_ABC_MIN); /* unsigned */
59176 DUK_ASSERT(abc <= DUK_BC_ABC_MAX);
59177 DUK_ASSERT((abc & DUK__CONST_MARKER) == 0);
#define DUK_OP_STREG
#define DUK_BC_ABC_MIN
#define DUK_BC_ABC_MAX

◆ duk__emit_cstring()

DUK_LOCAL void duk__emit_cstring ( duk_json_enc_ctx * js_ctx,
const char * str )

Definition at line 30157 of file duktape-1.8.0/src/duktape.c.

◆ duk__emit_esc_auto_fast()

DUK_LOCAL_DECL duk_uint8_t * duk__emit_esc_auto_fast ( duk_json_enc_ctx * js_ctx,
duk_uint_fast32_t cp,
duk_uint8_t * q )

Definition at line 30183 of file duktape-1.8.0/src/duktape.c.

30190 {
30191 DUK_ASSERT(DUK_BW_GET_SIZE(js_ctx->thr, &js_ctx->bw) >= 1);
30192 DUK_BW_ADD_PTR(js_ctx->thr, &js_ctx->bw, -1);
30193}
30194
30195#define DUK__MKESC(nybbles,esc1,esc2) \
30196 (((duk_uint_fast32_t) (nybbles)) << 16) | \
30197 (((duk_uint_fast32_t) (esc1)) << 8) | \
30198 ((duk_uint_fast32_t) (esc2))
30199
30200DUK_LOCAL duk_uint8_t *duk__emit_esc_auto_fast(duk_json_enc_ctx *js_ctx, duk_uint_fast32_t cp, duk_uint8_t *q) {
30202 duk_small_uint_t dig;
30203
30204 DUK_UNREF(js_ctx);
30205
30206 /* Caller ensures space for at least DUK__JSON_MAX_ESC_LEN. */
30207
30208 /* Select appropriate escape format automatically, and set 'tmp' to a
30209 * value encoding both the escape format character and the nybble count:
30210 *
30211 * (nybble_count << 16) | (escape_char1) | (escape_char2)
30212 */
30213
30214#ifdef DUK_USE_JX
30215 if (DUK_LIKELY(cp < 0x100UL)) {
30216 if (DUK_UNLIKELY(js_ctx->flag_ext_custom)) {
30218 } else {
30220 }
30221 } else
30222#endif
30223 if (DUK_LIKELY(cp < 0x10000UL)) {
30225 } else {
30226#ifdef DUK_USE_JX
30227 if (DUK_LIKELY(js_ctx->flag_ext_custom)) {
30229 } else
30230#endif
30231 {
30232 /* In compatible mode and standard JSON mode, output
30233 * something useful for non-BMP characters. This won't
30234 * roundtrip but will still be more or less readable and
30235 * more useful than an error.
DUK_LOCAL_DECL duk_uint8_t * duk__emit_esc_auto_fast(duk_json_enc_ctx *js_ctx, duk_uint_fast32_t cp, duk_uint8_t *q)
#define DUK__MKESC(nybbles, esc1, esc2)

◆ duk__emit_extraop_b()

DUK_LOCAL_DECL void duk__emit_extraop_b ( duk_compiler_ctx * comp_ctx,
duk_small_uint_t extraop_flags,
duk_regconst_t b )

Definition at line 59192 of file duktape-1.8.0/src/duktape.c.

59192 :
59194}
59195
59197 DUK_ASSERT_DISABLE((extraop_flags & 0xff) >= DUK_BC_EXTRAOP_MIN); /* unsigned */
59198 DUK_ASSERT((extraop_flags & 0xff) <= DUK_BC_EXTRAOP_MAX);
59199 /* Setting "no shuffle A" is covered by the assert, but it's needed
59200 * with DUK_USE_SHUFFLE_TORTURE.
59201 */
59202 duk__emit_a_b_c(comp_ctx,
59203 DUK_OP_EXTRA | DUK__EMIT_FLAG_NO_SHUFFLE_A | (extraop_flags & ~0xff), /* transfer flags */
#define DUK_BC_EXTRAOP_MAX
#define DUK_BC_EXTRAOP_MIN
DUK_LOCAL_DECL void duk__emit_extraop_b_c(duk_compiler_ctx *comp_ctx, duk_small_uint_t extraop_flags, duk_regconst_t b, duk_regconst_t c)

◆ duk__emit_extraop_b_c()

DUK_LOCAL_DECL void duk__emit_extraop_b_c ( duk_compiler_ctx * comp_ctx,
duk_small_uint_t extraop_flags,
duk_regconst_t b,
duk_regconst_t c )

Definition at line 59179 of file duktape-1.8.0/src/duktape.c.

59179 {
59180 ;
59181 } else {
59182 goto error_outofregs;
59183 }
59184 ins = DUK_ENC_OP_ABC(op, abc);
59185 DUK_DDD(DUK_DDDPRINT("duk__emit_abc: 0x%08lx line=%ld pc=%ld op=%ld (%!C) abc=%ld (%!I)",
59186 (unsigned long) ins, (long) comp_ctx->curr_token.start_line,
59187 (long) duk__get_current_pc(comp_ctx), (long) op, (long) op,
59188 (long) abc, (duk_instr_t) ins));
59189 duk__emit(comp_ctx, ins);
59190 return;

◆ duk__emit_extraop_bc()

DUK_LOCAL_DECL void duk__emit_extraop_bc ( duk_compiler_ctx * comp_ctx,
duk_small_uint_t extraop,
duk_regconst_t bc )

Definition at line 59205 of file duktape-1.8.0/src/duktape.c.

59209 {
59210 DUK_ASSERT_DISABLE((extraop_flags & 0xff) >= DUK_BC_EXTRAOP_MIN); /* unsigned */
59211 DUK_ASSERT((extraop_flags & 0xff) <= DUK_BC_EXTRAOP_MAX);
59212 /* Setting "no shuffle A" is covered by the assert, but it's needed
59213 * with DUK_USE_SHUFFLE_TORTURE.
59214 */
59215 duk__emit_a_b_c(comp_ctx,

Referenced by duk__ispec_toregconst_raw(), duk__parse_func_body(), and duk__parse_try_stmt().

◆ duk__emit_extraop_only()

DUK_LOCAL_DECL void duk__emit_extraop_only ( duk_compiler_ctx * comp_ctx,
duk_small_uint_t extraop_flags )

Definition at line 59217 of file duktape-1.8.0/src/duktape.c.

59222 {
59223 DUK_ASSERT_DISABLE(extraop >= DUK_BC_EXTRAOP_MIN); /* unsigned */
59224 DUK_ASSERT(extraop <= DUK_BC_EXTRAOP_MAX);
59225 /* Setting "no shuffle A" is covered by the assert, but it's needed
59226 * with DUK_USE_SHUFFLE_TORTURE.
59227 */
59228 duk__emit_a_bc(comp_ctx,

◆ duk__emit_hstring()

DUK_LOCAL_DECL void duk__emit_hstring ( duk_json_enc_ctx * js_ctx,
duk_hstring * h )

Definition at line 30152 of file duktape-1.8.0/src/duktape.c.

◆ duk__emit_if_false_skip()

DUK_LOCAL_DECL void duk__emit_if_false_skip ( duk_compiler_ctx * comp_ctx,
duk_regconst_t regconst )

Definition at line 59396 of file duktape-1.8.0/src/duktape.c.

59399 {
59400 /* No catch variable, e.g. a try-finally; replace LDCONST with
59401 * NOP to avoid a bogus LDCONST.
59402 */

◆ duk__emit_if_true_skip()

DUK_LOCAL_DECL void duk__emit_if_true_skip ( duk_compiler_ctx * comp_ctx,
duk_regconst_t regconst )

Definition at line 59404 of file duktape-1.8.0/src/duktape.c.

◆ duk__emit_invalid()

DUK_LOCAL_DECL void duk__emit_invalid ( duk_compiler_ctx * comp_ctx)

◆ duk__emit_jump()

DUK_LOCAL_DECL void duk__emit_jump ( duk_compiler_ctx * comp_ctx,
duk_int_t target_pc )

Definition at line 59273 of file duktape-1.8.0/src/duktape.c.

59277 {
59278 duk__emit_load_int32_raw(comp_ctx, reg, val, DUK__EMIT_FLAG_NO_SHUFFLE_A /*op_flags*/);
59279}
59280#else
59281DUK_LOCAL void duk__emit_load_int32_noshuffle(duk_compiler_ctx *comp_ctx, duk_reg_t reg, duk_int32_t val) {
59282 /* When torture not enabled, can just use the same helper because
duk_int32_t duk_reg_t
DUK_LOCAL void duk__emit_load_int32_raw(duk_compiler_ctx *comp_ctx, duk_reg_t reg, duk_int32_t val, duk_small_uint_t op_flags)

References DUK__EMIT_FLAG_NO_SHUFFLE_A, and duk__emit_load_int32_raw().

◆ duk__emit_jump_empty()

DUK_LOCAL_DECL duk_int_t duk__emit_jump_empty ( duk_compiler_ctx * comp_ctx)

Definition at line 59284 of file duktape-1.8.0/src/duktape.c.

59290 {

◆ duk__emit_load_int32()

DUK_LOCAL_DECL void duk__emit_load_int32 ( duk_compiler_ctx * comp_ctx,
duk_reg_t reg,
duk_int32_t val )

◆ duk__emit_load_int32_noshuffle()

DUK_LOCAL_DECL void duk__emit_load_int32_noshuffle ( duk_compiler_ctx * comp_ctx,
duk_reg_t reg,
duk_int32_t val )

Definition at line 59264 of file duktape-1.8.0/src/duktape.c.

59269 {
59270 duk__emit_load_int32_raw(comp_ctx, reg, val, 0 /*op_flags*/);

◆ duk__emit_load_int32_raw()

DUK_LOCAL void duk__emit_load_int32_raw ( duk_compiler_ctx * comp_ctx,
duk_reg_t reg,
duk_int32_t val,
duk_small_uint_t op_flags )

Definition at line 59231 of file duktape-1.8.0/src/duktape.c.

59234 {
59235 DUK_ASSERT_DISABLE((extraop_flags & 0xff) >= DUK_BC_EXTRAOP_MIN); /* unsigned */
59236 DUK_ASSERT((extraop_flags & 0xff) <= DUK_BC_EXTRAOP_MAX);
59237 /* Setting "no shuffle A" is covered by the assert, but it's needed
59238 * with DUK_USE_SHUFFLE_TORTURE.
59239 */
59240 duk__emit_a_b_c(comp_ctx,
59242 DUK__EMIT_FLAG_NO_SHUFFLE_C | (extraop_flags & ~0xff), /* transfer flags */
59243 extraop_flags & 0xff,
59244 0,
59245 0);
59246}
59247
59248DUK_LOCAL void duk__emit_load_int32_raw(duk_compiler_ctx *comp_ctx, duk_reg_t reg, duk_int32_t val, duk_small_uint_t op_flags) {
59249 /* XXX: Shuffling support could be implemented here so that LDINT+LDINTX
59250 * would only shuffle once (instead of twice). The current code works

Referenced by duk__emit_jump().

◆ duk__emit_stridx()

DUK_LOCAL_DECL void duk__emit_stridx ( duk_json_enc_ctx * js_ctx,
duk_small_uint_t stridx )

Definition at line 30162 of file duktape-1.8.0/src/duktape.c.

30165 {
30166 DUK_BW_WRITE_ENSURE_U8_2(js_ctx->thr, &js_ctx->bw, ch1, ch2);
30167}
30168
30170 DUK_BW_WRITE_ENSURE_HSTRING(js_ctx->thr, &js_ctx->bw, h);
30171}
DUK_LOCAL_DECL void duk__emit_hstring(duk_json_enc_ctx *js_ctx, duk_hstring *h)
#define DUK_BW_WRITE_ENSURE_HSTRING(thr, bw_ctx, val)
#define DUK_BW_WRITE_ENSURE_U8_2(thr, bw_ctx, val1, val2)

◆ duk__emit_u16_direct_ranges()

DUK_LOCAL void duk__emit_u16_direct_ranges ( duk_lexer_ctx * lex_ctx,
duk_re_range_callback gen_range,
void * userdata,
const duk_uint16_t * ranges,
duk_small_int_t num )

Definition at line 75187 of file duktape-1.8.0/src/duktape.c.

◆ duk__enc_allow_into_proplist()

DUK_LOCAL_DECL duk_bool_t duk__enc_allow_into_proplist ( duk_tval * tv)

Definition at line 31278 of file duktape-1.8.0/src/duktape.c.

31285 :
31286 duk_pop_2(ctx); /* [ ... key val ] -> [ ... ] */
31287 return 1; /* emitted */
31288
31289 pop2_undef:
31290 duk_pop_2(ctx); /* [ ... key val ] -> [ ... ] */
31291 return 0; /* not emitted */
31292}
31293
31294/* E5 Section 15.12.3, main algorithm, step 4.b.ii steps 1-4. */
DUK_LOCAL_DECL duk_bool_t duk__enc_allow_into_proplist(duk_tval *tv)

◆ duk__enc_array()

DUK_LOCAL_DECL void duk__enc_array ( duk_json_enc_ctx * js_ctx)

Definition at line 30954 of file duktape-1.8.0/src/duktape.c.

30955 {
30956 DUK_ASSERT(js_ctx->recursion_depth >= 1);
30957 duk__enc_newline_indent(js_ctx, js_ctx->recursion_depth - 1);
30958 }
30959 }
30960 DUK__EMIT_1(js_ctx, DUK_ASC_RCURLY);
30961
30962 duk__enc_objarr_exit(js_ctx, &entry_top);
30963
30964 DUK_ASSERT_TOP(ctx, entry_top);
30965}
30966
30967/* The JA(value) operation: encode array.
30968 *
30969 * Stack policy: [ array ] -> [ array ].
30970 */
30972 duk_context *ctx = (duk_context *) js_ctx->thr;
30973 duk_idx_t entry_top;
30974 duk_idx_t idx_arr;
30975 duk_bool_t emitted;
30976 duk_uarridx_t i, arr_len;
30977
30978 DUK_DDD(DUK_DDDPRINT("duk__enc_array: array=%!T",
30979 (duk_tval *) duk_get_tval(ctx, -1)));
30980
30981 duk__enc_objarr_entry(js_ctx, &entry_top);
30982
30983 idx_arr = entry_top - 1;
30984
30985 /* Steps 8-10 have been merged to avoid a "partial" variable. */
30986
30988
30989 arr_len = (duk_uarridx_t) duk_get_length(ctx, idx_arr);
30990 emitted = 0;
30991 for (i = 0; i < arr_len; i++) {
30992 DUK_DDD(DUK_DDDPRINT("array entry loop: array=%!T, index=%ld, arr_len=%ld",
30993 (duk_tval *) duk_get_tval(ctx, idx_arr),
30994 (long) i, (long) arr_len));
30995
30996 if (DUK_UNLIKELY(js_ctx->h_gap != NULL)) {
30997 DUK_ASSERT(js_ctx->recursion_depth >= 1);
30999 }
31000
31001 /* XXX: duk_push_uint_string() */
31002 duk_push_uint(ctx, (duk_uint_t) i);
31003 duk_to_string(ctx, -1); /* -> [ ... key ] */
31004
31005 /* [ ... key ] */
31006
31007 if (DUK_UNLIKELY(duk__enc_value(js_ctx, idx_arr) == 0)) {
31008 /* Value would normally be omitted, replace with 'null'. */
31010 } else {
31011 ;
31012 }
31013
31014 /* [ ... ] */
31015
31016 DUK__EMIT_1(js_ctx, DUK_ASC_COMMA);
DUK_LOCAL_DECL void duk__enc_objarr_entry(duk_json_enc_ctx *js_ctx, duk_idx_t *entry_top)
#define DUK__EMIT_STRIDX(js_ctx, i)
DUK_LOCAL_DECL void duk__enc_newline_indent(duk_json_enc_ctx *js_ctx, duk_int_t depth)
DUK_LOCAL_DECL void duk__enc_array(duk_json_enc_ctx *js_ctx)
DUK_LOCAL_DECL duk_bool_t duk__enc_value(duk_json_enc_ctx *js_ctx, duk_idx_t idx_holder)
#define DUK_STRIDX_LC_NULL
#define DUK_ASC_LBRACKET
DUK_LOCAL_DECL void duk__enc_objarr_exit(duk_json_enc_ctx *js_ctx, duk_idx_t *entry_top)
#define DUK__EMIT_1(js_ctx, ch)

◆ duk__enc_buffer()

DUK_LOCAL_DECL void duk__enc_buffer ( duk_json_enc_ctx * js_ctx,
duk_hbuffer * h )

Definition at line 30648 of file duktape-1.8.0/src/duktape.c.

30652 {

References DUK_ASSERT, DUK_MEMCPY, and duk_json_enc_ctx::flag_ext_compatible.

◆ duk__enc_buffer_data()

DUK_LOCAL void duk__enc_buffer_data ( duk_json_enc_ctx * js_ctx,
duk_uint8_t * buf_data,
duk_size_t buf_len )

Definition at line 30594 of file duktape-1.8.0/src/duktape.c.

30601 {
30602 x = *p++;
30603 *q++ = duk_lc_digits[x >> 4];
30604 *q++ = duk_lc_digits[x & 0x0f];
30605 }
30606
30607 return q;
30608}
30609#endif /* DUK_USE_HEX_FASTPATH */
30610
30611DUK_LOCAL void duk__enc_buffer_data(duk_json_enc_ctx *js_ctx, duk_uint8_t *buf_data, duk_size_t buf_len) {
30612 duk_hthread *thr;
30613 duk_uint8_t *q;
30614 duk_size_t space;
30615
30616 thr = js_ctx->thr;
30617
30618 DUK_ASSERT(js_ctx->flag_ext_custom || js_ctx->flag_ext_compatible); /* caller checks */
30620
30621 /* Buffer values are encoded in (lowercase) hex to make the
30622 * binary data readable. Base64 or similar would be more
30623 * compact but less readable, and the point of JX/JC
30624 * variants is to be as useful to a programmer as possible.
30625 */
30626
30627 /* The #ifdef clutter here needs to handle the three cases:
30628 * (1) JX+JC, (2) JX only, (3) JC only.
30629 */
30630
30631 /* Note: space must cater for both JX and JC. */
30632 space = 9 + buf_len * 2 + 2;
30633 DUK_ASSERT(DUK_HBUFFER_MAX_BYTELEN <= 0x7ffffffeUL);
30634 DUK_ASSERT((space - 2) / 2 >= buf_len); /* overflow not possible, buffer limits */
30635 q = DUK_BW_ENSURE_GETPTR(thr, &js_ctx->bw, space);
30636
30637#if defined(DUK_USE_JX) && defined(DUK_USE_JC)
30638 if (js_ctx->flag_ext_custom)
30639#endif
30640#if defined(DUK_USE_JX)
30641 {
30642 *q++ = DUK_ASC_PIPE;
30643 q = duk__enc_buffer_data_hex(buf_data, buf_len, q);
30644 *q++ = DUK_ASC_PIPE;
30645
30646 }
DUK_LOCAL void duk__enc_buffer_data(duk_json_enc_ctx *js_ctx, duk_uint8_t *buf_data, duk_size_t buf_len)
DUK_INTERNAL const duk_uint8_t duk_lc_digits[36]
DUK_LOCAL duk_uint8_t * duk__enc_buffer_data_hex(const duk_uint8_t *src, duk_size_t src_len, duk_uint8_t *dst)

References duk_lc_digits.

◆ duk__enc_buffer_data_hex()

DUK_LOCAL duk_uint8_t * duk__enc_buffer_data_hex ( const duk_uint8_t * src,
duk_size_t src_len,
duk_uint8_t * dst )

Definition at line 30517 of file duktape-1.8.0/src/duktape.c.

30534 {
30535 duk_uint8_t *q;
30536 duk_uint16_t *q16;
30538 duk_size_t i, len_safe;
30539#if !defined(DUK_USE_UNALIGNED_ACCESSES_POSSIBLE)
30540 duk_bool_t shift_dst;
30541#endif
30542
30543 /* Unlike in duk_hex_encode() 'dst' is not necessarily aligned by 2.
30544 * For platforms where unaligned accesses are not allowed, shift 'dst'
30545 * ahead by 1 byte to get alignment and then DUK_MEMMOVE() the result
30546 * in place. The faster encoding loop makes up the difference.
30547 * There's always space for one extra byte because a terminator always
30548 * follows the hex data and that's been accounted for by the caller.
30549 */
30550
30551#if defined(DUK_USE_UNALIGNED_ACCESSES_POSSIBLE)
30552 q16 = (duk_uint16_t *) (void *) dst;
30553#else
30554 shift_dst = (duk_bool_t) (((duk_size_t) dst) & 0x01U);
30555 if (shift_dst) {
30556 DUK_DD(DUK_DDPRINT("unaligned accesses not possible, dst not aligned -> step to dst + 1"));
30557 q16 = (duk_uint16_t *) (void *) (dst + 1);
30558 } else {
30559 DUK_DD(DUK_DDPRINT("unaligned accesses not possible, dst is aligned"));
30560 q16 = (duk_uint16_t *) (void *) dst;
30561 }
30562 DUK_ASSERT((((duk_size_t) q16) & 0x01U) == 0);
30563#endif
30564
30565 len_safe = src_len & ~0x03U;
30566 for (i = 0; i < len_safe; i += 4) {
30567 q16[0] = duk_hex_enctab[src[i]];
30568 q16[1] = duk_hex_enctab[src[i + 1]];
30569 q16[2] = duk_hex_enctab[src[i + 2]];
30570 q16[3] = duk_hex_enctab[src[i + 3]];
30571 q16 += 4;
30572 }
30573 q = (duk_uint8_t *) q16;
DUK_INTERNAL const duk_uint16_t duk_hex_enctab[256]

◆ duk__enc_bufferobject()

DUK_LOCAL_DECL void duk__enc_bufferobject ( duk_json_enc_ctx * js_ctx,
duk_hbufferobject * h_bufobj )

Definition at line 30693 of file duktape-1.8.0/src/duktape.c.

30697 {
30699 fmt = ptr ? "{\"_ptr\":\"%p\"}" : "{\"_ptr\":\"null\"}";
30700 }
30701#endif
30702
30703 /* When ptr == NULL, the format argument is unused. */
30704 DUK_SNPRINTF(buf, sizeof(buf) - 1, fmt, ptr); /* must not truncate */

References DUK_ASSERT, and duk_json_enc_ctx::flag_ext_compatible.

◆ duk__enc_double()

DUK_LOCAL_DECL void duk__enc_double ( duk_json_enc_ctx * js_ctx)

Definition at line 30425 of file duktape-1.8.0/src/duktape.c.

30426 {
30427 /* as is */
30428 DUK_RAW_WRITE_XUTF8(q, cp);
30429 }
30430 }
30431 }
30432
30433 DUK_BW_SET_PTR(thr, &js_ctx->bw, q);
30434 }
30435
30437}
30438
30439/* Encode a double (checked by caller) from stack top. Stack top may be
30440 * replaced by serialized string but is not popped (caller does that).
30441 */
30443 duk_hthread *thr;
30444 duk_context *ctx;
30445 duk_tval *tv;
30446 duk_double_t d;
30449 duk_small_uint_t stridx;
30450 duk_small_uint_t n2s_flags;
30451 duk_hstring *h_str;
30452
30453 DUK_ASSERT(js_ctx != NULL);
30454 thr = js_ctx->thr;
30455 DUK_ASSERT(thr != NULL);
30456 ctx = (duk_context *) thr;
30457
30458 /* Caller must ensure 'tv' is indeed a double and not a fastint! */
30459 tv = DUK_GET_TVAL_NEGIDX(ctx, -1);
30461 d = DUK_TVAL_GET_DOUBLE(tv);
30462
30465 DUK_UNREF(s);
30466
30467 if (DUK_LIKELY(!(c == DUK_FP_INFINITE || c == DUK_FP_NAN))) {
30469
30470#if defined(DUK_USE_JX) || defined(DUK_USE_JC)
30471 /* Negative zero needs special handling in JX/JC because
30472 * it would otherwise serialize to '0', not '-0'.
30473 */
30474 if (DUK_UNLIKELY(c == DUK_FP_ZERO && s != 0 &&
30475 (js_ctx->flag_ext_custom_or_compatible))) {
30477 } else
30478#endif /* DUK_USE_JX || DUK_USE_JC */
30479 {
30480 n2s_flags = 0;
30481 /* [ ... number ] -> [ ... string ] */
30482 duk_numconv_stringify(ctx, 10 /*radix*/, 0 /*digits*/, n2s_flags);
30483 }
30484 h_str = duk_to_hstring(ctx, -1);
30485 DUK_ASSERT(h_str != NULL);
30486 DUK__EMIT_HSTR(js_ctx, h_str);
30487 return;
30488 }
#define DUK_BW_SET_PTR(thr, bw_ctx, ptr)
#define DUK_TVAL_IS_DOUBLE(v)
#define DUK_GET_TVAL_NEGIDX(ctx, idx)
#define DUK__EMIT_HSTR(js_ctx, h)
#define DUK_STRIDX_MINUS_ZERO
DUK_INTERNAL_DECL void duk_numconv_stringify(duk_context *ctx, duk_small_int_t radix, duk_small_int_t digits, duk_small_uint_t flags)
#define DUK_TVAL_GET_DOUBLE(tv)
DUK_LOCAL_DECL void duk__enc_double(duk_json_enc_ctx *js_ctx)

◆ duk__enc_key_autoquote()

DUK_LOCAL_DECL void duk__enc_key_autoquote ( duk_json_enc_ctx * js_ctx,
duk_hstring * k )

Definition at line 30237 of file duktape-1.8.0/src/duktape.c.

30245 {
30246 tmp--;
30247 dig = (duk_small_uint_t) ((cp >> (4 * tmp)) & 0x0f);
30248 *q++ = duk_lc_digits[dig];
30249 }
30250
30251 return q;
30252}
30253
30255 const duk_int8_t *p, *p_start, *p_end; /* Note: intentionally signed. */
30256 duk_size_t k_len;
30257 duk_codepoint_t cp;
30258
30259 DUK_ASSERT(k != NULL);
30260
30261 /* Accept ASCII strings which conform to identifier requirements
30262 * as being emitted without key quotes. Since we only accept ASCII
30263 * there's no need for actual decoding: 'p' is intentionally signed
30264 * so that bytes >= 0x80 extend to negative values and are rejected
30265 * as invalid identifier codepoints.
30266 */
30267
30268 if (js_ctx->flag_avoid_key_quotes) {
30269 k_len = DUK_HSTRING_GET_BYTELEN(k);
30270 p_start = (const duk_int8_t *) DUK_HSTRING_GET_DATA(k);
30271 p_end = p_start + k_len;
30272 p = p_start;
30273
30274 if (p == p_end) {
30275 /* Zero length string is not accepted without quotes */
30276 goto quote_normally;
30277 }
30278 cp = (duk_codepoint_t) (*p++);
30280 goto quote_normally;
30281 }
DUK_LOCAL_DECL void duk__enc_key_autoquote(duk_json_enc_ctx *js_ctx, duk_hstring *k)

◆ duk__enc_newline_indent()

DUK_LOCAL_DECL void duk__enc_newline_indent ( duk_json_enc_ctx * js_ctx,
duk_int_t depth )

Definition at line 30721 of file duktape-1.8.0/src/duktape.c.

30728 {
30729 DUK_ASSERT(js_ctx->h_gap != NULL);
30730 DUK_ASSERT(DUK_HSTRING_GET_BYTELEN(js_ctx->h_gap) > 0); /* caller guarantees */
30731
30732 DUK__EMIT_1(js_ctx, 0x0a);
30733 while (depth-- > 0) {
30734 DUK__EMIT_HSTR(js_ctx, js_ctx->h_gap);
30735 }
30736}
30737#else /* DUK_USE_PREFER_SIZE */
30739 const duk_uint8_t *gap_data;
30740 duk_size_t gap_len;
30741 duk_size_t avail_bytes; /* bytes of indent available for copying */
30742 duk_size_t need_bytes; /* bytes of indent still needed */
30743 duk_uint8_t *p_start;
30744 duk_uint8_t *p;
30745
30746 DUK_ASSERT(js_ctx->h_gap != NULL);
30747 DUK_ASSERT(DUK_HSTRING_GET_BYTELEN(js_ctx->h_gap) > 0); /* caller guarantees */
30748
30749 DUK__EMIT_1(js_ctx, 0x0a);
30750 if (DUK_UNLIKELY(depth == 0)) {
30751 return;
30752 }
30753
30754 /* To handle deeper indents efficiently, make use of copies we've
30755 * already emitted. In effect we can emit a sequence of 1, 2, 4,
30756 * 8, etc copies, and then finish the last run. Byte counters
30757 * avoid multiply with gap_len on every loop.
30758 */
30759
30760 gap_data = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(js_ctx->h_gap);
30761 gap_len = (duk_size_t) DUK_HSTRING_GET_BYTELEN(js_ctx->h_gap);
30762 DUK_ASSERT(gap_len > 0);
30763
30764 need_bytes = gap_len * depth;
30765 p = DUK_BW_ENSURE_GETPTR(js_ctx->thr, &js_ctx->bw, need_bytes);
30766 p_start = p;
30767
30768 DUK_MEMCPY((void *) p, (const void *) gap_data, (size_t) gap_len);
30769 p += gap_len;
30770 avail_bytes = gap_len;

◆ duk__enc_objarr_entry()

DUK_LOCAL_DECL void duk__enc_objarr_entry ( duk_json_enc_ctx * js_ctx,
duk_idx_t * entry_top )

Definition at line 30774 of file duktape-1.8.0/src/duktape.c.

30774 {
30775 DUK_MEMCPY((void *) p, (const void *) p_start, (size_t) avail_bytes);
30776 p += avail_bytes;
30777 need_bytes -= avail_bytes;
30778 avail_bytes <<= 1;
30779 }
30780
30781 DUK_ASSERT(need_bytes < avail_bytes); /* need_bytes may be zero */
30782 DUK_MEMCPY((void *) p, (const void *) p_start, (size_t) need_bytes);
30783 p += need_bytes;
30784 /*avail_bytes += need_bytes*/
30785
30786 DUK_BW_SET_PTR(js_ctx->thr, &js_ctx->bw, p);
30787}
30788#endif /* DUK_USE_PREFER_SIZE */
30789
30790/* Shared entry handling for object/array serialization. */
30792 duk_context *ctx = (duk_context *) js_ctx->thr;
30793 duk_hobject *h_target;
30794 duk_uint_fast32_t i, n;
30795
30796 *entry_top = duk_get_top(ctx);
30797
30799
30800 /* Loop check using a hybrid approach: a fixed-size visited[] array
30801 * with overflow in a loop check object.
30802 */
30803
30804 h_target = duk_get_hobject(ctx, -1); /* object or array */
30805 DUK_ASSERT(h_target != NULL);
30806
30807 n = js_ctx->recursion_depth;
30810 }
30811 for (i = 0; i < n; i++) {
30812 if (DUK_UNLIKELY(js_ctx->visiting[i] == h_target)) {
30813 DUK_DD(DUK_DDPRINT("slow path loop detect"));
30815 }
30816 }
30818 js_ctx->visiting[js_ctx->recursion_depth] = h_target;
30819 } else {
30820 duk_push_sprintf(ctx, DUK_STR_FMT_PTR, (void *) h_target);
30821 duk_dup_top(ctx); /* -> [ ... voidp voidp ] */
30822 if (duk_has_prop(ctx, js_ctx->idx_loop)) {
#define DUK_JSON_ENC_LOOPARRAY
#define DUK_STR_FMT_PTR
#define DUK_JSON_ENC_REQSTACK
#define DUK_STR_CYCLIC_INPUT
DUK_EXTERNAL const char * duk_push_sprintf(duk_context *ctx, const char *fmt,...)
duk_hobject * visiting[DUK_JSON_ENC_LOOPARRAY]

References DUK_MEMCPY.

◆ duk__enc_objarr_exit()

DUK_LOCAL_DECL void duk__enc_objarr_exit ( duk_json_enc_ctx * js_ctx,
duk_idx_t * entry_top )

Definition at line 30826 of file duktape-1.8.0/src/duktape.c.

30833 {
30835 }
30836 js_ctx->recursion_depth++;
30837
30838 DUK_DDD(DUK_DDDPRINT("shared entry finished: top=%ld, loop=%!T",
30839 (long) duk_get_top(ctx), (duk_tval *) duk_get_tval(ctx, js_ctx->idx_loop)));
30840}
30841
30842/* Shared exit handling for object/array serialization. */
30843DUK_LOCAL void duk__enc_objarr_exit(duk_json_enc_ctx *js_ctx, duk_idx_t *entry_top) {
30844 duk_context *ctx = (duk_context *) js_ctx->thr;
30845 duk_hobject *h_target;
30846
30847 /* C recursion check. */
30848
30849 DUK_ASSERT(js_ctx->recursion_depth > 0);
30850 DUK_ASSERT(js_ctx->recursion_depth <= js_ctx->recursion_limit);
30851 js_ctx->recursion_depth--;
30852
30853 /* Loop check. */
#define DUK_STR_JSONENC_RECLIMIT

◆ duk__enc_object()

DUK_LOCAL_DECL void duk__enc_object ( duk_json_enc_ctx * js_ctx)

Definition at line 30859 of file duktape-1.8.0/src/duktape.c.

30860 {
30861 duk_push_sprintf(ctx, DUK_STR_FMT_PTR, (void *) h_target);
30862 duk_del_prop(ctx, js_ctx->idx_loop); /* -> [ ... ] */
30863 }
30864
30865 /* Restore stack top after unbalanced code paths. */
30866 duk_set_top(ctx, *entry_top);
30867
30868 DUK_DDD(DUK_DDDPRINT("shared entry finished: top=%ld, loop=%!T",
30869 (long) duk_get_top(ctx), (duk_tval *) duk_get_tval(ctx, js_ctx->idx_loop)));
30870}
30871
30872/* The JO(value) operation: encode object.
30873 *
30874 * Stack policy: [ object ] -> [ object ].
30875 */
30877 duk_context *ctx = (duk_context *) js_ctx->thr;
30878 duk_hstring *h_key;
30879 duk_idx_t entry_top;
30880 duk_idx_t idx_obj;
30881 duk_idx_t idx_keys;
30882 duk_bool_t emitted;
30883 duk_uarridx_t arr_len, i;
30884 duk_size_t prev_size;
30885
30886 DUK_DDD(DUK_DDDPRINT("duk__enc_object: obj=%!T", (duk_tval *) duk_get_tval(ctx, -1)));
30887
30888 duk__enc_objarr_entry(js_ctx, &entry_top);
30889
30890 idx_obj = entry_top - 1;
30891
30892 if (js_ctx->idx_proplist >= 0) {
30893 idx_keys = js_ctx->idx_proplist;
30894 } else {
30895 /* XXX: would be nice to enumerate an object at specified index */
30896 duk_dup(ctx, idx_obj);
30897 (void) duk_hobject_get_enumerated_keys(ctx, DUK_ENUM_OWN_PROPERTIES_ONLY /*flags*/); /* [ ... target ] -> [ ... target keys ] */
30898 idx_keys = duk_require_normalize_index(ctx, -1);
30899 /* leave stack unbalanced on purpose */
30900 }
30901
30902 DUK_DDD(DUK_DDDPRINT("idx_keys=%ld, h_keys=%!T",
30903 (long) idx_keys, (duk_tval *) duk_get_tval(ctx, idx_keys)));
30904
30905 /* Steps 8-10 have been merged to avoid a "partial" variable. */
30906
30907 DUK__EMIT_1(js_ctx, DUK_ASC_LCURLY);
30908
30909 /* XXX: keys is an internal object with all keys to be processed
30910 * in its (gapless) array part. Because nobody can touch the keys
30911 * object, we could iterate its array part directly (keeping in mind
30912 * that it can be reallocated).
30913 */
30914
30915 arr_len = (duk_uarridx_t) duk_get_length(ctx, idx_keys);
30916 emitted = 0;
30917 for (i = 0; i < arr_len; i++) {
30918 duk_get_prop_index(ctx, idx_keys, i); /* -> [ ... key ] */
30919
30920 DUK_DDD(DUK_DDDPRINT("object property loop: holder=%!T, key=%!T",
30921 (duk_tval *) duk_get_tval(ctx, idx_obj),
30922 (duk_tval *) duk_get_tval(ctx, -1)));
30923
30924 h_key = duk_get_hstring(ctx, -1);
30925 DUK_ASSERT(h_key != NULL);
30926
30927 prev_size = DUK_BW_GET_SIZE(js_ctx->thr, &js_ctx->bw);
30928 if (DUK_UNLIKELY(js_ctx->h_gap != NULL)) {
30930 duk__enc_key_autoquote(js_ctx, h_key);
30932 } else {
30933 duk__enc_key_autoquote(js_ctx, h_key);
30934 DUK__EMIT_1(js_ctx, DUK_ASC_COLON);
30935 }
30936
30937 /* [ ... key ] */
30938
30939 if (DUK_UNLIKELY(duk__enc_value(js_ctx, idx_obj) == 0)) {
30940 /* Value would yield 'undefined', so skip key altogether.
30941 * Side effects have already happened.
30942 */
30943 DUK_BW_SET_SIZE(js_ctx->thr, &js_ctx->bw, prev_size);
30944 } else {
30945 DUK__EMIT_1(js_ctx, DUK_ASC_COMMA);
30946 emitted = 1;
30947 }
30948
DUK_EXTERNAL duk_idx_t duk_require_normalize_index(duk_context *ctx, duk_idx_t index)
#define DUK__EMIT_2(js_ctx, ch1, ch2)
#define DUK_BW_SET_SIZE(thr, bw_ctx, sz)
DUK_INTERNAL_DECL duk_ret_t duk_hobject_get_enumerated_keys(duk_context *ctx, duk_small_uint_t enum_flags)
#define DUK_ASC_LCURLY
#define DUK_ASC_SPACE
DUK_LOCAL_DECL void duk__enc_object(duk_json_enc_ctx *js_ctx)

◆ duk__enc_pointer()

DUK_LOCAL_DECL void duk__enc_pointer ( duk_json_enc_ctx * js_ctx,
void * ptr )

Definition at line 30656 of file duktape-1.8.0/src/duktape.c.

30665 {
30666 duk__enc_buffer_data(js_ctx,
30667 (duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(js_ctx->thr->heap, h),
30669}
30670#endif /* DUK_USE_JX || DUK_USE_JC */
30671
30672#if defined(DUK_USE_JX) || defined(DUK_USE_JC)
30673DUK_LOCAL void duk__enc_pointer(duk_json_enc_ctx *js_ctx, void *ptr) {
30674 char buf[64]; /* XXX: how to figure correct size? */
30675 const char *fmt;
30676
30677 DUK_ASSERT(js_ctx->flag_ext_custom || js_ctx->flag_ext_compatible); /* caller checks */
30679
30680 DUK_MEMZERO(buf, sizeof(buf));
30681
30682 /* The #ifdef clutter here needs to handle the three cases:
30683 * (1) JX+JC, (2) JX only, (3) JC only.
30684 */
30685#if defined(DUK_USE_JX) && defined(DUK_USE_JC)
30686 if (js_ctx->flag_ext_custom)
30687#endif
30688#if defined(DUK_USE_JX)
30689 {
DUK_LOCAL_DECL void duk__enc_pointer(duk_json_enc_ctx *js_ctx, void *ptr)

◆ duk__enc_quote_string()

DUK_LOCAL_DECL void duk__enc_quote_string ( duk_json_enc_ctx * js_ctx,
duk_hstring * h_str )

Definition at line 30288 of file duktape-1.8.0/src/duktape.c.

30296 :
30297 duk__enc_quote_string(js_ctx, k);
30298}
30299
30300/* The Quote(value) operation: quote a string.
30301 *
30302 * Stack policy: [ ] -> [ ].
30303 */
30304
30306 duk_hthread *thr = js_ctx->thr;
30307 const duk_uint8_t *p, *p_start, *p_end, *p_now, *p_tmp;
30308 duk_uint8_t *q;
30309 duk_ucodepoint_t cp; /* typed for duk_unicode_decode_xutf8() */
30310
30311 DUK_DDD(DUK_DDDPRINT("duk__enc_quote_string: h_str=%!O", (duk_heaphdr *) h_str));
30312
30313 DUK_ASSERT(h_str != NULL);
30314 p_start = DUK_HSTRING_GET_DATA(h_str);
30315 p_end = p_start + DUK_HSTRING_GET_BYTELEN(h_str);
30316 p = p_start;
30317
30319
30320 /* Encode string in small chunks, estimating the maximum expansion so that
30321 * there's no need to ensure space while processing the chunk.
30322 */
30323
30324 while (p < p_end) {
30325 duk_size_t left, now, space;
30326
30327 left = (duk_size_t) (p_end - p);
30330
30331 /* Maximum expansion per input byte is 6:
30332 * - invalid UTF-8 byte causes "\uXXXX" to be emitted (6/1 = 6).
30333 * - 2-byte UTF-8 encodes as "\uXXXX" (6/2 = 3).
30334 * - 4-byte UTF-8 encodes as "\Uxxxxxxxx" (10/4 = 2.5).
30335 */
30336 space = now * 6;
30337 q = DUK_BW_ENSURE_GETPTR(thr, &js_ctx->bw, space);
30338
30339 p_now = p + now;
30340
30341 while (p < p_now) {
30342#if defined(DUK_USE_JSON_QUOTESTRING_FASTPATH)
30343 duk_uint8_t b;
30344
30345 b = duk__json_quotestr_lookup[*p++];
30346 if (DUK_LIKELY(b < 0x80)) {
30347 /* Most input bytes go through here. */
30348 *q++ = b;
30349 } else if (b >= 0xa0) {
30350 *q++ = DUK_ASC_BACKSLASH;
30351 *q++ = (duk_uint8_t) (b - 0x80);
30352 } else if (b == 0x80) {
30353 cp = (duk_ucodepoint_t) (*(p - 1));
30354 q = duk__emit_esc_auto_fast(js_ctx, cp, q);
30355 } else if (b == 0x7f && js_ctx->flag_ascii_only) {
30356 /* 0x7F is special */
30357 DUK_ASSERT(b == 0x81);
30358 cp = (duk_ucodepoint_t) 0x7f;
30359 q = duk__emit_esc_auto_fast(js_ctx, cp, q);
30360 } else {
30361 DUK_ASSERT(b == 0x81);
30362 p--;
30363
30364 /* slow path is shared */
30365#else /* DUK_USE_JSON_QUOTESTRING_FASTPATH */
30366 cp = *p;
30367
30368 if (DUK_LIKELY(cp <= 0x7f)) {
30369 /* ascii fast path: avoid decoding utf-8 */
30370 p++;
30371 if (cp == 0x22 || cp == 0x5c) {
30372 /* double quote or backslash */
30373 *q++ = DUK_ASC_BACKSLASH;
30374 *q++ = (duk_uint8_t) cp;
30375 } else if (cp < 0x20) {
30376 duk_uint_fast8_t esc_char;
30377
30378 /* This approach is a bit shorter than a straight
30379 * if-else-ladder and also a bit faster.
30380 */
30381 if (cp < (sizeof(duk__json_quotestr_esc) / sizeof(duk_uint8_t)) &&
30382 (esc_char = duk__json_quotestr_esc[cp]) != 0) {
30383 *q++ = DUK_ASC_BACKSLASH;
30384 *q++ = (duk_uint8_t) esc_char;
30385 } else {
30386 q = duk__emit_esc_auto_fast(js_ctx, cp, q);
30387 }
30388 } else if (cp == 0x7f && js_ctx->flag_ascii_only) {
30389 q = duk__emit_esc_auto_fast(js_ctx, cp, q);
30390 } else {
30391 /* any other printable -> as is */
30392 *q++ = (duk_uint8_t) cp;
30393 }
30394 } else {
30395 /* slow path is shared */
30396#endif /* DUK_USE_JSON_QUOTESTRING_FASTPATH */
30397
30398 /* slow path decode */
30399
30400 /* If XUTF-8 decoding fails, treat the offending byte as a codepoint directly
30401 * and go forward one byte. This is of course very lossy, but allows some kind
30402 * of output to be produced even for internal strings which don't conform to
30403 * XUTF-8. All standard Ecmascript strings are always CESU-8, so this behavior
30404 * does not violate the Ecmascript specification. The behavior is applied to
30405 * all modes, including Ecmascript standard JSON. Because the current XUTF-8
30406 * decoding is not very strict, this behavior only really affects initial bytes
30407 * and truncated codepoints.
30408 *
30409 * Another alternative would be to scan forwards to start of next codepoint
30410 * (or end of input) and emit just one replacement codepoint.
30411 */
30412
30413 p_tmp = p;
30414 if (!duk_unicode_decode_xutf8(thr, &p, p_start, p_end, &cp)) {
30415 /* Decode failed. */
30416 cp = *p_tmp;
30417 p = p_tmp + 1;
30418 }
30419
30420#ifdef DUK_USE_NONSTD_JSON_ESC_U2028_U2029
DUK_LOCAL_DECL void duk__enc_quote_string(duk_json_enc_ctx *js_ctx, duk_hstring *h_str)
DUK_LOCAL const duk_uint8_t duk__json_quotestr_lookup[256]
#define DUK__JSON_ENCSTR_CHUNKSIZE
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_decode_xutf8(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end, duk_ucodepoint_t *out_cp)
lu_byte left

◆ duk__enc_value()

DUK_LOCAL_DECL duk_bool_t duk__enc_value ( duk_json_enc_ctx * js_ctx,
duk_idx_t idx_holder )

Definition at line 31022 of file duktape-1.8.0/src/duktape.c.

31023 {
31024 DUK_ASSERT(js_ctx->recursion_depth >= 1);
31025 duk__enc_newline_indent(js_ctx, js_ctx->recursion_depth - 1);
31026 }
31027 }
31029
31030 duk__enc_objarr_exit(js_ctx, &entry_top);
31031
31032 DUK_ASSERT_TOP(ctx, entry_top);
31033}
31034
31035/* The Str(key, holder) operation.
31036 *
31037 * Stack policy: [ ... key ] -> [ ... ]
31038 */
31040 duk_context *ctx = (duk_context *) js_ctx->thr;
31041 duk_hthread *thr = (duk_hthread *) ctx;
31042 duk_hobject *h_tmp;
31043 duk_tval *tv;
31044 duk_tval *tv_holder;
31045 duk_tval *tv_key;
31047
31048 DUK_DDD(DUK_DDDPRINT("duk__enc_value: idx_holder=%ld, holder=%!T, key=%!T",
31049 (long) idx_holder, (duk_tval *) duk_get_tval(ctx, idx_holder),
31050 (duk_tval *) duk_get_tval(ctx, -1)));
31051
31052 DUK_UNREF(thr);
31053
31054 tv_holder = DUK_GET_TVAL_POSIDX(ctx, idx_holder);
31055 DUK_ASSERT(DUK_TVAL_IS_OBJECT(tv_holder));
31056 tv_key = DUK_GET_TVAL_NEGIDX(ctx, -1);
31058 (void) duk_hobject_getprop(thr, tv_holder, tv_key);
31059
31060 /* -> [ ... key val ] */
31061
31062 DUK_DDD(DUK_DDDPRINT("value=%!T", (duk_tval *) duk_get_tval(ctx, -1)));
31063
31064 h_tmp = duk_get_hobject_or_lfunc_coerce(ctx, -1);
31065 if (h_tmp != NULL) {
31067 h_tmp = duk_get_hobject_or_lfunc_coerce(ctx, -1); /* toJSON() can also be a lightfunc */
31068
31069 if (h_tmp != NULL && DUK_HOBJECT_IS_CALLABLE(h_tmp)) {
31070 DUK_DDD(DUK_DDDPRINT("value is object, has callable toJSON() -> call it"));
31071 /* XXX: duk_dup_unvalidated(ctx, -2) etc. */
31072 duk_dup(ctx, -2); /* -> [ ... key val toJSON val ] */
31073 duk_dup(ctx, -4); /* -> [ ... key val toJSON val key ] */
31074 duk_call_method(ctx, 1); /* -> [ ... key val val' ] */
31075 duk_remove(ctx, -2); /* -> [ ... key val' ] */
31076 } else {
31077 duk_pop(ctx); /* -> [ ... key val ] */
31078 }
31079 }
31080
31081 /* [ ... key val ] */
31082
31083 DUK_DDD(DUK_DDDPRINT("value=%!T", (duk_tval *) duk_get_tval(ctx, -1)));
31084
31085 if (js_ctx->h_replacer) {
31086 /* XXX: Here a "slice copy" would be useful. */
31087 DUK_DDD(DUK_DDDPRINT("replacer is set, call replacer"));
31088 duk_push_hobject(ctx, js_ctx->h_replacer); /* -> [ ... key val replacer ] */
31089 duk_dup(ctx, idx_holder); /* -> [ ... key val replacer holder ] */
31090 duk_dup(ctx, -4); /* -> [ ... key val replacer holder key ] */
31091 duk_dup(ctx, -4); /* -> [ ... key val replacer holder key val ] */
31092 duk_call_method(ctx, 2); /* -> [ ... key val val' ] */
31093 duk_remove(ctx, -2); /* -> [ ... key val' ] */
31094 }
31095
31096 /* [ ... key val ] */
31097
31098 DUK_DDD(DUK_DDDPRINT("value=%!T", (duk_tval *) duk_get_tval(ctx, -1)));
31099
31100 tv = DUK_GET_TVAL_NEGIDX(ctx, -1);
31101 if (DUK_TVAL_IS_OBJECT(tv)) {
31102 duk_hobject *h;
31103
31104 h = DUK_TVAL_GET_OBJECT(tv);
31105 DUK_ASSERT(h != NULL);
31106
31108#if defined(DUK_USE_JX) || defined(DUK_USE_JC)
31109 duk_hbufferobject *h_bufobj;
31110 h_bufobj = (duk_hbufferobject *) h;
31112
31113 /* Conceptually we'd extract the plain underlying buffer
31114 * or its slice and then do a type mask check below to
31115 * see if we should reject it. Do the mask check here
31116 * instead to avoid making a copy of the buffer slice.
31117 */
31118
31120 DUK_DDD(DUK_DDDPRINT("-> bufferobject (-> plain buffer) will result in undefined (type mask check)"));
31121 goto pop2_undef;
31122 }
31123 DUK_DDD(DUK_DDDPRINT("-> bufferobject won't result in undefined, encode directly"));
31124 duk__enc_bufferobject(js_ctx, h_bufobj);
31125 goto pop2_emitted;
31126#else
31127 DUK_DDD(DUK_DDDPRINT("no JX/JC support, bufferobject/buffer will always result in undefined"));
31128 goto pop2_undef;
31129#endif
31130 } else {
31132 switch ((int) c) {
31134 DUK_DDD(DUK_DDDPRINT("value is a Number object -> coerce with ToNumber()"));
31135 duk_to_number(ctx, -1);
31136 /* The coercion potentially invokes user .valueOf() and .toString()
31137 * but can't result in a function value because [[DefaultValue]] would
31138 * reject such a result: test-dev-json-stringify-coercion-1.js.
31139 */
31140 DUK_ASSERT(!duk_is_callable(ctx, -1));
31141 break;
31142 }
31144 DUK_DDD(DUK_DDDPRINT("value is a String object -> coerce with ToString()"));
31145 duk_to_string(ctx, -1);
31146 /* Same coercion behavior as for Number. */
31147 DUK_ASSERT(!duk_is_callable(ctx, -1));
31148 break;
31149 }
31150#if defined(DUK_USE_JX) || defined(DUK_USE_JC)
31152#endif
31154 DUK_DDD(DUK_DDDPRINT("value is a Boolean/Buffer/Pointer object -> get internal value"));
31156 duk_remove(ctx, -2);
31157 break;
31158 }
31159 default: {
31160 /* Normal object which doesn't get automatically coerced to a
31161 * primitive value. Functions are checked for specially. The
31162 * primitive value coercions for Number, String, Pointer, and
31163 * Boolean can't result in functions so suffices to check here.
31164 */
31165 DUK_ASSERT(h != NULL);
31166 if (DUK_HOBJECT_IS_CALLABLE(h)) {
31167#if defined(DUK_USE_JX) || defined(DUK_USE_JC)
31168 if (js_ctx->flags & (DUK_JSON_FLAG_EXT_CUSTOM |
31170 /* We only get here when doing non-standard JSON encoding */
31171 DUK_DDD(DUK_DDDPRINT("-> function allowed, serialize to custom format"));
31174 goto pop2_emitted;
31175 } else {
31176 DUK_DDD(DUK_DDDPRINT("-> will result in undefined (function)"));
31177 goto pop2_undef;
31178 }
31179#else /* DUK_USE_JX || DUK_USE_JC */
31180 DUK_DDD(DUK_DDDPRINT("-> will result in undefined (function)"));
31181 goto pop2_undef;
31182#endif /* DUK_USE_JX || DUK_USE_JC */
31183 }
31184 }
31185 } /* end switch */
31186 }
31187 }
31188
31189 /* [ ... key val ] */
31190
31191 DUK_DDD(DUK_DDDPRINT("value=%!T", (duk_tval *) duk_get_tval(ctx, -1)));
31192
31193 if (duk_check_type_mask(ctx, -1, js_ctx->mask_for_undefined)) {
31194 /* will result in undefined */
31195 DUK_DDD(DUK_DDDPRINT("-> will result in undefined (type mask check)"));
31196 goto pop2_undef;
31197 }
31198 tv = DUK_GET_TVAL_NEGIDX(ctx, -1);
31199
31200 switch (DUK_TVAL_GET_TAG(tv)) {
31201#if defined(DUK_USE_JX) || defined(DUK_USE_JC)
31202 /* When JX/JC not in use, the type mask above will avoid this case if needed. */
31203 case DUK_TAG_UNDEFINED: {
31205 break;
31206 }
31207#endif
31208 case DUK_TAG_NULL: {
31210 break;
31211 }
31212 case DUK_TAG_BOOLEAN: {
31215 break;
31216 }
31217#if defined(DUK_USE_JX) || defined(DUK_USE_JC)
31218 /* When JX/JC not in use, the type mask above will avoid this case if needed. */
31219 case DUK_TAG_POINTER: {
31221 break;
31222 }
31223#endif /* DUK_USE_JX || DUK_USE_JC */
31224 case DUK_TAG_STRING: {
31226 DUK_ASSERT(h != NULL);
31227
31228 duk__enc_quote_string(js_ctx, h);
31229 break;
31230 }
31231 case DUK_TAG_OBJECT: {
31233 DUK_ASSERT(h != NULL);
31234
31235 /* Function values are handled completely above (including
31236 * coercion results):
31237 */
31239
31241 duk__enc_array(js_ctx);
31242 } else {
31243 duk__enc_object(js_ctx);
31244 }
31245 break;
31246 }
31247#if defined(DUK_USE_JX) || defined(DUK_USE_JC)
31248 /* When JX/JC not in use, the type mask above will avoid this case if needed. */
31249 case DUK_TAG_BUFFER: {
31251 break;
31252 }
31253#endif /* DUK_USE_JX || DUK_USE_JC */
31254 case DUK_TAG_LIGHTFUNC: {
31255#if defined(DUK_USE_JX) || defined(DUK_USE_JC)
31256 /* We only get here when doing non-standard JSON encoding */
31259#else
31260 /* Standard JSON omits functions */
31262#endif
31263 break;
31264 }
31265#if defined(DUK_USE_FASTINT)
31266 case DUK_TAG_FASTINT:
31267 /* Number serialization has a significant impact relative to
31268 * other fast path code, so careful fast path for fastints.
31269 */
31270 duk__enc_fastint_tval(js_ctx, tv);
31271 break;
31272#endif
31273 default: {
31274 /* number */
#define DUK_TYPE_MASK_BUFFER
#define duk_is_callable(ctx, index)
#define DUK_HOBJECT_CLASS_BOOLEAN
#define DUK_HOBJECT_CLASS_POINTER
#define DUK_STRIDX_TRUE
DUK_EXTERNAL duk_bool_t duk_check_type_mask(duk_context *ctx, duk_idx_t index, duk_uint_t mask)
#define DUK_ASC_RBRACKET
#define DUK_ASSERT_HBUFFEROBJECT_VALID(h)
#define DUK_TVAL_IS_UNUSED(tv)
#define DUK_HOBJECT_CLASS_NUMBER
#define DUK_STRIDX_FALSE
#define DUK_JSON_FLAG_EXT_CUSTOM
#define DUK_STRIDX_INT_VALUE
DUK_INTERNAL_DECL duk_bool_t duk_hobject_getprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key)
#define DUK_TVAL_GET_POINTER(tv)
DUK_INTERNAL_DECL duk_hobject * duk_get_hobject_or_lfunc_coerce(duk_context *ctx, duk_idx_t index)
DUK_LOCAL_DECL void duk__enc_buffer(duk_json_enc_ctx *js_ctx, duk_hbuffer *h)
#define DUK_TVAL_GET_BOOLEAN(tv)
#define DUK_GET_TVAL_POSIDX(ctx, idx)
DUK_LOCAL_DECL void duk__enc_bufferobject(duk_json_enc_ctx *js_ctx, duk_hbufferobject *h_bufobj)
#define DUK_STRIDX_TO_JSON
#define DUK_JSON_FLAG_EXT_COMPATIBLE
#define DUK_HOBJECT_CLASS_STRING

◆ duk__encode_i32()

DUK_LOCAL duk_uint32_t duk__encode_i32 ( duk_int32_t x)

Definition at line 77727 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__append_jump_offset().

◆ duk__err_augment_builtin_create()

DUK_LOCAL void duk__err_augment_builtin_create ( duk_hthread * thr,
duk_hthread * thr_callstack,
const char * c_filename,
duk_int_t c_line,
duk_small_int_t noblame_fileline,
duk_hobject * obj )

Definition at line 40290 of file duktape-1.8.0/src/duktape.c.

40293 {
40294 duk_pop(ctx);
40295 }
40296
40297 DUK_DDD(DUK_DDDPRINT("compile error, after adding line info: %!T",
40298 (duk_tval *) duk_get_tval(ctx, -1)));
40299}
40300
40301/*
40302 * Augment an error being created using Duktape specific properties
40303 * like _Tracedata or .fileName/.lineNumber.
40304 */
40305
40306#if defined(DUK_USE_AUGMENT_ERROR_CREATE)
40307DUK_LOCAL void duk__err_augment_builtin_create(duk_hthread *thr, duk_hthread *thr_callstack, const char *c_filename, duk_int_t c_line, duk_small_int_t noblame_fileline, duk_hobject *obj) {
40308 duk_context *ctx = (duk_context *) thr;
40309#if defined(DUK_USE_ASSERTIONS)
40310 duk_int_t entry_top;
40311#endif
40312
40313#if defined(DUK_USE_ASSERTIONS)
40314 entry_top = duk_get_top(ctx);
40315#endif
40316 DUK_ASSERT(obj != NULL);
40317
40318 DUK_UNREF(obj); /* unreferenced w/o tracebacks */
40319 DUK_UNREF(ctx); /* unreferenced w/o asserts */
40320
40322
40323#if defined(DUK_USE_TRACEBACKS)
40324 /* If tracebacks are enabled, the '_Tracedata' property is the only
40325 * thing we need: 'fileName' and 'lineNumber' are virtual properties
40326 * which use '_Tracedata'.
DUK_LOCAL void duk__err_augment_builtin_create(duk_hthread *thr, duk_hthread *thr_callstack, const char *c_filename, duk_int_t c_line, duk_small_int_t noblame_fileline, duk_hobject *obj)

Referenced by duk_err_augment_error_create().

◆ duk__err_augment_user()

DUK_LOCAL void duk__err_augment_user ( duk_hthread * thr,
duk_small_uint_t stridx_cb )

Definition at line 39904 of file duktape-1.8.0/src/duktape.c.

39912 : since further longjmp()s may occur while calling the error handler
39913 * (for many reasons, e.g. a labeled 'break' inside the handler), the
39914 * caller can make no assumptions on the thr->heap->lj state after the
39915 * call (this affects especially duk_error_throw.c). This is not an issue
39916 * as long as the caller writes to the lj state only after the error handler
39917 * finishes.
39918 */
39919
39920#if defined(DUK_USE_ERRTHROW) || defined(DUK_USE_ERRCREATE)
39922 duk_context *ctx = (duk_context *) thr;
39923 duk_tval *tv_hnd;
39924 duk_small_uint_t call_flags;
39925 duk_int_t rc;
39926
39927 DUK_ASSERT(thr != NULL);
39928 DUK_ASSERT(thr->heap != NULL);
39929 DUK_ASSERT_DISABLE(stridx_cb >= 0); /* unsigned */
39930 DUK_ASSERT(stridx_cb < DUK_HEAP_NUM_STRINGS);
39931
39933 DUK_DD(DUK_DDPRINT("recursive call to error handler, ignore"));
39934 return;
39935 }
39936
39937 /*
39938 * Check whether or not we have an error handler.
39939 *
39940 * We must be careful of not triggering an error when looking up the
39941 * property. For instance, if the property is a getter, we don't want
39942 * to call it, only plain values are allowed. The value, if it exists,
39943 * is not checked. If the value is not a function, a TypeError happens
39944 * when it is called and that error replaces the original one.
39945 */
39946
39947 DUK_ASSERT_VALSTACK_SPACE(thr, 4); /* 3 entries actually needed below */
39948
39949 /* [ ... errval ] */
39950
39951 if (thr->builtins[DUK_BIDX_DUKTAPE] == NULL) {
39952 /* When creating built-ins, some of the built-ins may not be set
39953 * and we want to tolerate that when throwing errors.
39954 */
39955 DUK_DD(DUK_DDPRINT("error occurred when DUK_BIDX_DUKTAPE is NULL, ignoring"));
39956 return;
39957 }
39960 DUK_HTHREAD_GET_STRING(thr, stridx_cb));
39961 if (tv_hnd == NULL) {
39962 DUK_DD(DUK_DDPRINT("error handler does not exist or is not a plain value: %!T",
39963 (duk_tval *) tv_hnd));
39964 return;
39965 }
39966 DUK_DDD(DUK_DDDPRINT("error handler dump (callability not checked): %!T",
39967 (duk_tval *) tv_hnd));
39968 duk_push_tval(ctx, tv_hnd);
39969
39970 /* [ ... errval errhandler ] */
39971
39972 duk_insert(ctx, -2); /* -> [ ... errhandler errval ] */
39973 duk_push_undefined(ctx);
39974 duk_insert(ctx, -2); /* -> [ ... errhandler undefined(= this) errval ] */
39975
39976 /* [ ... errhandler undefined errval ] */
39977
39978 /*
39979 * DUK_CALL_FLAG_IGNORE_RECLIMIT causes duk_handle_call() to ignore C
39980 * recursion depth limit (and won't increase it either). This is
39981 * dangerous, but useful because it allows the error handler to run
39982 * even if the original error is caused by C recursion depth limit.
39983 *
39984 * The heap level DUK_HEAP_FLAG_ERRHANDLER_RUNNING is set for the
39985 * duration of the error handler and cleared afterwards. This flag
39986 * prevents the error handler from running recursively. The flag is
39987 * heap level so that the flag properly controls even coroutines
39988 * launched by an error handler. Since the flag is heap level, it is
39989 * critical to restore it correctly.
39990 *
39991 * We ignore errors now: a success return and an error value both
39992 * replace the original error value. (This would be easy to change.)
#define DUK_HEAP_HAS_ERRHANDLER_RUNNING(heap)
DUK_EXTERNAL void duk_push_undefined(duk_context *ctx)
#define DUK_BIDX_DUKTAPE
DUK_LOCAL void duk__err_augment_user(duk_hthread *thr, duk_small_uint_t stridx_cb)
duk_hobject * builtins[DUK_NUM_BUILTINS]

References duk_hthread::builtins, DUK_ASSERT, DUK_ASSERT_DISABLE, DUK_ASSERT_VALSTACK_SPACE, DUK_BIDX_DUKTAPE, DUK_CALL_FLAG_IGNORE_RECLIMIT, DUK_DD, DUK_DDD, DUK_DDDPRINT, DUK_DDPRINT, DUK_HEAP_HAS_ERRHANDLER_RUNNING, DUK_HEAP_NUM_STRINGS, DUK_HEAP_SET_ERRHANDLER_RUNNING, duk_hobject_find_existing_entry_tval_ptr(), DUK_HTHREAD_GET_STRING, duk_insert(), duk_push_tval(), duk_push_undefined(), duk_hthread::heap, and NULL.

Referenced by duk_err_longjmp().

◆ duk__error_getter_helper()

DUK_LOCAL duk_ret_t duk__error_getter_helper ( duk_context * ctx,
duk_small_int_t output_type )

Definition at line 27189 of file duktape-1.8.0/src/duktape.c.

27195 : although _Tracedata is an internal property, user code can currently
27196 * write to the array (or replace it with something other than an array).
27197 * The code below must tolerate arbitrary _Tracedata. It can throw errors
27198 * etc, but cannot cause a segfault or memory unsafe behavior.
27199 */
27200
27201/* constants arbitrary, chosen for small loads */
27202#define DUK__OUTPUT_TYPE_TRACEBACK (-1)
27203#define DUK__OUTPUT_TYPE_FILENAME 0
27204#define DUK__OUTPUT_TYPE_LINENUMBER 1
27205
27207 duk_hthread *thr = (duk_hthread *) ctx;
27208 duk_idx_t idx_td;
27209 duk_small_int_t i; /* traceback depth fits into 16 bits */
27210 duk_small_int_t t; /* stack type fits into 16 bits */
27211 duk_small_int_t count_func = 0; /* traceback depth ensures fits into 16 bits */
27212 const char *str_tailcall = " tailcall";
27213 const char *str_strict = " strict";
27214 const char *str_construct = " construct";
27215 const char *str_prevyield = " preventsyield";
27216 const char *str_directeval = " directeval";
27217 const char *str_empty = "";
27218
27219 DUK_ASSERT_TOP(ctx, 0); /* fixed arg count */
27220 DUK_UNREF(thr);
27221
27222 duk_push_this(ctx);
27224 idx_td = duk_get_top_index(ctx);
27225
27227 duk_push_this(ctx);
27228
27229 /* [ ... this tracedata sep this ] */
27230
27231 /* XXX: skip null filename? */
27232
27233 if (duk_check_type(ctx, idx_td, DUK_TYPE_OBJECT)) {
27234 /* Current tracedata contains 2 entries per callstack entry. */
27235 for (i = 0; ; i += 2) {
27236 duk_int_t pc;
27237 duk_int_t line;
27238 duk_int_t flags;
27239 duk_double_t d;
27240 const char *funcname;
27241 const char *filename;
27242 duk_hobject *h_func;
27243 duk_hstring *h_name;
27244
27245 duk_require_stack(ctx, 5);
27246 duk_get_prop_index(ctx, idx_td, i);
27247 duk_get_prop_index(ctx, idx_td, i + 1);
27248 d = duk_to_number(ctx, -1);
27250 flags = (duk_int_t) DUK_FLOOR(d / DUK_DOUBLE_2TO32);
27251 t = (duk_small_int_t) duk_get_type(ctx, -2);
27252
27253 if (t == DUK_TYPE_OBJECT || t == DUK_TYPE_LIGHTFUNC) {
27254 /*
27255 * Ecmascript/native function call or lightfunc call
27256 */
27257
27258 count_func++;
27259
27260 /* [ ... v1(func) v2(pc+flags) ] */
27261
27262 h_func = duk_get_hobject(ctx, -2); /* NULL for lightfunc */
27263
27266
27267#if defined(DUK_USE_PC2LINE)
27268 line = duk_hobject_pc2line_query(ctx, -4, (duk_uint_fast32_t) pc);
27269#else
27270 line = 0;
27271#endif
27272
27273 /* [ ... v1 v2 name filename ] */
27274
27275 /* When looking for .fileName/.lineNumber, blame first
27276 * function which has a .fileName.
27277 */
27278 if (duk_is_string(ctx, -1)) {
27279 if (output_type == DUK__OUTPUT_TYPE_FILENAME) {
27280 return 1;
27281 } else if (output_type == DUK__OUTPUT_TYPE_LINENUMBER) {
27282 duk_push_int(ctx, line);
27283 return 1;
27284 }
27285 }
27286
27287 /* XXX: Change 'anon' handling here too, to use empty string for anonymous functions? */
27288 /* XXX: Could be improved by coercing to a readable duk_tval (especially string escaping) */
27289 h_name = duk_get_hstring(ctx, -2); /* may be NULL */
27290 funcname = (h_name == NULL || h_name == DUK_HTHREAD_STRING_EMPTY_STRING(thr)) ?
27291 "[anon]" : (const char *) DUK_HSTRING_GET_DATA(h_name);
27292 filename = duk_get_string(ctx, -1);
27293 filename = filename ? filename : "";
27295 DUK_ASSERT(filename != NULL);
27296
27297 if (h_func == NULL) {
27298 duk_push_sprintf(ctx, "at %s light%s%s%s%s%s",
27299 (const char *) funcname,
27300 (const char *) ((flags & DUK_ACT_FLAG_STRICT) ? str_strict : str_empty),
27301 (const char *) ((flags & DUK_ACT_FLAG_TAILCALLED) ? str_tailcall : str_empty),
27302 (const char *) ((flags & DUK_ACT_FLAG_CONSTRUCT) ? str_construct : str_empty),
27303 (const char *) ((flags & DUK_ACT_FLAG_DIRECT_EVAL) ? str_directeval : str_empty),
27304 (const char *) ((flags & DUK_ACT_FLAG_PREVENT_YIELD) ? str_prevyield : str_empty));
27305 } else if (DUK_HOBJECT_HAS_NATIVEFUNCTION(h_func)) {
27306 duk_push_sprintf(ctx, "at %s (%s) native%s%s%s%s%s",
27307 (const char *) funcname,
27308 (const char *) filename,
27309 (const char *) ((flags & DUK_ACT_FLAG_STRICT) ? str_strict : str_empty),
27310 (const char *) ((flags & DUK_ACT_FLAG_TAILCALLED) ? str_tailcall : str_empty),
27311 (const char *) ((flags & DUK_ACT_FLAG_CONSTRUCT) ? str_construct : str_empty),
27312 (const char *) ((flags & DUK_ACT_FLAG_DIRECT_EVAL) ? str_directeval : str_empty),
27313 (const char *) ((flags & DUK_ACT_FLAG_PREVENT_YIELD) ? str_prevyield : str_empty));
27314 } else {
27315 duk_push_sprintf(ctx, "at %s (%s:%ld)%s%s%s%s%s",
27316 (const char *) funcname,
27317 (const char *) filename,
27318 (long) line,
27319 (const char *) ((flags & DUK_ACT_FLAG_STRICT) ? str_strict : str_empty),
27320 (const char *) ((flags & DUK_ACT_FLAG_TAILCALLED) ? str_tailcall : str_empty),
27321 (const char *) ((flags & DUK_ACT_FLAG_CONSTRUCT) ? str_construct : str_empty),
27322 (const char *) ((flags & DUK_ACT_FLAG_DIRECT_EVAL) ? str_directeval : str_empty),
27323 (const char *) ((flags & DUK_ACT_FLAG_PREVENT_YIELD) ? str_prevyield : str_empty));
27324 }
27325 duk_replace(ctx, -5); /* [ ... v1 v2 name filename str ] -> [ ... str v2 name filename ] */
27326 duk_pop_n(ctx, 3); /* -> [ ... str ] */
27327 } else if (t == DUK_TYPE_STRING) {
27328 /*
27329 * __FILE__ / __LINE__ entry, here 'pc' is line number directly.
27330 * Sometimes __FILE__ / __LINE__ is reported as the source for
27331 * the error (fileName, lineNumber), sometimes not.
27332 */
27333
27334 /* [ ... v1(filename) v2(line+flags) ] */
27335
27336 /* When looking for .fileName/.lineNumber, blame compilation
27337 * or C call site unless flagged not to do so.
27338 */
27339 if (!(flags & DUK_TB_FLAG_NOBLAME_FILELINE)) {
27340 if (output_type == DUK__OUTPUT_TYPE_FILENAME) {
27341 duk_pop(ctx);
27342 return 1;
27343 } else if (output_type == DUK__OUTPUT_TYPE_LINENUMBER) {
27344 duk_push_int(ctx, pc);
27345 return 1;
27346 }
27347 }
27348
27349 duk_push_sprintf(ctx, "at [anon] (%s:%ld) internal",
27350 (const char *) duk_get_string(ctx, -2), (long) pc);
27351 duk_replace(ctx, -3); /* [ ... v1 v2 str ] -> [ ... str v2 ] */
27352 duk_pop(ctx); /* -> [ ... str ] */
27353 } else {
27354 /* unknown, ignore */
27355 duk_pop_2(ctx);
27356 break;
27357 }
27358 }
27359
27360 if (count_func >= DUK_USE_TRACEBACK_DEPTH) {
27361 /* Possibly truncated; there is no explicit truncation
27362 * marker so this is the best we can do.
27363 */
27364
#define DUK_ACT_FLAG_TAILCALLED
#define DUK_ACT_FLAG_PREVENT_YIELD
DUK_EXTERNAL void duk_push_this(duk_context *ctx)
DUK_EXTERNAL duk_bool_t duk_check_type(duk_context *ctx, duk_idx_t index, duk_int_t type)
#define DUK_ACT_FLAG_STRICT
#define DUK__OUTPUT_TYPE_LINENUMBER
#define DUK_ACT_FLAG_DIRECT_EVAL
DUK_EXTERNAL duk_int_t duk_get_type(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL void duk_replace(duk_context *ctx, duk_idx_t to_index)
#define DUK_ACT_FLAG_CONSTRUCT
DUK_EXTERNAL duk_idx_t duk_get_top_index(duk_context *ctx)
#define DUK_HOBJECT_HAS_NATIVEFUNCTION(h)
#define DUK_STRIDX_INT_TRACEDATA
DUK_EXTERNAL void duk_pop_n(duk_context *ctx, duk_idx_t count)
DUK_LOCAL duk_ret_t duk__error_getter_helper(duk_context *ctx, duk_small_int_t output_type)
DUK_INTERNAL_DECL duk_uint_fast32_t duk_hobject_pc2line_query(duk_context *ctx, duk_idx_t idx_func, duk_uint_fast32_t pc)
#define DUK_STRIDX_NEWLINE_4SPACE
#define DUK__OUTPUT_TYPE_FILENAME
static int funcname(LexState *ls, expdesc *v)
static void cannot(const char *what)

References DUK__OUTPUT_TYPE_FILENAME, DUK__OUTPUT_TYPE_LINENUMBER, DUK_ACT_FLAG_CONSTRUCT, DUK_ACT_FLAG_DIRECT_EVAL, DUK_ACT_FLAG_PREVENT_YIELD, DUK_ACT_FLAG_STRICT, DUK_ACT_FLAG_TAILCALLED, DUK_ASSERT, DUK_ASSERT_TOP, duk_check_type(), DUK_DOUBLE_2TO32, DUK_FLOOR, DUK_FMOD, duk_get_hobject(), duk_get_hstring(), duk_get_prop_index(), duk_get_prop_stridx(), duk_get_string(), duk_get_top_index(), duk_get_type(), DUK_HOBJECT_HAS_NATIVEFUNCTION, duk_hobject_pc2line_query(), DUK_HSTRING_GET_DATA, DUK_HTHREAD_STRING_EMPTY_STRING, duk_is_string(), duk_pop(), duk_pop_2(), duk_pop_n(), duk_push_hstring_stridx(), duk_push_int(), duk_push_sprintf(), duk_push_this(), duk_replace(), duk_require_stack(), DUK_STRIDX_BRACKETED_ELLIPSIS, DUK_STRIDX_FILE_NAME, DUK_STRIDX_INT_TRACEDATA, DUK_STRIDX_NAME, DUK_STRIDX_NEWLINE_4SPACE, DUK_TB_FLAG_NOBLAME_FILELINE, duk_to_number(), DUK_TYPE_LIGHTFUNC, DUK_TYPE_OBJECT, DUK_TYPE_STRING, DUK_UNREF, DUK_USE_TRACEBACK_DEPTH, funcname(), and NULL.

◆ duk__error_setter_helper()

DUK_LOCAL duk_ret_t duk__error_setter_helper ( duk_context * ctx,
duk_small_uint_t stridx_key )

Definition at line 27419 of file duktape-1.8.0/src/duktape.c.

27424 {
27425 DUK_UNREF(ctx);
27426 return 0;
27427}
27428
27430 DUK_UNREF(ctx);
27431 return 0;
27432}
27433
27434#endif /* DUK_USE_TRACEBACKS */
27435
27437 /* Attempt to write 'stack', 'fileName', 'lineNumber' works as if
27438 * user code called Object.defineProperty() to create an overriding
27439 * own property. This allows user code to overwrite .fileName etc
27440 * intuitively as e.g. "err.fileName = 'dummy'" as one might expect.
27441 * See https://github.com/svaarala/duktape/issues/387.
27442 */
27443
DUK_LOCAL duk_ret_t duk__error_setter_helper(duk_context *ctx, duk_small_uint_t stridx_key)
DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_linenumber_getter(duk_context *ctx)

◆ duk__exp()

DUK_LOCAL double duk__exp ( double x)

Definition at line 32753 of file duktape-1.8.0/src/duktape.c.

32755 {

◆ duk__expr()

DUK_LOCAL_DECL void duk__expr ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res,
duk_small_uint_t rbp_flags )

Definition at line 62480 of file duktape-1.8.0/src/duktape.c.

62497 {
62498 duk_hthread *thr = comp_ctx->thr;
62499 duk_context *ctx = (duk_context *) thr;
62500 duk_ivalue tmp_alloc; /* 'res' is used for "left", and 'tmp' for "right" */
62501 duk_ivalue *tmp = &tmp_alloc;
62502 duk_small_uint_t rbp;
62503
62504 DUK__RECURSION_INCREASE(comp_ctx, thr);
62505
62507
62508 /* filter out flags from exprtop rbp_flags here to save space */
62509 rbp = rbp_flags & DUK__EXPR_RBP_MASK;
62510
62511 DUK_DDD(DUK_DDDPRINT("duk__expr(), rbp_flags=%ld, rbp=%ld, allow_in=%ld, paren_level=%ld",
62512 (long) rbp_flags, (long) rbp, (long) comp_ctx->curr_func.allow_in,
62513 (long) comp_ctx->curr_func.paren_level));
62514
62515 DUK_MEMZERO(&tmp_alloc, sizeof(tmp_alloc));
62516 tmp->x1.valstack_idx = duk_get_top(ctx);
62517 tmp->x2.valstack_idx = tmp->x1.valstack_idx + 1;
62518 duk_push_undefined(ctx);
62519 duk_push_undefined(ctx);
62520
62521 /* XXX: where to release temp regs in intermediate expressions?
62522 * e.g. 1+2+3 -> don't inflate temp register count when parsing this.
62523 * that particular expression temp regs can be forced here.
62524 */
62525
62526 /* XXX: increase ctx->expr_tokens here for every consumed token
62527 * (this would be a nice statistic)?
62528 */
62529
62530 if (comp_ctx->curr_token.t == DUK_TOK_SEMICOLON || comp_ctx->curr_token.t == DUK_TOK_RPAREN) {
62531 /* XXX: possibly incorrect handling of empty expression */
62532 DUK_DDD(DUK_DDDPRINT("empty expression"));
62533 if (!(rbp_flags & DUK__EXPR_FLAG_ALLOW_EMPTY)) {
62535 }
62536 res->t = DUK_IVAL_PLAIN;
62537 res->x1.t = DUK_ISPEC_VALUE;
62538 duk_push_undefined(ctx);
62539 duk_replace(ctx, res->x1.valstack_idx);
62540 goto cleanup;
#define DUK__EXPR_FLAG_ALLOW_EMPTY
#define DUK__EXPR_RBP_MASK
#define DUK_STR_EMPTY_EXPR_NOT_ALLOWED
#define DUK_IVAL_PLAIN
#define DUK_TOK_SEMICOLON
#define DUK__RECURSION_INCREASE(comp_ctx, thr)
#define DUK_ISPEC_VALUE
#define DUK__PARSE_EXPR_SLOTS
#define DUK_TOK_RPAREN

Referenced by duk__expr_toforcedreg(), duk__expr_toplain_ignore(), duk__exprtop_toforcedreg(), and duk__exprtop_toreg().

◆ duk__expr_is_empty()

DUK_LOCAL_DECL duk_bool_t duk__expr_is_empty ( duk_compiler_ctx * comp_ctx)

Definition at line 60953 of file duktape-1.8.0/src/duktape.c.

◆ duk__expr_lbp()

DUK_LOCAL_DECL duk_small_uint_t duk__expr_lbp ( duk_compiler_ctx * comp_ctx)

Definition at line 62436 of file duktape-1.8.0/src/duktape.c.

62444 :
62446 return;
62447
62448 syntax_error_lvalue:
62450 return;
62451}
62452
62454 duk_small_int_t tok = comp_ctx->curr_token.t;
62455
62456 DUK_ASSERT(tok >= DUK_TOK_MINVAL && tok <= DUK_TOK_MAXVAL);
62458
62459 /* XXX: integrate support for this into led() instead?
62460 * Similar issue as post-increment/post-decrement.
62461 */
62462
62463 /* prevent duk__expr_led() by using a binding power less than anything valid */
DUK_LOCAL_DECL duk_small_uint_t duk__expr_lbp(duk_compiler_ctx *comp_ctx)
#define DUK_STR_INVALID_EXPRESSION
#define DUK_TOK_MINVAL
#define DUK_STR_INVALID_LVALUE

◆ duk__expr_led()

DUK_LOCAL_DECL void duk__expr_led ( duk_compiler_ctx * comp_ctx,
duk_ivalue * left,
duk_ivalue * res )

Definition at line 61483 of file duktape-1.8.0/src/duktape.c.

61483 :
61484 {
61485 /* Stack top contains plain value */
61486 res->t = DUK_IVAL_PLAIN;
61487 res->x1.t = DUK_ISPEC_VALUE;
61488 duk_replace(ctx, res->x1.valstack_idx);
61489 return;
61490 }
61491
61492 syntax_error:
61494}
61495
61496/* XXX: add flag to indicate whether caller cares about return value; this
61497 * affects e.g. handling of assignment expressions. This change needs API
61498 * changes elsewhere too.
61499 */
61501 duk_hthread *thr = comp_ctx->thr;
61502 duk_context *ctx = (duk_context *) thr;
61503 duk_token *tk;
61504 duk_small_int_t tok;
61505 duk_uint32_t args; /* temp variable to pass constants and flags to shared code */
61506
61507 /*
61508 * ctx->prev_token token to process with duk__expr_led()
61509 * ctx->curr_token updated by caller
61510 */
61511
61512 comp_ctx->curr_func.led_count++;
61513
61514 /* The token in the switch has already been eaten here */
61515 tk = &comp_ctx->prev_token;
61516 tok = tk->t;
61517
61518 DUK_DDD(DUK_DDDPRINT("duk__expr_led(), prev_token.t=%ld, allow_in=%ld, paren_level=%ld",
61519 (long) tk->t, (long) comp_ctx->curr_func.allow_in, (long) comp_ctx->curr_func.paren_level));
61520
61521 /* XXX: default priority for infix operators is duk__expr_lbp(tok) -> get it here? */
61522
61523 switch (tok) {
61524
61525 /* PRIMARY EXPRESSIONS */
61526
61527 case DUK_TOK_PERIOD: {
61528 /* Property access expressions are critical for correct LHS ordering,
61529 * see comments in duk__expr()!
61530 *
61531 * A conservative approach would be to use duk__ivalue_totempconst()
61532 * for 'left'. However, allowing a reg-bound variable seems safe here
61533 * and is nice because "foo.bar" is a common expression. If the ivalue
61534 * is used in an expression a GETPROP will occur before any changes to
61535 * the base value can occur. If the ivalue is used as an assignment
61536 * LHS, the assignment code will ensure the base value is safe from
61537 * RHS mutation.
61538 */
61539
61540 /* XXX: This now coerces an identifier into a GETVAR to a temp, which
61541 * causes an extra LDREG in call setup. It's sufficient to coerce to a
61542 * unary ivalue?
61543 */
61544 duk__ivalue_toplain(comp_ctx, left);
61545
61546 /* NB: must accept reserved words as property name */
61547 if (comp_ctx->curr_token.t_nores != DUK_TOK_IDENTIFIER) {
61549 }
61550
61551 res->t = DUK_IVAL_PROP;
61552 duk__copy_ispec(comp_ctx, &left->x1, &res->x1); /* left.x1 -> res.x1 */
61553 DUK_ASSERT(comp_ctx->curr_token.str1 != NULL);
61554 duk_push_hstring(ctx, comp_ctx->curr_token.str1);
61555 duk_replace(ctx, res->x2.valstack_idx);
61556 res->x2.t = DUK_ISPEC_VALUE;
61557
61558 /* special RegExp literal handling after IdentifierName */
61559 comp_ctx->curr_func.reject_regexp_in_adv = 1;
61560
61561 duk__advance(comp_ctx);
61562 return;
61563 }
61564 case DUK_TOK_LBRACKET: {
61565 /* Property access expressions are critical for correct LHS ordering,
61566 * see comments in duk__expr()!
61567 */
61568
61569 /* XXX: optimize temp reg use */
61570 /* XXX: similar coercion issue as in DUK_TOK_PERIOD */
61571 /* XXX: coerce to regs? it might be better for enumeration use, where the
61572 * same PROP ivalue is used multiple times. Or perhaps coerce PROP further
61573 * there?
61574 */
61575 /* XXX: for simple cases like x['y'] an unnecessary LDREG is
61576 * emitted for the base value; could avoid it if we knew that
61577 * the key expression is safe (e.g. just a single literal).
61578 */
61579
61580 /* The 'left' value must not be a register bound variable
61581 * because it may be mutated during the rest of the expression
61582 * and E5.1 Section 11.2.1 specifies the order of evaluation
61583 * so that the base value is evaluated first.
61584 * See: test-bug-nested-prop-mutate.js.
61585 */
61586 duk__ivalue_totempconst(comp_ctx, left);
61587 duk__expr_toplain(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/); /* Expression, ']' terminates */
61589
61590 res->t = DUK_IVAL_PROP;
61591 duk__copy_ispec(comp_ctx, &res->x1, &res->x2); /* res.x1 -> res.x2 */
61592 duk__copy_ispec(comp_ctx, &left->x1, &res->x1); /* left.x1 -> res.x1 */
61593 return;
61594 }
61595 case DUK_TOK_LPAREN: {
61596 /* function call */
61597 duk_reg_t reg_cs = DUK__ALLOCTEMPS(comp_ctx, 2);
61598 duk_int_t nargs;
61599 duk_small_uint_t call_flags = 0;
61600
61601 /*
61602 * XXX: attempt to get the call result to "next temp" whenever
61603 * possible to avoid unnecessary register shuffles.
61604 *
61605 * XXX: CSPROP (and CSREG) can overwrite the call target register, and save one temp,
61606 * if the call target is a temporary register and at the top of the temp reg "stack".
61607 */
61608
61609 /*
61610 * Setup call: target and 'this' binding. Three cases:
61611 *
61612 * 1. Identifier base (e.g. "foo()")
61613 * 2. Property base (e.g. "foo.bar()")
61614 * 3. Register base (e.g. "foo()()"; i.e. when a return value is a function)
61615 */
61616
61617 if (left->t == DUK_IVAL_VAR) {
61618 duk_hstring *h_varname;
61619 duk_reg_t reg_varbind;
61620 duk_regconst_t rc_varname;
61621
61622 DUK_DDD(DUK_DDDPRINT("function call with identifier base"));
61623
61624 h_varname = duk_get_hstring(ctx, left->x1.valstack_idx);
61625 DUK_ASSERT(h_varname != NULL);
61626 if (h_varname == DUK_HTHREAD_STRING_EVAL(thr)) {
61627 /* Potential direct eval call detected, flag the CALL
61628 * so that a run-time "direct eval" check is made and
61629 * special behavior may be triggered. Note that this
61630 * does not prevent 'eval' from being register bound.
61631 */
61632 DUK_DDD(DUK_DDDPRINT("function call with identifier 'eval' "
61633 "-> enabling EVALCALL flag, marking function "
61634 "as may_direct_eval"));
61635 call_flags |= DUK_BC_CALL_FLAG_EVALCALL;
61636
61637 comp_ctx->curr_func.may_direct_eval = 1;
61638 }
61639
61640 duk_dup(ctx, left->x1.valstack_idx);
61641 if (duk__lookup_lhs(comp_ctx, &reg_varbind, &rc_varname)) {
61642 duk__emit_a_b(comp_ctx,
61644 (duk_regconst_t) (reg_cs + 0),
61645 (duk_regconst_t) reg_varbind);
61646 } else {
61647 duk__emit_a_b(comp_ctx,
61649 (duk_regconst_t) (reg_cs + 0),
61650 rc_varname);
61651 }
61652 } else if (left->t == DUK_IVAL_PROP) {
61653 DUK_DDD(DUK_DDDPRINT("function call with property base"));
61654
61655 duk__ispec_toforcedreg(comp_ctx, &left->x1, reg_cs + 0); /* base */
61656 duk__ispec_toforcedreg(comp_ctx, &left->x2, reg_cs + 1); /* key */
61657 duk__emit_a_b_c(comp_ctx,
61659 (duk_regconst_t) (reg_cs + 0),
61660 (duk_regconst_t) (reg_cs + 0),
61661 (duk_regconst_t) (reg_cs + 1)); /* in-place setup */
61662 } else {
61663 DUK_DDD(DUK_DDDPRINT("function call with register base"));
61664
61665 duk__ivalue_toforcedreg(comp_ctx, left, reg_cs + 0);
61666 duk__emit_a_b(comp_ctx,
61668 (duk_regconst_t) (reg_cs + 0),
61669 (duk_regconst_t) (reg_cs + 0)); /* in-place setup */
61670 }
61671
61672 DUK__SETTEMP(comp_ctx, reg_cs + 2);
61673 nargs = duk__parse_arguments(comp_ctx, res); /* parse args starting from "next temp" */
61674
61675 /* Tailcalls are handled by back-patching the TAILCALL flag to the
61676 * already emitted instruction later (in return statement parser).
61677 * Since A and C have a special meaning here, they cannot be "shuffled".
61678 */
61679
61680 duk__emit_a_b_c(comp_ctx,
61682 (duk_regconst_t) call_flags /*flags*/,
61683 (duk_regconst_t) reg_cs /*basereg*/,
61684 (duk_regconst_t) nargs /*numargs*/);
61685 DUK__SETTEMP(comp_ctx, reg_cs + 1); /* result in csreg */
61686
61687 res->t = DUK_IVAL_PLAIN;
61688 res->x1.t = DUK_ISPEC_REGCONST;
61689 res->x1.regconst = (duk_regconst_t) reg_cs;
61690 return;
61691 }
61692
61693 /* POSTFIX EXPRESSION */
61694
61695 case DUK_TOK_INCREMENT: {
61696 args = (DUK_OP_POSTINCR << 8) + 0;
61697 goto postincdec;
61698 }
61699 case DUK_TOK_DECREMENT: {
61700 args = (DUK_OP_POSTDECR << 8) + 0;
61701 goto postincdec;
61702 }
61703
61704 /* MULTIPLICATIVE EXPRESSION */
61705
61706 case DUK_TOK_MUL: {
61707 args = (DUK_OP_MUL << 8) + DUK__BP_MULTIPLICATIVE; /* UnaryExpression */
61708 goto binary;
61709 }
61710 case DUK_TOK_DIV: {
61711 args = (DUK_OP_DIV << 8) + DUK__BP_MULTIPLICATIVE; /* UnaryExpression */
61712 goto binary;
61713 }
61714 case DUK_TOK_MOD: {
61715 args = (DUK_OP_MOD << 8) + DUK__BP_MULTIPLICATIVE; /* UnaryExpression */
61716 goto binary;
61717 }
61718
61719 /* ADDITIVE EXPRESSION */
61720
61721 case DUK_TOK_ADD: {
61722 args = (DUK_OP_ADD << 8) + DUK__BP_ADDITIVE; /* MultiplicativeExpression */
61723 goto binary;
61724 }
61725 case DUK_TOK_SUB: {
61726 args = (DUK_OP_SUB << 8) + DUK__BP_ADDITIVE; /* MultiplicativeExpression */
61727 goto binary;
61728 }
61729
61730 /* SHIFT EXPRESSION */
61731
61732 case DUK_TOK_ALSHIFT: {
61733 /* << */
61734 args = (DUK_OP_BASL << 8) + DUK__BP_SHIFT;
61735 goto binary;
61736 }
61737 case DUK_TOK_ARSHIFT: {
61738 /* >> */
61739 args = (DUK_OP_BASR << 8) + DUK__BP_SHIFT;
61740 goto binary;
61741 }
61742 case DUK_TOK_RSHIFT: {
61743 /* >>> */
61744 args = (DUK_OP_BLSR << 8) + DUK__BP_SHIFT;
61745 goto binary;
61746 }
61747
61748 /* RELATIONAL EXPRESSION */
61749
61750 case DUK_TOK_LT: {
61751 /* < */
61752 args = (DUK_OP_LT << 8) + DUK__BP_RELATIONAL;
61753 goto binary;
61754 }
61755 case DUK_TOK_GT: {
61756 args = (DUK_OP_GT << 8) + DUK__BP_RELATIONAL;
61757 goto binary;
61758 }
61759 case DUK_TOK_LE: {
61760 args = (DUK_OP_LE << 8) + DUK__BP_RELATIONAL;
61761 goto binary;
61762 }
61763 case DUK_TOK_GE: {
61764 args = (DUK_OP_GE << 8) + DUK__BP_RELATIONAL;
61765 goto binary;
61766 }
61767 case DUK_TOK_INSTANCEOF: {
61768 args = (1 << 16 /*is_extra*/) + (DUK_EXTRAOP_INSTOF << 8) + DUK__BP_RELATIONAL;
61769 goto binary;
61770 }
61771 case DUK_TOK_IN: {
61772 args = (1 << 16 /*is_extra*/) + (DUK_EXTRAOP_IN << 8) + DUK__BP_RELATIONAL;
61773 goto binary;
61774 }
61775
61776 /* EQUALITY EXPRESSION */
61777
61778 case DUK_TOK_EQ: {
61779 args = (DUK_OP_EQ << 8) + DUK__BP_EQUALITY;
61780 goto binary;
61781 }
61782 case DUK_TOK_NEQ: {
61783 args = (DUK_OP_NEQ << 8) + DUK__BP_EQUALITY;
61784 goto binary;
61785 }
61786 case DUK_TOK_SEQ: {
61787 args = (DUK_OP_SEQ << 8) + DUK__BP_EQUALITY;
61788 goto binary;
61789 }
61790 case DUK_TOK_SNEQ: {
61791 args = (DUK_OP_SNEQ << 8) + DUK__BP_EQUALITY;
61792 goto binary;
61793 }
61794
61795 /* BITWISE EXPRESSIONS */
61796
61797 case DUK_TOK_BAND: {
61798 args = (DUK_OP_BAND << 8) + DUK__BP_BAND;
61799 goto binary;
61800 }
61801 case DUK_TOK_BXOR: {
61802 args = (DUK_OP_BXOR << 8) + DUK__BP_BXOR;
61803 goto binary;
61804 }
61805 case DUK_TOK_BOR: {
61806 args = (DUK_OP_BOR << 8) + DUK__BP_BOR;
61807 goto binary;
61808 }
61809
61810 /* LOGICAL EXPRESSIONS */
61811
61812 case DUK_TOK_LAND: {
61813 /* syntactically left-associative but parsed as right-associative */
61814 args = (1 << 8) + DUK__BP_LAND - 1;
61815 goto binary_logical;
61816 }
61817 case DUK_TOK_LOR: {
61818 /* syntactically left-associative but parsed as right-associative */
61819 args = (0 << 8) + DUK__BP_LOR - 1;
61820 goto binary_logical;
61821 }
61822
61823 /* CONDITIONAL EXPRESSION */
61824
61825 case DUK_TOK_QUESTION: {
61826 /* XXX: common reg allocation need is to reuse a sub-expression's temp reg,
61827 * but only if it really is a temp. Nothing fancy here now.
61828 */
61829 duk_reg_t reg_temp;
61830 duk_int_t pc_jump1;
61831 duk_int_t pc_jump2;
61832
61833 reg_temp = DUK__ALLOCTEMP(comp_ctx);
61834 duk__ivalue_toforcedreg(comp_ctx, left, reg_temp);
61835 duk__emit_if_true_skip(comp_ctx, reg_temp);
61836 pc_jump1 = duk__emit_jump_empty(comp_ctx); /* jump to false */
61837 duk__expr_toforcedreg(comp_ctx, res, DUK__BP_COMMA /*rbp_flags*/, reg_temp /*forced_reg*/); /* AssignmentExpression */
61839 pc_jump2 = duk__emit_jump_empty(comp_ctx); /* jump to end */
61840 duk__patch_jump_here(comp_ctx, pc_jump1);
61841 duk__expr_toforcedreg(comp_ctx, res, DUK__BP_COMMA /*rbp_flags*/, reg_temp /*forced_reg*/); /* AssignmentExpression */
61842 duk__patch_jump_here(comp_ctx, pc_jump2);
61843
61844 DUK__SETTEMP(comp_ctx, reg_temp + 1);
61845 res->t = DUK_IVAL_PLAIN;
61846 res->x1.t = DUK_ISPEC_REGCONST;
61847 res->x1.regconst = (duk_regconst_t) reg_temp;
61848 return;
61849 }
61850
61851 /* ASSIGNMENT EXPRESSION */
61852
61853 case DUK_TOK_EQUALSIGN: {
61854 /*
61855 * Assignments are right associative, allows e.g.
61856 * a = 5;
61857 * a += b = 9; // same as a += (b = 9)
61858 * -> expression value 14, a = 14, b = 9
61859 *
61860 * Right associativiness is reflected in the BP for recursion,
61861 * "-1" ensures assignment operations are allowed.
61862 *
61863 * XXX: just use DUK__BP_COMMA (i.e. no need for 2-step bp levels)?
61864 */
61865 args = (DUK_OP_NONE << 8) + DUK__BP_ASSIGNMENT - 1; /* DUK_OP_NONE marks a 'plain' assignment */
61866 goto assign;
61867 }
61868 case DUK_TOK_ADD_EQ: {
61869 /* right associative */
61870 args = (DUK_OP_ADD << 8) + DUK__BP_ASSIGNMENT - 1;
61871 goto assign;
61872 }
61873 case DUK_TOK_SUB_EQ: {
61874 /* right associative */
61875 args = (DUK_OP_SUB << 8) + DUK__BP_ASSIGNMENT - 1;
61876 goto assign;
61877 }
61878 case DUK_TOK_MUL_EQ: {
61879 /* right associative */
61880 args = (DUK_OP_MUL << 8) + DUK__BP_ASSIGNMENT - 1;
61881 goto assign;
61882 }
61883 case DUK_TOK_DIV_EQ: {
61884 /* right associative */
61885 args = (DUK_OP_DIV << 8) + DUK__BP_ASSIGNMENT - 1;
61886 goto assign;
61887 }
61888 case DUK_TOK_MOD_EQ: {
61889 /* right associative */
61890 args = (DUK_OP_MOD << 8) + DUK__BP_ASSIGNMENT - 1;
61891 goto assign;
61892 }
61893 case DUK_TOK_ALSHIFT_EQ: {
61894 /* right associative */
61895 args = (DUK_OP_BASL << 8) + DUK__BP_ASSIGNMENT - 1;
61896 goto assign;
61897 }
61898 case DUK_TOK_ARSHIFT_EQ: {
61899 /* right associative */
61900 args = (DUK_OP_BASR << 8) + DUK__BP_ASSIGNMENT - 1;
61901 goto assign;
61902 }
61903 case DUK_TOK_RSHIFT_EQ: {
61904 /* right associative */
61905 args = (DUK_OP_BLSR << 8) + DUK__BP_ASSIGNMENT - 1;
61906 goto assign;
61907 }
61908 case DUK_TOK_BAND_EQ: {
61909 /* right associative */
61910 args = (DUK_OP_BAND << 8) + DUK__BP_ASSIGNMENT - 1;
61911 goto assign;
61912 }
61913 case DUK_TOK_BOR_EQ: {
61914 /* right associative */
61915 args = (DUK_OP_BOR << 8) + DUK__BP_ASSIGNMENT - 1;
61916 goto assign;
61917 }
61918 case DUK_TOK_BXOR_EQ: {
61919 /* right associative */
61920 args = (DUK_OP_BXOR << 8) + DUK__BP_ASSIGNMENT - 1;
61921 goto assign;
61922 }
61923
61924 /* COMMA */
61925
61926 case DUK_TOK_COMMA: {
61927 /* right associative */
61928
61929 duk__ivalue_toplain_ignore(comp_ctx, left); /* need side effects, not value */
61930 duk__expr_toplain(comp_ctx, res, DUK__BP_COMMA - 1 /*rbp_flags*/);
61931
61932 /* return 'res' (of right part) as our result */
61933 return;
61934 }
61935
61936 default: {
61937 break;
61938 }
61939 }
61940
61941 DUK_D(DUK_DPRINT("parse error: unexpected token: %ld", (long) tok));
61943 return;
61944
61945#if 0
61946 /* XXX: shared handling for 'duk__expr_lhs'? */
61947 if (comp_ctx->curr_func.paren_level == 0 && XXX) {
61948 comp_ctx->curr_func.duk__expr_lhs = 0;
61949 }
61950#endif
61951
61952 binary:
61953 /*
61954 * Shared handling of binary operations
61955 *
61956 * args = (is_extraop << 16) + (opcode << 8) + rbp
61957 */
61958 {
61959 duk__ivalue_toplain(comp_ctx, left);
61960 duk__expr_toplain(comp_ctx, res, args & 0xff /*rbp_flags*/);
61961
61962 /* combine left->x1 and res->x1 (right->x1, really) -> (left->x1 OP res->x1) */
61964 DUK_ASSERT(res->t == DUK_IVAL_PLAIN);
61965
61966 res->t = (args >> 16) ? DUK_IVAL_ARITH_EXTRAOP : DUK_IVAL_ARITH;
61967 res->op = (args >> 8) & 0xff;
61968
61969 res->x2.t = res->x1.t;
61970 res->x2.regconst = res->x1.regconst;
61971 duk_copy(ctx, res->x1.valstack_idx, res->x2.valstack_idx);
61972
61973 res->x1.t = left->x1.t;
61974 res->x1.regconst = left->x1.regconst;
61975 duk_copy(ctx, left->x1.valstack_idx, res->x1.valstack_idx);
61976
61977 DUK_DDD(DUK_DDDPRINT("binary op, res: t=%ld, x1.t=%ld, x1.regconst=0x%08lx, x2.t=%ld, x2.regconst=0x%08lx",
61978 (long) res->t, (long) res->x1.t, (unsigned long) res->x1.regconst, (long) res->x2.t, (unsigned long) res->x2.regconst));
61979 return;
61980 }
61981
61982 binary_logical:
61983 /*
61984 * Shared handling for logical AND and logical OR.
61985 *
61986 * args = (truthval << 8) + rbp
61987 *
61988 * Truthval determines when to skip right-hand-side.
61989 * For logical AND truthval=1, for logical OR truthval=0.
61990 *
61991 * See doc/compiler.rst for discussion on compiling logical
61992 * AND and OR expressions. The approach here is very simplistic,
61993 * generating extra jumps and multiple evaluations of truth values,
61994 * but generates code on-the-fly with only local back-patching.
61995 *
61996 * Both logical AND and OR are syntactically left-associated.
61997 * However, logical ANDs are compiled as right associative
61998 * expressions, i.e. "A && B && C" as "A && (B && C)", to allow
61999 * skip jumps to skip over the entire tail. Similarly for logical OR.
62000 */
62001
62002 {
62003 duk_reg_t reg_temp;
62004 duk_int_t pc_jump;
62005 duk_small_uint_t args_truthval = args >> 8;
62006 duk_small_uint_t args_rbp = args & 0xff;
62007
62008 /* XXX: unoptimal use of temps, resetting */
62009
62010 reg_temp = DUK__ALLOCTEMP(comp_ctx);
62011
62012 duk__ivalue_toforcedreg(comp_ctx, left, reg_temp);
62013 duk__emit_a_b(comp_ctx,
62015 (duk_regconst_t) args_truthval,
62016 (duk_regconst_t) reg_temp); /* skip jump conditionally */
62017 pc_jump = duk__emit_jump_empty(comp_ctx);
62018 duk__expr_toforcedreg(comp_ctx, res, args_rbp /*rbp_flags*/, reg_temp /*forced_reg*/);
62019 duk__patch_jump_here(comp_ctx, pc_jump);
62020
62021 res->t = DUK_IVAL_PLAIN;
62022 res->x1.t = DUK_ISPEC_REGCONST;
62023 res->x1.regconst = (duk_regconst_t) reg_temp;
62024 return;
62025 }
62026
62027 assign:
62028 /*
62029 * Shared assignment expression handling
62030 *
62031 * args = (opcode << 8) + rbp
62032 *
62033 * If 'opcode' is DUK_OP_NONE, plain assignment without arithmetic.
62034 * Syntactically valid left-hand-side forms which are not accepted as
62035 * left-hand-side values (e.g. as in "f() = 1") must NOT cause a
62036 * SyntaxError, but rather a run-time ReferenceError.
62037 *
62038 * When evaluating X <op>= Y, the LHS (X) is conceptually evaluated
62039 * to a temporary first. The RHS is then evaluated. Finally, the
62040 * <op> is applied to the initial value of RHS (not the value after
62041 * RHS evaluation), and written to X. Doing so concretely generates
62042 * inefficient code so we'd like to avoid the temporary when possible.
62043 * See: https://github.com/svaarala/duktape/pull/992.
62044 *
62045 * The expression value (final LHS value, written to RHS) is
62046 * conceptually copied into a fresh temporary so that it won't
62047 * change even if the LHS/RHS values change in outer expressions.
62048 * For example, it'd be generally incorrect for the expression value
62049 * to be the RHS register binding, unless there's a guarantee that it
62050 * won't change during further expression evaluation. Using the
62051 * temporary concretely produces inefficient bytecode, so we try to
62052 * avoid the extra temporary for some known-to-be-safe cases.
62053 * Currently the only safe case we detect is a "top level assignment",
62054 * for example "x = y + z;", where the assignment expression value is
62055 * ignored.
62056 * See: test-dev-assign-expr.js and test-bug-assign-mutate-gh381.js.
62057 */
62058
62059 {
62060 duk_small_uint_t args_op = args >> 8;
62061 duk_small_uint_t args_rbp = args & 0xff;
62062 duk_bool_t toplevel_assign;
62063
62064 /* XXX: here we need to know if 'left' is left-hand-side compatible.
62065 * That information is no longer available from current expr parsing
62066 * state; it would need to be carried into the 'left' ivalue or by
62067 * some other means.
62068 */
62069
62070 /* A top-level assignment is e.g. "x = y;". For these it's safe
62071 * to use the RHS as-is as the expression value, even if the RHS
62072 * is a reg-bound identifier. The RHS ('res') is right associative
62073 * so it has consumed all other assignment level operations; the
62074 * only relevant lower binding power construct is comma operator
62075 * which will ignore the expression value provided here. Usually
62076 * the top level assignment expression value is ignored, but it
62077 * is relevant for e.g. eval code.
62078 */
62079 toplevel_assign = (comp_ctx->curr_func.nud_count == 1 && /* one token before */
62080 comp_ctx->curr_func.led_count == 1); /* one operator (= assign) */
62081 DUK_DDD(DUK_DDDPRINT("assignment: nud_count=%ld, led_count=%ld, toplevel_assign=%ld",
62082 (long) comp_ctx->curr_func.nud_count,
62083 (long) comp_ctx->curr_func.led_count,
62084 (long) toplevel_assign));
62085
62086 if (left->t == DUK_IVAL_VAR) {
62087 duk_hstring *h_varname;
62088 duk_reg_t reg_varbind;
62089 duk_regconst_t rc_varname;
62090
62091 DUK_ASSERT(left->x1.t == DUK_ISPEC_VALUE); /* LHS is already side effect free */
62092
62093 h_varname = duk_get_hstring(ctx, left->x1.valstack_idx);
62094 DUK_ASSERT(h_varname != NULL);
62095 if (duk__hstring_is_eval_or_arguments_in_strict_mode(comp_ctx, h_varname)) {
62096 /* E5 Section 11.13.1 (and others for other assignments), step 4. */
62097 goto syntax_error_lvalue;
62098 }
62099 duk_dup(ctx, left->x1.valstack_idx);
62100 (void) duk__lookup_lhs(comp_ctx, &reg_varbind, &rc_varname);
62101
62102 if (args_op == DUK_OP_NONE) {
62103 duk__expr(comp_ctx, res, args_rbp /*rbp_flags*/);
62104 if (toplevel_assign) {
62105 /* Any 'res' will do. */
62106 DUK_DDD(DUK_DDDPRINT("plain assignment, toplevel assign, use as is"));
62107 } else {
62108 /* 'res' must be a plain ivalue, and not register-bound variable. */
62109 DUK_DDD(DUK_DDDPRINT("plain assignment, not toplevel assign, ensure not a reg-bound identifier"));
62110 if (res->t != DUK_IVAL_PLAIN || (res->x1.t == DUK_ISPEC_REGCONST &&
62111 (res->x1.regconst & DUK__CONST_MARKER) == 0 &&
62112 !DUK__ISTEMP(comp_ctx, res->x1.regconst))) {
62113 duk__ivalue_totempconst(comp_ctx, res);
62114 }
62115 }
62116 } else {
62117 /* For X <op>= Y we need to evaluate the pre-op
62118 * value of X before evaluating the RHS: the RHS
62119 * can change X, but when we do <op> we must use
62120 * the pre-op value.
62121 */
62122 duk_reg_t reg_temp;
62123
62124 reg_temp = DUK__ALLOCTEMP(comp_ctx);
62125
62126 if (reg_varbind >= 0) {
62127 duk_reg_t reg_res;
62128 duk_reg_t reg_src;
62129 duk_int_t pc_temp_load;
62130 duk_int_t pc_before_rhs;
62131 duk_int_t pc_after_rhs;
62132
62133 if (toplevel_assign) {
62134 /* 'reg_varbind' is the operation result and can also
62135 * become the expression value for top level assignments
62136 * such as: "var x; x += y;".
62137 */
62138 DUK_DD(DUK_DDPRINT("<op>= expression is top level, write directly to reg_varbind"));
62139 reg_res = reg_varbind;
62140 } else {
62141 /* Not safe to use 'reg_varbind' as assignment expression
62142 * value, so go through a temp.
62143 */
62144 DUK_DD(DUK_DDPRINT("<op>= expression is not top level, write to reg_temp"));
62145 reg_res = reg_temp; /* reg_res should be smallest possible */
62146 reg_temp = DUK__ALLOCTEMP(comp_ctx);
62147 }
62148
62149 /* Try to optimize X <op>= Y for reg-bound
62150 * variables. Detect side-effect free RHS
62151 * narrowly by seeing whether it emits code.
62152 * If not, rewind the code emitter and overwrite
62153 * the unnecessary temp reg load.
62154 */
62155
62156 pc_temp_load = duk__get_current_pc(comp_ctx);
62157 duk__emit_a_bc(comp_ctx,
62159 (duk_regconst_t) reg_temp,
62160 reg_varbind);
62161
62162 pc_before_rhs = duk__get_current_pc(comp_ctx);
62163 duk__expr_toregconst(comp_ctx, res, args_rbp /*rbp_flags*/);
62164 DUK_ASSERT(res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_REGCONST);
62165 pc_after_rhs = duk__get_current_pc(comp_ctx);
62166
62167 DUK_DD(DUK_DDPRINT("pc_temp_load=%ld, pc_before_rhs=%ld, pc_after_rhs=%ld",
62168 (long) pc_temp_load, (long) pc_before_rhs,
62169 (long) pc_after_rhs));
62170
62171 if (pc_after_rhs == pc_before_rhs) {
62172 /* Note: if the reg_temp load generated shuffling
62173 * instructions, we may need to rewind more than
62174 * one instruction, so use explicit PC computation.
62175 */
62176 DUK_DD(DUK_DDPRINT("rhs is side effect free, rewind and avoid unnecessary temp for reg-based <op>="));
62177 DUK_BW_ADD_PTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code, (pc_temp_load - pc_before_rhs) * sizeof(duk_compiler_instr));
62178 reg_src = reg_varbind;
62179 } else {
62180 DUK_DD(DUK_DDPRINT("rhs evaluation emitted code, not sure if rhs is side effect free; use temp reg for LHS"));
62181 reg_src = reg_temp;
62182 }
62183
62184 duk__emit_a_b_c(comp_ctx,
62185 args_op,
62186 (duk_regconst_t) reg_res,
62187 (duk_regconst_t) reg_src,
62188 res->x1.regconst);
62189
62190 res->x1.regconst = (duk_regconst_t) reg_res;
62191
62192 /* Ensure compact use of temps. */
62193 if (DUK__ISTEMP(comp_ctx, reg_res)) {
62194 DUK__SETTEMP(comp_ctx, reg_res + 1);
62195 }
62196 } else {
62197 /* When LHS is not register bound, always go through a
62198 * temporary. No optimization for top level assignment.
62199 */
62200
62201 duk__emit_a_bc(comp_ctx,
62203 (duk_regconst_t) reg_temp,
62204 rc_varname);
62205
62206 duk__expr_toregconst(comp_ctx, res, args_rbp /*rbp_flags*/);
62207 DUK_ASSERT(res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_REGCONST);
62208
62209 duk__emit_a_b_c(comp_ctx,
62210 args_op,
62211 (duk_regconst_t) reg_temp,
62212 (duk_regconst_t) reg_temp,
62213 res->x1.regconst);
62214 res->x1.regconst = (duk_regconst_t) reg_temp;
62215 }
62216
62217 DUK_ASSERT(res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_REGCONST);
62218 }
62219
62220 /* At this point 'res' holds the potential expression value.
62221 * It can be basically any ivalue here, including a reg-bound
62222 * identifier (if code above deems it safe) or a unary/binary
62223 * operation. Operations must be resolved to a side effect free
62224 * plain value, and the side effects must happen exactly once.
62225 */
62226
62227 if (reg_varbind >= 0) {
62228 if (res->t != DUK_IVAL_PLAIN) {
62229 /* Resolve 'res' directly into the LHS binding, and use
62230 * that as the expression value if safe. If not safe,
62231 * resolve to a temp/const and copy to LHS.
62232 */
62233 if (toplevel_assign) {
62234 duk__ivalue_toforcedreg(comp_ctx, res, (duk_int_t) reg_varbind);
62235 } else {
62236 duk__ivalue_totempconst(comp_ctx, res);
62237 duk__copy_ivalue(comp_ctx, res, left); /* use 'left' as a temp */
62238 duk__ivalue_toforcedreg(comp_ctx, left, (duk_int_t) reg_varbind);
62239 }
62240 } else {
62241 /* Use 'res' as the expression value (it's side effect
62242 * free and may be a plain value, a register, or a
62243 * constant) and write it to the LHS binding too.
62244 */
62245 duk__copy_ivalue(comp_ctx, res, left); /* use 'left' as a temp */
62246 duk__ivalue_toforcedreg(comp_ctx, left, (duk_int_t) reg_varbind);
62247 }
62248 } else {
62249 /* Only a reg fits into 'A' so coerce 'res' into a register
62250 * for PUTVAR.
62251 *
62252 * XXX: here the current A/B/C split is suboptimal: we could
62253 * just use 9 bits for reg_res (and support constants) and 17
62254 * instead of 18 bits for the varname const index.
62255 */
62256
62257 duk__ivalue_toreg(comp_ctx, res);
62258 duk__emit_a_bc(comp_ctx,
62260 res->x1.regconst,
62261 rc_varname);
62262 }
62263
62264 /* 'res' contains expression value */
62265 } else if (left->t == DUK_IVAL_PROP) {
62266 /* E5 Section 11.13.1 (and others) step 4 never matches for prop writes -> no check */
62267 duk_reg_t reg_obj;
62268 duk_regconst_t rc_key;
62269 duk_regconst_t rc_res;
62270 duk_reg_t reg_temp;
62271
62272 /* Property access expressions ('a[b]') are critical to correct
62273 * LHS evaluation ordering, see test-dev-assign-eval-order*.js.
62274 * We must make sure that the LHS target slot (base object and
62275 * key) don't change during RHS evaluation. The only concrete
62276 * problem is a register reference to a variable-bound register
62277 * (i.e., non-temp). Require temp regs for both key and base.
62278 *
62279 * Don't allow a constant for the object (even for a number
62280 * etc), as it goes into the 'A' field of the opcode.
62281 */
62282
62283 reg_obj = duk__ispec_toregconst_raw(comp_ctx,
62284 &left->x1,
62285 -1 /*forced_reg*/,
62286 DUK__IVAL_FLAG_REQUIRE_TEMP /*flags*/);
62287
62288 rc_key = duk__ispec_toregconst_raw(comp_ctx,
62289 &left->x2,
62290 -1 /*forced_reg*/,
62292
62293 /* Evaluate RHS only when LHS is safe. */
62294
62295 if (args_op == DUK_OP_NONE) {
62296 duk__expr_toregconst(comp_ctx, res, args_rbp /*rbp_flags*/);
62297 DUK_ASSERT(res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_REGCONST);
62298 rc_res = res->x1.regconst;
62299 } else {
62300 reg_temp = DUK__ALLOCTEMP(comp_ctx);
62301 duk__emit_a_b_c(comp_ctx,
62303 (duk_regconst_t) reg_temp,
62304 (duk_regconst_t) reg_obj,
62305 rc_key);
62306
62307 duk__expr_toregconst(comp_ctx, res, args_rbp /*rbp_flags*/);
62308 DUK_ASSERT(res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_REGCONST);
62309
62310 duk__emit_a_b_c(comp_ctx,
62311 args_op,
62312 (duk_regconst_t) reg_temp,
62313 (duk_regconst_t) reg_temp,
62314 res->x1.regconst);
62315 rc_res = (duk_regconst_t) reg_temp;
62316 }
62317
62318 duk__emit_a_b_c(comp_ctx,
62320 (duk_regconst_t) reg_obj,
62321 rc_key,
62322 rc_res);
62323
62324 res->t = DUK_IVAL_PLAIN;
62325 res->x1.t = DUK_ISPEC_REGCONST;
62326 res->x1.regconst = rc_res;
62327 } else {
62328 /* No support for lvalues returned from new or function call expressions.
62329 * However, these must NOT cause compile-time SyntaxErrors, but run-time
62330 * ReferenceErrors. Both left and right sides of the assignment must be
62331 * evaluated before throwing a ReferenceError. For instance:
62332 *
62333 * f() = g();
62334 *
62335 * must result in f() being evaluated, then g() being evaluated, and
62336 * finally, a ReferenceError being thrown. See E5 Section 11.13.1.
62337 */
62338
62339 duk_regconst_t rc_res;
62340
62341 /* First evaluate LHS fully to ensure all side effects are out. */
62343
62344 /* Then evaluate RHS fully (its value becomes the expression value too).
62345 * Technically we'd need the side effect safety check here too, but because
62346 * we always throw using INVLHS the result doesn't matter.
62347 */
62348 rc_res = duk__expr_toregconst(comp_ctx, res, args_rbp /*rbp_flags*/);
62349
62350 duk__emit_extraop_only(comp_ctx,
62352
62353 res->t = DUK_IVAL_PLAIN;
62354 res->x1.t = DUK_ISPEC_REGCONST;
62355 res->x1.regconst = rc_res;
62356 }
62357
62358 return;
62359 }
62360
62361 postincdec:
62362 {
62363 /*
62364 * Post-increment/decrement will return the original value as its
62365 * result value. However, even that value will be coerced using
62366 * ToNumber() which is quite awkward. Specific bytecode opcodes
62367 * are used to handle these semantics.
62368 *
62369 * Note that post increment/decrement has a "no LineTerminator here"
62370 * restriction. This is handled by duk__expr_lbp(), which forcibly terminates
62371 * the previous expression if a LineTerminator occurs before '++'/'--'.
62372 */
62373
62374 duk_reg_t reg_res;
62375 duk_small_uint_t args_op = args >> 8;
62376
62377 /* Specific assumptions for opcode numbering. */
62382
62383 reg_res = DUK__ALLOCTEMP(comp_ctx);
62384
62385 if (left->t == DUK_IVAL_VAR) {
62386 duk_hstring *h_varname;
62387 duk_reg_t reg_varbind;
62388 duk_regconst_t rc_varname;
62389
62390 h_varname = duk_get_hstring(ctx, left->x1.valstack_idx);
62391 DUK_ASSERT(h_varname != NULL);
62392
62393 if (duk__hstring_is_eval_or_arguments_in_strict_mode(comp_ctx, h_varname)) {
62394 goto syntax_error;
62395 }
62396
62397 duk_dup(ctx, left->x1.valstack_idx);
62398 if (duk__lookup_lhs(comp_ctx, &reg_varbind, &rc_varname)) {
62399 duk__emit_a_bc(comp_ctx,
62400 args_op, /* e.g. DUK_OP_POSTINCR */
62401 (duk_regconst_t) reg_res,
62402 (duk_regconst_t) reg_varbind);
62403 } else {
62404 duk__emit_a_bc(comp_ctx,
62405 args_op + 4, /* e.g. DUK_OP_POSTINCV */
62406 (duk_regconst_t) reg_res,
62407 rc_varname);
62408 }
62409
62410 DUK_DDD(DUK_DDDPRINT("postincdec to '%!O' -> reg_varbind=%ld, rc_varname=%ld",
62411 (duk_heaphdr *) h_varname, (long) reg_varbind, (long) rc_varname));
62412 } else if (left->t == DUK_IVAL_PROP) {
62413 duk_reg_t reg_obj; /* allocate to reg only (not const) */
62414 duk_regconst_t rc_key;
62415
62416 reg_obj = duk__ispec_toregconst_raw(comp_ctx, &left->x1, -1 /*forced_reg*/, 0 /*flags*/); /* don't allow const */
62417 rc_key = duk__ispec_toregconst_raw(comp_ctx, &left->x2, -1 /*forced_reg*/, DUK__IVAL_FLAG_ALLOW_CONST /*flags*/);
62418 duk__emit_a_b_c(comp_ctx,
62419 args_op + 8, /* e.g. DUK_OP_POSTINCP */
62420 (duk_regconst_t) reg_res,
62421 (duk_regconst_t) reg_obj,
62422 rc_key);
62423 } else {
62424 /* Technically return value is not needed because INVLHS will
62425 * unconditially throw a ReferenceError. Coercion is necessary
62426 * for proper semantics (consider ToNumber() called for an object).
62427 * Use DUK_EXTRAOP_UNP with a dummy register to get ToNumber().
62428 */
62429 duk__ivalue_toforcedreg(comp_ctx, left, reg_res);
62430 duk__emit_extraop_bc(comp_ctx,
62432 reg_res); /* for side effects, result ignored */
62433 duk__emit_extraop_only(comp_ctx,
#define DUK_OP_POSTINCR
#define DUK_TOK_SUB
#define DUK__BP_ASSIGNMENT
#define DUK_TOK_ARSHIFT_EQ
#define DUK__BP_BAND
#define DUK_EXTRAOP_INVLHS
#define DUK_TOK_INCREMENT
#define DUK_OP_SNEQ
DUK_LOCAL_DECL duk_reg_t duk__ivalue_toreg(duk_compiler_ctx *comp_ctx, duk_ivalue *x)
#define DUK_OP_NONE
#define DUK_TOK_MUL
#define DUK_IVAL_VAR
#define DUK_TOK_EQUALSIGN
#define DUK_IVAL_ARITH_EXTRAOP
#define DUK_OP_SUB
#define DUK__BP_SHIFT
#define DUK_EXTRAOP_UNP
#define DUK_TOK_ADD
DUK_LOCAL_DECL void duk__advance(duk_compiler_ctx *ctx)
#define DUK_TOK_IDENTIFIER
#define DUK_TOK_BXOR
#define DUK_TOK_GT
DUK_LOCAL_DECL duk_regconst_t duk__ispec_toregconst_raw(duk_compiler_ctx *comp_ctx, duk_ispec *x, duk_reg_t forced_reg, duk_small_uint_t flags)
#define DUK_OP_MOD
#define DUK_OP_POSTINCP
#define DUK__BP_BXOR
#define DUK__IVAL_FLAG_ALLOW_CONST
#define DUK__SETTEMP(comp_ctx, x)
DUK_LOCAL_DECL void duk__expr_toplain(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags)
#define DUK_OP_PUTVAR
#define DUK_TOK_LT
#define DUK_TOK_BAND
#define DUK_OP_IF
#define DUK_OP_BOR
DUK_LOCAL_DECL duk_regconst_t duk__ivalue_totempconst(duk_compiler_ctx *comp_ctx, duk_ivalue *x)
#define DUK_TOK_DIV_EQ
#define DUK_TOK_EQ
#define DUK__BP_RELATIONAL
#define DUK__BP_BOR
DUK_LOCAL_DECL void duk__ivalue_toplain(duk_compiler_ctx *comp_ctx, duk_ivalue *x)
#define DUK__BP_COMMA
#define DUK_OP_BXOR
#define DUK_TOK_GE
#define DUK__IVAL_FLAG_REQUIRE_TEMP
#define DUK_TOK_ALSHIFT_EQ
#define DUK_TOK_MUL_EQ
#define DUK_TOK_LE
#define DUK_TOK_LAND
#define DUK_TOK_BXOR_EQ
#define DUK_OP_PUTPROP
DUK_LOCAL_DECL void duk__advance_expect(duk_compiler_ctx *comp_ctx, duk_small_int_t expect)
#define DUK_OP_LT
#define DUK_OP_BASL
duk_uint32_t duk_regconst_t
#define DUK_TOK_COLON
#define DUK__ALLOCTEMP(comp_ctx)
#define DUK_OP_SEQ
#define DUK_STR_EXPECTED_IDENTIFIER
#define DUK_TOK_BOR_EQ
#define DUK_TOK_SNEQ
#define DUK_TOK_ALSHIFT
#define DUK_OP_POSTDECP
#define DUK_TOK_DECREMENT
#define DUK_OP_DIV
DUK_LOCAL_DECL void duk__patch_jump_here(duk_compiler_ctx *comp_ctx, duk_int_t jump_pc)
#define DUK_TOK_LPAREN
#define DUK_EXTRAOP_INSTOF
#define DUK__BP_LOR
#define DUK_TOK_MOD
#define DUK_OP_POSTDECR
#define DUK__BP_ADDITIVE
#define DUK_OP_BAND
#define DUK_OP_ADD
#define DUK__BP_FOR_EXPR
#define DUK_TOK_QUESTION
#define DUK_TOK_RBRACKET
DUK_LOCAL_DECL duk_int_t duk__emit_jump_empty(duk_compiler_ctx *comp_ctx)
#define DUK_HTHREAD_STRING_EVAL(thr)
#define DUK__BP_LAND
DUK_LOCAL_DECL duk_bool_t duk__lookup_lhs(duk_compiler_ctx *ctx, duk_reg_t *out_reg_varbind, duk_regconst_t *out_rc_varname)
DUK_LOCAL_DECL void duk__ivalue_toplain_ignore(duk_compiler_ctx *comp_ctx, duk_ivalue *x)
#define DUK_TOK_RSHIFT_EQ
#define DUK_IVAL_ARITH
#define DUK_TOK_COMMA
#define DUK__ISTEMP(comp_ctx, x)
#define DUK_OP_BASR
#define DUK_OP_BLSR
#define DUK_OP_LE
#define DUK_OP_MUL
DUK_LOCAL_DECL void duk__expr_led(duk_compiler_ctx *comp_ctx, duk_ivalue *left, duk_ivalue *res)
#define DUK__ALLOCTEMPS(comp_ctx, count)
#define DUK_ISPEC_REGCONST
#define DUK_TOK_LOR
#define DUK_OP_GETPROP
#define DUK_OP_NEQ
#define DUK_TOK_ADD_EQ
#define DUK_TOK_LBRACKET
#define DUK_EXTRAOP_IN
DUK_LOCAL_DECL void duk__ivalue_toforcedreg(duk_compiler_ctx *comp_ctx, duk_ivalue *x, duk_int_t forced_reg)
#define DUK_BC_CALL_FLAG_EVALCALL
#define DUK__BP_MULTIPLICATIVE
#define DUK_TOK_RSHIFT
#define DUK_TOK_DIV
#define DUK_TOK_BAND_EQ
#define DUK_OP_GT
DUK_LOCAL_DECL void duk__expr(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags)
#define DUK_TOK_INSTANCEOF
DUK_LOCAL_DECL void duk__emit_if_true_skip(duk_compiler_ctx *comp_ctx, duk_regconst_t regconst)
#define DUK_TOK_SUB_EQ
#define DUK_TOK_BOR
#define DUK_TOK_NEQ
#define DUK_TOK_ARSHIFT
DUK_LOCAL_DECL void duk__copy_ivalue(duk_compiler_ctx *comp_ctx, duk_ivalue *src, duk_ivalue *dst)
#define DUK_TOK_PERIOD
DUK_LOCAL_DECL void duk__ispec_toforcedreg(duk_compiler_ctx *comp_ctx, duk_ispec *x, duk_reg_t forced_reg)
#define DUK_TOK_MOD_EQ
#define DUK_TOK_IN
#define DUK_IVAL_PROP
#define DUK_OP_POSTDECV
DUK_LOCAL_DECL void duk__emit_extraop_bc(duk_compiler_ctx *comp_ctx, duk_small_uint_t extraop, duk_regconst_t bc)
#define DUK_OP_POSTINCV
DUK_LOCAL_DECL duk_int_t duk__parse_arguments(duk_compiler_ctx *comp_ctx, duk_ivalue *res)
DUK_LOCAL duk_bool_t duk__hstring_is_eval_or_arguments_in_strict_mode(duk_compiler_ctx *comp_ctx, duk_hstring *h)
#define DUK_OP_EQ
#define DUK_OP_GETVAR
#define DUK_OP_GE
#define DUK__BP_EQUALITY
#define DUK_TOK_SEQ
DUK_LOCAL_DECL void duk__emit_extraop_only(duk_compiler_ctx *comp_ctx, duk_small_uint_t extraop_flags)
DUK_LOCAL_DECL void duk__expr_toforcedreg(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags, duk_reg_t forced_reg)
DUK_LOCAL_DECL duk_regconst_t duk__expr_toregconst(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags)

References DUK_ISPEC_VALUE, DUK_IVAL_PLAIN, duk_replace(), duk_ispec::t, duk_ivalue::t, duk_ispec::valstack_idx, and duk_ivalue::x1.

◆ duk__expr_nud()

DUK_LOCAL_DECL void duk__expr_nud ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res )

Definition at line 60959 of file duktape-1.8.0/src/duktape.c.

60970 {
60971 /* empty expressions can be detected conveniently with nud/led counts */
60972 return (comp_ctx->curr_func.nud_count == 0) &&
60973 (comp_ctx->curr_func.led_count == 0);
60974}
60975
60976DUK_LOCAL void duk__expr_nud(duk_compiler_ctx *comp_ctx, duk_ivalue *res) {
60977 duk_hthread *thr = comp_ctx->thr;
60978 duk_context *ctx = (duk_context *) thr;
60979 duk_token *tk;
60980 duk_reg_t temp_at_entry;
60981 duk_small_int_t tok;
60982 duk_uint32_t args; /* temp variable to pass constants and flags to shared code */
60983
60984 /*
60985 * ctx->prev_token token to process with duk__expr_nud()
60986 * ctx->curr_token updated by caller
60987 *
60988 * Note: the token in the switch below has already been eaten.
60989 */
60990
60991 temp_at_entry = DUK__GETTEMP(comp_ctx);
60992
60993 comp_ctx->curr_func.nud_count++;
60994
60995 tk = &comp_ctx->prev_token;
60996 tok = tk->t;
60997 res->t = DUK_IVAL_NONE;
60998
60999 DUK_DDD(DUK_DDDPRINT("duk__expr_nud(), prev_token.t=%ld, allow_in=%ld, paren_level=%ld",
61000 (long) tk->t, (long) comp_ctx->curr_func.allow_in, (long) comp_ctx->curr_func.paren_level));
61001
61002 switch (tok) {
61003
61004 /* PRIMARY EXPRESSIONS */
61005
61006 case DUK_TOK_THIS: {
61007 duk_reg_t reg_temp;
61008 reg_temp = DUK__ALLOCTEMP(comp_ctx);
61009 duk__emit_extraop_bc(comp_ctx,
61011 (duk_regconst_t) reg_temp);
61012 res->t = DUK_IVAL_PLAIN;
61013 res->x1.t = DUK_ISPEC_REGCONST;
61014 res->x1.regconst = (duk_regconst_t) reg_temp;
61015 return;
61016 }
61017 case DUK_TOK_IDENTIFIER: {
61018 res->t = DUK_IVAL_VAR;
61019 res->x1.t = DUK_ISPEC_VALUE;
61020 duk_push_hstring(ctx, tk->str1);
61021 duk_replace(ctx, res->x1.valstack_idx);
61022 return;
61023 }
61024 case DUK_TOK_NULL: {
61025 duk_push_null(ctx);
61026 goto plain_value;
61027 }
61028 case DUK_TOK_TRUE: {
61029 duk_push_true(ctx);
61030 goto plain_value;
61031 }
61032 case DUK_TOK_FALSE: {
61033 duk_push_false(ctx);
61034 goto plain_value;
61035 }
61036 case DUK_TOK_NUMBER: {
61037 duk_push_number(ctx, tk->num);
61038 goto plain_value;
61039 }
61040 case DUK_TOK_STRING: {
61041 DUK_ASSERT(tk->str1 != NULL);
61042 duk_push_hstring(ctx, tk->str1);
61043 goto plain_value;
61044 }
61045 case DUK_TOK_REGEXP: {
61046#ifdef DUK_USE_REGEXP_SUPPORT
61047 duk_reg_t reg_temp;
61048 duk_regconst_t rc_re_bytecode; /* const */
61049 duk_regconst_t rc_re_source; /* const */
61050
61051 DUK_ASSERT(tk->str1 != NULL);
61052 DUK_ASSERT(tk->str2 != NULL);
61053
61054 DUK_DDD(DUK_DDDPRINT("emitting regexp op, str1=%!O, str2=%!O",
61055 (duk_heaphdr *) tk->str1,
61056 (duk_heaphdr *) tk->str2));
61057
61058 reg_temp = DUK__ALLOCTEMP(comp_ctx);
61059 duk_push_hstring(ctx, tk->str1);
61060 duk_push_hstring(ctx, tk->str2);
61061
61062 /* [ ... pattern flags ] */
61063
61064 duk_regexp_compile(thr);
61065
61066 /* [ ... escaped_source bytecode ] */
61067
61068 rc_re_bytecode = duk__getconst(comp_ctx);
61069 rc_re_source = duk__getconst(comp_ctx);
61070
61071 duk__emit_a_b_c(comp_ctx,
61073 (duk_regconst_t) reg_temp /*a*/,
61074 rc_re_bytecode /*b*/,
61075 rc_re_source /*c*/);
61076
61077 res->t = DUK_IVAL_PLAIN;
61078 res->x1.t = DUK_ISPEC_REGCONST;
61079 res->x1.regconst = (duk_regconst_t) reg_temp;
61080 return;
61081#else /* DUK_USE_REGEXP_SUPPORT */
61082 goto syntax_error;
61083#endif /* DUK_USE_REGEXP_SUPPORT */
61084 }
61085 case DUK_TOK_LBRACKET: {
61086 DUK_DDD(DUK_DDDPRINT("parsing array literal"));
61087 duk__nud_array_literal(comp_ctx, res);
61088 return;
61089 }
61090 case DUK_TOK_LCURLY: {
61091 DUK_DDD(DUK_DDDPRINT("parsing object literal"));
61092 duk__nud_object_literal(comp_ctx, res);
61093 return;
61094 }
61095 case DUK_TOK_LPAREN: {
61096 duk_bool_t prev_allow_in;
61097
61098 comp_ctx->curr_func.paren_level++;
61099 prev_allow_in = comp_ctx->curr_func.allow_in;
61100 comp_ctx->curr_func.allow_in = 1; /* reset 'allow_in' for parenthesized expression */
61101
61102 duk__expr(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/); /* Expression, terminates at a ')' */
61103
61105 comp_ctx->curr_func.allow_in = prev_allow_in;
61106 comp_ctx->curr_func.paren_level--;
61107 return;
61108 }
61109
61110 /* MEMBER/NEW/CALL EXPRESSIONS */
61111
61112 case DUK_TOK_NEW: {
61113 /*
61114 * Parsing an expression starting with 'new' is tricky because
61115 * there are multiple possible productions deriving from
61116 * LeftHandSideExpression which begin with 'new'.
61117 *
61118 * We currently resort to one-token lookahead to distinguish the
61119 * cases. Hopefully this is correct. The binding power must be
61120 * such that parsing ends at an LPAREN (CallExpression) but not at
61121 * a PERIOD or LBRACKET (MemberExpression).
61122 *
61123 * See doc/compiler.rst for discussion on the parsing approach,
61124 * and testcases/test-dev-new.js for a bunch of documented tests.
61125 */
61126
61127 duk_reg_t reg_target;
61128 duk_int_t nargs;
61129
61130 DUK_DDD(DUK_DDDPRINT("begin parsing new expression"));
61131
61132 reg_target = DUK__ALLOCTEMP(comp_ctx);
61133 duk__expr_toforcedreg(comp_ctx, res, DUK__BP_CALL /*rbp_flags*/, reg_target /*forced_reg*/);
61134 DUK__SETTEMP(comp_ctx, reg_target + 1);
61135
61136 if (comp_ctx->curr_token.t == DUK_TOK_LPAREN) {
61137 /* 'new' MemberExpression Arguments */
61138 DUK_DDD(DUK_DDDPRINT("new expression has argument list"));
61139 duk__advance(comp_ctx);
61140 nargs = duk__parse_arguments(comp_ctx, res); /* parse args starting from "next temp", reg_target + 1 */
61141 /* right paren eaten */
61142 } else {
61143 /* 'new' MemberExpression */
61144 DUK_DDD(DUK_DDDPRINT("new expression has no argument list"));
61145 nargs = 0;
61146 }
61147
61148 /* Opcode slot C is used in a non-standard way, so shuffling
61149 * is not allowed.
61150 */
61151 duk__emit_a_b_c(comp_ctx,
61153 0 /*unused*/,
61154 reg_target /*target*/,
61155 nargs /*num_args*/);
61156
61157 DUK_DDD(DUK_DDDPRINT("end parsing new expression"));
61158
61159 res->t = DUK_IVAL_PLAIN;
61160 res->x1.t = DUK_ISPEC_REGCONST;
61161 res->x1.regconst = (duk_regconst_t) reg_target;
61162 return;
61163 }
61164
61165 /* FUNCTION EXPRESSIONS */
61166
61167 case DUK_TOK_FUNCTION: {
61168 /* Function expression. Note that any statement beginning with 'function'
61169 * is handled by the statement parser as a function declaration, or a
61170 * non-standard function expression/statement (or a SyntaxError). We only
61171 * handle actual function expressions (occurring inside an expression) here.
61172 *
61173 * O(depth^2) parse count for inner functions is handled by recording a
61174 * lexer offset on the first compilation pass, so that the function can
61175 * be efficiently skipped on the second pass. This is encapsulated into
61176 * duk__parse_func_like_fnum().
61177 */
61178
61179 duk_reg_t reg_temp;
61180 duk_int_t fnum;
61181
61182 reg_temp = DUK__ALLOCTEMP(comp_ctx);
61183
61184 /* curr_token follows 'function' */
61185 fnum = duk__parse_func_like_fnum(comp_ctx, 0 /*is_decl*/, 0 /*is_setget*/);
61186 DUK_DDD(DUK_DDDPRINT("parsed inner function -> fnum %ld", (long) fnum));
61187
61188 duk__emit_a_bc(comp_ctx,
61190 (duk_regconst_t) reg_temp /*a*/,
61191 (duk_regconst_t) fnum /*bc*/);
61192
61193 res->t = DUK_IVAL_PLAIN;
61194 res->x1.t = DUK_ISPEC_REGCONST;
61195 res->x1.regconst = (duk_regconst_t) reg_temp;
61196 return;
61197 }
61198
61199 /* UNARY EXPRESSIONS */
61200
61201 case DUK_TOK_DELETE: {
61202 /* Delete semantics are a bit tricky. The description in E5 specification
61203 * is kind of confusing, because it distinguishes between resolvability of
61204 * a reference (which is only known at runtime) seemingly at compile time
61205 * (= SyntaxError throwing).
61206 */
61207 duk__expr(comp_ctx, res, DUK__BP_MULTIPLICATIVE /*rbp_flags*/); /* UnaryExpression */
61208 if (res->t == DUK_IVAL_VAR) {
61209 /* not allowed in strict mode, regardless of whether resolves;
61210 * in non-strict mode DELVAR handles both non-resolving and
61211 * resolving cases (the specification description is a bit confusing).
61212 */
61213
61214 duk_reg_t reg_temp;
61215 duk_reg_t reg_varbind;
61216 duk_regconst_t rc_varname;
61217
61218 if (comp_ctx->curr_func.is_strict) {
61220 }
61221
61222 DUK__SETTEMP(comp_ctx, temp_at_entry);
61223 reg_temp = DUK__ALLOCTEMP(comp_ctx);
61224
61225 duk_dup(ctx, res->x1.valstack_idx);
61226 if (duk__lookup_lhs(comp_ctx, &reg_varbind, &rc_varname)) {
61227 /* register bound variables are non-configurable -> always false */
61228 duk__emit_extraop_bc(comp_ctx,
61230 (duk_regconst_t) reg_temp);
61231 } else {
61232 duk_dup(ctx, res->x1.valstack_idx);
61233 rc_varname = duk__getconst(comp_ctx);
61234 duk__emit_a_b(comp_ctx,
61236 (duk_regconst_t) reg_temp,
61237 (duk_regconst_t) rc_varname);
61238 }
61239 res->t = DUK_IVAL_PLAIN;
61240 res->x1.t = DUK_ISPEC_REGCONST;
61241 res->x1.regconst = (duk_regconst_t) reg_temp;
61242 } else if (res->t == DUK_IVAL_PROP) {
61243 duk_reg_t reg_temp;
61244 duk_reg_t reg_obj;
61245 duk_regconst_t rc_key;
61246
61247 DUK__SETTEMP(comp_ctx, temp_at_entry);
61248 reg_temp = DUK__ALLOCTEMP(comp_ctx);
61249 reg_obj = duk__ispec_toregconst_raw(comp_ctx, &res->x1, -1 /*forced_reg*/, 0 /*flags*/); /* don't allow const */
61250 rc_key = duk__ispec_toregconst_raw(comp_ctx, &res->x2, -1 /*forced_reg*/, DUK__IVAL_FLAG_ALLOW_CONST /*flags*/);
61251 duk__emit_a_b_c(comp_ctx,
61253 (duk_regconst_t) reg_temp,
61254 (duk_regconst_t) reg_obj,
61255 rc_key);
61256
61257 res->t = DUK_IVAL_PLAIN;
61258 res->x1.t = DUK_ISPEC_REGCONST;
61259 res->x1.regconst = (duk_regconst_t) reg_temp;
61260 } else {
61261 /* non-Reference deletion is always 'true', even in strict mode */
61262 duk_push_true(ctx);
61263 goto plain_value;
61264 }
61265 return;
61266 }
61267 case DUK_TOK_VOID: {
61268 duk__expr_toplain_ignore(comp_ctx, res, DUK__BP_MULTIPLICATIVE /*rbp_flags*/); /* UnaryExpression */
61269 duk_push_undefined(ctx);
61270 goto plain_value;
61271 }
61272 case DUK_TOK_TYPEOF: {
61273 /* 'typeof' must handle unresolvable references without throwing
61274 * a ReferenceError (E5 Section 11.4.3). Register mapped values
61275 * will never be unresolvable so special handling is only required
61276 * when an identifier is a "slow path" one.
61277 */
61278 duk__expr(comp_ctx, res, DUK__BP_MULTIPLICATIVE /*rbp_flags*/); /* UnaryExpression */
61279
61280 if (res->t == DUK_IVAL_VAR) {
61281 duk_reg_t reg_varbind;
61282 duk_regconst_t rc_varname;
61283 duk_reg_t reg_temp;
61284
61285 duk_dup(ctx, res->x1.valstack_idx);
61286 if (!duk__lookup_lhs(comp_ctx, &reg_varbind, &rc_varname)) {
61287 DUK_DDD(DUK_DDDPRINT("typeof for an identifier name which could not be resolved "
61288 "at compile time, need to use special run-time handling"));
61289 reg_temp = DUK__ALLOCTEMP(comp_ctx);
61290 duk__emit_extraop_b_c(comp_ctx,
61292 reg_temp,
61293 rc_varname);
61294 res->t = DUK_IVAL_PLAIN;
61295 res->x1.t = DUK_ISPEC_REGCONST;
61296 res->x1.regconst = (duk_regconst_t) reg_temp;
61297 return;
61298 }
61299 }
61300
61301 args = (DUK_EXTRAOP_TYPEOF << 8) + 0;
61302 goto unary_extraop;
61303 }
61304 case DUK_TOK_INCREMENT: {
61305 args = (DUK_OP_PREINCR << 8) + 0;
61306 goto preincdec;
61307 }
61308 case DUK_TOK_DECREMENT: {
61309 args = (DUK_OP_PREDECR << 8) + 0;
61310 goto preincdec;
61311 }
61312 case DUK_TOK_ADD: {
61313 /* unary plus */
61314 duk__expr(comp_ctx, res, DUK__BP_MULTIPLICATIVE /*rbp_flags*/); /* UnaryExpression */
61315 if (res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_VALUE &&
61316 duk_is_number(ctx, res->x1.valstack_idx)) {
61317 /* unary plus of a number is identity */
61318 ;
61319 return;
61320 }
61321 args = (DUK_EXTRAOP_UNP << 8) + 0;
61322 goto unary_extraop;
61323 }
61324 case DUK_TOK_SUB: {
61325 /* unary minus */
61326 duk__expr(comp_ctx, res, DUK__BP_MULTIPLICATIVE /*rbp_flags*/); /* UnaryExpression */
61327 if (res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_VALUE &&
61328 duk_is_number(ctx, res->x1.valstack_idx)) {
61329 /* this optimization is important to handle negative literals
61330 * (which are not directly provided by the lexical grammar)
61331 */
61332 duk_tval *tv_num;
61334
61335 tv_num = DUK_GET_TVAL_POSIDX(ctx, res->x1.valstack_idx);
61336 DUK_ASSERT(tv_num != NULL);
61338 du.d = DUK_TVAL_GET_NUMBER(tv_num);
61339 du.d = -du.d;
61341 DUK_TVAL_SET_NUMBER(tv_num, du.d);
61342 return;
61343 }
61344 args = (DUK_EXTRAOP_UNM << 8) + 0;
61345 goto unary_extraop;
61346 }
61347 case DUK_TOK_BNOT: {
61348 duk__expr(comp_ctx, res, DUK__BP_MULTIPLICATIVE /*rbp_flags*/); /* UnaryExpression */
61349 args = (DUK_EXTRAOP_BNOT << 8) + 0;
61350 goto unary_extraop;
61351 }
61352 case DUK_TOK_LNOT: {
61353 duk__expr(comp_ctx, res, DUK__BP_MULTIPLICATIVE /*rbp_flags*/); /* UnaryExpression */
61354 if (res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_VALUE) {
61355 /* Very minimal inlining to handle common idioms '!0' and '!1',
61356 * and also boolean arguments like '!false' and '!true'.
61357 */
61358 duk_tval *tv_val;
61359
61360 tv_val = DUK_GET_TVAL_POSIDX(ctx, res->x1.valstack_idx);
61361 DUK_ASSERT(tv_val != NULL);
61362 if (DUK_TVAL_IS_NUMBER(tv_val)) {
61363 duk_double_t d;
61364 d = DUK_TVAL_GET_NUMBER(tv_val);
61365 if (d == 0.0) {
61366 /* Matches both +0 and -0 on purpose. */
61367 DUK_DDD(DUK_DDDPRINT("inlined lnot: !0 -> true"));
61369 return;
61370 } else if (d == 1.0) {
61371 DUK_DDD(DUK_DDDPRINT("inlined lnot: !1 -> false"));
61373 return;
61374 }
61375 } else if (DUK_TVAL_IS_BOOLEAN(tv_val)) {
61377 v = DUK_TVAL_GET_BOOLEAN(tv_val);
61378 DUK_DDD(DUK_DDDPRINT("inlined lnot boolean: %ld", (long) v));
61379 DUK_ASSERT(v == 0 || v == 1);
61380 DUK_TVAL_SET_BOOLEAN(tv_val, v ^ 0x01);
61381 return;
61382 }
61383 }
61384 args = (DUK_EXTRAOP_LNOT << 8) + 0;
61385 goto unary_extraop;
61386 }
61387
61388 } /* end switch */
61389
61391 return;
61392
61393 unary_extraop:
61394 {
61395 /* Note: must coerce to a (writable) temp register, so that e.g. "!x" where x
61396 * is a reg-mapped variable works correctly (does not mutate the variable register).
61397 */
61398
61399 duk_reg_t reg_temp;
61400 reg_temp = duk__ivalue_toregconst_raw(comp_ctx, res, -1 /*forced_reg*/, DUK__IVAL_FLAG_REQUIRE_TEMP /*flags*/);
61401 duk__emit_extraop_bc(comp_ctx,
61402 (args >> 8),
61403 (duk_regconst_t) reg_temp);
61404 res->t = DUK_IVAL_PLAIN;
61405 res->x1.t = DUK_ISPEC_REGCONST;
61406 res->x1.regconst = (duk_regconst_t) reg_temp;
61407 return;
61408 }
61409
61410 preincdec:
61411 {
61412 /* preincrement and predecrement */
61413 duk_reg_t reg_res;
61414 duk_small_uint_t args_op = args >> 8;
61415
61416 /* Specific assumptions for opcode numbering. */
61421
61422 reg_res = DUK__ALLOCTEMP(comp_ctx);
61423
61424 duk__expr(comp_ctx, res, DUK__BP_MULTIPLICATIVE /*rbp_flags*/); /* UnaryExpression */
61425 if (res->t == DUK_IVAL_VAR) {
61426 duk_hstring *h_varname;
61427 duk_reg_t reg_varbind;
61428 duk_regconst_t rc_varname;
61429
61430 h_varname = duk_get_hstring(ctx, res->x1.valstack_idx);
61431 DUK_ASSERT(h_varname != NULL);
61432
61433 if (duk__hstring_is_eval_or_arguments_in_strict_mode(comp_ctx, h_varname)) {
61434 goto syntax_error;
61435 }
61436
61437 duk_dup(ctx, res->x1.valstack_idx);
61438 if (duk__lookup_lhs(comp_ctx, &reg_varbind, &rc_varname)) {
61439 duk__emit_a_bc(comp_ctx,
61440 args_op, /* e.g. DUK_OP_PREINCR */
61441 (duk_regconst_t) reg_res,
61442 (duk_regconst_t) reg_varbind);
61443 } else {
61444 duk__emit_a_bc(comp_ctx,
61445 args_op + 4, /* e.g. DUK_OP_PREINCV */
61446 (duk_regconst_t) reg_res,
61447 rc_varname);
61448 }
61449
61450 DUK_DDD(DUK_DDDPRINT("preincdec to '%!O' -> reg_varbind=%ld, rc_varname=%ld",
61451 (duk_heaphdr *) h_varname, (long) reg_varbind, (long) rc_varname));
61452 } else if (res->t == DUK_IVAL_PROP) {
61453 duk_reg_t reg_obj; /* allocate to reg only (not const) */
61454 duk_regconst_t rc_key;
61455 reg_obj = duk__ispec_toregconst_raw(comp_ctx, &res->x1, -1 /*forced_reg*/, 0 /*flags*/); /* don't allow const */
61456 rc_key = duk__ispec_toregconst_raw(comp_ctx, &res->x2, -1 /*forced_reg*/, DUK__IVAL_FLAG_ALLOW_CONST /*flags*/);
61457 duk__emit_a_b_c(comp_ctx,
61458 args_op + 8, /* e.g. DUK_OP_PREINCP */
61459 (duk_regconst_t) reg_res,
61460 (duk_regconst_t) reg_obj,
61461 rc_key);
61462 } else {
61463 /* Technically return value is not needed because INVLHS will
61464 * unconditially throw a ReferenceError. Coercion is necessary
61465 * for proper semantics (consider ToNumber() called for an object).
61466 * Use DUK_EXTRAOP_UNP with a dummy register to get ToNumber().
61467 */
61468
61469 duk__ivalue_toforcedreg(comp_ctx, res, reg_res);
61470 duk__emit_extraop_bc(comp_ctx,
61472 reg_res); /* for side effects, result ignored */
61473 duk__emit_extraop_only(comp_ctx,
61475 }
61476 res->t = DUK_IVAL_PLAIN;
61477 res->x1.t = DUK_ISPEC_REGCONST;
#define DUK_DBLUNION_NORMALIZE_NAN_CHECK(u)
#define DUK_OP_PREDECP
#define DUK_OP_DELPROP
DUK_EXTERNAL void duk_push_true(duk_context *ctx)
#define DUK_TOK_THIS
#define DUK_TOK_LNOT
#define DUK_TOK_BNOT
#define DUK__GETTEMP(comp_ctx)
#define DUK_OP_PREDECR
#define DUK_OP_PREINCP
DUK_LOCAL_DECL duk_regconst_t duk__ivalue_toregconst_raw(duk_compiler_ctx *comp_ctx, duk_ivalue *x, duk_reg_t forced_reg, duk_small_uint_t flags)
#define DUK_TOK_NUMBER
DUK_LOCAL_DECL void duk__nud_array_literal(duk_compiler_ctx *comp_ctx, duk_ivalue *res)
DUK_LOCAL_DECL void duk__expr_toplain_ignore(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags)
#define DUK_STR_CANNOT_DELETE_IDENTIFIER
#define DUK__BP_CALL
#define DUK_TOK_TRUE
#define DUK_EXTRAOP_UNM
#define DUK_EXTRAOP_TYPEOFID
DUK_EXTERNAL void duk_push_null(duk_context *ctx)
#define DUK_EXTRAOP_LNOT
DUK_EXTERNAL duk_bool_t duk_is_number(duk_context *ctx, duk_idx_t index)
#define DUK_TOK_NEW
#define DUK_TOK_REGEXP
#define DUK_OP_CLOSURE
#define DUK_TOK_NULL
DUK_LOCAL_DECL void duk__nud_object_literal(duk_compiler_ctx *comp_ctx, duk_ivalue *res)
#define DUK_TOK_FALSE
#define DUK_OP_PREINCR
#define DUK_TVAL_SET_BOOLEAN_TRUE(v)
#define DUK_TOK_STRING
#define DUK_EXTRAOP_LDFALSE
#define DUK_OP_DELVAR
#define DUK_OP_PREDECV
#define DUK_EXTRAOP_LDTHIS
#define DUK_TOK_DELETE
DUK_EXTERNAL void duk_push_false(duk_context *ctx)
DUK_INTERNAL_DECL void duk_regexp_compile(duk_hthread *thr)
DUK_LOCAL_DECL void duk__expr_nud(duk_compiler_ctx *comp_ctx, duk_ivalue *res)
#define DUK_TVAL_SET_BOOLEAN_FALSE(v)
#define DUK_TVAL_SET_BOOLEAN(tv, val)
#define DUK_EXTRAOP_BNOT
#define DUK_TOK_TYPEOF
#define DUK_OP_REGEXP
#define DUK_TOK_LCURLY
#define DUK_OP_PREINCV
DUK_LOCAL_DECL duk_int_t duk__parse_func_like_fnum(duk_compiler_ctx *comp_ctx, duk_bool_t is_decl, duk_bool_t is_setget)
#define DUK_EXTRAOP_TYPEOF
#define DUK_IVAL_NONE
#define DUK_TOK_FUNCTION
#define DUK_TVAL_IS_BOOLEAN(tv)
#define DUK_TVAL_SET_NUMBER(tv, val)
#define DUK_TOK_VOID

◆ duk__expr_toforcedreg()

DUK_LOCAL_DECL void duk__expr_toforcedreg ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res,
duk_small_uint_t rbp_flags,
duk_reg_t forced_reg )

Definition at line 62581 of file duktape-1.8.0/src/duktape.c.

62585 {

References duk__expr().

◆ duk__expr_toplain()

DUK_LOCAL_DECL void duk__expr_toplain ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res,
duk_small_uint_t rbp_flags )

Definition at line 62599 of file duktape-1.8.0/src/duktape.c.

◆ duk__expr_toplain_ignore()

DUK_LOCAL_DECL void duk__expr_toplain_ignore ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res,
duk_small_uint_t rbp_flags )

Definition at line 62604 of file duktape-1.8.0/src/duktape.c.

62604 {
62605 duk__expr(comp_ctx, res, rbp_flags);
62606 return duk__ivalue_toregconst(comp_ctx, res);
62607}
DUK_LOCAL_DECL duk_regconst_t duk__ivalue_toregconst(duk_compiler_ctx *comp_ctx, duk_ivalue *x)

References duk__expr(), and duk__ivalue_toregconst().

◆ duk__expr_toregconst()

DUK_LOCAL_DECL duk_regconst_t duk__expr_toregconst ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res,
duk_small_uint_t rbp_flags )

Definition at line 62587 of file duktape-1.8.0/src/duktape.c.

◆ duk__exprtop()

DUK_LOCAL_DECL void duk__exprtop ( duk_compiler_ctx * ctx,
duk_ivalue * res,
duk_small_uint_t rbp_flags )

Definition at line 62542 of file duktape-1.8.0/src/duktape.c.

62545 {
62546 duk__advance(comp_ctx);
62547 duk__expr_led(comp_ctx, res, tmp);
62548 duk__copy_ivalue(comp_ctx, tmp, res); /* tmp -> res */
62549 }
62550
62551 cleanup:
62552 /* final result is already in 'res' */
62553
62554 duk_pop_2(ctx);
62555
62556 DUK__RECURSION_DECREASE(comp_ctx, thr);
62557}
62558
62559DUK_LOCAL void duk__exprtop(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags) {
DUK_LOCAL_DECL void duk__exprtop(duk_compiler_ctx *ctx, duk_ivalue *res, duk_small_uint_t rbp_flags)
#define DUK__RECURSION_DECREASE(comp_ctx, thr)

Referenced by duk__parse_var_decl().

◆ duk__exprtop_toforcedreg()

DUK_LOCAL_DECL void duk__exprtop_toforcedreg ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res,
duk_small_uint_t rbp_flags,
duk_reg_t forced_reg )

Definition at line 62621 of file duktape-1.8.0/src/duktape.c.

62621 {
62622 duk__expr(comp_ctx, res, rbp_flags);
62623 duk__ivalue_toplain_ignore(comp_ctx, res);
62624}
62625

References duk__expr(), and duk__ivalue_toplain_ignore().

◆ duk__exprtop_toreg()

DUK_LOCAL_DECL duk_reg_t duk__exprtop_toreg ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res,
duk_small_uint_t rbp_flags )

Definition at line 62609 of file duktape-1.8.0/src/duktape.c.

62610 {
62611 duk__expr(comp_ctx, res, rbp_flags);
62612 return duk__ivalue_totempconst(comp_ctx, res);

References duk__expr(), and duk__ivalue_totempconst().

Referenced by duk__parse_try_stmt().

◆ duk__exprtop_toregconst()

DUK_LOCAL_DECL duk_regconst_t duk__exprtop_toregconst ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res,
duk_small_uint_t rbp_flags )

Definition at line 62627 of file duktape-1.8.0/src/duktape.c.

◆ duk__fabs()

DUK_LOCAL double duk__fabs ( double x)

Definition at line 32735 of file duktape-1.8.0/src/duktape.c.

◆ duk__fill_lexer_buffer()

DUK_LOCAL void duk__fill_lexer_buffer ( duk_lexer_ctx * lex_ctx,
duk_small_uint_t start_offset_bytes )

Definition at line 73493 of file duktape-1.8.0/src/duktape.c.

73494 :
73495 *
73496 * * Reject other invalid Unicode sequences (see Wikipedia entry for examples)
73497 * in strict UTF-8 mode.
73498 *
73499 * * Size optimize. An attempt to use a 16-byte lookup table for the first
73500 * byte resulted in a code increase though.
73501 *
73502 * * Is checking against maximum 0x10ffff really useful? 4-byte encoding
73503 * imposes a certain limit anyway.
73504 *
73505 * * Support chunked streaming of source code. Can be implemented either
73506 * by streaming chunks of bytes or chunks of codepoints.
73507 */
73508
73509#if defined(DUK_USE_LEXER_SLIDING_WINDOW)
73510DUK_LOCAL void duk__fill_lexer_buffer(duk_lexer_ctx *lex_ctx, duk_small_uint_t start_offset_bytes) {
73511 duk_lexer_codepoint *cp, *cp_end;
73513 duk_small_uint_t contlen;
73514 const duk_uint8_t *p, *p_end;
73515#if defined(DUK_USE_STRICT_UTF8_SOURCE)
73516 duk_ucodepoint_t mincp;
73517#endif
73518 duk_int_t input_line;
73519
73520 /* Use temporaries and update lex_ctx only when finished. */
73521 input_line = lex_ctx->input_line;
73522 p = lex_ctx->input + lex_ctx->input_offset;
73523 p_end = lex_ctx->input + lex_ctx->input_length;
73524
73525 cp = (duk_lexer_codepoint *) (void *) ((duk_uint8_t *) lex_ctx->buffer + start_offset_bytes);
73526 cp_end = lex_ctx->buffer + DUK_LEXER_BUFFER_SIZE;
73527
73528 for (; cp != cp_end; cp++) {
73529 cp->offset = (duk_size_t) (p - lex_ctx->input);
73530 cp->line = input_line;
73531
73532 /* XXX: potential issue with signed pointers, p_end < p. */
73533 if (DUK_UNLIKELY(p >= p_end)) {
73534 /* If input_offset were assigned a negative value, it would
73535 * result in a large positive value. Most likely it would be
73536 * larger than input_length and be caught here. In any case
73537 * no memory unsafe behavior would happen.
73538 */
73539 cp->codepoint = -1;
73540 continue;
73541 }
73542
73543 x = (duk_ucodepoint_t) (*p++);
73544
73545 /* Fast path. */
73546
73547 if (DUK_LIKELY(x < 0x80UL)) {
73548 DUK_ASSERT(x != 0x2028UL && x != 0x2029UL); /* not LS/PS */
73549 if (DUK_UNLIKELY(x <= 0x000dUL)) {
73550 if ((x == 0x000aUL) ||
73551 ((x == 0x000dUL) && (p >= p_end || *p != 0x000aUL))) {
73552 /* lookup for 0x000a above assumes shortest encoding now */
73553
73554 /* E5 Section 7.3, treat the following as newlines:
73555 * LF
73556 * CR [not followed by LF]
73557 * LS
73558 * PS
73559 *
73560 * For CR LF, CR is ignored if it is followed by LF, and the LF will bump
73561 * the line number.
73562 */
73563 input_line++;
73564 }
73565 }
73566
73567 cp->codepoint = (duk_codepoint_t) x;
73568 continue;
73569 }
73570
73571 /* Slow path. */
73572
73573 if (x < 0xc0UL) {
73574 /* 10xx xxxx -> invalid */
73575 goto error_encoding;
73576 } else if (x < 0xe0UL) {
73577 /* 110x xxxx 10xx xxxx */
73578 contlen = 1;
73579#if defined(DUK_USE_STRICT_UTF8_SOURCE)
73580 mincp = 0x80UL;
73581#endif
73582 x = x & 0x1fUL;
73583 } else if (x < 0xf0UL) {
73584 /* 1110 xxxx 10xx xxxx 10xx xxxx */
73585 contlen = 2;
73586#if defined(DUK_USE_STRICT_UTF8_SOURCE)
73587 mincp = 0x800UL;
73588#endif
73589 x = x & 0x0fUL;
73590 } else if (x < 0xf8UL) {
73591 /* 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx */
73592 contlen = 3;
73593#if defined(DUK_USE_STRICT_UTF8_SOURCE)
73594 mincp = 0x10000UL;
73595#endif
73596 x = x & 0x07UL;
73597 } else {
73598 /* no point in supporting encodings of 5 or more bytes */
73599 goto error_encoding;
73600 }
73601
73602 DUK_ASSERT(p_end >= p);
73603 if ((duk_size_t) contlen > (duk_size_t) (p_end - p)) {
73604 goto error_clipped;
73605 }
73606
73607 while (contlen > 0) {
73609 y = *p++;
73610 if ((y & 0xc0U) != 0x80U) {
73611 /* check that byte has the form 10xx xxxx */
73612 goto error_encoding;
73613 }
73614 x = x << 6;
73615 x += y & 0x3fUL;
73616 contlen--;
73617 }
73618
73619 /* check final character validity */
73620
73621 if (x > 0x10ffffUL) {
73622 goto error_encoding;
73623 }
73624#if defined(DUK_USE_STRICT_UTF8_SOURCE)
73625 if (x < mincp || (x >= 0xd800UL && x <= 0xdfffUL) || x == 0xfffeUL) {
73626 goto error_encoding;
73627 }
73628#endif
73629
73630 DUK_ASSERT(x != 0x000aUL && x != 0x000dUL);
73631 if ((x == 0x2028UL) || (x == 0x2029UL)) {
DUK_LOCAL void duk__fill_lexer_buffer(duk_lexer_ctx *lex_ctx, duk_small_uint_t start_offset_bytes)

References duk_lexer_ctx::buffer, duk_lexer_codepoint::codepoint, DUK_ASSERT, DUK_LEXER_BUFFER_SIZE, DUK_LIKELY, DUK_UNLIKELY, duk_lexer_ctx::input, duk_lexer_ctx::input_length, duk_lexer_ctx::input_line, duk_lexer_ctx::input_offset, duk_lexer_codepoint::line, and duk_lexer_codepoint::offset.

Referenced by duk__init_lexer_window().

◆ duk__finalize_helper()

DUK_LOCAL duk_ret_t duk__finalize_helper ( duk_context * ctx)

Definition at line 47027 of file duktape-1.8.0/src/duktape.c.

47032 :
47033 *
47034 * - The thread used for calling the finalizer is the same as the
47035 * 'thr' argument. This may need to change later.
47036 *
47037 * - The finalizer thread 'top' assertions are there because it is
47038 * critical that strict stack policy is observed (i.e. no cruft
47039 * left on the finalizer stack).
47040 */
47041
47042/* include removed: duk_internal.h */
47043
47045 duk_hthread *thr;
47046
47047 DUK_ASSERT(ctx != NULL);
47048 thr = (duk_hthread *) ctx;
47049
47050 DUK_DDD(DUK_DDDPRINT("protected finalization helper running"));
47051
47052 /* [... obj] */
47053
47054 /* XXX: Finalizer lookup should traverse the prototype chain (to allow
47055 * inherited finalizers) but should not invoke accessors or proxy object
47056 * behavior. At the moment this lookup will invoke proxy behavior, so
47057 * caller must ensure that this function is not called if the target is
47058 * a Proxy.
47059 */
47060
DUK_LOCAL duk_ret_t duk__finalize_helper(duk_context *ctx)

References DUK_ASSERT, DUK_DDD, DUK_DDDPRINT, duk_get_prop_stridx(), DUK_STRIDX_INT_FINALIZER, and NULL.

◆ duk__finalize_refcounts()

DUK_LOCAL void duk__finalize_refcounts ( duk_heap * heap)

Definition at line 42620 of file duktape-1.8.0/src/duktape.c.

42637 {
42638 duk_hthread *thr;
42639 duk_heaphdr *hdr;
42640
42641 thr = duk__get_temp_hthread(heap);
42642 DUK_ASSERT(thr != NULL);
42643
42644 DUK_DD(DUK_DDPRINT("duk__finalize_refcounts: heap=%p, hthread=%p",
42645 (void *) heap, (void *) thr));
42646
42647 hdr = heap->heap_allocated;
42648 while (hdr) {
42649 if (!DUK_HEAPHDR_HAS_REACHABLE(hdr)) {
#define DUK_HEAPHDR_HAS_REACHABLE(h)

◆ duk__find_matching_string_probe()

DUK_LOCAL duk_hstring * duk__find_matching_string_probe ( duk_heap * heap,
duk_hstring ** entries,
duk_uint32_t size,
const duk_uint8_t * str,
duk_uint32_t blen,
duk_uint32_t strhash )

Definition at line 45559 of file duktape-1.8.0/src/duktape.c.

45565 : %ld", (long) i));
45566 i = (i + step) % size;
45567
45568 /* looping should never happen */
45569 DUK_ASSERT(i != DUK__HASH_INITIAL(DUK_HSTRING_GET_HASH(h), size));
45570 }
45571}
45572
45573#if defined(DUK_USE_HEAPPTR16)
45574DUK_LOCAL duk_hstring *duk__find_matching_string_probe(duk_heap *heap, duk_uint16_t *entries16, duk_uint32_t size, const duk_uint8_t *str, duk_uint32_t blen, duk_uint32_t strhash) {
45575#else
45576DUK_LOCAL duk_hstring *duk__find_matching_string_probe(duk_heap *heap, duk_hstring **entries, duk_uint32_t size, const duk_uint8_t *str, duk_uint32_t blen, duk_uint32_t strhash) {
45577#endif
45578 duk_uint32_t i;
45579 duk_uint32_t step;
45580
45581 DUK_ASSERT(size > 0);
45582
45583 i = DUK__HASH_INITIAL(strhash, size);
45584 step = DUK__HASH_PROBE_STEP(strhash);
45585 for (;;) {
45586 duk_hstring *e;
45587#if defined(DUK_USE_HEAPPTR16)
45588 e = (duk_hstring *) DUK_USE_HEAPPTR_DEC16(heap->heap_udata, entries16[i]);
45589#else
45590 e = entries[i];
45591#endif
45592
45593 if (!e) {
45594 return NULL;

◆ duk__floor()

DUK_LOCAL double duk__floor ( double x)

Definition at line 32756 of file duktape-1.8.0/src/duktape.c.

32758 {

◆ duk__fmax_fixed()

DUK_LOCAL double duk__fmax_fixed ( double x,
double y )

Definition at line 32607 of file duktape-1.8.0/src/duktape.c.

32609 {
32610 /* XXX: what's the safest way of creating a negative zero? */
32611 if (DUK_SIGNBIT(x) != 0 || DUK_SIGNBIT(y) != 0) {
32612 return -0.0;
32613 } else {
32614 return +0.0;
32615 }
32616 }
32617#ifdef DUK_USE_MATH_FMIN
32618 return DUK_FMIN(x, y);
32619#else
32620 return (x < y ? x : y);
32621#endif
32622}
32623

References DUK_SIGNBIT.

◆ duk__fmin_fixed()

DUK_LOCAL double duk__fmin_fixed ( double x,
double y )

Definition at line 32588 of file duktape-1.8.0/src/duktape.c.

32591 {
32592 t = duk_to_number(ctx, i);
32593 if (DUK_FPCLASSIFY(t) == DUK_FP_NAN || DUK_FPCLASSIFY(res) == DUK_FP_NAN) {
32594 /* Note: not normalized, but duk_push_number() will normalize */
32596 } else {
32597 res = (duk_double_t) min_max(res, (double) t);
32598 }
32599 }
32600
32601 duk_push_number(ctx, res);
32602 return 1;
32603}
32604
32605DUK_LOCAL double duk__fmin_fixed(double x, double y) {
DUK_LOCAL double duk__fmin_fixed(double x, double y)

References DUK_DOUBLE_NAN, DUK_FP_NAN, DUK_FPCLASSIFY, and duk_to_number().

◆ duk__format_parts_iso8601()

DUK_LOCAL void duk__format_parts_iso8601 ( duk_int_t * parts,
duk_int_t tzoffset,
duk_small_uint_t flags,
duk_uint8_t * out_buf )

Definition at line 25566 of file duktape-1.8.0/src/duktape.c.

25568 {
25569 duk_double_t d;
25570
25571 /* [ ... this ] */
25572
25573 d = duk_bi_date_get_timeval_from_dparts(dparts, flags);
25574 duk_push_number(ctx, d); /* -> [ ... this timeval_new ] */
25575 duk_dup_top(ctx); /* -> [ ... this timeval_new timeval_new ] */
25577
25578 /* stack top: new time value, return 1 to allow tail calls */
25579 return 1;
25580}
25581
25582/* 'out_buf' must be at least DUK_BI_DATE_ISO8601_BUFSIZE long. */
25583DUK_LOCAL void duk__format_parts_iso8601(duk_int_t *parts, duk_int_t tzoffset, duk_small_uint_t flags, duk_uint8_t *out_buf) {
25584 char yearstr[8]; /* "-123456\0" */
25585 char tzstr[8]; /* "+11:22\0" */
25586 char sep = (flags & DUK_DATE_FLAG_SEP_T) ? DUK_ASC_UC_T : DUK_ASC_SPACE;
25587
25588 DUK_ASSERT(parts[DUK_DATE_IDX_MONTH] >= 1 && parts[DUK_DATE_IDX_MONTH] <= 12);
25589 DUK_ASSERT(parts[DUK_DATE_IDX_DAY] >= 1 && parts[DUK_DATE_IDX_DAY] <= 31);
25590 DUK_ASSERT(parts[DUK_DATE_IDX_YEAR] >= -999999 && parts[DUK_DATE_IDX_YEAR] <= 999999);
25591
25592 /* Note: %06d for positive value, %07d for negative value to include
25593 * sign and 6 digits.
25594 */
25595 DUK_SNPRINTF(yearstr,
25596 sizeof(yearstr),
25597 (parts[DUK_DATE_IDX_YEAR] >= 0 && parts[DUK_DATE_IDX_YEAR] <= 9999) ? "%04ld" :
25598 ((parts[DUK_DATE_IDX_YEAR] >= 0) ? "+%06ld" : "%07ld"),
25599 (long) parts[DUK_DATE_IDX_YEAR]);
25600 yearstr[sizeof(yearstr) - 1] = (char) 0;
25601
25602 if (flags & DUK_DATE_FLAG_LOCALTIME) {
25603 /* tzoffset seconds are dropped; 16 bits suffice for
25604 * time offset in minutes
25605 */
25606 if (tzoffset >= 0) {
25607 duk_small_int_t tmp = tzoffset / 60;
25608 DUK_SNPRINTF(tzstr, sizeof(tzstr), "+%02d:%02d", (int) (tmp / 60), (int) (tmp % 60));
25609 } else {
25610 duk_small_int_t tmp = -tzoffset / 60;
25611 DUK_SNPRINTF(tzstr, sizeof(tzstr), "-%02d:%02d", (int) (tmp / 60), (int) (tmp % 60));
25612 }
25613 tzstr[sizeof(tzstr) - 1] = (char) 0;
25614 } else {
25615 tzstr[0] = DUK_ASC_UC_Z;
25616 tzstr[1] = (char) 0;
25617 }
25618
25619 /* Unlike year, the other parts fit into 16 bits so %d format
25620 * is portable.
#define DUK_DATE_FLAG_LOCALTIME
#define DUK_ASC_UC_T
DUK_INTERNAL_DECL duk_double_t duk_bi_date_get_timeval_from_dparts(duk_double_t *dparts, duk_small_uint_t flags)
DUK_LOCAL void duk__format_parts_iso8601(duk_int_t *parts, duk_int_t tzoffset, duk_small_uint_t flags, duk_uint8_t *out_buf)
#define DUK_ASC_UC_Z
DUK_INTERNAL_DECL duk_bool_t duk_put_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx)

References duk_bi_date_get_timeval_from_dparts(), duk_dup_top(), duk_push_number(), duk_put_prop_stridx(), and DUK_STRIDX_INT_VALUE.

◆ duk__free_allocated()

DUK_LOCAL void duk__free_allocated ( duk_heap * heap)

Definition at line 41131 of file duktape-1.8.0/src/duktape.c.

◆ duk__free_markandsweep_finalize_list()

DUK_LOCAL void duk__free_markandsweep_finalize_list ( duk_heap * heap)

Definition at line 41166 of file duktape-1.8.0/src/duktape.c.

41167 {
41168 duk_heaphdr *curr;
41170
41171 curr = heap->refzero_list;
41172 while (curr) {
41173 DUK_DDD(DUK_DDDPRINT("FINALFREE (refzero_list): %!iO",
41174 (duk_heaphdr *) curr));
41175 next = DUK_HEAPHDR_GET_NEXT(heap, curr);
41176 duk_heap_free_heaphdr_raw(heap, curr);
41177 curr = next;
41178 }
DUK_INTERNAL_DECL void duk_heap_free_heaphdr_raw(duk_heap *heap, duk_heaphdr *hdr)

References DUK_DDD, DUK_DDDPRINT, duk_heap_free_heaphdr_raw(), DUK_HEAPHDR_GET_NEXT, next, and duk_heap::refzero_list.

◆ duk__free_refzero_list()

DUK_LOCAL void duk__free_refzero_list ( duk_heap * heap)

Definition at line 41150 of file duktape-1.8.0/src/duktape.c.

41153 {
41154 /* We don't log or warn about freeing zero refcount objects
41155 * because they may happen with finalizer processing.
41156 */
41157
41158 DUK_DDD(DUK_DDDPRINT("FINALFREE (allocated): %!iO",
41159 (duk_heaphdr *) curr));
41160 next = DUK_HEAPHDR_GET_NEXT(heap, curr);
41161 duk_heap_free_heaphdr_raw(heap, curr);
41162 curr = next;

References DUK_DDD, DUK_DDDPRINT, duk_heap_free_heaphdr_raw(), DUK_HEAPHDR_GET_NEXT, and next.

◆ duk__free_run_finalizers()

DUK_LOCAL void duk__free_run_finalizers ( duk_heap * heap)

Definition at line 41186 of file duktape-1.8.0/src/duktape.c.

41188 {
41189 DUK_DDD(DUK_DDDPRINT("FINALFREE (finalize_list): %!iO",
41190 (duk_heaphdr *) curr));
41191 next = DUK_HEAPHDR_GET_NEXT(heap, curr);
41192 duk_heap_free_heaphdr_raw(heap, curr);
41193 curr = next;
41194 }
41195}
41196#endif
41197
41199 /* strings are only tracked by stringtable */
41201}
41202
41204 duk_hthread *thr;
41205 duk_heaphdr *curr;
41206 duk_uint_t round_no;
41207 duk_size_t count_all;
41208 duk_size_t count_finalized;
41209 duk_size_t curr_limit;
41210
41211 DUK_ASSERT(heap != NULL);
41212 DUK_ASSERT(heap->heap_thread != NULL);
41213
41214#if defined(DUK_USE_REFERENCE_COUNTING)
41215 DUK_ASSERT(heap->refzero_list == NULL); /* refzero not running -> must be empty */
41216#endif
41217#if defined(DUK_USE_MARK_AND_SWEEP)
41218 DUK_ASSERT(heap->finalize_list == NULL); /* mark-and-sweep not running -> must be empty */
41219#endif
41220
41221 /* XXX: here again finalizer thread is the heap_thread which needs
41222 * to be coordinated with finalizer thread fixes.
41223 */
41224 thr = heap->heap_thread;
41225 DUK_ASSERT(thr != NULL);
41226
41227 /* Prevent mark-and-sweep for the pending finalizers, also prevents
41228 * refzero handling from moving objects away from the heap_allocated
41229 * list. (The flag meaning is slightly abused here.)
41230 */
41233
41234 curr_limit = 0; /* suppress warning, not used */
41235 for (round_no = 0; ; round_no++) {
41236 curr = heap->heap_allocated;
41237 count_all = 0;
41238 count_finalized = 0;
41239 while (curr) {
41240 count_all++;
41242 /* Only objects in heap_allocated may have finalizers. Check that
41243 * the object itself has a _Finalizer property (own or inherited)
41244 * so that we don't execute finalizers for e.g. Proxy objects.
41245 */
41246 DUK_ASSERT(thr != NULL);
41247 DUK_ASSERT(curr != NULL);
41248
41250 if (!DUK_HEAPHDR_HAS_FINALIZED((duk_heaphdr *) curr)) {
41251 DUK_ASSERT(DUK_HEAP_HAS_FINALIZER_NORESCUE(heap)); /* maps to finalizer 2nd argument */
41253 count_finalized++;
41254 }
41255 }
41256 }
41257 curr = DUK_HEAPHDR_GET_NEXT(heap, curr);
41258 }
41259
41260 /* Each round of finalizer execution may spawn new finalizable objects
41261 * which is normal behavior for some applications. Allow multiple
41262 * rounds of finalization, but use a shrinking limit based on the
41263 * first round to detect the case where a runaway finalizer creates
41264 * an unbounded amount of new finalizable objects. Finalizer rescue
41265 * is not supported: the semantics are unclear because most of the
41266 * objects being finalized here are already reachable. The finalizer
41267 * is given a boolean to indicate that rescue is not possible.
41268 *
41269 * See discussion in: https://github.com/svaarala/duktape/pull/473
41270 */
41271
41272 if (round_no == 0) {
41273 /* Cannot wrap: each object is at least 8 bytes so count is
41274 * at most 1/8 of that.
41275 */
41276 curr_limit = count_all * 2;
41277 } else {
41278 curr_limit = (curr_limit * 3) / 4; /* Decrease by 25% every round */
#define DUK_HEAP_HAS_FINALIZER_NORESCUE(heap)
DUK_LOCAL void duk__free_run_finalizers(duk_heap *heap)
#define DUK_HEAP_SET_MARKANDSWEEP_RUNNING(heap)
DUK_LOCAL void duk__free_stringtable(duk_heap *heap)
#define DUK_HEAP_HAS_MARKANDSWEEP_RUNNING(heap)
#define DUK_HEAPHDR_HAS_FINALIZED(h)
DUK_INTERNAL_DECL void duk_hobject_run_finalizer(duk_hthread *thr, duk_hobject *obj)
DUK_INTERNAL void duk_heap_free_strtab(duk_heap *heap)
#define DUK_HTHREAD_STRING_INT_FINALIZER(thr)
DUK_INTERNAL_DECL duk_bool_t duk_hobject_hasprop_raw(duk_hthread *thr, duk_hobject *obj, duk_hstring *key)

References DUK_DDD, DUK_DDDPRINT, duk_heap_free_heaphdr_raw(), DUK_HEAPHDR_GET_NEXT, and next.

◆ duk__free_stringtable()

DUK_LOCAL void duk__free_stringtable ( duk_heap * heap)

Definition at line 41181 of file duktape-1.8.0/src/duktape.c.

41183 {
41184 duk_heaphdr *curr;

References next.

◆ duk__generate_ranges()

DUK_LOCAL void duk__generate_ranges ( void * userdata,
duk_codepoint_t r1,
duk_codepoint_t r2,
duk_bool_t direct )

Definition at line 77838 of file duktape-1.8.0/src/duktape.c.

77845 {] is
77846 * continuous but [X-{] is not). The current algorithm creates the
77847 * canonicalized range(s) space efficiently at the cost of compile
77848 * time execution time (see doc/regexp.rst for discussion).
77849 *
77850 * Note that the ctx->nranges is a context-wide temporary value
77851 * (this is OK because there cannot be multiple character classes
77852 * being parsed simultaneously).
77853 */
77854
77855DUK_LOCAL void duk__generate_ranges(void *userdata, duk_codepoint_t r1, duk_codepoint_t r2, duk_bool_t direct) {
77856 duk_re_compiler_ctx *re_ctx = (duk_re_compiler_ctx *) userdata;
77857
77858 DUK_DD(DUK_DDPRINT("duk__generate_ranges(): re_ctx=%p, range=[%ld,%ld] direct=%ld",
77859 (void *) re_ctx, (long) r1, (long) r2, (long) direct));
77860
77861 if (!direct && (re_ctx->re_flags & DUK_RE_FLAG_IGNORE_CASE)) {
77862 /*
77863 * Canonicalize a range, generating result ranges as necessary.
77864 * Needs to exhaustively scan the entire range (at most 65536
77865 * code points). If 'direct' is set, caller (lexer) has ensured
77866 * that the range is already canonicalization compatible (this
77867 * is used to avoid unnecessary canonicalization of built-in
77868 * ranges like \W, which are not affected by canonicalization).
77869 *
77870 * NOTE: here is one place where we don't want to support chars
77871 * outside the BMP, because the exhaustive search would be
77872 * massively larger.
77873 */
77874
77877 duk_codepoint_t r_start, r_end;
77878
77879 r_start = duk_unicode_re_canonicalize_char(re_ctx->thr, r1);
77880 r_end = r_start;
77881 for (i = r1 + 1; i <= r2; i++) {
77882 t = duk_unicode_re_canonicalize_char(re_ctx->thr, i);
77883 if (t == r_end + 1) {
77884 r_end = t;
77885 } else {
77886 DUK_DD(DUK_DDPRINT("canonicalized, emit range: [%ld,%ld]", (long) r_start, (long) r_end));
77887 duk__append_u32(re_ctx, (duk_uint32_t) r_start);
DUK_LOCAL void duk__generate_ranges(void *userdata, duk_codepoint_t r1, duk_codepoint_t r2, duk_bool_t direct)
DUK_INTERNAL_DECL duk_codepoint_t duk_unicode_re_canonicalize_char(duk_hthread *thr, duk_codepoint_t cp)
#define DUK_RE_FLAG_IGNORE_CASE
DUK_LOCAL duk_uint32_t duk__append_u32(duk_re_compiler_ctx *re_ctx, duk_uint32_t x)

References duk__append_u32(), DUK_DD, DUK_DDPRINT, DUK_RE_FLAG_IGNORE_CASE, duk_unicode_re_canonicalize_char(), duk_re_compiler_ctx::nranges, duk_re_compiler_ctx::re_flags, and duk_re_compiler_ctx::thr.

Referenced by duk__parse_disjunction().

◆ duk__get_buffer_data_helper()

DUK_LOCAL void * duk__get_buffer_data_helper ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_size,
duk_bool_t throw_flag )

Definition at line 16340 of file duktape-1.8.0/src/duktape.c.

16343 {
16345 }
16346 return NULL;
16347}
16348
16350 return duk__get_buffer_helper(ctx, index, out_size, 0 /*throw_flag*/);
16351}
16352
16354 return duk__get_buffer_helper(ctx, index, out_size, 1 /*throw_flag*/);
16355}
16356
16358 duk_hthread *thr = (duk_hthread *) ctx;
16359 duk_tval *tv;
16360
16362 DUK_UNREF(thr);
16363
16364 if (out_size != NULL) {
16365 *out_size = 0;
16366 }
16367
16368 tv = duk_get_tval(ctx, index);
16369 if (tv == NULL) {
16370 goto fail;
16371 }
16372
16373 if (DUK_TVAL_IS_BUFFER(tv)) {
16375 DUK_ASSERT(h != NULL);
16376 if (out_size) {
16377 *out_size = DUK_HBUFFER_GET_SIZE(h);
16378 }
16379 return (void *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h); /* may be NULL (but only if size is 0) */
16380 } else if (DUK_TVAL_IS_OBJECT(tv)) {
16382 DUK_ASSERT(h != NULL);
16384 /* XXX: this is probably a useful shared helper: for a
16385 * duk_hbufferobject, get a validated buffer pointer/length.
16386 */
16387 duk_hbufferobject *h_bufobj = (duk_hbufferobject *) h;
16389
16390 if (h_bufobj->buf != NULL &&
16392 duk_uint8_t *p;
#define DUK_TVAL_IS_BUFFER(tv)
#define DUK_HBUFFEROBJECT_VALID_SLICE(h)
DUK_EXTERNAL void * duk_require_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size)
DUK_LOCAL void * duk__get_buffer_data_helper(duk_context *ctx, duk_idx_t index, duk_size_t *out_size, duk_bool_t throw_flag)
#define DUK_STR_NOT_BUFFER
DUK_LOCAL void * duk__get_buffer_helper(duk_context *ctx, duk_idx_t index, duk_size_t *out_size, duk_bool_t throw_flag)

◆ duk__get_buffer_helper()

DUK_LOCAL void * duk__get_buffer_helper ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_size,
duk_bool_t throw_flag )

Definition at line 16305 of file duktape-1.8.0/src/duktape.c.

16306 {
16307 duk_tval *tv;
16308
16310
16311 tv = duk_get_tval(ctx, index);
16312 if (tv && DUK_TVAL_IS_HEAP_ALLOCATED(tv)) {
16314 DUK_ASSERT(h != NULL);
16315 return (void *) h;
16316 }
16317
16318 return NULL;
16319}
16320#endif
16321
16323 duk_hthread *thr = (duk_hthread *) ctx;
16324 duk_tval *tv;
16325
16327 DUK_UNREF(thr);
16328
16329 if (out_size != NULL) {
16330 *out_size = 0;

References DUK_ASSERT, DUK_ASSERT_CTX_VALID, duk_get_tval(), DUK_TVAL_GET_HEAPHDR, DUK_TVAL_IS_HEAP_ALLOCATED, index, and NULL.

◆ duk__get_bufobj_this()

DUK_LOCAL duk_hbufferobject * duk__get_bufobj_this ( duk_context * ctx)

Definition at line 21863 of file duktape-1.8.0/src/duktape.c.

21865 {

◆ duk__get_current_pc()

DUK_LOCAL_DECL duk_int_t duk__get_current_pc ( duk_compiler_ctx * comp_ctx)

Definition at line 58732 of file duktape-1.8.0/src/duktape.c.

◆ duk__get_default_h_size()

DUK_LOCAL duk_uint32_t duk__get_default_h_size ( duk_uint32_t e_size)

Definition at line 47596 of file duktape-1.8.0/src/duktape.c.

47601 {
47602 DUK_UNREF(thr);
47603 return (key == DUK_HTHREAD_STRING_LENGTH(thr) ||
47604 key == DUK_HTHREAD_STRING_NAME(thr));
47605}
47606
47607/*
47608 * Helpers for managing property storage size
47609 */
47610
47611/* Get default hash part size for a certain entry part size. */
#define DUK_HTHREAD_STRING_NAME(thr)
#define DUK_HTHREAD_STRING_LENGTH(thr)

◆ duk__get_identifier_reference()

DUK_LOCAL duk_bool_t duk__get_identifier_reference ( duk_hthread * thr,
duk_hobject * env,
duk_hstring * name,
duk_activation * act,
duk_bool_t parents,
duk__id_lookup_result * out )

Definition at line 72380 of file duktape-1.8.0/src/duktape.c.

72402 {
72403 duk_tval *tv;
72404 duk_tval *tv_target;
72405 duk_tval tv_name;
72406 duk_uint_t sanity;
72407
72408 DUK_ASSERT(thr != NULL);
72409 DUK_ASSERT(env != NULL || act != NULL);
72410 DUK_ASSERT(name != NULL);
72411 DUK_ASSERT(out != NULL);
72412
72413 DUK_ASSERT(!env || DUK_HOBJECT_IS_ENV(env));
72415
72416 /*
72417 * Conceptually, we look for the identifier binding by starting from
72418 * 'env' and following to chain of environment records (represented
72419 * by the prototype chain).
72420 *
72421 * If 'env' is NULL, the current activation does not yet have an
72422 * allocated declarative environment record; this should be treated
72423 * exactly as if the environment record existed but had no bindings
72424 * other than register bindings.
72425 *
72426 * Note: we assume that with the DUK_HOBJECT_FLAG_NEWENV cleared
72427 * the environment will always be initialized immediately; hence
72428 * a NULL 'env' should only happen with the flag set. This is the
72429 * case for: (1) function calls, and (2) strict, direct eval calls.
72430 */
72431
72432 if (env == NULL && act != NULL) {
72433 duk_hobject *func;
72434
72435 DUK_DDD(DUK_DDDPRINT("duk__get_identifier_reference: env is NULL, activation is non-NULL -> "
72436 "delayed env case, look up activation regs first"));
72437
72438 /*
72439 * Try registers
72440 */
72441
72442 if (duk__getid_activation_regs(thr, name, act, out)) {
72443 DUK_DDD(DUK_DDDPRINT("duk__get_identifier_reference successful: "
72444 "name=%!O -> value=%!T, attrs=%ld, this=%!T, env=%!O, holder=%!O "
72445 "(found from register bindings when env=NULL)",
72446 (duk_heaphdr *) name, (duk_tval *) out->value,
72447 (long) out->attrs, (duk_tval *) out->this_binding,
72448 (duk_heaphdr *) out->env, (duk_heaphdr *) out->holder));
72449 return 1;
72450 }
72451
72452 DUK_DDD(DUK_DDDPRINT("not found in current activation regs"));
72453
72454 /*
72455 * Not found in registers, proceed to the parent record.
72456 * Here we need to determine what the parent would be,
72457 * if 'env' was not NULL (i.e. same logic as when initializing
72458 * the record).
72459 *
72460 * Note that environment initialization is only deferred when
72461 * DUK_HOBJECT_HAS_NEWENV is set, and this only happens for:
72462 * - Function code
72463 * - Strict eval code
72464 *
72465 * We only need to check _Lexenv here; _Varenv exists only if it
72466 * differs from _Lexenv (and thus _Lexenv will also be present).
72467 */
72468
72469 if (!parents) {
72470 DUK_DDD(DUK_DDDPRINT("duk__get_identifier_reference failed, no parent traversal "
72471 "(not found from register bindings when env=NULL)"));
72472 goto fail_not_found;
72473 }
72474
72475 func = DUK_ACT_GET_FUNC(act);
72476 DUK_ASSERT(func != NULL);
72478
72480 if (tv) {
72482 env = DUK_TVAL_GET_OBJECT(tv);
72483 } else {
72485 env = thr->builtins[DUK_BIDX_GLOBAL_ENV];
72486 }
72487
72488 DUK_DDD(DUK_DDDPRINT("continue lookup from env: %!iO",
72489 (duk_heaphdr *) env));
72490 }
72491
72492 /*
72493 * Prototype walking starting from 'env'.
72494 *
72495 * ('act' is not needed anywhere here.)
72496 */
72497
72499 while (env != NULL) {
72500 duk_small_int_t cl;
72501 duk_int_t attrs;
72502
72503 DUK_DDD(DUK_DDDPRINT("duk__get_identifier_reference, name=%!O, considering env=%p -> %!iO",
72504 (duk_heaphdr *) name,
72505 (void *) env,
72506 (duk_heaphdr *) env));
72507
72508 DUK_ASSERT(env != NULL);
72511
72514 if (cl == DUK_HOBJECT_CLASS_DECENV) {
72515 /*
72516 * Declarative environment record.
72517 *
72518 * Identifiers can never be stored in ancestors and are
72519 * always plain values, so we can use an internal helper
72520 * and access the value directly with an duk_tval ptr.
72521 *
72522 * A closed environment is only indicated by it missing
72523 * the "book-keeping" properties required for accessing
72524 * register-bound variables.
72525 */
72526
72528 /* already closed */
72529 goto skip_regs;
72530 }
72531
72532 if (duk__getid_open_decl_env_regs(thr, name, env, out)) {
72533 DUK_DDD(DUK_DDDPRINT("duk__get_identifier_reference successful: "
72534 "name=%!O -> value=%!T, attrs=%ld, this=%!T, env=%!O, holder=%!O "
72535 "(declarative environment record, scope open, found in regs)",
72536 (duk_heaphdr *) name, (duk_tval *) out->value,
72537 (long) out->attrs, (duk_tval *) out->this_binding,
72538 (duk_heaphdr *) out->env, (duk_heaphdr *) out->holder));
72539 return 1;
72540 }
72541 skip_regs:
72542
72544 if (tv) {
72545 out->value = tv;
72546 out->attrs = attrs;
72547 out->this_binding = NULL; /* implicit this value always undefined for
72548 * declarative environment records.
72549 */
72550 out->env = env;
72551 out->holder = env;
72552
72553 DUK_DDD(DUK_DDDPRINT("duk__get_identifier_reference successful: "
72554 "name=%!O -> value=%!T, attrs=%ld, this=%!T, env=%!O, holder=%!O "
72555 "(declarative environment record, found in properties)",
72556 (duk_heaphdr *) name, (duk_tval *) out->value,
72557 (long) out->attrs, (duk_tval *) out->this_binding,
72558 (duk_heaphdr *) out->env, (duk_heaphdr *) out->holder));
72559 return 1;
72560 }
72561 } else {
72562 /*
72563 * Object environment record.
72564 *
72565 * Binding (target) object is an external, uncontrolled object.
72566 * Identifier may be bound in an ancestor property, and may be
72567 * an accessor. Target can also be a Proxy which we must support
72568 * here.
72569 */
72570
72571 /* XXX: we could save space by using _Target OR _This. If _Target, assume
72572 * this binding is undefined. If _This, assumes this binding is _This, and
72573 * target is also _This. One property would then be enough.
72574 */
72575
72576 duk_hobject *target;
72577 duk_bool_t found;
72578
72580
72582 DUK_ASSERT(tv_target != NULL);
72583 DUK_ASSERT(DUK_TVAL_IS_OBJECT(tv_target));
72584 target = DUK_TVAL_GET_OBJECT(tv_target);
72585 DUK_ASSERT(target != NULL);
72586
72587 /* Target may be a Proxy or property may be an accessor, so we must
72588 * use an actual, Proxy-aware hasprop check here.
72589 *
72590 * out->holder is NOT set to the actual duk_hobject where the
72591 * property is found, but rather the object binding target object.
72592 */
72593
72594 if (DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(target)) {
72595 DUK_ASSERT(name != NULL);
72596 DUK_TVAL_SET_STRING(&tv_name, name);
72597
72598 found = duk_hobject_hasprop(thr, tv_target, &tv_name);
72599 } else {
72600 /* XXX: duk_hobject_hasprop() would be correct for
72601 * non-Proxy objects too, but it is about ~20-25%
72602 * slower at present so separate code paths for
72603 * Proxy and non-Proxy now.
72604 */
72605 found = duk_hobject_hasprop_raw(thr, target, name);
72606 }
72607
72608 if (found) {
72609 out->value = NULL; /* can't get value, may be accessor */
72610 out->attrs = 0; /* irrelevant when out->value == NULL */
72612 out->this_binding = tv; /* may be NULL */
72613 out->env = env;
72614 out->holder = target;
72615
72616 DUK_DDD(DUK_DDDPRINT("duk__get_identifier_reference successful: "
72617 "name=%!O -> value=%!T, attrs=%ld, this=%!T, env=%!O, holder=%!O "
72618 "(object environment record)",
72619 (duk_heaphdr *) name, (duk_tval *) out->value,
72620 (long) out->attrs, (duk_tval *) out->this_binding,
72621 (duk_heaphdr *) out->env, (duk_heaphdr *) out->holder));
72622 return 1;
72623 }
72624 }
72625
72626 if (!parents) {
72627 DUK_DDD(DUK_DDDPRINT("duk__get_identifier_reference failed, no parent traversal "
DUK_LOCAL duk_bool_t duk__getid_activation_regs(duk_hthread *thr, duk_hstring *name, duk_activation *act, duk__id_lookup_result *out)
#define DUK_HTHREAD_STRING_INT_VARENV(thr)
#define DUK_HTHREAD_STRING_INT_LEXENV(thr)
#define DUK_HOBJECT_IS_ENV(h)
#define DUK_HOBJECT_HAS_ARRAY_PART(h)
#define DUK_HOBJECT_CLASS_OBJENV
DUK_INTERNAL_DECL duk_tval * duk_hobject_find_existing_entry_tval_ptr_and_attrs(duk_heap *heap, duk_hobject *obj, duk_hstring *key, duk_int_t *out_attrs)
#define DUK_HTHREAD_STRING_INT_THIS(thr)
#define DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY
#define DUK_HOBJECT_CLASS_DECENV
#define DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(h)
DUK_LOCAL duk_bool_t duk__getid_open_decl_env_regs(duk_hthread *thr, duk_hstring *name, duk_hobject *env, duk__id_lookup_result *out)
#define DUK_ACT_GET_FUNC(act)
DUK_INTERNAL_DECL duk_bool_t duk_hobject_hasprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key)
#define DUK_HOBJECT_HAS_ENVRECCLOSED(h)
#define DUK_TVAL_SET_STRING(tv, hptr)

Referenced by duk__declvar_helper(), duk__delvar_helper(), duk__getvar_helper(), and duk__putvar_helper().

◆ duk__get_idx_func()

DUK_LOCAL duk_idx_t duk__get_idx_func ( duk_hthread * thr,
duk_idx_t num_stack_args )

Definition at line 55906 of file duktape-1.8.0/src/duktape.c.

55910 {
55911 /* XXX: inefficient; block insert primitive */
55912 duk_push_undefined(ctx);
55913 duk_insert(ctx, idx_rcbase);
55914 }
55915 }
55916}
55917
55918/*
55919 * Misc shared helpers.
55920 */
55921
55922/* Get valstack index for the func argument or throw if insane stack. */
55924 duk_size_t off_stack_top;
55925 duk_size_t off_stack_args;
55926 duk_size_t off_stack_all;
DUK_LOCAL duk_idx_t duk__get_idx_func(duk_hthread *thr, duk_idx_t num_stack_args)

Referenced by duk_handle_call_protected().

◆ duk__get_instr_ptr()

DUK_LOCAL_DECL duk_compiler_instr * duk__get_instr_ptr ( duk_compiler_ctx * comp_ctx,
duk_int_t pc )

Definition at line 58738 of file duktape-1.8.0/src/duktape.c.

◆ duk__get_min_grow_a()

DUK_LOCAL duk_uint32_t duk__get_min_grow_a ( duk_uint32_t a_size)

Definition at line 47626 of file duktape-1.8.0/src/duktape.c.

47632 {
47633 duk_uint32_t res;
47634

◆ duk__get_min_grow_e()

DUK_LOCAL duk_uint32_t duk__get_min_grow_e ( duk_uint32_t e_size)

Definition at line 47615 of file duktape-1.8.0/src/duktape.c.

47616 {
47617 duk_uint32_t res;
47618
47619 /* result: hash_prime(floor(1.2 * e_size)) */
47620 res = duk_util_get_hash_prime(e_size + e_size / DUK_HOBJECT_H_SIZE_DIVISOR);
47621
47622 /* if fails, e_size will be zero = not an issue, except performance-wise */
47623 DUK_ASSERT(res == 0 || res > e_size);
#define DUK_HOBJECT_H_SIZE_DIVISOR
DUK_INTERNAL_DECL duk_uint32_t duk_util_get_hash_prime(duk_uint32_t size)

References DUK_ASSERT, DUK_HOBJECT_H_SIZE_DIVISOR, and duk_util_get_hash_prime().

◆ duk__get_old_array_length()

DUK_LOCAL duk_uint32_t duk__get_old_array_length ( duk_hthread * thr,
duk_hobject * obj,
duk_propdesc * temp_desc )

Definition at line 50286 of file duktape-1.8.0/src/duktape.c.

50303 {
50304 duk_bool_t rc;
50305 duk_tval *tv;
50306 duk_uint32_t res;
50307
50309
50310 /* This function is only called for objects with array exotic behavior.
50311 * The [[DefineOwnProperty]] algorithm for arrays requires that
50312 * 'length' can never have a value outside the unsigned 32-bit range,
50313 * attempt to write such a value is a RangeError. Here we can thus
50314 * assert for this. When Duktape internals go around the official
50315 * property write interface (doesn't happen often) this assumption is
50316 * easy to accidentally break, so such code must be written carefully.
50317 * See test-bi-array-push-maxlen.js.
50318 */
50319
50320 rc = duk__get_own_propdesc_raw(thr, obj, DUK_HTHREAD_STRING_LENGTH(thr), DUK__NO_ARRAY_INDEX, temp_desc, 0 /*flags*/); /* don't push value */
50321 DUK_UNREF(rc);
50322 DUK_ASSERT(rc != 0); /* arrays MUST have a 'length' property */
50323 DUK_ASSERT(temp_desc->e_idx >= 0);
50324
50325 tv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, temp_desc->e_idx);
50326 DUK_ASSERT(DUK_TVAL_IS_NUMBER(tv)); /* array 'length' is always a number, as we coerce it */
50327 DUK_ASSERT(DUK_TVAL_GET_NUMBER(tv) >= 0.0);
50328 DUK_ASSERT(DUK_TVAL_GET_NUMBER(tv) <= (double) 0xffffffffUL);
#define DUK__NO_ARRAY_INDEX
DUK_LOCAL_DECL duk_bool_t duk__get_own_propdesc_raw(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_uint32_t arr_idx, duk_propdesc *out_desc, duk_small_uint_t flags)

Referenced by duk_hobject_define_property_helper(), and duk_hobject_putprop().

◆ duk__get_own_propdesc_raw()

DUK_LOCAL_DECL duk_bool_t duk__get_own_propdesc_raw ( duk_hthread * thr,
duk_hobject * obj,
duk_hstring * key,
duk_uint32_t arr_idx,
duk_propdesc * out_desc,
duk_small_uint_t flags )

Definition at line 49009 of file duktape-1.8.0/src/duktape.c.

49026 {
49027 duk_context *ctx = (duk_context *) thr;
49028 duk_tval *tv;
49029
49030 DUK_DDD(DUK_DDDPRINT("duk_hobject_get_own_propdesc: thr=%p, obj=%p, key=%p, out_desc=%p, flags=%lx, "
49031 "arr_idx=%ld (obj -> %!O, key -> %!O)",
49032 (void *) thr, (void *) obj, (void *) key, (void *) out_desc,
49033 (long) flags, (long) arr_idx,
49034 (duk_heaphdr *) obj, (duk_heaphdr *) key));
49035
49036 DUK_ASSERT(ctx != NULL);
49037 DUK_ASSERT(thr != NULL);
49038 DUK_ASSERT(thr->heap != NULL);
49039 DUK_ASSERT(obj != NULL);
49040 DUK_ASSERT(key != NULL);
49041 DUK_ASSERT(out_desc != NULL);
49043
49044 /* XXX: optimize this filling behavior later */
49045 out_desc->flags = 0;
49046 out_desc->get = NULL;
49047 out_desc->set = NULL;
49048 out_desc->e_idx = -1;
49049 out_desc->h_idx = -1;
49050 out_desc->a_idx = -1;
49051
49052 /*
49053 * Array part
49054 */
49055
49056 if (DUK_HOBJECT_HAS_ARRAY_PART(obj) && arr_idx != DUK__NO_ARRAY_INDEX) {
49057 if (arr_idx < DUK_HOBJECT_GET_ASIZE(obj)) {
49058 tv = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, arr_idx);
49059 if (!DUK_TVAL_IS_UNUSED(tv)) {
49060 DUK_DDD(DUK_DDDPRINT("-> found in array part"));
49061 if (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {
49062 duk_push_tval(ctx, tv);
49063 }
49064 /* implicit attributes */
49065 out_desc->flags = DUK_PROPDESC_FLAG_WRITABLE |
49068 out_desc->a_idx = arr_idx;
49069 goto prop_found;
49070 }
49071 }
49072 /* assume array part is comprehensive (contains all array indexed elements
49073 * or none of them); hence no need to check the entries part here.
49074 */
49075 DUK_DDD(DUK_DDDPRINT("-> not found as a concrete property (has array part, "
49076 "should be there if present)"));
49077 goto prop_not_found_concrete;
49078 }
49079
49080 /*
49081 * Entries part
49082 */
49083
49084 duk_hobject_find_existing_entry(thr->heap, obj, key, &out_desc->e_idx, &out_desc->h_idx);
49085 if (out_desc->e_idx >= 0) {
49086 duk_int_t e_idx = out_desc->e_idx;
49087 out_desc->flags = DUK_HOBJECT_E_GET_FLAGS(thr->heap, obj, e_idx);
49088 if (out_desc->flags & DUK_PROPDESC_FLAG_ACCESSOR) {
49089 DUK_DDD(DUK_DDDPRINT("-> found accessor property in entry part"));
49090 out_desc->get = DUK_HOBJECT_E_GET_VALUE_GETTER(thr->heap, obj, e_idx);
49091 out_desc->set = DUK_HOBJECT_E_GET_VALUE_SETTER(thr->heap, obj, e_idx);
49092 if (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {
49093 /* a dummy undefined value is pushed to make valstack
49094 * behavior uniform for caller
49095 */
49096 duk_push_undefined(ctx);
49097 }
49098 } else {
49099 DUK_DDD(DUK_DDDPRINT("-> found plain property in entry part"));
49100 tv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, e_idx);
49101 if (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {
49102 duk_push_tval(ctx, tv);
49103 }
49104 }
49105 goto prop_found;
49106 }
49107
49108 /*
49109 * Not found as a concrete property, check whether a String object
49110 * virtual property matches.
49111 */
49112
49113 prop_not_found_concrete:
49114
49116 DUK_DDD(DUK_DDDPRINT("string object exotic property get for key: %!O, arr_idx: %ld",
49117 (duk_heaphdr *) key, (long) arr_idx));
49118
49119 if (arr_idx != DUK__NO_ARRAY_INDEX) {
49120 duk_hstring *h_val;
49121
49122 DUK_DDD(DUK_DDDPRINT("array index exists"));
49123
49124 h_val = duk_hobject_get_internal_value_string(thr->heap, obj);
49125 DUK_ASSERT(h_val);
49126 if (arr_idx < DUK_HSTRING_GET_CHARLEN(h_val)) {
49127 DUK_DDD(DUK_DDDPRINT("-> found, array index inside string"));
49128 if (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {
49129 duk_push_hstring(ctx, h_val);
49130 duk_substring(ctx, -1, arr_idx, arr_idx + 1); /* [str] -> [substr] */
49131 }
49132 out_desc->flags = DUK_PROPDESC_FLAG_ENUMERABLE | /* E5 Section 15.5.5.2 */
49134
49136 return 1; /* cannot be e.g. arguments exotic, since exotic 'traits' are mutually exclusive */
49137 } else {
49138 /* index is above internal string length -> property is fully normal */
49139 DUK_DDD(DUK_DDDPRINT("array index outside string -> normal property"));
49140 }
49141 } else if (key == DUK_HTHREAD_STRING_LENGTH(thr)) {
49142 duk_hstring *h_val;
49143
49144 DUK_DDD(DUK_DDDPRINT("-> found, key is 'length', length exotic behavior"));
49145
49146 h_val = duk_hobject_get_internal_value_string(thr->heap, obj);
49147 DUK_ASSERT(h_val != NULL);
49148 if (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {
49150 }
49151 out_desc->flags = DUK_PROPDESC_FLAG_VIRTUAL; /* E5 Section 15.5.5.1 */
49152
49154 return 1; /* cannot be arguments exotic */
49155 }
49156 } else if (DUK_HOBJECT_IS_BUFFEROBJECT(obj)) {
49157 duk_hbufferobject *h_bufobj;
49158 duk_uint_t byte_off;
49159 duk_small_uint_t elem_size;
49160
49161 h_bufobj = (duk_hbufferobject *) obj;
49163 DUK_DDD(DUK_DDDPRINT("bufferobject property get for key: %!O, arr_idx: %ld",
49164 (duk_heaphdr *) key, (long) arr_idx));
49165
49166 if (arr_idx != DUK__NO_ARRAY_INDEX) {
49167 DUK_DDD(DUK_DDDPRINT("array index exists"));
49168
49169 /* Careful with wrapping: arr_idx upshift may easily wrap, whereas
49170 * length downshift won't.
49171 */
49172 if (arr_idx < (h_bufobj->length >> h_bufobj->shift)) {
49173 byte_off = arr_idx << h_bufobj->shift; /* no wrap assuming h_bufobj->length is valid */
49174 elem_size = 1 << h_bufobj->shift;
49175 if (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {
49176 duk_uint8_t *data;
49177
49178 if (h_bufobj->buf != NULL && DUK_HBUFFEROBJECT_VALID_BYTEOFFSET_EXCL(h_bufobj, byte_off + elem_size)) {
49179 data = (duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_bufobj->buf) + h_bufobj->offset + byte_off;
49180 duk_hbufferobject_push_validated_read(ctx, h_bufobj, data, elem_size);
49181 } else {
49182 DUK_D(DUK_DPRINT("bufferobject access out of underlying buffer, ignoring (read zero)"));
49183 duk_push_uint(ctx, 0);
49184 }
49185 }
49186 out_desc->flags = DUK_PROPDESC_FLAG_WRITABLE |
49189
49191 return 1; /* cannot be e.g. arguments exotic, since exotic 'traits' are mutually exclusive */
49192 } else {
49193 /* index is above internal buffer length -> property is fully normal */
49194 DUK_DDD(DUK_DDDPRINT("array index outside buffer -> normal property"));
49195 }
49196 } else if (key == DUK_HTHREAD_STRING_LENGTH(thr)) {
49197 DUK_DDD(DUK_DDDPRINT("-> found, key is 'length', length exotic behavior"));
49198
49199 if (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {
49200 /* Length in elements: take into account shift, but
49201 * intentionally don't check the underlying buffer here.
49202 */
49203 duk_push_uint(ctx, h_bufobj->length >> h_bufobj->shift);
49204 }
49205 out_desc->flags = DUK_PROPDESC_FLAG_VIRTUAL;
49206
49208 return 1; /* cannot be arguments exotic */
49209 } else if (key == DUK_HTHREAD_STRING_BYTE_LENGTH(thr)) {
49210 /* If neutered must return 0; length is zeroed during
49211 * neutering.
49212 */
49213 if (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {
49214 duk_push_uint(ctx, h_bufobj->length);
49215 }
49216 out_desc->flags = DUK_PROPDESC_FLAG_VIRTUAL;
49217 return 1; /* cannot be arguments exotic */
49218 } else if (key == DUK_HTHREAD_STRING_BYTE_OFFSET(thr)) {
49219 /* If neutered must return 0; offset is zeroed during
49220 * neutering.
49221 */
49222 if (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {
49223 duk_push_uint(ctx, h_bufobj->offset);
49224 }
49225 out_desc->flags = DUK_PROPDESC_FLAG_VIRTUAL;
49226 return 1; /* cannot be arguments exotic */
49227 } else if (key == DUK_HTHREAD_STRING_BYTES_PER_ELEMENT(thr)) {
49228 if (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {
49229 duk_push_uint(ctx, 1 << h_bufobj->shift);
49230 }
49231 out_desc->flags = DUK_PROPDESC_FLAG_VIRTUAL;
49232 return 1; /* cannot be arguments exotic */
49233 }
49234 } else if (DUK_HOBJECT_HAS_EXOTIC_DUKFUNC(obj)) {
49235 DUK_DDD(DUK_DDDPRINT("duktape/c object exotic property get for key: %!O, arr_idx: %ld",
49236 (duk_heaphdr *) key, (long) arr_idx));
49237
49238 if (key == DUK_HTHREAD_STRING_LENGTH(thr)) {
49239 DUK_DDD(DUK_DDDPRINT("-> found, key is 'length', length exotic behavior"));
49240
49241 if (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {
49242 duk_int16_t func_nargs = ((duk_hnativefunction *) obj)->nargs;
49243 duk_push_int(ctx, func_nargs == DUK_HNATIVEFUNCTION_NARGS_VARARGS ? 0 : func_nargs);
49244 }
49245 out_desc->flags = DUK_PROPDESC_FLAG_VIRTUAL; /* not enumerable */
49246
49248 return 1; /* cannot be arguments exotic */
49249 }
49250 }
49251
49252 /* Array properties have exotic behavior but they are concrete,
49253 * so no special handling here.
49254 *
49255 * Arguments exotic behavior (E5 Section 10.6, [[GetOwnProperty]]
49256 * is only relevant as a post-check implemented below; hence no
49257 * check here.
49258 */
49259
49260 /*
49261 * Not found as concrete or virtual
49262 */
49263
49264 DUK_DDD(DUK_DDDPRINT("-> not found (virtual, entry part, or array part)"));
49265 return 0;
49266
49267 /*
49268 * Found
49269 *
49270 * Arguments object has exotic post-processing, see E5 Section 10.6,
49271 * description of [[GetOwnProperty]] variant for arguments.
49272 */
49273
49274 prop_found:
49275 DUK_DDD(DUK_DDDPRINT("-> property found, checking for arguments exotic post-behavior"));
49276
49277 /* Notes:
49278 * - only numbered indices are relevant, so arr_idx fast reject is good
49279 * (this is valid unless there are more than 4**32-1 arguments).
49280 * - since variable lookup has no side effects, this can be skipped if
49281 * DUK_GETDESC_FLAG_PUSH_VALUE is not set.
49282 */
49283
49285 arr_idx != DUK__NO_ARRAY_INDEX &&
49286 (flags & DUK_GETDESC_FLAG_PUSH_VALUE)) {
49287 duk_propdesc temp_desc;
49288
49289 /* Magically bound variable cannot be an accessor. However,
49290 * there may be an accessor property (or a plain property) in
49291 * place with magic behavior removed. This happens e.g. when
49292 * a magic property is redefined with defineProperty().
#define DUK_HTHREAD_STRING_BYTES_PER_ELEMENT(thr)
#define DUK_HOBJECT_HAS_EXOTIC_DUKFUNC(h)
#define DUK_HBUFFEROBJECT_VALID_BYTEOFFSET_EXCL(h, off)
#define DUK_HOBJECT_HAS_EXOTIC_STRINGOBJ(h)
#define DUK_HTHREAD_STRING_BYTE_LENGTH(thr)
#define DUK_PROPDESC_FLAG_VIRTUAL
#define DUK_HSTRING_GET_CHARLEN(x)
#define DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(h)
DUK_INTERNAL_DECL duk_hstring * duk_hobject_get_internal_value_string(duk_heap *heap, duk_hobject *obj)
#define DUK_HNATIVEFUNCTION_NARGS_VARARGS
#define DUK_HTHREAD_STRING_BYTE_OFFSET(thr)
DUK_EXTERNAL void duk_substring(duk_context *ctx, duk_idx_t index, duk_size_t start_offset, duk_size_t end_offset)
DUK_INTERNAL_DECL void duk_hbufferobject_push_validated_read(duk_context *ctx, duk_hbufferobject *h_bufobj, duk_uint8_t *p, duk_small_uint_t elem_size)

References duk_propdesc::a_idx, duk_hbufferobject::buf, DUK__NO_ARRAY_INDEX, DUK__VALSTACK_SPACE, DUK_ASSERT, DUK_ASSERT_HBUFFEROBJECT_VALID, DUK_ASSERT_VALSTACK_SPACE, DUK_D, DUK_DDD, DUK_DDDPRINT, DUK_DPRINT, DUK_GETDESC_FLAG_PUSH_VALUE, DUK_HBUFFER_GET_DATA_PTR, duk_hbufferobject_push_validated_read(), DUK_HBUFFEROBJECT_VALID_BYTEOFFSET_EXCL, DUK_HNATIVEFUNCTION_NARGS_VARARGS, DUK_HOBJECT_A_GET_VALUE_PTR, DUK_HOBJECT_E_GET_FLAGS, DUK_HOBJECT_E_GET_VALUE_GETTER, DUK_HOBJECT_E_GET_VALUE_SETTER, DUK_HOBJECT_E_GET_VALUE_TVAL_PTR, duk_hobject_find_existing_entry(), DUK_HOBJECT_GET_ASIZE, duk_hobject_get_internal_value_string(), DUK_HOBJECT_HAS_ARRAY_PART, DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS, DUK_HOBJECT_HAS_EXOTIC_DUKFUNC, DUK_HOBJECT_HAS_EXOTIC_STRINGOBJ, DUK_HOBJECT_IS_BUFFEROBJECT, DUK_HSTRING_GET_CHARLEN, DUK_HTHREAD_STRING_BYTE_LENGTH, DUK_HTHREAD_STRING_BYTE_OFFSET, DUK_HTHREAD_STRING_BYTES_PER_ELEMENT, DUK_HTHREAD_STRING_LENGTH, DUK_PROPDESC_FLAG_ACCESSOR, DUK_PROPDESC_FLAG_CONFIGURABLE, DUK_PROPDESC_FLAG_ENUMERABLE, DUK_PROPDESC_FLAG_VIRTUAL, DUK_PROPDESC_FLAG_WRITABLE, duk_push_hstring(), duk_push_int(), duk_push_tval(), duk_push_uint(), duk_push_undefined(), duk_substring(), DUK_TVAL_IS_UNUSED, duk_propdesc::e_idx, duk_propdesc::flags, duk_propdesc::get, duk_propdesc::h_idx, duk_hthread::heap, duk_hbufferobject::length, NULL, duk_hbufferobject::offset, duk_propdesc::set, and duk_hbufferobject::shift.

Referenced by duk__get_propdesc(), duk_hobject_define_property_helper(), duk_hobject_define_property_internal(), and duk_hobject_putprop().

◆ duk__get_part_helper()

DUK_LOCAL duk_ret_t duk__get_part_helper ( duk_context * ctx,
duk_small_uint_t flags_and_idx )

Definition at line 25682 of file duktape-1.8.0/src/duktape.c.

25699 {
25700 duk_double_t d;
25702 duk_small_uint_t idx_part = (duk_small_uint_t) (flags_and_idx >> DUK_DATE_FLAG_VALUE_SHIFT); /* unpack args */
25703
25704 DUK_ASSERT_DISABLE(idx_part >= 0); /* unsigned */
#define DUK_DATE_IDX_NUM_PARTS
#define DUK_DATE_FLAG_VALUE_SHIFT

Referenced by duk_bi_date_prototype_get_timezone_offset().

◆ duk__get_propdesc()

DUK_LOCAL_DECL duk_bool_t duk__get_propdesc ( duk_hthread * thr,
duk_hobject * obj,
duk_hstring * key,
duk_propdesc * out_desc,
duk_small_uint_t flags )

Definition at line 49323 of file duktape-1.8.0/src/duktape.c.

49324 :
49325 * - Fills descriptor fields to 'out_desc'
49326 * - If DUK_GETDESC_FLAG_PUSH_VALUE is set, pushes a value related to the
49327 * property onto the stack ('undefined' for accessor properties).
49328 * - Returns non-zero
49329 *
49330 * If property is not found:
49331 * - 'out_desc' is left in untouched state (possibly garbage)
49332 * - Nothing is pushed onto the stack (not even with DUK_GETDESC_FLAG_PUSH_VALUE
49333 * set)
49334 * - Returns zero
49335 *
49336 * May cause arbitrary side effects and invalidate (most) duk_tval
49337 * pointers.
49338 */
49339
49341 duk_hobject *curr;
49342 duk_uint32_t arr_idx;
49343 duk_uint_t sanity;
49344
49345 DUK_ASSERT(thr != NULL);
49346 DUK_ASSERT(thr->heap != NULL);
49347 DUK_ASSERT(obj != NULL);
49348 DUK_ASSERT(key != NULL);
49349 DUK_ASSERT(out_desc != NULL);
49351
49352 arr_idx = DUK_HSTRING_GET_ARRIDX_FAST(key);
49353
49354 DUK_DDD(DUK_DDDPRINT("duk__get_propdesc: thr=%p, obj=%p, key=%p, out_desc=%p, flags=%lx, "
49355 "arr_idx=%ld (obj -> %!O, key -> %!O)",
49356 (void *) thr, (void *) obj, (void *) key, (void *) out_desc,
49357 (long) flags, (long) arr_idx,
49358 (duk_heaphdr *) obj, (duk_heaphdr *) key));
49359
49360 curr = obj;
49361 DUK_ASSERT(curr != NULL);
49363 do {
49364 if (duk__get_own_propdesc_raw(thr, curr, key, arr_idx, out_desc, flags)) {
49365 /* stack contains value (if requested), 'out_desc' is set */
49366 return 1;
49367 }
49368
49369 /* not found in 'curr', next in prototype chain; impose max depth */
#define DUK_HSTRING_GET_ARRIDX_FAST(h)
DUK_LOCAL_DECL duk_bool_t duk__get_propdesc(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *out_desc, duk_small_uint_t flags)

References duk__get_own_propdesc_raw(), DUK__VALSTACK_SPACE, DUK_ASSERT, DUK_ASSERT_VALSTACK_SPACE, DUK_DDD, DUK_DDDPRINT, DUK_ERROR_RANGE, DUK_GETDESC_FLAG_IGNORE_PROTOLOOP, DUK_HOBJECT_GET_PROTOTYPE, DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY, DUK_HSTRING_GET_ARRIDX_FAST, DUK_STR_PROTOTYPE_CHAIN_LIMIT, duk_hthread::heap, and NULL.

◆ duk__get_tagged_heaphdr_raw()

DUK_LOCAL_DECL duk_heaphdr * duk__get_tagged_heaphdr_raw ( duk_context * ctx,
duk_idx_t index,
duk_uint_t tag )

Definition at line 16407 of file duktape-1.8.0/src/duktape.c.

16411 {
16412 return duk__get_buffer_data_helper(ctx, index, out_size, 0 /*throw_flag*/);
16413}
16414
16416 return duk__get_buffer_data_helper(ctx, index, out_size, 1 /*throw_flag*/);
16417}
16418
16419/* Raw helper for getting a value from the stack, checking its tag.
16420 * The tag cannot be a number because numbers don't have an internal
16421 * tag in the packed representation.
DUK_EXTERNAL void * duk_require_buffer_data(duk_context *ctx, duk_idx_t index, duk_size_t *out_size)

Referenced by duk_get_c_function(), duk_get_hcompiledfunction(), duk_get_hnativefunction(), duk_require_hbuffer(), duk_require_hcompiledfunction(), duk_require_hnativefunction(), duk_require_hobject(), and duk_require_hthread().

◆ duk__get_temp_hthread()

DUK_LOCAL duk_hthread * duk__get_temp_hthread ( duk_heap * heap)

Definition at line 42195 of file duktape-1.8.0/src/duktape.c.

◆ duk__get_this_regexp()

DUK_LOCAL void duk__get_this_regexp ( duk_context * ctx)

Definition at line 33855 of file duktape-1.8.0/src/duktape.c.

33858 {
33859 DUK_UNREF(ctx);
33861}
33862#endif /* DUK_USE_ES6_PROXY */
33863#line 1 "duk_bi_regexp.c"

◆ duk__getconst()

DUK_LOCAL_DECL duk_regconst_t duk__getconst ( duk_compiler_ctx * comp_ctx)

Definition at line 59601 of file duktape-1.8.0/src/duktape.c.

59606 {
59607 return duk__alloctemps(comp_ctx, 1);
59608}
59609
59610DUK_LOCAL void duk__settemp_checkmax(duk_compiler_ctx *comp_ctx, duk_reg_t temp_next) {
59611 comp_ctx->curr_func.temp_next = temp_next;
59612 if (temp_next > comp_ctx->curr_func.temp_max) {
59613 comp_ctx->curr_func.temp_max = temp_next;
59614 }
59615}
59616
59617/* get const for value at valstack top */
59619 duk_hthread *thr = comp_ctx->thr;
59620 duk_context *ctx = (duk_context *) thr;
59621 duk_compiler_func *f = &comp_ctx->curr_func;
59622 duk_tval *tv1;
59623 duk_int_t i, n, n_check;
59624
59625 n = (duk_int_t) duk_get_length(ctx, f->consts_idx);
59626
59627 tv1 = DUK_GET_TVAL_NEGIDX(ctx, -1);
59628 DUK_ASSERT(tv1 != NULL);
59629
59630#if defined(DUK_USE_FASTINT)
59631 /* Explicit check for fastint downgrade. */
59633#endif
59634
59635 /* Sanity workaround for handling functions with a large number of
59636 * constants at least somewhat reasonably. Otherwise checking whether
59637 * we already have the constant would grow very slow (as it is O(N^2)).
59638 */
59640 for (i = 0; i < n_check; i++) {
59642
59643 /* Strict equality is NOT enough, because we cannot use the same
59644 * constant for e.g. +0 and -0.
59645 */
#define DUK__GETCONST_MAX_CONSTS_CHECK
DUK_LOCAL_DECL void duk__settemp_checkmax(duk_compiler_ctx *comp_ctx, duk_reg_t temp_next)
#define DUK_TVAL_CHKFAST_INPLACE(v)
DUK_LOCAL_DECL duk_reg_t duk__alloctemps(duk_compiler_ctx *comp_ctx, duk_small_int_t num)

Referenced by duk__init_varmap_and_prologue_for_pass2(), and duk__ispec_toregconst_raw().

◆ duk__getid_activation_regs()

DUK_LOCAL duk_bool_t duk__getid_activation_regs ( duk_hthread * thr,
duk_hstring * name,
duk_activation * act,
duk__id_lookup_result * out )

Definition at line 72324 of file duktape-1.8.0/src/duktape.c.

72344 {
72345 duk_tval *tv;
72346 duk_hobject *func;
72347 duk_hobject *varmap;
72348 duk_size_t reg_rel;
72349 duk_size_t idx;
72350
72351 DUK_ASSERT(thr != NULL);
72352 DUK_ASSERT(name != NULL);
72353 DUK_ASSERT(act != NULL);
72354 DUK_ASSERT(out != NULL);
72355
72356 func = DUK_ACT_GET_FUNC(act);
72357 DUK_ASSERT(func != NULL);
72359
72361 return 0;
72362 }
72363
72365 if (!tv) {
72366 return 0;
72367 }
72369 varmap = DUK_TVAL_GET_OBJECT(tv);
72370 DUK_ASSERT(varmap != NULL);
72371
72373 if (!tv) {
72374 return 0;
72375 }
72377 reg_rel = (duk_size_t) DUK_TVAL_GET_NUMBER(tv);

◆ duk__getid_open_decl_env_regs()

DUK_LOCAL duk_bool_t duk__getid_open_decl_env_regs ( duk_hthread * thr,
duk_hstring * name,
duk_hobject * env,
duk__id_lookup_result * out )

Definition at line 72239 of file duktape-1.8.0/src/duktape.c.

72259 {
72260 duk_hthread *env_thr;
72261 duk_hobject *env_func;
72262 duk_size_t env_regbase;
72263 duk_hobject *varmap;
72264 duk_tval *tv;
72265 duk_size_t reg_rel;
72266 duk_size_t idx;
72267
72268 DUK_ASSERT(thr != NULL);
72269 DUK_ASSERT(name != NULL);
72270 DUK_ASSERT(env != NULL);
72271 DUK_ASSERT(out != NULL);
72272
72274
72276 if (!tv) {
72277 /* env is closed, should be missing _Callee, _Thread, _Regbase */
72281 return 0;
72282 }
72283
72287 env_func = DUK_TVAL_GET_OBJECT(tv);
72288 DUK_ASSERT(env_func != NULL);
72289
72291 if (!tv) {
72292 return 0;
72293 }
72295 varmap = DUK_TVAL_GET_OBJECT(tv);
72296 DUK_ASSERT(varmap != NULL);
72297
72299 if (!tv) {
72300 return 0;
72301 }
72303 reg_rel = (duk_size_t) DUK_TVAL_GET_NUMBER(tv);
72304 DUK_ASSERT_DISABLE(reg_rel >= 0); /* unsigned */
72305 DUK_ASSERT(reg_rel < ((duk_hcompiledfunction *) env_func)->nregs);
72306
72308 DUK_ASSERT(tv != NULL);
72312 env_thr = (duk_hthread *) DUK_TVAL_GET_OBJECT(tv);
72313 DUK_ASSERT(env_thr != NULL);
72314
72315 /* Note: env_thr != thr is quite possible and normal, so careful
72316 * with what thread is used for valstack lookup.
72317 */
72318
72320 DUK_ASSERT(tv != NULL);
#define DUK_HTHREAD_STRING_INT_REGBASE(thr)
#define DUK_HTHREAD_STRING_INT_THREAD(thr)
#define DUK_HTHREAD_STRING_INT_CALLEE(thr)

References DUK_ASSERT, DUK_ASSERT_DISABLE, duk_hobject_find_existing_entry_tval_ptr(), DUK_HOBJECT_IS_COMPILEDFUNCTION, DUK_HOBJECT_IS_DECENV, DUK_HOBJECT_IS_THREAD, DUK_HTHREAD_STRING_INT_CALLEE, DUK_HTHREAD_STRING_INT_REGBASE, DUK_HTHREAD_STRING_INT_THREAD, DUK_HTHREAD_STRING_INT_VARMAP, DUK_TVAL_GET_NUMBER, DUK_TVAL_GET_OBJECT, DUK_TVAL_IS_NUMBER, DUK_TVAL_IS_OBJECT, duk_hthread::heap, name, and NULL.

◆ duk__getprop_fastpath_bufobj_tval()

DUK_LOCAL duk_bool_t duk__getprop_fastpath_bufobj_tval ( duk_hthread * thr,
duk_hobject * obj,
duk_tval * tv_key )

Definition at line 49519 of file duktape-1.8.0/src/duktape.c.

49521 {
49522 ;
49523 }
49524
49525 tv = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, idx);
49526 DUK_TVAL_SET_TVAL_UPDREF(thr, tv, tv_val); /* side effects */
49527
49528 DUK_DDD(DUK_DDDPRINT("array fast path success for index %ld", (long) idx));
49529 return 1;
49530}
49531
49532/*
49533 * Fast path for bufferobject getprop/putprop
49534 */
49535
49537 duk_context *ctx;
49538 duk_uint32_t idx;
49539 duk_hbufferobject *h_bufobj;
49540 duk_uint_t byte_off;
49541 duk_small_uint_t elem_size;
49542 duk_uint8_t *data;
49543
49544 ctx = (duk_context *) thr;
49545
49546 if (!DUK_HOBJECT_IS_BUFFEROBJECT(obj)) {
49547 return 0;
49548 }
49549 h_bufobj = (duk_hbufferobject *) obj;
49550
49551#if defined(DUK_USE_FASTINT)
49552 if (DUK_TVAL_IS_FASTINT(tv_key)) {
49553 idx = duk__tval_fastint_to_arr_idx(tv_key);
49554 } else
49555#endif
49556 if (DUK_TVAL_IS_DOUBLE(tv_key)) {
49557 idx = duk__tval_number_to_arr_idx(tv_key);
49558 } else {
49559 return 0;
49560 }
49561
49562 /* If index is not valid, idx will be DUK__NO_ARRAY_INDEX which
49563 * is 0xffffffffUL. We don't need to check for that explicitly
49564 * because 0xffffffffUL will never be inside bufferobject length.
49565 */
49566
49567 /* Careful with wrapping (left shifting idx would be unsafe). */
49568 if (idx >= (h_bufobj->length >> h_bufobj->shift)) {
DUK_LOCAL duk_bool_t duk__getprop_fastpath_bufobj_tval(duk_hthread *thr, duk_hobject *obj, duk_tval *tv_key)
#define DUK_TVAL_SET_TVAL_UPDREF
DUK_LOCAL duk_uint32_t duk__tval_number_to_arr_idx(duk_tval *tv)

◆ duk__getprop_shallow_fastpath_array_tval()

DUK_LOCAL duk_tval * duk__getprop_shallow_fastpath_array_tval ( duk_hthread * thr,
duk_hobject * obj,
duk_tval * tv_key )

Definition at line 49391 of file duktape-1.8.0/src/duktape.c.

49394 :
49395 * - Object has array part, index is within array allocation, and
49396 * value is not unused (= key exists)
49397 * - Object has no interfering exotic behavior (e.g. arguments or
49398 * string object exotic behaviors interfere, array exotic
49399 * behavior does not).
49400 *
49401 * Current shortcoming: if key does not exist (even if it is within
49402 * the array allocation range) a slow path lookup with interning is
49403 * always required. This can probably be fixed so that there is a
49404 * quick fast path for non-existent elements as well, at least for
49405 * standard Array objects.
49406 */
49407
49409 duk_tval *tv;
49410 duk_uint32_t idx;
49411
49412 DUK_UNREF(thr);
49413
49414 if (!(DUK_HOBJECT_HAS_ARRAY_PART(obj) &&
49419 /* Must have array part and no conflicting exotic behaviors.
49420 * Doesn't need to have array special behavior, e.g. Arguments
49421 * object has array part.
49422 */
49423 return NULL;
49424 }
49425
49426 /* Arrays never have other exotic behaviors. */
49427
49428 DUK_DDD(DUK_DDDPRINT("fast path attempt (no exotic string/arguments/buffer "
49429 "behavior, object has array part)"));
49430
49431#if defined(DUK_USE_FASTINT)
49432 if (DUK_TVAL_IS_FASTINT(tv_key)) {
49433 idx = duk__tval_fastint_to_arr_idx(tv_key);
49434 } else
49435#endif
49436 if (DUK_TVAL_IS_DOUBLE(tv_key)) {
49437 idx = duk__tval_number_to_arr_idx(tv_key);
49438 } else {
49439 DUK_DDD(DUK_DDDPRINT("key is not a number"));
49440 return NULL;
49441 }
49442
49443 /* If index is not valid, idx will be DUK__NO_ARRAY_INDEX which
49444 * is 0xffffffffUL. We don't need to check for that explicitly
49445 * because 0xffffffffUL will never be inside object 'a_size'.
49446 */
49447
49448 if (idx >= DUK_HOBJECT_GET_ASIZE(obj)) {
49449 DUK_DDD(DUK_DDDPRINT("key is not an array index or outside array part"));
49450 return NULL;
49451 }
union @139 unused
DUK_LOCAL duk_tval * duk__getprop_shallow_fastpath_array_tval(duk_hthread *thr, duk_hobject *obj, duk_tval *tv_key)

References duk__tval_number_to_arr_idx(), DUK_ASSERT, DUK_DDD, DUK_DDDPRINT, DUK_HOBJECT_GET_ASIZE, DUK_HOBJECT_HAS_ARRAY_PART, DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS, DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ, DUK_HOBJECT_HAS_EXOTIC_STRINGOBJ, DUK_HOBJECT_IS_BUFFEROBJECT, DUK_TVAL_IS_DOUBLE, DUK_UNREF, and NULL.

◆ duk__getrequire_bufobj_this()

DUK_LOCAL duk_hbufferobject * duk__getrequire_bufobj_this ( duk_context * ctx,
duk_bool_t throw_flag )

Definition at line 21835 of file duktape-1.8.0/src/duktape.c.

21852 {
21853 duk_hthread *thr;
21854 duk_tval *tv;
21855 duk_hbufferobject *h_this;
21856
21857 DUK_ASSERT(ctx != NULL);
21858 thr = (duk_hthread *) ctx;

Referenced by duk__require_bufobj_value().

◆ duk__getvar_helper()

DUK_LOCAL duk_bool_t duk__getvar_helper ( duk_hthread * thr,
duk_hobject * env,
duk_activation * act,
duk_hstring * name,
duk_bool_t throw_flag )

Definition at line 72700 of file duktape-1.8.0/src/duktape.c.

72702 : [val this].
72703 *
72704 * If 'throw' is false, returns 0 if identifier cannot be resolved, and the
72705 * stack will be unaffected in this case. If identifier is resolved, returns
72706 * 1 and leaves [val this] on top of stack.
72707 *
72708 * Note: the 'strict' flag of a reference returned by GetIdentifierReference
72709 * is ignored by GetValue. Hence we don't take a 'strict' parameter.
72710 *
72711 * The 'throw' flag is needed for implementing 'typeof' for an unreferenced
72712 * identifier. An unreference identifier in other contexts generates a
72713 * ReferenceError.
72714 */
72715
72716DUK_LOCAL
72717duk_bool_t duk__getvar_helper(duk_hthread *thr,
72718 duk_hobject *env,
72719 duk_activation *act,
72720 duk_hstring *name,
72721 duk_bool_t throw_flag) {
72722 duk_context *ctx = (duk_context *) thr;
72723 duk__id_lookup_result ref;
72724 duk_tval tv_tmp_obj;
72725 duk_tval tv_tmp_key;
72726 duk_bool_t parents;
72727
72728 DUK_DDD(DUK_DDDPRINT("getvar: thr=%p, env=%p, act=%p, name=%!O "
72729 "(env -> %!dO)",
72730 (void *) thr, (void *) env, (void *) act,
72731 (duk_heaphdr *) name, (duk_heaphdr *) env));
72732
72733 DUK_ASSERT(thr != NULL);
72734 DUK_ASSERT(name != NULL);
72735 /* env and act may be NULL */
72736
72737 DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR(env);
72738 DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR(name);
72739
72740 parents = 1; /* follow parent chain */
72741 if (duk__get_identifier_reference(thr, env, name, act, parents, &ref)) {
72742 if (ref.value) {
72743 DUK_ASSERT(ref.this_binding == NULL); /* always for register bindings */
72744 duk_push_tval(ctx, ref.value);
72745 duk_push_undefined(ctx);
72746 } else {
72747 DUK_ASSERT(ref.holder != NULL);
72748
72749 /* Note: getprop may invoke any getter and invalidate any
72750 * duk_tval pointers, so this must be done first.
72751 */
72752
72753 if (ref.this_binding) {
72754 duk_push_tval(ctx, ref.this_binding);
72755 } else {
72756 duk_push_undefined(ctx);
72757 }
72758
72759 DUK_TVAL_SET_OBJECT(&tv_tmp_obj, ref.holder);
72760 DUK_TVAL_SET_STRING(&tv_tmp_key, name);
72761 (void) duk_hobject_getprop(thr, &tv_tmp_obj, &tv_tmp_key); /* [this value] */

References duk__get_identifier_reference(), DUK_ASSERT, DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR, DUK_DDD, DUK_DDDPRINT, duk_hobject_getprop(), duk_push_tval(), duk_push_undefined(), DUK_TVAL_SET_OBJECT, DUK_TVAL_SET_STRING, duk__id_lookup_result::holder, name, NULL, duk__id_lookup_result::this_binding, and duk__id_lookup_result::value.

◆ duk__grow_props_for_array_item()

DUK_LOCAL void duk__grow_props_for_array_item ( duk_hthread * thr,
duk_hobject * obj,
duk_uint32_t highest_arr_idx )

Definition at line 48391 of file duktape-1.8.0/src/duktape.c.

48408 {

Referenced by duk_hobject_define_property_internal(), and duk_hobject_putprop().

◆ duk__grow_props_for_new_entry_item()

DUK_LOCAL void duk__grow_props_for_new_entry_item ( duk_hthread * thr,
duk_hobject * obj )

Definition at line 48361 of file duktape-1.8.0/src/duktape.c.

48378 {
48379 duk_uint32_t old_e_used; /* actually used, non-NULL entries */
48380 duk_uint32_t new_e_size;
48381 duk_uint32_t new_a_size;
48382 duk_uint32_t new_h_size;
48383
48384 DUK_ASSERT(thr != NULL);
48385 DUK_ASSERT(obj != NULL);
48386
48387 /* Duktape 0.11.0 and prior tried to optimize the resize by not
48388 * counting the number of actually used keys prior to the resize.

◆ duk__handle_bound_chain_for_call()

DUK_LOCAL void duk__handle_bound_chain_for_call ( duk_hthread * thr,
duk_idx_t idx_func,
duk_idx_t * p_num_stack_args,
duk_bool_t is_constructor_call )

Definition at line 55388 of file duktape-1.8.0/src/duktape.c.

55408 {
55409 duk_context *ctx = (duk_context *) thr;
55410 duk_idx_t num_stack_args;
55411 duk_tval *tv_func;
55412 duk_hobject *func;
55413 duk_uint_t sanity;
55414
55415 DUK_ASSERT(thr != NULL);
55416 DUK_ASSERT(p_num_stack_args != NULL);
55417
55418 /* On entry, item at idx_func is a bound, non-lightweight function,
55419 * but we don't rely on that below.
55420 */
55421
55422 num_stack_args = *p_num_stack_args;
55423
55425 do {
55426 duk_idx_t i, len;
55427
55428 tv_func = duk_require_tval(ctx, idx_func);
55429 DUK_ASSERT(tv_func != NULL);
55430
55431 if (DUK_TVAL_IS_LIGHTFUNC(tv_func)) {
55432 /* Lightweight function: never bound, so terminate. */
55433 break;
55434 } else if (DUK_TVAL_IS_OBJECT(tv_func)) {
55435 func = DUK_TVAL_GET_OBJECT(tv_func);
55436 if (!DUK_HOBJECT_HAS_BOUND(func)) {
55437 /* Normal non-bound function. */
55438 break;
55439 }
55440 } else {
55441 /* Function.prototype.bind() should never let this happen,
55442 * ugly error message is enough.
55443 */
55445 }
55446 DUK_ASSERT(DUK_TVAL_GET_OBJECT(tv_func) != NULL);
55447
55448 /* XXX: this could be more compact by accessing the internal properties
55449 * directly as own properties (they cannot be inherited, and are not
55450 * externally visible).
55451 */
55452
55453 DUK_DDD(DUK_DDDPRINT("bound function encountered, ptr=%p, num_stack_args=%ld: %!T",
55454 (void *) DUK_TVAL_GET_OBJECT(tv_func), (long) num_stack_args, tv_func));
55455
55456 /* [ ... func this arg1 ... argN ] */
55457
55458 if (is_constructor_call) {
55459 /* See: tests/ecmascript/test-spec-bound-constructor.js */
55460 DUK_DDD(DUK_DDDPRINT("constructor call: don't update this binding"));
55461 } else {
55463 duk_replace(ctx, idx_func + 1); /* idx_this = idx_func + 1 */
55464 }
55465
55466 /* [ ... func this arg1 ... argN ] */
55467
55468 /* XXX: duk_get_length? */
55469 duk_get_prop_stridx(ctx, idx_func, DUK_STRIDX_INT_ARGS); /* -> [ ... func this arg1 ... argN _Args ] */
55470 duk_get_prop_stridx(ctx, -1, DUK_STRIDX_LENGTH); /* -> [ ... func this arg1 ... argN _Args length ] */
55471 len = (duk_idx_t) duk_require_int(ctx, -1);
55472 duk_pop(ctx);
55473
55474 duk_require_stack(ctx, len);
55475 for (i = 0; i < len; i++) {
55476 /* XXX: very slow - better to bulk allocate a gap, and copy
55477 * from args_array directly (we know it has a compact array
55478 * part, etc).
55479 */
55480
55481 /* [ ... func this <some bound args> arg1 ... argN _Args ] */
55482 duk_get_prop_index(ctx, -1, i);
55483 duk_insert(ctx, idx_func + 2 + i); /* idx_args = idx_func + 2 */
55484 }
55485 num_stack_args += len; /* must be updated to work properly (e.g. creation of 'arguments') */
55486 duk_pop(ctx);
55487
55488 /* [ ... func this <bound args> arg1 ... argN ] */
55489
55491 duk_replace(ctx, idx_func); /* replace in stack */
55492
55493 DUK_DDD(DUK_DDDPRINT("bound function handled, num_stack_args=%ld, idx_func=%ld, curr func=%!T",
55494 (long) num_stack_args, (long) idx_func, duk_get_tval(ctx, idx_func)));
55495 } while (--sanity > 0);
55496
55497 if (sanity == 0) {
55499 }
55500
#define DUK_STRIDX_INT_ARGS
#define DUK_STRIDX_INT_THIS
#define DUK_HOBJECT_HAS_BOUND(h)
#define DUK_TVAL_IS_LIGHTFUNC(tv)
#define DUK_STRIDX_INT_TARGET
#define DUK_HOBJECT_BOUND_CHAIN_SANITY
DUK_INTERNAL_DECL duk_tval * duk_require_tval(duk_context *ctx, duk_idx_t index)
#define DUK_STR_BOUND_CHAIN_LIMIT

◆ duk__handle_break_or_continue()

DUK_LOCAL void duk__handle_break_or_continue ( duk_hthread * thr,
duk_uint_t label_id,
duk_small_uint_t lj_type )

Definition at line 66803 of file duktape-1.8.0/src/duktape.c.

66803 :
66804 return retval;
66805
66806 convert_to_internal_error:
66807 /* This could also be thrown internally (set the error, goto check_longjmp),
66808 * but it's better for internal errors to bubble outwards so that we won't
66809 * infinite loop in this catchpoint.
66810 */
66813 return retval;
66814}
66815
66816/* Handle a BREAK/CONTINUE opcode. Avoid using longjmp() for BREAK/CONTINUE
66817 * handling because it has a measurable performance impact in ordinary
66818 * environments and an extreme impact in Emscripten (GH-342).
66819 */
66821 duk_uint_t label_id,
66822 duk_small_uint_t lj_type) {
66823 duk_catcher *cat;
66824 duk_size_t orig_callstack_index;
66825
66826 DUK_ASSERT(thr != NULL);
66827
66828 /*
66829 * Find a matching label catcher or 'finally' catcher in
66830 * the same function.
66831 *
66832 * A label catcher must always exist and will match unless
66833 * a 'finally' captures the break/continue first. It is the
66834 * compiler's responsibility to ensure that labels are used
66835 * correctly.
66836 */
66837
66838 /* Note: thr->catchstack_top may be 0, so that cat < thr->catchstack
66839 * initially. This is OK and intended.
66840 */
66841 cat = thr->catchstack + thr->catchstack_top - 1;
66842 DUK_ASSERT(thr->callstack_top > 0);
66843 orig_callstack_index = thr->callstack_top - 1;
66844
66845 DUK_DDD(DUK_DDDPRINT("handling break/continue with label=%ld, callstack index=%ld",
66846 (long) label_id, (long) cat->callstack_index));
66847
66848 while (cat >= thr->catchstack) {
66849 if (cat->callstack_index != orig_callstack_index) {
66850 break;
66851 }
66852 DUK_DDD(DUK_DDDPRINT("considering catcher %ld: type=%ld label=%ld",
66853 (long) (cat - thr->catchstack),
66854 (long) DUK_CAT_GET_TYPE(cat),
66855 (long) DUK_CAT_GET_LABEL(cat)));
66856
66857 if (DUK_CAT_GET_TYPE(cat) == DUK_CAT_TYPE_TCF &&
66859 duk_size_t cat_idx;
66860 duk_tval tv_tmp;
66861
66862 cat_idx = (duk_size_t) (cat - thr->catchstack); /* get before side effects */
66863
66864 DUK_TVAL_SET_FASTINT_U32(&tv_tmp, (duk_uint32_t) label_id);
66865 duk__handle_finally(thr, cat_idx, &tv_tmp, lj_type);
66866
66867 DUK_DD(DUK_DDPRINT("-> break/continue caught by 'finally', restart execution"));
66868 return;
66869 }
#define DUK_TVAL_SET_FASTINT_U32(tv, val)
#define DUK_CAT_GET_TYPE(c)
#define DUK_CAT_HAS_FINALLY_ENABLED(c)
#define DUK_CAT_GET_LABEL(c)
#define DUK_CAT_TYPE_TCF
#define DUK_CAT_TYPE_LABEL
DUK_LOCAL void duk__handle_break_or_continue(duk_hthread *thr, duk_uint_t label_id, duk_small_uint_t lj_type)
DUK_LOCAL void duk__handle_finally(duk_hthread *thr, duk_size_t cat_idx, duk_tval *tv_val_unstable, duk_small_uint_t lj_type)

◆ duk__handle_call_error()

DUK_LOCAL void duk__handle_call_error ( duk_hthread * thr,
duk_size_t entry_valstack_bottom_index,
duk_size_t entry_valstack_end,
duk_size_t entry_catchstack_top,
duk_size_t entry_callstack_top,
duk_int_t entry_call_recursion_depth,
duk_hthread * entry_curr_thread,
duk_uint_fast8_t entry_thread_state,
duk_instr_t ** entry_ptr_curr_pc,
duk_idx_t idx_func,
duk_jmpbuf * old_jmpbuf_ptr )

Definition at line 56719 of file duktape-1.8.0/src/duktape.c.

56730 :
56731 DUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, "invalid thread state for call (%ld)", (long) thr->state);
56733 return; /* never executed */
56734}
56735
56737 duk_size_t entry_valstack_bottom_index,
56738 duk_size_t entry_valstack_end,
56739 duk_size_t entry_catchstack_top,
56740 duk_size_t entry_callstack_top,
56741 duk_int_t entry_call_recursion_depth,
56742 duk_hthread *entry_curr_thread,
56743 duk_uint_fast8_t entry_thread_state,
56744 duk_instr_t **entry_ptr_curr_pc,
56745 duk_idx_t idx_func,
56746 duk_jmpbuf *old_jmpbuf_ptr) {
56747 duk_context *ctx;
56748 duk_tval *tv_ret;
56749
56750 ctx = (duk_context *) thr;
56751
56752 DUK_DDD(DUK_DDDPRINT("error caught during duk__handle_call_inner(): %!T",
56753 (duk_tval *) &thr->heap->lj.value1));
56754
56755 /* Other longjmp types are handled by executor before propagating
56756 * the error here.
56757 */
56759 DUK_ASSERT(thr->callstack_top >= entry_callstack_top);
56760 DUK_ASSERT(thr->catchstack_top >= entry_catchstack_top);
56761
56762 /* We don't need to sync back thr->ptr_curr_pc here because
56763 * the bytecode executor always has a setjmp catchpoint which
56764 * does that before errors propagate to here.
56765 */
56766 DUK_ASSERT(thr->ptr_curr_pc == NULL);
56767
56768 /* Restore the previous setjmp catcher so that any error in
56769 * error handling will propagate outwards rather than re-enter
56770 * the same handler. However, the error handling path must be
56771 * designed to be error free so that sandboxing guarantees are
56772 * reliable, see e.g. https://github.com/svaarala/duktape/issues/476.
56773 */
56774 thr->heap->lj.jmpbuf_ptr = old_jmpbuf_ptr;
56775
56776 /* XXX: callstack unwind may now throw an error when closing
56777 * scopes; this is a sandboxing issue, described in:
56778 * https://github.com/svaarala/duktape/issues/476
56779 */
56780 duk_hthread_catchstack_unwind(thr, entry_catchstack_top);
56782 duk_hthread_callstack_unwind(thr, entry_callstack_top);
56784
56785 thr->valstack_bottom = thr->valstack + entry_valstack_bottom_index;
56786 tv_ret = thr->valstack_bottom + idx_func; /* XXX: byte offset? */
56787 DUK_TVAL_SET_TVAL_UPDREF(thr, tv_ret, &thr->heap->lj.value1); /* side effects */
56788#if defined(DUK_USE_FASTINT)
56789 /* Explicit check for fastint downgrade. */
56791#endif
56792 duk_set_top(ctx, idx_func + 1); /* XXX: could be eliminated with valstack adjust */
56793
56794 /* [ ... errobj ] */
56795
56796 /* Ensure there is internal valstack spare before we exit; this may
56797 * throw an alloc error. The same guaranteed size must be available
56798 * as before the call. This is not optimal now: we store the valstack
56799 * allocated size during entry; this value may be higher than the
56800 * minimal guarantee for an application.
56801 */
56802
56803 /* XXX: this needs to be reworked so that we never shrink the value
56804 * stack on function entry so that we never need to grow it here.
56805 * Needing to grow here is a sandboxing issue because we need to
56806 * allocate which may cause an error in the error handling path
56807 * and thus propagate an error out of a protected call.
56808 */
56809
56810 (void) duk_valstack_resize_raw((duk_context *) thr,
56811 entry_valstack_end, /* same as during entry */
56812 DUK_VSRESIZE_FLAG_SHRINK | /* flags */
56815
56816
56817 /* These are just convenience "wiping" of state. Side effects should
56818 * not be an issue here: thr->heap and thr->heap->lj have a stable
56819 * pointer. Finalizer runs etc capture even out-of-memory errors so
56820 * nothing should throw here.
56821 */
56823 thr->heap->lj.iserror = 0;
56824 DUK_TVAL_SET_UNDEFINED_UPDREF(thr, &thr->heap->lj.value1); /* side effects */
56825 DUK_TVAL_SET_UNDEFINED_UPDREF(thr, &thr->heap->lj.value2); /* side effects */
56826
56827 /* Restore entry thread executor curr_pc stack frame pointer. */
56828 thr->ptr_curr_pc = entry_ptr_curr_pc;
56829
56830 DUK_HEAP_SWITCH_THREAD(thr->heap, entry_curr_thread); /* may be NULL */
56831 thr->state = (duk_uint8_t) entry_thread_state;
56832
56833 DUK_ASSERT((thr->state == DUK_HTHREAD_STATE_INACTIVE && thr->heap->curr_thread == NULL) || /* first call */
56834 (thr->state == DUK_HTHREAD_STATE_INACTIVE && thr->heap->curr_thread != NULL) || /* other call */
56835 (thr->state == DUK_HTHREAD_STATE_RUNNING && thr->heap->curr_thread == thr)); /* current thread */
56836
56837 thr->heap->call_recursion_depth = entry_call_recursion_depth;
56838
56839 /* If the debugger is active we need to force an interrupt so that
56840 * debugger breakpoints are rechecked. This is important for function
56841 * calls caused by side effects (e.g. when doing a DUK_OP_GETPROP), see
56842 * GH-303. Only needed for success path, error path always causes a
56843 * breakpoint recheck in the executor. It would be enough to set this
#define DUK_LJ_TYPE_THROW
DUK_INTERNAL_DECL duk_bool_t duk_valstack_resize_raw(duk_context *ctx, duk_size_t min_new_size, duk_small_uint_t flags)
#define DUK_VSRESIZE_FLAG_THROW
DUK_INTERNAL_DECL void duk_hthread_catchstack_unwind(duk_hthread *thr, duk_size_t new_top)
#define DUK_VSRESIZE_FLAG_SHRINK
#define DUK_HTHREAD_STATE_INACTIVE
#define DUK_LJ_TYPE_UNKNOWN
DUK_LOCAL void duk__handle_call_error(duk_hthread *thr, duk_size_t entry_valstack_bottom_index, duk_size_t entry_valstack_end, duk_size_t entry_catchstack_top, duk_size_t entry_callstack_top, duk_int_t entry_call_recursion_depth, duk_hthread *entry_curr_thread, duk_uint_fast8_t entry_thread_state, duk_instr_t **entry_ptr_curr_pc, duk_idx_t idx_func, duk_jmpbuf *old_jmpbuf_ptr)
#define DUK_VSRESIZE_FLAG_COMPACT
DUK_INTERNAL_DECL void duk_hthread_callstack_shrink_check(duk_hthread *thr)
#define DUK_HTHREAD_STATE_RUNNING
DUK_INTERNAL_DECL void duk_hthread_callstack_unwind(duk_hthread *thr, duk_size_t new_top)
DUK_INTERNAL_DECL void duk_hthread_catchstack_shrink_check(duk_hthread *thr)
#define DUK_HEAP_SWITCH_THREAD(heap, newthr)

Referenced by duk_handle_call_protected().

◆ duk__handle_call_inner()

DUK_LOCAL void duk__handle_call_inner ( duk_hthread * thr,
duk_idx_t num_stack_args,
duk_small_uint_t call_flags,
duk_idx_t idx_func )

Definition at line 56142 of file duktape-1.8.0/src/duktape.c.

56150 {
56151 duk_idx_t idx_func; /* valstack index of 'func' and retval (relative to entry valstack_bottom) */
56152
56153 /* Argument validation and func/args offset. */
56154 idx_func = duk__get_idx_func(thr, num_stack_args);
56155
56156 duk__handle_call_inner(thr, num_stack_args, call_flags, idx_func);
56157}
56158
56160 duk_idx_t num_stack_args,
56161 duk_small_uint_t call_flags,
56162 duk_idx_t idx_func) {
56163 duk_context *ctx;
56164 duk_size_t entry_valstack_bottom_index;
56165 duk_size_t entry_valstack_end;
56166 duk_size_t entry_callstack_top;
56167 duk_size_t entry_catchstack_top;
56168 duk_int_t entry_call_recursion_depth;
56169 duk_hthread *entry_curr_thread;
56170 duk_uint_fast8_t entry_thread_state;
56171 duk_instr_t **entry_ptr_curr_pc;
56172 duk_idx_t nargs; /* # argument registers target function wants (< 0 => "as is") */
56173 duk_idx_t nregs; /* # total registers target function wants on entry (< 0 => "as is") */
56174 duk_hobject *func; /* 'func' on stack (borrowed reference) */
56175 duk_tval *tv_func; /* duk_tval ptr for 'func' on stack (borrowed reference) or tv_func_copy */
56176 duk_tval tv_func_copy; /* to avoid relookups */
56177 duk_activation *act;
56178 duk_hobject *env;
56179 duk_ret_t rc;
56180
56181 ctx = (duk_context *) thr;
56182 DUK_ASSERT(thr != NULL);
56184 DUK_ASSERT(ctx != NULL);
56185 DUK_ASSERT(num_stack_args >= 0);
56186 /* XXX: currently NULL allocations are not supported; remove if later allowed */
56187 DUK_ASSERT(thr->valstack != NULL);
56188 DUK_ASSERT(thr->callstack != NULL);
56189 DUK_ASSERT(thr->catchstack != NULL);
56190
56191 DUK_DD(DUK_DDPRINT("duk__handle_call_inner: num_stack_args=%ld, call_flags=0x%08lx, top=%ld",
56192 (long) num_stack_args, (long) call_flags, (long) duk_get_top(ctx)));
56193
56194 /*
56195 * Store entry state.
56196 */
56197
56198 entry_valstack_bottom_index = (duk_size_t) (thr->valstack_bottom - thr->valstack);
56199#if defined(DUK_USE_PREFER_SIZE)
56200 entry_valstack_end = (duk_size_t) (thr->valstack_end - thr->valstack);
56201#else
56202 DUK_ASSERT((duk_size_t) (thr->valstack_end - thr->valstack) == thr->valstack_size);
56203 entry_valstack_end = thr->valstack_size;
56204#endif
56205 entry_callstack_top = thr->callstack_top;
56206 entry_catchstack_top = thr->catchstack_top;
56207 entry_call_recursion_depth = thr->heap->call_recursion_depth;
56208 entry_curr_thread = thr->heap->curr_thread; /* Note: may be NULL if first call */
56209 entry_thread_state = thr->state;
56210 entry_ptr_curr_pc = thr->ptr_curr_pc; /* may be NULL */
56211
56212 /* If thr->ptr_curr_pc is set, sync curr_pc to act->pc. Then NULL
56213 * thr->ptr_curr_pc so that it's not accidentally used with an incorrect
56214 * activation when side effects occur.
56215 */
56217
56218 DUK_DD(DUK_DDPRINT("duk__handle_call_inner: thr=%p, num_stack_args=%ld, "
56219 "call_flags=0x%08lx (ignorerec=%ld, constructor=%ld), "
56220 "valstack_top=%ld, idx_func=%ld, idx_args=%ld, rec_depth=%ld/%ld, "
56221 "entry_valstack_bottom_index=%ld, entry_callstack_top=%ld, entry_catchstack_top=%ld, "
56222 "entry_call_recursion_depth=%ld, entry_curr_thread=%p, entry_thread_state=%ld",
56223 (void *) thr,
56224 (long) num_stack_args,
56225 (unsigned long) call_flags,
56226 (long) ((call_flags & DUK_CALL_FLAG_IGNORE_RECLIMIT) != 0 ? 1 : 0),
56227 (long) ((call_flags & DUK_CALL_FLAG_CONSTRUCTOR_CALL) != 0 ? 1 : 0),
56228 (long) duk_get_top(ctx),
56229 (long) idx_func,
56230 (long) (idx_func + 2),
56231 (long) thr->heap->call_recursion_depth,
56232 (long) thr->heap->call_recursion_limit,
56233 (long) entry_valstack_bottom_index,
56234 (long) entry_callstack_top,
56235 (long) entry_catchstack_top,
56236 (long) entry_call_recursion_depth,
56237 (void *) entry_curr_thread,
56238 (long) entry_thread_state));
56239
56240
56241 /*
56242 * Thread state check and book-keeping.
56243 */
56244
56245 if (thr == thr->heap->curr_thread) {
56246 /* same thread */
56247 if (thr->state != DUK_HTHREAD_STATE_RUNNING) {
56248 /* should actually never happen, but check anyway */
56249 goto thread_state_error;
56250 }
56251 } else {
56252 /* different thread */
56253 DUK_ASSERT(thr->heap->curr_thread == NULL ||
56254 thr->heap->curr_thread->state == DUK_HTHREAD_STATE_RUNNING);
56255 if (thr->state != DUK_HTHREAD_STATE_INACTIVE) {
56256 goto thread_state_error;
56257 }
56258 DUK_HEAP_SWITCH_THREAD(thr->heap, thr);
56259 thr->state = DUK_HTHREAD_STATE_RUNNING;
56260
56261 /* Note: multiple threads may be simultaneously in the RUNNING
56262 * state, but not in the same "resume chain".
56263 */
56264 }
56265 DUK_ASSERT(thr->heap->curr_thread == thr);
56267
56268 /*
56269 * C call recursion depth check, which provides a reasonable upper
56270 * bound on maximum C stack size (arbitrary C stack growth is only
56271 * possible by recursive handle_call / handle_safe_call calls).
56272 */
56273
56274 /* XXX: remove DUK_CALL_FLAG_IGNORE_RECLIMIT flag: there's now the
56275 * reclimit bump?
56276 */
56277
56278 DUK_ASSERT(thr->heap->call_recursion_depth >= 0);
56279 DUK_ASSERT(thr->heap->call_recursion_depth <= thr->heap->call_recursion_limit);
56280 if (call_flags & DUK_CALL_FLAG_IGNORE_RECLIMIT) {
56281 DUK_DD(DUK_DDPRINT("ignoring reclimit for this call (probably an errhandler call)"));
56282 } else {
56283 if (thr->heap->call_recursion_depth >= thr->heap->call_recursion_limit) {
56284 /* XXX: error message is a bit misleading: we reached a recursion
56285 * limit which is also essentially the same as a C callstack limit
56286 * (except perhaps with some relaxed threading assumptions).
56287 */
56289 }
56290 thr->heap->call_recursion_depth++;
56291 }
56292
56293 /*
56294 * Check the function type, handle bound function chains, and prepare
56295 * parameters for the rest of the call handling. Also figure out the
56296 * effective 'this' binding, which replaces the current value at
56297 * idx_func + 1.
56298 *
56299 * If the target function is a 'bound' one, follow the chain of 'bound'
56300 * functions until a non-bound function is found. During this process,
56301 * bound arguments are 'prepended' to existing ones, and the "this"
56302 * binding is overridden. See E5 Section 15.3.4.5.1.
56303 *
56304 * Lightfunc detection happens here too. Note that lightweight functions
56305 * can be wrapped by (non-lightweight) bound functions so we must resolve
56306 * the bound function chain first.
56307 */
56308
56309 func = duk__nonbound_func_lookup(ctx, idx_func, &num_stack_args, &tv_func, call_flags);
56310 DUK_TVAL_SET_TVAL(&tv_func_copy, tv_func);
56311 tv_func = &tv_func_copy; /* local copy to avoid relookups */
56312
56313 DUK_ASSERT(func == NULL || !DUK_HOBJECT_HAS_BOUND(func));
56316
56317 duk__coerce_effective_this_binding(thr, func, idx_func + 1);
56318 DUK_DDD(DUK_DDDPRINT("effective 'this' binding is: %!T",
56319 (duk_tval *) duk_get_tval(ctx, idx_func + 1)));
56320
56321 /* [ ... func this arg1 ... argN ] */
56322
56323 /*
56324 * Setup a preliminary activation and figure out nargs/nregs.
56325 *
56326 * Don't touch valstack_bottom or valstack_top yet so that Duktape API
56327 * calls work normally.
56328 */
56329
56331
56332 if (thr->callstack_top > 0) {
56333 /*
56334 * Update idx_retval of current activation.
56335 *
56336 * Although it might seem this is not necessary (bytecode executor
56337 * does this for Ecmascript-to-Ecmascript calls; other calls are
56338 * handled here), this turns out to be necessary for handling yield
56339 * and resume. For them, an Ecmascript-to-native call happens, and
56340 * the Ecmascript call's idx_retval must be set for things to work.
56341 */
56342
56343 (thr->callstack + thr->callstack_top - 1)->idx_retval = entry_valstack_bottom_index + idx_func;
56344 }
56345
56346 DUK_ASSERT(thr->callstack_top < thr->callstack_size);
56347 act = thr->callstack + thr->callstack_top;
56348 thr->callstack_top++;
56349 DUK_ASSERT(thr->callstack_top <= thr->callstack_size);
56350 DUK_ASSERT(thr->valstack_top > thr->valstack_bottom); /* at least effective 'this' */
56351 DUK_ASSERT(func == NULL || !DUK_HOBJECT_HAS_BOUND(func));
56352
56353 act->flags = 0;
56354
56355 /* For now all calls except Ecma-to-Ecma calls prevent a yield. */
56357 if (call_flags & DUK_CALL_FLAG_CONSTRUCTOR_CALL) {
56359 }
56360 if (call_flags & DUK_CALL_FLAG_DIRECT_EVAL) {
56362 }
56363
56364 /* These base values are never used, but if the compiler doesn't know
56365 * that DUK_ERROR() won't return, these are needed to silence warnings.
56366 * On the other hand, scan-build will warn about the values not being
56367 * used, so add a DUK_UNREF.
56368 */
56369 nargs = 0; DUK_UNREF(nargs);
56370 nregs = 0; DUK_UNREF(nregs);
56371
56372 if (DUK_LIKELY(func != NULL)) {
56373 if (DUK_HOBJECT_HAS_STRICT(func)) {
56374 act->flags |= DUK_ACT_FLAG_STRICT;
56375 }
56377 nargs = ((duk_hcompiledfunction *) func)->nargs;
56378 nregs = ((duk_hcompiledfunction *) func)->nregs;
56379 DUK_ASSERT(nregs >= nargs);
56380 } else if (DUK_HOBJECT_IS_NATIVEFUNCTION(func)) {
56381 /* Note: nargs (and nregs) may be negative for a native,
56382 * function, which indicates that the function wants the
56383 * input stack "as is" (i.e. handles "vararg" arguments).
56384 */
56385 nargs = ((duk_hnativefunction *) func)->nargs;
56386 nregs = nargs;
56387 } else {
56388 /* XXX: this should be an assert */
56390 }
56391 } else {
56392 duk_small_uint_t lf_flags;
56393
56395 lf_flags = DUK_TVAL_GET_LIGHTFUNC_FLAGS(tv_func);
56396 nargs = DUK_LFUNC_FLAGS_GET_NARGS(lf_flags);
56397 if (nargs == DUK_LFUNC_NARGS_VARARGS) {
56398 nargs = -1; /* vararg */
56399 }
56400 nregs = nargs;
56401
56402 act->flags |= DUK_ACT_FLAG_STRICT;
56403 }
56404
56405 act->func = func; /* NULL for lightfunc */
56406 act->var_env = NULL;
56407 act->lex_env = NULL;
56408#if defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)
56409 act->prev_caller = NULL;
56410#endif
56411 act->curr_pc = NULL;
56412#if defined(DUK_USE_DEBUGGER_SUPPORT)
56413 act->prev_line = 0;
56414#endif
56415 act->idx_bottom = entry_valstack_bottom_index + idx_func + 2;
56416#if 0 /* topmost activation idx_retval is considered garbage, no need to init */
56417 act->idx_retval = 0;
56418#endif
56419 DUK_TVAL_SET_TVAL(&act->tv_func, tv_func); /* borrowed, no refcount */
56420
56421 /* XXX: remove the preventcount and make yield walk the callstack?
56422 * Or perhaps just use a single flag, not a counter, faster to just
56423 * set and restore?
56424 */
56425 if (act->flags & DUK_ACT_FLAG_PREVENT_YIELD) {
56426 /* duk_hthread_callstack_unwind() will decrease this on unwind */
56427 thr->callstack_preventcount++;
56428 }
56429
56430 /* XXX: Is this INCREF necessary? 'func' is always a borrowed
56431 * reference reachable through the value stack? If changed, stack
56432 * unwind code also needs to be fixed to match.
56433 */
56434 DUK_HOBJECT_INCREF_ALLOWNULL(thr, func); /* act->func */
56435
56436#if defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)
56437 if (func) {
56438 duk__update_func_caller_prop(thr, func);
56439 act = thr->callstack + thr->callstack_top - 1;
56440 }
56441#endif
56442
56443 /* [ ... func this arg1 ... argN ] */
56444
56445 /*
56446 * Environment record creation and 'arguments' object creation.
56447 * Named function expression name binding is handled by the
56448 * compiler; the compiled function's parent env will contain
56449 * the (immutable) binding already.
56450 *
56451 * This handling is now identical for C and Ecmascript functions.
56452 * C functions always have the 'NEWENV' flag set, so their
56453 * environment record initialization is delayed (which is good).
56454 *
56455 * Delayed creation (on demand) is handled in duk_js_var.c.
56456 */
56457
56458 DUK_ASSERT(func == NULL || !DUK_HOBJECT_HAS_BOUND(func)); /* bound function chain has already been resolved */
56459
56460 if (DUK_LIKELY(func != NULL)) {
56463 /* Use a new environment but there's no 'arguments' object;
56464 * delayed environment initialization. This is the most
56465 * common case.
56466 */
56467 DUK_ASSERT(act->lex_env == NULL);
56468 DUK_ASSERT(act->var_env == NULL);
56469 } else {
56470 /* Use a new environment and there's an 'arguments' object.
56471 * We need to initialize it right now.
56472 */
56473
56474 /* third arg: absolute index (to entire valstack) of idx_bottom of new activation */
56476 DUK_ASSERT(env != NULL);
56477
56478 /* [ ... func this arg1 ... argN envobj ] */
56479
56481 duk__handle_createargs_for_call(thr, func, env, num_stack_args);
56482
56483 /* [ ... func this arg1 ... argN envobj ] */
56484
56485 act = thr->callstack + thr->callstack_top - 1;
56486 act->lex_env = env;
56487 act->var_env = env;
56488 DUK_HOBJECT_INCREF(thr, env);
56489 DUK_HOBJECT_INCREF(thr, env); /* XXX: incref by count (2) directly */
56490 duk_pop(ctx);
56491 }
56492 } else {
56493 /* Use existing env (e.g. for non-strict eval); cannot have
56494 * an own 'arguments' object (but can refer to an existing one).
56495 */
56496
56498
56499 duk__handle_oldenv_for_call(thr, func, act);
56500 /* No need to re-lookup 'act' at present: no side effects. */
56501
56502 DUK_ASSERT(act->lex_env != NULL);
56503 DUK_ASSERT(act->var_env != NULL);
56504 }
56505 } else {
56506 /* Lightfuncs are always native functions and have "newenv". */
56507 DUK_ASSERT(act->lex_env == NULL);
56508 DUK_ASSERT(act->var_env == NULL);
56509 }
56510
56511 /* [ ... func this arg1 ... argN ] */
56512
56513 /*
56514 * Setup value stack: clamp to 'nargs', fill up to 'nregs'
56515 *
56516 * Value stack may either grow or shrink, depending on the
56517 * number of func registers and the number of actual arguments.
56518 * If nregs >= 0, func wants args clamped to 'nargs'; else it
56519 * wants all args (= 'num_stack_args').
56520 */
56521
56522 /* XXX: optimize value stack operation */
56523 /* XXX: don't want to shrink allocation here */
56524
56526 num_stack_args,
56527 idx_func + 2,
56528 nregs,
56529 nargs,
56530 func);
56531
56532 /*
56533 * Determine call type, then finalize activation, shift to
56534 * new value stack bottom, and call the target.
56535 */
56536
56537 act = thr->callstack + thr->callstack_top - 1;
56538 if (func != NULL && DUK_HOBJECT_IS_COMPILEDFUNCTION(func)) {
56539 /*
56540 * Ecmascript call
56541 */
56542
56543 duk_tval *tv_ret;
56544 duk_tval *tv_funret;
56545
56546 DUK_ASSERT(func != NULL);
56549
56550 thr->valstack_bottom = thr->valstack_bottom + idx_func + 2;
56551 /* keep current valstack_top */
56552 DUK_ASSERT(thr->valstack_bottom >= thr->valstack);
56553 DUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);
56554 DUK_ASSERT(thr->valstack_end >= thr->valstack_top);
56555
56556 /* [ ... func this | arg1 ... argN ] ('this' must precede new bottom) */
56557
56558 /*
56559 * Bytecode executor call.
56560 *
56561 * Execute bytecode, handling any recursive function calls and
56562 * thread resumptions. Returns when execution would return from
56563 * the entry level activation. When the executor returns, a
56564 * single return value is left on the stack top.
56565 *
56566 * The only possible longjmp() is an error (DUK_LJ_TYPE_THROW),
56567 * other types are handled internally by the executor.
56568 */
56569
56570 /* thr->ptr_curr_pc is set by bytecode executor early on entry */
56571 DUK_ASSERT(thr->ptr_curr_pc == NULL);
56572 DUK_DDD(DUK_DDDPRINT("entering bytecode execution"));
56574 DUK_DDD(DUK_DDDPRINT("returned from bytecode execution"));
56575
56576 /* Unwind. */
56577
56578 DUK_ASSERT(thr->catchstack_top >= entry_catchstack_top); /* may need unwind */
56579 DUK_ASSERT(thr->callstack_top == entry_callstack_top + 1);
56580 DUK_ASSERT(thr->callstack_top == entry_callstack_top + 1);
56581 duk_hthread_catchstack_unwind(thr, entry_catchstack_top);
56583 duk_hthread_callstack_unwind(thr, entry_callstack_top);
56585
56586 thr->valstack_bottom = thr->valstack + entry_valstack_bottom_index;
56587 /* keep current valstack_top */
56588 DUK_ASSERT(thr->valstack_bottom >= thr->valstack);
56589 DUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);
56590 DUK_ASSERT(thr->valstack_end >= thr->valstack_top);
56591 DUK_ASSERT(thr->valstack_top - thr->valstack_bottom >= idx_func + 1);
56592
56593 /* Return value handling. */
56594
56595 /* [ ... func this (crud) retval ] */
56596
56597 tv_ret = thr->valstack_bottom + idx_func;
56598 tv_funret = thr->valstack_top - 1;
56599#if defined(DUK_USE_FASTINT)
56600 /* Explicit check for fastint downgrade. */
56601 DUK_TVAL_CHKFAST_INPLACE(tv_funret);
56602#endif
56603 DUK_TVAL_SET_TVAL_UPDREF(thr, tv_ret, tv_funret); /* side effects */
56604 } else {
56605 /*
56606 * Native call.
56607 */
56608
56609 duk_tval *tv_ret;
56610 duk_tval *tv_funret;
56611
56612 thr->valstack_bottom = thr->valstack_bottom + idx_func + 2;
56613 /* keep current valstack_top */
56614 DUK_ASSERT(thr->valstack_bottom >= thr->valstack);
56615 DUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);
56616 DUK_ASSERT(thr->valstack_end >= thr->valstack_top);
56617 DUK_ASSERT(func == NULL || ((duk_hnativefunction *) func)->func != NULL);
56618
56619 /* [ ... func this | arg1 ... argN ] ('this' must precede new bottom) */
56620
56621 /* For native calls must be NULL so we don't sync back */
56622 DUK_ASSERT(thr->ptr_curr_pc == NULL);
56623
56624 if (func) {
56625 rc = ((duk_hnativefunction *) func)->func((duk_context *) thr);
56626 } else {
56628 rc = funcptr((duk_context *) thr);
56629 }
56630
56631 /* Automatic error throwing, retval check. */
56632
56633 if (rc < 0) {
56636 } else if (rc > 1) {
56637 DUK_ERROR_API(thr, "c function returned invalid rc");
56638 }
56639 DUK_ASSERT(rc == 0 || rc == 1);
56640
56641 /* Unwind. */
56642
56643 DUK_ASSERT(thr->catchstack_top == entry_catchstack_top); /* no need to unwind */
56644 DUK_ASSERT(thr->callstack_top == entry_callstack_top + 1);
56645 duk_hthread_callstack_unwind(thr, entry_callstack_top);
56647
56648 thr->valstack_bottom = thr->valstack + entry_valstack_bottom_index;
56649 /* keep current valstack_top */
56650 DUK_ASSERT(thr->valstack_bottom >= thr->valstack);
56651 DUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);
56652 DUK_ASSERT(thr->valstack_end >= thr->valstack_top);
56653 DUK_ASSERT(thr->valstack_top - thr->valstack_bottom >= idx_func + 1);
56654
56655 /* Return value handling. */
56656
56657 /* XXX: should this happen in the callee's activation or after unwinding? */
56658 tv_ret = thr->valstack_bottom + idx_func;
56659 if (rc == 0) {
56660 DUK_TVAL_SET_UNDEFINED_UPDREF(thr, tv_ret); /* side effects */
56661 } else {
56662 /* [ ... func this (crud) retval ] */
56663 tv_funret = thr->valstack_top - 1;
56664#if defined(DUK_USE_FASTINT)
56665 /* Explicit check for fastint downgrade. */
56666 DUK_TVAL_CHKFAST_INPLACE(tv_funret);
56667#endif
56668 DUK_TVAL_SET_TVAL_UPDREF(thr, tv_ret, tv_funret); /* side effects */
56669 }
56670 }
56671
56672 duk_set_top(ctx, idx_func + 1); /* XXX: unnecessary, handle in adjust */
56673
56674 /* [ ... retval ] */
56675
56676 /* Ensure there is internal valstack spare before we exit; this may
56677 * throw an alloc error. The same guaranteed size must be available
56678 * as before the call. This is not optimal now: we store the valstack
56679 * allocated size during entry; this value may be higher than the
56680 * minimal guarantee for an application.
56681 */
56682
56683 /* XXX: we should never shrink here; when we error out later, we'd
56684 * need to potentially grow the value stack in error unwind which could
56685 * cause another error.
56686 */
56687
56688 (void) duk_valstack_resize_raw((duk_context *) thr,
56689 entry_valstack_end, /* same as during entry */
56690 DUK_VSRESIZE_FLAG_SHRINK | /* flags */
56693
56694 /* Restore entry thread executor curr_pc stack frame pointer. */
56695 thr->ptr_curr_pc = entry_ptr_curr_pc;
56696
56697 DUK_HEAP_SWITCH_THREAD(thr->heap, entry_curr_thread); /* may be NULL */
56698 thr->state = (duk_uint8_t) entry_thread_state;
56699
56700 DUK_ASSERT((thr->state == DUK_HTHREAD_STATE_INACTIVE && thr->heap->curr_thread == NULL) || /* first call */
56701 (thr->state == DUK_HTHREAD_STATE_INACTIVE && thr->heap->curr_thread != NULL) || /* other call */
56702 (thr->state == DUK_HTHREAD_STATE_RUNNING && thr->heap->curr_thread == thr)); /* current thread */
56703
56704 thr->heap->call_recursion_depth = entry_call_recursion_depth;
56705
56706 /* If the debugger is active we need to force an interrupt so that
56707 * debugger breakpoints are rechecked. This is important for function
56708 * calls caused by side effects (e.g. when doing a DUK_OP_GETPROP), see
56709 * GH-303. Only needed for success path, error path always causes a
56710 * breakpoint recheck in the executor. It would be enough to set this
56711 * only when returning to an Ecmascript activation, but setting the flag
56712 * on every return should have no ill effect.
56713 */
56714#if defined(DUK_USE_DEBUGGER_SUPPORT)
56715 if (DUK_HEAP_IS_DEBUGGER_ATTACHED(thr->heap)) {
56716 DUK_DD(DUK_DDPRINT("returning with debugger enabled, force interrupt"));
56717 DUK_ASSERT(thr->interrupt_counter <= thr->interrupt_init);
DUK_LOCAL duk_hobject * duk__nonbound_func_lookup(duk_context *ctx, duk_idx_t idx_func, duk_idx_t *out_num_stack_args, duk_tval **out_tv_func, duk_small_uint_t call_flags)
DUK_INTERNAL_DECL void duk_hthread_sync_and_null_currpc(duk_hthread *thr)
#define DUK_CALL_FLAG_CONSTRUCTOR_CALL
DUK_LOCAL void duk__handle_oldenv_for_call(duk_hthread *thr, duk_hobject *func, duk_activation *act)
#define DUK_TVAL_GET_LIGHTFUNC_FUNCPTR(tv)
#define DUK_HOBJECT_HAS_CREATEARGS(h)
DUK_INTERNAL_DECL void duk_hthread_callstack_grow(duk_hthread *thr)
#define DUK_LFUNC_NARGS_VARARGS
DUK_LOCAL void duk__handle_call_inner(duk_hthread *thr, duk_idx_t num_stack_args, duk_small_uint_t call_flags, duk_idx_t idx_func)
DUK_INTERNAL_DECL void duk_js_execute_bytecode(duk_hthread *exec_thr)
DUK_INTERNAL_DECL duk_hobject * duk_create_activation_environment_record(duk_hthread *thr, duk_hobject *func, duk_size_t idx_bottom)
DUK_LOCAL void duk__handle_createargs_for_call(duk_hthread *thr, duk_hobject *func, duk_hobject *env, duk_idx_t num_stack_args)
#define DUK_STR_C_CALLSTACK_LIMIT
DUK_INTERNAL void duk_error_throw_from_negative_rc(duk_hthread *thr, duk_ret_t rc)
#define DUK_LFUNC_FLAGS_GET_NARGS(lf_flags)
#define DUK_CALL_FLAG_DIRECT_EVAL
#define DUK_HOBJECT_INCREF_ALLOWNULL(thr, h)
#define DUK_HOBJECT_HAS_COMPILEDFUNCTION(h)
#define DUK_TVAL_GET_LIGHTFUNC_FLAGS(tv)
#define DUK_CALL_FLAG_IGNORE_RECLIMIT

Referenced by duk_handle_call_protected().

◆ duk__handle_catch()

DUK_LOCAL void duk__handle_catch ( duk_hthread * thr,
duk_size_t cat_idx,
duk_tval * tv_val_unstable,
duk_small_uint_t lj_type )

Definition at line 66241 of file duktape-1.8.0/src/duktape.c.

66242 {
66243 duk_tval *tv1;
66244
66245 DUK_ASSERT(thr != NULL);
66246 DUK_ASSERT(tv_val_unstable != NULL);
66247
66248 tv1 = thr->valstack + thr->catchstack[cat_idx].idx_base;
66249 DUK_ASSERT(tv1 < thr->valstack_top);
66250 DUK_TVAL_SET_TVAL_UPDREF(thr, tv1, tv_val_unstable); /* side effects */
66251
66252 tv1 = thr->valstack + thr->catchstack[cat_idx].idx_base + 1;
66253 DUK_ASSERT(tv1 < thr->valstack_top);
66254
66255 DUK_TVAL_SET_FASTINT_U32_UPDREF(thr, tv1, (duk_uint32_t) lj_type); /* side effects */
66256}
66257
66258DUK_LOCAL void duk__handle_catch(duk_hthread *thr, duk_size_t cat_idx, duk_tval *tv_val_unstable, duk_small_uint_t lj_type) {
66259 duk_context *ctx;
66260 duk_activation *act;
66261
66262 DUK_ASSERT(thr != NULL);
66263 DUK_ASSERT(tv_val_unstable != NULL);
66264 ctx = (duk_context *) thr;
66265
66266 duk__set_catcher_regs(thr, cat_idx, tv_val_unstable, lj_type);
66267
66268 duk_hthread_catchstack_unwind(thr, cat_idx + 1);
66270
66271 DUK_ASSERT(thr->callstack_top >= 1);
66274
66275 duk__reconfig_valstack_ecma_catcher(thr, thr->callstack_top - 1, cat_idx);
66276
66277 DUK_ASSERT(thr->callstack_top >= 1);
66278 act = thr->callstack + thr->callstack_top - 1;
66279 act->curr_pc = thr->catchstack[cat_idx].pc_base + 0; /* +0 = catch */
66280 act = NULL;
66281
66282 /*
66283 * If entering a 'catch' block which requires an automatic
66284 * catch variable binding, create the lexical environment.
66285 *
66286 * The binding is mutable (= writable) but not deletable.
66287 * Step 4 for the catch production in E5 Section 12.14;
66288 * no value is given for CreateMutableBinding 'D' argument,
66289 * which implies the binding is not deletable.
66290 */
66291
66292 if (DUK_CAT_HAS_CATCH_BINDING_ENABLED(&thr->catchstack[cat_idx])) {
66293 duk_hobject *new_env;
66294 duk_hobject *act_lex_env;
66295
66296 DUK_DDD(DUK_DDDPRINT("catcher has an automatic catch binding"));
66297
66298 /* Note: 'act' is dangerous here because it may get invalidate at many
66299 * points, so we re-lookup it multiple times.
66300 */
66301 DUK_ASSERT(thr->callstack_top >= 1);
66302 act = thr->callstack + thr->callstack_top - 1;
66303
66304 if (act->lex_env == NULL) {
66305 DUK_ASSERT(act->var_env == NULL);
66306 DUK_DDD(DUK_DDDPRINT("delayed environment initialization"));
66307
66308 /* this may have side effects, so re-lookup act */
66310 act = thr->callstack + thr->callstack_top - 1;
66311 }
66312 DUK_ASSERT(act->lex_env != NULL);
66313 DUK_ASSERT(act->var_env != NULL);
66315 DUK_UNREF(act); /* unreferenced without assertions */
66316
66317 act = thr->callstack + thr->callstack_top - 1;
66318 act_lex_env = act->lex_env;
66319 act = NULL; /* invalidated */
66320
66324 act_lex_env);
66325 new_env = DUK_GET_HOBJECT_NEGIDX(ctx, -1);
66326 DUK_ASSERT(new_env != NULL);
66327 DUK_DDD(DUK_DDDPRINT("new_env allocated: %!iO", (duk_heaphdr *) new_env));
66328
66329 /* Note: currently the catch binding is handled without a register
66330 * binding because we don't support dynamic register bindings (they
66331 * must be fixed for an entire function). So, there is no need to
66332 * record regbases etc.
66333 */
66334
66335 DUK_ASSERT(thr->catchstack[cat_idx].h_varname != NULL);
#define DUK_TVAL_SET_FASTINT_U32_UPDREF
DUK_LOCAL void duk__reconfig_valstack_ecma_catcher(duk_hthread *thr, duk_size_t act_idx, duk_size_t cat_idx)
DUK_INTERNAL_DECL void duk_js_init_activation_environment_records_delayed(duk_hthread *thr, duk_activation *act)
#define DUK_CAT_HAS_CATCH_BINDING_ENABLED(c)
DUK_LOCAL void duk__set_catcher_regs(duk_hthread *thr, duk_size_t cat_idx, duk_tval *tv_val_unstable, duk_small_uint_t lj_type)
DUK_LOCAL void duk__handle_catch(duk_hthread *thr, duk_size_t cat_idx, duk_tval *tv_val_unstable, duk_small_uint_t lj_type)
DUK_INTERNAL_DECL duk_idx_t duk_push_object_helper_proto(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_hobject *proto)

References duk_hthread::catchstack, DUK_ASSERT, DUK_TVAL_SET_FASTINT_U32_UPDREF, DUK_TVAL_SET_TVAL_UPDREF, duk_catcher::idx_base, NULL, and duk_hthread::valstack.

◆ duk__handle_createargs_for_call()

DUK_LOCAL void duk__handle_createargs_for_call ( duk_hthread * thr,
duk_hobject * func,
duk_hobject * env,
duk_idx_t num_stack_args )

Definition at line 55342 of file duktape-1.8.0/src/duktape.c.

55362 {
55363 duk_context *ctx = (duk_context *) thr;
55364
55365 DUK_DDD(DUK_DDDPRINT("creating arguments object for function call"));
55366
55367 DUK_ASSERT(thr != NULL);
55368 DUK_ASSERT(func != NULL);
55369 DUK_ASSERT(env != NULL);
55371 DUK_ASSERT(duk_get_top(ctx) >= num_stack_args + 1);
55372

Referenced by duk_handle_ecma_call_setup().

◆ duk__handle_executor_error()

DUK_LOCAL void duk__handle_executor_error ( duk_heap * heap,
duk_hthread * entry_thread,
duk_size_t entry_callstack_top,
duk_int_t entry_call_recursion_depth,
duk_jmpbuf * entry_jmpbuf_ptr )

Definition at line 67563 of file duktape-1.8.0/src/duktape.c.

67563 { \
67564 goto internal_error; \
67565 } while (0)
67566#endif
67567
67568#define DUK__SYNC_CURR_PC() do { \
67569 duk_activation *act; \
67570 act = thr->callstack + thr->callstack_top - 1; \
67571 act->curr_pc = curr_pc; \
67572 } while (0)
67573#define DUK__SYNC_AND_NULL_CURR_PC() do { \
67574 duk_activation *act; \
67575 act = thr->callstack + thr->callstack_top - 1; \
67576 act->curr_pc = curr_pc; \
67577 thr->ptr_curr_pc = NULL; \
67578 } while (0)
67579
67581 duk_hthread *entry_thread,
67582 duk_size_t entry_callstack_top,
67583 duk_int_t entry_call_recursion_depth,
67584 duk_jmpbuf *entry_jmpbuf_ptr) {
67585 duk_small_uint_t lj_ret;
67586
67587 /* Longjmp callers are required to sync-and-null thr->ptr_curr_pc
67588 * before longjmp.
67589 */
67590 DUK_ASSERT(heap->curr_thread != NULL);
67592
67593 /* XXX: signalling the need to shrink check (only if unwound) */
67594
67595 /* Must be restored here to handle e.g. yields properly. */
67596 heap->call_recursion_depth = entry_call_recursion_depth;
67597
67598 /* Switch to caller's setjmp() catcher so that if an error occurs
67599 * during error handling, it is always propagated outwards instead
67600 * of causing an infinite loop in our own handler.
67601 */
67602 heap->lj.jmpbuf_ptr = (duk_jmpbuf *) entry_jmpbuf_ptr;
67603
DUK_LOCAL void duk__handle_executor_error(duk_heap *heap, duk_hthread *entry_thread, duk_size_t entry_callstack_top, duk_int_t entry_call_recursion_depth, duk_jmpbuf *entry_jmpbuf_ptr)

References duk_heap::call_recursion_depth, duk_heap::curr_thread, duk__handle_longjmp(), DUK_ASSERT, duk_ljstate::jmpbuf_ptr, duk_heap::lj, NULL, and duk_hthread::ptr_curr_pc.

◆ duk__handle_finally()

DUK_LOCAL void duk__handle_finally ( duk_hthread * thr,
duk_size_t cat_idx,
duk_tval * tv_val_unstable,
duk_small_uint_t lj_type )

Definition at line 66337 of file duktape-1.8.0/src/duktape.c.

66348 : %!iO", (duk_heaphdr *) new_env));
66349 }
66350
66351 DUK_CAT_CLEAR_CATCH_ENABLED(&thr->catchstack[cat_idx]);
66352}
66353
66354DUK_LOCAL void duk__handle_finally(duk_hthread *thr, duk_size_t cat_idx, duk_tval *tv_val_unstable, duk_small_uint_t lj_type) {
66355 duk_activation *act;
66356
66357 DUK_ASSERT(thr != NULL);
66358 DUK_ASSERT(tv_val_unstable != NULL);
66359
66360 duk__set_catcher_regs(thr, cat_idx, tv_val_unstable, lj_type);

◆ duk__handle_label()

DUK_LOCAL void duk__handle_label ( duk_hthread * thr,
duk_size_t cat_idx,
duk_small_uint_t lj_type )

Definition at line 66362 of file duktape-1.8.0/src/duktape.c.

66379 {
66380 duk_activation *act;
66381
66382 DUK_ASSERT(thr != NULL);
66383
66384 DUK_ASSERT(thr->callstack_top >= 1);
66385 act = thr->callstack + thr->callstack_top - 1;
66386

◆ duk__handle_longjmp()

DUK_LOCAL duk_small_uint_t duk__handle_longjmp ( duk_hthread * thr,
duk_hthread * entry_thread,
duk_size_t entry_callstack_top )

Definition at line 66413 of file duktape-1.8.0/src/duktape.c.

66432 {
66433 duk_size_t entry_callstack_index;
66435
66436 DUK_ASSERT(thr != NULL);
66437 DUK_ASSERT(entry_thread != NULL);
66438 DUK_ASSERT(entry_callstack_top > 0); /* guarantees entry_callstack_top - 1 >= 0 */
66439
66440 entry_callstack_index = entry_callstack_top - 1;
66441
66442 /* 'thr' is the current thread, as no-one resumes except us and we
66443 * switch 'thr' in that case.
66444 */
66445 DUK_ASSERT(thr == thr->heap->curr_thread);
66446
66447 /*
66448 * (Re)try handling the longjmp.
66449 *
66450 * A longjmp handler may convert the longjmp to a different type and
66451 * "virtually" rethrow by goto'ing to 'check_longjmp'. Before the goto,
66452 * the following must be updated:
66453 * - the heap 'lj' state
66454 * - 'thr' must reflect the "throwing" thread
66455 */
66456
66457 check_longjmp:
66458
66459 DUK_DD(DUK_DDPRINT("handling longjmp: type=%ld, value1=%!T, value2=%!T, iserror=%ld",
66460 (long) thr->heap->lj.type,
66461 (duk_tval *) &thr->heap->lj.value1,
66462 (duk_tval *) &thr->heap->lj.value2,
66463 (long) thr->heap->lj.iserror));
66464
66465 switch (thr->heap->lj.type) {
66466
66467 case DUK_LJ_TYPE_RESUME: {
66468 /*
66469 * Note: lj.value1 is 'value', lj.value2 is 'resumee'.
66470 * This differs from YIELD.
66471 */
66472
66473 duk_tval *tv;
66474 duk_tval *tv2;
66475 duk_size_t act_idx;
66476 duk_hthread *resumee;
66477
66478 /* duk_bi_duk_object_yield() and duk_bi_duk_object_resume() ensure all of these are met */
66479
66480 DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING); /* unchanged by Duktape.Thread.resume() */
66481 DUK_ASSERT(thr->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */
66486 DUK_HOBJECT_IS_COMPILEDFUNCTION(DUK_ACT_GET_FUNC(thr->callstack + thr->callstack_top - 2))); /* an Ecmascript function */
66487 DUK_ASSERT_DISABLE((thr->callstack + thr->callstack_top - 2)->idx_retval >= 0); /* unsigned */
66488
66489 tv = &thr->heap->lj.value2; /* resumee */
66493 resumee = (duk_hthread *) DUK_TVAL_GET_OBJECT(tv);
66494
66495 DUK_ASSERT(resumee != NULL);
66496 DUK_ASSERT(resumee->resumer == NULL);
66498 resumee->state == DUK_HTHREAD_STATE_YIELDED); /* checked by Duktape.Thread.resume() */
66500 resumee->callstack_top >= 2); /* YIELDED: Ecmascript activation + Duktape.Thread.yield() activation */
66502 (DUK_ACT_GET_FUNC(resumee->callstack + resumee->callstack_top - 1) != NULL &&
66504 ((duk_hnativefunction *) DUK_ACT_GET_FUNC(resumee->callstack + resumee->callstack_top - 1))->func == duk_bi_thread_yield));
66506 (DUK_ACT_GET_FUNC(resumee->callstack + resumee->callstack_top - 2) != NULL &&
66507 DUK_HOBJECT_IS_COMPILEDFUNCTION(DUK_ACT_GET_FUNC(resumee->callstack + resumee->callstack_top - 2)))); /* an Ecmascript function */
66509 (resumee->callstack + resumee->callstack_top - 2)->idx_retval >= 0); /* idx_retval unsigned */
66511 resumee->callstack_top == 0); /* INACTIVE: no activation, single function value on valstack */
66513 (resumee->valstack_top == resumee->valstack + 1 &&
66514 DUK_TVAL_IS_OBJECT(resumee->valstack_top - 1) &&
66516
66517 if (thr->heap->lj.iserror) {
66518 /*
66519 * Throw the error in the resumed thread's context; the
66520 * error value is pushed onto the resumee valstack.
66521 *
66522 * Note: the callstack of the target may empty in this case
66523 * too (i.e. the target thread has never been resumed). The
66524 * value stack will contain the initial function in that case,
66525 * which we simply ignore.
66526 */
66527
66528 resumee->resumer = thr;
66531 DUK_HEAP_SWITCH_THREAD(thr->heap, resumee);
66532 thr = resumee;
66533
66534 thr->heap->lj.type = DUK_LJ_TYPE_THROW;
66535
66536 /* thr->heap->lj.value1 is already the value to throw */
66537 /* thr->heap->lj.value2 is 'thread', will be wiped out at the end */
66538
66539 DUK_ASSERT(thr->heap->lj.iserror); /* already set */
66540
66541 DUK_DD(DUK_DDPRINT("-> resume with an error, converted to a throw in the resumee, propagate"));
66542 goto check_longjmp;
66543 } else if (resumee->state == DUK_HTHREAD_STATE_YIELDED) {
66544 act_idx = resumee->callstack_top - 2; /* Ecmascript function */
66545 DUK_ASSERT_DISABLE(resumee->callstack[act_idx].idx_retval >= 0); /* unsigned */
66546
66547 tv = resumee->valstack + resumee->callstack[act_idx].idx_retval; /* return value from Duktape.Thread.yield() */
66548 DUK_ASSERT(tv >= resumee->valstack && tv < resumee->valstack_top);
66549 tv2 = &thr->heap->lj.value1;
66550 DUK_TVAL_SET_TVAL_UPDREF(thr, tv, tv2); /* side effects */
66551
66552 duk_hthread_callstack_unwind(resumee, act_idx + 1); /* unwind to 'yield' caller */
66553
66554 /* no need to unwind catchstack */
66555
66556 duk__reconfig_valstack_ecma_return(resumee, act_idx);
66557
66558 resumee->resumer = thr;
66561 DUK_HEAP_SWITCH_THREAD(thr->heap, resumee);
66562#if 0
66563 thr = resumee; /* not needed, as we exit right away */
66564#endif
66565 DUK_DD(DUK_DDPRINT("-> resume with a value, restart execution in resumee"));
66566 retval = DUK__LONGJMP_RESTART;
66567 goto wipe_and_return;
66568 } else {
66569 duk_small_uint_t call_flags;
66570 duk_bool_t setup_rc;
66571
66572 /* resumee: [... initial_func] (currently actually: [initial_func]) */
66573
66574 duk_push_undefined((duk_context *) resumee);
66575 tv = &thr->heap->lj.value1;
66576 duk_push_tval((duk_context *) resumee, tv);
66577
66578 /* resumee: [... initial_func undefined(= this) resume_value ] */
66579
66580 call_flags = DUK_CALL_FLAG_IS_RESUME; /* is resume, not a tail call */
66581
66582 setup_rc = duk_handle_ecma_call_setup(resumee,
66583 1, /* num_stack_args */
66584 call_flags); /* call_flags */
66585 if (setup_rc == 0) {
66586 /* Shouldn't happen but check anyway. */
66588 }
66589
66590 resumee->resumer = thr;
66593 DUK_HEAP_SWITCH_THREAD(thr->heap, resumee);
66594#if 0
66595 thr = resumee; /* not needed, as we exit right away */
66596#endif
66597 DUK_DD(DUK_DDPRINT("-> resume with a value, restart execution in resumee"));
66598 retval = DUK__LONGJMP_RESTART;
66599 goto wipe_and_return;
66600 }
66602 break; /* never here */
66603 }
66604
66605 case DUK_LJ_TYPE_YIELD: {
66606 /*
66607 * Currently only allowed only if yielding thread has only
66608 * Ecmascript activations (except for the Duktape.Thread.yield()
66609 * call at the callstack top) and none of them constructor
66610 * calls.
66611 *
66612 * This excludes the 'entry' thread which will always have
66613 * a preventcount > 0.
66614 */
66615
66616 duk_hthread *resumer;
66617
66618 /* duk_bi_duk_object_yield() and duk_bi_duk_object_resume() ensure all of these are met */
66619
66620 DUK_ASSERT(thr != entry_thread); /* Duktape.Thread.yield() should prevent */
66621 DUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING); /* unchanged from Duktape.Thread.yield() */
66622 DUK_ASSERT(thr->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.yield() activation */
66627 DUK_HOBJECT_IS_COMPILEDFUNCTION(DUK_ACT_GET_FUNC(thr->callstack + thr->callstack_top - 2))); /* an Ecmascript function */
66628 DUK_ASSERT_DISABLE((thr->callstack + thr->callstack_top - 2)->idx_retval >= 0); /* unsigned */
66629
66630 resumer = thr->resumer;
66631
66632 DUK_ASSERT(resumer != NULL);
66633 DUK_ASSERT(resumer->state == DUK_HTHREAD_STATE_RESUMED); /* written by a previous RESUME handling */
66634 DUK_ASSERT(resumer->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */
66635 DUK_ASSERT(DUK_ACT_GET_FUNC(resumer->callstack + resumer->callstack_top - 1) != NULL &&
66637 ((duk_hnativefunction *) DUK_ACT_GET_FUNC(resumer->callstack + resumer->callstack_top - 1))->func == duk_bi_thread_resume);
66638 DUK_ASSERT(DUK_ACT_GET_FUNC(resumer->callstack + resumer->callstack_top - 2) != NULL &&
66639 DUK_HOBJECT_IS_COMPILEDFUNCTION(DUK_ACT_GET_FUNC(resumer->callstack + resumer->callstack_top - 2))); /* an Ecmascript function */
66640 DUK_ASSERT_DISABLE((resumer->callstack + resumer->callstack_top - 2)->idx_retval >= 0); /* unsigned */
66641
66642 if (thr->heap->lj.iserror) {
66644 thr->resumer = NULL;
66646 DUK_HEAP_SWITCH_THREAD(thr->heap, resumer);
66647 thr = resumer;
66648
66649 thr->heap->lj.type = DUK_LJ_TYPE_THROW;
66650 /* lj.value1 is already set */
66651 DUK_ASSERT(thr->heap->lj.iserror); /* already set */
66652
66653 DUK_DD(DUK_DDPRINT("-> yield an error, converted to a throw in the resumer, propagate"));
66654 goto check_longjmp;
66655 } else {
66656 duk__handle_yield(thr, resumer, resumer->callstack_top - 2, &thr->heap->lj.value1);
66657
66659 thr->resumer = NULL;
66661 DUK_HEAP_SWITCH_THREAD(thr->heap, resumer);
66662#if 0
66663 thr = resumer; /* not needed, as we exit right away */
66664#endif
66665
66666 DUK_DD(DUK_DDPRINT("-> yield a value, restart execution in resumer"));
66667 retval = DUK__LONGJMP_RESTART;
66668 goto wipe_and_return;
66669 }
66671 break; /* never here */
66672 }
66673
66674 case DUK_LJ_TYPE_THROW: {
66675 /*
66676 * Three possible outcomes:
66677 * * A try or finally catcher is found => resume there.
66678 * (or)
66679 * * The error propagates to the bytecode executor entry
66680 * level (and we're in the entry thread) => rethrow
66681 * with a new longjmp(), after restoring the previous
66682 * catchpoint.
66683 * * The error is not caught in the current thread, so
66684 * the thread finishes with an error. This works like
66685 * a yielded error, except that the thread is finished
66686 * and can no longer be resumed. (There is always a
66687 * resumer in this case.)
66688 *
66689 * Note: until we hit the entry level, there can only be
66690 * Ecmascript activations.
66691 */
66692
66693 duk_catcher *cat;
66694 duk_hthread *resumer;
66695
66696 cat = thr->catchstack + thr->catchstack_top - 1;
66697 while (cat >= thr->catchstack) {
66698 if (thr == entry_thread &&
66699 cat->callstack_index < entry_callstack_index) {
66700 /* entry level reached */
66701 break;
66702 }
66703
66704 if (DUK_CAT_HAS_CATCH_ENABLED(cat)) {
66706
66708 cat - thr->catchstack,
66709 &thr->heap->lj.value1,
66711
66712 DUK_DD(DUK_DDPRINT("-> throw caught by a 'catch' clause, restart execution"));
66713 retval = DUK__LONGJMP_RESTART;
66714 goto wipe_and_return;
66715 }
66716
66717 if (DUK_CAT_HAS_FINALLY_ENABLED(cat)) {
66720
66722 cat - thr->catchstack,
66723 &thr->heap->lj.value1,
66725
66726 DUK_DD(DUK_DDPRINT("-> throw caught by a 'finally' clause, restart execution"));
66727 retval = DUK__LONGJMP_RESTART;
66728 goto wipe_and_return;
66729 }
66730
66731 cat--;
66732 }
66733
66734 if (thr == entry_thread) {
66735 /* not caught by anything before entry level; rethrow and let the
66736 * final catcher unwind everything
66737 */
66738#if 0
66739 duk_hthread_catchstack_unwind(thr, (cat - thr->catchstack) + 1); /* leave 'cat' as top catcher (also works if catchstack exhausted) */
66740 duk_hthread_callstack_unwind(thr, entry_callstack_index + 1);
66741
66742#endif
66743 DUK_D(DUK_DPRINT("-> throw propagated up to entry level, rethrow and exit bytecode executor"));
66744 retval = DUK__LONGJMP_RETHROW;
66745 goto just_return;
66746 /* Note: MUST NOT wipe_and_return here, as heap->lj must remain intact */
66747 }
66748
66749 DUK_DD(DUK_DDPRINT("-> throw not caught by current thread, yield error to resumer and recheck longjmp"));
66750
66751 /* not caught by current thread, thread terminates (yield error to resumer);
66752 * note that this may cause a cascade if the resumer terminates with an uncaught
66753 * exception etc (this is OK, but needs careful testing)
66754 */
66755
66756 DUK_ASSERT(thr->resumer != NULL);
66757 DUK_ASSERT(thr->resumer->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */
66760 ((duk_hnativefunction *) DUK_ACT_GET_FUNC(thr->resumer->callstack + thr->resumer->callstack_top - 1))->func == duk_bi_thread_resume); /* Duktape.Thread.resume() */
66762 DUK_HOBJECT_IS_COMPILEDFUNCTION(DUK_ACT_GET_FUNC(thr->resumer->callstack + thr->resumer->callstack_top - 2))); /* an Ecmascript function */
66763
66764 resumer = thr->resumer;
66765
66766 /* reset longjmp */
66767
66768 DUK_ASSERT(thr->heap->lj.type == DUK_LJ_TYPE_THROW); /* already set */
66769 /* lj.value1 already set */
66770
66771 duk_hthread_terminate(thr); /* updates thread state, minimizes its allocations */
66773
66774 thr->resumer = NULL;
66776 DUK_HEAP_SWITCH_THREAD(thr->heap, resumer);
66777 thr = resumer;
66778 goto check_longjmp;
66779 }
66780
66781 case DUK_LJ_TYPE_BREAK: /* pseudotypes, not used in actual longjmps */
66783 case DUK_LJ_TYPE_RETURN:
66784 case DUK_LJ_TYPE_NORMAL:
66785 default: {
66786 /* should never happen, but be robust */
66787 DUK_D(DUK_DPRINT("caught unknown longjmp type %ld, treat as internal error", (long) thr->heap->lj.type));
66788 goto convert_to_internal_error;
66789 }
66790
66791 } /* end switch */
66792
66794
66795 wipe_and_return:
66796 /* this is not strictly necessary, but helps debugging */
#define DUK_LJ_TYPE_CONTINUE
#define DUK_LJ_TYPE_YIELD
DUK_INTERNAL_DECL duk_bool_t duk_handle_ecma_call_setup(duk_hthread *thr, duk_idx_t num_stack_args, duk_small_uint_t call_flags)
#define DUK_LJ_TYPE_RETURN
#define DUK_CALL_FLAG_IS_RESUME
DUK_LOCAL void duk__reconfig_valstack_ecma_return(duk_hthread *thr, duk_size_t act_idx)
#define DUK_HTHREAD_STATE_RESUMED
#define DUK__LONGJMP_RETHROW
DUK_INTERNAL_DECL duk_ret_t duk_bi_thread_resume(duk_context *ctx)
#define DUK__LONGJMP_RESTART
#define DUK_LJ_TYPE_RESUME
#define DUK_LJ_TYPE_BREAK
DUK_LOCAL void duk__handle_yield(duk_hthread *thr, duk_hthread *resumer, duk_size_t act_idx, duk_tval *tv_val_unstable)
DUK_INTERNAL_DECL void duk_hthread_terminate(duk_hthread *thr)
#define DUK_CAT_HAS_CATCH_ENABLED(c)
#define DUK_HTHREAD_STATE_YIELDED
#define DUK_LJ_TYPE_NORMAL
#define DUK_HTHREAD_STATE_TERMINATED
DUK_INTERNAL_DECL duk_ret_t duk_bi_thread_yield(duk_context *ctx)

Referenced by duk__handle_executor_error().

◆ duk__handle_oldenv_for_call()

DUK_LOCAL void duk__handle_oldenv_for_call ( duk_hthread * thr,
duk_hobject * func,
duk_activation * act )

Definition at line 55507 of file duktape-1.8.0/src/duktape.c.

55526 {
55527 duk_tval *tv;
55528
55529 DUK_ASSERT(thr != NULL);
55530 DUK_ASSERT(func != NULL);
55531 DUK_ASSERT(act != NULL);
55534
55536 if (tv) {
55539 act->lex_env = DUK_TVAL_GET_OBJECT(tv);

Referenced by duk_handle_ecma_call_setup().

◆ duk__handle_put_array_length()

DUK_LOCAL_DECL duk_bool_t duk__handle_put_array_length ( duk_hthread * thr,
duk_hobject * obj )

Definition at line 50543 of file duktape-1.8.0/src/duktape.c.

50543 : update length (done by caller)"));
50544
50545 *out_result_len = target_len;
50546
50547 if (target_len == new_len) {
50548 DUK_DDD(DUK_DDDPRINT("target_len matches new_len, return success"));
50549 return 1;
50550 }
50551 DUK_DDD(DUK_DDDPRINT("target_len does not match new_len (some entry prevented "
50552 "full length adjustment), return error"));
50553 return 0;
50554 }
50555
50556 DUK_UNREACHABLE();
50557}
50558
50559/* XXX: is valstack top best place for argument? */
50560DUK_LOCAL duk_bool_t duk__handle_put_array_length(duk_hthread *thr, duk_hobject *obj) {
50561 duk_context *ctx = (duk_context *) thr;
50562 duk_propdesc desc;
50563 duk_uint32_t old_len;
50564 duk_uint32_t new_len;
50565 duk_uint32_t result_len;
50566 duk_tval *tv;
50567 duk_bool_t rc;
50568
50569 DUK_DDD(DUK_DDDPRINT("handling a put operation to array 'length' exotic property, "
50570 "new val: %!T",
50571 (duk_tval *) duk_get_tval(ctx, -1)));
50572
50573 DUK_ASSERT(thr != NULL);
50574 DUK_ASSERT(ctx != NULL);
50575 DUK_ASSERT(obj != NULL);
50576
50577 DUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);
50578
50579 DUK_ASSERT(duk_is_valid_index(ctx, -1));
50580
50581 /*
50582 * Get old and new length
50583 */
50584
50585 old_len = duk__get_old_array_length(thr, obj, &desc);
50586 duk_dup(ctx, -1); /* [in_val in_val] */
50587 new_len = duk__to_new_array_length_checked(thr); /* -> [in_val] */
50588 DUK_DDD(DUK_DDDPRINT("old_len=%ld, new_len=%ld", (long) old_len, (long) new_len));
50589
50590 /*
50591 * Writability check
50592 */
50593
50594 if (!(desc.flags & DUK_PROPDESC_FLAG_WRITABLE)) {
50595 DUK_DDD(DUK_DDDPRINT("length is not writable, fail"));
50596 return 0;
50597 }
50598
50599 /*
50600 * New length not lower than old length => no changes needed
50601 * (not even array allocation).
50602 */
50603
50604 if (new_len >= old_len) {
50605 DUK_DDD(DUK_DDDPRINT("new length is higher than old length, just update length, no deletions"));
50606
50607 DUK_ASSERT(desc.e_idx >= 0);
50608 DUK_ASSERT(!DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, obj, desc.e_idx));
50609 tv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, desc.e_idx);
50610 DUK_ASSERT(DUK_TVAL_IS_NUMBER(tv));
50611 /* no decref needed for a number */
50612 DUK_TVAL_SET_FASTINT_U32(tv, new_len);
50613 DUK_ASSERT(DUK_TVAL_IS_NUMBER(tv));
50614 return 1;
50615 }
50616
50617 DUK_DDD(DUK_DDDPRINT("new length is lower than old length, probably must delete entries"));
50618
50619 /*
50620 * New length lower than old length => delete elements, then
50621 * update length.
50622 *
50623 * Note: even though a bunch of elements have been deleted, the 'desc' is
50624 * still valid as properties haven't been resized (and entries compacted).
static const char * match(MatchState *ms, const char *s, const char *p)

Referenced by duk_hobject_putprop().

◆ duk__handle_put_array_length_smaller()

DUK_LOCAL_DECL duk_bool_t duk__handle_put_array_length_smaller ( duk_hthread * thr,
duk_hobject * obj,
duk_uint32_t old_len,
duk_uint32_t new_len,
duk_bool_t force_flag,
duk_uint32_t * out_result_len )

Definition at line 50360 of file duktape-1.8.0/src/duktape.c.

50362 {
50364 }
50365 duk_pop(ctx);
50366 return res;
50367}
50368
50369/* Delete elements required by a smaller length, taking into account
50370 * potentially non-configurable elements. Returns non-zero if all
50371 * elements could be deleted, and zero if all or some elements could
50372 * not be deleted. Also writes final "target length" to 'out_result_len'.
50373 * This is the length value that should go into the 'length' property
50374 * (must be set by the caller). Never throws an error.
50375 */
50378 duk_hobject *obj,
50379 duk_uint32_t old_len,
50380 duk_uint32_t new_len,
50381 duk_bool_t force_flag,
50382 duk_uint32_t *out_result_len) {
50383 duk_uint32_t target_len;
50385 duk_uint32_t arr_idx;
50386 duk_hstring *key;
50387 duk_tval *tv;
50388 duk_bool_t rc;
50389
50390 DUK_DDD(DUK_DDDPRINT("new array length smaller than old (%ld -> %ld), "
50391 "probably need to remove elements",
50392 (long) old_len, (long) new_len));
50393
50394 /*
50395 * New length is smaller than old length, need to delete properties above
50396 * the new length.
50397 *
50398 * If array part exists, this is straightforward: array entries cannot
50399 * be non-configurable so this is guaranteed to work.
50400 *
50401 * If array part does not exist, array-indexed values are scattered
50402 * in the entry part, and some may not be configurable (preventing length
50403 * from becoming lower than their index + 1). To handle the algorithm
50404 * in E5 Section 15.4.5.1, step l correctly, we scan the entire property
50405 * set twice.
50406 */
50407
50408 DUK_ASSERT(thr != NULL);
50409 DUK_ASSERT(obj != NULL);
50410 DUK_ASSERT(new_len < old_len);
50411 DUK_ASSERT(out_result_len != NULL);
50413
50414 if (DUK_HOBJECT_HAS_ARRAY_PART(obj)) {
50415 /*
50416 * All defined array-indexed properties are in the array part
50417 * (we assume the array part is comprehensive), and all array
50418 * entries are writable, configurable, and enumerable. Thus,
50419 * nothing can prevent array entries from being deleted.
50420 */
50421
50422 DUK_DDD(DUK_DDDPRINT("have array part, easy case"));
50423
50424 if (old_len < DUK_HOBJECT_GET_ASIZE(obj)) {
50425 /* XXX: assertion that entries >= old_len are already unused */
50426 i = old_len;
50427 } else {
50428 i = DUK_HOBJECT_GET_ASIZE(obj);
50429 }
50431
50432 while (i > new_len) {
50433 i--;
50434 tv = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, i);
50435 DUK_TVAL_SET_UNUSED_UPDREF(thr, tv); /* side effects */
50436 }
50437
50438 *out_result_len = new_len;
50439 return 1;
50440 } else {
50441 /*
50442 * Entries part is a bit more complex
50443 */
50444
50445 /* Stage 1: find highest preventing non-configurable entry (if any).
50446 * When forcing, ignore non-configurability.
50447 */
50448
50449 DUK_DDD(DUK_DDDPRINT("no array part, slow case"));
50450
50451 DUK_DDD(DUK_DDDPRINT("array length write, no array part, stage 1: find target_len "
50452 "(highest preventing non-configurable entry (if any))"));
50453
50454 target_len = new_len;
50455 if (force_flag) {
50456 DUK_DDD(DUK_DDDPRINT("array length write, no array part; force flag -> skip stage 1"));
50457 goto skip_stage1;
50458 }
50459 for (i = 0; i < DUK_HOBJECT_GET_ENEXT(obj); i++) {
50460 key = DUK_HOBJECT_E_GET_KEY(thr->heap, obj, i);
50461 if (!key) {
50462 DUK_DDD(DUK_DDDPRINT("skip entry index %ld: null key", (long) i));
50463 continue;
50464 }
50465 if (!DUK_HSTRING_HAS_ARRIDX(key)) {
50466 DUK_DDD(DUK_DDDPRINT("skip entry index %ld: key not an array index", (long) i));
50467 continue;
50468 }
50469
50470 DUK_ASSERT(DUK_HSTRING_HAS_ARRIDX(key)); /* XXX: macro checks for array index flag, which is unnecessary here */
50471 arr_idx = DUK_HSTRING_GET_ARRIDX_SLOW(key);
50472 DUK_ASSERT(arr_idx != DUK__NO_ARRAY_INDEX);
50473 DUK_ASSERT(arr_idx < old_len); /* consistency requires this */
50474
50475 if (arr_idx < new_len) {
50476 DUK_DDD(DUK_DDDPRINT("skip entry index %ld: key is array index %ld, below new_len",
50477 (long) i, (long) arr_idx));
50478 continue;
50479 }
50480 if (DUK_HOBJECT_E_SLOT_IS_CONFIGURABLE(thr->heap, obj, i)) {
50481 DUK_DDD(DUK_DDDPRINT("skip entry index %ld: key is a relevant array index %ld, but configurable",
50482 (long) i, (long) arr_idx));
50483 continue;
50484 }
50485
50486 /* relevant array index is non-configurable, blocks write */
50487 if (arr_idx >= target_len) {
50488 DUK_DDD(DUK_DDDPRINT("entry at index %ld has arr_idx %ld, is not configurable, "
50489 "update target_len %ld -> %ld",
50490 (long) i, (long) arr_idx, (long) target_len,
50491 (long) (arr_idx + 1)));
50492 target_len = arr_idx + 1;
50493 }
50494 }
50495 skip_stage1:
50496
50497 /* stage 2: delete configurable entries above target length */
50498
50499 DUK_DDD(DUK_DDDPRINT("old_len=%ld, new_len=%ld, target_len=%ld",
50500 (long) old_len, (long) new_len, (long) target_len));
50501
50502 DUK_DDD(DUK_DDDPRINT("array length write, no array part, stage 2: remove "
50503 "entries >= target_len"));
50504
50505 for (i = 0; i < DUK_HOBJECT_GET_ENEXT(obj); i++) {
50506 key = DUK_HOBJECT_E_GET_KEY(thr->heap, obj, i);
50507 if (!key) {
50508 DUK_DDD(DUK_DDDPRINT("skip entry index %ld: null key", (long) i));
50509 continue;
50510 }
50511 if (!DUK_HSTRING_HAS_ARRIDX(key)) {
50512 DUK_DDD(DUK_DDDPRINT("skip entry index %ld: key not an array index", (long) i));
50513 continue;
50514 }
50515
50516 DUK_ASSERT(DUK_HSTRING_HAS_ARRIDX(key)); /* XXX: macro checks for array index flag, which is unnecessary here */
50517 arr_idx = DUK_HSTRING_GET_ARRIDX_SLOW(key);
50518 DUK_ASSERT(arr_idx != DUK__NO_ARRAY_INDEX);
50519 DUK_ASSERT(arr_idx < old_len); /* consistency requires this */
50520
50521 if (arr_idx < target_len) {
50522 DUK_DDD(DUK_DDDPRINT("skip entry index %ld: key is array index %ld, below target_len",
50523 (long) i, (long) arr_idx));
50524 continue;
50525 }
50526 DUK_ASSERT(force_flag || DUK_HOBJECT_E_SLOT_IS_CONFIGURABLE(thr->heap, obj, i)); /* stage 1 guarantees */
50527
50528 DUK_DDD(DUK_DDDPRINT("delete entry index %ld: key is array index %ld",
50529 (long) i, (long) arr_idx));
50530
50531 /*
50532 * Slow delete, but we don't care as we're already in a very slow path.
50533 * The delete always succeeds: key has no exotic behavior, property
50534 * is configurable, and no resize occurs.
50535 */
50536 rc = duk_hobject_delprop_raw(thr, obj, key, force_flag ? DUK_DELPROP_FLAG_FORCE : 0);
50537 DUK_UNREF(rc);
50538 DUK_ASSERT(rc != 0);
50539 }
50540
DUK_LOCAL_DECL duk_bool_t duk__handle_put_array_length_smaller(duk_hthread *thr, duk_hobject *obj, duk_uint32_t old_len, duk_uint32_t new_len, duk_bool_t force_flag, duk_uint32_t *out_result_len)
#define DUK_STR_INVALID_ARRAY_LENGTH
#define DUK_TVAL_SET_UNUSED_UPDREF
#define DUK_DELPROP_FLAG_FORCE
DUK_INTERNAL_DECL duk_bool_t duk_hobject_delprop_raw(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_small_uint_t flags)
#define DUK_HSTRING_GET_ARRIDX_SLOW(h)
#define DUK_HOBJECT_E_SLOT_IS_CONFIGURABLE(heap, h, i)

Referenced by duk_hobject_define_property_helper().

◆ duk__handle_return()

DUK_LOCAL duk_small_uint_t duk__handle_return ( duk_hthread * thr,
duk_hthread * entry_thread,
duk_size_t entry_callstack_top )

Definition at line 66876 of file duktape-1.8.0/src/duktape.c.

66895 {
66896 duk_tval *tv1;
66897 duk_tval *tv2;
66898 duk_hthread *resumer;
66899 duk_catcher *cat;
66900 duk_size_t new_cat_top;
66901 duk_size_t orig_callstack_index;
66902
66903 /* We can directly access value stack here. */
66904
66905 DUK_ASSERT(thr != NULL);
66906 DUK_ASSERT(entry_thread != NULL);
66907 DUK_ASSERT(thr->valstack_top - 1 >= thr->valstack_bottom);
66908 tv1 = thr->valstack_top - 1;
66909 DUK_TVAL_CHKFAST_INPLACE(tv1); /* fastint downgrade check for return values */
66910
66911 /*
66912 * Four possible outcomes:
66913 *
66914 * 1. A 'finally' in the same function catches the 'return'.
66915 * It may continue to propagate when 'finally' is finished,
66916 * or it may be neutralized by 'finally' (both handled by
66917 * ENDFIN).
66918 *
66919 * 2. The return happens at the entry level of the bytecode
66920 * executor, so return from the executor (in C stack).
66921 *
66922 * 3. There is a calling (Ecmascript) activation in the call
66923 * stack => return to it, in the same executor instance.
66924 *
66925 * 4. There is no calling activation, and the thread is
66926 * terminated. There is always a resumer in this case,
66927 * which gets the return value similarly to a 'yield'
66928 * (except that the current thread can no longer be
66929 * resumed).
66930 */
66931
66932 DUK_ASSERT(thr != NULL);
66933 DUK_ASSERT(thr->callstack_top >= 1);
66934 DUK_ASSERT(thr->catchstack != NULL);
66935
66936 /* XXX: does not work if thr->catchstack is NULL */
66937 /* XXX: does not work if thr->catchstack is allocated but lowest pointer */
66938
66939 cat = thr->catchstack + thr->catchstack_top - 1; /* may be < thr->catchstack initially */
66940 DUK_ASSERT(thr->callstack_top > 0); /* ensures callstack_top - 1 >= 0 */
66941 orig_callstack_index = thr->callstack_top - 1;
66942
66943 while (cat >= thr->catchstack) {
66944 if (cat->callstack_index != orig_callstack_index) {
66945 break;
66946 }
66947 if (DUK_CAT_GET_TYPE(cat) == DUK_CAT_TYPE_TCF &&
66949 duk_size_t cat_idx;
66950
66951 cat_idx = (duk_size_t) (cat - thr->catchstack); /* get before side effects */
66952
66953 DUK_ASSERT(thr->valstack_top - 1 >= thr->valstack_bottom);
66954 duk__handle_finally(thr, cat_idx, thr->valstack_top - 1, DUK_LJ_TYPE_RETURN);
66955
66956 DUK_DD(DUK_DDPRINT("-> return caught by 'finally', restart execution"));
66957 return DUK__RETHAND_RESTART;
66958 }
66959 cat--;
66960 }
66961 /* If out of catchstack, cat = thr->catchstack - 1;
66962 * new_cat_top will be 0 in that case.
66963 */
66964 new_cat_top = (duk_size_t) ((cat + 1) - thr->catchstack);
66965 cat = NULL; /* avoid referencing, invalidated */
66966
66967 DUK_DDD(DUK_DDDPRINT("no catcher in catch stack, return to calling activation / yield"));
66968
66969 if (thr == entry_thread &&
66970 thr->callstack_top == entry_callstack_top) {
66971 /* Return to the bytecode executor caller which will unwind stacks.
66972 * Return value is already on the stack top: [ ... retval ].
66973 */
66974
66975 /* XXX: could unwind catchstack here, so that call handling
66976 * didn't need to do that?
66977 */
66978 DUK_DDD(DUK_DDDPRINT("-> return propagated up to entry level, exit bytecode executor"));
66979 return DUK__RETHAND_FINISHED;
66980 }
66981
66982 if (thr->callstack_top >= 2) {
66983 /* There is a caller; it MUST be an Ecmascript caller (otherwise it would
66984 * match entry level check)
66985 */
66986
66987 DUK_DDD(DUK_DDDPRINT("return to Ecmascript caller, idx_retval=%ld, lj_value1=%!T",
66988 (long) (thr->callstack + thr->callstack_top - 2)->idx_retval,
66989 (duk_tval *) &thr->heap->lj.value1));
66990
66991 DUK_ASSERT(DUK_HOBJECT_IS_COMPILEDFUNCTION(DUK_ACT_GET_FUNC(thr->callstack + thr->callstack_top - 2))); /* must be ecmascript */
66992
66993 tv1 = thr->valstack + (thr->callstack + thr->callstack_top - 2)->idx_retval;
66994 DUK_ASSERT(thr->valstack_top - 1 >= thr->valstack_bottom);
66995 tv2 = thr->valstack_top - 1;
66996 DUK_TVAL_SET_TVAL_UPDREF(thr, tv1, tv2); /* side effects */
66997
66998 DUK_DDD(DUK_DDDPRINT("return value at idx_retval=%ld is %!T",
66999 (long) (thr->callstack + thr->callstack_top - 2)->idx_retval,
67000 (duk_tval *) (thr->valstack + (thr->callstack + thr->callstack_top - 2)->idx_retval)));
67001
67002 duk_hthread_catchstack_unwind(thr, new_cat_top); /* leave 'cat' as top catcher (also works if catchstack exhausted) */
67005
67006 DUK_DD(DUK_DDPRINT("-> return not intercepted, restart execution in caller"));
67007 return DUK__RETHAND_RESTART;
67008 }
67009
67010 DUK_DD(DUK_DDPRINT("no calling activation, thread finishes (similar to yield)"));
67011
67012 DUK_ASSERT(thr->resumer != NULL);
67013 DUK_ASSERT(thr->resumer->callstack_top >= 2); /* Ecmascript activation + Duktape.Thread.resume() activation */
67016 ((duk_hnativefunction *) DUK_ACT_GET_FUNC(thr->resumer->callstack + thr->resumer->callstack_top - 1))->func == duk_bi_thread_resume); /* Duktape.Thread.resume() */
67018 DUK_HOBJECT_IS_COMPILEDFUNCTION(DUK_ACT_GET_FUNC(thr->resumer->callstack + thr->resumer->callstack_top - 2))); /* an Ecmascript function */
67019 DUK_ASSERT_DISABLE((thr->resumer->callstack + thr->resumer->callstack_top - 2)->idx_retval >= 0); /* unsigned */
67022
67023 resumer = thr->resumer;
67024
#define DUK__RETHAND_FINISHED
#define DUK__RETHAND_RESTART

◆ duk__handle_safe_call_error()

DUK_LOCAL void duk__handle_safe_call_error ( duk_hthread * thr,
duk_idx_t idx_retbase,
duk_idx_t num_stack_rets,
duk_size_t entry_valstack_bottom_index,
duk_size_t entry_callstack_top,
duk_size_t entry_catchstack_top,
duk_jmpbuf * old_jmpbuf_ptr )

Definition at line 57133 of file duktape-1.8.0/src/duktape.c.

57135 {
57136 DUK_ERROR_API(thr, "not enough stack values for safe_call rc");
57137 }
57138
57139 DUK_ASSERT(thr->catchstack_top == entry_catchstack_top); /* no need to unwind */
57140 DUK_ASSERT(thr->callstack_top == entry_callstack_top);
57141
57142 duk__safe_call_adjust_valstack(thr, idx_retbase, num_stack_rets, rc);
57143 return;
57144
57145 thread_state_error:
57146 DUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, "invalid thread state for safe_call (%ld)", (long) thr->state);
57148}
57149
57151 duk_idx_t idx_retbase,
57152 duk_idx_t num_stack_rets,
57153 duk_size_t entry_valstack_bottom_index,
57154 duk_size_t entry_callstack_top,
57155 duk_size_t entry_catchstack_top,
57156 duk_jmpbuf *old_jmpbuf_ptr) {
57157 duk_context *ctx;
57158
57159 DUK_ASSERT(thr != NULL);
57160 ctx = (duk_context *) thr;
57162
57163 /*
57164 * Error during call. The error value is at heap->lj.value1.
57165 *
57166 * The very first thing we do is restore the previous setjmp catcher.
57167 * This means that any error in error handling will propagate outwards
57168 * instead of causing a setjmp() re-entry above.
57169 */
57170
57171 DUK_DDD(DUK_DDDPRINT("error caught during protected duk_handle_safe_call()"));
57172
57173 /* Other longjmp types are handled by executor before propagating
57174 * the error here.
57175 */
57177 DUK_ASSERT(thr->callstack_top >= entry_callstack_top);
57178 DUK_ASSERT(thr->catchstack_top >= entry_catchstack_top);
57179
57180 /* Note: either pointer may be NULL (at entry), so don't assert. */
57181 thr->heap->lj.jmpbuf_ptr = old_jmpbuf_ptr;
57182
57183 DUK_ASSERT(thr->catchstack_top >= entry_catchstack_top);
57184 DUK_ASSERT(thr->callstack_top >= entry_callstack_top);
57185 duk_hthread_catchstack_unwind(thr, entry_catchstack_top);
57187 duk_hthread_callstack_unwind(thr, entry_callstack_top);
57189 thr->valstack_bottom = thr->valstack + entry_valstack_bottom_index;
57190
57191 /* [ ... | (crud) ] */
57192
57193 /* XXX: space in valstack? see discussion in duk_handle_call_xxx(). */
57194 duk_push_tval(ctx, &thr->heap->lj.value1);
57195
57196 /* [ ... | (crud) errobj ] */
57197
57198 DUK_ASSERT(duk_get_top(ctx) >= 1); /* at least errobj must be on stack */
57199
57200 /* check that the valstack has space for the final amount and any
57201 * intermediate space needed; this is unoptimal but should be safe
57202 */
DUK_LOCAL void duk__safe_call_adjust_valstack(duk_hthread *thr, duk_idx_t idx_retbase, duk_idx_t num_stack_rets, duk_idx_t num_actual_rets)
DUK_LOCAL void duk__handle_safe_call_error(duk_hthread *thr, duk_idx_t idx_retbase, duk_idx_t num_stack_rets, duk_size_t entry_valstack_bottom_index, duk_size_t entry_callstack_top, duk_size_t entry_catchstack_top, duk_jmpbuf *old_jmpbuf_ptr)

◆ duk__handle_safe_call_inner()

DUK_LOCAL void duk__handle_safe_call_inner ( duk_hthread * thr,
duk_safe_call_function func,
duk_idx_t idx_retbase,
duk_idx_t num_stack_rets,
duk_size_t entry_valstack_bottom_index,
duk_size_t entry_callstack_top,
duk_size_t entry_catchstack_top )

Definition at line 57024 of file duktape-1.8.0/src/duktape.c.

57047 {
57048 duk_context *ctx;
57049 duk_ret_t rc;
57050
57051 DUK_ASSERT(thr != NULL);
57052 ctx = (duk_context *) thr;
57054 DUK_UNREF(entry_valstack_bottom_index);
57055 DUK_UNREF(entry_callstack_top);
57056 DUK_UNREF(entry_catchstack_top);
57057
57058 /*
57059 * Thread state check and book-keeping.
57060 */
57061
57062 if (thr == thr->heap->curr_thread) {
57063 /* same thread */
57064 if (thr->state != DUK_HTHREAD_STATE_RUNNING) {
57065 /* should actually never happen, but check anyway */
57066 goto thread_state_error;
57067 }
57068 } else {
57069 /* different thread */
57070 DUK_ASSERT(thr->heap->curr_thread == NULL ||
57072 if (thr->state != DUK_HTHREAD_STATE_INACTIVE) {
57073 goto thread_state_error;
57074 }
57075 DUK_HEAP_SWITCH_THREAD(thr->heap, thr);
57077
57078 /* Note: multiple threads may be simultaneously in the RUNNING
57079 * state, but not in the same "resume chain".
57080 */
57081 }
57082
57083 DUK_ASSERT(thr->heap->curr_thread == thr);
57085
57086 /*
57087 * Recursion limit check.
57088 *
57089 * Note: there is no need for an "ignore recursion limit" flag
57090 * for duk_handle_safe_call now.
57091 */
57092
57096 /* XXX: error message is a bit misleading: we reached a recursion
57097 * limit which is also essentially the same as a C callstack limit
57098 * (except perhaps with some relaxed threading assumptions).
57099 */
57101 }
57102 thr->heap->call_recursion_depth++;
57103
57104 /*
57105 * Valstack spare check
57106 */
57107
57108 duk_require_stack(ctx, 0); /* internal spare */
57109
57110 /*
57111 * Make the C call
57112 */
57113
57114 rc = func(ctx);
57115
57116 DUK_DDD(DUK_DDDPRINT("safe_call, func rc=%ld", (long) rc));
57117
57118 /*
57119 * Valstack manipulation for results.
57120 */
57121
57122 /* we're running inside the caller's activation, so no change in call/catch stack or valstack bottom */
57123 DUK_ASSERT(thr->callstack_top == entry_callstack_top);
57124 DUK_ASSERT(thr->catchstack_top == entry_catchstack_top);
57125 DUK_ASSERT(thr->valstack_bottom >= thr->valstack);
57126 DUK_ASSERT((duk_size_t) (thr->valstack_bottom - thr->valstack) == entry_valstack_bottom_index);
57128 DUK_ASSERT(thr->valstack_end >= thr->valstack_top);
57129
57130 if (rc < 0) {

◆ duk__handle_safe_call_shared()

DUK_LOCAL void duk__handle_safe_call_shared ( duk_hthread * thr,
duk_idx_t idx_retbase,
duk_idx_t num_stack_rets,
duk_int_t entry_call_recursion_depth,
duk_hthread * entry_curr_thread,
duk_uint_fast8_t entry_thread_state,
duk_instr_t ** entry_ptr_curr_pc )

Definition at line 57204 of file duktape-1.8.0/src/duktape.c.

57227 {
57228 duk_context *ctx;
57229
57230 DUK_ASSERT(thr != NULL);
57231 ctx = (duk_context *) thr;
57233 DUK_UNREF(ctx);
57234 DUK_UNREF(idx_retbase);
57235 DUK_UNREF(num_stack_rets);
57236
57237 /* Restore entry thread executor curr_pc stack frame pointer. */
57238 thr->ptr_curr_pc = entry_ptr_curr_pc;
57239
57240 /* XXX: because we unwind stacks above, thr->heap->curr_thread is at
57241 * risk of pointing to an already freed thread. This was indeed the
57242 * case in test-bug-multithread-valgrind.c, until duk_handle_call()
57243 * was fixed to restore thr->heap->curr_thread before rethrowing an
57244 * uncaught error.
57245 */
57246 DUK_HEAP_SWITCH_THREAD(thr->heap, entry_curr_thread); /* may be NULL */
57247 thr->state = (duk_uint8_t) entry_thread_state;
57248

◆ duk__handle_temproot()

DUK_LOCAL void duk__handle_temproot ( duk_heap * heap,
duk_heaphdr * hdr )

Definition at line 42548 of file duktape-1.8.0/src/duktape.c.

42563 {

◆ duk__handle_yield()

DUK_LOCAL void duk__handle_yield ( duk_hthread * thr,
duk_hthread * resumer,
duk_size_t act_idx,
duk_tval * tv_val_unstable )

Definition at line 66392 of file duktape-1.8.0/src/duktape.c.

66409 {
66410 duk_tval *tv1;

◆ duk__hexval()

DUK_LOCAL duk_codepoint_t duk__hexval ( duk_lexer_ctx * lex_ctx,
duk_codepoint_t x )

Definition at line 73912 of file duktape-1.8.0/src/duktape.c.

73916 {
73917 DUK_ASSERT_DISABLE(pt->offset >= 0); /* unsigned */
73918 DUK_ASSERT(pt->line >= 1);
73919 lex_ctx->input_offset = pt->offset;
73920 lex_ctx->input_line = pt->line;
73921 duk__init_lexer_window(lex_ctx);
73922}
73923
73924/*
73925 * Lexing helpers
73926 */
73927
73928/* numeric value of a hex digit (also covers octal and decimal digits) */
DUK_LOCAL void duk__init_lexer_window(duk_lexer_ctx *lex_ctx)

References duk__init_lexer_window(), DUK_ASSERT, DUK_ASSERT_DISABLE, duk_lexer_ctx::input_line, duk_lexer_ctx::input_offset, duk_lexer_point::line, and duk_lexer_point::offset.

Referenced by duk_lexer_parse_js_input_element().

◆ duk__hobject_pc2line_query_raw()

DUK_LOCAL duk_uint_fast32_t duk__hobject_pc2line_query_raw ( duk_hthread * thr,
duk_hbuffer_fixed * buf,
duk_uint_fast32_t pc )

Definition at line 47300 of file duktape-1.8.0/src/duktape.c.

47308 : pc_limit=%ld, length=%ld, %lf bits/opcode --> %!ixT",
47309 (long) length, (long) new_size, (double) new_size * 8.0 / (double) length,
47310 (duk_tval *) duk_get_tval(ctx, -1)));
47311}
47312
47313/* PC is unsigned. If caller does PC arithmetic and gets a negative result,
47314 * it will map to a large PC which is out of bounds and causes a zero to be
47315 * returned.
47316 */
47317DUK_LOCAL duk_uint_fast32_t duk__hobject_pc2line_query_raw(duk_hthread *thr, duk_hbuffer_fixed *buf, duk_uint_fast32_t pc) {
47318 duk_bitdecoder_ctx bd_ctx_alloc;
47319 duk_bitdecoder_ctx *bd_ctx = &bd_ctx_alloc;
47320 duk_uint32_t *hdr;
47321 duk_uint_fast32_t start_offset;
47322 duk_uint_fast32_t pc_limit;
47323 duk_uint_fast32_t hdr_index;
47324 duk_uint_fast32_t pc_base;
47325 duk_uint_fast32_t n;
47326 duk_uint_fast32_t curr_line;
47327
47328 DUK_ASSERT(buf != NULL);
47329 DUK_ASSERT(!DUK_HBUFFER_HAS_DYNAMIC((duk_hbuffer *) buf) && !DUK_HBUFFER_HAS_EXTERNAL((duk_hbuffer *) buf));
47330 DUK_UNREF(thr);
47331
47332 /*
47333 * Use the index in the header to find the right starting point
47334 */
47335
47336 hdr_index = pc / DUK_PC2LINE_SKIP;
47337 pc_base = hdr_index * DUK_PC2LINE_SKIP;
47338 n = pc - pc_base;
47339
47340 if (DUK_HBUFFER_FIXED_GET_SIZE(buf) <= sizeof(duk_uint32_t)) {
47341 DUK_DD(DUK_DDPRINT("pc2line lookup failed: buffer is smaller than minimal header"));
47342 goto error;
47343 }
47344
47345 hdr = (duk_uint32_t *) (void *) DUK_HBUFFER_FIXED_GET_DATA_PTR(thr->heap, buf);
47346 pc_limit = hdr[0];
47347 if (pc >= pc_limit) {
47348 /* Note: pc is unsigned and cannot be negative */
47349 DUK_DD(DUK_DDPRINT("pc2line lookup failed: pc out of bounds (pc=%ld, limit=%ld)",
47350 (long) pc, (long) pc_limit));
47351 goto error;
47352 }
47353
47354 curr_line = hdr[1 + hdr_index * 2];
47355 start_offset = hdr[1 + hdr_index * 2 + 1];
47356 if ((duk_size_t) start_offset > DUK_HBUFFER_FIXED_GET_SIZE(buf)) {
47357 DUK_DD(DUK_DDPRINT("pc2line lookup failed: start_offset out of bounds (start_offset=%ld, buffer_size=%ld)",
47358 (long) start_offset, (long) DUK_HBUFFER_GET_SIZE((duk_hbuffer *) buf)));
47359 goto error;
47360 }
47361
47362 /*
47363 * Iterate the bitstream (line diffs) until PC is reached
47364 */
47365
47366 DUK_MEMZERO(bd_ctx, sizeof(*bd_ctx));
47367 bd_ctx->data = ((duk_uint8_t *) hdr) + start_offset;
47368 bd_ctx->length = (duk_size_t) (DUK_HBUFFER_FIXED_GET_SIZE(buf) - start_offset);
47369
47370#if 0
47371 DUK_DDD(DUK_DDDPRINT("pc2line lookup: pc=%ld -> hdr_index=%ld, pc_base=%ld, n=%ld, start_offset=%ld",
47372 (long) pc, (long) hdr_index, (long) pc_base, (long) n, (long) start_offset));
47373#endif
47374
47375 while (n > 0) {
47376#if 0
47377 DUK_DDD(DUK_DDDPRINT("lookup: n=%ld, curr_line=%ld", (long) n, (long) curr_line));
47378#endif
47379
47380 if (duk_bd_decode_flag(bd_ctx)) {
47381 if (duk_bd_decode_flag(bd_ctx)) {
47382 if (duk_bd_decode_flag(bd_ctx)) {
47383 /* 1 1 1 <32 bits> */
47384 duk_uint_fast32_t t;
47385 t = duk_bd_decode(bd_ctx, 16); /* workaround: max nbits = 24 now */
47386 t = (t << 16) + duk_bd_decode(bd_ctx, 16);
47387 curr_line = t;
47388 } else {
47389 /* 1 1 0 <8 bits> */
47390 duk_uint_fast32_t t;
47391 t = duk_bd_decode(bd_ctx, 8);
47392 curr_line = curr_line + t - 0x80;
47393 }
47394 } else {
47395 /* 1 0 <2 bits> */
47396 duk_uint_fast32_t t;

◆ duk__hstring_is_eval_or_arguments()

DUK_LOCAL duk_bool_t duk__hstring_is_eval_or_arguments ( duk_compiler_ctx * comp_ctx,
duk_hstring * h )

◆ duk__hstring_is_eval_or_arguments_in_strict_mode()

DUK_LOCAL duk_bool_t duk__hstring_is_eval_or_arguments_in_strict_mode ( duk_compiler_ctx * comp_ctx,
duk_hstring * h )

Definition at line 58116 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_var_decl().

◆ duk__inc_data_inner_refcounts()

DUK_LOCAL void duk__inc_data_inner_refcounts ( duk_hthread * thr,
duk_hcompiledfunction * f )

Definition at line 71558 of file duktape-1.8.0/src/duktape.c.

71564 :
71565 *
71566 * * Order of internal properties should match frequency of use, since the
71567 * properties will be linearly scanned on lookup (functions usually don't
71568 * have enough properties to warrant a hash part).
71569 *
71570 * * The created closure is independent of its template; they do share the
71571 * same 'data' buffer object, but the template object itself can be freed
71572 * even if the closure object remains reachable.
71573 */
71574
71575DUK_LOCAL void duk__inc_data_inner_refcounts(duk_hthread *thr, duk_hcompiledfunction *f) {
71576 duk_tval *tv, *tv_end;
71577 duk_hobject **funcs, **funcs_end;
71578
71579 /* If function creation fails due to out-of-memory, the data buffer
71580 * pointer may be NULL in some cases. That's actually possible for
71581 * GC code, but shouldn't be possible here because the incomplete
71582 * function will be unwound from the value stack and never instantiated.
71583 */

References DUK_ASSERT, DUK_HCOMPILEDFUNCTION_GET_CONSTS_BASE, DUK_HCOMPILEDFUNCTION_GET_CONSTS_END, DUK_HCOMPILEDFUNCTION_GET_DATA, DUK_TVAL_INCREF, DUK_UNREF, funcs, duk_hthread::heap, and NULL.

◆ duk__init_func_valstack_slots()

DUK_LOCAL_DECL void duk__init_func_valstack_slots ( duk_compiler_ctx * comp_ctx)

Definition at line 58203 of file duktape-1.8.0/src/duktape.c.

58206 {
58207 duk__advance_helper(comp_ctx, expect);
58208}
58209
58210/* advance, whatever the current token is; parse next token in regexp context */
58211DUK_LOCAL void duk__advance(duk_compiler_ctx *comp_ctx) {
58212 duk__advance_helper(comp_ctx, -1);
58213}
58214
58215/*
58216 * Helpers for duk_compiler_func.
58217 */
58218
58219/* init function state: inits valstack allocations */
58221 duk_compiler_func *func = &comp_ctx->curr_func;
58222 duk_hthread *thr = comp_ctx->thr;
58223 duk_context *ctx = (duk_context *) thr;
58224 duk_idx_t entry_top;
58225
58226 entry_top = duk_get_top(ctx);
58227
58228 DUK_MEMZERO(func, sizeof(*func)); /* intentional overlap with earlier memzero */
58229#ifdef DUK_USE_EXPLICIT_NULL_INIT
58230 func->h_name = NULL;
58231 func->h_consts = NULL;
58232 func->h_funcs = NULL;
58233 func->h_decls = NULL;
58234 func->h_labelnames = NULL;
58235 func->h_labelinfos = NULL;
58236 func->h_argnames = NULL;
58237 func->h_varmap = NULL;
58238#endif
58239
58241
58243 /* code_idx = entry_top + 0 */
58244
58245 duk_push_array(ctx);
58246 func->consts_idx = entry_top + 1;
58247 func->h_consts = DUK_GET_HOBJECT_POSIDX(ctx, entry_top + 1);
58248 DUK_ASSERT(func->h_consts != NULL);
58249
58250 duk_push_array(ctx);
58251 func->funcs_idx = entry_top + 2;
58252 func->h_funcs = DUK_GET_HOBJECT_POSIDX(ctx, entry_top + 2);
58253 DUK_ASSERT(func->h_funcs != NULL);
58254 DUK_ASSERT(func->fnum_next == 0);
58255
58256 duk_push_array(ctx);
58257 func->decls_idx = entry_top + 3;
58258 func->h_decls = DUK_GET_HOBJECT_POSIDX(ctx, entry_top + 3);
58259 DUK_ASSERT(func->h_decls != NULL);
58260
58261 duk_push_array(ctx);
58262 func->labelnames_idx = entry_top + 4;
58263 func->h_labelnames = DUK_GET_HOBJECT_POSIDX(ctx, entry_top + 4);
58264 DUK_ASSERT(func->h_labelnames != NULL);
#define DUK__FUNCTION_INIT_REQUIRE_SLOTS
#define DUK_GET_HOBJECT_POSIDX(ctx, idx)
DUK_LOCAL_DECL void duk__init_func_valstack_slots(duk_compiler_ctx *comp_ctx)
#define DUK__BC_INITIAL_INSTS

◆ duk__init_heap_strings()

DUK_LOCAL duk_bool_t duk__init_heap_strings ( duk_heap * heap)

Definition at line 41383 of file duktape-1.8.0/src/duktape.c.

41386 {
41387 duk_uint32_t hash;
41388 const duk_hstring *h;
41389 h = duk_rom_strings[i];
41390 DUK_ASSERT(h != NULL);
41391 hash = duk_heap_hashstring(heap, (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h));
41392 DUK_DD(DUK_DDPRINT("duk_rom_strings[%d] -> hash 0x%08lx, computed 0x%08lx",
41393 (int) i, (unsigned long) DUK_HSTRING_GET_HASH(h), (unsigned long) hash));
41394 DUK_ASSERT(hash == (duk_uint32_t) DUK_HSTRING_GET_HASH(h));
41395 }
41396#endif
41397 return 1;
41398}
41399#else /* DUK_USE_ROM_STRINGS */
41401 duk_bitdecoder_ctx bd_ctx;
41402 duk_bitdecoder_ctx *bd = &bd_ctx; /* convenience */
41403 duk_small_uint_t i, j;
41404
41405 DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx));
41406 bd->data = (const duk_uint8_t *) duk_strings_data;
41408
41409 for (i = 0; i < DUK_HEAP_NUM_STRINGS; i++) {
41410 duk_uint8_t tmp[DUK_STRDATA_MAX_STRLEN];
41411 duk_hstring *h;
41412 duk_small_uint_t len;
41413 duk_small_uint_t mode;
41415
41416 len = duk_bd_decode(bd, 5);
41417 mode = 32; /* 0 = uppercase, 32 = lowercase (= 'a' - 'A') */
41418 for (j = 0; j < len; j++) {
41419 t = duk_bd_decode(bd, 5);
41420 if (t < DUK__BITPACK_LETTER_LIMIT) {
41421 t = t + DUK_ASC_UC_A + mode;
41422 } else if (t == DUK__BITPACK_UNDERSCORE) {
41424 } else if (t == DUK__BITPACK_FF) {
41425 /* Internal keys are prefixed with 0xFF in the stringtable
41426 * (which makes them invalid UTF-8 on purpose).
41427 */
41428 t = 0xff;
41429 } else if (t == DUK__BITPACK_SWITCH1) {
41430 t = duk_bd_decode(bd, 5);
41431 DUK_ASSERT_DISABLE(t >= 0); /* unsigned */
41432 DUK_ASSERT(t <= 25);
41433 t = t + DUK_ASC_UC_A + (mode ^ 32);
41434 } else if (t == DUK__BITPACK_SWITCH) {
41435 mode = mode ^ 32;
41436 t = duk_bd_decode(bd, 5);
41437 DUK_ASSERT_DISABLE(t >= 0);
41438 DUK_ASSERT(t <= 25);
41439 t = t + DUK_ASC_UC_A + mode;
41440 } else if (t == DUK__BITPACK_SEVENBIT) {
41441 t = duk_bd_decode(bd, 7);
41442 }
41443 tmp[j] = (duk_uint8_t) t;
41444 }
41445
41446 /* No need to length check string: it will never exceed even
41447 * the 16-bit length maximum.
41448 */
41449 DUK_ASSERT(len <= 0xffffUL);
41450 DUK_DDD(DUK_DDDPRINT("intern built-in string %ld", (long) i));
41451 h = duk_heap_string_intern(heap, tmp, len);
41452 if (!h) {
41453 goto error;
41454 }
41456
41457 /* Special flags checks. Since these strings are always
41458 * reachable and a string cannot appear twice in the string
41459 * table, there's no need to check/set these flags elsewhere.
41460 * The 'internal' flag is set by string intern code.
41461 */
41462 if (i == DUK_STRIDX_EVAL || i == DUK_STRIDX_LC_ARGUMENTS) {
41464 }
41469 }
41470 }
41471
41472 DUK_DDD(DUK_DDDPRINT("interned: %!O", (duk_heaphdr *) h));
41473
#define DUK_STRIDX_LC_ARGUMENTS
#define DUK_STRDATA_MAX_STRLEN
DUK_INTERNAL const duk_uint8_t duk_strings_data[1049]
#define DUK_STRIDX_START_RESERVED
#define DUK_STRDATA_DATA_LENGTH
DUK_INTERNAL_DECL duk_hstring * duk_heap_string_intern(duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen)
#define DUK_HSTRING_SET_EVAL_OR_ARGUMENTS(x)
#define DUK__BITPACK_FF
#define DUK__BITPACK_UNDERSCORE
#define DUK_HEAPHDR_HAS_READONLY(h)
#define DUK__BITPACK_SWITCH
#define DUK_STRIDX_START_STRICT_RESERVED
#define DUK_HSTRING_SET_STRICT_RESERVED_WORD(x)
#define DUK_HSTRING_SET_RESERVED_WORD(x)
#define DUK__BITPACK_SEVENBIT
#define DUK__BITPACK_LETTER_LIMIT
#define DUK_STRIDX_END_RESERVED
#define DUK_ASC_UNDERSCORE
#define DUK_ASC_UC_A
#define DUK__BITPACK_SWITCH1
DUK_INTERNAL_DECL duk_int32_t duk_bd_decode(duk_bitdecoder_ctx *ctx, duk_small_int_t bits)
DUK_LOCAL duk_bool_t duk__init_heap_strings(duk_heap *heap)

◆ duk__init_heap_thread()

DUK_LOCAL duk_bool_t duk__init_heap_thread ( duk_heap * heap)

Definition at line 41476 of file duktape-1.8.0/src/duktape.c.

41488 :
41489 return 0;
41490}
41491#endif /* DUK_USE_ROM_STRINGS */
41492
41494 duk_hthread *thr;
41495
41496 DUK_DD(DUK_DDPRINT("heap init: alloc heap thread"));
41497 thr = duk_hthread_alloc(heap,
41501 if (!thr) {
41502 DUK_D(DUK_DPRINT("failed to alloc heap_thread"));
41503 return 0;
41504 }
41506#if defined(DUK_USE_ROM_STRINGS)
41507 /* No strs[] pointer. */
41508#else /* DUK_USE_ROM_STRINGS */
41509#if defined(DUK_USE_HEAPPTR16)
41510 thr->strs16 = heap->strs16;
41511#else
41512 thr->strs = heap->strs;
41513#endif
41514#endif /* DUK_USE_ROM_STRINGS */
41515
DUK_LOCAL duk_bool_t duk__init_heap_thread(duk_heap *heap)
#define DUK_HOBJECT_CLASS_THREAD
#define DUK_HOBJECT_FLAG_THREAD
DUK_INTERNAL_DECL duk_hthread * duk_hthread_alloc(duk_heap *heap, duk_uint_t hobject_flags)
duk_hstring * strs[DUK_HEAP_NUM_STRINGS]

◆ duk__init_lexer_window()

DUK_LOCAL void duk__init_lexer_window ( duk_lexer_ctx * lex_ctx)

◆ duk__init_object_parts()

DUK_LOCAL void duk__init_object_parts ( duk_heap * heap,
duk_hobject * obj,
duk_uint_t hobject_flags )

Definition at line 46198 of file duktape-1.8.0/src/duktape.c.

46215 {
46216#ifdef DUK_USE_EXPLICIT_NULL_INIT
46217 DUK_HOBJECT_SET_PROPS(heap, obj, NULL);
46218#endif
46219
46220 /* XXX: macro? sets both heaphdr and object flags */
46221 obj->hdr.h_flags = hobject_flags;
46222 DUK_HEAPHDR_SET_TYPE(&obj->hdr, DUK_HTYPE_OBJECT); /* also goes into flags */
46223
#define DUK_HOBJECT_SET_PROPS(heap, h, x)
#define DUK_HEAPHDR_SET_TYPE(h, val)

References DUK_ASSERT_HEAPHDR_LINKS, DUK_HEAP_INSERT_INTO_HEAP_ALLOCATED, DUK_HEAPHDR_SET_NEXT, DUK_HEAPHDR_SET_PREV, DUK_HEAPHDR_SET_TYPE, DUK_HOBJECT_SET_PROPS, DUK_HTYPE_OBJECT, duk_heaphdr::h_flags, duk_hobject::hdr, and NULL.

◆ duk__init_varmap_and_prologue_for_pass2()

DUK_LOCAL_DECL void duk__init_varmap_and_prologue_for_pass2 ( duk_compiler_ctx * comp_ctx,
duk_reg_t * out_stmt_value_reg )

Definition at line 64521 of file duktape-1.8.0/src/duktape.c.

64524 :
64525 *
64526 * - The 'arguments' binding, established only if no shadowing argument
64527 * or function declaration exists. We handle 'arguments' creation
64528 * and binding through an explicit slow path environment record.
64529 *
64530 * - The "name" binding for a named function expression. This is also
64531 * handled through an explicit slow path environment record.
64532 */
64533
64534/* XXX: add support for variables to not be register bound always, to
64535 * handle cases with a very large number of variables?
64536 */
64537
64539 duk_hthread *thr = comp_ctx->thr;
64540 duk_context *ctx = (duk_context *) thr;
64541 duk_hstring *h_name;
64542 duk_bool_t configurable_bindings;
64543 duk_uarridx_t num_args;
64544 duk_uarridx_t num_decls;
64545 duk_regconst_t rc_name;
64546 duk_small_uint_t declvar_flags;
64547 duk_uarridx_t i;
64548#ifdef DUK_USE_ASSERTIONS
64549 duk_idx_t entry_top;
64550#endif
64551
64552#ifdef DUK_USE_ASSERTIONS
64553 entry_top = duk_get_top(ctx);
64554#endif
64555
64556 /*
64557 * Preliminaries
64558 */
64559
64560 configurable_bindings = comp_ctx->curr_func.is_eval;
64561 DUK_DDD(DUK_DDDPRINT("configurable_bindings=%ld", (long) configurable_bindings));
64562
64563 /* varmap is already in comp_ctx->curr_func.varmap_idx */
64564
64565 /*
64566 * Function formal arguments, always bound to registers
64567 * (there's no support for shuffling them now).
64568 */
64569
64570 num_args = (duk_uarridx_t) duk_get_length(ctx, comp_ctx->curr_func.argnames_idx);
64571 DUK_DDD(DUK_DDDPRINT("num_args=%ld", (long) num_args));
64572 /* XXX: check num_args */
64573
64574 for (i = 0; i < num_args; i++) {
64575 duk_get_prop_index(ctx, comp_ctx->curr_func.argnames_idx, i);
64576 h_name = duk_get_hstring(ctx, -1);
64577 DUK_ASSERT(h_name != NULL);
64578
64579 if (comp_ctx->curr_func.is_strict) {
64580 if (duk__hstring_is_eval_or_arguments(comp_ctx, h_name)) {
64581 DUK_DDD(DUK_DDDPRINT("arg named 'eval' or 'arguments' in strict mode -> SyntaxError"));
64582 goto error_argname;
64583 }
64584 duk_dup_top(ctx);
64585 if (duk_has_prop(ctx, comp_ctx->curr_func.varmap_idx)) {
64586 DUK_DDD(DUK_DDDPRINT("duplicate arg name in strict mode -> SyntaxError"));
64587 goto error_argname;
64588 }
64589
64590 /* Ensure argument name is not a reserved word in current
64591 * (final) strictness. Formal argument parsing may not
64592 * catch reserved names if strictness changes during
64593 * parsing.
64594 *
64595 * We only need to do this in strict mode because non-strict
64596 * keyword are always detected in formal argument parsing.
64597 */
64598
64600 goto error_argname;
64601 }
64602 }
64603
64604 /* overwrite any previous binding of the same name; the effect is
64605 * that last argument of a certain name wins.
64606 */
64607
64608 /* only functions can have arguments */
64609 DUK_ASSERT(comp_ctx->curr_func.is_function);
64610 duk_push_uarridx(ctx, i); /* -> [ ... name index ] */
64611 duk_put_prop(ctx, comp_ctx->curr_func.varmap_idx); /* -> [ ... ] */
64612
64613 /* no code needs to be emitted, the regs already have values */
64614 }
64615
64616 /* use temp_next for tracking register allocations */
64617 DUK__SETTEMP_CHECKMAX(comp_ctx, (duk_reg_t) num_args);
64618
64619 /*
64620 * After arguments, allocate special registers (like shuffling temps)
64621 */
64622
64623 if (out_stmt_value_reg) {
64624 *out_stmt_value_reg = DUK__ALLOCTEMP(comp_ctx);
64625 }
64626 if (comp_ctx->curr_func.needs_shuffle) {
64627 duk_reg_t shuffle_base = DUK__ALLOCTEMPS(comp_ctx, 3);
64628 comp_ctx->curr_func.shuffle1 = shuffle_base;
64629 comp_ctx->curr_func.shuffle2 = shuffle_base + 1;
64630 comp_ctx->curr_func.shuffle3 = shuffle_base + 2;
64631 DUK_D(DUK_DPRINT("shuffle registers needed by function, allocated: %ld %ld %ld",
64632 (long) comp_ctx->curr_func.shuffle1,
64633 (long) comp_ctx->curr_func.shuffle2,
64634 (long) comp_ctx->curr_func.shuffle3));
64635 }
64636 if (comp_ctx->curr_func.temp_next > 0x100) {
64637 DUK_D(DUK_DPRINT("not enough 8-bit regs: temp_next=%ld", (long) comp_ctx->curr_func.temp_next));
64638 goto error_outofregs;
64639 }
64640
64641 /*
64642 * Function declarations
64643 */
64644
64645 num_decls = (duk_uarridx_t) duk_get_length(ctx, comp_ctx->curr_func.decls_idx);
64646 DUK_DDD(DUK_DDDPRINT("num_decls=%ld -> %!T",
64647 (long) num_decls,
64648 (duk_tval *) duk_get_tval(ctx, comp_ctx->curr_func.decls_idx)));
64649 for (i = 0; i < num_decls; i += 2) {
64650 duk_int_t decl_type;
64651 duk_int_t fnum;
64652
64653 duk_get_prop_index(ctx, comp_ctx->curr_func.decls_idx, i + 1); /* decl type */
64654 decl_type = duk_to_int(ctx, -1);
64655 fnum = decl_type >> 8; /* XXX: macros */
64656 decl_type = decl_type & 0xff;
64657 duk_pop(ctx);
64658
64659 if (decl_type != DUK_DECL_TYPE_FUNC) {
64660 continue;
64661 }
64662
64663 duk_get_prop_index(ctx, comp_ctx->curr_func.decls_idx, i); /* decl name */
64664
64665 /* XXX: spilling */
64666 if (comp_ctx->curr_func.is_function) {
64667 duk_reg_t reg_bind;
64668 duk_dup_top(ctx);
64669 if (duk_has_prop(ctx, comp_ctx->curr_func.varmap_idx)) {
64670 /* shadowed; update value */
64671 duk_dup_top(ctx);
64672 duk_get_prop(ctx, comp_ctx->curr_func.varmap_idx);
64673 reg_bind = duk_to_int(ctx, -1); /* [ ... name reg_bind ] */
64674 duk__emit_a_bc(comp_ctx,
64676 (duk_regconst_t) reg_bind,
64677 (duk_regconst_t) fnum);
64678 } else {
64679 /* function: always register bound */
64680 reg_bind = DUK__ALLOCTEMP(comp_ctx);
64681 duk__emit_a_bc(comp_ctx,
64683 (duk_regconst_t) reg_bind,
64684 (duk_regconst_t) fnum);
64685 duk_push_int(ctx, (duk_int_t) reg_bind);
64686 }
64687 } else {
64688 /* Function declaration for global/eval code is emitted even
64689 * for duplicates, because of E5 Section 10.5, step 5.e of
64690 * E5.1 (special behavior for variable bound to global object).
64691 *
64692 * DECLVAR will not re-declare a variable as such, but will
64693 * update the binding value.
64694 */
64695
64696 duk_reg_t reg_temp = DUK__ALLOCTEMP(comp_ctx);
64697 duk_dup_top(ctx);
64698 rc_name = duk__getconst(comp_ctx);
64699 duk_push_null(ctx);
64700
64701 duk__emit_a_bc(comp_ctx,
64703 (duk_regconst_t) reg_temp,
64704 (duk_regconst_t) fnum);
64705
64706 declvar_flags = DUK_PROPDESC_FLAG_WRITABLE |
64709
64710 if (configurable_bindings) {
64711 declvar_flags |= DUK_PROPDESC_FLAG_CONFIGURABLE;
64712 }
64713
64714 duk__emit_a_b_c(comp_ctx,
64716 (duk_regconst_t) declvar_flags /*flags*/,
64717 rc_name /*name*/,
64718 (duk_regconst_t) reg_temp /*value*/);
64719
64720 DUK__SETTEMP(comp_ctx, reg_temp); /* forget temp */
64721 }
64722
64723 DUK_DDD(DUK_DDDPRINT("function declaration to varmap: %!T -> %!T",
64724 (duk_tval *) duk_get_tval(ctx, -2),
64725 (duk_tval *) duk_get_tval(ctx, -1)));
64726
64727 duk_put_prop(ctx, comp_ctx->curr_func.varmap_idx); /* [ ... name reg/null ] -> [ ... ] */
64728 }
64729
64730 /*
64731 * 'arguments' binding is special; if a shadowing argument or
64732 * function declaration exists, an arguments object will
64733 * definitely not be needed, regardless of whether the identifier
64734 * 'arguments' is referenced inside the function body.
64735 */
64736
64738 DUK_DDD(DUK_DDDPRINT("'arguments' is shadowed by argument or function declaration "
64739 "-> arguments object creation can be skipped"));
64740 comp_ctx->curr_func.is_arguments_shadowed = 1;
64741 }
64742
64743 /*
64744 * Variable declarations.
64745 *
64746 * Unlike function declarations, variable declaration values don't get
64747 * assigned on entry. If a binding of the same name already exists, just
64748 * ignore it silently.
64749 */
64750
64751 for (i = 0; i < num_decls; i += 2) {
64752 duk_int_t decl_type;
64753
64754 duk_get_prop_index(ctx, comp_ctx->curr_func.decls_idx, i + 1); /* decl type */
64755 decl_type = duk_to_int(ctx, -1);
64756 decl_type = decl_type & 0xff;
64757 duk_pop(ctx);
64758
64759 if (decl_type != DUK_DECL_TYPE_VAR) {
64760 continue;
64761 }
64762
64763 duk_get_prop_index(ctx, comp_ctx->curr_func.decls_idx, i); /* decl name */
64764
64765 if (duk_has_prop(ctx, comp_ctx->curr_func.varmap_idx)) {
64766 /* shadowed, ignore */
64767 } else {
64768 duk_get_prop_index(ctx, comp_ctx->curr_func.decls_idx, i); /* decl name */
64769 h_name = duk_get_hstring(ctx, -1);
64770 DUK_ASSERT(h_name != NULL);
64771
64772 if (h_name == DUK_HTHREAD_STRING_LC_ARGUMENTS(thr) &&
64773 !comp_ctx->curr_func.is_arguments_shadowed) {
64774 /* E5 Section steps 7-8 */
64775 DUK_DDD(DUK_DDDPRINT("'arguments' not shadowed by a function declaration, "
64776 "but appears as a variable declaration -> treat as "
64777 "a no-op for variable declaration purposes"));
64778 duk_pop(ctx);
64779 continue;
64780 }
64781
64782 /* XXX: spilling */
64783 if (comp_ctx->curr_func.is_function) {
64784 duk_reg_t reg_bind = DUK__ALLOCTEMP(comp_ctx);
64785 /* no need to init reg, it will be undefined on entry */
64786 duk_push_int(ctx, (duk_int_t) reg_bind);
64787 } else {
64788 duk_dup_top(ctx);
64789 rc_name = duk__getconst(comp_ctx);
64790 duk_push_null(ctx);
64791
64792 declvar_flags = DUK_PROPDESC_FLAG_WRITABLE |
64795 if (configurable_bindings) {
64796 declvar_flags |= DUK_PROPDESC_FLAG_CONFIGURABLE;
64797 }
64798
64799 duk__emit_a_b_c(comp_ctx,
64801 (duk_regconst_t) declvar_flags /*flags*/,
64802 rc_name /*name*/,
64803 (duk_regconst_t) 0 /*value*/);
64804 }
64805
64806 duk_put_prop(ctx, comp_ctx->curr_func.varmap_idx); /* [ ... name reg/null ] -> [ ... ] */
64807 }
64808 }
64809
64810 /*
64811 * Wrap up
64812 */
64813
#define DUK_DECL_TYPE_VAR
#define DUK__SETTEMP_CHECKMAX(comp_ctx, x)
DUK_LOCAL_DECL void duk__init_varmap_and_prologue_for_pass2(duk_compiler_ctx *comp_ctx, duk_reg_t *out_stmt_value_reg)
#define DUK_DECL_TYPE_FUNC
#define DUK_BC_DECLVAR_FLAG_UNDEF_VALUE
#define DUK_HTHREAD_STRING_LC_ARGUMENTS(thr)
#define DUK_OP_DECLVAR
DUK_LOCAL duk_bool_t duk__hstring_is_eval_or_arguments(duk_compiler_ctx *comp_ctx, duk_hstring *h)
#define duk_push_uarridx(ctx, val)
#define DUK_BC_DECLVAR_FLAG_FUNC_DECL
#define DUK_HSTRING_HAS_STRICT_RESERVED_WORD(x)
DUK_INTERNAL_DECL duk_bool_t duk_has_prop_stridx(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx)
DUK_EXTERNAL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_idx)

References duk_compiler_func::argnames_idx, duk_compiler_ctx::curr_func, duk_compiler_func::decls_idx, DUK__ALLOCTEMP, DUK__ALLOCTEMPS, duk__emit_a_b_c(), duk__emit_a_bc(), DUK__EMIT_FLAG_NO_SHUFFLE_A, duk__getconst(), duk__hstring_is_eval_or_arguments(), DUK__SETTEMP, DUK__SETTEMP_CHECKMAX, DUK_ASSERT, DUK_ASSERT_TOP, DUK_BC_DECLVAR_FLAG_FUNC_DECL, DUK_BC_DECLVAR_FLAG_UNDEF_VALUE, DUK_D, DUK_DDD, DUK_DDDPRINT, DUK_DECL_TYPE_FUNC, DUK_DECL_TYPE_VAR, DUK_DPRINT, duk_dup_top(), DUK_ERROR_RANGE, DUK_ERROR_SYNTAX, duk_get_hstring(), duk_get_length(), duk_get_prop(), duk_get_prop_index(), duk_get_top(), duk_get_tval(), duk_has_prop(), duk_has_prop_stridx(), DUK_HSTRING_HAS_STRICT_RESERVED_WORD, DUK_HTHREAD_STRING_LC_ARGUMENTS, DUK_OP_CLOSURE, DUK_OP_DECLVAR, duk_pop(), DUK_PROPDESC_FLAG_CONFIGURABLE, DUK_PROPDESC_FLAG_ENUMERABLE, DUK_PROPDESC_FLAG_WRITABLE, duk_push_int(), duk_push_null(), duk_push_uarridx, duk_put_prop(), DUK_STR_INVALID_ARG_NAME, DUK_STR_REG_LIMIT, DUK_STRIDX_LC_ARGUMENTS, duk_to_int(), DUK_UNREACHABLE, duk_compiler_func::is_arguments_shadowed, duk_compiler_func::is_eval, duk_compiler_func::is_function, duk_compiler_func::is_strict, duk_compiler_func::needs_shuffle, NULL, duk_compiler_func::shuffle1, duk_compiler_func::shuffle2, duk_compiler_func::shuffle3, duk_compiler_func::temp_next, duk_compiler_ctx::thr, and duk_compiler_func::varmap_idx.

Referenced by duk__parse_func_body().

◆ duk__initbuffer()

DUK_LOCAL void duk__initbuffer ( duk_lexer_ctx * lex_ctx)

Definition at line 73828 of file duktape-1.8.0/src/duktape.c.

73834 {
73835 /* Call with count == DUK_LEXER_WINDOW_SIZE to fill buffer initially. */
73836 duk__advance_bytes(lex_ctx, DUK_LEXER_WINDOW_SIZE * sizeof(duk_lexer_codepoint)); /* fill window */
73837}

◆ duk__inp_backtrack()

DUK_LOCAL const duk_uint8_t * duk__inp_backtrack ( duk_re_matcher_ctx * re_ctx,
const duk_uint8_t ** sp,
duk_uint_fast32_t count )

Definition at line 78847 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__match_regexp().

◆ duk__inp_get_cp()

DUK_LOCAL duk_codepoint_t duk__inp_get_cp ( duk_re_matcher_ctx * re_ctx,
const duk_uint8_t ** sp )

Definition at line 78839 of file duktape-1.8.0/src/duktape.c.

78843 :
78845 return NULL; /* never here */

Referenced by duk__match_regexp().

◆ duk__inp_get_prev_cp()

◆ duk__insert_hstring_probe()

DUK_LOCAL void duk__insert_hstring_probe ( duk_heap * heap,
duk_hstring ** entries,
duk_uint32_t size,
duk_uint32_t * p_used,
duk_hstring * h )

Definition at line 45498 of file duktape-1.8.0/src/duktape.c.

45500 {
45501#if defined(DUK_USE_HEAPPTR16)
45502 if (heap->strtable16[i] != null16 && heap->strtable16[i] != deleted16) {
45503#else
45504 if (heap->strtable[i] != NULL && heap->strtable[i] != DUK__DELETED_MARKER(heap)) {
45505#endif
45506 res++;
45507 }
45508 }
45509 return res;
45510}
45511
45512#if defined(DUK_USE_HEAPPTR16)
45513DUK_LOCAL void duk__insert_hstring_probe(duk_heap *heap, duk_uint16_t *entries16, duk_uint32_t size, duk_uint32_t *p_used, duk_hstring *h) {
45514#else
45515DUK_LOCAL void duk__insert_hstring_probe(duk_heap *heap, duk_hstring **entries, duk_uint32_t size, duk_uint32_t *p_used, duk_hstring *h) {
45516#endif
45517 duk_uint32_t i;
45518 duk_uint32_t step;
45519#if defined(DUK_USE_HEAPPTR16)
45520 duk_uint16_t null16 = heap->heapptr_null16;
45521 duk_uint16_t deleted16 = heap->heapptr_deleted16;
45522#endif
45523
45524 DUK_ASSERT(size > 0);
45525
45528 for (;;) {
45529#if defined(DUK_USE_HEAPPTR16)
45530 duk_uint16_t e16 = entries16[i];
45531#else
45532 duk_hstring *e = entries[i];
45533#endif
45534
45535#if defined(DUK_USE_HEAPPTR16)
45536 /* XXX: could check for e16 == 0 because NULL is guaranteed to
45537 * encode to zero.
45538 */
45539 if (e16 == null16) {
45540#else
45541 if (e == NULL) {
45542#endif
45543 DUK_DDD(DUK_DDDPRINT("insert hit (null): %ld", (long) i));
45544#if defined(DUK_USE_HEAPPTR16)
45545 entries16[i] = DUK_USE_HEAPPTR_ENC16(heap->heap_udata, (void *) h);
45546#else
45547 entries[i] = h;
45548#endif
45549 (*p_used)++;
45550 break;
45551#if defined(DUK_USE_HEAPPTR16)
45552 } else if (e16 == deleted16) {
45553#else
45554 } else if (e == DUK__DELETED_MARKER(heap)) {
#define DUK__DELETED_MARKER(heap)

◆ duk__insert_i32()

DUK_LOCAL duk_uint32_t duk__insert_i32 ( duk_re_compiler_ctx * re_ctx,
duk_uint32_t offset,
duk_int32_t x )

Definition at line 77756 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__append_jump_offset().

◆ duk__insert_jump_entry()

DUK_LOCAL_DECL void duk__insert_jump_entry ( duk_compiler_ctx * comp_ctx,
duk_int_t jump_pc )

Definition at line 59295 of file duktape-1.8.0/src/duktape.c.

59301 {
59302 duk_int_t ret;
59303
59304 ret = duk__get_current_pc(comp_ctx); /* useful for patching jumps later */
59305 duk__emit_abc(comp_ctx, DUK_OP_JUMP, 0);
59306 return ret;
59307}
59308
59309/* Insert an empty jump in the middle of code emitted earlier. This is
59310 * currently needed for compiling for-in.
59311 */
59313#if defined(DUK_USE_PC2LINE)
59314 duk_int_t line;
59315#endif
59316 duk_compiler_instr *instr;
59317 duk_size_t offset;
59318
59319 offset = jump_pc * sizeof(duk_compiler_instr),
59320 instr = (duk_compiler_instr *) (void *)
59322 &comp_ctx->curr_func.bw_code,
59323 offset,
59324 sizeof(duk_compiler_instr));
59325
DUK_LOCAL_DECL void duk__insert_jump_entry(duk_compiler_ctx *comp_ctx, duk_int_t jump_pc)
#define DUK_BW_INSERT_ENSURE_AREA(thr, bw, off, len)

◆ duk__insert_jump_offset()

DUK_LOCAL duk_uint32_t duk__insert_jump_offset ( duk_re_compiler_ctx * re_ctx,
duk_uint32_t offset,
duk_int32_t skip )

Definition at line 77800 of file duktape-1.8.0/src/duktape.c.

77800 {
77801 DUK_BW_REMOVE_ENSURE_SLICE(re_ctx->thr, &re_ctx->bw, data_offset, data_length);
77802}
77803
77804/*
77805 * Insert a jump offset at 'offset' to complete an instruction
77806 * (the jump offset is always the last component of an instruction).
77807 * The 'skip' argument must be computed relative to 'offset',
77808 * -without- taking into account the skip field being inserted.
77809 *
77810 * ... A B C ins X Y Z ... (ins may be a JUMP, SPLIT1/SPLIT2, etc)
77811 * => ... A B C ins SKIP X Y Z
77812 *
77813 * Computing the final (adjusted) skip value, which is relative to the
#define DUK_BW_REMOVE_ENSURE_SLICE(thr, bw, off, len)

References duk_re_compiler_ctx::bw, DUK_BW_REMOVE_ENSURE_SLICE, and duk_re_compiler_ctx::thr.

Referenced by duk__parse_disjunction().

◆ duk__insert_slice()

DUK_LOCAL void duk__insert_slice ( duk_re_compiler_ctx * re_ctx,
duk_uint32_t offset,
duk_uint32_t data_offset,
duk_uint32_t data_length )

Definition at line 77775 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_disjunction().

◆ duk__insert_u32()

DUK_LOCAL duk_uint32_t duk__insert_u32 ( duk_re_compiler_ctx * re_ctx,
duk_uint32_t offset,
duk_uint32_t x )

Definition at line 77738 of file duktape-1.8.0/src/duktape.c.

77744 {
77745 if (x < 0) {

Referenced by duk__parse_disjunction().

◆ duk__internbuffer()

DUK_LOCAL void duk__internbuffer ( duk_lexer_ctx * lex_ctx,
duk_idx_t valstack_idx )

Definition at line 73866 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_lexer_parse_js_input_element().

◆ duk__is_hex_digit()

DUK_LOCAL duk_bool_t duk__is_hex_digit ( duk_codepoint_t x)

Definition at line 73931 of file duktape-1.8.0/src/duktape.c.

73933 {
73934 t = duk_hex_dectab[x];
73935 if (DUK_LIKELY(t >= 0)) {
73936 return t;

References duk_hex_dectab, and DUK_LIKELY.

◆ duk__is_whole_get_int32()

DUK_LOCAL_DECL duk_bool_t duk__is_whole_get_int32 ( duk_double_t x,
duk_int32_t * ival )

Definition at line 59552 of file duktape-1.8.0/src/duktape.c.

59555 {
59556 duk_context *ctx = (duk_context *) comp_ctx->thr;
59557
59558 dst->t = src->t;
59559 dst->op = src->op;
59560 dst->x1.t = src->x1.t;
59561 dst->x1.regconst = src->x1.regconst;
59562 dst->x2.t = src->x2.t;
59563 dst->x2.regconst = src->x2.regconst;
59564 duk_copy(ctx, src->x1.valstack_idx, dst->x1.valstack_idx);
59565 duk_copy(ctx, src->x2.valstack_idx, dst->x2.valstack_idx);
59566}
59567
59568/* XXX: to util */
DUK_LOCAL_DECL duk_bool_t duk__is_whole_get_int32(duk_double_t x, duk_int32_t *ival)

Referenced by duk__ispec_toregconst_raw().

◆ duk__ispec_toforcedreg()

DUK_LOCAL_DECL void duk__ispec_toforcedreg ( duk_compiler_ctx * comp_ctx,
duk_ispec * x,
duk_reg_t forced_reg )

Definition at line 59835 of file duktape-1.8.0/src/duktape.c.

59836 {
59837 duk_reg_t dest = DUK__ALLOCTEMP(comp_ctx);
59838 duk__emit_a_bc(comp_ctx, DUK_OP_LDREG, (duk_regconst_t) dest, x->regconst);

◆ duk__ispec_toregconst_raw()

DUK_LOCAL_DECL duk_regconst_t duk__ispec_toregconst_raw ( duk_compiler_ctx * comp_ctx,
duk_ispec * x,
duk_reg_t forced_reg,
duk_small_uint_t flags )

Definition at line 59664 of file duktape-1.8.0/src/duktape.c.

59684 {
59685 duk_hthread *thr = comp_ctx->thr;
59686 duk_context *ctx = (duk_context *) thr;
59687
59688 DUK_DDD(DUK_DDDPRINT("duk__ispec_toregconst_raw(): x={%ld:%ld:%!T}, "
59689 "forced_reg=%ld, flags 0x%08lx: allow_const=%ld require_temp=%ld require_short=%ld",
59690 (long) x->t,
59691 (long) x->regconst,
59692 (duk_tval *) duk_get_tval(ctx, x->valstack_idx),
59693 (long) forced_reg,
59694 (unsigned long) flags,
59695 (long) ((flags & DUK__IVAL_FLAG_ALLOW_CONST) ? 1 : 0),
59696 (long) ((flags & DUK__IVAL_FLAG_REQUIRE_TEMP) ? 1 : 0),
59697 (long) ((flags & DUK__IVAL_FLAG_REQUIRE_SHORT) ? 1 : 0)));
59698
59699 switch (x->t) {
59700 case DUK_ISPEC_VALUE: {
59701 duk_tval *tv;
59702
59703 tv = DUK_GET_TVAL_POSIDX(ctx, x->valstack_idx);
59704 DUK_ASSERT(tv != NULL);
59705
59706 switch (DUK_TVAL_GET_TAG(tv)) {
59707 case DUK_TAG_UNDEFINED: {
59708 /* Note: although there is no 'undefined' literal, undefined
59709 * values can occur during compilation as a result of e.g.
59710 * the 'void' operator.
59711 */
59712 duk_reg_t dest = (forced_reg >= 0 ? forced_reg : DUK__ALLOCTEMP(comp_ctx));
59714 return (duk_regconst_t) dest;
59715 }
59716 case DUK_TAG_NULL: {
59717 duk_reg_t dest = (forced_reg >= 0 ? forced_reg : DUK__ALLOCTEMP(comp_ctx));
59719 return (duk_regconst_t) dest;
59720 }
59721 case DUK_TAG_BOOLEAN: {
59722 duk_reg_t dest = (forced_reg >= 0 ? forced_reg : DUK__ALLOCTEMP(comp_ctx));
59723 duk__emit_extraop_bc(comp_ctx,
59725 (duk_regconst_t) dest);
59726 return (duk_regconst_t) dest;
59727 }
59728 case DUK_TAG_POINTER: {
59730 break;
59731 }
59732 case DUK_TAG_STRING: {
59733 duk_hstring *h;
59734 duk_reg_t dest;
59735 duk_regconst_t constidx;
59736
59737 h = DUK_TVAL_GET_STRING(tv);
59738 DUK_UNREF(h);
59739 DUK_ASSERT(h != NULL);
59740
59741#if 0 /* XXX: to be implemented? */
59742 /* Use special opcodes to load short strings */
59743 if (DUK_HSTRING_GET_BYTELEN(h) <= 2) {
59744 /* Encode into a single opcode (18 bits can encode 1-2 bytes + length indicator) */
59745 } else if (DUK_HSTRING_GET_BYTELEN(h) <= 6) {
59746 /* Encode into a double constant (53 bits can encode 6*8 = 48 bits + 3-bit length */
59747 }
59748#endif
59749 duk_dup(ctx, x->valstack_idx);
59750 constidx = duk__getconst(comp_ctx);
59751
59752 if (flags & DUK__IVAL_FLAG_ALLOW_CONST) {
59753 return constidx;
59754 }
59755
59756 dest = (forced_reg >= 0 ? forced_reg : DUK__ALLOCTEMP(comp_ctx));
59757 duk__emit_a_bc(comp_ctx, DUK_OP_LDCONST, (duk_regconst_t) dest, constidx);
59758 return (duk_regconst_t) dest;
59759 }
59760 case DUK_TAG_OBJECT: {
59762 break;
59763 }
59764 case DUK_TAG_BUFFER: {
59766 break;
59767 }
59768 case DUK_TAG_LIGHTFUNC: {
59770 break;
59771 }
59772#if defined(DUK_USE_FASTINT)
59773 case DUK_TAG_FASTINT:
59774#endif
59775 default: {
59776 /* number */
59777 duk_reg_t dest;
59778 duk_regconst_t constidx;
59779 duk_double_t dval;
59780 duk_int32_t ival;
59781
59784 dval = DUK_TVAL_GET_NUMBER(tv);
59785
59786 if (!(flags & DUK__IVAL_FLAG_ALLOW_CONST)) {
59787 /* A number can be loaded either through a constant, using
59788 * LDINT, or using LDINT+LDINTX. LDINT is always a size win,
59789 * LDINT+LDINTX is not if the constant is used multiple times.
59790 * Currently always prefer LDINT+LDINTX over a double constant.
59791 */
59792
59793 if (duk__is_whole_get_int32(dval, &ival)) {
59794 dest = (forced_reg >= 0 ? forced_reg : DUK__ALLOCTEMP(comp_ctx));
59795 duk__emit_load_int32(comp_ctx, dest, ival);
59796 return (duk_regconst_t) dest;
59797 }
59798 }
59799
59800 duk_dup(ctx, x->valstack_idx);
59801 constidx = duk__getconst(comp_ctx);
59802
59803 if (flags & DUK__IVAL_FLAG_ALLOW_CONST) {
59804 return constidx;
59805 } else {
59806 dest = (forced_reg >= 0 ? forced_reg : DUK__ALLOCTEMP(comp_ctx));
59807 duk__emit_a_bc(comp_ctx, DUK_OP_LDCONST, (duk_regconst_t) dest, constidx);
59808 return (duk_regconst_t) dest;
59809 }
59810 }
59811 } /* end switch */
59812 }
59813 case DUK_ISPEC_REGCONST: {
59814 if (forced_reg >= 0) {
59815 if (x->regconst & DUK__CONST_MARKER) {
59816 duk__emit_a_bc(comp_ctx, DUK_OP_LDCONST, forced_reg, x->regconst);
59817 } else if (x->regconst != (duk_regconst_t) forced_reg) {
59818 duk__emit_a_bc(comp_ctx, DUK_OP_LDREG, forced_reg, x->regconst);
59819 } else {
59820 ; /* already in correct reg */
59821 }
59822 return (duk_regconst_t) forced_reg;
59823 }
59824
59825 DUK_ASSERT(forced_reg < 0);
59826 if (x->regconst & DUK__CONST_MARKER) {
59827 if (!(flags & DUK__IVAL_FLAG_ALLOW_CONST)) {
59828 duk_reg_t dest = DUK__ALLOCTEMP(comp_ctx);
59830 return (duk_regconst_t) dest;
59831 }
59832 return x->regconst;
59833 }
DUK_LOCAL_DECL void duk__emit_load_int32(duk_compiler_ctx *comp_ctx, duk_reg_t reg, duk_int32_t val)
#define DUK_EXTRAOP_LDNULL
#define DUK__IVAL_FLAG_REQUIRE_SHORT
#define DUK_EXTRAOP_LDTRUE
#define DUK_EXTRAOP_LDUNDEF

References DUK__ALLOCTEMP, DUK__CONST_MARKER, duk__emit_a_bc(), duk__emit_extraop_bc(), duk__emit_load_int32(), duk__getconst(), duk__is_whole_get_int32(), DUK__IVAL_FLAG_ALLOW_CONST, DUK__IVAL_FLAG_REQUIRE_SHORT, DUK__IVAL_FLAG_REQUIRE_TEMP, DUK_ASSERT, DUK_DDD, DUK_DDDPRINT, duk_dup(), DUK_EXTRAOP_LDFALSE, DUK_EXTRAOP_LDNULL, DUK_EXTRAOP_LDTRUE, DUK_EXTRAOP_LDUNDEF, duk_get_tval(), DUK_GET_TVAL_POSIDX, DUK_HSTRING_GET_BYTELEN, DUK_ISPEC_REGCONST, DUK_ISPEC_VALUE, DUK_OP_LDCONST, DUK_OP_LDREG, DUK_TAG_BOOLEAN, DUK_TAG_BUFFER, DUK_TAG_LIGHTFUNC, DUK_TAG_NULL, DUK_TAG_OBJECT, DUK_TAG_POINTER, DUK_TAG_STRING, DUK_TAG_UNDEFINED, DUK_TVAL_GET_BOOLEAN, DUK_TVAL_GET_NUMBER, DUK_TVAL_GET_STRING, DUK_TVAL_GET_TAG, DUK_TVAL_IS_NUMBER, DUK_TVAL_IS_UNUSED, DUK_UNREACHABLE, DUK_UNREF, NULL, duk_ispec::regconst, duk_ispec::t, duk_compiler_ctx::thr, and duk_ispec::valstack_idx.

◆ duk__ivalue_toforcedreg()

DUK_LOCAL_DECL void duk__ivalue_toforcedreg ( duk_compiler_ctx * comp_ctx,
duk_ivalue * x,
duk_int_t forced_reg )

Definition at line 60129 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__parse_var_decl().

◆ duk__ivalue_toplain()

DUK_LOCAL_DECL void duk__ivalue_toplain ( duk_compiler_ctx * comp_ctx,
duk_ivalue * x )

Definition at line 60061 of file duktape-1.8.0/src/duktape.c.

◆ duk__ivalue_toplain_ignore()

DUK_LOCAL_DECL void duk__ivalue_toplain_ignore ( duk_compiler_ctx * comp_ctx,
duk_ivalue * x )

Definition at line 60066 of file duktape-1.8.0/src/duktape.c.

60066 :
60067 default: {
60068 DUK_D(DUK_DPRINT("invalid ivalue type: %ld", (long) x->t));
60069 break;
60070 }
60071 }
60072
60074 return;
60075}

References DUK_D, DUK_DPRINT, and duk_ivalue::t.

Referenced by duk__exprtop_toforcedreg().

◆ duk__ivalue_toplain_raw()

DUK_LOCAL_DECL void duk__ivalue_toplain_raw ( duk_compiler_ctx * comp_ctx,
duk_ivalue * x,
duk_reg_t forced_reg )

Definition at line 59845 of file duktape-1.8.0/src/duktape.c.

59852 {
59853 DUK_ASSERT(forced_reg >= 0);
59854 (void) duk__ispec_toregconst_raw(comp_ctx, x, forced_reg, 0 /*flags*/);
59855}
59856
59857/* Coerce an duk_ivalue to a 'plain' value by generating the necessary
59858 * arithmetic operations, property access, or variable access bytecode.
59859 * The duk_ivalue argument ('x') is converted into a plain value as a
59860 * side effect.
59861 */
59863 duk_hthread *thr = comp_ctx->thr;
59864 duk_context *ctx = (duk_context *) thr;
59865
59866 DUK_DDD(DUK_DDDPRINT("duk__ivalue_toplain_raw(): x={t=%ld,op=%ld,x1={%ld:%ld:%!T},x2={%ld:%ld:%!T}}, "
59867 "forced_reg=%ld",
59868 (long) x->t, (long) x->op,
59869 (long) x->x1.t, (long) x->x1.regconst,
59870 (duk_tval *) duk_get_tval(ctx, x->x1.valstack_idx),
59871 (long) x->x2.t, (long) x->x2.regconst,
59872 (duk_tval *) duk_get_tval(ctx, x->x2.valstack_idx),
59873 (long) forced_reg));
59874
59875 switch (x->t) {
59876 case DUK_IVAL_PLAIN: {
59877 return;
59878 }
59879 /* XXX: support unary arithmetic ivalues (useful?) */
59880 case DUK_IVAL_ARITH:
59882 duk_regconst_t arg1;
59883 duk_regconst_t arg2;
59884 duk_reg_t dest;
59885 duk_tval *tv1;
59886 duk_tval *tv2;
59887
59888 DUK_DDD(DUK_DDDPRINT("arith to plain conversion"));
59889
59890 /* inline arithmetic check for constant values */
59891 /* XXX: use the exactly same arithmetic function here as in executor */
59892 if (x->x1.t == DUK_ISPEC_VALUE && x->x2.t == DUK_ISPEC_VALUE && x->t == DUK_IVAL_ARITH) {
59893 tv1 = DUK_GET_TVAL_POSIDX(ctx, x->x1.valstack_idx);
59894 tv2 = DUK_GET_TVAL_POSIDX(ctx, x->x2.valstack_idx);
59895 DUK_ASSERT(tv1 != NULL);
59896 DUK_ASSERT(tv2 != NULL);
59897
59898 DUK_DDD(DUK_DDDPRINT("arith: tv1=%!T, tv2=%!T",
59899 (duk_tval *) tv1,
59900 (duk_tval *) tv2));
59901
59902 if (DUK_TVAL_IS_NUMBER(tv1) && DUK_TVAL_IS_NUMBER(tv2)) {
59905 duk_double_t d3;
59906 duk_bool_t accept = 1;
59907
59908 DUK_DDD(DUK_DDDPRINT("arith inline check: d1=%lf, d2=%lf, op=%ld",
59909 (double) d1, (double) d2, (long) x->op));
59910 switch (x->op) {
59911 case DUK_OP_ADD: d3 = d1 + d2; break;
59912 case DUK_OP_SUB: d3 = d1 - d2; break;
59913 case DUK_OP_MUL: d3 = d1 * d2; break;
59914 case DUK_OP_DIV: d3 = d1 / d2; break;
59915 default: accept = 0; break;
59916 }
59917
59918 if (accept) {
59920 du.d = d3;
59922 d3 = du.d;
59923
59924 x->t = DUK_IVAL_PLAIN;
59926 DUK_TVAL_SET_NUMBER(tv1, d3); /* old value is number: no refcount */
59927 return;
59928 }
59929 } else if (x->op == DUK_OP_ADD && DUK_TVAL_IS_STRING(tv1) && DUK_TVAL_IS_STRING(tv2)) {
59930 /* inline string concatenation */
59931 duk_dup(ctx, x->x1.valstack_idx);
59932 duk_dup(ctx, x->x2.valstack_idx);
59933 duk_concat(ctx, 2);
59934 duk_replace(ctx, x->x1.valstack_idx);
59935 x->t = DUK_IVAL_PLAIN;
59937 return;
59938 }
59939 }
59940
59943
59944 /* If forced reg, use it as destination. Otherwise try to
59945 * use either coerced ispec if it is a temporary.
59946 *
59947 * When using extraops, avoid reusing arg2 as dest because that
59948 * would lead to an LDREG shuffle below. We still can't guarantee
59949 * dest != arg2 because we may have a forced_reg.
59950 */
59951 if (forced_reg >= 0) {
59952 dest = forced_reg;
59953 } else if (DUK__ISTEMP(comp_ctx, arg1)) {
59954 dest = (duk_reg_t) arg1;
59955 } else if (DUK__ISTEMP(comp_ctx, arg2) && x->t != DUK_IVAL_ARITH_EXTRAOP) {
59956 dest = (duk_reg_t) arg2;
59957 } else {
59958 dest = DUK__ALLOCTEMP(comp_ctx);
59959 }
59960
59961 /* Extraop arithmetic opcodes must have destination same as
59962 * first source. If second source matches destination we need
59963 * a temporary register to avoid clobbering the second source.
59964 *
59965 * XXX: change calling code to avoid this situation in most cases.
59966 */
59967
59968 if (x->t == DUK_IVAL_ARITH_EXTRAOP) {
59969 if (!(DUK__ISREG(comp_ctx, arg1) && (duk_reg_t) arg1 == dest)) {
59970 if (DUK__ISREG(comp_ctx, arg2) && (duk_reg_t) arg2 == dest) {
59971 /* arg2 would be clobbered so reassign it to a temp. */
59972 duk_reg_t tempreg;
59973 tempreg = DUK__ALLOCTEMP(comp_ctx);
59974 duk__emit_a_bc(comp_ctx, DUK_OP_LDREG, tempreg, arg2);
59975 arg2 = tempreg;
59976 }
59977
59978 if (DUK__ISREG(comp_ctx, arg1)) {
59979 duk__emit_a_bc(comp_ctx, DUK_OP_LDREG, dest, arg1);
59980 } else {
59981 DUK_ASSERT(DUK__ISCONST(comp_ctx, arg1));
59982 duk__emit_a_bc(comp_ctx, DUK_OP_LDCONST, dest, arg1);
59983 }
59984 }
59985
59986 /* Note: special DUK__EMIT_FLAG_B_IS_TARGETSOURCE
59987 * used to indicate that B is both a source and a
59988 * target register. When shuffled, it needs to be
59989 * both input and output shuffled.
59990 */
59991 DUK_ASSERT(DUK__ISREG(comp_ctx, dest));
59992 duk__emit_extraop_b_c(comp_ctx,
59995 (duk_regconst_t) dest,
59996 (duk_regconst_t) arg2);
59997
59998 } else {
59999 DUK_ASSERT(DUK__ISREG(comp_ctx, dest));
60000 duk__emit_a_b_c(comp_ctx, x->op, (duk_regconst_t) dest, arg1, arg2);
60001 }
60002
60003 x->t = DUK_IVAL_PLAIN;
60004 x->x1.t = DUK_ISPEC_REGCONST;
60005 x->x1.regconst = (duk_regconst_t) dest;
60006 return;
60007 }
60008 case DUK_IVAL_PROP: {
60009 /* XXX: very similar to DUK_IVAL_ARITH - merge? */
60010 duk_regconst_t arg1;
60011 duk_regconst_t arg2;
60012 duk_reg_t dest;
60013
60014 /* Need a short reg/const, does not have to be a mutable temp. */
60017
60018 /* Pick a destination register. If either base value or key
60019 * happens to be a temp value, reuse it as the destination.
60020 *
60021 * XXX: The temp must be a "mutable" one, i.e. such that no
60022 * other expression is using it anymore. Here this should be
60023 * the case because the value of a property access expression
60024 * is neither the base nor the key, but the lookup result.
60025 */
60026
60027 if (forced_reg >= 0) {
60028 dest = forced_reg;
60029 } else if (DUK__ISTEMP(comp_ctx, arg1)) {
60030 dest = (duk_reg_t) arg1;
60031 } else if (DUK__ISTEMP(comp_ctx, arg2)) {
60032 dest = (duk_reg_t) arg2;
60033 } else {
60034 dest = DUK__ALLOCTEMP(comp_ctx);
60035 }
60036
60037 duk__emit_a_b_c(comp_ctx, DUK_OP_GETPROP, (duk_regconst_t) dest, arg1, arg2);
60038
60039 x->t = DUK_IVAL_PLAIN;
60040 x->x1.t = DUK_ISPEC_REGCONST;
60041 x->x1.regconst = (duk_regconst_t) dest;
60042 return;
60043 }
60044 case DUK_IVAL_VAR: {
60045 /* x1 must be a string */
60046 duk_reg_t dest;
60047 duk_reg_t reg_varbind;
60048 duk_regconst_t rc_varname;
60049
60051
60052 duk_dup(ctx, x->x1.valstack_idx);
60053 if (duk__lookup_lhs(comp_ctx, &reg_varbind, &rc_varname)) {
60054 x->t = DUK_IVAL_PLAIN;
60055 x->x1.t = DUK_ISPEC_REGCONST;
60056 x->x1.regconst = (duk_regconst_t) reg_varbind;
60057 } else {
60058 dest = (forced_reg >= 0 ? forced_reg : DUK__ALLOCTEMP(comp_ctx));
DUK_EXTERNAL void duk_concat(duk_context *ctx, duk_idx_t count)
duk_int32_t duk_reg_t
#define DUK__ISREG(comp_ctx, x)
DUK_LOCAL_DECL void duk__ivalue_toplain_raw(duk_compiler_ctx *comp_ctx, duk_ivalue *x, duk_reg_t forced_reg)
#define DUK__ISCONST(comp_ctx, x)

◆ duk__ivalue_toreg()

DUK_LOCAL_DECL duk_reg_t duk__ivalue_toreg ( duk_compiler_ctx * comp_ctx,
duk_ivalue * x )

Definition at line 60119 of file duktape-1.8.0/src/duktape.c.

60120 : 0),
60121 (long) ((flags & DUK__IVAL_FLAG_REQUIRE_TEMP) ? 1 : 0),

Referenced by duk__parse_var_decl().

◆ duk__ivalue_toregconst()

DUK_LOCAL_DECL duk_regconst_t duk__ivalue_toregconst ( duk_compiler_ctx * comp_ctx,
duk_ivalue * x )

Definition at line 60134 of file duktape-1.8.0/src/duktape.c.

60136 {

Referenced by duk__expr_toplain_ignore().

◆ duk__ivalue_toregconst_raw()

DUK_LOCAL_DECL duk_regconst_t duk__ivalue_toregconst_raw ( duk_compiler_ctx * comp_ctx,
duk_ivalue * x,
duk_reg_t forced_reg,
duk_small_uint_t flags )

Definition at line 60084 of file duktape-1.8.0/src/duktape.c.

60104 {
60105 duk_hthread *thr = comp_ctx->thr;
60106 duk_context *ctx = (duk_context *) thr;
60107 duk_regconst_t reg;
60108 DUK_UNREF(thr);
60109 DUK_UNREF(ctx);
60110
60111 DUK_DDD(DUK_DDDPRINT("duk__ivalue_toregconst_raw(): x={t=%ld,op=%ld,x1={%ld:%ld:%!T},x2={%ld:%ld:%!T}}, "
60112 "forced_reg=%ld, flags 0x%08lx: allow_const=%ld require_temp=%ld require_short=%ld",
60113 (long) x->t, (long) x->op,
60114 (long) x->x1.t, (long) x->x1.regconst,
60115 (duk_tval *) duk_get_tval(ctx, x->x1.valstack_idx),
60116 (long) x->x2.t, (long) x->x2.regconst,
60117 (duk_tval *) duk_get_tval(ctx, x->x2.valstack_idx),

Referenced by duk__lookup_active_register_binding().

◆ duk__ivalue_totempconst()

DUK_LOCAL_DECL duk_regconst_t duk__ivalue_totempconst ( duk_compiler_ctx * comp_ctx,
duk_ivalue * x )

Definition at line 60138 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__exprtop_toreg().

◆ duk__js_compile_raw()

DUK_LOCAL duk_ret_t duk__js_compile_raw ( duk_context * ctx)

Definition at line 65398 of file duktape-1.8.0/src/duktape.c.

65415 {
65416 duk_hthread *thr = (duk_hthread *) ctx;
65417 duk_hstring *h_filename;
65418 duk__compiler_stkstate *comp_stk;
65419 duk_compiler_ctx *comp_ctx;
65420 duk_lexer_point *lex_pt;
65421 duk_compiler_func *func;
65422 duk_idx_t entry_top;
65423 duk_bool_t is_strict;
65424 duk_bool_t is_eval;
65425 duk_bool_t is_funcexpr;
65426 duk_small_uint_t flags;
65427
65428 DUK_ASSERT(thr != NULL);
65429
65430 /*
65431 * Arguments check
65432 */
65433
65434 entry_top = duk_get_top(ctx);
65435 DUK_ASSERT(entry_top >= 2);
65436
65437 comp_stk = (duk__compiler_stkstate *) duk_require_pointer(ctx, -1);
65438 comp_ctx = &comp_stk->comp_ctx_alloc;
65439 lex_pt = &comp_stk->lex_pt_alloc;
65440 DUK_ASSERT(comp_ctx != NULL);
65441 DUK_ASSERT(lex_pt != NULL);
65442
65443 flags = comp_stk->flags;
65444 is_eval = (flags & DUK_JS_COMPILE_FLAG_EVAL ? 1 : 0);
65445 is_strict = (flags & DUK_JS_COMPILE_FLAG_STRICT ? 1 : 0);
65446 is_funcexpr = (flags & DUK_JS_COMPILE_FLAG_FUNCEXPR ? 1 : 0);
65447
65448 h_filename = duk_get_hstring(ctx, -2); /* may be undefined */
65449
65450 /*
65451 * Init compiler and lexer contexts
65452 */
65453
65454 func = &comp_ctx->curr_func;
65455#ifdef DUK_USE_EXPLICIT_NULL_INIT
65456 comp_ctx->thr = NULL;
65457 comp_ctx->h_filename = NULL;
65458 comp_ctx->prev_token.str1 = NULL;
65459 comp_ctx->prev_token.str2 = NULL;
65460 comp_ctx->curr_token.str1 = NULL;
65461 comp_ctx->curr_token.str2 = NULL;
65462#endif
65463
65465
65466 duk_push_dynamic_buffer(ctx, 0); /* entry_top + 0 */
65467 duk_push_undefined(ctx); /* entry_top + 1 */
65468 duk_push_undefined(ctx); /* entry_top + 2 */
65469 duk_push_undefined(ctx); /* entry_top + 3 */
65470 duk_push_undefined(ctx); /* entry_top + 4 */
65471
65472 comp_ctx->thr = thr;
65473 comp_ctx->h_filename = h_filename;
65474 comp_ctx->tok11_idx = entry_top + 1;
65475 comp_ctx->tok12_idx = entry_top + 2;
65476 comp_ctx->tok21_idx = entry_top + 3;
65477 comp_ctx->tok22_idx = entry_top + 4;
65479
65480 /* comp_ctx->lex has been pre-initialized by caller: it has been
65481 * zeroed and input/input_length has been set.
65482 */
65483 comp_ctx->lex.thr = thr;
65484 /* comp_ctx->lex.input and comp_ctx->lex.input_length filled by caller */
65485 comp_ctx->lex.slot1_idx = comp_ctx->tok11_idx;
65486 comp_ctx->lex.slot2_idx = comp_ctx->tok12_idx;
65487 comp_ctx->lex.buf_idx = entry_top + 0;
65488 comp_ctx->lex.buf = (duk_hbuffer_dynamic *) duk_get_hbuffer(ctx, entry_top + 0);
65489 DUK_ASSERT(comp_ctx->lex.buf != NULL);
65492
65493 lex_pt->offset = 0;
65494 lex_pt->line = 1;
65495 DUK_LEXER_SETPOINT(&comp_ctx->lex, lex_pt); /* fills window */
65496 comp_ctx->curr_token.start_line = 0; /* needed for line number tracking (becomes prev_token.start_line) */
65497
65498 /*
65499 * Initialize function state for a zero-argument function
65500 */
65501
65503 DUK_ASSERT(func->num_formals == 0);
65504
65505 if (is_funcexpr) {
65506 /* Name will be filled from function expression, not by caller.
65507 * This case is used by Function constructor and duk_compile()
65508 * API with the DUK_COMPILE_FUNCTION option.
65509 */
65510 DUK_ASSERT(func->h_name == NULL);
65511 } else {
65514 func->h_name = duk_get_hstring(ctx, -1);
65515 }
65516
65517 /*
65518 * Parse a function body or a function-like expression, depending
65519 * on flags.
65520 */
65521
65522 func->is_strict = is_strict;
65523 func->is_setget = 0;
65524 func->is_decl = 0;
65525
65526 if (is_funcexpr) {
65527 func->is_function = 1;
65528 func->is_eval = 0;
65529 func->is_global = 0;
65530
65531 duk__advance(comp_ctx); /* init 'curr_token' */
65533 (void) duk__parse_func_like_raw(comp_ctx,
65534 0, /* is_decl */
65535 0); /* is_setget */
65536 } else {
65537 func->is_function = 0;
65538 func->is_eval = is_eval;
65539 func->is_global = !is_eval;
65540
65541 duk__parse_func_body(comp_ctx,
65542 1, /* expect_eof */
65543 1, /* implicit_return_value */
#define duk_push_dynamic_buffer(ctx, size)
#define DUK_STRIDX_GLOBAL
DUK_LOCAL_DECL void duk__parse_func_like_raw(duk_compiler_ctx *comp_ctx, duk_bool_t is_decl, duk_bool_t is_setget)
#define DUK_COMPILER_TOKEN_LIMIT
DUK_LOCAL_DECL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_small_int_t expect_token)
#define DUK_LEXER_SETPOINT(ctx, pt)
#define DUK__COMPILE_ENTRY_SLOTS
#define DUK_HBUFFER_HAS_EXTERNAL(x)
#define DUK_HBUFFER_HAS_DYNAMIC(x)

◆ duk__js_equals_number()

DUK_LOCAL duk_bool_t duk__js_equals_number ( duk_double_t x,
duk_double_t y )

Definition at line 70537 of file duktape-1.8.0/src/duktape.c.

70540 :
70541 *
70542 * - Current implementation (and spec definition) has recursion; this should
70543 * be fixed if possible.
70544 *
70545 * - String-to-number coercion should be possible without going through the
70546 * value stack (and be more compact) if a shared helper is invoked.
70547 */
70548
70549/* Note that this is the same operation for strict and loose equality:
70550 * - E5 Section 11.9.3, step 1.c (loose)
70551 * - E5 Section 11.9.6, step 4 (strict)
70552 */
70553
70555#if defined(DUK_USE_PARANOID_MATH)
70556 /* Straightforward algorithm, makes fewer compiler assumptions. */
70559 if (cx == DUK_FP_NAN || cy == DUK_FP_NAN) {
70560 return 0;
70561 }
70562 if (cx == DUK_FP_ZERO && cy == DUK_FP_ZERO) {
70563 return 1;
70564 }
70565 if (x == y) {
70566 return 1;
70567 }
70568 return 0;
70569#else /* DUK_USE_PARANOID_MATH */
70570 /* Better equivalent algorithm. If the compiler is compliant, C and
70571 * Ecmascript semantics are identical for this particular comparison.
70572 * In particular, NaNs must never compare equal and zeroes must compare
70573 * equal regardless of sign. Could also use a macro, but this inlines
DUK_LOCAL duk_bool_t duk__js_equals_number(duk_double_t x, duk_double_t y)

References DUK_FP_NAN, DUK_FP_ZERO, and DUK_FPCLASSIFY.

◆ duk__js_execute_bytecode_inner()

DUK_LOCAL_DECL void duk__js_execute_bytecode_inner ( duk_hthread * entry_thread,
duk_size_t entry_callstack_top )

Definition at line 67712 of file duktape-1.8.0/src/duktape.c.

67712 {
67713 DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ exception"));
67714 DUK_UNREF(exc);
67716 entry_thread,
67717 entry_callstack_top,
67718 entry_call_recursion_depth,
67719 entry_jmpbuf_ptr);
67720 }
67721 }
67722#endif
67723 }
67724
67726}
67727
67728/* Inner executor, performance critical. */
67729DUK_LOCAL DUK_NOINLINE void duk__js_execute_bytecode_inner(duk_hthread *entry_thread, duk_size_t entry_callstack_top) {
67730 /* Current PC, accessed by other functions through thr->ptr_to_curr_pc.
67731 * Critical for performance. It would be safest to make this volatile,
67732 * but that eliminates performance benefits; aliasing guarantees
67733 * should be enough though.
67734 */
67735 duk_instr_t *curr_pc; /* bytecode has a stable pointer */
67736
67737 /* Hot variables for interpretation. Critical for performance,
67738 * but must add sparingly to minimize register shuffling.
67739 */
67740 duk_hthread *thr; /* stable */
67741 duk_tval *consts; /* stable */
67742 duk_tval *consts2; /* stable; precalculated for faster lookups */
67744 /* 'funcs' is quite rarely used, so no local for it */
67745#if defined(DUK_USE_EXEC_FUN_LOCAL)
67747#else
67748 /* 'fun' is quite rarely used, so no local for it */
67749#endif
67750
67751#ifdef DUK_USE_INTERRUPT_COUNTER
67752 duk_int_t int_ctr;
67753#endif
67754
67755#ifdef DUK_USE_ASSERTIONS
67756 duk_size_t valstack_top_base; /* valstack top, should match before interpreting each op (no leftovers) */
67757#endif
67758
67759 /*
67760 * Restart execution by reloading thread state.
67761 *
67762 * Note that 'thr' and any thread configuration may have changed,
67763 * so all local variables are suspect and we need to reinitialize.
67764 *
67765 * The number of local variables should be kept to a minimum: if
67766 * the variables are spilled, they will need to be loaded from
67767 * memory anyway.
67768 *
67769 * Any 'goto restart_execution;' code path in opcode dispatch must
67770 * ensure 'curr_pc' is synced back to act->curr_pc before the goto
67771 * takes place.
67772 *
67773 * The interpreter must be very careful with memory pointers, as
67774 * many pointers are not guaranteed to be 'stable' and may be
67775 * reallocated and relocated on-the-fly quite easily (e.g. by a
67776 * memory allocation or a property access).
67777 *
67778 * The following are assumed to have stable pointers:
67779 * - the current thread
67780 * - the current function
67781 * - the bytecode, constant table, inner function table of the
67782 * current function (as they are a part of the function allocation)
67783 *
67784 * The following are assumed to have semi-stable pointers:
67785 * - the current activation entry: stable as long as callstack
67786 * is not changed (reallocated by growing or shrinking), or
67787 * by any garbage collection invocation (through finalizers)
67788 * - Note in particular that ANY DECREF can invalidate the
67789 * activation pointer, so for the most part a fresh lookup
67790 * is required
67791 *
67792 * The following are not assumed to have stable pointers at all:
67793 * - the value stack (registers) of the current thread
67794 * - the catch stack of the current thread
67795 *
67796 * See execution.rst for discussion.
67797 */
67798
67799 restart_execution:
67800
67801 /* Lookup current thread; use the stable 'entry_thread' for this to
67802 * avoid clobber warnings. Any valid, reachable 'thr' value would be
67803 * fine for this, so using 'entry_thread' is just to silence warnings.
67804 */
67805 thr = entry_thread->heap->curr_thread;
67806 DUK_ASSERT(thr != NULL);
67807 DUK_ASSERT(thr->callstack_top >= 1);
67810
67811 thr->ptr_curr_pc = &curr_pc;
67812
67813 /* Relookup and initialize dispatch loop variables. Debugger check. */
67814 {
67815 duk_activation *act;
67816#if !defined(DUK_USE_EXEC_FUN_LOCAL)
67818#endif
67819
67820 /* Assume interrupt init/counter are properly initialized here. */
67821 /* Assume that thr->valstack_bottom has been set-up before getting here. */
67822
67823 act = thr->callstack + thr->callstack_top - 1;
67825 DUK_ASSERT(fun != NULL);
67826 DUK_ASSERT(thr->valstack_top - thr->valstack_bottom == fun->nregs);
67827 consts = DUK_HCOMPILEDFUNCTION_GET_CONSTS_BASE(thr->heap, fun);
67828 DUK_ASSERT(consts != NULL);
67829 consts2 = consts - DUK_BC_REGLIMIT;
67830
67831#if defined(DUK_USE_DEBUGGER_SUPPORT)
67832 if (DUK_HEAP_IS_DEBUGGER_ATTACHED(thr->heap) && !thr->heap->dbg_processing) {
67833 duk__executor_recheck_debugger(thr, act, fun);
67834 act = thr->callstack + thr->callstack_top - 1; /* relookup after side effects (no side effects currently however) */
67835 }
67836#endif /* DUK_USE_DEBUGGER_SUPPORT */
67837
67838#ifdef DUK_USE_ASSERTIONS
67839 valstack_top_base = (duk_size_t) (thr->valstack_top - thr->valstack);
67840#endif
67841
67842 /* Set up curr_pc for opcode dispatch. */
67843 curr_pc = act->curr_pc;
67844 }
67845
67846 DUK_DD(DUK_DDPRINT("restarting execution, thr %p, act idx %ld, fun %p,"
67847 "consts %p, funcs %p, lev %ld, regbot %ld, regtop %ld, catchstack_top=%ld, "
67848 "preventcount=%ld",
67849 (void *) thr,
67850 (long) (thr->callstack_top - 1),
67851 (void *) DUK__FUN(),
67852 (void *) DUK_HCOMPILEDFUNCTION_GET_CONSTS_BASE(thr->heap, DUK__FUN()),
67853 (void *) DUK_HCOMPILEDFUNCTION_GET_FUNCS_BASE(thr->heap, DUK__FUN()),
67854 (long) (thr->callstack_top - 1),
67855 (long) (thr->valstack_bottom - thr->valstack),
67856 (long) (thr->valstack_top - thr->valstack),
67857 (long) thr->catchstack_top,
67858 (long) thr->callstack_preventcount));
67859
67860 /* Dispatch loop. */
67861
67862 for (;;) {
67863 DUK_ASSERT(thr->callstack_top >= 1);
67864 DUK_ASSERT(thr->valstack_top - thr->valstack_bottom == DUK__FUN()->nregs);
67865 DUK_ASSERT((duk_size_t) (thr->valstack_top - thr->valstack) == valstack_top_base);
67866
67867 /* Executor interrupt counter check, used to implement breakpoints,
67868 * debugging interface, execution timeouts, etc. The counter is heap
67869 * specific but is maintained in the current thread to make the check
67870 * as fast as possible. The counter is copied back to the heap struct
67871 * whenever a thread switch occurs by the DUK_HEAP_SWITCH_THREAD() macro.
67872 */
67873#if defined(DUK_USE_INTERRUPT_COUNTER)
67874 int_ctr = thr->interrupt_counter;
67875 if (DUK_LIKELY(int_ctr > 0)) {
67876 thr->interrupt_counter = int_ctr - 1;
67877 } else {
67878 /* Trigger at zero or below */
67879 duk_small_uint_t exec_int_ret;
67880
67881 /* Write curr_pc back for the debugger. */
67882 DUK_ASSERT(thr->callstack_top > 0);
67883 {
67884 duk_activation *act;
67885 act = thr->callstack + thr->callstack_top - 1;
67886 act->curr_pc = (duk_instr_t *) curr_pc;
67887 }
67888
67889 /* Force restart caused by a function return; must recheck
67890 * debugger breakpoints before checking line transitions,
67891 * see GH-303. Restart and then handle interrupt_counter
67892 * zero again.
67893 */
67894#if defined(DUK_USE_DEBUGGER_SUPPORT)
67895 if (thr->heap->dbg_force_restart) {
67896 DUK_DD(DUK_DDPRINT("dbg_force_restart flag forced restart execution")); /* GH-303 */
67897 thr->heap->dbg_force_restart = 0;
67898 goto restart_execution;
67899 }
67900#endif
67901
67902 exec_int_ret = duk__executor_interrupt(thr);
67903 if (exec_int_ret == DUK__INT_RESTART) {
67904 /* curr_pc synced back above */
67905 goto restart_execution;
67906 }
67907 }
67908#endif /* DUK_USE_INTERRUPT_COUNTER */
67909#if defined(DUK_USE_INTERRUPT_COUNTER) && defined(DUK_USE_DEBUG)
67910 /* For cross-checking during development: ensure dispatch count
67911 * matches cumulative interrupt counter init value sums.
67912 */
67913 thr->heap->inst_count_exec++;
67914#endif
67915
67916#if defined(DUK_USE_ASSERTIONS) || defined(DUK_USE_DEBUG)
67917 {
67918 duk_activation *act;
67919 act = thr->callstack + thr->callstack_top - 1;
67922 DUK_UNREF(act); /* if debugging disabled */
67923
67924 DUK_DDD(DUK_DDDPRINT("executing bytecode: pc=%ld, ins=0x%08lx, op=%ld, valstack_top=%ld/%ld, nregs=%ld --> %!I",
67925 (long) (curr_pc - DUK_HCOMPILEDFUNCTION_GET_CODE_BASE(thr->heap, DUK__FUN())),
67926 (unsigned long) *curr_pc,
67927 (long) DUK_DEC_OP(*curr_pc),
67928 (long) (thr->valstack_top - thr->valstack),
67929 (long) (thr->valstack_end - thr->valstack),
67930 (long) (DUK__FUN() ? DUK__FUN()->nregs : -1),
67931 (duk_instr_t) *curr_pc));
67932 }
67933#endif
67934
67935#if defined(DUK_USE_ASSERTIONS)
67936 /* Quite heavy assert: check valstack policy. Improper
67937 * shuffle instructions can write beyond valstack_top/end
67938 * so this check catches them in the act.
67939 */
67940 {
67941 duk_tval *tv;
67942 tv = thr->valstack_top;
67943 while (tv != thr->valstack_end) {
67945 tv++;
67946 }
67947 }
67948#endif
67949
67950 ins = *curr_pc++;
67951
67952 /* Typing: use duk_small_(u)int_fast_t when decoding small
67953 * opcode fields (op, A, B, C) and duk_(u)int_fast_t when
67954 * decoding larger fields (e.g. BC which is 18 bits). Use
67955 * unsigned variant by default, signed when the value is used
67956 * in signed arithmetic. Using variable names such as 'a', 'b',
67957 * 'c', 'bc', etc makes it easier to spot typing mismatches.
67958 */
67959
67960 /* XXX: the best typing needs to be validated by perf measurement:
67961 * e.g. using a small type which is the cast to a larger duk_idx_t
67962 * may be slower than declaring the variable as a duk_idx_t in the
67963 * first place.
67964 */
67965
67966 /* XXX: use macros for the repetitive tval/refcount handling. */
67967
67968 switch ((int) DUK_DEC_OP(ins)) {
67969 /* XXX: switch cast? */
67970
67971 case DUK_OP_LDREG: {
67973 duk_uint_fast_t bc;
67974 duk_tval *tv1, *tv2;
67975
67976 a = DUK_DEC_A(ins); tv1 = DUK__REGP(a);
67977 bc = DUK_DEC_BC(ins); tv2 = DUK__REGP(bc);
67978 DUK_TVAL_SET_TVAL_UPDREF_FAST(thr, tv1, tv2); /* side effects */
67979 break;
67980 }
67981
67982 case DUK_OP_STREG: {
67984 duk_uint_fast_t bc;
67985 duk_tval *tv1, *tv2;
67986
67987 a = DUK_DEC_A(ins); tv1 = DUK__REGP(a);
67988 bc = DUK_DEC_BC(ins); tv2 = DUK__REGP(bc);
67989 DUK_TVAL_SET_TVAL_UPDREF_FAST(thr, tv2, tv1); /* side effects */
67990 break;
67991 }
67992
67993 case DUK_OP_LDCONST: {
67995 duk_uint_fast_t bc;
67996 duk_tval *tv1, *tv2;
67997
67998 a = DUK_DEC_A(ins); tv1 = DUK__REGP(a);
67999 bc = DUK_DEC_BC(ins); tv2 = DUK__CONSTP(bc);
68000 DUK_TVAL_SET_TVAL_UPDREF_FAST(thr, tv1, tv2); /* side effects */
68001 break;
68002 }
68003
68004 case DUK_OP_LDINT: {
68006 duk_int_fast_t bc;
68007 duk_tval *tv1;
68008#if defined(DUK_USE_FASTINT)
68009 duk_int32_t val;
68010#else
68011 duk_double_t val;
68012#endif
68013
68014#if defined(DUK_USE_FASTINT)
68015 a = DUK_DEC_A(ins); tv1 = DUK__REGP(a);
68016 bc = DUK_DEC_BC(ins); val = (duk_int32_t) (bc - DUK_BC_LDINT_BIAS);
68017 DUK_TVAL_SET_FASTINT_I32_UPDREF(thr, tv1, val); /* side effects */
68018#else
68019 a = DUK_DEC_A(ins); tv1 = DUK__REGP(a);
68020 bc = DUK_DEC_BC(ins); val = (duk_double_t) (bc - DUK_BC_LDINT_BIAS);
68021 DUK_TVAL_SET_NUMBER_UPDREF(thr, tv1, val); /* side effects */
68022#endif
68023 break;
68024 }
68025
68026 case DUK_OP_LDINTX: {
68028 duk_tval *tv1;
68029 duk_double_t val;
68030
68031 /* LDINTX is not necessarily in FASTINT range, so
68032 * no fast path for now.
68033 *
68034 * XXX: perhaps restrict LDINTX to fastint range, wider
68035 * range very rarely needed.
68036 */
68037
68038 a = DUK_DEC_A(ins); tv1 = DUK__REGP(a);
68040 val = DUK_TVAL_GET_NUMBER(tv1) * ((duk_double_t) (1L << DUK_BC_LDINTX_SHIFT)) +
68041 (duk_double_t) DUK_DEC_BC(ins);
68042#if defined(DUK_USE_FASTINT)
68044#else
68045 DUK_TVAL_SET_NUMBER(tv1, val);
68046#endif
68047 break;
68048 }
68049
68050 case DUK_OP_MPUTOBJ:
68051 case DUK_OP_MPUTOBJI: {
68052 duk_context *ctx = (duk_context *) thr;
68054 duk_tval *tv1;
68055 duk_hobject *obj;
68056 duk_uint_fast_t idx;
68058
68059 /* A -> register of target object
68060 * B -> first register of key/value pair list
68061 * C -> number of key/value pairs
68062 */
68063
68064 a = DUK_DEC_A(ins); tv1 = DUK__REGP(a);
68066 obj = DUK_TVAL_GET_OBJECT(tv1);
68067
68068 idx = (duk_uint_fast_t) DUK_DEC_B(ins);
68069 if (DUK_DEC_OP(ins) == DUK_OP_MPUTOBJI) {
68070 duk_tval *tv_ind = DUK__REGP(idx);
68072 idx = (duk_uint_fast_t) DUK_TVAL_GET_NUMBER(tv_ind);
68073 }
68074
68075 count = (duk_small_uint_fast_t) DUK_DEC_C(ins);
68076
68077#if defined(DUK_USE_EXEC_INDIRECT_BOUND_CHECK)
68078 if (DUK_UNLIKELY(idx + count * 2 > (duk_uint_fast_t) duk_get_top(ctx))) {
68079 /* XXX: use duk_is_valid_index() instead? */
68080 /* XXX: improve check; check against nregs, not against top */
68081 DUK__INTERNAL_ERROR("MPUTOBJ out of bounds");
68082 }
68083#endif
68084
68085 duk_push_hobject(ctx, obj);
68086
68087 while (count > 0) {
68088 /* XXX: faster initialization (direct access or better primitives) */
68089
68090 duk_push_tval(ctx, DUK__REGP(idx));
68091 DUK_ASSERT(duk_is_string(ctx, -1));
68092 duk_push_tval(ctx, DUK__REGP(idx + 1)); /* -> [... obj key value] */
68093 duk_xdef_prop_wec(ctx, -3); /* -> [... obj] */
68094
68095 count--;
68096 idx += 2;
68097 }
68098
68099 duk_pop(ctx); /* [... obj] -> [...] */
68100 break;
68101 }
68102
68103 case DUK_OP_MPUTARR:
68104 case DUK_OP_MPUTARRI: {
68105 duk_context *ctx = (duk_context *) thr;
68107 duk_tval *tv1;
68108 duk_hobject *obj;
68109 duk_uint_fast_t idx;
68111 duk_uint32_t arr_idx;
68112
68113 /* A -> register of target object
68114 * B -> first register of value data (start_index, value1, value2, ..., valueN)
68115 * C -> number of key/value pairs (N)
68116 */
68117
68118 a = DUK_DEC_A(ins); tv1 = DUK__REGP(a);
68120 obj = DUK_TVAL_GET_OBJECT(tv1);
68121 DUK_ASSERT(obj != NULL);
68122
68123 idx = (duk_uint_fast_t) DUK_DEC_B(ins);
68124 if (DUK_DEC_OP(ins) == DUK_OP_MPUTARRI) {
68125 duk_tval *tv_ind = DUK__REGP(idx);
68127 idx = (duk_uint_fast_t) DUK_TVAL_GET_NUMBER(tv_ind);
68128 }
68129
68130 count = (duk_small_uint_fast_t) DUK_DEC_C(ins);
68131
68132#if defined(DUK_USE_EXEC_INDIRECT_BOUND_CHECK)
68133 if (idx + count + 1 > (duk_uint_fast_t) duk_get_top(ctx)) {
68134 /* XXX: use duk_is_valid_index() instead? */
68135 /* XXX: improve check; check against nregs, not against top */
68136 DUK__INTERNAL_ERROR("MPUTARR out of bounds");
68137 }
68138#endif
68139
68140 tv1 = DUK__REGP(idx);
68142 arr_idx = (duk_uint32_t) DUK_TVAL_GET_NUMBER(tv1);
68143 idx++;
68144
68145 duk_push_hobject(ctx, obj);
68146
68147 while (count > 0) {
68148 /* duk_xdef_prop() will define an own property without any array
68149 * special behaviors. We'll need to set the array length explicitly
68150 * in the end. For arrays with elisions, the compiler will emit an
68151 * explicit SETALEN which will update the length.
68152 */
68153
68154 /* XXX: because we're dealing with 'own' properties of a fresh array,
68155 * the array initializer should just ensure that the array has a large
68156 * enough array part and write the values directly into array part,
68157 * and finally set 'length' manually in the end (as already happens now).
68158 */
68159
68160 duk_push_tval(ctx, DUK__REGP(idx)); /* -> [... obj value] */
68161 duk_xdef_prop_index_wec(ctx, -2, arr_idx); /* -> [... obj] */
68162
68163 /* XXX: could use at least one fewer loop counters */
68164 count--;
68165 idx++;
68166 arr_idx++;
68167 }
68168
68169 /* XXX: E5.1 Section 11.1.4 coerces the final length through
68170 * ToUint32() which is odd but happens now as a side effect of
68171 * 'arr_idx' type.
68172 */
68173 duk_hobject_set_length(thr, obj, (duk_uint32_t) arr_idx);
68174
68175 duk_pop(ctx); /* [... obj] -> [...] */
68176 break;
68177 }
68178
68179 case DUK_OP_NEW:
68180 case DUK_OP_NEWI: {
68181 duk_context *ctx = (duk_context *) thr;
68183 duk_uint_fast_t idx;
68185
68186 /* A -> unused (reserved for flags, for consistency with DUK_OP_CALL)
68187 * B -> target register and start reg: constructor, arg1, ..., argN
68188 * (for DUK_OP_NEWI, 'b' is indirect)
68189 * C -> num args (N)
68190 */
68191
68192 /* duk_new() will call the constuctor using duk_handle_call().
68193 * A constructor call prevents a yield from inside the constructor,
68194 * even if the constructor is an Ecmascript function.
68195 */
68196
68197 /* Don't need to sync curr_pc here; duk_new() will do that
68198 * when it augments the created error.
68199 */
68200
68201 /* XXX: unnecessary copying of values? Just set 'top' to
68202 * b + c, and let the return handling fix up the stack frame?
68203 */
68204
68205 idx = (duk_uint_fast_t) DUK_DEC_B(ins);
68206 if (DUK_DEC_OP(ins) == DUK_OP_NEWI) {
68207 duk_tval *tv_ind = DUK__REGP(idx);
68209 idx = (duk_uint_fast_t) DUK_TVAL_GET_NUMBER(tv_ind);
68210 }
68211
68212#if defined(DUK_USE_EXEC_INDIRECT_BOUND_CHECK)
68213 if (idx + c + 1 > (duk_uint_fast_t) duk_get_top(ctx)) {
68214 /* XXX: use duk_is_valid_index() instead? */
68215 /* XXX: improve check; check against nregs, not against top */
68216 DUK__INTERNAL_ERROR("NEW out of bounds");
68217 }
68218#endif
68219
68220 duk_require_stack(ctx, (duk_idx_t) c);
68221 duk_push_tval(ctx, DUK__REGP(idx));
68222 for (i = 0; i < c; i++) {
68223 duk_push_tval(ctx, DUK__REGP(idx + i + 1));
68224 }
68225 duk_new(ctx, (duk_idx_t) c); /* [... constructor arg1 ... argN] -> [retval] */
68226 DUK_DDD(DUK_DDDPRINT("NEW -> %!iT", (duk_tval *) duk_get_tval(ctx, -1)));
68227 duk_replace(ctx, (duk_idx_t) idx);
68228
68229 /* When debugger is enabled, we need to recheck the activation
68230 * status after returning. This is now handled by call handling
68231 * and heap->dbg_force_restart.
68232 */
68233 break;
68234 }
68235
68236 case DUK_OP_REGEXP: {
68237#ifdef DUK_USE_REGEXP_SUPPORT
68238 duk_context *ctx = (duk_context *) thr;
68242
68243 /* A -> target register
68244 * B -> bytecode (also contains flags)
68245 * C -> escaped source
68246 */
68247
68249 duk_push_tval(ctx, DUK__REGCONSTP(b)); /* -> [ ... escaped_source bytecode ] */
68250 duk_regexp_create_instance(thr); /* -> [ ... regexp_instance ] */
68251 DUK_DDD(DUK_DDDPRINT("regexp instance: %!iT", (duk_tval *) duk_get_tval(ctx, -1)));
68252 duk_replace(ctx, (duk_idx_t) a);
68253#else
68254 /* The compiler should never emit DUK_OP_REGEXP if there is no
68255 * regexp support.
68256 */
68257 DUK__INTERNAL_ERROR("no regexp support");
68258#endif
68259
68260 break;
68261 }
68262
68263 case DUK_OP_CSREG:
68264 case DUK_OP_CSREGI: {
68265 /*
68266 * Assuming a register binds to a variable declared within this
68267 * function (a declarative binding), the 'this' for the call
68268 * setup is always 'undefined'. E5 Section 10.2.1.1.6.
68269 */
68270
68271 duk_context *ctx = (duk_context *) thr;
68272 duk_small_uint_fast_t b = DUK_DEC_B(ins); /* restricted to regs */
68273 duk_uint_fast_t idx;
68274
68275 /* A -> target register (A, A+1) for call setup
68276 * (for DUK_OP_CSREGI, 'a' is indirect)
68277 * B -> register containing target function (not type checked here)
68278 */
68279
68280 /* XXX: direct manipulation, or duk_replace_tval() */
68281
68282 /* Note: target registers a and a+1 may overlap with DUK__REGP(b).
68283 * Careful here.
68284 */
68285
68286 idx = (duk_uint_fast_t) DUK_DEC_A(ins);
68287 if (DUK_DEC_OP(ins) == DUK_OP_CSREGI) {
68288 duk_tval *tv_ind = DUK__REGP(idx);
68290 idx = (duk_uint_fast_t) DUK_TVAL_GET_NUMBER(tv_ind);
68291 }
68292
68293#if defined(DUK_USE_EXEC_INDIRECT_BOUND_CHECK)
68294 if (idx + 2 > (duk_uint_fast_t) duk_get_top(ctx)) {
68295 /* XXX: use duk_is_valid_index() instead? */
68296 /* XXX: improve check; check against nregs, not against top */
68297 DUK__INTERNAL_ERROR("CSREG out of bounds");
68298 }
68299#endif
68300
68301 duk_push_tval(ctx, DUK__REGP(b));
68302 duk_replace(ctx, (duk_idx_t) idx);
68303 duk_push_undefined(ctx);
68304 duk_replace(ctx, (duk_idx_t) (idx + 1));
68305 break;
68306 }
68307
68308 case DUK_OP_GETVAR: {
68309 duk_context *ctx = (duk_context *) thr;
68310 duk_activation *act;
68312 duk_uint_fast_t bc = DUK_DEC_BC(ins);
68313 duk_tval *tv1;
68315
68316 tv1 = DUK__CONSTP(bc);
68319 DUK_ASSERT(name != NULL);
68320 DUK_DDD(DUK_DDDPRINT("GETVAR: '%!O'", (duk_heaphdr *) name));
68321 act = thr->callstack + thr->callstack_top - 1;
68322 (void) duk_js_getvar_activation(thr, act, name, 1 /*throw*/); /* -> [... val this] */
68323
68324 duk_pop(ctx); /* 'this' binding is not needed here */
68325 duk_replace(ctx, (duk_idx_t) a);
68326 break;
68327 }
68328
68329 case DUK_OP_PUTVAR: {
68330 duk_activation *act;
68332 duk_uint_fast_t bc = DUK_DEC_BC(ins);
68333 duk_tval *tv1;
68335
68336 tv1 = DUK__CONSTP(bc);
68339 DUK_ASSERT(name != NULL);
68340
68341 /* XXX: putvar takes a duk_tval pointer, which is awkward and
68342 * should be reworked.
68343 */
68344
68345 tv1 = DUK__REGP(a); /* val */
68346 act = thr->callstack + thr->callstack_top - 1;
68347 duk_js_putvar_activation(thr, act, name, tv1, DUK__STRICT());
68348 break;
68349 }
68350
68351 case DUK_OP_DECLVAR: {
68352 duk_activation *act;
68353 duk_context *ctx = (duk_context *) thr;
68357 duk_tval *tv1;
68359 duk_small_uint_t prop_flags;
68360 duk_bool_t is_func_decl;
68361 duk_bool_t is_undef_value;
68362
68363 tv1 = DUK__REGCONSTP(b);
68366 DUK_ASSERT(name != NULL);
68367
68368 is_undef_value = ((a & DUK_BC_DECLVAR_FLAG_UNDEF_VALUE) != 0);
68369 is_func_decl = ((a & DUK_BC_DECLVAR_FLAG_FUNC_DECL) != 0);
68370
68371 /* XXX: declvar takes an duk_tval pointer, which is awkward and
68372 * should be reworked.
68373 */
68374
68375 /* Compiler is responsible for selecting property flags (configurability,
68376 * writability, etc).
68377 */
68378 prop_flags = a & DUK_PROPDESC_FLAGS_MASK;
68379
68380 if (is_undef_value) {
68381 duk_push_undefined(ctx);
68382 } else {
68384 }
68385 tv1 = DUK_GET_TVAL_NEGIDX(ctx, -1);
68386
68387 act = thr->callstack + thr->callstack_top - 1;
68388 if (duk_js_declvar_activation(thr, act, name, tv1, prop_flags, is_func_decl)) {
68389 if (is_undef_value) {
68390 /* Already declared but no initializer value
68391 * (e.g. 'var xyz;'), no-op.
68392 */
68393 } else {
68394 /* Already declared, update value. */
68395 tv1 = DUK_GET_TVAL_NEGIDX(ctx, -1);
68396 duk_js_putvar_activation(thr, act, name, tv1, DUK__STRICT());
68397 }
68398 }
68399
68400 duk_pop(ctx);
68401 break;
68402 }
68403
68404 case DUK_OP_DELVAR: {
68405 duk_activation *act;
68406 duk_context *ctx = (duk_context *) thr;
68409 duk_tval *tv1;
68411 duk_bool_t rc;
68412
68413 tv1 = DUK__REGCONSTP(b);
68416 DUK_ASSERT(name != NULL);
68417 DUK_DDD(DUK_DDDPRINT("DELVAR '%!O'", (duk_heaphdr *) name));
68418 act = thr->callstack + thr->callstack_top - 1;
68419 rc = duk_js_delvar_activation(thr, act, name);
68420
68421 duk_push_boolean(ctx, rc);
68422 duk_replace(ctx, (duk_idx_t) a);
68423 break;
68424 }
68425
68426 case DUK_OP_CSVAR:
68427 case DUK_OP_CSVARI: {
68428 /* 'this' value:
68429 * E5 Section 6.b.i
68430 *
68431 * The only (standard) case where the 'this' binding is non-null is when
68432 * (1) the variable is found in an object environment record, and
68433 * (2) that object environment record is a 'with' block.
68434 *
68435 */
68436
68437 duk_context *ctx = (duk_context *) thr;
68438 duk_activation *act;
68440 duk_uint_fast_t idx;
68441 duk_tval *tv1;
68443
68444 tv1 = DUK__REGCONSTP(b);
68447 DUK_ASSERT(name != NULL);
68448 act = thr->callstack + thr->callstack_top - 1;
68449 (void) duk_js_getvar_activation(thr, act, name, 1 /*throw*/); /* -> [... val this] */
68450
68451 /* Note: target registers a and a+1 may overlap with DUK__REGCONSTP(b)
68452 * and DUK__REGCONSTP(c). Careful here.
68453 */
68454
68455 idx = (duk_uint_fast_t) DUK_DEC_A(ins);
68456 if (DUK_DEC_OP(ins) == DUK_OP_CSVARI) {
68457 duk_tval *tv_ind = DUK__REGP(idx);
68459 idx = (duk_uint_fast_t) DUK_TVAL_GET_NUMBER(tv_ind);
68460 }
68461
68462#if defined(DUK_USE_EXEC_INDIRECT_BOUND_CHECK)
68463 if (idx + 2 > (duk_uint_fast_t) duk_get_top(ctx)) {
68464 /* XXX: use duk_is_valid_index() instead? */
68465 /* XXX: improve check; check against nregs, not against top */
68466 DUK__INTERNAL_ERROR("CSVAR out of bounds");
68467 }
68468#endif
68469
68470 duk_replace(ctx, (duk_idx_t) (idx + 1)); /* 'this' binding */
68471 duk_replace(ctx, (duk_idx_t) idx); /* variable value (function, we hope, not checked here) */
68472 break;
68473 }
68474
68475 case DUK_OP_CLOSURE: {
68476 duk_context *ctx = (duk_context *) thr;
68477 duk_activation *act;
68480 duk_uint_fast_t bc = DUK_DEC_BC(ins);
68481 duk_hobject *fun_temp;
68482
68483 /* A -> target reg
68484 * BC -> inner function index
68485 */
68486
68487 DUK_DDD(DUK_DDDPRINT("CLOSURE to target register %ld, fnum %ld (count %ld)",
68488 (long) a, (long) bc, (long) DUK_HCOMPILEDFUNCTION_GET_FUNCS_COUNT(thr->heap, DUK__FUN())));
68489
68490 DUK_ASSERT_DISABLE(bc >= 0); /* unsigned */
68492
68493 act = thr->callstack + thr->callstack_top - 1;
68495 fun_temp = DUK_HCOMPILEDFUNCTION_GET_FUNCS_BASE(thr->heap, fun)[bc];
68496 DUK_ASSERT(fun_temp != NULL);
68498
68499 DUK_DDD(DUK_DDDPRINT("CLOSURE: function template is: %p -> %!O",
68500 (void *) fun_temp, (duk_heaphdr *) fun_temp));
68501
68502 if (act->lex_env == NULL) {
68503 DUK_ASSERT(act->var_env == NULL);
68505 act = thr->callstack + thr->callstack_top - 1;
68506 }
68507 DUK_ASSERT(act->lex_env != NULL);
68508 DUK_ASSERT(act->var_env != NULL);
68509
68510 /* functions always have a NEWENV flag, i.e. they get a
68511 * new variable declaration environment, so only lex_env
68512 * matters here.
68513 */
68515 (duk_hcompiledfunction *) fun_temp,
68516 act->var_env,
68517 act->lex_env,
68518 1 /*add_auto_proto*/);
68519 duk_replace(ctx, (duk_idx_t) a);
68520
68521 break;
68522 }
68523
68524 case DUK_OP_GETPROP: {
68525 duk_context *ctx = (duk_context *) thr;
68529 duk_tval *tv_obj;
68530 duk_tval *tv_key;
68531 duk_bool_t rc;
68532
68533 /* A -> target reg
68534 * B -> object reg/const (may be const e.g. in "'foo'[1]")
68535 * C -> key reg/const
68536 */
68537
68538 tv_obj = DUK__REGCONSTP(b);
68539 tv_key = DUK__REGCONSTP(c);
68540 DUK_DDD(DUK_DDDPRINT("GETPROP: a=%ld obj=%!T, key=%!T",
68541 (long) a,
68542 (duk_tval *) DUK__REGCONSTP(b),
68543 (duk_tval *) DUK__REGCONSTP(c)));
68544 rc = duk_hobject_getprop(thr, tv_obj, tv_key); /* -> [val] */
68545 DUK_UNREF(rc); /* ignore */
68546 DUK_DDD(DUK_DDDPRINT("GETPROP --> %!T",
68547 (duk_tval *) duk_get_tval(ctx, -1)));
68548 tv_obj = NULL; /* invalidated */
68549 tv_key = NULL; /* invalidated */
68550
68551 duk_replace(ctx, (duk_idx_t) a); /* val */
68552 break;
68553 }
68554
68555 case DUK_OP_PUTPROP: {
68559 duk_tval *tv_obj;
68560 duk_tval *tv_key;
68561 duk_tval *tv_val;
68562 duk_bool_t rc;
68563
68564 /* A -> object reg
68565 * B -> key reg/const
68566 * C -> value reg/const
68567 *
68568 * Note: intentional difference to register arrangement
68569 * of e.g. GETPROP; 'A' must contain a register-only value.
68570 */
68571
68572 tv_obj = DUK__REGP(a);
68573 tv_key = DUK__REGCONSTP(b);
68574 tv_val = DUK__REGCONSTP(c);
68575 DUK_DDD(DUK_DDDPRINT("PUTPROP: obj=%!T, key=%!T, val=%!T",
68576 (duk_tval *) DUK__REGP(a),
68577 (duk_tval *) DUK__REGCONSTP(b),
68578 (duk_tval *) DUK__REGCONSTP(c)));
68579 rc = duk_hobject_putprop(thr, tv_obj, tv_key, tv_val, DUK__STRICT());
68580 DUK_UNREF(rc); /* ignore */
68581 DUK_DDD(DUK_DDDPRINT("PUTPROP --> obj=%!T, key=%!T, val=%!T",
68582 (duk_tval *) DUK__REGP(a),
68583 (duk_tval *) DUK__REGCONSTP(b),
68584 (duk_tval *) DUK__REGCONSTP(c)));
68585 tv_obj = NULL; /* invalidated */
68586 tv_key = NULL; /* invalidated */
68587 tv_val = NULL; /* invalidated */
68588
68589 break;
68590 }
68591
68592 case DUK_OP_DELPROP: {
68593 duk_context *ctx = (duk_context *) thr;
68597 duk_tval *tv_obj;
68598 duk_tval *tv_key;
68599 duk_bool_t rc;
68600
68601 /* A -> result reg
68602 * B -> object reg
68603 * C -> key reg/const
68604 */
68605
68606 tv_obj = DUK__REGP(b);
68607 tv_key = DUK__REGCONSTP(c);
68608 rc = duk_hobject_delprop(thr, tv_obj, tv_key, DUK__STRICT());
68609 tv_obj = NULL; /* invalidated */
68610 tv_key = NULL; /* invalidated */
68611
68612 duk_push_boolean(ctx, rc);
68613 duk_replace(ctx, (duk_idx_t) a); /* result */
68614 break;
68615 }
68616
68617 case DUK_OP_CSPROP:
68618 case DUK_OP_CSPROPI: {
68619 duk_context *ctx = (duk_context *) thr;
68622 duk_uint_fast_t idx;
68623 duk_tval *tv_obj;
68624 duk_tval *tv_key;
68625 duk_bool_t rc;
68626
68627 /* E5 Section 11.2.3, step 6.a.i */
68628 /* E5 Section 10.4.3 */
68629
68630 /* XXX: allow object to be a const, e.g. in 'foo'.toString()?
68631 * On the other hand, DUK_REGCONSTP() is slower and generates
68632 * more code.
68633 */
68634
68635 tv_obj = DUK__REGP(b);
68636 tv_key = DUK__REGCONSTP(c);
68637 rc = duk_hobject_getprop(thr, tv_obj, tv_key); /* -> [val] */
68638 DUK_UNREF(rc); /* unused */
68639 tv_obj = NULL; /* invalidated */
68640 tv_key = NULL; /* invalidated */
68641
68642 /* Note: target registers a and a+1 may overlap with DUK__REGP(b)
68643 * and DUK__REGCONSTP(c). Careful here.
68644 */
68645
68646 idx = (duk_uint_fast_t) DUK_DEC_A(ins);
68647 if (DUK_DEC_OP(ins) == DUK_OP_CSPROPI) {
68648 duk_tval *tv_ind = DUK__REGP(idx);
68650 idx = (duk_uint_fast_t) DUK_TVAL_GET_NUMBER(tv_ind);
68651 }
68652
68653#if defined(DUK_USE_EXEC_INDIRECT_BOUND_CHECK)
68654 if (idx + 2 > (duk_uint_fast_t) duk_get_top(ctx)) {
68655 /* XXX: use duk_is_valid_index() instead? */
68656 /* XXX: improve check; check against nregs, not against top */
68657 DUK__INTERNAL_ERROR("CSPROP out of bounds");
68658 }
68659#endif
68660
68661 duk_push_tval(ctx, DUK__REGP(b)); /* [ ... val obj ] */
68662 duk_replace(ctx, (duk_idx_t) (idx + 1)); /* 'this' binding */
68663 duk_replace(ctx, (duk_idx_t) idx); /* val */
68664 break;
68665 }
68666
68667 case DUK_OP_ADD:
68668 case DUK_OP_SUB:
68669 case DUK_OP_MUL:
68670 case DUK_OP_DIV:
68671 case DUK_OP_MOD: {
68676
68677 if (op == DUK_OP_ADD) {
68678 /*
68679 * Handling DUK_OP_ADD this way is more compact (experimentally)
68680 * than a separate case with separate argument decoding.
68681 */
68683 } else {
68685 }
68686 break;
68687 }
68688
68689 case DUK_OP_BAND:
68690 case DUK_OP_BOR:
68691 case DUK_OP_BXOR:
68692 case DUK_OP_BASL:
68693 case DUK_OP_BLSR:
68694 case DUK_OP_BASR: {
68699
68701 break;
68702 }
68703
68704 case DUK_OP_EQ:
68705 case DUK_OP_NEQ: {
68706 duk_context *ctx = (duk_context *) thr;
68710 duk_bool_t tmp;
68711
68712 /* E5 Sections 11.9.1, 11.9.3 */
68713 tmp = duk_js_equals(thr, DUK__REGCONSTP(b), DUK__REGCONSTP(c));
68714 if (DUK_DEC_OP(ins) == DUK_OP_NEQ) {
68715 tmp = !tmp;
68716 }
68717 duk_push_boolean(ctx, tmp);
68718 duk_replace(ctx, (duk_idx_t) a);
68719 break;
68720 }
68721
68722 case DUK_OP_SEQ:
68723 case DUK_OP_SNEQ: {
68724 duk_context *ctx = (duk_context *) thr;
68728 duk_bool_t tmp;
68729
68730 /* E5 Sections 11.9.1, 11.9.3 */
68732 if (DUK_DEC_OP(ins) == DUK_OP_SNEQ) {
68733 tmp = !tmp;
68734 }
68735 duk_push_boolean(ctx, tmp);
68736 duk_replace(ctx, (duk_idx_t) a);
68737 break;
68738 }
68739
68740 /* Note: combining comparison ops must be done carefully because
68741 * of uncomparable values (NaN): it's not necessarily true that
68742 * (x >= y) === !(x < y). Also, evaluation order matters, and
68743 * although it would only seem to affect the compiler this is
68744 * actually not the case, because there are also run-time coercions
68745 * of the arguments (with potential side effects).
68746 *
68747 * XXX: can be combined; check code size.
68748 */
68749
68750 case DUK_OP_GT: {
68751 duk_context *ctx = (duk_context *) thr;
68755 duk_bool_t tmp;
68756
68757 /* x > y --> y < x */
68758 tmp = duk_js_compare_helper(thr,
68759 DUK__REGCONSTP(c), /* y */
68760 DUK__REGCONSTP(b), /* x */
68761 0); /* flags */
68762
68763 duk_push_boolean(ctx, tmp);
68764 duk_replace(ctx, (duk_idx_t) a);
68765 break;
68766 }
68767
68768 case DUK_OP_GE: {
68769 duk_context *ctx = (duk_context *) thr;
68773 duk_bool_t tmp;
68774
68775 /* x >= y --> not (x < y) */
68776 tmp = duk_js_compare_helper(thr,
68777 DUK__REGCONSTP(b), /* x */
68778 DUK__REGCONSTP(c), /* y */
68780 DUK_COMPARE_FLAG_NEGATE); /* flags */
68781
68782 duk_push_boolean(ctx, tmp);
68783 duk_replace(ctx, (duk_idx_t) a);
68784 break;
68785 }
68786
68787 case DUK_OP_LT: {
68788 duk_context *ctx = (duk_context *) thr;
68792 duk_bool_t tmp;
68793
68794 /* x < y */
68795 tmp = duk_js_compare_helper(thr,
68796 DUK__REGCONSTP(b), /* x */
68797 DUK__REGCONSTP(c), /* y */
68799
68800 duk_push_boolean(ctx, tmp);
68801 duk_replace(ctx, (duk_idx_t) a);
68802 break;
68803 }
68804
68805 case DUK_OP_LE: {
68806 duk_context *ctx = (duk_context *) thr;
68810 duk_bool_t tmp;
68811
68812 /* x <= y --> not (x > y) --> not (y < x) */
68813 tmp = duk_js_compare_helper(thr,
68814 DUK__REGCONSTP(c), /* y */
68815 DUK__REGCONSTP(b), /* x */
68816 DUK_COMPARE_FLAG_NEGATE); /* flags */
68817
68818 duk_push_boolean(ctx, tmp);
68819 duk_replace(ctx, (duk_idx_t) a);
68820 break;
68821 }
68822
68823 case DUK_OP_IF: {
68826 duk_bool_t tmp;
68827
68829 if (tmp == (duk_bool_t) a) {
68830 /* if boolean matches A, skip next inst */
68831 curr_pc++;
68832 } else {
68833 ;
68834 }
68835 break;
68836 }
68837
68838 case DUK_OP_JUMP: {
68839 duk_int_fast_t abc = DUK_DEC_ABC(ins);
68840
68841 curr_pc += abc - DUK_BC_JUMP_BIAS;
68842 break;
68843 }
68844
68845 case DUK_OP_RETURN: {
68846 duk_context *ctx = (duk_context *) thr;
68849 /* duk_small_uint_fast_t c = DUK_DEC_C(ins); */
68850 duk_small_uint_t ret_result;
68851
68852 /* A -> flags
68853 * B -> return value reg/const
68854 * C -> currently unused
68855 */
68856
68858
68859 /* duk__handle_return() is guaranteed never to throw, except
68860 * for potential out-of-memory situations which will then
68861 * propagate out of the executor longjmp handler.
68862 */
68863
68866 } else {
68867 duk_push_undefined(ctx);
68868 }
68869 ret_result = duk__handle_return(thr,
68870 entry_thread,
68871 entry_callstack_top);
68872 if (ret_result == DUK__RETHAND_RESTART) {
68873 goto restart_execution;
68874 }
68875 DUK_ASSERT(ret_result == DUK__RETHAND_FINISHED);
68876
68877 DUK_DDD(DUK_DDDPRINT("exiting executor after RETURN handling"));
68878 return;
68879 }
68880
68881 case DUK_OP_CALL:
68882 case DUK_OP_CALLI: {
68883 duk_context *ctx = (duk_context *) thr;
68886 duk_uint_fast_t idx;
68887 duk_small_uint_t call_flags;
68888 duk_small_uint_t flag_tailcall;
68889 duk_small_uint_t flag_evalcall;
68890 duk_tval *tv_func;
68891 duk_hobject *obj_func;
68892 duk_bool_t setup_rc;
68893 duk_idx_t num_stack_args;
68894#if !defined(DUK_USE_EXEC_FUN_LOCAL)
68896#endif
68897
68898 /* A -> flags
68899 * B -> base register for call (base -> func, base+1 -> this, base+2 -> arg1 ... base+2+N-1 -> argN)
68900 * (for DUK_OP_CALLI, 'b' is indirect)
68901 * C -> nargs
68902 */
68903
68904 /* these are not necessarily 0 or 1 (may be other non-zero), that's ok */
68905 flag_tailcall = (a & DUK_BC_CALL_FLAG_TAILCALL);
68906 flag_evalcall = (a & DUK_BC_CALL_FLAG_EVALCALL);
68907
68908 idx = (duk_uint_fast_t) DUK_DEC_B(ins);
68909 if (DUK_DEC_OP(ins) == DUK_OP_CALLI) {
68910 duk_tval *tv_ind = DUK__REGP(idx);
68912 idx = (duk_uint_fast_t) DUK_TVAL_GET_NUMBER(tv_ind);
68913 }
68914
68915#if defined(DUK_USE_EXEC_INDIRECT_BOUND_CHECK)
68916 if (!duk_is_valid_index(ctx, (duk_idx_t) idx)) {
68917 /* XXX: improve check; check against nregs, not against top */
68918 DUK__INTERNAL_ERROR("CALL out of bounds");
68919 }
68920#endif
68921
68922 /*
68923 * To determine whether to use an optimized Ecmascript-to-Ecmascript
68924 * call, we need to know whether the final, non-bound function is an
68925 * Ecmascript function.
68926 *
68927 * This is now implemented so that we start to do an ecma-to-ecma call
68928 * setup which will resolve the bound chain as the first thing. If the
68929 * final function is not eligible, the return value indicates that the
68930 * ecma-to-ecma call is not possible. The setup will overwrite the call
68931 * target at DUK__REGP(idx) with the final, non-bound function (which
68932 * may be a lightfunc), and fudge arguments if necessary.
68933 *
68934 * XXX: If an ecma-to-ecma call is not possible, this initial call
68935 * setup will do bound function chain resolution but won't do the
68936 * "effective this binding" resolution which is quite confusing.
68937 * Perhaps add a helper for doing bound function and effective this
68938 * binding resolution - and call that explicitly? Ecma-to-ecma call
68939 * setup and normal function handling can then assume this prestep has
68940 * been done by the caller.
68941 */
68942
68943 duk_set_top(ctx, (duk_idx_t) (idx + c + 2)); /* [ ... func this arg1 ... argN ] */
68944
68945 call_flags = 0;
68946 if (flag_tailcall) {
68947 /* We request a tail call, but in some corner cases
68948 * call handling can decide that a tail call is
68949 * actually not possible.
68950 * See: test-bug-tailcall-preventyield-assert.c.
68951 */
68952 call_flags |= DUK_CALL_FLAG_IS_TAILCALL;
68953 }
68954
68955 /* Compared to duk_handle_call():
68956 * - protected call: never
68957 * - ignore recursion limit: never
68958 */
68959 num_stack_args = c;
68960 setup_rc = duk_handle_ecma_call_setup(thr,
68961 num_stack_args,
68962 call_flags);
68963
68964 if (setup_rc) {
68965 /* Ecma-to-ecma call possible, may or may not be a tail call.
68966 * Avoid C recursion by being clever.
68967 */
68968 DUK_DDD(DUK_DDDPRINT("ecma-to-ecma call setup possible, restart execution"));
68969 /* curr_pc synced by duk_handle_ecma_call_setup() */
68970 goto restart_execution;
68971 }
68972 DUK_ASSERT(thr->ptr_curr_pc != NULL); /* restored if ecma-to-ecma setup fails */
68973
68974 DUK_DDD(DUK_DDDPRINT("ecma-to-ecma call not possible, target is native (may be lightfunc)"));
68975
68976 /* Recompute argument count: bound function handling may have shifted. */
68977 num_stack_args = duk_get_top(ctx) - (idx + 2);
68978 DUK_DDD(DUK_DDDPRINT("recomputed arg count: %ld\n", (long) num_stack_args));
68979
68980 tv_func = DUK__REGP(idx); /* Relookup if relocated */
68981 if (DUK_TVAL_IS_LIGHTFUNC(tv_func)) {
68982
68983 call_flags = 0; /* not protected, respect reclimit, not constructor */
68984
68985 /* There is no eval() special handling here: eval() is never
68986 * automatically converted to a lightfunc.
68987 */
68989
68991 num_stack_args,
68992 call_flags);
68993
68994 /* duk_js_call.c is required to restore the stack reserve
68995 * so we only need to reset the top.
68996 */
68997#if !defined(DUK_USE_EXEC_FUN_LOCAL)
68998 fun = DUK__FUN();
68999#endif
69000 duk_set_top(ctx, (duk_idx_t) fun->nregs);
69001
69002 /* No need to reinit setjmp() catchpoint, as call handling
69003 * will store and restore our state.
69004 */
69005 } else {
69006 /* Call setup checks callability. */
69008 obj_func = DUK_TVAL_GET_OBJECT(tv_func);
69009 DUK_ASSERT(obj_func != NULL);
69011
69012 /*
69013 * Other cases, use C recursion.
69014 *
69015 * If a tail call was requested we ignore it and execute a normal call.
69016 * Since Duktape 0.11.0 the compiler emits a RETURN opcode even after
69017 * a tail call to avoid test-bug-tailcall-thread-yield-resume.js.
69018 *
69019 * Direct eval call: (1) call target (before following bound function
69020 * chain) is the built-in eval() function, and (2) call was made with
69021 * the identifier 'eval'.
69022 */
69023
69024 call_flags = 0; /* not protected, respect reclimit, not constructor */
69025
69026 if (DUK_HOBJECT_IS_NATIVEFUNCTION(obj_func) &&
69027 ((duk_hnativefunction *) obj_func)->func == duk_bi_global_object_eval) {
69028 if (flag_evalcall) {
69029 DUK_DDD(DUK_DDDPRINT("call target is eval, call identifier was 'eval' -> direct eval"));
69030 call_flags |= DUK_CALL_FLAG_DIRECT_EVAL;
69031 } else {
69032 DUK_DDD(DUK_DDDPRINT("call target is eval, call identifier was not 'eval' -> indirect eval"));
69033 }
69034 }
69035
69037 num_stack_args,
69038 call_flags);
69039
69040 /* duk_js_call.c is required to restore the stack reserve
69041 * so we only need to reset the top.
69042 */
69043#if !defined(DUK_USE_EXEC_FUN_LOCAL)
69044 fun = DUK__FUN();
69045#endif
69046 duk_set_top(ctx, (duk_idx_t) fun->nregs);
69047
69048 /* No need to reinit setjmp() catchpoint, as call handling
69049 * will store and restore our state.
69050 */
69051 }
69052
69053 /* When debugger is enabled, we need to recheck the activation
69054 * status after returning. This is now handled by call handling
69055 * and heap->dbg_force_restart.
69056 */
69057 break;
69058 }
69059
69060 case DUK_OP_TRYCATCH: {
69061 duk_context *ctx = (duk_context *) thr;
69062 duk_activation *act;
69063 duk_catcher *cat;
69064 duk_tval *tv1;
69066 duk_uint_fast_t bc;
69067
69068 /* A -> flags
69069 * BC -> reg_catch; base register for two registers used both during
69070 * trycatch setup and when catch is triggered
69071 *
69072 * If DUK_BC_TRYCATCH_FLAG_CATCH_BINDING set:
69073 * reg_catch + 0: catch binding variable name (string).
69074 * Automatic declarative environment is established for
69075 * the duration of the 'catch' clause.
69076 *
69077 * If DUK_BC_TRYCATCH_FLAG_WITH_BINDING set:
69078 * reg_catch + 0: with 'target value', which is coerced to
69079 * an object and then used as a bindind object for an
69080 * environment record. The binding is initialized here, for
69081 * the 'try' clause.
69082 *
69083 * Note that a TRYCATCH generated for a 'with' statement has no
69084 * catch or finally parts.
69085 */
69086
69087 /* XXX: TRYCATCH handling should be reworked to avoid creating
69088 * an explicit scope unless it is actually needed (e.g. function
69089 * instances or eval is executed inside the catch block). This
69090 * rework is not trivial because the compiler doesn't have an
69091 * intermediate representation. When the rework is done, the
69092 * opcode format can also be made more straightforward.
69093 */
69094
69095 /* XXX: side effect handling is quite awkward here */
69096
69097 DUK_DDD(DUK_DDDPRINT("TRYCATCH: reg_catch=%ld, have_catch=%ld, "
69098 "have_finally=%ld, catch_binding=%ld, with_binding=%ld (flags=0x%02lx)",
69099 (long) DUK_DEC_BC(ins),
69100 (long) (DUK_DEC_A(ins) & DUK_BC_TRYCATCH_FLAG_HAVE_CATCH ? 1 : 0),
69101 (long) (DUK_DEC_A(ins) & DUK_BC_TRYCATCH_FLAG_HAVE_FINALLY ? 1 : 0),
69102 (long) (DUK_DEC_A(ins) & DUK_BC_TRYCATCH_FLAG_CATCH_BINDING ? 1 : 0),
69103 (long) (DUK_DEC_A(ins) & DUK_BC_TRYCATCH_FLAG_WITH_BINDING ? 1 : 0),
69104 (unsigned long) DUK_DEC_A(ins)));
69105
69106 a = DUK_DEC_A(ins);
69107 bc = DUK_DEC_BC(ins);
69108
69109 act = thr->callstack + thr->callstack_top - 1;
69110 DUK_ASSERT(thr->callstack_top >= 1);
69111
69112 /* 'with' target must be created first, in case we run out of memory */
69113 /* XXX: refactor out? */
69114
69116 DUK_DDD(DUK_DDDPRINT("need to initialize a with binding object"));
69117
69118 if (act->lex_env == NULL) {
69119 DUK_ASSERT(act->var_env == NULL);
69120 DUK_DDD(DUK_DDDPRINT("delayed environment initialization"));
69121
69122 /* must relookup act in case of side effects */
69124 act = thr->callstack + thr->callstack_top - 1;
69125 DUK_UNREF(act); /* 'act' is no longer accessed, scanbuild fix */
69126 }
69127 DUK_ASSERT(act->lex_env != NULL);
69128 DUK_ASSERT(act->var_env != NULL);
69129
69130 (void) duk_push_object_helper(ctx,
69133 -1); /* no prototype, updated below */
69134
69135 duk_push_tval(ctx, DUK__REGP(bc));
69136 duk_to_object(ctx, -1);
69137 duk_dup(ctx, -1);
69138
69139 /* [ ... env target ] */
69140 /* [ ... env target target ] */
69141
69143 duk_xdef_prop_stridx(thr, -2, DUK_STRIDX_INT_THIS, DUK_PROPDESC_FLAGS_NONE); /* always provideThis=true */
69144
69145 /* [ ... env ] */
69146
69147 DUK_DDD(DUK_DDDPRINT("environment for with binding: %!iT",
69148 (duk_tval *) duk_get_tval(ctx, -1)));
69149 }
69150
69151 /* allocate catcher and populate it (should be atomic) */
69152
69154 cat = thr->catchstack + thr->catchstack_top;
69155 DUK_ASSERT(thr->catchstack_top + 1 <= thr->catchstack_size);
69156 thr->catchstack_top++;
69157
69158 cat->flags = DUK_CAT_TYPE_TCF;
69159 cat->h_varname = NULL;
69160
69163 }
69166 }
69168 DUK_DDD(DUK_DDDPRINT("catch binding flag set to catcher"));
69170 tv1 = DUK__REGP(bc);
69172
69173 /* borrowed reference; although 'tv1' comes from a register,
69174 * its value was loaded using LDCONST so the constant will
69175 * also exist and be reachable.
69176 */
69177 cat->h_varname = DUK_TVAL_GET_STRING(tv1);
69178 } else if (a & DUK_BC_TRYCATCH_FLAG_WITH_BINDING) {
69179 /* env created above to stack top */
69180 duk_hobject *new_env;
69181
69182 DUK_DDD(DUK_DDDPRINT("lexenv active flag set to catcher"));
69184
69185 DUK_DDD(DUK_DDDPRINT("activating object env: %!iT",
69186 (duk_tval *) duk_get_tval(ctx, -1)));
69187 new_env = DUK_GET_HOBJECT_NEGIDX(ctx, -1);
69188 DUK_ASSERT(new_env != NULL);
69189
69190 act = thr->callstack + thr->callstack_top - 1; /* relookup (side effects) */
69191 DUK_ASSERT(act->lex_env != NULL);
69192 DUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, new_env, act->lex_env); /* side effects */
69193
69194 act = thr->callstack + thr->callstack_top - 1; /* relookup (side effects) */
69195 act->lex_env = new_env;
69196 DUK_HOBJECT_INCREF(thr, new_env);
69197 duk_pop(ctx);
69198 } else {
69199 ;
69200 }
69201
69202 /* Registers 'bc' and 'bc + 1' are written in longjmp handling
69203 * and if their previous values (which are temporaries) become
69204 * unreachable -and- have a finalizer, there'll be a function
69205 * call during error handling which is not supported now (GH-287).
69206 * Ensure that both 'bc' and 'bc + 1' have primitive values to
69207 * guarantee no finalizer calls in error handling. Scrubbing also
69208 * ensures finalizers for the previous values run here rather than
69209 * later. Error handling related values are also written to 'bc'
69210 * and 'bc + 1' but those values never become unreachable during
69211 * error handling, so there's no side effect problem even if the
69212 * error value has a finalizer.
69213 */
69214 duk_to_undefined(ctx, bc);
69215 duk_to_undefined(ctx, bc + 1);
69216
69217 cat = thr->catchstack + thr->catchstack_top - 1; /* relookup (side effects) */
69218 cat->callstack_index = thr->callstack_top - 1;
69219 cat->pc_base = (duk_instr_t *) curr_pc; /* pre-incremented, points to first jump slot */
69220 cat->idx_base = (duk_size_t) (thr->valstack_bottom - thr->valstack) + bc;
69221
69222 DUK_DDD(DUK_DDDPRINT("TRYCATCH catcher: flags=0x%08lx, callstack_index=%ld, pc_base=%ld, "
69223 "idx_base=%ld, h_varname=%!O",
69224 (unsigned long) cat->flags, (long) cat->callstack_index,
69225 (long) cat->pc_base, (long) cat->idx_base, (duk_heaphdr *) cat->h_varname));
69226
69227 curr_pc += 2; /* skip jump slots */
69228 break;
69229 }
69230
69231 /* Pre/post inc/dec for register variables, important for loops. */
69232 case DUK_OP_PREINCR:
69233 case DUK_OP_PREDECR:
69234 case DUK_OP_POSTINCR:
69235 case DUK_OP_POSTDECR: {
69236 duk_context *ctx = (duk_context *) thr;
69238 duk_uint_fast_t bc = DUK_DEC_BC(ins);
69239 duk_tval *tv1, *tv2;
69240 duk_double_t x, y, z;
69241
69242 /* Two lowest bits of opcode are used to distinguish
69243 * variants. Bit 0 = inc(0)/dec(1), bit 1 = pre(0)/post(1).
69244 */
69245 DUK_ASSERT((DUK_OP_PREINCR & 0x03) == 0x00);
69246 DUK_ASSERT((DUK_OP_PREDECR & 0x03) == 0x01);
69247 DUK_ASSERT((DUK_OP_POSTINCR & 0x03) == 0x02);
69248 DUK_ASSERT((DUK_OP_POSTDECR & 0x03) == 0x03);
69249
69250 tv1 = DUK__REGP(bc);
69251#if defined(DUK_USE_FASTINT)
69252 if (DUK_TVAL_IS_FASTINT(tv1)) {
69253 duk_int64_t x_fi, y_fi, z_fi;
69254 x_fi = DUK_TVAL_GET_FASTINT(tv1);
69255 if (ins & DUK_ENC_OP(0x01)) {
69256 if (x_fi == DUK_FASTINT_MIN) {
69257 goto skip_fastint;
69258 }
69259 y_fi = x_fi - 1;
69260 } else {
69261 if (x_fi == DUK_FASTINT_MAX) {
69262 goto skip_fastint;
69263 }
69264 y_fi = x_fi + 1;
69265 }
69266
69267 DUK_TVAL_SET_FASTINT(tv1, y_fi); /* no need for refcount update */
69268
69269 tv2 = DUK__REGP(a);
69270 z_fi = (ins & DUK_ENC_OP(0x02)) ? x_fi : y_fi;
69271 DUK_TVAL_SET_FASTINT_UPDREF(thr, tv2, z_fi); /* side effects */
69272 break;
69273 }
69274 skip_fastint:
69275#endif
69276 if (DUK_TVAL_IS_NUMBER(tv1)) {
69277 /* Fast path for the case where the register
69278 * is a number (e.g. loop counter).
69279 */
69280
69281 x = DUK_TVAL_GET_NUMBER(tv1);
69282 if (ins & DUK_ENC_OP(0x01)) {
69283 y = x - 1.0;
69284 } else {
69285 y = x + 1.0;
69286 }
69287
69288 DUK_TVAL_SET_NUMBER(tv1, y); /* no need for refcount update */
69289 } else {
69290 x = duk_to_number(ctx, bc);
69291
69292 if (ins & DUK_ENC_OP(0x01)) {
69293 y = x - 1.0;
69294 } else {
69295 y = x + 1.0;
69296 }
69297
69298 duk_push_number(ctx, y);
69299 duk_replace(ctx, bc);
69300 }
69301
69302 tv2 = DUK__REGP(a);
69303 z = (ins & DUK_ENC_OP(0x02)) ? x : y;
69304 DUK_TVAL_SET_NUMBER_UPDREF(thr, tv2, z); /* side effects */
69305 break;
69306 }
69307
69308 /* Preinc/predec for var-by-name, slow path. */
69309 case DUK_OP_PREINCV:
69310 case DUK_OP_PREDECV:
69311 case DUK_OP_POSTINCV:
69312 case DUK_OP_POSTDECV: {
69313 duk_context *ctx = (duk_context *) thr;
69314 duk_activation *act;
69316 duk_uint_fast_t bc = DUK_DEC_BC(ins);
69317 duk_double_t x, y;
69318 duk_tval *tv1;
69320
69321 /* Two lowest bits of opcode are used to distinguish
69322 * variants. Bit 0 = inc(0)/dec(1), bit 1 = pre(0)/post(1).
69323 */
69324 DUK_ASSERT((DUK_OP_PREINCV & 0x03) == 0x00);
69325 DUK_ASSERT((DUK_OP_PREDECV & 0x03) == 0x01);
69326 DUK_ASSERT((DUK_OP_POSTINCV & 0x03) == 0x02);
69327 DUK_ASSERT((DUK_OP_POSTDECV & 0x03) == 0x03);
69328
69329 tv1 = DUK__CONSTP(bc);
69332 DUK_ASSERT(name != NULL);
69333 act = thr->callstack + thr->callstack_top - 1;
69334 (void) duk_js_getvar_activation(thr, act, name, 1 /*throw*/); /* -> [... val this] */
69335
69336 /* XXX: fastint fast path would be very useful here */
69337
69338 x = duk_to_number(ctx, -2);
69339 duk_pop_2(ctx);
69340 if (ins & DUK_ENC_OP(0x01)) {
69341 y = x - 1.0;
69342 } else {
69343 y = x + 1.0;
69344 }
69345
69346 duk_push_number(ctx, y);
69347 tv1 = DUK_GET_TVAL_NEGIDX(ctx, -1);
69348 DUK_ASSERT(tv1 != NULL);
69349 act = thr->callstack + thr->callstack_top - 1;
69350 duk_js_putvar_activation(thr, act, name, tv1, DUK__STRICT());
69351 duk_pop(ctx);
69352
69353 duk_push_number(ctx, (ins & DUK_ENC_OP(0x02)) ? x : y);
69354 duk_replace(ctx, (duk_idx_t) a);
69355 break;
69356 }
69357
69358 /* Preinc/predec for object properties. */
69359 case DUK_OP_PREINCP:
69360 case DUK_OP_PREDECP:
69361 case DUK_OP_POSTINCP:
69362 case DUK_OP_POSTDECP: {
69363 duk_context *ctx = (duk_context *) thr;
69367 duk_tval *tv_obj;
69368 duk_tval *tv_key;
69369 duk_tval *tv_val;
69370 duk_bool_t rc;
69371 duk_double_t x, y;
69372
69373 /* A -> target reg
69374 * B -> object reg/const (may be const e.g. in "'foo'[1]")
69375 * C -> key reg/const
69376 */
69377
69378 /* Two lowest bits of opcode are used to distinguish
69379 * variants. Bit 0 = inc(0)/dec(1), bit 1 = pre(0)/post(1).
69380 */
69381 DUK_ASSERT((DUK_OP_PREINCP & 0x03) == 0x00);
69382 DUK_ASSERT((DUK_OP_PREDECP & 0x03) == 0x01);
69383 DUK_ASSERT((DUK_OP_POSTINCP & 0x03) == 0x02);
69384 DUK_ASSERT((DUK_OP_POSTDECP & 0x03) == 0x03);
69385
69386 tv_obj = DUK__REGCONSTP(b);
69387 tv_key = DUK__REGCONSTP(c);
69388 rc = duk_hobject_getprop(thr, tv_obj, tv_key); /* -> [val] */
69389 DUK_UNREF(rc); /* ignore */
69390 tv_obj = NULL; /* invalidated */
69391 tv_key = NULL; /* invalidated */
69392
69393 x = duk_to_number(ctx, -1);
69394 duk_pop(ctx);
69395 if (ins & DUK_ENC_OP(0x01)) {
69396 y = x - 1.0;
69397 } else {
69398 y = x + 1.0;
69399 }
69400
69401 duk_push_number(ctx, y);
69402 tv_val = DUK_GET_TVAL_NEGIDX(ctx, -1);
69403 DUK_ASSERT(tv_val != NULL);
69404 tv_obj = DUK__REGCONSTP(b);
69405 tv_key = DUK__REGCONSTP(c);
69406 rc = duk_hobject_putprop(thr, tv_obj, tv_key, tv_val, DUK__STRICT());
69407 DUK_UNREF(rc); /* ignore */
69408 tv_obj = NULL; /* invalidated */
69409 tv_key = NULL; /* invalidated */
69410 duk_pop(ctx);
69411
69412 duk_push_number(ctx, (ins & DUK_ENC_OP(0x02)) ? x : y);
69413 duk_replace(ctx, (duk_idx_t) a);
69414 break;
69415 }
69416
69417 case DUK_OP_EXTRA: {
69418 /* XXX: shared decoding of 'b' and 'c'? */
69419
69420 duk_small_uint_fast_t extraop = DUK_DEC_A(ins);
69421 switch ((int) extraop) {
69422 /* XXX: switch cast? */
69423
69424 case DUK_EXTRAOP_NOP: {
69425 /* nop */
69426 break;
69427 }
69428
69429 case DUK_EXTRAOP_INVALID: {
69430 DUK_ERROR_FMT1(thr, DUK_ERR_INTERNAL_ERROR, "INVALID opcode (%ld)", (long) DUK_DEC_BC(ins));
69431 break;
69432 }
69433
69434 case DUK_EXTRAOP_LDTHIS: {
69435 /* Note: 'this' may be bound to any value, not just an object */
69436 duk_uint_fast_t bc = DUK_DEC_BC(ins);
69437 duk_tval *tv1, *tv2;
69438
69439 tv1 = DUK__REGP(bc);
69440 tv2 = thr->valstack_bottom - 1; /* 'this binding' is just under bottom */
69441 DUK_ASSERT(tv2 >= thr->valstack);
69442
69443 DUK_DDD(DUK_DDDPRINT("LDTHIS: %!T to r%ld", (duk_tval *) tv2, (long) bc));
69444
69445 DUK_TVAL_SET_TVAL_UPDREF_FAST(thr, tv1, tv2); /* side effects */
69446 break;
69447 }
69448
69449 case DUK_EXTRAOP_LDUNDEF: {
69450 duk_uint_fast_t bc = DUK_DEC_BC(ins);
69451 duk_tval *tv1;
69452
69453 tv1 = DUK__REGP(bc);
69454 DUK_TVAL_SET_UNDEFINED_UPDREF(thr, tv1); /* side effects */
69455 break;
69456 }
69457
69458 case DUK_EXTRAOP_LDNULL: {
69459 duk_uint_fast_t bc = DUK_DEC_BC(ins);
69460 duk_tval *tv1;
69461
69462 tv1 = DUK__REGP(bc);
69463 DUK_TVAL_SET_NULL_UPDREF(thr, tv1); /* side effects */
69464 break;
69465 }
69466
69467 case DUK_EXTRAOP_LDTRUE:
69468 case DUK_EXTRAOP_LDFALSE: {
69469 duk_uint_fast_t bc = DUK_DEC_BC(ins);
69470 duk_tval *tv1;
69471 duk_small_uint_fast_t bval = (extraop == DUK_EXTRAOP_LDTRUE ? 1 : 0);
69472
69473 tv1 = DUK__REGP(bc);
69474 DUK_TVAL_SET_BOOLEAN_UPDREF(thr, tv1, bval); /* side effects */
69475 break;
69476 }
69477
69478 case DUK_EXTRAOP_NEWOBJ: {
69479 duk_context *ctx = (duk_context *) thr;
69481
69482 duk_push_object(ctx);
69483 duk_replace(ctx, (duk_idx_t) b);
69484 break;
69485 }
69486
69487 case DUK_EXTRAOP_NEWARR: {
69488 duk_context *ctx = (duk_context *) thr;
69490
69491 duk_push_array(ctx);
69492 duk_replace(ctx, (duk_idx_t) b);
69493 break;
69494 }
69495
69496 case DUK_EXTRAOP_SETALEN: {
69499 duk_tval *tv1;
69500 duk_hobject *h;
69501 duk_uint32_t len;
69502
69503 b = DUK_DEC_B(ins); tv1 = DUK__REGP(b);
69505 h = DUK_TVAL_GET_OBJECT(tv1);
69506
69507 c = DUK_DEC_C(ins); tv1 = DUK__REGP(c);
69509 len = (duk_uint32_t) DUK_TVAL_GET_NUMBER(tv1);
69510
69511 duk_hobject_set_length(thr, h, len);
69512
69513 break;
69514 }
69515
69516 case DUK_EXTRAOP_TYPEOF: {
69517 duk_context *ctx = (duk_context *) thr;
69518 duk_uint_fast_t bc = DUK_DEC_BC(ins);
69520 duk_replace(ctx, (duk_idx_t) bc);
69521 break;
69522 }
69523
69524 case DUK_EXTRAOP_TYPEOFID: {
69525 duk_context *ctx = (duk_context *) thr;
69526 duk_activation *act;
69530 duk_tval *tv;
69531
69532 /* B -> target register
69533 * C -> constant index of identifier name
69534 */
69535
69536 tv = DUK__REGCONSTP(c); /* XXX: this could be a DUK__CONSTP instead */
69539 act = thr->callstack + thr->callstack_top - 1;
69540 if (duk_js_getvar_activation(thr, act, name, 0 /*throw*/)) {
69541 /* -> [... val this] */
69542 tv = DUK_GET_TVAL_NEGIDX(ctx, -2);
69543 duk_push_hstring(ctx, duk_js_typeof(thr, tv));
69544 duk_replace(ctx, (duk_idx_t) b);
69545 duk_pop_2(ctx);
69546 } else {
69547 /* unresolvable, no stack changes */
69549 duk_replace(ctx, (duk_idx_t) b);
69550 }
69551
69552 break;
69553 }
69554
69555 case DUK_EXTRAOP_INITENUM: {
69556 duk_context *ctx = (duk_context *) thr;
69559
69560 /*
69561 * Enumeration semantics come from for-in statement, E5 Section 12.6.4.
69562 * If called with 'null' or 'undefined', this opcode returns 'null' as
69563 * the enumerator, which is special cased in NEXTENUM. This simplifies
69564 * the compiler part
69565 */
69566
69567 /* B -> register for writing enumerator object
69568 * C -> value to be enumerated (register)
69569 */
69570
69571 if (duk_is_null_or_undefined(ctx, (duk_idx_t) c)) {
69572 duk_push_null(ctx);
69573 duk_replace(ctx, (duk_idx_t) b);
69574 } else {
69575 duk_dup(ctx, (duk_idx_t) c);
69576 duk_to_object(ctx, -1);
69577 duk_hobject_enumerator_create(ctx, 0 /*enum_flags*/); /* [ ... val ] --> [ ... enum ] */
69578 duk_replace(ctx, (duk_idx_t) b);
69579 }
69580 break;
69581 }
69582
69583 case DUK_EXTRAOP_NEXTENUM: {
69584 duk_context *ctx = (duk_context *) thr;
69587
69588 /*
69589 * NEXTENUM checks whether the enumerator still has unenumerated
69590 * keys. If so, the next key is loaded to the target register
69591 * and the next instruction is skipped. Otherwise the next instruction
69592 * will be executed, jumping out of the enumeration loop.
69593 */
69594
69595 /* B -> target register for next key
69596 * C -> enum register
69597 */
69598
69599 DUK_DDD(DUK_DDDPRINT("NEXTENUM: b->%!T, c->%!T",
69600 (duk_tval *) duk_get_tval(ctx, (duk_idx_t) b),
69601 (duk_tval *) duk_get_tval(ctx, (duk_idx_t) c)));
69602
69603 if (duk_is_object(ctx, (duk_idx_t) c)) {
69604 /* XXX: assert 'c' is an enumerator */
69605 duk_dup(ctx, (duk_idx_t) c);
69606 if (duk_hobject_enumerator_next(ctx, 0 /*get_value*/)) {
69607 /* [ ... enum ] -> [ ... next_key ] */
69608 DUK_DDD(DUK_DDDPRINT("enum active, next key is %!T, skip jump slot ",
69609 (duk_tval *) duk_get_tval(ctx, -1)));
69610 curr_pc++;
69611 } else {
69612 /* [ ... enum ] -> [ ... ] */
69613 DUK_DDD(DUK_DDDPRINT("enum finished, execute jump slot"));
69614 duk_push_undefined(ctx);
69615 }
69616 duk_replace(ctx, (duk_idx_t) b);
69617 } else {
69618 /* 'null' enumerator case -> behave as with an empty enumerator */
69619 DUK_ASSERT(duk_is_null(ctx, (duk_idx_t) c));
69620 DUK_DDD(DUK_DDDPRINT("enum is null, execute jump slot"));
69621 }
69622 break;
69623 }
69624
69628 case DUK_EXTRAOP_INITGETI: {
69629 duk_context *ctx = (duk_context *) thr;
69630 duk_bool_t is_set = (extraop == DUK_EXTRAOP_INITSET || extraop == DUK_EXTRAOP_INITSETI);
69632 duk_uint_fast_t idx;
69633
69634 /* B -> object register
69635 * C -> C+0 contains key, C+1 closure (value)
69636 */
69637
69638 /*
69639 * INITSET/INITGET are only used to initialize object literal keys.
69640 * The compiler ensures that there cannot be a previous data property
69641 * of the same name. It also ensures that setter and getter can only
69642 * be initialized once (or not at all).
69643 */
69644
69645 idx = (duk_uint_fast_t) DUK_DEC_C(ins);
69646 if (extraop == DUK_EXTRAOP_INITSETI || extraop == DUK_EXTRAOP_INITGETI) {
69647 duk_tval *tv_ind = DUK__REGP(idx);
69649 idx = (duk_uint_fast_t) DUK_TVAL_GET_NUMBER(tv_ind);
69650 }
69651
69652#if defined(DUK_USE_EXEC_INDIRECT_BOUND_CHECK)
69653 if (idx + 2 > (duk_uint_fast_t) duk_get_top(ctx)) {
69654 /* XXX: use duk_is_valid_index() instead? */
69655 /* XXX: improve check; check against nregs, not against top */
69656 DUK__INTERNAL_ERROR("INITSET/INITGET out of bounds");
69657 }
69658#endif
69659
69660 /* XXX: this is now a very unoptimal implementation -- this can be
69661 * made very simple by direct manipulation of the object internals,
69662 * given the guarantees above.
69663 */
69664
69667 duk_push_undefined(ctx);
69668 duk_dup(ctx, (duk_idx_t) b);
69669 duk_dup(ctx, (duk_idx_t) (idx + 0));
69670 duk_push_object(ctx); /* -> [ Object defineProperty undefined obj key desc ] */
69671
69672 duk_push_true(ctx);
69674 duk_push_true(ctx);
69676 duk_dup(ctx, (duk_idx_t) (idx + 1));
69677 duk_put_prop_stridx(ctx, -2, (is_set ? DUK_STRIDX_SET : DUK_STRIDX_GET));
69678
69679 DUK_DDD(DUK_DDDPRINT("INITGET/INITSET: obj=%!T, key=%!T, desc=%!T",
69680 (duk_tval *) duk_get_tval(ctx, -3),
69681 (duk_tval *) duk_get_tval(ctx, -2),
69682 (duk_tval *) duk_get_tval(ctx, -1)));
69683
69684 duk_call_method(ctx, 3); /* -> [ Object res ] */
69685 duk_pop_2(ctx);
69686
69687 DUK_DDD(DUK_DDDPRINT("INITGET/INITSET AFTER: obj=%!T",
69688 (duk_tval *) duk_get_tval(ctx, (duk_idx_t) b)));
69689 break;
69690 }
69691
69692 case DUK_EXTRAOP_ENDTRY: {
69693 duk_catcher *cat;
69694 duk_tval *tv1;
69695
69696 DUK_ASSERT(thr->catchstack_top >= 1);
69697 DUK_ASSERT(thr->callstack_top >= 1);
69698 DUK_ASSERT(thr->catchstack[thr->catchstack_top - 1].callstack_index == thr->callstack_top - 1);
69699
69700 cat = thr->catchstack + thr->catchstack_top - 1;
69701
69702 DUK_DDD(DUK_DDDPRINT("ENDTRY: clearing catch active flag (regardless of whether it was set or not)"));
69704
69705 if (DUK_CAT_HAS_FINALLY_ENABLED(cat)) {
69706 DUK_DDD(DUK_DDDPRINT("ENDTRY: finally part is active, jump through 2nd jump slot with 'normal continuation'"));
69707
69708 tv1 = thr->valstack + cat->idx_base;
69709 DUK_ASSERT(tv1 >= thr->valstack && tv1 < thr->valstack_top);
69710 DUK_TVAL_SET_UNDEFINED_UPDREF(thr, tv1); /* side effects */
69711 tv1 = NULL;
69712
69713 tv1 = thr->valstack + cat->idx_base + 1;
69714 DUK_ASSERT(tv1 >= thr->valstack && tv1 < thr->valstack_top);
69715 DUK_TVAL_SET_FASTINT_U32_UPDREF(thr, tv1, (duk_uint32_t) DUK_LJ_TYPE_NORMAL); /* side effects */
69716 tv1 = NULL;
69717
69719 } else {
69720 DUK_DDD(DUK_DDDPRINT("ENDTRY: no finally part, dismantle catcher, jump through 2nd jump slot (to end of statement)"));
69721 duk_hthread_catchstack_unwind(thr, thr->catchstack_top - 1);
69722 /* no need to unwind callstack */
69723 }
69724
69725 curr_pc = cat->pc_base + 1;
69726 break;
69727 }
69728
69729 case DUK_EXTRAOP_ENDCATCH: {
69730 duk_activation *act;
69731 duk_catcher *cat;
69732 duk_tval *tv1;
69733
69734 DUK_ASSERT(thr->catchstack_top >= 1);
69735 DUK_ASSERT(thr->callstack_top >= 1);
69736 DUK_ASSERT(thr->catchstack[thr->catchstack_top - 1].callstack_index == thr->callstack_top - 1);
69737
69738 cat = thr->catchstack + thr->catchstack_top - 1;
69739 DUK_ASSERT(!DUK_CAT_HAS_CATCH_ENABLED(cat)); /* cleared before entering catch part */
69740
69741 act = thr->callstack + thr->callstack_top - 1;
69742
69743 if (DUK_CAT_HAS_LEXENV_ACTIVE(cat)) {
69744 duk_hobject *prev_env;
69745
69746 /* 'with' binding has no catch clause, so can't be here unless a normal try-catch */
69748 DUK_ASSERT(act->lex_env != NULL);
69749
69750 DUK_DDD(DUK_DDDPRINT("ENDCATCH: popping catcher part lexical environment"));
69751
69752 prev_env = act->lex_env;
69753 DUK_ASSERT(prev_env != NULL);
69754 act->lex_env = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, prev_env);
69756 DUK_HOBJECT_DECREF(thr, prev_env); /* side effects */
69757 }
69758
69759 if (DUK_CAT_HAS_FINALLY_ENABLED(cat)) {
69760 DUK_DDD(DUK_DDDPRINT("ENDCATCH: finally part is active, jump through 2nd jump slot with 'normal continuation'"));
69761
69762 tv1 = thr->valstack + cat->idx_base;
69763 DUK_ASSERT(tv1 >= thr->valstack && tv1 < thr->valstack_top);
69764 DUK_TVAL_SET_UNDEFINED_UPDREF(thr, tv1); /* side effects */
69765 tv1 = NULL;
69766
69767 tv1 = thr->valstack + cat->idx_base + 1;
69768 DUK_ASSERT(tv1 >= thr->valstack && tv1 < thr->valstack_top);
69769 DUK_TVAL_SET_FASTINT_U32_UPDREF(thr, tv1, (duk_uint32_t) DUK_LJ_TYPE_NORMAL); /* side effects */
69770 tv1 = NULL;
69771
69773 } else {
69774 DUK_DDD(DUK_DDDPRINT("ENDCATCH: no finally part, dismantle catcher, jump through 2nd jump slot (to end of statement)"));
69775 duk_hthread_catchstack_unwind(thr, thr->catchstack_top - 1);
69776 /* no need to unwind callstack */
69777 }
69778
69779 curr_pc = cat->pc_base + 1;
69780 break;
69781 }
69782
69783 case DUK_EXTRAOP_ENDFIN: {
69784 duk_context *ctx = (duk_context *) thr;
69785 duk_catcher *cat;
69786 duk_tval *tv1;
69787 duk_small_uint_t cont_type;
69788 duk_small_uint_t ret_result;
69789
69790 /* Sync and NULL early. */
69792
69793 DUK_ASSERT(thr->catchstack_top >= 1);
69794 DUK_ASSERT(thr->callstack_top >= 1);
69795 DUK_ASSERT(thr->catchstack[thr->catchstack_top - 1].callstack_index == thr->callstack_top - 1);
69796
69797 cat = thr->catchstack + thr->catchstack_top - 1;
69798
69799 /* CATCH flag may be enabled or disabled here; it may be enabled if
69800 * the statement has a catch block but the try block does not throw
69801 * an error.
69802 */
69803 DUK_ASSERT(!DUK_CAT_HAS_FINALLY_ENABLED(cat)); /* cleared before entering finally */
69804 /* XXX: assert idx_base */
69805
69806 DUK_DDD(DUK_DDDPRINT("ENDFIN: completion value=%!T, type=%!T",
69807 (duk_tval *) (thr->valstack + cat->idx_base + 0),
69808 (duk_tval *) (thr->valstack + cat->idx_base + 1)));
69809
69810 tv1 = thr->valstack + cat->idx_base + 1; /* type */
69812 cont_type = (duk_small_uint_t) DUK_TVAL_GET_NUMBER(tv1);
69813
69814 switch (cont_type) {
69815 case DUK_LJ_TYPE_NORMAL: {
69816 DUK_DDD(DUK_DDDPRINT("ENDFIN: finally part finishing with 'normal' (non-abrupt) completion -> "
69817 "dismantle catcher, resume execution after ENDFIN"));
69818 duk_hthread_catchstack_unwind(thr, thr->catchstack_top - 1);
69819 /* no need to unwind callstack */
69820 goto restart_execution;
69821 }
69822 case DUK_LJ_TYPE_RETURN: {
69823 DUK_DDD(DUK_DDDPRINT("ENDFIN: finally part finishing with 'return' complation -> dismantle "
69824 "catcher, handle return, lj.value1=%!T", thr->valstack + cat->idx_base));
69825
69826 /* Not necessary to unwind catchstack: return handling will
69827 * do it. The finally flag of 'cat' is no longer set. The
69828 * catch flag may be set, but it's not checked by return handling.
69829 */
69830 DUK_ASSERT(!DUK_CAT_HAS_FINALLY_ENABLED(cat)); /* cleared before entering finally */
69831#if 0
69832 duk_hthread_catchstack_unwind(thr, thr->catchstack_top - 1);
69833#endif
69834
69835 duk_push_tval(ctx, thr->valstack + cat->idx_base);
69836 ret_result = duk__handle_return(thr,
69837 entry_thread,
69838 entry_callstack_top);
69839 if (ret_result == DUK__RETHAND_RESTART) {
69840 goto restart_execution;
69841 }
69842 DUK_ASSERT(ret_result == DUK__RETHAND_FINISHED);
69843
69844 DUK_DDD(DUK_DDDPRINT("exiting executor after ENDFIN and RETURN (pseudo) longjmp type"));
69845 return;
69846 }
69847 case DUK_LJ_TYPE_BREAK:
69848 case DUK_LJ_TYPE_CONTINUE: {
69849 duk_uint_t label_id;
69850 duk_small_uint_t lj_type;
69851
69852 /* Not necessary to unwind catchstack: break/continue
69853 * handling will do it. The finally flag of 'cat' is
69854 * no longer set. The catch flag may be set, but it's
69855 * not checked by break/continue handling.
69856 */
69857#if 0
69858 duk_hthread_catchstack_unwind(thr, thr->catchstack_top - 1);
69859#endif
69860
69861 tv1 = thr->valstack + cat->idx_base;
69863#if defined(DUK_USE_FASTINT)
69864 DUK_ASSERT(DUK_TVAL_IS_FASTINT(tv1));
69865 label_id = (duk_small_uint_t) DUK_TVAL_GET_FASTINT_U32(tv1);
69866#else
69867 label_id = (duk_small_uint_t) DUK_TVAL_GET_NUMBER(tv1);
69868#endif
69869 lj_type = cont_type;
69870 duk__handle_break_or_continue(thr, label_id, lj_type);
69871 goto restart_execution;
69872 }
69873 default: {
69874 DUK_DDD(DUK_DDDPRINT("ENDFIN: finally part finishing with abrupt completion, lj_type=%ld -> "
69875 "dismantle catcher, re-throw error",
69876 (long) cont_type));
69877
69878 duk_push_tval(ctx, thr->valstack + cat->idx_base);
69879
69881
69882 DUK_ASSERT(thr->heap->lj.jmpbuf_ptr != NULL); /* always in executor */
69883 duk_err_longjmp(thr);
69885 }
69886 }
69887
69888 /* Must restart in all cases because we NULLed thr->ptr_curr_pc. */
69890 break;
69891 }
69892
69893 case DUK_EXTRAOP_THROW: {
69894 duk_context *ctx = (duk_context *) thr;
69895 duk_uint_fast_t bc = DUK_DEC_BC(ins);
69896
69897 /* Note: errors are augmented when they are created, not
69898 * when they are thrown. So, don't augment here, it would
69899 * break re-throwing for instance.
69900 */
69901
69902 /* Sync so that augmentation sees up-to-date activations, NULL
69903 * thr->ptr_curr_pc so that it's not used if side effects occur
69904 * in augmentation or longjmp handling.
69905 */
69907
69908 duk_dup(ctx, (duk_idx_t) bc);
69909 DUK_DDD(DUK_DDDPRINT("THROW ERROR (BYTECODE): %!dT (before throw augment)",
69910 (duk_tval *) duk_get_tval(ctx, -1)));
69911#if defined(DUK_USE_AUGMENT_ERROR_THROW)
69913 DUK_DDD(DUK_DDDPRINT("THROW ERROR (BYTECODE): %!dT (after throw augment)",
69914 (duk_tval *) duk_get_tval(ctx, -1)));
69915#endif
69916
69918
69919 DUK_ASSERT(thr->heap->lj.jmpbuf_ptr != NULL); /* always in executor */
69920 duk_err_longjmp(thr);
69922 break;
69923 }
69924
69925 case DUK_EXTRAOP_INVLHS: {
69926 DUK_ERROR(thr, DUK_ERR_REFERENCE_ERROR, "invalid lvalue");
69927
69929 break;
69930 }
69931
69932 case DUK_EXTRAOP_UNM:
69933 case DUK_EXTRAOP_UNP: {
69934 duk_uint_fast_t bc = DUK_DEC_BC(ins);
69935 duk__vm_arith_unary_op(thr, DUK__REGP(bc), bc, extraop);
69936 break;
69937 }
69938
69939 case DUK_EXTRAOP_DEBUGGER: {
69940 /* Opcode only emitted by compiler when debugger
69941 * support is enabled. Ignore it silently without
69942 * debugger support, in case it has been loaded
69943 * from precompiled bytecode.
69944 */
69945#if defined(DUK_USE_DEBUGGER_SUPPORT)
69946 if (DUK_HEAP_IS_DEBUGGER_ATTACHED(thr->heap)) {
69947 DUK_D(DUK_DPRINT("DEBUGGER statement encountered, halt execution"));
69949 duk_debug_halt_execution(thr, 1 /*use_prev_pc*/);
69950 DUK_D(DUK_DPRINT("DEBUGGER statement finished, resume execution"));
69951 goto restart_execution;
69952 } else {
69953 DUK_D(DUK_DPRINT("DEBUGGER statement ignored, debugger not attached"));
69954 }
69955#else
69956 DUK_D(DUK_DPRINT("DEBUGGER statement ignored, no debugger support"));
69957#endif
69958 break;
69959 }
69960
69961 case DUK_EXTRAOP_BREAK: {
69962 duk_uint_fast_t bc = DUK_DEC_BC(ins);
69963
69964 DUK_DDD(DUK_DDDPRINT("BREAK: %ld", (long) bc));
69965
69968 goto restart_execution;
69969 }
69970
69971 case DUK_EXTRAOP_CONTINUE: {
69972 duk_uint_fast_t bc = DUK_DEC_BC(ins);
69973
69974 DUK_DDD(DUK_DDDPRINT("CONTINUE: %ld", (long) bc));
69975
69978 goto restart_execution;
69979 }
69980
69981 case DUK_EXTRAOP_BNOT: {
69982 duk_uint_fast_t bc = DUK_DEC_BC(ins);
69983
69984 duk__vm_bitwise_not(thr, DUK__REGP(bc), bc);
69985 break;
69986 }
69987
69988 case DUK_EXTRAOP_LNOT: {
69989 duk_uint_fast_t bc = DUK_DEC_BC(ins);
69990 duk_tval *tv1;
69991
69992 tv1 = DUK__REGP(bc);
69993 duk__vm_logical_not(thr, tv1, tv1);
69994 break;
69995 }
69996
69997 case DUK_EXTRAOP_INSTOF: {
69998 duk_context *ctx = (duk_context *) thr;
70001 duk_bool_t tmp;
70002
70003 tmp = duk_js_instanceof(thr, DUK__REGP(b), DUK__REGCONSTP(c));
70004 duk_push_boolean(ctx, tmp);
70005 duk_replace(ctx, (duk_idx_t) b);
70006 break;
70007 }
70008
70009 case DUK_EXTRAOP_IN: {
70010 duk_context *ctx = (duk_context *) thr;
70013 duk_bool_t tmp;
70014
70015 tmp = duk_js_in(thr, DUK__REGP(b), DUK__REGCONSTP(c));
70016 duk_push_boolean(ctx, tmp);
70017 duk_replace(ctx, (duk_idx_t) b);
70018 break;
70019 }
70020
70021 case DUK_EXTRAOP_LABEL: {
70022 duk_catcher *cat;
70023 duk_uint_fast_t bc = DUK_DEC_BC(ins);
70024
70025 /* allocate catcher and populate it (should be atomic) */
70026
70028 cat = thr->catchstack + thr->catchstack_top;
70029 thr->catchstack_top++;
70030
70032 cat->callstack_index = thr->callstack_top - 1;
70033 cat->pc_base = (duk_instr_t *) curr_pc; /* pre-incremented, points to first jump slot */
70034 cat->idx_base = 0; /* unused for label */
70035 cat->h_varname = NULL;
70036
70037 DUK_DDD(DUK_DDDPRINT("LABEL catcher: flags=0x%08lx, callstack_index=%ld, pc_base=%ld, "
70038 "idx_base=%ld, h_varname=%!O, label_id=%ld",
70039 (long) cat->flags, (long) cat->callstack_index, (long) cat->pc_base,
70040 (long) cat->idx_base, (duk_heaphdr *) cat->h_varname, (long) DUK_CAT_GET_LABEL(cat)));
70041
70042 curr_pc += 2; /* skip jump slots */
70043 break;
70044 }
70045
70046 case DUK_EXTRAOP_ENDLABEL: {
70047 duk_catcher *cat;
70048#if defined(DUK_USE_DDDPRINT) || defined(DUK_USE_ASSERTIONS)
70049 duk_uint_fast_t bc = DUK_DEC_BC(ins);
70050#endif
70051#if defined(DUK_USE_DDDPRINT)
70052 DUK_DDD(DUK_DDDPRINT("ENDLABEL %ld", (long) bc));
70053#endif
70054
70055 DUK_ASSERT(thr->catchstack_top >= 1);
70056
70057 cat = thr->catchstack + thr->catchstack_top - 1;
70058 DUK_UNREF(cat);
70061
70062 duk_hthread_catchstack_unwind(thr, thr->catchstack_top - 1);
70063 /* no need to unwind callstack */
70064 break;
70065 }
70066
70067 default: {
70068 DUK__INTERNAL_ERROR("invalid extra opcode");
70069 }
70070
70071 } /* end switch */
70072
70073 break;
70074 }
70075
duk_uint_fast32_t duk_uint_fast_t
duk_int_fast32_t duk_int_fast_t
duk_uint_fast16_t duk_small_uint_fast_t
#define DUK_ERR_INTERNAL_ERROR
#define DUK_ERR_REFERENCE_ERROR
#define DUK_OP_LDINT
#define DUK_OP_TRYCATCH
#define DUK_DEC_OP(x)
#define DUK_TVAL_SET_NUMBER_UPDREF
#define DUK_ENC_OP(op)
#define DUK_DEC_B(x)
#define DUK_EXTRAOP_THROW
#define DUK_TVAL_SET_FASTINT_UPDREF
#define DUK_STRIDX_ENUMERABLE
#define DUK_BC_TRYCATCH_FLAG_HAVE_FINALLY
#define DUK_CAT_LABEL_SHIFT
DUK_INTERNAL void duk_err_longjmp(duk_hthread *thr)
#define DUK_DEC_A(x)
#define DUK__CONSTP(x)
DUK_INTERNAL_DECL duk_bool_t duk_js_in(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y)
#define DUK_BC_TRYCATCH_FLAG_CATCH_BINDING
#define DUK_COMPARE_FLAG_NEGATE
DUK_INTERNAL_DECL duk_bool_t duk_hobject_enumerator_next(duk_context *ctx, duk_bool_t get_value)
DUK_INTERNAL_DECL void duk_hthread_catchstack_grow(duk_hthread *thr)
DUK_EXTERNAL void duk_push_boolean(duk_context *ctx, duk_bool_t val)
DUK_EXTERNAL void duk_to_undefined(duk_context *ctx, duk_idx_t index)
#define DUK_CAT_CLEAR_CATCH_ENABLED(c)
#define DUK_EXTRAOP_ENDTRY
DUK_LOCAL void duk__vm_arith_unary_op(duk_hthread *thr, duk_tval *tv_x, duk_idx_t idx_x, duk_small_uint_fast_t opcode)
DUK_INTERNAL_DECL void duk_js_putvar_activation(duk_hthread *thr, duk_activation *act, duk_hstring *name, duk_tval *val, duk_bool_t strict)
DUK_LOCAL void duk__vm_bitwise_binary_op(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_uint_fast_t idx_z, duk_small_uint_fast_t opcode)
#define DUK_EXTRAOP_SETALEN
#define DUK_TVAL_IS_UNDEFINED(tv)
#define DUK_STRIDX_SET
#define DUK_BC_REGLIMIT
DUK_EXTERNAL void duk_new(duk_context *ctx, duk_idx_t nargs)
#define DUK_EXTRAOP_NEXTENUM
#define DUK_TVAL_SET_TVAL_UPDREF_FAST
#define DUK_TVAL_SET_NULL_UPDREF
DUK_LOCAL duk_small_uint_t duk__handle_return(duk_hthread *thr, duk_hthread *entry_thread, duk_size_t entry_callstack_top)
DUK_LOCAL void duk__vm_bitwise_not(duk_hthread *thr, duk_tval *tv_x, duk_uint_fast_t idx_z)
#define DUK_EXTRAOP_ENDFIN
DUK_INTERNAL_DECL duk_bool_t duk_js_getvar_activation(duk_hthread *thr, duk_activation *act, duk_hstring *name, duk_bool_t throw_flag)
#define DUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, h, p)
#define DUK_STRIDX_LC_UNDEFINED
#define DUK_COMPARE_FLAG_EVAL_LEFT_FIRST
#define DUK__REGP(x)
#define DUK_STRIDX_DEFINE_PROPERTY
#define DUK_CALL_FLAG_IS_TAILCALL
DUK_INTERNAL_DECL duk_hstring * duk_js_typeof(duk_hthread *thr, duk_tval *tv_x)
#define DUK_EXTRAOP_ENDLABEL
#define DUK_DEC_C(x)
#define DUK__FUN()
#define DUK_EXTRAOP_NEWOBJ
#define DUK_TVAL_SET_BOOLEAN_UPDREF
DUK_INTERNAL_DECL void duk_err_setup_heap_ljstate(duk_hthread *thr, duk_small_int_t lj_type)
DUK_LOCAL void duk__vm_logical_not(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_z)
#define DUK_EXTRAOP_BREAK
#define DUK_TVAL_SET_FASTINT(tv, val)
DUK_INTERNAL_DECL void duk_regexp_create_instance(duk_hthread *thr)
#define DUK_TVAL_SET_NUMBER_CHKFAST(tv, d)
#define DUK_BC_TRYCATCH_FLAG_HAVE_CATCH
#define DUK_BC_JUMP_BIAS
#define DUK_OP_LDINTX
#define DUK_OP_RETURN
#define DUK_EXTRAOP_INITENUM
#define DUK_HOBJECT_DECREF(thr, h)
#define DUK_BC_RETURN_FLAG_HAVE_RETVAL
DUK_EXTERNAL duk_bool_t duk_is_null(duk_context *ctx, duk_idx_t index)
#define DUK_EXTRAOP_INVALID
DUK_INTERNAL_DECL duk_bool_t duk_js_delvar_activation(duk_hthread *thr, duk_activation *act, duk_hstring *name)
#define DUK__REGCONSTP(x)
#define DUK_CAT_HAS_LEXENV_ACTIVE(c)
#define DUK_EXTRAOP_ENDCATCH
#define DUK__SYNC_AND_NULL_CURR_PC()
#define DUK__STRICT()
DUK_INTERNAL_DECL void duk_js_push_closure(duk_hthread *thr, duk_hcompiledfunction *fun_temp, duk_hobject *outer_var_env, duk_hobject *outer_lex_env, duk_bool_t add_auto_proto)
#define DUK_EXTRAOP_DEBUGGER
#define DUK_DEC_BC(x)
#define DUK_BC_LDINTX_SHIFT
#define DUK_BC_TRYCATCH_FLAG_WITH_BINDING
#define duk_js_equals(thr, tv_x, tv_y)
DUK_INTERNAL_DECL duk_bool_t duk_js_toboolean(duk_tval *tv)
#define DUK_EXTRAOP_NEWARR
DUK_INTERNAL_DECL void duk_hobject_enumerator_create(duk_context *ctx, duk_small_uint_t enum_flags)
#define duk_js_strict_equals(tv_x, tv_y)
DUK_EXTERNAL duk_bool_t duk_is_null_or_undefined(duk_context *ctx, duk_idx_t index)
#define DUK_BIDX_OBJECT_CONSTRUCTOR
DUK_INTERNAL_DECL duk_bool_t duk_hobject_putprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key, duk_tval *tv_val, duk_bool_t throw_flag)
DUK_EXTERNAL void duk_to_object(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL void duk_handle_call_unprotected(duk_hthread *thr, duk_idx_t num_stack_args, duk_small_uint_t call_flags)
#define DUK_STRIDX_CONFIGURABLE
#define DUK_EXTRAOP_LABEL
#define DUK__INTERNAL_ERROR(msg)
DUK_INTERNAL_DECL void duk_err_augment_error_throw(duk_hthread *thr)
DUK_LOCAL void duk__vm_arith_binary_op(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_idx_t idx_z, duk_small_uint_fast_t opcode)
#define DUK_CAT_CLEAR_LEXENV_ACTIVE(c)
#define DUK_ERROR(thr, err, msg)
#define DUK_EXTRAOP_CONTINUE
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_eval(duk_context *ctx)
#define DUK_CAT_CLEAR_FINALLY_ENABLED(c)
#define DUK_BC_LDINT_BIAS
#define DUK_EXTRAOP_NOP
DUK_LOCAL_DECL void duk__js_execute_bytecode_inner(duk_hthread *entry_thread, duk_size_t entry_callstack_top)
DUK_INTERNAL_DECL duk_bool_t duk_js_declvar_activation(duk_hthread *thr, duk_activation *act, duk_hstring *name, duk_tval *val, duk_small_int_t prop_flags, duk_bool_t is_func_decl)
#define DUK_DEC_ABC(x)
DUK_LOCAL void duk__vm_arith_add(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_uint_fast_t idx_z)
DUK_INTERNAL_DECL void duk_push_hobject_bidx(duk_context *ctx, duk_small_int_t builtin_idx)
#define DUK_STRIDX_GET
#define DUK_TVAL_SET_FASTINT_I32_UPDREF
#define DUK_BC_CALL_FLAG_TAILCALL
DUK_INTERNAL_DECL duk_bool_t duk_hobject_delprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key, duk_bool_t throw_flag)

◆ duk__js_samevalue_number()

DUK_LOCAL duk_bool_t duk__js_samevalue_number ( duk_double_t x,
duk_double_t y )

Definition at line 70575 of file duktape-1.8.0/src/duktape.c.

70576 {
70577 /* IEEE requires that NaNs compare false */
70580 return 1;
70581 } else {
70582 /* IEEE requires that zeros compare the same regardless
70583 * of their signed, so if both x and y are zeroes, they
70584 * are caught above.
70585 */
70587 return 0;
70588 }
70589#endif /* DUK_USE_PARANOID_MATH */
70590}
70591
70593#if defined(DUK_USE_PARANOID_MATH)
70596
70597 if (cx == DUK_FP_NAN && cy == DUK_FP_NAN) {
70598 /* SameValue(NaN, NaN) = true, regardless of NaN sign or extra bits */
70599 return 1;
70600 }
70601 if (cx == DUK_FP_ZERO && cy == DUK_FP_ZERO) {
70602 /* Note: cannot assume that a non-zero return value of signbit() would
70603 * always be the same -- hence cannot (portably) use something like:
70604 *
70605 * signbit(x) == signbit(y)
70606 */
70607 duk_small_int_t sx = (DUK_SIGNBIT(x) ? 1 : 0);
70608 duk_small_int_t sy = (DUK_SIGNBIT(y) ? 1 : 0);
70609 return (sx == sy);
70610 }
70611
70612 /* normal comparison; known:
70613 * - both x and y are not NaNs (but one of them can be)
70614 * - both x and y are not zero (but one of them can be)
70615 * - x and y may be denormal or infinite
70616 */
70617
70618 return (x == y);
70619#else /* DUK_USE_PARANOID_MATH */
70622
70623 if (x == y) {
70624 /* IEEE requires that NaNs compare false */
70627
70628 /* Using classification has smaller footprint than direct comparison. */
70629 if (DUK_UNLIKELY(cx == DUK_FP_ZERO && cy == DUK_FP_ZERO)) {
70630 /* Note: cannot assume that a non-zero return value of signbit() would
70631 * always be the same -- hence cannot (portably) use something like:
70632 *
70633 * signbit(x) == signbit(y)
70634 */
70635 duk_small_int_t sx = (DUK_SIGNBIT(x) ? 1 : 0);
70636 duk_small_int_t sy = (DUK_SIGNBIT(y) ? 1 : 0);
70637 return (sx == sy);
70638 }
70639 return 1;
70640 } else {
DUK_LOCAL duk_bool_t duk__js_samevalue_number(duk_double_t x, duk_double_t y)

References DUK_ASSERT, DUK_FP_NAN, and DUK_FPCLASSIFY.

◆ duk__key_is_lightfunc_ownprop()

DUK_LOCAL duk_bool_t duk__key_is_lightfunc_ownprop ( duk_hthread * thr,
duk_hstring * key )

Definition at line 47584 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_hobject_putprop().

◆ duk__load_buffer_raw()

DUK_LOCAL duk_uint8_t * duk__load_buffer_raw ( duk_context * ctx,
duk_uint8_t * p )

Definition at line 11684 of file duktape-1.8.0/src/duktape.c.

11692 {
11693 duk_uint32_t len;
11694

References DUK_RAW_READ_U32_BE.

◆ duk__load_func()

static duk_uint8_t * duk__load_func ( duk_context * ctx,
duk_uint8_t * p,
duk_uint8_t * p_end )
static

Definition at line 12019 of file duktape-1.8.0/src/duktape.c.

12032 { \
12033 DUK_ASSERT((duk_size_t) (p_end - p) >= (duk_size_t) (n)); \
12034 } while (0)
12035
12036static duk_uint8_t *duk__load_func(duk_context *ctx, duk_uint8_t *p, duk_uint8_t *p_end) {
12037 duk_hthread *thr;
12038 duk_hcompiledfunction *h_fun;
12039 duk_hbuffer *h_data;
12040 duk_size_t data_size;
12041 duk_uint32_t count_instr, count_const, count_funcs;
12042 duk_uint32_t n;
12043 duk_uint32_t tmp32;
12044 duk_small_uint_t const_type;
12045 duk_uint8_t *fun_data;
12046 duk_uint8_t *q;
12047 duk_idx_t idx_base;
12048 duk_tval *tv1;
12049 duk_uarridx_t arr_idx;
12050
12051 /* XXX: There's some overlap with duk_js_closure() here, but
12052 * seems difficult to share code. Ensure that the final function
12053 * looks the same as created by duk_js_closure().
12054 */
12055
12056 DUK_ASSERT(ctx != NULL);
12057 thr = (duk_hthread *) ctx;
12058
12059 DUK_DD(DUK_DDPRINT("loading function, p=%p, p_end=%p", (void *) p, (void *) p_end));
12060
12061 DUK__ASSERT_LEFT(3 * 4);
12062 count_instr = DUK_RAW_READ_U32_BE(p);
12063 count_const = DUK_RAW_READ_U32_BE(p);
12064 count_funcs = DUK_RAW_READ_U32_BE(p);
12065
12066 data_size = sizeof(duk_tval) * count_const +
12067 sizeof(duk_hobject *) * count_funcs +
12068 sizeof(duk_instr_t) * count_instr;
12069
12070 DUK_DD(DUK_DDPRINT("instr=%ld, const=%ld, funcs=%ld, data_size=%ld",
12071 (long) count_instr, (long) count_const,
12072 (long) count_const, (long) data_size));
12073
12074 /* Value stack is used to ensure reachability of constants and
12075 * inner functions being loaded. Require enough space to handle
12076 * large functions correctly.
12077 */
12078 duk_require_stack(ctx, 2 + count_const + count_funcs);
12079 idx_base = duk_get_top(ctx);
12080
12081 /* Push function object, init flags etc. This must match
12082 * duk_js_push_closure() quite carefully.
12083 */
12085 h_fun = duk_get_hcompiledfunction(ctx, -1);
12086 DUK_ASSERT(h_fun != NULL);
12091
12092 h_fun->nregs = DUK_RAW_READ_U16_BE(p);
12093 h_fun->nargs = DUK_RAW_READ_U16_BE(p);
12094#if defined(DUK_USE_DEBUGGER_SUPPORT)
12095 h_fun->start_line = DUK_RAW_READ_U32_BE(p);
12096 h_fun->end_line = DUK_RAW_READ_U32_BE(p);
12097#else
12098 p += 8; /* skip line info */
12099#endif
12100
12101 /* duk_hcompiledfunction flags; quite version specific */
12102 tmp32 = DUK_RAW_READ_U32_BE(p);
12103 DUK_HEAPHDR_SET_FLAGS((duk_heaphdr *) h_fun, tmp32);
12104
12105 /* standard prototype */
12107
12108 /* assert just a few critical flags */
12117
12118 /* Create function 'data' buffer but don't attach it yet. */
12119 fun_data = (duk_uint8_t *) duk_push_fixed_buffer(ctx, data_size);
12120 DUK_ASSERT(fun_data != NULL);
12121
12122 /* Load bytecode instructions. */
12123 DUK_ASSERT(sizeof(duk_instr_t) == 4);
12124 DUK__ASSERT_LEFT(count_instr * sizeof(duk_instr_t));
12125#if defined(DUK_USE_INTEGER_BE)
12126 q = fun_data + sizeof(duk_tval) * count_const + sizeof(duk_hobject *) * count_funcs;
12127 DUK_MEMCPY((void *) q,
12128 (const void *) p,
12129 sizeof(duk_instr_t) * count_instr);
12130 p += sizeof(duk_instr_t) * count_instr;
12131#else
12132 q = fun_data + sizeof(duk_tval) * count_const + sizeof(duk_hobject *) * count_funcs;
12133 for (n = count_instr; n > 0; n--) {
12134 *((duk_instr_t *) (void *) q) = DUK_RAW_READ_U32_BE(p);
12135 q += sizeof(duk_instr_t);
12136 }
12137#endif
12138
12139 /* Load constants onto value stack but don't yet copy to buffer. */
12140 for (n = count_const; n > 0; n--) {
12142 const_type = DUK_RAW_READ_U8(p);
12143 switch (const_type) {
12144 case DUK__SER_STRING: {
12145 p = duk__load_string_raw(ctx, p);
12146 break;
12147 }
12148 case DUK__SER_NUMBER: {
12149 /* Important to do a fastint check so that constants are
12150 * properly read back as fastints.
12151 */
12152 duk_tval tv_tmp;
12153 duk_double_t val;
12155 val = DUK_RAW_READ_DOUBLE_BE(p);
12156 DUK_TVAL_SET_NUMBER_CHKFAST(&tv_tmp, val);
12157 duk_push_tval(ctx, &tv_tmp);
12158 break;
12159 }
12160 default: {
12161 goto format_error;
12162 }
12163 }
12164 }
12165
12166 /* Load inner functions to value stack, but don't yet copy to buffer. */
12167 for (n = count_funcs; n > 0; n--) {
12168 p = duk__load_func(ctx, p, p_end);
12169 if (p == NULL) {
12170 goto format_error;
12171 }
12172 }
12173
12174 /* With constants and inner functions on value stack, we can now
12175 * atomically finish the function 'data' buffer, bump refcounts,
12176 * etc.
12177 *
12178 * Here we take advantage of the value stack being just a duk_tval
12179 * array: we can just memcpy() the constants as long as we incref
12180 * them afterwards.
12181 */
12182
12183 h_data = (duk_hbuffer *) duk_get_hbuffer(ctx, idx_base + 1);
12184 DUK_ASSERT(h_data != NULL);
12186 DUK_HCOMPILEDFUNCTION_SET_DATA(thr->heap, h_fun, h_data);
12187 DUK_HBUFFER_INCREF(thr, h_data);
12188
12189 tv1 = duk_get_tval(ctx, idx_base + 2); /* may be NULL if no constants or inner funcs */
12190 DUK_ASSERT((count_const == 0 && count_funcs == 0) || tv1 != NULL);
12191
12192 q = fun_data;
12193 if (count_const > 0) {
12194 /* Explicit zero size check to avoid NULL 'tv1'. */
12195 DUK_MEMCPY((void *) q, (const void *) tv1, sizeof(duk_tval) * count_const);
12196 for (n = count_const; n > 0; n--) {
12197 DUK_TVAL_INCREF_FAST(thr, (duk_tval *) (void *) q); /* no side effects */
12198 q += sizeof(duk_tval);
12199 }
12200 tv1 += count_const;
12201 }
12202
12203 DUK_HCOMPILEDFUNCTION_SET_FUNCS(thr->heap, h_fun, (duk_hobject **) (void *) q);
12204 for (n = count_funcs; n > 0; n--) {
12205 duk_hobject *h_obj;
12206
12208 h_obj = DUK_TVAL_GET_OBJECT(tv1);
12209 DUK_ASSERT(h_obj != NULL);
12210 tv1++;
12211 DUK_HOBJECT_INCREF(thr, h_obj);
12212
12213 *((duk_hobject **) (void *) q) = h_obj;
12214 q += sizeof(duk_hobject *);
12215 }
12216
12217 DUK_HCOMPILEDFUNCTION_SET_BYTECODE(thr->heap, h_fun, (duk_instr_t *) (void *) q);
12218
12219 /* The function object is now reachable and refcounts are fine,
12220 * so we can pop off all the temporaries.
12221 */
12222 DUK_DDD(DUK_DDDPRINT("function is reachable, reset top; func: %!iT", duk_get_tval(ctx, idx_base)));
12223 duk_set_top(ctx, idx_base + 1);
12224
12225 /* Setup function properties. */
12226 tmp32 = DUK_RAW_READ_U32_BE(p);
12227 duk_push_u32(ctx, tmp32);
12229
12230 p = duk__load_string_raw(ctx, p);
12232 /* Original function instance/template had NAMEBINDING.
12233 * Must create a lexical environment on loading to allow
12234 * recursive functions like 'function foo() { foo(); }'.
12235 */
12237
12242 proto);
12243 duk_dup(ctx, -2); /* -> [ func funcname env funcname ] */
12244 duk_dup(ctx, idx_base); /* -> [ func funcname env funcname func ] */
12245 duk_xdef_prop(ctx, -3, DUK_PROPDESC_FLAGS_NONE); /* -> [ func funcname env ] */
12247 /* since closure has NEWENV, never define DUK_STRIDX_INT_VARENV, as it
12248 * will be ignored anyway
12249 */
12250 }
12252
12253 p = duk__load_string_raw(ctx, p);
12255
12256 duk_push_object(ctx);
12257 duk_dup(ctx, -2);
12258 duk_xdef_prop_stridx(ctx, -2, DUK_STRIDX_CONSTRUCTOR, DUK_PROPDESC_FLAGS_WC); /* func.prototype.constructor = func */
12259 duk_compact(ctx, -1);
12261
12262 p = duk__load_buffer_raw(ctx, p);
12264
12265 duk_push_object(ctx); /* _Varmap */
12266 for (;;) {
12267 /* XXX: awkward */
12268 p = duk__load_string_raw(ctx, p);
12269 if (duk_get_length(ctx, -1) == 0) {
12270 duk_pop(ctx);
12271 break;
12272 }
12273 tmp32 = DUK_RAW_READ_U32_BE(p);
12274 duk_push_u32(ctx, tmp32);
12275 duk_put_prop(ctx, -3);
12276 }
12277 duk_compact(ctx, -1);
12279
12280 duk_push_array(ctx); /* _Formals */
12281 for (arr_idx = 0; ; arr_idx++) {
12282 /* XXX: awkward */
12283 p = duk__load_string_raw(ctx, p);
const char * proto
Definition civetweb.c:18378
#define DUK_HBUFFER_INCREF(thr, h)
#define DUK_TVAL_INCREF_FAST(thr, tv)
DUK_INTERNAL_DECL void duk_xdef_prop(duk_context *ctx, duk_idx_t obj_index, duk_small_uint_t desc_flags)
#define DUK_BIDX_FUNCTION_PROTOTYPE
#define DUK_STRIDX_CONSTRUCTOR
#define DUK__ASSERT_LEFT(n)
DUK_LOCAL duk_uint8_t * duk__load_string_raw(duk_context *ctx, duk_uint8_t *p)
static duk_uint8_t * duk__load_func(duk_context *ctx, duk_uint8_t *p, duk_uint8_t *p_end)
#define DUK_STRIDX_INT_LEXENV
#define DUK_RAW_READ_U8(ptr)
#define DUK_HEAPHDR_SET_FLAGS(h, val)
#define DUK_HOBJECT_HAS_THREAD(h)
DUK_LOCAL duk_uint8_t * duk__load_buffer_raw(duk_context *ctx, duk_uint8_t *p)
#define DUK_RAW_READ_DOUBLE_BE(ptr)
DUK_INTERNAL_DECL duk_hcompiledfunction * duk_get_hcompiledfunction(duk_context *ctx, duk_idx_t index)
#define DUK_RAW_READ_U16_BE(ptr)
#define DUK_STRIDX_PROTOTYPE
#define duk_push_u32(ctx, val)
#define DUK_PROPDESC_FLAGS_W
#define DUK_HOBJECT_HAS_NAMEBINDING(h)

◆ duk__load_string_raw()

DUK_LOCAL duk_uint8_t * duk__load_string_raw ( duk_context * ctx,
duk_uint8_t * p )

Definition at line 11675 of file duktape-1.8.0/src/duktape.c.

◆ duk__log()

DUK_LOCAL double duk__log ( double x)

Definition at line 32759 of file duktape-1.8.0/src/duktape.c.

32761 {

◆ duk__lookup_active_label()

DUK_LOCAL_DECL void duk__lookup_active_label ( duk_compiler_ctx * comp_ctx,
duk_hstring * h_label,
duk_bool_t is_break,
duk_int_t * out_label_id,
duk_int_t * out_label_catch_depth,
duk_int_t * out_label_pc,
duk_bool_t * out_is_closest )

Definition at line 60357 of file duktape-1.8.0/src/duktape.c.

60374 {
60375 duk_hthread *thr = comp_ctx->thr;
60376 duk_context *ctx = (duk_context *) thr;
60377 duk_uint8_t *p;
60378 duk_labelinfo *li_start, *li_end, *li;
60379 duk_bool_t match = 0;
60380
60381 DUK_DDD(DUK_DDDPRINT("looking up active label: label='%!O', is_break=%ld",
60382 (duk_heaphdr *) h_label, (long) is_break));
60383
60384 DUK_UNREF(ctx);
60385
60386 p = (duk_uint8_t *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, comp_ctx->curr_func.h_labelinfos);
60387 li_start = (duk_labelinfo *) (void *) p;
60388 li_end = (duk_labelinfo *) (void *) (p + DUK_HBUFFER_GET_SIZE(comp_ctx->curr_func.h_labelinfos));
60389 li = li_end;
60390
60391 /* Match labels starting from latest label because there can be duplicate empty
60392 * labels in the label set.
60393 */
60394 while (li > li_start) {
60395 li--;
60396
60397 if (li->h_label != h_label) {
60398 DUK_DDD(DUK_DDDPRINT("labelinfo[%ld] ->'%!O' != %!O",
60399 (long) (li - li_start),
60400 (duk_heaphdr *) li->h_label,
60401 (duk_heaphdr *) h_label));
60402 continue;
60403 }
60404
60405 DUK_DDD(DUK_DDDPRINT("labelinfo[%ld] -> '%!O' label name matches (still need to check type)",
60406 (long) (li - li_start), (duk_heaphdr *) h_label));
60407
60408 /* currently all labels accept a break, so no explicit check for it now */
60410
60411 if (is_break) {
60412 /* break matches always */
60413 match = 1;
60414 break;
60415 } else if (li->flags & DUK_LABEL_FLAG_ALLOW_CONTINUE) {
60416 /* iteration statements allow continue */
60417 match = 1;
60418 break;
60419 } else {
60420 /* continue matched this label -- we can only continue if this is the empty
60421 * label, for which duplication is allowed, and thus there is hope of
60422 * finding a match deeper in the label stack.
60423 */
60424 if (h_label != DUK_HTHREAD_STRING_EMPTY_STRING(thr)) {
60426 } else {
60427 DUK_DDD(DUK_DDDPRINT("continue matched an empty label which does not "
60428 "allow a continue -> continue lookup deeper in label stack"));
#define DUK_LABEL_FLAG_ALLOW_CONTINUE
#define DUK_LABEL_FLAG_ALLOW_BREAK
#define DUK_STR_INVALID_LABEL

◆ duk__lookup_active_register_binding()

DUK_LOCAL_DECL duk_reg_t duk__lookup_active_register_binding ( duk_compiler_ctx * comp_ctx)

Definition at line 60154 of file duktape-1.8.0/src/duktape.c.

60155 {
60157}
60158
60159/* The issues below can be solved with better flags */
60160
60161/* XXX: many operations actually want toforcedtemp() -- brand new temp? */
60162/* XXX: need a toplain_ignore() which will only coerce a value to a temp
60163 * register if it might have a side effect. Side-effect free values do not
60164 * need to be coerced.
60165 */
60166
60167/*
60168 * Identifier handling
60169 */
60170
60172 duk_hthread *thr = comp_ctx->thr;
60173 duk_context *ctx = (duk_context *) thr;
60174 duk_hstring *h_varname;
60175 duk_reg_t ret;
60176
60177 DUK_DDD(DUK_DDDPRINT("resolving identifier reference to '%!T'",
60178 (duk_tval *) duk_get_tval(ctx, -1)));
60179
60180 /*
60181 * Special name handling
60182 */
60183
60184 h_varname = duk_get_hstring(ctx, -1);
60185 DUK_ASSERT(h_varname != NULL);
60186
60187 if (h_varname == DUK_HTHREAD_STRING_LC_ARGUMENTS(thr)) {
60188 DUK_DDD(DUK_DDDPRINT("flagging function as accessing 'arguments'"));
60189 comp_ctx->curr_func.id_access_arguments = 1;
60190 }
60191
60192 /*
60193 * Inside one or more 'with' statements fall back to slow path always.
60194 * (See e.g. test-stmt-with.js.)
60195 */
60196
60197 if (comp_ctx->curr_func.with_depth > 0) {
60198 DUK_DDD(DUK_DDDPRINT("identifier lookup inside a 'with' -> fall back to slow path"));
60199 goto slow_path;
60200 }
60201
60202 /*
60203 * Any catch bindings ("catch (e)") also affect identifier binding.
60204 *
60205 * Currently, the varmap is modified for the duration of the catch
60206 * clause to ensure any identifier accesses with the catch variable
60207 * name will use slow path.
60208 */
60209
60210 duk_get_prop(ctx, comp_ctx->curr_func.varmap_idx);
DUK_LOCAL_DECL duk_reg_t duk__lookup_active_register_binding(duk_compiler_ctx *comp_ctx)

References DUK__IVAL_FLAG_ALLOW_CONST, DUK__IVAL_FLAG_REQUIRE_TEMP, and duk__ivalue_toregconst_raw().

◆ duk__lookup_arguments_map()

DUK_LOCAL duk_bool_t duk__lookup_arguments_map ( duk_hthread * thr,
duk_hobject * obj,
duk_hstring * key,
duk_propdesc * temp_desc,
duk_hobject ** out_map,
duk_hobject ** out_varenv )

Definition at line 48806 of file duktape-1.8.0/src/duktape.c.

48828 {
48829 duk_context *ctx = (duk_context *) thr;
48830 duk_hobject *map;
48831 duk_hobject *varenv;
48832 duk_bool_t rc;
48833
48835
48836 DUK_DDD(DUK_DDDPRINT("arguments map lookup: thr=%p, obj=%p, key=%p, temp_desc=%p "
48837 "(obj -> %!O, key -> %!O)",
48838 (void *) thr, (void *) obj, (void *) key, (void *) temp_desc,
48839 (duk_heaphdr *) obj, (duk_heaphdr *) key));
48840
48842 DUK_DDD(DUK_DDDPRINT("-> no 'map'"));
48843 return 0;
48844 }
48845
48846 map = duk_require_hobject(ctx, -1);
48847 DUK_ASSERT(map != NULL);
48848 duk_pop(ctx); /* map is reachable through obj */
48849
48850 if (!duk_hobject_get_own_propdesc(thr, map, key, temp_desc, DUK_GETDESC_FLAG_PUSH_VALUE)) {
48851 DUK_DDD(DUK_DDDPRINT("-> 'map' exists, but key not in map"));
48852 return 0;
48853 }
48854
48855 /* [... varname] */
48856 DUK_DDD(DUK_DDDPRINT("-> 'map' exists, and contains key, key is mapped to argument/variable binding %!T",
48857 (duk_tval *) duk_get_tval(ctx, -1)));

Referenced by duk_hobject_define_property_helper().

◆ duk__lookup_lhs()

DUK_LOCAL_DECL duk_bool_t duk__lookup_lhs ( duk_compiler_ctx * ctx,
duk_reg_t * out_reg_varbind,
duk_regconst_t * out_rc_varname )

Definition at line 60220 of file duktape-1.8.0/src/duktape.c.

60222 :
60223 DUK_DDD(DUK_DDDPRINT("identifier lookup -> slow path"));
60224
60225 comp_ctx->curr_func.id_access_slow = 1;
60226 return (duk_reg_t) -1;
60227}
60228
60229/* Lookup an identifier name in the current varmap, indicating whether the
60230 * identifier is register-bound and if not, allocating a constant for the
60231 * identifier name. Returns 1 if register-bound, 0 otherwise. Caller can
60232 * also check (out_reg_varbind >= 0) to check whether or not identifier is
60233 * register bound. The caller must NOT use out_rc_varname at all unless
60234 * return code is 0 or out_reg_varbind is < 0; this is becuase out_rc_varname
60235 * is unsigned and doesn't have a "unused" / none value.
60236 */
60237DUK_LOCAL duk_bool_t duk__lookup_lhs(duk_compiler_ctx *comp_ctx, duk_reg_t *out_reg_varbind, duk_regconst_t *out_rc_varname) {
60238 duk_hthread *thr = comp_ctx->thr;
60239 duk_context *ctx = (duk_context *) thr;
60240 duk_reg_t reg_varbind;
60241 duk_regconst_t rc_varname;
60242

Referenced by duk__parse_var_decl().

◆ duk__make_day()

DUK_LOCAL duk_double_t duk__make_day ( duk_double_t year,
duk_double_t month,
duk_double_t day )

Definition at line 25156 of file duktape-1.8.0/src/duktape.c.

25159 : 365));
25160 return year;
25161 }
25162
25163 /* Note: this is very tricky; we must never 'overshoot' the
25164 * correction downwards.
25165 */
25166 year -= 1 + (diff_days - 1) / 366; /* conservative */
25167 }
25168}
25169
25170/* Given a (year, month, day-within-month) triple, compute day number.
25171 * The input triple is un-normalized and may contain non-finite values.
25172 */
25174 duk_int_t day_num;
25175 duk_bool_t is_leap;
25176 duk_small_int_t i, n;
25177
25178 /* Assume that year, month, day are all coerced to whole numbers.
25179 * They may also be NaN or infinity, in which case this function
25180 * must return NaN or infinity to ensure time value becomes NaN.
25181 * If 'day' is NaN, the final return will end up returning a NaN,
25182 * so it doesn't need to be checked here.
25183 */
25184
25185 if (!DUK_ISFINITE(year) || !DUK_ISFINITE(month)) {
25186 return DUK_DOUBLE_NAN;
25187 }
25188
25189 year += DUK_FLOOR(month / 12.0);
25190
25191 month = DUK_FMOD(month, 12.0);
25192 if (month < 0.0) {
25193 /* handle negative values */
25194 month += 12.0;
25195 }
25196
25197 /* The algorithm in E5.1 Section 15.9.1.12 normalizes month, but
25198 * does not normalize the day-of-month (nor check whether or not
25199 * it is finite) because it's not necessary for finding the day
25200 * number which matches the (year,month) pair.
25201 *
25202 * We assume that duk__day_from_year() is exact here.
25203 *
25204 * Without an explicit infinity / NaN check in the beginning,
25205 * day_num would be a bogus integer here.
25206 *
25207 * It's possible for 'year' to be out of integer range here.
25208 * If so, we need to return NaN without integer overflow.
25209 * This fixes test-bug-setyear-overflow.js.
25210 */
25211
DUK_INTERNAL_DECL duk_bool_t duk_bi_date_year_in_valid_range(duk_double_t year)
DUK_LOCAL duk_double_t duk__make_day(duk_double_t year, duk_double_t month, duk_double_t day)

◆ duk__mark_finalizable()

DUK_LOCAL void duk__mark_finalizable ( duk_heap * heap)

Definition at line 42440 of file duktape-1.8.0/src/duktape.c.

42457 {
42458 duk_hthread *thr;
42459 duk_heaphdr *hdr;
42460 duk_size_t count_finalizable = 0;
42461
42462 DUK_DD(DUK_DDPRINT("duk__mark_finalizable: %p", (void *) heap));
42463
42464 thr = duk__get_temp_hthread(heap);
42465 DUK_ASSERT(thr != NULL);
42466
42467 hdr = heap->heap_allocated;
42468 while (hdr) {
42469 /* A finalizer is looked up from the object and up its prototype chain
42470 * (which allows inherited finalizers). A prototype loop must not cause
42471 * an error to be thrown here; duk_hobject_hasprop_raw() will ignore a
42472 * prototype loop silently and indicate that the property doesn't exist.
42473 */
42474
42475 if (!DUK_HEAPHDR_HAS_REACHABLE(hdr) &&
42479
42480 /* heaphdr:
42481 * - is not reachable
42482 * - is an object
42483 * - is not a finalized object
42484 * - has a finalizer
42485 */
42486
42487 DUK_DD(DUK_DDPRINT("unreachable heap object will be "
42488 "finalized -> mark as finalizable "
42489 "and treat as a reachability root: %p",
42490 (void *) hdr));
42493 count_finalizable ++;
42494 }
42495
42496 hdr = DUK_HEAPHDR_GET_NEXT(heap, hdr);
42497 }
42498
42499 if (count_finalizable == 0) {
#define DUK_HEAPHDR_SET_FINALIZABLE(h)

◆ duk__mark_finalize_list()

DUK_LOCAL void duk__mark_finalize_list ( duk_heap * heap)

Definition at line 42506 of file duktape-1.8.0/src/duktape.c.

42507 {
42508 if (DUK_HEAPHDR_HAS_FINALIZABLE(hdr)) {
42509 duk__mark_heaphdr(heap, hdr);
42510 }
42511
42512 hdr = DUK_HEAPHDR_GET_NEXT(heap, hdr);
42513 }
42514
42515 /* Caller will finish the marking process if we hit a recursion limit. */
42516}
42517
42518/*
42519 * Mark objects on finalize_list.
42520 *
42521 */
42522
42524 duk_heaphdr *hdr;
42525#ifdef DUK_USE_DEBUG
42526 duk_size_t count_finalize_list = 0;
42527#endif
42528
42529 DUK_DD(DUK_DDPRINT("duk__mark_finalize_list: %p", (void *) heap));
DUK_LOCAL_DECL void duk__mark_heaphdr(duk_heap *heap, duk_heaphdr *h)
DUK_LOCAL void duk__mark_finalize_list(duk_heap *heap)
#define DUK_HEAPHDR_HAS_FINALIZABLE(h)

References duk__mark_heaphdr(), DUK_HEAPHDR_GET_NEXT, and DUK_HEAPHDR_HAS_FINALIZABLE.

◆ duk__mark_heaphdr()

DUK_LOCAL_DECL void duk__mark_heaphdr ( duk_heap * heap,
duk_heaphdr * h )

Definition at line 42319 of file duktape-1.8.0/src/duktape.c.

42321 {
42322 duk_catcher *cat = t->catchstack + i;
42323 }
42324#endif
42325
42326 duk__mark_heaphdr(heap, (duk_heaphdr *) t->resumer);
42327
42328 /* XXX: duk_small_uint_t would be enough for this loop */
42329 for (i = 0; i < DUK_NUM_BUILTINS; i++) {
42330 duk__mark_heaphdr(heap, (duk_heaphdr *) t->builtins[i]);
42331 }
42332 }
42333}
42334
42335/* recursion tracking happens here only */
42337 DUK_DDD(DUK_DDDPRINT("duk__mark_heaphdr %p, type %ld",
42338 (void *) h,
42339 (h != NULL ? (long) DUK_HEAPHDR_GET_TYPE(h) : (long) -1)));
42340 if (!h) {
42341 return;
42342 }
42343#if defined(DUK_USE_ROM_OBJECTS)
42344 if (DUK_HEAPHDR_HAS_READONLY(h)) {
42345 DUK_DDD(DUK_DDDPRINT("readonly object %p, skip", (void *) h));
42346 return;
42347 }
42348#endif
42350 DUK_DDD(DUK_DDDPRINT("already marked reachable, skip"));
42351 return;
42352 }
42354
42356 /* log this with a normal debug level because this should be relatively rare */
42357 DUK_D(DUK_DPRINT("mark-and-sweep recursion limit reached, marking as temproot: %p", (void *) h));
42360 return;
42361 }
42362
42364
#define DUK_USE_MARK_AND_SWEEP_RECLIMIT
#define DUK_HEAPHDR_SET_REACHABLE(h)
#define DUK_HEAPHDR_SET_TEMPROOT(h)
#define DUK_HEAP_SET_MARKANDSWEEP_RECLIMIT_REACHED(heap)
#define DUK_NUM_BUILTINS

Referenced by duk__mark_finalize_list(), and duk__mark_temproots_by_heap_scan().

◆ duk__mark_hobject()

DUK_LOCAL void duk__mark_hobject ( duk_heap * heap,
duk_hobject * h )

Definition at line 42216 of file duktape-1.8.0/src/duktape.c.

42223 {
42224 DUK_UNREF(heap);
42225 DUK_UNREF(h);
42226
42227 DUK_DDD(DUK_DDDPRINT("duk__mark_hstring: %p", (void *) h));
42228 DUK_ASSERT(h);
42229
42230 /* nothing to process */
42231}
42232
42235
42236 DUK_DDD(DUK_DDDPRINT("duk__mark_hobject: %p", (void *) h));
42237
42238 DUK_ASSERT(h);
42239
42240 /* XXX: use advancing pointers instead of index macros -> faster and smaller? */
42241
42242 for (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ENEXT(h); i++) {
42243 duk_hstring *key = DUK_HOBJECT_E_GET_KEY(heap, h, i);
42244 if (!key) {
42245 continue;
42246 }
42247 duk__mark_heaphdr(heap, (duk_heaphdr *) key);
42248 if (DUK_HOBJECT_E_SLOT_IS_ACCESSOR(heap, h, i)) {
42249 duk__mark_heaphdr(heap, (duk_heaphdr *) DUK_HOBJECT_E_GET_VALUE_PTR(heap, h, i)->a.get);
42250 duk__mark_heaphdr(heap, (duk_heaphdr *) DUK_HOBJECT_E_GET_VALUE_PTR(heap, h, i)->a.set);
42251 } else {
42252 duk__mark_tval(heap, &DUK_HOBJECT_E_GET_VALUE_PTR(heap, h, i)->v);
42253 }
42254 }
42255
42256 for (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ASIZE(h); i++) {
42258 }
42259
42260 /* hash part is a 'weak reference' and does not contribute */
42261
42263
42266 duk_tval *tv, *tv_end;
42267 duk_hobject **fn, **fn_end;
42268
42269 /* 'data' is reachable through every compiled function which
42270 * contains a reference.
42271 */
42272
42274
42275 if (DUK_HCOMPILEDFUNCTION_GET_DATA(heap, f) != NULL) {
42277 tv_end = DUK_HCOMPILEDFUNCTION_GET_CONSTS_END(heap, f);
42278 while (tv < tv_end) {
42279 duk__mark_tval(heap, tv);
42280 tv++;
42281 }
42282
42284 fn_end = DUK_HCOMPILEDFUNCTION_GET_FUNCS_END(heap, f);
42285 while (fn < fn_end) {
42286 duk__mark_heaphdr(heap, (duk_heaphdr *) *fn);
42287 fn++;
42288 }
42289 } else {
42290 /* May happen in some out-of-memory corner cases. */
42291 DUK_D(DUK_DPRINT("duk_hcompiledfunction 'data' is NULL, skipping marking"));
42292 }
42293 } else if (DUK_HOBJECT_IS_NATIVEFUNCTION(h)) {
42295 DUK_UNREF(f);
42296 /* nothing to mark */
42297 } else if (DUK_HOBJECT_IS_BUFFEROBJECT(h)) {
42299 duk__mark_heaphdr(heap, (duk_heaphdr *) b->buf);
42300 } else if (DUK_HOBJECT_IS_THREAD(h)) {
42301 duk_hthread *t = (duk_hthread *) h;
42302 duk_tval *tv;
42303
42304 tv = t->valstack;
42305 while (tv < t->valstack_top) {
42306 duk__mark_tval(heap, tv);
42307 tv++;
42308 }
42309
42310 for (i = 0; i < (duk_uint_fast32_t) t->callstack_top; i++) {
42311 duk_activation *act = t->callstack + i;
42313 duk__mark_heaphdr(heap, (duk_heaphdr *) act->var_env);
42314 duk__mark_heaphdr(heap, (duk_heaphdr *) act->lex_env);
42315#ifdef DUK_USE_NONSTD_FUNC_CALLER_PROPERTY
42316 duk__mark_heaphdr(heap, (duk_heaphdr *) act->prev_caller);
#define DUK_HOBJECT_E_GET_VALUE_PTR(heap, h, i)
DUK_LOCAL void duk__mark_hobject(duk_heap *heap, duk_hobject *h)
DUK_LOCAL_DECL void duk__mark_tval(duk_heap *heap, duk_tval *tv)

◆ duk__mark_hstring()

DUK_LOCAL void duk__mark_hstring ( duk_heap * heap,
duk_hstring * h )

Definition at line 42206 of file duktape-1.8.0/src/duktape.c.

42212 {
42213 if (heap->curr_thread) {
42214 return heap->curr_thread;

References duk_heap::curr_thread.

◆ duk__mark_refzero_list()

DUK_LOCAL void duk__mark_refzero_list ( duk_heap * heap)

Definition at line 42415 of file duktape-1.8.0/src/duktape.c.

◆ duk__mark_roots_heap()

DUK_LOCAL void duk__mark_roots_heap ( duk_heap * heap)

Definition at line 42380 of file duktape-1.8.0/src/duktape.c.

42383 {
42384 DUK_DDD(DUK_DDDPRINT("duk__mark_tval %p", (void *) tv));
42385 if (!tv) {
42386 return;
42387 }
42390 }
42391}
42392
42393/*
42394 * Mark the heap.
42395 */
42396
42399
42400 DUK_DD(DUK_DDPRINT("duk__mark_roots_heap: %p", (void *) heap));
42401
DUK_LOCAL void duk__mark_roots_heap(duk_heap *heap)

◆ duk__mark_temproots_by_heap_scan()

DUK_LOCAL void duk__mark_temproots_by_heap_scan ( duk_heap * heap)

Definition at line 42565 of file duktape-1.8.0/src/duktape.c.

42565 {
42566#endif
42567 if (!DUK_HEAPHDR_HAS_TEMPROOT(hdr)) {
42568 DUK_DDD(DUK_DDDPRINT("not a temp root: %p", (void *) hdr));
42569 return;
42570 }
42571
42572 DUK_DDD(DUK_DDDPRINT("found a temp root: %p", (void *) hdr));
42574 DUK_HEAPHDR_CLEAR_REACHABLE(hdr); /* done so that duk__mark_heaphdr() works correctly */
42575 duk__mark_heaphdr(heap, hdr);
42576
42577#ifdef DUK_USE_DEBUG
42578 (*count)++;
42579#endif
42580}
42581
42583 duk_heaphdr *hdr;
42584#ifdef DUK_USE_DEBUG
42585 duk_size_t count;
42586#endif
42587
42588 DUK_DD(DUK_DDPRINT("duk__mark_temproots_by_heap_scan: %p", (void *) heap));
42589
42591 DUK_DD(DUK_DDPRINT("recursion limit reached, doing heap scan to continue from temproots"));
42592
42593#ifdef DUK_USE_DEBUG
42594 count = 0;
42595#endif
42597
42598 hdr = heap->heap_allocated;
42599 while (hdr) {
42600#ifdef DUK_USE_DEBUG
42601 duk__handle_temproot(heap, hdr, &count);
42602#else
42603 duk__handle_temproot(heap, hdr);
42604#endif
42605 hdr = DUK_HEAPHDR_GET_NEXT(heap, hdr);
42606 }
42607
42608 /* must also check refzero_list */
#define DUK_HEAP_HAS_MARKANDSWEEP_RECLIMIT_REACHED(heap)
#define DUK_HEAP_CLEAR_MARKANDSWEEP_RECLIMIT_REACHED(heap)
DUK_LOCAL void duk__mark_temproots_by_heap_scan(duk_heap *heap)
DUK_LOCAL void duk__handle_temproot(duk_heap *heap, duk_heaphdr *hdr)
#define DUK_HEAPHDR_HAS_TEMPROOT(h)
#define DUK_HEAPHDR_CLEAR_REACHABLE(h)
#define DUK_HEAPHDR_CLEAR_TEMPROOT(h)

References duk__mark_heaphdr(), DUK_DDD, DUK_DDDPRINT, DUK_HEAPHDR_CLEAR_REACHABLE, DUK_HEAPHDR_CLEAR_TEMPROOT, and DUK_HEAPHDR_HAS_TEMPROOT.

◆ duk__mark_tval()

DUK_LOCAL_DECL void duk__mark_tval ( duk_heap * heap,
duk_tval * tv )

Definition at line 42366 of file duktape-1.8.0/src/duktape.c.

42366 :
42367 duk__mark_hstring(heap, (duk_hstring *) h);
42368 break;
42369 case DUK_HTYPE_OBJECT:
42370 duk__mark_hobject(heap, (duk_hobject *) h);
42371 break;
42372 case DUK_HTYPE_BUFFER:
42373 /* nothing to mark */
42374 break;
DUK_LOCAL void duk__mark_hstring(duk_heap *heap, duk_hstring *h)
#define DUK_HTYPE_BUFFER

◆ duk__match_regexp()

DUK_LOCAL const duk_uint8_t * duk__match_regexp ( duk_re_matcher_ctx * re_ctx,
const duk_uint8_t * pc,
const duk_uint8_t * sp )

Definition at line 78869 of file duktape-1.8.0/src/duktape.c.

78869 {
78870 /* note: caller 'sp' is intentionally not updated here */
78871 (void) duk__inp_backtrack(re_ctx, &sp, (duk_uint_fast32_t) 1);
78872 return duk__inp_get_cp(re_ctx, &sp);
78873}
78874
78875/*
78876 * Regexp recursive matching function.
78877 *
78878 * Returns 'sp' on successful match (points to character after last matched one),
78879 * NULL otherwise.
78880 *
78881 * The C recursion depth limit check is only performed in this function, this
78882 * suffices because the function is present in all true recursion required by
78883 * regexp execution.
78884 */
78885
78886DUK_LOCAL const duk_uint8_t *duk__match_regexp(duk_re_matcher_ctx *re_ctx, const duk_uint8_t *pc, const duk_uint8_t *sp) {
78887 if (re_ctx->recursion_depth >= re_ctx->recursion_limit) {
78889 }
78890 re_ctx->recursion_depth++;
78891
78892 for (;;) {
78893 duk_small_int_t op;
78894
78895 if (re_ctx->steps_count >= re_ctx->steps_limit) {
78897 }
78898 re_ctx->steps_count++;
78899
78900 op = (duk_small_int_t) duk__bc_get_u32(re_ctx, &pc);
78901
78902 DUK_DDD(DUK_DDDPRINT("match: rec=%ld, steps=%ld, pc (after op)=%ld, sp=%ld, op=%ld",
78903 (long) re_ctx->recursion_depth,
78904 (long) re_ctx->steps_count,
78905 (long) (pc - re_ctx->bytecode),
78906 (long) (sp - re_ctx->input),
78907 (long) op));
78908
78909 switch (op) {
78910 case DUK_REOP_MATCH: {
78911 goto match;
78912 }
78913 case DUK_REOP_CHAR: {
78914 /*
78915 * Byte-based matching would be possible for case-sensitive
78916 * matching but not for case-insensitive matching. So, we
78917 * match by decoding the input and bytecode character normally.
78918 *
78919 * Bytecode characters are assumed to be already canonicalized.
78920 * Input characters are canonicalized automatically by
78921 * duk__inp_get_cp() if necessary.
78922 *
78923 * There is no opcode for matching multiple characters. The
78924 * regexp compiler has trouble joining strings efficiently
78925 * during compilation. See doc/regexp.rst for more discussion.
78926 */
78927 duk_codepoint_t c1, c2;
78928
78929 c1 = (duk_codepoint_t) duk__bc_get_u32(re_ctx, &pc);
78931 c1 == duk_unicode_re_canonicalize_char(re_ctx->thr, c1)); /* canonicalized by compiler */
78932 if (sp >= re_ctx->input_end) {
78933 goto fail;
78934 }
78935 c2 = duk__inp_get_cp(re_ctx, &sp);
78936 DUK_DDD(DUK_DDDPRINT("char match, c1=%ld, c2=%ld", (long) c1, (long) c2));
78937 if (c1 != c2) {
78938 goto fail;
78939 }
78940 break;
78941 }
78942 case DUK_REOP_PERIOD: {
78944
78945 if (sp >= re_ctx->input_end) {
78946 goto fail;
78947 }
78948 c = duk__inp_get_cp(re_ctx, &sp);
78950 /* E5 Sections 15.10.2.8, 7.3 */
78951 goto fail;
78952 }
78953 break;
78954 }
78955 case DUK_REOP_RANGES:
78956 case DUK_REOP_INVRANGES: {
78957 duk_uint32_t n;
78960
78961 n = duk__bc_get_u32(re_ctx, &pc);
78962 if (sp >= re_ctx->input_end) {
78963 goto fail;
78964 }
78965 c = duk__inp_get_cp(re_ctx, &sp);
78966
78967 match = 0;
78968 while (n) {
78969 duk_codepoint_t r1, r2;
78970 r1 = (duk_codepoint_t) duk__bc_get_u32(re_ctx, &pc);
78971 r2 = (duk_codepoint_t) duk__bc_get_u32(re_ctx, &pc);
78972 DUK_DDD(DUK_DDDPRINT("matching ranges/invranges, n=%ld, r1=%ld, r2=%ld, c=%ld",
78973 (long) n, (long) r1, (long) r2, (long) c));
78974 if (c >= r1 && c <= r2) {
78975 /* Note: don't bail out early, we must read all the ranges from
78976 * bytecode. Another option is to skip them efficiently after
78977 * breaking out of here. Prefer smallest code.
78978 */
78979 match = 1;
78980 }
78981 n--;
78982 }
78983
78984 if (op == DUK_REOP_RANGES) {
78985 if (!match) {
78986 goto fail;
78987 }
78988 } else {
78990 if (match) {
78991 goto fail;
78992 }
78993 }
78994 break;
78995 }
78996 case DUK_REOP_ASSERT_START: {
78998
78999 if (sp <= re_ctx->input) {
79000 break;
79001 }
79002 if (!(re_ctx->re_flags & DUK_RE_FLAG_MULTILINE)) {
79003 goto fail;
79004 }
79005 c = duk__inp_get_prev_cp(re_ctx, sp);
79007 /* E5 Sections 15.10.2.8, 7.3 */
79008 break;
79009 }
79010 goto fail;
79011 }
79012 case DUK_REOP_ASSERT_END: {
79014 const duk_uint8_t *tmp_sp;
79015
79016 if (sp >= re_ctx->input_end) {
79017 break;
79018 }
79019 if (!(re_ctx->re_flags & DUK_RE_FLAG_MULTILINE)) {
79020 goto fail;
79021 }
79022 tmp_sp = sp;
79023 c = duk__inp_get_cp(re_ctx, &tmp_sp);
79025 /* E5 Sections 15.10.2.8, 7.3 */
79026 break;
79027 }
79028 goto fail;
79029 }
79032 /*
79033 * E5 Section 15.10.2.6. The previous and current character
79034 * should -not- be canonicalized as they are now. However,
79035 * canonicalization does not affect the result of IsWordChar()
79036 * (which depends on Unicode characters never canonicalizing
79037 * into ASCII characters) so this does not matter.
79038 */
79039 duk_small_int_t w1, w2;
79040
79041 if (sp <= re_ctx->input) {
79042 w1 = 0; /* not a wordchar */
79043 } else {
79045 c = duk__inp_get_prev_cp(re_ctx, sp);
79047 }
79048 if (sp >= re_ctx->input_end) {
79049 w2 = 0; /* not a wordchar */
79050 } else {
79051 const duk_uint8_t *tmp_sp = sp; /* dummy so sp won't get updated */
79053 c = duk__inp_get_cp(re_ctx, &tmp_sp);
79055 }
79056
79058 if (w1 == w2) {
79059 goto fail;
79060 }
79061 } else {
79063 if (w1 != w2) {
79064 goto fail;
79065 }
79066 }
79067 break;
79068 }
79069 case DUK_REOP_JUMP: {
79070 duk_int32_t skip;
79071
79072 skip = duk__bc_get_i32(re_ctx, &pc);
79073 pc += skip;
79074 break;
79075 }
79076 case DUK_REOP_SPLIT1: {
79077 /* split1: prefer direct execution (no jump) */
79078 const duk_uint8_t *sub_sp;
79079 duk_int32_t skip;
79080
79081 skip = duk__bc_get_i32(re_ctx, &pc);
79082 sub_sp = duk__match_regexp(re_ctx, pc, sp);
79083 if (sub_sp) {
79084 sp = sub_sp;
79085 goto match;
79086 }
79087 pc += skip;
79088 break;
79089 }
79090 case DUK_REOP_SPLIT2: {
79091 /* split2: prefer jump execution (not direct) */
79092 const duk_uint8_t *sub_sp;
79093 duk_int32_t skip;
79094
79095 skip = duk__bc_get_i32(re_ctx, &pc);
79096 sub_sp = duk__match_regexp(re_ctx, pc + skip, sp);
79097 if (sub_sp) {
79098 sp = sub_sp;
79099 goto match;
79100 }
79101 break;
79102 }
79103 case DUK_REOP_SQMINIMAL: {
79104 duk_uint32_t q, qmin, qmax;
79105 duk_int32_t skip;
79106 const duk_uint8_t *sub_sp;
79107
79108 qmin = duk__bc_get_u32(re_ctx, &pc);
79109 qmax = duk__bc_get_u32(re_ctx, &pc);
79110 skip = duk__bc_get_i32(re_ctx, &pc);
79111 DUK_DDD(DUK_DDDPRINT("minimal quantifier, qmin=%lu, qmax=%lu, skip=%ld",
79112 (unsigned long) qmin, (unsigned long) qmax, (long) skip));
79113
79114 q = 0;
79115 while (q <= qmax) {
79116 if (q >= qmin) {
79117 sub_sp = duk__match_regexp(re_ctx, pc + skip, sp);
79118 if (sub_sp) {
79119 sp = sub_sp;
79120 goto match;
79121 }
79122 }
79123 sub_sp = duk__match_regexp(re_ctx, pc, sp);
79124 if (!sub_sp) {
79125 break;
79126 }
79127 sp = sub_sp;
79128 q++;
79129 }
79130 goto fail;
79131 }
79132 case DUK_REOP_SQGREEDY: {
79133 duk_uint32_t q, qmin, qmax, atomlen;
79134 duk_int32_t skip;
79135 const duk_uint8_t *sub_sp;
79136
79137 qmin = duk__bc_get_u32(re_ctx, &pc);
79138 qmax = duk__bc_get_u32(re_ctx, &pc);
79139 atomlen = duk__bc_get_u32(re_ctx, &pc);
79140 skip = duk__bc_get_i32(re_ctx, &pc);
79141 DUK_DDD(DUK_DDDPRINT("greedy quantifier, qmin=%lu, qmax=%lu, atomlen=%lu, skip=%ld",
79142 (unsigned long) qmin, (unsigned long) qmax, (unsigned long) atomlen, (long) skip));
79143
79144 q = 0;
79145 while (q < qmax) {
79146 sub_sp = duk__match_regexp(re_ctx, pc, sp);
79147 if (!sub_sp) {
79148 break;
79149 }
79150 sp = sub_sp;
79151 q++;
79152 }
79153 while (q >= qmin) {
79154 sub_sp = duk__match_regexp(re_ctx, pc + skip, sp);
79155 if (sub_sp) {
79156 sp = sub_sp;
79157 goto match;
79158 }
79159 if (q == qmin) {
79160 break;
79161 }
79162
79163 /* Note: if atom were to contain e.g. captures, we would need to
79164 * re-match the atom to get correct captures. Simply quantifiers
79165 * do not allow captures in their atom now, so this is not an issue.
79166 */
79167
79168 DUK_DDD(DUK_DDDPRINT("greedy quantifier, backtrack %ld characters (atomlen)",
79169 (long) atomlen));
79170 sp = duk__inp_backtrack(re_ctx, &sp, (duk_uint_fast32_t) atomlen);
79171 q--;
79172 }
79173 goto fail;
79174 }
79175 case DUK_REOP_SAVE: {
79176 duk_uint32_t idx;
79177 const duk_uint8_t *old;
79178 const duk_uint8_t *sub_sp;
79179
79180 idx = duk__bc_get_u32(re_ctx, &pc);
79181 if (idx >= re_ctx->nsaved) {
79182 /* idx is unsigned, < 0 check is not necessary */
79183 DUK_D(DUK_DPRINT("internal error, regexp save index insane: idx=%ld", (long) idx));
79184 goto internal_error;
79185 }
79186 old = re_ctx->saved[idx];
79187 re_ctx->saved[idx] = sp;
79188 sub_sp = duk__match_regexp(re_ctx, pc, sp);
79189 if (sub_sp) {
79190 sp = sub_sp;
79191 goto match;
79192 }
79193 re_ctx->saved[idx] = old;
79194 goto fail;
79195 }
79196 case DUK_REOP_WIPERANGE: {
79197 /* Wipe capture range and save old values for backtracking.
79198 *
79199 * XXX: this typically happens with a relatively small idx_count.
79200 * It might be useful to handle cases where the count is small
79201 * (say <= 8) by saving the values in stack instead. This would
79202 * reduce memory churn and improve performance, at the cost of a
79203 * slightly higher code footprint.
79204 */
79205 duk_uint32_t idx_start, idx_count;
79206#ifdef DUK_USE_EXPLICIT_NULL_INIT
79207 duk_uint32_t idx_end, idx;
79208#endif
79209 duk_uint8_t **range_save;
79210 const duk_uint8_t *sub_sp;
79211
79212 idx_start = duk__bc_get_u32(re_ctx, &pc);
79213 idx_count = duk__bc_get_u32(re_ctx, &pc);
79214 DUK_DDD(DUK_DDDPRINT("wipe saved range: start=%ld, count=%ld -> [%ld,%ld] (captures [%ld,%ld])",
79215 (long) idx_start, (long) idx_count,
79216 (long) idx_start, (long) (idx_start + idx_count - 1),
79217 (long) (idx_start / 2), (long) ((idx_start + idx_count - 1) / 2)));
79218 if (idx_start + idx_count > re_ctx->nsaved || idx_count == 0) {
79219 /* idx is unsigned, < 0 check is not necessary */
79220 DUK_D(DUK_DPRINT("internal error, regexp wipe indices insane: idx_start=%ld, idx_count=%ld",
79221 (long) idx_start, (long) idx_count));
79222 goto internal_error;
79223 }
79224 DUK_ASSERT(idx_count > 0);
79225
79226 duk_require_stack((duk_context *) re_ctx->thr, 1);
79227 range_save = (duk_uint8_t **) duk_push_fixed_buffer((duk_context *) re_ctx->thr,
79228 sizeof(duk_uint8_t *) * idx_count);
79229 DUK_ASSERT(range_save != NULL);
79230 DUK_MEMCPY(range_save, re_ctx->saved + idx_start, sizeof(duk_uint8_t *) * idx_count);
79231#ifdef DUK_USE_EXPLICIT_NULL_INIT
79232 idx_end = idx_start + idx_count;
79233 for (idx = idx_start; idx < idx_end; idx++) {
79234 re_ctx->saved[idx] = NULL;
79235 }
79236#else
79237 DUK_MEMZERO((void *) (re_ctx->saved + idx_start), sizeof(duk_uint8_t *) * idx_count);
79238#endif
79239
79240 sub_sp = duk__match_regexp(re_ctx, pc, sp);
79241 if (sub_sp) {
79242 /* match: keep wiped/resaved values */
79243 DUK_DDD(DUK_DDDPRINT("match: keep wiped/resaved values [%ld,%ld] (captures [%ld,%ld])",
79244 (long) idx_start, (long) (idx_start + idx_count - 1),
79245 (long) (idx_start / 2), (long) ((idx_start + idx_count - 1) / 2)));
79246 duk_pop((duk_context *) re_ctx->thr);
79247 sp = sub_sp;
79248 goto match;
79249 }
79250
79251 /* fail: restore saves */
79252 DUK_DDD(DUK_DDDPRINT("fail: restore wiped/resaved values [%ld,%ld] (captures [%ld,%ld])",
79253 (long) idx_start, (long) (idx_start + idx_count - 1),
79254 (long) (idx_start / 2), (long) ((idx_start + idx_count - 1) / 2)));
79255 DUK_MEMCPY((void *) (re_ctx->saved + idx_start),
79256 (const void *) range_save,
79257 sizeof(duk_uint8_t *) * idx_count);
79258 duk_pop((duk_context *) re_ctx->thr);
79259 goto fail;
79260 }
79261 case DUK_REOP_LOOKPOS:
79262 case DUK_REOP_LOOKNEG: {
79263 /*
79264 * Needs a save of multiple saved[] entries depending on what range
79265 * may be overwritten. Because the regexp parser does no such analysis,
79266 * we currently save the entire saved array here. Lookaheads are thus
79267 * a bit expensive. Note that the saved array is not needed for just
79268 * the lookahead sub-match, but for the matching of the entire sequel.
79269 *
79270 * The temporary save buffer is pushed on to the valstack to handle
79271 * errors correctly. Each lookahead causes a C recursion and pushes
79272 * more stuff on the value stack. If the C recursion limit is less
79273 * than the value stack spare, there is no need to check the stack.
79274 * We do so regardless, just in case.
79275 */
79276
79277 duk_int32_t skip;
79278 duk_uint8_t **full_save;
79279 const duk_uint8_t *sub_sp;
79280
79281 DUK_ASSERT(re_ctx->nsaved > 0);
79282
79283 duk_require_stack((duk_context *) re_ctx->thr, 1);
79284 full_save = (duk_uint8_t **) duk_push_fixed_buffer((duk_context *) re_ctx->thr,
79285 sizeof(duk_uint8_t *) * re_ctx->nsaved);
79286 DUK_ASSERT(full_save != NULL);
79287 DUK_MEMCPY(full_save, re_ctx->saved, sizeof(duk_uint8_t *) * re_ctx->nsaved);
79288
79289 skip = duk__bc_get_i32(re_ctx, &pc);
79290 sub_sp = duk__match_regexp(re_ctx, pc, sp);
79291 if (op == DUK_REOP_LOOKPOS) {
79292 if (!sub_sp) {
79293 goto lookahead_fail;
79294 }
79295 } else {
79296 if (sub_sp) {
79297 goto lookahead_fail;
79298 }
79299 }
79300 sub_sp = duk__match_regexp(re_ctx, pc + skip, sp);
79301 if (sub_sp) {
79302 /* match: keep saves */
79303 duk_pop((duk_context *) re_ctx->thr);
79304 sp = sub_sp;
79305 goto match;
79306 }
79307
79308 /* fall through */
79309
79310 lookahead_fail:
79311 /* fail: restore saves */
79312 DUK_MEMCPY((void *) re_ctx->saved,
79313 (const void *) full_save,
79314 sizeof(duk_uint8_t *) * re_ctx->nsaved);
79315 duk_pop((duk_context *) re_ctx->thr);
79316 goto fail;
79317 }
79319 /*
79320 * Byte matching for back-references would be OK in case-
79321 * sensitive matching. In case-insensitive matching we need
79322 * to canonicalize characters, so back-reference matching needs
79323 * to be done with codepoints instead. So, we just decode
79324 * everything normally here, too.
79325 *
79326 * Note: back-reference index which is 0 or higher than
79327 * NCapturingParens (= number of capturing parens in the
79328 * -entire- regexp) is a compile time error. However, a
79329 * backreference referring to a valid capture which has
79330 * not matched anything always succeeds! See E5 Section
79331 * 15.10.2.9, step 5, sub-step 3.
79332 */
79333 duk_uint32_t idx;
79334 const duk_uint8_t *p;
79335
79336 idx = duk__bc_get_u32(re_ctx, &pc);
79337 idx = idx << 1; /* backref n -> saved indices [n*2, n*2+1] */
79338 if (idx < 2 || idx + 1 >= re_ctx->nsaved) {
79339 /* regexp compiler should catch these */
79340 DUK_D(DUK_DPRINT("internal error, backreference index insane"));
79341 goto internal_error;
79342 }
79343 if (!re_ctx->saved[idx] || !re_ctx->saved[idx+1]) {
79344 /* capture is 'undefined', always matches! */
79345 DUK_DDD(DUK_DDDPRINT("backreference: saved[%ld,%ld] not complete, always match",
79346 (long) idx, (long) (idx + 1)));
79347 break;
79348 }
79349 DUK_DDD(DUK_DDDPRINT("backreference: match saved[%ld,%ld]", (long) idx, (long) (idx + 1)));
79350
79351 p = re_ctx->saved[idx];
79352 while (p < re_ctx->saved[idx+1]) {
79353 duk_codepoint_t c1, c2;
79354
79355 /* Note: not necessary to check p against re_ctx->input_end:
79356 * the memory access is checked by duk__inp_get_cp(), while
79357 * valid compiled regexps cannot write a saved[] entry
79358 * which points to outside the string.
79359 */
79360 if (sp >= re_ctx->input_end) {
79361 goto fail;
79362 }
79363 c1 = duk__inp_get_cp(re_ctx, &p);
79364 c2 = duk__inp_get_cp(re_ctx, &sp);
79365 if (c1 != c2) {
79366 goto fail;
79367 }
79368 }
79369 break;
79370 }
79371 default: {
79372 DUK_D(DUK_DPRINT("internal error, regexp opcode error: %ld", (long) op));
DUK_LOCAL duk_uint32_t duk__bc_get_u32(duk_re_matcher_ctx *re_ctx, const duk_uint8_t **pc)
#define DUK_REOP_MATCH
#define DUK_STR_REGEXP_EXECUTOR_STEP_LIMIT
#define DUK_REOP_RANGES
#define DUK_REOP_ASSERT_WORD_BOUNDARY
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_re_is_wordchar(duk_codepoint_t cp)
#define DUK_REOP_ASSERT_END
#define DUK_RE_FLAG_MULTILINE
#define DUK_REOP_INVRANGES
#define DUK_REOP_SAVE
DUK_LOCAL const duk_uint8_t * duk__match_regexp(duk_re_matcher_ctx *re_ctx, const duk_uint8_t *pc, const duk_uint8_t *sp)
DUK_LOCAL duk_int32_t duk__bc_get_i32(duk_re_matcher_ctx *re_ctx, const duk_uint8_t **pc)
#define DUK_REOP_PERIOD
#define DUK_REOP_SQGREEDY
#define DUK_REOP_SPLIT2
#define DUK_REOP_LOOKPOS
#define DUK_REOP_LOOKNEG
DUK_LOCAL duk_codepoint_t duk__inp_get_prev_cp(duk_re_matcher_ctx *re_ctx, const duk_uint8_t *sp)
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_line_terminator(duk_codepoint_t cp)
#define DUK_REOP_JUMP
#define DUK_REOP_BACKREFERENCE
#define DUK_REOP_WIPERANGE
#define DUK_REOP_ASSERT_START
DUK_LOCAL duk_codepoint_t duk__inp_get_cp(duk_re_matcher_ctx *re_ctx, const duk_uint8_t **sp)
#define DUK_REOP_ASSERT_NOT_WORD_BOUNDARY
#define DUK_REOP_SPLIT1
#define DUK_REOP_CHAR
#define DUK_STR_REGEXP_EXECUTOR_RECURSION_LIMIT
#define DUK_REOP_SQMINIMAL
DUK_LOCAL const duk_uint8_t * duk__inp_backtrack(duk_re_matcher_ctx *re_ctx, const duk_uint8_t **sp, duk_uint_fast32_t count)

References duk__inp_backtrack(), and duk__inp_get_cp().

◆ duk__math_minmax()

DUK_LOCAL duk_ret_t duk__math_minmax ( duk_context * ctx,
duk_double_t initial,
duk__two_arg_func min_max )

Definition at line 32557 of file duktape-1.8.0/src/duktape.c.

32574 {
32575 duk_idx_t n = duk_get_top(ctx);
32576 duk_idx_t i;
32577 duk_double_t res = initial;
32578 duk_double_t t;
32579
32580 /*
32581 * Note: fmax() does not match the E5 semantics. E5 requires
32582 * that if -any- input to Math.max() is a NaN, the result is a
32583 * NaN. fmax() will return a NaN only if -both- inputs are NaN.
32584 * Same applies to fmin().
32585 *
32586 * Note: every input value must be coerced with ToNumber(), even

References duk_get_top().

◆ duk__nonbound_func_lookup()

DUK_LOCAL duk_hobject * duk__nonbound_func_lookup ( duk_context * ctx,
duk_idx_t idx_func,
duk_idx_t * out_num_stack_args,
duk_tval ** out_tv_func,
duk_small_uint_t call_flags )

Definition at line 55701 of file duktape-1.8.0/src/duktape.c.

55704 :
55705 DUK_ASSERT(!DUK_TVAL_IS_UNUSED(tv_this));
55706 DUK_DDD(DUK_DDDPRINT("this binding: non-strict, not object/undefined/null -> use ToObject(value)"));
55707 duk_to_object(ctx, idx_this); /* may have side effects */
55708 break;
55709 }
55710}
55711
55712/*
55713 * Shared helper for non-bound func lookup.
55714 *
55715 * Returns duk_hobject * to the final non-bound function (NULL for lightfunc).
55716 */
55717
55719 duk_idx_t idx_func,
55720 duk_idx_t *out_num_stack_args,
55721 duk_tval **out_tv_func,
55722 duk_small_uint_t call_flags) {
55723 duk_hthread *thr = (duk_hthread *) ctx;
55724 duk_tval *tv_func;
55725 duk_hobject *func;
55726
55727 for (;;) {
55728 /* Use loop to minimize code size of relookup after bound function case */
55729 tv_func = DUK_GET_TVAL_POSIDX(ctx, idx_func);
55730 DUK_ASSERT(tv_func != NULL);
55731
55732 if (DUK_TVAL_IS_OBJECT(tv_func)) {
55733 func = DUK_TVAL_GET_OBJECT(tv_func);
55734 if (!DUK_HOBJECT_IS_CALLABLE(func)) {
55735 goto not_callable_error;
55736 }
55737 if (DUK_HOBJECT_HAS_BOUND(func)) {
55738 duk__handle_bound_chain_for_call(thr, idx_func, out_num_stack_args, call_flags & DUK_CALL_FLAG_CONSTRUCTOR_CALL);
55739
55740 /* The final object may be a normal function or a lightfunc.
55741 * We need to re-lookup tv_func because it may have changed
55742 * (also value stack may have been resized). Loop again to
55743 * do that; we're guaranteed not to come here again.
55744 */
55746 DUK_TVAL_IS_LIGHTFUNC(duk_require_tval(ctx, idx_func)));
55747 continue;
55748 }
55749 } else if (DUK_TVAL_IS_LIGHTFUNC(tv_func)) {
55750 func = NULL;
55751 } else {
55752 goto not_callable_error;
55753 }
55754 break;
55755 }
55756
55758 DUK_TVAL_IS_LIGHTFUNC(tv_func));
DUK_LOCAL void duk__handle_bound_chain_for_call(duk_hthread *thr, duk_idx_t idx_func, duk_idx_t *p_num_stack_args, duk_bool_t is_constructor_call)

Referenced by duk_handle_ecma_call_setup().

◆ duk__nud_array_literal()

DUK_LOCAL_DECL void duk__nud_array_literal ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res )

Definition at line 60455 of file duktape-1.8.0/src/duktape.c.

60472 {
60473 duk_hthread *thr = comp_ctx->thr;
60474 duk_reg_t reg_obj; /* result reg */
60475 duk_reg_t reg_temp; /* temp reg */
60476 duk_reg_t temp_start; /* temp reg value for start of loop */
60477 duk_small_uint_t max_init_values; /* max # of values initialized in one MPUTARR set */
60478 duk_small_uint_t num_values; /* number of values in current MPUTARR set */
60479 duk_uarridx_t curr_idx; /* current (next) array index */
60480 duk_uarridx_t start_idx; /* start array index of current MPUTARR set */
60481 duk_uarridx_t init_idx; /* last array index explicitly initialized, +1 */
60482 duk_bool_t require_comma; /* next loop requires a comma */
60483
60484 /* DUK_TOK_LBRACKET already eaten, current token is right after that */
60486
60487 max_init_values = DUK__MAX_ARRAY_INIT_VALUES; /* XXX: depend on available temps? */
60488
60489 reg_obj = DUK__ALLOCTEMP(comp_ctx);
60490 duk__emit_extraop_b_c(comp_ctx,
60492 reg_obj,
60493 0); /* XXX: patch initial size afterwards? */
60494 temp_start = DUK__GETTEMP(comp_ctx);
60495
60496 /*
60497 * Emit initializers in sets of maximum max_init_values.
60498 * Corner cases such as single value initializers do not have
60499 * special handling now.
60500 *
60501 * Elided elements must not be emitted as 'undefined' values,
60502 * because such values would be enumerable (which is incorrect).
60503 * Also note that trailing elisions must be reflected in the
60504 * length of the final array but cause no elements to be actually
60505 * inserted.
60506 */
60507
60508 curr_idx = 0;
60509 init_idx = 0; /* tracks maximum initialized index + 1 */
60510 start_idx = 0;
60511 require_comma = 0;
60512
60513 for (;;) {
60514 num_values = 0;
60515 DUK__SETTEMP(comp_ctx, temp_start);
60516
60517 if (comp_ctx->curr_token.t == DUK_TOK_RBRACKET) {
60518 break;
60519 }
60520
60521 for (;;) {
60522 if (comp_ctx->curr_token.t == DUK_TOK_RBRACKET) {
60523 /* the outer loop will recheck and exit */
60524 break;
60525 }
60526
60527 /* comma check */
60528 if (require_comma) {
60529 if (comp_ctx->curr_token.t == DUK_TOK_COMMA) {
60530 /* comma after a value, expected */
60531 duk__advance(comp_ctx);
60532 require_comma = 0;
60533 continue;
60534 } else {
60535 goto syntax_error;
60536 }
60537 } else {
60538 if (comp_ctx->curr_token.t == DUK_TOK_COMMA) {
60539 /* elision - flush */
60540 curr_idx++;
60541 duk__advance(comp_ctx);
60542 /* if num_values > 0, MPUTARR emitted by outer loop after break */
60543 break;
60544 }
60545 }
60546 /* else an array initializer element */
60547
60548 /* initial index */
60549 if (num_values == 0) {
60550 start_idx = curr_idx;
60551 reg_temp = DUK__ALLOCTEMP(comp_ctx);
60552 duk__emit_load_int32(comp_ctx, reg_temp, (duk_int32_t) start_idx);
60553 }
60554
60555 reg_temp = DUK__ALLOCTEMP(comp_ctx); /* alloc temp just in case, to update max temp */
60556 DUK__SETTEMP(comp_ctx, reg_temp);
60557 duk__expr_toforcedreg(comp_ctx, res, DUK__BP_COMMA /*rbp_flags*/, reg_temp /*forced_reg*/);
60558 DUK__SETTEMP(comp_ctx, reg_temp + 1);
60559
60560 num_values++;
60561 curr_idx++;
60562 require_comma = 1;
60563
60564 if (num_values >= max_init_values) {
60565 /* MPUTARR emitted by outer loop */
60566 break;
60567 }
60568 }
60569
60570 if (num_values > 0) {
60571 /* - A is a source register (it's not a write target, but used
60572 * to identify the target object) but can be shuffled.
60573 * - B cannot be shuffled normally because it identifies a range
60574 * of registers, the emitter has special handling for this
60575 * (the "no shuffle" flag must not be set).
60576 * - C is a non-register number and cannot be shuffled, but
60577 * never needs to be.
60578 */
60579 duk__emit_a_b_c(comp_ctx,
60583 (duk_regconst_t) reg_obj,
60584 (duk_regconst_t) temp_start,
60585 (duk_regconst_t) num_values);
60586 init_idx = start_idx + num_values;
60587
60588 /* num_values and temp_start reset at top of outer loop */
60589 }
60590 }
60591
60593 duk__advance(comp_ctx);
60594
60595 DUK_DDD(DUK_DDDPRINT("array literal done, curridx=%ld, initidx=%ld",
60596 (long) curr_idx, (long) init_idx));
60597
60598 /* trailing elisions? */
60599 if (curr_idx > init_idx) {
60600 /* yes, must set array length explicitly */
60601 DUK_DDD(DUK_DDDPRINT("array literal has trailing elisions which affect its length"));
60602 reg_temp = DUK__ALLOCTEMP(comp_ctx);
#define DUK__MAX_ARRAY_INIT_VALUES

◆ duk__nud_object_literal()

DUK_LOCAL_DECL void duk__nud_object_literal ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res )

Definition at line 60663 of file duktape-1.8.0/src/duktape.c.

60663 : getter/setter encountered twice"));
60664 return 1;
60665 }
60666 }
60667
60668 new_key_flags |= key_flags;
60669 DUK_DDD(DUK_DDDPRINT("setting/updating key %!T flags: 0x%08lx -> 0x%08lx",
60670 (duk_tval *) duk_get_tval(ctx, -1),
60671 (unsigned long) key_flags,
60672 (unsigned long) new_key_flags));
60673 duk_dup(ctx, -1);
60674 duk_push_int(ctx, new_key_flags); /* [ ... key_obj key key flags ] */
60675 duk_put_prop(ctx, -4); /* [ ... key_obj key ] */
60676
60677 return 0;
60678}
60679
60680DUK_LOCAL void duk__nud_object_literal(duk_compiler_ctx *comp_ctx, duk_ivalue *res) {
60681 duk_hthread *thr = comp_ctx->thr;
60682 duk_context *ctx = (duk_context *) thr;
60683 duk_reg_t reg_obj; /* result reg */
60684 duk_reg_t reg_key; /* temp reg for key literal */
60685 duk_reg_t reg_temp; /* temp reg */
60686 duk_reg_t temp_start; /* temp reg value for start of loop */
60687 duk_small_uint_t max_init_pairs; /* max # of key-value pairs initialized in one MPUTOBJ set */
60688 duk_small_uint_t num_pairs; /* number of pairs in current MPUTOBJ set */
60689 duk_bool_t first; /* first value: comma must not precede the value */
60690 duk_bool_t is_set, is_get; /* temps */
60691
60692 DUK_ASSERT(comp_ctx->prev_token.t == DUK_TOK_LCURLY);
60693
60694 max_init_pairs = DUK__MAX_OBJECT_INIT_PAIRS; /* XXX: depend on available temps? */
60695
60696 reg_obj = DUK__ALLOCTEMP(comp_ctx);
60697 duk__emit_extraop_b_c(comp_ctx,
60698 DUK_EXTRAOP_NEWOBJ | DUK__EMIT_FLAG_B_IS_TARGET,
60699 reg_obj,
60700 0); /* XXX: patch initial size afterwards? */
60701 temp_start = DUK__GETTEMP(comp_ctx);
60702
60703 /* temp object for tracking / detecting duplicate keys */
60704 duk_push_object(ctx);
60705
60706 /*
60707 * Emit initializers in sets of maximum max_init_pairs keys.
60708 * Setter/getter is handled separately and terminates the
60709 * current set of initializer values. Corner cases such as
60710 * single value initializers do not have special handling now.
60711 */
60712
60713 first = 1;
60714 for (;;) {
60715 num_pairs = 0;
60716 DUK__SETTEMP(comp_ctx, temp_start);
60717
60718 if (comp_ctx->curr_token.t == DUK_TOK_RCURLY) {
60719 break;
60720 }
60721
60722 for (;;) {
60723 /*
60724 * Three possible element formats:
60725 * 1) PropertyName : AssignmentExpression
60726 * 2) get PropertyName () { FunctionBody }
60727 * 3) set PropertyName ( PropertySetParameterList ) { FunctionBody }
60728 *
60729 * PropertyName can be IdentifierName (includes reserved words), a string
60730 * literal, or a number literal. Note that IdentifierName allows 'get' and
60731 * 'set' too, so we need to look ahead to the next token to distinguish:
60732 *
60733 * { get : 1 }
60734 *
60735 * and
60736 *
60737 * { get foo() { return 1 } }
60738 * { get get() { return 1 } } // 'get' as getter propertyname
60739 *
60740 * Finally, a trailing comma is allowed.
60741 *
60742 * Key name is coerced to string at compile time (and ends up as a
60743 * a string constant) even for numeric keys (e.g. "{1:'foo'}").
60744 * These could be emitted using e.g. LDINT, but that seems hardly
60745 * worth the effort and would increase code size.
60746 */
60747
60748 DUK_DDD(DUK_DDDPRINT("object literal inner loop, curr_token->t = %ld",
60749 (long) comp_ctx->curr_token.t));
60750
60751 if (comp_ctx->curr_token.t == DUK_TOK_RCURLY) {
60752 /* the outer loop will recheck and exit */
60753 break;
60754 }
60755 if (num_pairs >= max_init_pairs) {
60756 /* MPUTOBJ emitted by outer loop */
60757 break;
60758 }
60759
60760 if (first) {
60761 first = 0;
60762 } else {
60763 if (comp_ctx->curr_token.t != DUK_TOK_COMMA) {
60764 goto syntax_error;
60765 }
60766 duk__advance(comp_ctx);
60767 if (comp_ctx->curr_token.t == DUK_TOK_RCURLY) {
60768 /* trailing comma followed by rcurly */
60769 break;
60770 }
60771 }
60772
60773 /* advance to get one step of lookup */
60774 duk__advance(comp_ctx);
60775
60776 /* NOTE: "get" and "set" are not officially ReservedWords and the lexer
60777 * currently treats them always like ordinary identifiers (DUK_TOK_GET
60778 * and DUK_TOK_SET are unused). They need to be detected based on the
60779 * identifier string content.
60780 */
60781
60782 is_get = (comp_ctx->prev_token.t == DUK_TOK_IDENTIFIER &&
60783 comp_ctx->prev_token.str1 == DUK_HTHREAD_STRING_GET(thr));
60784 is_set = (comp_ctx->prev_token.t == DUK_TOK_IDENTIFIER &&
60785 comp_ctx->prev_token.str1 == DUK_HTHREAD_STRING_SET(thr));
60786 if ((is_get || is_set) && comp_ctx->curr_token.t != DUK_TOK_COLON) {
60787 /* getter/setter */
60788 duk_int_t fnum;
60789
60790 if (comp_ctx->curr_token.t_nores == DUK_TOK_IDENTIFIER ||
60791 comp_ctx->curr_token.t_nores == DUK_TOK_STRING) {
60792 /* same handling for identifiers and strings */
60793 DUK_ASSERT(comp_ctx->curr_token.str1 != NULL);
60794 duk_push_hstring(ctx, comp_ctx->curr_token.str1);
60795 } else if (comp_ctx->curr_token.t == DUK_TOK_NUMBER) {
60796 duk_push_number(ctx, comp_ctx->curr_token.num);
60797 duk_to_string(ctx, -1);
60798 } else {
60799 goto syntax_error;
60800 }
60801
60802 DUK_ASSERT(duk_is_string(ctx, -1));
60803 if (duk__nud_object_literal_key_check(comp_ctx,
60804 (is_get ? DUK__OBJ_LIT_KEY_GET : DUK__OBJ_LIT_KEY_SET))) {
60805 goto syntax_error;
60806 }
60807 reg_key = duk__getconst(comp_ctx);
60808
60809 if (num_pairs > 0) {
60810 /* - A is a source register (it's not a write target, but used
60811 * to identify the target object) but can be shuffled.
60812 * - B cannot be shuffled normally because it identifies a range
60813 * of registers, the emitter has special handling for this
60814 * (the "no shuffle" flag must not be set).
60815 * - C is a non-register number and cannot be shuffled, but
60816 * never needs to be.
60817 */
60818 duk__emit_a_b_c(comp_ctx,
60819 DUK_OP_MPUTOBJ |
60820 DUK__EMIT_FLAG_NO_SHUFFLE_C |
60821 DUK__EMIT_FLAG_A_IS_SOURCE,
60822 reg_obj,
60823 temp_start,
60824 num_pairs);
60825 num_pairs = 0;
60826 DUK__SETTEMP(comp_ctx, temp_start);
60827 }
60828
60829 /* curr_token = get/set name */
60830 fnum = duk__parse_func_like_fnum(comp_ctx, 0 /*is_decl*/, 1 /*is_setget*/);
60831
60832 DUK_ASSERT(DUK__GETTEMP(comp_ctx) == temp_start);
60833 reg_temp = DUK__ALLOCTEMP(comp_ctx);
60834 duk__emit_a_bc(comp_ctx,
60835 DUK_OP_LDCONST,
60836 (duk_regconst_t) reg_temp,
60837 (duk_regconst_t) reg_key);
60838 reg_temp = DUK__ALLOCTEMP(comp_ctx);
60839 duk__emit_a_bc(comp_ctx,
60840 DUK_OP_CLOSURE,
60841 (duk_regconst_t) reg_temp,
60842 (duk_regconst_t) fnum);
60843
60844 /* Slot C is used in a non-standard fashion (range of regs),
60845 * emitter code has special handling for it (must not set the
60846 * "no shuffle" flag).
60847 */
60848 duk__emit_extraop_b_c(comp_ctx,
60849 (is_get ? DUK_EXTRAOP_INITGET : DUK_EXTRAOP_INITSET),
60850 reg_obj,
60851 temp_start); /* temp_start+0 = key, temp_start+1 = closure */
60852
60853 DUK__SETTEMP(comp_ctx, temp_start);
60854 } else {
60855 /* normal key/value */
60856 if (comp_ctx->prev_token.t_nores == DUK_TOK_IDENTIFIER ||
60857 comp_ctx->prev_token.t_nores == DUK_TOK_STRING) {
60858 /* same handling for identifiers and strings */
60859 DUK_ASSERT(comp_ctx->prev_token.str1 != NULL);
60860 duk_push_hstring(ctx, comp_ctx->prev_token.str1);
60861 } else if (comp_ctx->prev_token.t == DUK_TOK_NUMBER) {
60862 duk_push_number(ctx, comp_ctx->prev_token.num);
60863 duk_to_string(ctx, -1);
60864 } else {
60865 goto syntax_error;
60866 }
60867
60868 DUK_ASSERT(duk_is_string(ctx, -1));
60869 if (duk__nud_object_literal_key_check(comp_ctx, DUK__OBJ_LIT_KEY_PLAIN)) {
60870 goto syntax_error;
60871 }
60872 reg_key = duk__getconst(comp_ctx);
60873
60874 reg_temp = DUK__ALLOCTEMP(comp_ctx);
60875 duk__emit_a_bc(comp_ctx,
60876 DUK_OP_LDCONST,
60877 (duk_regconst_t) reg_temp,
60878 (duk_regconst_t) reg_key);
60879 duk__advance_expect(comp_ctx, DUK_TOK_COLON);
60880
60881 reg_temp = DUK__ALLOCTEMP(comp_ctx); /* alloc temp just in case, to update max temp */
60882 DUK__SETTEMP(comp_ctx, reg_temp);
60883 duk__expr_toforcedreg(comp_ctx, res, DUK__BP_COMMA /*rbp_flags*/, reg_temp /*forced_reg*/);
60884 DUK__SETTEMP(comp_ctx, reg_temp + 1);
60885
60886 num_pairs++;
60887 }
60888 }
60889
60890 if (num_pairs > 0) {
60891 /* See MPUTOBJ comments above. */
60892 duk__emit_a_b_c(comp_ctx,
60893 DUK_OP_MPUTOBJ |
60894 DUK__EMIT_FLAG_NO_SHUFFLE_C |
60895 DUK__EMIT_FLAG_A_IS_SOURCE,
60896 reg_obj,
60897 temp_start,
60898 num_pairs);
60899
60900 /* num_pairs and temp_start reset at top of outer loop */
60901 }
60902 }
60903

◆ duk__nud_object_literal_key_check()

DUK_LOCAL_DECL duk_bool_t duk__nud_object_literal_key_check ( duk_compiler_ctx * comp_ctx,
duk_small_uint_t new_key_flags )

Definition at line 60605 of file duktape-1.8.0/src/duktape.c.

60617 :
60619}
60620
60621/* duplicate/invalid key checks; returns 1 if syntax error */
60623 duk_hthread *thr = comp_ctx->thr;
60624 duk_context *ctx = (duk_context *) thr;
60625 duk_small_uint_t key_flags;
60626
60627 /* [ ... key_obj key ] */
60628
60629 DUK_ASSERT(duk_is_string(ctx, -1));
60630
60631 /*
60632 * 'key_obj' tracks keys encountered so far by associating an
60633 * integer with flags with already encountered keys. The checks
60634 * below implement E5 Section 11.1.5, step 4 for production:
60635 *
60636 * PropertyNameAndValueList: PropertyNameAndValueList , PropertyAssignment
60637 */
60638
60639 duk_dup(ctx, -1); /* [ ... key_obj key key ] */
60640 duk_get_prop(ctx, -3); /* [ ... key_obj key val ] */
60641 key_flags = duk_to_int(ctx, -1);
60642 duk_pop(ctx); /* [ ... key_obj key ] */
60643
60644 if (new_key_flags & DUK__OBJ_LIT_KEY_PLAIN) {
60645 if ((key_flags & DUK__OBJ_LIT_KEY_PLAIN) && comp_ctx->curr_func.is_strict) {
60646 /* step 4.a */
60647 DUK_DDD(DUK_DDDPRINT("duplicate key: plain key appears twice in strict mode"));
60648 return 1;
60649 }
60650 if (key_flags & (DUK__OBJ_LIT_KEY_GET | DUK__OBJ_LIT_KEY_SET)) {
60651 /* step 4.c */
60652 DUK_DDD(DUK_DDDPRINT("duplicate key: plain key encountered after setter/getter"));
60653 return 1;
60654 }
60655 } else {
60656 if (key_flags & DUK__OBJ_LIT_KEY_PLAIN) {
60657 /* step 4.b */
60658 DUK_DDD(DUK_DDDPRINT("duplicate key: getter/setter encountered after plain key"));
60659 return 1;
60660 }
60661 if (key_flags & new_key_flags) {
#define DUK__OBJ_LIT_KEY_PLAIN
#define DUK__OBJ_LIT_KEY_GET
DUK_LOCAL_DECL duk_bool_t duk__nud_object_literal_key_check(duk_compiler_ctx *comp_ctx, duk_small_uint_t new_key_flags)
#define DUK_STR_INVALID_ARRAY_LITERAL
#define DUK__OBJ_LIT_KEY_SET

◆ duk__obj_flag_any_default_false()

DUK_LOCAL duk_bool_t duk__obj_flag_any_default_false ( duk_context * ctx,
duk_idx_t index,
duk_uint_t flag_mask )

Definition at line 17601 of file duktape-1.8.0/src/duktape.c.

17608 {
17609 duk_tval *tv;
17610
17611 tv = duk_get_tval(ctx, index);

◆ duk__parse_arguments()

DUK_LOCAL_DECL duk_int_t duk__parse_arguments ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res )

Definition at line 60909 of file duktape-1.8.0/src/duktape.c.

60913 : %!T",
60914 (duk_tval *) duk_get_tval(ctx, -1)));
60915 duk_pop(ctx);
60916 return;
60917
60918 syntax_error:
60919 DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_OBJECT_LITERAL);
60920}
60921
60922/* Parse argument list. Arguments are written to temps starting from
60923 * "next temp". Returns number of arguments parsed. Expects left paren
60924 * to be already eaten, and eats the right paren before returning.
60925 */
60926DUK_LOCAL duk_int_t duk__parse_arguments(duk_compiler_ctx *comp_ctx, duk_ivalue *res) {
60927 duk_int_t nargs = 0;
60928 duk_reg_t reg_temp;
60929
60930 /* Note: expect that caller has already eaten the left paren */
60931
60932 DUK_DDD(DUK_DDDPRINT("start parsing arguments, prev_token.t=%ld, curr_token.t=%ld",
60933 (long) comp_ctx->prev_token.t, (long) comp_ctx->curr_token.t));
60934
60935 for (;;) {
60936 if (comp_ctx->curr_token.t == DUK_TOK_RPAREN) {
60937 break;
60938 }
60939 if (nargs > 0) {
60940 duk__advance_expect(comp_ctx, DUK_TOK_COMMA);
60941 }
60942
60943 /* We want the argument expression value to go to "next temp"
60944 * without additional moves. That should almost always be the
60945 * case, but we double check after expression parsing.
60946 *
60947 * This is not the cleanest possible approach.
60948 */
60949
60950 reg_temp = DUK__ALLOCTEMP(comp_ctx); /* bump up "allocated" reg count, just in case */
60951 DUK__SETTEMP(comp_ctx, reg_temp);

◆ duk__parse_break_or_continue_stmt()

DUK_LOCAL_DECL void duk__parse_break_or_continue_stmt ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res )

Definition at line 63447 of file duktape-1.8.0/src/duktape.c.

63464 {
63465 duk_hthread *thr = comp_ctx->thr;
63466 duk_bool_t is_break = (comp_ctx->curr_token.t == DUK_TOK_BREAK);
63467 duk_int_t label_id;
63468 duk_int_t label_catch_depth;
63469 duk_int_t label_pc; /* points to LABEL; pc+1 = jump site for break; pc+2 = jump site for continue */
63470 duk_bool_t label_is_closest;
63471
63472 DUK_UNREF(res);
63473
63474 duk__advance(comp_ctx); /* eat 'break' or 'continue' */
63475
63476 if (comp_ctx->curr_token.t == DUK_TOK_SEMICOLON || /* explicit semi follows */
63477 comp_ctx->curr_token.lineterm || /* automatic semi will be inserted */
63478 comp_ctx->curr_token.allow_auto_semi) { /* automatic semi will be inserted */
63479 /* break/continue without label */
63480
63481 duk__lookup_active_label(comp_ctx, DUK_HTHREAD_STRING_EMPTY_STRING(thr), is_break, &label_id, &label_catch_depth, &label_pc, &label_is_closest);
63482 } else if (comp_ctx->curr_token.t == DUK_TOK_IDENTIFIER) {
63483 /* break/continue with label (label cannot be a reserved word, production is 'Identifier' */
63484 DUK_ASSERT(comp_ctx->curr_token.str1 != NULL);
63485 duk__lookup_active_label(comp_ctx, comp_ctx->curr_token.str1, is_break, &label_id, &label_catch_depth, &label_pc, &label_is_closest);
63486 duk__advance(comp_ctx);
63487 } else {
63489 }
63490
63491 /* Use a fast break/continue when possible. A fast break/continue is
63492 * just a jump to the LABEL break/continue jump slot, which then jumps
63493 * to an appropriate place (for break, going through ENDLABEL correctly).
63494 * The peephole optimizer will optimize the jump to a direct one.
63495 */
63496
63497 if (label_catch_depth == comp_ctx->curr_func.catch_depth &&
63498 label_is_closest) {
63499 DUK_DDD(DUK_DDDPRINT("break/continue: is_break=%ld, label_id=%ld, label_is_closest=%ld, "
63500 "label_catch_depth=%ld, catch_depth=%ld "
DUK_LOCAL_DECL void duk__lookup_active_label(duk_compiler_ctx *comp_ctx, duk_hstring *h_label, duk_bool_t is_break, duk_int_t *out_label_id, duk_int_t *out_label_catch_depth, duk_int_t *out_label_pc, duk_bool_t *out_is_closest)
#define DUK_TOK_BREAK
#define DUK_STR_INVALID_BREAK_CONT_LABEL

◆ duk__parse_disjunction()

DUK_LOCAL void duk__parse_disjunction ( duk_re_compiler_ctx * re_ctx,
duk_bool_t expect_eof,
duk__re_disjunction_info * out_atom_info )

Definition at line 77939 of file duktape-1.8.0/src/duktape.c.

77956 {
77957 duk_int32_t atom_start_offset = -1; /* negative -> no atom matched on previous round */
77958 duk_int32_t atom_char_length = 0; /* negative -> complex atom */
77959 duk_uint32_t atom_start_captures = re_ctx->captures; /* value of re_ctx->captures at start of atom */
77960 duk_int32_t unpatched_disjunction_split = -1;
77961 duk_int32_t unpatched_disjunction_jump = -1;
77962 duk_uint32_t entry_offset = (duk_uint32_t) DUK__RE_BUFLEN(re_ctx);
77963 duk_int32_t res_charlen = 0; /* -1 if disjunction is complex, char length if simple */
77964 duk__re_disjunction_info tmp_disj;
77965
77966 DUK_ASSERT(out_atom_info != NULL);
77967
77968 if (re_ctx->recursion_depth >= re_ctx->recursion_limit) {
77970 }
77971 re_ctx->recursion_depth++;
77972
77973#if 0
77974 out_atom_info->start_captures = re_ctx->captures;
77975#endif
77976
77977 for (;;) {
77978 /* atom_char_length, atom_start_offset, atom_start_offset reflect the
77979 * atom matched on the previous loop. If a quantifier is encountered
77980 * on this loop, these are needed to handle the quantifier correctly.
77981 * new_atom_char_length etc are for the atom parsed on this round;
77982 * they're written to atom_char_length etc at the end of the round.
77983 */
77984 duk_int32_t new_atom_char_length; /* char length of the atom parsed in this loop */
77985 duk_int32_t new_atom_start_offset; /* bytecode start offset of the atom parsed in this loop
77986 * (allows quantifiers to copy the atom bytecode)
77987 */
77988 duk_uint32_t new_atom_start_captures; /* re_ctx->captures at the start of the atom parsed in this loop */
77989
77990 duk_lexer_parse_re_token(&re_ctx->lex, &re_ctx->curr_token);
77991
77992 DUK_DD(DUK_DDPRINT("re token: %ld (num=%ld, char=%c)",
77993 (long) re_ctx->curr_token.t,
77994 (long) re_ctx->curr_token.num,
77995 (re_ctx->curr_token.num >= 0x20 && re_ctx->curr_token.num <= 0x7e) ?
77996 (int) re_ctx->curr_token.num : (int) '?'));
77997
77998 /* set by atom case clauses */
77999 new_atom_start_offset = -1;
78000 new_atom_char_length = -1;
78001 new_atom_start_captures = re_ctx->captures;
78002
78003 switch (re_ctx->curr_token.t) {
78004 case DUK_RETOK_DISJUNCTION: {
78005 /*
78006 * The handling here is a bit tricky. If a previous '|' has been processed,
78007 * we have a pending split1 and a pending jump (for a previous match). These
78008 * need to be back-patched carefully. See docs for a detailed example.
78009 */
78010
78011 /* patch pending jump and split */
78012 if (unpatched_disjunction_jump >= 0) {
78013 duk_uint32_t offset;
78014
78015 DUK_ASSERT(unpatched_disjunction_split >= 0);
78016 offset = unpatched_disjunction_jump;
78017 offset += duk__insert_jump_offset(re_ctx,
78018 offset,
78019 (duk_int32_t) (DUK__RE_BUFLEN(re_ctx) - offset));
78020 /* offset is now target of the pending split (right after jump) */
78022 unpatched_disjunction_split,
78023 offset - unpatched_disjunction_split);
78024 }
78025
78026 /* add a new pending split to the beginning of the entire disjunction */
78027 (void) duk__insert_u32(re_ctx,
78028 entry_offset,
78029 DUK_REOP_SPLIT1); /* prefer direct execution */
78030 unpatched_disjunction_split = entry_offset + 1; /* +1 for opcode */
78031
78032 /* add a new pending match jump for latest finished alternative */
78034 unpatched_disjunction_jump = (duk_int32_t) DUK__RE_BUFLEN(re_ctx);
78035
78036 /* 'taint' result as complex */
78037 res_charlen = -1;
78038 break;
78039 }
78040 case DUK_RETOK_QUANTIFIER: {
78041 if (atom_start_offset < 0) {
78043 }
78044 if (re_ctx->curr_token.qmin > re_ctx->curr_token.qmax) {
78046 }
78047 if (atom_char_length >= 0) {
78048 /*
78049 * Simple atom
78050 *
78051 * If atom_char_length is zero, we'll have unbounded execution time for e.g.
78052 * /()*x/.exec('x'). We can't just skip the match because it might have some
78053 * side effects (for instance, if we allowed captures in simple atoms, the
78054 * capture needs to happen). The simple solution below is to force the
78055 * quantifier to match at most once, since the additional matches have no effect.
78056 *
78057 * With a simple atom there can be no capture groups, so no captures need
78058 * to be reset.
78059 */
78060 duk_int32_t atom_code_length;
78061 duk_uint32_t offset;
78062 duk_uint32_t qmin, qmax;
78063
78064 qmin = re_ctx->curr_token.qmin;
78065 qmax = re_ctx->curr_token.qmax;
78066 if (atom_char_length == 0) {
78067 /* qmin and qmax will be 0 or 1 */
78068 if (qmin > 1) {
78069 qmin = 1;
78070 }
78071 if (qmax > 1) {
78072 qmax = 1;
78073 }
78074 }
78075
78076 duk__append_u32(re_ctx, DUK_REOP_MATCH); /* complete 'sub atom' */
78077 atom_code_length = (duk_int32_t) (DUK__RE_BUFLEN(re_ctx) - atom_start_offset);
78078
78079 offset = atom_start_offset;
78080 if (re_ctx->curr_token.greedy) {
78081 offset += duk__insert_u32(re_ctx, offset, DUK_REOP_SQGREEDY);
78082 offset += duk__insert_u32(re_ctx, offset, qmin);
78083 offset += duk__insert_u32(re_ctx, offset, qmax);
78084 offset += duk__insert_u32(re_ctx, offset, atom_char_length);
78085 offset += duk__insert_jump_offset(re_ctx, offset, atom_code_length);
78086 } else {
78087 offset += duk__insert_u32(re_ctx, offset, DUK_REOP_SQMINIMAL);
78088 offset += duk__insert_u32(re_ctx, offset, qmin);
78089 offset += duk__insert_u32(re_ctx, offset, qmax);
78090 offset += duk__insert_jump_offset(re_ctx, offset, atom_code_length);
78091 }
78092 DUK_UNREF(offset); /* silence scan-build warning */
78093 } else {
78094 /*
78095 * Complex atom
78096 *
78097 * The original code is used as a template, and removed at the end
78098 * (this differs from the handling of simple quantifiers).
78099 *
78100 * NOTE: there is no current solution for empty atoms in complex
78101 * quantifiers. This would need some sort of a 'progress' instruction.
78102 *
78103 * XXX: impose limit on maximum result size, i.e. atom_code_len * atom_copies?
78104 */
78105 duk_int32_t atom_code_length;
78106 duk_uint32_t atom_copies;
78107 duk_uint32_t tmp_qmin, tmp_qmax;
78108
78109 /* pre-check how many atom copies we're willing to make (atom_copies not needed below) */
78110 atom_copies = (re_ctx->curr_token.qmax == DUK_RE_QUANTIFIER_INFINITE) ?
78111 re_ctx->curr_token.qmin : re_ctx->curr_token.qmax;
78112 if (atom_copies > DUK_RE_MAX_ATOM_COPIES) {
78114 }
78115
78116 /* wipe the capture range made by the atom (if any) */
78117 DUK_ASSERT(atom_start_captures <= re_ctx->captures);
78118 if (atom_start_captures != re_ctx->captures) {
78119 DUK_ASSERT(atom_start_captures < re_ctx->captures);
78120 DUK_DDD(DUK_DDDPRINT("must wipe ]atom_start_captures,re_ctx->captures]: ]%ld,%ld]",
78121 (long) atom_start_captures, (long) re_ctx->captures));
78122
78123 /* insert (DUK_REOP_WIPERANGE, start, count) in reverse order so the order ends up right */
78124 duk__insert_u32(re_ctx, atom_start_offset, (re_ctx->captures - atom_start_captures) * 2);
78125 duk__insert_u32(re_ctx, atom_start_offset, (atom_start_captures + 1) * 2);
78126 duk__insert_u32(re_ctx, atom_start_offset, DUK_REOP_WIPERANGE);
78127 } else {
78128 DUK_DDD(DUK_DDDPRINT("no need to wipe captures: atom_start_captures == re_ctx->captures == %ld",
78129 (long) atom_start_captures));
78130 }
78131
78132 atom_code_length = (duk_int32_t) DUK__RE_BUFLEN(re_ctx) - atom_start_offset;
78133
78134 /* insert the required matches (qmin) by copying the atom */
78135 tmp_qmin = re_ctx->curr_token.qmin;
78136 tmp_qmax = re_ctx->curr_token.qmax;
78137 while (tmp_qmin > 0) {
78138 duk__append_slice(re_ctx, atom_start_offset, atom_code_length);
78139 tmp_qmin--;
78140 if (tmp_qmax != DUK_RE_QUANTIFIER_INFINITE) {
78141 tmp_qmax--;
78142 }
78143 }
78144 DUK_ASSERT(tmp_qmin == 0);
78145
78146 /* insert code for matching the remainder - infinite or finite */
78147 if (tmp_qmax == DUK_RE_QUANTIFIER_INFINITE) {
78148 /* reuse last emitted atom for remaining 'infinite' quantifier */
78149
78150 if (re_ctx->curr_token.qmin == 0) {
78151 /* Special case: original qmin was zero so there is nothing
78152 * to repeat. Emit an atom copy but jump over it here.
78153 */
78155 duk__append_jump_offset(re_ctx, atom_code_length);
78156 duk__append_slice(re_ctx, atom_start_offset, atom_code_length);
78157 }
78158 if (re_ctx->curr_token.greedy) {
78159 duk__append_u32(re_ctx, DUK_REOP_SPLIT2); /* prefer jump */
78160 } else {
78161 duk__append_u32(re_ctx, DUK_REOP_SPLIT1); /* prefer direct */
78162 }
78163 duk__append_jump_offset(re_ctx, -atom_code_length - 1); /* -1 for opcode */
78164 } else {
78165 /*
78166 * The remaining matches are emitted as sequence of SPLITs and atom
78167 * copies; the SPLITs skip the remaining copies and match the sequel.
78168 * This sequence needs to be emitted starting from the last copy
78169 * because the SPLITs are variable length due to the variable length
78170 * skip offset. This causes a lot of memory copying now.
78171 *
78172 * Example structure (greedy, match maximum # atoms):
78173 *
78174 * SPLIT1 LSEQ
78175 * (atom)
78176 * SPLIT1 LSEQ ; <- the byte length of this instruction is needed
78177 * (atom) ; to encode the above SPLIT1 correctly
78178 * ...
78179 * LSEQ:
78180 */
78181 duk_uint32_t offset = (duk_uint32_t) DUK__RE_BUFLEN(re_ctx);
78182 while (tmp_qmax > 0) {
78183 duk__insert_slice(re_ctx, offset, atom_start_offset, atom_code_length);
78184 if (re_ctx->curr_token.greedy) {
78185 duk__insert_u32(re_ctx, offset, DUK_REOP_SPLIT1); /* prefer direct */
78186 } else {
78187 duk__insert_u32(re_ctx, offset, DUK_REOP_SPLIT2); /* prefer jump */
78188 }
78190 offset + 1, /* +1 for opcode */
78191 (duk_int32_t) (DUK__RE_BUFLEN(re_ctx) - (offset + 1)));
78192 tmp_qmax--;
78193 }
78194 }
78195
78196 /* remove the original 'template' atom */
78197 duk__remove_slice(re_ctx, atom_start_offset, atom_code_length);
78198 }
78199
78200 /* 'taint' result as complex */
78201 res_charlen = -1;
78202 break;
78203 }
78206 break;
78207 }
78208 case DUK_RETOK_ASSERT_END: {
78210 break;
78211 }
78214 break;
78215 }
78218 break;
78219 }
78222 duk_uint32_t offset;
78223 duk_uint32_t opcode = (re_ctx->curr_token.t == DUK_RETOK_ASSERT_START_POS_LOOKAHEAD) ?
78225
78226 offset = (duk_uint32_t) DUK__RE_BUFLEN(re_ctx);
78227 duk__parse_disjunction(re_ctx, 0, &tmp_disj);
78229
78230 (void) duk__insert_u32(re_ctx, offset, opcode);
78231 (void) duk__insert_jump_offset(re_ctx,
78232 offset + 1, /* +1 for opcode */
78233 (duk_int32_t) (DUK__RE_BUFLEN(re_ctx) - (offset + 1)));
78234
78235 /* 'taint' result as complex -- this is conservative,
78236 * as lookaheads do not backtrack.
78237 */
78238 res_charlen = -1;
78239 break;
78240 }
78241 case DUK_RETOK_ATOM_PERIOD: {
78242 new_atom_char_length = 1;
78243 new_atom_start_offset = (duk_int32_t) DUK__RE_BUFLEN(re_ctx);
78245 break;
78246 }
78247 case DUK_RETOK_ATOM_CHAR: {
78248 /* Note: successive characters could be joined into string matches
78249 * but this is not trivial (consider e.g. '/xyz+/); see docs for
78250 * more discussion.
78251 */
78252 duk_uint32_t ch;
78253
78254 new_atom_char_length = 1;
78255 new_atom_start_offset = (duk_int32_t) DUK__RE_BUFLEN(re_ctx);
78257 ch = re_ctx->curr_token.num;
78258 if (re_ctx->re_flags & DUK_RE_FLAG_IGNORE_CASE) {
78259 ch = duk_unicode_re_canonicalize_char(re_ctx->thr, ch);
78260 }
78261 duk__append_u32(re_ctx, ch);
78262 break;
78263 }
78266 new_atom_char_length = 1;
78267 new_atom_start_offset = (duk_int32_t) DUK__RE_BUFLEN(re_ctx);
78268 duk__append_u32(re_ctx,
78269 (re_ctx->curr_token.t == DUK_RETOK_ATOM_DIGIT) ?
78271 duk__append_u32(re_ctx, sizeof(duk_unicode_re_ranges_digit) / (2 * sizeof(duk_uint16_t)));
78272 duk__append_u16_list(re_ctx, duk_unicode_re_ranges_digit, sizeof(duk_unicode_re_ranges_digit) / sizeof(duk_uint16_t));
78273 break;
78274 }
78277 new_atom_char_length = 1;
78278 new_atom_start_offset = (duk_int32_t) DUK__RE_BUFLEN(re_ctx);
78279 duk__append_u32(re_ctx,
78280 (re_ctx->curr_token.t == DUK_RETOK_ATOM_WHITE) ?
78282 duk__append_u32(re_ctx, sizeof(duk_unicode_re_ranges_white) / (2 * sizeof(duk_uint16_t)));
78283 duk__append_u16_list(re_ctx, duk_unicode_re_ranges_white, sizeof(duk_unicode_re_ranges_white) / sizeof(duk_uint16_t));
78284 break;
78285 }
78288 new_atom_char_length = 1;
78289 new_atom_start_offset = (duk_int32_t) DUK__RE_BUFLEN(re_ctx);
78290 duk__append_u32(re_ctx,
78293 duk__append_u32(re_ctx, sizeof(duk_unicode_re_ranges_wordchar) / (2 * sizeof(duk_uint16_t)));
78295 break;
78296 }
78298 duk_uint32_t backref = (duk_uint32_t) re_ctx->curr_token.num;
78299 if (backref > re_ctx->highest_backref) {
78300 re_ctx->highest_backref = backref;
78301 }
78302 new_atom_char_length = -1; /* mark as complex */
78303 new_atom_start_offset = (duk_int32_t) DUK__RE_BUFLEN(re_ctx);
78305 duk__append_u32(re_ctx, backref);
78306 break;
78307 }
78309 duk_uint32_t cap;
78310
78311 new_atom_char_length = -1; /* mark as complex (capture handling) */
78312 new_atom_start_offset = (duk_int32_t) DUK__RE_BUFLEN(re_ctx);
78313 cap = ++re_ctx->captures;
78315 duk__append_u32(re_ctx, cap * 2);
78316 duk__parse_disjunction(re_ctx, 0, &tmp_disj); /* retval (sub-atom char length) unused, tainted as complex above */
78318 duk__append_u32(re_ctx, cap * 2 + 1);
78319 break;
78320 }
78322 new_atom_start_offset = (duk_int32_t) DUK__RE_BUFLEN(re_ctx);
78323 duk__parse_disjunction(re_ctx, 0, &tmp_disj);
78324 new_atom_char_length = tmp_disj.charlen;
78325 break;
78326 }
78329 /*
78330 * Range parsing is done with a special lexer function which calls
78331 * us for every range parsed. This is different from how rest of
78332 * the parsing works, but avoids a heavy, arbitrary size intermediate
78333 * value type to hold the ranges.
78334 *
78335 * Another complication is the handling of character ranges when
78336 * case insensitive matching is used (see docs for discussion).
78337 * The range handler callback given to the lexer takes care of this
78338 * as well.
78339 *
78340 * Note that duplicate ranges are not eliminated when parsing character
78341 * classes, so that canonicalization of
78342 *
78343 * [0-9a-fA-Fx-{]
78344 *
78345 * creates the result (note the duplicate ranges):
78346 *
78347 * [0-9A-FA-FX-Z{-{]
78348 *
78349 * where [x-{] is split as a result of canonicalization. The duplicate
78350 * ranges are not a semantics issue: they work correctly.
78351 */
78352
78353 duk_uint32_t offset;
78354
78355 DUK_DD(DUK_DDPRINT("character class"));
78356
78357 /* insert ranges instruction, range count patched in later */
78358 new_atom_char_length = 1;
78359 new_atom_start_offset = (duk_int32_t) DUK__RE_BUFLEN(re_ctx);
78360 duk__append_u32(re_ctx,
78363 offset = (duk_uint32_t) DUK__RE_BUFLEN(re_ctx); /* patch in range count later */
78364
78365 /* parse ranges until character class ends */
78366 re_ctx->nranges = 0; /* note: ctx-wide temporary */
78367 duk_lexer_parse_re_ranges(&re_ctx->lex, duk__generate_ranges, (void *) re_ctx);
78368
78369 /* insert range count */
78370 duk__insert_u32(re_ctx, offset, re_ctx->nranges);
78371 break;
78372 }
78374 if (expect_eof) {
78376 }
78377 goto done;
78378 }
78379 case DUK_RETOK_EOF: {
78380 if (!expect_eof) {
78382 }
78383 goto done;
78384 }
78385 default: {
78387 }
78388 }
78389
78390 /* a complex (new) atom taints the result */
78391 if (new_atom_start_offset >= 0) {
78392 if (new_atom_char_length < 0) {
78393 res_charlen = -1;
78394 } else if (res_charlen >= 0) {
78395 /* only advance if not tainted */
78396 res_charlen += new_atom_char_length;
78397 }
78398 }
78399
78400 /* record previous atom info in case next token is a quantifier */
78401 atom_start_offset = new_atom_start_offset;
78402 atom_char_length = new_atom_char_length;
78403 atom_start_captures = new_atom_start_captures;
78404 }
78405
78406 done:
78407
78408 /* finish up pending jump and split for last alternative */
78409 if (unpatched_disjunction_jump >= 0) {
78410 duk_uint32_t offset;
78411
78412 DUK_ASSERT(unpatched_disjunction_split >= 0);
78413 offset = unpatched_disjunction_jump;
78414 offset += duk__insert_jump_offset(re_ctx,
#define DUK_RETOK_DISJUNCTION
DUK_LOCAL duk_uint32_t duk__append_jump_offset(duk_re_compiler_ctx *re_ctx, duk_int32_t skip)
DUK_LOCAL void duk__remove_slice(duk_re_compiler_ctx *re_ctx, duk_uint32_t data_offset, duk_uint32_t data_length)
#define DUK_RETOK_ATOM_PERIOD
#define DUK_RETOK_EOF
#define DUK_RETOK_ATOM_WORD_CHAR
#define DUK_RETOK_ATOM_START_CHARCLASS
#define DUK_STR_INVALID_QUANTIFIER_NO_ATOM
#define DUK_STR_UNEXPECTED_REGEXP_TOKEN
DUK_LOCAL duk_uint32_t duk__insert_jump_offset(duk_re_compiler_ctx *re_ctx, duk_uint32_t offset, duk_int32_t skip)
DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_digit[2]
#define DUK_RETOK_ATOM_START_CHARCLASS_INVERTED
#define DUK_STR_UNEXPECTED_END_OF_PATTERN
#define DUK_RETOK_ATOM_DIGIT
#define DUK_RETOK_ATOM_END_GROUP
DUK_LOCAL void duk__append_slice(duk_re_compiler_ctx *re_ctx, duk_uint32_t data_offset, duk_uint32_t data_length)
#define DUK_RETOK_ATOM_NOT_WHITE
#define DUK_RETOK_ASSERT_WORD_BOUNDARY
#define DUK_RETOK_ATOM_NOT_WORD_CHAR
#define DUK_RETOK_ATOM_START_CAPTURE_GROUP
#define DUK_RETOK_ASSERT_START
DUK_LOCAL void duk__insert_slice(duk_re_compiler_ctx *re_ctx, duk_uint32_t offset, duk_uint32_t data_offset, duk_uint32_t data_length)
#define DUK_STR_INVALID_QUANTIFIER_VALUES
#define DUK_RETOK_ASSERT_START_POS_LOOKAHEAD
#define DUK_RETOK_ATOM_NOT_DIGIT
DUK_INTERNAL_DECL void duk_lexer_parse_re_token(duk_lexer_ctx *lex_ctx, duk_re_token *out_token)
DUK_LOCAL void duk__parse_disjunction(duk_re_compiler_ctx *re_ctx, duk_bool_t expect_eof, duk__re_disjunction_info *out_atom_info)
#define DUK_RETOK_QUANTIFIER
DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_wordchar[8]
#define DUK_RE_QUANTIFIER_INFINITE
#define DUK_RETOK_ATOM_START_NONCAPTURE_GROUP
#define DUK_RETOK_ATOM_WHITE
#define DUK_STR_REGEXP_COMPILER_RECURSION_LIMIT
DUK_LOCAL void duk__append_u16_list(duk_re_compiler_ctx *re_ctx, const duk_uint16_t *values, duk_uint32_t count)
#define DUK_RETOK_ASSERT_END
#define DUK_RETOK_ATOM_BACKREFERENCE
#define DUK_RETOK_ASSERT_START_NEG_LOOKAHEAD
#define DUK_RE_MAX_ATOM_COPIES
#define DUK_STR_UNEXPECTED_CLOSING_PAREN
DUK_LOCAL duk_uint32_t duk__insert_u32(duk_re_compiler_ctx *re_ctx, duk_uint32_t offset, duk_uint32_t x)
#define DUK_RETOK_ASSERT_NOT_WORD_BOUNDARY
#define DUK__RE_BUFLEN(re_ctx)
#define DUK_STR_QUANTIFIER_TOO_MANY_COPIES
DUK_INTERNAL_DECL void duk_lexer_parse_re_ranges(duk_lexer_ctx *lex_ctx, duk_re_range_callback gen_range, void *userdata)
#define DUK_RETOK_ATOM_CHAR
DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_white[22]

References duk_re_compiler_ctx::captures, duk__re_disjunction_info::charlen, duk_re_compiler_ctx::curr_token, duk__append_jump_offset(), duk__append_slice(), duk__append_u16_list(), duk__append_u32(), duk__generate_ranges(), duk__insert_jump_offset(), duk__insert_slice(), duk__insert_u32(), duk__parse_disjunction(), DUK__RE_BUFLEN, duk__remove_slice(), DUK_ASSERT, DUK_DD, DUK_DDD, DUK_DDDPRINT, DUK_DDPRINT, DUK_ERROR_RANGE, DUK_ERROR_SYNTAX, duk_lexer_parse_re_ranges(), duk_lexer_parse_re_token(), DUK_RE_FLAG_IGNORE_CASE, DUK_RE_MAX_ATOM_COPIES, DUK_RE_QUANTIFIER_INFINITE, DUK_REOP_ASSERT_END, DUK_REOP_ASSERT_NOT_WORD_BOUNDARY, DUK_REOP_ASSERT_START, DUK_REOP_ASSERT_WORD_BOUNDARY, DUK_REOP_BACKREFERENCE, DUK_REOP_CHAR, DUK_REOP_INVRANGES, DUK_REOP_JUMP, DUK_REOP_LOOKNEG, DUK_REOP_LOOKPOS, DUK_REOP_MATCH, DUK_REOP_PERIOD, DUK_REOP_RANGES, DUK_REOP_SAVE, DUK_REOP_SPLIT1, DUK_REOP_SPLIT2, DUK_REOP_SQGREEDY, DUK_REOP_SQMINIMAL, DUK_REOP_WIPERANGE, DUK_RETOK_ASSERT_END, DUK_RETOK_ASSERT_NOT_WORD_BOUNDARY, DUK_RETOK_ASSERT_START, DUK_RETOK_ASSERT_START_NEG_LOOKAHEAD, DUK_RETOK_ASSERT_START_POS_LOOKAHEAD, DUK_RETOK_ASSERT_WORD_BOUNDARY, DUK_RETOK_ATOM_BACKREFERENCE, DUK_RETOK_ATOM_CHAR, DUK_RETOK_ATOM_DIGIT, DUK_RETOK_ATOM_END_GROUP, DUK_RETOK_ATOM_NOT_DIGIT, DUK_RETOK_ATOM_NOT_WHITE, DUK_RETOK_ATOM_NOT_WORD_CHAR, DUK_RETOK_ATOM_PERIOD, DUK_RETOK_ATOM_START_CAPTURE_GROUP, DUK_RETOK_ATOM_START_CHARCLASS, DUK_RETOK_ATOM_START_CHARCLASS_INVERTED, DUK_RETOK_ATOM_START_NONCAPTURE_GROUP, DUK_RETOK_ATOM_WHITE, DUK_RETOK_ATOM_WORD_CHAR, DUK_RETOK_DISJUNCTION, DUK_RETOK_EOF, DUK_RETOK_QUANTIFIER, DUK_STR_INVALID_QUANTIFIER_NO_ATOM, DUK_STR_INVALID_QUANTIFIER_VALUES, DUK_STR_QUANTIFIER_TOO_MANY_COPIES, DUK_STR_REGEXP_COMPILER_RECURSION_LIMIT, DUK_STR_UNEXPECTED_CLOSING_PAREN, DUK_STR_UNEXPECTED_END_OF_PATTERN, DUK_STR_UNEXPECTED_REGEXP_TOKEN, duk_unicode_re_canonicalize_char(), duk_unicode_re_ranges_digit, duk_unicode_re_ranges_white, duk_unicode_re_ranges_wordchar, DUK_UNREF, duk_re_token::greedy, duk_re_compiler_ctx::highest_backref, duk_re_compiler_ctx::lex, duk_re_compiler_ctx::nranges, NULL, duk_re_token::num, duk_re_token::qmax, duk_re_token::qmin, duk_re_compiler_ctx::re_flags, duk_re_compiler_ctx::recursion_depth, duk_re_compiler_ctx::recursion_limit, duk_re_token::t, and duk_re_compiler_ctx::thr.

Referenced by duk__parse_disjunction().

◆ duk__parse_do_stmt()

DUK_LOCAL_DECL void duk__parse_do_stmt ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res,
duk_int_t pc_label_site )

Definition at line 63387 of file duktape-1.8.0/src/duktape.c.

63395 {
63396 DUK_DDD(DUK_DDDPRINT("if does not have else part"));
63397
63398 duk__patch_jump_here(comp_ctx, pc_jump_false);
63399 }
63400
63401 DUK_DDD(DUK_DDDPRINT("end parsing if statement"));
63402}
63403
63404DUK_LOCAL void duk__parse_do_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site) {
63405 duk_regconst_t rc_cond;
63406 duk_int_t pc_start;
63407
63408 DUK_DDD(DUK_DDDPRINT("begin parsing do statement"));
63409
63410 duk__advance(comp_ctx); /* eat 'do' */
63411
63412 pc_start = duk__get_current_pc(comp_ctx);
DUK_LOCAL_DECL void duk__parse_do_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site)

◆ duk__parse_for_stmt()

DUK_LOCAL_DECL void duk__parse_for_stmt ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res,
duk_int_t pc_label_site )

Definition at line 62786 of file duktape-1.8.0/src/duktape.c.

62786 {
62787 duk_reg_t reg_varbind;
62788 duk_regconst_t rc_varname;
62789
62790 duk__advance(comp_ctx); /* eat 'var' */
62791
62792 for (;;) {
62793 /* rc_varname and reg_varbind are ignored here */
62794 duk__parse_var_decl(comp_ctx, res, 0 | expr_flags, &reg_varbind, &rc_varname);
62795
62796 if (comp_ctx->curr_token.t != DUK_TOK_COMMA) {
62797 break;
62798 }
62799 duk__advance(comp_ctx);
62800 }
62801}
62802
62803DUK_LOCAL void duk__parse_for_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site) {
62804 duk_hthread *thr = comp_ctx->thr;
62805 duk_context *ctx = (duk_context *) thr;
62806 duk_int_t pc_v34_lhs; /* start variant 3/4 left-hand-side code (L1 in doc/compiler.rst example) */
62807 duk_reg_t temp_reset; /* knock back "next temp" to this whenever possible */
62808 duk_reg_t reg_temps; /* preallocated temporaries (2) for variants 3 and 4 */
62809
62810 DUK_DDD(DUK_DDDPRINT("start parsing a for/for-in statement"));
62811
62812 /* Two temporaries are preallocated here for variants 3 and 4 which need
62813 * registers which are never clobbered by expressions in the loop
62814 * (concretely: for the enumerator object and the next enumerated value).
62815 * Variants 1 and 2 "release" these temps.
62816 */
62817
62818 reg_temps = DUK__ALLOCTEMPS(comp_ctx, 2);
62819
62820 temp_reset = DUK__GETTEMP(comp_ctx);
62821
62822 /*
62823 * For/for-in main variants are:
62824 *
62825 * 1. for (ExpressionNoIn_opt; Expression_opt; Expression_opt) Statement
62826 * 2. for (var VariableDeclarationNoIn; Expression_opt; Expression_opt) Statement
62827 * 3. for (LeftHandSideExpression in Expression) Statement
62828 * 4. for (var VariableDeclarationNoIn in Expression) Statement
62829 *
62830 * Parsing these without arbitrary lookahead or backtracking is relatively
62831 * tricky but we manage to do so for now.
62832 *
62833 * See doc/compiler.rst for a detailed discussion of control flow
62834 * issues, evaluation order issues, etc.
62835 */
62836
62837 duk__advance(comp_ctx); /* eat 'for' */
62839
62840 DUK_DDD(DUK_DDDPRINT("detecting for/for-in loop variant, pc=%ld", (long) duk__get_current_pc(comp_ctx)));
62841
62842 /* a label site has been emitted by duk__parse_stmt() automatically
62843 * (it will also emit the ENDLABEL).
62844 */
62845
62846 if (comp_ctx->curr_token.t == DUK_TOK_VAR) {
62847 /*
62848 * Variant 2 or 4
62849 */
62850
62851 duk_reg_t reg_varbind; /* variable binding register if register-bound (otherwise < 0) */
62852 duk_regconst_t rc_varname; /* variable name reg/const, if variable not register-bound */
62853
62854 duk__advance(comp_ctx); /* eat 'var' */
62855 duk__parse_var_decl(comp_ctx, res, DUK__EXPR_FLAG_REJECT_IN, &reg_varbind, &rc_varname);
62856 DUK__SETTEMP(comp_ctx, temp_reset);
62857
62858 if (comp_ctx->curr_token.t == DUK_TOK_IN) {
62859 /*
62860 * Variant 4
62861 */
62862
62863 DUK_DDD(DUK_DDDPRINT("detected for variant 4: for (var VariableDeclarationNoIn in Expression) Statement"));
62864 pc_v34_lhs = duk__get_current_pc(comp_ctx); /* jump is inserted here */
62865 if (reg_varbind >= 0) {
62866 duk__emit_a_bc(comp_ctx,
62868 (duk_regconst_t) reg_varbind,
62869 (duk_regconst_t) (reg_temps + 0));
62870 } else {
62871 duk__emit_a_bc(comp_ctx,
62873 (duk_regconst_t) (reg_temps + 0),
62874 rc_varname);
62875 }
62876 goto parse_3_or_4;
62877 } else {
62878 /*
62879 * Variant 2
62880 */
62881
62882 DUK_DDD(DUK_DDDPRINT("detected for variant 2: for (var VariableDeclarationNoIn; Expression_opt; Expression_opt) Statement"));
62883 for (;;) {
62884 /* more initializers */
62885 if (comp_ctx->curr_token.t != DUK_TOK_COMMA) {
62886 break;
62887 }
62888 DUK_DDD(DUK_DDDPRINT("variant 2 has another variable initializer"));
62889
62890 duk__advance(comp_ctx); /* eat comma */
62891 duk__parse_var_decl(comp_ctx, res, DUK__EXPR_FLAG_REJECT_IN, &reg_varbind, &rc_varname);
62892 }
62893 goto parse_1_or_2;
62894 }
62895 } else {
62896 /*
62897 * Variant 1 or 3
62898 */
62899
62900 pc_v34_lhs = duk__get_current_pc(comp_ctx); /* jump is inserted here (variant 3) */
62901
62902 /* Note that duk__exprtop() here can clobber any reg above current temp_next,
62903 * so any loop variables (e.g. enumerator) must be "preallocated".
62904 */
62905
62906 /* don't coerce yet to a plain value (variant 3 needs special handling) */
62907 duk__exprtop(comp_ctx, res, DUK__BP_FOR_EXPR | DUK__EXPR_FLAG_REJECT_IN | DUK__EXPR_FLAG_ALLOW_EMPTY /*rbp_flags*/); /* Expression */
62908 if (comp_ctx->curr_token.t == DUK_TOK_IN) {
62909 /*
62910 * Variant 3
62911 */
62912
62913 /* XXX: need to determine LHS type, and check that it is LHS compatible */
62914 DUK_DDD(DUK_DDDPRINT("detected for variant 3: for (LeftHandSideExpression in Expression) Statement"));
62915 if (duk__expr_is_empty(comp_ctx)) {
62916 goto syntax_error; /* LeftHandSideExpression does not allow empty expression */
62917 }
62918
62919 if (res->t == DUK_IVAL_VAR) {
62920 duk_reg_t reg_varbind;
62921 duk_regconst_t rc_varname;
62922
62923 duk_dup(ctx, res->x1.valstack_idx);
62924 if (duk__lookup_lhs(comp_ctx, &reg_varbind, &rc_varname)) {
62925 duk__emit_a_bc(comp_ctx,
62927 (duk_regconst_t) reg_varbind,
62928 (duk_regconst_t) (reg_temps + 0));
62929 } else {
62930 duk__emit_a_bc(comp_ctx,
62932 (duk_regconst_t) (reg_temps + 0),
62933 rc_varname);
62934 }
62935 } else if (res->t == DUK_IVAL_PROP) {
62936 /* Don't allow a constant for the object (even for a number etc), as
62937 * it goes into the 'A' field of the opcode.
62938 */
62939 duk_reg_t reg_obj;
62940 duk_regconst_t rc_key;
62941 reg_obj = duk__ispec_toregconst_raw(comp_ctx, &res->x1, -1 /*forced_reg*/, 0 /*flags*/); /* don't allow const */
62942 rc_key = duk__ispec_toregconst_raw(comp_ctx, &res->x2, -1 /*forced_reg*/, DUK__IVAL_FLAG_ALLOW_CONST /*flags*/);
62943 duk__emit_a_b_c(comp_ctx,
62945 (duk_regconst_t) reg_obj,
62946 rc_key,
62947 (duk_regconst_t) (reg_temps + 0));
62948 } else {
62949 duk__ivalue_toplain_ignore(comp_ctx, res); /* just in case */
62950 duk__emit_extraop_only(comp_ctx,
62952 }
62953 goto parse_3_or_4;
62954 } else {
62955 /*
62956 * Variant 1
62957 */
62958
62959 DUK_DDD(DUK_DDDPRINT("detected for variant 1: for (ExpressionNoIn_opt; Expression_opt; Expression_opt) Statement"));
62960 duk__ivalue_toplain_ignore(comp_ctx, res);
62961 goto parse_1_or_2;
62962 }
62963 }
62964
62965 parse_1_or_2:
62966 /*
62967 * Parse variant 1 or 2. The first part expression (which differs
62968 * in the variants) has already been parsed and its code emitted.
62969 *
62970 * reg_temps + 0: unused
62971 * reg_temps + 1: unused
62972 */
62973 {
62974 duk_regconst_t rc_cond;
62975 duk_int_t pc_l1, pc_l2, pc_l3, pc_l4;
62976 duk_int_t pc_jumpto_l3, pc_jumpto_l4;
62977 duk_bool_t expr_c_empty;
62978
62979 DUK_DDD(DUK_DDDPRINT("shared code for parsing variants 1 and 2"));
62980
62981 /* "release" preallocated temps since we won't need them */
62982 temp_reset = reg_temps + 0;
62983 DUK__SETTEMP(comp_ctx, temp_reset);
62984
62986
62987 pc_l1 = duk__get_current_pc(comp_ctx);
62988 duk__exprtop(comp_ctx, res, DUK__BP_FOR_EXPR | DUK__EXPR_FLAG_ALLOW_EMPTY /*rbp_flags*/); /* Expression_opt */
62989 if (duk__expr_is_empty(comp_ctx)) {
62990 /* no need to coerce */
62991 pc_jumpto_l3 = duk__emit_jump_empty(comp_ctx); /* to body */
62992 pc_jumpto_l4 = -1; /* omitted */
62993 } else {
62994 rc_cond = duk__ivalue_toregconst(comp_ctx, res);
62995 duk__emit_if_false_skip(comp_ctx, rc_cond);
62996 pc_jumpto_l3 = duk__emit_jump_empty(comp_ctx); /* to body */
62997 pc_jumpto_l4 = duk__emit_jump_empty(comp_ctx); /* to exit */
62998 }
62999 DUK__SETTEMP(comp_ctx, temp_reset);
63000
63002
63003 pc_l2 = duk__get_current_pc(comp_ctx);
63004 duk__exprtop(comp_ctx, res, DUK__BP_FOR_EXPR | DUK__EXPR_FLAG_ALLOW_EMPTY /*rbp_flags*/); /* Expression_opt */
63005 if (duk__expr_is_empty(comp_ctx)) {
63006 /* no need to coerce */
63007 expr_c_empty = 1;
63008 /* JUMP L1 omitted */
63009 } else {
63010 duk__ivalue_toplain_ignore(comp_ctx, res);
63011 expr_c_empty = 0;
63012 duk__emit_jump(comp_ctx, pc_l1);
63013 }
63014 DUK__SETTEMP(comp_ctx, temp_reset);
63015
63017
63018 pc_l3 = duk__get_current_pc(comp_ctx);
63019 duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/);
63020 if (expr_c_empty) {
63021 duk__emit_jump(comp_ctx, pc_l1);
63022 } else {
63023 duk__emit_jump(comp_ctx, pc_l2);
63024 }
63025 /* temp reset is not necessary after duk__parse_stmt(), which already does it */
63026
63027 pc_l4 = duk__get_current_pc(comp_ctx);
63028
63029 DUK_DDD(DUK_DDDPRINT("patching jumps: jumpto_l3: %ld->%ld, jumpto_l4: %ld->%ld, "
63030 "break: %ld->%ld, continue: %ld->%ld",
63031 (long) pc_jumpto_l3, (long) pc_l3, (long) pc_jumpto_l4, (long) pc_l4,
63032 (long) (pc_label_site + 1), (long) pc_l4, (long) (pc_label_site + 2), (long) pc_l2));
63033
63034 duk__patch_jump(comp_ctx, pc_jumpto_l3, pc_l3);
63035 duk__patch_jump(comp_ctx, pc_jumpto_l4, pc_l4);
63036 duk__patch_jump(comp_ctx,
63037 pc_label_site + 1,
63038 pc_l4); /* break jump */
63039 duk__patch_jump(comp_ctx,
63040 pc_label_site + 2,
63041 expr_c_empty ? pc_l1 : pc_l2); /* continue jump */
63042 }
63043 goto finished;
63044
63045 parse_3_or_4:
63046 /*
63047 * Parse variant 3 or 4.
63048 *
63049 * For variant 3 (e.g. "for (A in C) D;") the code for A (except the
63050 * final property/variable write) has already been emitted. The first
63051 * instruction of that code is at pc_v34_lhs; a JUMP needs to be inserted
63052 * there to satisfy control flow needs.
63053 *
63054 * For variant 4, if the variable declaration had an initializer
63055 * (e.g. "for (var A = B in C) D;") the code for the assignment
63056 * (B) has already been emitted.
63057 *
63058 * Variables set before entering here:
63059 *
63060 * pc_v34_lhs: insert a "JUMP L2" here (see doc/compiler.rst example).
63061 * reg_temps + 0: iteration target value (written to LHS)
63062 * reg_temps + 1: enumerator object
63063 */
63064 {
63065 duk_int_t pc_l1, pc_l2, pc_l3, pc_l4, pc_l5;
63066 duk_int_t pc_jumpto_l2, pc_jumpto_l3, pc_jumpto_l4, pc_jumpto_l5;
63067 duk_reg_t reg_target;
63068
63069 DUK_DDD(DUK_DDDPRINT("shared code for parsing variants 3 and 4, pc_v34_lhs=%ld", (long) pc_v34_lhs));
63070
63071 DUK__SETTEMP(comp_ctx, temp_reset);
63072
63073 /* First we need to insert a jump in the middle of previously
63074 * emitted code to get the control flow right. No jumps can
63075 * cross the position where the jump is inserted. See doc/compiler.rst
63076 * for discussion on the intricacies of control flow and side effects
63077 * for variants 3 and 4.
63078 */
63079
63080 duk__insert_jump_entry(comp_ctx, pc_v34_lhs);
63081 pc_jumpto_l2 = pc_v34_lhs; /* inserted jump */
63082 pc_l1 = pc_v34_lhs + 1; /* +1, right after inserted jump */
63083
63084 /* The code for writing reg_temps + 0 to the left hand side has already
63085 * been emitted.
63086 */
63087
63088 pc_jumpto_l3 = duk__emit_jump_empty(comp_ctx); /* -> loop body */
63089
63090 duk__advance(comp_ctx); /* eat 'in' */
63091
63092 /* Parse enumeration target and initialize enumerator. For 'null' and 'undefined',
63093 * INITENUM will creates a 'null' enumerator which works like an empty enumerator
63094 * (E5 Section 12.6.4, step 3). Note that INITENUM requires the value to be in a
63095 * register (constant not allowed).
63096 */
63097
63098 pc_l2 = duk__get_current_pc(comp_ctx);
63099 reg_target = duk__exprtop_toreg(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/); /* Expression */
63100 duk__emit_extraop_b_c(comp_ctx,
63102 (duk_regconst_t) (reg_temps + 1),
63103 (duk_regconst_t) reg_target);
63104 pc_jumpto_l4 = duk__emit_jump_empty(comp_ctx);
63105 DUK__SETTEMP(comp_ctx, temp_reset);
63106
63108
63109 pc_l3 = duk__get_current_pc(comp_ctx);
63110 duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/);
63111 /* temp reset is not necessary after duk__parse_stmt(), which already does it */
63112
63113 /* NEXTENUM needs a jump slot right after the main opcode.
63114 * We need the code emitter to reserve the slot: if there's
63115 * target shuffling, the target shuffle opcodes must happen
63116 * after the jump slot (for NEXTENUM the shuffle opcodes are
63117 * not needed if the enum is finished).
63118 */
63119 pc_l4 = duk__get_current_pc(comp_ctx);
63120 duk__emit_extraop_b_c(comp_ctx,
63122 (duk_regconst_t) (reg_temps + 0),
63123 (duk_regconst_t) (reg_temps + 1));
63124 pc_jumpto_l5 = comp_ctx->emit_jumpslot_pc; /* NEXTENUM jump slot: executed when enum finished */
63125 duk__emit_jump(comp_ctx, pc_l1); /* jump to next loop, using reg_v34_iter as iterated value */
63126
63127 pc_l5 = duk__get_current_pc(comp_ctx);
63128
63129 /* XXX: since the enumerator may be a memory expensive object,
63130 * perhaps clear it explicitly here? If so, break jump must
63131 * go through this clearing operation.
63132 */
63133
63134 DUK_DDD(DUK_DDDPRINT("patching jumps: jumpto_l2: %ld->%ld, jumpto_l3: %ld->%ld, "
63135 "jumpto_l4: %ld->%ld, jumpto_l5: %ld->%ld, "
63136 "break: %ld->%ld, continue: %ld->%ld",
63137 (long) pc_jumpto_l2, (long) pc_l2, (long) pc_jumpto_l3, (long) pc_l3,
63138 (long) pc_jumpto_l4, (long) pc_l4, (long) pc_jumpto_l5, (long) pc_l5,
63139 (long) (pc_label_site + 1), (long) pc_l5, (long) (pc_label_site + 2), (long) pc_l4));
DUK_LOCAL_DECL void duk__patch_jump(duk_compiler_ctx *comp_ctx, duk_int_t jump_pc, duk_int_t target_pc)
#define DUK__EXPR_FLAG_REJECT_IN
DUK_LOCAL_DECL void duk__emit_jump(duk_compiler_ctx *comp_ctx, duk_int_t target_pc)
DUK_LOCAL_DECL void duk__parse_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_bool_t allow_source_elem)
#define DUK_TOK_VAR
DUK_LOCAL_DECL void duk__parse_var_decl(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t expr_flags, duk_reg_t *out_reg_varbind, duk_regconst_t *out_rc_varname)
DUK_LOCAL_DECL void duk__emit_if_false_skip(duk_compiler_ctx *comp_ctx, duk_regconst_t regconst)
DUK_LOCAL_DECL void duk__parse_for_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site)
DUK_LOCAL_DECL duk_reg_t duk__exprtop_toreg(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags)
DUK_LOCAL_DECL duk_bool_t duk__expr_is_empty(duk_compiler_ctx *comp_ctx)

References duk_compiler_ctx::curr_token, duk__advance(), duk__parse_var_decl(), DUK_TOK_COMMA, and duk_token::t.

◆ duk__parse_func_body()

DUK_LOCAL_DECL void duk__parse_func_body ( duk_compiler_ctx * comp_ctx,
duk_bool_t expect_eof,
duk_bool_t implicit_return_value,
duk_small_int_t expect_token )

Definition at line 64849 of file duktape-1.8.0/src/duktape.c.

64853 :
64854 *
64855 * - Global and eval code have an implicit return value generated
64856 * by the last statement; function code does not
64857 *
64858 * - Global code, eval code, and Function constructor body end in
64859 * an EOF, other bodies in a closing brace ('}')
64860 *
64861 * Upon entry, 'curr_tok' is ignored and the function will pull in the
64862 * first token on its own. Upon exit, 'curr_tok' is the terminating
64863 * token (EOF or closing brace).
64864 */
64865
64866DUK_LOCAL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_small_int_t expect_token) {
64867 duk_compiler_func *func;
64868 duk_hthread *thr;
64869 duk_context *ctx;
64870 duk_reg_t reg_stmt_value = -1;
64871 duk_lexer_point lex_pt;
64872 duk_reg_t temp_first;
64873 duk_small_int_t compile_round = 1;
64874
64875 DUK_ASSERT(comp_ctx != NULL);
64876
64877 thr = comp_ctx->thr;
64878 ctx = (duk_context *) thr;
64879 DUK_ASSERT(thr != NULL);
64880
64881 func = &comp_ctx->curr_func;
64882 DUK_ASSERT(func != NULL);
64883
64884 DUK__RECURSION_INCREASE(comp_ctx, thr);
64885
64887
64888 /*
64889 * Store lexer position for a later rewind
64890 */
64891
64892 DUK_LEXER_GETPOINT(&comp_ctx->lex, &lex_pt);
64893
64894 /*
64895 * Program code (global and eval code) has an implicit return value
64896 * from the last statement value (e.g. eval("1; 2+3;") returns 3).
64897 * This is not the case with functions. If implicit statement return
64898 * value is requested, all statements are coerced to a register
64899 * allocated here, and used in the implicit return statement below.
64900 */
64901
64902 /* XXX: this is pointless here because pass 1 is throw-away */
64903 if (implicit_return_value) {
64904 reg_stmt_value = DUK__ALLOCTEMP(comp_ctx);
64905
64906 /* If an implicit return value is needed by caller, it must be
64907 * initialized to 'undefined' because we don't know whether any
64908 * non-empty (where "empty" is a continuation type, and different
64909 * from an empty statement) statements will be executed.
64910 *
64911 * However, since 1st pass is a throwaway one, no need to emit
64912 * it here.
64913 */
64914#if 0
64915 duk__emit_extraop_bc(comp_ctx,
64917 0);
64918#endif
64919 }
64920
64921 /*
64922 * First pass.
64923 *
64924 * Gather variable/function declarations needed for second pass.
64925 * Code generated is dummy and discarded.
64926 */
64927
64928 func->in_directive_prologue = 1;
64929 func->in_scanning = 1;
64930 func->may_direct_eval = 0;
64931 func->id_access_arguments = 0;
64932 func->id_access_slow = 0;
64933 func->reg_stmt_value = reg_stmt_value;
64934#if defined(DUK_USE_DEBUGGER_SUPPORT)
64935 func->min_line = DUK_INT_MAX;
64936 func->max_line = 0;
64937#endif
64938
64939 /* duk__parse_stmts() expects curr_tok to be set; parse in "allow regexp literal" mode with current strictness */
64940 if (expect_token >= 0) {
64941 /* Eating a left curly; regexp mode is allowed by left curly
64942 * based on duk__token_lbp[] automatically.
64943 */
64944 DUK_ASSERT(expect_token == DUK_TOK_LCURLY);
64946 duk__advance_expect(comp_ctx, expect_token);
64947 } else {
64948 /* Need to set curr_token.t because lexing regexp mode depends on current
64949 * token type. Zero value causes "allow regexp" mode.
64950 */
64951 comp_ctx->curr_token.t = 0;
64952 duk__advance(comp_ctx);
64953 }
64954
64955 DUK_DDD(DUK_DDDPRINT("begin 1st pass"));
64956 duk__parse_stmts(comp_ctx,
64957 1, /* allow source elements */
64958 expect_eof); /* expect EOF instead of } */
64959 DUK_DDD(DUK_DDDPRINT("end 1st pass"));
64960
64961 /*
64962 * Second (and possibly third) pass.
64963 *
64964 * Generate actual code. In most cases the need for shuffle
64965 * registers is detected during pass 1, but in some corner cases
64966 * we'll only detect it during pass 2 and a third pass is then
64967 * needed (see GH-115).
64968 */
64969
64970 for (;;) {
64971 duk_bool_t needs_shuffle_before = comp_ctx->curr_func.needs_shuffle;
64972 compile_round++;
64973
64974 /*
64975 * Rewind lexer.
64976 *
64977 * duk__parse_stmts() expects curr_tok to be set; parse in "allow regexp
64978 * literal" mode with current strictness.
64979 *
64980 * curr_token line number info should be initialized for pass 2 before
64981 * generating prologue, to ensure prologue bytecode gets nice line numbers.
64982 */
64983
64984 DUK_DDD(DUK_DDDPRINT("rewind lexer"));
64985 DUK_LEXER_SETPOINT(&comp_ctx->lex, &lex_pt);
64986 comp_ctx->curr_token.t = 0; /* this is needed for regexp mode */
64987 comp_ctx->curr_token.start_line = 0; /* needed for line number tracking (becomes prev_token.start_line) */
64988 duk__advance(comp_ctx);
64989
64990 /*
64991 * Reset function state and perform register allocation, which creates
64992 * 'varmap' for second pass. Function prologue for variable declarations,
64993 * binding value initializations etc is emitted as a by-product.
64994 *
64995 * Strict mode restrictions for duplicate and invalid argument
64996 * names are checked here now that we know whether the function
64997 * is actually strict. See: test-dev-strict-mode-boundary.js.
64998 *
64999 * Inner functions are compiled during pass 1 and are not reset.
65000 */
65001
65002 duk__reset_func_for_pass2(comp_ctx);
65003 func->in_directive_prologue = 1;
65004 func->in_scanning = 0;
65005
65006 /* must be able to emit code, alloc consts, etc. */
65007
65009 (implicit_return_value ? &reg_stmt_value : NULL));
65010 func->reg_stmt_value = reg_stmt_value;
65011
65012 temp_first = DUK__GETTEMP(comp_ctx);
65013
65014 func->temp_first = temp_first;
65015 func->temp_next = temp_first;
65016 func->stmt_next = 0;
65017 func->label_next = 0;
65018
65019 /* XXX: init or assert catch depth etc -- all values */
65020 func->id_access_arguments = 0;
65021 func->id_access_slow = 0;
65022
65023 /*
65024 * Check function name validity now that we know strictness.
65025 * This only applies to function declarations and expressions,
65026 * not setter/getter name.
65027 *
65028 * See: test-dev-strict-mode-boundary.js
65029 */
65030
65031 if (func->is_function && !func->is_setget && func->h_name != NULL) {
65032 if (func->is_strict) {
65033 if (duk__hstring_is_eval_or_arguments(comp_ctx, func->h_name)) {
65034 DUK_DDD(DUK_DDDPRINT("func name is 'eval' or 'arguments' in strict mode"));
65035 goto error_funcname;
65036 }
65038 DUK_DDD(DUK_DDDPRINT("func name is a reserved word in strict mode"));
65039 goto error_funcname;
65040 }
65041 } else {
65044 DUK_DDD(DUK_DDDPRINT("func name is a reserved word in non-strict mode"));
65045 goto error_funcname;
65046 }
65047 }
65048 }
65049
65050 /*
65051 * Second pass parsing.
65052 */
65053
65054 if (implicit_return_value) {
65055 /* Default implicit return value. */
65056 duk__emit_extraop_bc(comp_ctx,
65058 0);
65059 }
65060
65061 DUK_DDD(DUK_DDDPRINT("begin 2nd pass"));
65062 duk__parse_stmts(comp_ctx,
65063 1, /* allow source elements */
65064 expect_eof); /* expect EOF instead of } */
65065 DUK_DDD(DUK_DDDPRINT("end 2nd pass"));
65066
65068
65069 if (needs_shuffle_before == comp_ctx->curr_func.needs_shuffle) {
65070 /* Shuffle decision not changed. */
65071 break;
65072 }
65073 if (compile_round >= 3) {
65074 /* Should never happen but avoid infinite loop just in case. */
65075 DUK_D(DUK_DPRINT("more than 3 compile passes needed, should never happen"));
65077 }
65078 DUK_D(DUK_DPRINT("need additional round to compile function, round now %d", (int) compile_round));
65079 }
65080
65081 /*
65082 * Emit a final RETURN.
65083 *
65084 * It would be nice to avoid emitting an unnecessary "return" opcode
65085 * if the current PC is not reachable. However, this cannot be reliably
65086 * detected; even if the previous instruction is an unconditional jump,
65087 * there may be a previous jump which jumps to current PC (which is the
65088 * case for iteration and conditional statements, for instance).
65089 */
65090
65091 /* XXX: request a "last statement is terminal" from duk__parse_stmt() and duk__parse_stmts();
65092 * we could avoid the last RETURN if we could ensure there is no way to get here
65093 * (directly or via a jump)
65094 */
65095
65096 DUK_ASSERT(comp_ctx->curr_func.catch_depth == 0);
65097 if (reg_stmt_value >= 0) {
65098 duk__emit_a_b(comp_ctx,
65101 (duk_regconst_t) reg_stmt_value /*reg*/);
65102 } else {
65103 duk__emit_a_b(comp_ctx,
65105 (duk_regconst_t) 0 /*flags*/,
65106 (duk_regconst_t) 0 /*reg(ignored)*/);
65107 }
65108
#define DUK__FUNCTION_BODY_REQUIRE_SLOTS
#define DUK_HSTRING_HAS_RESERVED_WORD(x)
#define DUK_LEXER_GETPOINT(ctx, pt)
DUK_LOCAL_DECL void duk__reset_func_for_pass2(duk_compiler_ctx *comp_ctx)
DUK_LOCAL_DECL void duk__parse_stmts(duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof)
DUK_LOCAL void duk__update_lineinfo_currtoken(duk_compiler_ctx *comp_ctx)
static int statement(LexState *ls)
static void body(LexState *ls, expdesc *e, int needself, int line)
static void constructor(LexState *ls, expdesc *t)

References duk_compiler_func::catch_depth, duk_compiler_ctx::curr_func, duk_compiler_ctx::curr_token, duk__advance(), duk__advance_expect(), DUK__ALLOCTEMP, duk__emit_a_b(), duk__emit_extraop_bc(), DUK__EMIT_FLAG_NO_SHUFFLE_A, DUK__FUNCTION_BODY_REQUIRE_SLOTS, DUK__GETTEMP, duk__hstring_is_eval_or_arguments(), duk__init_varmap_and_prologue_for_pass2(), duk__parse_stmts(), duk__peephole_optimize_bytecode(), DUK__RECURSION_DECREASE, DUK__RECURSION_INCREASE, duk__reset_func_for_pass2(), duk__update_lineinfo_currtoken(), DUK_ASSERT, DUK_BC_RETURN_FLAG_HAVE_RETVAL, DUK_D, DUK_DDD, DUK_DDDPRINT, DUK_DPRINT, DUK_ERROR_INTERNAL_DEFMSG, DUK_ERROR_SYNTAX, DUK_EXTRAOP_LDUNDEF, DUK_HSTRING_HAS_RESERVED_WORD, DUK_HSTRING_HAS_STRICT_RESERVED_WORD, DUK_INT_MAX, DUK_LEXER_GETPOINT, DUK_LEXER_SETPOINT, DUK_OP_RETURN, duk_require_stack(), DUK_STR_INVALID_FUNC_NAME, DUK_TOK_LCURLY, duk_compiler_func::h_name, duk_compiler_func::id_access_arguments, duk_compiler_func::id_access_slow, duk_compiler_func::in_directive_prologue, duk_compiler_func::in_scanning, duk_compiler_func::is_function, duk_compiler_func::is_setget, duk_compiler_func::is_strict, duk_compiler_func::label_next, duk_compiler_ctx::lex, duk_compiler_func::may_direct_eval, duk_compiler_func::needs_shuffle, NULL, duk_compiler_func::reg_stmt_value, duk_token::start_line, duk_compiler_func::stmt_next, duk_token::t, duk_compiler_func::temp_first, duk_compiler_func::temp_next, and duk_compiler_ctx::thr.

◆ duk__parse_func_formals()

DUK_LOCAL_DECL void duk__parse_func_formals ( duk_compiler_ctx * comp_ctx)

Definition at line 65128 of file duktape-1.8.0/src/duktape.c.

65128 :
65129 *
65130 * - function expression
65131 * - function declaration
65132 * - function statement (non-standard)
65133 * - setter/getter
65134 *
65135 * Adds the function to comp_ctx->curr_func function table and returns the
65136 * function number.
65137 *
65138 * On entry, curr_token points to:
65139 *
65140 * - the token after 'function' for function expression/declaration/statement
65141 * - the token after 'set' or 'get' for setter/getter
65142 */
65143
65144/* Parse formals. */
65146 duk_hthread *thr = comp_ctx->thr;
65147 duk_context *ctx = (duk_context *) thr;
65148 duk_bool_t first = 1;
65149 duk_uarridx_t n;
65150
65151 for (;;) {
65152 if (comp_ctx->curr_token.t == DUK_TOK_RPAREN) {
65153 break;
65154 }
65155
65156 if (first) {
65157 /* no comma */
65158 first = 0;
65159 } else {
65161 }
65162
65163 /* Note: when parsing a formal list in non-strict context, e.g.
65164 * "implements" is parsed as an identifier. When the function is
65165 * later detected to be strict, the argument list must be rechecked
65166 * against a larger set of reserved words (that of strict mode).
65167 * This is handled by duk__parse_func_body(). Here we recognize
65168 * whatever tokens are considered reserved in current strictness
65169 * (which is not always enough).
65170 */
DUK_LOCAL_DECL void duk__parse_func_formals(duk_compiler_ctx *comp_ctx)

References duk_compiler_ctx::curr_token, duk__advance_expect(), DUK_ASSERT, DUK_ERROR_SYNTAX, DUK_TOK_COMMA, DUK_TOK_IDENTIFIER, DUK_TOK_RPAREN, duk_token::t, and duk_compiler_ctx::thr.

◆ duk__parse_func_like_fnum()

DUK_LOCAL_DECL duk_int_t duk__parse_func_like_fnum ( duk_compiler_ctx * comp_ctx,
duk_bool_t is_decl,
duk_bool_t is_setget )

Definition at line 65284 of file duktape-1.8.0/src/duktape.c.

65301 {
65302 duk_hthread *thr = comp_ctx->thr;
65303 duk_context *ctx = (duk_context *) thr;
65304 duk_compiler_func old_func;
65305 duk_idx_t entry_top;
65306 duk_int_t fnum;
65307
65308 /*
65309 * On second pass, skip the function.
65310 */
65311
65312 if (!comp_ctx->curr_func.in_scanning) {
65313 duk_lexer_point lex_pt;
65314
65315 fnum = comp_ctx->curr_func.fnum_next++;
65316 duk_get_prop_index(ctx, comp_ctx->curr_func.funcs_idx, (duk_uarridx_t) (fnum * 3 + 1));
65317 lex_pt.offset = duk_to_int(ctx, -1);
65318 duk_pop(ctx);
65319 duk_get_prop_index(ctx, comp_ctx->curr_func.funcs_idx, (duk_uarridx_t) (fnum * 3 + 2));
65320 lex_pt.line = duk_to_int(ctx, -1);
65321 duk_pop(ctx);
65322
65323 DUK_DDD(DUK_DDDPRINT("second pass of an inner func, skip the function, reparse closing brace; lex offset=%ld, line=%ld",
65324 (long) lex_pt.offset, (long) lex_pt.line));
65325
65326 DUK_LEXER_SETPOINT(&comp_ctx->lex, &lex_pt);
65327 comp_ctx->curr_token.t = 0; /* this is needed for regexp mode */
65328 comp_ctx->curr_token.start_line = 0; /* needed for line number tracking (becomes prev_token.start_line) */
65329 duk__advance(comp_ctx);
65331
65332 return fnum;
65333 }
65334
65335 /*
65336 * On first pass, perform actual parsing. Remember valstack top on entry
65337 * to restore it later, and switch to using a new function in comp_ctx.
65338 */
65339
65340 entry_top = duk_get_top(ctx);
65341 DUK_DDD(DUK_DDDPRINT("before func: entry_top=%ld, curr_tok.start_offset=%ld",
65342 (long) entry_top, (long) comp_ctx->curr_token.start_offset));
65343
65344 DUK_MEMCPY(&old_func, &comp_ctx->curr_func, sizeof(duk_compiler_func));
65345
65346 DUK_MEMZERO(&comp_ctx->curr_func, sizeof(duk_compiler_func));
65348 DUK_ASSERT(comp_ctx->curr_func.num_formals == 0);
65349
65350 /* inherit initial strictness from parent */
65351 comp_ctx->curr_func.is_strict = old_func.is_strict;
65352
65353 DUK_ASSERT(comp_ctx->curr_func.is_notail == 0);
65354 comp_ctx->curr_func.is_function = 1;
65355 DUK_ASSERT(comp_ctx->curr_func.is_eval == 0);
65356 DUK_ASSERT(comp_ctx->curr_func.is_global == 0);
65357 comp_ctx->curr_func.is_setget = is_setget;
65358 comp_ctx->curr_func.is_decl = is_decl;
65359
65360 /*
65361 * Parse inner function
65362 */
65363
65364 duk__parse_func_like_raw(comp_ctx, is_decl, is_setget); /* pushes function template */
65365
65366 /* prev_token.start_offset points to the closing brace here; when skipping
65367 * we're going to reparse the closing brace to ensure semicolon insertion
65368 * etc work as expected.
65369 */
65370 DUK_DDD(DUK_DDDPRINT("after func: prev_tok.start_offset=%ld, curr_tok.start_offset=%ld",
65371 (long) comp_ctx->prev_token.start_offset, (long) comp_ctx->curr_token.start_offset));
65372 DUK_ASSERT(comp_ctx->lex.input[comp_ctx->prev_token.start_offset] == (duk_uint8_t) DUK_ASC_RCURLY);
65373
65374 /* XXX: append primitive */
65375 DUK_ASSERT(duk_get_length(ctx, old_func.funcs_idx) == (duk_size_t) (old_func.fnum_next * 3));
65376 fnum = old_func.fnum_next++;
65377
65378 if (fnum > DUK__MAX_FUNCS) {
65380 }
65381
65382 /* array writes autoincrement length */
#define DUK_TOK_RCURLY
#define DUK__MAX_FUNCS
#define DUK_STR_FUNC_LIMIT

◆ duk__parse_func_like_raw()

DUK_LOCAL_DECL void duk__parse_func_like_raw ( duk_compiler_ctx * comp_ctx,
duk_bool_t is_decl,
duk_bool_t is_setget )

Definition at line 65176 of file duktape-1.8.0/src/duktape.c.

65177 : %!O",
65178 (duk_heaphdr *) comp_ctx->curr_token.str1));
65179
65180 /* XXX: append primitive */
65181 duk_push_hstring(ctx, comp_ctx->curr_token.str1);
65182 n = (duk_uarridx_t) duk_get_length(ctx, comp_ctx->curr_func.argnames_idx);
65183 duk_put_prop_index(ctx, comp_ctx->curr_func.argnames_idx, n);
65184
65185 duk__advance(comp_ctx); /* eat identifier */
65186 }
65187}
65188
65189/* Parse a function-like expression, assuming that 'comp_ctx->curr_func' is
65190 * correctly set up. Assumes that curr_token is just after 'function' (or
65191 * 'set'/'get' etc).
65192 */
65193DUK_LOCAL void duk__parse_func_like_raw(duk_compiler_ctx *comp_ctx, duk_bool_t is_decl, duk_bool_t is_setget) {
65194 duk_hthread *thr = comp_ctx->thr;
65195 duk_context *ctx = (duk_context *) thr;
65196
65197 DUK_ASSERT(comp_ctx->curr_func.num_formals == 0);
65198 DUK_ASSERT(comp_ctx->curr_func.is_function == 1);
65199 DUK_ASSERT(comp_ctx->curr_func.is_eval == 0);
65200 DUK_ASSERT(comp_ctx->curr_func.is_global == 0);
65201 DUK_ASSERT(comp_ctx->curr_func.is_setget == is_setget);
65202 DUK_ASSERT(comp_ctx->curr_func.is_decl == is_decl);
65203
65204 duk__update_lineinfo_currtoken(comp_ctx);
65205
65206 /*
65207 * Function name (if any)
65208 *
65209 * We don't check for prohibited names here, because we don't
65210 * yet know whether the function will be strict. Function body
65211 * parsing handles this retroactively.
65212 *
65213 * For function expressions and declarations function name must
65214 * be an Identifer (excludes reserved words). For setter/getter
65215 * it is a PropertyName which allows reserved words and also
65216 * strings and numbers (e.g. "{ get 1() { ... } }").
65217 */
65218
65219 if (is_setget) {
65220 /* PropertyName -> IdentifierName | StringLiteral | NumericLiteral */
65221 if (comp_ctx->curr_token.t_nores == DUK_TOK_IDENTIFIER ||
65222 comp_ctx->curr_token.t == DUK_TOK_STRING) {
65223 duk_push_hstring(ctx, comp_ctx->curr_token.str1); /* keep in valstack */
65224 } else if (comp_ctx->curr_token.t == DUK_TOK_NUMBER) {
65225 duk_push_number(ctx, comp_ctx->curr_token.num);
65226 duk_to_string(ctx, -1);
65227 } else {
65228 DUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_GETSET_NAME);
65229 }
65230 comp_ctx->curr_func.h_name = duk_get_hstring(ctx, -1); /* borrowed reference */
65231 DUK_ASSERT(comp_ctx->curr_func.h_name != NULL);
65232 duk__advance(comp_ctx);
65233 } else {
65234 /* Function name is an Identifier (not IdentifierName), but we get
65235 * the raw name (not recognizing keywords) here and perform the name
65236 * checks only after pass 1.
65237 */
65238 if (comp_ctx->curr_token.t_nores == DUK_TOK_IDENTIFIER) {
65239 duk_push_hstring(ctx, comp_ctx->curr_token.str1); /* keep in valstack */
65240 comp_ctx->curr_func.h_name = duk_get_hstring(ctx, -1); /* borrowed reference */
65241 DUK_ASSERT(comp_ctx->curr_func.h_name != NULL);
65242 duk__advance(comp_ctx);
65243 } else {
65244 /* valstack will be unbalanced, which is OK */
65245 DUK_ASSERT(!is_setget);
65246 if (is_decl) {
65247 DUK_ERROR_SYNTAX(thr, DUK_STR_FUNC_NAME_REQUIRED);
65248 }
65249 }
65250 }
65251
65252 DUK_DDD(DUK_DDDPRINT("function name: %!O",
65253 (duk_heaphdr *) comp_ctx->curr_func.h_name));
65254
65255 /*
65256 * Formal argument list
65257 *
65258 * We don't check for prohibited names or for duplicate argument
65259 * names here, becase we don't yet know whether the function will
65260 * be strict. Function body parsing handles this retroactively.
65261 */
65262
65263 duk__advance_expect(comp_ctx, DUK_TOK_LPAREN);
65264
65265 duk__parse_func_formals(comp_ctx);
65266
65267 DUK_ASSERT(comp_ctx->curr_token.t == DUK_TOK_RPAREN);
65268 duk__advance(comp_ctx);

◆ duk__parse_if_stmt()

DUK_LOCAL_DECL void duk__parse_if_stmt ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res )

Definition at line 63340 of file duktape-1.8.0/src/duktape.c.

63353 :
63355}
63356
63358 duk_reg_t temp_reset;
63359 duk_regconst_t rc_cond;
63360 duk_int_t pc_jump_false;
63361
63362 DUK_DDD(DUK_DDDPRINT("begin parsing if statement"));
63363
63364 temp_reset = DUK__GETTEMP(comp_ctx);
63365
63366 duk__advance(comp_ctx); /* eat 'if' */
63368
63369 rc_cond = duk__exprtop_toregconst(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/);
63370 duk__emit_if_true_skip(comp_ctx, rc_cond);
63371 pc_jump_false = duk__emit_jump_empty(comp_ctx); /* jump to end or else part */
63372 DUK__SETTEMP(comp_ctx, temp_reset);
63373
63375
63376 duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/);
63377
63378 /* The 'else' ambiguity is resolved by 'else' binding to the innermost
63379 * construct, so greedy matching is correct here.
63380 */
63381
63382 if (comp_ctx->curr_token.t == DUK_TOK_ELSE) {
63383 duk_int_t pc_jump_end;
63384
63385 DUK_DDD(DUK_DDDPRINT("if has else part"));
#define DUK_STR_INVALID_SWITCH
DUK_LOCAL_DECL void duk__parse_if_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res)
DUK_LOCAL_DECL duk_regconst_t duk__exprtop_toregconst(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags)
#define DUK_TOK_ELSE

◆ duk__parse_regexp_flags()

DUK_LOCAL duk_uint32_t duk__parse_regexp_flags ( duk_hthread * thr,
duk_hstring * h )

Definition at line 78420 of file duktape-1.8.0/src/duktape.c.

78427 : charlen=%ld",
78428 (long) out_atom_info->charlen));
78429
78430 re_ctx->recursion_depth--;
78431}
78432
78433/*
78434 * Flags parsing (see E5 Section 15.10.4.1).
78435 */
78436
78437DUK_LOCAL duk_uint32_t duk__parse_regexp_flags(duk_hthread *thr, duk_hstring *h) {
78438 const duk_uint8_t *p;
78439 const duk_uint8_t *p_end;
78440 duk_uint32_t flags = 0;
78441
78442 p = DUK_HSTRING_GET_DATA(h);
78443 p_end = p + DUK_HSTRING_GET_BYTELEN(h);
78444
78445 /* Note: can be safely scanned as bytes (undecoded) */
78446
78447 while (p < p_end) {
78448 duk_uint8_t c = *p++;
78449 switch ((int) c) {
78450 case (int) 'g': {
78451 if (flags & DUK_RE_FLAG_GLOBAL) {
78452 goto error;
78453 }
78454 flags |= DUK_RE_FLAG_GLOBAL;
78455 break;
78456 }
78457 case (int) 'i': {
78458 if (flags & DUK_RE_FLAG_IGNORE_CASE) {
78459 goto error;
78460 }
78461 flags |= DUK_RE_FLAG_IGNORE_CASE;
78462 break;
78463 }
78464 case (int) 'm': {
78465 if (flags & DUK_RE_FLAG_MULTILINE) {

◆ duk__parse_return_stmt()

DUK_LOCAL_DECL void duk__parse_return_stmt ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res )

Definition at line 63502 of file duktape-1.8.0/src/duktape.c.

63505 : 2));
63506 } else {
63507 DUK_DDD(DUK_DDDPRINT("break/continue: is_break=%ld, label_id=%ld, label_is_closest=%ld, "
63508 "label_catch_depth=%ld, catch_depth=%ld "
63509 "-> use slow variant (longjmp)",
63510 (long) is_break, (long) label_id, (long) label_is_closest,
63511 (long) label_catch_depth, (long) comp_ctx->curr_func.catch_depth));
63512
63513 duk__emit_extraop_bc(comp_ctx,
63515 (duk_regconst_t) label_id);
63516 }
63517}
63518
63520 duk_hthread *thr = comp_ctx->thr;
63521 duk_regconst_t rc_val;
63522 duk_small_uint_t ret_flags;
63523
63524 duk__advance(comp_ctx); /* eat 'return' */
63525
63526 /* A 'return' statement is only allowed inside an actual function body,
63527 * not as part of eval or global code.
63528 */
63529 if (!comp_ctx->curr_func.is_function) {
63531 }
63532
63533 ret_flags = 0;
63534
63535 if (comp_ctx->curr_token.t == DUK_TOK_SEMICOLON || /* explicit semi follows */
63536 comp_ctx->curr_token.lineterm || /* automatic semi will be inserted */
63537 comp_ctx->curr_token.allow_auto_semi) { /* automatic semi will be inserted */
63538 DUK_DDD(DUK_DDDPRINT("empty return value -> undefined"));
63539 rc_val = 0;
63540 } else {
63541 duk_int_t pc_before_expr;
63542 duk_int_t pc_after_expr;
63543
63544 DUK_DDD(DUK_DDDPRINT("return with a value"));
63545
63546 DUK_UNREF(pc_before_expr);
63547 DUK_UNREF(pc_after_expr);
63548
63549 pc_before_expr = duk__get_current_pc(comp_ctx);
63550 rc_val = duk__exprtop_toregconst(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/);
63551 pc_after_expr = duk__get_current_pc(comp_ctx);
63552
63553 /* Tail call check: if last opcode emitted was CALL(I), and
63554 * the context allows it, change the CALL(I) to a tail call.
63555 * This doesn't guarantee that a tail call will be allowed at
63556 * runtime, so the RETURN must still be emitted. (Duktape
63557 * 0.10.0 avoided this and simulated a RETURN if a tail call
63558 * couldn't be used at runtime; but this didn't work
63559 * correctly with a thread yield/resume, see
63560 * test-bug-tailcall-thread-yield-resume.js for discussion.)
63561 *
63562 * In addition to the last opcode being CALL, we also need to
63563 * be sure that 'rc_val' is the result register of the CALL(I).
63564 * For instance, for the expression 'return 0, (function ()
63565 * { return 1; }), 2' the last opcode emitted is CALL (no
63566 * bytecode is emitted for '2') but 'rc_val' indicates
63567 * constant '2'. Similarly if '2' is replaced by a register
63568 * bound variable, no opcodes are emitted but tail call would
63569 * be incorrect.
63570 *
63571 * This is tricky and easy to get wrong. It would be best to
63572 * track enough expression metadata to check that 'rc_val' came
63573 * from that last CALL instruction. We don't have that metadata
63574 * now, so we check that 'rc_val' is a temporary register result
63575 * (not a constant or a register bound variable). There should
63576 * be no way currently for 'rc_val' to be a temporary for an
63577 * expression following the CALL instruction without emitting
63578 * some opcodes following the CALL. This proxy check is used
63579 * below.
63580 *
63581 * See: test-bug-comma-expr-gh131.js.
63582 *
63583 * The non-standard 'caller' property disables tail calls
63584 * because they pose some special cases which haven't been
63585 * fixed yet.
63586 */
63587
63588#if defined(DUK_USE_TAILCALL)
63589 if (comp_ctx->curr_func.catch_depth == 0 && /* no catchers */
63590 pc_after_expr > pc_before_expr) { /* at least one opcode emitted */
63591 duk_compiler_instr *instr;
63593
63594 instr = duk__get_instr_ptr(comp_ctx, pc_after_expr - 1);
63595 DUK_ASSERT(instr != NULL);
63596
63597 op = (duk_small_uint_t) DUK_DEC_OP(instr->ins);
63598 if ((op == DUK_OP_CALL || op == DUK_OP_CALLI) &&
63599 DUK__ISTEMP(comp_ctx, rc_val) /* see above */) {
63600 DUK_DDD(DUK_DDDPRINT("return statement detected a tail call opportunity: "
#define DUK_STR_INVALID_RETURN
DUK_LOCAL_DECL void duk__parse_return_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res)

◆ duk__parse_stmt()

DUK_LOCAL_DECL void duk__parse_stmt ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res,
duk_bool_t allow_source_elem )

Definition at line 63917 of file duktape-1.8.0/src/duktape.c.

63918 : %ld", (long) label_id));
63919
63920 duk__emit_extraop_bc(comp_ctx,
63921 DUK_EXTRAOP_LABEL,
63922 (duk_regconst_t) label_id);
63923 duk__emit_invalid(comp_ctx);
63924 duk__emit_invalid(comp_ctx);
63925
63926 return label_id;
63927}
63928
63929/* Parse a single statement.
63930 *
63931 * Creates a label site (with an empty label) automatically for iteration
63932 * statements. Also "peels off" any label statements for explicit labels.
63933 */
63934DUK_LOCAL void duk__parse_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_bool_t allow_source_elem) {
63935 duk_hthread *thr = comp_ctx->thr;
63936 duk_context *ctx = (duk_context *) thr;
63937 duk_bool_t dir_prol_at_entry; /* directive prologue status at entry */
63938 duk_reg_t temp_at_entry;
63939 duk_uarridx_t labels_len_at_entry;
63940 duk_int_t pc_at_entry; /* assumed to also be PC of "LABEL" */
63941 duk_int_t stmt_id;
63942 duk_small_uint_t stmt_flags = 0;
63943 duk_int_t label_id = -1;
63944 duk_small_uint_t tok;
63945
63946 DUK__RECURSION_INCREASE(comp_ctx, thr);
63947
63948 temp_at_entry = DUK__GETTEMP(comp_ctx);
63949 pc_at_entry = duk__get_current_pc(comp_ctx);
63950 labels_len_at_entry = (duk_uarridx_t) duk_get_length(ctx, comp_ctx->curr_func.labelnames_idx);
63951 stmt_id = comp_ctx->curr_func.stmt_next++;
63952 dir_prol_at_entry = comp_ctx->curr_func.in_directive_prologue;
63953
63954 DUK_UNREF(stmt_id);
63955
63956 DUK_DDD(DUK_DDDPRINT("parsing a statement, stmt_id=%ld, temp_at_entry=%ld, labels_len_at_entry=%ld, "
63957 "is_strict=%ld, in_directive_prologue=%ld, catch_depth=%ld",
63958 (long) stmt_id, (long) temp_at_entry, (long) labels_len_at_entry,
63959 (long) comp_ctx->curr_func.is_strict, (long) comp_ctx->curr_func.in_directive_prologue,
63960 (long) comp_ctx->curr_func.catch_depth));
63961
63962 /* The directive prologue flag is cleared by default so that it is
63963 * unset for any recursive statement parsing. It is only "revived"
63964 * if a directive is detected. (We could also make directives only
63965 * allowed if 'allow_source_elem' was true.)
63966 */
63967 comp_ctx->curr_func.in_directive_prologue = 0;
63968
63969 retry_parse:
63970
63971 DUK_DDD(DUK_DDDPRINT("try stmt parse, stmt_id=%ld, label_id=%ld, allow_source_elem=%ld, catch_depth=%ld",
63972 (long) stmt_id, (long) label_id, (long) allow_source_elem,
63973 (long) comp_ctx->curr_func.catch_depth));
63974
63975 /*
63976 * Detect iteration statements; if encountered, establish an
63977 * empty label.
63978 */
63979
63980 tok = comp_ctx->curr_token.t;
63981 if (tok == DUK_TOK_FOR || tok == DUK_TOK_DO || tok == DUK_TOK_WHILE ||
63982 tok == DUK_TOK_SWITCH) {
63983 DUK_DDD(DUK_DDDPRINT("iteration/switch statement -> add empty label"));
63984
63985 label_id = duk__stmt_label_site(comp_ctx, label_id);
63986 duk__add_label(comp_ctx,
63987 DUK_HTHREAD_STRING_EMPTY_STRING(thr),
63988 pc_at_entry /*pc_label*/,
63989 label_id);
63990 }
63991
63992 /*
63993 * Main switch for statement / source element type.
63994 */
63995
63996 switch (comp_ctx->curr_token.t) {
63997 case DUK_TOK_FUNCTION: {
63998 /*
63999 * Function declaration, function expression, or (non-standard)
64000 * function statement.
64001 *
64002 * The E5 specification only allows function declarations at
64003 * the top level (in "source elements"). An ExpressionStatement
64004 * is explicitly not allowed to begin with a "function" keyword
64005 * (E5 Section 12.4). Hence any non-error semantics for such
64006 * non-top-level statements are non-standard. Duktape semantics
64007 * for function statements are modelled after V8, see
64008 * test-dev-func-decl-outside-top.js.
64009 */
64010
64011#if defined(DUK_USE_NONSTD_FUNC_STMT)
64012 /* Lenient: allow function declarations outside top level in
64013 * non-strict mode but reject them in strict mode.
64014 */
64015 if (allow_source_elem || !comp_ctx->curr_func.is_strict)
64016#else /* DUK_USE_NONSTD_FUNC_STMT */
64017 /* Strict: never allow function declarations outside top level. */
64018 if (allow_source_elem)
64019#endif /* DUK_USE_NONSTD_FUNC_STMT */
64020 {
64021 /* FunctionDeclaration: not strictly a statement but handled as such.
64022 *
64023 * O(depth^2) parse count for inner functions is handled by recording a
64024 * lexer offset on the first compilation pass, so that the function can
64025 * be efficiently skipped on the second pass. This is encapsulated into
64026 * duk__parse_func_like_fnum().
64027 */
64028
64029 duk_int_t fnum;
64030
64031 DUK_DDD(DUK_DDDPRINT("function declaration statement"));
64032
64033 duk__advance(comp_ctx); /* eat 'function' */
64034 fnum = duk__parse_func_like_fnum(comp_ctx, 1 /*is_decl*/, 0 /*is_setget*/);
64035
64036 if (comp_ctx->curr_func.in_scanning) {
64037 duk_uarridx_t n;
64038 duk_hstring *h_funcname;
64039
64040 duk_get_prop_index(ctx, comp_ctx->curr_func.funcs_idx, fnum * 3);
64041 duk_get_prop_stridx(ctx, -1, DUK_STRIDX_NAME); /* -> [ ... func name ] */
64042 h_funcname = duk_get_hstring(ctx, -1);
64043 DUK_ASSERT(h_funcname != NULL);
64044
64045 DUK_DDD(DUK_DDDPRINT("register function declaration %!O in pass 1, fnum %ld",
64046 (duk_heaphdr *) h_funcname, (long) fnum));
64047 n = (duk_uarridx_t) duk_get_length(ctx, comp_ctx->curr_func.decls_idx);
64048 duk_push_hstring(ctx, h_funcname);
64049 duk_put_prop_index(ctx, comp_ctx->curr_func.decls_idx, n);
64050 duk_push_int(ctx, (duk_int_t) (DUK_DECL_TYPE_FUNC + (fnum << 8)));
64051 duk_put_prop_index(ctx, comp_ctx->curr_func.decls_idx, n + 1);
64052
64053 duk_pop_n(ctx, 2);
64054 }
64055
64056 /* no statement value (unlike function expression) */
64057 stmt_flags = 0;
64058 break;
64059 } else {
64060 DUK_ERROR_SYNTAX(thr, DUK_STR_FUNC_STMT_NOT_ALLOWED);
64061 }
64062 break;
64063 }
64064 case DUK_TOK_LCURLY: {
64065 DUK_DDD(DUK_DDDPRINT("block statement"));
64066 duk__advance(comp_ctx);
64067 duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/);
64068 /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */
64069 if (label_id >= 0) {
64070 duk__patch_jump_here(comp_ctx, pc_at_entry + 1); /* break jump */
64071 }
64072 stmt_flags = 0;
64073 break;
64074 }
64075 case DUK_TOK_CONST: {
64076 DUK_DDD(DUK_DDDPRINT("constant declaration statement"));
64077 duk__parse_var_stmt(comp_ctx, res, DUK__EXPR_FLAG_REQUIRE_INIT /*expr_flags*/);
64078 stmt_flags = DUK__HAS_TERM;
64079 break;
64080 }
64081 case DUK_TOK_VAR: {
64082 DUK_DDD(DUK_DDDPRINT("variable declaration statement"));
64083 duk__parse_var_stmt(comp_ctx, res, 0 /*expr_flags*/);
64084 stmt_flags = DUK__HAS_TERM;
64085 break;
64086 }
64087 case DUK_TOK_SEMICOLON: {
64088 /* empty statement with an explicit semicolon */
64089 DUK_DDD(DUK_DDDPRINT("empty statement"));
64090 stmt_flags = DUK__HAS_TERM;
64091 break;
64092 }
64093 case DUK_TOK_IF: {
64094 DUK_DDD(DUK_DDDPRINT("if statement"));
64095 duk__parse_if_stmt(comp_ctx, res);
64096 if (label_id >= 0) {
64097 duk__patch_jump_here(comp_ctx, pc_at_entry + 1); /* break jump */
64098 }
64099 stmt_flags = 0;
64100 break;
64101 }
64102 case DUK_TOK_DO: {
64103 /*
64104 * Do-while statement is mostly trivial, but there is special
64105 * handling for automatic semicolon handling (triggered by the
64106 * DUK__ALLOW_AUTO_SEMI_ALWAYS) flag related to a bug filed at:
64107 *
64108 * https://bugs.ecmascript.org/show_bug.cgi?id=8
64109 *
64110 * See doc/compiler.rst for details.
64111 */
64112 DUK_DDD(DUK_DDDPRINT("do statement"));
64113 DUK_ASSERT(label_id >= 0);
64114 duk__update_label_flags(comp_ctx,
64115 label_id,
64116 DUK_LABEL_FLAG_ALLOW_BREAK | DUK_LABEL_FLAG_ALLOW_CONTINUE);
64117 duk__parse_do_stmt(comp_ctx, res, pc_at_entry);
64118 stmt_flags = DUK__HAS_TERM | DUK__ALLOW_AUTO_SEMI_ALWAYS; /* DUK__ALLOW_AUTO_SEMI_ALWAYS workaround */
64119 break;
64120 }
64121 case DUK_TOK_WHILE: {
64122 DUK_DDD(DUK_DDDPRINT("while statement"));
64123 DUK_ASSERT(label_id >= 0);
64124 duk__update_label_flags(comp_ctx,
64125 label_id,
64126 DUK_LABEL_FLAG_ALLOW_BREAK | DUK_LABEL_FLAG_ALLOW_CONTINUE);
64127 duk__parse_while_stmt(comp_ctx, res, pc_at_entry);
64128 stmt_flags = 0;
64129 break;
64130 }
64131 case DUK_TOK_FOR: {
64132 /*
64133 * For/for-in statement is complicated to parse because
64134 * determining the statement type (three-part for vs. a
64135 * for-in) requires potential backtracking.
64136 *
64137 * See the helper for the messy stuff.
64138 */
64139 DUK_DDD(DUK_DDDPRINT("for/for-in statement"));
64140 DUK_ASSERT(label_id >= 0);
64141 duk__update_label_flags(comp_ctx,
64142 label_id,
64143 DUK_LABEL_FLAG_ALLOW_BREAK | DUK_LABEL_FLAG_ALLOW_CONTINUE);
64144 duk__parse_for_stmt(comp_ctx, res, pc_at_entry);
64145 stmt_flags = 0;
64146 break;
64147 }
64148 case DUK_TOK_CONTINUE:
64149 case DUK_TOK_BREAK: {
64150 DUK_DDD(DUK_DDDPRINT("break/continue statement"));
64151 duk__parse_break_or_continue_stmt(comp_ctx, res);
64152 stmt_flags = DUK__HAS_TERM | DUK__IS_TERMINAL;
64153 break;
64154 }
64155 case DUK_TOK_RETURN: {
64156 DUK_DDD(DUK_DDDPRINT("return statement"));
64157 duk__parse_return_stmt(comp_ctx, res);
64158 stmt_flags = DUK__HAS_TERM | DUK__IS_TERMINAL;
64159 break;
64160 }
64161 case DUK_TOK_WITH: {
64162 DUK_DDD(DUK_DDDPRINT("with statement"));
64163 comp_ctx->curr_func.with_depth++;
64164 duk__parse_with_stmt(comp_ctx, res);
64165 if (label_id >= 0) {
64166 duk__patch_jump_here(comp_ctx, pc_at_entry + 1); /* break jump */
64167 }
64168 comp_ctx->curr_func.with_depth--;
64169 stmt_flags = 0;
64170 break;
64171 }
64172 case DUK_TOK_SWITCH: {
64173 /*
64174 * The switch statement is pretty messy to compile.
64175 * See the helper for details.
64176 */
64177 DUK_DDD(DUK_DDDPRINT("switch statement"));
64178 DUK_ASSERT(label_id >= 0);
64179 duk__update_label_flags(comp_ctx,
64180 label_id,
64181 DUK_LABEL_FLAG_ALLOW_BREAK); /* don't allow continue */
64182 duk__parse_switch_stmt(comp_ctx, res, pc_at_entry);
64183 stmt_flags = 0;
64184 break;
64185 }
64186 case DUK_TOK_THROW: {
64187 DUK_DDD(DUK_DDDPRINT("throw statement"));
64188 duk__parse_throw_stmt(comp_ctx, res);
64189 stmt_flags = DUK__HAS_TERM | DUK__IS_TERMINAL;
64190 break;
64191 }
64192 case DUK_TOK_TRY: {
64193 DUK_DDD(DUK_DDDPRINT("try statement"));
64194 duk__parse_try_stmt(comp_ctx, res);
64195 stmt_flags = 0;
64196 break;
64197 }
64198 case DUK_TOK_DEBUGGER: {
64199 duk__advance(comp_ctx);
64200#if defined(DUK_USE_DEBUGGER_SUPPORT)
64201 DUK_DDD(DUK_DDDPRINT("debugger statement: debugging enabled, emit debugger opcode"));
64202 duk__emit_extraop_only(comp_ctx, DUK_EXTRAOP_DEBUGGER);
64203#else
64204 DUK_DDD(DUK_DDDPRINT("debugger statement: ignored"));
64205#endif
64206 stmt_flags = DUK__HAS_TERM;
64207 break;
64208 }
64209 default: {
64210 /*
64211 * Else, must be one of:
64212 * - ExpressionStatement, possibly a directive (String)
64213 * - LabelledStatement (Identifier followed by ':')
64214 *
64215 * Expressions beginning with 'function' keyword are covered by a case
64216 * above (such expressions are not allowed in standard E5 anyway).
64217 * Also expressions starting with '{' are interpreted as block
64218 * statements. See E5 Section 12.4.
64219 *
64220 * Directive detection is tricky; see E5 Section 14.1 on directive
64221 * prologue. A directive is an expression statement with a single
64222 * string literal and an explicit or automatic semicolon. Escape
64223 * characters are significant and no parens etc are allowed:
64224 *
64225 * 'use strict'; // valid 'use strict' directive
64226 * 'use\u0020strict'; // valid directive, not a 'use strict' directive
64227 * ('use strict'); // not a valid directive
64228 *
64229 * The expression is determined to consist of a single string literal
64230 * based on duk__expr_nud() and duk__expr_led() call counts. The string literal
64231 * of a 'use strict' directive is determined to lack any escapes based
64232 * num_escapes count from the lexer. Note that other directives may be
64233 * allowed to contain escapes, so a directive with escapes does not
64234 * terminate a directive prologue.
64235 *
64236 * We rely on the fact that the expression parser will not emit any
64237 * code for a single token expression. However, it will generate an
64238 * intermediate value which we will then successfully ignore.
64239 *
64240 * A similar approach is used for labels.
64241 */
64242
64243 duk_bool_t single_token;
64244
64245 DUK_DDD(DUK_DDDPRINT("expression statement"));
64246 duk__exprtop(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/);
64247
64248 single_token = (comp_ctx->curr_func.nud_count == 1 && /* one token */
64249 comp_ctx->curr_func.led_count == 0); /* no operators */
64250
64251 if (single_token &&
64252 comp_ctx->prev_token.t == DUK_TOK_IDENTIFIER &&
64253 comp_ctx->curr_token.t == DUK_TOK_COLON) {
64254 /*
64255 * Detected label
64256 */
64257
64258 duk_hstring *h_lab;
64259
64260 /* expected ival */
64261 DUK_ASSERT(res->t == DUK_IVAL_VAR);
64262 DUK_ASSERT(res->x1.t == DUK_ISPEC_VALUE);
64263 DUK_ASSERT(DUK_TVAL_IS_STRING(duk_get_tval(ctx, res->x1.valstack_idx)));
64264 h_lab = comp_ctx->prev_token.str1;
64265 DUK_ASSERT(h_lab != NULL);
64266
64267 DUK_DDD(DUK_DDDPRINT("explicit label site for label '%!O'",
64268 (duk_heaphdr *) h_lab));
64269
64270 duk__advance(comp_ctx); /* eat colon */
64271
64272 label_id = duk__stmt_label_site(comp_ctx, label_id);
64273
64274 duk__add_label(comp_ctx,
64275 h_lab,
64276 pc_at_entry /*pc_label*/,
64277 label_id);
64278
64279 /* a statement following a label cannot be a source element
64280 * (a function declaration).
64281 */
64282 allow_source_elem = 0;
64283
64284 DUK_DDD(DUK_DDDPRINT("label handled, retry statement parsing"));
64285 goto retry_parse;
64286 }
64287
64288 stmt_flags = 0;
64289
64290 if (dir_prol_at_entry && /* still in prologue */
64291 single_token && /* single string token */
64292 comp_ctx->prev_token.t == DUK_TOK_STRING) {
64293 /*
64294 * Detected a directive
64295 */
64296 duk_hstring *h_dir;
64297
64298 /* expected ival */
64299 DUK_ASSERT(res->t == DUK_IVAL_PLAIN);
64300 DUK_ASSERT(res->x1.t == DUK_ISPEC_VALUE);
64301 DUK_ASSERT(DUK_TVAL_IS_STRING(duk_get_tval(ctx, res->x1.valstack_idx)));
64302 h_dir = comp_ctx->prev_token.str1;
64303 DUK_ASSERT(h_dir != NULL);
64304
64305 DUK_DDD(DUK_DDDPRINT("potential directive: %!O", h_dir));
64306
64307 stmt_flags |= DUK__STILL_PROLOGUE;
64308
64309 /* Note: escaped characters differentiate directives */
64310
64311 if (comp_ctx->prev_token.num_escapes > 0) {
64312 DUK_DDD(DUK_DDDPRINT("directive contains escapes: valid directive "
64313 "but we ignore such directives"));
64314 } else {
64315 /*
64316 * The length comparisons are present to handle
64317 * strings like "use strict\u0000foo" as required.
64318 */
64319
64320 if (DUK_HSTRING_GET_BYTELEN(h_dir) == 10 &&
64321 DUK_STRNCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use strict", 10) == 0) {
64322#if defined(DUK_USE_STRICT_DECL)
64323 DUK_DDD(DUK_DDDPRINT("use strict directive detected: strict flag %ld -> %ld",
64324 (long) comp_ctx->curr_func.is_strict, (long) 1));
64325 comp_ctx->curr_func.is_strict = 1;
64326#else
64327 DUK_DDD(DUK_DDDPRINT("use strict detected but strict declarations disabled, ignoring"));
64328#endif
64329 } else if (DUK_HSTRING_GET_BYTELEN(h_dir) == 14 &&
64330 DUK_STRNCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), "use duk notail", 14) == 0) {
64331 DUK_DDD(DUK_DDDPRINT("use duk notail directive detected: notail flag %ld -> %ld",
64332 (long) comp_ctx->curr_func.is_notail, (long) 1));
64333 comp_ctx->curr_func.is_notail = 1;
64334 } else {
64335 DUK_DD(DUK_DDPRINT("unknown directive: '%!O', ignoring but not terminating "
64336 "directive prologue", (duk_hobject *) h_dir));
64337 }
64338 }
64339 } else {
64340 DUK_DDD(DUK_DDDPRINT("non-directive expression statement or no longer in prologue; "
64341 "prologue terminated if still active"));
64342 }
64343
64344 stmt_flags |= DUK__HAS_VAL | DUK__HAS_TERM;
64345 }
64346 } /* end switch (tok) */
64347
64348 /*
64349 * Statement value handling.
64350 *
64351 * Global code and eval code has an implicit return value
64352 * which comes from the last statement with a value
64353 * (technically a non-"empty" continuation, which is
64354 * different from an empty statement).
64355 *
64356 * Since we don't know whether a later statement will
64357 * override the value of the current statement, we need
64358 * to coerce the statement value to a register allocated
64359 * for implicit return values. In other cases we need
64360 * to coerce the statement value to a plain value to get
64361 * any side effects out (consider e.g. "foo.bar;").
64362 */
64363
64364 /* XXX: what about statements which leave a half-cooked value in 'res'
64365 * but have no stmt value? Any such statements?
64366 */
64367
64368 if (stmt_flags & DUK__HAS_VAL) {
64369 duk_reg_t reg_stmt_value = comp_ctx->curr_func.reg_stmt_value;
64370 if (reg_stmt_value >= 0) {
64371 duk__ivalue_toforcedreg(comp_ctx, res, reg_stmt_value);
64372 } else {
64373 duk__ivalue_toplain_ignore(comp_ctx, res);
64374 }
64375 } else {
64376 ;
64377 }
64378
64379 /*
64380 * Statement terminator check, including automatic semicolon
64381 * handling. After this step, 'curr_tok' should be the first
64382 * token after a possible statement terminator.
64383 */
64384
64385 if (stmt_flags & DUK__HAS_TERM) {
64386 if (comp_ctx->curr_token.t == DUK_TOK_SEMICOLON) {
64387 DUK_DDD(DUK_DDDPRINT("explicit semicolon terminates statement"));
64388 duk__advance(comp_ctx);
64389 } else {
64390 if (comp_ctx->curr_token.allow_auto_semi) {
64391 DUK_DDD(DUK_DDDPRINT("automatic semicolon terminates statement"));
64392 } else if (stmt_flags & DUK__ALLOW_AUTO_SEMI_ALWAYS) {
64393 /* XXX: make this lenience dependent on flags or strictness? */
64394 DUK_DDD(DUK_DDDPRINT("automatic semicolon terminates statement (allowed for compatibility "
64395 "even though no lineterm present before next token)"));
64396 } else {
64397 DUK_ERROR_SYNTAX(thr, DUK_STR_UNTERMINATED_STMT);
64398 }
64399 }
64400 } else {
64401 DUK_DDD(DUK_DDDPRINT("statement has no terminator"));
64402 }
64403
64404 /*
64405 * Directive prologue tracking.
64406 */
64407
64408 if (stmt_flags & DUK__STILL_PROLOGUE) {
64409 DUK_DDD(DUK_DDDPRINT("setting in_directive_prologue"));
64410 comp_ctx->curr_func.in_directive_prologue = 1;
64411 }
64412
64413 /*
64414 * Cleanups (all statement parsing flows through here).
64415 *
64416 * Pop label site and reset labels. Reset 'next temp' to value at
static void block(LexState *ls)
#define notail(x)

◆ duk__parse_stmts()

DUK_LOCAL_DECL void duk__parse_stmts ( duk_compiler_ctx * comp_ctx,
duk_bool_t allow_source_elem,
duk_bool_t expect_eof )

Definition at line 64433 of file duktape-1.8.0/src/duktape.c.

64450 {
64451 duk_hthread *thr = comp_ctx->thr;
64452 duk_context *ctx = (duk_context *) thr;
64453 duk_ivalue res_alloc;
64454 duk_ivalue *res = &res_alloc;
64455
64456 /* Setup state. Initial ivalue is 'undefined'. */
64457
64459
64460 /* XXX: 'res' setup can be moved to function body level; in fact, two 'res'
64461 * intermediate values suffice for parsing of each function. Nesting is needed
64462 * for nested functions (which may occur inside expressions).
64463 */
64464
64465 DUK_MEMZERO(&res_alloc, sizeof(res_alloc));
64466 res->t = DUK_IVAL_PLAIN;
64467 res->x1.t = DUK_ISPEC_VALUE;
64468 res->x1.valstack_idx = duk_get_top(ctx);
64469 res->x2.valstack_idx = res->x1.valstack_idx + 1;
64470 duk_push_undefined(ctx);
64471 duk_push_undefined(ctx);
64472
64473 /* Parse statements until a closing token (EOF or '}') is found. */
64474
64475 for (;;) {
64476 /* Check whether statement list ends. */
64477
64478 if (expect_eof) {
64479 if (comp_ctx->curr_token.t == DUK_TOK_EOF) {
64480 break;
64481 }
64482 } else {
64483 if (comp_ctx->curr_token.t == DUK_TOK_RCURLY) {
64484 break;
64485 }
64486 }
64487
#define DUK__PARSE_STATEMENTS_SLOTS
#define DUK_TOK_EOF

Referenced by duk__parse_func_body().

◆ duk__parse_string()

DUK_LOCAL duk_ret_t duk__parse_string ( duk_context * ctx,
const char * str )

Definition at line 24995 of file duktape-1.8.0/src/duktape.c.

25012 {
25013 /* XXX: there is a small risk here: because the ISO 8601 parser is
25014 * very loose, it may end up parsing some datetime values which
25015 * would be better parsed with a platform specific parser.
25016 */
25017
25018 DUK_ASSERT(str != NULL);
25019 DUK_DDD(DUK_DDDPRINT("parse datetime from string '%s'", (const char *) str));
25020
25021 if (duk__parse_string_iso8601_subset(ctx, str) != 0) {
25022 return 1;
25023 }
DUK_LOCAL duk_bool_t duk__parse_string_iso8601_subset(duk_context *ctx, const char *str)

References duk__parse_string_iso8601_subset(), DUK_ASSERT, DUK_DDD, DUK_DDDPRINT, and NULL.

◆ duk__parse_string_iso8601_subset()

DUK_LOCAL duk_bool_t duk__parse_string_iso8601_subset ( duk_context * ctx,
const char * str )

Definition at line 24800 of file duktape-1.8.0/src/duktape.c.

24817 {
24820 duk_double_t d;
24821 const duk_uint8_t *p;
24822 duk_small_uint_t part_idx = 0;
24823 duk_int_t accum = 0;
24824 duk_small_uint_t ndigits = 0;
24825 duk_bool_t neg_year = 0;
24826 duk_bool_t neg_tzoffset = 0;
24829
24830 /* During parsing, month and day are one-based; set defaults here. */
24831 DUK_MEMZERO(parts, sizeof(parts));
24832 DUK_ASSERT(parts[DUK_DATE_IDX_YEAR] == 0); /* don't care value, year is mandatory */
24833 parts[DUK_DATE_IDX_MONTH] = 1;
24834 parts[DUK_DATE_IDX_DAY] = 1;
24835
24836 /* Special handling for year sign. */
24837 p = (const duk_uint8_t *) str;
24838 ch = p[0];
24839 if (ch == DUK_ASC_PLUS) {
24840 p++;
24841 } else if (ch == DUK_ASC_MINUS) {
24842 neg_year = 1;
24843 p++;
24844 }
24845
24846 for (;;) {
24847 ch = *p++;
24848 DUK_DDD(DUK_DDDPRINT("parsing, part_idx=%ld, char=%ld ('%c')",
24849 (long) part_idx, (long) ch,
24850 (int) ((ch >= 0x20 && ch <= 0x7e) ? ch : DUK_ASC_QUESTION)));
24851
24852 if (ch >= DUK_ASC_0 && ch <= DUK_ASC_9) {
24853 if (ndigits >= 9) {
24854 DUK_DDD(DUK_DDDPRINT("too many digits -> reject"));
24855 goto reject;
24856 }
24857 if (part_idx == DUK__PI_MILLISECOND /*msec*/ && ndigits >= 3) {
24858 /* ignore millisecond fractions after 3 */
24859 } else {
24860 accum = accum * 10 + ((duk_int_t) ch) - ((duk_int_t) DUK_ASC_0) + 0x00;
24861 ndigits++;
24862 }
24863 } else {
24864 duk_uint_fast32_t match_val;
24865 duk_small_int_t sep_idx;
24866
24867 if (ndigits <= 0) {
24868 goto reject;
24869 }
24870 if (part_idx == DUK__PI_MILLISECOND) {
24871 /* complete the millisecond field */
24872 while (ndigits < 3) {
24873 accum *= 10;
24874 ndigits++;
24875 }
24876 }
24877 parts[part_idx] = accum;
24878 DUK_DDD(DUK_DDDPRINT("wrote part %ld -> value %ld", (long) part_idx, (long) accum));
24879
24880 accum = 0;
24881 ndigits = 0;
24882
24883 for (i = 0; i < (duk_small_uint_t) (sizeof(duk__parse_iso8601_seps) / sizeof(duk_uint8_t)); i++) {
24884 if (duk__parse_iso8601_seps[i] == ch) {
24885 break;
24886 }
24887 }
24888 if (i == (duk_small_uint_t) (sizeof(duk__parse_iso8601_seps) / sizeof(duk_uint8_t))) {
24889 DUK_DDD(DUK_DDDPRINT("separator character doesn't match -> reject"));
24890 goto reject;
24891 }
24892
24893 sep_idx = i;
24894 match_val = (1UL << part_idx) + (1UL << (sep_idx + 9)); /* match against rule part/sep bits */
24895
24896 for (i = 0; i < (duk_small_uint_t) (sizeof(duk__parse_iso8601_control) / sizeof(duk_uint32_t)); i++) {
24898 duk_small_uint_t nextpart;
24899 duk_small_uint_t cflags;
24900
24901 DUK_DDD(DUK_DDDPRINT("part_idx=%ld, sep_idx=%ld, match_val=0x%08lx, considering rule=0x%08lx",
24902 (long) part_idx, (long) sep_idx,
24903 (unsigned long) match_val, (unsigned long) rule));
24904
24905 if ((rule & match_val) != match_val) {
24906 continue;
24907 }
24908
24909 DUK__UNPACK_RULE(rule, nextpart, cflags);
24910
24911 DUK_DDD(DUK_DDDPRINT("rule match -> part_idx=%ld, sep_idx=%ld, match_val=0x%08lx, "
24912 "rule=0x%08lx -> nextpart=%ld, cflags=0x%02lx",
24913 (long) part_idx, (long) sep_idx,
24914 (unsigned long) match_val, (unsigned long) rule,
24915 (long) nextpart, (unsigned long) cflags));
24916
24917 if (cflags & DUK__CF_NEG) {
24918 neg_tzoffset = 1;
24919 }
24920
24921 if (cflags & DUK__CF_ACCEPT) {
24922 goto accept;
24923 }
24924
24925 if (cflags & DUK__CF_ACCEPT_NUL) {
24926 DUK_ASSERT(*(p - 1) != (char) 0);
24927 if (*p == DUK_ASC_NUL) {
24928 goto accept;
24929 }
24930 goto reject;
24931 }
24932
24933 part_idx = nextpart;
24934 break;
24935 } /* rule match */
24936
24937 if (i == (duk_small_uint_t) (sizeof(duk__parse_iso8601_control) / sizeof(duk_uint32_t))) {
24938 DUK_DDD(DUK_DDDPRINT("no rule matches -> reject"));
24939 goto reject;
24940 }
24941
24942 if (ch == 0) {
24943 /* This shouldn't be necessary, but check just in case
24944 * to avoid any chance of overruns.
24945 */
24946 DUK_DDD(DUK_DDDPRINT("NUL after rule matching (should not happen) -> reject"));
24947 goto reject;
24948 }
24949 } /* if-digit-else-ctrl */
24950 } /* char loop */
24951
24952 /* We should never exit the loop above. */
24954
24955 reject:
24956 DUK_DDD(DUK_DDDPRINT("reject"));
24957 return 0;
24958
24959 accept:
24960 DUK_DDD(DUK_DDDPRINT("accept"));
24961
24962 /* Apply timezone offset to get the main parts in UTC */
24963 if (neg_year) {
24964 parts[DUK__PI_YEAR] = -parts[DUK__PI_YEAR];
24965 }
24966 if (neg_tzoffset) {
24967 parts[DUK__PI_HOUR] += parts[DUK__PI_TZHOUR];
24968 parts[DUK__PI_MINUTE] += parts[DUK__PI_TZMINUTE];
24969 } else {
24970 parts[DUK__PI_HOUR] -= parts[DUK__PI_TZHOUR];
24971 parts[DUK__PI_MINUTE] -= parts[DUK__PI_TZMINUTE];
24972 }
24973 parts[DUK__PI_MONTH] -= 1; /* zero-based month */
24974 parts[DUK__PI_DAY] -= 1; /* zero-based day */
DUK_LOCAL const duk_uint32_t duk__parse_iso8601_control[]
#define DUK__PI_TZMINUTE
#define DUK_ASC_NUL
#define DUK__CF_ACCEPT_NUL
#define DUK__PI_HOUR
#define DUK__UNPACK_RULE(rule, var_nextidx, var_flags)
#define DUK__PI_MONTH
DUK_LOCAL const duk_uint8_t duk__parse_iso8601_seps[]
#define DUK__PI_TZHOUR
#define DUK__CF_ACCEPT
#define DUK__NUM_ISO8601_PARSER_PARTS
#define DUK__PI_YEAR
#define DUK__CF_NEG
#define DUK_ASC_QUESTION
#define DUK__PI_MINUTE
#define DUK__PI_DAY
#define DUK__PI_MILLISECOND

Referenced by duk__parse_string().

◆ duk__parse_switch_stmt()

DUK_LOCAL_DECL void duk__parse_switch_stmt ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res,
duk_int_t pc_label_site )

Definition at line 63141 of file duktape-1.8.0/src/duktape.c.

63150 :
63151 DUK_DDD(DUK_DDDPRINT("end parsing a for/for-in statement"));
63152 return;
63153
63154 syntax_error:
63156}
63157
63158DUK_LOCAL void duk__parse_switch_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site) {
63159 duk_hthread *thr = comp_ctx->thr;
63160 duk_reg_t temp_at_loop;
63161 duk_regconst_t rc_switch; /* reg/const for switch value */
63162 duk_regconst_t rc_case; /* reg/const for case value */
63163 duk_reg_t reg_temp; /* general temp register */
63164 duk_int_t pc_prevcase = -1;
63165 duk_int_t pc_prevstmt = -1;
63166 duk_int_t pc_default = -1; /* -1 == not set, -2 == pending (next statement list) */
63167
63168 /* Note: negative pc values are ignored when patching jumps, so no explicit checks needed */
63169
63170 /*
63171 * Switch is pretty complicated because of several conflicting concerns:
63172 *
63173 * - Want to generate code without an intermediate representation,
63174 * i.e., in one go
63175 *
63176 * - Case selectors are expressions, not values, and may thus e.g. throw
63177 * exceptions (which causes evaluation order concerns)
63178 *
63179 * - Evaluation semantics of case selectors and default clause need to be
63180 * carefully implemented to provide correct behavior even with case value
63181 * side effects
63182 *
63183 * - Fall through case and default clauses; avoiding dead JUMPs if case
63184 * ends with an unconditional jump (a break or a continue)
63185 *
63186 * - The same case value may occur multiple times, but evaluation rules
63187 * only process the first match before switching to a "propagation" mode
63188 * where case values are no longer evaluated
63189 *
63190 * See E5 Section 12.11. Also see doc/compiler.rst for compilation
63191 * discussion.
63192 */
63193
63194 duk__advance(comp_ctx);
63196 rc_switch = duk__exprtop_toregconst(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/);
63199
63200 DUK_DDD(DUK_DDDPRINT("switch value in register %ld", (long) rc_switch));
63201
63202 temp_at_loop = DUK__GETTEMP(comp_ctx);
63203
63204 for (;;) {
63205 duk_int_t num_stmts;
63206 duk_small_int_t tok;
63207
63208 /* sufficient for keeping temp reg numbers in check */
63209 DUK__SETTEMP(comp_ctx, temp_at_loop);
63210
63211 if (comp_ctx->curr_token.t == DUK_TOK_RCURLY) {
63212 break;
63213 }
63214
63215 /*
63216 * Parse a case or default clause.
63217 */
63218
63219 if (comp_ctx->curr_token.t == DUK_TOK_CASE) {
63220 /*
63221 * Case clause.
63222 *
63223 * Note: cannot use reg_case as a temp register (for SEQ target)
63224 * because it may be a constant.
63225 */
63226
63227 duk__patch_jump_here(comp_ctx, pc_prevcase); /* chain jumps for case
63228 * evaluation and checking
63229 */
63230
63231 duk__advance(comp_ctx);
63232 rc_case = duk__exprtop_toregconst(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/);
63234
63235 reg_temp = DUK__ALLOCTEMP(comp_ctx);
63236 duk__emit_a_b_c(comp_ctx,
63237 DUK_OP_SEQ,
63238 (duk_regconst_t) reg_temp,
63239 rc_switch,
63240 rc_case);
63241 duk__emit_if_true_skip(comp_ctx, (duk_regconst_t) reg_temp);
63242
63243 /* jump to next case clause */
63244 pc_prevcase = duk__emit_jump_empty(comp_ctx); /* no match, next case */
63245
63246 /* statements go here (if any) on next loop */
63247 } else if (comp_ctx->curr_token.t == DUK_TOK_DEFAULT) {
63248 /*
63249 * Default clause.
63250 */
63251
63252 if (pc_default >= 0) {
63253 goto syntax_error;
63254 }
63255 duk__advance(comp_ctx);
63257
63258 /* Fix for https://github.com/svaarala/duktape/issues/155:
63259 * If 'default' is first clause (detected by pc_prevcase < 0)
63260 * we need to ensure we stay in the matching chain.
63261 */
63262 if (pc_prevcase < 0) {
63263 DUK_DD(DUK_DDPRINT("default clause is first, emit prevcase jump"));
63264 pc_prevcase = duk__emit_jump_empty(comp_ctx);
63265 }
63266
63267 /* default clause matches next statement list (if any) */
63268 pc_default = -2;
63269 } else {
63270 /* Code is not accepted before the first case/default clause */
63271 goto syntax_error;
63272 }
63273
63274 /*
63275 * Parse code after the clause. Possible terminators are
63276 * 'case', 'default', and '}'.
63277 *
63278 * Note that there may be no code at all, not even an empty statement,
63279 * between case clauses. This must be handled just like an empty statement
63280 * (omitting seemingly pointless JUMPs), to avoid situations like
63281 * test-bug-case-fallthrough.js.
63282 */
63283
63284 num_stmts = 0;
63285 if (pc_default == -2) {
63286 pc_default = duk__get_current_pc(comp_ctx);
63287 }
63288
63289 /* Note: this is correct even for default clause statements:
63290 * they participate in 'fall-through' behavior even if the
63291 * default clause is in the middle.
63292 */
63293 duk__patch_jump_here(comp_ctx, pc_prevstmt); /* chain jumps for 'fall-through'
63294 * after a case matches.
63295 */
63296
63297 for (;;) {
63298 tok = comp_ctx->curr_token.t;
63299 if (tok == DUK_TOK_CASE || tok == DUK_TOK_DEFAULT ||
63300 tok == DUK_TOK_RCURLY) {
63301 break;
63302 }
63303 num_stmts++;
63304 duk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/);
63305 }
63306
63307 /* fall-through jump to next code of next case (backpatched) */
63308 pc_prevstmt = duk__emit_jump_empty(comp_ctx);
63309
63310 /* XXX: would be nice to omit this jump when the jump is not
63311 * reachable, at least in the obvious cases (such as the case
63312 * ending with a 'break'.
63313 *
63314 * Perhaps duk__parse_stmt() could provide some info on whether
63315 * the statement is a "dead end"?
63316 *
63317 * If implemented, just set pc_prevstmt to -1 when not needed.
63318 */
63319 }
63320
63321 DUK_ASSERT(comp_ctx->curr_token.t == DUK_TOK_RCURLY);
63322 duk__advance(comp_ctx);
63323
63324 /* default case control flow patchup; note that if pc_prevcase < 0
63325 * (i.e. no case clauses), control enters default case automatically.
63326 */
63327 if (pc_default >= 0) {
63328 /* default case exists: go there if no case matches */
63329 duk__patch_jump(comp_ctx, pc_prevcase, pc_default);
63330 } else {
63331 /* default case does not exist, or no statements present
63332 * after default case: finish case evaluation
63333 */
63334 duk__patch_jump_here(comp_ctx, pc_prevcase);
63335 }
63336
63337 /* fall-through control flow patchup; note that pc_prevstmt may be
63338 * < 0 (i.e. no case clauses), in which case this is a no-op.
#define DUK_TOK_DEFAULT
#define DUK_TOK_CASE
#define DUK_STR_INVALID_FOR
DUK_LOCAL_DECL void duk__parse_switch_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site)

◆ duk__parse_throw_stmt()

DUK_LOCAL_DECL void duk__parse_throw_stmt ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res )

Definition at line 63602 of file duktape-1.8.0/src/duktape.c.

◆ duk__parse_try_stmt()

DUK_LOCAL_DECL void duk__parse_try_stmt ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res )

Definition at line 63619 of file duktape-1.8.0/src/duktape.c.

63619 {
63620 duk_reg_t reg_val;
63621
63622 duk__advance(comp_ctx); /* eat 'throw' */
63623
63624 /* Unlike break/continue, throw statement does not allow an empty value. */
63625
63626 if (comp_ctx->curr_token.lineterm) {
63628 }
63629
63630 reg_val = duk__exprtop_toreg(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/);
63631 duk__emit_extraop_bc(comp_ctx,
63633 (duk_regconst_t) reg_val);
63634}
63635
63637 duk_hthread *thr = comp_ctx->thr;
63638 duk_context *ctx = (duk_context *) thr;
63639 duk_reg_t reg_catch; /* reg_catch+0 and reg_catch+1 are reserved for TRYCATCH */
63640 duk_regconst_t rc_varname = 0;
63641 duk_small_uint_t trycatch_flags = 0;
63642 duk_int_t pc_ldconst = -1;
63643 duk_int_t pc_trycatch = -1;
63644 duk_int_t pc_catch = -1;
63645 duk_int_t pc_finally = -1;
63646
63647 DUK_UNREF(res);
63648
63649 /*
63650 * See the following documentation for discussion:
63651 *
63652 * doc/execution.rst: control flow details
63653 *
63654 * Try, catch, and finally "parts" are Blocks, not Statements, so
63655 * they must always be delimited by curly braces. This is unlike e.g.
63656 * the if statement, which accepts any Statement. This eliminates any
63657 * questions of matching parts of nested try statements. The Block
63658 * parsing is implemented inline here (instead of calling out).
63659 *
63660 * Finally part has a 'let scoped' variable, which requires a few kinks
63661 * here.
63662 */
63663
63664 comp_ctx->curr_func.catch_depth++;
63665
63666 duk__advance(comp_ctx); /* eat 'try' */
63667
63668 reg_catch = DUK__ALLOCTEMPS(comp_ctx, 2);
63669
63670 /* The target for this LDCONST may need output shuffling, but we assume
63671 * that 'pc_ldconst' will be the LDCONST that we can patch later. This
63672 * should be the case because there's no input shuffling. (If there's
63673 * no catch clause, this LDCONST will be replaced with a NOP.)
63674 */
63675 pc_ldconst = duk__get_current_pc(comp_ctx);
63676 duk__emit_a_bc(comp_ctx, DUK_OP_LDCONST, reg_catch, 0 /*patched later*/);
63677
63678 pc_trycatch = duk__get_current_pc(comp_ctx);
63679 duk__emit_invalid(comp_ctx); /* TRYCATCH, cannot emit now (not enough info) */
63680 duk__emit_invalid(comp_ctx); /* jump for 'catch' case */
63681 duk__emit_invalid(comp_ctx); /* jump for 'finally' case or end (if no finally) */
63682
63683 /* try part */
63685 duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/);
63686 /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */
63687 duk__emit_extraop_only(comp_ctx,
63689
63690 if (comp_ctx->curr_token.t == DUK_TOK_CATCH) {
63691 /*
63692 * The catch variable must be updated to reflect the new allocated
63693 * register for the duration of the catch clause. We need to store
63694 * and restore the original value for the varmap entry (if any).
63695 */
63696
63697 /*
63698 * Note: currently register bindings must be fixed for the entire
63699 * function. So, even though the catch variable is in a register
63700 * we know, we must use an explicit environment record and slow path
63701 * accesses to read/write the catch binding to make closures created
63702 * within the catch clause work correctly. This restriction should
63703 * be fixable (at least in common cases) later.
63704 *
63705 * See: test-bug-catch-binding-2.js.
63706 *
63707 * XXX: improve to get fast path access to most catch clauses.
63708 */
63709
63710 duk_hstring *h_var;
63711 duk_int_t varmap_value; /* for storing/restoring the varmap binding for catch variable */
63712
63713 DUK_DDD(DUK_DDDPRINT("stack top at start of catch clause: %ld", (long) duk_get_top(ctx)));
63714
63715 trycatch_flags |= DUK_BC_TRYCATCH_FLAG_HAVE_CATCH;
63716
63717 pc_catch = duk__get_current_pc(comp_ctx);
63718
63719 duk__advance(comp_ctx);
63721
63722 if (comp_ctx->curr_token.t != DUK_TOK_IDENTIFIER) {
63723 /* Identifier, i.e. don't allow reserved words */
63724 goto syntax_error;
63725 }
63726 h_var = comp_ctx->curr_token.str1;
63727 DUK_ASSERT(h_var != NULL);
63728
63729 duk_push_hstring(ctx, h_var); /* keep in on valstack, use borrowed ref below */
63730
63731 if (comp_ctx->curr_func.is_strict &&
63732 ((h_var == DUK_HTHREAD_STRING_EVAL(thr)) ||
63733 (h_var == DUK_HTHREAD_STRING_LC_ARGUMENTS(thr)))) {
63734 DUK_DDD(DUK_DDDPRINT("catch identifier 'eval' or 'arguments' in strict mode -> SyntaxError"));
63735 goto syntax_error;
63736 }
63737
63738 duk_dup_top(ctx);
63739 rc_varname = duk__getconst(comp_ctx);
63740 DUK_DDD(DUK_DDDPRINT("catch clause, rc_varname=0x%08lx (%ld)",
63741 (unsigned long) rc_varname, (long) rc_varname));
63742
63743 duk__advance(comp_ctx);
63745
63747
63748 DUK_DDD(DUK_DDDPRINT("varmap before modifying for catch clause: %!iT",
63749 (duk_tval *) duk_get_tval(ctx, comp_ctx->curr_func.varmap_idx)));
63750
63751 duk_dup_top(ctx);
63752 duk_get_prop(ctx, comp_ctx->curr_func.varmap_idx);
63753 if (duk_is_undefined(ctx, -1)) {
63754 varmap_value = -2;
63755 } else if (duk_is_null(ctx, -1)) {
63756 varmap_value = -1;
63757 } else {
63758 DUK_ASSERT(duk_is_number(ctx, -1));
63759 varmap_value = duk_get_int(ctx, -1);
63760 DUK_ASSERT(varmap_value >= 0);
63761 }
63762 duk_pop(ctx);
63763
63764#if 0
63765 /* It'd be nice to do something like this - but it doesn't
63766 * work for closures created inside the catch clause.
63767 */
63768 duk_dup_top(ctx);
63769 duk_push_int(ctx, (duk_int_t) (reg_catch + 0));
63770 duk_put_prop(ctx, comp_ctx->curr_func.varmap_idx);
63771#endif
63772 duk_dup_top(ctx);
63773 duk_push_null(ctx);
63774 duk_put_prop(ctx, comp_ctx->curr_func.varmap_idx);
63775
63776 duk__emit_a_bc(comp_ctx,
63778 (duk_regconst_t) (reg_catch + 0) /*value*/,
63779 rc_varname /*varname*/);
63780
63781 DUK_DDD(DUK_DDDPRINT("varmap before parsing catch clause: %!iT",
63782 (duk_tval *) duk_get_tval(ctx, comp_ctx->curr_func.varmap_idx)));
63783
63784 duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/);
63785 /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */
63786
63787 if (varmap_value == -2) {
63788 /* not present */
63789 duk_del_prop(ctx, comp_ctx->curr_func.varmap_idx);
63790 } else {
63791 if (varmap_value == -1) {
63792 duk_push_null(ctx);
63793 } else {
63794 DUK_ASSERT(varmap_value >= 0);
63795 duk_push_int(ctx, varmap_value);
63796 }
63797 duk_put_prop(ctx, comp_ctx->curr_func.varmap_idx);
63798 }
63799 /* varname is popped by above code */
63800
63801 DUK_DDD(DUK_DDDPRINT("varmap after restore catch clause: %!iT",
63802 (duk_tval *) duk_get_tval(ctx, comp_ctx->curr_func.varmap_idx)));
63803
63804 duk__emit_extraop_only(comp_ctx,
63806
63807 /*
63808 * XXX: for now, indicate that an expensive catch binding
63809 * declarative environment is always needed. If we don't
63810 * need it, we don't need the const_varname either.
63811 */
63812
63813 trycatch_flags |= DUK_BC_TRYCATCH_FLAG_CATCH_BINDING;
63814
63815 DUK_DDD(DUK_DDDPRINT("stack top at end of catch clause: %ld", (long) duk_get_top(ctx)));
63816 }
63817
63818 if (comp_ctx->curr_token.t == DUK_TOK_FINALLY) {
63819 trycatch_flags |= DUK_BC_TRYCATCH_FLAG_HAVE_FINALLY;
63820
63821 pc_finally = duk__get_current_pc(comp_ctx);
63822
63823 duk__advance(comp_ctx);
63824
63826 duk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/);
63827 /* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */
63828 duk__emit_extraop_b(comp_ctx,
63830 reg_catch); /* rethrow */
63831 }
63832
63833 if (!(trycatch_flags & DUK_BC_TRYCATCH_FLAG_HAVE_CATCH) &&
63834 !(trycatch_flags & DUK_BC_TRYCATCH_FLAG_HAVE_FINALLY)) {
63835 /* must have catch and/or finally */
63836 goto syntax_error;
63837 }
63838
63839 /* If there's no catch block, rc_varname will be 0 and duk__patch_trycatch()
63840 * will replace the LDCONST with a NOP. For any actual constant (including
63841 * constant 0) the DUK__CONST_MARKER flag will be set in rc_varname.
63842 */
63843
63844 duk__patch_trycatch(comp_ctx,
63845 pc_ldconst,
63846 pc_trycatch,
63847 reg_catch,
63848 rc_varname,
63849 trycatch_flags);
63850
63851 if (trycatch_flags & DUK_BC_TRYCATCH_FLAG_HAVE_CATCH) {
63852 DUK_ASSERT(pc_catch >= 0);
#define DUK_TOK_FINALLY
DUK_LOCAL_DECL void duk__parse_try_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res)
DUK_EXTERNAL duk_int_t duk_get_int(duk_context *ctx, duk_idx_t index)
DUK_LOCAL_DECL void duk__emit_invalid(duk_compiler_ctx *comp_ctx)
DUK_LOCAL_DECL void duk__patch_trycatch(duk_compiler_ctx *comp_ctx, duk_int_t ldconst_pc, duk_int_t trycatch_pc, duk_regconst_t reg_catch, duk_regconst_t const_varname, duk_small_uint_t flags)
#define DUK_TOK_CATCH
DUK_LOCAL_DECL void duk__emit_extraop_b(duk_compiler_ctx *comp_ctx, duk_small_uint_t extraop_flags, duk_regconst_t b)
#define DUK_STR_INVALID_THROW

References duk_compiler_ctx::curr_token, duk__advance(), DUK__BP_FOR_EXPR, duk__emit_extraop_bc(), duk__exprtop_toreg(), DUK_ERROR_SYNTAX, DUK_EXTRAOP_THROW, DUK_STR_INVALID_THROW, duk_token::lineterm, and duk_compiler_ctx::thr.

◆ duk__parse_var_decl()

DUK_LOCAL_DECL void duk__parse_var_decl ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res,
duk_small_uint_t expr_flags,
duk_reg_t * out_reg_varbind,
duk_regconst_t * out_rc_varname )

Definition at line 62691 of file duktape-1.8.0/src/duktape.c.

62699 :
62700 *
62701 * If register bound: out_reg_varbind >= 0, out_rc_varname == 0 (ignore)
62702 * If not register bound: out_reg_varbind < 0, out_rc_varname >= 0
62703 *
62704 * These allow the caller to use the variable for further assignment, e.g.
62705 * as is done in 'for-in' parsing.
62706 */
62707
62708DUK_LOCAL void duk__parse_var_decl(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t expr_flags, duk_reg_t *out_reg_varbind, duk_regconst_t *out_rc_varname) {
62709 duk_hthread *thr = comp_ctx->thr;
62710 duk_context *ctx = (duk_context *) thr;
62711 duk_hstring *h_varname;
62712 duk_reg_t reg_varbind;
62713 duk_regconst_t rc_varname;
62714
62715 /* assume 'var' has been eaten */
62716
62717 /* Note: Identifier rejects reserved words */
62718 if (comp_ctx->curr_token.t != DUK_TOK_IDENTIFIER) {
62719 goto syntax_error;
62720 }
62721 h_varname = comp_ctx->curr_token.str1;
62722
62723 DUK_ASSERT(h_varname != NULL);
62724
62725 /* strict mode restrictions (E5 Section 12.2.1) */
62726 if (duk__hstring_is_eval_or_arguments_in_strict_mode(comp_ctx, h_varname)) {
62727 goto syntax_error;
62728 }
62729
62730 /* register declarations in first pass */
62731 if (comp_ctx->curr_func.in_scanning) {
62732 duk_uarridx_t n;
62733 DUK_DDD(DUK_DDDPRINT("register variable declaration %!O in pass 1",
62734 (duk_heaphdr *) h_varname));
62735 n = (duk_uarridx_t) duk_get_length(ctx, comp_ctx->curr_func.decls_idx);
62736 duk_push_hstring(ctx, h_varname);
62737 duk_put_prop_index(ctx, comp_ctx->curr_func.decls_idx, n);
62738 duk_push_int(ctx, DUK_DECL_TYPE_VAR + (0 << 8));
62739 duk_put_prop_index(ctx, comp_ctx->curr_func.decls_idx, n + 1);
62740 }
62741
62742 duk_push_hstring(ctx, h_varname); /* push before advancing to keep reachable */
62743
62744 /* register binding lookup is based on varmap (even in first pass) */
62745 duk_dup_top(ctx);
62746 (void) duk__lookup_lhs(comp_ctx, &reg_varbind, &rc_varname);
62747
62748 duk__advance(comp_ctx); /* eat identifier */
62749
62750 if (comp_ctx->curr_token.t == DUK_TOK_EQUALSIGN) {
62751 duk__advance(comp_ctx);
62752
62753 DUK_DDD(DUK_DDDPRINT("vardecl, assign to '%!O' -> reg_varbind=%ld, rc_varname=%ld",
62754 (duk_heaphdr *) h_varname, (long) reg_varbind, (long) rc_varname));
62755
62756 duk__exprtop(comp_ctx, res, DUK__BP_COMMA | expr_flags /*rbp_flags*/); /* AssignmentExpression */
62757
62758 if (reg_varbind >= 0) {
62759 duk__ivalue_toforcedreg(comp_ctx, res, reg_varbind);
62760 } else {
62761 duk_reg_t reg_val;
62762 reg_val = duk__ivalue_toreg(comp_ctx, res);
62763 duk__emit_a_bc(comp_ctx,
62765 (duk_regconst_t) reg_val,
62766 rc_varname);
62767 }
static void assignment(LexState *ls, struct LHS_assign *lh, int nvars)

References duk_compiler_ctx::curr_func, duk_compiler_ctx::curr_token, duk_compiler_func::decls_idx, duk__advance(), DUK__BP_COMMA, duk__emit_a_bc(), DUK__EMIT_FLAG_A_IS_SOURCE, duk__exprtop(), duk__hstring_is_eval_or_arguments_in_strict_mode(), duk__ivalue_toforcedreg(), duk__ivalue_toreg(), duk__lookup_lhs(), DUK_ASSERT, DUK_DDD, DUK_DDDPRINT, DUK_DECL_TYPE_VAR, duk_dup_top(), duk_get_length(), DUK_OP_PUTVAR, duk_push_hstring(), duk_push_int(), duk_put_prop_index(), DUK_TOK_EQUALSIGN, DUK_TOK_IDENTIFIER, duk_compiler_func::in_scanning, NULL, duk_token::str1, duk_token::t, and duk_compiler_ctx::thr.

Referenced by duk__parse_for_stmt().

◆ duk__parse_var_stmt()

DUK_LOCAL_DECL void duk__parse_var_stmt ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res,
duk_small_uint_t expr_flags )

Definition at line 62769 of file duktape-1.8.0/src/duktape.c.

62769 {
62770 /* Used for minimal 'const': initializer required. */
62771 goto syntax_error;
62772 }
62773 }
62774
62775 duk_pop(ctx); /* pop varname */
62776
62777 *out_rc_varname = rc_varname;
62778 *out_reg_varbind = reg_varbind;
62779
62780 return;
62781
62782 syntax_error:
62784}
#define DUK_STR_INVALID_VAR_DECLARATION

◆ duk__parse_while_stmt()

DUK_LOCAL_DECL void duk__parse_while_stmt ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res,
duk_int_t pc_label_site )

Definition at line 63414 of file duktape-1.8.0/src/duktape.c.

63431 {
63432 duk_reg_t temp_reset;
63433 duk_regconst_t rc_cond;
63434 duk_int_t pc_start;
63435 duk_int_t pc_jump_false;
63436
63437 DUK_DDD(DUK_DDDPRINT("begin parsing while statement"));
63438
63439 temp_reset = DUK__GETTEMP(comp_ctx);
63440
63441 duk__advance(comp_ctx); /* eat 'while' */
63442
63444
63445 pc_start = duk__get_current_pc(comp_ctx);

◆ duk__parse_with_stmt()

DUK_LOCAL_DECL void duk__parse_with_stmt ( duk_compiler_ctx * comp_ctx,
duk_ivalue * res )

Definition at line 63854 of file duktape-1.8.0/src/duktape.c.

63856 {
63857 DUK_ASSERT(pc_finally >= 0);
63858 duk__patch_jump(comp_ctx, pc_trycatch + 2, pc_finally);
63859 } else {
63860 /* without finally, the second jump slot is used to jump to end of stmt */
63861 duk__patch_jump_here(comp_ctx, pc_trycatch + 2);
63862 }
63863
63864 comp_ctx->curr_func.catch_depth--;
63865 return;
63866
63867 syntax_error:
63869}
63870
63872 duk_int_t pc_trycatch;
63873 duk_int_t pc_finished;
63874 duk_reg_t reg_catch;
63875 duk_small_uint_t trycatch_flags;
63876
63877 if (comp_ctx->curr_func.is_strict) {
63879 }
63880
63881 comp_ctx->curr_func.catch_depth++;
63882
63883 duk__advance(comp_ctx); /* eat 'with' */
63884
63885 reg_catch = DUK__ALLOCTEMPS(comp_ctx, 2);
63886
63888 duk__exprtop_toforcedreg(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/, reg_catch);
63890
63891 pc_trycatch = duk__get_current_pc(comp_ctx);
63892 trycatch_flags = DUK_BC_TRYCATCH_FLAG_WITH_BINDING;
#define DUK_STR_INVALID_TRY
DUK_LOCAL_DECL void duk__parse_with_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res)
DUK_LOCAL_DECL void duk__exprtop_toforcedreg(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags, duk_reg_t forced_reg)
#define DUK_STR_WITH_IN_STRICT_MODE

◆ duk__patch_jump()

DUK_LOCAL_DECL void duk__patch_jump ( duk_compiler_ctx * comp_ctx,
duk_int_t jump_pc,
duk_int_t target_pc )

Definition at line 59330 of file duktape-1.8.0/src/duktape.c.

59335 {
59336 goto fail_bc_limit;
59337 }
59338 return;
59339
59340 fail_bc_limit:
59342}
59343
59344/* Does not assume that jump_pc contains a DUK_OP_JUMP previously; this is intentional
59345 * to allow e.g. an INVALID opcode be overwritten with a JUMP (label management uses this).
59346 */
59347DUK_LOCAL void duk__patch_jump(duk_compiler_ctx *comp_ctx, duk_int_t jump_pc, duk_int_t target_pc) {
59348 duk_compiler_instr *instr;
59349 duk_int_t offset;
59350
59351 /* allow negative PCs, behave as a no-op */
59352 if (jump_pc < 0) {
#define DUK_STR_BYTECODE_LIMIT

◆ duk__patch_jump_here()

DUK_LOCAL_DECL void duk__patch_jump_here ( duk_compiler_ctx * comp_ctx,
duk_int_t jump_pc )

Definition at line 59354 of file duktape-1.8.0/src/duktape.c.

◆ duk__patch_trycatch()

DUK_LOCAL_DECL void duk__patch_trycatch ( duk_compiler_ctx * comp_ctx,
duk_int_t ldconst_pc,
duk_int_t trycatch_pc,
duk_regconst_t reg_catch,
duk_regconst_t const_varname,
duk_small_uint_t flags )

Definition at line 59358 of file duktape-1.8.0/src/duktape.c.

59367 : jump_pc=%ld, target_pc=%ld, offset=%ld",
59368 (long) jump_pc, (long) target_pc, (long) offset));
59369}
59370
59371DUK_LOCAL void duk__patch_jump_here(duk_compiler_ctx *comp_ctx, duk_int_t jump_pc) {
59372 duk__patch_jump(comp_ctx, jump_pc, duk__get_current_pc(comp_ctx));
59373}
59374
59375DUK_LOCAL void duk__patch_trycatch(duk_compiler_ctx *comp_ctx, duk_int_t ldconst_pc, duk_int_t trycatch_pc, duk_regconst_t reg_catch, duk_regconst_t const_varname, duk_small_uint_t flags) {
59376 duk_compiler_instr *instr;
59377
59378 DUK_ASSERT((reg_catch & DUK__CONST_MARKER) == 0);
59379
59380 instr = duk__get_instr_ptr(comp_ctx, ldconst_pc);
59381 DUK_ASSERT(DUK_DEC_OP(instr->ins) == DUK_OP_LDCONST);
59382 DUK_ASSERT(instr != NULL);
59383 if (const_varname & DUK__CONST_MARKER) {
59384 /* Have a catch variable. */
59385 const_varname = const_varname & (~DUK__CONST_MARKER);
59386 if (reg_catch > DUK_BC_BC_MAX || const_varname > DUK_BC_BC_MAX) {
59387 /* Catch attempts to use out-of-range reg/const. Without this
59388 * check Duktape 0.12.0 could generate invalid code which caused
59389 * an assert failure on execution. This error is triggered e.g.
59390 * for functions with a lot of constants and a try-catch statement.
59391 * Shuffling or opcode semantics change is needed to fix the issue.
59392 * See: test-bug-trycatch-many-constants.js.
59393 */
59394 DUK_D(DUK_DPRINT("failed to patch trycatch: flags=%ld, reg_catch=%ld, const_varname=%ld (0x%08lx)",

◆ duk__pcall_prop_raw()

DUK_LOCAL duk_ret_t duk__pcall_prop_raw ( duk_context * ctx)

Definition at line 12545 of file duktape-1.8.0/src/duktape.c.

12547 {
12548 /* See comments in duk_pcall(). */
12550 return DUK_EXEC_ERROR; /* unreachable */
12551 }
12552
12553 call_flags = 0; /* respect reclimit, not constructor */
12554
12555 rc = duk_handle_call_protected(thr, /* thread */
12556 nargs, /* num_stack_args */
12557 call_flags); /* call_flags */
12558
12559 return rc;
12560}
12561
12563 duk_idx_t obj_index;
DUK_LOCAL duk_ret_t duk__pcall_prop_raw(duk_context *ctx)
DUK_INTERNAL_DECL duk_int_t duk_handle_call_protected(duk_hthread *thr, duk_idx_t num_stack_args, duk_small_uint_t call_flags)

References DUK_ERROR_API, DUK_EXEC_ERROR, and DUK_STR_INVALID_CALL_ARGS.

◆ duk__peephole_optimize_bytecode()

DUK_LOCAL void duk__peephole_optimize_bytecode ( duk_compiler_ctx * comp_ctx)

Definition at line 59423 of file duktape-1.8.0/src/duktape.c.

59429 {
59431}
59432
59433/*
59434 * Peephole optimizer for finished bytecode.
59435 *
59436 * Does not remove opcodes; currently only straightens out unconditional
59437 * jump chains which are generated by several control structures.
59438 */
59439
59442 duk_small_uint_t iter;
59443 duk_int_t i, n;
59444 duk_int_t count_opt;
59445
59446 bc = (duk_compiler_instr *) (void *) DUK_BW_GET_BASEPTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code);
59447#if defined(DUK_USE_BUFLEN16)
59448 /* No need to assert, buffer size maximum is 0xffff. */
59449#else
59450 DUK_ASSERT((duk_size_t) DUK_BW_GET_SIZE(comp_ctx->thr, &comp_ctx->curr_func.bw_code) / sizeof(duk_compiler_instr) <= (duk_size_t) DUK_INT_MAX); /* bytecode limits */
59451#endif
59452 n = (duk_int_t) (DUK_BW_GET_SIZE(comp_ctx->thr, &comp_ctx->curr_func.bw_code) / sizeof(duk_compiler_instr));
59453
59454 for (iter = 0; iter < DUK_COMPILER_PEEPHOLE_MAXITER; iter++) {
59455 count_opt = 0;
59456
59457 for (i = 0; i < n; i++) {
59458 duk_instr_t ins;
59459 duk_int_t target_pc1;
59460 duk_int_t target_pc2;
59461
59462 ins = bc[i].ins;
59463 if (DUK_DEC_OP(ins) != DUK_OP_JUMP) {
59464 continue;
59465 }
59466
59467 target_pc1 = i + 1 + DUK_DEC_ABC(ins) - DUK_BC_JUMP_BIAS;
59468 DUK_DDD(DUK_DDDPRINT("consider jump at pc %ld; target_pc=%ld", (long) i, (long) target_pc1));
59469 DUK_ASSERT(target_pc1 >= 0);
59470 DUK_ASSERT(target_pc1 < n);
59471
59472 /* Note: if target_pc1 == i, we'll optimize a jump to itself.
59473 * This does not need to be checked for explicitly; the case
59474 * is rare and max iter breaks us out.
59475 */
59476
59477 ins = bc[target_pc1].ins;
59478 if (DUK_DEC_OP(ins) != DUK_OP_JUMP) {
59479 continue;
59480 }
59481
DUK_LOCAL void duk__peephole_optimize_bytecode(duk_compiler_ctx *comp_ctx)
#define DUK_COMPILER_PEEPHOLE_MAXITER

Referenced by duk__parse_func_body().

◆ duk__pnew_helper()

DUK_LOCAL duk_ret_t duk__pnew_helper ( duk_context * ctx)

Definition at line 12805 of file duktape-1.8.0/src/duktape.c.

◆ duk__pow_fixed()

DUK_LOCAL double duk__pow_fixed ( double x,
double y )

Definition at line 32666 of file duktape-1.8.0/src/duktape.c.

32671 {
32672 /* +0.5 is handled by floor, this is on purpose */
32673 if (x < 0.0) {
32674 return -0.0;
32675 } else {
32676 return +0.0;
32677 }
32678 }
32679
32680 return DUK_FLOOR(x + 0.5);
32681}
32682
32683DUK_LOCAL double duk__pow_fixed(double x, double y) {
32684 /* The ANSI C pow() semantics differ from Ecmascript.
32685 *
32686 * E.g. when x==1 and y is +/- infinite, the Ecmascript required
32687 * result is NaN, while at least Linux pow() returns 1.
32688 */
32689
32690 duk_small_int_t cx, cy, sx;
32691
32692 DUK_UNREF(cx);
32693 DUK_UNREF(sx);
32695
32696 if (cy == DUK_FP_NAN) {
32697 goto ret_nan;
32698 }
32699 if (DUK_FABS(x) == 1.0 && cy == DUK_FP_INFINITE) {
32700 goto ret_nan;
32701 }
32702#if defined(DUK_USE_POW_NETBSD_WORKAROUND)
32703 /* See test-bug-netbsd-math-pow.js: NetBSD 6.0 on x86 (at least) does not
32704 * correctly handle some cases where x=+/-0. Specific fixes to these
32705 * here.
32706 */
32708 if (cx == DUK_FP_ZERO && y < 0.0) {
32709 sx = (duk_small_int_t) DUK_SIGNBIT(x);
32710 if (sx == 0) {
32711 /* Math.pow(+0,y) should be Infinity when y<0. NetBSD pow()
32712 * returns -Infinity instead when y is <0 and finite. The
32713 * if-clause also catches y == -Infinity (which works even
32714 * without the fix).
32715 */
32716 return DUK_DOUBLE_INFINITY;
32717 } else {
32718 /* Math.pow(-0,y) where y<0 should be:
32719 * - -Infinity if y<0 and an odd integer
32720 * - Infinity otherwise
32721 * NetBSD pow() returns -Infinity for all finite y<0. The
32722 * if-clause also catches y == -Infinity (which works even
32723 * without the fix).
32724 */
32725
32726 /* fmod() return value has same sign as input (negative) so
32727 * the result here will be in the range ]-2,0], 1 indicates
32728 * odd. If x is -Infinity, NaN is returned and the odd check
DUK_LOCAL double duk__pow_fixed(double x, double y)

◆ duk__prep_codec_arg()

DUK_LOCAL const duk_uint8_t * duk__prep_codec_arg ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_len )

Definition at line 12958 of file duktape-1.8.0/src/duktape.c.

◆ duk__protected_compact_object()

DUK_LOCAL int duk__protected_compact_object ( duk_context * ctx)

Definition at line 43125 of file duktape-1.8.0/src/duktape.c.

43132 : %ld finalizers called", (long) count));

◆ duk__proxy_check_prop()

DUK_LOCAL duk_bool_t duk__proxy_check_prop ( duk_hthread * thr,
duk_hobject * obj,
duk_small_uint_t stridx_trap,
duk_tval * tv_key,
duk_hobject ** out_target )

Definition at line 47815 of file duktape-1.8.0/src/duktape.c.

47817 {
47818 if (duk_hobject_proxy_check(thr, obj, &h_target, &h_handler)) {
47819 DUK_ASSERT(h_target != NULL);
47820 obj = h_target;
47821 } else {
47822 break;
47823 }
47824 }
47825
47826 DUK_ASSERT(obj != NULL);
47827 return obj;
47828}
47829#endif /* DUK_USE_ES6_PROXY */
47830
47831#if defined(DUK_USE_ES6_PROXY)
47833 duk_context *ctx = (duk_context *) thr;
47834 duk_hobject *h_handler;
47835
47836 DUK_ASSERT(thr != NULL);
47837 DUK_ASSERT(obj != NULL);
47838 DUK_ASSERT(tv_key != NULL);
47839 DUK_ASSERT(out_target != NULL);
47840
47841 if (!duk_hobject_proxy_check(thr, obj, out_target, &h_handler)) {
47842 return 0;
47843 }
47844 DUK_ASSERT(*out_target != NULL);
47845 DUK_ASSERT(h_handler != NULL);
47846
47847 /* XXX: At the moment Duktape accesses internal keys like _Finalizer using a
47848 * normal property set/get which would allow a proxy handler to interfere with
47849 * such behavior and to get access to internal key strings. This is not a problem
47850 * as such because internal key strings can be created in other ways too (e.g.
47851 * through buffers). The best fix is to change Duktape internal lookups to
47852 * skip proxy behavior. Until that, internal property accesses bypass the
47853 * proxy and are applied to the target (as if the handler did not exist).
47854 * This has some side effects, see test-bi-proxy-internal-keys.js.
47855 */
47856
47857 if (DUK_TVAL_IS_STRING(tv_key)) {
47858 duk_hstring *h_key = (duk_hstring *) DUK_TVAL_GET_STRING(tv_key);
47859 DUK_ASSERT(h_key != NULL);
47860 if (DUK_HSTRING_HAS_INTERNAL(h_key)) {
47861 DUK_DDD(DUK_DDDPRINT("internal key, skip proxy handler and apply to target"));
47862 return 0;
47863 }
47864 }
47865
47866 /* The handler is looked up with a normal property lookup; it may be an
47867 * accessor or the handler object itself may be a proxy object. If the
47868 * handler is a proxy, we need to extend the valstack as we make a
47869 * recursive proxy check without a function call in between (in fact
47870 * there is no limit to the potential recursion here).
47871 *
47872 * (For sanity, proxy creation rejects another proxy object as either
47873 * the handler or the target at the moment so recursive proxy cases
47874 * are not realized now.)
DUK_INTERNAL_DECL duk_bool_t duk_hobject_proxy_check(duk_hthread *thr, duk_hobject *obj, duk_hobject **out_target, duk_hobject **out_handler)
DUK_LOCAL duk_bool_t duk__proxy_check_prop(duk_hthread *thr, duk_hobject *obj, duk_small_uint_t stridx_trap, duk_tval *tv_key, duk_hobject **out_target)

References DUK_ASSERT, duk_hobject_proxy_check(), and NULL.

Referenced by duk_hobject_putprop().

◆ duk__push_arraybuffer_with_length()

DUK_LOCAL duk_hbufferobject * duk__push_arraybuffer_with_length ( duk_context * ctx,
duk_uint_t len )

Definition at line 21927 of file duktape-1.8.0/src/duktape.c.

21944 {
21945 duk_hbuffer *h_val;
21946 duk_hbufferobject *h_bufobj;

◆ duk__push_c_function_raw()

DUK_LOCAL_DECL duk_idx_t duk__push_c_function_raw ( duk_context * ctx,
duk_c_function func,
duk_idx_t nargs,
duk_uint_t flags )

Definition at line 18763 of file duktape-1.8.0/src/duktape.c.

18766 : 0x%08lx", (unsigned long) obj->obj.hdr.h_flags));
18767
18768 tv_slot = thr->valstack_top;
18769 DUK_TVAL_SET_OBJECT(tv_slot, (duk_hobject *) obj);
18770 DUK_HOBJECT_INCREF(thr, obj);
18771 ret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom);
18772 thr->valstack_top++;
18773
18774 /* default prototype (Note: 'obj' must be reachable) */
18775 DUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, (duk_hobject *) obj, thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE]);
18776
18777 return ret;
18778}
18779
18780DUK_LOCAL duk_idx_t duk__push_c_function_raw(duk_context *ctx, duk_c_function func, duk_idx_t nargs, duk_uint_t flags) {
18781 duk_hthread *thr = (duk_hthread *) ctx;
18782 duk_hnativefunction *obj;
18783 duk_idx_t ret;
18784 duk_tval *tv_slot;
18785 duk_int16_t func_nargs;
18786
18787 DUK_ASSERT_CTX_VALID(ctx);
18788
18789 /* check stack first */
18790 if (thr->valstack_top >= thr->valstack_end) {
18791 DUK_ERROR_API(thr, DUK_STR_PUSH_BEYOND_ALLOC_STACK);
18792 }
18793 if (func == NULL) {
18794 goto api_error;
18795 }
18796 if (nargs >= 0 && nargs < DUK_HNATIVEFUNCTION_NARGS_MAX) {
18797 func_nargs = (duk_int16_t) nargs;
18798 } else if (nargs == DUK_VARARGS) {
18799 func_nargs = DUK_HNATIVEFUNCTION_NARGS_VARARGS;
18800 } else {
18801 goto api_error;
18802 }
18803
18804 obj = duk_hnativefunction_alloc(thr->heap, flags);
18805 if (!obj) {
18806 DUK_ERROR_ALLOC_DEFMSG(thr);
18807 }
18808
18809 obj->func = func;
18810 obj->nargs = func_nargs;
18811
18812 DUK_DDD(DUK_DDDPRINT("created native function object with flags: 0x%08lx, nargs=%ld",
static union @102 native

Referenced by duk_push_c_function_noconstruct_noexotic(), and duk_push_c_function_noexotic().

◆ duk__push_double()

DUK_LOCAL void duk__push_double ( duk_context * ctx,
duk_bitdecoder_ctx * bd )

Definition at line 53755 of file duktape-1.8.0/src/duktape.c.

53760 {
53761 *p++ = (duk_uint8_t) duk_bd_decode(bd, DUK__STRING_CHAR_BITS);
53762 }
53763 duk_to_string(ctx, -1);
53764}
53766 if (duk_bd_decode_flag(bd)) {
53767 duk__push_string(ctx, bd);
DUK_LOCAL void duk__push_string(duk_context *ctx, duk_bitdecoder_ctx *bd)
#define DUK__STRING_CHAR_BITS
DUK_LOCAL void duk__push_stridx_or_string(duk_context *ctx, duk_bitdecoder_ctx *bd)
DUK_INTERNAL_DECL duk_small_int_t duk_bd_decode_flag(duk_bitdecoder_ctx *ctx)

References DUK__STRING_CHAR_BITS, and duk_bd_decode().

◆ duk__push_hstring_readable_unicode()

DUK_LOCAL void duk__push_hstring_readable_unicode ( duk_context * ctx,
duk_hstring * h_input )

Definition at line 19685 of file duktape-1.8.0/src/duktape.c.

19702 {
19703 duk_hthread *thr;
19704 const duk_uint8_t *p, *p_start, *p_end;
19706 2 /*quotes*/ + 3 /*periods*/];
19707 duk_uint8_t *q;
19709 duk_small_uint_t nchars;
19710
19712 DUK_ASSERT(h_input != NULL);
19713 thr = (duk_hthread *) ctx;
19714
19715 p_start = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input);
19716 p_end = p_start + DUK_HSTRING_GET_BYTELEN(h_input);
19717 p = p_start;
19718 q = buf;
19719
19720 nchars = 0;
19721 *q++ = (duk_uint8_t) DUK_ASC_SINGLEQUOTE;
19722 for (;;) {
19723 if (p >= p_end) {
19724 break;
19725 }
19726 if (nchars == DUK__READABLE_STRING_MAXCHARS) {
19727 *q++ = (duk_uint8_t) DUK_ASC_PERIOD;
19728 *q++ = (duk_uint8_t) DUK_ASC_PERIOD;
19729 *q++ = (duk_uint8_t) DUK_ASC_PERIOD;
19730 break;
19731 }
19732 if (duk_unicode_decode_xutf8(thr, &p, p_start, p_end, &cp)) {
19733 if (cp < 0x20 || cp == 0x7f || cp == DUK_ASC_SINGLEQUOTE || cp == DUK_ASC_BACKSLASH) {
19734 DUK_ASSERT(DUK_UNICODE_MAX_XUTF8_LENGTH >= 4); /* estimate is valid */
19735 DUK_ASSERT((cp >> 4) <= 0x0f);
#define DUK_ASC_SINGLEQUOTE
#define DUK__READABLE_STRING_MAXCHARS

◆ duk__push_stash()

DUK_LOCAL void duk__push_stash ( duk_context * ctx)

Definition at line 18421 of file duktape-1.8.0/src/duktape.c.

18424 {
18425 duk_push_hobject(ctx, (duk_hobject *) thr->heap->curr_thread);
18426 } else {
18427 duk_push_undefined(ctx);
18428 }
18429}
18430
DUK_EXTERNAL void duk_push_global_object(duk_context *ctx)

Referenced by duk_push_thread_stash().

◆ duk__push_stridx()

DUK_LOCAL void duk__push_stridx ( duk_context * ctx,
duk_bitdecoder_ctx * bd )

Definition at line 53728 of file duktape-1.8.0/src/duktape.c.

53728 {
53729 duk_hobject *h;
53730 h = (duk_hobject *) DUK_LOSE_CONST(duk_rom_builtins_bidx[i]);
53731 DUK_ASSERT(h != NULL);
53732 thr->builtins[i] = h;
53733 }
53734
53735#if defined(DUK_USE_ROM_GLOBAL_CLONE) || defined(DUK_USE_ROM_GLOBAL_INHERIT)

References duk_hthread::builtins, DUK_ASSERT, DUK_LOSE_CONST, and NULL.

◆ duk__push_stridx_or_string()

DUK_LOCAL void duk__push_stridx_or_string ( duk_context * ctx,
duk_bitdecoder_ctx * bd )

Definition at line 53748 of file duktape-1.8.0/src/duktape.c.

53753 {

◆ duk__push_string()

DUK_LOCAL void duk__push_string ( duk_context * ctx,
duk_bitdecoder_ctx * bd )

Definition at line 53736 of file duktape-1.8.0/src/duktape.c.

53745 {
53747

◆ duk__push_this_get_timeval()

DUK_LOCAL_DECL duk_double_t duk__push_this_get_timeval ( duk_context * ctx,
duk_small_uint_t flags )

Definition at line 25543 of file duktape-1.8.0/src/duktape.c.

25545 {

◆ duk__push_this_get_timeval_tzoffset()

DUK_LOCAL_DECL duk_double_t duk__push_this_get_timeval_tzoffset ( duk_context * ctx,
duk_small_uint_t flags,
duk_int_t * out_tzoffset )

Definition at line 25501 of file duktape-1.8.0/src/duktape.c.

25518 {
25519 duk_hthread *thr = (duk_hthread *) ctx;
25520 duk_hobject *h;
25521 duk_double_t d;
25522 duk_int_t tzoffset = 0;
25523
25524 duk_push_this(ctx);
25525 h = duk_get_hobject(ctx, -1); /* XXX: getter with class check, useful in built-ins */
25527 DUK_ERROR_TYPE(thr, "expected Date");
25528 }
25529
25531 d = duk_to_number(ctx, -1);
25532 duk_pop(ctx);
25533
25534 if (DUK_ISNAN(d)) {
25535 if (flags & DUK_DATE_FLAG_NAN_TO_ZERO) {
25536 d = 0.0;
25537 }
25539 DUK_ERROR_RANGE(thr, "Invalid Date");
25540 }
25541 }
#define DUK_DATE_FLAG_NAN_TO_RANGE_ERROR
#define DUK_DATE_FLAG_NAN_TO_ZERO
#define DUK_HOBJECT_CLASS_DATE

◆ duk__push_this_helper()

DUK_LOCAL void duk__push_this_helper ( duk_context * ctx,
duk_small_uint_t check_object_coercible )

Definition at line 18296 of file duktape-1.8.0/src/duktape.c.

18302 {
18303 duk_hthread *thr;
18304 duk_tval *tv_slot;
18305
18307 thr = (duk_hthread *) ctx;
18309 tv_slot = thr->valstack_top++;
18310 DUK_TVAL_SET_POINTER(tv_slot, val);
18311}
18312
18313DUK_LOCAL void duk__push_this_helper(duk_context *ctx, duk_small_uint_t check_object_coercible) {
18314 duk_hthread *thr;
18315 duk_tval *tv_slot;
18316
18318 DUK_ASSERT_DISABLE(thr->callstack_top >= 0); /* avoid warning (unsigned) */
18319 thr = (duk_hthread *) ctx;
18322
18323 DUK_ASSERT(DUK_TVAL_IS_UNDEFINED(thr->valstack_top)); /* because of valstack init policy */
18324 tv_slot = thr->valstack_top++;
18325
18326 if (DUK_UNLIKELY(thr->callstack_top == 0)) {
18327 if (check_object_coercible) {
18328 goto type_error;
18329 }
18330 /* 'undefined' already on stack top */
18331 } else {
18332 duk_tval *tv;
18333
DUK_LOCAL void duk__push_this_helper(duk_context *ctx, duk_small_uint_t check_object_coercible)
#define DUK_TVAL_SET_POINTER(tv, hptr)
#define DUK__CHECK_SPACE()

◆ duk__push_this_number_plain()

DUK_LOCAL duk_double_t duk__push_this_number_plain ( duk_context * ctx)

Definition at line 32892 of file duktape-1.8.0/src/duktape.c.

32896 {
32897 DUK_UNREF(ctx);
32899}
32900
32901#endif /* DUK_USE_MATH_BUILTIN */
32902#line 1 "duk_bi_number.c"
32903/*
32904 * Number built-ins
32905 */
32906
32907/* include removed: duk_internal.h */
32908
32910 duk_hobject *h;
32911
32912 /* Number built-in accepts a plain number or a Number object (whose
32913 * internal value is operated on). Other types cause TypeError.
32914 */
32915
32916 duk_push_this(ctx);
32917 if (duk_is_number(ctx, -1)) {
32918 DUK_DDD(DUK_DDDPRINT("plain number value: %!T", (duk_tval *) duk_get_tval(ctx, -1)));
#define DUK_RET_UNIMPLEMENTED_ERROR
DUK_LOCAL duk_double_t duk__push_this_number_plain(duk_context *ctx)

◆ duk__push_this_obj_len_u32()

DUK_LOCAL duk_uint32_t duk__push_this_obj_len_u32 ( duk_context * ctx)

Definition at line 20266 of file duktape-1.8.0/src/duktape.c.

20268 : even Duktape code internally
20269 * assumes that an Array instance will always have a 'length' property.
20270 * Preventing deletion of the property is critical.
20271 */
20272
20273/* include removed: duk_internal.h */
20274
20275/* Perform an intermediate join when this many elements have been pushed

Referenced by duk_bi_array_constructor().

◆ duk__push_this_obj_len_u32_limited()

DUK_LOCAL duk_uint32_t duk__push_this_obj_len_u32_limited ( duk_context * ctx)

Definition at line 20277 of file duktape-1.8.0/src/duktape.c.

20283 {
20284 duk_uint32_t len;
20285
DUK_INTERNAL_DECL duk_hobject * duk_push_this_coercible_to_object(duk_context *ctx)

References duk_get_prop_stridx(), duk_push_this_coercible_to_object(), DUK_STRIDX_LENGTH, and duk_to_uint32().

◆ duk__push_tval_to_hstring_arr_idx()

DUK_LOCAL duk_uint32_t duk__push_tval_to_hstring_arr_idx ( duk_context * ctx,
duk_tval * tv,
duk_hstring ** out_h )

Definition at line 47565 of file duktape-1.8.0/src/duktape.c.

47567 {
47568 /* Catches >0x100000000 and negative values. */
47569 return DUK__NO_ARRAY_INDEX;
47570 }
47571
47572 /* If the value happens to be 0xFFFFFFFF, it's not a valid array index
47573 * but will then match DUK__NO_ARRAY_INDEX.
47574 */
47575 return (duk_uint32_t) t;
47576}
47577#endif /* DUK_USE_FASTINT */
47578
47579/* Push an arbitrary duk_tval to the stack, coerce it to string, and return
47580 * both a duk_hstring pointer and an array index (or DUK__NO_ARRAY_INDEX).
47581 */

Referenced by duk_hobject_putprop().

◆ duk__put_prop_shared()

DUK_LOCAL duk_bool_t duk__put_prop_shared ( duk_context * ctx,
duk_idx_t obj_idx,
duk_idx_t idx_key )

Definition at line 14478 of file duktape-1.8.0/src/duktape.c.

14478 {
14479 duk_bool_t rc;
14480
14482 DUK_ASSERT_DISABLE(stridx >= 0);
14484
14485 rc = duk_get_prop_stridx(ctx, obj_index, stridx);
14486 if (out_has_prop) {
14487 *out_has_prop = rc;
14488 }
14489 rc = duk_to_boolean(ctx, -1);
14490 DUK_ASSERT(rc == 0 || rc == 1);
14491 duk_pop(ctx);
14492 return rc;
14493}
14494
14496 duk_hthread *thr = (duk_hthread *) ctx;
14497 duk_tval *tv_obj;
14498 duk_tval *tv_key;
14499 duk_tval *tv_val;
14500 duk_small_int_t throw_flag;
14501 duk_bool_t rc;
14502
14503 /* Note: copying tv_obj and tv_key to locals to shield against a valstack
14504 * resize is not necessary for a property put right now (putprop protects
14505 * against it internally).
14506 */
DUK_EXTERNAL duk_bool_t duk_to_boolean(duk_context *ctx, duk_idx_t index)
DUK_LOCAL duk_bool_t duk__put_prop_shared(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t idx_key)

References DUK_ASSERT, DUK_ASSERT_CTX_VALID, DUK_ASSERT_DISABLE, duk_get_prop_stridx(), DUK_HEAP_NUM_STRINGS, duk_pop(), and duk_to_boolean().

◆ duk__putprop_fastpath_bufobj_tval()

DUK_LOCAL duk_bool_t duk__putprop_fastpath_bufobj_tval ( duk_hthread * thr,
duk_hobject * obj,
duk_tval * tv_key,
duk_tval * tv_val )

Definition at line 49570 of file duktape-1.8.0/src/duktape.c.

49576 {
49577 data = (duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_bufobj->buf) + h_bufobj->offset + byte_off;
49578 duk_hbufferobject_push_validated_read(ctx, h_bufobj, data, elem_size);
49579 } else {
49580 DUK_D(DUK_DPRINT("bufferobject access out of underlying buffer, ignoring (read zero)"));
49581 duk_push_uint(ctx, 0);
49582 }
49583
49584 return 1;
49585}
49586
49588 duk_context *ctx;
49589 duk_uint32_t idx;
49590 duk_hbufferobject *h_bufobj;
49591 duk_uint_t byte_off;
49592 duk_small_uint_t elem_size;
49593 duk_uint8_t *data;
49594
49595 ctx = (duk_context *) thr;
49596
49597 if (!(DUK_HOBJECT_IS_BUFFEROBJECT(obj) &&
49598 DUK_TVAL_IS_NUMBER(tv_val))) {
49599 return 0;
49600 }
49601 DUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj)); /* caller ensures; rom objects are never bufferobjects now */
49602
49603 h_bufobj = (duk_hbufferobject *) obj;
49604#if defined(DUK_USE_FASTINT)
49605 if (DUK_TVAL_IS_FASTINT(tv_key)) {
49606 idx = duk__tval_fastint_to_arr_idx(tv_key);
49607 } else
49608#endif
49609 if (DUK_TVAL_IS_DOUBLE(tv_key)) {
49610 idx = duk__tval_number_to_arr_idx(tv_key);
49611 } else {
49612 return 0;
49613 }
49614
49615 /* If index is not valid, idx will be DUK__NO_ARRAY_INDEX which
49616 * is 0xffffffffUL. We don't need to check for that explicitly
49617 * because 0xffffffffUL will never be inside bufferobject length.
49618 */
49619
49620 /* Careful with wrapping (left shifting idx would be unsafe). */
49621 if (idx >= (h_bufobj->length >> h_bufobj->shift)) {
49622 return 0;
49623 }
49625
49626 byte_off = idx << h_bufobj->shift; /* no wrap assuming h_bufobj->length is valid */
49627 elem_size = 1 << h_bufobj->shift;
DUK_LOCAL duk_bool_t duk__putprop_fastpath_bufobj_tval(duk_hthread *thr, duk_hobject *obj, duk_tval *tv_key, duk_tval *tv_val)

Referenced by duk_hobject_putprop().

◆ duk__putprop_shallow_fastpath_array_tval()

DUK_LOCAL duk_bool_t duk__putprop_shallow_fastpath_array_tval ( duk_hthread * thr,
duk_hobject * obj,
duk_tval * tv_key,
duk_tval * tv_val,
duk_propdesc * temp_desc )

Definition at line 49453 of file duktape-1.8.0/src/duktape.c.

49461 {
49462 DUK_DDD(DUK_DDDPRINT("-> fast path successful"));
49463 return tv;
49464 }
49465
49466 DUK_DDD(DUK_DDDPRINT("fast path attempt failed, fall back to slow path"));
49467 return NULL;
49468}
49469
49471 duk_tval *tv;
49472 duk_uint32_t idx;
49473 duk_uint32_t old_len, new_len;
49474
49475 if (!(DUK_HOBJECT_HAS_EXOTIC_ARRAY(obj) &&
49478 return 0;
49479 }
49480 DUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj)); /* caller ensures */
49481
49482#if defined(DUK_USE_FASTINT)
49483 if (DUK_TVAL_IS_FASTINT(tv_key)) {
49484 idx = duk__tval_fastint_to_arr_idx(tv_key);
49485 } else
49486#endif
49487 if (DUK_TVAL_IS_DOUBLE(tv_key)) {
49488 idx = duk__tval_number_to_arr_idx(tv_key);
49489 } else {
49490 DUK_DDD(DUK_DDDPRINT("key is not a number"));
49491 return 0;
49492 }
49493
49494 /* If index is not valid, idx will be DUK__NO_ARRAY_INDEX which
49495 * is 0xffffffffUL. We don't need to check for that explicitly
49496 * because 0xffffffffUL will never be inside object 'a_size'.
49497 */
49498
49499 if (idx >= DUK_HOBJECT_GET_ASIZE(obj)) { /* for resizing of array part, use slow path */
49500 return 0;
49501 }
49502 DUK_ASSERT(idx != 0xffffffffUL);
49504
49505 old_len = duk__get_old_array_length(thr, obj, temp_desc);
49506
49507 if (idx >= old_len) {
49508 DUK_DDD(DUK_DDDPRINT("write new array entry requires length update "
49509 "(arr_idx=%ld, old_len=%ld)",
49510 (long) idx, (long) old_len));
49511 if (!(temp_desc->flags & DUK_PROPDESC_FLAG_WRITABLE)) {
49513 return 0; /* not reachable */
#define DUK_STR_NOT_WRITABLE
DUK_LOCAL duk_bool_t duk__putprop_shallow_fastpath_array_tval(duk_hthread *thr, duk_hobject *obj, duk_tval *tv_key, duk_tval *tv_val, duk_propdesc *temp_desc)
#define DUK_HOBJECT_HAS_EXTENSIBLE(h)
DUK_LOCAL duk_uint32_t duk__get_old_array_length(duk_hthread *thr, duk_hobject *obj, duk_propdesc *temp_desc)

Referenced by duk_hobject_putprop().

◆ duk__putvar_helper()

DUK_LOCAL void duk__putvar_helper ( duk_hthread * thr,
duk_hobject * env,
duk_activation * act,
duk_hstring * name,
duk_tval * val,
duk_bool_t strict )

Definition at line 72796 of file duktape-1.8.0/src/duktape.c.

72818 {
72820 duk_tval tv_tmp_obj;
72821 duk_tval tv_tmp_key;
72822 duk_bool_t parents;
72823
72824 DUK_DDD(DUK_DDDPRINT("putvar: thr=%p, env=%p, act=%p, name=%!O, val=%p, strict=%ld "
72825 "(env -> %!dO, val -> %!T)",
72826 (void *) thr, (void *) env, (void *) act,
72827 (duk_heaphdr *) name, (void *) val, (long) strict,
72828 (duk_heaphdr *) env, (duk_tval *) val));
72829
72830 DUK_ASSERT(thr != NULL);
72831 DUK_ASSERT(name != NULL);
72832 DUK_ASSERT(val != NULL);
72833 /* env and act may be NULL */
72834
72838
72839 /*
72840 * In strict mode E5 protects 'eval' and 'arguments' from being
72841 * assigned to (or even declared anywhere). Attempt to do so
72842 * should result in a compile time SyntaxError. See the internal
72843 * design documentation for details.
72844 *
72845 * Thus, we should never come here, run-time, for strict code,
72846 * and name 'eval' or 'arguments'.
72847 */
72848
72849 DUK_ASSERT(!strict ||
72850 (name != DUK_HTHREAD_STRING_EVAL(thr) &&
72852
72853 /*
72854 * Lookup variable and update in-place if found.
72855 */
72856
72857 parents = 1; /* follow parent chain */
72858
72859 if (duk__get_identifier_reference(thr, env, name, act, parents, &ref)) {
72860 if (ref.value && (ref.attrs & DUK_PROPDESC_FLAG_WRITABLE)) {
72861 /* Update duk_tval in-place if pointer provided and the
72862 * property is writable. If the property is not writable
72863 * (immutable binding), use duk_hobject_putprop() which
72864 * will respect mutability.
72865 */
72866 duk_tval *tv_val;
72867
72868 DUK_ASSERT(ref.this_binding == NULL); /* always for register bindings */
72869
72870 tv_val = ref.value;
72871 DUK_ASSERT(tv_val != NULL);
72872 DUK_TVAL_SET_TVAL_UPDREF(thr, tv_val, val); /* side effects */
72873
72874 /* ref.value and ref.this_binding invalidated here */
72875 } else {
72876 DUK_ASSERT(ref.holder != NULL);
72877
72878 DUK_TVAL_SET_OBJECT(&tv_tmp_obj, ref.holder);
72879 DUK_TVAL_SET_STRING(&tv_tmp_key, name);
72880 (void) duk_hobject_putprop(thr, &tv_tmp_obj, &tv_tmp_key, val, strict);
72881
72882 /* ref.value and ref.this_binding invalidated here */
72883 }
72884
72885 return;
72886 }
72887
72888 /*
72889 * Not found: write to global object (non-strict) or ReferenceError
72890 * (strict); see E5 Section 8.7.2, step 3.
#define DUK_ASSERT_REFCOUNT_NONZERO_TVAL(tv)

References duk__id_lookup_result::attrs, duk__get_identifier_reference(), DUK_ASSERT, DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR, DUK_ASSERT_REFCOUNT_NONZERO_TVAL, DUK_DDD, DUK_DDDPRINT, duk_hobject_putprop(), DUK_HTHREAD_STRING_EVAL, DUK_HTHREAD_STRING_LC_ARGUMENTS, DUK_PROPDESC_FLAG_WRITABLE, DUK_TVAL_SET_OBJECT, DUK_TVAL_SET_STRING, DUK_TVAL_SET_TVAL_UPDREF, duk__id_lookup_result::holder, name, NULL, duk__id_lookup_result::this_binding, and duk__id_lookup_result::value.

◆ duk__queue_refzero()

DUK_LOCAL void duk__queue_refzero ( duk_heap * heap,
duk_heaphdr * hdr )

Definition at line 44098 of file duktape-1.8.0/src/duktape.c.

44115 {
44116 /* tail insert: don't disturb head in case refzero is running */
44117
44118 if (heap->refzero_list != NULL) {
44119 duk_heaphdr *hdr_prev;
44120
44121 hdr_prev = heap->refzero_list_tail;
44122 DUK_ASSERT(hdr_prev != NULL);

References DUK_ASSERT, DUK_ASSERT_HEAPHDR_LINKS, DUK_HEAPHDR_GET_NEXT, DUK_HEAPHDR_SET_NEXT, DUK_HEAPHDR_SET_PREV, NULL, duk_heap::refzero_list, and duk_heap::refzero_list_tail.

◆ duk__realloc_props()

DUK_LOCAL void duk__realloc_props ( duk_hthread * thr,
duk_hobject * obj,
duk_uint32_t new_e_size,
duk_uint32_t new_a_size,
duk_uint32_t new_h_size,
duk_bool_t abandon_array )

Definition at line 47910 of file duktape-1.8.0/src/duktape.c.

47917 : a non-checked variant would be nice but is a bit tricky to
47918 * implement for the array abandonment process. It's easy for
47919 * everything else.
47920 *
47921 * Note: because we need to potentially resize the valstack (as part
47922 * of abandoning the array part), any tval pointers to the valstack
47923 * will become invalid after this call.
47924 */
47925
47926DUK_LOCAL
47927void duk__realloc_props(duk_hthread *thr,
47928 duk_hobject *obj,
47929 duk_uint32_t new_e_size,
47930 duk_uint32_t new_a_size,
47931 duk_uint32_t new_h_size,
47932 duk_bool_t abandon_array) {
47933 duk_context *ctx = (duk_context *) thr;
47934#ifdef DUK_USE_MARK_AND_SWEEP
47935 duk_small_uint_t prev_mark_and_sweep_base_flags;
47936#endif
47937 duk_uint32_t new_alloc_size;
47938 duk_uint32_t new_e_size_adjusted;
47939 duk_uint8_t *new_p;
47940 duk_hstring **new_e_k;
47941 duk_propvalue *new_e_pv;
47942 duk_uint8_t *new_e_f;
47943 duk_tval *new_a;
47944 duk_uint32_t *new_h;
47945 duk_uint32_t new_e_next;
47946 duk_uint_fast32_t i;
47947
47948 DUK_ASSERT(thr != NULL);
47949 DUK_ASSERT(ctx != NULL);
47950 DUK_ASSERT(obj != NULL);
47951 DUK_ASSERT(!abandon_array || new_a_size == 0); /* if abandon_array, new_a_size must be 0 */
47952 DUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, obj) != NULL || (DUK_HOBJECT_GET_ESIZE(obj) == 0 && DUK_HOBJECT_GET_ASIZE(obj) == 0));
47953 DUK_ASSERT(new_h_size == 0 || new_h_size >= new_e_size); /* required to guarantee success of rehashing,
47954 * intentionally use unadjusted new_e_size
47955 */
47956 DUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj));
47957 DUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);
47958
47959 /*
47960 * Pre resize assertions.
47961 */
47962
47963#ifdef DUK_USE_ASSERTIONS
47964 /* XXX: pre-checks (such as no duplicate keys) */
47965#endif
47966
47967 /*
47968 * For property layout 1, tweak e_size to ensure that the whole entry
47969 * part (key + val + flags) is a suitable multiple for alignment
47970 * (platform specific).
47971 *
47972 * Property layout 2 does not require this tweaking and is preferred
47973 * on low RAM platforms requiring alignment.
47974 */
47975
47976#if defined(DUK_USE_HOBJECT_LAYOUT_2) || defined(DUK_USE_HOBJECT_LAYOUT_3)
47977 DUK_DDD(DUK_DDDPRINT("using layout 2 or 3, no need to pad e_size: %ld", (long) new_e_size));
47978 new_e_size_adjusted = new_e_size;
47979#elif defined(DUK_USE_HOBJECT_LAYOUT_1) && (DUK_HOBJECT_ALIGN_TARGET == 1)
47980 DUK_DDD(DUK_DDDPRINT("using layout 1, but no need to pad e_size: %ld", (long) new_e_size));
47981 new_e_size_adjusted = new_e_size;
47982#elif defined(DUK_USE_HOBJECT_LAYOUT_1) && ((DUK_HOBJECT_ALIGN_TARGET == 4) || (DUK_HOBJECT_ALIGN_TARGET == 8))
47983 new_e_size_adjusted = (new_e_size + DUK_HOBJECT_ALIGN_TARGET - 1) & (~(DUK_HOBJECT_ALIGN_TARGET - 1));
47984 DUK_DDD(DUK_DDDPRINT("using layout 1, and alignment target is %ld, adjusted e_size: %ld -> %ld",
47985 (long) DUK_HOBJECT_ALIGN_TARGET, (long) new_e_size, (long) new_e_size_adjusted));
47986 DUK_ASSERT(new_e_size_adjusted >= new_e_size);
47987#else
47988#error invalid hobject layout defines
47989#endif
47990
47991 /*
47992 * Debug logging after adjustment.
47993 */
47994
47995 DUK_DDD(DUK_DDDPRINT("attempt to resize hobject %p props (%ld -> %ld bytes), from {p=%p,e_size=%ld,e_next=%ld,a_size=%ld,h_size=%ld} to "
47996 "{e_size=%ld,a_size=%ld,h_size=%ld}, abandon_array=%ld, unadjusted new_e_size=%ld",
47997 (void *) obj,
47998 (long) DUK_HOBJECT_P_COMPUTE_SIZE(DUK_HOBJECT_GET_ESIZE(obj),
47999 DUK_HOBJECT_GET_ASIZE(obj),
48000 DUK_HOBJECT_GET_HSIZE(obj)),
48001 (long) DUK_HOBJECT_P_COMPUTE_SIZE(new_e_size_adjusted, new_a_size, new_h_size),
48002 (void *) DUK_HOBJECT_GET_PROPS(thr->heap, obj),
48003 (long) DUK_HOBJECT_GET_ESIZE(obj),
48004 (long) DUK_HOBJECT_GET_ENEXT(obj),
48005 (long) DUK_HOBJECT_GET_ASIZE(obj),
48006 (long) DUK_HOBJECT_GET_HSIZE(obj),
48007 (long) new_e_size_adjusted,
48008 (long) new_a_size,
48009 (long) new_h_size,
48010 (long) abandon_array,
48011 (long) new_e_size));
48012
48013 /*
48014 * Property count check. This is the only point where we ensure that
48015 * we don't get more (allocated) property space that we can handle.
48016 * There aren't hard limits as such, but some algorithms fail (e.g.
48017 * finding next higher prime, selecting hash part size) if we get too
48018 * close to the 4G property limit.
48019 *
48020 * Since this works based on allocation size (not actually used size),
48021 * the limit is a bit approximate but good enough in practice.
48022 */
48023
48024 if (new_e_size_adjusted + new_a_size > DUK_HOBJECT_MAX_PROPERTIES) {
48025 DUK_ERROR_ALLOC_DEFMSG(thr);
48026 }
48027
48028 /*
48029 * Compute new alloc size and alloc new area.
48030 *
48031 * The new area is allocated as a dynamic buffer and placed into the
48032 * valstack for reachability. The actual buffer is then detached at
48033 * the end.
48034 *
48035 * Note: heap_mark_and_sweep_base_flags are altered here to ensure
48036 * no-one touches this object while we're resizing and rehashing it.
48037 * The flags must be reset on every exit path after it. Finalizers
48038 * and compaction is prevented currently for all objects while it
48039 * would be enough to restrict it only for the current object.
48040 */
48041
48042#ifdef DUK_USE_MARK_AND_SWEEP
48043 prev_mark_and_sweep_base_flags = thr->heap->mark_and_sweep_base_flags;
48045 DUK_MS_FLAG_NO_FINALIZERS | /* avoid attempts to add/remove object keys */
48046 DUK_MS_FLAG_NO_OBJECT_COMPACTION; /* avoid attempt to compact the current object */
48047#endif
48048
48049 new_alloc_size = DUK_HOBJECT_P_COMPUTE_SIZE(new_e_size_adjusted, new_a_size, new_h_size);
48050 DUK_DDD(DUK_DDDPRINT("new hobject allocation size is %ld", (long) new_alloc_size));
48051 new_e_next = 0;
48052 new_e_k = NULL;
48053 if (new_alloc_size == 0) {
48054 /* for zero size, don't push anything on valstack */
48055 DUK_ASSERT(new_e_size_adjusted == 0);
48056 DUK_ASSERT(new_a_size == 0);
48057 DUK_ASSERT(new_h_size == 0);
48058 new_p = NULL;
48059 } else {
48060 /* This may trigger mark-and-sweep with arbitrary side effects,
48061 * including an attempted resize of the object we're resizing,
48062 * executing a finalizer which may add or remove properties of
48063 * the object we're resizing etc.
48064 */
48065
48066#if 0 /* XXX: inject test */
48067 if (1) {
48068 goto alloc_failed;
48069 }
48070#endif
48071 new_p = (duk_uint8_t *) DUK_ALLOC(thr->heap, new_alloc_size);
48072 if (new_p == NULL) {
48073 /* NULL always indicates alloc failure because
48074 * new_alloc_size > 0.
48075 */
48076 goto alloc_failed;
48077 }
48078 }
48079
48080 /* Set up pointers to the new property area: this is hidden behind a macro
48081 * because it is memory layout specific.
48082 */
48083 DUK_HOBJECT_P_SET_REALLOC_PTRS(new_p, new_e_k, new_e_pv, new_e_f, new_a, new_h,
48084 new_e_size_adjusted, new_a_size, new_h_size);
48085 DUK_UNREF(new_h); /* happens when hash part dropped */
48086
48087 /* if new_p == NULL, all of these pointers are NULL */
48088 DUK_ASSERT((new_p != NULL) ||
48089 (new_e_k == NULL && new_e_pv == NULL && new_e_f == NULL &&
48090 new_a == NULL && new_h == NULL));
48091
48092 DUK_DDD(DUK_DDDPRINT("new alloc size %ld, new_e_k=%p, new_e_pv=%p, new_e_f=%p, new_a=%p, new_h=%p",
48093 (long) new_alloc_size, (void *) new_e_k, (void *) new_e_pv, (void *) new_e_f,
48094 (void *) new_a, (void *) new_h));
48095
48096 /*
48097 * Migrate array to start of entries if requested.
48098 *
48099 * Note: from an enumeration perspective the order of entry keys matters.
48100 * Array keys should appear wherever they appeared before the array abandon
48101 * operation.
48102 */
48103
48104 if (abandon_array) {
48105 /*
48106 * Note: assuming new_a_size == 0, and that entry part contains
48107 * no conflicting keys, refcounts do not need to be adjusted for
48108 * the values, as they remain exactly the same.
48109 *
48110 * The keys, however, need to be interned, incref'd, and be
48111 * reachable for GC. Any intern attempt may trigger a GC and
48112 * claim any non-reachable strings, so every key must be reachable
48113 * at all times.
48114 *
48115 * A longjmp must not occur here, as the new_p allocation would
48116 * be freed without these keys being decref'd, hence the messy
48117 * decref handling if intern fails.
48118 */
48119 DUK_ASSERT(new_a_size == 0);
48120
48121 for (i = 0; i < DUK_HOBJECT_GET_ASIZE(obj); i++) {
48122 duk_tval *tv1;
48123 duk_tval *tv2;
48124 duk_hstring *key;
48125
48127
48128 tv1 = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, i);
48129 if (DUK_TVAL_IS_UNUSED(tv1)) {
48130 continue;
48131 }
48132
48133 DUK_ASSERT(new_p != NULL && new_e_k != NULL &&
48134 new_e_pv != NULL && new_e_f != NULL);
48135
48136 /*
48137 * Intern key via the valstack to ensure reachability behaves
48138 * properly. We must avoid longjmp's here so use non-checked
48139 * primitives.
48140 *
48141 * Note: duk_check_stack() potentially reallocs the valstack,
48142 * invalidating any duk_tval pointers to valstack. Callers
48143 * must be careful.
48144 */
48145
48146 /* never shrinks; auto-adds DUK_VALSTACK_INTERNAL_EXTRA, which is generous */
48147 if (!duk_check_stack(ctx, 1)) {
48148 goto abandon_error;
48149 }
48151 key = duk_heap_string_intern_u32(thr->heap, i);
48152 if (!key) {
48153 goto abandon_error;
48154 }
48155 duk_push_hstring(ctx, key); /* keep key reachable for GC etc; guaranteed not to fail */
48156
48157 /* key is now reachable in the valstack */
48158
48159 DUK_HSTRING_INCREF(thr, key); /* second incref for the entry reference */
48160 new_e_k[new_e_next] = key;
48161 tv2 = &new_e_pv[new_e_next].v; /* array entries are all plain values */
48162 DUK_TVAL_SET_TVAL(tv2, tv1);
48163 new_e_f[new_e_next] = DUK_PROPDESC_FLAG_WRITABLE |
48166 new_e_next++;
48167
48168 /* Note: new_e_next matches pushed temp key count, and nothing can
48169 * fail above between the push and this point.
48170 */
48171 }
48172
48173 DUK_DDD(DUK_DDDPRINT("abandon array: pop %ld key temps from valstack", (long) new_e_next));
48174 duk_pop_n(ctx, new_e_next);
48175 }
48176
48177 /*
48178 * Copy keys and values in the entry part (compacting them at the same time).
48179 */
48180
48181 for (i = 0; i < DUK_HOBJECT_GET_ENEXT(obj); i++) {
48182 duk_hstring *key;
48183
48185
48186 key = DUK_HOBJECT_E_GET_KEY(thr->heap, obj, i);
48187 if (!key) {
48188 continue;
48189 }
48190
48191 DUK_ASSERT(new_p != NULL && new_e_k != NULL &&
48192 new_e_pv != NULL && new_e_f != NULL);
48193
48194 new_e_k[new_e_next] = key;
48195 new_e_pv[new_e_next] = DUK_HOBJECT_E_GET_VALUE(thr->heap, obj, i);
48196 new_e_f[new_e_next] = DUK_HOBJECT_E_GET_FLAGS(thr->heap, obj, i);
48197 new_e_next++;
48198 }
48199 /* the entries [new_e_next, new_e_size_adjusted[ are left uninitialized on purpose (ok, not gc reachable) */
48200
48201 /*
48202 * Copy array elements to new array part.
48203 */
48204
48205 if (new_a_size > DUK_HOBJECT_GET_ASIZE(obj)) {
48206 /* copy existing entries as is */
48207 DUK_ASSERT(new_p != NULL && new_a != NULL);
48208 if (DUK_HOBJECT_GET_ASIZE(obj) > 0) {
48209 /* Avoid zero copy with an invalid pointer. If obj->p is NULL,
48210 * the 'new_a' pointer will be invalid which is not allowed even
48211 * when copy size is zero.
48212 */
48215 DUK_MEMCPY((void *) new_a, (void *) DUK_HOBJECT_A_GET_BASE(thr->heap, obj), sizeof(duk_tval) * DUK_HOBJECT_GET_ASIZE(obj));
48216 }
48217
48218 /* fill new entries with -unused- (required, gc reachable) */
48219 for (i = DUK_HOBJECT_GET_ASIZE(obj); i < new_a_size; i++) {
48220 duk_tval *tv = &new_a[i];
48222 }
48223 } else {
48224#ifdef DUK_USE_ASSERTIONS
48225 /* caller must have decref'd values above new_a_size (if that is necessary) */
48226 if (!abandon_array) {
48227 for (i = new_a_size; i < DUK_HOBJECT_GET_ASIZE(obj); i++) {
48228 duk_tval *tv;
48229 tv = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, i);
48230
48231 /* current assertion is quite strong: decref's and set to unused */
48233 }
48234 }
48235#endif
48236 if (new_a_size > 0) {
48237 /* Avoid zero copy with an invalid pointer. If obj->p is NULL,
48238 * the 'new_a' pointer will be invalid which is not allowed even
48239 * when copy size is zero.
48240 */
48242 DUK_ASSERT(new_a_size > 0);
48243 DUK_MEMCPY((void *) new_a, (void *) DUK_HOBJECT_A_GET_BASE(thr->heap, obj), sizeof(duk_tval) * new_a_size);
48244 }
48245 }
48246
48247 /*
48248 * Rebuild the hash part always from scratch (guaranteed to finish).
48249 *
48250 * Any resize of hash part requires rehashing. In addition, by rehashing
48251 * get rid of any elements marked deleted (DUK__HASH_DELETED) which is critical
48252 * to ensuring the hash part never fills up.
48253 */
48254
48255#if defined(DUK_USE_HOBJECT_HASH_PART)
48256 if (DUK_UNLIKELY(new_h_size > 0)) {
48257 DUK_ASSERT(new_h != NULL);
48258
48259 /* fill new_h with u32 0xff = UNUSED */
48261 DUK_ASSERT(new_h_size > 0);
48262 DUK_MEMSET(new_h, 0xff, sizeof(duk_uint32_t) * new_h_size);
48263
48264 DUK_ASSERT(new_e_next <= new_h_size); /* equality not actually possible */
48265 for (i = 0; i < new_e_next; i++) {
48266 duk_hstring *key = new_e_k[i];
48267 duk_uint32_t j, step;
48268
48269 DUK_ASSERT(key != NULL);
48270 j = DUK__HASH_INITIAL(DUK_HSTRING_GET_HASH(key), new_h_size);
48272
48273 for (;;) {
48274 DUK_ASSERT(new_h[j] != DUK__HASH_DELETED); /* should never happen */
48275 if (new_h[j] == DUK__HASH_UNUSED) {
48276 DUK_DDD(DUK_DDDPRINT("rebuild hit %ld -> %ld", (long) j, (long) i));
48277 new_h[j] = i;
48278 break;
48279 }
48280 DUK_DDD(DUK_DDDPRINT("rebuild miss %ld, step %ld", (long) j, (long) step));
48281 j = (j + step) % new_h_size;
48282
48283 /* guaranteed to finish */
48284 DUK_ASSERT(j != (duk_uint32_t) DUK__HASH_INITIAL(DUK_HSTRING_GET_HASH(key), new_h_size));
48285 }
48286 }
48287 } else {
48288 DUK_DDD(DUK_DDDPRINT("no hash part, no rehash"));
48289 }
48290#endif /* DUK_USE_HOBJECT_HASH_PART */
48291
48292 /*
48293 * Nice debug log.
48294 */
48295
48296 DUK_DD(DUK_DDPRINT("resized hobject %p props (%ld -> %ld bytes), from {p=%p,e_size=%ld,e_next=%ld,a_size=%ld,h_size=%ld} to "
48297 "{p=%p,e_size=%ld,e_next=%ld,a_size=%ld,h_size=%ld}, abandon_array=%ld, unadjusted new_e_size=%ld",
48298 (void *) obj,
48302 (long) new_alloc_size,
48303 (void *) DUK_HOBJECT_GET_PROPS(thr->heap, obj),
48304 (long) DUK_HOBJECT_GET_ESIZE(obj),
48305 (long) DUK_HOBJECT_GET_ENEXT(obj),
48306 (long) DUK_HOBJECT_GET_ASIZE(obj),
48307 (long) DUK_HOBJECT_GET_HSIZE(obj),
48308 (void *) new_p,
48309 (long) new_e_size_adjusted,
48310 (long) new_e_next,
48311 (long) new_a_size,
48312 (long) new_h_size,
48313 (long) abandon_array,
48314 (long) new_e_size));
48315
48316 /*
48317 * All done, switch properties ('p') allocation to new one.
48318 */
48319
48320 DUK_FREE(thr->heap, DUK_HOBJECT_GET_PROPS(thr->heap, obj)); /* NULL obj->p is OK */
48321 DUK_HOBJECT_SET_PROPS(thr->heap, obj, new_p);
48322 DUK_HOBJECT_SET_ESIZE(obj, new_e_size_adjusted);
48323 DUK_HOBJECT_SET_ENEXT(obj, new_e_next);
48324 DUK_HOBJECT_SET_ASIZE(obj, new_a_size);
48325 DUK_HOBJECT_SET_HSIZE(obj, new_h_size);
48326
48327 /* clear array part flag only after switching */
48328 if (abandon_array) {
48330 }
48331
48332 DUK_DDD(DUK_DDDPRINT("resize result: %!O", (duk_heaphdr *) obj));
48333
48334#ifdef DUK_USE_MARK_AND_SWEEP
48335 thr->heap->mark_and_sweep_base_flags = prev_mark_and_sweep_base_flags;
48336#endif
48337
48338 /*
48339 * Post resize assertions.
48340 */
48341
48342#ifdef DUK_USE_ASSERTIONS
48343 /* XXX: post-checks (such as no duplicate keys) */
48344#endif
48345 return;
48346
48347 /*
48348 * Abandon array failed, need to decref keys already inserted
48349 * into the beginning of new_e_k before unwinding valstack.
48350 */
48351
48352 abandon_error:
48353 alloc_failed:
48354 DUK_D(DUK_DPRINT("object property table resize failed"));
DUK_INTERNAL_DECL duk_hstring * duk_heap_string_intern_u32(duk_heap *heap, duk_uint32_t val)
#define DUK_TVAL_SET_UNUSED(tv)
#define DUK_HOBJECT_SET_ESIZE(h, v)
#define DUK_HOBJECT_SET_ENEXT(h, v)
#define DUK_HOBJECT_SET_ASIZE(h, v)
#define DUK_HOBJECT_CLEAR_ARRAY_PART(h)
DUK_EXTERNAL duk_bool_t duk_check_stack(duk_context *ctx, duk_idx_t extra)
#define DUK_HOBJECT_SET_HSIZE(h, v)
union duk_tval_struct::@18 v

References DUK__HASH_DELETED, DUK__HASH_INITIAL, DUK__HASH_PROBE_STEP, DUK__HASH_UNUSED, DUK__VALSTACK_SPACE, DUK_ALLOC, DUK_ASSERT, DUK_ASSERT_VALSTACK_SPACE, duk_check_stack(), DUK_D, DUK_DD, DUK_DDD, DUK_DDDPRINT, DUK_DDPRINT, DUK_DPRINT, DUK_ERROR_ALLOC_DEFMSG, DUK_FREE, duk_heap_string_intern_u32(), DUK_HEAPHDR_HAS_READONLY, DUK_HOBJECT_A_GET_BASE, DUK_HOBJECT_A_GET_VALUE_PTR, DUK_HOBJECT_ALIGN_TARGET, DUK_HOBJECT_CLEAR_ARRAY_PART, DUK_HOBJECT_E_GET_FLAGS, DUK_HOBJECT_E_GET_KEY, DUK_HOBJECT_E_GET_VALUE, DUK_HOBJECT_GET_ASIZE, DUK_HOBJECT_GET_ENEXT, DUK_HOBJECT_GET_ESIZE, DUK_HOBJECT_GET_HSIZE, DUK_HOBJECT_GET_PROPS, DUK_HOBJECT_MAX_PROPERTIES, DUK_HOBJECT_P_COMPUTE_SIZE, DUK_HOBJECT_P_SET_REALLOC_PTRS, DUK_HOBJECT_SET_ASIZE, DUK_HOBJECT_SET_ENEXT, DUK_HOBJECT_SET_ESIZE, DUK_HOBJECT_SET_HSIZE, DUK_HOBJECT_SET_PROPS, DUK_HSTRING_GET_HASH, DUK_HSTRING_INCREF, DUK_MEMCPY, DUK_MEMSET, DUK_MS_FLAG_NO_FINALIZERS, DUK_MS_FLAG_NO_OBJECT_COMPACTION, duk_pop_n(), DUK_PROPDESC_FLAG_CONFIGURABLE, DUK_PROPDESC_FLAG_ENUMERABLE, DUK_PROPDESC_FLAG_WRITABLE, duk_push_hstring(), DUK_TVAL_IS_UNUSED, DUK_TVAL_SET_TVAL, DUK_TVAL_SET_UNUSED, DUK_UNLIKELY, DUK_UNREF, duk_hthread::heap, duk_heap::mark_and_sweep_base_flags, NULL, and duk_propvalue::v.

◆ duk__recheck_strtab_size_probe()

DUK_LOCAL duk_bool_t duk__recheck_strtab_size_probe ( duk_heap * heap,
duk_uint32_t new_used )

Definition at line 45785 of file duktape-1.8.0/src/duktape.c.

45785 {
45787 } else {
45789 new_size = duk_util_get_hash_prime(new_size);
45790 }
45791 DUK_ASSERT(new_size > 0);
45792
45793 /* rehash even if old and new sizes are the same to get rid of
45794 * DELETED entries.
45795 */
45796
45797 ret = duk__resize_strtab_raw_probe(heap, new_size);
45798
45799 return ret;
45800}
45801
45802DUK_LOCAL duk_bool_t duk__recheck_strtab_size_probe(duk_heap *heap, duk_uint32_t new_used) {
45803 duk_uint32_t new_free;
45804 duk_uint32_t tmp1;
45805 duk_uint32_t tmp2;
#define DUK_STRTAB_HIGHEST_32BIT_PRIME
DUK_LOCAL duk_bool_t duk__resize_strtab_raw_probe(duk_heap *heap, duk_uint32_t new_size)
#define DUK_STRTAB_GROW_ST_SIZE(n)

References DUK_STRTAB_HIGHEST_32BIT_PRIME.

◆ duk__reconfig_valstack_ecma_catcher()

DUK_LOCAL void duk__reconfig_valstack_ecma_catcher ( duk_hthread * thr,
duk_size_t act_idx,
duk_size_t cat_idx )

Definition at line 66190 of file duktape-1.8.0/src/duktape.c.

66207 {
66208 duk_activation *act;
66209 duk_catcher *cat;
66210 duk_hcompiledfunction *h_func;
66211 duk_idx_t clamp_top;
66212
66213 DUK_ASSERT(thr != NULL);
66214 DUK_ASSERT_DISABLE(act_idx >= 0); /* unsigned */
66215 DUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack + act_idx) != NULL);
66217 DUK_ASSERT_DISABLE(thr->callstack[act_idx].idx_retval >= 0); /* unsigned */
66218
66219 act = thr->callstack + act_idx;
66220 cat = thr->catchstack + cat_idx;
66221 h_func = (duk_hcompiledfunction *) DUK_ACT_GET_FUNC(act);
66222

◆ duk__reconfig_valstack_ecma_return()

DUK_LOCAL void duk__reconfig_valstack_ecma_return ( duk_hthread * thr,
duk_size_t act_idx )

Definition at line 66154 of file duktape-1.8.0/src/duktape.c.

66155 : should not ordinarily throw errors; if errors
66156 * occur (e.g. due to out-of-memory) they bubble outwards rather than being
66157 * handled recursively.
66158 */
66159
66160#define DUK__LONGJMP_RESTART 0 /* state updated, restart bytecode execution */
66161#define DUK__LONGJMP_RETHROW 1 /* exit bytecode executor by rethrowing an error to caller */
66162
66163#define DUK__RETHAND_RESTART 0 /* state updated, restart bytecode execution */
66164#define DUK__RETHAND_FINISHED 1 /* exit bytecode execution with return value */
66165
66166/* XXX: optimize reconfig valstack operations so that resize, clamp, and setting
66167 * top are combined into one pass.
66168 */
66169
66170/* Reconfigure value stack for return to an Ecmascript function at 'act_idx'. */
66172 duk_activation *act;
66173 duk_hcompiledfunction *h_func;
66174 duk_idx_t clamp_top;
66175
66176 DUK_ASSERT(thr != NULL);
66177 DUK_ASSERT_DISABLE(act_idx >= 0); /* unsigned */
66178 DUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack + act_idx) != NULL);
66180 DUK_ASSERT_DISABLE(thr->callstack[act_idx].idx_retval >= 0); /* unsigned */
66181
66182 /* Clamp so that values at 'clamp_top' and above are wiped and won't
66183 * retain reachable garbage. Then extend to 'nregs' because we're
66184 * returning to an Ecmascript function.
66185 */
66186
66187 act = thr->callstack + act_idx;
66188 h_func = (duk_hcompiledfunction *) DUK_ACT_GET_FUNC(act);

References duk_hthread::callstack, DUK_ACT_GET_FUNC, DUK_ASSERT, DUK_ASSERT_DISABLE, DUK_HOBJECT_IS_COMPILEDFUNCTION, duk_activation::idx_retval, and NULL.

◆ duk__recursion_decrease()

DUK_LOCAL void duk__recursion_decrease ( duk_compiler_ctx * comp_ctx)

Definition at line 58104 of file duktape-1.8.0/src/duktape.c.

◆ duk__recursion_increase()

DUK_LOCAL void duk__recursion_increase ( duk_compiler_ctx * comp_ctx)

Definition at line 58095 of file duktape-1.8.0/src/duktape.c.

◆ duk__refcount_finalize_hobject()

DUK_LOCAL void duk__refcount_finalize_hobject ( duk_hthread * thr,
duk_hobject * h )

Definition at line 44138 of file duktape-1.8.0/src/duktape.c.

44155 {
44157
44158 DUK_ASSERT(h);
44160
44161 /* XXX: better to get base and walk forwards? */
44162
44163 for (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ENEXT(h); i++) {
44164 duk_hstring *key = DUK_HOBJECT_E_GET_KEY(thr->heap, h, i);
44165 if (!key) {
44166 continue;
44167 }
44168 duk_heaphdr_decref(thr, (duk_heaphdr *) key);
44169 if (DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, h, i)) {
44172 } else {
44174 }
44175 }
44176
44177 for (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ASIZE(h); i++) {
44179 }
44180
44181 /* hash part is a 'weak reference' and does not contribute */
44182
44184
44187 duk_tval *tv, *tv_end;
44188 duk_hobject **funcs, **funcs_end;
44189
44190 if (DUK_HCOMPILEDFUNCTION_GET_DATA(thr->heap, f) != NULL) {
44193 while (tv < tv_end) {
44194 duk_tval_decref(thr, tv);
44195 tv++;
44196 }
44197
44199 funcs_end = DUK_HCOMPILEDFUNCTION_GET_FUNCS_END(thr->heap, f);
44200 while (funcs < funcs_end) {
44202 funcs++;
44203 }
44204 } else {
44205 /* May happen in some out-of-memory corner cases. */
44206 DUK_D(DUK_DPRINT("duk_hcompiledfunction 'data' is NULL, skipping decref"));
44207 }
44208
44210 } else if (DUK_HOBJECT_IS_NATIVEFUNCTION(h)) {
44212 DUK_UNREF(f);
44213 /* nothing to finalize */
44214 } else if (DUK_HOBJECT_IS_BUFFEROBJECT(h)) {
44216 if (b->buf) {
44217 duk_heaphdr_decref(thr, (duk_heaphdr *) b->buf);
44218 }
44219 } else if (DUK_HOBJECT_IS_THREAD(h)) {
44220 duk_hthread *t = (duk_hthread *) h;
44221 duk_tval *tv;
44222
44223 tv = t->valstack;
44224 while (tv < t->valstack_top) {
44225 duk_tval_decref(thr, tv);
44226 tv++;
44227 }
44228
44229 for (i = 0; i < (duk_uint_fast32_t) t->callstack_top; i++) {
44230 duk_activation *act = t->callstack + i;
44234#ifdef DUK_USE_NONSTD_FUNC_CALLER_PROPERTY
DUK_INTERNAL_DECL void duk_heaphdr_decref_allownull(duk_hthread *thr, duk_heaphdr *h)
DUK_INTERNAL_DECL void duk_tval_decref(duk_hthread *thr, duk_tval *tv)
DUK_INTERNAL_DECL void duk_heaphdr_decref(duk_hthread *thr, duk_heaphdr *h)

◆ duk__refzero_free_pending()

DUK_LOCAL void duk__refzero_free_pending ( duk_hthread * thr)

Definition at line 44318 of file duktape-1.8.0/src/duktape.c.

44335 {
44336 duk_heaphdr *h1, *h2;
44337 duk_heap *heap;
44338 duk_int_t count = 0;
44339
44340 DUK_ASSERT(thr != NULL);
44341 DUK_ASSERT(thr->heap != NULL);
44342 heap = thr->heap;
44343 DUK_ASSERT(heap != NULL);
44344
44345 /*
44346 * Detect recursive invocation
44347 */
44348
44350 DUK_DDD(DUK_DDDPRINT("refzero free running, skip run"));
44351 return;
44352 }
44353
44354 /*
44355 * Churn refzero_list until empty
44356 */
44357
44359 while (heap->refzero_list) {
44360 duk_hobject *obj;
44361 duk_bool_t rescued = 0;
44362
44363 /*
44364 * Pick an object from the head (don't remove yet).
44365 */
44366
44367 h1 = heap->refzero_list;
44368 obj = (duk_hobject *) h1;
44369 DUK_DD(DUK_DDPRINT("refzero processing %p: %!O", (void *) h1, (duk_heaphdr *) h1));
44370 DUK_ASSERT(DUK_HEAPHDR_GET_PREV(heap, h1) == NULL);
44371 DUK_ASSERT(DUK_HEAPHDR_GET_TYPE(h1) == DUK_HTYPE_OBJECT); /* currently, always the case */
44372
44373#if defined(DUK_USE_REFZERO_FINALIZER_TORTURE)
44374 /* Torture option to shake out finalizer side effect issues:
44375 * make a bogus function call for every finalizable object,
44376 * essentially simulating the case where everything has a
44377 * finalizer.
44378 */
44379 DUK_DD(DUK_DDPRINT("refzero torture enabled, fake finalizer"));
44381 DUK_HEAPHDR_PREINC_REFCOUNT(h1); /* bump refcount to prevent refzero during finalizer processing */
44382 duk__refcount_run_torture_finalizer(thr, obj); /* must never longjmp */
44383 DUK_HEAPHDR_PREDEC_REFCOUNT(h1); /* remove artificial bump */
44384 DUK_ASSERT_DISABLE(h1->h_refcount >= 0); /* refcount is unsigned, so always true */
44385#endif
44386
44387 /*
44388 * Finalizer check.
44389 *
44390 * Note: running a finalizer may have arbitrary side effects, e.g.
44391 * queue more objects on refzero_list (tail), or even trigger a
44392 * mark-and-sweep.
44393 *
44394 * Note: quick reject check should match vast majority of
44395 * objects and must be safe (not throw any errors, ever).
44396 */
44397
44398 /* An object may have FINALIZED here if it was finalized by mark-and-sweep
44399 * on a previous run and refcount then decreased to zero. We won't run the
44400 * finalizer again here.
44401 */
44402
44403 /* A finalizer is looked up from the object and up its prototype chain
44404 * (which allows inherited finalizers).
44405 */
44407 DUK_DDD(DUK_DDDPRINT("object has a finalizer, run it"));
44408
44410 DUK_HEAPHDR_PREINC_REFCOUNT(h1); /* bump refcount to prevent refzero during finalizer processing */
44411
44412 duk_hobject_run_finalizer(thr, obj); /* must never longjmp */
44413 DUK_ASSERT(DUK_HEAPHDR_HAS_FINALIZED(h1)); /* duk_hobject_run_finalizer() sets */
44414
44415 DUK_HEAPHDR_PREDEC_REFCOUNT(h1); /* remove artificial bump */
44416 DUK_ASSERT_DISABLE(h1->h_refcount >= 0); /* refcount is unsigned, so always true */
44417
44418 if (DUK_HEAPHDR_GET_REFCOUNT(h1) != 0) {
44419 DUK_DDD(DUK_DDDPRINT("-> object refcount after finalization non-zero, object will be rescued"));
44420 rescued = 1;
44421 } else {
44422 DUK_DDD(DUK_DDDPRINT("-> object refcount still zero after finalization, object will be freed"));
44423 }
44424 }
44425
44426 /* Refzero head is still the same. This is the case even if finalizer
44427 * inserted more refzero objects; they are inserted to the tail.
44428 */
44429 DUK_ASSERT(h1 == heap->refzero_list);
44430
44431 /*
44432 * Remove the object from the refzero list. This cannot be done
44433 * before a possible finalizer has been executed; the finalizer
44434 * may trigger a mark-and-sweep, and mark-and-sweep must be able
44435 * to traverse a complete refzero_list.
44436 */
44437
44438 h2 = DUK_HEAPHDR_GET_NEXT(heap, h1);
44439 if (h2) {
44440 DUK_HEAPHDR_SET_PREV(heap, h2, NULL); /* not strictly necessary */
44441 heap->refzero_list = h2;
44442 } else {
44443 heap->refzero_list = NULL;
44444 heap->refzero_list_tail = NULL;
44445 }
44446
44447 /*
44448 * Rescue or free.
44449 */
44450
44451 if (rescued) {
44452 /* yes -> move back to heap allocated */
44453 DUK_DD(DUK_DDPRINT("object rescued during refcount finalization: %p", (void *) h1));
44457 h2 = heap->heap_allocated;
44458 DUK_HEAPHDR_SET_PREV(heap, h1, NULL);
44459 if (h2) {
44460 DUK_HEAPHDR_SET_PREV(heap, h2, h1);
44461 }
44462 DUK_HEAPHDR_SET_NEXT(heap, h1, h2);
44463 DUK_ASSERT_HEAPHDR_LINKS(heap, h1);
44464 DUK_ASSERT_HEAPHDR_LINKS(heap, h2);
44465 heap->heap_allocated = h1;
44466 } else {
44467 /* no -> decref members, then free */
44469 duk_heap_free_heaphdr_raw(heap, h1);
44470 }
44471
44472 count++;
44473 }
44475
44476 DUK_DDD(DUK_DDDPRINT("refzero processed %ld objects", (long) count));
44477
44478 /*
44479 * Once the whole refzero cascade has been freed, check for
44480 * a voluntary mark-and-sweep.
44481 */
44482
44483#if defined(DUK_USE_MARK_AND_SWEEP) && defined(DUK_USE_VOLUNTARY_GC)
44484 /* 'count' is more or less comparable to normal trigger counter update
#define DUK_HEAPHDR_CLEAR_FINALIZED(h)
#define DUK_HEAPHDR_SET_NEXT(heap, h, val)
#define DUK_HEAPHDR_GET_PREV(heap, h)
#define DUK_HEAPHDR_SET_PREV(heap, h, val)
#define DUK_HEAPHDR_PREINC_REFCOUNT(h)
#define DUK_HEAP_SET_REFZERO_FREE_RUNNING(heap)
DUK_LOCAL void duk__refcount_finalize_hobject(duk_hthread *thr, duk_hobject *h)
#define DUK_HEAP_HAS_REFZERO_FREE_RUNNING(heap)
#define DUK_HEAP_CLEAR_REFZERO_FREE_RUNNING(heap)
#define DUK_ASSERT_HEAPHDR_LINKS(heap, h)

◆ duk__regexp_match_helper()

DUK_LOCAL void duk__regexp_match_helper ( duk_hthread * thr,
duk_small_int_t force_global )

Definition at line 79386 of file duktape-1.8.0/src/duktape.c.

79386 :
79387 DUK_ERROR_INTERNAL_DEFMSG(re_ctx->thr);
79388 return NULL; /* never here */
79389}
79390
79391/*
79392 * Exposed matcher function which provides the semantics of RegExp.prototype.exec().
79393 *
79394 * RegExp.prototype.test() has the same semantics as exec() but does not return the
79395 * result object (which contains the matching string and capture groups). Currently
79396 * there is no separate test() helper, so a temporary result object is created and
79397 * discarded if test() is needed. This is intentional, to save code space.
79398 *
79399 * Input stack: [ ... re_obj input ]
79400 * Output stack: [ ... result ]
79401 */
79402
79404 duk_context *ctx = (duk_context *) thr;
79405 duk_re_matcher_ctx re_ctx;
79406 duk_hobject *h_regexp;
79407 duk_hstring *h_bytecode;
79408 duk_hstring *h_input;
79409 duk_uint8_t *p_buf;
79410 const duk_uint8_t *pc;
79411 const duk_uint8_t *sp;
79413 duk_small_int_t global;
79415 double d;
79416 duk_uint32_t char_offset;
79417
79418 DUK_ASSERT(thr != NULL);
79419 DUK_ASSERT(ctx != NULL);
79420
79421 DUK_DD(DUK_DDPRINT("regexp match: regexp=%!T, input=%!T",
79422 (duk_tval *) duk_get_tval(ctx, -2),
79423 (duk_tval *) duk_get_tval(ctx, -1)));
79424
79425 /*
79426 * Regexp instance check, bytecode check, input coercion.
79427 *
79428 * See E5 Section 15.10.6.
79429 */
79430
79431 /* TypeError if wrong; class check, see E5 Section 15.10.6 */
79433 DUK_ASSERT(h_regexp != NULL);
79435 DUK_UNREF(h_regexp);
79436
79437 duk_to_string(ctx, -1);
79438 h_input = duk_get_hstring(ctx, -1);
79439 DUK_ASSERT(h_input != NULL);
79440
79441 duk_get_prop_stridx(ctx, -2, DUK_STRIDX_INT_BYTECODE); /* [ ... re_obj input ] -> [ ... re_obj input bc ] */
79442 h_bytecode = duk_require_hstring(ctx, -1); /* no regexp instance should exist without a non-configurable bytecode property */
79443 DUK_ASSERT(h_bytecode != NULL);
79444
79445 /*
79446 * Basic context initialization.
79447 *
79448 * Some init values are read from the bytecode header
79449 * whose format is (UTF-8 codepoints):
79450 *
79451 * uint flags
79452 * uint nsaved (even, 2n+2 where n = num captures)
79453 */
79454
79455 /* [ ... re_obj input bc ] */
79456
79457 DUK_MEMZERO(&re_ctx, sizeof(re_ctx));
79458
79459 re_ctx.thr = thr;
79460 re_ctx.input = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input);
79461 re_ctx.input_end = re_ctx.input + DUK_HSTRING_GET_BYTELEN(h_input);
79462 re_ctx.bytecode = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_bytecode);
79463 re_ctx.bytecode_end = re_ctx.bytecode + DUK_HSTRING_GET_BYTELEN(h_bytecode);
79464 re_ctx.saved = NULL;
79467
79468 /* read header */
79469 pc = re_ctx.bytecode;
79470 re_ctx.re_flags = duk__bc_get_u32(&re_ctx, &pc);
79471 re_ctx.nsaved = duk__bc_get_u32(&re_ctx, &pc);
79472 re_ctx.bytecode = pc;
79473
79474 DUK_ASSERT(DUK_RE_FLAG_GLOBAL < 0x10000UL); /* must fit into duk_small_int_t */
79475 global = (duk_small_int_t) (force_global | (re_ctx.re_flags & DUK_RE_FLAG_GLOBAL));
79476
79477 DUK_ASSERT(re_ctx.nsaved >= 2);
79478 DUK_ASSERT((re_ctx.nsaved % 2) == 0);
79479
79480 p_buf = (duk_uint8_t *) duk_push_fixed_buffer(ctx, sizeof(duk_uint8_t *) * re_ctx.nsaved);
79481 DUK_UNREF(p_buf);
79482 re_ctx.saved = (const duk_uint8_t **) duk_get_buffer(ctx, -1, NULL);
79483 DUK_ASSERT(re_ctx.saved != NULL);
79484
79485 /* [ ... re_obj input bc saved_buf ] */
79486
79487#if defined(DUK_USE_EXPLICIT_NULL_INIT)
79488 for (i = 0; i < re_ctx.nsaved; i++) {
79489 re_ctx.saved[i] = (duk_uint8_t *) NULL;
79490 }
79491#elif defined(DUK_USE_ZERO_BUFFER_DATA)
79492 /* buffer is automatically zeroed */
79493#else
79494 DUK_MEMZERO((void *) p_buf, sizeof(duk_uint8_t *) * re_ctx.nsaved);
79495#endif
79496
79497 DUK_DDD(DUK_DDDPRINT("regexp ctx initialized, flags=0x%08lx, nsaved=%ld, recursion_limit=%ld, steps_limit=%ld",
79498 (unsigned long) re_ctx.re_flags, (long) re_ctx.nsaved, (long) re_ctx.recursion_limit,
79499 (long) re_ctx.steps_limit));
79500
79501 /*
79502 * Get starting character offset for match, and initialize 'sp' based on it.
79503 *
79504 * Note: lastIndex is non-configurable so it must be present (we check the
79505 * internal class of the object above, so we know it is). User code can set
79506 * its value to an arbitrary (garbage) value though; E5 requires that lastIndex
79507 * be coerced to a number before using. The code below works even if the
79508 * property is missing: the value will then be coerced to zero.
79509 *
79510 * Note: lastIndex may be outside Uint32 range even after ToInteger() coercion.
79511 * For instance, ToInteger(+Infinity) = +Infinity. We track the match offset
79512 * as an integer, but pre-check it to be inside the 32-bit range before the loop.
79513 * If not, the check in E5 Section 15.10.6.2, step 9.a applies.
79514 */
79515
79516 /* XXX: lastIndex handling produces a lot of asm */
79517
79518 /* [ ... re_obj input bc saved_buf ] */
79519
79520 duk_get_prop_stridx(ctx, -4, DUK_STRIDX_LAST_INDEX); /* -> [ ... re_obj input bc saved_buf lastIndex ] */
79521 (void) duk_to_int(ctx, -1); /* ToInteger(lastIndex) */
79522 d = duk_get_number(ctx, -1); /* integer, but may be +/- Infinite, +/- zero (not NaN, though) */
79523 duk_pop(ctx);
79524
79525 if (global) {
79526 if (d < 0.0 || d > (double) DUK_HSTRING_GET_CHARLEN(h_input)) {
79527 /* match fail */
79528 char_offset = 0; /* not really necessary */
79529 DUK_ASSERT(match == 0);
79530 goto match_over;
79531 }
79532 char_offset = (duk_uint32_t) d;
79533 } else {
79534 /* lastIndex must be ignored for non-global regexps, but get the
79535 * value for (theoretical) side effects. No side effects can
79536 * really occur, because lastIndex is a normal property and is
79537 * always non-configurable for RegExp instances.
79538 */
79539 char_offset = (duk_uint32_t) 0;
79540 }
79541
79542 sp = re_ctx.input + duk_heap_strcache_offset_char2byte(thr, h_input, char_offset);
79543
79544 /*
79545 * Match loop.
79546 *
79547 * Try matching at different offsets until match found or input exhausted.
79548 */
79549
79550 /* [ ... re_obj input bc saved_buf ] */
79551
79552 DUK_ASSERT(match == 0);
79553
79554 for (;;) {
79555 /* char offset in [0, h_input->clen] (both ends inclusive), checked before entry */
79556 DUK_ASSERT_DISABLE(char_offset >= 0);
79557 DUK_ASSERT(char_offset <= DUK_HSTRING_GET_CHARLEN(h_input));
79558
79559 /* Note: ctx.steps is intentionally not reset, it applies to the entire unanchored match */
79560 DUK_ASSERT(re_ctx.recursion_depth == 0);
79561
79562 DUK_DDD(DUK_DDDPRINT("attempt match at char offset %ld; %p [%p,%p]",
79563 (long) char_offset, (const void *) sp,
79564 (const void *) re_ctx.input, (const void *) re_ctx.input_end));
79565
79566 /*
79567 * Note:
79568 *
79569 * - duk__match_regexp() is required not to longjmp() in ordinary "non-match"
79570 * conditions; a longjmp() will terminate the entire matching process.
79571 *
79572 * - Clearing saved[] is not necessary because backtracking does it
79573 *
79574 * - Backtracking also rewinds ctx.recursion back to zero, unless an
79575 * internal/limit error occurs (which causes a longjmp())
79576 *
79577 * - If we supported anchored matches, we would break out here
79578 * unconditionally; however, Ecmascript regexps don't have anchored
79579 * matches. It might make sense to implement a fast bail-out if
79580 * the regexp begins with '^' and sp is not 0: currently we'll just
79581 * run through the entire input string, trivially failing the match
79582 * at every non-zero offset.
79583 */
79584
79585 if (duk__match_regexp(&re_ctx, re_ctx.bytecode, sp) != NULL) {
79586 DUK_DDD(DUK_DDDPRINT("match at offset %ld", (long) char_offset));
79587 match = 1;
79588 break;
79589 }
79590
79591 /* advance by one character (code point) and one char_offset */
79592 char_offset++;
79593 if (char_offset > DUK_HSTRING_GET_CHARLEN(h_input)) {
79594 /*
79595 * Note:
79596 *
79597 * - Intentionally attempt (empty) match at char_offset == k_input->clen
79598 *
79599 * - Negative char_offsets have been eliminated and char_offset is duk_uint32_t
79600 * -> no need or use for a negative check
79601 */
79602
79603 DUK_DDD(DUK_DDDPRINT("no match after trying all sp offsets"));
79604 break;
79605 }
79606
79607 /* avoid calling at end of input, will DUK_ERROR (above check suffices to avoid this) */
79608 (void) duk__utf8_advance(thr, &sp, re_ctx.input, re_ctx.input_end, (duk_uint_fast32_t) 1);
79609 }
79610
79611 match_over:
79612
79613 /*
79614 * Matching complete, create result array or return a 'null'. Update lastIndex
79615 * if necessary. See E5 Section 15.10.6.2.
79616 *
79617 * Because lastIndex is a character (not byte) offset, we need the character
79618 * length of the match which we conveniently get as a side effect of interning
79619 * the matching substring (0th index of result array).
79620 *
79621 * saved[0] start pointer (~ byte offset) of current match
79622 * saved[1] end pointer (~ byte offset) of current match (exclusive)
79623 * char_offset start character offset of current match (-> .index of result)
79624 * char_end_offset end character offset (computed below)
79625 */
79626
79627 /* [ ... re_obj input bc saved_buf ] */
79628
79629 if (match) {
79630#ifdef DUK_USE_ASSERTIONS
79631 duk_hobject *h_res;
79632#endif
79633 duk_uint32_t char_end_offset = 0;
79634
79635 DUK_DDD(DUK_DDDPRINT("regexp matches at char_offset %ld", (long) char_offset));
79636
79637 DUK_ASSERT(re_ctx.nsaved >= 2); /* must have start and end */
79638 DUK_ASSERT((re_ctx.nsaved % 2) == 0); /* and even number */
79639
79640 /* XXX: Array size is known before and (2 * re_ctx.nsaved) but not taken
79641 * advantage of now. The array is not compacted either, as regexp match
79642 * objects are usually short lived.
79643 */
79644
79645 duk_push_array(ctx);
79646
79647#ifdef DUK_USE_ASSERTIONS
79648 h_res = duk_require_hobject(ctx, -1);
79652#endif
79653
79654 /* [ ... re_obj input bc saved_buf res_obj ] */
79655
79656 duk_push_u32(ctx, char_offset);
79658
79659 duk_dup(ctx, -4);
79661
79662 for (i = 0; i < re_ctx.nsaved; i += 2) {
79663 /* Captures which are undefined have NULL pointers and are returned
79664 * as 'undefined'. The same is done when saved[] pointers are insane
79665 * (this should, of course, never happen in practice).
79666 */
79667 if (re_ctx.saved[i] && re_ctx.saved[i+1] && re_ctx.saved[i+1] >= re_ctx.saved[i]) {
79668 duk_hstring *h_saved;
79669
79670 duk_push_lstring(ctx,
79671 (const char *) re_ctx.saved[i],
79672 (duk_size_t) (re_ctx.saved[i+1] - re_ctx.saved[i]));
79673 h_saved = duk_get_hstring(ctx, -1);
79674 DUK_ASSERT(h_saved != NULL);
79675
79676 if (i == 0) {
79677 /* Assumes that saved[0] and saved[1] are always
79678 * set by regexp bytecode (if not, char_end_offset
79679 * will be zero). Also assumes clen reflects the
79680 * correct char length.
79681 */
79682 char_end_offset = char_offset + DUK_HSTRING_GET_CHARLEN(h_saved);
79683 }
79684 } else {
79685 duk_push_undefined(ctx);
79686 }
79687
79688 /* [ ... re_obj input bc saved_buf res_obj val ] */
79689 duk_put_prop_index(ctx, -2, i / 2);
79690 }
79691
79692 /* [ ... re_obj input bc saved_buf res_obj ] */
79693
79694 /* NB: 'length' property is automatically updated by the array setup loop */
79695
79696 if (global) {
79697 /* global regexp: lastIndex updated on match */
79698 duk_push_u32(ctx, char_end_offset);
79700 } else {
79701 /* non-global regexp: lastIndex never updated on match */
79702 ;
79703 }
79704 } else {
79705 /*
79706 * No match, E5 Section 15.10.6.2, step 9.a.i - 9.a.ii apply, regardless
79707 * of 'global' flag of the RegExp. In particular, if lastIndex is invalid
79708 * initially, it is reset to zero.
79709 */
79710
79711 DUK_DDD(DUK_DDDPRINT("regexp does not match"));
79712
79713 duk_push_null(ctx);
79714
79715 /* [ ... re_obj input bc saved_buf res_obj ] */
79716
79717 duk_push_int(ctx, 0);
#define DUK_USE_REGEXP_EXECUTOR_RECLIMIT
#define DUK_HOBJECT_CLASS_REGEXP
#define DUK_RE_EXECUTE_STEPS_LIMIT
DUK_EXTERNAL duk_double_t duk_get_number(duk_context *ctx, duk_idx_t index)
#define duk_xdef_prop_stridx_wec(ctx, obj_index, stridx)
#define DUK_STRIDX_INDEX
DUK_INTERNAL_DECL duk_hobject * duk_require_hobject_with_class(duk_context *ctx, duk_idx_t index, duk_small_uint_t classnum)
#define DUK_RE_FLAG_GLOBAL
#define DUK_STRIDX_LAST_INDEX
DUK_INTERNAL_DECL duk_uint_fast32_t duk_heap_strcache_offset_char2byte(duk_hthread *thr, duk_hstring *h, duk_uint_fast32_t char_offset)
DUK_LOCAL const duk_uint8_t * duk__utf8_advance(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end, duk_uint_fast32_t count)
DUK_LOCAL void duk__regexp_match_helper(duk_hthread *thr, duk_small_int_t force_global)
#define DUK_STRIDX_INT_BYTECODE

◆ duk__remove_matching_hstring_probe()

DUK_LOCAL void duk__remove_matching_hstring_probe ( duk_heap * heap,
duk_hstring ** entries,
duk_uint32_t size,
duk_hstring * h )

Definition at line 45599 of file duktape-1.8.0/src/duktape.c.

45603 : %ld (step %ld, size %ld)",
45604 (long) i, (long) step, (long) size));
45605 i = (i + step) % size;
45606
45607 /* looping should never happen */
45608 DUK_ASSERT(i != DUK__HASH_INITIAL(strhash, size));
45609 }
45610 DUK_UNREACHABLE();
45611}
45612
45613#if defined(DUK_USE_HEAPPTR16)
45614DUK_LOCAL void duk__remove_matching_hstring_probe(duk_heap *heap, duk_uint16_t *entries16, duk_uint32_t size, duk_hstring *h) {
45615#else
45616DUK_LOCAL void duk__remove_matching_hstring_probe(duk_heap *heap, duk_hstring **entries, duk_uint32_t size, duk_hstring *h) {
45617#endif
45618 duk_uint32_t i;
45619 duk_uint32_t step;
45620 duk_uint32_t hash;
45621#if defined(DUK_USE_HEAPPTR16)
45622 duk_uint16_t null16 = heap->heapptr_null16;
45623 duk_uint16_t h16 = DUK_USE_HEAPPTR_ENC16(heap->heap_udata, (void *) h);
45624#endif
45625
45626 DUK_ASSERT(size > 0);
45627
45628 hash = DUK_HSTRING_GET_HASH(h);
45629 i = DUK__HASH_INITIAL(hash, size);
45630 step = DUK__HASH_PROBE_STEP(hash);
45631 for (;;) {
45632#if defined(DUK_USE_HEAPPTR16)
45633 duk_uint16_t e16 = entries16[i];
45634#else
45635 duk_hstring *e = entries[i];
45636#endif
45637
45638#if defined(DUK_USE_HEAPPTR16)
45639 if (e16 == null16) {
45640#else
45641 if (!e) {
45642#endif
45643 DUK_UNREACHABLE();
45644 break;
45645 }
45646#if defined(DUK_USE_HEAPPTR16)
45647 if (e16 == h16) {
45648#else
45649 if (e == h) {
45650#endif

◆ duk__remove_slice()

DUK_LOCAL void duk__remove_slice ( duk_re_compiler_ctx * re_ctx,
duk_uint32_t data_offset,
duk_uint32_t data_length )

Definition at line 77783 of file duktape-1.8.0/src/duktape.c.

77784 {
77785 /* Call sites don't need the result length so it's not accumulated. */

References duk__append_u32().

Referenced by duk__parse_disjunction().

◆ duk__require_bufobj_this()

◆ duk__require_bufobj_value()

DUK_LOCAL duk_hbufferobject * duk__require_bufobj_value ( duk_context * ctx,
duk_idx_t index )

Definition at line 21879 of file duktape-1.8.0/src/duktape.c.

21880 {
21881 return duk__getrequire_bufobj_this(ctx, 0);
21882}
21883#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
21884
21885#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
21886/* Check that 'this' is a duk_hbufferobject and return a pointer to it
21887 * (NULL if not).
21888 */
21890 return duk__getrequire_bufobj_this(ctx, 1);
21891}
21892#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
21893
21894#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
21895/* Check that value is a duk_hbufferobject and return a pointer to it. */
21897 duk_hthread *thr;
21898 duk_tval *tv;
21899 duk_hbufferobject *h_obj;
21900
21901 thr = (duk_hthread *) ctx;
21902
DUK_LOCAL duk_hbufferobject * duk__getrequire_bufobj_this(duk_context *ctx, duk_bool_t throw_flag)
DUK_LOCAL duk_hbufferobject * duk__require_bufobj_value(duk_context *ctx, duk_idx_t index)
DUK_LOCAL duk_hbufferobject * duk__require_bufobj_this(duk_context *ctx)

References duk__getrequire_bufobj_this().

◆ duk__reset_func_for_pass2()

DUK_LOCAL_DECL void duk__reset_func_for_pass2 ( duk_compiler_ctx * comp_ctx)

Definition at line 58267 of file duktape-1.8.0/src/duktape.c.

58284 {
58285 duk_compiler_func *func = &comp_ctx->curr_func;
58286 duk_hthread *thr = comp_ctx->thr;
58287 duk_context *ctx = (duk_context *) thr;
58288
58289 /* reset bytecode buffer but keep current size; pass 2 will
58290 * require same amount or more.

Referenced by duk__parse_func_body().

◆ duk__reset_labels_to_length()

DUK_LOCAL_DECL void duk__reset_labels_to_length ( duk_compiler_ctx * comp_ctx,
duk_int_t len )

Definition at line 60430 of file duktape-1.8.0/src/duktape.c.

60433 {
60435 }
60436
60437 DUK_DDD(DUK_DDDPRINT("label match: %!O -> label_id %ld, catch_depth=%ld, pc_label=%ld",
60438 (duk_heaphdr *) h_label, (long) li->label_id,
60439 (long) li->catch_depth, (long) li->pc_label));
60440

◆ duk__resize_strtab_probe()

DUK_LOCAL duk_bool_t duk__resize_strtab_probe ( duk_heap * heap)

Definition at line 45763 of file duktape-1.8.0/src/duktape.c.

45775 :
45776 DUK_FREE(heap, new_entries);
45777 return 1; /* FAIL */
45778}
45779
45781 duk_uint32_t new_size;
45782 duk_bool_t ret;
45783
DUK_LOCAL duk_bool_t duk__resize_strtab_probe(duk_heap *heap)

◆ duk__resize_strtab_raw_probe()

DUK_LOCAL duk_bool_t duk__resize_strtab_raw_probe ( duk_heap * heap,
duk_uint32_t new_size )

Definition at line 45652 of file duktape-1.8.0/src/duktape.c.

45652 : %ld", (long) i));
45653#if defined(DUK_USE_HEAPPTR16)
45654 entries16[i] = heap->heapptr_deleted16;
45655#else
45656 entries[i] = DUK__DELETED_MARKER(heap);
45657#endif
45658 break;
45659 }
45660
45661 DUK_DDD(DUK_DDDPRINT("free matching miss: %ld", (long) i));
45662 i = (i + step) % size;
45663
45664 /* looping should never happen */
45665 DUK_ASSERT(i != DUK__HASH_INITIAL(hash, size));
45666 }
45667}
45668
45669DUK_LOCAL duk_bool_t duk__resize_strtab_raw_probe(duk_heap *heap, duk_uint32_t new_size) {
45670#if defined(DUK_USE_DEBUG)
45671 duk_uint32_t old_used = heap->st_used;
45672#endif
45673 duk_uint32_t old_size = heap->st_size;
45674#if defined(DUK_USE_HEAPPTR16)
45675 duk_uint16_t *old_entries = heap->strtable16;
45676 duk_uint16_t *new_entries = NULL;
45677#else
45678 duk_hstring **old_entries = heap->strtable;
45679 duk_hstring **new_entries = NULL;
45680#endif
45681 duk_uint32_t new_used = 0;
45682 duk_uint32_t i;
45683
45684#if defined(DUK_USE_DEBUG)
45685 DUK_UNREF(old_used); /* unused with some debug level combinations */
45686#endif
45687
45688#ifdef DUK_USE_DDDPRINT
45689 DUK_DDD(DUK_DDDPRINT("attempt to resize stringtable: %ld entries, %ld bytes, %ld used, %ld%% load -> %ld entries, %ld bytes, %ld used, %ld%% load",
45690 (long) old_size, (long) (sizeof(duk_hstring *) * old_size), (long) old_used,
45691 (long) (((double) old_used) / ((double) old_size) * 100.0),
45692 (long) new_size, (long) (sizeof(duk_hstring *) * new_size), (long) duk__count_used_probe(heap),
45693 (long) (((double) duk__count_used_probe(heap)) / ((double) new_size) * 100.0)));
45694#endif
45695
45696 DUK_ASSERT(new_size > (duk_uint32_t) duk__count_used_probe(heap)); /* required for rehash to succeed, equality not that useful */
45697 DUK_ASSERT(old_entries);
45698
45699 /*
45700 * The attempt to allocate may cause a GC. Such a GC must not attempt to resize
45701 * the stringtable (though it can be swept); finalizer execution and object
45702 * compaction must also be postponed to avoid the pressure to add strings to the
45703 * string table. Call site must prevent these.
45704 */
45705
45706#if defined(DUK_USE_MARK_AND_SWEEP)
45707 DUK_ASSERT(heap->mark_and_sweep_base_flags & DUK_MS_FLAG_NO_STRINGTABLE_RESIZE);
45708 DUK_ASSERT(heap->mark_and_sweep_base_flags & DUK_MS_FLAG_NO_FINALIZERS);
45709 DUK_ASSERT(heap->mark_and_sweep_base_flags & DUK_MS_FLAG_NO_OBJECT_COMPACTION);
45710#endif
45711
45712#if defined(DUK_USE_HEAPPTR16)
45713 new_entries = (duk_uint16_t *) DUK_ALLOC(heap, sizeof(duk_uint16_t) * new_size);
45714#else
45715 new_entries = (duk_hstring **) DUK_ALLOC(heap, sizeof(duk_hstring *) * new_size);
45716#endif
45717
45718 if (!new_entries) {
45719 goto resize_error;
45720 }
45721
45722#if defined(DUK_USE_EXPLICIT_NULL_INIT)
45723 for (i = 0; i < new_size; i++) {
45724#if defined(DUK_USE_HEAPPTR16)
45725 new_entries[i] = heap->heapptr_null16;
45726#else
45727 new_entries[i] = NULL;
45728#endif
45729 }
45730#else
45731#if defined(DUK_USE_HEAPPTR16)
45732 /* Relies on NULL encoding to zero. */
45733 DUK_MEMZERO(new_entries, sizeof(duk_uint16_t) * new_size);
45734#else
45735 DUK_MEMZERO(new_entries, sizeof(duk_hstring *) * new_size);
45736#endif
45737#endif
45738
45739 /* Because new_size > duk__count_used_probe(heap), guaranteed to work */
45740 for (i = 0; i < old_size; i++) {
45741 duk_hstring *e;
45742
45743#if defined(DUK_USE_HEAPPTR16)
45744 e = (duk_hstring *) DUK_USE_HEAPPTR_DEC16(heap->heap_udata, old_entries[i]);
45745#else
45746 e = old_entries[i];
45747#endif
45748 if (e == NULL || e == DUK__DELETED_MARKER(heap)) {
45749 continue;
45750 }
45751 /* checking for DUK__DELETED_MARKER is not necessary here, but helper does it now */
45752 duk__insert_hstring_probe(heap, new_entries, new_size, &new_used, e);
45753 }
45754
45755#ifdef DUK_USE_DDPRINT
45756 DUK_DD(DUK_DDPRINT("resized stringtable: %ld entries, %ld bytes, %ld used, %ld%% load -> %ld entries, %ld bytes, %ld used, %ld%% load",
45757 (long) old_size, (long) (sizeof(duk_hstring *) * old_size), (long) old_used,
45758 (long) (((double) old_used) / ((double) old_size) * 100.0),
45759 (long) new_size, (long) (sizeof(duk_hstring *) * new_size), (long) new_used,
45760 (long) (((double) new_used) / ((double) new_size) * 100.0)));
45761#endif
#define free
Definition civetweb.c:1542
struct stringtable stringtable
static void resize(lua_State *L, Table *t, int nasize, int nhsize)

◆ duk__resize_valstack()

DUK_LOCAL duk_bool_t duk__resize_valstack ( duk_context * ctx,
duk_size_t new_size )

Definition at line 15491 of file duktape-1.8.0/src/duktape.c.

15508 {
15509 duk_hthread *thr = (duk_hthread *) ctx;
15510 duk_ptrdiff_t old_bottom_offset;
15511 duk_ptrdiff_t old_top_offset;
15512 duk_ptrdiff_t old_end_offset_post;
15513#ifdef DUK_USE_DEBUG
15514 duk_ptrdiff_t old_end_offset_pre;
15515 duk_tval *old_valstack_pre;
15516 duk_tval *old_valstack_post;
15517#endif
15518 duk_tval *new_valstack;
15519 duk_size_t new_alloc_size;
15520 duk_tval *p;
15521
15523 DUK_ASSERT(thr != NULL);
15524 DUK_ASSERT(thr->valstack_bottom >= thr->valstack);
15526 DUK_ASSERT(thr->valstack_end >= thr->valstack_top);
15527 DUK_ASSERT((duk_size_t) (thr->valstack_top - thr->valstack) <= new_size); /* can't resize below 'top' */
15528 DUK_ASSERT(new_size <= thr->valstack_max); /* valstack limit caller has check, prevents wrapping */
15529 DUK_ASSERT(new_size <= DUK_SIZE_MAX / sizeof(duk_tval)); /* specific assert for wrapping */
15530
15531 /* get pointer offsets for tweaking below */
15532 old_bottom_offset = (((duk_uint8_t *) thr->valstack_bottom) - ((duk_uint8_t *) thr->valstack));
15533 old_top_offset = (((duk_uint8_t *) thr->valstack_top) - ((duk_uint8_t *) thr->valstack));
15534#ifdef DUK_USE_DEBUG
15535 old_end_offset_pre = (((duk_uint8_t *) thr->valstack_end) - ((duk_uint8_t *) thr->valstack)); /* not very useful, used for debugging */
15536 old_valstack_pre = thr->valstack;
15537#endif
15538
15539 /* Allocate a new valstack.
15540 *
15541 * Note: cannot use a plain DUK_REALLOC() because a mark-and-sweep may
15542 * invalidate the original thr->valstack base pointer inside the realloc
15543 * process. See doc/memory-management.rst.
15544 */
15545
15546 new_alloc_size = sizeof(duk_tval) * new_size;
15547 new_valstack = (duk_tval *) DUK_REALLOC_INDIRECT(thr->heap, duk_hthread_get_valstack_ptr, (void *) thr, new_alloc_size);
15548 if (!new_valstack) {
15549 /* Because new_size != 0, if condition doesn't need to be
15550 * (new_valstack != NULL || new_size == 0).
15551 */
15552 DUK_ASSERT(new_size != 0);
15553 DUK_D(DUK_DPRINT("failed to resize valstack to %lu entries (%lu bytes)",
15554 (unsigned long) new_size, (unsigned long) new_alloc_size));
15555 return 0;
15556 }
15557
15558 /* Note: the realloc may have triggered a mark-and-sweep which may
15559 * have resized our valstack internally. However, the mark-and-sweep
15560 * MUST NOT leave the stack bottom/top in a different state. Particular
15561 * assumptions and facts:
15562 *
15563 * - The thr->valstack pointer may be different after realloc,
15564 * and the offset between thr->valstack_end <-> thr->valstack
15565 * may have changed.
15566 * - The offset between thr->valstack_bottom <-> thr->valstack
15567 * and thr->valstack_top <-> thr->valstack MUST NOT have changed,
15568 * because mark-and-sweep must adhere to a strict stack policy.
15569 * In other words, logical bottom and top MUST NOT have changed.
15570 * - All values above the top are unreachable but are initialized
15571 * to UNDEFINED, up to the post-realloc valstack_end.
15572 * - 'old_end_offset' must be computed after realloc to be correct.
15573 */
15574
15575 DUK_ASSERT((((duk_uint8_t *) thr->valstack_bottom) - ((duk_uint8_t *) thr->valstack)) == old_bottom_offset);
15576 DUK_ASSERT((((duk_uint8_t *) thr->valstack_top) - ((duk_uint8_t *) thr->valstack)) == old_top_offset);
15577
15578 /* success, fixup pointers */
15579 old_end_offset_post = (((duk_uint8_t *) thr->valstack_end) - ((duk_uint8_t *) thr->valstack)); /* must be computed after realloc */
15580#ifdef DUK_USE_DEBUG
15581 old_valstack_post = thr->valstack;
15582#endif
15583 thr->valstack = new_valstack;
15584 thr->valstack_end = new_valstack + new_size;
15585#if !defined(DUK_USE_PREFER_SIZE)
15586 thr->valstack_size = new_size;
15587#endif
15588 thr->valstack_bottom = (duk_tval *) (void *) ((duk_uint8_t *) new_valstack + old_bottom_offset);
15589 thr->valstack_top = (duk_tval *) (void *) ((duk_uint8_t *) new_valstack + old_top_offset);
15590
15591 DUK_ASSERT(thr->valstack_bottom >= thr->valstack);
15593 DUK_ASSERT(thr->valstack_end >= thr->valstack_top);
15594
15595 /* useful for debugging */
15596#ifdef DUK_USE_DEBUG
15597 if (old_end_offset_pre != old_end_offset_post) {
15598 DUK_D(DUK_DPRINT("valstack was resized during valstack_resize(), probably by mark-and-sweep; "
15599 "end offset changed: %lu -> %lu",
15600 (unsigned long) old_end_offset_pre,
15601 (unsigned long) old_end_offset_post));
15602 }
15603 if (old_valstack_pre != old_valstack_post) {
15604 DUK_D(DUK_DPRINT("valstack pointer changed during valstack_resize(), probably by mark-and-sweep: %p -> %p",
15605 (void *) old_valstack_pre,
15606 (void *) old_valstack_post));
15607 }
15608#endif
15609
15610 DUK_DD(DUK_DDPRINT("resized valstack to %lu elements (%lu bytes), bottom=%ld, top=%ld, "
15611 "new pointers: start=%p end=%p bottom=%p top=%p",
15612 (unsigned long) new_size, (unsigned long) new_alloc_size,
15613 (long) (thr->valstack_bottom - thr->valstack),
15614 (long) (thr->valstack_top - thr->valstack),
15615 (void *) thr->valstack, (void *) thr->valstack_end,
15616 (void *) thr->valstack_bottom, (void *) thr->valstack_top));
15617
15618 /* Init newly allocated slots (only). */
15619 p = (duk_tval *) (void *) ((duk_uint8_t *) thr->valstack + old_end_offset_post);
#define DUK_REALLOC_INDIRECT(heap, cb, ud, newsize)
DUK_INTERNAL_DECL void * duk_hthread_get_valstack_ptr(duk_heap *heap, void *ud)

References DUK_ASSERT, DUK_ASSERT_CTX_VALID, DUK_D, DUK_DD, DUK_DDPRINT, DUK_DPRINT, duk_hthread_get_valstack_ptr(), DUK_REALLOC_INDIRECT, DUK_SIZE_MAX, duk_hthread::heap, NULL, duk_hthread::valstack, duk_hthread::valstack_bottom, duk_hthread::valstack_end, duk_hthread::valstack_size, and duk_hthread::valstack_top.

◆ duk__resolve_offset_opt_length()

DUK_LOCAL void duk__resolve_offset_opt_length ( duk_context * ctx,
duk_hbufferobject * h_bufarg,
duk_idx_t idx_offset,
duk_idx_t idx_length,
duk_uint_t * out_offset,
duk_uint_t * out_length,
duk_bool_t throw_flag )

Definition at line 21951 of file duktape-1.8.0/src/duktape.c.

21974 {
21975 duk_hthread *thr;
21976 duk_int_t offset_signed;
21977 duk_int_t length_signed;
21978 duk_uint_t offset;
21979 duk_uint_t length;
21980
21981 thr = (duk_hthread *) ctx;
21982 DUK_UNREF(thr);
21983
21984 offset_signed = duk_to_int(ctx, idx_offset);
21985 if (offset_signed < 0) {
21986 goto fail_range;
21987 }
21988 offset = (duk_uint_t) offset_signed;
21989 if (offset > h_bufarg->length) {
21990 goto fail_range;
21991 }
21992 DUK_ASSERT_DISABLE(offset >= 0); /* unsigned */
21993 DUK_ASSERT(offset <= h_bufarg->length);
21994
21995 if (duk_is_undefined(ctx, idx_length)) {
21996 DUK_ASSERT(h_bufarg->length >= offset);
21997 length = h_bufarg->length - offset; /* >= 0 */
21998 } else {
21999 length_signed = duk_to_int(ctx, idx_length);
22000 if (length_signed < 0) {
22001 goto fail_range;
22002 }
22003 length = (duk_uint_t) length_signed;
22004 DUK_ASSERT(h_bufarg->length >= offset);
22005 if (length > h_bufarg->length - offset) {
22006 /* Unlike for negative arguments, some call sites
22007 * want length to be clamped if it's positive.
22008 */

◆ duk__round_fixed()

DUK_LOCAL double duk__round_fixed ( double x)

Definition at line 32625 of file duktape-1.8.0/src/duktape.c.

32628 {
32629 if (DUK_SIGNBIT(x) == 0 || DUK_SIGNBIT(y) == 0) {
32630 return +0.0;
32631 } else {
32632 return -0.0;
32633 }
32634 }
32635#ifdef DUK_USE_MATH_FMAX
32636 return DUK_FMAX(x, y);
32637#else
32638 return (x > y ? x : y);
32639#endif
32640}
32641
32642DUK_LOCAL double duk__round_fixed(double x) {
32643 /* Numbers half-way between integers must be rounded towards +Infinity,
32644 * e.g. -3.5 must be rounded to -3 (not -4). When rounded to zero, zero
32645 * sign must be set appropriately. E5.1 Section 15.8.2.15.
32646 *
32647 * Note that ANSI C round() is "round to nearest integer, away from zero",
32648 * which is incorrect for negative values. Here we make do with floor().
32649 */
32650
32652 if (c == DUK_FP_NAN || c == DUK_FP_INFINITE || c == DUK_FP_ZERO) {
32653 return x;
32654 }
32655
32656 /*
32657 * x is finite and non-zero
32658 *
32659 * -1.6 -> floor(-1.1) -> -2
32660 * -1.5 -> floor(-1.0) -> -1 (towards +Inf)
32661 * -1.4 -> floor(-0.9) -> -1
32662 * -0.5 -> -0.0 (special case)
32663 * -0.1 -> -0.0 (special case)
32664 * +0.1 -> +0.0 (special case)
DUK_LOCAL double duk__round_fixed(double x)

References DUK_SIGNBIT.

◆ duk__run_object_finalizers()

DUK_LOCAL void duk__run_object_finalizers ( duk_heap * heap,
duk_small_uint_t flags )

Definition at line 43050 of file duktape-1.8.0/src/duktape.c.

43051 {
43052 DUK_HEAPHDR_SET_NEXT(heap, prev, NULL);
43053 }
43054 DUK_ASSERT_HEAPHDR_LINKS(heap, prev);
43055
43056#ifdef DUK_USE_DEBUG
43057 DUK_D(DUK_DPRINT("mark-and-sweep sweep objects (non-string): %ld freed, %ld kept, %ld rescued, %ld queued for finalization",
43058 (long) count_free, (long) count_keep, (long) count_rescue, (long) count_finalize));
43059#endif
43060 *out_count_keep = count_keep;
43061}
43062
43063/*
43064 * Run (object) finalizers in the "to be finalized" work list.
43065 */
43066
43068 duk_heaphdr *curr;
43070#ifdef DUK_USE_DEBUG
43071 duk_size_t count = 0;
43072#endif
43073 duk_hthread *thr;
43074
43075 DUK_DD(DUK_DDPRINT("duk__run_object_finalizers: %p", (void *) heap));
43076
43077 thr = duk__get_temp_hthread(heap);
43078 DUK_ASSERT(thr != NULL);
43079
43080 curr = heap->finalize_list;
43081 while (curr) {
43082 DUK_DDD(DUK_DDDPRINT("mark-and-sweep finalize: %p", (void *) curr));
43083
43084 DUK_ASSERT(DUK_HEAPHDR_GET_TYPE(curr) == DUK_HTYPE_OBJECT); /* only objects have finalizers */
43085 DUK_ASSERT(!DUK_HEAPHDR_HAS_REACHABLE(curr)); /* flags have been already cleared */
43089 DUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY(curr)); /* No finalizers for ROM objects */
43090
43091 /* Keep heap->finalize_list up-to-date during the list walk.
43092 * This has no functional impact, but does matter e.g. for
43093 * duk_push_heapptr() asserts when assertions are enabled.
43094 */
43095 heap->finalize_list = curr;
43096
43097 if (DUK_LIKELY((flags & DUK_MS_FLAG_SKIP_FINALIZERS) == 0)) {
43098 /* Run the finalizer, duk_hobject_run_finalizer() sets FINALIZED.
43099 * Next mark-and-sweep will collect the object unless it has
43100 * become reachable (i.e. rescued). FINALIZED prevents the
43101 * finalizer from being executed again before that.
43102 */
43103 duk_hobject_run_finalizer(thr, (duk_hobject *) curr); /* must never longjmp */
43105
43106 /* XXX: could clear FINALIZED already here; now cleared in
43107 * next mark-and-sweep.
43108 */
43109 } else {
43110 /* Used during heap destruction: don't actually run finalizers
43111 * because we're heading into forced finalization. Instead,
43112 * queue finalizable objects back to the heap_allocated list.
43113 */
43114 DUK_D(DUK_DPRINT("skip finalizers flag set, queue object to heap_allocated without finalizing"));
43116 }
43117
DUK_LOCAL void duk__run_object_finalizers(duk_heap *heap, duk_small_uint_t flags)
#define DUK_MS_FLAG_SKIP_FINALIZERS

◆ duk__run_voluntary_gc()

DUK_LOCAL void duk__run_voluntary_gc ( duk_heap * heap)

Definition at line 43639 of file duktape-1.8.0/src/duktape.c.

43649 { \
43650 (heap)->mark_and_sweep_trigger_counter--; \
43651 if ((heap)->mark_and_sweep_trigger_counter <= 0) { \

References DUK_DD, DUK_DDPRINT, and DUK_HEAP_HAS_MARKANDSWEEP_RUNNING.

◆ duk__safe_call_adjust_valstack()

DUK_LOCAL void duk__safe_call_adjust_valstack ( duk_hthread * thr,
duk_idx_t idx_retbase,
duk_idx_t num_stack_rets,
duk_idx_t num_actual_rets )

Definition at line 55835 of file duktape-1.8.0/src/duktape.c.

55852 {
55853 duk_context *ctx = (duk_context *) thr;
55854 duk_idx_t idx_rcbase;
55855
55856 DUK_ASSERT(thr != NULL);
55857 DUK_ASSERT(idx_retbase >= 0);
55858 DUK_ASSERT(num_stack_rets >= 0);
55859 DUK_ASSERT(num_actual_rets >= 0);
55860
55861 idx_rcbase = duk_get_top(ctx) - num_actual_rets; /* base of known return values */
55862
55863 DUK_DDD(DUK_DDDPRINT("adjust valstack after func call: "
55864 "num_stack_rets=%ld, num_actual_rets=%ld, stack_top=%ld, idx_retbase=%ld, idx_rcbase=%ld",
55865 (long) num_stack_rets, (long) num_actual_rets, (long) duk_get_top(ctx),
55866 (long) idx_retbase, (long) idx_rcbase));
55867
55868 DUK_ASSERT(idx_rcbase >= 0); /* caller must check */
55869
55870 /* Ensure space for final configuration (idx_retbase + num_stack_rets)
55871 * and intermediate configurations.
55872 */
55874 (idx_rcbase > idx_retbase ? idx_rcbase : idx_retbase) +
55875 num_stack_rets);
55876
55877 /* Chop extra retvals away / extend with undefined. */
55878 duk_set_top(ctx, idx_rcbase + num_stack_rets);
55879
55880 if (idx_rcbase >= idx_retbase) {
55881 duk_idx_t count = idx_rcbase - idx_retbase;
55882 duk_idx_t i;
55883
55884 DUK_DDD(DUK_DDDPRINT("elements at/after idx_retbase have enough to cover func retvals "
55885 "(idx_retbase=%ld, idx_rcbase=%ld)", (long) idx_retbase, (long) idx_rcbase));
55886
55887 /* nuke values at idx_retbase to get the first retval (initially
55888 * at idx_rcbase) to idx_retbase
55889 */
55890
55891 DUK_ASSERT(count >= 0);
55892
55893 for (i = 0; i < count; i++) {
55894 /* XXX: inefficient; block remove primitive */
55895 duk_remove(ctx, idx_retbase);
55896 }
55897 } else {
55898 duk_idx_t count = idx_retbase - idx_rcbase;
55899 duk_idx_t i;
DUK_EXTERNAL void duk_require_stack_top(duk_context *ctx, duk_idx_t top)

◆ duk__safe_to_string_raw()

DUK_LOCAL duk_ret_t duk__safe_to_string_raw ( duk_context * ctx)

Definition at line 17057 of file duktape-1.8.0/src/duktape.c.

17057 : d=4.5, t=0.5 -> ret = (4 + 1) & 0xfe = 5 & 0xfe = 4
17058 */
17059 } else {
17060 /* Not halfway, round to nearest. */
17061 ret = (duk_uint8_t) (d + 0.5);
17062 }

◆ duk__scan_backwards()

DUK_LOCAL const duk_uint8_t * duk__scan_backwards ( const duk_uint8_t * p,
const duk_uint8_t * q,
duk_uint_fast32_t n )

Definition at line 44767 of file duktape-1.8.0/src/duktape.c.

44768 {
44769 while (n > 0) {
44770 for (;;) {
44771 p++;
44772 if (p >= q) {
44773 return NULL;
44774 }
44775 if ((*p & 0xc0) != 0x80) {
44776 break;
44777 }
44778 }
44779 n--;
44780 }
44781 return p;

References NULL.

◆ duk__scan_forwards()

DUK_LOCAL const duk_uint8_t * duk__scan_forwards ( const duk_uint8_t * p,
const duk_uint8_t * q,
duk_uint_fast32_t n )

Definition at line 44751 of file duktape-1.8.0/src/duktape.c.

◆ duk__set_bufobj_buffer()

DUK_LOCAL void duk__set_bufobj_buffer ( duk_context * ctx,
duk_hbufferobject * h_bufobj,
duk_hbuffer * h_val )

Definition at line 21905 of file duktape-1.8.0/src/duktape.c.

21908 {
21909 h_obj = (duk_hbufferobject *) DUK_TVAL_GET_OBJECT(tv);
21910 DUK_ASSERT(h_obj != NULL);
21913 return h_obj;
21914 }
21915 }
21916
21918 return NULL; /* not reachable */
21919}
21920#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
21921
21923 duk_hthread *thr;
21924
DUK_LOCAL void duk__set_bufobj_buffer(duk_context *ctx, duk_hbufferobject *h_bufobj, duk_hbuffer *h_val)

◆ duk__set_catcher_regs()

DUK_LOCAL void duk__set_catcher_regs ( duk_hthread * thr,
duk_size_t cat_idx,
duk_tval * tv_val_unstable,
duk_small_uint_t lj_type )

Definition at line 66225 of file duktape-1.8.0/src/duktape.c.

◆ duk__set_part_helper()

DUK_LOCAL duk_ret_t duk__set_part_helper ( duk_context * ctx,
duk_small_uint_t flags_and_maxnargs )

Definition at line 25714 of file duktape-1.8.0/src/duktape.c.

25720 : parts[idx_part]);
25721 return 1;
25722}
25723
25724/* Helper for component setter calls: check 'this' binding, get the
25725 * internal time value, split it into parts (either as UTC time or
25726 * local time), modify one or more components as specified, recompute
25727 * the time value, set it as the internal value. Finally, push the
25728 * new time value as a return value to the value stack and return 1
25729 * (caller can then tail call us).
25730 */
25732 duk_double_t d;
25735 duk_idx_t nargs;
25736 duk_small_uint_t maxnargs = (duk_small_uint_t) (flags_and_maxnargs >> DUK_DATE_FLAG_VALUE_SHIFT); /* unpack args */
25737 duk_small_uint_t idx_first, idx;
25739
25740 nargs = duk_get_top(ctx);
25741 d = duk__push_this_get_timeval(ctx, flags_and_maxnargs);
25743
25744 if (DUK_ISFINITE(d)) {
25745 duk_bi_date_timeval_to_parts(d, parts, dparts, flags_and_maxnargs);
25746 } else {
25747 /* NaN timevalue: we need to coerce the arguments, but
25748 * the resulting internal timestamp needs to remain NaN.
25749 * This works but is not pretty: parts and dparts will
25750 * be partially uninitialized, but we only write to them.
25751 */
25752 }
25753
25754 /*
25755 * Determining which datetime components to overwrite based on
25756 * stack arguments is a bit complicated, but important to factor
25757 * out from setters themselves for compactness.
25758 *
25759 * If DUK_DATE_FLAG_TIMESETTER, maxnargs indicates setter type:
25760 *
25761 * 1 -> millisecond
25762 * 2 -> second, [millisecond]
25763 * 3 -> minute, [second], [millisecond]
25764 * 4 -> hour, [minute], [second], [millisecond]
25765 *
25766 * Else:
25767 *
25768 * 1 -> date
25769 * 2 -> month, [date]
25770 * 3 -> year, [month], [date]
25771 *
25772 * By comparing nargs and maxnargs (and flags) we know which
25773 * components to override. We rely on part index ordering.
25774 */
25775
25776 if (flags_and_maxnargs & DUK_DATE_FLAG_TIMESETTER) {
25777 DUK_ASSERT(maxnargs >= 1 && maxnargs <= 4);
25778 idx_first = DUK_DATE_IDX_MILLISECOND - (maxnargs - 1);
25779 } else {
25780 DUK_ASSERT(maxnargs >= 1 && maxnargs <= 3);
25781 idx_first = DUK_DATE_IDX_DAY - (maxnargs - 1);
25782 }
25783 DUK_ASSERT_DISABLE(idx_first >= 0); /* unsigned */
25785
25786 for (i = 0; i < maxnargs; i++) {
25787 if ((duk_idx_t) i >= nargs) {
25788 /* no argument given -> leave components untouched */
25789 break;
25790 }
25791 idx = idx_first + i;
25792 DUK_ASSERT_DISABLE(idx >= 0); /* unsigned */
25794
25795 if (idx == DUK_DATE_IDX_YEAR && (flags_and_maxnargs & DUK_DATE_FLAG_YEAR_FIXUP)) {
25797 }
25798
25799 dparts[idx] = duk_to_number(ctx, i);
25800
25801 if (idx == DUK_DATE_IDX_DAY) {
25802 /* Day-of-month is one-based in the API, but zero-based
25803 * internally, so fix here. Note that month is zero-based
25804 * both in the API and internally.
25805 */
25806 /* SCANBUILD: complains about use of uninitialized values.
25807 * The complaint is correct, but operating in undefined
25808 * values here is intentional in some cases and the caller
#define DUK_DATE_FLAG_TIMESETTER
#define DUK_DATE_IDX_MILLISECOND
#define DUK_DATE_FLAG_YEAR_FIXUP
DUK_LOCAL duk_ret_t duk__set_part_helper(duk_context *ctx, duk_small_uint_t flags_and_maxnargs)
DUK_INTERNAL_DECL void duk_bi_date_timeval_to_parts(duk_double_t d, duk_int_t *parts, duk_double_t *dparts, duk_small_uint_t flags)

Referenced by duk_bi_date_prototype_set_time().

◆ duk__set_parts_from_args()

DUK_LOCAL void duk__set_parts_from_args ( duk_context * ctx,
duk_double_t * dparts,
duk_idx_t nargs )

Definition at line 25839 of file duktape-1.8.0/src/duktape.c.

25839 {
25840 return;
25841 }
25842 duk_dup(ctx, idx_val);
25843 duk_to_int(ctx, -1);
25844 d = duk_get_number(ctx, -1); /* get as double to handle huge numbers correctly */
25845 if (d >= 0.0 && d <= 99.0) {
25846 d += 1900.0;
25847 duk_push_number(ctx, d);
25848 duk_replace(ctx, idx_val);
25849 }
25850 duk_pop(ctx);
25851}
25852
25853/* Set datetime parts from stack arguments, defaulting any missing values.
25854 * Day-of-week is not set; it is not required when setting the time value.
25855 */
25857 duk_double_t d;
25859 duk_small_uint_t idx;
25860
25861 /* Causes a ToNumber() coercion, but doesn't break coercion order since
25862 * year is coerced first anyway.
25863 */
25865
25866 /* There are at most 7 args, but we use 8 here so that also
25867 * DUK_DATE_IDX_WEEKDAY gets initialized (to zero) to avoid the potential
25868 * for any Valgrind gripes later.
25869 */
25870 for (i = 0; i < 8; i++) {
25871 /* Note: rely on index ordering */
25872 idx = DUK_DATE_IDX_YEAR + i;
25873 if ((duk_idx_t) i < nargs) {
25874 d = duk_to_number(ctx, (duk_idx_t) i);
25875 if (idx == DUK_DATE_IDX_DAY) {
25876 /* Convert day from one-based to zero-based (internal). This may
25877 * cause the day part to be negative, which is OK.
25878 */
25879 d -= 1.0;
DUK_LOCAL void duk__set_parts_from_args(duk_context *ctx, duk_double_t *dparts, duk_idx_t nargs)

◆ duk__set_this_timeval_from_dparts()

DUK_LOCAL_DECL duk_ret_t duk__set_this_timeval_from_dparts ( duk_context * ctx,
duk_double_t * dparts,
duk_small_uint_t flags )

Definition at line 25551 of file duktape-1.8.0/src/duktape.c.

25552 {
25553 *out_tzoffset = tzoffset;
25554 }
25555
25556 /* [ ... this ] */
25557 return d;
25558}
25559
25561 return duk__push_this_get_timeval_tzoffset(ctx, flags, NULL);
25562}
25563

◆ duk__settemp_checkmax()

DUK_LOCAL_DECL void duk__settemp_checkmax ( duk_compiler_ctx * comp_ctx,
duk_reg_t temp_next )

Definition at line 59593 of file duktape-1.8.0/src/duktape.c.

59594 { /* == DUK__MAX_TEMPS is OK */
59596 }
59597
59598 /* maintain highest 'used' temporary, needed to figure out nregs of function */
#define DUK_STR_TEMP_LIMIT

References DUK_ERROR_RANGE, DUK_STR_TEMP_LIMIT, and duk_compiler_ctx::thr.

◆ duk__sin()

DUK_LOCAL double duk__sin ( double x)

Definition at line 32762 of file duktape-1.8.0/src/duktape.c.

32764 {

◆ duk__slow_case_conversion()

DUK_LOCAL duk_codepoint_t duk__slow_case_conversion ( duk_hthread * thr,
duk_bufwriter_ctx * bw,
duk_codepoint_t cp,
duk_bitdecoder_ctx * bd_ctx )

Definition at line 10739 of file duktape-1.8.0/src/duktape.c.

10759 {
10760 duk_small_int_t skip = 0;
10763 duk_small_int_t count;
10764 duk_codepoint_t tmp_cp;
10765 duk_codepoint_t start_i;
10766 duk_codepoint_t start_o;
10767
10768 DUK_UNREF(thr);
10769 DUK_ASSERT(bd_ctx != NULL);
10770
10771 DUK_DDD(DUK_DDDPRINT("slow case conversion for codepoint: %ld", (long) cp));
10772
10773 /* range conversion with a "skip" */
10774 DUK_DDD(DUK_DDDPRINT("checking ranges"));
10775 for (;;) {
10776 skip++;
10777 n = (duk_small_int_t) duk_bd_decode(bd_ctx, 6);
10778 if (n == 0x3f) {
10779 /* end marker */
10780 break;
10781 }
10782 DUK_DDD(DUK_DDDPRINT("skip=%ld, n=%ld", (long) skip, (long) n));
10783
10784 while (n--) {
10785 start_i = (duk_codepoint_t) duk_bd_decode(bd_ctx, 16);
10786 start_o = (duk_codepoint_t) duk_bd_decode(bd_ctx, 16);
10787 count = (duk_small_int_t) duk_bd_decode(bd_ctx, 7);
10788 DUK_DDD(DUK_DDDPRINT("range: start_i=%ld, start_o=%ld, count=%ld, skip=%ld",
10789 (long) start_i, (long) start_o, (long) count, (long) skip));
10790
10791 if (cp >= start_i) {
10792 tmp_cp = cp - start_i; /* always >= 0 */
10793 if (tmp_cp < (duk_codepoint_t) count * (duk_codepoint_t) skip &&
10794 (tmp_cp % (duk_codepoint_t) skip) == 0) {
10795 DUK_DDD(DUK_DDDPRINT("range matches input codepoint"));
10796 cp = start_o + tmp_cp;
10797 goto single;
10798 }
10799 }
10800 }
10801 }
10802
10803 /* 1:1 conversion */
10804 n = (duk_small_int_t) duk_bd_decode(bd_ctx, 6);
10805 DUK_DDD(DUK_DDDPRINT("checking 1:1 conversions (count %ld)", (long) n));
10806 while (n--) {
10807 start_i = (duk_codepoint_t) duk_bd_decode(bd_ctx, 16);
10808 start_o = (duk_codepoint_t) duk_bd_decode(bd_ctx, 16);
10809 DUK_DDD(DUK_DDDPRINT("1:1 conversion %ld -> %ld", (long) start_i, (long) start_o));
10810 if (cp == start_i) {
10811 DUK_DDD(DUK_DDDPRINT("1:1 matches input codepoint"));
10812 cp = start_o;
10813 goto single;
10814 }
10815 }
10816
10817 /* complex, multicharacter conversion */
10818 n = (duk_small_int_t) duk_bd_decode(bd_ctx, 7);
10819 DUK_DDD(DUK_DDDPRINT("checking 1:n conversions (count %ld)", (long) n));
10820 while (n--) {
10821 start_i = (duk_codepoint_t) duk_bd_decode(bd_ctx, 16);
10822 t = (duk_small_int_t) duk_bd_decode(bd_ctx, 2);
10823 DUK_DDD(DUK_DDDPRINT("1:n conversion %ld -> %ld chars", (long) start_i, (long) t));
10824 if (cp == start_i) {
10825 DUK_DDD(DUK_DDDPRINT("1:n matches input codepoint"));
10826 if (bw != NULL) {
10827 while (t--) {
10828 tmp_cp = (duk_codepoint_t) duk_bd_decode(bd_ctx, 16);
10829 DUK_BW_WRITE_RAW_XUTF8(thr, bw, (duk_ucodepoint_t) tmp_cp);
10830 }
10831 }
10832 return -1;

References DUK_ASSERT, duk_bd_decode(), DUK_BW_WRITE_RAW_XUTF8, DUK_DDD, DUK_DDDPRINT, DUK_UNREF, and NULL.

◆ duk__sort_array_indices()

DUK_LOCAL void duk__sort_array_indices ( duk_hthread * thr,
duk_hobject * h_obj )

Definition at line 46437 of file duktape-1.8.0/src/duktape.c.

46449 ://en.wikipedia.org/wiki/Insertion_sort
46450 *
46451 * (Compiles to about 160 bytes now as a stand-alone function.)
46452 */
46453
46455 duk_hstring **keys;
46456 duk_hstring **p_curr, **p_insert, **p_end;
46457 duk_hstring *h_curr;
46458 duk_uarridx_t val_highest, val_curr, val_insert;
46459
46460 DUK_ASSERT(h_obj != NULL);
46461 DUK_ASSERT(DUK_HOBJECT_GET_ENEXT(h_obj) >= 2); /* control props */
46462 DUK_UNREF(thr);
46463
46464 if (DUK_HOBJECT_GET_ENEXT(h_obj) <= 1 + DUK__ENUM_START_INDEX) {
46465 return;
46466 }
46467
46468 keys = DUK_HOBJECT_E_GET_KEY_BASE(thr->heap, h_obj);
46469 p_end = keys + DUK_HOBJECT_GET_ENEXT(h_obj);
46470 keys += DUK__ENUM_START_INDEX;
46471
46472 DUK_DDD(DUK_DDDPRINT("keys=%p, p_end=%p (after skipping enum props)",
46473 (void *) keys, (void *) p_end));
46474
46475#ifdef DUK_USE_DDDPRINT
46476 {
46478 for (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ENEXT(h_obj); i++) {
46479 DUK_DDD(DUK_DDDPRINT("initial: %ld %p -> %!O",
46480 (long) i,
46481 (void *) DUK_HOBJECT_E_GET_KEY_PTR(thr->heap, h_obj, i),
46482 (duk_heaphdr *) DUK_HOBJECT_E_GET_KEY(thr->heap, h_obj, i)));
46483 }
46484 }
46485#endif
46486
46487 val_highest = DUK_HSTRING_GET_ARRIDX_SLOW(keys[0]);
46488 for (p_curr = keys + 1; p_curr < p_end; p_curr++) {
46489 DUK_ASSERT(*p_curr != NULL);
46490 val_curr = DUK_HSTRING_GET_ARRIDX_SLOW(*p_curr);
46491
46492 if (val_curr >= val_highest) {
46493 DUK_DDD(DUK_DDDPRINT("p_curr=%p, p_end=%p, val_highest=%ld, val_curr=%ld -> "
46494 "already in correct order, next",
46495 (void *) p_curr, (void *) p_end, (long) val_highest, (long) val_curr));
46496 val_highest = val_curr;
46497 continue;
46498 }
46499
46500 DUK_DDD(DUK_DDDPRINT("p_curr=%p, p_end=%p, val_highest=%ld, val_curr=%ld -> "
46501 "needs to be inserted",
46502 (void *) p_curr, (void *) p_end, (long) val_highest, (long) val_curr));
46503
46504 /* Needs to be inserted; scan backwards, since we optimize
46505 * for the case where elements are nearly in order.
46506 */
46507
46508 p_insert = p_curr - 1;
46509 for (;;) {
46510 val_insert = DUK_HSTRING_GET_ARRIDX_SLOW(*p_insert);
46511 if (val_insert < val_curr) {
46512 DUK_DDD(DUK_DDDPRINT("p_insert=%p, val_insert=%ld, val_curr=%ld -> insert after this",
46513 (void *) p_insert, (long) val_insert, (long) val_curr));
46514 p_insert++;
46515 break;
46516 }
46517 if (p_insert == keys) {
46518 DUK_DDD(DUK_DDDPRINT("p_insert=%p -> out of keys, insert to beginning", (void *) p_insert));
46519 break;
46520 }
46521 DUK_DDD(DUK_DDDPRINT("p_insert=%p, val_insert=%ld, val_curr=%ld -> search backwards",
46522 (void *) p_insert, (long) val_insert, (long) val_curr));
46523 p_insert--;
46524 }
46525
46526 DUK_DDD(DUK_DDDPRINT("final p_insert=%p", (void *) p_insert));
46527
46528 /* .-- p_insert .-- p_curr
46529 * v v
46530 * | ... | insert | ... | curr
46531 */
46532
46533 h_curr = *p_curr;
46534 DUK_DDD(DUK_DDDPRINT("memmove: dest=%p, src=%p, size=%ld, h_curr=%p",
46535 (void *) (p_insert + 1), (void *) p_insert,
46536 (long) (p_curr - p_insert), (void *) h_curr));
46537
46538 DUK_MEMMOVE((void *) (p_insert + 1),
46539 (const void *) p_insert,
DUK_LOCAL void duk__sort_array_indices(duk_hthread *thr, duk_hobject *h_obj)
#define DUK_HOBJECT_E_GET_KEY_BASE(heap, h)
#define DUK__ENUM_START_INDEX
#define DUK_HOBJECT_E_GET_KEY_PTR(heap, h, i)

References DUK__ENUM_START_INDEX, DUK_ASSERT, DUK_DDD, DUK_DDDPRINT, DUK_HOBJECT_E_GET_KEY, DUK_HOBJECT_E_GET_KEY_BASE, DUK_HOBJECT_E_GET_KEY_PTR, DUK_HOBJECT_GET_ENEXT, DUK_HSTRING_GET_ARRIDX_SLOW, DUK_MEMMOVE, DUK_UNREF, duk_hthread::heap, and NULL.

◆ duk__sqrt()

DUK_LOCAL double duk__sqrt ( double x)

Definition at line 32765 of file duktape-1.8.0/src/duktape.c.

32767 {

◆ duk__stmt_label_site()

DUK_LOCAL_DECL duk_int_t duk__stmt_label_site ( duk_compiler_ctx * comp_ctx,
duk_int_t label_id )

Definition at line 63894 of file duktape-1.8.0/src/duktape.c.

◆ duk__sweep_heap()

DUK_LOCAL void duk__sweep_heap ( duk_heap * heap,
duk_int_t flags,
duk_size_t * out_count_keep )

Definition at line 42892 of file duktape-1.8.0/src/duktape.c.

42898 : %ld freed, %ld kept",
42899 (long) count_free, (long) count_keep));
42900#endif
42901 *out_count_keep = count_keep;
42902}
42903#endif /* DUK_USE_STRTAB_PROBE */
42904
42905/*
42906 * Sweep heap
42907 */
42908
42909DUK_LOCAL void duk__sweep_heap(duk_heap *heap, duk_int_t flags, duk_size_t *out_count_keep) {
42910 duk_heaphdr *prev; /* last element that was left in the heap */
42911 duk_heaphdr *curr;
42912 duk_heaphdr *next;
42913#ifdef DUK_USE_DEBUG
42914 duk_size_t count_free = 0;
42915 duk_size_t count_finalize = 0;
42916 duk_size_t count_rescue = 0;
42917#endif
42918 duk_size_t count_keep = 0;
42919
42920 DUK_UNREF(flags);
42921 DUK_DD(DUK_DDPRINT("duk__sweep_heap: %p", (void *) heap));
42922
42923 prev = NULL;
42924 curr = heap->heap_allocated;
42925 heap->heap_allocated = NULL;
42926 while (curr) {
42927 /* Strings and ROM objects are never placed on the heap allocated list. */
42928 DUK_ASSERT(DUK_HEAPHDR_GET_TYPE(curr) != DUK_HTYPE_STRING);
42929 DUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY(curr));
42930
42931 next = DUK_HEAPHDR_GET_NEXT(heap, curr);
42932
42933 if (DUK_HEAPHDR_HAS_REACHABLE(curr)) {
42934 /*
42935 * Reachable object, keep
42936 */
42937
42938 DUK_DDD(DUK_DDDPRINT("sweep, reachable: %p", (void *) curr));
42939
42940 if (DUK_HEAPHDR_HAS_FINALIZABLE(curr)) {
42941 /*
42942 * If object has been marked finalizable, move it to the
42943 * "to be finalized" work list. It will be collected on
42944 * the next mark-and-sweep if it is still unreachable
42945 * after running the finalizer.
42946 */
42947
42948 DUK_ASSERT(!DUK_HEAPHDR_HAS_FINALIZED(curr));
42949 DUK_ASSERT(DUK_HEAPHDR_GET_TYPE(curr) == DUK_HTYPE_OBJECT);
42950 DUK_DDD(DUK_DDDPRINT("object has finalizer, move to finalization work list: %p", (void *) curr));
42951
42952#ifdef DUK_USE_DOUBLE_LINKED_HEAP
42953 if (heap->finalize_list) {
42954 DUK_HEAPHDR_SET_PREV(heap, heap->finalize_list, curr);
42955 }
42956 DUK_HEAPHDR_SET_PREV(heap, curr, NULL);
42957#endif
42958 DUK_HEAPHDR_SET_NEXT(heap, curr, heap->finalize_list);
42959 DUK_ASSERT_HEAPHDR_LINKS(heap, curr);
42960 heap->finalize_list = curr;
42961#ifdef DUK_USE_DEBUG
42962 count_finalize++;
42963#endif
42964 } else {
42965 /*
42966 * Object will be kept; queue object back to heap_allocated (to tail)
42967 */
42968
42969 if (DUK_HEAPHDR_HAS_FINALIZED(curr)) {
42970 /*
42971 * Object's finalizer was executed on last round, and
42972 * object has been happily rescued.
42973 */
42974
42975 DUK_ASSERT(!DUK_HEAPHDR_HAS_FINALIZABLE(curr));
42976 DUK_ASSERT(DUK_HEAPHDR_GET_TYPE(curr) == DUK_HTYPE_OBJECT);
42977 DUK_DD(DUK_DDPRINT("object rescued during mark-and-sweep finalization: %p", (void *) curr));
42978#ifdef DUK_USE_DEBUG
42979 count_rescue++;
42980#endif
42981 } else {
42982 /*
42983 * Plain, boring reachable object.
42984 */
42985 DUK_DD(DUK_DDPRINT("keep object: %!iO", curr));
42986 count_keep++;
42987 }
42988
42989 if (!heap->heap_allocated) {
42990 heap->heap_allocated = curr;
42991 }
42992 if (prev) {
42993 DUK_HEAPHDR_SET_NEXT(heap, prev, curr);
42994 }
42995#ifdef DUK_USE_DOUBLE_LINKED_HEAP
42996 DUK_HEAPHDR_SET_PREV(heap, curr, prev);
42997#endif
42998 DUK_ASSERT_HEAPHDR_LINKS(heap, prev);
42999 DUK_ASSERT_HEAPHDR_LINKS(heap, curr);
43000 prev = curr;
43001 }
43002
43003 DUK_HEAPHDR_CLEAR_REACHABLE(curr);
43004 DUK_HEAPHDR_CLEAR_FINALIZED(curr);
43005 DUK_HEAPHDR_CLEAR_FINALIZABLE(curr);
43006
43007 DUK_ASSERT(!DUK_HEAPHDR_HAS_REACHABLE(curr));
43008 DUK_ASSERT(!DUK_HEAPHDR_HAS_FINALIZED(curr));
43009 DUK_ASSERT(!DUK_HEAPHDR_HAS_FINALIZABLE(curr));
43010
43011 curr = next;
43012 } else {
43013 /*
43014 * Unreachable object, free
43015 */
43016
43017 DUK_DDD(DUK_DDDPRINT("sweep, not reachable: %p", (void *) curr));
43018
43019#if defined(DUK_USE_REFERENCE_COUNTING)
43020 /* Non-zero refcounts should not happen because we refcount
43021 * finalize all unreachable objects which should cancel out
43022 * refcounts (even for cycles).
43023 */
43024 DUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(curr) == 0);
43025#endif
43026 DUK_ASSERT(!DUK_HEAPHDR_HAS_FINALIZABLE(curr));
43027
43028 if (DUK_HEAPHDR_HAS_FINALIZED(curr)) {
43029 DUK_DDD(DUK_DDDPRINT("finalized object not rescued: %p", (void *) curr));
43030 }
43031
43032 /* Note: object cannot be a finalizable unreachable object, as
43033 * they have been marked temporarily reachable for this round,
43034 * and are handled above.
43035 */
43036
43037#ifdef DUK_USE_DEBUG
43038 count_free++;
43039#endif
43040
43041 /* weak refs should be handled here, but no weak refs for
43042 * any non-string objects exist right now.
43043 */
43044
DUK_LOCAL void duk__sweep_heap(duk_heap *heap, duk_int_t flags, duk_size_t *out_count_keep)

◆ duk__sweep_stringtable_probe()

DUK_LOCAL void duk__sweep_stringtable_probe ( duk_heap * heap,
duk_size_t * out_count_keep )

Definition at line 42819 of file duktape-1.8.0/src/duktape.c.

42819 {
42820#if defined(DUK_USE_HEAPPTR16)
42821 duk__sweep_string_chain16(heap, lst + j, &count_keep, &count_free);
42822#else
42823 duk__sweep_string_chain(heap, lst + j, &count_keep, &count_free);
42824#endif
42825 }
42826 }
42827 }
42828
42829 DUK_D(DUK_DPRINT("mark-and-sweep sweep stringtable: %ld freed, %ld kept",
42830 (long) count_free, (long) count_keep));
42831 *out_count_keep = count_keep;
42832}
42833#endif /* DUK_USE_STRTAB_CHAIN */
42834
42835#if defined(DUK_USE_STRTAB_PROBE)
42836DUK_LOCAL void duk__sweep_stringtable_probe(duk_heap *heap, duk_size_t *out_count_keep) {
42837 duk_hstring *h;
42839#ifdef DUK_USE_DEBUG
42840 duk_size_t count_free = 0;
42841#endif
42842 duk_size_t count_keep = 0;
42843
42844 DUK_DD(DUK_DDPRINT("duk__sweep_stringtable: %p", (void *) heap));
42845
42846 for (i = 0; i < heap->st_size; i++) {
42847#if defined(DUK_USE_HEAPPTR16)
42848 h = (duk_hstring *) DUK_USE_HEAPPTR_DEC16(heap->heap_udata, heap->strtable16[i]);
42849#else
42850 h = heap->strtable[i];
42851#endif
42852 if (h == NULL || h == DUK_STRTAB_DELETED_MARKER(heap)) {
42853 continue;
42854 } else if (DUK_HEAPHDR_HAS_REACHABLE((duk_heaphdr *) h)) {
42856 count_keep++;
42857 continue;
42858 }
42859
42860#ifdef DUK_USE_DEBUG
42861 count_free++;
42862#endif
42863
42864#if defined(DUK_USE_REFERENCE_COUNTING)
42865 /* Non-zero refcounts should not happen for unreachable strings,
42866 * because we refcount finalize all unreachable objects which
42867 * should have decreased unreachable string refcounts to zero
42868 * (even for cycles).
42869 */
42871#endif
42872
42873 DUK_DDD(DUK_DDDPRINT("sweep string, not reachable: %p", (void *) h));
42874
42875 /* deal with weak references first */
42877
42878 /* remove the string (mark DELETED), could also call
42879 * duk_heap_string_remove() but that would be slow and
42880 * pointless because we already know the slot.
42881 */
42882#if defined(DUK_USE_HEAPPTR16)
42883 heap->strtable16[i] = heap->heapptr_deleted16;
42884#else
42885 heap->strtable[i] = DUK_STRTAB_DELETED_MARKER(heap);
#define DUK_STRTAB_DELETED_MARKER(heap)
DUK_INTERNAL_DECL void duk_heap_strcache_string_remove(duk_heap *heap, duk_hstring *h)
DUK_LOCAL void duk__sweep_stringtable_probe(duk_heap *heap, duk_size_t *out_count_keep)

◆ duk__tag_check()

DUK_LOCAL duk_bool_t duk__tag_check ( duk_context * ctx,
duk_idx_t index,
duk_small_uint_t tag )

Definition at line 17591 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_is_buffer_data(), and duk_is_function().

◆ duk__tan()

DUK_LOCAL double duk__tan ( double x)

Definition at line 32768 of file duktape-1.8.0/src/duktape.c.

32770 {

◆ duk__timeclip()

DUK_LOCAL duk_double_t duk__timeclip ( duk_double_t x)

Definition at line 25078 of file duktape-1.8.0/src/duktape.c.

25083 {
25084 return (x >= -DUK_DATE_MSEC_100M_DAYS && x <= DUK_DATE_MSEC_100M_DAYS);
25085}
25086
25089}
25090
#define DUK_DATE_MSEC_100M_DAYS
#define DUK_DATE_MSEC_100M_DAYS_LEEWAY
DUK_INTERNAL_DECL duk_bool_t duk_bi_date_timeval_in_leeway_range(duk_double_t x)

◆ duk__to_int_uint_helper()

DUK_LOCAL duk_double_t duk__to_int_uint_helper ( duk_context * ctx,
duk_idx_t index,
duk__toint_coercer coerce_func )

Definition at line 16925 of file duktape-1.8.0/src/duktape.c.

16942 {

◆ duk__to_new_array_length_checked()

DUK_LOCAL duk_uint32_t duk__to_new_array_length_checked ( duk_hthread * thr)

Definition at line 50331 of file duktape-1.8.0/src/duktape.c.

50336 {
50337 res = (duk_uint32_t) DUK_TVAL_GET_FASTINT_U32(tv);
50338 } else {
50339 res = (duk_uint32_t) DUK_TVAL_GET_DOUBLE(tv);
50340 }
50341#else
50342 res = (duk_uint32_t) DUK_TVAL_GET_NUMBER(tv);
50343#endif /* DUK_USE_FASTINT */
50344
50345 return res;
50346}
50347
50349 duk_context *ctx = (duk_context *) thr;
50350 duk_uint32_t res;
DUK_LOCAL duk_uint32_t duk__to_new_array_length_checked(duk_hthread *thr)

Referenced by duk_hobject_define_property_helper().

◆ duk__to_regexp_helper()

DUK_LOCAL void duk__to_regexp_helper ( duk_context * ctx,
duk_idx_t index,
duk_bool_t force_new )

Definition at line 35148 of file duktape-1.8.0/src/duktape.c.

35150 :
35151#ifdef DUK_USE_REGEXP_SUPPORT
35152 if (is_regexp) {
35153 duk_pop(ctx);
35154 }
35155#endif
35156
35157 return 1;
35158}
35159
35160/*
35161 * Various
35162 */
35163
35164#ifdef DUK_USE_REGEXP_SUPPORT
35166 duk_hobject *h;
35167
35168 /* Shared helper for match() steps 3-4, search() steps 3-4. */
35169
35170 DUK_ASSERT(index >= 0);
DUK_LOCAL void duk__to_regexp_helper(duk_context *ctx, duk_idx_t index, duk_bool_t force_new)

References duk_pop().

◆ duk__to_string_helper()

DUK_LOCAL duk_ret_t duk__to_string_helper ( duk_context * ctx,
duk_small_uint_t flags )

Definition at line 25626 of file duktape-1.8.0/src/duktape.c.

25627 {
25628 DUK_SPRINTF((char *) out_buf, "%s-%02d-%02d",
25629 (const char *) yearstr, (int) parts[DUK_DATE_IDX_MONTH], (int) parts[DUK_DATE_IDX_DAY]);
25630 } else {
25632 DUK_SPRINTF((char *) out_buf, "%02d:%02d:%02d.%03d%s",
25633 (int) parts[DUK_DATE_IDX_HOUR], (int) parts[DUK_DATE_IDX_MINUTE],
25634 (int) parts[DUK_DATE_IDX_SECOND], (int) parts[DUK_DATE_IDX_MILLISECOND],
25635 (const char *) tzstr);
25636 }
25637}
25638
25639/* Helper for string conversion calls: check 'this' binding, get the
25640 * internal time value, and format date and/or time in a few formats.
25641 * Return value allows tail calls.
25642 */
25644 duk_double_t d;
25646 duk_int_t tzoffset; /* seconds, doesn't fit into 16 bits */
25647 duk_bool_t rc;
25648 duk_uint8_t buf[DUK_BI_DATE_ISO8601_BUFSIZE];
25649
25650 DUK_UNREF(rc); /* unreferenced with some options */
25651
25652 d = duk__push_this_get_timeval_tzoffset(ctx, flags, &tzoffset);
25653 if (DUK_ISNAN(d)) {
25655 return 1;
25656 }
25658
25659 /* formatters always get one-based month/day-of-month */
25661 DUK_ASSERT(parts[DUK_DATE_IDX_MONTH] >= 1 && parts[DUK_DATE_IDX_MONTH] <= 12);
25662 DUK_ASSERT(parts[DUK_DATE_IDX_DAY] >= 1 && parts[DUK_DATE_IDX_DAY] <= 31);
25663
25664 if (flags & DUK_DATE_FLAG_TOSTRING_LOCALE) {
25665 /* try locale specific formatter; if it refuses to format the
25666 * string, fall back to an ISO 8601 formatted value in local
25667 * time.
25668 */
25669#if defined(DUK_USE_DATE_FORMAT_STRING)
25670 /* Contract, either:
25671 * - Push string to value stack and return 1
25672 * - Don't push anything and return 0
25673 */
25674
25675 rc = DUK_USE_DATE_FORMAT_STRING(ctx, parts, tzoffset, flags);
#define DUK_DATE_FLAG_TOSTRING_LOCALE
#define DUK_DATE_FLAG_TOSTRING_TIME
#define DUK_DATE_FLAG_ONEBASED
#define DUK_BI_DATE_ISO8601_BUFSIZE
#define DUK_STRIDX_INVALID_DATE
DUK_LOCAL duk_ret_t duk__to_string_helper(duk_context *ctx, duk_small_uint_t flags)

Referenced by duk_bi_date_prototype_to_json().

◆ duk__toint32_touint32_helper()

DUK_LOCAL duk_double_t duk__toint32_touint32_helper ( duk_double_t x,
duk_bool_t is_toint32 )

Definition at line 70386 of file duktape-1.8.0/src/duktape.c.

70392 {
70393 /* XXX: fastint */
70394 duk_double_t d = duk_js_tonumber(thr, tv); /* invalidates tv */
70395 return duk_js_tointeger_number(d);
70396}
70397
70398/*
70399 * ToInt32(), ToUint32(), ToUint16() (E5 Sections 9.5, 9.6, 9.7)
70400 */
70401
70402/* combined algorithm matching E5 Sections 9.5 and 9.6 */
70406
70407 if (c == DUK_FP_NAN || c == DUK_FP_ZERO || c == DUK_FP_INFINITE) {
70408 return 0.0;
70409 }
70410
70411
70412 /* x = sign(x) * floor(abs(x)), i.e. truncate towards zero, keep sign */
70414 x = DUK_FLOOR(DUK_FABS(x));
70415 if (s) {
70416 x = -x;
70417 }
70418
70419 /* NOTE: fmod(x) result sign is same as sign of x, which
70420 * differs from what Javascript wants (see Section 9.6).
70421 */
70422
DUK_INTERNAL_DECL duk_double_t duk_js_tonumber(duk_hthread *thr, duk_tval *tv)
DUK_LOCAL duk_double_t duk__toint32_touint32_helper(duk_double_t x, duk_bool_t is_toint32)

◆ duk__tonumber_string_raw()

DUK_LOCAL duk_double_t duk__tonumber_string_raw ( duk_hthread * thr)

Definition at line 70245 of file duktape-1.8.0/src/duktape.c.

70262 {
70263 duk_context *ctx = (duk_context *) thr;
70264 duk_small_uint_t s2n_flags;
70265 duk_double_t d;
70266
70267 /* Quite lenient, e.g. allow empty as zero, but don't allow trailing
70268 * garbage.
70269 */
70270 s2n_flags = DUK_S2N_FLAG_TRIM_WHITE |
#define DUK_S2N_FLAG_TRIM_WHITE

References DUK_S2N_FLAG_ALLOW_EXP, and DUK_S2N_FLAG_TRIM_WHITE.

◆ duk__transform_callback_decode_uri()

DUK_LOCAL void duk__transform_callback_decode_uri ( duk__transform_context * tfm_ctx,
const void * udata,
duk_codepoint_t cp )

Definition at line 28011 of file duktape-1.8.0/src/duktape.c.

28013 {
28014 t = (int) xutf8_buf[i];
28015 DUK_BW_WRITE_RAW_U8_3(tfm_ctx->thr,
28016 &tfm_ctx->bw,
28018 (duk_uint8_t) duk_uc_nybbles[t >> 4],
28019 (duk_uint8_t) duk_uc_nybbles[t & 0x0f]);
28020 }
28021
28022 return;
28023
28024 uri_error:
28025 DUK_ERROR(tfm_ctx->thr, DUK_ERR_URI_ERROR, "invalid input");
28026}
28027
28029 const duk_uint8_t *reserved_table = (const duk_uint8_t *) udata;
28030 duk_small_uint_t utf8_blen;
28031 duk_codepoint_t min_cp;
28032 duk_small_int_t t; /* must be signed */
28034
28035 /* Maximum write size: XUTF8 path writes max DUK_UNICODE_MAX_XUTF8_LENGTH,
28036 * percent escape path writes max two times CESU-8 encoded BMP length.
28037 */
28038 DUK_BW_ENSURE(tfm_ctx->thr,
28039 &tfm_ctx->bw,
28042
28043 if (cp == (duk_codepoint_t) '%') {
28044 const duk_uint8_t *p = tfm_ctx->p;
28045 duk_size_t left = (duk_size_t) (tfm_ctx->p_end - p); /* bytes left */
28046
28047 DUK_DDD(DUK_DDDPRINT("percent encoding, left=%ld", (long) left));
28048
28049 if (left < 2) {
28050 goto uri_error;
28051 }
28052
28053 t = duk__decode_hex_escape(p, 2);
28054 DUK_DDD(DUK_DDDPRINT("first byte: %ld", (long) t));
28055 if (t < 0) {
28056 goto uri_error;
28057 }
28058
28059 if (t < 0x80) {
28060 if (DUK__CHECK_BITMASK(reserved_table, t)) {
28061 /* decode '%xx' to '%xx' if decoded char in reserved set */
28062 DUK_ASSERT(tfm_ctx->p - 1 >= tfm_ctx->p_start);
28063 DUK_BW_WRITE_RAW_U8_3(tfm_ctx->thr,
28064 &tfm_ctx->bw,
28066 p[0],
28067 p[1]);
28068 } else {
28069 DUK_BW_WRITE_RAW_U8(tfm_ctx->thr, &tfm_ctx->bw, (duk_uint8_t) t);
28070 }
28071 tfm_ctx->p += 2;
28072 return;
28073 }
28074
28075 /* Decode UTF-8 codepoint from a sequence of hex escapes. The
28076 * first byte of the sequence has been decoded to 't'.
28077 *
28078 * Note that UTF-8 validation must be strict according to the
28079 * specification: E5.1 Section 15.1.3, decode algorithm step
28080 * 4.d.vii.8. URIError from non-shortest encodings is also
28081 * specifically noted in the spec.
28082 */
28083
28084 DUK_ASSERT(t >= 0x80);
28085 if (t < 0xc0) {
28086 /* continuation byte */
28087 goto uri_error;
28088 } else if (t < 0xe0) {
28089 /* 110x xxxx; 2 bytes */
28090 utf8_blen = 2;
28091 min_cp = 0x80L;
28092 cp = t & 0x1f;
28093 } else if (t < 0xf0) {
28094 /* 1110 xxxx; 3 bytes */
28095 utf8_blen = 3;
28096 min_cp = 0x800L;
28097 cp = t & 0x0f;
28098 } else if (t < 0xf8) {
28099 /* 1111 0xxx; 4 bytes */
28100 utf8_blen = 4;
28101 min_cp = 0x10000L;
28102 cp = t & 0x07;
28103 } else {
28104 /* extended utf-8 not allowed for URIs */
28105 goto uri_error;
28106 }
28107
28108 if (left < utf8_blen * 3 - 1) {
28109 /* '%xx%xx...%xx', p points to char after first '%' */
28110 goto uri_error;
28111 }
28112
28113 p += 3;
28114 for (i = 1; i < utf8_blen; i++) {
28115 /* p points to digit part ('%xy', p points to 'x') */
28116 t = duk__decode_hex_escape(p, 2);
28117 DUK_DDD(DUK_DDDPRINT("i=%ld utf8_blen=%ld cp=%ld t=0x%02lx",
28118 (long) i, (long) utf8_blen, (long) cp, (unsigned long) t));
28119 if (t < 0) {
28120 goto uri_error;
28121 }
28122 if ((t & 0xc0) != 0x80) {
28123 goto uri_error;
28124 }
28125 cp = (cp << 6) + (t & 0x3f);
28126 p += 3;
28127 }
28128 p--; /* p overshoots */
28129 tfm_ctx->p = p;
28130
28131 DUK_DDD(DUK_DDDPRINT("final cp=%ld, min_cp=%ld", (long) cp, (long) min_cp));
28132
28133 if (cp < min_cp || cp > 0x10ffffL || (cp >= 0xd800L && cp <= 0xdfffL)) {
28134 goto uri_error;
28135 }
28136
28137 /* The E5.1 algorithm checks whether or not a decoded codepoint
28138 * is below 0x80 and perhaps may be in the "reserved" set.
28139 * This seems pointless because the single byte UTF-8 case is
28140 * handled separately, and non-shortest encodings are rejected.
28141 * So, 'cp' cannot be below 0x80 here, and thus cannot be in
28142 * the reserved set.
28143 */
28144
28145 /* utf-8 validation ensures these */
28146 DUK_ASSERT(cp >= 0x80L && cp <= 0x10ffffL);
28147
#define DUK_UNICODE_MAX_CESU8_BMP_LENGTH
DUK_LOCAL duk_small_int_t duk__decode_hex_escape(const duk_uint8_t *p, duk_small_int_t n)
#define DUK_BW_WRITE_RAW_U8_3(thr, bw_ctx, val1, val2, val3)
#define DUK_BW_ENSURE(thr, bw_ctx, sz)
DUK_INTERNAL const duk_uint8_t duk_uc_nybbles[16]
DUK_LOCAL void duk__transform_callback_decode_uri(duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp)
#define DUK_ASC_PERCENT
#define DUK__CHECK_BITMASK(table, cp)

Referenced by duk_bi_global_object_escape(), and duk_bi_global_object_unescape().

◆ duk__transform_callback_encode_uri()

DUK_LOCAL void duk__transform_callback_encode_uri ( duk__transform_context * tfm_ctx,
const void * udata,
duk_codepoint_t cp )

Definition at line 27949 of file duktape-1.8.0/src/duktape.c.

27955 {
27956 cp = (duk_codepoint_t) duk_unicode_decode_xutf8_checked(thr, &tfm_ctx->p, tfm_ctx->p_start, tfm_ctx->p_end);
27957 callback(tfm_ctx, udata, cp);
27958 }
27959
27960 DUK_BW_COMPACT(thr, &tfm_ctx->bw);
27961
27962 duk_to_string(ctx, -1);
27963 return 1;
27964}
27965
27967 duk_uint8_t xutf8_buf[DUK_UNICODE_MAX_XUTF8_LENGTH];
27968 duk_small_int_t len;
27969 duk_codepoint_t cp1, cp2;
27970 duk_small_int_t i, t;
27971 const duk_uint8_t *unescaped_table = (const duk_uint8_t *) udata;
27972
27973 /* UTF-8 encoded bytes escaped as %xx%xx%xx... -> 3 * nbytes.
27974 * Codepoint range is restricted so this is a slightly too large
27975 * but doesn't matter.
27976 */
27977 DUK_BW_ENSURE(tfm_ctx->thr, &tfm_ctx->bw, 3 * DUK_UNICODE_MAX_XUTF8_LENGTH);
27978
27979 if (cp < 0) {
27980 goto uri_error;
27981 } else if ((cp < 0x80L) && DUK__CHECK_BITMASK(unescaped_table, cp)) {
27982 DUK_BW_WRITE_RAW_U8(tfm_ctx->thr, &tfm_ctx->bw, (duk_uint8_t) cp);
27983 return;
27984 } else if (cp >= 0xdc00L && cp <= 0xdfffL) {
27985 goto uri_error;
27986 } else if (cp >= 0xd800L && cp <= 0xdbffL) {
27987 /* Needs lookahead */
27988 if (duk_unicode_decode_xutf8(tfm_ctx->thr, &tfm_ctx->p, tfm_ctx->p_start, tfm_ctx->p_end, (duk_ucodepoint_t *) &cp2) == 0) {
27989 goto uri_error;
27990 }
27991 if (!(cp2 >= 0xdc00L && cp2 <= 0xdfffL)) {
27992 goto uri_error;
27993 }
27994 cp1 = cp;
27995 cp = ((cp1 - 0xd800L) << 10) + (cp2 - 0xdc00L) + 0x10000L;
27996 } else if (cp > 0x10ffffL) {
27997 /* Although we can allow non-BMP characters (they'll decode
27998 * back into surrogate pairs), we don't allow extended UTF-8
27999 * characters; they would encode to URIs which won't decode
28000 * back because of strict UTF-8 checks in URI decoding.
28001 * (However, we could just as well allow them here.)
28002 */
28003 goto uri_error;
28004 } else {
28005 /* Non-BMP characters within valid UTF-8 range: encode as is.
28006 * They'll decode back into surrogate pairs if the escaped
28007 * output is decoded.
28008 */
28009 ;
DUK_LOCAL void duk__transform_callback_encode_uri(duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp)
#define DUK_BW_COMPACT(thr, bw_ctx)
DUK_INTERNAL_DECL duk_ucodepoint_t duk_unicode_decode_xutf8_checked(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end)

◆ duk__transform_callback_escape()

DUK_LOCAL void duk__transform_callback_escape ( duk__transform_context * tfm_ctx,
const void * udata,
duk_codepoint_t cp )

Definition at line 28150 of file duktape-1.8.0/src/duktape.c.

28154 {
28155 DUK_BW_WRITE_RAW_XUTF8(tfm_ctx->thr, &tfm_ctx->bw, cp);
28156 }
28157 } else {
28158 DUK_BW_WRITE_RAW_XUTF8(tfm_ctx->thr, &tfm_ctx->bw, cp);
28159 }
28160 return;
28161
28162 uri_error:
28163 DUK_ERROR(tfm_ctx->thr, DUK_ERR_URI_ERROR, "invalid input");
28164}
28165
28166#ifdef DUK_USE_SECTION_B
28168 DUK_UNREF(udata);
28169
28170 DUK_BW_ENSURE(tfm_ctx->thr, &tfm_ctx->bw, 6);
28171
28172 if (cp < 0) {
28173 goto esc_error;
28174 } else if ((cp < 0x80L) && DUK__CHECK_BITMASK(duk__escape_unescaped_table, cp)) {
28175 DUK_BW_WRITE_RAW_U8(tfm_ctx->thr, &tfm_ctx->bw, (duk_uint8_t) cp);
28176 } else if (cp < 0x100L) {
28177 DUK_BW_WRITE_RAW_U8_3(tfm_ctx->thr,
28178 &tfm_ctx->bw,
28179 (duk_uint8_t) DUK_ASC_PERCENT,
28180 (duk_uint8_t) duk_uc_nybbles[cp >> 4],
28181 (duk_uint8_t) duk_uc_nybbles[cp & 0x0f]);
28182 } else if (cp < 0x10000L) {
28183 DUK_BW_WRITE_RAW_U8_6(tfm_ctx->thr,
28184 &tfm_ctx->bw,
28185 (duk_uint8_t) DUK_ASC_PERCENT,
28186 (duk_uint8_t) DUK_ASC_LC_U,
28187 (duk_uint8_t) duk_uc_nybbles[cp >> 12],
#define DUK_BW_WRITE_RAW_U8_6(thr, bw_ctx, val1, val2, val3, val4, val5, val6)
DUK_LOCAL void duk__transform_callback_escape(duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp)
DUK_LOCAL const duk_uint8_t duk__escape_unescaped_table[16]

◆ duk__transform_callback_unescape()

DUK_LOCAL void duk__transform_callback_unescape ( duk__transform_context * tfm_ctx,
const void * udata,
duk_codepoint_t cp )

Definition at line 28189 of file duktape-1.8.0/src/duktape.c.

28191 {
28192 /* Characters outside BMP cannot be escape()'d. We could
28193 * encode them as surrogate pairs (for codepoints inside
28194 * valid UTF-8 range, but not extended UTF-8). Because
28195 * escape() and unescape() are legacy functions, we don't.
28196 */
28197 goto esc_error;
28198 }
28199
28200 return;
28201
28202 esc_error:
28203 DUK_ERROR_TYPE(tfm_ctx->thr, "invalid input");
28204}
28205
28208
28209 DUK_UNREF(udata);
28210
DUK_LOCAL void duk__transform_callback_unescape(duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp)

Referenced by duk_bi_global_object_print_helper().

◆ duk__transform_helper()

DUK_LOCAL int duk__transform_helper ( duk_context * ctx,
duk__transform_callback callback,
const void * udata )

Definition at line 27921 of file duktape-1.8.0/src/duktape.c.

27921 {
27922 duk_small_int_t ch;
27923 duk_small_int_t t = 0;
27924
27925 while (n > 0) {
27926 t = t * 16;
27927 ch = (duk_small_int_t) duk_hex_dectab[*p++];
27928 if (DUK_LIKELY(ch >= 0)) {
27929 t += ch;
27930 } else {
27931 return -1;
27932 }
27933 n--;
27934 }
27935 return t;
27936}
27937
27938DUK_LOCAL int duk__transform_helper(duk_context *ctx, duk__transform_callback callback, const void *udata) {
27939 duk_hthread *thr = (duk_hthread *) ctx;
27940 duk__transform_context tfm_ctx_alloc;
27941 duk__transform_context *tfm_ctx = &tfm_ctx_alloc;
27942 duk_codepoint_t cp;
27943
27944 tfm_ctx->thr = thr;
27945
27946 tfm_ctx->h_str = duk_to_hstring(ctx, 0);
27947 DUK_ASSERT(tfm_ctx->h_str != NULL);
DUK_LOCAL int duk__transform_helper(duk_context *ctx, duk__transform_callback callback, const void *udata)

References duk_hex_dectab, and DUK_LIKELY.

Referenced by duk_bi_global_object_escape(), duk_bi_global_object_print_helper(), and duk_bi_global_object_unescape().

◆ duk__try_push_vsprintf()

DUK_LOCAL duk_int_t duk__try_push_vsprintf ( duk_context * ctx,
void * buf,
duk_size_t sz,
const char * fmt,
va_list ap )

Definition at line 18461 of file duktape-1.8.0/src/duktape.c.

18466 {
18467 duk_hthread *thr = (duk_hthread *) ctx;
18469 if (!target_ctx) {
18471 return; /* not reached */
18472 }
18473 duk_push_hobject(ctx, (duk_hobject *) target_ctx);
18474 duk__push_stash(ctx);
18475}
18476
DUK_LOCAL void duk__push_stash(duk_context *ctx)

◆ duk__tval_number_to_arr_idx()

DUK_LOCAL duk_uint32_t duk__tval_number_to_arr_idx ( duk_tval * tv)

Definition at line 47520 of file duktape-1.8.0/src/duktape.c.

47537 {
47538 duk_double_t dbl;
47539 duk_uint32_t idx;

Referenced by duk__getprop_shallow_fastpath_array_tval(), and duk_hobject_putprop().

◆ duk__twodigit_year_fixup()

DUK_LOCAL_DECL void duk__twodigit_year_fixup ( duk_context * ctx,
duk_idx_t idx_val )

Definition at line 25813 of file duktape-1.8.0/src/duktape.c.

25818 {
25819 return duk__set_this_timeval_from_dparts(ctx, dparts, flags_and_maxnargs);
25820 } else {
25821 /* Internal timevalue is already NaN, so don't touch it. */
25822 duk_push_nan(ctx);
25823 return 1;
25824 }
25825}
25826
25827/* Apply ToNumber() to specified index; if ToInteger(val) in [0,99], add
25828 * 1900 and replace value at idx_val.
25829 */
25831 duk_double_t d;
25832
25833 /* XXX: idx_val would fit into 16 bits, but using duk_small_uint_t
25834 * might not generate better code due to casting.
DUK_EXTERNAL void duk_push_nan(duk_context *ctx)

◆ duk__unemit_1()

DUK_LOCAL_DECL void duk__unemit_1 ( duk_json_enc_ctx * js_ctx)

Definition at line 30173 of file duktape-1.8.0/src/duktape.c.

30174 {
30175 DUK_BW_WRITE_ENSURE_CSTRING(js_ctx->thr, &js_ctx->bw, str);
30176}
#define DUK_BW_WRITE_ENSURE_CSTRING(thr, bw_ctx, val)

References duk_json_enc_ctx::bw, DUK_BW_WRITE_ENSURE_CSTRING, and duk_json_enc_ctx::thr.

◆ duk__uni_decode_value()

DUK_LOCAL duk_uint32_t duk__uni_decode_value ( duk_bitdecoder_ctx * bd_ctx)

Definition at line 10331 of file duktape-1.8.0/src/duktape.c.

10348 {
10349 duk_uint32_t t;

◆ duk__uni_range_match()

DUK_LOCAL duk_small_int_t duk__uni_range_match ( const duk_uint8_t * unitab,
duk_size_t unilen,
duk_codepoint_t cp )

Definition at line 10351 of file duktape-1.8.0/src/duktape.c.

10352 {
10353 return t;
10354 }
10355 t = (duk_uint32_t) duk_bd_decode(bd_ctx, 8);
10356 if (t <= 0xfdU) {
10357 return t + 0x0f;
10358 }
10359 if (t == 0xfeU) {
10360 t = (duk_uint32_t) duk_bd_decode(bd_ctx, 12);
10361 return t + 0x0fU + 0xfeU;
10362 } else {
10363 t = (duk_uint32_t) duk_bd_decode(bd_ctx, 24);
10364 return t + 0x0fU + 0xfeU + 0x1000UL;
10365 }
10366}
10367
10368DUK_LOCAL duk_small_int_t duk__uni_range_match(const duk_uint8_t *unitab, duk_size_t unilen, duk_codepoint_t cp) {
10369 duk_bitdecoder_ctx bd_ctx;
10370 duk_codepoint_t prev_re;
10371
10372 DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx));
10373 bd_ctx.data = (const duk_uint8_t *) unitab;
10374 bd_ctx.length = (duk_size_t) unilen;
10375
10376 prev_re = 0;
10377 for (;;) {
10378 duk_codepoint_t r1, r2;
10379 r1 = (duk_codepoint_t) duk__uni_decode_value(&bd_ctx);
10380 if (r1 == 0) {
10381 break;
10382 }
DUK_LOCAL duk_uint32_t duk__uni_decode_value(duk_bitdecoder_ctx *bd_ctx)
DUK_LOCAL duk_small_int_t duk__uni_range_match(const duk_uint8_t *unitab, duk_size_t unilen, duk_codepoint_t cp)

◆ duk__update_label_flags()

DUK_LOCAL_DECL void duk__update_label_flags ( duk_compiler_ctx * comp_ctx,
duk_int_t label_id,
duk_small_uint_t flags )

Definition at line 60316 of file duktape-1.8.0/src/duktape.c.

60327 : flags=0x%08lx, id=%ld, name=%!O, catch_depth=%ld, pc_label=%ld",
60328 (unsigned long) li->flags, (long) li->label_id, (duk_heaphdr *) li->h_label,
60329 (long) li->catch_depth, (long) li->pc_label));
60330}
60331
60332/* Update all labels with matching label_id. */
60333DUK_LOCAL void duk__update_label_flags(duk_compiler_ctx *comp_ctx, duk_int_t label_id, duk_small_uint_t flags) {
60334 duk_uint8_t *p;
60335 duk_labelinfo *li_start, *li;
60336
60337 p = (duk_uint8_t *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(comp_ctx->thr->heap, comp_ctx->curr_func.h_labelinfos);
60338 li_start = (duk_labelinfo *) (void *) p;
60339 li = (duk_labelinfo *) (void *) (p + DUK_HBUFFER_GET_SIZE(comp_ctx->curr_func.h_labelinfos));
60340

◆ duk__update_lineinfo_currtoken()

DUK_LOCAL void duk__update_lineinfo_currtoken ( duk_compiler_ctx * comp_ctx)

Definition at line 58820 of file duktape-1.8.0/src/duktape.c.

58820 {
58821 goto fail_bc_limit;
58822 }
58823#endif
58824#endif
58825
58826 return;
58827
58828 fail_bc_limit:
58830}
58831
58832/* Update function min/max line from current token. Needed to improve
58833 * function line range information for debugging, so that e.g. opening
58834 * curly brace is covered by line range even when no opcodes are emitted
58835 * for the line containing the brace.
58836 */

Referenced by duk__parse_func_body().

◆ duk__utf8_advance()

DUK_LOCAL const duk_uint8_t * duk__utf8_advance ( duk_hthread * thr,
const duk_uint8_t ** ptr,
const duk_uint8_t * ptr_start,
const duk_uint8_t * ptr_end,
duk_uint_fast32_t count )

Definition at line 78800 of file duktape-1.8.0/src/duktape.c.

78802 {
78803 /* utf-8 continuation bytes have the form 10xx xxxx */
78804 break;
78805 }
78806 }
78807 count--;
78808 }
78809 *ptr = p;
78810 return p;
78811
78812 fail:
78814 return NULL; /* never here */
78815}
78816
78817DUK_LOCAL const duk_uint8_t *duk__utf8_advance(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end, duk_uint_fast32_t count) {
78818 const duk_uint8_t *p;
78819
78820 p = *ptr;
78821 if (p < ptr_start || p >= ptr_end) {
78822 goto fail;
78823 }
78824
78825 while (count > 0) {
78826 for (;;) {
78827 p++;
78828
78829 /* Note: if encoding ends by hitting end of input, we don't check that

◆ duk__utf8_backtrack()

DUK_LOCAL const duk_uint8_t * duk__utf8_backtrack ( duk_hthread * thr,
const duk_uint8_t ** ptr,
const duk_uint8_t * ptr_start,
const duk_uint8_t * ptr_end,
duk_uint_fast32_t count )

Definition at line 78770 of file duktape-1.8.0/src/duktape.c.

78771 {
78772 return (duk_uint32_t) duk_unicode_decode_xutf8_checked(re_ctx->thr, pc, re_ctx->bytecode, re_ctx->bytecode_end);
78773}
78774
78775DUK_LOCAL duk_int32_t duk__bc_get_i32(duk_re_matcher_ctx *re_ctx, const duk_uint8_t **pc) {
78776 duk_uint32_t t;
78777
78778 /* signed integer encoding needed to work with UTF-8 */
78779 t = (duk_uint32_t) duk_unicode_decode_xutf8_checked(re_ctx->thr, pc, re_ctx->bytecode, re_ctx->bytecode_end);
78780 if (t & 1) {
78781 return -((duk_int32_t) (t >> 1));
78782 } else {
78783 return (duk_int32_t) (t >> 1);
78784 }
78785}
78786
78787DUK_LOCAL const duk_uint8_t *duk__utf8_backtrack(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end, duk_uint_fast32_t count) {
78788 const duk_uint8_t *p;
78789
78790 /* Note: allow backtracking from p == ptr_end */
78791 p = *ptr;
78792 if (p < ptr_start || p > ptr_end) {
78793 goto fail;
78794 }
78795
78796 while (count > 0) {
78797 for (;;) {
78798 p--;
DUK_LOCAL const duk_uint8_t * duk__utf8_backtrack(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end, duk_uint_fast32_t count)

References duk_re_matcher_ctx::bytecode, duk_re_matcher_ctx::bytecode_end, duk_unicode_decode_xutf8_checked(), and duk_re_matcher_ctx::thr.

◆ duk__vm_arith_add()

DUK_LOCAL void duk__vm_arith_add ( duk_hthread * thr,
duk_tval * tv_x,
duk_tval * tv_y,
duk_small_uint_fast_t idx_z )

Definition at line 65621 of file duktape-1.8.0/src/duktape.c.

65626 {
65627 /*
65628 * Ecmascript modulus ('%') does not match IEEE 754 "remainder"
65629 * operation (implemented by remainder() in C99) but does seem
65630 * to match ANSI C fmod().
65631 *
65632 * Compare E5 Section 11.5.3 and "man fmod".
65633 */
65634
65635 return (duk_double_t) DUK_FMOD((double) d1, (double) d2);
65636}
65637
65639 /*
65640 * Addition operator is different from other arithmetic
65641 * operations in that it also provides string concatenation.
65642 * Hence it is implemented separately.
65643 *
65644 * There is a fast path for number addition. Other cases go
65645 * through potentially multiple coercions as described in the
65646 * E5 specification. It may be possible to reduce the number
65647 * of coercions, but this must be done carefully to preserve
65648 * the exact semantics.
65649 *
65650 * E5 Section 11.6.1.
65651 *
65652 * Custom types also have special behavior implemented here.
65653 */
65654
65655 duk_context *ctx = (duk_context *) thr;
65657
65658 DUK_ASSERT(thr != NULL);
65659 DUK_ASSERT(ctx != NULL);
65660 DUK_ASSERT(tv_x != NULL); /* may be reg or const */
65661 DUK_ASSERT(tv_y != NULL); /* may be reg or const */
65662 DUK_ASSERT_DISABLE(idx_z >= 0); /* unsigned */
65663 DUK_ASSERT((duk_uint_t) idx_z < (duk_uint_t) duk_get_top(ctx));
65664
65665 /*
65666 * Fast paths
65667 */
65668
65669#if defined(DUK_USE_FASTINT)
65670 if (DUK_TVAL_IS_FASTINT(tv_x) && DUK_TVAL_IS_FASTINT(tv_y)) {
65671 duk_int64_t v1, v2, v3;
65672 duk_int32_t v3_hi;
65673 duk_tval *tv_z;
65674
65675 /* Input values are signed 48-bit so we can detect overflow
65676 * reliably from high bits or just a comparison.
65677 */
65678
65679 v1 = DUK_TVAL_GET_FASTINT(tv_x);
65680 v2 = DUK_TVAL_GET_FASTINT(tv_y);
65681 v3 = v1 + v2;
65682 v3_hi = (duk_int32_t) (v3 >> 32);
65683 if (DUK_LIKELY(v3_hi >= -0x8000LL && v3_hi <= 0x7fffLL)) {
65684 tv_z = thr->valstack_bottom + idx_z;
65685 DUK_TVAL_SET_FASTINT_UPDREF(thr, tv_z, v3); /* side effects */
65686 return;
65687 } else {
65688 /* overflow, fall through */
65689 ;
65690 }
65691 }
65692#endif /* DUK_USE_FASTINT */
65693
65694 if (DUK_TVAL_IS_NUMBER(tv_x) && DUK_TVAL_IS_NUMBER(tv_y)) {
65695 duk_tval *tv_z;
65696
65697 du.d = DUK_TVAL_GET_NUMBER(tv_x) + DUK_TVAL_GET_NUMBER(tv_y);
65700
65701 tv_z = thr->valstack_bottom + idx_z;
65702 DUK_TVAL_SET_NUMBER_UPDREF(thr, tv_z, du.d); /* side effects */
65703 return;
65704 }
65705
65706 /*
65707 * Slow path: potentially requires function calls for coercion
65708 */
65709
65710 duk_push_tval(ctx, tv_x);
65711 duk_push_tval(ctx, tv_y);
65712 duk_to_primitive(ctx, -2, DUK_HINT_NONE); /* side effects -> don't use tv_x, tv_y after */
65714
65715 /* As a first approximation, buffer values are coerced to strings
65716 * for addition. This means that adding two buffers currently
65717 * results in a string.
65718 */
65721 duk_to_string(ctx, -2);
65722 duk_to_string(ctx, -1);
65723 duk_concat(ctx, 2); /* [... s1 s2] -> [... s1+s2] */
65724 duk_replace(ctx, (duk_idx_t) idx_z); /* side effects */
65725 } else {
65726 duk_double_t d1, d2;
#define DUK_TYPE_MASK_STRING
#define DUK_DBLUNION_IS_NORMALIZED(u)
DUK_EXTERNAL void duk_to_primitive(duk_context *ctx, duk_idx_t index, duk_int_t hint)

References DUK_FMOD.

◆ duk__vm_arith_binary_op()

DUK_LOCAL void duk__vm_arith_binary_op ( duk_hthread * thr,
duk_tval * tv_x,
duk_tval * tv_y,
duk_idx_t idx_z,
duk_small_uint_fast_t opcode )

Definition at line 65728 of file duktape-1.8.0/src/duktape.c.

65745 {
65746 /*
65747 * Arithmetic operations other than '+' have number-only semantics
65748 * and are implemented here. The separate switch-case here means a
65749 * "double dispatch" of the arithmetic opcode, but saves code space.
65750 *
65751 * E5 Sections 11.5, 11.5.1, 11.5.2, 11.5.3, 11.6, 11.6.1, 11.6.2, 11.6.3.
65752 */
65753
65754 duk_context *ctx = (duk_context *) thr;
65755 duk_tval *tv_z;
65756 duk_double_t d1, d2;
65758
65759 DUK_ASSERT(thr != NULL);
65760 DUK_ASSERT(ctx != NULL);
65761 DUK_ASSERT(tv_x != NULL); /* may be reg or const */
65762 DUK_ASSERT(tv_y != NULL); /* may be reg or const */
65763 DUK_ASSERT_DISABLE(idx_z >= 0); /* unsigned */
65764 DUK_ASSERT((duk_uint_t) idx_z < (duk_uint_t) duk_get_top(ctx));
65765
65766#if defined(DUK_USE_FASTINT)
65767 if (DUK_TVAL_IS_FASTINT(tv_x) && DUK_TVAL_IS_FASTINT(tv_y)) {
65768 duk_int64_t v1, v2, v3;
65769 duk_int32_t v3_hi;
65770
65771 v1 = DUK_TVAL_GET_FASTINT(tv_x);
65772 v2 = DUK_TVAL_GET_FASTINT(tv_y);
65773
65774 switch (opcode) {
65775 case DUK_OP_SUB: {
65776 v3 = v1 - v2;
65777 break;
65778 }
65779 case DUK_OP_MUL: {
65780 /* Must ensure result is 64-bit (no overflow); a
65781 * simple and sufficient fast path is to allow only
65782 * 32-bit inputs. Avoid zero inputs to avoid
65783 * negative zero issues (-1 * 0 = -0, for instance).
65784 */
65785 if (v1 >= -0x80000000LL && v1 <= 0x7fffffffLL && v1 != 0 &&
65786 v2 >= -0x80000000LL && v2 <= 0x7fffffffLL && v2 != 0) {
65787 v3 = v1 * v2;
65788 } else {
65789 goto skip_fastint;
65790 }
65791 break;
65792 }
65793 case DUK_OP_DIV: {
65794 /* Don't allow a zero divisor. Fast path check by
65795 * "verifying" with multiplication. Also avoid zero
65796 * dividend to avoid negative zero issues (0 / -1 = -0
65797 * for instance).
65798 */
65799 if (v1 == 0 || v2 == 0) {
65800 goto skip_fastint;
65801 }
65802 v3 = v1 / v2;
65803 if (v3 * v2 != v1) {
65804 goto skip_fastint;
65805 }
65806 break;
65807 }
65808 case DUK_OP_MOD: {
65809 /* Don't allow a zero divisor. Restrict both v1 and
65810 * v2 to positive values to avoid compiler specific
65811 * behavior.
65812 */
65813 if (v1 < 1 || v2 < 1) {
65814 goto skip_fastint;
65815 }
65816 v3 = v1 % v2;
65817 DUK_ASSERT(v3 >= 0);
65818 DUK_ASSERT(v3 < v2);
65819 DUK_ASSERT(v1 - (v1 / v2) * v2 == v3);
65820 break;
65821 }
65822 default: {
65824 goto skip_fastint;
65825 }
65826 }
65827
65828 v3_hi = (duk_int32_t) (v3 >> 32);
65829 if (DUK_LIKELY(v3_hi >= -0x8000LL && v3_hi <= 0x7fffLL)) {
65830 tv_z = thr->valstack_bottom + idx_z;
65831 DUK_TVAL_SET_FASTINT_UPDREF(thr, tv_z, v3); /* side effects */
65832 return;
65833 }
65834 /* fall through if overflow etc */
65835 }
65836 skip_fastint:
65837#endif /* DUK_USE_FASTINT */
65838
65839 if (DUK_TVAL_IS_NUMBER(tv_x) && DUK_TVAL_IS_NUMBER(tv_y)) {
65840 /* fast path */
65841 d1 = DUK_TVAL_GET_NUMBER(tv_x);
65842 d2 = DUK_TVAL_GET_NUMBER(tv_y);
65843 } else {
65844 duk_push_tval(ctx, tv_x);
65845 duk_push_tval(ctx, tv_y);
65846 d1 = duk_to_number(ctx, -2); /* side effects */
65847 d2 = duk_to_number(ctx, -1);
65848 DUK_ASSERT(duk_is_number(ctx, -2));
65849 DUK_ASSERT(duk_is_number(ctx, -1));
65852 duk_pop_2(ctx);
65853 }
65854
65855 switch (opcode) {
65856 case DUK_OP_SUB: {
65857 du.d = d1 - d2;
65858 break;
65859 }
65860 case DUK_OP_MUL: {
65861 du.d = d1 * d2;
65862 break;
65863 }
65864 case DUK_OP_DIV: {
65865 du.d = d1 / d2;
65866 break;
65867 }
65868 case DUK_OP_MOD: {
#define DUK_ASSERT_DOUBLE_IS_NORMALIZED(dval)

◆ duk__vm_arith_unary_op()

DUK_LOCAL void duk__vm_arith_unary_op ( duk_hthread * thr,
duk_tval * tv_x,
duk_idx_t idx_x,
duk_small_uint_fast_t opcode )

Definition at line 65990 of file duktape-1.8.0/src/duktape.c.

65991 :
65992 tv_z = thr->valstack_bottom + idx_z;
65993 DUK_TVAL_SET_FASTINT_UPDREF(thr, tv_z, fi3); /* side effects */
65994#else
65995 d3 = (duk_double_t) i3;
65996
65997 result_set:
65998 DUK_ASSERT(!DUK_ISNAN(d3)); /* 'd3' is never NaN, so no need to normalize */
65999 DUK_ASSERT_DOUBLE_IS_NORMALIZED(d3); /* always normalized */
66000
66001 tv_z = thr->valstack_bottom + idx_z;
66002 DUK_TVAL_SET_NUMBER_UPDREF(thr, tv_z, d3); /* side effects */
66003#endif
66004}
66005
66006/* In-place unary operation. */
66008 /*
66009 * Arithmetic operations other than '+' have number-only semantics
66010 * and are implemented here. The separate switch-case here means a
66011 * "double dispatch" of the arithmetic opcode, but saves code space.
66012 *
66013 * E5 Sections 11.5, 11.5.1, 11.5.2, 11.5.3, 11.6, 11.6.1, 11.6.2, 11.6.3.
66014 */
66015
66016 duk_context *ctx = (duk_context *) thr;
66017 duk_double_t d1;
66019
66020 DUK_ASSERT(thr != NULL);
66021 DUK_ASSERT(ctx != NULL);
66022 DUK_ASSERT(opcode == DUK_EXTRAOP_UNM || opcode == DUK_EXTRAOP_UNP);
66023 DUK_ASSERT(tv_x != NULL);
66024 DUK_ASSERT(idx_x >= 0);
66025
66026#if defined(DUK_USE_FASTINT)
66027 if (DUK_TVAL_IS_FASTINT(tv_x)) {
66028 duk_int64_t v1, v2;
66029
66030 v1 = DUK_TVAL_GET_FASTINT(tv_x);
66031 if (opcode == DUK_EXTRAOP_UNM) {
66032 /* The smallest fastint is no longer 48-bit when
66033 * negated. Positive zero becames negative zero
66034 * (cannot be represented) when negated.
66035 */
66036 if (DUK_LIKELY(v1 != DUK_FASTINT_MIN && v1 != 0)) {
66037 v2 = -v1;
66038 DUK_TVAL_SET_FASTINT(tv_x, v2); /* no refcount changes */
66039 return;
66040 }
66041 } else {
66042 /* ToNumber() for a fastint is a no-op. */
66043 DUK_ASSERT(opcode == DUK_EXTRAOP_UNP);
66044 return;
66045 }
66046 /* fall through if overflow etc */
66047 }
66048#endif /* DUK_USE_FASTINT */
66049
66050 if (!DUK_TVAL_IS_NUMBER(tv_x)) {
66051 duk_to_number(ctx, idx_x); /* side effects, perform in-place */
66052 tv_x = DUK_GET_TVAL_POSIDX(ctx, idx_x);
66053 DUK_ASSERT(tv_x != NULL);
66055 }
66056
66057 d1 = DUK_TVAL_GET_NUMBER(tv_x);
66058 if (opcode == DUK_EXTRAOP_UNM) {
66059 du.d = -d1;
66060 } else {

◆ duk__vm_bitwise_binary_op()

DUK_LOCAL void duk__vm_bitwise_binary_op ( duk_hthread * thr,
duk_tval * tv_x,
duk_tval * tv_y,
duk_small_uint_fast_t idx_z,
duk_small_uint_fast_t opcode )

Definition at line 65870 of file duktape-1.8.0/src/duktape.c.

65872 : {
65874 du.d = DUK_DOUBLE_NAN; /* should not happen */
65875 break;
65876 }
65877 }
65878
65879 /* important to use normalized NaN with 8-byte tagged types */
65882
65883 tv_z = thr->valstack_bottom + idx_z;
65884 DUK_TVAL_SET_NUMBER_UPDREF(thr, tv_z, du.d); /* side effects */
65885}
65886
65888 /*
65889 * Binary bitwise operations use different coercions (ToInt32, ToUint32)
65890 * depending on the operation. We coerce the arguments first using
65891 * ToInt32(), and then cast to an 32-bit value if necessary. Note that
65892 * such casts must be correct even if there is no native 32-bit type
65893 * (e.g., duk_int32_t and duk_uint32_t are 64-bit).
65894 *
65895 * E5 Sections 11.10, 11.7.1, 11.7.2, 11.7.3
65896 */
65897
65898 duk_context *ctx = (duk_context *) thr;
65899 duk_tval *tv_z;
65900 duk_int32_t i1, i2, i3;
65901 duk_uint32_t u1, u2, u3;
65902#if defined(DUK_USE_FASTINT)
65903 duk_int64_t fi3;
65904#else
65905 duk_double_t d3;
65906#endif
65907
65908 DUK_ASSERT(thr != NULL);
65909 DUK_ASSERT(ctx != NULL);
65910 DUK_ASSERT(tv_x != NULL); /* may be reg or const */
65911 DUK_ASSERT(tv_y != NULL); /* may be reg or const */
65912 DUK_ASSERT_DISABLE(idx_z >= 0); /* unsigned */
65913 DUK_ASSERT((duk_uint_t) idx_z < (duk_uint_t) duk_get_top(ctx));
65914
65915#if defined(DUK_USE_FASTINT)
65916 if (DUK_TVAL_IS_FASTINT(tv_x) && DUK_TVAL_IS_FASTINT(tv_y)) {
65917 i1 = (duk_int32_t) DUK_TVAL_GET_FASTINT_I32(tv_x);
65918 i2 = (duk_int32_t) DUK_TVAL_GET_FASTINT_I32(tv_y);
65919 }
65920 else
65921#endif /* DUK_USE_FASTINT */
65922 {
65923 duk_push_tval(ctx, tv_x);
65924 duk_push_tval(ctx, tv_y);
65925 i1 = duk_to_int32(ctx, -2);
65926 i2 = duk_to_int32(ctx, -1);
65927 duk_pop_2(ctx);
65928 }
65929
65930 switch (opcode) {
65931 case DUK_OP_BAND: {
65932 i3 = i1 & i2;
65933 break;
65934 }
65935 case DUK_OP_BOR: {
65936 i3 = i1 | i2;
65937 break;
65938 }
65939 case DUK_OP_BXOR: {
65940 i3 = i1 ^ i2;
65941 break;
65942 }
65943 case DUK_OP_BASL: {
65944 /* Signed shift, named "arithmetic" (asl) because the result
65945 * is signed, e.g. 4294967295 << 1 -> -2. Note that result
65946 * must be masked.
65947 */
65948
65949 u2 = ((duk_uint32_t) i2) & 0xffffffffUL;
65950 i3 = (duk_int32_t) (((duk_uint32_t) i1) << (u2 & 0x1fUL)); /* E5 Section 11.7.1, steps 7 and 8 */
65951 i3 = i3 & ((duk_int32_t) 0xffffffffUL); /* Note: left shift, should mask */
65952 break;
65953 }
65954 case DUK_OP_BASR: {
65955 /* signed shift */
65956
65957 u2 = ((duk_uint32_t) i2) & 0xffffffffUL;
65958 i3 = i1 >> (u2 & 0x1fUL); /* E5 Section 11.7.2, steps 7 and 8 */
65959 break;
65960 }
65961 case DUK_OP_BLSR: {
65962 /* unsigned shift */
65963
65964 u1 = ((duk_uint32_t) i1) & 0xffffffffUL;
65965 u2 = ((duk_uint32_t) i2) & 0xffffffffUL;
65966
65967 /* special result value handling */
65968 u3 = u1 >> (u2 & 0x1fUL); /* E5 Section 11.7.2, steps 7 and 8 */
65969#if defined(DUK_USE_FASTINT)
65970 fi3 = (duk_int64_t) u3;
65971 goto fastint_result_set;
65972#else
65973 d3 = (duk_double_t) u3;
65974 goto result_set;
65975#endif
65976 }
65977 default: {
65979 i3 = 0; /* should not happen */
65980 break;
65981 }
65982 }
65983
65984#if defined(DUK_USE_FASTINT)
65985 /* Result is always fastint compatible. */
65986 /* XXX: Set 32-bit result (but must then handle signed and
65987 * unsigned results separately).
DUK_EXTERNAL duk_int32_t duk_to_int32(duk_context *ctx, duk_idx_t index)

◆ duk__vm_bitwise_not()

DUK_LOCAL void duk__vm_bitwise_not ( duk_hthread * thr,
duk_tval * tv_x,
duk_uint_fast_t idx_z )

Definition at line 66062 of file duktape-1.8.0/src/duktape.c.

66079 {
66080 /*
66081 * E5 Section 11.4.8
66082 */
66083
66084 duk_context *ctx = (duk_context *) thr;
66085 duk_tval *tv_z;
66086 duk_int32_t i1, i2;
66087#if !defined(DUK_USE_FASTINT)
66088 duk_double_t d2;
66089#endif
66090
66091 DUK_ASSERT(thr != NULL);
66092 DUK_ASSERT(ctx != NULL);
66093 DUK_ASSERT(tv_x != NULL); /* may be reg or const */
66094 DUK_ASSERT_DISABLE(idx_z >= 0);
66095 DUK_ASSERT((duk_uint_t) idx_z < (duk_uint_t) duk_get_top(ctx));
66096
66097#if defined(DUK_USE_FASTINT)
66098 if (DUK_TVAL_IS_FASTINT(tv_x)) {
66099 i1 = (duk_int32_t) DUK_TVAL_GET_FASTINT_I32(tv_x);
66100 }
66101 else
66102#endif /* DUK_USE_FASTINT */
66103 {
66104 duk_push_tval(ctx, tv_x);
66105 i1 = duk_to_int32(ctx, -1);
66106 duk_pop(ctx);
66107 }

◆ duk__vm_logical_not()

DUK_LOCAL void duk__vm_logical_not ( duk_hthread * thr,
duk_tval * tv_x,
duk_tval * tv_z )

Definition at line 66109 of file duktape-1.8.0/src/duktape.c.

66126 {
66127 /*
66128 * E5 Section 11.4.9
66129 */
66130

◆ duk__year_from_day()

DUK_LOCAL duk_int_t duk__year_from_day ( duk_int_t day,
duk_small_int_t * out_day_within_year )

Definition at line 25119 of file duktape-1.8.0/src/duktape.c.

25125 {
25126 /* Note: in integer arithmetic, (x / 4) is same as floor(x / 4) for non-negative
25127 * values, but is incorrect for negative ones.
25128 */
25129 return 365 * (year - 1970)
25130 + duk__div_floor(year - 1969, 4)
25131 - duk__div_floor(year - 1901, 100)
25132 + duk__div_floor(year - 1601, 400);
25133}
25134
25135/* Given a day number, determine year and day-within-year. */
25137 duk_int_t year;
25138 duk_int_t diff_days;
25139
25140 /* estimate year upwards (towards positive infinity), then back down;
25141 * two iterations should be enough
25142 */
25143
25144 if (day >= 0) {
25145 year = 1970 + day / 365;
25146 } else {
25147 year = 1970 + day / 366;
25148 }
25149
25150 for (;;) {
25151 diff_days = duk__day_from_year(year) - day;
DUK_LOCAL duk_int_t duk__year_from_day(duk_int_t day, duk_small_int_t *out_day_within_year)
DUK_LOCAL duk_int_t duk__day_from_year(duk_int_t year)
DUK_LOCAL duk_int_t duk__div_floor(duk_int_t a, duk_int_t b)

◆ duk_alloc()

DUK_EXTERNAL void * duk_alloc ( duk_context * ctx,
duk_size_t size )

Definition at line 14320 of file duktape-1.8.0/src/duktape.c.

14321 {
14322 duk_hthread *thr = (duk_hthread *) ctx;
14323
14325
14326 DUK_FREE_RAW(thr->heap, ptr);
#define DUK_FREE_RAW(heap, ptr)

References DUK_ASSERT_CTX_VALID, DUK_FREE_RAW, and duk_hthread::heap.

◆ duk_alloc_raw()

DUK_EXTERNAL void * duk_alloc_raw ( duk_context * ctx,
duk_size_t size )

Definition at line 14296 of file duktape-1.8.0/src/duktape.c.

14297 {
14298 va_list ap;
14299
14301
14302 va_start(ap, fmt);

References DUK_ASSERT_CTX_VALID, and duk_log_va().

◆ duk_base64_decode()

DUK_EXTERNAL void duk_base64_decode ( duk_context * ctx,
duk_idx_t index )

Definition at line 13353 of file duktape-1.8.0/src/duktape.c.

13353 {
13354 goto type_error;
13355 }
13356 dstlen = (srclen + 2) / 3 * 4;
13357 dst = (duk_uint8_t *) duk_push_fixed_buffer(ctx, dstlen);
13358
13359 duk__base64_encode_helper((const duk_uint8_t *) src, srclen, dst);
13360
13361 ret = duk_to_string(ctx, -1);
13362 duk_replace(ctx, index);
13363 return ret;
13364
13365 type_error:
13367 return NULL; /* never here */
13368}
13369
13371 duk_hthread *thr = (duk_hthread *) ctx;
13372 const duk_uint8_t *src;
13373 duk_size_t srclen;
13374 duk_size_t dstlen;
13375 duk_uint8_t *dst;
13376 duk_uint8_t *dst_final;
13377 duk_bool_t retval;
13378
13380
13381 /* XXX: optimize for buffer inputs: no need to coerce to a string
13382 * which causes an unnecessary interning.
13383 */
13384
13386 src = duk__prep_codec_arg(ctx, index, &srclen);
13387
13388 /* Computation must not wrap, only srclen + 3 is at risk of
13389 * wrapping because after that the number gets smaller.
13390 * This limit works for 32-bit size_t:
13391 * 0x100000000 - 3 - 1 = 4294967292
13392 */
13393 if (srclen > 4294967292UL) {
13394 goto type_error;
13395 }
DUK_LOCAL const duk_uint8_t * duk__prep_codec_arg(duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
DUK_EXTERNAL void duk_base64_decode(duk_context *ctx, duk_idx_t index)
#define DUK_STR_ENCODE_FAILED

◆ duk_base64_encode()

DUK_EXTERNAL const char * duk_base64_encode ( duk_context * ctx,
duk_idx_t index )

Definition at line 13313 of file duktape-1.8.0/src/duktape.c.

13314 {
13315 /* Here we'd have the option of decoding unpadded base64
13316 * (e.g. "xxxxyy" instead of "xxxxyy==". Currently not
13317 * accepted.
13318 */
13319 goto error;
13320 }
13321
13322 *out_dst_final = dst;
13323 return 1;
13324
13325 error:
13326 return 0;
13327}
13328#endif /* DUK_USE_BASE64_FASTPATH */
13329
13331 duk_hthread *thr = (duk_hthread *) ctx;
13332 const duk_uint8_t *src;
13333 duk_size_t srclen;
13334 duk_size_t dstlen;
13335 duk_uint8_t *dst;
13336 const char *ret;
13337
13339
13340 /* XXX: optimize for string inputs: no need to coerce to a buffer
13341 * which makes a copy of the input.
13342 */
13343
13345 src = duk__prep_codec_arg(ctx, index, &srclen);
13346 /* Note: for srclen=0, src may be NULL */
13347
13348 /* Computation must not wrap; this limit works for 32-bit size_t:
13349 * >>> srclen = 3221225469
13350 * >>> '%x' % ((srclen + 2) / 3 * 4)
13351 * 'fffffffc'
DUK_EXTERNAL const char * duk_base64_encode(duk_context *ctx, duk_idx_t index)

References error().

◆ duk_bd_decode()

DUK_INTERNAL_DECL duk_int32_t duk_bd_decode ( duk_bitdecoder_ctx * ctx,
duk_small_int_t bits )

Definition at line 86379 of file duktape-1.8.0/src/duktape.c.

86396 {
86397 duk_small_int_t shift;
86398 duk_uint32_t mask;
86399 duk_uint32_t tmp;
86400
86401 /* Note: cannot read more than 24 bits without possibly shifting top bits out.
86402 * Fixable, but adds complexity.
86403 */
86404 DUK_ASSERT(bits >= 1 && bits <= 24);
86405
86406 while (ctx->currbits < bits) {
86407#if 0
86408 DUK_DDD(DUK_DDDPRINT("decode_bits: shift more data (bits=%ld, currbits=%ld)",
86409 (long) bits, (long) ctx->currbits));
86410#endif
86411 ctx->currval <<= 8;
86412 if (ctx->offset < ctx->length) {
86413 /* If ctx->offset >= ctx->length, we "shift zeroes in"
86414 * instead of croaking.
86415 */
86416 ctx->currval |= ctx->data[ctx->offset++];
86417 }
86418 ctx->currbits += 8;
86419 }
86420#if 0
86421 DUK_DDD(DUK_DDDPRINT("decode_bits: bits=%ld, currbits=%ld, currval=0x%08lx",
86422 (long) bits, (long) ctx->currbits, (unsigned long) ctx->currval));

Referenced by duk__push_double(), duk__slow_case_conversion(), and duk_be_encode().

◆ duk_bd_decode_flag()

Definition at line 86424 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_be_encode().

◆ duk_bd_decode_flagged()

DUK_INTERNAL_DECL duk_int32_t duk_bd_decode_flagged ( duk_bitdecoder_ctx * ctx,
duk_small_int_t bits,
duk_int32_t def_value )

Definition at line 86432 of file duktape-1.8.0/src/duktape.c.

86434 : %ld bits -> 0x%08lx (%ld), currbits=%ld, currval=0x%08lx",
86435 (long) bits, (unsigned long) tmp, (long) tmp, (long) ctx->currbits, (unsigned long) ctx->currval));
86436#endif
86437
86438 return tmp;

◆ duk_be_encode()

DUK_INTERNAL_DECL void duk_be_encode ( duk_bitencoder_ctx * ctx,
duk_uint32_t data,
duk_small_int_t bits )

Definition at line 86446 of file duktape-1.8.0/src/duktape.c.

86449 {
86450 if (duk_bd_decode_flag(ctx)) {
86451 return (duk_int32_t) duk_bd_decode(ctx, bits);
86452 } else {
86453 return def_value;
86454 }
86455}
86456#line 1 "duk_util_bitencoder.c"
86457/*
86458 * Bitstream encoder.
86459 */
86460
86461/* include removed: duk_internal.h */
86462
86463DUK_INTERNAL void duk_be_encode(duk_bitencoder_ctx *ctx, duk_uint32_t data, duk_small_int_t bits) {
86464 duk_uint8_t tmp;
86465
86466 DUK_ASSERT(ctx != NULL);
86467 DUK_ASSERT(ctx->currbits < 8);
86468
86469 /* This limitation would be fixable but adds unnecessary complexity. */

References duk_bd_decode(), and duk_bd_decode_flag().

Referenced by duk__bw_update_ptrs().

◆ duk_be_finish()

DUK_INTERNAL_DECL void duk_be_finish ( duk_bitencoder_ctx * ctx)

Definition at line 86471 of file duktape-1.8.0/src/duktape.c.

86475 {
86476 if (ctx->offset < ctx->length) {
86477 tmp = (duk_uint8_t) ((ctx->currval >> (ctx->currbits - 8)) & 0xff);
86478 ctx->data[ctx->offset++] = tmp;
86479 } else {
86480 /* If buffer has been exhausted, truncate bitstream */
86481 ctx->truncated = 1;
86482 }

References duk_bitencoder_ctx::currbits, duk_bitencoder_ctx::currval, duk_bitencoder_ctx::data, duk_bitencoder_ctx::length, duk_bitencoder_ctx::offset, and duk_bitencoder_ctx::truncated.

◆ duk_bi_array_constructor()

DUK_INTERNAL_DECL duk_ret_t duk_bi_array_constructor ( duk_context * ctx)

Definition at line 20293 of file duktape-1.8.0/src/duktape.c.

20294 {
20295 /* Range limited to [0, 0x7fffffff] range, i.e. range that can be
20296 * represented with duk_int32_t. Use this when the method doesn't
20297 * handle the full 32-bit unsigned range correctly.
20298 */
20299 duk_uint32_t ret = duk__push_this_obj_len_u32(ctx);
20300 if (DUK_UNLIKELY(ret >= 0x80000000UL)) {
20302 }
20303 return ret;
20304}
20305
20306/*
20307 * Constructor
20308 */
20309
20311 duk_idx_t nargs;
20312 duk_double_t d;
20313 duk_uint32_t len;
20314 duk_idx_t i;
20315
20316 nargs = duk_get_top(ctx);
20317 duk_push_array(ctx);
20318
20319 if (nargs == 1 && duk_is_number(ctx, 0)) {
20320 /* XXX: expensive check (also shared elsewhere - so add a shared internal API call?) */
20321 d = duk_get_number(ctx, 0);
20322 len = duk_to_uint32(ctx, 0);
20323 if (((duk_double_t) len) != d) {
20324 return DUK_RET_RANGE_ERROR;
20325 }
20326
20327 /* XXX: if 'len' is low, may want to ensure array part is kept:
20328 * the caller is likely to want a dense array.
20329 */
20330 duk_push_u32(ctx, len);
#define DUK_RET_RANGE_ERROR
#define DUK_STR_ARRAY_LENGTH_OVER_2G
DUK_LOCAL duk_uint32_t duk__push_this_obj_len_u32(duk_context *ctx)
DUK_EXTERNAL duk_uint32_t duk_to_uint32(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_constructor(duk_context *ctx)

References duk__push_this_obj_len_u32(), DUK_ERROR_RANGE, DUK_STR_ARRAY_LENGTH_OVER_2G, and DUK_UNLIKELY.

◆ duk_bi_array_constructor_is_array()

DUK_INTERNAL_DECL duk_ret_t duk_bi_array_constructor_is_array ( duk_context * ctx)

Definition at line 20336 of file duktape-1.8.0/src/duktape.c.

20339 {
20340 duk_dup(ctx, i);
20342 }

References duk_dup(), and duk_xdef_prop_index_wec.

◆ duk_bi_array_prototype_concat()

DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_concat ( duk_context * ctx)

Definition at line 20387 of file duktape-1.8.0/src/duktape.c.

20392 : func=%!iT, this=%!iT",
20393 (duk_tval *) duk_get_tval(ctx, -2),
20394 (duk_tval *) duk_get_tval(ctx, -1)));
20395 duk_call_method(ctx, 0);
20396
20397 return 1;
20398}
20399
20400/*
20401 * concat()
20402 */
20403
20404DUK_INTERNAL duk_ret_t duk_bi_array_prototype_concat(duk_context *ctx) {
20405 duk_idx_t i, n;
20406 duk_uarridx_t idx, idx_last;
20407 duk_uarridx_t j, len;
20408 duk_hobject *h;
20409
20410 /* XXX: the insert here is a bit expensive if there are a lot of items.
20411 * It could also be special cased in the outermost for loop quite easily
20412 * (as the element is dup()'d anyway).
20413 */
20414
20415 (void) duk_push_this_coercible_to_object(ctx);
20416 duk_insert(ctx, 0);
20417 n = duk_get_top(ctx);
20418 duk_push_array(ctx); /* -> [ ToObject(this) item1 ... itemN arr ] */
20419
20420 /* NOTE: The Array special behaviors are NOT invoked by duk_xdef_prop_index()
20421 * (which differs from the official algorithm). If no error is thrown, this
20422 * doesn't matter as the length is updated at the end. However, if an error
20423 * is thrown, the length will be unset. That shouldn't matter because the
20424 * caller won't get a reference to the intermediate value.
20425 */
20426
20427 idx = 0;
20428 idx_last = 0;
20429 for (i = 0; i < n; i++) {
20430 DUK_ASSERT_TOP(ctx, n + 1);
20431
20432 /* [ ToObject(this) item1 ... itemN arr ] */
20433
20434 duk_dup(ctx, i);
20435 h = duk_get_hobject_with_class(ctx, -1, DUK_HOBJECT_CLASS_ARRAY);
20436 if (!h) {
20437 duk_xdef_prop_index_wec(ctx, -2, idx++);
20438 idx_last = idx;
20439 continue;
20440 }
20441
20442 /* [ ToObject(this) item1 ... itemN arr item(i) ] */
20443
20444 /* XXX: an array can have length higher than 32 bits; this is not handled
20445 * correctly now.
20446 */
20447 len = (duk_uarridx_t) duk_get_length(ctx, -1);
20448 for (j = 0; j < len; j++) {
20449 if (duk_get_prop_index(ctx, -1, j)) {
20450 /* [ ToObject(this) item1 ... itemN arr item(i) item(i)[j] ] */
20451 duk_xdef_prop_index_wec(ctx, -3, idx++);
20452 idx_last = idx;
20453 } else {
20454 idx++;
20455 duk_pop(ctx);
20456#if defined(DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER)
20457 /* According to E5.1 Section 15.4.4.4 nonexistent trailing
20458 * elements do not affect 'length' of the result. Test262
20459 * and other engines disagree, so update idx_last here too.
20460 */
20461 idx_last = idx;
20462#else
20463 /* Strict standard behavior, ignore trailing elements for
20464 * result 'length'.

◆ duk_bi_array_prototype_indexof_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_indexof_shared ( duk_context * ctx)

Definition at line 21329 of file duktape-1.8.0/src/duktape.c.

21346 {
21347 duk_idx_t nargs;
21348 duk_int_t i, len;
21349 duk_int_t from_index;
21350 duk_small_int_t idx_step = duk_get_current_magic(ctx); /* idx_step is +1 for indexOf, -1 for lastIndexOf */
21351
21352 /* lastIndexOf() needs to be a vararg function because we must distinguish
21353 * between an undefined fromIndex and a "not given" fromIndex; indexOf() is
21354 * made vararg for symmetry although it doesn't strictly need to be.
21355 */
21356
21357 nargs = duk_get_top(ctx);
21358 duk_set_top(ctx, 2);
21359
21360 /* XXX: must be able to represent -len */
21362 if (len == 0) {
21363 goto not_found;
21364 }
21365
21366 /* Index clamping is a bit tricky, we must ensure that we'll only iterate
21367 * through elements that exist and that the specific requirements from E5.1
21368 * Sections 15.4.4.14 and 15.4.4.15 are fulfilled; especially:
21369 *
21370 * - indexOf: clamp to [-len,len], negative handling -> [0,len],
21371 * if clamped result is len, for-loop bails out immediately
21372 *
21373 * - lastIndexOf: clamp to [-len-1, len-1], negative handling -> [-1, len-1],
21374 * if clamped result is -1, for-loop bails out immediately
21375 *
21376 * If fromIndex is not given, ToInteger(undefined) = 0, which is correct
21377 * for indexOf() but incorrect for lastIndexOf(). Hence special handling,
21378 * and why lastIndexOf() needs to be a vararg function.
21379 */
21380
21381 if (nargs >= 2) {
21382 /* indexOf: clamp fromIndex to [-len, len]
21383 * (if fromIndex == len, for-loop terminates directly)
21384 *
21385 * lastIndexOf: clamp fromIndex to [-len - 1, len - 1]
21386 * (if clamped to -len-1 -> fromIndex becomes -1, terminates for-loop directly)
21387 */
21388 from_index = duk_to_int_clamped(ctx,
21389 1,
21390 (idx_step > 0 ? -len : -len - 1),
21391 (idx_step > 0 ? len : len - 1));
21392 if (from_index < 0) {
21393 /* for lastIndexOf, result may be -1 (mark immediate termination) */
21394 from_index = len + from_index;
21395 }
21396 } else {
21397 /* for indexOf, ToInteger(undefined) would be 0, i.e. correct, but
21398 * handle both indexOf and lastIndexOf specially here.
21399 */
21400 if (idx_step > 0) {
21401 from_index = 0;
21402 } else {
21403 from_index = len - 1;
21404 }
21405 }
21406
21407 /* stack[0] = searchElement
21408 * stack[1] = fromIndex
21409 * stack[2] = object
21410 * stack[3] = length (not needed, but not popped above)
21411 */
21412
21413 for (i = from_index; i >= 0 && i < len; i += idx_step) {
DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped(duk_context *ctx, duk_idx_t index, duk_int_t minval, duk_int_t maxval)
DUK_EXTERNAL duk_int_t duk_get_current_magic(duk_context *ctx)
DUK_LOCAL duk_uint32_t duk__push_this_obj_len_u32_limited(duk_context *ctx)

◆ duk_bi_array_prototype_iter_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_iter_shared ( duk_context * ctx)

Definition at line 21430 of file duktape-1.8.0/src/duktape.c.

21447 {
21448 duk_uint32_t len;
21449 duk_uint32_t i;
21450 duk_uarridx_t k;
21451 duk_bool_t bval;
21452 duk_small_int_t iter_type = duk_get_current_magic(ctx);
21453 duk_uint32_t res_length = 0;
21454
21455 /* each call this helper serves has nargs==2 */
21456 DUK_ASSERT_TOP(ctx, 2);
21457
21458 len = duk__push_this_obj_len_u32(ctx);
21459 duk_require_callable(ctx, 0);
21460 /* if thisArg not supplied, behave as if undefined was supplied */
21461
21462 if (iter_type == DUK__ITER_MAP || iter_type == DUK__ITER_FILTER) {
21463 duk_push_array(ctx);
21464 } else {
21465 duk_push_undefined(ctx);
21466 }
21467
21468 /* stack[0] = callback
21469 * stack[1] = thisArg
21470 * stack[2] = object
21471 * stack[3] = ToUint32(length) (unused, but avoid unnecessary pop)
21472 * stack[4] = result array (or undefined)
21473 */
21474
21475 k = 0; /* result index for filter() */
21476 for (i = 0; i < len; i++) {
21477 DUK_ASSERT_TOP(ctx, 5);
21478
21479 if (!duk_get_prop_index(ctx, 2, (duk_uarridx_t) i)) {
21480#if defined(DUK_USE_NONSTD_ARRAY_MAP_TRAILER)
21481 /* Real world behavior for map(): trailing non-existent
21482 * elements don't invoke the user callback, but are still
21483 * counted towards result 'length'.
21484 */
21485 if (iter_type == DUK__ITER_MAP) {
21486 res_length = i + 1;
21487 }
21488#else
21489 /* Standard behavior for map(): trailing non-existent
21490 * elements don't invoke the user callback and are not
21491 * counted towards result 'length'.
21492 */
21493#endif
21494 duk_pop(ctx);
21495 continue;
21496 }
21497
21498 /* The original value needs to be preserved for filter(), hence
21499 * this funny order. We can't re-get the value because of side
21500 * effects.
21501 */
21502
21503 duk_dup(ctx, 0);
21504 duk_dup(ctx, 1);
21505 duk_dup(ctx, -3);
21506 duk_push_u32(ctx, i);
21507 duk_dup(ctx, 2); /* [ ... val callback thisArg val i obj ] */
21508 duk_call_method(ctx, 3); /* -> [ ... val retval ] */
21509
21510 switch (iter_type) {
21511 case DUK__ITER_EVERY:
21512 bval = duk_to_boolean(ctx, -1);
21513 if (!bval) {
21514 /* stack top contains 'false' */
21515 return 1;
21516 }
21517 break;
21518 case DUK__ITER_SOME:
21519 bval = duk_to_boolean(ctx, -1);
21520 if (bval) {
21521 /* stack top contains 'true' */
21522 return 1;
21523 }
21524 break;
21525 case DUK__ITER_FOREACH:
21526 /* nop */
21527 break;
21528 case DUK__ITER_MAP:
21529 duk_dup(ctx, -1);
21530 duk_xdef_prop_index_wec(ctx, 4, (duk_uarridx_t) i); /* retval to result[i] */
21531 res_length = i + 1;
21532 break;
21533 case DUK__ITER_FILTER:
21534 bval = duk_to_boolean(ctx, -1);
21535 if (bval) {
21536 duk_dup(ctx, -2); /* orig value */
21538 k++;
21539 res_length = k;
21540 }
21541 break;
21542 default:
21544 break;
21545 }
21546 duk_pop_2(ctx);
21547
21548 DUK_ASSERT_TOP(ctx, 5);
21549 }
21550
21551 switch (iter_type) {
21552 case DUK__ITER_EVERY:
21553 duk_push_true(ctx);
21554 break;
21555 case DUK__ITER_SOME:
21556 duk_push_false(ctx);
21557 break;
#define duk_require_callable(ctx, index)
#define DUK__ITER_SOME
#define DUK__ITER_MAP
#define DUK__ITER_FOREACH
#define DUK__ITER_EVERY
#define DUK__ITER_FILTER

◆ duk_bi_array_prototype_join_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_join_shared ( duk_context * ctx)

Definition at line 20479 of file duktape-1.8.0/src/duktape.c.

20496 {
20497 duk_uint32_t len, count;
20498 duk_uint32_t idx;
20499 duk_small_int_t to_locale_string = duk_get_current_magic(ctx);
20500 duk_idx_t valstack_required;
20501
20502 /* For join(), nargs is 1. For toLocaleString(), nargs is 0 and
20503 * setting the top essentially pushes an undefined to the stack,
20504 * thus defaulting to a comma separator.
20505 */
20506 duk_set_top(ctx, 1);
20507 if (duk_is_undefined(ctx, 0)) {
20508 duk_pop(ctx);
20510 } else {
20511 duk_to_string(ctx, 0);
20512 }
20513
20514 len = duk__push_this_obj_len_u32(ctx);
20515
20516 /* [ sep ToObject(this) len ] */
20517
20518 DUK_DDD(DUK_DDDPRINT("sep=%!T, this=%!T, len=%lu",
20519 (duk_tval *) duk_get_tval(ctx, 0),
20520 (duk_tval *) duk_get_tval(ctx, 1),
20521 (unsigned long) len));
20522
20523 /* The extra (+4) is tight. */
20524 valstack_required = (len >= DUK__ARRAY_MID_JOIN_LIMIT ?
20525 DUK__ARRAY_MID_JOIN_LIMIT : len) + 4;
20526 duk_require_stack(ctx, valstack_required);
20527
20528 duk_dup(ctx, 0);
20529
20530 /* [ sep ToObject(this) len sep ] */
20531
20532 count = 0;
20533 idx = 0;
20534 for (;;) {
20535 if (count >= DUK__ARRAY_MID_JOIN_LIMIT || /* intermediate join to avoid valstack overflow */
20536 idx >= len) { /* end of loop (careful with len==0) */
20537 /* [ sep ToObject(this) len sep str0 ... str(count-1) ] */
20538 DUK_DDD(DUK_DDDPRINT("mid/final join, count=%ld, idx=%ld, len=%ld",
20539 (long) count, (long) idx, (long) len));
20540 duk_join(ctx, (duk_idx_t) count); /* -> [ sep ToObject(this) len str ] */
20541 duk_dup(ctx, 0); /* -> [ sep ToObject(this) len str sep ] */
20542 duk_insert(ctx, -2); /* -> [ sep ToObject(this) len sep str ] */
20543 count = 1;
20544 }
20545 if (idx >= len) {
20546 /* if true, the stack already contains the final result */
20547 break;
20548 }
20549
20550 duk_get_prop_index(ctx, 1, (duk_uarridx_t) idx);
20551 if (duk_is_null_or_undefined(ctx, -1)) {
20552 duk_pop(ctx);
20554 } else {
20555 if (to_locale_string) {
20556 duk_to_object(ctx, -1);
#define DUK_STRIDX_COMMA
#define DUK__ARRAY_MID_JOIN_LIMIT
DUK_EXTERNAL void duk_join(duk_context *ctx, duk_idx_t count)

◆ duk_bi_array_prototype_pop()

DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_pop ( duk_context * ctx)

Definition at line 20562 of file duktape-1.8.0/src/duktape.c.

20579 {
20580 duk_uint32_t len;

◆ duk_bi_array_prototype_push()

DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_push ( duk_context * ctx)

Definition at line 20582 of file duktape-1.8.0/src/duktape.c.

20585 {
20586 duk_push_int(ctx, 0);
20588 return 0;
20589 }
20590 idx = len - 1;
20591
20592 duk_get_prop_index(ctx, 0, (duk_uarridx_t) idx);
20593 duk_del_prop_index(ctx, 0, (duk_uarridx_t) idx);
20594 duk_push_u32(ctx, idx);
20596 return 1;
20597}
20598
20600 /* Note: 'this' is not necessarily an Array object. The push()
20601 * algorithm is supposed to work for other kinds of objects too,
20602 * so the algorithm has e.g. an explicit update for the 'length'
20603 * property which is normally "magical" in arrays.
20604 */
20605
20606 duk_uint32_t len;
20607 duk_idx_t i, n;
20608
20609 n = duk_get_top(ctx);
20610 len = duk__push_this_obj_len_u32(ctx);
20611
20612 /* [ arg1 ... argN obj length ] */
20613
20614 /* Technically Array.prototype.push() can create an Array with length
20615 * longer than 2^32-1, i.e. outside the 32-bit range. The final length
20616 * is *not* wrapped to 32 bits in the specification.
20617 *
20618 * This implementation tracks length with a uint32 because it's much
20619 * more practical.
20620 *
20621 * See: test-bi-array-push-maxlen.js.
20622 */
20623
20624 if (len + (duk_uint32_t) n < len) {
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_push(duk_context *ctx)

◆ duk_bi_array_prototype_reduce_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_reduce_shared ( duk_context * ctx)

Definition at line 21563 of file duktape-1.8.0/src/duktape.c.

21568 :
21570 break;
21571 }
21572
21573 return 1;
21574}
21575
21576/*
21577 * reduce(), reduceRight()
21578 */
21579
21581 duk_idx_t nargs;
21582 duk_bool_t have_acc;
21583 duk_uint32_t i, len;
21584 duk_small_int_t idx_step = duk_get_current_magic(ctx); /* idx_step is +1 for reduce, -1 for reduceRight */
21585
21586 /* We're a varargs function because we need to detect whether
21587 * initialValue was given or not.
21588 */
21589 nargs = duk_get_top(ctx);
21590 DUK_DDD(DUK_DDDPRINT("nargs=%ld", (long) nargs));
21591
21592 duk_set_top(ctx, 2);
21593 len = duk__push_this_obj_len_u32(ctx);
21594 if (!duk_is_callable(ctx, 0)) {
21595 goto type_error;
21596 }
21597
21598 /* stack[0] = callback fn
21599 * stack[1] = initialValue
21600 * stack[2] = object (coerced this)
21601 * stack[3] = length (not needed, but not popped above)
21602 * stack[4] = accumulator
21603 */
21604
21605 have_acc = 0;
21606 if (nargs >= 2) {
21607 duk_dup(ctx, 1);
21608 have_acc = 1;
21609 }
21610 DUK_DDD(DUK_DDDPRINT("have_acc=%ld, acc=%!T",
21611 (long) have_acc, (duk_tval *) duk_get_tval(ctx, 3)));
21612
21613 /* For len == 0, i is initialized to len - 1 which underflows.
21614 * The condition (i < len) will then exit the for-loop on the
21615 * first round which is correct. Similarly, loop termination
21616 * happens by i underflowing.
21617 */
21618
21619 for (i = (idx_step >= 0 ? 0 : len - 1);
21620 i < len; /* i >= 0 would always be true */
21621 i += idx_step) {
21622 DUK_DDD(DUK_DDDPRINT("i=%ld, len=%ld, have_acc=%ld, top=%ld, acc=%!T",
21623 (long) i, (long) len, (long) have_acc,
21624 (long) duk_get_top(ctx),
21625 (duk_tval *) duk_get_tval(ctx, 4)));
21626
21627 DUK_ASSERT((have_acc && duk_get_top(ctx) == 5) ||
21628 (!have_acc && duk_get_top(ctx) == 4));
21629
21630 if (!duk_has_prop_index(ctx, 2, (duk_uarridx_t) i)) {
21631 continue;
21632 }
21633
21634 if (!have_acc) {
21635 DUK_ASSERT_TOP(ctx, 4);
21636 duk_get_prop_index(ctx, 2, (duk_uarridx_t) i);
21637 have_acc = 1;
21638 DUK_ASSERT_TOP(ctx, 5);
21639 } else {
21640 DUK_ASSERT_TOP(ctx, 5);
21641 duk_dup(ctx, 0);
21642 duk_dup(ctx, 4);
21643 duk_get_prop_index(ctx, 2, (duk_uarridx_t) i);
21644 duk_push_u32(ctx, i);
21645 duk_dup(ctx, 2);
21646 DUK_DDD(DUK_DDDPRINT("calling reduce function: func=%!T, prev=%!T, curr=%!T, idx=%!T, obj=%!T",
21647 (duk_tval *) duk_get_tval(ctx, -5), (duk_tval *) duk_get_tval(ctx, -4),
21648 (duk_tval *) duk_get_tval(ctx, -3), (duk_tval *) duk_get_tval(ctx, -2),
21649 (duk_tval *) duk_get_tval(ctx, -1)));
DUK_EXTERNAL duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_index, duk_uarridx_t arr_index)
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_reduce_shared(duk_context *ctx)

◆ duk_bi_array_prototype_reverse()

DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_reverse ( duk_context * ctx)

Definition at line 21112 of file duktape-1.8.0/src/duktape.c.

21129 {
21130 duk_uint32_t len;
21131 duk_uint32_t middle;
21132 duk_uint32_t lower, upper;
21133 duk_bool_t have_lower, have_upper;
21134
21135 len = duk__push_this_obj_len_u32(ctx);
21136 middle = len / 2;
21137
21138 /* If len <= 1, middle will be 0 and for-loop bails out
21139 * immediately (0 < 0 -> false).
21140 */
21141
21142 for (lower = 0; lower < middle; lower++) {
21143 DUK_ASSERT(len >= 2);
21144 DUK_ASSERT_TOP(ctx, 2);
21145
21146 DUK_ASSERT(len >= lower + 1);
21147 upper = len - lower - 1;
21148
21149 have_lower = duk_get_prop_index(ctx, -2, (duk_uarridx_t) lower);
21150 have_upper = duk_get_prop_index(ctx, -3, (duk_uarridx_t) upper);
21151
21152 /* [ ToObject(this) ToUint32(length) lowerValue upperValue ] */
21153
21154 if (have_upper) {
21155 duk_put_prop_index(ctx, -4, (duk_uarridx_t) lower);
21156 } else {
21157 duk_del_prop_index(ctx, -4, (duk_uarridx_t) lower);

◆ duk_bi_array_prototype_shift()

DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_shift ( duk_context * ctx)

Definition at line 21225 of file duktape-1.8.0/src/duktape.c.

21242 {
21243 duk_uint32_t len;
21244 duk_uint32_t i;
21245
21246 len = duk__push_this_obj_len_u32(ctx);
21247 if (len == 0) {
21248 duk_push_int(ctx, 0);
21250 return 0;
21251 }
21252
21253 duk_get_prop_index(ctx, 0, 0);
21254
21255 /* stack[0] = object (this)
21256 * stack[1] = ToUint32(length)
21257 * stack[2] = elem at index 0 (retval)
21258 */
21259
21260 for (i = 1; i < len; i++) {
21261 DUK_ASSERT_TOP(ctx, 3);

◆ duk_bi_array_prototype_slice()

DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_slice ( duk_context * ctx)

Definition at line 21163 of file duktape-1.8.0/src/duktape.c.

21163 {
21164 duk_del_prop_index(ctx, -3, (duk_uarridx_t) upper);
21165 duk_pop(ctx);
21166 }
21167
21168 DUK_ASSERT_TOP(ctx, 2);
21169 }
21170
21171 DUK_ASSERT_TOP(ctx, 2);
21172 duk_pop(ctx); /* -> [ ToObject(this) ] */
21173 return 1;
21174}
21175
21176/*
21177 * slice()
21178 */
21179
21181 duk_uint32_t len;
21182 duk_int_t start, end;
21183 duk_int_t i;
21184 duk_uarridx_t idx;
21185 duk_uint32_t res_length = 0;
21186
21187 /* XXX: len >= 0x80000000 won't work below because we need to be
21188 * able to represent -len.
21189 */
21191 duk_push_array(ctx);
21192
21193 /* stack[0] = start
21194 * stack[1] = end
21195 * stack[2] = ToObject(this)
21196 * stack[3] = ToUint32(length)
21197 * stack[4] = result array
21198 */
21199
21200 start = duk_to_int_clamped(ctx, 0, -((duk_int_t) len), (duk_int_t) len);
21201 if (start < 0) {
21202 start = len + start;
21203 }
21204 /* XXX: could duk_is_undefined() provide defaulting undefined to 'len'
21205 * (the upper limit)?
21206 */
21207 if (duk_is_undefined(ctx, 1)) {
21208 end = len;
21209 } else {
21210 end = duk_to_int_clamped(ctx, 1, -((duk_int_t) len), (duk_int_t) len);
21211 if (end < 0) {
21212 end = len + end;
21213 }
21214 }
21215 DUK_ASSERT(start >= 0 && (duk_uint32_t) start <= len);
21216 DUK_ASSERT(end >= 0 && (duk_uint32_t) end <= len);
21217
21218 idx = 0;
21219 for (i = start; i < end; i++) {
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_slice(duk_context *ctx)

◆ duk_bi_array_prototype_sort()

DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_sort ( duk_context * ctx)

Definition at line 20912 of file duktape-1.8.0/src/duktape.c.

20917 : %!T", (duk_tval *) duk_get_tval(ctx, 1)));
20918 duk__array_sort_swap(ctx, lo, r);
20919
20920#if defined(DUK_USE_DDDPRINT)
20921 duk__debuglog_qsort_state(ctx, lo, hi, r);
20922#endif
20923
20924 DUK_DDD(DUK_DDDPRINT("recurse: pivot=%ld, obj=%!T", (long) r, (duk_tval *) duk_get_tval(ctx, 1)));
20925 duk__array_qsort(ctx, lo, r - 1);
20926 duk__array_qsort(ctx, r + 1, hi);
20927}
20928
20929DUK_INTERNAL duk_ret_t duk_bi_array_prototype_sort(duk_context *ctx) {
20930 duk_uint32_t len;
20931
20932 /* XXX: len >= 0x80000000 won't work below because a signed type
20933 * is needed by qsort.

◆ duk_bi_array_prototype_splice()

DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_splice ( duk_context * ctx)

Definition at line 20948 of file duktape-1.8.0/src/duktape.c.

20965 {
20966 duk_idx_t nargs;
20967 duk_uint32_t len;
20968 duk_bool_t have_delcount;
20969 duk_int_t item_count;
20970 duk_int_t act_start;
20971 duk_int_t del_count;
20972 duk_int_t i, n;
20973
20974 DUK_UNREF(have_delcount);
20975
20976 nargs = duk_get_top(ctx);
20977 if (nargs < 2) {
20978 duk_set_top(ctx, 2);
20979 nargs = 2;
20980 have_delcount = 0;
20981 } else {
20982 have_delcount = 1;
20983 }
20984
20985 /* XXX: len >= 0x80000000 won't work below because we need to be
20986 * able to represent -len.
20987 */
20989
20990 act_start = duk_to_int_clamped(ctx, 0, -((duk_int_t) len), (duk_int_t) len);
20991 if (act_start < 0) {
20992 act_start = len + act_start;
20993 }
20994 DUK_ASSERT(act_start >= 0 && act_start <= (duk_int_t) len);
20995
20996#ifdef DUK_USE_NONSTD_ARRAY_SPLICE_DELCOUNT
20997 if (have_delcount) {
20998#endif
20999 del_count = duk_to_int_clamped(ctx, 1, 0, len - act_start);
21000#ifdef DUK_USE_NONSTD_ARRAY_SPLICE_DELCOUNT
21001 } else {
21002 /* E5.1 standard behavior when deleteCount is not given would be
21003 * to treat it just like if 'undefined' was given, which coerces
21004 * ultimately to 0. Real world behavior is to splice to the end
21005 * of array, see test-bi-array-proto-splice-no-delcount.js.
21006 */
21007 del_count = len - act_start;
21008 }
21009#endif
21010
21011 DUK_ASSERT(nargs >= 2);
21012 item_count = (duk_int_t) (nargs - 2);
21013
21014 DUK_ASSERT(del_count >= 0 && del_count <= (duk_int_t) len - act_start);
21015 DUK_ASSERT(del_count + act_start <= (duk_int_t) len);
21016
21017 /* For now, restrict result array into 32-bit length range. */
21018 if (((duk_double_t) len) - ((duk_double_t) del_count) + ((duk_double_t) item_count) > (duk_double_t) DUK_UINT32_MAX) {
21019 DUK_D(DUK_DPRINT("Array.prototype.splice() would go beyond 32-bit length, throw"));
21020 return DUK_RET_RANGE_ERROR;
21021 }
21022
21023 duk_push_array(ctx);
21024
21025 /* stack[0] = start
21026 * stack[1] = deleteCount
21027 * stack[2...nargs-1] = items
21028 * stack[nargs] = ToObject(this) -3
21029 * stack[nargs+1] = ToUint32(length) -2
21030 * stack[nargs+2] = result array -1
21031 */
21032
21033 DUK_ASSERT_TOP(ctx, nargs + 3);
21034
21035 /* Step 9: copy elements-to-be-deleted into the result array */
21036
21037 for (i = 0; i < del_count; i++) {
21038 if (duk_get_prop_index(ctx, -3, (duk_uarridx_t) (act_start + i))) {
21039 duk_xdef_prop_index_wec(ctx, -2, i); /* throw flag irrelevant (false in std alg) */
21040 } else {
21041 duk_pop(ctx);
21042 }
21043 }
21044 duk_push_u32(ctx, (duk_uint32_t) del_count);
21046
21047 /* Steps 12 and 13: reorganize elements to make room for itemCount elements */
21048
21049 if (item_count < del_count) {
21050 /* [ A B C D E F G H ] rel_index = 2, del_count 3, item count 1
21051 * -> [ A B F G H ] (conceptual intermediate step)
21052 * -> [ A B . F G H ] (placeholder marked)
21053 * [ A B C F G H ] (actual result at this point, C will be replaced)
21054 */
21055
21056 DUK_ASSERT_TOP(ctx, nargs + 3);
21057
21058 n = len - del_count;
21059 for (i = act_start; i < n; i++) {
21060 if (duk_get_prop_index(ctx, -3, (duk_uarridx_t) (i + del_count))) {
21061 duk_put_prop_index(ctx, -4, (duk_uarridx_t) (i + item_count));
21062 } else {
21063 duk_pop(ctx);
21064 duk_del_prop_index(ctx, -3, (duk_uarridx_t) (i + item_count));
21065 }
21066 }
21067
21068 DUK_ASSERT_TOP(ctx, nargs + 3);
21069
21070 /* loop iterator init and limit changed from standard algorithm */
21071 n = len - del_count + item_count;
21072 for (i = len - 1; i >= n; i--) {
21073 duk_del_prop_index(ctx, -3, (duk_uarridx_t) i);
21074 }
21075
21076 DUK_ASSERT_TOP(ctx, nargs + 3);
21077 } else if (item_count > del_count) {
21078 /* [ A B C D E F G H ] rel_index = 2, del_count 3, item count 4
21079 * -> [ A B F G H ] (conceptual intermediate step)
21080 * -> [ A B . . . . F G H ] (placeholder marked)
21081 * [ A B C D E F F G H ] (actual result at this point)
21082 */
21083
21084 DUK_ASSERT_TOP(ctx, nargs + 3);
21085
21086 /* loop iterator init and limit changed from standard algorithm */
21087 for (i = len - del_count - 1; i >= act_start; i--) {
21088 if (duk_get_prop_index(ctx, -3, (duk_uarridx_t) (i + del_count))) {
21089 duk_put_prop_index(ctx, -4, (duk_uarridx_t) (i + item_count));
21090 } else {
21091 duk_pop(ctx);
21092 duk_del_prop_index(ctx, -3, (duk_uarridx_t) (i + item_count));
21093 }
21094 }
21095
21096 DUK_ASSERT_TOP(ctx, nargs + 3);
21097 } else {
21098 /* [ A B C D E F G H ] rel_index = 2, del_count 3, item count 3
21099 * -> [ A B F G H ] (conceptual intermediate step)
21100 * -> [ A B . . . F G H ] (placeholder marked)
21101 * [ A B C D E F G H ] (actual result at this point)
21102 */
21103 }
21104 DUK_ASSERT_TOP(ctx, nargs + 3);
21105
21106 /* Step 15: insert itemCount elements into the hole made above */

◆ duk_bi_array_prototype_to_string()

DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_to_string ( duk_context * ctx)

Definition at line 20348 of file duktape-1.8.0/src/duktape.c.

20353 {
20354 duk_hobject *h;
20355
20357 duk_push_boolean(ctx, (h != NULL));
20358 return 1;
20359}
20360
20361/*
20362 * toString()
20363 */
20364
20368
20369 /* [ ... this func ] */
20370 if (!duk_is_callable(ctx, -1)) {
20371 /* Fall back to the initial (original) Object.toString(). We don't
20372 * currently have pointers to the built-in functions, only the top
20373 * level global objects (like "Array") so this is now done in a bit
20374 * of a hacky manner. It would be cleaner to push the (original)
20375 * function and use duk_call_method().
20376 */
20377
20378 /* XXX: 'this' will be ToObject() coerced twice, which is incorrect
20379 * but should have no visible side effects.
20380 */
20381 DUK_DDD(DUK_DDDPRINT("this.join is not callable, fall back to (original) Object.toString"));
DUK_INTERNAL_DECL duk_hobject * duk_get_hobject_with_class(duk_context *ctx, duk_idx_t index, duk_small_uint_t classnum)
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_to_string(duk_context *ctx)
#define DUK_STRIDX_JOIN

References duk_get_hobject_with_class(), DUK_HOBJECT_CLASS_ARRAY, duk_push_boolean(), and NULL.

◆ duk_bi_array_prototype_unshift()

DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_unshift ( duk_context * ctx)

Definition at line 21267 of file duktape-1.8.0/src/duktape.c.

21284 {
21285 duk_idx_t nargs;
21286 duk_uint32_t len;
21287 duk_uint32_t i;
21288
21289 nargs = duk_get_top(ctx);
21290 len = duk__push_this_obj_len_u32(ctx);
21291
21292 /* stack[0...nargs-1] = unshift args (vararg)
21293 * stack[nargs] = ToObject(this)
21294 * stack[nargs+1] = ToUint32(length)
21295 */
21296
21297 DUK_ASSERT_TOP(ctx, nargs + 2);
21298
21299 /* Note: unshift() may operate on indices above unsigned 32-bit range
21300 * and the final length may be >= 2**32. However, we restrict the
21301 * final result to 32-bit range for practicality.
21302 */
21303
21304 if (len + (duk_uint32_t) nargs < len) {
21305 DUK_D(DUK_DPRINT("Array.prototype.unshift() would go beyond 32-bit length, throw"));
21306 return DUK_RET_RANGE_ERROR;
21307 }
21308
21309 i = len;
21310 while (i > 0) {
21311 DUK_ASSERT_TOP(ctx, nargs + 2);
21312 i--;
21313 /* k+argCount-1; note that may be above 32-bit range */
21314
21315 if (duk_get_prop_index(ctx, -2, (duk_uarridx_t) i)) {
21316 /* fromPresent = true */
21317 /* [ ... ToObject(this) ToUint32(length) val ] */
21318 duk_put_prop_index(ctx, -3, (duk_uarridx_t) (i + nargs)); /* -> [ ... ToObject(this) ToUint32(length) ] */
21319 } else {
21320 /* fromPresent = false */
21321 /* [ ... ToObject(this) ToUint32(length) val ] */
21322 duk_pop(ctx);
21323 duk_del_prop_index(ctx, -2, (duk_uarridx_t) (i + nargs)); /* -> [ ... ToObject(this) ToUint32(length) ] */

◆ duk_bi_arraybuffer_constructor()

DUK_INTERNAL_DECL duk_ret_t duk_bi_arraybuffer_constructor ( duk_context * ctx)

Definition at line 22399 of file duktape-1.8.0/src/duktape.c.

22405 {
22406 DUK_UNREF(ctx);
22408}
22409#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
22410
22411/*
22412 * ArrayBuffer, DataView, and TypedArray constructors
22413 */
22414
22415#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
22417 duk_hthread *thr;
22418 duk_hbufferobject *h_bufobj;
22419 duk_hbuffer *h_val;
22420
22422 thr = (duk_hthread *) ctx;
22423 DUK_UNREF(thr);
22424
22425 /* XXX: function flag to make this automatic? */
22426 if (!duk_is_constructor_call(ctx)) {
22427 return DUK_RET_TYPE_ERROR;
22428 }
22429
22430 if (duk_is_buffer(ctx, 0)) {
22431 /* Custom behavior: plain buffer is used as internal buffer
22432 * without making a copy (matches Duktape.Buffer).
22433 */
22434
22435 h_val = duk_get_hbuffer(ctx, 0);
22436 DUK_ASSERT(h_val != NULL);
22437
22438 /* XXX: accept any duk_hbufferobject type as an input also? */
22439 } else {
22440 duk_int_t len;
22441 len = duk_to_int(ctx, 0);
22442 if (len < 0) {
22443 goto fail_length;
22444 }
22445 (void) duk_push_fixed_buffer(ctx, (duk_size_t) len);
22446 h_val = (duk_hbuffer *) duk_get_hbuffer(ctx, -1);
22447 DUK_ASSERT(h_val != NULL);
22448
22449#if !defined(DUK_USE_ZERO_BUFFER_DATA)
22450 /* Khronos/ES6 requires zeroing even when DUK_USE_ZERO_BUFFER_DATA
22451 * is not set.
22452 */
22454 DUK_MEMZERO((void *) DUK_HBUFFER_FIXED_GET_DATA_PTR(thr->heap, h_val), (duk_size_t) len);
22455#endif
DUK_INTERNAL_DECL duk_ret_t duk_bi_arraybuffer_constructor(duk_context *ctx)
DUK_EXTERNAL duk_bool_t duk_is_constructor_call(duk_context *ctx)

◆ duk_bi_arraybuffer_isview()

DUK_INTERNAL_DECL duk_ret_t duk_bi_arraybuffer_isview ( duk_context * ctx)

Definition at line 22898 of file duktape-1.8.0/src/duktape.c.

22904 {
22905 DUK_UNREF(ctx);
22907}
22908#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */

◆ duk_bi_boolean_constructor()

DUK_INTERNAL_DECL duk_ret_t duk_bi_boolean_constructor ( duk_context * ctx)

Definition at line 21704 of file duktape-1.8.0/src/duktape.c.

21705 {
21707 DUK_ASSERT(duk_is_boolean(ctx, -1));
21708 goto type_ok;
21709 }
21710 }
21711
21712 return DUK_RET_TYPE_ERROR;
21713
21714 type_ok:
21715 if (coerce_tostring) {
21716 duk_to_string(ctx, -1);
21717 }
21718 return 1;
21719}
21720
21722 duk_hthread *thr = (duk_hthread *) ctx;
21723 duk_hobject *h_this;
21724
21725 DUK_UNREF(thr);
21726
DUK_EXTERNAL duk_bool_t duk_is_boolean(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL duk_ret_t duk_bi_boolean_constructor(duk_context *ctx)

References DUK_ASSERT, duk_get_prop_stridx(), duk_is_boolean(), and DUK_STRIDX_INT_VALUE.

◆ duk_bi_boolean_prototype_tostring_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_boolean_prototype_tostring_shared ( duk_context * ctx)

Definition at line 21668 of file duktape-1.8.0/src/duktape.c.

21685 {
21686 duk_tval *tv;
21687 duk_hobject *h;
21688 duk_small_int_t coerce_tostring = duk_get_current_magic(ctx);
21689
21690 /* XXX: there is room to use a shared helper here, many built-ins
21691 * check the 'this' type, and if it's an object, check its class,
21692 * then get its internal value, etc.
21693 */
21694
21695 duk_push_this(ctx);
21696 tv = duk_get_tval(ctx, -1);
21697 DUK_ASSERT(tv != NULL);
21698
21699 if (DUK_TVAL_IS_BOOLEAN(tv)) {
21700 goto type_ok;
21701 } else if (DUK_TVAL_IS_OBJECT(tv)) {
21702 h = DUK_TVAL_GET_OBJECT(tv);

References DUK_ASSERT, duk_get_current_magic(), duk_get_tval(), duk_push_this(), DUK_TVAL_GET_OBJECT, DUK_TVAL_IS_BOOLEAN, DUK_TVAL_IS_OBJECT, and NULL.

◆ duk_bi_buffer_compare_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_compare_shared ( duk_context * ctx)

Definition at line 23090 of file duktape-1.8.0/src/duktape.c.

23094 {
23095 DUK_UNREF(ctx);
23097}
23098#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
23099
23100/*
23101 * Node.js Buffer.prototype.equals()
23102 * Node.js Buffer.prototype.compare()
23103 * Node.js Buffer.compare()
23104 */
23105
23106#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
23108 duk_hthread *thr;
23109 duk_small_uint_t magic;
23110 duk_hbufferobject *h_bufarg1;
23111 duk_hbufferobject *h_bufarg2;
23112 duk_small_int_t comp_res;
23113
23114 thr = (duk_hthread *) ctx;
23115 DUK_UNREF(thr);
23116
23117 magic = duk_get_current_magic(ctx);
23118 if (magic & 0x02) {
23119 /* Static call style. */
23120 h_bufarg1 = duk__require_bufobj_value(ctx, 0);
23121 h_bufarg2 = duk__require_bufobj_value(ctx, 1);
23122 } else {
23123 h_bufarg1 = duk__require_bufobj_this(ctx);
23124 h_bufarg2 = duk__require_bufobj_value(ctx, 0);
23125 }
23126 DUK_ASSERT(h_bufarg1 != NULL);
23127 DUK_ASSERT(h_bufarg2 != NULL);
23128
23129 /* We want to compare the slice/view areas of the arguments.
23130 * If either slice/view is invalid (underlying buffer is shorter)
23131 * ensure equals() is false, but otherwise the only thing that
23132 * matters is to be memory safe.
23133 */
23134
23135 if (DUK_HBUFFEROBJECT_VALID_SLICE(h_bufarg1) &&
23136 DUK_HBUFFEROBJECT_VALID_SLICE(h_bufarg2)) {
23137 comp_res = duk_js_data_compare((const duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_bufarg1->buf) + h_bufarg1->offset,
DUK_INTERNAL_DECL duk_small_int_t duk_js_data_compare(const duk_uint8_t *buf1, const duk_uint8_t *buf2, duk_size_t len1, duk_size_t len2)
DUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_compare_shared(duk_context *ctx)

◆ duk_bi_buffer_constructor()

DUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_constructor ( duk_context * ctx)

Definition at line 22215 of file duktape-1.8.0/src/duktape.c.

22217 :
22218 du.d = (duk_double_t) duk_to_number(ctx, -1);
22219 break;
22220#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
22221 default:
22223 }
22224
22225 DUK_MEMCPY((void *) p, (const void *) du.uc, (size_t) elem_size);
22226}
22227
22228/*
22229 * Duktape.Buffer: constructor
22230 */
22231
22233 duk_hthread *thr;
22234 duk_size_t buf_size;
22235 duk_small_int_t buf_dynamic;
22236 duk_uint8_t *buf_data;
22237 const duk_uint8_t *src_data;
22238
22239 thr = (duk_hthread *) ctx;
22240 DUK_UNREF(thr);
22241
22242 /*
22243 * Constructor arguments are currently somewhat compatible with
22244 * (keep it that way if possible):
22245 *
22246 * http://nodejs.org/api/buffer.html
22247 *
22248 * Note that the ToBuffer() coercion (duk_to_buffer()) does NOT match
22249 * the constructor behavior.
22250 */
22251
22252 buf_dynamic = duk_get_boolean(ctx, 1); /* default to false */
22253
22254 switch (duk_get_type(ctx, 0)) {
22255 case DUK_TYPE_NUMBER: {
22256 /* new buffer of specified size */
22257 buf_size = (duk_size_t) duk_to_int(ctx, 0);
22258 (void) duk_push_buffer(ctx, buf_size, buf_dynamic);
22259 break;
22260 }
22261 case DUK_TYPE_BUFFER: {
22262 /* return input buffer, converted to a Duktape.Buffer object
22263 * if called as a constructor (no change if called as a
22264 * function).
22265 */
22266 duk_set_top(ctx, 1);
22267 break;
22268 }
22269 case DUK_TYPE_STRING: {
22270 /* new buffer with string contents */
22271 src_data = (const duk_uint8_t *) duk_get_lstring(ctx, 0, &buf_size);
22272 DUK_ASSERT(src_data != NULL); /* even for zero-length string */
22273 buf_data = (duk_uint8_t *) duk_push_buffer(ctx, buf_size, buf_dynamic);
22274 DUK_MEMCPY((void *) buf_data, (const void *) src_data, (size_t) buf_size);
22275 break;
22276 }
22277 case DUK_TYPE_OBJECT: {
22278 /* For all duk_hbufferobjects, get the plain buffer inside
22279 * without making a copy. This is compatible with Duktape 1.2
22280 * but means that a slice/view information is ignored and the
22281 * full underlying buffer is returned.
22282 *
22283 * If called as a constructor, a new Duktape.Buffer object
22284 * pointing to the same plain buffer is created below.
22285 */
22286 duk_hbufferobject *h_bufobj;
22287 h_bufobj = (duk_hbufferobject *) duk_get_hobject(ctx, 0);
22288 DUK_ASSERT(h_bufobj != NULL);
22289 if (!DUK_HOBJECT_IS_BUFFEROBJECT((duk_hobject *) h_bufobj)) {
22290 return DUK_RET_TYPE_ERROR;
22291 }
22292 if (h_bufobj->buf == NULL) {
22293 return DUK_RET_TYPE_ERROR;
22294 }
22295 duk_push_hbuffer(ctx, h_bufobj->buf);
22296 break;
22297 }
22298 case DUK_TYPE_NONE:
22299 default: {
22300 return DUK_RET_TYPE_ERROR;
22301 }
22302 }
22303 DUK_ASSERT(duk_is_buffer(ctx, -1));
22304
22305 /* stack is unbalanced, but: [ <something> buf ] */
22306
22307 if (duk_is_constructor_call(ctx)) {
22308 duk_hbufferobject *h_bufobj;
22309 duk_hbuffer *h_val;
22310
22311 h_val = duk_get_hbuffer(ctx, -1);
#define duk_push_buffer(ctx, size, dynamic)
DUK_EXTERNAL const char * duk_get_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
DUK_EXTERNAL duk_bool_t duk_get_boolean(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL void duk_push_hbuffer(duk_context *ctx, duk_hbuffer *h)
DUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_constructor(duk_context *ctx)

◆ duk_bi_buffer_prototype_tostring_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_prototype_tostring_shared ( duk_context * ctx)

Definition at line 22978 of file duktape-1.8.0/src/duktape.c.

22980 :
22981 return DUK_RET_TYPE_ERROR;
22982}
22983#else /* DUK_USE_BUFFEROBJECT_SUPPORT */
22985 DUK_UNREF(ctx);
22987}
22988#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
22989
22990/*
22991 * Duktape.Buffer: toString(), valueOf()
22992 */
22993
22994#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
22996 duk_hthread *thr;
22997 duk_tval *tv;
22998 duk_small_int_t to_string = duk_get_current_magic(ctx);
22999
23000 thr = (duk_hthread *) ctx;
23001 DUK_UNREF(thr);
23002
23004 DUK_ASSERT(tv != NULL);
23005
23006 if (DUK_TVAL_IS_BUFFER(tv)) {
23007 duk_hbuffer *h_buf;
23008 h_buf = DUK_TVAL_GET_BUFFER(tv);
23009 DUK_ASSERT(h_buf != NULL);
23010 duk_push_hbuffer(ctx, h_buf);
23011 } else if (DUK_TVAL_IS_OBJECT(tv)) {
23012 duk_hobject *h;
23013 duk_hbufferobject *h_bufobj;
23014
23015 /* Accept any duk_hbufferobject, though we're only normally
23016 * called for Duktape.Buffer values.
23017 */
23018 h = DUK_TVAL_GET_OBJECT(tv);
23019 DUK_ASSERT(h != NULL);
23021 DUK_DD(DUK_DDPRINT("toString/valueOf() called for a non-bufferobject object"));
23022 goto type_error;
23023 }
23024 h_bufobj = (duk_hbufferobject *) h;
23026
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_tostring(duk_context *ctx)
DUK_INTERNAL_DECL duk_tval * duk_get_borrowed_this_tval(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_prototype_tostring_shared(duk_context *ctx)

◆ duk_bi_buffer_readfield()

DUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_readfield ( duk_context * ctx)

Definition at line 24056 of file duktape-1.8.0/src/duktape.c.

24073 {
24074 duk_hthread *thr;
24076 duk_small_int_t magic_ftype;
24077 duk_small_int_t magic_bigendian;
24078 duk_small_int_t magic_signed;
24079 duk_small_int_t magic_typedarray;
24080 duk_small_int_t endswap;
24081 duk_hbufferobject *h_this;
24082 duk_bool_t no_assert;
24083 duk_int_t offset_signed;
24084 duk_uint_t offset;
24085 duk_uint_t buffer_length;
24086 duk_uint_t check_length;
24087 duk_uint8_t *buf;
24089
24090 thr = (duk_hthread *) ctx;
24091 DUK_UNREF(thr);
24092
24093 magic_ftype = magic & 0x0007;
24094 magic_bigendian = magic & 0x0008;
24095 magic_signed = magic & 0x0010;
24096 magic_typedarray = magic & 0x0020;
24097
24098 h_this = duk__require_bufobj_this(ctx);
24099 DUK_ASSERT(h_this != NULL);
24100 buffer_length = h_this->length;
24101
24102 /* [ offset noAssert ], when ftype != DUK__FLD_VARINT */
24103 /* [ offset fieldByteLength noAssert ], when ftype == DUK__FLD_VARINT */
24104 /* [ offset littleEndian ], when DUK__FLD_TYPEDARRAY (regardless of ftype) */
24105
24106 /* Handle TypedArray vs. Node.js Buffer arg differences */
24107 if (magic_typedarray) {
24108 no_assert = 0;
24109#if defined(DUK_USE_INTEGER_LE)
24110 endswap = !duk_to_boolean(ctx, 1); /* 1=little endian */
24111#else
24112 endswap = duk_to_boolean(ctx, 1); /* 1=little endian */
24113#endif
24114 } else {
24115 no_assert = duk_to_boolean(ctx, (magic_ftype == DUK__FLD_VARINT) ? 2 : 1);
24116#if defined(DUK_USE_INTEGER_LE)
24117 endswap = magic_bigendian;
24118#else
24119 endswap = !magic_bigendian;
24120#endif
24121 }
24122
24123 /* Offset is coerced first to signed integer range and then to unsigned.
24124 * This ensures we can add a small byte length (1-8) to the offset in
24125 * bound checks and not wrap.
24126 */
24127 offset_signed = duk_to_int(ctx, 0);
24128 offset = (duk_uint_t) offset_signed;
24129 if (offset_signed < 0) {
24130 goto fail_bounds;
24131 }
24132
24133 DUK_DDD(DUK_DDDPRINT("readfield, buffer_length=%ld, offset=%ld, no_assert=%d, "
24134 "magic=%04x, magic_fieldtype=%d, magic_bigendian=%d, magic_signed=%d, "
24135 "endswap=%d",
24136 (long) buffer_length, (long) offset, (int) no_assert,
24137 (unsigned int) magic, (int) magic_ftype, (int) (magic_bigendian >> 3),
24138 (int) (magic_signed >> 4), (int) endswap));
24139
24140 /* Update 'buffer_length' to be the effective, safe limit which
24141 * takes into account the underlying buffer. This value will be
24142 * potentially invalidated by any side effect.
24143 */
24144 check_length = DUK_HBUFFEROBJECT_CLAMP_BYTELENGTH(h_this, buffer_length);
24145 DUK_DDD(DUK_DDDPRINT("buffer_length=%ld, check_length=%ld",
24146 (long) buffer_length, (long) check_length));
24147
24148 if (h_this->buf) {
24149 buf = DUK_HBUFFEROBJECT_GET_SLICE_BASE(thr->heap, h_this);
24150 } else {
24151 /* Neutered. We could go into the switch-case safely with
24152 * buf == NULL because check_length == 0. To avoid scanbuild
24153 * warnings, fail directly instead.
24154 */
24155 DUK_ASSERT(check_length == 0);
24156 goto fail_neutered;
24157 }
24158 DUK_ASSERT(buf != NULL);
24159
24160 switch (magic_ftype) {
24161 case DUK__FLD_8BIT: {
24162 duk_uint8_t tmp;
24163 if (offset + 1U > check_length) {
24164 goto fail_bounds;
24165 }
24166 tmp = buf[offset];
24167 if (magic_signed) {
24168 duk_push_int(ctx, (duk_int_t) ((duk_int8_t) tmp));
24169 } else {
24170 duk_push_uint(ctx, (duk_uint_t) tmp);
24171 }
24172 break;
24173 }
24174 case DUK__FLD_16BIT: {
24175 duk_uint16_t tmp;
24176 if (offset + 2U > check_length) {
24177 goto fail_bounds;
24178 }
24179 DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 2);
24180 tmp = du.us[0];
24181 if (endswap) {
24182 tmp = DUK_BSWAP16(tmp);
24183 }
24184 if (magic_signed) {
24185 duk_push_int(ctx, (duk_int_t) ((duk_int16_t) tmp));
24186 } else {
24187 duk_push_uint(ctx, (duk_uint_t) tmp);
24188 }
24189 break;
24190 }
24191 case DUK__FLD_32BIT: {
24192 duk_uint32_t tmp;
24193 if (offset + 4U > check_length) {
24194 goto fail_bounds;
24195 }
24196 DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 4);
24197 tmp = du.ui[0];
24198 if (endswap) {
24199 tmp = DUK_BSWAP32(tmp);
24200 }
24201 if (magic_signed) {
24202 duk_push_int(ctx, (duk_int_t) ((duk_int32_t) tmp));
24203 } else {
24204 duk_push_uint(ctx, (duk_uint_t) tmp);
24205 }
24206 break;
24207 }
24208 case DUK__FLD_FLOAT: {
24209 duk_uint32_t tmp;
24210 if (offset + 4U > check_length) {
24211 goto fail_bounds;
24212 }
24213 DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 4);
24214 if (endswap) {
24215 tmp = du.ui[0];
24216 tmp = DUK_BSWAP32(tmp);
24217 du.ui[0] = tmp;
24218 }
24219 duk_push_number(ctx, (duk_double_t) du.f[0]);
24220 break;
24221 }
24222 case DUK__FLD_DOUBLE: {
24223 if (offset + 8U > check_length) {
24224 goto fail_bounds;
24225 }
24226 DUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 8);
24227 if (endswap) {
24229 }
24230 duk_push_number(ctx, (duk_double_t) du.d);
24231 break;
24232 }
24233 case DUK__FLD_VARINT: {
24234 /* Node.js Buffer variable width integer field. We don't really
24235 * care about speed here, so aim for shortest algorithm.
24236 */
24237 duk_int_t field_bytelen;
24238 duk_int_t i, i_step, i_end;
24239#if defined(DUK_USE_64BIT_OPS)
24240 duk_int64_t tmp;
24241 duk_small_uint_t shift_tmp;
24242#else
24243 duk_double_t tmp;
24244 duk_small_int_t highbyte;
24245#endif
24246 const duk_uint8_t *p;
24247
24248 field_bytelen = duk_get_int(ctx, 1); /* avoid side effects! */
24249 if (field_bytelen < 1 || field_bytelen > 6) {
24250 goto fail_field_length;
24251 }
24252 if (offset + (duk_uint_t) field_bytelen > check_length) {
24253 goto fail_bounds;
24254 }
24255 p = (const duk_uint8_t *) (buf + offset);
24256
24257 /* Slow gathering of value using either 64-bit arithmetic
24258 * or IEEE doubles if 64-bit types not available. Handling
24259 * of negative numbers is a bit non-obvious in both cases.
24260 */
24261
24262 if (magic_bigendian) {
24263 /* Gather in big endian */
24264 i = 0;
24265 i_step = 1;
24266 i_end = field_bytelen; /* one i_step over */
24267 } else {
24268 /* Gather in little endian */
24269 i = field_bytelen - 1;
24270 i_step = -1;
24271 i_end = -1; /* one i_step over */
24272 }
24273
24274#if defined(DUK_USE_64BIT_OPS)
24275 tmp = 0;
24276 do {
24277 DUK_ASSERT(i >= 0 && i < field_bytelen);
24278 tmp = (tmp << 8) + (duk_int64_t) p[i];
24279 i += i_step;
24280 } while (i != i_end);
24281
24282 if (magic_signed) {
24283 /* Shift to sign extend. */
24284 shift_tmp = 64 - (field_bytelen * 8);
24285 tmp = (tmp << shift_tmp) >> shift_tmp;
24286 }
24287
24288 duk_push_i64(ctx, tmp);
24289#else
24290 highbyte = p[i];
24291 if (magic_signed && (highbyte & 0x80) != 0) {
24292 /* 0xff => 255 - 256 = -1; 0x80 => 128 - 256 = -128 */
24293 tmp = (duk_double_t) (highbyte - 256);
24294 } else {
24295 tmp = (duk_double_t) highbyte;
24296 }
24297 for (;;) {
24298 i += i_step;
24299 if (i == i_end) {
24300 break;
24301 }
24302 DUK_ASSERT(i >= 0 && i < field_bytelen);
24303 tmp = (tmp * 256.0) + (duk_double_t) p[i];
24304 }
24305
24306 duk_push_number(ctx, tmp);
24307#endif
24308 break;
24309 }
24310 default: { /* should never happen but default here */
24311 goto fail_bounds;
24312 }
#define DUK_DBLUNION_BSWAP64(u)
#define DUK__FLD_FLOAT
#define DUK__FLD_DOUBLE
#define DUK__FLD_16BIT
#define DUK_HBUFFEROBJECT_CLAMP_BYTELENGTH(h, len)
#define duk_push_i64(ctx, val)
#define DUK__FLD_32BIT
#define DUK_HBUFFEROBJECT_GET_SLICE_BASE(heap, h)
#define DUK__FLD_VARINT
#define DUK__FLD_8BIT

References duk_hbufferobject::buf, duk_double_union::d, DUK__FLD_16BIT, DUK__FLD_32BIT, DUK__FLD_8BIT, DUK__FLD_DOUBLE, DUK__FLD_FLOAT, DUK__FLD_VARINT, duk__require_bufobj_this(), DUK_ASSERT, DUK_BSWAP16, DUK_BSWAP32, DUK_DBLUNION_BSWAP64, DUK_DDD, DUK_DDDPRINT, duk_get_current_magic(), duk_get_int(), DUK_HBUFFEROBJECT_CLAMP_BYTELENGTH, DUK_HBUFFEROBJECT_GET_SLICE_BASE, DUK_MEMCPY, duk_push_i64, duk_push_int(), duk_push_number(), duk_push_uint(), duk_to_boolean(), duk_to_int(), DUK_UNREF, duk_double_union::f, duk_hthread::heap, duk_hbufferobject::length, NULL, duk_double_union::uc, duk_double_union::ui, and duk_double_union::us.

◆ duk_bi_buffer_slice_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_slice_shared ( duk_context * ctx)

Definition at line 23703 of file duktape-1.8.0/src/duktape.c.

23708 :
23709 *
23710 * - Copy/view behavior; Node.js .slice() and TypedArray .subarray() create
23711 * views, ArrayBuffer .slice() creates a copy
23712 *
23713 * - Resulting object has a different class and prototype depending on the
23714 * call (or 'this' argument)
23715 *
23716 * - TypedArray .subarray() arguments are element indices, not byte offsets
23717 */
23718
23719#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
23721 duk_hthread *thr;
23722 duk_small_int_t magic;
23723 duk_small_uint_t res_class_num;
23724 duk_hobject *res_proto;
23725 duk_hbufferobject *h_this;
23726 duk_hbufferobject *h_bufobj;
23727 duk_hbuffer *h_val;
23728 duk_int_t start_offset, end_offset;
23729 duk_uint_t slice_length;
23730
23731 thr = (duk_hthread *) ctx;
23732 DUK_UNREF(thr);
23733
23734 /* [ start end ] */
23735
23736 magic = duk_get_current_magic(ctx);
23737 h_this = duk__require_bufobj_this(ctx);
23738
23739 /* Slice offsets are element (not byte) offsets, which only matters
23740 * for TypedArray views, Node.js Buffer and ArrayBuffer have shift
23741 * zero so byte and element offsets are the same. Negative indices
23742 * are counted from end of slice, crossed indices are allowed (and
23743 * result in zero length result), and final values are clamped
23744 * against the current slice. There's intentionally no check
23745 * against the underlying buffer here.
23746 */
23747
23748 duk__clamp_startend_negidx_shifted(ctx, h_this, 0 /*idx_start*/, 1 /*idx_end*/, &start_offset, &end_offset);
23749 DUK_ASSERT(end_offset >= start_offset);
23750 slice_length = (duk_uint_t) (end_offset - start_offset);
23751
23752 /* The resulting buffer object gets the same class and prototype as
23753 * the buffer in 'this', e.g. if the input is a Node.js Buffer the
23754 * result is a Node.js Buffer; if the input is a Float32Array, the
23755 * result is a Float32Array.
23756 *
23757 * For the class number this seems correct. The internal prototype
23758 * is not so clear: if 'this' is a bufferobject with a non-standard
23759 * prototype object, that value gets copied over into the result
23760 * (instead of using the standard prototype for that object type).
23761 */
23762
23763 res_class_num = DUK_HOBJECT_GET_CLASS_NUMBER((duk_hobject *) h_this);
23764 h_bufobj = duk_push_bufferobject_raw(ctx,
23767 DUK_HOBJECT_CLASS_AS_FLAGS(res_class_num),
23768 DUK_BIDX_OBJECT_PROTOTYPE); /* replaced */
23769 DUK_ASSERT(h_bufobj != NULL);
23770 res_proto = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, (duk_hobject *) h_this); /* may be NULL */
23771 DUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, (duk_hobject *) h_bufobj, res_proto);
23772
23773 DUK_ASSERT(h_bufobj->length == 0);
23774 h_bufobj->shift = h_this->shift; /* inherit */
23775 h_bufobj->elem_type = h_this->elem_type; /* inherit */
23776 h_bufobj->is_view = magic & 0x01;
23777 DUK_ASSERT(h_bufobj->is_view == 0 || h_bufobj->is_view == 1);
23778
23779 h_val = h_this->buf;
23780 if (h_val == NULL) {
23781 return DUK_RET_TYPE_ERROR;
23782 }
23783
23784 if (magic & 0x02) {
23785 /* non-zero: make copy */
23786 duk_uint8_t *p_copy;
23787 duk_size_t copy_length;
23788
23789 p_copy = (duk_uint8_t *) duk_push_fixed_buffer(ctx, (duk_size_t) slice_length);
23790 DUK_ASSERT(p_copy != NULL);
23791
23792 /* Copy slice, respecting underlying buffer limits; remainder
23793 * is left as zero.
23794 */
23795 copy_length = DUK_HBUFFEROBJECT_CLAMP_BYTELENGTH(h_this, slice_length);
23796 DUK_MEMCPY((void *) p_copy,
23797 (const void *) (DUK_HBUFFEROBJECT_GET_SLICE_BASE(thr->heap, h_this) + start_offset),
23798 copy_length);
23799
23800 h_val = duk_get_hbuffer(ctx, -1);
23801 DUK_ASSERT(h_val != NULL);
23802
23803 h_bufobj->buf = h_val;
23804 DUK_HBUFFER_INCREF(thr, h_val);
23805 h_bufobj->length = slice_length;
23806 DUK_ASSERT(h_bufobj->offset == 0);
23807
23808 duk_pop(ctx); /* reachable so pop OK */
23809 } else {
23810 h_bufobj->buf = h_val;
23811 DUK_HBUFFER_INCREF(thr, h_val);
23812 h_bufobj->length = slice_length;
23813 h_bufobj->offset = (duk_uint_t) (h_this->offset + start_offset);
23814
23815 /* Copy the .buffer property, needed for TypedArray.prototype.subarray().
DUK_INTERNAL_DECL duk_hbufferobject * duk_push_bufferobject_raw(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_small_int_t prototype_bidx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_slice_shared(duk_context *ctx)
DUK_LOCAL void duk__clamp_startend_negidx_shifted(duk_context *ctx, duk_hbufferobject *h_bufobj, duk_idx_t idx_start, duk_idx_t idx_end, duk_int_t *out_start_offset, duk_int_t *out_end_offset)

References duk_hbufferobject::buf, duk__clamp_startend_negidx_shifted(), duk__require_bufobj_this(), DUK_ASSERT, DUK_BIDX_OBJECT_PROTOTYPE, duk_get_current_magic(), duk_get_hbuffer(), duk_get_prop_stridx(), DUK_HBUFFER_INCREF, DUK_HBUFFEROBJECT_CLAMP_BYTELENGTH, DUK_HBUFFEROBJECT_GET_SLICE_BASE, DUK_HOBJECT_CLASS_AS_FLAGS, DUK_HOBJECT_FLAG_BUFFEROBJECT, DUK_HOBJECT_FLAG_EXTENSIBLE, DUK_HOBJECT_GET_CLASS_NUMBER, DUK_HOBJECT_GET_PROTOTYPE, DUK_HOBJECT_SET_PROTOTYPE_UPDREF, DUK_MEMCPY, duk_pop(), duk_pop_2(), DUK_PROPDESC_FLAGS_NONE, duk_push_bufferobject_raw(), duk_push_fixed_buffer, duk_push_this(), DUK_RET_TYPE_ERROR, DUK_STRIDX_LC_BUFFER, DUK_UNREF, duk_xdef_prop_stridx(), duk_hbufferobject::elem_type, duk_hthread::heap, duk_hbufferobject::is_view, duk_hbufferobject::length, NULL, duk_hbufferobject::offset, and duk_hbufferobject::shift.

◆ duk_bi_buffer_writefield()

DUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_writefield ( duk_context * ctx)

Definition at line 24322 of file duktape-1.8.0/src/duktape.c.

24331 {
24332 DUK_UNREF(ctx);
24334}
24335#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
24336
24337#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
24338/* XXX: split into separate functions for each field type? */
24340 duk_hthread *thr;
24342 duk_small_int_t magic_ftype;
24343 duk_small_int_t magic_bigendian;
24344 duk_small_int_t magic_signed;
24345 duk_small_int_t magic_typedarray;
24346 duk_small_int_t endswap;
24347 duk_hbufferobject *h_this;
24348 duk_bool_t no_assert;
24349 duk_int_t offset_signed;
24350 duk_uint_t offset;
24351 duk_uint_t buffer_length;
24352 duk_uint_t check_length;
24353 duk_uint8_t *buf;
24355 duk_int_t nbytes = 0;
24356
24357 thr = (duk_hthread *) ctx;
24358 DUK_UNREF(thr);
24359
24360 magic_ftype = magic & 0x0007;
24361 magic_bigendian = magic & 0x0008;
24362 magic_signed = magic & 0x0010;
24363 magic_typedarray = magic & 0x0020;
24364 DUK_UNREF(magic_signed);
24365
24366 h_this = duk__require_bufobj_this(ctx);
24367 DUK_ASSERT(h_this != NULL);
24368 buffer_length = h_this->length;
24369
24370 /* [ value offset noAssert ], when ftype != DUK__FLD_VARINT */
24371 /* [ value offset fieldByteLength noAssert ], when ftype == DUK__FLD_VARINT */
24372 /* [ offset value littleEndian ], when DUK__FLD_TYPEDARRAY (regardless of ftype) */
24373
24374 /* Handle TypedArray vs. Node.js Buffer arg differences */
24375 if (magic_typedarray) {
24376 no_assert = 0;
24377#if defined(DUK_USE_INTEGER_LE)
24378 endswap = !duk_to_boolean(ctx, 2); /* 1=little endian */
24379#else
24380 endswap = duk_to_boolean(ctx, 2); /* 1=little endian */
24381#endif
24382 duk_swap(ctx, 0, 1); /* offset/value order different from Node.js */
24383 } else {
24384 no_assert = duk_to_boolean(ctx, (magic_ftype == DUK__FLD_VARINT) ? 3 : 2);
24385#if defined(DUK_USE_INTEGER_LE)
24386 endswap = magic_bigendian;
24387#else
24388 endswap = !magic_bigendian;
24389#endif
24390 }
24391
24392 /* Offset is coerced first to signed integer range and then to unsigned.
24393 * This ensures we can add a small byte length (1-8) to the offset in
24394 * bound checks and not wrap.
24395 */
24396 offset_signed = duk_to_int(ctx, 1);
24397 offset = (duk_uint_t) offset_signed;
24398
24399 /* We need 'nbytes' even for a failed offset; return value must be
24400 * (offset + nbytes) even when write fails due to invalid offset.
24401 */
24402 if (magic_ftype != DUK__FLD_VARINT) {
24403 DUK_ASSERT(magic_ftype >= 0 && magic_ftype < (duk_small_int_t) (sizeof(duk__buffer_nbytes_from_fldtype) / sizeof(duk_uint8_t)));
24404 nbytes = duk__buffer_nbytes_from_fldtype[magic_ftype];
24405 } else {
24406 nbytes = duk_get_int(ctx, 2);
24407 if (nbytes < 1 || nbytes > 6) {
24408 goto fail_field_length;
24409 }
24410 }
24411 DUK_ASSERT(nbytes >= 1 && nbytes <= 8);
24412
24413 /* Now we can check offset validity. */
24414 if (offset_signed < 0) {
24415 goto fail_bounds;
24416 }
24417
24418 DUK_DDD(DUK_DDDPRINT("writefield, value=%!T, buffer_length=%ld, offset=%ld, no_assert=%d, "
24419 "magic=%04x, magic_fieldtype=%d, magic_bigendian=%d, magic_signed=%d, "
24420 "endswap=%d",
24421 duk_get_tval(ctx, 0), (long) buffer_length, (long) offset, (int) no_assert,
24422 (unsigned int) magic, (int) magic_ftype, (int) (magic_bigendian >> 3),
24423 (int) (magic_signed >> 4), (int) endswap));
24424
24425 /* Coerce value to a number before computing check_length, so that
24426 * the field type specific coercion below can't have side effects
24427 * that would invalidate check_length.
24428 */
24429 duk_to_number(ctx, 0);
24430
24431 /* Update 'buffer_length' to be the effective, safe limit which
24432 * takes into account the underlying buffer. This value will be
24433 * potentially invalidated by any side effect.
24434 */
24435 check_length = DUK_HBUFFEROBJECT_CLAMP_BYTELENGTH(h_this, buffer_length);
24436 DUK_DDD(DUK_DDDPRINT("buffer_length=%ld, check_length=%ld",
24437 (long) buffer_length, (long) check_length));
24438
24439 if (h_this->buf) {
24440 buf = DUK_HBUFFEROBJECT_GET_SLICE_BASE(thr->heap, h_this);
24441 } else {
24442 /* Neutered. We could go into the switch-case safely with
24443 * buf == NULL because check_length == 0. To avoid scanbuild
24444 * warnings, fail directly instead.
24445 */
24446 DUK_ASSERT(check_length == 0);
24447 goto fail_neutered;
24448 }
24449 DUK_ASSERT(buf != NULL);
24450
24451 switch (magic_ftype) {
24452 case DUK__FLD_8BIT: {
24453 if (offset + 1U > check_length) {
24454 goto fail_bounds;
24455 }
24456 /* sign doesn't matter when writing */
24457 buf[offset] = (duk_uint8_t) duk_to_uint32(ctx, 0);
24458 break;
24459 }
24460 case DUK__FLD_16BIT: {
24461 duk_uint16_t tmp;
24462 if (offset + 2U > check_length) {
24463 goto fail_bounds;
24464 }
24465 tmp = (duk_uint16_t) duk_to_uint32(ctx, 0);
24466 if (endswap) {
24467 tmp = DUK_BSWAP16(tmp);
24468 }
24469 du.us[0] = tmp;
24470 /* sign doesn't matter when writing */
24471 DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 2);
24472 break;
24473 }
24474 case DUK__FLD_32BIT: {
24475 duk_uint32_t tmp;
24476 if (offset + 4U > check_length) {
24477 goto fail_bounds;
24478 }
24479 tmp = (duk_uint32_t) duk_to_uint32(ctx, 0);
24480 if (endswap) {
24481 tmp = DUK_BSWAP32(tmp);
24482 }
24483 du.ui[0] = tmp;
24484 /* sign doesn't matter when writing */
24485 DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 4);
24486 break;
24487 }
24488 case DUK__FLD_FLOAT: {
24489 duk_uint32_t tmp;
24490 if (offset + 4U > check_length) {
24491 goto fail_bounds;
24492 }
24493 du.f[0] = (duk_float_t) duk_to_number(ctx, 0);
24494 if (endswap) {
24495 tmp = du.ui[0];
24496 tmp = DUK_BSWAP32(tmp);
24497 du.ui[0] = tmp;
24498 }
24499 /* sign doesn't matter when writing */
24500 DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 4);
24501 break;
24502 }
24503 case DUK__FLD_DOUBLE: {
24504 if (offset + 8U > check_length) {
24505 goto fail_bounds;
24506 }
24507 du.d = (duk_double_t) duk_to_number(ctx, 0);
24508 if (endswap) {
24510 }
24511 /* sign doesn't matter when writing */
24512 DUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 8);
24513 break;
24514 }
24515 case DUK__FLD_VARINT: {
24516 /* Node.js Buffer variable width integer field. We don't really
24517 * care about speed here, so aim for shortest algorithm.
24518 */
24519 duk_int_t field_bytelen;
24520 duk_int_t i, i_step, i_end;
24521#if defined(DUK_USE_64BIT_OPS)
24522 duk_int64_t tmp;
24523#else
24524 duk_double_t tmp;
24525#endif
24526 duk_uint8_t *p;
24527
24528 field_bytelen = (duk_int_t) nbytes;
24529 if (offset + (duk_uint_t) field_bytelen > check_length) {
24530 goto fail_bounds;
24531 }
24532
24533 /* Slow writing of value using either 64-bit arithmetic
24534 * or IEEE doubles if 64-bit types not available. There's
24535 * no special sign handling when writing varints.
24536 */
24537
24538 if (magic_bigendian) {
24539 /* Write in big endian */
24540 i = field_bytelen; /* one i_step added at top of loop */
24541 i_step = -1;
24542 i_end = 0;
24543 } else {
24544 /* Write in little endian */
24545 i = -1; /* one i_step added at top of loop */
24546 i_step = 1;
24547 i_end = field_bytelen - 1;
24548 }
24549
24550 /* XXX: The duk_to_number() cast followed by integer coercion
24551 * is platform specific so NaN, +/- Infinity, and out-of-bounds
24552 * values result in platform specific output now.
24553 * See: test-bi-nodejs-buffer-proto-varint-special.js
24554 */
24555
24556#if defined(DUK_USE_64BIT_OPS)
24557 tmp = (duk_int64_t) duk_to_number(ctx, 0);
24558 p = (duk_uint8_t *) (buf + offset);
24559 do {
24560 i += i_step;
24561 DUK_ASSERT(i >= 0 && i < field_bytelen);
24562 p[i] = (duk_uint8_t) (tmp & 0xff);
24563 tmp = tmp >> 8; /* unnecessary shift for last byte */
24564 } while (i != i_end);
24565#else
24566 tmp = duk_to_number(ctx, 0);
24567 p = (duk_uint8_t *) (buf + offset);
24568 do {
24569 i += i_step;
24570 tmp = DUK_FLOOR(tmp);
24571 DUK_ASSERT(i >= 0 && i < field_bytelen);
24572 p[i] = (duk_uint8_t) (DUK_FMOD(tmp, 256.0));
24573 tmp = tmp / 256.0; /* unnecessary div for last byte */
24574 } while (i != i_end);
24575#endif
24576 break;
24577 }
24578 default: { /* should never happen but default here */
24579 goto fail_bounds;
24580 }
24581 }
24582
24583 /* Node.js Buffer: return offset + #bytes written (i.e. next
24584 * write offset).
24585 */
24586 if (magic_typedarray) {
24587 /* For TypedArrays 'undefined' return value is specified
24588 * by ES6 (matches V8).
24589 */
24590 return 0;
24591 }
24592 duk_push_uint(ctx, offset + nbytes);
24593 return 1;
24594
24595 fail_neutered:
DUK_EXTERNAL void duk_swap(duk_context *ctx, duk_idx_t index1, duk_idx_t index2)
static const duk_uint8_t duk__buffer_nbytes_from_fldtype[6]
DUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_writefield(duk_context *ctx)

◆ duk_bi_dataview_constructor()

DUK_INTERNAL_DECL duk_ret_t duk_bi_dataview_constructor ( duk_context * ctx)

Definition at line 22831 of file duktape-1.8.0/src/duktape.c.

22837 :
22838 return DUK_RET_RANGE_ERROR;
22839}
22840#else /* DUK_USE_BUFFEROBJECT_SUPPORT */
22842 DUK_UNREF(ctx);
22844}
22845#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
22846
22847#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
22849 duk_hbufferobject *h_bufarg;
22850 duk_hbufferobject *h_bufobj;
22851 duk_hbuffer *h_val;
22852 duk_uint_t offset;
22853 duk_uint_t length;
22854
22855 /* XXX: function flag to make this automatic? */
22856 if (!duk_is_constructor_call(ctx)) {
22857 return DUK_RET_TYPE_ERROR;
22858 }
22859
22860 h_bufarg = duk__require_bufobj_value(ctx, 0);
22861 DUK_ASSERT(h_bufarg != NULL);
22862
22863 duk__resolve_offset_opt_length(ctx, h_bufarg, 1, 2, &offset, &length, 1 /*throw_flag*/);
22864 DUK_ASSERT(offset <= h_bufarg->length);
22865 DUK_ASSERT(offset + length <= h_bufarg->length);
22866
22867 h_bufobj = duk_push_bufferobject_raw(ctx,
22872
22873 h_val = h_bufarg->buf;
22874 if (h_val == NULL) {
22875 return DUK_RET_TYPE_ERROR;
22876 }
22877 h_bufobj->buf = h_val;
22878 DUK_HBUFFER_INCREF(thr, h_val);
22879 h_bufobj->offset = h_bufarg->offset + offset;
22880 h_bufobj->length = length;
22881 DUK_ASSERT(h_bufobj->shift == 0);
22883 h_bufobj->is_view = 1;
22884
22885 /* The DataView .buffer property is ordinarily set to the argument
DUK_INTERNAL_DECL duk_ret_t duk_bi_dataview_constructor(duk_context *ctx)
#define DUK_BIDX_DATAVIEW_PROTOTYPE
DUK_LOCAL void duk__resolve_offset_opt_length(duk_context *ctx, duk_hbufferobject *h_bufarg, duk_idx_t idx_offset, duk_idx_t idx_length, duk_uint_t *out_offset, duk_uint_t *out_length, duk_bool_t throw_flag)
DUK_INTERNAL_DECL duk_ret_t duk_bi_typedarray_constructor(duk_context *ctx)

◆ duk_bi_date_constructor()

DUK_INTERNAL_DECL duk_ret_t duk_bi_date_constructor ( duk_context * ctx)

Definition at line 26045 of file duktape-1.8.0/src/duktape.c.

26052 {
26054 DUK_ASSERT(magicidx >= 0 && magicidx < (duk_small_int_t) (sizeof(duk__date_magics) / sizeof(duk_uint16_t)));
26055 return (duk_small_uint_t) duk__date_magics[magicidx];
26056}
26057
26058/*
26059 * Constructor calls
26060 */
26061
26063 duk_idx_t nargs = duk_get_top(ctx);
26064 duk_bool_t is_cons = duk_is_constructor_call(ctx);
26066 duk_double_t d;
26067
26068 DUK_DDD(DUK_DDDPRINT("Date constructor, nargs=%ld, is_cons=%ld", (long) nargs, (long) is_cons));
26069
26074
26075 /* Unlike most built-ins, the internal [[PrimitiveValue]] of a Date
26076 * is mutable.
26077 */
26078
26079 if (nargs == 0 || !is_cons) {
26080 d = duk__timeclip(DUK_USE_DATE_GET_NOW(ctx));
26081 duk_push_number(ctx, d);
26083 if (!is_cons) {
26084 /* called as a normal function: return new Date().toString() */
26085 duk_to_string(ctx, -1);
26086 }
26087 return 1;
26088 } else if (nargs == 1) {
26090 if (duk_is_string(ctx, 0)) {
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_constructor(duk_context *ctx)
static duk_uint16_t duk__date_magics[]
#define DUK_BIDX_DATE_PROTOTYPE
DUK_LOCAL duk_double_t duk__timeclip(duk_double_t x)

◆ duk_bi_date_constructor_now()

DUK_INTERNAL_DECL duk_ret_t duk_bi_date_constructor_now ( duk_context * ctx)

Definition at line 26115 of file duktape-1.8.0/src/duktape.c.

26122 {

References duk_push_nan().

◆ duk_bi_date_constructor_parse()

DUK_INTERNAL_DECL duk_ret_t duk_bi_date_constructor_parse ( duk_context * ctx)

Definition at line 26092 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_date_constructor_utc()

DUK_INTERNAL_DECL duk_ret_t duk_bi_date_constructor_utc ( duk_context * ctx)

Definition at line 26096 of file duktape-1.8.0/src/duktape.c.

26109 {
26110 return duk__parse_string(ctx, duk_to_string(ctx, 0));
26111}
26112
DUK_LOCAL duk_ret_t duk__parse_string(duk_context *ctx, const char *str)
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_constructor_utc(duk_context *ctx)

◆ duk_bi_date_format_timeval()

DUK_INTERNAL_DECL void duk_bi_date_format_timeval ( duk_double_t timeval,
duk_uint8_t * out_buf )

Definition at line 25886 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_date_get_local_tzoffset_gmtime()

DUK_INTERNAL_DECL duk_int_t duk_bi_date_get_local_tzoffset_gmtime ( duk_double_t d)

Definition at line 26390 of file duktape-1.8.0/src/duktape.c.

26396 {
26397 time_t t;
26398
26399 DUK_UNREF(ctx);
26400 t = time(NULL);
26401 return ((duk_double_t) t) * 1000.0;
26402}
26403#endif /* DUK_USE_DATE_NOW_TIME */
26404
26405#if defined(DUK_USE_DATE_TZO_GMTIME) || defined(DUK_USE_DATE_TZO_GMTIME_R)
26406/* Get local time offset (in seconds) for a certain (UTC) instant 'd'. */
26408 time_t t, t1, t2;
26411 struct tm tms[2];
26412#ifdef DUK_USE_DATE_TZO_GMTIME
26413 struct tm *tm_ptr;
26414#endif
26415
26416 /* For NaN/inf, the return value doesn't matter. */
26417 if (!DUK_ISFINITE(d)) {
26418 return 0;
26419 }
26420
26421 /* If not within Ecmascript range, some integer time calculations
26422 * won't work correctly (and some asserts will fail), so bail out
26423 * if so. This fixes test-bug-date-insane-setyear.js. There is
26424 * a +/- 24h leeway in this range check to avoid a test262 corner
26425 * case documented in test-bug-date-timeval-edges.js.
26426 */
26428 DUK_DD(DUK_DDPRINT("timeval not within valid range, skip tzoffset computation to avoid integer overflows"));
26429 return 0;
26430 }
26431
26432 /*
26433 * This is a bit tricky to implement portably. The result depends
26434 * on the timestamp (specifically, DST depends on the timestamp).
26435 * If e.g. UNIX APIs are used, they'll have portability issues with
26436 * very small and very large years.
26437 *
26438 * Current approach:
26439 *
26440 * - Stay within portable UNIX limits by using equivalent year mapping.
26441 * Avoid year 1970 and 2038 as some conversions start to fail, at
26442 * least on some platforms. Avoiding 1970 means that there are
26443 * currently DST discrepancies for 1970.
26444 *
26445 * - Create a UTC and local time breakdowns from 't'. Then create
26446 * a time_t using gmtime() and localtime() and compute the time
26447 * difference between the two.
26448 *
26449 * Equivalent year mapping (E5 Section 15.9.1.8):
26450 *
26451 * If the host environment provides functionality for determining
26452 * daylight saving time, the implementation of ECMAScript is free
26453 * to map the year in question to an equivalent year (same
26454 * leap-year-ness and same starting week day for the year) for which
26455 * the host environment provides daylight saving time information.
26456 * The only restriction is that all equivalent years should produce
26457 * the same result.
26458 *
26459 * This approach is quite reasonable but not entirely correct, e.g.
26460 * the specification also states (E5 Section 15.9.1.8):
26461 *
26462 * The implementation of ECMAScript should not try to determine
26463 * whether the exact time was subject to daylight saving time, but
26464 * just whether daylight saving time would have been in effect if
26465 * the _current daylight saving time algorithm_ had been used at the
26466 * time. This avoids complications such as taking into account the
26467 * years that the locale observed daylight saving time year round.
26468 *
26469 * Since we rely on the platform APIs for conversions between local
26470 * time and UTC, we can't guarantee the above. Rather, if the platform
26471 * has historical DST rules they will be applied. This seems to be the
26472 * general preferred direction in Ecmascript standardization (or at least
26473 * implementations) anyway, and even the equivalent year mapping should
26474 * be disabled if the platform is known to handle DST properly for the
26475 * full Ecmascript range.
26476 *
26477 * The following has useful discussion and links:
26478 *
26479 * https://bugzilla.mozilla.org/show_bug.cgi?id=351066
26480 */
26481
26482 duk_bi_date_timeval_to_parts(d, parts, dparts, DUK_DATE_FLAG_EQUIVYEAR /*flags*/);
26483 DUK_ASSERT(parts[DUK_DATE_IDX_YEAR] >= 1970 && parts[DUK_DATE_IDX_YEAR] <= 2038);
26484
26485 d = duk_bi_date_get_timeval_from_dparts(dparts, 0 /*flags*/);
26486 DUK_ASSERT(d >= 0 && d < 2147483648.0 * 1000.0); /* unsigned 31-bit range */
26487 t = (time_t) (d / 1000.0);
26488 DUK_DDD(DUK_DDDPRINT("timeval: %lf -> time_t %ld", (double) d, (long) t));
26489
26490 DUK_MEMZERO((void *) tms, sizeof(struct tm) * 2);
26491
26492#if defined(DUK_USE_DATE_TZO_GMTIME_R)
26493 (void) gmtime_r(&t, &tms[0]);
26494 (void) localtime_r(&t, &tms[1]);
26495#elif defined(DUK_USE_DATE_TZO_GMTIME)
26496 tm_ptr = gmtime(&t);
26497 DUK_MEMCPY((void *) &tms[0], tm_ptr, sizeof(struct tm));
26498 tm_ptr = localtime(&t);
26499 DUK_MEMCPY((void *) &tms[1], tm_ptr, sizeof(struct tm));
26500#else
26501#error internal error
26502#endif
26503 DUK_DDD(DUK_DDDPRINT("gmtime result: tm={sec:%ld,min:%ld,hour:%ld,mday:%ld,mon:%ld,year:%ld,"
26504 "wday:%ld,yday:%ld,isdst:%ld}",
26505 (long) tms[0].tm_sec, (long) tms[0].tm_min, (long) tms[0].tm_hour,
26506 (long) tms[0].tm_mday, (long) tms[0].tm_mon, (long) tms[0].tm_year,
26507 (long) tms[0].tm_wday, (long) tms[0].tm_yday, (long) tms[0].tm_isdst));
26508 DUK_DDD(DUK_DDDPRINT("localtime result: tm={sec:%ld,min:%ld,hour:%ld,mday:%ld,mon:%ld,year:%ld,"
26509 "wday:%ld,yday:%ld,isdst:%ld}",
26510 (long) tms[1].tm_sec, (long) tms[1].tm_min, (long) tms[1].tm_hour,
26511 (long) tms[1].tm_mday, (long) tms[1].tm_mon, (long) tms[1].tm_year,
26512 (long) tms[1].tm_wday, (long) tms[1].tm_yday, (long) tms[1].tm_isdst));
26513
26514 /* tm_isdst is both an input and an output to mktime(), use 0 to
26515 * avoid DST handling in mktime():
26516 * - https://github.com/svaarala/duktape/issues/406
26517 * - http://stackoverflow.com/questions/8558919/mktime-and-tm-isdst
26518 */
26519 tms[0].tm_isdst = 0;
26520 tms[1].tm_isdst = 0;
26521 t1 = mktime(&tms[0]); /* UTC */
26522 t2 = mktime(&tms[1]); /* local */
26523 if (t1 == (time_t) -1 || t2 == (time_t) -1) {
26524 /* This check used to be for (t < 0) but on some platforms
26525 * time_t is unsigned and apparently the proper way to detect
26526 * an mktime() error return is the cast above. See e.g.:
26527 * http://pubs.opengroup.org/onlinepubs/009695299/functions/mktime.html
26528 */
26529 goto error;
26530 }
26531 DUK_DDD(DUK_DDDPRINT("t1=%ld (utc), t2=%ld (local)", (long) t1, (long) t2));
26532
#define DUK_DATE_FLAG_EQUIVYEAR
DUK_INTERNAL_DECL duk_int_t duk_bi_date_get_local_tzoffset_gmtime(duk_double_t d)

◆ duk_bi_date_get_now_time()

DUK_INTERNAL_DECL duk_double_t duk_bi_date_get_now_time ( duk_context * ctx)

Definition at line 26379 of file duktape-1.8.0/src/duktape.c.

26382 {
26384 }
26385

◆ duk_bi_date_get_timeval_from_dparts()

DUK_INTERNAL_DECL duk_double_t duk_bi_date_get_timeval_from_dparts ( duk_double_t * dparts,
duk_small_uint_t flags )

Definition at line 25363 of file duktape-1.8.0/src/duktape.c.

25367 {
25368 for (i = 0; i < DUK_DATE_IDX_NUM_PARTS; i++) {
25369 dparts[i] = (duk_double_t) parts[i];
25370 }
25371 }
25372}
25373
25374/* Compute time value from (double) parts. The parts can be either UTC
25375 * or local time; if local, they need to be (conceptually) converted into
25376 * UTC time. The parts may represent valid or invalid time, and may be
25377 * wildly out of range (but may cancel each other and still come out in
25378 * the valid Date range).
25379 */
25381#if defined(DUK_USE_PARANOID_DATE_COMPUTATION)
25382 /* See comments below on MakeTime why these are volatile. */
25383 volatile duk_double_t tmp_time;
25384 volatile duk_double_t tmp_day;
25385 volatile duk_double_t d;
25386#else
25387 duk_double_t tmp_time;
25388 duk_double_t tmp_day;
25389 duk_double_t d;
25390#endif
25392 duk_int_t tzoff, tzoffprev1, tzoffprev2;
25393
25394 /* Expects 'this' at top of stack on entry. */
25395
25396 /* Coerce all finite parts with ToInteger(). ToInteger() must not
25397 * be called for NaN/Infinity because it will convert e.g. NaN to
25398 * zero. If ToInteger() has already been called, this has no side
25399 * effects and is idempotent.
25400 *
25401 * Don't read dparts[DUK_DATE_IDX_WEEKDAY]; it will cause Valgrind
25402 * issues if the value is uninitialized.
25403 */
25404 for (i = 0; i <= DUK_DATE_IDX_MILLISECOND; i++) {
25405 /* SCANBUILD: scan-build complains here about assigned value
25406 * being garbage or undefined. This is correct but operating
25407 * on undefined values has no ill effect and is ignored by the
25408 * caller in the case where this happens.
25409 */
25410 d = dparts[i];
25411 if (DUK_ISFINITE(d)) {
25412 dparts[i] = duk_js_tointeger_number(d);
25413 }
25414 }
25415
25416 /* Use explicit steps in computation to try to ensure that
25417 * computation happens with intermediate results coerced to
25418 * double values (instead of using something more accurate).
25419 * E.g. E5.1 Section 15.9.1.11 requires use of IEEE 754
25420 * rules (= Ecmascript '+' and '*' operators).
25421 *
25422 * Without 'volatile' even this approach fails on some platform
25423 * and compiler combinations. For instance, gcc 4.8.1 on Ubuntu
25424 * 64-bit, with -m32 and without -std=c99, test-bi-date-canceling.js
25425 * would fail because of some optimizations when computing tmp_time
25426 * (MakeTime below). Adding 'volatile' to tmp_time solved this
25427 * particular problem (annoyingly, also adding debug prints or
25428 * running the executable under valgrind hides it).
25429 */
25430
25431 /* MakeTime */
25432 tmp_time = 0.0;
25433 tmp_time += dparts[DUK_DATE_IDX_HOUR] * ((duk_double_t) DUK_DATE_MSEC_HOUR);
25434 tmp_time += dparts[DUK_DATE_IDX_MINUTE] * ((duk_double_t) DUK_DATE_MSEC_MINUTE);
25435 tmp_time += dparts[DUK_DATE_IDX_SECOND] * ((duk_double_t) DUK_DATE_MSEC_SECOND);
25436 tmp_time += dparts[DUK_DATE_IDX_MILLISECOND];
25437
25438 /* MakeDay */
25439 tmp_day = duk__make_day(dparts[DUK_DATE_IDX_YEAR], dparts[DUK_DATE_IDX_MONTH], dparts[DUK_DATE_IDX_DAY]);
25440
25441 /* MakeDate */
25442 d = tmp_day * ((duk_double_t) DUK_DATE_MSEC_DAY) + tmp_time;
25443
25444 DUK_DDD(DUK_DDDPRINT("time=%lf day=%lf --> timeval=%lf",
25445 (double) tmp_time, (double) tmp_day, (double) d));
25446
25447 /* Optional UTC conversion. */
25448 if (flags & DUK_DATE_FLAG_LOCALTIME) {
25449 /* DUK_USE_DATE_GET_LOCAL_TZOFFSET() needs to be called with a
25450 * time value computed from UTC parts. At this point we only
25451 * have 'd' which is a time value computed from local parts, so
25452 * it is off by the UTC-to-local time offset which we don't know
25453 * yet. The current solution for computing the UTC-to-local
25454 * time offset is to iterate a few times and detect a fixed
25455 * point or a two-cycle loop (or a sanity iteration limit),
25456 * see test-bi-date-local-parts.js and test-bi-date-tzoffset-basic-fi.js.
25457 *
25458 * E5.1 Section 15.9.1.9:
25459 * UTC(t) = t - LocalTZA - DaylightSavingTA(t - LocalTZA)
25460 *
25461 * For NaN/inf, DUK_USE_DATE_GET_LOCAL_TZOFFSET() returns 0.
25462 */
25463
25464#if 0
25465 /* Old solution: don't iterate, incorrect */
25466 tzoff = DUK_USE_DATE_GET_LOCAL_TZOFFSET(d);
25467 DUK_DDD(DUK_DDDPRINT("tzoffset w/o iteration, tzoff=%ld", (long) tzoff));
25468 d -= tzoff * 1000L;
25469 DUK_UNREF(tzoffprev1);
25470 DUK_UNREF(tzoffprev2);
25471#endif
25472
25473 /* Iteration solution */
25474 tzoff = 0;
25475 tzoffprev1 = 999999999L; /* invalid value which never matches */
25476 for (i = 0; i < DUK__LOCAL_TZOFFSET_MAXITER; i++) {
25477 tzoffprev2 = tzoffprev1;
25478 tzoffprev1 = tzoff;
25479 tzoff = DUK_USE_DATE_GET_LOCAL_TZOFFSET(d - tzoff * 1000L);
25480 DUK_DDD(DUK_DDDPRINT("tzoffset iteration, i=%d, tzoff=%ld, tzoffprev1=%ld tzoffprev2=%ld",
25481 (int) i, (long) tzoff, (long) tzoffprev1, (long) tzoffprev2));
25482 if (tzoff == tzoffprev1) {
25483 DUK_DDD(DUK_DDDPRINT("tzoffset iteration finished, i=%d, tzoff=%ld, tzoffprev1=%ld, tzoffprev2=%ld",
25484 (int) i, (long) tzoff, (long) tzoffprev1, (long) tzoffprev2));
25485 break;
25486 } else if (tzoff == tzoffprev2) {
25487 /* Two value cycle, see e.g. test-bi-date-tzoffset-basic-fi.js.
25488 * In these cases, favor a higher tzoffset to get a consistent
25489 * result which is independent of iteration count. Not sure if
25490 * this is a generically correct solution.
25491 */
#define DUK__LOCAL_TZOFFSET_MAXITER

Referenced by duk__format_parts_iso8601().

◆ duk_bi_date_is_leap_year()

DUK_INTERNAL_DECL duk_bool_t duk_bi_date_is_leap_year ( duk_int_t year)

Definition at line 25053 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_date_prototype_get_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_get_shared ( duk_context * ctx)

Definition at line 26240 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_date_prototype_get_timezone_offset()

DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_get_timezone_offset ( duk_context * ctx)

Definition at line 26245 of file duktape-1.8.0/src/duktape.c.

26246 :
26247 *
26248 * - Date.prototype.getDate(): 'date' means day-of-month, and is
26249 * zero-based in internal calculations but public API expects it to
26250 * be one-based.
26251 *
26252 * - Date.prototype.getTime() and Date.prototype.valueOf() have identical
26253 * behavior. They have separate function objects, but share the same C
26254 * function (duk_bi_date_prototype_value_of).
26255 */
26256
26259 return duk__get_part_helper(ctx, flags_and_idx);
26260}
26261
26263 /*
26264 * Return (t - LocalTime(t)) in minutes:
26265 *
26266 * t - LocalTime(t) = t - (t + LocalTZA + DaylightSavingTA(t))
26267 * = -(LocalTZA + DaylightSavingTA(t))
26268 *
26269 * where DaylightSavingTA() is checked for time 't'.
26270 *
26271 * Note that the sign of the result is opposite to common usage,
26272 * e.g. for EE(S)T which normally is +2h or +3h from UTC, this
26273 * function returns -120 or -180.
26274 *
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_get_shared(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_value_of(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_get_timezone_offset(duk_context *ctx)
DUK_LOCAL duk_ret_t duk__get_part_helper(duk_context *ctx, duk_small_uint_t flags_and_idx)
DUK_LOCAL duk_small_uint_t duk__date_get_indirect_magic(duk_context *ctx)

References duk__date_get_indirect_magic(), and duk__get_part_helper().

◆ duk_bi_date_prototype_set_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_set_shared ( duk_context * ctx)

Definition at line 26325 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_date_prototype_set_time()

DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_set_time ( duk_context * ctx)

Definition at line 26330 of file duktape-1.8.0/src/duktape.c.

26331 : special year check
26332 * is omitted. NaN / Infinity will just flow through and ultimately
26333 * result in a NaN internal time value.
26334 *
26335 * - Date.prototype.setYear() does not have optional arguments for
26336 * setting month and day-in-month (like setFullYear()), but we indicate
26337 * 'maxnargs' to be 3 to get the year written to the correct component
26338 * index in duk__set_part_helper(). The function has nargs == 1, so only
26339 * the year will be set regardless of actual argument count.
26340 */

References duk__date_get_indirect_magic(), and duk__set_part_helper().

◆ duk_bi_date_prototype_to_json()

DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_to_json ( duk_context * ctx)

Definition at line 26174 of file duktape-1.8.0/src/duktape.c.

26175 {
26177 return duk__to_string_helper(ctx, flags);
26178}
26179
26181 /* This native function is also used for Date.prototype.getTime()
26182 * as their behavior is identical.
26183 */
26184
26185 duk_double_t d = duk__push_this_get_timeval(ctx, 0 /*flags*/); /* -> [ this ] */
26187 duk_push_number(ctx, d);
26188 return 1;
26189}
26190
26192 /* Note: toJSON() is a generic function which works even if 'this'
26193 * is not a Date. The sole argument is ignored.
26194 */
26195
26196 duk_push_this(ctx);
26197 duk_to_object(ctx, -1);
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_to_json(duk_context *ctx)

References duk__date_get_indirect_magic(), and duk__to_string_helper().

◆ duk_bi_date_prototype_tostring_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_tostring_shared ( duk_context * ctx)

Definition at line 26158 of file duktape-1.8.0/src/duktape.c.

26160 :
26161 *

◆ duk_bi_date_prototype_value_of()

DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_value_of ( duk_context * ctx)

Definition at line 26163 of file duktape-1.8.0/src/duktape.c.

26166 : E5.1 specification does not require a
26167 * specific format, but result should be human readable. The
26168 * specification suggests using ISO 8601 format with a space (instead
26169 * of 'T') separator if a more human readable format is not available.
26170 *
26171 * - Date.prototype.toISOString(): unlike other conversion functions,
26172 * toISOString() requires a RangeError for invalid date values.
json_t format(printf, 1, 2)))
static int readable(const char *filename)

◆ duk_bi_date_timeval_in_leeway_range()

DUK_INTERNAL_DECL duk_bool_t duk_bi_date_timeval_in_leeway_range ( duk_double_t x)

Definition at line 25070 of file duktape-1.8.0/src/duktape.c.

25070 {
25071 if ((year % 4) != 0) {
25072 return 0;

◆ duk_bi_date_timeval_in_valid_range()

DUK_INTERNAL_DECL duk_bool_t duk_bi_date_timeval_in_valid_range ( duk_double_t x)

Definition at line 25066 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__div_floor().

◆ duk_bi_date_timeval_to_parts()

DUK_INTERNAL_DECL void duk_bi_date_timeval_to_parts ( duk_double_t d,
duk_int_t * parts,
duk_double_t * dparts,
duk_small_uint_t flags )

Definition at line 25218 of file duktape-1.8.0/src/duktape.c.

25220 {
25221 day_num += duk__days_in_month[i];
25222 if (i == 1 && is_leap) {
25223 day_num++;
25224 }
25225 }
25226
25227 /* If 'day' is NaN, returns NaN. */
25228 return (duk_double_t) day_num + day;
25229}
25230
25231/* Split time value into parts. The time value is assumed to be an internal
25232 * one, i.e. finite, no fractions. Possible local time adjustment has already
25233 * been applied when reading the time value.
25234 */
25236 duk_double_t d1, d2;
25237 duk_int_t t1, t2;
25238 duk_int_t day_since_epoch;
25239 duk_int_t year; /* does not fit into 16 bits */
25240 duk_small_int_t day_in_year;
25241 duk_small_int_t month;
25242 duk_small_int_t day;
25243 duk_small_int_t dim;
25244 duk_int_t jan1_since_epoch;
25245 duk_small_int_t jan1_weekday;
25246 duk_int_t equiv_year;
25248 duk_bool_t is_leap;
25249 duk_small_int_t arridx;
25250
25251 DUK_ASSERT(DUK_ISFINITE(d)); /* caller checks */
25252 DUK_ASSERT(DUK_FLOOR(d) == d); /* no fractions in internal time */
25253
25254 /* The timevalue must be in valid Ecmascript range, but since a local
25255 * time offset can be applied, we need to allow a +/- 24h leeway to
25256 * the value. In other words, although the UTC time is within the
25257 * Ecmascript range, the local part values can be just outside of it.
25258 */
25261
25262 /* these computations are guaranteed to be exact for the valid
25263 * E5 time value range, assuming milliseconds without fractions.
25264 */
25265 d1 = (duk_double_t) DUK_FMOD(d, (double) DUK_DATE_MSEC_DAY);
25266 if (d1 < 0.0) {
25267 /* deal with negative values */
25269 }
25270 d2 = DUK_FLOOR((double) (d / (duk_double_t) DUK_DATE_MSEC_DAY));
25271 DUK_ASSERT(d2 * ((duk_double_t) DUK_DATE_MSEC_DAY) + d1 == d);
25272 /* now expected to fit into a 32-bit integer */
25273 t1 = (duk_int_t) d1;
25274 t2 = (duk_int_t) d2;
25275 day_since_epoch = t2;
25276 DUK_ASSERT((duk_double_t) t1 == d1);
25277 DUK_ASSERT((duk_double_t) t2 == d2);
25278
25279 /* t1 = milliseconds within day (fits 32 bit)
25280 * t2 = day number from epoch (fits 32 bit, may be negative)
25281 */
25282
25283 parts[DUK_DATE_IDX_MILLISECOND] = t1 % 1000; t1 /= 1000;
25284 parts[DUK_DATE_IDX_SECOND] = t1 % 60; t1 /= 60;
25285 parts[DUK_DATE_IDX_MINUTE] = t1 % 60; t1 /= 60;
25286 parts[DUK_DATE_IDX_HOUR] = t1;
25287 DUK_ASSERT(parts[DUK_DATE_IDX_MILLISECOND] >= 0 && parts[DUK_DATE_IDX_MILLISECOND] <= 999);
25288 DUK_ASSERT(parts[DUK_DATE_IDX_SECOND] >= 0 && parts[DUK_DATE_IDX_SECOND] <= 59);
25289 DUK_ASSERT(parts[DUK_DATE_IDX_MINUTE] >= 0 && parts[DUK_DATE_IDX_MINUTE] <= 59);
25290 DUK_ASSERT(parts[DUK_DATE_IDX_HOUR] >= 0 && parts[DUK_DATE_IDX_HOUR] <= 23);
25291
25292 DUK_DDD(DUK_DDDPRINT("d=%lf, d1=%lf, d2=%lf, t1=%ld, t2=%ld, parts: hour=%ld min=%ld sec=%ld msec=%ld",
25293 (double) d, (double) d1, (double) d2, (long) t1, (long) t2,
25294 (long) parts[DUK_DATE_IDX_HOUR],
25295 (long) parts[DUK_DATE_IDX_MINUTE],
25296 (long) parts[DUK_DATE_IDX_SECOND],
25297 (long) parts[DUK_DATE_IDX_MILLISECOND]));
25298
25299 /* This assert depends on the input parts representing time inside
25300 * the Ecmascript range.
25301 */
25303 parts[DUK_DATE_IDX_WEEKDAY] = (t2 + 4 + DUK__WEEKDAY_MOD_ADDER) % 7; /* E5.1 Section 15.9.1.6 */
25304 DUK_ASSERT(parts[DUK_DATE_IDX_WEEKDAY] >= 0 && parts[DUK_DATE_IDX_WEEKDAY] <= 6);
25305
25306 year = duk__year_from_day(t2, &day_in_year);
25307 day = day_in_year;
25308 is_leap = duk_bi_date_is_leap_year(year);
25309 for (month = 0; month < 12; month++) {
25310 dim = duk__days_in_month[month];
25311 if (month == 1 && is_leap) {
25312 dim++;
25313 }
25314 DUK_DDD(DUK_DDDPRINT("month=%ld, dim=%ld, day=%ld",
25315 (long) month, (long) dim, (long) day));
25316 if (day < dim) {
25317 break;
25318 }
25319 day -= dim;
25320 }
25321 DUK_DDD(DUK_DDDPRINT("final month=%ld", (long) month));
25322 DUK_ASSERT(month >= 0 && month <= 11);
25323 DUK_ASSERT(day >= 0 && day <= 31);
25324
25325 /* Equivalent year mapping, used to avoid DST trouble when platform
25326 * may fail to provide reasonable DST answers for dates outside the
25327 * ordinary range (e.g. 1970-2038). An equivalent year has the same
25328 * leap-year-ness as the original year and begins on the same weekday
25329 * (Jan 1).
25330 *
25331 * The year 2038 is avoided because there seem to be problems with it
25332 * on some platforms. The year 1970 is also avoided as there were
25333 * practical problems with it; an equivalent year is used for it too,
25334 * which breaks some DST computations for 1970 right now, see e.g.
25335 * test-bi-date-tzoffset-brute-fi.js.
25336 */
25337 if ((flags & DUK_DATE_FLAG_EQUIVYEAR) && (year < 1971 || year > 2037)) {
25338 DUK_ASSERT(is_leap == 0 || is_leap == 1);
25339
25340 jan1_since_epoch = day_since_epoch - day_in_year; /* day number for Jan 1 since epoch */
25341 DUK_ASSERT(jan1_since_epoch + DUK__WEEKDAY_MOD_ADDER >= 0);
25342 jan1_weekday = (jan1_since_epoch + 4 + DUK__WEEKDAY_MOD_ADDER) % 7; /* E5.1 Section 15.9.1.6 */
25343 DUK_ASSERT(jan1_weekday >= 0 && jan1_weekday <= 6);
25344 arridx = jan1_weekday;
25345 if (is_leap) {
25346 arridx += 7;
25347 }
25348 DUK_ASSERT(arridx >= 0 && arridx < (duk_small_int_t) (sizeof(duk__date_equivyear) / sizeof(duk_uint8_t)));
25349
25350 equiv_year = (duk_int_t) duk__date_equivyear[arridx] + 1970;
25351 year = equiv_year;
25352 DUK_DDD(DUK_DDDPRINT("equiv year mapping, year=%ld, day_in_year=%ld, day_since_epoch=%ld, "
25353 "jan1_since_epoch=%ld, jan1_weekday=%ld -> equiv year %ld",
25354 (long) year, (long) day_in_year, (long) day_since_epoch,
25355 (long) jan1_since_epoch, (long) jan1_weekday, (long) equiv_year));
DUK_INTERNAL_DECL duk_bool_t duk_bi_date_is_leap_year(duk_int_t year)
#define DUK__WEEKDAY_MOD_ADDER
DUK_LOCAL duk_uint8_t duk__date_equivyear[14]
DUK_LOCAL duk_uint8_t duk__days_in_month[12]

References duk__days_in_month.

◆ duk_bi_date_year_in_valid_range()

DUK_INTERNAL_DECL duk_bool_t duk_bi_date_year_in_valid_range ( duk_double_t year)

Definition at line 25074 of file duktape-1.8.0/src/duktape.c.

25074 {
25075 return 1;
25076 }

◆ duk_bi_duktape_object_act()

DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_act ( duk_context * ctx)

Definition at line 26884 of file duktape-1.8.0/src/duktape.c.

26889 :
26890 /* set values into ret array */
26891 /* XXX: primitive to make array from valstack slice */
26892 n = duk_get_top(ctx);
26893 for (i = 2; i < n; i++) {
26894 duk_dup(ctx, i);
26895 duk_put_prop_index(ctx, 1, i - 2);
26896 }
26897 duk_dup(ctx, 1);
26898 return 1;
26899}
26900
26902 duk_hthread *thr = (duk_hthread *) ctx;
26903 duk_activation *act;
26905 duk_uint_fast32_t line;
26906 duk_int_t level;
26907
26908 /* -1 = top callstack entry, callstack[callstack_top - 1]
26909 * -callstack_top = bottom callstack entry, callstack[0]
26910 */
26911 level = duk_to_int(ctx, 0);
26912 if (level >= 0 || -level > (duk_int_t) thr->callstack_top) {
26913 return 0;
26914 }
26915 DUK_ASSERT(level >= -((duk_int_t) thr->callstack_top) && level <= -1);
26916 act = thr->callstack + thr->callstack_top + level;
26917
26918 duk_push_object(ctx);
26919
26920 duk_push_tval(ctx, &act->tv_func);
26921
26922 /* Relevant PC is just before current one because PC is
26923 * post-incremented. This should match what error augment
26924 * code does.
26925 */
26926 pc = duk_hthread_get_act_prev_pc(thr, act);
26927 duk_push_uint(ctx, (duk_uint_t) pc);
26928
26929#if defined(DUK_USE_PC2LINE)
26930 line = duk_hobject_pc2line_query(ctx, -2, pc);
26931#else
26932 line = 0;
DUK_INTERNAL_DECL duk_uint_fast32_t duk_hthread_get_act_prev_pc(duk_hthread *thr, duk_activation *act)
DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_act(duk_context *ctx)

◆ duk_bi_duktape_object_compact()

DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_compact ( duk_context * ctx)

Definition at line 27067 of file duktape-1.8.0/src/duktape.c.

27068 {
27070 1 /*idx_value*/,
27071 2 /*idx_replacer*/,
DUK_INTERNAL_DECL void duk_bi_json_parse_helper(duk_context *ctx, duk_idx_t idx_value, duk_idx_t idx_reviver, duk_small_uint_t flags)

◆ duk_bi_duktape_object_dec()

DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_dec ( duk_context * ctx)

Definition at line 27021 of file duktape-1.8.0/src/duktape.c.

27024 {
27026 1 /*idx_value*/,
27027 2 /*idx_replacer*/,
27028 3 /*idx_space*/,
27030 DUK_JSON_FLAG_ASCII_ONLY /*flags*/);
27031#endif
27032 } else {
27033 return DUK_RET_TYPE_ERROR;
27034 }
27035 return 1;
27036}
27037
27039 duk_hthread *thr = (duk_hthread *) ctx;
27040 duk_hstring *h_str;
27041
27042 DUK_UNREF(thr);
27043
27044 /* Vararg function: must be careful to check/require arguments.
27045 * The JSON helpers accept invalid indices and treat them like
27046 * non-existent optional parameters.
27047 */
27048
27049 h_str = duk_require_hstring(ctx, 0);
27051
27052 if (h_str == DUK_HTHREAD_STRING_HEX(thr)) {
27053 duk_set_top(ctx, 2);
27054 duk_hex_decode(ctx, 1);
27055 DUK_ASSERT_TOP(ctx, 2);
27056 } else if (h_str == DUK_HTHREAD_STRING_BASE64(thr)) {
27057 duk_set_top(ctx, 2);
27058 duk_base64_decode(ctx, 1);
27059 DUK_ASSERT_TOP(ctx, 2);
27060#ifdef DUK_USE_JX
27061 } else if (h_str == DUK_HTHREAD_STRING_JX(thr)) {
#define DUK_HTHREAD_STRING_BASE64(thr)
#define DUK_HTHREAD_STRING_JX(thr)
DUK_INTERNAL_DECL void duk_bi_json_stringify_helper(duk_context *ctx, duk_idx_t idx_value, duk_idx_t idx_replacer, duk_idx_t idx_space, duk_small_uint_t flags)
DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_dec(duk_context *ctx)
DUK_EXTERNAL void duk_require_valid_index(duk_context *ctx, duk_idx_t index)
#define DUK_HTHREAD_STRING_HEX(thr)
DUK_EXTERNAL void duk_hex_decode(duk_context *ctx, duk_idx_t index)
#define DUK_JSON_FLAG_ASCII_ONLY

◆ duk_bi_duktape_object_enc()

DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_enc ( duk_context * ctx)

Definition at line 26974 of file duktape-1.8.0/src/duktape.c.

26983 {
26984 /* Get. */
26985 DUK_ASSERT(duk_get_top(ctx) == 1);
26987 return 1;
26988 }
26989}
26990
26992 duk_hthread *thr = (duk_hthread *) ctx;
26993 duk_hstring *h_str;
26994
26995 DUK_UNREF(thr);
26996
26997 /* Vararg function: must be careful to check/require arguments.
26998 * The JSON helpers accept invalid indices and treat them like
26999 * non-existent optional parameters.
27000 */
27001
27002 h_str = duk_require_hstring(ctx, 0);
27004
27005 if (h_str == DUK_HTHREAD_STRING_HEX(thr)) {
27006 duk_set_top(ctx, 2);
27007 duk_hex_encode(ctx, 1);
27008 DUK_ASSERT_TOP(ctx, 2);
27009 } else if (h_str == DUK_HTHREAD_STRING_BASE64(thr)) {
27010 duk_set_top(ctx, 2);
27011 duk_base64_encode(ctx, 1);
27012 DUK_ASSERT_TOP(ctx, 2);
27013#ifdef DUK_USE_JX
27014 } else if (h_str == DUK_HTHREAD_STRING_JX(thr)) {
27016 1 /*idx_value*/,
27017 2 /*idx_replacer*/,
27018 3 /*idx_space*/,
DUK_EXTERNAL const char * duk_hex_encode(duk_context *ctx, duk_idx_t index)
#define DUK_STRIDX_INT_FINALIZER
DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_enc(duk_context *ctx)

◆ duk_bi_duktape_object_fin()

DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_fin ( duk_context * ctx)

Definition at line 26954 of file duktape-1.8.0/src/duktape.c.

26971 {
26972 (void) duk_require_hobject(ctx, 0);

◆ duk_bi_duktape_object_gc()

DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_gc ( duk_context * ctx)

Definition at line 26934 of file duktape-1.8.0/src/duktape.c.

26951 {
26952#ifdef DUK_USE_MARK_AND_SWEEP

◆ duk_bi_duktape_object_info()

DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_info ( duk_context * ctx)

Definition at line 26770 of file duktape-1.8.0/src/duktape.c.

26771 : it might seem that vararg multipurpose functions
26772 * like fin(), enc(), and dec() are not very size optimal, but using a single
26773 * user-visible Ecmascript function saves a lot of run-time footprint; each
26774 * Function instance takes >100 bytes. Using a shared native helper and a
26775 * 'magic' value won't save much if there are multiple Function instances
26776 * anyway.
26777 */
26778
26779/* include removed: duk_internal.h */
26780
26781/* Raw helper to extract internal information / statistics about a value.
26782 * The return values are version specific and must not expose anything
26783 * that would lead to security issues (e.g. exposing compiled function
26784 * 'data' buffer might be an issue). Currently only counts and sizes and
26785 * such are given so there should not be a security impact.
26786 */
26788 duk_hthread *thr = (duk_hthread *) ctx;
26789 duk_tval *tv;
26790 duk_heaphdr *h;
26791 duk_int_t i, n;
26792
26793 DUK_UNREF(thr);
26794
26795 /* result array */
26796 duk_push_array(ctx); /* -> [ val arr ] */
26797
26798 /* type tag (public) */
26799 duk_push_int(ctx, duk_get_type(ctx, 0));
26800
26801 /* address */
26802 tv = duk_get_tval(ctx, 0);
26803 DUK_ASSERT(tv != NULL); /* because arg count is 1 */
26805 h = DUK_TVAL_GET_HEAPHDR(tv);
26806 duk_push_pointer(ctx, (void *) h);
26807 } else {
26808 /* internal type tag */
26810 goto done;
26811 }
26812 DUK_ASSERT(h != NULL);
26813
26814 /* refcount */
26815#ifdef DUK_USE_REFERENCE_COUNTING
26817#else
26818 duk_push_undefined(ctx);
26819#endif
26820
26821 /* heaphdr size and additional allocation size, followed by
26822 * type specific stuff (with varying value count)
26823 */
26825 case DUK_HTYPE_STRING: {
26826 duk_hstring *h_str = (duk_hstring *) h;
26827 duk_push_uint(ctx, (duk_uint_t) (sizeof(duk_hstring) + DUK_HSTRING_GET_BYTELEN(h_str) + 1));
26828 break;
26829 }
26830 case DUK_HTYPE_OBJECT: {
26831 duk_hobject *h_obj = (duk_hobject *) h;
26832 duk_small_uint_t hdr_size;
26834 hdr_size = (duk_small_uint_t) sizeof(duk_hcompiledfunction);
26835 } else if (DUK_HOBJECT_IS_NATIVEFUNCTION(h_obj)) {
26836 hdr_size = (duk_small_uint_t) sizeof(duk_hnativefunction);
26837 } else if (DUK_HOBJECT_IS_THREAD(h_obj)) {
26838 hdr_size = (duk_small_uint_t) sizeof(duk_hthread);
26839#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
26840 } else if (DUK_HOBJECT_IS_BUFFEROBJECT(h_obj)) {
26841 hdr_size = (duk_small_uint_t) sizeof(duk_hbufferobject);
26842#endif
26843 } else {
26844 hdr_size = (duk_small_uint_t) sizeof(duk_hobject);
26845 }
26846 duk_push_uint(ctx, (duk_uint_t) hdr_size);
26849 /* Note: e_next indicates the number of gc-reachable entries
26850 * in the entry part, and also indicates the index where the
26851 * next new property would be inserted. It does *not* indicate
26852 * the number of non-NULL keys present in the object. That
26853 * value could be counted separately but requires a pass through
26854 * the key list.
26855 */
26861 if (h_data) {
26863 } else {
26864 duk_push_uint(ctx, 0);
26865 }
26866 }
26867 break;
26868 }
26869 case DUK_HTYPE_BUFFER: {
26870 duk_hbuffer *h_buf = (duk_hbuffer *) h;
26871 if (DUK_HBUFFER_HAS_DYNAMIC(h_buf)) {
26872 if (DUK_HBUFFER_HAS_EXTERNAL(h_buf)) {
26874 } else {
26875 /* When alloc_size == 0 the second allocation may not
26876 * actually exist.
26877 */
26879 }
26881 } else {
26882 duk_push_uint(ctx, (duk_uint_t) (sizeof(duk_hbuffer_fixed) + DUK_HBUFFER_GET_SIZE(h_buf) + 1));
#define duk_push_size_t(ctx, val)
DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_info(duk_context *ctx)
DUK_EXTERNAL void duk_push_pointer(duk_context *ctx, void *val)
#define DUK_HOBJECT_P_ALLOC_SIZE(h)
static void save(LexState *ls, int c)

References DUK_ASSERT, duk_get_tval(), duk_get_type(), DUK_HBUFFER_GET_SIZE, DUK_HBUFFER_HAS_DYNAMIC, DUK_HBUFFER_HAS_EXTERNAL, DUK_HCOMPILEDFUNCTION_GET_DATA, DUK_HEAPHDR_GET_REFCOUNT, DUK_HEAPHDR_GET_TYPE, DUK_HOBJECT_GET_ASIZE, DUK_HOBJECT_GET_ENEXT, DUK_HOBJECT_GET_ESIZE, DUK_HOBJECT_GET_HSIZE, DUK_HOBJECT_IS_BUFFEROBJECT, DUK_HOBJECT_IS_COMPILEDFUNCTION, DUK_HOBJECT_IS_NATIVEFUNCTION, DUK_HOBJECT_IS_THREAD, DUK_HOBJECT_P_ALLOC_SIZE, DUK_HSTRING_GET_BYTELEN, DUK_HTYPE_BUFFER, DUK_HTYPE_OBJECT, DUK_HTYPE_STRING, duk_push_array(), duk_push_int(), duk_push_pointer(), duk_push_size_t, duk_push_uint(), duk_push_undefined(), DUK_TVAL_GET_HEAPHDR, DUK_TVAL_GET_TAG, DUK_TVAL_IS_HEAP_ALLOCATED, DUK_UNREF, duk_hthread::heap, and NULL.

◆ duk_bi_error_constructor_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_error_constructor_shared ( duk_context * ctx)

Definition at line 27079 of file duktape-1.8.0/src/duktape.c.

27084 {
27085 DUK_ASSERT_TOP(ctx, 1);
27086 duk_compact(ctx, 0);
27087 return 1; /* return the argument object */
27088}
27089#line 1 "duk_bi_error.c"
27090/*
27091 * Error built-ins
27092 */
27093
27094/* include removed: duk_internal.h */
27095
27097 /* Behavior for constructor and non-constructor call is
27098 * the same except for augmenting the created error. When
27099 * called as a constructor, the caller (duk_new()) will handle
27100 * augmentation; when called as normal function, we need to do
27101 * it here.
27102 */
27103
27104 duk_hthread *thr = (duk_hthread *) ctx;
27105 duk_small_int_t bidx_prototype = duk_get_current_magic(ctx);
27106
27107 /* same for both error and each subclass like TypeError */
27108 duk_uint_t flags_and_class = DUK_HOBJECT_FLAG_EXTENSIBLE |
27110
27111 DUK_UNREF(thr);
27112
27113 duk_push_object_helper(ctx, flags_and_class, bidx_prototype);
27114
27115 /* If message is undefined, the own property 'message' is not set at
27116 * all to save property space. An empty message is inherited anyway.
27117 */
27118 if (!duk_is_undefined(ctx, 0)) {
DUK_INTERNAL_DECL duk_ret_t duk_bi_error_constructor_shared(duk_context *ctx)
#define DUK_HOBJECT_CLASS_ERROR

References DUK_ASSERT_TOP, and duk_compact().

◆ duk_bi_error_prototype_filename_getter()

DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_filename_getter ( duk_context * ctx)

Definition at line 27374 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_error_prototype_filename_setter()

DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_filename_setter ( duk_context * ctx)

Definition at line 27449 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_error_prototype_linenumber_getter()

DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_linenumber_getter ( duk_context * ctx)

Definition at line 27378 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_error_prototype_linenumber_setter()

DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_linenumber_setter ( duk_context * ctx)

Definition at line 27453 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_error_prototype_stack_getter()

DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_stack_getter ( duk_context * ctx)

Definition at line 27370 of file duktape-1.8.0/src/duktape.c.

27371 {
27372 return 0;

◆ duk_bi_error_prototype_stack_setter()

DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_stack_setter ( duk_context * ctx)

Definition at line 27445 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_error_prototype_to_string()

DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_to_string ( duk_context * ctx)

Definition at line 27120 of file duktape-1.8.0/src/duktape.c.

27129 {
27130 duk_err_augment_error_create(thr, thr, NULL, 0, 1 /*noblame_fileline*/);
27131 }
27132#endif
27133
27134 return 1;
27135}
27136
27138 /* XXX: optimize with more direct internal access */
27139
27140 duk_push_this(ctx);
27142
27143 /* [ ... this ] */
27144
27146 if (duk_is_undefined(ctx, -1)) {
27147 duk_pop(ctx);
27148 duk_push_string(ctx, "Error");
27149 } else {
27150 duk_to_string(ctx, -1);
27151 }
27152
27153 /* [ ... this name ] */
27154
27155 /* XXX: Are steps 6 and 7 in E5 Section 15.11.4.4 duplicated by
27156 * accident or are they actually needed? The first ToString()
27157 * could conceivably return 'undefined'.
27158 */
27160 if (duk_is_undefined(ctx, -1)) {
27161 duk_pop(ctx);
27162 duk_push_string(ctx, "");
27163 } else {
27164 duk_to_string(ctx, -1);
27165 }
27166
DUK_INTERNAL_DECL duk_hobject * duk_require_hobject_or_lfunc_coerce(duk_context *ctx, duk_idx_t index)
#define DUK_STRIDX_MESSAGE
DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_to_string(duk_context *ctx)
DUK_INTERNAL_DECL void duk_err_augment_error_create(duk_hthread *thr, duk_hthread *thr_callstack, const char *filename, duk_int_t line, duk_bool_t noblame_fileline)

◆ duk_bi_function_constructor()

DUK_INTERNAL_DECL duk_ret_t duk_bi_function_constructor ( duk_context * ctx)

Definition at line 27463 of file duktape-1.8.0/src/duktape.c.

27466 {
27468}
27469
27472}
27473#line 1 "duk_bi_function.c"
27474/*
27475 * Function built-ins
27476 */
27477
27478/* include removed: duk_internal.h */
27479
27481 duk_hthread *thr = (duk_hthread *) ctx;
27482 duk_hstring *h_sourcecode;
27483 duk_idx_t nargs;
27484 duk_idx_t i;
27485 duk_small_uint_t comp_flags;
27487 duk_hobject *outer_lex_env;
27488 duk_hobject *outer_var_env;
27489
27490 /* normal and constructor calls have identical semantics */
27491
27492 nargs = duk_get_top(ctx);
27493 for (i = 0; i < nargs; i++) {
27494 duk_to_string(ctx, i);
27495 }
27496
27497 if (nargs == 0) {
27498 duk_push_string(ctx, "");
27499 duk_push_string(ctx, "");
27500 } else if (nargs == 1) {
27501 /* XXX: cover this with the generic >1 case? */
27502 duk_push_string(ctx, "");
27503 } else {
27504 duk_insert(ctx, 0); /* [ arg1 ... argN-1 body] -> [body arg1 ... argN-1] */
27505 duk_push_string(ctx, ",");
27506 duk_insert(ctx, 1);
27507 duk_join(ctx, nargs - 1);
27508 }
27509
27510 /* [ body formals ], formals is comma separated list that needs to be parsed */
27511
27512 DUK_ASSERT_TOP(ctx, 2);
27513
27514 /* XXX: this placeholder is not always correct, but use for now.
27515 * It will fail in corner cases; see test-dev-func-cons-args.js.
27516 */
27517 duk_push_string(ctx, "function(");
27518 duk_dup(ctx, 1);
27519 duk_push_string(ctx, "){");
27520 duk_dup(ctx, 0);
27521 duk_push_string(ctx, "}");
27522 duk_concat(ctx, 5);
27523
27524 /* [ body formals source ] */
27525
27526 DUK_ASSERT_TOP(ctx, 3);
27527
27528 /* strictness is not inherited, intentional */
27529 comp_flags = DUK_JS_COMPILE_FLAG_FUNCEXPR;
27530
27531 duk_push_hstring_stridx(ctx, DUK_STRIDX_COMPILE); /* XXX: copy from caller? */ /* XXX: ignored now */
27532 h_sourcecode = duk_require_hstring(ctx, -2);
27533 duk_js_compile(thr,
27534 (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_sourcecode),
27535 (duk_size_t) DUK_HSTRING_GET_BYTELEN(h_sourcecode),
27536 comp_flags);
27537 func = (duk_hcompiledfunction *) duk_get_hobject(ctx, -1);
27538 DUK_ASSERT(func != NULL);
DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_linenumber_setter(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_function_constructor(duk_context *ctx)
#define DUK_STRIDX_COMPILE

◆ duk_bi_function_prototype()

DUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype ( duk_context * ctx)

Definition at line 27540 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_function_prototype_apply()

DUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype_apply ( duk_context * ctx)

Definition at line 27613 of file duktape-1.8.0/src/duktape.c.

27613 {
27614 duk_push_sprintf(ctx, "function %s() {\"bound\"}", (const char *) func_name);
27615 } else {
27616 goto type_error;
27617 }
27618 } else if (DUK_TVAL_IS_LIGHTFUNC(tv)) {
27620 } else {
27621 goto type_error;
27622 }
27623
27624 return 1;
27625
27626 type_error:
27627 return DUK_RET_TYPE_ERROR;
27628}
27629
27631 duk_idx_t len;
27632 duk_idx_t i;
27633
27634 DUK_ASSERT_TOP(ctx, 2); /* not a vararg function */
27635
27636 duk_push_this(ctx);
27637 if (!duk_is_callable(ctx, -1)) {
27638 DUK_DDD(DUK_DDDPRINT("func is not callable"));
27639 goto type_error;
27640 }
27641 duk_insert(ctx, 0);
27642 DUK_ASSERT_TOP(ctx, 3);
27643
27644 DUK_DDD(DUK_DDDPRINT("func=%!iT, thisArg=%!iT, argArray=%!iT",
27645 (duk_tval *) duk_get_tval(ctx, 0),
27646 (duk_tval *) duk_get_tval(ctx, 1),
27647 (duk_tval *) duk_get_tval(ctx, 2)));
27648
27649 /* [ func thisArg argArray ] */
27650
27651 if (duk_is_null_or_undefined(ctx, 2)) {
27652 DUK_DDD(DUK_DDDPRINT("argArray is null/undefined, no args"));
27653 len = 0;
27654 } else if (!duk_is_object(ctx, 2)) {
27655 goto type_error;
27656 } else {
27657 DUK_DDD(DUK_DDDPRINT("argArray is an object"));
27658
27659 /* XXX: make this an internal helper */
27661 len = (duk_idx_t) duk_to_uint32(ctx, -1); /* ToUint32() coercion required */
27662 duk_pop(ctx);
27663
27664 duk_require_stack(ctx, len);
27665
27666 DUK_DDD(DUK_DDDPRINT("argArray length is %ld", (long) len));
27667 for (i = 0; i < len; i++) {
27668 duk_get_prop_index(ctx, 2, i);
DUK_INTERNAL_DECL void duk_push_lightfunc_tostring(duk_context *ctx, duk_tval *tv)
DUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype_apply(duk_context *ctx)

◆ duk_bi_function_prototype_bind()

DUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype_bind ( duk_context * ctx)

Definition at line 27707 of file duktape-1.8.0/src/duktape.c.

27724 {
27725 duk_hobject *h_bound;
27726 duk_hobject *h_target;
27727 duk_idx_t nargs;
27728 duk_idx_t i;
27729
27730 /* vararg function, careful arg handling (e.g. thisArg may not be present) */
27731 nargs = duk_get_top(ctx); /* = 1 + arg count */
27732 if (nargs == 0) {
27733 duk_push_undefined(ctx);
27734 nargs++;
27735 }
27736 DUK_ASSERT(nargs >= 1);
27737
27738 duk_push_this(ctx);
27739 if (!duk_is_callable(ctx, -1)) {
27740 DUK_DDD(DUK_DDDPRINT("func is not callable"));
27741 goto type_error;
27742 }
27743
27744 /* [ thisArg arg1 ... argN func ] (thisArg+args == nargs total) */
27745 DUK_ASSERT_TOP(ctx, nargs + 1);
27746
27747 /* create bound function object */
27754 h_bound = duk_get_hobject(ctx, -1);
27755 DUK_ASSERT(h_bound != NULL);
27756
27757 /* [ thisArg arg1 ... argN func boundFunc ] */
27758 duk_dup(ctx, -2); /* func */
27760
27761 duk_dup(ctx, 0); /* thisArg */
27763
27764 duk_push_array(ctx);
27765
27766 /* [ thisArg arg1 ... argN func boundFunc argArray ] */
27767
27768 for (i = 0; i < nargs - 1; i++) {
27769 duk_dup(ctx, 1 + i);
27770 duk_put_prop_index(ctx, -2, i);
27771 }
27773
27774 /* [ thisArg arg1 ... argN func boundFunc ] */
27775
27776 /* bound function 'length' property is interesting */
27777 h_target = duk_get_hobject(ctx, -2);
27778 if (h_target == NULL || /* lightfunc */
27780 /* For lightfuncs, simply read the virtual property. */
27781 duk_int_t tmp;
27783 tmp = duk_to_int(ctx, -1) - (nargs - 1); /* step 15.a */
27784 duk_pop(ctx);
27785 duk_push_int(ctx, (tmp < 0 ? 0 : tmp));
27786 } else {
27787 duk_push_int(ctx, 0);
27788 }
27789 duk_xdef_prop_stridx(ctx, -2, DUK_STRIDX_LENGTH, DUK_PROPDESC_FLAGS_NONE); /* attrs in E5 Section 15.3.5.1 */
27790
27791 /* caller and arguments must use the same thrower, [[ThrowTypeError]] */
27794
27795 /* these non-standard properties are copied for convenience */
27796 /* XXX: 'copy properties' API call? */
27801
27802 /* The 'strict' flag is copied to get the special [[Get]] of E5.1
#define DUK_HOBJECT_FLAG_CONSTRUCTABLE

◆ duk_bi_function_prototype_call()

DUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype_call ( duk_context * ctx)

Definition at line 27670 of file duktape-1.8.0/src/duktape.c.

27683 :
27684 return DUK_RET_TYPE_ERROR;
27685}
27686
27688 duk_idx_t nargs;
27689
27690 /* Step 1 is not necessary because duk_call_method() will take
27691 * care of it.
27692 */
27693
27694 /* vararg function, thisArg needs special handling */
27695 nargs = duk_get_top(ctx); /* = 1 + arg count */
27696 if (nargs == 0) {
27697 duk_push_undefined(ctx);
27698 nargs++;
27699 }
DUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype_call(duk_context *ctx)

◆ duk_bi_function_prototype_to_string()

DUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype_to_string ( duk_context * ctx)

Definition at line 27546 of file duktape-1.8.0/src/duktape.c.

27557 {
27558 /* ignore arguments, return undefined (E5 Section 15.3.4) */
27559 DUK_UNREF(ctx);
27560 return 0;
27561}
27562
27564 duk_tval *tv;
27565
27566 /*
27567 * E5 Section 15.3.4.2 places few requirements on the output of
27568 * this function:
27569 *
27570 * - The result is an implementation dependent representation
27571 * of the function; in particular
27572 *
27573 * - The result must follow the syntax of a FunctionDeclaration.
27574 * In particular, the function must have a name (even in the
27575 * case of an anonymous function or a function with an empty
27576 * name).
27577 *
27578 * - Note in particular that the output does NOT need to compile
27579 * into anything useful.
27580 */
27581
27582
27583 /* XXX: faster internal way to get this */
27584 duk_push_this(ctx);
27585 tv = duk_get_tval(ctx, -1);
27586 DUK_ASSERT(tv != NULL);
27587
27588 if (DUK_TVAL_IS_OBJECT(tv)) {
27590 const char *func_name;
27591
27592 /* Function name: missing/undefined is mapped to empty string,
27593 * otherwise coerce to string.
27594 */
27595 /* XXX: currently no handling for non-allowed identifier characters,
27596 * e.g. a '{' in the function name.
27597 */
27599 if (duk_is_undefined(ctx, -1)) {
27600 func_name = "";
27601 } else {
27602 func_name = duk_to_string(ctx, -1);
27603 DUK_ASSERT(func_name != NULL);
27604 }
27605
27606 /* Indicate function type in the function body using a dummy
27607 * directive.
27608 */
27610 duk_push_sprintf(ctx, "function %s() {\"ecmascript\"}", (const char *) func_name);
27611 } else if (DUK_HOBJECT_HAS_NATIVEFUNCTION(obj)) {
DUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype_to_string(duk_context *ctx)

◆ duk_bi_global_object_decode_uri()

DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_decode_uri ( duk_context * ctx)

Definition at line 28489 of file duktape-1.8.0/src/duktape.c.

28490 {
28491 duk_double_t d = duk_to_number(ctx, 0);

References DUK_ISNAN, duk_push_boolean(), and duk_to_number().

◆ duk_bi_global_object_decode_uri_component()

DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_decode_uri_component ( duk_context * ctx)

Definition at line 28493 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_global_object_encode_uri()

DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_encode_uri ( duk_context * ctx)

Definition at line 28497 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_global_object_encode_uri_component()

DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_encode_uri_component ( duk_context * ctx)

Definition at line 28501 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_global_object_escape()

DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_escape ( duk_context * ctx)

Definition at line 28506 of file duktape-1.8.0/src/duktape.c.

28506 {
28508}
DUK_LOCAL const duk_uint8_t duk__decode_uri_reserved_table[16]

References duk__decode_uri_reserved_table, duk__transform_callback_decode_uri(), and duk__transform_helper().

◆ duk_bi_global_object_eval()

DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_eval ( duk_context * ctx)

Definition at line 28224 of file duktape-1.8.0/src/duktape.c.

28241 {
28242 duk_hthread *thr = (duk_hthread *) ctx;
28243 duk_hstring *h;
28244 duk_activation *act_caller;
28245 duk_activation *act_eval;
28246 duk_activation *act;
28248 duk_hobject *outer_lex_env;
28249 duk_hobject *outer_var_env;
28250 duk_bool_t this_to_global = 1;
28251 duk_small_uint_t comp_flags;
28252 duk_int_t level = -2;
28253
28254 DUK_ASSERT(duk_get_top(ctx) == 1 || duk_get_top(ctx) == 2); /* 2 when called by debugger */
28255 DUK_ASSERT(thr->callstack_top >= 1); /* at least this function exists */
28256 DUK_ASSERT(((thr->callstack + thr->callstack_top - 1)->flags & DUK_ACT_FLAG_DIRECT_EVAL) == 0 || /* indirect eval */
28257 (thr->callstack_top >= 2)); /* if direct eval, calling activation must exist */
28258
28259 /*
28260 * callstack_top - 1 --> this function
28261 * callstack_top - 2 --> caller (may not exist)
28262 *
28263 * If called directly from C, callstack_top might be 1. If calling
28264 * activation doesn't exist, call must be indirect.
28265 */
28266
28267 h = duk_get_hstring(ctx, 0);
28268 if (!h) {
28269 return 1; /* return arg as-is */
28270 }
28271
28272#if defined(DUK_USE_DEBUGGER_SUPPORT)
28273 /* NOTE: level is used only by the debugger and should never be present
28274 * for an Ecmascript eval().
28275 */
28276 DUK_ASSERT(level == -2); /* by default, use caller's environment */
28277 if (duk_get_top(ctx) >= 2 && duk_is_number(ctx, 1)) {
28278 level = duk_get_int(ctx, 1);
28279 }
28280 DUK_ASSERT(level <= -2); /* This is guaranteed by debugger code. */
28281#endif
28282
28283 /* [ source ] */
28284
28285 comp_flags = DUK_JS_COMPILE_FLAG_EVAL;
28286 act_eval = thr->callstack + thr->callstack_top - 1; /* this function */
28287 if (thr->callstack_top >= (duk_size_t) -level) {
28288 /* Have a calling activation, check for direct eval (otherwise
28289 * assume indirect eval.
28290 */
28291 act_caller = thr->callstack + thr->callstack_top + level; /* caller */
28292 if ((act_caller->flags & DUK_ACT_FLAG_STRICT) &&
28293 (act_eval->flags & DUK_ACT_FLAG_DIRECT_EVAL)) {
28294 /* Only direct eval inherits strictness from calling code
28295 * (E5.1 Section 10.1.1).
28296 */
28297 comp_flags |= DUK_JS_COMPILE_FLAG_STRICT;
28298 }
28299 } else {
28300 DUK_ASSERT((act_eval->flags & DUK_ACT_FLAG_DIRECT_EVAL) == 0);
28301 }
28302 act_caller = NULL; /* avoid dereference after potential callstack realloc */
28303 act_eval = NULL;
28304
28305 duk_push_hstring_stridx(ctx, DUK_STRIDX_INPUT); /* XXX: copy from caller? */
28306 duk_js_compile(thr,
28307 (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h),
28309 comp_flags);
28310 func = (duk_hcompiledfunction *) duk_get_hobject(ctx, -1);
28311 DUK_ASSERT(func != NULL);
28313
28314 /* [ source template ] */
28315
28316 /* E5 Section 10.4.2 */
28317 DUK_ASSERT(thr->callstack_top >= 1);
28318 act = thr->callstack + thr->callstack_top - 1; /* this function */
28319 if (act->flags & DUK_ACT_FLAG_DIRECT_EVAL) {
28320 DUK_ASSERT(thr->callstack_top >= 2);
28321 act = thr->callstack + thr->callstack_top + level; /* caller */
28322 if (act->lex_env == NULL) {
28323 DUK_ASSERT(act->var_env == NULL);
28324 DUK_DDD(DUK_DDDPRINT("delayed environment initialization"));
28325
28326 /* this may have side effects, so re-lookup act */
28328 act = thr->callstack + thr->callstack_top + level;
28329 }
28330 DUK_ASSERT(act->lex_env != NULL);
28331 DUK_ASSERT(act->var_env != NULL);
28332
28333 this_to_global = 0;
28334
28335 if (DUK_HOBJECT_HAS_STRICT((duk_hobject *) func)) {
28336 duk_hobject *new_env;
28337 duk_hobject *act_lex_env;
28338
28339 DUK_DDD(DUK_DDDPRINT("direct eval call to a strict function -> "
28340 "var_env and lex_env to a fresh env, "
28341 "this_binding to caller's this_binding"));
28342
28343 act_lex_env = act->lex_env;
28344 act = NULL; /* invalidated */
28345
28349 act_lex_env);
28350 new_env = duk_require_hobject(ctx, -1);
28351 DUK_ASSERT(new_env != NULL);
28352 DUK_DDD(DUK_DDDPRINT("new_env allocated: %!iO",
28353 (duk_heaphdr *) new_env));
28354
28355 outer_lex_env = new_env;
28356 outer_var_env = new_env;
28357
28358 duk_insert(ctx, 0); /* stash to bottom of value stack to keep new_env reachable for duration of eval */
28359
28360 /* compiler's responsibility */
28362 } else {
28363 DUK_DDD(DUK_DDDPRINT("direct eval call to a non-strict function -> "
28364 "var_env and lex_env to caller's envs, "
28365 "this_binding to caller's this_binding"));
28366
28367 outer_lex_env = act->lex_env;
28368 outer_var_env = act->var_env;
28369
28370 /* compiler's responsibility */
28372 }
28373 } else {
28374 DUK_DDD(DUK_DDDPRINT("indirect eval call -> var_env and lex_env to "
28375 "global object, this_binding to global object"));
28376
28377 this_to_global = 1;
28378 outer_lex_env = thr->builtins[DUK_BIDX_GLOBAL_ENV];
28379 outer_var_env = thr->builtins[DUK_BIDX_GLOBAL_ENV];
28380 }
28381 act = NULL;
28382
28383 /* Eval code doesn't need an automatic .prototype object. */
28384 duk_js_push_closure(thr, func, outer_var_env, outer_lex_env, 0 /*add_auto_proto*/);
28385
28386 /* [ source template closure ] */
28387
28388 if (this_to_global) {
28391 } else {
28392 duk_tval *tv;
28393 DUK_ASSERT(thr->callstack_top >= 2);
28394 act = thr->callstack + thr->callstack_top + level; /* caller */
28395 tv = thr->valstack + act->idx_bottom - 1; /* this is just beneath bottom */

◆ duk_bi_global_object_is_finite()

DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_is_finite ( duk_context * ctx)

Definition at line 28479 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_global_object_is_nan()

DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_is_nan ( duk_context * ctx)

Definition at line 28473 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_global_object_parse_float()

DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_float ( duk_context * ctx)

Definition at line 28444 of file duktape-1.8.0/src/duktape.c.

28445 {
28446 s2n_flags &= ~DUK_S2N_FLAG_ALLOW_AUTO_HEX_INT;
28447 }
28448 } else {
28449 radix = 10;
28450 }
28451
28452 duk_dup(ctx, 0);
28453 duk_numconv_parse(ctx, radix, s2n_flags);
28454 return 1;
28455
28456 ret_nan:
28457 duk_push_nan(ctx);
28458 return 1;
28459}
28460
28462 duk_small_uint_t s2n_flags;
28463 duk_int32_t radix;
28464
28465 DUK_ASSERT_TOP(ctx, 1);
28466 duk_to_string(ctx, 0);
28467
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_float(duk_context *ctx)
DUK_INTERNAL_DECL void duk_numconv_parse(duk_context *ctx, duk_small_int_t radix, duk_small_uint_t flags)

◆ duk_bi_global_object_parse_int()

DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_int ( duk_context * ctx)

Definition at line 28401 of file duktape-1.8.0/src/duktape.c.

28418 {
28419 duk_int32_t radix;
28420 duk_small_uint_t s2n_flags;
28421
28422 DUK_ASSERT_TOP(ctx, 2);
28423 duk_to_string(ctx, 0);
28424
28425 radix = duk_to_int32(ctx, 1);
28426
28427 s2n_flags = DUK_S2N_FLAG_TRIM_WHITE |
28433
28434 /* Specification stripPrefix maps to DUK_S2N_FLAG_ALLOW_AUTO_HEX_INT.
28435 *
28436 * Don't autodetect octals (from leading zeroes), require user code to
28437 * provide an explicit radix 8 for parsing octal. See write-up from Mozilla:
28438 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt#ECMAScript_5_Removes_Octal_Interpretation
28439 */
28440
28441 if (radix != 0) {
28442 if (radix < 2 || radix > 36) {
#define DUK_S2N_FLAG_ALLOW_MINUS
#define DUK_S2N_FLAG_ALLOW_AUTO_HEX_INT
#define DUK_S2N_FLAG_ALLOW_PLUS
#define DUK_S2N_FLAG_ALLOW_LEADING_ZERO
#define DUK_S2N_FLAG_ALLOW_GARBAGE

◆ duk_bi_global_object_print_helper()

DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_print_helper ( duk_context * ctx)

Definition at line 28526 of file duktape-1.8.0/src/duktape.c.

28527 {
28528 return duk__transform_helper(ctx, duk__transform_callback_unescape, (const void *) NULL);
28529}
28530#else /* DUK_USE_SECTION_B */
28532 DUK_UNREF(ctx);
28534}
28535
28537 DUK_UNREF(ctx);
28539}
28540#endif /* DUK_USE_SECTION_B */
28541
28542#if defined(DUK_USE_BROWSER_LIKE) && (defined(DUK_USE_FILE_IO) || defined(DUK_USE_DEBUGGER_SUPPORT))
28544 duk_hthread *thr = (duk_hthread *) ctx;
28545 duk_int_t magic;
28546 duk_idx_t nargs;
28547 const duk_uint8_t *buf;
28548 duk_size_t sz_buf;
28549 const char nl = (const char) DUK_ASC_LF;
28550#ifndef DUK_USE_PREFER_SIZE
28551 duk_uint8_t buf_stack[256];
28552#endif
28553#ifdef DUK_USE_FILE_IO
28554 duk_file *f_out;
28555#endif
28556
28557 DUK_UNREF(thr);
28558
28559 magic = duk_get_current_magic(ctx);
28560 DUK_UNREF(magic);
28561
28562 nargs = duk_get_top(ctx);
28563
28564 /* If argument count is 1 and first argument is a buffer, write the buffer
28565 * as raw data into the file without a newline; this allows exact control
28566 * over stdout/stderr without an additional entrypoint (useful for now).
28567 *
28568 * Otherwise current print/alert semantics are to ToString() coerce
28569 * arguments, join them with a single space, and append a newline.
28570 */
28571
28572 if (nargs == 1 && duk_is_buffer(ctx, 0)) {
28573 buf = (const duk_uint8_t *) duk_get_buffer(ctx, 0, &sz_buf);
28574 DUK_ASSERT(buf != NULL);
28575 } else if (nargs > 0) {
28576#ifdef DUK_USE_PREFER_SIZE
28577 /* Compact but lots of churn. */
28579 duk_insert(ctx, 0);
28580 duk_join(ctx, nargs);
28581 duk_push_string(thr, "\n");
28582 duk_concat(ctx, 2);
28583 buf = (const duk_uint8_t *) duk_get_lstring(ctx, -1, &sz_buf);
28584 DUK_ASSERT(buf != NULL);
28585#else /* DUK_USE_PREFER_SIZE */
28586 /* Higher footprint, less churn. */
28587 duk_idx_t i;
28588 duk_size_t sz_str;
28589 const duk_uint8_t *p_str;
28590 duk_uint8_t *p;
28591
28592 sz_buf = (duk_size_t) nargs; /* spaces (nargs - 1) + newline */
28593 for (i = 0; i < nargs; i++) {
28594 (void) duk_to_lstring(ctx, i, &sz_str);
28595 sz_buf += sz_str;
28596 }
28597
28598 if (sz_buf <= sizeof(buf_stack)) {
28599 p = (duk_uint8_t *) buf_stack;
28600 } else {
28601 p = (duk_uint8_t *) duk_push_fixed_buffer(ctx, sz_buf);
28602 DUK_ASSERT(p != NULL);
28603 }
28604
28605 buf = (const duk_uint8_t *) p;
28606 for (i = 0; i < nargs; i++) {
28607 p_str = (const duk_uint8_t *) duk_get_lstring(ctx, i, &sz_str);
28608 DUK_ASSERT(p_str != NULL);
28609 DUK_MEMCPY((void *) p, (const void *) p_str, sz_str);
28610 p += sz_str;
28611 *p++ = (duk_uint8_t) (i == nargs - 1 ? DUK_ASC_LF : DUK_ASC_SPACE);
28612 }
28613 DUK_ASSERT((const duk_uint8_t *) p == buf + sz_buf);
28614#endif /* DUK_USE_PREFER_SIZE */
28615 } else {
28616 buf = (const duk_uint8_t *) &nl;
28617 sz_buf = 1;
28618 }
28619
28620 /* 'buf' contains the string to write, 'sz_buf' contains the length
28621 * (which may be zero).
28622 */
28623 DUK_ASSERT(buf != NULL);
28624
28625 if (sz_buf == 0) {
28626 return 0;
#define DUK_STRIDX_SPACE
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_unescape(duk_context *ctx)
#define DUK_ASC_LF
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_escape(duk_context *ctx)

References duk__transform_callback_unescape(), duk__transform_helper(), and NULL.

◆ duk_bi_global_object_require()

DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_require ( duk_context * ctx)

Definition at line 28828 of file duktape-1.8.0/src/duktape.c.

28845 {
28846 const char *str_req_id; /* requested identifier */
28847 const char *str_mod_id; /* require.id of current module */
28848 duk_int_t pcall_rc;
28849
28850 /* NOTE: we try to minimize code size by avoiding unnecessary pops,
28851 * so the stack looks a bit cluttered in this function. DUK_ASSERT_TOP()
28852 * assertions are used to ensure stack configuration is correct at each
28853 * step.
28854 */
28855
28856 /*
28857 * Resolve module identifier into canonical absolute form.
28858 */
28859
28860 str_req_id = duk_require_string(ctx, DUK__IDX_REQUESTED_ID);
28863 str_mod_id = duk_get_string(ctx, DUK__IDX_REQUIRE_ID); /* ignore non-strings */
28864 DUK_DDD(DUK_DDDPRINT("resolve module id: requested=%!T, currentmodule=%!T",
28867 duk__bi_global_resolve_module_id(ctx, str_req_id, str_mod_id);
28868 str_req_id = NULL;
28869 str_mod_id = NULL;
28870 DUK_DDD(DUK_DDDPRINT("resolved module id: requested=%!T, currentmodule=%!T, result=%!T, lastcomp=%!T",
28875
28876 /* [ requested_id require require.id resolved_id last_comp ] */
28878
28879 /*
28880 * Cached module check.
28881 *
28882 * If module has been loaded or its loading has already begun without
28883 * finishing, return the same cached value ('exports'). The value is
28884 * registered when module load starts so that circular references can
28885 * be supported to some extent.
28886 */
28887
28889 duk_get_prop_stridx(ctx, DUK__IDX_DUKTAPE, DUK_STRIDX_MOD_LOADED); /* Duktape.modLoaded */
28892
28894 if (duk_get_prop(ctx, DUK__IDX_MODLOADED)) {
28895 /* [ requested_id require require.id resolved_id last_comp Duktape Duktape.modLoaded Duktape.modLoaded[id] ] */
28896 DUK_DD(DUK_DDPRINT("module already loaded: %!T",
28898 duk_get_prop_stridx(ctx, -1, DUK_STRIDX_EXPORTS); /* return module.exports */
28899 return 1;
28900 }
28902
28903 /* [ requested_id require require.id resolved_id last_comp Duktape Duktape.modLoaded undefined ] */
28904
28905 /*
28906 * Module not loaded (and loading not started previously).
28907 *
28908 * Create a new require() function with 'id' set to resolved ID
28909 * of module being loaded. Also create 'exports' and 'module'
28910 * tables but don't register exports to the loaded table yet.
28911 * We don't want to do that unless the user module search callbacks
28912 * succeeds in finding the module.
28913 */
28914
28915 DUK_D(DUK_DPRINT("loading module %!T, resolution base %!T, requested ID %!T -> resolved ID %!T, last component %!T",
28921
28922 /* Fresh require: require.id is left configurable (but not writable)
28923 * so that is not easy to accidentally tweak it, but it can still be
28924 * done with Object.defineProperty().
28925 *
28926 * XXX: require.id could also be just made non-configurable, as there
28927 * is no practical reason to touch it.
28928 */
28933 duk_xdef_prop_stridx(ctx, DUK__IDX_FRESH_REQUIRE, DUK_STRIDX_ID, DUK_PROPDESC_FLAGS_C); /* a fresh require() with require.id = resolved target module id */
28934
28935 /* Module table:
28936 * - module.exports: initial exports table (may be replaced by user)
28937 * - module.id is non-writable and non-configurable, as the CommonJS
28938 * spec suggests this if possible
28939 * - module.filename: not set, defaults to resolved ID if not explicitly
28940 * set by modSearch() (note capitalization, not .fileName, matches Node.js)
28941 * - module.name: not set, defaults to last component of resolved ID if
28942 * not explicitly set by modSearch()
28943 */
28944 duk_push_object(ctx); /* exports */
28945 duk_push_object(ctx); /* module */
28948 duk_dup(ctx, DUK__IDX_RESOLVED_ID); /* resolved id: require(id) must return this same module */
28949 duk_xdef_prop_stridx(ctx, DUK__IDX_MODULE, DUK_STRIDX_ID, DUK_PROPDESC_FLAGS_NONE); /* module.id = resolved_id */
28950 duk_compact(ctx, DUK__IDX_MODULE); /* module table remains registered to modLoaded, minimize its size */
28952
28953 DUK_DD(DUK_DDPRINT("module table created: %!T", duk_get_tval(ctx, DUK__IDX_MODULE)));
28954
28955 /* [ requested_id require require.id resolved_id last_comp Duktape Duktape.modLoaded undefined fresh_require exports module ] */
28956
28957 /* Register the module table early to modLoaded[] so that we can
28958 * support circular references even in modSearch(). If an error
28959 * is thrown, we'll delete the reference.
28960 */
28963 duk_put_prop(ctx, DUK__IDX_MODLOADED); /* Duktape.modLoaded[resolved_id] = module */
28964
28965 /*
28966 * Call user provided module search function and build the wrapped
28967 * module source code (if necessary). The module search function
28968 * can be used to implement pure Ecmacsript, pure C, and mixed
28969 * Ecmascript/C modules.
28970 *
28971 * The module search function can operate on the exports table directly
28972 * (e.g. DLL code can register values to it). It can also return a
28973 * string which is interpreted as module source code (if a non-string
28974 * is returned the module is assumed to be a pure C one). If a module
28975 * cannot be found, an error must be thrown by the user callback.
28976 *
28977 * Because Duktape.modLoaded[] already contains the module being
28978 * loaded, circular references for C modules should also work
28979 * (although expected to be quite rare).
28980 */
28981
28982 duk_push_string(ctx, "(function(require,exports,module){");
28983
28984 /* Duktape.modSearch(resolved_id, fresh_require, exports, module). */
28985 duk_get_prop_stridx(ctx, DUK__IDX_DUKTAPE, DUK_STRIDX_MOD_SEARCH); /* Duktape.modSearch */
28989 duk_dup(ctx, DUK__IDX_MODULE); /* [ ... Duktape.modSearch resolved_id last_comp fresh_require exports module ] */
28990 pcall_rc = duk_pcall(ctx, 4 /*nargs*/); /* -> [ ... source ] */
28992
28993 if (pcall_rc != DUK_EXEC_SUCCESS) {
28994 /* Delete entry in Duktape.modLoaded[] and rethrow. */
28995 goto delete_rethrow;
28996 }
28997
28998 /* If user callback did not return source code, module loading
28999 * is finished (user callback initialized exports table directly).
29000 */
29001 if (!duk_is_string(ctx, -1)) {
29002 /* User callback did not return source code, so module loading
29003 * is finished: just update modLoaded with final module.exports
29004 * and we're done.
29005 */
29006 goto return_exports;
29007 }
29008
29009 /* Finish the wrapped module source. Force module.filename as the
29010 * function .fileName so it gets set for functions defined within a
29011 * module. This also ensures loggers created within the module get
29012 * the module ID (or overridden filename) as their default logger name.
29013 * (Note capitalization: .filename matches Node.js while .fileName is
29014 * used elsewhere in Duktape.)
29015 */
29016 duk_push_string(ctx, "\n})"); /* Newline allows module last line to contain a // comment. */
29017 duk_concat(ctx, 3);
29019 /* module.filename for .fileName, default to resolved ID if
29020 * not present.
29021 */
29022 duk_pop(ctx);
29024 }
29026
29027 /* Module has now evaluated to a wrapped module function. Force its
29028 * .name to match module.name (defaults to last component of resolved
29029 * ID) so that it is shown in stack traces too. Note that we must not
29030 * introduce an actual name binding into the function scope (which is
29031 * usually the case with a named function) because it would affect the
29032 * scope seen by the module and shadow accesses to globals of the same name.
29033 * This is now done by compiling the function as anonymous and then forcing
29034 * its .name without setting a "has name binding" flag.
29035 */
29036
29039 /* module.name for .name, default to last component if
29040 * not present.
29041 */
29042 duk_pop(ctx);
29044 }
29046
29047 /*
29048 * Call the wrapped module function.
29049 *
29050 * Use a protected call so that we can update Duktape.modLoaded[resolved_id]
29051 * even if the module throws an error.
29052 */
29053
29054 /* [ requested_id require require.id resolved_id last_comp Duktape Duktape.modLoaded undefined fresh_require exports module mod_func ] */
29056
29057 duk_dup(ctx, DUK__IDX_EXPORTS); /* exports (this binding) */
29058 duk_dup(ctx, DUK__IDX_FRESH_REQUIRE); /* fresh require (argument) */
29059 duk_get_prop_stridx(ctx, DUK__IDX_MODULE, DUK_STRIDX_EXPORTS); /* relookup exports from module.exports in case it was changed by modSearch */
29060 duk_dup(ctx, DUK__IDX_MODULE); /* module (argument) */
29062
29063 /* [ requested_id require require.id resolved_id last_comp Duktape Duktape.modLoaded undefined fresh_require exports module mod_func exports fresh_require exports module ] */
29064
29065 pcall_rc = duk_pcall_method(ctx, 3 /*nargs*/);
29066 if (pcall_rc != DUK_EXEC_SUCCESS) {
29067 /* Module loading failed. Node.js will forget the module
29068 * registration so that another require() will try to load
29069 * the module again. Mimic that behavior.
29070 */
29071 goto delete_rethrow;
29072 }
#define DUK_DEFPROP_HAVE_VALUE
DUK_EXTERNAL void duk_def_prop(duk_context *ctx, duk_idx_t obj_index, duk_uint_t flags)
#define DUK_STRIDX_MOD_LOADED
#define DUK__IDX_UNDEFINED
#define DUK_PROPDESC_FLAGS_C
DUK_EXTERNAL duk_idx_t duk_push_c_function(duk_context *ctx, duk_c_function func, duk_int_t nargs)
DUK_EXTERNAL void duk_push_current_function(duk_context *ctx)
#define DUK__IDX_EXPORTS
#define DUK__IDX_REQUIRE_ID
#define DUK_STRIDX_EXPORTS
#define DUK_STRIDX_MOD_SEARCH
#define DUK__IDX_REQUESTED_ID
DUK_EXTERNAL duk_int_t duk_pcall_method(duk_context *ctx, duk_idx_t nargs)
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_require(duk_context *ctx)
#define DUK__IDX_DUKTAPE
#define DUK_STRIDX_REQUIRE
#define DUK__IDX_FRESH_REQUIRE
#define DUK__IDX_LASTCOMP
#define DUK__IDX_MODLOADED
#define DUK_STRIDX_FILENAME
#define DUK_STRIDX_ID
#define DUK__IDX_RESOLVED_ID
DUK_EXTERNAL duk_int_t duk_eval_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags)
DUK_EXTERNAL const char * duk_require_string(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL duk_int_t duk_pcall(duk_context *ctx, duk_idx_t nargs)
#define DUK__IDX_MODULE

◆ duk_bi_global_object_unescape()

DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_unescape ( duk_context * ctx)

◆ duk_bi_json_object_parse()

DUK_INTERNAL_DECL duk_ret_t duk_bi_json_object_parse ( duk_context * ctx)

Definition at line 32213 of file duktape-1.8.0/src/duktape.c.

32214 : value=%!T, replacer=%!T, space=%!T, "
32215 "flags=0x%08lx, result=%!T, stack_top=%ld",
32216 (duk_tval *) duk_get_tval(ctx, idx_value),
32217 (duk_tval *) duk_get_tval(ctx, idx_replacer),
32218 (duk_tval *) duk_get_tval(ctx, idx_space),
32219 (unsigned long) flags,

◆ duk_bi_json_object_stringify()

DUK_INTERNAL_DECL duk_ret_t duk_bi_json_object_stringify ( duk_context * ctx)

Definition at line 32221 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_json_parse_helper()

DUK_INTERNAL_DECL void duk_bi_json_parse_helper ( duk_context * ctx,
duk_idx_t idx_value,
duk_idx_t idx_reviver,
duk_small_uint_t flags )

Definition at line 31773 of file duktape-1.8.0/src/duktape.c.

31776 {
31777 DUK_DD(DUK_DDPRINT("top level value not supported, fail fast path"));
31778 return DUK_RET_ERROR; /* error message doesn't matter, ignored anyway */
31779 }
31780
31781 return 0;
31782}
31783#endif /* DUK_USE_JSON_STRINGIFY_FASTPATH */
31784
31785/*
31786 * Top level wrappers
31787 */
31788
31791 duk_idx_t idx_value,
31792 duk_idx_t idx_reviver,
31793 duk_small_uint_t flags) {
31794 duk_hthread *thr = (duk_hthread *) ctx;
31795 duk_json_dec_ctx js_ctx_alloc;
31796 duk_json_dec_ctx *js_ctx = &js_ctx_alloc;
31797 duk_hstring *h_text;
31798#ifdef DUK_USE_ASSERTIONS
31799 duk_idx_t entry_top = duk_get_top(ctx);
31800#endif
31801
31802 /* negative top-relative indices not allowed now */
31803 DUK_ASSERT(idx_value == DUK_INVALID_INDEX || idx_value >= 0);
31804 DUK_ASSERT(idx_reviver == DUK_INVALID_INDEX || idx_reviver >= 0);
31805
31806 DUK_DDD(DUK_DDDPRINT("JSON parse start: text=%!T, reviver=%!T, flags=0x%08lx, stack_top=%ld",
31807 (duk_tval *) duk_get_tval(ctx, idx_value),
31808 (duk_tval *) duk_get_tval(ctx, idx_reviver),
31809 (unsigned long) flags,
31810 (long) duk_get_top(ctx)));
31811
31812 DUK_MEMZERO(&js_ctx_alloc, sizeof(js_ctx_alloc));
31813 js_ctx->thr = thr;
31814#ifdef DUK_USE_EXPLICIT_NULL_INIT
31815 /* nothing now */
31816#endif
31818 DUK_ASSERT(js_ctx->recursion_depth == 0);
31819
31820 /* Flag handling currently assumes that flags are consistent. This is OK
31821 * because the call sites are now strictly controlled.
31822 */
31823
31824 js_ctx->flags = flags;
31825#if defined(DUK_USE_JX)
31826 js_ctx->flag_ext_custom = flags & DUK_JSON_FLAG_EXT_CUSTOM;
31827#endif
31828#if defined(DUK_USE_JC)
31830#endif
31831#if defined(DUK_USE_JX) || defined(DUK_USE_JC)
31833#endif
31834
31835 h_text = duk_to_hstring(ctx, idx_value); /* coerce in-place */
31836 DUK_ASSERT(h_text != NULL);
31837
31838 /* JSON parsing code is allowed to read [p_start,p_end]: p_end is
31839 * valid and points to the string NUL terminator (which is always
31840 * guaranteed for duk_hstrings.
31841 */
31842 js_ctx->p_start = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_text);
31843 js_ctx->p = js_ctx->p_start;
31844 js_ctx->p_end = ((const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_text)) +
31846 DUK_ASSERT(*(js_ctx->p_end) == 0x00);
31847
31848 duk__dec_value(js_ctx); /* -> [ ... value ] */
31849
31850 /* Trailing whitespace has been eaten by duk__dec_value(), so if
31851 * we're not at end of input here, it's a SyntaxError.
31852 */
31853
31854 if (js_ctx->p != js_ctx->p_end) {
31855 duk__dec_syntax_error(js_ctx);
31856 }
31857
31858 if (duk_is_callable(ctx, idx_reviver)) {
31859 DUK_DDD(DUK_DDDPRINT("applying reviver: %!T",
31860 (duk_tval *) duk_get_tval(ctx, idx_reviver)));
31861
31862 js_ctx->idx_reviver = idx_reviver;
31863
31864 duk_push_object(ctx);
31865 duk_dup(ctx, -2); /* -> [ ... val root val ] */
31866 duk_put_prop_stridx(ctx, -2, DUK_STRIDX_EMPTY_STRING); /* default attrs ok */
31867 duk_push_hstring_stridx(ctx, DUK_STRIDX_EMPTY_STRING); /* -> [ ... val root "" ] */
31868
31869 DUK_DDD(DUK_DDDPRINT("start reviver walk, root=%!T, name=%!T",
31870 (duk_tval *) duk_get_tval(ctx, -2),
31871 (duk_tval *) duk_get_tval(ctx, -1)));
31872
31873 duk__dec_reviver_walk(js_ctx); /* [ ... val root "" ] -> [ ... val val' ] */

◆ duk_bi_json_stringify_helper()

DUK_INTERNAL_DECL void duk_bi_json_stringify_helper ( duk_context * ctx,
duk_idx_t idx_value,
duk_idx_t idx_replacer,
duk_idx_t idx_space,
duk_small_uint_t flags )

Definition at line 31876 of file duktape-1.8.0/src/duktape.c.

31876 : %!T",
31877 (duk_tval *) duk_get_tval(ctx, idx_reviver)));
31878 }
31879
31880 /* Final result is at stack top. */
31881
31882 DUK_DDD(DUK_DDDPRINT("JSON parse end: text=%!T, reviver=%!T, flags=0x%08lx, result=%!T, stack_top=%ld",
31883 (duk_tval *) duk_get_tval(ctx, idx_value),
31884 (duk_tval *) duk_get_tval(ctx, idx_reviver),
31885 (unsigned long) flags,
31886 (duk_tval *) duk_get_tval(ctx, -1),
31887 (long) duk_get_top(ctx)));
31888
31889 DUK_ASSERT(duk_get_top(ctx) == entry_top + 1);
31890}
31891
31892DUK_INTERNAL
31893void duk_bi_json_stringify_helper(duk_context *ctx,
31894 duk_idx_t idx_value,
31895 duk_idx_t idx_replacer,
31896 duk_idx_t idx_space,
31897 duk_small_uint_t flags) {
31898 duk_hthread *thr = (duk_hthread *) ctx;
31899 duk_json_enc_ctx js_ctx_alloc;
31900 duk_json_enc_ctx *js_ctx = &js_ctx_alloc;
31901 duk_hobject *h;
31902 duk_idx_t idx_holder;
31903 duk_idx_t entry_top;
31904
31905 /* negative top-relative indices not allowed now */
31906 DUK_ASSERT(idx_value == DUK_INVALID_INDEX || idx_value >= 0);
31907 DUK_ASSERT(idx_replacer == DUK_INVALID_INDEX || idx_replacer >= 0);
31908 DUK_ASSERT(idx_space == DUK_INVALID_INDEX || idx_space >= 0);
31909
31910 DUK_DDD(DUK_DDDPRINT("JSON stringify start: value=%!T, replacer=%!T, space=%!T, flags=0x%08lx, stack_top=%ld",
31911 (duk_tval *) duk_get_tval(ctx, idx_value),
31912 (duk_tval *) duk_get_tval(ctx, idx_replacer),
31913 (duk_tval *) duk_get_tval(ctx, idx_space),
31914 (unsigned long) flags,
31915 (long) duk_get_top(ctx)));
31916
31917 entry_top = duk_get_top(ctx);
31918
31919 /*
31920 * Context init
31921 */
31922
31923 DUK_MEMZERO(&js_ctx_alloc, sizeof(js_ctx_alloc));
31924 js_ctx->thr = thr;
31925#ifdef DUK_USE_EXPLICIT_NULL_INIT
31926 js_ctx->h_replacer = NULL;
31927 js_ctx->h_gap = NULL;
31928#endif
31929 js_ctx->idx_proplist = -1;
31930
31931 /* Flag handling currently assumes that flags are consistent. This is OK
31932 * because the call sites are now strictly controlled.
31933 */
31934
31935 js_ctx->flags = flags;
31936 js_ctx->flag_ascii_only = flags & DUK_JSON_FLAG_ASCII_ONLY;
31937 js_ctx->flag_avoid_key_quotes = flags & DUK_JSON_FLAG_AVOID_KEY_QUOTES;
31938#ifdef DUK_USE_JX
31939 js_ctx->flag_ext_custom = flags & DUK_JSON_FLAG_EXT_CUSTOM;
31940#endif
31941#ifdef DUK_USE_JC
31942 js_ctx->flag_ext_compatible = flags & DUK_JSON_FLAG_EXT_COMPATIBLE;
31943#endif
31944#if defined(DUK_USE_JX) || defined(DUK_USE_JC)
31945 js_ctx->flag_ext_custom_or_compatible = flags & (DUK_JSON_FLAG_EXT_CUSTOM | DUK_JSON_FLAG_EXT_COMPATIBLE);
31946#endif
31947
31948 /* The #ifdef clutter here handles the JX/JC enable/disable
31949 * combinations properly.
31950 */
31951#if defined(DUK_USE_JX) || defined(DUK_USE_JC)
31952 js_ctx->stridx_custom_undefined = DUK_STRIDX_LC_NULL; /* standard JSON; array gaps */
31953#if defined(DUK_USE_JX)
31954 if (flags & DUK_JSON_FLAG_EXT_CUSTOM) {
31955 js_ctx->stridx_custom_undefined = DUK_STRIDX_LC_UNDEFINED;
31956 js_ctx->stridx_custom_nan = DUK_STRIDX_NAN;
31957 js_ctx->stridx_custom_neginf = DUK_STRIDX_MINUS_INFINITY;
31958 js_ctx->stridx_custom_posinf = DUK_STRIDX_INFINITY;
31959 js_ctx->stridx_custom_function =
31960 (flags & DUK_JSON_FLAG_AVOID_KEY_QUOTES) ?
31961 DUK_STRIDX_JSON_EXT_FUNCTION2 :
31962 DUK_STRIDX_JSON_EXT_FUNCTION1;
31963 }
31964#endif /* DUK_USE_JX */
31965#if defined(DUK_USE_JX) && defined(DUK_USE_JC)
31966 else
31967#endif /* DUK_USE_JX && DUK_USE_JC */
31968#if defined(DUK_USE_JC)
31969 if (js_ctx->flags & DUK_JSON_FLAG_EXT_COMPATIBLE) {
31970 js_ctx->stridx_custom_undefined = DUK_STRIDX_JSON_EXT_UNDEFINED;
31971 js_ctx->stridx_custom_nan = DUK_STRIDX_JSON_EXT_NAN;
31972 js_ctx->stridx_custom_neginf = DUK_STRIDX_JSON_EXT_NEGINF;
31973 js_ctx->stridx_custom_posinf = DUK_STRIDX_JSON_EXT_POSINF;
31974 js_ctx->stridx_custom_function = DUK_STRIDX_JSON_EXT_FUNCTION1;
31975 }
31976#endif /* DUK_USE_JC */
31977#endif /* DUK_USE_JX || DUK_USE_JC */
31978
31979#if defined(DUK_USE_JX) || defined(DUK_USE_JC)
31980 if (js_ctx->flags & (DUK_JSON_FLAG_EXT_CUSTOM |
31981 DUK_JSON_FLAG_EXT_COMPATIBLE)) {
31982 DUK_ASSERT(js_ctx->mask_for_undefined == 0); /* already zero */
31983 }
31984 else
31985#endif /* DUK_USE_JX || DUK_USE_JC */
31986 {
31987 js_ctx->mask_for_undefined = DUK_TYPE_MASK_UNDEFINED |
31988 DUK_TYPE_MASK_POINTER |
31989 DUK_TYPE_MASK_BUFFER |
31990 DUK_TYPE_MASK_LIGHTFUNC;
31991 }
31992
31993 DUK_BW_INIT_PUSHBUF(thr, &js_ctx->bw, DUK__JSON_STRINGIFY_BUFSIZE);
31994
31995 js_ctx->idx_loop = duk_push_object_internal(ctx);
31996 DUK_ASSERT(js_ctx->idx_loop >= 0);
31997
31998 /* [ ... buf loop ] */
31999
32000 /*
32001 * Process replacer/proplist (2nd argument to JSON.stringify)
32002 */
32003
32004 h = duk_get_hobject(ctx, idx_replacer);
32005 if (h != NULL) {
32006 if (DUK_HOBJECT_IS_CALLABLE(h)) {
32007 js_ctx->h_replacer = h;
32008 } else if (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_ARRAY) {
32009 /* Here the specification requires correct array index enumeration
32010 * which is a bit tricky for sparse arrays (it is handled by the
32011 * enum setup code). We now enumerate ancestors too, although the
32012 * specification is not very clear on whether that is required.
32013 */
32014
32015 duk_uarridx_t plist_idx = 0;
32016 duk_small_uint_t enum_flags;
32017
32018 js_ctx->idx_proplist = duk_push_array(ctx); /* XXX: array internal? */
32019
32020 enum_flags = DUK_ENUM_ARRAY_INDICES_ONLY |
32021 DUK_ENUM_SORT_ARRAY_INDICES; /* expensive flag */
32022 duk_enum(ctx, idx_replacer, enum_flags);
32023 while (duk_next(ctx, -1 /*enum_index*/, 1 /*get_value*/)) {
32024 /* [ ... proplist enum_obj key val ] */
32025 if (duk__enc_allow_into_proplist(duk_get_tval(ctx, -1))) {
32026 /* XXX: duplicates should be eliminated here */
32027 DUK_DDD(DUK_DDDPRINT("proplist enum: key=%!T, val=%!T --> accept",
32028 (duk_tval *) duk_get_tval(ctx, -2),
32029 (duk_tval *) duk_get_tval(ctx, -1)));
32030 duk_to_string(ctx, -1); /* extra coercion of strings is OK */
32031 duk_put_prop_index(ctx, -4, plist_idx); /* -> [ ... proplist enum_obj key ] */
32032 plist_idx++;
32033 duk_pop(ctx);
32034 } else {
32035 DUK_DDD(DUK_DDDPRINT("proplist enum: key=%!T, val=%!T --> reject",
32036 (duk_tval *) duk_get_tval(ctx, -2),
32037 (duk_tval *) duk_get_tval(ctx, -1)));
32038 duk_pop_2(ctx);
32039 }
32040 }
32041 duk_pop(ctx); /* pop enum */
32042
32043 /* [ ... proplist ] */
32044 }
32045 }
32046
32047 /* [ ... buf loop (proplist) ] */
32048
32049 /*
32050 * Process space (3rd argument to JSON.stringify)
32051 */
32052
32053 h = duk_get_hobject(ctx, idx_space);
32054 if (h != NULL) {
32055 int c = DUK_HOBJECT_GET_CLASS_NUMBER(h);
32056 if (c == DUK_HOBJECT_CLASS_NUMBER) {
32057 duk_to_number(ctx, idx_space);
32058 } else if (c == DUK_HOBJECT_CLASS_STRING) {
32059 duk_to_string(ctx, idx_space);
32060 }
32061 }
32062
32063 if (duk_is_number(ctx, idx_space)) {
32064 duk_small_int_t nspace;
32065 /* spaces[] must be static to allow initializer with old compilers like BCC */
32066 static const char spaces[10] = {
32067 DUK_ASC_SPACE, DUK_ASC_SPACE, DUK_ASC_SPACE, DUK_ASC_SPACE,
32068 DUK_ASC_SPACE, DUK_ASC_SPACE, DUK_ASC_SPACE, DUK_ASC_SPACE,
32069 DUK_ASC_SPACE, DUK_ASC_SPACE
32070 }; /* XXX: helper */
32071
32072 /* ToInteger() coercion; NaN -> 0, infinities are clamped to 0 and 10 */
32073 nspace = (duk_small_int_t) duk_to_int_clamped(ctx, idx_space, 0 /*minval*/, 10 /*maxval*/);
32074 DUK_ASSERT(nspace >= 0 && nspace <= 10);
32075
32076 duk_push_lstring(ctx, spaces, (duk_size_t) nspace);
32077 js_ctx->h_gap = duk_get_hstring(ctx, -1);
32078 DUK_ASSERT(js_ctx->h_gap != NULL);
32079 } else if (duk_is_string(ctx, idx_space)) {
32080 /* XXX: substring in-place at idx_place? */
32081 duk_dup(ctx, idx_space);
32082 duk_substring(ctx, -1, 0, 10); /* clamp to 10 chars */
32083 js_ctx->h_gap = duk_get_hstring(ctx, -1);
32084 DUK_ASSERT(js_ctx->h_gap != NULL);
32085 } else {
32086 /* nop */
32087 }
32088
32089 if (js_ctx->h_gap != NULL) {
32090 /* if gap is empty, behave as if not given at all */
32091 if (DUK_HSTRING_GET_CHARLEN(js_ctx->h_gap) == 0) {
32092 js_ctx->h_gap = NULL;
32093 }
32094 }
32095
32096 /* [ ... buf loop (proplist) (gap) ] */
32097
32098 /*
32099 * Fast path: assume no mutation, iterate object property tables
32100 * directly; bail out if that assumption doesn't hold.
32101 */
32102
32103#if defined(DUK_USE_JSON_STRINGIFY_FASTPATH)
32104 if (js_ctx->h_replacer == NULL && /* replacer is a mutation risk */
32105 js_ctx->idx_proplist == -1) { /* proplist is very rare */
32106 duk_int_t pcall_rc;
32107#ifdef DUK_USE_MARK_AND_SWEEP
32108 duk_small_uint_t prev_mark_and_sweep_base_flags;
32109#endif
32110
32111 DUK_DD(DUK_DDPRINT("try JSON.stringify() fast path"));
32112
32113 /* Use recursion_limit to ensure we don't overwrite js_ctx->visiting[]
32114 * array so we don't need two counter checks in the fast path. The
32115 * slow path has a much larger recursion limit which we'll use if
32116 * necessary.
32117 */
32118 DUK_ASSERT(DUK_USE_JSON_ENC_RECLIMIT >= DUK_JSON_ENC_LOOPARRAY);
32119 js_ctx->recursion_limit = DUK_JSON_ENC_LOOPARRAY;
32120 DUK_ASSERT(js_ctx->recursion_depth == 0);
32121
32122 /* Execute the fast path in a protected call. If any error is thrown,
32123 * fall back to the slow path. This includes e.g. recursion limit
32124 * because the fast path has a smaller recursion limit (and simpler,
32125 * limited loop detection).
32126 */
32127
32128 duk_push_pointer(ctx, (void *) js_ctx);
32129 duk_dup(ctx, idx_value);
32130
32131#if defined(DUK_USE_MARK_AND_SWEEP)
32132 /* Must prevent finalizers which may have arbitrary side effects. */
32133 prev_mark_and_sweep_base_flags = thr->heap->mark_and_sweep_base_flags;
32134 thr->heap->mark_and_sweep_base_flags |=
32135 DUK_MS_FLAG_NO_FINALIZERS | /* avoid attempts to add/remove object keys */
32136 DUK_MS_FLAG_NO_OBJECT_COMPACTION; /* avoid attempt to compact any objects */
32137#endif
32138
32139 pcall_rc = duk_safe_call(ctx, duk__json_stringify_fast, 2 /*nargs*/, 0 /*nret*/);
32140
32141#if defined(DUK_USE_MARK_AND_SWEEP)
32142 thr->heap->mark_and_sweep_base_flags = prev_mark_and_sweep_base_flags;
32143#endif
32144 if (pcall_rc == DUK_EXEC_SUCCESS) {
32145 DUK_DD(DUK_DDPRINT("fast path successful"));
32146 DUK_BW_PUSH_AS_STRING(thr, &js_ctx->bw);
32147 goto replace_finished;
32148 }
32149
32150 /* We come here for actual aborts (like encountering .toJSON())
32151 * but also for recursion/loop errors. Bufwriter size can be
32152 * kept because we'll probably need at least as much as we've
32153 * allocated so far.
32154 */
32155 DUK_D(DUK_DPRINT("fast path failed, serialize using slow path instead"));
32156 DUK_BW_RESET_SIZE(thr, &js_ctx->bw);
32157 js_ctx->recursion_depth = 0;
32158 }
32159#endif
32160
32161 /*
32162 * Create wrapper object and serialize
32163 */
32164
32165 idx_holder = duk_push_object(ctx);
32166 duk_dup(ctx, idx_value);
32167 duk_put_prop_stridx(ctx, -2, DUK_STRIDX_EMPTY_STRING);
32168
32169 DUK_DDD(DUK_DDDPRINT("before: flags=0x%08lx, loop=%!T, replacer=%!O, "
32170 "proplist=%!T, gap=%!O, holder=%!T",
32171 (unsigned long) js_ctx->flags,
32172 (duk_tval *) duk_get_tval(ctx, js_ctx->idx_loop),
32173 (duk_heaphdr *) js_ctx->h_replacer,
32174 (duk_tval *) (js_ctx->idx_proplist >= 0 ? duk_get_tval(ctx, js_ctx->idx_proplist) : NULL),
32175 (duk_heaphdr *) js_ctx->h_gap,
32176 (duk_tval *) duk_get_tval(ctx, -1)));
32177
32178 /* serialize the wrapper with empty string key */
32179
32180 duk_push_hstring_stridx(ctx, DUK_STRIDX_EMPTY_STRING);
32181
32182 /* [ ... buf loop (proplist) (gap) holder "" ] */
32183
32184 js_ctx->recursion_limit = DUK_USE_JSON_ENC_RECLIMIT;
32185 DUK_ASSERT(js_ctx->recursion_depth == 0);
32186
32187 if (DUK_UNLIKELY(duk__enc_value(js_ctx, idx_holder) == 0)) { /* [ ... holder key ] -> [ ... holder ] */
32188 /* Result is undefined. */
32189 duk_push_undefined(ctx);
32190 } else {
32191 /* Convert buffer to result string. */
32192 DUK_BW_PUSH_AS_STRING(thr, &js_ctx->bw);
32193 }
32194
32195 DUK_DDD(DUK_DDDPRINT("after: flags=0x%08lx, loop=%!T, replacer=%!O, "
32196 "proplist=%!T, gap=%!O, holder=%!T",
32197 (unsigned long) js_ctx->flags,
32198 (duk_tval *) duk_get_tval(ctx, js_ctx->idx_loop),
32199 (duk_heaphdr *) js_ctx->h_replacer,
32200 (duk_tval *) (js_ctx->idx_proplist >= 0 ? duk_get_tval(ctx, js_ctx->idx_proplist) : NULL),
32201 (duk_heaphdr *) js_ctx->h_gap,
32202 (duk_tval *) duk_get_tval(ctx, idx_holder)));
32203
32204 /* The stack has a variable shape here, so force it to the
32205 * desired one explicitly.
32206 */
32207

◆ duk_bi_logger_constructor()

DUK_INTERNAL_DECL duk_ret_t duk_bi_logger_constructor ( duk_context * ctx)

Definition at line 32253 of file duktape-1.8.0/src/duktape.c.

32260 {
32261 (duk_uint8_t) DUK_ASC_UC_T, (duk_uint8_t) DUK_ASC_UC_R, (duk_uint8_t) DUK_ASC_UC_C,
32262 (duk_uint8_t) DUK_ASC_UC_D, (duk_uint8_t) DUK_ASC_UC_B, (duk_uint8_t) DUK_ASC_UC_G,
32263 (duk_uint8_t) DUK_ASC_UC_I, (duk_uint8_t) DUK_ASC_UC_N, (duk_uint8_t) DUK_ASC_UC_F,
32264 (duk_uint8_t) DUK_ASC_UC_W, (duk_uint8_t) DUK_ASC_UC_R, (duk_uint8_t) DUK_ASC_UC_N,
32265 (duk_uint8_t) DUK_ASC_UC_E, (duk_uint8_t) DUK_ASC_UC_R, (duk_uint8_t) DUK_ASC_UC_R,
32266 (duk_uint8_t) DUK_ASC_UC_F, (duk_uint8_t) DUK_ASC_UC_T, (duk_uint8_t) DUK_ASC_UC_L
32267};
32268
32269/* Constructor */
32271 duk_hthread *thr = (duk_hthread *) ctx;
32272 duk_idx_t nargs;
32273
32274 /* Calling as a non-constructor is not meaningful. */
32275 if (!duk_is_constructor_call(ctx)) {
32276 return DUK_RET_TYPE_ERROR;
32277 }
32278
32279 nargs = duk_get_top(ctx);
32280 duk_set_top(ctx, 1);
32281
32282 duk_push_this(ctx);
32283
32284 /* [ name this ] */
32285
32286 if (nargs == 0) {
32287 /* Automatic defaulting of logger name from caller. This would
32288 * work poorly with tail calls, but constructor calls are currently
32289 * never tail calls, so tail calls are not an issue now.
32290 */
32291
32292 if (thr->callstack_top >= 2) {
32293 duk_activation *act_caller = thr->callstack + thr->callstack_top - 2;
32294 duk_hobject *func_caller;
32295
32296 func_caller = DUK_ACT_GET_FUNC(act_caller);
32297 if (func_caller) {
32298 /* Stripping the filename might be a good idea
32299 * ("/foo/bar/quux.js" -> logger name "quux"),
32300 * but now used verbatim.
32301 */
32302 duk_push_hobject(ctx, func_caller);
32304 duk_replace(ctx, 0);
32305 }
#define DUK_ASC_UC_C
#define DUK_ASC_UC_B
#define DUK_ASC_UC_D
#define DUK_ASC_UC_L
#define DUK_ASC_UC_W
#define DUK_ASC_UC_I
#define DUK_ASC_UC_R
#define DUK_ASC_UC_G
#define DUK_ASC_UC_N
#define DUK_ASC_UC_F
DUK_INTERNAL_DECL duk_ret_t duk_bi_logger_constructor(duk_context *ctx)

References DUK_ASC_UC_B, DUK_ASC_UC_C, DUK_ASC_UC_D, DUK_ASC_UC_E, DUK_ASC_UC_F, DUK_ASC_UC_G, DUK_ASC_UC_I, DUK_ASC_UC_L, DUK_ASC_UC_N, DUK_ASC_UC_R, DUK_ASC_UC_T, and DUK_ASC_UC_W.

◆ duk_bi_logger_prototype_fmt()

DUK_INTERNAL_DECL duk_ret_t duk_bi_logger_prototype_fmt ( duk_context * ctx)

Definition at line 32310 of file duktape-1.8.0/src/duktape.c.

32312 {
32313 duk_dup(ctx, 0);
32315 } else {
32316 /* don't set 'n' at all, inherited value is used as name */
32317 }
32318
32319 duk_compact(ctx, 1);
32320
32321 return 0; /* keep default instance */
32322}
32323
32324/* Default function to format objects. Tries to use toLogString() but falls
32325 * back to toString(). Any errors are propagated out without catching.
#define DUK_STRIDX_LC_N

References duk_dup(), duk_put_prop_stridx(), and DUK_STRIDX_LC_N.

◆ duk_bi_logger_prototype_log_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_logger_prototype_log_shared ( duk_context * ctx)

Definition at line 32358 of file duktape-1.8.0/src/duktape.c.

32375 {
32376 duk_hthread *thr = (duk_hthread *) ctx;
32377 duk_double_t now;
32378 duk_small_int_t entry_lev = duk_get_current_magic(ctx);
32379 duk_small_int_t logger_lev;
32380 duk_int_t nargs;
32381 duk_int_t i;
32382 duk_size_t tot_len;
32383 const duk_uint8_t *arg_str;
32384 duk_size_t arg_len;
32385 duk_uint8_t *buf, *p;
32386 const duk_uint8_t *q;
32387 duk_uint8_t date_buf[DUK_BI_DATE_ISO8601_BUFSIZE];
32388 duk_size_t date_len;
32389 duk_small_int_t rc;
32390
32391 DUK_ASSERT(entry_lev >= 0 && entry_lev <= 5);
32392 DUK_UNREF(thr);
32393
32394 /* XXX: sanitize to printable (and maybe ASCII) */
32395 /* XXX: better multiline */
32396
32397 /*
32398 * Logger arguments are:
32399 *
32400 * magic: log level (0-5)
32401 * this: logger
32402 * stack: plain log args
32403 *
32404 * We want to minimize memory churn so a two-pass approach
32405 * is used: first pass formats arguments and computes final
32406 * string length, second pass copies strings either into a
32407 * pre-allocated and reused buffer (short messages) or into a
32408 * newly allocated fixed buffer. If the backend function plays
32409 * nice, it won't coerce the buffer to a string (and thus
32410 * intern it).
32411 */
32412
32413 nargs = duk_get_top(ctx);
32414
32415 /* [ arg1 ... argN this ] */
32416
32417 /*
32418 * Log level check
32419 */
32420
32421 duk_push_this(ctx);
32422
32424 logger_lev = (duk_small_int_t) duk_get_int(ctx, -1);
32425 if (entry_lev < logger_lev) {
32426 return 0;
32427 }
32428 /* log level could be popped but that's not necessary */
32429
32430 now = DUK_USE_DATE_GET_NOW(ctx);
32431 duk_bi_date_format_timeval(now, date_buf);
32432 date_len = DUK_STRLEN((const char *) date_buf);
32433
32435 duk_to_string(ctx, -1);
32436 DUK_ASSERT(duk_is_string(ctx, -1));
32437
32438 /* [ arg1 ... argN this loggerLevel loggerName ] */
32439
32440 /*
32441 * Pass 1
32442 */
32443
32444 /* Line format: <time> <entryLev> <loggerName>: <msg> */
32445
32446 tot_len = 0;
32447 tot_len += 3 + /* separators: space, space, colon */
32448 3 + /* level string */
32449 date_len + /* time */
32450 duk_get_length(ctx, -1); /* loggerName */
32451
32452 for (i = 0; i < nargs; i++) {
32453 /* When formatting an argument to a string, errors may happen from multiple
32454 * causes. In general we want to catch obvious errors like a toLogString()
32455 * throwing an error, but we don't currently try to catch every possible
32456 * error. In particular, internal errors (like out of memory or stack) are
32457 * not caught. Also, we expect Error toString() to not throw an error.
32458 */
32459 if (duk_is_object(ctx, i)) {
32460 /* duk_pcall_prop() may itself throw an error, but we're content
32461 * in catching the obvious errors (like toLogString() throwing an
32462 * error).
32463 */
32465 duk_dup(ctx, i);
32466 /* [ arg1 ... argN this loggerLevel loggerName 'fmt' arg ] */
32467 /* call: this.fmt(arg) */
32468 rc = duk_pcall_prop(ctx, -5 /*obj_index*/, 1 /*nargs*/);
32469 if (rc) {
32470 /* Keep the error as the result (coercing it might fail below,
32471 * but we don't catch that now).
32472 */
32473 ;
32474 }
32475 duk_replace(ctx, i);
32476 }
32477 (void) duk_to_lstring(ctx, i, &arg_len);
32478 tot_len++; /* sep (even before first one) */
32479 tot_len += arg_len;
32480 }
32481
32482 /*
32483 * Pass 2
32484 */
32485
32486 /* XXX: There used to be a shared log buffer here, but it was removed
32487 * when dynamic buffer spare was removed. The problem with using
32488 * bufwriter is that, without the spare, the buffer gets passed on
32489 * as an argument to the raw() call so it'd need to be resized
32490 * (reallocated) anyway. If raw() call convention is changed, this
32491 * could be made more efficient.
32492 */
32493
32494 buf = (duk_uint8_t *) duk_push_fixed_buffer(ctx, tot_len);
32495 DUK_ASSERT(buf != NULL);
32496 p = buf;
32497
32498 DUK_MEMCPY((void *) p, (const void *) date_buf, (size_t) date_len);
32499 p += date_len;
32500 *p++ = (duk_uint8_t) DUK_ASC_SPACE;
32501
32502 q = duk__log_level_strings + (entry_lev * 3);
32503 DUK_MEMCPY((void *) p, (const void *) q, (size_t) 3);
32504 p += 3;
32505
32506 *p++ = (duk_uint8_t) DUK_ASC_SPACE;
32507
32508 arg_str = (const duk_uint8_t *) duk_get_lstring(ctx, -2, &arg_len);
32509 DUK_MEMCPY((void *) p, (const void *) arg_str, (size_t) arg_len);
32510 p += arg_len;
32511
32512 *p++ = (duk_uint8_t) DUK_ASC_COLON;
32513
32514 for (i = 0; i < nargs; i++) {
32515 *p++ = (duk_uint8_t) DUK_ASC_SPACE;
32516
32517 arg_str = (const duk_uint8_t *) duk_get_lstring(ctx, i, &arg_len);
32518 DUK_ASSERT(arg_str != NULL);
32519 DUK_MEMCPY((void *) p, (const void *) arg_str, (size_t) arg_len);
32520 p += arg_len;
32521 }
32522 DUK_ASSERT(buf + tot_len == p);
32523
32524 /* [ arg1 ... argN this loggerLevel loggerName buffer ] */
32525
32526#if defined(DUK_USE_DEBUGGER_SUPPORT) && defined(DUK_USE_DEBUGGER_FWD_LOGGING)
32527 /* Do debugger forwarding before raw() because the raw() function
32528 * doesn't get the log level right now.
32529 */
32530 if (DUK_HEAP_IS_DEBUGGER_ATTACHED(thr->heap)) {
32531 const char *log_buf;
32532 duk_size_t sz_buf;
32533 log_buf = (const char *) duk_get_buffer(ctx, -1, &sz_buf);
32534 DUK_ASSERT(log_buf != NULL);
32535 duk_debug_write_notify(thr, DUK_DBG_CMD_LOG);
DUK_INTERNAL_DECL void duk_bi_date_format_timeval(duk_double_t timeval, duk_uint8_t *out_buf)
#define DUK_STRIDX_FMT
DUK_LOCAL const duk_uint8_t duk__log_level_strings[]
#define DUK_DBG_CMD_LOG
DUK_EXTERNAL duk_int_t duk_pcall_prop(duk_context *ctx, duk_idx_t obj_index, duk_idx_t nargs)
#define DUK_STRIDX_LC_L

◆ duk_bi_logger_prototype_raw()

DUK_INTERNAL_DECL duk_ret_t duk_bi_logger_prototype_raw ( duk_context * ctx)

Definition at line 32334 of file duktape-1.8.0/src/duktape.c.

32351 {

◆ duk_bi_math_object_max()

DUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_max ( duk_context * ctx)

Definition at line 32842 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_math_object_min()

DUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_min ( duk_context * ctx)

Definition at line 32846 of file duktape-1.8.0/src/duktape.c.

32848 {

◆ duk_bi_math_object_onearg_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_onearg_shared ( duk_context * ctx)

Definition at line 32820 of file duktape-1.8.0/src/duktape.c.

32827 {
32828#if defined(DUK_USE_AVOID_PLATFORM_FUNCPTRS)
32829 duk__atan2,
DUK_LOCAL double duk__atan2(double x, double y)

◆ duk_bi_math_object_random()

DUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_random ( duk_context * ctx)

Definition at line 32850 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_math_object_twoarg_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_twoarg_shared ( duk_context * ctx)

Definition at line 32831 of file duktape-1.8.0/src/duktape.c.

32837 {
32840
double(* duk__one_arg_func)(double)

◆ duk_bi_nodejs_buffer_byte_length()

DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_byte_length ( duk_context * ctx)

Definition at line 23891 of file duktape-1.8.0/src/duktape.c.

23897 {
23898 DUK_UNREF(ctx);
23900}
23901#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
23902
23903/*
23904 * Node.js Buffer.byteLength()

◆ duk_bi_nodejs_buffer_concat()

DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_concat ( duk_context * ctx)

Definition at line 23917 of file duktape-1.8.0/src/duktape.c.

23923 {
23924 DUK_UNREF(ctx);
23926}
23927#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
23928
23929/*
23930 * Node.js Buffer.concat()
23931 */
23932
23933#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
23935 duk_hthread *thr;
23936 duk_hobject *h_arg;
23937 duk_int_t total_length = 0;
23938 duk_hbufferobject *h_bufobj;
23939 duk_hbufferobject *h_bufres;
23940 duk_hbuffer *h_val;
23941 duk_uint_t i, n;
23942 duk_uint8_t *p;
23943 duk_size_t space_left;
23944 duk_size_t copy_size;
23945
23946 thr = (duk_hthread *) ctx;
23947 DUK_UNREF(thr);
23948
23949 /* Node.js accepts only actual Arrays. */
23950 h_arg = duk_require_hobject(ctx, 0);
23952 return DUK_RET_TYPE_ERROR;
23953 }
23954
23955 /* Compute result length and validate argument buffers. */
23956 n = (duk_uint_t) duk_get_length(ctx, 0);
23957 for (i = 0; i < n; i++) {
23958 /* Neutered checks not necessary here: neutered buffers have
23959 * zero 'length' so we'll effectively skip them.
23960 */
23961 DUK_ASSERT_TOP(ctx, 2); /* [ array totalLength ] */
23962 duk_get_prop_index(ctx, 0, (duk_uarridx_t) i); /* -> [ array totalLength buf ] */
23963 h_bufobj = duk__require_bufobj_value(ctx, 2);
23964 DUK_ASSERT(h_bufobj != NULL);
23965 total_length += h_bufobj->length;
23966 duk_pop(ctx);
23967 }
23968 if (n == 1) {
23969 /* For the case n==1 Node.js doesn't seem to type check
23970 * the sole member but we do it before returning it.
23971 * For this case only the original buffer object is
23972 * returned (not a copy).
23973 */
23974 duk_get_prop_index(ctx, 0, 0);
23975 return 1;
23976 }
23977
23978 /* User totalLength overrides a computed length, but we'll check
23979 * every copy in the copy loop. Note that duk_to_uint() can
23980 * technically have arbitrary side effects so we need to recheck
23981 * the buffers in the copy loop.
23982 */
23983 if (!duk_is_undefined(ctx, 1) && n > 0) {
23984 /* For n == 0, Node.js ignores totalLength argument and
23985 * returns a zero length buffer.
23986 */
23987 total_length = duk_to_int(ctx, 1);
23988 }
23989 if (total_length < 0) {
23990 return DUK_RET_RANGE_ERROR;
23991 }
23992
23993 h_bufres = duk_push_bufferobject_raw(ctx,
23998 DUK_ASSERT(h_bufres != NULL);
23999
24000 p = (duk_uint8_t *) duk_push_fixed_buffer(ctx, total_length);
24001 DUK_ASSERT(p != NULL);
24002 space_left = total_length;
24003
24004 for (i = 0; i < n; i++) {
24005 DUK_ASSERT_TOP(ctx, 4); /* [ array totalLength bufres buf ] */
24006
24007 duk_get_prop_index(ctx, 0, (duk_uarridx_t) i);
24008 h_bufobj = duk__require_bufobj_value(ctx, 4);
24009 DUK_ASSERT(h_bufobj != NULL);
24010
24011 copy_size = h_bufobj->length;
24012 if (copy_size > space_left) {
24013 copy_size = space_left;
24014 }
24015
24016 if (h_bufobj->buf != NULL &&
24018 DUK_MEMCPY((void *) p,
24019 (const void *) DUK_HBUFFEROBJECT_GET_SLICE_BASE(thr->heap, h_bufobj),
24020 copy_size);
24021 } else {
24022 /* Just skip, leaving zeroes in the result. */
24023 ;
#define DUK_BIDX_NODEJS_BUFFER_PROTOTYPE
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_concat(duk_context *ctx)

◆ duk_bi_nodejs_buffer_constructor()

DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_constructor ( duk_context * ctx)

Definition at line 22318 of file duktape-1.8.0/src/duktape.c.

22335 {
22336 /* Internal class is Object: Object.prototype.toString.call(new Buffer(0))
22337 * prints "[object Object]".
22338 */
22339 duk_int_t len;
22340 duk_int_t i;
22341 duk_hbuffer *h_buf;
22342 duk_hbufferobject *h_bufobj;
22343 duk_size_t buf_size;
22344
22345 switch (duk_get_type(ctx, 0)) {
22346 case DUK_TYPE_BUFFER: {
22347 /* Custom behavior: plain buffer is used as internal buffer
22348 * without making a copy (matches Duktape.Buffer).
22349 */
22350 duk_set_top(ctx, 1); /* -> [ buffer ] */
22351 break;
22352 }
22353 case DUK_TYPE_NUMBER: {
22354 len = duk_to_int_clamped(ctx, 0, 0, DUK_INT_MAX);
22355 (void) duk_push_fixed_buffer(ctx, (duk_size_t) len);
22356 break;
22357 }
22358 case DUK_TYPE_OBJECT: {
22359 duk_uint8_t *buf;
22360
22361 (void) duk_get_prop_string(ctx, 0, "length");
22362 len = duk_to_int_clamped(ctx, -1, 0, DUK_INT_MAX);
22363 duk_pop(ctx);
22364 buf = (duk_uint8_t *) duk_push_fixed_buffer(ctx, (duk_size_t) len);
22365 for (i = 0; i < len; i++) {
22366 /* XXX: fast path for array arguments? */
22367 duk_get_prop_index(ctx, 0, (duk_uarridx_t) i);
22368 buf[i] = (duk_uint8_t) (duk_to_uint32(ctx, -1) & 0xffU);
22369 duk_pop(ctx);
22370 }
22371 break;
22372 }
22373 case DUK_TYPE_STRING: {
22374 /* ignore encoding for now */
22375 duk_dup(ctx, 0);
22376 (void) duk_to_buffer(ctx, -1, &buf_size);
22377 break;
22378 }
22379 default:
22380 return DUK_RET_TYPE_ERROR;
22381 }
22382
22383 DUK_ASSERT(duk_is_buffer(ctx, -1));
22384 h_buf = duk_get_hbuffer(ctx, -1);
22385 DUK_ASSERT(h_buf != NULL);
22386
#define duk_to_buffer(ctx, index, out_size)
DUK_EXTERNAL duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_index, const char *key)

◆ duk_bi_nodejs_buffer_copy()

DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_copy ( duk_context * ctx)

Definition at line 23278 of file duktape-1.8.0/src/duktape.c.

23284 {
23285 DUK_UNREF(ctx);
23287}
23288#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
23289
23290/*
23291 * Node.js Buffer.prototype.copy()
23292 */
23293
23294#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
23296 duk_hthread *thr;
23297 duk_hbufferobject *h_this;
23298 duk_hbufferobject *h_bufarg;
23299 duk_int_t source_length;
23300 duk_int_t target_length;
23301 duk_int_t target_start, source_start, source_end;
23302 duk_uint_t target_ustart, source_ustart, source_uend;
23303 duk_uint_t copy_size = 0;
23304
23305 /* [ targetBuffer targetStart sourceStart sourceEnd ] */
23306
23307 thr = (duk_hthread *) ctx;
23308 DUK_UNREF(thr);
23309
23310 h_this = duk__require_bufobj_this(ctx);
23311 h_bufarg = duk__require_bufobj_value(ctx, 0);
23312 DUK_ASSERT(h_this != NULL);
23313 DUK_ASSERT(h_bufarg != NULL);
23314 source_length = (duk_int_t) h_this->length;
23315 target_length = (duk_int_t) h_bufarg->length;
23316
23317 target_start = duk_to_int(ctx, 1);
23318 source_start = duk_to_int(ctx, 2);
23319 if (duk_is_undefined(ctx, 3)) {
23320 source_end = source_length;
23321 } else {
23322 source_end = duk_to_int(ctx, 3);
23323 }
23324
23325 DUK_DDD(DUK_DDDPRINT("checking copy args: target_start=%ld, target_length=%ld, "
23326 "source_start=%ld, source_end=%ld, source_length=%ld",
23327 (long) target_start, (long) h_bufarg->length,
23328 (long) source_start, (long) source_end, (long) source_length));
23329
23330 /* This behavior mostly mimics Node.js now. */
23331
23332 if (source_start < 0 || source_end < 0 || target_start < 0) {
23333 /* Negative offsets cause a RangeError. */
23334 goto fail_bounds;
23335 }
23336 source_ustart = (duk_uint_t) source_start;
23337 source_uend = (duk_uint_t) source_end;
23338 target_ustart = (duk_uint_t) target_start;
23339 if (source_ustart >= source_uend || /* crossed offsets or zero size */
23340 source_ustart >= (duk_uint_t) source_length || /* source out-of-bounds (but positive) */
23341 target_ustart >= (duk_uint_t) target_length) { /* target out-of-bounds (but positive) */
23342 goto silent_ignore;
23343 }
23344 if (source_uend >= (duk_uint_t) source_length) {
23345 /* Source end clamped silently to available length. */
23346 source_uend = source_length;
23347 }
23348 copy_size = source_uend - source_ustart;
23349 if (target_ustart + copy_size > (duk_uint_t) target_length) {
23350 /* Clamp to target's end if too long.
23351 *
23352 * NOTE: there's no overflow possibility in the comparison;
23353 * both target_ustart and copy_size are >= 0 and based on
23354 * values in duk_int_t range. Adding them as duk_uint_t
23355 * values is then guaranteed not to overflow.
23356 */
23357 DUK_ASSERT(target_ustart + copy_size >= target_ustart); /* no overflow */
23358 DUK_ASSERT(target_ustart + copy_size >= copy_size); /* no overflow */
23359 copy_size = (duk_uint_t) target_length - target_ustart;
23360 }
23361
23362 DUK_DDD(DUK_DDDPRINT("making copy: target_ustart=%lu source_ustart=%lu copy_size=%lu",
23363 (unsigned long) target_ustart, (unsigned long) source_ustart,
23364 (unsigned long) copy_size));
23365
23366 DUK_ASSERT(copy_size >= 1);
23367 DUK_ASSERT(source_ustart <= (duk_uint_t) source_length);
23368 DUK_ASSERT(source_ustart + copy_size <= (duk_uint_t) source_length);
23369 DUK_ASSERT(target_ustart <= (duk_uint_t) target_length);
23370 DUK_ASSERT(target_ustart + copy_size <= (duk_uint_t) target_length);
23371
23372 /* Ensure copy is covered by underlying buffers. */
23373 DUK_ASSERT(h_bufarg->buf != NULL); /* length check */
23374 DUK_ASSERT(h_this->buf != NULL); /* length check */
23375 if (DUK_HBUFFEROBJECT_VALID_BYTEOFFSET_EXCL(h_bufarg, target_ustart + copy_size) &&
23376 DUK_HBUFFEROBJECT_VALID_BYTEOFFSET_EXCL(h_this, source_ustart + copy_size)) {
23377 /* Must use memmove() because copy area may overlap (source and target
23378 * buffer may be the same, or from different slices.
23379 */
23380 DUK_MEMMOVE((void *) (DUK_HBUFFEROBJECT_GET_SLICE_BASE(thr->heap, h_bufarg) + target_ustart),
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_copy(duk_context *ctx)

◆ duk_bi_nodejs_buffer_fill()

DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_fill ( duk_context * ctx)

Definition at line 23150 of file duktape-1.8.0/src/duktape.c.

23156 {
23157 DUK_UNREF(ctx);
23159}
23160#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
23161
23162/*
23163 * Node.js Buffer.prototype.fill()
23164 */
23165
23166#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
23168 duk_hthread *thr;
23169 duk_hbufferobject *h_this;
23170 const duk_uint8_t *fill_str_ptr;
23171 duk_size_t fill_str_len;
23172 duk_uint8_t fill_value;
23173 duk_int_t fill_offset;
23174 duk_int_t fill_end;
23175 duk_size_t fill_length;
23176 duk_uint8_t *p;
23177
23178 thr = (duk_hthread *) ctx;
23179 DUK_UNREF(thr);
23180
23181 h_this = duk__require_bufobj_this(ctx);
23182 DUK_ASSERT(h_this != NULL);
23183 if (h_this->buf == NULL) {
23184 return DUK_RET_TYPE_ERROR;
23185 }
23186
23187 /* [ value offset end ] */
23188
23189 if (duk_is_string(ctx, 0)) {
23190 fill_str_ptr = (const duk_uint8_t *) duk_get_lstring(ctx, 0, &fill_str_len);
23191 DUK_ASSERT(fill_str_ptr != NULL);
23192 } else {
23193 fill_value = (duk_uint8_t) duk_to_uint32(ctx, 0);
23194 fill_str_ptr = (const duk_uint8_t *) &fill_value;
23195 fill_str_len = 1;
23196 }
23197
23198 /* Fill offset handling is more lenient than in Node.js. */
23199
23200 duk__clamp_startend_nonegidx_noshift(ctx, h_this, 1 /*idx_start*/, 2 /*idx_end*/, &fill_offset, &fill_end);
23201
23202 DUK_DDD(DUK_DDDPRINT("fill: fill_value=%02x, fill_offset=%ld, fill_end=%ld, view length=%ld",
23203 (unsigned int) fill_value, (long) fill_offset, (long) fill_end, (long) h_this->length));
23204
23205 DUK_ASSERT(fill_end - fill_offset >= 0);
23206 DUK_ASSERT(h_this->buf != NULL);
23207
23208 p = (DUK_HBUFFEROBJECT_GET_SLICE_BASE(thr->heap, h_this) + fill_offset);
23209 fill_length = (duk_size_t) (fill_end - fill_offset);
23210 if (fill_str_len == 1) {
23211 /* Handle single character fills as memset() even when
23212 * the fill data comes from a one-char argument.
23213 */
23214 DUK_MEMSET((void *) p, (int) fill_str_ptr[0], (size_t) fill_length);
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_fill(duk_context *ctx)

◆ duk_bi_nodejs_buffer_is_buffer()

DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_is_buffer ( duk_context * ctx)

Definition at line 23850 of file duktape-1.8.0/src/duktape.c.

23856 {
23857 DUK_UNREF(ctx);
23859}
23860#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
23861
23862/*
23863 * Node.js Buffer.isBuffer()
23864 */
23865
23866#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
23868 duk_hthread *thr;
23869 duk_tval *tv;
23870 duk_hobject *h;
23871 duk_hobject *h_proto;
23872 duk_bool_t ret = 0;
23873
23874 thr = (duk_hthread *) ctx;
23875
23876 DUK_ASSERT(duk_get_top(ctx) >= 1); /* nargs */
23877 tv = duk_get_tval(ctx, 0);
23878 DUK_ASSERT(tv != NULL);
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_is_buffer(duk_context *ctx)

◆ duk_bi_nodejs_buffer_is_encoding()

DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_is_encoding ( duk_context * ctx)

Definition at line 23828 of file duktape-1.8.0/src/duktape.c.

23834 {
23835 DUK_UNREF(ctx);
23837}

◆ duk_bi_nodejs_buffer_tojson()

DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_tojson ( duk_context * ctx)

Definition at line 23039 of file duktape-1.8.0/src/duktape.c.

23041 :
23042 return DUK_RET_TYPE_ERROR;
23043}
23044#else /* DUK_USE_BUFFEROBJECT_SUPPORT */
23046 DUK_UNREF(ctx);
23048}
23049#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
23050
23051/*
23052 * Node.js Buffer.prototype: toJSON()
23053 */
23054
23055#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
23057 duk_hthread *thr;
23058 duk_hbufferobject *h_this;
23059 duk_uint8_t *buf;
23060 duk_uint_t i;
23061
23062 thr = (duk_hthread *) ctx;
23063 DUK_UNREF(thr);
23064 h_this = duk__require_bufobj_this(ctx);
23065 DUK_ASSERT(h_this != NULL);
23066
23067 if (h_this->buf == NULL || !DUK_HBUFFEROBJECT_VALID_SLICE(h_this)) {
23068 /* Serialize uncovered backing buffer as a null; doesn't
23069 * really matter as long we're memory safe.
23070 */
23071 duk_push_null(ctx);
23072 return 1;
23073 }
23074
23075 duk_push_object(ctx);
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_tojson(duk_context *ctx)

◆ duk_bi_nodejs_buffer_tostring()

DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_tostring ( duk_context * ctx)

Definition at line 22921 of file duktape-1.8.0/src/duktape.c.

22927 {
22928 DUK_UNREF(ctx);
22930}
22931#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
22932
22933/*
22934 * Node.js Buffer: toString([encoding], [start], [end])
22935 */
22936
22937#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
22939 duk_hthread *thr;
22940 duk_hbufferobject *h_this;
22941 duk_int_t start_offset, end_offset;
22942 duk_uint8_t *buf_slice;
22943 duk_size_t slice_length;
22944
22945 thr = (duk_hthread *) ctx;
22946 DUK_UNREF(thr);
22947
22948 h_this = duk__get_bufobj_this(ctx);
22949 if (h_this == NULL) {
22950 /* XXX: happens e.g. when evaluating: String(Buffer.prototype). */
22951 duk_push_string(ctx, "[object Object]");
22952 return 1;
22953 }
22955
22956 /* ignore encoding for now */
22957
22958 duk__clamp_startend_nonegidx_noshift(ctx, h_this, 1 /*idx_start*/, 2 /*idx_end*/, &start_offset, &end_offset);
22959
22960 slice_length = (duk_size_t) (end_offset - start_offset);
22961 buf_slice = (duk_uint8_t *) duk_push_fixed_buffer(ctx, slice_length);
22962 DUK_ASSERT(buf_slice != NULL);
22963
22964 if (h_this->buf == NULL) {
22965 goto type_error;
DUK_LOCAL duk_hbufferobject * duk__get_bufobj_this(duk_context *ctx)

◆ duk_bi_nodejs_buffer_write()

DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_write ( duk_context * ctx)

Definition at line 23227 of file duktape-1.8.0/src/duktape.c.

23233 {
23234 DUK_UNREF(ctx);
23236}
23237#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
23238
23239/*
23240 * Node.js Buffer.prototype.write(string, [offset], [length], [encoding])
23241 */
23242
23243#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
23245 duk_hthread *thr;
23246 duk_hbufferobject *h_this;
23247 duk_uint_t offset;
23248 duk_uint_t length;
23249 const duk_uint8_t *str_data;
23251
23252 thr = (duk_hthread *) ctx;
23253 DUK_UNREF(thr);
23254
23255 h_this = duk__require_bufobj_this(ctx);
23256 DUK_ASSERT(h_this != NULL);
23257
23258 /* Argument must be a string, e.g. a buffer is not allowed. */
23259 str_data = (const duk_uint8_t *) duk_require_lstring(ctx, 0, &str_len);
23260
23261 duk__resolve_offset_opt_length(ctx, h_this, 1, 2, &offset, &length, 0 /*throw_flag*/);
23262 DUK_ASSERT(offset <= h_this->length);
23263 DUK_ASSERT(offset + length <= h_this->length);
23264
23265 /* XXX: encoding is ignored now. */
DUK_EXTERNAL const char * duk_require_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_write(duk_context *ctx)
static int str_len(lua_State *L)

◆ duk_bi_number_constructor()

DUK_INTERNAL_DECL duk_ret_t duk_bi_number_constructor ( duk_context * ctx)

Definition at line 32920 of file duktape-1.8.0/src/duktape.c.

32923 {
32924 DUK_DDD(DUK_DDDPRINT("unacceptable this value: %!T", (duk_tval *) duk_get_tval(ctx, -1)));
32925 DUK_ERROR_TYPE((duk_hthread *) ctx, "number expected");
32926 }
32928 DUK_ASSERT(duk_is_number(ctx, -1));
32929 DUK_DDD(DUK_DDDPRINT("number object: %!T, internal value: %!T",
32930 (duk_tval *) duk_get_tval(ctx, -2), (duk_tval *) duk_get_tval(ctx, -1)));
32931 duk_remove(ctx, -2);
32932
32933 done:
32934 return duk_get_number(ctx, -1);
32935}
32936
32938 duk_hthread *thr = (duk_hthread *) ctx;
32939 duk_idx_t nargs;
32940 duk_hobject *h_this;
32941
32942 DUK_UNREF(thr);
32943
32944 /*
32945 * The Number constructor uses ToNumber(arg) for number coercion
32946 * (coercing an undefined argument to NaN). However, if the
32947 * argument is not given at all, +0 must be used instead. To do
32948 * this, a vararg function is used.
32949 */
32950
32951 nargs = duk_get_top(ctx);
32952 if (nargs == 0) {
32953 duk_push_int(ctx, 0);
32954 }
32955 duk_to_number(ctx, 0);
32956 duk_set_top(ctx, 1);
32957 DUK_ASSERT_TOP(ctx, 1);
32958
32959 if (!duk_is_constructor_call(ctx)) {
32960 return 1;
32961 }
32962
32963 /*
32964 * E5 Section 15.7.2.1 requires that the constructed object
32965 * must have the original Number.prototype as its internal
32966 * prototype. However, since Number.prototype is non-writable
32967 * and non-configurable, this doesn't have to be enforced here:
32968 * The default object (bound to 'this') is OK, though we have
32969 * to change its class.
32970 *
32971 * Internal value set to ToNumber(arg) or +0; if no arg given,
32972 * ToNumber(undefined) = NaN, so special treatment is needed
DUK_INTERNAL_DECL duk_ret_t duk_bi_number_constructor(duk_context *ctx)

◆ duk_bi_number_prototype_to_exponential()

DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_exponential ( duk_context * ctx)

Definition at line 33046 of file duktape-1.8.0/src/duktape.c.

33057 :
33058 DUK_ASSERT_TOP(ctx, 2);
33059 duk_to_string(ctx, -1);
33060 return 1;
33061}
33062
33064 duk_bool_t frac_undefined;
33065 duk_small_int_t frac_digits;
33066 duk_double_t d;
33068 duk_small_uint_t n2s_flags;
33069
33071
33072 frac_undefined = duk_is_undefined(ctx, 0);
33073 duk_to_int(ctx, 0); /* for side effects */
33074
33076 if (c == DUK_FP_NAN || c == DUK_FP_INFINITE) {
33077 goto use_to_string;
33078 }
DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_exponential(duk_context *ctx)

◆ duk_bi_number_prototype_to_fixed()

DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_fixed ( duk_context * ctx)

Definition at line 33013 of file duktape-1.8.0/src/duktape.c.

33017 {
33018 /* XXX: just use toString() for now; permitted although not recommended.
33019 * nargs==1, so radix is passed to toString().
33020 */
33022}
33023
33024/*
33025 * toFixed(), toExponential(), toPrecision()
33026 */
33027
33028/* XXX: shared helper for toFixed(), toExponential(), toPrecision()? */
33029
33031 duk_small_int_t frac_digits;
33032 duk_double_t d;
33034 duk_small_uint_t n2s_flags;
33035
33036 frac_digits = (duk_small_int_t) duk_to_int_check_range(ctx, 0, 0, 20);
33038
33040 if (c == DUK_FP_NAN || c == DUK_FP_INFINITE) {
33041 goto use_to_string;
33042 }
33043
33044 if (d >= 1.0e21 || d <= -1.0e21) {
DUK_INTERNAL_DECL duk_int_t duk_to_int_check_range(duk_context *ctx, duk_idx_t index, duk_int_t minval, duk_int_t maxval)
DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_string(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_fixed(duk_context *ctx)

◆ duk_bi_number_prototype_to_locale_string()

DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_locale_string ( duk_context * ctx)

Definition at line 33000 of file duktape-1.8.0/src/duktape.c.

33001 {
33002 radix = 10;
33003 } else {
33004 radix = (duk_small_int_t) duk_to_int_check_range(ctx, 0, 2, 36);
33005 }

◆ duk_bi_number_prototype_to_precision()

DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_precision ( duk_context * ctx)

Definition at line 33080 of file duktape-1.8.0/src/duktape.c.

33084
33086 10 /*radix*/,
33087 frac_digits + 1 /*leading digit + fractions*/,
33088 n2s_flags /*flags*/);
33089 return 1;
33090
33091 use_to_string:
33092 DUK_ASSERT_TOP(ctx, 2);
33093 duk_to_string(ctx, -1);
33094 return 1;
33095}
33096
33098 /* The specification has quite awkward order of coercion and
33099 * checks for toPrecision(). The operations below are a bit
33100 * reordered, within constraints of observable side effects.
33101 */
33102
33103 duk_double_t d;
33104 duk_small_int_t prec;
33106 duk_small_uint_t n2s_flags;
33107
33108 DUK_ASSERT_TOP(ctx, 1);
33109
33111 if (duk_is_undefined(ctx, 0)) {
33112 goto use_to_string;
33113 }
33114 DUK_ASSERT_TOP(ctx, 2);
33115
33116 duk_to_int(ctx, 0); /* for side effects */
33117
33119 if (c == DUK_FP_NAN || c == DUK_FP_INFINITE) {
33120 goto use_to_string;
33121 }
33122
33123 prec = (duk_small_int_t) duk_to_int_check_range(ctx, 0, 1, 21);
33124
33125 n2s_flags = DUK_N2S_FLAG_FIXED_FORMAT |
#define DUK_N2S_FLAG_FIXED_FORMAT
DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_precision(duk_context *ctx)

◆ duk_bi_number_prototype_to_string()

DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_string ( duk_context * ctx)

Definition at line 32979 of file duktape-1.8.0/src/duktape.c.

32991 {
32992 (void) duk__push_this_number_plain(ctx);
32993 return 1;
32994}
32995
32997 duk_small_int_t radix;
32998 duk_small_uint_t n2s_flags;

◆ duk_bi_number_prototype_value_of()

DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_value_of ( duk_context * ctx)

Definition at line 32974 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_object_constructor()

DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor ( duk_context * ctx)

Definition at line 33133 of file duktape-1.8.0/src/duktape.c.

33134 :
33135 /* Used when precision is undefined; also used for NaN (-> "NaN"),
33136 * and +/- infinity (-> "Infinity", "-Infinity").
33137 */
33138
33139 DUK_ASSERT_TOP(ctx, 2);
33140 duk_to_string(ctx, -1);
33141 return 1;
33142}
33143#line 1 "duk_bi_object.c"
33144/*
33145 * Object built-ins
33146 */
33147
33148/* include removed: duk_internal.h */
33149
33151 if (!duk_is_constructor_call(ctx) &&
33152 !duk_is_null_or_undefined(ctx, 0)) {
33153 duk_to_object(ctx, 0);
33154 return 1;
33155 }
33156
33157 if (duk_is_object(ctx, 0)) {
33158 return 1;
33159 }
33160
33161 /* Pointer and buffer primitive values are treated like other
33162 * primitives values which have a fully fledged object counterpart:
33163 * promote to an object value. Lightfuncs are coerced with
33164 * ToObject() even they could also be returned as is.
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor(duk_context *ctx)

◆ duk_bi_object_constructor_create()

DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_create ( duk_context * ctx)

Definition at line 33284 of file duktape-1.8.0/src/duktape.c.

33287 :
33288 duk_set_top(ctx, 1);
33289 return ret_success;
33290
33291 fail_nonextensible:
33292 fail_loop:
33293 return DUK_RET_TYPE_ERROR;
33294}
33295
33297 /* XXX: no need for indirect call */
33299}
33300
33302 duk_tval *tv;
33304
33305 DUK_ASSERT_TOP(ctx, 2);
33306
33307 tv = duk_get_tval(ctx, 0);
33308 DUK_ASSERT(tv != NULL);
33309 if (DUK_TVAL_IS_NULL(tv)) {
33310 ;
33311 } else if (DUK_TVAL_IS_OBJECT(tv)) {
33313 DUK_ASSERT(proto != NULL);
33314 } else {
33315 return DUK_RET_TYPE_ERROR;
33316 }
33317
33321 proto);
33322
33323 if (!duk_is_undefined(ctx, 1)) {
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_create(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_hobject_object_get_own_property_descriptor(duk_context *ctx)
#define DUK_TVAL_IS_NULL(tv)
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_get_own_property_descriptor(duk_context *ctx)

◆ duk_bi_object_constructor_define_properties()

DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_define_properties ( duk_context * ctx)

Definition at line 33395 of file duktape-1.8.0/src/duktape.c.

33412 {
33413 duk_small_uint_t pass;
33414 duk_uint_t defprop_flags;
33415 duk_hobject *obj;
33416 duk_idx_t idx_value;
33417 duk_hobject *get;
33418 duk_hobject *set;
33419
33420 /* Lightfunc handling by ToObject() coercion. */
33421 obj = duk_require_hobject_or_lfunc_coerce(ctx, 0); /* target */
33422 DUK_ASSERT(obj != NULL);
33423
33424 duk_to_object(ctx, 1); /* properties object */
33425
33426 DUK_DDD(DUK_DDDPRINT("target=%!iT, properties=%!iT",
33427 (duk_tval *) duk_get_tval(ctx, 0),
33428 (duk_tval *) duk_get_tval(ctx, 1)));
33429
33430 /*
33431 * Two pass approach to processing the property descriptors.
33432 * On first pass validate and normalize all descriptors before
33433 * any changes are made to the target object. On second pass
33434 * make the actual modifications to the target object.
33435 *
33436 * Right now we'll just use the same normalize/validate helper
33437 * on both passes, ignoring its outputs on the first pass.
33438 */
33439
33440 for (pass = 0; pass < 2; pass++) {
33441 duk_set_top(ctx, 2); /* -> [ hobject props ] */
33442 duk_enum(ctx, 1, DUK_ENUM_OWN_PROPERTIES_ONLY /*enum_flags*/);
33443
33444 for (;;) {
33445 duk_hstring *key;
33446
33447 /* [ hobject props enum(props) ] */
33448
33449 duk_set_top(ctx, 3);
33450
33451 if (!duk_next(ctx, 2, 1 /*get_value*/)) {
33452 break;
33453 }
33454
33455 DUK_DDD(DUK_DDDPRINT("-> key=%!iT, desc=%!iT",
33456 (duk_tval *) duk_get_tval(ctx, -2),
33457 (duk_tval *) duk_get_tval(ctx, -1)));
33458
33459 /* [ hobject props enum(props) key desc ] */
33460
33462 4 /*idx_desc*/,
33463 &defprop_flags,
33464 &idx_value,
33465 &get,
33466 &set);
33467
33468 /* [ hobject props enum(props) key desc value? getter? setter? ] */
33469
33470 if (pass == 0) {
33471 continue;
33472 }
33473
33474 key = duk_get_hstring(ctx, 3);
33475 DUK_ASSERT(key != NULL);
33476
DUK_INTERNAL_DECL void duk_hobject_prepare_property_descriptor(duk_context *ctx, duk_idx_t idx_in, duk_uint_t *out_defprop_flags, duk_idx_t *out_idx_value, duk_hobject **out_getter, duk_hobject **out_setter)

◆ duk_bi_object_constructor_define_property()

DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_define_property ( duk_context * ctx)

Definition at line 33325 of file duktape-1.8.0/src/duktape.c.

33342 {
33343 duk_hobject *obj;
33344 duk_hstring *key;
33345 duk_hobject *get;
33346 duk_hobject *set;
33347 duk_idx_t idx_value;
33348 duk_uint_t defprop_flags;
33349
33350 DUK_ASSERT(ctx != NULL);
33351
33352 DUK_DDD(DUK_DDDPRINT("Object.defineProperty(): ctx=%p obj=%!T key=%!T desc=%!T",
33353 (void *) ctx,
33354 (duk_tval *) duk_get_tval(ctx, 0),
33355 (duk_tval *) duk_get_tval(ctx, 1),
33356 (duk_tval *) duk_get_tval(ctx, 2)));
33357
33358 /* [ obj key desc ] */
33359
33360 /* Lightfuncs are currently supported by coercing to a temporary
33361 * Function object; changes will be allowed (the coerced value is
33362 * extensible) but will be lost.
33363 */
33365 (void) duk_to_string(ctx, 1);
33366 key = duk_require_hstring(ctx, 1);
33367 (void) duk_require_hobject(ctx, 2);
33368
33369 DUK_ASSERT(obj != NULL);
33370 DUK_ASSERT(key != NULL);
33371 DUK_ASSERT(duk_get_hobject(ctx, 2) != NULL);
33372
33373 /*
33374 * Validate and convert argument property descriptor (an Ecmascript
33375 * object) into a set of defprop_flags and possibly property value,
33376 * getter, and/or setter values on the value stack.
33377 *
33378 * Lightfunc set/get values are coerced to full Functions.
33379 */
33380
33382 2 /*idx_desc*/,
33383 &defprop_flags,
33384 &idx_value,
33385 &get,
33386 &set);
33387
33388 /*
33389 * Use Object.defineProperty() helper for the actual operation.
33390 */
33391
33393 defprop_flags,
DUK_INTERNAL_DECL void duk_hobject_define_property_helper(duk_context *ctx, duk_uint_t defprop_flags, duk_hobject *obj, duk_hstring *key, duk_idx_t idx_value, duk_hobject *get, duk_hobject *set)

◆ duk_bi_object_constructor_get_own_property_descriptor()

DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_get_own_property_descriptor ( duk_context * ctx)

Definition at line 33279 of file duktape-1.8.0/src/duktape.c.

33280 {
33281 goto fail_loop;
33282 }

◆ duk_bi_object_constructor_is_extensible()

DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_is_extensible ( duk_context * ctx)

Definition at line 33537 of file duktape-1.8.0/src/duktape.c.

33538 {
33539 duk_hobject *h;
33540 duk_bool_t is_frozen;
33541 duk_bool_t rc;
33542
33543 h = duk_require_hobject_or_lfunc(ctx, 0);
33544 if (!h) {
33545 duk_push_true(ctx); /* frozen and sealed */
33546 } else {
33547 is_frozen = duk_get_current_magic(ctx);
DUK_INTERNAL_DECL duk_hobject * duk_require_hobject_or_lfunc(duk_context *ctx, duk_idx_t index)

References duk_get_current_magic(), duk_hobject_object_is_sealed_frozen_helper(), duk_push_boolean(), duk_push_true(), and duk_require_hobject_or_lfunc().

◆ duk_bi_object_constructor_is_sealed_frozen_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_is_sealed_frozen_shared ( duk_context * ctx)

Definition at line 33521 of file duktape-1.8.0/src/duktape.c.

33522 {
33523 /* Lightfunc, always success. */
33524 return 1;
33525 }
33526 DUK_ASSERT(h != NULL);
33527
33529
33530 /* A non-extensible object cannot gain any more properties,
33531 * so this is a good time to compact.
33532 */
33534
33535 return 1;
#define DUK_HOBJECT_CLEAR_EXTENSIBLE(h)

◆ duk_bi_object_constructor_keys_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_keys_shared ( duk_context * ctx)

Definition at line 33552 of file duktape-1.8.0/src/duktape.c.

33554 {
33555 duk_hobject *h;
33556
33557 h = duk_require_hobject_or_lfunc(ctx, 0);
33558 if (!h) {
33559 duk_push_false(ctx);
33560 } else {
33562 }
33563 return 1;
33564}
33565
33566/* Shared helper for Object.getOwnPropertyNames() and Object.keys().
33567 * Magic: 0=getOwnPropertyNames, 1=Object.keys.
33568 */
33570 duk_hthread *thr = (duk_hthread *) ctx;
33571 duk_hobject *obj;
33572#if defined(DUK_USE_ES6_PROXY)
33573 duk_hobject *h_proxy_target;
33574 duk_hobject *h_proxy_handler;
33575 duk_hobject *h_trap_result;
33576 duk_uarridx_t i, len, idx;
33577#endif
33578 duk_small_uint_t enum_flags;
33579
33580 DUK_ASSERT_TOP(ctx, 1);
33581 DUK_UNREF(thr);
33582
33584 DUK_ASSERT(obj != NULL);
33585 DUK_UNREF(obj);
33586
33587#if defined(DUK_USE_ES6_PROXY)
33589 obj,
33590 &h_proxy_target,
33591 &h_proxy_handler))) {
33592 goto skip_proxy;
33593 }
33594
33595 duk_push_hobject(ctx, h_proxy_handler);
33597 /* Careful with reachability here: don't pop 'obj' before pushing
33598 * proxy target.
33599 */
33600 DUK_DDD(DUK_DDDPRINT("no ownKeys trap, get keys of target instead"));
33601 duk_pop_2(ctx);
33602 duk_push_hobject(ctx, h_proxy_target);
33603 duk_replace(ctx, 0);
33604 DUK_ASSERT_TOP(ctx, 1);
33605 goto skip_proxy;
33606 }
33607
33608 /* [ obj handler trap ] */
33609 duk_insert(ctx, -2);
33610 duk_push_hobject(ctx, h_proxy_target); /* -> [ obj trap handler target ] */
33611 duk_call_method(ctx, 1 /*nargs*/); /* -> [ obj trap_result ] */
33612 h_trap_result = duk_require_hobject(ctx, -1);
33613 DUK_UNREF(h_trap_result);
33614
33615 len = (duk_uarridx_t) duk_get_length(ctx, -1);
33616 idx = 0;
33617 duk_push_array(ctx);
33618 for (i = 0; i < len; i++) {
33619 /* [ obj trap_result res_arr ] */
33620 if (duk_get_prop_index(ctx, -2, i) && duk_is_string(ctx, -1)) {
33621 /* XXX: for Object.keys() we should check enumerability of key */
33622 /* [ obj trap_result res_arr propname ] */
33623 duk_put_prop_index(ctx, -2, idx);
33624 idx++;
33625 } else {
33626 duk_pop(ctx);
33627 }
33628 }
33629
33630 /* XXX: missing trap result validation for non-configurable target keys
33631 * (must be present), for non-extensible target all target keys must be
33632 * present and no extra keys can be present.
33633 * http://www.ecma-international.org/ecma-262/6.0/#sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys
33634 */
33635
33636 /* XXX: for Object.keys() the [[OwnPropertyKeys]] result (trap result)
33637 * should be filtered so that only enumerable keys remain. Enumerability
33638 * should be checked with [[GetOwnProperty]] on the original object
33639 * (i.e., the proxy in this case). If the proxy has a getOwnPropertyDescriptor
33640 * trap, it should be triggered for every property. If the proxy doesn't have
33641 * the trap, enumerability should be checked against the target object instead.
33642 * We don't do any of this now, so Object.keys() and Object.getOwnPropertyNames()
33643 * return the same result now for proxy traps. We still do clean up the trap
33644 * result, so that Object.keys() and Object.getOwnPropertyNames() will return a
33645 * clean array of strings without gaps.
33646 */
33647 return 1;
33648
33649 skip_proxy:
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_keys_shared(duk_context *ctx)
#define DUK_STRIDX_OWN_KEYS

◆ duk_bi_object_constructor_prevent_extensions()

DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_prevent_extensions ( duk_context * ctx)

Definition at line 33500 of file duktape-1.8.0/src/duktape.c.

33501 {
33502 /* Lightfunc, always success. */
33503 return 1;
33504 }
33505
33506 is_freeze = (duk_bool_t) duk_get_current_magic(ctx);
33507 duk_hobject_object_seal_freeze_helper(thr, h, is_freeze);
33508
33509 /* Sealed and frozen objects cannot gain any more properties,
33510 * so this is a good time to compact them.
33511 */
33513
33514 return 1;
33515}
33516
33518 duk_hthread *thr = (duk_hthread *) ctx;
33519 duk_hobject *h;
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_prevent_extensions(duk_context *ctx)
DUK_INTERNAL_DECL void duk_hobject_object_seal_freeze_helper(duk_hthread *thr, duk_hobject *obj, duk_bool_t is_freeze)

◆ duk_bi_object_constructor_seal_freeze_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_seal_freeze_shared ( duk_context * ctx)

Definition at line 33478 of file duktape-1.8.0/src/duktape.c.

33495 {
33496 duk_hthread *thr = (duk_hthread *) ctx;
33497 duk_hobject *h;
33498 duk_bool_t is_freeze;

◆ duk_bi_object_getprototype_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_object_getprototype_shared ( duk_context * ctx)

Definition at line 33171 of file duktape-1.8.0/src/duktape.c.

33171 {
33172 duk_to_object(ctx, 0);
33173 return 1;
33174 }
33175
33180 return 1;
33181}
33182
33183/* Shared helper to implement Object.getPrototypeOf and the ES6
33184 * Object.prototype.__proto__ getter.
33185 *
33186 * http://www.ecma-international.org/ecma-262/6.0/index.html#sec-get-object.prototype.__proto__
33187 */
33189 duk_hthread *thr = (duk_hthread *) ctx;
33190 duk_hobject *h;
33192
33193 DUK_UNREF(thr);
33194
33195 /* magic: 0=getter call, 1=Object.getPrototypeOf */
33196 if (duk_get_current_magic(ctx) == 0) {
33198 duk_insert(ctx, 0);
33199 }
33200
33201 h = duk_require_hobject_or_lfunc(ctx, 0);
33202 /* h is NULL for lightfunc */
33203
33204 /* XXX: should the API call handle this directly, i.e. attempt
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_getprototype_shared(duk_context *ctx)

References duk_to_object().

◆ duk_bi_object_prototype_has_own_property()

DUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_has_own_property ( duk_context * ctx)

Definition at line 33697 of file duktape-1.8.0/src/duktape.c.

33699 {

◆ duk_bi_object_prototype_is_prototype_of()

DUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_is_prototype_of ( duk_context * ctx)

Definition at line 33674 of file duktape-1.8.0/src/duktape.c.

33674 {
33675 DUK_ASSERT_TOP(ctx, 0);
33678 if (!duk_is_callable(ctx, 1)) {
33679 return DUK_RET_TYPE_ERROR;
33680 }
33681 duk_dup(ctx, 0); /* -> [ O toString O ] */
33682 duk_call_method(ctx, 0); /* XXX: call method tail call? */
33683 return 1;
33684}
33685
33688 return 1;
33689}
33690
33692 duk_hthread *thr = (duk_hthread *) ctx;
33693 duk_hobject *h_v;
33694 duk_hobject *h_obj;
33695
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_value_of(duk_context *ctx)
#define DUK_STRIDX_TO_STRING
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_is_prototype_of(duk_context *ctx)

References DUK_ASSERT_TOP, duk_call_method(), duk_dup(), duk_get_prop_stridx(), duk_is_callable, duk_push_this_coercible_to_object(), DUK_RET_TYPE_ERROR, and DUK_STRIDX_TO_STRING.

◆ duk_bi_object_prototype_property_is_enumerable()

DUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_property_is_enumerable ( duk_context * ctx)

Definition at line 33701 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_object_prototype_to_locale_string()

DUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_to_locale_string ( duk_context * ctx)

Definition at line 33657 of file duktape-1.8.0/src/duktape.c.

33658 {
33659 /* Object.getOwnPropertyNames */
33660 enum_flags = DUK_ENUM_INCLUDE_NONENUMERABLE |
33663 }
33664
33665 return duk_hobject_get_enumerated_keys(ctx, enum_flags);
33666}
33667
#define DUK_ENUM_NO_PROXY_BEHAVIOR
#define DUK_ENUM_INCLUDE_NONENUMERABLE

◆ duk_bi_object_prototype_to_string()

DUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_to_string ( duk_context * ctx)

Definition at line 33651 of file duktape-1.8.0/src/duktape.c.

33654 {
33655 /* Object.keys */

◆ duk_bi_object_prototype_value_of()

DUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_value_of ( duk_context * ctx)

Definition at line 33669 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_object_setprototype_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_object_setprototype_shared ( duk_context * ctx)

Definition at line 33212 of file duktape-1.8.0/src/duktape.c.

33212 {
33213 proto = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h);
33214 if (proto) {
33215 duk_push_hobject(ctx, proto);
33216 } else {
33217 duk_push_null(ctx);
33218 }
33219 }
33220 return 1;
33221}
33222
33223/* Shared helper to implement ES6 Object.setPrototypeOf and
33224 * Object.prototype.__proto__ setter.
33225 *
33226 * http://www.ecma-international.org/ecma-262/6.0/index.html#sec-get-object.prototype.__proto__
33227 * http://www.ecma-international.org/ecma-262/6.0/index.html#sec-object.setprototypeof
33228 */
33230 duk_hthread *thr = (duk_hthread *) ctx;
33231 duk_hobject *h_obj;
33232 duk_hobject *h_new_proto;
33233 duk_hobject *h_curr;
33234 duk_ret_t ret_success = 1; /* retval for success path */
33235
33236 /* Preliminaries for __proto__ and setPrototypeOf (E6 19.1.2.18 steps 1-4);
33237 * magic: 0=setter call, 1=Object.setPrototypeOf
33238 */
33239 if (duk_get_current_magic(ctx) == 0) {
33241 duk_insert(ctx, 0);
33243 return 0;
33244 }
33245
33246 /* __proto__ setter returns 'undefined' on success unlike the
33247 * setPrototypeOf() call which returns the target object.
33248 */
33249 ret_success = 0;
33250 } else {
33253 }
33254
33255 h_new_proto = duk_get_hobject(ctx, 1);
33256 /* h_new_proto may be NULL */
33257 if (duk_is_lightfunc(ctx, 0)) {
33258 if (h_new_proto == thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE]) {
33259 goto skip;
33260 }
33261 goto fail_nonextensible;
33262 }
33263 h_obj = duk_get_hobject(ctx, 0);
33264 if (!h_obj) {
33265 goto skip;
33266 }
33267 DUK_ASSERT(h_obj != NULL);
33268
33269 /* [[SetPrototypeOf]] standard behavior, E6 9.1.2 */
33270 /* TODO: implement Proxy object support here */
33271
33272 if (h_new_proto == DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h_obj)) {
33273 goto skip;
33274 }
33275 if (!DUK_HOBJECT_HAS_EXTENSIBLE(h_obj)) {
33276 goto fail_nonextensible;
33277 }
#define DUK_TYPE_MASK_OBJECT
#define duk_require_object_coercible(ctx, index)
#define duk_require_type_mask(ctx, index, mask)
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_setprototype_shared(duk_context *ctx)
DUK_EXTERNAL duk_bool_t duk_is_lightfunc(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL void duk_push_this_check_object_coercible(duk_context *ctx)

◆ duk_bi_pointer_constructor()

DUK_INTERNAL_DECL duk_ret_t duk_bi_pointer_constructor ( duk_context * ctx)

Definition at line 33715 of file duktape-1.8.0/src/duktape.c.

33718 {
33719 return duk_hobject_object_ownprop_helper(ctx, DUK_PROPDESC_FLAG_ENUMERABLE /*required_desc_flags*/);
33720}
33721#line 1 "duk_bi_pointer.c"
33722/*
33723 * Pointer built-ins
33724 */
33725
33726/* include removed: duk_internal.h */
33727
33728/*
33729 * Constructor
33730 */
33731
33733 /* XXX: this behavior is quite useless now; it would be nice to be able
33734 * to create pointer values from e.g. numbers or strings. Numbers are
33735 * problematic on 64-bit platforms though. Hex encoded strings?
33736 */
33737 if (duk_get_top(ctx) == 0) {
33738 duk_push_pointer(ctx, NULL);
33739 } else {
33740 duk_to_pointer(ctx, 0);
33741 }
DUK_EXTERNAL void * duk_to_pointer(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL duk_bool_t duk_hobject_object_ownprop_helper(duk_context *ctx, duk_small_uint_t required_desc_flags)
DUK_INTERNAL_DECL duk_ret_t duk_bi_pointer_constructor(duk_context *ctx)

◆ duk_bi_pointer_prototype_tostring_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_pointer_prototype_tostring_shared ( duk_context * ctx)

Definition at line 33747 of file duktape-1.8.0/src/duktape.c.

33764 {
33765 duk_tval *tv;
33766 duk_small_int_t to_string = duk_get_current_magic(ctx);
33767
33768 duk_push_this(ctx);
33769 tv = duk_require_tval(ctx, -1);
33770 DUK_ASSERT(tv != NULL);
33771
33772 if (DUK_TVAL_IS_POINTER(tv)) {
33773 /* nop */
33774 } else if (DUK_TVAL_IS_OBJECT(tv)) {
33776 DUK_ASSERT(h != NULL);
33777
33778 /* Must be a "pointer object", i.e. class "Pointer" */
#define DUK_TVAL_IS_POINTER(tv)

◆ duk_bi_proxy_constructor()

DUK_INTERNAL_DECL duk_ret_t duk_bi_proxy_constructor ( duk_context * ctx)

Definition at line 33787 of file duktape-1.8.0/src/duktape.c.

33788 {
33789 duk_to_string(ctx, -1);
33790 }
33791 return 1;
33792
33793 type_error:
33794 return DUK_RET_TYPE_ERROR;
33795}
33796#line 1 "duk_bi_proxy.c"
33797/*
33798 * Proxy built-in (ES6)
33799 */
33800
33801/* include removed: duk_internal.h */
33802
33803#if defined(DUK_USE_ES6_PROXY)
33805 duk_hobject *h_target;
33806 duk_hobject *h_handler;
33807
33808 if (!duk_is_constructor_call(ctx)) {
33809 return DUK_RET_TYPE_ERROR;
33810 }
33811
33812 /* Reject a proxy object as the target because it would need
33813 * special handler in property lookups. (ES6 has no such restriction)
33814 */
33815 h_target = duk_require_hobject_or_lfunc_coerce(ctx, 0);
33816 DUK_ASSERT(h_target != NULL);
33817 if (DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(h_target)) {
33818 return DUK_RET_TYPE_ERROR;
33819 }
33820
33821 /* Reject a proxy object as the handler because it would cause
33822 * potentially unbounded recursion. (ES6 has no such restriction)
33823 */
33824 h_handler = duk_require_hobject_or_lfunc_coerce(ctx, 1);
33825 DUK_ASSERT(h_handler != NULL);
33826 if (DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(h_handler)) {
33827 return DUK_RET_TYPE_ERROR;
33828 }
33829
33830 /* XXX: the returned value is exotic in ES6, but we use a
33831 * simple object here with no prototype. Without a prototype,
33832 * [[DefaultValue]] coercion fails which is abit confusing.
33833 * No callable check/handling in the current Proxy subset.
33834 */
33839 NULL);
DUK_INTERNAL_DECL duk_ret_t duk_bi_proxy_constructor(duk_context *ctx)

References duk_to_string().

◆ duk_bi_regexp_constructor()

DUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_constructor ( duk_context * ctx)

Definition at line 33866 of file duktape-1.8.0/src/duktape.c.

33872 {
33873 duk_hobject *h;
33874
33875 duk_push_this(ctx);
33877 DUK_ASSERT(h != NULL);
33878 DUK_UNREF(h);
33879 duk_insert(ctx, 0); /* prepend regexp to valstack 0 index */
33880}
33881
33882/* XXX: much to improve (code size) */
33884 duk_hthread *thr = (duk_hthread *) ctx;
33885 duk_hobject *h_pattern;
33886
33887 DUK_ASSERT_TOP(ctx, 2);
33888 h_pattern = duk_get_hobject(ctx, 0);
33889
33890 if (!duk_is_constructor_call(ctx) &&
33891 h_pattern != NULL &&
33893 duk_is_undefined(ctx, 1)) {
33894 /* Called as a function, pattern has [[Class]] "RegExp" and
33895 * flags is undefined -> return object as is.
33896 */
33897 duk_dup(ctx, 0);
33898 return 1;
33899 }
33900
33901 /* Else functionality is identical for function call and constructor
33902 * call.
33903 */
33904
33905 if (h_pattern != NULL &&
33907 if (duk_is_undefined(ctx, 1)) {
33908 duk_bool_t flag_g, flag_i, flag_m;
33913
33914 duk_push_sprintf(ctx, "%s%s%s",
33915 (const char *) (flag_g ? "g" : ""),
33916 (const char *) (flag_i ? "i" : ""),
33917 (const char *) (flag_m ? "m" : ""));
33918
33919 /* [ ... pattern flags ] */
33920 } else {
33921 return DUK_RET_TYPE_ERROR;
33922 }
33923 } else {
33924 if (duk_is_undefined(ctx, 0)) {
33925 duk_push_string(ctx, "");
33926 } else {
33927 duk_dup(ctx, 0);
33928 duk_to_string(ctx, -1);
33929 }
33930 if (duk_is_undefined(ctx, 1)) {
33931 duk_push_string(ctx, "");
33932 } else {
33933 duk_dup(ctx, 1);
33934 duk_to_string(ctx, -1);
33935 }
33936
33937 /* [ ... pattern flags ] */
DUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_constructor(duk_context *ctx)
#define DUK_STRIDX_SOURCE
DUK_INTERNAL_DECL duk_bool_t duk_get_prop_stridx_boolean(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_bool_t *out_has_prop)
#define DUK_STRIDX_IGNORE_CASE
#define DUK_STRIDX_MULTILINE

References DUK_ASSERT, DUK_HOBJECT_CLASS_REGEXP, duk_insert(), duk_push_this(), duk_require_hobject_with_class(), DUK_UNREF, and NULL.

◆ duk_bi_regexp_prototype_exec()

DUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_prototype_exec ( duk_context * ctx)

Definition at line 33939 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_regexp_prototype_test()

DUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_prototype_test ( duk_context * ctx)

Definition at line 33951 of file duktape-1.8.0/src/duktape.c.

33956 {
33958
33959 /* [ regexp input ] */
33960
33962
33963 /* [ result ] */
33964
DUK_LOCAL void duk__get_this_regexp(duk_context *ctx)
DUK_INTERNAL_DECL void duk_regexp_match(duk_hthread *thr)

◆ duk_bi_regexp_prototype_to_string()

DUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_prototype_to_string ( duk_context * ctx)

Definition at line 33966 of file duktape-1.8.0/src/duktape.c.

33968 {
33970
33971 /* [ regexp input ] */
33972
33973 /* result object is created and discarded; wasteful but saves code space */
33975
33976 /* [ result ] */
33977
33978 duk_push_boolean(ctx, (duk_is_null(ctx, -1) ? 0 : 1));
33979
33980 return 1;
33981}
33982
33984 duk_hstring *h_bc;
33985 duk_small_int_t re_flags;
33986
33987#if 0
33988 /* A little tricky string approach to provide the flags string.
33989 * This depends on the specific flag values in duk_regexp.h,
33990 * which needs to be asserted for. In practice this doesn't
33991 * produce more compact code than the easier approach in use.
33992 */
33993
33994 const char *flag_strings = "gim\0gi\0gm\0g\0";
33995 duk_uint8_t flag_offsets[8] = {
33996 (duk_uint8_t) 3, /* flags: "" */
33997 (duk_uint8_t) 10, /* flags: "g" */
33998 (duk_uint8_t) 5, /* flags: "i" */
33999 (duk_uint8_t) 4, /* flags: "gi" */
34000 (duk_uint8_t) 2, /* flags: "m" */
34001 (duk_uint8_t) 7, /* flags: "gm" */
34002 (duk_uint8_t) 1, /* flags: "im" */
34003 (duk_uint8_t) 0, /* flags: "gim" */
34004 };
34008#endif
34009
34011
34012 /* [ regexp ] */
34013
34016 h_bc = duk_get_hstring(ctx, -1);
34017 DUK_ASSERT(h_bc != NULL);
34020 DUK_ASSERT(DUK_HSTRING_GET_DATA(h_bc)[0] < 0x80);
34021 re_flags = (duk_small_int_t) DUK_HSTRING_GET_DATA(h_bc)[0];
34022
34023 /* [ regexp source bytecode ] */
34024
34025#if 1
34026 /* This is a cleaner approach and also produces smaller code than
34027 * the other alternative. Use duk_require_string() for format
34028 * safety (although the source property should always exist).
34029 */
34030 duk_push_sprintf(ctx, "/%s/%s%s%s",
34031 (const char *) duk_require_string(ctx, -2), /* require to be safe */
DUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_prototype_to_string(duk_context *ctx)

◆ duk_bi_string_constructor()

DUK_INTERNAL_DECL duk_ret_t duk_bi_string_constructor ( duk_context * ctx)

Definition at line 34076 of file duktape-1.8.0/src/duktape.c.

34093 {
34094 /* String constructor needs to distinguish between an argument not given at all
34095 * vs. given as 'undefined'. We're a vararg function to handle this properly.
34096 */
34097
34098 if (duk_get_top(ctx) == 0) {
34100 } else {
34101 duk_to_string(ctx, 0);
34102 }
34103 DUK_ASSERT(duk_is_string(ctx, 0));

References DUK_ASSERT, duk_get_top(), duk_is_string(), duk_push_hstring_stridx(), duk_set_top(), DUK_STRIDX_EMPTY_STRING, and duk_to_string().

◆ duk_bi_string_constructor_from_char_code()

DUK_INTERNAL_DECL duk_ret_t duk_bi_string_constructor_from_char_code ( duk_context * ctx)

Definition at line 34105 of file duktape-1.8.0/src/duktape.c.

34106 {
34112
34113 /* String object internal value is immutable */
34114 duk_dup(ctx, 0);
34116 }
34117 /* Note: unbalanced stack on purpose */
34118
34119 return 1;
34120}
34121
34123 duk_hthread *thr = (duk_hthread *) ctx;
34124 duk_bufwriter_ctx bw_alloc;
34126 duk_idx_t i, n;
34128
34129 /* XXX: It would be nice to build the string directly but ToUint16()
34130 * coercion is needed so a generic helper would not be very
34131 * helpful (perhaps coerce the value stack first here and then
34132 * build a string from a duk_tval number sequence in one go?).
34133 */
34134
34135 n = duk_get_top(ctx);
34136
34137 bw = &bw_alloc;
34138 DUK_BW_INIT_PUSHBUF(thr, bw, n); /* initial estimate for ASCII only codepoints */
34139
34140 for (i = 0; i < n; i++) {
34141 /* XXX: could improve bufwriter handling to write multiple codepoints
34142 * with one ensure call but the relative benefit would be quite small.
34143 */
34144
34145#if defined(DUK_USE_NONSTD_STRING_FROMCHARCODE_32BIT)
34146 /* ToUint16() coercion is mandatory in the E5.1 specification, but
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_constructor_from_char_code(duk_context *ctx)
#define DUK_BIDX_STRING_PROTOTYPE

References DUK_BIDX_STRING_PROTOTYPE, duk_dup(), DUK_HOBJECT_CLASS_AS_FLAGS, DUK_HOBJECT_CLASS_STRING, DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ, DUK_HOBJECT_FLAG_EXTENSIBLE, DUK_PROPDESC_FLAGS_NONE, duk_push_object_helper(), DUK_STRIDX_INT_VALUE, and duk_xdef_prop_stridx().

◆ duk_bi_string_prototype_caseconv_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_caseconv_shared ( duk_context * ctx)

Definition at line 34357 of file duktape-1.8.0/src/duktape.c.

34360 {
34361 end_pos = start_pos;
34362 }
34363
34364 DUK_ASSERT(end_pos >= start_pos);

◆ duk_bi_string_prototype_char_at()

DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_char_at ( duk_context * ctx)

Definition at line 34189 of file duktape-1.8.0/src/duktape.c.

34192 {
34193 goto type_error;
34194 }
34195
34196 /* never here, but fall through */
34197
34198 type_error:

◆ duk_bi_string_prototype_char_code_at()

DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_char_code_at ( duk_context * ctx)

Definition at line 34200 of file duktape-1.8.0/src/duktape.c.

34206 {
34207 duk_int_t pos;
34208
34209 /* XXX: faster implementation */
34210
34212 pos = duk_to_int(ctx, 0);
34213 duk_substring(ctx, -1, pos, pos + 1);
34214 return 1;
34215}
34216
34218 duk_hthread *thr = (duk_hthread *) ctx;
34219 duk_int_t pos;
34220 duk_hstring *h;
34221 duk_bool_t clamped;
34222
34223 /* XXX: faster implementation */
34224
34225 DUK_DDD(DUK_DDDPRINT("arg=%!T", (duk_tval *) duk_get_tval(ctx, 0)));
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_char_code_at(duk_context *ctx)
DUK_INTERNAL_DECL duk_hstring * duk_push_this_coercible_to_string(duk_context *ctx)

◆ duk_bi_string_prototype_concat()

DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_concat ( duk_context * ctx)

Definition at line 35298 of file duktape-1.8.0/src/duktape.c.

35302 {
35303 duk_push_null(ctx);
35304 }

◆ duk_bi_string_prototype_indexof_shared()

DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_indexof_shared ( duk_context * ctx)

Definition at line 34370 of file duktape-1.8.0/src/duktape.c.

34374 {
34375 duk_hthread *thr = (duk_hthread *) ctx;
34376 duk_small_int_t uppercase = duk_get_current_magic(ctx);
34377
34380 return 1;
34381}
34382
34383/*
34384 * indexOf() and lastIndexOf()
34385 */
34386
34388 duk_hthread *thr = (duk_hthread *) ctx;
34389 duk_hstring *h_this;
34390 duk_hstring *h_search;
34391 duk_int_t clen_this;
34392 duk_int_t cpos;
34393 duk_int_t bpos;
34394 const duk_uint8_t *p_start, *p_end, *p;
34395 const duk_uint8_t *q_start;
34396 duk_int_t q_blen;
34397 duk_uint8_t firstbyte;
34398 duk_uint8_t t;
34399 duk_small_int_t is_lastindexof = duk_get_current_magic(ctx); /* 0=indexOf, 1=lastIndexOf */
34400
34402 DUK_ASSERT(h_this != NULL);
34403 clen_this = (duk_int_t) DUK_HSTRING_GET_CHARLEN(h_this);
34404
34405 h_search = duk_to_hstring(ctx, 0);
34406 DUK_ASSERT(h_search != NULL);
34407 q_start = DUK_HSTRING_GET_DATA(h_search);
34408 q_blen = (duk_int_t) DUK_HSTRING_GET_BYTELEN(h_search);
34409
34410 duk_to_number(ctx, 1);
34411 if (duk_is_nan(ctx, 1) && is_lastindexof) {
34412 /* indexOf: NaN should cause pos to be zero.
34413 * lastIndexOf: NaN should cause pos to be +Infinity
34414 * (and later be clamped to len).
34415 */
34416 cpos = clen_this;
34417 } else {
34418 cpos = duk_to_int_clamped(ctx, 1, 0, clen_this);
34419 }
34420
34421 /* Empty searchstring always matches; cpos must be clamped here.
34422 * (If q_blen were < 0 due to clamped coercion, it would also be
34423 * caught here.)
34424 */
34425 if (q_blen <= 0) {
34426 duk_push_int(ctx, cpos);
34427 return 1;
34428 }
34429 DUK_ASSERT(q_blen > 0);
34430
34431 bpos = (duk_int_t) duk_heap_strcache_offset_char2byte(thr, h_this, (duk_uint32_t) cpos);
34432
34433 p_start = DUK_HSTRING_GET_DATA(h_this);
34434 p_end = p_start + DUK_HSTRING_GET_BYTELEN(h_this);
34435 p = p_start + bpos;
34436
34437 /* This loop is optimized for size. For speed, there should be
34438 * two separate loops, and we should ensure that memcmp() can be
34439 * used without an extra "will searchstring fit" check. Doing
34440 * the preconditioning for 'p' and 'p_end' is easy but cpos
34441 * must be updated if 'p' is wound back (backward scanning).
34442 */
34443
34444 firstbyte = q_start[0]; /* leading byte of match string */
34445 while (p <= p_end && p >= p_start) {
34446 t = *p;
34447
34448 /* For Ecmascript strings, this check can only match for
34449 * initial UTF-8 bytes (not continuation bytes). For other
34450 * strings all bets are off.
34451 */
34452
34453 if ((t == firstbyte) && ((duk_size_t) (p_end - p) >= (duk_size_t) q_blen)) {
34454 DUK_ASSERT(q_blen > 0); /* no issues with memcmp() zero size, even if broken */
34455 if (DUK_MEMCMP((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) {
34456 duk_push_int(ctx, cpos);
34457 return 1;
34458 }
34459 }
34460
34461 /* track cpos while scanning */
34462 if (is_lastindexof) {
34463 /* when going backwards, we decrement cpos 'early';
34464 * 'p' may point to a continuation byte of the char
34465 * at offset 'cpos', but that's OK because we'll
34466 * backtrack all the way to the initial byte.
DUK_EXTERNAL duk_bool_t duk_is_nan(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL void duk_unicode_case_convert_string(duk_hthread *thr, duk_bool_t uppercase)
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_indexof_shared(duk_context *ctx)

References duk_get_current_magic(), duk_push_this_coercible_to_string(), and duk_unicode_case_convert_string().

◆ duk_bi_string_prototype_locale_compare()

DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_locale_compare ( duk_context * ctx)

Definition at line 35314 of file duktape-1.8.0/src/duktape.c.

35315 {
35316 /* duk_concat() coerces arguments with ToString() in correct order */
35318 duk_insert(ctx, 0); /* this is relatively expensive */
35319 duk_concat(ctx, duk_get_top(ctx));
35320 return 1;
35321}
35322
35324 DUK_ASSERT_TOP(ctx, 0);
35326 duk_trim(ctx, 0);
35327 DUK_ASSERT_TOP(ctx, 1);
35328 return 1;
35329}
35330
35332 duk_hstring *h1;
35333 duk_hstring *h2;
35334 duk_size_t h1_len, h2_len, prefix_len;
35335 duk_small_int_t ret = 0;
35336 duk_small_int_t rc;
35337
35338 /* The current implementation of localeCompare() is simply a codepoint
35339 * by codepoint comparison, implemented with a simple string compare
35340 * because UTF-8 should preserve codepoint ordering (assuming valid
35341 * shortest UTF-8 encoding).
35342 *
35343 * The specification requires that the return value must be related
35344 * to the sort order: e.g. negative means that 'this' comes before
35345 * 'that' in sort order. We assume an ascending sort order.
35346 */
35347
35348 /* XXX: could share code with duk_js_ops.c, duk_js_compare_helper */
35349
35351 DUK_ASSERT(h1 != NULL);
35352
35353 h2 = duk_to_hstring(ctx, 0);
35354 DUK_ASSERT(h2 != NULL);
35355
35356 h1_len = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h1);
35357 h2_len = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h2);
35358 prefix_len = (h1_len <= h2_len ? h1_len : h2_len);
35359
35360 /* Zero size compare not an issue with DUK_MEMCMP. */
35361 rc = (duk_small_int_t) DUK_MEMCMP((const void *) DUK_HSTRING_GET_DATA(h1),
35362 (const void *) DUK_HSTRING_GET_DATA(h2),
35363 (size_t) prefix_len);
35364
35365 if (rc < 0) {
35366 ret = -1;
35367 goto done;
35368 } else if (rc > 0) {
35369 ret = 1;
35370 goto done;
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_locale_compare(duk_context *ctx)
DUK_EXTERNAL void duk_trim(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_trim(duk_context *ctx)

References duk_concat(), duk_get_top(), duk_insert(), and duk_push_this_coercible_to_string().

◆ duk_bi_string_prototype_match()

DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_match ( duk_context * ctx)

Definition at line 35220 of file duktape-1.8.0/src/duktape.c.

35220 {
35221 duk_push_int(ctx, -1);
35222 return 1;
35223 }
35224
35226 DUK_ASSERT(duk_is_number(ctx, -1));
35227 return 1;
35228}
35229#else /* DUK_USE_REGEXP_SUPPORT */
35231 DUK_UNREF(ctx);
35233}
35234#endif /* DUK_USE_REGEXP_SUPPORT */
35235
35236#ifdef DUK_USE_REGEXP_SUPPORT
35238 duk_hthread *thr = (duk_hthread *) ctx;
35239 duk_bool_t global;
35240 duk_int_t prev_last_index;
35241 duk_int_t this_index;
35242 duk_int_t arr_idx;
35243
35244 DUK_ASSERT_TOP(ctx, 1);
35246 duk__to_regexp_helper(ctx, 0 /*index*/, 0 /*force_new*/);
35248 DUK_ASSERT_TOP(ctx, 2);
35249
35250 /* stack[0] = regexp
35251 * stack[1] = string
35252 */
35253
35254 if (!global) {
35255 duk_regexp_match(thr); /* -> [ res_obj ] */
35256 return 1; /* return 'res_obj' */
35257 }
35258
35259 /* Global case is more complex. */
35260
35261 /* [ regexp string ] */
35262
35263 duk_push_int(ctx, 0);
35265 duk_push_array(ctx);
35266
35267 /* [ regexp string res_arr ] */
35268
35269 prev_last_index = 0;
35270 arr_idx = 0;
35271
35272 for (;;) {
35273 DUK_ASSERT_TOP(ctx, 3);
35274
35275 duk_dup(ctx, 0);
35276 duk_dup(ctx, 1);
35277 duk_regexp_match(thr); /* -> [ ... regexp string ] -> [ ... res_obj ] */
35278
35279 if (!duk_is_object(ctx, -1)) {
35280 duk_pop(ctx);
35281 break;
35282 }
35283
35285 DUK_ASSERT(duk_is_number(ctx, -1));
35286 this_index = duk_get_int(ctx, -1);
35287 duk_pop(ctx);
35288
35289 if (this_index == prev_last_index) {
35290 this_index++;
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_match(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_search(duk_context *ctx)

References duk_push_int().

◆ duk_bi_string_prototype_replace()

DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_replace ( duk_context * ctx)

Definition at line 34483 of file duktape-1.8.0/src/duktape.c.

34500 {
34501 duk_hthread *thr = (duk_hthread *) ctx;
34502 duk_hstring *h_input;
34503 duk_hstring *h_match;
34504 duk_hstring *h_search;
34505 duk_hobject *h_re;
34506 duk_bufwriter_ctx bw_alloc;
34508#ifdef DUK_USE_REGEXP_SUPPORT
34509 duk_bool_t is_regexp;
34510 duk_bool_t is_global;
34511#endif
34512 duk_bool_t is_repl_func;
34513 duk_uint32_t match_start_coff, match_start_boff;
34514#ifdef DUK_USE_REGEXP_SUPPORT
34515 duk_int_t match_caps;
34516#endif
34517 duk_uint32_t prev_match_end_boff;
34518 const duk_uint8_t *r_start, *r_end, *r; /* repl string scan */
34519 duk_size_t tmp_sz;
34520
34521 DUK_ASSERT_TOP(ctx, 2);
34522 h_input = duk_push_this_coercible_to_string(ctx);
34523 DUK_ASSERT(h_input != NULL);
34524
34525 bw = &bw_alloc;
34526 DUK_BW_INIT_PUSHBUF(thr, bw, DUK_HSTRING_GET_BYTELEN(h_input)); /* input size is good output starting point */
34527
34528 DUK_ASSERT_TOP(ctx, 4);
34529
34530 /* stack[0] = search value
34531 * stack[1] = replace value
34532 * stack[2] = input string
34533 * stack[3] = result buffer
34534 */
34535
34537 if (h_re) {
34538#ifdef DUK_USE_REGEXP_SUPPORT
34539 is_regexp = 1;
34541
34542 if (is_global) {
34543 /* start match from beginning */
34544 duk_push_int(ctx, 0);
34546 }
34547#else /* DUK_USE_REGEXP_SUPPORT */
34549#endif /* DUK_USE_REGEXP_SUPPORT */
34550 } else {
34551 duk_to_string(ctx, 0);
34552#ifdef DUK_USE_REGEXP_SUPPORT
34553 is_regexp = 0;
34554 is_global = 0;
34555#endif
34556 }
34557
34558 if (duk_is_function(ctx, 1)) {
34559 is_repl_func = 1;
34560 r_start = NULL;
34561 r_end = NULL;
34562 } else {
34563 duk_hstring *h_repl;
34564
34565 is_repl_func = 0;
34566 h_repl = duk_to_hstring(ctx, 1);
34567 DUK_ASSERT(h_repl != NULL);
34568 r_start = DUK_HSTRING_GET_DATA(h_repl);
34569 r_end = r_start + DUK_HSTRING_GET_BYTELEN(h_repl);
34570 }
34571
34572 prev_match_end_boff = 0;
34573
34574 for (;;) {
34575 /*
34576 * If matching with a regexp:
34577 * - non-global RegExp: lastIndex not touched on a match, zeroed
34578 * on a non-match
34579 * - global RegExp: on match, lastIndex will be updated by regexp
34580 * executor to point to next char after the matching part (so that
34581 * characters in the matching part are not matched again)
34582 *
34583 * If matching with a string:
34584 * - always non-global match, find first occurrence
34585 *
34586 * We need:
34587 * - The character offset of start-of-match for the replacer function
34588 * - The byte offsets for start-of-match and end-of-match to implement
34589 * the replacement values $&, $`, and $', and to copy non-matching
34590 * input string portions (including header and trailer) verbatim.
34591 *
34592 * NOTE: the E5.1 specification is a bit vague how the RegExp should
34593 * behave in the replacement process; e.g. is matching done first for
34594 * all matches (in the global RegExp case) before any replacer calls
34595 * are made? See: test-bi-string-proto-replace.js for discussion.
34596 */
34597
34598 DUK_ASSERT_TOP(ctx, 4);
34599
34600#ifdef DUK_USE_REGEXP_SUPPORT
34601 if (is_regexp) {
34602 duk_dup(ctx, 0);
34603 duk_dup(ctx, 2);
34604 duk_regexp_match(thr); /* [ ... regexp input ] -> [ res_obj ] */
34605 if (!duk_is_object(ctx, -1)) {
34606 duk_pop(ctx);
34607 break;
34608 }
34609
34611 DUK_ASSERT(duk_is_number(ctx, -1));
34612 match_start_coff = duk_get_int(ctx, -1);
34613 duk_pop(ctx);
34614
34615 duk_get_prop_index(ctx, -1, 0);
34616 DUK_ASSERT(duk_is_string(ctx, -1));
34617 h_match = duk_get_hstring(ctx, -1);
34618 DUK_ASSERT(h_match != NULL);
34619 duk_pop(ctx); /* h_match is borrowed, remains reachable through match_obj */
34620
34621 if (DUK_HSTRING_GET_BYTELEN(h_match) == 0) {
34622 /* This should be equivalent to match() algorithm step 8.f.iii.2:
34623 * detect an empty match and allow it, but don't allow it twice.
34624 */
34625 duk_uint32_t last_index;
34626
34628 last_index = (duk_uint32_t) duk_get_uint(ctx, -1);
34629 DUK_DDD(DUK_DDDPRINT("empty match, bump lastIndex: %ld -> %ld",
34630 (long) last_index, (long) (last_index + 1)));
34631 duk_pop(ctx);
34632 duk_push_int(ctx, last_index + 1);
34634 }
34635
34636 DUK_ASSERT(duk_get_length(ctx, -1) <= DUK_INT_MAX); /* string limits */
34637 match_caps = (duk_int_t) duk_get_length(ctx, -1);
34638 } else {
34639#else /* DUK_USE_REGEXP_SUPPORT */
34640 { /* unconditionally */
34641#endif /* DUK_USE_REGEXP_SUPPORT */
34642 const duk_uint8_t *p_start, *p_end, *p; /* input string scan */
34643 const duk_uint8_t *q_start; /* match string */
34644 duk_size_t q_blen;
34645
34646#ifdef DUK_USE_REGEXP_SUPPORT
34647 DUK_ASSERT(!is_global); /* single match always */
34648#endif
34649
34650 p_start = DUK_HSTRING_GET_DATA(h_input);
34651 p_end = p_start + DUK_HSTRING_GET_BYTELEN(h_input);
34652 p = p_start;
34653
34654 h_search = duk_get_hstring(ctx, 0);
34655 DUK_ASSERT(h_search != NULL);
34656 q_start = DUK_HSTRING_GET_DATA(h_search);
34657 q_blen = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h_search);
34658
34659 p_end -= q_blen; /* ensure full memcmp() fits in while */
34660
34661 match_start_coff = 0;
34662
34663 while (p <= p_end) {
34664 DUK_ASSERT(p + q_blen <= DUK_HSTRING_GET_DATA(h_input) + DUK_HSTRING_GET_BYTELEN(h_input));
34665 if (DUK_MEMCMP((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) {
34666 duk_dup(ctx, 0);
34667 h_match = duk_get_hstring(ctx, -1);
34668 DUK_ASSERT(h_match != NULL);
34669#ifdef DUK_USE_REGEXP_SUPPORT
34670 match_caps = 0;
34671#endif
34672 goto found;
34673 }
34674
34675 /* track utf-8 non-continuation bytes */
34676 if ((p[0] & 0xc0) != 0x80) {
34677 match_start_coff++;
34678 }
34679 p++;
34680 }
34681
34682 /* not found */
34683 break;
34684 }
34685 found:
34686
34687 /* stack[0] = search value
34688 * stack[1] = replace value
34689 * stack[2] = input string
34690 * stack[3] = result buffer
34691 * stack[4] = regexp match OR match string
34692 */
34693
34694 match_start_boff = duk_heap_strcache_offset_char2byte(thr, h_input, match_start_coff);
34695
34696 tmp_sz = (duk_size_t) (match_start_boff - prev_match_end_boff);
34697 DUK_BW_WRITE_ENSURE_BYTES(thr, bw, DUK_HSTRING_GET_DATA(h_input) + prev_match_end_boff, tmp_sz);
34698
34699 prev_match_end_boff = match_start_boff + DUK_HSTRING_GET_BYTELEN(h_match);
34700
34701 if (is_repl_func) {
34702 duk_idx_t idx_args;
34703 duk_hstring *h_repl;
34704
34705 /* regexp res_obj is at index 4 */
34706
34707 duk_dup(ctx, 1);
34708 idx_args = duk_get_top(ctx);
34709
34710#ifdef DUK_USE_REGEXP_SUPPORT
34711 if (is_regexp) {
34712 duk_int_t idx;
34713 duk_require_stack(ctx, match_caps + 2);
34714 for (idx = 0; idx < match_caps; idx++) {
34715 /* match followed by capture(s) */
34716 duk_get_prop_index(ctx, 4, idx);
34717 }
34718 } else {
34719#else /* DUK_USE_REGEXP_SUPPORT */
34720 { /* unconditionally */
34721#endif /* DUK_USE_REGEXP_SUPPORT */
34722 /* match == search string, by definition */
34723 duk_dup(ctx, 0);
34724 }
34725 duk_push_int(ctx, match_start_coff);
34726 duk_dup(ctx, 2);
34727
34728 /* [ ... replacer match [captures] match_char_offset input ] */
34729
34730 duk_call(ctx, duk_get_top(ctx) - idx_args);
34731 h_repl = duk_to_hstring(ctx, -1); /* -> [ ... repl_value ] */
34732 DUK_ASSERT(h_repl != NULL);
34733
34734 DUK_BW_WRITE_ENSURE_HSTRING(thr, bw, h_repl);
34735
34736 duk_pop(ctx); /* repl_value */
34737 } else {
34738 r = r_start;
34739
34740 while (r < r_end) {
34741 duk_int_t ch1;
34742 duk_int_t ch2;
34743#ifdef DUK_USE_REGEXP_SUPPORT
34744 duk_int_t ch3;
34745#endif
34747
34748 ch1 = *r++;
34749 if (ch1 != DUK_ASC_DOLLAR) {
34750 goto repl_write;
34751 }
34752 left = r_end - r;
34753
34754 if (left <= 0) {
34755 goto repl_write;
34756 }
34757
34758 ch2 = r[0];
34759 switch ((int) ch2) {
34760 case DUK_ASC_DOLLAR: {
34761 ch1 = (1 << 8) + DUK_ASC_DOLLAR;
34762 goto repl_write;
34763 }
34764 case DUK_ASC_AMP: {
34765 DUK_BW_WRITE_ENSURE_HSTRING(thr, bw, h_match);
34766 r++;
34767 continue;
34768 }
34769 case DUK_ASC_GRAVE: {
34770 tmp_sz = (duk_size_t) match_start_boff;
34771 DUK_BW_WRITE_ENSURE_BYTES(thr, bw, DUK_HSTRING_GET_DATA(h_input), tmp_sz);
34772 r++;
34773 continue;
34774 }
34775 case DUK_ASC_SINGLEQUOTE: {
34776 duk_uint32_t match_end_boff;
34777
34778 /* Use match charlen instead of bytelen, just in case the input and
34779 * match codepoint encodings would have different lengths.
34780 */
34781 match_end_boff = duk_heap_strcache_offset_char2byte(thr,
34782 h_input,
34783 match_start_coff + DUK_HSTRING_GET_CHARLEN(h_match));
34784
34785 tmp_sz = (duk_size_t) (DUK_HSTRING_GET_BYTELEN(h_input) - match_end_boff);
34786 DUK_BW_WRITE_ENSURE_BYTES(thr, bw, DUK_HSTRING_GET_DATA(h_input) + match_end_boff, tmp_sz);
34787 r++;
34788 continue;
34789 }
34790 default: {
34791#ifdef DUK_USE_REGEXP_SUPPORT
34792 duk_int_t capnum, captmp, capadv;
34793 /* XXX: optional check, match_caps is zero if no regexp,
34794 * so dollar will be interpreted literally anyway.
34795 */
34796
34797 if (!is_regexp) {
34798 goto repl_write;
34799 }
34800
34801 if (!(ch2 >= DUK_ASC_0 && ch2 <= DUK_ASC_9)) {
34802 goto repl_write;
34803 }
34804 capnum = ch2 - DUK_ASC_0;
34805 capadv = 1;
34806
34807 if (left >= 2) {
34808 ch3 = r[1];
34809 if (ch3 >= DUK_ASC_0 && ch3 <= DUK_ASC_9) {
34810 captmp = capnum * 10 + (ch3 - DUK_ASC_0);
34811 if (captmp < match_caps) {
34812 capnum = captmp;
34813 capadv = 2;
34814 }
34815 }
34816 }
34817
34818 if (capnum > 0 && capnum < match_caps) {
34819 DUK_ASSERT(is_regexp != 0); /* match_caps == 0 without regexps */
34820
34821 /* regexp res_obj is at offset 4 */
34822 duk_get_prop_index(ctx, 4, (duk_uarridx_t) capnum);
34823 if (duk_is_string(ctx, -1)) {
34824 duk_hstring *h_tmp_str;
34825
34826 h_tmp_str = duk_get_hstring(ctx, -1);
34827 DUK_ASSERT(h_tmp_str != NULL);
34828
34829 DUK_BW_WRITE_ENSURE_HSTRING(thr, bw, h_tmp_str);
34830 } else {
34831 /* undefined -> skip (replaced with empty) */
34832 }
34833 duk_pop(ctx);
34834 r += capadv;
34835 continue;
34836 } else {
34837 goto repl_write;
34838 }
34839#else /* DUK_USE_REGEXP_SUPPORT */
34840 goto repl_write; /* unconditionally */
34841#endif /* DUK_USE_REGEXP_SUPPORT */
34842 } /* default case */
34843 } /* switch (ch2) */
34844
34845 repl_write:
34846 /* ch1 = (r_increment << 8) + byte */
34847
34848 DUK_BW_WRITE_ENSURE_U8(thr, bw, (duk_uint8_t) (ch1 & 0xff));
34849 r += ch1 >> 8;
34850 } /* while repl */
34851 } /* if (is_repl_func) */
34852
34853 duk_pop(ctx); /* pop regexp res_obj or match string */
34854
34855#ifdef DUK_USE_REGEXP_SUPPORT
#define DUK_ASC_AMP
#define DUK_BW_WRITE_ENSURE_U8(thr, bw_ctx, val)
DUK_EXTERNAL duk_bool_t duk_is_function(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL duk_uint_t duk_get_uint(duk_context *ctx, duk_idx_t index)
#define DUK_ASC_GRAVE
#define DUK_BW_WRITE_ENSURE_BYTES(thr, bw_ctx, valptr, valsz)
#define DUK_ASC_DOLLAR

◆ duk_bi_string_prototype_search()

DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_search ( duk_context * ctx)

Definition at line 35174 of file duktape-1.8.0/src/duktape.c.

35177 {
35178 goto do_new;
35179 }
35180 return;
35181
35182 do_new:
35184 duk_dup(ctx, index);
35185 duk_new(ctx, 1); /* [ ... RegExp val ] -> [ ... res ] */
35186 duk_replace(ctx, index);
35187}
35188#endif /* DUK_USE_REGEXP_SUPPORT */
35189
35190#ifdef DUK_USE_REGEXP_SUPPORT
35192 duk_hthread *thr = (duk_hthread *) ctx;
35193
35194 /* Easiest way to implement the search required by the specification
35195 * is to do a RegExp test() with lastIndex forced to zero. To avoid
35196 * side effects on the argument, "clone" the RegExp if a RegExp was
35197 * given as input.
35198 *
35199 * The global flag of the RegExp should be ignored; setting lastIndex
35200 * to zero (which happens when "cloning" the RegExp) should have an
35201 * equivalent effect.
35202 */
35203
35204 DUK_ASSERT_TOP(ctx, 1);
35205 (void) duk_push_this_coercible_to_string(ctx); /* at index 1 */
35206 duk__to_regexp_helper(ctx, 0 /*index*/, 1 /*force_new*/);
35207
35208 /* stack[0] = regexp
35209 * stack[1] = string
35210 */
35211
#define DUK_BIDX_REGEXP_CONSTRUCTOR

◆ duk_bi_string_prototype_slice()

DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_slice ( duk_context * ctx)

Definition at line 34317 of file duktape-1.8.0/src/duktape.c.

34328 {
34329 DUK_UNREF(ctx);
34331}
34332#endif /* DUK_USE_SECTION_B */
34333
34335 duk_hstring *h;
34336 duk_int_t start_pos, end_pos;
34337 duk_int_t len;
34338
34340 DUK_ASSERT(h != NULL);
34342
34343 /* [ start end str ] */
34344
34345 start_pos = duk_to_int_clamped(ctx, 0, -len, len);
34346 if (start_pos < 0) {
34347 start_pos = len + start_pos;
34348 }
34349 if (duk_is_undefined(ctx, 1)) {
34350 end_pos = len;
34351 } else {
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_slice(duk_context *ctx)

◆ duk_bi_string_prototype_split()

DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_split ( duk_context * ctx)

Definition at line 34865 of file duktape-1.8.0/src/duktape.c.

34882 {
34883 duk_hthread *thr = (duk_hthread *) ctx;
34884 duk_hstring *h_input;
34885 duk_hstring *h_sep;
34886 duk_uint32_t limit;
34887 duk_uint32_t arr_idx;
34888#ifdef DUK_USE_REGEXP_SUPPORT
34889 duk_bool_t is_regexp;
34890#endif
34891 duk_bool_t matched; /* set to 1 if any match exists (needed for empty input special case) */
34892 duk_uint32_t prev_match_end_coff, prev_match_end_boff;
34893 duk_uint32_t match_start_boff, match_start_coff;
34894 duk_uint32_t match_end_boff, match_end_coff;
34895
34896 DUK_UNREF(thr);
34897
34898 h_input = duk_push_this_coercible_to_string(ctx);
34899 DUK_ASSERT(h_input != NULL);
34900
34901 duk_push_array(ctx);
34902
34903 if (duk_is_undefined(ctx, 1)) {
34904 limit = 0xffffffffUL;
34905 } else {
34906 limit = duk_to_uint32(ctx, 1);
34907 }
34908
34909 if (limit == 0) {
34910 return 1;
34911 }
34912
34913 /* If the separator is a RegExp, make a "clone" of it. The specification
34914 * algorithm calls [[Match]] directly for specific indices; we emulate this
34915 * by tweaking lastIndex and using a "force global" variant of duk_regexp_match()
34916 * which will use global-style matching even when the RegExp itself is non-global.
34917 */
34918
34919 if (duk_is_undefined(ctx, 0)) {
34920 /* The spec algorithm first does "R = ToString(separator)" before checking
34921 * whether separator is undefined. Since this is side effect free, we can
34922 * skip the ToString() here.
34923 */
34924 duk_dup(ctx, 2);
34925 duk_put_prop_index(ctx, 3, 0);
34926 return 1;
34928#ifdef DUK_USE_REGEXP_SUPPORT
34930 duk_dup(ctx, 0);
34931 duk_new(ctx, 1); /* [ ... RegExp val ] -> [ ... res ] */
34932 duk_replace(ctx, 0);
34933 /* lastIndex is initialized to zero by new RegExp() */
34934 is_regexp = 1;
34935#else
34937#endif
34938 } else {
34939 duk_to_string(ctx, 0);
34940#ifdef DUK_USE_REGEXP_SUPPORT
34941 is_regexp = 0;
34942#endif
34943 }
34944
34945 /* stack[0] = separator (string or regexp)
34946 * stack[1] = limit
34947 * stack[2] = input string
34948 * stack[3] = result array
34949 */
34950
34951 prev_match_end_boff = 0;
34952 prev_match_end_coff = 0;
34953 arr_idx = 0;
34954 matched = 0;
34955
34956 for (;;) {
34957 /*
34958 * The specification uses RegExp [[Match]] to attempt match at specific
34959 * offsets. We don't have such a primitive, so we use an actual RegExp
34960 * and tweak lastIndex. Since the RegExp may be non-global, we use a
34961 * special variant which forces global-like behavior for matching.
34962 */
34963
34964 DUK_ASSERT_TOP(ctx, 4);
34965
34966#ifdef DUK_USE_REGEXP_SUPPORT
34967 if (is_regexp) {
34968 duk_dup(ctx, 0);
34969 duk_dup(ctx, 2);
34970 duk_regexp_match_force_global(thr); /* [ ... regexp input ] -> [ res_obj ] */
34971 if (!duk_is_object(ctx, -1)) {
34972 duk_pop(ctx);
34973 break;
34974 }
34975 matched = 1;
34976
34978 DUK_ASSERT(duk_is_number(ctx, -1));
34979 match_start_coff = duk_get_int(ctx, -1);
34980 match_start_boff = duk_heap_strcache_offset_char2byte(thr, h_input, match_start_coff);
34981 duk_pop(ctx);
34982
34983 if (match_start_coff == DUK_HSTRING_GET_CHARLEN(h_input)) {
34984 /* don't allow an empty match at the end of the string */
34985 duk_pop(ctx);
34986 break;
34987 }
34988
34990 DUK_ASSERT(duk_is_number(ctx, -1));
34991 match_end_coff = duk_get_int(ctx, -1);
34992 match_end_boff = duk_heap_strcache_offset_char2byte(thr, h_input, match_end_coff);
34993 duk_pop(ctx);
34994
34995 /* empty match -> bump and continue */
34996 if (prev_match_end_boff == match_end_boff) {
34997 duk_push_int(ctx, match_end_coff + 1);
34999 duk_pop(ctx);
35000 continue;
35001 }
35002 } else {
35003#else /* DUK_USE_REGEXP_SUPPORT */
35004 { /* unconditionally */
35005#endif /* DUK_USE_REGEXP_SUPPORT */
35006 const duk_uint8_t *p_start, *p_end, *p; /* input string scan */
35007 const duk_uint8_t *q_start; /* match string */
35008 duk_size_t q_blen, q_clen;
35009
35010 p_start = DUK_HSTRING_GET_DATA(h_input);
35011 p_end = p_start + DUK_HSTRING_GET_BYTELEN(h_input);
35012 p = p_start + prev_match_end_boff;
35013
35014 h_sep = duk_get_hstring(ctx, 0);
35015 DUK_ASSERT(h_sep != NULL);
35016 q_start = DUK_HSTRING_GET_DATA(h_sep);
35017 q_blen = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h_sep);
35018 q_clen = (duk_size_t) DUK_HSTRING_GET_CHARLEN(h_sep);
35019
35020 p_end -= q_blen; /* ensure full memcmp() fits in while */
35021
35022 match_start_coff = prev_match_end_coff;
35023
35024 if (q_blen == 0) {
35025 /* Handle empty separator case: it will always match, and always
35026 * triggers the check in step 13.c.iii initially. Note that we
35027 * must skip to either end of string or start of first codepoint,
35028 * skipping over any continuation bytes!
35029 *
35030 * Don't allow an empty string to match at the end of the input.
35031 */
35032
35033 matched = 1; /* empty separator can always match */
35034
35035 match_start_coff++;
35036 p++;
35037 while (p < p_end) {
35038 if ((p[0] & 0xc0) != 0x80) {
35039 goto found;
35040 }
35041 p++;
35042 }
35043 goto not_found;
35044 }
35045
35046 DUK_ASSERT(q_blen > 0 && q_clen > 0);
35047 while (p <= p_end) {
35048 DUK_ASSERT(p + q_blen <= DUK_HSTRING_GET_DATA(h_input) + DUK_HSTRING_GET_BYTELEN(h_input));
35049 DUK_ASSERT(q_blen > 0); /* no issues with empty memcmp() */
35050 if (DUK_MEMCMP((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) {
35051 /* never an empty match, so step 13.c.iii can't be triggered */
35052 goto found;
35053 }
35054
35055 /* track utf-8 non-continuation bytes */
35056 if ((p[0] & 0xc0) != 0x80) {
35057 match_start_coff++;
35058 }
35059 p++;
35060 }
35061
35062 not_found:
35063 /* not found */
35064 break;
35065
35066 found:
35067 matched = 1;
35068 match_start_boff = (duk_uint32_t) (p - p_start);
35069 match_end_coff = (duk_uint32_t) (match_start_coff + q_clen); /* constrained by string length */
35070 match_end_boff = (duk_uint32_t) (match_start_boff + q_blen); /* ditto */
35071
35072 /* empty match (may happen with empty separator) -> bump and continue */
35073 if (prev_match_end_boff == match_end_boff) {
35074 prev_match_end_boff++;
35075 prev_match_end_coff++;
35076 continue;
35077 }
35078 } /* if (is_regexp) */
35079
35080 /* stack[0] = separator (string or regexp)
35081 * stack[1] = limit
35082 * stack[2] = input string
35083 * stack[3] = result array
35084 * stack[4] = regexp res_obj (if is_regexp)
35085 */
35086
35087 DUK_DDD(DUK_DDDPRINT("split; match_start b=%ld,c=%ld, match_end b=%ld,c=%ld, prev_end b=%ld,c=%ld",
35088 (long) match_start_boff, (long) match_start_coff,
35089 (long) match_end_boff, (long) match_end_coff,
35090 (long) prev_match_end_boff, (long) prev_match_end_coff));
35091
35092 duk_push_lstring(ctx,
35093 (const char *) (DUK_HSTRING_GET_DATA(h_input) + prev_match_end_boff),
35094 (duk_size_t) (match_start_boff - prev_match_end_boff));
35095 duk_put_prop_index(ctx, 3, arr_idx);
35096 arr_idx++;
35097 if (arr_idx >= limit) {
35098 goto hit_limit;
35099 }
35100
35101#ifdef DUK_USE_REGEXP_SUPPORT
35102 if (is_regexp) {
35103 duk_size_t i, len;
35104
35105 len = duk_get_length(ctx, 4);
35106 for (i = 1; i < len; i++) {
35107 DUK_ASSERT(i <= DUK_UARRIDX_MAX); /* cannot have >4G captures */
35108 duk_get_prop_index(ctx, 4, (duk_uarridx_t) i);
35109 duk_put_prop_index(ctx, 3, arr_idx);
35110 arr_idx++;
35111 if (arr_idx >= limit) {
35112 goto hit_limit;
35113 }
35114 }
35115
35116 duk_pop(ctx);
35117 /* lastIndex already set up for next match */
35118 } else {
35119#else /* DUK_USE_REGEXP_SUPPORT */
35120 { /* unconditionally */
35121#endif /* DUK_USE_REGEXP_SUPPORT */
35122 /* no action */
35123 }
35124
35125 prev_match_end_boff = match_end_boff;
35126 prev_match_end_coff = match_end_coff;
35127 continue;
35128 } /* for */
35129
35130 /* Combined step 11 (empty string special case) and 14-15. */
35131
35132 DUK_DDD(DUK_DDDPRINT("split trailer; prev_end b=%ld,c=%ld",
35133 (long) prev_match_end_boff, (long) prev_match_end_coff));
35134
35135 if (DUK_HSTRING_GET_CHARLEN(h_input) > 0 || !matched) {
35136 /* Add trailer if:
35137 * a) non-empty input
35138 * b) empty input and no (zero size) match found (step 11)
35139 */
35140
35141 duk_push_lstring(ctx,
DUK_INTERNAL_DECL void duk_regexp_match_force_global(duk_hthread *thr)

◆ duk_bi_string_prototype_substr()

DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_substr ( duk_context * ctx)

Definition at line 34268 of file duktape-1.8.0/src/duktape.c.

34272 {
34273 duk_int_t tmp = start_pos;
34274 start_pos = end_pos;
34275 end_pos = tmp;
34276 }
34277
34278 DUK_ASSERT(end_pos >= start_pos);
34279
34280 duk_substring(ctx, -1, (duk_size_t) start_pos, (duk_size_t) end_pos);
34281 return 1;
34282}
34283
34284#ifdef DUK_USE_SECTION_B
34286 duk_hstring *h;
34287 duk_int_t start_pos, end_pos;
34288 duk_int_t len;
34289
34290 /* Unlike non-obsolete String calls, substr() algorithm in E5.1
34291 * specification will happily coerce undefined and null to strings
34292 * ("undefined" and "null").
34293 */
34294 duk_push_this(ctx);
34295 h = duk_to_hstring(ctx, -1);
34296 DUK_ASSERT(h != NULL);
34298
34299 /* [ start length str ] */
34300
34301 /* The implementation for computing of start_pos and end_pos differs
34302 * from the standard algorithm, but is intended to result in the exactly
34303 * same behavior. This is not always obvious.
34304 */
34305
34306 /* combines steps 2 and 5; -len ensures max() not needed for step 5 */
34307 start_pos = duk_to_int_clamped(ctx, 0, -len, len);
34308 if (start_pos < 0) {
34309 start_pos = len + start_pos;
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_substr(duk_context *ctx)

◆ duk_bi_string_prototype_substring()

DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_substring ( duk_context * ctx)

Definition at line 34235 of file duktape-1.8.0/src/duktape.c.

34235 {
34237 return 1;
34238 }
34239
34240 duk_push_u32(ctx, (duk_uint32_t) duk_hstring_char_code_at_raw(thr, h, pos));
34241 return 1;
34242}
34243
34244/*
34245 * substring(), substr(), slice()
34246 */
34247
34248/* XXX: any chance of merging these three similar but still slightly
34249 * different algorithms so that footprint would be reduced?
34250 */
34251
34253 duk_hstring *h;
34254 duk_int_t start_pos, end_pos;
34255 duk_int_t len;
34256
34258 DUK_ASSERT(h != NULL);
34260
34261 /* [ start end str ] */
34262
34263 start_pos = duk_to_int_clamped(ctx, 0, 0, len);
34264 if (duk_is_undefined(ctx, 1)) {
34265 end_pos = len;
DUK_INTERNAL_DECL duk_ucodepoint_t duk_hstring_char_code_at_raw(duk_hthread *thr, duk_hstring *h, duk_uint_t pos)
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_substring(duk_context *ctx)

References DUK_DOUBLE_NAN, and duk_push_number().

◆ duk_bi_string_prototype_to_string()

DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_to_string ( duk_context * ctx)

Definition at line 34152 of file duktape-1.8.0/src/duktape.c.

34169 {
34170 duk_tval *tv;
34171
34172 duk_push_this(ctx);
34173 tv = duk_require_tval(ctx, -1);
34174 DUK_ASSERT(tv != NULL);
34175
34176 if (DUK_TVAL_IS_STRING(tv)) {
34177 /* return as is */
34178 return 1;
34179 } else if (DUK_TVAL_IS_OBJECT(tv)) {
34181 DUK_ASSERT(h != NULL);
34182
34183 /* Must be a "string object", i.e. class "String" */

◆ duk_bi_string_prototype_trim()

DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_trim ( duk_context * ctx)

Definition at line 35306 of file duktape-1.8.0/src/duktape.c.

35309 {
35310 DUK_UNREF(ctx);
35312}

◆ duk_bi_thread_constructor()

DUK_INTERNAL_DECL duk_ret_t duk_bi_thread_constructor ( duk_context * ctx)

Definition at line 35382 of file duktape-1.8.0/src/duktape.c.

35384 :
35385 duk_push_int(ctx, (duk_int_t) ret);
35386 return 1;
35387}
35388#line 1 "duk_bi_thread.c"
35389/*
35390 * Thread builtins
35391 */
35392
35393/* include removed: duk_internal.h */
35394
35395/*
35396 * Constructor
35397 */
35398
35400 duk_hthread *new_thr;
35401 duk_hobject *func;
35402
35403 /* XXX: need a duk_require_func_or_lfunc_coerce() */
35404 if (!duk_is_callable(ctx, 0)) {
DUK_INTERNAL_DECL duk_ret_t duk_bi_thread_constructor(duk_context *ctx)

◆ duk_bi_thread_current()

DUK_INTERNAL_DECL duk_ret_t duk_bi_thread_current ( duk_context * ctx)

Definition at line 35673 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_thread_resume()

DUK_INTERNAL_DECL duk_ret_t duk_bi_thread_resume ( duk_context * ctx)

Definition at line 35421 of file duktape-1.8.0/src/duktape.c.

35438 {
35439 duk_hthread *thr = (duk_hthread *) ctx;
35440 duk_hthread *thr_resume;
35441 duk_tval *tv;
35442 duk_hobject *func;
35443 duk_hobject *caller_func;
35444 duk_small_int_t is_error;
35445
35446 DUK_DDD(DUK_DDDPRINT("Duktape.Thread.resume(): thread=%!T, value=%!T, is_error=%!T",
35447 (duk_tval *) duk_get_tval(ctx, 0),
35448 (duk_tval *) duk_get_tval(ctx, 1),
35449 (duk_tval *) duk_get_tval(ctx, 2)));
35450
35452 DUK_ASSERT(thr->heap->curr_thread == thr);
35453
35454 thr_resume = duk_require_hthread(ctx, 0);
35455 is_error = (duk_small_int_t) duk_to_boolean(ctx, 2);
35456 duk_set_top(ctx, 2);
35457
35458 /* [ thread value ] */
35459
35460 /*
35461 * Thread state and calling context checks
35462 */
35463
35464 if (thr->callstack_top < 2) {
35465 DUK_DD(DUK_DDPRINT("resume state invalid: callstack should contain at least 2 entries (caller and Duktape.Thread.resume)"));
35466 goto state_error;
35467 }
35468 DUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack + thr->callstack_top - 1) != NULL); /* us */
35470 DUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack + thr->callstack_top - 2) != NULL); /* caller */
35471
35472 caller_func = DUK_ACT_GET_FUNC(thr->callstack + thr->callstack_top - 2);
35473 if (!DUK_HOBJECT_IS_COMPILEDFUNCTION(caller_func)) {
35474 DUK_DD(DUK_DDPRINT("resume state invalid: caller must be Ecmascript code"));
35475 goto state_error;
35476 }
35477
35478 /* Note: there is no requirement that: 'thr->callstack_preventcount == 1'
35479 * like for yield.
35480 */
35481
35482 if (thr_resume->state != DUK_HTHREAD_STATE_INACTIVE &&
35483 thr_resume->state != DUK_HTHREAD_STATE_YIELDED) {
35484 DUK_DD(DUK_DDPRINT("resume state invalid: target thread must be INACTIVE or YIELDED"));
35485 goto state_error;
35486 }
35487
35489 thr_resume->state == DUK_HTHREAD_STATE_YIELDED);
35490
35491 /* Further state-dependent pre-checks */
35492
35493 if (thr_resume->state == DUK_HTHREAD_STATE_YIELDED) {
35494 /* no pre-checks now, assume a previous yield() has left things in
35495 * tip-top shape (longjmp handler will assert for these).
35496 */
35497 } else {
35499
35500 if ((thr_resume->callstack_top != 0) ||
35501 (thr_resume->valstack_top - thr_resume->valstack != 1)) {
35502 goto state_invalid_initial;
35503 }
35504 tv = &thr_resume->valstack_top[-1];
35505 DUK_ASSERT(tv >= thr_resume->valstack && tv < thr_resume->valstack_top);
35506 if (!DUK_TVAL_IS_OBJECT(tv)) {
35507 goto state_invalid_initial;
35508 }
35509 func = DUK_TVAL_GET_OBJECT(tv);
35510 DUK_ASSERT(func != NULL);
35512 /* Note: cannot be a bound function either right now,
35513 * this would be easy to relax though.
35514 */
35515 goto state_invalid_initial;
35516 }
35517
35518 }
35519
35520 /*
35521 * The error object has been augmented with a traceback and other
35522 * info from its creation point -- usually another thread. The
35523 * error handler is called here right before throwing, but it also
35524 * runs in the resumer's thread. It might be nice to get a traceback
35525 * from the resumee but this is not the case now.
35526 */
35527
35528#if defined(DUK_USE_AUGMENT_ERROR_THROW)
35529 if (is_error) {
35530 DUK_ASSERT_TOP(ctx, 2); /* value (error) is at stack top */
35531 duk_err_augment_error_throw(thr); /* in resumer's context */
35532 }
35533#endif
35534
35535#ifdef DUK_USE_DEBUG
35536 if (is_error) {
35537 DUK_DDD(DUK_DDDPRINT("RESUME ERROR: thread=%!T, value=%!T",
35538 (duk_tval *) duk_get_tval(ctx, 0),
35539 (duk_tval *) duk_get_tval(ctx, 1)));
35540 } else if (thr_resume->state == DUK_HTHREAD_STATE_YIELDED) {
35541 DUK_DDD(DUK_DDDPRINT("RESUME NORMAL: thread=%!T, value=%!T",
35542 (duk_tval *) duk_get_tval(ctx, 0),
35543 (duk_tval *) duk_get_tval(ctx, 1)));
35544 } else {
35545 DUK_DDD(DUK_DDDPRINT("RESUME INITIAL: thread=%!T, value=%!T",
35546 (duk_tval *) duk_get_tval(ctx, 0),
35547 (duk_tval *) duk_get_tval(ctx, 1)));
35548 }
35549#endif
35550
35552
35553 /* lj value2: thread */
35555 DUK_TVAL_SET_TVAL_UPDREF(thr, &thr->heap->lj.value2, &thr->valstack_bottom[0]); /* side effects */
35556
35557 /* lj value1: value */
35558 DUK_ASSERT(thr->valstack_bottom + 1 < thr->valstack_top);
DUK_INTERNAL_DECL duk_hthread * duk_require_hthread(duk_context *ctx, duk_idx_t index)

◆ duk_bi_thread_yield()

DUK_INTERNAL_DECL duk_ret_t duk_bi_thread_yield ( duk_context * ctx)

Definition at line 35575 of file duktape-1.8.0/src/duktape.c.

35592 {
35593 duk_hthread *thr = (duk_hthread *) ctx;
35594 duk_hobject *caller_func;
35595 duk_small_int_t is_error;
35596
35597 DUK_DDD(DUK_DDDPRINT("Duktape.Thread.yield(): value=%!T, is_error=%!T",
35598 (duk_tval *) duk_get_tval(ctx, 0),
35599 (duk_tval *) duk_get_tval(ctx, 1)));
35600
35602 DUK_ASSERT(thr->heap->curr_thread == thr);
35603
35604 is_error = (duk_small_int_t) duk_to_boolean(ctx, 1);
35605 duk_set_top(ctx, 1);
35606
35607 /* [ value ] */
35608
35609 /*
35610 * Thread state and calling context checks
35611 */
35612
35613 if (!thr->resumer) {
35614 DUK_DD(DUK_DDPRINT("yield state invalid: current thread must have a resumer"));
35615 goto state_error;
35616 }
35618
35619 if (thr->callstack_top < 2) {
35620 DUK_DD(DUK_DDPRINT("yield state invalid: callstack should contain at least 2 entries (caller and Duktape.Thread.yield)"));
35621 goto state_error;
35622 }
35623 DUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack + thr->callstack_top - 1) != NULL); /* us */
35625 DUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack + thr->callstack_top - 2) != NULL); /* caller */
35626
35627 caller_func = DUK_ACT_GET_FUNC(thr->callstack + thr->callstack_top - 2);
35628 if (!DUK_HOBJECT_IS_COMPILEDFUNCTION(caller_func)) {
35629 DUK_DD(DUK_DDPRINT("yield state invalid: caller must be Ecmascript code"));
35630 goto state_error;
35631 }
35632
35633 DUK_ASSERT(thr->callstack_preventcount >= 1); /* should never be zero, because we (Duktape.Thread.yield) are on the stack */
35634 if (thr->callstack_preventcount != 1) {
35635 /* Note: the only yield-preventing call is Duktape.Thread.yield(), hence check for 1, not 0 */
35636 DUK_DD(DUK_DDPRINT("yield state invalid: there must be no yield-preventing calls in current thread callstack (preventcount is %ld)",
35637 (long) thr->callstack_preventcount));
35638 goto state_error;
35639 }
35640
35641 /*
35642 * The error object has been augmented with a traceback and other
35643 * info from its creation point -- usually the current thread.
35644 * The error handler, however, is called right before throwing
35645 * and runs in the yielder's thread.
35646 */
35647
35648#if defined(DUK_USE_AUGMENT_ERROR_THROW)
35649 if (is_error) {
35650 DUK_ASSERT_TOP(ctx, 1); /* value (error) is at stack top */
35651 duk_err_augment_error_throw(thr); /* in yielder's context */
35652 }
35653#endif
35654
35655#ifdef DUK_USE_DEBUG
35656 if (is_error) {
35657 DUK_DDD(DUK_DDDPRINT("YIELD ERROR: value=%!T",
35658 (duk_tval *) duk_get_tval(ctx, 0)));
35659 } else {
35660 DUK_DDD(DUK_DDDPRINT("YIELD NORMAL: value=%!T",
35661 (duk_tval *) duk_get_tval(ctx, 0)));
35662 }
35663#endif
35664
35665 /*
35666 * Process yield
35667 *
35668 * After longjmp(), processing continues in bytecode executor longjmp
35669 * handler, which will e.g. update thr->resumer to NULL.
35670 */
35671

◆ duk_bi_type_error_thrower()

DUK_INTERNAL_DECL duk_ret_t duk_bi_type_error_thrower ( duk_context * ctx)

Definition at line 35684 of file duktape-1.8.0/src/duktape.c.

35685 :
35686 DUK_ERROR_TYPE(thr, "invalid state");
35687 return 0; /* never here */

◆ duk_bi_typedarray_constructor()

DUK_INTERNAL_DECL duk_ret_t duk_bi_typedarray_constructor ( duk_context * ctx)

Definition at line 22470 of file duktape-1.8.0/src/duktape.c.

22470 :
22471 return DUK_RET_RANGE_ERROR;
22472}
22473#else /* DUK_USE_BUFFEROBJECT_SUPPORT */
22475 DUK_UNREF(ctx);
22477}
22478#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
22479
22480
22481/* Format of magic, bits:
22482 * 0...1: elem size shift (0-3)
22483 * 2...5: elem type (DUK_HBUFFEROBJECT_ELEM_xxx)
22484 */
22485
22486#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
22488 duk_hthread *thr;
22489 duk_tval *tv;
22490 duk_hobject *h_obj;
22491 duk_hbufferobject *h_bufobj = NULL;
22492 duk_hbufferobject *h_bufarr = NULL;
22493 duk_hbufferobject *h_bufarg = NULL;
22494 duk_hbuffer *h_val;
22495 duk_small_uint_t magic;
22496 duk_small_uint_t shift;
22497 duk_small_uint_t elem_type;
22498 duk_small_uint_t elem_size;
22499 duk_small_uint_t class_num;
22500 duk_small_uint_t proto_bidx;
22501 duk_uint_t align_mask;
22502 duk_uint_t elem_length;
22503 duk_int_t elem_length_signed;
22504 duk_uint_t byte_length;
22505 duk_small_uint_t copy_mode;
22506
22507 thr = (duk_hthread *) ctx;
22508 DUK_UNREF(thr);
22509
22510 /* XXX: function flag to make this automatic? */
22511 if (!duk_is_constructor_call(ctx)) {
22512 return DUK_RET_TYPE_ERROR;
22513 }
22514
22515 /* We could fit built-in index into magic but that'd make the magic
22516 * number dependent on built-in numbering (genbuiltins.py doesn't
22517 * handle that yet). So map both class and prototype from the
22518 * element type.
22519 */
22520 magic = duk_get_current_magic(ctx);
22521 shift = magic & 0x03; /* bits 0...1: shift */
22522 elem_type = (magic >> 2) & 0x0f; /* bits 2...5: type */
22523 elem_size = 1 << shift;
22524 align_mask = elem_size - 1;
22525 DUK_ASSERT(elem_type < sizeof(duk__buffer_proto_from_elemtype) / sizeof(duk_uint8_t));
22526 proto_bidx = duk__buffer_proto_from_elemtype[elem_type];
22527 DUK_ASSERT(proto_bidx < DUK_NUM_BUILTINS);
22528 DUK_ASSERT(elem_type < sizeof(duk__buffer_class_from_elemtype) / sizeof(duk_uint8_t));
22529 class_num = duk__buffer_class_from_elemtype[elem_type];
22530
22531 DUK_DD(DUK_DDPRINT("typedarray constructor, magic=%d, shift=%d, elem_type=%d, "
22532 "elem_size=%d, proto_bidx=%d, class_num=%d",
22533 (int) magic, (int) shift, (int) elem_type, (int) elem_size,
22534 (int) proto_bidx, (int) class_num));
22535
22536 /* Argument variants. When the argument is an ArrayBuffer a view to
22537 * the same buffer is created; otherwise a new ArrayBuffer is always
22538 * created.
22539 */
22540
22541 tv = duk_get_tval(ctx, 0);
22542 DUK_ASSERT(tv != NULL); /* arg count */
22543 if (DUK_TVAL_IS_OBJECT(tv)) {
22544 h_obj = DUK_TVAL_GET_OBJECT(tv);
22545 DUK_ASSERT(h_obj != NULL);
22546
22548 /* ArrayBuffer: unlike any other argument variant, create
22549 * a view into the existing buffer.
22550 */
22551
22552 duk_int_t byte_offset_signed;
22553 duk_uint_t byte_offset;
22554
22555 h_bufarg = (duk_hbufferobject *) h_obj;
22556
22557 byte_offset_signed = duk_to_int(ctx, 1);
22558 if (byte_offset_signed < 0) {
22559 goto fail_arguments;
22560 }
22561 byte_offset = (duk_uint_t) byte_offset_signed;
22562 if (byte_offset > h_bufarg->length ||
22563 (byte_offset & align_mask) != 0) {
22564 /* Must be >= 0 and multiple of element size. */
22565 goto fail_arguments;
22566 }
22567 if (duk_is_undefined(ctx, 2)) {
22568 DUK_ASSERT(h_bufarg->length >= byte_offset);
22569 byte_length = h_bufarg->length - byte_offset;
22570 if ((byte_length & align_mask) != 0) {
22571 /* Must be element size multiple from
22572 * start offset to end of buffer.
22573 */
22574 goto fail_arguments;
22575 }
22576 elem_length = (byte_length >> shift);
22577 } else {
22578 elem_length_signed = duk_to_int(ctx, 2);
22579 if (elem_length_signed < 0) {
22580 goto fail_arguments;
22581 }
22582 elem_length = (duk_uint_t) elem_length_signed;
22583 byte_length = elem_length << shift;
22584 if ((byte_length >> shift) != elem_length) {
22585 /* Byte length would overflow. */
22586 /* XXX: easier check with less code? */
22587 goto fail_arguments;
22588 }
22589 DUK_ASSERT(h_bufarg->length >= byte_offset);
22590 if (byte_length > h_bufarg->length - byte_offset) {
22591 /* Not enough data. */
22592 goto fail_arguments;
22593 }
22594 }
22595 DUK_UNREF(elem_length);
22596 DUK_ASSERT_DISABLE(byte_offset >= 0);
22597 DUK_ASSERT(byte_offset <= h_bufarg->length);
22598 DUK_ASSERT_DISABLE(byte_length >= 0);
22599 DUK_ASSERT(byte_offset + byte_length <= h_bufarg->length);
22600 DUK_ASSERT((elem_length << shift) == byte_length);
22601
22602 h_bufobj = duk_push_bufferobject_raw(ctx,
22605 DUK_HOBJECT_CLASS_AS_FLAGS(class_num),
22606 proto_bidx);
22607 h_val = h_bufarg->buf;
22608 if (h_val == NULL) {
22609 return DUK_RET_TYPE_ERROR;
22610 }
22611 h_bufobj->buf = h_val;
22612 DUK_HBUFFER_INCREF(thr, h_val);
22613 h_bufobj->offset = h_bufarg->offset + byte_offset;
22614 h_bufobj->length = byte_length;
22615 h_bufobj->shift = (duk_uint8_t) shift;
22616 h_bufobj->elem_type = (duk_uint8_t) elem_type;
22617 h_bufobj->is_view = 1;
22619
22620 /* Set .buffer to the argument ArrayBuffer. */
22621 duk_dup(ctx, 0);
22623 duk_compact(ctx, -1);
22624 return 1;
22625 } else if (DUK_HOBJECT_IS_BUFFEROBJECT(h_obj)) {
22626 /* TypedArray (or other non-ArrayBuffer duk_hbufferobject).
22627 * Conceptually same behavior as for an Array-like argument,
22628 * with a few fast paths.
22629 */
22630
22631 h_bufarg = (duk_hbufferobject *) h_obj;
22633 elem_length_signed = (duk_int_t) (h_bufarg->length >> h_bufarg->shift);
22634 if (h_bufarg->buf == NULL) {
22635 return DUK_RET_TYPE_ERROR;
22636 }
22637
22638 /* Select copy mode. Must take into account element
22639 * compatibility and validity of the underlying source
22640 * buffer.
22641 */
22642
22643 DUK_DDD(DUK_DDDPRINT("selecting copy mode for bufobj arg, "
22644 "src byte_length=%ld, src shift=%d, "
22645 "src/dst elem_length=%ld; "
22646 "dst shift=%d -> dst byte_length=%ld",
22647 (long) h_bufarg->length, (int) h_bufarg->shift,
22648 (long) elem_length_signed, (int) shift,
22649 (long) (elem_length_signed << shift)));
22650
22651 copy_mode = 2; /* default is explicit index read/write copy */
22652 DUK_ASSERT(elem_type < sizeof(duk__buffer_elemtype_copy_compatible) / sizeof(duk_uint16_t));
22653 if (DUK_HBUFFEROBJECT_VALID_SLICE(h_bufarg)) {
22654 if ((duk__buffer_elemtype_copy_compatible[elem_type] & (1 << h_bufarg->elem_type)) != 0) {
22655 DUK_DDD(DUK_DDDPRINT("source/target are copy compatible, memcpy"));
22656 DUK_ASSERT(shift == h_bufarg->shift); /* byte sizes will match */
22657 copy_mode = 0;
22658 } else {
22659 DUK_DDD(DUK_DDDPRINT("source/target not copy compatible but valid, fast copy"));
22660 copy_mode = 1;
22661 }
22662 }
22663 } else {
22664 /* Array or Array-like */
22665 elem_length_signed = (duk_int_t) duk_get_length(ctx, 0);
22666 copy_mode = 2;
22667 }
22668 } else if (DUK_TVAL_IS_BUFFER(tv)) {
22669 /* Accept plain buffer values like array initializers
22670 * (new in Duktape 1.4.0).
22671 */
22672 duk_hbuffer *h_srcbuf;
22673 h_srcbuf = DUK_TVAL_GET_BUFFER(tv);
22674 elem_length_signed = (duk_int_t) DUK_HBUFFER_GET_SIZE(h_srcbuf);
22675 copy_mode = 2; /* XXX: could add fast path for u8 compatible views */
22676 } else {
22677 /* Non-object argument is simply int coerced, matches
22678 * V8 behavior (except for "null", which we coerce to
22679 * 0 but V8 TypeErrors).
22680 */
22681 elem_length_signed = duk_to_int(ctx, 0);
22682 copy_mode = 3;
22683 }
22684 if (elem_length_signed < 0) {
22685 goto fail_arguments;
22686 }
22687 elem_length = (duk_uint_t) elem_length_signed;
22688 byte_length = (duk_uint_t) (elem_length << shift);
22689 if ((byte_length >> shift) != elem_length) {
22690 /* Byte length would overflow. */
22691 /* XXX: easier check with less code? */
22692 goto fail_arguments;
22693 }
22694
22695 DUK_DDD(DUK_DDDPRINT("elem_length=%ld, byte_length=%ld",
22696 (long) elem_length, (long) byte_length));
22697
22698 /* ArrayBuffer argument is handled specially above; the rest of the
22699 * argument variants are handled by shared code below.
22700 */
22701
22702 /* Push a new ArrayBuffer (becomes view .buffer) */
22703 h_bufarr = duk__push_arraybuffer_with_length(ctx, byte_length);
22704 DUK_ASSERT(h_bufarr != NULL);
22705 h_val = h_bufarr->buf;
22706 DUK_ASSERT(h_val != NULL);
22707
22708 /* Push the resulting view object and attach the ArrayBuffer. */
22709 h_bufobj = duk_push_bufferobject_raw(ctx,
22712 DUK_HOBJECT_CLASS_AS_FLAGS(class_num),
22713 proto_bidx);
22714
22715 h_bufobj->buf = h_val;
22716 DUK_HBUFFER_INCREF(thr, h_val);
22717 DUK_ASSERT(h_bufobj->offset == 0);
22718 h_bufobj->length = byte_length;
22719 h_bufobj->shift = (duk_uint8_t) shift;
22720 h_bufobj->elem_type = (duk_uint8_t) elem_type;
22721 h_bufobj->is_view = 1;
22723
22724 /* Set .buffer */
22725 duk_dup(ctx, -2);
22727 duk_compact(ctx, -1);
22728
22729 /* Copy values, the copy method depends on the arguments.
22730 *
22731 * Copy mode decision may depend on the validity of the underlying
22732 * buffer of the source argument; there must be no harmful side effects
22733 * from there to here for copy_mode to still be valid.
22734 */
22735 DUK_DDD(DUK_DDDPRINT("copy mode: %d", (int) copy_mode));
22736 switch (copy_mode) {
22737 case 0: {
22738 /* Use byte copy. */
22739
22740 duk_uint8_t *p_src;
22741 duk_uint8_t *p_dst;
22742
22743 DUK_ASSERT(h_bufobj != NULL);
22744 DUK_ASSERT(h_bufobj->buf != NULL);
22746 DUK_ASSERT(h_bufarg != NULL);
22747 DUK_ASSERT(h_bufarg->buf != NULL);
22749
22750 p_dst = DUK_HBUFFEROBJECT_GET_SLICE_BASE(thr->heap, h_bufobj);
22751 p_src = DUK_HBUFFEROBJECT_GET_SLICE_BASE(thr->heap, h_bufarg);
22752
22753 DUK_DDD(DUK_DDDPRINT("using memcpy: p_src=%p, p_dst=%p, byte_length=%ld",
22754 (void *) p_src, (void *) p_dst, (long) byte_length));
22755
22756 DUK_MEMCPY((void *) p_dst, (const void *) p_src, (size_t) byte_length);
22757 break;
22758 }
22759 case 1: {
22760 /* Copy values through direct validated reads and writes. */
22761
22762 duk_small_uint_t src_elem_size;
22763 duk_small_uint_t dst_elem_size;
22764 duk_uint8_t *p_src;
22765 duk_uint8_t *p_src_end;
22766 duk_uint8_t *p_dst;
22767
22768 DUK_ASSERT(h_bufobj != NULL);
22769 DUK_ASSERT(h_bufobj->buf != NULL);
22771 DUK_ASSERT(h_bufarg != NULL);
22772 DUK_ASSERT(h_bufarg->buf != NULL);
22774
22775 src_elem_size = 1 << h_bufarg->shift;
22776 dst_elem_size = elem_size;
22777
22778 p_src = DUK_HBUFFEROBJECT_GET_SLICE_BASE(thr->heap, h_bufarg);
22779 p_dst = DUK_HBUFFEROBJECT_GET_SLICE_BASE(thr->heap, h_bufobj);
22780 p_src_end = p_src + h_bufarg->length;
22781
22782 DUK_DDD(DUK_DDDPRINT("using fast copy: p_src=%p, p_src_end=%p, p_dst=%p, "
22783 "src_elem_size=%d, dst_elem_size=%d",
22784 (void *) p_src, (void *) p_src_end, (void *) p_dst,
22785 (int) src_elem_size, (int) dst_elem_size));
22786
22787 while (p_src != p_src_end) {
22788 DUK_DDD(DUK_DDDPRINT("fast path per element copy loop: "
22789 "p_src=%p, p_src_end=%p, p_dst=%p",
22790 (void *) p_src, (void *) p_src_end, (void *) p_dst));
22791 /* A validated read() is always a number, so it's write coercion
22792 * is always side effect free an won't invalidate pointers etc.
22793 */
22794 duk_hbufferobject_push_validated_read(ctx, h_bufarg, p_src, src_elem_size);
22795 duk_hbufferobject_validated_write(ctx, h_bufobj, p_dst, dst_elem_size);
22796 duk_pop(ctx);
22797 p_src += src_elem_size;
22798 p_dst += dst_elem_size;
22799 }
22800 break;
22801 }
22802 case 2: {
22803 /* Copy values by index reads and writes. Let virtual
22804 * property handling take care of coercion.
22805 */
22806 duk_uint_t i;
22807
22808 DUK_DDD(DUK_DDDPRINT("using slow copy"));
22809
22810 for (i = 0; i < elem_length; i++) {
22811 duk_get_prop_index(ctx, 0, (duk_uarridx_t) i);
22812 duk_put_prop_index(ctx, -2, (duk_uarridx_t) i);
22813 }
22814 break;
22815 }
22816 default:
22817 case 3: {
22818 /* No copy, leave zero bytes in the buffer. There's no
22819 * ambiguity with Float32/Float64 because zero bytes also
22820 * represent 0.0.
22821 */
22822#if !defined(DUK_USE_ZERO_BUFFER_DATA)
#define DUK_STRIDX_LC_BUFFER
DUK_LOCAL duk_hbufferobject * duk__push_arraybuffer_with_length(duk_context *ctx, duk_uint_t len)
static const duk_uint8_t duk__buffer_class_from_elemtype[9]
static const duk_uint8_t duk__buffer_proto_from_elemtype[9]
DUK_INTERNAL_DECL void duk_hbufferobject_validated_write(duk_context *ctx, duk_hbufferobject *h_bufobj, duk_uint8_t *p, duk_small_uint_t elem_size)
static duk_uint16_t duk__buffer_elemtype_copy_compatible[9]

◆ duk_bi_typedarray_set()

DUK_INTERNAL_DECL duk_ret_t duk_bi_typedarray_set ( duk_context * ctx)

Definition at line 23425 of file duktape-1.8.0/src/duktape.c.

23428 :
23429 *
23430 * - Source and target separate buffers or non-overlapping.
23431 *
23432 * - Source and target have a compatible type so that a plain byte copy
23433 * is possible. Note that while e.g. uint8 and int8 are compatible
23434 * (coercion one way or another doesn't change the byte representation),
23435 * e.g. int8 and uint8clamped are NOT compatible when writing int8
23436 * values into uint8clamped typedarray (-1 would clamp to 0 for instance).
23437 *
23438 * See test-bi-typedarray-proto-set.js.
23439 */
23440
23441#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
23442DUK_INTERNAL duk_ret_t duk_bi_typedarray_set(duk_context *ctx) {
23443 duk_hthread *thr;
23444 duk_hbufferobject *h_this;
23445 duk_hobject *h_obj;
23446 duk_uarridx_t i, n;
23447 duk_int_t offset_signed;
23448 duk_uint_t offset_elems;
23449 duk_uint_t offset_bytes;
23450
23451 thr = (duk_hthread *) ctx;
23452 DUK_UNREF(thr);
23453
23454 h_this = duk__require_bufobj_this(ctx);
23455 DUK_ASSERT(h_this != NULL);
23456 DUK_ASSERT_HBUFFEROBJECT_VALID(h_this);
23457
23458 if (h_this->buf == NULL) {
23459 DUK_DDD(DUK_DDDPRINT("source neutered, skip copy"));
23460 return 0;
23461 }
23462
23463 h_obj = duk_require_hobject(ctx, 0);
23464 DUK_ASSERT(h_obj != NULL);
23465
23466 /* XXX: V8 throws a TypeError for negative values. Would it
23467 * be more useful to interpret negative offsets here from the
23468 * end of the buffer too?
23469 */
23470 offset_signed = duk_to_int(ctx, 1);
23471 if (offset_signed < 0) {
23472 return DUK_RET_TYPE_ERROR;
23473 }
23474 offset_elems = (duk_uint_t) offset_signed;
23475 offset_bytes = offset_elems << h_this->shift;
23476 if ((offset_bytes >> h_this->shift) != offset_elems) {
23477 /* Byte length would overflow. */
23478 /* XXX: easier check with less code? */
23479 return DUK_RET_RANGE_ERROR;
23480 }
23481 if (offset_bytes > h_this->length) {
23482 /* Equality may be OK but >length not. Checking
23483 * this explicitly avoids some overflow cases
23484 * below.
23485 */
23486 return DUK_RET_RANGE_ERROR;
23487 }
23488 DUK_ASSERT(offset_bytes <= h_this->length);
23489
23490 /* Fast path: source is a TypedArray (or any bufferobject). */
23491
23492 if (DUK_HOBJECT_IS_BUFFEROBJECT(h_obj)) {
23493 duk_hbufferobject *h_bufarg;
23494 duk_uint16_t comp_mask;
23495 duk_small_int_t no_overlap = 0;
23496 duk_uint_t src_length;
23497 duk_uint_t dst_length;
23498 duk_uint_t dst_length_elems;
23499 duk_uint8_t *p_src_base;
23500 duk_uint8_t *p_src_end;
23501 duk_uint8_t *p_src;
23502 duk_uint8_t *p_dst_base;
23503 duk_uint8_t *p_dst;
23504 duk_small_uint_t src_elem_size;
23505 duk_small_uint_t dst_elem_size;
23506
23507 h_bufarg = (duk_hbufferobject *) h_obj;
23508 DUK_ASSERT_HBUFFEROBJECT_VALID(h_bufarg);
23509
23510 if (h_bufarg->buf == NULL) {
23511 DUK_DDD(DUK_DDDPRINT("target neutered, skip copy"));
23512 return 0;
23513 }
23514
23515 /* Nominal size check. */
23516 src_length = h_bufarg->length; /* bytes in source */
23517 dst_length_elems = (src_length >> h_bufarg->shift); /* elems in source and dest */
23518 dst_length = dst_length_elems << h_this->shift; /* bytes in dest */
23519 if ((dst_length >> h_this->shift) != dst_length_elems) {
23520 /* Byte length would overflow. */
23521 /* XXX: easier check with less code? */
23522 return DUK_RET_RANGE_ERROR;
23523 }
23524 DUK_DDD(DUK_DDDPRINT("nominal size check: src_length=%ld, dst_length=%ld",
23525 (long) src_length, (long) dst_length));
23526 DUK_ASSERT(offset_bytes <= h_this->length);
23527 if (dst_length > h_this->length - offset_bytes) {
23528 /* Overflow not an issue because subtraction is used on the right
23529 * side and guaranteed to be >= 0.
23530 */
23531 DUK_DDD(DUK_DDDPRINT("copy exceeds target buffer nominal length"));
23532 return DUK_RET_RANGE_ERROR;
23533 }
23534 if (!DUK_HBUFFEROBJECT_VALID_BYTEOFFSET_EXCL(h_this, offset_bytes + dst_length)) {
23535 DUK_DDD(DUK_DDDPRINT("copy not covered by underlying target buffer, ignore"));
23536 return 0;
23537 }
23538
23539 p_src_base = DUK_HBUFFEROBJECT_GET_SLICE_BASE(thr->heap, h_bufarg);
23540 p_dst_base = DUK_HBUFFEROBJECT_GET_SLICE_BASE(thr->heap, h_this) + offset_bytes;
23541
23542 /* Check actual underlying buffers for validity and that they
23543 * cover the copy. No side effects are allowed after the check
23544 * so that the validity status doesn't change.
23545 */
23546 if (!DUK_HBUFFEROBJECT_VALID_SLICE(h_this) ||
23547 !DUK_HBUFFEROBJECT_VALID_SLICE(h_bufarg)) {
23548 /* The condition could be more narrow and check for the
23549 * copy area only, but there's no need for fine grained
23550 * behavior when the underlying buffer is misconfigured.
23551 */
23552 DUK_DDD(DUK_DDDPRINT("source and/or target not covered by underlying buffer, skip copy"));
23553 return 0;
23554 }
23555
23556 /* We want to do a straight memory copy if possible: this is
23557 * an important operation because .set() is the TypedArray
23558 * way to copy chunks of memory. However, because set()
23559 * conceptually works in terms of elements, not all views are
23560 * compatible with direct byte copying.
23561 *
23562 * If we do manage a direct copy, the "overlap issue" handled
23563 * below can just be solved using memmove() because the source
23564 * and destination element sizes are necessarily equal.
23565 */
23566
23567 DUK_ASSERT(h_this->elem_type < sizeof(duk__buffer_elemtype_copy_compatible) / sizeof(duk_uint16_t));
23568 comp_mask = duk__buffer_elemtype_copy_compatible[h_this->elem_type];
23569 if (comp_mask & (1 << h_bufarg->elem_type)) {
23570 DUK_ASSERT(src_length == dst_length);
23571
23572 DUK_DDD(DUK_DDDPRINT("fast path: able to use memmove() because views are compatible"));
23573 DUK_MEMMOVE((void *) p_dst_base, (const void *) p_src_base, (size_t) dst_length);
23574 return 0;
23575 }
23576 DUK_DDD(DUK_DDDPRINT("fast path: views are not compatible with a byte copy, copy by item"));
23577
23578 /* We want to avoid making a copy to process set() but that's
23579 * not always possible: the source and the target may overlap
23580 * and because element sizes are different, the overlap cannot
23581 * always be handled with a memmove() or choosing the copy
23582 * direction in a certain way. For example, if source type is
23583 * uint8 and target type is uint32, the target area may exceed
23584 * the source area from both ends!
23585 *
23586 * Note that because external buffers may point to the same
23587 * memory areas, we must ultimately make this check using
23588 * pointers.
23589 *
23590 * NOTE: careful with side effects: any side effect may cause
23591 * a buffer resize (or external buffer pointer/length update)!
23592 */
23593
23594 DUK_DDD(DUK_DDDPRINT("overlap check: p_src_base=%p, src_length=%ld, "
23595 "p_dst_base=%p, dst_length=%ld",
23596 (void *) p_src_base, (long) src_length,
23597 (void *) p_dst_base, (long) dst_length));
23598
23599 if (p_src_base >= p_dst_base + dst_length || /* source starts after dest ends */
23600 p_src_base + src_length <= p_dst_base) { /* source ends before dest starts */
23601 no_overlap = 1;
23602 }
23603
23604 if (!no_overlap) {
23605 /* There's overlap: the desired end result is that
23606 * conceptually a copy is made to avoid "trampling"
23607 * of source data by destination writes. We make
23608 * an actual temporary copy to handle this case.
23609 */
23610 duk_uint8_t *p_src_copy;
23611
23612 DUK_DDD(DUK_DDDPRINT("there is overlap, make a copy of the source"));
23613 p_src_copy = (duk_uint8_t *) duk_push_fixed_buffer(ctx, src_length);
23614 DUK_ASSERT(p_src_copy != NULL);
23615 DUK_MEMCPY((void *) p_src_copy, (const void *) p_src_base, (size_t) src_length);
23616
23617 p_src_base = p_src_copy; /* use p_src_base from now on */
23618 }
23619 /* Value stack intentionally mixed size here. */
23620
23621 DUK_DDD(DUK_DDDPRINT("after overlap check: p_src_base=%p, src_length=%ld, "
23622 "p_dst_base=%p, dst_length=%ld, valstack top=%ld",
23623 (void *) p_src_base, (long) src_length,
23624 (void *) p_dst_base, (long) dst_length,
23625 (long) duk_get_top(ctx)));
23626
23627 /* Ready to make the copy. We must proceed element by element
23628 * and must avoid any side effects that might cause the buffer
23629 * validity check above to become invalid.
23630 *
23631 * Although we work through the value stack here, only plain
23632 * numbers are handled which should be side effect safe.
23633 */
23634
23635 src_elem_size = 1 << h_bufarg->shift;
23636 dst_elem_size = 1 << h_this->shift;
23637 p_src = p_src_base;
23638 p_dst = p_dst_base;
23639 p_src_end = p_src_base + src_length;
23640
23641 while (p_src != p_src_end) {
23642 DUK_DDD(DUK_DDDPRINT("fast path per element copy loop: "
23643 "p_src=%p, p_src_end=%p, p_dst=%p",
23644 (void *) p_src, (void *) p_src_end, (void *) p_dst));
23645 /* A validated read() is always a number, so it's write coercion
23646 * is always side effect free an won't invalidate pointers etc.
23647 */
23648 duk_hbufferobject_push_validated_read(ctx, h_bufarg, p_src, src_elem_size);
23649 duk_hbufferobject_validated_write(ctx, h_this, p_dst, dst_elem_size);
23650 duk_pop(ctx);
23651 p_src += src_elem_size;
23652 p_dst += dst_elem_size;
23653 }
23654
23655 return 0;
23656 } else {
23657 /* Slow path: quite slow, but we save space by using the property code
23658 * to write coerce target values. We don't need to worry about overlap
23659 * here because the source is not a TypedArray.
23660 *
23661 * We could use the bufferobject write coercion helper but since the
23662 * property read may have arbitrary side effects, full validity checks
23663 * would be needed for every element anyway.
23664 */
23665
23666 n = (duk_uarridx_t) duk_get_length(ctx, 0);
23667 DUK_ASSERT(offset_bytes <= h_this->length);
23668 if ((n << h_this->shift) > h_this->length - offset_bytes) {
23669 /* Overflow not an issue because subtraction is used on the right
23670 * side and guaranteed to be >= 0.
23671 */
23672 DUK_DDD(DUK_DDDPRINT("copy exceeds target buffer nominal length"));
23673 return DUK_RET_RANGE_ERROR;
23674 }
23675
23676 /* There's no need to check for buffer validity status for the

References duk_hbufferobject::buf, duk__buffer_elemtype_copy_compatible, duk__require_bufobj_this(), DUK_ASSERT, DUK_ASSERT_HBUFFEROBJECT_VALID, DUK_ASSERT_TOP, DUK_DDD, DUK_DDDPRINT, duk_get_length(), duk_get_prop_index(), duk_get_top(), DUK_HBUFFEROBJECT_GET_SLICE_BASE, duk_hbufferobject_push_validated_read(), DUK_HBUFFEROBJECT_VALID_BYTEOFFSET_EXCL, DUK_HBUFFEROBJECT_VALID_SLICE, duk_hbufferobject_validated_write(), DUK_HOBJECT_IS_BUFFEROBJECT, DUK_MEMCPY, DUK_MEMMOVE, duk_pop(), duk_push_fixed_buffer, duk_push_this(), duk_put_prop_index(), duk_require_hobject(), DUK_RET_RANGE_ERROR, DUK_RET_TYPE_ERROR, duk_to_int(), DUK_UNREF, duk_hbufferobject::elem_type, duk_hthread::heap, duk_hbufferobject::length, NULL, and duk_hbufferobject::shift.

◆ duk_bw_compact()

DUK_INTERNAL_DECL void duk_bw_compact ( duk_hthread * thr,
duk_bufwriter_ctx * bw_ctx )

Definition at line 86572 of file duktape-1.8.0/src/duktape.c.

◆ duk_bw_init()

DUK_INTERNAL_DECL void duk_bw_init ( duk_hthread * thr,
duk_bufwriter_ctx * bw_ctx,
duk_hbuffer_dynamic * h_buf )

Definition at line 86508 of file duktape-1.8.0/src/duktape.c.

86511 {
86512 duk_uint8_t *p;
86513
86514 DUK_ASSERT(thr != NULL);
86515 DUK_ASSERT(bw_ctx != NULL);
86516 DUK_UNREF(thr);
86517

References duk_bufwriter_ctx::buf, DUK_ASSERT, DUK_HBUFFER_DYNAMIC_GET_DATA_PTR, DUK_UNREF, duk_hthread::heap, and NULL.

◆ duk_bw_init_pushbuf()

DUK_INTERNAL_DECL void duk_bw_init_pushbuf ( duk_hthread * thr,
duk_bufwriter_ctx * bw_ctx,
duk_size_t buf_size )

Definition at line 86519 of file duktape-1.8.0/src/duktape.c.

86525 {
86526
86527 DUK_ASSERT(thr != NULL);
86528 DUK_ASSERT(bw_ctx != NULL);
86529 DUK_ASSERT(h_buf != NULL);

◆ duk_bw_insert_ensure_area()

DUK_INTERNAL_DECL duk_uint8_t * duk_bw_insert_ensure_area ( duk_hthread * thr,
duk_bufwriter_ctx * bw,
duk_size_t off,
duk_size_t len )

Definition at line 86719 of file duktape-1.8.0/src/duktape.c.

◆ duk_bw_insert_ensure_bytes()

DUK_INTERNAL_DECL void duk_bw_insert_ensure_bytes ( duk_hthread * thr,
duk_bufwriter_ctx * bw,
duk_size_t dst_off,
const duk_uint8_t * buf,
duk_size_t len )

Definition at line 86637 of file duktape-1.8.0/src/duktape.c.

◆ duk_bw_insert_ensure_slice()

DUK_INTERNAL_DECL void duk_bw_insert_ensure_slice ( duk_hthread * thr,
duk_bufwriter_ctx * bw,
duk_size_t dst_off,
duk_size_t src_off,
duk_size_t len )

Definition at line 86685 of file duktape-1.8.0/src/duktape.c.

◆ duk_bw_insert_raw_area()

DUK_INTERNAL_DECL duk_uint8_t * duk_bw_insert_raw_area ( duk_hthread * thr,
duk_bufwriter_ctx * bw,
duk_size_t off,
duk_size_t len )

Definition at line 86701 of file duktape-1.8.0/src/duktape.c.

86702 {
86703 DUK_ASSERT(thr != NULL);
86704 DUK_ASSERT(bw != NULL);
86705 DUK_ASSERT(dst_off <= DUK_BW_GET_SIZE(thr, bw));
86706 DUK_ASSERT(src_off <= DUK_BW_GET_SIZE(thr, bw));
86707 DUK_ASSERT(len <= DUK_BW_GET_SIZE(thr, bw));
86708 DUK_ASSERT(src_off + len <= DUK_BW_GET_SIZE(thr, bw));
86709 DUK_UNREF(thr);
86710
86711 /* Don't support "straddled" source now. */
86712 DUK_ASSERT(dst_off <= src_off || dst_off >= src_off + len);
86713
86714 DUK_BW_ENSURE(thr, bw, len);
86715 duk_bw_insert_raw_slice(thr, bw, dst_off, src_off, len);
86716}
86717
DUK_INTERNAL_DECL void duk_bw_insert_raw_slice(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t dst_off, duk_size_t src_off, duk_size_t len)

References DUK_ASSERT, DUK_BW_ENSURE, DUK_BW_GET_SIZE, duk_bw_insert_raw_slice(), DUK_UNREF, and NULL.

◆ duk_bw_insert_raw_bytes()

DUK_INTERNAL_DECL void duk_bw_insert_raw_bytes ( duk_hthread * thr,
duk_bufwriter_ctx * bw,
duk_size_t dst_off,
const duk_uint8_t * buf,
duk_size_t len )

Definition at line 86613 of file duktape-1.8.0/src/duktape.c.

86618 {
86619 DUK_ASSERT(thr != NULL);
86620 DUK_ASSERT(bw != NULL);
86621 DUK_ASSERT(src_off <= DUK_BW_GET_SIZE(thr, bw));
86622 DUK_ASSERT(len <= DUK_BW_GET_SIZE(thr, bw));
86623 DUK_ASSERT(src_off + len <= DUK_BW_GET_SIZE(thr, bw));
86624 DUK_UNREF(thr);
86625
86626 DUK_BW_ENSURE(thr, bw, len);
86627 duk_bw_write_raw_slice(thr, bw, src_off, len);
86628}
86629
86630DUK_INTERNAL void duk_bw_insert_raw_bytes(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t dst_off, const duk_uint8_t *buf, duk_size_t len) {
86631 duk_uint8_t *p_base;
86632 duk_size_t buf_sz, move_sz;
86633
86634 DUK_ASSERT(thr != NULL);
86635 DUK_ASSERT(bw != NULL);
DUK_INTERNAL_DECL void duk_bw_insert_raw_bytes(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t dst_off, const duk_uint8_t *buf, duk_size_t len)
DUK_INTERNAL_DECL void duk_bw_write_raw_slice(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t src_off, duk_size_t len)

◆ duk_bw_insert_raw_slice()

DUK_INTERNAL_DECL void duk_bw_insert_raw_slice ( duk_hthread * thr,
duk_bufwriter_ctx * bw,
duk_size_t dst_off,
duk_size_t src_off,
duk_size_t len )

Definition at line 86648 of file duktape-1.8.0/src/duktape.c.

86654 {
86655 DUK_ASSERT(thr != NULL);
86656 DUK_ASSERT(bw != NULL);
86657 DUK_ASSERT(dst_off <= DUK_BW_GET_SIZE(thr, bw));
86658 DUK_ASSERT(buf != NULL);
86659 DUK_UNREF(thr);
86660
86661 DUK_BW_ENSURE(thr, bw, len);
86662 duk_bw_insert_raw_bytes(thr, bw, dst_off, buf, len);
86663}
86664
86666 duk_uint8_t *p_base;
86667 duk_size_t buf_sz, move_sz;
86668
86669 DUK_ASSERT(thr != NULL);
86670 DUK_ASSERT(bw != NULL);
86671 DUK_ASSERT(dst_off <= DUK_BW_GET_SIZE(thr, bw));
86672 DUK_ASSERT(src_off <= DUK_BW_GET_SIZE(thr, bw));
86673 DUK_ASSERT(len <= DUK_BW_GET_SIZE(thr, bw));
86674 DUK_ASSERT(src_off + len <= DUK_BW_GET_SIZE(thr, bw));
86675 DUK_UNREF(thr);
86676
86677 p_base = bw->p_base;
86678
86679 /* Don't support "straddled" source now. */
86680 DUK_ASSERT(dst_off <= src_off || dst_off >= src_off + len);
86681
86682 if (dst_off <= src_off) {
86683 /* Target is before source. Source offset is expressed as

Referenced by duk_bw_insert_raw_area().

◆ duk_bw_remove_raw_slice()

DUK_INTERNAL_DECL void duk_bw_remove_raw_slice ( duk_hthread * thr,
duk_bufwriter_ctx * bw,
duk_size_t off,
duk_size_t len )

Definition at line 86729 of file duktape-1.8.0/src/duktape.c.

86736 {
86737 DUK_ASSERT(thr != NULL);
86738 DUK_ASSERT(bw != NULL);
86739 DUK_ASSERT(off <= DUK_BW_GET_SIZE(thr, bw));
86740 DUK_UNREF(thr);
86741
86742 DUK_BW_ENSURE(thr, bw, len);
86743 return duk_bw_insert_raw_area(thr, bw, off, len);
86744}
86745
86747 duk_size_t move_sz;
86748
86749 duk_uint8_t *p_base;
86750 duk_uint8_t *p_src;
86751 duk_uint8_t *p_dst;
DUK_INTERNAL_DECL duk_uint8_t * duk_bw_insert_raw_area(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t off, duk_size_t len)
DUK_INTERNAL_DECL void duk_bw_remove_raw_slice(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t off, duk_size_t len)

◆ duk_bw_resize()

DUK_INTERNAL_DECL duk_uint8_t * duk_bw_resize ( duk_hthread * thr,
duk_bufwriter_ctx * bw_ctx,
duk_size_t sz )

Definition at line 86534 of file duktape-1.8.0/src/duktape.c.

86536 {
86537 duk_context *ctx;
86538
86539 DUK_ASSERT(thr != NULL);
86540 DUK_ASSERT(bw_ctx != NULL);
86541 ctx = (duk_context *) thr;
86542
86543 (void) duk_push_dynamic_buffer(ctx, buf_size);
86544 bw_ctx->buf = (duk_hbuffer_dynamic *) duk_get_hbuffer(ctx, -1);
86545 duk__bw_update_ptrs(thr, bw_ctx, 0, buf_size);
86546}
86547
86548/* Resize target buffer for requested size. Called by the macro only when the
86549 * fast path test (= there is space) fails.
86550 */
86551DUK_INTERNAL duk_uint8_t *duk_bw_resize(duk_hthread *thr, duk_bufwriter_ctx *bw_ctx, duk_size_t sz) {
86552 duk_size_t curr_off;
86553 duk_size_t add_sz;
86554 duk_size_t new_sz;
86555
86556 DUK_ASSERT(thr != NULL);
86557 DUK_ASSERT(bw_ctx != NULL);
86558
86559 /* We could do this operation without caller updating bw_ctx->ptr,
86560 * but by writing it back here we can share code better.
86561 */
86562
86563 curr_off = (duk_size_t) (bw_ctx->p - bw_ctx->p_base);
86564 add_sz = (curr_off >> DUK_BW_SPARE_SHIFT) + DUK_BW_SPARE_ADD;
86565 new_sz = curr_off + sz + add_sz;
86566 if (new_sz < curr_off) {
86567 /* overflow */
86569 return NULL; /* not reachable */
DUK_LOCAL void duk__bw_update_ptrs(duk_hthread *thr, duk_bufwriter_ctx *bw_ctx, duk_size_t curr_offset, duk_size_t new_length)
#define DUK_STR_BUFFER_TOO_LONG
#define DUK_BW_SPARE_SHIFT
#define DUK_BW_SPARE_ADD

◆ duk_bw_write_ensure_slice()

DUK_INTERNAL_DECL void duk_bw_write_ensure_slice ( duk_hthread * thr,
duk_bufwriter_ctx * bw,
duk_size_t src_off,
duk_size_t len )

Definition at line 86601 of file duktape-1.8.0/src/duktape.c.

86601 {
86602 duk_uint8_t *p_base;
86603
86604 DUK_ASSERT(thr != NULL);
86605 DUK_ASSERT(bw != NULL);
86606 DUK_ASSERT(src_off <= DUK_BW_GET_SIZE(thr, bw));
86607 DUK_ASSERT(len <= DUK_BW_GET_SIZE(thr, bw));
86608 DUK_ASSERT(src_off + len <= DUK_BW_GET_SIZE(thr, bw));
86609 DUK_UNREF(thr);
86610
86611 p_base = bw->p_base;

References DUK_ASSERT, DUK_BW_GET_SIZE, DUK_MEMCPY, DUK_UNREF, NULL, duk_bufwriter_ctx::p, and duk_bufwriter_ctx::p_base.

◆ duk_bw_write_raw_slice()

DUK_INTERNAL_DECL void duk_bw_write_raw_slice ( duk_hthread * thr,
duk_bufwriter_ctx * bw,
duk_size_t src_off,
duk_size_t len )

Definition at line 86584 of file duktape-1.8.0/src/duktape.c.

86589 {
86590 duk_size_t len;
86591
86592 DUK_ASSERT(thr != NULL);
86593 DUK_ASSERT(bw_ctx != NULL);
86594 DUK_UNREF(thr);
86595
86596 len = (duk_size_t) (bw_ctx->p - bw_ctx->p_base);
86597 duk_hbuffer_resize(thr, bw_ctx->buf, len);
86598 duk__bw_update_ptrs(thr, bw_ctx, len, len);
86599}

◆ duk_call()

DUK_EXTERNAL void duk_call ( duk_context * ctx,
duk_idx_t nargs )

Definition at line 12414 of file duktape-1.8.0/src/duktape.c.

12417 : %!T", (duk_tval *) duk_get_tval(ctx, -1)));
12418
12419 /* [... key arg1 ... argN func] */
12420
12421 duk_replace(ctx, -nargs - 2);
12422
12423 /* [... func arg1 ... argN] */
12424
12425 duk_dup(ctx, normalized_obj_index);
12426 duk_insert(ctx, -nargs - 1);
12427
12428 /* [... func this arg1 ... argN] */
12429}
12430
12431DUK_EXTERNAL void duk_call(duk_context *ctx, duk_idx_t nargs) {
12432 duk_hthread *thr = (duk_hthread *) ctx;
12433 duk_small_uint_t call_flags;
12434 duk_idx_t idx_func;
12435
12436 DUK_ASSERT_CTX_VALID(ctx);
12437 DUK_ASSERT(thr != NULL);
12438
12439 idx_func = duk_get_top(ctx) - nargs - 1;

◆ duk_call_method()

DUK_EXTERNAL void duk_call_method ( duk_context * ctx,
duk_idx_t nargs )

Definition at line 12441 of file duktape-1.8.0/src/duktape.c.

12458 {
12459 duk_hthread *thr = (duk_hthread *) ctx;
12460 duk_small_uint_t call_flags;

Referenced by duk_bi_object_prototype_is_prototype_of(), duk_hobject_putprop(), and duk_to_defaultvalue().

◆ duk_call_prop()

DUK_EXTERNAL void duk_call_prop ( duk_context * ctx,
duk_idx_t obj_index,
duk_idx_t nargs )

Definition at line 12462 of file duktape-1.8.0/src/duktape.c.

12467 {
12468 /* note that we can't reliably pop anything here */
12470 }
12471
12472 call_flags = 0; /* not protected, respect reclimit, not constructor */
12473
12474 duk_handle_call_unprotected(thr, /* thread */
12475 nargs, /* num_stack_args */
12476 call_flags); /* call_flags */
12477}
12478
12479DUK_EXTERNAL void duk_call_prop(duk_context *ctx, duk_idx_t obj_index, duk_idx_t nargs) {
12480 /*
DUK_EXTERNAL void duk_call_prop(duk_context *ctx, duk_idx_t obj_index, duk_idx_t nargs)

◆ duk_char_code_at()

DUK_EXTERNAL duk_codepoint_t duk_char_code_at ( duk_context * ctx,
duk_idx_t index,
duk_size_t char_offset )

Definition at line 20106 of file duktape-1.8.0/src/duktape.c.

20110 : p_start=%p, p_end=%p, q_start=%p, q_end=%p",
20111 (const void *) p_start, (const void *) p_end,
20112 (const void *) q_start, (const void *) q_end));
20113
20114 if (q_start == p_start && q_end == p_end) {
20115 DUK_DDD(DUK_DDDPRINT("nothing was trimmed: avoid interning (hashing etc)"));
20116 return;
20117 }
20118
20119 duk_push_lstring(ctx, (const char *) q_start, (duk_size_t) (q_end - q_start));
20120 duk_replace(ctx, index);
20121}
20122
20123DUK_EXTERNAL duk_codepoint_t duk_char_code_at(duk_context *ctx, duk_idx_t index, duk_size_t char_offset) {
20124 duk_hthread *thr = (duk_hthread *) ctx;

◆ duk_check_stack()

DUK_EXTERNAL duk_bool_t duk_check_stack ( duk_context * ctx,
duk_idx_t extra )

Definition at line 15721 of file duktape-1.8.0/src/duktape.c.

15727 {
15729 } else {
15730 return 0;
15731 }
15732 }
15733
15734 DUK_DDD(DUK_DDDPRINT("valstack resize successful"));
15735 return 1;
15736}
15737
15739 duk_hthread *thr = (duk_hthread *) ctx;
15740 duk_size_t min_new_size;
15741

Referenced by duk__realloc_props().

◆ duk_check_stack_top()

DUK_EXTERNAL duk_bool_t duk_check_stack_top ( duk_context * ctx,
duk_idx_t top )

Definition at line 15765 of file duktape-1.8.0/src/duktape.c.

15767 {
15768 /* Clamping to zero makes the API more robust to calling code
15769 * calculation errors.
15770 */
15771 extra = 0;
15772 }
15773
15774 min_new_size = (thr->valstack_top - thr->valstack) + extra + DUK_VALSTACK_INTERNAL_EXTRA;
15775 (void) duk_valstack_resize_raw(ctx,
15776 min_new_size, /* min_new_size */
15777 0 /* no shrink */ | /* flags */
15778 0 /* no compact */ |
15780}
15781
15783 duk_hthread *thr;
15784 duk_size_t min_new_size;
15785
DUK_EXTERNAL duk_bool_t duk_check_stack_top(duk_context *ctx, duk_idx_t top)

◆ duk_check_type()

DUK_EXTERNAL duk_bool_t duk_check_type ( duk_context * ctx,
duk_idx_t index,
duk_int_t type )

Definition at line 17676 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__error_getter_helper().

◆ duk_check_type_mask()

DUK_EXTERNAL duk_bool_t duk_check_type_mask ( duk_context * ctx,
duk_idx_t index,
duk_uint_t mask )

Definition at line 17720 of file duktape-1.8.0/src/duktape.c.

17721 :
17722 return DUK_TYPE_MASK_POINTER;
17723 case DUK_TAG_LIGHTFUNC:
17725#if defined(DUK_USE_FASTINT)
17726 case DUK_TAG_FASTINT:
17727#endif
17728 default:
17729 /* Note: number has no explicit tag (in 8-byte representation) */
17732 return DUK_TYPE_MASK_NUMBER;
17733 }
#define DUK_TYPE_MASK_LIGHTFUNC
#define DUK_TYPE_MASK_NUMBER
#define DUK_TYPE_MASK_POINTER

Referenced by duk_to_boolean().

◆ duk_compact()

DUK_EXTERNAL void duk_compact ( duk_context * ctx,
duk_idx_t obj_index )

Definition at line 14834 of file duktape-1.8.0/src/duktape.c.

14835 :
14837 return;
14838
14839 fail_not_callable:
14841 return;
14842}
14843
14844/*
14845 * Object related
#define DUK_STR_INVALID_DESCRIPTOR

Referenced by duk_bi_error_constructor_shared().

◆ duk_compile_raw()

DUK_EXTERNAL duk_int_t duk_compile_raw ( duk_context * ctx,
const char * src_buffer,
duk_size_t src_length,
duk_uint_t flags )

Definition at line 13733 of file duktape-1.8.0/src/duktape.c.

13750 {
13751 duk__compile_raw_args comp_args_alloc;
13752 duk__compile_raw_args *comp_args = &comp_args_alloc;
13753
13755
13756 if ((flags & DUK_COMPILE_STRLEN) && (src_buffer != NULL)) {
13757 /* String length is computed here to avoid multiple evaluation
13758 * of a macro argument in the calling side.
13759 */
13760 src_length = DUK_STRLEN(src_buffer);
13761 }
13762
13763 comp_args->src_buffer = (const duk_uint8_t *) src_buffer;
13764 comp_args->src_length = src_length;
13765 comp_args->flags = flags;
13766 duk_push_pointer(ctx, (void *) comp_args);
13767
13768 /* [ ... source? filename? &comp_args ] (depends on flags) */
13769
13770 if (flags & DUK_COMPILE_SAFE) {
13771 duk_int_t rc;
13772 duk_int_t nargs;
13773 duk_int_t nrets = 1;
13774
13775 /* Arguments can be: [ source? filename? &comp_args] so that
13776 * nargs is 1 to 3. Call site encodes the correct nargs count

◆ duk_concat()

DUK_EXTERNAL void duk_concat ( duk_context * ctx,
duk_idx_t count )

Definition at line 19902 of file duktape-1.8.0/src/duktape.c.

19903 {
19904 duk_replace(ctx, -((duk_idx_t) count) - 1); /* overwrite str1 */
19905 duk_pop_n(ctx, count-1);
19906 }

Referenced by duk_bi_string_prototype_locale_compare(), and duk_push_string_funcptr().

◆ duk_config_buffer()

DUK_EXTERNAL void duk_config_buffer ( duk_context * ctx,
duk_idx_t index,
void * ptr,
duk_size_t len )

Definition at line 11631 of file duktape-1.8.0/src/duktape.c.

11639 {
11640 *out_size = sz;
11641 }
11644
11645 return ptr;
11646}
11647
#define DUK_HBUFFER_DYNAMIC_SET_SIZE(x, v)
#define DUK_HBUFFER_DYNAMIC_SET_DATA_PTR_NULL(heap, x)

◆ duk_copy()

DUK_EXTERNAL void duk_copy ( duk_context * ctx,
duk_idx_t from_index,
duk_idx_t to_index )

Definition at line 15938 of file duktape-1.8.0/src/duktape.c.

◆ duk_create_activation_environment_record()

DUK_INTERNAL_DECL duk_hobject * duk_create_activation_environment_record ( duk_hthread * thr,
duk_hobject * func,
duk_size_t idx_bottom )

Definition at line 71971 of file duktape-1.8.0/src/duktape.c.

71990 {
71991 duk_context *ctx = (duk_context *) thr;
71992 duk_hobject *env;
71993 duk_hobject *parent;
71994 duk_tval *tv;
71995
71996 DUK_ASSERT(thr != NULL);
71997 DUK_ASSERT(func != NULL);
71998
72000 if (tv) {
72003 parent = DUK_TVAL_GET_OBJECT(tv);
72004 } else {
72005 parent = thr->builtins[DUK_BIDX_GLOBAL_ENV];
72006 }
72007
72008 (void) duk_push_object_helper(ctx,
72011 -1); /* no prototype, updated below */

Referenced by duk_handle_ecma_call_setup().

◆ duk_create_heap()

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 )

Definition at line 14058 of file duktape-1.8.0/src/duktape.c.

14067 {
14068 duk_ljstate lj;
14069 duk_bool_t handling_error;
14070 duk_hthread *curr_thread;
14071 duk_int_t call_recursion_depth;
14072};
14073
14076 duk_realloc_function realloc_func,
14077 duk_free_function free_func,
14078 void *heap_udata,
14079 duk_fatal_function fatal_handler) {
14080 duk_heap *heap = NULL;
14081 duk_context *ctx;
14082
14083 /* Assume that either all memory funcs are NULL or non-NULL, mixed
14084 * cases will now be unsafe.
14085 */
14086
14087 /* XXX: just assert non-NULL values here and make caller arguments
14088 * do the defaulting to the default implementations (smaller code)?
14089 */
14090
14091 if (!alloc_func) {
14092 DUK_ASSERT(realloc_func == NULL);
14093 DUK_ASSERT(free_func == NULL);
14094#if defined(DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS)
14095 alloc_func = duk_default_alloc_function;
14096 realloc_func = duk_default_realloc_function;
14097 free_func = duk_default_free_function;
14098#else
14099 DUK_D(DUK_DPRINT("no allocation functions given and no default providers"));
14100 return NULL;
14101#endif
14102 } else {
14103 DUK_ASSERT(realloc_func != NULL);
14104 DUK_ASSERT(free_func != NULL);
14105 }
14106
14107 if (!fatal_handler) {
void *(* duk_alloc_function)(void *udata, duk_size_t size)
void(* duk_fatal_function)(duk_context *ctx, duk_errcode_t code, const char *msg)
void(* duk_free_function)(void *udata, void *ptr)
void *(* duk_realloc_function)(void *udata, void *ptr, duk_size_t size)
DUK_INTERNAL_DECL void * duk_default_alloc_function(void *udata, duk_size_t size)
DUK_INTERNAL_DECL void * duk_default_realloc_function(void *udata, void *ptr, duk_size_t newsize)
DUK_INTERNAL_DECL void duk_default_free_function(void *udata, void *ptr)
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)

◆ duk_debugger_attach_custom()

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 )

Definition at line 13986 of file duktape-1.8.0/src/duktape.c.

13989 {
13990 DUK_HEAP_SET_PAUSED(thr->heap);
13991
13992 /* Pause on the next opcode executed. This is always safe to do even
13993 * inside the debugger message loop: the interrupt counter will be reset
13994 * to its proper value when the message loop exits.
13995 */
13996 thr->interrupt_init = 1;
13997 thr->interrupt_counter = 0;
13998 }
13999}
14000
14001#else /* DUK_USE_DEBUGGER_SUPPORT */
14002
14005 duk_debug_write_function write_cb,
duk_size_t(* duk_debug_read_function)(void *udata, char *buffer, duk_size_t length)
duk_size_t(* duk_debug_write_function)(void *udata, const char *buffer, duk_size_t length)
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_debugger_cooperate()

DUK_EXTERNAL void duk_debugger_cooperate ( duk_context * ctx)

Definition at line 14012 of file duktape-1.8.0/src/duktape.c.

◆ duk_debugger_detach()

DUK_EXTERNAL void duk_debugger_detach ( duk_context * ctx)

Definition at line 14007 of file duktape-1.8.0/src/duktape.c.

◆ duk_debugger_notify()

DUK_EXTERNAL duk_bool_t duk_debugger_notify ( duk_context * ctx,
duk_idx_t nvalues )

Definition at line 14018 of file duktape-1.8.0/src/duktape.c.

14024 {
14026 DUK_ERROR_API((duk_hthread *) ctx, "no debugger support");
14027}
14028
14030 /* nop */
14032 DUK_UNREF(ctx);
DUK_EXTERNAL void duk_debugger_cooperate(duk_context *ctx)

◆ duk_debugger_pause()

DUK_EXTERNAL void duk_debugger_pause ( duk_context * ctx)

Definition at line 14034 of file duktape-1.8.0/src/duktape.c.

14035 {
14036 duk_idx_t top;
14037

References DUK_ASSERT_CTX_VALID, DUK_ERROR_API, duk_get_top(), and duk_pop_n().

◆ duk_decode_string()

DUK_EXTERNAL void duk_decode_string ( duk_context * ctx,
duk_idx_t index,
duk_decode_char_function callback,
void * udata )

Definition at line 19918 of file duktape-1.8.0/src/duktape.c.

19919 {
19921
19922 duk__concat_and_join_helper(ctx, count, 0 /*is_join*/);
19923}
19924
19925DUK_EXTERNAL void duk_join(duk_context *ctx, duk_idx_t count) {
19927
19928 duk__concat_and_join_helper(ctx, count, 1 /*is_join*/);
19929}
19930
19931/* XXX: could map/decode be unified with duk_unicode_support.c code?
19932 * Case conversion needs also the character surroundings though.
19933 */
19934
19936 duk_hthread *thr = (duk_hthread *) ctx;
19937 duk_hstring *h_input;
19938 const duk_uint8_t *p, *p_start, *p_end;
19939 duk_codepoint_t cp;
19940
void(* duk_decode_char_function)(void *udata, duk_codepoint_t codepoint)
DUK_EXTERNAL void duk_decode_string(duk_context *ctx, duk_idx_t index, duk_decode_char_function callback, void *udata)

References duk__concat_and_join_helper(), and DUK_ASSERT_CTX_VALID.

◆ duk_def_prop()

DUK_EXTERNAL void duk_def_prop ( duk_context * ctx,
duk_idx_t obj_index,
duk_uint_t flags )

Definition at line 14742 of file duktape-1.8.0/src/duktape.c.

14751 {
14752 duk_hthread *thr = (duk_hthread *) ctx;
14753 duk_hobject *obj = duk_require_hobject(ctx, obj_index);
14755 duk_hobject_define_accessor_internal(thr, obj, DUK_HTHREAD_GET_STRING(thr, stridx), thrower, thrower, desc_flags);
14756}
14757
14758/* Object.defineProperty() equivalent C binding. */
14759DUK_EXTERNAL void duk_def_prop(duk_context *ctx, duk_idx_t obj_index, duk_uint_t flags) {
14760 duk_hthread *thr = (duk_hthread *) ctx;
14761 duk_idx_t idx_base;
14762 duk_hobject *obj;
14763 duk_hstring *key;
14764 duk_idx_t idx_value;
14765 duk_hobject *get;
14766 duk_hobject *set;
14767 duk_uint_t is_data_desc;
14768 duk_uint_t is_acc_desc;
14769
14771
14772 obj = duk_require_hobject(ctx, obj_index);
14773
14774 is_data_desc = flags & (DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE);
14775 is_acc_desc = flags & (DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER);
14776 if (is_data_desc && is_acc_desc) {
14777 /* "Have" flags must not be conflicting so that they would
14778 * apply to both a plain property and an accessor at the same
14779 * time.
14780 */
14781 goto fail_invalid_desc;
14782 }
14783
14784 idx_base = duk_get_top_index(ctx);
14785 if (flags & DUK_DEFPROP_HAVE_SETTER) {
14789 set = duk_get_hobject_or_lfunc_coerce(ctx, idx_base);
14790 if (set != NULL && !DUK_HOBJECT_IS_CALLABLE(set)) {
14791 goto fail_not_callable;
14792 }
14793 idx_base--;
14794 } else {
14795 set = NULL;
14796 }
14797 if (flags & DUK_DEFPROP_HAVE_GETTER) {
14801 get = duk_get_hobject_or_lfunc_coerce(ctx, idx_base);
14802 if (get != NULL && !DUK_HOBJECT_IS_CALLABLE(get)) {
14803 goto fail_not_callable;
14804 }
14805 idx_base--;
14806 } else {
14807 get = NULL;
14808 }
14809 if (flags & DUK_DEFPROP_HAVE_VALUE) {
14810 idx_value = idx_base;
14811 idx_base--;
14812 } else {
14813 idx_value = (duk_idx_t) -1;
14814 }
14815 key = duk_require_hstring(ctx, idx_base);
14816
14817 duk_require_valid_index(ctx, idx_base);
14818
14820 flags /*defprop_flags*/,
14821 obj,
14822 key,
14823 idx_value,
14824 get,
14825 set);
#define DUK_DEFPROP_HAVE_GETTER
#define DUK_DEFPROP_HAVE_WRITABLE
#define DUK_DEFPROP_HAVE_SETTER
#define DUK_TYPE_MASK_UNDEFINED
DUK_INTERNAL_DECL void duk_hobject_define_accessor_internal(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_hobject *getter, duk_hobject *setter, duk_small_uint_t propflags)
#define DUK_BIDX_TYPE_ERROR_THROWER

◆ duk_default_alloc_function()

DUK_INTERNAL_DECL void * duk_default_alloc_function ( void * udata,
duk_size_t size )

Definition at line 11550 of file duktape-1.8.0/src/duktape.c.

◆ duk_default_fatal_handler()

DUK_INTERNAL void duk_default_fatal_handler ( duk_context * ctx,
duk_errcode_t code,
const char * msg )

Definition at line 9876 of file duktape-1.8.0/src/duktape.c.

9878 {
9880}
9883}
9886}
9887#endif
#define DUK_ERR_ALLOC_ERROR
DUK_INTERNAL void duk_err_alloc(duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message)
DUK_INTERNAL void duk_err_internal(duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message)
#define DUK_ERROR_RAW(thr, file, line, err, msg)

◆ duk_default_free_function()

DUK_INTERNAL_DECL void duk_default_free_function ( void * udata,
void * ptr )

Definition at line 11568 of file duktape-1.8.0/src/duktape.c.

11571 : %lu -> %p",
11572 (unsigned long) size, (void *) res));

◆ duk_default_panic_handler()

DUK_INTERNAL void duk_default_panic_handler ( duk_errcode_t code,
const char * msg )

Definition at line 9894 of file duktape-1.8.0/src/duktape.c.

9896 : %s\n", (long) code, (const char *) (msg ? msg : "null"));
9897 DUK_FFLUSH(DUK_STDERR);
9898#else
9899 /* omit print */
9900#endif
9901 DUK_D(DUK_DPRINT("default fatal handler called, code %ld -> calling DUK_PANIC()", (long) code));
9902 DUK_PANIC(code, msg);
9903 DUK_UNREACHABLE();
9904}
9905
9906/*
9907 * Default panic handler
9908 */
9909
9910#if !defined(DUK_USE_PANIC_HANDLER)
9911DUK_INTERNAL void duk_default_panic_handler(duk_errcode_t code, const char *msg) {
9912#if defined(DUK_USE_FILE_IO)
9913 DUK_FPRINTF(DUK_STDERR, "PANIC %ld: %s ("
9914#if defined(DUK_USE_PANIC_ABORT)
9915 "calling abort"
9916#elif defined(DUK_USE_PANIC_EXIT)
9917 "calling exit"
9918#elif defined(DUK_USE_PANIC_SEGFAULT)
9919 "segfaulting on purpose"
9920#else
9921#error no DUK_USE_PANIC_xxx macro defined
9922#endif
9923 ")\n", (long) code, (const char *) (msg ? msg : "null"));
9924 DUK_FFLUSH(DUK_STDERR);
9925#else
9926 /* omit print */
9927 DUK_UNREF(code);
#define DUK_PANIC(code, msg)
static void fatal(const char *message)

◆ duk_default_realloc_function()

DUK_INTERNAL_DECL void * duk_default_realloc_function ( void * udata,
void * ptr,
duk_size_t newsize )

Definition at line 11559 of file duktape-1.8.0/src/duktape.c.

◆ duk_del_prop()

DUK_EXTERNAL duk_bool_t duk_del_prop ( duk_context * ctx,
duk_idx_t obj_index )

Definition at line 14547 of file duktape-1.8.0/src/duktape.c.

14551 {
14552 duk_hthread *thr = (duk_hthread *) ctx;
14553
14555 DUK_ASSERT_DISABLE(stridx >= 0);
14557 DUK_UNREF(thr);
14558
14559 obj_idx = duk_require_normalize_index(ctx, obj_idx);
14560 duk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx));
14561 return duk__put_prop_shared(ctx, obj_idx, -1);
14562}
14563
14565 duk_hthread *thr = (duk_hthread *) ctx;
14566 duk_tval *tv_obj;
14567 duk_tval *tv_key;
14568 duk_small_int_t throw_flag;
14569 duk_bool_t rc;

Referenced by duk_del_prop_stridx().

◆ duk_del_prop_index()

DUK_EXTERNAL duk_bool_t duk_del_prop_index ( duk_context * ctx,
duk_idx_t obj_index,
duk_uarridx_t arr_index )

Definition at line 14580 of file duktape-1.8.0/src/duktape.c.

◆ duk_del_prop_stridx()

DUK_INTERNAL_DECL duk_bool_t duk_del_prop_stridx ( duk_context * ctx,
duk_idx_t obj_index,
duk_small_int_t stridx )

Definition at line 14588 of file duktape-1.8.0/src/duktape.c.

14588 {
14590 DUK_ASSERT(key != NULL);
14591
14592 obj_index = duk_require_normalize_index(ctx, obj_index);
14593 duk_push_string(ctx, key);
14594 return duk_del_prop(ctx, obj_index);
14595}
14596
14599

References DUK_ASSERT, DUK_ASSERT_CTX_VALID, duk_del_prop(), duk_push_string(), duk_require_normalize_index(), and NULL.

◆ duk_del_prop_string()

DUK_EXTERNAL duk_bool_t duk_del_prop_string ( duk_context * ctx,
duk_idx_t obj_index,
const char * key )

Definition at line 14571 of file duktape-1.8.0/src/duktape.c.

◆ duk_del_var()

DUK_EXTERNAL duk_bool_t duk_del_var ( duk_context * ctx)

Definition at line 20199 of file duktape-1.8.0/src/duktape.c.

20199 {
20200 duk_js_putvar_activation(thr, act, h_varname, tv_val, throw_flag); /* -> [ ... varname val this ] */
20201 } else {
20202 /* Outside any activation -> put to global. */
20203 DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL_ENV] != NULL);
20204 duk_js_putvar_envrec(thr, thr->builtins[DUK_BIDX_GLOBAL_ENV], h_varname, tv_val, throw_flag);
DUK_INTERNAL_DECL void duk_js_putvar_envrec(duk_hthread *thr, duk_hobject *env, duk_hstring *name, duk_tval *val, duk_bool_t strict)

References duk_js_putvar_activation().

◆ duk_destroy_heap()

DUK_EXTERNAL void duk_destroy_heap ( duk_context * ctx)

Definition at line 14109 of file duktape-1.8.0/src/duktape.c.

14117 {
14118 return NULL;
14119 }
14120 ctx = (duk_context *) heap->heap_thread;

◆ duk_dump_function()

DUK_EXTERNAL void duk_dump_function ( duk_context * ctx)

Definition at line 12285 of file duktape-1.8.0/src/duktape.c.

12294 : %!iT", duk_get_tval(ctx, -1)));
12295 DUK_ASSERT_TOP(ctx, idx_base + 1);
12296 return p;
12297
12298 format_error:
12299 return NULL;
12300}
12301
12302DUK_EXTERNAL void duk_dump_function(duk_context *ctx) {
12303 duk_hthread *thr;
12304 duk_hcompiledfunction *func;
12305 duk_bufwriter_ctx bw_ctx_alloc;
12306 duk_bufwriter_ctx *bw_ctx = &bw_ctx_alloc;
12307 duk_uint8_t *p;
12308
12309 DUK_ASSERT(ctx != NULL);
12310 thr = (duk_hthread *) ctx;
12311
12312 /* Bound functions don't have all properties so we'd either need to
12313 * lookup the non-bound target function or reject bound functions.
12314 * For now, bound functions are rejected.
12315 */
12316 func = duk_require_hcompiledfunction(ctx, -1);
12317 DUK_ASSERT(func != NULL);

◆ duk_dup()

◆ duk_dup_top()

DUK_EXTERNAL void duk_dup_top ( duk_context * ctx)

Definition at line 15854 of file duktape-1.8.0/src/duktape.c.

15854 {
15855 duk_hthread *thr;
15856 duk_tval *tv_from;
15857 duk_tval *tv_to;
15858
15860 thr = (duk_hthread *) ctx;
15862
15863 tv_from = duk_require_tval(ctx, from_index);
15864 tv_to = thr->valstack_top++;
15865 DUK_ASSERT(tv_from != NULL);
15866 DUK_ASSERT(tv_to != NULL);
15867 DUK_TVAL_SET_TVAL(tv_to, tv_from);
15868 DUK_TVAL_INCREF(thr, tv_to); /* no side effects */
15869}
15870
15872 duk_hthread *thr;
15873 duk_tval *tv_from;

References DUK__CHECK_SPACE, DUK_ASSERT, DUK_ASSERT_CTX_VALID, duk_require_tval(), DUK_TVAL_INCREF, DUK_TVAL_SET_TVAL, NULL, and duk_hthread::valstack_top.

Referenced by duk__format_parts_iso8601(), duk__init_varmap_and_prologue_for_pass2(), and duk__parse_var_decl().

◆ duk_enum()

DUK_EXTERNAL void duk_enum ( duk_context * ctx,
duk_idx_t obj_index,
duk_uint_t enum_flags )

Definition at line 14849 of file duktape-1.8.0/src/duktape.c.

14851 {
14852 duk_hthread *thr = (duk_hthread *) ctx;
14853 duk_hobject *obj;
14854

References DUK_ASSERT_CTX_VALID.

◆ duk_equals()

DUK_EXTERNAL duk_bool_t duk_equals ( duk_context * ctx,
duk_idx_t index1,
duk_idx_t index2 )

Definition at line 19543 of file duktape-1.8.0/src/duktape.c.

◆ duk_err_alloc()

DUK_INTERNAL void duk_err_alloc ( duk_hthread * thr,
const char * filename,
duk_int_t linenumber,
const char * message )

Definition at line 9839 of file duktape-1.8.0/src/duktape.c.

9839 {
9840 DUK_ERROR_RAW(thr, filename, linenumber, DUK_ERR_API_ERROR, message);
9841}

References DUK_ERR_API_ERROR, and DUK_ERROR_RAW.

◆ duk_err_api()

DUK_INTERNAL void duk_err_api ( duk_hthread * thr,
const char * filename,
duk_int_t linenumber,
const char * message )

Definition at line 9822 of file duktape-1.8.0/src/duktape.c.

9823 {
9824 DUK_ERROR_RAW_FMT3(thr, filename, linenumber, DUK_ERR_TYPE_ERROR, "%s required, found %s (stack index %ld)",
#define DUK_ERROR_RAW_FMT3(thr, file, line, err, fmt, arg1, arg2, arg3)

References DUK_ERR_TYPE_ERROR, and DUK_ERROR_RAW_FMT3.

◆ duk_err_api_index()

DUK_INTERNAL void duk_err_api_index ( duk_hthread * thr,
const char * filename,
duk_int_t linenumber,
duk_idx_t index )

Definition at line 9819 of file duktape-1.8.0/src/duktape.c.

◆ duk_err_augment_error_create()

DUK_INTERNAL_DECL void duk_err_augment_error_create ( duk_hthread * thr,
duk_hthread * thr_callstack,
const char * filename,
duk_int_t line,
duk_bool_t noblame_fileline )

Definition at line 40347 of file duktape-1.8.0/src/duktape.c.

40351 : thread containing the error value
40352 * thr_callstack: thread which should be used for generating callstack etc.
40353 * c_filename: C __FILE__ related to the error
40354 * c_line: C __LINE__ related to the error
40355 * noblame_fileline: if true, don't fileName/line as error source, otherwise use traceback
40356 * (needed because user code filename/line are reported but internal ones
40357 * are not)
40358 *
40359 * XXX: rename noblame_fileline to flags field; combine it to some existing
40360 * field (there are only a few call sites so this may not be worth it).
40361 */
40362
40363#if defined(DUK_USE_AUGMENT_ERROR_CREATE)
40364DUK_INTERNAL void duk_err_augment_error_create(duk_hthread *thr, duk_hthread *thr_callstack, const char *c_filename, duk_int_t c_line, duk_bool_t noblame_fileline) {
40365 duk_context *ctx = (duk_context *) thr;
40366 duk_hobject *obj;
40367
40368 DUK_ASSERT(thr != NULL);
40369 DUK_ASSERT(thr_callstack != NULL);
40370 DUK_ASSERT(ctx != NULL);
40371
40372 /* [ ... error ] */
40373
40374 /*
40375 * Criteria for augmenting:
40376 *
40377 * - augmentation enabled in build (naturally)
40378 * - error value internal prototype chain contains the built-in
40379 * Error prototype object (i.e. 'val instanceof Error')
40380 *
40381 * Additional criteria for built-in augmenting:
40382 *
40383 * - error value is an extensible object
40384 */
40385
40386 obj = duk_get_hobject(ctx, -1);
40387 if (!obj) {
40388 DUK_DDD(DUK_DDDPRINT("value is not an object, skip both built-in and user augment"));
40389 return;
40390 }
40391 if (!duk_hobject_prototype_chain_contains(thr, obj, thr->builtins[DUK_BIDX_ERROR_PROTOTYPE], 1 /*ignore_loop*/)) {
40392 /* If the value has a prototype loop, it's critical not to
40393 * throw here. Instead, assume the value is not to be
40394 * augmented.

References duk_hthread::builtins, duk__err_augment_builtin_create(), DUK_ASSERT, DUK_BIDX_ERROR_PROTOTYPE, DUK_DDD, DUK_DDDPRINT, duk_get_hobject(), DUK_HOBJECT_HAS_EXTENSIBLE, duk_hobject_prototype_chain_contains(), and NULL.

◆ duk_err_augment_error_throw()

DUK_INTERNAL_DECL void duk_err_augment_error_throw ( duk_hthread * thr)

Definition at line 40404 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_err_create_and_throw().

◆ duk_err_create_and_throw()

DUK_INTERNAL void duk_err_create_and_throw ( duk_hthread * thr,
duk_errcode_t code,
const char * msg,
const char * filename,
duk_int_t line )

Definition at line 40613 of file duktape-1.8.0/src/duktape.c.

40630 {
40631#else
40633#endif
40634 duk_context *ctx = (duk_context *) thr;
40635 duk_bool_t double_error = thr->heap->handling_error;
40636
40637#ifdef DUK_USE_VERBOSE_ERRORS
40638 DUK_DD(DUK_DDPRINT("duk_err_create_and_throw(): code=%ld, msg=%s, filename=%s, line=%ld",
40639 (long) code, (const char *) msg,
40640 (const char *) filename, (long) line));
40641#else
40642 DUK_DD(DUK_DDPRINT("duk_err_create_and_throw(): code=%ld", (long) code));
40643#endif
40644
40645 DUK_ASSERT(thr != NULL);
40646 DUK_ASSERT(ctx != NULL);
40647
40648 thr->heap->handling_error = 1;
40649
40650 if (!double_error) {
40651 /* Allow headroom for calls during error handling (see GH-191).
40652 * We allow space for 10 additional recursions, with one extra
40653 * for, e.g. a print() call at the deepest level.
40654 */
40657 }
40658
40659 DUK_ASSERT(thr->callstack_max == DUK_CALLSTACK_DEFAULT_MAX + DUK_CALLSTACK_GROW_STEP + 11); /* just making sure */
40660
40661 /* Sync so that augmentation sees up-to-date activations, NULL
40662 * thr->ptr_curr_pc so that it's not used if side effects occur
40663 * in augmentation or longjmp handling.
40664 */
40666
40667 /*
40668 * Create and push an error object onto the top of stack.
40669 * If a "double error" occurs, use a fixed error instance
40670 * to avoid further trouble.
40671 */
40672
40673 /* XXX: if attempt to push beyond allocated valstack, this double fault
40674 * handling fails miserably. We should really write the double error
40675 * directly to thr->heap->lj.value1 and avoid valstack use entirely.
40676 */
40677
40678 if (double_error) {
40679 if (thr->builtins[DUK_BIDX_DOUBLE_ERROR]) {
40680 DUK_D(DUK_DPRINT("double fault detected -> push built-in fixed 'double error' instance"));
40682 } else {
40683 DUK_D(DUK_DPRINT("double fault detected; there is no built-in fixed 'double error' instance "
40684 "-> push the error code as a number"));
40685 duk_push_int(ctx, (duk_int_t) code);
40686 }
40687 } else {
40688 /* Error object is augmented at its creation here. */
40689 duk_require_stack(ctx, 1);
40690 /* XXX: unnecessary '%s' formatting here, but cannot use
40691 * 'msg' as a format string directly.
40692 */
40693#ifdef DUK_USE_VERBOSE_ERRORS
40696 filename,
40697 line,
40698 "%s",
40699 (const char *) msg);
40700#else
40703 NULL,
40704 0,
40705 NULL);
40706#endif
40707 }
40708
40709 /*
40710 * Augment error (throw time), unless alloc/double error
40711 */
40712
40713 if (double_error || code == DUK_ERR_ALLOC_ERROR) {
40714 DUK_D(DUK_DPRINT("alloc or double error: skip throw augmenting to avoid further trouble"));
40715 } else {
40716#if defined(DUK_USE_AUGMENT_ERROR_THROW)
40717 DUK_DDD(DUK_DDDPRINT("THROW ERROR (INTERNAL): %!iT (before throw augment)",
40718 (duk_tval *) duk_get_tval(ctx, -1)));
40720#endif
#define DUK_BIDX_DOUBLE_ERROR
DUK_INTERNAL void duk_err_create_and_throw(duk_hthread *thr, duk_errcode_t code, const char *msg, const char *filename, duk_int_t line)
#define DUK_CALLSTACK_DEFAULT_MAX
#define DUK_CALLSTACK_GROW_STEP
#define DUK_ERRCODE_FLAG_NOBLAME_FILELINE
DUK_EXTERNAL duk_idx_t duk_push_error_object_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt,...)

References duk_hthread::builtins, duk_hthread::callstack_max, DUK_ASSERT, DUK_BIDX_DOUBLE_ERROR, DUK_CALLSTACK_DEFAULT_MAX, DUK_CALLSTACK_GROW_STEP, DUK_D, DUK_DD, DUK_DDD, DUK_DDDPRINT, DUK_DDPRINT, DUK_DPRINT, DUK_ERR_ALLOC_ERROR, duk_err_augment_error_throw(), duk_err_create_and_throw(), DUK_ERRCODE_FLAG_NOBLAME_FILELINE, duk_get_tval(), duk_hthread_sync_and_null_currpc(), DUK_INTERNAL, duk_push_error_object_raw(), duk_push_hobject_bidx(), duk_push_int(), duk_require_stack(), duk_heap::handling_error, duk_hthread::heap, and NULL.

Referenced by duk_err_create_and_throw(), duk_err_handle_error(), and duk_err_require_type_index().

◆ duk_err_handle_error()

DUK_INTERNAL void duk_err_handle_error ( duk_hthread * thr,
const char * filename,
duk_uint_t line_and_code,
const char * msg )

◆ duk_err_handle_error_fmt()

DUK_INTERNAL void duk_err_handle_error_fmt ( duk_hthread * thr,
const char * filename,
duk_uint_t line_and_code,
const char * fmt,
... )

Definition at line 9778 of file duktape-1.8.0/src/duktape.c.

◆ duk_err_internal()

DUK_INTERNAL void duk_err_internal ( duk_hthread * thr,
const char * filename,
duk_int_t linenumber,
const char * message )

Definition at line 9836 of file duktape-1.8.0/src/duktape.c.

9836 {
9837 DUK_ERROR_RAW_FMT1(thr, filename, linenumber, DUK_ERR_API_ERROR, "invalid stack index %ld", (long) (index));
9838}
#define DUK_ERROR_RAW_FMT1(thr, file, line, err, fmt, arg1)

References DUK_ERR_API_ERROR, DUK_ERROR_RAW_FMT1, and index.

◆ duk_err_internal_defmsg()

DUK_INTERNAL void duk_err_internal_defmsg ( duk_hthread * thr,
const char * filename,
duk_int_t linenumber )

Definition at line 9833 of file duktape-1.8.0/src/duktape.c.

9833 {
9834 DUK_ERROR_RAW(thr, filename, linenumber, DUK_ERR_RANGE_ERROR, message);
9835}
#define DUK_ERR_RANGE_ERROR

References DUK_ERR_RANGE_ERROR, and DUK_ERROR_RAW.

◆ duk_err_longjmp()

DUK_INTERNAL void duk_err_longjmp ( duk_hthread * thr)

Definition at line 40418 of file duktape-1.8.0/src/duktape.c.

40421 {
40422#if defined(DUK_USE_ERRTHROW)
40424#endif /* DUK_USE_ERRTHROW */
40425}
40426#endif /* DUK_USE_AUGMENT_ERROR_THROW */
40427#line 1 "duk_error_longjmp.c"
40428/*
40429 * Do a longjmp call, calling the fatal error handler if no
40430 * catchpoint exists.
40431 */
40432
40433/* include removed: duk_internal.h */
40434
40436 DUK_ASSERT(thr != NULL);
40437
40438 DUK_DD(DUK_DDPRINT("longjmp error: type=%d iserror=%d value1=%!T value2=%!T",
40439 (int) thr->heap->lj.type, (int) thr->heap->lj.iserror,
40440 &thr->heap->lj.value1, &thr->heap->lj.value2));
40441
40442#if !defined(DUK_USE_CPP_EXCEPTIONS)
40443 /* If we don't have a jmpbuf_ptr, there is little we can do
40444 * except panic. The caller's expectation is that we never
40445 * return.
40446 *
40447 * With C++ exceptions we now just propagate an uncaught error
40448 * instead of invoking the fatal error handler. Because there's
40449 * a dummy jmpbuf for C++ exceptions now, this could be changed.
40450 */
40451 if (!thr->heap->lj.jmpbuf_ptr) {
40452
40453 DUK_D(DUK_DPRINT("uncaught error: type=%d iserror=%d value1=%!T value2=%!T",
40454 (int) thr->heap->lj.type, (int) thr->heap->lj.iserror,
40455 &thr->heap->lj.value1, &thr->heap->lj.value2));
#define DUK_STRIDX_ERR_THROW

References duk__err_augment_user(), and DUK_STRIDX_ERR_THROW.

◆ duk_err_range()

DUK_INTERNAL void duk_err_range ( duk_hthread * thr,
const char * filename,
duk_int_t linenumber,
const char * message )

Definition at line 9816 of file duktape-1.8.0/src/duktape.c.

◆ duk_err_require_type_index()

DUK_INTERNAL void duk_err_require_type_index ( duk_hthread * thr,
const char * filename,
duk_int_t linenumber,
duk_idx_t index,
const char * expect_name )

Definition at line 9811 of file duktape-1.8.0/src/duktape.c.

9811 {
9812 duk_err_create_and_throw(thr, code);
9813}
9814

References duk_err_create_and_throw().

◆ duk_err_setup_heap_ljstate()

DUK_INTERNAL_DECL void duk_err_setup_heap_ljstate ( duk_hthread * thr,
duk_small_int_t lj_type )

Definition at line 40530 of file duktape-1.8.0/src/duktape.c.

40532 :
40536 case DUK_ERR_API_ERROR:
40537 case DUK_ERR_ERROR:
40538 default:
40540 }
40541}
40542
40543/*
40544 * Exposed helper for setting up heap longjmp state.
40545 */
40546
40548#if defined(DUK_USE_DEBUGGER_SUPPORT)
40549 /* If something is thrown with the debugger attached and nobody will
40550 * catch it, execution is paused before the longjmp, turning over
40551 * control to the debug client. This allows local state to be examined
40552 * before the stack is unwound. Errors are not intercepted when debug
40553 * message loop is active (e.g. for Eval).
40554 */
40555
40556 /* XXX: Allow customizing the pause and notify behavior at runtime
40557 * using debugger runtime flags. For now the behavior is fixed using
40558 * config options.
40559 */
40560#if defined(DUK_USE_DEBUGGER_THROW_NOTIFY) || defined(DUK_USE_DEBUGGER_PAUSE_UNCAUGHT)
40561 if (DUK_HEAP_IS_DEBUGGER_ATTACHED(thr->heap) &&
40562 !thr->heap->dbg_processing &&
40563 lj_type == DUK_LJ_TYPE_THROW) {
40564 duk_context *ctx = (duk_context *) thr;
40566 duk_hobject *h_obj;
40567
40568 /* Don't intercept a DoubleError, we may have caused the initial double
40569 * fault and attempting to intercept it will cause us to be called
40570 * recursively and exhaust the C stack.
40571 */
40572 h_obj = duk_get_hobject(ctx, -1);
40573 if (h_obj == thr->builtins[DUK_BIDX_DOUBLE_ERROR]) {
40574 DUK_D(DUK_DPRINT("built-in DoubleError instance thrown, not intercepting"));
40575 goto skip_throw_intercept;
40576 }
40577
40578 DUK_D(DUK_DPRINT("throw with debugger attached, report to client"));
40579
40580 fatal = !duk__have_active_catcher(thr);
40581
40582#if defined(DUK_USE_DEBUGGER_THROW_NOTIFY)
40583 /* Report it to the debug client */
40584 duk_debug_send_throw(thr, fatal);
40585#endif
40586
40587#if defined(DUK_USE_DEBUGGER_PAUSE_UNCAUGHT)
40588 if (fatal) {
#define DUK_ERR_ASSERTION_ERROR
#define DUK_BIDX_ERROR_PROTOTYPE

◆ duk_err_unimplemented_defmsg()

DUK_INTERNAL void duk_err_unimplemented_defmsg ( duk_hthread * thr,
const char * filename,
duk_int_t linenumber )

Definition at line 9825 of file duktape-1.8.0/src/duktape.c.

◆ duk_error_prototype_from_code()

DUK_INTERNAL_DECL duk_hobject * duk_error_prototype_from_code ( duk_hthread * thr,
duk_errcode_t err_code )

Definition at line 40499 of file duktape-1.8.0/src/duktape.c.

40499 {
40500 for (i = 0; i < thr->catchstack_top; i++) {
40501 duk_catcher *cat = thr->catchstack + i;
40502 if (DUK_CAT_HAS_CATCH_ENABLED(cat)) {
40503 return 1; /* all we need to know */
40504 }
40505 }
40506 thr = thr->resumer;
40507 }
40508 return 0;
40509}
40510#endif /* DUK_USE_DEBUGGER_SUPPORT && (DUK_USE_DEBUGGER_THROW_NOTIFY || DUK_USE_DEBUGGER_PAUSE_UNCAUGHT) */
40511
40512/*
40513 * Get prototype object for an integer error code.
40514 */
40515
40517 switch (code) {
40518 case DUK_ERR_EVAL_ERROR:
#define DUK_BIDX_EVAL_ERROR_PROTOTYPE
DUK_INTERNAL_DECL duk_hobject * duk_error_prototype_from_code(duk_hthread *thr, duk_errcode_t err_code)
#define DUK_BIDX_REFERENCE_ERROR_PROTOTYPE
#define DUK_BIDX_RANGE_ERROR_PROTOTYPE

References duk_hthread::catchstack, duk_hthread::catchstack_top, DUK_CAT_HAS_CATCH_ENABLED, and duk_hthread::resumer.

◆ duk_error_raw()

DUK_EXTERNAL void duk_error_raw ( duk_context * ctx,
duk_errcode_t err_code,
const char * filename,
duk_int_t line,
const char * fmt,
... )

Definition at line 19508 of file duktape-1.8.0/src/duktape.c.

◆ duk_error_stash()

DUK_EXTERNAL void duk_error_stash ( duk_context * ctx,
duk_errcode_t err_code,
const char * fmt,
... )

Definition at line 19520 of file duktape-1.8.0/src/duktape.c.

19525 {
19526 va_list ap;
19527
19529
19530 va_start(ap, fmt);
19531 duk_push_error_object_va_raw(ctx, err_code, filename, line, fmt, ap);
19532 va_end(ap);
19533 duk_throw(ctx);
19534}
19535
19536#if !defined(DUK_USE_VARIADIC_MACROS)
DUK_EXTERNAL void duk_throw(duk_context *ctx)
DUK_EXTERNAL duk_idx_t duk_push_error_object_va_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, va_list ap)

◆ duk_error_throw_from_negative_rc()

DUK_INTERNAL void duk_error_throw_from_negative_rc ( duk_hthread * thr,
duk_ret_t rc )

Definition at line 40726 of file duktape-1.8.0/src/duktape.c.

40732 : %!iT, %!iT (after throw augment)",
40733 (duk_tval *) &thr->heap->lj.value1, (duk_tval *) &thr->heap->lj.value2));
40734
40735 duk_err_longjmp(thr);
40736 DUK_UNREACHABLE();
40737}
40738
40739/*
40740 * Helper for C function call negative return values.
40741 */
40742
40743DUK_INTERNAL void duk_error_throw_from_negative_rc(duk_hthread *thr, duk_ret_t rc) {
40744 duk_context *ctx = (duk_context *) thr;
40745 const char *msg;
40746 duk_errcode_t code;
40747
40748 DUK_ASSERT(thr != NULL);
40749 DUK_ASSERT(rc < 0);
40750
40751 /* XXX: this generates quite large code - perhaps select the error
40752 * class based on the code and then just use the error 'name'?
40753 */
40754 /* XXX: shared strings */
40755
40756 code = -rc;
40757
40758 switch (rc) {
40759 case DUK_RET_UNIMPLEMENTED_ERROR: msg = "unimplemented"; break;
40760 case DUK_RET_UNSUPPORTED_ERROR: msg = "unsupported"; break;
40761 case DUK_RET_INTERNAL_ERROR: msg = "internal"; break;
40762 case DUK_RET_ALLOC_ERROR: msg = "alloc"; break;
40763 case DUK_RET_ASSERTION_ERROR: msg = "assertion"; break;
40764 case DUK_RET_API_ERROR: msg = "api"; break;
40765 case DUK_RET_UNCAUGHT_ERROR: msg = "uncaught"; break;
40766 case DUK_RET_ERROR: msg = "error"; break;
40767 case DUK_RET_EVAL_ERROR: msg = "eval"; break;
40768 case DUK_RET_RANGE_ERROR: msg = "range"; break;
40769 case DUK_RET_REFERENCE_ERROR: msg = "reference"; break;
40770 case DUK_RET_SYNTAX_ERROR: msg = "syntax"; break;

◆ duk_error_va_raw()

DUK_EXTERNAL void duk_error_va_raw ( duk_context * ctx,
duk_errcode_t err_code,
const char * filename,
duk_int_t line,
const char * fmt,
va_list ap )

Definition at line 19501 of file duktape-1.8.0/src/duktape.c.

◆ duk_eval_raw()

DUK_EXTERNAL duk_int_t duk_eval_raw ( duk_context * ctx,
const char * src_buffer,
duk_size_t src_length,
duk_uint_t flags )

Definition at line 13597 of file duktape-1.8.0/src/duktape.c.

13607 {
13608 duk_size_t src_length; /* should be first on 64-bit platforms */
13609 const duk_uint8_t *src_buffer;
13610 duk_uint_t flags;
13611};
13612
13613/* Eval is just a wrapper now. */
13614DUK_EXTERNAL duk_int_t duk_eval_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags) {
13615 duk_uint_t comp_flags;
13616 duk_int_t rc;
13617
13619
13620 /* Note: strictness is *not* inherited from the current Duktape/C.
13621 * This would be confusing because the current strictness state
13622 * depends on whether we're running inside a Duktape/C activation
13623 * (= strict mode) or outside of any activation (= non-strict mode).
13624 * See tests/api/test-eval-strictness.c for more discussion.
13625 */
13626
13627 /* [ ... source? filename? ] (depends on flags) */
13628
13629 comp_flags = flags;
13630 comp_flags |= DUK_COMPILE_EVAL;
13631 rc = duk_compile_raw(ctx, src_buffer, src_length, comp_flags); /* may be safe, or non-safe depending on flags */
13632
13633 /* [ ... closure/error ] */
13634
13635 if (rc != DUK_EXEC_SUCCESS) {
13636 rc = DUK_EXEC_ERROR;
13637 goto got_rc;
13638 }
13639
13640 duk_push_global_object(ctx); /* explicit 'this' binding, see GH-164 */
DUK_EXTERNAL duk_int_t duk_compile_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags)

◆ duk_fatal()

DUK_EXTERNAL void duk_fatal ( duk_context * ctx,
duk_errcode_t err_code,
const char * err_msg )

Definition at line 19481 of file duktape-1.8.0/src/duktape.c.

19482 : %!dT (before throw augment)", (duk_tval *) duk_get_tval(ctx, -1)));
19483 duk_err_augment_error_throw(thr);
19484#endif
19485 DUK_DDD(DUK_DDDPRINT("THROW ERROR (API): %!dT (after throw augment)", (duk_tval *) duk_get_tval(ctx, -1)));
19486
19487 duk_err_setup_heap_ljstate(thr, DUK_LJ_TYPE_THROW);
19488
19489 /* thr->heap->lj.jmpbuf_ptr is checked by duk_err_longjmp() so we don't
19490 * need to check that here. If the value is NULL, a panic occurs because
19491 * we can't return.
19492 */
19493
19494 duk_err_longjmp(thr);
19495 DUK_UNREACHABLE();
19496}
19497
19498DUK_EXTERNAL void duk_fatal(duk_context *ctx, duk_errcode_t err_code, const char *err_msg) {
19499 duk_hthread *thr = (duk_hthread *) ctx;

◆ duk_free()

DUK_EXTERNAL void duk_free ( duk_context * ctx,
void * ptr )

Definition at line 14328 of file duktape-1.8.0/src/duktape.c.

14329 {
14330 duk_hthread *thr = (duk_hthread *) ctx;
14331
14333
14334 return DUK_REALLOC_RAW(thr->heap, ptr, size);
#define DUK_REALLOC_RAW(heap, ptr, newsize)

References DUK_ASSERT_CTX_VALID, DUK_REALLOC_RAW, and duk_hthread::heap.

◆ duk_free_hbuffer_inner()

DUK_INTERNAL_DECL void duk_free_hbuffer_inner ( duk_heap * heap,
duk_hbuffer * h )

Definition at line 41068 of file duktape-1.8.0/src/duktape.c.

41068 {
41069 duk_hthread *t = (duk_hthread *) h;
41070 DUK_FREE(heap, t->valstack);
41071 DUK_FREE(heap, t->callstack);
41072 DUK_FREE(heap, t->catchstack);
41073 /* Don't free h->resumer because it exists in the heap.
41074 * Callstack entries also contain function pointers which
41075 * are not freed for the same reason.
41076 */
41077

◆ duk_free_hobject_inner()

DUK_INTERNAL_DECL void duk_free_hobject_inner ( duk_heap * heap,
duk_hobject * h )

Definition at line 41037 of file duktape-1.8.0/src/duktape.c.

41054 {
41055 DUK_ASSERT(heap != NULL);
41056 DUK_ASSERT(h != NULL);
41057
41058 DUK_FREE(heap, DUK_HOBJECT_GET_PROPS(heap, h));
41059
41062 DUK_UNREF(f);
41063 /* Currently nothing to free; 'data' is a heap object */
41064 } else if (DUK_HOBJECT_IS_NATIVEFUNCTION(h)) {
41066 DUK_UNREF(f);

References DUK_ASSERT, DUK_FREE, DUK_HOBJECT_GET_PROPS, DUK_HOBJECT_IS_COMPILEDFUNCTION, DUK_HOBJECT_IS_NATIVEFUNCTION, DUK_UNREF, and NULL.

◆ duk_free_hstring_inner()

DUK_INTERNAL_DECL void duk_free_hstring_inner ( duk_heap * heap,
duk_hstring * h )

Definition at line 41079 of file duktape-1.8.0/src/duktape.c.

41085 {
41086 DUK_ASSERT(heap != NULL);
41087 DUK_ASSERT(h != NULL);
41088
41091 DUK_DDD(DUK_DDDPRINT("free dynamic buffer %p", (void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(heap, g)));
41093 }

◆ duk_free_raw()

DUK_EXTERNAL void duk_free_raw ( duk_context * ctx,
void * ptr )

Definition at line 14304 of file duktape-1.8.0/src/duktape.c.

◆ duk_gc()

DUK_EXTERNAL void duk_gc ( duk_context * ctx,
duk_uint_t flags )

Definition at line 14370 of file duktape-1.8.0/src/duktape.c.

14371 {
14372 duk_hthread *thr = (duk_hthread *) ctx;
14373 duk_heap *heap;
14374
14376 DUK_ASSERT(out_funcs != NULL);
14377 DUK_ASSERT(thr != NULL);
14378 DUK_ASSERT(thr->heap != NULL);
14379
14380 heap = thr->heap;
14381 out_funcs->alloc_func = heap->alloc_func;
14382 out_funcs->realloc_func = heap->realloc_func;
14383 out_funcs->free_func = heap->free_func;
14384 out_funcs->udata = heap->heap_udata;
14385}
14386
14387DUK_EXTERNAL void duk_gc(duk_context *ctx, duk_uint_t flags) {
14388#ifdef DUK_USE_MARK_AND_SWEEP
14389 duk_hthread *thr = (duk_hthread *) ctx;
14390 duk_heap *heap;
14391
14392 DUK_UNREF(flags);
DUK_EXTERNAL void duk_gc(duk_context *ctx, duk_uint_t flags)
duk_realloc_function realloc_func
duk_alloc_function alloc_func

References duk_heap::alloc_func, duk_memory_functions::alloc_func, DUK_ASSERT, DUK_ASSERT_CTX_VALID, duk_heap::free_func, duk_memory_functions::free_func, duk_hthread::heap, duk_heap::heap_udata, NULL, duk_heap::realloc_func, duk_memory_functions::realloc_func, and duk_memory_functions::udata.

◆ duk_get_boolean()

DUK_EXTERNAL duk_bool_t duk_get_boolean ( duk_context * ctx,
duk_idx_t index )

Definition at line 16100 of file duktape-1.8.0/src/duktape.c.

16103 {
16104 duk_hthread *thr = (duk_hthread *) ctx;
16105 duk_tval *tv;
16106
16108
16109 tv = duk_get_tval(ctx, index);
16110 if (tv && DUK_TVAL_IS_NULL(tv)) {
16111 return;
16112 }
#define DUK_STR_NOT_NULL

◆ duk_get_borrowed_this_tval()

DUK_INTERNAL_DECL duk_tval * duk_get_borrowed_this_tval ( duk_context * ctx)

Definition at line 18371 of file duktape-1.8.0/src/duktape.c.

18376 {
18377 duk_hstring *h;
18378
18380
18381 duk__push_this_helper(ctx, 1 /*check_object_coercible*/);
18382 duk_to_string(ctx, -1);

◆ duk_get_buffer()

DUK_EXTERNAL void * duk_get_buffer ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_size )

Definition at line 16332 of file duktape-1.8.0/src/duktape.c.

16334 {

Referenced by duk__base64_encode_helper().

◆ duk_get_buffer_data()

DUK_EXTERNAL void * duk_get_buffer_data ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_size )

Definition at line 16394 of file duktape-1.8.0/src/duktape.c.

16395 {
16396 *out_size = (duk_size_t) h_bufobj->length;

References duk_hbufferobject::length.

◆ duk_get_c_function()

DUK_EXTERNAL duk_c_function duk_get_c_function ( duk_context * ctx,
duk_idx_t index )

Definition at line 16513 of file duktape-1.8.0/src/duktape.c.

16513 {
16515 if (h != NULL && !DUK_HOBJECT_IS_NATIVEFUNCTION(h)) {
16516 h = NULL;
16517 }
16518 return (duk_hnativefunction *) h;
16519}
16520
16522 duk_hthread *thr = (duk_hthread *) ctx;
16524 if (!(h != NULL && DUK_HOBJECT_IS_NATIVEFUNCTION(h))) {
16526 }
16527 return (duk_hnativefunction *) h;
16528}
16529
16531 duk_tval *tv;
16532 duk_hobject *h;
16534
16536
16537 tv = duk_get_tval(ctx, index);
#define DUK_STR_NOT_NATIVEFUNCTION
DUK_EXTERNAL duk_c_function duk_get_c_function(duk_context *ctx, duk_idx_t index)
DUK_INTERNAL_DECL duk_hnativefunction * duk_require_hnativefunction(duk_context *ctx, duk_idx_t index)

References duk__get_tagged_heaphdr_raw(), DUK_HOBJECT_IS_NATIVEFUNCTION, DUK_TAG_OBJECT, index, and NULL.

◆ duk_get_context()

DUK_EXTERNAL duk_context * duk_get_context ( duk_context * ctx,
duk_idx_t index )

Definition at line 16558 of file duktape-1.8.0/src/duktape.c.

◆ duk_get_current_magic()

DUK_EXTERNAL duk_int_t duk_get_current_magic ( duk_context * ctx)

Definition at line 12880 of file duktape-1.8.0/src/duktape.c.

12886 {
12887 /* Strict by default. */
12888 return 1;
12889 }
12890 return ((act->flags & DUK_ACT_FLAG_STRICT) != 0 ? 1 : 0);
12891}
12892
12893/*
12894 * Duktape/C function magic
12895 */
12896
12898 duk_hthread *thr = (duk_hthread *) ctx;
12899 duk_activation *act;
12900 duk_hobject *func;
12901
12903 DUK_ASSERT(thr != NULL);
12905
DUK_INTERNAL_DECL duk_activation * duk_hthread_get_current_activation(duk_hthread *thr)

Referenced by duk_bi_boolean_prototype_tostring_shared(), duk_bi_buffer_readfield(), duk_bi_buffer_slice_shared(), duk_bi_object_constructor_is_extensible(), and duk_bi_string_prototype_indexof_shared().

◆ duk_get_error_code()

DUK_EXTERNAL duk_errcode_t duk_get_error_code ( duk_context * ctx,
duk_idx_t index )

Definition at line 17953 of file duktape-1.8.0/src/duktape.c.

17956 {
17957 duk_tval *tv;
17958
17960
17961 tv = duk_get_tval(ctx, index);
17962 if (tv && DUK_TVAL_IS_BUFFER(tv)) {
17964 DUK_ASSERT(h != NULL);
17965 return (DUK_HBUFFER_HAS_DYNAMIC(h) && DUK_HBUFFER_HAS_EXTERNAL(h) ? 1 : 0);
17966 }
17967 return 0;
17968}
17969
17971 duk_hthread *thr = (duk_hthread *) ctx;
17972 duk_hobject *h;
17973 duk_uint_t sanity;
17974
17976
17977 h = duk_get_hobject(ctx, index);
17978
17980 do {
17981 if (!h) {
17982 return DUK_ERR_NONE;
17983 }
17984 if (h == thr->builtins[DUK_BIDX_EVAL_ERROR_PROTOTYPE]) {
17985 return DUK_ERR_EVAL_ERROR;
17986 }
17988 return DUK_ERR_RANGE_ERROR;
17989 }
17992 }
DUK_EXTERNAL duk_errcode_t duk_get_error_code(duk_context *ctx, duk_idx_t index)
#define DUK_BIDX_SYNTAX_ERROR_PROTOTYPE

◆ duk_get_finalizer()

DUK_EXTERNAL void duk_get_finalizer ( duk_context * ctx,
duk_idx_t index )

Definition at line 14993 of file duktape-1.8.0/src/duktape.c.

◆ duk_get_global_string()

DUK_EXTERNAL duk_bool_t duk_get_global_string ( duk_context * ctx,
const char * key )

Definition at line 14903 of file duktape-1.8.0/src/duktape.c.

14907 {
14908 while (ent->key != NULL) {
14909 duk_push_number(ctx, ent->value);
14910 duk_put_prop_string(ctx, obj_index, ent->key);
14911 ent++;
14912 }
14913 }
14914}
14915
14916/*
DUK_EXTERNAL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key)

◆ duk_get_hbuffer()

DUK_INTERNAL_DECL duk_hbuffer * duk_get_hbuffer ( duk_context * ctx,
duk_idx_t index )

Definition at line 16449 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_buffer_slice_shared().

◆ duk_get_hcompiledfunction()

DUK_INTERNAL_DECL duk_hcompiledfunction * duk_get_hcompiledfunction ( duk_context * ctx,
duk_idx_t index )

Definition at line 16479 of file duktape-1.8.0/src/duktape.c.

16479 {
16481 if (h != NULL && !DUK_HOBJECT_IS_THREAD(h)) {
16482 h = NULL;
16483 }
16484 return (duk_hthread *) h;
16485}

References duk__get_tagged_heaphdr_raw(), DUK_HOBJECT_IS_THREAD, DUK_TAG_OBJECT, index, and NULL.

◆ duk_get_heapptr()

DUK_EXTERNAL void * duk_get_heapptr ( duk_context * ctx,
duk_idx_t index )

Definition at line 16570 of file duktape-1.8.0/src/duktape.c.

16570 {
16572 }
16573}
16574
16577
16578 return (duk_context *) duk_get_hthread(ctx, index);
16579}
16580
16583
16584 return (duk_context *) duk_require_hthread(ctx, index);
#define DUK_STR_NOT_FUNCTION
DUK_INTERNAL_DECL duk_hthread * duk_get_hthread(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL duk_context * duk_get_context(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL duk_context * duk_require_context(duk_context *ctx, duk_idx_t index)

References DUK_ERROR_REQUIRE_TYPE_INDEX, DUK_STR_NOT_FUNCTION, and index.

◆ duk_get_hnativefunction()

DUK_INTERNAL_DECL duk_hnativefunction * duk_get_hnativefunction ( duk_context * ctx,
duk_idx_t index )

Definition at line 16496 of file duktape-1.8.0/src/duktape.c.

16496 {
16498 if (h != NULL && !DUK_HOBJECT_IS_COMPILEDFUNCTION(h)) {
16499 h = NULL;
16500 }
16501 return (duk_hcompiledfunction *) h;
16502}

References duk__get_tagged_heaphdr_raw(), DUK_HOBJECT_IS_COMPILEDFUNCTION, DUK_TAG_OBJECT, index, and NULL.

◆ duk_get_hobject()

◆ duk_get_hobject_or_lfunc_coerce()

DUK_INTERNAL_DECL duk_hobject * duk_get_hobject_or_lfunc_coerce ( duk_context * ctx,
duk_idx_t index )

Definition at line 16618 of file duktape-1.8.0/src/duktape.c.

16626 {
16627}
16628#endif
16629
16630/* Useful for internal call sites where we either expect an object (function)
16631 * or a lightfunc. Accepts an object (returned as is) or a lightfunc (coerced
16632 * to an object). Return value is NULL if value is neither an object nor a
16633 * lightfunc.

Referenced by duk_hobject_prepare_property_descriptor(), and duk_js_instanceof().

◆ duk_get_hobject_with_class()

DUK_INTERNAL_DECL duk_hobject * duk_get_hobject_with_class ( duk_context * ctx,
duk_idx_t index,
duk_small_uint_t classnum )

◆ duk_get_hstring()

◆ duk_get_hthread()

DUK_INTERNAL_DECL duk_hthread * duk_get_hthread ( duk_context * ctx,
duk_idx_t index )

Definition at line 16462 of file duktape-1.8.0/src/duktape.c.

16466 {
16468}

◆ duk_get_int()

DUK_EXTERNAL duk_int_t duk_get_int ( duk_context * ctx,
duk_idx_t index )

Definition at line 16175 of file duktape-1.8.0/src/duktape.c.

16176 {
16177 duk_double_union ret;
16178 ret.d = DUK_TVAL_GET_NUMBER(tv);
16179

Referenced by duk_bi_buffer_readfield().

◆ duk_get_length()

DUK_EXTERNAL duk_size_t duk_get_length ( duk_context * ctx,
duk_idx_t index )

Definition at line 16710 of file duktape-1.8.0/src/duktape.c.

16717 {
16718 duk_hstring *h_class;
16720 DUK_UNREF(h_class);
16721
16723 }
16724 return h;
16725}
16726
16728 duk_tval *tv;
16729
16731
16732 tv = duk_get_tval(ctx, index);
16733 if (!tv) {
16734 return 0;
16735 }
16736
16737 switch (DUK_TVAL_GET_TAG(tv)) {
16738 case DUK_TAG_UNDEFINED:
16739 case DUK_TAG_NULL:
16740 case DUK_TAG_BOOLEAN:
16741 case DUK_TAG_POINTER:
16742 return 0;
16743 case DUK_TAG_STRING: {
16745 DUK_ASSERT(h != NULL);
16747 }
16748 case DUK_TAG_OBJECT: {
16750 DUK_ASSERT(h != NULL);
16751 return (duk_size_t) duk_hobject_get_length((duk_hthread *) ctx, h);
16752 }
16753 case DUK_TAG_BUFFER: {
16755 DUK_ASSERT(h != NULL);
16756 return (duk_size_t) DUK_HBUFFER_GET_SIZE(h);
16757 }
#define DUK_STR_UNEXPECTED_TYPE

Referenced by duk__init_varmap_and_prologue_for_pass2(), duk__parse_var_decl(), and duk_bi_typedarray_set().

◆ duk_get_lstring()

DUK_EXTERNAL const char * duk_get_lstring ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_len )

Definition at line 16199 of file duktape-1.8.0/src/duktape.c.

16204 {
16205 /* Custom coercion for API */
16207 return (duk_int_t) duk__api_coerce_d2i(ctx, index, 1 /*require*/);
16208}
16209
16211 /* Custom coercion for API */
16213 return (duk_uint_t) duk__api_coerce_d2ui(ctx, index, 1 /*require*/);
16214}
16215
16217 const char *ret;
16218 duk_tval *tv;
16219
16221
16222 /* default: NULL, length 0 */
16223 ret = NULL;
16224 if (out_len) {
16225 *out_len = 0;
DUK_EXTERNAL duk_uint_t duk_require_uint(duk_context *ctx, duk_idx_t index)

◆ duk_get_magic()

DUK_EXTERNAL duk_int_t duk_get_magic ( duk_context * ctx,
duk_idx_t index )

Definition at line 12908 of file duktape-1.8.0/src/duktape.c.

12909 {
12910 duk_tval *tv = &act->tv_func;
12911 duk_small_uint_t lf_flags;
12912 lf_flags = DUK_TVAL_GET_LIGHTFUNC_FLAGS(tv);
12913 return (duk_int_t) DUK_LFUNC_FLAGS_GET_MAGIC(lf_flags);
12914 }
12915 DUK_ASSERT(func != NULL);
12916
12919 return (duk_int_t) nf->magic;
12920 }
12921 }
12922 return 0;
12923}
12924
12926 duk_hthread *thr = (duk_hthread *) ctx;
12927 duk_tval *tv;
12928 duk_hobject *h;
12929
12931
12932 tv = duk_require_tval(ctx, index);
#define DUK_LFUNC_FLAGS_GET_MAGIC(lf_flags)
DUK_EXTERNAL duk_int_t duk_get_magic(duk_context *ctx, duk_idx_t index)

◆ duk_get_memory_functions()

DUK_EXTERNAL void duk_get_memory_functions ( duk_context * ctx,
duk_memory_functions * out_funcs )

Definition at line 14354 of file duktape-1.8.0/src/duktape.c.

◆ duk_get_number()

DUK_EXTERNAL duk_double_t duk_get_number ( duk_context * ctx,
duk_idx_t index )

Definition at line 16131 of file duktape-1.8.0/src/duktape.c.

16132 {
16133 duk_hthread *thr = (duk_hthread *) ctx;
16134 duk_tval *tv;
16135
16137
16138 tv = duk_get_tval(ctx, index);
16139 if (tv && DUK_TVAL_IS_BOOLEAN(tv)) {
16141 DUK_ASSERT(ret == 0 || ret == 1);
16142 return ret;
16143 }
16145 return 0; /* not reachable */
16146}
16147
16149 duk_double_union ret;
16150 duk_tval *tv;
#define DUK_STR_NOT_BOOLEAN

References DUK_ASSERT, DUK_ASSERT_CTX_VALID, DUK_ERROR_REQUIRE_TYPE_INDEX, duk_get_tval(), DUK_STR_NOT_BOOLEAN, DUK_TVAL_GET_BOOLEAN, DUK_TVAL_IS_BOOLEAN, and index.

◆ duk_get_pointer()

DUK_EXTERNAL void * duk_get_pointer ( duk_context * ctx,
duk_idx_t index )

Definition at line 16256 of file duktape-1.8.0/src/duktape.c.

16261 {
16263
16264 return duk_get_lstring(ctx, index, NULL);
16265}
16266

◆ duk_get_prop()

DUK_EXTERNAL duk_bool_t duk_get_prop ( duk_context * ctx,
duk_idx_t obj_index )

Definition at line 14408 of file duktape-1.8.0/src/duktape.c.

14425 {
14426 duk_hthread *thr = (duk_hthread *) ctx;
14427 duk_tval *tv_obj;
14428 duk_tval *tv_key;
14429 duk_bool_t rc;

Referenced by duk__init_varmap_and_prologue_for_pass2(), and duk_get_prop_stridx().

◆ duk_get_prop_index()

◆ duk_get_prop_stridx()

◆ duk_get_prop_stridx_boolean()

DUK_INTERNAL_DECL duk_bool_t duk_get_prop_stridx_boolean ( duk_context * ctx,
duk_idx_t obj_index,
duk_small_int_t stridx,
duk_bool_t * out_has_prop )

Definition at line 14461 of file duktape-1.8.0/src/duktape.c.

14465 {
14466 duk_hthread *thr = (duk_hthread *) ctx;
14467
14469 DUK_ASSERT_DISABLE(stridx >= 0);
14471 DUK_UNREF(thr);
14472
14473 obj_index = duk_require_normalize_index(ctx, obj_index);
14474 duk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx));
14475 return duk_get_prop(ctx, obj_index);
14476}

◆ duk_get_prop_string()

DUK_EXTERNAL duk_bool_t duk_get_prop_string ( duk_context * ctx,
duk_idx_t obj_index,
const char * key )

Definition at line 14431 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_put_global_string().

◆ duk_get_prototype()

DUK_EXTERNAL void duk_get_prototype ( duk_context * ctx,
duk_idx_t index )

Definition at line 14938 of file duktape-1.8.0/src/duktape.c.

14955 {
14956 duk_hthread *thr = (duk_hthread *) ctx;

◆ duk_get_string()

DUK_EXTERNAL const char * duk_get_string ( duk_context * ctx,
duk_idx_t index )

Definition at line 16244 of file duktape-1.8.0/src/duktape.c.

16244 {
16245 duk_hthread *thr = (duk_hthread *) ctx;
16246 const char *ret;
16247

References DUK_ASSERT_CTX_VALID.

Referenced by duk__error_getter_helper().

◆ duk_get_top()

◆ duk_get_top_index()

DUK_EXTERNAL duk_idx_t duk_get_top_index ( duk_context * ctx)

Definition at line 15438 of file duktape-1.8.0/src/duktape.c.

15446 {
15447 tv--;
15449 } while (tv != tv_end);
15450 thr->valstack_top = tv_end;
15451#endif /* DUK_USE_REFERENCE_COUNTING */
15452 }
15453}
#define DUK_TVAL_SET_UNDEFINED(tv)

Referenced by duk__error_getter_helper(), and duk_hobject_prepare_property_descriptor().

◆ duk_get_tval()

DUK_INTERNAL_DECL duk_tval * duk_get_tval ( duk_context * ctx,
duk_idx_t index )

Definition at line 15252 of file duktape-1.8.0/src/duktape.c.

15252 {
15253 uindex = vs_size + (duk_uidx_t) index;
15254 } else {
15256 uindex = (duk_uidx_t) index;
15257 }
15258
15259 /* DUK_INVALID_INDEX won't be accepted as a valid index. */
15260 DUK_ASSERT(vs_size + (duk_uidx_t) DUK_INVALID_INDEX >= vs_size);
15261
15262 if (DUK_LIKELY(uindex < vs_size)) {
15263 return (duk_idx_t) uindex;
15264 }
15266 return 0; /* unreachable */
15267}
15268
15270 duk_hthread *thr = (duk_hthread *) ctx;
15271 duk_uidx_t vs_size;
15272 duk_uidx_t uindex;
15273
15276
15278 vs_size = (duk_uidx_t) (thr->valstack_top - thr->valstack_bottom);
#define DUK_ERROR_API_INDEX(thr, index)

References index.

Referenced by duk__concat_and_join_helper(), duk__get_buffer_helper(), duk__init_varmap_and_prologue_for_pass2(), duk__ispec_toregconst_raw(), duk_bi_boolean_prototype_tostring_shared(), duk_bi_duktape_object_info(), duk_err_create_and_throw(), duk_get_number(), duk_handle_ecma_call_setup(), duk_hobject_define_property_helper(), duk_hobject_define_property_internal(), duk_hobject_putprop(), duk_is_c_function(), duk_require_heapptr(), and duk_require_null().

◆ duk_get_type()

DUK_EXTERNAL duk_int_t duk_get_type ( duk_context * ctx,
duk_idx_t index )

Definition at line 17613 of file duktape-1.8.0/src/duktape.c.

17618 {
17619 duk_hobject *obj;
17620
17622
17623 obj = duk_get_hobject(ctx, index);
17624 if (obj) {
17625 return (DUK_HEAPHDR_CHECK_FLAG_BITS((duk_heaphdr *) obj, flag_mask) ? 1 : 0);
17626 }
17627 return 0;
17628}
17629
17631 duk_tval *tv;
17632
17634
17635 tv = duk_get_tval(ctx, index);
17636 if (!tv) {
17637 return DUK_TYPE_NONE;
17638 }
17639 switch (DUK_TVAL_GET_TAG(tv)) {
17640 case DUK_TAG_UNDEFINED:
17641 return DUK_TYPE_UNDEFINED;
17642 case DUK_TAG_NULL:
17643 return DUK_TYPE_NULL;
17644 case DUK_TAG_BOOLEAN:
17645 return DUK_TYPE_BOOLEAN;
17646 case DUK_TAG_STRING:
17647 return DUK_TYPE_STRING;
17648 case DUK_TAG_OBJECT:
17649 return DUK_TYPE_OBJECT;

Referenced by duk__error_getter_helper(), duk_bi_duktape_object_info(), and duk_get_type_mask().

◆ duk_get_type_mask()

DUK_EXTERNAL duk_uint_t duk_get_type_mask ( duk_context * ctx,
duk_idx_t index )

Definition at line 17682 of file duktape-1.8.0/src/duktape.c.

17682 {
17683 duk_int_t type_tag;
17684
17685 type_tag = duk_get_type(ctx, index);
17686 DUK_ASSERT(type_tag >= DUK_TYPE_MIN && type_tag <= DUK_TYPE_MAX);
17687 DUK_ASSERT(DUK_TYPE_MIN == 0 && sizeof(duk__type_names) / sizeof(const char *) == DUK_TYPE_MAX + 1);
17688
17689 return duk__type_names[type_tag];
17690}
17691#endif
17692
17695
17696 return (duk_get_type(ctx, index) == type) ? 1 : 0;
17697}
17698
17700 duk_tval *tv;
17701
17703
17704 tv = duk_get_tval(ctx, index);
17705 if (!tv) {
17706 return DUK_TYPE_MASK_NONE;
17707 }
17708 switch (DUK_TVAL_GET_TAG(tv)) {
17709 case DUK_TAG_UNDEFINED:
17711 case DUK_TAG_NULL:
17712 return DUK_TYPE_MASK_NULL;
17713 case DUK_TAG_BOOLEAN:
17714 return DUK_TYPE_MASK_BOOLEAN;
17715 case DUK_TAG_STRING:
17716 return DUK_TYPE_MASK_STRING;
17717 case DUK_TAG_OBJECT:
17718 return DUK_TYPE_MASK_OBJECT;
#define DUK_TYPE_MASK_BOOLEAN
DUK_EXTERNAL duk_uint_t duk_get_type_mask(duk_context *ctx, duk_idx_t index)

References DUK_ASSERT, duk_get_type(), DUK_TYPE_MAX, DUK_TYPE_MIN, and index.

◆ duk_get_uint()

DUK_EXTERNAL duk_uint_t duk_get_uint ( duk_context * ctx,
duk_idx_t index )

Definition at line 16181 of file duktape-1.8.0/src/duktape.c.

◆ duk_get_var()

DUK_EXTERNAL void duk_get_var ( duk_context * ctx)

Definition at line 20132 of file duktape-1.8.0/src/duktape.c.

20134 {
20135 return 0;
20136 }
20137
20138 DUK_ASSERT(char_offset <= DUK_UINT_MAX); /* guaranteed by string limits */
20139 cp = duk_hstring_char_code_at_raw(thr, h, (duk_uint_t) char_offset);
20140 return (duk_codepoint_t) cp;
20141}
20142#line 1 "duk_api_var.c"
20143/*
20144 * Variable access
20145 */
20146
20147/* include removed: duk_internal.h */
20148
20150 duk_hthread *thr = (duk_hthread *) ctx;
20151 duk_activation *act;
20152 duk_hstring *h_varname;
20153 duk_small_int_t throw_flag = 1; /* always throw ReferenceError for unresolvable */
20154
20156
20157 h_varname = duk_require_hstring(ctx, -1); /* XXX: tostring? */
20158 DUK_ASSERT(h_varname != NULL);
20159
20161 if (act) {
20162 (void) duk_js_getvar_activation(thr, act, h_varname, throw_flag); /* -> [ ... varname val this ] */
20163 } else {
DUK_EXTERNAL void duk_get_var(duk_context *ctx)

◆ duk_handle_call_protected()

DUK_INTERNAL_DECL duk_int_t duk_handle_call_protected ( duk_hthread * thr,
duk_idx_t num_stack_args,
duk_small_uint_t call_flags )

Definition at line 55950 of file duktape-1.8.0/src/duktape.c.

55953 :
55954 *
55955 * [ retval ] (DUK_EXEC_SUCCESS)
55956 * [ errobj ] (DUK_EXEC_ERROR (normal error), protected call)
55957 *
55958 * Even when executing a protected call an error may be thrown in rare cases
55959 * such as an insane num_stack_args argument. If there is no catchpoint for
55960 * such errors, the fatal error handler is called.
55961 *
55962 * The error handling path should be error free, even for out-of-memory
55963 * errors, to ensure safe sandboxing. (As of Duktape 1.4.0 this is not
55964 * yet the case, see XXX notes below.)
55965 */
55966
55968 duk_idx_t num_stack_args,
55969 duk_small_uint_t call_flags) {
55970 duk_context *ctx;
55971 duk_size_t entry_valstack_bottom_index;
55972 duk_size_t entry_valstack_end;
55973 duk_size_t entry_callstack_top;
55974 duk_size_t entry_catchstack_top;
55975 duk_int_t entry_call_recursion_depth;
55976 duk_hthread *entry_curr_thread;
55977 duk_uint_fast8_t entry_thread_state;
55978 duk_instr_t **entry_ptr_curr_pc;
55979 duk_jmpbuf *old_jmpbuf_ptr = NULL;
55980 duk_jmpbuf our_jmpbuf;
55981 duk_idx_t idx_func; /* valstack index of 'func' and retval (relative to entry valstack_bottom) */
55982
55983 /* XXX: Multiple tv_func lookups are now avoided by making a local
55984 * copy of tv_func. Another approach would be to compute an offset
55985 * for tv_func from valstack bottom and recomputing the tv_func
55986 * pointer quickly as valstack + offset instead of calling duk_get_tval().
55987 */
55988
55989 ctx = (duk_context *) thr;
55990 DUK_UNREF(ctx);
55991 DUK_ASSERT(thr != NULL);
55993 DUK_ASSERT(num_stack_args >= 0);
55994 /* XXX: currently NULL allocations are not supported; remove if later allowed */
55995 DUK_ASSERT(thr->valstack != NULL);
55996 DUK_ASSERT(thr->callstack != NULL);
55997 DUK_ASSERT(thr->catchstack != NULL);
55998
55999 /* Argument validation and func/args offset. */
56000 idx_func = duk__get_idx_func(thr, num_stack_args);
56001
56002 /* Preliminaries, required by setjmp() handler. Must be careful not
56003 * to throw an unintended error here.
56004 */
56005
56006 entry_valstack_bottom_index = (duk_size_t) (thr->valstack_bottom - thr->valstack);
56007#if defined(DUK_USE_PREFER_SIZE)
56008 entry_valstack_end = (duk_size_t) (thr->valstack_end - thr->valstack);
56009#else
56010 DUK_ASSERT((duk_size_t) (thr->valstack_end - thr->valstack) == thr->valstack_size);
56011 entry_valstack_end = thr->valstack_size;
56012#endif
56013 entry_callstack_top = thr->callstack_top;
56014 entry_catchstack_top = thr->catchstack_top;
56015 entry_call_recursion_depth = thr->heap->call_recursion_depth;
56016 entry_curr_thread = thr->heap->curr_thread; /* Note: may be NULL if first call */
56017 entry_thread_state = thr->state;
56018 entry_ptr_curr_pc = thr->ptr_curr_pc; /* may be NULL */
56019
56020 DUK_DD(DUK_DDPRINT("duk_handle_call_protected: thr=%p, num_stack_args=%ld, "
56021 "call_flags=0x%08lx (ignorerec=%ld, constructor=%ld), "
56022 "valstack_top=%ld, idx_func=%ld, idx_args=%ld, rec_depth=%ld/%ld, "
56023 "entry_valstack_bottom_index=%ld, entry_callstack_top=%ld, entry_catchstack_top=%ld, "
56024 "entry_call_recursion_depth=%ld, entry_curr_thread=%p, entry_thread_state=%ld",
56025 (void *) thr,
56026 (long) num_stack_args,
56027 (unsigned long) call_flags,
56028 (long) ((call_flags & DUK_CALL_FLAG_IGNORE_RECLIMIT) != 0 ? 1 : 0),
56029 (long) ((call_flags & DUK_CALL_FLAG_CONSTRUCTOR_CALL) != 0 ? 1 : 0),
56030 (long) duk_get_top(ctx),
56031 (long) idx_func,
56032 (long) (idx_func + 2),
56033 (long) thr->heap->call_recursion_depth,
56034 (long) thr->heap->call_recursion_limit,
56035 (long) entry_valstack_bottom_index,
56036 (long) entry_callstack_top,
56037 (long) entry_catchstack_top,
56038 (long) entry_call_recursion_depth,
56039 (void *) entry_curr_thread,
56040 (long) entry_thread_state));
56041
56042 old_jmpbuf_ptr = thr->heap->lj.jmpbuf_ptr;
56043 thr->heap->lj.jmpbuf_ptr = &our_jmpbuf;
56044
56045#if defined(DUK_USE_CPP_EXCEPTIONS)
56046 try {
56047#else
56048 DUK_ASSERT(thr->heap->lj.jmpbuf_ptr == &our_jmpbuf);
56049 if (DUK_SETJMP(our_jmpbuf.jb) == 0) {
56050#endif
56051 /* Call handling and success path. Success path exit cleans
56052 * up almost all state.
56053 */
56054 duk__handle_call_inner(thr, num_stack_args, call_flags, idx_func);
56055
56056 /* Success path handles */
56057 DUK_ASSERT(thr->heap->call_recursion_depth == entry_call_recursion_depth);
56058 DUK_ASSERT(thr->ptr_curr_pc == entry_ptr_curr_pc);
56059
56060 /* Longjmp state is kept clean in success path */
56061 DUK_ASSERT(thr->heap->lj.type == DUK_LJ_TYPE_UNKNOWN);
56062 DUK_ASSERT(thr->heap->lj.iserror == 0);
56063 DUK_ASSERT(DUK_TVAL_IS_UNDEFINED(&thr->heap->lj.value1));
56064 DUK_ASSERT(DUK_TVAL_IS_UNDEFINED(&thr->heap->lj.value2));
56065
56066 thr->heap->lj.jmpbuf_ptr = old_jmpbuf_ptr;
56067
56068 return DUK_EXEC_SUCCESS;
56069#if defined(DUK_USE_CPP_EXCEPTIONS)
56070 } catch (duk_internal_exception &exc) {
56071#else
56072 } else {
56073#endif
56074 /* Error; error value is in heap->lj.value1. */
56075
56076#if defined(DUK_USE_CPP_EXCEPTIONS)
56077 DUK_UNREF(exc);
56078#endif
56079
56081 entry_valstack_bottom_index,
56082 entry_valstack_end,
56083 entry_catchstack_top,
56084 entry_callstack_top,
56085 entry_call_recursion_depth,
56086 entry_curr_thread,
56087 entry_thread_state,
56088 entry_ptr_curr_pc,
56089 idx_func,
56090 old_jmpbuf_ptr);
56091
56092 /* Longjmp state is cleaned up by error handling */
56093 DUK_ASSERT(thr->heap->lj.type == DUK_LJ_TYPE_UNKNOWN);
56094 DUK_ASSERT(thr->heap->lj.iserror == 0);
56095 DUK_ASSERT(DUK_TVAL_IS_UNDEFINED(&thr->heap->lj.value1));
56096 DUK_ASSERT(DUK_TVAL_IS_UNDEFINED(&thr->heap->lj.value2));
56097 return DUK_EXEC_ERROR;
56098 }
56099#if defined(DUK_USE_CPP_EXCEPTIONS)
56100 catch (std::exception &exc) {
56101 const char *what = exc.what();
56102 if (!what) {
56103 what = "unknown";
56104 }
56105 DUK_D(DUK_DPRINT("unexpected c++ std::exception (perhaps thrown by user code)"));
56106 try {
56107 DUK_ERROR_FMT1(thr, DUK_ERR_API_ERROR, "caught invalid c++ std::exception '%s' (perhaps thrown by user code)", what);
56108 } catch (duk_internal_exception exc) {
56109 DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ std::exception"));
56110 DUK_UNREF(exc);
56112 entry_valstack_bottom_index,
56113 entry_valstack_end,
56114 entry_catchstack_top,
56115 entry_callstack_top,
56116 entry_call_recursion_depth,
56117 entry_curr_thread,
56118 entry_thread_state,
56119 entry_ptr_curr_pc,
56120 idx_func,
56121 old_jmpbuf_ptr);
56122 return DUK_EXEC_ERROR;
56123 }
56124 } catch (...) {
56125 DUK_D(DUK_DPRINT("unexpected c++ exception (perhaps thrown by user code)"));
56126 try {
56127 DUK_ERROR_API(thr, "caught invalid c++ exception (perhaps thrown by user code)");
56128 } catch (duk_internal_exception exc) {
56129 DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ exception"));

References duk_heap::call_recursion_depth, duk_heap::call_recursion_limit, duk_hthread::callstack, duk_hthread::callstack_top, duk_hthread::catchstack, duk_hthread::catchstack_top, duk_heap::curr_thread, duk__get_idx_func(), duk__handle_call_error(), duk__handle_call_inner(), DUK_ASSERT, DUK_ASSERT_CTX_VALID, DUK_CALL_FLAG_CONSTRUCTOR_CALL, DUK_CALL_FLAG_IGNORE_RECLIMIT, DUK_D, DUK_DD, DUK_DDPRINT, DUK_DPRINT, DUK_ERR_API_ERROR, DUK_ERROR_API, DUK_ERROR_FMT1, DUK_EXEC_ERROR, DUK_EXEC_SUCCESS, duk_get_top(), DUK_LJ_TYPE_UNKNOWN, DUK_SETJMP, DUK_TVAL_IS_UNDEFINED, DUK_UNREF, duk_hthread::heap, duk_ljstate::iserror, duk_jmpbuf::jb, duk_ljstate::jmpbuf_ptr, duk_heap::lj, NULL, duk_hthread::ptr_curr_pc, duk_hthread::state, duk_ljstate::type, duk_hthread::valstack, duk_hthread::valstack_bottom, duk_hthread::valstack_end, duk_hthread::valstack_size, duk_ljstate::value1, and duk_ljstate::value2.

◆ duk_handle_call_unprotected()

DUK_INTERNAL_DECL void duk_handle_call_unprotected ( duk_hthread * thr,
duk_idx_t num_stack_args,
duk_small_uint_t call_flags )

Definition at line 56131 of file duktape-1.8.0/src/duktape.c.

◆ duk_handle_ecma_call_setup()

DUK_INTERNAL_DECL duk_bool_t duk_handle_ecma_call_setup ( duk_hthread * thr,
duk_idx_t num_stack_args,
duk_small_uint_t call_flags )

Definition at line 57276 of file duktape-1.8.0/src/duktape.c.

57295 {
57296 duk_context *ctx = (duk_context *) thr;
57297 duk_size_t entry_valstack_bottom_index;
57298 duk_idx_t idx_func; /* valstack index of 'func' and retval (relative to entry valstack_bottom) */
57299 duk_idx_t idx_args; /* valstack index of start of args (arg1) (relative to entry valstack_bottom) */
57300 duk_idx_t nargs; /* # argument registers target function wants (< 0 => never for ecma calls) */
57301 duk_idx_t nregs; /* # total registers target function wants on entry (< 0 => never for ecma calls) */
57302 duk_hobject *func; /* 'func' on stack (borrowed reference) */
57303 duk_tval *tv_func; /* duk_tval ptr for 'func' on stack (borrowed reference) */
57304 duk_activation *act;
57305 duk_hobject *env;
57306 duk_bool_t use_tailcall;
57307 duk_instr_t **entry_ptr_curr_pc;
57308
57309 DUK_ASSERT(thr != NULL);
57310 DUK_ASSERT(ctx != NULL);
57311 DUK_ASSERT(!((call_flags & DUK_CALL_FLAG_IS_RESUME) != 0 && (call_flags & DUK_CALL_FLAG_IS_TAILCALL) != 0));
57312
57313 /* XXX: assume these? */
57314 DUK_ASSERT(thr->valstack != NULL);
57315 DUK_ASSERT(thr->callstack != NULL);
57316 DUK_ASSERT(thr->catchstack != NULL);
57317
57318 /* no need to handle thread state book-keeping here */
57319 DUK_ASSERT((call_flags & DUK_CALL_FLAG_IS_RESUME) != 0 ||
57321 thr->heap->curr_thread == thr));
57322
57323 /* If thr->ptr_curr_pc is set, sync curr_pc to act->pc. Then NULL
57324 * thr->ptr_curr_pc so that it's not accidentally used with an incorrect
57325 * activation when side effects occur. If we end up not making the
57326 * call we must restore the value.
57327 */
57328 entry_ptr_curr_pc = thr->ptr_curr_pc;
57330
57331 /* if a tail call:
57332 * - an Ecmascript activation must be on top of the callstack
57333 * - there cannot be any active catchstack entries
57334 */
57335#if defined(DUK_USE_ASSERTIONS)
57336 if (call_flags & DUK_CALL_FLAG_IS_TAILCALL) {
57337 duk_size_t our_callstack_index;
57338 duk_size_t i;
57339
57340 DUK_ASSERT(thr->callstack_top >= 1);
57341 our_callstack_index = thr->callstack_top - 1;
57342 DUK_ASSERT_DISABLE(our_callstack_index >= 0);
57343 DUK_ASSERT(our_callstack_index < thr->callstack_size);
57344 DUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack + our_callstack_index) != NULL);
57346
57347 /* No entry in the catchstack which would actually catch a
57348 * throw can refer to the callstack entry being reused.
57349 * There *can* be catchstack entries referring to the current
57350 * callstack entry as long as they don't catch (e.g. label sites).
57351 */
57352
57353 for (i = 0; i < thr->catchstack_top; i++) {
57354 DUK_ASSERT(thr->catchstack[i].callstack_index < our_callstack_index || /* refer to callstack entries below current */
57355 DUK_CAT_GET_TYPE(thr->catchstack + i) == DUK_CAT_TYPE_LABEL); /* or a non-catching entry */
57356 }
57357 }
57358#endif /* DUK_USE_ASSERTIONS */
57359
57360 entry_valstack_bottom_index = (duk_size_t) (thr->valstack_bottom - thr->valstack);
57361 /* XXX: rework */
57362 idx_func = duk_normalize_index(thr, -num_stack_args - 2);
57363 idx_args = idx_func + 2;
57364
57365 DUK_DD(DUK_DDPRINT("handle_ecma_call_setup: thr=%p, "
57366 "num_stack_args=%ld, call_flags=0x%08lx (resume=%ld, tailcall=%ld), "
57367 "idx_func=%ld, idx_args=%ld, entry_valstack_bottom_index=%ld",
57368 (void *) thr,
57369 (long) num_stack_args,
57370 (unsigned long) call_flags,
57371 (long) ((call_flags & DUK_CALL_FLAG_IS_RESUME) != 0 ? 1 : 0),
57372 (long) ((call_flags & DUK_CALL_FLAG_IS_TAILCALL) != 0 ? 1 : 0),
57373 (long) idx_func,
57374 (long) idx_args,
57375 (long) entry_valstack_bottom_index));
57376
57377 if (DUK_UNLIKELY(idx_func < 0 || idx_args < 0)) {
57378 /* XXX: assert? compiler is responsible for this never happening */
57380 }
57381
57382 /*
57383 * Check the function type, handle bound function chains, and prepare
57384 * parameters for the rest of the call handling. Also figure out the
57385 * effective 'this' binding, which replaces the current value at
57386 * idx_func + 1.
57387 *
57388 * If the target function is a 'bound' one, follow the chain of 'bound'
57389 * functions until a non-bound function is found. During this process,
57390 * bound arguments are 'prepended' to existing ones, and the "this"
57391 * binding is overridden. See E5 Section 15.3.4.5.1.
57392 *
57393 * If the final target function cannot be handled by an ecma-to-ecma
57394 * call, return to the caller with a return value indicating this case.
57395 * The bound chain is resolved and the caller can resume with a plain
57396 * function call.
57397 */
57398
57399 func = duk__nonbound_func_lookup(ctx, idx_func, &num_stack_args, &tv_func, call_flags);
57400 if (func == NULL || !DUK_HOBJECT_IS_COMPILEDFUNCTION(func)) {
57401 DUK_DDD(DUK_DDDPRINT("final target is a lightfunc/nativefunc, cannot do ecma-to-ecma call"));
57402 thr->ptr_curr_pc = entry_ptr_curr_pc;
57403 return 0;
57404 }
57405 /* XXX: tv_func is not actually needed */
57406
57407 DUK_ASSERT(func != NULL);
57410
57411 duk__coerce_effective_this_binding(thr, func, idx_func + 1);
57412 DUK_DDD(DUK_DDDPRINT("effective 'this' binding is: %!T",
57413 duk_get_tval(ctx, idx_func + 1)));
57414
57415 nargs = ((duk_hcompiledfunction *) func)->nargs;
57416 nregs = ((duk_hcompiledfunction *) func)->nregs;
57417 DUK_ASSERT(nregs >= nargs);
57418
57419 /* [ ... func this arg1 ... argN ] */
57420
57421 /*
57422 * Preliminary activation record and valstack manipulation.
57423 * The concrete actions depend on whether the we're dealing
57424 * with a tail call (reuse an existing activation), a resume,
57425 * or a normal call.
57426 *
57427 * The basic actions, in varying order, are:
57428 *
57429 * - Check stack size for call handling
57430 * - Grow call stack if necessary (non-tail-calls)
57431 * - Update current activation (idx_retval) if necessary
57432 * (non-tail, non-resume calls)
57433 * - Move start of args (idx_args) to valstack bottom
57434 * (tail calls)
57435 *
57436 * Don't touch valstack_bottom or valstack_top yet so that Duktape API
57437 * calls work normally.
57438 */
57439
57440 /* XXX: some overlapping code; cleanup */
57441 use_tailcall = call_flags & DUK_CALL_FLAG_IS_TAILCALL;
57442#if !defined(DUK_USE_TAILCALL)
57443 DUK_ASSERT(use_tailcall == 0); /* compiler ensures this */
57444#endif
57445 if (use_tailcall) {
57446 /* tailcall cannot be flagged to resume calls, and a
57447 * previous frame must exist
57448 */
57449 DUK_ASSERT(thr->callstack_top >= 1);
57450 DUK_ASSERT((call_flags & DUK_CALL_FLAG_IS_RESUME) == 0);
57451
57452 act = thr->callstack + thr->callstack_top - 1;
57453 if (act->flags & DUK_ACT_FLAG_PREVENT_YIELD) {
57454 /* See: test-bug-tailcall-preventyield-assert.c. */
57455 DUK_DDD(DUK_DDDPRINT("tail call prevented by current activation having DUK_ACT_FLAG_PREVENTYIELD"));
57456 use_tailcall = 0;
57457 } else if (DUK_HOBJECT_HAS_NOTAIL(func)) {
57458 DUK_D(DUK_DPRINT("tail call prevented by function having a notail flag"));
57459 use_tailcall = 0;
57460 }
57461 }
57462
57463 if (use_tailcall) {
57464 duk_tval *tv1, *tv2;
57465 duk_size_t cs_index;
57466 duk_int_t i_stk; /* must be signed for loop structure */
57467 duk_idx_t i_arg;
57468
57469 /*
57470 * Tailcall handling
57471 *
57472 * Although the callstack entry is reused, we need to explicitly unwind
57473 * the current activation (or simulate an unwind). In particular, the
57474 * current activation must be closed, otherwise something like
57475 * test-bug-reduce-judofyr.js results. Also catchstack needs be unwound
57476 * because there may be non-error-catching label entries in valid tail calls.
57477 */
57478
57479 DUK_DDD(DUK_DDDPRINT("is tail call, reusing activation at callstack top, at index %ld",
57480 (long) (thr->callstack_top - 1)));
57481
57482 /* 'act' already set above */
57483
57488
57489 /* Unwind catchstack entries referring to the callstack entry we're reusing */
57490 cs_index = thr->callstack_top - 1;
57491 DUK_ASSERT(thr->catchstack_top <= DUK_INT_MAX); /* catchstack limits */
57492 for (i_stk = (duk_int_t) (thr->catchstack_top - 1); i_stk >= 0; i_stk--) {
57493 duk_catcher *cat = thr->catchstack + i_stk;
57494 if (cat->callstack_index != cs_index) {
57495 /* 'i' is the first entry we'll keep */
57496 break;
57497 }
57498 }
57499 duk_hthread_catchstack_unwind(thr, i_stk + 1);
57500
57501 /* Unwind the topmost callstack entry before reusing it */
57502 DUK_ASSERT(thr->callstack_top > 0);
57503 duk_hthread_callstack_unwind(thr, thr->callstack_top - 1);
57504
57505 /* Then reuse the unwound activation; callstack was not shrunk so there is always space */
57506 thr->callstack_top++;
57507 DUK_ASSERT(thr->callstack_top <= thr->callstack_size);
57508 act = thr->callstack + thr->callstack_top - 1;
57509
57510 /* Start filling in the activation */
57511 act->func = func; /* don't want an intermediate exposed state with func == NULL */
57512#if defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)
57513 act->prev_caller = NULL;
57514#endif
57515 DUK_ASSERT(func != NULL);
57517 /* don't want an intermediate exposed state with invalid pc */
57519#if defined(DUK_USE_DEBUGGER_SUPPORT)
57520 act->prev_line = 0;
57521#endif
57522 DUK_TVAL_SET_OBJECT(&act->tv_func, func); /* borrowed, no refcount */
57523#if defined(DUK_USE_REFERENCE_COUNTING)
57524 DUK_HOBJECT_INCREF(thr, func);
57525 act = thr->callstack + thr->callstack_top - 1; /* side effects (currently none though) */
57526#endif
57527
57528#if defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)
57529#if defined(DUK_USE_TAILCALL)
57530#error incorrect options: tail calls enabled with function caller property
57531#endif
57532 /* XXX: this doesn't actually work properly for tail calls, so
57533 * tail calls are disabled when DUK_USE_NONSTD_FUNC_CALLER_PROPERTY
57534 * is in use.
57535 */
57536 duk__update_func_caller_prop(thr, func);
57537 act = thr->callstack + thr->callstack_top - 1;
57538#endif
57539
57540 act->flags = (DUK_HOBJECT_HAS_STRICT(func) ?
57543
57544 DUK_ASSERT(DUK_ACT_GET_FUNC(act) == func); /* already updated */
57545 DUK_ASSERT(act->var_env == NULL); /* already NULLed (by unwind) */
57546 DUK_ASSERT(act->lex_env == NULL); /* already NULLed (by unwind) */
57547 act->idx_bottom = entry_valstack_bottom_index; /* tail call -> reuse current "frame" */
57548 DUK_ASSERT(nregs >= 0);
57549#if 0 /* topmost activation idx_retval is considered garbage, no need to init */
57550 act->idx_retval = 0;
57551#endif
57552
57553 /*
57554 * Manipulate valstack so that args are on the current bottom and the
57555 * previous caller's 'this' binding (which is the value preceding the
57556 * current bottom) is replaced with the new 'this' binding:
57557 *
57558 * [ ... this_old | (crud) func this_new arg1 ... argN ]
57559 * --> [ ... this_new | arg1 ... argN ]
57560 *
57561 * For tail calling to work properly, the valstack bottom must not grow
57562 * here; otherwise crud would accumulate on the valstack.
57563 */
57564
57565 tv1 = thr->valstack_bottom - 1;
57566 tv2 = thr->valstack_bottom + idx_func + 1;
57567 DUK_ASSERT(tv1 >= thr->valstack && tv1 < thr->valstack_top); /* tv1 is -below- valstack_bottom */
57568 DUK_ASSERT(tv2 >= thr->valstack_bottom && tv2 < thr->valstack_top);
57569 DUK_TVAL_SET_TVAL_UPDREF(thr, tv1, tv2); /* side effects */
57570
57571 for (i_arg = 0; i_arg < idx_args; i_arg++) {
57572 /* XXX: block removal API primitive */
57573 /* Note: 'func' is popped from valstack here, but it is
57574 * already reachable from the activation.
57575 */
57576 duk_remove(ctx, 0);
57577 }
57578 idx_func = 0; DUK_UNREF(idx_func); /* really 'not applicable' anymore, should not be referenced after this */
57579 idx_args = 0;
57580
57581 /* [ ... this_new | arg1 ... argN ] */
57582 } else {
57583 DUK_DDD(DUK_DDDPRINT("not a tail call, pushing a new activation to callstack, to index %ld",
57584 (long) (thr->callstack_top)));
57585
57587
57588 if (call_flags & DUK_CALL_FLAG_IS_RESUME) {
57589 DUK_DDD(DUK_DDDPRINT("is resume -> no update to current activation (may not even exist)"));
57590 } else {
57591 DUK_DDD(DUK_DDDPRINT("update to current activation idx_retval"));
57592 DUK_ASSERT(thr->callstack_top < thr->callstack_size);
57593 DUK_ASSERT(thr->callstack_top >= 1);
57594 act = thr->callstack + thr->callstack_top - 1;
57597 act->idx_retval = entry_valstack_bottom_index + idx_func;
57598 }
57599
57600 DUK_ASSERT(thr->callstack_top < thr->callstack_size);
57601 act = thr->callstack + thr->callstack_top;
57602 thr->callstack_top++;
57603 DUK_ASSERT(thr->callstack_top <= thr->callstack_size);
57604
57608
57609 act->flags = (DUK_HOBJECT_HAS_STRICT(func) ?
57611 0);
57612 act->func = func;
57613 act->var_env = NULL;
57614 act->lex_env = NULL;
57615#if defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)
57616 act->prev_caller = NULL;
57617#endif
57618 DUK_ASSERT(func != NULL);
57621#if defined(DUK_USE_DEBUGGER_SUPPORT)
57622 act->prev_line = 0;
57623#endif
57624 act->idx_bottom = entry_valstack_bottom_index + idx_args;
57625 DUK_ASSERT(nregs >= 0);
57626#if 0 /* topmost activation idx_retval is considered garbage, no need to init */
57627 act->idx_retval = 0;
57628#endif
57629 DUK_TVAL_SET_OBJECT(&act->tv_func, func); /* borrowed, no refcount */
57630
57631 DUK_HOBJECT_INCREF(thr, func); /* act->func */
57632
57633#if defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)
57634 duk__update_func_caller_prop(thr, func);
57635 act = thr->callstack + thr->callstack_top - 1;
57636#endif
57637 }
57638
57639 /* [ ... func this arg1 ... argN ] (not tail call)
57640 * [ this | arg1 ... argN ] (tail call)
57641 *
57642 * idx_args updated to match
57643 */
57644
57645 /*
57646 * Environment record creation and 'arguments' object creation.
57647 * Named function expression name binding is handled by the
57648 * compiler; the compiled function's parent env will contain
57649 * the (immutable) binding already.
57650 *
57651 * Delayed creation (on demand) is handled in duk_js_var.c.
57652 */
57653
57654 /* XXX: unify handling with native call. */
57655
57656 DUK_ASSERT(!DUK_HOBJECT_HAS_BOUND(func)); /* bound function chain has already been resolved */
57657
57658 if (!DUK_HOBJECT_HAS_NEWENV(func)) {
57659 /* use existing env (e.g. for non-strict eval); cannot have
57660 * an own 'arguments' object (but can refer to the existing one)
57661 */
57662
57663 duk__handle_oldenv_for_call(thr, func, act);
57664 /* No need to re-lookup 'act' at present: no side effects. */
57665
57666 DUK_ASSERT(act->lex_env != NULL);
57667 DUK_ASSERT(act->var_env != NULL);
57668 goto env_done;
57669 }
57670
57672
57673 if (!DUK_HOBJECT_HAS_CREATEARGS(func)) {
57674 /* no need to create environment record now; leave as NULL */
57675 DUK_ASSERT(act->lex_env == NULL);
57676 DUK_ASSERT(act->var_env == NULL);
57677 goto env_done;
57678 }
57679
57680 /* third arg: absolute index (to entire valstack) of idx_bottom of new activation */
57682 DUK_ASSERT(env != NULL);
57683
57684 /* [ ... arg1 ... argN envobj ] */
57685
57686 /* original input stack before nargs/nregs handling must be
57687 * intact for 'arguments' object
57688 */
57690 duk__handle_createargs_for_call(thr, func, env, num_stack_args);
57691
57692 /* [ ... arg1 ... argN envobj ] */
57693
57694 act = thr->callstack + thr->callstack_top - 1;
57695 act->lex_env = env;
57696 act->var_env = env;
57697 DUK_HOBJECT_INCREF(thr, act->lex_env);
57698 DUK_HOBJECT_INCREF(thr, act->var_env);
57699 duk_pop(ctx);
57700
57701 env_done:
57702 /* [ ... arg1 ... argN ] */
57703
57704 /*
57705 * Setup value stack: clamp to 'nargs', fill up to 'nregs'
57706 */
57707
57709 num_stack_args,
57710 idx_args,
57711 nregs,
57712 nargs,
57713 func);
57714
DUK_EXTERNAL duk_idx_t duk_normalize_index(duk_context *ctx, duk_idx_t index)
#define DUK_HOBJECT_HAS_NOTAIL(h)

References duk_hthread::callstack, duk_catcher::callstack_index, duk_hthread::callstack_size, duk_hthread::callstack_top, duk_hthread::catchstack, duk_hthread::catchstack_top, duk_activation::curr_pc, duk_heap::curr_thread, duk__adjust_valstack_and_top(), duk__coerce_effective_this_binding(), duk__handle_createargs_for_call(), duk__handle_oldenv_for_call(), duk__nonbound_func_lookup(), DUK_ACT_FLAG_PREVENT_YIELD, DUK_ACT_FLAG_STRICT, DUK_ACT_FLAG_TAILCALLED, DUK_ACT_GET_FUNC, DUK_ASSERT, DUK_ASSERT_DISABLE, DUK_CALL_FLAG_IS_RESUME, DUK_CALL_FLAG_IS_TAILCALL, DUK_CAT_GET_TYPE, DUK_CAT_TYPE_LABEL, duk_create_activation_environment_record(), DUK_D, DUK_DD, DUK_DDD, DUK_DDDPRINT, DUK_DDPRINT, DUK_DPRINT, DUK_ERROR_API, duk_get_tval(), DUK_HCOMPILEDFUNCTION_GET_CODE_BASE, DUK_HOBJECT_HAS_BOUND, DUK_HOBJECT_HAS_COMPILEDFUNCTION, DUK_HOBJECT_HAS_CREATEARGS, DUK_HOBJECT_HAS_NATIVEFUNCTION, DUK_HOBJECT_HAS_NEWENV, DUK_HOBJECT_HAS_NOTAIL, DUK_HOBJECT_HAS_STRICT, DUK_HOBJECT_INCREF, DUK_HOBJECT_IS_COMPILEDFUNCTION, duk_hthread_callstack_grow(), duk_hthread_callstack_unwind(), duk_hthread_catchstack_unwind(), DUK_HTHREAD_STATE_RUNNING, duk_hthread_sync_and_null_currpc(), DUK_INT_MAX, duk_normalize_index(), duk_pop(), duk_remove(), DUK_STR_INVALID_CALL_ARGS, DUK_TVAL_SET_OBJECT, DUK_TVAL_SET_TVAL_UPDREF, DUK_UNLIKELY, DUK_UNREF, duk_activation::flags, duk_activation::func, duk_hthread::heap, duk_activation::idx_bottom, duk_activation::idx_retval, duk_activation::lex_env, NULL, duk_hthread::ptr_curr_pc, duk_hthread::state, duk_activation::tv_func, duk_hthread::valstack, duk_hthread::valstack_bottom, duk_hthread::valstack_end, duk_hthread::valstack_top, and duk_activation::var_env.

◆ duk_handle_safe_call()

DUK_INTERNAL_DECL duk_int_t duk_handle_safe_call ( duk_hthread * thr,
duk_safe_call_function func,
duk_idx_t num_stack_args,
duk_idx_t num_stack_res )

Definition at line 56858 of file duktape-1.8.0/src/duktape.c.

56878 {
56879 duk_context *ctx = (duk_context *) thr;
56880 duk_size_t entry_valstack_bottom_index;
56881 duk_size_t entry_callstack_top;
56882 duk_size_t entry_catchstack_top;
56883 duk_int_t entry_call_recursion_depth;
56884 duk_hthread *entry_curr_thread;
56885 duk_uint_fast8_t entry_thread_state;
56886 duk_instr_t **entry_ptr_curr_pc;
56887 duk_jmpbuf *old_jmpbuf_ptr = NULL;
56888 duk_jmpbuf our_jmpbuf;
56889 duk_idx_t idx_retbase;
56890 duk_int_t retval;
56891
56892 DUK_ASSERT(thr != NULL);
56893 DUK_ASSERT(ctx != NULL);
56894
56895 /* Note: careful with indices like '-x'; if 'x' is zero, it refers to bottom */
56896 entry_valstack_bottom_index = (duk_size_t) (thr->valstack_bottom - thr->valstack);
56897 entry_callstack_top = thr->callstack_top;
56898 entry_catchstack_top = thr->catchstack_top;
56899 entry_call_recursion_depth = thr->heap->call_recursion_depth;
56900 entry_curr_thread = thr->heap->curr_thread; /* Note: may be NULL if first call */
56901 entry_thread_state = thr->state;
56902 entry_ptr_curr_pc = thr->ptr_curr_pc; /* may be NULL */
56903 idx_retbase = duk_get_top(ctx) - num_stack_args; /* Note: not a valid stack index if num_stack_args == 0 */
56904
56905 /* Note: cannot portably debug print a function pointer, hence 'func' not printed! */
56906 DUK_DD(DUK_DDPRINT("duk_handle_safe_call: thr=%p, num_stack_args=%ld, num_stack_rets=%ld, "
56907 "valstack_top=%ld, idx_retbase=%ld, rec_depth=%ld/%ld, "
56908 "entry_valstack_bottom_index=%ld, entry_callstack_top=%ld, entry_catchstack_top=%ld, "
56909 "entry_call_recursion_depth=%ld, entry_curr_thread=%p, entry_thread_state=%ld",
56910 (void *) thr,
56911 (long) num_stack_args,
56912 (long) num_stack_rets,
56913 (long) duk_get_top(ctx),
56914 (long) idx_retbase,
56915 (long) thr->heap->call_recursion_depth,
56916 (long) thr->heap->call_recursion_limit,
56917 (long) entry_valstack_bottom_index,
56918 (long) entry_callstack_top,
56919 (long) entry_catchstack_top,
56920 (long) entry_call_recursion_depth,
56921 (void *) entry_curr_thread,
56922 (long) entry_thread_state));
56923
56924 if (idx_retbase < 0) {
56925 /* Since stack indices are not reliable, we can't do anything useful
56926 * here. Invoke the existing setjmp catcher, or if it doesn't exist,
56927 * call the fatal error handler.
56928 */
56929
56931 }
56932
56933 /* setjmp catchpoint setup */
56934
56935 old_jmpbuf_ptr = thr->heap->lj.jmpbuf_ptr;
56936 thr->heap->lj.jmpbuf_ptr = &our_jmpbuf;
56937
56938#if defined(DUK_USE_CPP_EXCEPTIONS)
56939 try {
56940#else
56941 DUK_ASSERT(thr->heap->lj.jmpbuf_ptr == &our_jmpbuf);
56942 if (DUK_SETJMP(our_jmpbuf.jb) == 0) {
56943 /* Success path. */
56944#endif
56945 DUK_DDD(DUK_DDDPRINT("safe_call setjmp catchpoint setup complete"));
56946
56948 func,
56949 idx_retbase,
56950 num_stack_rets,
56951 entry_valstack_bottom_index,
56952 entry_callstack_top,
56953 entry_catchstack_top);
56954
56955 /* Longjmp state is kept clean in success path */
56956 DUK_ASSERT(thr->heap->lj.type == DUK_LJ_TYPE_UNKNOWN);
56957 DUK_ASSERT(thr->heap->lj.iserror == 0);
56958 DUK_ASSERT(DUK_TVAL_IS_UNDEFINED(&thr->heap->lj.value1));
56959 DUK_ASSERT(DUK_TVAL_IS_UNDEFINED(&thr->heap->lj.value2));
56960
56961 /* Note: either pointer may be NULL (at entry), so don't assert */
56962 thr->heap->lj.jmpbuf_ptr = old_jmpbuf_ptr;
56963
56964 retval = DUK_EXEC_SUCCESS;
56965#if defined(DUK_USE_CPP_EXCEPTIONS)
56966 } catch (duk_internal_exception &exc) {
56967 DUK_UNREF(exc);
56968#else
56969 } else {
56970 /* Error path. */
56971#endif
56973 idx_retbase,
56974 num_stack_rets,
56975 entry_valstack_bottom_index,
56976 entry_callstack_top,
56977 entry_catchstack_top,
56978 old_jmpbuf_ptr);
56979
56980 /* Longjmp state is cleaned up by error handling */
56981 DUK_ASSERT(thr->heap->lj.type == DUK_LJ_TYPE_UNKNOWN);
56982 DUK_ASSERT(thr->heap->lj.iserror == 0);
56983 DUK_ASSERT(DUK_TVAL_IS_UNDEFINED(&thr->heap->lj.value1));
56984 DUK_ASSERT(DUK_TVAL_IS_UNDEFINED(&thr->heap->lj.value2));
56985
56986 retval = DUK_EXEC_ERROR;
56987 }
56988#if defined(DUK_USE_CPP_EXCEPTIONS)
56989 catch (std::exception &exc) {
56990 const char *what = exc.what();
56991 if (!what) {
56992 what = "unknown";
56993 }
56994 DUK_D(DUK_DPRINT("unexpected c++ std::exception (perhaps thrown by user code)"));
56995 try {
56996 DUK_ERROR_FMT1(thr, DUK_ERR_API_ERROR, "caught invalid c++ std::exception '%s' (perhaps thrown by user code)", what);
56997 } catch (duk_internal_exception exc) {
56998 DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ std::exception"));
56999 DUK_UNREF(exc);
57001 idx_retbase,
57002 num_stack_rets,
57003 entry_valstack_bottom_index,
57004 entry_callstack_top,
57005 entry_catchstack_top,
57006 old_jmpbuf_ptr);
57007 retval = DUK_EXEC_ERROR;
57008 }
57009 } catch (...) {
57010 DUK_D(DUK_DPRINT("unexpected c++ exception (perhaps thrown by user code)"));
57011 try {
57012 DUK_ERROR_API(thr, "caught invalid c++ exception (perhaps thrown by user code)");
57013 } catch (duk_internal_exception exc) {
57014 DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ exception"));
57015 DUK_UNREF(exc);
57017 idx_retbase,
57018 num_stack_rets,
57019 entry_valstack_bottom_index,
57020 entry_callstack_top,
57021 entry_catchstack_top,
57022 old_jmpbuf_ptr);
DUK_LOCAL void duk__handle_safe_call_inner(duk_hthread *thr, duk_safe_call_function func, duk_idx_t idx_retbase, duk_idx_t num_stack_rets, duk_size_t entry_valstack_bottom_index, duk_size_t entry_callstack_top, duk_size_t entry_catchstack_top)

◆ duk_has_prop()

DUK_EXTERNAL duk_bool_t duk_has_prop ( duk_context * ctx,
duk_idx_t obj_index )

Definition at line 14601 of file duktape-1.8.0/src/duktape.c.

14605 {
14606 duk_hthread *thr = (duk_hthread *) ctx;
14607
14609 DUK_ASSERT_DISABLE(stridx >= 0);
14611 DUK_UNREF(thr);
14612
14613 obj_index = duk_require_normalize_index(ctx, obj_index);
14614 duk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx));
14615 return duk_del_prop(ctx, obj_index);
14616}
14617
14619 duk_hthread *thr = (duk_hthread *) ctx;
14620 duk_tval *tv_obj;
14621 duk_tval *tv_key;

Referenced by duk__init_varmap_and_prologue_for_pass2(), and duk_has_prop_stridx().

◆ duk_has_prop_index()

DUK_EXTERNAL duk_bool_t duk_has_prop_index ( duk_context * ctx,
duk_idx_t obj_index,
duk_uarridx_t arr_index )

Definition at line 14632 of file duktape-1.8.0/src/duktape.c.

◆ duk_has_prop_stridx()

DUK_INTERNAL_DECL duk_bool_t duk_has_prop_stridx ( duk_context * ctx,
duk_idx_t obj_index,
duk_small_int_t stridx )

Definition at line 14640 of file duktape-1.8.0/src/duktape.c.

14640 {
14642 DUK_ASSERT(key != NULL);
14643
14644 obj_index = duk_require_normalize_index(ctx, obj_index);
14645 duk_push_string(ctx, key);
14646 return duk_has_prop(ctx, obj_index);
14647}
14648
14651

References DUK_ASSERT, DUK_ASSERT_CTX_VALID, duk_has_prop(), duk_push_string(), duk_require_normalize_index(), and NULL.

Referenced by duk__init_varmap_and_prologue_for_pass2().

◆ duk_has_prop_string()

DUK_EXTERNAL duk_bool_t duk_has_prop_string ( duk_context * ctx,
duk_idx_t obj_index,
const char * key )

Definition at line 14623 of file duktape-1.8.0/src/duktape.c.

◆ duk_has_var()

DUK_EXTERNAL duk_bool_t duk_has_var ( duk_context * ctx)

Definition at line 20206 of file duktape-1.8.0/src/duktape.c.

◆ duk_hbuffer_alloc()

DUK_INTERNAL_DECL duk_hbuffer * duk_hbuffer_alloc ( duk_heap * heap,
duk_size_t size,
duk_small_uint_t flags,
void ** out_bufdata )

Definition at line 40782 of file duktape-1.8.0/src/duktape.c.

40799 {
40800 duk_hbuffer *res = NULL;
40801 duk_size_t header_size;
40802 duk_size_t alloc_size;
40803
40804 DUK_ASSERT(heap != NULL);
40805 DUK_ASSERT(out_bufdata != NULL);
40806
40807 DUK_DDD(DUK_DDDPRINT("allocate hbuffer"));
40808
40809 /* Size sanity check. Should not be necessary because caller is
40810 * required to check this, but we don't want to cause a segfault
40811 * if the size wraps either in duk_size_t computation or when
40812 * storing the size in a 16-bit field.
40813 */
40814 if (size > DUK_HBUFFER_MAX_BYTELEN) {
40815 DUK_D(DUK_DPRINT("hbuffer alloc failed: size too large: %ld", (long) size));
40816 return NULL; /* no need to write 'out_bufdata' */
40817 }
40818
40819 if (flags & DUK_BUF_FLAG_EXTERNAL) {
40820 header_size = sizeof(duk_hbuffer_external);
40821 alloc_size = sizeof(duk_hbuffer_external);
40822 } else if (flags & DUK_BUF_FLAG_DYNAMIC) {
40823 header_size = sizeof(duk_hbuffer_dynamic);
40824 alloc_size = sizeof(duk_hbuffer_dynamic);
40825 } else {
40826 header_size = sizeof(duk_hbuffer_fixed);
40827 alloc_size = sizeof(duk_hbuffer_fixed) + size;
40828 DUK_ASSERT(alloc_size >= sizeof(duk_hbuffer_fixed)); /* no wrapping */
40829 }
40830
40831 res = (duk_hbuffer *) DUK_ALLOC(heap, alloc_size);
40832 if (!res) {
40833 goto error;
40834 }
40835
40836 /* zero everything unless requested not to do so */
40837#if defined(DUK_USE_ZERO_BUFFER_DATA)
40838 DUK_MEMZERO((void *) res,
40839 (flags & DUK_BUF_FLAG_NOZERO) ? header_size : alloc_size);
40840#else
40841 DUK_MEMZERO((void *) res, header_size);
40842#endif
40843
40844 if (flags & DUK_BUF_FLAG_EXTERNAL) {
40846 h = (duk_hbuffer_external *) res;
40847 DUK_UNREF(h);
40848 *out_bufdata = NULL;
40849#if defined(DUK_USE_EXPLICIT_NULL_INIT)
40850#if defined(DUK_USE_HEAPPTR16)
40851/* the compressed pointer is zeroed which maps to NULL, so nothing to do. */
40852#else
40854#endif
40855#endif
40857 } else if (flags & DUK_BUF_FLAG_DYNAMIC) {
40859 void *ptr;
40860
40861 if (size > 0) {
40862 DUK_ASSERT(!(flags & DUK_BUF_FLAG_EXTERNAL)); /* alloc external with size zero */
40863 DUK_DDD(DUK_DDDPRINT("dynamic buffer with nonzero size, alloc actual buffer"));
40864#ifdef DUK_USE_ZERO_BUFFER_DATA
40865 ptr = DUK_ALLOC_ZEROED(heap, size);
40866#else
40867 ptr = DUK_ALLOC(heap, size);
40868#endif
40869 if (!ptr) {
40870 /* Because size > 0, NULL check is correct */
40871 goto error;
40872 }
40873 *out_bufdata = ptr;
40874
40876 } else {
40877 *out_bufdata = NULL;
40878#if defined(DUK_USE_EXPLICIT_NULL_INIT)
40879#if defined(DUK_USE_HEAPPTR16)
40880/* the compressed pointer is zeroed which maps to NULL, so nothing to do. */
40881#else
40883#endif
40884#endif
40886 }
40887 } else {
40888 *out_bufdata = (void *) ((duk_hbuffer_fixed *) res + 1);
40889 }
40890
40891 DUK_HBUFFER_SET_SIZE(res, size);
40892
40894 if (flags & DUK_BUF_FLAG_DYNAMIC) {
#define DUK_BUF_FLAG_NOZERO
#define DUK_BUF_FLAG_DYNAMIC
#define DUK_BUF_FLAG_EXTERNAL
#define DUK_HBUFFER_EXTERNAL_GET_DATA_PTR(heap, x)
struct duk_hbuffer_dynamic duk_hbuffer_dynamic
#define DUK_HBUFFER_DYNAMIC_SET_DATA_PTR(heap, x, v)
struct duk_hbuffer_external duk_hbuffer_external
struct duk_hbuffer_fixed duk_hbuffer_fixed
#define DUK_ALLOC_ZEROED(heap, size)
#define DUK_HBUFFER_SET_SIZE(x, v)
#define DUK_HBUFFER_SET_DYNAMIC(x)

◆ duk_hbuffer_get_dynalloc_ptr()

DUK_INTERNAL_DECL void * duk_hbuffer_get_dynalloc_ptr ( duk_heap * heap,
void * ud )

Definition at line 40899 of file duktape-1.8.0/src/duktape.c.

40899 {
40901 }
40902 DUK_HEAP_INSERT_INTO_HEAP_ALLOCATED(heap, &res->hdr);
40903
#define DUK_HEAP_INSERT_INTO_HEAP_ALLOCATED(heap, hdr)

Referenced by duk_hbuffer_resize().

◆ duk_hbuffer_reset()

DUK_INTERNAL_DECL void duk_hbuffer_reset ( duk_hthread * thr,
duk_hbuffer_dynamic * buf )

Definition at line 40979 of file duktape-1.8.0/src/duktape.c.

40979 {
40980 DUK_ASSERT(new_size - prev_size > 0);
40981#ifdef DUK_USE_ZERO_BUFFER_DATA
40982 DUK_MEMZERO((void *) ((char *) res + prev_size),
40983 (duk_size_t) (new_size - prev_size));
40984#endif
40985 }
40986

References DUK_ASSERT, and DUK_MEMZERO.

◆ duk_hbuffer_resize()

DUK_INTERNAL_DECL void duk_hbuffer_resize ( duk_hthread * thr,
duk_hbuffer_dynamic * buf,
duk_size_t new_size )

Definition at line 40922 of file duktape-1.8.0/src/duktape.c.

40939 {
40940 void *res;
40941 duk_size_t prev_size;
40942
40943 DUK_ASSERT(thr != NULL);
40944 DUK_ASSERT(buf != NULL);
40947
40948 /*
40949 * Maximum size check
40950 */
40951
40952 if (new_size > DUK_HBUFFER_MAX_BYTELEN) {
40953 DUK_ERROR_RANGE(thr, "buffer too long");
40954 }
40955
40956 /*
40957 * Note: use indirect realloc variant just in case mark-and-sweep
40958 * (finalizers) might resize this same buffer during garbage
40959 * collection.
40960 */
40961
40962 res = DUK_REALLOC_INDIRECT(thr->heap, duk_hbuffer_get_dynalloc_ptr, (void *) buf, new_size);
40963 if (res != NULL || new_size == 0) {
40964 /* 'res' may be NULL if new allocation size is 0. */
40965
40966 DUK_DDD(DUK_DDDPRINT("resized dynamic buffer %p:%ld -> %p:%ld",
40967 (void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, buf),
40968 (long) DUK_HBUFFER_DYNAMIC_GET_SIZE(buf),
40969 (void *) res,
40970 (long) new_size));
40971
40972 /*
40973 * The entire allocated buffer area, regardless of actual used
40974 * size, is kept zeroed in resizes for simplicity. If the buffer
40975 * is grown, zero the new part.
40976 */
40977
DUK_INTERNAL_DECL void * duk_hbuffer_get_dynalloc_ptr(duk_heap *heap, void *ud)

References DUK_ASSERT, DUK_DDD, DUK_DDDPRINT, DUK_ERROR_RANGE, DUK_HBUFFER_DYNAMIC_GET_DATA_PTR, DUK_HBUFFER_DYNAMIC_GET_SIZE, duk_hbuffer_get_dynalloc_ptr(), DUK_HBUFFER_HAS_DYNAMIC, DUK_HBUFFER_HAS_EXTERNAL, DUK_HBUFFER_MAX_BYTELEN, DUK_REALLOC_INDIRECT, duk_hthread::heap, and NULL.

Referenced by duk__appendbuffer().

◆ duk_hbufferobject_alloc()

DUK_INTERNAL duk_hbufferobject * duk_hbufferobject_alloc ( duk_heap * heap,
duk_uint_t hobject_flags )

Definition at line 46299 of file duktape-1.8.0/src/duktape.c.

46302 {
46303 return NULL;
46304 }
46305 DUK_MEMZERO(res, sizeof(duk_hnativefunction));
46306
46307 duk__init_object_parts(heap, &res->obj, hobject_flags);
46308
46309#ifdef DUK_USE_EXPLICIT_NULL_INIT
46310 res->func = NULL;
46311#endif
46312
46313 return res;
46314}
46315
DUK_INTERNAL duk_hbufferobject * duk_hbufferobject_alloc(duk_heap *heap, duk_uint_t hobject_flags)
DUK_LOCAL void duk__init_object_parts(duk_heap *heap, duk_hobject *obj, duk_uint_t hobject_flags)

References NULL.

◆ duk_hbufferobject_clamp_bytelength()

DUK_INTERNAL_DECL duk_uint_t duk_hbufferobject_clamp_bytelength ( duk_hbufferobject * h_bufobj,
duk_uint_t len )

Definition at line 40991 of file duktape-1.8.0/src/duktape.c.

40996 {
40997 DUK_ASSERT(thr != NULL);
40998 DUK_ASSERT(buf != NULL);
41001
41002 duk_hbuffer_resize(thr, buf, 0);
41003}
41004/* include removed: duk_internal.h */
41005#line 2 "duk_hbufferobject_misc.c"
41006

◆ duk_hbufferobject_push_validated_read()

DUK_INTERNAL_DECL void duk_hbufferobject_push_validated_read ( duk_context * ctx,
duk_hbufferobject * h_bufobj,
duk_uint8_t * p,
duk_small_uint_t elem_size )

Definition at line 22121 of file duktape-1.8.0/src/duktape.c.

22138 {
22140
22141 DUK_MEMCPY((void *) du.uc, (const void *) p, (size_t) elem_size);
22142
22143 switch (h_bufobj->elem_type) {
22145#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
22147#endif
22148 duk_push_uint(ctx, (duk_uint_t) du.uc[0]);
22149 break;
22150#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
22151 /* These are not needed when only Duktape.Buffer is supported. */
22153 duk_push_int(ctx, (duk_int_t) (duk_int8_t) du.uc[0]);
22154 break;
22156 duk_push_uint(ctx, (duk_uint_t) du.us[0]);
22157 break;
22159 duk_push_int(ctx, (duk_int_t) (duk_int16_t) du.us[0]);
22160 break;

Referenced by duk__get_own_propdesc_raw(), and duk_bi_typedarray_set().

◆ duk_hbufferobject_validated_write()

DUK_INTERNAL_DECL void duk_hbufferobject_validated_write ( duk_context * ctx,
duk_hbufferobject * h_bufobj,
duk_uint8_t * p,
duk_small_uint_t elem_size )

Definition at line 22162 of file duktape-1.8.0/src/duktape.c.

22164 :
22165 duk_push_int(ctx, (duk_int_t) (duk_int32_t) du.ui[0]);
22166 break;
22168 duk_push_number(ctx, (duk_double_t) du.f[0]);
22169 break;
22171 duk_push_number(ctx, (duk_double_t) du.d);
22172 break;
22173#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
22174 default:
22176 }
22177}
22178
22179DUK_INTERNAL void duk_hbufferobject_validated_write(duk_context *ctx, duk_hbufferobject *h_bufobj, duk_uint8_t *p, duk_small_uint_t elem_size) {
22181
22182 /* NOTE! Caller must ensure that any side effects from the
22183 * coercions below are safe. If that cannot be guaranteed
22184 * (which is normally the case), caller must coerce the
22185 * argument using duk_to_number() before any pointer
22186 * validations; the result of duk_to_number() always coerces
22187 * without side effects here.
22188 */
22189
22190 switch (h_bufobj->elem_type) {
22192 du.uc[0] = (duk_uint8_t) duk_to_uint32(ctx, -1);
22193 break;
22194#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
22195 /* These are not needed when only Duktape.Buffer is supported. */
22197 du.uc[0] = (duk_uint8_t) duk_to_uint8clamped(ctx, -1);
22198 break;
22200 du.uc[0] = (duk_uint8_t) duk_to_int32(ctx, -1);
22201 break;
22203 du.us[0] = (duk_uint16_t) duk_to_uint32(ctx, -1);
22204 break;
22206 du.us[0] = (duk_uint16_t) duk_to_int32(ctx, -1);
22207 break;
22209 du.ui[0] = (duk_uint32_t) duk_to_uint32(ctx, -1);
DUK_INTERNAL_DECL duk_uint8_t duk_to_uint8clamped(duk_context *ctx, duk_idx_t index)

Referenced by duk_bi_typedarray_set(), and duk_hobject_putprop().

◆ duk_hcompiledfunction_alloc()

DUK_INTERNAL_DECL duk_hcompiledfunction * duk_hcompiledfunction_alloc ( duk_heap * heap,
duk_uint_t hobject_flags )

Definition at line 46257 of file duktape-1.8.0/src/duktape.c.

46264 {
46265 return NULL;
46266 }
46267 DUK_MEMZERO(res, sizeof(duk_hobject));
46268
46269 duk__init_object_parts(heap, res, hobject_flags);
46270
46271 return res;
46272}
46273
46276
46277 res = (duk_hcompiledfunction *) DUK_ALLOC(heap, sizeof(duk_hcompiledfunction));
46278 if (!res) {
46279 return NULL;
DUK_INTERNAL_DECL duk_hcompiledfunction * duk_hcompiledfunction_alloc(duk_heap *heap, duk_uint_t hobject_flags)

◆ duk_heap_alloc()

DUK_INTERNAL_DECL duk_heap * duk_heap_alloc ( duk_alloc_function alloc_func,
duk_realloc_function realloc_func,
duk_free_function free_func,
void * heap_udata,
duk_fatal_function fatal_func )

Definition at line 41739 of file duktape-1.8.0/src/duktape.c.

41739 : big"));
41740#else
41741 DUK_D(DUK_DPRINT("integer endianness: ???"));
41742#endif
41743#if defined(DUK_USE_DOUBLE_LE)
41744 DUK_D(DUK_DPRINT("IEEE double endianness: little"));
41745#elif defined(DUK_USE_DOUBLE_ME)
41746 DUK_D(DUK_DPRINT("IEEE double endianness: mixed"));
41747#elif defined(DUK_USE_DOUBLE_BE)
41748 DUK_D(DUK_DPRINT("IEEE double endianness: big"));
41749#else
41750 DUK_D(DUK_DPRINT("IEEE double endianness: ???"));
41751#endif
41752}
41753#endif /* DUK_USE_DEBUG */
41754
41755DUK_INTERNAL
41756duk_heap *duk_heap_alloc(duk_alloc_function alloc_func,
41757 duk_realloc_function realloc_func,
41758 duk_free_function free_func,
41759 void *heap_udata,
41760 duk_fatal_function fatal_func) {
41761 duk_heap *res = NULL;
41762
41763 /* Silence a few global unused warnings here. */
41764 DUK_UNREF(duk_str_unsupported);
41765
41766 DUK_D(DUK_DPRINT("allocate heap"));
41767
41768 /*
41769 * Debug dump type sizes
41770 */
41771
41772#if defined(DUK_USE_DEBUG)
41773 duk__dump_misc_options();
41774 duk__dump_type_sizes();
41775 duk__dump_type_limits();
41776#endif
41777
41778 /*
41779 * If selftests enabled, run them as early as possible
41780 */
41781#if defined(DUK_USE_SELF_TESTS)
41782 DUK_D(DUK_DPRINT("running self tests"));
41783 duk_selftest_run_tests();
41784 DUK_D(DUK_DPRINT("self tests passed"));
41785#endif
41786
41787 /*
41788 * Computed values (e.g. INFINITY)
41789 */
41790
41791#if defined(DUK_USE_COMPUTED_NAN)
41792 do {
41793 /* Workaround for some exotic platforms where NAN is missing
41794 * and the expression (0.0 / 0.0) does NOT result in a NaN.
41795 * Such platforms use the global 'duk_computed_nan' which must
41796 * be initialized at runtime. Use 'volatile' to ensure that
41797 * the compiler will actually do the computation and not try
41798 * to do constant folding which might result in the original
41799 * problem.
41800 */
41801 volatile double dbl1 = 0.0;
41802 volatile double dbl2 = 0.0;
41803 duk_computed_nan = dbl1 / dbl2;
41804 } while (0);
41805#endif
41806
41807#if defined(DUK_USE_COMPUTED_INFINITY)
41808 do {
41809 /* Similar workaround for INFINITY. */
41810 volatile double dbl1 = 1.0;
41811 volatile double dbl2 = 0.0;
41812 duk_computed_infinity = dbl1 / dbl2;
41813 } while (0);
41814#endif
41815
41816 /*
41817 * Allocate heap struct
41818 *
41819 * Use a raw call, all macros expect the heap to be initialized
41820 */
41821
41822 res = (duk_heap *) alloc_func(heap_udata, sizeof(duk_heap));
41823 if (!res) {
41824 goto error;
41825 }
41826
41827 /*
41828 * Zero the struct, and start initializing roughly in order
41829 */
41830
41831 DUK_MEMZERO(res, sizeof(*res));
41832
41833 /* explicit NULL inits */
41834#if defined(DUK_USE_EXPLICIT_NULL_INIT)
41835 res->heap_udata = NULL;
41836 res->heap_allocated = NULL;
41837#if defined(DUK_USE_REFERENCE_COUNTING)
41838 res->refzero_list = NULL;
41839 res->refzero_list_tail = NULL;
41840#endif
41841#if defined(DUK_USE_MARK_AND_SWEEP)
41842 res->finalize_list = NULL;
41843#endif
41844 res->heap_thread = NULL;
41845 res->curr_thread = NULL;
41846 res->heap_object = NULL;
41847#if defined(DUK_USE_STRTAB_CHAIN)
41848 /* nothing to NULL */
41849#elif defined(DUK_USE_STRTAB_PROBE)
41850#if defined(DUK_USE_HEAPPTR16)
41851 res->strtable16 = (duk_uint16_t *) NULL;
41852#else
41853 res->strtable = (duk_hstring **) NULL;
41854#endif
41855#endif
41856#if defined(DUK_USE_ROM_STRINGS)
41857 /* no res->strs[] */
41858#else /* DUK_USE_ROM_STRINGS */
41859#if defined(DUK_USE_HEAPPTR16)
41860 /* res->strs16[] is zeroed and zero decodes to NULL, so no NULL inits. */
41861#else
41862 {
41863 duk_small_uint_t i;
41864 for (i = 0; i < DUK_HEAP_NUM_STRINGS; i++) {
41865 res->strs[i] = NULL;
41866 }
41867 }
41868#endif
41869#endif /* DUK_USE_ROM_STRINGS */
41870#if defined(DUK_USE_DEBUGGER_SUPPORT)
41871 res->dbg_read_cb = NULL;
41872 res->dbg_write_cb = NULL;
41873 res->dbg_peek_cb = NULL;
41874 res->dbg_read_flush_cb = NULL;
41875 res->dbg_write_flush_cb = NULL;
41876 res->dbg_request_cb = NULL;
41877 res->dbg_udata = NULL;
41878 res->dbg_step_thread = NULL;
41879#endif
41880#endif /* DUK_USE_EXPLICIT_NULL_INIT */
41881
41882 res->alloc_func = alloc_func;
41883 res->realloc_func = realloc_func;
41884 res->free_func = free_func;
41885 res->heap_udata = heap_udata;
41886 res->fatal_func = fatal_func;
41887
41888#if defined(DUK_USE_HEAPPTR16)
41889 /* XXX: zero assumption */
41890 res->heapptr_null16 = DUK_USE_HEAPPTR_ENC16(res->heap_udata, (void *) NULL);
41891 res->heapptr_deleted16 = DUK_USE_HEAPPTR_ENC16(res->heap_udata, (void *) DUK_STRTAB_DELETED_MARKER(res));
41892#endif
41893
41894 /* res->mark_and_sweep_trigger_counter == 0 -> now causes immediate GC; which is OK */
41895
41896 res->call_recursion_depth = 0;
41897 res->call_recursion_limit = DUK_USE_NATIVE_CALL_RECLIMIT;
41898
41899 /* XXX: use the pointer as a seed for now: mix in time at least */
41900
41901 /* The casts through duk_intr_pt is to avoid the following GCC warning:
41902 *
41903 * warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
41904 *
41905 * This still generates a /Wp64 warning on VS2010 when compiling for x86.
41906 */
41907#if defined(DUK_USE_ROM_STRINGS)
41908 /* XXX: make a common DUK_USE_ option, and allow custom fixed seed? */
41909 DUK_D(DUK_DPRINT("using rom strings, force heap hash_seed to fixed value 0x%08lx", (long) DUK__FIXED_HASH_SEED));
41910 res->hash_seed = (duk_uint32_t) DUK__FIXED_HASH_SEED;
41911#else /* DUK_USE_ROM_STRINGS */
41912 res->hash_seed = (duk_uint32_t) (duk_intptr_t) res;
41913#if !defined(DUK_USE_STRHASH_DENSE)
41914 res->hash_seed ^= 5381; /* Bernstein hash init value is normally 5381; XOR it in in case pointer low bits are 0 */
41915#endif
41916#endif /* DUK_USE_ROM_STRINGS */
41917 res->rnd_state = (duk_uint32_t) (duk_intptr_t) res;
41918
41919#if defined(DUK_USE_EXPLICIT_NULL_INIT)
41920 res->lj.jmpbuf_ptr = NULL;
41921#endif
41922 DUK_ASSERT(res->lj.type == DUK_LJ_TYPE_UNKNOWN); /* zero */
41923
41924 DUK_TVAL_SET_UNDEFINED(&res->lj.value1);
41925 DUK_TVAL_SET_UNDEFINED(&res->lj.value2);
41926
41927#if (DUK_STRTAB_INITIAL_SIZE < DUK_UTIL_MIN_HASH_PRIME)
41928#error initial heap stringtable size is defined incorrectly
41929#endif
41930
41931 /*
41932 * Init stringtable: fixed variant
41933 */
41934
41935#if defined(DUK_USE_STRTAB_CHAIN)
41936 DUK_MEMZERO(res->strtable, sizeof(duk_strtab_entry) * DUK_STRTAB_CHAIN_SIZE);
41937#if defined(DUK_USE_EXPLICIT_NULL_INIT)
41938 {
41939 duk_small_uint_t i;
41940 for (i = 0; i < DUK_STRTAB_CHAIN_SIZE; i++) {
41941#if defined(DUK_USE_HEAPPTR16)
41942 res->strtable[i].u.str16 = res->heapptr_null16;
41943#else
41944 res->strtable[i].u.str = NULL;
41945#endif
41946 }
41947 }
41948#endif /* DUK_USE_EXPLICIT_NULL_INIT */
41949#endif /* DUK_USE_STRTAB_CHAIN */
41950
41951 /*
41952 * Init stringtable: probe variant
41953 */
41954
41955#if defined(DUK_USE_STRTAB_PROBE)
41956#if defined(DUK_USE_HEAPPTR16)
41957 res->strtable16 = (duk_uint16_t *) alloc_func(heap_udata, sizeof(duk_uint16_t) * DUK_STRTAB_INITIAL_SIZE);
41958 if (!res->strtable16) {
41959 goto error;
41960 }
41961#else /* DUK_USE_HEAPPTR16 */
41962 res->strtable = (duk_hstring **) alloc_func(heap_udata, sizeof(duk_hstring *) * DUK_STRTAB_INITIAL_SIZE);
41963 if (!res->strtable) {
41964 goto error;
41965 }
41966#endif /* DUK_USE_HEAPPTR16 */
41967 res->st_size = DUK_STRTAB_INITIAL_SIZE;
41968#if defined(DUK_USE_EXPLICIT_NULL_INIT)
41969 {
41970 duk_small_uint_t i;
41971 DUK_ASSERT(res->st_size == DUK_STRTAB_INITIAL_SIZE);
41972 for (i = 0; i < DUK_STRTAB_INITIAL_SIZE; i++) {
41973#if defined(DUK_USE_HEAPPTR16)
41974 res->strtable16[i] = res->heapptr_null16;
41975#else
41976 res->strtable[i] = NULL;
41977#endif
41978 }
41979 }
41980#else /* DUK_USE_EXPLICIT_NULL_INIT */
41981#if defined(DUK_USE_HEAPPTR16)
41982 DUK_MEMZERO(res->strtable16, sizeof(duk_uint16_t) * DUK_STRTAB_INITIAL_SIZE);
41983#else
41984 DUK_MEMZERO(res->strtable, sizeof(duk_hstring *) * DUK_STRTAB_INITIAL_SIZE);
41985#endif
41986#endif /* DUK_USE_EXPLICIT_NULL_INIT */
41987#endif /* DUK_USE_STRTAB_PROBE */
41988
41989 /*
41990 * Init stringcache
41991 */
41992
41993#if defined(DUK_USE_EXPLICIT_NULL_INIT)
41994 {
41995 duk_small_uint_t i;
41996 for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) {
41997 res->strcache[i].h = NULL;
41998 }
41999 }
42000#endif
42001
42002 /* XXX: error handling is incomplete. It would be cleanest if
42003 * there was a setjmp catchpoint, so that all init code could
42004 * freely throw errors. If that were the case, the return code
42005 * passing here could be removed.
42006 */
42007
42008 /*
42009 * Init built-in strings
42010 */
42011
42012 DUK_DD(DUK_DDPRINT("HEAP: INIT STRINGS"));
42013 if (!duk__init_heap_strings(res)) {
42014 goto error;
42015 }
42016
42017 /*
42018 * Init the heap thread
42019 */
42020
42021 DUK_DD(DUK_DDPRINT("HEAP: INIT HEAP THREAD"));
42022 if (!duk__init_heap_thread(res)) {
42023 goto error;
42024 }
42025
42026 DUK_ASSERT(res->heap_thread != NULL);
42027 res->rnd_state ^= (duk_uint32_t) DUK_USE_DATE_GET_NOW((duk_context *) res->heap_thread);
42028
42029 /*
42030 * Init the heap object
42031 */
42032
42033 DUK_DD(DUK_DDPRINT("HEAP: INIT HEAP OBJECT"));
42034 DUK_ASSERT(res->heap_thread != NULL);
42035 res->heap_object = duk_hobject_alloc(res, DUK_HOBJECT_FLAG_EXTENSIBLE |
42036 DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_OBJECT));
42037 if (!res->heap_object) {
42038 goto error;
42039 }
42040 DUK_HOBJECT_INCREF(res->heap_thread, res->heap_object);
42041
42042 /*
42043 * All done
42044 */
42045

◆ duk_heap_force_strtab_resize()

DUK_INTERNAL_DECL void duk_heap_force_strtab_resize ( duk_heap * heap)

Definition at line 46058 of file duktape-1.8.0/src/duktape.c.

46075 {
46076 duk_small_uint_t prev_mark_and_sweep_base_flags;
46077 /* Force a resize so that DELETED entries are eliminated.

◆ duk_heap_free()

DUK_INTERNAL_DECL void duk_heap_free ( duk_heap * heap)

Definition at line 41280 of file duktape-1.8.0/src/duktape.c.

41283 {
41284 DUK_D(DUK_DPRINT("no more finalizable objects, forced finalization finished"));
41285 break;
41286 }
41287 if (count_finalized >= curr_limit) {
41288 DUK_D(DUK_DPRINT("finalizer count above limit, potentially runaway finalizer; skip remaining finalizers"));
41289 break;
41290 }
41291 }
41292
41295}
41296
41298 DUK_D(DUK_DPRINT("free heap: %p", (void *) heap));
41299
41300#if defined(DUK_USE_DEBUG)
41301 duk_heap_dump_strtab(heap);
41302#endif
41303
41304#if defined(DUK_USE_DEBUGGER_SUPPORT)
41305 /* Detach a debugger if attached (can be called multiple times)
41306 * safely.
41307 */
41308 /* XXX: Add a flag to reject an attempt to re-attach? Otherwise
41309 * the detached callback may immediately reattach.
41310 */
41311 duk_debug_do_detach(heap);
41312#endif
41313
41314 /* Execute finalizers before freeing the heap, even for reachable
41315 * objects, and regardless of whether or not mark-and-sweep is
41316 * enabled. This gives finalizers the chance to free any native
41317 * resources like file handles, allocations made outside Duktape,
41318 * etc. This is quite tricky to get right, so that all finalizer
41319 * guarantees are honored.
41320 *
41321 * XXX: this perhaps requires an execution time limit.
41322 */
41323 DUK_D(DUK_DPRINT("execute finalizers before freeing heap"));
41324#if defined(DUK_USE_MARK_AND_SWEEP)
41325 /* Run mark-and-sweep a few times just in case (unreachable object
41326 * finalizers run already here). The last round must rescue objects
41327 * from the previous round without running any more finalizers. This
41328 * ensures rescued objects get their FINALIZED flag cleared so that
41329 * their finalizer is called once more in forced finalization to
41330 * satisfy finalizer guarantees. However, we don't want to run any
41331 * more finalizer because that'd required one more loop, and so on.
41332 */
41333 DUK_D(DUK_DPRINT("forced gc #1 in heap destruction"));
41334 duk_heap_mark_and_sweep(heap, 0);
41335 DUK_D(DUK_DPRINT("forced gc #2 in heap destruction"));
41336 duk_heap_mark_and_sweep(heap, 0);
41337 DUK_D(DUK_DPRINT("forced gc #3 in heap destruction (don't run finalizers)"));
41338 duk_heap_mark_and_sweep(heap, DUK_MS_FLAG_SKIP_FINALIZERS); /* skip finalizers; queue finalizable objects to heap_allocated */
41339#endif
41340
41341 DUK_HEAP_SET_FINALIZER_NORESCUE(heap); /* rescue no longer supported */
41343
41344 /* Note: heap->heap_thread, heap->curr_thread, and heap->heap_object
41345 * are on the heap allocated list.
41346 */
41347
41348 DUK_D(DUK_DPRINT("freeing heap objects of heap: %p", (void *) heap));
41349 duk__free_allocated(heap);
#define DUK_HEAP_SET_FINALIZER_NORESCUE(heap)
#define DUK_HEAP_CLEAR_MARKANDSWEEP_RUNNING(heap)
DUK_LOCAL void duk__free_allocated(duk_heap *heap)
DUK_INTERNAL_DECL duk_bool_t duk_heap_mark_and_sweep(duk_heap *heap, duk_small_uint_t flags)
DUK_INTERNAL_DECL void duk_heap_free(duk_heap *heap)

◆ duk_heap_free_heaphdr_raw()

DUK_INTERNAL_DECL void duk_heap_free_heaphdr_raw ( duk_heap * heap,
duk_heaphdr * hdr )

Definition at line 41095 of file duktape-1.8.0/src/duktape.c.

41096 {
41097 DUK_ASSERT(heap != NULL);
41098 DUK_ASSERT(h != NULL);
41099
41100 DUK_UNREF(heap);
41101 DUK_UNREF(h);
41102
41103#if defined(DUK_USE_HSTRING_EXTDATA) && defined(DUK_USE_EXTSTR_FREE)
41104 if (DUK_HSTRING_HAS_EXTDATA(h)) {
41105 DUK_DDD(DUK_DDDPRINT("free extstr: hstring %!O, extdata: %p",
41106 h, DUK_HSTRING_GET_EXTDATA((duk_hstring_external *) h)));
41107 DUK_USE_EXTSTR_FREE(heap->heap_udata, (const void *) DUK_HSTRING_GET_EXTDATA((duk_hstring_external *) h));
41108 }
41109#endif
41110}
41111
41113 DUK_ASSERT(heap);
41114 DUK_ASSERT(hdr);
41115
41116 DUK_DDD(DUK_DDDPRINT("free heaphdr %p, htype %ld", (void *) hdr, (long) DUK_HEAPHDR_GET_TYPE(hdr)));
#define DUK_HSTRING_HAS_EXTDATA(x)

References DUK_ASSERT, DUK_DDD, DUK_DDDPRINT, DUK_HSTRING_HAS_EXTDATA, DUK_UNREF, duk_heap::heap_udata, and NULL.

Referenced by duk__free_markandsweep_finalize_list(), duk__free_refzero_list(), and duk__free_run_finalizers().

◆ duk_heap_free_strtab()

DUK_INTERNAL void duk_heap_free_strtab ( duk_heap * heap)

Definition at line 46144 of file duktape-1.8.0/src/duktape.c.

46150 {
46151 duk_free_hstring_inner(heap, h);
46152 DUK_FREE(heap, h);
46153 }
46154 }
46155 e->listlen = 0;
46156 }
46157}
46158#endif /* DUK_USE_STRTAB_CHAIN */
46159
46160#if defined(DUK_USE_STRTAB_PROBE)
46163 duk_hstring *h;
46164
46165#if defined(DUK_USE_HEAPPTR16)
46166 if (heap->strtable16) {
46167#else
46168 if (heap->strtable) {
46169#endif
46170 for (i = 0; i < (duk_uint_fast32_t) heap->st_size; i++) {
46171#if defined(DUK_USE_HEAPPTR16)
46172 h = (duk_hstring *) DUK_USE_HEAPPTR_DEC16(heap->heap_udata, heap->strtable16[i]);
46173#else
46174 h = heap->strtable[i];
46175#endif
46176 if (h == NULL || h == DUK_STRTAB_DELETED_MARKER(heap)) {
46177 continue;
46178 }
46179 DUK_ASSERT(h != NULL);
46180
DUK_INTERNAL_DECL void duk_free_hstring_inner(duk_heap *heap, duk_hstring *h)

◆ duk_heap_hashstring()

DUK_INTERNAL_DECL duk_uint32_t duk_heap_hashstring ( duk_heap * heap,
const duk_uint8_t * str,
duk_size_t len )

Definition at line 42142 of file duktape-1.8.0/src/duktape.c.

42159 {
42160 duk_uint32_t hash;
42161 duk_size_t step;
42162 duk_size_t off;
42163
42164 /* Slightly modified "Bernstein hash" from:
42165 *
42166 * http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx
42167 *
42168 * Modifications: string skipping and reverse direction similar to
42169 * Lua 5.1.5, and different hash initializer.
42170 *
42171 * The reverse direction ensures last byte it always included in the
42172 * hash which is a good default as changing parts of the string are
42173 * more often in the suffix than in the prefix.

◆ duk_heap_insert_into_heap_allocated()

DUK_INTERNAL_DECL void duk_heap_insert_into_heap_allocated ( duk_heap * heap,
duk_heaphdr * hdr )

Definition at line 44033 of file duktape-1.8.0/src/duktape.c.

44034 {
44035 heap->heap_allocated = DUK_HEAPHDR_GET_NEXT(heap, hdr);
44036 }
44037 if (DUK_HEAPHDR_GET_NEXT(heap, hdr)) {
44039 } else {
44040 ;
44041 }
44042
44043 /* The prev/next pointers of the removed duk_heaphdr are left as garbage.
44044 * It's up to the caller to ensure they're written before inserting the
44045 * object back.

◆ duk_heap_mark_and_sweep()

DUK_INTERNAL_DECL duk_bool_t duk_heap_mark_and_sweep ( duk_heap * heap,
duk_small_uint_t flags )

Definition at line 43340 of file duktape-1.8.0/src/duktape.c.

43357 {
43358 duk_hthread *thr;
43359 duk_size_t count_keep_obj;
43360 duk_size_t count_keep_str;
43361#ifdef DUK_USE_VOLUNTARY_GC
43362 duk_size_t tmp;
43363#endif
43364
43366 DUK_D(DUK_DPRINT("refuse to do a recursive mark-and-sweep"));
43367 return 0;
43368 }
43369
43370 /* XXX: thread selection for mark-and-sweep is currently a hack.
43371 * If we don't have a thread, the entire mark-and-sweep is now
43372 * skipped (although we could just skip finalizations).
43373 */
43374
43375 /* If thr != NULL, the thr may still be in the middle of
43376 * initialization.
43377 * XXX: Improve the thread viability test.
43378 */
43379 thr = duk__get_temp_hthread(heap);
43380 if (thr == NULL) {
43381 DUK_D(DUK_DPRINT("gc skipped because we don't have a temp thread"));
43382
43383 /* reset voluntary gc trigger count */
43384#ifdef DUK_USE_VOLUNTARY_GC
43386#endif
43387 return 0; /* OK */
43388 }
43389
43390 /* If debugger is paused, garbage collection is disabled by default. */
43391 /* XXX: will need a force flag if garbage collection is triggered
43392 * explicitly during paused state.
43393 */
43394#if defined(DUK_USE_DEBUGGER_SUPPORT)
43395 if (DUK_HEAP_IS_PAUSED(heap)) {
43396 /* Checking this here rather that in memory alloc primitives
43397 * reduces checking code there but means a failed allocation
43398 * will go through a few retries before giving up. That's
43399 * fine because this only happens during debugging.
43400 */
43401 DUK_D(DUK_DPRINT("gc skipped because debugger is paused"));
43402 return 0;
43403 }
43404#endif
43405
43406 DUK_D(DUK_DPRINT("garbage collect (mark-and-sweep) starting, requested flags: 0x%08lx, effective flags: 0x%08lx",
43407 (unsigned long) flags, (unsigned long) (flags | heap->mark_and_sweep_base_flags)));
43408
43409 flags |= heap->mark_and_sweep_base_flags;
43410
43411 /*
43412 * Assertions before
43413 */
43414
43415#ifdef DUK_USE_ASSERTIONS
43419 duk__assert_heaphdr_flags(heap);
43420#ifdef DUK_USE_REFERENCE_COUNTING
43421 /* Note: DUK_HEAP_HAS_REFZERO_FREE_RUNNING(heap) may be true; a refcount
43422 * finalizer may trigger a mark-and-sweep.
43423 */
43424 duk__assert_valid_refcounts(heap);
43425#endif /* DUK_USE_REFERENCE_COUNTING */
43426#endif /* DUK_USE_ASSERTIONS */
43427
43428 /*
43429 * Begin
43430 */
43431
43433
43434 /*
43435 * Mark roots, hoping that recursion limit is not normally hit.
43436 * If recursion limit is hit, run additional reachability rounds
43437 * starting from "temproots" until marking is complete.
43438 *
43439 * Marking happens in two phases: first we mark actual reachability
43440 * roots (and run "temproots" to complete the process). Then we
43441 * check which objects are unreachable and are finalizable; such
43442 * objects are marked as FINALIZABLE and marked as reachability
43443 * (and "temproots" is run again to complete the process).
43444 *
43445 * The heap finalize_list must also be marked as a reachability root.
43446 * There may be objects on the list from a previous round if the
43447 * previous run had finalizer skip flag.
43448 */
43449
43450 duk__mark_roots_heap(heap); /* main reachability roots */
43451#ifdef DUK_USE_REFERENCE_COUNTING
43452 duk__mark_refzero_list(heap); /* refzero_list treated as reachability roots */
43453#endif
43454 duk__mark_temproots_by_heap_scan(heap); /* temproots */
43455
43456 duk__mark_finalizable(heap); /* mark finalizable as reachability roots */
43457 duk__mark_finalize_list(heap); /* mark finalizer work list as reachability roots */
43458 duk__mark_temproots_by_heap_scan(heap); /* temproots */
43459
43460 /*
43461 * Sweep garbage and remove marking flags, and move objects with
43462 * finalizers to the finalizer work list.
43463 *
43464 * Objects to be swept need to get their refcounts finalized before
43465 * they are swept. In other words, their target object refcounts
43466 * need to be decreased. This has to be done before freeing any
43467 * objects to avoid decref'ing dangling pointers (which may happen
43468 * even without bugs, e.g. with reference loops)
43469 *
43470 * Because strings don't point to other heap objects, similar
43471 * finalization is not necessary for strings.
43472 */
43473
43474 /* XXX: more emergency behavior, e.g. find smaller hash sizes etc */
43475
43476#ifdef DUK_USE_REFERENCE_COUNTING
43478#endif
43479 duk__sweep_heap(heap, flags, &count_keep_obj);
43480#if defined(DUK_USE_STRTAB_CHAIN)
43481 duk__sweep_stringtable_chain(heap, &count_keep_str);
43482#elif defined(DUK_USE_STRTAB_PROBE)
43483 duk__sweep_stringtable_probe(heap, &count_keep_str);
43484#else
43485#error internal error, invalid strtab options
43486#endif
43487#ifdef DUK_USE_REFERENCE_COUNTING
43489#endif
43491
43492 /*
43493 * Object compaction (emergency only).
43494 *
43495 * Object compaction is a separate step after sweeping, as there is
43496 * more free memory for it to work with. Also, currently compaction
43497 * may insert new objects into the heap allocated list and the string
43498 * table which we don't want to do during a sweep (the reachability
43499 * flags of such objects would be incorrect). The objects inserted
43500 * are currently:
43501 *
43502 * - a temporary duk_hbuffer for a new properties allocation
43503 * - if array part is abandoned, string keys are interned
43504 *
43505 * The object insertions go to the front of the list, so they do not
43506 * cause an infinite loop (they are not compacted).
43507 */
43508
43509 if ((flags & DUK_MS_FLAG_EMERGENCY) &&
43512 }
43513
43514 /*
43515 * String table resize check.
43516 *
43517 * Note: this may silently (and safely) fail if GC is caused by an
43518 * allocation call in stringtable resize_hash(). Resize_hash()
43519 * will prevent a recursive call to itself by setting the
43520 * DUK_MS_FLAG_NO_STRINGTABLE_RESIZE in heap->mark_and_sweep_base_flags.
43521 */
43522
43523 /* XXX: stringtable emergency compaction? */
43524
43525 /* XXX: remove this feature entirely? it would only matter for
43526 * emergency GC. Disable for lowest memory builds.
43527 */
43528#if defined(DUK_USE_MS_STRINGTABLE_RESIZE)
43529 if (!(flags & DUK_MS_FLAG_NO_STRINGTABLE_RESIZE)) {
43530 DUK_DD(DUK_DDPRINT("resize stringtable: %p", (void *) heap));
43532 } else {
43533 DUK_D(DUK_DPRINT("stringtable resize skipped because DUK_MS_FLAG_NO_STRINGTABLE_RESIZE is set"));
43534 }
43535#endif
43536
43537 /*
43538 * Finalize objects in the finalization work list. Finalized
43539 * objects are queued back to heap_allocated with FINALIZED set.
43540 *
43541 * Since finalizers may cause arbitrary side effects, they are
43542 * prevented during string table and object property allocation
43543 * resizing using the DUK_MS_FLAG_NO_FINALIZERS flag in
43544 * heap->mark_and_sweep_base_flags. In this case the objects
43545 * remain in the finalization work list after mark-and-sweep
43546 * exits and they may be finalized on the next pass.
43547 *
43548 * Finalization currently happens inside "MARKANDSWEEP_RUNNING"
43549 * protection (no mark-and-sweep may be triggered by the
43550 * finalizers). As a side effect:
43551 *
43552 * 1) an out-of-memory error inside a finalizer will not
43553 * cause a mark-and-sweep and may cause the finalizer
43554 * to fail unnecessarily
43555 *
43556 * 2) any temporary objects whose refcount decreases to zero
43557 * during finalization will not be put into refzero_list;
43558 * they can only be collected by another mark-and-sweep
43559 *
43560 * This is not optimal, but since the sweep for this phase has
43561 * already happened, this is probably good enough for now.
43562 */
43563
43564#if defined(DUK_USE_MARKANDSWEEP_FINALIZER_TORTURE)
43565 /* Cannot simulate individual finalizers because finalize_list only
43566 * contains objects with actual finalizers. But simulate side effects
43567 * from finalization by doing a bogus function call and resizing the
43568 * stacks.
43569 */
43570 if (flags & DUK_MS_FLAG_NO_FINALIZERS) {
43571 DUK_D(DUK_DPRINT("skip mark-and-sweep torture finalizer, DUK_MS_FLAG_NO_FINALIZERS is set"));
43572 } else if (!(thr->valstack != NULL && thr->callstack != NULL && thr->catchstack != NULL)) {
43573 DUK_D(DUK_DPRINT("skip mark-and-sweep torture finalizer, thread not yet viable"));
43574 } else {
43575 DUK_D(DUK_DPRINT("run mark-and-sweep torture finalizer"));
43576 duk__markandsweep_torture_finalizer(thr);
43577 }
43578#endif /* DUK_USE_MARKANDSWEEP_FINALIZER_TORTURE */
43579
43580 if (flags & DUK_MS_FLAG_NO_FINALIZERS) {
43581 DUK_D(DUK_DPRINT("finalizer run skipped because DUK_MS_FLAG_NO_FINALIZERS is set"));
43582 } else {
43583 duk__run_object_finalizers(heap, flags);
43584 }
43585
43586 /*
43587 * Finish
43588 */
43589
43591
43592 /*
43593 * Assertions after
43594 */
43595
43596#ifdef DUK_USE_ASSERTIONS
43600 duk__assert_heaphdr_flags(heap);
43601#ifdef DUK_USE_REFERENCE_COUNTING
43602 /* Note: DUK_HEAP_HAS_REFZERO_FREE_RUNNING(heap) may be true; a refcount
43603 * finalizer may trigger a mark-and-sweep.
43604 */
43605 duk__assert_valid_refcounts(heap);
43606#endif /* DUK_USE_REFERENCE_COUNTING */
43607#endif /* DUK_USE_ASSERTIONS */
43608
43609 /*
#define DUK_MS_FLAG_EMERGENCY
DUK_LOCAL void duk__clear_refzero_list_flags(duk_heap *heap)
DUK_LOCAL void duk__finalize_refcounts(duk_heap *heap)
DUK_LOCAL void duk__mark_finalizable(duk_heap *heap)
DUK_LOCAL void duk__mark_refzero_list(duk_heap *heap)
#define DUK_HEAP_MARK_AND_SWEEP_TRIGGER_SKIP
DUK_LOCAL void duk__clear_finalize_list_flags(duk_heap *heap)
DUK_INTERNAL_DECL void duk_heap_force_strtab_resize(duk_heap *heap)

◆ duk_heap_mem_alloc()

DUK_INTERNAL_DECL void * duk_heap_mem_alloc ( duk_heap * heap,
duk_size_t size )

Definition at line 43661 of file duktape-1.8.0/src/duktape.c.

43678 {
43679 void *res;
43680 duk_bool_t rc;
43682
43683 DUK_ASSERT(heap != NULL);
43684 DUK_ASSERT_DISABLE(size >= 0);
43685
43686 /*
43687 * Voluntary periodic GC (if enabled)
43688 */
43689
43691
43692 /*
43693 * First attempt
43694 */
43695
43696#ifdef DUK_USE_GC_TORTURE
43697 /* simulate alloc failure on every alloc (except when mark-and-sweep is running) */
43699 DUK_DDD(DUK_DDDPRINT("gc torture enabled, pretend that first alloc attempt fails"));
43700 res = NULL;
43701 DUK_UNREF(res);
43702 goto skip_attempt;
43703 }
43704#endif
43705 res = heap->alloc_func(heap->heap_udata, size);
43706 if (res || size == 0) {
43707 /* for zero size allocations NULL is allowed */
43708 return res;
43709 }
43710#ifdef DUK_USE_GC_TORTURE
43711 skip_attempt:
43712#endif
43713
43714 DUK_D(DUK_DPRINT("first alloc attempt failed, attempt to gc and retry"));
43715
43716 /*
43717 * Avoid a GC if GC is already running. This can happen at a late
43718 * stage in a GC when we try to e.g. resize the stringtable
43719 * or compact objects.
43720 */
43721
43723 DUK_D(DUK_DPRINT("duk_heap_mem_alloc() failed, gc in progress (gc skipped), alloc size %ld", (long) size));
43724 return NULL;
43725 }
43726
43727 /*
43728 * Retry with several GC attempts. Initial attempts are made without
43729 * emergency mode; later attempts use emergency mode which minimizes
43730 * memory allocations forcibly.
43731 */
43732
43733 for (i = 0; i < DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_LIMIT; i++) {
43734 duk_small_uint_t flags;
43735
43736 flags = 0;
#define DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_LIMIT
#define DUK__VOLUNTARY_PERIODIC_GC(heap)
#define DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_EMERGENCY_LIMIT

◆ duk_heap_mem_alloc_zeroed()

DUK_INTERNAL_DECL void * duk_heap_mem_alloc_zeroed ( duk_heap * heap,
duk_size_t size )

Definition at line 43751 of file duktape-1.8.0/src/duktape.c.

43760 {
43761 DUK_ASSERT(heap != NULL);
43762 DUK_ASSERT_DISABLE(size >= 0);
43763

◆ duk_heap_mem_free()

DUK_INTERNAL_DECL void duk_heap_mem_free ( duk_heap * heap,
void * ptr )

Definition at line 43971 of file duktape-1.8.0/src/duktape.c.

43978 {
43979 return heap->realloc_func(heap->heap_udata, cb(heap, ud), newsize);
43980}
43981#endif /* DUK_USE_MARK_AND_SWEEP */
43982
43983/*
43984 * Free memory
43985 */
43986
43987#ifdef DUK_USE_MARK_AND_SWEEP
43988DUK_INTERNAL void duk_heap_mem_free(duk_heap *heap, void *ptr) {
DUK_INTERNAL_DECL void duk_heap_mem_free(duk_heap *heap, void *ptr)

◆ duk_heap_mem_realloc()

DUK_INTERNAL_DECL void * duk_heap_mem_realloc ( duk_heap * heap,
void * ptr,
duk_size_t newsize )

Definition at line 43770 of file duktape-1.8.0/src/duktape.c.

43775 {
43776 /* assume memset with zero size is OK */
43777 DUK_MEMZERO(res, size);
43778 }
43779 return res;
43780}
43781
43782/*
43783 * Reallocate memory with garbage collection
43784 */
43785
43786#ifdef DUK_USE_MARK_AND_SWEEP
43787DUK_INTERNAL void *duk_heap_mem_realloc(duk_heap *heap, void *ptr, duk_size_t newsize) {
43788 void *res;
43789 duk_bool_t rc;
43791
43792 DUK_ASSERT(heap != NULL);
43793 /* ptr may be NULL */
43794 DUK_ASSERT_DISABLE(newsize >= 0);
43795
43796 /*
43797 * Voluntary periodic GC (if enabled)
43798 */
43799
43801
43802 /*
43803 * First attempt
43804 */
43805
43806#ifdef DUK_USE_GC_TORTURE
43807 /* simulate alloc failure on every realloc (except when mark-and-sweep is running) */
43809 DUK_DDD(DUK_DDDPRINT("gc torture enabled, pretend that first realloc attempt fails"));
43810 res = NULL;
43811 DUK_UNREF(res);
43812 goto skip_attempt;
43813 }
43814#endif
43815 res = heap->realloc_func(heap->heap_udata, ptr, newsize);
43816 if (res || newsize == 0) {
43817 /* for zero size allocations NULL is allowed */
43818 return res;
43819 }
43820#ifdef DUK_USE_GC_TORTURE
43821 skip_attempt:
43822#endif
43823
43824 DUK_D(DUK_DPRINT("first realloc attempt failed, attempt to gc and retry"));
43825
43826 /*
43827 * Avoid a GC if GC is already running. See duk_heap_mem_alloc().
43828 */
43829
43831 DUK_D(DUK_DPRINT("duk_heap_mem_realloc() failed, gc in progress (gc skipped), alloc size %ld", (long) newsize));
43832 return NULL;
43833 }
43834
43835 /*
43836 * Retry with several GC attempts. Initial attempts are made without
43837 * emergency mode; later attempts use emergency mode which minimizes
43838 * memory allocations forcibly.
43839 */
43840
43841 for (i = 0; i < DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_LIMIT; i++) {
43842 duk_small_uint_t flags;
43843
43844 flags = 0;
DUK_INTERNAL_DECL void * duk_heap_mem_realloc(duk_heap *heap, void *ptr, duk_size_t newsize)

◆ duk_heap_mem_realloc_indirect()

DUK_INTERNAL_DECL void * duk_heap_mem_realloc_indirect ( duk_heap * heap,
duk_mem_getptr cb,
void * ud,
duk_size_t newsize )

Definition at line 43864 of file duktape-1.8.0/src/duktape.c.

43865 {
43866 DUK_ASSERT(heap != NULL);
43867 /* ptr may be NULL */
43868 DUK_ASSERT_DISABLE(newsize >= 0);
43869
43870 return heap->realloc_func(heap->heap_udata, ptr, newsize);
43871}
43872#endif /* DUK_USE_MARK_AND_SWEEP */
43873
43874/*
43875 * Reallocate memory with garbage collection, using a callback to provide
43876 * the current allocated pointer. This variant is used when a mark-and-sweep
43877 * (e.g. finalizers) might change the original pointer.
43878 */
43879
43880#ifdef DUK_USE_MARK_AND_SWEEP
43882 void *res;
43883 duk_bool_t rc;
43885
43886 DUK_ASSERT(heap != NULL);
43887 DUK_ASSERT_DISABLE(newsize >= 0);
43888
43889 /*
43890 * Voluntary periodic GC (if enabled)
43891 */
43892
43894
43895 /*
43896 * First attempt
43897 */
43898
43899#ifdef DUK_USE_GC_TORTURE
43900 /* simulate alloc failure on every realloc (except when mark-and-sweep is running) */
43902 DUK_DDD(DUK_DDDPRINT("gc torture enabled, pretend that first indirect realloc attempt fails"));
43903 res = NULL;
43904 DUK_UNREF(res);
43905 goto skip_attempt;
43906 }
43907#endif
43908 res = heap->realloc_func(heap->heap_udata, cb(heap, ud), newsize);
43909 if (res || newsize == 0) {
43910 /* for zero size allocations NULL is allowed */
43911 return res;
43912 }
43913#ifdef DUK_USE_GC_TORTURE
43914 skip_attempt:
43915#endif
43916
43917 DUK_D(DUK_DPRINT("first indirect realloc attempt failed, attempt to gc and retry"));
43918
43919 /*
43920 * Avoid a GC if GC is already running. See duk_heap_mem_alloc().
43921 */
43922
43924 DUK_D(DUK_DPRINT("duk_heap_mem_realloc_indirect() failed, gc in progress (gc skipped), alloc size %ld", (long) newsize));
43925 return NULL;
43926 }
43927
43928 /*
43929 * Retry with several GC attempts. Initial attempts are made without
43930 * emergency mode; later attempts use emergency mode which minimizes
43931 * memory allocations forcibly.
43932 */
43933
43934 for (i = 0; i < DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_LIMIT; i++) {
43935 duk_small_uint_t flags;
43936
43937#ifdef DUK_USE_ASSERTIONS
43938 void *ptr_pre; /* ptr before mark-and-sweep */
43939 void *ptr_post;
43940#endif
43941
43942#ifdef DUK_USE_ASSERTIONS
43943 ptr_pre = cb(heap, ud);
43944#endif
43945 flags = 0;
43947 flags |= DUK_MS_FLAG_EMERGENCY;
43948 }
43949
43950 rc = duk_heap_mark_and_sweep(heap, flags);
43951 DUK_UNREF(rc);
43952#ifdef DUK_USE_ASSERTIONS
43953 ptr_post = cb(heap, ud);
43954 if (ptr_pre != ptr_post) {
43955 /* useful for debugging */
43956 DUK_DD(DUK_DDPRINT("note: base pointer changed by mark-and-sweep: %p -> %p",
43957 (void *) ptr_pre, (void *) ptr_post));
43958 }
DUK_INTERNAL_DECL void * duk_heap_mem_realloc_indirect(duk_heap *heap, duk_mem_getptr cb, void *ud, duk_size_t newsize)
void *(* duk_mem_getptr)(duk_heap *heap, void *ud)

References DUK_ASSERT, DUK_ASSERT_DISABLE, duk_heap::heap_udata, NULL, and duk_heap::realloc_func.

◆ duk_heap_remove_any_from_heap_allocated()

DUK_INTERNAL_DECL void duk_heap_remove_any_from_heap_allocated ( duk_heap * heap,
duk_heaphdr * hdr )

Definition at line 44012 of file duktape-1.8.0/src/duktape.c.

◆ duk_heap_strcache_offset_char2byte()

DUK_INTERNAL_DECL duk_uint_fast32_t duk_heap_strcache_offset_char2byte ( duk_hthread * thr,
duk_hstring * h,
duk_uint_fast32_t char_offset )

Definition at line 44795 of file duktape-1.8.0/src/duktape.c.

44812 {
44813 duk_heap *heap;
44814 duk_strcache *sce;
44815 duk_uint_fast32_t byte_offset;
44817 duk_bool_t use_cache;
44818 duk_uint_fast32_t dist_start, dist_end, dist_sce;
44819 const duk_uint8_t *p_start;
44820 const duk_uint8_t *p_end;
44821 const duk_uint8_t *p_found;
44822
44823 if (char_offset > DUK_HSTRING_GET_CHARLEN(h)) {
44824 goto error;
44825 }
44826
44827 /*
44828 * For ASCII strings, the answer is simple.
44829 */
44830
44831 if (DUK_HSTRING_IS_ASCII(h)) {
44832 /* clen == blen -> pure ascii */
44833 return char_offset;
44834 }
44835
44836 /*
44837 * For non-ASCII strings, we need to scan forwards or backwards
44838 * from some starting point. The starting point may be the start
44839 * or end of the string, or some cached midpoint in the string
44840 * cache.
44841 *
44842 * For "short" strings we simply scan without checking or updating
44843 * the cache. For longer strings we check and update the cache as
44844 * necessary, inserting a new cache entry if none exists.
44845 */
44846
44847 DUK_DDD(DUK_DDDPRINT("non-ascii string %p, char_offset=%ld, clen=%ld, blen=%ld",
44848 (void *) h, (long) char_offset,
44849 (long) DUK_HSTRING_GET_CHARLEN(h),
44850 (long) DUK_HSTRING_GET_BYTELEN(h)));
44851
44852 heap = thr->heap;
44853 sce = NULL;
44855
44856 if (use_cache) {
44857#ifdef DUK_USE_DDDPRINT
44858 DUK_DDD(DUK_DDDPRINT("stringcache before char2byte (using cache):"));
44859 for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) {
44860 duk_strcache *c = heap->strcache + i;
44861 DUK_DDD(DUK_DDDPRINT(" [%ld] -> h=%p, cidx=%ld, bidx=%ld",
44862 (long) i, (void *) c->h, (long) c->cidx, (long) c->bidx));
44863 }
44864#endif
44865
44866 for (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) {
44867 duk_strcache *c = heap->strcache + i;
44868
44869 if (c->h == h) {
44870 sce = c;
44871 break;
44872 }
44873 }
44874 }
44875
44876 /*
44877 * Scan from shortest distance:
44878 * - start of string
44879 * - end of string
44880 * - cache entry (if exists)
44881 */
44882
44883 DUK_ASSERT(DUK_HSTRING_GET_CHARLEN(h) >= char_offset);
44884 dist_start = char_offset;
44885 dist_end = DUK_HSTRING_GET_CHARLEN(h) - char_offset;
44886 dist_sce = 0; DUK_UNREF(dist_sce); /* initialize for debug prints, needed if sce==NULL */
44887
44888 p_start = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h);
44889 p_end = (const duk_uint8_t *) (p_start + DUK_HSTRING_GET_BYTELEN(h));
44890 p_found = NULL;
44891
44892 if (sce) {
44893 if (char_offset >= sce->cidx) {
44894 dist_sce = char_offset - sce->cidx;
44895 if ((dist_sce <= dist_start) && (dist_sce <= dist_end)) {
44896 DUK_DDD(DUK_DDDPRINT("non-ascii string, use_cache=%ld, sce=%p:%ld:%ld, "
44897 "dist_start=%ld, dist_end=%ld, dist_sce=%ld => "
44898 "scan forwards from sce",
44899 (long) use_cache, (void *) (sce ? sce->h : NULL),
44900 (sce ? (long) sce->cidx : (long) -1),
44901 (sce ? (long) sce->bidx : (long) -1),
44902 (long) dist_start, (long) dist_end, (long) dist_sce));
44903
44904 p_found = duk__scan_forwards(p_start + sce->bidx,
44905 p_end,
44906 dist_sce);
44907 goto scan_done;
44908 }
44909 } else {
44910 dist_sce = sce->cidx - char_offset;
44911 if ((dist_sce <= dist_start) && (dist_sce <= dist_end)) {
44912 DUK_DDD(DUK_DDDPRINT("non-ascii string, use_cache=%ld, sce=%p:%ld:%ld, "
44913 "dist_start=%ld, dist_end=%ld, dist_sce=%ld => "
44914 "scan backwards from sce",
44915 (long) use_cache, (void *) (sce ? sce->h : NULL),
44916 (sce ? (long) sce->cidx : (long) -1),
44917 (sce ? (long) sce->bidx : (long) -1),
44918 (long) dist_start, (long) dist_end, (long) dist_sce));
44919
44920 p_found = duk__scan_backwards(p_start + sce->bidx,
44921 p_start,
44922 dist_sce);
44923 goto scan_done;
44924 }
44925 }
44926 }
44927
44928 /* no sce, or sce scan not best */
44929
44930 if (dist_start <= dist_end) {
44931 DUK_DDD(DUK_DDDPRINT("non-ascii string, use_cache=%ld, sce=%p:%ld:%ld, "
44932 "dist_start=%ld, dist_end=%ld, dist_sce=%ld => "
44933 "scan forwards from string start",
44934 (long) use_cache, (void *) (sce ? sce->h : NULL),
44935 (sce ? (long) sce->cidx : (long) -1),
44936 (sce ? (long) sce->bidx : (long) -1),
44937 (long) dist_start, (long) dist_end, (long) dist_sce));
44938
44939 p_found = duk__scan_forwards(p_start,
44940 p_end,
44941 dist_start);
44942 } else {
44943 DUK_DDD(DUK_DDDPRINT("non-ascii string, use_cache=%ld, sce=%p:%ld:%ld, "
44944 "dist_start=%ld, dist_end=%ld, dist_sce=%ld => "
44945 "scan backwards from string end",
44946 (long) use_cache, (void *) (sce ? sce->h : NULL),
44947 (sce ? (long) sce->cidx : (long) -1),
44948 (sce ? (long) sce->bidx : (long) -1),
44949 (long) dist_start, (long) dist_end, (long) dist_sce));
44950
44951 p_found = duk__scan_backwards(p_end,
44952 p_start,
44953 dist_end);
44954 }
44955
44956 scan_done:
44957
44958 if (!p_found) {
44959 /* Scan error: this shouldn't normally happen; it could happen if
44960 * string is not valid UTF-8 data, and clen/blen are not consistent
44961 * with the scanning algorithm.
44962 */
44963 goto error;
44964 }
44965
44966 DUK_ASSERT(p_found >= p_start);
44967 DUK_ASSERT(p_found <= p_end); /* may be equal */
44968 byte_offset = (duk_uint32_t) (p_found - p_start);
44969
44970 DUK_DDD(DUK_DDDPRINT("-> string %p, cidx %ld -> bidx %ld",
44971 (void *) h, (long) char_offset, (long) byte_offset));
44972
44973 /*
44974 * Update cache entry (allocating if necessary), and move the
44975 * cache entry to the first place (in an "LRU" policy).
44976 */
44977
44978 if (use_cache) {
44979 /* update entry, allocating if necessary */
44980 if (!sce) {
44981 sce = heap->strcache + DUK_HEAP_STRCACHE_SIZE - 1; /* take last entry */
44982 sce->h = h;
44983 }
44984 DUK_ASSERT(sce != NULL);
44985 sce->bidx = (duk_uint32_t) (p_found - p_start);
44986 sce->cidx = (duk_uint32_t) char_offset;
44987
44988 /* LRU: move our entry to first */
44989 if (sce > &heap->strcache[0]) {
44990 /*
44991 * A C
44992 * B A
44993 * C <- sce ==> B
44994 * D D
44995 */
44996 duk_strcache tmp;
44997
44998 tmp = *sce;
44999 DUK_MEMMOVE((void *) (&heap->strcache[1]),
45000 (const void *) (&heap->strcache[0]),
45001 (size_t) (((char *) sce) - ((char *) &heap->strcache[0])));
45002 heap->strcache[0] = tmp;
45003
45004 /* 'sce' points to the wrong entry here, but is no longer used */
#define DUK_HSTRING_IS_ASCII(x)
DUK_LOCAL const duk_uint8_t * duk__scan_forwards(const duk_uint8_t *p, const duk_uint8_t *q, duk_uint_fast32_t n)
#define DUK_HEAP_STRINGCACHE_NOCACHE_LIMIT
#define DUK_HEAP_STRCACHE_SIZE
DUK_LOCAL const duk_uint8_t * duk__scan_backwards(const duk_uint8_t *p, const duk_uint8_t *q, duk_uint_fast32_t n)
duk_strcache strcache[DUK_HEAP_STRCACHE_SIZE]

Referenced by duk_hstring_char_code_at_raw().

◆ duk_heap_strcache_string_remove()

DUK_INTERNAL_DECL void duk_heap_strcache_string_remove ( duk_heap * heap,
duk_hstring * h )

◆ duk_heap_string_intern()

DUK_INTERNAL_DECL duk_hstring * duk_heap_string_intern ( duk_heap * heap,
const duk_uint8_t * str,
duk_uint32_t blen )

Definition at line 45985 of file duktape-1.8.0/src/duktape.c.

45996 {
45997 duk_uint32_t strhash; /* dummy */
45998 return duk__do_lookup(heap, str, blen, &strhash);
45999}

◆ duk_heap_string_intern_checked()

DUK_INTERNAL_DECL duk_hstring * duk_heap_string_intern_checked ( duk_hthread * thr,
const duk_uint8_t * str,
duk_uint32_t len )

Definition at line 46001 of file duktape-1.8.0/src/duktape.c.

46002 {
46003 duk_hstring *res;
46004 duk_uint32_t strhash;
46005
46006 /* caller is responsible for ensuring this */

References duk__do_intern(), duk__do_lookup(), DUK_ASSERT, and DUK_HSTRING_MAX_BYTELEN.

◆ duk_heap_string_intern_u32()

DUK_INTERNAL_DECL duk_hstring * duk_heap_string_intern_u32 ( duk_heap * heap,
duk_uint32_t val )

Definition at line 46019 of file duktape-1.8.0/src/duktape.c.

46020 {
46022 }
46023 return res;
46024}
46025

Referenced by duk__realloc_props().

◆ duk_heap_string_intern_u32_checked()

DUK_INTERNAL_DECL duk_hstring * duk_heap_string_intern_u32_checked ( duk_hthread * thr,
duk_uint32_t val )

Definition at line 46027 of file duktape-1.8.0/src/duktape.c.

46027 {
46028 char buf[DUK_STRTAB_U32_MAX_STRLEN+1];
46029 DUK_SNPRINTF(buf, sizeof(buf), "%lu", (unsigned long) val);
46030 buf[sizeof(buf) - 1] = (char) 0;
46031 DUK_ASSERT(DUK_STRLEN(buf) <= DUK_UINT32_MAX); /* formatted result limited */
46032 return duk_heap_string_lookup(heap, (const duk_uint8_t *) buf, (duk_uint32_t) DUK_STRLEN(buf));
46033}
#define DUK_STRTAB_U32_MAX_STRLEN

References DUK_ASSERT, DUK_SNPRINTF, DUK_STRLEN, DUK_STRTAB_U32_MAX_STRLEN, and DUK_UINT32_MAX.

◆ duk_heap_string_remove()

DUK_INTERNAL_DECL void duk_heap_string_remove ( duk_heap * heap,
duk_hstring * h )

Definition at line 46037 of file duktape-1.8.0/src/duktape.c.

46044 {
46045 duk_hstring *res = duk_heap_string_intern_u32(thr->heap, val);
46046 if (!res) {
46048 }
46049 return res;
46050}
46051
46052/* find and remove string from stringtable; caller must free the string itself */
46053#if defined(DUK_USE_REFERENCE_COUNTING)
DUK_INTERNAL_DECL void duk_heap_string_remove(duk_heap *heap, duk_hstring *h)

◆ duk_heaphdr_decref()

DUK_INTERNAL_DECL void duk_heaphdr_decref ( duk_hthread * thr,
duk_heaphdr * h )

Definition at line 44662 of file duktape-1.8.0/src/duktape.c.

44668 {
44669 if (h == NULL) {
44670 return;
44671 }
44674
44676}
44677#endif
44678

◆ duk_heaphdr_decref_allownull()

DUK_INTERNAL_DECL void duk_heaphdr_decref_allownull ( duk_hthread * thr,
duk_heaphdr * h )

Definition at line 44680 of file duktape-1.8.0/src/duktape.c.

44687 {
44688 return;
44689 }
44690#endif
44691 if (DUK_HEAPHDR_PREDEC_REFCOUNT(h) != 0) {
44692 return;
44693 }
44694 duk_heaphdr_refzero(thr, h);
44695}
44696
44698 DUK_ASSERT(thr != NULL);
44699 DUK_ASSERT(thr->heap != NULL);
DUK_INTERNAL_DECL void duk_heaphdr_refzero(duk_hthread *thr, duk_heaphdr *h)

◆ duk_heaphdr_refcount_finalize()

DUK_INTERNAL_DECL void duk_heaphdr_refcount_finalize ( duk_hthread * thr,
duk_heaphdr * hdr )

Definition at line 44236 of file duktape-1.8.0/src/duktape.c.

44240 {
44241 duk_catcher *cat = t->catchstack + i;
44242 }
44243#endif
44244
44245 for (i = 0; i < DUK_NUM_BUILTINS; i++) {
44246 duk_heaphdr_decref_allownull(thr, (duk_heaphdr *) t->builtins[i]);
44247 }
44248
44249 duk_heaphdr_decref_allownull(thr, (duk_heaphdr *) t->resumer);
44250 }
44251}

◆ duk_heaphdr_refzero()

DUK_INTERNAL_DECL void duk_heaphdr_refzero ( duk_hthread * thr,
duk_heaphdr * h )

Definition at line 44494 of file duktape-1.8.0/src/duktape.c.

44511 {
44512 duk_heap *heap;
44513
44514 DUK_ASSERT(thr != NULL);
44515 DUK_ASSERT(h != NULL);
44516
44517 heap = thr->heap;
44518 DUK_DDD(DUK_DDDPRINT("refzero %p: %!O", (void *) h, (duk_heaphdr *) h));
44519
44520 /*
44521 * Refzero handling is skipped entirely if (1) mark-and-sweep is
44522 * running or (2) execution is paused in the debugger. The objects
44523 * are left in the heap, and will be freed by mark-and-sweep or
44524 * eventual heap destruction.
44525 *
44526 * This is necessary during mark-and-sweep because refcounts are also
44527 * updated during the sweep phase (otherwise objects referenced by a
44528 * swept object would have incorrect refcounts) which then calls here.
44529 * This could be avoided by using separate decref macros in
44530 * mark-and-sweep; however, mark-and-sweep also calls finalizers which
44531 * would use the ordinary decref macros anyway and still call this
44532 * function.
44533 *
44534 * This check must be enabled also when mark-and-sweep support has been
44535 * disabled: the flag is also used in heap destruction when running
44536 * finalizers for remaining objects, and the flag prevents objects from
44537 * being moved around in heap linked lists.
44538 */
44539
44540 /* XXX: ideally this would be just one flag (maybe a derived one) so
44541 * that a single bit test is sufficient to check the condition.
44542 */
44543#if defined(DUK_USE_DEBUGGER_SUPPORT)
44544 if (DUK_UNLIKELY(DUK_HEAP_HAS_MARKANDSWEEP_RUNNING(heap) || DUK_HEAP_IS_PAUSED(heap))) {
44545#else
44547#endif
44548 DUK_DDD(DUK_DDDPRINT("refzero handling suppressed when mark-and-sweep running, object: %p", (void *) h));
44549 return;
44550 }
44551
44553 case DUK_HTYPE_STRING:
44554 /*
44555 * Strings have no internal references but do have "weak"
44556 * references in the string cache. Also note that strings
44557 * are not on the heap_allocated list like other heap
44558 * elements.
44559 */
44560
44564 break;
44565
44566 case DUK_HTYPE_OBJECT:
44567 /*
44568 * Objects have internal references. Must finalize through
44569 * the "refzero" work list.
44570 */
44571
44573 duk__queue_refzero(heap, h);
44575 break;
DUK_LOCAL void duk__queue_refzero(duk_heap *heap, duk_heaphdr *hdr)
DUK_LOCAL void duk__refzero_free_pending(duk_hthread *thr)
DUK_INTERNAL_DECL void duk_heap_remove_any_from_heap_allocated(duk_heap *heap, duk_heaphdr *hdr)

◆ duk_hex_decode()

DUK_EXTERNAL void duk_hex_decode ( duk_context * ctx,
duk_idx_t index )

Definition at line 13453 of file duktape-1.8.0/src/duktape.c.

13470 {
13471 duk_hthread *thr = (duk_hthread *) ctx;
13472 const duk_uint8_t *inp;
13473 duk_size_t len;
13474 duk_size_t i;
13475 duk_int_t t;
13476 duk_uint8_t *buf;
13477#if defined(DUK_USE_HEX_FASTPATH)
13478 duk_int_t chk;
13479 duk_uint8_t *p;
13480 duk_size_t len_safe;
13481#endif
13482
13484
13486 inp = duk__prep_codec_arg(ctx, index, &len);
13487 DUK_ASSERT(inp != NULL || len == 0);
13488
13489 if (len & 0x01) {
13490 goto type_error;
13491 }
13492
13493 /* Fixed buffer, no zeroing because we'll fill all the data. */
13494 buf = (duk_uint8_t *) duk_push_buffer_raw(ctx, len / 2, DUK_BUF_FLAG_NOZERO /*flags*/);
13495 DUK_ASSERT(buf != NULL);
13496
13497#if defined(DUK_USE_HEX_FASTPATH)
13498 p = buf;
13499 len_safe = len & ~0x07U;
13500 for (i = 0; i < len_safe; i += 8) {
13501 t = ((duk_int_t) duk_hex_dectab_shift4[inp[i]]) |
13502 ((duk_int_t) duk_hex_dectab[inp[i + 1]]);
13503 chk = t;
13504 p[0] = (duk_uint8_t) t;
13505 t = ((duk_int_t) duk_hex_dectab_shift4[inp[i + 2]]) |
13506 ((duk_int_t) duk_hex_dectab[inp[i + 3]]);
13507 chk |= t;
13508 p[1] = (duk_uint8_t) t;
13509 t = ((duk_int_t) duk_hex_dectab_shift4[inp[i + 4]]) |
13510 ((duk_int_t) duk_hex_dectab[inp[i + 5]]);
13511 chk |= t;
13512 p[2] = (duk_uint8_t) t;
13513 t = ((duk_int_t) duk_hex_dectab_shift4[inp[i + 6]]) |
13514 ((duk_int_t) duk_hex_dectab[inp[i + 7]]);
13515 chk |= t;
13516 p[3] = (duk_uint8_t) t;
13517 p += 4;
13518
13519 /* Check if any lookup above had a negative result. */
13520 if (DUK_UNLIKELY(chk < 0)) {
13521 goto type_error;
13522 }
13523 }
13524 for (; i < len; i += 2) {
13525 t = (((duk_int_t) duk_hex_dectab[inp[i]]) << 4) |
13526 ((duk_int_t) duk_hex_dectab[inp[i + 1]]);
13527 if (DUK_UNLIKELY(t < 0)) {
13528 goto type_error;
13529 }
13530 *p++ = (duk_uint8_t) t;
13531 }
13532#else /* DUK_USE_HEX_FASTPATH */
13533 for (i = 0; i < len; i += 2) {
13534 /* For invalid characters the value -1 gets extended to
13535 * at least 16 bits. If either nybble is invalid, the
DUK_EXTERNAL void * duk_push_buffer_raw(duk_context *ctx, duk_size_t size, duk_small_uint_t flags)
DUK_INTERNAL const duk_int16_t duk_hex_dectab_shift4[256]

◆ duk_hex_encode()

DUK_EXTERNAL const char * duk_hex_encode ( duk_context * ctx,
duk_idx_t index )

Definition at line 13397 of file duktape-1.8.0/src/duktape.c.

13401 {
13402 goto type_error;
13403 }
13404
13405 /* XXX: convert to fixed buffer? */
13406 (void) duk_resize_buffer(ctx, -1, (duk_size_t) (dst_final - dst));
13407 duk_replace(ctx, index);
13408 return;
13409
13410 type_error:
13412}
13413
13415 const duk_uint8_t *inp;
13416 duk_size_t len;
13417 duk_size_t i;
13418 duk_uint8_t *buf;
13419 const char *ret;
13420#if defined(DUK_USE_HEX_FASTPATH)
13421 duk_size_t len_safe;
13422 duk_uint16_t *p16;
13423#endif
13424
13426
13428 inp = duk__prep_codec_arg(ctx, index, &len);
13429 DUK_ASSERT(inp != NULL || len == 0);
13430
13431 /* Fixed buffer, no zeroing because we'll fill all the data. */
13432 buf = (duk_uint8_t *) duk_push_buffer_raw(ctx, len * 2, DUK_BUF_FLAG_NOZERO /*flags*/);
13433 DUK_ASSERT(buf != NULL);
13434
13435#if defined(DUK_USE_HEX_FASTPATH)
13436 DUK_ASSERT((((duk_size_t) buf) & 0x01U) == 0); /* pointer is aligned, guaranteed for fixed buffer */
13437 p16 = (duk_uint16_t *) (void *) buf;
13438 len_safe = len & ~0x03U;
13439 for (i = 0; i < len_safe; i += 4) {
13440 p16[0] = duk_hex_enctab[inp[i]];
13441 p16[1] = duk_hex_enctab[inp[i + 1]];
13442 p16[2] = duk_hex_enctab[inp[i + 2]];
13443 p16[3] = duk_hex_enctab[inp[i + 3]];
13444 p16 += 4;
13445 }
13446 for (; i < len; i++) {
13447 *p16++ = duk_hex_enctab[inp[i]];
13448 }
13449#else /* DUK_USE_HEX_FASTPATH */
13450 for (i = 0; i < len; i++) {
#define DUK_STR_DECODE_FAILED
DUK_EXTERNAL void * duk_resize_buffer(duk_context *ctx, duk_idx_t index, duk_size_t new_size)

◆ duk_hnativefunction_alloc()

DUK_INTERNAL_DECL duk_hnativefunction * duk_hnativefunction_alloc ( duk_heap * heap,
duk_uint_t hobject_flags )

Definition at line 46281 of file duktape-1.8.0/src/duktape.c.

◆ duk_hobject_alloc()

DUK_INTERNAL_DECL duk_hobject * duk_hobject_alloc ( duk_heap * heap,
duk_uint_t hobject_flags )

Definition at line 46236 of file duktape-1.8.0/src/duktape.c.

46236 : empty objects consume a minimum
46237 * amount of memory. Further, an initial allocation might fail and cause
46238 * 'obj' to "leak" (require a mark-and-sweep) since it is not reachable yet.
46239 */
46240}
46241
46242/*
46243 * Allocate an duk_hobject.
46244 *
46245 * The allocated object has no allocation for properties; the caller may
46246 * want to force a resize if a desired size is known.
46247 *
46248 * The allocated object has zero reference count and is not reachable.
46249 * The caller MUST make the object reachable and increase its reference
46250 * count before invoking any operation that might require memory allocation.
46251 */
46252
46254 duk_hobject *res;
46255
DUK_INTERNAL_DECL duk_hobject * duk_hobject_alloc(duk_heap *heap, duk_uint_t hobject_flags)

◆ duk_hobject_compact_props()

DUK_INTERNAL_DECL void duk_hobject_compact_props ( duk_hthread * thr,
duk_hobject * obj )

Definition at line 48465 of file duktape-1.8.0/src/duktape.c.

48482 {
48483 duk_uint32_t e_size; /* currently used -> new size */
48484 duk_uint32_t a_size; /* currently required */
48485 duk_uint32_t a_used; /* actually used */
48486 duk_uint32_t h_size;
48487 duk_bool_t abandon_array;
48488
48489 DUK_ASSERT(thr != NULL);
48490 DUK_ASSERT(obj != NULL);
48491
48492#if defined(DUK_USE_ROM_OBJECTS)
48494 DUK_DD(DUK_DDPRINT("ignore attempt to compact a rom object"));
48495 return;
48496 }
48497#endif
48498
48499 e_size = duk__count_used_e_keys(thr, obj);
48500 duk__compute_a_stats(thr, obj, &a_used, &a_size);
48501
48502 DUK_DD(DUK_DDPRINT("compacting hobject, used e keys %ld, used a keys %ld, min a size %ld, "
48503 "resized array density would be: %ld/%ld = %lf",
48504 (long) e_size, (long) a_used, (long) a_size,
48505 (long) a_used, (long) a_size,
48506 (double) a_used / (double) a_size));
48507
48508 if (duk__abandon_array_density_check(a_used, a_size)) {
48509 DUK_DD(DUK_DDPRINT("decided to abandon array during compaction, a_used=%ld, a_size=%ld",
48510 (long) a_used, (long) a_size));
48511 abandon_array = 1;
48512 e_size += a_used;
48513 a_size = 0;
48514 } else {
48515 DUK_DD(DUK_DDPRINT("decided to keep array during compaction"));
48516 abandon_array = 0;

Referenced by duk__compact_object_list().

◆ duk_hobject_define_accessor_internal()

DUK_INTERNAL_DECL void duk_hobject_define_accessor_internal ( duk_hthread * thr,
duk_hobject * obj,
duk_hstring * key,
duk_hobject * getter,
duk_hobject * setter,
duk_small_uint_t propflags )

Definition at line 52113 of file duktape-1.8.0/src/duktape.c.

52130 {
52131 duk_context *ctx = (duk_context *) thr;
52132 duk_int_t e_idx;
52133 duk_int_t h_idx;
52134
52135 DUK_DDD(DUK_DDDPRINT("define new accessor (internal): thr=%p, obj=%!O, key=%!O, "
52136 "getter=%!O, setter=%!O, flags=0x%02lx",
52137 (void *) thr, (duk_heaphdr *) obj, (duk_heaphdr *) key,
52138 (duk_heaphdr *) getter, (duk_heaphdr *) setter,
52139 (unsigned long) propflags));
52140
52141 DUK_ASSERT(thr != NULL);
52142 DUK_ASSERT(thr->heap != NULL);
52143 DUK_ASSERT(obj != NULL);
52144 DUK_ASSERT(key != NULL);
52145 DUK_ASSERT((propflags & ~DUK_PROPDESC_FLAGS_MASK) == 0);
52146 /* setter and/or getter may be NULL */
52148

◆ duk_hobject_define_property_helper()

DUK_INTERNAL_DECL void duk_hobject_define_property_helper ( duk_context * ctx,
duk_uint_t defprop_flags,
duk_hobject * obj,
duk_hstring * key,
duk_idx_t idx_value,
duk_hobject * get,
duk_hobject * set )

Definition at line 52429 of file duktape-1.8.0/src/duktape.c.

52431 : Ecmascript compliant [[DefineOwnProperty]](P, Desc, Throw) is not
52432 * implemented directly, but Object.defineProperty() serves its purpose.
52433 * We don't need the [[DefineOwnProperty]] internally and we don't have a
52434 * property descriptor with 'missing values' so it's easier to avoid it
52435 * entirely.
52436 *
52437 * Note: this is only called for actual objects, not primitive values.
52438 * This must support virtual properties for full objects (e.g. Strings)
52439 * but not for plain values (e.g. strings). Lightfuncs, even though
52440 * primitive in a sense, are treated like objects and accepted as target
52441 * values.
52442 */
52443
52444/* XXX: this is a major target for size optimization */
52445DUK_INTERNAL
52446void duk_hobject_define_property_helper(duk_context *ctx,
52447 duk_uint_t defprop_flags,
52448 duk_hobject *obj,
52449 duk_hstring *key,
52450 duk_idx_t idx_value,
52451 duk_hobject *get,
52452 duk_hobject *set) {
52453 duk_hthread *thr = (duk_hthread *) ctx;
52454 duk_uint32_t arr_idx;
52455 duk_tval tv;
52456 duk_bool_t has_enumerable;
52457 duk_bool_t has_configurable;
52458 duk_bool_t has_writable;
52459 duk_bool_t has_value;
52460 duk_bool_t has_get;
52461 duk_bool_t has_set;
52462 duk_bool_t is_enumerable;
52463 duk_bool_t is_configurable;
52464 duk_bool_t is_writable;
52465 duk_bool_t throw_flag;
52466 duk_bool_t force_flag;
52467 duk_small_uint_t new_flags;
52468 duk_propdesc curr;
52469 duk_uint32_t arridx_new_array_length; /* != 0 => post-update for array 'length' (used when key is an array index) */
52470 duk_uint32_t arrlen_old_len;
52471 duk_uint32_t arrlen_new_len;
52472 duk_bool_t pending_write_protect;
52473
52474 DUK_ASSERT(thr != NULL);
52475 DUK_ASSERT(thr->heap != NULL);
52476 DUK_ASSERT(ctx != NULL);
52477 DUK_ASSERT(obj != NULL);
52478 DUK_ASSERT(key != NULL);
52479 /* idx_value may be < 0 (no value), set and get may be NULL */
52480
52481 DUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);
52482
52483 /* All the flags fit in 16 bits, so will fit into duk_bool_t. */
52484
52485 has_writable = (defprop_flags & DUK_DEFPROP_HAVE_WRITABLE);
52486 has_enumerable = (defprop_flags & DUK_DEFPROP_HAVE_ENUMERABLE);
52487 has_configurable = (defprop_flags & DUK_DEFPROP_HAVE_CONFIGURABLE);
52488 has_value = (defprop_flags & DUK_DEFPROP_HAVE_VALUE);
52489 has_get = (defprop_flags & DUK_DEFPROP_HAVE_GETTER);
52490 has_set = (defprop_flags & DUK_DEFPROP_HAVE_SETTER);
52491 is_writable = (defprop_flags & DUK_DEFPROP_WRITABLE);
52492 is_enumerable = (defprop_flags & DUK_DEFPROP_ENUMERABLE);
52493 is_configurable = (defprop_flags & DUK_DEFPROP_CONFIGURABLE);
52494 throw_flag = 1; /* Object.defineProperty() calls [[DefineOwnProperty]] with Throw=true */
52495 force_flag = (defprop_flags & DUK_DEFPROP_FORCE);
52496
52497 arr_idx = DUK_HSTRING_GET_ARRIDX_SLOW(key);
52498
52499 arridx_new_array_length = 0;
52500 pending_write_protect = 0;
52501 arrlen_old_len = 0;
52502 arrlen_new_len = 0;
52503
52504 DUK_DDD(DUK_DDDPRINT("has_enumerable=%ld is_enumerable=%ld "
52505 "has_configurable=%ld is_configurable=%ld "
52506 "has_writable=%ld is_writable=%ld "
52507 "has_value=%ld value=%!T "
52508 "has_get=%ld get=%p=%!O "
52509 "has_set=%ld set=%p=%!O "
52510 "arr_idx=%ld",
52511 (long) has_enumerable, (long) is_enumerable,
52512 (long) has_configurable, (long) is_configurable,
52513 (long) has_writable, (long) is_writable,
52514 (long) has_value, (duk_tval *) (idx_value >= 0 ? duk_get_tval(ctx, idx_value) : NULL),
52515 (long) has_get, (void *) get, (duk_heaphdr *) get,
52516 (long) has_set, (void *) set, (duk_heaphdr *) set,
52517 (long) arr_idx));
52518
52519 /*
52520 * Array exotic behaviors can be implemented at this point. The local variables
52521 * are essentially a 'value copy' of the input descriptor (Desc), which is modified
52522 * by the Array [[DefineOwnProperty]] (E5 Section 15.4.5.1).
52523 */
52524
52525 if (!DUK_HOBJECT_HAS_EXOTIC_ARRAY(obj)) {
52526 goto skip_array_exotic;
52527 }
52528
52529 if (key == DUK_HTHREAD_STRING_LENGTH(thr)) {
52530 /* E5 Section 15.4.5.1, step 3, steps a - i are implemented here, j - n at the end */
52531 if (!has_value) {
52532 DUK_DDD(DUK_DDDPRINT("exotic array behavior for 'length', but no value in descriptor -> normal behavior"));
52533 goto skip_array_exotic;
52534 }
52535
52536 DUK_DDD(DUK_DDDPRINT("exotic array behavior for 'length', value present in descriptor -> exotic behavior"));
52537
52538 /*
52539 * Get old and new length
52540 */
52541
52542 /* Note: reuse 'curr' as a temp propdesc */
52543 arrlen_old_len = duk__get_old_array_length(thr, obj, &curr);
52544
52545 duk_dup(ctx, idx_value);
52546 arrlen_new_len = duk__to_new_array_length_checked(thr);
52547 duk_push_u32(ctx, arrlen_new_len);
52548 duk_replace(ctx, idx_value); /* step 3.e: replace 'Desc.[[Value]]' */
52549
52550 DUK_DDD(DUK_DDDPRINT("old_len=%ld, new_len=%ld", (long) arrlen_old_len, (long) arrlen_new_len));
52551
52552 if (arrlen_new_len >= arrlen_old_len) {
52553 /* standard behavior, step 3.f.i */
52554 DUK_DDD(DUK_DDDPRINT("new length is same or higher as previous => standard behavior"));
52555 goto skip_array_exotic;
52556 }
52557 DUK_DDD(DUK_DDDPRINT("new length is smaller than previous => exotic post behavior"));
52558
52559 /* XXX: consolidated algorithm step 15.f -> redundant? */
52560 if (!(curr.flags & DUK_PROPDESC_FLAG_WRITABLE) && !force_flag) {
52561 /* Note: 'curr' refers to 'length' propdesc */
52562 goto fail_not_writable_array_length;
52563 }
52564
52565 /* steps 3.h and 3.i */
52566 if (has_writable && !is_writable) {
52567 DUK_DDD(DUK_DDDPRINT("desc writable is false, force it back to true, and flag pending write protect"));
52568 is_writable = 1;
52569 pending_write_protect = 1;
52570 }
52571
52572 /* remaining actual steps are carried out if standard DefineOwnProperty succeeds */
52573 } else if (arr_idx != DUK__NO_ARRAY_INDEX) {
52574 /* XXX: any chance of unifying this with the 'length' key handling? */
52575
52576 /* E5 Section 15.4.5.1, step 4 */
52577 duk_uint32_t old_len;
52578
52579 /* Note: use 'curr' as a temp propdesc */
52580 old_len = duk__get_old_array_length(thr, obj, &curr);
52581
52582 if (arr_idx >= old_len) {
52583 DUK_DDD(DUK_DDDPRINT("defineProperty requires array length update "
52584 "(arr_idx=%ld, old_len=%ld)",
52585 (long) arr_idx, (long) old_len));
52586
52587 if (!(curr.flags & DUK_PROPDESC_FLAG_WRITABLE)) {
52588 /* Note: 'curr' refers to 'length' propdesc */
52589 goto fail_not_writable_array_length;
52590 }
52591
52592 /* actual update happens once write has been completed without
52593 * error below.
52594 */
52595 DUK_ASSERT(arr_idx != 0xffffffffUL);
52596 arridx_new_array_length = arr_idx + 1;
52597 } else {
52598 DUK_DDD(DUK_DDDPRINT("defineProperty does not require length update "
52599 "(arr_idx=%ld, old_len=%ld) -> standard behavior",
52600 (long) arr_idx, (long) old_len));
52601 }
52602 }
52603 skip_array_exotic:
52604
52605 /* XXX: There is currently no support for writing buffer object
52606 * indexed elements here. Attempt to do so will succeed and
52607 * write a concrete property into the buffer object. This should
52608 * be fixed at some point but because buffers are a custom feature
52609 * anyway, this is relatively unimportant.
52610 */
52611
52612 /*
52613 * Actual Object.defineProperty() default algorithm.
52614 */
52615
52616 /*
52617 * First check whether property exists; if not, simple case. This covers
52618 * steps 1-4.
52619 */
52620
52621 if (!duk__get_own_propdesc_raw(thr, obj, key, arr_idx, &curr, DUK_GETDESC_FLAG_PUSH_VALUE)) {
52622 DUK_DDD(DUK_DDDPRINT("property does not exist"));
52623
52624 if (!DUK_HOBJECT_HAS_EXTENSIBLE(obj) && !force_flag) {
52625 goto fail_not_extensible;
52626 }
52627
52628 /* XXX: share final setting code for value and flags? difficult because
52629 * refcount code is different. Share entry allocation? But can't allocate
52630 * until array index checked.
52631 */
52632
52633 /* steps 4.a and 4.b are tricky */
52634 if (has_set || has_get) {
52635 duk_int_t e_idx;
52636
52637 DUK_DDD(DUK_DDDPRINT("create new accessor property"));
52638
52639 DUK_ASSERT(has_set || set == NULL);
52640 DUK_ASSERT(has_get || get == NULL);
52641 DUK_ASSERT(!has_value);
52642 DUK_ASSERT(!has_writable);
52643
52644 new_flags = DUK_PROPDESC_FLAG_ACCESSOR; /* defaults, E5 Section 8.6.1, Table 7 */
52645 if (has_enumerable && is_enumerable) {
52646 new_flags |= DUK_PROPDESC_FLAG_ENUMERABLE;
52647 }
52648 if (has_configurable && is_configurable) {
52649 new_flags |= DUK_PROPDESC_FLAG_CONFIGURABLE;
52650 }
52651
52652 if (arr_idx != DUK__NO_ARRAY_INDEX && DUK_HOBJECT_HAS_ARRAY_PART(obj)) {
52653 DUK_DDD(DUK_DDDPRINT("accessor cannot go to array part, abandon array"));
52655 }
52656
52657 /* write to entry part */
52658 e_idx = duk__alloc_entry_checked(thr, obj, key);
52659 DUK_ASSERT(e_idx >= 0);
52660
52661 DUK_HOBJECT_E_SET_VALUE_GETTER(thr->heap, obj, e_idx, get);
52662 DUK_HOBJECT_E_SET_VALUE_SETTER(thr->heap, obj, e_idx, set);
52665
52666 DUK_HOBJECT_E_SET_FLAGS(thr->heap, obj, e_idx, new_flags);
52667 goto success_exotics;
52668 } else {
52669 duk_int_t e_idx;
52670 duk_tval *tv2;
52671
52672 DUK_DDD(DUK_DDDPRINT("create new data property"));
52673
52674 DUK_ASSERT(!has_set);
52675 DUK_ASSERT(!has_get);
52676
52677 new_flags = 0; /* defaults, E5 Section 8.6.1, Table 7 */
52678 if (has_writable && is_writable) {
52679 new_flags |= DUK_PROPDESC_FLAG_WRITABLE;
52680 }
52681 if (has_enumerable && is_enumerable) {
52682 new_flags |= DUK_PROPDESC_FLAG_ENUMERABLE;
52683 }
52684 if (has_configurable && is_configurable) {
52685 new_flags |= DUK_PROPDESC_FLAG_CONFIGURABLE;
52686 }
52687 if (has_value) {
52688 duk_tval *tv_tmp = duk_require_tval(ctx, idx_value);
52689 DUK_TVAL_SET_TVAL(&tv, tv_tmp);
52690 } else {
52691 DUK_TVAL_SET_UNDEFINED(&tv); /* default value */
52692 }
52693
52694 if (arr_idx != DUK__NO_ARRAY_INDEX && DUK_HOBJECT_HAS_ARRAY_PART(obj)) {
52695 if (new_flags == DUK_PROPDESC_FLAGS_WEC) {
52696#if 0
52697 DUK_DDD(DUK_DDDPRINT("new data property attributes match array defaults, attempt to write to array part"));
52698 /* may become sparse...*/
52699#endif
52700 /* XXX: handling for array part missing now; this doesn't affect
52701 * compliance but causes array entry writes using defineProperty()
52702 * to always abandon array part.
52703 */
52704 }
52705 DUK_DDD(DUK_DDDPRINT("new data property cannot go to array part, abandon array"));
52707 /* fall through */
52708 }
52709
52710 /* write to entry part */
52711 e_idx = duk__alloc_entry_checked(thr, obj, key);
52712 DUK_ASSERT(e_idx >= 0);
52713 tv2 = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, e_idx);
52714 DUK_TVAL_SET_TVAL(tv2, &tv);
52715 DUK_TVAL_INCREF(thr, tv2);
52716
52717 DUK_HOBJECT_E_SET_FLAGS(thr->heap, obj, e_idx, new_flags);
52718 goto success_exotics;
52719 }
52721 }
52722
52723 /* we currently assume virtual properties are not configurable (as none of them are) */
52724 DUK_ASSERT((curr.e_idx >= 0 || curr.a_idx >= 0) || !(curr.flags & DUK_PROPDESC_FLAG_CONFIGURABLE));
52725
52726 /* [obj key desc value get set curr_value] */
52727
52728 /*
52729 * Property already exists. Steps 5-6 detect whether any changes need
52730 * to be made.
52731 */
52732
52733 if (has_enumerable) {
52734 if (is_enumerable) {
52735 if (!(curr.flags & DUK_PROPDESC_FLAG_ENUMERABLE)) {
52736 goto need_check;
52737 }
52738 } else {
52739 if (curr.flags & DUK_PROPDESC_FLAG_ENUMERABLE) {
52740 goto need_check;
52741 }
52742 }
52743 }
52744 if (has_configurable) {
52745 if (is_configurable) {
52746 if (!(curr.flags & DUK_PROPDESC_FLAG_CONFIGURABLE)) {
52747 goto need_check;
52748 }
52749 } else {
52750 if (curr.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) {
52751 goto need_check;
52752 }
52753 }
52754 }
52755 if (has_value) {
52756 duk_tval *tmp1;
52757 duk_tval *tmp2;
52758
52759 /* attempt to change from accessor to data property */
52760 if (curr.flags & DUK_PROPDESC_FLAG_ACCESSOR) {
52761 goto need_check;
52762 }
52763
52764 tmp1 = duk_require_tval(ctx, -1); /* curr value */
52765 tmp2 = duk_require_tval(ctx, idx_value); /* new value */
52766 if (!duk_js_samevalue(tmp1, tmp2)) {
52767 goto need_check;
52768 }
52769 }
52770 if (has_writable) {
52771 /* attempt to change from accessor to data property */
52772 if (curr.flags & DUK_PROPDESC_FLAG_ACCESSOR) {
52773 goto need_check;
52774 }
52775
52776 if (is_writable) {
52777 if (!(curr.flags & DUK_PROPDESC_FLAG_WRITABLE)) {
52778 goto need_check;
52779 }
52780 } else {
52781 if (curr.flags & DUK_PROPDESC_FLAG_WRITABLE) {
52782 goto need_check;
52783 }
52784 }
52785 }
52786 if (has_set) {
52787 if (curr.flags & DUK_PROPDESC_FLAG_ACCESSOR) {
52788 if (set != curr.set) {
52789 goto need_check;
52790 }
52791 } else {
52792 goto need_check;
52793 }
52794 }
52795 if (has_get) {
52796 if (curr.flags & DUK_PROPDESC_FLAG_ACCESSOR) {
52797 if (get != curr.get) {
52798 goto need_check;
52799 }
52800 } else {
52801 goto need_check;
52802 }
52803 }
52804
52805 /* property exists, either 'desc' is empty, or all values
52806 * match (SameValue)
52807 */
52808 goto success_no_exotics;
52809
52810 need_check:
52811
52812 /*
52813 * Some change(s) need to be made. Steps 7-11.
52814 */
52815
52816 /* shared checks for all descriptor types */
52817 if (!(curr.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) && !force_flag) {
52818 if (has_configurable && is_configurable) {
52819 goto fail_not_configurable;
52820 }
52821 if (has_enumerable) {
52822 if (curr.flags & DUK_PROPDESC_FLAG_ENUMERABLE) {
52823 if (!is_enumerable) {
52824 goto fail_not_configurable;
52825 }
52826 } else {
52827 if (is_enumerable) {
52828 goto fail_not_configurable;
52829 }
52830 }
52831 }
52832 }
52833
52834 /* Reject attempt to change virtual properties: not part of the
52835 * standard algorithm, applies currently to e.g. virtual index
52836 * properties of buffer objects (which are virtual but writable).
52837 * (Cannot "force" modification of a virtual property.)
52838 */
52839 if (curr.flags & DUK_PROPDESC_FLAG_VIRTUAL) {
52840 goto fail_virtual;
52841 }
52842
52843 /* Reject attempt to change a read-only object. */
52844#if defined(DUK_USE_ROM_OBJECTS)
52846 DUK_DD(DUK_DDPRINT("attempt to define property on read-only target object"));
52847 goto fail_not_configurable;
52848 }
52849#endif
52850
52851 /* descriptor type specific checks */
52852 if (has_set || has_get) {
52853 /* IsAccessorDescriptor(desc) == true */
52854 DUK_ASSERT(!has_writable);
52855 DUK_ASSERT(!has_value);
52856
52857 if (curr.flags & DUK_PROPDESC_FLAG_ACCESSOR) {
52858 /* curr and desc are accessors */
52859 if (!(curr.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) && !force_flag) {
52860 if (has_set && set != curr.set) {
52861 goto fail_not_configurable;
52862 }
52863 if (has_get && get != curr.get) {
52864 goto fail_not_configurable;
52865 }
52866 }
52867 } else {
52868 duk_bool_t rc;
52869 duk_tval *tv1;
52870 duk_tval tv_tmp;
52871
52872 /* curr is data, desc is accessor */
52873 if (!(curr.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) && !force_flag) {
52874 goto fail_not_configurable;
52875 }
52876
52877 DUK_DDD(DUK_DDDPRINT("convert property to accessor property"));
52878 if (curr.a_idx >= 0) {
52879 DUK_DDD(DUK_DDDPRINT("property to convert is stored in an array entry, abandon array and re-lookup"));
52881 duk_pop(ctx); /* remove old value */
52882 rc = duk__get_own_propdesc_raw(thr, obj, key, arr_idx, &curr, DUK_GETDESC_FLAG_PUSH_VALUE);
52883 DUK_UNREF(rc);
52884 DUK_ASSERT(rc != 0);
52885 DUK_ASSERT(curr.e_idx >= 0 && curr.a_idx < 0);
52886 }
52887
52888 DUK_ASSERT(!DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, obj, curr.e_idx));
52889
52890 /* Avoid side effects that might disturb curr.e_idx until
52891 * we're done editing the slot.
52892 */
52893 tv1 = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, curr.e_idx);
52894 DUK_TVAL_SET_TVAL(&tv_tmp, tv1);
52896
52897 DUK_HOBJECT_E_SET_VALUE_GETTER(thr->heap, obj, curr.e_idx, NULL);
52898 DUK_HOBJECT_E_SET_VALUE_SETTER(thr->heap, obj, curr.e_idx, NULL);
52899 DUK_HOBJECT_E_SLOT_CLEAR_WRITABLE(thr->heap, obj, curr.e_idx);
52900 DUK_HOBJECT_E_SLOT_SET_ACCESSOR(thr->heap, obj, curr.e_idx);
52901
52902 DUK_DDD(DUK_DDDPRINT("flags after data->accessor conversion: 0x%02lx",
52903 (unsigned long) DUK_HOBJECT_E_GET_FLAGS(thr->heap, obj, curr.e_idx)));
52904
52905 DUK_TVAL_DECREF(thr, &tv_tmp); /* side effects */
52906
52907 /* re-lookup to update curr.flags
52908 * XXX: would be faster to update directly
52909 */
52910 duk_pop(ctx); /* remove old value */
52911 rc = duk__get_own_propdesc_raw(thr, obj, key, arr_idx, &curr, DUK_GETDESC_FLAG_PUSH_VALUE);
52912 DUK_UNREF(rc);
52913 DUK_ASSERT(rc != 0);
52914 }
52915 } else if (has_value || has_writable) {
52916 /* IsDataDescriptor(desc) == true */
52917 DUK_ASSERT(!has_set);
52918 DUK_ASSERT(!has_get);
52919
52920 if (curr.flags & DUK_PROPDESC_FLAG_ACCESSOR) {
52921 duk_bool_t rc;
52922 duk_hobject *h_get;
52923 duk_hobject *h_set;
52924
52925 /* curr is accessor, desc is data */
52926 if (!(curr.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) && !force_flag) {
52927 goto fail_not_configurable;
52928 }
52929
52930 /* curr is accessor -> cannot be in array part */
52931 DUK_ASSERT(curr.e_idx >= 0 && curr.a_idx < 0);
52932
52933 DUK_DDD(DUK_DDDPRINT("convert property to data property"));
52934
52935 /* Avoid side effects that might disturb curr.e_idx until
52936 * we're done editing the slot.
52937 */
52938 DUK_ASSERT(DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, obj, curr.e_idx));
52939 h_get = DUK_HOBJECT_E_GET_VALUE_GETTER(thr->heap, obj, curr.e_idx);
52940 DUK_HOBJECT_E_SET_VALUE_GETTER(thr->heap, obj, curr.e_idx, NULL);
52941 h_set = DUK_HOBJECT_E_GET_VALUE_SETTER(thr->heap, obj, curr.e_idx);
52942 DUK_HOBJECT_E_SET_VALUE_SETTER(thr->heap, obj, curr.e_idx, NULL);
52943
52944 DUK_TVAL_SET_UNDEFINED(DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, curr.e_idx));
52945 DUK_HOBJECT_E_SLOT_CLEAR_WRITABLE(thr->heap, obj, curr.e_idx);
52946 DUK_HOBJECT_E_SLOT_CLEAR_ACCESSOR(thr->heap, obj, curr.e_idx);
52947
52948 DUK_DDD(DUK_DDDPRINT("flags after accessor->data conversion: 0x%02lx",
52949 (unsigned long) DUK_HOBJECT_E_GET_FLAGS(thr->heap, obj, curr.e_idx)));
52950
52951 DUK_HOBJECT_DECREF_ALLOWNULL(thr, h_get); /* side effects */
52952 DUK_HOBJECT_DECREF_ALLOWNULL(thr, h_set); /* side effects */
52953
52954 /* re-lookup to update curr.flags
52955 * XXX: would be faster to update directly
52956 */
52957 duk_pop(ctx); /* remove old value */
52958 rc = duk__get_own_propdesc_raw(thr, obj, key, arr_idx, &curr, DUK_GETDESC_FLAG_PUSH_VALUE);
52959 DUK_UNREF(rc);
52960 DUK_ASSERT(rc != 0);
52961 } else {
52962 /* curr and desc are data */
52963 if (!(curr.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) && !force_flag) {
52964 if (!(curr.flags & DUK_PROPDESC_FLAG_WRITABLE) && has_writable && is_writable) {
52965 goto fail_not_configurable;
52966 }
52967 /* Note: changing from writable to non-writable is OK */
52968 if (!(curr.flags & DUK_PROPDESC_FLAG_WRITABLE) && has_value) {
52969 duk_tval *tmp1 = duk_require_tval(ctx, -1); /* curr value */
52970 duk_tval *tmp2 = duk_require_tval(ctx, idx_value); /* new value */
52971 if (!duk_js_samevalue(tmp1, tmp2)) {
52972 goto fail_not_configurable;
52973 }
52974 }
52975 }
52976 }
52977 } else {
52978 /* IsGenericDescriptor(desc) == true; this means in practice that 'desc'
52979 * only has [[Enumerable]] or [[Configurable]] flag updates, which are
52980 * allowed at this point.
52981 */
52982
52983 DUK_ASSERT(!has_value && !has_writable && !has_get && !has_set);
52984 }
52985
52986 /*
52987 * Start doing property attributes updates. Steps 12-13.
52988 *
52989 * Start by computing new attribute flags without writing yet.
52990 * Property type conversion is done above if necessary.
52991 */
52992
52993 new_flags = curr.flags;
52994
52995 if (has_enumerable) {
52996 if (is_enumerable) {
52997 new_flags |= DUK_PROPDESC_FLAG_ENUMERABLE;
52998 } else {
52999 new_flags &= ~DUK_PROPDESC_FLAG_ENUMERABLE;
53000 }
53001 }
53002 if (has_configurable) {
53003 if (is_configurable) {
53004 new_flags |= DUK_PROPDESC_FLAG_CONFIGURABLE;
53005 } else {
53006 new_flags &= ~DUK_PROPDESC_FLAG_CONFIGURABLE;
53007 }
53008 }
53009 if (has_writable) {
53010 if (is_writable) {
53011 new_flags |= DUK_PROPDESC_FLAG_WRITABLE;
53012 } else {
53013 new_flags &= ~DUK_PROPDESC_FLAG_WRITABLE;
53014 }
53015 }
53016
53017 /* XXX: write protect after flag? -> any chance of handling it here? */
53018
53019 DUK_DDD(DUK_DDDPRINT("new flags that we want to write: 0x%02lx",
53020 (unsigned long) new_flags));
53021
53022 /*
53023 * Check whether we need to abandon an array part (if it exists)
53024 */
53025
53026 if (curr.a_idx >= 0) {
53027 duk_bool_t rc;
53028
53029 DUK_ASSERT(curr.e_idx < 0);
53030
53031 if (new_flags == DUK_PROPDESC_FLAGS_WEC) {
53032 duk_tval *tv1, *tv2;
53033
53034 DUK_DDD(DUK_DDDPRINT("array index, new property attributes match array defaults, update in-place"));
53035
53036 DUK_ASSERT(curr.flags == DUK_PROPDESC_FLAGS_WEC); /* must have been, since in array part */
53037 DUK_ASSERT(!has_set);
53038 DUK_ASSERT(!has_get);
53039
53040 tv2 = duk_require_tval(ctx, idx_value);
53041 tv1 = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, curr.a_idx);
53042 DUK_TVAL_SET_TVAL_UPDREF(thr, tv1, tv2); /* side effects */
53043 goto success_exotics;
53044 }
53045
53046 DUK_DDD(DUK_DDDPRINT("array index, new property attributes do not match array defaults, abandon array and re-lookup"));
53048 duk_pop(ctx); /* remove old value */
53049 rc = duk__get_own_propdesc_raw(thr, obj, key, arr_idx, &curr, DUK_GETDESC_FLAG_PUSH_VALUE);
53050 DUK_UNREF(rc);
53051 DUK_ASSERT(rc != 0);
53052 DUK_ASSERT(curr.e_idx >= 0 && curr.a_idx < 0);
53053 }
53054
53055 DUK_DDD(DUK_DDDPRINT("updating existing property in entry part"));
53056
53057 /* array case is handled comprehensively above */
53058 DUK_ASSERT(curr.e_idx >= 0 && curr.a_idx < 0);
53059
53060 DUK_DDD(DUK_DDDPRINT("update existing property attributes"));
53061 DUK_HOBJECT_E_SET_FLAGS(thr->heap, obj, curr.e_idx, new_flags);
53062
53063 if (has_set) {
53064 duk_hobject *tmp;
53065
53066 DUK_DDD(DUK_DDDPRINT("update existing property setter"));
53067 DUK_ASSERT(DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, obj, curr.e_idx));
53068
53069 tmp = DUK_HOBJECT_E_GET_VALUE_SETTER(thr->heap, obj, curr.e_idx);
53070 DUK_UNREF(tmp);
53071 DUK_HOBJECT_E_SET_VALUE_SETTER(thr->heap, obj, curr.e_idx, set);
53073 DUK_HOBJECT_DECREF_ALLOWNULL(thr, tmp); /* side effects */
53074 }
53075 if (has_get) {
53076 duk_hobject *tmp;
53077
53078 DUK_DDD(DUK_DDDPRINT("update existing property getter"));
53079 DUK_ASSERT(DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, obj, curr.e_idx));
53080
53081 tmp = DUK_HOBJECT_E_GET_VALUE_GETTER(thr->heap, obj, curr.e_idx);
53082 DUK_UNREF(tmp);
53083 DUK_HOBJECT_E_SET_VALUE_GETTER(thr->heap, obj, curr.e_idx, get);
53085 DUK_HOBJECT_DECREF_ALLOWNULL(thr, tmp); /* side effects */
53086 }
53087 if (has_value) {
53088 duk_tval *tv1, *tv2;
53089
53090 DUK_DDD(DUK_DDDPRINT("update existing property value"));
53091 DUK_ASSERT(!DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, obj, curr.e_idx));
53092
53093 tv2 = duk_require_tval(ctx, idx_value);
53094 tv1 = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, curr.e_idx);
53095 DUK_TVAL_SET_TVAL_UPDREF(thr, tv1, tv2); /* side effects */
53096 }
53097
53098 /*
53099 * Standard algorithm succeeded without errors, check for exotic post-behaviors.
53100 *
53101 * Arguments exotic behavior in E5 Section 10.6 occurs after the standard
53102 * [[DefineOwnProperty]] has completed successfully.
53103 *
53104 * Array exotic behavior in E5 Section 15.4.5.1 is implemented partly
53105 * prior to the default [[DefineOwnProperty]], but:
53106 * - for an array index key (e.g. "10") the final 'length' update occurs here
53107 * - for 'length' key the element deletion and 'length' update occurs here
53108 */
53109
53110 success_exotics:
53111
53112 /* [obj key desc value get set curr_value] */
53113
53115 if (arridx_new_array_length > 0) {
53116 duk_tval *tmp;
53117 duk_bool_t rc;
53118
53119 /*
53120 * Note: zero works as a "no update" marker because the new length
53121 * can never be zero after a new property is written.
53122 */
53123
53124 /* E5 Section 15.4.5.1, steps 4.e.i - 4.e.ii */
53125
53126 DUK_DDD(DUK_DDDPRINT("defineProperty successful, pending array length update to: %ld",
53127 (long) arridx_new_array_length));
53128
53129 /* Note: reuse 'curr' */
53130 rc = duk__get_own_propdesc_raw(thr, obj, DUK_HTHREAD_STRING_LENGTH(thr), DUK__NO_ARRAY_INDEX, &curr, 0 /*flags*/); /* don't push value */
53131 DUK_UNREF(rc);
53132 DUK_ASSERT(rc != 0);
53133 DUK_ASSERT(curr.e_idx >= 0);
53134
53135 tmp = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, curr.e_idx);
53137 /* no need for decref/incref because value is a number */
53138 DUK_TVAL_SET_FASTINT_U32(tmp, arridx_new_array_length);
53139 }
53140 if (key == DUK_HTHREAD_STRING_LENGTH(thr) && arrlen_new_len < arrlen_old_len) {
53141 /*
53142 * E5 Section 15.4.5.1, steps 3.k - 3.n. The order at the end combines
53143 * the error case 3.l.iii and the success case 3.m-3.n.
53144 *
53145 * Note: 'length' is always in entries part, so no array abandon issues for
53146 * 'writable' update.
53147 */
53148
53149 /* XXX: investigate whether write protect can be handled above, if we
53150 * just update length here while ignoring its protected status
53151 */
53152
53153 duk_tval *tmp;
53154 duk_uint32_t result_len;
53155 duk_bool_t rc;
53156
53157 DUK_DDD(DUK_DDDPRINT("defineProperty successful, key is 'length', exotic array behavior, "
53158 "doing array element deletion and length update"));
53159
53160 rc = duk__handle_put_array_length_smaller(thr, obj, arrlen_old_len, arrlen_new_len, force_flag, &result_len);
53161
53162 /* update length (curr points to length, and we assume it's still valid) */
53163 DUK_ASSERT(result_len >= arrlen_new_len && result_len <= arrlen_old_len);
53164
53165 DUK_ASSERT(curr.e_idx >= 0);
53166 DUK_ASSERT(!DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, obj, curr.e_idx));
53167 tmp = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, curr.e_idx);
53169 /* no decref needed for a number */
53170 DUK_TVAL_SET_FASTINT_U32(tmp, result_len);
53172
53173 if (pending_write_protect) {
53174 DUK_DDD(DUK_DDDPRINT("setting array length non-writable (pending writability update)"));
53175 DUK_HOBJECT_E_SLOT_CLEAR_WRITABLE(thr->heap, obj, curr.e_idx);
53176 }
53177
53178 /*
53179 * XXX: shrink array allocation or entries compaction here?
53180 */
53181
53182 if (!rc) {
53183 goto fail_array_length_partial;
53184 }
53185 }
53186 } else if (arr_idx != DUK__NO_ARRAY_INDEX && DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(obj)) {
53187 duk_hobject *map;
53188 duk_hobject *varenv;
53189
53190 DUK_ASSERT(arridx_new_array_length == 0);
53191 DUK_ASSERT(!DUK_HOBJECT_HAS_EXOTIC_ARRAY(obj)); /* traits are separate; in particular, arguments not an array */
53192
53193 map = NULL;
53194 varenv = NULL;
53195 if (!duk__lookup_arguments_map(thr, obj, key, &curr, &map, &varenv)) {
53196 goto success_no_exotics;
53197 }
53198 DUK_ASSERT(map != NULL);
53199 DUK_ASSERT(varenv != NULL);
53200
53201 /* [obj key desc value get set curr_value varname] */
53202
53203 if (has_set || has_get) {
53204 /* = IsAccessorDescriptor(Desc) */
53205 DUK_DDD(DUK_DDDPRINT("defineProperty successful, key mapped to arguments 'map' "
53206 "changed to an accessor, delete arguments binding"));
53207
53208 (void) duk_hobject_delprop_raw(thr, map, key, 0); /* ignore result */
53209 } else {
53210 /* Note: this order matters (final value before deleting map entry must be done) */
53211 DUK_DDD(DUK_DDDPRINT("defineProperty successful, key mapped to arguments 'map', "
53212 "check for value update / binding deletion"));
53213
53214 if (has_value) {
53215 duk_hstring *varname;
53216
53217 DUK_DDD(DUK_DDDPRINT("defineProperty successful, key mapped to arguments 'map', "
53218 "update bound value (variable/argument)"));
53219
53220 varname = duk_require_hstring(ctx, -1);
53221 DUK_ASSERT(varname != NULL);
53222
53223 DUK_DDD(DUK_DDDPRINT("arguments object automatic putvar for a bound variable; "
53224 "key=%!O, varname=%!O, value=%!T",
53225 (duk_heaphdr *) key,
53226 (duk_heaphdr *) varname,
53227 (duk_tval *) duk_require_tval(ctx, idx_value)));
53228
53229 /* strict flag for putvar comes from our caller (currently: fixed) */
53230 duk_js_putvar_envrec(thr, varenv, varname, duk_require_tval(ctx, idx_value), throw_flag);
53231 }
53232 if (has_writable && !is_writable) {
53233 DUK_DDD(DUK_DDDPRINT("defineProperty successful, key mapped to arguments 'map', "
53234 "changed to non-writable, delete arguments binding"));
53235
53236 (void) duk_hobject_delprop_raw(thr, map, key, 0); /* ignore result */
53237 }
53238 }
53239
53240 /* 'varname' is in stack in this else branch, leaving an unbalanced stack below,
53241 * but this doesn't matter now.
53242 */
53243 }
53244
53245 success_no_exotics:
53246 return;
53247
53248 fail_virtual:
53250 return;
#define DUK_TVAL_DECREF(thr, tv)
#define duk_js_samevalue(tv_x, tv_y)
DUK_LOCAL void duk__abandon_array_checked(duk_hthread *thr, duk_hobject *obj)
#define DUK_HOBJECT_E_SLOT_CLEAR_ACCESSOR(heap, h, i)
#define DUK_HOBJECT_E_SLOT_CLEAR_WRITABLE(heap, h, i)
#define DUK_STR_PROPERTY_IS_VIRTUAL
#define DUK_PROPDESC_FLAGS_WEC
#define DUK_HOBJECT_E_SLOT_SET_ACCESSOR(heap, h, i)
union Value Value

References duk_propdesc::a_idx, duk__abandon_array_checked(), duk__alloc_entry_checked(), duk__get_old_array_length(), duk__get_own_propdesc_raw(), duk__handle_put_array_length_smaller(), duk__lookup_arguments_map(), DUK__NO_ARRAY_INDEX, duk__to_new_array_length_checked(), DUK__VALSTACK_SPACE, DUK_ASSERT, DUK_ASSERT_VALSTACK_SPACE, DUK_DD, DUK_DDD, DUK_DDDPRINT, DUK_DDPRINT, DUK_DEFPROP_CONFIGURABLE, DUK_DEFPROP_ENUMERABLE, DUK_DEFPROP_FORCE, DUK_DEFPROP_HAVE_CONFIGURABLE, DUK_DEFPROP_HAVE_ENUMERABLE, DUK_DEFPROP_HAVE_GETTER, DUK_DEFPROP_HAVE_SETTER, DUK_DEFPROP_HAVE_VALUE, DUK_DEFPROP_HAVE_WRITABLE, DUK_DEFPROP_WRITABLE, duk_dup(), DUK_ERROR_TYPE, duk_get_tval(), DUK_GETDESC_FLAG_PUSH_VALUE, DUK_HEAPHDR_HAS_READONLY, DUK_HOBJECT_A_GET_VALUE_PTR, DUK_HOBJECT_DECREF_ALLOWNULL, duk_hobject_delprop_raw(), DUK_HOBJECT_E_GET_FLAGS, DUK_HOBJECT_E_GET_VALUE_GETTER, DUK_HOBJECT_E_GET_VALUE_SETTER, DUK_HOBJECT_E_GET_VALUE_TVAL_PTR, DUK_HOBJECT_E_SET_FLAGS, DUK_HOBJECT_E_SET_VALUE_GETTER, DUK_HOBJECT_E_SET_VALUE_SETTER, DUK_HOBJECT_E_SLOT_CLEAR_ACCESSOR, DUK_HOBJECT_E_SLOT_CLEAR_WRITABLE, DUK_HOBJECT_E_SLOT_IS_ACCESSOR, DUK_HOBJECT_E_SLOT_SET_ACCESSOR, DUK_HOBJECT_HAS_ARRAY_PART, DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS, DUK_HOBJECT_HAS_EXOTIC_ARRAY, DUK_HOBJECT_HAS_EXTENSIBLE, DUK_HOBJECT_INCREF_ALLOWNULL, DUK_HSTRING_GET_ARRIDX_SLOW, DUK_HTHREAD_STRING_LENGTH, duk_js_putvar_envrec(), duk_js_samevalue, duk_pop(), DUK_PROPDESC_FLAG_ACCESSOR, DUK_PROPDESC_FLAG_CONFIGURABLE, DUK_PROPDESC_FLAG_ENUMERABLE, DUK_PROPDESC_FLAG_VIRTUAL, DUK_PROPDESC_FLAG_WRITABLE, DUK_PROPDESC_FLAGS_WEC, duk_push_u32, duk_replace(), duk_require_hstring(), duk_require_tval(), DUK_STR_ARRAY_LENGTH_NOT_WRITABLE, DUK_STR_PROPERTY_IS_VIRTUAL, DUK_TVAL_DECREF, DUK_TVAL_INCREF, DUK_TVAL_IS_NUMBER, DUK_TVAL_SET_FASTINT_U32, DUK_TVAL_SET_TVAL, DUK_TVAL_SET_TVAL_UPDREF, DUK_TVAL_SET_UNDEFINED, DUK_UNREACHABLE, DUK_UNREF, duk_propdesc::e_idx, duk_propdesc::flags, duk_propdesc::get, duk_hthread::heap, NULL, and duk_propdesc::set.

◆ duk_hobject_define_property_internal()

DUK_INTERNAL_DECL void duk_hobject_define_property_internal ( duk_hthread * thr,
duk_hobject * obj,
duk_hstring * key,
duk_small_uint_t flags )

Definition at line 51940 of file duktape-1.8.0/src/duktape.c.

51944 :
51945 * - virtual properties (error if write attempted)
51946 * - getter/setter properties (error if write attempted)
51947 * - non-default (!= WEC) attributes for array entries (error if attempted)
51948 * - array abandoning: if array part exists, it is always extended
51949 * - array 'length' updating
51950 *
51951 * Stack: [... in_val] -> []
51952 *
51953 * Used for e.g. built-in initialization and environment record
51954 * operations.
51955 */
51956
51958 duk_context *ctx = (duk_context *) thr;
51959 duk_propdesc desc;
51960 duk_uint32_t arr_idx;
51961 duk_int_t e_idx;
51962 duk_tval *tv1 = NULL;
51963 duk_tval *tv2 = NULL;
51964 duk_small_uint_t propflags = flags & DUK_PROPDESC_FLAGS_MASK; /* mask out flags not actually stored */
51965
51966 DUK_DDD(DUK_DDDPRINT("define new property (internal): thr=%p, obj=%!O, key=%!O, flags=0x%02lx, val=%!T",
51967 (void *) thr, (duk_heaphdr *) obj, (duk_heaphdr *) key,
51968 (unsigned long) flags, (duk_tval *) duk_get_tval(ctx, -1)));
51969
51970 DUK_ASSERT(thr != NULL);
51971 DUK_ASSERT(thr->heap != NULL);
51972 DUK_ASSERT(obj != NULL);
51973 DUK_ASSERT(key != NULL);
51976 DUK_ASSERT(duk_is_valid_index(ctx, -1)); /* contains value */
51977
51978 arr_idx = DUK_HSTRING_GET_ARRIDX_SLOW(key);
51979
51980 if (duk__get_own_propdesc_raw(thr, obj, key, arr_idx, &desc, 0 /*flags*/)) { /* don't push value */
51981 if (desc.e_idx >= 0) {
51982 if (flags & DUK_PROPDESC_FLAG_NO_OVERWRITE) {
51983 DUK_DDD(DUK_DDDPRINT("property already exists in the entry part -> skip as requested"));
51984 goto pop_exit;
51985 }
51986 DUK_DDD(DUK_DDDPRINT("property already exists in the entry part -> update value and attributes"));
51987 if (DUK_UNLIKELY(DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, obj, desc.e_idx))) {
51988 DUK_D(DUK_DPRINT("existing property is an accessor, not supported"));
51989 goto error_internal;
51990 }
51991
51992 DUK_HOBJECT_E_SET_FLAGS(thr->heap, obj, desc.e_idx, propflags);
51993 tv1 = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, desc.e_idx);
51994 } else if (desc.a_idx >= 0) {
51995 if (flags & DUK_PROPDESC_FLAG_NO_OVERWRITE) {
51996 DUK_DDD(DUK_DDDPRINT("property already exists in the array part -> skip as requested"));
51997 goto pop_exit;
51998 }
51999 DUK_DDD(DUK_DDDPRINT("property already exists in the array part -> update value (assert attributes)"));
52000 if (propflags != DUK_PROPDESC_FLAGS_WEC) {
52001 DUK_D(DUK_DPRINT("existing property in array part, but propflags not WEC (0x%02lx)",
52002 (unsigned long) propflags));
52003 goto error_internal;
52004 }
52005
52006 tv1 = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, desc.a_idx);
52007 } else {
52008 if (flags & DUK_PROPDESC_FLAG_NO_OVERWRITE) {
52009 DUK_DDD(DUK_DDDPRINT("property already exists but is virtual -> skip as requested"));
52010 goto pop_exit;
52011 }
52012 DUK_DDD(DUK_DDDPRINT("property already exists but is virtual -> failure"));
52013 goto error_virtual;
52014 }
52015
52016 goto write_value;
52017 }
52018
52019 if (DUK_HOBJECT_HAS_ARRAY_PART(obj)) {
52020 if (arr_idx != DUK__NO_ARRAY_INDEX) {
52021 DUK_DDD(DUK_DDDPRINT("property does not exist, object has array part -> possibly extend array part and write value (assert attributes)"));
52022 DUK_ASSERT(propflags == DUK_PROPDESC_FLAGS_WEC);
52023
52024 /* always grow the array, no sparse / abandon support here */
52025 if (arr_idx >= DUK_HOBJECT_GET_ASIZE(obj)) {
52026 duk__grow_props_for_array_item(thr, obj, arr_idx);
52027 }
52028
52029 DUK_ASSERT(arr_idx < DUK_HOBJECT_GET_ASIZE(obj));
52030 tv1 = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, arr_idx);
52031 goto write_value;
52032 }
52033 }
52034
52035 DUK_DDD(DUK_DDDPRINT("property does not exist, object belongs in entry part -> allocate new entry and write value and attributes"));
52036 e_idx = duk__alloc_entry_checked(thr, obj, key); /* increases key refcount */
52037 DUK_ASSERT(e_idx >= 0);
52038 DUK_HOBJECT_E_SET_FLAGS(thr->heap, obj, e_idx, propflags);
52039 tv1 = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, e_idx);
52040 /* new entry: previous value is garbage; set to undefined to share write_value */
52042 goto write_value;
52043
52044 write_value:
52045 /* tv1 points to value storage */
52046
52047 tv2 = duk_require_tval(ctx, -1); /* late lookup, avoid side effects */
52048 DUK_DDD(DUK_DDDPRINT("writing/updating value: %!T -> %!T",
DUK_LOCAL void duk__grow_props_for_array_item(duk_hthread *thr, duk_hobject *obj, duk_uint32_t highest_arr_idx)

References duk_propdesc::a_idx, duk__alloc_entry_checked(), duk__get_own_propdesc_raw(), duk__grow_props_for_array_item(), DUK__NO_ARRAY_INDEX, DUK__VALSTACK_SPACE, DUK_ASSERT, DUK_ASSERT_VALSTACK_SPACE, DUK_D, DUK_DDD, DUK_DDDPRINT, DUK_DPRINT, duk_get_tval(), DUK_HEAPHDR_HAS_READONLY, DUK_HOBJECT_A_GET_VALUE_PTR, DUK_HOBJECT_E_GET_VALUE_TVAL_PTR, DUK_HOBJECT_E_SET_FLAGS, DUK_HOBJECT_E_SLOT_IS_ACCESSOR, DUK_HOBJECT_GET_ASIZE, DUK_HOBJECT_HAS_ARRAY_PART, DUK_HSTRING_GET_ARRIDX_SLOW, duk_is_valid_index(), duk_pop(), DUK_PROPDESC_FLAG_NO_OVERWRITE, DUK_PROPDESC_FLAGS_MASK, DUK_PROPDESC_FLAGS_WEC, duk_require_tval(), DUK_TVAL_SET_TVAL_UPDREF, DUK_TVAL_SET_UNDEFINED, DUK_UNLIKELY, duk_propdesc::e_idx, duk_hthread::heap, and NULL.

Referenced by duk__declvar_helper().

◆ duk_hobject_define_property_internal_arridx()

DUK_INTERNAL_DECL void duk_hobject_define_property_internal_arridx ( duk_hthread * thr,
duk_hobject * obj,
duk_uarridx_t arr_idx,
duk_small_uint_t flags )

Definition at line 52056 of file duktape-1.8.0/src/duktape.c.

52058 :
52060 return;
52061
52062 error_virtual:
52064 return;
52065}
52066
52067/*
52068 * Fast path for defining array indexed values without interning the key.
52069 * This is used by e.g. code for Array prototype and traceback creation so
52070 * must avoid interning.
52071 */
52072
52074 duk_context *ctx = (duk_context *) thr;
52075 duk_hstring *key;
52076 duk_tval *tv1, *tv2;
52077
52078 DUK_DDD(DUK_DDDPRINT("define new property (internal) arr_idx fast path: thr=%p, obj=%!O, "
52079 "arr_idx=%ld, flags=0x%02lx, val=%!T",
52080 (void *) thr, obj, (long) arr_idx, (unsigned long) flags,
52081 (duk_tval *) duk_get_tval(ctx, -1)));
52082
52083 DUK_ASSERT(thr != NULL);
52084 DUK_ASSERT(thr->heap != NULL);
52085 DUK_ASSERT(obj != NULL);
52087
52088 if (DUK_HOBJECT_HAS_ARRAY_PART(obj) &&
52089 arr_idx != DUK__NO_ARRAY_INDEX &&
52090 flags == DUK_PROPDESC_FLAGS_WEC) {
52091 DUK_ASSERT((flags & DUK_PROPDESC_FLAG_NO_OVERWRITE) == 0); /* covered by comparison */
52092
52093 DUK_DDD(DUK_DDDPRINT("define property to array part (property may or may not exist yet)"));
52094
52095 /* always grow the array, no sparse / abandon support here */
52096 if (arr_idx >= DUK_HOBJECT_GET_ASIZE(obj)) {
52097 duk__grow_props_for_array_item(thr, obj, arr_idx);
52098 }
52099
52100 DUK_ASSERT(arr_idx < DUK_HOBJECT_GET_ASIZE(obj));
52101 tv1 = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, arr_idx);
52102 tv2 = duk_require_tval(ctx, -1);
52103
#define DUK_STR_REDEFINE_VIRT_PROP
DUK_INTERNAL_DECL void duk_hobject_define_property_internal_arridx(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t arr_idx, duk_small_uint_t flags)

◆ duk_hobject_delprop()

DUK_INTERNAL_DECL duk_bool_t duk_hobject_delprop ( duk_hthread * thr,
duk_tval * tv_obj,
duk_tval * tv_key,
duk_bool_t throw_flag )

Definition at line 51732 of file duktape-1.8.0/src/duktape.c.

51736 :
51737 DUK_DDD(DUK_DDDPRINT("delete failed: property found, not configurable"));
51738
51739 if (throw_flag) {
51741 }
51742 return 0;
51743}
51744
51745/*
51746 * DELPROP: Ecmascript property deletion.
51747 */
51748
51750 duk_context *ctx = (duk_context *) thr;
51751 duk_hstring *key = NULL;
51752#if defined(DUK_USE_ES6_PROXY)
51753 duk_propdesc desc;
51754#endif
51755 duk_int_t entry_top;
51756 duk_uint32_t arr_idx = DUK__NO_ARRAY_INDEX;
51757 duk_bool_t rc;
51758
51759 DUK_DDD(DUK_DDDPRINT("delprop: thr=%p, obj=%p, key=%p (obj -> %!T, key -> %!T)",
51760 (void *) thr, (void *) tv_obj, (void *) tv_key,
51761 (duk_tval *) tv_obj, (duk_tval *) tv_key));
51762
51763 DUK_ASSERT(ctx != NULL);
51764 DUK_ASSERT(thr != NULL);
51765 DUK_ASSERT(thr->heap != NULL);
51766 DUK_ASSERT(tv_obj != NULL);
51767 DUK_ASSERT(tv_key != NULL);
51768
51770
51771 /* Storing the entry top is cheaper here to ensure stack is correct at exit,
51772 * as there are several paths out.
51773 */
51774 entry_top = duk_get_top(ctx);
51775
51776 if (DUK_TVAL_IS_UNDEFINED(tv_obj) ||
51777 DUK_TVAL_IS_NULL(tv_obj)) {
51778 DUK_DDD(DUK_DDDPRINT("base object is undefined or null -> reject"));
51779 goto fail_invalid_base_uncond;
51780 }
51781
51782 duk_push_tval(ctx, tv_obj);
51783 duk_push_tval(ctx, tv_key);
51784
51785 tv_obj = DUK_GET_TVAL_NEGIDX(ctx, -2);
51786 if (DUK_TVAL_IS_OBJECT(tv_obj)) {
51787 duk_hobject *obj = DUK_TVAL_GET_OBJECT(tv_obj);
51788 DUK_ASSERT(obj != NULL);
51789
51790#if defined(DUK_USE_ES6_PROXY)
51792 duk_hobject *h_target;
51793 duk_bool_t tmp_bool;
51794
51795 /* Note: proxy handling must happen before key is string coerced. */
51796
51797 if (duk__proxy_check_prop(thr, obj, DUK_STRIDX_DELETE_PROPERTY, tv_key, &h_target)) {
51798 /* -> [ ... obj key trap handler ] */
51799 DUK_DDD(DUK_DDDPRINT("-> proxy object 'deleteProperty' for key %!T", (duk_tval *) tv_key));
51800 duk_push_hobject(ctx, h_target); /* target */
51801 duk_dup(ctx, -4); /* P */
51802 duk_call_method(ctx, 2 /*nargs*/);
51803 tmp_bool = duk_to_boolean(ctx, -1);
51804 duk_pop(ctx);
51805 if (!tmp_bool) {
51806 goto fail_proxy_rejected; /* retval indicates delete failed */
51807 }
51808
51809 /* Target object must be checked for a conflicting
51810 * non-configurable property.
51811 */
51812 tv_key = DUK_GET_TVAL_NEGIDX(ctx, -1);
51813 arr_idx = duk__push_tval_to_hstring_arr_idx(ctx, tv_key, &key);
51814 DUK_ASSERT(key != NULL);
51815
51816 if (duk__get_own_propdesc_raw(thr, h_target, key, arr_idx, &desc, 0 /*flags*/)) { /* don't push value */
51817 int desc_reject;
51818
51819 DUK_DDD(DUK_DDDPRINT("proxy 'deleteProperty': target has matching property %!O, check for "
51820 "conflicting property; desc.flags=0x%08lx, "
51821 "desc.get=%p, desc.set=%p",
51822 (duk_heaphdr *) key, (unsigned long) desc.flags,
51823 (void *) desc.get, (void *) desc.set));
51824
51825 desc_reject = !(desc.flags & DUK_PROPDESC_FLAG_CONFIGURABLE);
51826 if (desc_reject) {
51827 /* unconditional */
51829 }
51830 }
51831 rc = 1; /* success */
51832 goto done_rc;
51833 }
51834
51835 obj = h_target; /* resume delete to target */
51836 }
51837#endif /* DUK_USE_ES6_PROXY */
51838
51839 duk_to_string(ctx, -1);
51840 key = duk_get_hstring(ctx, -1);
51841 DUK_ASSERT(key != NULL);
51842
51843 rc = duk_hobject_delprop_raw(thr, obj, key, throw_flag ? DUK_DELPROP_FLAG_THROW : 0);
51844 goto done_rc;
51845 } else if (DUK_TVAL_IS_STRING(tv_obj)) {
51846 /* XXX: unnecessary string coercion for array indices,
51847 * intentional to keep small.
51848 */
51849 duk_hstring *h = DUK_TVAL_GET_STRING(tv_obj);
51850 DUK_ASSERT(h != NULL);
51851
51852 duk_to_string(ctx, -1);
51853 key = duk_get_hstring(ctx, -1);
51854 DUK_ASSERT(key != NULL);
51855
51856 if (key == DUK_HTHREAD_STRING_LENGTH(thr)) {
51857 goto fail_not_configurable;
51858 }
51859
51860 arr_idx = DUK_HSTRING_GET_ARRIDX_FAST(key);
51861
51862 if (arr_idx != DUK__NO_ARRAY_INDEX &&
51863 arr_idx < DUK_HSTRING_GET_CHARLEN(h)) {
51864 goto fail_not_configurable;
51865 }
51866 } else if (DUK_TVAL_IS_BUFFER(tv_obj)) {
51867 /* XXX: unnecessary string coercion for array indices,
51868 * intentional to keep small; some overlap with string
51869 * handling.
51870 */
51871 duk_hbuffer *h = DUK_TVAL_GET_BUFFER(tv_obj);
51872 DUK_ASSERT(h != NULL);
51873
51874 duk_to_string(ctx, -1);
51875 key = duk_get_hstring(ctx, -1);
51876 DUK_ASSERT(key != NULL);
51877
51878 if (key == DUK_HTHREAD_STRING_LENGTH(thr)) {
51879 goto fail_not_configurable;
51880 }
51881
51882 arr_idx = DUK_HSTRING_GET_ARRIDX_FAST(key);
51883
51884 if (arr_idx != DUK__NO_ARRAY_INDEX &&
51885 arr_idx < DUK_HBUFFER_GET_SIZE(h)) {
51886 goto fail_not_configurable;
51887 }
51888 } else if (DUK_TVAL_IS_LIGHTFUNC(tv_obj)) {
51889 /* Lightfunc virtual properties are non-configurable, so
51890 * reject if match any of them.
51891 */
51892
51893 duk_to_string(ctx, -1);
51894 key = duk_get_hstring(ctx, -1);
51895 DUK_ASSERT(key != NULL);
51896
51897 if (duk__key_is_lightfunc_ownprop(thr, key)) {
51898 goto fail_not_configurable;
51899 }
51900 }
51901
51902 /* non-object base, no offending virtual property */
51903 rc = 1;
51904 goto done_rc;
51905
51906 done_rc:
51907 duk_set_top(ctx, entry_top);
51908 return rc;
51909
51910 fail_invalid_base_uncond:
51911 /* Note: unconditional throw */
51912 DUK_ASSERT(duk_get_top(ctx) == entry_top);
51913#if defined(DUK_USE_PARANOID_ERRORS)
51915#else
51916 DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot delete property %s of %s",
51918#endif
51919 return 0;
#define DUK_DELPROP_FLAG_THROW
DUK_LOCAL duk_uint32_t duk__push_tval_to_hstring_arr_idx(duk_context *ctx, duk_tval *tv, duk_hstring **out_h)
#define DUK_STRIDX_DELETE_PROPERTY
#define DUK_ERROR_FMT2(thr, err, fmt, arg1, arg2)
#define DUK_STR_INVALID_BASE
#define DUK_STR_NOT_CONFIGURABLE
DUK_LOCAL duk_bool_t duk__key_is_lightfunc_ownprop(duk_hthread *thr, duk_hstring *key)
#define DUK_STR_PROXY_REJECTED

◆ duk_hobject_delprop_raw()

DUK_INTERNAL_DECL duk_bool_t duk_hobject_delprop_raw ( duk_hthread * thr,
duk_hobject * obj,
duk_hstring * key,
duk_small_uint_t flags )

Definition at line 51564 of file duktape-1.8.0/src/duktape.c.

51568 :
51569 DUK_DDD(DUK_DDDPRINT("result: error, internal"));
51570 if (throw_flag) {
51572 }
51573 duk_pop(ctx); /* remove key */
51574 return 0;
51575}
51576
51577/*
51578 * Ecmascript compliant [[Delete]](P, Throw).
51579 */
51580
51582 duk_propdesc desc;
51583 duk_tval *tv;
51584 duk_uint32_t arr_idx;
51585 duk_bool_t throw_flag;
51586 duk_bool_t force_flag;
51587
51588 throw_flag = (flags & DUK_DELPROP_FLAG_THROW);
51589 force_flag = (flags & DUK_DELPROP_FLAG_FORCE);
51590
51591 DUK_DDD(DUK_DDDPRINT("delprop_raw: thr=%p, obj=%p, key=%p, throw=%ld, force=%ld (obj -> %!O, key -> %!O)",
51592 (void *) thr, (void *) obj, (void *) key, (long) throw_flag, (long) force_flag,
51593 (duk_heaphdr *) obj, (duk_heaphdr *) key));
51594
51595 DUK_ASSERT(thr != NULL);
51596 DUK_ASSERT(thr->heap != NULL);
51597 DUK_ASSERT(obj != NULL);
51598 DUK_ASSERT(key != NULL);
51599
51601
51602 arr_idx = DUK_HSTRING_GET_ARRIDX_FAST(key);
51603
51604 /* 0 = don't push current value */
51605 if (!duk__get_own_propdesc_raw(thr, obj, key, arr_idx, &desc, 0 /*flags*/)) { /* don't push value */
51606 DUK_DDD(DUK_DDDPRINT("property not found, succeed always"));
51607 goto success;
51608 }
51609
51610#if defined(DUK_USE_ROM_OBJECTS)
51612 DUK_DD(DUK_DDPRINT("attempt to delprop on read-only target object"));
51613 goto fail_not_configurable;
51614 }
51615#endif
51616
51617 if ((desc.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) == 0 && !force_flag) {
51618 goto fail_not_configurable;
51619 }
51620 if (desc.a_idx < 0 && desc.e_idx < 0) {
51621 /* Currently there are no deletable virtual properties, but
51622 * with force_flag we might attempt to delete one.
51623 */
51624 goto fail_virtual;
51625 }
51626
51627 if (desc.a_idx >= 0) {
51628 DUK_ASSERT(desc.e_idx < 0);
51629
51630 tv = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, desc.a_idx);
51631 DUK_TVAL_SET_UNUSED_UPDREF(thr, tv); /* side effects */
51632 goto success;
51633 } else {
51634 duk_hobject *h_get = NULL;
51635 duk_hobject *h_set = NULL;
51636 duk_tval tv_tmp;
51637
51638 DUK_ASSERT(desc.a_idx < 0);
51639
51640 /* Set property slot to an empty state. Careful not to invoke
51641 * any side effects while using desc.e_idx so that it doesn't
51642 * get invalidated by a finalizer mutating our object.
51643 */
51644
51645 /* remove hash entry (no decref) */
51646#if defined(DUK_USE_HOBJECT_HASH_PART)
51647 if (desc.h_idx >= 0) {
51648 duk_uint32_t *h_base = DUK_HOBJECT_H_GET_BASE(thr->heap, obj);
51649
51650 DUK_DDD(DUK_DDDPRINT("removing hash entry at h_idx %ld", (long) desc.h_idx));
51652 DUK_ASSERT((duk_uint32_t) desc.h_idx < DUK_HOBJECT_GET_HSIZE(obj));
51653 h_base[desc.h_idx] = DUK__HASH_DELETED;
51654 } else {
51656 }
51657#else
51659#endif
51660
51661 /* remove value */
51662 DUK_DDD(DUK_DDDPRINT("before removing value, e_idx %ld, key %p, key at slot %p",
51663 (long) desc.e_idx, (void *) key, (void *) DUK_HOBJECT_E_GET_KEY(thr->heap, obj, desc.e_idx)));
51664 DUK_DDD(DUK_DDDPRINT("removing value at e_idx %ld", (long) desc.e_idx));
51665 DUK_MEMSET((void *) &tv_tmp, 0, sizeof(tv_tmp));
51666 DUK_TVAL_SET_UNDEFINED(&tv_tmp);
51667 if (DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, obj, desc.e_idx)) {
51668 h_get = DUK_HOBJECT_E_GET_VALUE_GETTER(thr->heap, obj, desc.e_idx);
51669 h_set = DUK_HOBJECT_E_GET_VALUE_SETTER(thr->heap, obj, desc.e_idx);
51670 DUK_HOBJECT_E_SET_VALUE_GETTER(thr->heap, obj, desc.e_idx, NULL);
51671 DUK_HOBJECT_E_SET_VALUE_SETTER(thr->heap, obj, desc.e_idx, NULL);
51672 } else {
51673 tv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, desc.e_idx);
51674 DUK_TVAL_SET_TVAL(&tv_tmp, tv);
51676 }
51677#if 0
51678 /* Not strictly necessary because if key == NULL, flag MUST be ignored. */
51679 DUK_HOBJECT_E_SET_FLAGS(thr->heap, obj, desc.e_idx, 0);
51680#endif
51681
51682 /* remove key */
51683 DUK_DDD(DUK_DDDPRINT("before removing key, e_idx %ld, key %p, key at slot %p",
51684 (long) desc.e_idx, (void *) key, (void *) DUK_HOBJECT_E_GET_KEY(thr->heap, obj, desc.e_idx)));
51685 DUK_DDD(DUK_DDDPRINT("removing key at e_idx %ld", (long) desc.e_idx));
51686 DUK_ASSERT(key == DUK_HOBJECT_E_GET_KEY(thr->heap, obj, desc.e_idx));
51687 DUK_HOBJECT_E_SET_KEY(thr->heap, obj, desc.e_idx, NULL);
51688
51689 /* Do decrefs only with safe pointers to avoid side effects
51690 * disturbing e_idx.
51691 */
51692 DUK_TVAL_DECREF(thr, &tv_tmp);
51693 DUK_HOBJECT_DECREF_ALLOWNULL(thr, h_get);
51694 DUK_HOBJECT_DECREF_ALLOWNULL(thr, h_set);
51695 DUK_HSTRING_DECREF(thr, key);
51696 goto success;
51697 }
51698
51700
51701 success:
51702 /*
51703 * Argument exotic [[Delete]] behavior (E5 Section 10.6) is
51704 * a post-check, keeping arguments internal 'map' in sync with
51705 * any successful deletes (note that property does not need to
51706 * exist for delete to 'succeed').
51707 *
51708 * Delete key from 'map'. Since 'map' only contains array index
51709 * keys, we can use arr_idx for a fast skip.
51710 */
51711
51712 DUK_DDD(DUK_DDDPRINT("delete successful, check for arguments exotic behavior"));
51713
51715 /* Note: only numbered indices are relevant, so arr_idx fast reject
51716 * is good (this is valid unless there are more than 4**32-1 arguments).
51717 */
51718
51719 DUK_DDD(DUK_DDDPRINT("delete successful, arguments exotic behavior needed"));
51720
51721 /* Note: we can reuse 'desc' here */
51722 (void) duk__check_arguments_map_for_delete(thr, obj, key, &desc);
51723 }
51724
51725 DUK_DDD(DUK_DDDPRINT("delete successful"));
51726 return 1;
#define DUK_HSTRING_DECREF(thr, h)
DUK_LOCAL_DECL void duk__check_arguments_map_for_delete(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *temp_desc)

Referenced by duk__delvar_helper(), and duk_hobject_define_property_helper().

◆ duk_hobject_enumerator_create()

DUK_INTERNAL_DECL void duk_hobject_enumerator_create ( duk_context * ctx,
duk_small_uint_t enum_flags )

Definition at line 46550 of file duktape-1.8.0/src/duktape.c.

46567 {
46568 duk_hthread *thr = (duk_hthread *) ctx;
46569 duk_hobject *enum_target;
46570 duk_hobject *curr;
46571 duk_hobject *res;
46572#if defined(DUK_USE_ES6_PROXY)
46573 duk_hobject *h_proxy_target;
46574 duk_hobject *h_proxy_handler;
46575 duk_hobject *h_trap_result;
46576#endif
46577 duk_uint_fast32_t i, len; /* used for array, stack, and entry indices */
46578
46579 DUK_ASSERT(ctx != NULL);
46580
46581 DUK_DDD(DUK_DDDPRINT("create enumerator, stack top: %ld", (long) duk_get_top(ctx)));
46582
46583 enum_target = duk_require_hobject(ctx, -1);
46584 DUK_ASSERT(enum_target != NULL);
46585
46587 res = duk_require_hobject(ctx, -1);
46588
46589 DUK_DDD(DUK_DDDPRINT("created internal object"));
46590
46591 /* [enum_target res] */
46592
46593 /* Target must be stored so that we can recheck whether or not
46594 * keys still exist when we enumerate. This is not done if the
46595 * enumeration result comes from a proxy trap as there is no
46596 * real object to check against.
46597 */
46598 duk_push_hobject(ctx, enum_target);
46600
46601 /* Initialize index so that we skip internal control keys. */
46604
46605 /*
46606 * Proxy object handling
46607 */
46608
46609#if defined(DUK_USE_ES6_PROXY)
46610 if (DUK_LIKELY((enum_flags & DUK_ENUM_NO_PROXY_BEHAVIOR) != 0)) {
46611 goto skip_proxy;
46612 }
46614 enum_target,
46615 &h_proxy_target,
46616 &h_proxy_handler))) {
46617 goto skip_proxy;
46618 }
46619
46620 DUK_DDD(DUK_DDDPRINT("proxy enumeration"));
46621 duk_push_hobject(ctx, h_proxy_handler);
46623 /* No need to replace the 'enum_target' value in stack, only the
46624 * enum_target reference. This also ensures that the original
46625 * enum target is reachable, which keeps the proxy and the proxy
46626 * target reachable. We do need to replace the internal _Target.
46627 */
46628 DUK_DDD(DUK_DDDPRINT("no enumerate trap, enumerate proxy target instead"));
46629 DUK_DDD(DUK_DDDPRINT("h_proxy_target=%!O", (duk_heaphdr *) h_proxy_target));
46630 enum_target = h_proxy_target;
46631
46632 duk_push_hobject(ctx, enum_target); /* -> [ ... enum_target res handler undefined target ] */
46634
46635 duk_pop_2(ctx); /* -> [ ... enum_target res ] */
46636 goto skip_proxy;
46637 }
46638
46639 /* [ ... enum_target res handler trap ] */
46640 duk_insert(ctx, -2);
46641 duk_push_hobject(ctx, h_proxy_target); /* -> [ ... enum_target res trap handler target ] */
46642 duk_call_method(ctx, 1 /*nargs*/); /* -> [ ... enum_target res trap_result ] */
46643 h_trap_result = duk_require_hobject(ctx, -1);
46644 DUK_UNREF(h_trap_result);
46645
46646 /* Copy trap result keys into the enumerator object. */
46647 len = (duk_uint_fast32_t) duk_get_length(ctx, -1);
46648 for (i = 0; i < len; i++) {
46649 /* XXX: not sure what the correct semantic details are here,
46650 * e.g. handling of missing values (gaps), handling of non-array
46651 * trap results, etc.
46652 *
46653 * For keys, we simply skip non-string keys which seems to be
46654 * consistent with how e.g. Object.keys() will process proxy trap
46655 * results (ES6, Section 19.1.2.14).
46656 */
46657 if (duk_get_prop_index(ctx, -1, i) && duk_is_string(ctx, -1)) {
46658 /* [ ... enum_target res trap_result val ] */
46659 duk_push_true(ctx);
46660 /* [ ... enum_target res trap_result val true ] */
46661 duk_put_prop(ctx, -4);
46662 } else {
46663 duk_pop(ctx);
46664 }
46665 }
46666 /* [ ... enum_target res trap_result ] */
46667 duk_pop(ctx);
46668 duk_remove(ctx, -2);
46669
46670 /* [ ... res ] */
46671
46672 /* The internal _Target property is kept pointing to the original
46673 * enumeration target (the proxy object), so that the enumerator
46674 * 'next' operation can read property values if so requested. The
46675 * fact that the _Target is a proxy disables key existence check
46676 * during enumeration.
46677 */
46678 DUK_DDD(DUK_DDDPRINT("proxy enumeration, final res: %!O", (duk_heaphdr *) res));
46679 goto compact_and_return;
46680
46681 skip_proxy:
46682#endif /* DUK_USE_ES6_PROXY */
46683
46684 curr = enum_target;
46685 while (curr) {
46686 /*
46687 * Virtual properties.
46688 *
46689 * String and buffer indices are virtual and always enumerable,
46690 * 'length' is virtual and non-enumerable. Array and arguments
46691 * object props have special behavior but are concrete.
46692 */
46693
46696 /* String and buffer enumeration behavior is identical now,
46697 * so use shared handler.
46698 */
46700 duk_hstring *h_val;
46701 h_val = duk_hobject_get_internal_value_string(thr->heap, curr);
46702 DUK_ASSERT(h_val != NULL); /* string objects must not created without internal value */
46704 } else {
46705 duk_hbufferobject *h_bufobj;
46707 h_bufobj = (duk_hbufferobject *) curr;
46708 if (h_bufobj == NULL) {
46709 /* Neutered buffer, zero length seems
46710 * like good behavior here.
46711 */
46712 len = 0;
46713 } else {
46714 /* There's intentionally no check for
46715 * current underlying buffer length.
46716 */
46717 len = (duk_uint_fast32_t) (h_bufobj->length >> h_bufobj->shift);
46718 }
46719 }
46720
46721 for (i = 0; i < len; i++) {
46722 duk_hstring *k;
46723
46725 DUK_ASSERT(k);
46726 duk_push_hstring(ctx, k);
46727 duk_push_true(ctx);
46728
46729 /* [enum_target res key true] */
46730 duk_put_prop(ctx, -3);
46731
46732 /* [enum_target res] */
46733 }
46734
46735 /* 'length' and other virtual properties are not
46736 * enumerable, but are included if non-enumerable
46737 * properties are requested.
46738 */
46739
46740 if (enum_flags & DUK_ENUM_INCLUDE_NONENUMERABLE) {
46742
46743 if (DUK_HOBJECT_IS_BUFFEROBJECT(curr)) {
46744 n = sizeof(duk__bufferobject_virtual_props) / sizeof(duk_uint16_t);
46745 } else {
46748 n = 1; /* only 'length' */
46749 }
46750
46751 for (i = 0; i < n; i++) {
46753 duk_push_true(ctx);
46754 duk_put_prop(ctx, -3);
46755 }
46756
46757 }
46758 } else if (DUK_HOBJECT_HAS_EXOTIC_DUKFUNC(curr)) {
46759 if (enum_flags & DUK_ENUM_INCLUDE_NONENUMERABLE) {
46761 duk_push_true(ctx);
46762 duk_put_prop(ctx, -3);
46763 }
46764 }
46765
46766 /*
46767 * Array part
46768 *
46769 * Note: ordering between array and entry part must match 'abandon array'
46770 * behavior in duk_hobject_props.c: key order after an array is abandoned
46771 * must be the same.
46772 */
46773
46774 for (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ASIZE(curr); i++) {
46775 duk_hstring *k;
46776 duk_tval *tv;
46777
46778 tv = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, curr, i);
46779 if (DUK_TVAL_IS_UNUSED(tv)) {
46780 continue;
46781 }
46783 DUK_ASSERT(k);
46784
46785 duk_push_hstring(ctx, k);
46786 duk_push_true(ctx);
46787
46788 /* [enum_target res key true] */
46789 duk_put_prop(ctx, -3);
46790
46791 /* [enum_target res] */
46792 }
46793
46794 /*
46795 * Entries part
46796 */
46797
46798 for (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ENEXT(curr); i++) {
46799 duk_hstring *k;
46800
46801 k = DUK_HOBJECT_E_GET_KEY(thr->heap, curr, i);
46802 if (!k) {
46803 continue;
46804 }
46805 if (!DUK_HOBJECT_E_SLOT_IS_ENUMERABLE(thr->heap, curr, i) &&
46806 !(enum_flags & DUK_ENUM_INCLUDE_NONENUMERABLE)) {
46807 continue;
46808 }
46809 if (DUK_HSTRING_HAS_INTERNAL(k) &&
46810 !(enum_flags & DUK_ENUM_INCLUDE_INTERNAL)) {
46811 continue;
46812 }
46813 if ((enum_flags & DUK_ENUM_ARRAY_INDICES_ONLY) &&
46815 continue;
46816 }
46817
46820
46821 duk_push_hstring(ctx, k);
46822 duk_push_true(ctx);
46823
46824 /* [enum_target res key true] */
46825 duk_put_prop(ctx, -3);
46826
46827 /* [enum_target res] */
46828 }
46829
46830 if (enum_flags & DUK_ENUM_OWN_PROPERTIES_ONLY) {
46831 break;
46832 }
46833
46834 curr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, curr);
46835 }
46836
46837 /* [enum_target res] */
46838
46839 duk_remove(ctx, -2);
46840
46841 /* [res] */
46842
46845 /*
46846 * Some E5/E5.1 algorithms require that array indices are iterated
46847 * in a strictly ascending order. This is the case for e.g.
46848 * Array.prototype.forEach() and JSON.stringify() PropertyList
46849 * handling.
46850 *
46851 * To ensure this property for arrays with an array part (and
46852 * arbitrary objects too, since e.g. forEach() can be applied
46853 * to an array), the caller can request that we sort the keys
46854 * here.
46855 */
46856
46857 /* XXX: avoid this at least when enum_target is an Array, it has an
46858 * array part, and no ancestor properties were included? Not worth
#define DUK_ENUM_ARRAY_INDICES_ONLY
#define DUK_ENUM_SORT_ARRAY_INDICES
#define DUK_ENUM_INCLUDE_INTERNAL
#define DUK_STRIDX_ENUMERATE
#define DUK_HSTRING_NO_ARRAY_INDEX
#define DUK_HOBJECT_E_SLOT_IS_ENUMERABLE(heap, h, i)
#define DUK_STRIDX_INT_NEXT
DUK_INTERNAL_DECL duk_hstring * duk_heap_string_intern_u32_checked(duk_hthread *thr, duk_uint32_t val)
DUK_LOCAL const duk_uint16_t duk__bufferobject_virtual_props[]
DUK_INTERNAL_DECL duk_idx_t duk_push_object_internal(duk_context *ctx)

◆ duk_hobject_enumerator_next()

DUK_INTERNAL_DECL duk_bool_t duk_hobject_enumerator_next ( duk_context * ctx,
duk_bool_t get_value )

Definition at line 46868 of file duktape-1.8.0/src/duktape.c.

46869 :
46870#endif
46871 /* compact; no need to seal because object is internal */
46872 duk_hobject_compact_props(thr, res);
46873
46874 DUK_DDD(DUK_DDDPRINT("created enumerator object: %!iT", (duk_tval *) duk_get_tval(ctx, -1)));
46875}
46876
46877/*
46878 * Returns non-zero if a key and/or value was enumerated, and:
46879 *
46880 * [enum] -> [key] (get_value == 0)
46881 * [enum] -> [key value] (get_value == 1)
46882 *
46883 * Returns zero without pushing anything on the stack otherwise.
46884 */
46886 duk_hthread *thr = (duk_hthread *) ctx;
46887 duk_hobject *e;
46888 duk_hobject *enum_target;
46889 duk_hstring *res = NULL;
46891 duk_bool_t check_existence;
46892
46893 DUK_ASSERT(ctx != NULL);
46894
46895 /* [... enum] */
46896
46897 e = duk_require_hobject(ctx, -1);
46898
46899 /* XXX use get tval ptr, more efficient */
46901 idx = (duk_uint_fast32_t) duk_require_uint(ctx, -1);
46902 duk_pop(ctx);
46903 DUK_DDD(DUK_DDDPRINT("enumeration: index is: %ld", (long) idx));
46904
46905 /* Enumeration keys are checked against the enumeration target (to see
46906 * that they still exist). In the proxy enumeration case _Target will
46907 * be the proxy, and checking key existence against the proxy is not
46908 * required (or sensible, as the keys may be fully virtual).
46909 */
46911 enum_target = duk_require_hobject(ctx, -1);
46912 DUK_ASSERT(enum_target != NULL);
46913#if defined(DUK_USE_ES6_PROXY)
46914 check_existence = (!DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(enum_target));
46915#else
46916 check_existence = 1;
46917#endif
46918 duk_pop(ctx); /* still reachable */
46919
46920 DUK_DDD(DUK_DDDPRINT("getting next enum value, enum_target=%!iO, enumerator=%!iT",
46921 (duk_heaphdr *) enum_target, (duk_tval *) duk_get_tval(ctx, -1)));
46922
46923 /* no array part */
46924 for (;;) {
46925 duk_hstring *k;
46926
46927 if (idx >= DUK_HOBJECT_GET_ENEXT(e)) {
46928 DUK_DDD(DUK_DDDPRINT("enumeration: ran out of elements"));
46929 break;
46930 }
46931
46932 /* we know these because enum objects are internally created */
46933 k = DUK_HOBJECT_E_GET_KEY(thr->heap, e, idx);
46934 DUK_ASSERT(k != NULL);
46937
46938 idx++;
46939
46940 /* recheck that the property still exists */
46941 if (check_existence && !duk_hobject_hasprop_raw(thr, enum_target, k)) {
46942 DUK_DDD(DUK_DDDPRINT("property deleted during enumeration, skip"));
46943 continue;
46944 }
46945
46946 DUK_DDD(DUK_DDDPRINT("enumeration: found element, key: %!O", (duk_heaphdr *) k));
46947 res = k;
46948 break;
46949 }
46950
46951 DUK_DDD(DUK_DDDPRINT("enumeration: updating next index to %ld", (long) idx));
46952
46953 duk_push_u32(ctx, (duk_uint32_t) idx);
46955
46956 /* [... enum] */
46957

◆ duk_hobject_find_existing_array_entry_tval_ptr()

DUK_INTERNAL_DECL duk_tval * duk_hobject_find_existing_array_entry_tval_ptr ( duk_heap * heap,
duk_hobject * obj,
duk_uarridx_t i )

Definition at line 48649 of file duktape-1.8.0/src/duktape.c.

48656 {
48657 *out_attrs = DUK_HOBJECT_E_GET_FLAGS(heap, obj, e_idx);
48658 return DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(heap, obj, e_idx);
48659 } else {
48660 *out_attrs = 0;
48661 return NULL;
48662 }
48663}

◆ duk_hobject_find_existing_entry()

DUK_INTERNAL_DECL void duk_hobject_find_existing_entry ( duk_heap * heap,
duk_hobject * obj,
duk_hstring * key,
duk_int_t * e_idx,
duk_int_t * h_idx )

Definition at line 48528 of file duktape-1.8.0/src/duktape.c.

48545 {
48546 DUK_ASSERT(obj != NULL);
48547 DUK_ASSERT(key != NULL);
48548 DUK_ASSERT(e_idx != NULL);
48549 DUK_ASSERT(h_idx != NULL);
48550 DUK_UNREF(heap);
48551
48552 if (DUK_LIKELY(DUK_HOBJECT_GET_HSIZE(obj) == 0))
48553 {
48554 /* Linear scan: more likely because most objects are small.
48555 * This is an important fast path.
48556 *
48557 * XXX: this might be worth inlining for property lookups.
48558 */
48561 duk_hstring **h_keys_base;
48562 DUK_DDD(DUK_DDDPRINT("duk_hobject_find_existing_entry() using linear scan for lookup"));
48563
48564 h_keys_base = DUK_HOBJECT_E_GET_KEY_BASE(heap, obj);
48565 n = DUK_HOBJECT_GET_ENEXT(obj);
48566 for (i = 0; i < n; i++) {
48567 if (h_keys_base[i] == key) {
48568 *e_idx = i;
48569 *h_idx = -1;
48570 return;
48571 }
48572 }
48573 }
48574#if defined(DUK_USE_HOBJECT_HASH_PART)
48575 else
48576 {
48577 /* hash lookup */
48578 duk_uint32_t n;
48579 duk_uint32_t i, step;
48580 duk_uint32_t *h_base;
48581
48582 DUK_DDD(DUK_DDDPRINT("duk_hobject_find_existing_entry() using hash part for lookup"));
48583
48584 h_base = DUK_HOBJECT_H_GET_BASE(heap, obj);
48585 n = DUK_HOBJECT_GET_HSIZE(obj);
48588
48589 for (;;) {
48590 duk_uint32_t t;
48591
48592 DUK_ASSERT_DISABLE(i >= 0); /* unsigned */
48594 t = h_base[i];
48596 (t < DUK_HOBJECT_GET_ESIZE(obj))); /* t >= 0 always true, unsigned */
48597
48598 if (t == DUK__HASH_UNUSED) {
48599 break;
48600 } else if (t == DUK__HASH_DELETED) {
48601 DUK_DDD(DUK_DDDPRINT("lookup miss (deleted) i=%ld, t=%ld",
48602 (long) i, (long) t));
48603 } else {
48605 if (DUK_HOBJECT_E_GET_KEY(heap, obj, t) == key) {
48606 DUK_DDD(DUK_DDDPRINT("lookup hit i=%ld, t=%ld -> key %p",
48607 (long) i, (long) t, (void *) key));
48608 *e_idx = t;
48609 *h_idx = i;

Referenced by duk__declvar_helper(), duk__get_own_propdesc_raw(), and duk_hobject_find_existing_entry_tval_ptr_and_attrs().

◆ duk_hobject_find_existing_entry_tval_ptr()

DUK_INTERNAL_DECL duk_tval * duk_hobject_find_existing_entry_tval_ptr ( duk_heap * heap,
duk_hobject * obj,
duk_hstring * key )

◆ duk_hobject_find_existing_entry_tval_ptr_and_attrs()

DUK_INTERNAL_DECL duk_tval * duk_hobject_find_existing_entry_tval_ptr_and_attrs ( duk_heap * heap,
duk_hobject * obj,
duk_hstring * key,
duk_int_t * out_attrs )

Definition at line 48629 of file duktape-1.8.0/src/duktape.c.

48629 {
48630 duk_int_t e_idx;
48631 duk_int_t h_idx;
48632
48633 DUK_ASSERT(obj != NULL);
48634 DUK_ASSERT(key != NULL);
48635 DUK_UNREF(heap);
48636
48637 duk_hobject_find_existing_entry(heap, obj, key, &e_idx, &h_idx);
48638 if (e_idx >= 0 && !DUK_HOBJECT_E_SLOT_IS_ACCESSOR(heap, obj, e_idx)) {
48639 return DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(heap, obj, e_idx);
48640 } else {
48641 return NULL;
48642 }
48643}
48644
48645/* For internal use: get non-accessor entry value and attributes */

References DUK_ASSERT, DUK_HOBJECT_E_GET_VALUE_TVAL_PTR, DUK_HOBJECT_E_SLOT_IS_ACCESSOR, duk_hobject_find_existing_entry(), DUK_UNREF, and NULL.

◆ duk_hobject_get_enumerated_keys()

DUK_INTERNAL_DECL duk_ret_t duk_hobject_get_enumerated_keys ( duk_context * ctx,
duk_small_uint_t enum_flags )

Definition at line 46964 of file duktape-1.8.0/src/duktape.c.

46966 {
46967 duk_remove(ctx, -2); /* -> [... key] */
46968 }
46969 return 1;
46970 } else {
46971 duk_pop(ctx); /* -> [...] */
46972 return 0;
46973 }
46974}
46975
46976/*
46977 * Get enumerated keys in an Ecmascript array. Matches Object.keys() behavior
46978 * described in E5 Section 15.2.3.14.
46979 */
46980
46982 duk_hthread *thr = (duk_hthread *) ctx;
46983 duk_hobject *e;
46986
46987 DUK_ASSERT(ctx != NULL);
46988 DUK_ASSERT(duk_get_hobject(ctx, -1) != NULL);
46989 DUK_UNREF(thr);
46990
46991 /* Create a temporary enumerator to get the (non-duplicated) key list;
46992 * the enumerator state is initialized without being needed, but that
46993 * has little impact.
46994 */
46995
46996 duk_hobject_enumerator_create(ctx, enum_flags);
46997 duk_push_array(ctx);
46998
46999 /* [enum_target enum res] */
47000
47001 e = duk_require_hobject(ctx, -2);
47002 DUK_ASSERT(e != NULL);
47003
47004 idx = 0;
47006 duk_hstring *k;

◆ duk_hobject_get_internal_value()

DUK_INTERNAL_DECL duk_bool_t duk_hobject_get_internal_value ( duk_heap * heap,
duk_hobject * obj,
duk_tval * tv )

Definition at line 48752 of file duktape-1.8.0/src/duktape.c.

48769 {

◆ duk_hobject_get_internal_value_string()

DUK_INTERNAL_DECL duk_hstring * duk_hobject_get_internal_value_string ( duk_heap * heap,
duk_hobject * obj )

Definition at line 48771 of file duktape-1.8.0/src/duktape.c.

48779 {
48780 DUK_ASSERT(!DUK_HOBJECT_E_SLOT_IS_ACCESSOR(heap, obj, e_idx));
48781 DUK_TVAL_SET_TVAL(tv_out, DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(heap, obj, e_idx));
48782 return 1;
48783 }
48784 DUK_TVAL_SET_UNDEFINED(tv_out);
48785 return 0;
48786}
48787
48789 duk_tval tv;
48790

Referenced by duk__get_own_propdesc_raw().

◆ duk_hobject_get_length()

DUK_INTERNAL_DECL duk_uint32_t duk_hobject_get_length ( duk_hthread * thr,
duk_hobject * obj )

Definition at line 52173 of file duktape-1.8.0/src/duktape.c.

52173 {
52174 duk_context *ctx = (duk_context *) thr;
52175 duk_push_hobject(ctx, obj);
52177 duk_push_u32(ctx, length);
52178 (void) duk_hobject_putprop(thr,
52179 DUK_GET_TVAL_NEGIDX(ctx, -3),
52180 DUK_GET_TVAL_NEGIDX(ctx, -2),
52181 DUK_GET_TVAL_NEGIDX(ctx, -1),
52182 0);
52183 duk_pop_n(ctx, 3);
52184}
52185
52187 duk_hobject_set_length(thr, obj, 0);
DUK_INTERNAL_DECL void duk_hobject_set_length_zero(duk_hthread *thr, duk_hobject *obj)

References DUK_GET_TVAL_NEGIDX, duk_hobject_putprop(), duk_pop_n(), duk_push_hobject(), duk_push_hstring_stridx(), duk_push_u32, and DUK_STRIDX_LENGTH.

◆ duk_hobject_get_own_propdesc()

DUK_INTERNAL_DECL duk_bool_t duk_hobject_get_own_propdesc ( duk_hthread * thr,
duk_hobject * obj,
duk_hstring * key,
duk_propdesc * out_desc,
duk_small_uint_t flags )

Definition at line 49294 of file duktape-1.8.0/src/duktape.c.

49299 {
49300 DUK_DDD(DUK_DDDPRINT("-> arguments exotic behavior overrides result: %!T -> %!T",
49301 (duk_tval *) duk_get_tval(ctx, -2),
49302 (duk_tval *) duk_get_tval(ctx, -1)));

◆ duk_hobject_getprop()

DUK_INTERNAL_DECL duk_bool_t duk_hobject_getprop ( duk_hthread * thr,
duk_tval * tv_obj,
duk_tval * tv_key )

Definition at line 49633 of file duktape-1.8.0/src/duktape.c.

49635 {
49636 data = (duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_bufobj->buf) + h_bufobj->offset + byte_off;
49637 duk_hbufferobject_validated_write(ctx, h_bufobj, data, elem_size);
49638 } else {
49639 DUK_D(DUK_DPRINT("bufferobject access out of underlying buffer, ignoring (write skipped)"));
49640 }
49641
49642 duk_pop(ctx);
49643 return 1;
49644}
49645
49646/*
49647 * GETPROP: Ecmascript property read.
49648 */
49649
49651 duk_context *ctx = (duk_context *) thr;
49652 duk_tval tv_obj_copy;
49653 duk_tval tv_key_copy;
49654 duk_hobject *curr = NULL;
49655 duk_hstring *key = NULL;
49656 duk_uint32_t arr_idx = DUK__NO_ARRAY_INDEX;
49657 duk_propdesc desc;
49658 duk_uint_t sanity;
49659
49660 DUK_DDD(DUK_DDDPRINT("getprop: thr=%p, obj=%p, key=%p (obj -> %!T, key -> %!T)",
49661 (void *) thr, (void *) tv_obj, (void *) tv_key,
49662 (duk_tval *) tv_obj, (duk_tval *) tv_key));
49663
49664 DUK_ASSERT(ctx != NULL);
49665 DUK_ASSERT(thr != NULL);
49666 DUK_ASSERT(thr->heap != NULL);
49667 DUK_ASSERT(tv_obj != NULL);
49668 DUK_ASSERT(tv_key != NULL);
49669
49671
49672 /*
49673 * Make a copy of tv_obj, tv_key, and tv_val to avoid any issues of
49674 * them being invalidated by a valstack resize.
49675 *
49676 * XXX: this is now an overkill for many fast paths. Rework this
49677 * to be faster (although switching to a valstack discipline might
49678 * be a better solution overall).
49679 */
49680
49681 DUK_TVAL_SET_TVAL(&tv_obj_copy, tv_obj);
49682 DUK_TVAL_SET_TVAL(&tv_key_copy, tv_key);
49683 tv_obj = &tv_obj_copy;
49684 tv_key = &tv_key_copy;
49685
49686 /*
49687 * Coercion and fast path processing
49688 */
49689
49690 switch (DUK_TVAL_GET_TAG(tv_obj)) {
49691 case DUK_TAG_UNDEFINED:
49692 case DUK_TAG_NULL: {
49693 /* Note: unconditional throw */
49694 DUK_DDD(DUK_DDDPRINT("base object is undefined or null -> reject"));
49695#if defined(DUK_USE_PARANOID_ERRORS)
49697#else
49698 DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot read property %s of %s",
49700#endif
49701 return 0;
49702 }
49703
49704 case DUK_TAG_BOOLEAN: {
49705 DUK_DDD(DUK_DDDPRINT("base object is a boolean, start lookup from boolean prototype"));
49706 curr = thr->builtins[DUK_BIDX_BOOLEAN_PROTOTYPE];
49707 break;
49708 }
49709
49710 case DUK_TAG_STRING: {
49711 duk_hstring *h = DUK_TVAL_GET_STRING(tv_obj);
49712 duk_int_t pop_count;
49713
49714#if defined(DUK_USE_FASTINT)
49715 if (DUK_TVAL_IS_FASTINT(tv_key)) {
49716 arr_idx = duk__tval_fastint_to_arr_idx(tv_key);
49717 DUK_DDD(DUK_DDDPRINT("base object string, key is a fast-path fastint; arr_idx %ld", (long) arr_idx));
49718 pop_count = 0;
49719 } else
49720#endif
49721 if (DUK_TVAL_IS_NUMBER(tv_key)) {
49722 arr_idx = duk__tval_number_to_arr_idx(tv_key);
49723 DUK_DDD(DUK_DDDPRINT("base object string, key is a fast-path number; arr_idx %ld", (long) arr_idx));
49724 pop_count = 0;
49725 } else {
49726 arr_idx = duk__push_tval_to_hstring_arr_idx(ctx, tv_key, &key);
49727 DUK_ASSERT(key != NULL);
49728 DUK_DDD(DUK_DDDPRINT("base object string, key is a non-fast-path number; after "
49729 "coercion key is %!T, arr_idx %ld",
49730 (duk_tval *) duk_get_tval(ctx, -1), (long) arr_idx));
49731 pop_count = 1;
49732 }
49733
49734 if (arr_idx != DUK__NO_ARRAY_INDEX &&
49735 arr_idx < DUK_HSTRING_GET_CHARLEN(h)) {
49736 duk_pop_n(ctx, pop_count);
49737 duk_push_hstring(ctx, h);
49738 duk_substring(ctx, -1, arr_idx, arr_idx + 1); /* [str] -> [substr] */
49739
49740 DUK_DDD(DUK_DDDPRINT("-> %!T (base is string, key is an index inside string length "
49741 "after coercion -> return char)",
49742 (duk_tval *) duk_get_tval(ctx, -1)));
49743 return 1;
49744 }
49745
49746 if (pop_count == 0) {
49747 /* This is a pretty awkward control flow, but we need to recheck the
49748 * key coercion here.
49749 */
49750 arr_idx = duk__push_tval_to_hstring_arr_idx(ctx, tv_key, &key);
49751 DUK_ASSERT(key != NULL);
49752 DUK_DDD(DUK_DDDPRINT("base object string, key is a non-fast-path number; after "
49753 "coercion key is %!T, arr_idx %ld",
49754 (duk_tval *) duk_get_tval(ctx, -1), (long) arr_idx));
49755 }
49756
49757 if (key == DUK_HTHREAD_STRING_LENGTH(thr)) {
49758 duk_pop(ctx); /* [key] -> [] */
49759 duk_push_uint(ctx, (duk_uint_t) DUK_HSTRING_GET_CHARLEN(h)); /* [] -> [res] */
49760
49761 DUK_DDD(DUK_DDDPRINT("-> %!T (base is string, key is 'length' after coercion -> "
49762 "return string length)",
49763 (duk_tval *) duk_get_tval(ctx, -1)));
49764 return 1;
49765 }
49766 DUK_DDD(DUK_DDDPRINT("base object is a string, start lookup from string prototype"));
49767 curr = thr->builtins[DUK_BIDX_STRING_PROTOTYPE];
49768 goto lookup; /* avoid double coercion */
49769 }
49770
49771 case DUK_TAG_OBJECT: {
49772 duk_tval *tmp;
49773
49774 curr = DUK_TVAL_GET_OBJECT(tv_obj);
49775 DUK_ASSERT(curr != NULL);
49776
49777 tmp = duk__getprop_shallow_fastpath_array_tval(thr, curr, tv_key);
49778 if (tmp) {
49779 duk_push_tval(ctx, tmp);
49780
49781 DUK_DDD(DUK_DDDPRINT("-> %!T (base is object, key is a number, array part "
49782 "fast path)",
49783 (duk_tval *) duk_get_tval(ctx, -1)));
49784 return 1;
49785 }
49786
49787 if (duk__getprop_fastpath_bufobj_tval(thr, curr, tv_key) != 0) {
49788 /* Read value pushed on stack. */
49789 DUK_DDD(DUK_DDDPRINT("-> %!T (base is bufobj, key is a number, bufferobject "
49790 "fast path)",
49791 (duk_tval *) duk_get_tval(ctx, -1)));
49792 return 1;
49793 }
49794
49795#if defined(DUK_USE_ES6_PROXY)
49797 duk_hobject *h_target;
49798
49799 if (duk__proxy_check_prop(thr, curr, DUK_STRIDX_GET, tv_key, &h_target)) {
49800 /* -> [ ... trap handler ] */
49801 DUK_DDD(DUK_DDDPRINT("-> proxy object 'get' for key %!T", (duk_tval *) tv_key));
49802 duk_push_hobject(ctx, h_target); /* target */
49803 duk_push_tval(ctx, tv_key); /* P */
49804 duk_push_tval(ctx, tv_obj); /* Receiver: Proxy object */
49805 duk_call_method(ctx, 3 /*nargs*/);
49806
49807 /* Target object must be checked for a conflicting
49808 * non-configurable property.
49809 */
49810 arr_idx = duk__push_tval_to_hstring_arr_idx(ctx, tv_key, &key);
49811 DUK_ASSERT(key != NULL);
49812
49813 if (duk__get_own_propdesc_raw(thr, h_target, key, arr_idx, &desc, DUK_GETDESC_FLAG_PUSH_VALUE)) {
49814 duk_tval *tv_hook = duk_require_tval(ctx, -3); /* value from hook */
49815 duk_tval *tv_targ = duk_require_tval(ctx, -1); /* value from target */
49816 duk_bool_t datadesc_reject;
49817 duk_bool_t accdesc_reject;
49818
49819 DUK_DDD(DUK_DDDPRINT("proxy 'get': target has matching property %!O, check for "
49820 "conflicting property; tv_hook=%!T, tv_targ=%!T, desc.flags=0x%08lx, "
49821 "desc.get=%p, desc.set=%p",
49822 (duk_heaphdr *) key, (duk_tval *) tv_hook, (duk_tval *) tv_targ,
49823 (unsigned long) desc.flags,
49824 (void *) desc.get, (void *) desc.set));
49825
49826 datadesc_reject = !(desc.flags & DUK_PROPDESC_FLAG_ACCESSOR) &&
49829 !duk_js_samevalue(tv_hook, tv_targ);
49830 accdesc_reject = (desc.flags & DUK_PROPDESC_FLAG_ACCESSOR) &&
49832 (desc.get == NULL) &&
49833 !DUK_TVAL_IS_UNDEFINED(tv_hook);
49834 if (datadesc_reject || accdesc_reject) {
49836 }
49837
49838 duk_pop_2(ctx);
49839 } else {
49840 duk_pop(ctx);
49841 }
49842 return 1; /* return value */
49843 }
49844
49845 curr = h_target; /* resume lookup from target */
49846 DUK_TVAL_SET_OBJECT(tv_obj, curr);
49847 }
49848#endif /* DUK_USE_ES6_PROXY */
49849
49851 arr_idx = duk__push_tval_to_hstring_arr_idx(ctx, tv_key, &key);
49852 DUK_ASSERT(key != NULL);
49853
49854 if (duk__check_arguments_map_for_get(thr, curr, key, &desc)) {
49855 DUK_DDD(DUK_DDDPRINT("-> %!T (base is object with arguments exotic behavior, "
49856 "key matches magically bound property -> skip standard "
49857 "Get with replacement value)",
49858 (duk_tval *) duk_get_tval(ctx, -1)));
49859
49860 /* no need for 'caller' post-check, because 'key' must be an array index */
49861
49862 duk_remove(ctx, -2); /* [key result] -> [result] */
49863 return 1;
49864 }
49865
49866 goto lookup; /* avoid double coercion */
49867 }
49868 break;
49869 }
49870
49871 /* Buffer has virtual properties similar to string, but indexed values
49872 * are numbers, not 1-byte buffers/strings which would perform badly.
49873 */
49874 case DUK_TAG_BUFFER: {
49875 duk_hbuffer *h = DUK_TVAL_GET_BUFFER(tv_obj);
49876 duk_int_t pop_count;
49877
49878 /*
49879 * Because buffer values are often looped over, a number fast path
49880 * is important.
49881 */
49882
49883#if defined(DUK_USE_FASTINT)
49884 if (DUK_TVAL_IS_FASTINT(tv_key)) {
49885 arr_idx = duk__tval_fastint_to_arr_idx(tv_key);
49886 DUK_DDD(DUK_DDDPRINT("base object buffer, key is a fast-path fastint; arr_idx %ld", (long) arr_idx));
49887 pop_count = 0;
49888 }
49889 else
49890#endif
49891 if (DUK_TVAL_IS_NUMBER(tv_key)) {
49892 arr_idx = duk__tval_number_to_arr_idx(tv_key);
49893 DUK_DDD(DUK_DDDPRINT("base object buffer, key is a fast-path number; arr_idx %ld", (long) arr_idx));
49894 pop_count = 0;
49895 } else {
49896 arr_idx = duk__push_tval_to_hstring_arr_idx(ctx, tv_key, &key);
49897 DUK_ASSERT(key != NULL);
49898 DUK_DDD(DUK_DDDPRINT("base object buffer, key is a non-fast-path number; after "
49899 "coercion key is %!T, arr_idx %ld",
49900 (duk_tval *) duk_get_tval(ctx, -1), (long) arr_idx));
49901 pop_count = 1;
49902 }
49903
49904 if (arr_idx != DUK__NO_ARRAY_INDEX &&
49905 arr_idx < DUK_HBUFFER_GET_SIZE(h)) {
49906 duk_pop_n(ctx, pop_count);
49907 duk_push_uint(ctx, ((duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h))[arr_idx]);
49908
49909 DUK_DDD(DUK_DDDPRINT("-> %!T (base is buffer, key is an index inside buffer length "
49910 "after coercion -> return byte as number)",
49911 (duk_tval *) duk_get_tval(ctx, -1)));
49912 return 1;
49913 }
49914
49915 if (pop_count == 0) {
49916 /* This is a pretty awkward control flow, but we need to recheck the
49917 * key coercion here.
49918 */
49919 arr_idx = duk__push_tval_to_hstring_arr_idx(ctx, tv_key, &key);
49920 DUK_ASSERT(key != NULL);
49921 DUK_DDD(DUK_DDDPRINT("base object buffer, key is a non-fast-path number; after "
49922 "coercion key is %!T, arr_idx %ld",
49923 (duk_tval *) duk_get_tval(ctx, -1), (long) arr_idx));
49924 }
49925
49926 if (key == DUK_HTHREAD_STRING_LENGTH(thr) ||
49927 key == DUK_HTHREAD_STRING_BYTE_LENGTH(thr)) {
49928 duk_pop(ctx); /* [key] -> [] */
49929 duk_push_uint(ctx, (duk_uint_t) DUK_HBUFFER_GET_SIZE(h)); /* [] -> [res] */
49930
49931 DUK_DDD(DUK_DDDPRINT("-> %!T (base is buffer, key is 'length' or 'byteLength' "
49932 "after coercion -> return buffer length)",
49933 (duk_tval *) duk_get_tval(ctx, -1)));
49934 return 1;
49935 } else if (key == DUK_HTHREAD_STRING_BYTE_OFFSET(thr)) {
49936 duk_pop(ctx); /* [key] -> [] */
49937 duk_push_uint(ctx, 0); /* [] -> [res] */
49938
49939 DUK_DDD(DUK_DDDPRINT("-> %!T (base is buffer, key is 'byteOffset' after coercion -> "
49940 "return 0 for consistency with Buffer objects)",
49941 (duk_tval *) duk_get_tval(ctx, -1)));
49942 return 1;
49943 } else if (key == DUK_HTHREAD_STRING_BYTES_PER_ELEMENT(thr)) {
49944 duk_pop(ctx); /* [key] -> [] */
49945 duk_push_uint(ctx, 1); /* [] -> [res] */
49946
49947 DUK_DDD(DUK_DDDPRINT("-> %!T (base is buffer, key is 'BYTES_PER_ELEMENT' after coercion -> "
49948 "return 1 for consistency with Buffer objects)",
49949 (duk_tval *) duk_get_tval(ctx, -1)));
49950 return 1;
49951 }
49952
49953 DUK_DDD(DUK_DDDPRINT("base object is a buffer, start lookup from buffer prototype"));
49954 curr = thr->builtins[DUK_BIDX_BUFFER_PROTOTYPE];
49955 goto lookup; /* avoid double coercion */
49956 }
49957
49958 case DUK_TAG_POINTER: {
49959 DUK_DDD(DUK_DDDPRINT("base object is a pointer, start lookup from pointer prototype"));
49960 curr = thr->builtins[DUK_BIDX_POINTER_PROTOTYPE];
49961 break;
49962 }
49963
49964 case DUK_TAG_LIGHTFUNC: {
49965 duk_int_t lf_flags = DUK_TVAL_GET_LIGHTFUNC_FLAGS(tv_obj);
49966
49967 /* Must coerce key: if key is an object, it may coerce to e.g. 'length'. */
49968 arr_idx = duk__push_tval_to_hstring_arr_idx(ctx, tv_key, &key);
49969
49970 if (key == DUK_HTHREAD_STRING_LENGTH(thr)) {
49971 duk_int_t lf_len = DUK_LFUNC_FLAGS_GET_LENGTH(lf_flags);
49972 duk_pop(ctx);
49973 duk_push_int(ctx, lf_len);
49974 return 1;
49975 } else if (key == DUK_HTHREAD_STRING_NAME(thr)) {
49976 duk_pop(ctx);
49977 duk_push_lightfunc_name(ctx, tv_obj);
49978 return 1;
49979 }
49980
49981 DUK_DDD(DUK_DDDPRINT("base object is a lightfunc, start lookup from function prototype"));
49982 curr = thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE];
49983 goto lookup; /* avoid double coercion */
49984 }
49985
49986#if defined(DUK_USE_FASTINT)
49987 case DUK_TAG_FASTINT:
49988#endif
49989 default: {
49990 /* number */
49991 DUK_DDD(DUK_DDDPRINT("base object is a number, start lookup from number prototype"));
49994 curr = thr->builtins[DUK_BIDX_NUMBER_PROTOTYPE];
49995 break;
49996 }
49997 }
49998
49999 /* key coercion (unless already coerced above) */
50000 DUK_ASSERT(key == NULL);
50001 arr_idx = duk__push_tval_to_hstring_arr_idx(ctx, tv_key, &key);
50002 DUK_ASSERT(key != NULL);
50003
50004 /*
50005 * Property lookup
50006 */
50007
50008 lookup:
50009 /* [key] (coerced) */
50010 DUK_ASSERT(curr != NULL);
50011 DUK_ASSERT(key != NULL);
50012
50014 do {
50015 if (!duk__get_own_propdesc_raw(thr, curr, key, arr_idx, &desc, DUK_GETDESC_FLAG_PUSH_VALUE)) {
50016 goto next_in_chain;
50017 }
50018
50019 if (desc.get != NULL) {
50020 /* accessor with defined getter */
50022
50023 duk_pop(ctx); /* [key undefined] -> [key] */
50024 duk_push_hobject(ctx, desc.get);
50025 duk_push_tval(ctx, tv_obj); /* note: original, uncoerced base */
50026#ifdef DUK_USE_NONSTD_GETTER_KEY_ARGUMENT
50027 duk_dup(ctx, -3);
50028 duk_call_method(ctx, 1); /* [key getter this key] -> [key retval] */
50029#else
50030 duk_call_method(ctx, 0); /* [key getter this] -> [key retval] */
50031#endif
50032 } else {
50033 /* [key value] or [key undefined] */
50034
50035 /* data property or accessor without getter */
50037 (desc.get == NULL));
50038
50039 /* if accessor without getter, return value is undefined */
50041 duk_is_undefined(ctx, -1));
50042
50043 /* Note: for an accessor without getter, falling through to
50044 * check for "caller" exotic behavior is unnecessary as
50045 * "undefined" will never activate the behavior. But it does
50046 * no harm, so we'll do it anyway.
50047 */
50048 }
50049
50050 goto found; /* [key result] */
50051
50052 next_in_chain:
50053 /* XXX: option to pretend property doesn't exist if sanity limit is
50054 * hit might be useful.
50055 */
50056 if (sanity-- == 0) {
50058 }
50059 curr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, curr);
50060 } while (curr);
50061
50062 /*
50063 * Not found
50064 */
50065
50066 duk_to_undefined(ctx, -1); /* [key] -> [undefined] (default value) */
50067
50068 DUK_DDD(DUK_DDDPRINT("-> %!T (not found)", (duk_tval *) duk_get_tval(ctx, -1)));
50069 return 0;
50070
50071 /*
50072 * Found; post-processing (Function and arguments objects)
50073 */
50074
50075 found:
50076 /* [key result] */
50077
50078#if !defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)
50079 /* Special behavior for 'caller' property of (non-bound) function objects
50080 * and non-strict Arguments objects: if 'caller' -value- (!) is a strict
50081 * mode function, throw a TypeError (E5 Sections 15.3.5.4, 10.6).
50082 * Quite interestingly, a non-strict function with no formal arguments
50083 * will get an arguments object -without- special 'caller' behavior!
50084 *
50085 * The E5.1 spec is a bit ambiguous if this special behavior applies when
50086 * a bound function is the base value (not the 'caller' value): Section
50087 * 15.3.4.5 (describing bind()) states that [[Get]] for bound functions
50088 * matches that of Section 15.3.5.4 ([[Get]] for Function instances).
50089 * However, Section 13.3.5.4 has "NOTE: Function objects created using
50090 * Function.prototype.bind use the default [[Get]] internal method."
50091 * The current implementation assumes this means that bound functions
50092 * should not have the special [[Get]] behavior.
50093 *
50094 * The E5.1 spec is also a bit unclear if the TypeError throwing is
50095 * applied if the 'caller' value is a strict bound function. The
50096 * current implementation will throw even for both strict non-bound
50097 * and strict bound functions.
50098 *
50099 * See test-dev-strict-func-as-caller-prop-value.js for quite extensive
50100 * tests.
50101 *
50102 * This exotic behavior is disabled when the non-standard 'caller' property
50103 * is enabled, as it conflicts with the free use of 'caller'.
50104 */
50105 if (key == DUK_HTHREAD_STRING_CALLER(thr) &&
50106 DUK_TVAL_IS_OBJECT(tv_obj)) {
50107 duk_hobject *orig = DUK_TVAL_GET_OBJECT(tv_obj);
50108 DUK_ASSERT(orig != NULL);
50109
50112 duk_hobject *h;
50113
50114 /* XXX: The TypeError is currently not applied to bound
50115 * functions because the 'strict' flag is not copied by
50116 * bind(). This may or may not be correct, the specification
50117 * only refers to the value being a "strict mode Function
50118 * object" which is ambiguous.
50119 */
#define DUK_BIDX_POINTER_PROTOTYPE
DUK_INTERNAL_DECL void duk_push_lightfunc_name(duk_context *ctx, duk_tval *tv)
DUK_LOCAL_DECL duk_bool_t duk__check_arguments_map_for_get(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *temp_desc)
#define DUK_BIDX_NUMBER_PROTOTYPE
#define DUK_STR_PROTOTYPE_CHAIN_LIMIT
#define DUK_BIDX_BOOLEAN_PROTOTYPE
#define DUK_BIDX_BUFFER_PROTOTYPE
#define DUK_LFUNC_FLAGS_GET_LENGTH(lf_flags)
#define DUK_HTHREAD_STRING_CALLER(thr)

Referenced by duk__getvar_helper().

◆ duk_hobject_hasprop()

DUK_INTERNAL_DECL duk_bool_t duk_hobject_hasprop ( duk_hthread * thr,
duk_tval * tv_obj,
duk_tval * tv_key )

Definition at line 50129 of file duktape-1.8.0/src/duktape.c.

50146 {
50147 duk_context *ctx = (duk_context *) thr;
50148 duk_tval tv_key_copy;
50149 duk_hobject *obj;
50150 duk_hstring *key;
50151 duk_uint32_t arr_idx;
50152 duk_bool_t rc;
50153 duk_propdesc desc;
50154
50155 DUK_DDD(DUK_DDDPRINT("hasprop: thr=%p, obj=%p, key=%p (obj -> %!T, key -> %!T)",
50156 (void *) thr, (void *) tv_obj, (void *) tv_key,
50157 (duk_tval *) tv_obj, (duk_tval *) tv_key));
50158
50159 DUK_ASSERT(thr != NULL);
50160 DUK_ASSERT(thr->heap != NULL);
50161 DUK_ASSERT(tv_obj != NULL);
50162 DUK_ASSERT(tv_key != NULL);
50164
50165 DUK_TVAL_SET_TVAL(&tv_key_copy, tv_key);
50166 tv_key = &tv_key_copy;
50167
50168 /*
50169 * The 'in' operator requires an object as its right hand side,
50170 * throwing a TypeError unconditionally if this is not the case.
50171 *
50172 * However, lightfuncs need to behave like fully fledged objects
50173 * here to be maximally transparent, so we need to handle them
50174 * here.
50175 */
50176
50177 /* XXX: Refactor key coercion so that it's only called once. It can't
50178 * be trivially lifted here because the object must be type checked
50179 * first.
50180 */
50181
50182 if (DUK_TVAL_IS_OBJECT(tv_obj)) {
50183 obj = DUK_TVAL_GET_OBJECT(tv_obj);
50184 DUK_ASSERT(obj != NULL);
50185
50186 arr_idx = duk__push_tval_to_hstring_arr_idx(ctx, tv_key, &key);
50187 } else if (DUK_TVAL_IS_LIGHTFUNC(tv_obj)) {
50188 arr_idx = duk__push_tval_to_hstring_arr_idx(ctx, tv_key, &key);
50189 if (duk__key_is_lightfunc_ownprop(thr, key)) {
50190 /* FOUND */
50191 rc = 1;
50192 goto pop_and_return;
50193 }
50194
50195 /* If not found, resume existence check from Function.prototype.
50196 * We can just substitute the value in this case; nothing will
50197 * need the original base value (as would be the case with e.g.
50198 * setters/getters.
50199 */
50200 obj = thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE];
50201 } else {
50202 /* Note: unconditional throw */
50203 DUK_DDD(DUK_DDDPRINT("base object is not an object -> reject"));
50205 }
50206
50207 /* XXX: fast path for arrays? */
50208
50209 DUK_ASSERT(key != NULL);
50210 DUK_ASSERT(obj != NULL);
50211 DUK_UNREF(arr_idx);
50212
50213#if defined(DUK_USE_ES6_PROXY)
50215 duk_hobject *h_target;
50216 duk_bool_t tmp_bool;
50217
50218 /* XXX: the key in 'key in obj' is string coerced before we're called
50219 * (which is the required behavior in E5/E5.1/E6) so the key is a string
50220 * here already.
50221 */
50222
50223 if (duk__proxy_check_prop(thr, obj, DUK_STRIDX_HAS, tv_key, &h_target)) {
50224 /* [ ... key trap handler ] */
50225 DUK_DDD(DUK_DDDPRINT("-> proxy object 'has' for key %!T", (duk_tval *) tv_key));
50226 duk_push_hobject(ctx, h_target); /* target */
50227 duk_push_tval(ctx, tv_key); /* P */
50228 duk_call_method(ctx, 2 /*nargs*/);
50229 tmp_bool = duk_to_boolean(ctx, -1);
50230 if (!tmp_bool) {
50231 /* Target object must be checked for a conflicting
50232 * non-configurable property.
50233 */
50234
50235 if (duk__get_own_propdesc_raw(thr, h_target, key, arr_idx, &desc, 0 /*flags*/)) { /* don't push value */
50236 DUK_DDD(DUK_DDDPRINT("proxy 'has': target has matching property %!O, check for "
50237 "conflicting property; desc.flags=0x%08lx, "
50238 "desc.get=%p, desc.set=%p",
50239 (duk_heaphdr *) key, (unsigned long) desc.flags,
50240 (void *) desc.get, (void *) desc.set));
50241 /* XXX: Extensibility check for target uses IsExtensible(). If we
50242 * implemented the isExtensible trap and didn't reject proxies as
50243 * proxy targets, it should be respected here.
50244 */
50245 if (!((desc.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) && /* property is configurable and */
50246 DUK_HOBJECT_HAS_EXTENSIBLE(h_target))) { /* ... target is extensible */
50248 }
50249 }
50250 }
50251
#define DUK_STRIDX_HAS

◆ duk_hobject_hasprop_raw()

DUK_INTERNAL_DECL duk_bool_t duk_hobject_hasprop_raw ( duk_hthread * thr,
duk_hobject * obj,
duk_hstring * key )

Definition at line 50265 of file duktape-1.8.0/src/duktape.c.

50265 :
50266 duk_pop(ctx); /* [ key ] -> [] */
50267 return rc;
50268}
50269
50270/*
50271 * HASPROP variant used internally.
50272 *
50273 * This primitive must never throw an error, callers rely on this.
50274 * In particular, don't throw an error for prototype loops; instead,
50275 * pretend like the property doesn't exist if a prototype sanity limit
50276 * is reached.

◆ duk_hobject_object_get_own_property_descriptor()

DUK_INTERNAL_DECL duk_ret_t duk_hobject_object_get_own_property_descriptor ( duk_context * ctx)

Definition at line 52195 of file duktape-1.8.0/src/duktape.c.

52200 {
52201 return (duk_uint32_t) val;
52202 }
52203 return 0;
52204}
52205
52206/*
52207 * Object.getOwnPropertyDescriptor() (E5 Sections 15.2.3.3, 8.10.4)
52208 *
52209 * This is an actual function call.
52210 */
52211
52213 duk_hthread *thr = (duk_hthread *) ctx;
52214 duk_hobject *obj;
52215 duk_hstring *key;
52216 duk_propdesc pd;
52217 duk_bool_t rc;
52218
52219 DUK_ASSERT(ctx != NULL);
52220 DUK_ASSERT(thr != NULL);
52221 DUK_ASSERT(thr->heap != NULL);
52222
52224 (void) duk_to_string(ctx, 1);
52225 key = duk_require_hstring(ctx, 1);
52226
52227 DUK_ASSERT(obj != NULL);
52228 DUK_ASSERT(key != NULL);
52229
52231
52233 if (!rc) {
52234 duk_push_undefined(ctx);
52235
52236 /* [obj key undefined] */
52237 return 1;
52238 }
52239
52240 duk_push_object(ctx);
52241
52242 /* [obj key value desc] */
52243
52244 if (DUK_PROPDESC_IS_ACCESSOR(&pd)) {
52245 /* If a setter/getter is missing (undefined), the descriptor must
52246 * still have the property present with the value 'undefined'.
52247 */
52248 if (pd.get) {
52249 duk_push_hobject(ctx, pd.get);
52250 } else {
52251 duk_push_undefined(ctx);
52252 }
52254 if (pd.set) {
52255 duk_push_hobject(ctx, pd.set);
52256 } else {
52257 duk_push_undefined(ctx);
52258 }
#define DUK_PROPDESC_IS_ACCESSOR(p)

◆ duk_hobject_object_is_sealed_frozen_helper()

DUK_INTERNAL_DECL duk_bool_t duk_hobject_object_is_sealed_frozen_helper ( duk_hthread * thr,
duk_hobject * obj,
duk_bool_t is_frozen )

Definition at line 53352 of file duktape-1.8.0/src/duktape.c.

53369 {
53371
53372 DUK_ASSERT(obj != NULL);
53373 DUK_UNREF(thr);
53374
53375 /* Note: no allocation pressure, no need to check refcounts etc */
53376
53377 /* must not be extensible */
53378 if (DUK_HOBJECT_HAS_EXTENSIBLE(obj)) {
53379 return 0;
53380 }
53381
53382 /* all virtual properties are non-configurable and non-writable */
53383
53384 /* entry part must not contain any configurable properties, or
53385 * writable properties (if is_frozen).
53386 */
53387 for (i = 0; i < DUK_HOBJECT_GET_ENEXT(obj); i++) {
53388 duk_small_uint_t flags;
53389
53390 if (!DUK_HOBJECT_E_GET_KEY(thr->heap, obj, i)) {
53391 continue;
53392 }
53393
53394 /* avoid multiple computations of flags address; bypasses macros */
53395 flags = (duk_small_uint_t) DUK_HOBJECT_E_GET_FLAGS(thr->heap, obj, i);
53396
53397 if (flags & DUK_PROPDESC_FLAG_CONFIGURABLE) {
53398 return 0;
53399 }
53400 if (is_frozen &&
53401 !(flags & DUK_PROPDESC_FLAG_ACCESSOR) &&

Referenced by duk_bi_object_constructor_is_extensible().

◆ duk_hobject_object_ownprop_helper()

DUK_INTERNAL_DECL duk_bool_t duk_hobject_object_ownprop_helper ( duk_context * ctx,
duk_small_uint_t required_desc_flags )

Definition at line 53256 of file duktape-1.8.0/src/duktape.c.

53256 :
53258 return;
53259
53260 fail_not_configurable:
53262 return;
53263
53264 fail_array_length_partial:
53266 return;
53267}
53268
53269/*
53270 * Object.prototype.hasOwnProperty() and Object.prototype.propertyIsEnumerable().
53271 */
53272
53274 duk_hthread *thr = (duk_hthread *) ctx;
#define DUK_STR_ARRAY_LENGTH_WRITE_FAILED
#define DUK_STR_NOT_EXTENSIBLE

◆ duk_hobject_object_seal_freeze_helper()

DUK_INTERNAL_DECL void duk_hobject_object_seal_freeze_helper ( duk_hthread * thr,
duk_hobject * obj,
duk_bool_t is_freeze )

Definition at line 53291 of file duktape-1.8.0/src/duktape.c.

53308 {
53310
53311 DUK_ASSERT(thr != NULL);
53312 DUK_ASSERT(thr->heap != NULL);
53313 DUK_ASSERT(obj != NULL);
53314
53316
53317#if defined(DUK_USE_ROM_OBJECTS)
53319 DUK_DD(DUK_DDPRINT("attempt to seal/freeze a readonly object, reject"));
53321 }
53322#endif
53323
53324 /*
53325 * Abandon array part because all properties must become non-configurable.
53326 * Note that this is now done regardless of whether this is always the case
53327 * (skips check, but performance problem if caller would do this many times
53328 * for the same object; not likely).
53329 */
53330
53333
53334 for (i = 0; i < DUK_HOBJECT_GET_ENEXT(obj); i++) {
53335 duk_uint8_t *fp;
53336
53337 /* since duk__abandon_array_checked() causes a resize, there should be no gaps in keys */
53338 DUK_ASSERT(DUK_HOBJECT_E_GET_KEY(thr->heap, obj, i) != NULL);
53339

◆ duk_hobject_pc2line_pack()

DUK_INTERNAL_DECL void duk_hobject_pc2line_pack ( duk_hthread * thr,
duk_compiler_instr * instrs,
duk_uint_fast32_t length )

Definition at line 47186 of file duktape-1.8.0/src/duktape.c.

47203 {
47204 duk_context *ctx = (duk_context *) thr;
47205 duk_hbuffer_dynamic *h_buf;
47206 duk_bitencoder_ctx be_ctx_alloc;
47207 duk_bitencoder_ctx *be_ctx = &be_ctx_alloc;
47208 duk_uint32_t *hdr;
47209 duk_size_t new_size;
47210 duk_uint_fast32_t num_header_entries;
47211 duk_uint_fast32_t curr_offset;
47212 duk_int_fast32_t curr_line, next_line, diff_line;
47213 duk_uint_fast32_t curr_pc;
47214 duk_uint_fast32_t hdr_index;
47215
47217
47218 /* XXX: add proper spare handling to dynamic buffer, to minimize
47219 * reallocs; currently there is no spare at all.
47220 */
47221
47222 num_header_entries = (length + DUK_PC2LINE_SKIP - 1) / DUK_PC2LINE_SKIP;
47223 curr_offset = (duk_uint_fast32_t) (sizeof(duk_uint32_t) + num_header_entries * sizeof(duk_uint32_t) * 2);
47224
47225 duk_push_dynamic_buffer(ctx, (duk_size_t) curr_offset);
47226 h_buf = (duk_hbuffer_dynamic *) duk_get_hbuffer(ctx, -1);
47227 DUK_ASSERT(h_buf != NULL);
47229
47230 hdr = (duk_uint32_t *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, h_buf);
47231 DUK_ASSERT(hdr != NULL);
47232 hdr[0] = (duk_uint32_t) length; /* valid pc range is [0, length[ */
47233
47234 curr_pc = 0U;
47235 while (curr_pc < length) {
47236 new_size = (duk_size_t) (curr_offset + DUK_PC2LINE_MAX_DIFF_LENGTH);
47237 duk_hbuffer_resize(thr, h_buf, new_size);
47238
47239 hdr = (duk_uint32_t *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, h_buf);
47240 DUK_ASSERT(hdr != NULL);
47241 DUK_ASSERT(curr_pc < length);
47242 hdr_index = 1 + (curr_pc / DUK_PC2LINE_SKIP) * 2;
47243 curr_line = (duk_int_fast32_t) instrs[curr_pc].line;
47244 hdr[hdr_index + 0] = (duk_uint32_t) curr_line;
47245 hdr[hdr_index + 1] = (duk_uint32_t) curr_offset;
47246
47247#if 0
47248 DUK_DDD(DUK_DDDPRINT("hdr[%ld]: pc=%ld line=%ld offset=%ld",
47249 (long) (curr_pc / DUK_PC2LINE_SKIP),
47250 (long) curr_pc,
47251 (long) hdr[hdr_index + 0],
47252 (long) hdr[hdr_index + 1]));
47253#endif
47254
47255 DUK_MEMZERO(be_ctx, sizeof(*be_ctx));
47256 be_ctx->data = ((duk_uint8_t *) hdr) + curr_offset;
47258
47259 for (;;) {
47260 curr_pc++;
47261 if ( ((curr_pc % DUK_PC2LINE_SKIP) == 0) || /* end of diff run */
47262 (curr_pc >= length) ) { /* end of bytecode */
47263 break;
47264 }
47265 DUK_ASSERT(curr_pc < length);
47266 next_line = (duk_int32_t) instrs[curr_pc].line;
47267 diff_line = next_line - curr_line;
47268
47269#if 0
47270 DUK_DDD(DUK_DDDPRINT("curr_line=%ld, next_line=%ld -> diff_line=%ld",
47271 (long) curr_line, (long) next_line, (long) diff_line));
47272#endif
47273
47274 if (diff_line == 0) {
47275 /* 0 */
47276 duk_be_encode(be_ctx, 0, 1);
47277 } else if (diff_line >= 1 && diff_line <= 4) {
47278 /* 1 0 <2 bits> */
47279 duk_be_encode(be_ctx, (0x02 << 2) + (diff_line - 1), 4);
47280 } else if (diff_line >= -0x80 && diff_line <= 0x7f) {
47281 /* 1 1 0 <8 bits> */
47282 DUK_ASSERT(diff_line + 0x80 >= 0 && diff_line + 0x80 <= 0xff);
47283 duk_be_encode(be_ctx, (0x06 << 8) + (diff_line + 0x80), 11);
47284 } else {
47285 /* 1 1 1 <32 bits>
47286 * Encode in two parts to avoid bitencode 24-bit limitation
47287 */
47288 duk_be_encode(be_ctx, (0x07 << 16) + ((next_line >> 16) & 0xffffU), 19);
47289 duk_be_encode(be_ctx, next_line & 0xffffU, 16);
47290 }
47291
47292 curr_line = next_line;
47293 }
47294
duk_int32_t duk_int_fast32_t
#define DUK_PC2LINE_MAX_DIFF_LENGTH
#define DUK_PC2LINE_SKIP

◆ duk_hobject_pc2line_query()

DUK_INTERNAL_DECL duk_uint_fast32_t duk_hobject_pc2line_query ( duk_context * ctx,
duk_idx_t idx_func,
duk_uint_fast32_t pc )

Definition at line 47398 of file duktape-1.8.0/src/duktape.c.

47400 {
47401 /* 0: no change */
47402 }
47403
47404 n--;
47405 }
47406
47407 DUK_DDD(DUK_DDDPRINT("pc2line lookup result: pc %ld -> line %ld", (long) pc, (long) curr_line));
47408 return curr_line;
47409
47410 error:
47411 DUK_D(DUK_DPRINT("pc2line conversion failed for pc=%ld", (long) pc));
47412 return 0;
47413}
47414
47416 duk_hbuffer_fixed *pc2line;
47417 duk_uint_fast32_t line;
47418
47419 /* XXX: now that pc2line is used by the debugger quite heavily in

Referenced by duk__error_getter_helper().

◆ duk_hobject_prepare_property_descriptor()

DUK_INTERNAL_DECL void duk_hobject_prepare_property_descriptor ( duk_context * ctx,
duk_idx_t idx_in,
duk_uint_t * out_defprop_flags,
duk_idx_t * out_idx_value,
duk_hobject ** out_getter,
duk_hobject ** out_setter )

Definition at line 52276 of file duktape-1.8.0/src/duktape.c.

52298 {
52299 duk_hthread *thr = (duk_hthread *) ctx;
52300 duk_idx_t idx_value = -1;
52301 duk_hobject *getter = NULL;
52302 duk_hobject *setter = NULL;
52303 duk_bool_t is_data_desc = 0;
52304 duk_bool_t is_acc_desc = 0;
52305 duk_uint_t defprop_flags = 0;
52306
52307 DUK_ASSERT(ctx != NULL);
52308 DUK_ASSERT(out_defprop_flags != NULL);
52309 DUK_ASSERT(out_idx_value != NULL);
52310 DUK_ASSERT(out_getter != NULL);
52311 DUK_ASSERT(out_setter != NULL);
52312
52313 /* Must be an object, otherwise TypeError (E5.1 Section 8.10.5, step 1). */
52314 idx_in = duk_require_normalize_index(ctx, idx_in);
52315 (void) duk_require_hobject(ctx, idx_in);
52316
52317 /* The coercion order must match the ToPropertyDescriptor() algorithm
52318 * so that side effects in coercion happen in the correct order.
52319 * (This order also happens to be compatible with duk_def_prop(),
52320 * although it doesn't matter in practice.)
52321 */
52322
52323 if (duk_get_prop_stridx(ctx, idx_in, DUK_STRIDX_VALUE)) {
52324 is_data_desc = 1;
52325 defprop_flags |= DUK_DEFPROP_HAVE_VALUE;
52326 idx_value = duk_get_top_index(ctx);
52327 /* Leave 'value' on stack */
52328 } else {
52329 duk_pop(ctx);
52330 }
52331
52332 if (duk_get_prop_stridx(ctx, idx_in, DUK_STRIDX_WRITABLE)) {
52333 is_data_desc = 1;
52334 if (duk_to_boolean(ctx, -1)) {
52336 } else {
52337 defprop_flags |= DUK_DEFPROP_HAVE_WRITABLE;
52338 }
52339 }
52340 duk_pop(ctx);
52341
52342 if (duk_get_prop_stridx(ctx, idx_in, DUK_STRIDX_GET)) {
52343 duk_tval *tv = duk_require_tval(ctx, -1);
52344 duk_hobject *h_get;
52345
52346 if (DUK_TVAL_IS_UNDEFINED(tv)) {
52347 /* undefined is accepted */
52348 DUK_ASSERT(getter == NULL);
52349 } else {
52350 /* NOTE: lightfuncs are coerced to full functions because
52351 * lightfuncs don't fit into a property value slot. This
52352 * has some side effects, see test-dev-lightfunc-accessor.js.
52353 */
52354 h_get = duk_get_hobject_or_lfunc_coerce(ctx, -1);
52355 if (h_get == NULL || !DUK_HOBJECT_IS_CALLABLE(h_get)) {
52356 goto type_error;
52357 }
52358 getter = h_get;
52359 }
52360 is_acc_desc = 1;
52361 defprop_flags |= DUK_DEFPROP_HAVE_GETTER;
52362 /* Leave 'getter' on stack */
52363 } else {
52364 duk_pop(ctx);
52365 }
52366
52367 if (duk_get_prop_stridx(ctx, idx_in, DUK_STRIDX_SET)) {
52368 duk_tval *tv = duk_require_tval(ctx, -1);
52369 duk_hobject *h_set;
52370
52371 if (DUK_TVAL_IS_UNDEFINED(tv)) {
52372 /* undefined is accepted */
52373 DUK_ASSERT(setter == NULL);
52374 } else {
52375 /* NOTE: lightfuncs are coerced to full functions because
52376 * lightfuncs don't fit into a property value slot. This
52377 * has some side effects, see test-dev-lightfunc-accessor.js.
52378 */
52379 h_set = duk_get_hobject_or_lfunc_coerce(ctx, -1);
52380 if (h_set == NULL || !DUK_HOBJECT_IS_CALLABLE(h_set)) {
52381 goto type_error;
52382 }
52383 setter = h_set;
52384 }
52385 is_acc_desc = 1;
52386 defprop_flags |= DUK_DEFPROP_HAVE_SETTER;
52387 /* Leave 'setter' on stack */
52388 } else {
52389 duk_pop(ctx);
52390 }
52391
52392 if (duk_get_prop_stridx(ctx, idx_in, DUK_STRIDX_ENUMERABLE)) {
52393 if (duk_to_boolean(ctx, -1)) {
52395 } else {
52396 defprop_flags |= DUK_DEFPROP_HAVE_ENUMERABLE;
52397 }
52398 }
52399 duk_pop(ctx);
52400
52401 if (duk_get_prop_stridx(ctx, idx_in, DUK_STRIDX_CONFIGURABLE)) {
52402 if (duk_to_boolean(ctx, -1)) {
52404 } else {
52405 defprop_flags |= DUK_DEFPROP_HAVE_CONFIGURABLE;
52406 }
52407 }
#define DUK_DEFPROP_CONFIGURABLE
#define DUK_DEFPROP_HAVE_CONFIGURABLE
#define DUK_DEFPROP_ENUMERABLE
#define DUK_DEFPROP_HAVE_ENUMERABLE
#define DUK_DEFPROP_WRITABLE
#define DUK_STRIDX_WRITABLE
#define DUK_STRIDX_VALUE

References DUK_ASSERT, DUK_DEFPROP_CONFIGURABLE, DUK_DEFPROP_ENUMERABLE, DUK_DEFPROP_HAVE_CONFIGURABLE, DUK_DEFPROP_HAVE_ENUMERABLE, DUK_DEFPROP_HAVE_GETTER, DUK_DEFPROP_HAVE_SETTER, DUK_DEFPROP_HAVE_VALUE, DUK_DEFPROP_HAVE_WRITABLE, DUK_DEFPROP_WRITABLE, DUK_ERROR_TYPE, duk_get_hobject_or_lfunc_coerce(), duk_get_prop_stridx(), duk_get_top_index(), DUK_HOBJECT_IS_CALLABLE, duk_pop(), duk_require_hobject(), duk_require_normalize_index(), duk_require_tval(), DUK_STR_INVALID_DESCRIPTOR, DUK_STRIDX_CONFIGURABLE, DUK_STRIDX_ENUMERABLE, DUK_STRIDX_GET, DUK_STRIDX_SET, DUK_STRIDX_VALUE, DUK_STRIDX_WRITABLE, duk_to_boolean(), DUK_TVAL_IS_UNDEFINED, and NULL.

◆ duk_hobject_prototype_chain_contains()

DUK_INTERNAL_DECL duk_bool_t duk_hobject_prototype_chain_contains ( duk_hthread * thr,
duk_hobject * h,
duk_hobject * p,
duk_bool_t ignore_loop )

Definition at line 47125 of file duktape-1.8.0/src/duktape.c.

47128 : %!T",
47129 (void *) obj, (duk_tval *) duk_get_tval(ctx, -1)));
47130 }
47131 duk_pop_2(ctx); /* -> [...] */
47132
47133 DUK_ASSERT_TOP(ctx, entry_top);
47134}
47135#line 1 "duk_hobject_misc.c"
47136/*
47137 * Misc support functions
47138 */
47139
47140/* include removed: duk_internal.h */
47141
47142DUK_INTERNAL duk_bool_t duk_hobject_prototype_chain_contains(duk_hthread *thr, duk_hobject *h, duk_hobject *p, duk_bool_t ignore_loop) {
47143 duk_uint_t sanity;
47144
47145 DUK_ASSERT(thr != NULL);
47146
47147 /* False if the object is NULL or the prototype 'p' is NULL.
47148 * In particular, false if both are NULL (don't compare equal).
47149 */
47150 if (h == NULL || p == NULL) {
47151 return 0;
47152 }
47153
47154 sanity = DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY;

Referenced by duk_err_augment_error_create().

◆ duk_hobject_proxy_check()

DUK_INTERNAL_DECL duk_bool_t duk_hobject_proxy_check ( duk_hthread * thr,
duk_hobject * obj,
duk_hobject ** out_target,
duk_hobject ** out_handler )

Definition at line 47740 of file duktape-1.8.0/src/duktape.c.

47744 :
47745 *
47746 * arr_idx > limit'' * ((old_size + 7) / 8)
47747 */
47748
47749 return (arr_idx > DUK_HOBJECT_A_FAST_RESIZE_LIMIT * ((old_size + 7) >> 3));
47750}
47751
47752/*
47753 * Proxy helpers
47754 */
47755
47756#if defined(DUK_USE_ES6_PROXY)
47758 duk_tval *tv_target;
47759 duk_tval *tv_handler;
47760 duk_hobject *h_target;
47761 duk_hobject *h_handler;
47762
47763 DUK_ASSERT(thr != NULL);
47764 DUK_ASSERT(obj != NULL);
47765 DUK_ASSERT(out_target != NULL);
47766 DUK_ASSERT(out_handler != NULL);
47767
47768 /* Caller doesn't need to check exotic proxy behavior (but does so for
47769 * some fast paths).
47770 */
47772 return 0;
47773 }
47774
47776 if (!tv_handler) {
47778 return 0;
47779 }
47780 DUK_ASSERT(DUK_TVAL_IS_OBJECT(tv_handler));
47781 h_handler = DUK_TVAL_GET_OBJECT(tv_handler);
#define DUK_HTHREAD_STRING_INT_HANDLER(thr)
#define DUK_HOBJECT_A_FAST_RESIZE_LIMIT
#define DUK_STR_PROXY_REVOKED

Referenced by duk__proxy_check_prop().

◆ duk_hobject_putprop()

DUK_INTERNAL_DECL duk_bool_t duk_hobject_putprop ( duk_hthread * thr,
duk_tval * tv_obj,
duk_tval * tv_key,
duk_tval * tv_val,
duk_bool_t throw_flag )

Definition at line 50655 of file duktape-1.8.0/src/duktape.c.

50656 :
50657 *
50658 * - Preprocessing before and postprocessing after an actual property
50659 * write. For example, array index write requires pre-checking the
50660 * array 'length' property for access control, and may require an
50661 * array 'length' update after the actual write has succeeded (but
50662 * not if it fails).
50663 *
50664 * - Deletion of multiple entries, as a result of array 'length' write.
50665 *
50666 * * Input values are taken as pointers which may point to the valstack.
50667 * If valstack is resized because of the put (this may happen at least
50668 * when the array part is abandoned), the pointers can be invalidated.
50669 * (We currently make a copy of all of the input values to avoid issues.)
50670 */
50671
50672DUK_INTERNAL duk_bool_t duk_hobject_putprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key, duk_tval *tv_val, duk_bool_t throw_flag) {
50673 duk_context *ctx = (duk_context *) thr;
50674 duk_tval tv_obj_copy;
50675 duk_tval tv_key_copy;
50676 duk_tval tv_val_copy;
50677 duk_hobject *orig = NULL; /* NULL if tv_obj is primitive */
50678 duk_hobject *curr;
50679 duk_hstring *key = NULL;
50680 duk_propdesc desc;
50681 duk_tval *tv;
50682 duk_uint32_t arr_idx;
50683 duk_bool_t rc;
50684 duk_int_t e_idx;
50685 duk_uint_t sanity;
50686 duk_uint32_t new_array_length = 0; /* 0 = no update */
50687
50688 DUK_DDD(DUK_DDDPRINT("putprop: thr=%p, obj=%p, key=%p, val=%p, throw=%ld "
50689 "(obj -> %!T, key -> %!T, val -> %!T)",
50690 (void *) thr, (void *) tv_obj, (void *) tv_key, (void *) tv_val,
50691 (long) throw_flag, (duk_tval *) tv_obj, (duk_tval *) tv_key, (duk_tval *) tv_val));
50692
50693 DUK_ASSERT(thr != NULL);
50694 DUK_ASSERT(thr->heap != NULL);
50695 DUK_ASSERT(ctx != NULL);
50696 DUK_ASSERT(tv_obj != NULL);
50697 DUK_ASSERT(tv_key != NULL);
50698 DUK_ASSERT(tv_val != NULL);
50699
50701
50702 /*
50703 * Make a copy of tv_obj, tv_key, and tv_val to avoid any issues of
50704 * them being invalidated by a valstack resize.
50705 *
50706 * XXX: this is an overkill for some paths, so optimize this later
50707 * (or maybe switch to a stack arguments model entirely).
50708 */
50709
50710 DUK_TVAL_SET_TVAL(&tv_obj_copy, tv_obj);
50711 DUK_TVAL_SET_TVAL(&tv_key_copy, tv_key);
50712 DUK_TVAL_SET_TVAL(&tv_val_copy, tv_val);
50713 tv_obj = &tv_obj_copy;
50714 tv_key = &tv_key_copy;
50715 tv_val = &tv_val_copy;
50716
50717 /*
50718 * Coercion and fast path processing.
50719 */
50720
50721 switch (DUK_TVAL_GET_TAG(tv_obj)) {
50722 case DUK_TAG_UNDEFINED:
50723 case DUK_TAG_NULL: {
50724 /* Note: unconditional throw */
50725 DUK_DDD(DUK_DDDPRINT("base object is undefined or null -> reject (object=%!iT)",
50726 (duk_tval *) tv_obj));
50727#if defined(DUK_USE_PARANOID_ERRORS)
50729#else
50730 DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot write property %s of %s",
50732#endif
50733 return 0;
50734 }
50735
50736 case DUK_TAG_BOOLEAN: {
50737 DUK_DDD(DUK_DDDPRINT("base object is a boolean, start lookup from boolean prototype"));
50738 curr = thr->builtins[DUK_BIDX_BOOLEAN_PROTOTYPE];
50739 break;
50740 }
50741
50742 case DUK_TAG_STRING: {
50743 duk_hstring *h = DUK_TVAL_GET_STRING(tv_obj);
50744
50745 /*
50746 * Note: currently no fast path for array index writes.
50747 * They won't be possible anyway as strings are immutable.
50748 */
50749
50750 DUK_ASSERT(key == NULL);
50751 arr_idx = duk__push_tval_to_hstring_arr_idx(ctx, tv_key, &key);
50752 DUK_ASSERT(key != NULL);
50753
50754 if (key == DUK_HTHREAD_STRING_LENGTH(thr)) {
50755 goto fail_not_writable;
50756 }
50757
50758 if (arr_idx != DUK__NO_ARRAY_INDEX &&
50759 arr_idx < DUK_HSTRING_GET_CHARLEN(h)) {
50760 goto fail_not_writable;
50761 }
50762
50763 DUK_DDD(DUK_DDDPRINT("base object is a string, start lookup from string prototype"));
50764 curr = thr->builtins[DUK_BIDX_STRING_PROTOTYPE];
50765 goto lookup; /* avoid double coercion */
50766 }
50767
50768 case DUK_TAG_OBJECT: {
50769 orig = DUK_TVAL_GET_OBJECT(tv_obj);
50770 DUK_ASSERT(orig != NULL);
50771
50772#if defined(DUK_USE_ROM_OBJECTS)
50773 /* With this check in place fast paths won't need read-only
50774 * object checks. This is technically incorrect if there are
50775 * setters that cause no writes to ROM objects, but current
50776 * built-ins don't have such setters.
50777 */
50778 if (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) orig)) {
50779 DUK_DD(DUK_DDPRINT("attempt to putprop on read-only target object"));
50780 goto fail_not_writable_no_pop; /* Must avoid duk_pop() in exit path */
50781 }
50782#endif
50783
50784 /* The fast path for array property put is not fully compliant:
50785 * If one places conflicting number-indexed properties into
50786 * Array.prototype (for example, a non-writable Array.prototype[7])
50787 * the fast path will incorrectly ignore them.
50788 *
50789 * This fast path could be made compliant by falling through
50790 * to the slow path if the previous value was UNUSED. This would
50791 * also remove the need to check for extensibility. Right now a
50792 * non-extensible array is slower than an extensible one as far
50793 * as writes are concerned.
50794 *
50795 * The fast path behavior is documented in more detail here:
50796 * tests/ecmascript/test-misc-array-fast-write.js
50797 */
50798
50799 if (duk__putprop_shallow_fastpath_array_tval(thr, orig, tv_key, tv_val, &desc) != 0) {
50800 DUK_DDD(DUK_DDDPRINT("array fast path success"));
50801 return 1;
50802 }
50803
50804 if (duk__putprop_fastpath_bufobj_tval(thr, orig, tv_key, tv_val) != 0) {
50805 DUK_DDD(DUK_DDDPRINT("base is bufobj, key is a number, bufferobject fast path"));
50806 return 1;
50807 }
50808
50809#if defined(DUK_USE_ES6_PROXY)
50811 duk_hobject *h_target;
50812 duk_bool_t tmp_bool;
50813
50814 if (duk__proxy_check_prop(thr, orig, DUK_STRIDX_SET, tv_key, &h_target)) {
50815 /* -> [ ... trap handler ] */
50816 DUK_DDD(DUK_DDDPRINT("-> proxy object 'set' for key %!T", (duk_tval *) tv_key));
50817 duk_push_hobject(ctx, h_target); /* target */
50818 duk_push_tval(ctx, tv_key); /* P */
50819 duk_push_tval(ctx, tv_val); /* V */
50820 duk_push_tval(ctx, tv_obj); /* Receiver: Proxy object */
50821 duk_call_method(ctx, 4 /*nargs*/);
50822 tmp_bool = duk_to_boolean(ctx, -1);
50823 duk_pop(ctx);
50824 if (!tmp_bool) {
50825 goto fail_proxy_rejected;
50826 }
50827
50828 /* Target object must be checked for a conflicting
50829 * non-configurable property.
50830 */
50831 arr_idx = duk__push_tval_to_hstring_arr_idx(ctx, tv_key, &key);
50832 DUK_ASSERT(key != NULL);
50833
50834 if (duk__get_own_propdesc_raw(thr, h_target, key, arr_idx, &desc, DUK_GETDESC_FLAG_PUSH_VALUE)) {
50835 duk_tval *tv_targ = duk_require_tval(ctx, -1);
50836 duk_bool_t datadesc_reject;
50837 duk_bool_t accdesc_reject;
50838
50839 DUK_DDD(DUK_DDDPRINT("proxy 'set': target has matching property %!O, check for "
50840 "conflicting property; tv_val=%!T, tv_targ=%!T, desc.flags=0x%08lx, "
50841 "desc.get=%p, desc.set=%p",
50842 (duk_heaphdr *) key, (duk_tval *) tv_val, (duk_tval *) tv_targ,
50843 (unsigned long) desc.flags,
50844 (void *) desc.get, (void *) desc.set));
50845
50846 datadesc_reject = !(desc.flags & DUK_PROPDESC_FLAG_ACCESSOR) &&
50849 !duk_js_samevalue(tv_val, tv_targ);
50850 accdesc_reject = (desc.flags & DUK_PROPDESC_FLAG_ACCESSOR) &&
50852 (desc.set == NULL);
50853 if (datadesc_reject || accdesc_reject) {
50855 }
50856
50857 duk_pop_2(ctx);
50858 } else {
50859 duk_pop(ctx);
50860 }
50861 return 1; /* success */
50862 }
50863
50864 orig = h_target; /* resume write to target */
50865 DUK_TVAL_SET_OBJECT(tv_obj, orig);
50866 }
50867#endif /* DUK_USE_ES6_PROXY */
50868
50869 curr = orig;
50870 break;
50871 }
50872
50873 case DUK_TAG_BUFFER: {
50874 duk_hbuffer *h = DUK_TVAL_GET_BUFFER(tv_obj);
50875 duk_int_t pop_count = 0;
50876
50877 /*
50878 * Because buffer values may be looped over and read/written
50879 * from, an array index fast path is important.
50880 */
50881
50882#if defined(DUK_USE_FASTINT)
50883 if (DUK_TVAL_IS_FASTINT(tv_key)) {
50884 arr_idx = duk__tval_fastint_to_arr_idx(tv_key);
50885 DUK_DDD(DUK_DDDPRINT("base object buffer, key is a fast-path fastint; arr_idx %ld", (long) arr_idx));
50886 pop_count = 0;
50887 } else
50888#endif
50889 if (DUK_TVAL_IS_NUMBER(tv_key)) {
50890 arr_idx = duk__tval_number_to_arr_idx(tv_key);
50891 DUK_DDD(DUK_DDDPRINT("base object buffer, key is a fast-path number; arr_idx %ld", (long) arr_idx));
50892 pop_count = 0;
50893 } else {
50894 arr_idx = duk__push_tval_to_hstring_arr_idx(ctx, tv_key, &key);
50895 DUK_ASSERT(key != NULL);
50896 DUK_DDD(DUK_DDDPRINT("base object buffer, key is a non-fast-path number; after "
50897 "coercion key is %!T, arr_idx %ld",
50898 (duk_tval *) duk_get_tval(ctx, -1), (long) arr_idx));
50899 pop_count = 1;
50900 }
50901
50902 if (arr_idx != DUK__NO_ARRAY_INDEX &&
50903 arr_idx < DUK_HBUFFER_GET_SIZE(h)) {
50904 duk_uint8_t *data;
50905 DUK_DDD(DUK_DDDPRINT("writing to buffer data at index %ld", (long) arr_idx));
50906 data = (duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h);
50907
50908 /* XXX: duk_to_int() ensures we'll get 8 lowest bits as
50909 * as input is within duk_int_t range (capped outside it).
50910 */
50911#if defined(DUK_USE_FASTINT)
50912 /* Buffer writes are often integers. */
50913 if (DUK_TVAL_IS_FASTINT(tv_val)) {
50914 data[arr_idx] = (duk_uint8_t) DUK_TVAL_GET_FASTINT_U32(tv_val);
50915 }
50916 else
50917#endif
50918 {
50919 duk_push_tval(ctx, tv_val);
50920 data[arr_idx] = (duk_uint8_t) duk_to_uint32(ctx, -1);
50921 pop_count++;
50922 }
50923
50924 duk_pop_n(ctx, pop_count);
50925 DUK_DDD(DUK_DDDPRINT("result: success (buffer data write)"));
50926 return 1;
50927 }
50928
50929 if (pop_count == 0) {
50930 /* This is a pretty awkward control flow, but we need to recheck the
50931 * key coercion here.
50932 */
50933 arr_idx = duk__push_tval_to_hstring_arr_idx(ctx, tv_key, &key);
50934 DUK_ASSERT(key != NULL);
50935 DUK_DDD(DUK_DDDPRINT("base object buffer, key is a non-fast-path number; after "
50936 "coercion key is %!T, arr_idx %ld",
50937 (duk_tval *) duk_get_tval(ctx, -1), (long) arr_idx));
50938 }
50939
50940 if (key == DUK_HTHREAD_STRING_LENGTH(thr) ||
50941 key == DUK_HTHREAD_STRING_BYTE_LENGTH(thr) ||
50942 key == DUK_HTHREAD_STRING_BYTE_OFFSET(thr) ||
50944 goto fail_not_writable;
50945 }
50946
50947 DUK_DDD(DUK_DDDPRINT("base object is a buffer, start lookup from buffer prototype"));
50948 curr = thr->builtins[DUK_BIDX_BUFFER_PROTOTYPE];
50949 goto lookup; /* avoid double coercion */
50950 }
50951
50952 case DUK_TAG_POINTER: {
50953 DUK_DDD(DUK_DDDPRINT("base object is a pointer, start lookup from pointer prototype"));
50954 curr = thr->builtins[DUK_BIDX_POINTER_PROTOTYPE];
50955 break;
50956 }
50957
50958 case DUK_TAG_LIGHTFUNC: {
50959 /* All lightfunc own properties are non-writable and the lightfunc
50960 * is considered non-extensible. However, the write may be captured
50961 * by an inherited setter which means we can't stop the lookup here.
50962 */
50963
50964 arr_idx = duk__push_tval_to_hstring_arr_idx(ctx, tv_key, &key);
50965
50966 if (duk__key_is_lightfunc_ownprop(thr, key)) {
50967 goto fail_not_writable;
50968 }
50969
50970 DUK_DDD(DUK_DDDPRINT("base object is a lightfunc, start lookup from function prototype"));
50971 curr = thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE];
50972 goto lookup; /* avoid double coercion */
50973 }
50974
50975#if defined(DUK_USE_FASTINT)
50976 case DUK_TAG_FASTINT:
50977#endif
50978 default: {
50979 /* number */
50980 DUK_DDD(DUK_DDDPRINT("base object is a number, start lookup from number prototype"));
50982 curr = thr->builtins[DUK_BIDX_NUMBER_PROTOTYPE];
50983 break;
50984 }
50985 }
50986
50987 DUK_ASSERT(key == NULL);
50988 arr_idx = duk__push_tval_to_hstring_arr_idx(ctx, tv_key, &key);
50989 DUK_ASSERT(key != NULL);
50990
50991 lookup:
50992
50993 /*
50994 * Check whether the property already exists in the prototype chain.
50995 * Note that the actual write goes into the original base object
50996 * (except if an accessor property captures the write).
50997 */
50998
50999 /* [key] */
51000
51001 DUK_ASSERT(curr != NULL);
51003 do {
51004 if (!duk__get_own_propdesc_raw(thr, curr, key, arr_idx, &desc, 0 /*flags*/)) { /* don't push value */
51005 goto next_in_chain;
51006 }
51007
51008 if (desc.flags & DUK_PROPDESC_FLAG_ACCESSOR) {
51009 /*
51010 * Found existing accessor property (own or inherited).
51011 * Call setter with 'this' set to orig, and value as the only argument.
51012 * Setter calls are OK even for ROM objects.
51013 *
51014 * Note: no exotic arguments object behavior, because [[Put]] never
51015 * calls [[DefineOwnProperty]] (E5 Section 8.12.5, step 5.b).
51016 */
51017
51018 duk_hobject *setter;
51019
51020 DUK_DD(DUK_DDPRINT("put to an own or inherited accessor, calling setter"));
51021
51022 setter = DUK_HOBJECT_E_GET_VALUE_SETTER(thr->heap, curr, desc.e_idx);
51023 if (!setter) {
51024 goto fail_no_setter;
51025 }
51026 duk_push_hobject(ctx, setter);
51027 duk_push_tval(ctx, tv_obj); /* note: original, uncoerced base */
51028 duk_push_tval(ctx, tv_val); /* [key setter this val] */
51029#ifdef DUK_USE_NONSTD_SETTER_KEY_ARGUMENT
51030 duk_dup(ctx, -4);
51031 duk_call_method(ctx, 2); /* [key setter this val key] -> [key retval] */
51032#else
51033 duk_call_method(ctx, 1); /* [key setter this val] -> [key retval] */
51034#endif
51035 duk_pop(ctx); /* ignore retval -> [key] */
51036 goto success_no_arguments_exotic;
51037 }
51038
51039 if (orig == NULL) {
51040 /*
51041 * Found existing own or inherited plain property, but original
51042 * base is a primitive value.
51043 */
51044 DUK_DD(DUK_DDPRINT("attempt to create a new property in a primitive base object"));
51045 goto fail_base_primitive;
51046 }
51047
51048 if (curr != orig) {
51049 /*
51050 * Found existing inherited plain property.
51051 * Do an access control check, and if OK, write
51052 * new property to 'orig'.
51053 */
51054 if (!DUK_HOBJECT_HAS_EXTENSIBLE(orig)) {
51055 DUK_DD(DUK_DDPRINT("found existing inherited plain property, but original object is not extensible"));
51056 goto fail_not_extensible;
51057 }
51058 if (!(desc.flags & DUK_PROPDESC_FLAG_WRITABLE)) {
51059 DUK_DD(DUK_DDPRINT("found existing inherited plain property, original object is extensible, but inherited property is not writable"));
51060 goto fail_not_writable;
51061 }
51062 DUK_DD(DUK_DDPRINT("put to new property, object extensible, inherited property found and is writable"));
51063 goto create_new;
51064 } else {
51065 /*
51066 * Found existing own (non-inherited) plain property.
51067 * Do an access control check and update in place.
51068 */
51069
51070 if (!(desc.flags & DUK_PROPDESC_FLAG_WRITABLE)) {
51071 DUK_DD(DUK_DDPRINT("found existing own (non-inherited) plain property, but property is not writable"));
51072 goto fail_not_writable;
51073 }
51074 if (desc.flags & DUK_PROPDESC_FLAG_VIRTUAL) {
51075 DUK_DD(DUK_DDPRINT("found existing own (non-inherited) virtual property, property is writable"));
51076 if (DUK_HOBJECT_IS_BUFFEROBJECT(curr)) {
51077 duk_hbufferobject *h_bufobj;
51078 duk_uint_t byte_off;
51079 duk_small_uint_t elem_size;
51080
51081 h_bufobj = (duk_hbufferobject *) curr;
51083
51084 DUK_DD(DUK_DDPRINT("writable virtual property is in buffer object"));
51085
51086 /* Careful with wrapping: arr_idx upshift may easily wrap, whereas
51087 * length downshift won't.
51088 */
51089 if (arr_idx < (h_bufobj->length >> h_bufobj->shift)) {
51090 duk_uint8_t *data;
51091 DUK_DDD(DUK_DDDPRINT("writing to buffer data at index %ld", (long) arr_idx));
51092
51093 DUK_ASSERT(arr_idx != DUK__NO_ARRAY_INDEX); /* index/length check guarantees */
51094 byte_off = arr_idx << h_bufobj->shift; /* no wrap assuming h_bufobj->length is valid */
51095 elem_size = 1 << h_bufobj->shift;
51096
51097 /* Coerce to number before validating pointers etc so that the
51098 * number coercions in duk_hbufferobject_validated_write() are
51099 * guaranteed to be side effect free and not invalidate the
51100 * pointer checks we do here.
51101 */
51102 duk_push_tval(ctx, tv_val);
51103 duk_to_number(ctx, -1);
51104
51105 if (h_bufobj->buf != NULL && DUK_HBUFFEROBJECT_VALID_BYTEOFFSET_EXCL(h_bufobj, byte_off + elem_size)) {
51106 data = (duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_bufobj->buf) + h_bufobj->offset + byte_off;
51107 duk_hbufferobject_validated_write(ctx, h_bufobj, data, elem_size);
51108 } else {
51109 DUK_D(DUK_DPRINT("bufferobject access out of underlying buffer, ignoring (write skipped)"));
51110 }
51111 duk_pop(ctx);
51112 goto success_no_arguments_exotic;
51113 }
51114 }
51115
51116 goto fail_internal; /* should not happen */
51117 }
51118 DUK_DD(DUK_DDPRINT("put to existing own plain property, property is writable"));
51119 goto update_old;
51120 }
51122
51123 next_in_chain:
51124 /* XXX: option to pretend property doesn't exist if sanity limit is
51125 * hit might be useful.
51126 */
51127 if (sanity-- == 0) {
51129 }
51130 curr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, curr);
51131 } while (curr);
51132
51133 /*
51134 * Property not found in prototype chain.
51135 */
51136
51137 DUK_DDD(DUK_DDDPRINT("property not found in prototype chain"));
51138
51139 if (orig == NULL) {
51140 DUK_DD(DUK_DDPRINT("attempt to create a new property in a primitive base object"));
51141 goto fail_base_primitive;
51142 }
51143
51144 if (!DUK_HOBJECT_HAS_EXTENSIBLE(orig)) {
51145 DUK_DD(DUK_DDPRINT("put to a new property (not found in prototype chain), but original object not extensible"));
51146 goto fail_not_extensible;
51147 }
51148
51149 goto create_new;
51150
51151 update_old:
51152
51153 /*
51154 * Update an existing property of the base object.
51155 */
51156
51157 /* [key] */
51158
51159 DUK_DDD(DUK_DDDPRINT("update an existing property of the original object"));
51160
51161 DUK_ASSERT(orig != NULL);
51162#if defined(DUK_USE_ROM_OBJECTS)
51163 /* This should not happen because DUK_TAG_OBJECT case checks
51164 * for this already, but check just in case.
51165 */
51166 if (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) orig)) {
51167 goto fail_not_writable;
51168 }
51169#endif
51170
51171 /* Although there are writable virtual properties (e.g. plain buffer
51172 * and buffer object number indices), they are handled before we come
51173 * here.
51174 */
51176 DUK_ASSERT(desc.a_idx >= 0 || desc.e_idx >= 0);
51177
51178 if (DUK_HOBJECT_HAS_EXOTIC_ARRAY(orig) &&
51179 key == DUK_HTHREAD_STRING_LENGTH(thr)) {
51180 /*
51181 * Write to 'length' of an array is a very complex case
51182 * handled in a helper which updates both the array elements
51183 * and writes the new 'length'. The write may result in an
51184 * unconditional RangeError or a partial write (indicated
51185 * by a return code).
51186 *
51187 * Note: the helper has an unnecessary writability check
51188 * for 'length', we already know it is writable.
51189 */
51190
51191 DUK_DDD(DUK_DDDPRINT("writing existing 'length' property to array exotic, invoke complex helper"));
51192
51193 /* XXX: the helper currently assumes stack top contains new
51194 * 'length' value and the whole calling convention is not very
51195 * compatible with what we need.
51196 */
51197
51198 duk_push_tval(ctx, tv_val); /* [key val] */
51199 rc = duk__handle_put_array_length(thr, orig);
51200 duk_pop(ctx); /* [key val] -> [key] */
51201 if (!rc) {
51202 goto fail_array_length_partial;
51203 }
51204
51205 /* key is 'length', cannot match argument exotic behavior */
51206 goto success_no_arguments_exotic;
51207 }
51208
51209 if (desc.e_idx >= 0) {
51210 tv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, orig, desc.e_idx);
51211 DUK_DDD(DUK_DDDPRINT("previous entry value: %!iT", (duk_tval *) tv));
51212 DUK_TVAL_SET_TVAL_UPDREF(thr, tv, tv_val); /* side effects */
51213 /* don't touch property attributes or hash part */
51214 DUK_DD(DUK_DDPRINT("put to an existing entry at index %ld -> new value %!iT",
51215 (long) desc.e_idx, (duk_tval *) tv));
51216 } else {
51217 /* Note: array entries are always writable, so the writability check
51218 * above is pointless for them. The check could be avoided with some
51219 * refactoring but is probably not worth it.
51220 */
51221
51222 DUK_ASSERT(desc.a_idx >= 0);
51223 tv = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, orig, desc.a_idx);
51224 DUK_DDD(DUK_DDDPRINT("previous array value: %!iT", (duk_tval *) tv));
51225 DUK_TVAL_SET_TVAL_UPDREF(thr, tv, tv_val); /* side effects */
51226 DUK_DD(DUK_DDPRINT("put to an existing array entry at index %ld -> new value %!iT",
51227 (long) desc.a_idx, (duk_tval *) tv));
51228 }
51229
51230 /* Regardless of whether property is found in entry or array part,
51231 * it may have arguments exotic behavior (array indices may reside
51232 * in entry part for abandoned / non-existent array parts).
51233 */
51234 goto success_with_arguments_exotic;
51235
51236 create_new:
51237
51238 /*
51239 * Create a new property in the original object.
51240 *
51241 * Exotic properties need to be reconsidered here from a write
51242 * perspective (not just property attributes perspective).
51243 * However, the property does not exist in the object already,
51244 * so this limits the kind of exotic properties that apply.
51245 */
51246
51247 /* [key] */
51248
51249 DUK_DDD(DUK_DDDPRINT("create new property to original object"));
51250
51251 DUK_ASSERT(orig != NULL);
51252
51253#if defined(DUK_USE_ROM_OBJECTS)
51254 /* This should not happen because DUK_TAG_OBJECT case checks
51255 * for this already, but check just in case.
51256 */
51257 if (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) orig)) {
51258 goto fail_not_writable;
51259 }
51260#endif
51261
51262 /* Not possible because array object 'length' is present
51263 * from its creation and cannot be deleted, and is thus
51264 * caught as an existing property above.
51265 */
51267 key == DUK_HTHREAD_STRING_LENGTH(thr)));
51268
51269 if (DUK_HOBJECT_HAS_EXOTIC_ARRAY(orig) &&
51270 arr_idx != DUK__NO_ARRAY_INDEX) {
51271 /* automatic length update */
51272 duk_uint32_t old_len;
51273
51274 old_len = duk__get_old_array_length(thr, orig, &desc);
51275
51276 if (arr_idx >= old_len) {
51277 DUK_DDD(DUK_DDDPRINT("write new array entry requires length update "
51278 "(arr_idx=%ld, old_len=%ld)",
51279 (long) arr_idx, (long) old_len));
51280
51281 if (!(desc.flags & DUK_PROPDESC_FLAG_WRITABLE)) {
51282 DUK_DD(DUK_DDPRINT("attempt to extend array, but array 'length' is not writable"));
51283 goto fail_not_writable;
51284 }
51285
51286 /* Note: actual update happens once write has been completed
51287 * without error below. The write should always succeed
51288 * from a specification viewpoint, but we may e.g. run out
51289 * of memory. It's safer in this order.
51290 */
51291
51292 DUK_ASSERT(arr_idx != 0xffffffffUL);
51293 new_array_length = arr_idx + 1; /* flag for later write */
51294 } else {
51295 DUK_DDD(DUK_DDDPRINT("write new array entry does not require length update "
51296 "(arr_idx=%ld, old_len=%ld)",
51297 (long) arr_idx, (long) old_len));
51298 }
51299 }
51300
51301 /* write_to_array_part: */
51302
51303 /*
51304 * Write to array part?
51305 *
51306 * Note: array abandonding requires a property resize which uses
51307 * 'rechecks' valstack for temporaries and may cause any existing
51308 * valstack pointers to be invalidated. To protect against this,
51309 * tv_obj, tv_key, and tv_val are copies of the original inputs.
51310 */
51311
51312 if (arr_idx != DUK__NO_ARRAY_INDEX &&
51314 if (arr_idx < DUK_HOBJECT_GET_ASIZE(orig)) {
51315 goto no_array_growth;
51316 }
51317
51318 /*
51319 * Array needs to grow, but we don't want it becoming too sparse.
51320 * If it were to become sparse, abandon array part, moving all
51321 * array entries into the entries part (for good).
51322 *
51323 * Since we don't keep track of actual density (used vs. size) of
51324 * the array part, we need to estimate somehow. The check is made
51325 * in two parts:
51326 *
51327 * - Check whether the resize need is small compared to the
51328 * current size (relatively); if so, resize without further
51329 * checking (essentially we assume that the original part is
51330 * "dense" so that the result would be dense enough).
51331 *
51332 * - Otherwise, compute the resize using an actual density
51333 * measurement based on counting the used array entries.
51334 */
51335
51336 DUK_DDD(DUK_DDDPRINT("write to new array requires array resize, decide whether to do a "
51337 "fast resize without abandon check (arr_idx=%ld, old_size=%ld)",
51338 (long) arr_idx, (long) DUK_HOBJECT_GET_ASIZE(orig)));
51339
51341 duk_uint32_t old_used;
51342 duk_uint32_t old_size;
51343
51344 DUK_DDD(DUK_DDDPRINT("=> fast check is NOT OK, do slow check for array abandon"));
51345
51346 duk__compute_a_stats(thr, orig, &old_used, &old_size);
51347
51348 DUK_DDD(DUK_DDDPRINT("abandon check, array stats: old_used=%ld, old_size=%ld, arr_idx=%ld",
51349 (long) old_used, (long) old_size, (long) arr_idx));
51350
51351 /* Note: intentionally use approximations to shave a few instructions:
51352 * a_used = old_used (accurate: old_used + 1)
51353 * a_size = arr_idx (accurate: arr_idx + 1)
51354 */
51355 if (duk__abandon_array_density_check(old_used, arr_idx)) {
51356 DUK_DD(DUK_DDPRINT("write to new array entry beyond current length, "
51357 "decided to abandon array part (would become too sparse)"));
51358
51359 /* abandoning requires a props allocation resize and
51360 * 'rechecks' the valstack, invalidating any existing
51361 * valstack value pointers!
51362 */
51363 duk__abandon_array_checked(thr, orig);
51365
51366 goto write_to_entry_part;
51367 }
51368
51369 DUK_DDD(DUK_DDDPRINT("=> decided to keep array part"));
51370 } else {
51371 DUK_DDD(DUK_DDDPRINT("=> fast resize is OK"));
51372 }
51373
51374 DUK_DD(DUK_DDPRINT("write to new array entry beyond current length, "
51375 "decided to extend current allocation"));
51376
51377 duk__grow_props_for_array_item(thr, orig, arr_idx);
51378
51379 no_array_growth:
51380
51381 /* Note: assume array part is comprehensive, so that either
51382 * the write goes to the array part, or we've abandoned the
51383 * array above (and will not come here).
51384 */
51385
51387 DUK_ASSERT(arr_idx < DUK_HOBJECT_GET_ASIZE(orig));
51388
51389 tv = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, orig, arr_idx);
51390 /* prev value must be unused, no decref */
51392 DUK_TVAL_SET_TVAL(tv, tv_val);
51393 DUK_TVAL_INCREF(thr, tv);
51394 DUK_DD(DUK_DDPRINT("put to new array entry: %ld -> %!T",
51395 (long) arr_idx, (duk_tval *) tv));
51396
51397 /* Note: array part values are [[Writable]], [[Enumerable]],
51398 * and [[Configurable]] which matches the required attributes
51399 * here.
51400 */
51401 goto entry_updated;
51402 }
51403
51404 write_to_entry_part:
51405
51406 /*
51407 * Write to entry part
51408 */
51409
51410 /* entry allocation updates hash part and increases the key
51411 * refcount; may need a props allocation resize but doesn't
51412 * 'recheck' the valstack.
51413 */
51414 e_idx = duk__alloc_entry_checked(thr, orig, key);
51415 DUK_ASSERT(e_idx >= 0);
51416
51417 tv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, orig, e_idx);
51418 /* prev value can be garbage, no decref */
51419 DUK_TVAL_SET_TVAL(tv, tv_val);
51420 DUK_TVAL_INCREF(thr, tv);
51421 DUK_HOBJECT_E_SET_FLAGS(thr->heap, orig, e_idx, DUK_PROPDESC_FLAGS_WEC);
51422 goto entry_updated;
51423
51424 entry_updated:
51425
51426 /*
51427 * Possible pending array length update, which must only be done
51428 * if the actual entry write succeeded.
51429 */
51430
51431 if (new_array_length > 0) {
51432 /*
51433 * Note: zero works as a "no update" marker because the new length
51434 * can never be zero after a new property is written.
51435 *
51436 * Note: must re-lookup because calls above (e.g. duk__alloc_entry_checked())
51437 * may realloc and compact properties and hence change e_idx.
51438 */
51439
51440 DUK_DDD(DUK_DDDPRINT("write successful, pending array length update to: %ld",
51441 (long) new_array_length));
51442
51443 rc = duk__get_own_propdesc_raw(thr, orig, DUK_HTHREAD_STRING_LENGTH(thr), DUK__NO_ARRAY_INDEX, &desc, 0 /*flags*/); /* don't push value */
51444 DUK_UNREF(rc);
51445 DUK_ASSERT(rc != 0);
51446 DUK_ASSERT(desc.e_idx >= 0);
51447
51448 tv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, orig, desc.e_idx);
51450 /* no need for decref/incref because value is a number */
51451 DUK_TVAL_SET_FASTINT_U32(tv, new_array_length);
51452 }
51453
51454 /*
51455 * Arguments exotic behavior not possible for new properties: all
51456 * magically bound properties are initially present in the arguments
51457 * object, and if they are deleted, the binding is also removed from
51458 * parameter map.
51459 */
51460
51461 goto success_no_arguments_exotic;
51462
51463 success_with_arguments_exotic:
51464
51465 /*
51466 * Arguments objects have exotic [[DefineOwnProperty]] which updates
51467 * the internal 'map' of arguments for writes to currently mapped
51468 * arguments. More conretely, writes to mapped arguments generate
51469 * a write to a bound variable.
51470 *
51471 * The [[Put]] algorithm invokes [[DefineOwnProperty]] for existing
51472 * data properties and new properties, but not for existing accessors.
51473 * Hence, in E5 Section 10.6 ([[DefinedOwnProperty]] algorithm), we
51474 * have a Desc with 'Value' (and possibly other properties too), and
51475 * we end up in step 5.b.i.
51476 */
51477
51478 if (arr_idx != DUK__NO_ARRAY_INDEX &&
51480 /* Note: only numbered indices are relevant, so arr_idx fast reject
51481 * is good (this is valid unless there are more than 4**32-1 arguments).
51482 */
51483
51484 DUK_DDD(DUK_DDDPRINT("putprop successful, arguments exotic behavior needed"));
51485
51486 /* Note: we can reuse 'desc' here */
51487
51488 /* XXX: top of stack must contain value, which helper doesn't touch,
51489 * rework to use tv_val directly?
51490 */
51491
51492 duk_push_tval(ctx, tv_val);
51493 (void) duk__check_arguments_map_for_put(thr, orig, key, &desc, throw_flag);
51494 duk_pop(ctx);
51495 }
51496 /* fall thru */
51497
51498 success_no_arguments_exotic:
51499 /* shared exit path now */
51500 DUK_DDD(DUK_DDDPRINT("result: success"));
51501 duk_pop(ctx); /* remove key */
51502 return 1;
51503
51504#if defined(DUK_USE_ES6_PROXY)
51505 fail_proxy_rejected:
51506 DUK_DDD(DUK_DDDPRINT("result: error, proxy rejects"));
51507 if (throw_flag) {
51509 }
51510 /* Note: no key on stack */
51511 return 0;
51512#endif
51513
51514 fail_base_primitive:
51515 DUK_DDD(DUK_DDDPRINT("result: error, base primitive"));
51516 if (throw_flag) {
51517#if defined(DUK_USE_PARANOID_ERRORS)
51519#else
51520 DUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, "cannot write property %s of %s",
51522#endif
51523 }
51524 duk_pop(ctx); /* remove key */
51525 return 0;
51526
51527 fail_not_extensible:
51528 DUK_DDD(DUK_DDDPRINT("result: error, not extensible"));
51529 if (throw_flag) {
51531 }
51532 duk_pop(ctx); /* remove key */
51533 return 0;
51534
51535 fail_not_writable:
51536 DUK_DDD(DUK_DDDPRINT("result: error, not writable"));
51537 if (throw_flag) {
51539 }
51540 duk_pop(ctx); /* remove key */
51541 return 0;
51542
51543#if defined(DUK_USE_ROM_OBJECTS)
51544 fail_not_writable_no_pop:
51545 DUK_DDD(DUK_DDDPRINT("result: error, not writable"));
51546 if (throw_flag) {
51548 }
51549 return 0;
51550#endif
51551
51552 fail_array_length_partial:
51553 DUK_DDD(DUK_DDDPRINT("result: error, array length write only partially successful"));
51554 if (throw_flag) {
51556 }
51557 duk_pop(ctx); /* remove key */
51558 return 0;
DUK_LOCAL_DECL void duk__check_arguments_map_for_put(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *temp_desc, duk_bool_t throw_flag)
DUK_LOCAL_DECL duk_bool_t duk__handle_put_array_length(duk_hthread *thr, duk_hobject *obj)
DUK_LOCAL duk_bool_t duk__abandon_array_slow_check_required(duk_uint32_t arr_idx, duk_uint32_t old_size)

References duk_propdesc::a_idx, duk_hbufferobject::buf, duk_hthread::builtins, duk__abandon_array_checked(), duk__abandon_array_density_check(), duk__abandon_array_slow_check_required(), duk__alloc_entry_checked(), duk__check_arguments_map_for_put(), duk__compute_a_stats(), duk__get_old_array_length(), duk__get_own_propdesc_raw(), duk__grow_props_for_array_item(), duk__handle_put_array_length(), duk__key_is_lightfunc_ownprop(), DUK__NO_ARRAY_INDEX, duk__proxy_check_prop(), duk__push_tval_to_hstring_arr_idx(), duk__putprop_fastpath_bufobj_tval(), duk__putprop_shallow_fastpath_array_tval(), duk__tval_number_to_arr_idx(), DUK__VALSTACK_SPACE, DUK_ASSERT, DUK_ASSERT_HBUFFEROBJECT_VALID, DUK_ASSERT_VALSTACK_SPACE, DUK_BIDX_BOOLEAN_PROTOTYPE, DUK_BIDX_BUFFER_PROTOTYPE, DUK_BIDX_FUNCTION_PROTOTYPE, DUK_BIDX_NUMBER_PROTOTYPE, DUK_BIDX_POINTER_PROTOTYPE, DUK_BIDX_STRING_PROTOTYPE, duk_call_method(), DUK_D, DUK_DD, DUK_DDD, DUK_DDDPRINT, DUK_DDPRINT, DUK_DPRINT, duk_dup(), DUK_ERR_TYPE_ERROR, DUK_ERROR_FMT2, DUK_ERROR_RANGE, DUK_ERROR_TYPE, duk_get_tval(), DUK_GETDESC_FLAG_PUSH_VALUE, DUK_HBUFFER_GET_DATA_PTR, DUK_HBUFFER_GET_SIZE, DUK_HBUFFEROBJECT_VALID_BYTEOFFSET_EXCL, duk_hbufferobject_validated_write(), DUK_HEAPHDR_HAS_READONLY, DUK_HOBJECT_A_GET_VALUE_PTR, DUK_HOBJECT_E_GET_VALUE_SETTER, DUK_HOBJECT_E_GET_VALUE_TVAL_PTR, DUK_HOBJECT_E_SET_FLAGS, DUK_HOBJECT_GET_ASIZE, DUK_HOBJECT_GET_PROTOTYPE, DUK_HOBJECT_HAS_ARRAY_PART, DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS, DUK_HOBJECT_HAS_EXOTIC_ARRAY, DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ, DUK_HOBJECT_HAS_EXTENSIBLE, DUK_HOBJECT_IS_BUFFEROBJECT, DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY, DUK_HSTRING_GET_CHARLEN, DUK_HTHREAD_STRING_BYTE_LENGTH, DUK_HTHREAD_STRING_BYTE_OFFSET, DUK_HTHREAD_STRING_BYTES_PER_ELEMENT, DUK_HTHREAD_STRING_LENGTH, duk_js_samevalue, duk_pop(), duk_pop_2(), duk_pop_n(), DUK_PROPDESC_FLAG_ACCESSOR, DUK_PROPDESC_FLAG_CONFIGURABLE, DUK_PROPDESC_FLAG_VIRTUAL, DUK_PROPDESC_FLAG_WRITABLE, DUK_PROPDESC_FLAGS_WEC, duk_push_hobject(), duk_push_string_tval_readable(), duk_push_tval(), duk_require_tval(), DUK_STR_ARRAY_LENGTH_WRITE_FAILED, DUK_STR_INVALID_BASE, DUK_STR_NOT_EXTENSIBLE, DUK_STR_NOT_WRITABLE, DUK_STR_PROTOTYPE_CHAIN_LIMIT, DUK_STR_PROXY_REJECTED, DUK_STR_SETTER_UNDEFINED, DUK_STRIDX_SET, DUK_TAG_BOOLEAN, DUK_TAG_BUFFER, DUK_TAG_LIGHTFUNC, DUK_TAG_NULL, DUK_TAG_OBJECT, DUK_TAG_POINTER, DUK_TAG_STRING, DUK_TAG_UNDEFINED, duk_to_boolean(), duk_to_number(), duk_to_uint32(), DUK_TVAL_GET_BUFFER, DUK_TVAL_GET_OBJECT, DUK_TVAL_GET_STRING, DUK_TVAL_GET_TAG, DUK_TVAL_INCREF, DUK_TVAL_IS_NUMBER, DUK_TVAL_IS_UNUSED, DUK_TVAL_SET_FASTINT_U32, DUK_TVAL_SET_OBJECT, DUK_TVAL_SET_TVAL, DUK_TVAL_SET_TVAL_UPDREF, DUK_UNLIKELY, DUK_UNREACHABLE, DUK_UNREF, duk_propdesc::e_idx, duk_propdesc::flags, duk_propdesc::get, duk_hthread::heap, duk_hbufferobject::length, NULL, duk_hbufferobject::offset, duk_propdesc::set, and duk_hbufferobject::shift.

Referenced by duk__putvar_helper(), and duk_hobject_get_length().

◆ duk_hobject_resolve_proxy_target()

DUK_INTERNAL_DECL duk_hobject * duk_hobject_resolve_proxy_target ( duk_hthread * thr,
duk_hobject * obj )

Definition at line 47788 of file duktape-1.8.0/src/duktape.c.

47805 {
47806 duk_hobject *h_target;
47807 duk_hobject *h_handler;
47808
47809 DUK_ASSERT(thr != NULL);
47810 DUK_ASSERT(obj != NULL);
47811

Referenced by duk_js_instanceof().

◆ duk_hobject_run_finalizer()

DUK_INTERNAL_DECL void duk_hobject_run_finalizer ( duk_hthread * thr,
duk_hobject * obj )

Definition at line 47062 of file duktape-1.8.0/src/duktape.c.

47062 {
47063 DUK_DDD(DUK_DDDPRINT("-> no finalizer or finalizer not callable"));
47064 return 0;
47065 }
47066 duk_dup(ctx, -2);
47068 DUK_DDD(DUK_DDDPRINT("-> finalizer found, calling finalizer"));
47069 duk_call(ctx, 2); /* [ ... obj finalizer obj heapDestruct ] -> [ ... obj retval ] */
47070 DUK_DDD(DUK_DDDPRINT("finalizer finished successfully"));
47071 return 0;
47072
47073 /* Note: we rely on duk_safe_call() to fix up the stack for the caller,
47074 * so we don't need to pop stuff here. There is no return value;
47075 * caller determines rescued status based on object refcount.
47076 */
47077}
47078
47080 duk_context *ctx = (duk_context *) thr;
47081 duk_ret_t rc;
47082#ifdef DUK_USE_ASSERTIONS
47083 duk_idx_t entry_top;
47084#endif
47085
47086 DUK_DDD(DUK_DDDPRINT("running object finalizer for object: %p", (void *) obj));
47087
47088 DUK_ASSERT(thr != NULL);
47089 DUK_ASSERT(ctx != NULL);
47090 DUK_ASSERT(obj != NULL);
47092
47093#ifdef DUK_USE_ASSERTIONS
47094 entry_top = duk_get_top(ctx);
47095#endif
47096 /*
47097 * Get and call the finalizer. All of this must be wrapped
47098 * in a protected call, because even getting the finalizer
47099 * may trigger an error (getter may throw one, for instance).
47100 */
47101
47104 DUK_D(DUK_DPRINT("object already finalized, avoid running finalizer twice: %!O", obj));
47105 return;
47106 }
47107 DUK_HEAPHDR_SET_FINALIZED((duk_heaphdr *) obj); /* ensure never re-entered until rescue cycle complete */
47109 /* This shouldn't happen; call sites should avoid looking up
47110 * _Finalizer "through" a Proxy, but ignore if we come here
47111 * with a Proxy to avoid finalizer re-entry.
47112 */
47113 DUK_D(DUK_DPRINT("object is a proxy, skip finalizer call"));
47114 return;
47115 }
47116
47117 /* XXX: use a NULL error handler for the finalizer call? */
#define DUK_HEAPHDR_SET_FINALIZED(h)

References DUK_DDD, and DUK_DDDPRINT.

◆ duk_hobject_set_length()

DUK_INTERNAL_DECL void duk_hobject_set_length ( duk_hthread * thr,
duk_hobject * obj,
duk_uint32_t length )

Definition at line 52156 of file duktape-1.8.0/src/duktape.c.

◆ duk_hobject_set_length_zero()

DUK_INTERNAL_DECL void duk_hobject_set_length_zero ( duk_hthread * thr,
duk_hobject * obj )

Definition at line 52169 of file duktape-1.8.0/src/duktape.c.

◆ duk_hobject_set_prototype_updref()

DUK_INTERNAL_DECL void duk_hobject_set_prototype_updref ( duk_hthread * thr,
duk_hobject * h,
duk_hobject * p )

Definition at line 47156 of file duktape-1.8.0/src/duktape.c.

47156 {
47157 return 1;
47158 }
47159
47160 if (sanity-- == 0) {
47161 if (ignore_loop) {
47162 break;
47163 } else {
47165 }
47166 }
47167 h = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h);
47168 } while (h);
47169
47170 return 0;

◆ duk_hstring_char_code_at_raw()

DUK_INTERNAL_DECL duk_ucodepoint_t duk_hstring_char_code_at_raw ( duk_hthread * thr,
duk_hstring * h,
duk_uint_t pos )

Definition at line 53425 of file duktape-1.8.0/src/duktape.c.

53442 {
53443 duk_uint32_t boff;
53444 const duk_uint8_t *p, *p_start, *p_end;
53446
53447 /* Caller must check character offset to be inside the string. */
53448 DUK_ASSERT(thr != NULL);
53449 DUK_ASSERT(h != NULL);
53450 DUK_ASSERT_DISABLE(pos >= 0); /* unsigned */
53452

References DUK_ASSERT, DUK_ASSERT_DISABLE, DUK_DDD, DUK_DDDPRINT, duk_heap_strcache_offset_char2byte(), DUK_HSTRING_GET_BYTELEN, DUK_HSTRING_GET_CHARLEN, DUK_HSTRING_GET_DATA, duk_unicode_decode_xutf8_checked(), and NULL.

◆ duk_hthread_alloc()

DUK_INTERNAL_DECL duk_hthread * duk_hthread_alloc ( duk_heap * heap,
duk_uint_t hobject_flags )

Definition at line 46326 of file duktape-1.8.0/src/duktape.c.

46343 {
46344 duk_hthread *res;
46345
46346 res = (duk_hthread *) DUK_ALLOC(heap, sizeof(duk_hthread));
46347 if (!res) {
46348 return NULL;
46349 }
46350 DUK_MEMZERO(res, sizeof(duk_hthread));
46351
46352 duk__init_object_parts(heap, &res->obj, hobject_flags);
46353
46354#ifdef DUK_USE_EXPLICIT_NULL_INIT
46355 res->ptr_curr_pc = NULL;
46356 res->heap = NULL;
46357 res->valstack = NULL;
46358 res->valstack_end = NULL;
46359 res->valstack_bottom = NULL;
46360 res->valstack_top = NULL;
46361 res->callstack = NULL;
46362 res->catchstack = NULL;
46363 res->resumer = NULL;
46364 res->compile_ctx = NULL,
46365#ifdef DUK_USE_HEAPPTR16
46366 res->strs16 = NULL;
46367#else
46368 res->strs = NULL;
46369#endif

◆ duk_hthread_callstack_grow()

DUK_INTERNAL_DECL void duk_hthread_callstack_grow ( duk_hthread * thr)

Definition at line 54531 of file duktape-1.8.0/src/duktape.c.

54534 : This should be probably reworked so that there is a shared
54535 * unwind primitive which handles all stacks as requested, and knows
54536 * the proper order for unwinding.)
54537 *
54538 * Valstack entries above 'top' are always kept initialized to
54539 * "undefined unused". Callstack and catchstack entries above 'top'
54540 * are not zeroed and are left as garbage.
54541 *
54542 * Value stack handling is mostly a part of the API implementation.
54543 */
54544
54545/* include removed: duk_internal.h */
54546
54547/* check that there is space for at least one new entry */
54549 duk_activation *new_ptr;
54550 duk_size_t old_size;
54551 duk_size_t new_size;
54552
54553 DUK_ASSERT(thr != NULL);
54554 DUK_ASSERT_DISABLE(thr->callstack_top >= 0); /* avoid warning (unsigned) */
54556
54557 if (thr->callstack_top < thr->callstack_size) {
54558 return;
54559 }
54560
54561 old_size = thr->callstack_size;
54562 new_size = old_size + DUK_CALLSTACK_GROW_STEP;
54563
54564 /* this is a bit approximate (errors out before max is reached); this is OK */
54565 if (new_size >= thr->callstack_max) {
54567 }
54568
54569 DUK_DD(DUK_DDPRINT("growing callstack %ld -> %ld", (long) old_size, (long) new_size));
#define DUK_STR_CALLSTACK_LIMIT

References duk_hthread::callstack_max, duk_hthread::callstack_size, duk_hthread::callstack_top, DUK_ASSERT, DUK_ASSERT_DISABLE, DUK_CALLSTACK_GROW_STEP, DUK_DD, DUK_DDPRINT, DUK_ERROR_RANGE, DUK_STR_CALLSTACK_LIMIT, and NULL.

Referenced by duk_handle_ecma_call_setup().

◆ duk_hthread_callstack_shrink_check()

DUK_INTERNAL_DECL void duk_hthread_callstack_shrink_check ( duk_hthread * thr)

Definition at line 54571 of file duktape-1.8.0/src/duktape.c.

54578 {
54579 /* No need for a NULL/zero-size check because new_size > 0) */
54581 }
54582 thr->callstack = new_ptr;
54583 thr->callstack_size = new_size;
54584
54585 /* note: any entries above the callstack top are garbage and not zeroed */
54586}
54587
54589 duk_size_t new_size;
54590 duk_activation *p;
54591
54592 DUK_ASSERT(thr != NULL);
54593 DUK_ASSERT_DISABLE(thr->callstack_top >= 0); /* avoid warning (unsigned) */
54595
54597 return;
54598 }
54599
54600 new_size = thr->callstack_top + DUK_CALLSTACK_SHRINK_SPARE;
54601 DUK_ASSERT(new_size >= thr->callstack_top);
54602
54603 DUK_DD(DUK_DDPRINT("shrinking callstack %ld -> %ld", (long) thr->callstack_size, (long) new_size));
54604
54605 /*
54606 * Note: must use indirect variant of DUK_REALLOC() because underlying
54607 * pointer may be changed by mark-and-sweep.
#define DUK_CALLSTACK_SHRINK_THRESHOLD
#define DUK_CALLSTACK_SHRINK_SPARE

◆ duk_hthread_callstack_unwind()

DUK_INTERNAL_DECL void duk_hthread_callstack_unwind ( duk_hthread * thr,
duk_size_t new_top )

Definition at line 54609 of file duktape-1.8.0/src/duktape.c.

54612 {
54613 thr->callstack = p;
54614 thr->callstack_size = new_size;
54615 } else {
54616 /* Because new_size != 0, if condition doesn't need to be
54617 * (p != NULL || new_size == 0).
54618 */
54619 DUK_ASSERT(new_size != 0);
54620 DUK_D(DUK_DPRINT("callstack shrink failed, ignoring"));
54621 }
54622
54623 /* note: any entries above the callstack top are garbage and not zeroed */
54624}
54625
54627 duk_size_t idx;
54628
54629 DUK_DDD(DUK_DDDPRINT("unwind callstack top of thread %p from %ld to %ld",
54630 (void *) thr,
54631 (thr != NULL ? (long) thr->callstack_top : (long) -1),
54632 (long) new_top));
54633
54634 DUK_ASSERT(thr);
54635 DUK_ASSERT(thr->heap);
54636 DUK_ASSERT_DISABLE(new_top >= 0); /* unsigned */
54637 DUK_ASSERT((duk_size_t) new_top <= thr->callstack_top); /* cannot grow */
54638
54639 /*
54640 * The loop below must avoid issues with potential callstack
54641 * reallocations. A resize (and other side effects) may happen
54642 * e.g. due to finalizer/errhandler calls caused by a refzero or
54643 * mark-and-sweep. Arbitrary finalizers may run, because when
54644 * an environment record is refzero'd, it may refer to arbitrary
54645 * values which also become refzero'd.
54646 *
54647 * So, the pointer 'p' is re-looked-up below whenever a side effect
54648 * might have changed it.
54649 */
54650
54651 idx = thr->callstack_top;
54652 while (idx > new_top) {
54653 duk_activation *act;
54654 duk_hobject *func;
54655#ifdef DUK_USE_REFERENCE_COUNTING
54656 duk_hobject *tmp;
54657#endif
54658#ifdef DUK_USE_DEBUGGER_SUPPORT
54659 duk_heap *heap;
54660#endif
54661
54662 idx--;
54663 DUK_ASSERT_DISABLE(idx >= 0); /* unsigned */
54664 DUK_ASSERT((duk_size_t) idx < thr->callstack_size); /* true, despite side effect resizes */
54665
54666 act = thr->callstack + idx;
54667 /* With lightfuncs, act 'func' may be NULL */
54668
54669#ifdef DUK_USE_NONSTD_FUNC_CALLER_PROPERTY
54670 /*
54671 * Restore 'caller' property for non-strict callee functions.
54672 */
54673
54674 func = DUK_ACT_GET_FUNC(act);
54675 if (func != NULL && !DUK_HOBJECT_HAS_STRICT(func)) {
54676 duk_tval *tv_caller;
54677 duk_tval tv_tmp;
54678 duk_hobject *h_tmp;
54679
54681
54682 /* The act->prev_caller should only be set if the entry for 'caller'
54683 * exists (as it is only set in that case, and the property is not
54684 * configurable), but handle all the cases anyway.
54685 */
54686
54687 if (tv_caller) {
54688 DUK_TVAL_SET_TVAL(&tv_tmp, tv_caller);
54689 if (act->prev_caller) {
54690 /* Just transfer the refcount from act->prev_caller to tv_caller,
54691 * so no need for a refcount update. This is the expected case.
54692 */
54693 DUK_TVAL_SET_OBJECT(tv_caller, act->prev_caller);
54694 act->prev_caller = NULL;
54695 } else {
54696 DUK_TVAL_SET_NULL(tv_caller); /* no incref needed */
54697 DUK_ASSERT(act->prev_caller == NULL);
54698 }
54699 DUK_TVAL_DECREF(thr, &tv_tmp); /* side effects */
54700 } else {
54701 h_tmp = act->prev_caller;
54702 if (h_tmp) {
54703 act->prev_caller = NULL;
54704 DUK_HOBJECT_DECREF(thr, h_tmp); /* side effects */
54705 }
54706 }
54707 act = thr->callstack + idx; /* avoid side effects */
54708 DUK_ASSERT(act->prev_caller == NULL);
54709 }
54710#endif
54711
54712 /*
54713 * Unwind debugger state. If we unwind while stepping
54714 * (either step over or step into), pause execution.
54715 */
54716
54717#if defined(DUK_USE_DEBUGGER_SUPPORT)
54718 heap = thr->heap;
54719 if (heap->dbg_step_thread == thr &&
54720 heap->dbg_step_csindex == idx) {
54721 /* Pause for all step types: step into, step over, step out.
54722 * This is the only place explicitly handling a step out.
54723 */
54724 DUK_HEAP_SET_PAUSED(heap);
54725 DUK_ASSERT(heap->dbg_step_thread == NULL);
54726 }
54727#endif
54728
54729 /*
54730 * Close environment record(s) if they exist.
54731 *
54732 * Only variable environments are closed. If lex_env != var_env, it
54733 * cannot currently contain any register bound declarations.
54734 *
54735 * Only environments created for a NEWENV function are closed. If an
54736 * environment is created for e.g. an eval call, it must not be closed.
54737 */
54738
54739 func = DUK_ACT_GET_FUNC(act);
54740 if (func != NULL && !DUK_HOBJECT_HAS_NEWENV(func)) {
54741 DUK_DDD(DUK_DDDPRINT("skip closing environments, envs not owned by this activation"));
54742 goto skip_env_close;
54743 }
54744 /* func is NULL for lightfunc */
54745
54746 DUK_ASSERT(act->lex_env == act->var_env);
54747 if (act->var_env != NULL) {
54748 DUK_DDD(DUK_DDDPRINT("closing var_env record %p -> %!O",
54749 (void *) act->var_env, (duk_heaphdr *) act->var_env));
54750 duk_js_close_environment_record(thr, act->var_env, func, act->idx_bottom);
54751 act = thr->callstack + idx; /* avoid side effect issues */
54752 }
54753
54754#if 0
54755 if (act->lex_env != NULL) {
54756 if (act->lex_env == act->var_env) {
54757 /* common case, already closed, so skip */
54758 DUK_DD(DUK_DDPRINT("lex_env and var_env are the same and lex_env "
54759 "already closed -> skip closing lex_env"));
54760 ;
54761 } else {
54762 DUK_DD(DUK_DDPRINT("closing lex_env record %p -> %!O",
54763 (void *) act->lex_env, (duk_heaphdr *) act->lex_env));
54765 act = thr->callstack + idx; /* avoid side effect issues */
54766 }
54767 }
54768#endif
54769
54770 DUK_ASSERT((act->lex_env == NULL) ||
54775
54776 DUK_ASSERT((act->var_env == NULL) ||
54781
54782 skip_env_close:
54783
54784 /*
54785 * Update preventcount
54786 */
54787
54788 if (act->flags & DUK_ACT_FLAG_PREVENT_YIELD) {
54789 DUK_ASSERT(thr->callstack_preventcount >= 1);
54790 thr->callstack_preventcount--;
54791 }
54792
54793 /*
54794 * Reference count updates
54795 *
54796 * Note: careful manipulation of refcounts. The top is
54797 * not updated yet, so all the activations are reachable
54798 * for mark-and-sweep (which may be triggered by decref).
54799 * However, the pointers are NULL so this is not an issue.
54800 */
54801
54802#ifdef DUK_USE_REFERENCE_COUNTING
54803 tmp = act->var_env;
54804#endif
54805 act->var_env = NULL;
54806#ifdef DUK_USE_REFERENCE_COUNTING
54808 act = thr->callstack + idx; /* avoid side effect issues */
54809#endif
54810
54811#ifdef DUK_USE_REFERENCE_COUNTING
54812 tmp = act->lex_env;
54813#endif
54814 act->lex_env = NULL;
54815#ifdef DUK_USE_REFERENCE_COUNTING
54817 act = thr->callstack + idx; /* avoid side effect issues */
54818#endif
54819
54820 /* Note: this may cause a corner case situation where a finalizer
54821 * may see a currently reachable activation whose 'func' is NULL.
54822 */
54823#ifdef DUK_USE_REFERENCE_COUNTING
54824 tmp = DUK_ACT_GET_FUNC(act);
54825#endif
54826 act->func = NULL;
54827#ifdef DUK_USE_REFERENCE_COUNTING
54829 act = thr->callstack + idx; /* avoid side effect issues */
54830 DUK_UNREF(act);
54831#endif
54832 }
54833
54834 thr->callstack_top = new_top;
#define DUK_TVAL_SET_NULL(tv)
DUK_INTERNAL_DECL void duk_js_close_environment_record(duk_hthread *thr, duk_hobject *env, duk_hobject *func, duk_size_t regbase)

References duk_hthread::callstack, and duk_hthread::callstack_size.

Referenced by duk_handle_ecma_call_setup().

◆ duk_hthread_catchstack_grow()

DUK_INTERNAL_DECL void duk_hthread_catchstack_grow ( duk_hthread * thr)

Definition at line 54836 of file duktape-1.8.0/src/duktape.c.

54841 {
54842 duk_activation *act = thr->callstack + thr->callstack_top - 1;
54843 act->idx_retval = 0;
54844 }
54845#endif
54846
54847 /* Note: any entries above the callstack top are garbage and not zeroed.
54848 * Also topmost activation idx_retval is garbage (not zeroed), and must
54849 * be ignored.
54850 */
54851}
54852
54854 duk_catcher *new_ptr;
54855 duk_size_t old_size;
54856 duk_size_t new_size;
54857
54858 DUK_ASSERT(thr != NULL);
54859 DUK_ASSERT_DISABLE(thr->catchstack_top); /* avoid warning (unsigned) */
54861
54862 if (thr->catchstack_top < thr->catchstack_size) {
54863 return;
54864 }
54865
54866 old_size = thr->catchstack_size;
54867 new_size = old_size + DUK_CATCHSTACK_GROW_STEP;
54868
54869 /* this is a bit approximate (errors out before max is reached); this is OK */
54870 if (new_size >= thr->catchstack_max) {
54872 }
54873
54874 DUK_DD(DUK_DDPRINT("growing catchstack %ld -> %ld", (long) old_size, (long) new_size));
#define DUK_STR_CATCHSTACK_LIMIT
#define DUK_CATCHSTACK_GROW_STEP

References duk_activation::idx_retval.

◆ duk_hthread_catchstack_shrink_check()

DUK_INTERNAL_DECL void duk_hthread_catchstack_shrink_check ( duk_hthread * thr)

Definition at line 54876 of file duktape-1.8.0/src/duktape.c.

54883 {
54884 /* No need for a NULL/zero-size check because new_size > 0) */
54886 }
54887 thr->catchstack = new_ptr;
54888 thr->catchstack_size = new_size;
54889
54890 /* note: any entries above the catchstack top are garbage and not zeroed */
54891}
54892
54894 duk_size_t new_size;
54895 duk_catcher *p;
54896
54897 DUK_ASSERT(thr != NULL);
54898 DUK_ASSERT_DISABLE(thr->catchstack_top >= 0); /* avoid warning (unsigned) */
54900
54902 return;
54903 }
54904
54906 DUK_ASSERT(new_size >= thr->catchstack_top);
54907
54908 DUK_DD(DUK_DDPRINT("shrinking catchstack %ld -> %ld", (long) thr->catchstack_size, (long) new_size));
54909
54910 /*
54911 * Note: must use indirect variant of DUK_REALLOC() because underlying
54912 * pointer may be changed by mark-and-sweep.
#define DUK_CATCHSTACK_SHRINK_THRESHOLD
#define DUK_CATCHSTACK_SHRINK_SPARE

◆ duk_hthread_catchstack_unwind()

DUK_INTERNAL_DECL void duk_hthread_catchstack_unwind ( duk_hthread * thr,
duk_size_t new_top )

Definition at line 54914 of file duktape-1.8.0/src/duktape.c.

54917 {
54918 thr->catchstack = p;
54919 thr->catchstack_size = new_size;
54920 } else {
54921 /* Because new_size != 0, if condition doesn't need to be
54922 * (p != NULL || new_size == 0).
54923 */
54924 DUK_ASSERT(new_size != 0);
54925 DUK_D(DUK_DPRINT("catchstack shrink failed, ignoring"));
54926 }
54927
54928 /* note: any entries above the catchstack top are garbage and not zeroed */
54929}
54930
54932 duk_size_t idx;
54933
54934 DUK_DDD(DUK_DDDPRINT("unwind catchstack top of thread %p from %ld to %ld",
54935 (void *) thr,
54936 (thr != NULL ? (long) thr->catchstack_top : (long) -1),
54937 (long) new_top));
54938
54939 DUK_ASSERT(thr);
54940 DUK_ASSERT(thr->heap);
54941 DUK_ASSERT_DISABLE(new_top >= 0); /* unsigned */
54942 DUK_ASSERT((duk_size_t) new_top <= thr->catchstack_top); /* cannot grow */
54943
54944 /*
54945 * Since there are no references in the catcher structure,
54946 * unwinding is quite simple. The only thing we need to
54947 * look out for is popping a possible lexical environment
54948 * established for an active catch clause.
54949 */
54950
54951 idx = thr->catchstack_top;
54952 while (idx > new_top) {
54953 duk_catcher *p;
54954 duk_activation *act;
54955 duk_hobject *env;
54956
54957 idx--;
54958 DUK_ASSERT_DISABLE(idx >= 0); /* unsigned */
54959 DUK_ASSERT((duk_size_t) idx < thr->catchstack_size);
54960
54961 p = thr->catchstack + idx;
54962
54964 DUK_DDD(DUK_DDDPRINT("unwinding catchstack idx %ld, callstack idx %ld, callstack top %ld: lexical environment active",
54965 (long) idx, (long) p->callstack_index, (long) thr->callstack_top));
54966
54967 /* XXX: Here we have a nasty dependency: the need to manipulate
54968 * the callstack means that catchstack must always be unwound by
54969 * the caller before unwinding the callstack. This should be fixed
54970 * later.
54971 */
54972
54973 /* Note that multiple catchstack entries may refer to the same
54974 * callstack entry.
54975 */
54976 act = thr->callstack + p->callstack_index;
54977 DUK_ASSERT(act >= thr->callstack);
54978 DUK_ASSERT(act < thr->callstack + thr->callstack_top);
54979
54980 DUK_DDD(DUK_DDDPRINT("catchstack_index=%ld, callstack_index=%ld, lex_env=%!iO",
54981 (long) idx, (long) p->callstack_index,

References duk_hthread::catchstack, and duk_hthread::catchstack_size.

Referenced by duk_handle_ecma_call_setup().

◆ duk_hthread_copy_builtin_objects()

DUK_INTERNAL_DECL void duk_hthread_copy_builtin_objects ( duk_hthread * thr_from,
duk_hthread * thr_to )

Definition at line 54388 of file duktape-1.8.0/src/duktape.c.

54388 {
54389 DUK_DD(DUK_DDPRINT("built-in object %ld after initialization and compacting: %!@iO",
54390 (long) i, (duk_heaphdr *) duk_require_hobject(ctx, i)));
54391 }
54392#endif
54393
54394 /*
54395 * Pop built-ins from stack: they are now INCREF'd and

References DUK_DD, DUK_DDPRINT, and duk_require_hobject().

◆ duk_hthread_create_builtin_objects()

DUK_INTERNAL_DECL void duk_hthread_create_builtin_objects ( duk_hthread * thr)

Definition at line 53769 of file duktape-1.8.0/src/duktape.c.

53772 {
53775
53776 for (i = 0; i < 8; i++) {
53777 /* Encoding endianness must match target memory layout,
53778 * build scripts and genbuiltins.py must ensure this.
53779 */
53780 du.uc[i] = (duk_uint8_t) duk_bd_decode(bd, 8);
53781 }
53782
53783 duk_push_number(ctx, du.d); /* push operation normalizes NaNs */
53784}
53785
53787 duk_context *ctx = (duk_context *) thr;
53788 duk_bitdecoder_ctx bd_ctx;
53789 duk_bitdecoder_ctx *bd = &bd_ctx; /* convenience */
53790 duk_hobject *h;
53791 duk_small_uint_t i, j;
53792
53793 DUK_D(DUK_DPRINT("INITBUILTINS BEGIN: DUK_NUM_BUILTINS=%d, DUK_NUM_BUILTINS_ALL=%d", (int) DUK_NUM_BUILTINS, (int) DUK_NUM_ALL_BUILTINS));
53794
53795 DUK_MEMZERO(&bd_ctx, sizeof(bd_ctx));
53796 bd->data = (const duk_uint8_t *) duk_builtins_data;
53797 bd->length = (duk_size_t) DUK_BUILTINS_DATA_LENGTH;
53798
53799 /*
53800 * First create all built-in bare objects on the empty valstack.
53801 *
53802 * Built-ins in the index range [0,DUK_NUM_BUILTINS-1] have value
53803 * stack indices matching their eventual thr->builtins[] index.
53804 *
53805 * Built-ins in the index range [DUK_NUM_BUILTINS,DUK_NUM_ALL_BUILTINS]
53806 * will exist on the value stack during init but won't be placed
53807 * into thr->builtins[]. These are objects referenced in some way
53808 * from thr->builtins[] roots but which don't need to be indexed by
53809 * Duktape through thr->builtins[] (e.g. user custom objects).
53810 */
53811
53813
53814 DUK_DD(DUK_DDPRINT("create empty built-ins"));
53815 DUK_ASSERT_TOP(ctx, 0);
53816 for (i = 0; i < DUK_NUM_ALL_BUILTINS; i++) {
53817 duk_small_uint_t class_num;
53818 duk_small_int_t len = -1; /* must be signed */
53819
53821 len = (duk_small_int_t) duk_bd_decode_flagged(bd, DUK__LENGTH_PROP_BITS, (duk_int32_t) -1 /*def_value*/);
53822
53823 if (class_num == DUK_HOBJECT_CLASS_FUNCTION) {
53824 duk_small_uint_t natidx;
53825 duk_int_t c_nargs; /* must hold DUK_VARARGS */
53826 duk_c_function c_func;
53827 duk_int16_t magic;
53828
53829 DUK_DDD(DUK_DDDPRINT("len=%ld", (long) len));
53830 DUK_ASSERT(len >= 0);
53831
53833 c_func = duk_bi_native_functions[natidx];
53834
53835 c_nargs = (duk_small_uint_t) duk_bd_decode_flagged(bd, DUK__NARGS_BITS, len /*def_value*/);
53836 if (c_nargs == DUK__NARGS_VARARGS_MARKER) {
53837 c_nargs = DUK_VARARGS;
53838 }
53839
53840 /* XXX: set magic directly here? (it could share the c_nargs arg) */
53841 duk_push_c_function_noexotic(ctx, c_func, c_nargs);
53842
53843 h = duk_require_hobject(ctx, -1);
53844 DUK_ASSERT(h != NULL);
53845
53846 /* Currently all built-in native functions are strict.
53847 * duk_push_c_function() now sets strict flag, so
53848 * assert for it.
53849 */
53851
53852 /* XXX: function properties */
53853
53854 /* Built-in 'name' is not writable by default. Function '.name'
53855 * is writable to allow user code to set a '.name' on a native
53856 * function.
53857 */
53860 -2,
53864
53865 /* Almost all global level Function objects are constructable
53866 * but not all: Function.prototype is a non-constructable,
53867 * callable Function.
53868 */
53869 if (duk_bd_decode_flag(bd)) {
53871 } else {
53873 }
53874
53875 /* Cast converts magic to 16-bit signed value */
53876 magic = (duk_int16_t) duk_bd_decode_flagged(bd, DUK__MAGIC_BITS, 0 /*def_value*/);
53877 ((duk_hnativefunction *) h)->magic = magic;
53878 } else {
53879 /* XXX: ARRAY_PART for Array prototype? */
53880
53883 -1); /* no prototype or class yet */
53884
53885 h = duk_require_hobject(ctx, -1);
53886 DUK_ASSERT(h != NULL);
53887 }
53888
53889 DUK_HOBJECT_SET_CLASS_NUMBER(h, class_num);
53890
53891 if (i < DUK_NUM_BUILTINS) {
53892 thr->builtins[i] = h;
53893 DUK_HOBJECT_INCREF(thr, &h->hdr);
53894 }
53895
53896 if (len >= 0) {
53897 /*
53898 * For top-level objects, 'length' property has the following
53899 * default attributes: non-writable, non-enumerable, non-configurable
53900 * (E5 Section 15).
53901 *
53902 * However, 'length' property for Array.prototype has attributes
53903 * expected of an Array instance which are different: writable,
53904 * non-enumerable, non-configurable (E5 Section 15.4.5.2).
53905 *
53906 * This is currently determined implicitly based on class; there are
53907 * no attribute flags in the init data.
53908 */
53909
53910 duk_push_int(ctx, len);
53912 -2,
53914 (class_num == DUK_HOBJECT_CLASS_ARRAY ? /* only Array.prototype matches */
53916 }
53917
53918 /* enable exotic behaviors last */
53919
53920 if (class_num == DUK_HOBJECT_CLASS_ARRAY) {
53922 }
53923 if (class_num == DUK_HOBJECT_CLASS_STRING) {
53925 }
53926
53927 /* some assertions */
53928
53930 /* DUK_HOBJECT_FLAG_CONSTRUCTABLE varies */
53933 /* DUK_HOBJECT_FLAG_NATIVEFUNCTION varies */
53935 DUK_ASSERT(!DUK_HOBJECT_HAS_ARRAY_PART(h)); /* currently, even for Array.prototype */
53936 /* DUK_HOBJECT_FLAG_STRICT varies */
53937 DUK_ASSERT(!DUK_HOBJECT_HAS_NATIVEFUNCTION(h) || /* all native functions have NEWENV */
53942 /* DUK_HOBJECT_FLAG_EXOTIC_ARRAY varies */
53943 /* DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ varies */
53945
53946 DUK_DDD(DUK_DDDPRINT("created built-in %ld, class=%ld, length=%ld", (long) i, (long) class_num, (long) len));
53947 }
53948
53949 /*
53950 * Then decode the builtins init data (see genbuiltins.py) to
53951 * init objects
53952 */
53953
53954 DUK_DD(DUK_DDPRINT("initialize built-in object properties"));
53955 for (i = 0; i < DUK_NUM_ALL_BUILTINS; i++) {
53957 duk_small_uint_t num;
53958
53959 DUK_DDD(DUK_DDDPRINT("initializing built-in object at index %ld", (long) i));
53960 h = duk_require_hobject(ctx, i);
53961 DUK_ASSERT(h != NULL);
53962
53964 if (t != DUK__NO_BIDX_MARKER) {
53965 DUK_DDD(DUK_DDDPRINT("set internal prototype: built-in %ld", (long) t));
53967 }
53968
53970 if (t != DUK__NO_BIDX_MARKER) {
53971 /* 'prototype' property for all built-in objects (which have it) has attributes:
53972 * [[Writable]] = false,
53973 * [[Enumerable]] = false,
53974 * [[Configurable]] = false
53975 */
53976 DUK_DDD(DUK_DDDPRINT("set external prototype: built-in %ld", (long) t));
53978 }
53979
53981 if (t != DUK__NO_BIDX_MARKER) {
53982 /* 'constructor' property for all built-in objects (which have it) has attributes:
53983 * [[Writable]] = true,
53984 * [[Enumerable]] = false,
53985 * [[Configurable]] = true
53986 */
53987 DUK_DDD(DUK_DDDPRINT("set external constructor: built-in %ld", (long) t));
53989 }
53990
53991 /* normal valued properties */
53993 DUK_DDD(DUK_DDDPRINT("built-in object %ld, %ld normal valued properties", (long) i, (long) num));
53994 for (j = 0; j < num; j++) {
53995 duk_small_uint_t prop_flags;
53996
53998
53999 /*
54000 * Property attribute defaults are defined in E5 Section 15 (first
54001 * few pages); there is a default for all properties and a special
54002 * default for 'length' properties. Variation from the defaults is
54003 * signaled using a single flag bit in the bitstream.
54004 */
54005
54006 if (duk_bd_decode_flag(bd)) {
54008 } else {
54009 prop_flags = DUK_PROPDESC_FLAGS_WC;
54010 }
54011
54013
54014 DUK_DDD(DUK_DDDPRINT("built-in %ld, normal-valued property %ld, key %!T, flags 0x%02lx, type %ld",
54015 (long) i, (long) j, duk_get_tval(ctx, -1), (unsigned long) prop_flags, (long) t));
54016
54017 switch (t) {
54018 case DUK__PROP_TYPE_DOUBLE: {
54019 duk__push_double(ctx, bd);
54020 break;
54021 }
54022 case DUK__PROP_TYPE_STRING: {
54023 duk__push_string(ctx, bd);
54024 break;
54025 }
54026 case DUK__PROP_TYPE_STRIDX: {
54027 duk__push_stridx(ctx, bd);
54028 break;
54029 }
54031 duk_small_uint_t bidx;
54032
54035 duk_dup(ctx, (duk_idx_t) bidx);
54036 break;
54037 }
54039 duk_push_undefined(ctx);
54040 break;
54041 }
54043 duk_push_true(ctx);
54044 break;
54045 }
54047 duk_push_false(ctx);
54048 break;
54049 }
54053 duk_c_function c_func_getter;
54054 duk_c_function c_func_setter;
54055
54056 /* XXX: this is a bit awkward because there is no exposed helper
54057 * in the API style, only this internal helper.
54058 */
54059 DUK_DDD(DUK_DDDPRINT("built-in accessor property: objidx=%ld, key=%!T, getteridx=%ld, setteridx=%ld, flags=0x%04lx",
54060 (long) i, duk_get_tval(ctx, -1), (long) natidx_getter, (long) natidx_setter, (unsigned long) prop_flags));
54061
54062 c_func_getter = duk_bi_native_functions[natidx_getter];
54063 c_func_setter = duk_bi_native_functions[natidx_setter];
54064 duk_push_c_function_noconstruct_noexotic(ctx, c_func_getter, 0); /* always 0 args */
54065 duk_push_c_function_noconstruct_noexotic(ctx, c_func_setter, 1); /* always 1 arg */
54066
54067 /* XXX: magic for getter/setter? use duk_def_prop()? */
54068
54069 DUK_ASSERT((prop_flags & DUK_PROPDESC_FLAG_WRITABLE) == 0); /* genbuiltins.py ensures */
54070
54071 prop_flags |= DUK_PROPDESC_FLAG_ACCESSOR; /* accessor flag not encoded explicitly */
54073 duk_require_hobject(ctx, i),
54074 duk_get_hstring(ctx, -3),
54075 duk_require_hobject(ctx, -2),
54076 duk_require_hobject(ctx, -1),
54077 prop_flags);
54078 duk_pop_3(ctx); /* key, getter and setter, now reachable through object */
54079 goto skip_value;
54080 }
54081 default: {
54082 /* exhaustive */
54084 }
54085 }
54086
54087 DUK_ASSERT((prop_flags & DUK_PROPDESC_FLAG_ACCESSOR) == 0);
54088 duk_xdef_prop(ctx, i, prop_flags);
54089
54090 skip_value:
54091 continue; /* avoid empty label at the end of a compound statement */
54092 }
54093
54094 /* native function properties */
54096 DUK_DDD(DUK_DDDPRINT("built-in object %ld, %ld function valued properties", (long) i, (long) num));
54097 for (j = 0; j < num; j++) {
54098 duk_hstring *h_key;
54099 duk_small_uint_t natidx;
54100 duk_int_t c_nargs; /* must hold DUK_VARARGS */
54101 duk_small_uint_t c_length;
54102 duk_int16_t magic;
54103 duk_c_function c_func;
54104 duk_hnativefunction *h_func;
54105#if defined(DUK_USE_LIGHTFUNC_BUILTINS)
54106 duk_small_int_t lightfunc_eligible;
54107#endif
54108
54110 h_key = duk_get_hstring(ctx, -1);
54111 DUK_ASSERT(h_key != NULL);
54112 DUK_UNREF(h_key);
54114
54116 c_nargs = (duk_int_t) duk_bd_decode_flagged(bd, DUK__NARGS_BITS, (duk_int32_t) c_length /*def_value*/);
54117 if (c_nargs == DUK__NARGS_VARARGS_MARKER) {
54118 c_nargs = DUK_VARARGS;
54119 }
54120
54121 c_func = duk_bi_native_functions[natidx];
54122
54123 DUK_DDD(DUK_DDDPRINT("built-in %ld, function-valued property %ld, key %!O, natidx %ld, length %ld, nargs %ld",
54124 (long) i, (long) j, (duk_heaphdr *) h_key, (long) natidx, (long) c_length,
54125 (c_nargs == DUK_VARARGS ? (long) -1 : (long) c_nargs)));
54126
54127 /* Cast converts magic to 16-bit signed value */
54128 magic = (duk_int16_t) duk_bd_decode_flagged(bd, DUK__MAGIC_BITS, 0);
54129
54130#if defined(DUK_USE_LIGHTFUNC_BUILTINS)
54131 lightfunc_eligible =
54132 ((c_nargs >= DUK_LFUNC_NARGS_MIN && c_nargs <= DUK_LFUNC_NARGS_MAX) || (c_nargs == DUK_VARARGS)) &&
54133 (c_length <= DUK_LFUNC_LENGTH_MAX) &&
54134 (magic >= DUK_LFUNC_MAGIC_MIN && magic <= DUK_LFUNC_MAGIC_MAX);
54135
54136 if (h_key == DUK_HTHREAD_STRING_EVAL(thr) ||
54137 h_key == DUK_HTHREAD_STRING_YIELD(thr) ||
54138 h_key == DUK_HTHREAD_STRING_RESUME(thr) ||
54139 h_key == DUK_HTHREAD_STRING_REQUIRE(thr)) {
54140 /* These functions have trouble working as lightfuncs.
54141 * Some of them have specific asserts and some may have
54142 * additional properties (e.g. 'require.id' may be written).
54143 */
54144 DUK_D(DUK_DPRINT("reject as lightfunc: key=%!O, i=%d, j=%d", (duk_heaphdr *) h_key, (int) i, (int) j));
54145 lightfunc_eligible = 0;
54146 }
54147
54148 if (lightfunc_eligible) {
54149 duk_tval tv_lfunc;
54150 duk_small_uint_t lf_nargs = (c_nargs == DUK_VARARGS ? DUK_LFUNC_NARGS_VARARGS : c_nargs);
54151 duk_small_uint_t lf_flags = DUK_LFUNC_FLAGS_PACK(magic, c_length, lf_nargs);
54152 DUK_TVAL_SET_LIGHTFUNC(&tv_lfunc, c_func, lf_flags);
54153 duk_push_tval(ctx, &tv_lfunc);
54154 DUK_D(DUK_DPRINT("built-in function eligible as light function: i=%d, j=%d c_length=%ld, c_nargs=%ld, magic=%ld -> %!iT", (int) i, (int) j, (long) c_length, (long) c_nargs, (long) magic, duk_get_tval(ctx, -1)));
54155 goto lightfunc_skip;
54156 }
54157
54158 DUK_D(DUK_DPRINT("built-in function NOT ELIGIBLE as light function: i=%d, j=%d c_length=%ld, c_nargs=%ld, magic=%ld", (int) i, (int) j, (long) c_length, (long) c_nargs, (long) magic));
54159#endif /* DUK_USE_LIGHTFUNC_BUILTINS */
54160
54161 /* [ (builtin objects) name ] */
54162
54163 duk_push_c_function_noconstruct_noexotic(ctx, c_func, c_nargs);
54164 h_func = duk_require_hnativefunction(ctx, -1);
54165 DUK_UNREF(h_func);
54166
54167 /* Currently all built-in native functions are strict.
54168 * This doesn't matter for many functions, but e.g.
54169 * String.prototype.charAt (and other string functions)
54170 * rely on being strict so that their 'this' binding is
54171 * not automatically coerced.
54172 */
54174
54175 /* No built-in functions are constructable except the top
54176 * level ones (Number, etc).
54177 */
54179
54180 /* XXX: any way to avoid decoding magic bit; there are quite
54181 * many function properties and relatively few with magic values.
54182 */
54183 h_func->magic = magic;
54184
54185 /* [ (builtin objects) name func ] */
54186
54187 duk_push_int(ctx, c_length);
54189
54190 duk_dup(ctx, -2);
54192
54193 /* XXX: other properties of function instances; 'arguments', 'caller'. */
54194
54195 DUK_DD(DUK_DDPRINT("built-in object %ld, function property %ld -> %!T",
54196 (long) i, (long) j, (duk_tval *) duk_get_tval(ctx, -1)));
54197
54198 /* [ (builtin objects) name func ] */
54199
54200 /*
54201 * The default property attributes are correct for all
54202 * function valued properties of built-in objects now.
54203 */
54204
54205#if defined(DUK_USE_LIGHTFUNC_BUILTINS)
54206 lightfunc_skip:
54207#endif
54208
54210
54211 /* [ (builtin objects) ] */
54212 }
54213 }
54214
54215 /*
54216 * Special post-tweaks, for cases not covered by the init data format.
54217 *
54218 * - Set Date.prototype.toGMTString to Date.prototype.toUTCString.
54219 * toGMTString is required to have the same Function object as
54220 * toUTCString in E5 Section B.2.6. Note that while Smjs respects
54221 * this, V8 does not (the Function objects are distinct).
54222 *
54223 * - Make DoubleError non-extensible.
54224 *
54225 * - Add info about most important effective compile options to Duktape.
54226 *
54227 * - Possibly remove some properties (values or methods) which are not
54228 * desirable with current feature options but are not currently
54229 * conditional in init data.
54230 */
54231
54234
54236 DUK_ASSERT(h != NULL);
54238
54239#if !defined(DUK_USE_ES6_OBJECT_PROTO_PROPERTY)
54240 DUK_DD(DUK_DDPRINT("delete Object.prototype.__proto__ built-in which is not enabled in features"));
54242#endif
54243
54244#if !defined(DUK_USE_ES6_OBJECT_SETPROTOTYPEOF)
54245 DUK_DD(DUK_DDPRINT("delete Object.setPrototypeOf built-in which is not enabled in features"));
54247#endif
54248
54249 /* XXX: relocate */
54250 duk_push_string(ctx,
54251 /* Endianness indicator */
54252#if defined(DUK_USE_INTEGER_LE)
54253 "l"
54254#elif defined(DUK_USE_INTEGER_BE)
54255 "b"
54256#elif defined(DUK_USE_INTEGER_ME) /* integer mixed endian not really used now */
54257 "m"
54258#else
54259 "?"
54260#endif
54261#if defined(DUK_USE_DOUBLE_LE)
54262 "l"
54263#elif defined(DUK_USE_DOUBLE_BE)
54264 "b"
54265#elif defined(DUK_USE_DOUBLE_ME)
54266 "m"
54267#else
54268 "?"
54269#endif
54270 " "
54271 /* Packed or unpacked tval */
54272#if defined(DUK_USE_PACKED_TVAL)
54273 "p"
54274#else
54275 "u"
54276#endif
54277#if defined(DUK_USE_FASTINT)
54278 "f"
54279#endif
54280 " "
54281 /* Low memory options */
54282#if defined(DUK_USE_STRTAB_CHAIN)
54283 "c" /* chain */
54284#elif defined(DUK_USE_STRTAB_PROBE)
54285 "p" /* probe */
54286#else
54287 "?"
54288#endif
54289#if !defined(DUK_USE_HEAPPTR16) && !defined(DUK_DATAPTR16) && !defined(DUK_FUNCPTR16)
54290 "n"
54291#endif
54292#if defined(DUK_USE_HEAPPTR16)
54293 "h"
54294#endif
54295#if defined(DUK_USE_DATAPTR16)
54296 "d"
54297#endif
54298#if defined(DUK_USE_FUNCPTR16)
54299 "f"
54300#endif
54301#if defined(DUK_USE_REFCOUNT16)
54302 "R"
54303#endif
54304#if defined(DUK_USE_STRHASH16)
54305 "H"
54306#endif
54307#if defined(DUK_USE_STRLEN16)
54308 "S"
54309#endif
54310#if defined(DUK_USE_BUFLEN16)
54311 "B"
54312#endif
54313#if defined(DUK_USE_OBJSIZES16)
54314 "O"
54315#endif
54316#if defined(DUK_USE_LIGHTFUNC_BUILTINS)
54317 "L"
54318#endif
54319#if defined(DUK_USE_ROM_STRINGS) || defined(DUK_USE_ROM_OBJECTS)
54320 /* XXX: This won't be shown in practice now
54321 * because this code is not run when builtins
54322 * are in ROM.
54323 */
54324 "Z"
54325#endif
54326 " "
54327 /* Object property allocation layout */
54328#if defined(DUK_USE_HOBJECT_LAYOUT_1)
54329 "p1"
54330#elif defined(DUK_USE_HOBJECT_LAYOUT_2)
54331 "p2"
54332#elif defined(DUK_USE_HOBJECT_LAYOUT_3)
54333 "p3"
54334#else
54335 "p?"
54336#endif
54337 " "
54338 /* Alignment guarantee */
54339#if (DUK_USE_ALIGN_BY == 4)
54340 "a4"
54341#elif (DUK_USE_ALIGN_BY == 8)
54342 "a8"
54343#elif (DUK_USE_ALIGN_BY == 1)
54344 "a1"
54345#else
54346#error invalid DUK_USE_ALIGN_BY
54347#endif
54348 " "
54349 /* Architecture, OS, and compiler strings */
54351 " "
54353 " "
54356
54357 /*
54358 * InitJS code - Ecmascript code evaluated from a built-in source
54359 * which provides e.g. backward compatibility. User can also provide
54360 * JS code to be evaluated at startup.
54361 */
54362
54363#ifdef DUK_USE_BUILTIN_INITJS
54364 /* XXX: compression */
54365 DUK_DD(DUK_DDPRINT("running built-in initjs"));
54366 duk_eval_string(ctx, (const char *) duk_initjs_data); /* initjs data is NUL terminated */
54367 duk_pop(ctx);
54368#endif /* DUK_USE_BUILTIN_INITJS */
54369
54370#ifdef DUK_USE_USER_INITJS
54371 /* XXX: compression (as an option) */
54372 DUK_DD(DUK_DDPRINT("running user initjs"));
54373 duk_eval_string_noresult(ctx, (const char *) DUK_USE_USER_INITJS);
54374#endif /* DUK_USE_USER_INITJS */
54375
54376 /*
54377 * Since built-ins are not often extended, compact them.
54378 */
54379
54380 DUK_DD(DUK_DDPRINT("compact built-ins"));
54381 for (i = 0; i < DUK_NUM_ALL_BUILTINS; i++) {
54383 }
54384
54385 DUK_D(DUK_DPRINT("INITBUILTINS END"));
#define duk_eval_string(ctx, src)
#define duk_eval_string_noresult(ctx, src)
#define DUK__NARGS_VARARGS_MARKER
#define DUK__PROP_FLAGS_BITS
DUK_INTERNAL const duk_uint8_t duk_initjs_data[204]
#define DUK_STRIDX_TO_UTC_STRING
#define DUK_LFUNC_NARGS_MAX
#define DUK_HOBJECT_SET_EXOTIC_STRINGOBJ(h)
DUK_INTERNAL_DECL void duk_push_c_function_noconstruct_noexotic(duk_context *ctx, duk_c_function func, duk_int_t nargs)
#define DUK__NUM_FUNC_PROPS_BITS
#define DUK_LFUNC_LENGTH_MAX
#define DUK_STRIDX_TO_GMT_STRING
DUK_INTERNAL_DECL duk_int32_t duk_bd_decode_flagged(duk_bitdecoder_ctx *ctx, duk_small_int_t bits, duk_int32_t def_value)
#define DUK_HTHREAD_STRING___PROTO__(thr)
#define DUK__LENGTH_PROP_BITS
#define DUK_HOBJECT_HAS_CONSTRUCTABLE(h)
#define DUK__PROP_TYPE_ACCESSOR
#define DUK_HTHREAD_STRING_YIELD(thr)
#define DUK_HOBJECT_SET_EXOTIC_ARRAY(h)
DUK_EXTERNAL void duk_pop_3(duk_context *ctx)
#define DUK_LFUNC_MAGIC_MIN
#define DUK__PROP_TYPE_BUILTIN
DUK_INTERNAL const duk_c_function duk_bi_native_functions[149]
DUK_LOCAL void duk__push_stridx(duk_context *ctx, duk_bitdecoder_ctx *bd)
#define DUK_HTHREAD_STRING_RESUME(thr)
#define DUK__NO_BIDX_MARKER
#define DUK_LFUNC_FLAGS_PACK(magic, length, nargs)
#define DUK__CLASS_BITS
#define DUK__BIDX_BITS
#define DUK_HTHREAD_STRING_REQUIRE(thr)
#define DUK__PROP_TYPE_BITS
DUK_LOCAL void duk__push_double(duk_context *ctx, duk_bitdecoder_ctx *bd)
#define DUK__PROP_TYPE_STRIDX
#define DUK__PROP_TYPE_STRING
#define DUK__MAGIC_BITS
#define DUK_LFUNC_NARGS_MIN
DUK_INTERNAL_DECL void duk_push_c_function_noexotic(duk_context *ctx, duk_c_function func, duk_int_t nargs)
#define DUK_TVAL_SET_LIGHTFUNC(tv, fp, flags)
#define DUK_HOBJECT_CLEAR_CONSTRUCTABLE(h)
#define DUK_STRIDX_ENV
#define DUK__NATIDX_BITS
#define DUK_LFUNC_MAGIC_MAX
DUK_INTERNAL_DECL void duk_xdef_prop_stridx_builtin(duk_context *ctx, duk_idx_t obj_index, duk_small_int_t stridx, duk_small_int_t builtin_idx, duk_small_uint_t desc_flags)
#define DUK__PROP_TYPE_DOUBLE
DUK_INTERNAL_DECL void duk_hthread_create_builtin_objects(duk_hthread *thr)
#define DUK__NUM_NORMAL_PROPS_BITS
#define DUK_HOBJECT_SET_CLASS_NUMBER(h, v)
#define DUK__PROP_TYPE_BOOLEAN_FALSE
#define DUK__PROP_TYPE_BOOLEAN_TRUE
#define DUK__NARGS_BITS
#define DUK_HTHREAD_STRING_SET_PROTOTYPE_OF(thr)
#define DUK__PROP_TYPE_UNDEFINED
#define DUK_NUM_ALL_BUILTINS

◆ duk_hthread_get_act_prev_pc()

DUK_INTERNAL_DECL duk_uint_fast32_t duk_hthread_get_act_prev_pc ( duk_hthread * thr,
duk_activation * act )

Definition at line 54459 of file duktape-1.8.0/src/duktape.c.

54460 {
54461 duk_instr_t *bcode;
54462
54463 DUK_ASSERT(thr != NULL);
54464 DUK_ASSERT(act != NULL);
54465 DUK_UNREF(thr);
54466
54467 /* XXX: store 'bcode' pointer to activation for faster lookup? */
54468 if (act->func && DUK_HOBJECT_IS_COMPILEDFUNCTION(act->func)) {
54470 return (duk_uint_fast32_t) (act->curr_pc - bcode);
54471 }
54472 return 0;
54473}
54474#endif /* DUK_USE_DEBUGGER_SUPPORT */
54475

References duk_activation::curr_pc, DUK_ASSERT, DUK_HCOMPILEDFUNCTION_GET_CODE_BASE, DUK_HOBJECT_IS_COMPILEDFUNCTION, DUK_UNREF, duk_activation::func, duk_hthread::heap, and NULL.

◆ duk_hthread_get_callstack_ptr()

DUK_INTERNAL_DECL void * duk_hthread_get_callstack_ptr ( duk_heap * heap,
void * ud )

Definition at line 53549 of file duktape-1.8.0/src/duktape.c.

◆ duk_hthread_get_catchstack_ptr()

DUK_INTERNAL_DECL void * duk_hthread_get_catchstack_ptr ( duk_heap * heap,
void * ud )

Definition at line 53555 of file duktape-1.8.0/src/duktape.c.

◆ duk_hthread_get_current_activation()

DUK_INTERNAL_DECL duk_activation * duk_hthread_get_current_activation ( duk_hthread * thr)

Definition at line 54432 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_push_current_thread().

◆ duk_hthread_get_valstack_ptr()

DUK_INTERNAL_DECL void * duk_hthread_get_valstack_ptr ( duk_heap * heap,
void * ud )

Definition at line 53543 of file duktape-1.8.0/src/duktape.c.

53547 :
53548

Referenced by duk__resize_valstack().

◆ duk_hthread_init_stacks()

DUK_INTERNAL_DECL duk_bool_t duk_hthread_init_stacks ( duk_heap * heap,
duk_hthread * thr )

Definition at line 53477 of file duktape-1.8.0/src/duktape.c.

53494 {
53495 duk_size_t alloc_size;
53496 duk_size_t i;
53497
53498 DUK_ASSERT(heap != NULL);
53499 DUK_ASSERT(thr != NULL);
53500 DUK_ASSERT(thr->valstack == NULL);
53501 DUK_ASSERT(thr->valstack_end == NULL);
53503 DUK_ASSERT(thr->valstack_top == NULL);
53504 DUK_ASSERT(thr->callstack == NULL);
53505 DUK_ASSERT(thr->catchstack == NULL);
53506
53507 /* valstack */
53508 alloc_size = sizeof(duk_tval) * DUK_VALSTACK_INITIAL_SIZE;
53509 thr->valstack = (duk_tval *) DUK_ALLOC(heap, alloc_size);
53510 if (!thr->valstack) {
53511 goto fail;
53512 }
53513 DUK_MEMZERO(thr->valstack, alloc_size);
53515#if !defined(DUK_USE_PREFER_SIZE)
53517#endif
53518 thr->valstack_bottom = thr->valstack;
53519 thr->valstack_top = thr->valstack;
53520
53521 for (i = 0; i < DUK_VALSTACK_INITIAL_SIZE; i++) {
53523 }
53524
53525 /* callstack */
53526 alloc_size = sizeof(duk_activation) * DUK_CALLSTACK_INITIAL_SIZE;
53527 thr->callstack = (duk_activation *) DUK_ALLOC(heap, alloc_size);
53528 if (!thr->callstack) {
53529 goto fail;
53530 }
53531 DUK_MEMZERO(thr->callstack, alloc_size);
53533 DUK_ASSERT(thr->callstack_top == 0);
53534
53535 /* catchstack */
53536 alloc_size = sizeof(duk_catcher) * DUK_CATCHSTACK_INITIAL_SIZE;
53537 thr->catchstack = (duk_catcher *) DUK_ALLOC(heap, alloc_size);
53538 if (!thr->catchstack) {
53539 goto fail;
#define DUK_VALSTACK_INITIAL_SIZE
#define DUK_CATCHSTACK_INITIAL_SIZE
struct duk_activation duk_activation
#define DUK_CALLSTACK_INITIAL_SIZE
struct duk_catcher duk_catcher

◆ duk_hthread_sync_and_null_currpc()

DUK_INTERNAL_DECL void duk_hthread_sync_and_null_currpc ( duk_hthread * thr)

Definition at line 54492 of file duktape-1.8.0/src/duktape.c.

54496 {
54497 duk_activation *act;
54498
54499 DUK_ASSERT(thr != NULL);
54500
54501 if (thr->ptr_curr_pc != NULL) {
54502 /* ptr_curr_pc != NULL only when bytecode executor is active. */
54503 DUK_ASSERT(thr->callstack_top > 0);
54504 act = thr->callstack + thr->callstack_top - 1;

Referenced by duk_err_create_and_throw(), and duk_handle_ecma_call_setup().

◆ duk_hthread_sync_currpc()

DUK_INTERNAL_DECL void duk_hthread_sync_currpc ( duk_hthread * thr)

Definition at line 54479 of file duktape-1.8.0/src/duktape.c.

54484 {
54485 bcode = DUK_HCOMPILEDFUNCTION_GET_CODE_BASE(thr->heap, (duk_hcompiledfunction *) (act->func));
54486 ret = (duk_uint_fast32_t) (act->curr_pc - bcode);
54487 if (ret > 0) {
54488 ret--;
54489 }
54490 return ret;

◆ duk_hthread_terminate()

DUK_INTERNAL_DECL void duk_hthread_terminate ( duk_hthread * thr)

Definition at line 54403 of file duktape-1.8.0/src/duktape.c.

54405 {
54407
54408 for (i = 0; i < DUK_NUM_BUILTINS; i++) {
54409 thr_to->builtins[i] = thr_from->builtins[i];
54410 DUK_HOBJECT_INCREF_ALLOWNULL(thr_to, thr_to->builtins[i]); /* side effect free */
54411 }
54412}
54413#line 1 "duk_hthread_misc.c"
54414/*
54415 * Thread support.
54416 */
54417
54418/* include removed: duk_internal.h */
54419
54421 DUK_ASSERT(thr != NULL);
54422
54423 /* Order of unwinding is important */
54424
54426
54427 duk_hthread_callstack_unwind(thr, 0); /* side effects, possibly errors */
54428
54429 thr->valstack_bottom = thr->valstack;
54430 duk_set_top((duk_context *) thr, 0); /* unwinds valstack, updating refcounts */

References duk_hthread::builtins, DUK_HOBJECT_INCREF_ALLOWNULL, and DUK_NUM_BUILTINS.

◆ duk_insert()

DUK_EXTERNAL void duk_insert ( duk_context * ctx,
duk_idx_t to_index )

Definition at line 15875 of file duktape-1.8.0/src/duktape.c.

15880 {
15881 DUK_ERROR_API_INDEX(thr, -1);
15882 return; /* unreachable */
15883 }
15884 tv_from = thr->valstack_top - 1;
15885 tv_to = thr->valstack_top++;
15886 DUK_ASSERT(tv_from != NULL);
15887 DUK_ASSERT(tv_to != NULL);
15888 DUK_TVAL_SET_TVAL(tv_to, tv_from);
15889 DUK_TVAL_INCREF(thr, tv_to); /* no side effects */
15890}
15891
15892DUK_EXTERNAL void duk_insert(duk_context *ctx, duk_idx_t to_index) {
15893 duk_tval *p;
15894 duk_tval *q;
15895 duk_tval tv_tmp;
15896 duk_size_t nbytes;
15897
15899
15900 p = duk_require_tval(ctx, to_index);
15901 DUK_ASSERT(p != NULL);
15902 q = duk_require_tval(ctx, -1);
15903 DUK_ASSERT(q != NULL);
15904
15905 DUK_ASSERT(q >= p);
15906
15907 /* nbytes
15908 * <--------->
15909 * [ ... | p | x | x | q ]
15910 * => [ ... | q | p | x | x ]
15911 */
15912
15913 nbytes = (duk_size_t) (((duk_uint8_t *) q) - ((duk_uint8_t *) p)); /* Note: 'q' is top-1 */

Referenced by duk__err_augment_user(), duk_bi_regexp_constructor(), and duk_bi_string_prototype_locale_compare().

◆ duk_instanceof()

DUK_EXTERNAL duk_bool_t duk_instanceof ( duk_context * ctx,
duk_idx_t index1,
duk_idx_t index2 )

Definition at line 19580 of file duktape-1.8.0/src/duktape.c.

19585 {
19586 return 0;
19587 }
19588
19589 /* No coercions or other side effects, so safe */
19590 return duk_js_strict_equals(tv1, tv2);
19591}
19592
19593/*
19594 * instanceof
19595 */
19596
DUK_EXTERNAL duk_bool_t duk_instanceof(duk_context *ctx, duk_idx_t index1, duk_idx_t index2)

◆ duk_is_array()

DUK_EXTERNAL duk_bool_t duk_is_array ( duk_context * ctx,
duk_idx_t index )

Definition at line 17855 of file duktape-1.8.0/src/duktape.c.

17855 {
17857
17858 return duk_is_buffer(ctx, idx);
17859}
17860#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
17861
17864 return duk__tag_check(ctx, index, DUK_TAG_POINTER);
17865}
DUK_EXTERNAL duk_bool_t duk_is_pointer(duk_context *ctx, duk_idx_t index)
DUK_LOCAL duk_bool_t duk__tag_check(duk_context *ctx, duk_idx_t index, duk_small_uint_t tag)

References DUK_ASSERT_CTX_VALID, and duk_is_buffer().

◆ duk_is_boolean()

DUK_EXTERNAL duk_bool_t duk_is_boolean ( duk_context * ctx,
duk_idx_t index )

Definition at line 17759 of file duktape-1.8.0/src/duktape.c.

17762 {

Referenced by duk_bi_boolean_constructor().

◆ duk_is_bound_function()

DUK_EXTERNAL duk_bool_t duk_is_bound_function ( duk_context * ctx,
duk_idx_t index )

Definition at line 17897 of file duktape-1.8.0/src/duktape.c.

17900 {
DUK_LOCAL duk_bool_t duk__obj_flag_any_default_false(duk_context *ctx, duk_idx_t index, duk_uint_t flag_mask)

◆ duk_is_buffer()

DUK_EXTERNAL duk_bool_t duk_is_buffer ( duk_context * ctx,
duk_idx_t index )

Definition at line 17811 of file duktape-1.8.0/src/duktape.c.

17812 {
17813 return 0;
17814 }

Referenced by duk__base64_encode_helper(), and duk_is_array().

◆ duk_is_buffer_data()

DUK_EXTERNAL duk_bool_t duk_is_buffer_data ( duk_context * ctx,
duk_idx_t idx )

Definition at line 17817 of file duktape-1.8.0/src/duktape.c.

17818 {
17820 return duk__tag_check(ctx, index, DUK_TAG_STRING);
17821}
17822
17825 return duk__tag_check(ctx, index, DUK_TAG_OBJECT);
17826}
17827
17830 return duk__tag_check(ctx, index, DUK_TAG_BUFFER);
17831}
17832
17833#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
17835 duk_tval *tv;
17836
DUK_EXTERNAL duk_bool_t duk_is_buffer_data(duk_context *ctx, duk_idx_t idx)

References duk__tag_check(), DUK_ASSERT_CTX_VALID, DUK_TAG_STRING, and index.

◆ duk_is_c_function()

DUK_EXTERNAL duk_bool_t duk_is_c_function ( duk_context * ctx,
duk_idx_t index )

Definition at line 17883 of file duktape-1.8.0/src/duktape.c.

17884 {
17885 duk_tval *tv;
17886
17888

References DUK_ASSERT_CTX_VALID, duk_get_tval(), and index.

◆ duk_is_constructor_call()

DUK_EXTERNAL duk_bool_t duk_is_constructor_call ( duk_context * ctx)

Definition at line 12836 of file duktape-1.8.0/src/duktape.c.

12845 {
12847 }
12848 duk_push_uint(ctx, nargs);
12849 rc = duk_safe_call(ctx, duk__pnew_helper, nargs + 2 /*nargs*/, 1 /*nrets*/);
DUK_LOCAL duk_ret_t duk__pnew_helper(duk_context *ctx)

References DUK_ERROR_API, and DUK_STR_INVALID_CALL_ARGS.

◆ duk_is_dynamic_buffer()

DUK_EXTERNAL duk_bool_t duk_is_dynamic_buffer ( duk_context * ctx,
duk_idx_t index )

Definition at line 17925 of file duktape-1.8.0/src/duktape.c.

17928 {
17929 duk_tval *tv;
17930
17932
17933 tv = duk_get_tval(ctx, index);
17934 if (tv && DUK_TVAL_IS_BUFFER(tv)) {
17936 DUK_ASSERT(h != NULL);
17937 return (DUK_HBUFFER_HAS_DYNAMIC(h) ? 0 : 1);

◆ duk_is_ecmascript_function()

DUK_EXTERNAL duk_bool_t duk_is_ecmascript_function ( duk_context * ctx,
duk_idx_t index )

Definition at line 17890 of file duktape-1.8.0/src/duktape.c.

17890 {
17891 return 1;
17892 }
17894 index,

◆ duk_is_external_buffer()

DUK_EXTERNAL duk_bool_t duk_is_external_buffer ( duk_context * ctx,
duk_idx_t index )

Definition at line 17939 of file duktape-1.8.0/src/duktape.c.

17942 {
17943 duk_tval *tv;
17944
17946
17947 tv = duk_get_tval(ctx, index);
17948 if (tv && DUK_TVAL_IS_BUFFER(tv)) {
17950 DUK_ASSERT(h != NULL);
17951 return (DUK_HBUFFER_HAS_DYNAMIC(h) && !DUK_HBUFFER_HAS_EXTERNAL(h) ? 1 : 0);

◆ duk_is_fixed_buffer()

DUK_EXTERNAL duk_bool_t duk_is_fixed_buffer ( duk_context * ctx,
duk_idx_t index )

Definition at line 17911 of file duktape-1.8.0/src/duktape.c.

17914 {
17917 index,
17919}
17920
DUK_EXTERNAL duk_bool_t duk_is_thread(duk_context *ctx, duk_idx_t index)

◆ duk_is_function()

DUK_EXTERNAL duk_bool_t duk_is_function ( duk_context * ctx,
duk_idx_t index )

Definition at line 17867 of file duktape-1.8.0/src/duktape.c.

17867 {
17870}
17871
17873 duk_hobject *obj;
17874
17876
17877 obj = duk_get_hobject(ctx, index);
17878 if (obj) {
17880 }
17881 return 0;
DUK_EXTERNAL duk_bool_t duk_is_array(duk_context *ctx, duk_idx_t index)

References duk__tag_check(), DUK_ASSERT_CTX_VALID, DUK_TAG_LIGHTFUNC, and index.

◆ duk_is_lightfunc()

DUK_EXTERNAL duk_bool_t duk_is_lightfunc ( duk_context * ctx,
duk_idx_t index )

Definition at line 17850 of file duktape-1.8.0/src/duktape.c.

◆ duk_is_nan()

DUK_EXTERNAL duk_bool_t duk_is_nan ( duk_context * ctx,
duk_idx_t index )

Definition at line 17783 of file duktape-1.8.0/src/duktape.c.

17794 {
17795 return 0;
17796 }
17797 return DUK_TVAL_IS_NUMBER(tv);
17798}
17799

◆ duk_is_null()

DUK_EXTERNAL duk_bool_t duk_is_null ( duk_context * ctx,
duk_idx_t index )

Definition at line 17740 of file duktape-1.8.0/src/duktape.c.

17742 {
17743 return 1;

◆ duk_is_null_or_undefined()

DUK_EXTERNAL duk_bool_t duk_is_null_or_undefined ( duk_context * ctx,
duk_idx_t index )

Definition at line 17745 of file duktape-1.8.0/src/duktape.c.

17745 {
17748 }
17749 return 0;
17750}
17751
17755}
17756

References DUK_ERROR_TYPE, DUK_STR_UNEXPECTED_TYPE, and DUK_UNREACHABLE.

◆ duk_is_number()

DUK_EXTERNAL duk_bool_t duk_is_number ( duk_context * ctx,
duk_idx_t index )

Definition at line 17764 of file duktape-1.8.0/src/duktape.c.

17769 {
17770 return 0;
17771 }
17772 tag = DUK_TVAL_GET_TAG(tv);
17773 return (tag == DUK_TAG_UNDEFINED) || (tag == DUK_TAG_NULL);
17774}
17775
17778 return duk__tag_check(ctx, index, DUK_TAG_BOOLEAN);
17779}
17780

◆ duk_is_object()

DUK_EXTERNAL duk_bool_t duk_is_object ( duk_context * ctx,
duk_idx_t index )

Definition at line 17806 of file duktape-1.8.0/src/duktape.c.

◆ duk_is_pointer()

DUK_EXTERNAL duk_bool_t duk_is_pointer ( duk_context * ctx,
duk_idx_t index )

Definition at line 17845 of file duktape-1.8.0/src/duktape.c.

17845 {
17847 DUK_ASSERT(h != NULL);

◆ duk_is_strict_call()

DUK_EXTERNAL duk_bool_t duk_is_strict_call ( duk_context * ctx)

Definition at line 12851 of file duktape-1.8.0/src/duktape.c.

12853 {
12854 duk_hthread *thr = (duk_hthread *) ctx;
12855 duk_activation *act;
12856
12858 DUK_ASSERT(thr != NULL);
12860
12862 if (act != NULL) {
12863 return ((act->flags & DUK_ACT_FLAG_CONSTRUCT) != 0 ? 1 : 0);
12864 }
12865 return 0;
12866}
12867
12869 duk_hthread *thr = (duk_hthread *) ctx;
12870 duk_activation *act;
12871
12872 /* For user code this could just return 1 (strict) always
12873 * because all Duktape/C functions are considered strict,
12874 * and strict is also the default when nothing is running.
DUK_EXTERNAL duk_bool_t duk_is_strict_call(duk_context *ctx)

◆ duk_is_string()

DUK_EXTERNAL duk_bool_t duk_is_string ( duk_context * ctx,
duk_idx_t index )

◆ duk_is_thread()

DUK_EXTERNAL duk_bool_t duk_is_thread ( duk_context * ctx,
duk_idx_t index )

Definition at line 17904 of file duktape-1.8.0/src/duktape.c.

17907 {

◆ duk_is_undefined()

DUK_EXTERNAL duk_bool_t duk_is_undefined ( duk_context * ctx,
duk_idx_t index )

Definition at line 17735 of file duktape-1.8.0/src/duktape.c.

17737 {
17738 duk_hthread *thr = (duk_hthread *) ctx;

◆ duk_is_valid_index()

DUK_EXTERNAL duk_bool_t duk_is_valid_index ( duk_context * ctx,
duk_idx_t index )

Definition at line 15311 of file duktape-1.8.0/src/duktape.c.

15312 {
15314 uindex = (duk_uidx_t) index;
15315 }
15316

Referenced by duk__base64_encode_helper(), and duk_hobject_define_property_internal().

◆ duk_join()

DUK_EXTERNAL void duk_join ( duk_context * ctx,
duk_idx_t count )

Definition at line 19908 of file duktape-1.8.0/src/duktape.c.

◆ duk_js_close_environment_record()

DUK_INTERNAL_DECL void duk_js_close_environment_record ( duk_hthread * thr,
duk_hobject * env,
duk_hobject * func,
duk_size_t regbase )

Definition at line 72073 of file duktape-1.8.0/src/duktape.c.

72090 {
72091 duk_context *ctx = (duk_context *) thr;
72093
72094 DUK_ASSERT(thr != NULL);
72095 DUK_ASSERT(env != NULL);
72096 /* func is NULL for lightfuncs */
72097
72099 DUK_DDD(DUK_DDDPRINT("environment record not a declarative record, "
72100 "or already closed: %!iO",
72101 (duk_heaphdr *) env));
72102 return;
72103 }
72104
72105 DUK_DDD(DUK_DDDPRINT("closing environment record: %!iO, func: %!iO, regbase: %ld",
72106 (duk_heaphdr *) env, (duk_heaphdr *) func, (long) regbase));
72107
72108 duk_push_hobject(ctx, env);
72109
72110 /* assertions: env must be closed in the same thread as where it runs */
72111#ifdef DUK_USE_ASSERTIONS
72112 {
72113 /* [... env] */
72114
72116 DUK_ASSERT(duk_is_object(ctx, -1));
72117 DUK_ASSERT(duk_get_hobject(ctx, -1) == (duk_hobject *) func);
72118 }
72119 duk_pop(ctx);
72120
72122 DUK_ASSERT(duk_is_object(ctx, -1));
72123 DUK_ASSERT(duk_get_hobject(ctx, -1) == (duk_hobject *) thr);
72124 }
72125 duk_pop(ctx);
72126
72128 DUK_ASSERT(duk_is_number(ctx, -1));
72129 DUK_ASSERT(duk_get_number(ctx, -1) == (double) regbase);
72130 }
72131 duk_pop(ctx);
72132
72133 /* [... env] */
72134 }
72135#endif
72136
72137 if (func != NULL && DUK_HOBJECT_IS_COMPILEDFUNCTION(func)) {
72138 duk_hobject *varmap;
72139 duk_hstring *key;
72140 duk_tval *tv;
72141 duk_uint_t regnum;
72142
72143 /* XXX: additional conditions when to close variables? we don't want to do it
72144 * unless the environment may have "escaped" (referenced in a function closure).
72145 * With delayed environments, the existence is probably good enough of a check.
72146 */
72147
72148 /* XXX: any way to detect faster whether something needs to be closed?
72149 * We now look up _Callee and then skip the rest.
72150 */
72151
72152 /* Note: we rely on the _Varmap having a bunch of nice properties, like:
72153 * - being compacted and unmodified during this process
72154 * - not containing an array part
72155 * - having correct value types
72156 */
72157
72158 /* [... env] */
72159
72161 DUK_DDD(DUK_DDDPRINT("env has no callee property, nothing to close; re-delete the control properties just in case"));
72162 duk_pop(ctx);
72163 goto skip_varmap;
72164 }
72165
72166 /* [... env callee] */
72167
72169 DUK_DDD(DUK_DDDPRINT("callee has no varmap property, nothing to close; delete the control properties"));
72170 duk_pop_2(ctx);
72171 goto skip_varmap;
72172 }
72173 varmap = duk_require_hobject(ctx, -1);
72174 DUK_ASSERT(varmap != NULL);
72175
72176 DUK_DDD(DUK_DDDPRINT("varmap: %!O", (duk_heaphdr *) varmap));
72177
72178 /* [... env callee varmap] */
72179
72180 DUK_DDD(DUK_DDDPRINT("copying bound register values, %ld bound regs", (long) DUK_HOBJECT_GET_ENEXT(varmap)));
72181
72182 for (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ENEXT(varmap); i++) {
72183 key = DUK_HOBJECT_E_GET_KEY(thr->heap, varmap, i);
72184 DUK_ASSERT(key != NULL); /* assume keys are compacted */
72185
72186 DUK_ASSERT(!DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, varmap, i)); /* assume plain values */
72187
72188 tv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, varmap, i);
72189 DUK_ASSERT(DUK_TVAL_IS_NUMBER(tv)); /* assume value is a number */
72190 regnum = (duk_uint_t) DUK_TVAL_GET_NUMBER(tv);
72191 DUK_ASSERT_DISABLE(regnum >= 0); /* unsigned */
72192 DUK_ASSERT(regnum < ((duk_hcompiledfunction *) func)->nregs); /* regnum is sane */
72193 DUK_ASSERT(thr->valstack + regbase + regnum >= thr->valstack);
72194 DUK_ASSERT(thr->valstack + regbase + regnum < thr->valstack_top);
72195
72196 /* XXX: slightly awkward */
72197 duk_push_hstring(ctx, key);
72198 duk_push_tval(ctx, thr->valstack + regbase + regnum);
72199 DUK_DDD(DUK_DDDPRINT("closing identifier '%s' -> reg %ld, value %!T",
72200 (const char *) duk_require_string(ctx, -2),
72201 (long) regnum,
72202 (duk_tval *) duk_get_tval(ctx, -1)));
72203
72204 /* [... env callee varmap key val] */
72205
72206 /* if property already exists, overwrites silently */
72207 duk_xdef_prop(ctx, -5, DUK_PROPDESC_FLAGS_WE); /* writable but not deletable */
72208 }
72209
72210 duk_pop_2(ctx);
72211
72212 /* [... env] */
#define DUK_STRIDX_INT_CALLEE
#define DUK_STRIDX_INT_REGBASE
#define DUK_STRIDX_INT_THREAD
#define DUK_PROPDESC_FLAGS_WE

◆ duk_js_compare_helper()

DUK_INTERNAL_DECL duk_bool_t duk_js_compare_helper ( duk_hthread * thr,
duk_tval * tv_x,
duk_tval * tv_y,
duk_small_int_t flags )

Definition at line 70942 of file duktape-1.8.0/src/duktape.c.

70945 {
70946 /* Similar to String comparison. */
70947
70948 DUK_ASSERT(h1 != NULL);
70949 DUK_ASSERT(h2 != NULL);
70950 DUK_UNREF(heap);
70951
70952 return duk_js_data_compare((const duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(heap, h1),
70953 (const duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(heap, h2),
70956}
70957#endif
70958
70960 duk_context *ctx = (duk_context *) thr;
70961 duk_double_t d1, d2;
70962 duk_small_int_t c1, c2;
70963 duk_small_int_t s1, s2;
70964 duk_small_int_t rc;
70965 duk_bool_t retval;
70966
70967 /* Fast path for fastints */
70968#if defined(DUK_USE_FASTINT)
70969 if (DUK_TVAL_IS_FASTINT(tv_x) && DUK_TVAL_IS_FASTINT(tv_y)) {
70970 duk_int64_t v1 = DUK_TVAL_GET_FASTINT(tv_x);
70971 duk_int64_t v2 = DUK_TVAL_GET_FASTINT(tv_y);
70972 if (v1 < v2) {
70973 /* 'lt is true' */
70974 retval = 1;
70975 } else {
70976 retval = 0;
70977 }
70978 if (flags & DUK_COMPARE_FLAG_NEGATE) {
70979 retval ^= 1;
70980 }
70981 return retval;
70982 }
70983#endif /* DUK_USE_FASTINT */
70984
70985 /* Fast path for numbers (one of which may be a fastint) */
70986#if 1 /* XXX: make fast paths optional for size minimization? */
70987 if (DUK_TVAL_IS_NUMBER(tv_x) && DUK_TVAL_IS_NUMBER(tv_y)) {
70988 d1 = DUK_TVAL_GET_NUMBER(tv_x);
70989 d2 = DUK_TVAL_GET_NUMBER(tv_y);
70990 c1 = DUK_FPCLASSIFY(d1);
70991 c2 = DUK_FPCLASSIFY(d2);
70992
70993 if (c1 == DUK_FP_NORMAL && c2 == DUK_FP_NORMAL) {
70994 /* XXX: this is a very narrow check, and doesn't cover
70995 * zeroes, subnormals, infinities, which compare normally.
70996 */
70997
70998 if (d1 < d2) {
70999 /* 'lt is true' */
71000 retval = 1;
71001 } else {
71002 retval = 0;
71003 }
71004 if (flags & DUK_COMPARE_FLAG_NEGATE) {
71005 retval ^= 1;
71006 }
71007 return retval;
71008 }
71009 }
71010#endif
71011
71012 /* Slow path */
71013
71014 duk_push_tval(ctx, tv_x);
71015 duk_push_tval(ctx, tv_y);
71016
71020 } else {
71023 }
71024
71025 /* Note: reuse variables */
71026 tv_x = DUK_GET_TVAL_NEGIDX(ctx, -2);
71027 tv_y = DUK_GET_TVAL_NEGIDX(ctx, -1);
71028
71029 if (DUK_TVAL_IS_STRING(tv_x) && DUK_TVAL_IS_STRING(tv_y)) {
71030 duk_hstring *h1 = DUK_TVAL_GET_STRING(tv_x);
71031 duk_hstring *h2 = DUK_TVAL_GET_STRING(tv_y);
71032 DUK_ASSERT(h1 != NULL);
71033 DUK_ASSERT(h2 != NULL);
71034
71035 rc = duk_js_string_compare(h1, h2);
71036 if (rc < 0) {
71037 goto lt_true;
71038 } else {
71039 goto lt_false;
71040 }
71041 } else {
71042 /* Ordering should not matter (E5 Section 11.8.5, step 3.a) but
71043 * preserve it just in case.
71044 */
71045
71047 d1 = duk_to_number(ctx, -2);
71048 d2 = duk_to_number(ctx, -1);
71049 } else {
71050 d2 = duk_to_number(ctx, -1);
71051 d1 = duk_to_number(ctx, -2);
71052 }
71053
71055 s1 = (duk_small_int_t) DUK_SIGNBIT(d1);
71057 s2 = (duk_small_int_t) DUK_SIGNBIT(d2);
71058
71059 if (c1 == DUK_FP_NAN || c2 == DUK_FP_NAN) {
71060 goto lt_undefined;
71061 }
71062
71063 if (c1 == DUK_FP_ZERO && c2 == DUK_FP_ZERO) {
71064 /* For all combinations: +0 < +0, +0 < -0, -0 < +0, -0 < -0,
71065 * steps e, f, and g.
71066 */
71067 goto lt_false;
71068 }
71069
71070 if (d1 == d2) {
71071 goto lt_false;
71072 }
71073
71074 if (c1 == DUK_FP_INFINITE && s1 == 0) {
71075 /* x == +Infinity */
71076 goto lt_false;
71077 }
71078
71079 if (c2 == DUK_FP_INFINITE && s2 == 0) {
71080 /* y == +Infinity */
71081 goto lt_true;
71082 }
71083
71084 if (c2 == DUK_FP_INFINITE && s2 != 0) {
71085 /* y == -Infinity */
71086 goto lt_false;
71087 }
71088
71089 if (c1 == DUK_FP_INFINITE && s1 != 0) {
71090 /* x == -Infinity */
71091 goto lt_true;
71092 }
71093
71094 if (d1 < d2) {
71095 goto lt_true;
71096 }
71097
71098 goto lt_false;
71099 }
71100
71101 lt_undefined:
71102 /* Note: undefined from Section 11.8.5 always results in false
71103 * return (see e.g. Section 11.8.3) - hence special treatment here.
71104 */
71105 retval = 0;
71106 goto cleanup;
71107
71108 lt_true:
71109 if (flags & DUK_COMPARE_FLAG_NEGATE) {
71110 retval = 0;
71111 goto cleanup;
71112 } else {
71113 retval = 1;
71114 goto cleanup;

◆ duk_js_compile()

DUK_INTERNAL_DECL void duk_js_compile ( duk_hthread * thr,
const duk_uint8_t * src_buffer,
duk_size_t src_length,
duk_small_uint_t flags )

Definition at line 65545 of file duktape-1.8.0/src/duktape.c.

65562 {
65563 duk_context *ctx = (duk_context *) thr;
65564 duk__compiler_stkstate comp_stk;
65565 duk_compiler_ctx *prev_ctx;
65566 duk_ret_t safe_rc;
65567
65568 /* XXX: this illustrates that a C catchpoint implemented using duk_safe_call()
65569 * is a bit heavy at the moment. The wrapper compiles to ~180 bytes on x64.
65570 * Alternatives would be nice.
65571 */
65572
65573 DUK_ASSERT(thr != NULL);
65574 DUK_ASSERT(src_buffer != NULL);
65575
65576 /* preinitialize lexer state partially */
65577 DUK_MEMZERO(&comp_stk, sizeof(comp_stk));
65578 comp_stk.flags = flags;
65580 comp_stk.comp_ctx_alloc.lex.input = src_buffer;
#define DUK_LEXER_INITCTX(ctx)

◆ duk_js_data_compare()

DUK_INTERNAL_DECL duk_small_int_t duk_js_data_compare ( const duk_uint8_t * buf1,
const duk_uint8_t * buf2,
duk_size_t len1,
duk_size_t len2 )

Definition at line 70874 of file duktape-1.8.0/src/duktape.c.

70891 {
70892 duk_size_t prefix_len;
70893 duk_small_int_t rc;
70894
70895 prefix_len = (len1 <= len2 ? len1 : len2);
70896
70897 /* DUK_MEMCMP() is guaranteed to return zero (equal) for zero length
70898 * inputs so no zero length check is needed.
70899 */
70900 rc = DUK_MEMCMP((const void *) buf1,
70901 (const void *) buf2,
70902 (size_t) prefix_len);

◆ duk_js_declvar_activation()

DUK_INTERNAL_DECL duk_bool_t duk_js_declvar_activation ( duk_hthread * thr,
duk_activation * act,
duk_hstring * name,
duk_tval * val,
duk_small_int_t prop_flags,
duk_bool_t is_func_decl )

Definition at line 73277 of file duktape-1.8.0/src/duktape.c.

73287 :
73288 fail_not_extensible:
73289 DUK_ERROR_TYPE(thr, "declaration failed");
73290 return 0;
73291}
73292
73295 duk_activation *act,
73297 duk_tval *val,
73298 duk_small_int_t prop_flags,
73299 duk_bool_t is_func_decl) {
73300 duk_hobject *env;
73301 duk_tval tv_val_copy;
73302 duk_size_t act_off;
73303
73304 DUK_ASSERT(act != NULL);
73305 act_off = (duk_size_t) ((duk_uint8_t *) act - (duk_uint8_t *) thr->callstack);
73306
73307 /*
73308 * Make a value copy of the input val. This ensures that
73309 * side effects cannot invalidate the pointer.
73310 */
73311
73312 DUK_TVAL_SET_TVAL(&tv_val_copy, val);
73313 val = &tv_val_copy;
73314
73315 /*

◆ duk_js_delvar_activation()

DUK_INTERNAL_DECL duk_bool_t duk_js_delvar_activation ( duk_hthread * thr,
duk_activation * act,
duk_hstring * name )

Definition at line 72987 of file duktape-1.8.0/src/duktape.c.

72988 : name=%!O "
72989 "(treated as silent success)",
72990 (duk_heaphdr *) name));
72991 return 1;
72992}

◆ duk_js_equals_helper()

DUK_INTERNAL_DECL duk_bool_t duk_js_equals_helper ( duk_hthread * thr,
duk_tval * tv_x,
duk_tval * tv_y,
duk_small_int_t flags )

Definition at line 70642 of file duktape-1.8.0/src/duktape.c.

70650 {
70651 /* SameValue(NaN, NaN) = true, regardless of NaN sign or extra bits */
70652 return 1;
70653 }
70654 return 0;
70655 }
70656#endif /* DUK_USE_PARANOID_MATH */
70657}
70658
70660 duk_context *ctx = (duk_context *) thr;
70661 duk_tval *tv_tmp;
70662
70663 /* If flags != 0 (strict or SameValue), thr can be NULL. For loose
70664 * equals comparison it must be != NULL.
70665 */
70666 DUK_ASSERT(flags != 0 || thr != NULL);
70667
70668 /*
70669 * Same type?
70670 *
70671 * Note: since number values have no explicit tag in the 8-byte
70672 * representation, need the awkward if + switch.
70673 */
70674
70675#if defined(DUK_USE_FASTINT)
70676 if (DUK_TVAL_IS_FASTINT(tv_x) && DUK_TVAL_IS_FASTINT(tv_y)) {
70677 if (DUK_TVAL_GET_FASTINT(tv_x) == DUK_TVAL_GET_FASTINT(tv_y)) {
70678 return 1;
70679 } else {
70680 return 0;
70681 }
70682 }
70683 else
70684#endif
70685 if (DUK_TVAL_IS_NUMBER(tv_x) && DUK_TVAL_IS_NUMBER(tv_y)) {
70686 /* Catches both doubles and cases where only one argument is a fastint */
70687 if (DUK_UNLIKELY((flags & DUK_EQUALS_FLAG_SAMEVALUE) != 0)) {
70688 /* SameValue */
70690 DUK_TVAL_GET_NUMBER(tv_y));
70691 } else {
70692 /* equals and strict equals */
70694 DUK_TVAL_GET_NUMBER(tv_y));
70695 }
70696 } else if (DUK_TVAL_GET_TAG(tv_x) == DUK_TVAL_GET_TAG(tv_y)) {
70697 switch (DUK_TVAL_GET_TAG(tv_x)) {
70698 case DUK_TAG_UNDEFINED:
70699 case DUK_TAG_NULL: {
70700 return 1;
70701 }
70702 case DUK_TAG_BOOLEAN: {
70703 return DUK_TVAL_GET_BOOLEAN(tv_x) == DUK_TVAL_GET_BOOLEAN(tv_y);
70704 }
70705 case DUK_TAG_POINTER: {
70706 return DUK_TVAL_GET_POINTER(tv_x) == DUK_TVAL_GET_POINTER(tv_y);
70707 }
70708 case DUK_TAG_STRING:
70709 case DUK_TAG_OBJECT: {
70710 /* heap pointer comparison suffices */
70711 return DUK_TVAL_GET_HEAPHDR(tv_x) == DUK_TVAL_GET_HEAPHDR(tv_y);
70712 }
70713 case DUK_TAG_BUFFER: {
70714 if ((flags & (DUK_EQUALS_FLAG_STRICT | DUK_EQUALS_FLAG_SAMEVALUE)) != 0) {
70715 /* heap pointer comparison suffices */
70716 return DUK_TVAL_GET_HEAPHDR(tv_x) == DUK_TVAL_GET_HEAPHDR(tv_y);
70717 } else {
70718 /* non-strict equality for buffers compares contents */
70719 duk_hbuffer *h_x = DUK_TVAL_GET_BUFFER(tv_x);
70720 duk_hbuffer *h_y = DUK_TVAL_GET_BUFFER(tv_y);
70721 duk_size_t len_x = DUK_HBUFFER_GET_SIZE(h_x);
70722 duk_size_t len_y = DUK_HBUFFER_GET_SIZE(h_y);
70723 void *buf_x;
70724 void *buf_y;
70725 if (len_x != len_y) {
70726 return 0;
70727 }
70728 buf_x = (void *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_x);
70729 buf_y = (void *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_y);
70730 /* if len_x == len_y == 0, buf_x and/or buf_y may
70731 * be NULL, but that's OK.
70732 */
70733 DUK_ASSERT(len_x == len_y);
70734 DUK_ASSERT(len_x == 0 || buf_x != NULL);
70735 DUK_ASSERT(len_y == 0 || buf_y != NULL);
70736 return (DUK_MEMCMP((const void *) buf_x, (const void *) buf_y, (size_t) len_x) == 0) ? 1 : 0;
70737 }
70738 }
70739 case DUK_TAG_LIGHTFUNC: {
70740 /* At least 'magic' has a significant impact on function
70741 * identity.
70742 */
70743 duk_small_uint_t lf_flags_x;
70744 duk_small_uint_t lf_flags_y;
70745 duk_c_function func_x;
70746 duk_c_function func_y;
70747
70748 DUK_TVAL_GET_LIGHTFUNC(tv_x, func_x, lf_flags_x);
70749 DUK_TVAL_GET_LIGHTFUNC(tv_y, func_y, lf_flags_y);
70750 return ((func_x == func_y) && (lf_flags_x == lf_flags_y)) ? 1 : 0;
70751 }
70752#if defined(DUK_USE_FASTINT)
70753 case DUK_TAG_FASTINT:
70754#endif
70755 default: {
70761 return 0;
70762 }
70763 }
70764 }
70765
70766 if ((flags & (DUK_EQUALS_FLAG_STRICT | DUK_EQUALS_FLAG_SAMEVALUE)) != 0) {
70767 return 0;
70768 }
70769
70770 DUK_ASSERT(flags == 0); /* non-strict equality from here on */
70771
70772 /*
70773 * Types are different; various cases for non-strict comparison
70774 *
70775 * Since comparison is symmetric, we use a "swap trick" to reduce
70776 * code size.
70777 */
70778
70779 /* Undefined/null are considered equal (e.g. "null == undefined" -> true). */
70780 if ((DUK_TVAL_IS_UNDEFINED(tv_x) && DUK_TVAL_IS_NULL(tv_y)) ||
70781 (DUK_TVAL_IS_NULL(tv_x) && DUK_TVAL_IS_UNDEFINED(tv_y))) {
70782 return 1;
70783 }
70784
70785 /* Number/string-or-buffer -> coerce string to number (e.g. "'1.5' == 1.5" -> true). */
70786 if (DUK_TVAL_IS_NUMBER(tv_x) && (DUK_TVAL_IS_STRING(tv_y) || DUK_TVAL_IS_BUFFER(tv_y))) {
70787 /* the next 'if' is guaranteed to match after swap */
70788 tv_tmp = tv_x;
70789 tv_x = tv_y;
70790 tv_y = tv_tmp;
70791 }
70792 if ((DUK_TVAL_IS_STRING(tv_x) || DUK_TVAL_IS_BUFFER(tv_x)) && DUK_TVAL_IS_NUMBER(tv_y)) {
70793 /* XXX: this is possible without resorting to the value stack */
70794 duk_double_t d1, d2;
70795 d2 = DUK_TVAL_GET_NUMBER(tv_y);
70796 duk_push_tval(ctx, tv_x);
70797 duk_to_string(ctx, -1); /* buffer values are coerced first to string here */
70798 duk_to_number(ctx, -1);
70799 d1 = duk_require_number(ctx, -1);
70800 duk_pop(ctx);
70801 return duk__js_equals_number(d1, d2);
70802 }
70803
70804 /* Buffer/string -> compare contents. */
70805 if (DUK_TVAL_IS_BUFFER(tv_x) && DUK_TVAL_IS_STRING(tv_y)) {
70806 tv_tmp = tv_x;
70807 tv_x = tv_y;
70808 tv_y = tv_tmp;
70809 }
70810 if (DUK_TVAL_IS_STRING(tv_x) && DUK_TVAL_IS_BUFFER(tv_y)) {
70811 duk_hstring *h_x = DUK_TVAL_GET_STRING(tv_x);
70812 duk_hbuffer *h_y = DUK_TVAL_GET_BUFFER(tv_y);
70814 duk_size_t len_y = DUK_HBUFFER_GET_SIZE(h_y);
70815 const void *buf_x;
70816 const void *buf_y;
70817 if (len_x != len_y) {
70818 return 0;
70819 }
70820 buf_x = (const void *) DUK_HSTRING_GET_DATA(h_x);
70821 buf_y = (const void *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_y);
70822 /* if len_x == len_y == 0, buf_x and/or buf_y may
70823 * be NULL, but that's OK.
70824 */
70825 DUK_ASSERT(len_x == len_y);
70826 DUK_ASSERT(len_x == 0 || buf_x != NULL);
70827 DUK_ASSERT(len_y == 0 || buf_y != NULL);
70828 return (DUK_MEMCMP((const void *) buf_x, (const void *) buf_y, (size_t) len_x) == 0) ? 1 : 0;
70829 }
70830
70831 /* Boolean/any -> coerce boolean to number and try again. If boolean is
70832 * compared to a pointer, the final comparison after coercion now always
70833 * yields false (as pointer vs. number compares to false), but this is
70834 * not special cased.
70835 */
70836 if (DUK_TVAL_IS_BOOLEAN(tv_x)) {
70837 tv_tmp = tv_x;
70838 tv_x = tv_y;
70839 tv_y = tv_tmp;
70840 }
70841 if (DUK_TVAL_IS_BOOLEAN(tv_y)) {
70842 /* ToNumber(bool) is +1.0 or 0.0. Tagged boolean value is always 0 or 1. */
70843 duk_bool_t rc;
70844 DUK_ASSERT(DUK_TVAL_GET_BOOLEAN(tv_y) == 0 || DUK_TVAL_GET_BOOLEAN(tv_y) == 1);
70845 duk_push_tval(ctx, tv_x);
70847 rc = duk_js_equals_helper(thr,
70848 DUK_GET_TVAL_NEGIDX(ctx, -2),
70849 DUK_GET_TVAL_NEGIDX(ctx, -1),
70850 0 /*flags:nonstrict*/);
70851 duk_pop_2(ctx);
70852 return rc;
70853 }
70854
70855 /* String-number-buffer/object -> coerce object to primitive (apparently without hint), then try again. */
70856 if ((DUK_TVAL_IS_STRING(tv_x) || DUK_TVAL_IS_NUMBER(tv_x) || DUK_TVAL_IS_BUFFER(tv_x)) &&
70857 DUK_TVAL_IS_OBJECT(tv_y)) {
70858 tv_tmp = tv_x;
70859 tv_x = tv_y;
70860 tv_y = tv_tmp;
70861 }
DUK_EXTERNAL duk_double_t duk_require_number(duk_context *ctx, duk_idx_t index)
#define DUK_EQUALS_FLAG_SAMEVALUE
#define DUK_TVAL_GET_LIGHTFUNC(tv, out_fp, out_flags)

◆ duk_js_execute_bytecode()

DUK_INTERNAL_DECL void duk_js_execute_bytecode ( duk_hthread * exec_thr)

Definition at line 67606 of file duktape-1.8.0/src/duktape.c.

67606 {
67607 /* Restart bytecode execution, possibly with a changed thread. */
67608 ;
67609 } else {
67610 /* Rethrow error to calling state. */
67612
67613 /* Longjmp handling has restored jmpbuf_ptr. */
67614 DUK_ASSERT(heap->lj.jmpbuf_ptr == entry_jmpbuf_ptr);
67615
67616 /* Thread may have changed, e.g. YIELD converted to THROW. */
67617 duk_err_longjmp(heap->curr_thread);
67619 }
67620}
67621
67622/* Outer executor with setjmp/longjmp handling. */
67624 /* Entry level info. */
67625 duk_hthread *entry_thread;
67626 duk_size_t entry_callstack_top;
67627 duk_int_t entry_call_recursion_depth;
67628 duk_jmpbuf *entry_jmpbuf_ptr;
67629 duk_jmpbuf our_jmpbuf;
67630 duk_heap *heap;
67631
67632 DUK_ASSERT(exec_thr != NULL);
67633 DUK_ASSERT(exec_thr->heap != NULL);
67634 DUK_ASSERT(exec_thr->heap->curr_thread != NULL);
67636 DUK_ASSERT(exec_thr->callstack_top >= 1); /* at least one activation, ours */
67637 DUK_ASSERT(DUK_ACT_GET_FUNC(exec_thr->callstack + exec_thr->callstack_top - 1) != NULL);
67639
67640 entry_thread = exec_thr;
67641 heap = entry_thread->heap;
67642 entry_callstack_top = entry_thread->callstack_top;
67643 entry_call_recursion_depth = entry_thread->heap->call_recursion_depth;
67644 entry_jmpbuf_ptr = entry_thread->heap->lj.jmpbuf_ptr;
67645
67646 /*
67647 * Note: we currently assume that the setjmp() catchpoint is
67648 * not re-entrant (longjmp() cannot be called more than once
67649 * for a single setjmp()).
67650 *
67651 * See doc/code-issues.rst for notes on variable assignment
67652 * before and after setjmp().
67653 */
67654
67655 for (;;) {
67656 heap->lj.jmpbuf_ptr = &our_jmpbuf;
67657 DUK_ASSERT(heap->lj.jmpbuf_ptr != NULL);
67658
67659#if defined(DUK_USE_CPP_EXCEPTIONS)
67660 try {
67661#else
67662 DUK_ASSERT(heap->lj.jmpbuf_ptr == &our_jmpbuf);
67663 if (DUK_SETJMP(our_jmpbuf.jb) == 0) {
67664#endif
67665 /* Execute bytecode until returned or longjmp(). */
67666 duk__js_execute_bytecode_inner(entry_thread, entry_callstack_top);
67667
67668 /* Successful return: restore jmpbuf and return to caller. */
67669 heap->lj.jmpbuf_ptr = entry_jmpbuf_ptr;
67670
67671 return;
67672#if defined(DUK_USE_CPP_EXCEPTIONS)
67673 } catch (duk_internal_exception &exc) {
67674#else
67675 } else {
67676#endif
67677#if defined(DUK_USE_CPP_EXCEPTIONS)
67678 DUK_UNREF(exc);
67679#endif
67680 DUK_DDD(DUK_DDDPRINT("longjmp caught by bytecode executor"));
67681
67683 entry_thread,
67684 entry_callstack_top,
67685 entry_call_recursion_depth,
67686 entry_jmpbuf_ptr);
67687 }
67688#if defined(DUK_USE_CPP_EXCEPTIONS)
67689 catch (std::exception &exc) {
67690 const char *what = exc.what();
67691 if (!what) {
67692 what = "unknown";
67693 }
67694 DUK_D(DUK_DPRINT("unexpected c++ std::exception (perhaps thrown by user code)"));
67695 try {
67696 DUK_ASSERT(heap->curr_thread != NULL);
67697 DUK_ERROR_FMT1(heap->curr_thread, DUK_ERR_API_ERROR, "caught invalid c++ std::exception '%s' (perhaps thrown by user code)", what);
67698 } catch (duk_internal_exception exc) {
67699 DUK_D(DUK_DPRINT("caught api error thrown from unexpected c++ std::exception"));
67700 DUK_UNREF(exc);
67702 entry_thread,
67703 entry_callstack_top,
67704 entry_call_recursion_depth,
67705 entry_jmpbuf_ptr);
67706 }
67707 } catch (...) {
67708 DUK_D(DUK_DPRINT("unexpected c++ exception (perhaps thrown by user code)"));
67709 try {

◆ duk_js_getvar_activation()

DUK_INTERNAL_DECL duk_bool_t duk_js_getvar_activation ( duk_hthread * thr,
duk_activation * act,
duk_hstring * name,
duk_bool_t throw_flag )

Definition at line 72772 of file duktape-1.8.0/src/duktape.c.

◆ duk_js_getvar_envrec()

DUK_INTERNAL_DECL duk_bool_t duk_js_getvar_envrec ( duk_hthread * thr,
duk_hobject * env,
duk_hstring * name,
duk_bool_t throw_flag )

Definition at line 72764 of file duktape-1.8.0/src/duktape.c.

72769 {

◆ duk_js_in()

DUK_INTERNAL_DECL duk_bool_t duk_js_in ( duk_hthread * thr,
duk_tval * tv_x,
duk_tval * tv_y )

Definition at line 71293 of file duktape-1.8.0/src/duktape.c.

71295 :
71296 duk_pop_2(ctx);
71297 return 1;
71298}
71299
71300/*
71301 * in
71302 */
71303
71304/*
71305 * E5 Sections 11.8.7, 8.12.6.
71306 *
71307 * Basically just a property existence check using [[HasProperty]].
71308 */
71309
71311 duk_context *ctx = (duk_context *) thr;
71312 duk_bool_t retval;
71313
71314 /*
71315 * Get the values onto the stack first. It would be possible to cover
71316 * some normal cases without resorting to the value stack (e.g. if
71317 * lval is already a string).
71318 */
71319
71320 /* XXX: The ES5/5.1/6 specifications require that the key in 'key in obj'
71321 * must be string coerced before the internal HasProperty() algorithm is
71322 * invoked. A fast path skipping coercion could be safely implemented for
71323 * numbers (as number-to-string coercion has no side effects). For ES6
71324 * proxy behavior, the trap 'key' argument must be in a string coerced
71325 * form (which is a shame).

◆ duk_js_init_activation_environment_records_delayed()

DUK_INTERNAL_DECL void duk_js_init_activation_environment_records_delayed ( duk_hthread * thr,
duk_activation * act )

Definition at line 72014 of file duktape-1.8.0/src/duktape.c.

72018 {
72019 duk_push_hthread(ctx, thr);
72021 duk_push_hobject(ctx, func);
72023 duk_push_size_t(ctx, idx_bottom);
72025 }
72026
72027 return env;
72028}
72029
72032 duk_activation *act) {
72033 duk_context *ctx = (duk_context *) thr;
72034 duk_hobject *func;
72035 duk_hobject *env;
72036 duk_size_t act_off;
72037
72038 DUK_ASSERT(act != NULL);
72039 act_off = (duk_size_t) ((duk_uint8_t *) act - (duk_uint8_t *) thr->callstack);
72040 func = DUK_ACT_GET_FUNC(act);
72041 DUK_ASSERT(func != NULL);
72042 DUK_ASSERT(!DUK_HOBJECT_HAS_BOUND(func)); /* bound functions are never in act 'func' */
72043
72044 /*
72045 * Delayed initialization only occurs for 'NEWENV' functions.
72046 */
72047
72049 DUK_ASSERT(act->lex_env == NULL);
72050 DUK_ASSERT(act->var_env == NULL);
72051
72053 DUK_ASSERT(env != NULL);
72054 act = (duk_activation *) ((duk_uint8_t *) thr->callstack + act_off);
72055
72056 DUK_DDD(DUK_DDDPRINT("created delayed fresh env: %!ipO", (duk_heaphdr *) env));
#define duk_push_hthread(ctx, h)

◆ duk_js_instanceof()

DUK_INTERNAL_DECL duk_bool_t duk_js_instanceof ( duk_hthread * thr,
duk_tval * tv_x,
duk_tval * tv_y )

Definition at line 71136 of file duktape-1.8.0/src/duktape.c.

71153 {
71154 duk_context *ctx = (duk_context *) thr;
71155 duk_hobject *func;
71156 duk_hobject *val;
71158 duk_uint_t sanity;
71159
71160 /*
71161 * Get the values onto the stack first. It would be possible to cover
71162 * some normal cases without resorting to the value stack.
71163 *
71164 * The right hand side could be a light function (as they generally
71165 * behave like objects). Light functions never have a 'prototype'
71166 * property so E5.1 Section 15.3.5.3 step 3 always throws a TypeError.
71167 * Using duk_require_hobject() is thus correct (except for error msg).
71168 */
71169
71170 duk_push_tval(ctx, tv_x);
71171 duk_push_tval(ctx, tv_y);
71172 func = duk_require_hobject(ctx, -1);
71173
71174 /*
71175 * For bound objects, [[HasInstance]] just calls the target function
71176 * [[HasInstance]]. If that is again a bound object, repeat until
71177 * we find a non-bound Function object.
71178 */
71179
71180 /* XXX: this bound function resolution also happens elsewhere,
71181 * move into a shared helper.
71182 */
71183
71185 do {
71186 /* check func supports [[HasInstance]] (this is checked for every function
71187 * in the bound chain, including the final one)
71188 */
71189
71190 if (!DUK_HOBJECT_IS_CALLABLE(func)) {
71191 /*
71192 * Note: of native Ecmascript objects, only Function instances
71193 * have a [[HasInstance]] internal property. Custom objects might
71194 * also have it, but not in current implementation.
71195 *
71196 * XXX: add a separate flag, DUK_HOBJECT_FLAG_ALLOW_INSTANCEOF?
71197 */
71198 DUK_ERROR_TYPE(thr, "invalid instanceof rval");
71199 }
71200
71201 if (!DUK_HOBJECT_HAS_BOUND(func)) {
71202 break;
71203 }
71204
71205 /* [ ... lval rval ] */
71206
71207 duk_get_prop_stridx(ctx, -1, DUK_STRIDX_INT_TARGET); /* -> [ ... lval rval new_rval ] */
71208 duk_replace(ctx, -1); /* -> [ ... lval new_rval ] */
71209 func = duk_require_hobject(ctx, -1);
71210
71211 /* func support for [[HasInstance]] checked in the beginning of the loop */
71212 } while (--sanity > 0);
71213
71214 if (sanity == 0) {
71216 }
71217
71218 /*
71219 * 'func' is now a non-bound object which supports [[HasInstance]]
71220 * (which here just means DUK_HOBJECT_FLAG_CALLABLE). Move on
71221 * to execute E5 Section 15.3.5.3.
71222 */
71223
71226
71227 /* [ ... lval rval(func) ] */
71228
71229 /* Handle lightfuncs through object coercion for now. */
71230 /* XXX: direct implementation */
71231 val = duk_get_hobject_or_lfunc_coerce(ctx, -2);
71232 if (!val) {
71233 goto pop_and_false;
71234 }
71235
71236 duk_get_prop_stridx(ctx, -1, DUK_STRIDX_PROTOTYPE); /* -> [ ... lval rval rval.prototype ] */
71237 proto = duk_require_hobject(ctx, -1);
71238 duk_pop(ctx); /* -> [ ... lval rval ] */
71239
71240 DUK_ASSERT(val != NULL);
71241
71242#if defined(DUK_USE_ES6_PROXY)
71243 val = duk_hobject_resolve_proxy_target(thr, val);
71244 DUK_ASSERT(val != NULL);
71245#endif
71246
71248 do {
71249 /*
71250 * Note: prototype chain is followed BEFORE first comparison. This
71251 * means that the instanceof lval is never itself compared to the
71252 * rval.prototype property. This is apparently intentional, see E5
71253 * Section 15.3.5.3, step 4.a.
71254 *
71255 * Also note:
71256 *
71257 * js> (function() {}) instanceof Function
71258 * true
71259 * js> Function instanceof Function
71260 * true
71261 *
71262 * For the latter, h_proto will be Function.prototype, which is the
71263 * built-in Function prototype. Because Function.[[Prototype]] is
71264 * also the built-in Function prototype, the result is true.
71265 */
71266
71267 DUK_ASSERT(val != NULL);
71268 val = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, val);
71269
71270 if (!val) {
71271 goto pop_and_false;
71272 }
71273
71274 DUK_ASSERT(val != NULL);
71275#if defined(DUK_USE_ES6_PROXY)
71276 val = duk_hobject_resolve_proxy_target(thr, val);
71277#endif
71278
71279 if (val == proto) {
71280 goto pop_and_true;
71281 }
DUK_INTERNAL_DECL duk_hobject * duk_hobject_resolve_proxy_target(duk_hthread *thr, duk_hobject *obj)

References DUK_ASSERT, DUK_ERROR_RANGE, DUK_ERROR_TYPE, duk_get_hobject_or_lfunc_coerce(), duk_get_prop_stridx(), DUK_HOBJECT_BOUND_CHAIN_SANITY, DUK_HOBJECT_GET_PROTOTYPE, DUK_HOBJECT_HAS_BOUND, DUK_HOBJECT_IS_CALLABLE, DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY, duk_hobject_resolve_proxy_target(), duk_pop(), duk_pop_2(), duk_push_tval(), duk_replace(), duk_require_hobject(), DUK_STR_BOUND_CHAIN_LIMIT, DUK_STR_PROTOTYPE_CHAIN_LIMIT, DUK_STRIDX_INT_TARGET, DUK_STRIDX_PROTOTYPE, DUK_UNREACHABLE, duk_hthread::heap, NULL, and proto.

◆ duk_js_push_closure()

DUK_INTERNAL_DECL void duk_js_push_closure ( duk_hthread * thr,
duk_hcompiledfunction * fun_temp,
duk_hobject * outer_var_env,
duk_hobject * outer_lex_env,
duk_bool_t add_auto_proto )

Definition at line 71603 of file duktape-1.8.0/src/duktape.c.

71604 : if fun_temp has NEWENV, i.e. a new lexical and variable declaration
71605 * is created when the function is called, only outer_lex_env matters
71606 * (outer_var_env is ignored and may or may not be same as outer_lex_env).
71607 */
71608
71609DUK_LOCAL const duk_uint16_t duk__closure_copy_proplist[] = {
71610 /* order: most frequent to least frequent */
71617};
71618
71621 duk_hcompiledfunction *fun_temp,
71622 duk_hobject *outer_var_env,
71623 duk_hobject *outer_lex_env,
71624 duk_bool_t add_auto_proto) {
71625 duk_context *ctx = (duk_context *) thr;
71626 duk_hcompiledfunction *fun_clos;
71628 duk_uint_t len_value;
71629
71630 DUK_ASSERT(fun_temp != NULL);
71634 DUK_ASSERT(outer_var_env != NULL);
71635 DUK_ASSERT(outer_lex_env != NULL);
71636 DUK_UNREF(len_value);
71637
71639 duk_push_hobject(ctx, &fun_temp->obj); /* -> [ ... closure template ] */
71640
71641 fun_clos = (duk_hcompiledfunction *) duk_get_hcompiledfunction(ctx, -2);
71642 DUK_ASSERT(fun_clos != NULL);
71647
71651
71652 /* Note: all references inside 'data' need to get their refcounts
71653 * upped too. This is the case because refcounts are decreased
71654 * through every function referencing 'data' independently.
71655 */
71656
71658 duk__inc_data_inner_refcounts(thr, fun_temp);
71659
71660 fun_clos->nregs = fun_temp->nregs;
71661 fun_clos->nargs = fun_temp->nargs;
71662#if defined(DUK_USE_DEBUGGER_SUPPORT)
71663 fun_clos->start_line = fun_temp->start_line;
71664 fun_clos->end_line = fun_temp->end_line;
71665#endif
71666
71670
71671 /* XXX: could also copy from template, but there's no way to have any
71672 * other value here now (used code has no access to the template).
71673 */
71675
71676 /*
71677 * Init/assert flags, copying them where appropriate. Some flags
71678 * (like NEWENV) are processed separately below.
71679 */
71680
71681 /* XXX: copy flags using a mask */
71682
71684 DUK_HOBJECT_SET_CONSTRUCTABLE(&fun_clos->obj); /* Note: not set in template (has no "prototype") */
71686 DUK_ASSERT(!DUK_HOBJECT_HAS_BOUND(&fun_clos->obj));
71690 /* DUK_HOBJECT_FLAG_ARRAY_PART: don't care */
71691 if (DUK_HOBJECT_HAS_STRICT(&fun_temp->obj)) {
71692 DUK_HOBJECT_SET_STRICT(&fun_clos->obj);
71693 }
71694 if (DUK_HOBJECT_HAS_NOTAIL(&fun_temp->obj)) {
71695 DUK_HOBJECT_SET_NOTAIL(&fun_clos->obj);
71696 }
71697 /* DUK_HOBJECT_FLAG_NEWENV: handled below */
71698 if (DUK_HOBJECT_HAS_NAMEBINDING(&fun_temp->obj)) {
71699 /* Although NAMEBINDING is not directly needed for using
71700 * function instances, it's needed by bytecode dump/load
71701 * so copy it too.
71702 */
71703 DUK_HOBJECT_SET_NAMEBINDING(&fun_clos->obj);
71704 }
71705 if (DUK_HOBJECT_HAS_CREATEARGS(&fun_temp->obj)) {
71706 DUK_HOBJECT_SET_CREATEARGS(&fun_clos->obj);
71707 }
71711
71712 /*
71713 * Setup environment record properties based on the template and
71714 * its flags.
71715 *
71716 * If DUK_HOBJECT_HAS_NEWENV(fun_temp) is true, the environment
71717 * records represent identifiers "outside" the function; the
71718 * "inner" environment records are created on demand. Otherwise,
71719 * the environment records are those that will be directly used
71720 * (e.g. for declarations).
71721 *
71722 * _Lexenv is always set; _Varenv defaults to _Lexenv if missing,
71723 * so _Varenv is only set if _Lexenv != _Varenv.
71724 *
71725 * This is relatively complex, see doc/identifier-handling.rst.
71726 */
71727
71728 if (DUK_HOBJECT_HAS_NEWENV(&fun_temp->obj)) {
71729 DUK_HOBJECT_SET_NEWENV(&fun_clos->obj);
71730
71731 if (DUK_HOBJECT_HAS_NAMEBINDING(&fun_temp->obj)) {
71733
71734 /*
71735 * Named function expression, name needs to be bound
71736 * in an intermediate environment record. The "outer"
71737 * lexical/variable environment will thus be:
71738 *
71739 * a) { funcname: <func>, __prototype: outer_lex_env }
71740 * b) { funcname: <func>, __prototype: <globalenv> } (if outer_lex_env missing)
71741 */
71742
71743 DUK_ASSERT(duk_has_prop_stridx(ctx, -1, DUK_STRIDX_NAME)); /* required if NAMEBINDING set */
71744
71745 if (outer_lex_env) {
71746 proto = outer_lex_env;
71747 } else {
71749 }
71750
71751 /* -> [ ... closure template env ] */
71755 proto);
71756
71757 /* It's important that duk_xdef_prop() is a 'raw define' so that any
71758 * properties in an ancestor are never an issue (they should never be
71759 * e.g. non-writable, but just in case).
71760 */
71761 duk_get_prop_stridx(ctx, -2, DUK_STRIDX_NAME); /* -> [ ... closure template env funcname ] */
71762 duk_dup(ctx, -4); /* -> [ ... closure template env funcname closure ] */
71763 duk_xdef_prop(ctx, -3, DUK_PROPDESC_FLAGS_NONE); /* -> [ ... closure template env ] */
71764 /* env[funcname] = closure */
71765
71766 /* [ ... closure template env ] */
71767
71769 /* since closure has NEWENV, never define DUK_STRIDX_INT_VARENV, as it
71770 * will be ignored anyway
71771 */
71772
71773 /* [ ... closure template ] */
71774 } else {
71775 /*
71776 * Other cases (function declaration, anonymous function expression,
71777 * strict direct eval code). The "outer" environment will be whatever
71778 * the caller gave us.
71779 */
71780
71781 duk_push_hobject(ctx, outer_lex_env); /* -> [ ... closure template env ] */
71783 /* since closure has NEWENV, never define DUK_STRIDX_INT_VARENV, as it
71784 * will be ignored anyway
71785 */
71786
71787 /* [ ... closure template ] */
71788 }
71789 } else {
71790 /*
71791 * Function gets no new environment when called. This is the
71792 * case for global code, indirect eval code, and non-strict
71793 * direct eval code. There is no direct correspondence to the
71794 * E5 specification, as global/eval code is not exposed as a
71795 * function.
71796 */
71797
71799
71800 duk_push_hobject(ctx, outer_lex_env); /* -> [ ... closure template env ] */
71802
71803 if (outer_var_env != outer_lex_env) {
71804 duk_push_hobject(ctx, outer_var_env); /* -> [ ... closure template env ] */
71806 }
71807 }
71808#ifdef DUK_USE_DDDPRINT
71811 DUK_DDD(DUK_DDDPRINT("closure varenv -> %!ipT, lexenv -> %!ipT",
71812 (duk_tval *) duk_get_tval(ctx, -2),
71813 (duk_tval *) duk_get_tval(ctx, -1)));
71814 duk_pop_2(ctx);
71815#endif
71816
71817 /*
71818 * Copy some internal properties directly
71819 *
71820 * The properties will be writable and configurable, but not enumerable.
71821 */
71822
71823 /* [ ... closure template ] */
71824
71825 DUK_DDD(DUK_DDDPRINT("copying properties: closure=%!iT, template=%!iT",
71826 (duk_tval *) duk_get_tval(ctx, -2),
71827 (duk_tval *) duk_get_tval(ctx, -1)));
71828
71829 for (i = 0; i < (duk_small_uint_t) (sizeof(duk__closure_copy_proplist) / sizeof(duk_uint16_t)); i++) {
71831 if (duk_get_prop_stridx(ctx, -1, stridx)) {
71832 /* [ ... closure template val ] */
71833 DUK_DDD(DUK_DDDPRINT("copying property, stridx=%ld -> found", (long) stridx));
71835 } else {
71836 DUK_DDD(DUK_DDDPRINT("copying property, stridx=%ld -> not found", (long) stridx));
71837 duk_pop(ctx);
71838 }
71839 }
71840
71841 /*
71842 * "length" maps to number of formals (E5 Section 13.2) for function
71843 * declarations/expressions (non-bound functions). Note that 'nargs'
71844 * is NOT necessarily equal to the number of arguments.
71845 */
71846
71847 /* [ ... closure template ] */
71848
71849 len_value = 0;
71850
71851 /* XXX: use helper for size optimization */
71853 /* [ ... closure template formals ] */
71855 DUK_ASSERT(duk_get_length(ctx, -1) <= DUK_UINT_MAX); /* formal arg limits */
71856 len_value = (duk_uint_t) duk_get_length(ctx, -1);
71857 } else {
71858 /* XXX: what to do if _Formals is not empty but compiler has
71859 * optimized it away -- read length from an explicit property
71860 * then?
71861 */
71862 }
71863 duk_pop(ctx);
71864
71865 duk_push_uint(ctx, len_value); /* [ ... closure template len_value ] */
71867
71868 /*
71869 * "prototype" is, by default, a fresh object with the "constructor"
71870 * property.
71871 *
71872 * Note that this creates a circular reference for every function
71873 * instance (closure) which prevents refcount-based collection of
71874 * function instances.
71875 *
71876 * XXX: Try to avoid creating the default prototype object, because
71877 * many functions are not used as constructors and the default
71878 * prototype is unnecessary. Perhaps it could be created on-demand
71879 * when it is first accessed?
71880 */
71881
71882 /* [ ... closure template ] */
71883
71884 if (add_auto_proto) {
71885 duk_push_object(ctx); /* -> [ ... closure template newobj ] */
71886 duk_dup(ctx, -3); /* -> [ ... closure template newobj closure ] */
71887 duk_xdef_prop_stridx(ctx, -2, DUK_STRIDX_CONSTRUCTOR, DUK_PROPDESC_FLAGS_WC); /* -> [ ... closure template newobj ] */
71888 duk_compact(ctx, -1); /* compact the prototype */
71889 duk_xdef_prop_stridx(ctx, -3, DUK_STRIDX_PROTOTYPE, DUK_PROPDESC_FLAGS_W); /* -> [ ... closure template ] */
71890 }
71891
71892 /*
71893 * "arguments" and "caller" must be mapped to throwers for strict
71894 * mode and bound functions (E5 Section 15.3.5).
71895 *
71896 * XXX: This is expensive to have for every strict function instance.
71897 * Try to implement as virtual properties or on-demand created properties.
71898 */
71899
71900 /* [ ... closure template ] */
71901
71902 if (DUK_HOBJECT_HAS_STRICT(&fun_clos->obj)) {
71905 } else {
71906#ifdef DUK_USE_NONSTD_FUNC_CALLER_PROPERTY
71907 DUK_DDD(DUK_DDDPRINT("function is non-strict and non-standard 'caller' property in use, add initial 'null' value"));
71908 duk_push_null(ctx);
71910#else
71911 DUK_DDD(DUK_DDDPRINT("function is non-strict and non-standard 'caller' property not used"));
71912#endif
71913 }
71914
71915 /*
71916 * "name" is a non-standard property found in at least V8, Rhino, smjs.
71917 * For Rhino and smjs it is non-writable, non-enumerable, and non-configurable;
71918 * for V8 it is writable, non-enumerable, non-configurable. It is also defined
71919 * for an anonymous function expression in which case the value is an empty string.
71920 * We could also leave name 'undefined' for anonymous functions but that would
71921 * differ from behavior of other engines, so use an empty string.
71922 *
71923 * XXX: make optional? costs something per function.
71924 */
71925
71926 /* [ ... closure template ] */
71927
71928 if (duk_get_prop_stridx(ctx, -1, DUK_STRIDX_NAME)) {
71929 /* [ ... closure template name ] */
71930 DUK_ASSERT(duk_is_string(ctx, -1));
71931 } else {
71932 /* [ ... closure template undefined ] */
71933 duk_pop(ctx);
71935 }
71936 duk_xdef_prop_stridx(ctx, -3, DUK_STRIDX_NAME, DUK_PROPDESC_FLAGS_NONE); /* -> [ ... closure template ] */
71937
71938 /*
71939 * Compact the closure, in most cases no properties will be added later.
71940 * Also, without this the closures end up having unused property slots
71941 * (e.g. in Duktape 0.9.0, 8 slots would be allocated and only 7 used).
71942 * A better future solution would be to allocate the closure directly
71943 * to correct size (and setup the properties directly without going
71944 * through the API).
71945 */
71946
71947 duk_compact(ctx, -2);
71948
71949 /*
71950 * Some assertions (E5 Section 13.2).
71951 */
71952
71957 DUK_ASSERT(add_auto_proto == 0 || duk_has_prop_stridx(ctx, -2, DUK_STRIDX_PROTOTYPE) != 0);
71958 DUK_ASSERT(duk_has_prop_stridx(ctx, -2, DUK_STRIDX_NAME) != 0); /* non-standard */
71959 DUK_ASSERT(!DUK_HOBJECT_HAS_STRICT(&fun_clos->obj) ||
71960 duk_has_prop_stridx(ctx, -2, DUK_STRIDX_CALLER) != 0);
DUK_LOCAL const duk_uint16_t duk__closure_copy_proplist[]
#define DUK_HOBJECT_SET_CONSTRUCTABLE(h)
DUK_LOCAL void duk__inc_data_inner_refcounts(duk_hthread *thr, duk_hcompiledfunction *f)

References DUK_STRIDX_FILE_NAME, DUK_STRIDX_INT_FORMALS, DUK_STRIDX_INT_PC2LINE, DUK_STRIDX_INT_SOURCE, DUK_STRIDX_INT_VARMAP, and DUK_STRIDX_NAME.

◆ duk_js_putvar_activation()

DUK_INTERNAL_DECL void duk_js_putvar_activation ( duk_hthread * thr,
duk_activation * act,
duk_hstring * name,
duk_tval * val,
duk_bool_t strict )

Definition at line 72902 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_del_var().

◆ duk_js_putvar_envrec()

DUK_INTERNAL_DECL void duk_js_putvar_envrec ( duk_hthread * thr,
duk_hobject * env,
duk_hstring * name,
duk_tval * val,
duk_bool_t strict )

Definition at line 72893 of file duktape-1.8.0/src/duktape.c.

72893 {
72894 DUK_DDD(DUK_DDDPRINT("identifier binding not found, strict => reference error"));
72895 DUK_ERROR(thr, DUK_ERR_REFERENCE_ERROR, "identifier not defined");
72896 }
72897
72898 DUK_DDD(DUK_DDDPRINT("identifier binding not found, not strict => set to global"));
72899

References DUK_DDD, DUK_DDDPRINT, DUK_ERR_REFERENCE_ERROR, and DUK_ERROR.

Referenced by duk_hobject_define_property_helper().

◆ duk_js_string_compare()

DUK_INTERNAL_DECL duk_small_int_t duk_js_string_compare ( duk_hstring * h1,
duk_hstring * h2 )

Definition at line 70904 of file duktape-1.8.0/src/duktape.c.

70904 {
70905 return -1;
70906 } else if (rc > 0) {
70907 return 1;
70908 }
70909
70910 /* prefix matches, lengths matter now */
70911 if (len1 < len2) {
70912 /* e.g. "x" < "xx" */
70913 return -1;
70914 } else if (len1 > len2) {
70915 return 1;
70916 }
70917
70918 return 0;
70919}
70920
70922 /*
70923 * String comparison (E5 Section 11.8.5, step 4), which
70924 * needs to compare codepoint by codepoint.
70925 *

◆ duk_js_to_arrayindex_raw_string()

DUK_INTERNAL_DECL duk_small_int_t duk_js_to_arrayindex_raw_string ( const duk_uint8_t * str,
duk_uint32_t blen,
duk_uarridx_t * out_idx )

Definition at line 71414 of file duktape-1.8.0/src/duktape.c.

71431 {
71432 duk_uarridx_t res;
71433
71434 if (blen == 0 || blen > 10) {
71435 goto parse_fail;
71436 }
71437 if (str[0] == DUK_ASC_0 && blen > 1) {
71438 goto parse_fail;
71439 }
71440
71441 /* Accept 32-bit decimal integers, no leading zeroes, signs, etc.
71442 * Leading zeroes are not accepted (zero index "0" is an exception
71443 * handled above).
71444 */
71445
71446 res = 0;
71447 while (blen-- > 0) {
71448 duk_uint8_t c = *str++;
71449 if (c >= DUK_ASC_0 && c <= DUK_ASC_9) {
71450 /* Careful overflow handling. When multiplying by 10:
71451 * - 0x19999998 x 10 = 0xfffffff0: no overflow, and adding
71452 * 0...9 is safe.
71453 * - 0x19999999 x 10 = 0xfffffffa: no overflow, adding
71454 * 0...5 is safe, 6...9 overflows.
71455 * - 0x1999999a x 10 = 0x100000004: always overflow.
71456 */
71457 if (DUK_UNLIKELY(res >= 0x19999999UL)) {
71458 if (res >= 0x1999999aUL) {
71459 /* Always overflow. */
71460 goto parse_fail;
71461 }
71462 DUK_ASSERT(res == 0x19999999UL);
71463 c -= DUK_ASC_0;
71464 if (c >= 6) {
71465 goto parse_fail;
71466 }
71467 res = 0xfffffffaUL + c;

Referenced by duk__alloc_init_hstring().

◆ duk_js_to_arrayindex_string_helper()

DUK_INTERNAL_DECL duk_uarridx_t duk_js_to_arrayindex_string_helper ( duk_hstring * h)

Definition at line 71470 of file duktape-1.8.0/src/duktape.c.

71470 {
71471 res = res * 10U + (duk_uint32_t) (c - DUK_ASC_0);
71472 }
71473 } else {
71474 goto parse_fail;
71475 }
71476 }
71477
71478 *out_idx = res;
71479 return 1;
71480
71481 parse_fail:
71482 *out_idx = DUK_HSTRING_NO_ARRAY_INDEX;
71483 return 0;
71484}

◆ duk_js_toboolean()

DUK_INTERNAL_DECL duk_bool_t duk_js_toboolean ( duk_tval * tv)

Definition at line 70162 of file duktape-1.8.0/src/duktape.c.

70179 {
70180 switch (DUK_TVAL_GET_TAG(tv)) {
70181 case DUK_TAG_UNDEFINED:
70182 case DUK_TAG_NULL:
70183 return 0;
70184 case DUK_TAG_BOOLEAN:
70185 return DUK_TVAL_GET_BOOLEAN(tv);
70186 case DUK_TAG_STRING: {
70188 DUK_ASSERT(h != NULL);
70189 return (DUK_HSTRING_GET_BYTELEN(h) > 0 ? 1 : 0);
70190 }
70191 case DUK_TAG_OBJECT: {
70192 return 1;
70193 }
70194 case DUK_TAG_BUFFER: {
70195 /* mimic semantics for strings */
70197 DUK_ASSERT(h != NULL);
70198 return (DUK_HBUFFER_GET_SIZE(h) > 0 ? 1 : 0);
70199 }
70200 case DUK_TAG_POINTER: {
70201 void *p = DUK_TVAL_GET_POINTER(tv);
70202 return (p != NULL ? 1 : 0);
70203 }
70204 case DUK_TAG_LIGHTFUNC: {
70205 return 1;
70206 }
70207#if defined(DUK_USE_FASTINT)
70208 case DUK_TAG_FASTINT:
70209 if (DUK_TVAL_GET_FASTINT(tv) != 0) {
70210 return 1;
70211 } else {
70212 return 0;
70213 }
70214#endif

References DUK_ASSERT, DUK_FP_NAN, DUK_FP_ZERO, DUK_FPCLASSIFY, DUK_HBUFFER_GET_SIZE, DUK_HSTRING_GET_BYTELEN, DUK_TAG_BOOLEAN, DUK_TAG_BUFFER, DUK_TAG_LIGHTFUNC, DUK_TAG_NULL, DUK_TAG_OBJECT, DUK_TAG_POINTER, DUK_TAG_STRING, DUK_TAG_UNDEFINED, DUK_TVAL_GET_BOOLEAN, DUK_TVAL_GET_BUFFER, DUK_TVAL_GET_DOUBLE, DUK_TVAL_GET_POINTER, DUK_TVAL_GET_STRING, DUK_TVAL_GET_TAG, DUK_TVAL_IS_DOUBLE, DUK_TVAL_IS_UNUSED, DUK_UNREACHABLE, and NULL.

◆ duk_js_toint32()

DUK_INTERNAL_DECL duk_int32_t duk_js_toint32 ( duk_hthread * thr,
duk_tval * tv )

Definition at line 70424 of file duktape-1.8.0/src/duktape.c.

70425 {
70426 x += DUK_DOUBLE_2TO32;
70427 }
70428 /* -> x in [0, 2**32[ */
70429
70430 if (is_toint32) {
70431 if (x >= DUK_DOUBLE_2TO31) {
70432 /* x in [2**31, 2**32[ */
70433
70434 x -= DUK_DOUBLE_2TO32; /* -> x in [-2**31,2**31[ */
70435 }
70436 }
70437
70438 return x;
70439}

References DUK_DOUBLE_2TO32.

Referenced by duk_to_uint32().

◆ duk_js_tointeger()

DUK_INTERNAL_DECL duk_double_t duk_js_tointeger ( duk_hthread * thr,
duk_tval * tv )

Definition at line 70375 of file duktape-1.8.0/src/duktape.c.

70375 {
70376 return 0.0;
70377 } else if (c == DUK_FP_ZERO || c == DUK_FP_INFINITE) {
70378 /* XXX: FP_ZERO check can be removed, the else clause handles it
70379 * correctly (preserving sign).

◆ duk_js_tointeger_number()

DUK_INTERNAL_DECL duk_double_t duk_js_tointeger_number ( duk_double_t x)

Definition at line 70355 of file duktape-1.8.0/src/duktape.c.

70356 : {
70357 /* number */
70360 return DUK_TVAL_GET_DOUBLE(tv);
70361 }
70362 }
70363
70365}
70366
70367/*
70368 * ToInteger() (E5 Section 9.4)
70369 */
70370
70371/* exposed, used by e.g. duk_bi_date.c */

References DUK_ASSERT, DUK_TVAL_GET_DOUBLE, DUK_TVAL_IS_DOUBLE, and DUK_TVAL_IS_UNUSED.

Referenced by duk__div_floor().

◆ duk_js_tonumber()

DUK_INTERNAL_DECL duk_double_t duk_js_tonumber ( duk_hthread * thr,
duk_tval * tv )

Definition at line 70272 of file duktape-1.8.0/src/duktape.c.

70289 {
70290 duk_context *ctx = (duk_hthread *) thr;
70291
70292 DUK_ASSERT(thr != NULL);
70293 DUK_ASSERT(tv != NULL);
70294
70295 switch (DUK_TVAL_GET_TAG(tv)) {
70296 case DUK_TAG_UNDEFINED: {
70297 /* return a specific NaN (although not strictly necessary) */
70301 return du.d;
70302 }
70303 case DUK_TAG_NULL: {
70304 /* +0.0 */
70305 return 0.0;
70306 }
70307 case DUK_TAG_BOOLEAN: {
70308 if (DUK_TVAL_IS_BOOLEAN_TRUE(tv)) {
70309 return 1.0;
70310 }
70311 return 0.0;
70312 }
70313 case DUK_TAG_STRING: {
70315 duk_push_hstring(ctx, h);
70316 return duk__tonumber_string_raw(thr);
70317 }
70318 case DUK_TAG_OBJECT: {
70319 /* Note: ToPrimitive(object,hint) == [[DefaultValue]](object,hint),
70320 * so use [[DefaultValue]] directly.
70321 */
70322 duk_double_t d;
70323 duk_push_tval(ctx, tv);
70324 duk_to_defaultvalue(ctx, -1, DUK_HINT_NUMBER); /* 'tv' becomes invalid */
70325
70326 /* recursive call for a primitive value (guaranteed not to cause second
70327 * recursion).
70328 */
70329 d = duk_js_tonumber(thr, duk_require_tval(ctx, -1));
70330
70331 duk_pop(ctx);
70332 return d;
70333 }
70334 case DUK_TAG_BUFFER: {
70335 /* Coerce like a string. This makes sense because addition also treats
70336 * buffers like strings.
70337 */
70339 duk_push_hbuffer(ctx, h);
70340 duk_to_string(ctx, -1); /* XXX: expensive, but numconv now expects to see a string */
70341 return duk__tonumber_string_raw(thr);
70342 }
70343 case DUK_TAG_POINTER: {
70344 /* Coerce like boolean */
70345 void *p = DUK_TVAL_GET_POINTER(tv);
70346 return (p != NULL ? 1.0 : 0.0);
70347 }
70348 case DUK_TAG_LIGHTFUNC: {
#define DUK_DBLUNION_SET_NAN(u)
DUK_LOCAL duk_double_t duk__tonumber_string_raw(duk_hthread *thr)
#define DUK_TVAL_IS_BOOLEAN_TRUE(tv)
DUK_EXTERNAL void duk_to_defaultvalue(duk_context *ctx, duk_idx_t index, duk_int_t hint)

◆ duk_js_touint16()

DUK_INTERNAL_DECL duk_uint16_t duk_js_touint16 ( duk_hthread * thr,
duk_tval * tv )

Definition at line 70460 of file duktape-1.8.0/src/duktape.c.

70463 {

◆ duk_js_touint32()

DUK_INTERNAL_DECL duk_uint32_t duk_js_touint32 ( duk_hthread * thr,
duk_tval * tv )

Definition at line 70442 of file duktape-1.8.0/src/duktape.c.

70445 {
70446 return DUK_TVAL_GET_FASTINT_I32(tv);
70447 }
70448#endif
70449
70450 d = duk_js_tonumber(thr, tv); /* invalidates tv */
70453 DUK_ASSERT(d >= -2147483648.0 && d <= 2147483647.0); /* [-0x80000000,0x7fffffff] */
70454 DUK_ASSERT(d == ((duk_double_t) ((duk_int32_t) d))); /* whole, won't clip */
70455 return (duk_int32_t) d;
70456}
70457
70458

Referenced by duk_to_uint16().

◆ duk_js_typeof()

DUK_INTERNAL_DECL duk_hstring * duk_js_typeof ( duk_hthread * thr,
duk_tval * tv_x )

Definition at line 71341 of file duktape-1.8.0/src/duktape.c.

71358 {
71359 duk_small_int_t stridx = 0;
71360
71361 DUK_UNREF(thr);
71362
71363 switch (DUK_TVAL_GET_TAG(tv_x)) {
71364 case DUK_TAG_UNDEFINED: {
71365 stridx = DUK_STRIDX_LC_UNDEFINED;
71366 break;
71367 }
71368 case DUK_TAG_NULL: {
71369 /* Note: not a typo, "object" is returned for a null value */
71370 stridx = DUK_STRIDX_LC_OBJECT;
71371 break;
71372 }
71373 case DUK_TAG_BOOLEAN: {
71374 stridx = DUK_STRIDX_LC_BOOLEAN;
71375 break;
71376 }
71377 case DUK_TAG_POINTER: {
71378 /* implementation specific */
71379 stridx = DUK_STRIDX_LC_POINTER;
71380 break;
71381 }
71382 case DUK_TAG_STRING: {
71383 stridx = DUK_STRIDX_LC_STRING;
71384 break;
71385 }
71386 case DUK_TAG_OBJECT: {
71387 duk_hobject *obj = DUK_TVAL_GET_OBJECT(tv_x);
71388 DUK_ASSERT(obj != NULL);
71389 if (DUK_HOBJECT_IS_CALLABLE(obj)) {
71390 stridx = DUK_STRIDX_LC_FUNCTION;
71391 } else {
71392 stridx = DUK_STRIDX_LC_OBJECT;
71393 }
71394 break;
71395 }
71396 case DUK_TAG_BUFFER: {
71397 /* implementation specific */
71398 stridx = DUK_STRIDX_LC_BUFFER;
71399 break;
71400 }
71401 case DUK_TAG_LIGHTFUNC: {
71402 stridx = DUK_STRIDX_LC_FUNCTION;
#define DUK_STRIDX_LC_POINTER
#define DUK_STRIDX_LC_FUNCTION
#define DUK_STRIDX_LC_BOOLEAN
#define DUK_STRIDX_LC_STRING
#define DUK_STRIDX_LC_OBJECT

◆ duk_json_decode()

DUK_EXTERNAL void duk_json_decode ( duk_context * ctx,
duk_idx_t index )

Definition at line 13563 of file duktape-1.8.0/src/duktape.c.

13580 {
13581#ifdef DUK_USE_ASSERTIONS

◆ duk_json_encode()

DUK_EXTERNAL const char * duk_json_encode ( duk_context * ctx,
duk_idx_t index )

Definition at line 13537 of file duktape-1.8.0/src/duktape.c.

13540 {
13541 goto type_error;
13542 }
13543 buf[i >> 1] = (duk_uint8_t) t;
13544 }
13545#endif /* DUK_USE_HEX_FASTPATH */
13546
13547 duk_replace(ctx, index);
13548 return;
13549
13550 type_error:
13552}
13553
13555#ifdef DUK_USE_ASSERTIONS
13556 duk_idx_t top_at_entry;
13557#endif
13558 const char *ret;
13559
13561#ifdef DUK_USE_ASSERTIONS
DUK_EXTERNAL const char * duk_json_encode(duk_context *ctx, duk_idx_t index)

◆ duk_lexer_initctx()

DUK_INTERNAL_DECL void duk_lexer_initctx ( duk_lexer_ctx * lex_ctx)

Definition at line 73879 of file duktape-1.8.0/src/duktape.c.

73883 {
73884 duk_context *ctx = (duk_context *) lex_ctx->thr;
73885
73886 DUK_ASSERT(valstack_idx == lex_ctx->slot1_idx || valstack_idx == lex_ctx->slot2_idx);
73887
73888 DUK_BW_PUSH_AS_STRING(lex_ctx->thr, &lex_ctx->bw);
73889 duk_replace(ctx, valstack_idx);
73890}
73891
#define DUK_BW_PUSH_AS_STRING(thr, bw_ctx)

References duk_lexer_ctx::bw, DUK_ASSERT, DUK_BW_PUSH_AS_STRING, duk_replace(), duk_lexer_ctx::slot1_idx, duk_lexer_ctx::slot2_idx, and duk_lexer_ctx::thr.

◆ duk_lexer_parse_js_input_element()

DUK_INTERNAL_DECL void duk_lexer_parse_js_input_element ( duk_lexer_ctx * lex_ctx,
duk_token * out_token,
duk_bool_t strict_mode,
duk_bool_t regexp_mode )

Definition at line 74017 of file duktape-1.8.0/src/duktape.c.

74037 {
74038 duk_codepoint_t x; /* temporary, must be signed and 32-bit to hold Unicode code points */
74039 duk_small_uint_t advtok = 0; /* (advance << 8) + token_type, updated at function end,
74040 * init is unnecessary but suppresses "may be used uninitialized" warnings.
74041 */
74042 duk_bool_t got_lineterm = 0; /* got lineterm preceding non-whitespace, non-lineterm token */
74043
74044 if (++lex_ctx->token_count >= lex_ctx->token_limit) {
74045 DUK_ERROR_RANGE(lex_ctx->thr, "token limit");
74046 return; /* unreachable */
74047 }
74048
74049 out_token->t = DUK_TOK_EOF;
74050 out_token->t_nores = -1; /* marker: copy t if not changed */
74051#if 0 /* not necessary to init, disabled for faster parsing */
74052 out_token->num = DUK_DOUBLE_NAN;
74053 out_token->str1 = NULL;
74054 out_token->str2 = NULL;
74055#endif
74056 out_token->num_escapes = 0;
74057 /* out_token->lineterm set by caller */
74058
74059 /* This would be nice, but parsing is faster without resetting the
74060 * value slots. The only side effect is that references to temporary
74061 * string values may linger until lexing is finished; they're then
74062 * freed normally.
74063 */
74064#if 0
74065 duk_to_undefined((duk_context *) lex_ctx->thr, lex_ctx->slot1_idx);
74066 duk_to_undefined((duk_context *) lex_ctx->thr, lex_ctx->slot2_idx);
74067#endif
74068
74069 /* 'advtok' indicates how much to advance and which token id to assign
74070 * at the end. This shared functionality minimizes code size. All
74071 * code paths are required to set 'advtok' to some value, so no default
74072 * init value is used. Code paths calling DUK_ERROR() never return so
74073 * they don't need to set advtok.
74074 */
74075
74076 /*
74077 * Matching order:
74078 *
74079 * Punctuator first chars, also covers comments, regexps
74080 * LineTerminator
74081 * Identifier or reserved word, also covers null/true/false literals
74082 * NumericLiteral
74083 * StringLiteral
74084 * EOF
74085 *
74086 * The order does not matter as long as the longest match is
74087 * always correctly identified. There are order dependencies
74088 * in the clauses, so it's not trivial to convert to a switch.
74089 */
74090
74091 restart_lineupdate:
74092 out_token->start_line = lex_ctx->window[0].line;
74093
74094 restart:
74095 out_token->start_offset = lex_ctx->window[0].offset;
74096
74097 x = DUK__L0();
74098
74099 switch (x) {
74100 case DUK_ASC_SPACE:
74101 case DUK_ASC_HT: /* fast paths for space and tab */
74102 DUK__ADVANCECHARS(lex_ctx, 1);
74103 goto restart;
74104 case DUK_ASC_LF: /* LF line terminator; CR LF and Unicode lineterms are handled in slow path */
74105 DUK__ADVANCECHARS(lex_ctx, 1);
74106 got_lineterm = 1;
74107 goto restart_lineupdate;
74108 case DUK_ASC_SLASH: /* '/' */
74109 if (DUK__L1() == '/') {
74110 /*
74111 * E5 Section 7.4, allow SourceCharacter (which is any 16-bit
74112 * code point).
74113 */
74114
74115 /* DUK__ADVANCECHARS(lex_ctx, 2) would be correct here, but it unnecessary */
74116 for (;;) {
74117 x = DUK__L0();
74118 if (x < 0 || duk_unicode_is_line_terminator(x)) {
74119 break;
74120 }
74121 DUK__ADVANCECHARS(lex_ctx, 1);
74122 }
74123 goto restart; /* line terminator will be handled on next round */
74124 } else if (DUK__L1() == '*') {
74125 /*
74126 * E5 Section 7.4. If the multi-line comment contains a newline,
74127 * it is treated like a single line terminator for automatic
74128 * semicolon insertion.
74129 */
74130
74131 duk_bool_t last_asterisk = 0;
74132 DUK__ADVANCECHARS(lex_ctx, 2);
74133 for (;;) {
74134 x = DUK__L0();
74135 if (x < 0) {
74136 DUK_ERROR_SYNTAX(lex_ctx->thr, "eof in multiline comment");
74137 }
74138 DUK__ADVANCECHARS(lex_ctx, 1);
74139 if (last_asterisk && x == '/') {
74140 break;
74141 }
74143 got_lineterm = 1;
74144 }
74145 last_asterisk = (x == '*');
74146 }
74147 goto restart_lineupdate;
74148 } else if (regexp_mode) {
74149#if defined(DUK_USE_REGEXP_SUPPORT)
74150 /*
74151 * "/" followed by something in regexp mode. See E5 Section 7.8.5.
74152 *
74153 * RegExp parsing is a bit complex. First, the regexp body is delimited
74154 * by forward slashes, but the body may also contain forward slashes as
74155 * part of an escape sequence or inside a character class (delimited by
74156 * square brackets). A mini state machine is used to implement these.
74157 *
74158 * Further, an early (parse time) error must be thrown if the regexp
74159 * would cause a run-time error when used in the expression new RegExp(...).
74160 * Parsing here simply extracts the (candidate) regexp, and also accepts
74161 * invalid regular expressions (which are delimited properly). The caller
74162 * (compiler) must perform final validation and regexp compilation.
74163 *
74164 * RegExp first char may not be '/' (single line comment) or '*' (multi-
74165 * line comment). These have already been checked above, so there is no
74166 * need below for special handling of the first regexp character as in
74167 * the E5 productions.
74168 *
74169 * About unicode escapes within regexp literals:
74170 *
74171 * E5 Section 7.8.5 grammar does NOT accept \uHHHH escapes.
74172 * However, Section 6 states that regexps accept the escapes,
74173 * see paragraph starting with "In string literals...".
74174 * The regexp grammar, which sees the decoded regexp literal
74175 * (after lexical parsing) DOES have a \uHHHH unicode escape.
74176 * So, for instance:
74177 *
74178 * /\u1234/
74179 *
74180 * should first be parsed by the lexical grammar as:
74181 *
74182 * '\' 'u' RegularExpressionBackslashSequence
74183 * '1' RegularExpressionNonTerminator
74184 * '2' RegularExpressionNonTerminator
74185 * '3' RegularExpressionNonTerminator
74186 * '4' RegularExpressionNonTerminator
74187 *
74188 * and the escape itself is then parsed by the regexp engine.
74189 * This is the current implementation.
74190 *
74191 * Minor spec inconsistency:
74192 *
74193 * E5 Section 7.8.5 RegularExpressionBackslashSequence is:
74194 *
74195 * \ RegularExpressionNonTerminator
74196 *
74197 * while Section A.1 RegularExpressionBackslashSequence is:
74198 *
74199 * \ NonTerminator
74200 *
74201 * The latter is not normative and a typo.
74202 *
74203 */
74204
74205 /* first, parse regexp body roughly */
74206
74207 duk_small_int_t state = 0; /* 0=base, 1=esc, 2=class, 3=class+esc */
74208
74209 DUK__INITBUFFER(lex_ctx);
74210 for (;;) {
74211 DUK__ADVANCECHARS(lex_ctx, 1); /* skip opening slash on first loop */
74212 x = DUK__L0();
74213 if (x < 0 || duk_unicode_is_line_terminator(x)) {
74214 DUK_ERROR_SYNTAX(lex_ctx->thr, "eof or line terminator in regexp");
74215 }
74216 x = DUK__L0(); /* re-read to avoid spill / fetch */
74217 if (state == 0) {
74218 if (x == '/') {
74219 DUK__ADVANCECHARS(lex_ctx, 1); /* eat closing slash */
74220 break;
74221 } else if (x == '\\') {
74222 state = 1;
74223 } else if (x == '[') {
74224 state = 2;
74225 }
74226 } else if (state == 1) {
74227 state = 0;
74228 } else if (state == 2) {
74229 if (x == ']') {
74230 state = 0;
74231 } else if (x == '\\') {
74232 state = 3;
74233 }
74234 } else { /* state == 3 */
74235 state = 2;
74236 }
74237 DUK__APPENDBUFFER(lex_ctx, x);
74238 }
74239 duk__internbuffer(lex_ctx, lex_ctx->slot1_idx);
74240 out_token->str1 = duk_get_hstring((duk_context *) lex_ctx->thr, lex_ctx->slot1_idx);
74241
74242 /* second, parse flags */
74243
74244 DUK__INITBUFFER(lex_ctx);
74245 for (;;) {
74246 x = DUK__L0();
74248 break;
74249 }
74250 x = DUK__L0(); /* re-read to avoid spill / fetch */
74251 DUK__APPENDBUFFER(lex_ctx, x);
74252 DUK__ADVANCECHARS(lex_ctx, 1);
74253 }
74254 duk__internbuffer(lex_ctx, lex_ctx->slot2_idx);
74255 out_token->str2 = duk_get_hstring((duk_context *) lex_ctx->thr, lex_ctx->slot2_idx);
74256
74257 DUK__INITBUFFER(lex_ctx); /* free some memory */
74258
74259 /* validation of the regexp is caller's responsibility */
74260
74261 advtok = DUK__ADVTOK(0, DUK_TOK_REGEXP);
74262#else
74263 DUK_ERROR_SYNTAX(lex_ctx->thr, "regexp support disabled");
74264#endif
74265 } else if (DUK__L1() == '=') {
74266 /* "/=" and not in regexp mode */
74267 advtok = DUK__ADVTOK(2, DUK_TOK_DIV_EQ);
74268 } else {
74269 /* "/" and not in regexp mode */
74270 advtok = DUK__ADVTOK(1, DUK_TOK_DIV);
74271 }
74272 break;
74273 case DUK_ASC_LCURLY: /* '{' */
74274 advtok = DUK__ADVTOK(1, DUK_TOK_LCURLY);
74275 break;
74276 case DUK_ASC_RCURLY: /* '}' */
74277 advtok = DUK__ADVTOK(1, DUK_TOK_RCURLY);
74278 break;
74279 case DUK_ASC_LPAREN: /* '(' */
74280 advtok = DUK__ADVTOK(1, DUK_TOK_LPAREN);
74281 break;
74282 case DUK_ASC_RPAREN: /* ')' */
74283 advtok = DUK__ADVTOK(1, DUK_TOK_RPAREN);
74284 break;
74285 case DUK_ASC_LBRACKET: /* '[' */
74286 advtok = DUK__ADVTOK(1, DUK_TOK_LBRACKET);
74287 break;
74288 case DUK_ASC_RBRACKET: /* ']' */
74289 advtok = DUK__ADVTOK(1, DUK_TOK_RBRACKET);
74290 break;
74291 case DUK_ASC_PERIOD: /* '.' */
74292 if (DUK__ISDIGIT(DUK__L1())) {
74293 /* Period followed by a digit can only start DecimalLiteral
74294 * (handled in slow path). We could jump straight into the
74295 * DecimalLiteral handling but should avoid goto to inside
74296 * a block.
74297 */
74298 goto slow_path;
74299 }
74300 advtok = DUK__ADVTOK(1, DUK_TOK_PERIOD);
74301 break;
74302 case DUK_ASC_SEMICOLON: /* ';' */
74303 advtok = DUK__ADVTOK(1, DUK_TOK_SEMICOLON);
74304 break;
74305 case DUK_ASC_COMMA: /* ',' */
74306 advtok = DUK__ADVTOK(1, DUK_TOK_COMMA);
74307 break;
74308 case DUK_ASC_LANGLE: /* '<' */
74309 if (DUK__L1() == '<' && DUK__L2() == '=') {
74310 advtok = DUK__ADVTOK(3, DUK_TOK_ALSHIFT_EQ);
74311 } else if (DUK__L1() == '=') {
74312 advtok = DUK__ADVTOK(2, DUK_TOK_LE);
74313 } else if (DUK__L1() == '<') {
74314 advtok = DUK__ADVTOK(2, DUK_TOK_ALSHIFT);
74315 } else {
74316 advtok = DUK__ADVTOK(1, DUK_TOK_LT);
74317 }
74318 break;
74319 case DUK_ASC_RANGLE: /* '>' */
74320 if (DUK__L1() == '>' && DUK__L2() == '>' && DUK__L3() == '=') {
74321 advtok = DUK__ADVTOK(4, DUK_TOK_RSHIFT_EQ);
74322 } else if (DUK__L1() == '>' && DUK__L2() == '>') {
74323 advtok = DUK__ADVTOK(3, DUK_TOK_RSHIFT);
74324 } else if (DUK__L1() == '>' && DUK__L2() == '=') {
74325 advtok = DUK__ADVTOK(3, DUK_TOK_ARSHIFT_EQ);
74326 } else if (DUK__L1() == '=') {
74327 advtok = DUK__ADVTOK(2, DUK_TOK_GE);
74328 } else if (DUK__L1() == '>') {
74329 advtok = DUK__ADVTOK(2, DUK_TOK_ARSHIFT);
74330 } else {
74331 advtok = DUK__ADVTOK(1, DUK_TOK_GT);
74332 }
74333 break;
74334 case DUK_ASC_EQUALS: /* '=' */
74335 if (DUK__L1() == '=' && DUK__L2() == '=') {
74336 advtok = DUK__ADVTOK(3, DUK_TOK_SEQ);
74337 } else if (DUK__L1() == '=') {
74338 advtok = DUK__ADVTOK(2, DUK_TOK_EQ);
74339 } else {
74340 advtok = DUK__ADVTOK(1, DUK_TOK_EQUALSIGN);
74341 }
74342 break;
74343 case DUK_ASC_EXCLAMATION: /* '!' */
74344 if (DUK__L1() == '=' && DUK__L2() == '=') {
74345 advtok = DUK__ADVTOK(3, DUK_TOK_SNEQ);
74346 } else if (DUK__L1() == '=') {
74347 advtok = DUK__ADVTOK(2, DUK_TOK_NEQ);
74348 } else {
74349 advtok = DUK__ADVTOK(1, DUK_TOK_LNOT);
74350 }
74351 break;
74352 case DUK_ASC_PLUS: /* '+' */
74353 if (DUK__L1() == '+') {
74354 advtok = DUK__ADVTOK(2, DUK_TOK_INCREMENT);
74355 } else if (DUK__L1() == '=') {
74356 advtok = DUK__ADVTOK(2, DUK_TOK_ADD_EQ);
74357 } else {
74358 advtok = DUK__ADVTOK(1, DUK_TOK_ADD);
74359 }
74360 break;
74361 case DUK_ASC_MINUS: /* '-' */
74362 if (DUK__L1() == '-') {
74363 advtok = DUK__ADVTOK(2, DUK_TOK_DECREMENT);
74364 } else if (DUK__L1() == '=') {
74365 advtok = DUK__ADVTOK(2, DUK_TOK_SUB_EQ);
74366 } else {
74367 advtok = DUK__ADVTOK(1, DUK_TOK_SUB);
74368 }
74369 break;
74370 case DUK_ASC_STAR: /* '*' */
74371 if (DUK__L1() == '=') {
74372 advtok = DUK__ADVTOK(2, DUK_TOK_MUL_EQ);
74373 } else {
74374 advtok = DUK__ADVTOK(1, DUK_TOK_MUL);
74375 }
74376 break;
74377 case DUK_ASC_PERCENT: /* '%' */
74378 if (DUK__L1() == '=') {
74379 advtok = DUK__ADVTOK(2, DUK_TOK_MOD_EQ);
74380 } else {
74381 advtok = DUK__ADVTOK(1, DUK_TOK_MOD);
74382 }
74383 break;
74384 case DUK_ASC_AMP: /* '&' */
74385 if (DUK__L1() == '&') {
74386 advtok = DUK__ADVTOK(2, DUK_TOK_LAND);
74387 } else if (DUK__L1() == '=') {
74388 advtok = DUK__ADVTOK(2, DUK_TOK_BAND_EQ);
74389 } else {
74390 advtok = DUK__ADVTOK(1, DUK_TOK_BAND);
74391 }
74392 break;
74393 case DUK_ASC_PIPE: /* '|' */
74394 if (DUK__L1() == '|') {
74395 advtok = DUK__ADVTOK(2, DUK_TOK_LOR);
74396 } else if (DUK__L1() == '=') {
74397 advtok = DUK__ADVTOK(2, DUK_TOK_BOR_EQ);
74398 } else {
74399 advtok = DUK__ADVTOK(1, DUK_TOK_BOR);
74400 }
74401 break;
74402 case DUK_ASC_CARET: /* '^' */
74403 if (DUK__L1() == '=') {
74404 advtok = DUK__ADVTOK(2, DUK_TOK_BXOR_EQ);
74405 } else {
74406 advtok = DUK__ADVTOK(1, DUK_TOK_BXOR);
74407 }
74408 break;
74409 case DUK_ASC_TILDE: /* '~' */
74410 advtok = DUK__ADVTOK(1, DUK_TOK_BNOT);
74411 break;
74412 case DUK_ASC_QUESTION: /* '?' */
74413 advtok = DUK__ADVTOK(1, DUK_TOK_QUESTION);
74414 break;
74415 case DUK_ASC_COLON: /* ':' */
74416 advtok = DUK__ADVTOK(1, DUK_TOK_COLON);
74417 break;
74418 case DUK_ASC_DOUBLEQUOTE: /* '"' */
74419 case DUK_ASC_SINGLEQUOTE: { /* '\'' */
74420 duk_small_int_t quote = x; /* Note: duk_uint8_t type yields larger code */
74421 duk_small_int_t adv;
74422
74423 DUK__INITBUFFER(lex_ctx);
74424 for (;;) {
74425 DUK__ADVANCECHARS(lex_ctx, 1); /* eat opening quote on first loop */
74426 x = DUK__L0();
74427 if (x < 0 || duk_unicode_is_line_terminator(x)) {
74428 DUK_ERROR_SYNTAX(lex_ctx->thr, "eof or line terminator in string literal");
74429 }
74430 if (x == quote) {
74431 DUK__ADVANCECHARS(lex_ctx, 1); /* eat closing quote */
74432 break;
74433 }
74434 if (x == '\\') {
74435 /* DUK__L0 -> '\' char
74436 * DUK__L1 ... DUK__L5 -> more lookup
74437 */
74438
74439 x = DUK__L1();
74440
74441 /* How much to advance before next loop; note that next loop
74442 * will advance by 1 anyway, so -1 from the total escape
74443 * length (e.g. len('\uXXXX') - 1 = 6 - 1). As a default,
74444 * 1 is good.
74445 */
74446 adv = 2 - 1; /* note: long live range */
74447
74448 if (x < 0) {
74449 DUK_ERROR_SYNTAX(lex_ctx->thr, "eof or line terminator in string literal");
74450 }
74452 /* line continuation */
74453 if (x == 0x000d && DUK__L2() == 0x000a) {
74454 /* CR LF again a special case */
74455 adv = 3 - 1;
74456 }
74457 } else if (x == '\'') {
74458 DUK__APPENDBUFFER(lex_ctx, 0x0027);
74459 } else if (x == '"') {
74460 DUK__APPENDBUFFER(lex_ctx, 0x0022);
74461 } else if (x == '\\') {
74462 DUK__APPENDBUFFER(lex_ctx, 0x005c);
74463 } else if (x == 'b') {
74464 DUK__APPENDBUFFER(lex_ctx, 0x0008);
74465 } else if (x == 'f') {
74466 DUK__APPENDBUFFER(lex_ctx, 0x000c);
74467 } else if (x == 'n') {
74468 DUK__APPENDBUFFER(lex_ctx, 0x000a);
74469 } else if (x == 'r') {
74470 DUK__APPENDBUFFER(lex_ctx, 0x000d);
74471 } else if (x == 't') {
74472 DUK__APPENDBUFFER(lex_ctx, 0x0009);
74473 } else if (x == 'v') {
74474 DUK__APPENDBUFFER(lex_ctx, 0x000b);
74475 } else if (x == 'x') {
74476 adv = 4 - 1;
74478 } else if (x == 'u') {
74479 adv = 6 - 1;
74481 } else if (DUK__ISDIGIT(x)) {
74482 duk_codepoint_t ch = 0; /* initialized to avoid warnings of unused var */
74483
74484 /*
74485 * Octal escape or zero escape:
74486 * \0 (lookahead not DecimalDigit)
74487 * \1 ... \7 (lookahead not DecimalDigit)
74488 * \ZeroToThree OctalDigit (lookahead not DecimalDigit)
74489 * \FourToSeven OctalDigit (no lookahead restrictions)
74490 * \ZeroToThree OctalDigit OctalDigit (no lookahead restrictions)
74491 *
74492 * Zero escape is part of the standard syntax. Octal escapes are
74493 * defined in E5 Section B.1.2, and are only allowed in non-strict mode.
74494 * Any other productions starting with a decimal digit are invalid.
74495 */
74496
74497 if (x == '0' && !DUK__ISDIGIT(DUK__L2())) {
74498 /* Zero escape (also allowed in non-strict mode) */
74499 ch = 0;
74500 /* adv = 2 - 1 default OK */
74501#if defined(DUK_USE_OCTAL_SUPPORT)
74502 } else if (strict_mode) {
74503 /* No other escape beginning with a digit in strict mode */
74504 DUK_ERROR_SYNTAX(lex_ctx->thr, "invalid escape in string literal");
74505 } else if (DUK__ISDIGIT03(x) && DUK__ISOCTDIGIT(DUK__L2()) && DUK__ISOCTDIGIT(DUK__L3())) {
74506 /* Three digit octal escape, digits validated. */
74507 adv = 4 - 1;
74508 ch = (duk__hexval(lex_ctx, x) << 6) +
74509 (duk__hexval(lex_ctx, DUK__L2()) << 3) +
74510 duk__hexval(lex_ctx, DUK__L3());
74511 } else if (((DUK__ISDIGIT03(x) && !DUK__ISDIGIT(DUK__L3())) || DUK__ISDIGIT47(x)) &&
74513 /* Two digit octal escape, digits validated.
74514 *
74515 * The if-condition is a bit tricky. We could catch e.g.
74516 * '\039' in the three-digit escape and fail it there (by
74517 * validating the digits), but we want to avoid extra
74518 * additional validation code.
74519 */
74520 adv = 3 - 1;
74521 ch = (duk__hexval(lex_ctx, x) << 3) +
74522 duk__hexval(lex_ctx, DUK__L2());
74523 } else if (DUK__ISDIGIT(x) && !DUK__ISDIGIT(DUK__L2())) {
74524 /* One digit octal escape, digit validated. */
74525 /* adv = 2 default OK */
74526 ch = duk__hexval(lex_ctx, x);
74527#else
74528 /* fall through to error */
74529#endif
74530 } else {
74531 DUK_ERROR_SYNTAX(lex_ctx->thr, "invalid escape in string literal");
74532 }
74533
74534 DUK__APPENDBUFFER(lex_ctx, ch);
74535 } else {
74536 /* escaped NonEscapeCharacter */
74537 DUK__APPENDBUFFER(lex_ctx, x);
74538 }
74539 DUK__ADVANCECHARS(lex_ctx, adv);
74540
74541 /* Track number of escapes; count not really needed but directive
74542 * prologues need to detect whether there were any escapes or line
74543 * continuations or not.
74544 */
74545 out_token->num_escapes++;
74546 } else {
74547 /* part of string */
74548 DUK__APPENDBUFFER(lex_ctx, x);
74549 }
74550 }
74551
74552 duk__internbuffer(lex_ctx, lex_ctx->slot1_idx);
74553 out_token->str1 = duk_get_hstring((duk_context *) lex_ctx->thr, lex_ctx->slot1_idx);
74554
74555 DUK__INITBUFFER(lex_ctx); /* free some memory */
74556
74557 advtok = DUK__ADVTOK(0, DUK_TOK_STRING);
74558 break;
74559 }
74560 default:
74561 goto slow_path;
74562 } /* switch */
74563
74564 goto skip_slow_path;
74565
74566 slow_path:
74568 if (x == 0x000d && DUK__L1() == 0x000a) {
74569 /*
74570 * E5 Section 7.3: CR LF is detected as a single line terminator for
74571 * line numbers. Here we also detect it as a single line terminator
74572 * token.
74573 */
74574 DUK__ADVANCECHARS(lex_ctx, 2);
74575 } else {
74576 DUK__ADVANCECHARS(lex_ctx, 1);
74577 }
74578 got_lineterm = 1;
74579 goto restart_lineupdate;
74580 } else if (duk_unicode_is_identifier_start(x) || x == '\\') {
74581 /*
74582 * Parse an identifier and then check whether it is:
74583 * - reserved word (keyword or other reserved word)
74584 * - "null" (NullLiteral)
74585 * - "true" (BooleanLiteral)
74586 * - "false" (BooleanLiteral)
74587 * - anything else => identifier
74588 *
74589 * This does not follow the E5 productions cleanly, but is
74590 * useful and compact.
74591 *
74592 * Note that identifiers may contain Unicode escapes,
74593 * see E5 Sections 6 and 7.6. They must be decoded first,
74594 * and the result checked against allowed characters.
74595 * The above if-clause accepts an identifier start and an
74596 * '\' character -- no other token can begin with a '\'.
74597 *
74598 * Note that "get" and "set" are not reserved words in E5
74599 * specification so they are recognized as plain identifiers
74600 * (the tokens DUK_TOK_GET and DUK_TOK_SET are actually not
74601 * used now). The compiler needs to work around this.
74602 *
74603 * Strictly speaking, following Ecmascript longest match
74604 * specification, an invalid escape for the first character
74605 * should cause a syntax error. However, an invalid escape
74606 * for IdentifierParts should just terminate the identifier
74607 * early (longest match), and let the next tokenization
74608 * fail. For instance Rhino croaks with 'foo\z' when
74609 * parsing the identifier. This has little practical impact.
74610 */
74611
74612 duk_small_int_t i, i_end;
74613 duk_bool_t first = 1;
74614 duk_hstring *str;
74615
74616 DUK__INITBUFFER(lex_ctx);
74617 for (;;) {
74618 /* re-lookup first char on first loop */
74619 if (DUK__L0() == '\\') {
74620 duk_codepoint_t ch;
74621 if (DUK__L1() != 'u') {
74622 DUK_ERROR_SYNTAX(lex_ctx->thr, "invalid unicode escape in identifier");
74623 }
74624
74625 ch = duk__decode_uniesc_from_window(lex_ctx, 2);
74626
74627 /* IdentifierStart is stricter than IdentifierPart, so if the first
74628 * character is escaped, must have a stricter check here.
74629 */
74631 DUK_ERROR_SYNTAX(lex_ctx->thr, "invalid unicode escape in identifier");
74632 }
74633 DUK__APPENDBUFFER(lex_ctx, ch);
74634 DUK__ADVANCECHARS(lex_ctx, 6);
74635
74636 /* Track number of escapes: necessary for proper keyword
74637 * detection.
74638 */
74639 out_token->num_escapes++;
74640 } else {
74641 /* Note: first character is checked against this. But because
74642 * IdentifierPart includes all IdentifierStart characters, and
74643 * the first character (if unescaped) has already been checked
74644 * in the if condition, this is OK.
74645 */
74647 break;
74648 }
74649 DUK__APPENDBUFFER(lex_ctx, DUK__L0());
74650 DUK__ADVANCECHARS(lex_ctx, 1);
74651 }
74652 first = 0;
74653 }
74654
74655 duk__internbuffer(lex_ctx, lex_ctx->slot1_idx);
74656 out_token->str1 = duk_get_hstring((duk_context *) lex_ctx->thr, lex_ctx->slot1_idx);
74657 str = out_token->str1;
74658 DUK_ASSERT(str != NULL);
74659 out_token->t_nores = DUK_TOK_IDENTIFIER;
74660
74661 DUK__INITBUFFER(lex_ctx); /* free some memory */
74662
74663 /*
74664 * Interned identifier is compared against reserved words, which are
74665 * currently interned into the heap context. See genbuiltins.py.
74666 *
74667 * Note that an escape in the identifier disables recognition of
74668 * keywords; e.g. "\u0069f = 1;" is a valid statement (assigns to
74669 * identifier named "if"). This is not necessarily compliant,
74670 * see test-dec-escaped-char-in-keyword.js.
74671 *
74672 * Note: "get" and "set" are awkward. They are not officially
74673 * ReservedWords (and indeed e.g. "var set = 1;" is valid), and
74674 * must come out as DUK_TOK_IDENTIFIER. The compiler needs to
74675 * work around this a bit.
74676 */
74677
74678 /* XXX: optimize by adding the token numbers directly into the
74679 * always interned duk_hstring objects (there should be enough
74680 * flag bits free for that)?
74681 */
74682
74684
74685 advtok = DUK__ADVTOK(0, DUK_TOK_IDENTIFIER);
74686 if (out_token->num_escapes == 0) {
74687 for (i = DUK_STRIDX_START_RESERVED; i < i_end; i++) {
74688 DUK_ASSERT(i >= 0 && i < DUK_HEAP_NUM_STRINGS);
74689 if (DUK_HTHREAD_GET_STRING(lex_ctx->thr, i) == str) {
74690 advtok = DUK__ADVTOK(0, DUK_STRIDX_TO_TOK(i));
74691 break;
74692 }
74693 }
74694 }
74695 } else if (DUK__ISDIGIT(x) || (x == '.')) {
74696 /* Note: decimal number may start with a period, but must be followed by a digit */
74697
74698 /*
74699 * DecimalLiteral, HexIntegerLiteral, OctalIntegerLiteral
74700 * "pre-parsing", followed by an actual, accurate parser step.
74701 *
74702 * Note: the leading sign character ('+' or '-') is -not- part of
74703 * the production in E5 grammar, and that the a DecimalLiteral
74704 * starting with a '0' must be followed by a non-digit. Leading
74705 * zeroes are syntax errors and must be checked for.
74706 *
74707 * XXX: the two step parsing process is quite awkward, it would
74708 * be more straightforward to allow numconv to parse the longest
74709 * valid prefix (it already does that, it only needs to indicate
74710 * where the input ended). However, the lexer decodes characters
74711 * using a lookup window, so this is not a trivial change.
74712 */
74713
74714 /* XXX: because of the final check below (that the literal is not
74715 * followed by a digit), this could maybe be simplified, if we bail
74716 * out early from a leading zero (and if there are no periods etc).
74717 * Maybe too complex.
74718 */
74719
74720 duk_double_t val;
74721 duk_bool_t int_only = 0;
74722 duk_bool_t allow_hex = 0;
74723 duk_small_int_t state; /* 0=before period/exp,
74724 * 1=after period, before exp
74725 * 2=after exp, allow '+' or '-'
74726 * 3=after exp and exp sign
74727 */
74728 duk_small_uint_t s2n_flags;
74730
74731 DUK__INITBUFFER(lex_ctx);
74732 y = DUK__L1();
74733 if (x == '0' && (y == 'x' || y == 'X')) {
74734 DUK__APPENDBUFFER(lex_ctx, x);
74735 DUK__APPENDBUFFER(lex_ctx, y);
74736 DUK__ADVANCECHARS(lex_ctx, 2);
74737 int_only = 1;
74738 allow_hex = 1;
74739#if defined(DUK_USE_OCTAL_SUPPORT)
74740 } else if (!strict_mode && x == '0' && DUK__ISDIGIT(y)) {
74741 /* Note: if DecimalLiteral starts with a '0', it can only be
74742 * followed by a period or an exponent indicator which starts
74743 * with 'e' or 'E'. Hence the if-check above ensures that
74744 * OctalIntegerLiteral is the only valid NumericLiteral
74745 * alternative at this point (even if y is, say, '9').
74746 */
74747
74748 DUK__APPENDBUFFER(lex_ctx, x);
74749 DUK__ADVANCECHARS(lex_ctx, 1);
74750 int_only = 1;
74751#endif
74752 }
74753
74754 state = 0;
74755 for (;;) {
74756 x = DUK__L0(); /* re-lookup curr char on first round */
74757 if (DUK__ISDIGIT(x)) {
74758 /* Note: intentionally allow leading zeroes here, as the
74759 * actual parser will check for them.
74760 */
74761 if (state == 2) {
74762 state = 3;
74763 }
74764 } else if (allow_hex && DUK__ISHEXDIGIT(x)) {
74765 /* Note: 'e' and 'E' are also accepted here. */
74766 ;
74767 } else if (x == '.') {
74768 if (state >= 1 || int_only) {
74769 break;
74770 } else {
74771 state = 1;
74772 }
74773 } else if (x == 'e' || x == 'E') {
74774 if (state >= 2 || int_only) {
74775 break;
74776 } else {
74777 state = 2;
74778 }
74779 } else if (x == '-' || x == '+') {
74780 if (state != 2) {
74781 break;
74782 } else {
74783 state = 3;
74784 }
74785 } else {
74786 break;
74787 }
74788 DUK__APPENDBUFFER(lex_ctx, x);
74789 DUK__ADVANCECHARS(lex_ctx, 1);
74790 }
74791
74792 /* XXX: better coercion */
74793 duk__internbuffer(lex_ctx, lex_ctx->slot1_idx);
74794
74795 s2n_flags = DUK_S2N_FLAG_ALLOW_EXP |
74799#if defined(DUK_USE_OCTAL_SUPPORT)
74800 (strict_mode ? 0 : DUK_S2N_FLAG_ALLOW_AUTO_OCT_INT) |
74801#endif
74803
74804 duk_dup((duk_context *) lex_ctx->thr, lex_ctx->slot1_idx);
74805 duk_numconv_parse((duk_context *) lex_ctx->thr, 10 /*radix*/, s2n_flags);
74806 val = duk_to_number((duk_context *) lex_ctx->thr, -1);
74807 if (DUK_ISNAN(val)) {
74808 DUK_ERROR_SYNTAX(lex_ctx->thr, "invalid numeric literal");
74809 }
74810 duk_replace((duk_context *) lex_ctx->thr, lex_ctx->slot1_idx); /* could also just pop? */
74811
74812 DUK__INITBUFFER(lex_ctx); /* free some memory */
74813
74814 /* Section 7.8.3 (note): NumericLiteral must be followed by something other than
74815 * IdentifierStart or DecimalDigit.
74816 */
74817
74819 DUK_ERROR_SYNTAX(lex_ctx->thr, "invalid numeric literal");
74820 }
74821
74822 out_token->num = val;
74823 advtok = DUK__ADVTOK(0, DUK_TOK_NUMBER);
74824 } else if (duk_unicode_is_whitespace(DUK__LOOKUP(lex_ctx, 0))) {
74825 DUK__ADVANCECHARS(lex_ctx, 1);
74826 goto restart;
74827 } else if (x < 0) {
74828 advtok = DUK__ADVTOK(0, DUK_TOK_EOF);
74829 } else {
74830 DUK_ERROR_SYNTAX(lex_ctx->thr, "invalid token");
74831 }
74832 skip_slow_path:
74833
74834 /*
74835 * Shared exit path
74836 */
74837
#define DUK__ISHEXDIGIT(x)
#define DUK__ISDIGIT(x)
#define DUK_ASC_LPAREN
#define DUK_S2N_FLAG_ALLOW_FRAC
#define DUK_ASC_EXCLAMATION
#define DUK__ADVTOK(advbytes, tok)
DUK_LOCAL duk_codepoint_t duk__hexval(duk_lexer_ctx *lex_ctx, duk_codepoint_t x)
#define DUK_ASC_RANGLE
#define DUK__L3()
#define DUK__INITBUFFER(lex_ctx)
#define DUK_S2N_FLAG_ALLOW_EMPTY_FRAC
#define DUK__ISOCTDIGIT(x)
#define DUK__L0()
#define DUK__ADVANCECHARS(lex_ctx, count)
#define DUK_S2N_FLAG_ALLOW_NAKED_FRAC
#define DUK_ASC_SEMICOLON
#define DUK_S2N_FLAG_ALLOW_AUTO_OCT_INT
#define DUK_ASC_LANGLE
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_whitespace(duk_codepoint_t cp)
DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_identifier_part(duk_codepoint_t cp)
DUK_LOCAL void duk__internbuffer(duk_lexer_ctx *lex_ctx, duk_idx_t valstack_idx)
#define DUK__L2()
#define DUK_ASC_STAR
#define DUK__L1()
#define DUK__ISDIGIT03(x)
#define DUK_ASC_HT
#define DUK__ISDIGIT47(x)
#define DUK_ASC_EQUALS
DUK_LOCAL duk_codepoint_t duk__decode_uniesc_from_window(duk_lexer_ctx *lex_ctx, duk_small_int_t lookup_offset)
#define DUK_STRIDX_TO_TOK(x)
#define DUK__LOOKUP(lex_ctx, index)
#define DUK_ASC_TILDE
DUK_LOCAL duk_codepoint_t duk__decode_hexesc_from_window(duk_lexer_ctx *lex_ctx, duk_small_int_t lookup_offset)
#define DUK_ASC_CARET
#define DUK_S2N_FLAG_ALLOW_EXP
#define DUK__APPENDBUFFER(lex_ctx, x)

References DUK__ADVANCEBYTES, DUK__ADVANCECHARS, DUK__ADVTOK, DUK__APPENDBUFFER, duk__decode_hexesc_from_window(), duk__decode_uniesc_from_window(), duk__hexval(), DUK__INITBUFFER, duk__internbuffer(), DUK__ISDIGIT, DUK__ISDIGIT03, DUK__ISDIGIT47, DUK__ISHEXDIGIT, DUK__ISOCTDIGIT, DUK__L0, DUK__L1, DUK__L2, DUK__L3, DUK__LOOKUP, DUK_ASC_AMP, DUK_ASC_CARET, DUK_ASC_COLON, DUK_ASC_COMMA, DUK_ASC_DOUBLEQUOTE, DUK_ASC_EQUALS, DUK_ASC_EXCLAMATION, DUK_ASC_HT, DUK_ASC_LANGLE, DUK_ASC_LBRACKET, DUK_ASC_LCURLY, DUK_ASC_LF, DUK_ASC_LPAREN, DUK_ASC_MINUS, DUK_ASC_PERCENT, DUK_ASC_PERIOD, DUK_ASC_PIPE, DUK_ASC_PLUS, DUK_ASC_QUESTION, DUK_ASC_RANGLE, DUK_ASC_RBRACKET, DUK_ASC_RCURLY, DUK_ASC_RPAREN, DUK_ASC_SEMICOLON, DUK_ASC_SINGLEQUOTE, DUK_ASC_SLASH, DUK_ASC_SPACE, DUK_ASC_STAR, DUK_ASC_TILDE, DUK_ASSERT, DUK_DOUBLE_NAN, duk_dup(), DUK_ERROR_RANGE, DUK_ERROR_SYNTAX, duk_get_hstring(), DUK_HEAP_NUM_STRINGS, DUK_HTHREAD_GET_STRING, DUK_ISNAN, duk_numconv_parse(), duk_replace(), DUK_S2N_FLAG_ALLOW_AUTO_HEX_INT, DUK_S2N_FLAG_ALLOW_AUTO_OCT_INT, DUK_S2N_FLAG_ALLOW_EMPTY_FRAC, DUK_S2N_FLAG_ALLOW_EXP, DUK_S2N_FLAG_ALLOW_FRAC, DUK_S2N_FLAG_ALLOW_NAKED_FRAC, DUK_STRIDX_END_RESERVED, DUK_STRIDX_START_RESERVED, DUK_STRIDX_START_STRICT_RESERVED, DUK_STRIDX_TO_TOK, duk_to_number(), duk_to_undefined(), DUK_TOK_ADD, DUK_TOK_ADD_EQ, DUK_TOK_ALSHIFT, DUK_TOK_ALSHIFT_EQ, DUK_TOK_ARSHIFT, DUK_TOK_ARSHIFT_EQ, DUK_TOK_BAND, DUK_TOK_BAND_EQ, DUK_TOK_BNOT, DUK_TOK_BOR, DUK_TOK_BOR_EQ, DUK_TOK_BXOR, DUK_TOK_BXOR_EQ, DUK_TOK_COLON, DUK_TOK_COMMA, DUK_TOK_DECREMENT, DUK_TOK_DIV, DUK_TOK_DIV_EQ, DUK_TOK_EOF, DUK_TOK_EQ, DUK_TOK_EQUALSIGN, DUK_TOK_GE, DUK_TOK_GT, DUK_TOK_IDENTIFIER, DUK_TOK_INCREMENT, DUK_TOK_LAND, DUK_TOK_LBRACKET, DUK_TOK_LCURLY, DUK_TOK_LE, DUK_TOK_LNOT, DUK_TOK_LOR, DUK_TOK_LPAREN, DUK_TOK_LT, DUK_TOK_MOD, DUK_TOK_MOD_EQ, DUK_TOK_MUL, DUK_TOK_MUL_EQ, DUK_TOK_NEQ, DUK_TOK_NUMBER, DUK_TOK_PERIOD, DUK_TOK_QUESTION, DUK_TOK_RBRACKET, DUK_TOK_RCURLY, DUK_TOK_REGEXP, DUK_TOK_RPAREN, DUK_TOK_RSHIFT, DUK_TOK_RSHIFT_EQ, DUK_TOK_SEMICOLON, DUK_TOK_SEQ, DUK_TOK_SNEQ, DUK_TOK_STRING, DUK_TOK_SUB, DUK_TOK_SUB_EQ, duk_unicode_is_identifier_part(), duk_unicode_is_identifier_start(), duk_unicode_is_line_terminator(), duk_unicode_is_whitespace(), duk_lexer_codepoint::line, duk_token::lineterm, NULL, duk_token::num, duk_token::num_escapes, duk_lexer_codepoint::offset, duk_lexer_ctx::slot1_idx, duk_lexer_ctx::slot2_idx, duk_token::start_line, duk_token::start_offset, duk_token::str1, duk_token::str2, duk_token::t, duk_token::t_nores, duk_lexer_ctx::thr, duk_lexer_ctx::token_count, duk_lexer_ctx::token_limit, and duk_lexer_ctx::window.

◆ duk_lexer_parse_re_ranges()

DUK_INTERNAL_DECL void duk_lexer_parse_re_ranges ( duk_lexer_ctx * lex_ctx,
duk_re_range_callback gen_range,
void * userdata )

Definition at line 75204 of file duktape-1.8.0/src/duktape.c.

75208 {
75209 const duk_uint16_t *ranges_end;
75210
75211 DUK_UNREF(lex_ctx);
75212
75213 ranges_end = ranges + num;
75214 while (ranges < ranges_end) {
75215 /* mark range 'direct', bypass canonicalization (see Wiki) */
75216 gen_range(userdata, (duk_codepoint_t) ranges[0], (duk_codepoint_t) ranges[1], 1);
75217 ranges += 2;
75218 }
75219}
75220
75221DUK_INTERNAL void duk_lexer_parse_re_ranges(duk_lexer_ctx *lex_ctx, duk_re_range_callback gen_range, void *userdata) {
75222 duk_codepoint_t start = -1;
75223 duk_codepoint_t ch;
75225 duk_bool_t dash = 0;
75226
75227 DUK_DD(DUK_DDPRINT("parsing regexp ranges"));
75228
75229 for (;;) {
75230 x = DUK__L0();
75231 DUK__ADVANCECHARS(lex_ctx, 1);
75232
75233 ch = -1; /* not strictly necessary, but avoids "uninitialized variable" warnings */
75234 DUK_UNREF(ch);
75235
75236 if (x < 0) {
75237 DUK_ERROR_SYNTAX(lex_ctx->thr, "eof in character class");
75238 } else if (x == ']') {
75239 if (start >= 0) {
75240 gen_range(userdata, start, start, 0);
75241 }
75242 break;
75243 } else if (x == '-') {
75244 if (start >= 0 && !dash && DUK__L0() != ']') {
75245 /* '-' as a range indicator */
75246 dash = 1;
75247 continue;
75248 } else {
75249 /* '-' verbatim */
75250 ch = x;
75251 }
75252 } else if (x == '\\') {
75253 /*
75254 * The escapes are same as outside a character class, except that \b has a
75255 * different meaning, and \B and backreferences are prohibited (see E5
75256 * Section 15.10.2.19). However, it's difficult to share code because we
75257 * handle e.g. "\n" very differently: here we generate a single character
75258 * range for it.
75259 */
75260
75261 x = DUK__L0();
75262 DUK__ADVANCECHARS(lex_ctx, 1);
75263
75264 if (x == 'b') {
75265 /* Note: '\b' in char class is different than outside (assertion),
75266 * '\B' is not allowed and is caught by the duk_unicode_is_identifier_part()
75267 * check below.
75268 */
75269 ch = 0x0008;
75270 } else if (x == 'f') {
75271 ch = 0x000c;
75272 } else if (x == 'n') {
75273 ch = 0x000a;
75274 } else if (x == 't') {
75275 ch = 0x0009;
75276 } else if (x == 'r') {
75277 ch = 0x000d;
75278 } else if (x == 'v') {
75279 ch = 0x000b;
75280 } else if (x == 'c') {
75281 x = DUK__L0();
75282 DUK__ADVANCECHARS(lex_ctx, 1);
75283 if ((x >= 'a' && x <= 'z') ||
75284 (x >= 'A' && x <= 'Z')) {
75285 ch = (x % 32);
75286 } else {
75287 DUK_ERROR_SYNTAX(lex_ctx->thr, "invalid regexp escape");
75288 return; /* never reached, but avoids warnings of
75289 * potentially unused variables.
75290 */
75291 }
75292 } else if (x == 'x') {
75293 ch = duk__decode_hexesc_from_window(lex_ctx, 0);
75294 DUK__ADVANCECHARS(lex_ctx, 2);
75295 } else if (x == 'u') {
75296 ch = duk__decode_uniesc_from_window(lex_ctx, 0);
75297 DUK__ADVANCECHARS(lex_ctx, 4);
75298 } else if (x == 'd') {
75300 gen_range,
75301 userdata,
75303 sizeof(duk_unicode_re_ranges_digit) / sizeof(duk_uint16_t));
75304 ch = -1;
75305 } else if (x == 'D') {
75307 gen_range,
75308 userdata,
75310 sizeof(duk_unicode_re_ranges_not_digit) / sizeof(duk_uint16_t));
75311 ch = -1;
75312 } else if (x == 's') {
75314 gen_range,
75315 userdata,
75317 sizeof(duk_unicode_re_ranges_white) / sizeof(duk_uint16_t));
75318 ch = -1;
75319 } else if (x == 'S') {
75321 gen_range,
75322 userdata,
75324 sizeof(duk_unicode_re_ranges_not_white) / sizeof(duk_uint16_t));
75325 ch = -1;
75326 } else if (x == 'w') {
75328 gen_range,
75329 userdata,
75331 sizeof(duk_unicode_re_ranges_wordchar) / sizeof(duk_uint16_t));
75332 ch = -1;
75333 } else if (x == 'W') {
75335 gen_range,
75336 userdata,
75338 sizeof(duk_unicode_re_ranges_not_wordchar) / sizeof(duk_uint16_t));
75339 ch = -1;
75340 } else if (DUK__ISDIGIT(x)) {
75341 /* DecimalEscape, only \0 is allowed, no leading zeroes are allowed */
75342 if (x == '0' && !DUK__ISDIGIT(DUK__L0())) {
75343 ch = 0x0000;
75344 } else {
75345 DUK_ERROR_SYNTAX(lex_ctx->thr, "invalid regexp escape");
75346 }
75347 } else if (!duk_unicode_is_identifier_part(x)
75349 || x == '$'
75350#endif
75351 ) {
75352 /* IdentityEscape */
75353 ch = x;
75354 } else {
75355 DUK_ERROR_SYNTAX(lex_ctx->thr, "invalid regexp escape");
75356 }
75357 } else {
75358 /* character represents itself */
75359 ch = x;
75360 }
75361
75362 /* ch is a literal character here or -1 if parsed entity was
75363 * an escape such as "\s".
75364 */
75365
75366 if (ch < 0) {
75367 /* multi-character sets not allowed as part of ranges, see
75368 * E5 Section 15.10.2.15, abstract operation CharacterRange.
75369 */
75370 if (start >= 0) {
75371 if (dash) {
75372 DUK_ERROR_SYNTAX(lex_ctx->thr, "invalid range");
75373 } else {
75374 gen_range(userdata, start, start, 0);
75375 start = -1;
75376 /* dash is already 0 */
75377 }
75378 }
75379 } else {
75380 if (start >= 0) {
75381 if (dash) {
75382 if (start > ch) {
75383 DUK_ERROR_SYNTAX(lex_ctx->thr, "invalid range");
#define DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE
DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_not_white[24]
DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_not_digit[4]
DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_not_wordchar[10]
void(* duk_re_range_callback)(void *user, duk_codepoint_t r1, duk_codepoint_t r2, duk_bool_t direct)
DUK_LOCAL void duk__emit_u16_direct_ranges(duk_lexer_ctx *lex_ctx, duk_re_range_callback gen_range, void *userdata, const duk_uint16_t *ranges, duk_small_int_t num)

References DUK_UNREF.

Referenced by duk__parse_disjunction().

◆ duk_lexer_parse_re_token()

DUK_INTERNAL_DECL void duk_lexer_parse_re_token ( duk_lexer_ctx * lex_ctx,
duk_re_token * out_token )

Definition at line 74850 of file duktape-1.8.0/src/duktape.c.

74851 {
74852 out_token->allow_auto_semi = 0;
74853 }
74854}
74855
74856#if defined(DUK_USE_REGEXP_SUPPORT)
74857
74858/*
74859 * Parse a RegExp token. The grammar is described in E5 Section 15.10.
74860 * Terminal constructions (such as quantifiers) are parsed directly here.
74861 *
74862 * 0xffffffffU is used as a marker for "infinity" in quantifiers. Further,
74863 * DUK__MAX_RE_QUANT_DIGITS limits the maximum number of digits that
74864 * will be accepted for a quantifier.
74865 */
74866
74868 duk_small_int_t advtok = 0; /* init is unnecessary but suppresses "may be used uninitialized" warnings */
74869 duk_codepoint_t x, y;
74870
74871 if (++lex_ctx->token_count >= lex_ctx->token_limit) {
74872 DUK_ERROR_RANGE(lex_ctx->thr, "token limit");
74873 return; /* unreachable */
74874 }
74875
74876 DUK_MEMZERO(out_token, sizeof(*out_token));
74877
74878 x = DUK__L0();
74879 y = DUK__L1();
74880
74881 DUK_DDD(DUK_DDDPRINT("parsing regexp token, L0=%ld, L1=%ld", (long) x, (long) y));
74882
74883 switch (x) {
74884 case '|': {
74886 break;
74887 }
74888 case '^': {
74890 break;
74891 }
74892 case '$': {
74893 advtok = DUK__ADVTOK(1, DUK_RETOK_ASSERT_END);
74894 break;
74895 }
74896 case '?': {
74897 out_token->qmin = 0;
74898 out_token->qmax = 1;
74899 if (y == '?') {
74900 advtok = DUK__ADVTOK(2, DUK_RETOK_QUANTIFIER);
74901 out_token->greedy = 0;
74902 } else {
74903 advtok = DUK__ADVTOK(1, DUK_RETOK_QUANTIFIER);
74904 out_token->greedy = 1;
74905 }
74906 break;
74907 }
74908 case '*': {
74909 out_token->qmin = 0;
74910 out_token->qmax = DUK_RE_QUANTIFIER_INFINITE;
74911 if (y == '?') {
74912 advtok = DUK__ADVTOK(2, DUK_RETOK_QUANTIFIER);
74913 out_token->greedy = 0;
74914 } else {
74915 advtok = DUK__ADVTOK(1, DUK_RETOK_QUANTIFIER);
74916 out_token->greedy = 1;
74917 }
74918 break;
74919 }
74920 case '+': {
74921 out_token->qmin = 1;
74922 out_token->qmax = DUK_RE_QUANTIFIER_INFINITE;
74923 if (y == '?') {
74924 advtok = DUK__ADVTOK(2, DUK_RETOK_QUANTIFIER);
74925 out_token->greedy = 0;
74926 } else {
74927 advtok = DUK__ADVTOK(1, DUK_RETOK_QUANTIFIER);
74928 out_token->greedy = 1;
74929 }
74930 break;
74931 }
74932 case '{': {
74933 /* Production allows 'DecimalDigits', including leading zeroes */
74934 duk_uint_fast32_t val1 = 0;
74936 duk_small_int_t digits = 0;
74937#if defined(DUK_USE_ES6_REGEXP_BRACES)
74938 duk_lexer_point lex_pt;
74939#endif
74940
74941#if defined(DUK_USE_ES6_REGEXP_BRACES)
74942 /* Store lexer position, restoring if quantifier is invalid. */
74943 DUK_LEXER_GETPOINT(lex_ctx, &lex_pt);
74944#endif
74945
74946 for (;;) {
74947 DUK__ADVANCECHARS(lex_ctx, 1); /* eat '{' on entry */
74948 x = DUK__L0();
74949 if (DUK__ISDIGIT(x)) {
74950 digits++;
74951 val1 = val1 * 10 + (duk_uint_fast32_t) duk__hexval(lex_ctx, x);
74952 } else if (x == ',') {
74953 if (digits > DUK__MAX_RE_QUANT_DIGITS) {
74954 goto invalid_quantifier;
74955 }
74956 if (val2 != DUK_RE_QUANTIFIER_INFINITE) {
74957 goto invalid_quantifier;
74958 }
74959 if (DUK__L1() == '}') {
74960 /* form: { DecimalDigits , }, val1 = min count */
74961 if (digits == 0) {
74962 goto invalid_quantifier;
74963 }
74964 out_token->qmin = val1;
74965 out_token->qmax = DUK_RE_QUANTIFIER_INFINITE;
74966 DUK__ADVANCECHARS(lex_ctx, 2);
74967 break;
74968 }
74969 val2 = val1;
74970 val1 = 0;
74971 digits = 0; /* not strictly necessary because of lookahead '}' above */
74972 } else if (x == '}') {
74973 if (digits > DUK__MAX_RE_QUANT_DIGITS) {
74974 goto invalid_quantifier;
74975 }
74976 if (digits == 0) {
74977 goto invalid_quantifier;
74978 }
74979 if (val2 != DUK_RE_QUANTIFIER_INFINITE) {
74980 /* val2 = min count, val1 = max count */
74981 out_token->qmin = val2;
74982 out_token->qmax = val1;
74983 } else {
74984 /* val1 = count */
74985 out_token->qmin = val1;
74986 out_token->qmax = val1;
74987 }
74988 DUK__ADVANCECHARS(lex_ctx, 1);
74989 break;
74990 } else {
74991 goto invalid_quantifier;
74992 }
74993 }
74994 if (DUK__L0() == '?') {
74995 out_token->greedy = 0;
74996 DUK__ADVANCECHARS(lex_ctx, 1);
74997 } else {
74998 out_token->greedy = 1;
74999 }
75000 advtok = DUK__ADVTOK(0, DUK_RETOK_QUANTIFIER);
75001 break;
75002 invalid_quantifier:
75003#if defined(DUK_USE_ES6_REGEXP_BRACES)
75004 /* Failed to match the quantifier, restore lexer and parse
75005 * opening brace as a literal.
75006 */
75007 DUK_LEXER_SETPOINT(lex_ctx, &lex_pt);
75008 advtok = DUK__ADVTOK(1, DUK_RETOK_ATOM_CHAR);
75009 out_token->num = '{';
75010#else
75011 DUK_ERROR_SYNTAX(lex_ctx->thr, "invalid regexp quantifier");
75012#endif
75013 break;
75014 }
75015 case '.': {
75017 break;
75018 }
75019 case '\\': {
75020 /* The E5.1 specification does not seem to allow IdentifierPart characters
75021 * to be used as identity escapes. Unfortunately this includes '$', which
75022 * cannot be escaped as '\$'; it needs to be escaped e.g. as '\u0024'.
75023 * Many other implementations (including V8 and Rhino, for instance) do
75024 * accept '\$' as a valid identity escape, which is quite pragmatic.
75025 * See: test-regexp-identity-escape-dollar.js.
75026 */
75027
75028 advtok = DUK__ADVTOK(2, DUK_RETOK_ATOM_CHAR); /* default: char escape (two chars) */
75029 if (y == 'b') {
75031 } else if (y == 'B') {
75033 } else if (y == 'f') {
75034 out_token->num = 0x000c;
75035 } else if (y == 'n') {
75036 out_token->num = 0x000a;
75037 } else if (y == 't') {
75038 out_token->num = 0x0009;
75039 } else if (y == 'r') {
75040 out_token->num = 0x000d;
75041 } else if (y == 'v') {
75042 out_token->num = 0x000b;
75043 } else if (y == 'c') {
75044 x = DUK__L2();
75045 if ((x >= 'a' && x <= 'z') ||
75046 (x >= 'A' && x <= 'Z')) {
75047 out_token->num = (x % 32);
75048 advtok = DUK__ADVTOK(3, DUK_RETOK_ATOM_CHAR);
75049 } else {
75050 DUK_ERROR_SYNTAX(lex_ctx->thr, "invalid regexp escape");
75051 }
75052 } else if (y == 'x') {
75053 out_token->num = duk__decode_hexesc_from_window(lex_ctx, 2);
75054 advtok = DUK__ADVTOK(4, DUK_RETOK_ATOM_CHAR);
75055 } else if (y == 'u') {
75056 out_token->num = duk__decode_uniesc_from_window(lex_ctx, 2);
75057 advtok = DUK__ADVTOK(6, DUK_RETOK_ATOM_CHAR);
75058 } else if (y == 'd') {
75059 advtok = DUK__ADVTOK(2, DUK_RETOK_ATOM_DIGIT);
75060 } else if (y == 'D') {
75062 } else if (y == 's') {
75063 advtok = DUK__ADVTOK(2, DUK_RETOK_ATOM_WHITE);
75064 } else if (y == 'S') {
75066 } else if (y == 'w') {
75068 } else if (y == 'W') {
75070 } else if (DUK__ISDIGIT(y)) {
75071 /* E5 Section 15.10.2.11 */
75072 if (y == '0') {
75073 if (DUK__ISDIGIT(DUK__L2())) {
75074 DUK_ERROR_SYNTAX(lex_ctx->thr, "invalid regexp escape");
75075 }
75076 out_token->num = 0x0000;
75077 advtok = DUK__ADVTOK(2, DUK_RETOK_ATOM_CHAR);
75078 } else {
75079 /* XXX: shared parsing? */
75080 duk_uint_fast32_t val = 0;
75082 for (i = 0; ; i++) {
75083 if (i >= DUK__MAX_RE_DECESC_DIGITS) {
75084 DUK_ERROR_SYNTAX(lex_ctx->thr, "invalid regexp escape");
75085 }
75086 DUK__ADVANCECHARS(lex_ctx, 1); /* eat backslash on entry */
75087 x = DUK__L0();
75088 if (!DUK__ISDIGIT(x)) {
75089 break;
75090 }
75091 val = val * 10 + (duk_uint_fast32_t) duk__hexval(lex_ctx, x);
75092 }
75093 /* DUK__L0() cannot be a digit, because the loop doesn't terminate if it is */
75095 out_token->num = val;
75096 }
75097 } else if ((y >= 0 && !duk_unicode_is_identifier_part(y)) ||
75099 y == '$' ||
75100#endif
75101 y == DUK_UNICODE_CP_ZWNJ ||
75102 y == DUK_UNICODE_CP_ZWJ) {
75103 /* IdentityEscape, with dollar added as a valid additional
75104 * non-standard escape (see test-regexp-identity-escape-dollar.js).
75105 * Careful not to match end-of-buffer (<0) here.
75106 */
75107 out_token->num = y;
75108 } else {
75109 DUK_ERROR_SYNTAX(lex_ctx->thr, "invalid regexp escape");
75110 }
75111 break;
75112 }
75113 case '(': {
75114 /* XXX: naming is inconsistent: ATOM_END_GROUP ends an ASSERT_START_LOOKAHEAD */
75115
75116 if (y == '?') {
75117 if (DUK__L2() == '=') {
75118 /* (?= */
75120 } else if (DUK__L2() == '!') {
75121 /* (?! */
75123 } else if (DUK__L2() == ':') {
75124 /* (?: */
75126 } else {
75127 DUK_ERROR_SYNTAX(lex_ctx->thr, "invalid regexp group");
75128 return;
75129 }
75130 } else {
75131 /* ( */
75133 }
75134 break;
75135 }
75136 case ')': {
75138 break;
75139 }
75140 case '[': {
75141 /*
75142 * To avoid creating a heavy intermediate value for the list of ranges,
75143 * only the start token ('[' or '[^') is parsed here. The regexp
75144 * compiler parses the ranges itself.
75145 */
75147 if (y == '^') {
75149 }
75150 break;
75151 }
75152#if !defined(DUK_USE_ES6_REGEXP_BRACES)
75153 case '}':
75154#endif
75155 case ']': {
75156 /* Although these could be parsed as PatternCharacters unambiguously (here),
75157 * E5 Section 15.10.1 grammar explicitly forbids these as PatternCharacters.
75158 */
75159 DUK_ERROR_SYNTAX(lex_ctx->thr, "invalid regexp character");
75160 break;
75161 }
75162 case -1: {
75163 /* EOF */
75164 advtok = DUK__ADVTOK(0, DUK_TOK_EOF);
#define DUK__MAX_RE_QUANT_DIGITS
#define DUK_UNICODE_CP_ZWNJ
#define DUK_UNICODE_CP_ZWJ
#define DUK__MAX_RE_DECESC_DIGITS

Referenced by duk__parse_disjunction().

◆ duk_lexer_setpoint()

DUK_INTERNAL_DECL void duk_lexer_setpoint ( duk_lexer_ctx * lex_ctx,
duk_lexer_point * pt )

Definition at line 73899 of file duktape-1.8.0/src/duktape.c.

◆ duk_load_function()

DUK_EXTERNAL void duk_load_function ( duk_context * ctx)

Definition at line 12319 of file duktape-1.8.0/src/duktape.c.

12331 : %!T", duk_get_tval(ctx, -1)));
12332
12333 duk_remove(ctx, -2); /* [ ... func buf ] -> [ ... buf ] */
12334}
12335
12336DUK_EXTERNAL void duk_load_function(duk_context *ctx) {
12337 duk_hthread *thr;
12338 duk_uint8_t *p_buf, *p, *p_end;
12339 duk_size_t sz;
12340
12341 DUK_ASSERT(ctx != NULL);
12342 thr = (duk_hthread *) ctx;
12343 DUK_UNREF(ctx);
12344
12345 p_buf = (duk_uint8_t *) duk_require_buffer(ctx, -1, &sz);
12346 DUK_ASSERT(p_buf != NULL);
12347
12348 /* The caller is responsible for being sure that bytecode being loaded
12349 * is valid and trusted. Invalid bytecode can cause memory unsafe
12350 * behavior directly during loading or later during bytecode execution
12351 * (instruction validation would be quite complex to implement).
12352 *
12353 * This signature check is the only sanity check for detecting
12354 * accidental invalid inputs. The initial 0xFF byte ensures no
12355 * ordinary string will be accepted by accident.
12356 */
12357 p = p_buf;

◆ duk_log()

DUK_EXTERNAL void duk_log ( duk_context * ctx,
duk_int_t level,
const char * fmt,
... )

Definition at line 14280 of file duktape-1.8.0/src/duktape.c.

◆ duk_log_va()

DUK_EXTERNAL void duk_log_va ( duk_context * ctx,
duk_int_t level,
const char * fmt,
va_list ap )

Definition at line 14247 of file duktape-1.8.0/src/duktape.c.

14264 {
14265 /* stridx_logfunc[] must be static to allow initializer with old compilers like BCC */
14266 static const duk_uint16_t stridx_logfunc[6] = {
14269 };
14270
14272
14273 if (level < 0) {
14274 level = 0;
14275 } else if (level > (int) (sizeof(stridx_logfunc) / sizeof(duk_uint16_t)) - 1) {
14276 level = (int) (sizeof(stridx_logfunc) / sizeof(duk_uint16_t)) - 1;
14277 }
14278
#define DUK_STRIDX_LC_TRACE
#define DUK_STRIDX_LC_WARN
#define DUK_STRIDX_LC_INFO
#define DUK_STRIDX_LC_DEBUG
#define DUK_STRIDX_LC_ERROR
#define DUK_STRIDX_LC_FATAL

Referenced by duk_alloc_raw().

◆ duk_map_string()

DUK_EXTERNAL void duk_map_string ( duk_context * ctx,
duk_idx_t index,
duk_map_char_function callback,
void * udata )

Definition at line 19942 of file duktape-1.8.0/src/duktape.c.

19950 {
19951 if (p >= p_end) {
19952 break;
19953 }
19954 cp = (int) duk_unicode_decode_xutf8_checked(thr, &p, p_start, p_end);
19955 callback(udata, cp);
19956 }
19957}
19958
19960 duk_hthread *thr = (duk_hthread *) ctx;
19961 duk_hstring *h_input;
19962 duk_bufwriter_ctx bw_alloc;
19964 const duk_uint8_t *p, *p_start, *p_end;
19965 duk_codepoint_t cp;
19966
19968
19970
19971 h_input = duk_require_hstring(ctx, index);
19972 DUK_ASSERT(h_input != NULL);
19973
19974 bw = &bw_alloc;
19975 DUK_BW_INIT_PUSHBUF(thr, bw, DUK_HSTRING_GET_BYTELEN(h_input)); /* reasonable output estimate */
19976
19977 p_start = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input);
19978 p_end = p_start + DUK_HSTRING_GET_BYTELEN(h_input);
19979 p = p_start;
19980
19981 for (;;) {
duk_codepoint_t(* duk_map_char_function)(void *udata, duk_codepoint_t codepoint)
DUK_EXTERNAL void duk_map_string(duk_context *ctx, duk_idx_t index, duk_map_char_function callback, void *udata)

◆ duk_new()

DUK_EXTERNAL void duk_new ( duk_context * ctx,
duk_idx_t nargs )

Definition at line 12607 of file duktape-1.8.0/src/duktape.c.

12610 {
12611 /* See comments in duk_pcall(). */
12613 return DUK_EXEC_ERROR; /* unreachable */
12614 }
12615
12616 rc = duk_handle_safe_call(thr, /* thread */
12617 func, /* func */
12618 nargs, /* num_stack_args */
12619 nrets); /* num_stack_res */
12620
12621 return rc;
12622}
12623
12624DUK_EXTERNAL void duk_new(duk_context *ctx, duk_idx_t nargs) {
12625 /*
12626 * There are two [[Construct]] operations in the specification:
12627 *
12628 * - E5 Section 13.2.2: for Function objects
12629 * - E5 Section 15.3.4.5.2: for "bound" Function objects
12630 *
12631 * The chain of bound functions is resolved in Section 15.3.4.5.2,
12632 * with arguments "piling up" until the [[Construct]] internal
12633 * method is called on the final, actual Function object. Note
12634 * that the "prototype" property is looked up *only* from the
12635 * final object, *before* calling the constructor.
12636 *
12637 * Currently we follow the bound function chain here to get the
12638 * "prototype" property value from the final, non-bound function.
12639 * However, we let duk_handle_call() handle the argument "piling"
12640 * when the constructor is called. The bound function chain is
12641 * thus now processed twice.
12642 *
12643 * When constructing new Array instances, an unnecessary object is
12644 * created and discarded now: the standard [[Construct]] creates an
12645 * object, and calls the Array constructor. The Array constructor
12646 * returns an Array instance, which is used as the result value for
12647 * the "new" operation; the object created before the Array constructor
12648 * call is discarded.
12649 *
12650 * This would be easy to fix, e.g. by knowing that the Array constructor
12651 * will always create a replacement object and skip creating the fallback
12652 * object in that case.
12653 *
12654 * Note: functions called via "new" need to know they are called as a
12655 * constructor. For instance, built-in constructors behave differently
12656 * depending on how they are called.
12657 */
12658
12659 /* XXX: merge this with duk_js_call.c, as this function implements
12660 * core semantics (or perhaps merge the two files altogether).
12661 */
12662
12663 duk_hthread *thr = (duk_hthread *) ctx;
12665 duk_hobject *cons;
12666 duk_hobject *fallback;
12667 duk_idx_t idx_cons;
12668 duk_small_uint_t call_flags;
12669
12671
12672 /* [... constructor arg1 ... argN] */
12673
12674 idx_cons = duk_require_normalize_index(ctx, -nargs - 1);
12675
12676 DUK_DDD(DUK_DDDPRINT("top=%ld, nargs=%ld, idx_cons=%ld",
12677 (long) duk_get_top(ctx), (long) nargs, (long) idx_cons));
12678
12679 /* XXX: code duplication */
12680
12681 /*
12682 * Figure out the final, non-bound constructor, to get "prototype"
12683 * property.
12684 */
12685
12686 duk_dup(ctx, idx_cons);
12687 for (;;) {
12688 duk_tval *tv;
12689 tv = DUK_GET_TVAL_NEGIDX(ctx, -1);
12690 DUK_ASSERT(tv != NULL);
12691
12692 if (DUK_TVAL_IS_OBJECT(tv)) {
12693 cons = DUK_TVAL_GET_OBJECT(tv);
12694 DUK_ASSERT(cons != NULL);
12696 /* Checking callability of the immediate target
12697 * is important, same for constructability.
12698 * Checking it for functions down the bound
12699 * function chain is not strictly necessary
12700 * because .bind() should normally reject them.
12701 * But it's good to check anyway because it's
12702 * technically possible to edit the bound function
12703 * chain via internal keys.
12704 */
12705 goto not_constructable;
12706 }
12707 if (!DUK_HOBJECT_HAS_BOUND(cons)) {
12708 break;
12709 }
12710 } else if (DUK_TVAL_IS_LIGHTFUNC(tv)) {
12711 /* Lightfuncs cannot be bound. */
12712 break;
12713 } else {
12714 /* Anything else is not constructable. */
12715 goto not_constructable;
12716 }
12717 duk_get_prop_stridx(ctx, -1, DUK_STRIDX_INT_TARGET); /* -> [... cons target] */
12718 duk_remove(ctx, -2); /* -> [... target] */
12719 }
12720 DUK_ASSERT(duk_is_callable(ctx, -1));
12721 DUK_ASSERT(duk_is_lightfunc(ctx, -1) ||
12722 (duk_get_hobject(ctx, -1) != NULL && !DUK_HOBJECT_HAS_BOUND(duk_get_hobject(ctx, -1))));
12723
12724 /* [... constructor arg1 ... argN final_cons] */
12725
12726 /*
12727 * Create "fallback" object to be used as the object instance,
12728 * unless the constructor returns a replacement value.
12729 * Its internal prototype needs to be set based on "prototype"
12730 * property of the constructor.
12731 */
12732
12733 duk_push_object(ctx); /* class Object, extensible */
12734
12735 /* [... constructor arg1 ... argN final_cons fallback] */
12736
12738 proto = duk_get_hobject(ctx, -1);
12739 if (!proto) {
12740 DUK_DDD(DUK_DDDPRINT("constructor has no 'prototype' property, or value not an object "
12741 "-> leave standard Object prototype as fallback prototype"));
12742 } else {
12743 DUK_DDD(DUK_DDDPRINT("constructor has 'prototype' property with object value "
12744 "-> set fallback prototype to that value: %!iO", (duk_heaphdr *) proto));
12745 fallback = duk_get_hobject(ctx, -2);
12746 DUK_ASSERT(fallback != NULL);
12748 }
12749 duk_pop(ctx);
12750
12751 /* [... constructor arg1 ... argN final_cons fallback] */
12752
12753 /*
12754 * Manipulate callstack for the call.
12755 */
12756
12757 duk_dup_top(ctx);
12758 duk_insert(ctx, idx_cons + 1); /* use fallback as 'this' value */
12759 duk_insert(ctx, idx_cons); /* also stash it before constructor,
12760 * in case we need it (as the fallback value)
12761 */
12762 duk_pop(ctx); /* pop final_cons */
12763
12764
12765 /* [... fallback constructor fallback(this) arg1 ... argN];
12766 * Note: idx_cons points to first 'fallback', not 'constructor'.
12767 */
12768
12769 DUK_DDD(DUK_DDDPRINT("before call, idx_cons+1 (constructor) -> %!T, idx_cons+2 (fallback/this) -> %!T, "
12770 "nargs=%ld, top=%ld",
12771 (duk_tval *) duk_get_tval(ctx, idx_cons + 1),
12772 (duk_tval *) duk_get_tval(ctx, idx_cons + 2),
12773 (long) nargs,
12774 (long) duk_get_top(ctx)));
12775
12776 /*
12777 * Call the constructor function (called in "constructor mode").
12778 */
12779
12780 call_flags = DUK_CALL_FLAG_CONSTRUCTOR_CALL; /* not protected, respect reclimit, is a constructor call */
12781
12782 duk_handle_call_unprotected(thr, /* thread */
12783 nargs, /* num_stack_args */
12784 call_flags); /* call_flags */
12785
12786 /* [... fallback retval] */
12787
12788 DUK_DDD(DUK_DDDPRINT("constructor call finished, fallback=%!iT, retval=%!iT",
12789 (duk_tval *) duk_get_tval(ctx, -2),
12790 (duk_tval *) duk_get_tval(ctx, -1)));
12791
12792 /*
12793 * Determine whether to use the constructor return value as the created
12794 * object instance or not.
12795 */
12796
12797 if (duk_is_object(ctx, -1)) {
12798 duk_remove(ctx, -2);
12799 } else {
12800 duk_pop(ctx);
12801 }
12802
12803 /*
DUK_INTERNAL_DECL duk_int_t duk_handle_safe_call(duk_hthread *thr, duk_safe_call_function func, duk_idx_t num_stack_args, duk_idx_t num_stack_res)

◆ duk_next()

DUK_EXTERNAL duk_bool_t duk_next ( duk_context * ctx,
duk_idx_t enum_index,
duk_bool_t get_value )

Definition at line 14857 of file duktape-1.8.0/src/duktape.c.

14858 {
14859 /* Note: this may fail, caller should protect the call if necessary */
14860 duk_hobject_compact_props(thr, obj);
14861 }
14862}
14863

◆ DUK_NORETURN() [1/11]

DUK_NORETURN ( DUK_INTERNAL_DECL void duk_default_fatal_handlerduk_context *ctx, duk_errcode_t code, const char *msg)

◆ DUK_NORETURN() [2/11]

DUK_NORETURN ( DUK_INTERNAL_DECL void duk_default_panic_handlerduk_errcode_t code, const char *msg)

◆ DUK_NORETURN() [3/11]

DUK_NORETURN ( DUK_INTERNAL_DECL void duk_err_apiduk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message)

◆ DUK_NORETURN() [4/11]

DUK_NORETURN ( DUK_INTERNAL_DECL void duk_err_api_indexduk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t index)

◆ DUK_NORETURN() [5/11]

DUK_NORETURN ( DUK_INTERNAL_DECL void duk_err_create_and_throwduk_hthread *thr, duk_errcode_t code, const char *msg, const char *filename, duk_int_t line)

◆ DUK_NORETURN() [6/11]

DUK_NORETURN ( DUK_INTERNAL_DECL void duk_err_handle_errorduk_hthread *thr, const char *filename, duk_uint_t line_and_code, const char *msg)

◆ DUK_NORETURN() [7/11]

DUK_NORETURN ( DUK_INTERNAL_DECL void duk_err_handle_error_fmtduk_hthread *thr, const char *filename, duk_uint_t line_and_code, const char *fmt,...)

◆ DUK_NORETURN() [8/11]

DUK_NORETURN ( DUK_INTERNAL_DECL void duk_err_longjmpduk_hthread *thr)

◆ DUK_NORETURN() [9/11]

DUK_NORETURN ( DUK_INTERNAL_DECL void duk_err_require_type_indexduk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t index, const char *expect_name)

◆ DUK_NORETURN() [10/11]

DUK_NORETURN ( DUK_INTERNAL_DECL void duk_err_unimplemented_defmsgduk_hthread *thr, const char *filename, duk_int_t linenumber)

◆ DUK_NORETURN() [11/11]

DUK_NORETURN ( DUK_INTERNAL_DECL void duk_error_throw_from_negative_rcduk_hthread *thr, duk_ret_t rc)

◆ duk_normalize_index()

DUK_EXTERNAL duk_idx_t duk_normalize_index ( duk_context * ctx,
duk_idx_t index )

Definition at line 15187 of file duktape-1.8.0/src/duktape.c.

15188 {
15190 /* not reachable */
15191 }
15192 return 0;
15193}
15194
15195/*
15196 * Stack index validation/normalization and getting a stack duk_tval ptr.
15197 *
15198 * These are called by many API entrypoints so the implementations must be
15199 * fast and "inlined".
15200 *
15201 * There's some repetition because of this; keep the functions in sync.
15202 */
15203
15205 duk_hthread *thr = (duk_hthread *) ctx;
15206 duk_uidx_t vs_size;
15207 duk_uidx_t uindex;
15208
15211
15212 /* Care must be taken to avoid pointer wrapping in the index
15213 * validation. For instance, on a 32-bit platform with 8-byte
15214 * duk_tval the index 0x20000000UL would wrap the memory space
15215 * once.
15216 */
15217
15218 /* Assume value stack sizes (in elements) fits into duk_idx_t. */
15220 vs_size = (duk_uidx_t) (thr->valstack_top - thr->valstack_bottom);
15221 DUK_ASSERT_DISABLE(vs_size >= 0); /* unsigned */

References DUK_ERROR_REQUIRE_TYPE_INDEX, DUK_STR_NOT_NUMBER, and index.

Referenced by duk_get_top(), and duk_handle_ecma_call_setup().

◆ duk_numconv_parse()

DUK_INTERNAL_DECL void duk_numconv_parse ( duk_context * ctx,
duk_small_int_t radix,
duk_small_uint_t flags )

Definition at line 77130 of file duktape-1.8.0/src/duktape.c.

77147 {
77148 duk_hthread *thr = (duk_hthread *) ctx;
77149 duk__numconv_stringify_ctx nc_ctx_alloc; /* large context; around 2kB now */
77150 duk__numconv_stringify_ctx *nc_ctx = &nc_ctx_alloc;
77151 duk_double_t res;
77152 duk_hstring *h_str;
77153 duk_small_int_t expt;
77154 duk_small_int_t expt_neg;
77155 duk_small_int_t expt_adj;
77156 duk_small_int_t neg;
77157 duk_small_int_t dig;
77158 duk_small_int_t dig_whole;
77159 duk_small_int_t dig_lzero;
77160 duk_small_int_t dig_frac;
77161 duk_small_int_t dig_expt;
77162 duk_small_int_t dig_prec;
77163 const duk__exp_limits *explim;
77164 const duk_uint8_t *p;
77165 duk_small_int_t ch;
77166
77167 /* This seems to waste a lot of stack frame entries, but good compilers
77168 * will compute these as needed below. Some of these initial flags are
77169 * also modified in the code below, so they can't all be removed.
77170 */
77171 duk_small_int_t trim_white = (flags & DUK_S2N_FLAG_TRIM_WHITE);
77172 duk_small_int_t allow_expt = (flags & DUK_S2N_FLAG_ALLOW_EXP);
77173 duk_small_int_t allow_garbage = (flags & DUK_S2N_FLAG_ALLOW_GARBAGE);
77174 duk_small_int_t allow_plus = (flags & DUK_S2N_FLAG_ALLOW_PLUS);
77175 duk_small_int_t allow_minus = (flags & DUK_S2N_FLAG_ALLOW_MINUS);
77176 duk_small_int_t allow_infinity = (flags & DUK_S2N_FLAG_ALLOW_INF);
77177 duk_small_int_t allow_frac = (flags & DUK_S2N_FLAG_ALLOW_FRAC);
77178 duk_small_int_t allow_naked_frac = (flags & DUK_S2N_FLAG_ALLOW_NAKED_FRAC);
77179 duk_small_int_t allow_empty_frac = (flags & DUK_S2N_FLAG_ALLOW_EMPTY_FRAC);
77180 duk_small_int_t allow_empty = (flags & DUK_S2N_FLAG_ALLOW_EMPTY_AS_ZERO);
77181 duk_small_int_t allow_leading_zero = (flags & DUK_S2N_FLAG_ALLOW_LEADING_ZERO);
77182 duk_small_int_t allow_auto_hex_int = (flags & DUK_S2N_FLAG_ALLOW_AUTO_HEX_INT);
77183 duk_small_int_t allow_auto_oct_int = (flags & DUK_S2N_FLAG_ALLOW_AUTO_OCT_INT);
77184
77185 DUK_DDD(DUK_DDDPRINT("parse number: %!T, radix=%ld, flags=0x%08lx",
77186 (duk_tval *) duk_get_tval(ctx, -1),
77187 (long) radix, (unsigned long) flags));
77188
77189 DUK_ASSERT(radix >= 2 && radix <= 36);
77191
77192 /*
77193 * Preliminaries: trim, sign, Infinity check
77194 *
77195 * We rely on the interned string having a NUL terminator, which will
77196 * cause a parse failure wherever it is encountered. As a result, we
77197 * don't need separate pointer checks.
77198 *
77199 * There is no special parsing for 'NaN' in the specification although
77200 * 'Infinity' (with an optional sign) is allowed in some contexts.
77201 * Some contexts allow plus/minus sign, while others only allow the
77202 * minus sign (like JSON.parse()).
77203 *
77204 * Automatic hex number detection (leading '0x' or '0X') and octal
77205 * number detection (leading '0' followed by at least one octal digit)
77206 * is done here too.
77207 */
77208
77209 if (trim_white) {
77210 /* Leading / trailing whitespace is sometimes accepted and
77211 * sometimes not. After white space trimming, all valid input
77212 * characters are pure ASCII.
77213 */
77214 duk_trim(ctx, -1);
77215 }
77216 h_str = duk_require_hstring(ctx, -1);
77217 DUK_ASSERT(h_str != NULL);
77218 p = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_str);
77219
77220 neg = 0;
77221 ch = *p;
77222 if (ch == (duk_small_int_t) '+') {
77223 if (!allow_plus) {
77224 DUK_DDD(DUK_DDDPRINT("parse failed: leading plus sign not allowed"));
77225 goto parse_fail;
77226 }
77227 p++;
77228 } else if (ch == (duk_small_int_t) '-') {
77229 if (!allow_minus) {
77230 DUK_DDD(DUK_DDDPRINT("parse failed: leading minus sign not allowed"));
77231 goto parse_fail;
77232 }
77233 p++;
77234 neg = 1;
77235 }
77236
77237 ch = *p;
77238 if (allow_infinity && ch == (duk_small_int_t) 'I') {
77239 /* Don't check for Infinity unless the context allows it.
77240 * 'Infinity' is a valid integer literal in e.g. base-36:
77241 *
77242 * parseInt('Infinity', 36)
77243 * 1461559270678
77244 */
77245
77246 const duk_uint8_t *q;
77247
77248 /* borrow literal Infinity from builtin string */
77249 q = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(DUK_HTHREAD_STRING_INFINITY(thr));
77250 if (DUK_STRNCMP((const char *) p, (const char *) q, 8) == 0) {
77251 if (!allow_garbage && (p[8] != (duk_uint8_t) 0)) {
77252 DUK_DDD(DUK_DDDPRINT("parse failed: trailing garbage after matching 'Infinity' not allowed"));
77253 goto parse_fail;
77254 } else {
77255 res = DUK_DOUBLE_INFINITY;
77256 goto negcheck_and_ret;
77257 }
77258 }
77259 }
77260 if (ch == (duk_small_int_t) '0') {
77261 duk_small_int_t detect_radix = 0;
77262 ch = p[1];
77263 if (allow_auto_hex_int && (ch == (duk_small_int_t) 'x' || ch == (duk_small_int_t) 'X')) {
77264 DUK_DDD(DUK_DDDPRINT("detected 0x/0X hex prefix, changing radix and preventing fractions and exponent"));
77265 detect_radix = 16;
77266 allow_empty = 0; /* interpret e.g. '0x' and '0xg' as a NaN (= parse error) */
77267 p += 2;
77268 } else if (allow_auto_oct_int && (ch >= (duk_small_int_t) '0' && ch <= (duk_small_int_t) '9')) {
77269 DUK_DDD(DUK_DDDPRINT("detected 0n oct prefix, changing radix and preventing fractions and exponent"));
77270 detect_radix = 8;
77271 allow_empty = 1; /* interpret e.g. '09' as '0', not NaN */
77272 p += 1;
77273 }
77274 if (detect_radix > 0) {
77275 radix = detect_radix;
77276 allow_expt = 0;
77277 allow_frac = 0;
77278 allow_naked_frac = 0;
77279 allow_empty_frac = 0;
77280 allow_leading_zero = 1; /* allow e.g. '0x0009' and '00077' */
77281 }
77282 }
77283
77284 /*
77285 * Scan number and setup for Dragon4.
77286 *
77287 * The fast path case is detected during setup: an integer which
77288 * can be converted without rounding, no net exponent. The fast
77289 * path could be implemented as a separate scan, but may not really
77290 * be worth it: the multiplications for building 'f' are not
77291 * expensive when 'f' is small.
77292 *
77293 * The significand ('f') must contain enough bits of (apparent)
77294 * accuracy, so that Dragon4 will generate enough binary output digits.
77295 * For decimal numbers, this means generating a 20-digit significand,
77296 * which should yield enough practical accuracy to parse IEEE doubles.
77297 * In fact, the Ecmascript specification explicitly allows an
77298 * implementation to treat digits beyond 20 as zeroes (and even
77299 * to round the 20th digit upwards). For non-decimal numbers, the
77300 * appropriate number of digits has been precomputed for comparable
77301 * accuracy.
77302 *
77303 * Digit counts:
77304 *
77305 * [ dig_lzero ]
77306 * |
77307 * .+-..---[ dig_prec ]----.
77308 * | || |
77309 * 0000123.456789012345678901234567890e+123456
77310 * | | | | | |
77311 * `--+--' `------[ dig_frac ]-------' `-+--'
77312 * | |
77313 * [ dig_whole ] [ dig_expt ]
77314 *
77315 * dig_frac and dig_expt are -1 if not present
77316 * dig_lzero is only computed for whole number part
77317 *
77318 * Parsing state
77319 *
77320 * Parsing whole part dig_frac < 0 AND dig_expt < 0
77321 * Parsing fraction part dig_frac >= 0 AND dig_expt < 0
77322 * Parsing exponent part dig_expt >= 0 (dig_frac may be < 0 or >= 0)
77323 *
77324 * Note: in case we hit an implementation limit (like exponent range),
77325 * we should throw an error, NOT return NaN or Infinity. Even with
77326 * very large exponent (or significand) values the final result may be
77327 * finite, so NaN/Infinity would be incorrect.
77328 */
77329
77330 duk__bi_set_small(&nc_ctx->f, 0);
77331 dig_prec = 0;
77332 dig_lzero = 0;
77333 dig_whole = 0;
77334 dig_frac = -1;
77335 dig_expt = -1;
77336 expt = 0;
77337 expt_adj = 0; /* essentially tracks digit position of lowest 'f' digit */
77338 expt_neg = 0;
77339 for (;;) {
77340 ch = *p++;
77341
77342 DUK_DDD(DUK_DDDPRINT("parse digits: p=%p, ch='%c' (%ld), expt=%ld, expt_adj=%ld, "
77343 "dig_whole=%ld, dig_frac=%ld, dig_expt=%ld, dig_lzero=%ld, dig_prec=%ld",
77344 (const void *) p, (int) ((ch >= 0x20 && ch <= 0x7e) ? ch : '?'), (long) ch,
77345 (long) expt, (long) expt_adj, (long) dig_whole, (long) dig_frac,
77346 (long) dig_expt, (long) dig_lzero, (long) dig_prec));
77347 DUK__BI_PRINT("f", &nc_ctx->f);
77348
77349 /* Most common cases first. */
77350 if (ch >= (duk_small_int_t) '0' && ch <= (duk_small_int_t) '9') {
77351 dig = (int) ch - '0' + 0;
77352 } else if (ch == (duk_small_int_t) '.') {
77353 /* A leading digit is not required in some cases, e.g. accept ".123".
77354 * In other cases (JSON.parse()) a leading digit is required. This
77355 * is checked for after the loop.
77356 */
77357 if (dig_frac >= 0 || dig_expt >= 0) {
77358 if (allow_garbage) {
77359 DUK_DDD(DUK_DDDPRINT("garbage termination (invalid period)"));
77360 break;
77361 } else {
77362 DUK_DDD(DUK_DDDPRINT("parse failed: period not allowed"));
77363 goto parse_fail;
77364 }
77365 }
77366
77367 if (!allow_frac) {
77368 /* Some contexts don't allow fractions at all; this can't be a
77369 * post-check because the state ('f' and expt) would be incorrect.
77370 */
77371 if (allow_garbage) {
77372 DUK_DDD(DUK_DDDPRINT("garbage termination (invalid first period)"));
77373 break;
77374 } else {
77375 DUK_DDD(DUK_DDDPRINT("parse failed: fraction part not allowed"));
77376 }
77377 }
77378
77379 DUK_DDD(DUK_DDDPRINT("start fraction part"));
77380 dig_frac = 0;
77381 continue;
77382 } else if (ch == (duk_small_int_t) 0) {
77383 DUK_DDD(DUK_DDDPRINT("NUL termination"));
77384 break;
77385 } else if (allow_expt && dig_expt < 0 && (ch == (duk_small_int_t) 'e' || ch == (duk_small_int_t) 'E')) {
77386 /* Note: we don't parse back exponent notation for anything else
77387 * than radix 10, so this is not an ambiguous check (e.g. hex
77388 * exponent values may have 'e' either as a significand digit
77389 * or as an exponent separator).
77390 *
77391 * If the exponent separator occurs twice, 'e' will be interpreted
77392 * as a digit (= 14) and will be rejected as an invalid decimal
77393 * digit.
77394 */
77395
77396 DUK_DDD(DUK_DDDPRINT("start exponent part"));
77397
77398 /* Exponent without a sign or with a +/- sign is accepted
77399 * by all call sites (even JSON.parse()).
77400 */
77401 ch = *p;
77402 if (ch == (duk_small_int_t) '-') {
77403 expt_neg = 1;
77404 p++;
77405 } else if (ch == (duk_small_int_t) '+') {
77406 p++;
77407 }
77408 dig_expt = 0;
77409 continue;
77410 } else if (ch >= (duk_small_int_t) 'a' && ch <= (duk_small_int_t) 'z') {
77411 dig = (duk_small_int_t) (ch - (duk_small_int_t) 'a' + 0x0a);
77412 } else if (ch >= (duk_small_int_t) 'A' && ch <= (duk_small_int_t) 'Z') {
77413 dig = (duk_small_int_t) (ch - (duk_small_int_t) 'A' + 0x0a);
77414 } else {
77415 dig = 255; /* triggers garbage digit check below */
77416 }
77417 DUK_ASSERT((dig >= 0 && dig <= 35) || dig == 255);
77418
77419 if (dig >= radix) {
77420 if (allow_garbage) {
77421 DUK_DDD(DUK_DDDPRINT("garbage termination"));
77422 break;
77423 } else {
77424 DUK_DDD(DUK_DDDPRINT("parse failed: trailing garbage or invalid digit"));
77425 goto parse_fail;
77426 }
77427 }
77428
77429 if (dig_expt < 0) {
77430 /* whole or fraction digit */
77431
77432 if (dig_prec < duk__str2num_digits_for_radix[radix - 2]) {
77433 /* significant from precision perspective */
77434
77435 duk_small_int_t f_zero = duk__bi_is_zero(&nc_ctx->f);
77436 if (f_zero && dig == 0) {
77437 /* Leading zero is not counted towards precision digits; not
77438 * in the integer part, nor in the fraction part.
77439 */
77440 if (dig_frac < 0) {
77441 dig_lzero++;
77442 }
77443 } else {
77444 /* XXX: join these ops (multiply-accumulate), but only if
77445 * code footprint decreases.
77446 */
77447 duk__bi_mul_small(&nc_ctx->t1, &nc_ctx->f, radix);
77448 duk__bi_add_small(&nc_ctx->f, &nc_ctx->t1, dig);
77449 dig_prec++;
77450 }
77451 } else {
77452 /* Ignore digits beyond a radix-specific limit, but note them
77453 * in expt_adj.
77454 */
77455 expt_adj++;
77456 }
77457
77458 if (dig_frac >= 0) {
77459 dig_frac++;
77460 expt_adj--;
77461 } else {
77462 dig_whole++;
77463 }
77464 } else {
77465 /* exponent digit */
77466
77467 expt = expt * radix + dig;
77468 if (expt > DUK_S2N_MAX_EXPONENT) {
77469 /* impose a reasonable exponent limit, so that exp
77470 * doesn't need to get tracked using a bigint.
77471 */
77472 DUK_DDD(DUK_DDDPRINT("parse failed: exponent too large"));
77473 goto parse_explimit_error;
77474 }
77475 dig_expt++;
77476 }
77477 }
77478
77479 /* Leading zero. */
77480
77481 if (dig_lzero > 0 && dig_whole > 1) {
77482 if (!allow_leading_zero) {
77483 DUK_DDD(DUK_DDDPRINT("parse failed: leading zeroes not allowed in integer part"));
77484 goto parse_fail;
77485 }
77486 }
77487
77488 /* Validity checks for various fraction formats ("0.1", ".1", "1.", "."). */
77489
77490 if (dig_whole == 0) {
77491 if (dig_frac == 0) {
77492 /* "." is not accepted in any format */
77493 DUK_DDD(DUK_DDDPRINT("parse failed: plain period without leading or trailing digits"));
77494 goto parse_fail;
77495 } else if (dig_frac > 0) {
77496 /* ".123" */
77497 if (!allow_naked_frac) {
77498 DUK_DDD(DUK_DDDPRINT("parse failed: fraction part not allowed without "
77499 "leading integer digit(s)"));
77500 goto parse_fail;
77501 }
77502 } else {
77503 /* empty ("") is allowed in some formats (e.g. Number(''), as zero */
77504 if (!allow_empty) {
77505 DUK_DDD(DUK_DDDPRINT("parse failed: empty string not allowed (as zero)"));
77506 goto parse_fail;
77507 }
77508 }
77509 } else {
77510 if (dig_frac == 0) {
77511 /* "123." is allowed in some formats */
77512 if (!allow_empty_frac) {
77513 DUK_DDD(DUK_DDDPRINT("parse failed: empty fractions"));
77514 goto parse_fail;
77515 }
77516 } else if (dig_frac > 0) {
77517 /* "123.456" */
77518 ;
77519 } else {
77520 /* "123" */
77521 ;
77522 }
77523 }
77524
77525 /* Exponent without digits (e.g. "1e" or "1e+"). If trailing garbage is
77526 * allowed, ignore exponent part as garbage (= parse as "1", i.e. exp 0).
77527 */
77528
77529 if (dig_expt == 0) {
77530 if (!allow_garbage) {
77531 DUK_DDD(DUK_DDDPRINT("parse failed: empty exponent"));
77532 goto parse_fail;
77533 }
77534 DUK_ASSERT(expt == 0);
77535 }
77536
77537 if (expt_neg) {
77538 expt = -expt;
77539 }
77540 DUK_DDD(DUK_DDDPRINT("expt=%ld, expt_adj=%ld, net exponent -> %ld",
77541 (long) expt, (long) expt_adj, (long) (expt + expt_adj)));
77542 expt += expt_adj;
77543
77544 /* Fast path check. */
77545
77546 if (nc_ctx->f.n <= 1 && /* 32-bit value */
77547 expt == 0 /* no net exponent */) {
77548 /* Fast path is triggered for no exponent and also for balanced exponent
77549 * and fraction parts, e.g. for "1.23e2" == "123". Remember to respect
77550 * zero sign.
77551 */
77552
77553 /* XXX: could accept numbers larger than 32 bits, e.g. up to 53 bits? */
77554 DUK_DDD(DUK_DDDPRINT("fast path number parse"));
77555 if (nc_ctx->f.n == 1) {
77556 res = (double) nc_ctx->f.v[0];
77557 } else {
77558 res = 0.0;
77559 }
77560 goto negcheck_and_ret;
77561 }
77562
77563 /* Significand ('f') padding. */
77564
77565 while (dig_prec < duk__str2num_digits_for_radix[radix - 2]) {
77566 /* Pad significand with "virtual" zero digits so that Dragon4 will
77567 * have enough (apparent) precision to work with.
77568 */
77569 DUK_DDD(DUK_DDDPRINT("dig_prec=%ld, pad significand with zero", (long) dig_prec));
77570 duk__bi_mul_small_copy(&nc_ctx->f, radix, &nc_ctx->t1);
77571 DUK__BI_PRINT("f", &nc_ctx->f);
77572 expt--;
77573 dig_prec++;
77574 }
77575
77576 DUK_DDD(DUK_DDDPRINT("final exponent: %ld", (long) expt));
77577
77578 /* Detect zero special case. */
77579
77580 if (nc_ctx->f.n == 0) {
77581 /* This may happen even after the fast path check, if exponent is
77582 * not balanced (e.g. "0e1"). Remember to respect zero sign.
77583 */
77584 DUK_DDD(DUK_DDDPRINT("significand is zero"));
77585 res = 0.0;
77586 goto negcheck_and_ret;
77587 }
77588
77589
77590 /* Quick reject of too large or too small exponents. This check
77591 * would be incorrect for zero (e.g. "0e1000" is zero, not Infinity)
77592 * so zero check must be above.
77593 */
77594
77595 explim = &duk__str2num_exp_limits[radix - 2];
77596 if (expt > explim->upper) {
77597 DUK_DDD(DUK_DDDPRINT("exponent too large -> infinite"));
77599 goto negcheck_and_ret;
77600 } else if (expt < explim->lower) {
77601 DUK_DDD(DUK_DDDPRINT("exponent too small -> zero"));
77602 res = (duk_double_t) 0.0;
77603 goto negcheck_and_ret;
77604 }
77605
77606 nc_ctx->is_s2n = 1;
77607 nc_ctx->e = expt;
77608 nc_ctx->b = radix;
77609 nc_ctx->B = 2;
77610 nc_ctx->is_fixed = 1;
77611 nc_ctx->abs_pos = 0;
77612 nc_ctx->req_digits = 53 + 1;
77613
77614 DUK__BI_PRINT("f", &nc_ctx->f);
77615 DUK_DDD(DUK_DDDPRINT("e=%ld", (long) nc_ctx->e));
77616
77617 /*
77618 * Dragon4 slow path (binary) digit generation.
77619 * An extra digit is generated for rounding.
77620 */
77621
77622 duk__dragon4_prepare(nc_ctx); /* setup many variables in nc_ctx */
77623
77624 DUK_DDD(DUK_DDDPRINT("after prepare:"));
77625 DUK__BI_PRINT("r", &nc_ctx->r);
77626 DUK__BI_PRINT("s", &nc_ctx->s);
77627 DUK__BI_PRINT("mp", &nc_ctx->mp);
77628 DUK__BI_PRINT("mm", &nc_ctx->mm);
77629
77630 duk__dragon4_scale(nc_ctx);
77631
77632 DUK_DDD(DUK_DDDPRINT("after scale; k=%ld", (long) nc_ctx->k));
77633 DUK__BI_PRINT("r", &nc_ctx->r);
77634 DUK__BI_PRINT("s", &nc_ctx->s);
77635 DUK__BI_PRINT("mp", &nc_ctx->mp);
77636 DUK__BI_PRINT("mm", &nc_ctx->mm);
77637
77638 duk__dragon4_generate(nc_ctx);
77639
77640 DUK_ASSERT(nc_ctx->count == 53 + 1);
77641
77642 /*
77643 * Convert binary digits into an IEEE double. Need to handle
77644 * denormals and rounding correctly.
77645 */
77646
77647 duk__dragon4_ctx_to_double(nc_ctx, &res);
77648 goto negcheck_and_ret;
77649
77650 negcheck_and_ret:
77651 if (neg) {
77652 res = -res;
DUK_LOCAL void duk__bi_add_small(duk__bigint *x, duk__bigint *y, duk_uint32_t z)
DUK_LOCAL int duk__bi_is_zero(duk__bigint *x)
DUK_LOCAL const duk__exp_limits duk__str2num_exp_limits[]
DUK_LOCAL const duk_uint8_t duk__str2num_digits_for_radix[]
#define DUK_S2N_FLAG_ALLOW_EMPTY_AS_ZERO
#define DUK_S2N_MAX_EXPONENT
#define DUK_S2N_FLAG_ALLOW_INF
DUK_LOCAL void duk__dragon4_scale(duk__numconv_stringify_ctx *nc_ctx)
#define DUK_HTHREAD_STRING_INFINITY(thr)

Referenced by duk_lexer_parse_js_input_element().

◆ duk_numconv_stringify()

DUK_INTERNAL_DECL void duk_numconv_stringify ( duk_context * ctx,
duk_small_int_t radix,
duk_small_int_t digits,
duk_small_uint_t flags )

Definition at line 76927 of file duktape-1.8.0/src/duktape.c.

76930 : %08lx %08lx",
76931 (unsigned long) DUK_DBLUNION_GET_HIGH32(&u),
76932 (unsigned long) DUK_DBLUNION_GET_LOW32(&u)));
76933
76934 *x = DUK_DBLUNION_GET_DOUBLE(&u);
76935}
76936
76937/*
76938 * Exposed number-to-string API
76939 *
76940 * Input: [ number ]
76941 * Output: [ string ]
76942 */
76943
76944DUK_INTERNAL void duk_numconv_stringify(duk_context *ctx, duk_small_int_t radix, duk_small_int_t digits, duk_small_uint_t flags) {
76945 duk_double_t x;
76946 duk_small_int_t c;
76947 duk_small_int_t neg;
76948 duk_uint32_t uval;
76949 duk__numconv_stringify_ctx nc_ctx_alloc; /* large context; around 2kB now */
76950 duk__numconv_stringify_ctx *nc_ctx = &nc_ctx_alloc;
76951
76952 x = (duk_double_t) duk_require_number(ctx, -1);
76953 duk_pop(ctx);
76954
76955 /*
76956 * Handle special cases (NaN, infinity, zero).
76957 */
76958
76959 c = (duk_small_int_t) DUK_FPCLASSIFY(x);
76960 if (DUK_SIGNBIT((double) x)) {
76961 x = -x;
76962 neg = 1;
76963 } else {
76964 neg = 0;
76965 }
76966
76967 /* NaN sign bit is platform specific with unpacked, un-normalized NaNs */
76968 DUK_ASSERT(c == DUK_FP_NAN || DUK_SIGNBIT((double) x) == 0);
76969
76970 if (c == DUK_FP_NAN) {
76971 duk_push_hstring_stridx(ctx, DUK_STRIDX_NAN);
76972 return;
76973 } else if (c == DUK_FP_INFINITE) {
76974 if (neg) {
76975 /* -Infinity */
76976 duk_push_hstring_stridx(ctx, DUK_STRIDX_MINUS_INFINITY);
76977 } else {
76978 /* Infinity */
76979 duk_push_hstring_stridx(ctx, DUK_STRIDX_INFINITY);
76980 }
76981 return;
76982 } else if (c == DUK_FP_ZERO) {
76983 /* We can't shortcut zero here if it goes through special formatting
76984 * (such as forced exponential notation).
76985 */
76986 ;
76987 }
76988
76989 /*
76990 * Handle integers in 32-bit range (that is, [-(2**32-1),2**32-1])
76991 * specially, as they're very likely for embedded programs. This
76992 * is now done for all radix values. We must be careful not to use
76993 * the fast path when special formatting (e.g. forced exponential)
76994 * is in force.
76995 *
76996 * XXX: could save space by supporting radix 10 only and using
76997 * sprintf "%lu" for the fast path and for exponent formatting.
76998 */
76999
77000 uval = (unsigned int) x;
77001 if (((double) uval) == x && /* integer number in range */
77002 flags == 0) { /* no special formatting */
77003 /* use bigint area as a temp */
77004 duk_uint8_t *buf = (duk_uint8_t *) (&nc_ctx->f);
77005 duk_uint8_t *p = buf;
77006
77007 DUK_ASSERT(DUK__NUMCONV_CTX_BIGINTS_SIZE >= 32 + 1); /* max size: radix=2 + sign */
77008 if (neg && uval != 0) {
77009 /* no negative sign for zero */
77010 *p++ = (duk_uint8_t) '-';
77011 }
77012 p += duk__dragon4_format_uint32(p, uval, radix);
77013 duk_push_lstring(ctx, (const char *) buf, (duk_size_t) (p - buf));
77014 return;
77015 }
77016
77017 /*
77018 * Dragon4 setup.
77019 *
77020 * Convert double from IEEE representation for conversion;
77021 * normal finite values have an implicit leading 1-bit. The
77022 * slow path algorithm doesn't handle zero, so zero is special
77023 * cased here but still creates a valid nc_ctx, and goes
77024 * through normal formatting in case special formatting has
77025 * been requested (e.g. forced exponential format: 0 -> "0e+0").
77026 */
77027
77028 /* Would be nice to bulk clear the allocation, but the context
77029 * is 1-2 kilobytes and nothing should rely on it being zeroed.
77030 */
77031#if 0
77032 DUK_MEMZERO((void *) nc_ctx, sizeof(*nc_ctx)); /* slow init, do only for slow path cases */
77033#endif
77034
77035 nc_ctx->is_s2n = 0;
77036 nc_ctx->b = 2;
77037 nc_ctx->B = radix;
77038 nc_ctx->abs_pos = 0;
77039 if (flags & DUK_N2S_FLAG_FIXED_FORMAT) {
77040 nc_ctx->is_fixed = 1;
77041 if (flags & DUK_N2S_FLAG_FRACTION_DIGITS) {
77042 /* absolute req_digits; e.g. digits = 1 -> last digit is 0,
77043 * but add an extra digit for rounding.
77044 */
77045 nc_ctx->abs_pos = 1;
77046 nc_ctx->req_digits = (-digits + 1) - 1;
77047 } else {
77048 nc_ctx->req_digits = digits + 1;
77049 }
77050 } else {
77051 nc_ctx->is_fixed = 0;
77052 nc_ctx->req_digits = 0;
77053 }
77054
77055 if (c == DUK_FP_ZERO) {
77056 /* Zero special case: fake requested number of zero digits; ensure
77057 * no sign bit is printed. Relative and absolute fixed format
77058 * require separate handling.
77059 */
77060 duk_small_int_t count;
77061 if (nc_ctx->is_fixed) {
77062 if (nc_ctx->abs_pos) {
77063 count = digits + 2; /* lead zero + 'digits' fractions + 1 for rounding */
77064 } else {
77065 count = digits + 1; /* + 1 for rounding */
77066 }
77067 } else {
77068 count = 1;
77069 }
77070 DUK_DDD(DUK_DDDPRINT("count=%ld", (long) count));
77071 DUK_ASSERT(count >= 1);
77072 DUK_MEMZERO((void *) nc_ctx->digits, count);
77073 nc_ctx->count = count;
77074 nc_ctx->k = 1; /* 0.000... */
77075 neg = 0;
77076 goto zero_skip;
77077 }
77078
77079 duk__dragon4_double_to_ctx(nc_ctx, x); /* -> sets 'f' and 'e' */
77080 DUK__BI_PRINT("f", &nc_ctx->f);
77081 DUK_DDD(DUK_DDDPRINT("e=%ld", (long) nc_ctx->e));
77082
77083 /*
77084 * Dragon4 slow path digit generation.
77085 */
77086
77087 duk__dragon4_prepare(nc_ctx); /* setup many variables in nc_ctx */
77088
77089 DUK_DDD(DUK_DDDPRINT("after prepare:"));
77090 DUK__BI_PRINT("r", &nc_ctx->r);
77091 DUK__BI_PRINT("s", &nc_ctx->s);
77092 DUK__BI_PRINT("mp", &nc_ctx->mp);
77093 DUK__BI_PRINT("mm", &nc_ctx->mm);
77094
77095 duk__dragon4_scale(nc_ctx);
77096
77097 DUK_DDD(DUK_DDDPRINT("after scale; k=%ld", (long) nc_ctx->k));
77098 DUK__BI_PRINT("r", &nc_ctx->r);
77099 DUK__BI_PRINT("s", &nc_ctx->s);
77100 DUK__BI_PRINT("mp", &nc_ctx->mp);
77101 DUK__BI_PRINT("mm", &nc_ctx->mm);
77102
77103 duk__dragon4_generate(nc_ctx);
77104
77105 /*
77106 * Convert and push final string.
77107 */
77108
77109 zero_skip:
77110
77111 if (flags & DUK_N2S_FLAG_FIXED_FORMAT) {
77112 /* Perform fixed-format rounding. */
77113 duk_small_int_t roundpos;
77114 if (flags & DUK_N2S_FLAG_FRACTION_DIGITS) {
77115 /* 'roundpos' is relative to nc_ctx->k and increases to the right
77116 * (opposite of how 'k' changes).
77117 */
77118 roundpos = -digits; /* absolute position for digit considered for rounding */

◆ duk_pcall()

DUK_EXTERNAL duk_int_t duk_pcall ( duk_context * ctx,
duk_idx_t nargs )

Definition at line 12482 of file duktape-1.8.0/src/duktape.c.

12490 {
12492 }
12493
12494 duk__call_prop_prep_stack(ctx, obj_index, nargs);
12495
12496 duk_call_method(ctx, nargs);
12497}
12498
12500 duk_hthread *thr = (duk_hthread *) ctx;
12501 duk_small_uint_t call_flags;
12502 duk_idx_t idx_func;
12503 duk_int_t rc;
12504
12506 DUK_ASSERT(thr != NULL);
12507
12508 idx_func = duk_get_top(ctx) - nargs - 1; /* must work for nargs <= 0 */
12509 if (idx_func < 0 || nargs < 0) {
12510 /* We can't reliably pop anything here because the stack input
12511 * shape is incorrect. So we throw an error; if the caller has
12512 * no catch point for this, a fatal error will occur. Another
12513 * alternative would be to just return an error. But then the
12514 * stack would be in an unknown state which might cause some
12515 * very hard to diagnose problems later on. Also note that even
12516 * if we did not throw an error here, the underlying call handler
12517 * might STILL throw an out-of-memory error or some other internal
12518 * fatal error.

◆ duk_pcall_method()

DUK_EXTERNAL duk_int_t duk_pcall_method ( duk_context * ctx,
duk_idx_t nargs )

Definition at line 12520 of file duktape-1.8.0/src/duktape.c.

12537 {
12538 duk_hthread *thr = (duk_hthread *) ctx;
12539 duk_small_uint_t call_flags;
12540 duk_idx_t idx_func;
12541 duk_int_t rc;
12542

◆ duk_pcall_prop()

DUK_EXTERNAL duk_int_t duk_pcall_prop ( duk_context * ctx,
duk_idx_t obj_index,
duk_idx_t nargs )

Definition at line 12565 of file duktape-1.8.0/src/duktape.c.

12582 {
12583 /*
12584 * Must be careful to catch errors related to value stack manipulation

◆ duk_pnew()

DUK_EXTERNAL duk_int_t duk_pnew ( duk_context * ctx,
duk_idx_t nargs )

Definition at line 12815 of file duktape-1.8.0/src/duktape.c.

12818 :
12820}
12821
12823 duk_uint_t nargs;
12824
12825 nargs = duk_to_uint(ctx, -1);
12826 duk_pop(ctx);
12827
12828 duk_new(ctx, nargs);
12829 return 1;
12830}
12831
12833 duk_int_t rc;
12834
#define DUK_STR_NOT_CONSTRUCTABLE
DUK_EXTERNAL duk_uint_t duk_to_uint(duk_context *ctx, duk_idx_t index)
DUK_EXTERNAL duk_int_t duk_pnew(duk_context *ctx, duk_idx_t nargs)

◆ duk_pop()

◆ duk_pop_2()

◆ duk_pop_3()

DUK_EXTERNAL void duk_pop_3 ( duk_context * ctx)

Definition at line 19433 of file duktape-1.8.0/src/duktape.c.

◆ duk_pop_n()

DUK_EXTERNAL void duk_pop_n ( duk_context * ctx,
duk_idx_t count )

Definition at line 19349 of file duktape-1.8.0/src/duktape.c.

19353 {
19354 duk_hthread *thr = (duk_hthread *) ctx;
19356 DUK_ASSERT(thr != NULL);
19357 DUK_ASSERT(builtin_idx >= 0 && builtin_idx < DUK_NUM_BUILTINS);
19358 DUK_ASSERT(thr->builtins[builtin_idx] != NULL);
19359 duk_push_hobject(ctx, thr->builtins[builtin_idx]);
19360}
19361
19362/*
19363 * Poppers
19364 */
19365
19366DUK_EXTERNAL void duk_pop_n(duk_context *ctx, duk_idx_t count) {
19367 duk_hthread *thr = (duk_hthread *) ctx;
19368 duk_tval *tv;
19369
19371
19372 if (DUK_UNLIKELY(count < 0)) {
19374 return;
19375 }
19376
19378 if (DUK_UNLIKELY((duk_size_t) (thr->valstack_top - thr->valstack_bottom) < (duk_size_t) count)) {
19380 }
19381
19382 /*
19383 * Must be very careful here, every DECREF may cause reallocation
19384 * of our valstack.
19385 */
19386
19387 /* XXX: inlined DECREF macro would be nice here: no NULL check,
19388 * refzero queueing but no refzero algorithm run (= no pointer
19389 * instability), inline code.
19390 */
19391
19392 /* XXX: optimize loops */
19393
19394#if defined(DUK_USE_REFERENCE_COUNTING)
19395 while (count > 0) {
19396 count--;

Referenced by duk__error_getter_helper(), duk__realloc_props(), duk_debugger_pause(), duk_hobject_get_length(), and duk_hobject_putprop().

◆ duk_push_array()

DUK_EXTERNAL duk_idx_t duk_push_array ( duk_context * ctx)

Definition at line 18622 of file duktape-1.8.0/src/duktape.c.

18630 {
18632
18633 return duk_push_object_helper(ctx,
18637}
18638
18640 duk_hthread *thr = (duk_hthread *) ctx;
18641 duk_hobject *obj;
18642 duk_idx_t ret;
18643
18645
18646 ret = duk_push_object_helper(ctx,
18651
18652 obj = duk_require_hobject(ctx, ret);
18653
18654 /*
18655 * An array must have a 'length' property (E5 Section 15.4.5.2).
18656 * The special array behavior flag must only be enabled once the
18657 * length property has been added.
18658 *
#define DUK_BIDX_ARRAY_PROTOTYPE

Referenced by duk_bi_duktape_object_info().

◆ duk_push_boolean()

DUK_EXTERNAL void duk_push_boolean ( duk_context * ctx,
duk_bool_t val )

Definition at line 18037 of file duktape-1.8.0/src/duktape.c.

18043 {
18044 duk_hthread *thr;
18045 duk_tval *tv_slot;
18046
18048 thr = (duk_hthread *) ctx;

Referenced by duk_bi_array_prototype_to_string(), duk_bi_global_object_decode_uri(), and duk_bi_object_constructor_is_extensible().

◆ duk_push_buffer_object()

DUK_EXTERNAL void duk_push_buffer_object ( duk_context * ctx,
duk_idx_t idx_buffer,
duk_size_t byte_offset,
duk_size_t byte_length,
duk_uint_t flags )

Definition at line 18958 of file duktape-1.8.0/src/duktape.c.

18969 {
18971};
18972#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
18973#undef DUK__PACK_ARGS
18974
18975DUK_EXTERNAL void duk_push_buffer_object(duk_context *ctx, duk_idx_t idx_buffer, duk_size_t byte_offset, duk_size_t byte_length, duk_uint_t flags) {
18976 duk_hthread *thr;
18977 duk_hbufferobject *h_bufobj;
18978 duk_hbuffer *h_val;
18979 duk_uint32_t tmp;
18980 duk_uint_t classnum;
18981 duk_uint_t protobidx;
18982 duk_uint_t lookupidx;
18983 duk_uint_t uint_offset, uint_length, uint_added;
18984
18986 thr = (duk_hthread *) ctx;
18987 DUK_UNREF(thr);
18988
18989 /* The underlying types for offset/length in duk_hbufferobject is
18990 * duk_uint_t; make sure argument values fit and that offset + length
18991 * does not wrap.
18992 */
18993 uint_offset = (duk_uint_t) byte_offset;
18994 uint_length = (duk_uint_t) byte_length;
18995 if (sizeof(duk_size_t) != sizeof(duk_uint_t)) {
18996 if ((duk_size_t) uint_offset != byte_offset || (duk_size_t) uint_length != byte_length) {
18997 goto range_error;
18998 }
18999 }
19000 uint_added = uint_offset + uint_length;
19001 if (uint_added < uint_offset) {
19002 goto range_error;
19003 }
19004 DUK_ASSERT(uint_added >= uint_offset && uint_added >= uint_length);
19005
19006 DUK_ASSERT_DISABLE(flags >= 0); /* flags is unsigned */
19007 lookupidx = flags & 0x0f; /* 4 low bits */
19008 if (lookupidx >= sizeof(duk__bufobj_flags_lookup) / sizeof(duk_uint32_t)) {
19009 goto arg_error;
19010 }
19011 tmp = duk__bufobj_flags_lookup[lookupidx];
19012 classnum = tmp >> 24;
19013 protobidx = (tmp >> 16) & 0xff;
19014
19015 h_val = duk_require_hbuffer(ctx, idx_buffer);
19016 DUK_ASSERT(h_val != NULL);
19017
19018 h_bufobj = duk_push_bufferobject_raw(ctx,
19022 protobidx);
19023 DUK_ASSERT(h_bufobj != NULL);
19024
19025 h_bufobj->buf = h_val;
19026 DUK_HBUFFER_INCREF(thr, h_val);
19027 h_bufobj->offset = uint_offset;
19028 h_bufobj->length = uint_length;
19029 h_bufobj->shift = (tmp >> 4) & 0x0f;
19030 h_bufobj->elem_type = (tmp >> 8) & 0xff;
19031 h_bufobj->is_view = tmp & 0x0f;
19033
19034#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
19035 /* TypedArray views need an automatic ArrayBuffer which must be
19036 * provided as .buffer property of the view. Just create a new
19037 * ArrayBuffer sharing the same underlying buffer.
19038 *
19039 * The ArrayBuffer offset is always set to zero, so that if one
19040 * accesses the ArrayBuffer at the view's .byteOffset, the value
19041 * matches the view at index 0.
19042 */
19043 if (flags & DUK_BUFOBJ_CREATE_ARRBUF) {
19044 h_bufobj = duk_push_bufferobject_raw(ctx,
19049
19050 DUK_ASSERT(h_bufobj != NULL);
19051
19052 h_bufobj->buf = h_val;
19053 DUK_HBUFFER_INCREF(thr, h_val);
19054 h_bufobj->offset = 0;
19055 h_bufobj->length = uint_offset + uint_length; /* Wrap checked above. */
19056 DUK_ASSERT(h_bufobj->shift == 0);
19058 DUK_ASSERT(h_bufobj->is_view == 0);
#define DUK_BUFOBJ_CREATE_ARRBUF
#define DUK_BIDX_ARRAYBUFFER_PROTOTYPE
#define DUK__PACK_ARGS(classnum, protobidx, elemtype, elemshift, isview)
DUK_EXTERNAL void duk_push_buffer_object(duk_context *ctx, duk_idx_t idx_buffer, duk_size_t byte_offset, duk_size_t byte_length, duk_uint_t flags)
static const duk_uint32_t duk__bufobj_flags_lookup[]
DUK_INTERNAL_DECL duk_hbuffer * duk_require_hbuffer(duk_context *ctx, duk_idx_t index)

◆ duk_push_buffer_raw()

DUK_EXTERNAL void * duk_push_buffer_raw ( duk_context * ctx,
duk_size_t size,
duk_small_uint_t flags )

Definition at line 19142 of file duktape-1.8.0/src/duktape.c.

19142 {
19143 const char *filename = duk_api_global_filename;
19145 va_list ap;
19146 duk_idx_t ret;
19147
19149
19152 va_start(ap, fmt);
19153 ret = duk_push_error_object_va_raw(ctx, err_code, filename, line, fmt, ap);
19154 va_end(ap);
19155 return ret;
19156}
19157#endif /* DUK_USE_VARIADIC_MACROS */
19158
19160 duk_hthread *thr = (duk_hthread *) ctx;
19161 duk_tval *tv_slot;
19162 duk_hbuffer *h;
19163 void *buf_data;
19164
19166
19167 /* check stack first */
19168 if (thr->valstack_top >= thr->valstack_end) {
19170 }
19171

References duk_api_global_filename, duk_api_global_line, DUK_ASSERT_CTX_VALID, duk_push_error_object_va_raw(), and NULL.

◆ duk_push_bufferobject_raw()

DUK_INTERNAL_DECL duk_hbufferobject * duk_push_bufferobject_raw ( duk_context * ctx,
duk_uint_t hobject_flags_and_class,
duk_small_int_t prototype_bidx )

Definition at line 18899 of file duktape-1.8.0/src/duktape.c.

18901 {
18902 goto api_error;
18903 }
18904
18905 lf_flags = DUK_LFUNC_FLAGS_PACK(magic, length, nargs);
18906 DUK_TVAL_SET_LIGHTFUNC(&tv_tmp, func, lf_flags);
18907 duk_push_tval(ctx, &tv_tmp); /* XXX: direct valstack write */
18908 DUK_ASSERT(thr->valstack_top != thr->valstack_bottom);
18909 return ((duk_idx_t) (thr->valstack_top - thr->valstack_bottom)) - 1;
18910
18911 api_error:
18913 return 0; /* not reached */
18914}
18915
18916DUK_INTERNAL duk_hbufferobject *duk_push_bufferobject_raw(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_small_int_t prototype_bidx) {
18917 duk_hthread *thr = (duk_hthread *) ctx;
18918 duk_hbufferobject *obj;
18919 duk_tval *tv_slot;
18920
18921 DUK_ASSERT(ctx != NULL);
18922 DUK_ASSERT(prototype_bidx >= 0);
18923
18924 /* check stack first */
18925 if (thr->valstack_top >= thr->valstack_end) {

Referenced by duk_bi_buffer_slice_shared().

◆ duk_push_c_function()

DUK_EXTERNAL duk_idx_t duk_push_c_function ( duk_context * ctx,
duk_c_function func,
duk_int_t nargs )

Definition at line 18814 of file duktape-1.8.0/src/duktape.c.

18826 :
18828 return 0; /* not reached */
18829}

Referenced by duk_put_number_list().

◆ duk_push_c_function_noconstruct_noexotic()

◆ duk_push_c_function_noexotic()

◆ duk_push_c_lightfunc()

DUK_EXTERNAL duk_idx_t duk_push_c_lightfunc ( duk_context * ctx,
duk_c_function func,
duk_idx_t nargs,
duk_idx_t length,
duk_int_t magic )

Definition at line 18862 of file duktape-1.8.0/src/duktape.c.

18864 {
18865 duk_uint_t flags;
18866
18868
18875
18876 (void) duk__push_c_function_raw(ctx, func, nargs, flags);
18877}
18878
18880 duk_hthread *thr = (duk_hthread *) ctx;
18881 duk_tval tv_tmp;
18882 duk_small_uint_t lf_flags;
18883
18885
18886 /* check stack first */
18887 if (thr->valstack_top >= thr->valstack_end) {
18889 }
18890
18891 if (nargs >= DUK_LFUNC_NARGS_MIN && nargs <= DUK_LFUNC_NARGS_MAX) {
18892 /* as is */
18893 } else if (nargs == DUK_VARARGS) {
18895 } else {
18896 goto api_error;
18897 }
DUK_EXTERNAL duk_idx_t duk_push_c_lightfunc(duk_context *ctx, duk_c_function func, duk_idx_t nargs, duk_idx_t length, duk_int_t magic)

◆ duk_push_compiledfunction()

DUK_INTERNAL_DECL duk_idx_t duk_push_compiledfunction ( duk_context * ctx)

Definition at line 18723 of file duktape-1.8.0/src/duktape.c.

18724 {
18726 }
18727
18728 /* default prototype (Note: 'obj' must be reachable) */
18730
18731 /* Initial stack size satisfies the stack spare constraints so there
18732 * is no need to require stack here.
18733 */
18736
18737 return ret;
18738}
18739
18741 duk_hthread *thr = (duk_hthread *) ctx;
18743 duk_idx_t ret;
18744 duk_tval *tv_slot;
18745
18747
18748 /* check stack first */
18749 if (thr->valstack_top >= thr->valstack_end) {
18751 }
18752
18753 /* Template functions are not strictly constructable (they don't
18754 * have a "prototype" property for instance), so leave the
18755 * DUK_HOBJECT_FLAG_CONSRUCTABLE flag cleared here.
18756 */
18757
#define DUK_BIDX_THREAD_PROTOTYPE
DUK_INTERNAL_DECL void duk_hthread_copy_builtin_objects(duk_hthread *thr_from, duk_hthread *thr_to)

◆ duk_push_context_dump()

DUK_EXTERNAL void duk_push_context_dump ( duk_context * ctx)

Definition at line 13784 of file duktape-1.8.0/src/duktape.c.

13801 {
13802 duk_idx_t idx;
13803 duk_idx_t top;
13804
13806
13807 /* We don't duk_require_stack() here now, but rely on the caller having
13808 * enough space.
13809 */
13810
13811 top = duk_get_top(ctx);
13812 duk_push_array(ctx);
13813 for (idx = 0; idx < top; idx++) {
13814 duk_dup(ctx, idx);
13815 duk_put_prop_index(ctx, -2, idx);
13816 }

◆ duk_push_current_function()

DUK_EXTERNAL void duk_push_current_function ( duk_context * ctx)

Definition at line 18384 of file duktape-1.8.0/src/duktape.c.

18388 {
18389 duk_hthread *thr;
18390
18391 DUK_ASSERT(ctx != NULL);
18392 thr = (duk_hthread *) ctx;
18393
18394 DUK_ASSERT(thr->callstack_top > 0); /* caller required to know */
18395 DUK_ASSERT(thr->valstack_bottom > thr->valstack); /* consequence of above */
18396 DUK_ASSERT(thr->valstack_bottom - 1 >= thr->valstack); /* 'this' binding exists */
18397
18398 return thr->valstack_bottom - 1;
18399}

◆ duk_push_current_thread()

DUK_EXTERNAL void duk_push_current_thread ( duk_context * ctx)

◆ duk_push_error_object_raw()

DUK_EXTERNAL duk_idx_t duk_push_error_object_raw ( duk_context * ctx,
duk_errcode_t err_code,
const char * filename,
duk_int_t line,
const char * fmt,
... )

Definition at line 19112 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_err_create_and_throw().

◆ duk_push_error_object_stash()

DUK_EXTERNAL duk_idx_t duk_push_error_object_stash ( duk_context * ctx,
duk_errcode_t err_code,
const char * fmt,
... )

Definition at line 19125 of file duktape-1.8.0/src/duktape.c.

19129 {
19130 va_list ap;
19131 duk_idx_t ret;
19132
19134
19135 va_start(ap, fmt);
19136 ret = duk_push_error_object_va_raw(ctx, err_code, filename, line, fmt, ap);
19137 va_end(ap);
19138 return ret;
19139}

◆ duk_push_error_object_va_raw()

DUK_EXTERNAL duk_idx_t duk_push_error_object_va_raw ( duk_context * ctx,
duk_errcode_t err_code,
const char * filename,
duk_int_t line,
const char * fmt,
va_list ap )

Definition at line 19060 of file duktape-1.8.0/src/duktape.c.

19068 :
19070 return; /* not reached */
19071
19072 arg_error:
19074 return; /* not reached */
19075}
19076
19077DUK_EXTERNAL duk_idx_t duk_push_error_object_va_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, va_list ap) {
19078 duk_hthread *thr = (duk_hthread *) ctx;
19079 duk_idx_t ret;
19081#ifdef DUK_USE_AUGMENT_ERROR_CREATE
19082 duk_bool_t noblame_fileline;
19083#endif
19084
19086 DUK_ASSERT(thr != NULL);
19087 DUK_UNREF(filename);
19088 DUK_UNREF(line);
19089
19090 /* Error code also packs a tracedata related flag. */
19091#ifdef DUK_USE_AUGMENT_ERROR_CREATE
19092 noblame_fileline = err_code & DUK_ERRCODE_FLAG_NOBLAME_FILELINE;
19093#endif
19094 err_code = err_code & (~DUK_ERRCODE_FLAG_NOBLAME_FILELINE);
19095
19096 /* error gets its 'name' from the prototype */
19097 proto = duk_error_prototype_from_code(thr, err_code);
19101 proto);
19102
19103 /* ... and its 'message' from an instance property */
19104 if (fmt) {
19105 duk_push_vsprintf(ctx, fmt, ap);
19107 } else {
19108 /* If no explicit message given, put error code into message field
19109 * (as a number). This is not fully in keeping with the Ecmascript
19110 * error model because messages are supposed to be strings (Error
DUK_EXTERNAL const char * duk_push_vsprintf(duk_context *ctx, const char *fmt, va_list ap)

Referenced by duk_push_buffer_raw().

◆ duk_push_false()

DUK_EXTERNAL void duk_push_false ( duk_context * ctx)

Definition at line 18061 of file duktape-1.8.0/src/duktape.c.

18062 : 0); /* ensure value is 1 or 0 (not other non-zero) */
18063 tv_slot = thr->valstack_top++;
18064 DUK_TVAL_SET_BOOLEAN(tv_slot, b);
18065}
18066
18068 duk_hthread *thr;
18069 duk_tval *tv_slot;
18070

◆ duk_push_global_object()

DUK_EXTERNAL void duk_push_global_object ( duk_context * ctx)

Definition at line 18414 of file duktape-1.8.0/src/duktape.c.

18418 {

◆ duk_push_global_stash()

DUK_EXTERNAL void duk_push_global_stash ( duk_context * ctx)

Definition at line 18443 of file duktape-1.8.0/src/duktape.c.

◆ duk_push_hbuffer()

DUK_INTERNAL_DECL void duk_push_hbuffer ( duk_context * ctx,
duk_hbuffer * h )

Definition at line 19328 of file duktape-1.8.0/src/duktape.c.

19330 {
19331 duk_hthread *thr = (duk_hthread *) ctx;
19332 DUK_UNREF(thr);
19333 DUK_ASSERT(stridx >= 0 && stridx < DUK_HEAP_NUM_STRINGS);
19334 duk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx));

◆ duk_push_heap_stash()

DUK_EXTERNAL void duk_push_heap_stash ( duk_context * ctx)

Definition at line 18433 of file duktape-1.8.0/src/duktape.c.

18438 {
18441 DUK_DDD(DUK_DDDPRINT("creating heap/global/thread stash on first use"));

◆ duk_push_heapptr()

DUK_EXTERNAL duk_idx_t duk_push_heapptr ( duk_context * ctx,
void * ptr )

Definition at line 19255 of file duktape-1.8.0/src/duktape.c.

19258 {
19259 for (curr = thr->heap->heap_allocated;
19260 curr != NULL;
19261 curr = DUK_HEAPHDR_GET_NEXT(thr->heap, curr)) {
19262 if (curr == h) {
19263 DUK_ASSERT(found == 0); /* Would indicate corrupted lists. */
19264 found = 1;
19265 }
19266 }
19267 DUK_ASSERT(found != 0);
19268 }
19269}
19270#endif /* DUK_USE_ASSERTIONS */
19271
19273 duk_hthread *thr = (duk_hthread *) ctx;
19274 duk_idx_t ret;
19275
19277
19278 /* Reviving an object using a heap pointer is a dangerous API
19279 * operation: if the application doesn't guarantee that the
19280 * pointer target is always reachable, difficult-to-diagnose
19281 * problems may ensue. Try to validate the 'ptr' argument to
19282 * the extent possible.
19283 */
19284
19285#if defined(DUK_USE_ASSERTIONS)
19286 duk__validate_push_heapptr(ctx, ptr);
19287#endif
19288
19289 ret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom);
19290
19291 if (ptr == NULL) {
19292 goto push_undefined;
19293 }
19294
19295 switch ((int) DUK_HEAPHDR_GET_TYPE((duk_heaphdr *) ptr)) {
19296 case DUK_HTYPE_STRING:
DUK_EXTERNAL duk_idx_t duk_push_heapptr(duk_context *ctx, void *ptr)

◆ duk_push_hobject()

DUK_INTERNAL_DECL void duk_push_hobject ( duk_context * ctx,
duk_hobject * h )

◆ duk_push_hobject_bidx()

DUK_INTERNAL_DECL void duk_push_hobject_bidx ( duk_context * ctx,
duk_small_int_t builtin_idx )

Definition at line 19336 of file duktape-1.8.0/src/duktape.c.

19337 {
19338 duk_tval tv;
19340 DUK_ASSERT(h != NULL);
19341 DUK_TVAL_SET_OBJECT(&tv, h);
19342 duk_push_tval(ctx, &tv);
19343}

References DUK_ASSERT, DUK_ASSERT_CTX_VALID, duk_push_tval(), DUK_TVAL_SET_OBJECT, and NULL.

Referenced by duk_err_create_and_throw().

◆ duk_push_hobject_class_string()

DUK_INTERNAL_DECL void duk_push_hobject_class_string ( duk_context * ctx,
duk_hobject * h )

Definition at line 17136 of file duktape-1.8.0/src/duktape.c.

17137 {
17138 duk_hobject *h_obj;
17139
17140 duk_to_object(ctx, -1);
17141 h_obj = duk_get_hobject(ctx, -1);
17142 DUK_ASSERT(h_obj != NULL);
17143
17144 h_strclass = DUK_HOBJECT_GET_CLASS_STRING(thr->heap, h_obj);
17145 }
17146 DUK_ASSERT(h_strclass != NULL);
17147
17148 duk_pop(ctx);
#define DUK_HOBJECT_GET_CLASS_STRING(heap, h)

◆ duk_push_hstring()

DUK_INTERNAL_DECL void duk_push_hstring ( duk_context * ctx,
duk_hstring * h )

Definition at line 19305 of file duktape-1.8.0/src/duktape.c.

19305 :
19306 goto push_undefined;
19307 }
19308 return ret;
19309
19310 push_undefined:
19311 duk_push_undefined(ctx);

Referenced by duk__get_own_propdesc_raw(), duk__parse_var_decl(), and duk__realloc_props().

◆ duk_push_hstring_stridx()

◆ duk_push_int()

DUK_EXTERNAL void duk_push_int ( duk_context * ctx,
duk_int_t val )

Definition at line 18087 of file duktape-1.8.0/src/duktape.c.

18090 {
18091 duk_hthread *thr;
18092 duk_tval *tv_slot;
18094
18096 thr = (duk_hthread *) ctx;
18098 du.d = val;
18100 tv_slot = thr->valstack_top++;
18101 DUK_TVAL_SET_NUMBER(tv_slot, du.d);
18102}
18103
18105#if defined(DUK_USE_FASTINT)
18106 duk_hthread *thr;
18107 duk_tval *tv_slot;
18108
18110 thr = (duk_hthread *) ctx;
18112 tv_slot = thr->valstack_top++;
18113#if DUK_INT_MAX <= 0x7fffffffL
18114 DUK_TVAL_SET_FASTINT_I32(tv_slot, (duk_int32_t) val);
18115#else
18116 if (val >= DUK_FASTINT_MIN && val <= DUK_FASTINT_MAX) {
18117 DUK_TVAL_SET_FASTINT(tv_slot, (duk_int64_t) val);
18118 } else {
#define DUK_TVAL_SET_FASTINT_I32(tv, val)

Referenced by duk__error_getter_helper(), duk__get_own_propdesc_raw(), duk__init_varmap_and_prologue_for_pass2(), duk__parse_var_decl(), duk_bi_buffer_readfield(), duk_bi_duktape_object_info(), duk_bi_string_prototype_match(), and duk_err_create_and_throw().

◆ duk_push_lightfunc_name()

DUK_INTERNAL_DECL void duk_push_lightfunc_name ( duk_context * ctx,
duk_tval * tv )

Definition at line 19603 of file duktape-1.8.0/src/duktape.c.

19620 {
19621 duk_c_function func;
19622
19624
19625 /* Lightfunc name, includes Duktape/C native function pointer, which

Referenced by duk_push_string_funcptr().

◆ duk_push_lightfunc_tostring()

DUK_INTERNAL_DECL void duk_push_lightfunc_tostring ( duk_context * ctx,
duk_tval * tv )

Definition at line 19627 of file duktape-1.8.0/src/duktape.c.

◆ duk_push_lstring()

DUK_EXTERNAL const char * duk_push_lstring ( duk_context * ctx,
const char * str,
duk_size_t len )

Definition at line 18168 of file duktape-1.8.0/src/duktape.c.

18171 {
18172 duk_hthread *thr;
18173 duk_tval *tv_slot;
18175
18177 thr = (duk_hthread *) ctx;
18181 tv_slot = thr->valstack_top++;
18182 DUK_TVAL_SET_NUMBER(tv_slot, du.d);
18183}
18184
18185DUK_EXTERNAL const char *duk_push_lstring(duk_context *ctx, const char *str, duk_size_t len) {
18186 duk_hthread *thr = (duk_hthread *) ctx;
18187 duk_hstring *h;
18188 duk_tval *tv_slot;
18189
18191
18192 /* check stack before interning (avoid hanging temp) */
18193 if (thr->valstack_top >= thr->valstack_end) {
18195 }
18196
18197 /* NULL with zero length represents an empty string; NULL with higher
18198 * length is also now trated like an empty string although it is
18199 * a bit dubious. This is unlike duk_push_string() which pushes a
18200 * 'null' if the input string is a NULL.
18201 */
18202 if (!str) {

Referenced by duk_push_string_file_raw().

◆ duk_push_nan()

DUK_EXTERNAL void duk_push_nan ( duk_context * ctx)

Definition at line 18154 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_date_constructor_now().

◆ duk_push_null()

DUK_EXTERNAL void duk_push_null ( duk_context * ctx)

Definition at line 18026 of file duktape-1.8.0/src/duktape.c.

18029 {
18030 duk_hthread *thr;
18031
18033 thr = (duk_hthread *) ctx;
18035

Referenced by duk__init_varmap_and_prologue_for_pass2(), and duk_push_string_file_raw().

◆ duk_push_number()

DUK_EXTERNAL void duk_push_number ( duk_context * ctx,
duk_double_t val )

Definition at line 18073 of file duktape-1.8.0/src/duktape.c.

18078 {
18079 duk_hthread *thr;
18080 duk_tval *tv_slot;
18081
18083 thr = (duk_hthread *) ctx;
18085 tv_slot = thr->valstack_top++;

Referenced by duk__format_parts_iso8601(), duk_bi_buffer_readfield(), and duk_bi_string_prototype_substring().

◆ duk_push_object()

DUK_EXTERNAL duk_idx_t duk_push_object ( duk_context * ctx)

Definition at line 18613 of file duktape-1.8.0/src/duktape.c.

18615 {
18616 duk_hthread *thr = (duk_hthread *) ctx;
18617 duk_idx_t ret;
18618 duk_hobject *h;
18619

◆ duk_push_object_helper()

DUK_INTERNAL_DECL duk_idx_t duk_push_object_helper ( duk_context * ctx,
duk_uint_t hobject_flags_and_class,
duk_small_int_t prototype_bidx )

Definition at line 18558 of file duktape-1.8.0/src/duktape.c.

18561 {
18562 va_list ap;
18563 const char *ret;
18564
18566
18567 /* allow fmt==NULL */
18568 va_start(ap, fmt);
18569 ret = duk_push_vsprintf(ctx, fmt, ap);
18570 va_end(ap);
18571
18572 return ret;
18573}
18574
18575DUK_INTERNAL duk_idx_t duk_push_object_helper(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_small_int_t prototype_bidx) {
18576 duk_hthread *thr = (duk_hthread *) ctx;
18577 duk_tval *tv_slot;
18578 duk_hobject *h;
18579 duk_idx_t ret;
18580
18582 DUK_ASSERT(prototype_bidx == -1 ||
18583 (prototype_bidx >= 0 && prototype_bidx < DUK_NUM_BUILTINS));
18584
18585 /* check stack first */
18586 if (thr->valstack_top >= thr->valstack_end) {
18588 }
18589
18590 h = duk_hobject_alloc(thr->heap, hobject_flags_and_class);
18591 if (!h) {
18593 }
18594
18595 DUK_DDD(DUK_DDDPRINT("created object with flags: 0x%08lx", (unsigned long) h->hdr.h_flags));
18596

Referenced by duk_bi_string_constructor_from_char_code().

◆ duk_push_object_helper_proto()

DUK_INTERNAL_DECL duk_idx_t duk_push_object_helper_proto ( duk_context * ctx,
duk_uint_t hobject_flags_and_class,
duk_hobject * proto )

Definition at line 18598 of file duktape-1.8.0/src/duktape.c.

18605 {
18606 DUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, h, thr->builtins[prototype_bidx]);
18607 } else {
18608 DUK_ASSERT(prototype_bidx == -1);
18609 DUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h) == NULL);
18610 }
18611

◆ duk_push_object_internal()

DUK_INTERNAL_DECL duk_idx_t duk_push_object_internal ( duk_context * ctx)

Definition at line 19298 of file duktape-1.8.0/src/duktape.c.

19299 :
19300 duk_push_hobject(ctx, (duk_hobject *) ptr);
19301 break;
19302 case DUK_HTYPE_BUFFER:
19303 duk_push_hbuffer(ctx, (duk_hbuffer *) ptr);

◆ duk_push_pointer()

DUK_EXTERNAL void duk_push_pointer ( duk_context * ctx,
void * val )

Definition at line 18285 of file duktape-1.8.0/src/duktape.c.

18286 {
18287 duk_hthread *thr = (duk_hthread *) ctx;
18289 DUK_UNREF(path);
18290
18291 if (flags != 0) {
18292 DUK_ASSERT(flags == DUK_STRING_PUSH_SAFE); /* only flag now */
18293 duk_push_undefined(ctx);
18294 } else {
#define DUK_STRING_PUSH_SAFE

References DUK_ASSERT, DUK_ASSERT_CTX_VALID, duk_push_undefined(), DUK_STRING_PUSH_SAFE, and DUK_UNREF.

Referenced by duk_bi_duktape_object_info().

◆ duk_push_sprintf()

DUK_EXTERNAL const char * duk_push_sprintf ( duk_context * ctx,
const char * fmt,
... )

Definition at line 18544 of file duktape-1.8.0/src/duktape.c.

18546 {
18548 }
18549 }
18550
18551 /* Cannot use duk_to_string() on the buffer because it is usually
18552 * larger than 'len'. Also, 'buf' is usually a stack buffer.
18553 */
18554 res = duk_push_lstring(ctx, (const char *) buf, (duk_size_t) len); /* [ buf? res ] */
18555 if (pushed_buf) {
18556 duk_remove(ctx, -2);
#define DUK_STR_SPRINTF_TOO_LONG

References DUK_ERROR_API, and DUK_STR_SPRINTF_TOO_LONG.

Referenced by duk__error_getter_helper(), and duk_to_int_clamped_raw().

◆ duk_push_string()

DUK_EXTERNAL const char * duk_push_string ( duk_context * ctx,
const char * str )

Definition at line 18204 of file duktape-1.8.0/src/duktape.c.

18207 {
18209 }
18210
18211 h = duk_heap_string_intern_checked(thr, (const duk_uint8_t *) str, (duk_uint32_t) len);
18212 DUK_ASSERT(h != NULL);
18213
#define DUK_STR_STRING_TOO_LONG
DUK_INTERNAL_DECL duk_hstring * duk_heap_string_intern_checked(duk_hthread *thr, const duk_uint8_t *str, duk_uint32_t len)

Referenced by duk_del_prop_stridx(), duk_get_prop_stridx(), duk_has_prop_stridx(), and duk_push_string_funcptr().

◆ duk_push_string_file_raw()

DUK_EXTERNAL const char * duk_push_string_file_raw ( duk_context * ctx,
const char * path,
duk_uint_t flags )

Definition at line 18220 of file duktape-1.8.0/src/duktape.c.

18221 {
18223
18224 if (str) {
18225 return duk_push_lstring(ctx, str, DUK_STRLEN(str));
18226 } else {
18227 duk_push_null(ctx);
18228 return NULL;
18229 }
18230}
18231
18232#ifdef DUK_USE_FILE_IO
18233/* This is a bit clunky because it is ANSI C portable. Should perhaps
18234 * relocate to another file because this is potentially platform
18235 * dependent.
18236 */
18237DUK_EXTERNAL const char *duk_push_string_file_raw(duk_context *ctx, const char *path, duk_uint_t flags) {
18238 duk_hthread *thr = (duk_hthread *) ctx;
18239 duk_file *f = NULL;
18240 char *buf;
18241 long sz; /* ANSI C typing */
18242
18244
18245 if (!path) {
18246 goto fail;
18247 }
18248 f = DUK_FOPEN(path, "rb");
18249 if (!f) {
18250 goto fail;
18251 }
18252 if (DUK_FSEEK(f, 0, SEEK_END) < 0) {
18253 goto fail;
18254 }
18255 sz = DUK_FTELL(f);
18256 if (sz < 0) {
18257 goto fail;
18258 }
18259 if (DUK_FSEEK(f, 0, SEEK_SET) < 0) {
18260 goto fail;
18261 }
18262 buf = (char *) duk_push_fixed_buffer(ctx, (duk_size_t) sz);
18263 DUK_ASSERT(buf != NULL);
18264 if ((duk_size_t) DUK_FREAD(buf, 1, (size_t) sz, f) != (duk_size_t) sz) {
18265 goto fail;
18266 }
18267 (void) DUK_FCLOSE(f); /* ignore fclose() error */
DUK_EXTERNAL const char * duk_push_string_file_raw(duk_context *ctx, const char *path, duk_uint_t flags)

References DUK_ASSERT_CTX_VALID, duk_push_lstring(), duk_push_null(), DUK_STRLEN, and NULL.

◆ duk_push_string_funcptr()

DUK_INTERNAL_DECL void duk_push_string_funcptr ( duk_context * ctx,
duk_uint8_t * ptr,
duk_size_t sz )

Definition at line 19643 of file duktape-1.8.0/src/duktape.c.

19644 {
19646
19647 duk_push_string(ctx, "function ");
19648 duk_push_lightfunc_name(ctx, tv);
19649 duk_push_string(ctx, "() {\"light\"}");
19650 duk_concat(ctx, 3);
19651}
19652
19653/*
19654 * Function pointers
19655 *
19656 * Printing function pointers is non-portable, so we do that by hex printing
19657 * bytes from memory.
19658 */
19659
19660DUK_INTERNAL void duk_push_string_funcptr(duk_context *ctx, duk_uint8_t *ptr, duk_size_t sz) {
19661 duk_uint8_t buf[32 * 2];
19662 duk_uint8_t *p, *q;
19665
19666 DUK_ASSERT(sz <= 32); /* sanity limit for function pointer size */
19667
19668 p = buf;
DUK_INTERNAL_DECL void duk_push_string_funcptr(duk_context *ctx, duk_uint8_t *ptr, duk_size_t sz)

References DUK_ASSERT, duk_concat(), duk_push_lightfunc_name(), duk_push_string(), and DUK_TVAL_IS_LIGHTFUNC.

◆ duk_push_string_readable()

DUK_INTERNAL_DECL const char * duk_push_string_readable ( duk_context * ctx,
duk_idx_t index )

Definition at line 19784 of file duktape-1.8.0/src/duktape.c.

◆ duk_push_string_tval_readable()

DUK_INTERNAL_DECL const char * duk_push_string_tval_readable ( duk_context * ctx,
duk_tval * tv )

Definition at line 19737 of file duktape-1.8.0/src/duktape.c.

19740 {
19741 q += duk_unicode_encode_xutf8(cp, q);
19742 }
19743 } else {
19744 p++; /* advance manually */
19745 *q++ = (duk_uint8_t) DUK_ASC_QUESTION;
19746 }
19747 nchars++;
19748 }
19749 *q++ = (duk_uint8_t) DUK_ASC_SINGLEQUOTE;
19750
19751 duk_push_lstring(ctx, (const char *) buf, (duk_size_t) (q - buf));
19752}
19753
19755 duk_hthread *thr;
19756
19758 thr = (duk_hthread *) ctx;
19759 DUK_UNREF(thr);
19760
19761 if (tv == NULL) {
19762 duk_push_string(ctx, "none");
19763 } else {
19764 switch (DUK_TVAL_GET_TAG(tv)) {
19765 case DUK_TAG_STRING: {
19767 break;
19768 }
19769 case DUK_TAG_OBJECT: {
19771 DUK_ASSERT(h != NULL);
19773 break;
19774 }
19775 case DUK_TAG_BUFFER: {
19776 /* XXX: Hex encoded, length limited buffer summary here? */
19778 DUK_ASSERT(h != NULL);
19779 duk_push_sprintf(ctx, "[buffer:%ld]", (long) DUK_HBUFFER_GET_SIZE(h));
19780 break;
19781 }
19782 case DUK_TAG_POINTER: {
DUK_LOCAL void duk__push_hstring_readable_unicode(duk_context *ctx, duk_hstring *h_input)
DUK_INTERNAL_DECL void duk_push_hobject_class_string(duk_context *ctx, duk_hobject *h)

Referenced by duk__concat_and_join_helper(), and duk_hobject_putprop().

◆ duk_push_this()

DUK_EXTERNAL void duk_push_this ( duk_context * ctx)

Definition at line 18335 of file duktape-1.8.0/src/duktape.c.

18338 {
18339 /* XXX: better macro for DUK_TVAL_IS_UNDEFINED_OR_NULL(tv) */

Referenced by duk__error_getter_helper(), duk_bi_boolean_prototype_tostring_shared(), duk_bi_buffer_slice_shared(), duk_bi_regexp_constructor(), and duk_bi_typedarray_set().

◆ duk_push_this_check_object_coercible()

DUK_INTERNAL_DECL void duk_push_this_check_object_coercible ( duk_context * ctx)

Definition at line 18341 of file duktape-1.8.0/src/duktape.c.

◆ duk_push_this_coercible_to_object()

DUK_INTERNAL_DECL duk_hobject * duk_push_this_coercible_to_object ( duk_context * ctx)

Definition at line 18347 of file duktape-1.8.0/src/duktape.c.

18348 :
18350}
18351
18354
18355 duk__push_this_helper(ctx, 0 /*check_object_coercible*/);
18356}
18357
#define DUK_STR_NOT_OBJECT_COERCIBLE

Referenced by duk__push_this_obj_len_u32_limited(), and duk_bi_object_prototype_is_prototype_of().

◆ duk_push_this_coercible_to_string()

DUK_INTERNAL_DECL duk_hstring * duk_push_this_coercible_to_string ( duk_context * ctx)

Definition at line 18359 of file duktape-1.8.0/src/duktape.c.

18364 {
18365 duk_hobject *h;
18366
18368
18369 duk__push_this_helper(ctx, 1 /*check_object_coercible*/);

Referenced by duk_bi_string_prototype_indexof_shared(), and duk_bi_string_prototype_locale_compare().

◆ duk_push_thread_raw()

DUK_EXTERNAL duk_idx_t duk_push_thread_raw ( duk_context * ctx,
duk_uint_t flags )

Definition at line 18660 of file duktape-1.8.0/src/duktape.c.

18677 {
18678 duk_hthread *thr = (duk_hthread *) ctx;
18679 duk_hthread *obj;
18680 duk_idx_t ret;
18681 duk_tval *tv_slot;
18682
18684
18685 /* check stack first */
18686 if (thr->valstack_top >= thr->valstack_end) {
18688 }
18689
18690 obj = duk_hthread_alloc(thr->heap,
18694 if (!obj) {
18696 }
18698#if defined(DUK_USE_ROM_STRINGS)
18699 /* Nothing to initialize, strs[] is in ROM. */
18700#else
18701#if defined(DUK_USE_HEAPPTR16)
18702 obj->strs16 = thr->strs16;
18703#else
18704 obj->strs = thr->strs;
18705#endif
18706#endif
18707 DUK_DDD(DUK_DDDPRINT("created thread object with flags: 0x%08lx", (unsigned long) obj->obj.hdr.h_flags));
18708
18709 /* make the new thread reachable */
18710 tv_slot = thr->valstack_top;
18711 DUK_TVAL_SET_OBJECT(tv_slot, (duk_hobject *) obj);
18712 DUK_HTHREAD_INCREF(thr, obj);
18713 ret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom);
18714 thr->valstack_top++;
18715
18716 /* important to do this *after* pushing, to make the thread reachable for gc */
18717 if (!duk_hthread_init_stacks(thr->heap, obj)) {
18719 }
18720
18721 /* initialize built-ins - either by copying or creating new ones */
DUK_INTERNAL_DECL duk_bool_t duk_hthread_init_stacks(duk_heap *heap, duk_hthread *thr)
#define DUK_HTHREAD_INCREF(thr, h)

◆ duk_push_thread_stash()

DUK_EXTERNAL void duk_push_thread_stash ( duk_context * ctx,
duk_context * target_ctx )

Definition at line 18449 of file duktape-1.8.0/src/duktape.c.

18450 {
18451 duk_hthread *thr = (duk_hthread *) ctx;
18452 duk_heap *heap;
18454 heap = thr->heap;
18455 DUK_ASSERT(heap->heap_object != NULL);
18456 duk_push_hobject(ctx, heap->heap_object);
18457 duk__push_stash(ctx);
18458}

References duk__push_stash(), DUK_ASSERT, DUK_ASSERT_CTX_VALID, duk_push_hobject(), duk_hthread::heap, duk_heap::heap_object, and NULL.

◆ duk_push_true()

DUK_EXTERNAL void duk_push_true ( duk_context * ctx)

Definition at line 18050 of file duktape-1.8.0/src/duktape.c.

18054 {
18055 duk_hthread *thr;
18056 duk_tval *tv_slot;
18058

Referenced by duk_bi_object_constructor_is_extensible().

◆ duk_push_tval()

DUK_INTERNAL_DECL void duk_push_tval ( duk_context * ctx,
duk_tval * tv )

Definition at line 17999 of file duktape-1.8.0/src/duktape.c.

17999 {
18000 return DUK_ERR_URI_ERROR;
18001 }
18002 if (h == thr->builtins[DUK_BIDX_ERROR_PROTOTYPE]) {
18003 return DUK_ERR_ERROR;
18004 }
18005
18006 h = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h);
18007 } while (--sanity > 0);
18008
18009 return DUK_ERR_NONE;
18010}

References DUK_ERR_URI_ERROR.

Referenced by duk__declvar_helper(), duk__err_augment_user(), duk__get_own_propdesc_raw(), duk__getvar_helper(), duk_hobject_putprop(), duk_js_instanceof(), duk_push_current_thread(), and duk_push_hobject_bidx().

◆ duk_push_uint()

DUK_EXTERNAL void duk_push_uint ( duk_context * ctx,
duk_uint_t val )

Definition at line 18120 of file duktape-1.8.0/src/duktape.c.

18137 {
18138#if defined(DUK_USE_FASTINT)
18139 duk_hthread *thr;
18140 duk_tval *tv_slot;
18141
18143 thr = (duk_hthread *) ctx;
18145 tv_slot = thr->valstack_top++;
18146#if DUK_UINT_MAX <= 0xffffffffUL
18147 DUK_TVAL_SET_FASTINT_U32(tv_slot, (duk_uint32_t) val);
18148#else
18149 if (val <= DUK_FASTINT_MAX) { /* val is unsigned so >= 0 */
18150 /* XXX: take advantage of val being unsigned, no need to mask */
18151 DUK_TVAL_SET_FASTINT(tv_slot, (duk_int64_t) val);
18152 } else {

Referenced by duk__get_own_propdesc_raw(), duk_bi_buffer_readfield(), and duk_bi_duktape_object_info().

◆ duk_push_undefined()

DUK_EXTERNAL void duk_push_undefined ( duk_context * ctx)

◆ duk_push_vsprintf()

DUK_EXTERNAL const char * duk_push_vsprintf ( duk_context * ctx,
const char * fmt,
va_list ap )

Definition at line 18478 of file duktape-1.8.0/src/duktape.c.

18478 {
18479 duk_int_t len;
18480
18482 DUK_UNREF(ctx);
18483
18484 /* NUL terminator handling doesn't matter here */
18485 len = DUK_VSNPRINTF((char *) buf, sz, fmt, ap);
18486 if (len < (duk_int_t) sz) {
18487 /* Return value of 'sz' or more indicates output was (potentially)
18488 * truncated.
18489 */
18490 return (duk_int_t) len;
18491 }
18492 return -1;
18493}
18494
18495DUK_EXTERNAL const char *duk_push_vsprintf(duk_context *ctx, const char *fmt, va_list ap) {
18496 duk_hthread *thr = (duk_hthread *) ctx;
18497 duk_uint8_t stack_buf[DUK_PUSH_SPRINTF_INITIAL_SIZE];
18499 duk_bool_t pushed_buf = 0;
18500 void *buf;
18501 duk_int_t len; /* XXX: duk_ssize_t */
18502 const char *res;
18503
18505
18506 /* special handling of fmt==NULL */
18507 if (!fmt) {
18508 duk_hstring *h_str;
18510 h_str = DUK_HTHREAD_STRING_EMPTY_STRING(thr); /* rely on interning, must be this string */
18511 return (const char *) DUK_HSTRING_GET_DATA(h_str);
18512 }
18513
18514 /* initial estimate based on format string */
18515 sz = DUK_STRLEN(fmt) + 16; /* format plus something to avoid just missing */
18518 }
18519 DUK_ASSERT(sz > 0);
18520
18521 /* Try to make do with a stack buffer to avoid allocating a temporary buffer.
18522 * This works 99% of the time which is quite nice.
18523 */
18524 for (;;) {
18525 va_list ap_copy; /* copied so that 'ap' can be reused */
18526
18527 if (sz <= sizeof(stack_buf)) {
18528 buf = stack_buf;
18529 } else if (!pushed_buf) {
18530 pushed_buf = 1;
18531 buf = duk_push_dynamic_buffer(ctx, sz);
18532 } else {
18533 buf = duk_resize_buffer(ctx, -1, sz);
18534 }
18535 DUK_ASSERT(buf != NULL);
18536
18537 DUK_VA_COPY(ap_copy, ap);
18538 len = duk__try_push_vsprintf(ctx, buf, sz, fmt, ap_copy);
18539 va_end(ap_copy);
18540 if (len >= 0) {
18541 break;
18542 }
#define DUK_VA_COPY(dest, src)
DUK_LOCAL duk_int_t duk__try_push_vsprintf(duk_context *ctx, void *buf, duk_size_t sz, const char *fmt, va_list ap)
#define DUK_PUSH_SPRINTF_INITIAL_SIZE

References DUK_ASSERT_CTX_VALID, DUK_UNREF, and DUK_VSNPRINTF.

◆ duk_put_function_list()

DUK_EXTERNAL void duk_put_function_list ( duk_context * ctx,
duk_idx_t obj_index,
const duk_function_list_entry * funcs )

Definition at line 14869 of file duktape-1.8.0/src/duktape.c.

14874 {
14876
14877 duk_require_hobject(ctx, enum_index);
14878 duk_dup(ctx, enum_index);
14879 return duk_hobject_enumerator_next(ctx, get_value);
14880}
14881
14882/*

◆ duk_put_global_string()

DUK_EXTERNAL duk_bool_t duk_put_global_string ( duk_context * ctx,
const char * key )

Definition at line 14918 of file duktape-1.8.0/src/duktape.c.

14920 {
14921 duk_hthread *thr = (duk_hthread *) ctx;
14922 duk_bool_t ret;
14923
14926
14927 /* XXX: direct implementation */
14928
14930 ret = duk_get_prop_string(ctx, -1, key);
14931 duk_remove(ctx, -2);
14932 return ret;

References duk_hthread::builtins, DUK_ASSERT, DUK_ASSERT_CTX_VALID, DUK_BIDX_GLOBAL, duk_get_prop_string(), duk_push_hobject(), duk_remove(), and NULL.

◆ duk_put_number_list()

◆ duk_put_prop()

DUK_EXTERNAL duk_bool_t duk_put_prop ( duk_context * ctx,
duk_idx_t obj_idx )

◆ duk_put_prop_index()

DUK_EXTERNAL duk_bool_t duk_put_prop_index ( duk_context * ctx,
duk_idx_t obj_idx,
duk_uarridx_t arr_idx )

Definition at line 14526 of file duktape-1.8.0/src/duktape.c.

14530 {
14532 DUK_ASSERT(key != NULL);

Referenced by duk__parse_var_decl(), and duk_bi_typedarray_set().

◆ duk_put_prop_stridx()

DUK_INTERNAL_DECL duk_bool_t duk_put_prop_stridx ( duk_context * ctx,
duk_idx_t obj_index,
duk_small_int_t stridx )

Definition at line 14534 of file duktape-1.8.0/src/duktape.c.

14543 {
14545

Referenced by duk__format_parts_iso8601(), and duk_bi_logger_prototype_fmt().

◆ duk_put_prop_string()

DUK_EXTERNAL duk_bool_t duk_put_prop_string ( duk_context * ctx,
duk_idx_t obj_idx,
const char * key )

Definition at line 14513 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_put_number_list().

◆ duk_put_var()

DUK_EXTERNAL void duk_put_var ( duk_context * ctx)

Definition at line 20165 of file duktape-1.8.0/src/duktape.c.

20182 {
20183 duk_hthread *thr = (duk_hthread *) ctx;
20184 duk_activation *act;
20185 duk_hstring *h_varname;
20186 duk_tval *tv_val;
20187 duk_small_int_t throw_flag;
20188
20190
20191 h_varname = duk_require_hstring(ctx, -2); /* XXX: tostring? */
20192 DUK_ASSERT(h_varname != NULL);
20193
20194 tv_val = duk_require_tval(ctx, -1);
20195
20196 throw_flag = duk_is_strict_call(ctx);
20197

◆ duk_raw_read_double_be()

DUK_INTERNAL_DECL duk_double_t duk_raw_read_double_be ( duk_uint8_t ** p)

Definition at line 86788 of file duktape-1.8.0/src/duktape.c.

86793 {
86794 union {
86795 duk_uint8_t b[4];
86796 duk_uint32_t x;
86797 } u;
86798
86799 DUK_MEMCPY((void *) u.b, (const void *) (*p), (size_t) 4);
86800 u.x = DUK_NTOH32(u.x);
86801 *p += 4;
86802 return u.x;
86803}
86804

◆ duk_raw_read_u16_be()

DUK_INTERNAL_DECL duk_uint16_t duk_raw_read_u16_be ( duk_uint8_t ** p)

Definition at line 86764 of file duktape-1.8.0/src/duktape.c.

◆ duk_raw_read_u32_be()

DUK_INTERNAL_DECL duk_uint32_t duk_raw_read_u32_be ( duk_uint8_t ** p)

Definition at line 86776 of file duktape-1.8.0/src/duktape.c.

86781 {
86782 union {
86783 duk_uint8_t b[2];
86784 duk_uint16_t x;
86785 } u;
86786

References DUK_MEMCPY.

◆ duk_raw_write_double_be()

DUK_INTERNAL_DECL void duk_raw_write_double_be ( duk_uint8_t ** p,
duk_double_t val )

Definition at line 86828 of file duktape-1.8.0/src/duktape.c.

86834 {
86835 union {
86836 duk_uint8_t b[4];
86837 duk_uint32_t x;
86838 } u;
86839
86840 u.x = DUK_HTON32(val);
86841 DUK_MEMCPY((void *) (*p), (const void *) u.b, (size_t) 4);
86842 *p += 4;
86843}

◆ duk_raw_write_u16_be()

DUK_INTERNAL_DECL void duk_raw_write_u16_be ( duk_uint8_t ** p,
duk_uint16_t val )

Definition at line 86806 of file duktape-1.8.0/src/duktape.c.

86807 {
86808 duk_uint8_t b[4];
86809 duk_uint32_t x;
86810 } u;
86811
86812 DUK_MEMCPY((void *) u.b, (const void *) (*p), (size_t) 4);
86813 u.x = DUK_NTOH32(u.x);
86814 du.ui[DUK_DBL_IDX_UI0] = u.x;
86815 DUK_MEMCPY((void *) u.b, (const void *) (*p + 4), (size_t) 4);

◆ duk_raw_write_u32_be()

DUK_INTERNAL_DECL void duk_raw_write_u32_be ( duk_uint8_t ** p,
duk_uint32_t val )

Definition at line 86817 of file duktape-1.8.0/src/duktape.c.

86823 {
86824 union {
86825 duk_uint8_t b[2];
86826 duk_uint16_t x;

◆ duk_realloc()

DUK_EXTERNAL void * duk_realloc ( duk_context * ctx,
void * ptr,
duk_size_t size )

Definition at line 14336 of file duktape-1.8.0/src/duktape.c.

14337 {
14338 duk_hthread *thr = (duk_hthread *) ctx;
14339
14341
14342 return DUK_ALLOC(thr->heap, size);
14343}
14344
14345DUK_EXTERNAL void duk_free(duk_context *ctx, void *ptr) {
14346 duk_hthread *thr = (duk_hthread *) ctx;
14347
14349
14350 DUK_FREE(thr->heap, ptr);
14351}
14352
DUK_EXTERNAL void duk_free(duk_context *ctx, void *ptr)

References DUK_ALLOC, DUK_ASSERT_CTX_VALID, and duk_hthread::heap.

◆ duk_realloc_raw()

DUK_EXTERNAL void * duk_realloc_raw ( duk_context * ctx,
void * ptr,
duk_size_t size )

Definition at line 14312 of file duktape-1.8.0/src/duktape.c.

14313 {
14314 duk_hthread *thr = (duk_hthread *) ctx;
14315
14317
14318 return DUK_ALLOC_RAW(thr->heap, size);
#define DUK_ALLOC_RAW(heap, size)

References DUK_ALLOC_RAW, DUK_ASSERT_CTX_VALID, and duk_hthread::heap.

◆ duk_regexp_compile()

DUK_INTERNAL_DECL void duk_regexp_compile ( duk_hthread * thr)

Definition at line 78549 of file duktape-1.8.0/src/duktape.c.

78566 {
78567 duk_context *ctx = (duk_context *) thr;
78568 duk_re_compiler_ctx re_ctx;
78569 duk_lexer_point lex_point;
78570 duk_hstring *h_pattern;
78571 duk_hstring *h_flags;
78572 duk__re_disjunction_info ign_disj;
78573
78574 DUK_ASSERT(thr != NULL);
78575 DUK_ASSERT(ctx != NULL);
78576
78577 /*
78578 * Args validation
78579 */
78580
78581 /* TypeError if fails */
78582 h_pattern = duk_require_hstring(ctx, -2);
78583 h_flags = duk_require_hstring(ctx, -1);
78584
78585 /*
78586 * Create normalized 'source' property (E5 Section 15.10.3).
78587 */
78588
78589 /* [ ... pattern flags ] */
78590
78592
78593 /* [ ... pattern flags escaped_source ] */
78594
78595 /*
78596 * Init compilation context
78597 */
78598
78599 /* [ ... pattern flags escaped_source buffer ] */
78600
78601 DUK_MEMZERO(&re_ctx, sizeof(re_ctx));
78602 DUK_LEXER_INITCTX(&re_ctx.lex); /* duplicate zeroing, expect for (possible) NULL inits */
78603 re_ctx.thr = thr;
78604 re_ctx.lex.thr = thr;
78605 re_ctx.lex.input = DUK_HSTRING_GET_DATA(h_pattern);
78606 re_ctx.lex.input_length = DUK_HSTRING_GET_BYTELEN(h_pattern);
78609 re_ctx.re_flags = duk__parse_regexp_flags(thr, h_flags);
78610
78612
78613 DUK_DD(DUK_DDPRINT("regexp compiler ctx initialized, flags=0x%08lx, recursion_limit=%ld",
78614 (unsigned long) re_ctx.re_flags, (long) re_ctx.recursion_limit));
78615
78616 /*
78617 * Init lexer
78618 */
78619
78620 lex_point.offset = 0; /* expensive init, just want to fill window */
78621 lex_point.line = 1;
78622 DUK_LEXER_SETPOINT(&re_ctx.lex, &lex_point);
78623
78624 /*
78625 * Compilation
78626 */
78627
78628 DUK_DD(DUK_DDPRINT("starting regexp compilation"));
78629
78631 duk__append_u32(&re_ctx, 0);
78632 duk__parse_disjunction(&re_ctx, 1 /*expect_eof*/, &ign_disj);
78634 duk__append_u32(&re_ctx, 1);
78636
78637 /*
78638 * Check for invalid backreferences; note that it is NOT an error
78639 * to back-reference a capture group which has not yet been introduced
78640 * in the pattern (as in /\1(foo)/); in fact, the backreference will
78641 * always match! It IS an error to back-reference a capture group
78642 * which will never be introduced in the pattern. Thus, we can check
78643 * for such references only after parsing is complete.
78644 */
78645
78646 if (re_ctx.highest_backref > re_ctx.captures) {
78648 }
78649
78650 /*
78651 * Emit compiled regexp header: flags, ncaptures
78652 * (insertion order inverted on purpose)
78653 */
78654
78655 duk__insert_u32(&re_ctx, 0, (re_ctx.captures + 1) * 2);
78656 duk__insert_u32(&re_ctx, 0, re_ctx.re_flags);
78657
#define DUK_USE_REGEXP_COMPILER_RECLIMIT
DUK_LOCAL duk_uint32_t duk__parse_regexp_flags(duk_hthread *thr, duk_hstring *h)
#define DUK_RE_COMPILE_TOKEN_LIMIT
DUK_LOCAL void duk__create_escaped_source(duk_hthread *thr, int idx_pattern)
#define DUK__RE_INITIAL_BUFSIZE
#define DUK_STR_INVALID_BACKREFS

◆ duk_regexp_create_instance()

DUK_INTERNAL_DECL void duk_regexp_create_instance ( duk_hthread * thr)

Definition at line 78669 of file duktape-1.8.0/src/duktape.c.

78672 : %!T, escaped source: %!T",
78673 (duk_tval *) duk_get_tval(ctx, -1), (duk_tval *) duk_get_tval(ctx, -2)));
78674}
78675
78676/*
78677 * Create a RegExp instance (E5 Section 15.10.7).
78678 *
78679 * Note: the output stack left by duk_regexp_compile() is directly compatible
78680 * with the input here.
78681 *
78682 * Input stack: [ escaped_source bytecode ] (both as strings)
78683 * Output stack: [ RegExp ]
78684 */
78685
78686DUK_INTERNAL void duk_regexp_create_instance(duk_hthread *thr) {
78687 duk_context *ctx = (duk_context *) thr;
78688 duk_hobject *h;
78689 duk_hstring *h_bc;
78690 duk_small_int_t re_flags;
78691
78692 /* [ ... escape_source bytecode ] */
78693
78694 h_bc = duk_get_hstring(ctx, -1);
78695 DUK_ASSERT(h_bc != NULL);
78696 DUK_ASSERT(DUK_HSTRING_GET_BYTELEN(h_bc) >= 1); /* always at least the header */
78697 DUK_ASSERT(DUK_HSTRING_GET_CHARLEN(h_bc) >= 1);
78698 DUK_ASSERT((duk_small_int_t) DUK_HSTRING_GET_DATA(h_bc)[0] < 0x80); /* flags always encodes to 1 byte */
78699 re_flags = (duk_small_int_t) DUK_HSTRING_GET_DATA(h_bc)[0];
78700
78701 /* [ ... escaped_source bytecode ] */
78702
78703 duk_push_object(ctx);
78704 h = duk_get_hobject(ctx, -1);
78705 DUK_ASSERT(h != NULL);
78706 duk_insert(ctx, -3);
78707
78708 /* [ ... regexp_object escaped_source bytecode ] */
78709
78710 DUK_HOBJECT_SET_CLASS_NUMBER(h, DUK_HOBJECT_CLASS_REGEXP);
78711 DUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, h, thr->builtins[DUK_BIDX_REGEXP_PROTOTYPE]);
78712
78713 duk_xdef_prop_stridx(ctx, -3, DUK_STRIDX_INT_BYTECODE, DUK_PROPDESC_FLAGS_NONE);
78714
78715 /* [ ... regexp_object escaped_source ] */
78716
78717 duk_xdef_prop_stridx(ctx, -2, DUK_STRIDX_SOURCE, DUK_PROPDESC_FLAGS_NONE);

◆ duk_regexp_match()

DUK_INTERNAL_DECL void duk_regexp_match ( duk_hthread * thr)

Definition at line 79719 of file duktape-1.8.0/src/duktape.c.

◆ duk_regexp_match_force_global()

DUK_INTERNAL_DECL void duk_regexp_match_force_global ( duk_hthread * thr)

Definition at line 79726 of file duktape-1.8.0/src/duktape.c.

◆ duk_remove()

DUK_EXTERNAL void duk_remove ( duk_context * ctx,
duk_idx_t index )

Definition at line 15955 of file duktape-1.8.0/src/duktape.c.

15955 {
15956 duk_hthread *thr = (duk_hthread *) ctx;
15957 duk_tval *tv1;
15958 duk_tval *tv2;
15959
15961 DUK_UNREF(thr); /* w/o refcounting */
15962
15963 tv1 = duk_require_tval(ctx, from_index);
15964 DUK_ASSERT(tv1 != NULL);
15965 tv2 = duk_require_tval(ctx, to_index);
15966 DUK_ASSERT(tv2 != NULL);
15967
15968 /* For tv1 == tv2, this is a no-op (no explicit check needed). */
15969 DUK_TVAL_SET_TVAL_UPDREF(thr, tv2, tv1); /* side effects */
15970}
15971
15973 duk_hthread *thr = (duk_hthread *) ctx;
15974 duk_tval *p;
15975 duk_tval *q;
15976#ifdef DUK_USE_REFERENCE_COUNTING
15977 duk_tval tv_tmp;
15978#endif
15979 duk_size_t nbytes;
15980
15982
15983 p = duk_require_tval(ctx, index);
15984 DUK_ASSERT(p != NULL);
15985 q = duk_require_tval(ctx, -1);
15986 DUK_ASSERT(q != NULL);
15987
15988 DUK_ASSERT(q >= p);
15989
15990 /* nbytes zero size case
15991 * <--------->
15992 * [ ... | p | x | x | q ] [ ... | p==q ]
15993 * => [ ... | x | x | q ] [ ... ]

References DUK_ASSERT, DUK_ASSERT_CTX_VALID, duk_require_tval(), DUK_TVAL_SET_TVAL_UPDREF, DUK_UNREF, and NULL.

Referenced by duk_handle_ecma_call_setup(), and duk_put_global_string().

◆ duk_repl_fpclassify()

DUK_INTERNAL int duk_repl_fpclassify ( double x)

Definition at line 8666 of file duktape-1.8.0/src/duktape.c.

8683 {
8685 duk_uint_fast16_t expt;
8686 duk_small_int_t mzero;
8687
8688 u.d = x;
8689 expt = (duk_uint_fast16_t) (u.us[DUK_DBL_IDX_US0] & 0x7ff0UL);
8690 if (expt > 0x0000UL && expt < 0x7ff0UL) {
8691 /* expt values [0x001,0x7fe] = normal */
8692 return DUK_FP_NORMAL;
8693 }
8694
duk_uint16_t duk_uint_fast16_t

References duk_double_union::d, DUK_FP_NORMAL, duk_double_union::ui, and duk_double_union::us.

◆ duk_repl_isfinite()

DUK_INTERNAL int duk_repl_isfinite ( double x)

Definition at line 8706 of file duktape-1.8.0/src/duktape.c.

8707 {
8708 return DUK_FP_NAN;
8709 }
8710 }
8711}
8712#endif
8713

◆ duk_repl_isinf()

DUK_INTERNAL int duk_repl_isinf ( double x)

Definition at line 8724 of file duktape-1.8.0/src/duktape.c.

8725 {
8726 return 0;
8727 } else {

◆ duk_repl_isnan()

DUK_INTERNAL int duk_repl_isnan ( double x)

Definition at line 8717 of file duktape-1.8.0/src/duktape.c.

◆ duk_repl_signbit()

DUK_INTERNAL int duk_repl_signbit ( double x)

Definition at line 8698 of file duktape-1.8.0/src/duktape.c.

8698 {
8699 return DUK_FP_ZERO;
8700 } else {
8701 return DUK_FP_SUBNORMAL;
8702 }

References DUK_FP_ZERO.

◆ duk_replace()

DUK_EXTERNAL void duk_replace ( duk_context * ctx,
duk_idx_t to_index )

Definition at line 15915 of file duktape-1.8.0/src/duktape.c.

15915 : to_index=%ld, p=%p, q=%p, nbytes=%lu",
15916 (long) to_index, (void *) p, (void *) q, (unsigned long) nbytes));
15917
15918 /* No net refcount changes. */
15919
15920 if (nbytes > 0) {
15921 DUK_TVAL_SET_TVAL(&tv_tmp, q);
15922 DUK_ASSERT(nbytes > 0);
15923 DUK_MEMMOVE((void *) (p + 1), (const void *) p, (size_t) nbytes);
15924 DUK_TVAL_SET_TVAL(p, &tv_tmp);
15925 } else {
15926 /* nop: insert top to top */
15927 DUK_ASSERT(nbytes == 0);
15928 DUK_ASSERT(p == q);
15929 }
15930}
15931
15932DUK_EXTERNAL void duk_replace(duk_context *ctx, duk_idx_t to_index) {
15933 duk_hthread *thr = (duk_hthread *) ctx;
15934 duk_tval *tv1;
15935 duk_tval *tv2;
15936 duk_tval tv_tmp;

Referenced by duk__error_getter_helper(), duk__expr_led(), duk_hobject_define_property_helper(), duk_js_instanceof(), duk_lexer_initctx(), duk_lexer_parse_js_input_element(), and duk_to_defaultvalue().

◆ duk_require_boolean()

DUK_EXTERNAL duk_bool_t duk_require_boolean ( duk_context * ctx,
duk_idx_t index )

Definition at line 16115 of file duktape-1.8.0/src/duktape.c.

16117 {
16118 duk_bool_t ret = 0; /* default: false */
16119 duk_tval *tv;
16120
16122
16123 tv = duk_get_tval(ctx, index);
16124 if (tv && DUK_TVAL_IS_BOOLEAN(tv)) {
16125 ret = DUK_TVAL_GET_BOOLEAN(tv);
16126 }
16127
16128 DUK_ASSERT(ret == 0 || ret == 1);
16129 return ret;

◆ duk_require_buffer()

DUK_EXTERNAL void * duk_require_buffer ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_size )

Definition at line 16336 of file duktape-1.8.0/src/duktape.c.

16337 {
16338 *out_size = DUK_HBUFFER_GET_SIZE(h);

◆ duk_require_buffer_data()

DUK_EXTERNAL void * duk_require_buffer_data ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_size )

Definition at line 16398 of file duktape-1.8.0/src/duktape.c.

◆ duk_require_c_function()

DUK_EXTERNAL duk_c_function duk_require_c_function ( duk_context * ctx,
duk_idx_t index )

Definition at line 16539 of file duktape-1.8.0/src/duktape.c.

16541 {
16542 return NULL;
16543 }
16544 h = DUK_TVAL_GET_OBJECT(tv);
16545 DUK_ASSERT(h != NULL);
16546
16548 return NULL;
16549 }

◆ duk_require_context()

DUK_EXTERNAL duk_context * duk_require_context ( duk_context * ctx,
duk_idx_t index )

Definition at line 16564 of file duktape-1.8.0/src/duktape.c.

◆ duk_require_function()

DUK_EXTERNAL void duk_require_function ( duk_context * ctx,
duk_idx_t index )

Definition at line 16552 of file duktape-1.8.0/src/duktape.c.

16556 {

◆ duk_require_hbuffer()

DUK_INTERNAL_DECL duk_hbuffer * duk_require_hbuffer ( duk_context * ctx,
duk_idx_t index )

◆ duk_require_hcompiledfunction()

DUK_INTERNAL_DECL duk_hcompiledfunction * duk_require_hcompiledfunction ( duk_context * ctx,
duk_idx_t index )

◆ duk_require_heapptr()

DUK_EXTERNAL void * duk_require_heapptr ( duk_context * ctx,
duk_idx_t index )

Definition at line 16586 of file duktape-1.8.0/src/duktape.c.

16587 {
16588 duk_tval *tv;
16589 void *ret;
16590
16592
16593 tv = duk_get_tval(ctx, index);
16594 if (tv && DUK_TVAL_IS_HEAP_ALLOCATED(tv)) {
16595 ret = (void *) DUK_TVAL_GET_HEAPHDR(tv);
16596 DUK_ASSERT(ret != NULL);
16597 return ret;
16598 }
16599
16600 return (void *) NULL;
16601}
16602
DUK_EXTERNAL void * duk_require_heapptr(duk_context *ctx, duk_idx_t index)

References DUK_ASSERT, DUK_ASSERT_CTX_VALID, duk_get_tval(), DUK_TVAL_GET_HEAPHDR, DUK_TVAL_IS_HEAP_ALLOCATED, index, and NULL.

◆ duk_require_hnativefunction()

◆ duk_require_hobject()

◆ duk_require_hobject_or_lfunc()

DUK_INTERNAL_DECL duk_hobject * duk_require_hobject_or_lfunc ( duk_context * ctx,
duk_idx_t index )

Definition at line 16638 of file duktape-1.8.0/src/duktape.c.

16642 {
16643 return DUK_TVAL_GET_OBJECT(tv);
16644 } else if (DUK_TVAL_IS_LIGHTFUNC(tv)) {
16645 duk_to_object(ctx, index);
16646 return duk_require_hobject(ctx, index);
16647 }
16648
16649 return NULL;
16650}
16651
16652/* Useful for internal call sites where we either expect an object (function)
16653 * or a lightfunc. Returns NULL for a lightfunc.

Referenced by duk_bi_object_constructor_is_extensible().

◆ duk_require_hobject_or_lfunc_coerce()

DUK_INTERNAL_DECL duk_hobject * duk_require_hobject_or_lfunc_coerce ( duk_context * ctx,
duk_idx_t index )

Definition at line 16659 of file duktape-1.8.0/src/duktape.c.

16663 {
16664 return DUK_TVAL_GET_OBJECT(tv);
16665 } else if (DUK_TVAL_IS_LIGHTFUNC(tv)) {
16666 return NULL;
16667 }
16669 return NULL; /* not reachable */
16670}
16671
16672/* Useful for internal call sites where we either expect an object (function)
16673 * or a lightfunc. Accepts an object (returned as is) or a lightfunc (coerced
16674 * to an object). Return value is never NULL.
#define DUK_STR_NOT_OBJECT

◆ duk_require_hobject_with_class()

DUK_INTERNAL_DECL duk_hobject * duk_require_hobject_with_class ( duk_context * ctx,
duk_idx_t index,
duk_small_uint_t classnum )

Definition at line 16690 of file duktape-1.8.0/src/duktape.c.

16693 {
16694 duk_hobject *h;
16695
16697 DUK_ASSERT_DISABLE(classnum >= 0); /* unsigned */
16698 DUK_ASSERT(classnum <= DUK_HOBJECT_CLASS_MAX);
16699
16701 if (h != NULL && DUK_HOBJECT_GET_CLASS_NUMBER(h) != classnum) {
16702 h = NULL;
16703 }
16704 return h;
16705}
16706
16708 duk_hthread *thr;
#define DUK_HOBJECT_CLASS_MAX

Referenced by duk_bi_regexp_constructor().

◆ duk_require_hstring()

DUK_INTERNAL_DECL duk_hstring * duk_require_hstring ( duk_context * ctx,
duk_idx_t index )

Definition at line 16427 of file duktape-1.8.0/src/duktape.c.

16430 {
16431 duk_heaphdr *ret;
16432 ret = DUK_TVAL_GET_HEAPHDR(tv);
16433 DUK_ASSERT(ret != NULL); /* tagged null pointers should never occur */
16434 return ret;

Referenced by duk_hobject_define_property_helper().

◆ duk_require_hthread()

DUK_INTERNAL_DECL duk_hthread * duk_require_hthread ( duk_context * ctx,
duk_idx_t index )

Definition at line 16470 of file duktape-1.8.0/src/duktape.c.

16470 {
16471 duk_heaphdr *h;
16473 if (h == NULL) {
16475 }
16476 return (duk_hbuffer *) h;
16477}

References duk__get_tagged_heaphdr_raw(), DUK_ERROR_REQUIRE_TYPE_INDEX, DUK_STR_NOT_BUFFER, DUK_TAG_BUFFER, index, and NULL.

◆ duk_require_int()

DUK_EXTERNAL duk_int_t duk_require_int ( duk_context * ctx,
duk_idx_t index )

Definition at line 16187 of file duktape-1.8.0/src/duktape.c.

◆ duk_require_lstring()

DUK_EXTERNAL const char * duk_require_lstring ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_len )

Definition at line 16227 of file duktape-1.8.0/src/duktape.c.

16229 {
16230 /* Here we rely on duk_hstring instances always being zero
16231 * terminated even if the actual string is not.
16232 */
16234 DUK_ASSERT(h != NULL);
16235 ret = (const char *) DUK_HSTRING_GET_DATA(h);
16236 if (out_len) {
16237 *out_len = DUK_HSTRING_GET_BYTELEN(h);
16238 }
16239 }
16240
16241 return ret;
16242}

◆ duk_require_normalize_index()

DUK_EXTERNAL duk_idx_t duk_require_normalize_index ( duk_context * ctx,
duk_idx_t index )

Definition at line 15223 of file duktape-1.8.0/src/duktape.c.

15223 {
15224 uindex = vs_size + (duk_uidx_t) index;
15225 } else {
15226 /* since index non-negative */
15228 uindex = (duk_uidx_t) index;
15229 }
15230
15231 /* DUK_INVALID_INDEX won't be accepted as a valid index. */
15232 DUK_ASSERT(vs_size + (duk_uidx_t) DUK_INVALID_INDEX >= vs_size);
15233
15234 if (DUK_LIKELY(uindex < vs_size)) {
15235 return (duk_idx_t) uindex;
15236 }
15237 return DUK_INVALID_INDEX;
15238}
15239
15241 duk_hthread *thr = (duk_hthread *) ctx;
15242 duk_uidx_t vs_size;
15243 duk_uidx_t uindex;
15244
15247
15249 vs_size = (duk_uidx_t) (thr->valstack_top - thr->valstack_bottom);
15250 DUK_ASSERT_DISABLE(vs_size >= 0); /* unsigned */

References index.

Referenced by duk_del_prop_stridx(), duk_get_prop_stridx(), duk_has_prop_stridx(), duk_hobject_prepare_property_descriptor(), duk_put_number_list(), and duk_to_boolean().

◆ duk_require_null()

DUK_EXTERNAL void duk_require_null ( duk_context * ctx,
duk_idx_t index )

Definition at line 16086 of file duktape-1.8.0/src/duktape.c.

16089 {
16090 duk_hthread *thr = (duk_hthread *) ctx;
16091 duk_tval *tv;
16092
16094
16095 tv = duk_get_tval(ctx, index);
16096 if (tv && DUK_TVAL_IS_UNDEFINED(tv)) {
16097 return;
16098 }

References DUK_ASSERT_CTX_VALID, DUK_ERROR_REQUIRE_TYPE_INDEX, duk_get_tval(), DUK_STR_NOT_UNDEFINED, DUK_TVAL_IS_UNDEFINED, and index.

◆ duk_require_number()

DUK_EXTERNAL duk_double_t duk_require_number ( duk_context * ctx,
duk_idx_t index )

Definition at line 16152 of file duktape-1.8.0/src/duktape.c.

16156 {
16157 ret.d = DUK_TVAL_GET_NUMBER(tv);
16158 }
16159
16160 /*
16161 * Number should already be in NaN-normalized form, but let's
16162 * normalize anyway.
16163 */
16164
16166 return ret.d;
16167}
16168
16170 duk_hthread *thr = (duk_hthread *) ctx;
16171 duk_tval *tv;
16172

◆ duk_require_pointer()

DUK_EXTERNAL void * duk_require_pointer ( duk_context * ctx,
duk_idx_t index )

Definition at line 16270 of file duktape-1.8.0/src/duktape.c.

16273 {
16274 duk_tval *tv;
16275
16277
16278 tv = duk_get_tval(ctx, index);
16279 if (tv && DUK_TVAL_IS_POINTER(tv)) {
16280 void *p = DUK_TVAL_GET_POINTER(tv); /* may be NULL */
16281 return (void *) p;
16282 }
16283
16284 return NULL;
16285}
16286

◆ duk_require_stack()

DUK_EXTERNAL void duk_require_stack ( duk_context * ctx,
duk_idx_t extra )

Definition at line 15743 of file duktape-1.8.0/src/duktape.c.

15745 {
15746 /* Clamping to zero makes the API more robust to calling code
15747 * calculation errors.
15748 */
15749 extra = 0;
15750 }
15751
15752 min_new_size = (thr->valstack_top - thr->valstack) + extra + DUK_VALSTACK_INTERNAL_EXTRA;
15753 return duk_valstack_resize_raw(ctx,
15754 min_new_size, /* min_new_size */
15755 0 /* no shrink */ | /* flags */
15756 0 /* no compact */ |
15757 0 /* no throw */);
15758}
15759
15761 duk_hthread *thr = (duk_hthread *) ctx;
15762 duk_size_t min_new_size;
15763

Referenced by duk__error_getter_helper(), duk__parse_func_body(), and duk_err_create_and_throw().

◆ duk_require_stack_top()

DUK_EXTERNAL void duk_require_stack_top ( duk_context * ctx,
duk_idx_t top )

Definition at line 15787 of file duktape-1.8.0/src/duktape.c.

15789 {
15790 /* Clamping to zero makes the API more robust to calling code
15791 * calculation errors.
15792 */
15793 top = 0;
15794 }
15795
15796 min_new_size = (thr->valstack_bottom - thr->valstack) + top + DUK_VALSTACK_INTERNAL_EXTRA;
15797 return duk_valstack_resize_raw(ctx,
15798 min_new_size, /* min_new_size */
15799 0 /* no shrink */ | /* flags */
15800 0 /* no compact */ |
15801 0 /* no throw */);
15802}
15803
15805 duk_hthread *thr;
15806 duk_size_t min_new_size;
15807

◆ duk_require_string()

DUK_EXTERNAL const char * duk_require_string ( duk_context * ctx,
duk_idx_t index )

Definition at line 16250 of file duktape-1.8.0/src/duktape.c.

16254 {

◆ duk_require_top_index()

DUK_EXTERNAL duk_idx_t duk_require_top_index ( duk_context * ctx)

Definition at line 15455 of file duktape-1.8.0/src/duktape.c.

15455 {
15456 duk_hthread *thr = (duk_hthread *) ctx;
15457 duk_idx_t ret;
15458
15460
15461 ret = ((duk_idx_t) (thr->valstack_top - thr->valstack_bottom)) - 1;
15462 if (DUK_UNLIKELY(ret < 0)) {
15463 /* Return invalid index; if caller uses this without checking
15464 * in another API call, the index won't map to a valid stack
15465 * entry.
15466 */
15467 return DUK_INVALID_INDEX;

References DUK_ASSERT_CTX_VALID, DUK_INVALID_INDEX, DUK_UNLIKELY, duk_hthread::valstack_bottom, and duk_hthread::valstack_top.

◆ duk_require_tval()

DUK_INTERNAL_DECL duk_tval * duk_require_tval ( duk_context * ctx,
duk_idx_t index )

Definition at line 15280 of file duktape-1.8.0/src/duktape.c.

15281 {
15282 uindex = vs_size + (duk_uidx_t) index;
15283 } else {
15285 uindex = (duk_uidx_t) index;
15286 }
15287
15288 /* DUK_INVALID_INDEX won't be accepted as a valid index. */
15289 DUK_ASSERT(vs_size + (duk_uidx_t) DUK_INVALID_INDEX >= vs_size);
15290
15291 if (DUK_LIKELY(uindex < vs_size)) {
15292 return thr->valstack_bottom + uindex;
15293 }
15294 return NULL;
15295}
15296
15298 duk_hthread *thr = (duk_hthread *) ctx;
15299 duk_uidx_t vs_size;
15300 duk_uidx_t uindex;
15301
15304
15306 vs_size = (duk_uidx_t) (thr->valstack_top - thr->valstack_bottom);
15307 DUK_ASSERT_DISABLE(vs_size >= 0); /* unsigned */
15308

References index.

Referenced by duk_dup_top(), duk_get_hobject_with_class(), duk_hobject_define_property_helper(), duk_hobject_define_property_internal(), duk_hobject_prepare_property_descriptor(), duk_hobject_putprop(), duk_remove(), duk_to_uint16(), and duk_to_uint32().

◆ duk_require_uint()

DUK_EXTERNAL duk_uint_t duk_require_uint ( duk_context * ctx,
duk_idx_t index )

Definition at line 16193 of file duktape-1.8.0/src/duktape.c.

◆ duk_require_undefined()

DUK_EXTERNAL void duk_require_undefined ( duk_context * ctx,
duk_idx_t index )

Definition at line 16072 of file duktape-1.8.0/src/duktape.c.

16077 {
16078 p--;
16080 /* XXX: fast primitive to set a bunch of values to UNDEFINED */
16081 }
16082 }
16083}
16084

References DUK_TVAL_SET_UNDEFINED.

◆ duk_require_valid_index()

DUK_EXTERNAL void duk_require_valid_index ( duk_context * ctx,
duk_idx_t index )

Definition at line 15319 of file duktape-1.8.0/src/duktape.c.

15320 {
15321 return thr->valstack_bottom + uindex;
15322 }
15324 return NULL;
15325}
15326
15327/* Non-critical. */

References duk_hthread::valstack_bottom.

◆ duk_resize_buffer()

DUK_EXTERNAL void * duk_resize_buffer ( duk_context * ctx,
duk_idx_t index,
duk_size_t new_size )

Definition at line 11581 of file duktape-1.8.0/src/duktape.c.

11585 {
11586 DUK_DDD(DUK_DDDPRINT("default free function: %p", (void *) ptr));
11587 DUK_UNREF(udata);
11588 DUK_ANSI_FREE(ptr);
11589}
11590#endif /* DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS */
11591#line 1 "duk_api_buffer.c"
11592/*
11593 * Buffer
11594 */
11595
11596/* include removed: duk_internal.h */
11597

◆ duk_resume()

DUK_EXTERNAL void duk_resume ( duk_context * ctx,
const duk_thread_state * state )

Definition at line 14153 of file duktape-1.8.0/src/duktape.c.

14170 {
14171 duk_hthread *thr = (duk_hthread *) ctx;

◆ duk_safe_call()

DUK_EXTERNAL duk_int_t duk_safe_call ( duk_context * ctx,
duk_safe_call_function func,
duk_idx_t nargs,
duk_idx_t nrets )

Definition at line 12586 of file duktape-1.8.0/src/duktape.c.

12591 {
12593 }
12594 duk_push_idx(ctx, nargs);
12595
12596 /* Inputs: explicit arguments (nargs), +1 for key, +2 for obj_index/nargs passing.
12597 * If the value stack does not contain enough args, an error is thrown; this matches
12598 * behavior of the other protected call API functions.
12599 */
12600 return duk_safe_call(ctx, duk__pcall_prop_raw, nargs + 1 + 2 /*nargs*/, 1 /*nrets*/);
12601}
12602
12604 duk_hthread *thr = (duk_hthread *) ctx;
12605 duk_int_t rc;
duk_ret_t(* duk_safe_call_function)(duk_context *ctx)
#define duk_push_idx(ctx, val)

◆ duk_safe_to_lstring()

DUK_EXTERNAL const char * duk_safe_to_lstring ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_len )

Definition at line 17064 of file duktape-1.8.0/src/duktape.c.

17067 {
17069
17070 (void) duk_to_string(ctx, index);
17071 return duk_require_lstring(ctx, index, out_len);
17072}
17073
17076
17077 duk_to_string(ctx, -1);
17078 return 1;
17079}
17080
17083
17085
17086 /* We intentionally ignore the duk_safe_call() return value and only
17087 * check the output type. This way we don't also need to check that
17088 * the returned value is indeed a string in the success case.
17089 */
17090
17091 duk_dup(ctx, index);
17092 (void) duk_safe_call(ctx, duk__safe_to_string_raw, 1 /*nargs*/, 1 /*nrets*/);
17093 if (!duk_is_string(ctx, -1)) {
17094 /* Error: try coercing error to string once. */
DUK_EXTERNAL const char * duk_safe_to_lstring(duk_context *ctx, duk_idx_t index, duk_size_t *out_len)
DUK_LOCAL duk_ret_t duk__safe_to_string_raw(duk_context *ctx)

◆ duk_set_finalizer()

DUK_EXTERNAL void duk_set_finalizer ( duk_context * ctx,
duk_idx_t index )

Definition at line 14999 of file duktape-1.8.0/src/duktape.c.

◆ duk_set_global_object()

DUK_EXTERNAL void duk_set_global_object ( duk_context * ctx)

Definition at line 14174 of file duktape-1.8.0/src/duktape.c.

14191 {
14192 duk_hthread *thr = (duk_hthread *) ctx;
14193 duk_hobject *h_glob;
14194 duk_hobject *h_prev_glob;
14195 duk_hobject *h_env;
14196 duk_hobject *h_prev_env;
14197
14198 DUK_D(DUK_DPRINT("replace global object with: %!T", duk_get_tval(ctx, -1)));
14199
14200 h_glob = duk_require_hobject(ctx, -1);
14201 DUK_ASSERT(h_glob != NULL);
14202
14203 /*
14204 * Replace global object.
14205 */
14206
14207 h_prev_glob = thr->builtins[DUK_BIDX_GLOBAL];
14208 DUK_UNREF(h_prev_glob);
14209 thr->builtins[DUK_BIDX_GLOBAL] = h_glob;
14210 DUK_HOBJECT_INCREF(thr, h_glob);
14211 DUK_HOBJECT_DECREF_ALLOWNULL(thr, h_prev_glob); /* side effects, in theory (referenced by global env) */
14212
14213 /*
14214 * Replace lexical environment for global scope
14215 *
14216 * Create a new object environment for the global lexical scope.
14217 * We can't just reset the _Target property of the current one,
14218 * because the lexical scope is shared by other threads with the
14219 * same (initial) built-ins.
14220 */
14221
14222 (void) duk_push_object_helper(ctx,
14225 -1); /* no prototype, updated below */
14226
14227 duk_dup(ctx, -2);
14228 duk_dup(ctx, -3);
14229
14230 /* [ ... new_glob new_env new_glob new_glob ] */
14231
14234
14235 /* [ ... new_glob new_env ] */

◆ duk_set_length()

DUK_INTERNAL_DECL void duk_set_length ( duk_context * ctx,
duk_idx_t index,
duk_size_t length )

Definition at line 16759 of file duktape-1.8.0/src/duktape.c.

16764 :
16765#endif
16766 default:
16767 /* number */
16770 return 0;
16771 }

◆ duk_set_magic()

DUK_EXTERNAL void duk_set_magic ( duk_context * ctx,
duk_idx_t index,
duk_int_t magic )

Definition at line 12934 of file duktape-1.8.0/src/duktape.c.

12936 {
12937 goto type_error;
12938 }
12939 return (duk_int_t) ((duk_hnativefunction *) h)->magic;
12940 } else if (DUK_TVAL_IS_LIGHTFUNC(tv)) {
12942 return (duk_int_t) DUK_LFUNC_FLAGS_GET_MAGIC(lf_flags);

◆ duk_set_prototype()

DUK_EXTERNAL void duk_set_prototype ( duk_context * ctx,
duk_idx_t index )

Definition at line 14958 of file duktape-1.8.0/src/duktape.c.

14968 {
14969 duk_push_hobject(ctx, proto);
14970 } else {
14971 duk_push_undefined(ctx);
14972 }
14973}
14974
14976 duk_hthread *thr = (duk_hthread *) ctx;
14977 duk_hobject *obj;
14979
14981
14982 obj = duk_require_hobject(ctx, index);
DUK_EXTERNAL void duk_set_prototype(duk_context *ctx, duk_idx_t index)

◆ duk_set_top()

DUK_EXTERNAL void duk_set_top ( duk_context * ctx,
duk_idx_t index )

Definition at line 15347 of file duktape-1.8.0/src/duktape.c.

15352 {
15353 duk_hthread *thr = (duk_hthread *) ctx;
15354
15356
15357 return (duk_idx_t) (thr->valstack_top - thr->valstack_bottom);
15358}
15359
15360/* Set stack top within currently allocated range, but don't reallocate.
15361 * This is performance critical especially for call handling, so whenever
15362 * changing, profile and look at generated code.
15363 */
15365 duk_hthread *thr = (duk_hthread *) ctx;
15366 duk_uidx_t vs_size;
15367 duk_uidx_t vs_limit;
15368 duk_uidx_t uindex;
15369 duk_tval *tv;
15370
15373
15376 vs_size = (duk_uidx_t) (thr->valstack_top - thr->valstack_bottom);
15377 vs_limit = (duk_uidx_t) (thr->valstack_end - thr->valstack_bottom);
15378
15379 if (index < 0) {
15380 /* Negative indices are always within allocated stack but
15381 * must not go below zero index.
15382 */
15383 uindex = vs_size + (duk_uidx_t) index;
15384 } else {
15385 /* Positive index can be higher than valstack top but must
15386 * not go above allocated stack (equality is OK).
15387 */
15388 uindex = (duk_uidx_t) index;
15389 }
15390
15391 /* DUK_INVALID_INDEX won't be accepted as a valid index. */
15392 DUK_ASSERT(vs_size + (duk_uidx_t) DUK_INVALID_INDEX >= vs_size);
15393 DUK_ASSERT(vs_size + (duk_uidx_t) DUK_INVALID_INDEX >= vs_limit);
15394
15395#if defined(DUK_USE_VALSTACK_UNSAFE)
15396 DUK_ASSERT(uindex <= vs_limit);
15397 DUK_UNREF(vs_limit);
15398#else
15399 if (DUK_UNLIKELY(uindex > vs_limit)) {
15401 return; /* unreachable */
15402 }
15403#endif
15404 DUK_ASSERT(uindex <= vs_limit);
15405
15406 /* Handle change in value stack top. Respect value stack
15407 * initialization policy: 'undefined' above top. Note that
15408 * DECREF may cause a side effect that reallocates valstack,
15409 * so must relookup after DECREF.
15410 */
15411
15412 if (uindex >= vs_size) {
15413 /* Stack size increases or stays the same. */
15414#if defined(DUK_USE_ASSERTIONS)
15415 duk_uidx_t count;
15416
15417 count = uindex - vs_size;
15418 while (count != 0) {
15419 count--;
15420 tv = thr->valstack_top + count;
15422 }
15423#endif
15424 thr->valstack_top = thr->valstack_bottom + uindex;
15425 } else {
15426 /* Stack size decreases. */
15427#if defined(DUK_USE_REFERENCE_COUNTING)
15428 duk_uidx_t count;
15429
15430 count = vs_size - uindex;
15431 DUK_ASSERT(count > 0);
15432 while (count > 0) {
15433 count--;
15434 tv = --thr->valstack_top; /* tv -> value just before prev top value; must relookup */
15435 DUK_ASSERT(tv >= thr->valstack_bottom);
15436 DUK_TVAL_SET_UNDEFINED_UPDREF(thr, tv); /* side effects */

References DUK_ASSERT_CTX_VALID, duk_hthread::valstack_bottom, and duk_hthread::valstack_top.

Referenced by duk_bi_string_constructor().

◆ duk_steal_buffer()

DUK_EXTERNAL void * duk_steal_buffer ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_size )

Definition at line 11600 of file duktape-1.8.0/src/duktape.c.

11607 {
11609 }
11610
11611 /* maximum size check is handled by callee */
11612 duk_hbuffer_resize(thr, h, new_size);
11613
11614 return DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, h);
11615}
11616
11618 duk_hthread *thr = (duk_hthread *) ctx;
11620 void *ptr;
11621 duk_size_t sz;
11622
11623 DUK_ASSERT(ctx != NULL);
11624
11626 DUK_ASSERT(h != NULL);
11627
DUK_EXTERNAL void * duk_steal_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size)
#define DUK_STR_WRONG_BUFFER_TYPE

◆ duk_strict_equals()

DUK_EXTERNAL duk_bool_t duk_strict_equals ( duk_context * ctx,
duk_idx_t index1,
duk_idx_t index2 )

Definition at line 19561 of file duktape-1.8.0/src/duktape.c.

19568 {
19569 return 0;
19570 }
19571
19572 /* Coercion may be needed, the helper handles that by pushing the
19573 * tagged values to the stack.
19574 */

◆ duk_substring()

DUK_EXTERNAL void duk_substring ( duk_context * ctx,
duk_idx_t index,
duk_size_t start_offset,
duk_size_t end_offset )

Definition at line 19983 of file duktape-1.8.0/src/duktape.c.

19986 {
19987 break;
19988 }
19989 cp = (int) duk_unicode_decode_xutf8_checked(thr, &p, p_start, p_end);
19990 cp = callback(udata, cp);
19991
19992 DUK_BW_WRITE_ENSURE_XUTF8(thr, bw, cp);
19993 }
19994
19995 DUK_BW_COMPACT(thr, bw);
19996 duk_to_string(ctx, -1);
19997 duk_replace(ctx, index);
19998}
19999
20000DUK_EXTERNAL void duk_substring(duk_context *ctx, duk_idx_t index, duk_size_t start_offset, duk_size_t end_offset) {
20001 duk_hthread *thr = (duk_hthread *) ctx;
20002 duk_hstring *h;
20003 duk_hstring *res;
20004 duk_size_t start_byte_offset;
20005 duk_size_t end_byte_offset;
20006
20008
20010 h = duk_require_hstring(ctx, index);
20011 DUK_ASSERT(h != NULL);
20012
20013 if (end_offset >= DUK_HSTRING_GET_CHARLEN(h)) {
20014 end_offset = DUK_HSTRING_GET_CHARLEN(h);
20015 }
20016 if (start_offset > end_offset) {
20017 start_offset = end_offset;
20018 }
20019
20020 DUK_ASSERT_DISABLE(start_offset >= 0);
20021 DUK_ASSERT(start_offset <= end_offset && start_offset <= DUK_HSTRING_GET_CHARLEN(h));
20022 DUK_ASSERT_DISABLE(end_offset >= 0);
20023 DUK_ASSERT(end_offset >= start_offset && end_offset <= DUK_HSTRING_GET_CHARLEN(h));
20024
20025 /* guaranteed by string limits */
#define DUK_BW_WRITE_ENSURE_XUTF8(thr, bw_ctx, cp)

Referenced by duk__get_own_propdesc_raw().

◆ duk_suspend()

DUK_EXTERNAL void duk_suspend ( duk_context * ctx,
duk_thread_state * state )

Definition at line 14122 of file duktape-1.8.0/src/duktape.c.

14126 {
14127 duk_hthread *thr = (duk_hthread *) ctx;
14128 duk_heap *heap;
14129
14130 if (!ctx) {
14131 return;
14132 }
14133 heap = thr->heap;
14134 DUK_ASSERT(heap != NULL);
14135
14136 duk_heap_free(heap);
14137}
14138
14140 duk_hthread *thr = (duk_hthread *) ctx;
14141 duk_internal_thread_state *snapshot = (duk_internal_thread_state *) (void *) state;
14142 duk_heap *heap;
14143 duk_ljstate *lj;
14144
14146 DUK_ASSERT(thr != NULL);
14147 DUK_ASSERT(thr->heap != NULL);
14148 DUK_ASSERT(state != NULL); /* unvalidated */
14149
14150 heap = thr->heap;
14151 lj = &heap->lj;
DUK_EXTERNAL void duk_suspend(duk_context *ctx, duk_thread_state *state)

◆ duk_swap()

DUK_EXTERNAL void duk_swap ( duk_context * ctx,
duk_idx_t index1,
duk_idx_t index2 )

Definition at line 15813 of file duktape-1.8.0/src/duktape.c.

◆ duk_swap_top()

DUK_EXTERNAL void duk_swap_top ( duk_context * ctx,
duk_idx_t index )

Definition at line 15831 of file duktape-1.8.0/src/duktape.c.

◆ duk_throw()

DUK_EXTERNAL void duk_throw ( duk_context * ctx)

Definition at line 19442 of file duktape-1.8.0/src/duktape.c.

19445 {
19447 duk_pop_n(ctx, 2);
19448}
19449
19452 duk_pop_n(ctx, 3);
19453}
19454
19455/*
19456 * Error throwing
19457 */
19458
19460 duk_hthread *thr = (duk_hthread *) ctx;
19461
19462 DUK_ASSERT(thr->valstack_bottom >= thr->valstack);
19464 DUK_ASSERT(thr->valstack_end >= thr->valstack_top);
19465
19466 if (thr->valstack_top == thr->valstack_bottom) {
19468 }
19469
19470 /* Errors are augmented when they are created, not when they are
19471 * thrown or re-thrown. The current error handler, however, runs
19472 * just before an error is thrown.
19473 */
19474
19475 /* Sync so that augmentation sees up-to-date activations, NULL
19476 * thr->ptr_curr_pc so that it's not used if side effects occur
19477 * in augmentation or longjmp handling.
19478 */

◆ duk_to_boolean()

DUK_EXTERNAL duk_bool_t duk_to_boolean ( duk_context * ctx,
duk_idx_t index )

◆ duk_to_buffer_raw()

DUK_EXTERNAL void * duk_to_buffer_raw ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_size,
duk_uint_t mode )

Definition at line 17321 of file duktape-1.8.0/src/duktape.c.

17325 :
17326 return duk_require_string(ctx, index);
17327}
17328
17330 duk_hstring *ret;
17332 duk_to_string(ctx, index);
17333 ret = duk_get_hstring(ctx, index);
17334 DUK_ASSERT(ret != NULL);
17335 return ret;
17336}
17337
17339 duk_hthread *thr = (duk_hthread *) ctx;
17340 duk_hbuffer *h_buf;
17341 const duk_uint8_t *src_data;
17342 duk_size_t src_size;
17343 duk_uint8_t *dst_data;
17344
17346 DUK_UNREF(thr);
17347
17349
17350 h_buf = duk_get_hbuffer(ctx, index);
17351 if (h_buf != NULL) {
17352 /* Buffer is kept as is, with the fixed/dynamic nature of the
17353 * buffer only changed if requested. An external buffer
17354 * is converted into a non-external dynamic buffer in a
17355 * duk_to_dynamic_buffer() call.
17356 */
17357 duk_uint_t tmp;
17358 duk_uint8_t *tmp_ptr;
17359
17360 tmp_ptr = (duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_buf);
17361 src_data = (const duk_uint8_t *) tmp_ptr;
17362 src_size = DUK_HBUFFER_GET_SIZE(h_buf);
17363
17365 if ((tmp == mode && !DUK_HBUFFER_HAS_EXTERNAL(h_buf)) ||
17366 mode == DUK_BUF_MODE_DONTCARE) {
17367 /* Note: src_data may be NULL if input is a zero-size
17368 * dynamic buffer.
17369 */
17370 dst_data = tmp_ptr;
17371 goto skip_copy;
17372 }
17373 } else {
17374 /* Non-buffer value is first ToString() coerced, then converted
17375 * to a buffer (fixed buffer is used unless a dynamic buffer is
17376 * explicitly requested).
17377 */
17378
17379 src_data = (const duk_uint8_t *) duk_to_lstring(ctx, index, &src_size);
17380 }
17381
#define DUK_BUF_MODE_DONTCARE
#define DUK_BUF_MODE_DYNAMIC
DUK_EXTERNAL void * duk_to_buffer_raw(duk_context *ctx, duk_idx_t index, duk_size_t *out_size, duk_uint_t mode)

◆ duk_to_defaultvalue()

DUK_EXTERNAL void duk_to_defaultvalue ( duk_context * ctx,
duk_idx_t index,
duk_int_t hint )

Definition at line 16800 of file duktape-1.8.0/src/duktape.c.

16800 {
16801 if (duk_get_prop_stridx(ctx, index, func_stridx)) {
16802 /* [ ... func ] */
16803 if (duk_is_callable(ctx, -1)) {
16804 duk_dup(ctx, index); /* -> [ ... func this ] */
16805 duk_call_method(ctx, 0); /* -> [ ... retval ] */
16806 if (duk_is_primitive(ctx, -1)) {
16807 duk_replace(ctx, index);
16808 return 1;
16809 }
16810 /* [ ... retval ]; popped below */
16811 }
16812 }
16813 duk_pop(ctx); /* [ ... func/retval ] -> [ ... ] */
16814 return 0;
16815}
16816
16818 duk_hthread *thr = (duk_hthread *) ctx;
16819 duk_hobject *obj;
16820 /* inline initializer for coercers[] is not allowed by old compilers like BCC */
16821 duk_small_int_t coercers[2];
16822
16824 DUK_ASSERT(thr != NULL);
16825
16826 coercers[0] = DUK_STRIDX_VALUE_OF;
16827 coercers[1] = DUK_STRIDX_TO_STRING;
16828
16831
16832 if (hint == DUK_HINT_NONE) {
16834 hint = DUK_HINT_STRING;
16835 } else {
16836 hint = DUK_HINT_NUMBER;
16837 }
#define duk_is_primitive(ctx, index)
#define DUK_STRIDX_VALUE_OF

References duk_call_method(), duk_dup(), duk_get_prop_stridx(), duk_is_callable, duk_is_primitive, duk_pop(), duk_replace(), and index.

Referenced by duk_to_boolean().

◆ duk_to_hstring()

DUK_INTERNAL_DECL duk_hstring * duk_to_hstring ( duk_context * ctx,
duk_idx_t index )

Definition at line 17312 of file duktape-1.8.0/src/duktape.c.

◆ duk_to_int()

◆ duk_to_int32()

DUK_EXTERNAL duk_int32_t duk_to_int32 ( duk_context * ctx,
duk_idx_t index )

Definition at line 16962 of file duktape-1.8.0/src/duktape.c.

16970 {
16971 /* Value coercion (in stack): ToInteger(), E5 Section 9.4
16972 * API return value coercion: custom
16973 */
16976 return (duk_uint_t) duk__api_coerce_d2ui(ctx, index, 0 /*require*/);
16977}
DUK_LOCAL duk_double_t duk__to_int_uint_helper(duk_context *ctx, duk_idx_t index, duk__toint_coercer coerce_func)

◆ duk_to_int_check_range()

DUK_INTERNAL_DECL duk_int_t duk_to_int_check_range ( duk_context * ctx,
duk_idx_t index,
duk_int_t minval,
duk_int_t maxval )

Definition at line 17220 of file duktape-1.8.0/src/duktape.c.

17220 {
17221 *out_clamped = clamped;
17222 } else {

◆ duk_to_int_clamped()

DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped ( duk_context * ctx,
duk_idx_t index,
duk_int_t minval,
duk_int_t maxval )

Definition at line 17215 of file duktape-1.8.0/src/duktape.c.

◆ duk_to_int_clamped_raw()

DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped_raw ( duk_context * ctx,
duk_idx_t index,
duk_int_t minval,
duk_int_t maxval,
duk_bool_t * out_clamped )

Definition at line 17152 of file duktape-1.8.0/src/duktape.c.

17153 {
17154 duk_hthread *thr;
17155 duk_hstring *h_strclass;
17156
17158 DUK_ASSERT(h != NULL);
17159 thr = (duk_hthread *) ctx;
17160 DUK_UNREF(thr);
17161
17162 h_strclass = DUK_HOBJECT_GET_CLASS_STRING(thr->heap, h);
17163 DUK_ASSERT(h_strclass != NULL);
17164 duk_push_sprintf(ctx, "[object %s]", (const char *) DUK_HSTRING_GET_DATA(h_strclass));
17165}
17166#endif /* !DUK_USE_PARANOID_ERRORS */
17167
17168/* XXX: other variants like uint, u32 etc */
17170 duk_hthread *thr = (duk_hthread *) ctx;
17171 duk_tval *tv;
17172 duk_tval tv_tmp;
17173 duk_double_t d, dmin, dmax;
17174 duk_int_t res;
17175 duk_bool_t clamped = 0;
17176
17178
17179 tv = duk_require_tval(ctx, index);
17180 DUK_ASSERT(tv != NULL);
17181 d = duk_js_tointeger(thr, tv); /* E5 Section 9.4, ToInteger() */
17182
17183 dmin = (duk_double_t) minval;
17184 dmax = (duk_double_t) maxval;
17185
17186 if (d < dmin) {
17187 clamped = 1;
17188 res = minval;
17189 d = dmin;
17190 } else if (d > dmax) {
17191 clamped = 1;
17192 res = maxval;
17193 d = dmax;
17194 } else {
17195 res = (duk_int_t) d;
17196 }
17197 DUK_UNREF(d); /* SCANBUILD: with suitable dmin/dmax limits 'd' is unused */
17198 /* 'd' and 'res' agree here */
17199
17200 /* Relookup in case duk_js_tointeger() ends up e.g. coercing an object. */
17201 tv = duk_get_tval(ctx, index);
17202 DUK_ASSERT(tv != NULL); /* not popped by side effect */
17203 DUK_TVAL_SET_TVAL(&tv_tmp, tv);
17204#if defined(DUK_USE_FASTINT)
17205#if (DUK_INT_MAX <= 0x7fffffffL)
17206 DUK_TVAL_SET_FASTINT_I32(tv, res);
17207#else
17208 /* Clamping needed if duk_int_t is 64 bits. */
17209 if (res >= DUK_FASTINT_MIN && res <= DUK_FASTINT_MAX) {
17210 DUK_TVAL_SET_FASTINT(tv, res);
17211 } else {
17212 DUK_TVAL_SET_NUMBER(tv, d);
17213 }
DUK_INTERNAL_DECL duk_int_t duk_to_int_clamped_raw(duk_context *ctx, duk_idx_t index, duk_int_t minval, duk_int_t maxval, duk_bool_t *out_clamped)

References DUK_ASSERT, DUK_ASSERT_CTX_VALID, DUK_HOBJECT_GET_CLASS_STRING, DUK_HSTRING_GET_DATA, duk_push_sprintf(), DUK_UNREF, duk_hthread::heap, and NULL.

◆ duk_to_lstring()

DUK_EXTERNAL const char * duk_to_lstring ( duk_context * ctx,
duk_idx_t index,
duk_size_t * out_len )

Definition at line 17050 of file duktape-1.8.0/src/duktape.c.

17053 {
17054 /* Exact halfway, round to even. */
17055 ret = (duk_uint8_t) d;

Referenced by duk__base64_encode_helper().

◆ duk_to_null()

DUK_EXTERNAL void duk_to_null ( duk_context * ctx,
duk_idx_t index )

Definition at line 16851 of file duktape-1.8.0/src/duktape.c.

16856 {
16857 duk_hthread *thr = (duk_hthread *) ctx;
16858 duk_tval *tv;
16859
16861 DUK_UNREF(thr);

◆ duk_to_number()

◆ duk_to_object()

DUK_EXTERNAL void duk_to_object ( duk_context * ctx,
duk_idx_t index )

Definition at line 17434 of file duktape-1.8.0/src/duktape.c.

17436 :
17437#endif
17438 default:
17439 /* number */
17442 res = NULL;
17443 break;
17444 }
17445
17446 duk_push_pointer(ctx, res);
17447 duk_replace(ctx, index);
17448 return res;
17449}
17450
17452 duk_hthread *thr = (duk_hthread *) ctx;
17453 duk_tval *tv;
17454 duk_uint_t flags = 0; /* shared flags for a subset of types */
17456
17458
17460
17461 tv = duk_require_tval(ctx, index);
17462 DUK_ASSERT(tv != NULL);
17463
17464 switch (DUK_TVAL_GET_TAG(tv)) {
17465 case DUK_TAG_UNDEFINED:
17466 case DUK_TAG_NULL: {
17468 break;
17469 }
17470 case DUK_TAG_BOOLEAN: {
17474 goto create_object;
17475 }
17476 case DUK_TAG_STRING: {
17481 goto create_object;
17482 }
17483 case DUK_TAG_OBJECT: {
17484 /* nop */
17485 break;
17486 }
17487 case DUK_TAG_BUFFER: {
17488 /* A plain buffer coerces to a Duktape.Buffer because it's the
17489 * object counterpart of the plain buffer value. But it might
17490 * still make more sense to produce an ArrayBuffer here?
17491 */
17492
17493 duk_hbufferobject *h_bufobj;
17494 duk_hbuffer *h_val;
17495
17496 h_val = DUK_TVAL_GET_BUFFER(tv);
17497 DUK_ASSERT(h_val != NULL);
17498
17499 h_bufobj = duk_push_bufferobject_raw(ctx,
17504 DUK_ASSERT(h_bufobj != NULL);
17507
17508 h_bufobj->buf = h_val;
17509 DUK_HBUFFER_INCREF(thr, h_val);
17510 DUK_ASSERT(h_bufobj->offset == 0);
17511 h_bufobj->length = (duk_uint_t) DUK_HBUFFER_GET_SIZE(h_val);
17512 DUK_ASSERT(h_bufobj->shift == 0);
17514
17516 goto replace_value;
17517 }
17518 case DUK_TAG_POINTER: {
17522 goto create_object;
17523 }
17524 case DUK_TAG_LIGHTFUNC: {
17525 /* Lightfunc coerces to a Function instance with concrete
17526 * properties. Since 'length' is virtual for Duktape/C
17527 * functions, don't need to define that.
17528 *
17529 * The result is made extensible to mimic what happens to
17530 * strings:
17531 * > Object.isExtensible(Object('foo'))
17532 * true
17533 */
17534 duk_small_uint_t lf_flags;
17535 duk_idx_t nargs;
17536 duk_small_uint_t lf_len;
17537 duk_c_function func;
17539
17540 DUK_TVAL_GET_LIGHTFUNC(tv, func, lf_flags);
17541
17542 nargs = (duk_idx_t) DUK_LFUNC_FLAGS_GET_NARGS(lf_flags);
17543 if (nargs == DUK_LFUNC_NARGS_VARARGS) {
17544 nargs = (duk_idx_t) DUK_VARARGS;
17545 }
17552 /* DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC: omitted here intentionally */
17554 (void) duk__push_c_function_raw(ctx, func, nargs, flags);
17555
17556 lf_len = DUK_LFUNC_FLAGS_GET_LENGTH(lf_flags);
17557 if ((duk_idx_t) lf_len != nargs) {
17558 /* Explicit length is only needed if it differs from 'nargs'. */
17559 duk_push_int(ctx, (duk_int_t) lf_len);
17561 }
17562 duk_push_lightfunc_name(ctx, tv);
17564
17565 nf = duk_get_hnativefunction(ctx, -1);
17566 DUK_ASSERT(nf != NULL);
17567 nf->magic = (duk_int16_t) DUK_LFUNC_FLAGS_GET_MAGIC(lf_flags);
17568
17569 /* Enable DUKFUNC exotic behavior once properties are set up. */
17571 goto replace_value;
17572 }
17573#if defined(DUK_USE_FASTINT)
17574 case DUK_TAG_FASTINT:
17575#endif
17576 default: {
17582 goto create_object;
17583 }
17584 }
17585 return;
DUK_INTERNAL_DECL duk_hnativefunction * duk_get_hnativefunction(duk_context *ctx, duk_idx_t index)
#define DUK_HOBJECT_SET_EXOTIC_DUKFUNC(h)

Referenced by duk_bi_object_getprototype_shared(), and duk_get_hobject_with_class().

◆ duk_to_object_class_string_top()

DUK_INTERNAL_DECL void duk_to_object_class_string_top ( duk_context * ctx)

Definition at line 17106 of file duktape-1.8.0/src/duktape.c.

17114 {
17115 (void) duk_safe_to_string(ctx, index);
17118 return duk_get_hstring(ctx, index);
17119}
17120#endif
17121
17122/* Coerce top into Object.prototype.toString() output. */
17124 duk_hthread *thr;
17125 duk_uint_t typemask;
17126 duk_hstring *h_strclass;
17127
17129 thr = (duk_hthread *) ctx;
17130 DUK_UNREF(thr);
17131
17132 typemask = duk_get_type_mask(ctx, -1);
17133 if (typemask & DUK_TYPE_MASK_UNDEFINED) {
#define duk_safe_to_string(ctx, index)
DUK_INTERNAL_DECL void duk_to_object_class_string_top(duk_context *ctx)

◆ duk_to_pointer()

DUK_EXTERNAL void * duk_to_pointer ( duk_context * ctx,
duk_idx_t index )

Definition at line 17383 of file duktape-1.8.0/src/duktape.c.

17383 {
17384 /* When src_size == 0, src_data may be NULL (if source
17385 * buffer is dynamic), and dst_data may be NULL (if
17386 * target buffer is dynamic). Avoid zero-size memcpy()
17387 * with an invalid pointer.
17388 */
17389 DUK_MEMCPY((void *) dst_data, (const void *) src_data, (size_t) src_size);
17390 }
17391 duk_replace(ctx, index);
17392 skip_copy:
17393
17394 if (out_size) {
17395 *out_size = src_size;
17396 }
17397 return dst_data;
17398}
17399
17401 duk_tval *tv;
17402 void *res;
17403
17405
17407
17408 tv = duk_require_tval(ctx, index);
17409 DUK_ASSERT(tv != NULL);
17410
17411 switch (DUK_TVAL_GET_TAG(tv)) {
17412 case DUK_TAG_UNDEFINED:
17413 case DUK_TAG_NULL:
17414 case DUK_TAG_BOOLEAN:
17415 res = NULL;
17416 break;
17417 case DUK_TAG_POINTER:
17418 res = DUK_TVAL_GET_POINTER(tv);
17419 break;
17420 case DUK_TAG_STRING:
17421 case DUK_TAG_OBJECT:
17422 case DUK_TAG_BUFFER:
17423 /* Heap allocated: return heap pointer which is NOT useful
17424 * for the caller, except for debugging.
17425 */
17426 res = (void *) DUK_TVAL_GET_HEAPHDR(tv);
17427 break;
17428 case DUK_TAG_LIGHTFUNC:
17429 /* Function pointers do not always cast correctly to void *
17430 * (depends on memory and segmentation model for instance),
17431 * so they coerce to NULL.
17432 */

References DUK_MEMCPY.

◆ duk_to_primitive()

DUK_EXTERNAL void duk_to_primitive ( duk_context * ctx,
duk_idx_t index,
duk_int_t hint )

Definition at line 16864 of file duktape-1.8.0/src/duktape.c.

16868 {
16869 duk_hthread *thr = (duk_hthread *) ctx;
16870 duk_tval *tv;
16871
16873 DUK_UNREF(thr);
16874
16875 tv = duk_require_tval(ctx, index);
16876 DUK_ASSERT(tv != NULL);

◆ duk_to_string()

DUK_EXTERNAL const char * duk_to_string ( duk_context * ctx,
duk_idx_t index )

Definition at line 17224 of file duktape-1.8.0/src/duktape.c.

17224 {
17226 }
17227 }
17228
17229 return res;
17230}
17231
17234 return duk_to_int_clamped_raw(ctx, index, minval, maxval, &dummy);
17235}
17236
17238 return duk_to_int_clamped_raw(ctx, index, minval, maxval, NULL); /* out_clamped==NULL -> RangeError if outside range */
17239}
17240
17242 duk_hthread *thr = (duk_hthread *) ctx;
17243 duk_tval *tv;
17244
17246 DUK_UNREF(thr);
17247
17249
17250 tv = duk_require_tval(ctx, index);
17251 DUK_ASSERT(tv != NULL);
17252
17253 switch (DUK_TVAL_GET_TAG(tv)) {
17254 case DUK_TAG_UNDEFINED: {
17256 break;
17257 }
17258 case DUK_TAG_NULL: {
17260 break;
17261 }
17262 case DUK_TAG_BOOLEAN: {
17263 if (DUK_TVAL_GET_BOOLEAN(tv)) {
17265 } else {
17267 }
17268 break;
17269 }
17270 case DUK_TAG_STRING: {
17271 /* nop */
17272 goto skip_replace;
17273 }
17274 case DUK_TAG_OBJECT: {
17276 return duk_to_string(ctx, index); /* Note: recursive call */
17277 }
17278 case DUK_TAG_BUFFER: {
17280
17281 /* Note: this allows creation of internal strings. */
17282
17283 DUK_ASSERT(h != NULL);
17284 duk_push_lstring(ctx,
17285 (const char *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h),
17287 break;
17288 }
17289 case DUK_TAG_POINTER: {
17290 void *ptr = DUK_TVAL_GET_POINTER(tv);
17291 if (ptr != NULL) {
17292 duk_push_sprintf(ctx, DUK_STR_FMT_PTR, (void *) ptr);
17293 } else {
17294 /* Represent a null pointer as 'null' to be consistent with
17295 * the JX format variant. Native '%p' format for a NULL
17296 * pointer may be e.g. '(nil)'.
17297 */
17299 }
17300 break;
17301 }
17302 case DUK_TAG_LIGHTFUNC: {
17303 /* Should match Function.prototype.toString() */
17305 break;
17306 }
17307#if defined(DUK_USE_FASTINT)
17308 case DUK_TAG_FASTINT:
17309#endif
17310 default: {
#define DUK_STR_NUMBER_OUTSIDE_RANGE

References DUK_ERROR_RANGE, and DUK_STR_NUMBER_OUTSIDE_RANGE.

Referenced by duk__create_escaped_source(), duk_bi_proxy_constructor(), and duk_bi_string_constructor().

◆ duk_to_uint()

DUK_EXTERNAL duk_uint_t duk_to_uint ( duk_context * ctx,
duk_idx_t index )

Definition at line 16953 of file duktape-1.8.0/src/duktape.c.

◆ duk_to_uint16()

DUK_EXTERNAL duk_uint16_t duk_to_uint16 ( duk_context * ctx,
duk_idx_t index )

Definition at line 16996 of file duktape-1.8.0/src/duktape.c.

16996 {
16997 duk_hthread *thr = (duk_hthread *) ctx;
16998 duk_tval *tv;
16999 duk_uint32_t ret;
17000
17002
17003 tv = duk_require_tval(ctx, index);
17004 DUK_ASSERT(tv != NULL);
17005 ret = duk_js_touint32(thr, tv);
17006
17007 /* Relookup in case coerce_func() has side effects, e.g. ends up coercing an object */
17008 tv = duk_require_tval(ctx, index);
17009 DUK_TVAL_SET_FASTINT_U32_UPDREF(thr, tv, ret); /* side effects */
17010 return ret;
17011}

References DUK_ASSERT, DUK_ASSERT_CTX_VALID, duk_js_touint32(), duk_require_tval(), DUK_TVAL_SET_FASTINT_U32_UPDREF, index, and NULL.

◆ duk_to_uint32()

DUK_EXTERNAL duk_uint32_t duk_to_uint32 ( duk_context * ctx,
duk_idx_t index )

Definition at line 16979 of file duktape-1.8.0/src/duktape.c.

16979 {
16980 duk_hthread *thr = (duk_hthread *) ctx;
16981 duk_tval *tv;
16982 duk_int32_t ret;
16983
16985
16986 tv = duk_require_tval(ctx, index);
16987 DUK_ASSERT(tv != NULL);
16988 ret = duk_js_toint32(thr, tv);
16989
16990 /* Relookup in case coerce_func() has side effects, e.g. ends up coercing an object */
16991 tv = duk_require_tval(ctx, index);
16992 DUK_TVAL_SET_FASTINT_I32_UPDREF(thr, tv, ret); /* side effects */
16993 return ret;
16994}

References DUK_ASSERT, DUK_ASSERT_CTX_VALID, duk_js_toint32(), duk_require_tval(), DUK_TVAL_SET_FASTINT_I32_UPDREF, index, and NULL.

Referenced by duk__push_this_obj_len_u32_limited(), and duk_hobject_putprop().

◆ duk_to_uint8clamped()

DUK_INTERNAL_DECL duk_uint8_t duk_to_uint8clamped ( duk_context * ctx,
duk_idx_t index )

Definition at line 17015 of file duktape-1.8.0/src/duktape.c.

17032 {
17033 duk_double_t d;
17034 duk_double_t t;
17035 duk_uint8_t ret;
17036
17037 /* XXX: Simplify this algorithm, should be possible to come up with
17038 * a shorter and faster algorithm by inspecting IEEE representation
17039 * directly.
17040 */
17041
17042 d = duk_to_number(ctx, index);
17043 if (d <= 0.0) {
17044 return 0;
17045 } else if (d >= 255) {
17046 return 255;
17047 } else if (DUK_ISNAN(d)) {

◆ duk_to_undefined()

DUK_EXTERNAL void duk_to_undefined ( duk_context * ctx,
duk_idx_t index )

Definition at line 16839 of file duktape-1.8.0/src/duktape.c.

16840 {
16841 coercers[0] = DUK_STRIDX_TO_STRING;
16842 coercers[1] = DUK_STRIDX_VALUE_OF;
16843 }
16844
16845 if (duk__defaultvalue_coerce_attempt(ctx, index, coercers[0])) {
16846 return;
16847 }
16848
16849 if (duk__defaultvalue_coerce_attempt(ctx, index, coercers[1])) {
DUK_LOCAL duk_bool_t duk__defaultvalue_coerce_attempt(duk_context *ctx, duk_idx_t index, duk_small_int_t func_stridx)

References DUK_STRIDX_TO_STRING, and DUK_STRIDX_VALUE_OF.

Referenced by duk_lexer_parse_js_input_element().

◆ duk_trim()

DUK_EXTERNAL void duk_trim ( duk_context * ctx,
duk_idx_t index )

Definition at line 20030 of file duktape-1.8.0/src/duktape.c.

20047 {
20048 duk_hthread *thr = (duk_hthread *) ctx;
20049 duk_hstring *h;
20050 const duk_uint8_t *p, *p_start, *p_end, *p_tmp1, *p_tmp2; /* pointers for scanning */
20051 const duk_uint8_t *q_start, *q_end; /* start (incl) and end (excl) of trimmed part */
20052 duk_codepoint_t cp;
20053
20055
20057 h = duk_require_hstring(ctx, index);
20058 DUK_ASSERT(h != NULL);
20059
20060 p_start = DUK_HSTRING_GET_DATA(h);
20061 p_end = p_start + DUK_HSTRING_GET_BYTELEN(h);
20062
20063 p = p_start;
20064 while (p < p_end) {
20065 p_tmp1 = p;
20066 cp = (duk_codepoint_t) duk_unicode_decode_xutf8_checked(thr, &p_tmp1, p_start, p_end);
20068 break;
20069 }
20070 p = p_tmp1;
20071 }
20072 q_start = p;
20073 if (p == p_end) {
20074 /* entire string is whitespace */
20075 q_end = p;
20076 goto scan_done;
20077 }
20078
20079 p = p_end;
20080 while (p > p_start) {
20081 p_tmp1 = p;
20082 while (p > p_start) {
20083 p--;
20084 if (((*p) & 0xc0) != 0x80) {
20085 break;
20086 }
20087 }
20088 p_tmp2 = p;
20089
20090 cp = (duk_codepoint_t) duk_unicode_decode_xutf8_checked(thr, &p_tmp2, p_start, p_end);
20092 p = p_tmp1;
20093 break;
20094 }
20095 }
20096 q_end = p;
20097
20098 scan_done:
20099 /* This may happen when forward and backward scanning disagree
20100 * (possible for non-extended-UTF-8 strings).
20101 */
20102 if (q_end < q_start) {
20103 q_end = q_start;
20104 }

◆ duk_tval_decref()

◆ duk_unicode_case_convert_string()

DUK_INTERNAL_DECL void duk_unicode_case_convert_string ( duk_hthread * thr,
duk_bool_t uppercase )

Definition at line 10934 of file duktape-1.8.0/src/duktape.c.

10934 :
10935 if (bw != NULL) {
10937 }
10938 return cp;
10939
10940 /* unused now, not needed until Turkish/Azeri */
10941#if 0
10942 nochar:
10943 return -1;
10944#endif
10945}
10946
10947/*
10948 * Replace valstack top with case converted version.
10949 */
10950
10952 duk_context *ctx = (duk_context *) thr;
10953 duk_hstring *h_input;
10954 duk_bufwriter_ctx bw_alloc;
10956 const duk_uint8_t *p, *p_start, *p_end;
10957 duk_codepoint_t prev, curr, next;
10958
10959 h_input = duk_require_hstring(ctx, -1);
10960 DUK_ASSERT(h_input != NULL);
10961
10962 bw = &bw_alloc;
10964
10965 /* [ ... input buffer ] */
10966
10967 p_start = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input);
10968 p_end = p_start + DUK_HSTRING_GET_BYTELEN(h_input);
10969 p = p_start;
10970
10971 prev = -1; DUK_UNREF(prev);
10972 curr = -1;
10973 next = -1;
10974 for (;;) {
10975 prev = curr;
10976 curr = next;
10977 next = -1;
10978 if (p < p_end) {
10979 next = (int) duk_unicode_decode_xutf8_checked(thr, &p, p_start, p_end);
10980 } else {
10981 /* end of input and last char has been processed */
10982 if (curr < 0) {
10983 break;
10984 }
10985 }
10986
10987 /* on first round, skip */
10988 if (curr >= 0) {
10989 /* XXX: could add a fast path to process chunks of input codepoints,
10990 * but relative benefit would be quite small.
10991 */

References DUK_BW_WRITE_RAW_XUTF8.

Referenced by duk_bi_string_prototype_indexof_shared().

◆ duk_unicode_decode_xutf8()

DUK_INTERNAL_DECL duk_small_int_t duk_unicode_decode_xutf8 ( duk_hthread * thr,
const duk_uint8_t ** ptr,
const duk_uint8_t * ptr_start,
const duk_uint8_t * ptr_end,
duk_ucodepoint_t * out_cp )

Definition at line 10114 of file duktape-1.8.0/src/duktape.c.

10131 {
10132 const duk_uint8_t *p;
10133 duk_uint32_t res;
10136
10137 DUK_UNREF(thr);
10138
10139 p = *ptr;
10140 if (p < ptr_start || p >= ptr_end) {
10141 goto fail;
10142 }
10143
10144 /*
10145 * UTF-8 decoder which accepts longer than standard byte sequences.
10146 * This allows full 32-bit code points to be used.
10147 */
10148
10149 ch = (duk_uint_fast8_t) (*p++);
10150 if (ch < 0x80) {
10151 /* 0xxx xxxx [7 bits] */
10152 res = (duk_uint32_t) (ch & 0x7f);
10153 n = 0;
10154 } else if (ch < 0xc0) {
10155 /* 10xx xxxx -> invalid */
10156 goto fail;
10157 } else if (ch < 0xe0) {
10158 /* 110x xxxx 10xx xxxx [11 bits] */
10159 res = (duk_uint32_t) (ch & 0x1f);
10160 n = 1;
10161 } else if (ch < 0xf0) {
10162 /* 1110 xxxx 10xx xxxx 10xx xxxx [16 bits] */
10163 res = (duk_uint32_t) (ch & 0x0f);
10164 n = 2;
10165 } else if (ch < 0xf8) {
10166 /* 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx [21 bits] */
10167 res = (duk_uint32_t) (ch & 0x07);
10168 n = 3;
10169 } else if (ch < 0xfc) {
10170 /* 1111 10xx 10xx xxxx 10xx xxxx 10xx xxxx 10xx xxxx [26 bits] */
10171 res = (duk_uint32_t) (ch & 0x03);
10172 n = 4;
10173 } else if (ch < 0xfe) {
10174 /* 1111 110x 10xx xxxx 10xx xxxx 10xx xxxx 10xx xxxx 10xx xxxx [31 bits] */
10175 res = (duk_uint32_t) (ch & 0x01);
10176 n = 5;
10177 } else if (ch < 0xff) {
10178 /* 1111 1110 10xx xxxx 10xx xxxx 10xx xxxx 10xx xxxx 10xx xxxx 10xx xxxx [36 bits] */
10179 res = (duk_uint32_t) (0);
10180 n = 6;
10181 } else {
10182 /* 8-byte format could be:
10183 * 1111 1111 10xx xxxx 10xx xxxx 10xx xxxx 10xx xxxx 10xx xxxx 10xx xxxx 10xx xxxx [41 bits]
10184 *
10185 * However, this format would not have a zero bit following the
10186 * leading one bits and would not allow 0xFF to be used as an
10187 * "invalid xutf-8" marker for internal keys. Further, 8-byte
10188 * encodings (up to 41 bit code points) are not currently needed.
10189 */
10190 goto fail;
10191 }
10192
10193 DUK_ASSERT(p >= ptr_start); /* verified at beginning */
10194 if (p + n > ptr_end) {
10195 /* check pointer at end */

◆ duk_unicode_decode_xutf8_checked()

DUK_INTERNAL_DECL duk_ucodepoint_t duk_unicode_decode_xutf8_checked ( duk_hthread * thr,
const duk_uint8_t ** ptr,
const duk_uint8_t * ptr_start,
const duk_uint8_t * ptr_end )

Definition at line 10198 of file duktape-1.8.0/src/duktape.c.

10199 {
10200 DUK_ASSERT(p >= ptr_start && p < ptr_end);
10201 res = res << 6;
10202 res += (duk_uint32_t) ((*p++) & 0x3f);
10203 n--;
10204 }
10205
10206 *ptr = p;
10207 *out_cp = res;

References DUK_ASSERT.

Referenced by duk__inp_get_prev_cp(), duk__utf8_backtrack(), and duk_hstring_char_code_at_raw().

◆ duk_unicode_encode_cesu8()

DUK_INTERNAL_DECL duk_small_int_t duk_unicode_encode_cesu8 ( duk_ucodepoint_t cp,
duk_uint8_t * out )

Definition at line 10054 of file duktape-1.8.0/src/duktape.c.

10055 {
10056 /* Note: masking of 'x' is not necessary because of
10057 * range check and shifting -> no bits overlapping
10058 * the marker should be set.
10059 */
10060 out[0] = (duk_uint8_t) (marker + x);
10061 }
10062 } while (i > 0);
10063
10064 return len;
10065}
10066
10067/* Encode to CESU-8; 'out' must have space for at least
10068 * DUK_UNICODE_MAX_CESU8_LENGTH bytes; codepoints above U+10FFFF
10069 * will encode to garbage but won't overwrite the output buffer.
10070 */
10073 duk_small_int_t len;
10074
10075 if (x < 0x80UL) {
10076 out[0] = (duk_uint8_t) x;
10077 len = 1;
10078 } else if (x < 0x800UL) {
10079 out[0] = (duk_uint8_t) (0xc0 + ((x >> 6) & 0x1f));
10080 out[1] = (duk_uint8_t) (0x80 + (x & 0x3f));
10081 len = 2;
10082 } else if (x < 0x10000UL) {
10083 /* surrogate pairs get encoded here */
10084 out[0] = (duk_uint8_t) (0xe0 + ((x >> 12) & 0x0f));
10085 out[1] = (duk_uint8_t) (0x80 + ((x >> 6) & 0x3f));
10086 out[2] = (duk_uint8_t) (0x80 + (x & 0x3f));
10087 len = 3;
10088 } else {
10089 /*
10090 * Unicode codepoints above U+FFFF are encoded as surrogate
10091 * pairs here. This ensures that all CESU-8 codepoints are
10092 * 16-bit values as expected in Ecmascript. The surrogate
10093 * pairs always get a 3-byte encoding (each) in CESU-8.
10094 * See: http://en.wikipedia.org/wiki/Surrogate_pair
10095 *
10096 * 20-bit codepoint, 10 bits (A and B) per surrogate pair:
10097 *
10098 * x = 0b00000000 0000AAAA AAAAAABB BBBBBBBB
10099 * sp1 = 0b110110AA AAAAAAAA (0xd800 + ((x >> 10) & 0x3ff))
10100 * sp2 = 0b110111BB BBBBBBBB (0xdc00 + (x & 0x3ff))
10101 *
10102 * Encoded into CESU-8:
10103 *
10104 * sp1 -> 0b11101101 (0xe0 + ((sp1 >> 12) & 0x0f))
10105 * -> 0b1010AAAA (0x80 + ((sp1 >> 6) & 0x3f))
10106 * -> 0b10AAAAAA (0x80 + (sp1 & 0x3f))
10107 * sp2 -> 0b11101101 (0xe0 + ((sp2 >> 12) & 0x0f))
10108 * -> 0b1011BBBB (0x80 + ((sp2 >> 6) & 0x3f))
10109 * -> 0b10BBBBBB (0x80 + (sp2 & 0x3f))
10110 *
10111 * Note that 0x10000 must be subtracted first. The code below

◆ duk_unicode_encode_xutf8()

DUK_INTERNAL_DECL duk_small_int_t duk_unicode_encode_xutf8 ( duk_ucodepoint_t cp,
duk_uint8_t * out )

Definition at line 10020 of file duktape-1.8.0/src/duktape.c.

10029 {
10030 0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe
10031};
10032
10033/* Encode to extended UTF-8; 'out' must have space for at least
10034 * DUK_UNICODE_MAX_XUTF8_LENGTH bytes. Allows encoding of any
10035 * 32-bit (unsigned) codepoint.
10036 */
10039 duk_small_int_t len;
10040 duk_uint8_t marker;
10042
10044 DUK_ASSERT(len > 0);
10045
10046 marker = duk_unicode_xutf8_markers[len - 1]; /* 64-bit OK because always >= 0 */
10047
10048 i = len;
DUK_INTERNAL const duk_uint8_t duk_unicode_xutf8_markers[7]

◆ duk_unicode_get_xutf8_length()

DUK_INTERNAL_DECL duk_small_int_t duk_unicode_get_xutf8_length ( duk_ucodepoint_t cp)

Definition at line 9964 of file duktape-1.8.0/src/duktape.c.

9964 : IdentifierPart only
9965 */
9966 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00...0x0f */
9967 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10...0x1f */
9968 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20...0x2f */
9969 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, /* 0x30...0x3f */
9970 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x40...0x4f */
9971 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, /* 0x50...0x5f */
9972 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x60...0x6f */
9973 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 /* 0x70...0x7f */
9974};
9975#endif
9976
9977/*
9978 * XUTF-8 and CESU-8 encoding/decoding
9979 */
9980
9983 if (x < 0x80UL) {
9984 /* 7 bits */
9985 return 1;
9986 } else if (x < 0x800UL) {
9987 /* 11 bits */
9988 return 2;

Referenced by duk__append_jump_offset().

◆ duk_unicode_is_identifier_part()

DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_identifier_part ( duk_codepoint_t cp)

Definition at line 10567 of file duktape-1.8.0/src/duktape.c.

10567 {
10568 return 1;
10569 }
10570 return 0;
10571 } else {
10572 /* without explicit non-BMP support, assume non-BMP characters
10573 * are always accepted as identifier characters.
10574 */
10575 return 1;
10576 }
10577#endif
10578}
10579
10580/*
10581 * "IdentifierPart" production check.
10582 */
10583
10585 /*
10586 * E5 Section 7.6:
10587 *
10588 * IdentifierPart:
10589 * IdentifierStart
10590 * UnicodeCombiningMark
10591 * UnicodeDigit
10592 * UnicodeConnectorPunctuation
10593 * <ZWNJ> [U+200C]
10594 * <ZWJ> [U+200D]
10595 *
10596 * IdentifierPart production has one multi-character production
10597 * as part of its IdentifierStart alternative. The '\' character
10598 * of an escape sequence is not matched here, see discussion in
10599 * duk_unicode_is_identifier_start().
10600 *
10601 * To match non-ASCII characters (codepoints >= 0x80), a very slow
10602 * linear range-by-range scan is used. The codepoint is first compared
10603 * to the IdentifierStart ranges, and if it doesn't match, then to a
10604 * set consisting of code points in IdentifierPart but not in
10605 * IdentifierStart. This is done to keep the unicode range data small,
10606 * at the expense of speed.
10607 *
10608 * The ASCII fast path consists of:
10609 *
10610 * 0x0030 ... 0x0039 ['0' ... '9', UnicodeDigit]
10611 * 0x0041 ... 0x005a ['A' ... 'Z', IdentifierStart]
10612 * 0x0061 ... 0x007a ['a' ... 'z', IdentifierStart]
10613 * 0x0024 ['$', IdentifierStart]
10614 * 0x005f ['_', IdentifierStart and
10615 * UnicodeConnectorPunctuation]
10616 *
10617 * UnicodeCombiningMark has no code points <= 0x7f.
10618 *
10619 * The matching code reuses the "identifier start" tables, and then
10620 * consults a separate range set for characters in "identifier part"
10621 * but not in "identifier start". These can be extracted with the
10622 * "src/extract_chars.py" script.
10623 *
10624 * UnicodeCombiningMark -> categories Mn, Mc
10625 * UnicodeDigit -> categories Nd
10626 * UnicodeConnectorPunctuation -> categories Pc
10627 */
10628
10629 /* ASCII (and EOF) fast path -- quick accept and reject */
10630 if (cp <= 0x7fL) {
10631#if defined(DUK_USE_IDCHAR_FASTPATH)
10632 return (cp >= 0) && (duk_is_idchar_tab[cp] != 0);
10633#else
10634 if ((cp >= 'a' && cp <= 'z') ||
10635 (cp >= 'A' && cp <= 'Z') ||
10636 (cp >= '0' && cp <= '9') ||
10637 cp == '_' || cp == '$') {
10638 return 1;
10639 }
10640 return 0;
10641#endif
10642 }
10643
10644 /* Non-ASCII slow path (range-by-range linear comparison), very slow */
10645
10646#ifdef DUK_USE_SOURCE_NONBMP
10648 sizeof(duk_unicode_ids_noa),
10649 (duk_codepoint_t) cp) ||
10652 (duk_codepoint_t) cp)) {
10653 return 1;
10654 }
10655 return 0;
10656#else
10657 if (cp < 0x10000L) {
const duk_uint8_t duk_unicode_idp_m_ids_noa[397]
const duk_uint8_t duk_unicode_ids_noa[791]
DUK_INTERNAL const duk_int8_t duk_is_idchar_tab[128]

Referenced by duk_lexer_parse_js_input_element().

◆ duk_unicode_is_identifier_start()

DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_identifier_start ( duk_codepoint_t cp)

Definition at line 10488 of file duktape-1.8.0/src/duktape.c.

10494 {
10495 return 1;
10496 }
10497
10498 return 0;
10499}
10500
10501/*
10502 * "IdentifierStart" production check.
10503 */
10504
10506 /*
10507 * E5 Section 7.6:
10508 *
10509 * IdentifierStart:
10510 * UnicodeLetter
10511 * $
10512 * _
10513 * \ UnicodeEscapeSequence
10514 *
10515 * IdentifierStart production has one multi-character production:
10516 *
10517 * \ UnicodeEscapeSequence
10518 *
10519 * The '\' character is -not- matched by this function. Rather, the caller
10520 * should decode the escape and then call this function to check whether the
10521 * decoded character is acceptable (see discussion in E5 Section 7.6).
10522 *
10523 * The "UnicodeLetter" alternative of the production allows letters
10524 * from various Unicode categories. These can be extracted with the
10525 * "src/extract_chars.py" script.
10526 *
10527 * Because the result has hundreds of Unicode codepoint ranges, matching
10528 * for any values >= 0x80 are done using a very slow range-by-range scan
10529 * and a packed range format.
10530 *
10531 * The ASCII portion (codepoints 0x00 ... 0x7f) is fast-pathed below because
10532 * it matters the most. The ASCII related ranges of IdentifierStart are:
10533 *
10534 * 0x0041 ... 0x005a ['A' ... 'Z']
10535 * 0x0061 ... 0x007a ['a' ... 'z']
10536 * 0x0024 ['$']
10537 * 0x005f ['_']
10538 */
10539
10540 /* ASCII (and EOF) fast path -- quick accept and reject */
10541 if (cp <= 0x7fL) {
10542#if defined(DUK_USE_IDCHAR_FASTPATH)
10543 return (cp >= 0) && (duk_is_idchar_tab[cp] > 0);
10544#else
10545 if ((cp >= 'a' && cp <= 'z') ||
10546 (cp >= 'A' && cp <= 'Z') ||
10547 cp == '_' || cp == '$') {
10548 return 1;
10549 }
10550 return 0;
10551#endif
10552 }
10553
10554 /* Non-ASCII slow path (range-by-range linear comparison), very slow */
10555
10556#ifdef DUK_USE_SOURCE_NONBMP
10559 (duk_codepoint_t) cp)) {
10560 return 1;
10561 }

Referenced by duk_lexer_parse_js_input_element().

◆ duk_unicode_is_letter()

DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_letter ( duk_codepoint_t cp)

Definition at line 10663 of file duktape-1.8.0/src/duktape.c.

10663 {
10664 return 1;
10665 }
10666 return 0;
10667 } else {
10668 /* without explicit non-BMP support, assume non-BMP characters
10669 * are always accepted as identifier characters.
10670 */
10671 return 1;
10672 }
10673#endif
10674}
10675
10676/*
10677 * Unicode letter check.
10678 */
10679
10681 /*
10682 * Unicode letter is now taken to be the categories:
10683 *
10684 * Lu, Ll, Lt, Lm, Lo
10685 *
10686 * (Not sure if this is exactly correct.)
10687 *
10688 * The ASCII fast path consists of:
10689 *
10690 * 0x0041 ... 0x005a ['A' ... 'Z']
10691 * 0x0061 ... 0x007a ['a' ... 'z']
10692 */
10693
10694 /* ASCII (and EOF) fast path -- quick accept and reject */
10695 if (cp <= 0x7fL) {
10696 if ((cp >= 'a' && cp <= 'z') ||
10697 (cp >= 'A' && cp <= 'Z')) {
10698 return 1;
10699 }
10700 return 0;
10701 }
10702
10703 /* Non-ASCII slow path (range-by-range linear comparison), very slow */
10704
10705#ifdef DUK_USE_SOURCE_NONBMP
10707 sizeof(duk_unicode_ids_noa),
10708 (duk_codepoint_t) cp) &&
10711 (duk_codepoint_t) cp)) {
10712 return 1;
10713 }
10714 return 0;
10715#else
10716 if (cp < 0x10000L) {
const duk_uint8_t duk_unicode_ids_m_let_noa[42]

◆ duk_unicode_is_line_terminator()

DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_line_terminator ( duk_codepoint_t cp)

Definition at line 10468 of file duktape-1.8.0/src/duktape.c.

10469 {
10470 if (lo <= 0x0aU || lo == 0x2fU || lo == 0x5fU) {
10471 return 1;
10472 }
10473 } else if (cp == 0x1680L || cp == 0x180eL || cp == 0x3000L ||
10474 cp == 0xfeffL) {
10475 return 1;
10476 }
10477
10478 return 0;
10479}
10480
10481/*
10482 * "LineTerminator" production check.

Referenced by duk_lexer_parse_js_input_element().

◆ duk_unicode_is_whitespace()

DUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_whitespace ( duk_codepoint_t cp)

Definition at line 10388 of file duktape-1.8.0/src/duktape.c.

10391 : cp=%06lx range=[0x%06lx,0x%06lx]",
10392 (unsigned long) cp, (unsigned long) r1, (unsigned long) r2));
10393 if (cp >= r1 && cp <= r2) {
10394 return 1;
10395 }
10396 }
10397
10398 return 0;
10399}
10400
10401/*
10402 * "WhiteSpace" production check.
10403 */
10404
10405DUK_INTERNAL duk_small_int_t duk_unicode_is_whitespace(duk_codepoint_t cp) {
10406 /*
10407 * E5 Section 7.2 specifies six characters specifically as
10408 * white space:
10409 *
10410 * 0009;<control>;Cc;0;S;;;;;N;CHARACTER TABULATION;;;;
10411 * 000B;<control>;Cc;0;S;;;;;N;LINE TABULATION;;;;
10412 * 000C;<control>;Cc;0;WS;;;;;N;FORM FEED (FF);;;;
10413 * 0020;SPACE;Zs;0;WS;;;;;N;;;;;
10414 * 00A0;NO-BREAK SPACE;Zs;0;CS;<noBreak> 0020;;;;N;NON-BREAKING SPACE;;;;
10415 * FEFF;ZERO WIDTH NO-BREAK SPACE;Cf;0;BN;;;;;N;BYTE ORDER MARK;;;;
10416 *
10417 * It also specifies any Unicode category 'Zs' characters as white
10418 * space. These can be extracted with the "src/extract_chars.py" script.
10419 * Current result:
10420 *
10421 * RAW OUTPUT:
10422 * ===========
10423 * 0020;SPACE;Zs;0;WS;;;;;N;;;;;
10424 * 00A0;NO-BREAK SPACE;Zs;0;CS;<noBreak> 0020;;;;N;NON-BREAKING SPACE;;;;
10425 * 1680;OGHAM SPACE MARK;Zs;0;WS;;;;;N;;;;;
10426 * 180E;MONGOLIAN VOWEL SEPARATOR;Zs;0;WS;;;;;N;;;;;
10427 * 2000;EN QUAD;Zs;0;WS;2002;;;;N;;;;;
10428 * 2001;EM QUAD;Zs;0;WS;2003;;;;N;;;;;
10429 * 2002;EN SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;
10430 * 2003;EM SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;
10431 * 2004;THREE-PER-EM SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;
10432 * 2005;FOUR-PER-EM SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;
10433 * 2006;SIX-PER-EM SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;
10434 * 2007;FIGURE SPACE;Zs;0;WS;<noBreak> 0020;;;;N;;;;;
10435 * 2008;PUNCTUATION SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;
10436 * 2009;THIN SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;
10437 * 200A;HAIR SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;
10438 * 202F;NARROW NO-BREAK SPACE;Zs;0;CS;<noBreak> 0020;;;;N;;;;;
10439 * 205F;MEDIUM MATHEMATICAL SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;
10440 * 3000;IDEOGRAPHIC SPACE;Zs;0;WS;<wide> 0020;;;;N;;;;;
10441 *
10442 * RANGES:
10443 * =======
10444 * 0x0020
10445 * 0x00a0
10446 * 0x1680
10447 * 0x180e
10448 * 0x2000 ... 0x200a
10449 * 0x202f
10450 * 0x205f
10451 * 0x3000
10452 *
10453 * A manual decoder (below) is probably most compact for this.
10454 */
10455
10456 duk_uint_fast8_t lo;
10457 duk_uint_fast32_t hi;
10458
10459 /* cp == -1 (EOF) never matches and causes return value 0 */
10460
10461 lo = (duk_uint_fast8_t) (cp & 0xff);
10462 hi = (duk_uint_fast32_t) (cp >> 8); /* does not fit into an uchar */

Referenced by duk_lexer_parse_js_input_element().

◆ duk_unicode_re_canonicalize_char()

DUK_INTERNAL_DECL duk_codepoint_t duk_unicode_re_canonicalize_char ( duk_hthread * thr,
duk_codepoint_t cp )

Definition at line 11002 of file duktape-1.8.0/src/duktape.c.

11019 {
11020#if defined(DUK_USE_REGEXP_CANON_WORKAROUND)
11021 /* Fast canonicalization lookup at the cost of 128kB footprint. */
11022 DUK_ASSERT(cp >= 0);
11023 DUK_UNREF(thr);
11024 if (DUK_LIKELY(cp < 0x10000L)) {
11025 return (duk_codepoint_t) duk_unicode_re_canon_lookup[cp];
11026 }
11027 return cp;
11028#else /* DUK_USE_REGEXP_CANON_WORKAROUND */
11030

Referenced by duk__generate_ranges(), duk__inp_get_prev_cp(), and duk__parse_disjunction().

◆ duk_unicode_re_is_wordchar()

DUK_INTERNAL_DECL duk_small_int_t duk_unicode_re_is_wordchar ( duk_codepoint_t cp)

Definition at line 11037 of file duktape-1.8.0/src/duktape.c.

11038 {
11039 /* multiple codepoint conversion or non-ASCII mapped to ASCII
11040 * --> leave as is.
11041 */
11042 return cp;
11043 }
11044
11045 return y;
11046#endif /* DUK_USE_REGEXP_CANON_WORKAROUND */
11047}
11048
11049/*

◆ duk_unicode_unvalidated_utf8_length()

DUK_INTERNAL_DECL duk_size_t duk_unicode_unvalidated_utf8_length ( const duk_uint8_t * data,
duk_size_t blen )

Definition at line 10250 of file duktape-1.8.0/src/duktape.c.

10250 {
10251 duk_uint8_t x;
10252 x = *p++;
10253 if (DUK_UNLIKELY(x >= 0x80 && x <= 0xbf)) {
10254 ncont++;
10255 }
10256 }
10257
10258 DUK_ASSERT(ncont <= blen);
10259 clen = blen - ncont;
10260 DUK_ASSERT(clen <= blen);
10261 return clen;
10262}
10263#else /* DUK_USE_PREFER_SIZE */
10264/* This seems like a good overall approach. Fast path for ASCII in 4 byte
10265 * blocks.
10266 */
10268 const duk_uint8_t *p;
10269 const duk_uint8_t *p_end;
10270 const duk_uint32_t *p32_end;
10271 const duk_uint32_t *p32;
10272 duk_size_t ncont;
10273 duk_size_t clen;
10274
10275 ncont = 0; /* number of continuation (non-initial) bytes in [0x80,0xbf] */
10276 p = data;
10277 p_end = data + blen;
10278 if (blen < 16) {
10279 goto skip_fastpath;
10280 }
10281
10282 /* Align 'p' to 4; the input data may have arbitrary alignment.
10283 * End of string check not needed because blen >= 16.
10284 */
10285 while (((duk_size_t) (const void *) p) & 0x03U) {
10286 duk_uint8_t x;
10287 x = *p++;
10288 if (DUK_UNLIKELY(x >= 0x80 && x <= 0xbf)) {
10289 ncont++;
10290 }
10291 }
10292
10293 /* Full, aligned 4-byte reads. */
10294 p32_end = (const duk_uint32_t *) (const void *) (p + ((duk_size_t) (p_end - p) & (duk_size_t) (~0x03)));
10295 p32 = (const duk_uint32_t *) (const void *) p;
10296 while (p32 != (const duk_uint32_t *) p32_end) {
10297 duk_uint32_t x;
10298 x = *p32++;
10299 if (DUK_LIKELY((x & 0x80808080UL) == 0)) {
10300 ; /* ASCII fast path */
10301 } else {
10302 /* Flip highest bit of each byte which changes
10303 * the bit pattern 10xxxxxx into 00xxxxxx which
10304 * allows an easy bit mask test.
10305 */
10306 x ^= 0x80808080UL;
10307 if (DUK_UNLIKELY(!(x & 0xc0000000UL))) {
10308 ncont++;
10309 }
10310 if (DUK_UNLIKELY(!(x & 0x00c00000UL))) {
10311 ncont++;
10312 }
10313 if (DUK_UNLIKELY(!(x & 0x0000c000UL))) {
10314 ncont++;
10315 }
10316 if (DUK_UNLIKELY(!(x & 0x000000c0UL))) {
10317 ncont++;
10318 }
10319 }
10320 }

References DUK_UNLIKELY.

Referenced by duk__alloc_init_hstring().

◆ duk_util_get_hash_prime()

DUK_INTERNAL_DECL duk_uint32_t duk_util_get_hash_prime ( duk_uint32_t size)

Definition at line 11373 of file duktape-1.8.0/src/duktape.c.

11385 {
11386 2, 3, 5, 7, 11, 13, 19, 31, 41, 47, 59, 67, 73, 79, 89, 101, 103, 107,
11387 109, 127, 137, 139, 149, 157, 163, 167, 173, 181, 191, 193, 197, 199
11388};
11389
11390DUK_INTERNAL duk_uint32_t duk_util_get_hash_prime(duk_uint32_t size) {
11391 const duk_int8_t *p = duk__hash_size_corrections;
11392 duk_uint32_t curr;
11393
11394 curr = (duk_uint32_t) *p++;
11395 for (;;) {
11397 if (t < 0) {
11398 /* may happen if size is very close to 2^32-1 */
11399 break;
11400 }
11401
11402 /* prediction: portable variant using doubles if 64-bit values not available */
11403#ifdef DUK_USE_64BIT_OPS
DUK_LOCAL const duk_int8_t duk__hash_size_corrections[]

Referenced by duk__get_min_grow_e().

◆ duk_util_tinyrandom_get_bits()

DUK_INTERNAL_DECL duk_uint32_t duk_util_tinyrandom_get_bits ( duk_hthread * thr,
duk_small_int_t n )

Definition at line 86920 of file duktape-1.8.0/src/duktape.c.

86930 { \
86931 (rnd) += ((rnd) * (rnd)) | 0x05; \
86932 (rnd) = ((rnd) & 0xffffffffU); /* if duk_uint32_t is exactly 32 bits, this is a NOP */ \
86933 } while (0)
86934
86935#define DUK__RND_BIT(rnd) ((rnd) >> 31) /* only use the highest bit */
86936

◆ duk_util_tinyrandom_get_double()

DUK_INTERNAL_DECL duk_double_t duk_util_tinyrandom_get_double ( duk_hthread * thr)

Definition at line 86938 of file duktape-1.8.0/src/duktape.c.

86944 {
86945 DUK__UPDATE_RND(rnd);
86946 res <<= 1;
86947 res += DUK__RND_BIT(rnd);
86948 }
86949
86950 thr->heap->rnd_state = rnd;
86951
86952 return res;
86953}
86954
86956 duk_double_t t;
86958 duk_uint32_t rnd;
86959
86960 /*
86961 * XXX: could make this a lot faster if we create the double memory
86962 * representation directly. Feasible easily (must be uniform random).
86963 */
86964
86965 rnd = thr->heap->rnd_state;
DUK_INTERNAL_DECL duk_double_t duk_util_tinyrandom_get_double(duk_hthread *thr)
#define DUK__UPDATE_RND(rnd)
#define DUK__RND_BIT(rnd)

References DUK__RND_BIT, and DUK__UPDATE_RND.

◆ duk_valstack_resize_raw()

DUK_INTERNAL_DECL duk_bool_t duk_valstack_resize_raw ( duk_context * ctx,
duk_size_t min_new_size,
duk_small_uint_t flags )

Definition at line 15622 of file duktape-1.8.0/src/duktape.c.

15629 {
15631 p++;
15632 }
15633#endif
15634
15635 return 1;
15636}
15637
15640 duk_size_t min_new_size,
15641 duk_small_uint_t flags) {
15642 duk_hthread *thr = (duk_hthread *) ctx;
15643 duk_size_t old_size;
15644 duk_size_t new_size;
15645 duk_bool_t is_shrink = 0;
15646 duk_small_uint_t shrink_flag = (flags & DUK_VSRESIZE_FLAG_SHRINK);
15647 duk_small_uint_t compact_flag = (flags & DUK_VSRESIZE_FLAG_COMPACT);
15648 duk_small_uint_t throw_flag = (flags & DUK_VSRESIZE_FLAG_THROW);
15649
15650 DUK_DDD(DUK_DDDPRINT("check valstack resize: min_new_size=%lu, curr_size=%ld, curr_top=%ld, "
15651 "curr_bottom=%ld, shrink=%d, compact=%d, throw=%d",
15652 (unsigned long) min_new_size,
15653 (long) (thr->valstack_end - thr->valstack),
15654 (long) (thr->valstack_top - thr->valstack),
15655 (long) (thr->valstack_bottom - thr->valstack),
15656 (int) shrink_flag, (int) compact_flag, (int) throw_flag));
15657
15659 DUK_ASSERT(thr != NULL);
15660 DUK_ASSERT(thr->valstack_bottom >= thr->valstack);
15662 DUK_ASSERT(thr->valstack_end >= thr->valstack_top);
15663
15664#if defined(DUK_USE_PREFER_SIZE)
15665 old_size = (duk_size_t) (thr->valstack_end - thr->valstack);
15666#else
15667 DUK_ASSERT((duk_size_t) (thr->valstack_end - thr->valstack) == thr->valstack_size);
15668 old_size = thr->valstack_size;
15669#endif
15670
15671 if (min_new_size <= old_size) {
15672 is_shrink = 1;
15673 if (!shrink_flag ||
15674 old_size - min_new_size < DUK_VALSTACK_SHRINK_THRESHOLD) {
15675 DUK_DDD(DUK_DDDPRINT("no need to grow or shrink valstack"));
15676 return 1;
15677 }
15678 }
15679
15680 new_size = min_new_size;
15681 if (!compact_flag) {
15682 if (is_shrink) {
15683 /* shrink case; leave some spare */
15684 new_size += DUK_VALSTACK_SHRINK_SPARE;
15685 }
15686
15687 /* round up roughly to next 'grow step' */
15688 new_size = (new_size / DUK_VALSTACK_GROW_STEP + 1) * DUK_VALSTACK_GROW_STEP;
15689 }
15690
15691 DUK_DD(DUK_DDPRINT("want to %s valstack: %lu -> %lu elements (min_new_size %lu)",
15692 (const char *) (new_size > old_size ? "grow" : "shrink"),
15693 (unsigned long) old_size, (unsigned long) new_size,
15694 (unsigned long) min_new_size));
15695
15696 if (new_size > thr->valstack_max) {
15697 /* Note: may be triggered even if minimal new_size would not reach the limit,
15698 * plan limit accordingly (taking DUK_VALSTACK_GROW_STEP into account).
15699 */
15700 if (throw_flag) {
15702 } else {
15703 return 0;
15704 }
15705 }
15706
15707 /*
15708 * When resizing the valstack, a mark-and-sweep may be triggered for
15709 * the allocation of the new valstack. If the mark-and-sweep needs
15710 * to use our thread for something, it may cause *the same valstack*
15711 * to be resized recursively. This happens e.g. when mark-and-sweep
15712 * finalizers are called. This is taken into account carefully in
15713 * duk__resize_valstack().
15714 *
15715 * 'new_size' is known to be <= valstack_max, which ensures that
15716 * size_t and pointer arithmetic won't wrap in duk__resize_valstack().
15717 */
15718
15719 if (!duk__resize_valstack(ctx, new_size)) {
#define DUK_VALSTACK_SHRINK_THRESHOLD
DUK_LOCAL duk_bool_t duk__resize_valstack(duk_context *ctx, duk_size_t new_size)
#define DUK_STR_VALSTACK_LIMIT
#define DUK_VALSTACK_GROW_STEP
#define DUK_VALSTACK_SHRINK_SPARE

◆ duk_xcopymove_raw()

DUK_EXTERNAL void duk_xcopymove_raw ( duk_context * to_ctx,
duk_context * from_ctx,
duk_idx_t count,
duk_bool_t is_copy )

Definition at line 15999 of file duktape-1.8.0/src/duktape.c.

16016 {
16017 duk_hthread *to_thr = (duk_hthread *) to_ctx;
16018 duk_hthread *from_thr = (duk_hthread *) from_ctx;
16019 void *src;
16020 duk_size_t nbytes;
16021 duk_tval *p;
16022 duk_tval *q;
16023
16024 /* XXX: several pointer comparison issues here */
16025
16026 DUK_ASSERT_CTX_VALID(to_ctx);
16027 DUK_ASSERT_CTX_VALID(from_ctx);
16028 DUK_ASSERT(to_ctx != NULL);
16029 DUK_ASSERT(from_ctx != NULL);
16030
16031 if (to_ctx == from_ctx) {
16033 return;
16034 }
16035 if ((count < 0) ||
16036 (count > (duk_idx_t) to_thr->valstack_max)) {
16037 /* Maximum value check ensures 'nbytes' won't wrap below. */
16039 return;
16040 }
16041
16042 nbytes = sizeof(duk_tval) * count;
16043 if (nbytes == 0) {
16044 return;
16045 }
16046 DUK_ASSERT(to_thr->valstack_top <= to_thr->valstack_end);
16047 if ((duk_size_t) ((duk_uint8_t *) to_thr->valstack_end - (duk_uint8_t *) to_thr->valstack_top) < nbytes) {
16049 }
16050 src = (void *) ((duk_uint8_t *) from_thr->valstack_top - nbytes);
16051 if (src < (void *) from_thr->valstack_bottom) {
16053 }
16054
16055 /* copy values (no overlap even if to_ctx == from_ctx; that's not
16056 * allowed now anyway)
16057 */
16058 DUK_ASSERT(nbytes > 0);
16059 DUK_MEMCPY((void *) to_thr->valstack_top, (const void *) src, (size_t) nbytes);
16060
16061 p = to_thr->valstack_top;
16062 to_thr->valstack_top = (duk_tval *) (void *) (((duk_uint8_t *) p) + nbytes);
16063
16064 if (is_copy) {
16065 /* Incref copies, keep originals. */
16066 q = to_thr->valstack_top;
#define DUK_STR_INVALID_CONTEXT

◆ duk_xdef_prop()

DUK_INTERNAL_DECL void duk_xdef_prop ( duk_context * ctx,
duk_idx_t obj_index,
duk_small_uint_t desc_flags )

Definition at line 14658 of file duktape-1.8.0/src/duktape.c.

◆ duk_xdef_prop_index()

DUK_INTERNAL_DECL void duk_xdef_prop_index ( duk_context * ctx,
duk_idx_t obj_index,
duk_uarridx_t arr_index,
duk_small_uint_t desc_flags )

Definition at line 14676 of file duktape-1.8.0/src/duktape.c.

◆ duk_xdef_prop_stridx()

DUK_INTERNAL_DECL void duk_xdef_prop_stridx ( duk_context * ctx,
duk_idx_t obj_index,
duk_small_int_t stridx,
duk_small_uint_t desc_flags )

Definition at line 14689 of file duktape-1.8.0/src/duktape.c.

14693 {
14694 duk_hthread *thr = (duk_hthread *) ctx;
14695 duk_hobject *obj;
14696
14698
14699 obj = duk_require_hobject(ctx, obj_index);
14700 DUK_ASSERT(obj != NULL);
14701
14702 duk_hobject_define_property_internal_arridx(thr, obj, arr_index, desc_flags);
14703 /* value popped by call */
14704}
14705

Referenced by duk_bi_buffer_slice_shared(), and duk_bi_string_constructor_from_char_code().

◆ duk_xdef_prop_stridx_builtin()

DUK_INTERNAL_DECL void duk_xdef_prop_stridx_builtin ( duk_context * ctx,
duk_idx_t obj_index,
duk_small_int_t stridx,
duk_small_int_t builtin_idx,
duk_small_uint_t desc_flags )

Definition at line 14708 of file duktape-1.8.0/src/duktape.c.

14725 {
14726 duk_hthread *thr = (duk_hthread *) ctx;
14727 duk_hobject *obj;

◆ duk_xdef_prop_stridx_thrower()

DUK_INTERNAL_DECL void duk_xdef_prop_stridx_thrower ( duk_context * ctx,
duk_idx_t obj_index,
duk_small_int_t stridx,
duk_small_uint_t desc_flags )

Definition at line 14734 of file duktape-1.8.0/src/duktape.c.

Variable Documentation

◆ duk__buffer_class_from_elemtype

◆ duk__buffer_elemtype_copy_compatible

duk_uint16_t duk__buffer_elemtype_copy_compatible[9]
static

Definition at line 21792 of file duktape-1.8.0/src/duktape.c.

21792 {
21793 1, /* DUK__FLD_8BIT */
21794 2, /* DUK__FLD_16BIT */
21795 4, /* DUK__FLD_32BIT */
21796 4, /* DUK__FLD_FLOAT */
21797 8, /* DUK__FLD_DOUBLE */
21798 0 /* DUK__FLD_VARINT; not relevant here */
21799};
21800#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */
21801
21802#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)
21803/* Bitfield for each DUK_HBUFFEROBJECT_ELEM_xxx indicating which element types
21804 * are compatible with a blind byte copy for the TypedArray set() method (also
21805 * used for TypedArray constructor). Array index is target buffer elem type,
21806 * bitfield indicates compatible source types. The types must have same byte
21807 * size and they must be coercion compatible.
21808 */
21809static duk_uint16_t duk__buffer_elemtype_copy_compatible[9] = {
21810 /* xxx -> DUK_HBUFFEROBJECT_ELEM_UINT8 */
21814
21815 /* xxx -> DUK_HBUFFEROBJECT_ELEM_UINT8CLAMPED
21816 * Note: INT8 is -not- copy compatible, e.g. -1 would coerce to 0x00.
21817 */
21820
21821 /* xxx -> DUK_HBUFFEROBJECT_ELEM_INT8 */
21825
21826 /* xxx -> DUK_HBUFFEROBJECT_ELEM_UINT16 */
21829
21830 /* xxx -> DUK_HBUFFEROBJECT_ELEM_INT16 */

Referenced by duk_bi_typedarray_set().

◆ duk__buffer_nbytes_from_fldtype

const duk_uint8_t duk__buffer_nbytes_from_fldtype[6]
static
Initial value:
= {
1,
2,
4,
4,
8,
0
}

Definition at line 21775 of file duktape-1.8.0/src/duktape.c.

◆ duk__buffer_proto_from_elemtype

◆ duk__bufferobject_virtual_props

DUK_LOCAL const duk_uint16_t duk__bufferobject_virtual_props[]
Initial value:

Definition at line 46407 of file duktape-1.8.0/src/duktape.c.

46410 :
46411 * non-snapshot-based approaches are difficult to reconcile with mutating
46412 * the enumeration target, running multiple long-lived enumerators at the

◆ duk__bufobj_flags_lookup

const duk_uint32_t duk__bufobj_flags_lookup[]
static

◆ duk__closure_copy_proplist

DUK_LOCAL const duk_uint16_t duk__closure_copy_proplist[]

◆ duk__date_equivyear

DUK_LOCAL duk_uint8_t duk__date_equivyear[14]
Initial value:
= {
DUK__YEAR(2023), DUK__YEAR(2035), DUK__YEAR(2019), DUK__YEAR(2031),
DUK__YEAR(2015), DUK__YEAR(2027), DUK__YEAR(2011),
DUK__YEAR(2012), DUK__YEAR(2024), DUK__YEAR(2008), DUK__YEAR(2020),
DUK__YEAR(2032), DUK__YEAR(2016), DUK__YEAR(2028)
}
#define DUK__YEAR(x)

Definition at line 24674 of file duktape-1.8.0/src/duktape.c.

24677 { \
24678 DUK_D(DUK_DPRINT("dparts: %lf %lf %lf %lf %lf %lf %lf %lf", \
24679 (double) (dparts)[0], (double) (dparts)[1], \
24680 (double) (dparts)[2], (double) (dparts)[3], \
24681 (double) (dparts)[4], (double) (dparts)[5], \
24682 (double) (dparts)[6], (double) (dparts)[7])); \
24683 } while (0)
24684
24685/* Equivalent year for DST calculations outside [1970,2038[ range, see
24686 * E5 Section 15.9.1.8. Equivalent year has the same leap-year-ness and
24687 * starts with the same weekday on Jan 1.
24688 * https://bugzilla.mozilla.org/show_bug.cgi?id=351066
24689 */
24690#define DUK__YEAR(x) ((duk_uint8_t) ((x) - 1970))
24691DUK_LOCAL duk_uint8_t duk__date_equivyear[14] = {
24692#if 1
24693 /* This is based on V8 EquivalentYear() algorithm (see src/genequivyear.py):
24694 * http://code.google.com/p/v8/source/browse/trunk/src/date.h#146
24695 */
24696
24697 /* non-leap year: sunday, monday, ... */
24698 DUK__YEAR(2023), DUK__YEAR(2035), DUK__YEAR(2019), DUK__YEAR(2031),
24699 DUK__YEAR(2015), DUK__YEAR(2027), DUK__YEAR(2011),
24700
24701 /* leap year: sunday, monday, ... */
24702 DUK__YEAR(2012), DUK__YEAR(2024), DUK__YEAR(2008), DUK__YEAR(2020),

◆ duk__date_magics

duk_uint16_t duk__date_magics[]
static

Definition at line 25913 of file duktape-1.8.0/src/duktape.c.

25930 {
25931 /* 0: toString */
25933
25934 /* 1: toDateString */
25936
25937 /* 2: toTimeString */
25939
25940 /* 3: toLocaleString */
25942
25943 /* 4: toLocaleDateString */
25945
25946 /* 5: toLocaleTimeString */
25948
25949 /* 6: toUTCString */
25951
25952 /* 7: toISOString */
25954
25955 /* 8: getFullYear */
25957
25958 /* 9: getUTCFullYear */
25960
25961 /* 10: getMonth */
25963
25964 /* 11: getUTCMonth */
25966
25967 /* 12: getDate */
25969
25970 /* 13: getUTCDate */
25972
25973 /* 14: getDay */
25975
25976 /* 15: getUTCDay */
25978
25979 /* 16: getHours */
25981
25982 /* 17: getUTCHours */
25984
25985 /* 18: getMinutes */
25987
25988 /* 19: getUTCMinutes */
25990
25991 /* 20: getSeconds */
25993
25994 /* 21: getUTCSeconds */
25996
25997 /* 22: getMilliseconds */
25999
26000 /* 23: getUTCMilliseconds */
26002
26003 /* 24: setMilliseconds */
26005
26006 /* 25: setUTCMilliseconds */
26008
26009 /* 26: setSeconds */
26011
26012 /* 27: setUTCSeconds */
26014
26015 /* 28: setMinutes */
26017
26018 /* 29: setUTCMinutes */
26020
26021 /* 30: setHours */
26023
26024 /* 31: setUTCHours */
26026
26027 /* 32: setDate */
26029
26030 /* 33: setUTCDate */
26031 0 + (1 << DUK_DATE_FLAG_VALUE_SHIFT),
26032
26033 /* 34: setMonth */
#define DUK_DATE_FLAG_TOSTRING_DATE

◆ duk__days_in_month

DUK_LOCAL duk_uint8_t duk__days_in_month[12]
Initial value:
= {
(duk_uint8_t) 31, (duk_uint8_t) 28, (duk_uint8_t) 31, (duk_uint8_t) 30,
(duk_uint8_t) 31, (duk_uint8_t) 30, (duk_uint8_t) 31, (duk_uint8_t) 31,
(duk_uint8_t) 30, (duk_uint8_t) 31, (duk_uint8_t) 30, (duk_uint8_t) 31
}

Definition at line 25034 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_bi_date_timeval_to_parts().

◆ duk__decode_uri_component_reserved_table

DUK_LOCAL const duk_uint8_t duk__decode_uri_component_reserved_table[16]
Initial value:
= {
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
}
#define DUK__MKBITS(a, b, c, d, e, f, g, h)

Definition at line 27865 of file duktape-1.8.0/src/duktape.c.

27870 {
27871 DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 0x00-0x0f */
27872 DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 0x10-0x1f */
27873 DUK__MKBITS(0, 0, 0, 1, 1, 0, 1, 0), DUK__MKBITS(0, 0, 0, 1, 1, 0, 0, 1), /* 0x20-0x2f */
27874 DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 1, 1, 0, 1, 0, 1), /* 0x30-0x3f */

Referenced by duk_bi_global_object_unescape().

◆ duk__decode_uri_reserved_table

DUK_LOCAL const duk_uint8_t duk__decode_uri_reserved_table[16]
Initial value:
= {
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(0, 0, 0, 1, 1, 0, 1, 0), DUK__MKBITS(0, 0, 0, 1, 1, 0, 0, 1),
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 1, 1, 0, 1, 0, 1),
DUK__MKBITS(1, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
}

Definition at line 27853 of file duktape-1.8.0/src/duktape.c.

27858 {
27859 DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 0x00-0x0f */
27860 DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 0x10-0x1f */
27861 DUK__MKBITS(0, 1, 0, 0, 0, 0, 0, 1), DUK__MKBITS(1, 1, 1, 0, 0, 1, 1, 0), /* 0x20-0x2f */
27862 DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 0, 0, 0, 0, 0, 0), /* 0x30-0x3f */

Referenced by duk_bi_global_object_escape().

◆ duk__encode_uricomponent_unescaped_table

DUK_LOCAL const duk_uint8_t duk__encode_uricomponent_unescaped_table[16]
Initial value:
= {
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(0, 1, 0, 0, 0, 0, 0, 1), DUK__MKBITS(1, 1, 1, 0, 0, 1, 1, 0),
DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(0, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1),
DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 0, 0, 0, 0, 1),
DUK__MKBITS(0, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1),
DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 0, 0, 0, 1, 0),
}

Definition at line 27841 of file duktape-1.8.0/src/duktape.c.

27846 {
27847 DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 0x00-0x0f */
27848 DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 0x10-0x1f */
27849 DUK__MKBITS(0, 1, 0, 1, 1, 0, 1, 1), DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), /* 0x20-0x2f */
27850 DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 1, 0, 1, 0, 1), /* 0x30-0x3f */

◆ duk__encode_uriunescaped_table

DUK_LOCAL const duk_uint8_t duk__encode_uriunescaped_table[16]
Initial value:
= {
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(0, 1, 0, 1, 1, 0, 1, 1), DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1),
DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 1, 0, 1, 0, 1),
DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1),
DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 0, 0, 0, 0, 1),
DUK__MKBITS(0, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1),
DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 0, 0, 0, 1, 0),
}

Definition at line 27829 of file duktape-1.8.0/src/duktape.c.

◆ duk__escape_unescaped_table

DUK_LOCAL const duk_uint8_t duk__escape_unescaped_table[16]
Initial value:
= {
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 1, 1, 0, 1, 1, 1),
DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 0, 0, 0, 0, 0, 0),
DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1),
DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 0, 0, 0, 0, 1),
DUK__MKBITS(0, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1),
DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 0, 0, 0, 0, 0)
}

Definition at line 27878 of file duktape-1.8.0/src/duktape.c.

27882 {
27883 DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 0x00-0x0f */
27884 DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 0x10-0x1f */
27885 DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 0x20-0x2f */
27886 DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 0x30-0x3f */
27887 DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), /* 0x40-0x4f */

◆ duk__hash_size_corrections

DUK_LOCAL const duk_int8_t duk__hash_size_corrections[]
Initial value:
= {
17,
4, 3, 4, 1, 4, 1, 1, 2, 2, 2, 2, 1, 6, 6, 9, 5, 1, 2, 2, 5, 1, 3, 3, 3,
5, 4, 4, 2, 4, 8, 3, 4, 23, 2, 4, 7, 8, 11, 2, 12, 15, 10, 1, 1, 5, 1, 5,
8, 9, 17, 14, 10, 7, 5, 2, 46, 21, 1, 9, 9, 4, 4, 10, 23, 36, 6, 20, 29,
18, 6, 19, 21, 16, 11, 5, 5, 48, 9, 1, 39, 14, 8, 4, 29, 9, 1, 15, 48, 12,
22, 6, 15, 27, 4, 2, 17, 28, 8, 9, 4, 5, 8, 3, 3, 8, 37, 11, 15, 8, 30,
43, 6, 33, 41, 5, 20, 32, 41, 38, 24, 77, 14, 19, 11, 4, 35, 18, 19, 41,
10, 23, 16, 9, 2,
-1
}

Definition at line 11353 of file duktape-1.8.0/src/duktape.c.

◆ duk__json_decnumber_lookup

DUK_LOCAL const duk_uint8_t duk__json_decnumber_lookup[256]
Initial value:
= {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}

Definition at line 29256 of file duktape-1.8.0/src/duktape.c.

29273 {
29274 /* 0x00: finish (not part of number)
29275 * 0x01: continue
29276 */

◆ duk__json_decstr_lookup

DUK_LOCAL const duk_uint8_t duk__json_decstr_lookup[256]
Initial value:
= {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x20, 0x21, 0x00, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x00, 0x5d, 0x5e, 0x5f,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
}

Definition at line 29208 of file duktape-1.8.0/src/duktape.c.

29216 {
29221};
29222#endif /* DUK_USE_JSON_QUOTESTRING_FASTPATH */
29223
29224#if defined(DUK_USE_JSON_DECSTRING_FASTPATH)
29225DUK_LOCAL const duk_uint8_t duk__json_decstr_lookup[256] = {
29226 /* 0x00: slow path
29227 * other: as is
29228 */

◆ duk__json_eatwhite_lookup

DUK_LOCAL const duk_uint8_t duk__json_eatwhite_lookup[256]
Initial value:
= {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}

Definition at line 29232 of file duktape-1.8.0/src/duktape.c.

29249 {
29250 /* 0x00: finish (non-white)
29251 * 0x01: continue
29252 */

◆ duk__json_quotestr_lookup

DUK_LOCAL const duk_uint8_t duk__json_quotestr_lookup[256]
Initial value:
= {
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xe2, 0xf4, 0xee, 0x80, 0xe6, 0xf2, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x20, 0x21, 0xa2, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0xdc, 0x5d, 0x5e, 0x5f,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x81,
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,
0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81
}

Definition at line 29174 of file duktape-1.8.0/src/duktape.c.

29191 {
29192 /* 0x00 ... 0x7f: as is
29193 * 0x80: escape generically
29194 * 0x81: slow path
29195 * 0xa0 ... 0xff: backslash + one char
29196 */
29197

◆ duk__log_level_strings

DUK_LOCAL const duk_uint8_t duk__log_level_strings[]
Initial value:
= {
(duk_uint8_t) DUK_ASC_UC_T, (duk_uint8_t) DUK_ASC_UC_R, (duk_uint8_t) DUK_ASC_UC_C,
(duk_uint8_t) DUK_ASC_UC_D, (duk_uint8_t) DUK_ASC_UC_B, (duk_uint8_t) DUK_ASC_UC_G,
(duk_uint8_t) DUK_ASC_UC_I, (duk_uint8_t) DUK_ASC_UC_N, (duk_uint8_t) DUK_ASC_UC_F,
(duk_uint8_t) DUK_ASC_UC_W, (duk_uint8_t) DUK_ASC_UC_R, (duk_uint8_t) DUK_ASC_UC_N,
(duk_uint8_t) DUK_ASC_UC_E, (duk_uint8_t) DUK_ASC_UC_R, (duk_uint8_t) DUK_ASC_UC_R,
(duk_uint8_t) DUK_ASC_UC_F, (duk_uint8_t) DUK_ASC_UC_T, (duk_uint8_t) DUK_ASC_UC_L
}

Definition at line 32243 of file duktape-1.8.0/src/duktape.c.

◆ duk__one_arg_funcs

DUK_LOCAL const duk__one_arg_func duk__one_arg_funcs[]

Definition at line 32777 of file duktape-1.8.0/src/duktape.c.

32779 {
32780 return DUK_SIN(x);
32781}
32782DUK_LOCAL double duk__sqrt(double x) {
32783 return DUK_SQRT(x);
32784}
32785DUK_LOCAL double duk__tan(double x) {
32786 return DUK_TAN(x);
32787}
32788DUK_LOCAL double duk__atan2(double x, double y) {
32789 return DUK_ATAN2(x, y);
32790}
32791#endif /* DUK_USE_AVOID_PLATFORM_FUNCPTRS */
32792
32793/* order must match constants in genbuiltins.py */
32795#if defined(DUK_USE_AVOID_PLATFORM_FUNCPTRS)
32796 duk__fabs,
32797 duk__acos,
32798 duk__asin,
32799 duk__atan,
32800 duk__ceil,
32801 duk__cos,
32802 duk__exp,
32803 duk__floor,
32804 duk__log,
32806 duk__sin,
32807 duk__sqrt,
DUK_LOCAL double duk__asin(double x)
DUK_LOCAL double duk__atan(double x)
DUK_LOCAL double duk__log(double x)
DUK_LOCAL double duk__sin(double x)
DUK_LOCAL double duk__ceil(double x)
DUK_LOCAL double duk__floor(double x)
DUK_LOCAL const duk__one_arg_func duk__one_arg_funcs[]
DUK_LOCAL double duk__exp(double x)
DUK_LOCAL double duk__fabs(double x)
DUK_LOCAL double duk__acos(double x)
DUK_LOCAL double duk__tan(double x)
DUK_LOCAL double duk__cos(double x)
DUK_LOCAL double duk__sqrt(double x)

◆ duk__parse_iso8601_control

DUK_LOCAL const duk_uint32_t duk__parse_iso8601_control[]
Initial value:
= {
}
#define DUK__PM_SECOND
#define DUK__SM_PERIOD
#define DUK__PM_MINUTE
#define DUK__PM_TZHOUR
#define DUK__PM_DAY
#define DUK__SM_PLUS
#define DUK__PM_YEAR
#define DUK__SM_SPACE
#define DUK__PM_MONTH
#define DUK__SM_COLON
#define DUK__PACK_RULE(partmask, sepmask, nextpart, flags)
#define DUK__PI_SECOND
#define DUK__SM_T
#define DUK__SM_MINUS
#define DUK__PM_HOUR
#define DUK__PM_MILLISECOND
#define DUK__SM_Z

Definition at line 24779 of file duktape-1.8.0/src/duktape.c.

24782 { \
24783 (var_nextidx) = (duk_small_uint_t) (((rule) >> 17) & 0x0f); \
24784 (var_flags) = (duk_small_uint_t) ((rule) >> 21); \
24785 } while (0)
24786
24787#define DUK__RULE_MASK_PART_SEP 0x1ffffUL
24788
24789/* Matching separator index is used in the control table */
24790DUK_LOCAL const duk_uint8_t duk__parse_iso8601_seps[] = {
24791 DUK_ASC_PLUS /*0*/, DUK_ASC_MINUS /*1*/, DUK_ASC_UC_T /*2*/, DUK_ASC_SPACE /*3*/,
24792 DUK_ASC_COLON /*4*/, DUK_ASC_PERIOD /*5*/, DUK_ASC_UC_Z /*6*/, DUK_ASC_NUL /*7*/
24793};
24794
24795/* Rule table: first matching rule is used to determine what to do next. */
24796DUK_LOCAL const duk_uint32_t duk__parse_iso8601_control[] = {

◆ duk__parse_iso8601_seps

DUK_LOCAL const duk_uint8_t duk__parse_iso8601_seps[]

◆ duk__str2num_digits_for_radix

DUK_LOCAL const duk_uint8_t duk__str2num_digits_for_radix[]
Initial value:
= {
69, 44, 35, 30, 27, 25, 23, 22, 20, 20,
20, 19, 19, 18, 18, 17, 17, 17, 16, 16,
16, 16, 16, 15, 15, 15, 15, 15, 15, 14,
14, 14, 14, 14, 14
}

Definition at line 75421 of file duktape-1.8.0/src/duktape.c.

◆ duk__str2num_exp_limits

DUK_LOCAL const duk__exp_limits duk__str2num_exp_limits[]
Initial value:
= {
{ 957, -1147 }, { 605, -725 }, { 479, -575 }, { 414, -496 },
{ 372, -446 }, { 342, -411 }, { 321, -384 }, { 304, -364 },
{ 291, -346 }, { 279, -334 }, { 268, -323 }, { 260, -312 },
{ 252, -304 }, { 247, -296 }, { 240, -289 }, { 236, -283 },
{ 231, -278 }, { 227, -273 }, { 223, -267 }, { 220, -263 },
{ 216, -260 }, { 213, -256 }, { 210, -253 }, { 208, -249 },
{ 205, -246 }, { 203, -244 }, { 201, -241 }, { 198, -239 },
{ 196, -237 }, { 195, -234 }, { 193, -232 }, { 191, -230 },
{ 190, -228 }, { 188, -226 }, { 187, -225 },
}

Definition at line 75433 of file duktape-1.8.0/src/duktape.c.

75438 {
75439 69, 44, 35, 30, 27, 25, 23, 22, 20, 20, /* 2 to 11 */
75440 20, 19, 19, 18, 18, 17, 17, 17, 16, 16, /* 12 to 21 */
75441 16, 16, 16, 15, 15, 15, 15, 15, 15, 14, /* 22 to 31 */
75442 14, 14, 14, 14, 14 /* 31 to 36 */
75443};

◆ duk__token_lbp

DUK_LOCAL const duk_uint8_t duk__token_lbp[]

Definition at line 57988 of file duktape-1.8.0/src/duktape.c.

58005 {
58006 DUK__MK_LBP(DUK__BP_EOF), /* DUK_TOK_EOF */
58008 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_BREAK */
58009 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_CASE */
58010 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_CATCH */
58011 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_CONTINUE */
58012 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_DEBUGGER */
58013 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_DEFAULT */
58014 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_DELETE */
58015 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_DO */
58016 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_ELSE */
58017 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_FINALLY */
58018 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_FOR */
58019 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_FUNCTION */
58020 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_IF */
58021 DUK__MK_LBP(DUK__BP_RELATIONAL), /* DUK_TOK_IN */
58022 DUK__MK_LBP(DUK__BP_RELATIONAL), /* DUK_TOK_INSTANCEOF */
58023 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_NEW */
58024 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_RETURN */
58025 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_SWITCH */
58027 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_THROW */
58028 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_TRY */
58029 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_TYPEOF */
58030 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_VAR */
58031 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_CONST */
58032 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_VOID */
58033 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_WHILE */
58034 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_WITH */
58035 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_CLASS */
58036 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_ENUM */
58037 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_EXPORT */
58038 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_EXTENDS */
58039 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_IMPORT */
58040 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_SUPER */
58044 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_GET */
58045 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_SET */
58046 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_IMPLEMENTS */
58047 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_INTERFACE */
58048 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_LET */
58049 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_PACKAGE */
58050 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_PRIVATE */
58051 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_PROTECTED */
58052 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_PUBLIC */
58053 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_STATIC */
58054 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_YIELD */
58055 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_LCURLY */
58057 DUK__MK_LBP(DUK__BP_MEMBER), /* DUK_TOK_LBRACKET */
58059 DUK__MK_LBP(DUK__BP_CALL), /* DUK_TOK_LPAREN */
58061 DUK__MK_LBP(DUK__BP_MEMBER), /* DUK_TOK_PERIOD */
58062 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_SEMICOLON */
58063 DUK__MK_LBP(DUK__BP_COMMA), /* DUK_TOK_COMMA */
58064 DUK__MK_LBP(DUK__BP_RELATIONAL), /* DUK_TOK_LT */
58065 DUK__MK_LBP(DUK__BP_RELATIONAL), /* DUK_TOK_GT */
58066 DUK__MK_LBP(DUK__BP_RELATIONAL), /* DUK_TOK_LE */
58067 DUK__MK_LBP(DUK__BP_RELATIONAL), /* DUK_TOK_GE */
58068 DUK__MK_LBP(DUK__BP_EQUALITY), /* DUK_TOK_EQ */
58069 DUK__MK_LBP(DUK__BP_EQUALITY), /* DUK_TOK_NEQ */
58070 DUK__MK_LBP(DUK__BP_EQUALITY), /* DUK_TOK_SEQ */
58071 DUK__MK_LBP(DUK__BP_EQUALITY), /* DUK_TOK_SNEQ */
58072 DUK__MK_LBP(DUK__BP_ADDITIVE), /* DUK_TOK_ADD */
58073 DUK__MK_LBP(DUK__BP_ADDITIVE), /* DUK_TOK_SUB */
58074 DUK__MK_LBP(DUK__BP_MULTIPLICATIVE), /* DUK_TOK_MUL */
58075 DUK__MK_LBP(DUK__BP_MULTIPLICATIVE), /* DUK_TOK_DIV */
58076 DUK__MK_LBP(DUK__BP_MULTIPLICATIVE), /* DUK_TOK_MOD */
58077 DUK__MK_LBP(DUK__BP_POSTFIX), /* DUK_TOK_INCREMENT */
58078 DUK__MK_LBP(DUK__BP_POSTFIX), /* DUK_TOK_DECREMENT */
58079 DUK__MK_LBP(DUK__BP_SHIFT), /* DUK_TOK_ALSHIFT */
58080 DUK__MK_LBP(DUK__BP_SHIFT), /* DUK_TOK_ARSHIFT */
58081 DUK__MK_LBP(DUK__BP_SHIFT), /* DUK_TOK_RSHIFT */
58082 DUK__MK_LBP(DUK__BP_BAND), /* DUK_TOK_BAND */
58083 DUK__MK_LBP(DUK__BP_BOR), /* DUK_TOK_BOR */
58084 DUK__MK_LBP(DUK__BP_BXOR), /* DUK_TOK_BXOR */
58085 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_LNOT */
58086 DUK__MK_LBP(DUK__BP_INVALID), /* DUK_TOK_BNOT */
58087 DUK__MK_LBP(DUK__BP_LAND), /* DUK_TOK_LAND */
58088 DUK__MK_LBP(DUK__BP_LOR), /* DUK_TOK_LOR */
58089 DUK__MK_LBP(DUK__BP_CONDITIONAL), /* DUK_TOK_QUESTION */
#define DUK__MK_LBP(bp)
#define DUK__BP_CONDITIONAL
#define DUK__MK_LBP_FLAGS(bp, flags)
#define DUK__BP_POSTFIX
#define DUK__BP_MEMBER
#define DUK__BP_EOF
#define DUK__BP_INVALID
#define DUK__BP_CLOSING

◆ duk__two_arg_funcs

DUK_LOCAL const duk__two_arg_func duk__two_arg_funcs[]
Initial value:

Definition at line 32810 of file duktape-1.8.0/src/duktape.c.

◆ duk_api_global_filename

DUK_EXTERNAL const char* duk_api_global_filename = NULL

Definition at line 15030 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_push_buffer_raw().

◆ duk_api_global_line

DUK_EXTERNAL duk_int_t duk_api_global_line = 0

Definition at line 15031 of file duktape-1.8.0/src/duktape.c.

Referenced by duk_push_buffer_raw().

◆ duk_base64_dectab

DUK_INTERNAL const duk_int8_t duk_base64_dectab[256]
Initial value:
= {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, -1, -1, -2, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -3, -1, -1,
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
}

Definition at line 11287 of file duktape-1.8.0/src/duktape.c.

11291 {
11292 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* A...P */
11293 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, /* Q...f */
11294 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, /* g...v */
11295 0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2b, 0x2f /* w.../ */
11296};
11297#endif /* DUK_USE_BASE64_FASTPATH */
11298
11299/*
11300 * Table for base-64 decoding
11301 */
11302
11303#if defined(DUK_USE_BASE64_FASTPATH)
11304DUK_INTERNAL const duk_int8_t duk_base64_dectab[256] = {
11305 /* -1 = error, -2 = allowed whitespace, -3 = padding ('='), 0...63 decoded bytes */

◆ duk_base64_enctab

DUK_INTERNAL const duk_uint8_t duk_base64_enctab[64]
Initial value:
= {
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2b, 0x2f
}

Definition at line 11274 of file duktape-1.8.0/src/duktape.c.

◆ duk_bi_native_functions

DUK_INTERNAL const duk_c_function duk_bi_native_functions[149]

Definition at line 9058 of file duktape-1.8.0/src/duktape.c.

9075 {
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_is_encoding(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_join_shared(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_seal_freeze_shared(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_define_properties(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_encode_uri(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_decode_uri_component(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_splice(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_encode_uri_component(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_set_time(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_constructor_now(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_filename_setter(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_stack_getter(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_filename_getter(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_set_shared(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_int(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_locale_string(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_pop(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_to_string(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_readfield(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_has_own_property(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_json_object_stringify(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_is_nan(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_tostring_shared(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_sort(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_onearg_shared(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_is_finite(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_pointer_prototype_tostring_shared(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_compact(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_constructor(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_max(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_byte_length(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_char_at(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_unshift(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_json_object_parse(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_is_sealed_frozen_shared(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_fin(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_min(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_prototype_exec(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_property_is_enumerable(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_date_constructor_parse(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype_bind(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_concat(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_decode_uri(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_gc(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_twoarg_shared(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_constructor_is_array(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_is_extensible(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_concat(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_to_locale_string(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_stack_setter(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_random(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_shift(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_value_of(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_constructor(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_prototype_test(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_arraybuffer_isview(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_logger_prototype_log_shared(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_iter_shared(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_caseconv_shared(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_reverse(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_indexof_shared(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_boolean_prototype_tostring_shared(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_logger_prototype_fmt(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_define_property(duk_context *ctx)
DUK_INTERNAL_DECL duk_ret_t duk_bi_logger_prototype_raw(duk_context *ctx)

◆ duk_class_number_to_stridx

DUK_INTERNAL duk_uint8_t duk_class_number_to_stridx[32]

Definition at line 11505 of file duktape-1.8.0/src/duktape.c.

11522 {
11523 DUK_STRIDX_EMPTY_STRING, /* UNUSED, intentionally empty */
#define DUK_STRIDX_UC_ARGUMENTS
#define DUK_STRIDX_ARRAY
#define DUK_STRIDX_UC_BOOLEAN
#define DUK_STRIDX_MATH
#define DUK_STRIDX_UC_NUMBER
#define DUK_STRIDX_DEC_ENV
#define DUK_STRIDX_REG_EXP
#define DUK_STRIDX_UC_STRING
#define DUK_STRIDX_UC_OBJECT
#define DUK_STRIDX_DATE
#define DUK_STRIDX_JSON
#define DUK_STRIDX_OBJ_ENV
#define DUK_STRIDX_UC_ERROR
#define DUK_STRIDX_UC_FUNCTION

◆ duk_hex_dectab

DUK_INTERNAL const duk_int8_t duk_hex_dectab[256]
Initial value:
= {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
}

Definition at line 11140 of file duktape-1.8.0/src/duktape.c.

11146 {
11151};
11152
11153/*
11154 * Table for hex decoding ASCII hex digits
11155 */
11156
11157DUK_INTERNAL const duk_int8_t duk_hex_dectab[256] = {
11158 /* -1 if invalid */
#define DUK_ASC_2
#define DUK_ASC_8
#define DUK_ASC_5
#define DUK_ASC_6
#define DUK_ASC_7
#define DUK_ASC_1
#define DUK_ASC_4
#define DUK_ASC_3

Referenced by duk__is_hex_digit(), and duk__transform_helper().

◆ duk_hex_dectab_shift4

DUK_INTERNAL const duk_int16_t duk_hex_dectab_shift4[256]
Initial value:
= {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, -1, -1, -1, -1, -1, -1,
-1, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
}

Definition at line 11162 of file duktape-1.8.0/src/duktape.c.

11179 {

◆ duk_hex_enctab

DUK_INTERNAL const duk_uint16_t duk_hex_enctab[256]

Definition at line 11198 of file duktape-1.8.0/src/duktape.c.

11215 {
11216#if defined(DUK_USE_INTEGER_BE)
11217 0x3030U, 0x3031U, 0x3032U, 0x3033U, 0x3034U, 0x3035U, 0x3036U, 0x3037U,
11218 0x3038U, 0x3039U, 0x3061U, 0x3062U, 0x3063U, 0x3064U, 0x3065U, 0x3066U,
11219 0x3130U, 0x3131U, 0x3132U, 0x3133U, 0x3134U, 0x3135U, 0x3136U, 0x3137U,
11220 0x3138U, 0x3139U, 0x3161U, 0x3162U, 0x3163U, 0x3164U, 0x3165U, 0x3166U,
11221 0x3230U, 0x3231U, 0x3232U, 0x3233U, 0x3234U, 0x3235U, 0x3236U, 0x3237U,
11222 0x3238U, 0x3239U, 0x3261U, 0x3262U, 0x3263U, 0x3264U, 0x3265U, 0x3266U,
11223 0x3330U, 0x3331U, 0x3332U, 0x3333U, 0x3334U, 0x3335U, 0x3336U, 0x3337U,
11224 0x3338U, 0x3339U, 0x3361U, 0x3362U, 0x3363U, 0x3364U, 0x3365U, 0x3366U,
11225 0x3430U, 0x3431U, 0x3432U, 0x3433U, 0x3434U, 0x3435U, 0x3436U, 0x3437U,
11226 0x3438U, 0x3439U, 0x3461U, 0x3462U, 0x3463U, 0x3464U, 0x3465U, 0x3466U,
11227 0x3530U, 0x3531U, 0x3532U, 0x3533U, 0x3534U, 0x3535U, 0x3536U, 0x3537U,
11228 0x3538U, 0x3539U, 0x3561U, 0x3562U, 0x3563U, 0x3564U, 0x3565U, 0x3566U,
11229 0x3630U, 0x3631U, 0x3632U, 0x3633U, 0x3634U, 0x3635U, 0x3636U, 0x3637U,
11230 0x3638U, 0x3639U, 0x3661U, 0x3662U, 0x3663U, 0x3664U, 0x3665U, 0x3666U,
11231 0x3730U, 0x3731U, 0x3732U, 0x3733U, 0x3734U, 0x3735U, 0x3736U, 0x3737U,
11232 0x3738U, 0x3739U, 0x3761U, 0x3762U, 0x3763U, 0x3764U, 0x3765U, 0x3766U,
11233 0x3830U, 0x3831U, 0x3832U, 0x3833U, 0x3834U, 0x3835U, 0x3836U, 0x3837U,
11234 0x3838U, 0x3839U, 0x3861U, 0x3862U, 0x3863U, 0x3864U, 0x3865U, 0x3866U,
11235 0x3930U, 0x3931U, 0x3932U, 0x3933U, 0x3934U, 0x3935U, 0x3936U, 0x3937U,
11236 0x3938U, 0x3939U, 0x3961U, 0x3962U, 0x3963U, 0x3964U, 0x3965U, 0x3966U,
11237 0x6130U, 0x6131U, 0x6132U, 0x6133U, 0x6134U, 0x6135U, 0x6136U, 0x6137U,
11238 0x6138U, 0x6139U, 0x6161U, 0x6162U, 0x6163U, 0x6164U, 0x6165U, 0x6166U,
11239 0x6230U, 0x6231U, 0x6232U, 0x6233U, 0x6234U, 0x6235U, 0x6236U, 0x6237U,
11240 0x6238U, 0x6239U, 0x6261U, 0x6262U, 0x6263U, 0x6264U, 0x6265U, 0x6266U,
11241 0x6330U, 0x6331U, 0x6332U, 0x6333U, 0x6334U, 0x6335U, 0x6336U, 0x6337U,
11242 0x6338U, 0x6339U, 0x6361U, 0x6362U, 0x6363U, 0x6364U, 0x6365U, 0x6366U,
11243 0x6430U, 0x6431U, 0x6432U, 0x6433U, 0x6434U, 0x6435U, 0x6436U, 0x6437U,
11244 0x6438U, 0x6439U, 0x6461U, 0x6462U, 0x6463U, 0x6464U, 0x6465U, 0x6466U,
11245 0x6530U, 0x6531U, 0x6532U, 0x6533U, 0x6534U, 0x6535U, 0x6536U, 0x6537U,
11246 0x6538U, 0x6539U, 0x6561U, 0x6562U, 0x6563U, 0x6564U, 0x6565U, 0x6566U,
11247 0x6630U, 0x6631U, 0x6632U, 0x6633U, 0x6634U, 0x6635U, 0x6636U, 0x6637U,
11248 0x6638U, 0x6639U, 0x6661U, 0x6662U, 0x6663U, 0x6664U, 0x6665U, 0x6666U
11249#else /* DUK_USE_INTEGER_BE */
11250 0x3030U, 0x3130U, 0x3230U, 0x3330U, 0x3430U, 0x3530U, 0x3630U, 0x3730U,
11251 0x3830U, 0x3930U, 0x6130U, 0x6230U, 0x6330U, 0x6430U, 0x6530U, 0x6630U,
11252 0x3031U, 0x3131U, 0x3231U, 0x3331U, 0x3431U, 0x3531U, 0x3631U, 0x3731U,
11253 0x3831U, 0x3931U, 0x6131U, 0x6231U, 0x6331U, 0x6431U, 0x6531U, 0x6631U,
11254 0x3032U, 0x3132U, 0x3232U, 0x3332U, 0x3432U, 0x3532U, 0x3632U, 0x3732U,
11255 0x3832U, 0x3932U, 0x6132U, 0x6232U, 0x6332U, 0x6432U, 0x6532U, 0x6632U,
11256 0x3033U, 0x3133U, 0x3233U, 0x3333U, 0x3433U, 0x3533U, 0x3633U, 0x3733U,
11257 0x3833U, 0x3933U, 0x6133U, 0x6233U, 0x6333U, 0x6433U, 0x6533U, 0x6633U,
11258 0x3034U, 0x3134U, 0x3234U, 0x3334U, 0x3434U, 0x3534U, 0x3634U, 0x3734U,
11259 0x3834U, 0x3934U, 0x6134U, 0x6234U, 0x6334U, 0x6434U, 0x6534U, 0x6634U,
11260 0x3035U, 0x3135U, 0x3235U, 0x3335U, 0x3435U, 0x3535U, 0x3635U, 0x3735U,
11261 0x3835U, 0x3935U, 0x6135U, 0x6235U, 0x6335U, 0x6435U, 0x6535U, 0x6635U,
11262 0x3036U, 0x3136U, 0x3236U, 0x3336U, 0x3436U, 0x3536U, 0x3636U, 0x3736U,
11263 0x3836U, 0x3936U, 0x6136U, 0x6236U, 0x6336U, 0x6436U, 0x6536U, 0x6636U,
11264 0x3037U, 0x3137U, 0x3237U, 0x3337U, 0x3437U, 0x3537U, 0x3637U, 0x3737U,
11265 0x3837U, 0x3937U, 0x6137U, 0x6237U, 0x6337U, 0x6437U, 0x6537U, 0x6637U,
11266 0x3038U, 0x3138U, 0x3238U, 0x3338U, 0x3438U, 0x3538U, 0x3638U, 0x3738U,

◆ duk_initjs_data

DUK_INTERNAL const duk_uint8_t duk_initjs_data[204]
Initial value:
= {
40,102,117,110,99,116,105,111,110,40,100,44,97,41,123,102,117,110,99,116,
105,111,110,32,98,40,97,44,98,44,99,41,123,79,98,106,101,99,116,46,100,101,
102,105,110,101,80,114,111,112,101,114,116,121,40,97,44,98,44,123,118,97,
108,117,101,58,99,44,119,114,105,116,97,98,108,101,58,33,48,44,101,110,117,
109,101,114,97,98,108,101,58,33,49,44,99,111,110,102,105,103,117,114,97,98,
108,101,58,33,48,125,41,125,98,40,97,46,76,111,103,103,101,114,44,34,99,
108,111,103,34,44,110,101,119,32,97,46,76,111,103,103,101,114,40,34,67,34,
41,41,59,98,40,97,44,34,109,111,100,76,111,97,100,101,100,34,44,79,98,106,
101,99,116,46,99,114,101,97,116,101,40,110,117,108,108,41,41,125,41,40,116,
104,105,115,44,68,117,107,116,97,112,101,41,59,10,0,
}

Definition at line 9210 of file duktape-1.8.0/src/duktape.c.

◆ duk_is_idchar_tab

DUK_INTERNAL const duk_int8_t duk_is_idchar_tab[128]
Initial value:
= {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0
}

Definition at line 9944 of file duktape-1.8.0/src/duktape.c.

◆ duk_lc_digits

DUK_INTERNAL const duk_uint8_t duk_lc_digits[36]
Initial value:
= {
}
#define DUK_ASC_LC_M
#define DUK_ASC_LC_Z
#define DUK_ASC_LC_C
#define DUK_ASC_LC_L
#define DUK_ASC_LC_J
#define DUK_ASC_LC_Y
#define DUK_ASC_LC_P
#define DUK_ASC_LC_K
#define DUK_ASC_LC_D
#define DUK_ASC_LC_H
#define DUK_ASC_LC_G
#define DUK_ASC_LC_I
#define DUK_ASC_LC_O
#define DUK_ASC_LC_Q
#define DUK_ASC_LC_W
#define DUK_ASC_LC_S
#define DUK_ASC_LC_A
#define DUK_ASC_LC_V

Definition at line 11117 of file duktape-1.8.0/src/duktape.c.

Referenced by duk__enc_buffer_data().

◆ duk_str_alloc_failed

DUK_INTERNAL const char* duk_str_alloc_failed = "alloc failed"

Definition at line 8760 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_array_length_not_writable

DUK_INTERNAL const char* duk_str_array_length_not_writable = "array length non-writable"

Definition at line 8785 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_array_length_over_2g

DUK_INTERNAL const char* duk_str_array_length_over_2g = "array length over 2G"

Definition at line 8769 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_array_length_write_failed

DUK_INTERNAL const char* duk_str_array_length_write_failed = "array length write failed"

Definition at line 8784 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_bound_chain_limit

DUK_INTERNAL const char* duk_str_bound_chain_limit = "function call bound chain limit"

Definition at line 8832 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_buffer_too_long

DUK_INTERNAL const char* duk_str_buffer_too_long = "buffer too long"

Definition at line 8758 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_bytecode_limit

DUK_INTERNAL const char* duk_str_bytecode_limit = "bytecode limit"

Definition at line 8835 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_c_callstack_limit

DUK_INTERNAL const char* duk_str_c_callstack_limit = "C call stack depth limit"

Definition at line 8833 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_callstack_limit

DUK_INTERNAL const char* duk_str_callstack_limit = "callstack limit"

Definition at line 8829 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_cannot_delete_identifier

DUK_INTERNAL const char* duk_str_cannot_delete_identifier = "cannot delete identifier"

Definition at line 8798 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_catchstack_limit

DUK_INTERNAL const char* duk_str_catchstack_limit = "catchstack limit"

Definition at line 8830 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_compiler_recursion_limit

DUK_INTERNAL const char* duk_str_compiler_recursion_limit = "compiler recursion limit"

Definition at line 8834 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_concat_result_too_long

DUK_INTERNAL const char* duk_str_concat_result_too_long = "concat result too long"

Definition at line 8766 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_const_limit

DUK_INTERNAL const char* duk_str_const_limit = "const limit"

Definition at line 8838 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_cyclic_input

DUK_INTERNAL const char* duk_str_cyclic_input = "cyclic input"

Definition at line 8776 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_decode_failed

DUK_INTERNAL const char* duk_str_decode_failed = "decode failed"

Definition at line 8764 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_defaultvalue_coerce_failed

DUK_INTERNAL const char* duk_str_defaultvalue_coerce_failed = "[[DefaultValue]] coerce failed"

Definition at line 8754 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_duplicate_label

DUK_INTERNAL const char* duk_str_duplicate_label = "duplicate label"

Definition at line 8793 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_empty_expr_not_allowed

DUK_INTERNAL const char* duk_str_empty_expr_not_allowed = "empty expression not allowed"

Definition at line 8802 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_encode_failed

DUK_INTERNAL const char* duk_str_encode_failed = "encode failed"

Definition at line 8763 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_expected_identifier

DUK_INTERNAL const char* duk_str_expected_identifier = "expected identifier"

Definition at line 8801 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_fmt_invalid_json

DUK_INTERNAL const char* duk_str_fmt_invalid_json = "invalid json (at offset %ld)"

Definition at line 8773 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_fmt_ptr

DUK_INTERNAL const char* duk_str_fmt_ptr = "%p"

Definition at line 8772 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_func_limit

DUK_INTERNAL const char* duk_str_func_limit = "function limit"

Definition at line 8839 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_func_name_required

DUK_INTERNAL const char* duk_str_func_name_required = "function name required"

Definition at line 8815 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_func_stmt_not_allowed

DUK_INTERNAL const char* duk_str_func_stmt_not_allowed = "function statement not allowed"

Definition at line 8810 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_internal_error

DUK_INTERNAL const char* duk_str_internal_error = "internal error"

Definition at line 8741 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_arg_name

DUK_INTERNAL const char* duk_str_invalid_arg_name = "invalid argument name"

Definition at line 8812 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_array_length

DUK_INTERNAL const char* duk_str_invalid_array_length = "invalid array length"

Definition at line 8783 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_array_literal

DUK_INTERNAL const char* duk_str_invalid_array_literal = "invalid array literal"

Definition at line 8795 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_backrefs

DUK_INTERNAL const char* duk_str_invalid_backrefs = "invalid backreference(s)"

Definition at line 8825 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_base

DUK_INTERNAL const char* duk_str_invalid_base = "invalid base value"

Definition at line 8780 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_break_cont_label

DUK_INTERNAL const char* duk_str_invalid_break_cont_label = "invalid break/continue label"

Definition at line 8805 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_call_args

DUK_INTERNAL const char* duk_str_invalid_call_args = "invalid call args"

Definition at line 8743 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_context

DUK_INTERNAL const char* duk_str_invalid_context = "invalid context"

Definition at line 8750 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_count

DUK_INTERNAL const char* duk_str_invalid_count = "invalid count"

Definition at line 8742 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_descriptor

DUK_INTERNAL const char* duk_str_invalid_descriptor = "invalid descriptor"

Definition at line 8788 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_expression

DUK_INTERNAL const char* duk_str_invalid_expression = "invalid expression"

Definition at line 8799 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_for

DUK_INTERNAL const char* duk_str_invalid_for = "invalid for statement"

Definition at line 8803 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_func_name

DUK_INTERNAL const char* duk_str_invalid_func_name = "invalid function name"

Definition at line 8813 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_getset_name

DUK_INTERNAL const char* duk_str_invalid_getset_name = "invalid getter/setter name"

Definition at line 8814 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_label

DUK_INTERNAL const char* duk_str_invalid_label = "invalid label"

Definition at line 8794 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_lvalue

DUK_INTERNAL const char* duk_str_invalid_lvalue = "invalid lvalue"

Definition at line 8800 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_object_literal

DUK_INTERNAL const char* duk_str_invalid_object_literal = "invalid object literal"

Definition at line 8796 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_quantifier_no_atom

DUK_INTERNAL const char* duk_str_invalid_quantifier_no_atom = "quantifier without preceding atom"

Definition at line 8818 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_quantifier_values

DUK_INTERNAL const char* duk_str_invalid_quantifier_values = "quantifier values invalid (qmin > qmax)"

Definition at line 8819 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_regexp_flags

DUK_INTERNAL const char* duk_str_invalid_regexp_flags = "invalid regexp flags"

Definition at line 8824 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_return

DUK_INTERNAL const char* duk_str_invalid_return = "invalid return"

Definition at line 8806 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_switch

DUK_INTERNAL const char* duk_str_invalid_switch = "invalid switch statement"

Definition at line 8804 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_throw

DUK_INTERNAL const char* duk_str_invalid_throw = "invalid throw"

Definition at line 8808 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_try

DUK_INTERNAL const char* duk_str_invalid_try = "invalid try"

Definition at line 8807 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_invalid_var_declaration

DUK_INTERNAL const char* duk_str_invalid_var_declaration = "invalid variable declaration"

Definition at line 8797 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_jsondec_reclimit

DUK_INTERNAL const char* duk_str_jsondec_reclimit = "json decode recursion limit"

Definition at line 8774 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_jsonenc_reclimit

DUK_INTERNAL const char* duk_str_jsonenc_reclimit = "json encode recursion limit"

Definition at line 8775 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_no_sourcecode

DUK_INTERNAL const char* duk_str_no_sourcecode = "no sourcecode"

Definition at line 8765 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_not_buffer

DUK_INTERNAL const char* duk_str_not_buffer = "not buffer"

Definition at line 8752 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_not_callable

DUK_INTERNAL const char* duk_str_not_callable = "not callable"

Definition at line 8745 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_not_configurable

DUK_INTERNAL const char* duk_str_not_configurable = "not configurable"

Definition at line 8748 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_not_constructable

DUK_INTERNAL const char* duk_str_not_constructable = "not constructable"

Definition at line 8744 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_not_extensible

DUK_INTERNAL const char* duk_str_not_extensible = "not extensible"

Definition at line 8746 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_not_object_coercible

DUK_INTERNAL const char* duk_str_not_object_coercible = "not object coercible"

Definition at line 8756 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_not_writable

DUK_INTERNAL const char* duk_str_not_writable = "not writable"

Definition at line 8747 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_number_outside_range

DUK_INTERNAL const char* duk_str_number_outside_range = "number outside range"

Definition at line 8755 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_parse_error

DUK_INTERNAL const char* duk_str_parse_error = "parse error"

Definition at line 8792 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_pop_too_many

DUK_INTERNAL const char* duk_str_pop_too_many = "attempt to pop too many entries"

Definition at line 8761 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_property_is_virtual

DUK_INTERNAL const char* duk_str_property_is_virtual = "property is virtual"

Definition at line 8789 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_prototype_chain_limit

DUK_INTERNAL const char* duk_str_prototype_chain_limit = "prototype chain limit"

Definition at line 8831 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_proxy_rejected

DUK_INTERNAL const char* duk_str_proxy_rejected = "proxy rejected"

Definition at line 8782 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_proxy_revoked

DUK_INTERNAL const char* duk_str_proxy_revoked = "proxy revoked"

Definition at line 8779 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_push_beyond_alloc_stack

DUK_INTERNAL const char* duk_str_push_beyond_alloc_stack = "attempt to push beyond currently allocated stack"

Definition at line 8751 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_quantifier_too_many_copies

DUK_INTERNAL const char* duk_str_quantifier_too_many_copies = "quantifier expansion requires too many atom copies"

Definition at line 8820 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_redefine_virt_prop

DUK_INTERNAL const char* duk_str_redefine_virt_prop = "attempt to redefine virtual property"

Definition at line 8787 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_reg_limit

DUK_INTERNAL const char* duk_str_reg_limit = "register limit"

Definition at line 8836 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_regexp_compiler_recursion_limit

DUK_INTERNAL const char* duk_str_regexp_compiler_recursion_limit = "regexp compiler recursion limit"

Definition at line 8840 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_regexp_executor_recursion_limit

DUK_INTERNAL const char* duk_str_regexp_executor_recursion_limit = "regexp executor recursion limit"

Definition at line 8841 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_regexp_executor_step_limit

DUK_INTERNAL const char* duk_str_regexp_executor_step_limit = "regexp step limit"

Definition at line 8842 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_setter_undefined

DUK_INTERNAL const char* duk_str_setter_undefined = "setter undefined"

Definition at line 8786 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_sprintf_too_long

DUK_INTERNAL const char* duk_str_sprintf_too_long = "sprintf message too long"

Definition at line 8759 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_strict_caller_read

DUK_INTERNAL const char* duk_str_strict_caller_read = "attempt to read strict 'caller'"

Definition at line 8781 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_string_too_long

DUK_INTERNAL const char* duk_str_string_too_long = "string too long"

Definition at line 8757 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_temp_limit

DUK_INTERNAL const char* duk_str_temp_limit = "temp limit"

Definition at line 8837 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_unexpected_closing_paren

DUK_INTERNAL const char* duk_str_unexpected_closing_paren = "unexpected closing parenthesis"

Definition at line 8821 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_unexpected_end_of_pattern

DUK_INTERNAL const char* duk_str_unexpected_end_of_pattern = "unexpected end of pattern"

Definition at line 8822 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_unexpected_regexp_token

DUK_INTERNAL const char* duk_str_unexpected_regexp_token = "unexpected token in regexp"

Definition at line 8823 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_unexpected_type

DUK_INTERNAL const char* duk_str_unexpected_type = "unexpected type"

Definition at line 8753 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_unimplemented

DUK_INTERNAL const char* duk_str_unimplemented = "unimplemented"

Definition at line 8767 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_unsupported

DUK_INTERNAL const char* duk_str_unsupported = "unsupported"

Definition at line 8768 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_unterminated_stmt

DUK_INTERNAL const char* duk_str_unterminated_stmt = "unterminated statement"

Definition at line 8811 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_valstack_limit

DUK_INTERNAL const char* duk_str_valstack_limit = "valstack limit"

Definition at line 8828 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_with_in_strict_mode

DUK_INTERNAL const char* duk_str_with_in_strict_mode = "with in strict mode"

Definition at line 8809 of file duktape-1.8.0/src/duktape.c.

◆ duk_str_wrong_buffer_type

DUK_INTERNAL const char* duk_str_wrong_buffer_type = "wrong buffer type"

Definition at line 8762 of file duktape-1.8.0/src/duktape.c.

◆ duk_strings_data

DUK_INTERNAL const duk_uint8_t duk_strings_data[1049]

Definition at line 9000 of file duktape-1.8.0/src/duktape.c.

9017 {
901879,104,209,144,168,105,6,78,182,139,90,122,8,154,140,35,103,35,117,193,73,
90195,52,116,180,104,166,135,52,189,4,98,12,27,178,156,80,211,31,161,115,150,
902064,52,221,109,24,18,68,157,24,38,67,118,36,55,73,119,151,164,140,93,18,117,
9021128,153,201,228,201,205,2,250,8,196,24,232,104,82,146,40,232,193,48,118,
9022168,37,147,212,54,127,113,208,70,32,194,187,68,54,127,113,208,70,32,196,
9023123,68,54,127,113,209,44,12,121,7,208,70,32,194,186,134,207,236,126,219,
9024160,140,65,133,246,136,108,254,199,237,186,8,196,24,87,80,217,253,159,217,
9025116,17,136,48,190,209,13,159,217,253,151,65,24,131,12,233,86,224,79,236,
9026254,203,160,140,65,134,116,171,112,39,246,223,105,208,70,32,193,140,183,4,
902711,55,92,20,244,141,169,186,50,11,164,109,77,208,208,165,36,79,215,185,13,
9028153,34,110,204,241,32,6,66,84,11,112,200,84,52,157,124,92,242,70,120,45,64,
9029186,17,22,138,38,0,172,140,19,154,84,26,145,0,86,69,17,180,97,34,0,172,132,
903075,144,215,77,221,91,132,5,147,178,156,80,211,30,160,93,9,215,21,115,119,
9031169,49,75,211,138,26,101,205,222,68,157,47,78,40,105,151,55,120,204,156,
9032189,56,161,166,52,157,72,136,138,65,154,232,147,162,4,136,150,81,115,66,
9033208,210,37,96,148,250,134,140,151,39,212,125,255,221,125,73,80,209,146,233,
9034124,93,55,79,15,34,196,230,202,113,160,166,232,157,132,148,128,98,28,46,
9035114,200,6,153,180,96,73,19,74,113,67,76,103,5,36,20,211,70,140,133,67,72,
903649,245,160,235,81,212,52,168,106,39,132,253,111,80,210,161,168,158,5,245,
9037191,96,31,172,15,208,23,226,190,131,232,62,131,232,11,251,127,93,245,223,
903893,251,172,234,27,80,45,3,250,14,140,19,34,65,19,81,132,108,228,97,1,107,
903933,12,32,45,100,136,206,9,12,196,155,134,69,146,100,235,226,231,146,51,194,
904072,218,48,145,4,200,119,89,189,81,49,39,72,147,235,226,233,186,120,121,58,
9041226,167,90,124,93,55,107,71,137,33,68,68,130,64,206,75,189,209,156,144,84,
904244,141,3,8,137,187,178,156,80,211,26,110,242,100,230,146,120,121,8,48,76,6,
904389,26,105,157,65,196,201,213,145,166,153,212,28,76,157,113,75,34,78,62,14,
904438,73,105,228,142,136,178,48,141,152,228,73,150,83,0,148,39,137,75,67,73,
9045214,209,129,36,85,190,206,32,17,6,9,128,141,3,8,130,161,100,235,64,194,24,
904652,41,73,19,189,200,108,201,19,111,181,2,232,66,239,173,37,230,157,244,56,
9047153,4,225,145,27,233,93,22,1,114,62,251,80,69,128,121,247,213,146,228,109,
904879,190,212,17,35,106,125,246,78,164,68,68,111,175,23,217,45,13,33,119,208,
904968,210,38,250,192,61,91,233,80,208,45,25,36,81,190,156,13,26,201,19,239,
9050162,2,214,66,31,125,153,226,64,13,27,236,72,96,130,68,62,251,48,68,196,153,
9051119,217,157,18,56,156,199,161,100,42,26,250,77,36,140,122,40,144,19,34,9,

◆ duk_uc_nybbles

◆ duk_unicode_caseconv_lc

const duk_uint8_t duk_unicode_caseconv_lc[616]
Initial value:
= {
144,3,0,3,128,184,6,192,7,192,112,24,144,37,96,64,54,32,81,64,128,226,0,
235,65,129,199,1,230,130,3,145,3,177,34,7,70,7,134,36,15,244,13,236,24,32,
0,34,129,0,65,0,67,4,0,166,32,172,41,132,40,11,64,19,15,132,15,128,8,31,24,
31,16,12,62,80,62,64,32,124,224,124,192,64,250,64,250,0,97,246,129,246,1,3,
241,3,240,2,7,230,7,228,4,15,212,15,208,8,31,184,31,176,4,63,116,62,224,8,
127,32,125,200,32,254,192,254,128,33,253,161,247,96,67,253,3,252,0,135,250,
135,222,129,15,252,15,188,2,31,250,31,124,4,66,192,66,224,64,146,216,147,
64,209,96,1,97,130,242,199,224,35,240,95,228,63,232,38,161,1,0,1,1,48,2,
100,2,102,12,4,228,4,232,64,10,80,10,89,112,23,144,23,160,96,48,64,48,96,
128,104,0,104,65,128,217,128,218,2,1,203,1,204,18,3,188,3,190,36,7,200,7,
204,16,15,192,15,201,64,34,32,34,49,32,72,192,72,225,64,220,0,220,65,1,236,
1,236,140,4,96,4,97,34,9,20,9,22,108,19,4,19,8,56,38,128,38,138,193,224,1,
224,25,99,212,3,212,44,7,214,71,212,66,22,51,150,52,3,44,128,44,129,100,89,
214,89,216,10,153,2,153,4,189,52,5,52,8,202,114,42,114,48,244,230,84,230,
103,233,222,105,222,129,83,191,83,191,133,167,160,167,161,10,48,13,48,20,0,
32,26,192,26,208,64,56,128,56,192,192,113,64,113,129,1,251,129,252,2,44,
114,44,115,4,16,12,56,12,64,32,27,128,27,144,64,211,197,211,198,2,8,6,88,9,
164,16,17,216,17,224,47,245,1,120,0,255,1,129,2,83,1,134,2,84,1,142,1,221,
1,143,2,89,1,144,2,91,1,145,1,146,1,147,2,96,1,148,2,99,1,151,2,104,1,152,
1,153,1,157,2,114,1,159,2,117,1,167,1,168,1,174,2,136,1,183,2,146,1,241,1,
243,1,246,1,149,1,247,1,191,2,32,1,158,2,58,44,101,2,61,1,154,2,62,44,102,
2,67,1,128,2,68,2,137,2,69,2,140,3,118,3,119,3,134,3,172,3,140,3,204,3,207,
3,215,3,244,3,184,3,249,3,242,4,192,4,207,30,158,0,223,31,188,31,179,31,
204,31,195,31,236,31,229,31,252,31,243,33,38,3,201,33,42,0,107,33,43,0,229,
33,50,33,78,33,131,33,132,44,96,44,97,44,98,2,107,44,99,29,125,44,100,2,
125,44,109,2,81,44,110,2,113,44,111,2,80,44,112,2,82,167,125,29,121,167,
141,2,101,2,2,97,0,52,129,131,128,
}

Definition at line 80502 of file duktape-1.8.0/src/duktape.c.

80519 {
80520144,3,0,3,128,184,6,192,7,192,112,24,144,37,96,64,54,32,81,64,128,226,0,
80521235,65,129,199,1,230,130,3,145,3,177,34,7,70,7,134,36,15,244,13,236,24,32,
805220,34,129,0,65,0,67,4,0,166,32,172,41,132,40,11,64,19,15,132,15,128,8,31,24,
8052331,16,12,62,80,62,64,32,124,224,124,192,64,250,64,250,0,97,246,129,246,1,3,
80524241,3,240,2,7,230,7,228,4,15,212,15,208,8,31,184,31,176,4,63,116,62,224,8,
80525127,32,125,200,32,254,192,254,128,33,253,161,247,96,67,253,3,252,0,135,250,
80526135,222,129,15,252,15,188,2,31,250,31,124,4,66,192,66,224,64,146,216,147,
8052764,209,96,1,97,130,242,199,224,35,240,95,228,63,232,38,161,1,0,1,1,48,2,
80528100,2,102,12,4,228,4,232,64,10,80,10,89,112,23,144,23,160,96,48,64,48,96,
80529128,104,0,104,65,128,217,128,218,2,1,203,1,204,18,3,188,3,190,36,7,200,7,
80530204,16,15,192,15,201,64,34,32,34,49,32,72,192,72,225,64,220,0,220,65,1,236,

◆ duk_unicode_caseconv_uc

const duk_uint8_t duk_unicode_caseconv_uc[1288]

Definition at line 80441 of file duktape-1.8.0/src/duktape.c.

80458 {
80459132,3,128,3,0,184,7,192,6,192,112,35,242,199,224,64,74,192,49,32,128,162,
80460128,108,65,1,189,129,254,131,3,173,3,136,6,7,98,7,34,68,15,12,14,140,72,30,
80461104,28,112,32,67,0,65,4,0,138,0,128,4,1,88,65,76,83,15,128,15,132,8,31,16,
8046231,24,12,62,64,62,80,32,124,192,124,224,64,250,0,250,64,97,246,1,246,129,3,
80463238,3,247,64,135,220,135,242,2,15,187,15,237,2,31,120,31,248,4,62,244,63,
80464212,8,125,240,127,232,16,253,128,253,192,33,253,1,253,128,67,252,3,253,0,
80465136,92,8,88,8,18,104,18,91,26,44,48,44,0,94,90,0,33,64,155,253,7,252,132,
80466212,0,32,32,32,6,0,76,192,76,129,128,157,0,156,136,1,75,1,74,46,2,244,2,
80467242,12,6,12,6,8,16,13,8,13,0,48,27,64,27,48,64,57,192,57,162,0,119,192,119,
80468132,128,252,128,252,20,2,35,2,34,18,4,142,4,140,20,13,196,13,192,16,30,200,
8046930,192,192,70,16,70,2,32,145,96,145,70,193,48,129,48,67,130,104,130,104,44,
8047030,1,30,0,150,61,66,61,64,192,125,68,125,100,33,99,65,99,56,50,200,18,200,
804716,69,157,133,157,96,169,144,105,144,11,211,64,211,64,12,167,35,167,34,15,
8047278,103,78,100,126,157,234,157,228,21,59,253,59,240,90,122,26,122,0,163,128,
80473214,128,214,2,1,197,1,196,6,3,140,3,136,12,7,200,7,196,16,20,0,13,48,32,63,
80474128,63,112,69,142,101,142,64,130,1,136,1,135,4,3,114,3,112,8,26,120,202,
80475120,176,65,1,30,1,29,130,2,105,1,150,5,255,96,22,160,115,128,31,224,47,0,
8047638,32,9,32,47,224,10,96,48,0,72,96,50,64,50,32,50,160,62,192,51,32,51,0,51,
8047764,71,160,51,192,68,0,53,0,52,224,55,224,62,224,59,160,49,192,62,96,62,32,
8047874,5,141,224,74,37,141,160,74,69,142,0,74,96,48,32,74,128,48,192,75,32,49,
80479224,75,96,50,0,76,0,50,96,76,96,50,128,76,180,241,160,77,0,50,224,77,101,
80480140,64,78,37,141,192,78,64,51,160,78,160,51,224,79,165,140,128,81,0,53,192,
8048181,32,72,128,81,128,72,160,82,64,54,224,104,160,115,32,110,224,110,192,117,
80482128,112,192,120,64,116,96,121,128,113,128,122,0,114,64,122,32,115,0,122,
80483160,116,192,122,192,116,0,122,224,121,224,126,0,115,64,126,32,116,32,126,
8048464,127,32,126,160,114,160,153,224,152,3,175,52,239,163,175,165,140,99,211,
8048599,204,3,247,192,115,35,252,163,253,132,41,196,38,68,48,132,48,101,140,37,
80486140,5,140,160,71,69,140,192,71,217,128,55,224,5,48,5,48,20,152,10,240,1,56,
804877,194,0,74,3,12,3,144,192,230,64,194,0,192,64,236,48,58,80,48,128,48,16,88,
80488120,20,212,21,72,122,90,0,72,3,49,30,151,128,21,0,194,7,166,32,5,112,48,
80489161,233,152,1,100,12,40,122,106,0,65,2,190,31,80,128,233,64,196,199,212,
80490176,58,80,49,48,48,1,245,76,14,148,12,76,12,4,125,91,3,165,3,19,3,66,31,
80491128,135,194,0,230,71,224,97,240,144,57,145,248,40,124,40,14,100,126,14,31,
8049211,3,153,31,132,135,195,0,230,71,225,97,240,208,57,145,248,104,124,56,14,
80493100,126,30,31,15,3,153,31,136,135,194,0,230,71,226,97,240,144,57,145,248,
80494168,124,40,14,100,126,46,31,11,3,153,31,140,135,195,0,230,71,227,97,240,
80495208,57,145,248,232,124,56,14,100,126,62,31,15,3,153,31,144,135,202,0,230,
8049671,228,97,242,144,57,145,249,40,124,168,14,100,126,78,31,43,3,153,31,148,
80497135,203,0,230,71,229,97,242,208,57,145,249,104,124,184,14,100,126,94,31,47,
804983,153,31,152,135,202,0,230,71,230,97,242,144,57,145,249,168,124,168,14,100,
80499126,110,31,43,3,153,31,156,135,203,0,230,71,231,97,242,208,57,145,249,232,
80500124,184,14,100,126,126,31,47,3,153,31,160,135,218,0,230,71,232,97,246,144,
8050157,145,250,40,125,168,14,100,126,142,31,107,3,153,31,164,135,219,0,230,71,

◆ duk_unicode_idp_m_ids_noa

const duk_uint8_t duk_unicode_idp_m_ids_noa[397]
Initial value:
= {
255,225,243,246,15,254,0,116,255,191,29,32,33,33,32,243,170,242,47,15,112,
245,118,53,49,35,57,240,144,241,15,11,244,218,240,25,241,56,241,67,40,34,
36,241,210,249,99,242,130,47,2,38,177,57,240,50,242,160,38,49,50,160,177,
57,240,50,242,160,36,81,50,64,240,107,64,194,242,160,39,34,34,240,97,57,
240,50,242,160,38,49,50,145,177,57,240,64,242,212,66,35,160,240,9,240,50,
242,198,34,35,129,193,57,240,65,242,160,38,34,35,129,193,57,240,65,242,198,
34,35,160,177,57,240,65,243,128,85,32,39,240,65,242,240,54,215,41,244,144,
53,33,197,57,243,1,121,192,32,32,81,242,63,4,33,106,47,20,160,245,111,4,41,
211,82,34,54,67,235,46,255,225,179,47,254,42,98,240,242,240,241,241,1,243,
79,14,160,57,241,50,57,248,16,246,139,91,185,245,47,1,129,121,242,244,242,
185,47,13,58,121,245,132,242,31,1,201,240,56,210,241,9,105,241,237,242,47,
4,153,121,246,130,47,5,80,80,251,255,23,240,115,255,225,0,31,35,31,5,15,
109,197,4,191,254,175,34,247,240,245,47,16,255,225,30,95,91,31,255,0,100,
121,159,55,13,31,100,31,254,0,64,64,80,240,148,244,161,242,79,1,201,127,2,
240,9,240,231,240,188,241,227,242,29,240,25,244,29,208,145,57,241,48,242,
96,34,49,97,32,255,224,21,114,19,159,255,0,62,24,15,254,29,95,0,240,38,209,
240,162,251,41,241,112,255,225,177,15,254,25,105,255,228,75,34,22,63,26,37,
15,254,75,66,242,126,241,25,240,34,241,250,255,240,10,249,228,69,151,54,
241,3,248,98,255,228,125,242,47,255,12,23,244,254,0,
}

Definition at line 80381 of file duktape-1.8.0/src/duktape.c.

80385 {
80386255,240,0,94,18,255,233,99,241,51,63,254,215,32,240,184,240,2,255,240,6,89,
80387249,0,
80388};
80389#endif
80390
80391#ifdef DUK_USE_SOURCE_NONBMP
80392/* IdentifierPart production with IdentifierStart and ASCII excluded */
80393/* duk_unicode_idp_m_ids_noa[] */
80394/*
80395 * Automatically generated by extract_chars.py, do not edit!
80396 */
80397
80398const duk_uint8_t duk_unicode_idp_m_ids_noa[397] = {
80399255,225,243,246,15,254,0,116,255,191,29,32,33,33,32,243,170,242,47,15,112,
80400245,118,53,49,35,57,240,144,241,15,11,244,218,240,25,241,56,241,67,40,34,
8040136,241,210,249,99,242,130,47,2,38,177,57,240,50,242,160,38,49,50,160,177,

◆ duk_unicode_ids_m_let_noa

const duk_uint8_t duk_unicode_ids_m_let_noa[42]
Initial value:
= {
255,240,0,94,18,255,233,99,241,51,63,254,215,32,240,184,240,2,255,240,6,89,
249,255,240,4,148,79,37,255,224,192,9,15,120,79,255,0,15,30,245,48,
}

Definition at line 80357 of file duktape-1.8.0/src/duktape.c.

◆ duk_unicode_ids_noa

const duk_uint8_t duk_unicode_ids_noa[791]

Definition at line 80274 of file duktape-1.8.0/src/duktape.c.

80291 {
80292249,176,176,80,111,7,47,15,47,254,11,197,191,0,72,2,15,115,66,19,57,2,34,2,
80293240,66,244,50,247,185,248,234,241,99,8,241,127,58,240,182,47,31,241,191,21,
8029418,245,50,15,1,24,27,35,15,2,2,240,239,15,244,156,15,10,241,26,21,6,240,
80295101,10,4,15,9,240,159,157,242,100,15,4,8,159,1,98,102,115,19,240,98,98,4,
8029652,15,2,14,18,47,0,31,5,85,19,240,98,98,18,18,31,17,50,15,5,47,2,130,34,
80297240,98,98,18,68,15,4,15,1,31,21,115,19,240,98,98,18,68,15,16,18,47,1,15,3,
802982,84,34,52,18,2,20,20,36,191,8,15,38,114,34,240,114,146,68,15,12,23,31,21,
80299114,34,240,114,146,68,15,18,2,31,1,31,4,114,34,241,147,15,2,15,3,31,10,86,
80300240,36,240,130,130,3,111,44,242,2,29,111,44,18,3,18,3,7,50,98,34,2,3,18,50,
8030126,3,66,15,7,31,20,15,49,114,241,79,13,79,101,241,191,6,15,2,85,52,4,24,37,
80302205,15,3,241,107,241,178,4,255,224,59,35,54,32,35,63,25,35,63,17,35,54,32,
8030335,62,47,41,35,63,51,241,127,0,240,47,69,223,254,21,227,240,18,240,166,243,
80304180,47,1,194,63,0,240,47,0,240,47,0,194,47,1,242,79,21,5,15,53,244,137,241,
80305146,6,243,107,240,223,37,240,227,76,241,207,7,111,42,240,122,242,95,68,15,
8030679,241,255,3,111,41,240,238,31,2,241,111,12,241,79,27,43,241,79,93,50,63,0,
80307251,15,50,255,224,8,53,63,22,53,55,32,32,32,47,15,63,37,38,32,66,38,67,53,
8030892,98,38,246,96,224,240,44,245,112,80,57,32,68,112,32,32,35,42,51,100,80,
80309240,63,25,255,233,107,241,242,241,242,247,87,63,3,241,107,242,106,15,2,240,
80310122,98,98,98,98,98,98,98,111,66,15,254,12,146,240,184,132,52,95,70,114,47,
8031174,35,111,25,79,78,240,63,11,242,127,0,255,224,244,255,240,0,138,143,60,

◆ duk_unicode_re_ranges_digit

DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_digit[2]
Initial value:
= {
(duk_uint16_t) 0x0030UL, (duk_uint16_t) 0x0039UL,
}

Definition at line 11056 of file duktape-1.8.0/src/duktape.c.

11056 : the description in E5 Section 15.10.2.6 has a typo, it
11057 * contains 'A' twice and lacks 'a'; the intent is [0-9a-zA-Z_].
11058 */

Referenced by duk__parse_disjunction().

◆ duk_unicode_re_ranges_not_digit

DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_not_digit[4]
Initial value:
= {
(duk_uint16_t) 0x0000UL, (duk_uint16_t) 0x002FUL,
(duk_uint16_t) 0x003AUL, (duk_uint16_t) 0xFFFFUL,
}

Definition at line 11078 of file duktape-1.8.0/src/duktape.c.

◆ duk_unicode_re_ranges_not_white

DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_not_white[24]
Initial value:
= {
(duk_uint16_t) 0x0000UL, (duk_uint16_t) 0x0008UL,
(duk_uint16_t) 0x000EUL, (duk_uint16_t) 0x001FUL,
(duk_uint16_t) 0x0021UL, (duk_uint16_t) 0x009FUL,
(duk_uint16_t) 0x00A1UL, (duk_uint16_t) 0x167FUL,
(duk_uint16_t) 0x1681UL, (duk_uint16_t) 0x180DUL,
(duk_uint16_t) 0x180FUL, (duk_uint16_t) 0x1FFFUL,
(duk_uint16_t) 0x200BUL, (duk_uint16_t) 0x2027UL,
(duk_uint16_t) 0x202AUL, (duk_uint16_t) 0x202EUL,
(duk_uint16_t) 0x2030UL, (duk_uint16_t) 0x205EUL,
(duk_uint16_t) 0x2060UL, (duk_uint16_t) 0x2FFFUL,
(duk_uint16_t) 0x3001UL, (duk_uint16_t) 0xFEFEUL,
(duk_uint16_t) 0xFF00UL, (duk_uint16_t) 0xFFFFUL,
}

Definition at line 11082 of file duktape-1.8.0/src/duktape.c.

11089 {
11090 (duk_uint16_t) 0x0030UL, (duk_uint16_t) 0x0039UL,
11091 (duk_uint16_t) 0x0041UL, (duk_uint16_t) 0x005AUL,
11092 (duk_uint16_t) 0x005FUL, (duk_uint16_t) 0x005FUL,
11093 (duk_uint16_t) 0x0061UL, (duk_uint16_t) 0x007AUL,
11094};
11095DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_not_digit[4] = {

◆ duk_unicode_re_ranges_not_wordchar

DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_not_wordchar[10]
Initial value:
= {
(duk_uint16_t) 0x0000UL, (duk_uint16_t) 0x002FUL,
(duk_uint16_t) 0x003AUL, (duk_uint16_t) 0x0040UL,
(duk_uint16_t) 0x005BUL, (duk_uint16_t) 0x005EUL,
(duk_uint16_t) 0x0060UL, (duk_uint16_t) 0x0060UL,
(duk_uint16_t) 0x007BUL, (duk_uint16_t) 0xFFFFUL,
}

Definition at line 11096 of file duktape-1.8.0/src/duktape.c.

11099 {
11100 (duk_uint16_t) 0x0000UL, (duk_uint16_t) 0x0008UL,
11101 (duk_uint16_t) 0x000EUL, (duk_uint16_t) 0x001FUL,
11102 (duk_uint16_t) 0x0021UL, (duk_uint16_t) 0x009FUL,

◆ duk_unicode_re_ranges_white

DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_white[22]
Initial value:
= {
(duk_uint16_t) 0x0009UL, (duk_uint16_t) 0x000DUL,
(duk_uint16_t) 0x0020UL, (duk_uint16_t) 0x0020UL,
(duk_uint16_t) 0x00A0UL, (duk_uint16_t) 0x00A0UL,
(duk_uint16_t) 0x1680UL, (duk_uint16_t) 0x1680UL,
(duk_uint16_t) 0x180EUL, (duk_uint16_t) 0x180EUL,
(duk_uint16_t) 0x2000UL, (duk_uint16_t) 0x200AUL,
(duk_uint16_t) 0x2028UL, (duk_uint16_t) 0x2029UL,
(duk_uint16_t) 0x202FUL, (duk_uint16_t) 0x202FUL,
(duk_uint16_t) 0x205FUL, (duk_uint16_t) 0x205FUL,
(duk_uint16_t) 0x3000UL, (duk_uint16_t) 0x3000UL,
(duk_uint16_t) 0xFEFFUL, (duk_uint16_t) 0xFEFFUL,
}

Definition at line 11059 of file duktape-1.8.0/src/duktape.c.

11062 {
11063 return 1;
11064 }
11065 return 0;
11066}
11067
11068/*
11069 * Regexp range tables
11070 */
11071

Referenced by duk__parse_disjunction().

◆ duk_unicode_re_ranges_wordchar

DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_wordchar[8]
Initial value:
= {
(duk_uint16_t) 0x0030UL, (duk_uint16_t) 0x0039UL,
(duk_uint16_t) 0x0041UL, (duk_uint16_t) 0x005AUL,
(duk_uint16_t) 0x005FUL, (duk_uint16_t) 0x005FUL,
(duk_uint16_t) 0x0061UL, (duk_uint16_t) 0x007AUL,
}

Definition at line 11072 of file duktape-1.8.0/src/duktape.c.

11073 {
11074 (duk_uint16_t) 0x0030UL, (duk_uint16_t) 0x0039UL,
11075};
11076DUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_white[22] = {
11077 (duk_uint16_t) 0x0009UL, (duk_uint16_t) 0x000DUL,

Referenced by duk__parse_disjunction().

◆ duk_unicode_xutf8_markers

DUK_INTERNAL const duk_uint8_t duk_unicode_xutf8_markers[7]
Initial value:
= {
0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe
}

Definition at line 10012 of file duktape-1.8.0/src/duktape.c.

10013 {
10014 /* 11 bits */

◆ duk_util_probe_steps

DUK_INTERNAL duk_uint8_t duk_util_probe_steps[32]
Initial value:
= {
2, 3, 5, 7, 11, 13, 19, 31, 41, 47, 59, 67, 73, 79, 89, 101, 103, 107,
109, 127, 137, 139, 149, 157, 163, 167, 173, 181, 191, 193, 197, 199
}

Definition at line 11368 of file duktape-1.8.0/src/duktape.c.

11370 {
11371 17, /* minimum prime */