@scriptc/cli-darwin-x64 0.2.0 → 0.2.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/dist/THIRD_PARTY_NOTICES +1 -1
- package/dist/bin/scriptc +0 -0
- package/dist/bin/scriptc.json +1 -1
- package/dist/lib/declarations/scriptc-node-fallback.d.ts +84 -19
- package/dist/lib/llvm/bin/scriptc-llvm-codegen +0 -0
- package/dist/lib/llvm/package.json +1 -1
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_fetch.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_qs.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_island.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_qs.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic/scr_web.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-dev/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/library-thread-release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/licenses/v8-number-radix.txt +61 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_fetch.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_qs.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/default/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_array.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_assert.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_async_dyn.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bigint.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_bytes_io.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_child.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_console.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_console_native.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_crypto_async.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_dyn_invoke.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_error.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_events.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_exception.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_file_handle.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_grapheme.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_http.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_http2.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_island.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_json.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_lib.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_map.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_net.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_node_builtin.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_object.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_qs.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_regex.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_stream.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_string.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_symbol.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_url.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic/scr_web.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/dynamic-text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/artifacts/release/runtime/text-decoder-legacy/scr_bytes.o +0 -0
- package/dist/lib/runtime-darwin-x64/package.json +1 -1
- package/dist/lib/runtime-darwin-x64/runtime-pack.json +549 -545
- package/dist/lib/runtime-sources/package.json +1 -1
- package/dist/lib/runtime-sources/src/scr_abort.c +5 -0
- package/dist/lib/runtime-sources/src/scr_array.c +16 -0
- package/dist/lib/runtime-sources/src/scr_assert.c +1 -0
- package/dist/lib/runtime-sources/src/scr_async.c +38 -5
- package/dist/lib/runtime-sources/src/scr_async_dyn.c +208 -40
- package/dist/lib/runtime-sources/src/scr_bigint.c +8 -0
- package/dist/lib/runtime-sources/src/scr_bytes.c +431 -41
- package/dist/lib/runtime-sources/src/scr_bytes_io.c +628 -12
- package/dist/lib/runtime-sources/src/scr_child.c +544 -17
- package/dist/lib/runtime-sources/src/scr_console.c +1 -1
- package/dist/lib/runtime-sources/src/scr_crypto_async.c +22 -2
- package/dist/lib/runtime-sources/src/scr_dyn_invoke.c +344 -73
- package/dist/lib/runtime-sources/src/scr_error.c +52 -5
- package/dist/lib/runtime-sources/src/scr_exception.c +21 -5
- package/dist/lib/runtime-sources/src/scr_fetch.c +311 -3
- package/dist/lib/runtime-sources/src/scr_file_handle.c +31 -0
- package/dist/lib/runtime-sources/src/scr_http.c +3 -0
- package/dist/lib/runtime-sources/src/scr_island.c +1226 -405
- package/dist/lib/runtime-sources/src/scr_island_manifest.h +11 -9
- package/dist/lib/runtime-sources/src/scr_json.c +1594 -139
- package/dist/lib/runtime-sources/src/scr_json.test.ts +1 -0
- package/dist/lib/runtime-sources/src/scr_lib.c +816 -34
- package/dist/lib/runtime-sources/src/scr_map.c +47 -0
- package/dist/lib/runtime-sources/src/scr_node_builtin.c +10 -0
- package/dist/lib/runtime-sources/src/scr_object.c +11 -0
- package/dist/lib/runtime-sources/src/scr_qs.c +10 -0
- package/dist/lib/runtime-sources/src/scr_regex.c +148 -72
- package/dist/lib/runtime-sources/src/scr_runtime.h +257 -41
- package/dist/lib/runtime-sources/src/scr_stream.c +197 -0
- package/dist/lib/runtime-sources/src/scr_string.c +16 -1
- package/dist/lib/runtime-sources/src/scr_symbol.c +5 -0
- package/dist/lib/runtime-sources/src/scr_text_decoder_labels.h +225 -0
- package/dist/lib/runtime-sources/src/scr_url.c +206 -10
- package/dist/lib/runtime-sources/src/scr_web.c +129 -26
- package/dist/lib/runtime-sources/vendor/v8-number-radix/LICENSE +61 -0
- package/package.json +1 -1
|
@@ -72,9 +72,11 @@ static void scr_dyn_display_buf(ScrJsonBuf *b, const ScrDyn *d) {
|
|
|
72
72
|
case SCR_DYN_ARR:
|
|
73
73
|
for (size_t i = 0; i < d->v.arr.len; i++) {
|
|
74
74
|
if (i > 0) scr_jb_putc(b, ',');
|
|
75
|
-
|
|
76
|
-
if (e
|
|
77
|
-
scr_dyn_display_buf(b, e);
|
|
75
|
+
ScrDyn *e = scr_dyn_arr_at(d, (double)i);
|
|
76
|
+
if (!e) return;
|
|
77
|
+
if (e->kind != SCR_DYN_UNDEF && e->kind != SCR_DYN_NULL) scr_dyn_display_buf(b, e);
|
|
78
|
+
scr_dyn_release(e);
|
|
79
|
+
if (scr_exc_pending()) return;
|
|
78
80
|
}
|
|
79
81
|
return;
|
|
80
82
|
case SCR_DYN_OBJ: {
|
|
@@ -217,7 +219,7 @@ static ScrDyn *dyn_call_cb(ScrDyn *cb, ScrDyn *item, size_t i, ScrDyn *recv) {
|
|
|
217
219
|
/* The callable-callback gate: JS's "<String(cb)> is not a function". */
|
|
218
220
|
static bool dyn_cb_check(ScrDyn *const *args, size_t argc) {
|
|
219
221
|
ScrDyn *cb = argc > 0 ? args[0] : scr_dyn_undefined();
|
|
220
|
-
if (cb
|
|
222
|
+
if (scr_dyn_is_callable(cb)) return true;
|
|
221
223
|
/* An ENGINE function is callable — scr_dyn_call's JSVAL arm routes it
|
|
222
224
|
* (the loops below call through scr_dyn_call, which converts the checked-dynamic tree
|
|
223
225
|
* element arguments per the uniform crossing). A wrapped NON-function
|
|
@@ -451,10 +453,8 @@ ScrDyn *scr_dyn_array_proto_call(ScrDyn *recv, ScrStr *method, ScrDyn *args) {
|
|
|
451
453
|
bool present = dyn_borrow_present(recv, i);
|
|
452
454
|
if (scr_exc_pending()) { scr_dyn_release(out); return NULL; }
|
|
453
455
|
if (!present) {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
scr_dyn_release(out);
|
|
457
|
-
return NULL;
|
|
456
|
+
scr_dyn_arr_push_hole(out);
|
|
457
|
+
continue;
|
|
458
458
|
}
|
|
459
459
|
ScrDyn *item = dyn_borrow_item(recv, i);
|
|
460
460
|
if (!item) { scr_dyn_release(out); return NULL; }
|
|
@@ -514,10 +514,7 @@ ScrDyn *scr_dyn_array_proto_call(ScrDyn *recv, ScrStr *method, ScrDyn *args) {
|
|
|
514
514
|
if (scr_exc_pending()) { scr_dyn_release(out); return NULL; }
|
|
515
515
|
if (!present) {
|
|
516
516
|
if (map) {
|
|
517
|
-
|
|
518
|
-
static const char msg[] = "Array.prototype.map over sparse array-like values is not supported yet";
|
|
519
|
-
scr_throw_error_msg(SCR_ERR_ERROR, msg, sizeof msg - 1);
|
|
520
|
-
return NULL;
|
|
517
|
+
scr_dyn_arr_push_hole(out);
|
|
521
518
|
}
|
|
522
519
|
continue;
|
|
523
520
|
}
|
|
@@ -555,7 +552,15 @@ static bool dyn_name_is(const char *m, const char *n) { return strcmp(m, n) == 0
|
|
|
555
552
|
* accessor reports). */
|
|
556
553
|
static ScrDyn *scr_dynh_dispatch(ScrDyn *recv, const char *method, ScrDyn *const *args, size_t argc, const char *what) {
|
|
557
554
|
const ScrDynHandleOps *ops = scr_dyn_handle_ops_of(recv);
|
|
558
|
-
return ops->invoke(recv->v.handle.ptr, recv, method, args, argc, what);
|
|
555
|
+
if (ops->invoke) return ops->invoke(recv->v.handle.ptr, recv, method, args, argc, what);
|
|
556
|
+
ScrDyn *callable = ops->get ? ops->get(recv->v.handle.ptr, method, strlen(method)) : NULL;
|
|
557
|
+
if (scr_exc_pending()) { scr_dyn_release(callable); return NULL; }
|
|
558
|
+
if (!callable) callable = scr_dyn_retain(scr_dyn_undefined());
|
|
559
|
+
scr_dyn_this_push_dyn(recv);
|
|
560
|
+
ScrDyn *result = scr_dyn_call(callable, args, argc, what);
|
|
561
|
+
scr_dyn_this_pop();
|
|
562
|
+
scr_dyn_release(callable);
|
|
563
|
+
return result;
|
|
559
564
|
}
|
|
560
565
|
|
|
561
566
|
/* JS Array.prototype.sort over a dyn array: the spec's snapshot-sort —
|
|
@@ -647,26 +652,51 @@ static bool dyn_arr_flatten(ScrDyn *out, const ScrDyn *source, double depth, siz
|
|
|
647
652
|
scr_throw_error_msg_code(SCR_ERR_ERROR, message, sizeof message - 1, "SC2020");
|
|
648
653
|
return false;
|
|
649
654
|
}
|
|
650
|
-
|
|
655
|
+
if (!dyn_borrow_present((ScrDyn *)source, i)) { if (scr_exc_pending()) return false; continue; }
|
|
656
|
+
ScrDyn *item = dyn_borrow_item((ScrDyn *)source, i);
|
|
657
|
+
if (!item) return false;
|
|
658
|
+
if (depth > 0 && item->kind == SCR_DYN_TYPED_REF && scr_dyn_isl_is_array(item)) {
|
|
659
|
+
ScrDyn *view = scr_dyn_typed_ref_materialize(item);
|
|
660
|
+
if (!view || scr_exc_pending()) { scr_dyn_release(view); scr_dyn_release(item); return false; }
|
|
661
|
+
bool ok = dyn_arr_flatten(out, view, depth - 1, visits);
|
|
662
|
+
scr_dyn_release(view);
|
|
663
|
+
scr_dyn_release(item);
|
|
664
|
+
if (!ok) return false;
|
|
665
|
+
continue;
|
|
666
|
+
}
|
|
651
667
|
if (depth > 0 && item->kind == SCR_DYN_ARR) {
|
|
652
|
-
|
|
668
|
+
bool ok = dyn_arr_flatten(out, item, depth - 1, visits);
|
|
669
|
+
scr_dyn_release(item);
|
|
670
|
+
if (!ok) return false;
|
|
653
671
|
} else {
|
|
654
|
-
scr_dyn_arr_push(out,
|
|
672
|
+
scr_dyn_arr_push(out, item);
|
|
655
673
|
}
|
|
656
674
|
}
|
|
657
675
|
return true;
|
|
658
676
|
}
|
|
659
677
|
|
|
660
|
-
static
|
|
678
|
+
static bool dyn_arr_copy_item(ScrDyn *out, const ScrDyn *source, size_t index, bool preserve_hole) {
|
|
679
|
+
if (preserve_hole && !dyn_borrow_present((ScrDyn *)source, index)) {
|
|
680
|
+
if (scr_exc_pending()) return false;
|
|
681
|
+
scr_dyn_arr_push_hole(out);
|
|
682
|
+
return true;
|
|
683
|
+
}
|
|
684
|
+
ScrDyn *item = scr_dyn_arr_at(source, (double)index);
|
|
685
|
+
if (!item) return false;
|
|
686
|
+
scr_dyn_arr_push(out, item);
|
|
687
|
+
return true;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
static bool dyn_arr_reversed_copy(ScrDyn *out, const ScrDyn *source) {
|
|
661
691
|
for (size_t i = source->v.arr.len; i > 0; i--)
|
|
662
|
-
|
|
692
|
+
if (!dyn_arr_copy_item(out, source, i - 1, false)) return false;
|
|
693
|
+
return true;
|
|
663
694
|
}
|
|
664
695
|
|
|
665
696
|
/* Names each prototype declares BEYOND what's implemented here — these
|
|
666
697
|
* fence loudly instead of mis-answering "is not a function". */
|
|
667
698
|
static bool dyn_arr_proto_unimpl(const char *m) {
|
|
668
|
-
static const char *names[] = { "
|
|
669
|
-
"toString", "toLocaleString", NULL };
|
|
699
|
+
static const char *names[] = { "toString", "toLocaleString", NULL };
|
|
670
700
|
for (size_t i = 0; names[i]; i++) if (dyn_name_is(m, names[i])) return true;
|
|
671
701
|
return false;
|
|
672
702
|
}
|
|
@@ -690,6 +720,29 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
690
720
|
ScrDyn *recv, const char *method, ScrDyn *const *args, size_t argc,
|
|
691
721
|
const char *what, ScrDyn *callback_recv);
|
|
692
722
|
|
|
723
|
+
ScrDyn *scr_dyn_prepare_method(ScrDyn *recv, const char *method) {
|
|
724
|
+
if (recv->kind == SCR_DYN_UNDEF || recv->kind == SCR_DYN_NULL)
|
|
725
|
+
return scr_dyn_invoke(recv, method, NULL, 0, method);
|
|
726
|
+
if (recv->kind == SCR_DYN_OBJ)
|
|
727
|
+
return scr_dyn_obj_read(recv, method, strlen(method));
|
|
728
|
+
if (recv->kind == SCR_DYN_PROXY) {
|
|
729
|
+
ScrStr *key = scr_str_new(method, strlen(method));
|
|
730
|
+
ScrDyn *result = scr_dyn_proxy_get(recv, key);
|
|
731
|
+
scr_str_release(key);
|
|
732
|
+
return result;
|
|
733
|
+
}
|
|
734
|
+
return NULL;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
ScrDyn *scr_dyn_invoke_prepared(ScrDyn *recv, ScrDyn *callee, const char *method,
|
|
738
|
+
ScrDyn *const *args, size_t argc, const char *what) {
|
|
739
|
+
if (!callee) return scr_dyn_invoke(recv, method, args, argc, what);
|
|
740
|
+
scr_dyn_this_push_dyn(recv);
|
|
741
|
+
ScrDyn *result = scr_dyn_call(callee, args, argc, what);
|
|
742
|
+
scr_dyn_this_pop();
|
|
743
|
+
return result;
|
|
744
|
+
}
|
|
745
|
+
|
|
693
746
|
ScrDyn *scr_dyn_invoke(ScrDyn *recv, const char *method,
|
|
694
747
|
ScrDyn *const *args, size_t argc,
|
|
695
748
|
const char *what) {
|
|
@@ -767,15 +820,15 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
767
820
|
|
|
768
821
|
/* OBJ method calls follow the native prototype chain while binding the
|
|
769
822
|
* original receiver as `this`. */
|
|
770
|
-
if (recv->kind == SCR_DYN_OBJ) {
|
|
823
|
+
if (recv->kind == SCR_DYN_OBJ || recv->kind == SCR_DYN_PROXY) {
|
|
771
824
|
ScrDyn *m = scr_dyn_obj_read(recv, method, strlen(method));
|
|
772
|
-
if (m && (m
|
|
825
|
+
if (m && (scr_dyn_is_callable(m) ||
|
|
773
826
|
/* a WRAPPED engine function stored as a dyn member: the
|
|
774
827
|
* routed call (scr_dyn_call's JSVAL arm) runs it. */
|
|
775
828
|
(m->kind == SCR_DYN_JSVAL && scr_dyn_isl_typeof_is(m, "function")))) {
|
|
776
829
|
/* JS binds the receiver for the call (`obj.method()` — this === obj):
|
|
777
830
|
* the ambient-receiver window (scr_runtime.h). */
|
|
778
|
-
scr_dyn_this_push_dyn(recv);
|
|
831
|
+
scr_dyn_this_push_dyn(callback_recv ? callback_recv : recv);
|
|
779
832
|
ScrDyn *r = scr_dyn_call(m, args, argc, what);
|
|
780
833
|
scr_dyn_this_pop();
|
|
781
834
|
scr_dyn_release(m);
|
|
@@ -788,32 +841,8 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
788
841
|
|
|
789
842
|
if (recv->kind == SCR_DYN_FUNC) {
|
|
790
843
|
if (dyn_name_is(method, "apply")) {
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
* arguments)` forwards whatever receiver the wrapper ran under). */
|
|
794
|
-
const ScrDyn *thisv = argc >= 1 ? args[0] : scr_dyn_undefined();
|
|
795
|
-
ScrDyn *list = argc >= 2 ? args[1] : NULL;
|
|
796
|
-
if (list == NULL || list->kind == SCR_DYN_UNDEF || list->kind == SCR_DYN_NULL) {
|
|
797
|
-
scr_dyn_this_push_dyn(thisv);
|
|
798
|
-
ScrDyn *r = scr_dyn_call(recv, NULL, 0, what);
|
|
799
|
-
scr_dyn_this_pop();
|
|
800
|
-
return r;
|
|
801
|
-
}
|
|
802
|
-
ScrDyn *view = list->kind == SCR_DYN_TYPED_REF && scr_dyn_isl_is_array(list)
|
|
803
|
-
? scr_dyn_typed_ref_materialize(list) : NULL;
|
|
804
|
-
if (scr_exc_pending()) { scr_dyn_release(view); return NULL; }
|
|
805
|
-
if (view) list = view;
|
|
806
|
-
if (list->kind != SCR_DYN_ARR) {
|
|
807
|
-
scr_throw_error_msg(SCR_ERR_TYPE, "CreateListFromArrayLike called on non-object",
|
|
808
|
-
strlen("CreateListFromArrayLike called on non-object"));
|
|
809
|
-
scr_dyn_release(view);
|
|
810
|
-
return NULL;
|
|
811
|
-
}
|
|
812
|
-
scr_dyn_this_push_dyn(thisv);
|
|
813
|
-
ScrDyn *r = scr_dyn_call(recv, list->v.arr.items, list->v.arr.len, what);
|
|
814
|
-
scr_dyn_this_pop();
|
|
815
|
-
scr_dyn_release(view);
|
|
816
|
-
return r;
|
|
844
|
+
return scr_dyn_apply_array_like(recv, argc ? args[0] : scr_dyn_undefined(),
|
|
845
|
+
argc > 1 ? args[1] : scr_dyn_undefined(), what);
|
|
817
846
|
}
|
|
818
847
|
if (dyn_name_is(method, "call")) {
|
|
819
848
|
scr_dyn_this_push_dyn(argc >= 1 ? args[0] : scr_dyn_undefined());
|
|
@@ -823,6 +852,15 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
823
852
|
}
|
|
824
853
|
if (dyn_name_is(method, "bind")) return scr_dyn_bind(recv, args, argc);
|
|
825
854
|
if (dyn_name_is(method, "toString")) {
|
|
855
|
+
ScrDyn *member = scr_dyn_fn_get(recv, method, strlen(method));
|
|
856
|
+
if (member && member->kind != SCR_DYN_UNDEF) {
|
|
857
|
+
scr_dyn_this_push_dyn(recv);
|
|
858
|
+
ScrDyn *result = scr_dyn_call(member, args, argc, what);
|
|
859
|
+
scr_dyn_this_pop();
|
|
860
|
+
scr_dyn_release(member);
|
|
861
|
+
return result;
|
|
862
|
+
}
|
|
863
|
+
scr_dyn_release(member);
|
|
826
864
|
dyn_throw_unsupported("Function", method);
|
|
827
865
|
return NULL;
|
|
828
866
|
}
|
|
@@ -850,6 +888,26 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
850
888
|
if ((recv->kind == SCR_DYN_SYMBOL || recv->kind == SCR_DYN_BIGINT || recv->kind == SCR_DYN_NUM || recv->kind == SCR_DYN_BOOL || recv->kind == SCR_DYN_STR) &&
|
|
851
889
|
dyn_name_is(method, "valueOf")) return scr_dyn_retain(recv);
|
|
852
890
|
|
|
891
|
+
if (recv->kind == SCR_DYN_NUM && dyn_name_is(method, "toFixed")) {
|
|
892
|
+
double digits = dyn_index_arg(args, argc, 0, 0, what);
|
|
893
|
+
if (scr_exc_pending()) return NULL;
|
|
894
|
+
ScrStr *text = scr_num_to_fixed(recv->v.num, digits);
|
|
895
|
+
if (scr_exc_pending()) { scr_str_release(text); return NULL; }
|
|
896
|
+
ScrDyn *result = scr_dyn_new_str(text);
|
|
897
|
+
scr_str_release(text);
|
|
898
|
+
return result;
|
|
899
|
+
}
|
|
900
|
+
if (recv->kind == SCR_DYN_NUM && dyn_name_is(method, "toExponential")) {
|
|
901
|
+
if (argc && args[0]->kind != SCR_DYN_UNDEF) {
|
|
902
|
+
dyn_throw_unsupported("Number", method);
|
|
903
|
+
return NULL;
|
|
904
|
+
}
|
|
905
|
+
ScrStr *text = scr_num_to_exponential(recv->v.num);
|
|
906
|
+
ScrDyn *result = scr_dyn_new_str(text);
|
|
907
|
+
scr_str_release(text);
|
|
908
|
+
return result;
|
|
909
|
+
}
|
|
910
|
+
|
|
853
911
|
if (recv->kind == SCR_DYN_STR) {
|
|
854
912
|
ScrStr *s = recv->v.str;
|
|
855
913
|
if (dyn_name_is(method, "slice")) {
|
|
@@ -868,9 +926,11 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
868
926
|
if ((dyn_name_is(method, "indexOf") || dyn_name_is(method, "lastIndexOf") ||
|
|
869
927
|
dyn_name_is(method, "includes")) &&
|
|
870
928
|
argc >= 1 && args[0]->kind == SCR_DYN_STR) {
|
|
871
|
-
|
|
872
|
-
if (
|
|
873
|
-
return
|
|
929
|
+
double position = dyn_index_arg(args, argc, 1, dyn_name_is(method, "lastIndexOf") ? INFINITY : 0, what);
|
|
930
|
+
if (scr_exc_pending()) return NULL;
|
|
931
|
+
if (dyn_name_is(method, "includes")) return scr_dyn_new_bool(scr_str_index_of(s, args[0]->v.str, position) >= 0);
|
|
932
|
+
if (dyn_name_is(method, "indexOf")) return scr_dyn_new_num(scr_str_index_of(s, args[0]->v.str, position));
|
|
933
|
+
return scr_dyn_new_num(scr_str_last_index_of_from(s, args[0]->v.str, position));
|
|
874
934
|
}
|
|
875
935
|
dyn_throw_unsupported("String", method);
|
|
876
936
|
return NULL;
|
|
@@ -880,7 +940,32 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
880
940
|
}
|
|
881
941
|
|
|
882
942
|
if (recv->kind == SCR_DYN_ARR) {
|
|
943
|
+
if (dyn_name_is(method, "keys") || dyn_name_is(method, "values") || dyn_name_is(method, "entries"))
|
|
944
|
+
return scr_dyn_native_handle_iterator(callback_recv ? callback_recv : recv,
|
|
945
|
+
dyn_name_is(method, "keys") ? 1 : dyn_name_is(method, "entries") ? 2 : 0);
|
|
883
946
|
size_t len = recv->v.arr.len;
|
|
947
|
+
if (recv->v.arr.presence) {
|
|
948
|
+
bool sparse = false;
|
|
949
|
+
for (size_t i = 0; i < len; i++) if (!recv->v.arr.presence[i]) { sparse = true; break; }
|
|
950
|
+
if (!sparse) { free(recv->v.arr.presence); recv->v.arr.presence = NULL; }
|
|
951
|
+
else if (dyn_name_is(method, "forEach") || dyn_name_is(method, "map") || dyn_name_is(method, "filter") ||
|
|
952
|
+
dyn_name_is(method, "some") || dyn_name_is(method, "every") || dyn_name_is(method, "find") ||
|
|
953
|
+
dyn_name_is(method, "findIndex") || dyn_name_is(method, "findLast") || dyn_name_is(method, "findLastIndex") ||
|
|
954
|
+
dyn_name_is(method, "reduce") || dyn_name_is(method, "reduceRight") || dyn_name_is(method, "slice") ||
|
|
955
|
+
dyn_name_is(method, "indexOf") || dyn_name_is(method, "lastIndexOf") || dyn_name_is(method, "includes")) {
|
|
956
|
+
ScrDyn *pack = scr_dyn_new_arr();
|
|
957
|
+
for (size_t i = 0; i < argc; i++) scr_dyn_arr_push(pack, scr_dyn_retain(args[i]));
|
|
958
|
+
ScrStr *name = scr_str_new(method, strlen(method));
|
|
959
|
+
ScrDyn *result = scr_dyn_array_proto_call(callback_recv ? callback_recv : recv, name, pack);
|
|
960
|
+
scr_str_release(name);
|
|
961
|
+
scr_dyn_release(pack);
|
|
962
|
+
return result;
|
|
963
|
+
} else if (dyn_arr_proto_mutates(method) && !dyn_name_is(method, "fill") && !dyn_name_is(method, "push") && !dyn_name_is(method, "pop") && !dyn_name_is(method, "shift")) {
|
|
964
|
+
static const char message[] = "This checked array mutation over holes is not supported yet";
|
|
965
|
+
scr_throw_error_msg_code(SCR_ERR_ERROR, message, sizeof message - 1, "SC2020");
|
|
966
|
+
return NULL;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
884
969
|
size_t splice_start = 0;
|
|
885
970
|
size_t splice_removed = 0;
|
|
886
971
|
if (dyn_arr_proto_mutates(method)) {
|
|
@@ -944,7 +1029,10 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
944
1029
|
}
|
|
945
1030
|
if (dyn_name_is(method, "pop")) {
|
|
946
1031
|
if (len == 0) return scr_dyn_retain(scr_dyn_undefined());
|
|
947
|
-
|
|
1032
|
+
ScrDyn *result = scr_dyn_arr_at(recv, (double)(len - 1));
|
|
1033
|
+
if (!result) return NULL;
|
|
1034
|
+
scr_dyn_release(recv->v.arr.items[--recv->v.arr.len]);
|
|
1035
|
+
return result;
|
|
948
1036
|
}
|
|
949
1037
|
if (dyn_name_is(method, "shift")) {
|
|
950
1038
|
if (len == 0) return scr_dyn_retain(scr_dyn_undefined());
|
|
@@ -964,6 +1052,7 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
964
1052
|
}
|
|
965
1053
|
ScrDyn *first = recv->v.arr.items[0];
|
|
966
1054
|
memmove(recv->v.arr.items, recv->v.arr.items + 1, (len - 1) * sizeof(ScrDyn *));
|
|
1055
|
+
if (recv->v.arr.presence) memmove(recv->v.arr.presence, recv->v.arr.presence + 1, len - 1);
|
|
967
1056
|
recv->v.arr.len = len - 1;
|
|
968
1057
|
return first; /* ownership moves out */
|
|
969
1058
|
}
|
|
@@ -1022,7 +1111,7 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
1022
1111
|
if (!dyn_arr_length_unchanged(recv, len)) return NULL;
|
|
1023
1112
|
double idx = iD < 0 ? (double)len + iD : iD;
|
|
1024
1113
|
if (idx < 0 || idx >= (double)len) return scr_dyn_retain(scr_dyn_undefined());
|
|
1025
|
-
return
|
|
1114
|
+
return scr_dyn_arr_at(recv, idx);
|
|
1026
1115
|
}
|
|
1027
1116
|
if (dyn_name_is(method, "indexOf") || dyn_name_is(method, "lastIndexOf") ||
|
|
1028
1117
|
dyn_name_is(method, "includes")) {
|
|
@@ -1030,7 +1119,7 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
1030
1119
|
ScrDyn *needle = argc > 0 ? args[0] : scr_dyn_undefined();
|
|
1031
1120
|
double from = dyn_name_is(method, "lastIndexOf") ? (double)len - 1 : 0;
|
|
1032
1121
|
if (argc > 1) {
|
|
1033
|
-
from = dyn_index_arg(args, argc, 1,
|
|
1122
|
+
from = dyn_index_arg(args, argc, 1, 0, what);
|
|
1034
1123
|
if (scr_exc_pending()) return NULL;
|
|
1035
1124
|
}
|
|
1036
1125
|
if (!dyn_arr_length_unchanged(recv, len)) return NULL;
|
|
@@ -1080,15 +1169,19 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
1080
1169
|
if (dyn_name_is(method, "join")) {
|
|
1081
1170
|
ScrJsonBuf b;
|
|
1082
1171
|
scr_jb_init(&b);
|
|
1172
|
+
ScrStr *separator = argc > 0 && args[0]->kind != SCR_DYN_UNDEF
|
|
1173
|
+
? scr_dyn_string_coerce_js(args[0]) : scr_str_new(",", 1);
|
|
1174
|
+
if (!separator) { free(b.data); return NULL; }
|
|
1083
1175
|
for (size_t i = 0; i < len; i++) {
|
|
1084
|
-
if (i > 0)
|
|
1085
|
-
|
|
1086
|
-
|
|
1176
|
+
if (i > 0) for (size_t j = 0; j < separator->len; j++) scr_jb_putc(&b, separator->data[j]);
|
|
1177
|
+
ScrDyn *e = scr_dyn_arr_at(recv, (double)i);
|
|
1178
|
+
if (e) {
|
|
1179
|
+
if (e->kind != SCR_DYN_UNDEF && e->kind != SCR_DYN_NULL) scr_dyn_display_buf(&b, e);
|
|
1180
|
+
scr_dyn_release(e);
|
|
1087
1181
|
}
|
|
1088
|
-
|
|
1089
|
-
if (e->kind == SCR_DYN_UNDEF || e->kind == SCR_DYN_NULL) continue;
|
|
1090
|
-
scr_dyn_display_buf(&b, e);
|
|
1182
|
+
if (!e || scr_exc_pending()) { scr_str_release(separator); free(b.data); return NULL; }
|
|
1091
1183
|
}
|
|
1184
|
+
scr_str_release(separator);
|
|
1092
1185
|
ScrStr *joined = scr_jb_finish(&b);
|
|
1093
1186
|
ScrDyn *r = scr_dyn_new_str(joined); /* retains */
|
|
1094
1187
|
scr_str_release(joined);
|
|
@@ -1096,7 +1189,9 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
1096
1189
|
}
|
|
1097
1190
|
if (dyn_name_is(method, "concat")) {
|
|
1098
1191
|
ScrDyn *out = scr_dyn_new_arr();
|
|
1099
|
-
for (size_t i = 0; i < len; i++)
|
|
1192
|
+
for (size_t i = 0; i < len; i++) {
|
|
1193
|
+
if (!dyn_arr_copy_item(out, recv, i, true)) { scr_dyn_release(out); return NULL; }
|
|
1194
|
+
}
|
|
1100
1195
|
for (size_t a = 0; a < argc; a++) {
|
|
1101
1196
|
ScrDyn *view = args[a]->kind == SCR_DYN_TYPED_REF && scr_dyn_isl_is_array(args[a])
|
|
1102
1197
|
? scr_dyn_typed_ref_materialize(args[a]) : NULL;
|
|
@@ -1104,7 +1199,7 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
1104
1199
|
const ScrDyn *source = view ? view : args[a];
|
|
1105
1200
|
if (source->kind == SCR_DYN_ARR) {
|
|
1106
1201
|
for (size_t i = 0; i < source->v.arr.len; i++) {
|
|
1107
|
-
|
|
1202
|
+
if (!dyn_arr_copy_item(out, source, i, true)) { scr_dyn_release(view); scr_dyn_release(out); return NULL; }
|
|
1108
1203
|
}
|
|
1109
1204
|
} else {
|
|
1110
1205
|
scr_dyn_arr_push(out, scr_dyn_retain(args[a]));
|
|
@@ -1135,7 +1230,7 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
1135
1230
|
}
|
|
1136
1231
|
if (dyn_name_is(method, "toReversed")) {
|
|
1137
1232
|
ScrDyn *out = scr_dyn_new_arr();
|
|
1138
|
-
dyn_arr_reversed_copy(out, recv);
|
|
1233
|
+
if (!dyn_arr_reversed_copy(out, recv)) { scr_dyn_release(out); return NULL; }
|
|
1139
1234
|
return out;
|
|
1140
1235
|
}
|
|
1141
1236
|
if (dyn_name_is(method, "with")) {
|
|
@@ -1150,15 +1245,17 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
1150
1245
|
}
|
|
1151
1246
|
ScrDyn *replacement = argc > 1 ? args[1] : scr_dyn_undefined();
|
|
1152
1247
|
ScrDyn *out = scr_dyn_new_arr();
|
|
1153
|
-
for (size_t i = 0; i < len; i++)
|
|
1154
|
-
|
|
1248
|
+
for (size_t i = 0; i < len; i++) {
|
|
1249
|
+
if ((size_t)index == i) scr_dyn_arr_push(out, scr_dyn_retain(replacement));
|
|
1250
|
+
else if (!dyn_arr_copy_item(out, recv, i, false)) { scr_dyn_release(out); return NULL; }
|
|
1251
|
+
}
|
|
1155
1252
|
return out;
|
|
1156
1253
|
}
|
|
1157
1254
|
if (dyn_name_is(method, "toSpliced")) {
|
|
1158
1255
|
double startD = dyn_index_arg(args, argc, 0, 0, what);
|
|
1159
1256
|
if (scr_exc_pending()) return NULL;
|
|
1160
1257
|
size_t start = dyn_rel_index(startD, len);
|
|
1161
|
-
size_t delete_count = len - start;
|
|
1258
|
+
size_t delete_count = argc == 0 ? 0 : len - start;
|
|
1162
1259
|
if (argc > 1) {
|
|
1163
1260
|
double countD = dyn_index_arg(args, argc, 1, 0, what);
|
|
1164
1261
|
if (scr_exc_pending()) return NULL;
|
|
@@ -1166,9 +1263,9 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
1166
1263
|
}
|
|
1167
1264
|
if (!dyn_arr_length_unchanged(recv, len)) return NULL;
|
|
1168
1265
|
ScrDyn *out = scr_dyn_new_arr();
|
|
1169
|
-
for (size_t i = 0; i < start; i++)
|
|
1266
|
+
for (size_t i = 0; i < start; i++) if (!dyn_arr_copy_item(out, recv, i, false)) { scr_dyn_release(out); return NULL; }
|
|
1170
1267
|
for (size_t i = 2; i < argc; i++) scr_dyn_arr_push(out, scr_dyn_retain(args[i]));
|
|
1171
|
-
for (size_t i = start + delete_count; i < len; i++)
|
|
1268
|
+
for (size_t i = start + delete_count; i < len; i++) if (!dyn_arr_copy_item(out, recv, i, false)) { scr_dyn_release(out); return NULL; }
|
|
1172
1269
|
return out;
|
|
1173
1270
|
}
|
|
1174
1271
|
if (dyn_name_is(method, "fill")) {
|
|
@@ -1186,8 +1283,14 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
1186
1283
|
}
|
|
1187
1284
|
ScrDyn *fill = argc ? args[0] : scr_dyn_undefined();
|
|
1188
1285
|
for (size_t i = start; i < end; i++) {
|
|
1286
|
+
if (recv->non_extensible && !scr_dyn_arr_has_index(recv, i)) {
|
|
1287
|
+
static const char message[] = "Cannot add property, object is not extensible";
|
|
1288
|
+
scr_throw_error_msg(SCR_ERR_TYPE, message, sizeof message - 1);
|
|
1289
|
+
return NULL;
|
|
1290
|
+
}
|
|
1189
1291
|
ScrDyn *old = recv->v.arr.items[i];
|
|
1190
1292
|
recv->v.arr.items[i] = scr_dyn_retain(fill);
|
|
1293
|
+
if (recv->v.arr.presence) recv->v.arr.presence[i] = 1;
|
|
1191
1294
|
scr_dyn_release(old);
|
|
1192
1295
|
}
|
|
1193
1296
|
return scr_dyn_retain(recv);
|
|
@@ -1304,14 +1407,23 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
1304
1407
|
ScrDyn *out = scr_dyn_new_arr();
|
|
1305
1408
|
size_t n = recv->v.arr.len;
|
|
1306
1409
|
for (size_t i = 0; i < n && i < recv->v.arr.len; i++) {
|
|
1307
|
-
|
|
1410
|
+
if (!dyn_borrow_present(recv, i)) { if (scr_exc_pending()) { scr_dyn_release(out); return NULL; } continue; }
|
|
1411
|
+
ScrDyn *item = dyn_borrow_item(recv, i);
|
|
1412
|
+
if (!item) { scr_dyn_release(out); return NULL; }
|
|
1308
1413
|
ScrDyn *r = dyn_call_cb(
|
|
1309
1414
|
cb, item, i, callback_recv ? callback_recv : recv);
|
|
1310
1415
|
scr_dyn_release(item);
|
|
1311
1416
|
if (!r) { scr_dyn_release(out); return NULL; }
|
|
1417
|
+
if (r->kind == SCR_DYN_TYPED_REF && scr_dyn_isl_is_array(r)) {
|
|
1418
|
+
ScrDyn *view = scr_dyn_typed_ref_materialize(r);
|
|
1419
|
+
scr_dyn_release(r);
|
|
1420
|
+
r = view;
|
|
1421
|
+
if (!r) { scr_dyn_release(out); return NULL; }
|
|
1422
|
+
}
|
|
1312
1423
|
if (r->kind == SCR_DYN_ARR) {
|
|
1313
1424
|
for (size_t j = 0; j < r->v.arr.len; j++) {
|
|
1314
|
-
scr_dyn_arr_push(out,
|
|
1425
|
+
if (dyn_borrow_present(r, j)) scr_dyn_arr_push(out, dyn_borrow_item(r, j));
|
|
1426
|
+
if (scr_exc_pending()) { scr_dyn_release(r); scr_dyn_release(out); return NULL; }
|
|
1315
1427
|
}
|
|
1316
1428
|
scr_dyn_release(r);
|
|
1317
1429
|
} else if (scr_dyn_isl_is_array(r)) {
|
|
@@ -1361,7 +1473,7 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
1361
1473
|
return NULL;
|
|
1362
1474
|
}
|
|
1363
1475
|
ScrDyn *out = scr_dyn_new_arr();
|
|
1364
|
-
for (size_t i = 0; i < len; i++)
|
|
1476
|
+
for (size_t i = 0; i < len; i++) if (!dyn_arr_copy_item(out, recv, i, false)) { scr_dyn_release(out); return NULL; }
|
|
1365
1477
|
if (len > 1 && !dyn_arr_sort(out, cmp->kind == SCR_DYN_FUNC ? cmp : NULL)) {
|
|
1366
1478
|
scr_dyn_release(out);
|
|
1367
1479
|
return NULL;
|
|
@@ -1401,6 +1513,47 @@ static ScrDyn *scr_dyn_invoke_impl(
|
|
|
1401
1513
|
|
|
1402
1514
|
if (recv->kind == SCR_DYN_BYTES) {
|
|
1403
1515
|
ScrBytes *bytes = recv->v.bytes;
|
|
1516
|
+
if (bytes->is_data_view) {
|
|
1517
|
+
static const char *const kinds[] = { "Uint8", "Int8", "Uint16", "Int16", "Uint32", "Int32", "Float32", "Float64", "BigUint64", "BigInt64" };
|
|
1518
|
+
const bool get = !strncmp(method, "get", 3);
|
|
1519
|
+
const bool set = !strncmp(method, "set", 3);
|
|
1520
|
+
for (size_t kind = 0; (get || set) && kind < sizeof kinds / sizeof kinds[0]; kind++) {
|
|
1521
|
+
if (strcmp(method + 3, kinds[kind])) continue;
|
|
1522
|
+
double offset = 0;
|
|
1523
|
+
if (argc && !scr_dyn_number_coerce_js(args[0], &offset)) return NULL;
|
|
1524
|
+
/* ToIndex precedes value coercion; the view bounds check follows
|
|
1525
|
+
* it. Keep these stages distinct for observable valueOf calls. */
|
|
1526
|
+
offset = isnan(offset) ? 0 : trunc(offset);
|
|
1527
|
+
if (!(offset >= 0) || offset > 9007199254740991.0) {
|
|
1528
|
+
static const char message[] = "Offset is outside the bounds of the DataView";
|
|
1529
|
+
scr_throw_error_msg(SCR_ERR_RANGE, message, sizeof message - 1);
|
|
1530
|
+
return NULL;
|
|
1531
|
+
}
|
|
1532
|
+
const bool le = argc > (get ? 1 : 2) && scr_dyn_truthy(args[get ? 1 : 2]);
|
|
1533
|
+
if (get) {
|
|
1534
|
+
if (kind >= SCR_DV_BIGU64) {
|
|
1535
|
+
ScrBigInt *value = scr_bigint_dataview_get(bytes, offset, kind == SCR_DV_BIGI64, le);
|
|
1536
|
+
if (scr_exc_pending()) return NULL;
|
|
1537
|
+
ScrDyn *result = scr_dyn_new_bigint(value);
|
|
1538
|
+
scr_bigint_release(value);
|
|
1539
|
+
return result;
|
|
1540
|
+
}
|
|
1541
|
+
double value = scr_dataview_get(bytes, offset, (ScrDataViewGet)kind, le);
|
|
1542
|
+
return scr_exc_pending() ? NULL : scr_dyn_new_num(value);
|
|
1543
|
+
}
|
|
1544
|
+
if (kind >= SCR_DV_BIGU64) {
|
|
1545
|
+
ScrBigInt *value = scr_dyn_bigint_coerce(argc > 1 ? args[1] : scr_dyn_undefined());
|
|
1546
|
+
if (scr_exc_pending()) return NULL;
|
|
1547
|
+
scr_bigint_dataview_set(bytes, offset, value, le);
|
|
1548
|
+
scr_bigint_release(value);
|
|
1549
|
+
} else {
|
|
1550
|
+
double value;
|
|
1551
|
+
if (!scr_dyn_number_coerce_js(argc > 1 ? args[1] : scr_dyn_undefined(), &value)) return NULL;
|
|
1552
|
+
scr_dataview_set(bytes, offset, value, (ScrDataViewGet)kind, le);
|
|
1553
|
+
}
|
|
1554
|
+
return scr_exc_pending() ? NULL : scr_dyn_retain(scr_dyn_undefined());
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1404
1557
|
size_t blen = bytes->len;
|
|
1405
1558
|
if (dyn_name_is(method, "at")) {
|
|
1406
1559
|
double iD = dyn_bytes_index_arg(args, argc, 0, 0);
|
|
@@ -1487,6 +1640,107 @@ static ScrDyn *dyn_array_method_value_call(ScrClosure *closure, ScrDyn *const *a
|
|
|
1487
1640
|
return result;
|
|
1488
1641
|
}
|
|
1489
1642
|
|
|
1643
|
+
static SCR_TL ScrDyn *dyn_builtin_methods;
|
|
1644
|
+
|
|
1645
|
+
static void dyn_builtin_methods_cleanup(void) {
|
|
1646
|
+
scr_dyn_release(dyn_builtin_methods);
|
|
1647
|
+
dyn_builtin_methods = NULL;
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
static ScrDyn *dyn_builtin_method_call(ScrClosure *closure, ScrDyn *const *args, size_t argc) {
|
|
1651
|
+
ScrStr *prototype = scr_box_get_ref(closure->caps[0]);
|
|
1652
|
+
ScrStr *method = scr_box_get_ref(closure->caps[1]);
|
|
1653
|
+
ScrDyn *receiver = scr_dyn_this_get();
|
|
1654
|
+
ScrDyn *result = NULL;
|
|
1655
|
+
if (!strcmp(prototype->data, "Object")) {
|
|
1656
|
+
ScrDyn *key = argc ? args[0] : scr_dyn_undefined();
|
|
1657
|
+
if (!strcmp(method->data, "toString")) {
|
|
1658
|
+
ScrStr *tag = scr_dyn_object_tag(receiver);
|
|
1659
|
+
if (tag) { result = scr_dyn_new_str(tag); scr_str_release(tag); }
|
|
1660
|
+
} else if (!strcmp(method->data, "hasOwnProperty")) {
|
|
1661
|
+
bool own = scr_dyn_has_own_computed(receiver, key);
|
|
1662
|
+
if (!scr_exc_pending()) result = scr_dyn_new_bool(own);
|
|
1663
|
+
} else if (!strcmp(method->data, "propertyIsEnumerable")) {
|
|
1664
|
+
bool enumerable = scr_dyn_property_is_enumerable_computed(receiver, key);
|
|
1665
|
+
if (!scr_exc_pending()) result = scr_dyn_new_bool(enumerable);
|
|
1666
|
+
} else if (receiver->kind == SCR_DYN_NULL || receiver->kind == SCR_DYN_UNDEF) {
|
|
1667
|
+
static const char message[] = "Cannot convert undefined or null to object";
|
|
1668
|
+
scr_throw_error_msg(SCR_ERR_TYPE, message, sizeof message - 1);
|
|
1669
|
+
} else if (receiver->kind == SCR_DYN_OBJ || receiver->kind == SCR_DYN_ARR ||
|
|
1670
|
+
receiver->kind == SCR_DYN_FUNC || receiver->kind == SCR_DYN_HANDLE ||
|
|
1671
|
+
receiver->kind == SCR_DYN_TYPED_REF || receiver->kind == SCR_DYN_PROXY) result = scr_dyn_retain(receiver);
|
|
1672
|
+
else dyn_throw_unsupported("Object", method->data);
|
|
1673
|
+
} else {
|
|
1674
|
+
bool compatible = false;
|
|
1675
|
+
if (!strcmp(prototype->data, "String")) compatible = receiver->kind != SCR_DYN_UNDEF && receiver->kind != SCR_DYN_NULL;
|
|
1676
|
+
else if (!strcmp(prototype->data, "Number")) compatible = receiver->kind == SCR_DYN_NUM;
|
|
1677
|
+
else if (receiver->kind == SCR_DYN_HANDLE) {
|
|
1678
|
+
const ScrDynHandleOps *ops = scr_dyn_handle_ops_of(receiver);
|
|
1679
|
+
compatible = !strcmp(ops->cls, prototype->data);
|
|
1680
|
+
}
|
|
1681
|
+
if (!compatible) {
|
|
1682
|
+
static const char message[] = "Builtin prototype method called on incompatible receiver";
|
|
1683
|
+
scr_throw_error_msg(SCR_ERR_TYPE, message, sizeof message - 1);
|
|
1684
|
+
} else if (!strcmp(method->data, "toString") && receiver->kind == SCR_DYN_NUM) {
|
|
1685
|
+
ScrStr *value = scr_dyn_to_string_argument(receiver, argc ? args[0] : scr_dyn_undefined(), method);
|
|
1686
|
+
if (value) { result = scr_dyn_new_str(value); scr_str_release(value); }
|
|
1687
|
+
} else if (!strcmp(prototype->data, "String")) {
|
|
1688
|
+
bool strict = !strcmp(method->data, "toString") || !strcmp(method->data, "valueOf");
|
|
1689
|
+
if (strict && receiver->kind != SCR_DYN_STR) {
|
|
1690
|
+
static const char message[] = "String.prototype method requires a string receiver";
|
|
1691
|
+
scr_throw_error_msg(SCR_ERR_TYPE, message, sizeof message - 1);
|
|
1692
|
+
} else if (strict) result = scr_dyn_retain(receiver);
|
|
1693
|
+
else {
|
|
1694
|
+
ScrStr *text = scr_dyn_string_coerce_js(receiver);
|
|
1695
|
+
if (text) {
|
|
1696
|
+
ScrDyn *string = scr_dyn_new_str(text);
|
|
1697
|
+
scr_str_release(text);
|
|
1698
|
+
if (!strcmp(method->data, "slice")) result = scr_dyn_invoke(string, method->data, args, argc, method->data);
|
|
1699
|
+
else dyn_throw_unsupported("String", method->data);
|
|
1700
|
+
scr_dyn_release(string);
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
} else result = scr_dyn_invoke(receiver, method->data, args, argc, method->data);
|
|
1704
|
+
}
|
|
1705
|
+
scr_dyn_release(receiver);
|
|
1706
|
+
scr_str_release(prototype);
|
|
1707
|
+
scr_str_release(method);
|
|
1708
|
+
return result;
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
ScrDyn *scr_dyn_builtin_method(const ScrStr *prototype, const ScrStr *method) {
|
|
1712
|
+
if (!dyn_builtin_methods) {
|
|
1713
|
+
dyn_builtin_methods = scr_dyn_new_obj_null_proto();
|
|
1714
|
+
scr_atexit(dyn_builtin_methods_cleanup);
|
|
1715
|
+
}
|
|
1716
|
+
ScrJsonBuf buffer;
|
|
1717
|
+
scr_jb_init(&buffer);
|
|
1718
|
+
scr_jb_puts(&buffer, prototype->data);
|
|
1719
|
+
scr_jb_putc(&buffer, '.');
|
|
1720
|
+
scr_jb_puts(&buffer, method->data);
|
|
1721
|
+
ScrStr *key = scr_jb_finish(&buffer);
|
|
1722
|
+
ScrDyn *value = scr_dyn_obj_get(dyn_builtin_methods, key->data, key->len);
|
|
1723
|
+
if (!value) {
|
|
1724
|
+
ScrClosure *closure = scr_closure_new(NULL, 2);
|
|
1725
|
+
closure->caps[0] = scr_box_new(SCR_BOX_STR);
|
|
1726
|
+
closure->caps[1] = scr_box_new(SCR_BOX_STR);
|
|
1727
|
+
scr_box_set_ref(closure->caps[0], scr_str_retain((ScrStr *)prototype));
|
|
1728
|
+
scr_box_set_ref(closure->caps[1], scr_str_retain((ScrStr *)method));
|
|
1729
|
+
size_t arity = (!strcmp(method->data, "set") || !strcmp(method->data, "substring") ||
|
|
1730
|
+
!strcmp(method->data, "slice") ||
|
|
1731
|
+
!strcmp(method->data, "replace") || !strcmp(method->data, "split")) ? 2 :
|
|
1732
|
+
(!strcmp(method->data, "get") || !strcmp(method->data, "add") || !strcmp(method->data, "has") ||
|
|
1733
|
+
!strcmp(method->data, "delete") || !strcmp(method->data, "forEach") || !strcmp(method->data, "startsWith") ||
|
|
1734
|
+
!strcmp(method->data, "endsWith") || !strcmp(method->data, "padStart") || !strcmp(method->data, "toJSON") ||
|
|
1735
|
+
!strcmp(method->data, "charCodeAt") || !strcmp(method->data, "hasOwnProperty") ||
|
|
1736
|
+
!strcmp(method->data, "propertyIsEnumerable") || (!strcmp(prototype->data, "Number") && !strcmp(method->data, "toString"))) ? 1 : 0;
|
|
1737
|
+
value = scr_dyn_new_func(closure, dyn_builtin_method_call, arity, "native:prototype", method->data);
|
|
1738
|
+
scr_dyn_obj_set(dyn_builtin_methods, key->data, key->len, value);
|
|
1739
|
+
}
|
|
1740
|
+
scr_str_release(key);
|
|
1741
|
+
return scr_dyn_retain(value);
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1490
1744
|
ScrDyn *scr_dyn_array_prototype(void) {
|
|
1491
1745
|
static SCR_TL bool initialized;
|
|
1492
1746
|
ScrDyn *prototype = scr_dyn_array_prototype_base();
|
|
@@ -1527,7 +1781,7 @@ ScrDyn *scr_dyn_array_prototype(void) {
|
|
|
1527
1781
|
}
|
|
1528
1782
|
|
|
1529
1783
|
/* Object.defineProperties over dyn values (see scr_runtime.h). */
|
|
1530
|
-
ScrDyn *
|
|
1784
|
+
static ScrDyn *scr_dyn_define_props_internal(ScrDyn *target, ScrDyn *descs, ScrDyn *protected_keys) {
|
|
1531
1785
|
/* Island-held operands ARE objects to Node — the non-object TypeError
|
|
1532
1786
|
* below would be a wrong claim. Loud fence (lane dyn-routing-ops). */
|
|
1533
1787
|
scr_dyn_isl_fence(target, "Object.defineProperties");
|
|
@@ -1600,6 +1854,15 @@ ScrDyn *scr_dyn_define_props(ScrDyn *target, ScrDyn *descs) {
|
|
|
1600
1854
|
ScrDyn *pair = pending->v.arr.items[i];
|
|
1601
1855
|
ScrDyn *key = pair->v.arr.items[0];
|
|
1602
1856
|
ScrDyn *descriptor = pair->v.arr.items[1];
|
|
1857
|
+
if (protected_keys) {
|
|
1858
|
+
for (size_t k = 0; k < protected_keys->v.arr.len; k++) {
|
|
1859
|
+
if (!scr_dyn_strict_eq(key, protected_keys->v.arr.items[k])) continue;
|
|
1860
|
+
static const char message[] = "Replacing compiled class prototype members has no native lowering [SC1090]";
|
|
1861
|
+
scr_throw_error_msg(SCR_ERR_ERROR, message, sizeof message - 1);
|
|
1862
|
+
scr_dyn_release(pending);
|
|
1863
|
+
return NULL;
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1603
1866
|
ScrDyn *defined = scr_dyn_define_property(target, key, descriptor);
|
|
1604
1867
|
if (!defined) {
|
|
1605
1868
|
scr_dyn_release(pending);
|
|
@@ -1615,6 +1878,14 @@ fail:
|
|
|
1615
1878
|
return NULL;
|
|
1616
1879
|
}
|
|
1617
1880
|
|
|
1881
|
+
ScrDyn *scr_dyn_define_props(ScrDyn *target, ScrDyn *descs) {
|
|
1882
|
+
return scr_dyn_define_props_internal(target, descs, NULL);
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
ScrDyn *scr_dyn_define_prototype_props(ScrDyn *target, ScrDyn *descs, ScrDyn *protected_keys) {
|
|
1886
|
+
return scr_dyn_define_props_internal(target, descs, protected_keys);
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1618
1889
|
ScrDyn *scr_dyn_obj_create_with_properties(ScrDyn *prototype, ScrDyn *descriptors) {
|
|
1619
1890
|
ScrDyn *object = scr_dyn_obj_create(prototype);
|
|
1620
1891
|
if (!object) return NULL;
|