├── tests
├── octane
│ ├── mujs_tweaks.js
│ └── README.rst
├── perf
│ ├── test-hello-world.py
│ ├── test-hello-world.pl
│ ├── test-hello-world.rb
│ ├── test-hello-world.lua
│ ├── test-empty-loop.py
│ ├── test-empty-loop.pl
│ ├── test-empty-loop.rb
│ ├── test-empty-loop.lua
│ ├── test-fib.py
│ ├── test-hello-world.js
│ ├── test-fib.lua
│ ├── test-fib.rb
│ ├── test-string-plain-concat.py
│ ├── test-fib.pl
│ ├── test-string-array-concat.py
│ ├── test-string-plain-concat.lua
│ ├── test-string-array-concat.lua
│ ├── test-string-plain-concat.rb
│ ├── test-empty-loop.js
│ ├── test-empty-loop-step3.js
│ ├── test-string-array-concat.pl
│ ├── test-string-array-concat.rb
│ ├── test-string-plain-concat.pl
│ ├── test-fib.js
│ ├── test-string-number-list.js
│ ├── test-json-parse-number.py
│ └── test-json-parse-integer.py
├── jsinterpreter
│ └── addition.js
├── knownissues
│ ├── test-dev-lightfunc-finalizer-1.txt
│ ├── test-bi-proxy-object-tostring-1.txt
│ ├── test-numconv-tostring-misc-1.txt
│ ├── test-regexp-invalid-charclass-1.txt
│ ├── test-bug-tonumber-u0000-1.txt
│ ├── test-dev-yield-after-callapply-1.txt
│ ├── test-bug-numconv-1e23-1.txt
│ ├── test-bug-numconv-denorm-toprec-1.txt
│ ├── test-regexp-empty-quantified-1.txt
│ ├── test-dev-bound-thread-start-func-1.txt
│ ├── test-numconv-tostring-gen-1.txt
│ ├── test-dev-16bit-overflows-3.txt
│ ├── test-bi-proxy-construct-newtarget-1.txt
│ ├── test-dev-16bit-overflows-2.txt
│ ├── test-dev-16bit-overflows-1.txt
│ ├── test-bi-regexp-gh39-1.txt
│ ├── test-bi-json-enc-proxy-2.txt
│ ├── test-bi-typedarray-nan-handling-1.txt
│ ├── test-bi-array-push-maxlen-1.txt
│ ├── test-dev-object-literal-method-computed-1.txt
│ ├── test-bi-json-enc-proxy-1.txt
│ ├── test-bug-dataview-buffer-prop-1.txt
│ ├── test-dev-func-cons-args-1.txt
│ └── test-bug-enum-shadow-nonenumerable-1.txt
├── ecmascript
│ ├── test-bi-duktape-thread-prototype-class.js
│ ├── test-regexp-canonicalization-locale.js
│ ├── test-dev-eval-construct.js
│ ├── test-misc-hello-world.js
│ ├── test-dev-func-length-prop.js
│ ├── test-bug-func-args-trailing-comma.js
│ ├── test-dev-for-in-basic.js
│ ├── test-dev-hello-world.js
│ ├── test-bi-date-instance.js
│ ├── test-bi-string-trim-180e.js
│ ├── test-dev-object-constructor.js
│ ├── test-bug-date-nan-tzoffset.js
│ ├── test-dev-unicode-caseconv-basic.js
│ ├── test-expr-newtarget-newfoo.js
│ ├── test-bug-for-multivar.js
│ ├── test-misc-prepost-incdec-order.js
│ ├── test-stmt-break.js
│ ├── test-bug-objlit-nocomma.js
│ ├── test-dev-ctrl-with-binding.js
│ ├── test-dev-traceback-example.js
│ ├── test-bug-strcomp.js
│ ├── test-arguments-class.js
│ ├── test-dev-string-ops-non-string-this.js
│ ├── test-expr-logicalop.js
│ ├── test-dev-add-prec.js
│ ├── test-bug-regexp-dash-assert.js
│ ├── test-bug-typedarray-set-undefined.js
│ ├── test-expr-objectinit.js
│ ├── test-lex-string.js
│ ├── test-lex-whitespace.js
│ ├── test-spec-program.js
│ ├── test-bug-string-endswith-memcmp-overflow.js
│ ├── test-bi-proxy-isarray.js
│ ├── test-bi-regexp-getter-inherit.js
│ ├── test-bug-compiler-gh2033.js
│ ├── test-bug-compiler-gh2036.js
│ ├── test-dev-primary-objectliteral.js
│ ├── test-dev-string-object-props.js
│ ├── test-expr-assignment.js
│ ├── test-regexp-case-insensitive-backref.js
│ ├── test-bug-closure-outer.js
│ ├── test-bug-compiler-gh2026.js
│ ├── test-dev-func-closure-1.js
│ ├── test-bug-regexp-result-inherited-index-gh2203.js
│ ├── test-expr-newtarget-function-code.js
│ ├── test-bug-unary-minus-inplace.js
│ ├── test-dev-primary-parens.js
│ ├── test-bug-unary-bitwise-not-inplace.js
│ ├── test-bug-unary-plus-inplace-modify.js
│ ├── test-dev-catch-binding.js
│ ├── test-stmt-block.js
│ ├── test-bug-array-slice-end.js
│ ├── test-bug-for-var-in.js
│ ├── test-dev-func-without-args.js
│ ├── test-dev-set-arraylength-negzero.js
│ ├── test-expr-lhs-this.js
│ ├── test-bug-compiler-gh2035.js
│ ├── test-bug-props-asize-gh2023-2.js
│ ├── test-bug-switch-code-before-case.js
│ ├── test-bi-cbor-enc-symbol.js
│ ├── test-bug-base64-dec-zerolen-dynamic-buffer-gh2027.js
│ ├── test-bug-compiler-gh2025.js
│ ├── test-bug-assert-cbor-encode-gh2316.js
│ ├── test-dev-exec-timeout-plain.js
│ ├── test-dev-regexp-leading-zero-quant.js
│ ├── test-stmt-continue.js
│ ├── test-bug-string-replace-empty-match.js
│ ├── test-dev-include-test.js
│ ├── test-bi-symbol-object-valueof.js
│ ├── test-bug-props-asize-gh2023.js
│ ├── test-stmt-debugger.js
│ ├── test-lex-lineterm.js
│ ├── test-bug-ret-call.js
│ ├── test-bug-utf8-varname.js
│ ├── test-bi-promise-constructor-reject-basic.js
│ ├── test-bug-compiler-gh2031.js
│ ├── test-bug-isprototypeof-assert-gh1162.js
│ ├── test-bug-typeof-unref.js
│ ├── test-dev-str-characcess-2.js
│ ├── test-bi-json-dec-empty.js
│ ├── test-bi-promise-constructor-resolve-basic.js
│ ├── test-bug-json-stringify-proplist-inherited-gh2202.js
│ ├── test-expr-newtarget-program-code.js
│ ├── test-bug-call-valstack-segfault-gh107.js
│ ├── test-bug-coroutine-yield-refzero-1-gh2204.js
│ ├── test-dev-label-parsing.js
│ ├── test-bug-json-reviver-array-recursion.js
│ ├── test-bi-function-constructor-oneline-comment.js
│ ├── test-bi-json-enc-replacer-proxy.js
│ ├── test-bi-symbol-create-many.js
│ ├── test-bug-incdec-stale-act-gh1370.js
│ ├── test-bug-nodejs-buffer-varint-crash.js
│ ├── test-bug-packed-tval-nan-normalize.js
│ ├── test-bug-strict-global-this.js
│ ├── test-dev-assign-trivial-loop.js
│ ├── test-dev-exec-timeout-tailcall.js
│ ├── test-dev-valstack-shrink-check-1.js
│ ├── test-lex-line-continuation.js
│ ├── test-regexp-charclass-invalid-order.js
│ ├── test-bi-math-exp.js
│ ├── test-bi-promise-constructor-try-success.js
│ ├── test-bug-json-dec-num.js
│ ├── test-dev-implicit-return-value-1.js
│ ├── test-bi-cbor-dec-empty.js
│ ├── test-expr-newtarget-lhs.js
│ ├── test-misc-numeric-property-access.js
│ ├── test-misc-zerosign.js
│ ├── test-stmt-dowhile-bug.js
│ ├── test-bi-cbor-dec-64bit-tag.js
│ ├── test-bi-duktape-enc-jx.js
│ ├── test-bi-global-parseint-leadzero.js
│ ├── test-bug-coroutine-yield-refzero-2-gh2204.js
│ ├── test-bug-dowhile-infloop.js
│ └── test-dev-number-whitespace.js
├── lodash
│ └── basic.js
├── api
│ ├── test-bug-is-constructor-call-empty-callstack.c
│ ├── test-hello-world.c
│ ├── test-bug-push-buffer-semicolon.c
│ ├── test-concat.c
│ └── test-join.c
├── emscripten
│ ├── helloworld.c
│ └── fmod.c
├── memory
│ ├── test-uint8array-1.js
│ ├── test-function-expression-1.js
│ ├── test-plain-buffer-1.js
│ └── test-function-expression-2.js
└── google-v8-benchmark-v7
│ └── README.rst
├── config
├── header-snippets
│ ├── architecture_fillins.h.in
│ ├── cpp_exception_sanity.h.in
│ ├── platform_conditionalincludes.h.in
│ └── reject_fast_math.h.in
├── examples
│ ├── enable_fastint.yaml
│ ├── enable_debug_print0.yaml
│ ├── enable_debug_print1.yaml
│ ├── enable_debug_print2.yaml
│ ├── disable_es6.yaml
│ ├── disable_bufferobjects.yaml
│ └── timing_sensitive.yaml
├── helper-snippets
│ ├── DUK_F_QNX.h.in
│ ├── DUK_F_VBCC.h.in
│ ├── DUK_F_CLANG.h.in
│ ├── DUK_F_POSIX.h.in
│ ├── DUK_F_CYGWIN.h.in
│ ├── DUK_F_MINT.h.in
│ ├── DUK_F_UCLIBC.h.in
│ ├── DUK_F_ANDROID.h.in
│ ├── DUK_F_CPP.h.in
│ ├── DUK_F_NETBSD.h.in
│ ├── DUK_F_TINSPIRE.h.in
│ ├── DUK_F_FREEBSD.h.in
│ ├── DUK_F_OPENBSD.h.in
│ ├── DUK_F_APPLE.h.in
│ ├── DUK_F_DURANGO.h.in
│ ├── DUK_F_LINUX.h.in
│ ├── DUK_F_ORBIS.h.in
│ ├── DUK_F_FLASHPLAYER.h.in
│ ├── DUK_F_TINYC.h.in
│ ├── DUK_F_AIX.h.in
│ ├── DUK_F_HPUX.h.in
│ ├── DUK_F_C99.h.in
│ ├── DUK_F_CPP11.h.in
│ ├── DUK_F_EMSCRIPTEN.h.in
│ ├── DUK_F_MINGW.h.in
│ ├── DUK_F_BCC.h.in
│ ├── DUK_F_BSD.h.in
│ ├── DUK_F_UNIX.h.in
│ ├── DUK_F_M68K.h.in
│ ├── DUK_F_TOS.h.in
│ ├── DUK_F_AMIGAOS.h.in
│ ├── DUK_F_SPARC.h.in
│ ├── DUK_F_PPC.h.in
│ ├── DUK_F_SUPERH.h.in
│ └── DUK_F_WINDOWS.h.in
├── architectures
│ ├── architecture_riscv32.h.in
│ ├── architecture_riscv64.h.in
│ ├── architecture_arm32.h.in
│ ├── architecture_arm64.h.in
│ ├── architecture_superh.h.in
│ ├── architecture_mips32.h.in
│ ├── architecture_mips64.h.in
│ ├── architecture_sparc32.h.in
│ ├── architecture_sparc64.h.in
│ ├── architecture_m68k.h.in
│ ├── architecture_powerpc64.h.in
│ ├── architecture_x32.h.in
│ ├── architecture_x64.h.in
│ ├── architecture_powerpc32.h.in
│ ├── architecture_emscripten.h.in
│ └── architecture_generic.h.in
├── feature-options
│ ├── DUK_OPT_PANIC_HANDLER.yaml
│ ├── DUK_OPT_DPRINT.yaml
│ ├── DUK_OPT_DDPRINT.yaml
│ ├── DUK_OPT_DPRINT_RDTSC.yaml
│ ├── DUK_OPT_BUFLEN16.yaml
│ ├── DUK_OPT_STRHASH16.yaml
│ ├── DUK_OPT_STRLEN16.yaml
│ ├── DUK_OPT_TRACEBACK_DEPTH.yaml
│ ├── DUK_OPT_REFCOUNT16.yaml
│ ├── DUK_OPT_NO_COMMONJS_MODULES.yaml
│ ├── DUK_OPT_NO_JSONC.yaml
│ ├── DUK_OPT_NO_JSONX.yaml
│ ├── DUK_OPT_NO_ES6_PROXY.yaml
│ ├── DUK_OPT_NO_BYTECODE_DUMP_SUPPORT.yaml
│ ├── DUK_OPT_STRTAB_CHAIN_SIZE.yaml
│ ├── DUK_OPT_ASSERTIONS.yaml
│ ├── DUK_OPT_DEBUG.yaml
│ ├── DUK_OPT_NO_JC.yaml
│ ├── DUK_OPT_NO_JX.yaml
│ ├── DUK_OPT_DDDPRINT.yaml
│ ├── DUK_OPT_NO_FUNC_STMT.yaml
│ ├── DUK_OPT_NO_OCTAL_SUPPORT.yaml
│ ├── DUK_OPT_GC_TORTURE.yaml
│ ├── DUK_OPT_NO_ES6_OBJECT_SETPROTOTYPEOF.yaml
│ ├── DUK_OPT_NO_ES6_OBJECT_PROTO_PROPERTY.yaml
│ ├── DUK_OPT_NO_SOURCE_NONBMP.yaml
│ ├── DUK_OPT_DEBUGGER_FWD_PRINTALERT.yaml
│ ├── DUK_OPT_DPRINT_COLORS.yaml
│ ├── DUK_OPT_NO_ZERO_BUFFER_DATA.yaml
│ ├── DUK_OPT_FUNC_NONSTD_CALLER_PROPERTY.yaml
│ ├── DUK_OPT_FUNC_NONSTD_SOURCE_PROPERTY.yaml
│ ├── DUK_OPT_NO_STRICT_DECL.yaml
│ ├── DUK_OPT_JSON_STRINGIFY_FASTPATH.yaml
│ ├── DUK_OPT_SIGSETJMP.yaml
│ ├── DUK_OPT_NO_ARRAY_SPLICE_NONSTD_DELCOUNT.yaml
│ ├── DUK_OPT_NO_VERBOSE_ERRORS.yaml
│ ├── DUK_OPT_FORCE_ALIGN.yaml
│ ├── DUK_OPT_LIGHTFUNC_BUILTINS.yaml
│ ├── DUK_OPT_NO_OBJECT_ES6_PROTO_PROPERTY.yaml
│ ├── DUK_OPT_NO_OBJECT_ES6_SETPROTOTYPEOF.yaml
│ ├── DUK_OPT_SELF_TESTS.yaml
│ ├── DUK_OPT_NO_NONSTD_ACCESSOR_KEY_ARGUMENT.yaml
│ ├── DUK_OPT_SEGFAULT_ON_PANIC.yaml
│ ├── DUK_OPT_SHUFFLE_TORTURE.yaml
│ ├── DUK_OPT_TARGET_INFO.yaml
│ ├── DUK_OPT_NO_BUFFEROBJECT_SUPPORT.yaml
│ ├── DUK_OPT_NO_PACKED_TVAL.yaml
│ ├── DUK_OPT_NO_SECTION_B.yaml
│ ├── DUK_OPT_NO_TRACEBACKS.yaml
│ ├── DUK_OPT_BUFFEROBJECT_SUPPORT.yaml
│ ├── DUK_OPT_NO_BROWSER_LIKE.yaml
│ └── DUK_OPT_NO_REFERENCE_COUNTING.yaml
├── config-options
│ ├── DUK_USE_ARRAY_BUILTIN.yaml
│ ├── DUK_USE_DATE_BUILTIN.yaml
│ ├── DUK_USE_JC.yaml
│ ├── DUK_USE_JSON_BUILTIN.yaml
│ ├── DUK_USE_JX.yaml
│ ├── DUK_USE_MATH_BUILTIN.yaml
│ ├── DUK_USE_BOOLEAN_BUILTIN.yaml
│ ├── DUK_USE_DUKTAPE_BUILTIN.yaml
│ ├── DUK_USE_HEX_SUPPORT.yaml
│ ├── DUK_USE_NUMBER_BUILTIN.yaml
│ ├── DUK_USE_OBJECT_BUILTIN.yaml
│ ├── DUK_USE_STRING_BUILTIN.yaml
│ ├── DUK_USE_FUNCTION_BUILTIN.yaml
│ ├── DUK_USE_BASE64_SUPPORT.yaml
│ ├── DUK_USE_ES6_PROXY.yaml
│ ├── DUK_USE_HTML_COMMENTS.yaml
│ ├── DUK_USE_REFERENCE_COUNTING.yaml
│ ├── DUK_USE_32BIT_PTRS.yaml
│ ├── DUK_USE_ES6.yaml
│ ├── DUK_USE_ES7.yaml
│ ├── DUK_USE_ES8.yaml
│ ├── DUK_USE_ES9.yaml
│ ├── DUK_USE_EXEC_PREFER_SIZE.yaml
│ ├── DUK_USE_PACK_GCC_ATTR.yaml
│ ├── DUK_USE_PACK_CLANG_ATTR.yaml
│ ├── DUK_USE_PACK_DUMMY_MEMBER.yaml
│ ├── DUK_USE_PACK_MSVC_PRAGMA.yaml
│ ├── DUK_USE_COROUTINE_SUPPORT.yaml
│ ├── DUK_USE_DATE_NOW_WINDOWS.yaml
│ ├── DUK_USE_DDPRINT.yaml
│ ├── DUK_USE_DPRINT_RDTSC.yaml
│ ├── DUK_USE_ESBC_LIMITS.yaml
│ ├── DUK_USE_FINALIZER_SUPPORT.yaml
│ ├── DUK_USE_RDTSC.yaml
│ ├── DUK_USE_BYTECODE_DUMP_SUPPORT.yaml
│ ├── DUK_USE_ES6_REGEXP_BRACES.yaml
│ ├── DUK_USE_PANIC_ABORT.yaml
│ ├── DUK_USE_PANIC_EXIT.yaml
│ ├── DUK_USE_BUFLEN16.yaml
│ ├── DUK_USE_STRHASH16.yaml
│ ├── DUK_USE_STRLEN16.yaml
│ ├── DUK_USE_BROWSER_LIKE.yaml
│ ├── DUK_USE_CBOR_DEC_RECLIMIT.yaml
│ ├── DUK_USE_CBOR_ENC_RECLIMIT.yaml
│ ├── DUK_USE_DATE_TZO_GMTIME_S.yaml
│ ├── DUK_USE_ERRCREATE.yaml
│ ├── DUK_USE_JSON_DEC_RECLIMIT.yaml
│ ├── DUK_USE_COMPILER_RECLIMIT.yaml
│ ├── DUK_USE_DATE_TZO_WINDOWS.yaml
│ ├── DUK_USE_ERRTHROW.yaml
│ ├── DUK_USE_ALIGN_BY.yaml
│ ├── DUK_USE_ES6_OBJECT_SETPROTOTYPEOF.yaml
│ ├── DUK_USE_STRTAB_PROBE.yaml
│ ├── DUK_USE_ES6_OBJECT_PROTO_PROPERTY.yaml
│ ├── DUK_USE_GCC_PRAGMAS.yaml
│ ├── DUK_USE_GET_MONOTONIC_TIME_WINDOWS_QPC.yaml
│ ├── DUK_USE_GLOBAL_BINDING.yaml
│ ├── DUK_USE_INJECT_HEAP_ALLOC_ERROR.yaml
│ ├── DUK_USE_PERFORMANCE_BUILTIN.yaml
│ ├── DUK_USE_REGEXP_COMPILER_RECLIMIT.yaml
│ ├── DUK_USE_REGEXP_EXECUTOR_RECLIMIT.yaml
│ ├── DUK_USE_CLANG_PRAGMAS.yaml
│ ├── DUK_USE_FUZZILLI.yaml
│ ├── DUK_USE_PACKED_TVAL_POSSIBLE.yaml
│ ├── DUK_USE_REFCOUNT16.yaml
│ ├── DUK_USE_SHEBANG_COMMENTS.yaml
│ ├── DUK_USE_AUGMENT_ERROR_THROW.yaml
│ ├── DUK_USE_DPRINT.yaml
│ ├── DUK_USE_ES6_UNICODE_ESCAPE.yaml
│ ├── DUK_USE_CBOR_BUILTIN.yaml
│ ├── DUK_USE_DEBUG_LEVEL.yaml
│ ├── DUK_USE_ESBC_MAX_BYTES.yaml
│ ├── DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE.yaml
│ ├── DUK_USE_DATE_PRS_STRPTIME.yaml
│ ├── DUK_USE_ESBC_MAX_LINENUMBER.yaml
│ ├── DUK_USE_ASSERTIONS.yaml
│ ├── DUK_USE_DATE_PARSE_STRING.yaml
│ ├── DUK_USE_FATAL_MAXLEN.yaml
│ ├── DUK_USE_GET_MONOTONIC_TIME_CLOCK_GETTIME.yaml
│ ├── DUK_USE_HASHBYTES_UNALIGNED_U32_ACCESS.yaml
│ ├── DUK_USE_ARCH_STRING.yaml
│ ├── DUK_USE_BRANCH_HINTS.yaml
│ ├── DUK_USE_DATE_FORMAT_STRING.yaml
│ ├── DUK_USE_HOBJECT_ARRAY_MINGROW_ADD.yaml
│ ├── DUK_USE_OS_STRING.yaml
│ ├── DUK_USE_STRTAB_CHAIN_SIZE.yaml
│ ├── DUK_USE_STRTAB_MINSIZE.yaml
│ ├── DUK_USE_COMPILER_STRING.yaml
│ ├── DUK_USE_DDDPRINT.yaml
│ ├── DUK_USE_HOBJECT_ENTRY_MINGROW_ADD.yaml
│ ├── DUK_USE_HOBJECT_ENTRY_MINGROW_DIVISOR.yaml
│ ├── DUK_USE_AUGMENT_ERROR_CREATE.yaml
│ ├── DUK_USE_DATE_GET_LOCAL_TZOFFSET.yaml
│ ├── DUK_USE_HOBJECT_ARRAY_MINGROW_DIVISOR.yaml
│ ├── DUK_USE_HOBJECT_LAYOUT_2.yaml
│ ├── DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS.yaml
│ ├── DUK_USE_ATAN2_WORKAROUNDS.yaml
│ ├── DUK_USE_FUNC_FILENAME_PROPERTY.yaml
│ ├── DUK_USE_PARANOID_MATH.yaml
│ ├── DUK_USE_PROMISE_BUILTIN.yaml
│ ├── DUK_USE_SYMBOL_BUILTIN.yaml
│ ├── DUK_USE_FLEX_C99.yaml
│ ├── DUK_USE_REFLECT_BUILTIN.yaml
│ ├── DUK_USE_ALIGN_4.yaml
│ ├── DUK_USE_ALIGN_8.yaml
│ ├── DUK_USE_DATE_NOW_GETTIMEOFDAY.yaml
│ ├── DUK_USE_DEBUG.yaml
│ ├── DUK_USE_HEX_FASTPATH.yaml
│ ├── DUK_USE_DATE_TZO_GMTIME_R.yaml
│ ├── DUK_USE_64BIT_OPS.yaml
│ ├── DUK_USE_BASE64_FASTPATH.yaml
│ ├── DUK_USE_CBOR_SUPPORT.yaml
│ ├── DUK_USE_DATE_TZO_WINDOWS_NO_DST.yaml
│ ├── DUK_USE_DOUBLE_BE.yaml
│ ├── DUK_USE_DOUBLE_LE.yaml
│ ├── DUK_USE_INTEGER_BE.yaml
│ ├── DUK_USE_INTEGER_LE.yaml
│ ├── DUK_USE_UNALIGNED_ACCESSES_POSSIBLE.yaml
│ ├── DUK_USE_BYTEORDER_FORCED.yaml
│ ├── DUK_USE_DATE_NOW_WINDOWS_SUBMS.yaml
│ ├── DUK_USE_STRTAB_TORTURE.yaml
│ ├── DUK_USE_CACHE_CATCHER.yaml
│ ├── DUK_USE_IDCHAR_FASTPATH.yaml
│ ├── DUK_USE_JSON_DECSTRING_FASTPATH.yaml
│ ├── DUK_USE_JSON_EATWHITE_FASTPATH.yaml
│ ├── DUK_USE_DPRINT_COLORS.yaml
│ ├── DUK_USE_JSON_DECNUMBER_FASTPATH.yaml
│ ├── DUK_USE_VERBOSE_EXECUTOR_ERRORS.yaml
│ ├── DUK_USE_CACHE_ACTIVATION.yaml
│ ├── DUK_USE_FILE_IO.yaml
│ ├── DUK_USE_JSON_QUOTESTRING_FASTPATH.yaml
│ ├── DUK_USE_LIGHTFUNC_BUILTINS.yaml
│ ├── DUK_USE_FAST_REFCOUNT_DEFAULT.yaml
│ ├── DUK_USE_GLOBAL_BUILTIN.yaml
│ ├── DUK_USE_MARK_AND_SWEEP_RECLIMIT.yaml
│ ├── DUK_USE_DATE_NOW_TIME.yaml
│ ├── DUK_USE_ES7_EXP_OPERATOR.yaml
│ ├── DUK_USE_POW_WORKAROUNDS.yaml
│ ├── DUK_USE_PREFER_SIZE.yaml
│ ├── DUK_USE_DATE_FMT_STRFTIME.yaml
│ ├── DUK_USE_FINALIZER_TORTURE.yaml
│ ├── DUK_USE_VERBOSE_ERRORS.yaml
│ ├── DUK_USE_CPP_EXCEPTIONS.yaml
│ ├── DUK_USE_JSON_ENC_RECLIMIT.yaml
│ ├── DUK_USE_SELF_TESTS.yaml
│ ├── DUK_USE_DATE_TZO_GMTIME.yaml
│ ├── DUK_USE_FUNC_NAME_PROPERTY.yaml
│ ├── DUK_USE_OCTAL_SUPPORT.yaml
│ ├── DUK_USE_PANIC_SEGFAULT.yaml
│ ├── DUK_USE_REPL_ISINF.yaml
│ ├── DUK_USE_REPL_ISNAN.yaml
│ └── DUK_USE_SECTION_B.yaml
└── platforms
│ ├── platform_genericunix.h.in
│ ├── platform_posix.h.in
│ ├── platform_genericbsd.h.in
│ ├── platform_aix.h.in
│ └── platform_orbis.h.in
├── website
├── robots.txt
├── bg-c-2.png
├── bg-c.png
├── favicon.ico
├── favicon.png
├── bg-ecmascript.png
├── bg-ecmascript-2.png
├── startup_image_320x480.png
├── logo
│ ├── duktape-logo-125x83.png
│ ├── duktape-logo-125x88.png
│ ├── duktape-logo-125x88.xcf
│ ├── duktape-logo-300x200.png
│ ├── duktape-logo-600x400.png
│ └── duktape-logo-900x600.png
├── api
│ ├── no-production-dump-calls.html
│ ├── no-string-intern.html
│ ├── ref-custom-type-coercion.html
│ ├── path-encoding.html
│ ├── string-non-null-zero-length.html
│ ├── duk_push_null.yaml
│ └── duk_push_undefined.yaml
├── touch-icon
│ ├── touch_icon_57x57.png
│ ├── touch_icon_60x60.png
│ ├── touch_icon_72x72.png
│ ├── touch_icon_1024x1024.png
│ ├── touch_icon_114x114.png
│ ├── touch_icon_120x120.png
│ ├── touch_icon_144x144.png
│ └── touch_icon_152x152.png
└── resizeicons.sh
├── util
├── emduk_wrapper.sh
├── dukweb_fixup.h
├── remove_math_properties.yaml
├── makeduk_scanbuild.yaml
├── dukweb_base.yaml
├── README.rst
├── check_align.sh
├── example_user_builtins2.yaml
└── make_ascii.py
├── licenses
├── lua.txt
├── commonjs.txt
├── splitmix64.txt
└── xoroshiro128plus.txt
├── examples
├── coffee
│ ├── hello.coffee
│ ├── globals.coffee
│ └── README.rst
├── eval
│ └── README.rst
├── sandbox
│ └── README.rst
├── hello
│ └── README.rst
├── guide
│ ├── README.rst
│ └── fib.js
├── jxpretty
│ └── README.rst
├── eventloop
│ └── c_eventloop.h
├── dummy-date-provider
│ └── README.rst
├── cmdline
│ └── README.rst
├── alloc-logging
│ └── README.rst
├── codepage-conv
│ ├── duk_codepage_conv.h
│ └── README.rst
└── README.rst
├── src-input
├── SpecialCasing-8bit.txt
├── duk_api_random.c
├── duk_bi_thrower.c
├── duk_hbuffer_assert.c
└── duk_hstring_assert.c
├── src-tools
├── .eslintignore
├── index.js
└── lib
│ └── util
│ ├── xml.js
│ ├── exec.js
│ ├── assert.js
│ ├── engine_detect.js
│ └── json.js
├── references
├── commonjs_modules_1.0.pdf
├── commonjs_modules_1.1.pdf
└── commonjs_modules_1.1.1.pdf
├── extras
├── duk-v1-compat
│ ├── test_compile2.js
│ ├── test_compile1.js
│ ├── test_eval1.js
│ └── test_eval2.js
├── alloc-pool
│ └── ptrcomp_fixup.h
└── minimal-printf
│ └── Makefile
├── tools
├── yaml2json.py
└── json2yaml.py
├── debugger
└── duk_debugerrors.yaml
├── dist-files
├── Makefile.coffee
├── Makefile.codepage
├── Makefile.eval
├── Makefile.sandbox
├── Makefile.jxpretty
└── Makefile.jsoncbor
├── docker
├── duktape-shell-ubuntu-18.04-x64
│ ├── Dockerfile
│ └── run.sh
├── duktape-shell-ubuntu-20.04-x64
│ ├── Dockerfile
│ └── run.sh
├── duktape-release-1-ubuntu-18.04-x64
│ └── Dockerfile
├── duktape-release-1-ubuntu-20.04-x64
│ └── Dockerfile
├── duktape-shell-ubuntu-18.04-s390x
│ ├── Dockerfile
│ └── run.sh
├── duktape-shell-ubuntu-20.04-arm64
│ ├── Dockerfile
│ └── run.sh
├── duktape-release-1-ubuntu-20.04-arm64
│ └── Dockerfile
├── duktape-make-ubuntu-18.04-x64
│ ├── run.sh
│ └── Dockerfile
├── duktape-make-ubuntu-20.04-x64
│ ├── run.sh
│ └── Dockerfile
├── duktape-make-ubuntu-20.04-arm64
│ ├── run.sh
│ └── Dockerfile
└── duktape-clang-format
│ └── run.sh
├── .gitattributes
├── testrunner
└── README.rst
├── misc
├── tcc_zerosign2.c
├── chaos.py
├── preproc_compare1.c
├── preproc_compare2.c
├── preproc_compare3.c
└── preproc_compare4.c
└── RELEASES.rst
/tests/octane/mujs_tweaks.js:
--------------------------------------------------------------------------------
1 | var alert;
2 |
--------------------------------------------------------------------------------
/config/header-snippets/architecture_fillins.h.in:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/website/robots.txt:
--------------------------------------------------------------------------------
1 | User-Agent: *
2 | Disallow:
3 |
--------------------------------------------------------------------------------
/tests/perf/test-hello-world.py:
--------------------------------------------------------------------------------
1 | print('Hello world!')
2 |
--------------------------------------------------------------------------------
/tests/perf/test-hello-world.pl:
--------------------------------------------------------------------------------
1 | print("Hello world!\n");
2 |
--------------------------------------------------------------------------------
/tests/perf/test-hello-world.rb:
--------------------------------------------------------------------------------
1 | print("Hello world!\n");
2 |
--------------------------------------------------------------------------------
/util/emduk_wrapper.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | node WORKDIR/emduk.js "$@"
3 |
--------------------------------------------------------------------------------
/licenses/lua.txt:
--------------------------------------------------------------------------------
1 | Lua is under the MIT license: http://www.lua.org/license.html.
2 |
--------------------------------------------------------------------------------
/website/bg-c-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/bg-c-2.png
--------------------------------------------------------------------------------
/website/bg-c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/bg-c.png
--------------------------------------------------------------------------------
/examples/coffee/hello.coffee:
--------------------------------------------------------------------------------
1 | print 'Hello world!'
2 | print 'version: ' + Duktape.version
3 |
--------------------------------------------------------------------------------
/website/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/favicon.ico
--------------------------------------------------------------------------------
/website/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/favicon.png
--------------------------------------------------------------------------------
/config/examples/enable_fastint.yaml:
--------------------------------------------------------------------------------
1 | # Enable fastint support.
2 |
3 | DUK_USE_FASTINT: true
4 |
--------------------------------------------------------------------------------
/src-input/SpecialCasing-8bit.txt:
--------------------------------------------------------------------------------
1 | 00DF; 00DF; 0053 0073; 0053 0053; # LATIN SMALL LETTER SHARP S
2 |
--------------------------------------------------------------------------------
/website/bg-ecmascript.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/bg-ecmascript.png
--------------------------------------------------------------------------------
/src-tools/.eslintignore:
--------------------------------------------------------------------------------
1 | /node_modules/
2 | /duktool.js
3 | /from-xml/
4 | /js-yaml/
5 | /lib/extdeps/
6 |
--------------------------------------------------------------------------------
/tests/perf/test-hello-world.lua:
--------------------------------------------------------------------------------
1 | -- Hello world test for memory testing.
2 |
3 | print('hello world!')
4 |
--------------------------------------------------------------------------------
/website/bg-ecmascript-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/bg-ecmascript-2.png
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_QNX.h.in:
--------------------------------------------------------------------------------
1 | /* QNX */
2 | #if defined(__QNX__)
3 | #define DUK_F_QNX
4 | #endif
5 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_VBCC.h.in:
--------------------------------------------------------------------------------
1 | /* VBCC */
2 | #if defined(__VBCC__)
3 | #define DUK_F_VBCC
4 | #endif
5 |
--------------------------------------------------------------------------------
/src-tools/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { main } = require('./lib/duktool/main');
4 |
5 | main();
6 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_CLANG.h.in:
--------------------------------------------------------------------------------
1 | /* Clang */
2 | #if defined(__clang__)
3 | #define DUK_F_CLANG
4 | #endif
5 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_POSIX.h.in:
--------------------------------------------------------------------------------
1 | /* POSIX */
2 | #if defined(__posix)
3 | #define DUK_F_POSIX
4 | #endif
5 |
--------------------------------------------------------------------------------
/tests/jsinterpreter/addition.js:
--------------------------------------------------------------------------------
1 | var interp = new Interpreter('1+2+3');
2 | interp.run();
3 | print(interp.value);
4 |
--------------------------------------------------------------------------------
/tests/perf/test-empty-loop.py:
--------------------------------------------------------------------------------
1 | def test():
2 | i = 0
3 | while i < 1e8:
4 | i += 1
5 |
6 | test()
7 |
--------------------------------------------------------------------------------
/website/startup_image_320x480.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/startup_image_320x480.png
--------------------------------------------------------------------------------
/config/examples/enable_debug_print0.yaml:
--------------------------------------------------------------------------------
1 | # Enable debug level 0.
2 | DUK_USE_DEBUG: true
3 | DUK_USE_DEBUG_LEVEL: 0
4 |
--------------------------------------------------------------------------------
/config/examples/enable_debug_print1.yaml:
--------------------------------------------------------------------------------
1 | # Enable debug level 1.
2 | DUK_USE_DEBUG: true
3 | DUK_USE_DEBUG_LEVEL: 1
4 |
--------------------------------------------------------------------------------
/config/examples/enable_debug_print2.yaml:
--------------------------------------------------------------------------------
1 | # Enable debug level 2.
2 | DUK_USE_DEBUG: true
3 | DUK_USE_DEBUG_LEVEL: 2
4 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_CYGWIN.h.in:
--------------------------------------------------------------------------------
1 | /* Cygwin */
2 | #if defined(__CYGWIN__)
3 | #define DUK_F_CYGWIN
4 | #endif
5 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_MINT.h.in:
--------------------------------------------------------------------------------
1 | /* Atari Mint */
2 | #if defined(__MINT__)
3 | #define DUK_F_MINT
4 | #endif
5 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_UCLIBC.h.in:
--------------------------------------------------------------------------------
1 | /* uclibc */
2 | #if defined(__UCLIBC__)
3 | #define DUK_F_UCLIBC
4 | #endif
5 |
--------------------------------------------------------------------------------
/references/commonjs_modules_1.0.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/references/commonjs_modules_1.0.pdf
--------------------------------------------------------------------------------
/references/commonjs_modules_1.1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/references/commonjs_modules_1.1.pdf
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_ANDROID.h.in:
--------------------------------------------------------------------------------
1 | #if defined(ANDROID) || defined(__ANDROID__)
2 | #define DUK_F_ANDROID
3 | #endif
4 |
--------------------------------------------------------------------------------
/examples/eval/README.rst:
--------------------------------------------------------------------------------
1 | ============
2 | Eval example
3 | ============
4 |
5 | Evaluate expressions from command line.
6 |
--------------------------------------------------------------------------------
/extras/duk-v1-compat/test_compile2.js:
--------------------------------------------------------------------------------
1 | // File to compile, syntax error
2 | print('Hello from test_compile2.js');
3 | = y +;
4 |
--------------------------------------------------------------------------------
/references/commonjs_modules_1.1.1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/references/commonjs_modules_1.1.1.pdf
--------------------------------------------------------------------------------
/website/logo/duktape-logo-125x83.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/logo/duktape-logo-125x83.png
--------------------------------------------------------------------------------
/website/logo/duktape-logo-125x88.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/logo/duktape-logo-125x88.png
--------------------------------------------------------------------------------
/website/logo/duktape-logo-125x88.xcf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/logo/duktape-logo-125x88.xcf
--------------------------------------------------------------------------------
/website/logo/duktape-logo-300x200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/logo/duktape-logo-300x200.png
--------------------------------------------------------------------------------
/website/logo/duktape-logo-600x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/logo/duktape-logo-600x400.png
--------------------------------------------------------------------------------
/website/logo/duktape-logo-900x600.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/logo/duktape-logo-900x600.png
--------------------------------------------------------------------------------
/website/api/no-production-dump-calls.html:
--------------------------------------------------------------------------------
1 |
2 | You should not leave dump calls in production code.
3 |
4 |
--------------------------------------------------------------------------------
/website/touch-icon/touch_icon_57x57.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/touch-icon/touch_icon_57x57.png
--------------------------------------------------------------------------------
/website/touch-icon/touch_icon_60x60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/touch-icon/touch_icon_60x60.png
--------------------------------------------------------------------------------
/website/touch-icon/touch_icon_72x72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/touch-icon/touch_icon_72x72.png
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_CPP.h.in:
--------------------------------------------------------------------------------
1 | /* C++ */
2 | #undef DUK_F_CPP
3 | #if defined(__cplusplus)
4 | #define DUK_F_CPP
5 | #endif
6 |
--------------------------------------------------------------------------------
/examples/sandbox/README.rst:
--------------------------------------------------------------------------------
1 | ===============
2 | Sandbox example
3 | ===============
4 |
5 | Very simple, minimal sandboxing example.
6 |
--------------------------------------------------------------------------------
/tests/perf/test-empty-loop.pl:
--------------------------------------------------------------------------------
1 | sub test {
2 | my $i;
3 |
4 | for ($i = 0; $i < 1e8; $i++) {
5 | }
6 | }
7 |
8 | test();
9 |
--------------------------------------------------------------------------------
/tests/perf/test-empty-loop.rb:
--------------------------------------------------------------------------------
1 | def test()
2 | i = 0
3 | while i < 1e8 do
4 | i += 1
5 | end
6 | end
7 |
8 | test()
9 |
--------------------------------------------------------------------------------
/tools/yaml2json.py:
--------------------------------------------------------------------------------
1 | import os, sys, json, yaml
2 |
3 | if __name__ == '__main__':
4 | print(json.dumps(yaml.safe_load(sys.stdin)))
5 |
--------------------------------------------------------------------------------
/website/touch-icon/touch_icon_1024x1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/touch-icon/touch_icon_1024x1024.png
--------------------------------------------------------------------------------
/website/touch-icon/touch_icon_114x114.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/touch-icon/touch_icon_114x114.png
--------------------------------------------------------------------------------
/website/touch-icon/touch_icon_120x120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/touch-icon/touch_icon_120x120.png
--------------------------------------------------------------------------------
/website/touch-icon/touch_icon_144x144.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/touch-icon/touch_icon_144x144.png
--------------------------------------------------------------------------------
/website/touch-icon/touch_icon_152x152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ailisp/duktape/master/website/touch-icon/touch_icon_152x152.png
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_NETBSD.h.in:
--------------------------------------------------------------------------------
1 | /* NetBSD */
2 | #if defined(__NetBSD__) || defined(__NetBSD)
3 | #define DUK_F_NETBSD
4 | #endif
5 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_TINSPIRE.h.in:
--------------------------------------------------------------------------------
1 | /* TI-Nspire (using Ndless) */
2 | #if defined(_TINSPIRE)
3 | #define DUK_F_TINSPIRE
4 | #endif
5 |
--------------------------------------------------------------------------------
/extras/alloc-pool/ptrcomp_fixup.h:
--------------------------------------------------------------------------------
1 | /* To provide declarations for inline pointer compression functions. */
2 | #include "duk_alloc_pool.h"
3 |
--------------------------------------------------------------------------------
/tests/knownissues/test-dev-lightfunc-finalizer-1.txt:
--------------------------------------------------------------------------------
1 | summary: requires DUK_USE_LIGHTFUNC_BUILTINS
2 | ---
3 | false
4 | lfunc finalizer
5 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_FREEBSD.h.in:
--------------------------------------------------------------------------------
1 | /* FreeBSD */
2 | #if defined(__FreeBSD__) || defined(__FreeBSD)
3 | #define DUK_F_FREEBSD
4 | #endif
5 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_OPENBSD.h.in:
--------------------------------------------------------------------------------
1 | /* OpenBSD */
2 | #if defined(__OpenBSD__) || defined(__OpenBSD)
3 | #define DUK_F_OPENBSD
4 | #endif
5 |
--------------------------------------------------------------------------------
/debugger/duk_debugerrors.yaml:
--------------------------------------------------------------------------------
1 | error_codes:
2 | - Unknown
3 | - UnsupportedCommand
4 | - TooMany
5 | - NotFound
6 | - ApplicationError
7 |
--------------------------------------------------------------------------------
/tests/knownissues/test-bi-proxy-object-tostring-1.txt:
--------------------------------------------------------------------------------
1 | summary: Object class handling for Proxy objects is incomplete
2 | ---
3 | [object Object]
4 |
--------------------------------------------------------------------------------
/config/architectures/architecture_riscv32.h.in:
--------------------------------------------------------------------------------
1 | #define DUK_USE_ARCH_STRING "riscv32"
2 | #define DUK_USE_BYTEORDER 1
3 | #define DUK_USE_PACKED_TVAL
4 |
--------------------------------------------------------------------------------
/config/architectures/architecture_riscv64.h.in:
--------------------------------------------------------------------------------
1 | #define DUK_USE_ARCH_STRING "riscv64"
2 | #define DUK_USE_BYTEORDER 1
3 | #undef DUK_USE_PACKED_TVAL
4 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_APPLE.h.in:
--------------------------------------------------------------------------------
1 | /* Apple macOS, iOS, watchOS, tvOS, Darwin, etc */
2 | #if defined(__APPLE__)
3 | #define DUK_F_APPLE
4 | #endif
5 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_DURANGO.h.in:
--------------------------------------------------------------------------------
1 | /* Durango (Xbox One) */
2 | #if defined(_DURANGO) || defined(_XBOX_ONE)
3 | #define DUK_F_DURANGO
4 | #endif
5 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_LINUX.h.in:
--------------------------------------------------------------------------------
1 | /* Linux */
2 | #if defined(__linux) || defined(__linux__) || defined(linux)
3 | #define DUK_F_LINUX
4 | #endif
5 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_ORBIS.h.in:
--------------------------------------------------------------------------------
1 | /* Orbis (PS4) variant */
2 | #if defined(DUK_F_FREEBSD) && defined(__ORBIS__)
3 | #define DUK_F_ORBIS
4 | #endif
5 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_FLASHPLAYER.h.in:
--------------------------------------------------------------------------------
1 | /* Flash player (e.g. Crossbridge) */
2 | #if defined(__FLASHPLAYER__)
3 | #define DUK_F_FLASHPLAYER
4 | #endif
5 |
--------------------------------------------------------------------------------
/examples/hello/README.rst:
--------------------------------------------------------------------------------
1 | ===================
2 | Hello world example
3 | ===================
4 |
5 | Very simple example, most useful for compilation tests.
6 |
--------------------------------------------------------------------------------
/tests/perf/test-empty-loop.lua:
--------------------------------------------------------------------------------
1 | local function test()
2 | local i = 0
3 | while i < 1e8 do i = i + 1 end
4 | --for i=1,1e8 do end
5 | end
6 | test()
7 |
--------------------------------------------------------------------------------
/tests/perf/test-fib.py:
--------------------------------------------------------------------------------
1 | def fib(n):
2 | if n <= 1:
3 | return n
4 | else:
5 | return fib(n - 2) + fib(n - 1)
6 |
7 | print(fib(35))
8 |
--------------------------------------------------------------------------------
/config/architectures/architecture_arm32.h.in:
--------------------------------------------------------------------------------
1 | #define DUK_USE_ARCH_STRING "arm32"
2 | /* Byte order varies, so rely on autodetect. */
3 | #define DUK_USE_PACKED_TVAL
4 |
--------------------------------------------------------------------------------
/config/architectures/architecture_arm64.h.in:
--------------------------------------------------------------------------------
1 | #define DUK_USE_ARCH_STRING "arm64"
2 | /* Byte order varies, so rely on autodetect. */
3 | #undef DUK_USE_PACKED_TVAL
4 |
--------------------------------------------------------------------------------
/config/architectures/architecture_superh.h.in:
--------------------------------------------------------------------------------
1 | #define DUK_USE_ARCH_STRING "sh"
2 | /* Byte order varies, rely on autodetection. */
3 | #define DUK_USE_PACKED_TVAL
4 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_TINYC.h.in:
--------------------------------------------------------------------------------
1 | /* TinyC */
2 | #if defined(__TINYC__)
3 | /* http://bellard.org/tcc/tcc-doc.html#SEC9 */
4 | #define DUK_F_TINYC
5 | #endif
6 |
--------------------------------------------------------------------------------
/examples/guide/README.rst:
--------------------------------------------------------------------------------
1 | ===========================
2 | Duktape guide example files
3 | ===========================
4 |
5 | Examples used in the Duktape guide.
6 |
--------------------------------------------------------------------------------
/examples/jxpretty/README.rst:
--------------------------------------------------------------------------------
1 | ================
2 | Jxpretty example
3 | ================
4 |
5 | Simple command line utility to pretty print JSON in the JX format.
6 |
--------------------------------------------------------------------------------
/licenses/commonjs.txt:
--------------------------------------------------------------------------------
1 | CommonJS specification snapshots are included in the references/
2 | directory. CommonJS is under the MIT license: http://www.commonjs.org/.
3 |
--------------------------------------------------------------------------------
/src-tools/lib/util/xml.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const fromXml = require('../extdeps/from-xml');
4 |
5 | const parse = fromXml.fromXML;
6 | exports.parse = parse;
7 |
--------------------------------------------------------------------------------
/tests/knownissues/test-numconv-tostring-misc-1.txt:
--------------------------------------------------------------------------------
1 | summary: rounding corner case, 1e+23 string coerces to 1.0000000000000001e+23
2 | ---
3 | 1.0000000000000001e+23
4 |
--------------------------------------------------------------------------------
/dist-files/Makefile.coffee:
--------------------------------------------------------------------------------
1 | dummy:
2 | coffee -c examples/coffee/globals.coffee
3 | coffee -c examples/coffee/hello.coffee
4 | coffee -c examples/coffee/mandel.coffee
5 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bi-duktape-thread-prototype-class.js:
--------------------------------------------------------------------------------
1 | /*===
2 | [object Object]
3 | ===*/
4 |
5 | print(Object.prototype.toString.call(Duktape.Thread.prototype));
6 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-regexp-canonicalization-locale.js:
--------------------------------------------------------------------------------
1 | /*---
2 | {
3 | "skip": true
4 | }
5 | ---*/
6 |
7 | /* XXX: locale specific canonicalization in regexps */
8 |
--------------------------------------------------------------------------------
/tests/perf/test-hello-world.js:
--------------------------------------------------------------------------------
1 | // Hello world test for memory testing
2 |
3 | if (typeof print !== 'function') { print = console.log; }
4 |
5 | print('Hello world!');
6 |
--------------------------------------------------------------------------------
/config/architectures/architecture_mips32.h.in:
--------------------------------------------------------------------------------
1 | #define DUK_USE_ARCH_STRING "mips32"
2 | /* MIPS byte order varies so rely on autodetection. */
3 | #define DUK_USE_PACKED_TVAL
4 |
--------------------------------------------------------------------------------
/config/architectures/architecture_mips64.h.in:
--------------------------------------------------------------------------------
1 | #define DUK_USE_ARCH_STRING "mips64"
2 | /* MIPS byte order varies so rely on autodetection. */
3 | #undef DUK_USE_PACKED_TVAL
4 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_AIX.h.in:
--------------------------------------------------------------------------------
1 | /* AIX */
2 | #if defined(_AIX)
3 | /* defined(__xlc__) || defined(__IBMC__): works but too wide */
4 | #define DUK_F_AIX
5 | #endif
6 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_HPUX.h.in:
--------------------------------------------------------------------------------
1 | /* HPUX */
2 | #if defined(__hpux)
3 | #define DUK_F_HPUX
4 | #if defined(__ia64)
5 | #define DUK_F_HPUX_ITANIUM
6 | #endif
7 | #endif
8 |
--------------------------------------------------------------------------------
/tests/knownissues/test-regexp-invalid-charclass-1.txt:
--------------------------------------------------------------------------------
1 | summary: "some invalid character classes are accepted (e.g. '[\\d-z]' and '[z-x]')"
2 | ---
3 | no error
4 | SyntaxError
5 |
--------------------------------------------------------------------------------
/config/architectures/architecture_sparc32.h.in:
--------------------------------------------------------------------------------
1 | #define DUK_USE_ARCH_STRING "sparc32"
2 | /* SPARC byte order varies so rely on autodetection. */
3 | #define DUK_USE_PACKED_TVAL
4 |
--------------------------------------------------------------------------------
/config/architectures/architecture_sparc64.h.in:
--------------------------------------------------------------------------------
1 | #define DUK_USE_ARCH_STRING "sparc64"
2 | /* SPARC byte order varies so rely on autodetection. */
3 | #undef DUK_USE_PACKED_TVAL
4 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_C99.h.in:
--------------------------------------------------------------------------------
1 | /* C99 or above */
2 | #undef DUK_F_C99
3 | #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
4 | #define DUK_F_C99
5 | #endif
6 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_CPP11.h.in:
--------------------------------------------------------------------------------
1 | /* C++11 or above */
2 | #undef DUK_F_CPP11
3 | #if defined(__cplusplus) && (__cplusplus >= 201103L)
4 | #define DUK_F_CPP11
5 | #endif
6 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-eval-construct.js:
--------------------------------------------------------------------------------
1 | /*===
2 | TypeError
3 | ===*/
4 |
5 | try {
6 | new eval('print(1+2)');
7 | } catch (e) {
8 | print(e.name);
9 | }
10 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-misc-hello-world.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Very minimal hello world test.
3 | */
4 |
5 | /*===
6 | Hello Hulda!
7 | ===*/
8 |
9 | print('Hello Hulda!');
10 |
--------------------------------------------------------------------------------
/tests/knownissues/test-bug-tonumber-u0000-1.txt:
--------------------------------------------------------------------------------
1 | summary: "'\\u0000' should ToNumber() coerce to NaN, but now coerces to zero like an empty string"
2 | ---
3 | 0 Infinity
4 | 0
5 |
--------------------------------------------------------------------------------
/tests/knownissues/test-dev-yield-after-callapply-1.txt:
--------------------------------------------------------------------------------
1 | summary: yield() not allowed when function called via Function.prototype.(call|apply)()
2 | ---
3 | TypeError
4 | TypeError
5 |
--------------------------------------------------------------------------------
/config/examples/disable_es6.yaml:
--------------------------------------------------------------------------------
1 | # Disable ES2015 features.
2 |
3 | DUK_USE_ES6_OBJECT_PROTO_PROPERTY: false
4 | DUK_USE_ES6_OBJECT_SETPROTOTYPEOF: false
5 | DUK_USE_ES6_PROXY: false
6 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_EMSCRIPTEN.h.in:
--------------------------------------------------------------------------------
1 | /* Emscripten (provided explicitly by user), improve if possible */
2 | #if defined(EMSCRIPTEN)
3 | #define DUK_F_EMSCRIPTEN
4 | #endif
5 |
--------------------------------------------------------------------------------
/extras/duk-v1-compat/test_compile1.js:
--------------------------------------------------------------------------------
1 | // File to compile, no error
2 | print('Hello from test_compile1.js');
3 | print(new Error('test error for traceback (shows filename)').stack);
4 |
--------------------------------------------------------------------------------
/extras/duk-v1-compat/test_eval1.js:
--------------------------------------------------------------------------------
1 | // File to eval, no error
2 | print('Hello from test_eval1.js');
3 | print(new Error('test error for traceback (shows filename)').stack);
4 | 123;
5 |
--------------------------------------------------------------------------------
/src-tools/lib/util/exec.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const { exec, execStdoutUtf8 } = require('../extbindings/exec');
4 | exports.exec = exec;
5 | exports.execStdoutUtf8 = execStdoutUtf8;
6 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-func-length-prop.js:
--------------------------------------------------------------------------------
1 | /*===
2 | 0
3 | 2
4 | ===*/
5 |
6 | function f1() {}
7 | function f2(x,y) {};
8 |
9 | print(f1.length);
10 | print(f2.length);
11 |
--------------------------------------------------------------------------------
/tests/lodash/basic.js:
--------------------------------------------------------------------------------
1 | function p(x) { print(Duktape.enc('jx', x)); }
2 |
3 | p(_.assign({ 'a': 1 }, { 'b': 2 }, { 'c': 3 }));
4 | p(_.map([1, 2, 3], function(n) { return n * 3; }));
5 |
--------------------------------------------------------------------------------
/website/api/no-string-intern.html:
--------------------------------------------------------------------------------
1 |
2 | With this variant, the input source code is not interned by Duktape which is
3 | useful in low memory environments.
4 |
5 |
--------------------------------------------------------------------------------
/config/architectures/architecture_m68k.h.in:
--------------------------------------------------------------------------------
1 | #define DUK_USE_ARCH_STRING "m68k"
2 | #if !defined(DUK_USE_BYTEORDER)
3 | #define DUK_USE_BYTEORDER 3
4 | #endif
5 | #define DUK_USE_PACKED_TVAL
6 |
--------------------------------------------------------------------------------
/config/architectures/architecture_powerpc64.h.in:
--------------------------------------------------------------------------------
1 | #define DUK_USE_ARCH_STRING "ppc64"
2 | /* No forced byteorder (both little and big endian are possible). */
3 | #undef DUK_USE_PACKED_TVAL
4 |
--------------------------------------------------------------------------------
/config/architectures/architecture_x32.h.in:
--------------------------------------------------------------------------------
1 | #define DUK_USE_ARCH_STRING "x32"
2 | #if !defined(DUK_USE_BYTEORDER)
3 | #define DUK_USE_BYTEORDER 1
4 | #endif
5 | #define DUK_USE_PACKED_TVAL
6 |
--------------------------------------------------------------------------------
/config/architectures/architecture_x64.h.in:
--------------------------------------------------------------------------------
1 | #define DUK_USE_ARCH_STRING "x64"
2 | #if !defined(DUK_USE_BYTEORDER)
3 | #define DUK_USE_BYTEORDER 1
4 | #endif
5 | #undef DUK_USE_PACKED_TVAL
6 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_PANIC_HANDLER.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_PANIC_HANDLER
2 | introduced: 1.0.0
3 | tags:
4 | - portability
5 | description: >
6 | Provide a custom panic handler.
7 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_MINGW.h.in:
--------------------------------------------------------------------------------
1 | /* MinGW. Also GCC flags (DUK_F_GCC) are enabled now. */
2 | #if defined(__MINGW32__) || defined(__MINGW64__)
3 | #define DUK_F_MINGW
4 | #endif
5 |
--------------------------------------------------------------------------------
/docker/duktape-shell-ubuntu-18.04-x64/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM duktape-base-ubuntu-18.04-x64:latest
2 |
3 | COPY --chown=duktape:duktape run.sh .
4 | RUN chmod 755 run.sh
5 |
6 | CMD /work/run.sh
7 |
--------------------------------------------------------------------------------
/docker/duktape-shell-ubuntu-20.04-x64/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM duktape-base-ubuntu-20.04-x64:latest
2 |
3 | COPY --chown=duktape:duktape run.sh .
4 | RUN chmod 755 run.sh
5 |
6 | CMD /work/run.sh
7 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-func-args-trailing-comma.js:
--------------------------------------------------------------------------------
1 | /*===
2 | SyntaxError
3 | ===*/
4 |
5 | try {
6 | eval("print(1,2,)");
7 | } catch (e) {
8 | print(e.name);
9 | }
10 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-for-in-basic.js:
--------------------------------------------------------------------------------
1 | /*===
2 | foo -> 1
3 | bar -> 2
4 | ===*/
5 |
6 | obj = {foo:1,bar:2};
7 |
8 | for (i in obj) {
9 | print(i,'->',obj[i]);
10 | }
11 |
--------------------------------------------------------------------------------
/tests/knownissues/test-bug-numconv-1e23-1.txt:
--------------------------------------------------------------------------------
1 | summary: corner case in floating point parse rounding
2 | ---
3 | 1.0000000000000001e+23
4 | 1.0000000000000001e+23
5 | 1.0000000000000001e+23
6 |
--------------------------------------------------------------------------------
/tests/knownissues/test-bug-numconv-denorm-toprec-1.txt:
--------------------------------------------------------------------------------
1 | summary: in a denormal corner case toPrecision() can output a zero leading digit
2 | ---
3 | 1e-323
4 | 0.9881312916824930884e-323
5 |
--------------------------------------------------------------------------------
/util/dukweb_fixup.h:
--------------------------------------------------------------------------------
1 | /* Fixups for dukweb.js. */
2 |
3 | extern void dukweb_panic_handler(int code, const char *msg);
4 | extern void dukweb_fatal_handler(void *udata, const char *msg);
5 |
--------------------------------------------------------------------------------
/util/remove_math_properties.yaml:
--------------------------------------------------------------------------------
1 | objects:
2 |
3 | - id: bi_math
4 | replace: true
5 | class: Object
6 | internal_prototype: bi_object_prototype
7 |
8 | properties: []
9 |
--------------------------------------------------------------------------------
/docker/duktape-release-1-ubuntu-18.04-x64/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM duktape-base-ubuntu-18.04-x64:latest
2 |
3 | COPY --chown=duktape:duktape run.sh .
4 | RUN chmod 755 run.sh
5 |
6 | CMD /work/run.sh
7 |
--------------------------------------------------------------------------------
/docker/duktape-release-1-ubuntu-20.04-x64/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM duktape-base-ubuntu-20.04-x64:latest
2 |
3 | COPY --chown=duktape:duktape run.sh .
4 | RUN chmod 755 run.sh
5 |
6 | CMD /work/run.sh
7 |
--------------------------------------------------------------------------------
/docker/duktape-shell-ubuntu-18.04-s390x/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM duktape-base-ubuntu-18.04-s390x:latest
2 |
3 | COPY --chown=duktape:duktape run.sh .
4 | RUN chmod 755 run.sh
5 |
6 | CMD /work/run.sh
7 |
--------------------------------------------------------------------------------
/docker/duktape-shell-ubuntu-18.04-s390x/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | /work/prepare_repo.sh
6 |
7 | #source emsdk/emsdk_env.sh
8 |
9 | cd duktape
10 | /bin/bash --login
11 |
--------------------------------------------------------------------------------
/docker/duktape-shell-ubuntu-18.04-x64/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | /work/prepare_repo.sh
6 |
7 | source emsdk/emsdk_env.sh
8 |
9 | cd duktape
10 | /bin/bash --login
11 |
--------------------------------------------------------------------------------
/docker/duktape-shell-ubuntu-20.04-arm64/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM duktape-base-ubuntu-20.04-arm64:latest
2 |
3 | COPY --chown=duktape:duktape run.sh .
4 | RUN chmod 755 run.sh
5 |
6 | CMD /work/run.sh
7 |
--------------------------------------------------------------------------------
/docker/duktape-shell-ubuntu-20.04-arm64/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | /work/prepare_repo.sh
6 |
7 | #source emsdk/emsdk_env.sh
8 |
9 | cd duktape
10 | /bin/bash --login
11 |
--------------------------------------------------------------------------------
/docker/duktape-shell-ubuntu-20.04-x64/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | /work/prepare_repo.sh
6 |
7 | source emsdk/emsdk_env.sh
8 |
9 | cd duktape
10 | /bin/bash --login
11 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-hello-world.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Minimal test for memory usage baseline testing.
3 | */
4 |
5 | /*===
6 | hello world!
7 | ===*/
8 |
9 | print('hello world!');
10 |
--------------------------------------------------------------------------------
/tests/perf/test-fib.lua:
--------------------------------------------------------------------------------
1 | function fib(n)
2 | if n <= 1 then
3 | return n
4 | else
5 | return fib(n - 2) + fib(n - 1)
6 | end
7 | end
8 |
9 | print(fib(35))
10 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.c eol=lf
2 | *.h eol=lf
3 | *.h.in eol=lf
4 | *.js eol=lf
5 | *.sh eol=lf
6 | *.md eol=lf
7 | *.rst eol=lf
8 | *.txt eol=lf
9 | *.yaml eol=lf
10 | *.json eol=lf
11 |
--------------------------------------------------------------------------------
/config/architectures/architecture_powerpc32.h.in:
--------------------------------------------------------------------------------
1 | #define DUK_USE_ARCH_STRING "ppc32"
2 | #if !defined(DUK_USE_BYTEORDER)
3 | #define DUK_USE_BYTEORDER 3
4 | #endif
5 | #define DUK_USE_PACKED_TVAL
6 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ARRAY_BUILTIN.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ARRAY_BUILTIN
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Provide an Array built-in.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DATE_BUILTIN.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DATE_BUILTIN
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Provide a Date built-in.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_JC.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_JC
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Enable support for the JC custom JSON format.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_JSON_BUILTIN.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_JSON_BUILTIN
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Provide a JSON built-in.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_JX.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_JX
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Enable support for the JX custom JSON format.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_MATH_BUILTIN.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_MATH_BUILTIN
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Provide a Math built-in.
8 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_DPRINT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_DPRINT
2 | introduced: 1.0.0
3 | requires:
4 | - DUK_OPT_DEBUG
5 | tags:
6 | - debug
7 | description: >
8 | Enable debug printouts.
9 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_BCC.h.in:
--------------------------------------------------------------------------------
1 | /* BCC (Bruce's C compiler): this is a "torture target" for compilation */
2 | #if defined(__BCC__) || defined(__BCC_VERSION__)
3 | #define DUK_F_BCC
4 | #endif
5 |
--------------------------------------------------------------------------------
/docker/duktape-release-1-ubuntu-20.04-arm64/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM duktape-base-ubuntu-20.04-arm64:latest
2 |
3 | COPY --chown=duktape:duktape run.sh .
4 | RUN chmod 755 run.sh
5 |
6 | CMD /work/run.sh
7 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bi-date-instance.js:
--------------------------------------------------------------------------------
1 | /*===
2 | [object Date]
3 | ===*/
4 |
5 | // Date instance [[Class]] is "Date"
6 |
7 | var d = new Date();
8 | print(Object.prototype.toString.call(d));
9 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bi-string-trim-180e.js:
--------------------------------------------------------------------------------
1 | /*===
2 | 5
3 | ===*/
4 |
5 | // U+180E is no longer white space in Unicode, so trim() should not remove it.
6 | print('\u180efoo\u180e'.trim().length);
7 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-object-constructor.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Object constructor tests
3 | */
4 |
5 | /*---
6 | {
7 | "skip": true
8 | }
9 | ---*/
10 |
11 | /* XXX: to be implemented */
12 |
--------------------------------------------------------------------------------
/tests/perf/test-fib.rb:
--------------------------------------------------------------------------------
1 | def fib(n)
2 | if n <= 1 then
3 | return n
4 | else
5 | return fib(n - 2) + fib(n - 1)
6 | end
7 | end
8 |
9 | print(fib(35).to_s + "\n")
10 |
--------------------------------------------------------------------------------
/config/architectures/architecture_emscripten.h.in:
--------------------------------------------------------------------------------
1 | #define DUK_USE_ARCH_STRING "emscripten"
2 | #if !defined(DUK_USE_BYTEORDER)
3 | #define DUK_USE_BYTEORDER 1
4 | #endif
5 | #undef DUK_USE_PACKED_TVAL
6 |
--------------------------------------------------------------------------------
/config/architectures/architecture_generic.h.in:
--------------------------------------------------------------------------------
1 | /* These are necessary wild guesses. */
2 | #define DUK_USE_ARCH_STRING "generic"
3 | /* Rely on autodetection for byte order, alignment, and packed tval. */
4 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_BOOLEAN_BUILTIN.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_BOOLEAN_BUILTIN
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Provide a Boolean built-in.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DUKTAPE_BUILTIN.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DUKTAPE_BUILTIN
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - duktape
6 | description: >
7 | Provide a Duktape built-in.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_HEX_SUPPORT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_HEX_SUPPORT
2 | introduced: 2.3.0
3 | default: true
4 | tags:
5 | - codec
6 | description: >
7 | Enable hex encoding/decoding support.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_NUMBER_BUILTIN.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_NUMBER_BUILTIN
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Provide a Number built-in.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_OBJECT_BUILTIN.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_OBJECT_BUILTIN
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Provide an Object built-in.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_STRING_BUILTIN.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_STRING_BUILTIN
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Provide a String built-in.
8 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_DDPRINT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_DDPRINT
2 | introduced: 1.0.0
3 | requires:
4 | - DUK_OPT_DEBUG
5 | tags:
6 | - debug
7 | description: >
8 | Enable more debug printouts.
9 |
--------------------------------------------------------------------------------
/config/header-snippets/cpp_exception_sanity.h.in:
--------------------------------------------------------------------------------
1 | #if defined(DUK_USE_CPP_EXCEPTIONS) && !defined(__cplusplus)
2 | #error DUK_USE_CPP_EXCEPTIONS enabled but not compiling with a C++ compiler
3 | #endif
4 |
--------------------------------------------------------------------------------
/tests/api/test-bug-is-constructor-call-empty-callstack.c:
--------------------------------------------------------------------------------
1 | /*===
2 | still here
3 | ===*/
4 |
5 | void test(duk_context *ctx) {
6 | (void) duk_is_constructor_call(ctx);
7 | printf("still here\n");
8 | }
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_FUNCTION_BUILTIN.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_FUNCTION_BUILTIN
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Provide a Function built-in.
8 |
--------------------------------------------------------------------------------
/config/examples/disable_bufferobjects.yaml:
--------------------------------------------------------------------------------
1 | # Disable support for typed arrays and Node.js Buffer. Duktape will still
2 | # support plain buffers and Duktape.Buffer.
3 | DUK_USE_BUFFEROBJECT_SUPPORT: false
4 |
--------------------------------------------------------------------------------
/extras/duk-v1-compat/test_eval2.js:
--------------------------------------------------------------------------------
1 | // File to eval, throws error
2 | print('Hello from test_eval2.js');
3 | print(new Error('test error for traceback (shows filename)').stack);
4 | throw new Error('aiee');
5 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-date-nan-tzoffset.js:
--------------------------------------------------------------------------------
1 | /*===
2 | NaN
3 | ===*/
4 |
5 | try {
6 | var d = new Date(NaN);
7 | print(d.getTimezoneOffset());
8 | } catch (e) {
9 | print(e);
10 | }
11 |
--------------------------------------------------------------------------------
/tests/perf/test-string-plain-concat.py:
--------------------------------------------------------------------------------
1 | def test():
2 | for i in xrange(1):
3 | t = ''
4 | for j in xrange(int(1e5)):
5 | t += 'x'
6 | #print(len(t))
7 |
8 | test()
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_BASE64_SUPPORT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_BASE64_SUPPORT
2 | introduced: 2.3.0
3 | default: true
4 | tags:
5 | - codec
6 | description: >
7 | Enable base64 encoding/decoding support.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ES6_PROXY.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ES6_PROXY
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - ecmascript2015
6 | description: >
7 | Provide the non-standard (ES6) Proxy object.
8 |
--------------------------------------------------------------------------------
/dist-files/Makefile.codepage:
--------------------------------------------------------------------------------
1 | CC = gcc
2 |
3 | codepage:
4 | $(CC) -o $@ -std=c99 -O2 -Wall -Wextra -Isrc/ \
5 | src/duktape.c examples/codepage-conv/duk_codepage_conv.c \
6 | examples/codepage-conv/test.c -lm
7 |
--------------------------------------------------------------------------------
/examples/eventloop/c_eventloop.h:
--------------------------------------------------------------------------------
1 | #if !defined(C_EVENTLOOP_H)
2 | #define C_EVENTLOOP_H
3 |
4 | void eventloop_register(duk_context *ctx);
5 | duk_ret_t eventloop_run(duk_context *ctx, void *udata);
6 |
7 | #endif
8 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-unicode-caseconv-basic.js:
--------------------------------------------------------------------------------
1 | /*===
2 | Foo
3 | foo
4 | FOO
5 | ===*/
6 |
7 | text = 'Foo';
8 |
9 | print(text);
10 | print(text.toLowerCase());
11 | print(text.toUpperCase());
12 |
--------------------------------------------------------------------------------
/tests/emscripten/helloworld.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Hello World test case.
3 | */
4 |
5 | #include
6 |
7 | int main(int argc, char *argv[]) {
8 | printf("Hello world!\n");
9 | return 0;
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/tests/knownissues/test-regexp-empty-quantified-1.txt:
--------------------------------------------------------------------------------
1 | summary: a suitable empty quantified (e.g. '(x*)*') causes regexp parsing to terminate due to step limit
2 | ---
3 | RangeError: regexp executor recursion limit
4 |
--------------------------------------------------------------------------------
/website/api/ref-custom-type-coercion.html:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-expr-newtarget-newfoo.js:
--------------------------------------------------------------------------------
1 | /*===
2 | SyntaxError
3 | ===*/
4 |
5 | try {
6 | eval('new (function test() { print(typeof new.foo); })');
7 | } catch (e) {
8 | print(e.name);
9 | }
10 |
--------------------------------------------------------------------------------
/tests/perf/test-fib.pl:
--------------------------------------------------------------------------------
1 | sub fib {
2 | my $n = shift;
3 | if ($n <= 1) {
4 | return $n;
5 | } else {
6 | return fib($n - 2) + fib($n - 1);
7 | }
8 | }
9 | print fib(35) . "\n";
10 |
--------------------------------------------------------------------------------
/util/makeduk_scanbuild.yaml:
--------------------------------------------------------------------------------
1 | # Avoid NULL write for scanbuild fatal handler.
2 | DUK_USE_FATAL_HANDLER:
3 | verbatim: "#define DUK_USE_FATAL_HANDLER(udata,msg) do { (void) (udata); (void) (msg); abort(); } while(0)"
4 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_HTML_COMMENTS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_HTML_COMMENTS
2 | introduced: 2.1.0
3 | default: true
4 | tags:
5 | - ecmascript2015
6 | description: >
7 | Enable ES2015 Annex B.1.3 HTML comment syntax.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_REFERENCE_COUNTING.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_REFERENCE_COUNTING
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - gc
6 | description: >
7 | Use reference counting for garbage collection.
8 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_DPRINT_RDTSC.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_DPRINT_RDTSC
2 | introduced: 1.0.0
3 | removed: 1.4.0
4 | tags:
5 | - debug
6 | description: >
7 | Print RDTSC cycle count in debug prints if available.
8 |
--------------------------------------------------------------------------------
/config/header-snippets/platform_conditionalincludes.h.in:
--------------------------------------------------------------------------------
1 | #if defined(DUK_F_CPP) && defined(DUK_USE_CPP_EXCEPTIONS)
2 | #include /* std::exception */
3 | #include /* std::runtime_error */
4 | #endif
5 |
--------------------------------------------------------------------------------
/tests/knownissues/test-dev-bound-thread-start-func-1.txt:
--------------------------------------------------------------------------------
1 | summary: initial function of a new coroutine cannot be bound
2 | ---
3 | non-bound
4 | func called: 321
5 | bound
6 | TypeError: invalid initial thread state/stack
7 |
--------------------------------------------------------------------------------
/tests/knownissues/test-numconv-tostring-gen-1.txt:
--------------------------------------------------------------------------------
1 | summary: rounding corner cases in number-to-string coercion
2 | # Testcase output is 2.2MB long so use a hash for the known issue
3 | md5: 7a22b68dbd2f6e898040f516588e2330
4 |
--------------------------------------------------------------------------------
/util/dukweb_base.yaml:
--------------------------------------------------------------------------------
1 | DUK_USE_SELF_TESTS: true
2 | #DUK_USE_ASSERTIONS: true
3 | DUK_USE_FATAL_HANDLER:
4 | verbatim: "#define DUK_USE_FATAL_HANDLER(udata,msg) do {dukweb_fatal_handler((udata),(msg));abort();} while (0)"
5 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_32BIT_PTRS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_32BIT_PTRS
2 | introduced: 1.0.0
3 | removed: 1.4.0
4 | default: false
5 | tags:
6 | - portability
7 | description: >
8 | Pointers are 32-bit integer compatible.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ES6.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ES6
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - ecmascript2015
6 | description: >
7 | Enable ES6 functionality not covered by other specific config options.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ES7.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ES7
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - ecmascript2016
6 | description: >
7 | Enable ES7 functionality not covered by other specific config options.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ES8.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ES8
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - ecmascript2017
6 | description: >
7 | Enable ES8 functionality not covered by other specific config options.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ES9.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ES9
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - ecmascript2018
6 | description: >
7 | Enable ES9 functionality not covered by other specific config options.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_EXEC_PREFER_SIZE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_EXEC_PREFER_SIZE
2 | introduced: 2.0.0
3 | default: false
4 | tags:
5 | - lowmemory
6 | description: >
7 | Prefer size over performance in bytecode executor.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_PACK_GCC_ATTR.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_PACK_GCC_ATTR
2 | introduced: 1.0.0
3 | default: false
4 | tags:
5 | - portability
6 | description: >
7 | Use gcc-specific attribute to force struct packing.
8 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_BUFLEN16.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_BUFLEN16
2 | introduced: 1.1.0
3 | tags:
4 | - lowmemory
5 | - experimental
6 | description: >
7 | Use a 16-bit buffer length field (for low memory environments).
8 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_STRHASH16.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_STRHASH16
2 | introduced: 1.1.0
3 | tags:
4 | - lowmemory
5 | - experimental
6 | description: >
7 | Use a 16-bit string hash field (for low memory environments).
8 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_STRLEN16.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_STRLEN16
2 | introduced: 1.1.0
3 | tags:
4 | - lowmemory
5 | - experimental
6 | description: >
7 | Use a 16-bit string length field (for low memory environments).
8 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_BSD.h.in:
--------------------------------------------------------------------------------
1 | /* BSD variant */
2 | #if defined(DUK_F_FREEBSD) || defined(DUK_F_NETBSD) || defined(DUK_F_OPENBSD) || \
3 | defined(__bsdi__) || defined(__DragonFly__)
4 | #define DUK_F_BSD
5 | #endif
6 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_UNIX.h.in:
--------------------------------------------------------------------------------
1 | /* Generic Unix (includes Cygwin) */
2 | #if defined(__unix) || defined(__unix__) || defined(unix) || \
3 | defined(DUK_F_LINUX) || defined(DUK_F_BSD)
4 | #define DUK_F_UNIX
5 | #endif
6 |
--------------------------------------------------------------------------------
/dist-files/Makefile.eval:
--------------------------------------------------------------------------------
1 | #
2 | # Example Makefile for building the eval example
3 | #
4 |
5 | CC = gcc
6 |
7 | eval:
8 | $(CC) -o $@ -std=c99 -O2 -Wall -Wextra -Isrc/ \
9 | src/duktape.c examples/eval/eval.c -lm
10 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-for-multivar.js:
--------------------------------------------------------------------------------
1 | /*===
2 | 1 2
3 | ===*/
4 |
5 | /* This broke at some point. */
6 |
7 | try {
8 | for (var a=1, b=2; ; ) { print(a,b); break; }
9 | } catch (e) {
10 | print(e);
11 | }
12 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-misc-prepost-incdec-order.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Evaluation order of pre/post increment and decrement.
3 | */
4 |
5 | /*===
6 | 1 1 3 3 3 1
7 | ===*/
8 |
9 | x = 1;
10 | print(x, x++, ++x, x, x--, --x);
11 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-stmt-break.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Break statement (E5 Section 12.8).
3 | */
4 |
5 | /*---
6 | {
7 | "skip": true
8 | }
9 | ---*/
10 |
11 | /*===
12 | ===*/
13 |
14 | /* XXX: to be implemented */
15 |
--------------------------------------------------------------------------------
/tests/knownissues/test-dev-16bit-overflows-3.txt:
--------------------------------------------------------------------------------
1 | summary: requires lowmem 16-bit field options
2 | ---
3 | 32768
4 | 32767
5 | 65535
6 | 65536
7 | 32768
8 | 32767
9 | 38
10 | 38
11 | 65535
12 | 65536
13 | Reached: 65535
14 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_PACK_CLANG_ATTR.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_PACK_CLANG_ATTR
2 | introduced: 1.0.0
3 | default: false
4 | tags:
5 | - portability
6 | description: >
7 | Use clang-specific attribute to force struct packing.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_PACK_DUMMY_MEMBER.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_PACK_DUMMY_MEMBER
2 | introduced: 1.0.0
3 | default: false
4 | tags:
5 | - portability
6 | description: >
7 | Use dummy struct member to force struct packing.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_PACK_MSVC_PRAGMA.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_PACK_MSVC_PRAGMA
2 | introduced: 1.0.0
3 | default: false
4 | tags:
5 | - portability
6 | description: >
7 | Use msvc-specific attribute to force struct packing.
8 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_TRACEBACK_DEPTH.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_TRACEBACK_DEPTH
2 | introduced: 1.0.0
3 | tags:
4 | - ecmascript
5 | description: >
6 | Override default traceback collection depth. The default is currently 10.
7 |
--------------------------------------------------------------------------------
/examples/dummy-date-provider/README.rst:
--------------------------------------------------------------------------------
1 | ====================================
2 | Dummy external Date provider example
3 | ====================================
4 |
5 | This example implements a dummy, minimal external Date provider.
6 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-objlit-nocomma.js:
--------------------------------------------------------------------------------
1 | /*===
2 | SyntaxError
3 | ===*/
4 |
5 | try {
6 | var obj = eval("({ 'foo': 1 'bar': 2 })");
7 | print(obj.foo, obj.bar);
8 | } catch (e) {
9 | print(e.name);
10 | }
11 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-ctrl-with-binding.js:
--------------------------------------------------------------------------------
1 | /*===
2 | Infinity
3 | ===*/
4 |
5 | with (Number) {
6 | /* binds to Number.POSITIVE_INFINITY */
7 | print(POSITIVE_INFINITY);
8 | }
9 |
10 | /* XXX: more tests */
11 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-traceback-example.js:
--------------------------------------------------------------------------------
1 | /*---
2 | {
3 | "skip": true
4 | }
5 | ---*/
6 |
7 | try {
8 | decodeURIComponent('%e1%a9%01'); // invalid utf-8
9 | } catch (e) {
10 | print(e.stack || e);
11 | }
12 |
--------------------------------------------------------------------------------
/tests/memory/test-uint8array-1.js:
--------------------------------------------------------------------------------
1 | function test() {
2 | var arr = [];
3 | while (arr.length < 1e5) {
4 | arr.push(new Uint8Array(256));
5 | }
6 | print(arr.length + ' Uint8Arrays created');
7 | }
8 | test();
9 |
--------------------------------------------------------------------------------
/util/README.rst:
--------------------------------------------------------------------------------
1 | =======================
2 | Miscellaneous utilities
3 | =======================
4 |
5 | This directory contains miscellaneous Python, Shell, and other utilities
6 | which are not part of the end user distributable.
7 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_COROUTINE_SUPPORT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_COROUTINE_SUPPORT
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - execution
6 | description: >
7 | Enable support for Duktape coroutines, i.e. yield/resume.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DATE_NOW_WINDOWS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DATE_NOW_WINDOWS
2 | introduced: 1.0.0
3 | default: false
4 | tags:
5 | - date
6 | - portability
7 | description: >
8 | Use Win32 API calls to get current datetime.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DDPRINT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DDPRINT
2 | introduced: 1.0.0
3 | removed: 2.0.0
4 | default: false
5 | tags:
6 | - debug
7 | description: >
8 | Enable more debug printouts. Replaced by DUK_USE_DEBUG_LEVEL.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DPRINT_RDTSC.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DPRINT_RDTSC
2 | introduced: 1.0.0
3 | removed: 2.0.0
4 | default: false
5 | tags:
6 | - debug
7 | description: >
8 | Print RDTSC cycle count in debug prints if available.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ESBC_LIMITS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ESBC_LIMITS
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Impose byte and line number limits for compiled function bytecode.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_FINALIZER_SUPPORT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_FINALIZER_SUPPORT
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - execution
6 | description: >
7 | Enable support for object finalizers (Duktape specific).
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_RDTSC.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_RDTSC
2 | introduced: 1.3.0
3 | removed: 1.4.0
4 | default: false
5 | tags:
6 | - portability
7 | description: >
8 | Macro to provide an x86/x64 RDTSC timestamp for debug prints.
9 |
--------------------------------------------------------------------------------
/config/examples/timing_sensitive.yaml:
--------------------------------------------------------------------------------
1 | # Base configuration for timing sensitive environments, see
2 | # doc/timing-sensitive.rst:
3 |
4 | DUK_USE_MARK_AND_SWEEP: true
5 | DUK_USE_REFERENCE_COUNTING: true
6 | DUK_USE_VOLUNTARY_GC: false
7 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_REFCOUNT16.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_REFCOUNT16
2 | introduced: 1.1.0
3 | tags:
4 | - lowmemory
5 | - experimental
6 | description: >
7 | Use a 16-bit reference count field (for low memory environments).
8 |
--------------------------------------------------------------------------------
/src-input/duk_api_random.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Random numbers
3 | */
4 |
5 | #include "duk_internal.h"
6 |
7 | DUK_EXTERNAL duk_double_t duk_random(duk_hthread *thr) {
8 | return (duk_double_t) duk_util_get_random_double(thr);
9 | }
10 |
--------------------------------------------------------------------------------
/testrunner/README.rst:
--------------------------------------------------------------------------------
1 | ==================
2 | Duktape testrunner
3 | ==================
4 |
5 | The main testrunner has been moved to https://github.com/svaarala/duktape-testrunner.
6 | This directory only contains the actual test jobs.
7 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-strcomp.js:
--------------------------------------------------------------------------------
1 | /*===
2 | false
3 | false
4 | true
5 | ===*/
6 |
7 | try {
8 | print('' === 'foo');
9 | print('' > 'foo');
10 | print('' < 'foo');
11 | } catch (e) {
12 | print(e);
13 | }
14 |
--------------------------------------------------------------------------------
/tests/knownissues/test-bi-proxy-construct-newtarget-1.txt:
--------------------------------------------------------------------------------
1 | summary: new.target is target object rather than Proxy when calling via Proxy
2 | ---
3 | - direct call
4 | function
5 | true
6 | false
7 | function
8 | true
9 | false
10 |
--------------------------------------------------------------------------------
/website/api/path-encoding.html:
--------------------------------------------------------------------------------
1 |
2 | The path argument is given directly to fopen().
3 | The path encoding cannot be specified and there is no support for a wide
4 | character string.
5 |
6 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_BYTECODE_DUMP_SUPPORT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_BYTECODE_DUMP_SUPPORT
2 | introduced: 1.3.0
3 | default: true
4 | tags:
5 | - api
6 | description: >
7 | Enable support for API calls to dump/load function bytecode.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ES6_REGEXP_BRACES.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ES6_REGEXP_BRACES
2 | introduced: 1.5.0
3 | removed: 2.0.0
4 | default: true
5 | tags:
6 | - ecmascript2015
7 | description: >
8 | Replaced by DUK_USE_ES6_REGEXP_SYNTAX.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_PANIC_ABORT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_PANIC_ABORT
2 | introduced: 1.0.0
3 | removed: 2.0.0
4 | default: true
5 | tags:
6 | - portability
7 | description: >
8 | Call abort() when the default panic handler is invoked.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_PANIC_EXIT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_PANIC_EXIT
2 | introduced: 1.0.0
3 | removed: 2.0.0
4 | default: false
5 | tags:
6 | - portability
7 | description: >
8 | Call exit() when the default panic handler is invoked.
9 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_COMMONJS_MODULES.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_COMMONJS_MODULES
2 | introduced: 1.0.0
3 | tags:
4 | - ecmascript
5 | description: >
6 | Disable support for CommonJS modules. Causes require() to throw an error.
7 |
--------------------------------------------------------------------------------
/dist-files/Makefile.sandbox:
--------------------------------------------------------------------------------
1 | #
2 | # Example Makefile for building the sandbox example
3 | #
4 |
5 | CC = gcc
6 |
7 | sandbox:
8 | $(CC) -o $@ -std=c99 -O2 -Wall -Wextra -Isrc/ \
9 | src/duktape.c examples/sandbox/sandbox.c -lm
10 |
--------------------------------------------------------------------------------
/docker/duktape-make-ubuntu-18.04-x64/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | /work/prepare_repo.sh
6 |
7 | source emsdk/emsdk_env.sh
8 |
9 | cd duktape
10 | make "$@"
11 | zip -r /tmp/out.zip build dist tmp
12 | cat /tmp/out.zip
13 |
--------------------------------------------------------------------------------
/docker/duktape-make-ubuntu-20.04-x64/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | /work/prepare_repo.sh
6 |
7 | source emsdk/emsdk_env.sh
8 |
9 | cd duktape
10 | make "$@"
11 | zip -r /tmp/out.zip build dist tmp
12 | cat /tmp/out.zip
13 |
--------------------------------------------------------------------------------
/misc/tcc_zerosign2.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | int main(int argc, char *argv[]) {
4 | double d = 0.0;
5 | printf("signbit: %d\n", signbit(d));
6 | d = -d;
7 | printf("signbit: %d\n", signbit(d));
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-arguments-class.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Arguments [[Class]].
3 | */
4 |
5 | /*===
6 | [object Arguments]
7 | ===*/
8 |
9 | function args_class() {
10 | return arguments;
11 | }
12 |
13 | print("" + args_class());
14 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-string-ops-non-string-this.js:
--------------------------------------------------------------------------------
1 | /*---
2 | {
3 | "skip": true
4 | }
5 | ---*/
6 |
7 | /* XXX: test string prototype operations when called with 'this'
8 | * bound to something other than a string.
9 | */
10 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-expr-logicalop.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Logical operators (E5 Sections 11.4.9, 11.11).
3 | */
4 |
5 | /*---
6 | {
7 | "skip": true
8 | }
9 | ---*/
10 |
11 | /*===
12 | ===*/
13 |
14 | /* XXX: to be implemented */
15 |
--------------------------------------------------------------------------------
/tests/memory/test-function-expression-1.js:
--------------------------------------------------------------------------------
1 | function test() {
2 | var arr = [];
3 | while (arr.length < 1e5) {
4 | arr.push(function () {});
5 | }
6 | print(arr.length + ' anonymous functions created');
7 | }
8 | test();
9 |
--------------------------------------------------------------------------------
/tests/memory/test-plain-buffer-1.js:
--------------------------------------------------------------------------------
1 | function test() {
2 | var arr = [];
3 | while (arr.length < 1e5) {
4 | arr.push(Uint8Array.allocPlain(256));
5 | }
6 | print(arr.length + ' plain buffers created');
7 | }
8 | test();
9 |
--------------------------------------------------------------------------------
/tools/json2yaml.py:
--------------------------------------------------------------------------------
1 | import os, sys, json, yaml
2 |
3 | if __name__ == '__main__':
4 | # Use safe_dump() instead of dump() to avoid tags like "!!python/unicode"
5 | print(yaml.safe_dump(json.load(sys.stdin), default_flow_style=False))
6 |
--------------------------------------------------------------------------------
/website/api/string-non-null-zero-length.html:
--------------------------------------------------------------------------------
1 |
2 | A non-NULL return value is guaranteed even for zero length strings;
3 | this differs from how buffer data pointers are handled (for technical reasons).
4 |
5 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_BUFLEN16.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_BUFLEN16
2 | introduced: 1.1.0
3 | default: false
4 | tags:
5 | - lowmemory
6 | - experimental
7 | description: >
8 | Use a 16-bit buffer length field (for low memory environments).
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_STRHASH16.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_STRHASH16
2 | introduced: 1.1.0
3 | default: false
4 | tags:
5 | - lowmemory
6 | - experimental
7 | description: >
8 | Use a 16-bit string hash field (for low memory environments).
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_STRLEN16.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_STRLEN16
2 | introduced: 1.1.0
3 | default: false
4 | tags:
5 | - lowmemory
6 | - experimental
7 | description: >
8 | Use a 16-bit string length field (for low memory environments).
9 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_JSONC.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_JSONC
2 | introduced: 1.0.0
3 | removed: 1.0.0
4 | related:
5 | - DUK_OPT_NO_JC
6 | tags:
7 | - ecmascript
8 | description: >
9 | Removed, use DUK_OPT_NO_JC instead.
10 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_JSONX.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_JSONX
2 | introduced: 1.0.0
3 | removed: 1.0.0
4 | related:
5 | - DUK_OPT_NO_JX
6 | tags:
7 | - ecmascript
8 | description: >
9 | Removed, use DUK_OPT_NO_JX instead.
10 |
--------------------------------------------------------------------------------
/docker/duktape-make-ubuntu-20.04-arm64/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | /work/prepare_repo.sh
6 |
7 | #source emsdk/emsdk_env.sh
8 |
9 | cd duktape
10 | make "$@"
11 | zip -r /tmp/out.zip build dist tmp
12 | cat /tmp/out.zip
13 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-add-prec.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Addition precedence test.
3 | */
4 |
5 | /*===
6 | 3foo34
7 | ===*/
8 |
9 | /* This is equivalent to: (((1 + 2) + 'foo') + 3) + 4 === "3foo34" */
10 |
11 | print(1 + 2 + 'foo' + 3 + 4);
12 |
--------------------------------------------------------------------------------
/tests/knownissues/test-dev-16bit-overflows-2.txt:
--------------------------------------------------------------------------------
1 | summary: requires lowmem 16-bit field options
2 | ---
3 | 32768
4 | 32767
5 | 65535
6 | 65536
7 | TypeError: undefined not callable
8 | TypeError: undefined not callable
9 | Reached: 65535
10 |
--------------------------------------------------------------------------------
/RELEASES.rst:
--------------------------------------------------------------------------------
1 | ================
2 | Duktape releases
3 | ================
4 |
5 | Release information can be found at https://duktape.org/download.html.
6 | Raw release metadata is maintained in https://github.com/svaarala/duktape/tree/master/releases.
7 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_BROWSER_LIKE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_BROWSER_LIKE
2 | introduced: 1.0.0
3 | removed: 2.0.0
4 | default: true
5 | tags:
6 | - ecmascript
7 | description: >
8 | Provide browser-like bindings: currently print() and alert().
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_CBOR_DEC_RECLIMIT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_CBOR_DEC_RECLIMIT
2 | introduced: 2.6.0
3 | default: 1000
4 | tags:
5 | - portability
6 | - cstackdepth
7 | description: >
8 | Maximum native stack recursion for CBOR decoding.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_CBOR_ENC_RECLIMIT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_CBOR_ENC_RECLIMIT
2 | introduced: 2.6.0
3 | default: 1000
4 | tags:
5 | - portability
6 | - cstackdepth
7 | description: >
8 | Maximum native stack recursion for CBOR encoding.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DATE_TZO_GMTIME_S.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DATE_TZO_GMTIME_S
2 | introduced: 2.0.0
3 | default: false
4 | tags:
5 | - date
6 | - portability
7 | description: >
8 | Use gmtime_s() to get local time offset at a certain time.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ERRCREATE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ERRCREATE
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Call Duktape.errCreate() when augmenting an ECMAScript error object
8 | being created.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_JSON_DEC_RECLIMIT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_JSON_DEC_RECLIMIT
2 | introduced: 1.3.0
3 | default: 1000
4 | tags:
5 | - portability
6 | - cstackdepth
7 | description: >
8 | Maximum native stack recursion for JSON decoding.
9 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_ES6_PROXY.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_ES6_PROXY
2 | introduced: 1.0.0
3 | tags:
4 | - ecmascript
5 | - ecmascript6
6 | description: >
7 | Disable the non-standard (ES6) Proxy object which is enabled by
8 | default.
9 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_M68K.h.in:
--------------------------------------------------------------------------------
1 | /* Motorola 68K. Not defined by VBCC, so user must define one of these
2 | * manually when using VBCC.
3 | */
4 | #if defined(__m68k__) || defined(M68000) || defined(__MC68K__)
5 | #define DUK_F_M68K
6 | #endif
7 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_TOS.h.in:
--------------------------------------------------------------------------------
1 | /* Atari ST TOS. __TOS__ defined by PureC. No platform define in VBCC
2 | * apparently, so to use with VBCC user must define __TOS__ manually.
3 | */
4 | #if defined(__TOS__)
5 | #define DUK_F_TOS
6 | #endif
7 |
--------------------------------------------------------------------------------
/extras/minimal-printf/Makefile:
--------------------------------------------------------------------------------
1 | # Just for manual testing
2 | CC = gcc
3 |
4 | .PHONY: test
5 | test: duk_minimal_printf.c
6 | $(CC) -std=c99 -Wall -Wextra -fno-stack-protector -m32 -Os -fomit-frame-pointer -otest duk_minimal_printf.c test.c
7 | ./test
8 |
--------------------------------------------------------------------------------
/src-input/duk_bi_thrower.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Type error thrower, E5 Section 13.2.3.
3 | */
4 |
5 | #include "duk_internal.h"
6 |
7 | DUK_INTERNAL duk_ret_t duk_bi_type_error_thrower(duk_hthread *thr) {
8 | DUK_DCERROR_TYPE_INVALID_ARGS(thr);
9 | }
10 |
--------------------------------------------------------------------------------
/tests/knownissues/test-dev-16bit-overflows-1.txt:
--------------------------------------------------------------------------------
1 | summary: requires lowmem 16-bit field options
2 | ---
3 | 32768
4 | 32767
5 | 65535
6 | 65536
7 | TypeError: undefined not callable
8 | TypeError: undefined not constructable
9 | Reached: 65535
10 |
--------------------------------------------------------------------------------
/tests/perf/test-string-array-concat.py:
--------------------------------------------------------------------------------
1 | def test():
2 | for i in xrange(int(5e3)):
3 | t = []
4 | for j in xrange(int(1e4)):
5 | #t[j] = 'x'
6 | t.append('x')
7 | t = ''.join(t)
8 |
9 | test()
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_COMPILER_RECLIMIT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_COMPILER_RECLIMIT
2 | introduced: 1.3.0
3 | default: 2500
4 | tags:
5 | - portability
6 | - cstackdepth
7 | description: >
8 | ECMAScript compiler native call stack recursion limit.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DATE_TZO_WINDOWS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DATE_TZO_WINDOWS
2 | introduced: 1.0.0
3 | default: false
4 | tags:
5 | - date
6 | - portability
7 | description: >
8 | Use Win32 API calls to get local time offset at a certain time.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ERRTHROW.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ERRTHROW
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Call Duktape.errThrow() when augmenting an ECMAScript error object
8 | about to be thrown.
9 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_BYTECODE_DUMP_SUPPORT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_BYTECODE_DUMP_SUPPORT
2 | introduced: 1.3.0
3 | tags:
4 | - api
5 | description: >
6 | Disable API calls to dump/load functions to bytecode (reduces code
7 | footprint).
8 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_STRTAB_CHAIN_SIZE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_STRTAB_CHAIN_SIZE
2 | introduced: 1.1.0
3 | requires:
4 | - DUK_OPT_STRTAB_CHAIN
5 | tags:
6 | - lowmemory
7 | description: >
8 | Define stringtable size for DUK_OPT_STRTAB_CHAIN.
9 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_AMIGAOS.h.in:
--------------------------------------------------------------------------------
1 | /* AmigaOS. Neither AMIGA nor __amigaos__ is defined on VBCC, so user must
2 | * define 'AMIGA' manually when using VBCC.
3 | */
4 | #if defined(AMIGA) || defined(__amigaos__)
5 | #define DUK_F_AMIGAOS
6 | #endif
7 |
--------------------------------------------------------------------------------
/dist-files/Makefile.jxpretty:
--------------------------------------------------------------------------------
1 | #
2 | # Example Makefile for building the jxpretty example
3 | #
4 |
5 | CC = gcc
6 |
7 | jxpretty:
8 | $(CC) -o $@ -std=c99 -Wall -Wextra -O2 -Isrc \
9 | src/duktape.c examples/jxpretty/jxpretty.c \
10 | -lm
11 |
--------------------------------------------------------------------------------
/examples/cmdline/README.rst:
--------------------------------------------------------------------------------
1 | ====================
2 | Duktape command line
3 | ====================
4 |
5 | ECMAScript command line execution tool, useful for running ECMAScript code
6 | from a file, stdin, or interactively. Also used by automatic testing.
7 |
--------------------------------------------------------------------------------
/src-tools/lib/util/assert.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | function assert(x, message) {
4 | if (x) {
5 | return x;
6 | }
7 | throw new TypeError('assertion failed' + (message ? ': ' + message : ''));
8 | }
9 | exports.assert = assert;
10 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-regexp-dash-assert.js:
--------------------------------------------------------------------------------
1 | /*===
2 | true
3 | ===*/
4 |
5 | function test() {
6 | var re = /[--]/;
7 | print(re.test('-'));
8 | }
9 |
10 | try {
11 | test();
12 | } catch (e) {
13 | print(e.stack || e);
14 | }
15 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-typedarray-set-undefined.js:
--------------------------------------------------------------------------------
1 | /*===
2 | TypeError
3 | still here
4 | ===*/
5 |
6 | var x = new Float64Array(2)
7 | try {
8 | x.set(undefined)
9 | } catch (e) {
10 | print(e.name);
11 | }
12 | print('still here');
13 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-expr-objectinit.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Object literal (object initializer) (E5 Section 11.1.5).
3 | */
4 |
5 | /*===
6 | object
7 | ===*/
8 |
9 | var t;
10 |
11 | t = {};
12 | print(typeof t);
13 |
14 | /* XXX: to be implemented */
15 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-lex-string.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Parsing of string literals (E5 Sections 7.8.4, B.1.2).
3 | */
4 |
5 | /*---
6 | {
7 | "skip": true
8 | }
9 | ---*/
10 |
11 | /* XXX: These are covered by other tests, but add some basic tests. */
12 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-lex-whitespace.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Test whitespace characters, E5 Section 7.2. Also see duk_lexer.c
3 | * is_whitespace() function.
4 | */
5 |
6 | /*---
7 | {
8 | "skip": true
9 | }
10 | ---*/
11 |
12 | /* XXX: add tests */
13 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-spec-program.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Program compilation and execution (E5 Sections 14, 10.4.1).
3 | */
4 |
5 | /*---
6 | {
7 | "skip": true
8 | }
9 | ---*/
10 |
11 | /* XXX: What to test which is not covered by other tests? */
12 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ALIGN_BY.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ALIGN_BY
2 | introduced: 1.3.0
3 | default: 8
4 | tags:
5 | - portability
6 | description: >
7 | Use N-byte alignment for 64-bit integers and IEEE doubles
8 | (supported values are 1, 4, and 8).
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ES6_OBJECT_SETPROTOTYPEOF.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ES6_OBJECT_SETPROTOTYPEOF
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - ecmascript2015
6 | description: >
7 | Provide the non-standard (ES6) Object.setPrototypeOf method.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_STRTAB_PROBE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_STRTAB_PROBE
2 | introduced: 1.1.0
3 | removed: 2.1.0
4 | default: true
5 | tags:
6 | - lowmemory
7 | description: >
8 | Use the default open addressing (probing) based string table algorithm.
9 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-string-endswith-memcmp-overflow.js:
--------------------------------------------------------------------------------
1 | /*===
2 | done
3 | ===*/
4 |
5 | try {
6 | var v3 = "c".repeat(536870912);
7 | var v4 = "base64".endsWith(v3);
8 | } catch (e) {
9 | print(e.stack || e);
10 | }
11 | print('done');
12 |
--------------------------------------------------------------------------------
/tests/google-v8-benchmark-v7/README.rst:
--------------------------------------------------------------------------------
1 | ===================
2 | Google V8 benchmark
3 | ===================
4 |
5 | Create a combined test file::
6 |
7 | $ make
8 |
9 | Run the combined test file e.g. as::
10 |
11 | $ time ./duk combined.js
12 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ES6_OBJECT_PROTO_PROPERTY.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ES6_OBJECT_PROTO_PROPERTY
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - ecmascript2015
6 | description: >
7 | Provide the non-standard (ES6) Object.prototype.__proto__ property.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_GCC_PRAGMAS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_GCC_PRAGMAS
2 | introduced: 1.0.0
3 | default: false
4 | tags:
5 | - portability
6 | description: >
7 | Use GCC-specific pragmas, e.g. "#pragma GCC diagnostic" to suppress
8 | unnecessary warnings.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_GET_MONOTONIC_TIME_WINDOWS_QPC.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_GET_MONOTONIC_TIME_WINDOWS_QPC
2 | introduced: 2.2.0
3 | default: false
4 | tags:
5 | - portability
6 | description: >
7 | Use QueryPerformanceCounter() for monotonic time on Windows.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_GLOBAL_BINDING.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_GLOBAL_BINDING
2 | introduced: 2.1.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | - experimental
7 | description: >
8 | Provide a 'globalThis' binding (https://github.com/tc39/proposal-global).
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_INJECT_HEAP_ALLOC_ERROR.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_INJECT_HEAP_ALLOC_ERROR
2 | introduced: 2.1.0
3 | default: false
4 | tags:
5 | - development
6 | description: >
7 | Force heap allocation to fail, value indicates the desired error position.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_PERFORMANCE_BUILTIN.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_PERFORMANCE_BUILTIN
2 | introduced: 2.2.0
3 | default: true
4 | tags:
5 | - performance-api
6 | description: >
7 | Provide a 'performance' global object based on https://www.w3.org/TR/hr-time/.
8 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_REGEXP_COMPILER_RECLIMIT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_REGEXP_COMPILER_RECLIMIT
2 | introduced: 1.3.0
3 | default: 10000
4 | tags:
5 | - portability
6 | - cstackdepth
7 | description: >
8 | RegExp compiler native call stack recursion limit.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_REGEXP_EXECUTOR_RECLIMIT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_REGEXP_EXECUTOR_RECLIMIT
2 | introduced: 1.3.0
3 | default: 10000
4 | tags:
5 | - portability
6 | - cstackdepth
7 | description: >
8 | RegExp executor native call stack recursion limit.
9 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_ASSERTIONS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_ASSERTIONS
2 | introduced: 1.0.0
3 | tags:
4 | - development
5 | - debug
6 | description: >
7 | Enable internal assert checks. These slow down execution considerably
8 | so only use when debugging.
9 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_DEBUG.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_DEBUG
2 | introduced: 1.0.0
3 | tags:
4 | - debug
5 | description: >
6 | Enable debug code in Duktape internals. Without this option other
7 | debugging options (such as DUK_OPT_DPRINT) have no effect.
8 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_JC.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_JC
2 | introduced: 1.0.0
3 | tags:
4 | - ecmascript
5 | description: >
6 | Disable support for the JC format. Reduces code footprint. An attempt
7 | to encode or decode the format causes an error.
8 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_JX.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_JX
2 | introduced: 1.0.0
3 | tags:
4 | - ecmascript
5 | description: >
6 | Disable support for the JX format. Reduces code footprint. An attempt
7 | to encode or decode the format causes an error.
8 |
--------------------------------------------------------------------------------
/examples/coffee/globals.coffee:
--------------------------------------------------------------------------------
1 |
2 | print '*** All globals'
3 | print(name) for name in Object.getOwnPropertyNames(this)
4 |
5 | print '*** Globals with a short name (<= 8 chars)'
6 | print(name) for name in Object.getOwnPropertyNames(this) when name.length <= 8
7 |
8 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bi-proxy-isarray.js:
--------------------------------------------------------------------------------
1 | /*===
2 | [1,2,3]
3 | true
4 | ===*/
5 |
6 | try {
7 | var P = new Proxy([1, 2, 3], {});
8 | print(JSON.stringify(P));
9 | print(Array.isArray(P));
10 | } catch (e) {
11 | print(e.stack || e);
12 | }
13 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bi-regexp-getter-inherit.js:
--------------------------------------------------------------------------------
1 | /*===
2 | TypeError
3 | done
4 | ===*/
5 |
6 | try {
7 | var R = /foo/;
8 | var O = Object.create(R);
9 | print(O.source);
10 | } catch (e) {
11 | print(e.name);
12 | }
13 | print('done');
14 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-compiler-gh2033.js:
--------------------------------------------------------------------------------
1 | /*===
2 | A
3 | B
4 | done
5 | ===*/
6 |
7 | print('A');
8 | Object.defineProperty(Array.prototype, 0, { set : function( ) {} });
9 | print('B');
10 | eval('if (true) {} /foo/.test("foo")');
11 | print('done');
12 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-compiler-gh2036.js:
--------------------------------------------------------------------------------
1 | /*===
2 | A
3 | B
4 | done
5 | ===*/
6 |
7 | print('A');
8 | Object.defineProperty(Array.prototype, 0, { get : Math.asin, set : function f( ) { } });
9 | print('B');
10 | eval('([ 123 ] / 2)');
11 | print('done');
12 |
--------------------------------------------------------------------------------
/tests/knownissues/test-bi-regexp-gh39-1.txt:
--------------------------------------------------------------------------------
1 | summary: requires leniency for non-standard regexps
2 | description: >
3 | \1 inside a regexp character class is invalid in ES5, but accepted by some engines.
4 | ---
5 | SyntaxError
6 | SyntaxError: invalid regexp escape
7 |
--------------------------------------------------------------------------------
/tests/perf/test-string-plain-concat.lua:
--------------------------------------------------------------------------------
1 | function test()
2 | local t
3 |
4 | for i=1,1 do
5 | t = ''
6 | for j=1,1e5 do
7 | t = t .. 'x'
8 | --print(#t)
9 | end
10 | end
11 | end
12 |
13 | test()
14 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_CLANG_PRAGMAS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_CLANG_PRAGMAS
2 | introduced: 2.5.0
3 | default: false
4 | tags:
5 | - portability
6 | description: >
7 | Use Clang-specific pragmas, e.g. "#pragma clang diagnostic" to suppress
8 | unnecessary warnings.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_FUZZILLI.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_FUZZILLI
2 | introduced: 3.0.0
3 | default: false
4 | tags:
5 | - fuzzing
6 | description: >
7 | Needed when running Fuzzilli fuzzing, enables access to duk_assert_wrapper()
8 | expected by the integration.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_PACKED_TVAL_POSSIBLE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_PACKED_TVAL_POSSIBLE
2 | introduced: 1.0.0
3 | removed: 1.4.0
4 | default: false
5 | tags:
6 | - portability
7 | description: >
8 | Define when packed, 8-byte duk_tval representation is possible.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_REFCOUNT16.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_REFCOUNT16
2 | introduced: 1.1.0
3 | default: false
4 | tags:
5 | - lowmemory
6 | - experimental
7 | - gc
8 | description: >
9 | Use a 16-bit reference count field (for low memory environments).
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_SHEBANG_COMMENTS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_SHEBANG_COMMENTS
2 | introduced: 2.1.0
3 | default: true
4 | tags:
5 | - ecmascript2015
6 | description: >
7 | Support parsing of a "shebang" comment ('#!...') on the first line of
8 | source text.
9 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_DDDPRINT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_DDDPRINT
2 | introduced: 1.0.0
3 | requires:
4 | - DUK_OPT_DEBUG
5 | tags:
6 | - debug
7 | description: >
8 | Enable even more debug printouts. Not recommended unless you have
9 | grep handy.
10 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-primary-objectliteral.js:
--------------------------------------------------------------------------------
1 | /*
2 | * PrimaryExpression -> ObjectLiteral
3 | */
4 |
5 | /*---
6 | {
7 | "skip": true
8 | }
9 | ---*/
10 |
11 | /*===
12 | ===*/
13 |
14 | /* ObjectLiteral */
15 |
16 | /* XXX: to be implemented */
17 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-string-object-props.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Test string object properties, which are currently implemented as
3 | * "virtual properties".
4 | */
5 |
6 | /*---
7 | {
8 | "skip": true
9 | }
10 | ---*/
11 |
12 | /* XXX: to be implemented */
13 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-expr-assignment.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Assignment operators (E5 Section 11.13).
3 | */
4 |
5 | /*---
6 | {
7 | "skip": true
8 | }
9 | ---*/
10 |
11 | /*===
12 | ===*/
13 |
14 | /* XXX: to be implemented; associativity etc: look at dev tests */
15 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-regexp-case-insensitive-backref.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Spot check of case insensitive backref matching.
3 | */
4 |
5 | var m;
6 |
7 | /*===
8 | fooFOO foo FOO
9 | ===*/
10 |
11 | m = /^(...)(\1)$/i.exec('fooFOO');
12 | print(m[0], m[1], m[2]);
13 |
--------------------------------------------------------------------------------
/tests/perf/test-string-array-concat.lua:
--------------------------------------------------------------------------------
1 | function test()
2 | local t
3 |
4 | for i=1,5e3 do
5 | t = {}
6 | for j=1,1e4 do
7 | t[j] = 'x'
8 | end
9 | t = table.concat(t)
10 | end
11 | end
12 |
13 | test()
14 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_AUGMENT_ERROR_THROW.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_AUGMENT_ERROR_THROW
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Augment an ECMAScript error object at throw time with Duktape.errThrow
8 | (if enabled).
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DPRINT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DPRINT
2 | introduced: 1.0.0
3 | removed: 2.0.0
4 | requires:
5 | - DUK_USE_DEBUG
6 | default: false
7 | tags:
8 | - debug
9 | description: >
10 | Enable debug printouts. Replaced by DUK_USE_DEBUG_LEVEL.
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ES6_UNICODE_ESCAPE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ES6_UNICODE_ESCAPE
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - ecmascript2015
6 | description: >
7 | Enable support for ES6 Unicode escape syntax ("\u{12345}") in source code
8 | and RegExps.
9 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_SPARC.h.in:
--------------------------------------------------------------------------------
1 | /* SPARC */
2 | #if defined(sparc) || defined(__sparc) || defined(__sparc__)
3 | #define DUK_F_SPARC
4 | #if defined(__LP64__) || defined(_LP64)
5 | #define DUK_F_SPARC64
6 | #else
7 | #define DUK_F_SPARC32
8 | #endif
9 | #endif
10 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-closure-outer.js:
--------------------------------------------------------------------------------
1 | /*===
2 | y 2
3 | x 1
4 | ===*/
5 |
6 | /* This had a bug at some point. */
7 |
8 | function f(x) {
9 | return function(y) {
10 | print('y', y);
11 | print('x', x);
12 | }
13 | }
14 |
15 | f(1)(2);
16 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-compiler-gh2026.js:
--------------------------------------------------------------------------------
1 | /*===
2 | A
3 | B
4 | done
5 | ===*/
6 |
7 | print('A');
8 | Object.defineProperty(Array.prototype, 0, { set: function () {} });
9 | print('B');
10 | eval("function\u0009\u2029w(\u000c)\u00a0{\u000d};");
11 | print('done');
12 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-func-closure-1.js:
--------------------------------------------------------------------------------
1 | /*===
2 | inner 1 2
3 | ===*/
4 |
5 | function foo(x) {
6 | return function(y) {
7 | print('inner', x, y);
8 | }
9 | }
10 |
11 | try {
12 | foo(1)(2);
13 | } catch (e) {
14 | print(e.name);
15 | }
16 |
--------------------------------------------------------------------------------
/tests/perf/test-string-plain-concat.rb:
--------------------------------------------------------------------------------
1 | def test()
2 | i = 0
3 | while i < 1 do
4 | t = ''
5 | j = 0
6 | while j < 1e5 do
7 | t += 'x'
8 | #print(t.length)
9 | #print("\n")
10 | j += 1
11 | end
12 | i += 1
13 | end
14 | end
15 |
16 | test()
17 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_CBOR_BUILTIN.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_CBOR_BUILTIN
2 | introduced: 2.5.0
3 | default: true
4 | tags:
5 | - codec
6 | - cbor
7 | - experimental
8 | description: >
9 | Provide a CBOR built-in with CBOR.encode() and CBOR.decode() functions.
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DEBUG_LEVEL.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DEBUG_LEVEL
2 | introduced: 2.0.0
3 | default: 0
4 | tags:
5 | - debug
6 | description: >
7 | Set debug print level when DUK_USE_DEBUG is enabled. The level can be
8 | 0 (minimal), 1 (verbose), 2 (very verbose).
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ESBC_MAX_BYTES.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ESBC_MAX_BYTES
2 | introduced: 1.0.0
3 | requires:
4 | - DUK_USE_ESBC_LIMITS
5 | default: 0x7fff0000
6 | tags:
7 | - ecmascript
8 | description: >
9 | Maximum byte count for compiled function bytecode.
10 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_FUNC_STMT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_FUNC_STMT
2 | introduced: 1.0.0
3 | removed: 1.0.0
4 | related:
5 | - DUK_OPT_NO_NONSTD_FUNC_STMT
6 | tags:
7 | - ecmascript
8 | description: >
9 | Removed, use DUK_OPT_NO_NONSTD_FUNC_STMT instead.
10 |
--------------------------------------------------------------------------------
/config/platforms/platform_genericunix.h.in:
--------------------------------------------------------------------------------
1 | #define DUK_USE_DATE_NOW_GETTIMEOFDAY
2 | #define DUK_USE_DATE_TZO_GMTIME_R
3 | #define DUK_USE_DATE_PRS_STRPTIME
4 | #define DUK_USE_DATE_FMT_STRFTIME
5 | #include
6 | #include
7 | #define DUK_USE_OS_STRING "unknown"
8 |
--------------------------------------------------------------------------------
/tests/api/test-hello-world.c:
--------------------------------------------------------------------------------
1 | /*===
2 | Hello world from ECMAScript!
3 | Hello world from C!
4 | ===*/
5 |
6 | void test(duk_context *ctx) {
7 | duk_push_string(ctx, "print('Hello world from ECMAScript!');");
8 | duk_eval(ctx);
9 | printf("Hello world from C!\n");
10 | }
11 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-regexp-result-inherited-index-gh2203.js:
--------------------------------------------------------------------------------
1 | // https://github.com/svaarala/duktape/issues/2203
2 |
3 | /*===
4 | fundefinedo
5 | ===*/
6 |
7 | Object.defineProperty(Array.prototype, 0, { set: function () { } });
8 | print(String('foo'.replace(/(o)|(o)/)));
9 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-expr-newtarget-function-code.js:
--------------------------------------------------------------------------------
1 | /*===
2 | undefined
3 | function
4 | ===*/
5 |
6 | function test() {
7 | print(typeof new.target);
8 | }
9 |
10 | try {
11 | test();
12 | new test();
13 | } catch (e) {
14 | print(e.stack || e);
15 | }
16 |
--------------------------------------------------------------------------------
/tests/octane/README.rst:
--------------------------------------------------------------------------------
1 | ================
2 | Octane benchmark
3 | ================
4 |
5 | Example of running manually:
6 |
7 | ```
8 | $ git clone https://github.com/chromium/octane.git
9 | $ cd octane
10 | $ ../duk.O2 base.js splay.js ../tests/octane/duktape_harness.js
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE
2 | introduced: 1.0.0
3 | removed: 2.0.0
4 | default: true
5 | tags:
6 | - ecmascript
7 | - compliance
8 | description: >
9 | Replaced by DUK_USE_ES6_REGEXP_SYNTAX.
10 |
--------------------------------------------------------------------------------
/dist-files/Makefile.jsoncbor:
--------------------------------------------------------------------------------
1 | #
2 | # Example Makefile for building the jsoncbor example
3 | #
4 |
5 | CC = gcc
6 |
7 | jsoncbor:
8 | $(CC) -o $@ -std=c99 -Wall -Wextra -O2 -Isrc -Iextras/cbor \
9 | src/duktape.c extras/cbor/duk_cbor.c extras/cbor/jsoncbor.c \
10 | -lm
11 |
--------------------------------------------------------------------------------
/tests/api/test-bug-push-buffer-semicolon.c:
--------------------------------------------------------------------------------
1 | /*
2 | * https://github.com/svaarala/duktape/issues/500
3 | */
4 |
5 | /*===
6 | still here
7 | ===*/
8 |
9 | void test(duk_context *ctx) {
10 | (void) (duk_push_buffer(ctx, 123, 0), "dummy");
11 | printf("still here\n");
12 | }
13 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-unary-minus-inplace.js:
--------------------------------------------------------------------------------
1 | /*===
2 | NaN
3 | foo
4 | ===*/
5 |
6 | function test() {
7 | var foo = 'foo';
8 |
9 | print(-foo);
10 | print(foo);
11 | }
12 |
13 | try {
14 | test();
15 | } catch (e) {
16 | print(e.stack || e);
17 | }
18 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-primary-parens.js:
--------------------------------------------------------------------------------
1 | /*
2 | * PrimaryExpression -> parenthesized expression
3 | */
4 |
5 | /*---
6 | {
7 | "skip": true
8 | }
9 | ---*/
10 |
11 | /*===
12 | ===*/
13 |
14 | /* Parenthesized expression */
15 |
16 | /* XXX: to be implemented */
17 |
--------------------------------------------------------------------------------
/tests/knownissues/test-bi-json-enc-proxy-2.txt:
--------------------------------------------------------------------------------
1 | summary: Proxy getOwnPropertyDescriptor trap is unimplemented
2 | ---
3 | {"foo":234}
4 | {"foo":345}
5 | ownKeys should be called
6 | {"foo":"key-foo","quux":"key-quux"}
7 | ownKeys should be called
8 | {"foo":"key-foo","quux":"key-quux"}
9 |
--------------------------------------------------------------------------------
/util/check_align.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | for off in 0 1; do ./check_align uint16_t $off; done
4 | for off in 0 1 2 3; do ./check_align uint32_t $off; done
5 | for off in 0 1 2 3 4 5 6 7; do ./check_align uint64_t $off; done
6 | for off in 0 1 2 3 4 5 6 7; do ./check_align double $off; done
7 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DATE_PRS_STRPTIME.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DATE_PRS_STRPTIME
2 | introduced: 1.0.0
3 | default: false
4 | tags:
5 | - date
6 | - portability
7 | description: >
8 | Use strptime() to parse a platform specific datetime string into ECMAScript
9 | time.
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ESBC_MAX_LINENUMBER.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ESBC_MAX_LINENUMBER
2 | introduced: 1.0.0
3 | requires:
4 | - DUK_USE_ESBC_LIMITS
5 | default: 0x7fff0000
6 | tags:
7 | - ecmascript
8 | description: >
9 | Maximum line number for compiled function bytecode.
10 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_OCTAL_SUPPORT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_OCTAL_SUPPORT
2 | introduced: 1.0.0
3 | tags:
4 | - ecmascript
5 | description: >
6 | Disable optional octal number support (ECMAScript E5/E5.1
7 | Annex B: http://www.ecma-international.org/ecma-262/5.1/#sec-B).
8 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-unary-bitwise-not-inplace.js:
--------------------------------------------------------------------------------
1 | /*===
2 | -1
3 | foo
4 | ===*/
5 |
6 | function test() {
7 | var foo = 'foo';
8 |
9 | print(~foo);
10 | print(foo);
11 | }
12 |
13 | try {
14 | test();
15 | } catch (e) {
16 | print(e.stack || e);
17 | }
18 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-unary-plus-inplace-modify.js:
--------------------------------------------------------------------------------
1 | /*===
2 | NaN
3 | foo
4 | ===*/
5 |
6 | function test() {
7 | var foo = 'foo';
8 |
9 | print(+foo);
10 | print(foo);
11 | }
12 |
13 | try {
14 | test();
15 | } catch (e) {
16 | print(e.stack || e);
17 | }
18 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-catch-binding.js:
--------------------------------------------------------------------------------
1 | /*===
2 | 123
3 | foo
4 | 123
5 | ===*/
6 |
7 | function foo(e) {
8 | print(e);
9 |
10 | try {
11 | throw 'foo'
12 | } catch (e) {
13 | print(e);
14 | }
15 |
16 | print(e);
17 | }
18 |
19 | foo(123);
20 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-stmt-block.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Block statement (E5 Section 12.1).
3 | */
4 |
5 | /*===
6 | before
7 | inside 1
8 | inside 2
9 | after
10 | ===*/
11 |
12 | print('before');
13 | {
14 | print('inside 1');
15 | print('inside 2');
16 | }
17 | print('after');
18 |
--------------------------------------------------------------------------------
/tests/knownissues/test-bi-typedarray-nan-handling-1.txt:
--------------------------------------------------------------------------------
1 | summary: NaN sign bit depends on platform
2 | ---
3 | NaN handling test
4 | through dataview
5 | sign: 0
6 | expt: 2047
7 | mantissa is non-zero
8 | through float64array
9 | read back value: NaN
10 | read back value is NaN: true
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ASSERTIONS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ASSERTIONS
2 | introduced: 1.0.0
3 | default: false
4 | tags:
5 | - development
6 | - debug
7 | description: >
8 | Enable internal assert checks. These slow down execution considerably
9 | so only use when debugging.
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DATE_PARSE_STRING.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DATE_PARSE_STRING
2 | introduced: 1.3.0
3 | default: false
4 | tags:
5 | - date
6 | - portability
7 | description: >
8 | Optional macro for parsing a date in a platform dependent manner,
9 | see datetime.rst.
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_FATAL_MAXLEN.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_FATAL_MAXLEN
2 | introduced: 2.2.0
3 | default: 128
4 | tags:
5 | - portability
6 | description: >
7 | Maximum length of fatal error message string when error is thrown by
8 | Duktape internals, in particular for uncaught errors.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_GET_MONOTONIC_TIME_CLOCK_GETTIME.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_GET_MONOTONIC_TIME_CLOCK_GETTIME
2 | introduced: 2.2.0
3 | default: false
4 | tags:
5 | - portability
6 | description: >
7 | Use clock_gettime(CLOCK_MONOTONIC, ...) for monotonic time on POSIX
8 | platforms.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_HASHBYTES_UNALIGNED_U32_ACCESS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_HASHBYTES_UNALIGNED_U32_ACCESS
2 | introduced: 1.0.0
3 | removed: 1.4.0
4 | default: false
5 | tags:
6 | - portability
7 | description: >
8 | Allow unaligned 32-bit unsigned integer access in hashbytes algorithm.
9 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_GC_TORTURE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_GC_TORTURE
2 | introduced: 1.0.0
3 | tags:
4 | - gc
5 | - memory
6 | - development
7 | description: >
8 | Development time option: force full mark-and-sweep on every allocation to
9 | stress test memory management.
10 |
--------------------------------------------------------------------------------
/config/header-snippets/reject_fast_math.h.in:
--------------------------------------------------------------------------------
1 | /* GCC/clang inaccurate math would break compliance and probably duk_tval,
2 | * so refuse to compile. Relax this if -ffast-math is tested to work.
3 | */
4 | #if defined(__FAST_MATH__)
5 | #error __FAST_MATH__ defined, refusing to compile
6 | #endif
7 |
--------------------------------------------------------------------------------
/examples/alloc-logging/README.rst:
--------------------------------------------------------------------------------
1 | ======================
2 | Allocator with logging
3 | ======================
4 |
5 | Example allocator that writes all memory alloc/realloc/free calls into a
6 | log file so that memory usage can replayed later. This is useful to e.g.
7 | optimize pool sizes.
8 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-array-slice-end.js:
--------------------------------------------------------------------------------
1 | /*===
2 | 3,4,5
3 | 3,4,5
4 | ===*/
5 |
6 | /* Broken at some point: end would not default to 'length' */
7 |
8 | try {
9 | print([1,2,3,4,5].slice(2));
10 | print([1,2,3,4,5].slice(2, 5));
11 | } catch (e) {
12 | print(e);
13 | }
14 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-for-var-in.js:
--------------------------------------------------------------------------------
1 | /*===
2 | 0
3 | 1
4 | 2
5 | 0
6 | 1
7 | 2
8 | ===*/
9 |
10 | /* Latter variant was broken at some point */
11 |
12 | var test = 'Foo';
13 |
14 | for (i in test) {
15 | print(i)
16 | }
17 |
18 | for (var i in test) {
19 | print(i)
20 | }
21 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ARCH_STRING.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ARCH_STRING
2 | introduced: 1.0.0
3 | default:
4 | string: "unknown"
5 | tags:
6 | - portability
7 | description: >
8 | Human-readable architecture string used in e.g. Duktape.env and debugger
9 | protocol (example: x64).
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_BRANCH_HINTS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_BRANCH_HINTS
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - portability
6 | description: >
7 | Use branch hints if the compiler supports them.
8 |
9 | # XXX: Unused now, DUK_LIKELY and DUK_UNLIKELY are used instead.
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DATE_FORMAT_STRING.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DATE_FORMAT_STRING
2 | introduced: 1.3.0
3 | default: false
4 | tags:
5 | - date
6 | - portability
7 | description: >
8 | Optional macro for formatting a date in a platform dependent manner,
9 | see datetime.rst.
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_HOBJECT_ARRAY_MINGROW_ADD.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_HOBJECT_ARRAY_MINGROW_ADD
2 | introduced: 2.1.0
3 | default: 16
4 | tags:
5 | - performance
6 | description: >
7 | Technical internal parameter, see sources for details. Only adjust if
8 | you've looked at the internals.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_OS_STRING.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_OS_STRING
2 | introduced: 1.0.0
3 | default:
4 | string: "unknown"
5 | tags:
6 | - portability
7 | description: >
8 | Human-readable operating system string used in e.g. Duktape.env and debugger
9 | protocol (example: linux).
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_STRTAB_CHAIN_SIZE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_STRTAB_CHAIN_SIZE
2 | introduced: 1.1.0
3 | removed: 2.1.0
4 | requires:
5 | - DUK_USE_STRTAB_CHAIN
6 | default: false
7 | tags:
8 | - lowmemory
9 | description: >
10 | Define stringtable size for DUK_USE_STRTAB_CHAIN.
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_STRTAB_MINSIZE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_STRTAB_MINSIZE
2 | introduced: 2.1.0
3 | default: 1024
4 | tags:
5 | - performance
6 | - lowmemory
7 | description: >
8 | Minimum size for Duktape heap string table, must be 2^N, and should never
9 | be lower than 64.
10 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_ES6_OBJECT_SETPROTOTYPEOF.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_ES6_OBJECT_SETPROTOTYPEOF
2 | introduced: 1.0.0
3 | tags:
4 | - ecmascript
5 | - ecmascript6
6 | description: >
7 | Disable the non-standard (ES6) Object.setPrototypeOf method which
8 | is enabled by default.
9 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_PPC.h.in:
--------------------------------------------------------------------------------
1 | /* PowerPC */
2 | #if defined(__powerpc) || defined(__powerpc__) || defined(__PPC__)
3 | #define DUK_F_PPC
4 | #if defined(__PPC64__) || defined(__LP64__) || defined(_LP64)
5 | #define DUK_F_PPC64
6 | #else
7 | #define DUK_F_PPC32
8 | #endif
9 | #endif
10 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-func-without-args.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Development time testcase for a function without arguments
3 | */
4 |
5 | /*===
6 | hello world
7 | ===*/
8 |
9 | try {
10 | eval("(function() { print('hello world'); })();");
11 | } catch (e) {
12 | print(e.name);
13 | }
14 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-set-arraylength-negzero.js:
--------------------------------------------------------------------------------
1 | /*===
2 | 0
3 | ===*/
4 |
5 | function test() {
6 | var arr = [ 'foo', 'bar', 'quux' ];
7 | arr.length = -0;
8 | print(arr.length);
9 | }
10 |
11 | try {
12 | test();
13 | } catch (e) {
14 | print(e.stack || e);
15 | }
16 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-expr-lhs-this.js:
--------------------------------------------------------------------------------
1 | /*
2 | * 'this' as a left-hand side expression (E5 Sections 11.2, 11.13,
3 | * 11.3.1, 11.3.2, 11.4.4, 11.4.5).
4 | */
5 |
6 | /*===
7 | ReferenceError
8 | ===*/
9 |
10 | try {
11 | this = 1;
12 | } catch(e) {
13 | print(e.name);
14 | }
15 |
--------------------------------------------------------------------------------
/tests/perf/test-empty-loop.js:
--------------------------------------------------------------------------------
1 | if (typeof print !== 'function') { print = console.log; }
2 |
3 | function test() {
4 | var i;
5 |
6 | for (i = 0; i < 1e8; i++) {
7 | }
8 | }
9 |
10 | try {
11 | test();
12 | } catch (e) {
13 | print(e.stack || e);
14 | throw e;
15 | }
16 |
--------------------------------------------------------------------------------
/website/resizeicons.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Resize touch icon starting from touch_icon_1024x1024.png.
4 | #
5 |
6 | for sz in 57 60 72 114 120 144 152; do
7 | convert touch_icon_1024x1024.png -resize ${sz}x${sz} touch_icon_${sz}x${sz}.png
8 | file touch_icon_${sz}x${sz}.png
9 | done
10 |
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_COMPILER_STRING.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_COMPILER_STRING
2 | introduced: 1.0.0
3 | default:
4 | string: "unknown"
5 | tags:
6 | - portability
7 | description: >
8 | Human-readable compiler string used in e.g. Duktape.env and debugger
9 | protocol (example: gcc).
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DDDPRINT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DDDPRINT
2 | introduced: 1.0.0
3 | removed: 2.0.0
4 | default: false
5 | tags:
6 | - debug
7 | description: >
8 | Enable even more debug printouts. Not recommended unless you have
9 | grep handy. Replaced by DUK_USE_DEBUG_LEVEL.
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_HOBJECT_ENTRY_MINGROW_ADD.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_HOBJECT_ENTRY_MINGROW_DIVISOR
2 | introduced: 2.1.0
3 | default: 8
4 | tags:
5 | - performance
6 | description: >
7 | Technical internal parameter, see sources for details. Only adjust if
8 | you've looked at the internals.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_HOBJECT_ENTRY_MINGROW_DIVISOR.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_HOBJECT_ENTRY_MINGROW_ADD
2 | introduced: 2.1.0
3 | default: 16
4 | tags:
5 | - performance
6 | description: >
7 | Technical internal parameter, see sources for details. Only adjust if
8 | you've looked at the internals.
9 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_ES6_OBJECT_PROTO_PROPERTY.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_ES6_OBJECT_PROTO_PROPERTY
2 | introduced: 1.0.0
3 | tags:
4 | - ecmascript
5 | - ecmascript6
6 | description: >
7 | Disable the non-standard (ES6) Object.prototype.__proto__ property
8 | which is enabled by default.
9 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_SOURCE_NONBMP.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_SOURCE_NONBMP
2 | introduced: 1.0.0
3 | tags:
4 | - ecmascript
5 | description: >
6 | Disable accurate Unicode support for non-BMP characters in source code.
7 | Non-BMP characters are then always accepted as identifier characters.
8 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-compiler-gh2035.js:
--------------------------------------------------------------------------------
1 | /*===
2 | A
3 | B
4 | done
5 | ===*/
6 |
7 | print('A');
8 | Object.defineProperty(Array.prototype, 2, { get : Math.random, set : function f ( ) { } } ) ;
9 | print('B');
10 | eval ( "function\u0009\u2029w(\u000C)\u00A0{\u000D};" ) ;
11 | print('done');
12 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-props-asize-gh2023-2.js:
--------------------------------------------------------------------------------
1 | /*
2 | * https://github.com/svaarala/duktape/issues/2023
3 | *
4 | * Modified variant.
5 | */
6 |
7 | /*===
8 | done
9 | ===*/
10 |
11 | var input = [];
12 | input[65536] = 0;
13 | var output = input.map(Math.cos);
14 |
15 | print('done');
16 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-switch-code-before-case.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Any code before a case block must be rejected.
3 | */
4 |
5 | /*===
6 | SyntaxError
7 | ===*/
8 |
9 | try {
10 | eval('switch (2) { print("hello"); case 2: print("match 2"); }');
11 | } catch (e) {
12 | print(e.name);
13 | }
14 |
--------------------------------------------------------------------------------
/tests/knownissues/test-bi-array-push-maxlen-1.txt:
--------------------------------------------------------------------------------
1 | summary: array length above 2^32-1 not supported
2 | ---
3 | array
4 | RangeError
5 | 4294967295 undefined
6 | RangeError
7 | 4294967293 undefined undefined undefined undefined
8 | 4294967295 foo bar
9 | non-array
10 | RangeError: invalid length
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_AUGMENT_ERROR_CREATE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_AUGMENT_ERROR_CREATE
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Augment an ECMAScript error object at creation with tracedata or
8 | fileName/lineNumber, or Duktape.errCreate (if enabled).
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DATE_GET_LOCAL_TZOFFSET.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DATE_GET_LOCAL_TZOFFSET
2 | introduced: 1.3.0
3 | default: false
4 | tags:
5 | - date
6 | - portability
7 | description: >
8 | Mandatory macro for getting the local time offset for a given datetime,
9 | see datetime.rst.
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_HOBJECT_ARRAY_MINGROW_DIVISOR.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_HOBJECT_ARRAY_MINGROW_DIVISOR
2 | introduced: 2.1.0
3 | default: 8
4 | tags:
5 | - performance
6 | description: >
7 | Technical internal parameter, see sources for details. Only adjust if
8 | you've looked at the internals.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_HOBJECT_LAYOUT_2.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_HOBJECT_LAYOUT_2
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - portability
6 | description: >
7 | Use layout variant 2 for object properties. Layout 2 can be used on any
8 | target (including targets with alignment restrictions).
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - portability
6 | description: >
7 | Provide default allocation functions.
8 |
9 | At the moment this option should be enabled.
10 |
--------------------------------------------------------------------------------
/docker/duktape-clang-format/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | cat >/tmp/stdin.zip
6 | mkdir reformat && cd reformat
7 | unzip -q /tmp/stdin.zip
8 |
9 | clang-format-12 -i `find src-input -type f | egrep '(.c|.h|.c.in|.c.in)'`
10 |
11 | zip -1 -q -r /tmp/stdout.zip *
12 | cat /tmp/stdout.zip
13 |
--------------------------------------------------------------------------------
/src-input/duk_hbuffer_assert.c:
--------------------------------------------------------------------------------
1 | /*
2 | * duk_hbuffer assertion helpers
3 | */
4 |
5 | #include "duk_internal.h"
6 |
7 | #if defined(DUK_USE_ASSERTIONS)
8 |
9 | DUK_INTERNAL void duk_hbuffer_assert_valid(duk_hbuffer *h) {
10 | DUK_ASSERT(h != NULL);
11 | }
12 |
13 | #endif /* DUK_USE_ASSERTIONS */
14 |
--------------------------------------------------------------------------------
/tests/api/test-concat.c:
--------------------------------------------------------------------------------
1 | /*===
2 | result: foo123true
3 | ===*/
4 |
5 | void test(duk_context *ctx) {
6 | duk_push_string(ctx, "foo");
7 | duk_push_int(ctx, 123);
8 | duk_push_true(ctx);
9 | duk_concat(ctx, 3);
10 |
11 | printf("result: %s\n", duk_get_string(ctx, -1));
12 | duk_pop(ctx);
13 | }
14 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bi-cbor-enc-symbol.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Test for Symbol encoding behavior; for now encoded as an empty object.
3 | */
4 |
5 | /*===
6 | a0
7 | ===*/
8 |
9 | try {
10 | print(Duktape.enc('hex', CBOR.encode(Symbol('foo'))));
11 | } catch (e) {
12 | print(e.stack || e);
13 | }
14 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-base64-dec-zerolen-dynamic-buffer-gh2027.js:
--------------------------------------------------------------------------------
1 | /*===
2 | t1
3 | t2
4 | done
5 | ===*/
6 |
7 | print('t1');
8 | var t1 = Duktape.dec('base64', ''); // create zero-size dynamic plain buffer
9 | print('t2');
10 | var t2 = Duktape.dec('base64', t1); // segfault
11 | print('done');
12 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-compiler-gh2025.js:
--------------------------------------------------------------------------------
1 | /*===
2 | A
3 | B
4 | done
5 | ===*/
6 |
7 | var j;
8 | var str;
9 | print('A');
10 | Object.defineProperty(Array.prototype, "0", { set: function () {}, configurable: true });
11 | print('B');
12 | eval( 'for (j in this){\nstr+=j;\n}' );
13 | print('done');
14 |
--------------------------------------------------------------------------------
/tests/perf/test-empty-loop-step3.js:
--------------------------------------------------------------------------------
1 | if (typeof print !== 'function') { print = console.log; }
2 |
3 | function test() {
4 | var i;
5 |
6 | for (i = 0; i < 3e8; i += 3) {
7 | }
8 | }
9 |
10 | try {
11 | test();
12 | } catch (e) {
13 | print(e.stack || e);
14 | throw e;
15 | }
16 |
--------------------------------------------------------------------------------
/tests/perf/test-string-array-concat.pl:
--------------------------------------------------------------------------------
1 | sub test {
2 | my $i, $j, @t, $ign;
3 |
4 | for ($i = 0; $i < 5e3; $i++) {
5 | @t = ();
6 | for ($j = 0; $j < 1e4; $j++) {
7 | $t[$j] = 'x';
8 | }
9 | $ign = join('', @t);
10 | }
11 | }
12 |
13 | test();
14 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ATAN2_WORKAROUNDS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ATAN2_WORKAROUNDS
2 | introduced: 2.0.0
3 | default: false
4 | tags:
5 | - portability
6 | description: >
7 | Enable workarounds to common atan2() semantics issues. At least Cygwin/MinGW
8 | has such issues, see test-bug-mingw-math-issues.js.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_FUNC_FILENAME_PROPERTY.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_FUNC_FILENAME_PROPERTY
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | - compliance
7 | description: >
8 | Add a non-standard ".fileName" property to function instances. Disabling
9 | reduces footprint.
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_PARANOID_MATH.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_PARANOID_MATH
2 | introduced: 1.0.0
3 | default: false
4 | tags:
5 | - portability
6 | description: >
7 | Rely as little as possible on compiler behavior for NaN comparison,
8 | signed zero handling, etc. May be needed for (very) broken compilers.
9 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_PROMISE_BUILTIN.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_PROMISE_BUILTIN
2 | introduced: 2.2.0
3 | default: false # disabled until fully functional
4 | tags:
5 | - ecmascript
6 | description: >
7 | Enable Promise built-in.
8 |
9 | At present entirely non-functional, and disabled by default.
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_SYMBOL_BUILTIN.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_SYMBOL_BUILTIN
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - ecmascript2015
6 | description: >
7 | Provide ES6 Symbol built-ins.
8 |
9 | Even with the built-ins disabled, symbols created by C code are still
10 | supported.
11 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_DEBUGGER_FWD_PRINTALERT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_DEBUGGER_FWD_PRINTALERT
2 | introduced: 1.2.0
3 | requires:
4 | - DUK_OPT_DEBUGGER_SUPPORT
5 | tags:
6 | - debugger
7 | description: >
8 | Forward calls to the built-in print() and alert() function to the debug
9 | client.
10 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_DPRINT_COLORS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_DPRINT_COLORS
2 | introduced: 1.0.0
3 | tags:
4 | - debug
5 | description: >
6 | Enable coloring of debug prints with ANSI escape codes
7 | (http://en.wikipedia.org/wiki/ANSI_escape_code). The behavior is not
8 | sensitive to terminal settings.
9 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_ZERO_BUFFER_DATA.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_ZERO_BUFFER_DATA
2 | introduced: 1.0.0
3 | tags:
4 | - memory
5 | - ecmascript
6 | description: >
7 | By default Duktape zeroes data allocated for buffer values. Define
8 | this to disable the zeroing (perhaps for performance reasons).
9 |
--------------------------------------------------------------------------------
/src-input/duk_hstring_assert.c:
--------------------------------------------------------------------------------
1 | /*
2 | * duk_hstring assertion helpers.
3 | */
4 |
5 | #include "duk_internal.h"
6 |
7 | #if defined(DUK_USE_ASSERTIONS)
8 |
9 | DUK_INTERNAL void duk_hstring_assert_valid(duk_hstring *h) {
10 | DUK_ASSERT(h != NULL);
11 | }
12 |
13 | #endif /* DUK_USE_ASSERTIONS */
14 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-assert-cbor-encode-gh2316.js:
--------------------------------------------------------------------------------
1 | // https://github.com/svaarala/duktape/issues/2316
2 |
3 | /*===
4 | done
5 | ===*/
6 |
7 | function main() {
8 | var v0 = [];
9 | var v4 = Duktape.dec("base64",v0);
10 | var v5 = CBOR.encode(v4);
11 | }
12 | main();
13 | print('done');
14 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-exec-timeout-plain.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Execution timeout: plain bytecode execution
3 | */
4 |
5 | /*---
6 | {
7 | "skip": true
8 | }
9 | ---*/
10 |
11 | function test() {
12 | for (;;) ;
13 | }
14 |
15 | try {
16 | test();
17 | } catch (e) {
18 | print(e.name);
19 | }
20 |
--------------------------------------------------------------------------------
/tests/knownissues/test-dev-object-literal-method-computed-1.txt:
--------------------------------------------------------------------------------
1 | summary: computed name for object literal method shorthand not yet implemented
2 | ---
3 | computed name for method shorthand failed (not yet supported?)
4 | SyntaxError
5 | computed name for method shorthand failed (not yet supported?)
6 | SyntaxError
7 |
--------------------------------------------------------------------------------
/tests/perf/test-string-array-concat.rb:
--------------------------------------------------------------------------------
1 | def test()
2 | i = 0
3 | while i < 5e3 do
4 | t = []
5 | j = 0
6 | while j < 1e4 do
7 | t[j] = 'x'
8 | j += 1
9 | end
10 | t = t.join()
11 | i += 1
12 | end
13 | end
14 |
15 | test()
16 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_FLEX_C99.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_FLEX_C99
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - portability
6 | description: >
7 | Use C99 flexible array member for defining variable size structures.
8 |
9 | # XXX: currently unused, remove or mark unused so doesn't get emitted?
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_REFLECT_BUILTIN.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_REFLECT_BUILTIN
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - ecmascript2015
6 | description: >
7 | Provide a Reflect built-in. The ES6 Reflect object provides a collection of
8 | methods for examining and manipulating objects at runtime.
9 |
--------------------------------------------------------------------------------
/examples/codepage-conv/duk_codepage_conv.h:
--------------------------------------------------------------------------------
1 | #if !defined(DUK_CODEPAGE_CONV_H_INCLUDED)
2 | #define DUK_CODEPAGE_CONV_H_INCLUDED
3 |
4 | #include "duktape.h"
5 |
6 | void duk_decode_string_codepage(duk_context *ctx, const char *str, size_t len, unsigned int *codepage);
7 |
8 | #endif /* DUK_CODEPAGE_CONV_H_INCLUDED */
9 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-regexp-leading-zero-quant.js:
--------------------------------------------------------------------------------
1 | /*===
2 | false
3 | true
4 | ===*/
5 |
6 | /* Leading zeroes are allowed and the quantifier is still parsed as
7 | * decimal.
8 | */
9 |
10 | r = /x{010,011}/;
11 | print(r.test('xxxxxxxx'));
12 |
13 | r = /x{010,011}/;
14 | print(r.test('xxxxxxxxxx'));
15 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-stmt-continue.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Continue statement (E5 Section 12.7).
3 | */
4 |
5 | /*---
6 | {
7 | "skip": true
8 | }
9 | ---*/
10 |
11 | /*===
12 | ===*/
13 |
14 | /* XXX: to be implemented */
15 | /* XXX: explicit check for behavior with switch (which does not respect continue) */
16 |
--------------------------------------------------------------------------------
/tests/knownissues/test-bi-json-enc-proxy-1.txt:
--------------------------------------------------------------------------------
1 | summary: JSON enumeration behavior for Proxy targets is incomplete and uses 'enumerate' trap instead of 'ownKeys' trap
2 | ---
3 | {"foo":234}
4 | {"foo":345}
5 | enumerate should not be called
6 | {"quux":"key-quux"}
7 | enumerate should not be called
8 | {"quux":"key-quux"}
9 |
--------------------------------------------------------------------------------
/util/example_user_builtins2.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # User builtins can be specified in multiple files; you can apply this over
3 | # util/example_user_builtins1.yaml.
4 | #
5 |
6 | objects:
7 |
8 | - id: bi_global
9 | modify: true
10 |
11 | properties:
12 | - key: meaningOfLife
13 | value: 42
14 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ALIGN_4.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ALIGN_4
2 | introduced: 1.0.0
3 | removed: 1.3.0
4 | related:
5 | - DUK_USE_ALIGN_BY
6 | default: false
7 | tags:
8 | - portability
9 | description: >
10 | Use 4-byte alignment for 64-bit integers and IEEE doubles.
11 | Replaced by DUK_USE_ALIGN_BY.
12 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ALIGN_8.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ALIGN_8
2 | introduced: 1.0.0
3 | removed: 1.3.0
4 | related:
5 | - DUK_USE_ALIGN_BY
6 | default: false
7 | tags:
8 | - portability
9 | description: >
10 | Use 8-byte alignment for 64-bit integers and IEEE doubles.
11 | Replaced by DUK_USE_ALIGN_BY.
12 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DATE_NOW_GETTIMEOFDAY.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DATE_NOW_GETTIMEOFDAY
2 | introduced: 1.0.0
3 | default: false
4 | tags:
5 | - date
6 | - portability
7 | description: >
8 | Use gettimeofday() to get current datetime. When enabled, appropriate
9 | date/time headers must be included.
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DEBUG.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DEBUG
2 | introduced: 1.0.0
3 | default: false
4 | tags:
5 | - debug
6 | description: >
7 | Enable debug code in Duktape internals. Without this option other
8 | debugging options (such as DUK_USE_DEBUG_LEVEL and DUK_USE_DEBUG_WRITE)
9 | have no effect.
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_HEX_FASTPATH.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_HEX_FASTPATH
2 | introduced: 1.4.0
3 | default: true
4 | tags:
5 | - performance
6 | - fastpath
7 | - lowmemory
8 | description: >
9 | Enable fast path for hex encode/decode. The fast path uses a lookup
10 | table at a small cost in footprint.
11 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_FUNC_NONSTD_CALLER_PROPERTY.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_FUNC_NONSTD_CALLER_PROPERTY
2 | introduced: 1.0.0
3 | removed: 1.0.0
4 | related:
5 | - DUK_OPT_NONSTD_FUNC_CALLER_PROPERTY
6 | tags:
7 | - ecmascript
8 | description: >
9 | Removed, use DUK_OPT_NONSTD_FUNC_CALLER_PROPERTY instead.
10 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_FUNC_NONSTD_SOURCE_PROPERTY.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_FUNC_NONSTD_SOURCE_PROPERTY
2 | introduced: 1.0.0
3 | removed: 1.0.0
4 | related:
5 | - DUK_OPT_NONSTD_FUNC_SOURCE_PROPERTY
6 | tags:
7 | - ecmascript
8 | description: >
9 | Removed, use DUK_OPT_NONSTD_FUNC_SOURCE_PROPERTY instead.
10 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_STRICT_DECL.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_STRICT_DECL
2 | introduced: 1.1.0
3 | tags:
4 | - ecmascript
5 | - experimental
6 | description: >
7 | Disable support for "use strict" declaration so that ECMAScript code is
8 | always executed in non-strict mode. Duktape/C functions remain strict.
9 |
--------------------------------------------------------------------------------
/misc/chaos.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2
2 | #
3 | # $ ./duk test-dev-chaos.js | python chaos.py > chaos.raw
4 | # $ sox -r 8k -e unsigned -b 8 -c 1 chaos.raw chaos.wav
5 |
6 | import os
7 | import sys
8 |
9 | data = sys.stdin.read()
10 | data = data.strip()
11 | data = data.decode('hex')
12 | sys.stdout.write(data)
13 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-string-replace-empty-match.js:
--------------------------------------------------------------------------------
1 | /*===
2 | finished
3 | foo
4 | ===*/
5 |
6 | /* Empty match with a global RegExp caused an infinite loop. */
7 |
8 | try {
9 | var t = 'foo'.replace(/(?:)/g, '');
10 | print('finished');
11 | print(t);
12 | } catch (e) {
13 | print(e);
14 | }
15 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-include-test.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Test the include mechanism - not an actual ECMAScript testcase.
3 | */
4 |
5 | /*===
6 | Hello world!
7 | ===*/
8 |
9 | /*@include util-helloworld.js@*/
10 |
11 | try {
12 | testHelloWorldUtility();
13 | } catch (e) {
14 | print(e.stack || e);
15 | }
16 |
--------------------------------------------------------------------------------
/tests/memory/test-function-expression-2.js:
--------------------------------------------------------------------------------
1 | function test() {
2 | var arr = [];
3 | var fn;
4 | while (arr.length < 1e4) {
5 | fn = function () {};
6 | fn.prototype = null;
7 | arr.push(fn);
8 | }
9 | print(arr.length + ' anonymous functions created');
10 | }
11 | test();
12 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DATE_TZO_GMTIME_R.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DATE_TZO_GMTIME_R
2 | introduced: 1.0.0
3 | default: false
4 | tags:
5 | - date
6 | - portability
7 | description: >
8 | Use gmtime_r() to get local time offset at a certain time.
9 | When enabled, appropriate date/time headers must be included.
10 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_JSON_STRINGIFY_FASTPATH.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_JSON_STRINGIFY_FASTPATH
2 | introduced: 1.3.0
3 | tags:
4 | - performance
5 | - fastpath
6 | - lowmemory
7 | description: >
8 | Enable fast apth for JSON.stringify() serialization. See
9 | DUK_USE_JSON_STRINGIFY_FASTPATH for details.
10 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_SIGSETJMP.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_SIGSETJMP
2 | introduced: 1.1.0
3 | removed: 1.5.0
4 | tags:
5 | - portability
6 | description: >
7 | Force sigsetjmp/siglongjmp with savesigs == 0 for long control
8 | transfers (i.e. signal mask not saved/restored). See comments in
9 | DUK_OPT_SETJMP.
10 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bi-symbol-object-valueof.js:
--------------------------------------------------------------------------------
1 | /*===
2 | symbol
3 | object
4 | symbol
5 | true
6 | ===*/
7 |
8 | var symbol = Symbol('foo');
9 | print(typeof symbol);
10 | var object = Object(symbol);
11 | print(typeof object);
12 | var value = object.valueOf();
13 | print(typeof value);
14 | print(symbol === value);
15 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_64BIT_OPS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_64BIT_OPS
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - portability
6 | description: >
7 | Use 64-bit integer operations. On some platforms 64-bit types may be
8 | available but 64-bit operations don't work correctly e.g. in integer/float
9 | casts.
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_BASE64_FASTPATH.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_BASE64_FASTPATH
2 | introduced: 1.4.0
3 | default: true
4 | tags:
5 | - performance
6 | - fastpath
7 | - lowmemory
8 | description: >
9 | Enable fast path for base64 encode/decode. The fast path uses a lookup
10 | table at a small cost in footprint.
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_CBOR_SUPPORT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_CBOR_SUPPORT
2 | introduced: 2.5.0
3 | default: true
4 | tags:
5 | - codec
6 | - cbor
7 | - experimental
8 | description: >
9 | Include CBOR support. When disabled, CBOR functions in the C API (and the
10 | CBOR built-in, if enabled) will throw an error.
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DATE_TZO_WINDOWS_NO_DST.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DATE_TZO_WINDOWS_NO_DST
2 | introduced: 2.0.1
3 | default: false
4 | tags:
5 | - date
6 | - portability
7 | description: >
8 | Use Win32 API calls to get local time offset at a certain time.
9 | Does not take into account daylight savings time.
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DOUBLE_BE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DOUBLE_BE
2 | introduced: 1.0.0
3 | removed: 1.4.0
4 | default: false
5 | conflicts:
6 | - DUK_USE_DOUBLE_LE
7 | - DUK_USE_DOUBLE_ME
8 | tags:
9 | - portability
10 | description: >
11 | IEEE double memory representation is big endian on the target platform.
12 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DOUBLE_LE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DOUBLE_LE
2 | introduced: 1.0.0
3 | removed: 1.4.0
4 | default: true
5 | conflicts:
6 | - DUK_USE_DOUBLE_BE
7 | - DUK_USE_DOUBLE_ME
8 | tags:
9 | - portability
10 | description: >
11 | IEEE double memory representation is little endian on the target platform.
12 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_INTEGER_BE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_INTEGER_BE
2 | introduced: 1.0.0
3 | removed: 1.4.0
4 | default: false
5 | conflicts:
6 | - DUK_USE_INTEGER_LE
7 | - DUK_USE_INTEGER_ME
8 | tags:
9 | - portability
10 | description: >
11 | Integer memory representation is big endian on the target platform.
12 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_INTEGER_LE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_INTEGER_LE
2 | introduced: 1.0.0
3 | removed: 1.4.0
4 | default: true
5 | conflicts:
6 | - DUK_USE_INTEGER_BE
7 | - DUK_USE_INTEGER_ME
8 | tags:
9 | - portability
10 | description: >
11 | Integer memory representation is little endian on the target platform.
12 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_UNALIGNED_ACCESSES_POSSIBLE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_UNALIGNED_ACCESSES_POSSIBLE
2 | introduced: 1.0.0
3 | removed: 1.4.0
4 | default: false
5 | tags:
6 | - portability
7 | description: >
8 | Target architecture unaligned memory accesses (e.g. 32-bit integer access
9 | from an arbitrary address).
10 |
--------------------------------------------------------------------------------
/docker/duktape-make-ubuntu-18.04-x64/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM duktape-base-ubuntu-18.04-x64:latest
2 |
3 | COPY --chown=duktape:duktape run.sh .
4 | RUN chmod 755 run.sh
5 |
6 | # Result is written to stdout as a ZIP, which allows caller to extract
7 | # result without uid issues (ZIP tolerates leading garbage).
8 | ENTRYPOINT ["/work/run.sh"]
9 |
--------------------------------------------------------------------------------
/docker/duktape-make-ubuntu-20.04-x64/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM duktape-base-ubuntu-20.04-x64:latest
2 |
3 | COPY --chown=duktape:duktape run.sh .
4 | RUN chmod 755 run.sh
5 |
6 | # Result is written to stdout as a ZIP, which allows caller to extract
7 | # result without uid issues (ZIP tolerates leading garbage).
8 | ENTRYPOINT ["/work/run.sh"]
9 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-props-asize-gh2023.js:
--------------------------------------------------------------------------------
1 | /*
2 | * https://github.com/svaarala/duktape/issues/2023
3 | */
4 |
5 | /*===
6 | done
7 | ===*/
8 |
9 | function mapchar ( v ) { }
10 | var input ;
11 | var round ;
12 | input = [ ] ;
13 | input[ 65536 ] = 0 ;
14 | input.map( mapchar ).join( '' );
15 |
16 | print('done');
17 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-stmt-debugger.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Debugger statement (E5 Section 12.15).
3 | */
4 |
5 | /*===
6 | before
7 | after
8 | ===*/
9 |
10 | /* If a debugger is not present or active, this statement
11 | * should have no observable effect.
12 | */
13 |
14 | print("before");
15 | debugger;
16 | print("after");
17 |
--------------------------------------------------------------------------------
/tests/perf/test-string-plain-concat.pl:
--------------------------------------------------------------------------------
1 | sub test {
2 | my $i, $j, $t;
3 |
4 | for ($i = 0; $i < 1; $i++) {
5 | $t = '';
6 | for ($j = 0; $j < 1e5; $j++) {
7 | $t = $t . 'x';
8 | #print(length $t);
9 | #print("\n");
10 | }
11 | }
12 | }
13 |
14 | test()
15 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_ARRAY_SPLICE_NONSTD_DELCOUNT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_ARRAY_SPLICE_NONSTD_DELCOUNT
2 | introduced: 1.0.0
3 | removed: 1.0.0
4 | related:
5 | - DUK_OPT_NO_NONSTD_ARRAY_SPLICE_DELCOUNT
6 | tags:
7 | - ecmascript
8 | description: >
9 | Removed, use DUK_OPT_NO_NONSTD_ARRAY_SPLICE_DELCOUNT instead.
10 |
--------------------------------------------------------------------------------
/docker/duktape-make-ubuntu-20.04-arm64/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM duktape-base-ubuntu-20.04-arm64:latest
2 |
3 | COPY --chown=duktape:duktape run.sh .
4 | RUN chmod 755 run.sh
5 |
6 | # Result is written to stdout as a ZIP, which allows caller to extract
7 | # result without uid issues (ZIP tolerates leading garbage).
8 | ENTRYPOINT ["/work/run.sh"]
9 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-lex-lineterm.js:
--------------------------------------------------------------------------------
1 | /*
2 | * LineTerminator recognition, also test line numbers.
3 | *
4 | * CR LF should be treated as a single LineTerminator which should
5 | * be visible from line number tracking.
6 | */
7 |
8 | /*---
9 | {
10 | "skip": true
11 | }
12 | ---*/
13 |
14 | /* XXX: to be implemented */
15 |
--------------------------------------------------------------------------------
/tests/emscripten/fmod.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This should print "0.00000" but on some Emscripten versions it ends up
3 | * printing "nan" (when executed with NodeJS or Duktape).
4 | */
5 |
6 | #include
7 | #include
8 |
9 | int main(int argc, char *argv[]) {
10 | printf("%lf\n", fmod(0.0, 4.0));
11 | return 1;
12 | }
13 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_BYTEORDER_FORCED.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_BYTEORDER_FORCED
2 | introduced: 1.0.0
3 | removed: 1.4.0
4 | default: false
5 | tags:
6 | - portability
7 | description: >
8 | Byte order was forced (instead of being autodetected). This has no
9 | functional impact but the forced status shows up in Duktape.env.
10 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_VERBOSE_ERRORS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_VERBOSE_ERRORS
2 | introduced: 1.0.0
3 | tags:
4 | - ecmascript
5 | description: >
6 | Don't provide error message strings or filename/line information for errors
7 | generated by Duktape. Reduces footprint, at the cost of much less
8 | informative ECMAScript errors.
9 |
--------------------------------------------------------------------------------
/tests/api/test-join.c:
--------------------------------------------------------------------------------
1 | /*===
2 | result: foo; 123; true
3 | ===*/
4 |
5 | void test(duk_context *ctx) {
6 | duk_push_string(ctx, "; ");
7 | duk_push_string(ctx, "foo");
8 | duk_push_int(ctx, 123);
9 | duk_push_true(ctx);
10 | duk_join(ctx, 3);
11 |
12 | printf("result: %s\n", duk_get_string(ctx, -1));
13 | duk_pop(ctx);
14 | }
15 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DATE_NOW_WINDOWS_SUBMS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DATE_NOW_WINDOWS_SUBMS
2 | introduced: 2.2.0
3 | default: false
4 | tags:
5 | - date
6 | - portability
7 | description: >
8 | Like DUK_USE_DATE_NOW_WINDOWS but use GetSystemTimePreciseAsFileTime(),
9 | available since Windows 8, for sub-millisecond resolution.
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_STRTAB_TORTURE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_STRTAB_TORTURE
2 | introduced: 2.1.0
3 | default: false
4 | tags:
5 | - torture
6 | description: >
7 | Resize string table (grow, shrink back) for every intern. Ensures string
8 | table chaining is correct, and resize side effects are exercised on every
9 | resize.
10 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_FORCE_ALIGN.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_FORCE_ALIGN
2 | introduced: 1.0.0
3 | tags:
4 | - portability
5 | description: >
6 | Use -DDUK_OPT_FORCE_ALIGN=4 or -DDUK_OPT_FORCE_ALIGN=8 to force a
7 | specific struct/value alignment instead of relying on Duktape's
8 | automatic detection. This shouldn't normally be needed.
9 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_LIGHTFUNC_BUILTINS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_LIGHTFUNC_BUILTINS
2 | introduced: 1.1.0
3 | tags:
4 | - lowmemory
5 | - experimental
6 | description: >
7 | Force built-in functions to be lightweight functions. This reduces
8 | memory footprint by around 14 kB at the cost of some non-compliant
9 | behavior.
10 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_OBJECT_ES6_PROTO_PROPERTY.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_OBJECT_ES6_PROTO_PROPERTY
2 | introduced: 1.0.0
3 | removed: 1.0.0
4 | related:
5 | - DUK_OPT_NO_ES6_OBJECT_PROTO_PROPERTY
6 | tags:
7 | - ecmascript
8 | - ecmascript6
9 | description: >
10 | Removed, use DUK_OPT_NO_ES6_OBJECT_PROTO_PROPERTY instead.
11 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_OBJECT_ES6_SETPROTOTYPEOF.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_OBJECT_ES6_SETPROTOTYPEOF
2 | introduced: 1.0.0
3 | removed: 1.0.0
4 | related:
5 | - DUK_OPT_NO_ES6_OBJECT_SETPROTOTYPEOF
6 | tags:
7 | - ecmascript
8 | - ecmascript6
9 | description: >
10 | Removed, use DUK_OPT_NO_ES6_OBJECT_SETPROTOTYPEOF instead.
11 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-ret-call.js:
--------------------------------------------------------------------------------
1 | /*===
2 | A
3 | ===*/
4 |
5 | /* This was broken at some point, returning 65 (argument) instead of
6 | * desired value, string "A".
7 | */
8 |
9 | function f(x) {
10 | return String.fromCharCode(x);
11 | }
12 |
13 | try {
14 | print(f(65));
15 | } catch (e) {
16 | print(e.name);
17 | }
18 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-utf8-varname.js:
--------------------------------------------------------------------------------
1 | /*
2 | * https://github.com/svaarala/duktape/issues/103
3 | */
4 |
5 | /*===
6 | count: 2
7 | ===*/
8 |
9 | function test() {
10 | var my_变量=1;
11 | my_变量++;
12 | print('count:', my_变量);
13 | }
14 |
15 | try {
16 | test();
17 | } catch (e) {
18 | print(e.stack || e);
19 | }
20 |
--------------------------------------------------------------------------------
/tests/knownissues/test-bug-dataview-buffer-prop-1.txt:
--------------------------------------------------------------------------------
1 | summary: DataView .buffer property misleading when DataView argument is not an ArrayBuffer (custom behavior)
2 | ---
3 | [object ArrayBuffer]
4 | true
5 | [object DataView]
6 | false
7 | [object Uint16Array]
8 | false
9 | [object ArrayBuffer]
10 | false
11 | [object Uint8Array]
12 | false
13 |
--------------------------------------------------------------------------------
/tests/knownissues/test-dev-func-cons-args-1.txt:
--------------------------------------------------------------------------------
1 | summary: corner cases for 'new Function()' when arguments and code are given as strings
2 | ---
3 | 6
4 | 6
5 | 6
6 | 6
7 | SyntaxError
8 | SyntaxError
9 | function () {if (1) {print('foo')}}
10 | foo
11 | foo
12 | OBJ1
13 | OBJ2
14 | OBJ3
15 | 7
16 | undefined
17 | foo
18 | foo 1
19 | foo 1 2
20 |
--------------------------------------------------------------------------------
/website/api/duk_push_null.yaml:
--------------------------------------------------------------------------------
1 | name: duk_push_null
2 |
3 | proto: |
4 | void duk_push_null(duk_context *ctx);
5 |
6 | stack: |
7 | [ ... ] -> [ ... null! ]
8 |
9 | summary: |
10 | Push null to the stack.
11 |
12 | example: |
13 | duk_push_null(ctx);
14 |
15 | tags:
16 | - stack
17 |
18 | introduced: 1.0.0
19 |
--------------------------------------------------------------------------------
/examples/coffee/README.rst:
--------------------------------------------------------------------------------
1 | =====================
2 | Coffeescript examples
3 | =====================
4 |
5 | A few tests to see how CoffeeScript works with Duktape. Just convert the
6 | Coffeescript files to Javascript with the ``Makefile.coffee`` in the
7 | distributable, or manually::
8 |
9 | $ coffee -c hello.coffee
10 | $ cat hello.js
11 |
--------------------------------------------------------------------------------
/examples/guide/fib.js:
--------------------------------------------------------------------------------
1 | // fib.js
2 | function fib(n) {
3 | if (n == 0) { return 0; }
4 | if (n == 1) { return 1; }
5 | return fib(n-1) + fib(n-2);
6 | }
7 |
8 | function test() {
9 | var res = [];
10 | for (i = 0; i < 20; i++) {
11 | res.push(fib(i));
12 | }
13 | print(res.join(' '));
14 | }
15 |
16 | test();
17 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bi-promise-constructor-reject-basic.js:
--------------------------------------------------------------------------------
1 | /*---
2 | {
3 | "skip": true
4 | }
5 | ---*/
6 |
7 | /*===
8 | done
9 | reject: 123
10 | ===*/
11 |
12 | var P = Promise.reject(123);
13 | P.then(function (v) {
14 | print('fulfill:', v);
15 | }, function (e) {
16 | print('reject:', e);
17 | });
18 |
19 | print('done');
20 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-compiler-gh2031.js:
--------------------------------------------------------------------------------
1 | /*===
2 | A
3 | B
4 | ReferenceError
5 | ===*/
6 |
7 | try {
8 | print('A');
9 | Object.defineProperty(Array.prototype, 0, { set : function ( ) { } } ) ;
10 | print('B');
11 | eval('var x; for (x++ in [0,1]) {}');
12 | print('done');
13 | } catch (e) {
14 | print(e.name);
15 | }
16 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-isprototypeof-assert-gh1162.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Assert failure in Duktape 1.5.1
3 | *
4 | * https://github.com/svaarala/duktape/issues/1162
5 | */
6 |
7 | /*===
8 | false
9 | ===*/
10 |
11 | try {
12 | print(this.parseFloat.isPrototypeOf(this.Object.prototype));
13 | } catch (e) {
14 | print(e.stack || e);
15 | }
16 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-typeof-unref.js:
--------------------------------------------------------------------------------
1 | /*===
2 | undefined
3 | ===*/
4 |
5 | /* 'x' does not resolve, should not cause a ReferenceError but
6 | * an "undefined" typeof. E5 Section 11.4.3, step 2.a.
7 | *
8 | * This was broken at some point.
9 | */
10 |
11 | try {
12 | print(typeof x);
13 | } catch (e) {
14 | print(e.name);
15 | }
16 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-str-characcess-2.js:
--------------------------------------------------------------------------------
1 | /*===
2 | 70
3 | 111
4 | 111
5 | 70
6 | 111
7 | 111
8 | ===*/
9 |
10 | var text = 'Foo';
11 |
12 | print(text.charCodeAt(0));
13 | print(text.charCodeAt(1));
14 | print(text.charCodeAt(2));
15 |
16 | print(text.charCodeAt("0"));
17 | print(text.charCodeAt("1"));
18 | print(text.charCodeAt("2"));
19 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_CACHE_CATCHER.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_CACHE_CATCHER
2 | introduced: 2.2.0
3 | default: true
4 | tags:
5 | - performance
6 | description: >
7 | Cache duk_catcher records. When releasing a duk_catcher, place it in
8 | a free list for later reuse. Mark-and-sweep frees the free list to keep
9 | memory usage in check.
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_IDCHAR_FASTPATH.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_IDCHAR_FASTPATH
2 | introduced: 1.5.0
3 | default: true
4 | tags:
5 | - performance
6 | - fastpath
7 | - lowmemory
8 | description: >
9 | Enable fast path for identifier start/part tables, which affect lexing and
10 | JSON performance slightly at a small cost in footprint.
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_JSON_DECSTRING_FASTPATH.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_JSON_DECSTRING_FASTPATH
2 | introduced: 1.3.0
3 | default: true
4 | tags:
5 | - performance
6 | - fastpath
7 | - lowmemory
8 | description: >
9 | Enable fast path for string decoding in JSON.parse(). The fast path uses
10 | a lookup table at a small cost in footprint.
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_JSON_EATWHITE_FASTPATH.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_JSON_EATWHITE_FASTPATH
2 | introduced: 1.3.0
3 | default: true
4 | tags:
5 | - performance
6 | - fastpath
7 | - lowmemory
8 | description: >
9 | Enable fast path for eating whitespace in JSON.parse(). The fast path uses
10 | a lookup table at a small cost in footprint.
11 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_SELF_TESTS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_SELF_TESTS
2 | introduced: 1.0.0
3 | tags:
4 | - debug
5 | description: >
6 | Perform run-time self tests when a Duktape heap is created. Catches
7 | platform/compiler problems which cannot be reliably detected during
8 | compile time. Not enabled by default because of the extra footprint.
9 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bi-json-dec-empty.js:
--------------------------------------------------------------------------------
1 | /*===
2 | SyntaxError
3 | SyntaxError
4 | ===*/
5 |
6 | /* Empty or pure white space is a SyntaxError. */
7 |
8 | try {
9 | print(JSON.parse(''));
10 | } catch (e) {
11 | print(e.name);
12 | }
13 |
14 | try {
15 | print(JSON.parse(' \n\r\t'));
16 | } catch (e) {
17 | print(e.name);
18 | }
19 |
--------------------------------------------------------------------------------
/tests/knownissues/test-bug-enum-shadow-nonenumerable-1.txt:
--------------------------------------------------------------------------------
1 | summary: enumeration semantics corner case for shadowing
2 | description: >
3 | Corner case enumeration semantics, not sure what correct behavior is
4 | (test262 ch12/12.6/12.6.4/12.6.4-2).
5 | ---
6 | test1
7 | foo
8 | bar
9 | y enums "prop": true
10 | test2
11 | child enums "prop": true
12 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DPRINT_COLORS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DPRINT_COLORS
2 | introduced: 1.0.0
3 | removed: 2.0.0
4 | default: false
5 | tags:
6 | - debug
7 | description: >
8 | Enable coloring of debug prints with ANSI escape codes
9 | (http://en.wikipedia.org/wiki/ANSI_escape_code). The behavior is not
10 | sensitive to terminal settings.
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_JSON_DECNUMBER_FASTPATH.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_JSON_DECNUMBER_FASTPATH
2 | introduced: 1.3.0
3 | default: true
4 | tags:
5 | - performance
6 | - fastpath
7 | - lowmemory
8 | description: >
9 | Enable fast path for decoding numbers in JSON.parse(). The fast path uses
10 | a lookup table at a small cost in footprint.
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_VERBOSE_EXECUTOR_ERRORS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_VERBOSE_EXECUTOR_ERRORS
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Use verbose error messages in bytecode executor (recommended).
8 |
9 | When disabled, reduces footprint slightly at the cost of more obscure
10 | error messages.
11 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_NONSTD_ACCESSOR_KEY_ARGUMENT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_NONSTD_ACCESSOR_KEY_ARGUMENT
2 | introduced: 1.0.0
3 | tags:
4 | - ecmascript
5 | description: >
6 | Don't give setter/getter calls the property name being accessed as
7 | an additional, non-standard property. See
8 | http://duktape.org/guide.html#propertyvirtualization.
9 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_SEGFAULT_ON_PANIC.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_SEGFAULT_ON_PANIC
2 | introduced: 1.0.0
3 | tags:
4 | - portability
5 | description: >
6 | Cause the default panic handler to cause a segfault instead of using
7 | abort() or exit(). This is useful when debugging with valgrind,
8 | as a segfault provides a nice C traceback in valgrind.
9 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_SHUFFLE_TORTURE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_SHUFFLE_TORTURE
2 | introduced: 1.2.0
3 | tags:
4 | - gc
5 | - memory
6 | - development
7 | description: >
8 | Development time option: force compiler to shuffle every possible opcode
9 | to stress shuffle behavior which is otherwise difficult to test for
10 | comprehensively.
11 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_TARGET_INFO.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_TARGET_INFO
2 | introduced: 1.2.0
3 | tags:
4 | - debugger
5 | description: >
6 | Define a freeform human readable string to describe the target device (e.g.
7 | "Arduino Yun"). This string will be sent as part of version/target info in
8 | the debugger protocol and shows up in the debugger UI.
9 |
--------------------------------------------------------------------------------
/config/platforms/platform_posix.h.in:
--------------------------------------------------------------------------------
1 | #define DUK_USE_DATE_NOW_GETTIMEOFDAY
2 | #define DUK_USE_DATE_TZO_GMTIME_R
3 | #define DUK_USE_DATE_PRS_STRPTIME
4 | #define DUK_USE_DATE_FMT_STRFTIME
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | #define DUK_USE_OS_STRING "posix"
12 |
--------------------------------------------------------------------------------
/src-tools/lib/util/engine_detect.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | function isNodejs() {
4 | return typeof process === 'object' && process !== null && typeof process.cwd === 'function';
5 | }
6 | exports.isNodejs = isNodejs;
7 |
8 | function isDuktape() {
9 | return typeof Duktape === 'object' && Duktape !== null;
10 | }
11 | exports.isDuktape = isDuktape;
12 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bi-promise-constructor-resolve-basic.js:
--------------------------------------------------------------------------------
1 | /*---
2 | {
3 | "skip": true
4 | }
5 | ---*/
6 |
7 | /*===
8 | done
9 | fulfill: 123
10 | ===*/
11 |
12 | var P = Promise.resolve(123);
13 | P.then(function (v) {
14 | print('fulfill:', v);
15 | }, function (e) {
16 | print('reject:', String(e));
17 | });
18 |
19 | print('done');
20 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-json-stringify-proplist-inherited-gh2202.js:
--------------------------------------------------------------------------------
1 | // https://github.com/svaarala/duktape/issues/2202
2 |
3 | /*===
4 | A
5 | B
6 | {}
7 | done
8 | ===*/
9 |
10 | print('A');
11 | Object.defineProperty(Array.prototype, 0, { set: function () { } })
12 | print('B');
13 | print(String(JSON.stringify({ }, [ 0, 0])));
14 | print('done');
15 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-expr-newtarget-program-code.js:
--------------------------------------------------------------------------------
1 | /*
2 | * new.target not allowed in program code; this fails without print()
3 | * calls due to script SyntaxError.
4 | */
5 |
6 | /*---
7 | {
8 | "intended_uncaught": true
9 | }
10 | ---*/
11 |
12 | /*===
13 | ===*/
14 |
15 | print('start');
16 | print(typeof new.target);
17 | print('done');
18 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_CACHE_ACTIVATION.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_CACHE_ACTIVATION
2 | introduced: 2.2.0
3 | default: true
4 | tags:
5 | - performance
6 | description: >
7 | Cache duk_activation records. When releasing a duk_activation, place it in
8 | a free list for later reuse. Mark-and-sweep frees the free list to keep
9 | memory usage in check.
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_FILE_IO.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_FILE_IO
2 | introduced: 1.0.0
3 | removed: 2.0.0
4 | default: true
5 | tags:
6 | - io
7 | description: >
8 | File I/O support. This is now used in a few API calls to e.g. push
9 | a string from file contents or eval a file. For portability it must
10 | be possible to disable I/O altogether.
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_JSON_QUOTESTRING_FASTPATH.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_JSON_QUOTESTRING_FASTPATH
2 | introduced: 1.3.0
3 | default: true
4 | tags:
5 | - performance
6 | - fastpath
7 | - lowmemory
8 | description: >
9 | Enable fast path for string quoting in JSON.stringify(). The fast path uses
10 | a lookup table at a small cost in footprint.
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_LIGHTFUNC_BUILTINS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_LIGHTFUNC_BUILTINS
2 | introduced: 1.1.0
3 | default: false
4 | tags:
5 | - lowmemory
6 | - experimental
7 | description: >
8 | Force built-in functions to be lightweight functions. This reduces
9 | memory footprint by around 14 kB at the cost of some non-compliant
10 | behavior.
11 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_SUPERH.h.in:
--------------------------------------------------------------------------------
1 | /* SuperH */
2 | #if defined(__sh__) || \
3 | defined(__sh1__) || defined(__SH1__) || \
4 | defined(__sh2__) || defined(__SH2__) || \
5 | defined(__sh3__) || defined(__SH3__) || \
6 | defined(__sh4__) || defined(__SH4__) || \
7 | defined(__sh5__) || defined(__SH5__)
8 | #define DUK_F_SUPERH
9 | #endif
10 |
--------------------------------------------------------------------------------
/licenses/splitmix64.txt:
--------------------------------------------------------------------------------
1 | /* Written in 2015 by Sebastiano Vigna (vigna@acm.org)
2 |
3 | To the extent possible under law, the author has dedicated all copyright
4 | and related and neighboring rights to this software to the public domain
5 | worldwide. This software is distributed without any warranty.
6 |
7 | See . */
8 |
--------------------------------------------------------------------------------
/misc/preproc_compare1.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Preprocessor compare with right part undefined.
3 | */
4 |
5 | #include
6 |
7 | #define FOO 123
8 | #undef BAR
9 |
10 | int main(int argc, char *argv[]) {
11 | #if defined(FOO) && defined(BAR) && (FOO == BAR)
12 | printf("FOO == BAR\n");
13 | #else
14 | printf("FOO != BAR\n");
15 | #endif
16 | return 0;
17 | }
18 |
--------------------------------------------------------------------------------
/misc/preproc_compare2.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Preprocessor compare with left part undefined.
3 | */
4 |
5 | #include
6 |
7 | #define FOO 123
8 | #undef BAR
9 |
10 | int main(int argc, char *argv[]) {
11 | #if defined(FOO) && defined(BAR) && (BAR == FOO)
12 | printf("FOO == BAR\n");
13 | #else
14 | printf("FOO != BAR\n");
15 | #endif
16 | return 0;
17 | }
18 |
--------------------------------------------------------------------------------
/src-tools/lib/util/json.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | // Stringify to one-line pure-ASCII JSON.
4 | function jsonStringifyAscii(x) {
5 | return JSON.stringify(x).replace(/[\u0000-\u001f\u007f-\uffff]/g, (c) => {
6 | return '\\u' + ('0000' + c.charCodeAt(0).toString(16)).substr(-4);
7 | });
8 | }
9 | exports.jsonStringifyAscii = jsonStringifyAscii;
10 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-call-valstack-segfault-gh107.js:
--------------------------------------------------------------------------------
1 | /*
2 | * https://github.com/svaarala/duktape/issues/107
3 | */
4 |
5 | /*===
6 | still here
7 | ===*/
8 |
9 | function test() {
10 | Function().apply(1,Array(10000));
11 | print('still here');
12 | }
13 |
14 | try {
15 | test();
16 | } catch (e) {
17 | print(e.stack || e);
18 | }
19 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-coroutine-yield-refzero-1-gh2204.js:
--------------------------------------------------------------------------------
1 | // https://github.com/svaarala/duktape/issues/2204
2 |
3 | /*===
4 | 0
5 | done
6 | ===*/
7 |
8 | function yielder() {
9 | var yield = Duktape.Thread.yield;
10 | t = {};
11 | yield(0);
12 | }
13 | var t = Duktape.Thread(yielder);
14 | print(Duktape.Thread.resume(t));
15 | print('done');
16 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-label-parsing.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Simple label parsing test without actual label semantics tests.
3 | */
4 |
5 | /*===
6 | foo
7 | bar
8 | quux
9 | ===*/
10 |
11 | label1:
12 | print("foo");
13 |
14 | label1:
15 | label2:
16 | print("bar");
17 |
18 | label1:
19 | label2:
20 | label3:
21 | do {
22 | print("quux");
23 | } while(0);
24 |
--------------------------------------------------------------------------------
/tests/perf/test-fib.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Fibonacci test, exercises call handling and recursion
3 | */
4 |
5 | if (typeof print !== 'function') { print = console.log; }
6 |
7 | function fib(n) {
8 | return n <= 1 ? n : fib(n - 2) + fib(n - 1);
9 | }
10 |
11 | try {
12 | print(fib(35));
13 | } catch (e) {
14 | print(e.stack || e);
15 | throw e;
16 | }
17 |
--------------------------------------------------------------------------------
/util/make_ascii.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2
2 | #
3 | # Paranoia escape input file to be printable ASCII.
4 | #
5 |
6 | import os, sys
7 |
8 | inp = sys.stdin.read().decode('utf-8')
9 | for c in inp:
10 | if (ord(c) >= 0x20 and ord(c) <= 0x7e) or (c in '\x0a'):
11 | sys.stdout.write(c)
12 | else:
13 | sys.stdout.write('\\u%04x' % ord(c))
14 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_FAST_REFCOUNT_DEFAULT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_FAST_REFCOUNT_DEFAULT
2 | introduced: 1.2.0
3 | default: true
4 | tags:
5 | - performance
6 | - fastpath
7 | - experimental
8 | description: >
9 | When enabled, plain refcount macros (e.g. DUK_TVAL_INCREF) default to
10 | fast variants (DUK_TVAL_INCREF_FAST) to improve performance.
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_GLOBAL_BUILTIN.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_GLOBAL_BUILTIN
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Provide miscellaneous global built-ins like encodeURIComponent(), escape(),
8 | Infinity, etc. This is a catch-all for globals not covered by other options
9 | (like DUK_USE_ARRAY_BUILTIN).
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_MARK_AND_SWEEP_RECLIMIT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_MARK_AND_SWEEP_RECLIMIT
2 | introduced: 1.3.0
3 | default: 256
4 | tags:
5 | - portability
6 | - cstackdepth
7 | description: >
8 | Mark-and-sweep C recursion depth for marking phase; if reached,
9 | mark object as a TEMPROOT and use multi-pass marking (slower but
10 | same result).
11 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_BUFFEROBJECT_SUPPORT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_BUFFEROBJECT_SUPPORT
2 | introduced: 1.3.0
3 | tags:
4 | - ecmascript6
5 | description: >
6 | Disable support for Khronos/ES6 typed arrays and Node.js Buffer objects
7 | which reduces code footprint. When disabled, Duktape custom plain buffers
8 | and Duktape.Buffer are still supported.
9 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_PACKED_TVAL.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_PACKED_TVAL
2 | introduced: 1.0.0
3 | tags:
4 | - memory
5 | - portability
6 | description: >
7 | Don't use the packed 8-byte internal value representation even if otherwise
8 | possible. The packed representation has more platform/compiler portability
9 | issues than the unpacked one.
10 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_SECTION_B.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_SECTION_B
2 | introduced: 1.0.0
3 | tags:
4 | - ecmascript
5 | description: >
6 | Disable optional features in ECMAScript specification
7 | Annex B: http://www.ecma-international.org/ecma-262/5.1/#sec-B.
8 | Causes escape(), unescape(), and String.prototype.substr() to throw
9 | an error.
10 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_TRACEBACKS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_TRACEBACKS
2 | introduced: 1.0.0
3 | tags:
4 | - ecmascript
5 | description: >
6 | Don't record traceback data into ECMAScript error objects (but still record
7 | fileName and lineNumber). Reduces footprint and makes error handling a bit
8 | faster, at the cost of less informative ECMAScript errors.
9 |
--------------------------------------------------------------------------------
/config/platforms/platform_genericbsd.h.in:
--------------------------------------------------------------------------------
1 | #define DUK_USE_DATE_NOW_GETTIMEOFDAY
2 | #define DUK_USE_DATE_TZO_GMTIME_R
3 | #define DUK_USE_DATE_PRS_STRPTIME
4 | #define DUK_USE_DATE_FMT_STRFTIME
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | #define DUK_USE_OS_STRING "bsd"
12 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-json-reviver-array-recursion.js:
--------------------------------------------------------------------------------
1 | /*
2 | * https://github.com/svaarala/duktape/issues/2338
3 | */
4 |
5 | /*===
6 | RangeError
7 | done
8 | ===*/
9 |
10 | function b() {
11 | a = Array(3);
12 | this[2] = a;
13 | }
14 | try {
15 | JSON.parse("[1, 2, []]", b);
16 | } catch (e) {
17 | print(e.name);
18 | }
19 | print('done');
20 |
--------------------------------------------------------------------------------
/tests/perf/test-string-number-list.js:
--------------------------------------------------------------------------------
1 | if (typeof print !== 'function') { print = console.log; }
2 |
3 | function test() {
4 | var arr = [];
5 | for (var i = 0; i < 1e6; i++) {
6 | arr.push(String(i));
7 | }
8 | print(arr[1e6-1]);
9 | }
10 |
11 | try {
12 | test();
13 | } catch (e) {
14 | print(e.stack || e);
15 | throw e;
16 | }
17 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DATE_NOW_TIME.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DATE_NOW_TIME
2 | introduced: 1.0.0
3 | default: false
4 | tags:
5 | - date
6 | - portability
7 | description: >
8 | Use time() to get current datetime, with the limitation that datetime is
9 | limited to one second resolution. When enabled, appropriate date/time
10 | headers must be included.
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_ES7_EXP_OPERATOR.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_ES7_EXP_OPERATOR
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - ecmascript2016
6 | description: >
7 | Support the ES7 exponentiation operator (** and **=). This is optional
8 | because the operator pulls in pow() which may have a significant footprint
9 | impact on bare metal platforms.
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_POW_WORKAROUNDS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_POW_WORKAROUNDS
2 | introduced: 2.0.0
3 | default: false
4 | tags:
5 | - portability
6 | description: >
7 | Enable workarounds to common pow() semantics issues. At least NetBSD
8 | 6.0 x86 and Cygwin/MinGW have such issues, see test-bug-netbsd-math-pow.js
9 | and test-bug-mingw-math-issues.js.
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_PREFER_SIZE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_PREFER_SIZE
2 | introduced: 1.2.0
3 | default: false
4 | tags:
5 | - lowmemory
6 | description: >
7 | Catch-all flag which can be used to choose between variant algorithms
8 | where a speed-size tradeoff exists (e.g. lookup tables). When it really
9 | matters, specific use flags may be appropriate.
10 |
--------------------------------------------------------------------------------
/examples/codepage-conv/README.rst:
--------------------------------------------------------------------------------
1 | Codepage conversion example
2 | ===========================
3 |
4 | Example of how to convert an 8-bit input string (e.g. ISO-8859-1 or Windows
5 | codepage 1252) into CESU-8 without using an external library like iconv.
6 |
7 | This is useful e.g. when compiling non-UTF-8 source code which cannot be
8 | converted to UTF-8 (CESU-8) at build time.
9 |
--------------------------------------------------------------------------------
/misc/preproc_compare3.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Preprocessor compare with right part defined to empty.
3 | */
4 |
5 | #include
6 |
7 | #define FOO 123
8 | #define BAR
9 |
10 | int main(int argc, char *argv[]) {
11 | #if defined(FOO) && defined(BAR) && (FOO == BAR)
12 | printf("FOO == BAR\n");
13 | #else
14 | printf("FOO != BAR\n");
15 | #endif
16 | return 0;
17 | }
18 |
--------------------------------------------------------------------------------
/misc/preproc_compare4.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Preprocessor compare with left part defined to empty.
3 | */
4 |
5 | #include
6 |
7 | #define FOO 123
8 | #define BAR
9 |
10 | int main(int argc, char *argv[]) {
11 | #if defined(FOO) && defined(BAR) && (BAR == FOO)
12 | printf("FOO == BAR\n");
13 | #else
14 | printf("FOO != BAR\n");
15 | #endif
16 | return 0;
17 | }
18 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bi-function-constructor-oneline-comment.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Function constructor argument may end with a single line comment.
3 | * See https://github.com/svaarala/duktape/issues/1754.
4 | */
5 |
6 | /*===
7 | foo
8 | ===*/
9 |
10 | try {
11 | print(new Function('return "foo" //lastline')());
12 | } catch (e) {
13 | print(e.stack || e);
14 | }
15 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bi-json-enc-replacer-proxy.js:
--------------------------------------------------------------------------------
1 | /*===
2 | {"foo":123,"bar":234}
3 | {"foo":123,"bar":234}
4 | ===*/
5 |
6 | try {
7 | print(JSON.stringify({ foo: 123, bar: 234, quux: 345 }, [ 'foo', 'bar' ]));
8 | print(JSON.stringify({ foo: 123, bar: 234, quux: 345 }, new Proxy([ 'foo', 'bar' ], {})));
9 | } catch (e) {
10 | print(e.stack || e);
11 | }
12 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bi-symbol-create-many.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Create 10M symbols.
3 | */
4 |
5 | /*===
6 | done
7 | ===*/
8 |
9 | function test() {
10 | var i, s;
11 |
12 | for (i = 0; i < 1e7; i++) {
13 | s = Symbol('foo');
14 | }
15 | print('done');
16 | }
17 |
18 | try {
19 | test();
20 | } catch (e) {
21 | print(e.stack || e);
22 | }
23 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-incdec-stale-act-gh1370.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Stale 'act' pointer in pre/post inc/dec handling.
3 | * https://github.com/svaarala/duktape/issues/1370
4 | *
5 |
6 | /*===
7 | RangeError
8 | ===*/
9 |
10 | try {
11 | (function foo() {
12 | foo--; foo();
13 | })();
14 | } catch (e) {
15 | print(e.name); // eventual RangeError
16 | }
17 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-nodejs-buffer-varint-crash.js:
--------------------------------------------------------------------------------
1 | /*===
2 | RangeError
3 | ===*/
4 |
5 | function test() {
6 | var buf = new Buffer('ABCDEFGH');
7 |
8 | // Value/offset "mixed up" caused segfault at some point in development.
9 | buf.writeIntBE(0, 0xdeadbeef, 4)
10 | }
11 |
12 | try {
13 | test();
14 | } catch (e) {
15 | print(e.name);
16 | }
17 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-packed-tval-nan-normalize.js:
--------------------------------------------------------------------------------
1 | /*---
2 | {
3 | "custom": true
4 | }
5 | ---*/
6 |
7 | /*===
8 | NaN
9 | done
10 | ===*/
11 |
12 | try {
13 | var val = CBOR.decode(new Uint8Array([ 0xfb, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ]));
14 | print(val);
15 | } catch (e) {
16 | print(e.stack || e);
17 | }
18 |
19 | print('done');
20 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-strict-global-this.js:
--------------------------------------------------------------------------------
1 | /*
2 | * If global code is strict it still gets a 'this' binding
3 | * (not undefined as in Duktape 0.8.0). This is apparent from
4 | * E5.1 Section 10.4.1.
5 | */
6 |
7 | "use strict";
8 |
9 | /*===
10 | object
11 | ===*/
12 |
13 | try {
14 | print(typeof this);
15 | } catch (e) {
16 | print(e);
17 | }
18 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-assign-trivial-loop.js:
--------------------------------------------------------------------------------
1 | /*===
2 | 10
3 | 9
4 | 8
5 | 7
6 | 6
7 | 5
8 | 4
9 | 3
10 | 2
11 | 1
12 | 10
13 | 9
14 | 8
15 | 7
16 | 6
17 | 5
18 | 4
19 | 3
20 | 2
21 | 1
22 | ===*/
23 |
24 | /* Simple tests for assignment */
25 |
26 | for (i = 10; i; i -= 1) {
27 | print(i);
28 | }
29 |
30 | for (i = 10; i; i = i - 1) {
31 | print(i);
32 | }
33 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-exec-timeout-tailcall.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Execution timeout: tailcall function
3 | */
4 |
5 | /*---
6 | {
7 | "skip": true
8 | }
9 | ---*/
10 |
11 | // See: GH-214
12 | function f() {
13 | return f();
14 | }
15 |
16 | function test() {
17 | f();
18 | }
19 |
20 | try {
21 | test();
22 | } catch (e) {
23 | print(e.name);
24 | }
25 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-valstack-shrink-check-1.js:
--------------------------------------------------------------------------------
1 | /*===
2 | done
3 | ===*/
4 |
5 | function test(a,b,c,d,e,f,g,h,i,j) {
6 | if (a <= 0) {
7 | return;
8 | }
9 | test(a - 1);
10 | return 123;
11 | }
12 |
13 | // Pure Ecma-to-Ecma calls only
14 | test(1000);
15 | for (var i = 0; i < 10; i++) {
16 | Duktape.gc();
17 | }
18 | print('done');
19 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-lex-line-continuation.js:
--------------------------------------------------------------------------------
1 | /*===
2 | "This is a \
3 | line continuation."
4 | This is a line continuation.
5 | ===*/
6 |
7 | /* Line continuation inside a string. */
8 |
9 | var str;
10 |
11 | try {
12 | str = '"This is a \\\nline continuation."';
13 | print(str);
14 | print(eval(str));
15 | } catch (e) {
16 | print(e.name);
17 | }
18 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-regexp-charclass-invalid-order.js:
--------------------------------------------------------------------------------
1 | /*===
2 | /[a-z]/
3 | SyntaxError
4 | ===*/
5 |
6 | function test() {
7 | try {
8 | print(eval('/[a-z]/'));
9 | print(eval('/[z-a]/'));
10 | } catch (e) {
11 | print(e.name);
12 | }
13 | }
14 |
15 | try {
16 | test();
17 | } catch (e) {
18 | print(e.stack || e);
19 | }
20 |
--------------------------------------------------------------------------------
/tests/perf/test-json-parse-number.py:
--------------------------------------------------------------------------------
1 | import json
2 | import random
3 |
4 | def test():
5 | arr = []
6 | for i in xrange(10000):
7 | arr.append(random.random() * 1e9)
8 |
9 | jsondata = json.dumps(arr)
10 | print(len(jsondata))
11 | #print(jsondata)
12 |
13 | for i in xrange(100):
14 | ign = json.loads(jsondata)
15 |
16 | test()
17 |
--------------------------------------------------------------------------------
/website/api/duk_push_undefined.yaml:
--------------------------------------------------------------------------------
1 | name: duk_push_undefined
2 |
3 | proto: |
4 | void duk_push_undefined(duk_context *ctx);
5 |
6 | stack: |
7 | [ ... ] -> [ ... undefined! ]
8 |
9 | summary: |
10 | Push undefined to the stack.
11 |
12 | example: |
13 | duk_push_undefined(ctx);
14 |
15 | tags:
16 | - stack
17 |
18 | introduced: 1.0.0
19 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DATE_FMT_STRFTIME.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DATE_FMT_STRFTIME
2 | introduced: 1.0.0
3 | default: false
4 | tags:
5 | - date
6 | - portability
7 | description: >
8 | Use strftime() to format Date values in native, platform specific format
9 | before falling back into ISO 8601. When enabled, appropriate date/time
10 | headers must be included.
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_FINALIZER_TORTURE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_FINALIZER_TORTURE
2 | introduced: 2.1.0
3 | default: false
4 | tags:
5 | - gc
6 | - memory
7 | - development
8 | - torture
9 | description: >
10 | Development time option: simulate a fake finalizer call every time when
11 | finalizers might be executed (even if the actual finalize_list is empty).
12 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_VERBOSE_ERRORS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_VERBOSE_ERRORS
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Provide error message strings and file/line information for errors generated
8 | by Duktape.
9 |
10 | When disabled, reduces footprint at the cost of much less informative
11 | ECMAScript errors.
12 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_BUFFEROBJECT_SUPPORT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_BUFFEROBJECT_SUPPORT
2 | introduced: 1.3.0
3 | tags:
4 | - ecmascript6
5 | description: >
6 | Enable support for Khronos/ES6 typed arrays and Node.js Buffer objects.
7 | This adds about 8-9 kB of code footprint on x64. When disabled, Duktape
8 | custom plain buffers and Duktape.Buffer are still supported.
9 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bi-math-exp.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Math.exp()
3 | */
4 |
5 | /*@include util-number.js@*/
6 |
7 | /*===
8 | NaN
9 | 1
10 | 1
11 | Infinity
12 | 0
13 | ===*/
14 |
15 | printExact(Math.exp(NaN));
16 | printExact(Math.exp(+0));
17 | printExact(Math.exp(-0));
18 | printExact(Math.exp(Number.POSITIVE_INFINITY));
19 | printExact(Math.exp(Number.NEGATIVE_INFINITY));
20 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bi-promise-constructor-try-success.js:
--------------------------------------------------------------------------------
1 | /*---
2 | {
3 | "skip": true
4 | }
5 | ---*/
6 |
7 | /*===
8 | done
9 | fulfill: 123
10 | ===*/
11 |
12 | var P = Promise.try(function () {
13 | return 123;
14 | });
15 | P.then(function (v) {
16 | print('fulfill:', v);
17 | }, function (e) {
18 | print('reject:', e);
19 | });
20 | print('done');
21 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-json-dec-num.js:
--------------------------------------------------------------------------------
1 | /*===
2 | SyntaxError
3 | ===*/
4 |
5 | /* The current number parser is a lenient approximation and will be fixed
6 | * when compliant number parsing is implemented. This test case illustrates
7 | * one leniency example.
8 | */
9 |
10 | try {
11 | print(JSON.parse('1.2.3'));
12 | } catch (e) {
13 | print(e.name);
14 | }
15 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-implicit-return-value-1.js:
--------------------------------------------------------------------------------
1 | /* XXX: for eval/global code */
2 | /* XXX: test for handling of 'valued' and 'non-valued' statements */
3 |
4 | /*===
5 | 3
6 | 3
7 | ===*/
8 |
9 | /* basic case */
10 | print(eval('1+2;'));
11 |
12 | /* an empty statement (like debugger) must not alter non-empty previous result */
13 | print(eval('1+2; debugger;'));
14 |
--------------------------------------------------------------------------------
/tests/perf/test-json-parse-integer.py:
--------------------------------------------------------------------------------
1 | import json
2 | import random
3 |
4 | def test():
5 | arr = []
6 | for i in xrange(10000):
7 | arr.append(int(random.random() * 1e9))
8 |
9 | jsondata = json.dumps(arr)
10 | print(len(jsondata))
11 | #print(jsondata)
12 |
13 | for i in xrange(100):
14 | ign = json.loads(jsondata)
15 |
16 | test()
17 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_CPP_EXCEPTIONS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_CPP_EXCEPTIONS
2 | introduced: 1.4.0
3 | default: false
4 | tags:
5 | - portability
6 | description: >
7 | Use C++ exceptions instead of setjmp/longjmp for long control transfers.
8 | This allows Duktape/C functions written in C++ to use automatic destructors
9 | (RAII or scope-based resource management).
10 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_JSON_ENC_RECLIMIT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_JSON_ENC_RECLIMIT
2 | introduced: 1.3.0
3 | default: 1000
4 | tags:
5 | - portability
6 | - cstackdepth
7 | description: >
8 | Maximum native stack recursion for JSON encoding.
9 |
10 | Must be higher than the internal DUK_JSON_ENC_LOOPARRAY define when
11 | DUK_USE_JSON_STRINGIFY_FASTPATH is enabled.
12 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_SELF_TESTS.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_SELF_TESTS
2 | introduced: 1.0.0
3 | default: false
4 | tags:
5 | - debug
6 | description: >
7 | Perform run-time self tests when a Duktape heap is created. Catches
8 | platform/compiler problems which cannot be reliably detected during
9 | compile time. Not enabled by default because of the extra footprint.
10 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_BROWSER_LIKE.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_BROWSER_LIKE
2 | introduced: 1.0.0
3 | tags:
4 | - ecmascript
5 | description: >
6 | Disable browser-like functions. Makes print() and alert() throw an error.
7 |
8 | This option is confusing when used with the Duktape command line tool, as
9 | the command like tool will immediately panic on startup.
10 |
--------------------------------------------------------------------------------
/config/feature-options/DUK_OPT_NO_REFERENCE_COUNTING.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_OPT_NO_REFERENCE_COUNTING
2 | introduced: 1.0.0
3 | tags:
4 | - gc
5 | - memory
6 | description: >
7 | Disable reference counting and use only mark-and-sweep for garbage
8 | collection. Although this reduces memory footprint of heap objects, the
9 | downside is much more fluctuation in memory usage.
10 |
--------------------------------------------------------------------------------
/config/platforms/platform_aix.h.in:
--------------------------------------------------------------------------------
1 | #if !defined(DUK_USE_BYTEORDER)
2 | #define DUK_USE_BYTEORDER 3
3 | #endif
4 | #define DUK_USE_DATE_NOW_GETTIMEOFDAY
5 | #define DUK_USE_DATE_TZO_GMTIME_R
6 | #define DUK_USE_DATE_PRS_STRPTIME
7 | #define DUK_USE_DATE_FMT_STRFTIME
8 | #include
9 | #include
10 | #include
11 |
12 | #define DUK_USE_OS_STRING "aix"
13 |
--------------------------------------------------------------------------------
/examples/README.rst:
--------------------------------------------------------------------------------
1 | ================
2 | Duktape examples
3 | ================
4 |
5 | Examples for using Duktape. These support user documentation and are
6 | intended as informative illustrations only.
7 |
8 | Examples are unmaintained and are not production quality code. Bugs are
9 | not necessarily fixed, unless the bug makes the example misleading as
10 | documentation.
11 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bi-cbor-dec-empty.js:
--------------------------------------------------------------------------------
1 | /*===
2 | TypeError
3 | ===*/
4 |
5 | // Empty input is a decode error, TypeError used now. cbor-js triggers a
6 | // RangeError from reading out of bounds of a DataView.
7 | try {
8 | CBOR.decode(new Uint8Array([]).buffer);
9 | print('never here');
10 | } catch (e) {
11 | print(e.name);
12 | //print(e.stack || e);
13 | }
14 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-expr-newtarget-lhs.js:
--------------------------------------------------------------------------------
1 | /*===
2 | start
3 | ReferenceError
4 | ===*/
5 |
6 | function test() {
7 | new.target = 123;
8 | }
9 |
10 | // Currently causes a runtime ReferenceError.
11 | // XXX: in Firefox the error is compile time.
12 | try {
13 | print('start');
14 | test();
15 | print('done');
16 | } catch (e) {
17 | print(e.name);
18 | }
19 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-misc-numeric-property-access.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Numeric property access.
3 | */
4 |
5 | /*===
6 | SyntaxError
7 | ===*/
8 |
9 | try {
10 | /* Note: "x.5" should apparently be parsed as the two tokens
11 | * "x" (identifier) and ".5" (decimal number)
12 | */
13 | eval("x={5:6}; print(x.5);");
14 | } catch (e) {
15 | print (e.name);
16 | }
17 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-misc-zerosign.js:
--------------------------------------------------------------------------------
1 | /*
2 | * A simple zero sign behavior test.
3 | *
4 | * Comprehensive tests of zero sign behavior belong in e.g. arithmetic
5 | * operation tests.
6 | */
7 |
8 | /*===
9 | Infinity number
10 | -Infinity number
11 | ===*/
12 |
13 | var t;
14 |
15 | t = 1 / +0;
16 | print(t, typeof t);
17 |
18 | t = 1 / -0;
19 | print(t, typeof t);
20 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-stmt-dowhile-bug.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Test that we support the invalid but out-in-the-wild variation
3 | * described in:
4 | *
5 | * https://bugs.ecmascript.org/show_bug.cgi?id=8
6 | */
7 |
8 | /*===
9 | loop
10 | false
11 | ===*/
12 |
13 | try {
14 | print(eval("do{print('loop')}while(false)false"));
15 | } catch (e) {
16 | print(e.name);
17 | }
18 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_DATE_TZO_GMTIME.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_DATE_TZO_GMTIME
2 | introduced: 1.0.0
3 | default: false
4 | tags:
5 | - date
6 | - portability
7 | description: >
8 | Use gmtime() to get local time offset at a certain time.
9 | When enabled, appropriate date/time headers must be included.
10 |
11 | Since gmtime() is not re-entrant, this is not thread safe.
12 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_FUNC_NAME_PROPERTY.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_FUNC_NAME_PROPERTY
2 | introduced: 2.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | - compliance
7 | description: >
8 | Add a "name" property to function instances. This is part of ECMAScript
9 | requirements, but low memory devices can sometimes opt to not include the
10 | .name to reduce footprint.
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_OCTAL_SUPPORT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_OCTAL_SUPPORT
2 | introduced: 1.0.0
3 | removed: 2.0.0
4 | default: true
5 | tags:
6 | - ecmascript
7 | description: >
8 | Enable optional octal number support (ECMAScript E5/E5.1
9 | Annex B: http://www.ecma-international.org/ecma-262/5.1/#sec-B).
10 | Recommended because existing code bases use octal numbers.
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_PANIC_SEGFAULT.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_PANIC_SEGFAULT
2 | introduced: 1.0.0
3 | removed: 2.0.0
4 | default: false
5 | tags:
6 | - portability
7 | description: >
8 | Cause an intentional segfault when the default panic handler is invoked.
9 | This is useful when debugging with valgrind because a segfault provides
10 | a nice C traceback in valgrind.
11 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_REPL_ISINF.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_REPL_ISINF
2 | introduced: 1.0.0
3 | default: false
4 | tags:
5 | - portability
6 | description: >
7 | Provide a built-in replacement for isinf(), duk_repl_isinf.
8 |
9 | When enabled, define DUK_ISINF as duk_repl_isinf.
10 |
11 | # XXX: the dependency between DUK_USE_REPL_ISINF and DUK_ISINF
12 | # is a bit awkward.
13 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_REPL_ISNAN.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_REPL_ISNAN
2 | introduced: 1.0.0
3 | default: false
4 | tags:
5 | - portability
6 | description: >
7 | Provide a built-in replacement for isnan(), duk_repl_isnan.
8 |
9 | When enabled, define DUK_ISNAN as duk_repl_isnan.
10 |
11 | # XXX: the dependency between DUK_USE_REPL_ISNAN and DUK_ISNAN
12 | # is a bit awkward.
13 |
--------------------------------------------------------------------------------
/config/config-options/DUK_USE_SECTION_B.yaml:
--------------------------------------------------------------------------------
1 | define: DUK_USE_SECTION_B
2 | introduced: 1.0.0
3 | default: true
4 | tags:
5 | - ecmascript
6 | description: >
7 | Enable optional features in ECMAScript specification
8 | Annex B: http://www.ecma-international.org/ecma-262/5.1/#sec-B.
9 |
10 | When disabled, escape(), unescape(), and String.prototype.substr()
11 | throw an error.
12 |
--------------------------------------------------------------------------------
/config/helper-snippets/DUK_F_WINDOWS.h.in:
--------------------------------------------------------------------------------
1 | /* Windows, both 32-bit and 64-bit */
2 | #if defined(_WIN32) || defined(WIN32) || defined(_WIN64) || defined(WIN64) || \
3 | defined(__WIN32__) || defined(__TOS_WIN__) || defined(__WINDOWS__)
4 | #define DUK_F_WINDOWS
5 | #if defined(_WIN64) || defined(WIN64)
6 | #define DUK_F_WIN64
7 | #else
8 | #define DUK_F_WIN32
9 | #endif
10 | #endif
11 |
--------------------------------------------------------------------------------
/config/platforms/platform_orbis.h.in:
--------------------------------------------------------------------------------
1 | /* Orbis = PS4 */
2 | #define DUK_USE_DATE_NOW_GETTIMEOFDAY
3 | #define DUK_USE_DATE_TZO_GMTIME_S
4 | /* no parsing (not an error) */
5 | #define DUK_USE_DATE_FMT_STRFTIME
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | #define DUK_USE_OS_STRING "orbis"
13 |
--------------------------------------------------------------------------------
/licenses/xoroshiro128plus.txt:
--------------------------------------------------------------------------------
1 | /* Written in 2016 by David Blackman and Sebastiano Vigna (vigna@acm.org)
2 |
3 | To the extent possible under law, the author has dedicated all copyright
4 | and related and neighboring rights to this software to the public domain
5 | worldwide. This software is distributed without any warranty.
6 |
7 | See . */
8 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bi-cbor-dec-64bit-tag.js:
--------------------------------------------------------------------------------
1 | /*===
2 | [1,2,3]
3 | done
4 | ===*/
5 |
6 | // While 64-bit integers might not be supported, a 64-bit tag must still be
7 | // at least ignored.
8 | var t = CBOR.decode(new Uint8Array([
9 | 0xdb, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x83, 0x01, 0x02, 0x03
10 | ]));
11 | print(JSON.stringify(t));
12 |
13 | print('done');
14 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bi-duktape-enc-jx.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Duktape.enc() JX
3 | */
4 |
5 | /*===
6 | [undefined,null,undefined,undefined,undefined,1,undefined]
7 | ===*/
8 |
9 | function test() {
10 | // Array gaps: 'undefined'.
11 | print(Duktape.enc('jx', [ void 0, null,,,, 1,, ]));
12 | }
13 |
14 | try {
15 | test();
16 | } catch (e) {
17 | print(e.stack || e);
18 | }
19 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bi-global-parseint-leadzero.js:
--------------------------------------------------------------------------------
1 | /*
2 | * parseInt() has no auto octal behavior and will parse octal
3 | * look-alikes as decimal.
4 | */
5 |
6 | /*===
7 | 777
8 | 778
9 | 779
10 | ===*/
11 |
12 | try {
13 | print(parseInt('0777'));
14 | print(parseInt('0778'));
15 | print(parseInt('0779'));
16 | } catch (e) {
17 | print(e.stack || e);
18 | }
19 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-coroutine-yield-refzero-2-gh2204.js:
--------------------------------------------------------------------------------
1 | /*===
2 | RangeError: aiee
3 | done
4 | ===*/
5 |
6 | function yielder() {
7 | var yield = Duktape.Thread.yield;
8 | t = {};
9 | throw new RangeError('aiee');
10 | }
11 | var t = Duktape.Thread(yielder);
12 | try {
13 | Duktape.Thread.resume(t);
14 | } catch (e) {
15 | print(e);
16 | }
17 | print('done');
18 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-bug-dowhile-infloop.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Testcase for a bug reported by Aurélien Bouilland:
3 | *
4 | * The do-while loop never terminates in Duktape 0.7.0.
5 | */
6 |
7 | /*===
8 | 20
9 | 22
10 | 24
11 | 26
12 | ===*/
13 |
14 | var i = 0;
15 | do {
16 | if (i < 20) continue;
17 | print(i);
18 | if (i > 25) break;
19 | i++;
20 | } while (++i < 30);
21 |
--------------------------------------------------------------------------------
/tests/ecmascript/test-dev-number-whitespace.js:
--------------------------------------------------------------------------------
1 | /*===
2 | 0
3 | 0
4 | 0
5 | ===*/
6 |
7 | /* The ToNumber() coercion yields zero from an empty string or
8 | * from a string consisting entirely of whitespace. See E5
9 | * Section 9.3.1.
10 | *
11 | * Unary plus is an easy way to get a plain ToNumber() coercion.
12 | */
13 |
14 | print(+"");
15 | print(+" ");
16 | print(+"\n\n");
17 |
--------------------------------------------------------------------------------