@scriptc/runtime 0.0.0 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/package.json +16 -6
- package/src/scr_array.c +488 -0
- package/src/scr_assert.c +1393 -0
- package/src/scr_async.c +2593 -0
- package/src/scr_async_dyn.c +607 -0
- package/src/scr_bytes.c +1425 -0
- package/src/scr_bytes_io.c +161 -0
- package/src/scr_child.c +3587 -0
- package/src/scr_closure.c +214 -0
- package/src/scr_console.c +143 -0
- package/src/scr_cycle.c +218 -0
- package/src/scr_dc.c +805 -0
- package/src/scr_dgram.c +1007 -0
- package/src/scr_dyn_handle.c +154 -0
- package/src/scr_dyn_invoke.c +644 -0
- package/src/scr_error.c +332 -0
- package/src/scr_events.c +714 -0
- package/src/scr_events_emitter.c +699 -0
- package/src/scr_exception.c +242 -0
- package/src/scr_fetch.c +1130 -0
- package/src/scr_fetch_curl.c +654 -0
- package/src/scr_http.c +3482 -0
- package/src/scr_http2.c +3030 -0
- package/src/scr_inspect.c +803 -0
- package/src/scr_inspect_island.c +51 -0
- package/src/scr_island.c +9363 -0
- package/src/scr_json.c +2151 -0
- package/src/scr_lib.c +3612 -0
- package/src/scr_loop_epoll.c +241 -0
- package/src/scr_loop_kqueue.c +121 -0
- package/src/scr_loop_wsapoll.c +208 -0
- package/src/scr_map.c +591 -0
- package/src/scr_net.c +3017 -0
- package/src/scr_net_island.c +458 -0
- package/src/scr_number.c +115 -0
- package/src/scr_object.c +25 -0
- package/src/scr_path.c +1266 -0
- package/src/scr_platform.h +119 -0
- package/src/scr_readline.c +287 -0
- package/src/scr_regex.c +1080 -0
- package/src/scr_runtime.h +5046 -0
- package/src/scr_stream.c +2877 -0
- package/src/scr_string.c +1264 -0
- package/src/scr_symbol.c +132 -0
- package/src/scr_test.c +662 -0
- package/src/scr_tls.c +1520 -0
- package/src/scr_union.c +105 -0
- package/src/scr_url.c +911 -0
- package/src/scr_url_internal.h +29 -0
- package/src/scr_url_params.c +561 -0
- package/src/scr_watch.c +568 -0
- package/src/scr_web.c +1778 -0
- package/src/scr_win.c +76 -0
- package/src/scr_zlib.c +197 -0
- package/src/scr_zlib_island.c +15 -0
- package/vendor/README.md +52 -0
- package/vendor/curl/COPYRIGHT +534 -0
- package/vendor/curl/include/curl/curl.h +3214 -0
- package/vendor/curl/include/curl/curlver.h +79 -0
- package/vendor/curl/include/curl/easy.h +125 -0
- package/vendor/curl/include/curl/header.h +74 -0
- package/vendor/curl/include/curl/mprintf.h +52 -0
- package/vendor/curl/include/curl/multi.h +460 -0
- package/vendor/curl/include/curl/options.h +70 -0
- package/vendor/curl/include/curl/stdcheaders.h +35 -0
- package/vendor/curl/include/curl/system.h +508 -0
- package/vendor/curl/include/curl/typecheck-gcc.h +716 -0
- package/vendor/curl/include/curl/urlapi.h +149 -0
- package/vendor/curl/include/curl/websockets.h +84 -0
- package/vendor/mbedtls/LICENSE +553 -0
- package/vendor/mbedtls/include/CMakeLists.txt +22 -0
- package/vendor/mbedtls/include/mbedtls/aes.h +631 -0
- package/vendor/mbedtls/include/mbedtls/aria.h +343 -0
- package/vendor/mbedtls/include/mbedtls/asn1.h +642 -0
- package/vendor/mbedtls/include/mbedtls/asn1write.h +390 -0
- package/vendor/mbedtls/include/mbedtls/base64.h +82 -0
- package/vendor/mbedtls/include/mbedtls/bignum.h +1088 -0
- package/vendor/mbedtls/include/mbedtls/block_cipher.h +76 -0
- package/vendor/mbedtls/include/mbedtls/build_info.h +194 -0
- package/vendor/mbedtls/include/mbedtls/camellia.h +305 -0
- package/vendor/mbedtls/include/mbedtls/ccm.h +526 -0
- package/vendor/mbedtls/include/mbedtls/chacha20.h +209 -0
- package/vendor/mbedtls/include/mbedtls/chachapoly.h +351 -0
- package/vendor/mbedtls/include/mbedtls/check_config.h +1149 -0
- package/vendor/mbedtls/include/mbedtls/cipher.h +1250 -0
- package/vendor/mbedtls/include/mbedtls/cmac.h +246 -0
- package/vendor/mbedtls/include/mbedtls/compat-2.x.h +46 -0
- package/vendor/mbedtls/include/mbedtls/config_adjust_legacy_crypto.h +578 -0
- package/vendor/mbedtls/include/mbedtls/config_adjust_legacy_from_psa.h +873 -0
- package/vendor/mbedtls/include/mbedtls/config_adjust_psa_from_legacy.h +359 -0
- package/vendor/mbedtls/include/mbedtls/config_adjust_psa_superset_legacy.h +145 -0
- package/vendor/mbedtls/include/mbedtls/config_adjust_ssl.h +91 -0
- package/vendor/mbedtls/include/mbedtls/config_adjust_x509.h +35 -0
- package/vendor/mbedtls/include/mbedtls/config_psa.h +61 -0
- package/vendor/mbedtls/include/mbedtls/constant_time.h +36 -0
- package/vendor/mbedtls/include/mbedtls/ctr_drbg.h +596 -0
- package/vendor/mbedtls/include/mbedtls/debug.h +156 -0
- package/vendor/mbedtls/include/mbedtls/des.h +385 -0
- package/vendor/mbedtls/include/mbedtls/dhm.h +972 -0
- package/vendor/mbedtls/include/mbedtls/ecdh.h +455 -0
- package/vendor/mbedtls/include/mbedtls/ecdsa.h +674 -0
- package/vendor/mbedtls/include/mbedtls/ecjpake.h +298 -0
- package/vendor/mbedtls/include/mbedtls/ecp.h +1517 -0
- package/vendor/mbedtls/include/mbedtls/entropy.h +274 -0
- package/vendor/mbedtls/include/mbedtls/error.h +201 -0
- package/vendor/mbedtls/include/mbedtls/gcm.h +387 -0
- package/vendor/mbedtls/include/mbedtls/hkdf.h +124 -0
- package/vendor/mbedtls/include/mbedtls/hmac_drbg.h +434 -0
- package/vendor/mbedtls/include/mbedtls/lms.h +440 -0
- package/vendor/mbedtls/include/mbedtls/mbedtls_config.h +4446 -0
- package/vendor/mbedtls/include/mbedtls/md.h +526 -0
- package/vendor/mbedtls/include/mbedtls/md5.h +190 -0
- package/vendor/mbedtls/include/mbedtls/memory_buffer_alloc.h +142 -0
- package/vendor/mbedtls/include/mbedtls/net_sockets.h +299 -0
- package/vendor/mbedtls/include/mbedtls/nist_kw.h +166 -0
- package/vendor/mbedtls/include/mbedtls/oid.h +727 -0
- package/vendor/mbedtls/include/mbedtls/pem.h +160 -0
- package/vendor/mbedtls/include/mbedtls/pk.h +1303 -0
- package/vendor/mbedtls/include/mbedtls/pkcs12.h +186 -0
- package/vendor/mbedtls/include/mbedtls/pkcs5.h +198 -0
- package/vendor/mbedtls/include/mbedtls/pkcs7.h +252 -0
- package/vendor/mbedtls/include/mbedtls/platform.h +516 -0
- package/vendor/mbedtls/include/mbedtls/platform_time.h +79 -0
- package/vendor/mbedtls/include/mbedtls/platform_util.h +247 -0
- package/vendor/mbedtls/include/mbedtls/poly1305.h +168 -0
- package/vendor/mbedtls/include/mbedtls/private_access.h +20 -0
- package/vendor/mbedtls/include/mbedtls/psa_util.h +207 -0
- package/vendor/mbedtls/include/mbedtls/ripemd160.h +136 -0
- package/vendor/mbedtls/include/mbedtls/rsa.h +1170 -0
- package/vendor/mbedtls/include/mbedtls/sha1.h +219 -0
- package/vendor/mbedtls/include/mbedtls/sha256.h +200 -0
- package/vendor/mbedtls/include/mbedtls/sha3.h +172 -0
- package/vendor/mbedtls/include/mbedtls/sha512.h +208 -0
- package/vendor/mbedtls/include/mbedtls/ssl.h +5887 -0
- package/vendor/mbedtls/include/mbedtls/ssl_cache.h +187 -0
- package/vendor/mbedtls/include/mbedtls/ssl_ciphersuites.h +482 -0
- package/vendor/mbedtls/include/mbedtls/ssl_cookie.h +106 -0
- package/vendor/mbedtls/include/mbedtls/ssl_ticket.h +199 -0
- package/vendor/mbedtls/include/mbedtls/threading.h +167 -0
- package/vendor/mbedtls/include/mbedtls/timing.h +94 -0
- package/vendor/mbedtls/include/mbedtls/version.h +78 -0
- package/vendor/mbedtls/include/mbedtls/x509.h +500 -0
- package/vendor/mbedtls/include/mbedtls/x509_crl.h +184 -0
- package/vendor/mbedtls/include/mbedtls/x509_crt.h +1208 -0
- package/vendor/mbedtls/include/mbedtls/x509_csr.h +382 -0
- package/vendor/mbedtls/include/psa/build_info.h +20 -0
- package/vendor/mbedtls/include/psa/crypto.h +4998 -0
- package/vendor/mbedtls/include/psa/crypto_adjust_auto_enabled.h +31 -0
- package/vendor/mbedtls/include/psa/crypto_adjust_config_dependencies.h +51 -0
- package/vendor/mbedtls/include/psa/crypto_adjust_config_key_pair_types.h +101 -0
- package/vendor/mbedtls/include/psa/crypto_adjust_config_synonyms.h +49 -0
- package/vendor/mbedtls/include/psa/crypto_builtin_composites.h +214 -0
- package/vendor/mbedtls/include/psa/crypto_builtin_key_derivation.h +118 -0
- package/vendor/mbedtls/include/psa/crypto_builtin_primitives.h +114 -0
- package/vendor/mbedtls/include/psa/crypto_compat.h +230 -0
- package/vendor/mbedtls/include/psa/crypto_config.h +145 -0
- package/vendor/mbedtls/include/psa/crypto_driver_common.h +44 -0
- package/vendor/mbedtls/include/psa/crypto_driver_contexts_composites.h +151 -0
- package/vendor/mbedtls/include/psa/crypto_driver_contexts_key_derivation.h +52 -0
- package/vendor/mbedtls/include/psa/crypto_driver_contexts_primitives.h +105 -0
- package/vendor/mbedtls/include/psa/crypto_extra.h +2145 -0
- package/vendor/mbedtls/include/psa/crypto_legacy.h +88 -0
- package/vendor/mbedtls/include/psa/crypto_platform.h +102 -0
- package/vendor/mbedtls/include/psa/crypto_se_driver.h +1383 -0
- package/vendor/mbedtls/include/psa/crypto_sizes.h +1319 -0
- package/vendor/mbedtls/include/psa/crypto_struct.h +527 -0
- package/vendor/mbedtls/include/psa/crypto_types.h +508 -0
- package/vendor/mbedtls/include/psa/crypto_values.h +2782 -0
- package/vendor/mbedtls/library/aes.c +2294 -0
- package/vendor/mbedtls/library/aesce.c +624 -0
- package/vendor/mbedtls/library/aesce.h +136 -0
- package/vendor/mbedtls/library/aesni.c +846 -0
- package/vendor/mbedtls/library/aesni.h +162 -0
- package/vendor/mbedtls/library/alignment.h +704 -0
- package/vendor/mbedtls/library/aria.c +969 -0
- package/vendor/mbedtls/library/asn1parse.c +468 -0
- package/vendor/mbedtls/library/asn1write.c +440 -0
- package/vendor/mbedtls/library/base64.c +322 -0
- package/vendor/mbedtls/library/base64_internal.h +45 -0
- package/vendor/mbedtls/library/bignum.c +2583 -0
- package/vendor/mbedtls/library/bignum_core.c +1240 -0
- package/vendor/mbedtls/library/bignum_core.h +872 -0
- package/vendor/mbedtls/library/bignum_core_invasive.h +38 -0
- package/vendor/mbedtls/library/bignum_internal.h +122 -0
- package/vendor/mbedtls/library/bignum_mod.c +394 -0
- package/vendor/mbedtls/library/bignum_mod.h +452 -0
- package/vendor/mbedtls/library/bignum_mod_raw.c +276 -0
- package/vendor/mbedtls/library/bignum_mod_raw.h +416 -0
- package/vendor/mbedtls/library/bignum_mod_raw_invasive.h +34 -0
- package/vendor/mbedtls/library/block_cipher.c +207 -0
- package/vendor/mbedtls/library/block_cipher_internal.h +99 -0
- package/vendor/mbedtls/library/bn_mul.h +1094 -0
- package/vendor/mbedtls/library/camellia.c +1058 -0
- package/vendor/mbedtls/library/ccm.c +777 -0
- package/vendor/mbedtls/library/chacha20.c +563 -0
- package/vendor/mbedtls/library/chacha20_internal.h +23 -0
- package/vendor/mbedtls/library/chachapoly.c +487 -0
- package/vendor/mbedtls/library/check_crypto_config.h +136 -0
- package/vendor/mbedtls/library/cipher.c +1712 -0
- package/vendor/mbedtls/library/cipher_invasive.h +28 -0
- package/vendor/mbedtls/library/cipher_wrap.c +2482 -0
- package/vendor/mbedtls/library/cipher_wrap.h +178 -0
- package/vendor/mbedtls/library/cmac.c +1067 -0
- package/vendor/mbedtls/library/common.h +487 -0
- package/vendor/mbedtls/library/constant_time.c +247 -0
- package/vendor/mbedtls/library/constant_time_impl.h +541 -0
- package/vendor/mbedtls/library/constant_time_internal.h +579 -0
- package/vendor/mbedtls/library/ctr.h +35 -0
- package/vendor/mbedtls/library/ctr_drbg.c +1016 -0
- package/vendor/mbedtls/library/debug.c +475 -0
- package/vendor/mbedtls/library/debug_internal.h +185 -0
- package/vendor/mbedtls/library/des.c +1042 -0
- package/vendor/mbedtls/library/dhm.c +700 -0
- package/vendor/mbedtls/library/ecdh.c +696 -0
- package/vendor/mbedtls/library/ecdsa.c +858 -0
- package/vendor/mbedtls/library/ecjpake.c +1216 -0
- package/vendor/mbedtls/library/ecp.c +3674 -0
- package/vendor/mbedtls/library/ecp_curves.c +6125 -0
- package/vendor/mbedtls/library/ecp_curves_new.c +9 -0
- package/vendor/mbedtls/library/ecp_internal_alt.h +287 -0
- package/vendor/mbedtls/library/ecp_invasive.h +305 -0
- package/vendor/mbedtls/library/entropy.c +680 -0
- package/vendor/mbedtls/library/entropy_poll.c +233 -0
- package/vendor/mbedtls/library/entropy_poll.h +64 -0
- package/vendor/mbedtls/library/error.c +878 -0
- package/vendor/mbedtls/library/gcm.c +1330 -0
- package/vendor/mbedtls/library/hkdf.c +161 -0
- package/vendor/mbedtls/library/hmac_drbg.c +633 -0
- package/vendor/mbedtls/library/lmots.c +789 -0
- package/vendor/mbedtls/library/lmots.h +288 -0
- package/vendor/mbedtls/library/lms.c +778 -0
- package/vendor/mbedtls/library/md.c +1108 -0
- package/vendor/mbedtls/library/md5.c +426 -0
- package/vendor/mbedtls/library/md_psa.h +26 -0
- package/vendor/mbedtls/library/md_wrap.h +46 -0
- package/vendor/mbedtls/library/memory_buffer_alloc.c +751 -0
- package/vendor/mbedtls/library/mps_common.h +181 -0
- package/vendor/mbedtls/library/mps_error.h +89 -0
- package/vendor/mbedtls/library/mps_reader.c +538 -0
- package/vendor/mbedtls/library/mps_reader.h +366 -0
- package/vendor/mbedtls/library/mps_trace.c +112 -0
- package/vendor/mbedtls/library/mps_trace.h +154 -0
- package/vendor/mbedtls/library/net_sockets.c +694 -0
- package/vendor/mbedtls/library/nist_kw.c +729 -0
- package/vendor/mbedtls/library/oid.c +1166 -0
- package/vendor/mbedtls/library/padlock.c +157 -0
- package/vendor/mbedtls/library/padlock.h +111 -0
- package/vendor/mbedtls/library/pem.c +554 -0
- package/vendor/mbedtls/library/pk.c +1602 -0
- package/vendor/mbedtls/library/pk_ecc.c +261 -0
- package/vendor/mbedtls/library/pk_internal.h +241 -0
- package/vendor/mbedtls/library/pk_wrap.c +1618 -0
- package/vendor/mbedtls/library/pk_wrap.h +138 -0
- package/vendor/mbedtls/library/pkcs12.c +437 -0
- package/vendor/mbedtls/library/pkcs5.c +500 -0
- package/vendor/mbedtls/library/pkcs7.c +787 -0
- package/vendor/mbedtls/library/pkparse.c +1392 -0
- package/vendor/mbedtls/library/pkwrite.c +631 -0
- package/vendor/mbedtls/library/pkwrite.h +121 -0
- package/vendor/mbedtls/library/platform.c +402 -0
- package/vendor/mbedtls/library/platform_util.c +258 -0
- package/vendor/mbedtls/library/poly1305.c +492 -0
- package/vendor/mbedtls/library/psa_crypto.c +9532 -0
- package/vendor/mbedtls/library/psa_crypto_aead.c +646 -0
- package/vendor/mbedtls/library/psa_crypto_aead.h +499 -0
- package/vendor/mbedtls/library/psa_crypto_cipher.c +747 -0
- package/vendor/mbedtls/library/psa_crypto_cipher.h +316 -0
- package/vendor/mbedtls/library/psa_crypto_client.c +22 -0
- package/vendor/mbedtls/library/psa_crypto_core.h +983 -0
- package/vendor/mbedtls/library/psa_crypto_core_common.h +52 -0
- package/vendor/mbedtls/library/psa_crypto_driver_wrappers.h +2896 -0
- package/vendor/mbedtls/library/psa_crypto_driver_wrappers_no_static.c +256 -0
- package/vendor/mbedtls/library/psa_crypto_driver_wrappers_no_static.h +31 -0
- package/vendor/mbedtls/library/psa_crypto_ecp.c +594 -0
- package/vendor/mbedtls/library/psa_crypto_ecp.h +267 -0
- package/vendor/mbedtls/library/psa_crypto_ffdh.c +361 -0
- package/vendor/mbedtls/library/psa_crypto_ffdh.h +131 -0
- package/vendor/mbedtls/library/psa_crypto_hash.c +470 -0
- package/vendor/mbedtls/library/psa_crypto_hash.h +211 -0
- package/vendor/mbedtls/library/psa_crypto_invasive.h +92 -0
- package/vendor/mbedtls/library/psa_crypto_its.h +131 -0
- package/vendor/mbedtls/library/psa_crypto_mac.c +505 -0
- package/vendor/mbedtls/library/psa_crypto_mac.h +264 -0
- package/vendor/mbedtls/library/psa_crypto_pake.c +571 -0
- package/vendor/mbedtls/library/psa_crypto_pake.h +159 -0
- package/vendor/mbedtls/library/psa_crypto_random.c +181 -0
- package/vendor/mbedtls/library/psa_crypto_random.h +72 -0
- package/vendor/mbedtls/library/psa_crypto_random_impl.h +200 -0
- package/vendor/mbedtls/library/psa_crypto_rsa.c +714 -0
- package/vendor/mbedtls/library/psa_crypto_rsa.h +321 -0
- package/vendor/mbedtls/library/psa_crypto_se.c +373 -0
- package/vendor/mbedtls/library/psa_crypto_se.h +192 -0
- package/vendor/mbedtls/library/psa_crypto_slot_management.c +1137 -0
- package/vendor/mbedtls/library/psa_crypto_slot_management.h +344 -0
- package/vendor/mbedtls/library/psa_crypto_storage.c +481 -0
- package/vendor/mbedtls/library/psa_crypto_storage.h +392 -0
- package/vendor/mbedtls/library/psa_its_file.c +254 -0
- package/vendor/mbedtls/library/psa_util.c +614 -0
- package/vendor/mbedtls/library/psa_util_internal.h +100 -0
- package/vendor/mbedtls/library/ripemd160.c +490 -0
- package/vendor/mbedtls/library/rsa.c +3121 -0
- package/vendor/mbedtls/library/rsa_alt_helpers.c +455 -0
- package/vendor/mbedtls/library/rsa_alt_helpers.h +209 -0
- package/vendor/mbedtls/library/rsa_internal.h +188 -0
- package/vendor/mbedtls/library/sha1.c +480 -0
- package/vendor/mbedtls/library/sha256.c +983 -0
- package/vendor/mbedtls/library/sha3.c +721 -0
- package/vendor/mbedtls/library/sha512.c +1115 -0
- package/vendor/mbedtls/library/ssl_cache.c +410 -0
- package/vendor/mbedtls/library/ssl_ciphersuites.c +2050 -0
- package/vendor/mbedtls/library/ssl_ciphersuites_internal.h +154 -0
- package/vendor/mbedtls/library/ssl_client.c +1023 -0
- package/vendor/mbedtls/library/ssl_client.h +22 -0
- package/vendor/mbedtls/library/ssl_cookie.c +384 -0
- package/vendor/mbedtls/library/ssl_debug_helpers.h +85 -0
- package/vendor/mbedtls/library/ssl_debug_helpers_generated.c +251 -0
- package/vendor/mbedtls/library/ssl_misc.h +3198 -0
- package/vendor/mbedtls/library/ssl_msg.c +6619 -0
- package/vendor/mbedtls/library/ssl_ticket.c +556 -0
- package/vendor/mbedtls/library/ssl_tls.c +10234 -0
- package/vendor/mbedtls/library/ssl_tls12_client.c +3688 -0
- package/vendor/mbedtls/library/ssl_tls12_server.c +4311 -0
- package/vendor/mbedtls/library/ssl_tls13_client.c +3208 -0
- package/vendor/mbedtls/library/ssl_tls13_generic.c +1793 -0
- package/vendor/mbedtls/library/ssl_tls13_invasive.h +23 -0
- package/vendor/mbedtls/library/ssl_tls13_keys.c +1918 -0
- package/vendor/mbedtls/library/ssl_tls13_keys.h +668 -0
- package/vendor/mbedtls/library/ssl_tls13_server.c +3624 -0
- package/vendor/mbedtls/library/threading.c +193 -0
- package/vendor/mbedtls/library/threading_internal.h +28 -0
- package/vendor/mbedtls/library/timing.c +152 -0
- package/vendor/mbedtls/library/version.c +32 -0
- package/vendor/mbedtls/library/version_features.c +856 -0
- package/vendor/mbedtls/library/x509.c +1776 -0
- package/vendor/mbedtls/library/x509_create.c +570 -0
- package/vendor/mbedtls/library/x509_crl.c +708 -0
- package/vendor/mbedtls/library/x509_crt.c +3311 -0
- package/vendor/mbedtls/library/x509_csr.c +648 -0
- package/vendor/mbedtls/library/x509_internal.h +101 -0
- package/vendor/mbedtls/library/x509write.c +174 -0
- package/vendor/mbedtls/library/x509write_crt.c +688 -0
- package/vendor/mbedtls/library/x509write_csr.c +336 -0
- package/vendor/quickjs-ng/CMakeLists.txt +566 -0
- package/vendor/quickjs-ng/LICENSE +24 -0
- package/vendor/quickjs-ng/README.md +24 -0
- package/vendor/quickjs-ng/api-test.c +1195 -0
- package/vendor/quickjs-ng/builtin-array-fromasync.h +119 -0
- package/vendor/quickjs-ng/builtin-iterator-zip-keyed.h +332 -0
- package/vendor/quickjs-ng/builtin-iterator-zip.h +337 -0
- package/vendor/quickjs-ng/cutils.h +1998 -0
- package/vendor/quickjs-ng/dtoa.c +1619 -0
- package/vendor/quickjs-ng/dtoa.h +87 -0
- package/vendor/quickjs-ng/gen/function_source.c +81 -0
- package/vendor/quickjs-ng/gen/hello.c +53 -0
- package/vendor/quickjs-ng/gen/hello_module.c +106 -0
- package/vendor/quickjs-ng/gen/repl.c +3036 -0
- package/vendor/quickjs-ng/gen/standalone.c +323 -0
- package/vendor/quickjs-ng/gen/test_fib.c +81 -0
- package/vendor/quickjs-ng/libregexp-opcode.h +73 -0
- package/vendor/quickjs-ng/libregexp.c +3474 -0
- package/vendor/quickjs-ng/libregexp.h +101 -0
- package/vendor/quickjs-ng/libunicode-table.h +5173 -0
- package/vendor/quickjs-ng/libunicode.c +2069 -0
- package/vendor/quickjs-ng/libunicode.h +172 -0
- package/vendor/quickjs-ng/list.h +107 -0
- package/vendor/quickjs-ng/lre-test.c +52 -0
- package/vendor/quickjs-ng/qjs.c +762 -0
- package/vendor/quickjs-ng/qjsc.c +673 -0
- package/vendor/quickjs-ng/quickjs-atom.h +280 -0
- package/vendor/quickjs-ng/quickjs-c-atomics.h +54 -0
- package/vendor/quickjs-ng/quickjs-libc.c +5037 -0
- package/vendor/quickjs-ng/quickjs-libc.h +87 -0
- package/vendor/quickjs-ng/quickjs-opcode.h +377 -0
- package/vendor/quickjs-ng/quickjs.c +64041 -0
- package/vendor/quickjs-ng/quickjs.h +1447 -0
- package/vendor/quickjs-ng/run-test262.c +2374 -0
- package/vendor/quickjs-ng/unicode_gen.c +3121 -0
- package/vendor/quickjs-ng/unicode_gen_def.h +310 -0
- package/vendor/ryu/LICENSE-Boost +23 -0
- package/vendor/ryu/common.h +114 -0
- package/vendor/ryu/d2s.c +509 -0
- package/vendor/ryu/d2s_full_table.h +367 -0
- package/vendor/ryu/d2s_intrinsics.h +357 -0
- package/vendor/ryu/d2s_small_table.h +186 -0
- package/vendor/ryu/digit_table.h +35 -0
- package/vendor/ryu/ryu.h +46 -0
- package/vendor/zlib/LICENSE +22 -0
- package/vendor/zlib/adler32.c +164 -0
- package/vendor/zlib/compress.c +75 -0
- package/vendor/zlib/crc32.c +1049 -0
- package/vendor/zlib/crc32.h +9446 -0
- package/vendor/zlib/deflate.c +2139 -0
- package/vendor/zlib/deflate.h +377 -0
- package/vendor/zlib/gzclose.c +23 -0
- package/vendor/zlib/gzguts.h +214 -0
- package/vendor/zlib/gzlib.c +582 -0
- package/vendor/zlib/gzread.c +602 -0
- package/vendor/zlib/gzwrite.c +631 -0
- package/vendor/zlib/infback.c +628 -0
- package/vendor/zlib/inffast.c +320 -0
- package/vendor/zlib/inffast.h +11 -0
- package/vendor/zlib/inffixed.h +94 -0
- package/vendor/zlib/inflate.c +1526 -0
- package/vendor/zlib/inflate.h +126 -0
- package/vendor/zlib/inftrees.c +299 -0
- package/vendor/zlib/inftrees.h +62 -0
- package/vendor/zlib/trees.c +1117 -0
- package/vendor/zlib/trees.h +128 -0
- package/vendor/zlib/uncompr.c +85 -0
- package/vendor/zlib/zconf.h +543 -0
- package/vendor/zlib/zlib.h +1938 -0
- package/vendor/zlib/zutil.c +299 -0
- package/vendor/zlib/zutil.h +254 -0
- package/README.md +0 -3
- package/index.js +0 -2
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
/* Checked-dynamic ASYNC surfaces (gated — cc.ts links this TU only when
|
|
2
|
+
* the IR carries the crossing libCalls or dyn dispatch: the scr_dc.c
|
|
3
|
+
* size-class precedent). Everything here rides scr_async.c's public
|
|
4
|
+
* machinery: the DOM-promise reaction helpers (.then/.catch/.finally
|
|
5
|
+
* over SCR_DYN_PROMISE, await of a checked-dynamic value, the
|
|
6
|
+
* `new Promise(setImmediate)` constructor), the AsyncLocalStorage API
|
|
7
|
+
* over the fiber-carried snapshots (the always-linked core keeps only
|
|
8
|
+
* the active slot + RC pair), the unhandled-rejection listener registry
|
|
9
|
+
* (installed into scr_report_unhandled_rejections' hook at
|
|
10
|
+
* registration), and the process-warning channel (emitWarning + the
|
|
11
|
+
* 'warning' listeners + Node's stderr report). */
|
|
12
|
+
#include "scr_runtime.h"
|
|
13
|
+
|
|
14
|
+
#include <stdio.h>
|
|
15
|
+
#include <stdlib.h>
|
|
16
|
+
#include <string.h>
|
|
17
|
+
|
|
18
|
+
#ifdef _WIN32
|
|
19
|
+
#include <process.h>
|
|
20
|
+
#define SCR_WARN_PID() ((long)_getpid())
|
|
21
|
+
#else
|
|
22
|
+
#include <unistd.h>
|
|
23
|
+
#define SCR_WARN_PID() ((long)getpid())
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
static void scr_ad_oom(void) {
|
|
27
|
+
fputs("scriptc: out of memory\n", stderr);
|
|
28
|
+
abort();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* Fresh snapshot storage (the layout lives in scr_runtime.h; the RC pair
|
|
32
|
+
* in scr_async.c — spawn/destroy touch it). */
|
|
33
|
+
static ScrAlsCtx *scr_als_ctx_alloc(size_t len) {
|
|
34
|
+
ScrAlsCtx *c = malloc(sizeof *c + len * sizeof(ScrAlsEntry));
|
|
35
|
+
if (!c) scr_ad_oom();
|
|
36
|
+
c->rc = 1;
|
|
37
|
+
c->len = len;
|
|
38
|
+
return c;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static double scr_als_counter = 0;
|
|
42
|
+
|
|
43
|
+
/* Main-slot teardown (atexit, LIFO after scr_init's audit registration —
|
|
44
|
+
* the dc-registry precedent): a top-level enterWith leaves a context in
|
|
45
|
+
* the main slot at exit; release it before the RC audit counts. */
|
|
46
|
+
static void scr_als_teardown(void) {
|
|
47
|
+
/* atexit runs on the main context — the active slot IS main's. */
|
|
48
|
+
scr_als_ctx_release(*scr_als_active);
|
|
49
|
+
*scr_als_active = NULL;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
double scr_als_new(void) {
|
|
53
|
+
static bool teardown_registered = false;
|
|
54
|
+
if (!teardown_registered) {
|
|
55
|
+
teardown_registered = true;
|
|
56
|
+
atexit(scr_als_teardown);
|
|
57
|
+
}
|
|
58
|
+
return ++scr_als_counter;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
ScrDyn *scr_als_get(double id) {
|
|
62
|
+
const ScrAlsCtx *c = *scr_als_active;
|
|
63
|
+
if (c) {
|
|
64
|
+
for (size_t i = 0; i < c->len; i++) {
|
|
65
|
+
if (c->entries[i].id == id) return scr_dyn_retain(c->entries[i].value);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return scr_dyn_retain(scr_dyn_undefined());
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* Fresh snapshot with (id → value) replaced-or-appended (value borrowed,
|
|
72
|
+
* retained in), installed as the active context; the PREVIOUS snapshot
|
|
73
|
+
* returns (ownership moves out) for scr_als_restore. */
|
|
74
|
+
ScrAlsCtx *scr_als_enter(double id, ScrDyn *value) {
|
|
75
|
+
ScrAlsCtx *prev = *scr_als_active;
|
|
76
|
+
size_t n = prev ? prev->len : 0;
|
|
77
|
+
bool have = false;
|
|
78
|
+
for (size_t i = 0; i < n; i++) {
|
|
79
|
+
if (prev->entries[i].id == id) { have = true; break; }
|
|
80
|
+
}
|
|
81
|
+
ScrAlsCtx *next = scr_als_ctx_alloc(have ? n : n + 1);
|
|
82
|
+
size_t w = 0;
|
|
83
|
+
for (size_t i = 0; i < n; i++) {
|
|
84
|
+
if (prev->entries[i].id == id) continue;
|
|
85
|
+
next->entries[w].id = prev->entries[i].id;
|
|
86
|
+
next->entries[w].value = scr_dyn_retain(prev->entries[i].value);
|
|
87
|
+
w++;
|
|
88
|
+
}
|
|
89
|
+
next->entries[w].id = id;
|
|
90
|
+
next->entries[w].value = scr_dyn_retain(value);
|
|
91
|
+
*scr_als_active = next;
|
|
92
|
+
return prev; /* ownership moves to the caller */
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* The exit() arm: the id REMOVED from the snapshot. */
|
|
96
|
+
ScrAlsCtx *scr_als_enter_absent(double id) {
|
|
97
|
+
ScrAlsCtx *prev = *scr_als_active;
|
|
98
|
+
size_t n = prev ? prev->len : 0;
|
|
99
|
+
size_t keep = 0;
|
|
100
|
+
for (size_t i = 0; i < n; i++) {
|
|
101
|
+
if (prev->entries[i].id != id) keep++;
|
|
102
|
+
}
|
|
103
|
+
ScrAlsCtx *next = scr_als_ctx_alloc(keep);
|
|
104
|
+
size_t w = 0;
|
|
105
|
+
for (size_t i = 0; i < n; i++) {
|
|
106
|
+
if (prev->entries[i].id == id) continue;
|
|
107
|
+
next->entries[w].id = prev->entries[i].id;
|
|
108
|
+
next->entries[w].value = scr_dyn_retain(prev->entries[i].value);
|
|
109
|
+
w++;
|
|
110
|
+
}
|
|
111
|
+
*scr_als_active = next;
|
|
112
|
+
return prev;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
void scr_als_restore(ScrAlsCtx *prev) {
|
|
116
|
+
scr_als_ctx_release(*scr_als_active);
|
|
117
|
+
*scr_als_active = prev; /* ownership moves back in */
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
void scr_als_enter_with(double id, ScrDyn *value) {
|
|
121
|
+
ScrAlsCtx *prev = scr_als_enter(id, value);
|
|
122
|
+
scr_als_ctx_release(prev); /* no restore point — Node's enterWith */
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
void scr_als_disable(double id) {
|
|
126
|
+
ScrAlsCtx *prev = scr_als_enter_absent(id);
|
|
127
|
+
scr_als_ctx_release(prev); /* minimal core: cleared for the current context */
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* run(store, fn, ...args) / exit(fn, ...args): enter (or clear), call the
|
|
131
|
+
* DOM function with the forwarded arguments, restore — the finally, so a
|
|
132
|
+
* throw still restores before propagating. Result +1 or NULL pending. */
|
|
133
|
+
static ScrDyn *scr_als_call_in(ScrAlsCtx *prev, ScrDyn *fn, ScrDyn *args) {
|
|
134
|
+
size_t argc = args->kind == SCR_DYN_ARR ? args->v.arr.len : 0;
|
|
135
|
+
ScrDyn *const *items = args->kind == SCR_DYN_ARR ? args->v.arr.items : NULL;
|
|
136
|
+
ScrDyn *r = scr_dyn_call(fn, items, argc, "callback");
|
|
137
|
+
scr_als_restore(prev);
|
|
138
|
+
return r;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
ScrDyn *scr_als_run(double id, ScrDyn *value, ScrDyn *fn, ScrDyn *args) {
|
|
142
|
+
return scr_als_call_in(scr_als_enter(id, value), fn, args);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
ScrDyn *scr_als_exit_run(double id, ScrDyn *fn, ScrDyn *args) {
|
|
146
|
+
return scr_als_call_in(scr_als_enter_absent(id), fn, args);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
static ScrDyn **scr_urj_listeners = NULL;
|
|
150
|
+
static size_t scr_nurj = 0, scr_urj_cap = 0;
|
|
151
|
+
|
|
152
|
+
static void scr_urj_teardown(void) {
|
|
153
|
+
for (size_t i = 0; i < scr_nurj; i++) scr_dyn_release(scr_urj_listeners[i]);
|
|
154
|
+
free(scr_urj_listeners);
|
|
155
|
+
scr_urj_listeners = NULL;
|
|
156
|
+
scr_nurj = scr_urj_cap = 0;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
static bool scr_urj_dispatch(ScrPromise *p);
|
|
160
|
+
|
|
161
|
+
void scr_process_on_unhandled_rejection(ScrDyn *fn) {
|
|
162
|
+
if (fn->kind != SCR_DYN_FUNC) {
|
|
163
|
+
const char *msg = "The \"listener\" argument must be of type function";
|
|
164
|
+
scr_throw_error_msg_code(SCR_ERR_TYPE, msg, strlen(msg), "ERR_INVALID_ARG_TYPE");
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (scr_nurj == scr_urj_cap) {
|
|
168
|
+
scr_urj_cap = scr_urj_cap ? scr_urj_cap * 2 : 4;
|
|
169
|
+
scr_urj_listeners = realloc(scr_urj_listeners, scr_urj_cap * sizeof *scr_urj_listeners);
|
|
170
|
+
if (!scr_urj_listeners) scr_ad_oom();
|
|
171
|
+
}
|
|
172
|
+
if (scr_nurj == 0) {
|
|
173
|
+
atexit(scr_urj_teardown);
|
|
174
|
+
scr_urj_deliver_fn = scr_urj_dispatch; /* arm the loop-end report */
|
|
175
|
+
}
|
|
176
|
+
scr_urj_listeners[scr_nurj++] = scr_dyn_retain(fn);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/* Dispatch one unhandled rejection to the registered listeners —
|
|
180
|
+
* (reason, promise), Node's signature. A listener throw is an uncaught
|
|
181
|
+
* exception (Node crashes there too): print it and exit 1. Returns
|
|
182
|
+
* false on that crash path. */
|
|
183
|
+
static bool scr_urj_dispatch(ScrPromise *p) {
|
|
184
|
+
ScrDyn *reason = scr_promise_reason_dyn(p);
|
|
185
|
+
ScrDyn *boxed = scr_dyn_new_promise(p);
|
|
186
|
+
ScrDyn *args[2] = {reason, boxed};
|
|
187
|
+
bool ok = true;
|
|
188
|
+
for (size_t i = 0; i < scr_nurj && ok; i++) {
|
|
189
|
+
ScrDyn *r = scr_dyn_call(scr_urj_listeners[i], args, 2, "listener");
|
|
190
|
+
if (r == NULL) ok = false;
|
|
191
|
+
else scr_dyn_release(r);
|
|
192
|
+
}
|
|
193
|
+
scr_dyn_release(reason);
|
|
194
|
+
scr_dyn_release(boxed);
|
|
195
|
+
return ok;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/* `new Promise(setImmediate)` (the Node-suite early-exit shape): the
|
|
199
|
+
* executor IS setImmediate, so resolve rides the immediate queue — a
|
|
200
|
+
* fresh promise an armed immediate fulfills with the undefined DOM value
|
|
201
|
+
* (the executor's resolve receives no argument; the DOM payload keeps
|
|
202
|
+
* promise<dyn> awaiters honest and void awaiters ignore it). +1. */
|
|
203
|
+
static void scr_imm_promise_thunk(ScrClosure *self) {
|
|
204
|
+
ScrPromise *p = (ScrPromise *)scr_box_get_ref(self->caps[0]);
|
|
205
|
+
scr_promise_fulfill_ref(p, scr_dyn_retain(scr_dyn_undefined()), scr_dyn_retain_v,
|
|
206
|
+
scr_dyn_release_v, NULL);
|
|
207
|
+
scr_promise_release(p);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
ScrPromise *scr_immediate_promise(void) {
|
|
211
|
+
ScrPromise *p = scr_promise_new();
|
|
212
|
+
ScrClosure *cb = scr_closure_new((void *)scr_imm_promise_thunk, 1);
|
|
213
|
+
cb->caps[0] = scr_box_new_obj(scr_promise_retain_v, scr_promise_release_v, NULL);
|
|
214
|
+
scr_box_set_ref(cb->caps[0], scr_promise_retain(p));
|
|
215
|
+
scr_set_immediate(cb); /* ownership of cb moves in */
|
|
216
|
+
return p;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/* ── .then/.catch/.finally over DOM promises (scr_dyn_invoke's promise
|
|
220
|
+
* arm and the dc tracePromise reactions) ──────────────────────────────
|
|
221
|
+
* One reaction fiber per registration: it awaits src (the settled-await
|
|
222
|
+
* microtask hop keeps JS's ordering — reactions never run synchronously
|
|
223
|
+
* inside settle), runs the DOM handler, and settles dst. A handler
|
|
224
|
+
* returning a DOM promise is ADOPTED (awaited in a loop, like JS's
|
|
225
|
+
* resolve). Non-callable handlers pass the settlement through (JS's
|
|
226
|
+
* PromisePrototypeThen over non-function reactions). The fiber's own
|
|
227
|
+
* promise is dropped unobserved — the entry consumes every exception
|
|
228
|
+
* into dst, so it can never reject. */
|
|
229
|
+
typedef struct {
|
|
230
|
+
ScrPromise *src, *dst; /* owned */
|
|
231
|
+
ScrDyn *onf, *onr, *onfin; /* owned or NULL */
|
|
232
|
+
} ScrDynThenPack;
|
|
233
|
+
|
|
234
|
+
static void scr_dyn_then_entry(ScrFiber *self, void *ap) {
|
|
235
|
+
(void)self;
|
|
236
|
+
ScrDynThenPack *a = (ScrDynThenPack *)ap;
|
|
237
|
+
ScrDyn *v = scr_await_dyn(a->src);
|
|
238
|
+
bool rejected = scr_exc_pending();
|
|
239
|
+
ScrCaught *c = rejected ? scr_exc_take() : NULL;
|
|
240
|
+
ScrDyn *handler = a->onfin ? a->onfin : (rejected ? a->onr : a->onf);
|
|
241
|
+
if (handler != NULL && handler->kind == SCR_DYN_FUNC) {
|
|
242
|
+
ScrDyn *arg = NULL;
|
|
243
|
+
if (a->onfin == NULL) arg = rejected ? scr_caught_to_dyn(c) : scr_dyn_retain(v);
|
|
244
|
+
ScrDyn *r = scr_dyn_call(handler, arg ? &arg : NULL, arg ? 1 : 0, "handler");
|
|
245
|
+
scr_dyn_release(arg);
|
|
246
|
+
if (r == NULL) {
|
|
247
|
+
/* The handler threw: dst rejects with that. */
|
|
248
|
+
scr_promise_reject_pending(a->dst);
|
|
249
|
+
} else if (a->onfin != NULL) {
|
|
250
|
+
/* finally: the callback's value is dropped and the source
|
|
251
|
+
* settlement passes through (JS — a finally callback returning a
|
|
252
|
+
* promise would delay adoption; that refinement waits for a use). */
|
|
253
|
+
scr_dyn_release(r);
|
|
254
|
+
if (rejected) {
|
|
255
|
+
scr_rethrow(c);
|
|
256
|
+
scr_promise_reject_pending(a->dst);
|
|
257
|
+
} else {
|
|
258
|
+
scr_promise_fulfill_ref(a->dst, scr_dyn_retain(v), scr_dyn_retain_v, scr_dyn_release_v, NULL);
|
|
259
|
+
}
|
|
260
|
+
} else {
|
|
261
|
+
/* Adopt DOM-promise results (JS's resolve walk). */
|
|
262
|
+
while (r != NULL && r->kind == SCR_DYN_PROMISE) {
|
|
263
|
+
ScrDyn *inner = scr_await_dyn(r->v.promise);
|
|
264
|
+
scr_dyn_release(r);
|
|
265
|
+
r = inner;
|
|
266
|
+
if (scr_exc_pending()) {
|
|
267
|
+
scr_promise_reject_pending(a->dst);
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (r != NULL) {
|
|
272
|
+
scr_promise_fulfill_ref(a->dst, r, scr_dyn_retain_v, scr_dyn_release_v, NULL);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
} else if (rejected) {
|
|
276
|
+
scr_rethrow(c);
|
|
277
|
+
scr_promise_reject_pending(a->dst);
|
|
278
|
+
} else {
|
|
279
|
+
scr_promise_fulfill_ref(a->dst, scr_dyn_retain(v), scr_dyn_retain_v, scr_dyn_release_v, NULL);
|
|
280
|
+
}
|
|
281
|
+
scr_caught_release(c);
|
|
282
|
+
scr_dyn_release(v);
|
|
283
|
+
scr_promise_release(a->src);
|
|
284
|
+
scr_promise_release(a->dst);
|
|
285
|
+
scr_dyn_release(a->onf);
|
|
286
|
+
scr_dyn_release(a->onr);
|
|
287
|
+
scr_dyn_release(a->onfin);
|
|
288
|
+
free(a);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
ScrDyn *scr_dyn_promise_then(ScrPromise *src, ScrDyn *onf, ScrDyn *onr, ScrDyn *onfin) {
|
|
292
|
+
ScrDynThenPack *a = malloc(sizeof *a);
|
|
293
|
+
if (!a) scr_ad_oom();
|
|
294
|
+
a->src = scr_promise_retain(src);
|
|
295
|
+
a->dst = scr_promise_new();
|
|
296
|
+
a->onf = onf ? scr_dyn_retain(onf) : NULL;
|
|
297
|
+
a->onr = onr ? scr_dyn_retain(onr) : NULL;
|
|
298
|
+
a->onfin = onfin ? scr_dyn_retain(onfin) : NULL;
|
|
299
|
+
ScrDyn *boxed = scr_dyn_new_promise(a->dst);
|
|
300
|
+
ScrPromise *waiter = scr_async_spawn(scr_dyn_then_entry, a);
|
|
301
|
+
scr_promise_release(waiter); /* the entry never rejects; nobody awaits it */
|
|
302
|
+
return boxed;
|
|
303
|
+
}
|
|
304
|
+
/* `await v` where v is a CHECKED-DYNAMIC value: a DOM promise adopts
|
|
305
|
+
* (the boxed promise awaits — rejections re-throw); every other kind is
|
|
306
|
+
* JS's await-of-a-non-thenable — one microtask hop, the value itself
|
|
307
|
+
* (+1). Thenable ADOPTION (a plain object carrying a then method) is not
|
|
308
|
+
* modeled — SEMANTICS.md. */
|
|
309
|
+
ScrDyn *scr_await_dyn_value(ScrDyn *v) {
|
|
310
|
+
if (v->kind == SCR_DYN_PROMISE) return scr_await_dyn(v->v.promise);
|
|
311
|
+
scr_await_hop();
|
|
312
|
+
return scr_dyn_retain(v);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/* ── process warnings (emitWarning + the 'warning' event) ─────────────
|
|
316
|
+
* Gated with the rest of this TU (a deprecation-emitting unit's gate
|
|
317
|
+
* must imply the dynAsync link). Listeners are DOM functions; emission
|
|
318
|
+
* is SYNCHRONOUS at the
|
|
319
|
+
* call (Node defers a tick through nextTick — the MaxListenersExceeded
|
|
320
|
+
* precedent, SEMANTICS.md 138) and the default stderr report always
|
|
321
|
+
* prints (Node's own bootstrap listener; a compiled binary has no
|
|
322
|
+
* --no-warnings). The warning VALUE is the DOM error encoding built over
|
|
323
|
+
* an ScrError (identity-cached, so a listener comparing two deliveries
|
|
324
|
+
* of one warning sees one object); a string `detail` joins the DOM node
|
|
325
|
+
* and the report's second line, exactly Node. */
|
|
326
|
+
static ScrDyn **scr_warn_listeners = NULL;
|
|
327
|
+
static size_t scr_nwarn = 0, scr_warn_cap = 0;
|
|
328
|
+
|
|
329
|
+
static void scr_warn_teardown(void) {
|
|
330
|
+
for (size_t i = 0; i < scr_nwarn; i++) scr_dyn_release(scr_warn_listeners[i]);
|
|
331
|
+
free(scr_warn_listeners);
|
|
332
|
+
scr_warn_listeners = NULL;
|
|
333
|
+
scr_nwarn = scr_warn_cap = 0;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
void scr_process_on_warning(ScrDyn *fn) {
|
|
337
|
+
if (fn->kind != SCR_DYN_FUNC) {
|
|
338
|
+
const char *msg = "The \"listener\" argument must be of type function";
|
|
339
|
+
scr_throw_error_msg_code(SCR_ERR_TYPE, msg, strlen(msg), "ERR_INVALID_ARG_TYPE");
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
if (scr_nwarn == scr_warn_cap) {
|
|
343
|
+
scr_warn_cap = scr_warn_cap ? scr_warn_cap * 2 : 4;
|
|
344
|
+
scr_warn_listeners = realloc(scr_warn_listeners, scr_warn_cap * sizeof *scr_warn_listeners);
|
|
345
|
+
if (!scr_warn_listeners) {
|
|
346
|
+
fputs("scriptc: out of memory\n", stderr);
|
|
347
|
+
abort();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (scr_nwarn == 0) atexit(scr_warn_teardown);
|
|
351
|
+
scr_warn_listeners[scr_nwarn++] = scr_dyn_retain(fn);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
void scr_process_off_warning(ScrDyn *fn) {
|
|
355
|
+
for (size_t i = 0; i < scr_nwarn; i++) {
|
|
356
|
+
ScrDyn *l = scr_warn_listeners[i];
|
|
357
|
+
bool same = l == fn || (l->kind == SCR_DYN_FUNC && fn->kind == SCR_DYN_FUNC &&
|
|
358
|
+
l->v.fn.clo == fn->v.fn.clo);
|
|
359
|
+
if (same) {
|
|
360
|
+
scr_dyn_release(l);
|
|
361
|
+
memmove(scr_warn_listeners + i, scr_warn_listeners + i + 1,
|
|
362
|
+
(scr_nwarn - i - 1) * sizeof *scr_warn_listeners);
|
|
363
|
+
scr_nwarn--;
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/* Dispatch + the default stderr report over a built warning DOM node.
|
|
370
|
+
* Borrowed. A listener throw propagates (the dc publish stance). */
|
|
371
|
+
static void scr_warning_dispatch(ScrDyn *w) {
|
|
372
|
+
for (size_t i = 0; i < scr_nwarn; i++) {
|
|
373
|
+
ScrDyn *r = scr_dyn_call(scr_warn_listeners[i], &w, 1, "listener");
|
|
374
|
+
if (r == NULL) return; /* pending exception propagates */
|
|
375
|
+
scr_dyn_release(r);
|
|
376
|
+
}
|
|
377
|
+
/* "(node:pid) [CODE] Name: message" + "\n<detail>" — Node's
|
|
378
|
+
* onWarning report. */
|
|
379
|
+
const ScrDyn *en = scr_dyn_obj_get(w, "name", 4);
|
|
380
|
+
const ScrDyn *em = scr_dyn_obj_get(w, "message", 7);
|
|
381
|
+
const ScrDyn *ec = scr_dyn_obj_get(w, "code", 4);
|
|
382
|
+
const ScrDyn *ed = scr_dyn_obj_get(w, "detail", 6);
|
|
383
|
+
fflush(stdout);
|
|
384
|
+
fprintf(stderr, "(node:%ld) ", SCR_WARN_PID());
|
|
385
|
+
if (ec && ec->kind == SCR_DYN_STR) fprintf(stderr, "[%s] ", ec->v.str->data);
|
|
386
|
+
fprintf(stderr, "%s: %s",
|
|
387
|
+
(en && en->kind == SCR_DYN_STR) ? en->v.str->data : "Warning",
|
|
388
|
+
(em && em->kind == SCR_DYN_STR) ? em->v.str->data : "");
|
|
389
|
+
if (ed && ed->kind == SCR_DYN_STR) fprintf(stderr, "\n%s", ed->v.str->data);
|
|
390
|
+
fputc('\n', stderr);
|
|
391
|
+
/* Node's one-time trace hint, after the first report. */
|
|
392
|
+
static bool hinted = false;
|
|
393
|
+
if (!hinted) {
|
|
394
|
+
hinted = true;
|
|
395
|
+
fputs("(Use `node --trace-warnings ...` to show where the warning was created)\n", stderr);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/* A warning built from C parts (the runtime deprecation sites): name
|
|
400
|
+
* defaults to "Warning"; code/detail optional. Borrows message. */
|
|
401
|
+
void scr_emit_warning(const char *name, const char *code, ScrStr *message) {
|
|
402
|
+
ScrError *e = scr_error_new(SCR_ERR_ERROR, message);
|
|
403
|
+
scr_str_release(e->name);
|
|
404
|
+
e->name = scr_str_new(name ? name : "Warning", strlen(name ? name : "Warning"));
|
|
405
|
+
if (code) e->code = scr_str_new(code, strlen(code));
|
|
406
|
+
ScrDyn *w = scr_dyn_from_error(e);
|
|
407
|
+
scr_error_release(e);
|
|
408
|
+
scr_warning_dispatch(w);
|
|
409
|
+
scr_dyn_release(w);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
static void scr_warn_bad_arg(const char *arg, const char *want) {
|
|
413
|
+
char buf[160];
|
|
414
|
+
int n = snprintf(buf, sizeof buf, "The \"%s\" argument must be of type %s", arg, want);
|
|
415
|
+
scr_throw_error_msg_code(SCR_ERR_TYPE, buf, (size_t)n, "ERR_INVALID_ARG_TYPE");
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/* process.emitWarning(...) — Node's full argument grammar over DOM
|
|
419
|
+
* values: (warning: string | Error), then for string warnings a type
|
|
420
|
+
* string / ctor function / options object ({type, code, detail}) second
|
|
421
|
+
* and a code string / ctor function third. Wrong kinds throw Node's
|
|
422
|
+
* ERR_INVALID_ARG_TYPE TypeErrors; non-string details are ignored. */
|
|
423
|
+
void scr_process_emit_warning(ScrDyn *args) {
|
|
424
|
+
size_t argc = args->kind == SCR_DYN_ARR ? args->v.arr.len : 0;
|
|
425
|
+
ScrDyn *const *items = args->kind == SCR_DYN_ARR ? args->v.arr.items : NULL;
|
|
426
|
+
ScrDyn *warning = argc >= 1 ? items[0] : NULL;
|
|
427
|
+
/* An Error-encoded warning: type/code arguments are ignored (Node). */
|
|
428
|
+
if (warning != NULL && warning->kind == SCR_DYN_OBJ &&
|
|
429
|
+
scr_dyn_obj_get(warning, "%error", 6) != NULL) {
|
|
430
|
+
scr_warning_dispatch(warning);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
if (warning == NULL || warning->kind != SCR_DYN_STR) {
|
|
434
|
+
scr_warn_bad_arg("warning", "string or an instance of Error");
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
const ScrStr *type = NULL;
|
|
438
|
+
const ScrStr *code = NULL;
|
|
439
|
+
const ScrStr *detail = NULL;
|
|
440
|
+
size_t i = 1;
|
|
441
|
+
if (i < argc && items[i]->kind != SCR_DYN_UNDEF) {
|
|
442
|
+
ScrDyn *a = items[i];
|
|
443
|
+
if (a->kind == SCR_DYN_STR) {
|
|
444
|
+
type = a->v.str;
|
|
445
|
+
i++;
|
|
446
|
+
} else if (a->kind == SCR_DYN_FUNC) {
|
|
447
|
+
i = argc; /* ctor: consumed, stack-trace trimming only — ignored */
|
|
448
|
+
} else if (a->kind == SCR_DYN_OBJ && scr_dyn_obj_get(a, "%error", 6) == NULL) {
|
|
449
|
+
const ScrDyn *t = scr_dyn_obj_get(a, "type", 4);
|
|
450
|
+
const ScrDyn *c = scr_dyn_obj_get(a, "code", 4);
|
|
451
|
+
const ScrDyn *d = scr_dyn_obj_get(a, "detail", 6);
|
|
452
|
+
if (t && t->kind == SCR_DYN_STR) type = t->v.str;
|
|
453
|
+
else if (t && t->kind != SCR_DYN_UNDEF) {
|
|
454
|
+
scr_warn_bad_arg("options.type", "string");
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
if (c && c->kind == SCR_DYN_STR) code = c->v.str;
|
|
458
|
+
if (d && d->kind == SCR_DYN_STR) detail = d->v.str;
|
|
459
|
+
i = argc; /* options form: no third argument (Node ignores it) */
|
|
460
|
+
} else {
|
|
461
|
+
scr_warn_bad_arg("type", "string");
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
} else if (i < argc) {
|
|
465
|
+
i++; /* explicit undefined type: default */
|
|
466
|
+
}
|
|
467
|
+
if (i < argc && items[i]->kind != SCR_DYN_UNDEF) {
|
|
468
|
+
ScrDyn *a = items[i];
|
|
469
|
+
if (a->kind == SCR_DYN_STR) code = a->v.str;
|
|
470
|
+
else if (a->kind != SCR_DYN_FUNC) {
|
|
471
|
+
scr_warn_bad_arg("code", "string");
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
ScrError *e = scr_error_new(SCR_ERR_ERROR, (ScrStr *)warning->v.str);
|
|
476
|
+
scr_str_release(e->name);
|
|
477
|
+
e->name = type ? scr_str_retain((ScrStr *)type) : scr_str_new("Warning", 7);
|
|
478
|
+
if (code) e->code = scr_str_retain((ScrStr *)code);
|
|
479
|
+
ScrDyn *w = scr_dyn_from_error(e);
|
|
480
|
+
scr_error_release(e);
|
|
481
|
+
if (detail) {
|
|
482
|
+
scr_dyn_obj_set(w, "detail", 6, scr_dyn_new_str((ScrStr *)detail)); /* retains */
|
|
483
|
+
}
|
|
484
|
+
scr_warning_dispatch(w);
|
|
485
|
+
scr_dyn_release(w);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
/* A caught-exception snapshot as a DOM value — identity-preserving for
|
|
491
|
+
* DOM payloads (a dyn-thrown value is retained, not copied), the
|
|
492
|
+
* identity-cached %error encoding above for Error-family objects,
|
|
493
|
+
* scalars by value, the type-erased empty object for the rest
|
|
494
|
+
* (SEMANTICS.md 67). Shared by the dc trace choreography, the DOM
|
|
495
|
+
* promise reactions, and the unhandled-rejection dispatch. Borrows the
|
|
496
|
+
* box; result +1. */
|
|
497
|
+
ScrDyn *scr_caught_to_dyn(const ScrCaught *c) {
|
|
498
|
+
switch (c->kind) {
|
|
499
|
+
case SCR_EXC_F64: return scr_dyn_new_num(c->f64);
|
|
500
|
+
case SCR_EXC_BOOL: return scr_dyn_new_bool(c->b);
|
|
501
|
+
case SCR_EXC_STR: return scr_dyn_new_str((ScrStr *)c->payload);
|
|
502
|
+
case SCR_EXC_REF:
|
|
503
|
+
if (c->retain_fn == scr_dyn_retain_v) return scr_dyn_retain((ScrDyn *)c->payload);
|
|
504
|
+
return scr_dyn_new_obj();
|
|
505
|
+
case SCR_EXC_OBJ:
|
|
506
|
+
if (scr_error_is(c->payload)) return scr_dyn_from_error((const ScrError *)c->payload);
|
|
507
|
+
return scr_dyn_new_obj();
|
|
508
|
+
default:
|
|
509
|
+
return scr_dyn_new_obj();
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/* Await a DOM-CROSSING promise (SCR_DYN_PROMISE's boundary contract —
|
|
514
|
+
* dyn or void fulfillment): the payload as a DOM value (+1; a void
|
|
515
|
+
* fulfillment answers the undefined value, and the defensive scalar arms
|
|
516
|
+
* cover payload kinds a direct box could theoretically carry), or NULL
|
|
517
|
+
* with the rejection re-thrown into the awaiter. */
|
|
518
|
+
ScrDyn *scr_await_dyn(ScrPromise *p) {
|
|
519
|
+
if (!scr_promise_await_settled(p)) return NULL;
|
|
520
|
+
switch (scr_promise_payload_kind(p)) {
|
|
521
|
+
case SCR_EXC_F64: return scr_dyn_new_num(scr_promise_payload_num(p));
|
|
522
|
+
case SCR_EXC_BOOL: return scr_dyn_new_bool(scr_promise_payload_flag(p));
|
|
523
|
+
case SCR_EXC_STR: {
|
|
524
|
+
ScrStr *v = scr_promise_payload_str(p);
|
|
525
|
+
ScrDyn *d = scr_dyn_new_str(v); /* retains */
|
|
526
|
+
scr_str_release(v);
|
|
527
|
+
return d;
|
|
528
|
+
}
|
|
529
|
+
case SCR_EXC_REF: {
|
|
530
|
+
void *v = scr_promise_payload_ref(p);
|
|
531
|
+
if (v) return (ScrDyn *)v; /* the DOM contract: a retained dyn */
|
|
532
|
+
return scr_dyn_retain(scr_dyn_undefined());
|
|
533
|
+
}
|
|
534
|
+
default:
|
|
535
|
+
return scr_dyn_retain(scr_dyn_undefined());
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/* The rejection reason as a DOM value — the scr_caught_to_dyn stances
|
|
540
|
+
* over a promise's payload slot (identity-preserving for dyn-thrown
|
|
541
|
+
* values and %Error instances). */
|
|
542
|
+
ScrDyn *scr_promise_reason_dyn(const ScrPromise *p) {
|
|
543
|
+
switch (scr_promise_payload_kind(p)) {
|
|
544
|
+
case SCR_EXC_F64: return scr_dyn_new_num(scr_promise_payload_num(p));
|
|
545
|
+
case SCR_EXC_BOOL: return scr_dyn_new_bool(scr_promise_payload_flag(p));
|
|
546
|
+
case SCR_EXC_STR: {
|
|
547
|
+
ScrStr *v = scr_promise_payload_str((ScrPromise *)p);
|
|
548
|
+
ScrDyn *d = scr_dyn_new_str(v); /* retains */
|
|
549
|
+
scr_str_release(v);
|
|
550
|
+
return d;
|
|
551
|
+
}
|
|
552
|
+
case SCR_EXC_REF: {
|
|
553
|
+
void *v = scr_promise_payload_ref((ScrPromise *)p);
|
|
554
|
+
if (v == NULL) return scr_dyn_new_obj();
|
|
555
|
+
if (scr_promise_payload_is_dyn(p)) return (ScrDyn *)v; /* retained */
|
|
556
|
+
ScrDyn *d = scr_dyn_new_obj();
|
|
557
|
+
/* release the generic +1 the accessor took */
|
|
558
|
+
scr_promise_payload_release(p, v);
|
|
559
|
+
return d;
|
|
560
|
+
}
|
|
561
|
+
case SCR_EXC_OBJ: {
|
|
562
|
+
void *v = scr_promise_payload_ref((ScrPromise *)p);
|
|
563
|
+
if (v != NULL && scr_error_is(v)) {
|
|
564
|
+
ScrDyn *d = scr_dyn_from_error((const ScrError *)v);
|
|
565
|
+
scr_promise_payload_release(p, v);
|
|
566
|
+
return d;
|
|
567
|
+
}
|
|
568
|
+
if (v != NULL) scr_promise_payload_release(p, v);
|
|
569
|
+
return scr_dyn_new_obj();
|
|
570
|
+
}
|
|
571
|
+
default:
|
|
572
|
+
return scr_dyn_retain(scr_dyn_undefined());
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/* ── promises in the DOM (SCR_DYN_PROMISE) ────────────────────────────
|
|
577
|
+
* Reference boxes over the fiber machinery's ScrPromise (scr_runtime.h's
|
|
578
|
+
* design note). The boundary contract — a boxed promise settles with a
|
|
579
|
+
* DOM payload — is the CALLERS' to keep: the compiler's converters box
|
|
580
|
+
* promise<dyn> directly and every other inner type through the adapting
|
|
581
|
+
* constructor below. */
|
|
582
|
+
|
|
583
|
+
ScrDyn *scr_dyn_new_promise(ScrPromise *p) {
|
|
584
|
+
ScrDyn *d = scr_dyn_alloc_promise(scr_promise_release);
|
|
585
|
+
d->v.promise = scr_promise_retain(p);
|
|
586
|
+
return d;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/* The typed-inner box: a fresh destination promise parked on `src`
|
|
590
|
+
* through the Promise.race cb-waiter machinery — `adapt` (emitted,
|
|
591
|
+
* per-inner-type) converts the fulfillment payload into a DOM value and
|
|
592
|
+
* fulfills the destination; rejections copy raw inside the machinery and
|
|
593
|
+
* count as HANDLED on src (the box is the tracked promise, like a JS
|
|
594
|
+
* .then chain). Already-settled sources adapt inline. Borrows src; +1. */
|
|
595
|
+
ScrDyn *scr_dyn_new_promise_adapting(ScrPromise *src,
|
|
596
|
+
void (*adapt)(ScrPromise *dst, ScrPromise *src)) {
|
|
597
|
+
ScrPromise *dst = scr_promise_new();
|
|
598
|
+
scr_promise_race_add(dst, src, adapt);
|
|
599
|
+
ScrDyn *d = scr_dyn_alloc_promise(scr_promise_release);
|
|
600
|
+
d->v.promise = dst; /* the constructor's +1 moves in */
|
|
601
|
+
return d;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
ScrPromise *scr_dyn_promise_of(const ScrDyn *d) {
|
|
605
|
+
return d->kind == SCR_DYN_PROMISE ? d->v.promise : NULL;
|
|
606
|
+
}
|
|
607
|
+
|