visaljs 0.0.0-stage → 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 +21 -0
- package/README.md +45 -2
- package/cli.js +8084 -0
- package/node/include/js_node.h +46 -0
- package/node/prelude/async_hooks.js +88 -0
- package/node/prelude/buffer.js +31 -0
- package/node/prelude/crypto.js +114 -0
- package/node/prelude/events.js +227 -0
- package/node/prelude/fs.js +79 -0
- package/node/prelude/http.js +536 -0
- package/node/prelude/http2.js +30 -0
- package/node/prelude/internal/crypto/asym.js +333 -0
- package/node/prelude/internal/crypto/cipher.js +205 -0
- package/node/prelude/internal/crypto/hash.js +137 -0
- package/node/prelude/internal/crypto/kdf.js +182 -0
- package/node/prelude/internal/crypto/keys.js +603 -0
- package/node/prelude/internal/crypto/random.js +118 -0
- package/node/prelude/internal/crypto/util.js +76 -0
- package/node/prelude/internal/errors.js +88 -0
- package/node/prelude/internal/querystring.js +105 -0
- package/node/prelude/module.js +53 -0
- package/node/prelude/net.js +51 -0
- package/node/prelude/os.js +129 -0
- package/node/prelude/path.js +257 -0
- package/node/prelude/process.js +21 -0
- package/node/prelude/querystring.js +469 -0
- package/node/prelude/stream.js +1327 -0
- package/node/prelude/stream_promises.js +7 -0
- package/node/prelude/stream_web.js +6 -0
- package/node/prelude/string_decoder.js +236 -0
- package/node/prelude/tty.js +18 -0
- package/node/prelude/url.js +1156 -0
- package/node/prelude/util.js +64 -0
- package/node/prelude/zlib.js +81 -0
- package/node/src/host_fs.c +126 -0
- package/node/src/host_http.c +486 -0
- package/node/src/host_os.c +505 -0
- package/node/src/host_sys.c +78 -0
- package/node/third_party/libuv/LICENSE +19 -0
- package/node/third_party/libuv/include/uv/aix.h +32 -0
- package/node/third_party/libuv/include/uv/bsd.h +34 -0
- package/node/third_party/libuv/include/uv/darwin.h +61 -0
- package/node/third_party/libuv/include/uv/errno.h +483 -0
- package/node/third_party/libuv/include/uv/linux.h +34 -0
- package/node/third_party/libuv/include/uv/os390.h +33 -0
- package/node/third_party/libuv/include/uv/posix.h +31 -0
- package/node/third_party/libuv/include/uv/sunos.h +44 -0
- package/node/third_party/libuv/include/uv/threadpool.h +37 -0
- package/node/third_party/libuv/include/uv/tree.h +521 -0
- package/node/third_party/libuv/include/uv/unix.h +512 -0
- package/node/third_party/libuv/include/uv/version.h +43 -0
- package/node/third_party/libuv/include/uv/win.h +698 -0
- package/node/third_party/libuv/include/uv.h +1990 -0
- package/node/third_party/libuv/src/fs-poll.c +290 -0
- package/node/third_party/libuv/src/heap-inl.h +245 -0
- package/node/third_party/libuv/src/idna.c +560 -0
- package/node/third_party/libuv/src/idna.h +31 -0
- package/node/third_party/libuv/src/inet.c +298 -0
- package/node/third_party/libuv/src/queue.h +90 -0
- package/node/third_party/libuv/src/random.c +123 -0
- package/node/third_party/libuv/src/strscpy.c +38 -0
- package/node/third_party/libuv/src/strscpy.h +39 -0
- package/node/third_party/libuv/src/strtok.c +52 -0
- package/node/third_party/libuv/src/strtok.h +27 -0
- package/node/third_party/libuv/src/thread-common.c +175 -0
- package/node/third_party/libuv/src/threadpool.c +419 -0
- package/node/third_party/libuv/src/timer.c +200 -0
- package/node/third_party/libuv/src/unix/async.c +418 -0
- package/node/third_party/libuv/src/unix/bsd-ifaddrs.c +164 -0
- package/node/third_party/libuv/src/unix/core.c +2104 -0
- package/node/third_party/libuv/src/unix/darwin-proctitle.c +176 -0
- package/node/third_party/libuv/src/unix/darwin-stub.h +97 -0
- package/node/third_party/libuv/src/unix/darwin-syscalls.h +17 -0
- package/node/third_party/libuv/src/unix/darwin.c +237 -0
- package/node/third_party/libuv/src/unix/dl.c +80 -0
- package/node/third_party/libuv/src/unix/fs.c +2303 -0
- package/node/third_party/libuv/src/unix/fsevents.c +906 -0
- package/node/third_party/libuv/src/unix/getaddrinfo.c +252 -0
- package/node/third_party/libuv/src/unix/getnameinfo.c +121 -0
- package/node/third_party/libuv/src/unix/internal.h +530 -0
- package/node/third_party/libuv/src/unix/kqueue.c +667 -0
- package/node/third_party/libuv/src/unix/linux.c +2761 -0
- package/node/third_party/libuv/src/unix/loop-watcher.c +68 -0
- package/node/third_party/libuv/src/unix/loop.c +240 -0
- package/node/third_party/libuv/src/unix/pipe.c +555 -0
- package/node/third_party/libuv/src/unix/poll.c +159 -0
- package/node/third_party/libuv/src/unix/process.c +1123 -0
- package/node/third_party/libuv/src/unix/procfs-exepath.c +45 -0
- package/node/third_party/libuv/src/unix/proctitle.c +157 -0
- package/node/third_party/libuv/src/unix/random-devurandom.c +93 -0
- package/node/third_party/libuv/src/unix/random-getentropy.c +57 -0
- package/node/third_party/libuv/src/unix/random-getrandom.c +86 -0
- package/node/third_party/libuv/src/unix/random-sysctl-linux.c +99 -0
- package/node/third_party/libuv/src/unix/signal.c +581 -0
- package/node/third_party/libuv/src/unix/stream.c +1567 -0
- package/node/third_party/libuv/src/unix/tcp.c +673 -0
- package/node/third_party/libuv/src/unix/thread.c +975 -0
- package/node/third_party/libuv/src/unix/tty.c +510 -0
- package/node/third_party/libuv/src/unix/udp.c +1434 -0
- package/node/third_party/libuv/src/uv-common.c +1051 -0
- package/node/third_party/libuv/src/uv-common.h +474 -0
- package/node/third_party/libuv/src/uv-data-getter-setters.c +119 -0
- package/node/third_party/libuv/src/version.c +45 -0
- package/node/third_party/llhttp/LICENSE +22 -0
- package/node/third_party/llhttp/api.c +509 -0
- package/node/third_party/llhttp/http.c +170 -0
- package/node/third_party/llhttp/llhttp.c +10099 -0
- package/node/third_party/llhttp/llhttp.h +907 -0
- package/package.json +25 -4
- package/runtime/include/js_atoms.gen.h +68 -0
- package/runtime/include/js_atoms.h +54 -0
- package/runtime/include/js_bigint.h +93 -0
- package/runtime/include/js_buffer.h +79 -0
- package/runtime/include/js_builtins.h +168 -0
- package/runtime/include/js_console.h +58 -0
- package/runtime/include/js_convert.h +22 -0
- package/runtime/include/js_core.def +188 -0
- package/runtime/include/js_crypto.h +58 -0
- package/runtime/include/js_error.h +37 -0
- package/runtime/include/js_exception.h +65 -0
- package/runtime/include/js_function.h +167 -0
- package/runtime/include/js_gc.h +195 -0
- package/runtime/include/js_generator.h +96 -0
- package/runtime/include/js_host.h +19 -0
- package/runtime/include/js_jobs.h +84 -0
- package/runtime/include/js_module.h +16 -0
- package/runtime/include/js_object.h +384 -0
- package/runtime/include/js_ops.h +111 -0
- package/runtime/include/js_promise.h +45 -0
- package/runtime/include/js_regexp.h +25 -0
- package/runtime/include/js_runtime.h +30 -0
- package/runtime/include/js_symbol.h +62 -0
- package/runtime/include/js_web.h +110 -0
- package/runtime/include/jscell.h +48 -0
- package/runtime/include/jscontext.h +240 -0
- package/runtime/include/jsnum.h +42 -0
- package/runtime/include/jsstring.h +161 -0
- package/runtime/include/jsvalue.h +142 -0
- package/runtime/src/arguments.c +115 -0
- package/runtime/src/array.c +1145 -0
- package/runtime/src/arraybuffer.c +608 -0
- package/runtime/src/async_iter.c +479 -0
- package/runtime/src/atoms.c +157 -0
- package/runtime/src/base64.c +107 -0
- package/runtime/src/bigint.c +1189 -0
- package/runtime/src/blob.c +371 -0
- package/runtime/src/buffer.c +1357 -0
- package/runtime/src/builtin_table.c +100 -0
- package/runtime/src/builtins.c +987 -0
- package/runtime/src/builtins_util.h +53 -0
- package/runtime/src/collections.c +912 -0
- package/runtime/src/components.c +28 -0
- package/runtime/src/console.c +637 -0
- package/runtime/src/convert.c +82 -0
- package/runtime/src/core_all.c +21 -0
- package/runtime/src/crypto.c +116 -0
- package/runtime/src/crypto_asym.c +644 -0
- package/runtime/src/crypto_cipher.c +671 -0
- package/runtime/src/crypto_hash.c +260 -0
- package/runtime/src/crypto_host.c +414 -0
- package/runtime/src/crypto_internal.h +304 -0
- package/runtime/src/crypto_kdf.c +143 -0
- package/runtime/src/crypto_key.c +171 -0
- package/runtime/src/crypto_pkey.c +794 -0
- package/runtime/src/crypto_subtle.c +1675 -0
- package/runtime/src/date.c +940 -0
- package/runtime/src/domexception.c +169 -0
- package/runtime/src/elements.c +312 -0
- package/runtime/src/elements.h +45 -0
- package/runtime/src/encoding.c +485 -0
- package/runtime/src/error.c +297 -0
- package/runtime/src/events.c +793 -0
- package/runtime/src/exception.c +56 -0
- package/runtime/src/fetch.c +772 -0
- package/runtime/src/function.c +530 -0
- package/runtime/src/gc.c +803 -0
- package/runtime/src/generator.c +218 -0
- package/runtime/src/global.c +119 -0
- package/runtime/src/headers.c +557 -0
- package/runtime/src/inspect.c +1792 -0
- package/runtime/src/internal.h +80 -0
- package/runtime/src/iterate.c +94 -0
- package/runtime/src/iterator.c +409 -0
- package/runtime/src/jobs.c +337 -0
- package/runtime/src/jsnum.c +353 -0
- package/runtime/src/json.c +1028 -0
- package/runtime/src/math.c +243 -0
- package/runtime/src/module.c +336 -0
- package/runtime/src/number.c +176 -0
- package/runtime/src/object.c +1265 -0
- package/runtime/src/ops.c +322 -0
- package/runtime/src/os.c +196 -0
- package/runtime/src/os.h +29 -0
- package/runtime/src/process.c +432 -0
- package/runtime/src/promise.c +721 -0
- package/runtime/src/proxy.c +570 -0
- package/runtime/src/reflect.c +194 -0
- package/runtime/src/regexp.c +1141 -0
- package/runtime/src/regexp_anchor.h +34 -0
- package/runtime/src/regexp_message.h +32 -0
- package/runtime/src/shape.c +294 -0
- package/runtime/src/shape.h +46 -0
- package/runtime/src/streams.c +1046 -0
- package/runtime/src/streams.h +47 -0
- package/runtime/src/string.c +364 -0
- package/runtime/src/string_builtins.c +837 -0
- package/runtime/src/symbol.c +143 -0
- package/runtime/src/test_host.c +59 -0
- package/runtime/src/typedarray.c +1330 -0
- package/runtime/src/tznames.gen.h +712 -0
- package/runtime/src/uri.c +169 -0
- package/runtime/src/url.c +2116 -0
- package/runtime/src/weak.c +486 -0
- package/runtime/src/web.c +214 -0
- package/runtime/src/wrapper.c +59 -0
- package/runtime/src/writable.c +1486 -0
- package/runtime/third_party/ada-idna/LICENSE-MIT +18 -0
- package/runtime/third_party/ada-idna/README.md +27 -0
- package/runtime/third_party/ada-idna/convert.mjs +83 -0
- package/runtime/third_party/ada-idna/idna.c +416 -0
- package/runtime/third_party/ada-idna/idna.h +15 -0
- package/runtime/third_party/ada-idna/idna_tables.h +2657 -0
- package/runtime/third_party/bearssl/LICENSE.txt +21 -0
- package/runtime/third_party/bearssl/README.txt +136 -0
- package/runtime/third_party/bearssl/VERSION +1 -0
- package/runtime/third_party/bearssl/inc/bearssl.h +183 -0
- package/runtime/third_party/bearssl/inc/bearssl_aead.h +1059 -0
- package/runtime/third_party/bearssl/inc/bearssl_block.h +2618 -0
- package/runtime/third_party/bearssl/inc/bearssl_ec.h +967 -0
- package/runtime/third_party/bearssl/inc/bearssl_hash.h +1346 -0
- package/runtime/third_party/bearssl/inc/bearssl_hmac.h +241 -0
- package/runtime/third_party/bearssl/inc/bearssl_kdf.h +284 -0
- package/runtime/third_party/bearssl/inc/bearssl_pem.h +294 -0
- package/runtime/third_party/bearssl/inc/bearssl_prf.h +150 -0
- package/runtime/third_party/bearssl/inc/bearssl_rand.h +397 -0
- package/runtime/third_party/bearssl/inc/bearssl_rsa.h +1655 -0
- package/runtime/third_party/bearssl/inc/bearssl_ssl.h +4296 -0
- package/runtime/third_party/bearssl/inc/bearssl_x509.h +1474 -0
- package/runtime/third_party/bearssl/src/aead/ccm.c +346 -0
- package/runtime/third_party/bearssl/src/aead/eax.c +525 -0
- package/runtime/third_party/bearssl/src/aead/gcm.c +318 -0
- package/runtime/third_party/bearssl/src/codec/ccopy.c +44 -0
- package/runtime/third_party/bearssl/src/codec/dec16be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec16le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec32be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec32le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec64be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec64le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc16be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc16le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc32be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc32le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc64be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc64le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/pemdec.c +526 -0
- package/runtime/third_party/bearssl/src/codec/pemdec.t0 +314 -0
- package/runtime/third_party/bearssl/src/codec/pemenc.c +173 -0
- package/runtime/third_party/bearssl/src/config.h +247 -0
- package/runtime/third_party/bearssl/src/ec/ec_all_m15.c +121 -0
- package/runtime/third_party/bearssl/src/ec/ec_all_m31.c +171 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_i15.c +398 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_i31.c +390 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m15.c +1478 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m31.c +800 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m62.c +605 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m64.c +831 -0
- package/runtime/third_party/bearssl/src/ec/ec_curve25519.c +46 -0
- package/runtime/third_party/bearssl/src/ec/ec_default.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ec_keygen.c +86 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m15.c +2124 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m31.c +1469 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m62.c +1765 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m64.c +1781 -0
- package/runtime/third_party/bearssl/src/ec/ec_prime_i15.c +824 -0
- package/runtime/third_party/bearssl/src/ec/ec_prime_i31.c +826 -0
- package/runtime/third_party/bearssl/src/ec/ec_pubkey.c +85 -0
- package/runtime/third_party/bearssl/src/ec/ec_secp256r1.c +51 -0
- package/runtime/third_party/bearssl/src/ec/ec_secp384r1.c +57 -0
- package/runtime/third_party/bearssl/src/ec/ec_secp521r1.c +64 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_atr.c +134 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_sign_asn1.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_sign_raw.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_vrfy_asn1.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_vrfy_raw.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_bits.c +47 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_sign_asn1.c +45 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_sign_raw.c +174 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_vrfy_asn1.c +48 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_vrfy_raw.c +166 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_bits.c +47 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_sign_asn1.c +45 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_sign_raw.c +173 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_vrfy_asn1.c +48 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_vrfy_raw.c +165 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_rta.c +121 -0
- package/runtime/third_party/bearssl/src/hash/dig_oid.c +84 -0
- package/runtime/third_party/bearssl/src/hash/dig_size.c +50 -0
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul.c +345 -0
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul32.c +251 -0
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul64.c +154 -0
- package/runtime/third_party/bearssl/src/hash/ghash_pclmul.c +389 -0
- package/runtime/third_party/bearssl/src/hash/ghash_pwr8.c +411 -0
- package/runtime/third_party/bearssl/src/hash/md5.c +208 -0
- package/runtime/third_party/bearssl/src/hash/md5sha1.c +141 -0
- package/runtime/third_party/bearssl/src/hash/mgf1.c +56 -0
- package/runtime/third_party/bearssl/src/hash/multihash.c +166 -0
- package/runtime/third_party/bearssl/src/hash/sha1.c +191 -0
- package/runtime/third_party/bearssl/src/hash/sha2big.c +285 -0
- package/runtime/third_party/bearssl/src/hash/sha2small.c +341 -0
- package/runtime/third_party/bearssl/src/inner.h +2577 -0
- package/runtime/third_party/bearssl/src/int/i15_add.c +46 -0
- package/runtime/third_party/bearssl/src/int/i15_bitlen.c +44 -0
- package/runtime/third_party/bearssl/src/int/i15_decmod.c +124 -0
- package/runtime/third_party/bearssl/src/int/i15_decode.c +56 -0
- package/runtime/third_party/bearssl/src/int/i15_decred.c +100 -0
- package/runtime/third_party/bearssl/src/int/i15_encode.c +56 -0
- package/runtime/third_party/bearssl/src/int/i15_fmont.c +59 -0
- package/runtime/third_party/bearssl/src/int/i15_iszero.c +39 -0
- package/runtime/third_party/bearssl/src/int/i15_moddiv.c +465 -0
- package/runtime/third_party/bearssl/src/int/i15_modpow.c +50 -0
- package/runtime/third_party/bearssl/src/int/i15_modpow2.c +160 -0
- package/runtime/third_party/bearssl/src/int/i15_montmul.c +184 -0
- package/runtime/third_party/bearssl/src/int/i15_mulacc.c +61 -0
- package/runtime/third_party/bearssl/src/int/i15_muladd.c +173 -0
- package/runtime/third_party/bearssl/src/int/i15_ninv15.c +38 -0
- package/runtime/third_party/bearssl/src/int/i15_reduce.c +66 -0
- package/runtime/third_party/bearssl/src/int/i15_rshift.c +47 -0
- package/runtime/third_party/bearssl/src/int/i15_sub.c +46 -0
- package/runtime/third_party/bearssl/src/int/i15_tmont.c +36 -0
- package/runtime/third_party/bearssl/src/int/i31_add.c +46 -0
- package/runtime/third_party/bearssl/src/int/i31_bitlen.c +44 -0
- package/runtime/third_party/bearssl/src/int/i31_decmod.c +124 -0
- package/runtime/third_party/bearssl/src/int/i31_decode.c +57 -0
- package/runtime/third_party/bearssl/src/int/i31_decred.c +103 -0
- package/runtime/third_party/bearssl/src/int/i31_encode.c +79 -0
- package/runtime/third_party/bearssl/src/int/i31_fmont.c +60 -0
- package/runtime/third_party/bearssl/src/int/i31_iszero.c +39 -0
- package/runtime/third_party/bearssl/src/int/i31_moddiv.c +488 -0
- package/runtime/third_party/bearssl/src/int/i31_modpow.c +65 -0
- package/runtime/third_party/bearssl/src/int/i31_modpow2.c +160 -0
- package/runtime/third_party/bearssl/src/int/i31_montmul.c +127 -0
- package/runtime/third_party/bearssl/src/int/i31_mulacc.c +74 -0
- package/runtime/third_party/bearssl/src/int/i31_muladd.c +157 -0
- package/runtime/third_party/bearssl/src/int/i31_ninv31.c +39 -0
- package/runtime/third_party/bearssl/src/int/i31_reduce.c +66 -0
- package/runtime/third_party/bearssl/src/int/i31_rshift.c +47 -0
- package/runtime/third_party/bearssl/src/int/i31_sub.c +46 -0
- package/runtime/third_party/bearssl/src/int/i31_tmont.c +36 -0
- package/runtime/third_party/bearssl/src/int/i32_add.c +51 -0
- package/runtime/third_party/bearssl/src/int/i32_bitlen.c +44 -0
- package/runtime/third_party/bearssl/src/int/i32_decmod.c +77 -0
- package/runtime/third_party/bearssl/src/int/i32_decode.c +63 -0
- package/runtime/third_party/bearssl/src/int/i32_decred.c +107 -0
- package/runtime/third_party/bearssl/src/int/i32_div32.c +56 -0
- package/runtime/third_party/bearssl/src/int/i32_encode.c +72 -0
- package/runtime/third_party/bearssl/src/int/i32_fmont.c +60 -0
- package/runtime/third_party/bearssl/src/int/i32_iszero.c +39 -0
- package/runtime/third_party/bearssl/src/int/i32_modpow.c +65 -0
- package/runtime/third_party/bearssl/src/int/i32_montmul.c +69 -0
- package/runtime/third_party/bearssl/src/int/i32_mulacc.c +56 -0
- package/runtime/third_party/bearssl/src/int/i32_muladd.c +138 -0
- package/runtime/third_party/bearssl/src/int/i32_ninv32.c +39 -0
- package/runtime/third_party/bearssl/src/int/i32_reduce.c +66 -0
- package/runtime/third_party/bearssl/src/int/i32_sub.c +51 -0
- package/runtime/third_party/bearssl/src/int/i32_tmont.c +36 -0
- package/runtime/third_party/bearssl/src/int/i62_modpow2.c +493 -0
- package/runtime/third_party/bearssl/src/kdf/hkdf.c +107 -0
- package/runtime/third_party/bearssl/src/kdf/shake.c +590 -0
- package/runtime/third_party/bearssl/src/mac/hmac.c +122 -0
- package/runtime/third_party/bearssl/src/mac/hmac_ct.c +193 -0
- package/runtime/third_party/bearssl/src/rand/aesctr_drbg.c +206 -0
- package/runtime/third_party/bearssl/src/rand/hmac_drbg.c +157 -0
- package/runtime/third_party/bearssl/src/rand/sysrng.c +252 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_keygen.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_modulus.c +36 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_oaep_decrypt.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_oaep_encrypt.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pkcs1_sign.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pkcs1_vrfy.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_priv.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_privexp.c +36 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pss_sign.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pss_vrfy.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pub.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pubexp.c +36 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_keygen.c +583 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_modulus.c +99 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_oaep_decrypt.c +41 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_oaep_encrypt.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pkcs1_sign.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pkcs1_vrfy.c +43 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_priv.c +209 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_privexp.c +320 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pss_sign.c +40 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pss_vrfy.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pub.c +113 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pubexp.c +152 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_keygen.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_keygen_inner.c +608 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_modulus.c +99 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_oaep_decrypt.c +41 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_oaep_encrypt.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pkcs1_sign.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pkcs1_vrfy.c +43 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_priv.c +203 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_privexp.c +318 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pss_sign.c +40 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pss_vrfy.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pub.c +106 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pubexp.c +152 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_oaep_decrypt.c +41 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_oaep_encrypt.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pkcs1_sign.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pkcs1_vrfy.c +43 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_priv.c +160 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pss_sign.c +40 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pss_vrfy.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pub.c +77 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_keygen.c +57 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_oaep_decrypt.c +61 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_oaep_encrypt.c +64 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pkcs1_sign.c +57 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pkcs1_vrfy.c +63 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_priv.c +223 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pss_sign.c +60 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pss_vrfy.c +64 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pub.c +125 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_oaep_pad.c +112 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_oaep_unpad.c +145 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pkcs1_sig_pad.c +100 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pkcs1_sig_unpad.c +121 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pss_sig_pad.c +106 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pss_sig_unpad.c +121 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_ssl_decrypt.c +52 -0
- package/runtime/third_party/bearssl/src/settings.c +306 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_cbcdec.c +69 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_cbcenc.c +67 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_ctr.c +84 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_ctrcbc.c +142 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_dec.c +254 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_enc.c +157 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_common.c +112 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct.c +328 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64.c +398 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_cbcdec.c +104 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_cbcenc.c +81 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_ctr.c +114 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_ctrcbc.c +433 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_dec.c +159 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_enc.c +115 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_cbcdec.c +111 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_cbcenc.c +91 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_ctr.c +116 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_ctrcbc.c +422 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_dec.c +170 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_enc.c +112 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8.c +445 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_cbcdec.c +670 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_cbcenc.c +417 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_ctr.c +717 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_ctrcbc.c +946 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_cbcdec.c +69 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_cbcenc.c +67 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_ctr.c +84 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_ctrcbc.c +142 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_dec.c +176 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_enc.c +129 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni.c +240 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_cbcdec.c +223 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_cbcenc.c +122 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_ctr.c +211 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_ctrcbc.c +596 -0
- package/runtime/third_party/bearssl/src/symcipher/chacha20_ct.c +106 -0
- package/runtime/third_party/bearssl/src/symcipher/chacha20_sse2.c +237 -0
- package/runtime/third_party/bearssl/src/symcipher/des_ct.c +411 -0
- package/runtime/third_party/bearssl/src/symcipher/des_ct_cbcdec.c +87 -0
- package/runtime/third_party/bearssl/src/symcipher/des_ct_cbcenc.c +69 -0
- package/runtime/third_party/bearssl/src/symcipher/des_support.c +166 -0
- package/runtime/third_party/bearssl/src/symcipher/des_tab.c +310 -0
- package/runtime/third_party/bearssl/src/symcipher/des_tab_cbcdec.c +85 -0
- package/runtime/third_party/bearssl/src/symcipher/des_tab_cbcenc.c +67 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmul.c +260 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmul32.c +297 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmulq.c +475 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_i15.c +221 -0
- package/runtime/third_party/bearssl/src/x509/asn1.t0 +757 -0
- package/runtime/third_party/bearssl/src/x509/asn1enc.c +93 -0
- package/runtime/third_party/bearssl/src/x509/encode_ec_pk8der.c +110 -0
- package/runtime/third_party/bearssl/src/x509/encode_ec_rawder.c +161 -0
- package/runtime/third_party/bearssl/src/x509/encode_rsa_pk8der.c +97 -0
- package/runtime/third_party/bearssl/src/x509/encode_rsa_rawder.c +96 -0
- package/runtime/third_party/bearssl/src/x509/skey_decoder.c +653 -0
- package/runtime/third_party/bearssl/src/x509/skey_decoder.t0 +376 -0
- package/runtime/third_party/bearssl/src/x509/x509_decoder.c +776 -0
- package/runtime/third_party/bearssl/src/x509/x509_decoder.t0 +324 -0
- package/runtime/third_party/bearssl/src/x509/x509_knownkey.c +105 -0
- package/runtime/third_party/bearssl/src/x509/x509_minimal.c +1722 -0
- package/runtime/third_party/bearssl/src/x509/x509_minimal.t0 +1526 -0
- package/runtime/third_party/bearssl/src/x509/x509_minimal_full.c +59 -0
- package/runtime/third_party/quickjs-dtoa/LICENSE +22 -0
- package/runtime/third_party/quickjs-dtoa/README.md +23 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.c +1640 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.h +83 -0
- package/runtime/third_party/quickjs-dtoa/dtoa_compat.h +89 -0
- package/runtime/third_party/quickjs-regexp/LICENSE +22 -0
- package/runtime/third_party/quickjs-regexp/README.md +22 -0
- package/runtime/third_party/quickjs-regexp/cutils.c +641 -0
- package/runtime/third_party/quickjs-regexp/cutils.h +457 -0
- package/runtime/third_party/quickjs-regexp/libregexp-opcode.h +73 -0
- package/runtime/third_party/quickjs-regexp/libregexp.c +3448 -0
- package/runtime/third_party/quickjs-regexp/libregexp.h +65 -0
- package/runtime/third_party/quickjs-regexp/libunicode-table.h +5206 -0
- package/runtime/third_party/quickjs-regexp/libunicode.c +2124 -0
- package/runtime/third_party/quickjs-regexp/libunicode.h +196 -0
- package/runtime/third_party/v8-ieee754/LICENSE +61 -0
- package/runtime/third_party/v8-ieee754/README.md +22 -0
- package/runtime/third_party/v8-ieee754/convert.py +84 -0
- package/runtime/third_party/v8-ieee754/ieee754.c +3030 -0
- package/runtime/third_party/v8-ieee754/ieee754.h +27 -0
- package/runtime/tools/regexp_compile.c +90 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/* Generators (ECMAScript §27.3–27.5, §15.5.5; ADR 0007): the generator object, its driver
|
|
2
|
+
* (%GeneratorPrototype%.next / return / throw) and yield* delegation. */
|
|
3
|
+
#include "js_generator.h"
|
|
4
|
+
|
|
5
|
+
#include "internal.h"
|
|
6
|
+
#include "js_atoms.h"
|
|
7
|
+
#include "js_function.h"
|
|
8
|
+
#include "js_ops.h"
|
|
9
|
+
#include "js_promise.h"
|
|
10
|
+
#include "js_symbol.h"
|
|
11
|
+
#include "jscontext.h"
|
|
12
|
+
|
|
13
|
+
void js_generator_visit(JSCell *c, JSTracer *trc) {
|
|
14
|
+
js_trace_value(trc, ((JSGenerator *)c)->frame);
|
|
15
|
+
js_trace_value(trc, ((JSGenerator *)c)->driver);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static const JSClass generator_class = { "Generator", sizeof(JSGenerator), NULL, NULL, NULL, NULL, js_generator_visit, NULL, NULL };
|
|
19
|
+
|
|
20
|
+
JSGenerator *js_generator_alloc(JSContext *ctx, const JSClass *cls, JSValue proto, JSGeneratorResume resume, uint32_t slots) {
|
|
21
|
+
JSValueArray *frame = js_alloc_value_array(ctx, slots);
|
|
22
|
+
JSGenerator *g = (JSGenerator *)js_alloc_object(ctx, JS_CELL_OBJECT, js_shape_root(ctx, cls, proto, 0));
|
|
23
|
+
g->resume = resume;
|
|
24
|
+
js_store(ctx, &g->obj.cell, &g->frame, js_cell(&frame->cell));
|
|
25
|
+
js_store(ctx, &g->obj.cell, &g->driver, JS_UNDEFINED);
|
|
26
|
+
g->state = 0;
|
|
27
|
+
g->status = JS_GEN_START;
|
|
28
|
+
return g;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* OrdinaryCreateFromConstructor(callee, fallback): callee.prototype, else the realm's. */
|
|
32
|
+
JSValue js_generator_proto(JSContext *ctx, JSValue callee, JSIntrinsic fallback) {
|
|
33
|
+
JSValue proto = js_get_value(ctx, callee, JS_ATOM(prototype));
|
|
34
|
+
if (js_is_exception(proto) || js_is_object(proto)) return proto;
|
|
35
|
+
JSContext *realm = js_function_realm(ctx, callee);
|
|
36
|
+
return realm ? realm->intrinsics[fallback] : JS_EXCEPTION;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
JSValue js_generator_new(JSContext *ctx, JSValue callee, JSGeneratorResume resume, uint32_t slots) {
|
|
40
|
+
JSValue proto = js_generator_proto(ctx, callee, JS_INTRINSIC_GENERATOR_PROTOTYPE);
|
|
41
|
+
if (js_is_exception(proto)) return JS_EXCEPTION;
|
|
42
|
+
return js_object_value(&js_generator_alloc(ctx, &generator_class, proto, resume, slots)->obj);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* GeneratorResume / GeneratorResumeAbrupt (§27.5.3.3–4) */
|
|
46
|
+
static JSValue generator_resume(JSContext *ctx, JSValue this_val, JSValue value, int mode, const char *method) {
|
|
47
|
+
if (!js_is_object(this_val) || js_as_object(this_val)->shape->cls != &generator_class)
|
|
48
|
+
return js_throw_type_error(ctx, "%s method called on incompatible receiver (not a generator)", method);
|
|
49
|
+
JSGenerator *g = js_as_generator(this_val);
|
|
50
|
+
if (g->status == JS_GEN_EXECUTING) return js_throw_type_error(ctx, "Generator is already running");
|
|
51
|
+
if (g->status == JS_GEN_START && mode != JS_RESUME_NEXT) {
|
|
52
|
+
g->status = JS_GEN_COMPLETED; /* never started: its body doesn't run at all */
|
|
53
|
+
js_store(ctx, &g->obj.cell, &g->frame, JS_UNDEFINED);
|
|
54
|
+
}
|
|
55
|
+
if (g->status == JS_GEN_COMPLETED) {
|
|
56
|
+
if (mode == JS_RESUME_THROW) return js_throw(ctx, value);
|
|
57
|
+
return js_iter_result(ctx, mode == JS_RESUME_RETURN ? value : JS_UNDEFINED, true);
|
|
58
|
+
}
|
|
59
|
+
g->status = JS_GEN_EXECUTING;
|
|
60
|
+
g->raw = 0;
|
|
61
|
+
JSValue r = g->resume(ctx, g, value, mode);
|
|
62
|
+
if (g->status == JS_GEN_EXECUTING) { /* it returned or threw: done for good */
|
|
63
|
+
g->status = JS_GEN_COMPLETED;
|
|
64
|
+
js_store(ctx, &g->obj.cell, &g->frame, JS_UNDEFINED);
|
|
65
|
+
return js_is_exception(r) ? JS_EXCEPTION : js_iter_result(ctx, r, true);
|
|
66
|
+
}
|
|
67
|
+
return g->raw ? r : js_iter_result(ctx, r, false);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
#define DRIVER(fn, mode, name) \
|
|
71
|
+
static JSValue fn(JSContext *ctx, JSValue callee, JSValue this_val, uint32_t argc, const JSValue *argv, \
|
|
72
|
+
JSValue new_target) { \
|
|
73
|
+
(void)callee, (void)new_target; \
|
|
74
|
+
return generator_resume(ctx, this_val, argc ? argv[0] : JS_UNDEFINED, mode, name); \
|
|
75
|
+
}
|
|
76
|
+
DRIVER(generator_next, JS_RESUME_NEXT, "next")
|
|
77
|
+
DRIVER(generator_return, JS_RESUME_RETURN, "return")
|
|
78
|
+
DRIVER(generator_throw, JS_RESUME_THROW, "throw")
|
|
79
|
+
|
|
80
|
+
/* ---- yield* (§15.5.5) ------------------------------------------------------------------ */
|
|
81
|
+
|
|
82
|
+
enum { YS_YIELD, YS_DONE, YS_RETURN };
|
|
83
|
+
|
|
84
|
+
typedef struct YieldStar {
|
|
85
|
+
JSHostCell host;
|
|
86
|
+
JSValue iterator;
|
|
87
|
+
JSValue next;
|
|
88
|
+
int status;
|
|
89
|
+
} YieldStar;
|
|
90
|
+
|
|
91
|
+
static void yield_star_visit(JSCell *c, JSTracer *trc) {
|
|
92
|
+
YieldStar *y = (YieldStar *)c;
|
|
93
|
+
js_trace_value(trc, y->iterator);
|
|
94
|
+
js_trace_value(trc, y->next);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
static const JSCellClass yield_star_class = { "YieldStar", yield_star_visit, NULL };
|
|
98
|
+
|
|
99
|
+
JSValue js_yield_star_start(JSContext *ctx, JSValue iterable) {
|
|
100
|
+
JSValue method = js_is_nullish(iterable) ? JS_UNDEFINED : js_get_value(ctx, iterable, JS_SYMBOL(iterator));
|
|
101
|
+
if (js_is_exception(method)) return JS_EXCEPTION;
|
|
102
|
+
if (!js_is_callable(method)) return js_throw_type_error(ctx, "yield* operand is not iterable");
|
|
103
|
+
JSValue it = js_call(ctx, method, iterable, 0, NULL);
|
|
104
|
+
if (js_is_exception(it)) return JS_EXCEPTION;
|
|
105
|
+
if (!js_is_object(it)) return js_throw_type_error(ctx, "Result of the Symbol.iterator method is not an object");
|
|
106
|
+
JSValue next = js_get_value(ctx, it, JS_ATOM(next));
|
|
107
|
+
if (js_is_exception(next)) return JS_EXCEPTION;
|
|
108
|
+
YieldStar *y = (YieldStar *)js_alloc_host_cell(ctx, &yield_star_class, sizeof(YieldStar));
|
|
109
|
+
js_store(ctx, &y->host.cell, &y->iterator, it);
|
|
110
|
+
js_store(ctx, &y->host.cell, &y->next, next);
|
|
111
|
+
return js_cell(&y->host.cell);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
JSValue js_yield_star_status(JSValue rec) { return js_int32(((YieldStar *)js_as_cell(rec))->status); }
|
|
115
|
+
|
|
116
|
+
/* An inner result: done → its value (status DONE, or RETURN after a return()); else the result itself. */
|
|
117
|
+
static JSValue inner_result(JSContext *ctx, YieldStar *y, JSValue result, int when_done) {
|
|
118
|
+
if (js_is_exception(result)) return JS_EXCEPTION;
|
|
119
|
+
if (!js_is_object(result)) return js_throw_type_error(ctx, "Iterator result is not an object");
|
|
120
|
+
JSValue done = js_get_value(ctx, result, JS_ATOM(done));
|
|
121
|
+
if (js_is_exception(done)) return JS_EXCEPTION;
|
|
122
|
+
if (!js_truthy(done)) {
|
|
123
|
+
y->status = YS_YIELD;
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
y->status = when_done;
|
|
127
|
+
return js_get_value(ctx, result, JS_ATOM(value));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
JSValue js_yield_star_step(JSContext *ctx, JSValue rec, JSValue received, JSValue mode_value) {
|
|
131
|
+
YieldStar *y = (YieldStar *)js_as_cell(rec);
|
|
132
|
+
int mode = js_as_int32(mode_value);
|
|
133
|
+
if (mode == JS_RESUME_NEXT) return inner_result(ctx, y, js_call(ctx, y->next, y->iterator, 1, &received), YS_DONE);
|
|
134
|
+
JSValue method = js_get_value(ctx, y->iterator, mode == JS_RESUME_THROW ? js_atom_from_cstr(ctx, "throw") : JS_ATOM(return));
|
|
135
|
+
if (js_is_exception(method)) return JS_EXCEPTION;
|
|
136
|
+
if (!js_is_nullish(method) && !js_is_callable(method)) return js_throw_type_error(ctx, "The iterator's method is not callable");
|
|
137
|
+
if (mode == JS_RESUME_RETURN) {
|
|
138
|
+
if (js_is_nullish(method)) { /* no return(): this generator returns the value itself */
|
|
139
|
+
y->status = YS_RETURN;
|
|
140
|
+
return received;
|
|
141
|
+
}
|
|
142
|
+
return inner_result(ctx, y, js_call(ctx, method, y->iterator, 1, &received), YS_RETURN);
|
|
143
|
+
}
|
|
144
|
+
if (!js_is_nullish(method)) return inner_result(ctx, y, js_call(ctx, method, y->iterator, 1, &received), YS_DONE);
|
|
145
|
+
/* no throw(): close the inner iterator (its errors win), then a TypeError */
|
|
146
|
+
JSValue ret = js_get_value(ctx, y->iterator, JS_ATOM(return));
|
|
147
|
+
if (js_is_exception(ret)) return JS_EXCEPTION;
|
|
148
|
+
if (!js_is_nullish(ret)) {
|
|
149
|
+
if (!js_is_callable(ret)) return js_throw_type_error(ctx, "The iterator's 'return' method is not callable");
|
|
150
|
+
JSValue r = js_call(ctx, ret, y->iterator, 0, NULL);
|
|
151
|
+
if (js_is_exception(r)) return JS_EXCEPTION;
|
|
152
|
+
if (!js_is_object(r)) return js_throw_type_error(ctx, "The iterator's 'return' method returned a non-object");
|
|
153
|
+
}
|
|
154
|
+
return js_throw_type_error(ctx, "The iterator does not provide a 'throw' method");
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/* ---- Async functions (§27.7; ADR 0007) ------------------------------------------------- */
|
|
158
|
+
|
|
159
|
+
static const JSClass async_class = { "AsyncFunctionState", sizeof(JSGenerator), NULL, NULL, NULL, NULL, js_generator_visit, NULL, NULL };
|
|
160
|
+
|
|
161
|
+
JSValue js_async_new(JSContext *ctx, JSGeneratorResume resume, uint32_t slots) {
|
|
162
|
+
JSGenerator *g = js_generator_alloc(ctx, &async_class, JS_NULL, resume, slots);
|
|
163
|
+
g->kind = JS_GEN_ASYNC_FUNCTION;
|
|
164
|
+
JSValue promise = js_new_promise(ctx); /* after the frame: the cell is fully set when it allocates */
|
|
165
|
+
js_store(ctx, &g->obj.cell, &g->driver, promise);
|
|
166
|
+
return js_object_value(&g->obj);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/* The async driver: after the body returns or throws, settle the promise. */
|
|
170
|
+
void js_async_resume(JSContext *ctx, JSGenerator *g, JSValue value, int mode) {
|
|
171
|
+
if (g->kind == JS_GEN_ASYNC_GENERATOR) {
|
|
172
|
+
js_async_generator_resume(ctx, g, value, mode);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
g->status = JS_GEN_EXECUTING;
|
|
176
|
+
JSValue r = g->resume(ctx, g, value, mode);
|
|
177
|
+
if (g->status != JS_GEN_EXECUTING) return; /* paused at an await */
|
|
178
|
+
g->status = JS_GEN_COMPLETED;
|
|
179
|
+
js_store(ctx, &g->obj.cell, &g->frame, JS_UNDEFINED);
|
|
180
|
+
if (js_is_exception(r)) js_promise_reject_internal(ctx, g->driver, js_take_exception(ctx));
|
|
181
|
+
else js_promise_resolve_internal(ctx, g->driver, r);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
JSValue js_async_start(JSContext *ctx, JSGenerator *g) {
|
|
185
|
+
js_async_resume(ctx, g, JS_UNDEFINED, JS_RESUME_NEXT);
|
|
186
|
+
return g->driver;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
int js_await(JSContext *ctx, JSGenerator *g, JSValue v) {
|
|
190
|
+
JSValue promise = js_promise_resolve(ctx, v);
|
|
191
|
+
if (js_is_exception(promise)) return -1;
|
|
192
|
+
js_promise_await(ctx, promise, js_object_value(&g->obj));
|
|
193
|
+
g->status = JS_GEN_AWAITING;
|
|
194
|
+
return 0;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/* ---- Realm (§27.3, §27.5, §27.7) ------------------------------------------------------ */
|
|
198
|
+
|
|
199
|
+
void js_generator_realm_init(JSContext *ctx) {
|
|
200
|
+
JSValue *in = ctx->intrinsics;
|
|
201
|
+
/* %GeneratorFunction.prototype%: the [[Prototype]] of every generator function */
|
|
202
|
+
in[JS_INTRINSIC_GENERATOR_FUNCTION_PROTOTYPE] = js_new_object_proto(ctx, in[JS_INTRINSIC_FUNCTION_PROTOTYPE], 4);
|
|
203
|
+
JSObject *gfp = js_as_object(in[JS_INTRINSIC_GENERATOR_FUNCTION_PROTOTYPE]);
|
|
204
|
+
/* %GeneratorPrototype%: the [[Prototype]] of each generator function's prototype */
|
|
205
|
+
in[JS_INTRINSIC_GENERATOR_PROTOTYPE] = js_new_object_proto(ctx, in[JS_INTRINSIC_ITERATOR_PROTOTYPE], 8);
|
|
206
|
+
JSObject *gp = js_as_object(in[JS_INTRINSIC_GENERATOR_PROTOTYPE]);
|
|
207
|
+
js_define_data(ctx, gfp, JS_ATOM(prototype), in[JS_INTRINSIC_GENERATOR_PROTOTYPE], JS_PROP_CONFIGURABLE);
|
|
208
|
+
js_define_data(ctx, gfp, JS_SYMBOL(toStringTag), js_atom_from_cstr(ctx, "GeneratorFunction"), JS_PROP_CONFIGURABLE);
|
|
209
|
+
js_define_data(ctx, gp, JS_ATOM(constructor), in[JS_INTRINSIC_GENERATOR_FUNCTION_PROTOTYPE], JS_PROP_CONFIGURABLE);
|
|
210
|
+
(void)js_define_method(ctx, gp, "next", generator_next, 1);
|
|
211
|
+
(void)js_define_method(ctx, gp, "return", generator_return, 1);
|
|
212
|
+
(void)js_define_method(ctx, gp, "throw", generator_throw, 1);
|
|
213
|
+
js_define_data(ctx, gp, JS_SYMBOL(toStringTag), js_atom_from_cstr(ctx, "Generator"), JS_PROP_CONFIGURABLE);
|
|
214
|
+
/* %AsyncFunction.prototype%: the [[Prototype]] of every async function */
|
|
215
|
+
in[JS_INTRINSIC_ASYNC_FUNCTION_PROTOTYPE] = js_new_object_proto(ctx, in[JS_INTRINSIC_FUNCTION_PROTOTYPE], 4);
|
|
216
|
+
js_define_data(ctx, js_as_object(in[JS_INTRINSIC_ASYNC_FUNCTION_PROTOTYPE]), JS_SYMBOL(toStringTag),
|
|
217
|
+
js_atom_from_cstr(ctx, "AsyncFunction"), JS_PROP_CONFIGURABLE);
|
|
218
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/* The global object and the primitives' prototypes (ECMAScript §19; ADR 0011, 0012). */
|
|
2
|
+
#include "internal.h"
|
|
3
|
+
#include "js_atoms.h"
|
|
4
|
+
#include "js_console.h"
|
|
5
|
+
#include "js_error.h"
|
|
6
|
+
#include "js_generator.h"
|
|
7
|
+
#include "js_promise.h"
|
|
8
|
+
#include "js_ops.h"
|
|
9
|
+
#include "js_symbol.h"
|
|
10
|
+
#include "jsnum.h"
|
|
11
|
+
|
|
12
|
+
/* String.prototype, Number.prototype and Boolean.prototype: where primitives look up
|
|
13
|
+
* properties, and themselves wrapper objects (§22.1.3, §21.1.3, §20.3.3): of "", 0 and false. */
|
|
14
|
+
static void primitive_prototypes_init(JSContext *ctx) {
|
|
15
|
+
JSValue object_proto = ctx->intrinsics[JS_INTRINSIC_OBJECT_PROTOTYPE];
|
|
16
|
+
ctx->intrinsics[JS_INTRINSIC_STRING_PROTOTYPE] = js_new_wrapper(ctx, js_empty_string(), object_proto); /* own length 0 */
|
|
17
|
+
ctx->intrinsics[JS_INTRINSIC_NUMBER_PROTOTYPE] = js_new_wrapper(ctx, js_int32(0), object_proto);
|
|
18
|
+
ctx->intrinsics[JS_INTRINSIC_BOOLEAN_PROTOTYPE] = js_new_wrapper(ctx, JS_FALSE, object_proto);
|
|
19
|
+
ctx->intrinsics[JS_INTRINSIC_SYMBOL_PROTOTYPE] = js_new_object_proto(ctx, object_proto, 8);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static void define_function(JSContext *ctx, JSObject *o, const char *name, JSNativeFn fn, uint32_t length) {
|
|
23
|
+
JSValue f = js_define_method(ctx, o, name, fn, length);
|
|
24
|
+
(void)f;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
void js_global_realm_init(JSContext *ctx) {
|
|
28
|
+
primitive_prototypes_init(ctx);
|
|
29
|
+
JSValue global = js_new_object_proto(ctx, ctx->intrinsics[JS_INTRINSIC_OBJECT_PROTOTYPE], 16);
|
|
30
|
+
ctx->intrinsics[JS_INTRINSIC_GLOBAL_OBJECT] = global;
|
|
31
|
+
JSObject *g = js_as_object(global);
|
|
32
|
+
const uint8_t attrs = JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE;
|
|
33
|
+
|
|
34
|
+
/* §19.1: value properties are non-writable and non-configurable */
|
|
35
|
+
js_define_data(ctx, g, JS_ATOM(globalThis), global, attrs);
|
|
36
|
+
js_define_data(ctx, g, JS_ATOM(Infinity), js_double(INFINITY), 0);
|
|
37
|
+
js_define_data(ctx, g, JS_ATOM(NaN), js_double(NAN), 0);
|
|
38
|
+
js_define_data(ctx, g, JS_ATOM(undefined), JS_UNDEFINED, 0);
|
|
39
|
+
|
|
40
|
+
js_error_realm_init(ctx, g);
|
|
41
|
+
js_builtins_realm_init(ctx, g);
|
|
42
|
+
js_symbol_realm_init(ctx, g);
|
|
43
|
+
js_iterator_realm_init(ctx);
|
|
44
|
+
js_generator_realm_init(ctx);
|
|
45
|
+
js_async_iter_realm_init(ctx);
|
|
46
|
+
js_promise_realm_init(ctx, g);
|
|
47
|
+
js_weak_realm_init(ctx, g);
|
|
48
|
+
js_jobs_realm_init(ctx, g); /* queueMicrotask (ADR 0008: the v1 host) */
|
|
49
|
+
define_function(ctx, g, "print", js_print, 1); /* the test host's print (ADR 0011) */
|
|
50
|
+
/* console comes from the host prelude, which every program runs first (ADR 0012) */
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* ---- Global name lookup ------------------------------------------------------- */
|
|
54
|
+
|
|
55
|
+
static JSValue global_lookup(JSContext *ctx, const char *name, bool for_typeof) {
|
|
56
|
+
JSValue key = js_atom_from_cstr(ctx, name);
|
|
57
|
+
if (js_is_exception(key)) return JS_EXCEPTION;
|
|
58
|
+
JSValue global = ctx->intrinsics[JS_INTRINSIC_GLOBAL_OBJECT];
|
|
59
|
+
int has = js_has_property(ctx, js_as_object(global), key);
|
|
60
|
+
if (has < 0) return JS_EXCEPTION;
|
|
61
|
+
if (!has) return for_typeof ? JS_UNDEFINED : js_throw_reference_error(ctx, "%s is not defined", name);
|
|
62
|
+
return js_get(ctx, js_as_object(global), key, global);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
JSValue js_global_name(JSContext *ctx, const char *name) { return global_lookup(ctx, name, false); }
|
|
66
|
+
JSValue js_global_typeof_name(JSContext *ctx, const char *name) { return global_lookup(ctx, name, true); }
|
|
67
|
+
|
|
68
|
+
/* ---- Script globals (§16.1.7 GlobalDeclarationInstantiation; ADR 0009 classic scripts) --- */
|
|
69
|
+
|
|
70
|
+
static JSObject *global_object(JSContext *ctx) { return js_as_object(ctx->intrinsics[JS_INTRINSIC_GLOBAL_OBJECT]); }
|
|
71
|
+
|
|
72
|
+
int js_declare_global_var(JSContext *ctx, JSValue key) {
|
|
73
|
+
JSObject *g = global_object(ctx);
|
|
74
|
+
JSPropertyDescriptor d;
|
|
75
|
+
int has = js_get_own_property(ctx, g, key, &d);
|
|
76
|
+
if (has < 0) return -1;
|
|
77
|
+
if (has) return 0; /* an existing property keeps its value (`var Array;` changes nothing) */
|
|
78
|
+
if (!js_is_extensible(g)) {
|
|
79
|
+
js_discard(js_throw_type_error(ctx, "Cannot declare a global variable: the global object is not extensible"));
|
|
80
|
+
return -1;
|
|
81
|
+
}
|
|
82
|
+
JSPropertyDescriptor v = js_data_descriptor(JS_UNDEFINED, JS_PROP_WRITABLE | JS_PROP_ENUMERABLE);
|
|
83
|
+
return js_define_own_property(ctx, g, key, &v, true) < 0 ? -1 : 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
int js_declare_global_function(JSContext *ctx, JSValue key, JSValue fn) {
|
|
87
|
+
JSObject *g = global_object(ctx);
|
|
88
|
+
JSPropertyDescriptor d;
|
|
89
|
+
int has = js_get_own_property(ctx, g, key, &d);
|
|
90
|
+
if (has < 0) return -1;
|
|
91
|
+
JSPropertyDescriptor v;
|
|
92
|
+
if (!has || (d.attrs & JS_PROP_CONFIGURABLE)) {
|
|
93
|
+
v = js_data_descriptor(fn, JS_PROP_WRITABLE | JS_PROP_ENUMERABLE);
|
|
94
|
+
} else if ((d.has & JS_DESC_VALUE) && (d.attrs & JS_PROP_WRITABLE) && (d.attrs & JS_PROP_ENUMERABLE)) {
|
|
95
|
+
v = (JSPropertyDescriptor){ JS_DESC_VALUE, 0, fn, JS_UNDEFINED, JS_UNDEFINED }; /* CanDeclareGlobalFunction: the value only */
|
|
96
|
+
} else {
|
|
97
|
+
char name[64] = "";
|
|
98
|
+
if (js_is_string(key)) name[js_view_to_utf8(js_string_view(ctx, key), name, sizeof name - 1)] = '\0';
|
|
99
|
+
js_discard(js_throw_type_error(ctx, "Cannot redefine property: %s", name));
|
|
100
|
+
return -1;
|
|
101
|
+
}
|
|
102
|
+
return js_define_own_property(ctx, g, key, &v, true) < 0 ? -1 : 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
int js_set_global_name(JSContext *ctx, JSValue key, JSValue v, bool strict) {
|
|
106
|
+
JSObject *g = global_object(ctx);
|
|
107
|
+
if (strict) {
|
|
108
|
+
/* PutValue of an unresolvable reference: strict code can't create globals */
|
|
109
|
+
int has = js_has_property(ctx, g, key);
|
|
110
|
+
if (has < 0) return -1;
|
|
111
|
+
if (!has) {
|
|
112
|
+
char name[64] = "";
|
|
113
|
+
if (js_is_string(key)) name[js_view_to_utf8(js_string_view(ctx, key), name, sizeof name - 1)] = '\0';
|
|
114
|
+
js_discard(js_throw_reference_error(ctx, "%s is not defined", name));
|
|
115
|
+
return -1;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return js_set(ctx, g, key, v, js_object_value(g), strict);
|
|
119
|
+
}
|