Compare commits
413 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8ba0d1b6ee | |||
| d646cf51ee | |||
| bf7fa39581 | |||
| 3e548401fd | |||
| d97540e883 | |||
| cb85797ab5 | |||
| 8e83638daa | |||
| 6ec4455111 | |||
| 1d42d17ab6 | |||
| b313824228 | |||
| 2ade072e53 | |||
| 3b77117a2e | |||
| e00964176d | |||
| 0fec9135ec | |||
| ef8a6a9f39 | |||
| c4676a21fe | |||
| 79a2392b79 | |||
| 90d206dcee | |||
| f894a8fad5 | |||
| ccf511a544 | |||
| 69ce755593 | |||
| 9bc0f2fd3f | |||
| 11894a6032 | |||
| f2e9062cfc | |||
| 2bad20abf8 | |||
| 1fe7c3531a | |||
| abaf9637d7 | |||
| 3ce4dce805 | |||
| fe3b0a8435 | |||
| fd0ca7da69 | |||
| 5e483633f3 | |||
| abedab5ac2 | |||
| ad7fc07ca4 | |||
| b0ca537a34 | |||
| 9ce7e49073 | |||
| aefd381cf1 | |||
| 91baa17c51 | |||
| b46535cb8d | |||
| 363bc92529 | |||
| df6d430289 | |||
| 4541524256 | |||
| 75586242ba | |||
| 3dc6ed0dd5 | |||
| c84afefd47 | |||
| 3193e6d0dc | |||
| c46f4c3e40 | |||
| 053fe4b331 | |||
| 6f0391dd66 | |||
| 4399744588 | |||
| 5cef002ed6 | |||
| 8ddd24f870 | |||
| 2919a6463f | |||
| fdaacde667 | |||
| dcf9252892 | |||
| edb01f63d5 | |||
| 4c41f8ee07 | |||
| daba2b76fc | |||
| 99ec5b9bab | |||
| b7b2e0360e | |||
| 7b00db4079 | |||
| 4350401b5b | |||
| 29785b2af3 | |||
| 0e829cc41a | |||
| f50728ef8d | |||
| b56fa43aa3 | |||
| 238f9aab4a | |||
| d161e2d9ed | |||
| 0a3aa0f48b | |||
| 979a0c7826 | |||
| 7972386412 | |||
| 6dfd02a08c | |||
| fc701aef6d | |||
| 61d172aaaf | |||
| 128f18a225 | |||
| 7baaafa405 | |||
| cab266f21d | |||
| 2ac3c08c14 | |||
| 6279670484 | |||
| 257814d063 | |||
| 5962562e2d | |||
| 2faafa4cfc | |||
| 68b47f5f30 | |||
| 83f9c38ed1 | |||
| 9676500add | |||
| 1937f820e1 | |||
| e2be8f4c79 | |||
| 6083259030 | |||
| 035e5a27fa | |||
| fe216d4710 | |||
| 9380d93416 | |||
| 0b72150190 | |||
| 29be24f056 | |||
| fe29bf7390 | |||
| 7e135b04ed | |||
| cc1e8d2dee | |||
| df92c86ecf | |||
| 7cb9f808f7 | |||
| 1cb18f0ca6 | |||
| 89ff0fcf1f | |||
| de37e1e049 | |||
| c0fc67f5bd | |||
| 577a605ead | |||
| 290e845759 | |||
| 5bd88e2723 | |||
| 8eda7cb7d8 | |||
| 19011258d8 | |||
| 3af3597f2e | |||
| cc52282f34 | |||
| cbc3a5d291 | |||
| d2c523b2c0 | |||
| 7de7c2168e | |||
| 5d916fb8d4 | |||
| 7262b98021 | |||
| 65db83561f | |||
| fab35c3f93 | |||
| f7b7873a02 | |||
| 1237bef0f0 | |||
| 640a7d33b3 | |||
| 81702ff5ea | |||
| c57938e0c7 | |||
| 32674f9733 | |||
| 40004da163 | |||
| 25bb5083be | |||
| b2084e0a02 | |||
| d0e385f9eb | |||
| 11f7463986 | |||
| 3bad85b83b | |||
| b7ca097436 | |||
| e681adce05 | |||
| 72c92d6b36 | |||
| c7986fd2c5 | |||
| 484e999dec | |||
| 3115d4dc16 | |||
| 2007188373 | |||
| 24a5489331 | |||
| d5d27afd39 | |||
| 49c633210a | |||
| 91e0cfc767 | |||
| a65988798c | |||
| f303017542 | |||
| 8a0a86e3c7 | |||
| 6f25d6ed31 | |||
| 3c9a7915e1 | |||
| 870dbff1c7 | |||
| 23e9e773e0 | |||
| 01c0ca3b6c | |||
| f384642409 | |||
| 9da1211e26 | |||
| 080abb94ca | |||
| d8955552d7 | |||
| 841d536fce | |||
| 650269feca | |||
| f6cf1400bd | |||
| 2a8f1dcbc3 | |||
| 3c2a3f5dd9 | |||
| d317124650 | |||
| da1a4bbd44 | |||
| d1f73752ff | |||
| 596964ae0d | |||
| e3481d431b | |||
| 5b9a6deb93 | |||
| 4df833e7ad | |||
| c905c21abb | |||
| 148f69f4a5 | |||
| 99c7099eaa | |||
| 17fe441819 | |||
| 53a085cd28 | |||
| 17c8ec57bb | |||
| fb1c21beb7 | |||
| a084fdbe45 | |||
| 8edf8d6eea | |||
| 37d6b13891 | |||
| 7458766033 | |||
| 261a55c6b5 | |||
| 8fe3891b15 | |||
| e227634b45 | |||
| aa89d38df3 | |||
| b9e4897c71 | |||
| 69d9b2c326 | |||
| 4b2dbd5c21 | |||
| 0ffe1665bd | |||
| f97c0134d7 | |||
| 9f93b0a8ee | |||
| 75385a6045 | |||
| 32de38198a | |||
| c4388e2c19 | |||
| f58f15077f | |||
| de38764e88 | |||
| bc64957d19 | |||
| e478640d80 | |||
| 0745feb670 | |||
| 629a0e51c4 | |||
| 43e03a1ac6 | |||
| 3b7409f3a7 | |||
| be180ba159 | |||
| 3c723c9bc1 | |||
| 4d135bec5d | |||
| 55554535b2 | |||
| 74f66879c2 | |||
| f4af997935 | |||
| 1be9573925 | |||
| da2299d277 | |||
| d9653823ca | |||
| 7345c83af7 | |||
| f8983cd2b5 | |||
| f834340608 | |||
| c013fade26 | |||
| 9bffc981cd | |||
| 6f29e48fc6 | |||
| 861bb82749 | |||
| 2bc3111e31 | |||
| f03bf9074f | |||
| 074945dafa | |||
| ed63665901 | |||
| 1fd0cac8c9 | |||
| 2f08d8ac08 | |||
| 28c186c98f | |||
| cd1c06510e | |||
| 9589771f7a | |||
| e98f5342f9 | |||
| 6d0e948bef | |||
| 4ed9e2c033 | |||
| a470fef8a5 | |||
| 2aa5f136a4 | |||
| 1ec216e573 | |||
| 777b7e9c87 | |||
| a6cd19fa6e | |||
| 24753ddd70 | |||
| 59ab36088f | |||
| 138151832a | |||
| 09c8d28b2c | |||
| 85981457e6 | |||
| 55b6b1aed7 | |||
| 1bcfb711a3 | |||
| f2ff0d082f | |||
| 84bc1e03fb | |||
| 5b3f01af9d | |||
| b828d1c15f | |||
| d9cb2c60f2 | |||
| 086d1cc127 | |||
| 9d586fea76 | |||
| 8964a2bd18 | |||
| 409ead7415 | |||
| ea07052869 | |||
| 5ce95be174 | |||
| 79540727ab | |||
| cd34bfa4c3 | |||
| 0bb4626ddb | |||
| 6adf0c1a87 | |||
| 0c154306a8 | |||
| f761427a3e | |||
| 286e515f9f | |||
| 39fe04814e | |||
| 43a82cddb9 | |||
| cebb6aee5c | |||
| 58a649ffe8 | |||
| f4f9cde3e7 | |||
| cb14682983 | |||
| 082085a8fd | |||
| 25117ad56b | |||
| 3d44b26aeb | |||
| 531f724926 | |||
| 7d479ad91b | |||
| c76736eadf | |||
| b82bd76175 | |||
| 019dd03fcc | |||
| 621a5ddb8f | |||
| 401b36d406 | |||
| bdb39f1f03 | |||
| b749c4c267 | |||
| 945b22976a | |||
| b5a96c9eca | |||
| be9dbeffdb | |||
| 4ce4b617fd | |||
| e9b794f629 | |||
| cfd69d3b70 | |||
| f1eba9f826 | |||
| 26a299adf0 | |||
| 84125275ea | |||
| 611c8827ba | |||
| 40ad8c6e45 | |||
| 26c1ffaf71 | |||
| b4a4619a6c | |||
| b27f40303b | |||
| a4312d614f | |||
| df2f7782f7 | |||
| 3eb69075f7 | |||
| 56e328be41 | |||
| 2832bdc94d | |||
| dff2a2a6da | |||
| 51aee962a4 | |||
| dbea5e6a22 | |||
| 2e2b0dafb0 | |||
| 4d5757d1b1 | |||
| edab1964c2 | |||
| 20f83d963b | |||
| 7e0b478fe9 | |||
| d420811a0e | |||
| 9872c441e3 | |||
| 227007eda7 | |||
| 435c9cadcf | |||
| 9a026f54ac | |||
| daa409a09a | |||
| 39e2bc4df4 | |||
| ff36f3579d | |||
| ff47c84bc4 | |||
| 3f0f9589c4 | |||
| 11c2ae30d1 | |||
| da5b058dec | |||
| d39a076b2e | |||
| cf097ca16b | |||
| 54bfd2ba37 | |||
| 539928dbdb | |||
| 2f2a4e066c | |||
| f596211553 | |||
| fdb5d893bf | |||
| d92d9db40f | |||
| a4952da831 | |||
| 0124368ae7 | |||
| 04f0a7a670 | |||
| 1eef69f24d | |||
| 69f6bc6566 | |||
| 12ee41602e | |||
| 2fac7cc85e | |||
| fee3c295a2 | |||
| 39cb67397d | |||
| 321215fdbb | |||
| 33359ac506 | |||
| b162e27418 | |||
| e8c5c46894 | |||
| 74781c28c2 | |||
| c2bfdde806 | |||
| f6cde17bfb | |||
| b7fa4afb66 | |||
| dfd9d4497a | |||
| f60e16d9d5 | |||
| 604cfaced4 | |||
| c8d15ddbf7 | |||
| 8fdbc6a85b | |||
| 9dbbcab49d | |||
| 870a3d3ffb | |||
| 37906baa25 | |||
| dfabfe7a56 | |||
| b90fa63255 | |||
| 35e1e98008 | |||
| ae5cfae3e7 | |||
| ed9e3eccf9 | |||
| c1e90da0b4 | |||
| 7353b253ab | |||
| b6183baf84 | |||
| 69f917650e | |||
| 97fc48132a | |||
| 5f951bb4f1 | |||
| 392ee71712 | |||
| 19ecd8717f | |||
| f98d7f24a7 | |||
| 80716cca90 | |||
| f86b78a886 | |||
| 9e18ff29c6 | |||
| eb77f96d20 | |||
| cd1e067671 | |||
| 55d6637da5 | |||
| e943d12286 | |||
| 0c61aee597 | |||
| ca12a8f8f4 | |||
| 6389816f67 | |||
| dc3165533e | |||
| 0deeb39ebf | |||
| 1064b19cfb | |||
| b57e9cbc27 | |||
| 37049c4968 | |||
| 9d2b7334bc | |||
| 3e866258db | |||
| ed6689ab8f | |||
| cd949d9d64 | |||
| 122480aa61 | |||
| c0b594fa69 | |||
| 034b3b63f5 | |||
| 89342ea503 | |||
| 5535ea88ac | |||
| 0b404ea893 | |||
| 264bb210c1 | |||
| 2523323310 | |||
| b7e3baeecb | |||
| f88489beef | |||
| c12c60c550 | |||
| ae17c1184c | |||
| 5d8c5f3e92 | |||
| e64fc9aca9 | |||
| 281635cb40 | |||
| 8ccccd9705 | |||
| b2a6109430 | |||
| 0f0041d720 | |||
| 16750e8171 | |||
| 6a877185fe | |||
| fb6ea035d3 | |||
| 5e34a5e978 | |||
| 0fa07c1275 | |||
| 59b8e91c39 | |||
| a026a7d713 | |||
| e0b2f8e0d8 | |||
| 5d6467930a | |||
| c55a0baaf8 | |||
| b1912e7224 | |||
| 8e010146a9 | |||
| 5bcb78482a | |||
| cc4ac497b7 | |||
| 8719f72e61 | |||
| eb8e81d682 | |||
| b469f0e9a8 | |||
| 1b2e0aec8c | |||
| fde0d556ac | |||
| c0270c4887 |
@@ -0,0 +1,222 @@
|
||||
name: JerryScript CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
RUNNER: tools/run-tests.py
|
||||
|
||||
jobs:
|
||||
Checks:
|
||||
runs-on: ubuntu-18.04 # needed for checker version stability
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install doxygen vera++ cppcheck pylint python-serial
|
||||
- run: $RUNNER --check-signed-off=gh-actions
|
||||
- run: $RUNNER --check-doxygen
|
||||
- run: $RUNNER --check-vera
|
||||
- run: $RUNNER --check-license
|
||||
- run: $RUNNER --check-magic-strings
|
||||
- run: $RUNNER --check-pylint
|
||||
- run: $RUNNER --check-cppcheck
|
||||
|
||||
Linux_x86-64_Build_Correctness_Debugger_Tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '2.7' # needed by jerry-debugger
|
||||
- run: $RUNNER -q --jerry-tests
|
||||
- run: $RUNNER -q --jerry-debugger
|
||||
|
||||
Linux_x86_cpointer-32bit_Build_Correctness_Tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install gcc-multilib
|
||||
- run: $RUNNER -q --jerry-tests --buildoptions=--compile-flag=-m32,--cpointer-32bit=on
|
||||
|
||||
OSX_x86-64_Build_Correctness_Unit_Tests:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: $RUNNER -q --jerry-tests
|
||||
- run: $RUNNER -q --unittests
|
||||
|
||||
Linux_x86-64_Build_Option_Tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install gcc-multilib
|
||||
- run: $RUNNER --buildoption-test
|
||||
|
||||
Conformance_Tests_ES5_1:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: $RUNNER --test262
|
||||
|
||||
Conformance_Tests_ES2015:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: $RUNNER --test262-es2015=update
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: success() || failure()
|
||||
with:
|
||||
name: Test262-ES2015-results
|
||||
path: build/tests/test262_tests_es2015/local/bin/test262.report
|
||||
|
||||
Conformance_Tests_ESNext_A:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: $RUNNER --test262-esnext=update --test262-test-list=built-ins,annexB,harness,intl402
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: success() || failure()
|
||||
with:
|
||||
name: Test262-ESNext-results-A
|
||||
path: build/tests/test262_tests_esnext/local/bin/test262.report
|
||||
|
||||
Conformance_Tests_ESNext_B:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: $RUNNER --test262-esnext=update --test262-test-list=language
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: success() || failure()
|
||||
with:
|
||||
name: Test262-ESNext-results-B
|
||||
path: build/tests/test262_tests_esnext/local/bin/test262.report
|
||||
|
||||
Unit_Tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: $RUNNER -q --unittests
|
||||
|
||||
ASAN_Tests:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
ASAN_OPTIONS: detect_stack_use_after_return=1:check_initialization_order=true:strict_init_order=true
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install gcc-multilib
|
||||
- run: >-
|
||||
$RUNNER -q --jerry-tests
|
||||
--buildoptions=--stack-limit=0,--compile-flag=-fsanitize=address,--compile-flag=-m32,--compile-flag=-fno-omit-frame-pointer,--compile-flag=-fno-common,--compile-flag=-O2,--debug,--system-allocator=on,--linker-flag=-fuse-ld=gold
|
||||
--skip-list=parser-oom.js,parser-oom2.js,stack-limit.js,regression-test-issue-2190.js,regression-test-issue-2258-2963.js,regression-test-issue-2448.js,regression-test-issue-2905.js,regression-test-issue-3785.js
|
||||
|
||||
UBSAN_Tests:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
UBSAN_OPTIONS: print_stacktrace=1
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install gcc-multilib
|
||||
- run: >-
|
||||
$RUNNER -q --jerry-tests
|
||||
--buildoptions=--compile-flag=-fsanitize=undefined,--compile-flag=-m32,--compile-flag=-fno-omit-frame-pointer,--compile-flag=-fno-common,--debug,--system-allocator=on,--linker-flag=-fuse-ld=gold
|
||||
--skip-list=parser-oom.js,parser-oom2.js
|
||||
|
||||
Linux_ARMv7l_Tests:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUNTIME: qemu-arm-static
|
||||
TIMEOUT: 300
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user-static
|
||||
- run: >-
|
||||
$RUNNER -q --jerry-tests
|
||||
--buildoptions=--toolchain=cmake/toolchain_linux_armv7l.cmake,--linker-flag=-static
|
||||
|
||||
Linux_AArch64_Tests:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUNTIME: qemu-aarch64-static
|
||||
TIMEOUT: 300
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install gcc-aarch64-linux-gnu libc6-dev-armhf-cross qemu-user-static
|
||||
- run: >-
|
||||
$RUNNER -q --jerry-tests
|
||||
--buildoptions=--toolchain=cmake/toolchain_linux_aarch64.cmake,--linker-flag=-static
|
||||
|
||||
MbedOS5_K64F_Build_Test:
|
||||
runs-on: ubuntu-18.04 # needed due to ppa:team-gcc-arm-embedded/ppa
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.8' # needed due to 'intelhex' module
|
||||
- run: sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install gcc-arm-embedded python3-setuptools
|
||||
- run: make -f ./targets/mbedos5/Makefile.travis install
|
||||
- run: make -f ./targets/mbedos5/Makefile.travis script
|
||||
|
||||
Zephyr_Arduino_101_Build_Test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install gperf dfu-util device-tree-compiler
|
||||
- run: make -f ./targets/zephyr/Makefile.travis install
|
||||
- run: make -f ./targets/zephyr/Makefile.travis script
|
||||
|
||||
NuttX_STM32F4_Build_Test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install gcc-arm-none-eabi libnewlib-arm-none-eabi gperf
|
||||
- run: make -f ./targets/nuttx-stm32f4/Makefile.travis install-noapt
|
||||
- run: make -f ./targets/nuttx-stm32f4/Makefile.travis script
|
||||
|
||||
RIOT_STM32F4_Build_Test:
|
||||
runs-on: ubuntu-18.04 # needed due to ppa:team-gcc-arm-embedded/ppa
|
||||
env:
|
||||
CC: clang
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install clang gcc-arm-embedded gcc-multilib
|
||||
- run: make -f ./targets/riot-stm32f4/Makefile.travis install-noapt
|
||||
- run: make -f ./targets/riot-stm32f4/Makefile.travis script
|
||||
|
||||
ESP8266_Build_Test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '2.7' # needed due to ESP8266_RTOS_SDK/tools/gen_appbin.py
|
||||
- run: make -f ./targets/esp8266/Makefile.travis install-noapt
|
||||
- run: make -f ./targets/esp8266/Makefile.travis script
|
||||
|
||||
Notification:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push' && github.repository == 'jerryscript-project/jerryscript'
|
||||
steps:
|
||||
- uses: rectalogic/notify-irc@v1
|
||||
with:
|
||||
channel: '#jerryscript'
|
||||
nickname: jerryscript-notification
|
||||
message: |
|
||||
@${{ github.actor }}: ${{ github.repository }} (${{ github.ref }}#${{ github.sha }})
|
||||
${{ join(github.event.commits.*.message) }}
|
||||
${{ github.event.compare }}
|
||||
-180
@@ -1,180 +0,0 @@
|
||||
language: c
|
||||
|
||||
# Default environment: Ubuntu Bionic 18.04.
|
||||
os: linux
|
||||
dist: bionic
|
||||
|
||||
# Default job task: run tests as defined in the $OPT environment variable.
|
||||
# Jobs can redefine the 'script' stage in the matrix below.
|
||||
script: tools/run-tests.py $OPTS
|
||||
|
||||
# All the job definitions in the matrix.
|
||||
matrix:
|
||||
include:
|
||||
- name: "Checks"
|
||||
script:
|
||||
- tools/run-tests.py --check-signed-off=travis --check-doxygen --check-vera --check-license --check-magic-strings --check-pylint
|
||||
- travis_wait 40 tools/run-tests.py --check-cppcheck
|
||||
addons:
|
||||
apt:
|
||||
packages: [doxygen, cppcheck, vera++, pylint]
|
||||
|
||||
- name: "Linux/x86-64 Build, Correctness & Debugger Tests"
|
||||
env:
|
||||
- OPTS="--quiet --jerry-tests --jerry-test-suite --jerry-debugger"
|
||||
|
||||
- name: "Linux/x86 (cpointer-32bit) Build & Correctness Tests"
|
||||
env:
|
||||
- OPTS="--quiet --jerry-tests --jerry-test-suite --buildoptions=--compile-flag=-m32,--cpointer-32bit=on"
|
||||
addons:
|
||||
apt:
|
||||
packages: [gcc-multilib]
|
||||
|
||||
- name: "Linux/ARM Build & Correctness Tests"
|
||||
env:
|
||||
- OPTS="--quiet --jerry-tests --jerry-test-suite --toolchain=cmake/toolchain_linux_armv7l.cmake --buildoptions=--linker-flag=-static"
|
||||
- RUNTIME=qemu-arm-static
|
||||
- TIMEOUT=300
|
||||
addons:
|
||||
apt:
|
||||
packages: [gcc-arm-linux-gnueabihf, libc6-dev-armhf-cross, qemu-user-static]
|
||||
|
||||
- name: "Linux/AArch64 Native Build & Correctness Tests"
|
||||
arch: arm64
|
||||
env:
|
||||
- OPTS="--quiet --jerry-tests --jerry-test-suite --buildoptions=--linker-flag=-static"
|
||||
- TIMEOUT=300
|
||||
|
||||
- name: "OSX/x86-64 Build, Correctness & Unit Tests"
|
||||
env:
|
||||
- OPTS="--quiet --jerry-tests --jerry-test-suite --unittests"
|
||||
os: osx
|
||||
osx_image: xcode11.4
|
||||
addons:
|
||||
homebrew:
|
||||
packages: [cmake, cppcheck, vera++]
|
||||
|
||||
- name: "Build Tests"
|
||||
env:
|
||||
- OPTS="--buildoption-test"
|
||||
addons:
|
||||
apt:
|
||||
packages: [gcc-multilib]
|
||||
|
||||
- name: "Conformance Tests - ES5.1"
|
||||
env:
|
||||
- OPTS="--test262"
|
||||
|
||||
- name: "Conformance Tests - ES2015"
|
||||
env:
|
||||
- OPTS="--test262-es2015"
|
||||
|
||||
- name: "Unit Tests"
|
||||
env:
|
||||
- OPTS="--unittests"
|
||||
|
||||
- name: "ASAN Tests"
|
||||
env:
|
||||
# Skipping maximum stack usage related tests due to 'detect_stack_use_after_return=1' ASAN option.
|
||||
# For more detailed description: https://github.com/google/sanitizers/wiki/AddressSanitizerUseAfterReturn#compatibility
|
||||
- OPTS="--quiet --jerry-tests --jerry-test-suite --skip-list=parser-oom.js,parser-oom2.js,stack-limit.js,regression-test-issue-2190.js,regression-test-issue-2258-2963.js,regression-test-issue-2448.js,regression-test-issue-2905.js,regression-test-issue-3785.js --buildoptions=--stack-limit=0,--compile-flag=-fsanitize=address,--compile-flag=-m32,--compile-flag=-fno-omit-frame-pointer,--compile-flag=-fno-common,--compile-flag=-O2,--debug,--system-allocator=on,--linker-flag=-fuse-ld=gold"
|
||||
- ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=true:strict_init_order=true
|
||||
- TIMEOUT=600
|
||||
addons:
|
||||
apt:
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: [gcc-multilib]
|
||||
|
||||
- name: "UBSAN Tests"
|
||||
env:
|
||||
- OPTS="--quiet --jerry-tests --jerry-test-suite --skip-list=parser-oom.js,parser-oom2.js --buildoptions=--compile-flag=-fsanitize=undefined,--compile-flag=-m32,--compile-flag=-fno-omit-frame-pointer,--compile-flag=-fno-common,--debug,--system-allocator=on,--linker-flag=-fuse-ld=gold"
|
||||
- UBSAN_OPTIONS=print_stacktrace=1
|
||||
- TIMEOUT=600
|
||||
addons:
|
||||
apt:
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages: [gcc-multilib]
|
||||
|
||||
- name: "Coverity Scan & SonarQube"
|
||||
env:
|
||||
# Declaration of the encrypted COVERITY_SCAN_TOKEN, created via the
|
||||
# "travis encrypt" command using the project repo's public key.
|
||||
- secure: "V7BdXv3FCVkFGEfKfWto6I+Sytou1zTCGyn49xurkBfKNsG/3vbkXfsbK1m6lCZxmY7W/1odpfjixpAPZgy2L4FgPZK6/UyVvC8pIFjDOubcEniN48haleSvm/ZFPLDifxDL2+VVFtK1oRYPtDBzzSoUCcfwovgk+Wy+tSBnhnyRLqO/WaI6PqFof7ECYMTRlJVjioZARVP4YmkBruIPmGDdR/3EvwowlxfuiFoPheix61ug4x3tpTBW2qWgvFjDyCZXFz4pJrBQPTAIbyKMxHcBykJjl9eR+dWAOsvE1Uw48tFOJxjKDfUttVQUPsyKFllmcCVS0fDYB5pzZOmRUPxJmox1jt8J1FY85Ri1PGY0THBPM2H7to4Yf2418Y3539epbN8p+79dwaM7e2OiJ2owukbWI7PoNqIz5DV5zxpIKsOQfeWuNLJOgsBePEIU7lz133Si/2d5W/7If46B1d+hZRBJfSYksgDqDU6G/voZkPf0K5bKe2O2BxiIW1DYk4yQ1ecZAkqGjZ8jG3zYGMG3mSF4VyuU4UGFG1Pg8fw7Ap5zuHxSVY1H9dtu4T6JQG3aj/x1omlzfw48DjgkwxVhf7Xvl3yfR7pzydYheLX3MZYtcVo7rWnglZFZoUjWDK1StbmzsvPftvwWtoDTWlzo4xeSXhahSJvJyc4U8Wc="
|
||||
addons:
|
||||
coverity_scan:
|
||||
project:
|
||||
name: "jerryscript-project/jerryscript"
|
||||
description: "Ultra-lightweight JavaScript engine for the Internet of Things."
|
||||
notification_email: rsipka.uszeged@partner.samsung.com
|
||||
build_command: "tools/build.py --clean"
|
||||
branch_pattern: master
|
||||
sonarcloud:
|
||||
organization: "jerryscript-project"
|
||||
# Coverity Scan has already built the project by the time 'script' stage is reached.
|
||||
script: tools/check-sonarqube.sh
|
||||
cache:
|
||||
directories:
|
||||
- '${HOME}/.sonar/cache'
|
||||
|
||||
- name: "Mbed OS 5/K64F Build Test"
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: ppa:team-gcc-arm-embedded/ppa
|
||||
packages: [gcc-arm-embedded]
|
||||
language: python # NOTE: only way to ensure python>=2.7.10 on Trusty image
|
||||
python: 3.6
|
||||
install: make -f ./targets/mbedos5/Makefile.travis install
|
||||
script: make -f ./targets/mbedos5/Makefile.travis script
|
||||
|
||||
- name: "Zephyr/Arduino 101 Build Test"
|
||||
language: python # NOTE: only way to ensure python>=2.7.10 on Trusty image
|
||||
python: 3.6
|
||||
install: make -f ./targets/zephyr/Makefile.travis install-noapt
|
||||
script: make -f ./targets/zephyr/Makefile.travis script
|
||||
addons:
|
||||
apt:
|
||||
packages: [gperf, dfu-util, device-tree-compiler]
|
||||
|
||||
- name: "NuttX/STM32F4 Build Test"
|
||||
install: make -f targets/nuttx-stm32f4/Makefile.travis install-noapt
|
||||
script: make -f targets/nuttx-stm32f4/Makefile.travis script
|
||||
addons:
|
||||
apt:
|
||||
packages: [gcc-arm-none-eabi, libnewlib-arm-none-eabi, gperf]
|
||||
|
||||
- name: "RIOT/STM32F4 Build Test"
|
||||
install: make -f ./targets/riot-stm32f4/Makefile.travis install-noapt
|
||||
script: make -f ./targets/riot-stm32f4/Makefile.travis script
|
||||
compiler: clang-3.9
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: ppa:team-gcc-arm-embedded/ppa
|
||||
packages: [clang-3.9, gcc-arm-embedded, gcc-multilib]
|
||||
|
||||
- name: "ESP8266 Build Test"
|
||||
install: make -f ./targets/esp8266/Makefile.travis install-noapt
|
||||
script: make -f ./targets/esp8266/Makefile.travis script
|
||||
addons:
|
||||
apt:
|
||||
packages: [wget]
|
||||
|
||||
fast_finish: true
|
||||
|
||||
# The channel name "chat.freenode.net#jerryscript"
|
||||
# is encrypted against Samsung/jerryscript
|
||||
# to prevent IRC spam of forks.
|
||||
#
|
||||
# travis encrypt -r "Samsung/jerryscript" "chat.freenode.net#jerryscript"
|
||||
notifications:
|
||||
irc:
|
||||
channels:
|
||||
- secure: "4kML4uZywOPaT3r/bHCvZCeQWooyzZumESmKuHG2Y8/B29WtMBobsoRQZRfOmlUP5kshfjh0Itp5WFpdACiBCoorHch/8z3VT7fIbKF4UnxrAvNiFArqxXC0OWGIu93e7uyyXJCsQ/JiOXU7bD31Mh8LbnfS1z3wBAMXi+AwcaGiVVH4VTL6O8sR3ij5WmsqpECWhyWTgTP3MiLquZ+09Lv9mp5GGciEemq4p8VnaQt2BdyEBmUJJ1EAyMCJlKNObQudegOzYsY3CVON9C87dCuHf7DYstsxb8AzwRAKn8LHiaWhYaWLfvHqoXmc4w1ZgN0HZ5Qyx8KMkZkXKUiHxuCSoXDxNAHWTGQBsTDid5drZeqOFucOHEKJzkqaWSUKUF3pY/hq/h2kjAn230DlBNkJt+ikSxwy6Mm8GG8LnH5gRMl37zHDHrtyRsKR8GIst9B1B95LAOLA5t8U/ucGKXqLsohS8glXaM4jjh69it3GeHj6NhB8NbC/LsmRrhjKzV+VnjPI6gZvN+5tDiuxMbsMal+0DdWVNCst/aO3Jz0iaA5ahyo2ZwBb2efw3CekRLMKmHtnjqB0SWWXT3/t2+5zNoM6gBjo4RPOg7k5eTOXcfk8okWtQ5d3n8UtvZ5rSiDl3rssHwp1yHuuC8rGGov74DLvyDlpM6p/dmtu2o8="
|
||||
on_success: always
|
||||
on_failure: always
|
||||
use_notice: true
|
||||
template:
|
||||
- "%{repository_name} (%{branch}@%{commit}): %{author} - %{commit_subject} [%{result}]"
|
||||
- "Commit: %{compare_url}"
|
||||
- "Build: %{build_url}"
|
||||
+52
-34
@@ -15,6 +15,11 @@
|
||||
cmake_minimum_required (VERSION 2.8.12)
|
||||
project (Jerry C)
|
||||
|
||||
# Determining version
|
||||
execute_process(COMMAND python ${CMAKE_SOURCE_DIR}/tools/version.py
|
||||
OUTPUT_VARIABLE JERRY_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Determining platform
|
||||
set(PLATFORM "${CMAKE_SYSTEM_NAME}")
|
||||
string(TOUPPER "${PLATFORM}" PLATFORM)
|
||||
@@ -48,14 +53,16 @@ set(JERRY_CMDLINE_SNAPSHOT OFF CACHE BOOL "Build jerry snapshot command line to
|
||||
set(JERRY_LIBFUZZER OFF CACHE BOOL "Build jerry with libfuzzer support?")
|
||||
set(JERRY_PORT_DEFAULT ON CACHE BOOL "Build default jerry port implementation?")
|
||||
set(JERRY_EXT ON CACHE BOOL "Build jerry-ext?")
|
||||
set(JERRY_LIBM ON CACHE BOOL "Build and use jerry-libm?")
|
||||
set(JERRY_MATH OFF CACHE BOOL "Build and use jerry-math?")
|
||||
set(UNITTESTS OFF CACHE BOOL "Build unit tests?")
|
||||
set(DOCTESTS OFF CACHE BOOL "Build doc tests?")
|
||||
|
||||
# Optional build settings
|
||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries?")
|
||||
set(ENABLE_LTO ON CACHE BOOL "Enable LTO build?")
|
||||
set(ENABLE_STRIP ON CACHE BOOL "Enable stripping all symbols from release binary?")
|
||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries?")
|
||||
set(ENABLE_AMALGAM OFF CACHE BOOL "Enable amalgamated build?")
|
||||
set(ENABLE_LTO ON CACHE BOOL "Enable LTO build?")
|
||||
set(ENABLE_STRIP ON CACHE BOOL "Enable stripping all symbols from release binary?")
|
||||
set(ENABLE_COMPILE_COMMANDS ON CACHE BOOL "Enable generating compile_commands.json?")
|
||||
|
||||
# Option overrides
|
||||
if(NOT USING_CLANG)
|
||||
@@ -77,11 +84,17 @@ if(JERRY_CMDLINE OR DOCTESTS)
|
||||
endif()
|
||||
|
||||
if("${PLATFORM}" STREQUAL "DARWIN")
|
||||
set(JERRY_LIBM OFF)
|
||||
set(ENABLE_LTO OFF)
|
||||
set(ENABLE_STRIP OFF)
|
||||
|
||||
set(JERRY_LIBM_MESSAGE " (FORCED BY PLATFORM)")
|
||||
set(ENABLE_LTO_MESSAGE " (FORCED BY PLATFORM)")
|
||||
set(ENABLE_STRIP_MESSAGE " (FORCED BY PLATFORM)")
|
||||
endif()
|
||||
|
||||
if("${PLATFORM}" STREQUAL "ESP-IDF")
|
||||
set(ENABLE_LTO OFF)
|
||||
set(ENABLE_STRIP OFF)
|
||||
|
||||
set(ENABLE_LTO_MESSAGE " (FORCED BY PLATFORM)")
|
||||
set(ENABLE_STRIP_MESSAGE " (FORCED BY PLATFORM)")
|
||||
endif()
|
||||
@@ -93,36 +106,40 @@ if(USING_TI)
|
||||
endif()
|
||||
|
||||
if(USING_MSVC)
|
||||
set(JERRY_LIBM OFF)
|
||||
set(ENABLE_STRIP OFF)
|
||||
|
||||
set(JERRY_LIBM_MESSAGE " (FORCED BY COMPILER)")
|
||||
set(ENABLE_STRIP_MESSAGE " (FORCED BY COMPILER)")
|
||||
endif()
|
||||
|
||||
if(CYGWIN)
|
||||
if(CYGWIN OR MINGW OR MSYS)
|
||||
set(ENABLE_LTO OFF)
|
||||
|
||||
set(ENABLE_LTO_MESSAGE " (FORCED BY PLATFORM)")
|
||||
endif()
|
||||
|
||||
# Generate compile_commands.json
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ${ENABLE_COMPILE_COMMANDS})
|
||||
|
||||
# Status messages
|
||||
message(STATUS "CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE})
|
||||
message(STATUS "CMAKE_C_COMPILER_ID " ${CMAKE_C_COMPILER_ID})
|
||||
message(STATUS "CMAKE_SYSTEM_NAME " ${CMAKE_SYSTEM_NAME})
|
||||
message(STATUS "CMAKE_SYSTEM_PROCESSOR " ${CMAKE_SYSTEM_PROCESSOR})
|
||||
message(STATUS "BUILD_SHARED_LIBS " ${BUILD_SHARED_LIBS})
|
||||
message(STATUS "ENABLE_LTO " ${ENABLE_LTO} ${ENABLE_LTO_MESSAGE})
|
||||
message(STATUS "ENABLE_STRIP " ${ENABLE_STRIP} ${ENABLE_STRIP_MESSAGE})
|
||||
message(STATUS "JERRY_CMDLINE " ${JERRY_CMDLINE} ${JERRY_CMDLINE_MESSAGE})
|
||||
message(STATUS "JERRY_CMDLINE_TEST " ${JERRY_CMDLINE_TEST} ${JERRY_CMDLINE_TEST_MESSAGE})
|
||||
message(STATUS "JERRY_CMDLINE_SNAPSHOT " ${JERRY_CMDLINE_SNAPSHOT} ${JERRY_CMDLINE_SNAPSHOT_MESSAGE})
|
||||
message(STATUS "JERRY_LIBFUZZER " ${JERRY_LIBFUZZER} ${JERRY_LIBFUZZER_MESSAGE})
|
||||
message(STATUS "JERRY_PORT_DEFAULT " ${JERRY_PORT_DEFAULT} ${JERRY_PORT_DEFAULT_MESSAGE})
|
||||
message(STATUS "JERRY_EXT " ${JERRY_EXT} ${JERRY_EXT_MESSAGE})
|
||||
message(STATUS "JERRY_LIBM " ${JERRY_LIBM} ${JERRY_LIBM_MESSAGE})
|
||||
message(STATUS "UNITTESTS " ${UNITTESTS})
|
||||
message(STATUS "DOCTESTS " ${DOCTESTS})
|
||||
message(STATUS "CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE})
|
||||
message(STATUS "CMAKE_C_COMPILER_ID " ${CMAKE_C_COMPILER_ID})
|
||||
message(STATUS "CMAKE_SYSTEM_NAME " ${CMAKE_SYSTEM_NAME})
|
||||
message(STATUS "CMAKE_SYSTEM_PROCESSOR " ${CMAKE_SYSTEM_PROCESSOR})
|
||||
message(STATUS "BUILD_SHARED_LIBS " ${BUILD_SHARED_LIBS})
|
||||
message(STATUS "ENABLE_AMALGAM " ${ENABLE_AMALGAM} ${ENABLE_AMALGAM_MESSAGE})
|
||||
message(STATUS "ENABLE_LTO " ${ENABLE_LTO} ${ENABLE_LTO_MESSAGE})
|
||||
message(STATUS "ENABLE_STRIP " ${ENABLE_STRIP} ${ENABLE_STRIP_MESSAGE})
|
||||
message(STATUS "ENABLE_COMPILE_COMMANDS " ${ENABLE_COMPILE_COMMANDS})
|
||||
message(STATUS "JERRY_VERSION " ${JERRY_VERSION})
|
||||
message(STATUS "JERRY_CMDLINE " ${JERRY_CMDLINE} ${JERRY_CMDLINE_MESSAGE})
|
||||
message(STATUS "JERRY_CMDLINE_TEST " ${JERRY_CMDLINE_TEST} ${JERRY_CMDLINE_TEST_MESSAGE})
|
||||
message(STATUS "JERRY_CMDLINE_SNAPSHOT " ${JERRY_CMDLINE_SNAPSHOT} ${JERRY_CMDLINE_SNAPSHOT_MESSAGE})
|
||||
message(STATUS "JERRY_LIBFUZZER " ${JERRY_LIBFUZZER} ${JERRY_LIBFUZZER_MESSAGE})
|
||||
message(STATUS "JERRY_PORT_DEFAULT " ${JERRY_PORT_DEFAULT} ${JERRY_PORT_DEFAULT_MESSAGE})
|
||||
message(STATUS "JERRY_EXT " ${JERRY_EXT} ${JERRY_EXT_MESSAGE})
|
||||
message(STATUS "JERRY_MATH " ${JERRY_MATH} ${JERRY_MATH_MESSAGE})
|
||||
message(STATUS "UNITTESTS " ${UNITTESTS})
|
||||
message(STATUS "DOCTESTS " ${DOCTESTS})
|
||||
|
||||
# Setup directories
|
||||
# Note: This mimics a conventional file system layout in the build directory for
|
||||
@@ -185,14 +202,15 @@ if("${PLATFORM}" STREQUAL "DARWIN")
|
||||
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Sqc <TARGET> <LINK_FLAGS> <OBJECTS>")
|
||||
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup")
|
||||
elseif(NOT CYGWIN AND (USING_GCC OR USING_CLANG))
|
||||
elseif((NOT CYGWIN AND NOT MINGW AND NOT MSYS) AND (USING_GCC OR USING_CLANG))
|
||||
jerry_add_link_flags(-Wl,-z,noexecstack)
|
||||
endif()
|
||||
|
||||
if(USING_GCC OR USING_CLANG)
|
||||
jerry_add_compile_flags(-std=c99 -pedantic)
|
||||
# Turn off stack protector
|
||||
jerry_add_compile_flags(-fno-builtin -fno-stack-protector)
|
||||
if(JERRY_MATH)
|
||||
jerry_add_compile_flags(-fno-builtin)
|
||||
endif()
|
||||
jerry_add_compile_warnings(all extra format-nonliteral init-self conversion sign-conversion format-security missing-declarations shadow strict-prototypes undef old-style-definition)
|
||||
jerry_add_compile_flags(-Wno-stack-protector -Wno-attributes -Werror)
|
||||
endif()
|
||||
@@ -237,12 +255,12 @@ if(DEFINED EXTERNAL_LINKER_FLAGS)
|
||||
jerry_add_link_flags(${EXTERNAL_LINKER_FLAGS})
|
||||
endif()
|
||||
|
||||
# Used for placeholder to attach single source build targets
|
||||
add_custom_target(generate-single-source)
|
||||
# Used as placeholder to attach amalgamated build targets to
|
||||
add_custom_target(amalgam)
|
||||
|
||||
# Jerry's libm
|
||||
if(JERRY_LIBM)
|
||||
add_subdirectory(jerry-libm)
|
||||
if(JERRY_MATH)
|
||||
add_subdirectory(jerry-math)
|
||||
endif()
|
||||
|
||||
# Jerry's core
|
||||
@@ -266,8 +284,8 @@ endif()
|
||||
# Unittests
|
||||
if(UNITTESTS)
|
||||
add_subdirectory(tests/unit-core)
|
||||
if(JERRY_LIBM)
|
||||
add_subdirectory(tests/unit-libm)
|
||||
if(JERRY_MATH)
|
||||
add_subdirectory(tests/unit-math)
|
||||
endif()
|
||||
if(JERRY_EXT)
|
||||
add_subdirectory(tests/unit-ext)
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||

|
||||
# JerryScript: JavaScript engine for the Internet of Things
|
||||
[](LICENSE)
|
||||
[](https://travis-ci.org/jerryscript-project/jerryscript)
|
||||
[](https://github.com/jerryscript-project/jerryscript/actions)
|
||||
[](https://ci.appveyor.com/project/jerryscript-project/jerryscript/branch/master)
|
||||
[](https://scan.coverity.com/projects/jerryscript-project)
|
||||
[](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fjerryscript-project%2Fjerryscript?ref=badge_shield)
|
||||
[](https://sonarcloud.io/dashboard?id=jerryscript-project_jerryscript)
|
||||
[](https://kiwiirc.com/client/irc.freenode.net/#jerryscript)
|
||||
|
||||
JerryScript is a lightweight JavaScript engine for resource-constrained devices such as microcontrollers. It can run on devices with less than 64 KB of RAM and less than 200 KB of flash memory.
|
||||
|
||||
+3
-8
@@ -15,18 +15,13 @@ platform:
|
||||
- x64
|
||||
- Win32
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- JERRY_DEBUGGER: ON
|
||||
- JERRY_DEBUGGER: OFF
|
||||
|
||||
# Steps of a job.
|
||||
init:
|
||||
- cmake -version
|
||||
before_build:
|
||||
- if "%PLATFORM%"=="Win32" cmake -G"Visual Studio 15 2017" -Bbuild -H. -DJERRY_DEBUGGER=%JERRY_DEBUGGER%
|
||||
- if "%PLATFORM%"=="x64" cmake -G"Visual Studio 15 2017 Win64" -Bbuild -H. -DJERRY_DEBUGGER=%JERRY_DEBUGGER%
|
||||
- if "%PLATFORM%"=="Win32" cmake -G"Visual Studio 15 2017" -Bbuild -H. -DJERRY_DEBUGGER=ON
|
||||
- if "%PLATFORM%"=="x64" cmake -G"Visual Studio 15 2017 Win64" -Bbuild -H. -DJERRY_DEBUGGER=ON
|
||||
build:
|
||||
project: build\Jerry.sln
|
||||
parallel: true
|
||||
parallel: false # FIXME: This should not be needed but right now it is: msbuild generates all amalgamated files twice, at the same time in parallel builds, leading to I/O errors.
|
||||
verbosity: minimal
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# Copyright JS Foundation and other contributors, http://js.foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set(CMAKE_SYSTEM_NAME esp-idf)
|
||||
set(CMAKE_SYSTEM_PROCESSOR xtensa)
|
||||
|
||||
set(CMAKE_C_COMPILER xtensa-esp32-elf-gcc)
|
||||
set(CMAKE_CXX_COMPILER xtensa-esp32-elf-g++)
|
||||
set(CMAKE_ASM_COMPILER xtensa-esp32-elf-gcc)
|
||||
|
||||
# uncomment that if you want 4-bytes float (much faster on esp32)
|
||||
#add_definitions(-DJERRY_NUMBER_TYPE_FLOAT64=0)
|
||||
|
||||
set(CMAKE_C_FLAGS "-mlongcalls -Wno-frame-address" CACHE STRING "C Compiler Base Flags")
|
||||
set(CMAKE_CXX_FLAGS "-mlongcalls -Wno-frame-address" CACHE STRING "C++ Compiler Base Flags")
|
||||
|
||||
# Can be removed after gcc 5.2.0 support is removed (ref GCC_NOT_5_2_0)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-nostdlib" CACHE STRING "Linker Base Flags")
|
||||
@@ -51,10 +51,10 @@ tools/build.py --debug --logging=on --error-messages=on --line-info=on
|
||||
python tools/build.py --cmake-param=CMAKE_PARAM
|
||||
```
|
||||
|
||||
**Set a profile mode (ES5.1, subset of ES2015, minimal)**
|
||||
**Set a profile mode (ES.next, ES5.1, minimal)**
|
||||
|
||||
```bash
|
||||
python tools/build.py --profile=es5.1|es2015-subset|minimal
|
||||
python tools/build.py --profile=es.next|es5.1|minimal
|
||||
```
|
||||
|
||||
See also the related [README.md](https://github.com/jerryscript-project/jerryscript/blob/master/jerry-core/profiles/README.md).
|
||||
@@ -161,12 +161,6 @@ python tools/run-tests.py --unittests
|
||||
python tools/run-tests.py --jerry-tests
|
||||
```
|
||||
|
||||
**To run jerry-test-suite**
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --jerry-test-suite
|
||||
```
|
||||
|
||||
**To run signed-off check**
|
||||
|
||||
```bash
|
||||
|
||||
+24
-19
@@ -5,16 +5,19 @@ A configuration option's value can be changed either by providing specific C pre
|
||||
This document lists the available configuration options, shows the configuration name for C, CMake, and python, and provides a brief description that explains the effect of the options.
|
||||
|
||||
|
||||
### All-in-one build
|
||||
### Amalgamated build
|
||||
|
||||
Enables the All-in-one build process, which aggregates the contents of each source file, and uses this combined file to compile the JerryScript library.
|
||||
This process can provide comparable results to link time optimization, and can be useful when LTO is not available otherwise.
|
||||
Enables the amalgamated build process, which aggregates the contents of each source file per library
|
||||
(i.e., JerryScript's core, port, and math libraries), and uses these combined files to compile the project.
|
||||
This process can provide comparable results to link-time optimization, and can be useful when LTO is not available otherwise.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `<none>` |
|
||||
| CMake: | `-DENABLE_ALL_IN_ONE=ON/OFF` |
|
||||
| Python: | `--all-in-one=ON/OFF` |
|
||||
| CMake: | `-DENABLE_AMALGAM=ON/OFF` |
|
||||
| Python: | `--amalgam=ON/OFF` |
|
||||
|
||||
See also: [Amalgamated sources](#amalgamated-sources)
|
||||
|
||||
### Jerry debugger
|
||||
|
||||
@@ -41,7 +44,7 @@ that can be used by the debugger to identify the currently executed source conte
|
||||
### Profiles
|
||||
|
||||
This option can be used to enable/disable available JavaScript language features by providing profile files. Profile files contain a list of C definitions that configure each individual feature.
|
||||
The `path` value for CMake and Python arguments should be a file path to the profile file, or one of `es2015-subset`, `es5.1`, or `minimal`, which are the pre-defined profiles.
|
||||
The `path` value for CMake and Python arguments should be a file path to the profile file, or one of `es.next`, `es5.1`, or `minimal`, which are the pre-defined profiles.
|
||||
To see how a profile file should be created, or what configuration options are available in C, see the profile [README](https://github.com/jerryscript-project/jerryscript/blob/master/jerry-core/profiles/README.md).
|
||||
|
||||
| Options | |
|
||||
@@ -152,7 +155,7 @@ This feature is disabled by default.
|
||||
|
||||
### LCache
|
||||
|
||||
This option enables the LCache, allowing faster access to object properties. The LCache usases a statically allocated hash-map, which increases memory consumption.
|
||||
This option enables the LCache, allowing faster access to object properties. The LCache uses a statically allocated hash-map, which increases memory consumption.
|
||||
See [Internals](04.INTERNALS.md#lcache) for further details.
|
||||
This option is enabled by default.
|
||||
|
||||
@@ -278,25 +281,27 @@ This option is disabled by default.
|
||||
| Python: | `--mem-stress-test=ON/OFF` |
|
||||
|
||||
|
||||
# Single source build mode
|
||||
# Amalgamated sources
|
||||
|
||||
There is a special mode to use/"build" JerryScript. That is generating a single C file which can be
|
||||
included into projects quickly. To achive this the following command can be executed to create
|
||||
a set of files into the `gen_src` directory (Note that the command is executed in the jerryscript root directory
|
||||
but can be adapted to run outside of the project root dir):
|
||||
The sources of JerryScript can be combined into a handful of files to allow their easy integration
|
||||
in other projects. To achieve this, the following command can be executed to create a set of files
|
||||
into the `amalgam` directory:
|
||||
|
||||
```sh
|
||||
$ python tools/srcgenerator.py --output-dir gen_src --jerry-core --jerry-port-default --jerry-libm
|
||||
$ python tools/amalgam.py --output-dir amalgam --jerry-core --jerry-port-default --jerry-math
|
||||
```
|
||||
|
||||
The command creates the following files in the `gen_src` dir:
|
||||
(Note: In the example above, the command is executed from the project's root directory, but that is
|
||||
not mandatory.)
|
||||
|
||||
The command creates the following files in the `amalgam` dir:
|
||||
|
||||
* `jerryscript.c`
|
||||
* `jerryscript.h`
|
||||
* `jerryscript-config.h`
|
||||
* `jerryscript-port-default.c`
|
||||
* `jerryscript-port-default.h`
|
||||
* `jerryscript-libm.c`
|
||||
* `jerryscript-math.c`
|
||||
* `math.h`
|
||||
|
||||
**Important**: the `jerryscript-config.h` contains the configurations mentioned above and
|
||||
@@ -304,15 +309,15 @@ should be adapted to the required use-case. See the file contents for more detai
|
||||
default configuration. (Note: This config file is created from the the `jerry-core/config.h` file.)
|
||||
|
||||
These files can be directly compiled with an application using the JerryScript API.
|
||||
For example with the following command:
|
||||
E.g., using a command similar to the one below:
|
||||
|
||||
```sh
|
||||
$ gcc -Wall -o demo_app demo_app.c gen_src/jerryscript.c gen_src/jerryscript-port-default.c jerryscript-libm.c -Igen_src/
|
||||
$ gcc -Wall -o demo_app demo_app.c amalgam/jerryscript.c amalgam/jerryscript-port-default.c amalgam/jerryscript-math.c -Iamalgam/
|
||||
```
|
||||
|
||||
Please note that the headers must be available on the include path.
|
||||
(Note: The headers must be available on the include path.)
|
||||
|
||||
In addition there is a `-DENABLE_ALL_IN_ONE_SOURCE=ON` CMake option to use this kind of sources during the build.
|
||||
This approach is also under the hood of the [amalgamated build](#amalgamated-build) process.
|
||||
|
||||
# Target specific information
|
||||
|
||||
|
||||
+1623
-69
File diff suppressed because it is too large
Load Diff
+11
-11
@@ -32,7 +32,7 @@ $ export PKG_CONFIG_PATH=$(pwd)/example_install/lib/pkgconfig/
|
||||
Test if the `pkg-config` works for JerryScript:
|
||||
|
||||
```sh
|
||||
$ pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-ext libjerry-libm
|
||||
$ pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-ext libjerry-math
|
||||
```
|
||||
|
||||
## Example 1. Execute JavaScript from your application
|
||||
@@ -58,7 +58,7 @@ main (void)
|
||||
To compile it one can use the following command:
|
||||
|
||||
```sh
|
||||
$ gcc api-example-1.c -o api-example-1 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-libm)
|
||||
$ gcc api-example-1.c -o api-example-1 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-math)
|
||||
```
|
||||
|
||||
If everything is correct the application returns with a zero exit code:
|
||||
@@ -118,7 +118,7 @@ main (void)
|
||||
To compile it one can use the following command:
|
||||
|
||||
```sh
|
||||
$ gcc api-example-2.c -o api-example-2 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-libm)
|
||||
$ gcc api-example-2.c -o api-example-2 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-math)
|
||||
```
|
||||
|
||||
If everything is correct the application returns with a zero exit code:
|
||||
@@ -181,7 +181,7 @@ main (void)
|
||||
To compile it one can use the following command:
|
||||
|
||||
```sh
|
||||
$ gcc api-example-3.c -o api-example-3 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-libm)
|
||||
$ gcc api-example-3.c -o api-example-3 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-math)
|
||||
```
|
||||
|
||||
If everything is correct the application returns with a zero exit code:
|
||||
@@ -285,7 +285,7 @@ main (void)
|
||||
To compile it one can use the following command:
|
||||
|
||||
```sh
|
||||
$ gcc api-example-4.c -o api-example-4 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-libm)
|
||||
$ gcc api-example-4.c -o api-example-4 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-math)
|
||||
```
|
||||
|
||||
If everything is correct the application should print out the message present in the `print_handler` method:
|
||||
@@ -405,7 +405,7 @@ main (void)
|
||||
To compile it one can use the following command:
|
||||
|
||||
```sh
|
||||
$ gcc api-example-5.c -o api-example-5 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-libm)
|
||||
$ gcc api-example-5.c -o api-example-5 $(pkg-config --cflags --libs libjerry-core libjerry-port-default libjerry-math)
|
||||
```
|
||||
|
||||
If everything is correct the application should print out the string passed for the `print` method in the JS code:
|
||||
@@ -473,7 +473,7 @@ To compile it one can use the following command:
|
||||
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call.
|
||||
|
||||
```sh
|
||||
$ gcc api-example-6.c -o api-example-6 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-libm)
|
||||
$ gcc api-example-6.c -o api-example-6 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-math)
|
||||
```
|
||||
|
||||
If everything is correct the application should print out the string passed for the `print` method in the JS code:
|
||||
@@ -549,7 +549,7 @@ To compile it one can use the following command:
|
||||
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call.
|
||||
|
||||
```sh
|
||||
$ gcc api-example-7.c -o api-example-7 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-libm)
|
||||
$ gcc api-example-7.c -o api-example-7 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-math)
|
||||
```
|
||||
|
||||
The sample will output 'Hello from C!'. However, now it is not just a part of the source script, but the value, dynamically supplied to the engine:
|
||||
@@ -822,7 +822,7 @@ To compile it one can use the following command:
|
||||
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call.
|
||||
|
||||
```sh
|
||||
$ gcc api-example-8-shell.c -o api-example-8-shell $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-libm)
|
||||
$ gcc api-example-8-shell.c -o api-example-8-shell $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-math)
|
||||
```
|
||||
|
||||
The application reads lines from standard input and evaluates them, one after another. To try out run:
|
||||
@@ -922,7 +922,7 @@ To compile it one can use the following command:
|
||||
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call.
|
||||
|
||||
```sh
|
||||
$ gcc api-example-9.c -o api-example-9 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-libm)
|
||||
$ gcc api-example-9.c -o api-example-9 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-math)
|
||||
```
|
||||
|
||||
Execute the example with:
|
||||
@@ -1053,7 +1053,7 @@ To compile it one can use the following command:
|
||||
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port-default` entry for the `pkg-config` call.
|
||||
|
||||
```sh
|
||||
$ gcc api-example-10.c -o api-example-10 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-libm)
|
||||
$ gcc api-example-10.c -o api-example-10 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port-default libjerry-math)
|
||||
```
|
||||
|
||||
Execute the example with:
|
||||
|
||||
@@ -284,7 +284,8 @@ The objects are represented as following structure:
|
||||

|
||||
|
||||
Objects have a linked list that contains their properties. This list actually contains property pairs, in order to save memory described in the followings:
|
||||
A property is 7 bit long and its type field is 2 bit long which consumes 9 bit which does not fit into 1 byte but consumes 2 bytes. Hence, placing together two properties (14 bit) with the 2 bit long type field fits into 2 bytes.
|
||||
A property has a one byte long descriptor, a two byte long name and four byte long value. Hence 14 bytes consumed by a property pair. Another two bytes is
|
||||
used to show the next property pair, so the total size (16 byte) is divisible by 8.
|
||||
|
||||
#### Property Hashmap
|
||||
|
||||
|
||||
+57
-2
@@ -83,7 +83,7 @@ information.
|
||||
void jerry_port_print_char (char c);
|
||||
```
|
||||
|
||||
### ES2015 Module system
|
||||
### Jerry Module system
|
||||
|
||||
The port API provides functions that can be used by the module system to open
|
||||
and close source files, and normalize file paths.
|
||||
@@ -135,7 +135,7 @@ jerry_port_normalize_path (const char *in_path_p, /**< input file path */
|
||||
* Get the module object of a native module.
|
||||
*
|
||||
* Note:
|
||||
* This port function is called by jerry-core when ES2015_MODULE_SYSTEM
|
||||
* This port function is called by jerry-core when JERRY_MODULE_SYSTEM
|
||||
* is enabled.
|
||||
*
|
||||
* @param name String value of the module specifier.
|
||||
@@ -151,6 +151,32 @@ jerry_port_get_native_module (jerry_value_t name) /**< module specifier */
|
||||
}
|
||||
```
|
||||
|
||||
## Promise
|
||||
|
||||
```c
|
||||
/**
|
||||
* HostPromiseRejectionTracker operations
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
JERRY_PROMISE_REJECTION_OPERATION_REJECT, /**< promise is rejected without any handlers */
|
||||
JERRY_PROMISE_REJECTION_OPERATION_HANDLE, /**< handler is added to a rejected promise for the first time */
|
||||
} jerry_promise_rejection_operation_t;
|
||||
|
||||
/**
|
||||
* Track unhandled promise rejections.
|
||||
*
|
||||
* Note:
|
||||
* This port function is called by jerry-core when JERRY_BUILTIN_PROMISE
|
||||
* is enabled.
|
||||
*
|
||||
* @param promise rejected promise
|
||||
* @param operation HostPromiseRejectionTracker operation
|
||||
*/
|
||||
void jerry_port_track_promise_rejection (const jerry_value_t promise,
|
||||
const jerry_promise_rejection_operation_t operation);
|
||||
```
|
||||
|
||||
## Date
|
||||
|
||||
```c
|
||||
@@ -392,3 +418,32 @@ void jerry_port_sleep (uint32_t sleep_time)
|
||||
} /* jerry_port_sleep */
|
||||
#endif /* defined (JERRY_DEBUGGER) && (JERRY_DEBUGGER == 1) */
|
||||
```
|
||||
|
||||
## Promise
|
||||
|
||||
```c
|
||||
#include "jerryscript-port.h"
|
||||
|
||||
/**
|
||||
* Default implementation of jerry_port_track_promise_rejection.
|
||||
* Prints the reason of the unhandled rejections.
|
||||
*/
|
||||
void
|
||||
jerry_port_track_promise_rejection (const jerry_value_t promise, /**< rejected promise */
|
||||
const jerry_promise_rejection_operation_t operation) /**< operation */
|
||||
{
|
||||
(void) operation; /* unused */
|
||||
|
||||
jerry_value_t reason = jerry_get_promise_result (promise);
|
||||
jerry_value_t reason_to_string = jerry_value_to_string (reason);
|
||||
jerry_size_t req_sz = jerry_get_utf8_string_size (reason_to_string);
|
||||
jerry_char_t str_buf_p[req_sz + 1];
|
||||
jerry_string_to_utf8_char_buffer (reason_to_string, str_buf_p, req_sz);
|
||||
str_buf_p[req_sz] = '\0';
|
||||
|
||||
jerry_release_value (reason_to_string);
|
||||
jerry_release_value (reason);
|
||||
|
||||
printf ("Uncaught (in promise) %s\n", str_buf_p);
|
||||
} /* jerry_port_track_promise_rejection */
|
||||
```
|
||||
|
||||
@@ -739,6 +739,12 @@ typedef
|
||||
char wrong_newlines_again_t;
|
||||
```
|
||||
|
||||
### Type usage conventions
|
||||
|
||||
- Passing the number of arguments for a function call is always `uint32_t`
|
||||
- String size/length/position related operation should use `lit_utf8_size_t`
|
||||
- Extended objects internal fields must be `uint32_t`
|
||||
|
||||
## Function declarations
|
||||
|
||||
Function declarations in JerryScript are verbose but this format
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
The module system allows users to write import and export statements in scripts, which can be used to separate the logic of the application into custom modules.
|
||||
The standard's relevant part can be found [here](https://www.ecma-international.org/ecma-262/6.0/#sec-modules).
|
||||
Embedders wishing to use native builtin modules with ES6 imports can use the [Port API](05.PORT-API.md#es2015-module-system) to do so.
|
||||
Embedders wishing to use native builtin modules with ES6 imports can use the [Port API](05.PORT-API.md#jerry-module-system) to do so.
|
||||
|
||||
## General
|
||||
|
||||
@@ -76,7 +76,7 @@ export var version = "1.0 (e92ae0fb)";
|
||||
|
||||
```js
|
||||
// module_2.js
|
||||
var featureName = "EcmaScript 2015 modules";
|
||||
var featureName = "EcmaScript modules";
|
||||
var year = 2018;
|
||||
|
||||
export function getFeatureDetails() {
|
||||
|
||||
+394
-80
@@ -16,40 +16,33 @@ cmake_minimum_required (VERSION 2.8.12)
|
||||
set(JERRY_CORE_NAME jerry-core)
|
||||
project (${JERRY_CORE_NAME} C)
|
||||
|
||||
# Optional build settings
|
||||
set(ENABLE_ALL_IN_ONE OFF CACHE BOOL "Enable all-in-one build?")
|
||||
include(CheckLibraryExists)
|
||||
|
||||
# Optional features
|
||||
set(JERRY_CPOINTER_32_BIT OFF CACHE BOOL "Enable 32 bit compressed pointers?")
|
||||
set(JERRY_DEBUGGER OFF CACHE BOOL "Enable JerryScript debugger?")
|
||||
set(JERRY_ERROR_MESSAGES OFF CACHE BOOL "Enable error messages?")
|
||||
set(JERRY_EXTERNAL_CONTEXT OFF CACHE BOOL "Enable external context?")
|
||||
set(JERRY_PARSER ON CACHE BOOL "Enable javascript-parser?")
|
||||
set(JERRY_LINE_INFO OFF CACHE BOOL "Enable line info?")
|
||||
set(JERRY_LOGGING OFF CACHE BOOL "Enable logging?")
|
||||
set(JERRY_MEM_STATS OFF CACHE BOOL "Enable memory statistics?")
|
||||
set(JERRY_MEM_GC_BEFORE_EACH_ALLOC OFF CACHE BOOL "Enable mem-stress test?")
|
||||
set(JERRY_PARSER_DUMP_BYTE_CODE OFF CACHE BOOL "Enable parser byte-code dumps?")
|
||||
set(JERRY_PROFILE "es5.1" CACHE STRING "Use default or other profile?")
|
||||
set(JERRY_REGEXP_STRICT_MODE OFF CACHE BOOL "Enable regexp strict mode?")
|
||||
set(JERRY_REGEXP_DUMP_BYTE_CODE OFF CACHE BOOL "Enable regexp byte-code dumps?")
|
||||
set(JERRY_SNAPSHOT_EXEC OFF CACHE BOOL "Enable executing snapshot files?")
|
||||
set(JERRY_SNAPSHOT_SAVE OFF CACHE BOOL "Enable saving snapshot files?")
|
||||
set(JERRY_SYSTEM_ALLOCATOR OFF CACHE BOOL "Enable system allocator?")
|
||||
set(JERRY_VALGRIND OFF CACHE BOOL "Enable Valgrind support?")
|
||||
set(JERRY_VM_EXEC_STOP OFF CACHE BOOL "Enable VM execution stopping?")
|
||||
set(JERRY_GLOBAL_HEAP_SIZE "(512)" CACHE STRING "Size of memory heap, in kilobytes")
|
||||
set(JERRY_GC_LIMIT "(0)" CACHE STRING "Heap usage limit to trigger garbage collection")
|
||||
set(JERRY_STACK_LIMIT "(0)" CACHE STRING "Maximum stack usage size, in kilobytes")
|
||||
set(JERRY_GC_MARK_LIMIT "(8)" CACHE STRING "Maximum depth of recursion during GC mark phase")
|
||||
set(JERRY_CPOINTER_32_BIT OFF CACHE BOOL "Enable 32 bit compressed pointers?")
|
||||
set(JERRY_DEBUGGER OFF CACHE BOOL "Enable JerryScript debugger?")
|
||||
set(JERRY_ERROR_MESSAGES OFF CACHE BOOL "Enable error messages?")
|
||||
set(JERRY_EXTERNAL_CONTEXT OFF CACHE BOOL "Enable external context?")
|
||||
set(JERRY_PARSER ON CACHE BOOL "Enable javascript-parser?")
|
||||
set(JERRY_LINE_INFO OFF CACHE BOOL "Enable line info?")
|
||||
set(JERRY_LOGGING OFF CACHE BOOL "Enable logging?")
|
||||
set(JERRY_MEM_STATS OFF CACHE BOOL "Enable memory statistics?")
|
||||
set(JERRY_MEM_GC_BEFORE_EACH_ALLOC OFF CACHE BOOL "Enable mem-stress test?")
|
||||
set(JERRY_PARSER_DUMP_BYTE_CODE OFF CACHE BOOL "Enable parser byte-code dumps?")
|
||||
set(JERRY_PROFILE "es.next" CACHE STRING "Use default or other profile?")
|
||||
set(JERRY_REGEXP_STRICT_MODE OFF CACHE BOOL "Enable regexp strict mode?")
|
||||
set(JERRY_REGEXP_DUMP_BYTE_CODE OFF CACHE BOOL "Enable regexp byte-code dumps?")
|
||||
set(JERRY_SNAPSHOT_EXEC OFF CACHE BOOL "Enable executing snapshot files?")
|
||||
set(JERRY_SNAPSHOT_SAVE OFF CACHE BOOL "Enable saving snapshot files?")
|
||||
set(JERRY_SYSTEM_ALLOCATOR OFF CACHE BOOL "Enable system allocator?")
|
||||
set(JERRY_VALGRIND OFF CACHE BOOL "Enable Valgrind support?")
|
||||
set(JERRY_VM_EXEC_STOP OFF CACHE BOOL "Enable VM execution stopping?")
|
||||
set(JERRY_GLOBAL_HEAP_SIZE "(512)" CACHE STRING "Size of memory heap, in kilobytes")
|
||||
set(JERRY_GC_LIMIT "(0)" CACHE STRING "Heap usage limit to trigger garbage collection")
|
||||
set(JERRY_STACK_LIMIT "(0)" CACHE STRING "Maximum stack usage size, in kilobytes")
|
||||
set(JERRY_GC_MARK_LIMIT "(8)" CACHE STRING "Maximum depth of recursion during GC mark phase")
|
||||
|
||||
# Option overrides
|
||||
if(USING_MSVC)
|
||||
set(ENABLE_ALL_IN_ONE ON) # FIXME: This should not be needed but right now it is. To be tracked down and followed up.
|
||||
|
||||
set(ENABLE_ALL_IN_ONE_MESSAGE " (FORCED BY COMPILER)")
|
||||
endif()
|
||||
|
||||
if(JERRY_SYSTEM_ALLOCATOR)
|
||||
set(JERRY_CPOINTER_32_BIT ON)
|
||||
|
||||
@@ -83,7 +76,6 @@ if(JERRY_MEM_STATS OR JERRY_PARSER_DUMP_BYTE_CODE OR JERRY_REGEXP_DUMP_BYTE_CODE
|
||||
endif()
|
||||
|
||||
# Status messages
|
||||
message(STATUS "ENABLE_ALL_IN_ONE " ${ENABLE_ALL_IN_ONE} ${ENABLE_ALL_IN_ONE_MESSAGE})
|
||||
message(STATUS "JERRY_CPOINTER_32_BIT " ${JERRY_CPOINTER_32_BIT} ${JERRY_CPOINTER_32_BIT_MESSAGE})
|
||||
message(STATUS "JERRY_DEBUGGER " ${JERRY_DEBUGGER})
|
||||
message(STATUS "JERRY_ERROR_MESSAGES " ${JERRY_ERROR_MESSAGES})
|
||||
@@ -130,70 +122,379 @@ set(INCLUDE_CORE_PRIVATE ${INCLUDE_CORE_PRIVATE} PARENT_SCOPE) # for tests/unit-
|
||||
|
||||
# Sources
|
||||
# Jerry core
|
||||
file(GLOB SOURCE_CORE_FILES
|
||||
api/*.c
|
||||
debugger/*.c
|
||||
ecma/base/*.c
|
||||
ecma/builtin-objects/*.c
|
||||
ecma/builtin-objects/typedarray/*.c
|
||||
ecma/operations/*.c
|
||||
jcontext/*.c
|
||||
jmem/*.c
|
||||
jrt/*.c
|
||||
lit/*.c
|
||||
parser/js/*.c
|
||||
parser/regexp/*.c
|
||||
vm/*.c)
|
||||
set(SOURCE_CORE_FILES
|
||||
api/jerry-debugger-transport.c
|
||||
api/jerry-debugger.c
|
||||
api/jerry-snapshot.c
|
||||
api/jerry.c
|
||||
debugger/debugger.c
|
||||
ecma/base/ecma-alloc.c
|
||||
ecma/base/ecma-gc.c
|
||||
ecma/base/ecma-helpers-collection.c
|
||||
ecma/base/ecma-helpers-conversion.c
|
||||
ecma/base/ecma-helpers-errol.c
|
||||
ecma/base/ecma-helpers-external-pointers.c
|
||||
ecma/base/ecma-helpers-number.c
|
||||
ecma/base/ecma-helpers-string.c
|
||||
ecma/base/ecma-helpers-value.c
|
||||
ecma/base/ecma-helpers.c
|
||||
ecma/base/ecma-init-finalize.c
|
||||
ecma/base/ecma-lcache.c
|
||||
ecma/base/ecma-literal-storage.c
|
||||
ecma/base/ecma-module.c
|
||||
ecma/base/ecma-property-hashmap.c
|
||||
ecma/builtin-objects/ecma-builtin-array-iterator-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-array-prototype-unscopables.c
|
||||
ecma/builtin-objects/ecma-builtin-array-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-array.c
|
||||
ecma/builtin-objects/ecma-builtin-arraybuffer-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-arraybuffer.c
|
||||
ecma/builtin-objects/ecma-builtin-async-function-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-async-function.c
|
||||
ecma/builtin-objects/ecma-builtin-async-generator-function.c
|
||||
ecma/builtin-objects/ecma-builtin-async-generator-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-async-generator.c
|
||||
ecma/builtin-objects/ecma-builtin-async-iterator-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-bigint-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-bigint.c
|
||||
ecma/builtin-objects/ecma-builtin-boolean-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-boolean.c
|
||||
ecma/builtin-objects/ecma-builtin-dataview-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-dataview.c
|
||||
ecma/builtin-objects/ecma-builtin-date-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-date.c
|
||||
ecma/builtin-objects/ecma-builtin-error-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-error.c
|
||||
ecma/builtin-objects/ecma-builtin-evalerror-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-evalerror.c
|
||||
ecma/builtin-objects/ecma-builtin-function-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-function.c
|
||||
ecma/builtin-objects/ecma-builtin-generator-function.c
|
||||
ecma/builtin-objects/ecma-builtin-generator-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-generator.c
|
||||
ecma/builtin-objects/ecma-builtin-global.c
|
||||
ecma/builtin-objects/ecma-builtin-handlers.c
|
||||
ecma/builtin-objects/ecma-builtin-helpers-date.c
|
||||
ecma/builtin-objects/ecma-builtin-helpers-error.c
|
||||
ecma/builtin-objects/ecma-builtin-helpers-json.c
|
||||
ecma/builtin-objects/ecma-builtin-helpers-sort.c
|
||||
ecma/builtin-objects/ecma-builtin-helpers.c
|
||||
ecma/builtin-objects/ecma-builtin-intrinsic.c
|
||||
ecma/builtin-objects/ecma-builtin-iterator-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-json.c
|
||||
ecma/builtin-objects/ecma-builtin-map-iterator-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-map-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-map.c
|
||||
ecma/builtin-objects/ecma-builtin-math.c
|
||||
ecma/builtin-objects/ecma-builtin-number-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-number.c
|
||||
ecma/builtin-objects/ecma-builtin-object-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-object.c
|
||||
ecma/builtin-objects/ecma-builtin-promise-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-promise.c
|
||||
ecma/builtin-objects/ecma-builtin-proxy.c
|
||||
ecma/builtin-objects/ecma-builtin-rangeerror-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-rangeerror.c
|
||||
ecma/builtin-objects/ecma-builtin-referenceerror-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-referenceerror.c
|
||||
ecma/builtin-objects/ecma-builtin-reflect.c
|
||||
ecma/builtin-objects/ecma-builtin-regexp-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-regexp-string-iterator-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-regexp.c
|
||||
ecma/builtin-objects/ecma-builtin-set-iterator-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-set-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-set.c
|
||||
ecma/builtin-objects/ecma-builtin-string-iterator-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-string-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-string.c
|
||||
ecma/builtin-objects/ecma-builtin-symbol-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-symbol.c
|
||||
ecma/builtin-objects/ecma-builtin-syntaxerror-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-syntaxerror.c
|
||||
ecma/builtin-objects/ecma-builtin-type-error-thrower.c
|
||||
ecma/builtin-objects/ecma-builtin-typeerror-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-typeerror.c
|
||||
ecma/builtin-objects/ecma-builtin-urierror-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-urierror.c
|
||||
ecma/builtin-objects/ecma-builtin-weakmap-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-weakmap.c
|
||||
ecma/builtin-objects/ecma-builtin-weakset-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-weakset.c
|
||||
ecma/builtin-objects/ecma-builtins.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-bigint64array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-bigint64array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-biguint64array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-biguint64array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-float32array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-float32array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-float64array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-float64array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-int16array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-int16array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-int32array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-int32array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-int8array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-int8array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-typedarray-helpers.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-typedarray.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-uint16array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-uint16array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-uint32array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-uint32array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-uint8array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-uint8array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray.c
|
||||
ecma/operations/ecma-arguments-object.c
|
||||
ecma/operations/ecma-array-object.c
|
||||
ecma/operations/ecma-arraybuffer-object.c
|
||||
ecma/operations/ecma-async-generator-object.c
|
||||
ecma/operations/ecma-big-uint.c
|
||||
ecma/operations/ecma-bigint-object.c
|
||||
ecma/operations/ecma-bigint.c
|
||||
ecma/operations/ecma-boolean-object.c
|
||||
ecma/operations/ecma-comparison.c
|
||||
ecma/operations/ecma-container-object.c
|
||||
ecma/operations/ecma-conversion.c
|
||||
ecma/operations/ecma-dataview-object.c
|
||||
ecma/operations/ecma-eval.c
|
||||
ecma/operations/ecma-exceptions.c
|
||||
ecma/operations/ecma-function-object.c
|
||||
ecma/operations/ecma-get-put-value.c
|
||||
ecma/operations/ecma-iterator-object.c
|
||||
ecma/operations/ecma-jobqueue.c
|
||||
ecma/operations/ecma-lex-env.c
|
||||
ecma/operations/ecma-number-arithmetic.c
|
||||
ecma/operations/ecma-number-object.c
|
||||
ecma/operations/ecma-objects-general.c
|
||||
ecma/operations/ecma-objects.c
|
||||
ecma/operations/ecma-promise-object.c
|
||||
ecma/operations/ecma-proxy-object.c
|
||||
ecma/operations/ecma-reference.c
|
||||
ecma/operations/ecma-regexp-object.c
|
||||
ecma/operations/ecma-string-object.c
|
||||
ecma/operations/ecma-symbol-object.c
|
||||
ecma/operations/ecma-typedarray-object.c
|
||||
jcontext/jcontext.c
|
||||
jmem/jmem-allocator.c
|
||||
jmem/jmem-heap.c
|
||||
jmem/jmem-poolman.c
|
||||
jrt/jrt-fatals.c
|
||||
lit/lit-char-helpers.c
|
||||
lit/lit-magic-strings.c
|
||||
lit/lit-strings.c
|
||||
parser/js/byte-code.c
|
||||
parser/js/common.c
|
||||
parser/js/js-lexer.c
|
||||
parser/js/js-parser-expr.c
|
||||
parser/js/js-parser-mem.c
|
||||
parser/js/js-parser-module.c
|
||||
parser/js/js-parser-statm.c
|
||||
parser/js/js-parser-tagged-template-literal.c
|
||||
parser/js/js-parser-util.c
|
||||
parser/js/js-parser.c
|
||||
parser/js/js-scanner-ops.c
|
||||
parser/js/js-scanner-util.c
|
||||
parser/js/js-scanner.c
|
||||
parser/regexp/re-bytecode.c
|
||||
parser/regexp/re-compiler.c
|
||||
parser/regexp/re-parser.c
|
||||
vm/opcodes-ecma-arithmetics.c
|
||||
vm/opcodes-ecma-bitwise.c
|
||||
vm/opcodes-ecma-relational-equality.c
|
||||
vm/opcodes.c
|
||||
vm/vm-stack.c
|
||||
vm/vm-utils.c
|
||||
vm/vm.c
|
||||
)
|
||||
|
||||
# All-in-one build
|
||||
if(ENABLE_ALL_IN_ONE)
|
||||
set(ALL_IN_FILE "${CMAKE_BINARY_DIR}/jerry-all-in.c")
|
||||
list(SORT SOURCE_CORE_FILES)
|
||||
file(REMOVE ${ALL_IN_FILE})
|
||||
|
||||
foreach(FILE ${SOURCE_CORE_FILES})
|
||||
file(APPEND ${ALL_IN_FILE} "#include \"${FILE}\"\n")
|
||||
endforeach()
|
||||
|
||||
set(SOURCE_CORE_FILES ${ALL_IN_FILE})
|
||||
endif()
|
||||
|
||||
# "Single" JerryScript source/header build.
|
||||
# Amalgamated JerryScript source/header build.
|
||||
# The process will create the following files:
|
||||
# * jerryscript.c
|
||||
# * jerryscript.h
|
||||
# * jerryscript-config.h
|
||||
if(ENABLE_ALL_IN_ONE_SOURCE)
|
||||
if(ENABLE_AMALGAM)
|
||||
|
||||
# Create single C/H file
|
||||
file(GLOB HEADER_CORE_FILES *.h)
|
||||
set(HEADER_CORE_FILES
|
||||
api/jerry-snapshot.h
|
||||
debugger/debugger.h
|
||||
ecma/base/ecma-alloc.h
|
||||
ecma/base/ecma-gc.h
|
||||
ecma/base/ecma-globals.h
|
||||
ecma/base/ecma-helpers.h
|
||||
ecma/base/ecma-init-finalize.h
|
||||
ecma/base/ecma-lcache.h
|
||||
ecma/base/ecma-literal-storage.h
|
||||
ecma/base/ecma-module.h
|
||||
ecma/base/ecma-property-hashmap.h
|
||||
ecma/builtin-objects/ecma-builtin-array-iterator-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-array-prototype-unscopables.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-array-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-array.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-arraybuffer-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-arraybuffer.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-async-function-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-async-function.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-async-generator-function.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-async-generator-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-async-generator.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-async-iterator-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-bigint-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-bigint.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-boolean-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-boolean.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-dataview-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-dataview.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-date-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-date.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-error-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-error.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-evalerror-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-evalerror.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-function-prototype.h
|
||||
ecma/builtin-objects/ecma-builtin-function-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-function.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-generator-function.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-generator-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-generator.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-global.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-handlers.h
|
||||
ecma/builtin-objects/ecma-builtin-handlers.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-helpers-macro-defines.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-helpers-macro-undefs.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-helpers.h
|
||||
ecma/builtin-objects/ecma-builtin-internal-routines-template.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-intrinsic.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-iterator-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-json.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-map-iterator-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-map-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-map.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-math.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-number-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-number.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-object-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-object.h
|
||||
ecma/builtin-objects/ecma-builtin-object.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-promise-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-promise.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-proxy.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-rangeerror-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-rangeerror.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-referenceerror-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-referenceerror.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-reflect.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-regexp-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-regexp-string-iterator-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-regexp.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-set-iterator-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-set-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-set.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-string-iterator-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-string-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-string.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-symbol-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-symbol.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-syntaxerror-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-syntaxerror.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-type-error-thrower.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-typeerror-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-typeerror.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-urierror-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-urierror.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-weakmap-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-weakmap.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-weakset-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-weakset.inc.h
|
||||
ecma/builtin-objects/ecma-builtins-internal.h
|
||||
ecma/builtin-objects/ecma-builtins.h
|
||||
ecma/builtin-objects/ecma-builtins.inc.h
|
||||
ecma/operations/ecma-arguments-object.h
|
||||
ecma/operations/ecma-array-object.h
|
||||
ecma/operations/ecma-arraybuffer-object.h
|
||||
ecma/operations/ecma-async-generator-object.h
|
||||
ecma/operations/ecma-big-uint.h
|
||||
ecma/operations/ecma-bigint-object.h
|
||||
ecma/operations/ecma-bigint.h
|
||||
ecma/operations/ecma-boolean-object.h
|
||||
ecma/operations/ecma-comparison.h
|
||||
ecma/operations/ecma-container-object.h
|
||||
ecma/operations/ecma-conversion.h
|
||||
ecma/operations/ecma-dataview-object.h
|
||||
ecma/operations/ecma-eval.h
|
||||
ecma/operations/ecma-exceptions.h
|
||||
ecma/operations/ecma-function-object.h
|
||||
ecma/operations/ecma-iterator-object.h
|
||||
ecma/operations/ecma-jobqueue.h
|
||||
ecma/operations/ecma-lex-env.h
|
||||
ecma/operations/ecma-number-arithmetic.h
|
||||
ecma/operations/ecma-number-object.h
|
||||
ecma/operations/ecma-objects-general.h
|
||||
ecma/operations/ecma-objects.h
|
||||
ecma/operations/ecma-promise-object.h
|
||||
ecma/operations/ecma-proxy-object.h
|
||||
ecma/operations/ecma-reference.h
|
||||
ecma/operations/ecma-regexp-object.h
|
||||
ecma/operations/ecma-string-object.h
|
||||
ecma/operations/ecma-symbol-object.h
|
||||
ecma/operations/ecma-typedarray-object.h
|
||||
include/jerryscript-compiler.h
|
||||
include/jerryscript-core.h
|
||||
include/jerryscript-debugger-transport.h
|
||||
include/jerryscript-debugger.h
|
||||
include/jerryscript-port.h
|
||||
include/jerryscript-snapshot.h
|
||||
include/jerryscript.h
|
||||
jcontext/jcontext.h
|
||||
jmem/jmem-allocator-internal.h
|
||||
jmem/jmem.h
|
||||
jrt/jrt-bit-fields.h
|
||||
jrt/jrt-libc-includes.h
|
||||
jrt/jrt-types.h
|
||||
jrt/jrt.h
|
||||
lit/lit-char-helpers.h
|
||||
lit/lit-globals.h
|
||||
lit/lit-magic-strings.h
|
||||
lit/lit-magic-strings.inc.h
|
||||
lit/lit-strings.h
|
||||
lit/lit-unicode-conversions-sup.inc.h
|
||||
lit/lit-unicode-conversions.inc.h
|
||||
lit/lit-unicode-folding.inc.h
|
||||
lit/lit-unicode-ranges-sup.inc.h
|
||||
lit/lit-unicode-ranges.inc.h
|
||||
vm/opcodes.h
|
||||
vm/vm-defines.h
|
||||
vm/vm-stack.h
|
||||
vm/vm.h
|
||||
)
|
||||
|
||||
# Generated files
|
||||
set(ALL_IN_FILE "${CMAKE_BINARY_DIR}/src/jerryscript.c")
|
||||
set(ALL_IN_FILE_H "${CMAKE_BINARY_DIR}/src/jerryscript.h")
|
||||
set(JERRYSCRIPT_CONFIG_H "${CMAKE_BINARY_DIR}/src/jerryscript-config.h")
|
||||
set(AMALGAM_CORE_C "${CMAKE_BINARY_DIR}/amalgam/jerryscript.c")
|
||||
set(AMALGAM_CORE_H "${CMAKE_BINARY_DIR}/amalgam/jerryscript.h")
|
||||
set(AMALGAM_CONFIG_H "${CMAKE_BINARY_DIR}/amalgam/jerryscript-config.h")
|
||||
|
||||
add_custom_command(OUTPUT ${ALL_IN_FILE} ${ALL_IN_FILE_H}
|
||||
COMMAND python ${CMAKE_SOURCE_DIR}/tools/srcgenerator.py
|
||||
add_custom_command(OUTPUT ${AMALGAM_CORE_C} ${AMALGAM_CORE_H}
|
||||
COMMAND python ${CMAKE_SOURCE_DIR}/tools/amalgam.py
|
||||
--jerry-core
|
||||
--output-dir ${CMAKE_BINARY_DIR}/src
|
||||
--output-dir ${CMAKE_BINARY_DIR}/amalgam
|
||||
DEPENDS ${SOURCE_CORE_FILES}
|
||||
${HEADER_CORE_FILES}
|
||||
${CMAKE_SOURCE_DIR}/tools/srcgenerator.py
|
||||
${CMAKE_SOURCE_DIR}/tools/srcmerger.py
|
||||
${CMAKE_SOURCE_DIR}/tools/amalgam.py
|
||||
)
|
||||
|
||||
# The "true" jerryscript-config.h will be generated by the configure_file below,
|
||||
# which contains the default options and the ones passed for the CMake.
|
||||
# The input for this is the jerryscript-config.h generated by the command above.
|
||||
set(JERRYSCRIPT_GEN_CONFIG_H ${CMAKE_CURRENT_BINARY_DIR}/jerryscript-config.h)
|
||||
add_custom_command(OUTPUT ${JERRYSCRIPT_CONFIG_H}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${JERRYSCRIPT_GEN_CONFIG_H} ${JERRYSCRIPT_CONFIG_H}
|
||||
DEPENDS ${ALL_IN_FILE_C} ${ALL_IN_FILE_H})
|
||||
add_custom_target(generate-single-source-jerry DEPENDS ${ALL_IN_FILE} ${ALL_IN_FILE_H})
|
||||
add_dependencies(generate-single-source generate-single-source-jerry)
|
||||
add_custom_command(OUTPUT ${AMALGAM_CONFIG_H}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${JERRYSCRIPT_GEN_CONFIG_H} ${AMALGAM_CONFIG_H}
|
||||
DEPENDS ${AMALGAM_CORE_C} ${AMALGAM_CORE_H})
|
||||
add_custom_target(amalgam-jerry DEPENDS ${AMALGAM_CORE_C} ${AMALGAM_CORE_H} ${AMALGAM_CONFIG_H})
|
||||
add_dependencies(amalgam amalgam-jerry)
|
||||
|
||||
set(SOURCE_CORE_FILES ${ALL_IN_FILE} ${ALL_IN_FILE_H} ${JERRYSCRIPT_CONFIG_H})
|
||||
set(SOURCE_CORE_FILES ${AMALGAM_CORE_C} ${AMALGAM_CORE_H} ${AMALGAM_CONFIG_H})
|
||||
endif()
|
||||
|
||||
# Third-party
|
||||
@@ -254,14 +555,18 @@ jerry_add_define01(JERRY_MEM_GC_BEFORE_EACH_ALLOC)
|
||||
jerry_add_define01(JERRY_PARSER_DUMP_BYTE_CODE)
|
||||
|
||||
# Profile
|
||||
if (${JERRY_PROFILE} STREQUAL "es2015-subset")
|
||||
message(DEPRECATION "'es2015-subset' profile is deprecated, please use 'es.next' instead.")
|
||||
endif()
|
||||
|
||||
if (NOT IS_ABSOLUTE ${JERRY_PROFILE})
|
||||
set(JERRY_PROFILE "${CMAKE_CURRENT_SOURCE_DIR}/profiles/${JERRY_PROFILE}.profile")
|
||||
endif()
|
||||
|
||||
if(EXISTS ${JERRY_PROFILE})
|
||||
file(READ "${JERRY_PROFILE}" PROFILE_SETTINGS)
|
||||
string(REGEX REPLACE "^#.*$" "" PROFILE_SETTINGS "${PROFILE_SETTINGS}")
|
||||
string(REGEX REPLACE "[\r|\n]" ";" PROFILE_SETTINGS "${PROFILE_SETTINGS}")
|
||||
string(REGEX REPLACE "[ \t]*#[^\n]*" "" PROFILE_SETTINGS "${PROFILE_SETTINGS}")
|
||||
string(REGEX REPLACE "[\r\n]" ";" PROFILE_SETTINGS "${PROFILE_SETTINGS}")
|
||||
|
||||
# Process entries and save them as CMake variables.
|
||||
# This is required to correctly generate the jerryscript-config.h file.
|
||||
@@ -406,9 +711,18 @@ if(ENABLE_LTO)
|
||||
set(JERRY_CORE_PKGCONFIG_CFLAGS "${JERRY_CORE_PKGCONFIG_CFLAGS} -flto")
|
||||
endif()
|
||||
|
||||
if(JERRY_LIBM)
|
||||
target_link_libraries(${JERRY_CORE_NAME} jerry-libm)
|
||||
set(JERRY_CORE_PKGCONFIG_REQUIRES libjerry-libm)
|
||||
if(JERRY_MATH)
|
||||
target_link_libraries(${JERRY_CORE_NAME} jerry-math)
|
||||
set(JERRY_CORE_PKGCONFIG_REQUIRES libjerry-math)
|
||||
else()
|
||||
if(USING_GCC OR USING_CLANG)
|
||||
set(CMAKE_REQUIRED_FLAGS "-Wno-error -Wno-error=strict-prototypes")
|
||||
endif()
|
||||
check_library_exists(m sin "" HAVE_M_LIB)
|
||||
if(HAVE_M_LIB)
|
||||
target_link_libraries(${JERRY_CORE_NAME} m)
|
||||
set(JERRY_CORE_PKGCONFIG_LIBS "${JERRY_CORE_PKGCONFIG_LIBS} -lm")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
separate_arguments(EXTERNAL_LINK_LIBS)
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "jerry-snapshot.h"
|
||||
#include "js-parser.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "js-parser-internal.h"
|
||||
#include "re-compiler.h"
|
||||
|
||||
#if ENABLED (JERRY_SNAPSHOT_SAVE) || ENABLED (JERRY_SNAPSHOT_EXEC)
|
||||
@@ -45,9 +46,12 @@ snapshot_get_global_flags (bool has_regex, /**< regex literal is present */
|
||||
#if ENABLED (JERRY_BUILTIN_REGEXP)
|
||||
flags |= (has_regex ? JERRY_SNAPSHOT_HAS_REGEX_LITERAL : 0);
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
flags |= (has_class ? JERRY_SNAPSHOT_HAS_CLASS_LITERAL : 0);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
#if ENABLED (JERRY_BUILTIN_REALMS)
|
||||
flags |= JERRY_SNAPSHOT_HAS_REALM_VALUE;
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REALMS) */
|
||||
|
||||
return flags;
|
||||
} /* snapshot_get_global_flags */
|
||||
@@ -63,9 +67,12 @@ snapshot_check_global_flags (uint32_t global_flags) /**< global flags */
|
||||
#if ENABLED (JERRY_BUILTIN_REGEXP)
|
||||
global_flags &= (uint32_t) ~JERRY_SNAPSHOT_HAS_REGEX_LITERAL;
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
global_flags &= (uint32_t) ~JERRY_SNAPSHOT_HAS_CLASS_LITERAL;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
#if ENABLED (JERRY_BUILTIN_REALMS)
|
||||
global_flags |= JERRY_SNAPSHOT_HAS_REALM_VALUE;
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REALMS) */
|
||||
|
||||
return global_flags == snapshot_get_global_flags (false, false);
|
||||
} /* snapshot_check_global_flags */
|
||||
@@ -160,22 +167,22 @@ snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled
|
||||
uint8_t *copied_code_start_p = snapshot_buffer_p + globals_p->snapshot_buffer_write_offset;
|
||||
ecma_compiled_code_t *copied_code_p = (ecma_compiled_code_t *) copied_code_start_p;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAG_HAS_TAGGED_LITERALS)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_HAS_TAGGED_LITERALS)
|
||||
{
|
||||
const char * const error_message_p = "Unsupported feature: tagged template literals.";
|
||||
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_CLASS_CONSTRUCTOR)
|
||||
if (CBC_FUNCTION_GET_TYPE (compiled_code_p->status_flags) == CBC_FUNCTION_CONSTRUCTOR)
|
||||
{
|
||||
globals_p->class_found = true;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_REGEXP)
|
||||
if (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_FUNCTION))
|
||||
if (!CBC_IS_FUNCTION (compiled_code_p->status_flags))
|
||||
{
|
||||
/* Regular expression. */
|
||||
if (globals_p->snapshot_buffer_write_offset + sizeof (ecma_compiled_code_t) > snapshot_buffer_size)
|
||||
@@ -189,7 +196,7 @@ snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled
|
||||
ecma_value_t pattern = ((re_compiled_code_t *) compiled_code_p)->source;
|
||||
ecma_string_t *pattern_string_p = ecma_get_string_from_value (pattern);
|
||||
|
||||
ecma_length_t pattern_size = 0;
|
||||
lit_utf8_size_t pattern_size = 0;
|
||||
|
||||
ECMA_STRING_TO_UTF8_STRING (pattern_string_p, buffer_p, buffer_size);
|
||||
|
||||
@@ -219,7 +226,7 @@ snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled
|
||||
/* Regexp character size is stored in refs. */
|
||||
copied_code_p->refs = (uint16_t) pattern_size;
|
||||
|
||||
pattern_size += (ecma_length_t) sizeof (ecma_compiled_code_t);
|
||||
pattern_size += (lit_utf8_size_t) sizeof (ecma_compiled_code_t);
|
||||
copied_code_p->size = (uint16_t) ((pattern_size + JMEM_ALIGNMENT - 1) >> JMEM_ALIGNMENT_LOG);
|
||||
|
||||
copied_code_p->status_flags = compiled_code_p->status_flags;
|
||||
@@ -228,7 +235,7 @@ snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled
|
||||
}
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
|
||||
|
||||
JERRY_ASSERT (compiled_code_p->status_flags & CBC_CODE_FLAGS_FUNCTION);
|
||||
JERRY_ASSERT (CBC_IS_FUNCTION (compiled_code_p->status_flags));
|
||||
|
||||
if (!snapshot_write_to_buffer_by_offset (snapshot_buffer_p,
|
||||
snapshot_buffer_size,
|
||||
@@ -307,8 +314,8 @@ static_snapshot_error_unsupported_literal (snapshot_globals_t *globals_p, /**< s
|
||||
|
||||
ecma_deref_ecma_string (literal_string_p);
|
||||
|
||||
ecma_object_t *error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_RANGE,
|
||||
ecma_stringbuilder_finalize (&builder));
|
||||
ecma_object_t *error_object_p = ecma_new_standard_error (ECMA_ERROR_RANGE,
|
||||
ecma_stringbuilder_finalize (&builder));
|
||||
|
||||
globals_p->snapshot_error = ecma_create_error_object_reference (error_object_p);
|
||||
} /* static_snapshot_error_unsupported_literal */
|
||||
@@ -345,7 +352,7 @@ static_snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< c
|
||||
uint8_t *copied_code_start_p = snapshot_buffer_p + globals_p->snapshot_buffer_write_offset;
|
||||
ecma_compiled_code_t *copied_code_p = (ecma_compiled_code_t *) copied_code_start_p;
|
||||
|
||||
if (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_FUNCTION))
|
||||
if (!CBC_IS_FUNCTION (compiled_code_p->status_flags))
|
||||
{
|
||||
/* Regular expression literals are not supported. */
|
||||
const char * const error_message_p = "Regular expression literals are not supported.";
|
||||
@@ -379,6 +386,10 @@ static_snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< c
|
||||
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) buffer_p;
|
||||
literal_end = (uint32_t) (args_p->literal_end - args_p->register_end);
|
||||
const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_REALMS)
|
||||
args_p->realm_value = JMEM_CP_NULL;
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REALMS) */
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -387,6 +398,10 @@ static_snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< c
|
||||
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) buffer_p;
|
||||
literal_end = (uint32_t) (args_p->literal_end - args_p->register_end);
|
||||
const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_REALMS)
|
||||
args_p->realm_value = JMEM_CP_NULL;
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REALMS) */
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < const_literal_end; i++)
|
||||
@@ -454,7 +469,7 @@ jerry_snapshot_set_offsets (uint32_t *buffer_p, /**< buffer */
|
||||
ecma_compiled_code_t *bytecode_p = (ecma_compiled_code_t *) buffer_p;
|
||||
uint32_t code_size = ((uint32_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
|
||||
|
||||
if (bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION)
|
||||
if (CBC_IS_FUNCTION (bytecode_p->status_flags))
|
||||
{
|
||||
ecma_value_t *literal_start_p;
|
||||
uint32_t const_literal_end;
|
||||
@@ -477,6 +492,9 @@ jerry_snapshot_set_offsets (uint32_t *buffer_p, /**< buffer */
|
||||
for (uint32_t i = 0; i < const_literal_end; i++)
|
||||
{
|
||||
if (ecma_is_value_string (literal_start_p[i])
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
|| ecma_is_value_bigint (literal_start_p[i])
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
|| ecma_is_value_float_number (literal_start_p[i]))
|
||||
{
|
||||
lit_mem_to_snapshot_id_map_entry_t *current_p = lit_map_p;
|
||||
@@ -549,9 +567,8 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
|
||||
uint32_t code_size = ((uint32_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_REGEXP)
|
||||
if (!(bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION))
|
||||
if (!CBC_IS_FUNCTION (bytecode_p->status_flags))
|
||||
{
|
||||
|
||||
const uint8_t *regex_start_p = ((const uint8_t *) bytecode_p) + sizeof (ecma_compiled_code_t);
|
||||
|
||||
/* Real size is stored in refs. */
|
||||
@@ -564,10 +581,10 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
|
||||
|
||||
return (ecma_compiled_code_t *) re_bytecode_p;
|
||||
}
|
||||
#else /* !ENABLED (JERRY_BUILTIN_REGEXP) */
|
||||
JERRY_ASSERT (CBC_IS_FUNCTION (bytecode_p->status_flags));
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
|
||||
|
||||
JERRY_ASSERT (bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION);
|
||||
|
||||
size_t header_size;
|
||||
uint32_t argument_end;
|
||||
uint32_t const_literal_end;
|
||||
@@ -582,6 +599,10 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
|
||||
const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
|
||||
literal_end = (uint32_t) (args_p->literal_end - args_p->register_end);
|
||||
header_size = sizeof (cbc_uint16_arguments_t);
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_REALMS)
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (args_p->realm_value, ecma_builtin_get_global ());
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REALMS) */
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -592,6 +613,10 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
|
||||
const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
|
||||
literal_end = (uint32_t) (args_p->literal_end - args_p->register_end);
|
||||
header_size = sizeof (cbc_uint8_arguments_t);
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_REALMS)
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (args_p->realm_value, ecma_builtin_get_global ());
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REALMS) */
|
||||
}
|
||||
|
||||
if (copy_bytecode
|
||||
@@ -618,19 +643,19 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
|
||||
extra_bytes += (uint32_t) (argument_end * sizeof (ecma_value_t));
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/* function name */
|
||||
if (!(bytecode_p->status_flags & CBC_CODE_FLAGS_CLASS_CONSTRUCTOR))
|
||||
if (CBC_FUNCTION_GET_TYPE (bytecode_p->status_flags) != CBC_FUNCTION_CONSTRUCTOR)
|
||||
{
|
||||
extra_bytes += (uint32_t) sizeof (ecma_value_t);
|
||||
}
|
||||
|
||||
/* tagged template literals */
|
||||
if (bytecode_p->status_flags & CBC_CODE_FLAG_HAS_TAGGED_LITERALS)
|
||||
if (bytecode_p->status_flags & CBC_CODE_FLAGS_HAS_TAGGED_LITERALS)
|
||||
{
|
||||
extra_bytes += (uint32_t) sizeof (ecma_value_t);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_RESOURCE_NAME)
|
||||
/* resource name */
|
||||
@@ -746,21 +771,16 @@ jerry_generate_snapshot_with_args (const jerry_char_t *resource_name_p, /**< scr
|
||||
JERRY_UNUSED (resource_name_p);
|
||||
JERRY_UNUSED (resource_name_length);
|
||||
|
||||
ecma_value_t resource_name = ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON);
|
||||
|
||||
#if ENABLED (JERRY_RESOURCE_NAME)
|
||||
if (resource_name_length == 0)
|
||||
if (resource_name_length > 0)
|
||||
{
|
||||
JERRY_CONTEXT (resource_name) = ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON);
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_CONTEXT (resource_name) = ecma_find_or_create_literal_string (resource_name_p,
|
||||
(lit_utf8_size_t) resource_name_length);
|
||||
resource_name = ecma_find_or_create_literal_string (resource_name_p, (lit_utf8_size_t) resource_name_length);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_RESOURCE_NAME) */
|
||||
|
||||
snapshot_globals_t globals;
|
||||
ecma_value_t parse_status;
|
||||
ecma_compiled_code_t *bytecode_data_p;
|
||||
const uint32_t aligned_header_size = JERRY_ALIGNUP (sizeof (jerry_snapshot_header_t),
|
||||
JMEM_ALIGNMENT);
|
||||
|
||||
@@ -772,20 +792,18 @@ jerry_generate_snapshot_with_args (const jerry_char_t *resource_name_p, /**< scr
|
||||
uint32_t status_flags = ((generate_snapshot_opts & JERRY_SNAPSHOT_SAVE_STRICT) ? ECMA_PARSE_STRICT_MODE
|
||||
: ECMA_PARSE_NO_OPTS);
|
||||
|
||||
parse_status = parser_parse_script (args_p,
|
||||
args_size,
|
||||
source_p,
|
||||
source_size,
|
||||
status_flags,
|
||||
&bytecode_data_p);
|
||||
ecma_compiled_code_t *bytecode_data_p = parser_parse_script (args_p,
|
||||
args_size,
|
||||
source_p,
|
||||
source_size,
|
||||
resource_name,
|
||||
status_flags);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (parse_status))
|
||||
if (JERRY_UNLIKELY (bytecode_data_p == NULL))
|
||||
{
|
||||
return ecma_create_error_reference_from_context ();
|
||||
}
|
||||
|
||||
JERRY_ASSERT (bytecode_data_p != NULL);
|
||||
|
||||
if (generate_snapshot_opts & JERRY_SNAPSHOT_SAVE_STATIC)
|
||||
{
|
||||
static_snapshot_add_compiled_code (bytecode_data_p, (uint8_t *) buffer_p, buffer_size, &globals);
|
||||
@@ -996,18 +1014,31 @@ jerry_snapshot_result (const uint32_t *snapshot_p, /**< snapshot */
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_PARSER_DUMP_BYTE_CODE)
|
||||
if (JERRY_CONTEXT (jerry_init_flags) & ECMA_INIT_SHOW_OPCODES)
|
||||
{
|
||||
util_print_cbc (bytecode_p);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_PARSER_DUMP_BYTE_CODE) */
|
||||
|
||||
ecma_value_t ret_val;
|
||||
|
||||
if (as_function)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
ecma_object_t *global_object_p = ecma_builtin_get_global ();
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_REALMS)
|
||||
JERRY_ASSERT (global_object_p == (ecma_object_t *) ecma_op_function_get_realm (bytecode_p));
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REALMS) */
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (bytecode_p->status_flags & CBC_CODE_FLAGS_LEXICAL_BLOCK_NEEDED)
|
||||
{
|
||||
ecma_create_global_lexical_block ();
|
||||
ecma_create_global_lexical_block (global_object_p);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
ecma_object_t *lex_env_p = ecma_get_global_scope ();
|
||||
ecma_object_t *lex_env_p = ecma_get_global_scope (global_object_p);
|
||||
ecma_object_t *func_obj_p = ecma_op_create_simple_function_object (lex_env_p, bytecode_p);
|
||||
|
||||
if (!(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
|
||||
@@ -1083,7 +1114,7 @@ scan_snapshot_functions (const uint8_t *buffer_p, /**< snapshot buffer start */
|
||||
const ecma_compiled_code_t *bytecode_p = (ecma_compiled_code_t *) buffer_p;
|
||||
uint32_t code_size = ((uint32_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
|
||||
|
||||
if ((bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION)
|
||||
if (CBC_IS_FUNCTION (bytecode_p->status_flags)
|
||||
&& !(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
|
||||
{
|
||||
const ecma_value_t *literal_start_p;
|
||||
@@ -1149,7 +1180,7 @@ update_literal_offsets (uint8_t *buffer_p, /**< [in,out] snapshot buffer start *
|
||||
const ecma_compiled_code_t *bytecode_p = (ecma_compiled_code_t *) buffer_p;
|
||||
uint32_t code_size = ((uint32_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
|
||||
|
||||
if ((bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION)
|
||||
if (CBC_IS_FUNCTION (bytecode_p->status_flags)
|
||||
&& !(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
|
||||
{
|
||||
ecma_value_t *literal_start_p;
|
||||
|
||||
@@ -45,7 +45,8 @@ typedef enum
|
||||
{
|
||||
/* 8 bits are reserved for dynamic features */
|
||||
JERRY_SNAPSHOT_HAS_REGEX_LITERAL = (1u << 0), /**< byte code has regex literal */
|
||||
JERRY_SNAPSHOT_HAS_CLASS_LITERAL = (1u << 1), /**< byte code has class literal */
|
||||
JERRY_SNAPSHOT_HAS_REALM_VALUE = (1u << 1), /**< byte code has realm value */
|
||||
JERRY_SNAPSHOT_HAS_CLASS_LITERAL = (1u << 2), /**< byte code has class literal */
|
||||
/* 24 bits are reserved for compile time features */
|
||||
JERRY_SNAPSHOT_FOUR_BYTE_CPOINTER = (1u << 8) /**< deprecated, an unused placeholder now */
|
||||
} jerry_snapshot_global_flags_t;
|
||||
|
||||
+1623
-365
File diff suppressed because it is too large
Load Diff
+109
-78
@@ -40,6 +40,10 @@
|
||||
# define JERRY_BUILTIN_ARRAY JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_ARRAY) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_BOOLEAN
|
||||
# define JERRY_BUILTIN_BOOLEAN JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_BOOLEAN) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_DATE
|
||||
# define JERRY_BUILTIN_DATE JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_DATE) */
|
||||
@@ -48,10 +52,6 @@
|
||||
# define JERRY_BUILTIN_ERRORS JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_ERRORS) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_BOOLEAN
|
||||
# define JERRY_BUILTIN_BOOLEAN JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_BOOLEAN) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_JSON
|
||||
# define JERRY_BUILTIN_JSON JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_JSON) */
|
||||
@@ -73,51 +73,59 @@
|
||||
#endif /* !defined (JERRY_BUILTIN_STRING) */
|
||||
|
||||
/**
|
||||
* ES2015 (a.k.a es6) related features, by default all of them are enabled.
|
||||
* ES2015+ related features, by default all of them are enabled.
|
||||
*/
|
||||
#ifndef JERRY_ES2015
|
||||
# define JERRY_ES2015 1
|
||||
#endif /* !defined (JERRY_ES2015) */
|
||||
#ifndef JERRY_ESNEXT
|
||||
# define JERRY_ESNEXT 1
|
||||
#endif /* !defined (JERRY_ESNEXT) */
|
||||
|
||||
#ifndef JERRY_ES2015_BUILTIN_DATAVIEW
|
||||
# define JERRY_ES2015_BUILTIN_DATAVIEW JERRY_ES2015
|
||||
#endif /* !defined (JERRY_ES2015_BUILTIN_DATAVIEW) */
|
||||
#ifndef JERRY_BUILTIN_BIGINT
|
||||
# define JERRY_BUILTIN_BIGINT JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_BIGINT) */
|
||||
|
||||
#ifndef JERRY_ES2015_BUILTIN_MAP
|
||||
# define JERRY_ES2015_BUILTIN_MAP JERRY_ES2015
|
||||
#endif /* !defined (JERRY_ES2015_BUILTIN_MAP) */
|
||||
#ifndef JERRY_BUILTIN_DATAVIEW
|
||||
# define JERRY_BUILTIN_DATAVIEW JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_DATAVIEW) */
|
||||
|
||||
#ifndef JERRY_ES2015_BUILTIN_SET
|
||||
# define JERRY_ES2015_BUILTIN_SET JERRY_ES2015
|
||||
#endif /* !defined (JERRY_ES2015_BUILTIN_SET) */
|
||||
#ifndef JERRY_BUILTIN_MAP
|
||||
# define JERRY_BUILTIN_MAP JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_MAP) */
|
||||
|
||||
#ifndef JERRY_ES2015_BUILTIN_WEAKMAP
|
||||
# define JERRY_ES2015_BUILTIN_WEAKMAP JERRY_ES2015
|
||||
#endif /* !defined (JERRY_ES2015_BUILTIN_WEAKMAP) */
|
||||
#ifndef JERRY_BUILTIN_PROMISE
|
||||
# define JERRY_BUILTIN_PROMISE JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_PROMISE) */
|
||||
|
||||
#ifndef JERRY_ES2015_BUILTIN_WEAKSET
|
||||
# define JERRY_ES2015_BUILTIN_WEAKSET JERRY_ES2015
|
||||
#endif /* !defined (JERRY_ES2015_BUILTIN_WEAKSET) */
|
||||
#ifndef JERRY_BUILTIN_PROXY
|
||||
# define JERRY_BUILTIN_PROXY JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_PROXY) */
|
||||
|
||||
#ifndef JERRY_ES2015_BUILTIN_PROMISE
|
||||
# define JERRY_ES2015_BUILTIN_PROMISE JERRY_ES2015
|
||||
#endif /* !defined (JERRY_ES2015_BUILTIN_PROMISE) */
|
||||
#ifndef JERRY_BUILTIN_REALMS
|
||||
# define JERRY_BUILTIN_REALMS JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_REALMS) */
|
||||
|
||||
#ifndef JERRY_ES2015_BUILTIN_PROXY
|
||||
# define JERRY_ES2015_BUILTIN_PROXY JERRY_ES2015
|
||||
#endif /* !defined (JERRY_ES2015_BUILTIN_PROXY) */
|
||||
#ifndef JERRY_BUILTIN_REFLECT
|
||||
# define JERRY_BUILTIN_REFLECT JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_REFLECT) */
|
||||
|
||||
#ifndef JERRY_ES2015_BUILTIN_REFLECT
|
||||
# define JERRY_ES2015_BUILTIN_REFLECT JERRY_ES2015
|
||||
#endif /* !defined (JERRY_ES2015_BUILTIN_REFLECT) */
|
||||
#ifndef JERRY_BUILTIN_SET
|
||||
# define JERRY_BUILTIN_SET JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_SET) */
|
||||
|
||||
#ifndef JERRY_ES2015_BUILTIN_TYPEDARRAY
|
||||
# define JERRY_ES2015_BUILTIN_TYPEDARRAY JERRY_ES2015
|
||||
#endif /* !defined (JERRY_ES2015_BUILTIN_TYPEDARRAY) */
|
||||
#ifndef JERRY_BUILTIN_TYPEDARRAY
|
||||
# define JERRY_BUILTIN_TYPEDARRAY JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_TYPEDARRAY) */
|
||||
|
||||
#ifndef JERRY_ES2015_MODULE_SYSTEM
|
||||
# define JERRY_ES2015_MODULE_SYSTEM JERRY_ES2015
|
||||
#endif /* !defined (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#ifndef JERRY_BUILTIN_WEAKMAP
|
||||
# define JERRY_BUILTIN_WEAKMAP JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_WEAKMAP) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_WEAKSET
|
||||
# define JERRY_BUILTIN_WEAKSET JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_WEAKSET) */
|
||||
|
||||
#ifndef JERRY_MODULE_SYSTEM
|
||||
# define JERRY_MODULE_SYSTEM JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
/**
|
||||
* Engine internal and misc configurations.
|
||||
@@ -513,51 +521,74 @@
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Check ES2015 features
|
||||
* Check ES2015+ features
|
||||
*/
|
||||
#if !defined (JERRY_ES2015) \
|
||||
|| ((JERRY_ES2015 != 0) && (JERRY_ES2015 != 1))
|
||||
# error "Invalid value for JERRY_ES2015 macro."
|
||||
#if !defined (JERRY_ESNEXT) \
|
||||
|| ((JERRY_ESNEXT != 0) && (JERRY_ESNEXT != 1))
|
||||
# error "Invalid value for JERRY_ESNEXT macro."
|
||||
#endif
|
||||
#if !defined (JERRY_ES2015_BUILTIN_DATAVIEW) \
|
||||
|| ((JERRY_ES2015_BUILTIN_DATAVIEW != 0) && (JERRY_ES2015_BUILTIN_DATAVIEW != 1))
|
||||
# error "Invalid value for JERRY_ES2015_BUILTIN_DATAVIEW macro."
|
||||
#if !defined (JERRY_BUILTIN_REALMS) \
|
||||
|| ((JERRY_BUILTIN_REALMS != 0) && (JERRY_BUILTIN_REALMS != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_REALMS macro."
|
||||
#endif
|
||||
#if !defined (JERRY_ES2015_BUILTIN_MAP) \
|
||||
|| ((JERRY_ES2015_BUILTIN_MAP != 0) && (JERRY_ES2015_BUILTIN_MAP != 1))
|
||||
# error "Invalid value for JERRY_ES2015_BUILTIN_MAP macro."
|
||||
#if !defined (JERRY_BUILTIN_DATAVIEW) \
|
||||
|| ((JERRY_BUILTIN_DATAVIEW != 0) && (JERRY_BUILTIN_DATAVIEW != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_DATAVIEW macro."
|
||||
#endif
|
||||
#if !defined (JERRY_ES2015_BUILTIN_REFLECT) \
|
||||
|| ((JERRY_ES2015_BUILTIN_REFLECT != 0) && (JERRY_ES2015_BUILTIN_REFLECT != 1))
|
||||
# error "Invalid value for JERRY_ES2015_BUILTIN_REFLECT macro."
|
||||
#if !defined (JERRY_BUILTIN_MAP) \
|
||||
|| ((JERRY_BUILTIN_MAP != 0) && (JERRY_BUILTIN_MAP != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_MAP macro."
|
||||
#endif
|
||||
#if !defined (JERRY_ES2015_BUILTIN_SET) \
|
||||
|| ((JERRY_ES2015_BUILTIN_SET != 0) && (JERRY_ES2015_BUILTIN_SET != 1))
|
||||
# error "Invalid value for JERRY_ES2015_BUILTIN_SET macro."
|
||||
#if !defined (JERRY_BUILTIN_REFLECT) \
|
||||
|| ((JERRY_BUILTIN_REFLECT != 0) && (JERRY_BUILTIN_REFLECT != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_REFLECT macro."
|
||||
#endif
|
||||
#if !defined (JERRY_ES2015_BUILTIN_WEAKMAP) \
|
||||
|| ((JERRY_ES2015_BUILTIN_WEAKMAP != 0) && (JERRY_ES2015_BUILTIN_WEAKMAP != 1))
|
||||
# error "Invalid value for JERRY_ES2015_BUILTIN_WEAKMAP macro."
|
||||
#if !defined (JERRY_BUILTIN_SET) \
|
||||
|| ((JERRY_BUILTIN_SET != 0) && (JERRY_BUILTIN_SET != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_SET macro."
|
||||
#endif
|
||||
#if !defined (JERRY_ES2015_BUILTIN_WEAKSET) \
|
||||
|| ((JERRY_ES2015_BUILTIN_WEAKSET != 0) && (JERRY_ES2015_BUILTIN_WEAKSET != 1))
|
||||
# error "Invalid value for JERRY_ES2015_BUILTIN_WEAKSET macro."
|
||||
#if !defined (JERRY_BUILTIN_WEAKMAP) \
|
||||
|| ((JERRY_BUILTIN_WEAKMAP != 0) && (JERRY_BUILTIN_WEAKMAP != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_WEAKMAP macro."
|
||||
#endif
|
||||
#if !defined (JERRY_ES2015_BUILTIN_PROMISE) \
|
||||
|| ((JERRY_ES2015_BUILTIN_PROMISE != 0) && (JERRY_ES2015_BUILTIN_PROMISE != 1))
|
||||
# error "Invalid value for JERRY_ES2015_BUILTIN_PROMISE macro."
|
||||
#if !defined (JERRY_BUILTIN_WEAKSET) \
|
||||
|| ((JERRY_BUILTIN_WEAKSET != 0) && (JERRY_BUILTIN_WEAKSET != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_WEAKSET macro."
|
||||
#endif
|
||||
#if !defined (JERRY_ES2015_BUILTIN_PROXY) \
|
||||
|| ((JERRY_ES2015_BUILTIN_PROXY != 0) && (JERRY_ES2015_BUILTIN_PROXY != 1))
|
||||
# error "Invalid value for JERRY_ES2015_BUILTIN_PROXY macro."
|
||||
#if !defined (JERRY_BUILTIN_PROMISE) \
|
||||
|| ((JERRY_BUILTIN_PROMISE != 0) && (JERRY_BUILTIN_PROMISE != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_PROMISE macro."
|
||||
#endif
|
||||
#if !defined (JERRY_ES2015_BUILTIN_TYPEDARRAY) \
|
||||
|| ((JERRY_ES2015_BUILTIN_TYPEDARRAY != 0) && (JERRY_ES2015_BUILTIN_TYPEDARRAY != 1))
|
||||
# error "Invalid value for JERRY_ES2015_BUILTIN_TYPEDARRAY macro."
|
||||
#if !defined (JERRY_BUILTIN_PROXY) \
|
||||
|| ((JERRY_BUILTIN_PROXY != 0) && (JERRY_BUILTIN_PROXY != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_PROXY macro."
|
||||
#endif
|
||||
#if !defined (JERRY_ES2015_MODULE_SYSTEM) \
|
||||
|| ((JERRY_ES2015_MODULE_SYSTEM != 0) && (JERRY_ES2015_MODULE_SYSTEM != 1))
|
||||
# error "Invalid value for JERRY_ES2015_MODULE_SYSTEM macro."
|
||||
#if !defined (JERRY_BUILTIN_TYPEDARRAY) \
|
||||
|| ((JERRY_BUILTIN_TYPEDARRAY != 0) && (JERRY_BUILTIN_TYPEDARRAY != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_TYPEDARRAY macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_BIGINT) \
|
||||
|| ((JERRY_BUILTIN_BIGINT != 0) && (JERRY_BUILTIN_BIGINT != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_BIGINT macro."
|
||||
#endif
|
||||
#if !defined (JERRY_MODULE_SYSTEM) \
|
||||
|| ((JERRY_MODULE_SYSTEM != 0) && (JERRY_MODULE_SYSTEM != 1))
|
||||
# error "Invalid value for JERRY_MODULE_SYSTEM macro."
|
||||
#endif
|
||||
#if (JERRY_ESNEXT == 0) \
|
||||
&& ((JERRY_BUILTIN_DATAVIEW == 1) \
|
||||
|| (JERRY_BUILTIN_MAP == 1) \
|
||||
|| (JERRY_BUILTIN_SET == 1) \
|
||||
|| (JERRY_BUILTIN_WEAKMAP == 1) \
|
||||
|| (JERRY_BUILTIN_WEAKSET == 1) \
|
||||
|| (JERRY_BUILTIN_PROMISE == 1) \
|
||||
|| (JERRY_BUILTIN_PROXY == 1) \
|
||||
|| (JERRY_BUILTIN_REFLECT == 1) \
|
||||
|| (JERRY_BUILTIN_TYPEDARRAY == 1))
|
||||
# error "JERRY_ESNEXT should be enabled too to enable JERRY_BUILTIN_xxxxx macro."
|
||||
#endif
|
||||
#if (JERRY_ESNEXT == 0) && (JERRY_MODULE_SYSTEM == 1)
|
||||
# error "JERRY_ESNEXT should be enabled too to enable JERRY_MODULE_SYSTEM macro."
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -677,17 +708,17 @@
|
||||
/**
|
||||
* Wrap container types into a single guard
|
||||
*/
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_MAP) || ENABLED (JERRY_ES2015_BUILTIN_SET) \
|
||||
|| ENABLED (JERRY_ES2015_BUILTIN_WEAKMAP) || ENABLED (JERRY_ES2015_BUILTIN_WEAKSET)
|
||||
# define JERRY_ES2015_BUILTIN_CONTAINER 1
|
||||
#if ENABLED (JERRY_BUILTIN_MAP) || ENABLED (JERRY_BUILTIN_SET) \
|
||||
|| ENABLED (JERRY_BUILTIN_WEAKMAP) || ENABLED (JERRY_BUILTIN_WEAKSET)
|
||||
# define JERRY_BUILTIN_CONTAINER 1
|
||||
#else
|
||||
# define JERRY_ES2015_BUILTIN_CONTAINER 0
|
||||
# define JERRY_BUILTIN_CONTAINER 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Resource name relatey types into a single guard
|
||||
* Resource name related types into a single guard
|
||||
*/
|
||||
#if ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ERROR_MESSAGES) || ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ERROR_MESSAGES) || ENABLED (JERRY_MODULE_SYSTEM)
|
||||
# define JERRY_RESOURCE_NAME 1
|
||||
#else
|
||||
# define JERRY_RESOURCE_NAME 0
|
||||
|
||||
@@ -131,7 +131,7 @@ jerry_debugger_send_backtrace (const uint8_t *recv_buffer_p) /**< pointer to the
|
||||
uint32_t frame_count = 0;
|
||||
while (iter_frame_ctx_p != NULL)
|
||||
{
|
||||
if (!(iter_frame_ctx_p->bytecode_header_p->status_flags & (CBC_CODE_FLAGS_STATIC_FUNCTION)))
|
||||
if (!(iter_frame_ctx_p->shared_p->bytecode_header_p->status_flags & (CBC_CODE_FLAGS_STATIC_FUNCTION)))
|
||||
{
|
||||
frame_count++;
|
||||
}
|
||||
@@ -164,7 +164,7 @@ jerry_debugger_send_backtrace (const uint8_t *recv_buffer_p) /**< pointer to the
|
||||
|
||||
while (frame_ctx_p != NULL && min_depth_offset++ < max_depth)
|
||||
{
|
||||
if (frame_ctx_p->bytecode_header_p->status_flags
|
||||
if (frame_ctx_p->shared_p->bytecode_header_p->status_flags
|
||||
& (CBC_CODE_FLAGS_DEBUGGER_IGNORE | CBC_CODE_FLAGS_STATIC_FUNCTION))
|
||||
{
|
||||
frame_ctx_p = frame_ctx_p->prev_context_p;
|
||||
@@ -183,10 +183,10 @@ jerry_debugger_send_backtrace (const uint8_t *recv_buffer_p) /**< pointer to the
|
||||
jerry_debugger_frame_t *frame_p = backtrace_p->frames + current_frame;
|
||||
|
||||
jmem_cpointer_t byte_code_cp;
|
||||
JMEM_CP_SET_NON_NULL_POINTER (byte_code_cp, frame_ctx_p->bytecode_header_p);
|
||||
JMEM_CP_SET_NON_NULL_POINTER (byte_code_cp, frame_ctx_p->shared_p->bytecode_header_p);
|
||||
memcpy (frame_p->byte_code_cp, &byte_code_cp, sizeof (jmem_cpointer_t));
|
||||
|
||||
uint32_t offset = (uint32_t) (frame_ctx_p->byte_code_p - (uint8_t *) frame_ctx_p->bytecode_header_p);
|
||||
uint32_t offset = (uint32_t) (frame_ctx_p->byte_code_p - (uint8_t *) frame_ctx_p->shared_p->bytecode_header_p);
|
||||
memcpy (frame_p->offset, &offset, sizeof (uint32_t));
|
||||
|
||||
frame_ctx_p = frame_ctx_p->prev_context_p;
|
||||
@@ -1167,10 +1167,10 @@ jerry_debugger_breakpoint_hit (uint8_t message_type) /**< message type */
|
||||
vm_frame_ctx_t *frame_ctx_p = JERRY_CONTEXT (vm_top_context_p);
|
||||
|
||||
jmem_cpointer_t byte_code_header_cp;
|
||||
JMEM_CP_SET_NON_NULL_POINTER (byte_code_header_cp, frame_ctx_p->bytecode_header_p);
|
||||
JMEM_CP_SET_NON_NULL_POINTER (byte_code_header_cp, frame_ctx_p->shared_p->bytecode_header_p);
|
||||
memcpy (breakpoint_hit_p->byte_code_cp, &byte_code_header_cp, sizeof (jmem_cpointer_t));
|
||||
|
||||
uint32_t offset = (uint32_t) (frame_ctx_p->byte_code_p - (uint8_t *) frame_ctx_p->bytecode_header_p);
|
||||
uint32_t offset = (uint32_t) (frame_ctx_p->byte_code_p - (uint8_t *) frame_ctx_p->shared_p->bytecode_header_p);
|
||||
memcpy (breakpoint_hit_p->offset, &offset, sizeof (uint32_t));
|
||||
|
||||
if (!jerry_debugger_send (sizeof (jerry_debugger_send_breakpoint_hit_t)))
|
||||
@@ -1482,8 +1482,7 @@ jerry_debugger_exception_object_to_string (ecma_value_t exception_obj_value) /**
|
||||
property_p = ecma_find_named_property (ecma_get_object_from_value (exception_obj_value),
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE));
|
||||
|
||||
if (property_p == NULL
|
||||
|| ECMA_PROPERTY_GET_TYPE (*property_p) != ECMA_PROPERTY_TYPE_NAMEDDATA)
|
||||
if (property_p == NULL || !(*property_p & ECMA_PROPERTY_FLAG_DATA))
|
||||
{
|
||||
return ecma_stringbuilder_finalize (&builder);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ ecma_dealloc_number (ecma_number_t *number_p) /**< number to be freed */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
inline ecma_object_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_object_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_object (void)
|
||||
{
|
||||
#if ENABLED (JERRY_MEM_STATS)
|
||||
@@ -84,7 +84,7 @@ ecma_alloc_object (void)
|
||||
/**
|
||||
* Dealloc memory from an ecma-object
|
||||
*/
|
||||
inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_dealloc_object (ecma_object_t *object_p) /**< object to be freed */
|
||||
{
|
||||
#if ENABLED (JERRY_MEM_STATS)
|
||||
@@ -99,7 +99,7 @@ ecma_dealloc_object (ecma_object_t *object_p) /**< object to be freed */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
inline ecma_extended_object_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_extended_object_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_extended_object (size_t size) /**< size of object */
|
||||
{
|
||||
#if ENABLED (JERRY_MEM_STATS)
|
||||
@@ -112,7 +112,7 @@ ecma_alloc_extended_object (size_t size) /**< size of object */
|
||||
/**
|
||||
* Dealloc memory of an extended object
|
||||
*/
|
||||
inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_dealloc_extended_object (ecma_object_t *object_p, /**< extended object */
|
||||
size_t size) /**< size of object */
|
||||
{
|
||||
@@ -128,7 +128,7 @@ ecma_dealloc_extended_object (ecma_object_t *object_p, /**< extended object */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_string (void)
|
||||
{
|
||||
#if ENABLED (JERRY_MEM_STATS)
|
||||
@@ -141,7 +141,7 @@ ecma_alloc_string (void)
|
||||
/**
|
||||
* Dealloc memory from ecma-string descriptor
|
||||
*/
|
||||
inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_dealloc_string (ecma_string_t *string_p) /**< string to be freed */
|
||||
{
|
||||
#if ENABLED (JERRY_MEM_STATS)
|
||||
@@ -156,7 +156,7 @@ ecma_dealloc_string (ecma_string_t *string_p) /**< string to be freed */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
inline ecma_extended_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_extended_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_extended_string (void)
|
||||
{
|
||||
#if ENABLED (JERRY_MEM_STATS)
|
||||
@@ -169,7 +169,7 @@ ecma_alloc_extended_string (void)
|
||||
/**
|
||||
* Dealloc memory from extended ecma-string descriptor
|
||||
*/
|
||||
inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_dealloc_extended_string (ecma_extended_string_t *ext_string_p) /**< extended string to be freed */
|
||||
{
|
||||
#if ENABLED (JERRY_MEM_STATS)
|
||||
@@ -179,12 +179,40 @@ ecma_dealloc_extended_string (ecma_extended_string_t *ext_string_p) /**< extende
|
||||
jmem_heap_free_block (ext_string_p, sizeof (ecma_extended_string_t));
|
||||
} /* ecma_dealloc_extended_string */
|
||||
|
||||
/**
|
||||
* Allocate memory for external ecma-string descriptor
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_external_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_external_string (void)
|
||||
{
|
||||
#if ENABLED (JERRY_MEM_STATS)
|
||||
jmem_stats_allocate_string_bytes (sizeof (ecma_external_string_t));
|
||||
#endif /* ENABLED (JERRY_MEM_STATS) */
|
||||
|
||||
return (ecma_external_string_t *) jmem_heap_alloc_block (sizeof (ecma_external_string_t));
|
||||
} /* ecma_alloc_external_string */
|
||||
|
||||
/**
|
||||
* Dealloc memory from external ecma-string descriptor
|
||||
*/
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_dealloc_external_string (ecma_external_string_t *ext_string_p) /**< external string to be freed */
|
||||
{
|
||||
#if ENABLED (JERRY_MEM_STATS)
|
||||
jmem_stats_free_string_bytes (sizeof (ecma_external_string_t));
|
||||
#endif /* ENABLED (JERRY_MEM_STATS) */
|
||||
|
||||
jmem_heap_free_block (ext_string_p, sizeof (ecma_external_string_t));
|
||||
} /* ecma_dealloc_external_string */
|
||||
|
||||
/**
|
||||
* Allocate memory for an string with character data
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_string_buffer (size_t size) /**< size of string */
|
||||
{
|
||||
#if ENABLED (JERRY_MEM_STATS)
|
||||
@@ -197,7 +225,7 @@ ecma_alloc_string_buffer (size_t size) /**< size of string */
|
||||
/**
|
||||
* Dealloc memory of a string with character data
|
||||
*/
|
||||
inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_dealloc_string_buffer (ecma_string_t *string_p, /**< string with data */
|
||||
size_t size) /**< size of string */
|
||||
{
|
||||
@@ -213,7 +241,7 @@ ecma_dealloc_string_buffer (ecma_string_t *string_p, /**< string with data */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
inline ecma_property_pair_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_property_pair_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_property_pair (void)
|
||||
{
|
||||
#if ENABLED (JERRY_MEM_STATS)
|
||||
@@ -226,7 +254,7 @@ ecma_alloc_property_pair (void)
|
||||
/**
|
||||
* Dealloc memory of an ecma-property
|
||||
*/
|
||||
inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_dealloc_property_pair (ecma_property_pair_t *property_pair_p) /**< property pair to be freed */
|
||||
{
|
||||
#if ENABLED (JERRY_MEM_STATS)
|
||||
|
||||
@@ -85,6 +85,18 @@ ecma_extended_string_t *ecma_alloc_extended_string (void);
|
||||
*/
|
||||
void ecma_dealloc_extended_string (ecma_extended_string_t *string_p);
|
||||
|
||||
/**
|
||||
* Allocate memory for external ecma-string descriptor
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
ecma_external_string_t *ecma_alloc_external_string (void);
|
||||
|
||||
/**
|
||||
* Dealloc memory from external ecma-string descriptor
|
||||
*/
|
||||
void ecma_dealloc_external_string (ecma_external_string_t *string_p);
|
||||
|
||||
/**
|
||||
* Allocate memory for string with character data
|
||||
*
|
||||
|
||||
+692
-204
File diff suppressed because it is too large
Load Diff
+539
-209
File diff suppressed because it is too large
Load Diff
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
@@ -48,7 +49,7 @@ ecma_new_collection (void)
|
||||
/**
|
||||
* Deallocate a collection of ecma values without freeing it's values
|
||||
*/
|
||||
inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_collection_destroy (ecma_collection_t *collection_p) /**< value collection */
|
||||
{
|
||||
JERRY_ASSERT (collection_p != NULL);
|
||||
@@ -78,6 +79,46 @@ ecma_collection_free_objects (ecma_collection_t *collection_p) /**< value collec
|
||||
ecma_collection_destroy (collection_p);
|
||||
} /* ecma_collection_free_objects */
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* Free the template literal objects and deallocate the collection
|
||||
*/
|
||||
void
|
||||
ecma_collection_free_template_literal (ecma_collection_t *collection_p) /**< value collection */
|
||||
{
|
||||
for (uint32_t i = 0; i < collection_p->item_count; i++)
|
||||
{
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (collection_p->buffer_p[i]);
|
||||
|
||||
JERRY_ASSERT (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_ARRAY);
|
||||
|
||||
ecma_extended_object_t *array_object_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
JERRY_ASSERT (array_object_p->u.array.length_prop_and_hole_count & ECMA_ARRAY_TEMPLATE_LITERAL);
|
||||
array_object_p->u.array.length_prop_and_hole_count &= (uint32_t) ~ECMA_ARRAY_TEMPLATE_LITERAL;
|
||||
|
||||
ecma_property_value_t *property_value_p;
|
||||
|
||||
property_value_p = ecma_get_named_data_property (object_p, ecma_get_magic_string (LIT_MAGIC_STRING_RAW));
|
||||
ecma_object_t *raw_object_p = ecma_get_object_from_value (property_value_p->value);
|
||||
|
||||
JERRY_ASSERT (ecma_get_object_type (raw_object_p) == ECMA_OBJECT_TYPE_ARRAY);
|
||||
|
||||
array_object_p = (ecma_extended_object_t *) raw_object_p;
|
||||
|
||||
JERRY_ASSERT (array_object_p->u.array.length_prop_and_hole_count & ECMA_ARRAY_TEMPLATE_LITERAL);
|
||||
array_object_p->u.array.length_prop_and_hole_count &= (uint32_t) ~ECMA_ARRAY_TEMPLATE_LITERAL;
|
||||
|
||||
ecma_deref_object (raw_object_p);
|
||||
ecma_deref_object (object_p);
|
||||
}
|
||||
|
||||
ecma_collection_destroy (collection_p);
|
||||
} /* ecma_collection_free_template_literal */
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Free the non-object collection elements and deallocate the collection
|
||||
*/
|
||||
@@ -187,6 +228,194 @@ ecma_collection_append (ecma_collection_t *collection_p, /**< value collection *
|
||||
collection_p->item_count += count;
|
||||
} /* ecma_collection_append */
|
||||
|
||||
/**
|
||||
* Helper function to check if a given collection have duplicated properties or not
|
||||
*
|
||||
* @return true - if there are duplicated properties in the collection
|
||||
* false - otherwise
|
||||
*/
|
||||
bool
|
||||
ecma_collection_check_duplicated_entries (ecma_collection_t *collection_p) /**< prop name collection */
|
||||
{
|
||||
if (collection_p->item_count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ecma_value_t *buffer_p = collection_p->buffer_p;
|
||||
|
||||
for (uint32_t i = 0; i < collection_p->item_count - 1; i++)
|
||||
{
|
||||
ecma_string_t *current_name_p = ecma_get_prop_name_from_value (buffer_p[i]);
|
||||
|
||||
for (uint32_t j = i + 1; j < collection_p->item_count; j++)
|
||||
{
|
||||
if (ecma_compare_ecma_strings (current_name_p, ecma_get_prop_name_from_value (buffer_p[j])))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} /* ecma_collection_check_duplicated_entries */
|
||||
|
||||
/**
|
||||
* Check the string value existance in the collection.
|
||||
*
|
||||
* Used by:
|
||||
* - ecma_builtin_json_stringify step 4.b.ii.5
|
||||
* - ecma_op_object_enumerate
|
||||
*
|
||||
* @return true, if the string is already in the collection.
|
||||
*/
|
||||
bool
|
||||
ecma_collection_has_string_value (ecma_collection_t *collection_p, /**< collection */
|
||||
ecma_string_t *string_p) /**< string */
|
||||
{
|
||||
ecma_value_t *buffer_p = collection_p->buffer_p;
|
||||
|
||||
for (uint32_t i = 0; i < collection_p->item_count; i++)
|
||||
{
|
||||
ecma_string_t *current_p = ecma_get_string_from_value (buffer_p[i]);
|
||||
|
||||
if (ecma_compare_ecma_strings (current_p, string_p))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} /* ecma_collection_has_string_value */
|
||||
|
||||
/**
|
||||
* Initial capacity of an ecma-collection
|
||||
*/
|
||||
#define ECMA_COMPACT_COLLECTION_GROWTH 8
|
||||
|
||||
/**
|
||||
* Set the size of the compact collection
|
||||
*/
|
||||
#define ECMA_COMPACT_COLLECTION_SET_SIZE(compact_collection_p, item_count, unused_items) \
|
||||
((compact_collection_p)[0] = (((item_count) << ECMA_COMPACT_COLLECTION_SIZE_SHIFT) | (unused_items)))
|
||||
|
||||
/**
|
||||
* Set the size of the compact collection
|
||||
*/
|
||||
#define ECMA_COMPACT_COLLECTION_GET_UNUSED_ITEM_COUNT(compact_collection_p) \
|
||||
((compact_collection_p)[0] & ((1 << ECMA_COMPACT_COLLECTION_SIZE_SHIFT) - 1))
|
||||
|
||||
/**
|
||||
* Allocate a compact collection of ecma values
|
||||
*
|
||||
* @return pointer to the compact collection
|
||||
*/
|
||||
ecma_value_t *
|
||||
ecma_new_compact_collection (void)
|
||||
{
|
||||
size_t size = (ECMA_COMPACT_COLLECTION_GROWTH / 2) * sizeof (ecma_value_t);
|
||||
ecma_value_t *compact_collection_p = (ecma_value_t *) jmem_heap_alloc_block (size);
|
||||
|
||||
ECMA_COMPACT_COLLECTION_SET_SIZE (compact_collection_p,
|
||||
ECMA_COMPACT_COLLECTION_GROWTH / 2,
|
||||
(ECMA_COMPACT_COLLECTION_GROWTH / 2) - 1);
|
||||
return compact_collection_p;
|
||||
} /* ecma_new_compact_collection */
|
||||
|
||||
/**
|
||||
* Append a value to the compact collection
|
||||
*
|
||||
* @return updated pointer to the compact collection
|
||||
*/
|
||||
ecma_value_t *
|
||||
ecma_compact_collection_push_back (ecma_value_t *compact_collection_p, /**< compact collection */
|
||||
ecma_value_t value) /**< ecma value to append */
|
||||
{
|
||||
ecma_value_t size = ECMA_COMPACT_COLLECTION_GET_SIZE (compact_collection_p);
|
||||
ecma_value_t unused_items = ECMA_COMPACT_COLLECTION_GET_UNUSED_ITEM_COUNT (compact_collection_p);
|
||||
|
||||
if (unused_items > 0)
|
||||
{
|
||||
compact_collection_p[size - unused_items] = value;
|
||||
(*compact_collection_p)--;
|
||||
return compact_collection_p;
|
||||
}
|
||||
|
||||
if (size == ECMA_COMPACT_COLLECTION_GROWTH / 2)
|
||||
{
|
||||
size_t old_size = (ECMA_COMPACT_COLLECTION_GROWTH / 2) * sizeof (ecma_value_t);
|
||||
size_t new_size = ECMA_COMPACT_COLLECTION_GROWTH * sizeof (ecma_value_t);
|
||||
compact_collection_p = jmem_heap_realloc_block (compact_collection_p, old_size, new_size);
|
||||
|
||||
compact_collection_p[ECMA_COMPACT_COLLECTION_GROWTH / 2] = value;
|
||||
|
||||
ECMA_COMPACT_COLLECTION_SET_SIZE (compact_collection_p,
|
||||
ECMA_COMPACT_COLLECTION_GROWTH,
|
||||
(ECMA_COMPACT_COLLECTION_GROWTH / 2) - 1);
|
||||
return compact_collection_p;
|
||||
}
|
||||
|
||||
size_t old_size = size * sizeof (ecma_value_t);
|
||||
size_t new_size = old_size + (ECMA_COMPACT_COLLECTION_GROWTH * sizeof (ecma_value_t));
|
||||
|
||||
compact_collection_p = jmem_heap_realloc_block (compact_collection_p, old_size, new_size);
|
||||
compact_collection_p[size] = value;
|
||||
|
||||
ECMA_COMPACT_COLLECTION_SET_SIZE (compact_collection_p,
|
||||
size + ECMA_COMPACT_COLLECTION_GROWTH,
|
||||
ECMA_COMPACT_COLLECTION_GROWTH - 1);
|
||||
return compact_collection_p;
|
||||
} /* ecma_compact_collection_push_back */
|
||||
|
||||
/**
|
||||
* Discard the unused elements of a compact collection
|
||||
*
|
||||
* Note:
|
||||
* further items should not be added after this call
|
||||
*
|
||||
* @return updated pointer to the compact collection
|
||||
*/
|
||||
ecma_value_t *
|
||||
ecma_compact_collection_shrink (ecma_value_t *compact_collection_p) /**< compact collection */
|
||||
{
|
||||
ecma_value_t unused_items = ECMA_COMPACT_COLLECTION_GET_UNUSED_ITEM_COUNT (compact_collection_p);
|
||||
|
||||
if (unused_items == 0)
|
||||
{
|
||||
return compact_collection_p;
|
||||
}
|
||||
|
||||
ecma_value_t size = ECMA_COMPACT_COLLECTION_GET_SIZE (compact_collection_p);
|
||||
|
||||
size_t old_size = size * sizeof (ecma_value_t);
|
||||
size_t new_size = (size - unused_items) * sizeof (ecma_value_t);
|
||||
|
||||
compact_collection_p = jmem_heap_realloc_block (compact_collection_p, old_size, new_size);
|
||||
|
||||
ECMA_COMPACT_COLLECTION_SET_SIZE (compact_collection_p, size - unused_items, 0);
|
||||
return compact_collection_p;
|
||||
} /* ecma_compact_collection_shrink */
|
||||
|
||||
/**
|
||||
* Free a compact collection
|
||||
*/
|
||||
void
|
||||
ecma_compact_collection_free (ecma_value_t *compact_collection_p) /**< compact collection */
|
||||
{
|
||||
ecma_value_t size = ECMA_COMPACT_COLLECTION_GET_SIZE (compact_collection_p);
|
||||
ecma_value_t unused_items = ECMA_COMPACT_COLLECTION_GET_UNUSED_ITEM_COUNT (compact_collection_p);
|
||||
|
||||
ecma_value_t *end_p = compact_collection_p + size - unused_items;
|
||||
ecma_value_t *current_p = compact_collection_p + 1;
|
||||
|
||||
while (current_p < end_p)
|
||||
{
|
||||
ecma_free_value (*current_p++);
|
||||
}
|
||||
|
||||
jmem_heap_free_block (compact_collection_p, size * sizeof (ecma_value_t));
|
||||
} /* ecma_compact_collection_free */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
|
||||
@@ -295,10 +295,15 @@ ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 st
|
||||
const lit_utf8_byte_t *end_p, /**< end of utf-8 string */
|
||||
uint32_t radix) /**< radix */
|
||||
{
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
bool allow_underscore = (radix & ECMA_CONVERSION_ALLOW_UNDERSCORE);
|
||||
radix &= (uint32_t) ~ECMA_CONVERSION_ALLOW_UNDERSCORE;
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
JERRY_ASSERT (radix == 2 || radix == 8 || radix == 16);
|
||||
|
||||
ecma_number_t num = ECMA_NUMBER_ZERO;
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (radix <= 8)
|
||||
{
|
||||
lit_code_point_t upper_limit = LIT_CHAR_0 + radix;
|
||||
@@ -321,7 +326,7 @@ ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 st
|
||||
|
||||
return num;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
for (const lit_utf8_byte_t * iter_p = str_p; iter_p <= end_p; iter_p++)
|
||||
{
|
||||
@@ -342,12 +347,18 @@ ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 st
|
||||
{
|
||||
digit_value = 10 + (*iter_p - LIT_CHAR_UPPERCASE_A);
|
||||
}
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (*iter_p == LIT_CHAR_UNDERSCORE && allow_underscore)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
else
|
||||
{
|
||||
return ecma_number_make_nan ();
|
||||
}
|
||||
|
||||
num = num * radix + (ecma_number_t) digit_value;
|
||||
num = num * (ecma_number_t) radix + (ecma_number_t) digit_value;
|
||||
}
|
||||
|
||||
return num;
|
||||
@@ -364,7 +375,8 @@ ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 st
|
||||
*/
|
||||
ecma_number_t
|
||||
ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
lit_utf8_size_t str_size) /**< string size */
|
||||
lit_utf8_size_t str_size, /**< string size */
|
||||
uint32_t options) /**< allowing underscore option bit */
|
||||
{
|
||||
/* TODO: Check license issues */
|
||||
|
||||
@@ -388,15 +400,15 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
{
|
||||
case LIT_CHAR_LOWERCASE_X :
|
||||
{
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 16);
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 16 | options);
|
||||
}
|
||||
case LIT_CHAR_LOWERCASE_O :
|
||||
{
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 8);
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 8 | options);
|
||||
}
|
||||
case LIT_CHAR_LOWERCASE_B :
|
||||
{
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 2);
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 2 | options);
|
||||
}
|
||||
default:
|
||||
{
|
||||
@@ -449,6 +461,13 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
digit_seen = true;
|
||||
digit_value = (*str_p - LIT_CHAR_0);
|
||||
}
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (*str_p == LIT_CHAR_UNDERSCORE && (options & ECMA_CONVERSION_ALLOW_UNDERSCORE))
|
||||
{
|
||||
str_p++;
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
else
|
||||
{
|
||||
break;
|
||||
@@ -491,6 +510,11 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
digit_seen = true;
|
||||
digit_value = (*str_p - LIT_CHAR_0);
|
||||
}
|
||||
else if (*str_p == LIT_CHAR_UNDERSCORE && (options & ECMA_CONVERSION_ALLOW_UNDERSCORE))
|
||||
{
|
||||
str_p++;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
@@ -550,6 +574,13 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
{
|
||||
digit_value = (*str_p - LIT_CHAR_0);
|
||||
}
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (*str_p == LIT_CHAR_UNDERSCORE && (options & ECMA_CONVERSION_ALLOW_UNDERSCORE))
|
||||
{
|
||||
str_p++;
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
else
|
||||
{
|
||||
return ecma_number_make_nan ();
|
||||
@@ -877,142 +908,6 @@ ecma_number_to_decimal (ecma_number_t num, /**< ecma-number */
|
||||
return ecma_errol0_dtoa ((double) num, out_digits_p, out_decimal_exp_p);
|
||||
} /* ecma_number_to_decimal */
|
||||
|
||||
/**
|
||||
* Calculate the number of digits from the given double value whithout franction part
|
||||
*
|
||||
* @return number of digits
|
||||
*/
|
||||
inline static int32_t JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_number_of_digits (double val) /**< ecma number */
|
||||
{
|
||||
JERRY_ASSERT (fabs (fmod (val, 1.0)) < EPSILON);
|
||||
int32_t exponent = 0;
|
||||
|
||||
while (val >= 1.0)
|
||||
{
|
||||
val /= 10.0;
|
||||
exponent++;
|
||||
}
|
||||
|
||||
return exponent;
|
||||
} /* ecma_number_of_digits */
|
||||
|
||||
/**
|
||||
* Convert double value to ASCII
|
||||
*/
|
||||
inline static void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_double_to_ascii (double val, /**< ecma number */
|
||||
lit_utf8_byte_t *buffer_p, /**< buffer to generate digits into */
|
||||
int32_t num_of_digits, /**< number of digits */
|
||||
int32_t *exp_p) /**< [out] exponent */
|
||||
{
|
||||
int32_t char_cnt = 0;
|
||||
|
||||
double divider = 10.0;
|
||||
double prev_residual;
|
||||
double mod_res = fmod (val, divider);
|
||||
|
||||
buffer_p[num_of_digits - 1 - char_cnt++] = (lit_utf8_byte_t) ((int) mod_res + '0');
|
||||
divider *= 10.0;
|
||||
prev_residual = mod_res;
|
||||
|
||||
while (char_cnt < num_of_digits)
|
||||
{
|
||||
mod_res = fmod (val, divider);
|
||||
double residual = mod_res - prev_residual;
|
||||
buffer_p[num_of_digits - 1 - char_cnt++] = (lit_utf8_byte_t) ((int) (residual / (divider / 10.0)) + '0');
|
||||
|
||||
divider *= 10.0;
|
||||
prev_residual = mod_res;
|
||||
}
|
||||
|
||||
*exp_p = char_cnt;
|
||||
} /* ecma_double_to_ascii */
|
||||
|
||||
/**
|
||||
* Double to binary floating-point number conversion
|
||||
*
|
||||
* @return number of generated digits
|
||||
*/
|
||||
static inline lit_utf8_size_t JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_double_to_binary_floating_point (double val, /**< ecma number */
|
||||
lit_utf8_byte_t *buffer_p, /**< buffer to generate digits into */
|
||||
int32_t *exp_p) /**< [out] exponent */
|
||||
{
|
||||
int32_t char_cnt = 0;
|
||||
double integer_part, fraction_part;
|
||||
|
||||
fraction_part = fmod (val, 1.0);
|
||||
integer_part = floor (val);
|
||||
int32_t num_of_digits = ecma_number_of_digits (integer_part);
|
||||
|
||||
if (fabs (integer_part) < EPSILON)
|
||||
{
|
||||
buffer_p[0] = '0';
|
||||
char_cnt++;
|
||||
}
|
||||
else if (num_of_digits <= 16) /* Ensure that integer_part is not rounded */
|
||||
{
|
||||
while (integer_part > 0.0)
|
||||
{
|
||||
buffer_p[num_of_digits - 1 - char_cnt++] = (lit_utf8_byte_t) ((int) fmod (integer_part, 10.0) + '0');
|
||||
integer_part = floor (integer_part / 10.0);
|
||||
}
|
||||
}
|
||||
else if (num_of_digits <= 21)
|
||||
{
|
||||
ecma_double_to_ascii (integer_part, buffer_p, num_of_digits, &char_cnt);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* According to ECMA-262 v5, 15.7.4.5, step 7: if x >= 10^21, then execution will continue with
|
||||
* ToString(x) so in this case no further conversions are required. Number 21 in the else if condition
|
||||
* above must be kept in sync with the number 21 in ecma_builtin_number_prototype_object_to_fixed
|
||||
* method, step 7. */
|
||||
*exp_p = num_of_digits;
|
||||
return 0;
|
||||
}
|
||||
|
||||
*exp_p = char_cnt;
|
||||
|
||||
while (fraction_part > 0 && char_cnt < ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER - 1)
|
||||
{
|
||||
fraction_part *= 10;
|
||||
double tmp = fraction_part;
|
||||
fraction_part = fmod (fraction_part, 1.0);
|
||||
integer_part = floor (tmp);
|
||||
buffer_p[char_cnt++] = (lit_utf8_byte_t) ('0' + (int) integer_part);
|
||||
}
|
||||
|
||||
buffer_p[char_cnt] = '\0';
|
||||
|
||||
return (lit_utf8_size_t) (char_cnt - *exp_p);
|
||||
} /* ecma_double_to_binary_floating_point */
|
||||
|
||||
/**
|
||||
* Perform conversion of ecma-number to equivalent binary floating-point number representation with decimal exponent.
|
||||
*
|
||||
* Note:
|
||||
* The calculated values correspond to s, n, k parameters in ECMA-262 v5, 9.8.1, item 5:
|
||||
* - parameter out_digits_p corresponds to s, the digits of the number;
|
||||
* - parameter out_decimal_exp_p corresponds to n, the decimal exponent;
|
||||
* - return value corresponds to k, the number of digits.
|
||||
*
|
||||
* @return the number of digits
|
||||
*/
|
||||
lit_utf8_size_t
|
||||
ecma_number_to_binary_floating_point_number (ecma_number_t num, /**< ecma-number */
|
||||
lit_utf8_byte_t *out_digits_p, /**< [out] buffer to fill with digits */
|
||||
int32_t *out_decimal_exp_p) /**< [out] decimal exponent */
|
||||
{
|
||||
JERRY_ASSERT (!ecma_number_is_nan (num));
|
||||
JERRY_ASSERT (!ecma_number_is_zero (num));
|
||||
JERRY_ASSERT (!ecma_number_is_infinity (num));
|
||||
JERRY_ASSERT (!ecma_number_is_negative (num));
|
||||
|
||||
return ecma_double_to_binary_floating_point ((double) num, out_digits_p, out_decimal_exp_p);
|
||||
} /* ecma_number_to_binary_floating_point_number */
|
||||
|
||||
/**
|
||||
* Convert ecma-number to zero-terminated string
|
||||
*
|
||||
|
||||
@@ -133,7 +133,7 @@ ecma_divide_high_prec_by_10 (ecma_high_prec_t *hp_data_p) /**< [in, out] high-pr
|
||||
*
|
||||
* @return number of generated digits
|
||||
*/
|
||||
inline lit_utf8_size_t JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline lit_utf8_size_t JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_errol0_dtoa (double val, /**< ecma number */
|
||||
lit_utf8_byte_t *buffer_p, /**< buffer to generate digits into */
|
||||
int32_t *exp_p) /**< [out] exponent */
|
||||
|
||||
@@ -38,7 +38,7 @@ ecma_create_native_pointer_property (ecma_object_t *obj_p, /**< object to create
|
||||
void *native_p, /**< native pointer */
|
||||
void *info_p) /**< native pointer's type info */
|
||||
{
|
||||
ecma_string_t *name_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
|
||||
ecma_string_t *name_p = ecma_get_internal_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
|
||||
|
||||
if (ecma_op_object_is_fast_array (obj_p))
|
||||
{
|
||||
@@ -54,12 +54,9 @@ ecma_create_native_pointer_property (ecma_object_t *obj_p, /**< object to create
|
||||
if (property_p == NULL)
|
||||
{
|
||||
ecma_property_value_t *value_p;
|
||||
value_p = ecma_create_named_data_property (obj_p, name_p, ECMA_PROPERTY_CONFIGURABLE_WRITABLE, &property_p);
|
||||
|
||||
ECMA_CONVERT_DATA_PROPERTY_TO_INTERNAL_PROPERTY (property_p);
|
||||
ECMA_CREATE_INTERNAL_PROPERTY (obj_p, name_p, property_p, value_p);
|
||||
|
||||
native_pointer_p = jmem_heap_alloc_block (sizeof (ecma_native_pointer_t));
|
||||
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (value_p->value, native_pointer_p);
|
||||
}
|
||||
else
|
||||
@@ -121,7 +118,7 @@ ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ecma_string_t *name_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
|
||||
ecma_string_t *name_p = ecma_get_internal_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
|
||||
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
|
||||
|
||||
if (property_p == NULL)
|
||||
@@ -169,7 +166,7 @@ ecma_delete_native_pointer_property (ecma_object_t *obj_p, /**< object to delete
|
||||
return false;
|
||||
}
|
||||
|
||||
ecma_string_t *name_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
|
||||
ecma_string_t *name_p = ecma_get_internal_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
|
||||
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
|
||||
|
||||
if (property_p == NULL)
|
||||
|
||||
@@ -48,7 +48,7 @@ JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint32_t),
|
||||
*
|
||||
* @return ecma-number with specified sign, biased_exponent and fraction
|
||||
*/
|
||||
static ecma_number_t
|
||||
ecma_number_t
|
||||
ecma_number_pack (bool sign, /**< sign */
|
||||
uint32_t biased_exp, /**< biased exponent */
|
||||
uint64_t fraction) /**< fraction */
|
||||
@@ -68,7 +68,7 @@ ecma_number_pack (bool sign, /**< sign */
|
||||
/**
|
||||
* Unpacking sign, fraction and biased exponent from ecma-number
|
||||
*/
|
||||
static void
|
||||
void
|
||||
ecma_number_unpack (ecma_number_t num, /**< ecma-number */
|
||||
bool *sign_p, /**< [out] sign (optional) */
|
||||
uint32_t *biased_exp_p, /**< [out] biased exponent (optional) */
|
||||
@@ -111,7 +111,7 @@ JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint64_t),
|
||||
*
|
||||
* @return ecma-number with specified sign, biased_exponent and fraction
|
||||
*/
|
||||
static ecma_number_t
|
||||
ecma_number_t
|
||||
ecma_number_pack (bool sign, /**< sign */
|
||||
uint32_t biased_exp, /**< biased exponent */
|
||||
uint64_t fraction) /**< fraction */
|
||||
@@ -131,7 +131,7 @@ ecma_number_pack (bool sign, /**< sign */
|
||||
/**
|
||||
* Unpacking sign, fraction and biased exponent from ecma-number
|
||||
*/
|
||||
static void
|
||||
void
|
||||
ecma_number_unpack (ecma_number_t num, /**< ecma-number */
|
||||
bool *sign_p, /**< [out] sign (optional) */
|
||||
uint32_t *biased_exp_p, /**< [out] biased exponent (optional) */
|
||||
@@ -282,7 +282,7 @@ ecma_number_make_infinity (bool sign) /**< true - for negative Infinity,
|
||||
* @return true - if sign bit of ecma-number is set
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_number_is_negative (ecma_number_t num) /**< ecma-number */
|
||||
{
|
||||
JERRY_ASSERT (!ecma_number_is_nan (num));
|
||||
@@ -342,7 +342,7 @@ ecma_number_is_finite (ecma_number_t num) /**< ecma-number */
|
||||
{
|
||||
#if defined (__GNUC__) || defined (__clang__)
|
||||
return __builtin_isfinite (num);
|
||||
#elif defined (WIN32)
|
||||
#elif defined (_WIN32)
|
||||
return isfinite (num);
|
||||
#else
|
||||
return !ecma_number_is_nan (num) && !ecma_number_is_infinity (num);
|
||||
@@ -688,7 +688,7 @@ ecma_number_pow (ecma_number_t x, /**< left operand */
|
||||
*
|
||||
* @return number - result of multiplication.
|
||||
*/
|
||||
inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_integer_multiply (ecma_integer_value_t left_integer, /**< left operand */
|
||||
ecma_integer_value_t right_integer) /**< right operand */
|
||||
{
|
||||
@@ -729,13 +729,11 @@ ecma_number_parse_int (const lit_utf8_byte_t *string_buff, /**< routine's first
|
||||
return ecma_make_nan_value ();
|
||||
}
|
||||
|
||||
const lit_utf8_byte_t *string_curr_p = string_buff;
|
||||
/* 2. Remove leading whitespace. */
|
||||
|
||||
/* 2. Remove leading whitespace. */
|
||||
ecma_string_trim_helper (&string_curr_p, &string_buff_size);
|
||||
|
||||
const lit_utf8_byte_t *string_end_p = string_curr_p + string_buff_size;
|
||||
const lit_utf8_byte_t *start_p = string_curr_p;
|
||||
const lit_utf8_byte_t *string_end_p = string_buff + string_buff_size;
|
||||
const lit_utf8_byte_t *start_p = ecma_string_trim_front (string_buff, string_end_p);
|
||||
const lit_utf8_byte_t *string_curr_p = start_p;
|
||||
const lit_utf8_byte_t *end_p = string_end_p;
|
||||
|
||||
if (string_curr_p >= string_end_p)
|
||||
@@ -765,11 +763,11 @@ ecma_number_parse_int (const lit_utf8_byte_t *string_buff, /**< routine's first
|
||||
|
||||
/* 6. */
|
||||
ecma_number_t radix_num;
|
||||
radix = ecma_get_number (radix, &radix_num);
|
||||
radix = ecma_op_to_number (radix, &radix_num);
|
||||
|
||||
if (!ecma_is_value_empty (radix))
|
||||
if (ECMA_IS_VALUE_ERROR (radix))
|
||||
{
|
||||
return radix;
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
int32_t rad = ecma_number_to_int32 (radix_num);
|
||||
@@ -906,13 +904,11 @@ ecma_number_parse_float (const lit_utf8_byte_t *string_buff, /**< routine's firs
|
||||
return ecma_make_nan_value ();
|
||||
}
|
||||
|
||||
const lit_utf8_byte_t *str_curr_p = string_buff;
|
||||
|
||||
/* 2. Remove leading whitespace. */
|
||||
ecma_string_trim_helper (&str_curr_p, &string_buff_size);
|
||||
|
||||
const lit_utf8_byte_t *str_end_p = str_curr_p + string_buff_size;
|
||||
const lit_utf8_byte_t *start_p = str_curr_p;
|
||||
const lit_utf8_byte_t *str_end_p = string_buff + string_buff_size;
|
||||
const lit_utf8_byte_t *start_p = ecma_string_trim_front (string_buff, str_end_p);
|
||||
const lit_utf8_byte_t *str_curr_p = start_p;
|
||||
const lit_utf8_byte_t *end_p = str_end_p;
|
||||
|
||||
bool sign = false;
|
||||
@@ -1063,7 +1059,7 @@ ecma_number_parse_float (const lit_utf8_byte_t *string_buff, /**< routine's firs
|
||||
}
|
||||
|
||||
/* 5. */
|
||||
ecma_number_t ret_num = ecma_utf8_string_to_number (start_p, (lit_utf8_size_t) (end_p - start_p));
|
||||
ecma_number_t ret_num = ecma_utf8_string_to_number (start_p, (lit_utf8_size_t) (end_p - start_p), 0);
|
||||
|
||||
if (sign)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -56,6 +56,13 @@ JERRY_STATIC_ASSERT ((ECMA_VALUE_FALSE | (1 << ECMA_DIRECT_SHIFT)) == ECMA_VALUE
|
||||
&& ECMA_VALUE_FALSE != ECMA_VALUE_TRUE,
|
||||
only_the_lowest_bit_must_be_different_for_simple_value_true_and_false);
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_NULL_POINTER == (ECMA_BIGINT_ZERO & ~(ecma_value_t) ECMA_VALUE_TYPE_MASK),
|
||||
ecma_bigint_zero_must_be_encoded_as_null_pointer);
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
@@ -121,7 +128,7 @@ ecma_get_pointer_from_ecma_value (ecma_value_t value) /**< value */
|
||||
* @return true - if the value is a direct value,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_direct (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT);
|
||||
@@ -133,7 +140,7 @@ ecma_is_value_direct (ecma_value_t value) /**< ecma value */
|
||||
* @return true - if the value is a simple value,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_simple (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return (value & ECMA_DIRECT_TYPE_MASK) == ECMA_DIRECT_TYPE_SIMPLE_VALUE;
|
||||
@@ -158,7 +165,7 @@ ecma_is_value_equal_to_simple_value (ecma_value_t value, /**< ecma value */
|
||||
* @return true - if the value contains implementation-defined empty simple value,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_empty (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_EMPTY);
|
||||
@@ -170,7 +177,7 @@ ecma_is_value_empty (ecma_value_t value) /**< ecma value */
|
||||
* @return true - if the value contains ecma-undefined simple value,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_undefined (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_UNDEFINED);
|
||||
@@ -182,7 +189,7 @@ ecma_is_value_undefined (ecma_value_t value) /**< ecma value */
|
||||
* @return true - if the value contains ecma-null simple value,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_null (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_NULL);
|
||||
@@ -194,7 +201,7 @@ ecma_is_value_null (ecma_value_t value) /**< ecma value */
|
||||
* @return true - if the value contains ecma-true or ecma-false simple values,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_boolean (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return ecma_is_value_true (value | (1 << ECMA_DIRECT_SHIFT));
|
||||
@@ -206,7 +213,7 @@ ecma_is_value_boolean (ecma_value_t value) /**< ecma value */
|
||||
* @return true - if the value contains ecma-true simple value,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_true (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_TRUE);
|
||||
@@ -218,7 +225,7 @@ ecma_is_value_true (ecma_value_t value) /**< ecma value */
|
||||
* @return true - if the value contains ecma-false simple value,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_false (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_FALSE);
|
||||
@@ -230,7 +237,7 @@ ecma_is_value_false (ecma_value_t value) /**< ecma value */
|
||||
* @return true - if the value contains ecma-not-found simple value,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_found (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return value != ECMA_VALUE_NOT_FOUND;
|
||||
@@ -242,7 +249,7 @@ ecma_is_value_found (ecma_value_t value) /**< ecma value */
|
||||
* @return true - if the value contains ecma-array-hole simple value,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_array_hole (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return ecma_is_value_equal_to_simple_value (value, ECMA_VALUE_ARRAY_HOLE);
|
||||
@@ -254,7 +261,7 @@ ecma_is_value_array_hole (ecma_value_t value) /**< ecma value */
|
||||
* @return true - if the value contains an integer ecma-number value,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_integer_number (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return (value & ECMA_DIRECT_TYPE_MASK) == ECMA_DIRECT_TYPE_INTEGER_VALUE;
|
||||
@@ -266,7 +273,7 @@ ecma_is_value_integer_number (ecma_value_t value) /**< ecma value */
|
||||
* @return true - if both values contain integer ecma-number values,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_are_values_integer_numbers (ecma_value_t first_value, /**< first ecma value */
|
||||
ecma_value_t second_value) /**< second ecma value */
|
||||
{
|
||||
@@ -282,7 +289,7 @@ ecma_are_values_integer_numbers (ecma_value_t first_value, /**< first ecma value
|
||||
* @return true - if the value contains a floating-point ecma-number value,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_float_number (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_FLOAT);
|
||||
@@ -316,19 +323,52 @@ ecma_is_value_string (ecma_value_t value) /**< ecma value */
|
||||
return ((value & (ECMA_VALUE_TYPE_MASK - 0x4)) == ECMA_TYPE_STRING);
|
||||
} /* ecma_is_value_string */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/**
|
||||
* Check if the value is symbol.
|
||||
*
|
||||
* @return true - if the value contains symbol value,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_symbol (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_SYMBOL);
|
||||
#else /* ENABLED (JERRY_ESNEXT) */
|
||||
JERRY_UNUSED (value);
|
||||
return false;
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} /* ecma_is_value_symbol */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/**
|
||||
* Check if the value is a specific magic string.
|
||||
*
|
||||
* @return true - if the value the magic string value,
|
||||
* false - otherwise
|
||||
*/
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_magic_string (ecma_value_t value, /**< ecma value */
|
||||
lit_magic_string_id_t id) /**< magic string id */
|
||||
{
|
||||
return value == ecma_make_magic_string_value (id);
|
||||
} /* ecma_is_value_magic_string */
|
||||
|
||||
/**
|
||||
* Check if the value is bigint.
|
||||
*
|
||||
* @return true - if the value contains bigint value,
|
||||
* false - otherwise
|
||||
*/
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_bigint (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_BIGINT);
|
||||
#else /* !ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
JERRY_UNUSED (value);
|
||||
return false;
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
} /* ecma_is_value_bigint */
|
||||
|
||||
/**
|
||||
* Check if the value can be property name.
|
||||
@@ -336,14 +376,14 @@ ecma_is_value_symbol (ecma_value_t value) /**< ecma value */
|
||||
* @return true - if the value can be property name value,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_prop_name (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
return ecma_is_value_string (value) || ecma_is_value_symbol (value);
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
return ecma_is_value_string (value);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} /* ecma_is_value_prop_name */
|
||||
|
||||
/**
|
||||
@@ -352,7 +392,7 @@ ecma_is_value_prop_name (ecma_value_t value) /**< ecma value */
|
||||
* @return true - if the value contains direct ecma-string value,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_direct_string (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT_STRING);
|
||||
@@ -364,7 +404,7 @@ ecma_is_value_direct_string (ecma_value_t value) /**< ecma value */
|
||||
* @return true - if the value contains non-direct ecma-string value,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_non_direct_string (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_STRING);
|
||||
@@ -376,7 +416,7 @@ ecma_is_value_non_direct_string (ecma_value_t value) /**< ecma value */
|
||||
* @return true - if the value contains object value,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_object (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_OBJECT);
|
||||
@@ -388,7 +428,7 @@ ecma_is_value_object (ecma_value_t value) /**< ecma value */
|
||||
* @return true - if the value contains an error reference,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_error_reference (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_ERROR);
|
||||
@@ -406,7 +446,8 @@ ecma_check_value_type_is_spec_defined (ecma_value_t value) /**< ecma value */
|
||||
|| ecma_is_value_boolean (value)
|
||||
|| ecma_is_value_number (value)
|
||||
|| ecma_is_value_string (value)
|
||||
|| ECMA_ASSERT_VALUE_IS_SYMBOL (value)
|
||||
|| ecma_is_value_bigint (value)
|
||||
|| ecma_is_value_symbol (value)
|
||||
|| ecma_is_value_object (value));
|
||||
} /* ecma_check_value_type_is_spec_defined */
|
||||
|
||||
@@ -431,7 +472,7 @@ ecma_is_value_array (ecma_value_t arg) /**< argument */
|
||||
return ECMA_VALUE_TRUE;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_PROXY)
|
||||
#if ENABLED (JERRY_BUILTIN_PROXY)
|
||||
if (ECMA_OBJECT_IS_PROXY (arg_obj_p))
|
||||
{
|
||||
ecma_proxy_object_t *proxy_obj_p = (ecma_proxy_object_t *) arg_obj_p;
|
||||
@@ -444,7 +485,7 @@ ecma_is_value_array (ecma_value_t arg) /**< argument */
|
||||
|
||||
return ecma_is_value_array (proxy_obj_p->target);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_PROXY) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
|
||||
|
||||
return ECMA_VALUE_FALSE;
|
||||
} /* ecma_is_value_array */
|
||||
@@ -454,7 +495,7 @@ ecma_is_value_array (ecma_value_t arg) /**< argument */
|
||||
*
|
||||
* @return boolean ecma_value
|
||||
*/
|
||||
inline ecma_value_t JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_value_t JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_make_boolean_value (bool boolean_value) /**< raw bool value from which the ecma value will be created */
|
||||
{
|
||||
return boolean_value ? ECMA_VALUE_TRUE : ECMA_VALUE_FALSE;
|
||||
@@ -468,7 +509,7 @@ ecma_make_boolean_value (bool boolean_value) /**< raw bool value from which the
|
||||
*
|
||||
* @return ecma-value
|
||||
*/
|
||||
inline ecma_value_t JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_value_t JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_make_integer_value (ecma_integer_value_t integer_value) /**< integer number to be encoded */
|
||||
{
|
||||
JERRY_ASSERT (ECMA_IS_INTEGER_NUMBER (integer_value));
|
||||
@@ -530,6 +571,22 @@ ecma_is_number_equal_to_positive_zero (ecma_number_t ecma_number) /**< number */
|
||||
#endif /* !ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */
|
||||
} /* ecma_is_number_equal_to_positive_zero */
|
||||
|
||||
/**
|
||||
* Encode a property length number into an ecma-value
|
||||
*
|
||||
* @return ecma-value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_make_length_value (ecma_length_t number) /**< number to be encoded */
|
||||
{
|
||||
if (number <= ECMA_INTEGER_NUMBER_MAX)
|
||||
{
|
||||
return ecma_make_integer_value ((ecma_integer_value_t) number);
|
||||
}
|
||||
|
||||
return ecma_create_float_number ((ecma_number_t) number);
|
||||
} /* ecma_make_length_value */
|
||||
|
||||
/**
|
||||
* Encode a number into an ecma-value
|
||||
*
|
||||
@@ -587,13 +644,13 @@ ecma_make_uint32_value (uint32_t uint32_number) /**< uint32 number to be encoded
|
||||
*
|
||||
* @return ecma-value representation of the string argument
|
||||
*/
|
||||
inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_make_string_value (const ecma_string_t *ecma_string_p) /**< string to reference in value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_string_p != NULL);
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
JERRY_ASSERT (!ecma_prop_name_is_symbol ((ecma_string_t *) ecma_string_p));
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if ((((uintptr_t) ecma_string_p) & ECMA_VALUE_TYPE_MASK) != 0)
|
||||
{
|
||||
@@ -603,13 +660,13 @@ ecma_make_string_value (const ecma_string_t *ecma_string_p) /**< string to refer
|
||||
return ecma_pointer_to_ecma_value (ecma_string_p) | ECMA_TYPE_STRING;
|
||||
} /* ecma_make_string_value */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/**
|
||||
* Symbol value constructor
|
||||
*
|
||||
* @return ecma-value representation of the string argument
|
||||
*/
|
||||
inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_make_symbol_value (const ecma_string_t *ecma_symbol_p) /**< symbol to reference in value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_symbol_p != NULL);
|
||||
@@ -617,24 +674,24 @@ ecma_make_symbol_value (const ecma_string_t *ecma_symbol_p) /**< symbol to refer
|
||||
|
||||
return ecma_pointer_to_ecma_value (ecma_symbol_p) | ECMA_TYPE_SYMBOL;
|
||||
} /* ecma_make_symbol_value */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Property-name value constructor
|
||||
*
|
||||
* @return ecma-value representation of a property name argument
|
||||
*/
|
||||
inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_make_prop_name_value (const ecma_string_t *ecma_prop_name_p) /**< property name to reference in value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_prop_name_p != NULL);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (ecma_prop_name_is_symbol ((ecma_string_t *) ecma_prop_name_p))
|
||||
{
|
||||
return ecma_make_symbol_value (ecma_prop_name_p);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
return ecma_make_string_value (ecma_prop_name_p);
|
||||
} /* ecma_make_prop_name_value */
|
||||
@@ -644,7 +701,7 @@ ecma_make_prop_name_value (const ecma_string_t *ecma_prop_name_p) /**< property
|
||||
*
|
||||
* @return ecma-value representation of the string argument
|
||||
*/
|
||||
inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_make_magic_string_value (lit_magic_string_id_t id) /**< magic string id */
|
||||
{
|
||||
return (ecma_value_t) ECMA_CREATE_DIRECT_STRING (ECMA_DIRECT_STRING_MAGIC, (uintptr_t) id);
|
||||
@@ -655,7 +712,7 @@ ecma_make_magic_string_value (lit_magic_string_id_t id) /**< magic string id */
|
||||
*
|
||||
* @return ecma-value representation of the object argument
|
||||
*/
|
||||
inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_make_object_value (const ecma_object_t *object_p) /**< object to reference in value */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
@@ -668,20 +725,25 @@ ecma_make_object_value (const ecma_object_t *object_p) /**< object to reference
|
||||
*
|
||||
* @return ecma-value representation of the Error reference
|
||||
*/
|
||||
inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_make_error_reference_value (const ecma_error_reference_t *error_ref_p) /**< error reference */
|
||||
extern inline ecma_value_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_make_extended_primitive_value (const ecma_extended_primitive_t *primitve_p, /**< extended primitve value */
|
||||
uint32_t type) /**< ecma type of extended primitve value */
|
||||
{
|
||||
JERRY_ASSERT (error_ref_p != NULL);
|
||||
JERRY_ASSERT (primitve_p != NULL);
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
JERRY_ASSERT (primitve_p != ECMA_BIGINT_POINTER_TO_ZERO);
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
JERRY_ASSERT (type == ECMA_TYPE_BIGINT || type == ECMA_TYPE_ERROR);
|
||||
|
||||
return ecma_pointer_to_ecma_value (error_ref_p) | ECMA_TYPE_ERROR;
|
||||
} /* ecma_make_error_reference_value */
|
||||
return ecma_pointer_to_ecma_value (primitve_p) | type;
|
||||
} /* ecma_make_extended_primitive_value */
|
||||
|
||||
/**
|
||||
* Get integer value from an integer ecma value
|
||||
*
|
||||
* @return integer value
|
||||
*/
|
||||
inline ecma_integer_value_t JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_integer_value_t JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_integer_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_integer_number (value));
|
||||
@@ -694,7 +756,7 @@ ecma_get_integer_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return floating point value
|
||||
*/
|
||||
inline ecma_number_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_number_t JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_float_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_FLOAT);
|
||||
@@ -707,7 +769,7 @@ ecma_get_float_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return floating point value
|
||||
*/
|
||||
inline ecma_number_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_number_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_pointer_from_float_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_FLOAT);
|
||||
@@ -736,7 +798,7 @@ ecma_get_number_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the string pointer
|
||||
*/
|
||||
inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_string_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_string (value));
|
||||
@@ -749,27 +811,27 @@ ecma_get_string_from_value (ecma_value_t value) /**< ecma value */
|
||||
return (ecma_string_t *) ecma_get_pointer_from_ecma_value (value);
|
||||
} /* ecma_get_string_from_value */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/**
|
||||
* Get pointer to ecma-string from ecma value
|
||||
*
|
||||
* @return the string pointer
|
||||
*/
|
||||
inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_symbol_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_symbol (value));
|
||||
|
||||
return (ecma_string_t *) ecma_get_pointer_from_ecma_value (value);
|
||||
} /* ecma_get_symbol_from_value */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Get pointer to a property name from ecma value
|
||||
*
|
||||
* @return the string pointer
|
||||
*/
|
||||
inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_prop_name_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_prop_name (value));
|
||||
@@ -787,7 +849,7 @@ ecma_get_prop_name_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the pointer
|
||||
*/
|
||||
inline ecma_object_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_object_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_object_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_object (value));
|
||||
@@ -800,20 +862,24 @@ ecma_get_object_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the pointer
|
||||
*/
|
||||
inline ecma_error_reference_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_error_reference_from_value (ecma_value_t value) /**< ecma value */
|
||||
extern inline ecma_extended_primitive_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_extended_primitive_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_ERROR);
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
JERRY_ASSERT (value != ECMA_BIGINT_ZERO);
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_BIGINT
|
||||
|| ecma_get_value_type_field (value) == ECMA_TYPE_ERROR);
|
||||
|
||||
return (ecma_error_reference_t *) ecma_get_pointer_from_ecma_value (value);
|
||||
} /* ecma_get_error_reference_from_value */
|
||||
return (ecma_extended_primitive_t *) ecma_get_pointer_from_ecma_value (value);
|
||||
} /* ecma_get_extended_primitive_from_value */
|
||||
|
||||
/**
|
||||
* Invert a boolean value
|
||||
*
|
||||
* @return ecma value
|
||||
*/
|
||||
inline ecma_value_t JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_value_t JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_invert_boolean_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_boolean (value));
|
||||
@@ -842,13 +908,23 @@ ecma_copy_value (ecma_value_t value) /**< value description */
|
||||
ecma_ref_ecma_string (ecma_get_string_from_value (value));
|
||||
return value;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case ECMA_TYPE_SYMBOL:
|
||||
{
|
||||
ecma_ref_ecma_string (ecma_get_symbol_from_value (value));
|
||||
return value;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
case ECMA_TYPE_BIGINT:
|
||||
{
|
||||
if (value != ECMA_BIGINT_ZERO)
|
||||
{
|
||||
ecma_ref_extended_primitive (ecma_get_extended_primitive_from_value (value));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
case ECMA_TYPE_OBJECT:
|
||||
{
|
||||
ecma_ref_object (ecma_get_object_from_value (value));
|
||||
@@ -875,7 +951,7 @@ ecma_copy_value (ecma_value_t value) /**< value description */
|
||||
*
|
||||
* @return copy of the given value
|
||||
*/
|
||||
inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_fast_copy_value (ecma_value_t value) /**< value description */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT) ? value : ecma_copy_value (value);
|
||||
@@ -886,7 +962,7 @@ ecma_fast_copy_value (ecma_value_t value) /**< value description */
|
||||
*
|
||||
* @return copy of the given value
|
||||
*/
|
||||
inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_copy_value_if_not_object (ecma_value_t value) /**< value description */
|
||||
{
|
||||
if (!ecma_is_value_object (value))
|
||||
@@ -900,7 +976,7 @@ ecma_copy_value_if_not_object (ecma_value_t value) /**< value description */
|
||||
/**
|
||||
* Increase reference counter of a value if it is an object.
|
||||
*/
|
||||
inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_ref_if_object (ecma_value_t value) /**< value description */
|
||||
{
|
||||
if (ecma_is_value_object (value))
|
||||
@@ -912,7 +988,7 @@ ecma_ref_if_object (ecma_value_t value) /**< value description */
|
||||
/**
|
||||
* Decrease reference counter of a value if it is an object.
|
||||
*/
|
||||
inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_deref_if_object (ecma_value_t value) /**< value description */
|
||||
{
|
||||
if (ecma_is_value_object (value))
|
||||
@@ -1063,19 +1139,30 @@ ecma_free_value (ecma_value_t value) /**< value description */
|
||||
ecma_deref_ecma_string (string_p);
|
||||
break;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case ECMA_TYPE_SYMBOL:
|
||||
{
|
||||
ecma_deref_ecma_string (ecma_get_symbol_from_value (value));
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
case ECMA_TYPE_OBJECT:
|
||||
{
|
||||
ecma_deref_object (ecma_get_object_from_value (value));
|
||||
break;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
case ECMA_TYPE_BIGINT:
|
||||
{
|
||||
if (value != ECMA_BIGINT_ZERO)
|
||||
{
|
||||
ecma_deref_bigint (ecma_get_extended_primitive_from_value (value));
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
|
||||
default:
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT
|
||||
@@ -1096,7 +1183,7 @@ ecma_free_value (ecma_value_t value) /**< value description */
|
||||
* It also increases the binary size so it is recommended for
|
||||
* critical code paths only.
|
||||
*/
|
||||
inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_fast_free_value (ecma_value_t value) /**< value description */
|
||||
{
|
||||
if (ecma_get_value_type_field (value) != ECMA_TYPE_DIRECT)
|
||||
@@ -1117,10 +1204,19 @@ ecma_free_value_if_not_object (ecma_value_t value) /**< value description */
|
||||
}
|
||||
} /* ecma_free_value_if_not_object */
|
||||
|
||||
/**
|
||||
* Free an ecma-value object
|
||||
*/
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_free_object (ecma_value_t value) /**< value description */
|
||||
{
|
||||
ecma_deref_object (ecma_get_object_from_value (value));
|
||||
} /* ecma_free_object */
|
||||
|
||||
/**
|
||||
* Free an ecma-value number
|
||||
*/
|
||||
inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_free_number (ecma_value_t value) /**< value description */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_number (value));
|
||||
@@ -1169,12 +1265,18 @@ ecma_get_typeof_lit_id (ecma_value_t value) /**< input ecma value */
|
||||
{
|
||||
ret_value = LIT_MAGIC_STRING_STRING;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (ecma_is_value_symbol (value))
|
||||
{
|
||||
ret_value = LIT_MAGIC_STRING_SYMBOL;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
else if (ecma_is_value_bigint (value))
|
||||
{
|
||||
ret_value = LIT_MAGIC_STRING_BIGINT;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_object (value));
|
||||
|
||||
+222
-193
@@ -37,9 +37,6 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_PROPERTY_TYPE_MASK >= ECMA_PROPERTY_TYPE__MAX,
|
||||
ecma_property_types_must_be_lower_than_the_container_mask);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_OBJECT_TYPE_MASK >= ECMA_OBJECT_TYPE__MAX - 1,
|
||||
ecma_object_types_must_be_lower_than_the_container_mask);
|
||||
|
||||
@@ -58,8 +55,8 @@ JERRY_STATIC_ASSERT (ECMA_OBJECT_REF_ONE == (ECMA_OBJECT_FLAG_EXTENSIBLE << 1),
|
||||
JERRY_STATIC_ASSERT (((ECMA_OBJECT_MAX_REF + ECMA_OBJECT_REF_ONE) | (ECMA_OBJECT_REF_ONE - 1)) == UINT16_MAX,
|
||||
ecma_object_max_ref_does_not_fill_the_remaining_bits);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_PROPERTY_TYPE_DELETED == (ECMA_DIRECT_STRING_MAGIC << ECMA_PROPERTY_NAME_TYPE_SHIFT),
|
||||
ecma_property_type_deleted_must_have_magic_string_name_type);
|
||||
JERRY_STATIC_ASSERT (ECMA_PROPERTY_FLAGS_MASK == ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
ecma_property_flags_mask_must_use_the_configurable_enumerable_writable_flags);
|
||||
|
||||
/**
|
||||
* Create an object with specified prototype object
|
||||
@@ -139,12 +136,12 @@ ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< out
|
||||
ecma_object_t *binding_obj_p, /**< binding object */
|
||||
ecma_lexical_environment_type_t type) /**< type of the new lexical environment */
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
JERRY_ASSERT (type == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND
|
||||
|| type == ECMA_LEXICAL_ENVIRONMENT_HOME_OBJECT_BOUND);
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
JERRY_ASSERT (type == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
JERRY_ASSERT (binding_obj_p != NULL
|
||||
&& !ecma_is_lexical_environment (binding_obj_p));
|
||||
@@ -169,7 +166,7 @@ ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< out
|
||||
* @return true - if object is a lexical environment
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_PURE
|
||||
extern inline bool JERRY_ATTR_PURE
|
||||
ecma_is_lexical_environment (const ecma_object_t *object_p) /**< object or lexical environment */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
@@ -182,7 +179,7 @@ ecma_is_lexical_environment (const ecma_object_t *object_p) /**< object or lexic
|
||||
/**
|
||||
* Set value of [[Extensible]] object's internal property.
|
||||
*/
|
||||
inline void
|
||||
extern inline void
|
||||
ecma_op_ordinary_object_set_extensible (ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
@@ -196,7 +193,7 @@ ecma_op_ordinary_object_set_extensible (ecma_object_t *object_p) /**< object */
|
||||
*
|
||||
* @return type of the object (ecma_object_type_t)
|
||||
*/
|
||||
inline ecma_object_type_t JERRY_ATTR_PURE
|
||||
extern inline ecma_object_type_t JERRY_ATTR_PURE
|
||||
ecma_get_object_type (const ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
@@ -211,7 +208,7 @@ ecma_get_object_type (const ecma_object_t *object_p) /**< object */
|
||||
* @return true - if object is a built-in object
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_PURE
|
||||
extern inline bool JERRY_ATTR_PURE
|
||||
ecma_get_object_is_builtin (const ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
@@ -223,7 +220,7 @@ ecma_get_object_is_builtin (const ecma_object_t *object_p) /**< object */
|
||||
/**
|
||||
* Set flag indicating whether the object is a built-in object
|
||||
*/
|
||||
inline void
|
||||
extern inline void
|
||||
ecma_set_object_is_builtin (ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
@@ -239,7 +236,7 @@ ecma_set_object_is_builtin (ecma_object_t *object_p) /**< object */
|
||||
*
|
||||
* @return the ID of the built-in
|
||||
*/
|
||||
inline uint8_t
|
||||
extern inline uint8_t
|
||||
ecma_get_object_builtin_id (ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
if (!ecma_get_object_is_builtin (object_p))
|
||||
@@ -250,7 +247,7 @@ ecma_get_object_builtin_id (ecma_object_t *object_p) /**< object */
|
||||
ecma_built_in_props_t *built_in_props_p;
|
||||
ecma_object_type_t object_type = ecma_get_object_type (object_p);
|
||||
|
||||
if (object_type == ECMA_OBJECT_TYPE_CLASS || object_type == ECMA_OBJECT_TYPE_ARRAY)
|
||||
if (ECMA_BUILTIN_IS_EXTENDED_BUILT_IN (object_type))
|
||||
{
|
||||
built_in_props_p = &((ecma_extended_built_in_object_t *) object_p)->built_in;
|
||||
}
|
||||
@@ -267,7 +264,7 @@ ecma_get_object_builtin_id (ecma_object_t *object_p) /**< object */
|
||||
*
|
||||
* @return type of the lexical environment (ecma_lexical_environment_type_t)
|
||||
*/
|
||||
inline ecma_lexical_environment_type_t JERRY_ATTR_PURE
|
||||
extern inline ecma_lexical_environment_type_t JERRY_ATTR_PURE
|
||||
ecma_get_lex_env_type (const ecma_object_t *object_p) /**< lexical environment */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
@@ -281,17 +278,17 @@ ecma_get_lex_env_type (const ecma_object_t *object_p) /**< lexical environment *
|
||||
*
|
||||
* @return pointer to ecma object
|
||||
*/
|
||||
inline ecma_object_t *JERRY_ATTR_PURE
|
||||
extern inline ecma_object_t *JERRY_ATTR_PURE
|
||||
ecma_get_lex_env_binding_object (const ecma_object_t *object_p) /**< object-bound lexical environment */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_p));
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
JERRY_ASSERT (ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND
|
||||
|| ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_HOME_OBJECT_BOUND);
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
JERRY_ASSERT (ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
return ECMA_GET_NON_NULL_POINTER (ecma_object_t, object_p->u1.bound_object_cp);
|
||||
} /* ecma_get_lex_env_binding_object */
|
||||
@@ -335,7 +332,7 @@ ecma_clone_decl_lexical_environment (ecma_object_t *lex_env_p, /**< declarative
|
||||
{
|
||||
if (prop_iter_p->types[i] != ECMA_PROPERTY_TYPE_DELETED)
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_iter_p->types[i]) == ECMA_PROPERTY_TYPE_NAMEDDATA);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_RAW_DATA (prop_iter_p->types[i]));
|
||||
|
||||
uint8_t prop_attributes = (uint8_t) (prop_iter_p->types[i] & ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
|
||||
ecma_string_t *name_p = ecma_string_from_property_name (prop_iter_p->types[i], prop_pair_p->names_cp[i]);
|
||||
@@ -525,7 +522,7 @@ ecma_create_named_data_property (ecma_object_t *object_p, /**< object */
|
||||
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
|
||||
JERRY_ASSERT ((prop_attributes & ~ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE) == 0);
|
||||
|
||||
uint8_t type_and_flags = ECMA_PROPERTY_TYPE_NAMEDDATA | prop_attributes;
|
||||
uint8_t type_and_flags = ECMA_PROPERTY_FLAG_DATA | prop_attributes;
|
||||
|
||||
ecma_property_value_t value;
|
||||
value.value = ECMA_VALUE_UNDEFINED;
|
||||
@@ -553,7 +550,7 @@ ecma_create_named_accessor_property (ecma_object_t *object_p, /**< object */
|
||||
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
|
||||
JERRY_ASSERT ((prop_attributes & ~ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE) == 0);
|
||||
|
||||
uint8_t type_and_flags = ECMA_PROPERTY_TYPE_NAMEDACCESSOR | prop_attributes;
|
||||
uint8_t type_and_flags = prop_attributes;
|
||||
|
||||
ecma_property_value_t value;
|
||||
#if ENABLED (JERRY_CPOINTER_32_BIT)
|
||||
@@ -571,7 +568,7 @@ ecma_create_named_accessor_property (ecma_object_t *object_p, /**< object */
|
||||
} /* ecma_create_named_accessor_property */
|
||||
|
||||
/**
|
||||
* Find named data property or named access property in specified object.
|
||||
* Find named data property or named accessor property in a specified object.
|
||||
*
|
||||
* @return pointer to the property, if it is found,
|
||||
* NULL - otherwise.
|
||||
@@ -745,14 +742,16 @@ ecma_get_named_data_property (ecma_object_t *obj_p, /**< object to find property
|
||||
|
||||
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
|
||||
|
||||
JERRY_ASSERT (property_p != NULL
|
||||
&& ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA);
|
||||
JERRY_ASSERT (property_p != NULL && ECMA_PROPERTY_IS_RAW_DATA (*property_p));
|
||||
|
||||
return ECMA_PROPERTY_VALUE_PTR (property_p);
|
||||
} /* ecma_get_named_data_property */
|
||||
|
||||
/**
|
||||
* Free property values and change their type to deleted.
|
||||
*
|
||||
* Note:
|
||||
* internal properties are not supported
|
||||
*/
|
||||
void
|
||||
ecma_free_property (ecma_object_t *object_p, /**< object the property belongs to */
|
||||
@@ -760,33 +759,20 @@ ecma_free_property (ecma_object_t *object_p, /**< object the property belongs to
|
||||
ecma_property_t *property_p) /**< property */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL && property_p != NULL);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_RAW (*property_p));
|
||||
|
||||
switch (ECMA_PROPERTY_GET_TYPE (*property_p))
|
||||
if (*property_p & ECMA_PROPERTY_FLAG_DATA)
|
||||
{
|
||||
ecma_free_value_if_not_object (ECMA_PROPERTY_VALUE_PTR (property_p)->value);
|
||||
}
|
||||
else
|
||||
{
|
||||
case ECMA_PROPERTY_TYPE_NAMEDDATA:
|
||||
{
|
||||
ecma_free_value_if_not_object (ECMA_PROPERTY_VALUE_PTR (property_p)->value);
|
||||
break;
|
||||
}
|
||||
case ECMA_PROPERTY_TYPE_NAMEDACCESSOR:
|
||||
{
|
||||
#if ENABLED (JERRY_CPOINTER_32_BIT)
|
||||
ecma_getter_setter_pointers_t *getter_setter_pair_p;
|
||||
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t,
|
||||
ECMA_PROPERTY_VALUE_PTR (property_p)->getter_setter_pair_cp);
|
||||
jmem_pools_free (getter_setter_pair_p, sizeof (ecma_getter_setter_pointers_t));
|
||||
ecma_getter_setter_pointers_t *getter_setter_pair_p;
|
||||
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t,
|
||||
ECMA_PROPERTY_VALUE_PTR (property_p)->getter_setter_pair_cp);
|
||||
jmem_pools_free (getter_setter_pair_p, sizeof (ecma_getter_setter_pointers_t));
|
||||
#endif /* ENABLED (JERRY_CPOINTER_32_BIT) */
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_INTERNAL);
|
||||
|
||||
/* Must be a native pointer. */
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == ECMA_DIRECT_STRING_MAGIC
|
||||
&& name_cp >= LIT_FIRST_INTERNAL_MAGIC_STRING);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_LCACHE)
|
||||
@@ -846,7 +832,7 @@ ecma_delete_property (ecma_object_t *object_p, /**< object */
|
||||
{
|
||||
if ((prop_pair_p->values + i) == prop_value_p)
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (cur_prop_p->types[i]) != ECMA_PROPERTY_TYPE_SPECIAL);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (cur_prop_p->types[i]));
|
||||
|
||||
#if ENABLED (JERRY_PROPRETY_HASHMAP)
|
||||
if (hashmap_status == ECMA_PROPERTY_HASHMAP_DELETE_HAS_HASHMAP)
|
||||
@@ -911,7 +897,7 @@ ecma_delete_property (ecma_object_t *object_p, /**< object */
|
||||
static void
|
||||
ecma_assert_object_contains_the_property (const ecma_object_t *object_p, /**< ecma-object */
|
||||
const ecma_property_value_t *prop_value_p, /**< property value */
|
||||
ecma_property_types_t type) /**< expected property type */
|
||||
bool is_data) /**< property should be data property */
|
||||
{
|
||||
#ifndef JERRY_NDEBUG
|
||||
jmem_cpointer_t prop_iter_cp = object_p->u1.property_list_cp;
|
||||
@@ -936,7 +922,7 @@ ecma_assert_object_contains_the_property (const ecma_object_t *object_p, /**< ec
|
||||
{
|
||||
if ((prop_pair_p->values + i) == prop_value_p)
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_pair_p->header.types[i]) == type);
|
||||
JERRY_ASSERT (is_data == ((prop_pair_p->header.types[i] & ECMA_PROPERTY_FLAG_DATA) != 0));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -946,7 +932,7 @@ ecma_assert_object_contains_the_property (const ecma_object_t *object_p, /**< ec
|
||||
#else /* JERRY_NDEBUG */
|
||||
JERRY_UNUSED (object_p);
|
||||
JERRY_UNUSED (prop_value_p);
|
||||
JERRY_UNUSED (type);
|
||||
JERRY_UNUSED (is_data);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
} /* ecma_assert_object_contains_the_property */
|
||||
|
||||
@@ -956,12 +942,12 @@ ecma_assert_object_contains_the_property (const ecma_object_t *object_p, /**< ec
|
||||
* Note:
|
||||
* value previously stored in the property is freed
|
||||
*/
|
||||
inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_named_data_property_assign_value (ecma_object_t *obj_p, /**< object */
|
||||
ecma_property_value_t *prop_value_p, /**< property value reference */
|
||||
ecma_value_t value) /**< value to assign */
|
||||
{
|
||||
ecma_assert_object_contains_the_property (obj_p, prop_value_p, ECMA_PROPERTY_TYPE_NAMEDDATA);
|
||||
ecma_assert_object_contains_the_property (obj_p, prop_value_p, true);
|
||||
|
||||
ecma_value_assign_value (&prop_value_p->value, value);
|
||||
} /* ecma_named_data_property_assign_value */
|
||||
@@ -989,7 +975,7 @@ ecma_set_named_accessor_property_getter (ecma_object_t *object_p, /**< the prope
|
||||
ecma_property_value_t *prop_value_p, /**< property value reference */
|
||||
ecma_object_t *getter_p) /**< getter object */
|
||||
{
|
||||
ecma_assert_object_contains_the_property (object_p, prop_value_p, ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
ecma_assert_object_contains_the_property (object_p, prop_value_p, false);
|
||||
|
||||
#if ENABLED (JERRY_CPOINTER_32_BIT)
|
||||
ecma_getter_setter_pointers_t *getter_setter_pair_p;
|
||||
@@ -1009,7 +995,7 @@ ecma_set_named_accessor_property_setter (ecma_object_t *object_p, /**< the prope
|
||||
ecma_property_value_t *prop_value_p, /**< property value reference */
|
||||
ecma_object_t *setter_p) /**< setter object */
|
||||
{
|
||||
ecma_assert_object_contains_the_property (object_p, prop_value_p, ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
ecma_assert_object_contains_the_property (object_p, prop_value_p, false);
|
||||
|
||||
#if ENABLED (JERRY_CPOINTER_32_BIT)
|
||||
ecma_getter_setter_pointers_t *getter_setter_pair_p;
|
||||
@@ -1027,11 +1013,10 @@ ecma_set_named_accessor_property_setter (ecma_object_t *object_p, /**< the prope
|
||||
* @return true - property is writable,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_property_writable (ecma_property_t property) /**< property */
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_NAMEDDATA
|
||||
|| ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_VIRTUAL);
|
||||
JERRY_ASSERT (property & ECMA_PROPERTY_FLAG_DATA);
|
||||
|
||||
return (property & ECMA_PROPERTY_FLAG_WRITABLE) != 0;
|
||||
} /* ecma_is_property_writable */
|
||||
@@ -1043,7 +1028,7 @@ void
|
||||
ecma_set_property_writable_attr (ecma_property_t *property_p, /**< [in,out] property */
|
||||
bool is_writable) /**< new value for writable flag */
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_RAW_DATA (*property_p));
|
||||
|
||||
if (is_writable)
|
||||
{
|
||||
@@ -1061,12 +1046,10 @@ ecma_set_property_writable_attr (ecma_property_t *property_p, /**< [in,out] prop
|
||||
* @return true - property is enumerable,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_property_enumerable (ecma_property_t property) /**< property */
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_NAMEDDATA
|
||||
|| ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR
|
||||
|| ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_VIRTUAL);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (property));
|
||||
|
||||
return (property & ECMA_PROPERTY_FLAG_ENUMERABLE) != 0;
|
||||
} /* ecma_is_property_enumerable */
|
||||
@@ -1078,8 +1061,7 @@ void
|
||||
ecma_set_property_enumerable_attr (ecma_property_t *property_p, /**< [in,out] property */
|
||||
bool is_enumerable) /**< new value for enumerable flag */
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|
||||
|| ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_RAW (*property_p));
|
||||
|
||||
if (is_enumerable)
|
||||
{
|
||||
@@ -1097,12 +1079,10 @@ ecma_set_property_enumerable_attr (ecma_property_t *property_p, /**< [in,out] pr
|
||||
* @return true - property is configurable,
|
||||
* false - otherwise
|
||||
*/
|
||||
inline bool JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_property_configurable (ecma_property_t property) /**< property */
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_NAMEDDATA
|
||||
|| ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR
|
||||
|| ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_VIRTUAL);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (property));
|
||||
|
||||
return (property & ECMA_PROPERTY_FLAG_CONFIGURABLE) != 0;
|
||||
} /* ecma_is_property_configurable */
|
||||
@@ -1114,8 +1094,7 @@ void
|
||||
ecma_set_property_configurable_attr (ecma_property_t *property_p, /**< [in,out] property */
|
||||
bool is_configurable) /**< new value for configurable flag */
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|
||||
|| ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_RAW (*property_p));
|
||||
|
||||
if (is_configurable)
|
||||
{
|
||||
@@ -1134,12 +1113,10 @@ ecma_set_property_configurable_attr (ecma_property_t *property_p, /**< [in,out]
|
||||
*
|
||||
* @return true / false
|
||||
*/
|
||||
inline bool JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline bool JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_property_lcached (ecma_property_t *property_p) /**< property */
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|
||||
|| ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR
|
||||
|| ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_INTERNAL);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (*property_p));
|
||||
|
||||
return (*property_p & ECMA_PROPERTY_FLAG_LCACHED) != 0;
|
||||
} /* ecma_is_property_lcached */
|
||||
@@ -1147,13 +1124,11 @@ ecma_is_property_lcached (ecma_property_t *property_p) /**< property */
|
||||
/**
|
||||
* Set value of flag indicating whether the property is registered in LCache
|
||||
*/
|
||||
inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_set_property_lcached (ecma_property_t *property_p, /**< property */
|
||||
bool is_lcached) /**< new value for lcached flag */
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|
||||
|| ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR
|
||||
|| ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_INTERNAL);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (*property_p));
|
||||
|
||||
if (is_lcached)
|
||||
{
|
||||
@@ -1216,9 +1191,69 @@ ecma_free_property_descriptor (ecma_property_descriptor_t *prop_desc_p) /**< pro
|
||||
/**
|
||||
* The size of error reference must be 8 bytes to use jmem_pools_alloc().
|
||||
*/
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_error_reference_t) == 8,
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_extended_primitive_t) == 8,
|
||||
ecma_error_reference_size_must_be_8_bytes);
|
||||
|
||||
/**
|
||||
* Increase ref count of an extended primitve value.
|
||||
*/
|
||||
void
|
||||
ecma_ref_extended_primitive (ecma_extended_primitive_t *primitve_p) /**< extended primitve value */
|
||||
{
|
||||
if (JERRY_LIKELY (primitve_p->refs_and_type < ECMA_EXTENDED_PRIMITIVE_MAX_REF))
|
||||
{
|
||||
primitve_p->refs_and_type += ECMA_EXTENDED_PRIMITIVE_REF_ONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
jerry_fatal (ERR_REF_COUNT_LIMIT);
|
||||
}
|
||||
} /* ecma_ref_extended_primitive */
|
||||
|
||||
/**
|
||||
* Decrease ref count of an error reference.
|
||||
*/
|
||||
void
|
||||
ecma_deref_error_reference (ecma_extended_primitive_t *error_ref_p) /**< error reference */
|
||||
{
|
||||
JERRY_ASSERT (error_ref_p->refs_and_type >= ECMA_EXTENDED_PRIMITIVE_REF_ONE);
|
||||
|
||||
error_ref_p->refs_and_type -= ECMA_EXTENDED_PRIMITIVE_REF_ONE;
|
||||
|
||||
if (error_ref_p->refs_and_type < ECMA_EXTENDED_PRIMITIVE_REF_ONE)
|
||||
{
|
||||
ecma_free_value (error_ref_p->u.value);
|
||||
jmem_pools_free (error_ref_p, sizeof (ecma_extended_primitive_t));
|
||||
}
|
||||
} /* ecma_deref_error_reference */
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
|
||||
/**
|
||||
* Decrease ref count of a bigint value.
|
||||
*/
|
||||
void
|
||||
ecma_deref_bigint (ecma_extended_primitive_t *bigint_p) /**< bigint value */
|
||||
{
|
||||
JERRY_ASSERT (bigint_p->refs_and_type >= ECMA_EXTENDED_PRIMITIVE_REF_ONE);
|
||||
|
||||
bigint_p->refs_and_type -= ECMA_EXTENDED_PRIMITIVE_REF_ONE;
|
||||
|
||||
if (bigint_p->refs_and_type >= ECMA_EXTENDED_PRIMITIVE_REF_ONE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t size = ECMA_BIGINT_GET_SIZE (bigint_p);
|
||||
|
||||
JERRY_ASSERT (size > 0);
|
||||
|
||||
size_t mem_size = ECMA_BIGINT_GET_BYTE_SIZE (size) + sizeof (ecma_extended_primitive_t);
|
||||
jmem_heap_free_block (bigint_p, mem_size);
|
||||
} /* ecma_deref_bigint */
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
|
||||
/**
|
||||
* Create an error reference from a given value.
|
||||
*
|
||||
@@ -1231,11 +1266,13 @@ ecma_value_t
|
||||
ecma_create_error_reference (ecma_value_t value, /**< referenced value */
|
||||
bool is_exception) /**< error reference is an exception */
|
||||
{
|
||||
ecma_error_reference_t *error_ref_p = (ecma_error_reference_t *) jmem_pools_alloc (sizeof (ecma_error_reference_t));
|
||||
ecma_extended_primitive_t *error_ref_p;
|
||||
error_ref_p = (ecma_extended_primitive_t *) jmem_pools_alloc (sizeof (ecma_extended_primitive_t));
|
||||
|
||||
error_ref_p->refs_and_flags = ECMA_ERROR_REF_ONE | (is_exception ? 0 : ECMA_ERROR_REF_ABORT);
|
||||
error_ref_p->value = value;
|
||||
return ecma_make_error_reference_value (error_ref_p);
|
||||
error_ref_p->refs_and_type = (ECMA_EXTENDED_PRIMITIVE_REF_ONE
|
||||
| (is_exception ? ECMA_EXTENDED_PRIMITIVE_ERROR : ECMA_EXTENDED_PRIMITIVE_ABORT));
|
||||
error_ref_p->u.value = value;
|
||||
return ecma_make_extended_primitive_value (error_ref_p, ECMA_TYPE_ERROR);
|
||||
} /* ecma_create_error_reference */
|
||||
|
||||
/**
|
||||
@@ -1263,45 +1300,12 @@ ecma_create_error_reference_from_context (void)
|
||||
*
|
||||
* @return error reference value
|
||||
*/
|
||||
inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_create_error_object_reference (ecma_object_t *object_p) /**< referenced object */
|
||||
{
|
||||
return ecma_create_error_reference (ecma_make_object_value (object_p), true);
|
||||
} /* ecma_create_error_object_reference */
|
||||
|
||||
/**
|
||||
* Increase ref count of an error reference.
|
||||
*/
|
||||
void
|
||||
ecma_ref_error_reference (ecma_error_reference_t *error_ref_p) /**< error reference */
|
||||
{
|
||||
if (JERRY_LIKELY (error_ref_p->refs_and_flags < ECMA_ERROR_MAX_REF))
|
||||
{
|
||||
error_ref_p->refs_and_flags += ECMA_ERROR_REF_ONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
jerry_fatal (ERR_REF_COUNT_LIMIT);
|
||||
}
|
||||
} /* ecma_ref_error_reference */
|
||||
|
||||
/**
|
||||
* Decrease ref count of an error reference.
|
||||
*/
|
||||
void
|
||||
ecma_deref_error_reference (ecma_error_reference_t *error_ref_p) /**< error reference */
|
||||
{
|
||||
JERRY_ASSERT (error_ref_p->refs_and_flags >= ECMA_ERROR_REF_ONE);
|
||||
|
||||
error_ref_p->refs_and_flags -= ECMA_ERROR_REF_ONE;
|
||||
|
||||
if (error_ref_p->refs_and_flags < ECMA_ERROR_REF_ONE)
|
||||
{
|
||||
ecma_free_value (error_ref_p->value);
|
||||
jmem_pools_free (error_ref_p, sizeof (ecma_error_reference_t));
|
||||
}
|
||||
} /* ecma_deref_error_reference */
|
||||
|
||||
/**
|
||||
* Raise error from the given error reference.
|
||||
*
|
||||
@@ -1311,23 +1315,23 @@ void
|
||||
ecma_raise_error_from_error_reference (ecma_value_t value) /**< error reference */
|
||||
{
|
||||
JERRY_ASSERT (!jcontext_has_pending_exception () && !jcontext_has_pending_abort ());
|
||||
ecma_error_reference_t *error_ref_p = ecma_get_error_reference_from_value (value);
|
||||
ecma_extended_primitive_t *error_ref_p = ecma_get_extended_primitive_from_value (value);
|
||||
|
||||
JERRY_ASSERT (error_ref_p->refs_and_flags >= ECMA_ERROR_REF_ONE);
|
||||
JERRY_ASSERT (error_ref_p->refs_and_type >= ECMA_EXTENDED_PRIMITIVE_REF_ONE);
|
||||
|
||||
ecma_value_t referenced_value = error_ref_p->value;
|
||||
ecma_value_t referenced_value = error_ref_p->u.value;
|
||||
|
||||
jcontext_set_exception_flag (true);
|
||||
jcontext_set_abort_flag (error_ref_p->refs_and_flags & ECMA_ERROR_REF_ABORT);
|
||||
jcontext_set_abort_flag (ECMA_EXTENDED_PRIMITIVE_GET_TYPE (error_ref_p) == ECMA_EXTENDED_PRIMITIVE_ABORT);
|
||||
|
||||
if (error_ref_p->refs_and_flags >= 2 * ECMA_ERROR_REF_ONE)
|
||||
if (error_ref_p->refs_and_type >= 2 * ECMA_EXTENDED_PRIMITIVE_REF_ONE)
|
||||
{
|
||||
error_ref_p->refs_and_flags -= ECMA_ERROR_REF_ONE;
|
||||
error_ref_p->refs_and_type -= ECMA_EXTENDED_PRIMITIVE_REF_ONE;
|
||||
referenced_value = ecma_copy_value (referenced_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
jmem_pools_free (error_ref_p, sizeof (ecma_error_reference_t));
|
||||
jmem_pools_free (error_ref_p, sizeof (ecma_extended_primitive_t));
|
||||
}
|
||||
|
||||
JERRY_CONTEXT (error_value) = referenced_value;
|
||||
@@ -1357,7 +1361,8 @@ void
|
||||
ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
{
|
||||
JERRY_ASSERT (bytecode_p->refs > 0);
|
||||
JERRY_ASSERT (!(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION));
|
||||
JERRY_ASSERT (!CBC_IS_FUNCTION (bytecode_p->status_flags)
|
||||
|| !(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION));
|
||||
|
||||
bytecode_p->refs--;
|
||||
|
||||
@@ -1367,7 +1372,7 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
return;
|
||||
}
|
||||
|
||||
if (bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION)
|
||||
if (CBC_IS_FUNCTION (bytecode_p->status_flags))
|
||||
{
|
||||
ecma_value_t *literal_start_p = NULL;
|
||||
uint32_t literal_end;
|
||||
@@ -1438,17 +1443,17 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
}
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (bytecode_p->status_flags & CBC_CODE_FLAG_HAS_TAGGED_LITERALS)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (bytecode_p->status_flags & CBC_CODE_FLAGS_HAS_TAGGED_LITERALS)
|
||||
{
|
||||
ecma_collection_t *collection_p = ecma_compiled_code_get_tagged_template_collection (bytecode_p);
|
||||
|
||||
/* Since the objects in the tagged template collection are not strong referenced anymore by the compiled code
|
||||
we can treat them as 'new' objects. */
|
||||
JERRY_CONTEXT (ecma_gc_new_objects) += collection_p->item_count;
|
||||
ecma_collection_free (collection_p);
|
||||
JERRY_CONTEXT (ecma_gc_new_objects) += collection_p->item_count * 2;
|
||||
ecma_collection_free_template_literal (collection_p);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_MEM_STATS)
|
||||
jmem_stats_free_byte_code_bytes (((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG);
|
||||
@@ -1467,7 +1472,68 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG);
|
||||
} /* ecma_bytecode_deref */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/**
|
||||
* Resolve the position of the arguments list start of the compiled code
|
||||
*
|
||||
* @return start position of the arguments list start of the compiled code
|
||||
*/
|
||||
ecma_value_t *
|
||||
ecma_compiled_code_resolve_arguments_start (const ecma_compiled_code_t *bytecode_header_p) /**< compiled code */
|
||||
{
|
||||
JERRY_ASSERT (bytecode_header_p != NULL);
|
||||
|
||||
uint8_t *byte_p = (uint8_t *) bytecode_header_p;
|
||||
byte_p += ((size_t) bytecode_header_p->size) << JMEM_ALIGNMENT_LOG;
|
||||
|
||||
if (!(bytecode_header_p->status_flags & CBC_CODE_FLAGS_MAPPED_ARGUMENTS_NEEDED))
|
||||
{
|
||||
return ((ecma_value_t *) byte_p);
|
||||
}
|
||||
|
||||
if (JERRY_LIKELY (!(bytecode_header_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)))
|
||||
{
|
||||
return ((ecma_value_t *) byte_p) - ((cbc_uint8_arguments_t *) bytecode_header_p)->argument_end;
|
||||
}
|
||||
|
||||
return ((ecma_value_t *) byte_p) - ((cbc_uint16_arguments_t *) bytecode_header_p)->argument_end;
|
||||
} /* ecma_compiled_code_resolve_arguments_start */
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* Resolve the position of the function name of the compiled code
|
||||
*
|
||||
* @return position of the function name of the compiled code
|
||||
*/
|
||||
extern inline ecma_value_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_compiled_code_resolve_function_name (const ecma_compiled_code_t *bytecode_header_p) /**< compiled code */
|
||||
{
|
||||
JERRY_ASSERT (bytecode_header_p != NULL);
|
||||
ecma_value_t *base_p = ecma_compiled_code_resolve_arguments_start (bytecode_header_p);
|
||||
|
||||
if (CBC_FUNCTION_GET_TYPE (bytecode_header_p->status_flags) != CBC_FUNCTION_CONSTRUCTOR)
|
||||
{
|
||||
base_p--;
|
||||
}
|
||||
|
||||
return base_p;
|
||||
} /* ecma_compiled_code_resolve_function_name */
|
||||
|
||||
/**
|
||||
* Get the extended info from a byte code
|
||||
*
|
||||
* @return extended info value
|
||||
*/
|
||||
uint32_t
|
||||
ecma_compiled_code_resolve_extended_info (const ecma_compiled_code_t *bytecode_header_p) /**< compiled code */
|
||||
{
|
||||
JERRY_ASSERT (bytecode_header_p != NULL);
|
||||
JERRY_ASSERT (bytecode_header_p->status_flags & CBC_CODE_FLAGS_HAS_EXTENDED_INFO);
|
||||
|
||||
ecma_value_t *base_p = ecma_compiled_code_resolve_function_name (bytecode_header_p);
|
||||
return base_p[-1];
|
||||
} /* ecma_compiled_code_resolve_extended_info */
|
||||
|
||||
/**
|
||||
* Get the tagged template collection of the compiled code
|
||||
*
|
||||
@@ -1477,77 +1543,40 @@ ecma_collection_t *
|
||||
ecma_compiled_code_get_tagged_template_collection (const ecma_compiled_code_t *bytecode_header_p) /**< compiled code */
|
||||
{
|
||||
JERRY_ASSERT (bytecode_header_p != NULL);
|
||||
JERRY_ASSERT (bytecode_header_p->status_flags & CBC_CODE_FLAG_HAS_TAGGED_LITERALS);
|
||||
JERRY_ASSERT (bytecode_header_p->status_flags & CBC_CODE_FLAGS_HAS_TAGGED_LITERALS);
|
||||
|
||||
ecma_value_t *base_p = ecma_compiled_code_resolve_function_name (bytecode_header_p);
|
||||
int offset = (bytecode_header_p->status_flags & CBC_CODE_FLAGS_HAS_EXTENDED_INFO) ? -2 : -1;
|
||||
|
||||
#if ENABLED (JERRY_RESOURCE_NAME)
|
||||
base_p--;
|
||||
#endif /* ENABLED (JERRY_RESOURCE_NAME) */
|
||||
|
||||
return ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, base_p[-1]);
|
||||
return ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, base_p[offset]);
|
||||
} /* ecma_compiled_code_get_tagged_template_collection */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
#if ENABLED (JERRY_RESOURCE_NAME) || ENABLED (JERRY_ES2015)
|
||||
/**
|
||||
* Get the number of formal parameters of the compiled code
|
||||
*
|
||||
* @return number of formal parameters
|
||||
*/
|
||||
ecma_length_t
|
||||
ecma_compiled_code_get_formal_params (const ecma_compiled_code_t *bytecode_header_p) /**< compiled code */
|
||||
{
|
||||
if (!(bytecode_header_p->status_flags & CBC_CODE_FLAGS_MAPPED_ARGUMENTS_NEEDED))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (bytecode_header_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
|
||||
{
|
||||
return ((cbc_uint16_arguments_t *) bytecode_header_p)->argument_end;
|
||||
}
|
||||
|
||||
return ((cbc_uint8_arguments_t *) bytecode_header_p)->argument_end;
|
||||
} /* ecma_compiled_code_get_formal_params */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Resolve the position of the arguments list start of the compiled code
|
||||
* Get the resource name of a compiled code.
|
||||
*
|
||||
* @return start position of the arguments list start of the compiled code
|
||||
* @return resource name value
|
||||
*/
|
||||
ecma_value_t *
|
||||
ecma_compiled_code_resolve_arguments_start (const ecma_compiled_code_t *bytecode_header_p)
|
||||
ecma_value_t
|
||||
ecma_get_resource_name (const ecma_compiled_code_t *bytecode_p) /**< compiled code */
|
||||
{
|
||||
JERRY_ASSERT (bytecode_header_p != NULL);
|
||||
|
||||
uint8_t *byte_p = (uint8_t *) bytecode_header_p;
|
||||
byte_p += ((size_t) bytecode_header_p->size) << JMEM_ALIGNMENT_LOG;
|
||||
|
||||
return ((ecma_value_t *) byte_p) - ecma_compiled_code_get_formal_params (bytecode_header_p);
|
||||
} /* ecma_compiled_code_resolve_arguments_start */
|
||||
|
||||
/**
|
||||
* Resolve the position of the function name of the compiled code
|
||||
*
|
||||
* @return position of the function name of the compiled code
|
||||
*/
|
||||
inline ecma_value_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_compiled_code_resolve_function_name (const ecma_compiled_code_t *bytecode_header_p)
|
||||
{
|
||||
JERRY_ASSERT (bytecode_header_p != NULL);
|
||||
ecma_value_t *base_p = ecma_compiled_code_resolve_arguments_start (bytecode_header_p);
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (!(bytecode_header_p->status_flags & CBC_CODE_FLAGS_CLASS_CONSTRUCTOR))
|
||||
#if ENABLED (JERRY_RESOURCE_NAME)
|
||||
if (bytecode_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
|
||||
{
|
||||
base_p--;
|
||||
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) bytecode_p;
|
||||
ecma_value_t *lit_pool_p = (ecma_value_t *) ((uint8_t *) bytecode_p + sizeof (cbc_uint16_arguments_t));
|
||||
return lit_pool_p[args_p->const_literal_end - args_p->register_end - 1];
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
return base_p;
|
||||
} /* ecma_compiled_code_resolve_function_name */
|
||||
#endif /* ENABLED (JERRY_RESOURCE_NAME) || ENABLED (JERRY_ES2015) */
|
||||
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) bytecode_p;
|
||||
ecma_value_t *lit_pool_p = (ecma_value_t *) ((uint8_t *) bytecode_p + sizeof (cbc_uint8_arguments_t));
|
||||
return lit_pool_p[args_p->const_literal_end - args_p->register_end - 1];
|
||||
#else /* !ENABLED (JERRY_RESOURCE_NAME) */
|
||||
JERRY_UNUSED (bytecode_p);
|
||||
return ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON);
|
||||
#endif /* !ENABLED (JERRY_RESOURCE_NAME) */
|
||||
} /* ecma_get_resource_name */
|
||||
|
||||
#if (JERRY_STACK_LIMIT != 0)
|
||||
/**
|
||||
|
||||
@@ -96,6 +96,11 @@ typedef enum
|
||||
ECMA_STRING_FLAG_MUST_BE_FREED = (1 << 3), /**< The returned buffer must be freed */
|
||||
} ecma_string_flag_t;
|
||||
|
||||
/**
|
||||
* Underscore is ignored when this option is passed.
|
||||
*/
|
||||
#define ECMA_CONVERSION_ALLOW_UNDERSCORE 0x1
|
||||
|
||||
/**
|
||||
* Convert ecma-string's contents to a cesu-8 string and put it into a buffer.
|
||||
*/
|
||||
@@ -127,13 +132,13 @@ typedef enum
|
||||
* Set an internal property value from pointer.
|
||||
*/
|
||||
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) \
|
||||
(field) = ((ecma_value_t) pointer)
|
||||
((field) = ((ecma_value_t) pointer))
|
||||
|
||||
/**
|
||||
* Set an internal property value from pointer. Pointer can be NULL.
|
||||
*/
|
||||
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) \
|
||||
(field) = ((ecma_value_t) pointer)
|
||||
((field) = ((ecma_value_t) pointer))
|
||||
|
||||
/**
|
||||
* Convert an internal property value to pointer.
|
||||
@@ -147,6 +152,12 @@ typedef enum
|
||||
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) \
|
||||
((type *) field)
|
||||
|
||||
/**
|
||||
* Checks whether an internal property is NULL.
|
||||
*/
|
||||
#define ECMA_IS_INTERNAL_VALUE_NULL(field) \
|
||||
((field) == ((ecma_value_t) NULL))
|
||||
|
||||
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
/**
|
||||
@@ -173,6 +184,12 @@ typedef enum
|
||||
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) \
|
||||
ECMA_GET_POINTER (type, field)
|
||||
|
||||
/**
|
||||
* Checks whether an internal property is NULL.
|
||||
*/
|
||||
#define ECMA_IS_INTERNAL_VALUE_NULL(field) \
|
||||
((field) == ((ecma_value_t) JMEM_CP_NULL))
|
||||
|
||||
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
/**
|
||||
@@ -180,18 +197,6 @@ typedef enum
|
||||
*/
|
||||
#define ECMA_BOOL_TO_BITFIELD(x) ((x) ? 1 : 0)
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/**
|
||||
* JERRY_ASSERT compatible macro for checking whether the given ecma-value is symbol
|
||||
*/
|
||||
#define ECMA_ASSERT_VALUE_IS_SYMBOL(value) (ecma_is_value_symbol ((value)))
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
/**
|
||||
* JERRY_ASSERT compatible macro for checking whether the given ecma-value is symbol
|
||||
*/
|
||||
#define ECMA_ASSERT_VALUE_IS_SYMBOL(value) (false)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/**
|
||||
* Check whether the given type is ECMA_OBJECT_TYPE_PROXY
|
||||
*
|
||||
@@ -204,11 +209,11 @@ typedef enum
|
||||
*
|
||||
* @param obj_p ecma-object
|
||||
*/
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_PROXY)
|
||||
#if ENABLED (JERRY_BUILTIN_PROXY)
|
||||
#define ECMA_OBJECT_IS_PROXY(obj_p) (ECMA_OBJECT_TYPE_IS_PROXY (ecma_get_object_type ((obj_p))))
|
||||
#else /* !ENABLED (JERRY_ES2015_BUILTIN_PROXY) */
|
||||
#else /* !ENABLED (JERRY_BUILTIN_PROXY) */
|
||||
#define ECMA_OBJECT_IS_PROXY(obj_p) (false)
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_PROXY) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
|
||||
|
||||
/* ecma-helpers-value.c */
|
||||
ecma_type_t JERRY_ATTR_CONST ecma_get_value_type_field (ecma_value_t value);
|
||||
@@ -228,9 +233,9 @@ bool JERRY_ATTR_CONST ecma_are_values_integer_numbers (ecma_value_t first_value,
|
||||
bool JERRY_ATTR_CONST ecma_is_value_float_number (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_number (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_string (ecma_value_t value);
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
bool JERRY_ATTR_CONST ecma_is_value_symbol (ecma_value_t value);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
bool JERRY_ATTR_CONST ecma_is_value_magic_string (ecma_value_t value, lit_magic_string_id_t id);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_bigint (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_prop_name (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_direct_string (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_non_direct_string (ecma_value_t value);
|
||||
@@ -244,28 +249,30 @@ ecma_value_t JERRY_ATTR_CONST ecma_make_boolean_value (bool boolean_value);
|
||||
ecma_value_t JERRY_ATTR_CONST ecma_make_integer_value (ecma_integer_value_t integer_value);
|
||||
ecma_value_t ecma_make_nan_value (void);
|
||||
ecma_value_t ecma_make_float_value (ecma_number_t *ecma_num_p);
|
||||
ecma_value_t ecma_make_length_value (ecma_length_t length);
|
||||
ecma_value_t ecma_make_number_value (ecma_number_t ecma_number);
|
||||
ecma_value_t ecma_make_int32_value (int32_t int32_number);
|
||||
ecma_value_t ecma_make_uint32_value (uint32_t uint32_number);
|
||||
ecma_value_t JERRY_ATTR_PURE ecma_make_string_value (const ecma_string_t *ecma_string_p);
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ecma_value_t JERRY_ATTR_PURE ecma_make_symbol_value (const ecma_string_t *ecma_symbol_p);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
ecma_value_t JERRY_ATTR_PURE ecma_make_prop_name_value (const ecma_string_t *ecma_prop_name_p);
|
||||
ecma_value_t JERRY_ATTR_PURE ecma_make_magic_string_value (lit_magic_string_id_t id);
|
||||
ecma_value_t JERRY_ATTR_PURE ecma_make_object_value (const ecma_object_t *object_p);
|
||||
ecma_value_t JERRY_ATTR_PURE ecma_make_error_reference_value (const ecma_error_reference_t *error_ref_p);
|
||||
ecma_value_t JERRY_ATTR_PURE ecma_make_extended_primitive_value (const ecma_extended_primitive_t *primitve_p,
|
||||
uint32_t type);
|
||||
ecma_integer_value_t JERRY_ATTR_CONST ecma_get_integer_from_value (ecma_value_t value);
|
||||
ecma_number_t JERRY_ATTR_PURE ecma_get_float_from_value (ecma_value_t value);
|
||||
ecma_number_t * ecma_get_pointer_from_float_value (ecma_value_t value);
|
||||
ecma_number_t JERRY_ATTR_PURE ecma_get_number_from_value (ecma_value_t value);
|
||||
ecma_string_t JERRY_ATTR_PURE *ecma_get_string_from_value (ecma_value_t value);
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ecma_string_t JERRY_ATTR_PURE *ecma_get_symbol_from_value (ecma_value_t value);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
ecma_string_t JERRY_ATTR_PURE *ecma_get_prop_name_from_value (ecma_value_t value);
|
||||
ecma_object_t JERRY_ATTR_PURE *ecma_get_object_from_value (ecma_value_t value);
|
||||
ecma_error_reference_t JERRY_ATTR_PURE *ecma_get_error_reference_from_value (ecma_value_t value);
|
||||
ecma_extended_primitive_t JERRY_ATTR_PURE *ecma_get_extended_primitive_from_value (ecma_value_t value);
|
||||
ecma_value_t JERRY_ATTR_CONST ecma_invert_boolean_value (ecma_value_t value);
|
||||
ecma_value_t ecma_copy_value (ecma_value_t value);
|
||||
ecma_value_t ecma_fast_copy_value (ecma_value_t value);
|
||||
@@ -278,31 +285,36 @@ void ecma_value_assign_number (ecma_value_t *value_p, ecma_number_t ecma_number)
|
||||
void ecma_free_value (ecma_value_t value);
|
||||
void ecma_fast_free_value (ecma_value_t value);
|
||||
void ecma_free_value_if_not_object (ecma_value_t value);
|
||||
void ecma_free_object (ecma_value_t value);
|
||||
void ecma_free_number (ecma_value_t value);
|
||||
lit_magic_string_id_t ecma_get_typeof_lit_id (ecma_value_t value);
|
||||
|
||||
/* ecma-helpers-string.c */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ecma_string_t *ecma_new_symbol_from_descriptor_string (ecma_value_t string_desc);
|
||||
bool ecma_prop_name_is_symbol (ecma_string_t *string_p);
|
||||
uint32_t ecma_op_advance_string_index (ecma_string_t *str_p, uint32_t index, bool is_unicode);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_MAP) || ENABLED (JERRY_ES2015_BUILTIN_SET)
|
||||
ecma_length_t ecma_op_advance_string_index (ecma_string_t *str_p, ecma_length_t index_num, bool is_unicode);
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
#if ENABLED (JERRY_BUILTIN_MAP) || ENABLED (JERRY_BUILTIN_SET)
|
||||
ecma_string_t *ecma_new_map_key_string (ecma_value_t value);
|
||||
bool ecma_prop_name_is_map_key (ecma_string_t *string_p);
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_MAP) || ENABLED (JERRY_ES2015_BUILTIN_SET) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_MAP) || ENABLED (JERRY_BUILTIN_SET) */
|
||||
ecma_string_t *ecma_new_ecma_string_from_utf8 (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size);
|
||||
ecma_string_t *ecma_new_ecma_string_from_utf8_converted_to_cesu8 (const lit_utf8_byte_t *string_p,
|
||||
lit_utf8_size_t string_size);
|
||||
ecma_string_t *ecma_new_ecma_external_string_from_cesu8 (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size,
|
||||
ecma_object_native_free_callback_t free_cb);
|
||||
ecma_string_t *ecma_new_ecma_string_from_code_unit (ecma_char_t code_unit);
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ecma_string_t *ecma_new_ecma_string_from_code_units (ecma_char_t first_code_unit, ecma_char_t second_code_unit);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
ecma_string_t *ecma_new_ecma_string_from_length (ecma_length_t index);
|
||||
ecma_string_t *ecma_new_ecma_string_from_uint32 (uint32_t uint32_number);
|
||||
ecma_string_t *ecma_new_non_direct_string_from_uint32 (uint32_t uint32_number);
|
||||
ecma_string_t *ecma_get_ecma_string_from_uint32 (uint32_t uint32_number);
|
||||
ecma_string_t *ecma_new_ecma_string_from_number (ecma_number_t num);
|
||||
ecma_string_t *ecma_get_magic_string (lit_magic_string_id_t id);
|
||||
ecma_string_t *ecma_get_internal_string (lit_magic_string_id_t id);
|
||||
ecma_string_t *ecma_append_chars_to_string (ecma_string_t *string1_p,
|
||||
const lit_utf8_byte_t *cesu8_string2_p,
|
||||
lit_utf8_size_t cesu8_string2_size,
|
||||
@@ -324,14 +336,14 @@ ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t
|
||||
ecma_substring_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
|
||||
ecma_length_t start_pos,
|
||||
ecma_length_t end_pos,
|
||||
lit_utf8_size_t start_pos,
|
||||
lit_utf8_size_t end_pos,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t
|
||||
ecma_substring_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
|
||||
ecma_length_t start_pos,
|
||||
ecma_length_t end_pos,
|
||||
lit_utf8_size_t start_pos,
|
||||
lit_utf8_size_t end_pos,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
void ecma_string_to_utf8_bytes (const ecma_string_t *string_desc_p, lit_utf8_byte_t *buffer_p,
|
||||
@@ -355,19 +367,27 @@ bool ecma_string_compare_to_property_name (ecma_property_t property, jmem_cpoint
|
||||
bool ecma_compare_ecma_strings (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
|
||||
bool ecma_compare_ecma_non_direct_strings (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
|
||||
bool ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
|
||||
ecma_length_t ecma_string_get_length (const ecma_string_t *string_p);
|
||||
ecma_length_t ecma_string_get_utf8_length (const ecma_string_t *string_p);
|
||||
lit_utf8_size_t ecma_string_get_length (const ecma_string_t *string_p);
|
||||
lit_utf8_size_t ecma_string_get_utf8_length (const ecma_string_t *string_p);
|
||||
lit_utf8_size_t ecma_string_get_size (const ecma_string_t *string_p);
|
||||
lit_utf8_size_t ecma_string_get_utf8_size (const ecma_string_t *string_p);
|
||||
ecma_char_t ecma_string_get_char_at_pos (const ecma_string_t *string_p, ecma_length_t index);
|
||||
ecma_char_t ecma_string_get_char_at_pos (const ecma_string_t *string_p, lit_utf8_size_t index);
|
||||
|
||||
lit_magic_string_id_t ecma_get_string_magic (const ecma_string_t *string_p);
|
||||
|
||||
lit_string_hash_t ecma_string_hash (const ecma_string_t *string_p);
|
||||
ecma_string_t *ecma_string_substr (const ecma_string_t *string_p, ecma_length_t start_pos, ecma_length_t end_pos);
|
||||
ecma_string_t *ecma_string_substr (const ecma_string_t *string_p, lit_utf8_size_t start_pos, lit_utf8_size_t end_pos);
|
||||
const lit_utf8_byte_t *ecma_string_trim_front (const lit_utf8_byte_t *start_p, const lit_utf8_byte_t *end_p);
|
||||
const lit_utf8_byte_t *ecma_string_trim_back (const lit_utf8_byte_t *start_p, const lit_utf8_byte_t *end_p);
|
||||
void ecma_string_trim_helper (const lit_utf8_byte_t **utf8_str_p,
|
||||
lit_utf8_size_t *utf8_str_size);
|
||||
ecma_string_t *ecma_string_trim (const ecma_string_t *string_p);
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ecma_value_t ecma_string_pad (ecma_value_t original_string_p,
|
||||
ecma_value_t max_length,
|
||||
ecma_value_t fill_string,
|
||||
bool pad_on_start);
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
ecma_stringbuilder_t ecma_stringbuilder_create (void);
|
||||
ecma_stringbuilder_t ecma_stringbuilder_create_from (ecma_string_t *string_p);
|
||||
@@ -381,12 +401,15 @@ void ecma_stringbuilder_append_magic (ecma_stringbuilder_t *builder_p, const lit
|
||||
void ecma_stringbuilder_append_raw (ecma_stringbuilder_t *builder_p,
|
||||
const lit_utf8_byte_t *data_p,
|
||||
const lit_utf8_size_t data_size);
|
||||
void ecma_stringbuilder_append_codepoint (ecma_stringbuilder_t *builder_p, lit_code_point_t cp);
|
||||
void ecma_stringbuilder_append_char (ecma_stringbuilder_t *builder_p, const ecma_char_t c);
|
||||
void ecma_stringbuilder_append_byte (ecma_stringbuilder_t *builder_p, const lit_utf8_byte_t);
|
||||
ecma_string_t *ecma_stringbuilder_finalize (ecma_stringbuilder_t *builder_p);
|
||||
void ecma_stringbuilder_destroy (ecma_stringbuilder_t *builder_p);
|
||||
|
||||
/* ecma-helpers-number.c */
|
||||
ecma_number_t ecma_number_pack (bool sign, uint32_t biased_exp, uint64_t fraction);
|
||||
void ecma_number_unpack (ecma_number_t num, bool *sign_p, uint32_t *biased_exp_p, uint64_t *fraction_p);
|
||||
ecma_number_t ecma_number_make_nan (void);
|
||||
ecma_number_t ecma_number_make_infinity (bool sign);
|
||||
bool ecma_number_is_nan (ecma_number_t num);
|
||||
@@ -408,9 +431,6 @@ ecma_value_t ecma_number_parse_float (const lit_utf8_byte_t *string_buff,
|
||||
lit_utf8_size_t string_buff_size);
|
||||
ecma_value_t ecma_integer_multiply (ecma_integer_value_t left_integer, ecma_integer_value_t right_integer);
|
||||
lit_utf8_size_t ecma_number_to_decimal (ecma_number_t num, lit_utf8_byte_t *out_digits_p, int32_t *out_decimal_exp_p);
|
||||
lit_utf8_size_t ecma_number_to_binary_floating_point_number (ecma_number_t num,
|
||||
lit_utf8_byte_t *out_digits_p,
|
||||
int32_t *out_decimal_exp_p);
|
||||
|
||||
/* ecma-helpers-collection.c */
|
||||
ecma_collection_t *ecma_new_collection (void);
|
||||
@@ -421,6 +441,16 @@ void ecma_collection_destroy (ecma_collection_t *collection_p);
|
||||
void ecma_collection_free (ecma_collection_t *collection_p);
|
||||
void ecma_collection_free_if_not_object (ecma_collection_t *collection_p);
|
||||
void ecma_collection_free_objects (ecma_collection_t *collection_p);
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
void ecma_collection_free_template_literal (ecma_collection_t *collection_p);
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
bool ecma_collection_check_duplicated_entries (ecma_collection_t *collection_p);
|
||||
bool ecma_collection_has_string_value (ecma_collection_t *collection_p, ecma_string_t *string_p);
|
||||
|
||||
ecma_value_t *ecma_new_compact_collection (void);
|
||||
ecma_value_t *ecma_compact_collection_push_back (ecma_value_t *compact_collection_p, ecma_value_t value);
|
||||
ecma_value_t *ecma_compact_collection_shrink (ecma_value_t *compact_collection_p);
|
||||
void ecma_compact_collection_free (ecma_value_t *compact_collection_p);
|
||||
|
||||
/* ecma-helpers.c */
|
||||
ecma_object_t *ecma_create_object (ecma_object_t *prototype_object_p, size_t ext_object_size, ecma_object_type_t type);
|
||||
@@ -476,23 +506,26 @@ void ecma_set_property_lcached (ecma_property_t *property_p, bool is_lcached);
|
||||
ecma_property_descriptor_t ecma_make_empty_property_descriptor (void);
|
||||
void ecma_free_property_descriptor (ecma_property_descriptor_t *prop_desc_p);
|
||||
|
||||
void ecma_ref_extended_primitive (ecma_extended_primitive_t *primitve_p);
|
||||
void ecma_deref_error_reference (ecma_extended_primitive_t *error_ref_p);
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
void ecma_deref_bigint (ecma_extended_primitive_t *bigint_p);
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
|
||||
ecma_value_t ecma_create_error_reference (ecma_value_t value, bool is_exception);
|
||||
ecma_value_t ecma_create_error_reference_from_context (void);
|
||||
ecma_value_t ecma_create_error_object_reference (ecma_object_t *object_p);
|
||||
void ecma_ref_error_reference (ecma_error_reference_t *error_ref_p);
|
||||
void ecma_deref_error_reference (ecma_error_reference_t *error_ref_p);
|
||||
void ecma_raise_error_from_error_reference (ecma_value_t value);
|
||||
|
||||
void ecma_bytecode_ref (ecma_compiled_code_t *bytecode_p);
|
||||
void ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p);
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
ecma_collection_t *ecma_compiled_code_get_tagged_template_collection (const ecma_compiled_code_t *bytecode_header_p);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#if ENABLED (JERRY_RESOURCE_NAME) || ENABLED (JERRY_ES2015)
|
||||
ecma_length_t ecma_compiled_code_get_formal_params (const ecma_compiled_code_t *bytecode_p);
|
||||
ecma_value_t *ecma_compiled_code_resolve_arguments_start (const ecma_compiled_code_t *bytecode_header_p);
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ecma_value_t *ecma_compiled_code_resolve_function_name (const ecma_compiled_code_t *bytecode_header_p);
|
||||
#endif /* ENABLED (JERRY_RESOURCE_NAME) || ENABLED (JERRY_ES2015) */
|
||||
uint32_t ecma_compiled_code_resolve_extended_info (const ecma_compiled_code_t *bytecode_header_p);
|
||||
ecma_collection_t *ecma_compiled_code_get_tagged_template_collection (const ecma_compiled_code_t *bytecode_header_p);
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
ecma_value_t ecma_get_resource_name (const ecma_compiled_code_t *bytecode_p);
|
||||
#if (JERRY_STACK_LIMIT != 0)
|
||||
uintptr_t ecma_get_current_stack_usage (void);
|
||||
#endif /* (JERRY_STACK_LIMIT != 0) */
|
||||
@@ -503,7 +536,8 @@ ecma_native_pointer_t *ecma_get_native_pointer_value (ecma_object_t *obj_p, void
|
||||
bool ecma_delete_native_pointer_property (ecma_object_t *obj_p, void *info_p);
|
||||
|
||||
/* ecma-helpers-conversion.c */
|
||||
ecma_number_t ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, lit_utf8_size_t str_size);
|
||||
ecma_number_t ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, lit_utf8_size_t str_size,
|
||||
uint32_t option);
|
||||
lit_utf8_size_t ecma_uint32_to_utf8_string (uint32_t value, lit_utf8_byte_t *out_buffer_p, lit_utf8_size_t buffer_size);
|
||||
uint32_t ecma_number_to_uint32 (ecma_number_t num);
|
||||
int32_t ecma_number_to_int32 (ecma_number_t num);
|
||||
|
||||
@@ -56,14 +56,13 @@ ecma_init (void)
|
||||
JERRY_CONTEXT (stack_base) = (uintptr_t) &sp;
|
||||
#endif /* (JERRY_STACK_LIMIT != 0) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_PROMISE)
|
||||
#if ENABLED (JERRY_BUILTIN_PROMISE)
|
||||
ecma_job_queue_init ();
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_PROMISE) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_PROMISE) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
JERRY_CONTEXT (current_new_target) = NULL;
|
||||
JERRY_CONTEXT (current_function_obj_p) = NULL;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
JERRY_CONTEXT (current_new_target_p) = NULL;
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} /* ecma_init */
|
||||
|
||||
/**
|
||||
@@ -72,16 +71,15 @@ ecma_init (void)
|
||||
void
|
||||
ecma_finalize (void)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
JERRY_ASSERT (JERRY_CONTEXT (current_new_target) == NULL);
|
||||
JERRY_ASSERT (JERRY_CONTEXT (current_function_obj_p) == NULL);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
JERRY_ASSERT (JERRY_CONTEXT (current_new_target_p) == NULL);
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
ecma_finalize_global_environment ();
|
||||
uint8_t runs = 0;
|
||||
|
||||
do
|
||||
{
|
||||
ecma_finalize_builtins ();
|
||||
ecma_gc_run ();
|
||||
if (++runs >= JERRY_GC_LOOP_LIMIT)
|
||||
{
|
||||
@@ -89,6 +87,19 @@ ecma_finalize (void)
|
||||
}
|
||||
}
|
||||
while (JERRY_CONTEXT (ecma_gc_new_objects) != 0);
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
jmem_cpointer_t *global_symbols_cp = JERRY_CONTEXT (global_symbols_cp);
|
||||
|
||||
for (uint32_t i = 0; i < ECMA_BUILTIN_GLOBAL_SYMBOL_COUNT; i++)
|
||||
{
|
||||
if (global_symbols_cp[i] != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_deref_ecma_string (ECMA_GET_NON_NULL_POINTER (ecma_string_t, global_symbols_cp[i]));
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
ecma_finalize_lit_storage ();
|
||||
} /* ecma_finalize */
|
||||
|
||||
|
||||
@@ -91,9 +91,7 @@ ecma_lcache_insert (const ecma_object_t *object_p, /**< object */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (prop_p != NULL && !ecma_is_property_lcached (prop_p));
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|
||||
|| ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR
|
||||
|| ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_INTERNAL);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (*prop_p));
|
||||
|
||||
jmem_cpointer_t object_cp;
|
||||
|
||||
@@ -138,7 +136,7 @@ insert:
|
||||
* @return a pointer to an ecma_property_t if the lookup is successful
|
||||
* NULL otherwise
|
||||
*/
|
||||
inline ecma_property_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_property_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
|
||||
const ecma_string_t *prop_name_p) /**< property's name */
|
||||
{
|
||||
@@ -191,9 +189,7 @@ ecma_lcache_invalidate (const ecma_object_t *object_p, /**< object */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (prop_p != NULL && ecma_is_property_lcached (prop_p));
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|
||||
|| ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR
|
||||
|| ECMA_PROPERTY_GET_TYPE (*prop_p) == ECMA_PROPERTY_TYPE_INTERNAL);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (*prop_p));
|
||||
|
||||
jmem_cpointer_t object_cp;
|
||||
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-bigint.h"
|
||||
#include "ecma-big-uint.h"
|
||||
#include "ecma-literal-storage.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "jcontext.h"
|
||||
@@ -25,7 +27,7 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/**
|
||||
* Free symbol list
|
||||
*/
|
||||
@@ -53,7 +55,7 @@ ecma_free_symbol_list (jmem_cpointer_t symbol_list_cp) /**< symbol list */
|
||||
symbol_list_cp = next_item_cp;
|
||||
}
|
||||
} /* ecma_free_symbol_list */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Free string list
|
||||
@@ -87,39 +89,73 @@ ecma_free_string_list (jmem_cpointer_t string_list_cp) /**< string list */
|
||||
* Free number list
|
||||
*/
|
||||
static void
|
||||
ecma_free_number_list (jmem_cpointer_t number_list_cp) /**< string list */
|
||||
ecma_free_number_list (jmem_cpointer_t number_list_cp) /**< number list */
|
||||
{
|
||||
while (number_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_number_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_storage_item_t,
|
||||
number_list_cp);
|
||||
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
|
||||
number_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
if (number_list_p->values[i] != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_number_t *num_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_t, number_list_p->values[i]);
|
||||
ecma_dealloc_number (num_p);
|
||||
ecma_dealloc_number (JMEM_CP_GET_NON_NULL_POINTER (ecma_number_t, number_list_p->values[i]));
|
||||
}
|
||||
}
|
||||
|
||||
jmem_cpointer_t next_item_cp = number_list_p->next_cp;
|
||||
jmem_pools_free (number_list_p, sizeof (ecma_number_storage_item_t));
|
||||
jmem_pools_free (number_list_p, sizeof (ecma_lit_storage_item_t));
|
||||
number_list_cp = next_item_cp;
|
||||
}
|
||||
} /* ecma_free_number_list */
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
|
||||
/**
|
||||
* Free bigint list
|
||||
*/
|
||||
static void
|
||||
ecma_free_bigint_list (jmem_cpointer_t bigint_list_cp) /**< bigint list */
|
||||
{
|
||||
while (bigint_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
|
||||
bigint_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
if (bigint_list_p->values[i] != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_extended_primitive_t *bigint_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t,
|
||||
bigint_list_p->values[i]);
|
||||
JERRY_ASSERT (ECMA_EXTENDED_PRIMITIVE_IS_REF_EQUALS_TO_ONE (bigint_p));
|
||||
ecma_deref_bigint (bigint_p);
|
||||
}
|
||||
}
|
||||
|
||||
jmem_cpointer_t next_item_cp = bigint_list_p->next_cp;
|
||||
jmem_pools_free (bigint_list_p, sizeof (ecma_lit_storage_item_t));
|
||||
bigint_list_cp = next_item_cp;
|
||||
}
|
||||
} /* ecma_free_bigint_list */
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
|
||||
/**
|
||||
* Finalize literal storage
|
||||
*/
|
||||
void
|
||||
ecma_finalize_lit_storage (void)
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ecma_free_symbol_list (JERRY_CONTEXT (symbol_list_first_cp));
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
ecma_free_string_list (JERRY_CONTEXT (string_list_first_cp));
|
||||
ecma_free_number_list (JERRY_CONTEXT (number_list_first_cp));
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
ecma_free_bigint_list (JERRY_CONTEXT (bigint_list_first_cp));
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
} /* ecma_finalize_lit_storage */
|
||||
|
||||
/**
|
||||
@@ -199,7 +235,7 @@ ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, /**< string
|
||||
/**
|
||||
* Find or create a literal number.
|
||||
*
|
||||
* @return ecma_string_t compressed pointer
|
||||
* @return ecma value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be searched */
|
||||
@@ -218,8 +254,8 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
|
||||
|
||||
while (number_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_number_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_storage_item_t,
|
||||
number_list_cp);
|
||||
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
|
||||
number_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
@@ -246,10 +282,8 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
|
||||
number_list_cp = number_list_p->next_cp;
|
||||
}
|
||||
|
||||
ecma_number_t *num_p = ecma_get_pointer_from_float_value (num);
|
||||
|
||||
jmem_cpointer_t result;
|
||||
JMEM_CP_SET_NON_NULL_POINTER (result, num_p);
|
||||
JMEM_CP_SET_NON_NULL_POINTER (result, ecma_get_pointer_from_float_value (num));
|
||||
|
||||
if (empty_cpointer_p != NULL)
|
||||
{
|
||||
@@ -257,8 +291,8 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
|
||||
return num;
|
||||
}
|
||||
|
||||
ecma_number_storage_item_t *new_item_p;
|
||||
new_item_p = (ecma_number_storage_item_t *) jmem_pools_alloc (sizeof (ecma_number_storage_item_t));
|
||||
ecma_lit_storage_item_t *new_item_p;
|
||||
new_item_p = (ecma_lit_storage_item_t *) jmem_pools_alloc (sizeof (ecma_lit_storage_item_t));
|
||||
|
||||
new_item_p->values[0] = result;
|
||||
for (int i = 1; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
@@ -272,6 +306,83 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
|
||||
return num;
|
||||
} /* ecma_find_or_create_literal_number */
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
|
||||
/**
|
||||
* Find or create a literal BigInt.
|
||||
*
|
||||
* @return BigInt value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searched */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_bigint (bigint));
|
||||
|
||||
if (bigint == ECMA_BIGINT_ZERO)
|
||||
{
|
||||
return bigint;
|
||||
}
|
||||
|
||||
jmem_cpointer_t bigint_list_cp = JERRY_CONTEXT (bigint_list_first_cp);
|
||||
jmem_cpointer_t *empty_cpointer_p = NULL;
|
||||
|
||||
while (bigint_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
|
||||
bigint_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
if (bigint_list_p->values[i] == JMEM_CP_NULL)
|
||||
{
|
||||
if (empty_cpointer_p == NULL)
|
||||
{
|
||||
empty_cpointer_p = bigint_list_p->values + i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_extended_primitive_t *other_bigint_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t,
|
||||
bigint_list_p->values[i]);
|
||||
ecma_value_t other_bigint = ecma_make_extended_primitive_value (other_bigint_p, ECMA_TYPE_BIGINT);
|
||||
|
||||
if (ecma_bigint_is_equal_to_bigint (bigint, other_bigint))
|
||||
{
|
||||
ecma_free_value (bigint);
|
||||
return other_bigint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bigint_list_cp = bigint_list_p->next_cp;
|
||||
}
|
||||
|
||||
jmem_cpointer_t result;
|
||||
JMEM_CP_SET_NON_NULL_POINTER (result, ecma_get_extended_primitive_from_value (bigint));
|
||||
|
||||
if (empty_cpointer_p != NULL)
|
||||
{
|
||||
*empty_cpointer_p = result;
|
||||
return bigint;
|
||||
}
|
||||
|
||||
ecma_lit_storage_item_t *new_item_p;
|
||||
new_item_p = (ecma_lit_storage_item_t *) jmem_pools_alloc (sizeof (ecma_lit_storage_item_t));
|
||||
|
||||
new_item_p->values[0] = result;
|
||||
for (int i = 1; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
new_item_p->values[i] = JMEM_CP_NULL;
|
||||
}
|
||||
|
||||
new_item_p->next_cp = JERRY_CONTEXT (bigint_list_first_cp);
|
||||
JMEM_CP_SET_NON_NULL_POINTER (JERRY_CONTEXT (bigint_list_first_cp), new_item_p);
|
||||
|
||||
return bigint;
|
||||
} /* ecma_find_or_create_literal_bigint */
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
|
||||
/**
|
||||
* Log2 of snapshot literal alignment.
|
||||
*/
|
||||
@@ -285,13 +396,20 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
|
||||
/**
|
||||
* Literal offset shift.
|
||||
*/
|
||||
#define JERRY_SNAPSHOT_LITERAL_SHIFT (ECMA_VALUE_SHIFT + 1)
|
||||
#define JERRY_SNAPSHOT_LITERAL_SHIFT (ECMA_VALUE_SHIFT + 2)
|
||||
|
||||
/**
|
||||
* Literal value is number.
|
||||
*/
|
||||
#define JERRY_SNAPSHOT_LITERAL_IS_NUMBER (1u << ECMA_VALUE_SHIFT)
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
/**
|
||||
* Literal value is BigInt.
|
||||
*/
|
||||
#define JERRY_SNAPSHOT_LITERAL_IS_BIGINT (2u << ECMA_VALUE_SHIFT)
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
|
||||
#if ENABLED (JERRY_SNAPSHOT_SAVE)
|
||||
|
||||
/**
|
||||
@@ -301,7 +419,11 @@ void ecma_save_literals_append_value (ecma_value_t value, /**< value to be appen
|
||||
ecma_collection_t *lit_pool_p) /**< list of known values */
|
||||
{
|
||||
/* Unlike direct numbers, direct strings are converted to character literals. */
|
||||
if (!ecma_is_value_string (value) && !ecma_is_value_float_number (value))
|
||||
if (!ecma_is_value_string (value)
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
&& (!ecma_is_value_bigint (value) || value == ECMA_BIGINT_ZERO)
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
&& !ecma_is_value_float_number (value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -334,7 +456,7 @@ ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_
|
||||
uint32_t const_literal_end;
|
||||
uint32_t literal_end;
|
||||
|
||||
JERRY_ASSERT (compiled_code_p->status_flags & CBC_CODE_FLAGS_FUNCTION);
|
||||
JERRY_ASSERT (CBC_IS_FUNCTION (compiled_code_p->status_flags));
|
||||
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
|
||||
{
|
||||
@@ -377,7 +499,7 @@ ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_
|
||||
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
literal_p[i]);
|
||||
|
||||
if ((bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION)
|
||||
if (CBC_IS_FUNCTION (bytecode_p->status_flags)
|
||||
&& bytecode_p != compiled_code_p)
|
||||
{
|
||||
ecma_save_literals_add_compiled_code (bytecode_p, lit_pool_p);
|
||||
@@ -436,6 +558,15 @@ ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, /**< list of kno
|
||||
{
|
||||
lit_table_size += (uint32_t) sizeof (ecma_number_t);
|
||||
}
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
else if (ecma_is_value_bigint (lit_buffer_p[i]))
|
||||
{
|
||||
ecma_extended_primitive_t *bigint_p = ecma_get_extended_primitive_from_value (lit_buffer_p[i]);
|
||||
|
||||
lit_table_size += (uint32_t) JERRY_ALIGNUP (sizeof (uint32_t) + ECMA_BIGINT_GET_SIZE (bigint_p),
|
||||
JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
else
|
||||
{
|
||||
ecma_string_t *string_p = ecma_get_string_from_value (lit_buffer_p[i]);
|
||||
@@ -453,7 +584,7 @@ ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, /**< list of kno
|
||||
}
|
||||
|
||||
lit_mem_to_snapshot_id_map_entry_t *map_p;
|
||||
ecma_length_t total_count = lit_pool_p->item_count;
|
||||
uint32_t total_count = lit_pool_p->item_count;
|
||||
|
||||
map_p = jmem_heap_alloc_block (total_count * sizeof (lit_mem_to_snapshot_id_map_entry_t));
|
||||
|
||||
@@ -475,7 +606,7 @@ ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, /**< list of kno
|
||||
map_p->literal_id = lit_buffer_p[i];
|
||||
map_p->literal_offset = (literal_offset << JERRY_SNAPSHOT_LITERAL_SHIFT) | ECMA_TYPE_SNAPSHOT_OFFSET;
|
||||
|
||||
ecma_length_t length;
|
||||
lit_utf8_size_t length;
|
||||
|
||||
if (ecma_is_value_float_number (lit_buffer_p[i]))
|
||||
{
|
||||
@@ -486,6 +617,20 @@ ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, /**< list of kno
|
||||
|
||||
length = JERRY_ALIGNUP (sizeof (ecma_number_t), JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
|
||||
}
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
else if (ecma_is_value_bigint (lit_buffer_p[i]))
|
||||
{
|
||||
map_p->literal_offset |= JERRY_SNAPSHOT_LITERAL_IS_BIGINT;
|
||||
|
||||
ecma_extended_primitive_t *bigint_p = ecma_get_extended_primitive_from_value (lit_buffer_p[i]);
|
||||
uint32_t size = ECMA_BIGINT_GET_SIZE (bigint_p);
|
||||
|
||||
memcpy (destination_p, &bigint_p->u.bigint_sign_and_size, sizeof (uint32_t));
|
||||
memcpy (destination_p + sizeof (uint32_t), ECMA_BIGINT_GET_DIGITS (bigint_p, 0), size);
|
||||
|
||||
length = JERRY_ALIGNUP (sizeof (uint32_t) + size, JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
else
|
||||
{
|
||||
ecma_string_t *string_p = ecma_get_string_from_value (lit_buffer_p[i]);
|
||||
@@ -533,6 +678,28 @@ ecma_snapshot_get_literal (const uint8_t *literal_base_p, /**< literal start */
|
||||
return ecma_find_or_create_literal_number (num);
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
if (literal_value & JERRY_SNAPSHOT_LITERAL_IS_BIGINT)
|
||||
{
|
||||
uint32_t bigint_sign_and_size = *(uint32_t *) literal_p;
|
||||
uint32_t size = bigint_sign_and_size & ~(uint32_t) (sizeof (ecma_bigint_digit_t) - 1);
|
||||
|
||||
ecma_extended_primitive_t *bigint_p = ecma_bigint_create (size);
|
||||
|
||||
if (bigint_p == NULL)
|
||||
{
|
||||
jerry_fatal (ERR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
/* Only the sign bit can differ. */
|
||||
JERRY_ASSERT (bigint_p->u.bigint_sign_and_size == (bigint_sign_and_size & ~(uint32_t) ECMA_BIGINT_SIGN));
|
||||
|
||||
bigint_p->u.bigint_sign_and_size = bigint_sign_and_size;
|
||||
memcpy (ECMA_BIGINT_GET_DIGITS (bigint_p, 0), literal_p + sizeof (uint32_t), size);
|
||||
return ecma_find_or_create_literal_bigint (ecma_make_extended_primitive_value (bigint_p, ECMA_TYPE_BIGINT));
|
||||
}
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
|
||||
uint16_t length = *(const uint16_t *) literal_p;
|
||||
|
||||
return ecma_find_or_create_literal_string (literal_p + sizeof (uint16_t), length);
|
||||
@@ -542,8 +709,7 @@ ecma_snapshot_get_literal (const uint8_t *literal_base_p, /**< literal start */
|
||||
* Compute the start of the serializable ecma-values of the bytecode
|
||||
* Related values:
|
||||
* - function argument names, if CBC_CODE_FLAGS_MAPPED_ARGUMENTS_NEEDED is present
|
||||
* - function name, if CBC_CODE_FLAGS_CLASS_CONSTRUCTOR is not present and ES2015 profile is enabled
|
||||
* - resource name, if JERRY_RESOURCE_NAME is enabled
|
||||
* - function name, if CBC_CODE_FLAGS_CLASS_CONSTRUCTOR is not present and ES.next profile is enabled
|
||||
*
|
||||
* @return pointer to the beginning of the serializable ecma-values
|
||||
*/
|
||||
@@ -568,18 +734,13 @@ ecma_snapshot_resolve_serializable_values (ecma_compiled_code_t *compiled_code_p
|
||||
base_p -= argument_end;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/* function name */
|
||||
if (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_CLASS_CONSTRUCTOR))
|
||||
if (CBC_FUNCTION_GET_TYPE (compiled_code_p->status_flags) != CBC_FUNCTION_CONSTRUCTOR)
|
||||
{
|
||||
base_p--;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
#if ENABLED (JERRY_RESOURCE_NAME)
|
||||
/* resource name */
|
||||
base_p--;
|
||||
#endif /* ENABLED (JERRY_RESOURCE_NAME) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
return base_p;
|
||||
} /* ecma_snapshot_resolve_serializable_values */
|
||||
|
||||
@@ -42,6 +42,9 @@ void ecma_finalize_lit_storage (void);
|
||||
|
||||
ecma_value_t ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, lit_utf8_size_t size);
|
||||
ecma_value_t ecma_find_or_create_literal_number (ecma_number_t number_arg);
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
ecma_value_t ecma_find_or_create_literal_bigint (ecma_value_t bigint);
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
|
||||
#if ENABLED (JERRY_SNAPSHOT_SAVE)
|
||||
void ecma_save_literals_append_value (ecma_value_t value, ecma_collection_t *lit_pool_p);
|
||||
|
||||
+331
-251
@@ -27,7 +27,7 @@
|
||||
#include "lit-char-helpers.h"
|
||||
#include "vm.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
|
||||
/**
|
||||
* Takes a ModuleSpecifier and applies path normalization to it.
|
||||
@@ -37,8 +37,9 @@
|
||||
* @return pointer to ecma_string_t containing the normalized and zero terminated path
|
||||
*/
|
||||
ecma_string_t *
|
||||
ecma_module_create_normalized_path (const uint8_t *char_p, /**< module specifier */
|
||||
prop_length_t size) /**< size of module specifier */
|
||||
ecma_module_create_normalized_path (const lit_utf8_byte_t *char_p, /**< module path specifier */
|
||||
lit_utf8_size_t size, /**< size of module specifier */
|
||||
ecma_string_t *const base_path_p) /**< base path for the module specifier */
|
||||
{
|
||||
JERRY_ASSERT (size > 0);
|
||||
ecma_string_t *ret_p = NULL;
|
||||
@@ -57,16 +58,13 @@ ecma_module_create_normalized_path (const uint8_t *char_p, /**< module specifier
|
||||
lit_utf8_byte_t *module_path_p = NULL;
|
||||
lit_utf8_size_t module_path_size = 0;
|
||||
|
||||
/* Check if we have a current module, and use its path as the base path. */
|
||||
JERRY_ASSERT (JERRY_CONTEXT (module_top_context_p) != NULL);
|
||||
if (JERRY_CONTEXT (module_top_context_p)->module_p != NULL)
|
||||
if (base_path_p != NULL)
|
||||
{
|
||||
JERRY_ASSERT (JERRY_CONTEXT (module_top_context_p)->module_p->path_p != NULL);
|
||||
module_path_size = ecma_string_get_size (JERRY_CONTEXT (module_top_context_p)->module_p->path_p);
|
||||
module_path_size = ecma_string_get_size (base_path_p);
|
||||
module_path_p = (lit_utf8_byte_t *) jmem_heap_alloc_block (module_path_size + 1);
|
||||
|
||||
lit_utf8_size_t module_utf8_size;
|
||||
module_utf8_size = ecma_string_copy_to_utf8_buffer (JERRY_CONTEXT (module_top_context_p)->module_p->path_p,
|
||||
module_utf8_size = ecma_string_copy_to_utf8_buffer (base_path_p,
|
||||
module_path_p,
|
||||
module_path_size);
|
||||
|
||||
@@ -96,26 +94,39 @@ ecma_module_create_normalized_path (const uint8_t *char_p, /**< module specifier
|
||||
} /* ecma_module_create_normalized_path */
|
||||
|
||||
/**
|
||||
* Find a module with a specific identifier
|
||||
* Push a new module into the module list. New modules are inserted after the head module, this way in the end the
|
||||
* root module remains the first in the list.
|
||||
*/
|
||||
static void
|
||||
ecma_module_list_push (ecma_module_t *module_p)
|
||||
{
|
||||
ecma_module_t *head_p = JERRY_CONTEXT (module_list_p);
|
||||
module_p->next_p = head_p->next_p;
|
||||
head_p->next_p = module_p;
|
||||
} /* ecma_module_list_push */
|
||||
|
||||
/**
|
||||
* Lookup a module with a specific identifier.
|
||||
*
|
||||
* @return pointer to ecma_module_t, if found
|
||||
* NULL, otherwise
|
||||
*/
|
||||
ecma_module_t *
|
||||
ecma_module_find_module (ecma_string_t *const path_p) /**< module identifier */
|
||||
static ecma_module_t *
|
||||
ecma_module_list_lookup (ecma_string_t *const path_p) /**< module identifier */
|
||||
{
|
||||
ecma_module_t *current_p = JERRY_CONTEXT (ecma_modules_p);
|
||||
ecma_module_t *current_p = JERRY_CONTEXT (module_list_p);
|
||||
while (current_p != NULL)
|
||||
{
|
||||
if (ecma_compare_ecma_strings (path_p, current_p->path_p))
|
||||
{
|
||||
return current_p;
|
||||
}
|
||||
|
||||
current_p = current_p->next_p;
|
||||
}
|
||||
|
||||
return current_p;
|
||||
} /* ecma_module_find_module */
|
||||
return NULL;
|
||||
} /* ecma_module_list_lookup */
|
||||
|
||||
/**
|
||||
* Create a new module
|
||||
@@ -129,8 +140,7 @@ ecma_module_create_module (ecma_string_t *const path_p) /**< module identifier *
|
||||
memset (module_p, 0, sizeof (ecma_module_t));
|
||||
|
||||
module_p->path_p = path_p;
|
||||
module_p->next_p = JERRY_CONTEXT (ecma_modules_p);
|
||||
JERRY_CONTEXT (ecma_modules_p) = module_p;
|
||||
ecma_module_list_push (module_p);
|
||||
return module_p;
|
||||
} /* ecma_module_create_module */
|
||||
|
||||
@@ -140,9 +150,10 @@ ecma_module_create_module (ecma_string_t *const path_p) /**< module identifier *
|
||||
* @return pointer to found or newly created module structure
|
||||
*/
|
||||
ecma_module_t *
|
||||
ecma_module_find_or_create_module (ecma_string_t *const path_p) /**< module path */
|
||||
ecma_module_find_module (ecma_string_t *const path_p) /**< module path */
|
||||
{
|
||||
ecma_module_t *module_p = ecma_module_find_module (path_p);
|
||||
ecma_module_t *module_p = ecma_module_list_lookup (path_p);
|
||||
|
||||
if (module_p)
|
||||
{
|
||||
ecma_deref_ecma_string (path_p);
|
||||
@@ -150,7 +161,7 @@ ecma_module_find_or_create_module (ecma_string_t *const path_p) /**< module path
|
||||
}
|
||||
|
||||
return ecma_module_create_module (path_p);
|
||||
} /* ecma_module_find_or_create_module */
|
||||
} /* ecma_module_find_module */
|
||||
|
||||
/**
|
||||
* Create a new native module
|
||||
@@ -158,28 +169,83 @@ ecma_module_find_or_create_module (ecma_string_t *const path_p) /**< module path
|
||||
* @return pointer to created module
|
||||
*/
|
||||
ecma_module_t *
|
||||
ecma_module_create_native_module (ecma_string_t *const path_p, /**< module identifier */
|
||||
ecma_object_t *const namespace_p) /**< module namespace */
|
||||
ecma_module_find_native_module (ecma_string_t *const path_p)
|
||||
{
|
||||
ecma_module_t *module_p = ecma_module_create_module (path_p);
|
||||
module_p->state = ECMA_MODULE_STATE_NATIVE;
|
||||
module_p->namespace_object_p = namespace_p;
|
||||
return module_p;
|
||||
} /* ecma_module_create_native_module */
|
||||
ecma_module_t *module_p = ecma_module_list_lookup (path_p);
|
||||
|
||||
if (module_p != NULL)
|
||||
{
|
||||
return module_p;
|
||||
}
|
||||
|
||||
ecma_value_t native = jerry_port_get_native_module (ecma_make_string_value (path_p));
|
||||
|
||||
if (!ecma_is_value_undefined (native))
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_object (native));
|
||||
|
||||
module_p = ecma_module_create_module (path_p);
|
||||
module_p->state = ECMA_MODULE_STATE_NATIVE;
|
||||
module_p->namespace_object_p = ecma_get_object_from_value (native);
|
||||
|
||||
return module_p;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
} /* ecma_module_find_native_module */
|
||||
|
||||
/**
|
||||
* Creates a module context.
|
||||
*
|
||||
* @return pointer to created module context
|
||||
* Initialize context variables for the root module.
|
||||
*/
|
||||
static ecma_module_context_t *
|
||||
ecma_module_create_module_context (void)
|
||||
void
|
||||
ecma_module_initialize_context (ecma_string_t *root_path_p) /**< root module */
|
||||
{
|
||||
ecma_module_context_t *context_p = (ecma_module_context_t *) jmem_heap_alloc_block (sizeof (ecma_module_context_t));
|
||||
memset (context_p, 0, sizeof (ecma_module_context_t));
|
||||
JERRY_ASSERT (JERRY_CONTEXT (module_current_p) == NULL);
|
||||
JERRY_ASSERT (JERRY_CONTEXT (module_list_p) == NULL);
|
||||
|
||||
return context_p;
|
||||
} /* ecma_module_create_module_context */
|
||||
lit_utf8_size_t path_str_size;
|
||||
uint8_t flags = ECMA_STRING_FLAG_EMPTY;
|
||||
|
||||
const lit_utf8_byte_t *path_str_chars_p = ecma_string_get_chars (root_path_p,
|
||||
&path_str_size,
|
||||
NULL,
|
||||
NULL,
|
||||
&flags);
|
||||
|
||||
ecma_string_t *path_p = ecma_module_create_normalized_path (path_str_chars_p,
|
||||
path_str_size,
|
||||
NULL);
|
||||
|
||||
if (path_p == NULL)
|
||||
{
|
||||
ecma_ref_ecma_string (root_path_p);
|
||||
path_p = root_path_p;
|
||||
}
|
||||
|
||||
ecma_module_t *module_p = (ecma_module_t *) jmem_heap_alloc_block (sizeof (ecma_module_t));
|
||||
memset (module_p, 0, sizeof (ecma_module_t));
|
||||
|
||||
module_p->path_p = path_p;
|
||||
/* Root modules are handled differently then the rest of the referenced modules, as the scope and compiled code
|
||||
* are handled separately. */
|
||||
module_p->state = ECMA_MODULE_STATE_ROOT;
|
||||
|
||||
JERRY_CONTEXT (module_current_p) = module_p;
|
||||
JERRY_CONTEXT (module_list_p) = module_p;
|
||||
} /* ecma_module_initialize_context */
|
||||
|
||||
/**
|
||||
* cleanup context variables for the root module.
|
||||
*/
|
||||
void
|
||||
ecma_module_cleanup_context (void)
|
||||
{
|
||||
ecma_module_cleanup (JERRY_CONTEXT (module_current_p));
|
||||
#ifndef JERRY_NDEBUG
|
||||
JERRY_CONTEXT (module_current_p) = NULL;
|
||||
JERRY_CONTEXT (module_list_p) = NULL;
|
||||
#endif /* JERRY_NDEBUG */
|
||||
} /* ecma_module_cleanup_context */
|
||||
|
||||
/**
|
||||
* Inserts a {module, export_name} record into a resolve set.
|
||||
@@ -190,8 +256,8 @@ ecma_module_create_module_context (void)
|
||||
*/
|
||||
bool
|
||||
ecma_module_resolve_set_insert (ecma_module_resolve_set_t **set_p, /**< [in, out] resolve set */
|
||||
ecma_module_t * const module_p, /**< module */
|
||||
ecma_string_t * const export_name_p) /**< export name */
|
||||
ecma_module_t *const module_p, /**< module */
|
||||
ecma_string_t *const export_name_p) /**< export name */
|
||||
{
|
||||
JERRY_ASSERT (set_p != NULL);
|
||||
ecma_module_resolve_set_t *current_p = *set_p;
|
||||
@@ -283,8 +349,8 @@ ecma_module_resolve_stack_pop (ecma_module_resolve_stack_t **stack_p) /**< [in,
|
||||
* ECMA_VALUE_EMPTY - otherwise
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_module_resolve_export (ecma_module_t * const module_p, /**< base module */
|
||||
ecma_string_t * const export_name_p, /**< export name */
|
||||
ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */
|
||||
ecma_string_t *const export_name_p, /**< export name */
|
||||
ecma_module_record_t *out_record_p) /**< [out] found module record */
|
||||
{
|
||||
ecma_module_resolve_set_t *resolve_set_p = NULL;
|
||||
@@ -302,7 +368,6 @@ ecma_module_resolve_export (ecma_module_t * const module_p, /**< base module */
|
||||
|
||||
ecma_module_t *current_module_p = current_frame_p->module_p;
|
||||
JERRY_ASSERT (current_module_p->state >= ECMA_MODULE_STATE_PARSED);
|
||||
ecma_module_context_t *context_p = current_module_p->context_p;
|
||||
ecma_string_t *current_export_name_p = current_frame_p->export_name_p;
|
||||
|
||||
if (!current_frame_p->resolving)
|
||||
@@ -341,11 +406,11 @@ ecma_module_resolve_export (ecma_module_t * const module_p, /**< base module */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (context_p->local_exports_p != NULL)
|
||||
if (current_module_p->local_exports_p != NULL)
|
||||
{
|
||||
/* 15.2.1.16.3 / 4 */
|
||||
JERRY_ASSERT (context_p->local_exports_p->next_p == NULL);
|
||||
ecma_module_names_t *export_names_p = context_p->local_exports_p->module_names_p;
|
||||
JERRY_ASSERT (current_module_p->local_exports_p->next_p == NULL);
|
||||
ecma_module_names_t *export_names_p = current_module_p->local_exports_p->module_names_p;
|
||||
while (export_names_p != NULL)
|
||||
{
|
||||
if (ecma_compare_ecma_strings (current_export_name_p, export_names_p->imex_name_p))
|
||||
@@ -377,7 +442,7 @@ ecma_module_resolve_export (ecma_module_t * const module_p, /**< base module */
|
||||
}
|
||||
|
||||
/* 15.2.1.16.3 / 5 */
|
||||
ecma_module_node_t *indirect_export_p = context_p->indirect_exports_p;
|
||||
ecma_module_node_t *indirect_export_p = current_module_p->indirect_exports_p;
|
||||
while (indirect_export_p != NULL)
|
||||
{
|
||||
ecma_module_names_t *export_names_p = indirect_export_p->module_names_p;
|
||||
@@ -389,6 +454,7 @@ ecma_module_resolve_export (ecma_module_t * const module_p, /**< base module */
|
||||
ecma_module_resolve_stack_push (&stack_p,
|
||||
indirect_export_p->module_request_p,
|
||||
export_names_p->local_name_p);
|
||||
break;
|
||||
}
|
||||
|
||||
export_names_p = export_names_p->next_p;
|
||||
@@ -432,7 +498,7 @@ ecma_module_resolve_export (ecma_module_t * const module_p, /**< base module */
|
||||
ecma_module_resolve_stack_pop (&stack_p);
|
||||
|
||||
/* 15.2.1.16.3 / 10 */
|
||||
ecma_module_node_t *star_export_p = context_p->star_exports_p;
|
||||
ecma_module_node_t *star_export_p = current_module_p->star_exports_p;
|
||||
while (star_export_p != NULL)
|
||||
{
|
||||
JERRY_ASSERT (star_export_p->module_names_p == NULL);
|
||||
@@ -469,6 +535,49 @@ ecma_module_resolve_export (ecma_module_t * const module_p, /**< base module */
|
||||
return ret_value;
|
||||
} /* ecma_module_resolve_export */
|
||||
|
||||
/**
|
||||
* Evaluates an EcmaScript module.
|
||||
*
|
||||
* @return ECMA_VALUE_ERROR - if an error occured
|
||||
* ECMA_VALUE_EMPTY - otherwise
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_module_evaluate (ecma_module_t *module_p) /**< module */
|
||||
{
|
||||
JERRY_ASSERT (module_p->state >= ECMA_MODULE_STATE_PARSED);
|
||||
|
||||
if (module_p->state >= ECMA_MODULE_STATE_EVALUATING)
|
||||
{
|
||||
return ECMA_VALUE_EMPTY;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_REALMS)
|
||||
ecma_object_t *global_object_p = (ecma_object_t *) ecma_op_function_get_realm (module_p->compiled_code_p);
|
||||
#else /* !ENABLED (JERRY_BUILTIN_REALMS) */
|
||||
ecma_object_t *global_object_p = ecma_builtin_get_global ();
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REALMS) */
|
||||
|
||||
module_p->state = ECMA_MODULE_STATE_EVALUATING;
|
||||
module_p->scope_p = ecma_create_decl_lex_env (ecma_get_global_environment (global_object_p));
|
||||
|
||||
ecma_value_t ret_value;
|
||||
ret_value = vm_run_module (module_p);
|
||||
|
||||
if (!ECMA_IS_VALUE_ERROR (ret_value))
|
||||
{
|
||||
ecma_free_value (ret_value);
|
||||
ret_value = ECMA_VALUE_EMPTY;
|
||||
}
|
||||
|
||||
module_p->state = ECMA_MODULE_STATE_EVALUATED;
|
||||
ecma_bytecode_deref (module_p->compiled_code_p);
|
||||
#ifndef JERRY_NDEBUG
|
||||
module_p->compiled_code_p = NULL;
|
||||
#endif /* JERRY_NDEBUG */
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_module_evaluate */
|
||||
|
||||
/**
|
||||
* Resolves an export and adds it to the modules namespace object, if the export name is not yet handled.
|
||||
* Note: See 15.2.1.16.2 and 15.2.1.18
|
||||
@@ -483,7 +592,9 @@ ecma_module_namespace_object_add_export_if_needed (ecma_module_t *module_p, /**<
|
||||
JERRY_ASSERT (module_p->namespace_object_p != NULL);
|
||||
ecma_value_t result = ECMA_VALUE_EMPTY;
|
||||
|
||||
if (ecma_find_named_property (module_p->namespace_object_p, export_name_p) != NULL)
|
||||
/* Default exports should not be added to the namespace object. */
|
||||
if (ecma_compare_ecma_string_to_magic_id (export_name_p, LIT_MAGIC_STRING_DEFAULT)
|
||||
|| ecma_find_named_property (module_p->namespace_object_p, export_name_p) != NULL)
|
||||
{
|
||||
/* This export name has already been handled. */
|
||||
return result;
|
||||
@@ -550,7 +661,6 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
{
|
||||
ecma_module_resolve_stack_t *current_frame_p = stack_p;
|
||||
ecma_module_t *current_module_p = current_frame_p->module_p;
|
||||
ecma_module_context_t *context_p = current_module_p->context_p;
|
||||
|
||||
ecma_module_resolve_stack_pop (&stack_p);
|
||||
|
||||
@@ -563,11 +673,18 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (context_p->local_exports_p != NULL)
|
||||
result = ecma_module_evaluate (current_module_p);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (current_module_p->local_exports_p != NULL)
|
||||
{
|
||||
/* 15.2.1.16.2 / 5 */
|
||||
JERRY_ASSERT (context_p->local_exports_p->next_p == NULL);
|
||||
ecma_module_names_t *export_names_p = context_p->local_exports_p->module_names_p;
|
||||
JERRY_ASSERT (current_module_p->local_exports_p->next_p == NULL);
|
||||
ecma_module_names_t *export_names_p = current_module_p->local_exports_p->module_names_p;
|
||||
while (export_names_p != NULL && ecma_is_value_empty (result))
|
||||
{
|
||||
result = ecma_module_namespace_object_add_export_if_needed (module_p,
|
||||
@@ -577,7 +694,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
}
|
||||
|
||||
/* 15.2.1.16.2 / 6 */
|
||||
ecma_module_node_t *indirect_export_p = context_p->indirect_exports_p;
|
||||
ecma_module_node_t *indirect_export_p = current_module_p->indirect_exports_p;
|
||||
while (indirect_export_p != NULL && ecma_is_value_empty (result))
|
||||
{
|
||||
ecma_module_names_t *export_names_p = indirect_export_p->module_names_p;
|
||||
@@ -591,7 +708,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
}
|
||||
|
||||
/* 15.2.1.16.2 / 7 */
|
||||
ecma_module_node_t *star_export_p = context_p->star_exports_p;
|
||||
ecma_module_node_t *star_export_p = current_module_p->star_exports_p;
|
||||
while (star_export_p != NULL && ecma_is_value_empty (result))
|
||||
{
|
||||
JERRY_ASSERT (star_export_p->module_names_p == NULL);
|
||||
@@ -616,59 +733,18 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
} /* ecma_module_create_namespace_object */
|
||||
|
||||
/**
|
||||
* Evaluates an EcmaScript module.
|
||||
* Connects imported values to the current module scope.
|
||||
*
|
||||
* @return ECMA_VALUE_ERROR - if an error occured
|
||||
* ECMA_VALUE_EMPTY - otherwise
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_module_evaluate (ecma_module_t *module_p) /**< module */
|
||||
ecma_module_connect_imports (ecma_module_t *module_p)
|
||||
{
|
||||
JERRY_ASSERT (module_p->state >= ECMA_MODULE_STATE_PARSED);
|
||||
|
||||
if (module_p->state >= ECMA_MODULE_STATE_EVALUATING)
|
||||
{
|
||||
return ECMA_VALUE_EMPTY;
|
||||
}
|
||||
|
||||
module_p->state = ECMA_MODULE_STATE_EVALUATING;
|
||||
module_p->scope_p = ecma_create_decl_lex_env (ecma_get_global_environment ());
|
||||
module_p->context_p->parent_p = JERRY_CONTEXT (module_top_context_p);
|
||||
JERRY_CONTEXT (module_top_context_p) = module_p->context_p;
|
||||
|
||||
ecma_value_t ret_value;
|
||||
ret_value = vm_run_module (module_p->compiled_code_p,
|
||||
module_p->scope_p);
|
||||
|
||||
if (!ECMA_IS_VALUE_ERROR (ret_value))
|
||||
{
|
||||
jerry_release_value (ret_value);
|
||||
ret_value = ECMA_VALUE_EMPTY;
|
||||
}
|
||||
|
||||
JERRY_CONTEXT (module_top_context_p) = module_p->context_p->parent_p;
|
||||
|
||||
ecma_bytecode_deref (module_p->compiled_code_p);
|
||||
module_p->state = ECMA_MODULE_STATE_EVALUATED;
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_module_evaluate */
|
||||
|
||||
/**
|
||||
* Connects imported values to the current context.
|
||||
*
|
||||
* @return ECMA_VALUE_ERROR - if an error occured
|
||||
* ECMA_VALUE_EMPTY - otherwise
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_module_connect_imports (void)
|
||||
{
|
||||
ecma_module_context_t *current_context_p = JERRY_CONTEXT (module_top_context_p);
|
||||
|
||||
ecma_object_t *local_env_p = current_context_p->module_p->scope_p;
|
||||
ecma_object_t *local_env_p = module_p->scope_p;
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (local_env_p));
|
||||
|
||||
ecma_module_node_t *import_node_p = current_context_p->imports_p;
|
||||
ecma_module_node_t *import_node_p = module_p->imports_p;
|
||||
|
||||
/* Check that the imported bindings don't exist yet. */
|
||||
while (import_node_p != NULL)
|
||||
@@ -695,12 +771,12 @@ ecma_module_connect_imports (void)
|
||||
|
||||
ecma_value_t status = ecma_op_has_binding (lex_env_p, import_names_p->local_name_p);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_PROXY)
|
||||
#if ENABLED (JERRY_BUILTIN_PROXY)
|
||||
if (ECMA_IS_VALUE_ERROR (status))
|
||||
{
|
||||
return status;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_PROXY) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
|
||||
|
||||
if (ecma_is_value_true (status))
|
||||
{
|
||||
@@ -713,7 +789,7 @@ ecma_module_connect_imports (void)
|
||||
import_node_p = import_node_p->next_p;
|
||||
}
|
||||
|
||||
import_node_p = current_context_p->imports_p;
|
||||
import_node_p = module_p->imports_p;
|
||||
|
||||
/* Resolve imports and create local bindings. */
|
||||
while (import_node_p != NULL)
|
||||
@@ -730,6 +806,8 @@ ecma_module_connect_imports (void)
|
||||
const bool is_namespace_import = ecma_compare_ecma_string_to_magic_id (import_names_p->imex_name_p,
|
||||
LIT_MAGIC_STRING_ASTERIX_CHAR);
|
||||
|
||||
ecma_value_t prop_value;
|
||||
|
||||
if (is_namespace_import)
|
||||
{
|
||||
result = ecma_module_create_namespace_object (import_node_p->module_request_p);
|
||||
@@ -738,11 +816,8 @@ ecma_module_connect_imports (void)
|
||||
return result;
|
||||
}
|
||||
|
||||
ecma_op_create_mutable_binding (local_env_p, import_names_p->local_name_p, true /* is_deletable */);
|
||||
ecma_op_set_mutable_binding (local_env_p,
|
||||
import_names_p->local_name_p,
|
||||
ecma_make_object_value (import_node_p->module_request_p->namespace_object_p),
|
||||
false /* is_strict */);
|
||||
ecma_ref_object (import_node_p->module_request_p->namespace_object_p);
|
||||
prop_value = ecma_make_object_value (import_node_p->module_request_p->namespace_object_p);
|
||||
}
|
||||
else /* !is_namespace_import */
|
||||
{
|
||||
@@ -762,18 +837,8 @@ ecma_module_connect_imports (void)
|
||||
if (record.module_p->state == ECMA_MODULE_STATE_NATIVE)
|
||||
{
|
||||
ecma_object_t *object_p = record.module_p->namespace_object_p;
|
||||
ecma_value_t prop_value = ecma_op_object_find_own (ecma_make_object_value (object_p),
|
||||
object_p,
|
||||
record.name_p);
|
||||
prop_value = ecma_op_object_find_own (ecma_make_object_value (object_p), object_p, record.name_p);
|
||||
JERRY_ASSERT (ecma_is_value_found (prop_value));
|
||||
|
||||
ecma_op_create_mutable_binding (local_env_p, import_names_p->local_name_p, true /* is_deletable */);
|
||||
ecma_op_set_mutable_binding (local_env_p,
|
||||
import_names_p->local_name_p,
|
||||
prop_value,
|
||||
false /* is_strict */);
|
||||
|
||||
ecma_free_value (prop_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -785,20 +850,33 @@ ecma_module_connect_imports (void)
|
||||
}
|
||||
|
||||
ecma_object_t *ref_base_lex_env_p;
|
||||
ecma_value_t prop_value = ecma_op_get_value_lex_env_base (record.module_p->scope_p,
|
||||
&ref_base_lex_env_p,
|
||||
record.name_p);
|
||||
prop_value = ecma_op_get_value_lex_env_base (record.module_p->scope_p,
|
||||
&ref_base_lex_env_p,
|
||||
record.name_p);
|
||||
|
||||
ecma_op_create_mutable_binding (local_env_p, import_names_p->local_name_p, true /* is_deletable */);
|
||||
ecma_op_set_mutable_binding (local_env_p,
|
||||
import_names_p->local_name_p,
|
||||
prop_value,
|
||||
false /* is_strict */);
|
||||
|
||||
ecma_free_value (prop_value);
|
||||
}
|
||||
}
|
||||
|
||||
ecma_property_t *prop_p = ecma_op_create_mutable_binding (local_env_p,
|
||||
import_names_p->local_name_p,
|
||||
true /* is_deletable */);
|
||||
JERRY_ASSERT (prop_p != ECMA_PROPERTY_POINTER_ERROR);
|
||||
|
||||
if (prop_p != NULL)
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_undefined (ECMA_PROPERTY_VALUE_PTR (prop_p)->value));
|
||||
ECMA_PROPERTY_VALUE_PTR (prop_p)->value = prop_value;
|
||||
ecma_deref_if_object (prop_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_op_set_mutable_binding (local_env_p,
|
||||
import_names_p->local_name_p,
|
||||
prop_value,
|
||||
false /* is_strict */);
|
||||
ecma_free_value (prop_value);
|
||||
}
|
||||
|
||||
import_names_p = import_names_p->next_p;
|
||||
}
|
||||
|
||||
@@ -808,6 +886,48 @@ ecma_module_connect_imports (void)
|
||||
return ECMA_VALUE_EMPTY;
|
||||
} /* ecma_module_connect_imports */
|
||||
|
||||
/**
|
||||
* Checks if indirect exports in the current context are resolvable.
|
||||
* Note: See 15.2.1.16.4 / 9.
|
||||
*
|
||||
* @return ECMA_VALUE_ERROR - if an error occured
|
||||
* ECMA_VALUE_EMPTY - otherwise
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_module_check_indirect_exports (ecma_module_t *module_p)
|
||||
{
|
||||
ecma_module_node_t *indirect_export_p = module_p->indirect_exports_p;
|
||||
while (indirect_export_p != NULL)
|
||||
{
|
||||
ecma_module_names_t *name_p = indirect_export_p->module_names_p;
|
||||
while (name_p != NULL)
|
||||
{
|
||||
ecma_module_record_t record;
|
||||
ecma_value_t result = ecma_module_resolve_export (indirect_export_p->module_request_p,
|
||||
name_p->local_name_p,
|
||||
&record);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_empty (result));
|
||||
|
||||
if (record.module_p == NULL)
|
||||
{
|
||||
return ecma_raise_syntax_error (ECMA_ERR_MSG ("Ambiguous indirect export request."));
|
||||
}
|
||||
|
||||
name_p = name_p->next_p;
|
||||
}
|
||||
|
||||
indirect_export_p = indirect_export_p->next_p;
|
||||
}
|
||||
|
||||
return ECMA_VALUE_EMPTY;
|
||||
} /* ecma_module_check_indirect_exports */
|
||||
|
||||
/**
|
||||
* Initialize the current module by creating the local binding for the imported variables
|
||||
* and verifying indirect exports.
|
||||
@@ -816,17 +936,42 @@ ecma_module_connect_imports (void)
|
||||
* ECMA_VALUE_EMPTY - otherwise
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_module_initialize_current (void)
|
||||
ecma_module_initialize (ecma_module_t *module_p) /**< module */
|
||||
{
|
||||
ecma_value_t ret_value = ecma_module_connect_imports ();
|
||||
ecma_value_t ret_value = ecma_module_connect_imports (module_p);
|
||||
|
||||
if (ecma_is_value_empty (ret_value))
|
||||
{
|
||||
ret_value = ecma_module_check_indirect_exports ();
|
||||
ret_value = ecma_module_check_indirect_exports (module_p);
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_module_initialize_current */
|
||||
} /* ecma_module_initialize */
|
||||
|
||||
static ecma_value_t ecma_module_parse (ecma_module_t *module_p);
|
||||
|
||||
/**
|
||||
* Parses all referenced modules.
|
||||
*
|
||||
* @return ECMA_VALUE_ERROR - if an error occured
|
||||
* ECMA_VALUE_EMPTY - otherwise
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_module_parse_referenced_modules (void)
|
||||
{
|
||||
ecma_module_t *current_p = JERRY_CONTEXT (module_list_p);
|
||||
while (current_p != NULL)
|
||||
{
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_module_parse (current_p)))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
current_p = current_p->next_p;
|
||||
}
|
||||
|
||||
return ECMA_VALUE_EMPTY;
|
||||
} /* ecma_module_parse_referenced_modules */
|
||||
|
||||
/**
|
||||
* Parses an EcmaScript module.
|
||||
@@ -834,7 +979,7 @@ ecma_module_initialize_current (void)
|
||||
* @return ECMA_VALUE_ERROR - if an error occured
|
||||
* ECMA_VALUE_EMPTY - otherwise
|
||||
*/
|
||||
static jerry_value_t
|
||||
static ecma_value_t
|
||||
ecma_module_parse (ecma_module_t *module_p) /**< module */
|
||||
{
|
||||
if (module_p->state >= ECMA_MODULE_STATE_PARSING)
|
||||
@@ -843,7 +988,6 @@ ecma_module_parse (ecma_module_t *module_p) /**< module */
|
||||
}
|
||||
|
||||
module_p->state = ECMA_MODULE_STATE_PARSING;
|
||||
module_p->context_p = ecma_module_create_module_context ();
|
||||
|
||||
lit_utf8_size_t module_path_size = ecma_string_get_size (module_p->path_p);
|
||||
lit_utf8_byte_t *module_path_p = (lit_utf8_byte_t *) jmem_heap_alloc_block (module_path_size + 1);
|
||||
@@ -863,9 +1007,8 @@ ecma_module_parse (ecma_module_t *module_p) /**< module */
|
||||
return ecma_raise_syntax_error (ECMA_ERR_MSG ("File not found."));
|
||||
}
|
||||
|
||||
module_p->context_p->module_p = module_p;
|
||||
module_p->context_p->parent_p = JERRY_CONTEXT (module_top_context_p);
|
||||
JERRY_CONTEXT (module_top_context_p) = module_p->context_p;
|
||||
ecma_module_t *prev_module_p = JERRY_CONTEXT (module_current_p);
|
||||
JERRY_CONTEXT (module_current_p) = module_p;
|
||||
|
||||
#if ENABLED (JERRY_DEBUGGER) && ENABLED (JERRY_PARSER)
|
||||
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
|
||||
@@ -877,99 +1020,33 @@ ecma_module_parse (ecma_module_t *module_p) /**< module */
|
||||
}
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) && ENABLED (JERRY_PARSER) */
|
||||
|
||||
JERRY_CONTEXT (resource_name) = ecma_make_string_value (module_p->path_p);
|
||||
|
||||
ecma_compiled_code_t *bytecode_data_p;
|
||||
ecma_value_t ret_value = parser_parse_script (NULL,
|
||||
0,
|
||||
(jerry_char_t *) source_p,
|
||||
source_size,
|
||||
ECMA_PARSE_STRICT_MODE | ECMA_PARSE_MODULE,
|
||||
&bytecode_data_p);
|
||||
|
||||
JERRY_CONTEXT (module_top_context_p) = module_p->context_p->parent_p;
|
||||
ecma_compiled_code_t *bytecode_p = parser_parse_script (NULL,
|
||||
0,
|
||||
(jerry_char_t *) source_p,
|
||||
source_size,
|
||||
ecma_make_string_value (module_p->path_p),
|
||||
ECMA_PARSE_STRICT_MODE | ECMA_PARSE_MODULE);
|
||||
|
||||
JERRY_CONTEXT (module_current_p) = prev_module_p;
|
||||
jerry_port_release_source (source_p);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (ret_value))
|
||||
if (JERRY_UNLIKELY (bytecode_p == NULL))
|
||||
{
|
||||
return ret_value;
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_free_value (ret_value);
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_module_parse_referenced_modules ()))
|
||||
{
|
||||
ecma_bytecode_deref (bytecode_p);
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
module_p->compiled_code_p = bytecode_data_p;
|
||||
module_p->compiled_code_p = bytecode_p;
|
||||
module_p->state = ECMA_MODULE_STATE_PARSED;
|
||||
|
||||
return ECMA_VALUE_EMPTY;
|
||||
} /* ecma_module_parse */
|
||||
|
||||
/**
|
||||
* Parses all referenced modules.
|
||||
*
|
||||
* @return ECMA_VALUE_ERROR - if an error occured
|
||||
* ECMA_VALUE_EMPTY - otherwise
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_module_parse_modules (void)
|
||||
{
|
||||
ecma_module_t *current_p = JERRY_CONTEXT (ecma_modules_p);
|
||||
|
||||
while (current_p != NULL)
|
||||
{
|
||||
ecma_value_t ret_value = ecma_module_parse (current_p);
|
||||
if (ECMA_IS_VALUE_ERROR (ret_value))
|
||||
{
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_empty (ret_value));
|
||||
current_p = current_p->next_p;
|
||||
}
|
||||
|
||||
return ECMA_VALUE_EMPTY;
|
||||
} /* ecma_module_parse_modules */
|
||||
|
||||
/**
|
||||
* Checks if indirect exports in the current context are resolvable.
|
||||
* Note: See 15.2.1.16.4 / 9.
|
||||
*
|
||||
* @return ECMA_VALUE_ERROR - if an error occured
|
||||
* ECMA_VALUE_EMPTY - otherwise
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_module_check_indirect_exports (void)
|
||||
{
|
||||
ecma_module_node_t *indirect_export_p = JERRY_CONTEXT (module_top_context_p)->indirect_exports_p;
|
||||
while (indirect_export_p != NULL)
|
||||
{
|
||||
ecma_module_names_t *name_p = indirect_export_p->module_names_p;
|
||||
while (name_p != NULL)
|
||||
{
|
||||
ecma_module_record_t record;
|
||||
ecma_value_t result = ecma_module_resolve_export (indirect_export_p->module_request_p,
|
||||
name_p->local_name_p,
|
||||
&record);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
if (record.module_p == NULL)
|
||||
{
|
||||
return ecma_raise_syntax_error (ECMA_ERR_MSG ("Ambiguous indirect export request."));
|
||||
}
|
||||
|
||||
name_p = name_p->next_p;
|
||||
}
|
||||
|
||||
indirect_export_p = indirect_export_p->next_p;
|
||||
}
|
||||
|
||||
return ECMA_VALUE_EMPTY;
|
||||
} /* ecma_module_check_indirect_exports */
|
||||
|
||||
/**
|
||||
* Cleans up a list of module names.
|
||||
*/
|
||||
@@ -1006,52 +1083,60 @@ ecma_module_release_module_nodes (ecma_module_node_t *module_node_p) /**< first
|
||||
} /* ecma_module_release_module_nodes */
|
||||
|
||||
/**
|
||||
* Cleans up a module context.
|
||||
*/
|
||||
static void
|
||||
ecma_module_release_module_context (ecma_module_context_t *module_context_p) /**< modle context */
|
||||
{
|
||||
ecma_module_release_module_nodes (module_context_p->imports_p);
|
||||
ecma_module_release_module_nodes (module_context_p->local_exports_p);
|
||||
ecma_module_release_module_nodes (module_context_p->indirect_exports_p);
|
||||
ecma_module_release_module_nodes (module_context_p->star_exports_p);
|
||||
|
||||
jmem_heap_free_block (module_context_p, sizeof (ecma_module_context_t));
|
||||
} /* ecma_module_release_module_context */
|
||||
|
||||
/**
|
||||
* Cleans up a module structure.
|
||||
* Cleans up and releases a module structure including all referenced modules.
|
||||
*/
|
||||
static void
|
||||
ecma_module_release_module (ecma_module_t *module_p) /**< module */
|
||||
{
|
||||
ecma_module_state_t state = module_p->state;
|
||||
|
||||
ecma_deref_ecma_string (module_p->path_p);
|
||||
#ifndef JERRY_NDEBUG
|
||||
module_p->path_p = NULL;
|
||||
#endif /* JERRY_NDEBUG */
|
||||
|
||||
if (module_p->namespace_object_p != NULL)
|
||||
{
|
||||
/* The module structure keeps a strong reference to the namespace object, which will require an extra GC call. */
|
||||
JERRY_CONTEXT (ecma_gc_new_objects)++;
|
||||
ecma_deref_object (module_p->namespace_object_p);
|
||||
#ifndef JERRY_NDEBUG
|
||||
module_p->namespace_object_p = NULL;
|
||||
#endif /* JERRY_NDEBUG */
|
||||
}
|
||||
|
||||
if (module_p->state == ECMA_MODULE_STATE_NATIVE)
|
||||
if (state == ECMA_MODULE_STATE_NATIVE)
|
||||
{
|
||||
goto finished;
|
||||
}
|
||||
|
||||
if (module_p->state >= ECMA_MODULE_STATE_PARSING)
|
||||
if (state >= ECMA_MODULE_STATE_PARSING)
|
||||
{
|
||||
ecma_module_release_module_context (module_p->context_p);
|
||||
ecma_module_release_module_nodes (module_p->imports_p);
|
||||
ecma_module_release_module_nodes (module_p->local_exports_p);
|
||||
ecma_module_release_module_nodes (module_p->indirect_exports_p);
|
||||
ecma_module_release_module_nodes (module_p->star_exports_p);
|
||||
}
|
||||
|
||||
if (module_p->state >= ECMA_MODULE_STATE_EVALUATING
|
||||
&& module_p->scope_p != NULL)
|
||||
if (state == ECMA_MODULE_STATE_ROOT)
|
||||
{
|
||||
goto finished;
|
||||
}
|
||||
|
||||
if (state >= ECMA_MODULE_STATE_EVALUATING)
|
||||
{
|
||||
/* The module structure keeps a strong reference to the module scope, which will require an extra GC call. */
|
||||
JERRY_CONTEXT (ecma_gc_new_objects)++;
|
||||
ecma_deref_object (module_p->scope_p);
|
||||
}
|
||||
|
||||
if (module_p->state >= ECMA_MODULE_STATE_PARSED
|
||||
&& module_p->state < ECMA_MODULE_STATE_EVALUATED)
|
||||
if (state >= ECMA_MODULE_STATE_PARSED
|
||||
&& state < ECMA_MODULE_STATE_EVALUATED)
|
||||
{
|
||||
ecma_bytecode_deref (module_p->compiled_code_p);
|
||||
#ifndef JERRY_NDEBUG
|
||||
module_p->compiled_code_p = NULL;
|
||||
#endif /* JERRY_NDEBUG */
|
||||
}
|
||||
|
||||
finished:
|
||||
@@ -1059,21 +1144,16 @@ finished:
|
||||
} /* ecma_module_release_module */
|
||||
|
||||
/**
|
||||
* Cleans up all modules if the current context is the root context.
|
||||
* Cleans up and releases a module list.
|
||||
*/
|
||||
void
|
||||
ecma_module_cleanup (void)
|
||||
ecma_module_cleanup (ecma_module_t *head_p) /**< module */
|
||||
{
|
||||
ecma_module_t *current_p = JERRY_CONTEXT (ecma_modules_p);
|
||||
while (current_p != NULL)
|
||||
while (head_p != NULL)
|
||||
{
|
||||
ecma_module_t *next_p = current_p->next_p;
|
||||
ecma_module_release_module (current_p);
|
||||
current_p = next_p;
|
||||
ecma_module_t *next_p = head_p->next_p;
|
||||
ecma_module_release_module (head_p);
|
||||
head_p = next_p;
|
||||
}
|
||||
|
||||
JERRY_CONTEXT (ecma_modules_p) = NULL;
|
||||
JERRY_CONTEXT (module_top_context_p) = NULL;
|
||||
} /* ecma_module_cleanup */
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
#ifndef ECMA_MODULE_H
|
||||
#define ECMA_MODULE_H
|
||||
|
||||
#if ENABLED (JERRY_ES2015_MODULE_SYSTEM)
|
||||
|
||||
#include "common.h"
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
|
||||
#define ECMA_MODULE_MAX_PATH 255u
|
||||
|
||||
/**
|
||||
@@ -35,31 +35,6 @@ typedef struct ecma_module_names
|
||||
ecma_string_t *local_name_p; /**< Local name of the item */
|
||||
} ecma_module_names_t;
|
||||
|
||||
typedef struct ecma_module ecma_module_t;
|
||||
|
||||
/**
|
||||
* Module node to store imports / exports.
|
||||
*/
|
||||
typedef struct ecma_module_node
|
||||
{
|
||||
struct ecma_module_node *next_p; /**< next linked list node */
|
||||
ecma_module_names_t *module_names_p; /**< names of the requested import/export node */
|
||||
ecma_module_t *module_request_p; /**< module structure of the requested module */
|
||||
} ecma_module_node_t;
|
||||
|
||||
/**
|
||||
* Module context containing all import and export nodes.
|
||||
*/
|
||||
typedef struct ecma_module_context
|
||||
{
|
||||
struct ecma_module_context *parent_p; /**< parent context */
|
||||
ecma_module_node_t *imports_p; /**< import item of the current context */
|
||||
ecma_module_node_t *local_exports_p; /**< export item of the current context */
|
||||
ecma_module_node_t *indirect_exports_p; /**< export item of the current context */
|
||||
ecma_module_node_t *star_exports_p; /**< export item of the current context */
|
||||
ecma_module_t *module_p; /**< module request */
|
||||
} ecma_module_context_t;
|
||||
|
||||
/**
|
||||
* An enum identifing the current state of the module
|
||||
*/
|
||||
@@ -71,21 +46,36 @@ typedef enum
|
||||
ECMA_MODULE_STATE_EVALUATING = 3, /**< module is currently being evaluated */
|
||||
ECMA_MODULE_STATE_EVALUATED = 4, /**< module has been evaluated */
|
||||
ECMA_MODULE_STATE_NATIVE = 5, /**< module is native */
|
||||
ECMA_MODULE_STATE_ROOT = 6, /**< module is a root module */
|
||||
} ecma_module_state_t;
|
||||
|
||||
/**
|
||||
* Module structure storing an instance of a module
|
||||
*/
|
||||
struct ecma_module
|
||||
typedef struct ecma_module
|
||||
{
|
||||
struct ecma_module *next_p; /**< next linked list node */
|
||||
ecma_module_state_t state; /**< state of the mode */
|
||||
ecma_string_t *path_p; /**< path of the module */
|
||||
ecma_module_context_t *context_p; /**< module context of the module */
|
||||
ecma_compiled_code_t *compiled_code_p; /**< compiled code of the module */
|
||||
ecma_object_t *scope_p; /**< lexica lenvironment of the module */
|
||||
ecma_object_t *namespace_object_p; /**< namespace import object of the module */
|
||||
};
|
||||
/* TODO(dbatyai): These could be compressed pointers */
|
||||
struct ecma_module *next_p; /**< next module in the list */
|
||||
struct ecma_module_node *imports_p; /**< import requests of the module */
|
||||
struct ecma_module_node *local_exports_p; /**< local exports of the module */
|
||||
struct ecma_module_node *indirect_exports_p; /**< indirect exports of the module */
|
||||
struct ecma_module_node *star_exports_p; /**< star exports of the module*/
|
||||
ecma_string_t *path_p; /**< path of the module */
|
||||
ecma_compiled_code_t *compiled_code_p; /**< compiled code for the module */
|
||||
ecma_object_t *scope_p; /**< lexical lenvironment of the module */
|
||||
ecma_object_t *namespace_object_p; /**< namespace object of the module */
|
||||
ecma_module_state_t state; /**< evaluation state of the module */
|
||||
} ecma_module_t;
|
||||
|
||||
/**
|
||||
* Module node to store imports / exports.
|
||||
*/
|
||||
typedef struct ecma_module_node
|
||||
{
|
||||
struct ecma_module_node *next_p; /**< next linked list node */
|
||||
ecma_module_names_t *module_names_p; /**< names of the requested import/export node */
|
||||
ecma_module_t *module_request_p; /**< module structure of the requested module */
|
||||
} ecma_module_node_t;
|
||||
|
||||
/**
|
||||
* A record that can be used to store {module, identifier} pairs
|
||||
@@ -126,19 +116,21 @@ void ecma_module_resolve_stack_push (ecma_module_resolve_stack_t **stack_p,
|
||||
ecma_string_t *const export_name_p);
|
||||
void ecma_module_resolve_stack_pop (ecma_module_resolve_stack_t **stack_p);
|
||||
|
||||
ecma_string_t *ecma_module_create_normalized_path (const uint8_t *char_p,
|
||||
prop_length_t size);
|
||||
ecma_module_t *ecma_module_find_module (ecma_string_t *const path_p);
|
||||
ecma_module_t *ecma_module_create_native_module (ecma_string_t *const path_p,
|
||||
ecma_object_t *const namespace_p);
|
||||
ecma_module_t *ecma_module_find_or_create_module (ecma_string_t *const path_p);
|
||||
ecma_string_t *ecma_module_create_normalized_path (const lit_utf8_byte_t *char_p,
|
||||
lit_utf8_size_t size,
|
||||
ecma_string_t *const base_path_p);
|
||||
|
||||
ecma_value_t ecma_module_initialize_current (void);
|
||||
ecma_value_t ecma_module_parse_modules (void);
|
||||
ecma_value_t ecma_module_check_indirect_exports (void);
|
||||
ecma_module_t *ecma_module_find_module (ecma_string_t *const path_p);
|
||||
ecma_module_t *ecma_module_find_native_module (ecma_string_t *const path_p);
|
||||
|
||||
ecma_value_t ecma_module_parse_referenced_modules (void);
|
||||
ecma_value_t ecma_module_initialize (ecma_module_t *module_p);
|
||||
|
||||
void ecma_module_initialize_context (ecma_string_t *root_path_p);
|
||||
void ecma_module_cleanup_context (void);
|
||||
|
||||
void ecma_module_release_module_nodes (ecma_module_node_t *module_node_p);
|
||||
void ecma_module_cleanup (void);
|
||||
#endif /* ENABLED (JERRY_ES2015_MODULE_SYSTEM) */
|
||||
void ecma_module_cleanup (ecma_module_t *head_p);
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
#endif /* !ECMA_MODULE_H */
|
||||
|
||||
@@ -93,10 +93,9 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */
|
||||
|
||||
for (int i = 0; i < ECMA_PROPERTY_PAIR_ITEM_COUNT; i++)
|
||||
{
|
||||
ecma_property_types_t type = ECMA_PROPERTY_GET_TYPE (prop_iter_p->types[i]);
|
||||
|
||||
if (type != ECMA_PROPERTY_TYPE_SPECIAL)
|
||||
if (prop_iter_p->types[i] != ECMA_PROPERTY_TYPE_DELETED)
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[i]));
|
||||
named_property_count++;
|
||||
}
|
||||
}
|
||||
@@ -148,11 +147,13 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */
|
||||
|
||||
for (int i = 0; i < ECMA_PROPERTY_PAIR_ITEM_COUNT; i++)
|
||||
{
|
||||
if (!ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[i]))
|
||||
if (prop_iter_p->types[i] == ECMA_PROPERTY_TYPE_DELETED)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[i]));
|
||||
|
||||
ecma_property_pair_t *property_pair_p = (ecma_property_pair_t *) prop_iter_p;
|
||||
|
||||
uint32_t entry_index = ecma_string_get_property_name_hash (prop_iter_p->types[i],
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-iterator-object.h"
|
||||
#include "ecma-typedarray-object.h"
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
@@ -78,16 +79,31 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
|
||||
ecma_object_t *array_object_p = ecma_get_object_from_value (iterated_value);
|
||||
|
||||
/* 8 - 9. */
|
||||
uint32_t length;
|
||||
ecma_value_t len_value = ecma_op_object_get_length (array_object_p, &length);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (len_value))
|
||||
/* 8. */
|
||||
ecma_length_t length;
|
||||
if (ecma_object_is_typedarray (array_object_p))
|
||||
{
|
||||
return len_value;
|
||||
/* a. */
|
||||
ecma_object_t *arraybuffer_p = ecma_typedarray_get_arraybuffer (array_object_p);
|
||||
if (ecma_arraybuffer_is_detached (arraybuffer_p))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached."));
|
||||
}
|
||||
|
||||
/* b. */
|
||||
length = ecma_typedarray_get_length (array_object_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_value_t len_value = ecma_op_object_get_length (array_object_p, &length);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (len_value))
|
||||
{
|
||||
return len_value;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t index = ext_obj_p->u.pseudo_array.u1.iterator_index;
|
||||
ecma_length_t index = ext_obj_p->u.pseudo_array.u1.iterator_index;
|
||||
|
||||
if (JERRY_UNLIKELY (index == ECMA_ITERATOR_INDEX_LIMIT))
|
||||
{
|
||||
@@ -98,12 +114,12 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
|
||||
if (!ecma_is_value_undefined (index_value))
|
||||
{
|
||||
index = (uint32_t) (ecma_get_number_from_value (index_value) + 1);
|
||||
index = (ecma_length_t) (ecma_get_number_from_value (index_value) + 1);
|
||||
}
|
||||
|
||||
ecma_value_t put_result = ecma_op_object_put (obj_p,
|
||||
prop_name_p,
|
||||
ecma_make_uint32_value (index),
|
||||
ecma_make_length_value (index),
|
||||
true);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_true (put_result));
|
||||
@@ -123,16 +139,16 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
}
|
||||
|
||||
/* 7. */
|
||||
uint8_t iterator_type = ext_obj_p->u.pseudo_array.extra_info;
|
||||
uint8_t iterator_kind = ext_obj_p->u.pseudo_array.extra_info;
|
||||
|
||||
if (iterator_type == ECMA_ITERATOR_KEYS)
|
||||
if (iterator_kind == ECMA_ITERATOR_KEYS)
|
||||
{
|
||||
/* 12. */
|
||||
return ecma_create_iter_result_object (ecma_make_uint32_value (index), ECMA_VALUE_FALSE);
|
||||
return ecma_create_iter_result_object (ecma_make_length_value (index), ECMA_VALUE_FALSE);
|
||||
}
|
||||
|
||||
/* 14. */
|
||||
ecma_value_t get_value = ecma_op_object_get_by_uint32_index (array_object_p, index);
|
||||
ecma_value_t get_value = ecma_op_object_get_by_index (array_object_p, index);
|
||||
|
||||
/* 15. */
|
||||
if (ECMA_IS_VALUE_ERROR (get_value))
|
||||
@@ -143,19 +159,19 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
ecma_value_t result;
|
||||
|
||||
/* 16. */
|
||||
if (iterator_type == ECMA_ITERATOR_VALUES)
|
||||
if (iterator_kind == ECMA_ITERATOR_VALUES)
|
||||
{
|
||||
result = ecma_create_iter_result_object (get_value, ECMA_VALUE_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 17.a */
|
||||
JERRY_ASSERT (iterator_type == ECMA_ITERATOR_KEYS_VALUES);
|
||||
JERRY_ASSERT (iterator_kind == ECMA_ITERATOR_ENTRIES);
|
||||
|
||||
/* 17.b */
|
||||
ecma_value_t entry_array_value;
|
||||
entry_array_value = ecma_create_array_from_iter_element (get_value,
|
||||
ecma_make_uint32_value (index));
|
||||
ecma_make_length_value (index));
|
||||
|
||||
result = ecma_create_iter_result_object (entry_array_value, ECMA_VALUE_FALSE);
|
||||
ecma_free_value (entry_array_value);
|
||||
@@ -172,4 +188,4 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_ARRAY_ITERATOR_UL,
|
||||
@@ -29,6 +29,6 @@ STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
ROUTINE (LIT_MAGIC_STRING_NEXT, ecma_builtin_array_iterator_prototype_object_next, 0, 0)
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
@@ -25,4 +25,4 @@
|
||||
#define BUILTIN_UNDERSCORED_ID array_prototype_unscopables
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_COPY_WITHIN,
|
||||
ECMA_VALUE_TRUE,
|
||||
@@ -41,6 +41,18 @@ SIMPLE_VALUE (LIT_MAGIC_STRING_FIND_INDEX,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FLAT,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FLATMAP,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_INCLUDES,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_KEYS,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
@@ -49,6 +61,6 @@ SIMPLE_VALUE (LIT_MAGIC_STRING_VALUES,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,12 +29,12 @@ OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/* ECMA-262 v6, 22.1.3.31 */
|
||||
OBJECT_VALUE (LIT_GLOBAL_SYMBOL_UNSCOPABLES,
|
||||
ECMA_BUILTIN_ID_ARRAY_PROTOTYPE_UNSCOPABLES,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/* Number properties:
|
||||
* (property name, object pointer getter) */
|
||||
@@ -46,8 +46,10 @@ NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_STRING_UL, ECMA_ARRAY_PROTOTYPE_TO_STRING, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_LOCALE_STRING_UL, ECMA_ARRAY_PROTOTYPE_TO_LOCALE_STRING, 0, 0)
|
||||
#if !ENABLED (JERRY_ESNEXT)
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_STRING_UL, ECMA_ARRAY_PROTOTYPE_TO_STRING, 0, 0)
|
||||
#endif /* !ENABLED (JERRY_ESNEXT) */
|
||||
ROUTINE (LIT_MAGIC_STRING_CONCAT, ECMA_ARRAY_PROTOTYPE_CONCAT, NON_FIXED, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_JOIN, ECMA_ARRAY_PROTOTYPE_JOIN, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_POP, ECMA_ARRAY_PROTOTYPE_POP, 0, 0)
|
||||
@@ -69,18 +71,23 @@ ROUTINE (LIT_MAGIC_STRING_FILTER, ECMA_ARRAY_PROTOTYPE_FILTER, 2, 1)
|
||||
/* Note these 2 routines must be in this order */
|
||||
ROUTINE (LIT_MAGIC_STRING_REDUCE, ECMA_ARRAY_PROTOTYPE_REDUCE, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_REDUCE_RIGHT_UL, ECMA_ARRAY_PROTOTYPE_REDUCE_RIGHT, 2, 1)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ROUTINE (LIT_MAGIC_STRING_FIND, ECMA_ARRAY_PROTOTYPE_FIND, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_FIND_INDEX, ECMA_ARRAY_PROTOTYPE_FIND_INDEX, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_FILL, ECMA_ARRAY_PROTOTYPE_FILL, 3, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_COPY_WITHIN, ECMA_ARRAY_PROTOTYPE_COPY_WITHIN, NON_FIXED, 2)
|
||||
ROUTINE (LIT_MAGIC_STRING_ENTRIES, ECMA_ARRAY_PROTOTYPE_ENTRIES, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_KEYS, ECMA_ARRAY_PROTOTYPE_KEYS, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_INCLUDES, ECMA_ARRAY_PROTOTYPE_INCLUDES, NON_FIXED, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_FLAT, ECMA_ARRAY_PROTOTYPE_FLAT, 1, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_FLATMAP, ECMA_ARRAY_PROTOTYPE_FLATMAP, 2, 1)
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_STRING_UL, LIT_MAGIC_STRING_TO_STRING_UL,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_VALUES, LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
INTRINSIC_PROPERTY (LIT_GLOBAL_SYMBOL_ITERATOR, LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_ARRAY) */
|
||||
|
||||
|
||||
@@ -33,6 +33,25 @@
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
/**
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_CUSTOM_DISPATCH
|
||||
|
||||
/**
|
||||
* List of built-in routine identifiers.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
ECMA_ARRAY_ROUTINE_START = 0,
|
||||
ECMA_ARRAY_ROUTINE_IS_ARRAY,
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ECMA_ARRAY_ROUTINE_FROM,
|
||||
ECMA_ARRAY_ROUTINE_OF,
|
||||
ECMA_ARRAY_ROUTINE_SPECIES_GET
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-array.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID array
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
@@ -47,25 +66,7 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Array object's 'isArray' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v5, 15.4.3.2
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_array_object_is_array (ecma_value_t this_arg, /**< 'this' argument */
|
||||
ecma_value_t arg) /**< first argument */
|
||||
{
|
||||
JERRY_UNUSED (this_arg);
|
||||
|
||||
return ecma_is_value_array (arg);
|
||||
} /* ecma_builtin_array_object_is_array */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/**
|
||||
* The Array object's 'from' routine
|
||||
*
|
||||
@@ -78,7 +79,7 @@ ecma_builtin_array_object_is_array (ecma_value_t this_arg, /**< 'this' argument
|
||||
static ecma_value_t
|
||||
ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
/* 1. */
|
||||
ecma_value_t constructor = this_arg;
|
||||
@@ -122,44 +123,45 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
/* 6. */
|
||||
if (!ecma_is_value_undefined (using_iterator))
|
||||
{
|
||||
ecma_value_t array;
|
||||
ecma_object_t *array_obj_p;
|
||||
|
||||
/* 6.a */
|
||||
if (ecma_is_constructor (constructor))
|
||||
{
|
||||
ecma_object_t *constructor_obj_p = ecma_get_object_from_value (constructor);
|
||||
|
||||
array = ecma_op_function_construct (constructor_obj_p, constructor_obj_p, NULL, 0);
|
||||
ecma_value_t array = ecma_op_function_construct (constructor_obj_p, constructor_obj_p, NULL, 0);
|
||||
|
||||
if (ecma_is_value_undefined (array) || ecma_is_value_null (array))
|
||||
{
|
||||
ecma_free_value (using_iterator);
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Cannot convert undefined or null to object"));
|
||||
}
|
||||
|
||||
/* 6.c */
|
||||
if (ECMA_IS_VALUE_ERROR (array))
|
||||
{
|
||||
ecma_free_value (using_iterator);
|
||||
return array;
|
||||
}
|
||||
|
||||
array_obj_p = ecma_get_object_from_value (array);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 6.b */
|
||||
array = ecma_op_create_array_object (NULL, 0, false);
|
||||
array_obj_p = ecma_op_new_array_object (0);
|
||||
}
|
||||
|
||||
/* 6.c */
|
||||
if (ECMA_IS_VALUE_ERROR (array))
|
||||
{
|
||||
ecma_free_value (using_iterator);
|
||||
return array;
|
||||
}
|
||||
|
||||
ecma_object_t *array_obj_p = ecma_get_object_from_value (array);
|
||||
|
||||
/* 6.d */
|
||||
ecma_value_t iterator = ecma_op_get_iterator (items, using_iterator);
|
||||
ecma_value_t next_method;
|
||||
ecma_value_t iterator = ecma_op_get_iterator (items, using_iterator, &next_method);
|
||||
ecma_free_value (using_iterator);
|
||||
|
||||
/* 6.e */
|
||||
if (ECMA_IS_VALUE_ERROR (iterator))
|
||||
{
|
||||
ecma_free_value (array);
|
||||
ecma_deref_object (array_obj_p);
|
||||
return iterator;
|
||||
}
|
||||
|
||||
@@ -170,7 +172,7 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
while (true)
|
||||
{
|
||||
/* 6.g.ii */
|
||||
ecma_value_t next = ecma_op_iterator_step (iterator);
|
||||
ecma_value_t next = ecma_op_iterator_step (iterator, next_method);
|
||||
|
||||
/* 6.g.iii */
|
||||
if (ECMA_IS_VALUE_ERROR (next))
|
||||
@@ -196,8 +198,9 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
}
|
||||
|
||||
ecma_free_value (iterator);
|
||||
ecma_free_value (next_method);
|
||||
/* 6.g.iv.3 */
|
||||
return array;
|
||||
return ecma_make_object_value (array_obj_p);
|
||||
}
|
||||
|
||||
/* 6.g.v */
|
||||
@@ -254,7 +257,8 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
|
||||
iterator_cleanup:
|
||||
ecma_free_value (iterator);
|
||||
ecma_free_value (array);
|
||||
ecma_free_value (next_method);
|
||||
ecma_deref_object (array_obj_p);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
@@ -271,7 +275,7 @@ iterator_cleanup:
|
||||
ecma_object_t *array_like_obj_p = ecma_get_object_from_value (array_like);
|
||||
|
||||
/* 10. */
|
||||
uint32_t len;
|
||||
ecma_length_t len;
|
||||
ecma_value_t len_value = ecma_op_object_get_length (array_like_obj_p, &len);
|
||||
|
||||
/* 11. */
|
||||
@@ -280,49 +284,51 @@ iterator_cleanup:
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
len_value = ecma_make_uint32_value (len);
|
||||
|
||||
/* 12. */
|
||||
ecma_value_t array;
|
||||
ecma_object_t *array_obj_p;
|
||||
|
||||
/* 12.a */
|
||||
if (ecma_is_constructor (constructor))
|
||||
{
|
||||
ecma_object_t *constructor_obj_p = ecma_get_object_from_value (constructor);
|
||||
|
||||
array = ecma_op_function_construct (constructor_obj_p, constructor_obj_p, &len_value, 1);
|
||||
len_value = ecma_make_length_value (len);
|
||||
ecma_value_t array = ecma_op_function_construct (constructor_obj_p, constructor_obj_p, &len_value, 1);
|
||||
ecma_free_value (len_value);
|
||||
|
||||
if (ecma_is_value_undefined (array) || ecma_is_value_null (array))
|
||||
{
|
||||
ecma_free_value (len_value);
|
||||
ecma_raise_type_error (ECMA_ERR_MSG ("Cannot convert undefined or null to object"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* 14. */
|
||||
if (ECMA_IS_VALUE_ERROR (array))
|
||||
{
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
array_obj_p = ecma_get_object_from_value (array);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 13.a */
|
||||
array = ecma_op_create_array_object (&len_value, 1, true);
|
||||
array_obj_p = ecma_op_new_array_object_from_length (len);
|
||||
|
||||
if (JERRY_UNLIKELY (array_obj_p == NULL))
|
||||
{
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
ecma_free_value (len_value);
|
||||
|
||||
/* 14. */
|
||||
if (ECMA_IS_VALUE_ERROR (array))
|
||||
{
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ecma_object_t *array_obj_p = ecma_get_object_from_value (array);
|
||||
|
||||
/* 15. */
|
||||
uint32_t k = 0;
|
||||
ecma_length_t k = 0;
|
||||
|
||||
/* 16. */
|
||||
while (k < len)
|
||||
{
|
||||
/* 16.b */
|
||||
ecma_value_t k_value = ecma_op_object_get_by_uint32_index (array_like_obj_p, k);
|
||||
ecma_value_t k_value = ecma_op_object_get_by_index (array_like_obj_p, k);
|
||||
|
||||
/* 16.c */
|
||||
if (ECMA_IS_VALUE_ERROR (k_value))
|
||||
@@ -335,7 +341,7 @@ iterator_cleanup:
|
||||
if (mapfn_obj_p != NULL)
|
||||
{
|
||||
/* 16.d.i */
|
||||
ecma_value_t args_p[2] = { k_value, ecma_make_uint32_value (k) };
|
||||
ecma_value_t args_p[2] = { k_value, ecma_make_length_value (k) };
|
||||
mapped_value = ecma_op_function_call (mapfn_obj_p, call_this_arg, args_p, 2);
|
||||
ecma_free_value (args_p[1]);
|
||||
ecma_free_value (k_value);
|
||||
@@ -369,7 +375,7 @@ iterator_cleanup:
|
||||
}
|
||||
|
||||
/* 17. */
|
||||
len_value = ecma_make_uint32_value (k);
|
||||
len_value = ecma_make_length_value (k);
|
||||
ecma_value_t set_status = ecma_op_object_put (array_obj_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
|
||||
len_value,
|
||||
@@ -405,11 +411,11 @@ cleanup:
|
||||
static ecma_value_t
|
||||
ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
if (!ecma_is_constructor (this_arg))
|
||||
{
|
||||
return ecma_op_create_array_object (arguments_list_p, arguments_list_len, false);
|
||||
return ecma_op_new_array_object_from_buffer (arguments_list_p, arguments_list_len);
|
||||
}
|
||||
|
||||
ecma_value_t len = ecma_make_uint32_value (arguments_list_len);
|
||||
@@ -462,48 +468,53 @@ ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
|
||||
return ecma_make_object_value (obj_p);
|
||||
} /* ecma_builtin_array_object_of */
|
||||
|
||||
/**
|
||||
* 22.1.2.5 get Array [ @@species ] accessor
|
||||
*
|
||||
* @return ecma_value
|
||||
* returned value must be freed with ecma_free_value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_array_species_get (ecma_value_t this_value) /**< This Value */
|
||||
{
|
||||
return ecma_copy_value (this_value);
|
||||
} /* ecma_builtin_array_species_get */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Handle calling [[Call]] of built-in Array object
|
||||
*
|
||||
* @return ecma value
|
||||
* @return ECMA_VALUE_ERROR - if the array construction fails
|
||||
* constructed array object - otherwise
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_array_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
return ecma_op_create_array_object (arguments_list_p, arguments_list_len, true);
|
||||
if (arguments_list_len != 1
|
||||
|| !ecma_is_value_number (arguments_list_p[0]))
|
||||
{
|
||||
return ecma_op_new_array_object_from_buffer (arguments_list_p, arguments_list_len);
|
||||
}
|
||||
|
||||
ecma_number_t num = ecma_get_number_from_value (arguments_list_p[0]);
|
||||
uint32_t num_uint32 = ecma_number_to_uint32 (num);
|
||||
|
||||
if (num != ((ecma_number_t) num_uint32))
|
||||
{
|
||||
return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid array length."));
|
||||
}
|
||||
|
||||
return ecma_make_object_value (ecma_op_new_array_object (num_uint32));
|
||||
} /* ecma_builtin_array_dispatch_call */
|
||||
|
||||
/**
|
||||
* Handle calling [[Construct]] of built-in Array object
|
||||
*
|
||||
* @return ecma value
|
||||
* @return ECMA_VALUE_ERROR - if the array construction fails
|
||||
* constructed array object - otherwise
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_array_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
return ecma_op_create_array_object (arguments_list_p, arguments_list_len, true);
|
||||
#else /* ENABLED (JERRY_ES2015) */
|
||||
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target),
|
||||
#if !ENABLED (JERRY_ESNEXT)
|
||||
return ecma_builtin_array_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
#else /* ENABLED (JERRY_ESNEXT) */
|
||||
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p),
|
||||
ECMA_BUILTIN_ID_ARRAY_PROTOTYPE);
|
||||
|
||||
if (proto_p == NULL)
|
||||
@@ -511,21 +522,63 @@ ecma_builtin_array_dispatch_construct (const ecma_value_t *arguments_list_p, /**
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_value_t result = ecma_op_create_array_object (arguments_list_p, arguments_list_len, true);
|
||||
ecma_value_t result = ecma_builtin_array_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
ecma_deref_object (proto_p);
|
||||
return ECMA_VALUE_ERROR;
|
||||
return result;
|
||||
}
|
||||
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (result);
|
||||
ECMA_SET_NON_NULL_POINTER (object_p->u2.prototype_cp, proto_p);
|
||||
ecma_deref_object (proto_p);
|
||||
return result;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} /* ecma_builtin_array_dispatch_construct */
|
||||
|
||||
/**
|
||||
* Dispatcher of the built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_array_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide routine identifier */
|
||||
ecma_value_t this_arg, /**< 'this' argument value */
|
||||
const ecma_value_t arguments_list_p[], /**< list of arguments
|
||||
* passed to routine */
|
||||
uint32_t arguments_number) /**< length of arguments' list */
|
||||
{
|
||||
switch (builtin_routine_id)
|
||||
{
|
||||
case ECMA_ARRAY_ROUTINE_IS_ARRAY:
|
||||
{
|
||||
JERRY_UNUSED (this_arg);
|
||||
|
||||
return arguments_number > 0 ? ecma_is_value_array (arguments_list_p[0]) : ECMA_VALUE_FALSE;
|
||||
}
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case ECMA_ARRAY_ROUTINE_FROM:
|
||||
{
|
||||
return ecma_builtin_array_object_from (this_arg, arguments_list_p, arguments_number);
|
||||
}
|
||||
case ECMA_ARRAY_ROUTINE_OF:
|
||||
{
|
||||
return ecma_builtin_array_object_of (this_arg, arguments_list_p, arguments_number);
|
||||
}
|
||||
case ECMA_ARRAY_ROUTINE_SPECIES_GET:
|
||||
{
|
||||
return ecma_copy_value (this_arg);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
}
|
||||
}
|
||||
} /* ecma_builtin_array_dispatch_routine */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
|
||||
@@ -36,24 +36,24 @@ NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ARRAY_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
ROUTINE (LIT_MAGIC_STRING_IS_ARRAY_UL, ecma_builtin_array_object_is_array, 1, 1)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
ROUTINE (LIT_MAGIC_STRING_FROM, ecma_builtin_array_object_from, NON_FIXED, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_OF, ecma_builtin_array_object_of, NON_FIXED, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_IS_ARRAY_UL, ECMA_ARRAY_ROUTINE_IS_ARRAY, 1, 1)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ROUTINE (LIT_MAGIC_STRING_FROM, ECMA_ARRAY_ROUTINE_FROM, NON_FIXED, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_OF, ECMA_ARRAY_ROUTINE_OF, NON_FIXED, 0)
|
||||
|
||||
/* ECMA-262 v6, 22.1.2.5 */
|
||||
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES,
|
||||
ecma_builtin_array_species_get,
|
||||
ECMA_ARRAY_ROUTINE_SPECIES_GET,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#endif /* !(ENABLED (JERRY_BUILTIN_ARRAY)) */
|
||||
|
||||
|
||||
@@ -15,16 +15,18 @@
|
||||
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "jrt.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY)
|
||||
#if ENABLED (JERRY_BUILTIN_TYPEDARRAY)
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
@@ -65,7 +67,7 @@ ecma_builtin_arraybuffer_prototype_bytelength_getter (ecma_value_t this_arg) /**
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached."));
|
||||
}
|
||||
ecma_length_t len = ecma_arraybuffer_get_length (object_p);
|
||||
uint32_t len = ecma_arraybuffer_get_length (object_p);
|
||||
|
||||
return ecma_make_uint32_value (len);
|
||||
}
|
||||
@@ -78,15 +80,15 @@ ecma_builtin_arraybuffer_prototype_bytelength_getter (ecma_value_t this_arg) /**
|
||||
* The ArrayBuffer.prototype object's 'slice' routine
|
||||
*
|
||||
* See also:
|
||||
* ES2015, 24.1.4.3
|
||||
* ECMA-262 v11, 24.1.4.3
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_arraybuffer_prototype_object_slice (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t arg1, /**< routine's first argument */
|
||||
ecma_value_t arg2) /**< routine's second argument */
|
||||
const ecma_value_t *argument_list_p, /**< arguments list */
|
||||
uint32_t arguments_number) /**< number of arguments */
|
||||
{
|
||||
if (!ecma_is_value_object (this_arg))
|
||||
{
|
||||
@@ -95,53 +97,134 @@ ecma_builtin_arraybuffer_prototype_object_slice (ecma_value_t this_arg, /**< thi
|
||||
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
/* 2. */
|
||||
if (!ecma_object_class_is (object_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an ArrayBuffer object."));
|
||||
}
|
||||
|
||||
/* TODO: step 3. if SharedArrayBuffer will be implemented */
|
||||
|
||||
/* 4. */
|
||||
if (ecma_arraybuffer_is_detached (object_p))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached."));
|
||||
}
|
||||
|
||||
ecma_length_t len = ecma_arraybuffer_get_length (object_p);
|
||||
/* 5. */
|
||||
uint32_t len = ecma_arraybuffer_get_length (object_p);
|
||||
|
||||
ecma_length_t start = 0, end = len;
|
||||
uint32_t start = 0;
|
||||
uint32_t end = len;
|
||||
|
||||
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (arg1,
|
||||
len,
|
||||
&start)))
|
||||
if (arguments_number > 0)
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
if (!ecma_is_value_undefined (arg2))
|
||||
{
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (arg2,
|
||||
len,
|
||||
&end)))
|
||||
/* 6-7. */
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_uint32_index_normalize (argument_list_p[0],
|
||||
len,
|
||||
&start)))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
if (arguments_number > 1 && !ecma_is_value_undefined (argument_list_p[1]))
|
||||
{
|
||||
/* 8-9 .*/
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_uint32_index_normalize (argument_list_p[1],
|
||||
len,
|
||||
&end)))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ret_value != ECMA_VALUE_EMPTY)
|
||||
/* 10. */
|
||||
uint32_t new_len = (end >= start) ? (end - start) : 0;
|
||||
|
||||
/* 11. */
|
||||
ecma_value_t ctor = ecma_op_species_constructor (object_p, ECMA_BUILTIN_ID_ARRAYBUFFER);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (ctor))
|
||||
{
|
||||
return ret_value;
|
||||
return ctor;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (start <= len && end <= len);
|
||||
ecma_length_t new_len = (end >= start) ? (end - start) : 0;
|
||||
ecma_object_t *new_arraybuffer_p = ecma_arraybuffer_new_object (new_len);
|
||||
/* 12. */
|
||||
ecma_object_t *ctor_obj_p = ecma_get_object_from_value (ctor);
|
||||
ecma_value_t new_len_value = ecma_make_uint32_value (new_len);
|
||||
|
||||
ecma_value_t new_arraybuffer = ecma_op_function_construct (ctor_obj_p, ctor_obj_p, &new_len_value, 1);
|
||||
|
||||
ecma_deref_object (ctor_obj_p);
|
||||
ecma_free_value (new_len_value);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (new_arraybuffer))
|
||||
{
|
||||
return new_arraybuffer;
|
||||
}
|
||||
|
||||
ecma_object_t *new_arraybuffer_p = ecma_get_object_from_value (new_arraybuffer);
|
||||
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
|
||||
|
||||
/* 13. */
|
||||
if (!ecma_object_class_is (new_arraybuffer_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL))
|
||||
{
|
||||
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Return value is not an ArrayBuffer object."));
|
||||
goto free_new_arraybuffer;
|
||||
}
|
||||
|
||||
/* TODO: step 14. if SharedArrayBuffer will be implemented */
|
||||
|
||||
/* 15. */
|
||||
if (ecma_arraybuffer_is_detached (new_arraybuffer_p))
|
||||
{
|
||||
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Return ArrayBuffer has been detached."));
|
||||
goto free_new_arraybuffer;
|
||||
}
|
||||
|
||||
/* 16. */
|
||||
if (ecma_op_same_value (new_arraybuffer, this_arg))
|
||||
{
|
||||
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer subclass returned this from species constructor"));
|
||||
goto free_new_arraybuffer;
|
||||
}
|
||||
|
||||
/* 17. */
|
||||
if (ecma_arraybuffer_get_length (new_arraybuffer_p) < new_len)
|
||||
{
|
||||
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Derived ArrayBuffer constructor created a too small buffer."));
|
||||
goto free_new_arraybuffer;
|
||||
}
|
||||
|
||||
/* 19. */
|
||||
if (ecma_arraybuffer_is_detached (object_p))
|
||||
{
|
||||
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Original ArrayBuffer has been detached."));
|
||||
goto free_new_arraybuffer;
|
||||
}
|
||||
|
||||
/* 20. */
|
||||
lit_utf8_byte_t *old_buf = ecma_arraybuffer_get_buffer (object_p);
|
||||
|
||||
/* 21. */
|
||||
lit_utf8_byte_t *new_buf = ecma_arraybuffer_get_buffer (new_arraybuffer_p);
|
||||
|
||||
/* 22. */
|
||||
memcpy (new_buf, old_buf + start, new_len);
|
||||
|
||||
return ecma_make_object_value (new_arraybuffer_p);
|
||||
free_new_arraybuffer:
|
||||
if (ret_value != ECMA_VALUE_EMPTY)
|
||||
{
|
||||
ecma_deref_object (new_arraybuffer_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 23. */
|
||||
ret_value = ecma_make_object_value (new_arraybuffer_p);
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_arraybuffer_prototype_object_slice */
|
||||
|
||||
/**
|
||||
@@ -150,4 +233,4 @@ ecma_builtin_arraybuffer_prototype_object_slice (ecma_value_t this_arg, /**< thi
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_TYPEDARRAY) */
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY)
|
||||
#if ENABLED (JERRY_BUILTIN_TYPEDARRAY)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
@@ -33,17 +33,15 @@ ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
|
||||
ecma_builtin_arraybuffer_prototype_bytelength_getter,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/* ECMA-262 v6, 24.1.4.4 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_ARRAY_BUFFER_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
ROUTINE (LIT_MAGIC_STRING_SLICE, ecma_builtin_arraybuffer_prototype_object_slice, 2, 2)
|
||||
ROUTINE (LIT_MAGIC_STRING_SLICE, ecma_builtin_arraybuffer_prototype_object_slice, NON_FIXED, 2)
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_TYPEDARRAY) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -20,11 +20,10 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
#include "ecma-dataview-object.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "ecma-typedarray-object.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY)
|
||||
#if ENABLED (JERRY_BUILTIN_TYPEDARRAY)
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
@@ -72,7 +71,7 @@ ecma_builtin_arraybuffer_object_is_view (ecma_value_t this_arg, /**< 'this' argu
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_arraybuffer_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
@@ -86,7 +85,7 @@ ecma_builtin_arraybuffer_dispatch_call (const ecma_value_t *arguments_list_p, /*
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_arraybuffer_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
@@ -111,4 +110,4 @@ ecma_builtin_arraybuffer_species_get (ecma_value_t this_value) /**< This Value *
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_TYPEDARRAY) */
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY)
|
||||
#if ENABLED (JERRY_BUILTIN_TYPEDARRAY)
|
||||
|
||||
/* Number properties:
|
||||
* (property name, number value, writable, enumerable, configurable) */
|
||||
@@ -50,6 +50,6 @@ ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES,
|
||||
ecma_builtin_arraybuffer_species_get,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_TYPEDARRAY) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
+24
-22
@@ -13,29 +13,31 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
function test_set_prototype_of_error(o, proto, msg)
|
||||
{
|
||||
var name = "";
|
||||
#include "ecma-globals.h"
|
||||
|
||||
try
|
||||
{
|
||||
Object.setPrototypeOf(o, proto);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
name = e.name;
|
||||
}
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
assert(name === "TypeError");
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
if (msg)
|
||||
{
|
||||
print(msg + " PASS (XFAIL)");
|
||||
}
|
||||
}
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-function-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_function_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
(function test_incoercible_o(undefined)
|
||||
{
|
||||
test_set_prototype_of_error(undefined, new Object(), "Object.setPrototypeOf(undefined, ...)");
|
||||
test_set_prototype_of_error(null, new Object(), "Object.setPrototypeOf(null, ...)");
|
||||
})();
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup asyncfunctionprototype ECMA AsyncFunction.prototype object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
@@ -0,0 +1,36 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* %AsyncFunctionPrototype% built-in description (AsyncFunction.prototype)
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/* ECMA-262 v11, 25.7.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_ASYNC_FUNCTION,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v11, 25.7.3.2 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_ASYNC_FUNCTION_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
@@ -0,0 +1,74 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
#include "ecma-function-object.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-function.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_function
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup asyncfunction ECMA AsyncFunction object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handle calling [[Call]] of built-in AsyncFunction object
|
||||
*
|
||||
* @return constructed async function object - if success
|
||||
* raised error otherwise
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_async_function_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
return ecma_op_create_dynamic_function (arguments_list_p,
|
||||
arguments_list_len,
|
||||
ECMA_PARSE_ASYNC_FUNCTION);
|
||||
} /* ecma_builtin_async_function_dispatch_call */
|
||||
|
||||
/**
|
||||
* Handle calling [[Construct]] of built-in AsyncFunction object
|
||||
*
|
||||
* @return constructed async function object - if success
|
||||
* raised error otherwise
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_async_function_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
return ecma_builtin_async_function_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_async_function_dispatch_construct */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
@@ -0,0 +1,41 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* %AsyncFunction% built-in description
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/* ECMA-262 v11, 25.7.2 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ASYNC_FUNCTION_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v11, 25.7.2.1 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v10, 25.7.2.2 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_ASYNC_FUNCTION,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
@@ -0,0 +1,74 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
#include "ecma-function-object.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-generator-function.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator_function
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup asyncgenerator ECMA AsyncGeneratorFunction object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handle calling [[Call]] of built-in AsyncGeneratorFunction object
|
||||
*
|
||||
* @return constructed async generator function object - if success
|
||||
* raised error otherwise
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_async_generator_function_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
return ecma_op_create_dynamic_function (arguments_list_p,
|
||||
arguments_list_len,
|
||||
ECMA_PARSE_GENERATOR_FUNCTION | ECMA_PARSE_ASYNC_FUNCTION);
|
||||
} /* ecma_builtin_async_generator_function_dispatch_call */
|
||||
|
||||
/**
|
||||
* Handle calling [[Construct]] of built-in AsyncGeneratorFunction object
|
||||
*
|
||||
* @return constructed async generator function object - if success
|
||||
* raised error otherwise
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_async_generator_function_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
return ecma_builtin_async_generator_function_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_async_generator_function_dispatch_construct */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
@@ -0,0 +1,41 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* %AsyncGeneratorFunction% built-in description
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/* ECMA-262 v10, 25.3.2 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ASYNC_GENERATOR_FUNCTION_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v10, 25.3.2.1 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 25.3.2.2 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_ASYNC_GENERATOR,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
@@ -0,0 +1,147 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-async-generator-object.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-iterator-object.h"
|
||||
#include "ecma-promise-object.h"
|
||||
#include "jcontext.h"
|
||||
#include "opcodes.h"
|
||||
#include "vm-defines.h"
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
/**
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_CUSTOM_DISPATCH
|
||||
|
||||
/**
|
||||
* List of built-in routine identifiers.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_START = 0,
|
||||
ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_NEXT,
|
||||
ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_THROW,
|
||||
ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_RETURN
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-generator-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup asyncgenerator ECMA AsyncGenerator.prototype object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Convert routine type to operation type..
|
||||
*/
|
||||
#define ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION(type) \
|
||||
((ecma_async_generator_operation_type_t) ((type) - ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_NEXT))
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION (ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_NEXT)
|
||||
== ECMA_ASYNC_GENERATOR_DO_NEXT,
|
||||
convert_ecma_async_generator_routine_next_to_ecma_async_generator_do_next_failed);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION (ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_THROW)
|
||||
== ECMA_ASYNC_GENERATOR_DO_THROW,
|
||||
convert_ecma_async_generator_routine_throw_to_ecma_async_generator_do_throw_failed);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION (ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_RETURN)
|
||||
== ECMA_ASYNC_GENERATOR_DO_RETURN,
|
||||
convert_ecma_async_generator_routine_return_to_ecma_async_generator_do_return_failed);
|
||||
|
||||
/**
|
||||
* Dispatcher of the Generator built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_async_generator_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide routine
|
||||
* identifier */
|
||||
ecma_value_t this_arg, /**< 'this' argument value */
|
||||
const ecma_value_t arguments_list_p[], /**< list of arguments
|
||||
* passed to
|
||||
* routine */
|
||||
uint32_t arguments_number) /**< length of arguments'
|
||||
* list */
|
||||
{
|
||||
JERRY_UNUSED (arguments_number);
|
||||
|
||||
vm_executable_object_t *executable_object_p = NULL;
|
||||
|
||||
if (ecma_is_value_object (this_arg))
|
||||
{
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
if (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_CLASS)
|
||||
{
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
if (ext_object_p->u.class_prop.class_id == LIT_MAGIC_STRING_ASYNC_GENERATOR_UL)
|
||||
{
|
||||
executable_object_p = (vm_executable_object_t *) ext_object_p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (executable_object_p == NULL)
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an async generator object."));
|
||||
}
|
||||
|
||||
if (executable_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_COMPLETED)
|
||||
{
|
||||
ecma_value_t promise = ecma_make_object_value (ecma_builtin_get (ECMA_BUILTIN_ID_PROMISE));
|
||||
|
||||
if (JERRY_UNLIKELY (builtin_routine_id == ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_THROW))
|
||||
{
|
||||
return ecma_promise_reject_or_resolve (promise, arguments_list_p[0], false);
|
||||
}
|
||||
|
||||
ecma_value_t iter_result = ecma_create_iter_result_object (ECMA_VALUE_UNDEFINED, ECMA_VALUE_TRUE);
|
||||
ecma_value_t result = ecma_promise_reject_or_resolve (promise, iter_result, true);
|
||||
ecma_free_value (iter_result);
|
||||
return result;
|
||||
}
|
||||
|
||||
return ecma_async_generator_enqueue (executable_object_p,
|
||||
ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION (builtin_routine_id),
|
||||
arguments_list_p[0]);
|
||||
} /* ecma_builtin_async_generator_prototype_dispatch_routine */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
@@ -0,0 +1,45 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* AsyncGenerator.prototype built-in description
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v6, 25.3.1.5 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_ASYNC_GENERATOR_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 25.2.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_ASYNC_GENERATOR,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
ROUTINE (LIT_MAGIC_STRING_NEXT, ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_NEXT, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_RETURN, ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_RETURN, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_THROW, ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_THROW, 1, 1)
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
+22
-45
@@ -13,54 +13,31 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var name = "";
|
||||
#include "ecma-globals.h"
|
||||
|
||||
try
|
||||
{
|
||||
Int16Array.from.call(1);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
name = e.name;
|
||||
}
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
assert(name === "TypeError");
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
name = "";
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-generator.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
try
|
||||
{
|
||||
Int16Array.from.call(Float32Array);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
name = e.name;
|
||||
}
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup asyncgenerator ECMA AsyncGenerator object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
assert(name === "TypeError");
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
name = "";
|
||||
|
||||
try
|
||||
{
|
||||
Int16Array.from.call(Float32Array, [1,2,3], 1);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
name = e.name;
|
||||
}
|
||||
|
||||
assert(name === "TypeError");
|
||||
|
||||
name = "";
|
||||
|
||||
try
|
||||
{
|
||||
Int16Array.from.call(Number, [1,2,3]);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
name = e.name;
|
||||
}
|
||||
|
||||
assert(name === "TypeError");
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
@@ -0,0 +1,41 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* %AsyncGenerator% built-in description (AsyncGeneratorFunction.prototype)
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/* ECMA-262 v6, 25.3.2.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_ASYNC_GENERATOR_FUNCTION,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 25.3.2.3.2 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_ASYNC_GENERATOR_PROTOTYPE,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 25.3.2.3.3 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_ASYNC_GENERATOR_FUNCTION_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
@@ -0,0 +1,63 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-iterator-object.h"
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-iterator-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_iterator_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup %asynciteratorprototype% ECMA %AsyncIteratorPrototype% object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The %AsyncIteratorPrototype% object's '@@asyncIterator' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v10, 25.1.3.1
|
||||
*
|
||||
* Note:
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*
|
||||
* @return the given this value
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_async_iterator_prototype_object_async_iterator (ecma_value_t this_val) /**< this argument */
|
||||
{
|
||||
/* 1. */
|
||||
return ecma_copy_value (this_val);
|
||||
} /* ecma_builtin_async_iterator_prototype_object_async_iterator */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
+11
-17
@@ -13,24 +13,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var obj = {name:""};
|
||||
/*
|
||||
* %AsyncIteratorPrototype% built-in description
|
||||
*/
|
||||
|
||||
var a = new Promise(function(f, r){
|
||||
obj.name = obj.name + "a";
|
||||
f(obj);
|
||||
});
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
a.then(function(x) {
|
||||
x.name = x.name + "b";
|
||||
return x;
|
||||
}).then(null, function(x) {
|
||||
x.name = x.name + "c"; // unreachable
|
||||
return x;
|
||||
}).then(function(x) {
|
||||
x.name = x.name + "d";
|
||||
assert (obj.name === "aebd");
|
||||
});
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
obj.name = obj.name + "e";
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
ROUTINE (LIT_GLOBAL_SYMBOL_ASYNC_ITERATOR, ecma_builtin_async_iterator_prototype_object_async_iterator, 0, 0)
|
||||
|
||||
assert (obj.name === "ae")
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
@@ -0,0 +1,134 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-bigint.h"
|
||||
#include "ecma-exceptions.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
/**
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-bigint-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID bigint_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup bigint ECMA BigInt object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The BigInt.prototype object's 'valueOf' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v11, 20.2.3.4
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_bigint_prototype_object_value_of (ecma_value_t this_arg) /**< this argument */
|
||||
{
|
||||
if (ecma_is_value_bigint (this_arg))
|
||||
{
|
||||
return ecma_copy_value (this_arg);
|
||||
}
|
||||
|
||||
if (ecma_is_value_object (this_arg))
|
||||
{
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
if (ecma_object_class_is (object_p, LIT_MAGIC_STRING_BIGINT_UL))
|
||||
{
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_bigint (ext_object_p->u.class_prop.u.value));
|
||||
|
||||
return ecma_copy_value (ext_object_p->u.class_prop.u.value);
|
||||
}
|
||||
}
|
||||
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("BigInt value expected."));
|
||||
} /* ecma_builtin_bigint_prototype_object_value_of */
|
||||
|
||||
/**
|
||||
* The BigInt.prototype object's 'toString' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v11, 20.2.3.3
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_bigint_prototype_object_to_string (ecma_value_t this_arg, /**< this argument */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
ecma_value_t bigint = ecma_builtin_bigint_prototype_object_value_of (this_arg);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (bigint))
|
||||
{
|
||||
return bigint;
|
||||
}
|
||||
|
||||
uint32_t radix = 10;
|
||||
|
||||
if (arguments_list_len > 0 && !ecma_is_value_undefined (arguments_list_p[0]))
|
||||
{
|
||||
ecma_number_t arg_num;
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_op_to_integer (arguments_list_p[0], &arg_num)))
|
||||
{
|
||||
ecma_free_value (bigint);
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
if (arg_num < 2 || arg_num > 36)
|
||||
{
|
||||
ecma_free_value (bigint);
|
||||
return ecma_raise_range_error (ECMA_ERR_MSG ("Radix must be between 2 and 36."));
|
||||
}
|
||||
|
||||
radix = (uint32_t) arg_num;
|
||||
}
|
||||
|
||||
ecma_string_t *string_p = ecma_bigint_to_string (bigint, radix);
|
||||
ecma_free_value (bigint);
|
||||
|
||||
if (string_p == NULL)
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
return ecma_make_string_value (string_p);
|
||||
} /* ecma_builtin_bigint_prototype_object_to_string */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
@@ -0,0 +1,44 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* BigInt.prototype built-in description
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v11, 20.2.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_BIGINT,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v11, 20.2.3.5 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_BIGINT_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
ROUTINE (LIT_MAGIC_STRING_VALUE_OF_UL, ecma_builtin_bigint_prototype_object_value_of, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_STRING_UL, ecma_builtin_bigint_prototype_object_to_string, NON_FIXED, 0)
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
@@ -0,0 +1,80 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-bigint.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-exceptions.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-bigint.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID bigint
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup bigint ECMA BigInt object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handle calling [[Call]] of built-in BigInt object
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v11, 20.2.1.1
|
||||
*
|
||||
* @return ecma value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_bigint_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
ecma_value_t value = (arguments_list_len == 0) ? ECMA_VALUE_UNDEFINED : arguments_list_p[0];
|
||||
return ecma_bigint_to_bigint (value, true);
|
||||
} /* ecma_builtin_bigint_dispatch_call */
|
||||
|
||||
/**
|
||||
* Handle calling [[Construct]] of built-in BigInt object
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v11, 20.2.1
|
||||
*
|
||||
* @return ecma value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_bigint_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("BigInt function is not a constructor."));
|
||||
} /* ecma_builtin_bigint_dispatch_construct */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
@@ -0,0 +1,47 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* BigInt built-in description
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
|
||||
/* Number properties:
|
||||
* (property name, number value, writable, enumerable, configurable) */
|
||||
|
||||
/* ECMA-262 v11, 20.2.1 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v11, 20.2.1 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_BIGINT_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v11, 20.2.2.3 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_BIGINT_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-string-object.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BOOLEAN)
|
||||
@@ -30,6 +29,21 @@
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
/**
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_CUSTOM_DISPATCH
|
||||
|
||||
/**
|
||||
* List of built-in routine identifiers.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
ECMA_BOOLEAN_PROTOTYPE_ROUTINE_START = 0,
|
||||
ECMA_BOOLEAN_PROTOTYPE_ROUTINE_TO_STRING,
|
||||
ECMA_BOOLEAN_PROTOTYPE_ROUTINE_VALUE_OF
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-boolean-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID boolean_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
@@ -44,40 +58,6 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Boolean.prototype object's 'toString' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v5, 15.6.4.2
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_boolean_prototype_object_to_string (ecma_value_t this_arg) /**< this argument */
|
||||
{
|
||||
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
|
||||
|
||||
ECMA_TRY_CATCH (value_of_ret,
|
||||
ecma_builtin_boolean_prototype_object_value_of (this_arg),
|
||||
ret_value);
|
||||
|
||||
if (ecma_is_value_true (value_of_ret))
|
||||
{
|
||||
ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING_TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_boolean (value_of_ret));
|
||||
|
||||
ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING_FALSE);
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (value_of_ret);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_boolean_prototype_object_to_string */
|
||||
|
||||
/**
|
||||
* The Boolean.prototype object's 'valueOf' routine
|
||||
*
|
||||
@@ -111,6 +91,46 @@ ecma_builtin_boolean_prototype_object_value_of (ecma_value_t this_arg) /**< this
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a Boolean object."));
|
||||
} /* ecma_builtin_boolean_prototype_object_value_of */
|
||||
|
||||
/**
|
||||
* Dispatcher of the built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_boolean_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide routine
|
||||
* identifier */
|
||||
ecma_value_t this_arg, /**< 'this' argument value */
|
||||
const ecma_value_t arguments_list_p[], /**< list of arguments
|
||||
* passed to routine */
|
||||
uint32_t arguments_number) /**< length of arguments' list */
|
||||
{
|
||||
JERRY_UNUSED (arguments_number);
|
||||
JERRY_UNUSED (arguments_list_p);
|
||||
|
||||
ecma_value_t value_of_ret = ecma_builtin_boolean_prototype_object_value_of (this_arg);
|
||||
if (builtin_routine_id == ECMA_BOOLEAN_PROTOTYPE_ROUTINE_VALUE_OF)
|
||||
{
|
||||
return value_of_ret;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (builtin_routine_id == ECMA_BOOLEAN_PROTOTYPE_ROUTINE_TO_STRING);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (value_of_ret))
|
||||
{
|
||||
return value_of_ret;
|
||||
}
|
||||
|
||||
if (ecma_is_value_true (value_of_ret))
|
||||
{
|
||||
return ecma_make_magic_string_value (LIT_MAGIC_STRING_TRUE);
|
||||
}
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_false (value_of_ret));
|
||||
|
||||
return ecma_make_magic_string_value (LIT_MAGIC_STRING_FALSE);
|
||||
} /* ecma_builtin_boolean_prototype_dispatch_routine */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
|
||||
@@ -31,8 +31,8 @@ OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_STRING_UL, ecma_builtin_boolean_prototype_object_to_string, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_VALUE_OF_UL, ecma_builtin_boolean_prototype_object_value_of, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_STRING_UL, ECMA_BOOLEAN_PROTOTYPE_ROUTINE_TO_STRING, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_VALUE_OF_UL, ECMA_BOOLEAN_PROTOTYPE_ROUTINE_VALUE_OF, 0, 0)
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BOOLEAN) */
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BOOLEAN)
|
||||
@@ -51,7 +50,7 @@
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_boolean_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
@@ -76,7 +75,7 @@ ecma_builtin_boolean_dispatch_call (const ecma_value_t *arguments_list_p, /**< a
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_boolean_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
|
||||
@@ -36,11 +36,11 @@ NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_BOOLEAN_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BOOLEAN) */
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
#include "ecma-dataview-object.h"
|
||||
#include "ecma-gc.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW)
|
||||
#if ENABLED (JERRY_BUILTIN_DATAVIEW)
|
||||
|
||||
#ifdef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
|
||||
#if !ENABLED (JERRY_BUILTIN_TYPEDARRAY)
|
||||
#error "DataView builtin requires ES2015 TypedArray builtin"
|
||||
#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
|
||||
#endif /* !ENABLED (JERRY_BUILTIN_TYPEDARRAY) */
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
@@ -37,7 +37,7 @@
|
||||
*/
|
||||
enum
|
||||
{
|
||||
ECMA_DATAVIEW_PROTOTYPE_ROUTINE_START = ECMA_BUILTIN_ID__COUNT - 1,
|
||||
ECMA_DATAVIEW_PROTOTYPE_ROUTINE_START = 0,
|
||||
ECMA_DATAVIEW_PROTOTYPE_BUFFER_GETTER,
|
||||
ECMA_DATAVIEW_PROTOTYPE_BYTE_LENGTH_GETTER,
|
||||
ECMA_DATAVIEW_PROTOTYPE_BYTE_OFFSET_GETTER,
|
||||
@@ -52,6 +52,10 @@ enum
|
||||
#if ENABLED (JERRY_NUMBER_TYPE_FLOAT64)
|
||||
ECMA_DATAVIEW_PROTOTYPE_GET_FLOAT64,
|
||||
#endif /* ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
ECMA_DATAVIEW_PROTOTYPE_GET_BIGINT64,
|
||||
ECMA_DATAVIEW_PROTOTYPE_GET_BIGUINT64,
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
ECMA_DATAVIEW_PROTOTYPE_SET_INT8,
|
||||
ECMA_DATAVIEW_PROTOTYPE_SET_UINT8,
|
||||
ECMA_DATAVIEW_PROTOTYPE_SET_UINT8_CLAMPED, /* unused value */
|
||||
@@ -63,6 +67,10 @@ enum
|
||||
#if ENABLED (JERRY_NUMBER_TYPE_FLOAT64)
|
||||
ECMA_DATAVIEW_PROTOTYPE_SET_FLOAT64,
|
||||
#endif /* ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
ECMA_DATAVIEW_PROTOTYPE_SET_BIGINT64,
|
||||
ECMA_DATAVIEW_PROTOTYPE_SET_BIGUINT64,
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-dataview-prototype.inc.h"
|
||||
@@ -138,11 +146,11 @@ ecma_builtin_dataview_prototype_object_getters (ecma_value_t this_arg, /**< this
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_dataview_prototype_dispatch_routine (uint16_t builtin_routine_id, /**< built-in wide routine identifier */
|
||||
ecma_builtin_dataview_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide routine identifier */
|
||||
ecma_value_t this_arg, /**< 'this' argument value */
|
||||
const ecma_value_t arguments_list_p[], /**< list of arguments
|
||||
* passed to routine */
|
||||
ecma_length_t arguments_number) /**< length of arguments' list */
|
||||
uint32_t arguments_number) /**< length of arguments' list */
|
||||
{
|
||||
ecma_value_t byte_offset = arguments_number > 0 ? arguments_list_p[0] : ECMA_VALUE_UNDEFINED;
|
||||
|
||||
@@ -162,6 +170,10 @@ ecma_builtin_dataview_prototype_dispatch_routine (uint16_t builtin_routine_id, /
|
||||
case ECMA_DATAVIEW_PROTOTYPE_GET_INT32:
|
||||
case ECMA_DATAVIEW_PROTOTYPE_GET_UINT16:
|
||||
case ECMA_DATAVIEW_PROTOTYPE_GET_UINT32:
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
case ECMA_DATAVIEW_PROTOTYPE_GET_BIGINT64:
|
||||
case ECMA_DATAVIEW_PROTOTYPE_GET_BIGUINT64:
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
{
|
||||
ecma_value_t little_endian = arguments_number > 1 ? arguments_list_p[1] : ECMA_VALUE_FALSE;
|
||||
ecma_typedarray_type_t id = (ecma_typedarray_type_t) (builtin_routine_id - ECMA_DATAVIEW_PROTOTYPE_GET_INT8);
|
||||
@@ -176,6 +188,10 @@ ecma_builtin_dataview_prototype_dispatch_routine (uint16_t builtin_routine_id, /
|
||||
case ECMA_DATAVIEW_PROTOTYPE_SET_INT32:
|
||||
case ECMA_DATAVIEW_PROTOTYPE_SET_UINT16:
|
||||
case ECMA_DATAVIEW_PROTOTYPE_SET_UINT32:
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
case ECMA_DATAVIEW_PROTOTYPE_SET_BIGINT64:
|
||||
case ECMA_DATAVIEW_PROTOTYPE_SET_BIGUINT64:
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
{
|
||||
ecma_value_t value_to_set = arguments_number > 1 ? arguments_list_p[1] : ECMA_VALUE_UNDEFINED;
|
||||
ecma_value_t little_endian = arguments_number > 2 ? arguments_list_p[2] : ECMA_VALUE_FALSE;
|
||||
@@ -208,4 +224,4 @@ ecma_builtin_dataview_prototype_dispatch_routine (uint16_t builtin_routine_id, /
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_DATAVIEW */
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW)
|
||||
#if ENABLED (JERRY_BUILTIN_DATAVIEW)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
@@ -29,12 +29,10 @@ OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_DATAVIEW,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
/* ECMA-262 v6, 23.2.4.21 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_DATAVIEW_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
@@ -48,16 +46,22 @@ ROUTINE (LIT_MAGIC_STRING_GET_INT32_UL, ECMA_DATAVIEW_PROTOTYPE_GET_INT32, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_GET_UINT8_UL, ECMA_DATAVIEW_PROTOTYPE_GET_UINT8, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_GET_UINT16_UL, ECMA_DATAVIEW_PROTOTYPE_GET_UINT16, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_GET_UINT32_UL, ECMA_DATAVIEW_PROTOTYPE_GET_UINT32, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_FLOAT_32_UL, ECMA_DATAVIEW_PROTOTYPE_SET_FLOAT32, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_FLOAT_32_UL, ECMA_DATAVIEW_PROTOTYPE_SET_FLOAT32, 2, 2)
|
||||
#if ENABLED (JERRY_NUMBER_TYPE_FLOAT64)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_FLOAT_64_UL, ECMA_DATAVIEW_PROTOTYPE_SET_FLOAT64, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_FLOAT_64_UL, ECMA_DATAVIEW_PROTOTYPE_SET_FLOAT64, 2, 2)
|
||||
#endif /* ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_INT8_UL, ECMA_DATAVIEW_PROTOTYPE_SET_INT8, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_INT16_UL, ECMA_DATAVIEW_PROTOTYPE_SET_INT16, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_INT32_UL, ECMA_DATAVIEW_PROTOTYPE_SET_INT32, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_UINT8_UL, ECMA_DATAVIEW_PROTOTYPE_SET_UINT8, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_UINT16_UL, ECMA_DATAVIEW_PROTOTYPE_SET_UINT16, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_UINT32_UL, ECMA_DATAVIEW_PROTOTYPE_SET_UINT32, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_INT8_UL, ECMA_DATAVIEW_PROTOTYPE_SET_INT8, 1, 2)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_INT16_UL, ECMA_DATAVIEW_PROTOTYPE_SET_INT16, 2, 2)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_INT32_UL, ECMA_DATAVIEW_PROTOTYPE_SET_INT32, 2, 2)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_UINT8_UL, ECMA_DATAVIEW_PROTOTYPE_SET_UINT8, 2, 2)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_UINT16_UL, ECMA_DATAVIEW_PROTOTYPE_SET_UINT16, 2, 2)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_UINT32_UL, ECMA_DATAVIEW_PROTOTYPE_SET_UINT32, 2, 2)
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
ROUTINE (LIT_MAGIC_STRING_GET_BIGINT64, ECMA_DATAVIEW_PROTOTYPE_GET_BIGINT64, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_GET_BIGUINT64, ECMA_DATAVIEW_PROTOTYPE_GET_BIGUINT64, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_BIGINT64, ECMA_DATAVIEW_PROTOTYPE_SET_BIGINT64, 2, 2)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_BIGUINT64, ECMA_DATAVIEW_PROTOTYPE_SET_BIGUINT64, 2, 2)
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
|
||||
/* ECMA-262 v6, 24.2.4.1 */
|
||||
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BUFFER,
|
||||
@@ -74,6 +78,6 @@ ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_OFFSET_UL,
|
||||
ECMA_DATAVIEW_PROTOTYPE_BYTE_OFFSET_GETTER,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_DATAVIEW */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-dataview-object.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW)
|
||||
#if ENABLED (JERRY_BUILTIN_DATAVIEW)
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
@@ -43,7 +43,7 @@
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_dataview_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
@@ -57,7 +57,7 @@ ecma_builtin_dataview_dispatch_call (const ecma_value_t *arguments_list_p, /**<
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_dataview_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
return ecma_op_dataview_create (arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_dataview_dispatch_construct */
|
||||
@@ -68,4 +68,4 @@ ecma_builtin_dataview_dispatch_construct (const ecma_value_t *arguments_list_p,
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_DATAVIEW */
|
||||
|
||||
@@ -19,14 +19,14 @@
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW)
|
||||
#if ENABLED (JERRY_BUILTIN_DATAVIEW)
|
||||
|
||||
/* Number properties:
|
||||
* (property name, number value, writable, enumerable, configurable) */
|
||||
|
||||
/* ECMA-262 v6, 23.1.2 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
3,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 23.1 */
|
||||
@@ -42,6 +42,6 @@ OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_DATAVIEW_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_DATAVIEW */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-objects-general.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_DATE)
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
*/
|
||||
enum
|
||||
{
|
||||
ECMA_DATE_PROTOTYPE_ROUTINE_START = ECMA_BUILTIN_ID__COUNT - 1,
|
||||
ECMA_DATE_PROTOTYPE_ROUTINE_START = 0,
|
||||
|
||||
ECMA_DATE_PROTOTYPE_GET_FULL_YEAR, /* ECMA-262 v5 15.9.5.10 */
|
||||
ECMA_DATE_PROTOTYPE_GET_UTC_FULL_YEAR, /* ECMA-262 v5 15.9.5.11 */
|
||||
@@ -92,17 +92,19 @@ enum
|
||||
|
||||
ECMA_DATE_PROTOTYPE_TO_STRING, /* ECMA-262 v5, 15.9.5.2 */
|
||||
ECMA_DATE_PROTOTYPE_TO_DATE_STRING, /* ECMA-262 v5, 15.9.5.3 */
|
||||
ECMA_DATE_PROTOTYPE_TO_TIME_STRING, /* ECMA-262 v5, 15.9.5.4 */
|
||||
#if !ENABLED (JERRY_ESNEXT)
|
||||
ECMA_DATE_PROTOTYPE_TO_UTC_STRING, /* ECMA-262 v5, 15.9.5.42 */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
ECMA_DATE_PROTOTYPE_TO_TIME_STRING, /* ECMA-262 v5, 15.9.5.4 */
|
||||
ECMA_DATE_PROTOTYPE_TO_ISO_STRING, /* ECMA-262 v5, 15.9.5.43 */
|
||||
|
||||
ECMA_DATE_PROTOTYPE_GET_TIME, /* ECMA-262 v5, 15.9.5.9 */
|
||||
ECMA_DATE_PROTOTYPE_SET_TIME, /* ECMA-262 v5, 15.9.5.27 */
|
||||
ECMA_DATE_PROTOTYPE_TO_JSON, /* ECMA-262 v5, 15.9.5.44 */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ECMA_DATE_PROTOTYPE_TO_PRIMITIVE, /* ECMA-262 v6 20.3.4.45 */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-date-prototype.inc.h"
|
||||
@@ -131,60 +133,52 @@ enum
|
||||
static ecma_value_t
|
||||
ecma_builtin_date_prototype_to_json (ecma_value_t this_arg) /**< this argument */
|
||||
{
|
||||
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
|
||||
|
||||
/* 1. */
|
||||
ECMA_TRY_CATCH (obj,
|
||||
ecma_op_to_object (this_arg),
|
||||
ret_value);
|
||||
ecma_value_t obj = ecma_op_to_object (this_arg);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (obj))
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
|
||||
/* 2. */
|
||||
ECMA_TRY_CATCH (tv,
|
||||
ecma_op_to_primitive (obj, ECMA_PREFERRED_TYPE_NUMBER),
|
||||
ret_value);
|
||||
ecma_value_t tv = ecma_op_to_primitive (obj, ECMA_PREFERRED_TYPE_NUMBER);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (tv))
|
||||
{
|
||||
ecma_free_value (obj);
|
||||
return tv;
|
||||
}
|
||||
|
||||
/* 3. */
|
||||
if (ecma_is_value_number (tv))
|
||||
{
|
||||
ecma_number_t num_value = ecma_get_number_from_value (tv);
|
||||
|
||||
ecma_free_value (tv);
|
||||
|
||||
if (ecma_number_is_nan (num_value) || ecma_number_is_infinity (num_value))
|
||||
{
|
||||
ret_value = ECMA_VALUE_NULL;
|
||||
ecma_free_value (obj);
|
||||
return ECMA_VALUE_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (ecma_is_value_empty (ret_value))
|
||||
else
|
||||
{
|
||||
ecma_object_t *value_obj_p = ecma_get_object_from_value (obj);
|
||||
|
||||
/* 4. */
|
||||
ECMA_TRY_CATCH (to_iso,
|
||||
ecma_op_object_get_by_magic_id (value_obj_p, LIT_MAGIC_STRING_TO_ISO_STRING_UL),
|
||||
ret_value);
|
||||
|
||||
/* 5. */
|
||||
if (!ecma_op_is_callable (to_iso))
|
||||
{
|
||||
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("'toISOString' is missing or not a function."));
|
||||
}
|
||||
/* 6. */
|
||||
else
|
||||
{
|
||||
ecma_object_t *to_iso_obj_p = ecma_get_object_from_value (to_iso);
|
||||
ret_value = ecma_op_function_call (to_iso_obj_p, this_arg, NULL, 0);
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (to_iso);
|
||||
ecma_free_value (tv);
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (tv);
|
||||
ECMA_FINALIZE (obj);
|
||||
ecma_object_t *value_obj_p = ecma_get_object_from_value (obj);
|
||||
|
||||
/* 4. */
|
||||
ecma_value_t ret_value = ecma_op_invoke_by_magic_id (obj, LIT_MAGIC_STRING_TO_ISO_STRING_UL, NULL, 0);
|
||||
|
||||
ecma_deref_object (value_obj_p);
|
||||
|
||||
return ret_value;
|
||||
} /* ecma_builtin_date_prototype_to_json */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/**
|
||||
* The Date.prototype object's toPrimitive routine
|
||||
*
|
||||
@@ -202,7 +196,7 @@ ecma_builtin_date_prototype_to_primitive (ecma_value_t this_arg, /**< this argum
|
||||
{
|
||||
ecma_string_t *hint_str_p = ecma_get_string_from_value (hint_arg);
|
||||
|
||||
ecma_preferred_type_hint_t hint = ECMA_PREFERRED_TYPE_NUMBER;
|
||||
ecma_preferred_type_hint_t hint = ECMA_PREFERRED_TYPE_NO;
|
||||
|
||||
if (hint_str_p == ecma_get_magic_string (LIT_MAGIC_STRING_STRING)
|
||||
|| hint_str_p == ecma_get_magic_string (LIT_MAGIC_STRING_DEFAULT))
|
||||
@@ -222,7 +216,7 @@ ecma_builtin_date_prototype_to_primitive (ecma_value_t this_arg, /**< this argum
|
||||
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Invalid argument type in toPrimitive."));
|
||||
} /* ecma_builtin_date_prototype_to_primitive */
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Dispatch get date functions
|
||||
@@ -347,10 +341,10 @@ ecma_builtin_date_prototype_dispatch_set (uint16_t builtin_routine_id, /**< buil
|
||||
ecma_number_t date_num, /**< date converted to number */
|
||||
const ecma_value_t arguments_list[], /**< list of arguments
|
||||
* passed to routine */
|
||||
ecma_length_t arguments_number) /**< length of arguments' list */
|
||||
uint32_t arguments_number) /**< length of arguments' list */
|
||||
{
|
||||
ecma_number_t converted_number[4];
|
||||
ecma_length_t conversions = 0;
|
||||
uint32_t conversions = 0;
|
||||
|
||||
/* If the first argument is not specified, it is always converted to NaN. */
|
||||
converted_number[0] = ecma_number_make_nan ();
|
||||
@@ -399,17 +393,14 @@ ecma_builtin_date_prototype_dispatch_set (uint16_t builtin_routine_id, /**< buil
|
||||
conversions = arguments_number;
|
||||
}
|
||||
|
||||
for (ecma_length_t i = 0; i < conversions; i++)
|
||||
for (uint32_t i = 0; i < conversions; i++)
|
||||
{
|
||||
ecma_value_t value = ecma_op_to_number (arguments_list[i]);
|
||||
ecma_value_t value = ecma_op_to_number (arguments_list[i], &converted_number[i]);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
converted_number[i] = ecma_get_number_from_value (value);
|
||||
ecma_free_value (value);
|
||||
}
|
||||
|
||||
ecma_number_t day_part;
|
||||
@@ -593,25 +584,25 @@ ecma_builtin_date_prototype_dispatch_set (uint16_t builtin_routine_id, /**< buil
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_date_prototype_dispatch_routine (uint16_t builtin_routine_id, /**< built-in wide routine
|
||||
* identifier */
|
||||
ecma_builtin_date_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide routine
|
||||
* identifier */
|
||||
ecma_value_t this_arg, /**< 'this' argument value */
|
||||
const ecma_value_t arguments_list[], /**< list of arguments
|
||||
* passed to routine */
|
||||
ecma_length_t arguments_number) /**< length of arguments' list */
|
||||
uint32_t arguments_number) /**< length of arguments' list */
|
||||
{
|
||||
if (JERRY_UNLIKELY (builtin_routine_id == ECMA_DATE_PROTOTYPE_TO_JSON))
|
||||
{
|
||||
return ecma_builtin_date_prototype_to_json (this_arg);
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (JERRY_UNLIKELY (builtin_routine_id == ECMA_DATE_PROTOTYPE_TO_PRIMITIVE))
|
||||
{
|
||||
ecma_value_t argument = arguments_number > 0 ? arguments_list[0] : ECMA_VALUE_UNDEFINED;
|
||||
return ecma_builtin_date_prototype_to_primitive (this_arg, argument);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (!ecma_is_value_object (this_arg)
|
||||
|| !ecma_object_class_is (ecma_get_object_from_value (this_arg), LIT_MAGIC_STRING_DATE_UL))
|
||||
@@ -630,16 +621,16 @@ ecma_builtin_date_prototype_dispatch_routine (uint16_t builtin_routine_id, /**<
|
||||
|
||||
if (builtin_routine_id == ECMA_DATE_PROTOTYPE_SET_TIME)
|
||||
{
|
||||
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
|
||||
ecma_number_t time_num;
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_op_to_number (arguments_list[0], &time_num)))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
/* 1. */
|
||||
ECMA_OP_TO_NUMBER_TRY_CATCH (time_num, arguments_list[0], ret_value);
|
||||
*prim_value_p = ecma_date_time_clip (time_num);
|
||||
|
||||
ret_value = ecma_make_number_value (time_num);
|
||||
ECMA_OP_TO_NUMBER_FINALIZE (time_num);
|
||||
|
||||
return ret_value;
|
||||
return ecma_make_number_value (time_num);
|
||||
}
|
||||
|
||||
if (builtin_routine_id <= ECMA_DATE_PROTOTYPE_SET_UTC_MILLISECONDS)
|
||||
@@ -688,15 +679,17 @@ ecma_builtin_date_prototype_dispatch_routine (uint16_t builtin_routine_id, /**<
|
||||
{
|
||||
return ecma_date_value_to_date_string (*prim_value_p);
|
||||
}
|
||||
case ECMA_DATE_PROTOTYPE_TO_TIME_STRING:
|
||||
#if !ENABLED (JERRY_ESNEXT)
|
||||
case ECMA_DATE_PROTOTYPE_TO_UTC_STRING:
|
||||
{
|
||||
return ecma_date_value_to_time_string (*prim_value_p);
|
||||
return ecma_date_value_to_utc_string (*prim_value_p);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
default:
|
||||
{
|
||||
JERRY_ASSERT (builtin_routine_id == ECMA_DATE_PROTOTYPE_TO_UTC_STRING);
|
||||
JERRY_ASSERT (builtin_routine_id == ECMA_DATE_PROTOTYPE_TO_TIME_STRING);
|
||||
|
||||
return ecma_date_value_to_utc_string (*prim_value_p);
|
||||
return ecma_date_value_to_time_string (*prim_value_p);
|
||||
}
|
||||
}
|
||||
} /* ecma_builtin_date_prototype_dispatch_routine */
|
||||
|
||||
@@ -65,18 +65,27 @@ ROUTINE (LIT_MAGIC_STRING_SET_MONTH_UL, ECMA_DATE_PROTOTYPE_SET_MONTH, 2, 2)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_UTC_MONTH_UL, ECMA_DATE_PROTOTYPE_SET_UTC_MONTH, 2, 2)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_FULL_YEAR_UL, ECMA_DATE_PROTOTYPE_SET_FULL_YEAR, NON_FIXED, 3)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_UTC_FULL_YEAR_UL, ECMA_DATE_PROTOTYPE_SET_UTC_FULL_YEAR, NON_FIXED, 3)
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_UTC_STRING_UL, ECMA_DATE_PROTOTYPE_TO_UTC_STRING, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_ISO_STRING_UL, ECMA_DATE_PROTOTYPE_TO_ISO_STRING, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_JSON_UL, ECMA_DATE_PROTOTYPE_TO_JSON, 1, 1)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ROUTINE_CONFIGURABLE_ONLY (LIT_GLOBAL_SYMBOL_TO_PRIMITIVE, ECMA_DATE_PROTOTYPE_TO_PRIMITIVE, 1, 1)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_UTC_STRING_UL, LIT_MAGIC_STRING_TO_UTC_STRING_UL,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#if ENABLED (JERRY_BUILTIN_ANNEXB)
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_GMT_STRING_UL, LIT_MAGIC_STRING_TO_UTC_STRING_UL,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* ENABLED (JERRY_BUILTIN_ANNEXB) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_UTC_STRING_UL, ECMA_DATE_PROTOTYPE_TO_UTC_STRING, 0, 0)
|
||||
#if ENABLED (JERRY_BUILTIN_ANNEXB)
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_GMT_STRING_UL, ECMA_DATE_PROTOTYPE_TO_UTC_STRING, 0, 0)
|
||||
#endif /* ENABLED (JERRY_BUILTIN_ANNEXB) */
|
||||
#endif /* !ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_ANNEXB)
|
||||
|
||||
ROUTINE (LIT_MAGIC_STRING_GET_YEAR_UL, ECMA_DATE_PROTOTYPE_GET_YEAR, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_SET_YEAR_UL, ECMA_DATE_PROTOTYPE_SET_YEAR, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_GMT_STRING_UL, ECMA_DATE_PROTOTYPE_TO_UTC_STRING, 0, 0)
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_ANNEXB) */
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "lit-char-helpers.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_DATE)
|
||||
@@ -69,7 +68,7 @@ ecma_date_parse_date_chars (const lit_utf8_byte_t **str_p, /**< pointer to the c
|
||||
}
|
||||
}
|
||||
|
||||
ecma_number_t parsed_number = ecma_utf8_string_to_number (str_start_p, (lit_utf8_size_t) (*str_p - str_start_p));
|
||||
ecma_number_t parsed_number = ecma_utf8_string_to_number (str_start_p, (lit_utf8_size_t) (*str_p - str_start_p), 0);
|
||||
|
||||
if (parsed_number < min || parsed_number > max)
|
||||
{
|
||||
@@ -196,93 +195,54 @@ ecma_date_parse_month_name (const lit_utf8_byte_t **str_p, /**< pointer to the c
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_date_construct_helper (const ecma_value_t *args, /**< arguments passed to the Date constructor */
|
||||
ecma_length_t args_len) /**< number of arguments */
|
||||
uint32_t args_len) /**< number of arguments */
|
||||
{
|
||||
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
|
||||
ecma_number_t date_nums[7] =
|
||||
{
|
||||
ECMA_NUMBER_ZERO, /* year */
|
||||
ECMA_NUMBER_ZERO, /* month */
|
||||
ECMA_NUMBER_ONE, /* date */
|
||||
ECMA_NUMBER_ZERO, /* hours */
|
||||
ECMA_NUMBER_ZERO, /* minutes */
|
||||
ECMA_NUMBER_ZERO, /* seconds */
|
||||
ECMA_NUMBER_ZERO /* miliseconds */
|
||||
};
|
||||
|
||||
args_len = JERRY_MIN (args_len, sizeof (date_nums) / sizeof (date_nums[0]));
|
||||
|
||||
/* 1-7. */
|
||||
for (uint32_t i = 0; i < args_len; i++)
|
||||
{
|
||||
ecma_value_t status = ecma_op_to_number (args[i], date_nums + i);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (status))
|
||||
{
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
ecma_number_t prim_value = ecma_number_make_nan ();
|
||||
|
||||
ECMA_TRY_CATCH (year_value, ecma_op_to_number (args[0]), ret_value);
|
||||
ECMA_TRY_CATCH (month_value, ecma_op_to_number (args[1]), ret_value);
|
||||
|
||||
ecma_number_t year = ecma_get_number_from_value (year_value);
|
||||
ecma_number_t month = ecma_get_number_from_value (month_value);
|
||||
ecma_number_t date = ECMA_NUMBER_ONE;
|
||||
ecma_number_t hours = ECMA_NUMBER_ZERO;
|
||||
ecma_number_t minutes = ECMA_NUMBER_ZERO;
|
||||
ecma_number_t seconds = ECMA_NUMBER_ZERO;
|
||||
ecma_number_t milliseconds = ECMA_NUMBER_ZERO;
|
||||
|
||||
/* 3. */
|
||||
if (args_len >= 3 && ecma_is_value_empty (ret_value))
|
||||
if (!ecma_number_is_nan (date_nums[0]))
|
||||
{
|
||||
ECMA_TRY_CATCH (date_value, ecma_op_to_number (args[2]), ret_value);
|
||||
date = ecma_get_number_from_value (date_value);
|
||||
ECMA_FINALIZE (date_value);
|
||||
}
|
||||
/* 8. */
|
||||
ecma_number_t y = ecma_number_trunc (date_nums[0]);
|
||||
|
||||
/* 4. */
|
||||
if (args_len >= 4 && ecma_is_value_empty (ret_value))
|
||||
{
|
||||
ECMA_TRY_CATCH (hours_value, ecma_op_to_number (args[3]), ret_value);
|
||||
hours = ecma_get_number_from_value (hours_value);
|
||||
ECMA_FINALIZE (hours_value);
|
||||
}
|
||||
|
||||
/* 5. */
|
||||
if (args_len >= 5 && ecma_is_value_empty (ret_value))
|
||||
{
|
||||
ECMA_TRY_CATCH (minutes_value, ecma_op_to_number (args[4]), ret_value);
|
||||
minutes = ecma_get_number_from_value (minutes_value);
|
||||
ECMA_FINALIZE (minutes_value);
|
||||
}
|
||||
|
||||
/* 6. */
|
||||
if (args_len >= 6 && ecma_is_value_empty (ret_value))
|
||||
{
|
||||
ECMA_TRY_CATCH (seconds_value, ecma_op_to_number (args[5]), ret_value);
|
||||
seconds = ecma_get_number_from_value (seconds_value);
|
||||
ECMA_FINALIZE (seconds_value);
|
||||
}
|
||||
|
||||
/* 7. */
|
||||
if (args_len >= 7 && ecma_is_value_empty (ret_value))
|
||||
{
|
||||
ECMA_TRY_CATCH (milliseconds_value, ecma_op_to_number (args[6]), ret_value);
|
||||
milliseconds = ecma_get_number_from_value (milliseconds_value);
|
||||
ECMA_FINALIZE (milliseconds_value);
|
||||
}
|
||||
|
||||
if (ecma_is_value_empty (ret_value))
|
||||
{
|
||||
if (!ecma_number_is_nan (year))
|
||||
if (y >= 0 && y <= 99)
|
||||
{
|
||||
/* 8. */
|
||||
ecma_number_t y = ecma_number_trunc (year);
|
||||
|
||||
if (y >= 0 && y <= 99)
|
||||
{
|
||||
year = 1900 + y;
|
||||
}
|
||||
date_nums[0] = 1900 + y;
|
||||
}
|
||||
|
||||
prim_value = ecma_date_make_date (ecma_date_make_day (year,
|
||||
month,
|
||||
date),
|
||||
ecma_date_make_time (hours,
|
||||
minutes,
|
||||
seconds,
|
||||
milliseconds));
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (month_value);
|
||||
ECMA_FINALIZE (year_value);
|
||||
prim_value = ecma_date_make_date (ecma_date_make_day (date_nums[0],
|
||||
date_nums[1],
|
||||
date_nums[2]),
|
||||
ecma_date_make_time (date_nums[3],
|
||||
date_nums[4],
|
||||
date_nums[5],
|
||||
date_nums[6]));
|
||||
|
||||
if (ecma_is_value_empty (ret_value))
|
||||
{
|
||||
ret_value = ecma_make_number_value (prim_value);
|
||||
}
|
||||
|
||||
return ret_value;
|
||||
return ecma_make_number_value (prim_value);
|
||||
} /* ecma_date_construct_helper */
|
||||
|
||||
/**
|
||||
@@ -333,6 +293,7 @@ ecma_builtin_date_parse_ISO_string_format (const lit_utf8_byte_t *date_str_curr_
|
||||
day = ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, 2, 1, 31);
|
||||
}
|
||||
|
||||
bool is_utc = true;
|
||||
/* 4. read time if any */
|
||||
if (ecma_date_parse_special_char (&date_str_curr_p, date_str_end_p, 'T'))
|
||||
{
|
||||
@@ -341,8 +302,8 @@ ecma_builtin_date_parse_ISO_string_format (const lit_utf8_byte_t *date_str_curr_
|
||||
ecma_number_t seconds = ECMA_NUMBER_ZERO;
|
||||
ecma_number_t milliseconds = ECMA_NUMBER_ZERO;
|
||||
|
||||
ecma_length_t remaining_length = lit_utf8_string_length (date_str_curr_p,
|
||||
(lit_utf8_size_t) (date_str_end_p - date_str_curr_p));
|
||||
lit_utf8_size_t remaining_length = lit_utf8_string_length (date_str_curr_p,
|
||||
(lit_utf8_size_t) (date_str_end_p - date_str_curr_p));
|
||||
|
||||
if (remaining_length >= 5)
|
||||
{
|
||||
@@ -407,13 +368,24 @@ ecma_builtin_date_parse_ISO_string_format (const lit_utf8_byte_t *date_str_curr_
|
||||
ecma_number_t timezone_offset = ecma_date_make_time (hours, minutes, ECMA_NUMBER_ZERO, ECMA_NUMBER_ZERO);
|
||||
time += is_timezone_sign_negative ? timezone_offset : -timezone_offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
is_utc = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (date_str_curr_p >= date_str_end_p)
|
||||
{
|
||||
ecma_number_t date = ecma_date_make_day (year, month - 1, day);
|
||||
return ecma_date_make_date (date, time);
|
||||
|
||||
ecma_number_t result_date = ecma_date_make_date (date, time);
|
||||
if (!is_utc)
|
||||
{
|
||||
result_date = ecma_date_utc (result_date);
|
||||
}
|
||||
|
||||
return result_date;
|
||||
}
|
||||
}
|
||||
return ecma_number_make_nan ();
|
||||
@@ -638,7 +610,7 @@ ecma_builtin_date_parse (ecma_value_t this_arg, /**< this argument */
|
||||
|
||||
ECMA_FINALIZE_UTF8_STRING (date_start_p, date_start_size);
|
||||
ecma_deref_ecma_string (date_str_p);
|
||||
return ecma_make_number_value (ret_value);
|
||||
return ecma_make_number_value (ecma_date_time_clip (ret_value));
|
||||
} /* ecma_builtin_date_parse */
|
||||
|
||||
/**
|
||||
@@ -653,12 +625,17 @@ ecma_builtin_date_parse (ecma_value_t this_arg, /**< this argument */
|
||||
static ecma_value_t
|
||||
ecma_builtin_date_utc (ecma_value_t this_arg, /**< this argument */
|
||||
const ecma_value_t args[], /**< arguments list */
|
||||
ecma_length_t args_number) /**< number of arguments */
|
||||
uint32_t args_number) /**< number of arguments */
|
||||
{
|
||||
JERRY_UNUSED (this_arg);
|
||||
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
|
||||
|
||||
if (args_number < 2)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
const uint32_t required_args_number = 1;
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
const uint32_t required_args_number = 2;
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (args_number < required_args_number)
|
||||
{
|
||||
/* Note:
|
||||
* When the UTC function is called with fewer than two arguments,
|
||||
@@ -667,16 +644,31 @@ ecma_builtin_date_utc (ecma_value_t this_arg, /**< this argument */
|
||||
return ecma_make_number_value (ecma_number_make_nan ());
|
||||
}
|
||||
|
||||
ECMA_TRY_CATCH (time_value, ecma_date_construct_helper (args, args_number), ret_value);
|
||||
ecma_value_t time_value = ecma_date_construct_helper (args, args_number);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (time_value))
|
||||
{
|
||||
return time_value;
|
||||
}
|
||||
|
||||
ecma_number_t time = ecma_get_number_from_value (time_value);
|
||||
ret_value = ecma_make_number_value (ecma_date_time_clip (time));
|
||||
|
||||
ECMA_FINALIZE (time_value);
|
||||
ecma_free_value (time_value);
|
||||
|
||||
return ret_value;
|
||||
return ecma_make_number_value (ecma_date_time_clip (time));
|
||||
} /* ecma_builtin_date_utc */
|
||||
|
||||
/**
|
||||
* Helper method to get the current time
|
||||
*
|
||||
* @return ecma_number_t
|
||||
*/
|
||||
static ecma_number_t
|
||||
ecma_builtin_date_now_helper (void)
|
||||
{
|
||||
return floor (DOUBLE_TO_ECMA_NUMBER_T (jerry_port_get_current_time ()));
|
||||
} /* ecma_builtin_date_now_helper */
|
||||
|
||||
/**
|
||||
* The Date object's 'now' routine
|
||||
*
|
||||
@@ -690,7 +682,7 @@ static ecma_value_t
|
||||
ecma_builtin_date_now (ecma_value_t this_arg) /**< this argument */
|
||||
{
|
||||
JERRY_UNUSED (this_arg);
|
||||
return ecma_make_number_value (floor (DOUBLE_TO_ECMA_NUMBER_T (jerry_port_get_current_time ())));
|
||||
return ecma_make_number_value (ecma_builtin_date_now_helper ());
|
||||
} /* ecma_builtin_date_now */
|
||||
|
||||
/**
|
||||
@@ -703,21 +695,14 @@ ecma_builtin_date_now (ecma_value_t this_arg) /**< this argument */
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_date_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_UNUSED (arguments_list_p);
|
||||
JERRY_UNUSED (arguments_list_len);
|
||||
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
|
||||
|
||||
ECMA_TRY_CATCH (now_val,
|
||||
ecma_builtin_date_now (ECMA_VALUE_UNDEFINED),
|
||||
ret_value);
|
||||
ecma_number_t now_val_num = ecma_builtin_date_now_helper ();
|
||||
|
||||
ret_value = ecma_date_value_to_string (ecma_get_number_from_value (now_val));
|
||||
|
||||
ECMA_FINALIZE (now_val);
|
||||
|
||||
return ret_value;
|
||||
return ecma_date_value_to_string (now_val_num);
|
||||
} /* ecma_builtin_date_dispatch_call */
|
||||
|
||||
/**
|
||||
@@ -725,111 +710,136 @@ ecma_builtin_date_dispatch_call (const ecma_value_t *arguments_list_p, /**< argu
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v5, 15.9.3.1
|
||||
* ECMA-262 v11, 20.4.2
|
||||
*
|
||||
* @return ecma value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_date_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
|
||||
ecma_number_t prim_value_num = ECMA_NUMBER_ZERO;
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
JERRY_ASSERT (JERRY_CONTEXT (current_new_target_p));
|
||||
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_DATE_PROTOTYPE);
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (JERRY_CONTEXT (current_new_target))
|
||||
ecma_object_t *prototype_obj_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p),
|
||||
ECMA_BUILTIN_ID_DATE_PROTOTYPE);
|
||||
if (JERRY_UNLIKELY (prototype_obj_p == NULL))
|
||||
{
|
||||
prototype_obj_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target),
|
||||
ECMA_BUILTIN_ID_DATE_PROTOTYPE);
|
||||
if (JERRY_UNLIKELY (prototype_obj_p == NULL))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
#endif /* !(ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_DATE_PROTOTYPE);
|
||||
#endif /* (ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
ecma_object_t *obj_p = ecma_create_object (prototype_obj_p,
|
||||
sizeof (ecma_extended_object_t),
|
||||
ECMA_OBJECT_TYPE_CLASS);
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_UNDEFINED;
|
||||
|
||||
ecma_number_t prim_value_num = ECMA_NUMBER_ZERO;
|
||||
|
||||
/* 20.4.2.3 */
|
||||
if (arguments_list_len == 0)
|
||||
{
|
||||
ECMA_TRY_CATCH (parse_res_value,
|
||||
ecma_builtin_date_now (ecma_make_object_value (obj_p)),
|
||||
ret_value);
|
||||
|
||||
prim_value_num = ecma_get_number_from_value (parse_res_value);
|
||||
|
||||
ECMA_FINALIZE (parse_res_value)
|
||||
prim_value_num = ecma_builtin_date_now_helper ();
|
||||
}
|
||||
/* 20.4.2.2 */
|
||||
else if (arguments_list_len == 1)
|
||||
{
|
||||
ECMA_TRY_CATCH (prim_comp_value,
|
||||
ecma_op_to_primitive (arguments_list_p[0], ECMA_PREFERRED_TYPE_NUMBER),
|
||||
ret_value);
|
||||
ecma_value_t argument = arguments_list_p[0];
|
||||
ecma_object_t *arg_obj = NULL;
|
||||
|
||||
if (ecma_is_value_string (prim_comp_value))
|
||||
/* 4.a */
|
||||
if (ecma_is_value_object (argument))
|
||||
{
|
||||
ECMA_TRY_CATCH (parse_res_value,
|
||||
ecma_builtin_date_parse (ecma_make_object_value (obj_p), prim_comp_value),
|
||||
ret_value);
|
||||
|
||||
prim_value_num = ecma_get_number_from_value (parse_res_value);
|
||||
|
||||
ECMA_FINALIZE (parse_res_value);
|
||||
arg_obj = ecma_get_object_from_value (argument);
|
||||
}
|
||||
|
||||
if (arg_obj && ecma_object_class_is (arg_obj, LIT_MAGIC_STRING_DATE_UL))
|
||||
{
|
||||
ecma_extended_object_t *arg_ext_object_p = (ecma_extended_object_t *) arg_obj;
|
||||
prim_value_num = *ECMA_GET_INTERNAL_VALUE_POINTER (ecma_number_t, arg_ext_object_p->u.class_prop.u.value);
|
||||
}
|
||||
/* 4.b */
|
||||
else
|
||||
{
|
||||
ECMA_TRY_CATCH (prim_value, ecma_op_to_number (arguments_list_p[0]), ret_value);
|
||||
ecma_value_t prim_comp_value = ecma_op_to_primitive (argument, ECMA_PREFERRED_TYPE_NUMBER);
|
||||
|
||||
prim_value_num = ecma_date_time_clip (ecma_get_number_from_value (prim_value));
|
||||
if (ECMA_IS_VALUE_ERROR (prim_comp_value))
|
||||
{
|
||||
ecma_deref_object (obj_p);
|
||||
return prim_comp_value;
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (prim_value);
|
||||
if (ecma_is_value_string (prim_comp_value))
|
||||
{
|
||||
ecma_value_t parse_res_value = ecma_builtin_date_parse (ecma_make_object_value (obj_p), prim_comp_value);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (parse_res_value))
|
||||
{
|
||||
ecma_deref_object (obj_p);
|
||||
ecma_free_value (prim_comp_value);
|
||||
return parse_res_value;
|
||||
}
|
||||
|
||||
prim_value_num = ecma_get_number_from_value (parse_res_value);
|
||||
|
||||
ecma_free_value (parse_res_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_number_t arg;
|
||||
ecma_value_t prim_value = ecma_op_to_number (argument, &arg);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (prim_value))
|
||||
{
|
||||
ecma_deref_object (obj_p);
|
||||
ecma_free_value (prim_comp_value);
|
||||
return prim_value;
|
||||
}
|
||||
|
||||
prim_value_num = ecma_date_time_clip (arg);
|
||||
|
||||
}
|
||||
|
||||
ecma_free_value (prim_comp_value);
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (prim_comp_value);
|
||||
}
|
||||
/* 20.4.2.1 */
|
||||
else
|
||||
{
|
||||
ECMA_TRY_CATCH (time_value,
|
||||
ecma_date_construct_helper (arguments_list_p, arguments_list_len),
|
||||
ret_value);
|
||||
ecma_value_t time_value = ecma_date_construct_helper (arguments_list_p, arguments_list_len);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (time_value))
|
||||
{
|
||||
ecma_deref_object (obj_p);
|
||||
return time_value;
|
||||
}
|
||||
|
||||
ecma_number_t time = ecma_get_number_from_value (time_value);
|
||||
prim_value_num = ecma_date_time_clip (ecma_date_utc (time));
|
||||
|
||||
ECMA_FINALIZE (time_value);
|
||||
ecma_free_value (time_value);
|
||||
}
|
||||
|
||||
if (ecma_is_value_empty (ret_value))
|
||||
if (!ecma_number_is_nan (prim_value_num) && ecma_number_is_infinity (prim_value_num))
|
||||
{
|
||||
if (!ecma_number_is_nan (prim_value_num) && ecma_number_is_infinity (prim_value_num))
|
||||
{
|
||||
prim_value_num = ecma_number_make_nan ();
|
||||
}
|
||||
|
||||
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_DATE_UL;
|
||||
|
||||
ecma_number_t *date_num_p = ecma_alloc_number ();
|
||||
*date_num_p = prim_value_num;
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (ext_object_p->u.class_prop.u.value, date_num_p);
|
||||
|
||||
ret_value = ecma_make_object_value (obj_p);
|
||||
prim_value_num = ecma_number_make_nan ();
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (ECMA_IS_VALUE_ERROR (ret_value));
|
||||
ecma_deref_object (obj_p);
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
if (JERRY_CONTEXT (current_new_target))
|
||||
{
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
}
|
||||
#endif /* !(ENABLED (JERRY_ES2015) */
|
||||
return ret_value;
|
||||
|
||||
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_DATE_UL;
|
||||
|
||||
ecma_number_t *date_num_p = ecma_alloc_number ();
|
||||
*date_num_p = prim_value_num;
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (ext_object_p->u.class_prop.u.value, date_num_p);
|
||||
|
||||
return ecma_make_object_value (obj_p);
|
||||
} /* ecma_builtin_date_dispatch_construct */
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,11 +34,11 @@ ROUTINE (LIT_MAGIC_STRING_PARSE, ecma_builtin_date_parse, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_UTC_U, ecma_builtin_date_utc, NON_FIXED, 7)
|
||||
ROUTINE (LIT_MAGIC_STRING_NOW, ecma_builtin_date_now, 0, 0)
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_DATE_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_DATE) */
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "lit-char-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-string-object.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "jrt.h"
|
||||
#include "lit-magic-strings.h"
|
||||
|
||||
|
||||
@@ -22,8 +22,9 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "jrt.h"
|
||||
#include "jcontext.h"
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
@@ -49,7 +50,7 @@
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
return ecma_builtin_helper_error_dispatch_call (ECMA_ERROR_COMMON, arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_error_dispatch_call */
|
||||
@@ -61,9 +62,31 @@ ecma_builtin_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arg
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_error_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
#if !ENABLED (JERRY_ESNEXT)
|
||||
return ecma_builtin_error_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
#else /* ENABLED (JERRY_ESNEXT) */
|
||||
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p),
|
||||
ECMA_BUILTIN_ID_ERROR_PROTOTYPE);
|
||||
|
||||
if (proto_p == NULL)
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_value_t result = ecma_builtin_error_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
|
||||
if (!ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (result);
|
||||
ECMA_SET_NON_NULL_POINTER (object_p->u2.prototype_cp, proto_p);
|
||||
}
|
||||
|
||||
ecma_deref_object (proto_p);
|
||||
|
||||
return result;
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} /* ecma_builtin_error_dispatch_construct */
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,10 +34,10 @@ OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-string-object.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_ERRORS)
|
||||
|
||||
@@ -22,8 +22,9 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "jrt.h"
|
||||
#include "jcontext.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_ERRORS)
|
||||
|
||||
@@ -51,7 +52,7 @@
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_eval_error_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
return ecma_builtin_helper_error_dispatch_call (ECMA_ERROR_EVAL, arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_eval_error_dispatch_call */
|
||||
@@ -63,9 +64,31 @@ ecma_builtin_eval_error_dispatch_call (const ecma_value_t *arguments_list_p, /**
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_eval_error_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
#if !ENABLED (JERRY_ESNEXT)
|
||||
return ecma_builtin_eval_error_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
#else /* ENABLED (JERRY_ESNEXT) */
|
||||
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p),
|
||||
ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE);
|
||||
|
||||
if (proto_p == NULL)
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_value_t result = ecma_builtin_eval_error_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
|
||||
if (!ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (result);
|
||||
ECMA_SET_NON_NULL_POINTER (object_p->u2.prototype_cp, proto_p);
|
||||
}
|
||||
|
||||
ecma_deref_object (proto_p);
|
||||
|
||||
return result;
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} /* ecma_builtin_eval_error_dispatch_construct */
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,11 +36,11 @@ OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_EVAL_ERROR_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_ERRORS) */
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-proxy-object.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "jrt.h"
|
||||
#include "ecma-builtin-function-prototype.h"
|
||||
|
||||
@@ -41,14 +40,14 @@
|
||||
*/
|
||||
enum
|
||||
{
|
||||
ECMA_FUNCTION_PROTOTYPE_ROUTINE_START = ECMA_BUILTIN_ID__COUNT - 1,
|
||||
ECMA_FUNCTION_PROTOTYPE_ROUTINE_START = 0,
|
||||
ECMA_FUNCTION_PROTOTYPE_TO_STRING,
|
||||
ECMA_FUNCTION_PROTOTYPE_CALL,
|
||||
ECMA_FUNCTION_PROTOTYPE_APPLY,
|
||||
ECMA_FUNCTION_PROTOTYPE_BIND,
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ECMA_FUNCTION_PROTOTYPE_SYMBOL_HAS_INSTANCE,
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-function-prototype.inc.h"
|
||||
@@ -114,7 +113,7 @@ ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, /**< th
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (arg2);
|
||||
|
||||
/* 4-5. */
|
||||
uint32_t length;
|
||||
ecma_length_t length;
|
||||
ecma_value_t len_value = ecma_op_object_get_length (obj_p, &length);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (len_value))
|
||||
@@ -130,12 +129,12 @@ ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, /**< th
|
||||
/* 6. */
|
||||
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
|
||||
JMEM_DEFINE_LOCAL_ARRAY (arguments_list_p, length, ecma_value_t);
|
||||
uint32_t index = 0;
|
||||
ecma_length_t index = 0;
|
||||
|
||||
/* 7. */
|
||||
for (index = 0; index < length; index++)
|
||||
{
|
||||
ecma_value_t get_value = ecma_op_object_get_by_uint32_index (obj_p, index);
|
||||
ecma_value_t get_value = ecma_op_object_get_by_index (obj_p, index);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (get_value))
|
||||
{
|
||||
@@ -152,7 +151,7 @@ ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, /**< th
|
||||
ret_value = ecma_op_function_call (func_obj_p,
|
||||
arg1,
|
||||
arguments_list_p,
|
||||
length);
|
||||
(uint32_t) length);
|
||||
}
|
||||
|
||||
for (uint32_t remove_index = 0; remove_index < index; remove_index++)
|
||||
@@ -177,7 +176,7 @@ ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, /**< th
|
||||
static ecma_value_t
|
||||
ecma_builtin_function_prototype_object_call (ecma_object_t *func_obj_p , /**< this argument object */
|
||||
const ecma_value_t *arguments_list_p, /**< list of arguments */
|
||||
ecma_length_t arguments_number) /**< number of arguments */
|
||||
uint32_t arguments_number) /**< number of arguments */
|
||||
{
|
||||
if (arguments_number == 0)
|
||||
{
|
||||
@@ -191,7 +190,7 @@ ecma_builtin_function_prototype_object_call (ecma_object_t *func_obj_p , /**< th
|
||||
return ecma_op_function_call (func_obj_p,
|
||||
arguments_list_p[0],
|
||||
arguments_list_p + 1,
|
||||
(ecma_length_t) (arguments_number - 1u));
|
||||
(uint32_t) (arguments_number - 1u));
|
||||
} /* ecma_builtin_function_prototype_object_call */
|
||||
|
||||
/**
|
||||
@@ -206,15 +205,15 @@ ecma_builtin_function_prototype_object_call (ecma_object_t *func_obj_p , /**< th
|
||||
static ecma_value_t
|
||||
ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**< this argument object */
|
||||
const ecma_value_t *arguments_list_p, /**< list of arguments */
|
||||
ecma_length_t arguments_number) /**< number of arguments */
|
||||
uint32_t arguments_number) /**< number of arguments */
|
||||
{
|
||||
/* 4. 11. 18. */
|
||||
ecma_object_t *prototype_obj_p;
|
||||
|
||||
#if !ENABLED (JERRY_ES2015)
|
||||
#if !ENABLED (JERRY_ESNEXT)
|
||||
prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE);
|
||||
#else /* ENABLED (JERRY_ES2015) */
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_PROXY)
|
||||
#else /* ENABLED (JERRY_ESNEXT) */
|
||||
#if ENABLED (JERRY_BUILTIN_PROXY)
|
||||
if (ECMA_OBJECT_IS_PROXY (this_arg_obj_p))
|
||||
{
|
||||
ecma_value_t proto = ecma_proxy_object_get_prototype_of (this_arg_obj_p);
|
||||
@@ -227,7 +226,7 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_PROXY) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
|
||||
jmem_cpointer_t proto_cp = ecma_op_ordinary_object_get_prototype_of (this_arg_obj_p);
|
||||
if (proto_cp != JMEM_CP_NULL)
|
||||
{
|
||||
@@ -238,10 +237,10 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
|
||||
{
|
||||
prototype_obj_p = NULL;
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_PROXY)
|
||||
#if ENABLED (JERRY_BUILTIN_PROXY)
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_PROXY) */
|
||||
#endif /* !ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
|
||||
#endif /* !ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
ecma_object_t *function_p;
|
||||
ecma_bound_function_t *bound_func_p;
|
||||
@@ -287,7 +286,7 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
|
||||
bound_func_p->header.u.bound_function.args_len_or_this = ECMA_VALUE_UNDEFINED;
|
||||
ecma_value_t *args_p = (ecma_value_t *) (bound_func_p + 1);
|
||||
|
||||
for (ecma_length_t i = 0; i < arguments_number; i++)
|
||||
for (uint32_t i = 0; i < arguments_number; i++)
|
||||
{
|
||||
*args_p++ = ecma_copy_value_if_not_object (arguments_list_p[i]);
|
||||
}
|
||||
@@ -296,26 +295,27 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
|
||||
bound_func_p->header.u.bound_function.args_len_or_this = args_len_or_this;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (prototype_obj_p != NULL)
|
||||
{
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
}
|
||||
|
||||
ecma_integer_value_t len = 0;
|
||||
bound_func_p->target_length = ecma_make_integer_value (0);
|
||||
|
||||
ecma_string_t *len_string = ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH);
|
||||
ecma_property_descriptor_t prop_desc;
|
||||
ecma_value_t status = ecma_op_object_get_own_property_descriptor (this_arg_obj_p,
|
||||
len_string,
|
||||
&prop_desc);
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_PROXY)
|
||||
#if ENABLED (JERRY_BUILTIN_PROXY)
|
||||
if (ECMA_IS_VALUE_ERROR (status))
|
||||
{
|
||||
ecma_deref_object (function_p);
|
||||
return status;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_PROXY) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
|
||||
|
||||
if (ecma_is_value_true (status))
|
||||
{
|
||||
@@ -333,13 +333,11 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
|
||||
{
|
||||
ecma_number_t len_num;
|
||||
ecma_op_to_integer (len_value, &len_num);
|
||||
len = (ecma_integer_value_t) len_num;
|
||||
bound_func_p->target_length = ecma_make_number_value (len_num);
|
||||
}
|
||||
ecma_free_value (len_value);
|
||||
}
|
||||
|
||||
bound_func_p->target_length = len;
|
||||
|
||||
/* 12. */
|
||||
ecma_value_t name_value = ecma_op_object_get_by_magic_id (this_arg_obj_p, LIT_MAGIC_STRING_NAME);
|
||||
if (ECMA_IS_VALUE_ERROR (name_value))
|
||||
@@ -371,7 +369,7 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
|
||||
NULL);
|
||||
|
||||
name_prop_value_p->value = bound_function_name;
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/*
|
||||
* [[Class]] property is not stored explicitly for objects of ECMA_OBJECT_TYPE_FUNCTION type.
|
||||
@@ -390,7 +388,7 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_function_prototype_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
@@ -404,7 +402,7 @@ ecma_builtin_function_prototype_dispatch_call (const ecma_value_t *arguments_lis
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_function_prototype_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
@@ -418,21 +416,20 @@ ecma_builtin_function_prototype_dispatch_construct (const ecma_value_t *argument
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_function_prototype_dispatch_routine (uint16_t builtin_routine_id, /**< built-in wide routine
|
||||
* identifier */
|
||||
ecma_builtin_function_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide routine identifier */
|
||||
ecma_value_t this_arg, /**< 'this' argument value */
|
||||
const ecma_value_t arguments_list_p[], /**< list of arguments
|
||||
* passed to routine */
|
||||
ecma_length_t arguments_number) /**< length of arguments' list */
|
||||
* passed to routine */
|
||||
uint32_t arguments_number) /**< length of arguments' list */
|
||||
{
|
||||
if (!ecma_op_is_callable (this_arg))
|
||||
{
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (JERRY_UNLIKELY (builtin_routine_id == ECMA_FUNCTION_PROTOTYPE_SYMBOL_HAS_INSTANCE))
|
||||
{
|
||||
return ECMA_VALUE_FALSE;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a function."));
|
||||
}
|
||||
@@ -459,12 +456,12 @@ ecma_builtin_function_prototype_dispatch_routine (uint16_t builtin_routine_id, /
|
||||
{
|
||||
return ecma_builtin_function_prototype_object_bind (func_obj_p, arguments_list_p, arguments_number);
|
||||
}
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case ECMA_FUNCTION_PROTOTYPE_SYMBOL_HAS_INSTANCE:
|
||||
{
|
||||
return ecma_op_object_has_instance (func_obj_p, arguments_list_p[0]);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
|
||||
@@ -34,11 +34,11 @@ NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
0,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING__EMPTY,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
@@ -47,7 +47,7 @@ ROUTINE (LIT_MAGIC_STRING_APPLY, ECMA_FUNCTION_PROTOTYPE_APPLY, 2, 2)
|
||||
ROUTINE (LIT_MAGIC_STRING_CALL, ECMA_FUNCTION_PROTOTYPE_CALL, NON_FIXED, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_BIND, ECMA_FUNCTION_PROTOTYPE_BIND, NON_FIXED, 1)
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/**
|
||||
* ECMA-262 v6.0 19.2.3.6 @@hasInstance
|
||||
* the property attributes are: { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
|
||||
@@ -61,6 +61,6 @@ ACCESSOR_BUILTIN_FUNCTION (LIT_MAGIC_STRING_CALLER,
|
||||
ECMA_BUILTIN_ID_TYPE_ERROR_THROWER,
|
||||
ECMA_BUILTIN_ID_TYPE_ERROR_THROWER,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -20,14 +20,9 @@
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-lex-env.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "js-parser.h"
|
||||
#include "lit-magic-strings.h"
|
||||
|
||||
#if ENABLED (JERRY_RESOURCE_NAME)
|
||||
#include "jcontext.h"
|
||||
#endif /* ENABLED (JERRY_RESOURCE_NAME) */
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
@@ -52,7 +47,7 @@
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_function_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
@@ -69,7 +64,7 @@ ecma_builtin_function_dispatch_call (const ecma_value_t *arguments_list_p, /**<
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_function_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
return ecma_op_create_dynamic_function (arguments_list_p, arguments_list_len, ECMA_PARSE_NO_OPTS);
|
||||
} /* ecma_builtin_function_dispatch_construct */
|
||||
|
||||
@@ -34,10 +34,10 @@ NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_FUNCTION_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
@@ -43,7 +43,7 @@
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_generator_function_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
@@ -58,7 +58,7 @@ ecma_builtin_generator_function_dispatch_call (const ecma_value_t *arguments_lis
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_generator_function_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
return ecma_builtin_generator_function_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_generator_function_dispatch_construct */
|
||||
@@ -69,4 +69,4 @@ ecma_builtin_generator_function_dispatch_construct (const ecma_value_t *argument
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/* ECMA-262 v6, 25.2.2 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
@@ -36,6 +36,6 @@ OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_GENERATOR,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -23,11 +23,27 @@
|
||||
#include "opcodes.h"
|
||||
#include "vm-defines.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
/**
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_CUSTOM_DISPATCH
|
||||
|
||||
/**
|
||||
* List of built-in routine identifiers.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
ECMA_GENERATOR_PROTOTYPE_ROUTINE_START = 0,
|
||||
ECMA_GENERATOR_PROTOTYPE_ROUTINE_NEXT,
|
||||
ECMA_GENERATOR_PROTOTYPE_ROUTINE_THROW,
|
||||
ECMA_GENERATOR_PROTOTYPE_ROUTINE_RETURN
|
||||
} ecma_generator_operation_type_t;
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-generator-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID generator_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
@@ -43,20 +59,22 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Byte code sequence which returns from the generator.
|
||||
* Convert routine type to operation type..
|
||||
*/
|
||||
static const uint8_t ecma_builtin_generator_prototype_return[2] =
|
||||
{
|
||||
CBC_EXT_OPCODE, CBC_EXT_RETURN
|
||||
};
|
||||
#define ECMA_GENERATOR_ROUTINE_TO_OPERATION(type) \
|
||||
((ecma_iterator_command_type_t) ((type) - ECMA_GENERATOR_PROTOTYPE_ROUTINE_NEXT))
|
||||
|
||||
/**
|
||||
* Byte code sequence which throws an exception.
|
||||
*/
|
||||
static const uint8_t ecma_builtin_generator_prototype_throw[1] =
|
||||
{
|
||||
CBC_THROW
|
||||
};
|
||||
JERRY_STATIC_ASSERT (ECMA_GENERATOR_ROUTINE_TO_OPERATION (ECMA_GENERATOR_PROTOTYPE_ROUTINE_NEXT)
|
||||
== ECMA_ITERATOR_NEXT,
|
||||
convert_ecma_generator_routine_next_to_ecma_iterator_next_failed);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_GENERATOR_ROUTINE_TO_OPERATION (ECMA_GENERATOR_PROTOTYPE_ROUTINE_THROW)
|
||||
== ECMA_ITERATOR_THROW,
|
||||
convert_ecma_generator_routine_throw_to_ecma_iterator_throw_failed);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_GENERATOR_ROUTINE_TO_OPERATION (ECMA_GENERATOR_PROTOTYPE_ROUTINE_RETURN)
|
||||
== ECMA_ITERATOR_RETURN,
|
||||
convert_ecma_generator_routine_return_to_ecma_iterator_return_failed);
|
||||
|
||||
/**
|
||||
* Helper function for next / return / throw
|
||||
@@ -65,10 +83,132 @@ static const uint8_t ecma_builtin_generator_prototype_throw[1] =
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_generator_prototype_object_do (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_builtin_generator_prototype_object_do (vm_executable_object_t *generator_object_p, /**< generator object */
|
||||
ecma_value_t arg, /**< argument */
|
||||
ecma_iterator_command_type_t resume_mode) /**< resume mode */
|
||||
{
|
||||
arg = ecma_copy_value (arg);
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (generator_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD)
|
||||
{
|
||||
ecma_value_t iterator = generator_object_p->frame_ctx.block_result;
|
||||
ecma_value_t next_method = generator_object_p->frame_ctx.stack_top_p[-1];
|
||||
|
||||
bool done = false;
|
||||
ecma_value_t result = ecma_op_iterator_do (resume_mode, iterator, next_method, arg, &done);
|
||||
ecma_free_value (arg);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
arg = result;
|
||||
}
|
||||
else if (done)
|
||||
{
|
||||
arg = ecma_op_iterator_value (result);
|
||||
ecma_free_value (result);
|
||||
|
||||
if (resume_mode == ECMA_ITERATOR_THROW)
|
||||
{
|
||||
resume_mode = ECMA_ITERATOR_NEXT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
ECMA_EXECUTABLE_OBJECT_RESUME_EXEC (generator_object_p);
|
||||
generator_object_p->frame_ctx.block_result = ECMA_VALUE_UNDEFINED;
|
||||
|
||||
JERRY_ASSERT (generator_object_p->frame_ctx.stack_top_p[-1] == ECMA_VALUE_UNDEFINED
|
||||
|| ecma_is_value_object (generator_object_p->frame_ctx.stack_top_p[-1]));
|
||||
generator_object_p->frame_ctx.stack_top_p--;
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (arg))
|
||||
{
|
||||
arg = jcontext_take_exception ();
|
||||
resume_mode = ECMA_ITERATOR_THROW;
|
||||
}
|
||||
}
|
||||
|
||||
if (resume_mode == ECMA_ITERATOR_RETURN)
|
||||
{
|
||||
generator_object_p->frame_ctx.byte_code_p = opfunc_resume_executable_object_with_return;
|
||||
}
|
||||
else if (resume_mode == ECMA_ITERATOR_THROW)
|
||||
{
|
||||
generator_object_p->frame_ctx.byte_code_p = opfunc_resume_executable_object_with_throw;
|
||||
}
|
||||
|
||||
ecma_value_t value = opfunc_resume_executable_object (generator_object_p, arg);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
bool done = (generator_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_COMPLETED);
|
||||
|
||||
if (!done)
|
||||
{
|
||||
const uint8_t *byte_code_p = generator_object_p->frame_ctx.byte_code_p;
|
||||
|
||||
JERRY_ASSERT (byte_code_p[-2] == CBC_EXT_OPCODE
|
||||
&& (byte_code_p[-1] == CBC_EXT_YIELD || byte_code_p[-1] == CBC_EXT_YIELD_ITERATOR));
|
||||
|
||||
if (byte_code_p[-1] == CBC_EXT_YIELD_ITERATOR)
|
||||
{
|
||||
ecma_value_t iterator = ecma_op_get_iterator (value,
|
||||
ECMA_VALUE_SYNC_ITERATOR,
|
||||
generator_object_p->frame_ctx.stack_top_p);
|
||||
ecma_free_value (value);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (iterator))
|
||||
{
|
||||
resume_mode = ECMA_ITERATOR_THROW;
|
||||
arg = jcontext_take_exception ();
|
||||
continue;
|
||||
}
|
||||
|
||||
ecma_deref_object (ecma_get_object_from_value (iterator));
|
||||
generator_object_p->extended_object.u.class_prop.extra_info |= ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD;
|
||||
generator_object_p->frame_ctx.block_result = iterator;
|
||||
|
||||
if (generator_object_p->frame_ctx.stack_top_p[0] != ECMA_VALUE_UNDEFINED)
|
||||
{
|
||||
ecma_deref_object (ecma_get_object_from_value (generator_object_p->frame_ctx.stack_top_p[0]));
|
||||
}
|
||||
|
||||
generator_object_p->frame_ctx.stack_top_p++;
|
||||
arg = ECMA_VALUE_UNDEFINED;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
ecma_value_t result = ecma_create_iter_result_object (value, ecma_make_boolean_value (done));
|
||||
ecma_fast_free_value (value);
|
||||
return result;
|
||||
}
|
||||
} /* ecma_builtin_generator_prototype_object_do */
|
||||
|
||||
/**
|
||||
* Dispatcher of the Generator built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_generator_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide routine
|
||||
* identifier */
|
||||
ecma_value_t this_arg, /**< 'this' argument value */
|
||||
const ecma_value_t arguments_list_p[], /**< list of arguments
|
||||
* passed to routine */
|
||||
uint32_t arguments_number) /**< length of arguments' list */
|
||||
{
|
||||
JERRY_UNUSED (arguments_number);
|
||||
|
||||
vm_executable_object_t *executable_object_p = NULL;
|
||||
|
||||
if (ecma_is_value_object (this_arg))
|
||||
@@ -98,148 +238,19 @@ ecma_builtin_generator_prototype_object_do (ecma_value_t this_arg, /**< this arg
|
||||
|
||||
if (executable_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_COMPLETED)
|
||||
{
|
||||
return ecma_create_iter_result_object (ECMA_VALUE_UNDEFINED, ECMA_VALUE_TRUE);
|
||||
if (builtin_routine_id != ECMA_GENERATOR_PROTOTYPE_ROUTINE_THROW)
|
||||
{
|
||||
return ecma_create_iter_result_object (ECMA_VALUE_UNDEFINED, ECMA_VALUE_TRUE);
|
||||
}
|
||||
|
||||
jcontext_raise_exception (ecma_copy_value (arguments_list_p[0]));
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
arg = ecma_copy_value (arg);
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (executable_object_p->extended_object.u.class_prop.extra_info & ECMA_GENERATOR_ITERATE_AND_YIELD)
|
||||
{
|
||||
ecma_value_t iterator = executable_object_p->extended_object.u.class_prop.u.value;
|
||||
|
||||
bool done = false;
|
||||
ecma_value_t result = ecma_op_iterator_do (resume_mode, iterator, arg, &done);
|
||||
ecma_free_value (arg);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
arg = result;
|
||||
}
|
||||
else if (done)
|
||||
{
|
||||
arg = ecma_op_iterator_value (result);
|
||||
ecma_free_value (result);
|
||||
if (resume_mode == ECMA_ITERATOR_THROW)
|
||||
{
|
||||
/* This part is changed in the newest ECMAScript standard.
|
||||
* It was ECMA_ITERATOR_RETURN in ES2015, but I think it was a typo. */
|
||||
resume_mode = ECMA_ITERATOR_NEXT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
executable_object_p->extended_object.u.class_prop.extra_info &= (uint16_t) ~ECMA_GENERATOR_ITERATE_AND_YIELD;
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (arg))
|
||||
{
|
||||
arg = jcontext_take_exception ();
|
||||
resume_mode = ECMA_ITERATOR_THROW;
|
||||
}
|
||||
}
|
||||
|
||||
if (resume_mode == ECMA_ITERATOR_RETURN)
|
||||
{
|
||||
executable_object_p->frame_ctx.byte_code_p = ecma_builtin_generator_prototype_return;
|
||||
}
|
||||
else if (resume_mode == ECMA_ITERATOR_THROW)
|
||||
{
|
||||
executable_object_p->frame_ctx.byte_code_p = ecma_builtin_generator_prototype_throw;
|
||||
}
|
||||
|
||||
ecma_value_t value = opfunc_resume_executable_object (executable_object_p, arg);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
bool done = (executable_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_COMPLETED);
|
||||
|
||||
if (!done)
|
||||
{
|
||||
const uint8_t *byte_code_p = executable_object_p->frame_ctx.byte_code_p;
|
||||
|
||||
JERRY_ASSERT (byte_code_p[-2] == CBC_EXT_OPCODE
|
||||
&& (byte_code_p[-1] == CBC_EXT_YIELD || byte_code_p[-1] == CBC_EXT_YIELD_ITERATOR));
|
||||
|
||||
if (byte_code_p[-1] == CBC_EXT_YIELD_ITERATOR)
|
||||
{
|
||||
ecma_value_t iterator = ecma_op_get_iterator (value, ECMA_VALUE_EMPTY);
|
||||
ecma_free_value (value);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (iterator))
|
||||
{
|
||||
resume_mode = ECMA_ITERATOR_THROW;
|
||||
arg = jcontext_take_exception ();
|
||||
continue;
|
||||
}
|
||||
|
||||
ecma_deref_object (ecma_get_object_from_value (iterator));
|
||||
executable_object_p->extended_object.u.class_prop.extra_info |= ECMA_GENERATOR_ITERATE_AND_YIELD;
|
||||
executable_object_p->extended_object.u.class_prop.u.value = iterator;
|
||||
arg = ECMA_VALUE_UNDEFINED;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
ecma_value_t result = ecma_create_iter_result_object (value, ecma_make_boolean_value (done));
|
||||
ecma_fast_free_value (value);
|
||||
return result;
|
||||
}
|
||||
} /* ecma_builtin_generator_prototype_object_do */
|
||||
|
||||
/**
|
||||
* The Generator.prototype object's 'next' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 25.3.1.2
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_generator_prototype_object_next (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t next_arg) /**< next argument */
|
||||
{
|
||||
return ecma_builtin_generator_prototype_object_do (this_arg, next_arg, ECMA_ITERATOR_NEXT);
|
||||
} /* ecma_builtin_generator_prototype_object_next */
|
||||
|
||||
/**
|
||||
* The Generator.prototype object's 'return' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 25.3.1.3
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_generator_prototype_object_return (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t return_arg) /**< return argument */
|
||||
{
|
||||
return ecma_builtin_generator_prototype_object_do (this_arg, return_arg, ECMA_ITERATOR_RETURN);
|
||||
} /* ecma_builtin_generator_prototype_object_return */
|
||||
|
||||
/**
|
||||
* The Generator.prototype object's 'throw' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 25.3.1.4
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_generator_prototype_object_throw (ecma_value_t this_arg, /**< this argument */
|
||||
ecma_value_t throw_arg) /**< throw argument */
|
||||
{
|
||||
return ecma_builtin_generator_prototype_object_do (this_arg, throw_arg, ECMA_ITERATOR_THROW);
|
||||
} /* ecma_builtin_generator_prototype_object_throw */
|
||||
return ecma_builtin_generator_prototype_object_do (executable_object_p,
|
||||
arguments_list_p[0],
|
||||
ECMA_GENERATOR_ROUTINE_TO_OPERATION (builtin_routine_id));
|
||||
} /* ecma_builtin_generator_prototype_dispatch_routine */
|
||||
|
||||
/**
|
||||
* @}
|
||||
@@ -247,4 +258,4 @@ ecma_builtin_generator_prototype_object_throw (ecma_value_t this_arg, /**< this
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
@@ -36,10 +36,10 @@ OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
ROUTINE (LIT_MAGIC_STRING_NEXT, ecma_builtin_generator_prototype_object_next, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_RETURN, ecma_builtin_generator_prototype_object_return, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_THROW, ecma_builtin_generator_prototype_object_throw, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_NEXT, ECMA_GENERATOR_PROTOTYPE_ROUTINE_NEXT, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_RETURN, ECMA_GENERATOR_PROTOTYPE_ROUTINE_RETURN, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_THROW, ECMA_GENERATOR_PROTOTYPE_ROUTINE_THROW, 1, 1)
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
@@ -40,4 +40,4 @@
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/* ECMA-262 v6, 25.3.2.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
@@ -36,6 +36,6 @@ STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_GENERATOR_FUNCTION_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "jrt.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "lit-magic-strings.h"
|
||||
@@ -44,7 +43,7 @@
|
||||
*/
|
||||
enum
|
||||
{
|
||||
ECMA_GLOBAL_ROUTINE_START = ECMA_BUILTIN_ID__COUNT - 1,
|
||||
ECMA_GLOBAL_ROUTINE_START = 0,
|
||||
/* Note: these 5 routine ids must be in this order */
|
||||
ECMA_GLOBAL_IS_NAN,
|
||||
ECMA_GLOBAL_IS_FINITE,
|
||||
@@ -100,12 +99,12 @@ ecma_builtin_global_object_eval (ecma_value_t x) /**< routine's first argument *
|
||||
parse_opts |= ECMA_PARSE_STRICT_MODE;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (vm_is_direct_eval_form_call ())
|
||||
{
|
||||
parse_opts |= ECMA_GET_LOCAL_PARSE_OPTS ();
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/* steps 2 to 8 */
|
||||
return ecma_op_eval (ecma_get_string_from_value (x), parse_opts);
|
||||
@@ -203,29 +202,20 @@ ecma_builtin_global_object_decode_uri_helper (lit_utf8_byte_t *input_start_p, /*
|
||||
{
|
||||
lit_utf8_byte_t *input_char_p = input_start_p;
|
||||
lit_utf8_byte_t *input_end_p = input_start_p + input_size;
|
||||
lit_utf8_size_t output_size = 0;
|
||||
/*
|
||||
* The URI decoding has two major phases: first we validate the input,
|
||||
* and compute the length of the output, then we decode the input.
|
||||
*/
|
||||
ecma_stringbuilder_t builder = ecma_stringbuilder_create ();
|
||||
|
||||
while (input_char_p < input_end_p)
|
||||
{
|
||||
/*
|
||||
* We expect that the input is a valid UTF-8 sequence,
|
||||
* so characters >= 0x80 can be let through.
|
||||
*/
|
||||
|
||||
if (*input_char_p != '%')
|
||||
{
|
||||
output_size++;
|
||||
input_char_p++;
|
||||
ecma_stringbuilder_append_byte (&builder, *input_char_p++);
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t hex_value = lit_char_hex_lookup (input_char_p + 1, input_end_p, 2);
|
||||
if (hex_value == UINT32_MAX)
|
||||
{
|
||||
ecma_stringbuilder_destroy (&builder);
|
||||
return ecma_raise_uri_error (ECMA_ERR_MSG ("Invalid hexadecimal value."));
|
||||
}
|
||||
|
||||
@@ -234,70 +224,15 @@ ecma_builtin_global_object_decode_uri_helper (lit_utf8_byte_t *input_start_p, /*
|
||||
|
||||
if (decoded_byte <= LIT_UTF8_1_BYTE_CODE_POINT_MAX)
|
||||
{
|
||||
/*
|
||||
* We don't decode those bytes, which are part of reserved_uri_bitset
|
||||
* but not part of unescaped_uri_component_set.
|
||||
*/
|
||||
if (ecma_builtin_global_object_character_is_in (decoded_byte, reserved_uri_bitset)
|
||||
&& !ecma_builtin_global_object_character_is_in (decoded_byte, unescaped_uri_component_set))
|
||||
{
|
||||
output_size += URI_ENCODED_BYTE_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
output_size++;
|
||||
}
|
||||
}
|
||||
else if ((decoded_byte & LIT_UTF8_4_BYTE_MASK) == LIT_UTF8_4_BYTE_MARKER)
|
||||
{
|
||||
output_size += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
output_size++;
|
||||
}
|
||||
}
|
||||
|
||||
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
|
||||
|
||||
JMEM_DEFINE_LOCAL_ARRAY (output_start_p,
|
||||
output_size,
|
||||
lit_utf8_byte_t);
|
||||
|
||||
input_char_p = input_start_p;
|
||||
lit_utf8_byte_t *output_char_p = output_start_p;
|
||||
|
||||
while (input_char_p < input_end_p)
|
||||
{
|
||||
/* Input decode. */
|
||||
if (*input_char_p != '%')
|
||||
{
|
||||
*output_char_p++ = *input_char_p++;
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32_t hex_value = lit_char_hex_lookup (input_char_p + 1, input_end_p, 2);
|
||||
if (hex_value == UINT32_MAX)
|
||||
{
|
||||
ret_value = ecma_raise_uri_error (ECMA_ERR_MSG ("Invalid hexadecimal value."));
|
||||
break;
|
||||
}
|
||||
|
||||
ecma_char_t decoded_byte = (ecma_char_t) hex_value;
|
||||
input_char_p += URI_ENCODED_BYTE_SIZE;
|
||||
|
||||
if (decoded_byte <= LIT_UTF8_1_BYTE_CODE_POINT_MAX)
|
||||
{
|
||||
if (ecma_builtin_global_object_character_is_in (decoded_byte, reserved_uri_bitset)
|
||||
&& !ecma_builtin_global_object_character_is_in (decoded_byte, unescaped_uri_component_set))
|
||||
{
|
||||
*output_char_p = '%';
|
||||
output_char_p++;
|
||||
ecma_stringbuilder_append_char (&builder, LIT_CHAR_PERCENT);
|
||||
input_char_p -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
*output_char_p++ = (lit_utf8_byte_t) decoded_byte;
|
||||
ecma_stringbuilder_append_byte (&builder, (lit_utf8_byte_t) decoded_byte);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -318,8 +253,8 @@ ecma_builtin_global_object_decode_uri_helper (lit_utf8_byte_t *input_start_p, /*
|
||||
}
|
||||
else
|
||||
{
|
||||
ret_value = ecma_raise_uri_error (ECMA_ERR_MSG ("Invalid UTF8 character."));
|
||||
break;
|
||||
ecma_stringbuilder_destroy (&builder);
|
||||
return ecma_raise_uri_error (ECMA_ERR_MSG ("Invalid UTF8 character."));
|
||||
}
|
||||
|
||||
lit_utf8_byte_t octets[LIT_UTF8_MAX_BYTES_IN_CODE_POINT];
|
||||
@@ -351,8 +286,8 @@ ecma_builtin_global_object_decode_uri_helper (lit_utf8_byte_t *input_start_p, /*
|
||||
if (!is_valid
|
||||
|| !lit_is_valid_utf8_string (octets, bytes_count))
|
||||
{
|
||||
ret_value = ecma_raise_uri_error (ECMA_ERR_MSG ("Invalid UTF8 string."));
|
||||
break;
|
||||
ecma_stringbuilder_destroy (&builder);
|
||||
return ecma_raise_uri_error (ECMA_ERR_MSG ("Invalid UTF8 string."));
|
||||
}
|
||||
|
||||
lit_code_point_t cp;
|
||||
@@ -361,32 +296,17 @@ ecma_builtin_global_object_decode_uri_helper (lit_utf8_byte_t *input_start_p, /*
|
||||
if (lit_is_code_point_utf16_high_surrogate (cp)
|
||||
|| lit_is_code_point_utf16_low_surrogate (cp))
|
||||
{
|
||||
ret_value = ecma_raise_uri_error (ECMA_ERR_MSG ("Invalid UTF8 codepoint."));
|
||||
break;
|
||||
ecma_stringbuilder_destroy (&builder);
|
||||
return ecma_raise_uri_error (ECMA_ERR_MSG ("Invalid UTF8 codepoint."));
|
||||
}
|
||||
|
||||
output_char_p += lit_code_point_to_cesu8 (cp, output_char_p);
|
||||
lit_utf8_byte_t result_chars[LIT_CESU8_MAX_BYTES_IN_CODE_POINT];
|
||||
lit_utf8_size_t cp_size = lit_code_point_to_cesu8 (cp, result_chars);
|
||||
ecma_stringbuilder_append_raw (&builder, result_chars, cp_size);
|
||||
}
|
||||
}
|
||||
|
||||
if (ecma_is_value_empty (ret_value))
|
||||
{
|
||||
JERRY_ASSERT (output_start_p + output_size == output_char_p);
|
||||
|
||||
if (lit_is_valid_cesu8_string (output_start_p, output_size))
|
||||
{
|
||||
ecma_string_t *output_string_p = ecma_new_ecma_string_from_utf8 (output_start_p, output_size);
|
||||
ret_value = ecma_make_string_value (output_string_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret_value = ecma_raise_uri_error (ECMA_ERR_MSG ("Invalid CESU8 string."));
|
||||
}
|
||||
}
|
||||
|
||||
JMEM_FINALIZE_LOCAL_ARRAY (output_start_p);
|
||||
|
||||
return ret_value;
|
||||
return ecma_make_string_value (ecma_stringbuilder_finalize (&builder));
|
||||
} /* ecma_builtin_global_object_decode_uri_helper */
|
||||
|
||||
/**
|
||||
@@ -422,35 +342,30 @@ ecma_builtin_global_object_encode_uri_helper (lit_utf8_byte_t *input_start_p, /*
|
||||
* string buffer's size */
|
||||
const uint8_t *unescaped_uri_bitset_p) /**< unescaped bitset */
|
||||
{
|
||||
/*
|
||||
* The URI encoding has two major phases: first we validate the input,
|
||||
* and compute the length of the output, then we encode the input.
|
||||
*/
|
||||
|
||||
lit_utf8_byte_t *input_char_p = input_start_p;
|
||||
const lit_utf8_byte_t *input_end_p = input_start_p + input_size;
|
||||
lit_utf8_size_t output_length = 0;
|
||||
lit_code_point_t cp;
|
||||
ecma_char_t ch;
|
||||
ecma_stringbuilder_t builder = ecma_stringbuilder_create ();
|
||||
lit_utf8_byte_t octets[LIT_UTF8_MAX_BYTES_IN_CODE_POINT];
|
||||
memset (octets, LIT_BYTE_NULL, LIT_UTF8_MAX_BYTES_IN_CODE_POINT);
|
||||
|
||||
while (input_char_p < input_end_p)
|
||||
{
|
||||
/* Input validation, we need to reject stray surrogates. */
|
||||
input_char_p += lit_read_code_unit_from_utf8 (input_char_p, &ch);
|
||||
|
||||
if (lit_is_code_point_utf16_low_surrogate (ch))
|
||||
{
|
||||
ecma_stringbuilder_destroy (&builder);
|
||||
return ecma_raise_uri_error (ECMA_ERR_MSG ("Unicode surrogate pair missing."));
|
||||
}
|
||||
|
||||
cp = ch;
|
||||
lit_code_point_t cp = ch;
|
||||
|
||||
if (lit_is_code_point_utf16_high_surrogate (ch))
|
||||
{
|
||||
if (input_char_p == input_end_p)
|
||||
{
|
||||
ecma_stringbuilder_destroy (&builder);
|
||||
return ecma_raise_uri_error (ECMA_ERR_MSG ("Unicode surrogate pair missing."));
|
||||
}
|
||||
|
||||
@@ -464,89 +379,38 @@ ecma_builtin_global_object_encode_uri_helper (lit_utf8_byte_t *input_start_p, /*
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_stringbuilder_destroy (&builder);
|
||||
return ecma_raise_uri_error (ECMA_ERR_MSG ("Unicode surrogate pair missing."));
|
||||
}
|
||||
}
|
||||
|
||||
lit_utf8_size_t utf_size = lit_code_point_to_utf8 (cp, octets);
|
||||
lit_utf8_byte_t result_chars[URI_ENCODED_BYTE_SIZE];
|
||||
|
||||
if (utf_size == 1)
|
||||
{
|
||||
if (ecma_builtin_global_object_character_is_in (octets[0], unescaped_uri_bitset_p))
|
||||
{
|
||||
output_length++;
|
||||
ecma_stringbuilder_append_byte (&builder, octets[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
output_length += URI_ENCODED_BYTE_SIZE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
output_length += utf_size * URI_ENCODED_BYTE_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
ecma_value_t ret_value;
|
||||
|
||||
JMEM_DEFINE_LOCAL_ARRAY (output_start_p,
|
||||
output_length,
|
||||
lit_utf8_byte_t);
|
||||
|
||||
lit_utf8_byte_t *output_char_p = output_start_p;
|
||||
input_char_p = input_start_p;
|
||||
|
||||
while (input_char_p < input_end_p)
|
||||
{
|
||||
/* Input decode. */
|
||||
input_char_p += lit_read_code_unit_from_utf8 (input_char_p, &ch);
|
||||
cp = ch;
|
||||
|
||||
if (lit_is_code_point_utf16_high_surrogate (ch))
|
||||
{
|
||||
ecma_char_t next_ch;
|
||||
lit_utf8_size_t read_size = lit_read_code_unit_from_utf8 (input_char_p, &next_ch);
|
||||
|
||||
if (lit_is_code_point_utf16_low_surrogate (next_ch))
|
||||
{
|
||||
cp = lit_convert_surrogate_pair_to_code_point (ch, next_ch);
|
||||
input_char_p += read_size;
|
||||
}
|
||||
}
|
||||
|
||||
lit_utf8_size_t utf_size = lit_code_point_to_utf8 (cp, octets);
|
||||
|
||||
if (utf_size == 1)
|
||||
{
|
||||
if (ecma_builtin_global_object_character_is_in (octets[0], unescaped_uri_bitset_p))
|
||||
{
|
||||
*output_char_p++ = octets[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_builtin_global_object_byte_to_hex (output_char_p, octets[0]);
|
||||
output_char_p += URI_ENCODED_BYTE_SIZE;
|
||||
ecma_builtin_global_object_byte_to_hex (result_chars, octets[0]);
|
||||
ecma_stringbuilder_append_raw (&builder, result_chars, URI_ENCODED_BYTE_SIZE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (uint32_t i = 0; i < utf_size; i++)
|
||||
{
|
||||
ecma_builtin_global_object_byte_to_hex (output_char_p, octets[i]);
|
||||
output_char_p += URI_ENCODED_BYTE_SIZE;
|
||||
JERRY_ASSERT (utf_size <= LIT_UTF8_MAX_BYTES_IN_CODE_POINT);
|
||||
ecma_builtin_global_object_byte_to_hex (result_chars, octets[i]);
|
||||
ecma_stringbuilder_append_raw (&builder, result_chars, URI_ENCODED_BYTE_SIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JERRY_ASSERT (output_start_p + output_length == output_char_p);
|
||||
|
||||
ecma_string_t *output_string_p = ecma_new_ecma_string_from_utf8 (output_start_p, output_length);
|
||||
|
||||
ret_value = ecma_make_string_value (output_string_p);
|
||||
|
||||
JMEM_FINALIZE_LOCAL_ARRAY (output_start_p);
|
||||
|
||||
return ret_value;
|
||||
return ecma_make_string_value (ecma_stringbuilder_finalize (&builder));
|
||||
} /* ecma_builtin_global_object_encode_uri_helper */
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_ANNEXB)
|
||||
@@ -588,13 +452,10 @@ ecma_builtin_global_object_escape (lit_utf8_byte_t *input_start_p, /**< routine'
|
||||
lit_utf8_size_t input_size) /**< routine's first argument's
|
||||
* string buffer's size */
|
||||
{
|
||||
/*
|
||||
* The escape routine has two major phases: first we compute
|
||||
* the length of the output, then we encode the input.
|
||||
*/
|
||||
const lit_utf8_byte_t *input_curr_p = input_start_p;
|
||||
const lit_utf8_byte_t *input_end_p = input_start_p + input_size;
|
||||
lit_utf8_size_t output_length = 0;
|
||||
ecma_stringbuilder_t builder = ecma_stringbuilder_create ();
|
||||
lit_utf8_byte_t result_chars[URI_ENCODED_BYTE_SIZE];
|
||||
|
||||
while (input_curr_p < input_end_p)
|
||||
{
|
||||
@@ -604,86 +465,78 @@ ecma_builtin_global_object_escape (lit_utf8_byte_t *input_start_p, /**< routine'
|
||||
{
|
||||
if (ecma_builtin_global_object_character_is_in ((uint32_t) chr, ecma_escape_set))
|
||||
{
|
||||
output_length++;
|
||||
ecma_stringbuilder_append_char (&builder, chr);
|
||||
}
|
||||
else
|
||||
{
|
||||
output_length += URI_ENCODED_BYTE_SIZE;
|
||||
ecma_builtin_global_object_byte_to_hex (result_chars, chr);
|
||||
ecma_stringbuilder_append_raw (&builder, result_chars, URI_ENCODED_BYTE_SIZE);
|
||||
}
|
||||
}
|
||||
else if (chr > ECMA_ESCAPE_MAXIMUM_BYTE_VALUE)
|
||||
{
|
||||
output_length += ECMA_ESCAPE_ENCODED_UNICODE_CHARACTER_SIZE;
|
||||
ecma_stringbuilder_append_char (&builder, LIT_CHAR_PERCENT);
|
||||
ecma_stringbuilder_append_char (&builder, LIT_CHAR_LOWERCASE_U);
|
||||
|
||||
ecma_builtin_global_object_byte_to_hex (result_chars, (chr >> JERRY_BITSINBYTE));
|
||||
ecma_stringbuilder_append_raw (&builder, result_chars + 1, 2);
|
||||
|
||||
ecma_builtin_global_object_byte_to_hex (result_chars, (chr & 0xff));
|
||||
ecma_stringbuilder_append_raw (&builder, result_chars + 1, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
output_length += URI_ENCODED_BYTE_SIZE;
|
||||
ecma_builtin_global_object_byte_to_hex (result_chars, chr);
|
||||
ecma_stringbuilder_append_raw (&builder, result_chars, URI_ENCODED_BYTE_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
ecma_value_t ret_value;
|
||||
|
||||
JMEM_DEFINE_LOCAL_ARRAY (output_start_p,
|
||||
output_length,
|
||||
lit_utf8_byte_t);
|
||||
|
||||
lit_utf8_byte_t *output_char_p = output_start_p;
|
||||
|
||||
input_curr_p = input_start_p;
|
||||
|
||||
while (input_curr_p < input_end_p)
|
||||
{
|
||||
ecma_char_t chr = lit_cesu8_read_next (&input_curr_p);
|
||||
|
||||
if (chr <= LIT_UTF8_1_BYTE_CODE_POINT_MAX)
|
||||
{
|
||||
if (ecma_builtin_global_object_character_is_in ((uint32_t) chr, ecma_escape_set))
|
||||
{
|
||||
*output_char_p = (lit_utf8_byte_t) chr;
|
||||
output_char_p++;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_builtin_global_object_byte_to_hex (output_char_p, (lit_utf8_byte_t) chr);
|
||||
output_char_p += URI_ENCODED_BYTE_SIZE;
|
||||
}
|
||||
}
|
||||
else if (chr > ECMA_ESCAPE_MAXIMUM_BYTE_VALUE)
|
||||
{
|
||||
/*
|
||||
* Although ecma_builtin_global_object_byte_to_hex inserts a percent (%) sign
|
||||
* the follow-up changes overwrites it. We call this function twice to
|
||||
* produce four hexadecimal characters (%uxxxx format).
|
||||
*/
|
||||
ecma_builtin_global_object_byte_to_hex (output_char_p + 3, (lit_utf8_byte_t) (chr & 0xff));
|
||||
ecma_builtin_global_object_byte_to_hex (output_char_p + 1, (lit_utf8_byte_t) (chr >> JERRY_BITSINBYTE));
|
||||
output_char_p[0] = LIT_CHAR_PERCENT;
|
||||
output_char_p[1] = LIT_CHAR_LOWERCASE_U;
|
||||
output_char_p += ECMA_ESCAPE_ENCODED_UNICODE_CHARACTER_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_builtin_global_object_byte_to_hex (output_char_p, (lit_utf8_byte_t) chr);
|
||||
output_char_p += URI_ENCODED_BYTE_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
JERRY_ASSERT (output_start_p + output_length == output_char_p);
|
||||
|
||||
ecma_string_t *output_string_p = ecma_new_ecma_string_from_utf8 (output_start_p, output_length);
|
||||
|
||||
ret_value = ecma_make_string_value (output_string_p);
|
||||
|
||||
JMEM_FINALIZE_LOCAL_ARRAY (output_start_p);
|
||||
|
||||
return ret_value;
|
||||
return ecma_make_string_value (ecma_stringbuilder_finalize (&builder));
|
||||
} /* ecma_builtin_global_object_escape */
|
||||
|
||||
/**
|
||||
* Utility method to resolve character sequences for the 'unescape' method.
|
||||
*
|
||||
* Expected formats: %uxxxx or %yy
|
||||
*
|
||||
* @return number of characters processed during the escape resolve
|
||||
*/
|
||||
static uint8_t
|
||||
ecma_builtin_global_object_unescape_resolve_escape (const lit_utf8_byte_t *buffer_p, /**< character buffer */
|
||||
bool unicode_sequence, /**< true if unescaping unicode sequence */
|
||||
ecma_char_t *out_result_p) /**< [out] resolved character */
|
||||
{
|
||||
JERRY_ASSERT (buffer_p != NULL);
|
||||
JERRY_ASSERT (out_result_p != NULL);
|
||||
|
||||
ecma_char_t unescaped_chr = 0;
|
||||
uint8_t sequence_length = unicode_sequence ? 5 : 2;
|
||||
uint8_t start = unicode_sequence ? 1 : 0;
|
||||
|
||||
for (uint8_t i = start; i < sequence_length; i++)
|
||||
{
|
||||
const lit_utf8_byte_t current_char = buffer_p[i];
|
||||
|
||||
if (!lit_char_is_hex_digit (current_char))
|
||||
{
|
||||
/* This was not an escape sequence, skip processing */
|
||||
return 0;
|
||||
}
|
||||
|
||||
unescaped_chr = (ecma_char_t) ((unescaped_chr << 4) + (ecma_char_t) lit_char_hex_to_int (current_char));
|
||||
}
|
||||
|
||||
*out_result_p = unescaped_chr;
|
||||
|
||||
return sequence_length;
|
||||
} /* ecma_builtin_global_object_unescape_resolve_escape */
|
||||
|
||||
/**
|
||||
* The Global object's 'unescape' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v5, B.2.2
|
||||
* ECMA-262 v11, B.2.1.2
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
@@ -694,76 +547,40 @@ ecma_builtin_global_object_unescape (lit_utf8_byte_t *input_start_p, /**< routin
|
||||
lit_utf8_size_t input_size) /**< routine's first argument's
|
||||
* string buffer's size */
|
||||
{
|
||||
const lit_utf8_byte_t *input_curr_p = input_start_p;
|
||||
const lit_utf8_byte_t *input_end_p = input_start_p + input_size;
|
||||
/* 4. */
|
||||
/* The length of input string is always greater than output string
|
||||
* so we re-use the input string buffer.
|
||||
* The %xx is three byte long, and the maximum encoded value is 0xff,
|
||||
* which maximum encoded length is two byte. Similar to this, the maximum
|
||||
* encoded length of %uxxxx is four byte. */
|
||||
lit_utf8_byte_t *output_char_p = input_start_p;
|
||||
|
||||
/* The state of parsing that tells us where we are in an escape pattern.
|
||||
* 0 we are outside of pattern,
|
||||
* 1 found '%', start of pattern,
|
||||
* 2 found first hex digit of '%xy' pattern
|
||||
* 3 found valid '%xy' pattern
|
||||
* 4 found 'u', start of '%uwxyz' pattern
|
||||
* 5-7 found hex digits of '%uwxyz' pattern
|
||||
* 8 found valid '%uwxyz' pattern
|
||||
*/
|
||||
uint8_t status = 0;
|
||||
ecma_char_t hex_digits = 0;
|
||||
/* 5. */
|
||||
while (input_curr_p < input_end_p)
|
||||
if (input_size == 0)
|
||||
{
|
||||
/* 6. */
|
||||
ecma_char_t chr = lit_cesu8_read_next (&input_curr_p);
|
||||
|
||||
/* 7-8. */
|
||||
if (status == 0 && chr == LIT_CHAR_PERCENT)
|
||||
{
|
||||
/* Found '%' char, start of escape sequence. */
|
||||
status = 1;
|
||||
}
|
||||
/* 9-10. */
|
||||
else if (status == 1 && chr == LIT_CHAR_LOWERCASE_U)
|
||||
{
|
||||
/* Found 'u' char after '%'. */
|
||||
status = 4;
|
||||
}
|
||||
else if (status > 0 && lit_char_is_hex_digit (chr))
|
||||
{
|
||||
/* Found hexadecimal digit in escape sequence. */
|
||||
hex_digits = (ecma_char_t) (hex_digits * 16 + (ecma_char_t) lit_char_hex_to_int (chr));
|
||||
status++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Previously found hexadecimal digit in escape sequence but it's not valid '%xy' pattern
|
||||
* so essentially it was only a simple character. */
|
||||
status = 0;
|
||||
}
|
||||
|
||||
/* 11-17. Found valid '%uwxyz' or '%xy' escape. */
|
||||
if (status == 8 || status == 3)
|
||||
{
|
||||
output_char_p -= (status == 3) ? 2 : 5;
|
||||
status = 0;
|
||||
chr = hex_digits;
|
||||
hex_digits = 0;
|
||||
}
|
||||
|
||||
/* Copying character. */
|
||||
lit_utf8_size_t lit_size = lit_code_unit_to_utf8 (chr, output_char_p);
|
||||
output_char_p += lit_size;
|
||||
JERRY_ASSERT (output_char_p <= input_curr_p);
|
||||
return ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
|
||||
}
|
||||
|
||||
lit_utf8_size_t output_length = (lit_utf8_size_t) (output_char_p - input_start_p);
|
||||
ecma_string_t *output_string_p = ecma_new_ecma_string_from_utf8 (input_start_p, output_length);
|
||||
return ecma_make_string_value (output_string_p);
|
||||
const lit_utf8_byte_t *input_curr_p = input_start_p;
|
||||
const lit_utf8_byte_t *input_end_p = input_start_p + input_size;
|
||||
ecma_stringbuilder_t builder = ecma_stringbuilder_create ();
|
||||
|
||||
while (input_curr_p < input_end_p)
|
||||
{
|
||||
ecma_char_t chr = lit_cesu8_read_next (&input_curr_p);
|
||||
|
||||
// potential pattern
|
||||
if (chr == LIT_CHAR_PERCENT)
|
||||
{
|
||||
const lit_utf8_size_t chars_leftover = (lit_utf8_size_t) (input_end_p - input_curr_p);
|
||||
|
||||
// potential unicode sequence
|
||||
if (chars_leftover >= 5 && input_curr_p[0] == LIT_CHAR_LOWERCASE_U)
|
||||
{
|
||||
input_curr_p += ecma_builtin_global_object_unescape_resolve_escape (input_curr_p, true, &chr);
|
||||
}
|
||||
// potential two hexa sequence
|
||||
else if (chars_leftover >= 2)
|
||||
{
|
||||
input_curr_p += ecma_builtin_global_object_unescape_resolve_escape (input_curr_p, false, &chr);
|
||||
}
|
||||
}
|
||||
|
||||
ecma_stringbuilder_append_char (&builder, chr);
|
||||
}
|
||||
|
||||
return ecma_make_string_value (ecma_stringbuilder_finalize (&builder));
|
||||
} /* ecma_builtin_global_object_unescape */
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_ANNEXB) */
|
||||
@@ -775,11 +592,11 @@ ecma_builtin_global_object_unescape (lit_utf8_byte_t *input_start_p, /**< routin
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_global_dispatch_routine (uint16_t builtin_routine_id, /**< built-in wide routine identifier */
|
||||
ecma_builtin_global_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide routine identifier */
|
||||
ecma_value_t this_arg, /**< 'this' argument value */
|
||||
const ecma_value_t arguments_list_p[], /**< list of arguments
|
||||
* passed to routine */
|
||||
ecma_length_t arguments_number) /**< length of arguments' list */
|
||||
uint32_t arguments_number) /**< length of arguments' list */
|
||||
{
|
||||
JERRY_UNUSED (this_arg);
|
||||
JERRY_UNUSED (arguments_list_p);
|
||||
@@ -796,7 +613,7 @@ ecma_builtin_global_dispatch_routine (uint16_t builtin_routine_id, /**< built-in
|
||||
{
|
||||
ecma_number_t arg_num;
|
||||
|
||||
routine_arg_1 = ecma_get_number (routine_arg_1, &arg_num);
|
||||
routine_arg_1 = ecma_op_to_number (routine_arg_1, &arg_num);
|
||||
|
||||
if (!ecma_is_value_empty (routine_arg_1))
|
||||
{
|
||||
|
||||
@@ -139,12 +139,12 @@ OBJECT_VALUE (LIT_MAGIC_STRING_MATH_UL,
|
||||
ECMA_BUILTIN_ID_MATH,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* ENABLED (JERRY_BUILTIN_MATH) */
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_REFLECT)
|
||||
#if ENABLED (JERRY_BUILTIN_REFLECT)
|
||||
/* ECMA-262 v6, 26.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_REFLECT_UL,
|
||||
ECMA_BUILTIN_ID_REFLECT,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_REFLECT) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_REFLECT) */
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_JSON)
|
||||
/* ECMA-262 v5, 15.1.5.2 */
|
||||
@@ -153,7 +153,7 @@ OBJECT_VALUE (LIT_MAGIC_STRING_JSON_U,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* ENABLED (JERRY_BUILTIN_JSON) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY)
|
||||
#if ENABLED (JERRY_BUILTIN_TYPEDARRAY)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_ARRAY_BUFFER_UL,
|
||||
ECMA_BUILTIN_ID_ARRAYBUFFER,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
@@ -192,66 +192,88 @@ OBJECT_VALUE (LIT_MAGIC_STRING_FLOAT64_ARRAY_UL,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_BIGINT64_ARRAY_UL,
|
||||
ECMA_BUILTIN_ID_BIGINT64ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_BIGUINT64_ARRAY_UL,
|
||||
ECMA_BUILTIN_ID_BIGUINT64ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_UINT8_CLAMPED_ARRAY_UL,
|
||||
ECMA_BUILTIN_ID_UINT8CLAMPEDARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_TYPEDARRAY) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_PROMISE)
|
||||
#if ENABLED (JERRY_BUILTIN_PROMISE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROMISE_UL,
|
||||
ECMA_BUILTIN_ID_PROMISE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_PROMISE) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_PROMISE) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_MAP)
|
||||
#if ENABLED (JERRY_BUILTIN_MAP)
|
||||
/* ECMA-262 v6, 23.1.1.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_MAP_UL,
|
||||
ECMA_BUILTIN_ID_MAP,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_MAP) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_MAP) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_SET)
|
||||
#if ENABLED (JERRY_BUILTIN_SET)
|
||||
/* ECMA-262 v6, 23.1.1.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_SET_UL,
|
||||
ECMA_BUILTIN_ID_SET,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SET) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_SET) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_WEAKMAP)
|
||||
#if ENABLED (JERRY_BUILTIN_WEAKMAP)
|
||||
/* ECMA-262 v6, 23.1.1.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_WEAKMAP_UL,
|
||||
ECMA_BUILTIN_ID_WEAKMAP,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SET) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_SET) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_WEAKSET)
|
||||
#if ENABLED (JERRY_BUILTIN_WEAKSET)
|
||||
/* ECMA-262 v6, 23.1.1.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_WEAKSET_UL,
|
||||
ECMA_BUILTIN_ID_WEAKSET,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SET) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_SET) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/* ECMA-262 v6, 19.4.1.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_SYMBOL_UL,
|
||||
ECMA_BUILTIN_ID_SYMBOL,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW)
|
||||
/* ECMA-262 v11, 18.1.1 */
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_GLOBAL_THIS_UL,
|
||||
ECMA_VALUE_GLOBAL_THIS,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_DATAVIEW)
|
||||
/* ECMA-262 v6, 23.1.1.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_DATAVIEW_UL,
|
||||
ECMA_BUILTIN_ID_DATAVIEW,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_DATAVIEW */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_DATAVIEW */
|
||||
|
||||
#if ENABLED (JERRY_ES2015_BUILTIN_PROXY)
|
||||
#if ENABLED (JERRY_BUILTIN_PROXY)
|
||||
/* ECMA-262 v6, 26.2.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROXY_UL,
|
||||
ECMA_BUILTIN_ID_PROXY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* ENABLED (JERRY_ES2015_BUILTIN_PROXY) */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
/* ECMA-262 v11, 20.2.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_BIGINT_UL,
|
||||
ECMA_BUILTIN_ID_BIGINT,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
@@ -263,14 +285,14 @@ ROUTINE (LIT_MAGIC_STRING_DECODE_URI, ECMA_GLOBAL_DECODE_URI, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_DECODE_URI_COMPONENT, ECMA_GLOBAL_DECODE_URI_COMPONENT, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_ENCODE_URI, ECMA_GLOBAL_ENCODE_URI, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_ENCODE_URI_COMPONENT, ECMA_GLOBAL_ENCODE_URI_COMPONENT, 1, 1)
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_PARSE_FLOAT, LIT_MAGIC_STRING_PARSE_FLOAT, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_PARSE_INT, LIT_MAGIC_STRING_PARSE_INT, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
#else /* !ENABLED (JERRY_ES2015) */
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
ROUTINE (LIT_MAGIC_STRING_PARSE_FLOAT, ECMA_GLOBAL_PARSE_FLOAT, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_PARSE_INT, ECMA_GLOBAL_PARSE_INT, 2, 2)
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
#if ENABLED (JERRY_BUILTIN_ANNEXB)
|
||||
ROUTINE (LIT_MAGIC_STRING_ESCAPE, ECMA_GLOBAL_ESCAPE, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_UNESCAPE, ECMA_GLOBAL_UNESCAPE, 1, 1)
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
#include "ecma-builtin-handlers.h"
|
||||
#include "ecma-promise-object.h"
|
||||
|
||||
static const ecma_native_handler_t ecma_native_handlers[] =
|
||||
{
|
||||
#define ECMA_NATIVE_HANDLER(id, handler, length) handler,
|
||||
#include "ecma-builtin-handlers.inc.h"
|
||||
#undef ECMA_NATIVE_HANDLER
|
||||
};
|
||||
|
||||
static const uint8_t ecma_native_handler_lengths[] =
|
||||
{
|
||||
#define ECMA_NATIVE_HANDLER(id, handler, length) length,
|
||||
#include "ecma-builtin-handlers.inc.h"
|
||||
#undef ECMA_NATIVE_HANDLER
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the native handler of a built-in handler type.
|
||||
*
|
||||
* return Function pointer of the handler
|
||||
*/
|
||||
ecma_native_handler_t
|
||||
ecma_builtin_handler_get (ecma_native_handler_id_t id) /**< handler id */
|
||||
{
|
||||
JERRY_ASSERT (id != ECMA_NATIVE_HANDLER_START && id < ECMA_NATIVE_HANDLER__COUNT);
|
||||
return ecma_native_handlers[id - 1];
|
||||
} /* ecma_builtin_handler_get */
|
||||
|
||||
/**
|
||||
* Get the initial 'length' value of a built-in handler type.
|
||||
*
|
||||
* return 'length' value of the handler
|
||||
*/
|
||||
uint8_t
|
||||
ecma_builtin_handler_get_length (ecma_native_handler_id_t id) /**< handler id */
|
||||
{
|
||||
JERRY_ASSERT (id != ECMA_NATIVE_HANDLER_START && id < ECMA_NATIVE_HANDLER__COUNT);
|
||||
return ecma_native_handler_lengths[id - 1];
|
||||
} /* ecma_builtin_handler_get_length */
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
@@ -0,0 +1,52 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ECMA_BUILTIN_HANDLERS_H
|
||||
#define ECMA_BUILTIN_HANDLERS_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-promise-object.h"
|
||||
#include "ecma-proxy-object.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ECMA_NATIVE_HANDLER_START = 0,
|
||||
#define ECMA_NATIVE_HANDLER(id, handler, length) id,
|
||||
#include "ecma-builtin-handlers.inc.h"
|
||||
#undef ECMA_NATIVE_HANDLER
|
||||
ECMA_NATIVE_HANDLER__COUNT
|
||||
} ecma_native_handler_id_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ECMA_NATIVE_HANDLER_FLAGS_NONE = 0,
|
||||
ECMA_NATIVE_HANDLER_FLAGS_NAME_INITIALIZED = (1 << 0),
|
||||
ECMA_NATIVE_HANDLER_FLAGS_LENGTH_INITIALIZED = (1 << 1),
|
||||
ECMA_NATIVE_HANDLER_FLAGS_PROMISE_ALREADY_RESOLVED = (1 << 2),
|
||||
} ecma_native_handler_flags_t;
|
||||
|
||||
ecma_native_handler_t
|
||||
ecma_builtin_handler_get (ecma_native_handler_id_t id);
|
||||
uint8_t
|
||||
ecma_builtin_handler_get_length (ecma_native_handler_id_t id);
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#endif /* !ECMA_BUILTIN_HANDLERS_H */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user