Compare commits
346 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d0f00d599 | |||
| b7069350c2 | |||
| 355ab24cdc | |||
| 50200152fe | |||
| 4cda596060 | |||
| d2d30df420 | |||
| a1e4bd859e | |||
| f322f603f5 | |||
| f0a249dfd3 | |||
| b4bc23078a | |||
| 77c72d4da7 | |||
| 5480cc3973 | |||
| 718a439db1 | |||
| a746a1d29a | |||
| 8d44eed661 | |||
| aa7861daf2 | |||
| c509a06669 | |||
| b3fa5e0e03 | |||
| 0b1d75a7db | |||
| 5f467a658b | |||
| ba8957697a | |||
| 59649fc222 | |||
| 7db6a9a372 | |||
| dfa9afbf6e | |||
| e4017f0b3a | |||
| 95cc5e992a | |||
| 00d12c0265 | |||
| a7e24fe89a | |||
| 82ca949850 | |||
| f54f2d3a7b | |||
| e9f08a7879 | |||
| 348e6a470e | |||
| 38e05b4569 | |||
| d2e0d71101 | |||
| 43f5026eb2 | |||
| 3f314f387d | |||
| bd0d391ee3 | |||
| 5f3428becb | |||
| 4a39946ef6 | |||
| f5d3d9004a | |||
| de515316cf | |||
| 2dbb6f79ef | |||
| 4e89e1828e | |||
| d7e21259fe | |||
| 35465ed78e | |||
| 47bd5d4b91 | |||
| cefd391772 | |||
| bac7ee3acd | |||
| 52debe8589 | |||
| 514fa6735a | |||
| 3b876f7392 | |||
| ef4cb2bf74 | |||
| ff9ff8f36c | |||
| bc408b159b | |||
| a588e49661 | |||
| 05dbbd134c | |||
| 1a2c04763a | |||
| f5a8dc02b4 | |||
| 6fe763f191 | |||
| b143b050cc | |||
| 368641043f | |||
| 3360e352bf | |||
| baf308a7ae | |||
| 0d49696618 | |||
| c9e9f8e818 | |||
| d00f4810b0 | |||
| c5bc3786cf | |||
| 4924f9fd31 | |||
| 76403606d0 | |||
| aead4b79a9 | |||
| 0ef509458e | |||
| ac1c48eeff | |||
| 79fd540ec9 | |||
| 85c798705a | |||
| dfbd89d94f | |||
| c68f6e79e1 | |||
| 57547d1261 | |||
| e9da834385 | |||
| 47d025c74f | |||
| 799583e5c8 | |||
| 2a3782141c | |||
| 8fa7819c1f | |||
| d681f201c2 | |||
| 85bad33fbf | |||
| 5467ac4608 | |||
| 0aa182c378 | |||
| 6efe14d1bd | |||
| 58e504f1f4 | |||
| f3a420b672 | |||
| 69f30977d9 | |||
| 49a1a80aa8 | |||
| a6ab5e9abe | |||
| a63e1d294d | |||
| 077eaeb4e7 | |||
| 26c6031530 | |||
| 53b61c1f6f | |||
| c51b268276 | |||
| d650390e47 | |||
| 768a209544 | |||
| ce5c8492b8 | |||
| dfc001d373 | |||
| 070096f30f | |||
| 7e0aa086ec | |||
| dbba83fe40 | |||
| d37ff33dbe | |||
| ee59c226d9 | |||
| c2eb9ce35c | |||
| bcc711e731 | |||
| 42523bd6e2 | |||
| 4cbc77d709 | |||
| d5f048e961 | |||
| 55acdf2048 | |||
| 18dd9aa75a | |||
| f8faf574b6 | |||
| 51da15516e | |||
| bfc1121e35 | |||
| af297bc578 | |||
| 9860d66a56 | |||
| 81d2319144 | |||
| a1c1d42710 | |||
| d69ac0e070 | |||
| 70e275e92f | |||
| 841e21a970 | |||
| 271d9b2463 | |||
| fc4168f2b4 | |||
| 3737a28eaf | |||
| 2899582080 | |||
| 06b4c02204 | |||
| a7d5594d30 | |||
| 6b9e24aa51 | |||
| 4592143400 | |||
| 80777799f6 | |||
| badfdf4dba | |||
| bc091e1742 | |||
| 7ea0000ee0 | |||
| 6a995e2887 | |||
| 89e367bbfd | |||
| 960b99766c | |||
| 3ad76f932c | |||
| efe63a5bbc | |||
| 9ed695f9d2 | |||
| 3c742bef57 | |||
| a024eb2118 | |||
| d2388e907f | |||
| dd77ec914a | |||
| 24c1a93d91 | |||
| c6f9ea65ce | |||
| 499cdea75c | |||
| 100b6f577e | |||
| 2a4fb19157 | |||
| 74f98ec4d7 | |||
| c446871214 | |||
| 4e8d6344a8 | |||
| dae234f416 | |||
| 4912e3b739 | |||
| b52c114423 | |||
| fe3a5c08b2 | |||
| d4231e7251 | |||
| f6eac3afdc | |||
| c696bc9327 | |||
| 7c21fb89b2 | |||
| d98ff6fd30 | |||
| 54b1a3c739 | |||
| f3cd586094 | |||
| 7d355b0f8e | |||
| 2a82da62ad | |||
| 8b3eb93167 | |||
| 14ff5bfb52 | |||
| 35058cde31 | |||
| ca185acded | |||
| 053bfa0f9f | |||
| 430289b27d | |||
| 77c2602205 | |||
| 386ec44d4d | |||
| d08b5be57f | |||
| 723b26392d | |||
| 2c2539c6b8 | |||
| fea10bb7e3 | |||
| 1523ca3b26 | |||
| e1ce7dd727 | |||
| f94a3c80bd | |||
| 6649940ea6 | |||
| 1c6b18ecdf | |||
| bf049fbe2d | |||
| 8cbe1b59c1 | |||
| 4175037fb0 | |||
| b4fc591398 | |||
| 5a69b183c3 | |||
| be910b9867 | |||
| 3bcd48f72d | |||
| e7ffb70ae0 | |||
| 74e5ccd434 | |||
| fc29019165 | |||
| 3ed93cfb51 | |||
| b7dead7b05 | |||
| a25b824509 | |||
| 444806d78a | |||
| b6ec9275aa | |||
| c438d5fa92 | |||
| f71a4a6975 | |||
| 951044c036 | |||
| d99905aca6 | |||
| d69fe41085 | |||
| d4178ae386 | |||
| d9360f51d0 | |||
| bbf1c0105b | |||
| b25b640ff5 | |||
| 298228abdd | |||
| 57a09cbc9d | |||
| d65d035a36 | |||
| 6296a8251c | |||
| 7de391931a | |||
| 713d90b5a0 | |||
| 9ff25dbc12 | |||
| 252d68936f | |||
| d5a7839632 | |||
| 998e49a969 | |||
| 4be05a74eb | |||
| 305741a608 | |||
| 7f6a699700 | |||
| e3a299b3d6 | |||
| d1204ab1c9 | |||
| ccc152594a | |||
| 811fd4c054 | |||
| 8f71871a39 | |||
| 6de17b204e | |||
| d97d407eee | |||
| dddd37d38f | |||
| 9471515dae | |||
| 5729dd8cec | |||
| e8ed543677 | |||
| 703ddae194 | |||
| ce5e4d49b1 | |||
| 7be339ad61 | |||
| 800031c62b | |||
| 431a28b902 | |||
| 3c512d937b | |||
| 67a61bc211 | |||
| a67f198134 | |||
| 5180680030 | |||
| 26f604ce1e | |||
| e042998f02 | |||
| a58884c169 | |||
| 823a8b128d | |||
| 8aaabd8b01 | |||
| ce24edae24 | |||
| b4bea25f13 | |||
| dead11cdd0 | |||
| 10002aef60 | |||
| 4f15332e95 | |||
| ec3ed65b56 | |||
| cc1a263657 | |||
| 1f2a8d4ac1 | |||
| a7a4cb29e4 | |||
| 7b6743403f | |||
| 05a4e45ece | |||
| 60cbc93cd7 | |||
| 053389de80 | |||
| b3ec217b50 | |||
| ef35c0329c | |||
| 2381078e80 | |||
| d85020f709 | |||
| 4377ef684d | |||
| 6677fa0a12 | |||
| 6c484f3529 | |||
| 874a6a49d5 | |||
| 22ebb00a4c | |||
| edd2f20397 | |||
| e739f11ed2 | |||
| 8321640c4e | |||
| 546422161e | |||
| 7a2665621b | |||
| dc3ae4ff06 | |||
| 96cd542bf5 | |||
| 9254cd4e7a | |||
| 29b7c8f8ff | |||
| a95e3e37e1 | |||
| 129ca4946c | |||
| 9556701742 | |||
| 17ed855df5 | |||
| c27047da03 | |||
| f0f2a28109 | |||
| 1623c8db1e | |||
| a3bdd36556 | |||
| 1cf2989a64 | |||
| 5c35370327 | |||
| 322265bfb9 | |||
| 2240a9153a | |||
| 242c3a55e3 | |||
| 01e0388d77 | |||
| c14702c129 | |||
| 112ad83aaa | |||
| 488a0bf7e8 | |||
| 67e7e89c8e | |||
| 3afb007123 | |||
| a2f22cf888 | |||
| a95a0b3539 | |||
| a9c83020df | |||
| 34a6a93597 | |||
| 2a6917b5a5 | |||
| 3df7998084 | |||
| 818cc8ddab | |||
| f7c817efcf | |||
| ec872818c2 | |||
| 53aed02762 | |||
| 6fd0dfec35 | |||
| c2e016ec06 | |||
| 75b0378bc5 | |||
| 76a0b18287 | |||
| 35ecf4c4a3 | |||
| b1f73e698a | |||
| ca6c2194bb | |||
| 0628ae1e7b | |||
| e01c2549d7 | |||
| 3623ac789d | |||
| feb2855f0c | |||
| 9ca046b670 | |||
| e9df2ca814 | |||
| dd698f8d83 | |||
| 4bb9e2b878 | |||
| 9db4ec7d77 | |||
| aa941ed58e | |||
| 9dbb594170 | |||
| 982cd08083 | |||
| e7d11eaf9e | |||
| 3bb67397a0 | |||
| a1b682a83d | |||
| f369c84c24 | |||
| d7843be2e8 | |||
| dd0b00fdad | |||
| c82f184f00 | |||
| 1712ad5dc4 | |||
| 090b6307a6 | |||
| 748e1be041 | |||
| e191a5cf47 | |||
| 62dc782e5c | |||
| 87d30b8088 | |||
| ba06d492a3 | |||
| e081cbc2f0 | |||
| b5bf97c657 | |||
| ff1a99b999 | |||
| 0e21c17080 | |||
| b8a0ffd913 | |||
| 8be6aec50d | |||
| 1db0905889 | |||
| 9900cacb15 |
@@ -0,0 +1,87 @@
|
||||
---
|
||||
Language: Cpp
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveMacros: true
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: false
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterReturnType: AllDefinitions
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
AfterControlStatement: Always
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
AfterExternBlock: false
|
||||
BeforeElse: true
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 120
|
||||
ContinuationIndentWidth: 2
|
||||
Cpp11BracedListStyle: false
|
||||
DeriveLineEnding: true
|
||||
DerivePointerAlignment: true
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: true
|
||||
IncludeBlocks: Regroup
|
||||
IncludeCategories:
|
||||
- Regex: '<windows.h>'
|
||||
Priority: 0
|
||||
- Regex: '<[-./a-z]*>'
|
||||
Priority: 1
|
||||
- Regex: '"jerryscript[-.a-z]*"'
|
||||
Priority: 2
|
||||
- Regex: '"ecma[-.a-z]*"'
|
||||
Priority: 3
|
||||
- Regex: '.*'
|
||||
Priority: 4
|
||||
IndentCaseLabels: true
|
||||
IndentGotoLabels: false
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 2
|
||||
IndentWrappedFunctionNames: false
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
PointerAlignment: Right
|
||||
ReflowComments: true
|
||||
SortIncludes: true
|
||||
SpaceAfterCStyleCast: true
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeParens: Always
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpaceBeforeSquareBrackets: false
|
||||
Standard: Auto
|
||||
StatementMacros:
|
||||
- JERRY_ASSERT
|
||||
- JERRY_STATIC_ASSERT
|
||||
- JERRY_UNREACHABLE
|
||||
TabWidth: 0
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
...
|
||||
@@ -7,98 +7,203 @@ env:
|
||||
|
||||
jobs:
|
||||
Checks:
|
||||
runs-on: ubuntu-18.04 # needed for checker version stability
|
||||
runs-on: ubuntu-22.04 # needed for checker version stability
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.10'
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install doxygen vera++ cppcheck pylint python-serial
|
||||
- run: sudo apt install pylint doxygen cppcheck clang-format-15
|
||||
- run: $RUNNER --check-signed-off=gh-actions
|
||||
if: ${{ always() }}
|
||||
- run: $RUNNER --check-doxygen
|
||||
- run: $RUNNER --check-vera
|
||||
if: ${{ always() }}
|
||||
- run: $RUNNER --check-format
|
||||
if: ${{ always() }}
|
||||
- run: $RUNNER --check-license
|
||||
- run: $RUNNER --check-magic-strings
|
||||
if: ${{ always() }}
|
||||
- run: $RUNNER --check-strings
|
||||
if: ${{ always() }}
|
||||
- run: $RUNNER --check-pylint
|
||||
if: ${{ always() }}
|
||||
- run: $RUNNER --check-cppcheck
|
||||
if: ${{ always() }}
|
||||
|
||||
Linux_x86-64_Build_Correctness_Debugger_Tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '2.7' # needed by jerry-debugger
|
||||
python-version: '>=3.6'
|
||||
- run: $RUNNER -q --jerry-tests
|
||||
- run: $RUNNER -q --jerry-tests --build-debug
|
||||
- run: $RUNNER -q --jerry-debugger
|
||||
- run: $RUNNER -q --jerry-debugger --build-debug
|
||||
|
||||
Linux_x86_cpointer-32bit_Build_Correctness_Tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '>=3.6'
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install gcc-multilib
|
||||
- run: $RUNNER -q --jerry-tests --buildoptions=--compile-flag=-m32,--cpointer-32bit=on
|
||||
- run: $RUNNER -q --jerry-tests --buildoptions=--compile-flag=-m32,--cpointer-32bit=on --build-debug
|
||||
|
||||
OSX_x86-64_Build_Correctness_Unit_Tests:
|
||||
runs-on: macos-latest
|
||||
Win_x86-64_Conformance_Tests_ESNext:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: python $env:RUNNER --test262 update
|
||||
|
||||
Win_x86-64_Conformance_Tests_ESNext_Debug:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: python $env:RUNNER --test262 update --build-debug
|
||||
|
||||
Win_x86-64_Tests-MINGW:
|
||||
runs-on: windows-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: msys2 {0}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
msystem: MINGW64
|
||||
update: true
|
||||
install: >-
|
||||
mingw-w64-x86_64-python
|
||||
mingw-w64-x86_64-cmake
|
||||
mingw-w64-x86_64-make
|
||||
mingw-w64-x86_64-toolchain
|
||||
- run: python $RUNNER -q --jerry-tests
|
||||
- run: python $RUNNER -q --unittests --build-config=''
|
||||
# FIXME: enable it with upgrade valgrind - run: python $RUNNER -q --buildoption-test
|
||||
|
||||
Win_x86-64_Tests:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: python $env:RUNNER -q --jerry-tests
|
||||
- run: python $env:RUNNER -q --unittests
|
||||
- run: python $env:RUNNER -q --buildoption-test
|
||||
|
||||
Win_x86-64_Tests_Debug:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: python $env:RUNNER -q --jerry-tests --build-debug
|
||||
- run: python $env:RUNNER -q --unittests --build-debug
|
||||
- run: python $env:RUNNER -q --buildoption-test --build-debug
|
||||
|
||||
OSX_x86-64_Build_Correctness_Unit_Tests:
|
||||
runs-on: macos-13
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '>=3.6'
|
||||
- run: $RUNNER -q --jerry-tests
|
||||
- run: $RUNNER -q --unittests
|
||||
|
||||
OSX_x86-64_Build_Correctness_Unit_Tests_Debug:
|
||||
runs-on: macos-13
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '>=3.6'
|
||||
- run: $RUNNER -q --jerry-tests --build-debug
|
||||
- run: $RUNNER -q --unittests --build-debug
|
||||
|
||||
Linux_x86-64_Build_Option_Tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '>=3.6'
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install gcc-multilib
|
||||
- run: $RUNNER --buildoption-test
|
||||
|
||||
Conformance_Tests_ES5_1:
|
||||
Conformance_Tests_ESNext:
|
||||
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
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '>=3.6'
|
||||
- run: $RUNNER --test262 update
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: success() || failure()
|
||||
with:
|
||||
name: Test262-ES2015-results
|
||||
path: build/tests/test262_tests_es2015/local/bin/test262.report
|
||||
name: Test262-ESNext-results
|
||||
path: |
|
||||
build/tests/test262_tests_esnext/local/bin/test262.report
|
||||
|
||||
Conformance_Tests_ESNext_A:
|
||||
Conformance_Tests_ESNext_Debug_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
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '>=3.6'
|
||||
- run: $RUNNER --test262 update --build-debug --test262-test-list=built-ins,annexB,harness,intl402
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: success() || failure()
|
||||
with:
|
||||
name: Test262-ESNext-results-A
|
||||
path: build/tests/test262_tests_esnext/local/bin/test262.report
|
||||
name: Test262-ESNext-Debug-A-results
|
||||
path: |
|
||||
build/tests/test262_tests_esnext-debug/local/bin/test262.report
|
||||
|
||||
Conformance_Tests_ESNext_B:
|
||||
Conformance_Tests_ESNext_Debug_B:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: $RUNNER --test262-esnext=update --test262-test-list=language
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '>=3.6'
|
||||
- run: $RUNNER --test262 update --build-debug --test262-test-list=language
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: success() || failure()
|
||||
with:
|
||||
name: Test262-ESNext-results-B
|
||||
path: build/tests/test262_tests_esnext/local/bin/test262.report
|
||||
name: Test262-ESNext-Debug-B-results
|
||||
path: |
|
||||
build/tests/test262_tests_esnext-debug/local/bin/test262.report
|
||||
|
||||
Unit_Tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '>=3.6'
|
||||
- run: $RUNNER -q --unittests
|
||||
- run: $RUNNER -q --unittests --build-debug
|
||||
|
||||
Clang_Unit_Build_Option_Tests:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
CC: clang
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '>=3.6'
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install gcc-multilib
|
||||
- run: $RUNNER -q --unittests
|
||||
# clang has bug in supporting lto
|
||||
- run: $RUNNER -q --buildoption-test --buildoptions=--lto=off
|
||||
|
||||
ASAN_Tests:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -106,12 +211,31 @@ jobs:
|
||||
ASAN_OPTIONS: detect_stack_use_after_return=1:check_initialization_order=true:strict_init_order=true
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '>=3.6'
|
||||
- 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
|
||||
--skip-list=parser-oom.js,parser-oom2.js,stack-limit.js,regression-test-issue-4870.js,regression-test-issue-4901.js,regression-test-issue-4848.js,regression-test-issue-4890.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,proxy-evil-recursion.js,regression-test-issue-5101.js
|
||||
|
||||
ASAN_Tests_Debug:
|
||||
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
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '>=3.6'
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install gcc-multilib
|
||||
- run: >-
|
||||
$RUNNER -q --jerry-tests --build-debug
|
||||
--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-4870.js,regression-test-issue-4901.js,regression-test-issue-4848.js,regression-test-issue-4890.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,proxy-evil-recursion.js,regression-test-issue-5101.js
|
||||
|
||||
UBSAN_Tests:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -119,12 +243,19 @@ jobs:
|
||||
UBSAN_OPTIONS: print_stacktrace=1
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '>=3.6'
|
||||
- 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
|
||||
- run: >-
|
||||
$RUNNER -q --jerry-tests --build-debug
|
||||
--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
|
||||
@@ -133,12 +264,31 @@ jobs:
|
||||
TIMEOUT: 300
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '>=3.6'
|
||||
- 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_ARMv7l_Tests_Debug:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUNTIME: qemu-arm-static
|
||||
TIMEOUT: 300
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '>=3.6'
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user-static
|
||||
- run: >-
|
||||
$RUNNER -q --jerry-tests --build-debug
|
||||
--buildoptions=--toolchain=cmake/toolchain_linux_armv7l.cmake,--linker-flag=-static
|
||||
|
||||
Linux_AArch64_Tests:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
@@ -146,71 +296,100 @@ jobs:
|
||||
TIMEOUT: 300
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '>=3.6'
|
||||
- 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
|
||||
Linux_AArch64_Tests_Debug:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUNTIME: qemu-aarch64-static
|
||||
TIMEOUT: 300
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.8' # needed due to 'intelhex' module
|
||||
- run: sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
|
||||
python-version: '>=3.6'
|
||||
- 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
|
||||
- run: sudo apt install gcc-aarch64-linux-gnu libc6-dev-armhf-cross qemu-user-static
|
||||
- run: >-
|
||||
$RUNNER -q --jerry-tests --build-debug
|
||||
--buildoptions=--toolchain=cmake/toolchain_linux_aarch64.cmake,--linker-flag=-static
|
||||
|
||||
Zephyr_Arduino_101_Build_Test:
|
||||
MbedOS_K64F_Build_Test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.x'
|
||||
python-version: '>=3.6'
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install gcc-arm-none-eabi ninja-build
|
||||
- run: make -f ./targets/os/mbedos/Makefile.travis install
|
||||
- run: make -f ./targets/os/mbedos/Makefile.travis script
|
||||
|
||||
Zephyr_STM32F4_Build_Test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '>=3.6'
|
||||
- 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
|
||||
- run: make -f ./targets/os/zephyr/Makefile.travis install
|
||||
- run: make -f ./targets/os/zephyr/Makefile.travis script
|
||||
|
||||
NuttX_STM32F4_Build_Test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '>=3.6'
|
||||
- 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
|
||||
- run: make -f ./targets/os/nuttx/Makefile.travis install-noapt
|
||||
- run: make -f ./targets/os/nuttx/Makefile.travis script
|
||||
|
||||
RIOT_STM32F4_Build_Test:
|
||||
runs-on: ubuntu-18.04 # needed due to ppa:team-gcc-arm-embedded/ppa
|
||||
runs-on: ubuntu-latest
|
||||
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
|
||||
- run: sudo apt -y install clang gcc-arm-none-eabi
|
||||
- run: make -f ./targets/os/riot/Makefile.travis install-noapt
|
||||
- run: make -f ./targets/os/riot/Makefile.travis script
|
||||
|
||||
ESP8266_Build_Test:
|
||||
ESP8266_RTOS_SDK_Build_Test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
- uses: actions/setup-python@v4
|
||||
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
|
||||
python-version: '>=3.8'
|
||||
- run: make -f ./targets/baremetal-sdk/espressif/esp8266-rtos-sdk/Makefile.travis install-noapt
|
||||
- run: make -f ./targets/baremetal-sdk/espressif/esp8266-rtos-sdk/Makefile.travis script
|
||||
|
||||
ESP_IDF_Build_Test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '==3.8'
|
||||
- run: make -f ./targets/baremetal-sdk/espressif/esp-idf/Makefile.travis install-noapt
|
||||
- run: make -f ./targets/baremetal-sdk/espressif/esp-idf/Makefile.travis script
|
||||
|
||||
Notification:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push' && github.repository == 'jerryscript-project/jerryscript'
|
||||
if: false && github.event_name == 'push' && github.repository == 'jerryscript-project/jerryscript'
|
||||
steps:
|
||||
- uses: rectalogic/notify-irc@v1
|
||||
with:
|
||||
|
||||
+47
-15
@@ -12,11 +12,14 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required (VERSION 2.8.12)
|
||||
cmake_minimum_required (VERSION 3.10)
|
||||
project (Jerry C)
|
||||
|
||||
if(NOT DEFINED PYTHON)
|
||||
set(PYTHON "python")
|
||||
endif()
|
||||
# Determining version
|
||||
execute_process(COMMAND python ${CMAKE_SOURCE_DIR}/tools/version.py
|
||||
execute_process(COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/tools/version.py
|
||||
OUTPUT_VARIABLE JERRY_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
@@ -25,11 +28,16 @@ set(PLATFORM "${CMAKE_SYSTEM_NAME}")
|
||||
string(TOUPPER "${PLATFORM}" PLATFORM)
|
||||
|
||||
# Determining compiler
|
||||
if(MSVC)
|
||||
set(USING_MSVC 1)
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
|
||||
set(USING_GCC 1)
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
# Clang may support for MSVC
|
||||
if(NOT USING_MSVC AND CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
set(USING_CLANG 1)
|
||||
endif()
|
||||
|
||||
@@ -37,10 +45,6 @@ if(CMAKE_C_COMPILER_ID MATCHES "TI")
|
||||
set(USING_TI 1)
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
|
||||
set(USING_MSVC 1)
|
||||
endif()
|
||||
|
||||
# Determining build type
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "MinSizeRel")
|
||||
@@ -51,7 +55,7 @@ set(JERRY_CMDLINE ON CACHE BOOL "Build jerry command line tool?")
|
||||
set(JERRY_CMDLINE_TEST OFF CACHE BOOL "Build jerry test command line tool?")
|
||||
set(JERRY_CMDLINE_SNAPSHOT OFF CACHE BOOL "Build jerry snapshot command line tool?")
|
||||
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_PORT ON CACHE BOOL "Build default jerry port implementation?")
|
||||
set(JERRY_EXT ON CACHE BOOL "Build jerry-ext?")
|
||||
set(JERRY_MATH OFF CACHE BOOL "Build and use jerry-math?")
|
||||
set(UNITTESTS OFF CACHE BOOL "Build unit tests?")
|
||||
@@ -64,6 +68,10 @@ 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?")
|
||||
|
||||
if(USING_MSVC)
|
||||
set(ENABLE_STATIC_CRT OFF CACHE BOOL "Enable MSVC static CRT?")
|
||||
endif()
|
||||
|
||||
# Option overrides
|
||||
if(NOT USING_CLANG)
|
||||
set(JERRY_LIBFUZZER OFF)
|
||||
@@ -72,9 +80,9 @@ if(NOT USING_CLANG)
|
||||
endif()
|
||||
|
||||
if(JERRY_CMDLINE OR JERRY_CMDLINE_TEST OR JERRY_CMDLINE_SNAPSHOT OR JERRY_LIBFUZZER OR UNITTESTS OR DOCTESTS)
|
||||
set(JERRY_PORT_DEFAULT ON)
|
||||
set(JERRY_PORT ON)
|
||||
|
||||
set(JERRY_PORT_DEFAULT_MESSAGE " (FORCED BY CMDLINE OR LIBFUZZER OR TESTS)")
|
||||
set(JERRY_PORT_MESSAGE " (FORCED BY CMDLINE OR LIBFUZZER OR TESTS)")
|
||||
endif()
|
||||
|
||||
if(JERRY_CMDLINE OR DOCTESTS)
|
||||
@@ -129,13 +137,14 @@ 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_STATIC_CRT " ${ENABLE_STATIC_CRT})
|
||||
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_PORT " ${JERRY_PORT} ${JERRY_PORT_MESSAGE})
|
||||
message(STATUS "JERRY_EXT " ${JERRY_EXT} ${JERRY_EXT_MESSAGE})
|
||||
message(STATUS "JERRY_MATH " ${JERRY_MATH} ${JERRY_MATH_MESSAGE})
|
||||
message(STATUS "UNITTESTS " ${UNITTESTS})
|
||||
@@ -200,7 +209,11 @@ endif()
|
||||
if("${PLATFORM}" STREQUAL "DARWIN")
|
||||
jerry_add_link_flags(-lSystem)
|
||||
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>")
|
||||
if("${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
|
||||
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
|
||||
else()
|
||||
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
|
||||
endif()
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup")
|
||||
elseif((NOT CYGWIN AND NOT MINGW AND NOT MSYS) AND (USING_GCC OR USING_CLANG))
|
||||
jerry_add_link_flags(-Wl,-z,noexecstack)
|
||||
@@ -211,7 +224,10 @@ if(USING_GCC OR USING_CLANG)
|
||||
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_warnings(all extra format-nonliteral init-self sign-conversion format-security missing-declarations shadow strict-prototypes undef old-style-definition)
|
||||
if(NOT "${PLATFORM}" STREQUAL "WINDOWS")
|
||||
jerry_add_compile_warnings(conversion)
|
||||
endif()
|
||||
jerry_add_compile_flags(-Wno-stack-protector -Wno-attributes -Werror)
|
||||
endif()
|
||||
|
||||
@@ -235,6 +251,22 @@ if(USING_MSVC)
|
||||
jerry_add_link_flags(/OPT:NOREF)
|
||||
# Disable MSVC warning 4996 globally because it stops us from using standard C functions.
|
||||
jerry_add_compile_flags(/wd4996)
|
||||
|
||||
if(ENABLE_STATIC_CRT)
|
||||
# Replace the existing /MD and /MDd values with /MT and /MTd.
|
||||
set(COMPILER_FLAGS
|
||||
CMAKE_CXX_FLAGS
|
||||
CMAKE_CXX_FLAGS_DEBUG
|
||||
CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS
|
||||
CMAKE_C_FLAGS_DEBUG
|
||||
CMAKE_C_FLAGS_RELEASE
|
||||
)
|
||||
|
||||
foreach(_flag ${COMPILER_FLAGS})
|
||||
string(REPLACE "/MD" "/MT" ${_flag} "${${_flag}}")
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(JERRY_LIBFUZZER)
|
||||
@@ -272,8 +304,8 @@ if(JERRY_EXT)
|
||||
endif()
|
||||
|
||||
# Jerry's default port implementation
|
||||
if(JERRY_PORT_DEFAULT)
|
||||
add_subdirectory(jerry-port/default)
|
||||
if(JERRY_PORT)
|
||||
add_subdirectory(jerry-port)
|
||||
endif()
|
||||
|
||||
# Jerry command line tool
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
# JerryScript: JavaScript engine for the Internet of Things
|
||||
[](LICENSE)
|
||||
[](https://github.com/jerryscript-project/jerryscript/actions)
|
||||
[](https://ci.appveyor.com/project/jerryscript-project/jerryscript/branch/master)
|
||||
[](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fjerryscript-project%2Fjerryscript?ref=badge_shield)
|
||||
[](https://kiwiirc.com/client/irc.freenode.net/#jerryscript)
|
||||
|
||||
@@ -10,7 +9,9 @@ JerryScript is a lightweight JavaScript engine for resource-constrained devices
|
||||
|
||||
Key characteristics of JerryScript:
|
||||
* Full ECMAScript 5.1 standard compliance
|
||||
* 160K binary size when compiled for ARM Thumb-2
|
||||
* ECMAScript 2025 standard compliance is 70%
|
||||
* [Kangax Compatibilty Table](https://compat-table.github.io/compat-table/es2016plus/)
|
||||
* 258K binary size when compiled for ARM Thumb-2
|
||||
* Heavily optimized for low memory consumption
|
||||
* Written in C99 for maximum portability
|
||||
* Snapshot support for precompiling JavaScript source code to byte code
|
||||
@@ -18,14 +19,6 @@ Key characteristics of JerryScript:
|
||||
|
||||
Additional information can be found on our [project page](http://jerryscript.net) and [Wiki](https://github.com/jerryscript-project/jerryscript/wiki).
|
||||
|
||||
Memory usage and Binary footprint are measured at [here](https://jerryscript-project.github.io/jerryscript-test-results) with real target daily.
|
||||
|
||||
The latest results on **Raspberry Pi 2**:
|
||||
|
||||
|
||||
[](https://jerryscript-project.github.io/jerryscript-test-results/?view=rpi2)
|
||||
|
||||
IRC channel: #jerryscript on [freenode](https://freenode.net)
|
||||
Mailing list: jerryscript-dev@groups.io, you can subscribe [here](https://groups.io/g/jerryscript-dev) and access the mailing list archive [here](https://groups.io/g/jerryscript-dev/topics).
|
||||
|
||||
## Quick Start
|
||||
@@ -47,7 +40,17 @@ For additional information see [Getting Started](docs/00.GETTING-STARTED.md).
|
||||
- [Configuration](docs/01.CONFIGURATION.md)
|
||||
- [API Reference](docs/02.API-REFERENCE.md)
|
||||
- [API Example](docs/03.API-EXAMPLE.md)
|
||||
- [Internals](docs/04.INTERNALS.md)
|
||||
- [Port API](docs/05.PORT-API.md)
|
||||
- [Reference Couting](docs/06.REFERENCE-COUNTING.md)
|
||||
- [Debugger](docs/07.DEBUGGER.md)
|
||||
- [Coding Standards](docs/08.CODING-STANDARDS.md)
|
||||
- [Arguments Extension API](docs/09.EXT-REFERENCE-ARG.md)
|
||||
- [Property Extension API](docs/10.EXT-REFERENCE-HANDLER.md)
|
||||
- [Autorelease Extension API](docs/11.EXT-REFERENCE-AUTORELEASE.md)
|
||||
- [Module Extension API](docs/12.EXT-REFERENCE-MODULE.md)
|
||||
- [Debugger Transport Interface](docs/13.DEBUGGER-TRANSPORT.md)
|
||||
- [Scope Extension API](docs/14.EXT-REFERENCE-HANDLE-SCOPE.md)
|
||||
- [Module System](docs/15.MODULE-SYSTEM.md)
|
||||
- [Migration Guide](docs/16.MIGRATION-GUIDE.md)
|
||||
|
||||
## Contributing
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
version: "{build}"
|
||||
branches:
|
||||
except:
|
||||
- coverity_scan
|
||||
- gh_pages
|
||||
skip_tags: true
|
||||
|
||||
# Build matrix setup.
|
||||
image:
|
||||
- Visual Studio 2017
|
||||
configuration:
|
||||
- Debug
|
||||
- Release
|
||||
platform:
|
||||
- x64
|
||||
- Win32
|
||||
|
||||
# Steps of a job.
|
||||
init:
|
||||
- cmake -version
|
||||
before_build:
|
||||
- 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: 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
|
||||
+10
-10
@@ -5,17 +5,17 @@ Currently, only Ubuntu 18.04+ is officially supported as primary development env
|
||||
There are several dependencies, that should be installed manually. The following list is the absolute minimum for building:
|
||||
|
||||
- `gcc` or any C99-compliant compiler (native or cross, e.g., arm-none-eabi)
|
||||
- `cmake` >= `2.8.12.2`
|
||||
- `cmake` >= `3.10`
|
||||
|
||||
Several scripts and tools help the building and development process, thus it is recommended to have the following installed as well:
|
||||
|
||||
- `bash` >= `4.3.11`
|
||||
- `cppcheck` >= `1.61`
|
||||
- `vera++` >= `1.2.1`
|
||||
- `python` >= `2.7.6`
|
||||
- `cppcheck` >= `2.7`
|
||||
- `clang-format-15`
|
||||
- `python` >= `3.10`
|
||||
|
||||
```bash
|
||||
sudo apt-get install gcc gcc-arm-none-eabi cmake cppcheck vera++ python
|
||||
sudo apt-get install gcc gcc-arm-none-eabi cmake cppcheck clang-format-15 python
|
||||
```
|
||||
|
||||
To make our scripts run correctly, several shell utilities should be available on the system:
|
||||
@@ -51,13 +51,13 @@ tools/build.py --debug --logging=on --error-messages=on --line-info=on
|
||||
python tools/build.py --cmake-param=CMAKE_PARAM
|
||||
```
|
||||
|
||||
**Set a profile mode (ES.next, ES5.1, minimal)**
|
||||
**Set a profile mode (es.next, minimal)**
|
||||
|
||||
```bash
|
||||
python tools/build.py --profile=es.next|es5.1|minimal
|
||||
python tools/build.py --profile=es.next|minimal
|
||||
```
|
||||
|
||||
See also the related [README.md](https://github.com/jerryscript-project/jerryscript/blob/master/jerry-core/profiles/README.md).
|
||||
See also the related [README.md](../jerry-core/profiles/README.md).
|
||||
|
||||
**Use (compiler-default, external) libc**
|
||||
|
||||
@@ -173,10 +173,10 @@ python tools/run-tests.py --check-signed-off
|
||||
python tools/run-tests.py --check-cppcheck
|
||||
```
|
||||
|
||||
**To run vera check**
|
||||
**To run format check**
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --check-vera
|
||||
python tools/run-tests.py --check-format
|
||||
```
|
||||
|
||||
**To get a list of all the available test options**
|
||||
|
||||
+72
-10
@@ -1,7 +1,7 @@
|
||||
# Configuration
|
||||
|
||||
JerryScript provides a large number of configuration options which can be used to enable or disable specific features, allowing users to fine tune the engine to best suit their needs.
|
||||
A configuration option's value can be changed either by providing specific C preprocessor definitions, by adding CMake defininitions, or by using the arguments of the `tools/build.py` script.
|
||||
A configuration option's value can be changed either by providing specific C preprocessor definitions, by adding CMake definitions, or by using the arguments of the `tools/build.py` script.
|
||||
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.
|
||||
|
||||
|
||||
@@ -44,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 `es.next`, `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` 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 | |
|
||||
@@ -53,6 +53,17 @@ To see how a profile file should be created, or what configuration options are a
|
||||
| CMake: | `-DJERRY_PROFILE="path"` |
|
||||
| Python: | `--profile="path"` |
|
||||
|
||||
### Promise callback
|
||||
|
||||
Enables Promise event notification support. This feature allows setting a user callback, which is called when certain Promise related events occur such as
|
||||
creating a new Promise, resolving a Promise with a value, etc.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_PROMISE_CALLBACK=0/1` |
|
||||
| CMake: | `-DJERRY_PROMISE_CALLBACK=ON/OFF` |
|
||||
| Python: | `--promise-callback=ON/OFF` |
|
||||
|
||||
### External context
|
||||
|
||||
Enables external context support in the engine. By default, JerryScript uses a statically allocated context to store the current state of the engine internals.
|
||||
@@ -139,7 +150,7 @@ Enabling this feature provides detailed error messages where available, like lin
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_ERROR_MESSAGES=0/1` |
|
||||
| CMake: | `--DJERRY_ERROR_MESSAGES=ON/OFF` |
|
||||
| CMake: | `-DJERRY_ERROR_MESSAGES=ON/OFF` |
|
||||
| Python: | `--error-messages=ON/OFF` |
|
||||
|
||||
### Logging
|
||||
@@ -173,13 +184,13 @@ This option is enabled by default.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_PROPRETY_HASHMAP=0/1` |
|
||||
| C: | `-DJERRY_PROPERTY_HASHMAP=0/1` |
|
||||
| CMake: | `<none>` |
|
||||
| Python: | `<none>` |
|
||||
|
||||
### Memory statistics
|
||||
|
||||
This option can be used to provide memory usage statistics either upon engine termination, or during runtime using the `jerry_get_memory_stats` jerry API function.
|
||||
This option can be used to provide memory usage statistics either upon engine termination, or during runtime using the `jerry_heap_stats` jerry API function.
|
||||
The feature can create a significant performance overhead, and should only be used for measurement purposes. This option is disabled by default.
|
||||
|
||||
| Options | |
|
||||
@@ -196,7 +207,7 @@ The default value is 512.
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_GLOBAL_HEAP_SIZE=(int)` |
|
||||
| CMake: | `--DJERRY_GLOBAL_HEAP_SIZE=(int)` |
|
||||
| CMake: | `-DJERRY_GLOBAL_HEAP_SIZE=(int)` |
|
||||
| Python: | `--mem-heap=(int)` |
|
||||
|
||||
### Garbage collection limit
|
||||
@@ -280,6 +291,58 @@ This option is disabled by default.
|
||||
| CMake: | `-DJERRY_MEM_GC_BEFORE_EACH_ALLOC=ON/OFF` |
|
||||
| Python: | `--mem-stress-test=ON/OFF` |
|
||||
|
||||
### MSVC CRT
|
||||
|
||||
This option enables the use of the MSVC CRT library and is disabled by default.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `<none>` |
|
||||
| CMake: | `-DENABLE_STATIC_CRT=ON/OFF` |
|
||||
| Python: | `--static-crt=ON/OFF` |
|
||||
|
||||
### Architecture
|
||||
|
||||
Specify the platform name if it is supported by the generator.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `<none>` |
|
||||
| CMake: | `-A (string)` |
|
||||
| Python: | `--arch=(string)` |
|
||||
|
||||
### Tostring function
|
||||
|
||||
Enable function toString.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_FUNCTION_TO_STRING=0/1` |
|
||||
| CMake: | `-DJERRY_FUNCTION_TO_STRING=ON/OFF` |
|
||||
| Python: | `--function-to-string=ON/OFF` |
|
||||
|
||||
|
||||
### VM throw
|
||||
|
||||
Enable VM throw.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_VM_THROW=0/1` |
|
||||
| CMake: | `-DJERRY_VM_THROW=ON/OFF` |
|
||||
| Python: | `--vm-throw=ON/OFF` |
|
||||
|
||||
|
||||
### Promise callback
|
||||
|
||||
Enable Promise callback.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_PROMISE_CALLBACK=0/1` |
|
||||
| CMake: | `-DJERRY_PROMISE_CALLBACK=ON/OFF` |
|
||||
| Python: | `--promise-callback=ON/OFF` |
|
||||
|
||||
|
||||
# Amalgamated sources
|
||||
|
||||
@@ -288,7 +351,7 @@ in other projects. To achieve this, the following command can be executed to cre
|
||||
into the `amalgam` directory:
|
||||
|
||||
```sh
|
||||
$ python tools/amalgam.py --output-dir amalgam --jerry-core --jerry-port-default --jerry-math
|
||||
$ python tools/amalgam.py --output-dir amalgam --jerry-core --jerry-port --jerry-math
|
||||
```
|
||||
|
||||
(Note: In the example above, the command is executed from the project's root directory, but that is
|
||||
@@ -299,8 +362,7 @@ 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-port.c`
|
||||
* `jerryscript-math.c`
|
||||
* `math.h`
|
||||
|
||||
@@ -312,7 +374,7 @@ These files can be directly compiled with an application using the JerryScript A
|
||||
E.g., using a command similar to the one below:
|
||||
|
||||
```sh
|
||||
$ gcc -Wall -o demo_app demo_app.c amalgam/jerryscript.c amalgam/jerryscript-port-default.c amalgam/jerryscript-math.c -Iamalgam/
|
||||
$ gcc -Wall -o demo_app demo_app.c amalgam/jerryscript.c amalgam/jerryscript-port.c amalgam/jerryscript-math.c -Iamalgam/
|
||||
```
|
||||
|
||||
(Note: The headers must be available on the include path.)
|
||||
|
||||
+6739
-3228
File diff suppressed because it is too large
Load Diff
+152
-189
@@ -32,40 +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-math
|
||||
```
|
||||
|
||||
## Example 1. Execute JavaScript from your application
|
||||
|
||||
The most basic example to test the engine is to create an `api-example-1.c` file containing the following code:
|
||||
|
||||
[doctest]: # ()
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
const jerry_char_t script[] = "var str = 'Hello, World!';";
|
||||
|
||||
bool ret_value = jerry_run_simple (script, sizeof (script) - 1, JERRY_INIT_EMPTY);
|
||||
|
||||
return (ret_value ? 0 : 1);
|
||||
}
|
||||
```
|
||||
|
||||
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-math)
|
||||
```
|
||||
|
||||
If everything is correct the application returns with a zero exit code:
|
||||
|
||||
```
|
||||
$ ./api-example-1
|
||||
$ echo $?
|
||||
$ pkg-config --cflags --libs libjerry-core libjerry-port libjerry-ext libjerry-math
|
||||
```
|
||||
|
||||
## Example 2. Split engine initialization and script execution.
|
||||
@@ -73,9 +40,9 @@ $ echo $?
|
||||
In this example the engine is initialized directly with the `jerry_init` method
|
||||
and cleaned up with the `jerry_cleanup` method. The example JavaScript code
|
||||
is directly parsed and executed via the `jerry_eval` method. Each `jerry_value_t`
|
||||
returned by the API methods is freed with the `jerry_release_value` method.
|
||||
returned by the API methods is freed with the `jerry_value_free` method.
|
||||
|
||||
To make sure that the code parsing and execution was ok, the `jerry_value_is_error`
|
||||
To make sure that the code parsing and execution was ok, the `jerry_value_is_exception`
|
||||
method is used to check for any errors.
|
||||
|
||||
Use the following code for the `api-example-2.c` file:
|
||||
@@ -103,10 +70,10 @@ main (void)
|
||||
JERRY_PARSE_NO_OPTS);
|
||||
|
||||
/* Check if there was any error (syntax or runtime) */
|
||||
bool run_ok = !jerry_value_is_error (eval_ret);
|
||||
bool run_ok = !jerry_value_is_exception (eval_ret);
|
||||
|
||||
/* Parsed source code must be freed */
|
||||
jerry_release_value (eval_ret);
|
||||
jerry_value_free (eval_ret);
|
||||
|
||||
/* Cleanup engine */
|
||||
jerry_cleanup ();
|
||||
@@ -118,7 +85,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-math)
|
||||
$ gcc api-example-2.c -o api-example-2 $(pkg-config --cflags --libs libjerry-core libjerry-port libjerry-math)
|
||||
```
|
||||
|
||||
If everything is correct the application returns with a zero exit code:
|
||||
@@ -153,23 +120,23 @@ main (void)
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
|
||||
/* Setup Global scope code */
|
||||
jerry_value_t parsed_code = jerry_parse (NULL, 0, script, sizeof (script) - 1, JERRY_PARSE_NO_OPTS);
|
||||
jerry_value_t parsed_code = jerry_parse (script, sizeof (script) - 1, NULL);
|
||||
|
||||
/* Check if there is any JS code parse error */
|
||||
if (!jerry_value_is_error (parsed_code))
|
||||
if (!jerry_value_is_exception (parsed_code))
|
||||
{
|
||||
/* Execute the parsed source code in the Global scope */
|
||||
jerry_value_t ret_value = jerry_run (parsed_code);
|
||||
|
||||
/* Check the execution return value if there is any error */
|
||||
run_ok = !jerry_value_is_error (ret_value);
|
||||
run_ok = !jerry_value_is_exception (ret_value);
|
||||
|
||||
/* Returned value must be freed */
|
||||
jerry_release_value (ret_value);
|
||||
jerry_value_free (ret_value);
|
||||
}
|
||||
|
||||
/* Parsed source code must be freed */
|
||||
jerry_release_value (parsed_code);
|
||||
jerry_value_free (parsed_code);
|
||||
|
||||
/* Cleanup engine */
|
||||
jerry_cleanup ();
|
||||
@@ -181,7 +148,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-math)
|
||||
$ gcc api-example-3.c -o api-example-3 $(pkg-config --cflags --libs libjerry-core libjerry-port libjerry-math)
|
||||
```
|
||||
|
||||
If everything is correct the application returns with a zero exit code:
|
||||
@@ -200,10 +167,10 @@ In this example a very simple "print" method is added which prints out a static
|
||||
This method will be implemented in C and will be called from the JavaScript code.
|
||||
For this a few extra API methods are required:
|
||||
|
||||
- `jerry_get_global_object`
|
||||
- `jerry_create_string`
|
||||
- `jerry_set_property`
|
||||
- `jerry_create_external_function`
|
||||
- `jerry_current_realm`
|
||||
- `jerry_string_sz`
|
||||
- `jerry_object_set`
|
||||
- `jerry_function_external`
|
||||
|
||||
The `api-example-4.c` file should contain the following code:
|
||||
|
||||
@@ -214,8 +181,7 @@ The `api-example-4.c` file should contain the following code:
|
||||
#include "jerryscript.h"
|
||||
|
||||
static jerry_value_t
|
||||
print_handler (const jerry_value_t function_object,
|
||||
const jerry_value_t function_this,
|
||||
print_handler (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t arguments[],
|
||||
const jerry_length_t argument_count)
|
||||
{
|
||||
@@ -224,7 +190,7 @@ print_handler (const jerry_value_t function_object,
|
||||
printf ("Print handler was called\n");
|
||||
|
||||
/* Return an "undefined" value to the JavaScript engine */
|
||||
return jerry_create_undefined ();
|
||||
return jerry_undefined ();
|
||||
}
|
||||
|
||||
int
|
||||
@@ -239,40 +205,40 @@ main (void)
|
||||
/* Add the "print" method for the JavaScript global object */
|
||||
{
|
||||
/* Get the "global" object */
|
||||
jerry_value_t global_object = jerry_get_global_object ();
|
||||
jerry_value_t global_object = jerry_current_realm ();
|
||||
/* Create a "print" JS string */
|
||||
jerry_value_t property_name_print = jerry_create_string ((const jerry_char_t *) "print");
|
||||
jerry_value_t property_name_print = jerry_string_sz ("print");
|
||||
/* Create a function from a native C method (this function will be called from JS) */
|
||||
jerry_value_t property_value_func = jerry_create_external_function (print_handler);
|
||||
jerry_value_t property_value_func = jerry_function_external (print_handler);
|
||||
/* Add the "print" property with the function value to the "global" object */
|
||||
jerry_value_t set_result = jerry_set_property (global_object, property_name_print, property_value_func);
|
||||
jerry_value_t set_result = jerry_object_set (global_object, property_name_print, property_value_func);
|
||||
|
||||
/* Check if there was no error when adding the property (in this case it should never happen) */
|
||||
if (jerry_value_is_error (set_result)) {
|
||||
if (jerry_value_is_exception (set_result)) {
|
||||
printf ("Failed to add the 'print' property\n");
|
||||
}
|
||||
|
||||
/* Release all jerry_value_t-s */
|
||||
jerry_release_value (set_result);
|
||||
jerry_release_value (property_value_func);
|
||||
jerry_release_value (property_name_print);
|
||||
jerry_release_value (global_object);
|
||||
jerry_value_free (set_result);
|
||||
jerry_value_free (property_value_func);
|
||||
jerry_value_free (property_name_print);
|
||||
jerry_value_free (global_object);
|
||||
}
|
||||
|
||||
/* Setup Global scope code */
|
||||
jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS);
|
||||
jerry_value_t parsed_code = jerry_parse (script, script_size, NULL);
|
||||
|
||||
if (!jerry_value_is_error (parsed_code))
|
||||
if (!jerry_value_is_exception (parsed_code))
|
||||
{
|
||||
/* Execute the parsed source code in the Global scope */
|
||||
jerry_value_t ret_value = jerry_run (parsed_code);
|
||||
|
||||
/* Returned value must be freed */
|
||||
jerry_release_value (ret_value);
|
||||
jerry_value_free (ret_value);
|
||||
}
|
||||
|
||||
/* Parsed source code must be freed */
|
||||
jerry_release_value (parsed_code);
|
||||
jerry_value_free (parsed_code);
|
||||
|
||||
/* Cleanup engine */
|
||||
jerry_cleanup ();
|
||||
@@ -285,7 +251,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-math)
|
||||
$ gcc api-example-4.c -o api-example-4 $(pkg-config --cflags --libs libjerry-core libjerry-port libjerry-math)
|
||||
```
|
||||
|
||||
If everything is correct the application should print out the message present in the `print_handler` method:
|
||||
@@ -305,7 +271,7 @@ argument (which probably comes from a JavaScript source) to a JS string and prin
|
||||
New API methods used:
|
||||
|
||||
- `jerry_value_to_string`
|
||||
- `jerry_string_to_utf8_char_buffer`
|
||||
- `jerry_string_to_buffer`
|
||||
|
||||
The `api-example-5.c` file should contain the following code:
|
||||
|
||||
@@ -316,8 +282,7 @@ The `api-example-5.c` file should contain the following code:
|
||||
#include "jerryscript.h"
|
||||
|
||||
static jerry_value_t
|
||||
print_handler (const jerry_value_t function_object,
|
||||
const jerry_value_t function_this,
|
||||
print_handler (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t arguments[],
|
||||
const jerry_length_t arguments_count)
|
||||
{
|
||||
@@ -334,17 +299,17 @@ print_handler (const jerry_value_t function_object,
|
||||
* Please note that if the string does not fit into the buffer nothing will be copied.
|
||||
* More details on the API reference page
|
||||
*/
|
||||
jerry_size_t copied_bytes = jerry_string_to_utf8_char_buffer (string_value, buffer, sizeof (buffer) - 1);
|
||||
jerry_size_t copied_bytes = jerry_string_to_buffer (string_value, JERRY_ENCODING_UTF8, buffer, sizeof (buffer) - 1);
|
||||
buffer[copied_bytes] = '\0';
|
||||
|
||||
/* Release the "toString" result */
|
||||
jerry_release_value (string_value);
|
||||
jerry_value_free (string_value);
|
||||
|
||||
printf ("%s\n", (const char *)buffer);
|
||||
}
|
||||
|
||||
/* Return an "undefined" value to the JavaScript engine */
|
||||
return jerry_create_undefined ();
|
||||
return jerry_undefined ();
|
||||
}
|
||||
|
||||
int
|
||||
@@ -359,40 +324,40 @@ main (void)
|
||||
/* Add the "print" method for the JavaScript global object */
|
||||
{
|
||||
/* Get the "global" object */
|
||||
jerry_value_t global_object = jerry_get_global_object ();
|
||||
jerry_value_t global_object = jerry_current_realm ();
|
||||
/* Create a "print" JS string */
|
||||
jerry_value_t property_name_print = jerry_create_string ((const jerry_char_t *) "print");
|
||||
jerry_value_t property_name_print = jerry_string_sz ("print");
|
||||
/* Create a function from a native C method (this function will be called from JS) */
|
||||
jerry_value_t property_value_func = jerry_create_external_function (print_handler);
|
||||
jerry_value_t property_value_func = jerry_function_external (print_handler);
|
||||
/* Add the "print" property with the function value to the "global" object */
|
||||
jerry_value_t set_result = jerry_set_property (global_object, property_name_print, property_value_func);
|
||||
jerry_value_t set_result = jerry_object_set (global_object, property_name_print, property_value_func);
|
||||
|
||||
/* Check if there was no error when adding the property (in this case it should never happen) */
|
||||
if (jerry_value_is_error (set_result)) {
|
||||
if (jerry_value_is_exception (set_result)) {
|
||||
printf ("Failed to add the 'print' property\n");
|
||||
}
|
||||
|
||||
/* Release all jerry_value_t-s */
|
||||
jerry_release_value (set_result);
|
||||
jerry_release_value (property_value_func);
|
||||
jerry_release_value (property_name_print);
|
||||
jerry_release_value (global_object);
|
||||
jerry_value_free (set_result);
|
||||
jerry_value_free (property_value_func);
|
||||
jerry_value_free (property_name_print);
|
||||
jerry_value_free (global_object);
|
||||
}
|
||||
|
||||
/* Setup Global scope code */
|
||||
jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS);
|
||||
jerry_value_t parsed_code = jerry_parse (script, script_size, NULL);
|
||||
|
||||
if (!jerry_value_is_error (parsed_code))
|
||||
if (!jerry_value_is_exception (parsed_code))
|
||||
{
|
||||
/* Execute the parsed source code in the Global scope */
|
||||
jerry_value_t ret_value = jerry_run (parsed_code);
|
||||
|
||||
/* Returned value must be freed */
|
||||
jerry_release_value (ret_value);
|
||||
jerry_value_free (ret_value);
|
||||
}
|
||||
|
||||
/* Parsed source code must be freed */
|
||||
jerry_release_value (parsed_code);
|
||||
jerry_value_free (parsed_code);
|
||||
|
||||
/* Cleanup engine */
|
||||
jerry_cleanup ();
|
||||
@@ -405,7 +370,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-math)
|
||||
$ gcc api-example-5.c -o api-example-5 $(pkg-config --cflags --libs libjerry-core libjerry-port libjerry-math)
|
||||
```
|
||||
|
||||
If everything is correct the application should print out the string passed for the `print` method in the JS code:
|
||||
@@ -423,14 +388,14 @@ can be used by other applications.
|
||||
|
||||
In this example the following extension methods are used:
|
||||
|
||||
- `jerryx_handler_register_global`
|
||||
- `jerryx_register_global`
|
||||
- `jerryx_handler_print`
|
||||
|
||||
In further examples this "print" handler will be used.
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/handler.h"
|
||||
#include "jerryscript-ext/handlers.h"
|
||||
|
||||
int
|
||||
main (void)
|
||||
@@ -442,23 +407,22 @@ main (void)
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
|
||||
/* Register 'print' function from the extensions to the global object */
|
||||
jerryx_handler_register_global ((const jerry_char_t *) "print",
|
||||
jerryx_handler_print);
|
||||
jerryx_register_global ("print", jerryx_handler_print);
|
||||
|
||||
/* Setup Global scope code */
|
||||
jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS);
|
||||
jerry_value_t parsed_code = jerry_parse (script, script_size, NULL);
|
||||
|
||||
if (!jerry_value_is_error (parsed_code))
|
||||
if (!jerry_value_is_exception (parsed_code))
|
||||
{
|
||||
/* Execute the parsed source code in the Global scope */
|
||||
jerry_value_t ret_value = jerry_run (parsed_code);
|
||||
|
||||
/* Returned value must be freed */
|
||||
jerry_release_value (ret_value);
|
||||
jerry_value_free (ret_value);
|
||||
}
|
||||
|
||||
/* Parsed source code must be freed */
|
||||
jerry_release_value (parsed_code);
|
||||
jerry_value_free (parsed_code);
|
||||
|
||||
/* Cleanup engine */
|
||||
jerry_cleanup ();
|
||||
@@ -470,10 +434,10 @@ main (void)
|
||||
|
||||
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.
|
||||
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port` 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-math)
|
||||
$ gcc api-example-6.c -o api-example-6 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port libjerry-math)
|
||||
```
|
||||
|
||||
If everything is correct the application should print out the string passed for the `print` method in the JS code:
|
||||
@@ -492,8 +456,10 @@ Use the following code as the `api-example-7.c` file:
|
||||
[doctest]: # ()
|
||||
|
||||
```c
|
||||
#include <stdio.h>
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/handler.h"
|
||||
#include "jerryscript-ext/handlers.h"
|
||||
#include "jerryscript-ext/properties.h"
|
||||
|
||||
int
|
||||
main (void)
|
||||
@@ -504,30 +470,29 @@ main (void)
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
|
||||
/* Register 'print' function from the extensions */
|
||||
jerryx_handler_register_global ((const jerry_char_t *) "print",
|
||||
jerryx_handler_print);
|
||||
jerryx_register_global ("print", jerryx_handler_print);
|
||||
|
||||
/* Getting pointer to the Global object */
|
||||
jerry_value_t global_object = jerry_get_global_object ();
|
||||
jerry_value_t global_object = jerry_current_realm ();
|
||||
|
||||
/* Constructing strings */
|
||||
jerry_value_t prop_name = jerry_create_string ((const jerry_char_t *) "my_var");
|
||||
jerry_value_t prop_value = jerry_create_string ((const jerry_char_t *) "Hello from C!");
|
||||
jerry_value_t prop_name = jerry_string_sz ("my_var");
|
||||
jerry_value_t prop_value = jerry_string_sz ("Hello from C!");
|
||||
|
||||
/* Setting the string value as a property of the Global object */
|
||||
jerry_value_t set_result = jerry_set_property (global_object, prop_name, prop_value);
|
||||
jerry_value_t set_result = jerry_object_set (global_object, prop_name, prop_value);
|
||||
/* The 'set_result' should be checked if there was any error */
|
||||
if (jerry_value_is_error (set_result)) {
|
||||
if (jerry_value_is_exception (set_result)) {
|
||||
printf ("Failed to add the 'my_var' property\n");
|
||||
}
|
||||
jerry_release_value (set_result);
|
||||
jerry_value_free (set_result);
|
||||
|
||||
/* Releasing string values, as it is no longer necessary outside of engine */
|
||||
jerry_release_value (prop_name);
|
||||
jerry_release_value (prop_value);
|
||||
jerry_value_free (prop_name);
|
||||
jerry_value_free (prop_value);
|
||||
|
||||
/* Releasing the Global object */
|
||||
jerry_release_value (global_object);
|
||||
jerry_value_free (global_object);
|
||||
|
||||
/* Now starting script that would output value of just initialized field */
|
||||
jerry_value_t eval_ret = jerry_eval (script,
|
||||
@@ -535,7 +500,7 @@ main (void)
|
||||
JERRY_PARSE_NO_OPTS);
|
||||
|
||||
/* Free JavaScript value, returned by eval */
|
||||
jerry_release_value (eval_ret);
|
||||
jerry_value_free (eval_ret);
|
||||
|
||||
/* Freeing engine */
|
||||
jerry_cleanup ();
|
||||
@@ -546,10 +511,10 @@ main (void)
|
||||
|
||||
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.
|
||||
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port` 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-math)
|
||||
$ gcc api-example-7.c -o api-example-7 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port 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:
|
||||
@@ -563,9 +528,9 @@ $ ./api-example-7
|
||||
JerryScript value can be a boolean, number, null, object, string, undefined or some special type of objects (arraybuffer, symbols, etc).
|
||||
|
||||
There is a special "error" value which wraps another value. This "error" can be created by throwing a JavaScript value from JS code
|
||||
or via API method(s). It is advised to check for this error with the `jerry_value_is_error` method as not all API methods
|
||||
can process error values. To extract the value from the "error" the API method `jerry_get_value_from_error` should be used.
|
||||
If an error object is created via API method (for example with `jerry_create_error`) the "error" value is automatically created.
|
||||
or via API method(s). It is advised to check for this error with the `jerry_value_is_exception` method as not all API methods
|
||||
can process error values. To extract the value from the "error" the API method `jerry_exception_value` should be used.
|
||||
If an error object is created via API method (for example with `jerry_error`) the "error" value is automatically created.
|
||||
|
||||
Notice the difference between error value and error object:
|
||||
- The error object is a object which was constructed via one of the `Error` objects (available from the global object or from API).
|
||||
@@ -582,7 +547,7 @@ var error_object = new Error ("error message");
|
||||
throw "message";
|
||||
```
|
||||
|
||||
To check what type a given `jerry_value_t` is the `jerry_value_is_*` methods or the `jerry_value_get_type` could be used.
|
||||
To check what type a given `jerry_value_t` is the `jerry_value_is_*` methods or the `jerry_value_type` could be used.
|
||||
For example the following code snippet could print out a few types (not all types are checked):
|
||||
|
||||
[doctest]: # (test="compile")
|
||||
@@ -597,14 +562,14 @@ print_value (const jerry_value_t jsvalue)
|
||||
{
|
||||
jerry_value_t value;
|
||||
/* If there is an error extract the object from it */
|
||||
if (jerry_value_is_error (jsvalue))
|
||||
if (jerry_value_is_exception (jsvalue))
|
||||
{
|
||||
printf ("Error value detected: ");
|
||||
value = jerry_get_value_from_error (jsvalue, false);
|
||||
value = jerry_exception_value (jsvalue, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = jerry_acquire_value (jsvalue);
|
||||
value = jerry_value_copy (jsvalue);
|
||||
}
|
||||
|
||||
if (jerry_value_is_undefined (value))
|
||||
@@ -617,7 +582,7 @@ print_value (const jerry_value_t jsvalue)
|
||||
}
|
||||
else if (jerry_value_is_boolean (value))
|
||||
{
|
||||
if (jerry_get_boolean_value (value))
|
||||
if (jerry_value_is_true (value))
|
||||
{
|
||||
printf ("true");
|
||||
}
|
||||
@@ -629,7 +594,7 @@ print_value (const jerry_value_t jsvalue)
|
||||
/* Float value */
|
||||
else if (jerry_value_is_number (value))
|
||||
{
|
||||
printf ("number: %lf", jerry_get_number_value (value));
|
||||
printf ("number: %lf", jerry_value_as_number (value));
|
||||
}
|
||||
/* String value */
|
||||
else if (jerry_value_is_string (value))
|
||||
@@ -637,11 +602,11 @@ print_value (const jerry_value_t jsvalue)
|
||||
jerry_char_t str_buf_p[256];
|
||||
|
||||
/* Determining required buffer size */
|
||||
jerry_size_t req_sz = jerry_get_string_size (value);
|
||||
jerry_size_t req_sz = jerry_string_size (value, JERRY_ENCODING_CESU8);
|
||||
|
||||
if (req_sz <= 255)
|
||||
{
|
||||
jerry_string_to_char_buffer (value, str_buf_p, req_sz);
|
||||
jerry_string_to_buffer (value, JERRY_ENCODING_CESU8, str_buf_p, req_sz);
|
||||
str_buf_p[req_sz] = '\0';
|
||||
printf ("%s", (const char *) str_buf_p);
|
||||
}
|
||||
@@ -657,7 +622,7 @@ print_value (const jerry_value_t jsvalue)
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
jerry_release_value (value);
|
||||
jerry_value_free (value);
|
||||
}
|
||||
```
|
||||
|
||||
@@ -684,21 +649,22 @@ See the following `api-example-8-shell.c` file:
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/handler.h"
|
||||
#include "jerryscript-ext/handlers.h"
|
||||
#include "jerryscript-ext/properties.h"
|
||||
|
||||
static void
|
||||
print_value (const jerry_value_t jsvalue)
|
||||
{
|
||||
jerry_value_t value;
|
||||
/* If there is an error extract the object from it */
|
||||
if (jerry_value_is_error (jsvalue))
|
||||
if (jerry_value_is_exception (jsvalue))
|
||||
{
|
||||
printf ("Error value detected: ");
|
||||
value = jerry_get_value_from_error (jsvalue, false);
|
||||
value = jerry_exception_value (jsvalue, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = jerry_acquire_value (jsvalue);
|
||||
value = jerry_value_copy (jsvalue);
|
||||
}
|
||||
|
||||
if (jerry_value_is_undefined (value))
|
||||
@@ -711,7 +677,7 @@ print_value (const jerry_value_t jsvalue)
|
||||
}
|
||||
else if (jerry_value_is_boolean (value))
|
||||
{
|
||||
if (jerry_get_boolean_value (value))
|
||||
if (jerry_value_is_true (value))
|
||||
{
|
||||
printf ("true");
|
||||
}
|
||||
@@ -723,7 +689,7 @@ print_value (const jerry_value_t jsvalue)
|
||||
/* Float value */
|
||||
else if (jerry_value_is_number (value))
|
||||
{
|
||||
printf ("number: %lf", jerry_get_number_value (value));
|
||||
printf ("number: %lf", jerry_value_as_number (value));
|
||||
}
|
||||
/* String value */
|
||||
else if (jerry_value_is_string (value))
|
||||
@@ -731,11 +697,11 @@ print_value (const jerry_value_t jsvalue)
|
||||
jerry_char_t str_buf_p[256];
|
||||
|
||||
/* Determining required buffer size */
|
||||
jerry_size_t req_sz = jerry_get_string_size (value);
|
||||
jerry_size_t req_sz = jerry_string_size (value, JERRY_ENCODING_CESU8);
|
||||
|
||||
if (req_sz <= 255)
|
||||
{
|
||||
jerry_string_to_char_buffer (value, str_buf_p, req_sz);
|
||||
jerry_string_to_buffer (value, JERRY_ENCODING_CESU8, str_buf_p, req_sz);
|
||||
str_buf_p[req_sz] = '\0';
|
||||
printf ("%s", (const char *) str_buf_p);
|
||||
}
|
||||
@@ -751,7 +717,7 @@ print_value (const jerry_value_t jsvalue)
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
jerry_release_value (value);
|
||||
jerry_value_free (value);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -763,8 +729,7 @@ main (void)
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
|
||||
/* Register 'print' function from the extensions */
|
||||
jerryx_handler_register_global ((const jerry_char_t *) "print",
|
||||
jerryx_handler_print);
|
||||
jerryx_register_global ("print", jerryx_handler_print);
|
||||
|
||||
while (!is_done)
|
||||
{
|
||||
@@ -807,7 +772,7 @@ main (void)
|
||||
/* Print out the value */
|
||||
print_value (ret_val);
|
||||
|
||||
jerry_release_value (ret_val);
|
||||
jerry_value_free (ret_val);
|
||||
}
|
||||
|
||||
/* Cleanup engine */
|
||||
@@ -819,10 +784,10 @@ main (void)
|
||||
|
||||
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.
|
||||
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port` 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-math)
|
||||
$ gcc api-example-8-shell.c -o api-example-8-shell $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port libjerry-math)
|
||||
```
|
||||
|
||||
The application reads lines from standard input and evaluates them, one after another. To try out run:
|
||||
@@ -840,7 +805,8 @@ In this example (`api-example-9.c`) an object with a native function is added to
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/handler.h"
|
||||
#include "jerryscript-ext/handlers.h"
|
||||
#include "jerryscript-ext/properties.h"
|
||||
|
||||
struct my_struct
|
||||
{
|
||||
@@ -851,12 +817,11 @@ struct my_struct
|
||||
* Get a string from a native object
|
||||
*/
|
||||
static jerry_value_t
|
||||
get_msg_handler (const jerry_value_t func_value, /**< function object */
|
||||
const jerry_value_t this_value, /**< this arg */
|
||||
get_msg_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t *args_p, /**< function arguments */
|
||||
const jerry_length_t args_cnt) /**< number of function arguments */
|
||||
{
|
||||
return jerry_create_string ((const jerry_char_t *) my_struct.msg);
|
||||
return jerry_string_sz (my_struct.msg);
|
||||
} /* get_msg_handler */
|
||||
|
||||
int
|
||||
@@ -866,33 +831,32 @@ main (void)
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
|
||||
/* Register 'print' function from the extensions */
|
||||
jerryx_handler_register_global ((const jerry_char_t *) "print",
|
||||
jerryx_handler_print);
|
||||
jerryx_register_global ("print", jerryx_handler_print);
|
||||
|
||||
/* Do something with the native object */
|
||||
my_struct.msg = "Hello, World!";
|
||||
|
||||
/* Create an empty JS object */
|
||||
jerry_value_t object = jerry_create_object ();
|
||||
jerry_value_t object = jerry_object ();
|
||||
|
||||
/* Create a JS function object and wrap into a jerry value */
|
||||
jerry_value_t func_obj = jerry_create_external_function (get_msg_handler);
|
||||
jerry_value_t func_obj = jerry_function_external (get_msg_handler);
|
||||
|
||||
/* Set the native function as a property of the empty JS object */
|
||||
jerry_value_t prop_name = jerry_create_string ((const jerry_char_t *) "myFunc");
|
||||
jerry_release_value (jerry_set_property (object, prop_name, func_obj));
|
||||
jerry_release_value (prop_name);
|
||||
jerry_release_value (func_obj);
|
||||
jerry_value_t prop_name = jerry_string_sz ("myFunc");
|
||||
jerry_value_free (jerry_object_set (object, prop_name, func_obj));
|
||||
jerry_value_free (prop_name);
|
||||
jerry_value_free (func_obj);
|
||||
|
||||
/* Wrap the JS object (not empty anymore) into a jerry api value */
|
||||
jerry_value_t global_object = jerry_get_global_object ();
|
||||
jerry_value_t global_object = jerry_current_realm ();
|
||||
|
||||
/* Add the JS object to the global context */
|
||||
prop_name = jerry_create_string ((const jerry_char_t *) "MyObject");
|
||||
jerry_release_value (jerry_set_property (global_object, prop_name, object));
|
||||
jerry_release_value (prop_name);
|
||||
jerry_release_value (object);
|
||||
jerry_release_value (global_object);
|
||||
prop_name = jerry_string_sz ("MyObject");
|
||||
jerry_value_free (jerry_object_set (global_object, prop_name, object));
|
||||
jerry_value_free (prop_name);
|
||||
jerry_value_free (object);
|
||||
jerry_value_free (global_object);
|
||||
|
||||
/* Now we have a "builtin" object called MyObject with a function called myFunc()
|
||||
*
|
||||
@@ -908,7 +872,7 @@ main (void)
|
||||
jerry_value_t eval_ret = jerry_eval (script, sizeof (script) - 1, JERRY_PARSE_NO_OPTS);
|
||||
|
||||
/* Free JavaScript value, returned by eval */
|
||||
jerry_release_value (eval_ret);
|
||||
jerry_value_free (eval_ret);
|
||||
|
||||
/* Cleanup engine */
|
||||
jerry_cleanup ();
|
||||
@@ -919,10 +883,10 @@ main (void)
|
||||
|
||||
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.
|
||||
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port` 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-math)
|
||||
$ gcc api-example-9.c -o api-example-9 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port libjerry-math)
|
||||
```
|
||||
|
||||
Execute the example with:
|
||||
@@ -949,14 +913,14 @@ Use the following code for `api-example-10.c`:
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/handler.h"
|
||||
#include "jerryscript-ext/handlers.h"
|
||||
#include "jerryscript-ext/properties.h"
|
||||
|
||||
/**
|
||||
* Add param to 'this.x'
|
||||
*/
|
||||
static jerry_value_t
|
||||
add_handler (const jerry_value_t func_value, /**< function object */
|
||||
const jerry_value_t this_val, /**< this arg */
|
||||
add_handler (const jerry_call_info_t *call_info_p, /**< call information */
|
||||
const jerry_value_t args_p[], /**< function arguments */
|
||||
const jerry_length_t args_cnt) /**< number of function arguments */
|
||||
{
|
||||
@@ -964,27 +928,27 @@ add_handler (const jerry_value_t func_value, /**< function object */
|
||||
/* Note: that the argument count check is ignored for the example's case */
|
||||
|
||||
/* Get 'this.x' */
|
||||
jerry_value_t prop_name = jerry_create_string ((const jerry_char_t *) "x");
|
||||
jerry_value_t x_val = jerry_get_property (this_val, prop_name);
|
||||
jerry_value_t prop_name = jerry_string_sz ("x");
|
||||
jerry_value_t x_val = jerry_object_get (call_info_p->this_value, prop_name);
|
||||
|
||||
if (!jerry_value_is_error (x_val))
|
||||
if (!jerry_value_is_exception (x_val))
|
||||
{
|
||||
/* Convert Jerry API values to double */
|
||||
double x = jerry_get_number_value (x_val);
|
||||
double d = jerry_get_number_value (args_p[0]);
|
||||
double x = jerry_value_as_number (x_val);
|
||||
double d = jerry_value_as_number (args_p[0]);
|
||||
|
||||
/* Add the parameter to 'x' */
|
||||
jerry_value_t res_val = jerry_create_number (x + d);
|
||||
jerry_value_t res_val = jerry_number (x + d);
|
||||
|
||||
/* Set the new value of 'this.x' */
|
||||
jerry_release_value (jerry_set_property (this_val, prop_name, res_val));
|
||||
jerry_release_value (res_val);
|
||||
jerry_value_free (jerry_object_set (call_info_p->this_value, prop_name, res_val));
|
||||
jerry_value_free (res_val);
|
||||
}
|
||||
|
||||
jerry_release_value (x_val);
|
||||
jerry_release_value (prop_name);
|
||||
jerry_value_free (x_val);
|
||||
jerry_value_free (prop_name);
|
||||
|
||||
return jerry_create_undefined ();
|
||||
return jerry_undefined ();
|
||||
} /* add_handler */
|
||||
|
||||
int
|
||||
@@ -994,8 +958,7 @@ main (void)
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
|
||||
/* Register 'print' function from the extensions */
|
||||
jerryx_handler_register_global ((const jerry_char_t *) "print",
|
||||
jerryx_handler_print);
|
||||
jerryx_register_global ("print", jerryx_handler_print);
|
||||
|
||||
/* Create a JS object */
|
||||
const jerry_char_t my_js_object[] = " \
|
||||
@@ -1017,16 +980,16 @@ main (void)
|
||||
JERRY_PARSE_NO_OPTS);
|
||||
|
||||
/* Create a JS function object and wrap into a jerry value */
|
||||
jerry_value_t add_func_obj = jerry_create_external_function (add_handler);
|
||||
jerry_value_t add_func_obj = jerry_function_external (add_handler);
|
||||
|
||||
/* Set the native function as a property of previously created MyObject */
|
||||
jerry_value_t prop_name = jerry_create_string ((const jerry_char_t *) "add2x");
|
||||
jerry_release_value (jerry_set_property (my_js_obj_val, prop_name, add_func_obj));
|
||||
jerry_release_value (add_func_obj);
|
||||
jerry_release_value (prop_name);
|
||||
jerry_value_t prop_name = jerry_string_sz ("add2x");
|
||||
jerry_value_free (jerry_object_set (my_js_obj_val, prop_name, add_func_obj));
|
||||
jerry_value_free (add_func_obj);
|
||||
jerry_value_free (prop_name);
|
||||
|
||||
/* Free JavaScript value, returned by eval (my_js_object) */
|
||||
jerry_release_value (my_js_obj_val);
|
||||
jerry_value_free (my_js_obj_val);
|
||||
|
||||
const jerry_char_t script[] = " \
|
||||
var str = MyObject.foo (); \
|
||||
@@ -1039,7 +1002,7 @@ main (void)
|
||||
jerry_value_t eval_ret = jerry_eval (script, sizeof (script) - 1, JERRY_PARSE_NO_OPTS);
|
||||
|
||||
/* Free JavaScript value, returned by eval */
|
||||
jerry_release_value (eval_ret);
|
||||
jerry_value_free (eval_ret);
|
||||
|
||||
/* Cleanup engine */
|
||||
jerry_cleanup ();
|
||||
@@ -1050,10 +1013,10 @@ main (void)
|
||||
|
||||
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.
|
||||
(**Note** that the `libjerry-ext` was added **before** the `libjerry-port` 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-math)
|
||||
$ gcc api-example-10.c -o api-example-10 $(pkg-config --cflags --libs libjerry-core libjerry-ext libjerry-port libjerry-math)
|
||||
```
|
||||
|
||||
Execute the example with:
|
||||
@@ -1070,7 +1033,7 @@ Value of x is 17
|
||||
## Example 11. Changing the seed of pseudorandom generated numbers
|
||||
|
||||
If you want to change the seed of `Math.random()` generated numbers, you have to initialize the seed value with `srand`.
|
||||
A recommended method is using `jerry_port_get_current_time()` or something based on a constantly changing value, therefore every run produces truly random numbers.
|
||||
A recommended method is using `jerry_port_current_time()` or something based on a constantly changing value, therefore every run produces truly random numbers.
|
||||
|
||||
[doctest]: # ()
|
||||
|
||||
@@ -1078,13 +1041,14 @@ A recommended method is using `jerry_port_get_current_time()` or something based
|
||||
#include <stdlib.h>
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-port.h"
|
||||
#include "jerryscript-ext/handler.h"
|
||||
#include "jerryscript-ext/handlers.h"
|
||||
#include "jerryscript-ext/properties.h"
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
/* Initialize srand value */
|
||||
union { double d; unsigned u; } now = { .d = jerry_port_get_current_time () };
|
||||
union { double d; unsigned u; } now = { .d = jerry_port_current_time () };
|
||||
srand (now.u);
|
||||
|
||||
/* Generate a random number, and print it */
|
||||
@@ -1094,14 +1058,13 @@ main (void)
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
|
||||
/* Register the print function */
|
||||
jerryx_handler_register_global ((const jerry_char_t *) "print",
|
||||
jerryx_handler_print);
|
||||
jerryx_register_global ("print", jerryx_handler_print);
|
||||
|
||||
/* Evaluate the script */
|
||||
jerry_value_t eval_ret = jerry_eval (script, sizeof (script) - 1, JERRY_PARSE_NO_OPTS);
|
||||
|
||||
/* Free the JavaScript value returned by eval */
|
||||
jerry_release_value (eval_ret);
|
||||
jerry_value_free (eval_ret);
|
||||
|
||||
/* Cleanup the engine */
|
||||
jerry_cleanup ();
|
||||
|
||||
@@ -78,7 +78,7 @@ Argument combinations are limited to the following seven forms:
|
||||
## Literals
|
||||
|
||||
Literals are organized into groups whose represent various literal types. Having these groups consuming less space than assigning flag bits to each literal.
|
||||
(In the followings, the mentioned ranges represent those indicies which are greater than or equal to the left side and less than the right side of the range. For example a range between `ident_end` and `literal_end` fields of the byte-code header contains those indicies, which are greater than or equal to `ident_end`
|
||||
(In the followings, the mentioned ranges represent those indices which are greater than or equal to the left side and less than the right side of the range. For example a range between `ident_end` and `literal_end` fields of the byte-code header contains those indices, which are greater than or equal to `ident_end`
|
||||
and less than `literal_end`. If `ident_end` equals to `literal_end` the range is empty.)
|
||||
|
||||
The two major group of literals are _identifiers_ and _values_.
|
||||
@@ -271,7 +271,7 @@ An object can be a conventional data object or a lexical environment object. Unl
|
||||
|
||||
[Lexical environments](http://www.ecma-international.org/ecma-262/5.1/#sec-10.2) are implemented as objects in JerryScript, since lexical environments contains key-value pairs (called bindings) like objects. This simplifies the implementation and reduces code size.
|
||||
|
||||

|
||||

|
||||
|
||||
The objects are represented as following structure:
|
||||
|
||||
|
||||
+205
-376
@@ -1,9 +1,16 @@
|
||||
# Reference
|
||||
|
||||
## Termination
|
||||
## Process management
|
||||
|
||||
It is questionable whether a library should be able to terminate an application. Any API function can signal an error (ex.: cannot allocate memory), so the engine use the termination approach with this port function.
|
||||
|
||||
```c
|
||||
/**
|
||||
* Init the program
|
||||
*/
|
||||
void jerry_port_init (void);
|
||||
```
|
||||
|
||||
```c
|
||||
/**
|
||||
* Signal the port that jerry experienced a fatal failure from which it cannot
|
||||
@@ -24,232 +31,14 @@ Error codes
|
||||
```c
|
||||
typedef enum
|
||||
{
|
||||
ERR_OUT_OF_MEMORY = 10,
|
||||
ERR_REF_COUNT_LIMIT = 12,
|
||||
ERR_DISABLED_BYTE_CODE = 13,
|
||||
ERR_FAILED_INTERNAL_ASSERTION = 120
|
||||
JERRY_FATAL_OUT_OF_MEMORY = 10,
|
||||
JERRY_FATAL_REF_COUNT_LIMIT = 12,
|
||||
JERRY_FATAL_DISABLED_BYTE_CODE = 13,
|
||||
JERRY_FATAL_UNTERMINATED_GC_LOOPS = 14,
|
||||
JERRY_FATAL_FAILED_ASSERTION = 120
|
||||
} jerry_fatal_code_t;
|
||||
```
|
||||
|
||||
## I/O
|
||||
|
||||
These are the only I/O functions jerry calls.
|
||||
|
||||
```c
|
||||
/**
|
||||
* Jerry log levels. The levels are in severity order
|
||||
* where the most serious levels come first.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
JERRY_LOG_LEVEL_ERROR, /**< the engine will terminate after the message is printed */
|
||||
JERRY_LOG_LEVEL_WARNING, /**< a request is aborted, but the engine continues its operation */
|
||||
JERRY_LOG_LEVEL_DEBUG, /**< debug messages from the engine, low volume */
|
||||
JERRY_LOG_LEVEL_TRACE /**< detailed info about engine internals, potentially high volume */
|
||||
} jerry_log_level_t;
|
||||
|
||||
/**
|
||||
* Display or log a debug/error message, and sends it to the debugger client as well.
|
||||
* The function should implement a printf-like interface, where the first argument
|
||||
* specifies the log level and the second argument specifies a format string on how
|
||||
* to stringify the rest of the parameter list.
|
||||
*
|
||||
* This function is only called with messages coming from the jerry engine as
|
||||
* the result of some abnormal operation or describing its internal operations
|
||||
* (e.g., data structure dumps or tracing info).
|
||||
*
|
||||
* It should be the port that decides whether error and debug messages are logged to
|
||||
* the console, or saved to a database or to a file.
|
||||
*
|
||||
* Example: a libc-based port may implement this with vfprintf(stderr) or
|
||||
* vfprintf(logfile), or both, depending on log level.
|
||||
*
|
||||
* Note:
|
||||
* This port function is called by jerry-core when JERRY_LOGGING is
|
||||
* enabled. It is also common practice though to use this function in
|
||||
* application code.
|
||||
*/
|
||||
void jerry_port_log (jerry_log_level_t level, const char *fmt, ...);
|
||||
```
|
||||
|
||||
The `jerry_port_print_char` is currenlty not used by the jerry-core directly.
|
||||
However, it provides a port specifc way for `jerry-ext` components to print
|
||||
information.
|
||||
|
||||
```c
|
||||
/**
|
||||
* Print a character to stdout.
|
||||
*/
|
||||
void jerry_port_print_char (char c);
|
||||
```
|
||||
|
||||
### 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.
|
||||
The `jerry_port_get_native_module` port function can be used to provide native
|
||||
modules to the engine. This function will be called when an import/export
|
||||
statement is encountered with an unknown module specifier, which embedders can
|
||||
use to supply native module objects based on the module name argument.
|
||||
|
||||
```c
|
||||
/**
|
||||
* Opens file with the given path and reads its source.
|
||||
* @return the source of the file
|
||||
*/
|
||||
uint8_t *
|
||||
jerry_port_read_source (const char *file_name_p, /**< file name */
|
||||
size_t *out_size_p) /**< [out] read bytes */
|
||||
{
|
||||
// open file from given path
|
||||
// return its source
|
||||
} /* jerry_port_read_source */
|
||||
|
||||
/**
|
||||
* Release the previously opened file's content.
|
||||
*/
|
||||
void
|
||||
jerry_port_release_source (uint8_t *buffer_p) /**< buffer to free */
|
||||
{
|
||||
free (buffer_p);
|
||||
} /* jerry_port_release_source */
|
||||
|
||||
/**
|
||||
* Normalize a file path
|
||||
*
|
||||
* @return length of the path written to the output buffer
|
||||
*/
|
||||
size_t
|
||||
jerry_port_normalize_path (const char *in_path_p, /**< input file path */
|
||||
char *out_buf_p, /**< output buffer */
|
||||
size_t out_buf_size, /**< size of output buffer */
|
||||
char *base_file_p) /**< base file path */
|
||||
{
|
||||
// normalize in_path_p by expanding relative paths etc.
|
||||
// if base_file_p is not NULL, in_path_p is relative to that file
|
||||
// write to out_buf_p the normalized path
|
||||
// return length of written path
|
||||
} /* jerry_port_normalize_path */
|
||||
|
||||
/**
|
||||
* Get the module object of a native module.
|
||||
*
|
||||
* Note:
|
||||
* This port function is called by jerry-core when JERRY_MODULE_SYSTEM
|
||||
* is enabled.
|
||||
*
|
||||
* @param name String value of the module specifier.
|
||||
*
|
||||
* @return Undefined, if 'name' is not a native module
|
||||
* jerry_value_t containing the module object, otherwise
|
||||
*/
|
||||
jerry_value_t
|
||||
jerry_port_get_native_module (jerry_value_t name) /**< module specifier */
|
||||
{
|
||||
(void) name;
|
||||
return jerry_create_undefined ();
|
||||
}
|
||||
```
|
||||
|
||||
## 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
|
||||
/**
|
||||
* Get local time zone adjustment, in milliseconds, for the given timestamp.
|
||||
* The timestamp can be specified in either UTC or local time, depending on
|
||||
* the value of is_utc. Adding the value returned from this function to
|
||||
* a timestamp in UTC time should result in local time for the current time
|
||||
* zone, and subtracting it from a timestamp in local time should result in
|
||||
* UTC time.
|
||||
*
|
||||
* Ideally, this function should satisfy the stipulations applied to LocalTZA
|
||||
* in section 20.3.1.7 of the ECMAScript version 9.0 spec.
|
||||
*
|
||||
* See Also:
|
||||
* ECMA-262 v9, 20.3.1.7
|
||||
*
|
||||
* Note:
|
||||
* This port function is called by jerry-core when
|
||||
* JERRY_BUILTIN_DATE is set to 1. Otherwise this function is
|
||||
* not used.
|
||||
*
|
||||
* @param unix_ms The unix timestamp we want an offset for, given in
|
||||
* millisecond precision (could be now, in the future,
|
||||
* or in the past). As with all unix timestamps, 0 refers to
|
||||
* 1970-01-01, a day is exactly 86 400 000 milliseconds, and
|
||||
* leap seconds cause the same second to occur twice.
|
||||
* @param is_utc Is the given timestamp in UTC time? If false, it is in local
|
||||
* time.
|
||||
*
|
||||
* @return milliseconds between local time and UTC for the given timestamp,
|
||||
* if available
|
||||
*. 0 if not available / we are in UTC.
|
||||
*/
|
||||
double jerry_port_get_local_time_zone_adjustment (double unix_ms, bool is_utc);
|
||||
|
||||
/**
|
||||
* Get system time
|
||||
*
|
||||
* Note:
|
||||
* This port function is called by jerry-core when
|
||||
* JERRY_BUILTIN_DATE is set to 1. It is also common practice
|
||||
* in application code to use this function for the initialization of the
|
||||
* random number generator.
|
||||
*
|
||||
* @return milliseconds since Unix epoch
|
||||
*/
|
||||
double jerry_port_get_current_time (void);
|
||||
```
|
||||
|
||||
## External context
|
||||
|
||||
Allow user to provide external buffer for isolated engine contexts, so that user
|
||||
can configure the heap size at runtime and run multiple JS applications
|
||||
simultaneously.
|
||||
|
||||
```c
|
||||
/**
|
||||
* Get the current context of the engine. Each port should provide its own
|
||||
* implementation of this interface.
|
||||
*
|
||||
* Note:
|
||||
* This port function is called by jerry-core when
|
||||
* JERRY_EXTERNAL_CONTEXT is enabled. Otherwise this function is not
|
||||
* used.
|
||||
*
|
||||
* @return the pointer to the engine context.
|
||||
*/
|
||||
struct jerry_context_t *jerry_port_get_current_context (void);
|
||||
```
|
||||
|
||||
## Sleep
|
||||
|
||||
```c
|
||||
/**
|
||||
* Makes the process sleep for a given time.
|
||||
@@ -263,187 +52,227 @@ struct jerry_context_t *jerry_port_get_current_context (void);
|
||||
void jerry_port_sleep (uint32_t sleep_time);
|
||||
```
|
||||
|
||||
# How to port JerryScript
|
||||
## External context
|
||||
|
||||
This section describes a basic port implementation which was created for Unix based systems.
|
||||
|
||||
## Termination
|
||||
Allows the user to provide external buffer for isolated engine contexts, so that user
|
||||
can configure the heap size at runtime and run multiple JS applications
|
||||
simultaneously.
|
||||
|
||||
```c
|
||||
#include <stdlib.h>
|
||||
#include "jerryscript-port.h"
|
||||
|
||||
/**
|
||||
* Default implementation of jerry_port_fatal.
|
||||
* Allocate a new context for the engine.
|
||||
*
|
||||
* This port function is called by jerry_init when JERRY_EXTERNAL_CONTEXT is enabled. Otherwise this function is not
|
||||
* used. The engine will pass the size required for the context structure. An implementation must make sure to
|
||||
* allocate at least this amount.
|
||||
*
|
||||
* Excess allocated space will be used as the engine heap when jerryscript is configured to use it's internal allocator,
|
||||
* this can be used to control the internal heap size.
|
||||
*
|
||||
* NOTE: The allocated memory must be pointer-aligned, otherwise the behavior is
|
||||
* undefined.
|
||||
*
|
||||
* @param context_size: the size of the internal context structure
|
||||
*
|
||||
* @return total size of the allocated buffer
|
||||
*/
|
||||
void jerry_port_fatal (jerry_fatal_code_t code)
|
||||
{
|
||||
exit (code);
|
||||
} /* jerry_port_fatal */
|
||||
size_t jerry_port_context_alloc (size_t context_size);
|
||||
```
|
||||
|
||||
```c
|
||||
/**
|
||||
* Get the currently active context of the engine.
|
||||
*
|
||||
* This port function is called by jerry-core when JERRY_EXTERNAL_CONTEXT is enabled.
|
||||
* Otherwise this function is not used.
|
||||
*
|
||||
* @return the pointer to the currently used engine context.
|
||||
*/
|
||||
struct jerry_context_t *jerry_port_context_get (void);
|
||||
```
|
||||
|
||||
```c
|
||||
/**
|
||||
* Free the currently used context.
|
||||
*
|
||||
* This port function is called by jerry_cleanup when JERRY_EXTERNAL_CONTEXT is enabled.
|
||||
* Otherwise this function is not used.
|
||||
*
|
||||
* @return the pointer to the engine context.
|
||||
*/
|
||||
void jerry_port_context_free (void);
|
||||
```
|
||||
|
||||
## I/O
|
||||
|
||||
```c
|
||||
#include <stdarg.h>
|
||||
#include "jerryscript-port.h"
|
||||
|
||||
/**
|
||||
* Provide log message implementation for the engine.
|
||||
* Display or log a debug/error message.
|
||||
*
|
||||
* Note:
|
||||
* This example ignores the log level.
|
||||
* The message is passed as a zero-terminated string. Messages may be logged in parts, which
|
||||
* will result in multiple calls to this functions. The implementation should consider
|
||||
* this before appending or prepending strings to the argument.
|
||||
*
|
||||
* This function is called with messages coming from the jerry engine as
|
||||
* the result of some abnormal operation or describing its internal operations
|
||||
* (e.g., data structure dumps or tracing info).
|
||||
*
|
||||
* The implementation can decide whether error and debug messages are logged to
|
||||
* the console, or saved to a database or to a file.
|
||||
*
|
||||
* @param message_p: the message to log.
|
||||
*/
|
||||
void
|
||||
jerry_port_log (jerry_log_level_t level, /**< log level */
|
||||
const char *format, /**< format string */
|
||||
...) /**< parameters */
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, format);
|
||||
vfprintf (stderr, format, args);
|
||||
va_end (args);
|
||||
} /* jerry_port_log */
|
||||
void jerry_port_log (const char *message_p);
|
||||
```
|
||||
|
||||
```c
|
||||
/**
|
||||
* Print a character to stdout with putchar.
|
||||
* Print a buffer to standard output
|
||||
*
|
||||
* This port function is never called from jerry-core directly, it is only used by jerry-ext components to print
|
||||
* information.
|
||||
*
|
||||
* @param buffer_p: input buffer
|
||||
* @param buffer_size: data size
|
||||
*/
|
||||
void
|
||||
jerry_port_print_char (char c)
|
||||
{
|
||||
putchar (c);
|
||||
} /* jerr_port_print_char */
|
||||
void jerry_port_print_buffer (const jerry_char_t *buffer_p, jerry_size_t buffer_size);
|
||||
```
|
||||
|
||||
```c
|
||||
/**
|
||||
* Read a line from standard input.
|
||||
*
|
||||
* The implementation should allocate storage necessary for the string. The result string should include the ending line
|
||||
* terminator character(s) and should be zero terminated.
|
||||
*
|
||||
* An implementation may return NULL to signal that the end of input is reached, or an error occured.
|
||||
*
|
||||
* When a non-NULL value is returned, the caller will pass the returned value to `jerry_port_line_free` when the line is
|
||||
* no longer needed. This can be used to finalize dynamically allocated buffers if necessary.
|
||||
*
|
||||
* This port function is never called from jerry-core directly, it is only used by some jerry-ext components that
|
||||
* require user input.
|
||||
*
|
||||
* @param out_size_p: size of the input string in bytes, excluding terminating zero byte
|
||||
*
|
||||
* @return pointer to the buffer storing the string,
|
||||
* or NULL if end of input
|
||||
*/
|
||||
jerry_char_t *jerry_port_line_read (jerry_size_t *out_size_p);
|
||||
```
|
||||
|
||||
```c
|
||||
/**
|
||||
* Free a line buffer allocated by jerry_port_line_read
|
||||
*
|
||||
* @param buffer_p: buffer returned by jerry_port_line_read
|
||||
*/
|
||||
void jerry_port_line_free (jerry_char_t *buffer_p);
|
||||
```
|
||||
|
||||
## Filesystem
|
||||
|
||||
```
|
||||
/**
|
||||
* Canonicalize a file path.
|
||||
*
|
||||
* If possible, the implementation should resolve symbolic links and other directory references found in the input path,
|
||||
* and create a fully canonicalized file path as the result.
|
||||
*
|
||||
* The function may return with NULL in case an error is encountered, in which case the calling operation will not
|
||||
* proceed.
|
||||
*
|
||||
* The implementation should allocate storage for the result path as necessary. Non-NULL return values will be passed
|
||||
* to `jerry_port_path_free` when the result is no longer needed by the caller, which can be used to finalize
|
||||
* dynamically allocated buffers.
|
||||
*
|
||||
* NOTE: The implementation must not return directly with the input, as the input buffer is released after the call.
|
||||
*
|
||||
* @param path_p: zero-terminated string containing the input path
|
||||
* @param path_size: size of the input path string in bytes, excluding terminating zero
|
||||
*
|
||||
* @return buffer with the normalized path if the operation is successful,
|
||||
* NULL otherwise
|
||||
*/
|
||||
jerry_char_t *jerry_port_path_normalize (const jerry_char_t *path_p, jerry_size_t path_size);
|
||||
```
|
||||
|
||||
```c
|
||||
/**
|
||||
* Free a path buffer returned by jerry_port_path_normalize.
|
||||
*
|
||||
* @param path_p: the path buffer to free
|
||||
*/
|
||||
void jerry_port_path_free (jerry_char_t *path_p);
|
||||
```
|
||||
|
||||
```c
|
||||
/**
|
||||
* Get the offset of the basename component in the input path.
|
||||
*
|
||||
* The implementation should return the offset of the first character after the last path separator found in the path.
|
||||
* This is used by the caller to split the path into a directory name and a file name.
|
||||
*
|
||||
* @param path_p: input zero-terminated path string
|
||||
*
|
||||
* @return offset of the basename component in the input path
|
||||
*/
|
||||
jerry_size_t jerry_port_path_base (const jerry_char_t *path_p);
|
||||
```
|
||||
|
||||
```c
|
||||
/**
|
||||
* Open a source file and read its contents into a buffer.
|
||||
*
|
||||
* When the source file is no longer needed by the caller, the returned pointer will be passed to
|
||||
* `jerry_port_source_free`, which can be used to finalize the buffer.
|
||||
*
|
||||
* @param file_name_p: Path that points to the source file in the filesystem.
|
||||
* @param out_size_p: The opened file's size in bytes.
|
||||
*
|
||||
* @return pointer to the buffer which contains the content of the file.
|
||||
*/
|
||||
jerry_char_t *jerry_port_source_read (const char *file_name_p, jerry_size_t *out_size_p);
|
||||
```
|
||||
|
||||
```c
|
||||
/**
|
||||
* Free a source file buffer.
|
||||
*
|
||||
* @param buffer_p: buffer returned by jerry_port_source_read
|
||||
*/
|
||||
void jerry_port_source_free (jerry_char_t *buffer_p);
|
||||
```
|
||||
|
||||
## Date
|
||||
|
||||
```c
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include "jerryscript-port.h"
|
||||
|
||||
/**
|
||||
* Default implementation of jerry_port_get_local_time_zone_adjustment.
|
||||
*/
|
||||
double jerry_port_get_local_time_zone_adjustment (double unix_ms, /**< ms since unix epoch */
|
||||
bool is_utc) /**< is the time above in UTC? */
|
||||
{
|
||||
struct tm tm;
|
||||
time_t now = (time_t) (unix_ms / 1000);
|
||||
localtime_r (&now, &tm);
|
||||
if (!is_utc)
|
||||
{
|
||||
now -= tm.tm_gmtoff;
|
||||
localtime_r (&now, &tm);
|
||||
}
|
||||
return ((double) tm.tm_gmtoff) * 1000;
|
||||
} /* jerry_port_get_local_time_zone_adjustment */
|
||||
|
||||
/**
|
||||
* Default implementation of jerry_port_get_current_time.
|
||||
*/
|
||||
double jerry_port_get_current_time (void)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
if (gettimeofday (&tv, NULL) != 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ((double) tv.tv_sec) * 1000.0 + ((double) tv.tv_usec) / 1000.0;
|
||||
} /* jerry_port_get_current_time */
|
||||
```
|
||||
|
||||
## External context
|
||||
|
||||
```c
|
||||
#include "jerryscript-port.h"
|
||||
#include "jerryscript-port-default.h"
|
||||
|
||||
/**
|
||||
* Pointer to the current context.
|
||||
* Note that it is a global variable, and is not a thread safe implementation.
|
||||
*/
|
||||
static jerry_context_t *current_context_p = NULL;
|
||||
|
||||
/**
|
||||
* Set the current_context_p as the passed pointer.
|
||||
*/
|
||||
void
|
||||
jerry_port_default_set_current_context (jerry_context_t *context_p) /**< points to the created context */
|
||||
{
|
||||
current_context_p = context_p;
|
||||
} /* jerry_port_default_set_current_context */
|
||||
|
||||
/**
|
||||
* Get the current context.
|
||||
* Get local time zone adjustment in milliseconds for the given input time.
|
||||
*
|
||||
* @return the pointer to the current context
|
||||
* The argument is a time value representing milliseconds since unix epoch.
|
||||
*
|
||||
* Ideally, this function should satisfy the stipulations applied to LocalTZA
|
||||
* in section 21.4.1.7 of the ECMAScript version 12.0, as if called with isUTC true.
|
||||
*
|
||||
* This port function can be called by jerry-core when JERRY_BUILTIN_DATE is enabled.
|
||||
* Otherwise this function is not used.
|
||||
*
|
||||
* @param unix_ms: time value in milliseconds since unix epoch
|
||||
*
|
||||
* @return local time offset in milliseconds applied to UTC for the given time value
|
||||
*/
|
||||
jerry_context_t *
|
||||
jerry_port_get_current_context (void)
|
||||
{
|
||||
return current_context_p;
|
||||
} /* jerry_port_get_current_context */
|
||||
int32_t jerry_port_local_tza (double unix_ms);
|
||||
```
|
||||
|
||||
## Sleep
|
||||
|
||||
```c
|
||||
#include "jerryscript-port.h"
|
||||
#include "jerryscript-port-default.h"
|
||||
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#elif defined (HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif /* HAVE_TIME_H */
|
||||
|
||||
#if defined (JERRY_DEBUGGER) && (JERRY_DEBUGGER == 1)
|
||||
void jerry_port_sleep (uint32_t sleep_time)
|
||||
{
|
||||
#ifdef HAVE_TIME_H
|
||||
nanosleep (&(const struct timespec)
|
||||
{
|
||||
(time_t) sleep_time / 1000, ((long int) sleep_time % 1000) * 1000000L /* Seconds, nanoseconds */
|
||||
}
|
||||
, NULL);
|
||||
#elif defined (HAVE_UNISTD_H)
|
||||
usleep ((useconds_t) sleep_time * 1000);
|
||||
#endif /* HAVE_TIME_H */
|
||||
(void) 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.
|
||||
* Get the current system time in UTC.
|
||||
*
|
||||
* This port function is called by jerry-core when JERRY_BUILTIN_DATE is enabled.
|
||||
* It can also be used in the implementing application to initialize the random number generator.
|
||||
*
|
||||
* @return milliseconds since Unix epoch
|
||||
*/
|
||||
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 */
|
||||
double jerry_port_current_time (void);
|
||||
```
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
In JerryScript all `jerry_value_t` values are independent
|
||||
references to internal objects. Values returned by JerryScript
|
||||
API functions are always live references and must be released
|
||||
by `jerry_release_value`.
|
||||
by `jerry_value_free`.
|
||||
|
||||
```c
|
||||
jerry_value_t global = jerry_get_global_object ();
|
||||
jerry_value_t global = jerry_current_realm ();
|
||||
|
||||
/* The value stored in the 'global' variable contains a live
|
||||
* reference to the global object. The system also keeps its
|
||||
@@ -14,9 +14,9 @@ by `jerry_release_value`.
|
||||
* are independent, and both must be destroyed before the global
|
||||
* object can be freed. */
|
||||
|
||||
jerry_release_value (global);
|
||||
jerry_value_free (global);
|
||||
|
||||
/* Without jerry_release_value() the global object will not
|
||||
/* Without jerry_value_free() the global object will not
|
||||
* be freed even by jerry_cleanup(). After the reference
|
||||
* is released it becomes a dead reference and cannot be
|
||||
* used anymore. */
|
||||
@@ -26,15 +26,15 @@ Multiple references might refer to the same internal object
|
||||
even though their `jerry_value_t` representation might be different.
|
||||
|
||||
```c
|
||||
jerry_value_t pi_ref1 = jerry_create_number (3.14);
|
||||
jerry_value_t pi_ref2 = jerry_acquire_value (pi_ref1);
|
||||
jerry_value_t pi_ref1 = jerry_number (3.14);
|
||||
jerry_value_t pi_ref2 = jerry_value_copy (pi_ref1);
|
||||
|
||||
/* Both pi_ref1 and pi_ref2 refer to the same 3.14 value
|
||||
* although they might not be equal in C (pi_ref1 != pi_ref2). */
|
||||
|
||||
/* Both references must be released. */
|
||||
jerry_release_value (pi_ref1);
|
||||
jerry_release_value (pi_ref2);
|
||||
jerry_value_free (pi_ref1);
|
||||
jerry_value_free (pi_ref2);
|
||||
```
|
||||
|
||||
Releasing the same `jerry_value_t` twice to release two live
|
||||
@@ -42,8 +42,8 @@ references is not allowed and it might cause crashes. Hence the
|
||||
following code is an **INCORRECT WAY** of releasing the 3.14 value.
|
||||
|
||||
```c
|
||||
jerry_release_value (pi_ref1);
|
||||
jerry_release_value (pi_ref1);
|
||||
jerry_value_free (pi_ref1);
|
||||
jerry_value_free (pi_ref1);
|
||||
```
|
||||
|
||||
JerryScript API functions returning with a `jerry_value_t` always
|
||||
@@ -53,7 +53,7 @@ stated in the documentation). The next example shows this
|
||||
behaviour through property getting and setting.
|
||||
|
||||
```c
|
||||
jerry_value_t prop_value = jerry_get_property (...);
|
||||
jerry_value_t prop_value = jerry_object_get (...);
|
||||
|
||||
/* The prop_value must be released later because both the base
|
||||
* object and the prop_value have an independent reference to
|
||||
@@ -61,7 +61,7 @@ behaviour through property getting and setting.
|
||||
* prop_value contains a live reference to an error object.
|
||||
* This reference must be released as well. */
|
||||
|
||||
if (jerry_value_is_error (prop_value))
|
||||
if (jerry_value_is_exception (prop_value))
|
||||
{
|
||||
/* Errors can be handled here. */
|
||||
}
|
||||
@@ -73,12 +73,12 @@ behaviour through property getting and setting.
|
||||
}
|
||||
|
||||
/* The prop_value must be released. */
|
||||
jerry_release_value (prop_value);
|
||||
jerry_value_free (prop_value);
|
||||
|
||||
/* Property setting is the same. */
|
||||
|
||||
jerry_value_t new_prop_value = jerry_create_number (2.718);
|
||||
jerry_value_t result = jerry_set_property (..., new_prop_value);
|
||||
jerry_value_t new_prop_value = jerry_number (2.718);
|
||||
jerry_value_t result = jerry_object_set (..., new_prop_value);
|
||||
|
||||
/* If the property set is successful, a new reference is created
|
||||
* for the value referenced by new_prop_value. The new_prop_value
|
||||
@@ -86,14 +86,14 @@ behaviour through property getting and setting.
|
||||
* is successful. */
|
||||
|
||||
/* The new_prop_value can be passed to other JerryScript API
|
||||
* functions before the jerry_release_value () call. */
|
||||
* functions before the jerry_value_free () call. */
|
||||
|
||||
jerry_release_value (new_prop_value);
|
||||
jerry_value_free (new_prop_value);
|
||||
|
||||
/* The reference stored in the 'result' variable is live whether
|
||||
* the operation is successful or not, and must also be freed. */
|
||||
|
||||
if (jerry_value_is_error (result))
|
||||
if (jerry_value_is_exception (result))
|
||||
{
|
||||
/* Errors can be handled here. */
|
||||
}
|
||||
@@ -102,7 +102,7 @@ behaviour through property getting and setting.
|
||||
/* A reference to a true primitive value is returned. */
|
||||
}
|
||||
|
||||
jerry_release_value (result);
|
||||
jerry_value_free (result);
|
||||
```
|
||||
|
||||
The simplest form of setting a property without error checking
|
||||
@@ -110,8 +110,8 @@ is the following:
|
||||
|
||||
```c
|
||||
/* There are no 'ifs' in this snippet. */
|
||||
jerry_release_value (jerry_set_property (..., new_prop_value));
|
||||
jerry_release_value (new_prop_value);
|
||||
jerry_value_free (jerry_object_set (..., new_prop_value));
|
||||
jerry_value_free (new_prop_value);
|
||||
```
|
||||
|
||||
The reference returned by a `jerry_external_handler_t` callback
|
||||
@@ -128,48 +128,48 @@ jerry_value_t my_external_handler (const jerry_value_t function_obj,
|
||||
* these references are automatically released after the handler
|
||||
* is returned. This approach reduces code size which is useful
|
||||
* on embedded systems. However you can create other references
|
||||
* to them by calling jerry_acquire_value () if needed. */
|
||||
* to them by calling jerry_value_copy () if needed. */
|
||||
|
||||
/* Since the ownership of the reference is transferred to the
|
||||
* caller the following snippet is valid. */
|
||||
|
||||
/* If the value to be returned is needed for other purposes the
|
||||
* jerry_acquire_value () can be used to create new references. */
|
||||
return jerry_create_string (...);
|
||||
* jerry_value_copy () can be used to create new references. */
|
||||
return jerry_string (...);
|
||||
}
|
||||
```
|
||||
|
||||
Duplicating a `jerry_value_t` in C does not create another live reference.
|
||||
|
||||
```c
|
||||
jerry_value_t undef = jerry_create_undefined ();
|
||||
jerry_value_t undef = jerry_undefined ();
|
||||
jerry_value_t undef2 = undef;
|
||||
|
||||
/* Releasing either undef or undef2 is valid but not both.
|
||||
* After the release both references become dead (invalid). */
|
||||
jerry_release_value (undef2);
|
||||
jerry_value_free (undef2);
|
||||
|
||||
/* Dead references can be reassigned again. */
|
||||
undef = jerry_create_boolean (true);
|
||||
undef = jerry_boolean (true);
|
||||
```
|
||||
|
||||
References can be duplicated in C as long as only one of them is freed.
|
||||
|
||||
```c
|
||||
jerry_value_t a = jerry_create_boolean (true);
|
||||
jerry_value_t a = jerry_boolean (true);
|
||||
|
||||
jerry_value_t b = a;
|
||||
jerry_value_t c = a;
|
||||
|
||||
/* A new reference is assigned to 'a'. */
|
||||
a = jerry_create_boolean (false);
|
||||
a = jerry_boolean (false);
|
||||
|
||||
[...]
|
||||
|
||||
jerry_release_value (a);
|
||||
jerry_value_free (a);
|
||||
/* The 'a' (boolean false) reference becomes dead (invalid). */
|
||||
|
||||
jerry_release_value (c);
|
||||
jerry_value_free (c);
|
||||
/* Both 'b' and 'c' (boolean true) references become dead. */
|
||||
|
||||
/* Since all references are released, no memory leak occurs. */
|
||||
|
||||
+28
-56
@@ -74,8 +74,8 @@ Currently, `jerryx_debugger_rp_create ()` for raw packet transport layer and
|
||||
`jerryx_debugger_serial_create (const char* config)` for serial protocol
|
||||
are also available.)
|
||||
|
||||
The resource name provided to `jerry_parse ()` is used by the client
|
||||
to identify the resource name of the source code. This resource name
|
||||
The source name provided to `jerry_parse ()` is used by the client
|
||||
to identify the source name of the source code. This source name
|
||||
is usually a file name.
|
||||
|
||||
## JerryScript debugger C-API interface
|
||||
@@ -97,14 +97,15 @@ when a source code is received successfully.
|
||||
|
||||
```c
|
||||
typedef jerry_value_t
|
||||
(*jerry_debugger_wait_for_source_callback_t) (const jerry_char_t *resource_name_p,
|
||||
size_t resource_name_size,
|
||||
(*jerry_debugger_wait_for_source_callback_t) (const jerry_char_t *source_name_p,
|
||||
size_t source_name_size,
|
||||
const jerry_char_t *source_p,
|
||||
size_t source_size, void *user_p);
|
||||
size_t source_size,
|
||||
void *user_p);
|
||||
```
|
||||
|
||||
- `resource_name_p` - resource (usually a file) name of the source code
|
||||
- `resource_name_size` - size of resource name
|
||||
- `source_name_p` - source (usually a file) name of the source code
|
||||
- `source_name_size` - size of source name
|
||||
- `source_p` - source code character data
|
||||
- `source_size` - size of source code
|
||||
- `user_p` - custom pointer passed to [jerry_debugger_wait_for_client_source](#jerry_debugger_wait_for_client_source)
|
||||
@@ -130,6 +131,8 @@ jerry_debugger_is_connected (void);
|
||||
[doctest]: # (test="link")
|
||||
|
||||
```c
|
||||
#include <stdio.h>
|
||||
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/debugger.h"
|
||||
|
||||
@@ -291,7 +294,8 @@ return value of the function.
|
||||
```c
|
||||
jerry_debugger_wait_for_source_status_t
|
||||
jerry_debugger_wait_for_client_source (jerry_debugger_wait_for_source_callback_t callback_p,
|
||||
void *user_p, jerry_value_t *return_value)
|
||||
void *user_p,
|
||||
jerry_value_t *return_value)
|
||||
```
|
||||
|
||||
**Example**
|
||||
@@ -306,25 +310,30 @@ jerry_debugger_wait_for_client_source (jerry_debugger_wait_for_source_callback_t
|
||||
* Runs the source code received by jerry_debugger_wait_for_client_source.
|
||||
*/
|
||||
static jerry_value_t
|
||||
wait_for_source_callback (const jerry_char_t *resource_name_p, /**< resource name */
|
||||
size_t resource_name_size, /**< size of resource name */
|
||||
wait_for_source_callback (const jerry_char_t *source_name_p, /**< source name */
|
||||
size_t source_name_size, /**< size of source name */
|
||||
const jerry_char_t *source_p, /**< source code */
|
||||
size_t source_size, /**< source code size */
|
||||
void *user_p /**< user pointer */)
|
||||
{
|
||||
(void) user_p;
|
||||
|
||||
jerry_value_t ret_val = jerry_parse (resource_name_p,
|
||||
resource_name_size,
|
||||
source_p,
|
||||
source_size,
|
||||
JERRY_PARSE_NO_OPTS);
|
||||
jerry_parse_options_t parse_options;
|
||||
parse_options.options = JERRY_PARSE_HAS_SOURCE_NAME;
|
||||
parse_options.source_name = jerry_string ((const jerry_char_t *) source_name_p,
|
||||
(jerry_size_t) source_name_size,
|
||||
JERRY_ENCODING_UTF8);
|
||||
|
||||
if (!jerry_value_is_error (ret_val))
|
||||
jerry_value_t ret_val = jerry_parse (source_p,
|
||||
source_size,
|
||||
&parse_options);
|
||||
jerry_value_free (parse_options.source_name);
|
||||
|
||||
if (!jerry_value_is_exception (ret_val))
|
||||
{
|
||||
jerry_value_t func_val = ret_val;
|
||||
ret_val = jerry_run (func_val);
|
||||
jerry_release_value (func_val);
|
||||
jerry_value_free (func_val);
|
||||
}
|
||||
|
||||
return ret_val;
|
||||
@@ -352,7 +361,7 @@ main (void)
|
||||
NULL,
|
||||
&run_result);
|
||||
|
||||
jerry_release_value (run_result);
|
||||
jerry_value_free (run_result);
|
||||
}
|
||||
while (receive_status == JERRY_DEBUGGER_SOURCE_RECEIVED);
|
||||
|
||||
@@ -378,7 +387,7 @@ Sends the program's output to the debugger client.
|
||||
|
||||
```c
|
||||
void
|
||||
jerry_debugger_send_output (const jerry_char_t *buffer, jerry_size_t string_size)
|
||||
jerry_debugger_send_output (const jerry_char_t *buffer, jerry_size_t str_size)
|
||||
```
|
||||
|
||||
**Example**
|
||||
@@ -404,40 +413,3 @@ main (void)
|
||||
jerry_cleanup ();
|
||||
}
|
||||
```
|
||||
|
||||
### jerry_debugger_send_log
|
||||
|
||||
**Summary**
|
||||
|
||||
Sends the program's log to the debugger client.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
void
|
||||
jerry_debugger_send_log (jerry_log_level_t level, const jerry_char_t *buffer, jerry_size_t string_size)
|
||||
```
|
||||
|
||||
**Example**
|
||||
|
||||
[doctest]: # (test="link")
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/debugger.h"
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
jerryx_debugger_after_connect (jerryx_debugger_tcp_create (5001)
|
||||
&& jerryx_debugger_ws_create ());
|
||||
|
||||
jerry_char_t my_log[] = "Custom diagnostics";
|
||||
jerry_size_t my_log_size = sizeof (my_log);
|
||||
|
||||
jerry_debugger_send_log (JERRY_LOG_LEVEL_DEBUG, my_log, my_log_size);
|
||||
|
||||
jerry_cleanup ();
|
||||
}
|
||||
```
|
||||
|
||||
@@ -12,7 +12,7 @@ review.
|
||||
* Tab characters are not allowed.
|
||||
* Maximum line length is 120 characters (excluding newline).
|
||||
* No trailing white space is allowed.
|
||||
* Run `tools/run-tests.py --check-vera` to check several
|
||||
* Run `tools/run-tests.py --check-format` to check several
|
||||
of the coding conventions automatically.
|
||||
|
||||
## Comments
|
||||
@@ -46,7 +46,7 @@ is doing.
|
||||
|
||||
/* not a complete sentence */
|
||||
|
||||
/* A bad mulitiline
|
||||
/* A bad multiline
|
||||
comment. */
|
||||
```
|
||||
|
||||
@@ -369,7 +369,7 @@ a = 6;
|
||||
|
||||
b = 7;
|
||||
|
||||
/* No newlines are allowed between control staments
|
||||
/* No newlines are allowed between control statements
|
||||
* and their code blocks. */
|
||||
|
||||
if (a > 6)
|
||||
@@ -419,7 +419,7 @@ a=b+c;
|
||||
a = b+c;
|
||||
a += c + ( d );
|
||||
/* Introduce temporary variables or macros
|
||||
* if the expression is too long. Occures rarely.. */
|
||||
* if the expression is too long. Occurs rarely.. */
|
||||
a = b
|
||||
+ c;
|
||||
if ( a + b > 0 )
|
||||
|
||||
@@ -244,7 +244,7 @@ my_external_handler (const jerry_value_t function_obj,
|
||||
mapping,
|
||||
4);
|
||||
|
||||
if (jerry_value_is_error (rv))
|
||||
if (jerry_value_is_exception (rv))
|
||||
{
|
||||
/* Handle error. */
|
||||
return rv;
|
||||
@@ -255,7 +255,7 @@ my_external_handler (const jerry_value_t function_obj,
|
||||
* required_bool, required_str and optional_num can now be used.
|
||||
*/
|
||||
|
||||
return jerry_create_undefined (); /* Or return something more meaningful. */
|
||||
return jerry_undefined (); /* Or return something more meaningful. */
|
||||
}
|
||||
```
|
||||
|
||||
@@ -361,6 +361,28 @@ jerryx_arg_transform_array (const jerry_value_t array_val,
|
||||
|
||||
- [jerryx_arg_array](#jerryx_arg_array)
|
||||
|
||||
## jerryx_arg_transform_optional
|
||||
|
||||
**Summary**
|
||||
|
||||
The common function to deal with optional arguments. The core transform function is provided by argument `func`.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t jerryx_arg_transform_optional (jerryx_arg_js_iterator_t *js_arg_iter_p,
|
||||
const jerryx_arg_t *c_arg_p,
|
||||
jerryx_arg_transform_func_t func);
|
||||
```
|
||||
|
||||
- `js_arg_iter_p` - the JS arg iterator.
|
||||
- `c_arg_p` - the native arg.
|
||||
- `func` - the core transform function.
|
||||
- return value - a `jerry_value_t` representing `undefined` if all validators passed or an `Error` if a validator failed.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_transform_func_t](#jerryx_arg_transform_func_t)
|
||||
|
||||
# Helpers for commonly used validations
|
||||
|
||||
@@ -577,11 +599,11 @@ User should prepare the `jerryx_arg_object_props_t` instance, and pass it to thi
|
||||
|
||||
```c
|
||||
static inline jerryx_arg_t
|
||||
jerryx_arg_object_properties (const jerryx_arg_object_props_t *object_props_p,
|
||||
jerryx_arg_object_properties (const jerryx_arg_object_props_t *obj_prop_p,
|
||||
jerryx_arg_optional_t opt_flag);
|
||||
```
|
||||
- return value - the created `jerryx_arg_t` instance.
|
||||
- `object_props_p` - provides information for properties transform.
|
||||
- `obj_prop_p` - provides information for properties transform.
|
||||
- `opt_flag` - whether the argument is optional.
|
||||
|
||||
**Example**
|
||||
@@ -640,7 +662,7 @@ my_external_handler (const jerry_value_t function_obj,
|
||||
mapping,
|
||||
1);
|
||||
|
||||
if (jerry_value_is_error (rv))
|
||||
if (jerry_value_is_exception (rv))
|
||||
{
|
||||
/* Handle error. */
|
||||
return rv;
|
||||
@@ -651,7 +673,7 @@ my_external_handler (const jerry_value_t function_obj,
|
||||
* required_bool, required_num and optional_num can now be used.
|
||||
*/
|
||||
|
||||
return jerry_create_undefined (); /* Or return something more meaningful. */
|
||||
return jerry_undefined (); /* Or return something more meaningful. */
|
||||
}
|
||||
|
||||
```
|
||||
@@ -731,7 +753,7 @@ my_external_handler (const jerry_value_t function_obj,
|
||||
mapping,
|
||||
1);
|
||||
|
||||
if (jerry_value_is_error (rv))
|
||||
if (jerry_value_is_exception (rv))
|
||||
{
|
||||
/* Handle error. */
|
||||
return rv;
|
||||
@@ -742,7 +764,7 @@ my_external_handler (const jerry_value_t function_obj,
|
||||
* required_bool, required_num and optional_num can now be used.
|
||||
*/
|
||||
|
||||
return jerry_create_undefined (); /* Or return something more meaningful. */
|
||||
return jerry_undefined (); /* Or return something more meaningful. */
|
||||
}
|
||||
|
||||
```
|
||||
@@ -754,6 +776,23 @@ my_external_handler (const jerry_value_t function_obj,
|
||||
|
||||
# Functions to create custom validations
|
||||
|
||||
## jerryx_arg_ignore
|
||||
|
||||
**Summary**
|
||||
|
||||
Create a jerryx_arg_t instance for ignored argument.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
static inline jerryx_arg_t jerryx_arg_ignore (void);
|
||||
```
|
||||
- return value - the created `jerryx_arg_t` instance.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_t](#jerryx_arg_t)
|
||||
|
||||
## jerryx_arg_custom
|
||||
|
||||
**Summary**
|
||||
|
||||
@@ -1,173 +1,8 @@
|
||||
# Common methods to handle properties
|
||||
|
||||
The `jerryscript-ext/handler.h` header defines a set of convenience methods
|
||||
The `jerryscript-ext/properties.h` header defines a set of convenience methods
|
||||
which makes the property access a bit straightforward.
|
||||
|
||||
## jerryx_set_property_str
|
||||
|
||||
**Summary**
|
||||
|
||||
Set a property on a target object with a given name.
|
||||
|
||||
*Note*:
|
||||
- The property name must be a zero terminated UTF-8 string.
|
||||
- There should be no '\0' (NULL) character in the name excluding the string terminator.
|
||||
- Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
|
||||
is no longer needed.
|
||||
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerryx_set_property_str (const jerry_value_t target_object,
|
||||
const char *name,
|
||||
const jerry_value_t value);
|
||||
```
|
||||
|
||||
- `target_object` - the object where the property should be set
|
||||
- `name` - name of the property
|
||||
- `value` - property value to be set
|
||||
- return value
|
||||
- JS true value, if success
|
||||
- thrown error, if there was a problem setting the property
|
||||
|
||||
**Example**
|
||||
|
||||
[doctest]: # ()
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/handler.h"
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
|
||||
jerry_value_t global = jerry_get_global_object ();
|
||||
|
||||
jerry_value_t value = jerry_create_number (3.3);
|
||||
jerry_value_t result = jerryx_set_property_str (global, "value", value);
|
||||
if (jerry_value_is_error (result))
|
||||
{
|
||||
/* The error type/reason can be extracted via the `jerry_get_value_from_error` method */
|
||||
printf ("Error during property configuration\r\n");
|
||||
}
|
||||
|
||||
jerry_release_value (result);
|
||||
jerry_release_value (value);
|
||||
jerry_release_value (global);
|
||||
jerry_cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## jerryx_get_property_str
|
||||
|
||||
**Summary**
|
||||
|
||||
Get the value of a property from the specified object with the given name.
|
||||
|
||||
*Notes*:
|
||||
- The property name must be a zero terminated UTF-8 string.
|
||||
- There should be no '\0' (NULL) character in the name excluding the string terminator.
|
||||
- Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
|
||||
is no longer needed.
|
||||
|
||||
|
||||
**Prototype**
|
||||
|
||||
```
|
||||
jerry_value_t
|
||||
jerryx_get_property_str (const jerry_value_t target_object,
|
||||
const char *name);
|
||||
```
|
||||
|
||||
- `target_object` - object on which the property name is accessed
|
||||
- `name` - property name as an UTF-8 `char*`
|
||||
- return value
|
||||
- value of property, if success
|
||||
- thrown error, if there was a problem accessing the property
|
||||
|
||||
**Example**
|
||||
|
||||
[doctest]: # ()
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/handler.h"
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
|
||||
jerry_value_t global = jerry_get_global_object ();
|
||||
|
||||
jerry_value_t math_object = jerryx_get_property_str (global, "Math");
|
||||
|
||||
/* use math_object */
|
||||
|
||||
jerry_release_value (math_object);
|
||||
jerry_release_value (global);
|
||||
jerry_cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## jerryx_has_property_str
|
||||
|
||||
**Summary**
|
||||
|
||||
Check if a property exists on an object.
|
||||
|
||||
*Notes*:
|
||||
- The operation performed is the same as what the `jerry_has_property` method.
|
||||
- The property name must be a zero terminated UTF-8 string.
|
||||
- There should be no '\0' (NULL) character in the name excluding the string terminator.
|
||||
|
||||
|
||||
**Prototype**
|
||||
|
||||
```
|
||||
bool
|
||||
jerryx_has_property_str (const jerry_value_t target_object,
|
||||
const char *name);
|
||||
```
|
||||
|
||||
- `target_object` - object on which the property name is accessed
|
||||
- `name` - property name as an UTF-8 `char*`
|
||||
- return value
|
||||
- true, if the given property name exsits on the object
|
||||
- false, if there is no such property name or there was an error accessing the property
|
||||
|
||||
**Example**
|
||||
|
||||
[doctest]: # ()
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/handler.h"
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
|
||||
jerry_value_t global = jerry_get_global_object ();
|
||||
|
||||
bool have_math = jerryx_has_property_str (global, "Math");
|
||||
|
||||
jerry_release_value (global);
|
||||
jerry_cleanup();
|
||||
|
||||
return have_math ? 0 : 1;
|
||||
}
|
||||
```
|
||||
|
||||
# Utility to register multiple properties in bulk
|
||||
|
||||
In some cases it is useful to register multiple properties for a given object
|
||||
@@ -180,7 +15,7 @@ for this the following utility structures and methods are provided.
|
||||
Structure to define an array of properties with `name` and `value` fields which
|
||||
can be registered to a target object.
|
||||
|
||||
The engine must be initialied before specifying the `jerry_value_t` in the struct.
|
||||
The engine must be initialized before specifying the `jerry_value_t` in the struct.
|
||||
|
||||
|
||||
**Prototype**
|
||||
@@ -189,7 +24,7 @@ The engine must be initialied before specifying the `jerry_value_t` in the struc
|
||||
typedef struct {
|
||||
const char *name;
|
||||
jerry_value_t value;
|
||||
} jerryx_function_list_entry;
|
||||
} jerryx_property_entry;
|
||||
```
|
||||
|
||||
**See also**
|
||||
@@ -209,7 +44,7 @@ successfully registered methods.
|
||||
This must be passed for the [jerryx_release_property_entry](#jerryx_release_property_entry) method
|
||||
after the property registration.
|
||||
|
||||
If any error occured during the property registration the `result` field of the structure
|
||||
If any error occurred during the property registration the `result` field of the structure
|
||||
must be manually released after processing the error value.
|
||||
|
||||
**Prototype**
|
||||
@@ -263,18 +98,19 @@ jerryx_set_properties (const jerry_value_t target_object,
|
||||
[doctest]: # ()
|
||||
|
||||
```c
|
||||
#include <stdio.h>
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/handler.h"
|
||||
#include "jerryscript-ext/handlers.h"
|
||||
#include "jerryscript-ext/properties.h"
|
||||
|
||||
static jerry_value_t
|
||||
handler (const jerry_value_t function_obj,
|
||||
const jerry_value_t this_val,
|
||||
handler (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t args_p[],
|
||||
const jerry_length_t args_cnt)
|
||||
{
|
||||
printf ("native handler called!\n");
|
||||
|
||||
return jerry_create_boolean (true);
|
||||
return jerry_boolean (true);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -284,24 +120,24 @@ main (int argc, char **argv)
|
||||
|
||||
jerryx_property_entry methods[] =
|
||||
{
|
||||
{ "demo", jerry_create_external_function (handler) },
|
||||
{ "demo", jerry_function_external (handler) },
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
jerry_value_t global = jerry_get_global_object ();
|
||||
jerry_value_t global = jerry_current_realm ();
|
||||
jerryx_register_result reg = jerryx_set_properties (global, methods);
|
||||
/* if `reg.result` is undefined all methods are registered */
|
||||
if (jerry_value_is_error (reg.result))
|
||||
if (jerry_value_is_exception (reg.result))
|
||||
{
|
||||
printf ("Only registered %d properties\r\n", reg.registered);
|
||||
/* clean up not registered property values */
|
||||
jerryx_release_property_entry (methods, reg);
|
||||
|
||||
/* clean up the error */
|
||||
jerry_release_value (reg.result);
|
||||
jerry_value_free (reg.result);
|
||||
}
|
||||
|
||||
jerry_release_value (global);
|
||||
jerry_value_free (global);
|
||||
|
||||
jerry_cleanup();
|
||||
|
||||
@@ -315,8 +151,8 @@ To make property registration convenient, there are a set of macros to use
|
||||
when setting a property entry:
|
||||
|
||||
* `JERRYX_PROPERTY_NUMBER(NAME, NUMBER)` - creates a number entry.
|
||||
* `JERRYX_PROPERTY_STRING(NAME, STR)` - creates an UTF-8 string entry. This string must be zero terminated.
|
||||
* `JERRYX_PROPERTY_STRING_SZ(NAME, STR, SIZE)` - creates an UTF-8 string entry using only `SIZE` bytes from the string.
|
||||
* `JERRYX_PROPERTY_STRING(NAME, STR, SIZE)` - creates an UTF-8 string entry using `SIZE` bytes from the string.
|
||||
* `JERRYX_PROPERTY_STRING_SZ(NAME, STR)` - creates an ASCII string entry. This string must be zero terminated.
|
||||
* `JERRYX_PROPERTY_BOOLEAN(NAME, VALUE)` - creates a boolean entry.
|
||||
* `JERRYX_PROPERTY_FUNCTION(NAME, NATIVE)` - creates a native C function entry.
|
||||
* `JERRYX_PROPERTY_UNDEFINED(NAME)` - creates an undefined property entry.
|
||||
@@ -327,18 +163,19 @@ when setting a property entry:
|
||||
[doctest]: # ()
|
||||
|
||||
```c
|
||||
#include <stdio.h>
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/handler.h"
|
||||
#include "jerryscript-ext/handlers.h"
|
||||
#include "jerryscript-ext/properties.h"
|
||||
|
||||
static jerry_value_t
|
||||
handler (const jerry_value_t function_obj,
|
||||
const jerry_value_t this_val,
|
||||
handler (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t args_p[],
|
||||
const jerry_length_t args_cnt)
|
||||
{
|
||||
printf ("native handler called!\n");
|
||||
|
||||
return jerry_create_boolean (true);
|
||||
return jerry_boolean (true);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -359,20 +196,20 @@ main (int argc, char **argv)
|
||||
JERRYX_PROPERTY_LIST_END(),
|
||||
};
|
||||
|
||||
jerry_value_t global = jerry_get_global_object ();
|
||||
jerry_value_t global = jerry_current_realm ();
|
||||
jerryx_register_result reg = jerryx_set_properties (global, methods);
|
||||
/* if `reg.result` is undefined all methods are registered */
|
||||
if (jerry_value_is_error (reg.result))
|
||||
if (jerry_value_is_exception (reg.result))
|
||||
{
|
||||
printf ("Only registered %d properties\r\n", reg.registered);
|
||||
/* clean up not registered property values */
|
||||
jerryx_release_property_entry (methods, reg);
|
||||
|
||||
/* clean up the error */
|
||||
jerry_release_value (reg.result);
|
||||
jerry_value_free (reg.result);
|
||||
}
|
||||
|
||||
jerry_release_value (global);
|
||||
jerry_value_free (global);
|
||||
|
||||
jerry_cleanup();
|
||||
|
||||
@@ -395,7 +232,7 @@ Release all `jerry_value_t` in a `jerryx_property_entry` array based on a previo
|
||||
and also the error value (if any) in the `jerryx_register_result` structure.
|
||||
In case of a successful registration it is safe to call this method.
|
||||
|
||||
After the method call the `ęntries` array should not be used as all values are released.
|
||||
After the method call the `entries` array should not be used as all values are released.
|
||||
|
||||
**Prototype**
|
||||
|
||||
@@ -405,7 +242,7 @@ jerryx_release_property_entry (const jerryx_property_entry entries[],
|
||||
const jerryx_register_result register_result);
|
||||
```
|
||||
|
||||
- `entires` - array of [jerryx_property_entry](#jerryx_property_entry).
|
||||
- `entries` - array of [jerryx_property_entry](#jerryx_property_entry).
|
||||
- `register_result` - result of a previous [jerryx_set_properties](#jerryx_set_properties) call.
|
||||
|
||||
**Example**
|
||||
@@ -415,7 +252,7 @@ For example usage see [jerryx_set_properties](#jerryx_set_properties).
|
||||
|
||||
# Common external function handlers
|
||||
|
||||
## jerryx_handler_assert_fatal
|
||||
## jerryx_handler_assert
|
||||
|
||||
**Summary**
|
||||
|
||||
@@ -428,12 +265,13 @@ a backtrace is also printed out.
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerryx_handler_assert_fatal (const jerry_value_t func_obj_val, const jerry_value_t this_p,
|
||||
const jerry_value_t args_p[], const jerry_length_t args_cnt);
|
||||
jerryx_handler_assert (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t args_p[],
|
||||
const jerry_length_t args_cnt);
|
||||
```
|
||||
|
||||
- `func_obj_val` - the function object that was called (unused).
|
||||
- `this_p` - the `this` value of the call (unused).
|
||||
- `call_info_p` - pointer to a [jerry_call_info_t](#jerry_call_info_t)
|
||||
structure which holds call related information (unused).
|
||||
- `args_p` - the array of function arguments.
|
||||
- `args_cnt` - the number of function arguments.
|
||||
- return value - `jerry_value_t` representing boolean true, if only one argument
|
||||
@@ -442,44 +280,7 @@ jerryx_handler_assert_fatal (const jerry_value_t func_obj_val, const jerry_value
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_handler_register_global](#jerryx_handler_register_global)
|
||||
|
||||
|
||||
## jerryx_handler_assert_throw
|
||||
|
||||
**Summary**
|
||||
|
||||
Soft assert for scripts. The routine throws an error on assertion failure.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerryx_handler_assert_throw (const jerry_value_t func_obj_val, const jerry_value_t this_p,
|
||||
const jerry_value_t args_p[], const jerry_length_t args_cnt);
|
||||
```
|
||||
|
||||
- `func_obj_val` - the function object that was called (unused).
|
||||
- `this_p` - the `this` value of the call (unused).
|
||||
- `args_p` - the array of function arguments.
|
||||
- `args_cnt` - the number of function arguments.
|
||||
- return value - `jerry_value_t` representing boolean true, if only one argument
|
||||
was passed and that argument was a boolean true, an error otherwise.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_handler_register_global](#jerryx_handler_register_global)
|
||||
|
||||
|
||||
## jerryx_handler_assert
|
||||
|
||||
**Summary**
|
||||
|
||||
An alias to `jerryx_handler_assert_fatal`.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_handler_assert_fatal](#jerryx_handler_assert_fatal)
|
||||
- [jerryx_register_global](#jerryx_register_global)
|
||||
|
||||
|
||||
## jerryx_handler_gc
|
||||
@@ -494,19 +295,20 @@ gc is performed, which is also the default if no parameters passed.
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerryx_handler_gc (const jerry_value_t func_obj_val, const jerry_value_t this_p,
|
||||
const jerry_value_t args_p[], const jerry_length_t args_cnt);
|
||||
jerryx_handler_gc (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t args_p[],
|
||||
const jerry_length_t args_cnt);
|
||||
```
|
||||
|
||||
- `func_obj_val` - the function object that was called (unused).
|
||||
- `this_p` - the `this` value of the call (unused).
|
||||
- `call_info_p` - pointer to a [jerry_call_info_t](#jerry_call_info_t)
|
||||
structure which holds call related information (unused).
|
||||
- `args_p` - the array of function arguments (unused).
|
||||
- `args_cnt` - the number of function arguments (unused).
|
||||
- return value - `jerry_value_t` representing `undefined`.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_handler_register_global](#jerryx_handler_register_global)
|
||||
- [jerryx_register_global](#jerryx_register_global)
|
||||
|
||||
|
||||
## jerryx_handler_print
|
||||
@@ -514,26 +316,26 @@ jerryx_handler_gc (const jerry_value_t func_obj_val, const jerry_value_t this_p,
|
||||
**Summary**
|
||||
|
||||
Provide a `print` implementation for scripts. The routine converts all of its
|
||||
arguments to strings and outputs them char-by-char using
|
||||
`jerry_port_print_char`. The NUL character is output as "\u0000",
|
||||
other characters are output bytewise.
|
||||
arguments to strings and outputs them by using `jerry_port_print_buffer`.
|
||||
The NULL character is output as "\u0000", other characters are output bytewise.
|
||||
|
||||
*Note*: This implementation does not use standard C `printf` to print its
|
||||
output. This allows more flexibility but also extends the core JerryScript
|
||||
engine port API. Applications that want to use `jerryx_handler_print` must
|
||||
ensure that their port implementation also provides
|
||||
`jerry_port_print_char`.
|
||||
`jerry_port_print_buffer`.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerryx_handler_print (const jerry_value_t func_obj_val, const jerry_value_t this_p,
|
||||
const jerry_value_t args_p[], const jerry_length_t args_cnt);
|
||||
jerryx_handler_print (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t args_p[],
|
||||
const jerry_length_t args_cnt);
|
||||
```
|
||||
|
||||
- `func_obj_val` - the function object that was called (unused).
|
||||
- `this_p` - the `this` value of the call (unused).
|
||||
- `call_info_p` - pointer to a [jerry_call_info_t](#jerry_call_info_t)
|
||||
structure which holds call related information (unused).
|
||||
- `args_p` - the array of function arguments.
|
||||
- `args_cnt` - the number of function arguments.
|
||||
- return value - `jerry_value_t` representing `undefined` if all arguments could
|
||||
@@ -541,27 +343,27 @@ jerryx_handler_print (const jerry_value_t func_obj_val, const jerry_value_t this
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_handler_register_global](#jerryx_handler_register_global)
|
||||
- [jerry_port_print_char](05.PORT-API.md#jerry_port_print_char)
|
||||
- [jerryx_register_global](#jerryx_register_global)
|
||||
- [jerry_port_print_buffer](05.PORT-API.md#jerry_port_print_buffer)
|
||||
|
||||
|
||||
# Handler registration helper
|
||||
|
||||
## jerryx_handler_register_global
|
||||
## jerryx_register_global
|
||||
|
||||
**Summary**
|
||||
|
||||
Register a JavaScript function in the global object.
|
||||
|
||||
*Note*: Returned value must be freed with `jerry_release_value`, when it is no
|
||||
*Note*: Returned value must be freed with `jerry_value_free`, when it is no
|
||||
longer needed.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerryx_handler_register_global (const jerry_char_t *name_p,
|
||||
jerry_external_handler_t handler_p);
|
||||
jerryx_register_global (const char *name_p,
|
||||
jerry_external_handler_t handler_p);
|
||||
```
|
||||
|
||||
- `name_p` - the name of the function to be registered.
|
||||
@@ -575,7 +377,8 @@ jerryx_handler_register_global (const jerry_char_t *name_p,
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/handler.h"
|
||||
#include "jerryscript-ext/handlers.h"
|
||||
#include "jerryscript-ext/properties.h"
|
||||
|
||||
static const struct {
|
||||
const char *name_p;
|
||||
@@ -591,14 +394,14 @@ static const struct {
|
||||
static void
|
||||
register_common_functions (void)
|
||||
{
|
||||
jerry_value_t ret = jerry_create_undefined ();
|
||||
jerry_value_t ret = jerry_undefined ();
|
||||
|
||||
for (int i = 0; common_functions[i].name_p != NULL && !jerry_value_is_error (ret); i++)
|
||||
for (int i = 0; common_functions[i].name_p != NULL && !jerry_value_is_exception (ret); i++)
|
||||
{
|
||||
ret = jerryx_handler_register_global ((const jerry_char_t *) common_functions[i].name_p,
|
||||
common_functions[i].handler_p);
|
||||
ret = jerryx_register_global (common_functions[i].name_p,
|
||||
common_functions[i].handler_p);
|
||||
}
|
||||
|
||||
jerry_release_value (ret);
|
||||
jerry_value_free (ret);
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
**Summary**
|
||||
|
||||
Macro for `const jerry_value_t` for which jerry_release_value() is
|
||||
Macro for `const jerry_value_t` for which jerry_value_free() is
|
||||
automatically called when the variable goes out of scope.
|
||||
|
||||
*Note*: The macro depends on compiler support. For GCC and LLVM/clang, the macro is implemented
|
||||
@@ -21,23 +21,23 @@ using the `__cleanup__` variable attribute. For other compilers, no support has
|
||||
static void
|
||||
foo (bool enable)
|
||||
{
|
||||
JERRYX_AR_VALUE_T bar = jerry_create_string ((const jerry_char_t *) "...");
|
||||
JERRYX_AR_VALUE_T bar = jerry_string_sz ("...");
|
||||
|
||||
if (enable)
|
||||
{
|
||||
JERRYX_AR_VALUE_T baz = jerry_get_global_object ();
|
||||
JERRYX_AR_VALUE_T baz = jerry_current_realm ();
|
||||
|
||||
/* bar and baz can now be used. */
|
||||
|
||||
/*
|
||||
* jerry_release_value (baz) and jerry_release_value (bar) is called automatically before
|
||||
* jerry_value_free (baz) and jerry_value_free (bar) is called automatically before
|
||||
* returning, because `baz` and `bar` go out of scope.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* jerry_release_value (bar) is called automatically when the function returns,
|
||||
* jerry_value_free (bar) is called automatically when the function returns,
|
||||
* because `bar` goes out of scope.
|
||||
*/
|
||||
}
|
||||
@@ -46,5 +46,5 @@ foo (bool enable)
|
||||
**See also**
|
||||
|
||||
- [jerry_value_t](../docs/02.API-REFERENCE.md#jerry_value_t)
|
||||
- [jerry_acquire_value](../docs/02.API-REFERENCE.md#jerry_acquire_value)
|
||||
- [jerry_release_value](../docs/02.API-REFERENCE.md#jerry_release_value)
|
||||
- [jerry_value_copy](../docs/02.API-REFERENCE.md#jerry_value_copy)
|
||||
- [jerry_value_free](../docs/02.API-REFERENCE.md#jerry_value_free)
|
||||
|
||||
@@ -37,8 +37,8 @@ resolved using the native JerryScript module resolver `jerryx_module_native_reso
|
||||
`jerryx_module_resolve()`. Native modules are registered during application startup and by calling `dlopen()` by means
|
||||
of library constructors, support for which can be turned on using the `FEATURE_INIT_FINI` build flag. In the absence of
|
||||
such a flag, the module registration and unregistration functions are exposed as global symbols which can be called
|
||||
explicitly. Note: `FEATURE_INIT_FINI` build flag isn't supported on Windows, because Microsoft Visual C/C++ Compiler
|
||||
doesn't support library constructors and destructors.
|
||||
explicitly. Note: On windows, `FEATURE_INIT_FINI` build flag only supported with GNU toolchain or Microsoft Visual C/C++ Compiler
|
||||
2008 and upper.
|
||||
|
||||
## jerryx_module_resolve
|
||||
|
||||
@@ -63,7 +63,7 @@ to `jerryx_module_resolve` with a module name whose canonical name matches an al
|
||||
```c
|
||||
jerry_value_t
|
||||
jerryx_module_resolve (const jerry_value_t name,
|
||||
const jerryx_module_resolver_t *resolvers_p,
|
||||
const jerryx_module_resolver_t **resolvers_p,
|
||||
size_t resolver_count);
|
||||
```
|
||||
|
||||
@@ -84,7 +84,7 @@ Remove a module from the current context's cache, or clear the cache entirely.
|
||||
```c
|
||||
void
|
||||
jerryx_module_clear_cache (const jerry_value_t name,
|
||||
const jerryx_module_resolver_t *resolvers_p,
|
||||
const jerryx_module_resolver_t **resolvers_p,
|
||||
size_t resolver_count);
|
||||
```
|
||||
|
||||
@@ -164,9 +164,9 @@ load_and_evaluate_js_file (const jerry_value_t name, jerry_value_t *result)
|
||||
char *js_file_contents = NULL;
|
||||
int file_size = 0;
|
||||
|
||||
jerry_size_t name_size = jerry_get_utf8_string_size (name);
|
||||
jerry_size_t name_size = jerry_string_size (name, JERRY_ENCODING_UTF8);
|
||||
jerry_char_t name_string[name_size + 1];
|
||||
jerry_string_to_utf8_char_buffer (name, name_string, name_size);
|
||||
jerry_string_to_buffer (name, JERRY_ENCODING_UTF8, name_string, name_size);
|
||||
name_string[name_size] = 0;
|
||||
|
||||
FILE *js_file = fopen (name_string, "r");
|
||||
@@ -205,7 +205,7 @@ canonicalize_file_path (const jerry_value_t name)
|
||||
/**
|
||||
* Since a file on the file system can be referred to by multiple relative paths, but only by one absolute path, the
|
||||
* absolute path becomes the canonical name for the module. Thus, to establish this canonical name, we must search
|
||||
* name for "./" and "../", follow symlinks, etc., then create absolute_path via jerry_create_string () and return
|
||||
* name for "./" and "../", follow symlinks, etc., then create absolute_path via jerry_string () and return
|
||||
* it, because it is the canonical name for this module. Thus, we avoid loading the same JavaScript file twice.
|
||||
*/
|
||||
|
||||
@@ -257,7 +257,7 @@ symbols so that they may be called explicitly from within the application.
|
||||
#define JERRYX_NATIVE_MODULE(module_name, on_resolve_cb)
|
||||
```
|
||||
|
||||
- `module_name` - the name of the module without quotes. This value is used as the prefix for the registration and unregistration funtions. For example, when `module_name` is `example_module`, this results in the declaration of two functions `example_module_register()` and `example_module_unregister()`. These functions are declared global if support for library constructors/destructors is absent, allowing you to call them from other parts of the code by
|
||||
- `module_name` - the name of the module without quotes. This value is used as the prefix for the registration and unregistration functions. For example, when `module_name` is `example_module`, this results in the declaration of two functions `example_module_register()` and `example_module_unregister()`. These functions are declared global if support for library constructors/destructors is absent, allowing you to call them from other parts of the code by
|
||||
first forward-declaring them.
|
||||
- `on_resolve_cb` - the function of type `jerryx_native_module_on_resolve_t` that will be called when the module needs to be
|
||||
loaded.
|
||||
@@ -271,7 +271,7 @@ loaded.
|
||||
static jerry_value_t
|
||||
my_module_on_resolve (void)
|
||||
{
|
||||
return jerry_create_external_function (very_useful_function);
|
||||
return jerry_function_external (very_useful_function);
|
||||
} /* my_module_on_resolve */
|
||||
|
||||
/* Note that there is no semicolon at the end of the next line. This is how it must be. */
|
||||
|
||||
@@ -77,7 +77,8 @@ the `header_p->next_p->send()` method.
|
||||
|
||||
```c
|
||||
typedef bool (*jerry_debugger_transport_send_t) (struct jerry_debugger_transport_interface_t *header_p,
|
||||
uint8_t *message_p, size_t message_length);
|
||||
uint8_t *message_p,
|
||||
size_t message_length);
|
||||
```
|
||||
|
||||
## jerry_debugger_transport_receive_t
|
||||
@@ -100,18 +101,20 @@ typedef bool (*jerry_debugger_transport_receive_t) (struct jerry_debugger_transp
|
||||
|
||||
**Summary**
|
||||
|
||||
Add a new interface to the transporation interface chain. The interface
|
||||
Add a new interface to the transportation interface chain. The interface
|
||||
will be the first item of the interface chain.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
void jerry_debugger_transport_add (jerry_debugger_transport_header_t *header_p,
|
||||
size_t send_message_header_size, size_t max_send_message_size,
|
||||
size_t receive_message_header_size, size_t max_receive_message_size);
|
||||
size_t send_message_header_size,
|
||||
size_t max_send_message_size,
|
||||
size_t receive_message_header_size,
|
||||
size_t max_receive_message_size);
|
||||
```
|
||||
|
||||
- `header_p`: header of a transporation interface.
|
||||
- `header_p`: header of a transportation interface.
|
||||
- `send_message_header_size`: size of the outgoing message header, can be 0.
|
||||
- `max_send_message_size`: maximum outgoing message size supported by the interface.
|
||||
- `receive_message_header_size`: size of the incoming message header, can be 0.
|
||||
|
||||
@@ -11,7 +11,7 @@ JerryScript only supports a single nested hierarchy of scopes. There is only one
|
||||
|
||||
**Example**
|
||||
|
||||
[doctest]: # (test="compile")
|
||||
[doctest]: # ()
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
@@ -20,7 +20,7 @@ JerryScript only supports a single nested hierarchy of scopes. There is only one
|
||||
static jerry_value_t
|
||||
create_object (void)
|
||||
{
|
||||
jerry_value_t obj = jerry_create_object ();
|
||||
jerry_value_t obj = jerry_object ();
|
||||
return obj;
|
||||
} /* create_object */
|
||||
|
||||
@@ -41,7 +41,7 @@ main (void)
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
|
||||
test_handle_scope_val ();
|
||||
jerry_gc (JERRY_GC_PRESSURE_LOW);
|
||||
jerry_heap_gc (JERRY_GC_PRESSURE_LOW);
|
||||
|
||||
jerry_cleanup ();
|
||||
} /* main */
|
||||
@@ -55,7 +55,7 @@ It is necessary in common cases that a handle has to be promote to outer scope a
|
||||
|
||||
**Example**
|
||||
|
||||
[doctest]: # (test="compile")
|
||||
[doctest]: # ()
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
@@ -66,7 +66,7 @@ create_object (void)
|
||||
{
|
||||
jerryx_escapable_handle_scope scope;
|
||||
jerryx_open_escapable_handle_scope (&scope);
|
||||
jerry_value_t obj = jerryx_create_handle (jerry_create_object ());
|
||||
jerry_value_t obj = jerryx_create_handle (jerry_object ());
|
||||
|
||||
jerry_value_t escaped_obj;
|
||||
jerryx_escape_handle(scope, obj, &escaped_obj);
|
||||
@@ -93,7 +93,7 @@ main (void)
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
|
||||
test_handle_scope_val ();
|
||||
jerry_gc (JERRY_GC_PRESSURE_LOW);
|
||||
jerry_heap_gc (JERRY_GC_PRESSURE_LOW);
|
||||
|
||||
jerry_cleanup ();
|
||||
} /* main */
|
||||
@@ -102,8 +102,8 @@ main (void)
|
||||
**See also**
|
||||
|
||||
- [jerry_value_t](../docs/02.API-REFERENCE.md#jerry_value_t)
|
||||
- [jerry_acquire_value](../docs/02.API-REFERENCE.md#jerry_acquire_value)
|
||||
- [jerry_release_value](../docs/02.API-REFERENCE.md#jerry_release_value)
|
||||
- [jerry_value_copy](../docs/02.API-REFERENCE.md#jerry_value_copy)
|
||||
- [jerry_value_free](../docs/02.API-REFERENCE.md#jerry_value_free)
|
||||
|
||||
## Pre-allocated list of handle scopes and handles
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ Embedders wishing to use native builtin modules with ES6 imports can use the [Po
|
||||
## General
|
||||
|
||||
If a script contains import statements, then JerryScript will open and evaluate the the referenced modules before the main script runs, resolving and creating bindings for the referenced identifiers in the process.
|
||||
It is not necessary to use any specific filename extensions for modules, JerryScript will try to open the given file paths as they are, but will try to normalize them before doing so. The exact normalization process is dependant on the port implementation provided. It is the user's responsibility to verify that the given files are valid EcmaScript modules.
|
||||
It is not necessary to use any specific filename extensions for modules, JerryScript will try to open the given file paths as they are, but will try to normalize them before doing so. The exact normalization process is dependant on the port implementation provided. It is the user's responsibility to verify that the given files are valid ECMAScript modules.
|
||||
|
||||
main.js
|
||||
|
||||
@@ -76,7 +76,7 @@ export var version = "1.0 (e92ae0fb)";
|
||||
|
||||
```js
|
||||
// module_2.js
|
||||
var featureName = "EcmaScript modules";
|
||||
var featureName = "ECMAScript modules";
|
||||
var year = 2018;
|
||||
|
||||
export function getFeatureDetails() {
|
||||
@@ -86,7 +86,7 @@ export function getFeatureDetails() {
|
||||
|
||||
### Module namespace import statements
|
||||
|
||||
A module namespace object can be imported. In this case the local binding will contain an object holding the exported values of the module, including local exports and all indirect exports. Ambiguous exported names are exluded from the namespace object.
|
||||
A module namespace object can be imported. In this case the local binding will contain an object holding the exported values of the module, including local exports and all indirect exports. Ambiguous exported names are excluded from the namespace object.
|
||||
|
||||
```js
|
||||
import * as module from './module.js';
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# Migration guide
|
||||
|
||||
This guide intends to describe the major changes between the JerryScript 1.0 and 2.0 versions.
|
||||
In addtion it is designed to provide a guide on how to modify the 1.0 version code to a
|
||||
In addition it is designed to provide a guide on how to modify the 1.0 version code to a
|
||||
2.0 compliant code.
|
||||
|
||||
During the development it was important to minimize the changes in the API functions and types.
|
||||
Each API method removal or chang is described below providing a ***before*** and ***after***
|
||||
Each API method removal or change is described below providing a ***before*** and ***after***
|
||||
code example.
|
||||
For more information on the current API methods please check the [API reference](02.API-REFERENCE.md) document.
|
||||
|
||||
@@ -53,7 +53,7 @@ For more information on the current API methods please check the [API reference]
|
||||
|
||||
## Error manipulating functions
|
||||
|
||||
The most important changes in the API are releated to error handling and manipulation.
|
||||
The most important changes in the API are related to error handling and manipulation.
|
||||
|
||||
### jerry_value_set_abort_flag
|
||||
|
||||
@@ -770,3 +770,12 @@ In this section the new API functions are listed.
|
||||
- [`jerry_port_get_current_context`](05.PORT-API.md#jerry_port_get_current_context)
|
||||
- [`jerry_port_fatal`](05.PORT-API.md#jerry_port_fatal)
|
||||
- [`jerry_port_sleep`](05.PORT-API.md#jerry_port_sleep)
|
||||
- [`jerry_port_print_byte`](05.PORT-API.md#jerry_port_print_byte)
|
||||
|
||||
# Migrating from 2.x to 3.x
|
||||
|
||||
The most significant change in JerryScript 3.0 was the API rework. Most of the API functions had been
|
||||
renamed in this version. There are notes for every such function in the [API Reference](02.API-REFERENCE.md)
|
||||
to help you to migrate from an older version. For example:
|
||||
|
||||
*Renamed in version 3.0, it was previously known as `jerry_get_global_object` in earlier versions.*
|
||||
|
||||
+62
-16
@@ -12,7 +12,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required (VERSION 2.8.12)
|
||||
cmake_minimum_required (VERSION 3.10)
|
||||
set(JERRY_CORE_NAME jerry-core)
|
||||
project (${JERRY_CORE_NAME} C)
|
||||
|
||||
@@ -24,19 +24,22 @@ set(JERRY_DEBUGGER OFF CACHE BOOL "Enable JerryScrip
|
||||
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_FUNCTION_TO_STRING OFF CACHE BOOL "Enable function toString operation?")
|
||||
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_PROMISE_CALLBACK OFF CACHE BOOL "Enable Promise callbacks?")
|
||||
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_VM_HALT OFF CACHE BOOL "Enable VM execution stop callback?")
|
||||
set(JERRY_VM_THROW OFF CACHE BOOL "Enable VM throw callback?")
|
||||
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")
|
||||
@@ -81,19 +84,22 @@ message(STATUS "JERRY_DEBUGGER " ${JERRY_DEBUGGER})
|
||||
message(STATUS "JERRY_ERROR_MESSAGES " ${JERRY_ERROR_MESSAGES})
|
||||
message(STATUS "JERRY_EXTERNAL_CONTEXT " ${JERRY_EXTERNAL_CONTEXT})
|
||||
message(STATUS "JERRY_PARSER " ${JERRY_PARSER})
|
||||
message(STATUS "JERRY_FUNCTION_TO_STRING " ${JERRY_FUNCTION_TO_STRING})
|
||||
message(STATUS "JERRY_LINE_INFO " ${JERRY_LINE_INFO})
|
||||
message(STATUS "JERRY_LOGGING " ${JERRY_LOGGING} ${JERRY_LOGGING_MESSAGE})
|
||||
message(STATUS "JERRY_MEM_STATS " ${JERRY_MEM_STATS})
|
||||
message(STATUS "JERRY_MEM_GC_BEFORE_EACH_ALLOC " ${JERRY_MEM_GC_BEFORE_EACH_ALLOC})
|
||||
message(STATUS "JERRY_PARSER_DUMP_BYTE_CODE " ${JERRY_PARSER_DUMP_BYTE_CODE} ${JERRY_PARSER_DUMP_MESSAGE})
|
||||
message(STATUS "JERRY_PROFILE " ${JERRY_PROFILE})
|
||||
message(STATUS "JERRY_PROMISE_CALLBACK " ${JERRY_PROMISE_CALLBACK})
|
||||
message(STATUS "JERRY_REGEXP_STRICT_MODE " ${JERRY_REGEXP_STRICT_MODE})
|
||||
message(STATUS "JERRY_REGEXP_DUMP_BYTE_CODE " ${JERRY_REGEXP_DUMP_BYTE_CODE})
|
||||
message(STATUS "JERRY_SNAPSHOT_EXEC " ${JERRY_SNAPSHOT_EXEC} ${JERRY_SNAPSHOT_EXEC_MESSAGE})
|
||||
message(STATUS "JERRY_SNAPSHOT_SAVE " ${JERRY_SNAPSHOT_SAVE} ${JERRY_SNAPSHOT_SAVE_MESSAGE})
|
||||
message(STATUS "JERRY_SYSTEM_ALLOCATOR " ${JERRY_SYSTEM_ALLOCATOR})
|
||||
message(STATUS "JERRY_VALGRIND " ${JERRY_VALGRIND})
|
||||
message(STATUS "JERRY_VM_EXEC_STOP " ${JERRY_VM_EXEC_STOP})
|
||||
message(STATUS "JERRY_VM_HALT " ${JERRY_VM_HALT})
|
||||
message(STATUS "JERRY_VM_THROW " ${JERRY_VM_THROW})
|
||||
message(STATUS "JERRY_GLOBAL_HEAP_SIZE " ${JERRY_GLOBAL_HEAP_SIZE})
|
||||
message(STATUS "JERRY_GC_LIMIT " ${JERRY_GC_LIMIT})
|
||||
message(STATUS "JERRY_STACK_LIMIT " ${JERRY_STACK_LIMIT})
|
||||
@@ -117,6 +123,13 @@ set(INCLUDE_CORE_PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/parser/regexp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/vm")
|
||||
|
||||
# Third-party
|
||||
# Valgrind
|
||||
set(INCLUDE_THIRD_PARTY_VALGRIND "${CMAKE_SOURCE_DIR}/third-party/valgrind")
|
||||
if(JERRY_VALGRIND)
|
||||
set(INCLUDE_CORE_PRIVATE ${INCLUDE_CORE_PRIVATE} ${INCLUDE_THIRD_PARTY_VALGRIND})
|
||||
endif()
|
||||
|
||||
set(INCLUDE_CORE_PUBLIC ${INCLUDE_CORE_PUBLIC} PARENT_SCOPE) # for jerry-port
|
||||
set(INCLUDE_CORE_PRIVATE ${INCLUDE_CORE_PRIVATE} PARENT_SCOPE) # for tests/unit-core
|
||||
|
||||
@@ -125,11 +138,14 @@ set(INCLUDE_CORE_PRIVATE ${INCLUDE_CORE_PRIVATE} PARENT_SCOPE) # for tests/unit-
|
||||
set(SOURCE_CORE_FILES
|
||||
api/jerry-debugger-transport.c
|
||||
api/jerry-debugger.c
|
||||
api/jerry-module.c
|
||||
api/jerry-snapshot.c
|
||||
api/jerry.c
|
||||
api/jerryscript.c
|
||||
debugger/debugger.c
|
||||
ecma/base/ecma-alloc.c
|
||||
ecma/base/ecma-gc.c
|
||||
ecma/base/ecma-errors.c
|
||||
ecma/base/ecma-extended-info.c
|
||||
ecma/base/ecma-helpers-collection.c
|
||||
ecma/base/ecma-helpers-conversion.c
|
||||
ecma/base/ecma-helpers-errol.c
|
||||
@@ -140,21 +156,26 @@ set(SOURCE_CORE_FILES
|
||||
ecma/base/ecma-helpers.c
|
||||
ecma/base/ecma-init-finalize.c
|
||||
ecma/base/ecma-lcache.c
|
||||
ecma/base/ecma-line-info.c
|
||||
ecma/base/ecma-literal-storage.c
|
||||
ecma/base/ecma-module.c
|
||||
ecma/base/ecma-property-hashmap.c
|
||||
ecma/builtin-objects/ecma-builtin-aggregateerror.c
|
||||
ecma/builtin-objects/ecma-builtin-aggregateerror-prototype.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-from-sync-iterator-prototype.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-atomics.c
|
||||
ecma/builtin-objects/ecma-builtin-bigint-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-bigint.c
|
||||
ecma/builtin-objects/ecma-builtin-boolean-prototype.c
|
||||
@@ -204,6 +225,8 @@ set(SOURCE_CORE_FILES
|
||||
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-shared-arraybuffer-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-shared-arraybuffer.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
|
||||
@@ -218,6 +241,8 @@ set(SOURCE_CORE_FILES
|
||||
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-weakref-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-weakref.c
|
||||
ecma/builtin-objects/ecma-builtin-weakset-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-weakset.c
|
||||
ecma/builtin-objects/ecma-builtins.c
|
||||
@@ -250,6 +275,7 @@ set(SOURCE_CORE_FILES
|
||||
ecma/operations/ecma-array-object.c
|
||||
ecma/operations/ecma-arraybuffer-object.c
|
||||
ecma/operations/ecma-async-generator-object.c
|
||||
ecma/operations/ecma-atomics-object.c
|
||||
ecma/operations/ecma-big-uint.c
|
||||
ecma/operations/ecma-bigint-object.c
|
||||
ecma/operations/ecma-bigint.c
|
||||
@@ -265,7 +291,6 @@ set(SOURCE_CORE_FILES
|
||||
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
|
||||
@@ -273,6 +298,7 @@ set(SOURCE_CORE_FILES
|
||||
ecma/operations/ecma-proxy-object.c
|
||||
ecma/operations/ecma-reference.c
|
||||
ecma/operations/ecma-regexp-object.c
|
||||
ecma/operations/ecma-shared-arraybuffer-object.c
|
||||
ecma/operations/ecma-string-object.c
|
||||
ecma/operations/ecma-symbol-object.c
|
||||
ecma/operations/ecma-typedarray-object.c
|
||||
@@ -281,6 +307,7 @@ set(SOURCE_CORE_FILES
|
||||
jmem/jmem-heap.c
|
||||
jmem/jmem-poolman.c
|
||||
jrt/jrt-fatals.c
|
||||
jrt/jrt-logging.c
|
||||
lit/lit-char-helpers.c
|
||||
lit/lit-magic-strings.c
|
||||
lit/lit-strings.c
|
||||
@@ -288,6 +315,7 @@ set(SOURCE_CORE_FILES
|
||||
parser/js/common.c
|
||||
parser/js/js-lexer.c
|
||||
parser/js/js-parser-expr.c
|
||||
parser/js/js-parser-line-info-create.c
|
||||
parser/js/js-parser-mem.c
|
||||
parser/js/js-parser-module.c
|
||||
parser/js/js-parser-statm.c
|
||||
@@ -297,6 +325,7 @@ set(SOURCE_CORE_FILES
|
||||
parser/js/js-scanner-ops.c
|
||||
parser/js/js-scanner-util.c
|
||||
parser/js/js-scanner.c
|
||||
parser/js/parser-errors.c
|
||||
parser/regexp/re-bytecode.c
|
||||
parser/regexp/re-compiler.c
|
||||
parser/regexp/re-parser.c
|
||||
@@ -321,26 +350,33 @@ if(ENABLE_AMALGAM)
|
||||
api/jerry-snapshot.h
|
||||
debugger/debugger.h
|
||||
ecma/base/ecma-alloc.h
|
||||
ecma/base/ecma-error-messages.inc.h
|
||||
ecma/base/ecma-errors.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-line-info.h
|
||||
ecma/base/ecma-literal-storage.h
|
||||
ecma/base/ecma-module.h
|
||||
ecma/base/ecma-property-hashmap.h
|
||||
ecma/builtin-objects/ecma-builtin-aggregateerror-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-aggregateerror.inc.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-from-sync-iterator-prototype.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-atomics.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
|
||||
@@ -392,6 +428,8 @@ if(ENABLE_AMALGAM)
|
||||
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-shared-arraybuffer-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-shared-arraybuffer.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
|
||||
@@ -406,6 +444,8 @@ if(ENABLE_AMALGAM)
|
||||
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-weakref-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-weakref.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
|
||||
@@ -415,6 +455,7 @@ if(ENABLE_AMALGAM)
|
||||
ecma/operations/ecma-array-object.h
|
||||
ecma/operations/ecma-arraybuffer-object.h
|
||||
ecma/operations/ecma-async-generator-object.h
|
||||
ecma/operations/ecma-atomics-object.h
|
||||
ecma/operations/ecma-big-uint.h
|
||||
ecma/operations/ecma-bigint-object.h
|
||||
ecma/operations/ecma-bigint.h
|
||||
@@ -429,7 +470,6 @@ if(ENABLE_AMALGAM)
|
||||
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
|
||||
@@ -437,6 +477,7 @@ if(ENABLE_AMALGAM)
|
||||
ecma/operations/ecma-proxy-object.h
|
||||
ecma/operations/ecma-reference.h
|
||||
ecma/operations/ecma-regexp-object.h
|
||||
ecma/operations/ecma-shared-arraybuffer-object.h
|
||||
ecma/operations/ecma-string-object.h
|
||||
ecma/operations/ecma-symbol-object.h
|
||||
ecma/operations/ecma-typedarray-object.h
|
||||
@@ -476,7 +517,7 @@ if(ENABLE_AMALGAM)
|
||||
set(AMALGAM_CONFIG_H "${CMAKE_BINARY_DIR}/amalgam/jerryscript-config.h")
|
||||
|
||||
add_custom_command(OUTPUT ${AMALGAM_CORE_C} ${AMALGAM_CORE_H}
|
||||
COMMAND python ${CMAKE_SOURCE_DIR}/tools/amalgam.py
|
||||
COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/tools/amalgam.py
|
||||
--jerry-core
|
||||
--output-dir ${CMAKE_BINARY_DIR}/amalgam
|
||||
DEPENDS ${SOURCE_CORE_FILES}
|
||||
@@ -495,12 +536,10 @@ if(ENABLE_AMALGAM)
|
||||
add_dependencies(amalgam amalgam-jerry)
|
||||
|
||||
set(SOURCE_CORE_FILES ${AMALGAM_CORE_C} ${AMALGAM_CORE_H} ${AMALGAM_CONFIG_H})
|
||||
set(INCLUDE_CORE_PUBLIC PARENT_SCOPE)
|
||||
set(INCLUDE_CORE_PRIVATE PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
# Third-party
|
||||
# Valgrind
|
||||
set(INCLUDE_THIRD_PARTY_VALGRIND "${CMAKE_SOURCE_DIR}/third-party/valgrind")
|
||||
|
||||
# build mode specific compile/link flags
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} $<$<NOT:$<CONFIG:Debug>>:JERRY_NDEBUG>)
|
||||
|
||||
@@ -536,6 +575,9 @@ jerry_add_define01(JERRY_EXTERNAL_CONTEXT)
|
||||
# JS-Parser
|
||||
jerry_add_define01(JERRY_PARSER)
|
||||
|
||||
# JS function toString
|
||||
jerry_add_define01(JERRY_FUNCTION_TO_STRING)
|
||||
|
||||
# JS line info
|
||||
jerry_add_define01(JERRY_LINE_INFO)
|
||||
|
||||
@@ -582,6 +624,9 @@ else()
|
||||
message(FATAL_ERROR "Profile file: '${JERRY_PROFILE}' doesn't exist!")
|
||||
endif()
|
||||
|
||||
# Promise callback
|
||||
jerry_add_define01(JERRY_PROMISE_CALLBACK)
|
||||
|
||||
# RegExp strict mode
|
||||
jerry_add_define01(JERRY_REGEXP_STRICT_MODE)
|
||||
|
||||
@@ -599,12 +644,12 @@ jerry_add_define01(JERRY_SYSTEM_ALLOCATOR)
|
||||
|
||||
# Valgrind
|
||||
jerry_add_define01(JERRY_VALGRIND)
|
||||
if(JERRY_VALGRIND)
|
||||
set(INCLUDE_CORE_PRIVATE ${INCLUDE_CORE_PRIVATE} ${INCLUDE_THIRD_PARTY_VALGRIND})
|
||||
endif()
|
||||
|
||||
# Enable VM execution stopping
|
||||
jerry_add_define01(JERRY_VM_EXEC_STOP)
|
||||
# Enable VM execution stop callback
|
||||
jerry_add_define01(JERRY_VM_HALT)
|
||||
|
||||
# Enable VM throw callback
|
||||
jerry_add_define01(JERRY_VM_THROW)
|
||||
|
||||
# Size of heap
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_GLOBAL_HEAP_SIZE=${JERRY_GLOBAL_HEAP_SIZE})
|
||||
@@ -702,6 +747,7 @@ add_library(${JERRY_CORE_NAME} ${SOURCE_CORE_FILES})
|
||||
target_compile_definitions(${JERRY_CORE_NAME} PUBLIC ${DEFINES_JERRY})
|
||||
target_include_directories(${JERRY_CORE_NAME} PUBLIC ${INCLUDE_CORE_PUBLIC})
|
||||
target_include_directories(${JERRY_CORE_NAME} PRIVATE ${INCLUDE_CORE_PRIVATE})
|
||||
add_dependencies(${JERRY_CORE_NAME} amalgam)
|
||||
|
||||
set(JERRY_CORE_PKGCONFIG_REQUIRES)
|
||||
set(JERRY_CORE_PKGCONFIG_LIBS)
|
||||
|
||||
@@ -13,11 +13,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "debugger.h"
|
||||
#include "jcontext.h"
|
||||
#include "jerryscript.h"
|
||||
|
||||
#if ENABLED (JERRY_DEBUGGER)
|
||||
#include "debugger.h"
|
||||
#include "jcontext.h"
|
||||
|
||||
#if JERRY_DEBUGGER
|
||||
|
||||
/**
|
||||
* Minimum number of bytes transmitted or received.
|
||||
@@ -137,10 +138,9 @@ jerry_debugger_transport_close (void)
|
||||
current_p->close (current_p);
|
||||
|
||||
current_p = next_p;
|
||||
}
|
||||
while (current_p != NULL);
|
||||
} while (current_p != NULL);
|
||||
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "Debugger client connection closed.\n");
|
||||
jerry_log (JERRY_LOG_LEVEL_DEBUG, "Debugger client connection closed.\n");
|
||||
|
||||
jerry_debugger_free_unreferenced_byte_code ();
|
||||
} /* jerry_debugger_transport_close */
|
||||
@@ -164,8 +164,7 @@ jerry_debugger_transport_send (const uint8_t *message_p, /**< message to be sent
|
||||
|
||||
do
|
||||
{
|
||||
size_t fragment_length = (message_length <= max_send_size ? message_length
|
||||
: max_send_size);
|
||||
size_t fragment_length = (message_length <= max_send_size ? message_length : max_send_size);
|
||||
|
||||
memcpy (payload_p, message_p, fragment_length);
|
||||
|
||||
@@ -176,8 +175,7 @@ jerry_debugger_transport_send (const uint8_t *message_p, /**< message to be sent
|
||||
|
||||
message_p += fragment_length;
|
||||
message_length -= fragment_length;
|
||||
}
|
||||
while (message_length > 0);
|
||||
} while (message_length > 0);
|
||||
|
||||
return true;
|
||||
} /* jerry_debugger_transport_send */
|
||||
@@ -247,4 +245,4 @@ jerry_debugger_transport_sleep (void)
|
||||
jerry_port_sleep (JERRY_DEBUGGER_TRANSPORT_TIMEOUT);
|
||||
} /* jerry_debugger_transport_sleep */
|
||||
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
|
||||
@@ -13,9 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "jerryscript.h"
|
||||
|
||||
#include "debugger.h"
|
||||
#include "jcontext.h"
|
||||
#include "jerryscript.h"
|
||||
|
||||
/**
|
||||
* Checks whether the debugger is connected.
|
||||
@@ -26,11 +27,11 @@
|
||||
bool
|
||||
jerry_debugger_is_connected (void)
|
||||
{
|
||||
#if ENABLED (JERRY_DEBUGGER)
|
||||
#if JERRY_DEBUGGER
|
||||
return JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED;
|
||||
#else /* !ENABLED (JERRY_DEBUGGER) */
|
||||
#else /* !JERRY_DEBUGGER */
|
||||
return false;
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
} /* jerry_debugger_is_connected */
|
||||
|
||||
/**
|
||||
@@ -39,14 +40,14 @@ jerry_debugger_is_connected (void)
|
||||
void
|
||||
jerry_debugger_stop (void)
|
||||
{
|
||||
#if ENABLED (JERRY_DEBUGGER)
|
||||
#if JERRY_DEBUGGER
|
||||
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
|
||||
&& !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
|
||||
{
|
||||
JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_STOP);
|
||||
JERRY_CONTEXT (debugger_stop_context) = NULL;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
} /* jerry_debugger_stop */
|
||||
|
||||
/**
|
||||
@@ -55,14 +56,14 @@ jerry_debugger_stop (void)
|
||||
void
|
||||
jerry_debugger_continue (void)
|
||||
{
|
||||
#if ENABLED (JERRY_DEBUGGER)
|
||||
#if JERRY_DEBUGGER
|
||||
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
|
||||
&& !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
|
||||
{
|
||||
JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_VM_STOP);
|
||||
JERRY_CONTEXT (debugger_stop_context) = NULL;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
} /* jerry_debugger_continue */
|
||||
|
||||
/**
|
||||
@@ -71,7 +72,7 @@ jerry_debugger_continue (void)
|
||||
void
|
||||
jerry_debugger_stop_at_breakpoint (bool enable_stop_at_breakpoint) /**< enable/disable stop at breakpoint */
|
||||
{
|
||||
#if ENABLED (JERRY_DEBUGGER)
|
||||
#if JERRY_DEBUGGER
|
||||
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED
|
||||
&& !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
|
||||
{
|
||||
@@ -84,9 +85,9 @@ jerry_debugger_stop_at_breakpoint (bool enable_stop_at_breakpoint) /**< enable/d
|
||||
JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_VM_IGNORE);
|
||||
}
|
||||
}
|
||||
#else /* !ENABLED (JERRY_DEBUGGER) */
|
||||
#else /* !JERRY_DEBUGGER */
|
||||
JERRY_UNUSED (enable_stop_at_breakpoint);
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
} /* jerry_debugger_stop_at_breakpoint */
|
||||
|
||||
/**
|
||||
@@ -102,9 +103,9 @@ jerry_debugger_wait_for_client_source (jerry_debugger_wait_for_source_callback_t
|
||||
void *user_p, /**< user pointer passed to the callback */
|
||||
jerry_value_t *return_value) /**< [out] parse and run return value */
|
||||
{
|
||||
*return_value = jerry_create_undefined ();
|
||||
*return_value = jerry_undefined ();
|
||||
|
||||
#if ENABLED (JERRY_DEBUGGER)
|
||||
#if JERRY_DEBUGGER
|
||||
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
|
||||
&& !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
|
||||
{
|
||||
@@ -145,13 +146,13 @@ jerry_debugger_wait_for_client_source (jerry_debugger_wait_for_source_callback_t
|
||||
{
|
||||
JERRY_ASSERT (client_source_data_p != NULL);
|
||||
|
||||
jerry_char_t *resource_name_p = (jerry_char_t *) (client_source_data_p + 1);
|
||||
size_t resource_name_size = strlen ((const char *) resource_name_p);
|
||||
jerry_char_t *source_name_p = (jerry_char_t *) (client_source_data_p + 1);
|
||||
size_t source_name_size = strlen ((const char *) source_name_p);
|
||||
|
||||
*return_value = callback_p (resource_name_p,
|
||||
resource_name_size,
|
||||
resource_name_p + resource_name_size + 1,
|
||||
client_source_data_p->uint8_size - resource_name_size - 1,
|
||||
*return_value = callback_p (source_name_p,
|
||||
source_name_size,
|
||||
source_name_p + source_name_size + 1,
|
||||
client_source_data_p->uint8_size - source_name_size - 1,
|
||||
user_p);
|
||||
|
||||
ret_type = JERRY_DEBUGGER_SOURCE_RECEIVED;
|
||||
@@ -176,12 +177,12 @@ jerry_debugger_wait_for_client_source (jerry_debugger_wait_for_source_callback_t
|
||||
}
|
||||
|
||||
return JERRY_DEBUGGER_SOURCE_RECEIVE_FAILED;
|
||||
#else /* !ENABLED (JERRY_DEBUGGER) */
|
||||
#else /* !JERRY_DEBUGGER */
|
||||
JERRY_UNUSED (callback_p);
|
||||
JERRY_UNUSED (user_p);
|
||||
|
||||
return JERRY_DEBUGGER_SOURCE_RECEIVE_FAILED;
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
} /* jerry_debugger_wait_for_client_source */
|
||||
|
||||
/**
|
||||
@@ -192,39 +193,16 @@ void
|
||||
jerry_debugger_send_output (const jerry_char_t *buffer, /**< buffer */
|
||||
jerry_size_t str_size) /**< string size */
|
||||
{
|
||||
#if ENABLED (JERRY_DEBUGGER)
|
||||
#if JERRY_DEBUGGER
|
||||
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
|
||||
{
|
||||
jerry_debugger_send_string (JERRY_DEBUGGER_OUTPUT_RESULT,
|
||||
JERRY_DEBUGGER_OUTPUT_OK,
|
||||
JERRY_DEBUGGER_OUTPUT_PRINT,
|
||||
(const uint8_t *) buffer,
|
||||
sizeof (uint8_t) * str_size);
|
||||
}
|
||||
#else /* !ENABLED (JERRY_DEBUGGER) */
|
||||
#else /* !JERRY_DEBUGGER */
|
||||
JERRY_UNUSED (buffer);
|
||||
JERRY_UNUSED (str_size);
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
} /* jerry_debugger_send_output */
|
||||
|
||||
/**
|
||||
* Send the log of the program to the debugger client.
|
||||
*/
|
||||
void
|
||||
jerry_debugger_send_log (jerry_log_level_t level, /**< level of the diagnostics message */
|
||||
const jerry_char_t *buffer, /**< buffer */
|
||||
jerry_size_t str_size) /**< string size */
|
||||
{
|
||||
#if ENABLED (JERRY_DEBUGGER)
|
||||
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
|
||||
{
|
||||
jerry_debugger_send_string (JERRY_DEBUGGER_OUTPUT_RESULT,
|
||||
(uint8_t) (level + 2),
|
||||
(const uint8_t *) buffer,
|
||||
sizeof (uint8_t) * str_size);
|
||||
}
|
||||
#else /* !ENABLED (JERRY_DEBUGGER) */
|
||||
JERRY_UNUSED (level);
|
||||
JERRY_UNUSED (buffer);
|
||||
JERRY_UNUSED (str_size);
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
} /* jerry_debugger_send_log */
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
/* 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 "jerryscript-core.h"
|
||||
#include "jerryscript-port.h"
|
||||
|
||||
#include "ecma-errors.h"
|
||||
|
||||
#include "lit-magic-strings.h"
|
||||
#include "lit-strings.h"
|
||||
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
|
||||
/**
|
||||
* A module descriptor.
|
||||
*/
|
||||
typedef struct jerry_module_t
|
||||
{
|
||||
struct jerry_module_t *next_p; /**< next_module */
|
||||
jerry_char_t *path_p; /**< path to the module */
|
||||
jerry_size_t basename_offset; /**< offset of the basename in the module path*/
|
||||
jerry_value_t realm; /**< the realm of the module */
|
||||
jerry_value_t module; /**< the module itself */
|
||||
} jerry_module_t;
|
||||
|
||||
/**
|
||||
* Native info descriptor for modules.
|
||||
*/
|
||||
static const jerry_object_native_info_t jerry_module_native_info JERRY_ATTR_CONST_DATA = {
|
||||
.free_cb = NULL,
|
||||
};
|
||||
|
||||
/**
|
||||
* Default module manager.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
jerry_module_t *module_head_p; /**< first module */
|
||||
} jerry_module_manager_t;
|
||||
|
||||
/**
|
||||
* Release known modules.
|
||||
*/
|
||||
static void
|
||||
jerry_module_free (jerry_module_manager_t *manager_p, /**< module manager */
|
||||
const jerry_value_t realm) /**< if this argument is object, release only those modules,
|
||||
* which realm value is equal to this argument. */
|
||||
{
|
||||
jerry_module_t *module_p = manager_p->module_head_p;
|
||||
|
||||
bool release_all = !jerry_value_is_object (realm);
|
||||
|
||||
jerry_module_t *prev_p = NULL;
|
||||
|
||||
while (module_p != NULL)
|
||||
{
|
||||
jerry_module_t *next_p = module_p->next_p;
|
||||
|
||||
if (release_all || module_p->realm == realm)
|
||||
{
|
||||
jerry_port_path_free (module_p->path_p);
|
||||
jerry_value_free (module_p->realm);
|
||||
jerry_value_free (module_p->module);
|
||||
|
||||
jerry_heap_free (module_p, sizeof (jerry_module_t));
|
||||
|
||||
if (prev_p == NULL)
|
||||
{
|
||||
manager_p->module_head_p = next_p;
|
||||
}
|
||||
else
|
||||
{
|
||||
prev_p->next_p = next_p;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
prev_p = module_p;
|
||||
}
|
||||
|
||||
module_p = next_p;
|
||||
}
|
||||
} /* jerry_module_free */
|
||||
|
||||
/**
|
||||
* Initialize the default module manager.
|
||||
*/
|
||||
static void
|
||||
jerry_module_manager_init (void *user_data_p)
|
||||
{
|
||||
((jerry_module_manager_t *) user_data_p)->module_head_p = NULL;
|
||||
} /* jerry_module_manager_init */
|
||||
|
||||
/**
|
||||
* Deinitialize the default module manager.
|
||||
*/
|
||||
static void
|
||||
jerry_module_manager_deinit (void *user_data_p) /**< context pointer to deinitialize */
|
||||
{
|
||||
jerry_value_t undef = jerry_undefined ();
|
||||
jerry_module_free ((jerry_module_manager_t *) user_data_p, undef);
|
||||
jerry_value_free (undef);
|
||||
} /* jerry_module_manager_deinit */
|
||||
|
||||
/**
|
||||
* Declare the context data manager for modules.
|
||||
*/
|
||||
static const jerry_context_data_manager_t jerry_module_manager JERRY_ATTR_CONST_DATA = {
|
||||
.init_cb = jerry_module_manager_init,
|
||||
.deinit_cb = jerry_module_manager_deinit,
|
||||
.bytes_needed = sizeof (jerry_module_manager_t)
|
||||
};
|
||||
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
|
||||
/**
|
||||
* Default module resolver.
|
||||
*
|
||||
* @return a module object if resolving is successful, an error otherwise
|
||||
*/
|
||||
jerry_value_t
|
||||
jerry_module_resolve (const jerry_value_t specifier, /**< module specifier string */
|
||||
const jerry_value_t referrer, /**< parent module */
|
||||
void *user_p) /**< user data */
|
||||
{
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
JERRY_UNUSED (user_p);
|
||||
|
||||
const jerry_char_t *directory_p = lit_get_magic_string_utf8 (LIT_MAGIC_STRING__EMPTY);
|
||||
jerry_size_t directory_size = lit_get_magic_string_size (LIT_MAGIC_STRING__EMPTY);
|
||||
|
||||
jerry_module_t *module_p = jerry_object_get_native_ptr (referrer, &jerry_module_native_info);
|
||||
|
||||
if (module_p != NULL)
|
||||
{
|
||||
directory_p = module_p->path_p;
|
||||
directory_size = module_p->basename_offset;
|
||||
}
|
||||
|
||||
jerry_size_t specifier_size = jerry_string_size (specifier, JERRY_ENCODING_UTF8);
|
||||
jerry_size_t reference_size = directory_size + specifier_size;
|
||||
jerry_char_t *reference_path_p = jerry_heap_alloc (reference_size + 1);
|
||||
|
||||
memcpy (reference_path_p, directory_p, directory_size);
|
||||
jerry_string_to_buffer (specifier, JERRY_ENCODING_UTF8, reference_path_p + directory_size, specifier_size);
|
||||
reference_path_p[reference_size] = '\0';
|
||||
|
||||
jerry_char_t *path_p = jerry_port_path_normalize (reference_path_p, reference_size);
|
||||
jerry_heap_free (reference_path_p, reference_size + 1);
|
||||
|
||||
if (path_p == NULL)
|
||||
{
|
||||
return jerry_throw_sz (JERRY_ERROR_SYNTAX, "Failed to resolve module");
|
||||
}
|
||||
|
||||
jerry_value_t realm = jerry_current_realm ();
|
||||
|
||||
jerry_module_manager_t *manager_p;
|
||||
manager_p = (jerry_module_manager_t *) jerry_context_data (&jerry_module_manager);
|
||||
|
||||
module_p = manager_p->module_head_p;
|
||||
|
||||
while (module_p != NULL)
|
||||
{
|
||||
if (module_p->realm == realm && strcmp ((const char *) module_p->path_p, (const char *) path_p) == 0)
|
||||
{
|
||||
jerry_value_free (realm);
|
||||
jerry_port_path_free (path_p);
|
||||
return jerry_value_copy (module_p->module);
|
||||
}
|
||||
|
||||
module_p = module_p->next_p;
|
||||
}
|
||||
|
||||
jerry_size_t source_size;
|
||||
jerry_char_t *source_p = jerry_port_source_read ((const char *) path_p, &source_size);
|
||||
|
||||
if (source_p == NULL)
|
||||
{
|
||||
jerry_value_free (realm);
|
||||
jerry_port_path_free (path_p);
|
||||
|
||||
return jerry_throw_sz (JERRY_ERROR_SYNTAX, "Module file not found");
|
||||
}
|
||||
|
||||
jerry_parse_options_t parse_options;
|
||||
parse_options.options = JERRY_PARSE_MODULE | JERRY_PARSE_HAS_SOURCE_NAME;
|
||||
parse_options.source_name = jerry_value_copy (specifier);
|
||||
|
||||
jerry_value_t ret_value = jerry_parse (source_p, source_size, &parse_options);
|
||||
jerry_value_free (parse_options.source_name);
|
||||
|
||||
jerry_port_source_free (source_p);
|
||||
|
||||
if (jerry_value_is_exception (ret_value))
|
||||
{
|
||||
jerry_port_path_free (path_p);
|
||||
jerry_value_free (realm);
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
module_p = (jerry_module_t *) jerry_heap_alloc (sizeof (jerry_module_t));
|
||||
|
||||
module_p->next_p = manager_p->module_head_p;
|
||||
module_p->path_p = path_p;
|
||||
module_p->basename_offset = jerry_port_path_base (module_p->path_p);
|
||||
module_p->realm = realm;
|
||||
module_p->module = jerry_value_copy (ret_value);
|
||||
|
||||
jerry_object_set_native_ptr (ret_value, &jerry_module_native_info, module_p);
|
||||
manager_p->module_head_p = module_p;
|
||||
|
||||
return ret_value;
|
||||
#else /* JERRY_MODULE_SYSTEM */
|
||||
JERRY_UNUSED (specifier);
|
||||
JERRY_UNUSED (referrer);
|
||||
JERRY_UNUSED (user_p);
|
||||
|
||||
return jerry_throw_sz (JERRY_ERROR_TYPE, ecma_get_error_msg (ECMA_ERR_MODULE_NOT_SUPPORTED));
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
} /* jerry_module_resolve */
|
||||
|
||||
/**
|
||||
* Release known modules.
|
||||
*/
|
||||
void
|
||||
jerry_module_cleanup (const jerry_value_t realm) /**< if this argument is object, release only those modules,
|
||||
* whose realm value is equal to this argument. */
|
||||
{
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
jerry_module_free ((jerry_module_manager_t *) jerry_context_data (&jerry_module_manager), realm);
|
||||
#else /* JERRY_MODULE_SYSTEM */
|
||||
JERRY_UNUSED (realm);
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
} /* jerry_module_cleanup */
|
||||
+279
-436
File diff suppressed because it is too large
Load Diff
@@ -45,8 +45,7 @@ typedef enum
|
||||
{
|
||||
/* 8 bits are reserved for dynamic features */
|
||||
JERRY_SNAPSHOT_HAS_REGEX_LITERAL = (1u << 0), /**< byte code has regex 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 */
|
||||
JERRY_SNAPSHOT_HAS_CLASS_LITERAL = (1u << 1), /**< 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;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+267
-309
@@ -29,102 +29,95 @@
|
||||
* By default all built-ins are enabled if they are not defined.
|
||||
*/
|
||||
#ifndef JERRY_BUILTINS
|
||||
# define JERRY_BUILTINS 1
|
||||
#define JERRY_BUILTINS 1
|
||||
#endif /* !defined (JERRY_BUILTINS) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_ANNEXB
|
||||
# define JERRY_BUILTIN_ANNEXB JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_ANNEXB JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_ANNEXB) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_ARRAY
|
||||
# define JERRY_BUILTIN_ARRAY JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_ARRAY JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_ARRAY) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_BOOLEAN
|
||||
# define JERRY_BUILTIN_BOOLEAN JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_BOOLEAN JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_BOOLEAN) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_DATE
|
||||
# define JERRY_BUILTIN_DATE JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_DATE JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_DATE) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_ERRORS
|
||||
# define JERRY_BUILTIN_ERRORS JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_ERRORS JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_ERRORS) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_JSON
|
||||
# define JERRY_BUILTIN_JSON JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_JSON JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_JSON) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_MATH
|
||||
# define JERRY_BUILTIN_MATH JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_MATH JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_MATH) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_NUMBER
|
||||
# define JERRY_BUILTIN_NUMBER JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_NUMBER JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_NUMBER) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_REGEXP
|
||||
# define JERRY_BUILTIN_REGEXP JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_REGEXP JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_REGEXP) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_STRING
|
||||
# define JERRY_BUILTIN_STRING JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_STRING JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_STRING) */
|
||||
|
||||
/**
|
||||
* ES2015+ related features, by default all of them are enabled.
|
||||
*/
|
||||
#ifndef JERRY_ESNEXT
|
||||
# define JERRY_ESNEXT 1
|
||||
#endif /* !defined (JERRY_ESNEXT) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_BIGINT
|
||||
# define JERRY_BUILTIN_BIGINT JERRY_ESNEXT
|
||||
#define JERRY_BUILTIN_BIGINT JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_BIGINT) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_CONTAINER
|
||||
#define JERRY_BUILTIN_CONTAINER JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_CONTAINER) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_DATAVIEW
|
||||
# define JERRY_BUILTIN_DATAVIEW JERRY_ESNEXT
|
||||
#define JERRY_BUILTIN_DATAVIEW JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_DATAVIEW) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_MAP
|
||||
# define JERRY_BUILTIN_MAP JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_MAP) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_PROMISE
|
||||
# define JERRY_BUILTIN_PROMISE JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_PROMISE) */
|
||||
#ifndef JERRY_BUILTIN_GLOBAL_THIS
|
||||
#define JERRY_BUILTIN_GLOBAL_THIS JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_GLOBAL_THIS) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_PROXY
|
||||
# define JERRY_BUILTIN_PROXY JERRY_ESNEXT
|
||||
#define JERRY_BUILTIN_PROXY JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_PROXY) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_REALMS
|
||||
# define JERRY_BUILTIN_REALMS JERRY_ESNEXT
|
||||
#define JERRY_BUILTIN_REALMS JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_REALMS) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_REFLECT
|
||||
# define JERRY_BUILTIN_REFLECT JERRY_ESNEXT
|
||||
#define JERRY_BUILTIN_REFLECT JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_REFLECT) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_SET
|
||||
# define JERRY_BUILTIN_SET JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_SET) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_TYPEDARRAY
|
||||
# define JERRY_BUILTIN_TYPEDARRAY JERRY_ESNEXT
|
||||
#define JERRY_BUILTIN_TYPEDARRAY JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_TYPEDARRAY) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_WEAKMAP
|
||||
# define JERRY_BUILTIN_WEAKMAP JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_WEAKMAP) */
|
||||
#ifndef JERRY_BUILTIN_SHAREDARRAYBUFFER
|
||||
#define JERRY_BUILTIN_SHAREDARRAYBUFFER JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_SHAREDARRAYBUFFER) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_WEAKSET
|
||||
# define JERRY_BUILTIN_WEAKSET JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_WEAKSET) */
|
||||
#ifndef JERRY_BUILTIN_ATOMICS
|
||||
#define JERRY_BUILTIN_ATOMICS JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_ATOMICS) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_WEAKREF
|
||||
#define JERRY_BUILTIN_WEAKREF JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_WEAKREF) */
|
||||
|
||||
#ifndef JERRY_MODULE_SYSTEM
|
||||
# define JERRY_MODULE_SYSTEM JERRY_ESNEXT
|
||||
#define JERRY_MODULE_SYSTEM JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
/**
|
||||
@@ -142,7 +135,7 @@
|
||||
* For more details see: jmem/jmem.h
|
||||
*/
|
||||
#ifndef JERRY_CPOINTER_32_BIT
|
||||
# define JERRY_CPOINTER_32_BIT 0
|
||||
#define JERRY_CPOINTER_32_BIT 0
|
||||
#endif /* !defined (JERRY_CPOINTER_32_BIT) */
|
||||
|
||||
/**
|
||||
@@ -153,7 +146,7 @@
|
||||
* 1: Enable the debugger.
|
||||
*/
|
||||
#ifndef JERRY_DEBUGGER
|
||||
# define JERRY_DEBUGGER 0
|
||||
#define JERRY_DEBUGGER 0
|
||||
#endif /* !defined (JERRY_DEBUGGER) */
|
||||
|
||||
/**
|
||||
@@ -166,7 +159,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_ERROR_MESSAGES
|
||||
# define JERRY_ERROR_MESSAGES 0
|
||||
#define JERRY_ERROR_MESSAGES 0
|
||||
#endif /* !defined (JERRY_ERROR_MESSAGES) */
|
||||
|
||||
/**
|
||||
@@ -179,7 +172,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_EXTERNAL_CONTEXT
|
||||
# define JERRY_EXTERNAL_CONTEXT 0
|
||||
#define JERRY_EXTERNAL_CONTEXT 0
|
||||
#endif /* !defined (JERRY_EXTERNAL_CONTEXT) */
|
||||
|
||||
/**
|
||||
@@ -188,7 +181,7 @@
|
||||
* Default value: 512 KiB
|
||||
*/
|
||||
#ifndef JERRY_GLOBAL_HEAP_SIZE
|
||||
# define JERRY_GLOBAL_HEAP_SIZE (512)
|
||||
#define JERRY_GLOBAL_HEAP_SIZE (512)
|
||||
#endif /* !defined (JERRY_GLOBAL_HEAP_SIZE) */
|
||||
|
||||
/**
|
||||
@@ -197,7 +190,7 @@
|
||||
* If value is 0, the default is 1/32 of JERRY_HEAP_SIZE
|
||||
*/
|
||||
#ifndef JERRY_GC_LIMIT
|
||||
# define JERRY_GC_LIMIT 0
|
||||
#define JERRY_GC_LIMIT 0
|
||||
#endif /* !defined (JERRY_GC_LIMIT) */
|
||||
|
||||
/**
|
||||
@@ -210,7 +203,7 @@
|
||||
* Default value: 0, unlimited
|
||||
*/
|
||||
#ifndef JERRY_STACK_LIMIT
|
||||
# define JERRY_STACK_LIMIT (0)
|
||||
#define JERRY_STACK_LIMIT (0)
|
||||
#endif /* !defined (JERRY_STACK_LIMIT) */
|
||||
|
||||
/**
|
||||
@@ -219,7 +212,7 @@
|
||||
* Default value: 8
|
||||
*/
|
||||
#ifndef JERRY_GC_MARK_LIMIT
|
||||
# define JERRY_GC_MARK_LIMIT (8)
|
||||
#define JERRY_GC_MARK_LIMIT (8)
|
||||
#endif /* !defined (JERRY_GC_MARK_LIMIT) */
|
||||
|
||||
/**
|
||||
@@ -232,9 +225,22 @@
|
||||
* Default value: 1
|
||||
*/
|
||||
#ifndef JERRY_LCACHE
|
||||
# define JERRY_LCACHE 1
|
||||
#define JERRY_LCACHE 1
|
||||
#endif /* !defined (JERRY_LCACHE) */
|
||||
|
||||
/**
|
||||
* Enable/Disable function toString operation.
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable function toString operation.
|
||||
* 1: Enable function toString operation.
|
||||
*
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_FUNCTION_TO_STRING
|
||||
#define JERRY_FUNCTION_TO_STRING 0
|
||||
#endif /* !defined (JERRY_FUNCTION_TO_STRING) */
|
||||
|
||||
/**
|
||||
* Enable/Disable line-info management inside the engine.
|
||||
*
|
||||
@@ -245,7 +251,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_LINE_INFO
|
||||
# define JERRY_LINE_INFO 0
|
||||
#define JERRY_LINE_INFO 0
|
||||
#endif /* !defined (JERRY_LINE_INFO) */
|
||||
|
||||
/**
|
||||
@@ -258,7 +264,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_LOGGING
|
||||
# define JERRY_LOGGING 0
|
||||
#define JERRY_LOGGING 0
|
||||
#endif /* !defined (JERRY_LOGGING) */
|
||||
|
||||
/**
|
||||
@@ -273,7 +279,7 @@
|
||||
* Only enable it for debugging purposes.
|
||||
*/
|
||||
#ifndef JERRY_MEM_GC_BEFORE_EACH_ALLOC
|
||||
# define JERRY_MEM_GC_BEFORE_EACH_ALLOC 0
|
||||
#define JERRY_MEM_GC_BEFORE_EACH_ALLOC 0
|
||||
#endif /* !defined (JERRY_MEM_GC_BEFORE_EACH_ALLOC) */
|
||||
|
||||
/**
|
||||
@@ -286,7 +292,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_MEM_STATS
|
||||
# define JERRY_MEM_STATS 0
|
||||
#define JERRY_MEM_STATS 0
|
||||
#endif /* !defined (JERRY_MEM_STATS) */
|
||||
|
||||
/**
|
||||
@@ -300,7 +306,7 @@
|
||||
* Default value: 1
|
||||
*/
|
||||
#ifndef JERRY_NUMBER_TYPE_FLOAT64
|
||||
# define JERRY_NUMBER_TYPE_FLOAT64 1
|
||||
#define JERRY_NUMBER_TYPE_FLOAT64 1
|
||||
#endif /* !defined (JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
@@ -313,7 +319,7 @@
|
||||
* Default value: 1
|
||||
*/
|
||||
#ifndef JERRY_PARSER
|
||||
# define JERRY_PARSER 1
|
||||
#define JERRY_PARSER 1
|
||||
#endif /* !defined (JERRY_PARSER) */
|
||||
|
||||
/**
|
||||
@@ -328,7 +334,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_PARSER_DUMP_BYTE_CODE
|
||||
# define JERRY_PARSER_DUMP_BYTE_CODE 0
|
||||
#define JERRY_PARSER_DUMP_BYTE_CODE 0
|
||||
#endif /* defined (JERRY_PARSER_DUMP_BYTE_CODE) */
|
||||
|
||||
/**
|
||||
@@ -340,9 +346,18 @@
|
||||
*
|
||||
* Default value: 1
|
||||
*/
|
||||
#ifndef JERRY_PROPRETY_HASHMAP
|
||||
# define JERRY_PROPRETY_HASHMAP 1
|
||||
#endif /* !defined (JERRY_PROPRETY_HASHMAP) */
|
||||
#ifndef JERRY_PROPERTY_HASHMAP
|
||||
#define JERRY_PROPERTY_HASHMAP 1
|
||||
#endif /* !defined (JERRY_PROPERTY_HASHMAP) */
|
||||
|
||||
/**
|
||||
* Enables/disables the Promise event callbacks
|
||||
*
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_PROMISE_CALLBACK
|
||||
#define JERRY_PROMISE_CALLBACK 0
|
||||
#endif /* !defined (JERRY_PROMISE_CALLBACK) */
|
||||
|
||||
/**
|
||||
* Enable/Disable byte code dump functions for RegExp objects.
|
||||
@@ -357,7 +372,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_REGEXP_DUMP_BYTE_CODE
|
||||
# define JERRY_REGEXP_DUMP_BYTE_CODE 0
|
||||
#define JERRY_REGEXP_DUMP_BYTE_CODE 0
|
||||
#endif /* !defined (JERRY_REGEXP_DUMP_BYTE_CODE) */
|
||||
|
||||
/**
|
||||
@@ -366,7 +381,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_REGEXP_STRICT_MODE
|
||||
# define JERRY_REGEXP_STRICT_MODE 0
|
||||
#define JERRY_REGEXP_STRICT_MODE 0
|
||||
#endif /* !defined (JERRY_REGEXP_STRICT_MODE) */
|
||||
|
||||
/**
|
||||
@@ -379,7 +394,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_SNAPSHOT_EXEC
|
||||
# define JERRY_SNAPSHOT_EXEC 0
|
||||
#define JERRY_SNAPSHOT_EXEC 0
|
||||
#endif /* !defined (JERRY_SNAPSHOT_EXEC) */
|
||||
|
||||
/**
|
||||
@@ -390,7 +405,7 @@
|
||||
* 1: Enable snapshot save functions.
|
||||
*/
|
||||
#ifndef JERRY_SNAPSHOT_SAVE
|
||||
# define JERRY_SNAPSHOT_SAVE 0
|
||||
#define JERRY_SNAPSHOT_SAVE 0
|
||||
#endif /* !defined (JERRY_SNAPSHOT_SAVE) */
|
||||
|
||||
/**
|
||||
@@ -403,7 +418,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_SYSTEM_ALLOCATOR
|
||||
# define JERRY_SYSTEM_ALLOCATOR 0
|
||||
#define JERRY_SYSTEM_ALLOCATOR 0
|
||||
#endif /* !defined (JERRY_SYSTEM_ALLOCATOR) */
|
||||
|
||||
/**
|
||||
@@ -411,7 +426,7 @@
|
||||
* By default Unicode case conversion is enabled.
|
||||
*/
|
||||
#ifndef JERRY_UNICODE_CASE_CONVERSION
|
||||
# define JERRY_UNICODE_CASE_CONVERSION 1
|
||||
#define JERRY_UNICODE_CASE_CONVERSION 1
|
||||
#endif /* !defined (JERRY_UNICODE_CASE_CONVERSION) */
|
||||
|
||||
/**
|
||||
@@ -422,19 +437,30 @@
|
||||
* 1: Enable the Valgrind specific allocation notifications.
|
||||
*/
|
||||
#ifndef JERRY_VALGRIND
|
||||
# define JERRY_VALGRIND 0
|
||||
#define JERRY_VALGRIND 0
|
||||
#endif /* !defined (JERRY_VALGRIND) */
|
||||
|
||||
/**
|
||||
* Enable/Disable the vm execution stop callback function.
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable vm exec stop callbacks.
|
||||
* 1: Enable vm exec stop callback functionality.
|
||||
* 0: Disable vm exec stop callback support.
|
||||
* 1: Enable vm exec stop callback support.
|
||||
*/
|
||||
#ifndef JERRY_VM_EXEC_STOP
|
||||
# define JERRY_VM_EXEC_STOP 0
|
||||
#endif /* !defined (JERRY_VM_EXEC_STOP) */
|
||||
#ifndef JERRY_VM_HALT
|
||||
#define JERRY_VM_HALT 0
|
||||
#endif /* !defined (JERRY_VM_HALT) */
|
||||
|
||||
/**
|
||||
* Enable/Disable the vm throw callback function.
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable vm throw callback support.
|
||||
* 1: Enable vm throw callback support.
|
||||
*/
|
||||
#ifndef JERRY_VM_THROW
|
||||
#define JERRY_VM_THROW 0
|
||||
#endif /* !defined (JERRY_VM_THROW) */
|
||||
|
||||
/**
|
||||
* Advanced section configurations.
|
||||
@@ -454,7 +480,7 @@
|
||||
* # define JERRY_ATTR_CONST_DATA __attribute__((section(".rodata.const")))
|
||||
*/
|
||||
#ifndef JERRY_ATTR_CONST_DATA
|
||||
# define JERRY_ATTR_CONST_DATA
|
||||
#define JERRY_ATTR_CONST_DATA
|
||||
#endif /* !defined (JERRY_ATTR_CONST_DATA) */
|
||||
|
||||
/**
|
||||
@@ -464,7 +490,7 @@
|
||||
* #define JERRY_ATTR_GLOBAL_HEAP __attribute__((section(".text.globalheap")))
|
||||
*/
|
||||
#ifndef JERRY_ATTR_GLOBAL_HEAP
|
||||
# define JERRY_ATTR_GLOBAL_HEAP
|
||||
#define JERRY_ATTR_GLOBAL_HEAP
|
||||
#endif /* !defined (JERRY_ATTR_GLOBAL_HEAP) */
|
||||
|
||||
/**
|
||||
@@ -475,253 +501,185 @@
|
||||
/**
|
||||
* Check base builtins.
|
||||
*/
|
||||
#if !defined (JERRY_BUILTIN_ANNEXB) \
|
||||
|| ((JERRY_BUILTIN_ANNEXB != 0) && (JERRY_BUILTIN_ANNEXB != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_ANNEXB macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_ARRAY) \
|
||||
|| ((JERRY_BUILTIN_ARRAY != 0) && (JERRY_BUILTIN_ARRAY != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_ARRAY macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_BOOLEAN) \
|
||||
|| ((JERRY_BUILTIN_BOOLEAN != 0) && (JERRY_BUILTIN_BOOLEAN != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_BOOLEAN macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_DATE) \
|
||||
|| ((JERRY_BUILTIN_DATE != 0) && (JERRY_BUILTIN_DATE != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_DATE macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_ERRORS) \
|
||||
|| ((JERRY_BUILTIN_ERRORS != 0) && (JERRY_BUILTIN_ERRORS != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_ERRORS macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_JSON) \
|
||||
|| ((JERRY_BUILTIN_JSON != 0) && (JERRY_BUILTIN_JSON != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_JSON macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_MATH) \
|
||||
|| ((JERRY_BUILTIN_MATH != 0) && (JERRY_BUILTIN_MATH != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_MATH macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_NUMBER) \
|
||||
|| ((JERRY_BUILTIN_NUMBER != 0) && (JERRY_BUILTIN_NUMBER != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_NUMBER macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_REGEXP) \
|
||||
|| ((JERRY_BUILTIN_REGEXP != 0) && (JERRY_BUILTIN_REGEXP != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_REGEXP macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_STRING) \
|
||||
|| ((JERRY_BUILTIN_STRING != 0) && (JERRY_BUILTIN_STRING != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_STRING macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTINS) \
|
||||
|| ((JERRY_BUILTINS != 0) && (JERRY_BUILTINS != 1))
|
||||
# error "Invalid value for JERRY_BUILTINS macro."
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Check ES2015+ features
|
||||
*/
|
||||
#if !defined (JERRY_ESNEXT) \
|
||||
|| ((JERRY_ESNEXT != 0) && (JERRY_ESNEXT != 1))
|
||||
# error "Invalid value for JERRY_ESNEXT macro."
|
||||
#endif
|
||||
#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_BUILTIN_DATAVIEW) \
|
||||
|| ((JERRY_BUILTIN_DATAVIEW != 0) && (JERRY_BUILTIN_DATAVIEW != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_DATAVIEW macro."
|
||||
#endif
|
||||
#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_BUILTIN_REFLECT) \
|
||||
|| ((JERRY_BUILTIN_REFLECT != 0) && (JERRY_BUILTIN_REFLECT != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_REFLECT macro."
|
||||
#endif
|
||||
#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_BUILTIN_WEAKMAP) \
|
||||
|| ((JERRY_BUILTIN_WEAKMAP != 0) && (JERRY_BUILTIN_WEAKMAP != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_WEAKMAP macro."
|
||||
#endif
|
||||
#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_BUILTIN_PROMISE) \
|
||||
|| ((JERRY_BUILTIN_PROMISE != 0) && (JERRY_BUILTIN_PROMISE != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_PROMISE macro."
|
||||
#endif
|
||||
#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_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
|
||||
#if (JERRY_BUILTIN_ANNEXB != 0) && (JERRY_BUILTIN_ANNEXB != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_ANNEXB macro."
|
||||
#endif /* (JERRY_BUILTIN_ANNEXB != 0) && (JERRY_BUILTIN_ANNEXB != 1) */
|
||||
#if (JERRY_BUILTIN_ARRAY != 0) && (JERRY_BUILTIN_ARRAY != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_ARRAY macro."
|
||||
#endif /* (JERRY_BUILTIN_ARRAY != 0) && (JERRY_BUILTIN_ARRAY != 1) */
|
||||
#if (JERRY_BUILTIN_BOOLEAN != 0) && (JERRY_BUILTIN_BOOLEAN != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_BOOLEAN macro."
|
||||
#endif /* (JERRY_BUILTIN_BOOLEAN != 0) && (JERRY_BUILTIN_BOOLEAN != 1) */
|
||||
#if (JERRY_BUILTIN_DATE != 0) && (JERRY_BUILTIN_DATE != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_DATE macro."
|
||||
#endif /* (JERRY_BUILTIN_DATE != 0) && (JERRY_BUILTIN_DATE != 1) */
|
||||
#if (JERRY_BUILTIN_ERRORS != 0) && (JERRY_BUILTIN_ERRORS != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_ERRORS macro."
|
||||
#endif /* (JERRY_BUILTIN_ERRORS != 0) && (JERRY_BUILTIN_ERRORS != 1) */
|
||||
#if (JERRY_BUILTIN_JSON != 0) && (JERRY_BUILTIN_JSON != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_JSON macro."
|
||||
#endif /* (JERRY_BUILTIN_JSON != 0) && (JERRY_BUILTIN_JSON != 1) */
|
||||
#if (JERRY_BUILTIN_MATH != 0) && (JERRY_BUILTIN_MATH != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_MATH macro."
|
||||
#endif /* (JERRY_BUILTIN_MATH != 0) && (JERRY_BUILTIN_MATH != 1) */
|
||||
#if (JERRY_BUILTIN_NUMBER != 0) && (JERRY_BUILTIN_NUMBER != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_NUMBER macro."
|
||||
#endif /* (JERRY_BUILTIN_NUMBER != 0) && (JERRY_BUILTIN_NUMBER != 1) */
|
||||
#if (JERRY_BUILTIN_REGEXP != 0) && (JERRY_BUILTIN_REGEXP != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_REGEXP macro."
|
||||
#endif /* (JERRY_BUILTIN_REGEXP != 0) && (JERRY_BUILTIN_REGEXP != 1) */
|
||||
#if (JERRY_BUILTIN_STRING != 0) && (JERRY_BUILTIN_STRING != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_STRING macro."
|
||||
#endif /* (JERRY_BUILTIN_STRING != 0) && (JERRY_BUILTIN_STRING != 1) */
|
||||
#if (JERRY_BUILTINS != 0) && (JERRY_BUILTINS != 1)
|
||||
#error "Invalid value for JERRY_BUILTINS macro."
|
||||
#endif /* (JERRY_BUILTINS != 0) && (JERRY_BUILTINS != 1) */
|
||||
#if (JERRY_BUILTIN_REALMS != 0) && (JERRY_BUILTIN_REALMS != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_REALMS macro."
|
||||
#endif /* (JERRY_BUILTIN_REALMS != 0) && (JERRY_BUILTIN_REALMS != 1) */
|
||||
#if (JERRY_BUILTIN_DATAVIEW != 0) && (JERRY_BUILTIN_DATAVIEW != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_DATAVIEW macro."
|
||||
#endif /* (JERRY_BUILTIN_DATAVIEW != 0) && (JERRY_BUILTIN_DATAVIEW != 1) */
|
||||
#if (JERRY_BUILTIN_GLOBAL_THIS != 0) && (JERRY_BUILTIN_GLOBAL_THIS != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_GLOBAL_THIS macro."
|
||||
#endif /* (JERRY_BUILTIN_GLOBAL_THIS != 0) && (JERRY_BUILTIN_GLOBAL_THIS != 1) */
|
||||
#if (JERRY_BUILTIN_REFLECT != 0) && (JERRY_BUILTIN_REFLECT != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_REFLECT macro."
|
||||
#endif /* (JERRY_BUILTIN_REFLECT != 0) && (JERRY_BUILTIN_REFLECT != 1) */
|
||||
#if (JERRY_BUILTIN_WEAKREF != 0) && (JERRY_BUILTIN_WEAKREF != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_WEAKREF macro."
|
||||
#endif /* (JERRY_BUILTIN_WEAKREF != 0) && (JERRY_BUILTIN_WEAKREF != 1) */
|
||||
#if (JERRY_BUILTIN_PROXY != 0) && (JERRY_BUILTIN_PROXY != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_PROXY macro."
|
||||
#endif /* (JERRY_BUILTIN_PROXY != 0) && (JERRY_BUILTIN_PROXY != 1) */
|
||||
#if (JERRY_BUILTIN_TYPEDARRAY != 0) && (JERRY_BUILTIN_TYPEDARRAY != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_TYPEDARRAY macro."
|
||||
#endif /* (JERRY_BUILTIN_TYPEDARRAY != 0) && (JERRY_BUILTIN_TYPEDARRAY != 1) */
|
||||
#if (JERRY_BUILTIN_SHAREDARRAYBUFFER != 0) && (JERRY_BUILTIN_SHAREDARRAYBUFFER != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_SHAREDARRAYBUFFER macro."
|
||||
#endif /* (JERRY_BUILTIN_SHAREDARRAYBUFFER != 0) && (JERRY_BUILTIN_SHAREDARRAYBUFFER != 1) */
|
||||
#if (JERRY_BUILTIN_ATOMICS != 0) && (JERRY_BUILTIN_ATOMICS != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_ATOMICS macro."
|
||||
#endif /* (JERRY_BUILTIN_ATOMICS != 0) && (JERRY_BUILTIN_ATOMICS != 1) */
|
||||
#if (JERRY_BUILTIN_BIGINT != 0) && (JERRY_BUILTIN_BIGINT != 1)
|
||||
#error "Invalid value for JERRY_BUILTIN_BIGINT macro."
|
||||
#endif /* (JERRY_BUILTIN_BIGINT != 0) && (JERRY_BUILTIN_BIGINT != 1) */
|
||||
#if (JERRY_MODULE_SYSTEM != 0) && (JERRY_MODULE_SYSTEM != 1)
|
||||
#error "Invalid value for JERRY_MODULE_SYSTEM macro."
|
||||
#endif /* (JERRY_MODULE_SYSTEM != 0) && (JERRY_MODULE_SYSTEM != 1) */
|
||||
#if (JERRY_BUILTIN_TYPEDARRAY == 0) && (JERRY_BUILTIN_SHAREDARRAYBUFFER == 1)
|
||||
#error "JERRY_BUILTIN_TYPEDARRAY should be enabled too to enable JERRY_BUILTIN_SHAREDARRAYBUFFER macro."
|
||||
#endif /* (JERRY_BUILTIN_TYPEDARRAY == 0) && (JERRY_BUILTIN_SHAREDARRAYBUFFER == 1) */
|
||||
#if (JERRY_BUILTIN_SHAREDARRAYBUFFER == 0) && (JERRY_BUILTIN_ATOMICS == 1)
|
||||
#error "JERRY_BUILTIN_SHAREDARRAYBUFFER should be enabled too to enable JERRY_BUILTIN_ATOMICS macro."
|
||||
#endif /* (JERRY_BUILTIN_SHAREDARRAYBUFFER == 0) && (JERRY_BUILTIN_ATOMICS == 1) */
|
||||
|
||||
/**
|
||||
* Internal options.
|
||||
*/
|
||||
#if !defined (JERRY_CPOINTER_32_BIT) \
|
||||
|| ((JERRY_CPOINTER_32_BIT != 0) && (JERRY_CPOINTER_32_BIT != 1))
|
||||
# error "Invalid value for 'JERRY_CPOINTER_32_BIT' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_DEBUGGER) \
|
||||
|| ((JERRY_DEBUGGER != 0) && (JERRY_DEBUGGER != 1))
|
||||
# error "Invalid value for 'JERRY_DEBUGGER' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_ERROR_MESSAGES) \
|
||||
|| ((JERRY_ERROR_MESSAGES != 0) && (JERRY_ERROR_MESSAGES != 1))
|
||||
# error "Invalid value for 'JERRY_ERROR_MESSAGES' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_EXTERNAL_CONTEXT) \
|
||||
|| ((JERRY_EXTERNAL_CONTEXT != 0) && (JERRY_EXTERNAL_CONTEXT != 1))
|
||||
# error "Invalid value for 'JERRY_EXTERNAL_CONTEXT' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_GLOBAL_HEAP_SIZE) || (JERRY_GLOBAL_HEAP_SIZE <= 0)
|
||||
# error "Invalid value for 'JERRY_GLOBAL_HEAP_SIZE' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_GC_LIMIT) || (JERRY_GC_LIMIT < 0)
|
||||
# error "Invalid value for 'JERRY_GC_LIMIT' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_STACK_LIMIT) || (JERRY_STACK_LIMIT < 0)
|
||||
# error "Invalid value for 'JERRY_STACK_LIMIT' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_GC_MARK_LIMIT) || (JERRY_GC_MARK_LIMIT < 0)
|
||||
# error "Invalid value for 'JERRY_GC_MARK_LIMIT' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_LCACHE) \
|
||||
|| ((JERRY_LCACHE != 0) && (JERRY_LCACHE != 1))
|
||||
# error "Invalid value for 'JERRY_LCACHE' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_LINE_INFO) \
|
||||
|| ((JERRY_LINE_INFO != 0) && (JERRY_LINE_INFO != 1))
|
||||
# error "Invalid value for 'JERRY_LINE_INFO' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_LOGGING) \
|
||||
|| ((JERRY_LOGGING != 0) && (JERRY_LOGGING != 1))
|
||||
# error "Invalid value for 'JERRY_LOGGING' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_MEM_GC_BEFORE_EACH_ALLOC) \
|
||||
|| ((JERRY_MEM_GC_BEFORE_EACH_ALLOC != 0) && (JERRY_MEM_GC_BEFORE_EACH_ALLOC != 1))
|
||||
# error "Invalid value for 'JERRY_MEM_GC_BEFORE_EACH_ALLOC' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_MEM_STATS) \
|
||||
|| ((JERRY_MEM_STATS != 0) && (JERRY_MEM_STATS != 1))
|
||||
# error "Invalid value for 'JERRY_MEM_STATS' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_NUMBER_TYPE_FLOAT64) \
|
||||
|| ((JERRY_NUMBER_TYPE_FLOAT64 != 0) && (JERRY_NUMBER_TYPE_FLOAT64 != 1))
|
||||
# error "Invalid value for 'JERRY_NUMBER_TYPE_FLOAT64' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_PARSER) \
|
||||
|| ((JERRY_PARSER != 0) && (JERRY_PARSER != 1))
|
||||
# error "Invalid value for 'JERRY_PARSER' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_PARSER_DUMP_BYTE_CODE) \
|
||||
|| ((JERRY_PARSER_DUMP_BYTE_CODE != 0) && (JERRY_PARSER_DUMP_BYTE_CODE != 1))
|
||||
# error "Invalid value for 'JERRY_PARSER_DUMP_BYTE_CODE' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_PROPRETY_HASHMAP) \
|
||||
|| ((JERRY_PROPRETY_HASHMAP != 0) && (JERRY_PROPRETY_HASHMAP != 1))
|
||||
# error "Invalid value for 'JERRY_PROPRETY_HASHMAP' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_REGEXP_DUMP_BYTE_CODE) \
|
||||
|| ((JERRY_REGEXP_DUMP_BYTE_CODE != 0) && (JERRY_REGEXP_DUMP_BYTE_CODE != 1))
|
||||
# error "Invalid value for 'JERRY_REGEXP_DUMP_BYTE_CODE' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_REGEXP_STRICT_MODE) \
|
||||
|| ((JERRY_REGEXP_STRICT_MODE != 0) && (JERRY_REGEXP_STRICT_MODE != 1))
|
||||
# error "Invalid value for 'JERRY_REGEXP_STRICT_MODE' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_SNAPSHOT_EXEC) \
|
||||
|| ((JERRY_SNAPSHOT_EXEC != 0) && (JERRY_SNAPSHOT_EXEC != 1))
|
||||
# error "Invalid value for 'JERRY_SNAPSHOT_EXEC' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_SNAPSHOT_SAVE) \
|
||||
|| ((JERRY_SNAPSHOT_SAVE != 0) && (JERRY_SNAPSHOT_SAVE != 1))
|
||||
# error "Invalid value for 'JERRY_SNAPSHOT_SAVE' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_SYSTEM_ALLOCATOR) \
|
||||
|| ((JERRY_SYSTEM_ALLOCATOR != 0) && (JERRY_SYSTEM_ALLOCATOR != 1))
|
||||
# error "Invalid value for 'JERRY_SYSTEM_ALLOCATOR' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_UNICODE_CASE_CONVERSION) \
|
||||
|| ((JERRY_UNICODE_CASE_CONVERSION != 0) && (JERRY_UNICODE_CASE_CONVERSION != 1))
|
||||
# error "Invalid value for 'JERRY_UNICODE_CASE_CONVERSION' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_VALGRIND) \
|
||||
|| ((JERRY_VALGRIND != 0) && (JERRY_VALGRIND != 1))
|
||||
# error "Invalid value for 'JERRY_VALGRIND' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_VM_EXEC_STOP) \
|
||||
|| ((JERRY_VM_EXEC_STOP != 0) && (JERRY_VM_EXEC_STOP != 1))
|
||||
# error "Invalid value for 'JERRY_VM_EXEC_STOP' macro."
|
||||
#endif
|
||||
|
||||
#define ENABLED(FEATURE) ((FEATURE) == 1)
|
||||
#define DISABLED(FEATURE) ((FEATURE) != 1)
|
||||
#if (JERRY_CPOINTER_32_BIT != 0) && (JERRY_CPOINTER_32_BIT != 1)
|
||||
#error "Invalid value for 'JERRY_CPOINTER_32_BIT' macro."
|
||||
#endif /* (JERRY_CPOINTER_32_BIT != 0) && (JERRY_CPOINTER_32_BIT != 1) */
|
||||
#if (JERRY_DEBUGGER != 0) && (JERRY_DEBUGGER != 1)
|
||||
#error "Invalid value for 'JERRY_DEBUGGER' macro."
|
||||
#endif /* (JERRY_DEBUGGER != 0) && (JERRY_DEBUGGER != 1) */
|
||||
#if (JERRY_ERROR_MESSAGES != 0) && (JERRY_ERROR_MESSAGES != 1)
|
||||
#error "Invalid value for 'JERRY_ERROR_MESSAGES' macro."
|
||||
#endif /* (JERRY_ERROR_MESSAGES != 0) && (JERRY_ERROR_MESSAGES != 1) */
|
||||
#if (JERRY_EXTERNAL_CONTEXT != 0) && (JERRY_EXTERNAL_CONTEXT != 1)
|
||||
#error "Invalid value for 'JERRY_EXTERNAL_CONTEXT' macro."
|
||||
#endif /* (JERRY_EXTERNAL_CONTEXT != 0) && (JERRY_EXTERNAL_CONTEXT != 1) */
|
||||
#if JERRY_GLOBAL_HEAP_SIZE <= 0
|
||||
#error "Invalid value for 'JERRY_GLOBAL_HEAP_SIZE' macro."
|
||||
#endif /* JERRY_GLOBAL_HEAP_SIZE <= 0 */
|
||||
#if JERRY_GC_LIMIT < 0
|
||||
#error "Invalid value for 'JERRY_GC_LIMIT' macro."
|
||||
#endif /* JERRY_GC_LIMIT < 0 */
|
||||
#if JERRY_STACK_LIMIT < 0
|
||||
#error "Invalid value for 'JERRY_STACK_LIMIT' macro."
|
||||
#endif /* JERRY_STACK_LIMIT < 0 */
|
||||
#if JERRY_GC_MARK_LIMIT < 0
|
||||
#error "Invalid value for 'JERRY_GC_MARK_LIMIT' macro."
|
||||
#endif /* JERRY_GC_MARK_LIMIT < 0 */
|
||||
#if (JERRY_LCACHE != 0) && (JERRY_LCACHE != 1)
|
||||
#error "Invalid value for 'JERRY_LCACHE' macro."
|
||||
#endif /* (JERRY_LCACHE != 0) && (JERRY_LCACHE != 1) */
|
||||
#if (JERRY_FUNCTION_TO_STRING != 0) && (JERRY_FUNCTION_TO_STRING != 1)
|
||||
#error "Invalid value for 'JERRY_FUNCTION_TO_STRING' macro."
|
||||
#endif /* (JERRY_FUNCTION_TO_STRING != 0) && (JERRY_FUNCTION_TO_STRING != 1) */
|
||||
#if (JERRY_LINE_INFO != 0) && (JERRY_LINE_INFO != 1)
|
||||
#error "Invalid value for 'JERRY_LINE_INFO' macro."
|
||||
#endif /* (JERRY_LINE_INFO != 0) && (JERRY_LINE_INFO != 1) */
|
||||
#if (JERRY_LOGGING != 0) && (JERRY_LOGGING != 1)
|
||||
#error "Invalid value for 'JERRY_LOGGING' macro."
|
||||
#endif /* (JERRY_LOGGING != 0) && (JERRY_LOGGING != 1) */
|
||||
#if (JERRY_MEM_GC_BEFORE_EACH_ALLOC != 0) && (JERRY_MEM_GC_BEFORE_EACH_ALLOC != 1)
|
||||
#error "Invalid value for 'JERRY_MEM_GC_BEFORE_EACH_ALLOC' macro."
|
||||
#endif /* (JERRY_MEM_GC_BEFORE_EACH_ALLOC != 0) && (JERRY_MEM_GC_BEFORE_EACH_ALLOC != 1) */
|
||||
#if (JERRY_MEM_STATS != 0) && (JERRY_MEM_STATS != 1)
|
||||
#error "Invalid value for 'JERRY_MEM_STATS' macro."
|
||||
#endif /* (JERRY_MEM_STATS != 0) && (JERRY_MEM_STATS != 1) */
|
||||
#if (JERRY_NUMBER_TYPE_FLOAT64 != 0) && (JERRY_NUMBER_TYPE_FLOAT64 != 1)
|
||||
#error "Invalid value for 'JERRY_NUMBER_TYPE_FLOAT64' macro."
|
||||
#endif /* (JERRY_NUMBER_TYPE_FLOAT64 != 0) && (JERRY_NUMBER_TYPE_FLOAT64 != 1) */
|
||||
#if (JERRY_PARSER != 0) && (JERRY_PARSER != 1)
|
||||
#error "Invalid value for 'JERRY_PARSER' macro."
|
||||
#endif /* (JERRY_PARSER != 0) && (JERRY_PARSER != 1) */
|
||||
#if (JERRY_PARSER_DUMP_BYTE_CODE != 0) && (JERRY_PARSER_DUMP_BYTE_CODE != 1)
|
||||
#error "Invalid value for 'JERRY_PARSER_DUMP_BYTE_CODE' macro."
|
||||
#endif /* (JERRY_PARSER_DUMP_BYTE_CODE != 0) && (JERRY_PARSER_DUMP_BYTE_CODE != 1) */
|
||||
#if (JERRY_PROPERTY_HASHMAP != 0) && (JERRY_PROPERTY_HASHMAP != 1)
|
||||
#error "Invalid value for 'JERRY_PROPERTY_HASHMAP' macro."
|
||||
#endif /* (JERRY_PROPERTY_HASHMAP != 0) && (JERRY_PROPERTY_HASHMAP != 1) */
|
||||
#if (JERRY_PROMISE_CALLBACK != 0) && (JERRY_PROMISE_CALLBACK != 1)
|
||||
#error "Invalid value for 'JERRY_PROMISE_CALLBACK' macro."
|
||||
#endif /* (JERRY_PROMISE_CALLBACK != 0) && (JERRY_PROMISE_CALLBACK != 1) */
|
||||
#if (JERRY_REGEXP_DUMP_BYTE_CODE != 0) && (JERRY_REGEXP_DUMP_BYTE_CODE != 1)
|
||||
#error "Invalid value for 'JERRY_REGEXP_DUMP_BYTE_CODE' macro."
|
||||
#endif /* (JERRY_REGEXP_DUMP_BYTE_CODE != 0) && (JERRY_REGEXP_DUMP_BYTE_CODE != 1) */
|
||||
#if (JERRY_REGEXP_STRICT_MODE != 0) && (JERRY_REGEXP_STRICT_MODE != 1)
|
||||
#error "Invalid value for 'JERRY_REGEXP_STRICT_MODE' macro."
|
||||
#endif /* (JERRY_REGEXP_STRICT_MODE != 0) && (JERRY_REGEXP_STRICT_MODE != 1) */
|
||||
#if (JERRY_SNAPSHOT_EXEC != 0) && (JERRY_SNAPSHOT_EXEC != 1)
|
||||
#error "Invalid value for 'JERRY_SNAPSHOT_EXEC' macro."
|
||||
#endif /* (JERRY_SNAPSHOT_EXEC != 0) && (JERRY_SNAPSHOT_EXEC != 1) */
|
||||
#if (JERRY_SNAPSHOT_SAVE != 0) && (JERRY_SNAPSHOT_SAVE != 1)
|
||||
#error "Invalid value for 'JERRY_SNAPSHOT_SAVE' macro."
|
||||
#endif /* (JERRY_SNAPSHOT_SAVE != 0) && (JERRY_SNAPSHOT_SAVE != 1) */
|
||||
#if (JERRY_SYSTEM_ALLOCATOR != 0) && (JERRY_SYSTEM_ALLOCATOR != 1)
|
||||
#error "Invalid value for 'JERRY_SYSTEM_ALLOCATOR' macro."
|
||||
#endif /* (JERRY_SYSTEM_ALLOCATOR != 0) && (JERRY_SYSTEM_ALLOCATOR != 1) */
|
||||
#if (JERRY_UNICODE_CASE_CONVERSION != 0) && (JERRY_UNICODE_CASE_CONVERSION != 1)
|
||||
#error "Invalid value for 'JERRY_UNICODE_CASE_CONVERSION' macro."
|
||||
#endif /* (JERRY_UNICODE_CASE_CONVERSION != 0) && (JERRY_UNICODE_CASE_CONVERSION != 1) */
|
||||
#if (JERRY_VALGRIND != 0) && (JERRY_VALGRIND != 1)
|
||||
#error "Invalid value for 'JERRY_VALGRIND' macro."
|
||||
#endif /* (JERRY_VALGRIND != 0) && (JERRY_VALGRIND != 1) */
|
||||
#if (JERRY_VM_HALT != 0) && (JERRY_VM_HALT != 1)
|
||||
#error "Invalid value for 'JERRY_VM_HALT' macro."
|
||||
#endif /* (JERRY_VM_HALT != 0) && (JERRY_VM_HALT != 1) */
|
||||
#if (JERRY_VM_THROW != 0) && (JERRY_VM_THROW != 1)
|
||||
#error "Invalid value for 'JERRY_VM_THROW' macro."
|
||||
#endif /* (JERRY_VM_THROW != 0) && (JERRY_VM_THROW != 1) */
|
||||
|
||||
/**
|
||||
* Cross component requirements check.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The date module can only use the float 64 number types.
|
||||
* Do a check for this.
|
||||
*/
|
||||
#if ENABLED (JERRY_BUILTIN_DATE) && !ENABLED (JERRY_NUMBER_TYPE_FLOAT64)
|
||||
# error "Date does not support float32"
|
||||
#endif
|
||||
#if JERRY_BUILTIN_DATE && !JERRY_NUMBER_TYPE_FLOAT64
|
||||
#error "Date does not support float32"
|
||||
#endif /* JERRY_BUILTIN_DATE && !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Wrap container types into a single guard
|
||||
* Source name related types into a single guard
|
||||
*/
|
||||
#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_BUILTIN_CONTAINER 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Resource name related types into a single guard
|
||||
*/
|
||||
#if ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ERROR_MESSAGES) || ENABLED (JERRY_MODULE_SYSTEM)
|
||||
# define JERRY_RESOURCE_NAME 1
|
||||
#else
|
||||
# define JERRY_RESOURCE_NAME 0
|
||||
#endif
|
||||
#if JERRY_LINE_INFO || JERRY_ERROR_MESSAGES || JERRY_MODULE_SYSTEM
|
||||
#define JERRY_SOURCE_NAME 1
|
||||
#else /* !(JERRY_LINE_INFO || JERRY_ERROR_MESSAGES || JERRY_MODULE_SYSTEM) */
|
||||
#define JERRY_SOURCE_NAME 0
|
||||
#endif /* JERRY_LINE_INFO || JERRY_ERROR_MESSAGES || JERRY_MODULE_SYSTEM */
|
||||
|
||||
#endif /* !JERRYSCRIPT_CONFIG_H */
|
||||
|
||||
@@ -13,19 +13,22 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "byte-code.h"
|
||||
#include "debugger.h"
|
||||
|
||||
#include "jerryscript-debugger.h"
|
||||
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-eval.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-objects.h"
|
||||
|
||||
#include "byte-code.h"
|
||||
#include "jcontext.h"
|
||||
#include "jerryscript-port.h"
|
||||
#include "lit-char-helpers.h"
|
||||
|
||||
#if ENABLED (JERRY_DEBUGGER)
|
||||
#if JERRY_DEBUGGER
|
||||
|
||||
/**
|
||||
* Incoming message: next message of string data.
|
||||
@@ -39,16 +42,14 @@ typedef struct
|
||||
* The number of message types in the debugger should reflect the
|
||||
* debugger versioning.
|
||||
*/
|
||||
JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 33
|
||||
&& JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT == 21
|
||||
&& JERRY_DEBUGGER_VERSION == 9,
|
||||
JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 33 && JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT == 21
|
||||
&& JERRY_DEBUGGER_VERSION == 9,
|
||||
debugger_version_correlates_to_message_type_count);
|
||||
|
||||
/**
|
||||
* Waiting for data from the client.
|
||||
*/
|
||||
#define JERRY_DEBUGGER_RECEIVE_DATA_MODE \
|
||||
(JERRY_DEBUGGER_BREAKPOINT_MODE | JERRY_DEBUGGER_CLIENT_SOURCE_MODE)
|
||||
#define JERRY_DEBUGGER_RECEIVE_DATA_MODE (JERRY_DEBUGGER_BREAKPOINT_MODE | JERRY_DEBUGGER_CLIENT_SOURCE_MODE)
|
||||
|
||||
/**
|
||||
* Type cast the debugger send buffer into a specific type.
|
||||
@@ -59,8 +60,7 @@ JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 33
|
||||
/**
|
||||
* Type cast the debugger receive buffer into a specific type.
|
||||
*/
|
||||
#define JERRY_DEBUGGER_RECEIVE_BUFFER_AS(type, name_p) \
|
||||
type *name_p = ((type *) recv_buffer_p)
|
||||
#define JERRY_DEBUGGER_RECEIVE_BUFFER_AS(type, name_p) type *name_p = ((type *) recv_buffer_p)
|
||||
|
||||
/**
|
||||
* Free all unreferenced byte code structures which
|
||||
@@ -71,17 +71,15 @@ jerry_debugger_free_unreferenced_byte_code (void)
|
||||
{
|
||||
jerry_debugger_byte_code_free_t *byte_code_free_p;
|
||||
|
||||
byte_code_free_p = JMEM_CP_GET_POINTER (jerry_debugger_byte_code_free_t,
|
||||
JERRY_CONTEXT (debugger_byte_code_free_tail));
|
||||
byte_code_free_p =
|
||||
JMEM_CP_GET_POINTER (jerry_debugger_byte_code_free_t, JERRY_CONTEXT (debugger_byte_code_free_tail));
|
||||
|
||||
while (byte_code_free_p != NULL)
|
||||
{
|
||||
jerry_debugger_byte_code_free_t *prev_byte_code_free_p;
|
||||
prev_byte_code_free_p = JMEM_CP_GET_POINTER (jerry_debugger_byte_code_free_t,
|
||||
byte_code_free_p->prev_cp);
|
||||
prev_byte_code_free_p = JMEM_CP_GET_POINTER (jerry_debugger_byte_code_free_t, byte_code_free_p->prev_cp);
|
||||
|
||||
jmem_heap_free_block (byte_code_free_p,
|
||||
((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
|
||||
jmem_heap_free_block (byte_code_free_p, ((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
|
||||
|
||||
byte_code_free_p = prev_byte_code_free_p;
|
||||
}
|
||||
@@ -488,8 +486,7 @@ jerry_debugger_send_scope_variables (const uint8_t *recv_buffer_p) /**< pointer
|
||||
continue;
|
||||
}
|
||||
|
||||
ecma_string_t *prop_name = ecma_string_from_property_name (prop_iter_p->types[i],
|
||||
prop_pair_p->names_cp[i]);
|
||||
ecma_string_t *prop_name = ecma_string_from_property_name (prop_iter_p->types[i], prop_pair_p->names_cp[i]);
|
||||
|
||||
if (!jerry_debugger_copy_variables_to_string_message (JERRY_DEBUGGER_VALUE_NONE,
|
||||
prop_name,
|
||||
@@ -509,10 +506,7 @@ jerry_debugger_send_scope_variables (const uint8_t *recv_buffer_p) /**< pointer
|
||||
ecma_string_t *str_p = ecma_op_to_string (prop_value_p.value);
|
||||
JERRY_ASSERT (str_p != NULL);
|
||||
|
||||
if (!jerry_debugger_copy_variables_to_string_message (variable_type,
|
||||
str_p,
|
||||
message_string_p,
|
||||
&buffer_pos))
|
||||
if (!jerry_debugger_copy_variables_to_string_message (variable_type, str_p, message_string_p, &buffer_pos))
|
||||
{
|
||||
ecma_deref_ecma_string (str_p);
|
||||
return;
|
||||
@@ -546,9 +540,14 @@ jerry_debugger_send_eval (const lit_utf8_byte_t *eval_string_p, /**< evaluated s
|
||||
|
||||
uint32_t chain_index;
|
||||
memcpy (&chain_index, eval_string_p, sizeof (uint32_t));
|
||||
uint32_t parse_opts = ECMA_PARSE_DIRECT_EVAL | (chain_index << ECMA_PARSE_CHAIN_INDEX_SHIFT);
|
||||
uint32_t parse_opts = ECMA_PARSE_DIRECT_EVAL;
|
||||
JERRY_CONTEXT (debugger_eval_chain_index) = (uint16_t) chain_index;
|
||||
|
||||
ecma_value_t result = ecma_op_eval_chars_buffer (eval_string_p + 5, eval_string_size - 5, parse_opts);
|
||||
parser_source_char_t source_char;
|
||||
source_char.source_p = eval_string_p + 5;
|
||||
source_char.source_size = eval_string_size - 5;
|
||||
|
||||
ecma_value_t result = ecma_op_eval_chars_buffer ((void *) &source_char, parse_opts);
|
||||
JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_VM_IGNORE);
|
||||
|
||||
if (!ECMA_IS_VALUE_ERROR (result))
|
||||
@@ -587,21 +586,17 @@ jerry_debugger_send_eval (const lit_utf8_byte_t *eval_string_p, /**< evaluated s
|
||||
|
||||
if (ecma_is_value_object (result))
|
||||
{
|
||||
message = ecma_op_object_find (ecma_get_object_from_value (result),
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE));
|
||||
message =
|
||||
ecma_op_object_find (ecma_get_object_from_value (result), ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE));
|
||||
|
||||
if (!ecma_is_value_string (message)
|
||||
|| ecma_string_is_empty (ecma_get_string_from_value (message)))
|
||||
if (!ecma_is_value_string (message) || ecma_string_is_empty (ecma_get_string_from_value (message)))
|
||||
{
|
||||
ecma_free_value (message);
|
||||
lit_magic_string_id_t id = ecma_object_get_class_name (ecma_get_object_from_value (result));
|
||||
ecma_free_value (result);
|
||||
|
||||
const lit_utf8_byte_t *string_p = lit_get_magic_string_utf8 (id);
|
||||
jerry_debugger_send_string (JERRY_DEBUGGER_EVAL_RESULT,
|
||||
type,
|
||||
string_p,
|
||||
strlen ((const char *) string_p));
|
||||
jerry_debugger_send_string (JERRY_DEBUGGER_EVAL_RESULT, type, string_p, strlen ((const char *) string_p));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -631,12 +626,12 @@ jerry_debugger_send_eval (const lit_utf8_byte_t *eval_string_p, /**< evaluated s
|
||||
/**
|
||||
* Check received packet size.
|
||||
*/
|
||||
#define JERRY_DEBUGGER_CHECK_PACKET_SIZE(type) \
|
||||
if (message_size != sizeof (type)) \
|
||||
{ \
|
||||
#define JERRY_DEBUGGER_CHECK_PACKET_SIZE(type) \
|
||||
if (message_size != sizeof (type)) \
|
||||
{ \
|
||||
JERRY_ERROR_MSG ("Invalid message size\n"); \
|
||||
jerry_debugger_transport_close (); \
|
||||
return false; \
|
||||
jerry_debugger_transport_close (); \
|
||||
return false; \
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -654,8 +649,7 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
|
||||
{
|
||||
/* Process the received message. */
|
||||
|
||||
if (recv_buffer_p[0] >= JERRY_DEBUGGER_CONTINUE
|
||||
&& !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
|
||||
if (recv_buffer_p[0] >= JERRY_DEBUGGER_CONTINUE && !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
|
||||
{
|
||||
JERRY_ERROR_MSG ("Message requires breakpoint mode\n");
|
||||
jerry_debugger_transport_close ();
|
||||
@@ -700,9 +694,7 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
|
||||
}
|
||||
|
||||
lit_utf8_byte_t *string_p = (lit_utf8_byte_t *) (uint8_data_p + 1);
|
||||
memcpy (string_p + uint8_data_p->uint8_offset,
|
||||
(lit_utf8_byte_t *) (uint8_data_part_p + 1),
|
||||
message_size);
|
||||
memcpy (string_p + uint8_data_p->uint8_offset, (lit_utf8_byte_t *) (uint8_data_part_p + 1), message_size);
|
||||
|
||||
if (message_size < expected_data)
|
||||
{
|
||||
@@ -750,8 +742,7 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
|
||||
}
|
||||
|
||||
jerry_debugger_byte_code_free_t *byte_code_free_p;
|
||||
byte_code_free_p = JMEM_CP_GET_NON_NULL_POINTER (jerry_debugger_byte_code_free_t,
|
||||
byte_code_free_cp);
|
||||
byte_code_free_p = JMEM_CP_GET_NON_NULL_POINTER (jerry_debugger_byte_code_free_t, byte_code_free_cp);
|
||||
|
||||
if (byte_code_free_p->prev_cp != ECMA_NULL_POINTER)
|
||||
{
|
||||
@@ -763,12 +754,11 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
|
||||
JERRY_CONTEXT (debugger_byte_code_free_tail) = ECMA_NULL_POINTER;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_MEM_STATS)
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_free_byte_code_bytes (((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
|
||||
#endif /* ENABLED (JERRY_MEM_STATS) */
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
jmem_heap_free_block (byte_code_free_p,
|
||||
((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
|
||||
jmem_heap_free_block (byte_code_free_p, ((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1019,8 +1009,8 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
|
||||
client_source_data_p = (jerry_debugger_uint8_data_t *) jmem_heap_alloc_block (client_source_data_size);
|
||||
|
||||
client_source_data_p->uint8_size = client_source_size;
|
||||
client_source_data_p->uint8_offset = (uint32_t) (message_size
|
||||
- sizeof (jerry_debugger_receive_client_source_first_t));
|
||||
client_source_data_p->uint8_offset =
|
||||
(uint32_t) (message_size - sizeof (jerry_debugger_receive_client_source_first_t));
|
||||
|
||||
lit_utf8_byte_t *client_source_string_p = (lit_utf8_byte_t *) (client_source_data_p + 1);
|
||||
memcpy (client_source_string_p,
|
||||
@@ -1189,8 +1179,7 @@ jerry_debugger_breakpoint_hit (uint8_t message_type) /**< message type */
|
||||
|
||||
if (uint8_data != NULL)
|
||||
{
|
||||
jmem_heap_free_block (uint8_data,
|
||||
uint8_data->uint8_size + sizeof (jerry_debugger_uint8_data_t));
|
||||
jmem_heap_free_block (uint8_data, uint8_data->uint8_size + sizeof (jerry_debugger_uint8_data_t));
|
||||
}
|
||||
|
||||
JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_BREAKPOINT_MODE);
|
||||
@@ -1378,7 +1367,7 @@ jerry_debugger_send_memstats (void)
|
||||
|
||||
memstats_p->type = JERRY_DEBUGGER_MEMSTATS_RECEIVE;
|
||||
|
||||
#if ENABLED (JERRY_MEM_STATS) /* if memory statistics feature is enabled */
|
||||
#if JERRY_MEM_STATS /* if memory statistics feature is enabled */
|
||||
jmem_heap_stats_t *heap_stats = &JERRY_CONTEXT (jmem_heap_stats);
|
||||
|
||||
uint32_t allocated_bytes = (uint32_t) heap_stats->allocated_bytes;
|
||||
@@ -1391,13 +1380,13 @@ jerry_debugger_send_memstats (void)
|
||||
memcpy (memstats_p->object_bytes, &object_bytes, sizeof (uint32_t));
|
||||
uint32_t property_bytes = (uint32_t) heap_stats->property_bytes;
|
||||
memcpy (memstats_p->property_bytes, &property_bytes, sizeof (uint32_t));
|
||||
#else /* !ENABLED (JERRY_MEM_STATS) if not, just put zeros */
|
||||
#else /* !JERRY_MEM_STATS if not, just put zeros */
|
||||
memset (memstats_p->allocated_bytes, 0, sizeof (uint32_t));
|
||||
memset (memstats_p->byte_code_bytes, 0, sizeof (uint32_t));
|
||||
memset (memstats_p->string_bytes, 0, sizeof (uint32_t));
|
||||
memset (memstats_p->object_bytes, 0, sizeof (uint32_t));
|
||||
memset (memstats_p->property_bytes, 0, sizeof (uint32_t));
|
||||
#endif /* ENABLED (JERRY_MEM_STATS) */
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
jerry_debugger_send (sizeof (jerry_debugger_send_memstats_t));
|
||||
} /* jerry_debugger_send_memstats */
|
||||
@@ -1421,8 +1410,7 @@ jerry_debugger_exception_object_to_string (ecma_value_t exception_obj_value) /**
|
||||
|
||||
ecma_object_t *prototype_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, prototype_cp);
|
||||
|
||||
if (ecma_get_object_type (prototype_p) != ECMA_OBJECT_TYPE_GENERAL
|
||||
|| !ecma_get_object_is_builtin (prototype_p))
|
||||
if (ecma_get_object_type (prototype_p) != ECMA_OBJECT_TYPE_BUILT_IN_GENERAL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -1431,7 +1419,7 @@ jerry_debugger_exception_object_to_string (ecma_value_t exception_obj_value) /**
|
||||
|
||||
switch (((ecma_extended_object_t *) prototype_p)->u.built_in.id)
|
||||
{
|
||||
#if ENABLED (JERRY_BUILTIN_ERRORS)
|
||||
#if JERRY_BUILTIN_ERRORS
|
||||
case ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE:
|
||||
{
|
||||
string_id = LIT_MAGIC_STRING_EVAL_ERROR_UL;
|
||||
@@ -1457,12 +1445,17 @@ jerry_debugger_exception_object_to_string (ecma_value_t exception_obj_value) /**
|
||||
string_id = LIT_MAGIC_STRING_TYPE_ERROR_UL;
|
||||
break;
|
||||
}
|
||||
case ECMA_BUILTIN_ID_AGGREGATE_ERROR_PROTOTYPE:
|
||||
{
|
||||
string_id = LIT_MAGIC_STRING_AGGREGATE_ERROR_UL;
|
||||
break;
|
||||
}
|
||||
case ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE:
|
||||
{
|
||||
string_id = LIT_MAGIC_STRING_URI_ERROR_UL;
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_BUILTIN_ERRORS) */
|
||||
#endif /* JERRY_BUILTIN_ERRORS */
|
||||
case ECMA_BUILTIN_ID_ERROR_PROTOTYPE:
|
||||
{
|
||||
string_id = LIT_MAGIC_STRING_ERROR_UL;
|
||||
@@ -1534,10 +1527,8 @@ jerry_debugger_send_exception_string (ecma_value_t exception_value)
|
||||
|
||||
ECMA_STRING_TO_UTF8_STRING (string_p, string_data_p, string_size);
|
||||
|
||||
bool result = jerry_debugger_send_string (JERRY_DEBUGGER_EXCEPTION_STR,
|
||||
JERRY_DEBUGGER_NO_SUBTYPE,
|
||||
string_data_p,
|
||||
string_size);
|
||||
bool result =
|
||||
jerry_debugger_send_string (JERRY_DEBUGGER_EXCEPTION_STR, JERRY_DEBUGGER_NO_SUBTYPE, string_data_p, string_size);
|
||||
|
||||
ECMA_FINALIZE_UTF8_STRING (string_data_p, string_size);
|
||||
|
||||
@@ -1545,4 +1536,4 @@ jerry_debugger_send_exception_string (ecma_value_t exception_value)
|
||||
return result;
|
||||
} /* jerry_debugger_send_exception_string */
|
||||
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
|
||||
@@ -16,10 +16,11 @@
|
||||
#ifndef DEBUGGER_H
|
||||
#define DEBUGGER_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "jerryscript-debugger-transport.h"
|
||||
|
||||
#if ENABLED (JERRY_DEBUGGER)
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if JERRY_DEBUGGER
|
||||
|
||||
/* JerryScript debugger protocol is a simplified version of RFC-6455 (WebSockets). */
|
||||
|
||||
@@ -51,8 +52,7 @@
|
||||
/**
|
||||
* Calculate the size of a message when a count number of items transmitted.
|
||||
*/
|
||||
#define JERRY_DEBUGGER_SEND_SIZE(count, type) \
|
||||
((size_t) ((count * sizeof (type)) + sizeof (jerry_debugger_send_type_t)))
|
||||
#define JERRY_DEBUGGER_SEND_SIZE(count, type) ((size_t) ((count * sizeof (type)) + sizeof (jerry_debugger_send_type_t)))
|
||||
|
||||
/**
|
||||
* Debugger operation modes:
|
||||
@@ -113,8 +113,8 @@ typedef enum
|
||||
* Set and clear debugger flags.
|
||||
*/
|
||||
#define JERRY_DEBUGGER_UPDATE_FLAGS(flags_to_set, flags_to_clear) \
|
||||
JERRY_CONTEXT (debugger_flags) = ((JERRY_CONTEXT (debugger_flags) | (uint32_t) (flags_to_set)) \
|
||||
& (uint32_t) ~(flags_to_clear))
|
||||
JERRY_CONTEXT (debugger_flags) = \
|
||||
((JERRY_CONTEXT (debugger_flags) | (uint32_t) (flags_to_set)) & (uint32_t) ~(flags_to_clear))
|
||||
|
||||
/**
|
||||
* Types for the package.
|
||||
@@ -227,11 +227,8 @@ typedef enum
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
JERRY_DEBUGGER_OUTPUT_OK = 1, /**< output result, no error */
|
||||
JERRY_DEBUGGER_OUTPUT_ERROR = 2, /**< output result, error */
|
||||
JERRY_DEBUGGER_OUTPUT_WARNING = 3, /**< output result, warning */
|
||||
JERRY_DEBUGGER_OUTPUT_DEBUG = 4, /**< output result, debug */
|
||||
JERRY_DEBUGGER_OUTPUT_TRACE = 5, /**< output result, trace */
|
||||
JERRY_DEBUGGER_OUTPUT_PRINT = 1, /**< printed output */
|
||||
JERRY_DEBUGGER_OUTPUT_LOG = 2, /**< logged output */
|
||||
} jerry_debugger_output_subtype_t;
|
||||
|
||||
/**
|
||||
@@ -455,7 +452,7 @@ typedef struct
|
||||
|
||||
/**
|
||||
* Incoming message: get scope variables
|
||||
*/
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
@@ -486,6 +483,6 @@ bool jerry_debugger_send_parse_function (uint32_t line, uint32_t column);
|
||||
void jerry_debugger_send_memstats (void);
|
||||
bool jerry_debugger_send_exception_string (ecma_value_t exception_value);
|
||||
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) */
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
|
||||
#endif /* !DEBUGGER_H */
|
||||
|
||||
@@ -14,10 +14,12 @@
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "ecma-gc.h"
|
||||
#include "jrt.h"
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
#include "jrt.h"
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_property_value_t) == sizeof (ecma_value_t),
|
||||
size_of_ecma_property_value_t_must_be_equal_to_size_of_ecma_value_t);
|
||||
@@ -51,7 +53,7 @@ JERRY_STATIC_ASSERT (sizeof (ecma_extended_object_t) - sizeof (ecma_object_t) <=
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
ecma_number_t *
|
||||
extern inline ecma_number_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_number (void)
|
||||
{
|
||||
return (ecma_number_t *) jmem_pools_alloc (sizeof (ecma_number_t));
|
||||
@@ -60,7 +62,7 @@ ecma_alloc_number (void)
|
||||
/**
|
||||
* Dealloc memory from an ecma-number
|
||||
*/
|
||||
void
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_dealloc_number (ecma_number_t *number_p) /**< number to be freed */
|
||||
{
|
||||
jmem_pools_free ((uint8_t *) number_p, sizeof (ecma_number_t));
|
||||
@@ -71,12 +73,12 @@ ecma_dealloc_number (ecma_number_t *number_p) /**< number to be freed */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern 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)
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_allocate_object_bytes (sizeof (ecma_object_t));
|
||||
#endif /* ENABLED (JERRY_MEM_STATS) */
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
return (ecma_object_t *) jmem_pools_alloc (sizeof (ecma_object_t));
|
||||
} /* ecma_alloc_object */
|
||||
@@ -87,9 +89,9 @@ ecma_alloc_object (void)
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_dealloc_object (ecma_object_t *object_p) /**< object to be freed */
|
||||
{
|
||||
#if ENABLED (JERRY_MEM_STATS)
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_free_object_bytes (sizeof (ecma_object_t));
|
||||
#endif /* ENABLED (JERRY_MEM_STATS) */
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
jmem_pools_free (object_p, sizeof (ecma_object_t));
|
||||
} /* ecma_dealloc_object */
|
||||
@@ -99,12 +101,12 @@ ecma_dealloc_object (ecma_object_t *object_p) /**< object to be freed */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern 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)
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_allocate_object_bytes (size);
|
||||
#endif /* ENABLED (JERRY_MEM_STATS) */
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
return jmem_heap_alloc_block (size);
|
||||
} /* ecma_alloc_extended_object */
|
||||
@@ -116,9 +118,9 @@ extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_dealloc_extended_object (ecma_object_t *object_p, /**< extended object */
|
||||
size_t size) /**< size of object */
|
||||
{
|
||||
#if ENABLED (JERRY_MEM_STATS)
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_free_object_bytes (size);
|
||||
#endif /* ENABLED (JERRY_MEM_STATS) */
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
jmem_heap_free_block (object_p, size);
|
||||
} /* ecma_dealloc_extended_object */
|
||||
@@ -128,12 +130,12 @@ ecma_dealloc_extended_object (ecma_object_t *object_p, /**< extended object */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern 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)
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_allocate_string_bytes (sizeof (ecma_string_t));
|
||||
#endif /* ENABLED (JERRY_MEM_STATS) */
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
return (ecma_string_t *) jmem_pools_alloc (sizeof (ecma_string_t));
|
||||
} /* ecma_alloc_string */
|
||||
@@ -144,9 +146,9 @@ ecma_alloc_string (void)
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_dealloc_string (ecma_string_t *string_p) /**< string to be freed */
|
||||
{
|
||||
#if ENABLED (JERRY_MEM_STATS)
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_free_string_bytes (sizeof (ecma_string_t));
|
||||
#endif /* ENABLED (JERRY_MEM_STATS) */
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
jmem_pools_free (string_p, sizeof (ecma_string_t));
|
||||
} /* ecma_dealloc_string */
|
||||
@@ -156,12 +158,12 @@ ecma_dealloc_string (ecma_string_t *string_p) /**< string to be freed */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern 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)
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_allocate_string_bytes (sizeof (ecma_extended_string_t));
|
||||
#endif /* ENABLED (JERRY_MEM_STATS) */
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
return (ecma_extended_string_t *) jmem_heap_alloc_block (sizeof (ecma_extended_string_t));
|
||||
} /* ecma_alloc_extended_string */
|
||||
@@ -172,9 +174,9 @@ ecma_alloc_extended_string (void)
|
||||
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)
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_free_string_bytes (sizeof (ecma_extended_string_t));
|
||||
#endif /* ENABLED (JERRY_MEM_STATS) */
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
jmem_heap_free_block (ext_string_p, sizeof (ecma_extended_string_t));
|
||||
} /* ecma_dealloc_extended_string */
|
||||
@@ -184,12 +186,12 @@ ecma_dealloc_extended_string (ecma_extended_string_t *ext_string_p) /**< extende
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_external_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_external_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_external_string (void)
|
||||
{
|
||||
#if ENABLED (JERRY_MEM_STATS)
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_allocate_string_bytes (sizeof (ecma_external_string_t));
|
||||
#endif /* ENABLED (JERRY_MEM_STATS) */
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
return (ecma_external_string_t *) jmem_heap_alloc_block (sizeof (ecma_external_string_t));
|
||||
} /* ecma_alloc_external_string */
|
||||
@@ -200,9 +202,9 @@ ecma_alloc_external_string (void)
|
||||
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)
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_free_string_bytes (sizeof (ecma_external_string_t));
|
||||
#endif /* ENABLED (JERRY_MEM_STATS) */
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
jmem_heap_free_block (ext_string_p, sizeof (ecma_external_string_t));
|
||||
} /* ecma_dealloc_external_string */
|
||||
@@ -212,12 +214,12 @@ ecma_dealloc_external_string (ecma_external_string_t *ext_string_p) /**< externa
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern 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)
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_allocate_string_bytes (size);
|
||||
#endif /* ENABLED (JERRY_MEM_STATS) */
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
return jmem_heap_alloc_block (size);
|
||||
} /* ecma_alloc_string_buffer */
|
||||
@@ -229,9 +231,9 @@ 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 */
|
||||
{
|
||||
#if ENABLED (JERRY_MEM_STATS)
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_free_string_bytes (size);
|
||||
#endif /* ENABLED (JERRY_MEM_STATS) */
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
jmem_heap_free_block (string_p, size);
|
||||
} /* ecma_dealloc_string_buffer */
|
||||
@@ -241,12 +243,12 @@ ecma_dealloc_string_buffer (ecma_string_t *string_p, /**< string with data */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern 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)
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_allocate_property_bytes (sizeof (ecma_property_pair_t));
|
||||
#endif /* ENABLED (JERRY_MEM_STATS) */
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
return jmem_heap_alloc_block (sizeof (ecma_property_pair_t));
|
||||
} /* ecma_alloc_property_pair */
|
||||
@@ -257,9 +259,9 @@ ecma_alloc_property_pair (void)
|
||||
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)
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_free_property_bytes (sizeof (ecma_property_pair_t));
|
||||
#endif /* ENABLED (JERRY_MEM_STATS) */
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
jmem_heap_free_block (property_pair_p, sizeof (ecma_property_pair_t));
|
||||
} /* ecma_dealloc_property_pair */
|
||||
|
||||
@@ -0,0 +1,759 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/* This file is automatically generated by the gen-strings.py script
|
||||
* from ecma-error-messages.ini. Do not edit! */
|
||||
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_GROUP, "Invalid group")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_ESCAPE, "Invalid escape")
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
#if JERRY_BUILTIN_ATOMICS || JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_LENGTH, "Invalid length")
|
||||
#endif /* JERRY_BUILTIN_ATOMICS \
|
||||
|| JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_OFFSET, "Invalid offset")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_OBJECT_EXPECTED, "Object expected")
|
||||
#if JERRY_BUILTIN_ANNEXB && JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_ARGUMENT, "Invalid argument")
|
||||
#endif /* JERRY_BUILTIN_ANNEXB && JERRY_BUILTIN_REGEXP */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_ENCODING, "Invalid encoding")
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_NOTHING_TO_REPEAT, "Nothing to repeat")
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_EXPECTED_AN_OBJECT, "Expected an object")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_CAPABILITY, "Invalid capability")
|
||||
#if JERRY_BUILTIN_STRING
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_CODE_POINT, "Invalid code point")
|
||||
#endif /* JERRY_BUILTIN_STRING */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_QUANTIFIER, "Invalid quantifier")
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_NO_SOURCE_ARGUMENT, "No source argument")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_UNTERMINATED_GROUP, "Unterminated group")
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_EXPECTED_A_FUNCTION, "Expected a function")
|
||||
#if JERRY_BUILTIN_JSON
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_JSON_FORMAT, "Invalid JSON format")
|
||||
#endif /* JERRY_BUILTIN_JSON */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_UTF8_STRING, "Invalid UTF8 string")
|
||||
#if JERRY_BUILTIN_STRING
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_COUNT_VALUE, "Invalid count value")
|
||||
#endif /* JERRY_BUILTIN_STRING */
|
||||
#if !(JERRY_BUILTIN_REALMS)
|
||||
ECMA_ERROR_DEF (ECMA_ERR_REALMS_ARE_DISABLED, "Realms are disabled")
|
||||
#endif /* !(JERRY_BUILTIN_REALMS) */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_UNDEFINED_REFERENCE, "Undefined reference")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_ARRAY_LENGTH, "Invalid Array length")
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_REGEXP_FLAGS, "Invalid RegExp flags")
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
#if JERRY_BUILTIN_JSON
|
||||
ECMA_ERROR_DEF (ECMA_ERR_JSON_STRINGIFY_ERROR, "JSON stringify error")
|
||||
#endif /* JERRY_BUILTIN_JSON */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_STACK_LIMIT_EXCEEDED, "Stack limit exceeded")
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
#if JERRY_BUILTIN_WEAKREF
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TARGET_IS_NOT_OBJECT, "Target is not Object")
|
||||
#endif /* JERRY_BUILTIN_WEAKREF */
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
ECMA_ERROR_DEF (ECMA_ERR_BIGINT_VALUE_EXCPECTED, "BigInt value expected")
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_BINDING_CANNOT_SET, "Binding cannot be set")
|
||||
#if JERRY_BUILTIN_STRING
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_STRING_, "Invalid string length")
|
||||
#endif /* JERRY_BUILTIN_STRING */
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
ECMA_ERROR_DEF (ECMA_ERR_KEY_MUST_BE_AN_OBJECT, "Key must be an object")
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
#if JERRY_BUILTIN_ARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_MISSING_ARRAY_ELEMENT, "Missing Array element")
|
||||
#endif /* JERRY_BUILTIN_ARRAY */
|
||||
#if JERRY_BUILTIN_WEAKREF
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TARGET_IS_NOT_WEAKREF, "Target is not weakRef")
|
||||
#endif /* JERRY_BUILTIN_WEAKREF */
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TARGET_NOT_EXTENSIBLE, "Target not extensible")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
#if JERRY_BUILTIN_ANNEXB
|
||||
ECMA_ERROR_DEF (ECMA_ERR_GETTER_IS_NOT_CALLABLE, "Getter is not callable")
|
||||
#endif /* JERRY_BUILTIN_ANNEXB */
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_HANDLER_CANNOT_BE_NULL, "Handler cannot be null")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_UTF8_CHARACTER, "Invalid UTF8 character")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_UTF8_CODEPOINT, "Invalid UTF8 codepoint")
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_CONTAINER_TYPE, "Invalid container type")
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_RANGE_OF_INDEX, "Invalid range of index")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if !(JERRY_BUILTIN_PROXY)
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PROXY_IS_NOT_SUPPORTED, "Proxy is not supported")
|
||||
#endif /* !(JERRY_BUILTIN_PROXY) */
|
||||
#if !(JERRY_BUILTIN_REALMS)
|
||||
ECMA_ERROR_DEF (ECMA_ERR_REALM_IS_NOT_AVAILABLE, "Realm is not available")
|
||||
#endif /* !(JERRY_BUILTIN_REALMS) */
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
ECMA_ERROR_DEF (ECMA_ERR_BIGINT_ZERO_DIVISION, "BigInt division by zero")
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_EXPECTED_AN_ARRAYBUFFER, "Expected an ArrayBuffer")
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_CHARACTER_CLASS, "Invalid character class")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_ESCAPE_SEQUENCE, "Invalid escape sequence")
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
#if JERRY_SNAPSHOT_EXEC
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_SNAPSHOT_FORMAT, "Invalid snapshot format")
|
||||
#endif /* JERRY_SNAPSHOT_EXEC */
|
||||
#if JERRY_BUILTIN_JSON
|
||||
ECMA_ERROR_DEF (ECMA_ERR_JSON_STRING_PARSE_ERROR, "JSON string parse error")
|
||||
#endif /* JERRY_BUILTIN_JSON */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_LONE_QUANTIFIER_BRACKET, "Lone quantifier bracket")
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_OBJECT_CANNOT_BE_FROZEN, "Object cannot be frozen")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_OBJECT_CANNOT_BE_SEALED, "Object cannot be sealed")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
#if !(JERRY_BUILTIN_REGEXP)
|
||||
ECMA_ERROR_DEF (ECMA_ERR_REGEXP_IS_NOT_SUPPORTED, "RegExp is not supported")
|
||||
#endif /* !(JERRY_BUILTIN_REGEXP) */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_UNMATCHED_CLOSE_BRACKET, "Unmatched close bracket")
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
ECMA_ERROR_DEF (ECMA_ERR_NOT_MODULE, "Argument is not a module")
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_SET_PROTOTYPE, "Cannot set [[Prototype]]")
|
||||
#if JERRY_BUILTIN_ARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_NEW_ARRAY_LENGTH, "Invalid new Array length")
|
||||
#endif /* JERRY_BUILTIN_ARRAY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_IS_NOT_CALLABLE, "Iterator is not callable")
|
||||
#if !(JERRY_BUILTIN_JSON)
|
||||
ECMA_ERROR_DEF (ECMA_ERR_JSON_NOT_SUPPORTED, "JSON support is disabled")
|
||||
#endif /* !(JERRY_BUILTIN_JSON) */
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
ECMA_ERROR_DEF (ECMA_ERR_MODULE_IS_IN_ERROR_STATE, "Module is in error state")
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_REJECT_MUST_BE_UNDEFINED, "Reject must be undefined")
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
ECMA_ERROR_DEF (ECMA_ERR_REQUEST_IS_NOT_AVAILABLE, "Request is not available")
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT, "Argument is not an object")
|
||||
#if JERRY_BUILTIN_ATOMICS
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_NOT_SUPPORTED, "Argument is not supported")
|
||||
#endif /* JERRY_BUILTIN_ATOMICS */
|
||||
#if JERRY_BUILTIN_STRING
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_CODE_POINT_ERROR, "Error: Invalid code point")
|
||||
#endif /* JERRY_BUILTIN_STRING */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_TYPEDARRAY_LENGTH, "Invalid TypedArray length")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_HEXADECIMAL_VALUE, "Invalid hexadecimal value")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_IS_NOT_AN_OBJECT, "Iterator is not an object")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_RESOLVE_MUST_BE_UNDEFINED, "Resolve must be undefined")
|
||||
#if JERRY_SNAPSHOT_SAVE
|
||||
ECMA_ERROR_DEF (ECMA_ERR_SNAPSHOT_BUFFER_SMALL, "Snapshot buffer too small")
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
#if JERRY_BUILTIN_JSON
|
||||
ECMA_ERROR_DEF (ECMA_ERR_THE_STRUCTURE_IS_CYCLICAL, "The structure is cyclical")
|
||||
#endif /* JERRY_BUILTIN_JSON */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_UNEXPECTED_END_OF_PATTERN, "Unexpected end of pattern")
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
#if JERRY_SNAPSHOT_SAVE
|
||||
ECMA_ERROR_DEF (ECMA_ERR_SNAPSHOT_UNSUPPORTED_COMPILED_CODE, "Unsupported compiled code")
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
#if !(JERRY_BUILTIN_BIGINT)
|
||||
ECMA_ERROR_DEF (ECMA_ERR_BIGINT_NOT_SUPPORTED, "BigInt support is disabled")
|
||||
#endif /* !(JERRY_BUILTIN_BIGINT) */
|
||||
#if JERRY_BUILTIN_DATAVIEW
|
||||
ECMA_ERROR_DEF (ECMA_ERR_EXPECTED_A_DATAVIEW_OBJECT, "Expected a DataView object")
|
||||
#endif /* JERRY_BUILTIN_DATAVIEW */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_EXPECTED_A_FUNCTION_OBJECT, "Expected a function object")
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_ARRAYBUFFER_LENGTH, "Invalid ArrayBuffer length")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if !(JERRY_MODULE_SYSTEM)
|
||||
ECMA_ERROR_DEF (ECMA_ERR_MODULE_NOT_SUPPORTED, "Module support is disabled")
|
||||
#endif /* !(JERRY_MODULE_SYSTEM) */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_OBJECT_IS_NOT_A_TYPEDARRAY, "Object is not a TypedArray")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_RECEIVER_MUST_BE_AN_OBJECT, "Receiver must be an object")
|
||||
#if JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_JSON
|
||||
ECMA_ERROR_DEF (ECMA_ERR_BIGINT_SERIALIZED, "BigInt cannot be serialized")
|
||||
#endif /* JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_JSON */
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONTAINER_IS_NOT_AN_OBJECT, "Container is not an object.")
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_HEX_ESCAPE_SEQUENCE, "Invalid hex escape sequence")
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_SPECIES_CONSTRUCTOR, "Invalid species constructor")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PROXY_TRAP_RETURNED_FALSISH, "Proxy trap returned falsish")
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_MIN_GREATER_THAN_MAX, "Quantifier error: min > max")
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_SYMBOL_IS_NOT_A_CONSTRUCTOR, "Symbol is not a constructor")
|
||||
#if JERRY_BUILTIN_REFLECT
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TARGET_IS_NOT_A_CONSTRUCTOR, "Target is not a constructor")
|
||||
#endif /* JERRY_BUILTIN_REFLECT */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ACCESSOR_WRITABLE, "Accessors cannot be writable")
|
||||
#if !(JERRY_BUILTIN_DATAVIEW)
|
||||
ECMA_ERROR_DEF (ECMA_ERR_DATA_VIEW_NOT_SUPPORTED, "DataView support is disabled")
|
||||
#endif /* !(JERRY_BUILTIN_DATAVIEW) */
|
||||
#if JERRY_BUILTIN_DATE
|
||||
ECMA_ERROR_DEF (ECMA_ERR_DATE_MUST_BE_A_FINITE_NUMBER, "Date must be a finite number")
|
||||
#endif /* JERRY_BUILTIN_DATE */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_LOCAL_VARIABLE_IS_REDECLARED, "Local variable is redeclared")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_UNSUPPORTED_BINARY_OPERATION, "Unsupported binary operation")
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_UNTERMINATED_CHARACTER_CLASS, "Unterminated character class")
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARRAYBUFFER_IS_DETACHED, "ArrayBuffer has been detached")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_NOT_AN_OBJECT, "Constructor must be an object")
|
||||
#if !(JERRY_BUILTIN_CONTAINER)
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONTAINER_NOT_SUPPORTED, "Container support is disabled")
|
||||
#endif /* !(JERRY_BUILTIN_CONTAINER) */
|
||||
#if JERRY_BUILTIN_REALMS
|
||||
ECMA_ERROR_DEF (ECMA_ERR_FIRST_ARGUMENT_IS_NOT_A_REALM, "First argument is not a realm")
|
||||
#endif /* JERRY_BUILTIN_REALMS */
|
||||
#if JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INCOMPATIBLE_TYPEDARRAY_TYPES, "Incompatible TypedArray types")
|
||||
#endif /* JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INCORRECT_TYPE_FOR_TYPEDARRAY, "Incorrect type for TypedArray")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_OR_OUT_OF_RANGE_INDEX, "Invalid or out-of-range index")
|
||||
#if JERRY_SNAPSHOT_SAVE
|
||||
ECMA_ERROR_DEF (ECMA_ERR_MAXIMUM_SNAPSHOT_SIZE, "Maximum snapshot size reached")
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
ECMA_ERROR_DEF (ECMA_ERR_MODULE_CANNOT_BE_INSTANTIATED, "Module cannot be instantiated")
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_SPECIES_MUST_BE_A_CONSTRUCTOR, "Species must be a constructor")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_IS_NOT_A_PROXY, "Argument is not a Proxy object")
|
||||
#if JERRY_BUILTIN_ATOMICS || JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_NOT_ARRAY_BUFFER, "Argument is not an ArrayBuffer")
|
||||
#endif /* JERRY_BUILTIN_ATOMICS \
|
||||
|| JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_MAP_REQUIRES_NEW, "Constructor Map requires 'new'")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_SET_REQUIRES_NEW, "Constructor Set requires 'new'")
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
ECMA_ERROR_DEF (ECMA_ERR_MODULE_MUST_BE_IN_LINKED_STATE, "Module must be in linked state")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_UNKNOWN_EXPORT, "Native module export not found")
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PASSED_ARGUMENT_IS_NOT_A_REALM, "Passed argument is not a realm")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PRIVATE_METHOD_IS_NOT_WRITABLE, "Private method is not writable")
|
||||
#if JERRY_BUILTIN_BIGINT || JERRY_BUILTIN_NUMBER
|
||||
ECMA_ERROR_DEF (ECMA_ERR_RADIX_IS_OUT_OF_RANGE, "Radix must be between 2 and 36")
|
||||
#endif /* JERRY_BUILTIN_BIGINT \
|
||||
|| JERRY_BUILTIN_NUMBER */
|
||||
#if !(JERRY_SNAPSHOT_EXEC)
|
||||
ECMA_ERROR_DEF (ECMA_ERR_SNAPSHOT_EXEC_DISABLED, "Snapshot execution is disabled")
|
||||
#endif /* !(JERRY_SNAPSHOT_EXEC) */
|
||||
#if !(JERRY_BUILTIN_TYPEDARRAY)
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TYPED_ARRAY_NOT_SUPPORTED, "TypedArray support is disabled")
|
||||
#endif /* !(JERRY_BUILTIN_TYPEDARRAY) */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_UNICODE_SURROGATE_PAIR_MISSING, "Unicode surrogate pair missing")
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_CONTROL_ESCAPE_SEQUENCE, "Invalid control escape sequence")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_UNICODE_ESCAPE_SEQUENCE, "Invalid unicode escape sequence")
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_NEXT_IS_NOT_CALLABLE, "Iterator 'next' is not callable")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_VALUE_IS_NOT_AN_OBJECT, "Iterator value is not an object")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_RESOLVE_METHOD_MUST_BE_CALLABLE, "Resolve method must be callable")
|
||||
#if !(JERRY_SNAPSHOT_SAVE)
|
||||
ECMA_ERROR_DEF (ECMA_ERR_SNAPSHOT_SAVE_DISABLED, "Snapshot generation is disabled")
|
||||
#endif /* !(JERRY_SNAPSHOT_SAVE) */
|
||||
#if !(JERRY_PARSER)
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PARSER_NOT_SUPPORTED, "Source code parsing is disabled")
|
||||
#endif /* !(JERRY_PARSER) */
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TRAP_MUST_RETURN_WITH_AN_OBJECT, "Trap must return with an object")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
ECMA_ERROR_DEF (ECMA_ERR_UNSUPPORTED_CONTAINER_OPERATION, "Unsupported container operation")
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_METHOD_RETURN_IS_NOT_CALLABLE, "method 'return' is not callable")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_PROMISE, "Argument 'this' is not a Promise")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT, "Argument 'this' is not an object")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_SYMBOL, "Argument 'this' must be a Symbol")
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CALLBACK_RESULT_NOT_MODULE, "Callback result must be a module")
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CLASS_CONSTRUCTOR_REQUIRES_NEW, "Class constructor requires 'new'")
|
||||
#if JERRY_BUILTIN_ARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_COMPARE_FUNC_NOT_CALLABLE, "Compare function is not callable")
|
||||
#endif /* JERRY_BUILTIN_ARRAY */
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_PROXY_REQUIRES_NEW, "Constructor Proxy requires 'new'")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_EXPECTED_A_CONFIGURABLE_PROPERTY, "Expected a configurable property")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_FIRST_PARAMETER_MUST_BE_CALLABLE, "First parameter must be callable")
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
ECMA_ERROR_DEF (ECMA_ERR_FUNCTION_ADD_ORSET_IS_NOT_CALLABLE, "Function add/set is not callable")
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_RESULT_IS_NOT_AN_OBJECT, "Iterator result is not an object")
|
||||
#if (JERRY_STACK_LIMIT != 0)
|
||||
ECMA_ERROR_DEF (ECMA_ERR_MAXIMUM_CALL_STACK_SIZE_EXCEEDED, "Maximum call stack size exceeded")
|
||||
#endif /* (JERRY_STACK_LIMIT != 0) */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_MAXIMUM_STRING_LENGTH_IS_REACHED, "Maximum string length is reached")
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
ECMA_ERROR_DEF (ECMA_ERR_MODULE_MUST_BE_IN_UNLINKED_STATE, "Module must be in unlinked state")
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
#if JERRY_SNAPSHOT_EXEC
|
||||
ECMA_ERROR_DEF (ECMA_ERR_STATIC_SNAPSHOTS_ARE_NOT_ENABLED, "Static snapshots are not enabled")
|
||||
#endif /* JERRY_SNAPSHOT_EXEC */
|
||||
#if JERRY_BUILTIN_WEAKREF
|
||||
ECMA_ERROR_DEF (ECMA_ERR_WEAKREF_TARGET_MUST_BE_AN_OBJECT, "WeakRef target must be an object")
|
||||
#endif /* JERRY_BUILTIN_WEAKREF */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_FUNCTION, "Argument 'this' is not a function")
|
||||
#if JERRY_BUILTIN_ARRAY || JERRY_BUILTIN_CONTAINER || JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CALLBACK_IS_NOT_CALLABLE, "Callback function is not callable")
|
||||
#endif /* JERRY_BUILTIN_ARRAY \
|
||||
|| JERRY_BUILTIN_CONTAINER \
|
||||
|| JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INITIAL_VALUE_CANNOT_BE_UNDEFINED, "Initial value cannot be undefined")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_SHAREDARRAYBUFFER
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_SHARED_ARRAYBUFFER_LENGTH, "Invalid Shared ArrayBuffer length")
|
||||
#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_TYPE_FOR_CONSTRUCTOR_CALL, "Invalid type for constructor call")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_THROW_IS_NOT_AVAILABLE, "Iterator 'throw' is not available")
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
ECMA_ERROR_DEF (ECMA_ERR_NAMESPACE_OBJECT_IS_NOT_AVAILABLE, "Namespace object is not available")
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PROXY_TARGET_IS_NOT_A_CONSTRUCTOR, "Proxy target is not a constructor")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
#if JERRY_BUILTIN_REALMS
|
||||
ECMA_ERROR_DEF (ECMA_ERR_SECOND_ARGUMENT_MUST_BE_AN_OBJECT, "Second argument must be an object")
|
||||
#endif /* JERRY_BUILTIN_REALMS */
|
||||
#if JERRY_BUILTIN_DATAVIEW
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_BUFFER_NOT_OBJECT, "Argument 'buffer' is not an object")
|
||||
#endif /* JERRY_BUILTIN_DATAVIEW */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_ITERATOR, "Argument 'this' is not an iterator")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_VALUE_MSG, "Argument cannot be marked as error")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_PROMISE_REQUIRES_NEW, "Constructor Promise requires 'new'")
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_WEAKMAP_REQUIRES_NEW, "Constructor WeakMap requires 'new'")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_WEAKSET_REQUIRES_NEW, "Constructor WeakSet requires 'new'")
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
#if JERRY_DEBUGGER
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_SCOPE_CHAIN_INDEX_FOR_EVAL, "Invalid scope chain index for eval")
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_MAXIMUM_TYPEDARRAY_SIZE_IS_REACHED, "Maximum TypedArray size is reached")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_THE_GIVEN_ARGUMENT_IS_NOT_A_SYMBOL, "The given argument is not a Symbol")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PARAMETER_REJECT_MUST_BE_CALLABLE, "'reject' parameter must be callable")
|
||||
#if JERRY_BUILTIN_ATOMICS || JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_TYPED_ARRAY, "Argument 'this' is not a TypedArray")
|
||||
#endif /* JERRY_BUILTIN_ATOMICS \
|
||||
|| JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_SNAPSHOT_SAVE
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CANNOT_ALLOCATE_MEMORY_LITERALS, "Cannot allocate memory for literals")
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVOKE_NULLABLE_SUPER_METHOD, "Cannot invoke nullable super method")
|
||||
#if JERRY_BUILTIN_DATAVIEW
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_DATAVIEW_REQUIRES_NEW, "Constructor DataView requires 'new'")
|
||||
#endif /* JERRY_BUILTIN_DATAVIEW */
|
||||
#if JERRY_BUILTIN_WEAKREF
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_WEAKREF_REQUIRES_NEW, "Constructor WeakRef requires 'new'.")
|
||||
#endif /* JERRY_BUILTIN_WEAKREF */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_SUPER_BINDING_MUST_BE_A_CONSTRUCTOR, "Super binding must be a constructor")
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
ECMA_ERROR_DEF (ECMA_ERR_VALUE_CANNOT_BE_CONVERTED_TO_BIGINT, "Value cannot be converted to BigInt")
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PARAMETER_RESOLVE_MUST_BE_CALLABLE, "'resolve' parameter must be callable")
|
||||
#if JERRY_BUILTIN_DATE
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_DATE_OBJECT, "Argument 'this' is not a Date object")
|
||||
#endif /* JERRY_BUILTIN_DATE */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_CONSTRUCTOR, "Argument 'this' is not a constructor")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
ECMA_ERROR_DEF (ECMA_ERR_BIGINT_FUNCTION_NOT_CONSTRUCTOR, "BigInt function is not a constructor")
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTED_OBJECT_IS_NOT_TYPEDARRAY, "Constructed object is not TypedArray")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_INT8_ARRAY_REQUIRES_NEW, "Constructor Int8Array requires 'new'")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONTAINER_IS_NOT_A_CONTAINER_OBJECT, "Container is not a container object.")
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
#if JERRY_BUILTIN_DATE
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_ARGUMENT_TYPE_IN_TOPRIMITIVE, "Invalid argument type in toPrimitive")
|
||||
#endif /* JERRY_BUILTIN_DATE */
|
||||
#if JERRY_ERROR_MESSAGES
|
||||
ECMA_ERROR_DEF (ECMA_ERR_METHODS_INVOKE_WITH_NEW, "Methods cannot be invoked with 'new'")
|
||||
#endif /* JERRY_ERROR_MESSAGES */
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
ECMA_ERROR_DEF (ECMA_ERR_MODULE_EXPORTS_MUST_BE_STRING_VALUES, "Module exports must be string values")
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PROTOTYPE_IS_NEITHER_OBJECT_NOR_NULL, "Prototype is neither object nor null")
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_THE_MAPFN_ARGUMENT_IS_NOT_CALLABLE, "The 'mapfn' argument is not callable")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_THE_TWO_DESCRIPTORS_ARE_INCOMPATIBLE, "The two descriptors are incompatible")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_WRONG_ARGS_MSG, "This type of argument is not allowed")
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONTAINER_NEEDED, "Value is not a Container or Iterator")
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_REG_EXP, "Argument 'this' is not a valid RegExp")
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARRAY_BUFFER_DETACHED, "ArrayBuffer has already been detached")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_BULTIN_ROUTINES_HAVE_NO_CONSTRUCTOR, "Built-in routines have no constructor")
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_INT16_ARRAY_REQUIRES_NEW, "Constructor Int16Array requires 'new'")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_INT32_ARRAY_REQUIRES_NEW, "Constructor Int32Array requires 'new'")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_UINT8_ARRAY_REQUIRES_NEW, "Constructor Uint8Array requires 'new'")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_SNAPSHOT_EXEC
|
||||
ECMA_ERROR_DEF (ECMA_ERR_FUNCTION_INDEX_IS_HIGHER_THAN_MAXIMUM, "Function index is higher than maximum")
|
||||
#endif /* JERRY_SNAPSHOT_EXEC */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_RANGE_OUT_OF_ORDER_IN_CHARACTER_CLASS, "Range out of order in character class")
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_RESULT_OF_DEFAULTVALUE_IS_INVALID, "Result of [[DefaultValue]] is invalid")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_RIGHT_VALUE_OF_IN_MUST_BE_AN_OBJECT, "Right value of 'in' must be an object")
|
||||
#if !(JERRY_BUILTIN_SHAREDARRAYBUFFER)
|
||||
ECMA_ERROR_DEF (ECMA_ERR_SHARED_ARRAYBUFFER_NOT_SUPPORTED, "SharedArrayBuffer support is disabled")
|
||||
#endif /* !(JERRY_BUILTIN_SHAREDARRAYBUFFER) */
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TRAP_RETURNED_NEITHER_OBJECT_NOR_NULL, "Trap returned neither object nor null")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TRAP_WITH_DUPLICATED_ENTRIES, "Trap returned with duplicated entries")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
ECMA_ERROR_DEF (ECMA_ERR_UNARY_PLUS_IS_NOT_ALLOWED_FOR_BIGINTS, "Unary plus is not allowed for BigInts")
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_IS_NOT_AN_REGEXP, "Argument 'this' is not a RegExp object")
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ALLOCATE_ARRAY_BUFFER, "Cannot allocate memory for ArrayBuffer")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTANT_BINDINGS_CANNOT_BE_REASSIGNED, "Constant bindings cannot be reassigned")
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_ARRAYBUFFER_REQUIRES_NEW, "Constructor ArrayBuffer requires 'new'")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_UINT16_ARRAY_REQUIRES_NEW, "Constructor Uint16Array requires 'new'")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_UINT32_ARRAY_REQUIRES_NEW, "Constructor Uint32Array requires 'new'")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_GENERATOR_IS_CURRENTLY_UNDER_EXECUTION, "Generator is currently under execution")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_RETURN_RESULT_IS_NOT_OBJECT, "Iterator 'return' result is not object")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_SEARCH_STRING_CANNOT_BE_OF_TYPE_REGEXP, "Search string can't be of type: RegExp")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_VALUE_RECEIVED_BY_YIELD_IS_NOT_OBJECT, "Value received by yield* is not object")
|
||||
#if JERRY_BUILTIN_BOOLEAN
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_BOOLEAN_OBJECT, "Argument 'this' is not a Boolean object")
|
||||
#endif /* JERRY_BUILTIN_BOOLEAN */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CANNOT_DECLARE_SAME_PRIVATE_FIELD_TWICE, "Cannot declare same private field twice")
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_FLOAT32_ARRAY_REQUIRES_NEW, "Constructor Float32Array requires 'new'")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY && JERRY_NUMBER_TYPE_FLOAT64
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_FLOAT64_ARRAY_REQUIRES_NEW, "Constructor Float64Array requires 'new'")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY && JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_FUNCTION_PROTOTYPE_NOT_A_CONSTRUCTOR, "Function.prototype is not a constructor")
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
ECMA_ERROR_DEF (ECMA_ERR_IMPORTED_BINDING_SHADOWS_LOCAL_VARIABLE, "Imported binding shadows local variable")
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PROTOTYPE_FROM_REVOKED_PROXY_IS_INVALID, "Prototype from revoked Proxy is invalid")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
#if JERRY_BUILTIN_REGEXP && JERRY_BUILTIN_STRING
|
||||
ECMA_ERROR_DEF (ECMA_ERR_REGEXP_ARGUMENT_SHOULD_HAVE_GLOBAL_FLAG, "RegExp argument should have global flag")
|
||||
#endif /* JERRY_BUILTIN_REGEXP && JERRY_BUILTIN_STRING */
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TRAP_IS_NEITHER_AN_OBJECT_NOR_UNDEFINED, "Trap is neither an object nor undefined")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PROMISE_RESOLVE_ITSELF, "A promise cannot be resolved with itself")
|
||||
#if JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_BIGINT64_ARRAY_REQUIRES_NEW, "Constructor BigInt64Array requires 'new'")
|
||||
#endif /* JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
ECMA_ERROR_DEF (ECMA_ERR_MODULE_EXPORTS_MUST_BE_VALID_IDENTIFIERS, "Module exports must be valid identifiers")
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_GENERATOR_OBJECT, "Argument 'this' is not a generator object")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_CANNOT_CONVERT_TO_OBJECT, "Argument cannot be converted to an object")
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ALLOCATE_BIGINT_VALUE, "Cannot allocate memory for a BigInt value")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONVERT_BIGINT_TO_NUMBER, "Cannot convert a BigInt value to a number")
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONVERT_SYMBOL_TO_NUMBER, "Cannot convert a Symbol value to a number")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONVERT_SYMBOL_TO_STRING, "Cannot convert a Symbol value to a string")
|
||||
#if JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_BIG_UINT64_ARRAY_REQUIRES_NEW, "Constructor BigUInt64Array requires 'new'")
|
||||
#endif /* JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_NUMBER
|
||||
ECMA_ERROR_DEF (ECMA_ERR_FRACTION_DIGITS_OUT_OF_RANGE, "Fraction digits must be between 0 and 100")
|
||||
#endif /* JERRY_BUILTIN_NUMBER */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_RETURN_VALUE_IS_NOT_AN_ARRAYBUFFER_OBJECT, "Return value is not an ArrayBuffer object")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_SUPER_CONSTRUCTOR_MAY_ONLY_BE_CALLED_ONCE, "Super constructor may only be called once")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_BINDING_NOT_EXIST_OR_UNINITIALIZED, "Binding does not exist or is uninitialised")
|
||||
#if JERRY_BUILTIN_ARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CANNOT_CONVERT_TO_OBJECT, "Cannot convert undefined or null to object")
|
||||
#endif /* JERRY_BUILTIN_ARRAY */
|
||||
#if JERRY_BUILTIN_NUMBER
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PRECISION_DIGITS_MUST_BE_BETWEEN_IN_RANGE, "Precision digits must be between 1 and 100")
|
||||
#endif /* JERRY_BUILTIN_NUMBER */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PRIVATE_FIELD_WAS_DEFINED_WITHOUT_A_GETTER, "Private field was defined without a getter")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PRIVATE_FIELD_WAS_DEFINED_WITHOUT_A_SETTER, "Private field was defined without a setter")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PROPERTY_NAME_IS_NEITHER_SYMBOL_NOR_STRING, "Property name is neither Symbol nor string")
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
ECMA_ERROR_DEF (ECMA_ERR_STRING_CANNOT_BE_CONVERTED_TO_BIGINT_VALUE, "String cannot be converted to BigInt value")
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INCORRECT_TYPE_CALL, "Operator called on incorrect container type")
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
#if JERRY_BUILTIN_ARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE, "Reduce of empty Array with no initial value")
|
||||
#endif /* JERRY_BUILTIN_ARRAY */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_REG_EXP_OBJECT, "Argument 'this' is not a valid RegExp object")
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_ARRAY_BUFFER_OBJECT, "Argument 'this' is not an ArrayBuffer object")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_ERROR_MESSAGES
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARROW_FUNCTIONS_INVOKE_WITH_NEW, "Arrow functions cannot be invoked with 'new'")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ASYNC_FUNCTIONS_INVOKE_WITH_NEW, "Async functions cannot be invoked with 'new'")
|
||||
#endif /* JERRY_ERROR_MESSAGES */
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_SET_EXTENSIBLE_PROPERTY, "Cannot set [[Extensible]] property of object")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
#if JERRY_BUILTIN_SHAREDARRAYBUFFER
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_SHAREDARRAYBUFFER_REQUIRES_NEW, "Constructor SharedArrayBuffer requires 'new'")
|
||||
#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_UINT8_CLAMPED_ARRAY_REQUIRES_NEW, "Constructor Uint8ClampedArray requires 'new'")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
ECMA_ERROR_DEF (ECMA_ERR_NEGATIVE_EXPONENT_IS_NOT_ALLOWED_FOR_BIGINTS, "Negative exponent is not allowed for BigInts")
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PROMISE_ALL_REMAINING_ELEMENTS_LIMIT_REACHED, "Promise.all remaining elements limit reached")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_VALUE_RECEIVED_BY_FOR_ASYNC_OF_IS_NOT_OBJECT, "Value received by for-async-of is not object")
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INFINITY_OR_NAN_CANNOT_BE_CONVERTED_TO_BIGINT, "Infinity or NaN cannot be converted to BigInt")
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_OPERATOR_DELETE_RETURNED_FALSE_IN_STRICT_MODE, "Operator delete returned false in strict mode")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PROPERTY_PROTOTYPE_IS_NOT_AN_OBJECT, "Property 'prototype' is not an object or null")
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PROXY_HANDLER_IS_NULL_FOR_ISARRAY_OPERATION, "Proxy handler is null for 'isArray' operation")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
#if JERRY_SNAPSHOT_SAVE
|
||||
ECMA_ERROR_DEF (ECMA_ERR_REGULAR_EXPRESSION_NOT_SUPPORTED, "Regular expression literals are not supported")
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_RIGHT_VALUE_OF_INSTANCEOF_MUST_BE_AN_OBJECT, "Right value of 'instanceof' must be an object")
|
||||
#if JERRY_SNAPSHOT_EXEC
|
||||
ECMA_ERROR_DEF (ECMA_ERR_STATIC_SNAPSHOTS_CANNOT_BE_COPIED_INTO_MEMORY, "Static snapshots cannot be copied into memory")
|
||||
#endif /* JERRY_SNAPSHOT_EXEC */
|
||||
#if JERRY_SNAPSHOT_SAVE
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TAGGED_TEMPLATE_LITERALS, "Unsupported feature: tagged template literals")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_SNAPSHOT_FLAG_NOT_SUPPORTED, "Unsupported generate snapshot flags specified")
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
#if JERRY_SNAPSHOT_EXEC
|
||||
ECMA_ERROR_DEF (ECMA_ERR_UNSUPPORTED_SNAPSHOT_EXEC_FLAGS_ARE_SPECIFIED, "Unsupported snapshot exec flags are specified")
|
||||
#endif /* JERRY_SNAPSHOT_EXEC */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_VALUE_FOR_CLASS_HERITAGE_IS_NOT_A_CONSTRUCTOR, "Value for class heritage is not a constructor")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TOO_MANY_ARGUMENTS_DECLARED_FOR_FUNCTION_APPLY,
|
||||
"Too many arguments declared for Function.apply")
|
||||
#if JERRY_ERROR_MESSAGES
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ACCESSOR_FUNCTIONS_INVOKE_WITH_NEW, "Accessor functions cannot be invoked with 'new'")
|
||||
#endif /* JERRY_ERROR_MESSAGES */
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
ECMA_ERROR_DEF (ECMA_ERR_LINK_TO_MODULE_IN_ERROR_STATE, "Cannot link to a module which is in error state")
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ONLY_INTEGER_NUMBERS_CAN_BE_CONVERTED_TO_BIGINT,
|
||||
"Only integer numbers can be converted to BigInt")
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TYPEDARRAY_INTRINSTIC_DIRECTLY_CALLED, "TypedArray intrinstic cannot be directly called")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
ECMA_ERROR_DEF (ECMA_ERR_UNSIGNED_RIGHT_SHIFT_IS_NOT_ALLOWED_FOR_BIGINTS,
|
||||
"Unsigned right shift is not allowed for BigInts")
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_ASYNC_GENERATOR, "Argument 'this' is not an async generator object")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CLASS_EXTENDS_NOT_CONSTRUCTOR, "Class extends value is not a constructor or null")
|
||||
#if JERRY_ERROR_MESSAGES
|
||||
ECMA_ERROR_DEF (ECMA_ERR_GENERATOR_FUNCTIONS_INVOKE_WITH_NEW, "Generator functions cannot be invoked with 'new'")
|
||||
#endif /* JERRY_ERROR_MESSAGES */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
ECMA_ERROR_DEF (ECMA_ERR_RETURN_VALUE_OF_EXEC_MUST_BE_AN_OBJECT_OR_NULL,
|
||||
"Return value of 'exec' must be an object or null")
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
#if JERRY_BUILTIN_DATAVIEW
|
||||
ECMA_ERROR_DEF (ECMA_ERR_START_OFFSET_IS_OUTSIDE_THE_BOUNDS_OF_THE_BUFFER,
|
||||
"Start offset is outside the bounds of the buffer")
|
||||
#endif /* JERRY_BUILTIN_DATAVIEW */
|
||||
#if JERRY_BUILTIN_SHAREDARRAYBUFFER
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_SHARED_ARRAY_BUFFER, "Argument 'this' is not a SharedArrayBuffer object")
|
||||
#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CLASS_CONSTRUCTOR_NEW, "Class constructor cannot be invoked without 'new'")
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INCORRECT_RETURN_PROXY_GET_TRAP, "Incorrect value is returned by a Proxy 'get' trap")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INCORRECT_RETURN_PROXY_SET_TRAP, "Incorrect value is returned by a Proxy 'set' trap")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CLASS_IS_NON_CONFIGURABLE, "Prototype property of a class is non-configurable")
|
||||
#if JERRY_BUILTIN_ARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PUSHING_TOO_HIGH_ELEMENT, "Pushing element over 2**53-1 length is disallowed")
|
||||
#endif /* JERRY_BUILTIN_ARRAY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_THE_REQUESTED_PROPERTY_UPDATE_CANNOT_BE_PERFORMED,
|
||||
"The requested property update cannot be performed")
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TRAP_RESULT_NOT_INCLUDE_ALL_CONFIGURABLE_KEYS,
|
||||
"Trap result did not include all configurable keys")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TRAP_TRUISH_TARGET_NOT_EXTENSIBLE, "Trap returned truish for target is not extensible")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
#if JERRY_BUILTIN_NUMBER
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_NUMBER, "Argument 'this' is not a number or a Number object")
|
||||
#endif /* JERRY_BUILTIN_NUMBER */
|
||||
#if JERRY_BUILTIN_STRING
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_STRING_OBJECT, "Argument 'this' is not a string or a String object")
|
||||
#endif /* JERRY_BUILTIN_STRING */
|
||||
#if JERRY_BUILTIN_SHAREDARRAYBUFFER
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_SHARED_ARRAY_BUFFER_OBJECT,
|
||||
"Argument 'this' is not an SharedArrayBuffer object")
|
||||
#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */
|
||||
#if JERRY_ERROR_MESSAGES
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ASYNC_ARROW_FUNCTIONS_INVOKE_WITH_NEW, "Async arrow functions cannot be invoked with 'new'")
|
||||
#endif /* JERRY_ERROR_MESSAGES */
|
||||
#if JERRY_BUILTIN_ARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_UNSHIFT_TOO_HIGH, "Unshift elements over 2**53-1 length is disallowed")
|
||||
#endif /* JERRY_BUILTIN_ARRAY */
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TRAP_RESULT_NOT_INCLUDE_ALL_NON_CONFIGURABLE_KEYS,
|
||||
"Trap result did not include all non-configurable keys")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
#if JERRY_ERROR_MESSAGES
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ASYNC_GENERATOR_FUNCTIONS_INVOKE_WITH_NEW,
|
||||
"Async generator functions cannot be invoked with 'new'")
|
||||
#endif /* JERRY_ERROR_MESSAGES */
|
||||
#if JERRY_BUILTIN_REFLECT
|
||||
ECMA_ERROR_DEF (ECMA_ERR_REFLECT_EXPECTS_AN_OBJECT_AS_SECOND_ARGUMENT,
|
||||
"Reflect.construct expects an object as second argument")
|
||||
#endif /* JERRY_BUILTIN_REFLECT */
|
||||
#if JERRY_ERROR_MESSAGES
|
||||
ECMA_ERROR_DEF (ECMA_ERR_SCRIPT_GLOBAL_FUNCTIONS_INVOKE_WITH_NEW,
|
||||
"Script (global) functions cannot be invoked with 'new'")
|
||||
#endif /* JERRY_ERROR_MESSAGES */
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CANNOT_CREATE_PROXY, "Cannot create Proxy with a non-object target or handler")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_DERIVED_CTOR_RETURN_NOR_OBJECT_OR_UNDEFINED,
|
||||
"Derived constructors may only return object or undefined")
|
||||
#if JERRY_SNAPSHOT_EXEC
|
||||
ECMA_ERROR_DEF (ECMA_ERR_INVALID_SNAPSHOT_VERSION_OR_FEATURES,
|
||||
"Invalid snapshot version or unsupported features present")
|
||||
#endif /* JERRY_SNAPSHOT_EXEC */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TYPEDARRAY_SMALLER_THAN_FILTER_CALL_RESULT,
|
||||
"Constructed TypedArray is smaller than filter call result")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_DERIVED_ARRAY_BUFFER_CTOR_BUFFER_TOO_SMALL,
|
||||
"Derived ArrayBuffer constructor created a too small buffer")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TRAP_RESULT_NOT_REFLECT_TARGET_EXTENSIBILITY,
|
||||
"Trap result does not reflect extensibility of Proxy target")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TRAP_EXTRA_KEYS_FOR_A_NON_EXTENSIBLE_TARGET,
|
||||
"Trap returned extra keys for a non-extensible Proxy target")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARRAY_BUFFER_RETURNED_THIS_FROM_CONSTRUCTOR,
|
||||
"ArrayBuffer subclass returned this from species constructor")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_DATAVIEW
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_BUFFER_NOT_ARRAY_OR_SHARED_BUFFER,
|
||||
"Argument 'buffer' is not an ArrayBuffer or SharedArrayBuffer")
|
||||
#endif /* JERRY_BUILTIN_DATAVIEW */
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TRAP_RESULT_NOT_REFLECT_TARGET_INEXTENSIBILITY,
|
||||
"Trap result does not reflect inextensibility of Proxy target")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TYPEDARRAY_INTRINSTIC_CALLED_BY_NEW_EXPRESSION,
|
||||
"TypedArray intrinstic cannot be called by a 'new' expression")
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CONTENTTYPE_RETURNED_TYPEDARRAY_NOT_MATCH_SOURCE,
|
||||
"TypedArray returned by [[ContentType]] does not match source")
|
||||
#endif /* JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
ECMA_ERROR_DEF (ECMA_ERR_ALLOCATE_BIGINT_STRING, "Cannot allocate memory for a string representation of a BigInt value")
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TARGET_NOT_EXTENSIBLE_DIFFERENT_PROTOTYPE_RETURNED,
|
||||
"Target object is non-extensible and trap returned different prototype")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TRAP_TRUISH_ADDING_PROPERTY_NON_EXTENSIBLE_TARGET,
|
||||
"Trap returned truish for adding property to the non-extensible target")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CANNOT_READ_PRIVATE_MEMBER_TO_AN_OBJECT_WHOSE_CLASS_DID_NOT_DECLARE_IT,
|
||||
"Cannot read private member to an object whose class did not declare it")
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_GIVEN_PROPERTY_IS_A_NON_CONFIGURABLE,
|
||||
"Given property is a non-configurable data property on the proxy target")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CANNOT_WRITE_PRIVATE_MEMBER_TO_AN_OBJECT_WHOSE_CLASS_DID_NOT_DECLARE_IT,
|
||||
"Cannot write private member to an object whose class did not declare it")
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TRAP_FALSISH_PROPERTY_TARGET_NOT_EXTENSIBLE,
|
||||
"Trap returned falsish for property but the proxy target is not extensible")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_PROXY_PROPERTY_NOT_CONFIGURABLE_NOT_HAVE_GETTER,
|
||||
"Property of a Proxy is non-configurable and does not have a getter function")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TARGET_PROPERTY_CONFIGURE_ACCESSOR_WITHOUT_SETTER,
|
||||
"The property of a Proxy target is a non configurable accessor without a setter")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_LET_CONST_NOT_INITIALIZED,
|
||||
"Variables declared by let/const must be initialized before reading their value")
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TRAP_TRUISH_PROPERTY_NON_CONFIGURABLE,
|
||||
"Trap returned truish for property which is non-configurable in the proxy target")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TARGET_NOT_EXTENSIBLE_NOT_RETURNED_ITS_PROTOTYPE,
|
||||
"Proxy target is non-extensible, but the trap did not return its actual prototype")
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TRAP_FALSISH_PROPERTY_NON_CONFIGURABLE,
|
||||
"Trap returned falsish for property which exists in the proxy target as non-configurable")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CALL_SUPER_CONSTRUCTOR_DERIVED_CLASS_BEFORE_THIS,
|
||||
"Must call super constructor in derived class before accessing 'this' or returning from it")
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
ECMA_ERROR_DEF (ECMA_ERR_TRAP_TRUISH_DEFINING_NON_EXISTENT_PROPERTY,
|
||||
"Trap returned truish for defining non-configurable property which is non-existent in the target")
|
||||
ECMA_ERROR_DEF (
|
||||
ECMA_ERR_TRAP_TRUISH_ADD_PROPERTY_INCOMPATIBLE_OTHER_PROP,
|
||||
"Trap returned truish for adding property that is incompatible with the existing property in the target")
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
ECMA_ERROR_DEF (ECMA_ERR_CANNOT_ACCESS_CALLER_CALLE_ARGUMENTS,
|
||||
"'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the "
|
||||
"arguments objects for calls to them")
|
||||
@@ -0,0 +1,330 @@
|
||||
# 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.
|
||||
|
||||
[ECMA_ERROR_MESSAGES]
|
||||
|
||||
ECMA_ERR_CANNOT_ACCESS_CALLER_CALLE_ARGUMENTS = "'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them"
|
||||
ECMA_ERR_PARAMETER_REJECT_MUST_BE_CALLABLE = "'reject' parameter must be callable"
|
||||
ECMA_ERR_PARAMETER_RESOLVE_MUST_BE_CALLABLE = "'resolve' parameter must be callable"
|
||||
ECMA_ERR_PROMISE_RESOLVE_ITSELF = "A promise cannot be resolved with itself"
|
||||
ECMA_ERR_ACCESSOR_WRITABLE = "Accessors cannot be writable"
|
||||
ECMA_ERR_ARGUMENT_BUFFER_NOT_ARRAY_OR_SHARED_BUFFER = "Argument 'buffer' is not an ArrayBuffer or SharedArrayBuffer"
|
||||
ECMA_ERR_ARGUMENT_BUFFER_NOT_OBJECT = "Argument 'buffer' is not an object"
|
||||
ECMA_ERR_ARGUMENT_THIS_NOT_ARRAY_BUFFER_OBJECT = "Argument 'this' is not an ArrayBuffer object"
|
||||
ECMA_ERR_ARGUMENT_THIS_NOT_BOOLEAN_OBJECT = "Argument 'this' is not a Boolean object"
|
||||
ECMA_ERR_ARGUMENT_THIS_NOT_DATE_OBJECT = "Argument 'this' is not a Date object"
|
||||
ECMA_ERR_ARGUMENT_THIS_NOT_PROMISE = "Argument 'this' is not a Promise"
|
||||
ECMA_ERR_ARGUMENT_THIS_NOT_SHARED_ARRAY_BUFFER = "Argument 'this' is not a SharedArrayBuffer object"
|
||||
ECMA_ERR_ARGUMENT_THIS_NOT_TYPED_ARRAY = "Argument 'this' is not a TypedArray"
|
||||
ECMA_ERR_ARGUMENT_THIS_NOT_CONSTRUCTOR = "Argument 'this' is not a constructor"
|
||||
ECMA_ERR_ARGUMENT_THIS_NOT_FUNCTION = "Argument 'this' is not a function"
|
||||
ECMA_ERR_ARGUMENT_THIS_NOT_GENERATOR_OBJECT = "Argument 'this' is not a generator object"
|
||||
ECMA_ERR_ARGUMENT_THIS_NOT_NUMBER = "Argument 'this' is not a number or a Number object"
|
||||
ECMA_ERR_ARGUMENT_THIS_NOT_STRING_OBJECT = "Argument 'this' is not a string or a String object"
|
||||
ECMA_ERR_ARGUMENT_THIS_NOT_REG_EXP = "Argument 'this' is not a valid RegExp"
|
||||
ECMA_ERR_ARGUMENT_THIS_NOT_REG_EXP_OBJECT = "Argument 'this' is not a valid RegExp object"
|
||||
ECMA_ERR_ARGUMENT_THIS_NOT_SHARED_ARRAY_BUFFER_OBJECT = "Argument 'this' is not an SharedArrayBuffer object"
|
||||
ECMA_ERR_ARGUMENT_THIS_NOT_ASYNC_GENERATOR = "Argument 'this' is not an async generator object"
|
||||
ECMA_ERR_ARGUMENT_THIS_NOT_ITERATOR = "Argument 'this' is not an iterator"
|
||||
ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT = "Argument 'this' is not an object"
|
||||
ECMA_ERR_ARGUMENT_THIS_NOT_SYMBOL = "Argument 'this' must be a Symbol"
|
||||
ECMA_ERR_ARGUMENT_CANNOT_CONVERT_TO_OBJECT = "Argument cannot be converted to an object"
|
||||
ECMA_ERR_ARGUMENT_NOT_ARRAY_BUFFER = "Argument is not an ArrayBuffer"
|
||||
ECMA_ERR_ARGUMENT_NOT_SUPPORTED = "Argument is not supported"
|
||||
ECMA_ERR_ARRAY_BUFFER_DETACHED = "ArrayBuffer has already been detached"
|
||||
ECMA_ERR_ARRAY_BUFFER_RETURNED_THIS_FROM_CONSTRUCTOR = "ArrayBuffer subclass returned this from species constructor"
|
||||
ECMA_ERR_BIGINT_SERIALIZED = "BigInt cannot be serialized"
|
||||
ECMA_ERR_BIGINT_ZERO_DIVISION = "BigInt division by zero"
|
||||
ECMA_ERR_BIGINT_FUNCTION_NOT_CONSTRUCTOR = "BigInt function is not a constructor"
|
||||
ECMA_ERR_BIGINT_VALUE_EXCPECTED = "BigInt value expected"
|
||||
ECMA_ERR_BINDING_CANNOT_SET = "Binding cannot be set"
|
||||
ECMA_ERR_BINDING_NOT_EXIST_OR_UNINITIALIZED = "Binding does not exist or is uninitialised"
|
||||
ECMA_ERR_BULTIN_ROUTINES_HAVE_NO_CONSTRUCTOR = "Built-in routines have no constructor"
|
||||
ECMA_ERR_CALLBACK_RESULT_NOT_MODULE = "Callback result must be a module"
|
||||
ECMA_ERR_ALLOCATE_ARRAY_BUFFER = "Cannot allocate memory for ArrayBuffer"
|
||||
ECMA_ERR_ALLOCATE_BIGINT_VALUE = "Cannot allocate memory for a BigInt value"
|
||||
ECMA_ERR_ALLOCATE_BIGINT_STRING = "Cannot allocate memory for a string representation of a BigInt value"
|
||||
ECMA_ERR_CONVERT_BIGINT_TO_NUMBER = "Cannot convert a BigInt value to a number"
|
||||
ECMA_ERR_CONVERT_SYMBOL_TO_NUMBER = "Cannot convert a Symbol value to a number"
|
||||
ECMA_ERR_CONVERT_SYMBOL_TO_STRING = "Cannot convert a Symbol value to a string"
|
||||
ECMA_ERR_CANNOT_CREATE_PROXY = "Cannot create Proxy with a non-object target or handler"
|
||||
ECMA_ERR_INVOKE_NULLABLE_SUPER_METHOD = "Cannot invoke nullable super method"
|
||||
ECMA_ERR_LINK_TO_MODULE_IN_ERROR_STATE = "Cannot link to a module which is in error state"
|
||||
ECMA_ERR_SET_EXTENSIBLE_PROPERTY = "Cannot set [[Extensible]] property of object"
|
||||
ECMA_ERR_SET_PROTOTYPE = "Cannot set [[Prototype]]"
|
||||
ECMA_ERR_CLASS_CONSTRUCTOR_REQUIRES_NEW = "Class constructor requires 'new'"
|
||||
ECMA_ERR_CLASS_EXTENDS_NOT_CONSTRUCTOR = "Class extends value is not a constructor or null"
|
||||
ECMA_ERR_COMPARE_FUNC_NOT_CALLABLE = "Compare function is not callable"
|
||||
ECMA_ERR_CONSTANT_BINDINGS_CANNOT_BE_REASSIGNED = "Constant bindings cannot be reassigned"
|
||||
ECMA_ERR_TYPEDARRAY_SMALLER_THAN_FILTER_CALL_RESULT = "Constructed TypedArray is smaller than filter call result"
|
||||
ECMA_ERR_CONSTRUCTED_OBJECT_IS_NOT_TYPEDARRAY = "Constructed object is not TypedArray"
|
||||
ECMA_ERR_CONSTRUCTOR_ARRAYBUFFER_REQUIRES_NEW = "Constructor ArrayBuffer requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_BIGINT64_ARRAY_REQUIRES_NEW = "Constructor BigInt64Array requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_BIG_UINT64_ARRAY_REQUIRES_NEW = "Constructor BigUInt64Array requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_DATAVIEW_REQUIRES_NEW = "Constructor DataView requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_FLOAT32_ARRAY_REQUIRES_NEW = "Constructor Float32Array requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_FLOAT64_ARRAY_REQUIRES_NEW = "Constructor Float64Array requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_INT16_ARRAY_REQUIRES_NEW = "Constructor Int16Array requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_INT32_ARRAY_REQUIRES_NEW = "Constructor Int32Array requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_INT8_ARRAY_REQUIRES_NEW = "Constructor Int8Array requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_MAP_REQUIRES_NEW = "Constructor Map requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_PROMISE_REQUIRES_NEW = "Constructor Promise requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_PROXY_REQUIRES_NEW = "Constructor Proxy requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_SET_REQUIRES_NEW = "Constructor Set requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_SHAREDARRAYBUFFER_REQUIRES_NEW = "Constructor SharedArrayBuffer requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_UINT16_ARRAY_REQUIRES_NEW = "Constructor Uint16Array requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_UINT32_ARRAY_REQUIRES_NEW = "Constructor Uint32Array requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_UINT8_ARRAY_REQUIRES_NEW = "Constructor Uint8Array requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_UINT8_CLAMPED_ARRAY_REQUIRES_NEW = "Constructor Uint8ClampedArray requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_WEAKMAP_REQUIRES_NEW = "Constructor WeakMap requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_WEAKREF_REQUIRES_NEW = "Constructor WeakRef requires 'new'."
|
||||
ECMA_ERR_CONSTRUCTOR_WEAKSET_REQUIRES_NEW = "Constructor WeakSet requires 'new'"
|
||||
ECMA_ERR_CONSTRUCTOR_NOT_AN_OBJECT = "Constructor must be an object"
|
||||
ECMA_ERR_CONTAINER_IS_NOT_A_CONTAINER_OBJECT = "Container is not a container object."
|
||||
ECMA_ERR_CONTAINER_IS_NOT_AN_OBJECT = "Container is not an object."
|
||||
ECMA_ERR_DATE_MUST_BE_A_FINITE_NUMBER = "Date must be a finite number"
|
||||
ECMA_ERR_DERIVED_ARRAY_BUFFER_CTOR_BUFFER_TOO_SMALL = "Derived ArrayBuffer constructor created a too small buffer"
|
||||
ECMA_ERR_DERIVED_CTOR_RETURN_NOR_OBJECT_OR_UNDEFINED = "Derived constructors may only return object or undefined"
|
||||
ECMA_ERR_INVALID_CODE_POINT_ERROR = "Error: Invalid code point"
|
||||
ECMA_ERR_EXPECTED_A_DATAVIEW_OBJECT = "Expected a DataView object"
|
||||
ECMA_ERR_EXPECTED_A_CONFIGURABLE_PROPERTY = "Expected a configurable property"
|
||||
ECMA_ERR_EXPECTED_A_FUNCTION_OBJECT = "Expected a function object"
|
||||
ECMA_ERR_EXPECTED_AN_ARRAYBUFFER = "Expected an ArrayBuffer"
|
||||
ECMA_ERR_EXPECTED_AN_OBJECT = "Expected an object"
|
||||
ECMA_ERR_FIRST_ARGUMENT_IS_NOT_A_REALM = "First argument is not a realm"
|
||||
ECMA_ERR_FIRST_PARAMETER_MUST_BE_CALLABLE = "First parameter must be callable"
|
||||
ECMA_ERR_FRACTION_DIGITS_OUT_OF_RANGE = "Fraction digits must be between 0 and 100"
|
||||
ECMA_ERR_FUNCTION_ADD_ORSET_IS_NOT_CALLABLE = "Function add/set is not callable"
|
||||
ECMA_ERR_FUNCTION_INDEX_IS_HIGHER_THAN_MAXIMUM = "Function index is higher than maximum"
|
||||
ECMA_ERR_FUNCTION_PROTOTYPE_NOT_A_CONSTRUCTOR = "Function.prototype is not a constructor"
|
||||
ECMA_ERR_GENERATOR_IS_CURRENTLY_UNDER_EXECUTION = "Generator is currently under execution"
|
||||
ECMA_ERR_GETTER_IS_NOT_CALLABLE = "Getter is not callable"
|
||||
ECMA_ERR_GIVEN_PROPERTY_IS_A_NON_CONFIGURABLE = "Given property is a non-configurable data property on the proxy target"
|
||||
ECMA_ERR_HANDLER_CANNOT_BE_NULL = "Handler cannot be null"
|
||||
ECMA_ERR_IMPORTED_BINDING_SHADOWS_LOCAL_VARIABLE = "Imported binding shadows local variable"
|
||||
ECMA_ERR_INCOMPATIBLE_TYPEDARRAY_TYPES = "Incompatible TypedArray types"
|
||||
ECMA_ERR_INCORRECT_TYPE_FOR_TYPEDARRAY = "Incorrect type for TypedArray"
|
||||
ECMA_ERR_INCORRECT_RETURN_PROXY_GET_TRAP = "Incorrect value is returned by a Proxy 'get' trap"
|
||||
ECMA_ERR_INCORRECT_RETURN_PROXY_SET_TRAP = "Incorrect value is returned by a Proxy 'set' trap"
|
||||
ECMA_ERR_INFINITY_OR_NAN_CANNOT_BE_CONVERTED_TO_BIGINT = "Infinity or NaN cannot be converted to BigInt"
|
||||
ECMA_ERR_INITIAL_VALUE_CANNOT_BE_UNDEFINED = "Initial value cannot be undefined"
|
||||
ECMA_ERR_INVALID_ARRAYBUFFER_LENGTH = "Invalid ArrayBuffer length"
|
||||
ECMA_ERR_INVALID_JSON_FORMAT = "Invalid JSON format"
|
||||
ECMA_ERR_INVALID_REGEXP_FLAGS = "Invalid RegExp flags"
|
||||
ECMA_ERR_INVALID_SHARED_ARRAYBUFFER_LENGTH = "Invalid Shared ArrayBuffer length"
|
||||
ECMA_ERR_INVALID_TYPEDARRAY_LENGTH = "Invalid TypedArray length"
|
||||
ECMA_ERR_INVALID_UTF8_CHARACTER = "Invalid UTF8 character"
|
||||
ECMA_ERR_INVALID_UTF8_CODEPOINT = "Invalid UTF8 codepoint"
|
||||
ECMA_ERR_INVALID_UTF8_STRING = "Invalid UTF8 string"
|
||||
ECMA_ERR_INVALID_ENCODING = "Invalid encoding"
|
||||
ECMA_ERR_INVALID_ARGUMENT = "Invalid argument"
|
||||
ECMA_ERR_INVALID_ARGUMENT_TYPE_IN_TOPRIMITIVE = "Invalid argument type in toPrimitive"
|
||||
ECMA_ERR_INVALID_CAPABILITY = "Invalid capability"
|
||||
ECMA_ERR_INVALID_CHARACTER_CLASS = "Invalid character class"
|
||||
ECMA_ERR_INVALID_CODE_POINT = "Invalid code point"
|
||||
ECMA_ERR_INVALID_CONTAINER_TYPE = "Invalid container type"
|
||||
ECMA_ERR_INVALID_CONTROL_ESCAPE_SEQUENCE = "Invalid control escape sequence"
|
||||
ECMA_ERR_INVALID_COUNT_VALUE = "Invalid count value"
|
||||
ECMA_ERR_INVALID_ESCAPE = "Invalid escape"
|
||||
ECMA_ERR_INVALID_ESCAPE_SEQUENCE = "Invalid escape sequence"
|
||||
ECMA_ERR_INVALID_GROUP = "Invalid group"
|
||||
ECMA_ERR_INVALID_HEX_ESCAPE_SEQUENCE = "Invalid hex escape sequence"
|
||||
ECMA_ERR_INVALID_HEXADECIMAL_VALUE = "Invalid hexadecimal value"
|
||||
ECMA_ERR_INVALID_LENGTH = "Invalid length"
|
||||
ECMA_ERR_INVALID_NEW_ARRAY_LENGTH = "Invalid new Array length"
|
||||
ECMA_ERR_INVALID_OFFSET = "Invalid offset"
|
||||
ECMA_ERR_INVALID_OR_OUT_OF_RANGE_INDEX = "Invalid or out-of-range index"
|
||||
ECMA_ERR_INVALID_QUANTIFIER = "Invalid quantifier"
|
||||
ECMA_ERR_INVALID_RANGE_OF_INDEX = "Invalid range of index"
|
||||
ECMA_ERR_INVALID_SCOPE_CHAIN_INDEX_FOR_EVAL = "Invalid scope chain index for eval"
|
||||
ECMA_ERR_INVALID_SPECIES_CONSTRUCTOR = "Invalid species constructor"
|
||||
ECMA_ERR_INVALID_STRING_ = "Invalid string length"
|
||||
ECMA_ERR_INVALID_UNICODE_ESCAPE_SEQUENCE = "Invalid unicode escape sequence"
|
||||
ECMA_ERR_ITERATOR_NEXT_IS_NOT_CALLABLE = "Iterator 'next' is not callable"
|
||||
ECMA_ERR_ITERATOR_RETURN_RESULT_IS_NOT_OBJECT = "Iterator 'return' result is not object"
|
||||
ECMA_ERR_ITERATOR_THROW_IS_NOT_AVAILABLE = "Iterator 'throw' is not available"
|
||||
ECMA_ERR_ITERATOR_IS_NOT_AN_OBJECT = "Iterator is not an object"
|
||||
ECMA_ERR_ITERATOR_IS_NOT_CALLABLE = "Iterator is not callable"
|
||||
ECMA_ERR_ITERATOR_RESULT_IS_NOT_AN_OBJECT = "Iterator result is not an object"
|
||||
ECMA_ERR_ITERATOR_VALUE_IS_NOT_AN_OBJECT = "Iterator value is not an object"
|
||||
ECMA_ERR_JSON_STRING_PARSE_ERROR = "JSON string parse error"
|
||||
ECMA_ERR_JSON_STRINGIFY_ERROR = "JSON stringify error"
|
||||
ECMA_ERR_KEY_MUST_BE_AN_OBJECT = "Key must be an object"
|
||||
ECMA_ERR_LONE_QUANTIFIER_BRACKET = "Lone quantifier bracket"
|
||||
ECMA_ERR_MAXIMUM_TYPEDARRAY_SIZE_IS_REACHED = "Maximum TypedArray size is reached"
|
||||
ECMA_ERR_MAXIMUM_STRING_LENGTH_IS_REACHED = "Maximum string length is reached"
|
||||
ECMA_ERR_MISSING_ARRAY_ELEMENT = "Missing Array element"
|
||||
ECMA_ERR_MODULE_CANNOT_BE_INSTANTIATED = "Module cannot be instantiated"
|
||||
ECMA_ERR_MODULE_EXPORTS_MUST_BE_STRING_VALUES = "Module exports must be string values"
|
||||
ECMA_ERR_MODULE_EXPORTS_MUST_BE_VALID_IDENTIFIERS = "Module exports must be valid identifiers"
|
||||
ECMA_ERR_MODULE_IS_IN_ERROR_STATE = "Module is in error state"
|
||||
ECMA_ERR_MODULE_MUST_BE_IN_LINKED_STATE = "Module must be in linked state"
|
||||
ECMA_ERR_MODULE_MUST_BE_IN_UNLINKED_STATE = "Module must be in unlinked state"
|
||||
ECMA_ERR_CALL_SUPER_CONSTRUCTOR_DERIVED_CLASS_BEFORE_THIS = "Must call super constructor in derived class before accessing 'this' or returning from it"
|
||||
ECMA_ERR_NAMESPACE_OBJECT_IS_NOT_AVAILABLE = "Namespace object is not available"
|
||||
ECMA_ERR_NEGATIVE_EXPONENT_IS_NOT_ALLOWED_FOR_BIGINTS = "Negative exponent is not allowed for BigInts"
|
||||
ECMA_ERR_NO_SOURCE_ARGUMENT = "No source argument"
|
||||
ECMA_ERR_NOTHING_TO_REPEAT = "Nothing to repeat"
|
||||
ECMA_ERR_OBJECT_CANNOT_BE_FROZEN = "Object cannot be frozen"
|
||||
ECMA_ERR_OBJECT_CANNOT_BE_SEALED = "Object cannot be sealed"
|
||||
ECMA_ERR_OBJECT_EXPECTED = "Object expected"
|
||||
ECMA_ERR_OBJECT_IS_NOT_A_TYPEDARRAY = "Object is not a TypedArray"
|
||||
ECMA_ERR_ONLY_INTEGER_NUMBERS_CAN_BE_CONVERTED_TO_BIGINT = "Only integer numbers can be converted to BigInt"
|
||||
ECMA_ERR_OPERATOR_DELETE_RETURNED_FALSE_IN_STRICT_MODE = "Operator delete returned false in strict mode"
|
||||
ECMA_ERR_PASSED_ARGUMENT_IS_NOT_A_REALM = "Passed argument is not a realm"
|
||||
ECMA_ERR_PRECISION_DIGITS_MUST_BE_BETWEEN_IN_RANGE = "Precision digits must be between 1 and 100"
|
||||
ECMA_ERR_PROMISE_ALL_REMAINING_ELEMENTS_LIMIT_REACHED = "Promise.all remaining elements limit reached"
|
||||
ECMA_ERR_PROPERTY_PROTOTYPE_IS_NOT_AN_OBJECT = "Property 'prototype' is not an object or null"
|
||||
ECMA_ERR_PROPERTY_NAME_IS_NEITHER_SYMBOL_NOR_STRING = "Property name is neither Symbol nor string"
|
||||
ECMA_ERR_PROXY_PROPERTY_NOT_CONFIGURABLE_NOT_HAVE_GETTER = "Property of a Proxy is non-configurable and does not have a getter function"
|
||||
ECMA_ERR_PROTOTYPE_FROM_REVOKED_PROXY_IS_INVALID = "Prototype from revoked Proxy is invalid"
|
||||
ECMA_ERR_PROTOTYPE_IS_NEITHER_OBJECT_NOR_NULL = "Prototype is neither object nor null"
|
||||
ECMA_ERR_PROXY_HANDLER_IS_NULL_FOR_ISARRAY_OPERATION = "Proxy handler is null for 'isArray' operation"
|
||||
ECMA_ERR_PROXY_IS_NOT_SUPPORTED = "Proxy is not supported"
|
||||
ECMA_ERR_TARGET_NOT_EXTENSIBLE_NOT_RETURNED_ITS_PROTOTYPE = "Proxy target is non-extensible, but the trap did not return its actual prototype"
|
||||
ECMA_ERR_PROXY_TRAP_RETURNED_FALSISH = "Proxy trap returned falsish"
|
||||
ECMA_ERR_PUSHING_TOO_HIGH_ELEMENT = "Pushing element over 2**53-1 length is disallowed"
|
||||
ECMA_ERR_MIN_GREATER_THAN_MAX = "Quantifier error: min > max"
|
||||
ECMA_ERR_RADIX_IS_OUT_OF_RANGE = "Radix must be between 2 and 36"
|
||||
ECMA_ERR_RANGE_OUT_OF_ORDER_IN_CHARACTER_CLASS = "Range out of order in character class"
|
||||
ECMA_ERR_REALM_IS_NOT_AVAILABLE = "Realm is not available"
|
||||
ECMA_ERR_REALMS_ARE_DISABLED = "Realms are disabled"
|
||||
ECMA_ERR_REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE = "Reduce of empty Array with no initial value"
|
||||
ECMA_ERR_REFLECT_EXPECTS_AN_OBJECT_AS_SECOND_ARGUMENT = "Reflect.construct expects an object as second argument"
|
||||
ECMA_ERR_REGEXP_ARGUMENT_SHOULD_HAVE_GLOBAL_FLAG = "RegExp argument should have global flag"
|
||||
ECMA_ERR_REGEXP_IS_NOT_SUPPORTED = "RegExp is not supported"
|
||||
ECMA_ERR_REJECT_MUST_BE_UNDEFINED = "Reject must be undefined"
|
||||
ECMA_ERR_REQUEST_IS_NOT_AVAILABLE = "Request is not available"
|
||||
ECMA_ERR_RESOLVE_METHOD_MUST_BE_CALLABLE = "Resolve method must be callable"
|
||||
ECMA_ERR_RESOLVE_MUST_BE_UNDEFINED = "Resolve must be undefined"
|
||||
ECMA_ERR_RESULT_OF_DEFAULTVALUE_IS_INVALID = "Result of [[DefaultValue]] is invalid"
|
||||
ECMA_ERR_RETURN_VALUE_IS_NOT_AN_ARRAYBUFFER_OBJECT = "Return value is not an ArrayBuffer object"
|
||||
ECMA_ERR_RETURN_VALUE_OF_EXEC_MUST_BE_AN_OBJECT_OR_NULL = "Return value of 'exec' must be an object or null"
|
||||
ECMA_ERR_RIGHT_VALUE_OF_IN_MUST_BE_AN_OBJECT = "Right value of 'in' must be an object"
|
||||
ECMA_ERR_RIGHT_VALUE_OF_INSTANCEOF_MUST_BE_AN_OBJECT = "Right value of 'instanceof' must be an object"
|
||||
ECMA_ERR_SEARCH_STRING_CANNOT_BE_OF_TYPE_REGEXP = "Search string can't be of type: RegExp"
|
||||
ECMA_ERR_SECOND_ARGUMENT_MUST_BE_AN_OBJECT = "Second argument must be an object"
|
||||
ECMA_ERR_SPECIES_MUST_BE_A_CONSTRUCTOR = "Species must be a constructor"
|
||||
ECMA_ERR_STACK_LIMIT_EXCEEDED = "Stack limit exceeded"
|
||||
ECMA_ERR_START_OFFSET_IS_OUTSIDE_THE_BOUNDS_OF_THE_BUFFER = "Start offset is outside the bounds of the buffer"
|
||||
ECMA_ERR_STATIC_SNAPSHOTS_ARE_NOT_ENABLED = "Static snapshots are not enabled"
|
||||
ECMA_ERR_STATIC_SNAPSHOTS_CANNOT_BE_COPIED_INTO_MEMORY = "Static snapshots cannot be copied into memory"
|
||||
ECMA_ERR_STRING_CANNOT_BE_CONVERTED_TO_BIGINT_VALUE = "String cannot be converted to BigInt value"
|
||||
ECMA_ERR_SUPER_BINDING_MUST_BE_A_CONSTRUCTOR = "Super binding must be a constructor"
|
||||
ECMA_ERR_SUPER_CONSTRUCTOR_MAY_ONLY_BE_CALLED_ONCE = "Super constructor may only be called once"
|
||||
ECMA_ERR_SYMBOL_IS_NOT_A_CONSTRUCTOR = "Symbol is not a constructor"
|
||||
ECMA_ERR_TARGET_IS_NOT_OBJECT = "Target is not Object"
|
||||
ECMA_ERR_TARGET_IS_NOT_WEAKREF = "Target is not weakRef"
|
||||
ECMA_ERR_TARGET_NOT_EXTENSIBLE = "Target not extensible"
|
||||
ECMA_ERR_TARGET_NOT_EXTENSIBLE_DIFFERENT_PROTOTYPE_RETURNED = "Target object is non-extensible and trap returned different prototype"
|
||||
ECMA_ERR_THE_MAPFN_ARGUMENT_IS_NOT_CALLABLE = "The 'mapfn' argument is not callable"
|
||||
ECMA_ERR_THE_GIVEN_ARGUMENT_IS_NOT_A_SYMBOL = "The given argument is not a Symbol"
|
||||
ECMA_ERR_TARGET_PROPERTY_CONFIGURE_ACCESSOR_WITHOUT_SETTER = "The property of a Proxy target is a non configurable accessor without a setter"
|
||||
ECMA_ERR_THE_REQUESTED_PROPERTY_UPDATE_CANNOT_BE_PERFORMED = "The requested property update cannot be performed"
|
||||
ECMA_ERR_THE_STRUCTURE_IS_CYCLICAL = "The structure is cyclical"
|
||||
ECMA_ERR_THE_TWO_DESCRIPTORS_ARE_INCOMPATIBLE = "The two descriptors are incompatible"
|
||||
ECMA_ERR_TOO_MANY_ARGUMENTS_DECLARED_FOR_FUNCTION_APPLY = "Too many arguments declared for Function.apply"
|
||||
ECMA_ERR_TRAP_IS_NEITHER_AN_OBJECT_NOR_UNDEFINED = "Trap is neither an object nor undefined"
|
||||
ECMA_ERR_TRAP_MUST_RETURN_WITH_AN_OBJECT = "Trap must return with an object"
|
||||
ECMA_ERR_TRAP_RESULT_NOT_INCLUDE_ALL_CONFIGURABLE_KEYS = "Trap result did not include all configurable keys"
|
||||
ECMA_ERR_TRAP_RESULT_NOT_INCLUDE_ALL_NON_CONFIGURABLE_KEYS = "Trap result did not include all non-configurable keys"
|
||||
ECMA_ERR_TRAP_RESULT_NOT_REFLECT_TARGET_EXTENSIBILITY = "Trap result does not reflect extensibility of Proxy target"
|
||||
ECMA_ERR_TRAP_RESULT_NOT_REFLECT_TARGET_INEXTENSIBILITY = "Trap result does not reflect inextensibility of Proxy target"
|
||||
ECMA_ERR_TRAP_EXTRA_KEYS_FOR_A_NON_EXTENSIBLE_TARGET = "Trap returned extra keys for a non-extensible Proxy target"
|
||||
ECMA_ERR_TRAP_FALSISH_PROPERTY_TARGET_NOT_EXTENSIBLE = "Trap returned falsish for property but the proxy target is not extensible"
|
||||
ECMA_ERR_TRAP_FALSISH_PROPERTY_NON_CONFIGURABLE = "Trap returned falsish for property which exists in the proxy target as non-configurable"
|
||||
ECMA_ERR_TRAP_RETURNED_NEITHER_OBJECT_NOR_NULL = "Trap returned neither object nor null"
|
||||
ECMA_ERR_TRAP_TRUISH_ADDING_PROPERTY_NON_EXTENSIBLE_TARGET = "Trap returned truish for adding property to the non-extensible target"
|
||||
ECMA_ERR_TRAP_TRUISH_ADD_PROPERTY_INCOMPATIBLE_OTHER_PROP = "Trap returned truish for adding property that is incompatible with the existing property in the target"
|
||||
ECMA_ERR_TRAP_TRUISH_DEFINING_NON_EXISTENT_PROPERTY = "Trap returned truish for defining non-configurable property which is non-existent in the target"
|
||||
ECMA_ERR_TRAP_TRUISH_PROPERTY_NON_CONFIGURABLE = "Trap returned truish for property which is non-configurable in the proxy target"
|
||||
ECMA_ERR_TRAP_TRUISH_TARGET_NOT_EXTENSIBLE = "Trap returned truish for target is not extensible"
|
||||
ECMA_ERR_TRAP_WITH_DUPLICATED_ENTRIES = "Trap returned with duplicated entries"
|
||||
ECMA_ERR_TYPEDARRAY_INTRINSTIC_CALLED_BY_NEW_EXPRESSION = "TypedArray intrinstic cannot be called by a 'new' expression"
|
||||
ECMA_ERR_TYPEDARRAY_INTRINSTIC_DIRECTLY_CALLED = "TypedArray intrinstic cannot be directly called"
|
||||
ECMA_ERR_CONTENTTYPE_RETURNED_TYPEDARRAY_NOT_MATCH_SOURCE = "TypedArray returned by [[ContentType]] does not match source"
|
||||
ECMA_ERR_UNARY_PLUS_IS_NOT_ALLOWED_FOR_BIGINTS = "Unary plus is not allowed for BigInts"
|
||||
ECMA_ERR_UNDEFINED_REFERENCE = "Undefined reference"
|
||||
ECMA_ERR_UNEXPECTED_END_OF_PATTERN = "Unexpected end of pattern"
|
||||
ECMA_ERR_UNICODE_SURROGATE_PAIR_MISSING = "Unicode surrogate pair missing"
|
||||
ECMA_ERR_UNMATCHED_CLOSE_BRACKET = "Unmatched close bracket"
|
||||
ECMA_ERR_UNSHIFT_TOO_HIGH = "Unshift elements over 2**53-1 length is disallowed"
|
||||
ECMA_ERR_UNSIGNED_RIGHT_SHIFT_IS_NOT_ALLOWED_FOR_BIGINTS = "Unsigned right shift is not allowed for BigInts"
|
||||
ECMA_ERR_UNSUPPORTED_BINARY_OPERATION = "Unsupported binary operation"
|
||||
ECMA_ERR_UNSUPPORTED_CONTAINER_OPERATION = "Unsupported container operation"
|
||||
ECMA_ERR_UNSUPPORTED_SNAPSHOT_EXEC_FLAGS_ARE_SPECIFIED = "Unsupported snapshot exec flags are specified"
|
||||
ECMA_ERR_UNTERMINATED_CHARACTER_CLASS = "Unterminated character class"
|
||||
ECMA_ERR_UNTERMINATED_GROUP = "Unterminated group"
|
||||
ECMA_ERR_VALUE_CANNOT_BE_CONVERTED_TO_BIGINT = "Value cannot be converted to BigInt"
|
||||
ECMA_ERR_VALUE_FOR_CLASS_HERITAGE_IS_NOT_A_CONSTRUCTOR = "Value for class heritage is not a constructor"
|
||||
ECMA_ERR_VALUE_RECEIVED_BY_FOR_ASYNC_OF_IS_NOT_OBJECT = "Value received by for-async-of is not object"
|
||||
ECMA_ERR_VALUE_RECEIVED_BY_YIELD_IS_NOT_OBJECT = "Value received by yield* is not object"
|
||||
ECMA_ERR_WEAKREF_TARGET_MUST_BE_AN_OBJECT = "WeakRef target must be an object"
|
||||
ECMA_ERR_METHOD_RETURN_IS_NOT_CALLABLE = "method 'return' is not callable"
|
||||
ECMA_ERR_VALUE_MSG = "Argument cannot be marked as error"
|
||||
ECMA_ERR_WRONG_ARGS_MSG = "This type of argument is not allowed"
|
||||
ECMA_ERR_PARSER_NOT_SUPPORTED = "Source code parsing is disabled"
|
||||
ECMA_ERR_JSON_NOT_SUPPORTED = "JSON support is disabled"
|
||||
ECMA_ERR_TYPED_ARRAY_NOT_SUPPORTED = "TypedArray support is disabled"
|
||||
ECMA_ERR_SHARED_ARRAYBUFFER_NOT_SUPPORTED = "SharedArrayBuffer support is disabled"
|
||||
ECMA_ERR_DATA_VIEW_NOT_SUPPORTED = "DataView support is disabled"
|
||||
ECMA_ERR_BIGINT_NOT_SUPPORTED = "BigInt support is disabled"
|
||||
ECMA_ERR_CONTAINER_NOT_SUPPORTED = "Container support is disabled"
|
||||
ECMA_ERR_NOT_MODULE = "Argument is not a module"
|
||||
ECMA_ERR_UNKNOWN_EXPORT = "Native module export not found"
|
||||
ECMA_ERR_MODULE_NOT_SUPPORTED = "Module support is disabled"
|
||||
ECMA_ERR_CALLBACK_IS_NOT_CALLABLE = "Callback function is not callable"
|
||||
ECMA_ERR_ARRAYBUFFER_IS_DETACHED = "ArrayBuffer has been detached"
|
||||
ECMA_ERR_CANNOT_CONVERT_TO_OBJECT = "Cannot convert undefined or null to object"
|
||||
ECMA_ERR_CLASS_IS_NON_CONFIGURABLE = "Prototype property of a class is non-configurable"
|
||||
ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT = "Argument is not an object"
|
||||
ECMA_ERR_ARGUMENT_IS_NOT_A_PROXY = "Argument is not a Proxy object"
|
||||
ECMA_ERR_TARGET_IS_NOT_A_CONSTRUCTOR = "Target is not a constructor"
|
||||
ECMA_ERR_ARGUMENT_IS_NOT_AN_REGEXP = "Argument 'this' is not a RegExp object"
|
||||
ECMA_ERR_INVALID_ARRAY_LENGTH = "Invalid Array length"
|
||||
ECMA_ERR_LOCAL_VARIABLE_IS_REDECLARED = "Local variable is redeclared"
|
||||
ECMA_ERR_EXPECTED_A_FUNCTION = "Expected a function"
|
||||
ECMA_ERR_CLASS_CONSTRUCTOR_NEW = "Class constructor cannot be invoked without 'new'"
|
||||
ECMA_ERR_LET_CONST_NOT_INITIALIZED = "Variables declared by let/const must be initialized before reading their value"
|
||||
ECMA_ERR_MAXIMUM_SNAPSHOT_SIZE = "Maximum snapshot size reached"
|
||||
ECMA_ERR_REGULAR_EXPRESSION_NOT_SUPPORTED = "Regular expression literals are not supported"
|
||||
ECMA_ERR_SNAPSHOT_BUFFER_SMALL = "Snapshot buffer too small"
|
||||
ECMA_ERR_SNAPSHOT_UNSUPPORTED_COMPILED_CODE = "Unsupported compiled code"
|
||||
ECMA_ERR_SNAPSHOT_FLAG_NOT_SUPPORTED = "Unsupported generate snapshot flags specified"
|
||||
ECMA_ERR_SNAPSHOT_SAVE_DISABLED = "Snapshot generation is disabled"
|
||||
ECMA_ERR_SNAPSHOT_EXEC_DISABLED = "Snapshot execution is disabled"
|
||||
ECMA_ERR_CANNOT_ALLOCATE_MEMORY_LITERALS = "Cannot allocate memory for literals"
|
||||
ECMA_ERR_TAGGED_TEMPLATE_LITERALS = "Unsupported feature: tagged template literals"
|
||||
ECMA_ERR_CONTAINER_NEEDED = "Value is not a Container or Iterator"
|
||||
ECMA_ERR_INCORRECT_TYPE_CALL = "Operator called on incorrect container type"
|
||||
ECMA_ERR_INVALID_TYPE_FOR_CONSTRUCTOR_CALL = "Invalid type for constructor call"
|
||||
ECMA_ERR_SCRIPT_GLOBAL_FUNCTIONS_INVOKE_WITH_NEW = "Script (global) functions cannot be invoked with 'new'"
|
||||
ECMA_ERR_GENERATOR_FUNCTIONS_INVOKE_WITH_NEW = "Generator functions cannot be invoked with 'new'"
|
||||
ECMA_ERR_ASYNC_FUNCTIONS_INVOKE_WITH_NEW = "Async functions cannot be invoked with 'new'"
|
||||
ECMA_ERR_ASYNC_GENERATOR_FUNCTIONS_INVOKE_WITH_NEW = "Async generator functions cannot be invoked with 'new'"
|
||||
ECMA_ERR_ACCESSOR_FUNCTIONS_INVOKE_WITH_NEW = "Accessor functions cannot be invoked with 'new'"
|
||||
ECMA_ERR_METHODS_INVOKE_WITH_NEW = "Methods cannot be invoked with 'new'"
|
||||
ECMA_ERR_ARROW_FUNCTIONS_INVOKE_WITH_NEW = "Arrow functions cannot be invoked with 'new'"
|
||||
ECMA_ERR_ASYNC_ARROW_FUNCTIONS_INVOKE_WITH_NEW = "Async arrow functions cannot be invoked with 'new'"
|
||||
ECMA_ERR_PROXY_TARGET_IS_NOT_A_CONSTRUCTOR = "Proxy target is not a constructor"
|
||||
ECMA_ERR_MAXIMUM_CALL_STACK_SIZE_EXCEEDED = "Maximum call stack size exceeded"
|
||||
ECMA_ERR_INVALID_SNAPSHOT_FORMAT = "Invalid snapshot format"
|
||||
ECMA_ERR_INVALID_SNAPSHOT_VERSION_OR_FEATURES = "Invalid snapshot version or unsupported features present"
|
||||
ECMA_ERR_RECEIVER_MUST_BE_AN_OBJECT = "Receiver must be an object"
|
||||
ECMA_ERR_CANNOT_DECLARE_SAME_PRIVATE_FIELD_TWICE = "Cannot declare same private field twice"
|
||||
ECMA_ERR_CANNOT_WRITE_PRIVATE_MEMBER_TO_AN_OBJECT_WHOSE_CLASS_DID_NOT_DECLARE_IT = "Cannot write private member to an object whose class did not declare it"
|
||||
ECMA_ERR_PRIVATE_METHOD_IS_NOT_WRITABLE = "Private method is not writable"
|
||||
ECMA_ERR_PRIVATE_FIELD_WAS_DEFINED_WITHOUT_A_SETTER = "Private field was defined without a setter"
|
||||
ECMA_ERR_CANNOT_READ_PRIVATE_MEMBER_TO_AN_OBJECT_WHOSE_CLASS_DID_NOT_DECLARE_IT = "Cannot read private member to an object whose class did not declare it"
|
||||
ECMA_ERR_PRIVATE_FIELD_WAS_DEFINED_WITHOUT_A_GETTER = "Private field was defined without a getter"
|
||||
@@ -0,0 +1,71 @@
|
||||
/* 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-errors.h"
|
||||
|
||||
#if JERRY_ERROR_MESSAGES
|
||||
/**
|
||||
* Struct to store ecma error message with its size.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char *text; /* Text of ecma error message. */
|
||||
uint8_t size; /* Size of ecma error message. */
|
||||
} ecma_error_message_t;
|
||||
|
||||
/* Error message texts with size. */
|
||||
static ecma_error_message_t ecma_error_messages[] JERRY_ATTR_CONST_DATA = {
|
||||
{ "", 0 }, /* ECMA_ERR_EMPTY */
|
||||
/** @cond doxygen_suppress */
|
||||
#define ECMA_ERROR_DEF(id, string) { string, sizeof (string) - 1 },
|
||||
#include "ecma-error-messages.inc.h"
|
||||
#undef ECMA_ERROR_DEF
|
||||
/** @endcond */
|
||||
};
|
||||
#endif /* JERRY_ERROR_MESSAGES */
|
||||
|
||||
/**
|
||||
* Get specified ecma error as zero-terminated string
|
||||
*
|
||||
* @return pointer to zero-terminated ecma error
|
||||
*/
|
||||
const char *
|
||||
ecma_get_error_msg (ecma_error_msg_t id) /**< ecma error id */
|
||||
{
|
||||
JERRY_ASSERT (id != ECMA_IS_VALID_CONSTRUCTOR);
|
||||
|
||||
#if JERRY_ERROR_MESSAGES
|
||||
return ecma_error_messages[id].text;
|
||||
#else /* !JERRY_ERROR_MESSAGES */
|
||||
return NULL;
|
||||
#endif /* JERRY_ERROR_MESSAGES */
|
||||
} /* ecma_get_error_msg */
|
||||
|
||||
/**
|
||||
* Get size of specified ecma error
|
||||
*
|
||||
* @return size in bytes
|
||||
*/
|
||||
lit_utf8_size_t
|
||||
ecma_get_error_size (ecma_error_msg_t id) /**< ecma error id */
|
||||
{
|
||||
JERRY_ASSERT (id != ECMA_IS_VALID_CONSTRUCTOR);
|
||||
|
||||
#if JERRY_ERROR_MESSAGES
|
||||
return ecma_error_messages[id].size;
|
||||
#else /* !JERRY_ERROR_MESSAGES */
|
||||
return 0;
|
||||
#endif /* JERRY_ERROR_MESSAGES */
|
||||
} /* ecma_get_error_size */
|
||||
@@ -0,0 +1,39 @@
|
||||
/* 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_ERRORS_H
|
||||
#define ECMA_ERRORS_H
|
||||
|
||||
#include "lit-globals.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ECMA_ERR_EMPTY,
|
||||
/** @cond doxygen_suppress */
|
||||
#if JERRY_ERROR_MESSAGES
|
||||
#define ECMA_ERROR_DEF(id, ascii_zt_string) id,
|
||||
#else /* !JERRY_ERROR_MESSAGES */
|
||||
#define ECMA_ERROR_DEF(id, ascii_zt_string) id = ECMA_ERR_EMPTY,
|
||||
#endif /* JERRY_ERROR_MESSAGES */
|
||||
#include "ecma-error-messages.inc.h"
|
||||
#undef ECMA_ERROR_DEF
|
||||
/** @endcond */
|
||||
ECMA_IS_VALID_CONSTRUCTOR /* used as return value when checking constructor */
|
||||
} ecma_error_msg_t;
|
||||
|
||||
const char* ecma_get_error_msg (ecma_error_msg_t id);
|
||||
lit_utf8_size_t ecma_get_error_size (ecma_error_msg_t id);
|
||||
|
||||
#endif /* !ECMA_ERRORS_H */
|
||||
@@ -0,0 +1,144 @@
|
||||
/* 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-extended-info.h"
|
||||
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "byte-code.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmaextendedinfo Extended info
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Decodes an uint32_t number, and updates the buffer position.
|
||||
*
|
||||
* @return the decoded value
|
||||
*/
|
||||
uint32_t
|
||||
ecma_extended_info_decode_vlq (uint8_t **buffer_p) /**< [in/out] target buffer */
|
||||
{
|
||||
uint8_t *source_p = *buffer_p;
|
||||
uint32_t value = 0;
|
||||
|
||||
do
|
||||
{
|
||||
source_p--;
|
||||
value = (value << ECMA_EXTENDED_INFO_VLQ_SHIFT) | (*source_p & ECMA_EXTENDED_INFO_VLQ_MASK);
|
||||
} while (*source_p & ECMA_EXTENDED_INFO_VLQ_CONTINUE);
|
||||
|
||||
*buffer_p = source_p;
|
||||
return value;
|
||||
} /* ecma_extended_info_decode_vlq */
|
||||
|
||||
/**
|
||||
* Encodes an uint32_t number into a buffer.
|
||||
*/
|
||||
void
|
||||
ecma_extended_info_encode_vlq (uint8_t **buffer_p, /**< target buffer */
|
||||
uint32_t value) /**< encoded value */
|
||||
{
|
||||
uint8_t *destination_p = *buffer_p - 1;
|
||||
|
||||
if (value <= ECMA_EXTENDED_INFO_VLQ_MASK)
|
||||
{
|
||||
*destination_p = (uint8_t) value;
|
||||
*buffer_p = destination_p;
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t length = 0;
|
||||
uint32_t current_value = value >> ECMA_EXTENDED_INFO_VLQ_SHIFT;
|
||||
|
||||
do
|
||||
{
|
||||
current_value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT;
|
||||
length++;
|
||||
} while (current_value > 0);
|
||||
|
||||
destination_p -= length;
|
||||
*buffer_p = destination_p;
|
||||
|
||||
do
|
||||
{
|
||||
*destination_p++ = (uint8_t) (value | ECMA_EXTENDED_INFO_VLQ_CONTINUE);
|
||||
value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT;
|
||||
} while (value > 0);
|
||||
|
||||
**buffer_p &= ECMA_EXTENDED_INFO_VLQ_MASK;
|
||||
} /* ecma_extended_info_encode_vlq */
|
||||
|
||||
/**
|
||||
* Gets the encoded length of a number.
|
||||
*
|
||||
* @return encoded length
|
||||
*/
|
||||
uint32_t
|
||||
ecma_extended_info_get_encoded_length (uint32_t value) /**< encoded value */
|
||||
{
|
||||
uint32_t length = 0;
|
||||
|
||||
do
|
||||
{
|
||||
value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT;
|
||||
length++;
|
||||
} while (value > 0);
|
||||
|
||||
return length;
|
||||
} /* ecma_extended_info_get_encoded_length */
|
||||
|
||||
/**
|
||||
* Get the extended info from a byte code
|
||||
*
|
||||
* @return pointer to the extended info
|
||||
*/
|
||||
uint8_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_arguments_start (bytecode_header_p);
|
||||
|
||||
if (CBC_FUNCTION_GET_TYPE (bytecode_header_p->status_flags) != CBC_FUNCTION_CONSTRUCTOR)
|
||||
{
|
||||
base_p--;
|
||||
}
|
||||
|
||||
if (bytecode_header_p->status_flags & CBC_CODE_FLAGS_HAS_TAGGED_LITERALS)
|
||||
{
|
||||
base_p--;
|
||||
}
|
||||
|
||||
#if JERRY_LINE_INFO
|
||||
if (bytecode_header_p->status_flags & CBC_CODE_FLAGS_HAS_LINE_INFO)
|
||||
{
|
||||
base_p--;
|
||||
}
|
||||
#endif /* JERRY_LINE_INFO */
|
||||
|
||||
JERRY_ASSERT (((uint8_t *) base_p)[-1] != 0);
|
||||
|
||||
return ((uint8_t *) base_p) - 1;
|
||||
} /* ecma_compiled_code_resolve_extended_info */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,54 @@
|
||||
/* 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_EXTENDED_INFO_H
|
||||
#define ECMA_EXTENDED_INFO_H
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmaextendedinfo Extended info
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
/**
|
||||
* Vlq encoding: flag which is set for all bytes except the last one.
|
||||
*/
|
||||
#define ECMA_EXTENDED_INFO_VLQ_CONTINUE 0x80
|
||||
|
||||
/**
|
||||
* Vlq encoding: mask to decode the number fragment.
|
||||
*/
|
||||
#define ECMA_EXTENDED_INFO_VLQ_MASK 0x7f
|
||||
|
||||
/**
|
||||
* Vlq encoding: number of bits stored in a byte.
|
||||
*/
|
||||
#define ECMA_EXTENDED_INFO_VLQ_SHIFT 7
|
||||
|
||||
uint32_t ecma_extended_info_decode_vlq (uint8_t **buffer_p);
|
||||
void ecma_extended_info_encode_vlq (uint8_t **buffer_p, uint32_t value);
|
||||
uint32_t ecma_extended_info_get_encoded_length (uint32_t value);
|
||||
|
||||
uint8_t *ecma_compiled_code_resolve_extended_info (const ecma_compiled_code_t *bytecode_header_p);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !ECMA_EXTENDED_INFO_H */
|
||||
+1037
-737
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,7 @@
|
||||
#define ECMA_GC_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -26,10 +27,22 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Free option flags
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_GC_FREE_NO_OPTIONS = 0, /**< no options */
|
||||
ECMA_GC_FREE_SECOND_PROPERTY = (1 << 0), /**< free second property of a property pair */
|
||||
ECMA_GC_FREE_REFERENCES = (1 << 1), /**< free references */
|
||||
} ecma_gc_free_options_t;
|
||||
|
||||
void ecma_init_gc_info (ecma_object_t *object_p);
|
||||
void ecma_ref_object (ecma_object_t *object_p);
|
||||
void ecma_ref_object_inline (ecma_object_t *object_p);
|
||||
void ecma_deref_object (ecma_object_t *object_p);
|
||||
void ecma_gc_free_properties (ecma_object_t *object_p);
|
||||
void ecma_gc_free_property (ecma_object_t *object_p, ecma_property_pair_t *prop_pair_p, uint32_t options);
|
||||
void ecma_gc_free_properties (ecma_object_t *object_p, uint32_t options);
|
||||
void ecma_gc_run (void);
|
||||
void ecma_free_unused_memory (jmem_pressure_t pressure);
|
||||
|
||||
|
||||
+646
-660
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,7 @@
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -79,8 +80,6 @@ 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
|
||||
*/
|
||||
@@ -117,8 +116,6 @@ ecma_collection_free_template_literal (ecma_collection_t *collection_p) /**< val
|
||||
ecma_collection_destroy (collection_p);
|
||||
} /* ecma_collection_free_template_literal */
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Free the non-object collection elements and deallocate the collection
|
||||
*/
|
||||
@@ -416,6 +413,31 @@ ecma_compact_collection_free (ecma_value_t *compact_collection_p) /**< compact c
|
||||
jmem_heap_free_block (compact_collection_p, size * sizeof (ecma_value_t));
|
||||
} /* ecma_compact_collection_free */
|
||||
|
||||
/**
|
||||
* Get the end of a compact collection
|
||||
*
|
||||
* @return pointer to the compact collection end
|
||||
*/
|
||||
ecma_value_t *
|
||||
ecma_compact_collection_end (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);
|
||||
|
||||
return compact_collection_p + size - unused_items;
|
||||
} /* ecma_compact_collection_end */
|
||||
|
||||
/**
|
||||
* Destroy a compact collection
|
||||
*/
|
||||
void
|
||||
ecma_compact_collection_destroy (ecma_value_t *compact_collection_p) /**< compact collection */
|
||||
{
|
||||
ecma_value_t size = ECMA_COMPACT_COLLECTION_GET_SIZE (compact_collection_p);
|
||||
|
||||
jmem_heap_free_block (compact_collection_p, size * sizeof (ecma_value_t));
|
||||
} /* ecma_compact_collection_destroy */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -139,7 +139,7 @@ ecma_errol0_dtoa (double val, /**< ecma number */
|
||||
int32_t *exp_p) /**< [out] exponent */
|
||||
{
|
||||
double power_of_10 = 1.0;
|
||||
int32_t exp = 1;
|
||||
int32_t exponent = 1;
|
||||
|
||||
/* normalize the midpoint */
|
||||
ecma_high_prec_t mid;
|
||||
@@ -147,16 +147,16 @@ ecma_errol0_dtoa (double val, /**< ecma number */
|
||||
mid.value = val;
|
||||
mid.offset = 0.0;
|
||||
|
||||
while (((mid.value > 10.0) || ((mid.value == 10.0) && (mid.offset >= 0.0))) && (exp < 308))
|
||||
while (((mid.value > 10.0) || ((mid.value == 10.0) && (mid.offset >= 0.0))) && (exponent < 308))
|
||||
{
|
||||
exp++;
|
||||
exponent++;
|
||||
ecma_divide_high_prec_by_10 (&mid);
|
||||
power_of_10 /= 10.0;
|
||||
}
|
||||
|
||||
while (((mid.value < 1.0) || ((mid.value == 1.0) && (mid.offset < 0.0))) && (exp > -307))
|
||||
while (((mid.value < 1.0) || ((mid.value == 1.0) && (mid.offset < 0.0))) && (exponent > -307))
|
||||
{
|
||||
exp--;
|
||||
exponent--;
|
||||
ecma_multiply_high_prec_by_10 (&mid);
|
||||
power_of_10 *= 10.0;
|
||||
}
|
||||
@@ -181,14 +181,14 @@ ecma_errol0_dtoa (double val, /**< ecma number */
|
||||
|
||||
while (high_bound.value > 10.0 || (high_bound.value == 10.0 && (high_bound.offset >= 0.0)))
|
||||
{
|
||||
exp++;
|
||||
exponent++;
|
||||
ecma_divide_high_prec_by_10 (&high_bound);
|
||||
ecma_divide_high_prec_by_10 (&low_bound);
|
||||
}
|
||||
|
||||
while (high_bound.value < 1.0 || (high_bound.value == 1.0 && (high_bound.offset < 0.0)))
|
||||
{
|
||||
exp--;
|
||||
exponent--;
|
||||
ecma_multiply_high_prec_by_10 (&high_bound);
|
||||
ecma_multiply_high_prec_by_10 (&low_bound);
|
||||
}
|
||||
@@ -230,7 +230,7 @@ ecma_errol0_dtoa (double val, /**< ecma number */
|
||||
double mdig = (high_bound.value + low_bound.value) / 2.0 + 0.5;
|
||||
*dst_p++ = (lit_utf8_byte_t) ('0' + (uint8_t) mdig);
|
||||
|
||||
*exp_p = exp;
|
||||
*exp_p = exponent;
|
||||
|
||||
return (lit_utf8_size_t) (dst_p - buffer_p);
|
||||
} /* ecma_errol0_dtoa */
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-objects-general.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects-general.h"
|
||||
#include "ecma-objects.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -36,10 +36,15 @@
|
||||
bool
|
||||
ecma_create_native_pointer_property (ecma_object_t *obj_p, /**< object to create property in */
|
||||
void *native_p, /**< native pointer */
|
||||
void *info_p) /**< native pointer's type info */
|
||||
const jerry_object_native_info_t *native_info_p) /**< native type info */
|
||||
{
|
||||
ecma_string_t *name_p = ecma_get_internal_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
|
||||
|
||||
if (native_info_p != NULL && native_info_p->number_of_references > 0)
|
||||
{
|
||||
name_p = ecma_get_internal_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER_WITH_REFERENCES);
|
||||
}
|
||||
|
||||
if (ecma_op_object_is_fast_array (obj_p))
|
||||
{
|
||||
ecma_fast_array_convert_to_normal (obj_p);
|
||||
@@ -53,47 +58,91 @@ ecma_create_native_pointer_property (ecma_object_t *obj_p, /**< object to create
|
||||
|
||||
if (property_p == NULL)
|
||||
{
|
||||
native_pointer_p = (ecma_native_pointer_t *) jmem_heap_alloc_block (sizeof (ecma_native_pointer_t));
|
||||
|
||||
ecma_property_value_t *value_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);
|
||||
*property_p |= ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL;
|
||||
}
|
||||
else if (*property_p & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL)
|
||||
{
|
||||
ecma_property_value_t *value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
|
||||
|
||||
native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, value_p->value);
|
||||
|
||||
if (native_pointer_p->native_info_p == native_info_p)
|
||||
{
|
||||
native_pointer_p->native_p = native_p;
|
||||
return false;
|
||||
}
|
||||
|
||||
value_p->value = JMEM_CP_NULL;
|
||||
(void) value_p->value; /* Make cppcheck happy. */
|
||||
*property_p &= (ecma_property_t) ~ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL;
|
||||
|
||||
ecma_native_pointer_chain_t *item_p;
|
||||
item_p = (ecma_native_pointer_chain_t *) jmem_heap_alloc_block (sizeof (ecma_native_pointer_chain_t));
|
||||
item_p->data = *native_pointer_p;
|
||||
|
||||
jmem_heap_free_block (native_pointer_p, sizeof (ecma_native_pointer_t));
|
||||
|
||||
item_p->next_p = (ecma_native_pointer_chain_t *) jmem_heap_alloc_block (sizeof (ecma_native_pointer_chain_t));
|
||||
item_p->next_p->next_p = NULL;
|
||||
|
||||
native_pointer_p = &item_p->next_p->data;
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (value_p->value, item_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_property_value_t *value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
|
||||
|
||||
ecma_native_pointer_t *iter_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, value_p->value);
|
||||
|
||||
/* There should be at least 1 native pointer in the chain */
|
||||
JERRY_ASSERT (iter_p != NULL);
|
||||
|
||||
while (true)
|
||||
if (value_p->value == JMEM_CP_NULL)
|
||||
{
|
||||
if (iter_p->info_p == info_p)
|
||||
{
|
||||
/* The native info already exists -> update the corresponding data */
|
||||
iter_p->data_p = native_p;
|
||||
return false;
|
||||
}
|
||||
native_pointer_p = (ecma_native_pointer_t *) jmem_heap_alloc_block (sizeof (ecma_native_pointer_t));
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (value_p->value, native_pointer_p);
|
||||
|
||||
if (iter_p->next_p == NULL)
|
||||
{
|
||||
/* The native info does not exist -> append a new element to the chain */
|
||||
break;
|
||||
}
|
||||
|
||||
iter_p = iter_p->next_p;
|
||||
*property_p |= ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_native_pointer_chain_t *item_p;
|
||||
item_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_chain_t, value_p->value);
|
||||
|
||||
native_pointer_p = jmem_heap_alloc_block (sizeof (ecma_native_pointer_t));
|
||||
/* There should be at least 2 native pointers in the chain */
|
||||
JERRY_ASSERT (item_p != NULL && item_p->next_p != NULL);
|
||||
|
||||
iter_p->next_p = native_pointer_p;
|
||||
while (true)
|
||||
{
|
||||
if (item_p->data.native_info_p == native_info_p)
|
||||
{
|
||||
/* The native info already exists -> update the corresponding data */
|
||||
item_p->data.native_p = native_p;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item_p->next_p == NULL)
|
||||
{
|
||||
/* The native info does not exist -> append a new element to the chain */
|
||||
break;
|
||||
}
|
||||
|
||||
item_p = item_p->next_p;
|
||||
}
|
||||
|
||||
ecma_native_pointer_chain_t *new_item_p;
|
||||
|
||||
new_item_p = (ecma_native_pointer_chain_t *) jmem_heap_alloc_block (sizeof (ecma_native_pointer_chain_t));
|
||||
item_p->next_p = new_item_p;
|
||||
new_item_p->next_p = NULL;
|
||||
|
||||
native_pointer_p = &new_item_p->data;
|
||||
}
|
||||
}
|
||||
|
||||
native_pointer_p->data_p = native_p;
|
||||
native_pointer_p->info_p = info_p;
|
||||
native_pointer_p->next_p = NULL;
|
||||
native_pointer_p->native_p = native_p;
|
||||
native_pointer_p->native_info_p = (jerry_object_native_info_t *) native_info_p;
|
||||
|
||||
return is_new;
|
||||
} /* ecma_create_native_pointer_property */
|
||||
@@ -110,7 +159,7 @@ ecma_create_native_pointer_property (ecma_object_t *obj_p, /**< object to create
|
||||
*/
|
||||
ecma_native_pointer_t *
|
||||
ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property value from */
|
||||
void *info_p) /**< native pointer's type info */
|
||||
const jerry_object_native_info_t *native_info_p) /**< native type info */
|
||||
{
|
||||
if (ecma_op_object_is_fast_array (obj_p))
|
||||
{
|
||||
@@ -119,6 +168,12 @@ ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property
|
||||
}
|
||||
|
||||
ecma_string_t *name_p = ecma_get_internal_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
|
||||
|
||||
if (native_info_p != NULL && native_info_p->number_of_references > 0)
|
||||
{
|
||||
name_p = ecma_get_internal_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER_WITH_REFERENCES);
|
||||
}
|
||||
|
||||
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
|
||||
|
||||
if (property_p == NULL)
|
||||
@@ -128,21 +183,39 @@ ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property
|
||||
|
||||
ecma_property_value_t *value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
|
||||
|
||||
ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t,
|
||||
value_p->value);
|
||||
|
||||
JERRY_ASSERT (native_pointer_p != NULL);
|
||||
|
||||
while (native_pointer_p != NULL)
|
||||
if (JERRY_LIKELY (*property_p & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL))
|
||||
{
|
||||
if (native_pointer_p->info_p == info_p)
|
||||
ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, value_p->value);
|
||||
|
||||
if (native_pointer_p->native_info_p == native_info_p)
|
||||
{
|
||||
return native_pointer_p;
|
||||
}
|
||||
|
||||
native_pointer_p = native_pointer_p->next_p;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (value_p->value == JMEM_CP_NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ecma_native_pointer_chain_t *item_p;
|
||||
item_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_chain_t, value_p->value);
|
||||
|
||||
/* There should be at least 2 native pointers in the chain */
|
||||
JERRY_ASSERT (item_p != NULL && item_p->next_p != NULL);
|
||||
|
||||
do
|
||||
{
|
||||
if (item_p->data.native_info_p == native_info_p)
|
||||
{
|
||||
return &item_p->data;
|
||||
}
|
||||
|
||||
item_p = item_p->next_p;
|
||||
} while (item_p != NULL);
|
||||
|
||||
return NULL;
|
||||
} /* ecma_get_native_pointer_value */
|
||||
|
||||
@@ -158,7 +231,7 @@ ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property
|
||||
*/
|
||||
bool
|
||||
ecma_delete_native_pointer_property (ecma_object_t *obj_p, /**< object to delete property from */
|
||||
void *info_p) /**< native pointer's type info */
|
||||
const jerry_object_native_info_t *native_info_p) /**< native type info */
|
||||
{
|
||||
if (ecma_op_object_is_fast_array (obj_p))
|
||||
{
|
||||
@@ -167,6 +240,12 @@ ecma_delete_native_pointer_property (ecma_object_t *obj_p, /**< object to delete
|
||||
}
|
||||
|
||||
ecma_string_t *name_p = ecma_get_internal_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
|
||||
|
||||
if (native_info_p != NULL && native_info_p->number_of_references > 0)
|
||||
{
|
||||
name_p = ecma_get_internal_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER_WITH_REFERENCES);
|
||||
}
|
||||
|
||||
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
|
||||
|
||||
if (property_p == NULL)
|
||||
@@ -176,49 +255,75 @@ ecma_delete_native_pointer_property (ecma_object_t *obj_p, /**< object to delete
|
||||
|
||||
ecma_property_value_t *value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
|
||||
|
||||
ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t,
|
||||
value_p->value);
|
||||
ecma_native_pointer_t *prev_p = NULL;
|
||||
|
||||
JERRY_ASSERT (native_pointer_p != NULL);
|
||||
|
||||
while (native_pointer_p != NULL)
|
||||
if (JERRY_LIKELY (*property_p & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL))
|
||||
{
|
||||
if (native_pointer_p->info_p == info_p)
|
||||
ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, value_p->value);
|
||||
|
||||
if (native_pointer_p->native_info_p != native_info_p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
value_p->value = JMEM_CP_NULL;
|
||||
*property_p &= (ecma_property_t) ~ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL;
|
||||
jmem_heap_free_block (native_pointer_p, sizeof (ecma_native_pointer_t));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value_p->value == JMEM_CP_NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ecma_native_pointer_chain_t *first_p;
|
||||
first_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_chain_t, value_p->value);
|
||||
|
||||
/* There should be at least 2 native pointers in the chain */
|
||||
JERRY_ASSERT (first_p != NULL && first_p->next_p != NULL);
|
||||
|
||||
ecma_native_pointer_chain_t *item_p = first_p;
|
||||
ecma_native_pointer_chain_t *prev_p = NULL;
|
||||
|
||||
do
|
||||
{
|
||||
if (item_p->data.native_info_p == native_info_p)
|
||||
{
|
||||
if (prev_p == NULL)
|
||||
{
|
||||
if (native_pointer_p->next_p == NULL)
|
||||
{
|
||||
/* Only one native pointer property exists, so the property can be deleted as well. */
|
||||
ecma_op_general_object_delete (obj_p, name_p, false);
|
||||
|
||||
jmem_heap_free_block (native_pointer_p, sizeof (ecma_native_pointer_t));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* There are at least two native pointers and the first one should be deleted.
|
||||
In this case the second element's data is copied to the head of the chain, and freed as well. */
|
||||
ecma_native_pointer_t *next_p = native_pointer_p->next_p;
|
||||
memcpy (native_pointer_p, next_p, sizeof (ecma_native_pointer_t));
|
||||
jmem_heap_free_block (next_p, sizeof (ecma_native_pointer_t));
|
||||
return true;
|
||||
}
|
||||
/* The first element is deleted from the chain: change the property value. */
|
||||
first_p = item_p->next_p;
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (value_p->value, first_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* There are at least two native pointers and not the first element should be deleted.
|
||||
In this case the current element's next element reference is copied to the previous element. */
|
||||
prev_p->next_p = native_pointer_p->next_p;
|
||||
jmem_heap_free_block (native_pointer_p, sizeof (ecma_native_pointer_t));
|
||||
/* A non-first element is deleted from the chain: update the previous pointer. */
|
||||
prev_p->next_p = item_p->next_p;
|
||||
}
|
||||
|
||||
jmem_heap_free_block (item_p, sizeof (ecma_native_pointer_chain_t));
|
||||
|
||||
if (first_p->next_p != NULL)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Only one item remained. The ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL flag is
|
||||
* set early to avoid using the chain if the allocation below triggers a GC. */
|
||||
*property_p |= ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL;
|
||||
|
||||
ecma_native_pointer_t *native_pointer_p;
|
||||
native_pointer_p = (ecma_native_pointer_t *) jmem_heap_alloc_block (sizeof (ecma_native_pointer_t));
|
||||
*native_pointer_p = first_p->data;
|
||||
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (value_p->value, native_pointer_p);
|
||||
|
||||
jmem_heap_free_block (first_p, sizeof (ecma_native_pointer_chain_t));
|
||||
return true;
|
||||
}
|
||||
|
||||
prev_p = native_pointer_p;
|
||||
native_pointer_p = native_pointer_p->next_p;
|
||||
}
|
||||
prev_p = item_p;
|
||||
item_p = item_p->next_p;
|
||||
} while (item_p != NULL);
|
||||
|
||||
return false;
|
||||
} /* ecma_delete_native_pointer_property */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,245 @@
|
||||
/* 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_HELPERS_NUMBER_H
|
||||
#define ECMA_HELPERS_NUMBER_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
/**
|
||||
* Binary representation of an ecma-number
|
||||
*/
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
typedef uint64_t ecma_binary_num_t;
|
||||
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
typedef uint32_t ecma_binary_num_t;
|
||||
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Makes it possible to read/write the binary representation of an ecma_number_t
|
||||
* without strict aliasing rule violation.
|
||||
*/
|
||||
typedef union
|
||||
{
|
||||
ecma_number_t as_number; /**< ecma-number */
|
||||
ecma_binary_num_t as_binary; /**< binary representation */
|
||||
} ecma_number_accessor_t;
|
||||
|
||||
ecma_binary_num_t ecma_number_to_binary (ecma_number_t number);
|
||||
ecma_number_t ecma_number_from_binary (ecma_binary_num_t binary);
|
||||
|
||||
bool ecma_number_sign (ecma_binary_num_t binary);
|
||||
uint32_t ecma_number_biased_exp (ecma_binary_num_t binary);
|
||||
uint64_t ecma_number_fraction (ecma_binary_num_t binary);
|
||||
ecma_number_t ecma_number_create (bool sign, uint32_t biased_exp, uint64_t fraction);
|
||||
|
||||
/**
|
||||
* Maximum number of significant decimal digits that an ecma-number can store
|
||||
*/
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
#define ECMA_NUMBER_MAX_DIGITS (19)
|
||||
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
#define ECMA_NUMBER_MAX_DIGITS (9)
|
||||
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Width of sign field
|
||||
*
|
||||
* See also:
|
||||
* IEEE-754 2008, 3.6, Table 3.5
|
||||
*/
|
||||
#define ECMA_NUMBER_SIGN_WIDTH (1)
|
||||
|
||||
/**
|
||||
* Width of biased exponent field
|
||||
*
|
||||
* See also:
|
||||
* IEEE-754 2008, 3.6, Table 3.5
|
||||
*/
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
#define ECMA_NUMBER_BIASED_EXP_WIDTH (11)
|
||||
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
#define ECMA_NUMBER_BIASED_EXP_WIDTH (8)
|
||||
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Exponent bias
|
||||
*/
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
#define ECMA_NUMBER_EXPONENT_BIAS (1023)
|
||||
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
#define ECMA_NUMBER_EXPONENT_BIAS (127)
|
||||
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Width of fraction field
|
||||
*
|
||||
* See also:
|
||||
* IEEE-754 2008, 3.6, Table 3.5
|
||||
*/
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
#define ECMA_NUMBER_FRACTION_WIDTH (52)
|
||||
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
#define ECMA_NUMBER_FRACTION_WIDTH (23)
|
||||
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Sign bit in ecma-numbers
|
||||
*/
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
#define ECMA_NUMBER_SIGN_BIT 0x8000000000000000ull
|
||||
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
#define ECMA_NUMBER_SIGN_BIT 0x7f800000u;
|
||||
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Binary representation of an IEEE-754 QNaN value.
|
||||
*/
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
#define ECMA_NUMBER_BINARY_QNAN 0x7ff8000000000000ull
|
||||
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
#define ECMA_NUMBER_BINARY_QNAN 0x7fc00000u
|
||||
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Binary representation of an IEEE-754 Infinity value.
|
||||
*/
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
#define ECMA_NUMBER_BINARY_INF 0x7ff0000000000000ull
|
||||
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
#define ECMA_NUMBER_BINARY_INF 0x7f800000u
|
||||
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Binary representation of an IEEE-754 zero value.
|
||||
*/
|
||||
#define ECMA_NUMBER_BINARY_ZERO 0x0ull
|
||||
|
||||
/**
|
||||
* Number.MIN_VALUE (i.e., the smallest positive value of ecma-number)
|
||||
*
|
||||
* See also: ECMA_262 v5, 15.7.3.3
|
||||
*/
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
#define ECMA_NUMBER_MIN_VALUE ((ecma_number_t) 5e-324)
|
||||
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
#define ECMA_NUMBER_MIN_VALUE (FLT_MIN)
|
||||
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Number.MAX_VALUE (i.e., the maximum value of ecma-number)
|
||||
*
|
||||
* See also: ECMA_262 v5, 15.7.3.2
|
||||
*/
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
#define ECMA_NUMBER_MAX_VALUE ((ecma_number_t) 1.7976931348623157e+308)
|
||||
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
#define ECMA_NUMBER_MAX_VALUE (FLT_MAX)
|
||||
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Number.EPSILON
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.1
|
||||
*/
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
#define ECMA_NUMBER_EPSILON ((ecma_number_t) 2.2204460492503130808472633361816e-16)
|
||||
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
#define ECMA_NUMBER_EPSILON ((ecma_number_t) 1.1920928955078125e-7)
|
||||
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Number.MAX_SAFE_INTEGER
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.6
|
||||
*/
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
#define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0x1FFFFFFFFFFFFF)
|
||||
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
#define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0xFFFFFF)
|
||||
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Number.MIN_SAFE_INTEGER
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.8
|
||||
*/
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
#define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0x1FFFFFFFFFFFFF)
|
||||
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
#define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0xFFFFFF)
|
||||
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Number.MAX_VALUE exponent part
|
||||
*/
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
#define NUMBER_MAX_DECIMAL_EXPONENT 308
|
||||
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
#define NUMBER_MAX_DECIMAL_EXPONENT 38
|
||||
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Number.MIN_VALUE exponent part
|
||||
*/
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
#define NUMBER_MIN_DECIMAL_EXPONENT -324
|
||||
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
#define NUMBER_MIN_DECIMAL_EXPONENT -45
|
||||
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Euler number
|
||||
*/
|
||||
#define ECMA_NUMBER_E ((ecma_number_t) 2.7182818284590452354)
|
||||
|
||||
/**
|
||||
* Natural logarithm of 10
|
||||
*/
|
||||
#define ECMA_NUMBER_LN10 ((ecma_number_t) 2.302585092994046)
|
||||
|
||||
/**
|
||||
* Natural logarithm of 2
|
||||
*/
|
||||
#define ECMA_NUMBER_LN2 ((ecma_number_t) 0.6931471805599453)
|
||||
|
||||
/**
|
||||
* Logarithm base 2 of the Euler number
|
||||
*/
|
||||
#define ECMA_NUMBER_LOG2E ((ecma_number_t) 1.4426950408889634)
|
||||
|
||||
/**
|
||||
* Logarithm base 10 of the Euler number
|
||||
*/
|
||||
#define ECMA_NUMBER_LOG10E ((ecma_number_t) 0.4342944819032518)
|
||||
|
||||
/**
|
||||
* Pi number
|
||||
*/
|
||||
#define ECMA_NUMBER_PI ((ecma_number_t) 3.1415926535897932)
|
||||
|
||||
/**
|
||||
* Square root of 0.5
|
||||
*/
|
||||
#define ECMA_NUMBER_SQRT_1_2 ((ecma_number_t) 0.7071067811865476)
|
||||
|
||||
/**
|
||||
* Square root of 2
|
||||
*/
|
||||
#define ECMA_NUMBER_SQRT2 ((ecma_number_t) 1.4142135623730951)
|
||||
|
||||
#endif /* !ECMA_HELPERS_NUMBER_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,20 +15,19 @@
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers-number.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#include "jrt-bit-fields.h"
|
||||
#include "jrt.h"
|
||||
#include "vm-defines.h"
|
||||
|
||||
#include "ecma-function-object.h"
|
||||
JERRY_STATIC_ASSERT (ECMA_TYPE___MAX <= ECMA_VALUE_TYPE_MASK, ecma_types_must_be_less_than_mask);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_TYPE___MAX <= ECMA_VALUE_TYPE_MASK,
|
||||
ecma_types_must_be_less_than_mask);
|
||||
|
||||
JERRY_STATIC_ASSERT ((ECMA_VALUE_TYPE_MASK + 1) == (1 << ECMA_VALUE_SHIFT),
|
||||
ecma_value_part_must_start_after_flags);
|
||||
JERRY_STATIC_ASSERT ((ECMA_VALUE_TYPE_MASK + 1) == (1 << ECMA_VALUE_SHIFT), ecma_value_part_must_start_after_flags);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_VALUE_SHIFT <= JMEM_ALIGNMENT_LOG,
|
||||
ecma_value_shift_must_be_less_than_or_equal_than_mem_alignment_log);
|
||||
@@ -42,26 +41,24 @@ JERRY_STATIC_ASSERT (sizeof (jmem_cpointer_t) <= sizeof (jmem_cpointer_tag_t),
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
|
||||
/* cppcheck-suppress zerodiv */
|
||||
JERRY_STATIC_ASSERT (sizeof (uintptr_t) <= sizeof (ecma_value_t),
|
||||
uintptr_t_must_fit_in_ecma_value_t);
|
||||
JERRY_STATIC_ASSERT (sizeof (uintptr_t) <= sizeof (ecma_value_t), uintptr_t_must_fit_in_ecma_value_t);
|
||||
|
||||
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (uintptr_t) > sizeof (ecma_value_t),
|
||||
uintptr_t_must_not_fit_in_ecma_value_t);
|
||||
JERRY_STATIC_ASSERT (sizeof (uintptr_t) > sizeof (ecma_value_t), uintptr_t_must_not_fit_in_ecma_value_t);
|
||||
|
||||
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
JERRY_STATIC_ASSERT ((ECMA_VALUE_FALSE | (1 << ECMA_DIRECT_SHIFT)) == ECMA_VALUE_TRUE
|
||||
&& ECMA_VALUE_FALSE != ECMA_VALUE_TRUE,
|
||||
&& ECMA_VALUE_FALSE != ECMA_VALUE_TRUE,
|
||||
only_the_lowest_bit_must_be_different_for_simple_value_true_and_false);
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
#if 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) */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -110,7 +107,7 @@ ecma_pointer_to_ecma_value (const void *ptr) /**< pointer */
|
||||
*
|
||||
* @return pointer
|
||||
*/
|
||||
static inline void * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
static inline void *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_pointer_from_ecma_value (ecma_value_t value) /**< value */
|
||||
{
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
@@ -277,8 +274,7 @@ 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 */
|
||||
{
|
||||
JERRY_STATIC_ASSERT (ECMA_DIRECT_TYPE_INTEGER_VALUE == 0,
|
||||
ecma_direct_type_integer_value_must_be_zero);
|
||||
JERRY_STATIC_ASSERT (ECMA_DIRECT_TYPE_INTEGER_VALUE == 0, ecma_direct_type_integer_value_must_be_zero);
|
||||
|
||||
return ((first_value | second_value) & ECMA_DIRECT_TYPE_MASK) == ECMA_DIRECT_TYPE_INTEGER_VALUE;
|
||||
} /* ecma_are_values_integer_numbers */
|
||||
@@ -304,8 +300,7 @@ ecma_is_value_float_number (ecma_value_t value) /**< ecma value */
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_number (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return (ecma_is_value_integer_number (value)
|
||||
|| ecma_is_value_float_number (value));
|
||||
return (ecma_is_value_integer_number (value) || ecma_is_value_float_number (value));
|
||||
} /* ecma_is_value_number */
|
||||
|
||||
JERRY_STATIC_ASSERT ((ECMA_TYPE_STRING | 0x4) == ECMA_TYPE_DIRECT_STRING,
|
||||
@@ -332,12 +327,7 @@ ecma_is_value_string (ecma_value_t value) /**< ecma value */
|
||||
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 */
|
||||
|
||||
/**
|
||||
@@ -362,12 +352,12 @@ ecma_is_value_magic_string (ecma_value_t value, /**< ecma value */
|
||||
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)
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_BIGINT);
|
||||
#else /* !ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
#else /* !JERRY_BUILTIN_BIGINT */
|
||||
JERRY_UNUSED (value);
|
||||
return false;
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
} /* ecma_is_value_bigint */
|
||||
|
||||
/**
|
||||
@@ -379,11 +369,7 @@ ecma_is_value_bigint (ecma_value_t value) /**< ecma value */
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_prop_name (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
return ecma_is_value_string (value) || ecma_is_value_symbol (value);
|
||||
#else /* !ENABLED (JERRY_ESNEXT) */
|
||||
return ecma_is_value_string (value);
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} /* ecma_is_value_prop_name */
|
||||
|
||||
/**
|
||||
@@ -429,10 +415,10 @@ ecma_is_value_object (ecma_value_t value) /**< ecma value */
|
||||
* false - otherwise
|
||||
*/
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_error_reference (ecma_value_t value) /**< ecma value */
|
||||
ecma_is_value_exception (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_ERROR);
|
||||
} /* ecma_is_value_error_reference */
|
||||
} /* ecma_is_value_exception */
|
||||
|
||||
/**
|
||||
* Debug assertion that specified value's type is one of ECMA-defined
|
||||
@@ -441,14 +427,9 @@ ecma_is_value_error_reference (ecma_value_t value) /**< ecma value */
|
||||
void
|
||||
ecma_check_value_type_is_spec_defined (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_undefined (value)
|
||||
|| ecma_is_value_null (value)
|
||||
|| ecma_is_value_boolean (value)
|
||||
|| ecma_is_value_number (value)
|
||||
|| ecma_is_value_string (value)
|
||||
|| ecma_is_value_bigint (value)
|
||||
|| ecma_is_value_symbol (value)
|
||||
|| ecma_is_value_object (value));
|
||||
JERRY_ASSERT (ecma_is_value_undefined (value) || ecma_is_value_null (value) || ecma_is_value_boolean (value)
|
||||
|| ecma_is_value_number (value) || ecma_is_value_string (value) || ecma_is_value_bigint (value)
|
||||
|| ecma_is_value_symbol (value) || ecma_is_value_object (value));
|
||||
} /* ecma_check_value_type_is_spec_defined */
|
||||
|
||||
/**
|
||||
@@ -467,25 +448,24 @@ ecma_is_value_array (ecma_value_t arg) /**< argument */
|
||||
|
||||
ecma_object_t *arg_obj_p = ecma_get_object_from_value (arg);
|
||||
|
||||
if (ecma_get_object_type (arg_obj_p) == ECMA_OBJECT_TYPE_ARRAY)
|
||||
if (ecma_get_object_base_type (arg_obj_p) == ECMA_OBJECT_BASE_TYPE_ARRAY)
|
||||
{
|
||||
return ECMA_VALUE_TRUE;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_PROXY)
|
||||
#if 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;
|
||||
|
||||
if (proxy_obj_p->handler == ECMA_VALUE_NULL)
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Cannot perform 'IsArray' on the given proxy "
|
||||
"because handler is null"));
|
||||
return ecma_raise_type_error (ECMA_ERR_PROXY_HANDLER_IS_NULL_FOR_ISARRAY_OPERATION);
|
||||
}
|
||||
|
||||
return ecma_is_value_array (proxy_obj_p->target);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
|
||||
return ECMA_VALUE_FALSE;
|
||||
} /* ecma_is_value_array */
|
||||
@@ -537,7 +517,7 @@ ecma_create_float_number (ecma_number_t ecma_number) /**< value of the float num
|
||||
*
|
||||
* @return ecma-value
|
||||
*/
|
||||
ecma_value_t
|
||||
extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_make_float_value (ecma_number_t *ecma_num_p) /**< pointer to the float number */
|
||||
{
|
||||
return ecma_pointer_to_ecma_value (ecma_num_p) | ECMA_TYPE_FLOAT;
|
||||
@@ -548,7 +528,7 @@ ecma_make_float_value (ecma_number_t *ecma_num_p) /**< pointer to the float numb
|
||||
*
|
||||
* @return ecma-value
|
||||
*/
|
||||
extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE JERRY_ATTR_CONST
|
||||
ecma_make_nan_value (void)
|
||||
{
|
||||
return ecma_create_float_number (ecma_number_make_nan ());
|
||||
@@ -562,13 +542,7 @@ ecma_make_nan_value (void)
|
||||
static inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_number_equal_to_positive_zero (ecma_number_t ecma_number) /**< number */
|
||||
{
|
||||
ecma_number_accessor_t u;
|
||||
u.as_ecma_number_t = ecma_number;
|
||||
#if !ENABLED (JERRY_NUMBER_TYPE_FLOAT64)
|
||||
return u.as_uint32_t == 0;
|
||||
#else /* ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */
|
||||
return u.as_uint64_t == 0;
|
||||
#endif /* !ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */
|
||||
return ecma_number_to_binary (ecma_number) == ECMA_NUMBER_BINARY_ZERO;
|
||||
} /* ecma_is_number_equal_to_positive_zero */
|
||||
|
||||
/**
|
||||
@@ -648,9 +622,7 @@ 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_ESNEXT)
|
||||
JERRY_ASSERT (!ecma_prop_name_is_symbol ((ecma_string_t *) ecma_string_p));
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if ((((uintptr_t) ecma_string_p) & ECMA_VALUE_TYPE_MASK) != 0)
|
||||
{
|
||||
@@ -660,7 +632,6 @@ 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_ESNEXT)
|
||||
/**
|
||||
* Symbol value constructor
|
||||
*
|
||||
@@ -674,7 +645,6 @@ 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_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Property-name value constructor
|
||||
@@ -686,12 +656,10 @@ ecma_make_prop_name_value (const ecma_string_t *ecma_prop_name_p) /**< property
|
||||
{
|
||||
JERRY_ASSERT (ecma_prop_name_p != NULL);
|
||||
|
||||
#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_ESNEXT) */
|
||||
|
||||
return ecma_make_string_value (ecma_prop_name_p);
|
||||
} /* ecma_make_prop_name_value */
|
||||
@@ -730,9 +698,9 @@ ecma_make_extended_primitive_value (const ecma_extended_primitive_t *primitve_p,
|
||||
uint32_t type) /**< ecma type of extended primitve value */
|
||||
{
|
||||
JERRY_ASSERT (primitve_p != NULL);
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
JERRY_ASSERT (primitve_p != ECMA_BIGINT_POINTER_TO_ZERO);
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
JERRY_ASSERT (type == ECMA_TYPE_BIGINT || type == ECMA_TYPE_ERROR);
|
||||
|
||||
return ecma_pointer_to_ecma_value (primitve_p) | type;
|
||||
@@ -769,7 +737,7 @@ ecma_get_float_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return floating point value
|
||||
*/
|
||||
extern 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);
|
||||
@@ -798,7 +766,7 @@ ecma_get_number_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the string pointer
|
||||
*/
|
||||
extern 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));
|
||||
@@ -811,27 +779,25 @@ 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_ESNEXT)
|
||||
/**
|
||||
* Get pointer to ecma-string from ecma value
|
||||
*
|
||||
* @return the string pointer
|
||||
*/
|
||||
extern 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_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Get pointer to a property name from ecma value
|
||||
*
|
||||
* @return the string pointer
|
||||
*/
|
||||
extern 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));
|
||||
@@ -849,7 +815,7 @@ ecma_get_prop_name_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the pointer
|
||||
*/
|
||||
extern 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));
|
||||
@@ -862,12 +828,12 @@ ecma_get_object_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the pointer
|
||||
*/
|
||||
extern inline ecma_extended_primitive_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
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 */
|
||||
{
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
JERRY_ASSERT (value != ECMA_BIGINT_ZERO);
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_BIGINT
|
||||
|| ecma_get_value_type_field (value) == ECMA_TYPE_ERROR);
|
||||
|
||||
@@ -893,29 +859,27 @@ ecma_invert_boolean_value (ecma_value_t value) /**< ecma value */
|
||||
* @return copy of the given value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_copy_value (ecma_value_t value) /**< value description */
|
||||
ecma_copy_value (ecma_value_t value) /**< value description */
|
||||
{
|
||||
switch (ecma_get_value_type_field (value))
|
||||
{
|
||||
case ECMA_TYPE_FLOAT:
|
||||
{
|
||||
ecma_number_t *num_p = (ecma_number_t *) ecma_get_pointer_from_ecma_value (value);
|
||||
ecma_number_t *new_num_p = ecma_alloc_number ();
|
||||
|
||||
return ecma_create_float_number (*num_p);
|
||||
*new_num_p = *num_p;
|
||||
|
||||
return ecma_make_float_value (new_num_p);
|
||||
}
|
||||
case ECMA_TYPE_SYMBOL:
|
||||
case ECMA_TYPE_STRING:
|
||||
{
|
||||
ecma_ref_ecma_string (ecma_get_string_from_value (value));
|
||||
ecma_string_t *string_p = (ecma_string_t *) ecma_get_pointer_from_ecma_value (value);
|
||||
ecma_ref_ecma_string_non_direct (string_p);
|
||||
return value;
|
||||
}
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case ECMA_TYPE_SYMBOL:
|
||||
{
|
||||
ecma_ref_ecma_string (ecma_get_symbol_from_value (value));
|
||||
return value;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
case ECMA_TYPE_BIGINT:
|
||||
{
|
||||
if (value != ECMA_BIGINT_ZERO)
|
||||
@@ -924,10 +888,10 @@ ecma_copy_value (ecma_value_t value) /**< value description */
|
||||
}
|
||||
return value;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
case ECMA_TYPE_OBJECT:
|
||||
{
|
||||
ecma_ref_object (ecma_get_object_from_value (value));
|
||||
ecma_ref_object_inline (ecma_get_object_from_value (value));
|
||||
return value;
|
||||
}
|
||||
default:
|
||||
@@ -952,7 +916,7 @@ ecma_copy_value (ecma_value_t value) /**< value description */
|
||||
* @return copy of the given value
|
||||
*/
|
||||
extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_fast_copy_value (ecma_value_t value) /**< value description */
|
||||
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);
|
||||
} /* ecma_fast_copy_value */
|
||||
@@ -1007,8 +971,7 @@ void
|
||||
ecma_value_assign_value (ecma_value_t *value_p, /**< [in, out] ecma value */
|
||||
ecma_value_t ecma_value) /**< value to assign */
|
||||
{
|
||||
JERRY_STATIC_ASSERT (ECMA_TYPE_DIRECT == 0,
|
||||
ecma_type_direct_must_be_zero_for_the_next_check);
|
||||
JERRY_STATIC_ASSERT (ECMA_TYPE_DIRECT == 0, ecma_type_direct_must_be_zero_for_the_next_check);
|
||||
|
||||
if (*value_p == ecma_value)
|
||||
{
|
||||
@@ -1019,8 +982,7 @@ ecma_value_assign_value (ecma_value_t *value_p, /**< [in, out] ecma value */
|
||||
{
|
||||
*value_p = ecma_value;
|
||||
}
|
||||
else if (ecma_is_value_float_number (ecma_value)
|
||||
&& ecma_is_value_float_number (*value_p))
|
||||
else if (ecma_is_value_float_number (ecma_value) && ecma_is_value_float_number (*value_p))
|
||||
{
|
||||
const ecma_number_t *num_src_p = (ecma_number_t *) ecma_get_pointer_from_ecma_value (ecma_value);
|
||||
ecma_number_t *num_dst_p = (ecma_number_t *) ecma_get_pointer_from_ecma_value (*value_p);
|
||||
@@ -1132,37 +1094,29 @@ ecma_free_value (ecma_value_t value) /**< value description */
|
||||
ecma_dealloc_number (number_p);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECMA_TYPE_SYMBOL:
|
||||
case ECMA_TYPE_STRING:
|
||||
{
|
||||
ecma_string_t *string_p = ecma_get_string_from_value (value);
|
||||
ecma_deref_ecma_string (string_p);
|
||||
ecma_string_t *string_p = (ecma_string_t *) ecma_get_pointer_from_ecma_value (value);
|
||||
ecma_deref_ecma_string_non_direct (string_p);
|
||||
break;
|
||||
}
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case ECMA_TYPE_SYMBOL:
|
||||
{
|
||||
ecma_deref_ecma_string (ecma_get_symbol_from_value (value));
|
||||
break;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
case ECMA_TYPE_OBJECT:
|
||||
{
|
||||
ecma_deref_object (ecma_get_object_from_value (value));
|
||||
break;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
#if 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) */
|
||||
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
default:
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT
|
||||
@@ -1265,18 +1219,16 @@ ecma_get_typeof_lit_id (ecma_value_t value) /**< input ecma value */
|
||||
{
|
||||
ret_value = LIT_MAGIC_STRING_STRING;
|
||||
}
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (ecma_is_value_symbol (value))
|
||||
{
|
||||
ret_value = LIT_MAGIC_STRING_SYMBOL;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
else if (ecma_is_value_bigint (value))
|
||||
{
|
||||
ret_value = LIT_MAGIC_STRING_BIGINT;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_object (value));
|
||||
|
||||
+532
-332
File diff suppressed because it is too large
Load Diff
+113
-143
@@ -17,6 +17,7 @@
|
||||
#define ECMA_HELPERS_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
#include "lit-strings.h"
|
||||
|
||||
@@ -47,8 +48,8 @@
|
||||
* Set value of non-null compressed pointer so that it will correspond
|
||||
* to specified non_compressed_pointer.
|
||||
*/
|
||||
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) JMEM_CP_SET_NON_NULL_POINTER (field, \
|
||||
non_compressed_pointer)
|
||||
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) \
|
||||
JMEM_CP_SET_NON_NULL_POINTER (field, non_compressed_pointer)
|
||||
|
||||
/**
|
||||
* Set value of pointer-tag value so that it will correspond
|
||||
@@ -88,42 +89,38 @@
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_STRING_FLAG_EMPTY = 0, /**< No options are provided. */
|
||||
ECMA_STRING_FLAG_IS_ASCII = (1 << 0), /**< The string contains only ASCII characters. */
|
||||
ECMA_STRING_FLAG_EMPTY = 0, /**< No options are provided. */
|
||||
ECMA_STRING_FLAG_IS_ASCII = (1 << 0), /**< The string contains only ASCII characters. */
|
||||
ECMA_STRING_FLAG_REHASH_NEEDED = (1 << 1), /**< The hash of the string must be recalculated.
|
||||
* For more details see ecma_append_chars_to_string */
|
||||
ECMA_STRING_FLAG_IS_UINT32 = (1 << 2), /**< The string repesents an UINT32 number */
|
||||
ECMA_STRING_FLAG_IS_UINT32 = (1 << 2), /**< The string repesents an UINT32 number */
|
||||
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
|
||||
#define ECMA_CONVERSION_ALLOW_UNDERSCORE 0x1
|
||||
|
||||
/**
|
||||
* Convert ecma-string's contents to a cesu-8 string and put it into a buffer.
|
||||
*/
|
||||
#define ECMA_STRING_TO_UTF8_STRING(ecma_str_ptr, /**< ecma string pointer */ \
|
||||
utf8_ptr, /**< [out] output buffer pointer */ \
|
||||
#define ECMA_STRING_TO_UTF8_STRING(ecma_str_ptr, /**< ecma string pointer */ \
|
||||
utf8_ptr, /**< [out] output buffer pointer */ \
|
||||
utf8_str_size) /**< [out] output buffer size */ \
|
||||
lit_utf8_size_t utf8_str_size; \
|
||||
uint8_t utf8_ptr ## flags = ECMA_STRING_FLAG_EMPTY; \
|
||||
const lit_utf8_byte_t *utf8_ptr = ecma_string_get_chars (ecma_str_ptr, \
|
||||
&utf8_str_size, \
|
||||
NULL, \
|
||||
NULL, \
|
||||
&utf8_ptr ## flags);
|
||||
lit_utf8_size_t utf8_str_size; \
|
||||
uint8_t utf8_ptr##flags = ECMA_STRING_FLAG_EMPTY; \
|
||||
const lit_utf8_byte_t *utf8_ptr = ecma_string_get_chars (ecma_str_ptr, &utf8_str_size, NULL, NULL, &utf8_ptr##flags);
|
||||
|
||||
/**
|
||||
* Free the cesu-8 string buffer allocated by 'ECMA_STRING_TO_UTF8_STRING'
|
||||
*/
|
||||
#define ECMA_FINALIZE_UTF8_STRING(utf8_ptr, /**< pointer to character buffer */ \
|
||||
utf8_str_size) /**< buffer size */ \
|
||||
if (utf8_ptr ## flags & ECMA_STRING_FLAG_MUST_BE_FREED) \
|
||||
{ \
|
||||
JERRY_ASSERT (utf8_ptr != NULL); \
|
||||
jmem_heap_free_block ((void *) utf8_ptr, utf8_str_size); \
|
||||
utf8_str_size) /**< buffer size */ \
|
||||
if (utf8_ptr##flags & ECMA_STRING_FLAG_MUST_BE_FREED) \
|
||||
{ \
|
||||
JERRY_ASSERT (utf8_ptr != NULL); \
|
||||
jmem_heap_free_block ((void *) utf8_ptr, utf8_str_size); \
|
||||
}
|
||||
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
@@ -131,64 +128,54 @@ typedef enum
|
||||
/**
|
||||
* Set an internal property value from pointer.
|
||||
*/
|
||||
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) \
|
||||
((field) = ((ecma_value_t) pointer))
|
||||
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, 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))
|
||||
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) ((field) = ((ecma_value_t) pointer))
|
||||
|
||||
/**
|
||||
* Convert an internal property value to pointer.
|
||||
*/
|
||||
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) \
|
||||
((type *) field)
|
||||
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) ((type *) field)
|
||||
|
||||
/**
|
||||
* Convert an internal property value to pointer. Result can be NULL.
|
||||
*/
|
||||
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) \
|
||||
((type *) field)
|
||||
#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))
|
||||
#define ECMA_IS_INTERNAL_VALUE_NULL(field) ((field) == ((ecma_value_t) NULL))
|
||||
|
||||
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
/**
|
||||
* Set an internal property value from pointer.
|
||||
*/
|
||||
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) \
|
||||
ECMA_SET_NON_NULL_POINTER (field, pointer)
|
||||
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) ECMA_SET_NON_NULL_POINTER (field, pointer)
|
||||
|
||||
/**
|
||||
* Set an internal property value from pointer. Pointer can be NULL.
|
||||
*/
|
||||
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) \
|
||||
ECMA_SET_POINTER (field, pointer)
|
||||
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) ECMA_SET_POINTER (field, pointer)
|
||||
|
||||
/**
|
||||
* Convert an internal property value to pointer.
|
||||
*/
|
||||
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) \
|
||||
ECMA_GET_NON_NULL_POINTER (type, field)
|
||||
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) ECMA_GET_NON_NULL_POINTER (type, field)
|
||||
|
||||
/**
|
||||
* Convert an internal property value to pointer. Result can be NULL.
|
||||
*/
|
||||
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) \
|
||||
ECMA_GET_POINTER (type, field)
|
||||
#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))
|
||||
#define ECMA_IS_INTERNAL_VALUE_NULL(field) ((field) == ((ecma_value_t) JMEM_CP_NULL))
|
||||
|
||||
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
@@ -209,11 +196,11 @@ typedef enum
|
||||
*
|
||||
* @param obj_p ecma-object
|
||||
*/
|
||||
#if ENABLED (JERRY_BUILTIN_PROXY)
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
#define ECMA_OBJECT_IS_PROXY(obj_p) (ECMA_OBJECT_TYPE_IS_PROXY (ecma_get_object_type ((obj_p))))
|
||||
#else /* !ENABLED (JERRY_BUILTIN_PROXY) */
|
||||
#else /* !JERRY_BUILTIN_PROXY */
|
||||
#define ECMA_OBJECT_IS_PROXY(obj_p) (false)
|
||||
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
|
||||
/* ecma-helpers-value.c */
|
||||
ecma_type_t JERRY_ATTR_CONST ecma_get_value_type_field (ecma_value_t value);
|
||||
@@ -240,7 +227,7 @@ 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);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_object (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_error_reference (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_exception (ecma_value_t value);
|
||||
ecma_value_t ecma_is_value_array (ecma_value_t arg);
|
||||
|
||||
void ecma_check_value_type_is_spec_defined (ecma_value_t value);
|
||||
@@ -254,9 +241,7 @@ 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_ESNEXT)
|
||||
ecma_value_t JERRY_ATTR_PURE ecma_make_symbol_value (const ecma_string_t *ecma_symbol_p);
|
||||
#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);
|
||||
@@ -264,12 +249,10 @@ ecma_value_t JERRY_ATTR_PURE ecma_make_extended_primitive_value (const ecma_exte
|
||||
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 *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_ESNEXT)
|
||||
ecma_string_t JERRY_ATTR_PURE *ecma_get_symbol_from_value (ecma_value_t value);
|
||||
#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_extended_primitive_t JERRY_ATTR_PURE *ecma_get_extended_primitive_from_value (ecma_value_t value);
|
||||
@@ -290,24 +273,21 @@ 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_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);
|
||||
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)
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
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_BUILTIN_MAP) || ENABLED (JERRY_BUILTIN_SET) */
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
ecma_string_t *ecma_new_ecma_string_from_ascii (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size);
|
||||
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_external_string_from_cesu8 (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size, void *user_p);
|
||||
ecma_string_t *ecma_new_ecma_string_from_code_unit (ecma_char_t code_unit);
|
||||
#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_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);
|
||||
@@ -321,33 +301,19 @@ ecma_string_t *ecma_append_chars_to_string (ecma_string_t *string1_p,
|
||||
lit_utf8_size_t cesu8_string2_length);
|
||||
ecma_string_t *ecma_concat_ecma_strings (ecma_string_t *string1_p, ecma_string_t *string2_p);
|
||||
void ecma_ref_ecma_string (ecma_string_t *string_p);
|
||||
void ecma_ref_ecma_string_non_direct (ecma_string_t *string_p);
|
||||
void ecma_deref_ecma_string (ecma_string_t *string_p);
|
||||
void ecma_deref_ecma_string_non_direct (ecma_string_t *string_p);
|
||||
void ecma_destroy_ecma_string (ecma_string_t *string_p);
|
||||
ecma_number_t ecma_string_to_number (const ecma_string_t *str_p);
|
||||
uint32_t ecma_string_get_array_index (const ecma_string_t *str_p);
|
||||
|
||||
lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT
|
||||
ecma_string_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT
|
||||
ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t
|
||||
ecma_substring_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
|
||||
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,
|
||||
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,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT ecma_string_copy_to_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size,
|
||||
jerry_encoding_t encoding);
|
||||
void
|
||||
ecma_string_to_cesu8_bytes (const ecma_string_t *string_desc_p, lit_utf8_byte_t *buffer_p, lit_utf8_size_t buffer_size);
|
||||
const lit_utf8_byte_t *ecma_string_get_chars (const ecma_string_t *string_p,
|
||||
lit_utf8_size_t *size_p,
|
||||
lit_utf8_size_t *length_p,
|
||||
@@ -361,7 +327,8 @@ jmem_cpointer_t ecma_string_to_property_name (ecma_string_t *prop_name_p, ecma_p
|
||||
ecma_string_t *ecma_string_from_property_name (ecma_property_t property, jmem_cpointer_t prop_name_cp);
|
||||
lit_string_hash_t ecma_string_get_property_name_hash (ecma_property_t property, jmem_cpointer_t prop_name_cp);
|
||||
uint32_t ecma_string_get_property_index (ecma_property_t property, jmem_cpointer_t prop_name_cp);
|
||||
bool ecma_string_compare_to_property_name (ecma_property_t property, jmem_cpointer_t prop_name_cp,
|
||||
bool ecma_string_compare_to_property_name (ecma_property_t property,
|
||||
jmem_cpointer_t prop_name_cp,
|
||||
const ecma_string_t *string_p);
|
||||
|
||||
bool ecma_compare_ecma_strings (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
|
||||
@@ -379,20 +346,14 @@ 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, 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);
|
||||
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_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);
|
||||
|
||||
ecma_stringbuilder_t ecma_stringbuilder_create (void);
|
||||
ecma_stringbuilder_t ecma_stringbuilder_create_from (ecma_string_t *string_p);
|
||||
ecma_stringbuilder_t ecma_stringbuilder_create_raw (const lit_utf8_byte_t *data_p,
|
||||
const lit_utf8_size_t data_size);
|
||||
ecma_stringbuilder_t ecma_stringbuilder_create_raw (const lit_utf8_byte_t *data_p, const lit_utf8_size_t data_size);
|
||||
lit_utf8_size_t ecma_stringbuilder_get_size (ecma_stringbuilder_t *builder_p);
|
||||
lit_utf8_byte_t *ecma_stringbuilder_get_data (ecma_stringbuilder_t *builder_p);
|
||||
void ecma_stringbuilder_revert (ecma_stringbuilder_t *builder_p, const lit_utf8_size_t size);
|
||||
@@ -408,8 +369,6 @@ 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);
|
||||
@@ -417,18 +376,14 @@ bool ecma_number_is_negative (ecma_number_t num);
|
||||
bool ecma_number_is_zero (ecma_number_t num);
|
||||
bool ecma_number_is_infinity (ecma_number_t num);
|
||||
bool ecma_number_is_finite (ecma_number_t num);
|
||||
ecma_number_t
|
||||
ecma_number_make_from_sign_mantissa_and_exponent (bool sign, uint64_t mantissa, int32_t exponent);
|
||||
ecma_number_t ecma_number_get_prev (ecma_number_t num);
|
||||
ecma_number_t ecma_number_get_next (ecma_number_t num);
|
||||
ecma_number_t ecma_number_trunc (ecma_number_t num);
|
||||
ecma_number_t ecma_number_calc_remainder (ecma_number_t left_num, ecma_number_t right_num);
|
||||
ecma_number_t ecma_number_remainder (ecma_number_t left_num, ecma_number_t right_num);
|
||||
ecma_number_t ecma_number_pow (ecma_number_t x, ecma_number_t y);
|
||||
ecma_value_t ecma_number_parse_int (const lit_utf8_byte_t *string_buff,
|
||||
lit_utf8_size_t string_buff_size,
|
||||
ecma_value_t radix);
|
||||
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_number_parse_int (const lit_utf8_byte_t *string_buff, lit_utf8_size_t string_buff_size, ecma_value_t radix);
|
||||
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);
|
||||
|
||||
@@ -441,9 +396,7 @@ 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);
|
||||
|
||||
@@ -451,46 +404,55 @@ 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_value_t *ecma_compact_collection_end (ecma_value_t *compact_collection_p);
|
||||
void ecma_compact_collection_destroy (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);
|
||||
ecma_object_t *ecma_create_decl_lex_env (ecma_object_t *outer_lexical_environment_p);
|
||||
ecma_object_t *ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, ecma_object_t *binding_obj_p,
|
||||
ecma_lexical_environment_type_t type);
|
||||
ecma_object_t *ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, ecma_object_t *binding_obj_p);
|
||||
ecma_object_t *ecma_create_lex_env_class (ecma_object_t *outer_lexical_environment_p, size_t lexical_env_size);
|
||||
bool JERRY_ATTR_PURE ecma_is_lexical_environment (const ecma_object_t *object_p);
|
||||
void ecma_op_ordinary_object_set_extensible (ecma_object_t *object_p);
|
||||
ecma_object_type_t JERRY_ATTR_PURE ecma_get_object_type (const ecma_object_t *object_p);
|
||||
bool JERRY_ATTR_PURE ecma_get_object_is_builtin (const ecma_object_t *object_p);
|
||||
void ecma_set_object_is_builtin (ecma_object_t *object_p);
|
||||
uint8_t ecma_get_object_builtin_id (ecma_object_t *object_p);
|
||||
ecma_object_base_type_t JERRY_ATTR_PURE ecma_get_object_base_type (const ecma_object_t *object_p);
|
||||
bool JERRY_ATTR_PURE ecma_object_class_is (ecma_object_t *object_p, ecma_object_class_type_t class_id);
|
||||
ecma_lexical_environment_type_t JERRY_ATTR_PURE ecma_get_lex_env_type (const ecma_object_t *object_p);
|
||||
ecma_object_t JERRY_ATTR_PURE *ecma_get_lex_env_binding_object (const ecma_object_t *object_p);
|
||||
ecma_object_t *ecma_clone_decl_lexical_environment (ecma_object_t *lex_env_p, bool copy_values);
|
||||
|
||||
ecma_property_value_t *
|
||||
ecma_create_named_data_property (ecma_object_t *object_p, ecma_string_t *name_p, uint8_t prop_attributes,
|
||||
ecma_property_t **out_prop_p);
|
||||
ecma_property_value_t *
|
||||
ecma_create_named_accessor_property (ecma_object_t *object_p, ecma_string_t *name_p, ecma_object_t *get_p,
|
||||
ecma_object_t *set_p, uint8_t prop_attributes, ecma_property_t **out_prop_p);
|
||||
ecma_property_t *
|
||||
ecma_find_named_property (ecma_object_t *obj_p, ecma_string_t *name_p);
|
||||
ecma_property_value_t *
|
||||
ecma_get_named_data_property (ecma_object_t *obj_p, ecma_string_t *name_p);
|
||||
|
||||
void ecma_free_property (ecma_object_t *object_p, jmem_cpointer_t name_cp, ecma_property_t *property_p);
|
||||
ecma_property_value_t *ecma_create_named_data_property (ecma_object_t *object_p,
|
||||
ecma_string_t *name_p,
|
||||
uint8_t prop_attributes,
|
||||
ecma_property_t **out_prop_p);
|
||||
ecma_property_value_t *ecma_create_named_accessor_property (ecma_object_t *object_p,
|
||||
ecma_string_t *name_p,
|
||||
ecma_object_t *get_p,
|
||||
ecma_object_t *set_p,
|
||||
uint8_t prop_attributes,
|
||||
ecma_property_t **out_prop_p);
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
void ecma_create_named_reference_property (ecma_object_t *object_p, ecma_string_t *name_p, ecma_value_t reference);
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
ecma_property_t *ecma_find_named_property (ecma_object_t *obj_p, ecma_string_t *name_p);
|
||||
ecma_property_value_t *ecma_get_named_data_property (ecma_object_t *obj_p, ecma_string_t *name_p);
|
||||
|
||||
void ecma_delete_property (ecma_object_t *object_p, ecma_property_value_t *prop_value_p);
|
||||
|
||||
void ecma_named_data_property_assign_value (ecma_object_t *obj_p, ecma_property_value_t *prop_value_p,
|
||||
ecma_value_t value);
|
||||
void
|
||||
ecma_named_data_property_assign_value (ecma_object_t *obj_p, ecma_property_value_t *prop_value_p, ecma_value_t value);
|
||||
|
||||
ecma_getter_setter_pointers_t *
|
||||
ecma_get_named_accessor_property (const ecma_property_value_t *prop_value_p);
|
||||
void ecma_set_named_accessor_property_getter (ecma_object_t *object_p, ecma_property_value_t *prop_value_p,
|
||||
ecma_getter_setter_pointers_t *ecma_get_named_accessor_property (const ecma_property_value_t *prop_value_p);
|
||||
void ecma_set_named_accessor_property_getter (ecma_object_t *object_p,
|
||||
ecma_property_value_t *prop_value_p,
|
||||
ecma_object_t *getter_p);
|
||||
void ecma_set_named_accessor_property_setter (ecma_object_t *object_p, ecma_property_value_t *prop_value_p,
|
||||
void ecma_set_named_accessor_property_setter (ecma_object_t *object_p,
|
||||
ecma_property_value_t *prop_value_p,
|
||||
ecma_object_t *setter_p);
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
ecma_value_t ecma_property_to_reference (ecma_property_t *property_p);
|
||||
ecma_property_value_t *ecma_get_property_value_from_named_reference (ecma_property_value_t *reference_p);
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
bool ecma_is_property_writable (ecma_property_t property);
|
||||
void ecma_set_property_writable_attr (ecma_property_t *property_p, bool is_writable);
|
||||
bool ecma_is_property_enumerable (ecma_property_t property);
|
||||
@@ -498,46 +460,54 @@ void ecma_set_property_enumerable_attr (ecma_property_t *property_p, bool is_enu
|
||||
bool ecma_is_property_configurable (ecma_property_t property);
|
||||
void ecma_set_property_configurable_attr (ecma_property_t *property_p, bool is_configurable);
|
||||
|
||||
#if ENABLED (JERRY_LCACHE)
|
||||
#if JERRY_LCACHE
|
||||
bool ecma_is_property_lcached (ecma_property_t *property_p);
|
||||
void ecma_set_property_lcached (ecma_property_t *property_p, bool is_lcached);
|
||||
#endif /* ENABLED (JERRY_LCACHE) */
|
||||
#endif /* JERRY_LCACHE */
|
||||
|
||||
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_exception (ecma_extended_primitive_t *exception_p);
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
void ecma_deref_bigint (ecma_extended_primitive_t *bigint_p);
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
#endif /* 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_raise_error_from_error_reference (ecma_value_t value);
|
||||
ecma_value_t ecma_create_exception (ecma_value_t value, uint32_t options);
|
||||
ecma_value_t ecma_create_exception_from_context (void);
|
||||
ecma_value_t ecma_create_exception_from_object (ecma_object_t *object_p);
|
||||
void ecma_throw_exception (ecma_value_t value);
|
||||
|
||||
void ecma_script_deref (ecma_value_t script_value);
|
||||
void ecma_bytecode_ref (ecma_compiled_code_t *bytecode_p);
|
||||
void ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p);
|
||||
ecma_value_t ecma_script_get_from_value (ecma_value_t value);
|
||||
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);
|
||||
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_LINE_INFO
|
||||
uint8_t *ecma_compiled_code_get_line_info (const ecma_compiled_code_t *bytecode_header_p);
|
||||
#endif /* JERRY_LINE_INFO */
|
||||
ecma_value_t ecma_get_source_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) */
|
||||
|
||||
/* ecma-helpers-external-pointers.c */
|
||||
bool ecma_create_native_pointer_property (ecma_object_t *obj_p, void *native_p, void *info_p);
|
||||
ecma_native_pointer_t *ecma_get_native_pointer_value (ecma_object_t *obj_p, void *info_p);
|
||||
bool ecma_delete_native_pointer_property (ecma_object_t *obj_p, void *info_p);
|
||||
bool ecma_create_native_pointer_property (ecma_object_t *obj_p,
|
||||
void *native_p,
|
||||
const jerry_object_native_info_t *native_info_p);
|
||||
ecma_native_pointer_t *ecma_get_native_pointer_value (ecma_object_t *obj_p,
|
||||
const jerry_object_native_info_t *native_info_p);
|
||||
bool ecma_delete_native_pointer_property (ecma_object_t *obj_p, const jerry_object_native_info_t *native_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,
|
||||
uint32_t option);
|
||||
ecma_number_t ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, lit_utf8_size_t str_size, uint32_t option);
|
||||
ecma_number_t ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p,
|
||||
lit_utf8_size_t str_size,
|
||||
uint32_t radix,
|
||||
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);
|
||||
|
||||
@@ -13,14 +13,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-init-finalize.h"
|
||||
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-init-finalize.h"
|
||||
#include "ecma-lex-env.h"
|
||||
#include "ecma-literal-storage.h"
|
||||
#include "jmem.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jmem.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -46,23 +48,23 @@ ecma_init (void)
|
||||
|
||||
ecma_init_global_environment ();
|
||||
|
||||
#if ENABLED (JERRY_PROPRETY_HASHMAP)
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
JERRY_CONTEXT (ecma_prop_hashmap_alloc_state) = ECMA_PROP_HASHMAP_ALLOC_ON;
|
||||
JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_HIGH_PRESSURE_GC;
|
||||
#endif /* ENABLED (JERRY_PROPRETY_HASHMAP) */
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
|
||||
#if (JERRY_STACK_LIMIT != 0)
|
||||
volatile int sp;
|
||||
JERRY_CONTEXT (stack_base) = (uintptr_t) &sp;
|
||||
#endif /* (JERRY_STACK_LIMIT != 0) */
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_PROMISE)
|
||||
ecma_job_queue_init ();
|
||||
#endif /* ENABLED (JERRY_BUILTIN_PROMISE) */
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
JERRY_CONTEXT (current_new_target_p) = NULL;
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
JERRY_CONTEXT (arraybuffer_compact_allocation_limit) = 256;
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
} /* ecma_init */
|
||||
|
||||
/**
|
||||
@@ -71,9 +73,7 @@ ecma_init (void)
|
||||
void
|
||||
ecma_finalize (void)
|
||||
{
|
||||
#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;
|
||||
@@ -83,12 +83,10 @@ ecma_finalize (void)
|
||||
ecma_gc_run ();
|
||||
if (++runs >= JERRY_GC_LOOP_LIMIT)
|
||||
{
|
||||
jerry_fatal (ERR_UNTERMINATED_GC_LOOPS);
|
||||
jerry_fatal (JERRY_FATAL_UNTERMINATED_GC_LOOPS);
|
||||
}
|
||||
}
|
||||
while (JERRY_CONTEXT (ecma_gc_new_objects) != 0);
|
||||
} 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++)
|
||||
@@ -98,7 +96,6 @@ ecma_finalize (void)
|
||||
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 */
|
||||
|
||||
@@ -13,10 +13,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-lcache.h"
|
||||
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lcache.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -26,16 +28,16 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if ENABLED (JERRY_LCACHE)
|
||||
#if JERRY_LCACHE
|
||||
|
||||
/**
|
||||
* Bitshift index for calculating hash.
|
||||
*/
|
||||
#if ENABLED (JERRY_CPOINTER_32_BIT)
|
||||
#if JERRY_CPOINTER_32_BIT
|
||||
#define ECMA_LCACHE_HASH_BITSHIFT_INDEX (2 * JMEM_ALIGNMENT_LOG)
|
||||
#else /* !ENABLED (JERRY_CPOINTER_32_BIT) */
|
||||
#else /* !JERRY_CPOINTER_32_BIT */
|
||||
#define ECMA_LCACHE_HASH_BITSHIFT_INDEX 0
|
||||
#endif /* ENABLED (JERRY_CPOINTER_32_BIT) */
|
||||
#endif /* JERRY_CPOINTER_32_BIT */
|
||||
|
||||
/**
|
||||
* Mask for hash bits
|
||||
@@ -98,7 +100,7 @@ ecma_lcache_insert (const ecma_object_t *object_p, /**< object */
|
||||
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
|
||||
|
||||
size_t row_index = ecma_lcache_row_index (object_cp, name_cp);
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index];
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache)[row_index];
|
||||
ecma_lcache_hash_entry_t *entry_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH;
|
||||
|
||||
do
|
||||
@@ -109,8 +111,7 @@ ecma_lcache_insert (const ecma_object_t *object_p, /**< object */
|
||||
}
|
||||
|
||||
entry_p++;
|
||||
}
|
||||
while (entry_p < entry_end_p);
|
||||
} while (entry_p < entry_end_p);
|
||||
|
||||
/* Invalidate the last entry. */
|
||||
ecma_lcache_invalidate_entry (--entry_p);
|
||||
@@ -136,7 +137,7 @@ insert:
|
||||
* @return a pointer to an ecma_property_t if the lookup is successful
|
||||
* NULL otherwise
|
||||
*/
|
||||
extern 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 */
|
||||
{
|
||||
@@ -161,7 +162,7 @@ ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
|
||||
|
||||
size_t row_index = ecma_lcache_row_index (object_cp, prop_name_cp);
|
||||
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index];
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache)[row_index];
|
||||
ecma_lcache_hash_entry_t *entry_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH;
|
||||
ecma_lcache_hash_entry_id_t id = ECMA_LCACHE_CREATE_ID (object_cp, prop_name_cp);
|
||||
|
||||
@@ -173,8 +174,7 @@ ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
|
||||
return entry_p->prop_p;
|
||||
}
|
||||
entry_p++;
|
||||
}
|
||||
while (entry_p < entry_end_p);
|
||||
} while (entry_p < entry_end_p);
|
||||
|
||||
return NULL;
|
||||
} /* ecma_lcache_lookup */
|
||||
@@ -195,12 +195,12 @@ ecma_lcache_invalidate (const ecma_object_t *object_p, /**< object */
|
||||
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
|
||||
|
||||
size_t row_index = ecma_lcache_row_index (object_cp, name_cp);
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index];
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache)[row_index];
|
||||
|
||||
while (true)
|
||||
{
|
||||
/* The property must be present. */
|
||||
JERRY_ASSERT (entry_p - JERRY_CONTEXT (lcache) [row_index] < ECMA_LCACHE_HASH_ROW_LENGTH);
|
||||
JERRY_ASSERT (entry_p - JERRY_CONTEXT (lcache)[row_index] < ECMA_LCACHE_HASH_ROW_LENGTH);
|
||||
|
||||
if (entry_p->id != 0 && entry_p->prop_p == prop_p)
|
||||
{
|
||||
@@ -213,7 +213,7 @@ ecma_lcache_invalidate (const ecma_object_t *object_p, /**< object */
|
||||
}
|
||||
} /* ecma_lcache_invalidate */
|
||||
|
||||
#endif /* ENABLED (JERRY_LCACHE) */
|
||||
#endif /* JERRY_LCACHE */
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -23,12 +23,14 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if ENABLED (JERRY_LCACHE)
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if JERRY_LCACHE
|
||||
void ecma_lcache_insert (const ecma_object_t *object_p, const jmem_cpointer_t name_cp, ecma_property_t *prop_p);
|
||||
ecma_property_t *ecma_lcache_lookup (const ecma_object_t *object_p, const ecma_string_t *prop_name_p);
|
||||
void ecma_lcache_invalidate (const ecma_object_t *object_p, const jmem_cpointer_t name_cp, ecma_property_t *prop_p);
|
||||
|
||||
#endif /* ENABLED (JERRY_LCACHE) */
|
||||
#endif /* JERRY_LCACHE */
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -0,0 +1,271 @@
|
||||
/* 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-line-info.h"
|
||||
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmalineinfo Line info
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if JERRY_LINE_INFO
|
||||
|
||||
/* The layout of the structure is defined in js-parser-line-info-create.c */
|
||||
|
||||
JERRY_STATIC_ASSERT ((ECMA_LINE_INFO_COLUMN_DEFAULT - 1) == ((ECMA_LINE_INFO_ENCODE_TWO_BYTE >> 1) - 1),
|
||||
ecma_line_info_column_1_must_be_accessible_with_the_highest_one_byte_negative_value);
|
||||
|
||||
/**
|
||||
* Decodes an uint32_t number, and updates the buffer position.
|
||||
* Numbers expected to be larger values.
|
||||
*
|
||||
* @return the decoded value
|
||||
*/
|
||||
uint32_t
|
||||
ecma_line_info_decode_vlq (uint8_t **buffer_p) /**< [in/out] target buffer */
|
||||
{
|
||||
uint8_t *source_p = *buffer_p;
|
||||
uint32_t value = 0;
|
||||
|
||||
do
|
||||
{
|
||||
value = (value << ECMA_LINE_INFO_VLQ_SHIFT) | (*source_p & ECMA_LINE_INFO_VLQ_MASK);
|
||||
} while (*source_p++ & ECMA_LINE_INFO_VLQ_CONTINUE);
|
||||
|
||||
*buffer_p = source_p;
|
||||
return value;
|
||||
} /* ecma_line_info_decode_vlq */
|
||||
|
||||
/**
|
||||
* Decodes an uint32_t number, and updates the buffer position.
|
||||
* Numbers expected to be smaller values.
|
||||
*
|
||||
* @return the decoded value
|
||||
*/
|
||||
static uint32_t
|
||||
ecma_line_info_decode_small (uint8_t **buffer_p) /**< [in/out] target buffer */
|
||||
{
|
||||
uint8_t *source_p = *buffer_p;
|
||||
uint32_t type = source_p[0];
|
||||
|
||||
*buffer_p = source_p + 1;
|
||||
|
||||
if (type < ECMA_LINE_INFO_ENCODE_TWO_BYTE_MIN)
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
if (type == ECMA_LINE_INFO_ENCODE_TWO_BYTE)
|
||||
{
|
||||
*buffer_p = source_p + 2;
|
||||
return ((uint32_t) source_p[1]) + ECMA_LINE_INFO_ENCODE_TWO_BYTE_MIN;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (type == ECMA_LINE_INFO_ENCODE_VLQ);
|
||||
return ecma_line_info_decode_vlq (buffer_p) + ECMA_LINE_INFO_ENCODE_VLQ_MIN;
|
||||
} /* ecma_line_info_decode_small */
|
||||
|
||||
/**
|
||||
* Updates a value using an encoded difference.
|
||||
*
|
||||
* @return updated value
|
||||
*/
|
||||
extern inline uint32_t JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_line_info_difference_update (uint32_t current_value, /**< current value */
|
||||
uint32_t difference_value) /**< encoded difference */
|
||||
{
|
||||
if ((difference_value & 0x1) == ECMA_LINE_INFO_INCREASE)
|
||||
{
|
||||
return current_value + (difference_value >> 1) + 1;
|
||||
}
|
||||
|
||||
return current_value - (difference_value >> 1);
|
||||
} /* ecma_line_info_difference_update */
|
||||
|
||||
/**
|
||||
* Release line info data.
|
||||
*/
|
||||
void
|
||||
ecma_line_info_free (uint8_t *line_info_p) /**< line info buffer */
|
||||
{
|
||||
uint8_t *source_p = line_info_p;
|
||||
uint32_t total_length = ecma_line_info_decode_vlq (&source_p);
|
||||
|
||||
jmem_heap_free_block (line_info_p, total_length + (uint32_t) (source_p - line_info_p));
|
||||
} /* ecma_line_info_free */
|
||||
|
||||
/**
|
||||
* Returns the line/column information for a given byte code offset.
|
||||
*/
|
||||
void
|
||||
ecma_line_info_get (uint8_t *line_info_p, /**< line info buffer */
|
||||
uint32_t offset, /**< byte code offset */
|
||||
jerry_frame_location_t *location_p) /**< [out] location */
|
||||
{
|
||||
uint32_t line = 1;
|
||||
uint32_t column = ECMA_LINE_INFO_COLUMN_DEFAULT;
|
||||
uint32_t end_offset = 0;
|
||||
uint32_t end_offset_increase;
|
||||
uint32_t value;
|
||||
|
||||
/* Skip total_length. */
|
||||
ecma_line_info_decode_vlq (&line_info_p);
|
||||
|
||||
while (true)
|
||||
{
|
||||
value = ecma_line_info_decode_vlq (&line_info_p);
|
||||
line = ecma_line_info_difference_update (line, value);
|
||||
|
||||
if (*line_info_p == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
uint8_t *size_p = line_info_p + *line_info_p + (ECMA_LINE_INFO_STREAM_SIZE_MIN + 1);
|
||||
|
||||
uint32_t next_end_offset = end_offset + ecma_line_info_decode_vlq (&size_p);
|
||||
|
||||
if (offset < next_end_offset)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
end_offset = next_end_offset;
|
||||
line_info_p = size_p;
|
||||
}
|
||||
|
||||
line_info_p++;
|
||||
|
||||
do
|
||||
{
|
||||
end_offset_increase = ecma_line_info_decode_small (&line_info_p);
|
||||
|
||||
if (end_offset_increase & ECMA_LINE_INFO_HAS_LINE)
|
||||
{
|
||||
value = ecma_line_info_decode_small (&line_info_p);
|
||||
line = ecma_line_info_difference_update (line, value);
|
||||
column = ECMA_LINE_INFO_COLUMN_DEFAULT;
|
||||
}
|
||||
|
||||
end_offset_increase >>= 1;
|
||||
|
||||
value = ecma_line_info_decode_small (&line_info_p);
|
||||
column = ecma_line_info_difference_update (column, value);
|
||||
|
||||
end_offset += end_offset_increase;
|
||||
} while (end_offset_increase != 0 && end_offset <= offset);
|
||||
|
||||
location_p->line = line;
|
||||
location_p->column = column;
|
||||
} /* ecma_line_info_get */
|
||||
|
||||
#if JERRY_PARSER_DUMP_BYTE_CODE
|
||||
|
||||
/**
|
||||
* Dumps line info data.
|
||||
*/
|
||||
void
|
||||
ecma_line_info_dump (uint8_t *line_info_p) /**< dumps line info data */
|
||||
{
|
||||
bool block_last = false;
|
||||
uint32_t block_line = 1;
|
||||
uint32_t block_byte_code_offset = 0;
|
||||
uint32_t value;
|
||||
|
||||
value = ecma_line_info_decode_vlq (&line_info_p);
|
||||
JERRY_DEBUG_MSG ("\nLine info size: %d bytes\n", (int) value);
|
||||
|
||||
while (true)
|
||||
{
|
||||
value = ecma_line_info_decode_vlq (&line_info_p);
|
||||
block_line = ecma_line_info_difference_update (block_line, value);
|
||||
|
||||
JERRY_DEBUG_MSG ("\nNew block: line: %d", (int) block_line);
|
||||
|
||||
if (*line_info_p == 0)
|
||||
{
|
||||
JERRY_DEBUG_MSG (" StreamLength: [last]\n");
|
||||
block_last = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t *size_p = line_info_p + *line_info_p + (ECMA_LINE_INFO_STREAM_SIZE_MIN + 1);
|
||||
|
||||
value = ecma_line_info_decode_vlq (&size_p);
|
||||
|
||||
JERRY_DEBUG_MSG (" StreamLength: %d ByteCodeSize: %d\n",
|
||||
(int) (*line_info_p + ECMA_LINE_INFO_STREAM_SIZE_MIN),
|
||||
(int) value);
|
||||
}
|
||||
|
||||
line_info_p++;
|
||||
|
||||
uint32_t stream_line = block_line;
|
||||
uint32_t stream_column = ECMA_LINE_INFO_COLUMN_DEFAULT;
|
||||
uint32_t stream_end_offset = block_byte_code_offset;
|
||||
|
||||
while (true)
|
||||
{
|
||||
uint32_t stream_end_offset_increase = ecma_line_info_decode_small (&line_info_p);
|
||||
|
||||
if (stream_end_offset_increase & ECMA_LINE_INFO_HAS_LINE)
|
||||
{
|
||||
value = ecma_line_info_decode_small (&line_info_p);
|
||||
stream_line = ecma_line_info_difference_update (stream_line, value);
|
||||
stream_column = ECMA_LINE_INFO_COLUMN_DEFAULT;
|
||||
}
|
||||
|
||||
stream_end_offset_increase >>= 1;
|
||||
|
||||
value = ecma_line_info_decode_small (&line_info_p);
|
||||
stream_column = ecma_line_info_difference_update (stream_column, value);
|
||||
|
||||
if (stream_end_offset_increase == 0)
|
||||
{
|
||||
JERRY_DEBUG_MSG (" ByteCodeEndOffset: [unterminated] Line: %d Column: %d\n",
|
||||
(int) stream_line,
|
||||
(int) stream_column);
|
||||
break;
|
||||
}
|
||||
|
||||
stream_end_offset += stream_end_offset_increase;
|
||||
|
||||
JERRY_DEBUG_MSG (" ByteCodeEndOffset: %d Line: %d Column: %d\n",
|
||||
(int) stream_end_offset,
|
||||
(int) stream_line,
|
||||
(int) stream_column);
|
||||
}
|
||||
|
||||
if (block_last)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
block_byte_code_offset += ecma_line_info_decode_vlq (&line_info_p);
|
||||
}
|
||||
} /* ecma_line_info_dump */
|
||||
|
||||
#endif /* JERRY_PARSER_DUMP_BYTE_CODE */
|
||||
|
||||
#endif /* JERRY_LINE_INFO */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,114 @@
|
||||
/* 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_LINE_INFO_H
|
||||
#define ECMA_LINE_INFO_H
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmalineinfo Line info
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if JERRY_LINE_INFO
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
/**
|
||||
* Increase the current value of line or column.
|
||||
*/
|
||||
#define ECMA_LINE_INFO_INCREASE 0x0
|
||||
|
||||
/**
|
||||
* Decrease the current value of line or column.
|
||||
*/
|
||||
#define ECMA_LINE_INFO_DECREASE 0x1
|
||||
|
||||
/**
|
||||
* Line update is present.
|
||||
*/
|
||||
#define ECMA_LINE_INFO_HAS_LINE 0x1
|
||||
|
||||
/**
|
||||
* A default value for columns after a line update.
|
||||
*/
|
||||
#define ECMA_LINE_INFO_COLUMN_DEFAULT 127
|
||||
|
||||
/**
|
||||
* Vlq encoding: flag which is set for all bytes except the last one.
|
||||
*/
|
||||
#define ECMA_LINE_INFO_VLQ_CONTINUE 0x80
|
||||
|
||||
/**
|
||||
* Vlq encoding: mask to decode the number fragment.
|
||||
*/
|
||||
#define ECMA_LINE_INFO_VLQ_MASK 0x7f
|
||||
|
||||
/**
|
||||
* Vlq encoding: number of bits stored in a byte.
|
||||
*/
|
||||
#define ECMA_LINE_INFO_VLQ_SHIFT 7
|
||||
|
||||
/**
|
||||
* Small encoding: a value which represents a two byte long number.
|
||||
*/
|
||||
#define ECMA_LINE_INFO_ENCODE_TWO_BYTE (UINT8_MAX - 1)
|
||||
|
||||
/**
|
||||
* Small encoding: minimum value of an encoded two byte long number.
|
||||
*/
|
||||
#define ECMA_LINE_INFO_ENCODE_TWO_BYTE_MIN (UINT8_MAX - 1)
|
||||
|
||||
/**
|
||||
* Small encoding: a value which represents a three byte long number.
|
||||
*/
|
||||
#define ECMA_LINE_INFO_ENCODE_VLQ UINT8_MAX
|
||||
|
||||
/**
|
||||
* Small encoding: minimum value of an encoded three byte long number.
|
||||
*/
|
||||
#define ECMA_LINE_INFO_ENCODE_VLQ_MIN (ECMA_LINE_INFO_ENCODE_TWO_BYTE_MIN + UINT8_MAX + 1)
|
||||
|
||||
/**
|
||||
* Maximum number of line/column entries stored in a stream.
|
||||
*/
|
||||
#define ECMA_LINE_INFO_STREAM_VALUE_COUNT_MAX 48
|
||||
|
||||
/**
|
||||
* Minimum size of a stream (except the last one).
|
||||
*/
|
||||
#define ECMA_LINE_INFO_STREAM_SIZE_MIN ((2 * ECMA_LINE_INFO_STREAM_VALUE_COUNT_MAX) - 1)
|
||||
|
||||
/* Helper functions for parser/js/js-parser-line-info-create.c. */
|
||||
uint32_t ecma_line_info_decode_vlq (uint8_t **buffer_p);
|
||||
uint32_t ecma_line_info_difference_update (uint32_t current_value, uint32_t difference_value);
|
||||
|
||||
/* General functions. */
|
||||
void ecma_line_info_free (uint8_t *line_info_p);
|
||||
void ecma_line_info_get (uint8_t *line_info_p, uint32_t offset, jerry_frame_location_t *location_p);
|
||||
|
||||
#if JERRY_PARSER_DUMP_BYTE_CODE
|
||||
void ecma_line_info_dump (uint8_t *line_info_p);
|
||||
#endif /* JERRY_PARSER_DUMP_BYTE_CODE */
|
||||
|
||||
#endif /* JERRY_LINE_INFO */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !ECMA_LINE_INFO_H */
|
||||
@@ -13,11 +13,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-bigint.h"
|
||||
#include "ecma-big-uint.h"
|
||||
#include "ecma-literal-storage.h"
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-big-uint.h"
|
||||
#include "ecma-bigint.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -27,7 +29,6 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/**
|
||||
* Free symbol list
|
||||
*/
|
||||
@@ -42,8 +43,7 @@ ecma_free_symbol_list (jmem_cpointer_t symbol_list_cp) /**< symbol list */
|
||||
{
|
||||
if (symbol_list_p->values[i] != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
symbol_list_p->values[i]);
|
||||
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, symbol_list_p->values[i]);
|
||||
|
||||
JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (string_p));
|
||||
ecma_deref_ecma_string (string_p);
|
||||
@@ -55,7 +55,6 @@ 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_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Free string list
|
||||
@@ -71,8 +70,7 @@ ecma_free_string_list (jmem_cpointer_t string_list_cp) /**< string list */
|
||||
{
|
||||
if (string_list_p->values[i] != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
string_list_p->values[i]);
|
||||
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, string_list_p->values[i]);
|
||||
|
||||
JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (string_p));
|
||||
ecma_destroy_ecma_string (string_p);
|
||||
@@ -93,8 +91,7 @@ ecma_free_number_list (jmem_cpointer_t number_list_cp) /**< number list */
|
||||
{
|
||||
while (number_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_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++)
|
||||
{
|
||||
@@ -110,7 +107,7 @@ ecma_free_number_list (jmem_cpointer_t number_list_cp) /**< number list */
|
||||
}
|
||||
} /* ecma_free_number_list */
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
|
||||
/**
|
||||
* Free bigint list
|
||||
@@ -120,15 +117,14 @@ 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);
|
||||
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]);
|
||||
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);
|
||||
}
|
||||
@@ -140,7 +136,7 @@ ecma_free_bigint_list (jmem_cpointer_t bigint_list_cp) /**< bigint list */
|
||||
}
|
||||
} /* ecma_free_bigint_list */
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
|
||||
/**
|
||||
* Finalize literal storage
|
||||
@@ -148,14 +144,12 @@ ecma_free_bigint_list (jmem_cpointer_t bigint_list_cp) /**< bigint list */
|
||||
void
|
||||
ecma_finalize_lit_storage (void)
|
||||
{
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ecma_free_symbol_list (JERRY_CONTEXT (symbol_list_first_cp));
|
||||
#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)
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
ecma_free_bigint_list (JERRY_CONTEXT (bigint_list_first_cp));
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
} /* ecma_finalize_lit_storage */
|
||||
|
||||
/**
|
||||
@@ -165,9 +159,11 @@ ecma_finalize_lit_storage (void)
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, /**< string to be searched */
|
||||
lit_utf8_size_t size) /**< size of the string */
|
||||
lit_utf8_size_t size, /**< size of the string */
|
||||
bool is_ascii) /**< encode of the string */
|
||||
{
|
||||
ecma_string_t *string_p = ecma_new_ecma_string_from_utf8 (chars_p, size);
|
||||
ecma_string_t *string_p =
|
||||
(is_ascii ? ecma_new_ecma_string_from_ascii (chars_p, size) : ecma_new_ecma_string_from_utf8 (chars_p, size));
|
||||
|
||||
if (ECMA_IS_DIRECT_STRING (string_p))
|
||||
{
|
||||
@@ -192,8 +188,7 @@ ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, /**< string
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_string_t *value_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
string_list_p->values[i]);
|
||||
ecma_string_t *value_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, string_list_p->values[i]);
|
||||
|
||||
if (ecma_compare_ecma_strings (string_p, value_p))
|
||||
{
|
||||
@@ -254,8 +249,7 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
|
||||
|
||||
while (number_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_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++)
|
||||
{
|
||||
@@ -268,8 +262,7 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_number_t *number_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_t,
|
||||
number_list_p->values[i]);
|
||||
ecma_number_t *number_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_t, number_list_p->values[i]);
|
||||
|
||||
if (*number_p == number_arg)
|
||||
{
|
||||
@@ -306,7 +299,7 @@ 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)
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
|
||||
/**
|
||||
* Find or create a literal BigInt.
|
||||
@@ -328,8 +321,7 @@ ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searc
|
||||
|
||||
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);
|
||||
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++)
|
||||
{
|
||||
@@ -342,8 +334,8 @@ ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searc
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_extended_primitive_t *other_bigint_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t,
|
||||
bigint_list_p->values[i]);
|
||||
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))
|
||||
@@ -381,7 +373,7 @@ ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searc
|
||||
return bigint;
|
||||
} /* ecma_find_or_create_literal_bigint */
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
|
||||
/**
|
||||
* Log2 of snapshot literal alignment.
|
||||
@@ -403,26 +395,27 @@ ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searc
|
||||
*/
|
||||
#define JERRY_SNAPSHOT_LITERAL_IS_NUMBER (1u << ECMA_VALUE_SHIFT)
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
/**
|
||||
* Literal value is BigInt.
|
||||
*/
|
||||
#define JERRY_SNAPSHOT_LITERAL_IS_BIGINT (2u << ECMA_VALUE_SHIFT)
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
|
||||
#if ENABLED (JERRY_SNAPSHOT_SAVE)
|
||||
#if JERRY_SNAPSHOT_SAVE
|
||||
|
||||
/**
|
||||
* Append the value at the end of the appropriate list if it is not present there.
|
||||
*/
|
||||
void ecma_save_literals_append_value (ecma_value_t value, /**< value to be appended */
|
||||
ecma_collection_t *lit_pool_p) /**< list of known values */
|
||||
void
|
||||
ecma_save_literals_append_value (ecma_value_t value, /**< value to be appended */
|
||||
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)
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
&& (!ecma_is_value_bigint (value) || value == ECMA_BIGINT_ZERO)
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
&& !ecma_is_value_float_number (value))
|
||||
{
|
||||
return;
|
||||
@@ -496,11 +489,9 @@ ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_
|
||||
|
||||
for (uint32_t i = const_literal_end; i < literal_end; i++)
|
||||
{
|
||||
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
literal_p[i]);
|
||||
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, literal_p[i]);
|
||||
|
||||
if (CBC_IS_FUNCTION (bytecode_p->status_flags)
|
||||
&& bytecode_p != compiled_code_p)
|
||||
if (CBC_IS_FUNCTION (bytecode_p->status_flags) && bytecode_p != compiled_code_p)
|
||||
{
|
||||
ecma_save_literals_add_compiled_code (bytecode_p, lit_pool_p);
|
||||
}
|
||||
@@ -558,7 +549,7 @@ 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)
|
||||
#if 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]);
|
||||
@@ -566,7 +557,7 @@ ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, /**< list of kno
|
||||
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) */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
else
|
||||
{
|
||||
ecma_string_t *string_p = ecma_get_string_from_value (lit_buffer_p[i]);
|
||||
@@ -617,7 +608,7 @@ 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)
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
else if (ecma_is_value_bigint (lit_buffer_p[i]))
|
||||
{
|
||||
map_p->literal_offset |= JERRY_SNAPSHOT_LITERAL_IS_BIGINT;
|
||||
@@ -630,7 +621,7 @@ ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, /**< list of kno
|
||||
|
||||
length = JERRY_ALIGNUP (sizeof (uint32_t) + size, JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
else
|
||||
{
|
||||
ecma_string_t *string_p = ecma_get_string_from_value (lit_buffer_p[i]);
|
||||
@@ -638,7 +629,7 @@ ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, /**< list of kno
|
||||
|
||||
*(uint16_t *) destination_p = (uint16_t) length;
|
||||
|
||||
ecma_string_to_utf8_bytes (string_p, destination_p + sizeof (uint16_t), length);
|
||||
ecma_string_to_cesu8_bytes (string_p, destination_p + sizeof (uint16_t), length);
|
||||
|
||||
length = JERRY_ALIGNUP (sizeof (uint16_t) + length, JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
|
||||
}
|
||||
@@ -654,9 +645,9 @@ ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, /**< list of kno
|
||||
return true;
|
||||
} /* ecma_save_literals_for_snapshot */
|
||||
|
||||
#endif /* ENABLED (JERRY_SNAPSHOT_SAVE) */
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
|
||||
#if ENABLED (JERRY_SNAPSHOT_EXEC) || ENABLED (JERRY_SNAPSHOT_SAVE)
|
||||
#if JERRY_SNAPSHOT_EXEC || JERRY_SNAPSHOT_SAVE
|
||||
|
||||
/**
|
||||
* Get the compressed pointer of a given literal.
|
||||
@@ -678,7 +669,7 @@ 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 JERRY_BUILTIN_BIGINT
|
||||
if (literal_value & JERRY_SNAPSHOT_LITERAL_IS_BIGINT)
|
||||
{
|
||||
uint32_t bigint_sign_and_size = *(uint32_t *) literal_p;
|
||||
@@ -688,7 +679,7 @@ ecma_snapshot_get_literal (const uint8_t *literal_base_p, /**< literal start */
|
||||
|
||||
if (bigint_p == NULL)
|
||||
{
|
||||
jerry_fatal (ERR_OUT_OF_MEMORY);
|
||||
jerry_fatal (JERRY_FATAL_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
/* Only the sign bit can differ. */
|
||||
@@ -698,23 +689,23 @@ ecma_snapshot_get_literal (const uint8_t *literal_base_p, /**< literal start */
|
||||
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) */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
|
||||
uint16_t length = *(const uint16_t *) literal_p;
|
||||
|
||||
return ecma_find_or_create_literal_string (literal_p + sizeof (uint16_t), length);
|
||||
return ecma_find_or_create_literal_string (literal_p + sizeof (uint16_t), length, false);
|
||||
} /* ecma_snapshot_get_literal */
|
||||
|
||||
/**
|
||||
* 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 ES.next profile 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
|
||||
*/
|
||||
ecma_value_t *
|
||||
ecma_snapshot_resolve_serializable_values (ecma_compiled_code_t *compiled_code_p, /**< compiled code */
|
||||
ecma_snapshot_resolve_serializable_values (const ecma_compiled_code_t *compiled_code_p, /**< compiled code */
|
||||
uint8_t *bytecode_end_p) /**< end of the bytecode */
|
||||
{
|
||||
ecma_value_t *base_p = (ecma_value_t *) bytecode_end_p;
|
||||
@@ -734,17 +725,15 @@ ecma_snapshot_resolve_serializable_values (ecma_compiled_code_t *compiled_code_p
|
||||
base_p -= argument_end;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/* function name */
|
||||
if (CBC_FUNCTION_GET_TYPE (compiled_code_p->status_flags) != CBC_FUNCTION_CONSTRUCTOR)
|
||||
{
|
||||
base_p--;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
return base_p;
|
||||
} /* ecma_snapshot_resolve_serializable_values */
|
||||
#endif /* ENABLED (JERRY_SNAPSHOT_EXEC) || ENABLED (JERRY_SNAPSHOT_SAVE) */
|
||||
#endif /* JERRY_SNAPSHOT_EXEC || JERRY_SNAPSHOT_SAVE */
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#define ECMA_LIT_STORAGE_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
#include "lit-globals.h"
|
||||
|
||||
@@ -27,7 +28,7 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if ENABLED (JERRY_SNAPSHOT_SAVE)
|
||||
#if JERRY_SNAPSHOT_SAVE
|
||||
/**
|
||||
* Snapshot literal - offset map
|
||||
*/
|
||||
@@ -36,31 +37,32 @@ typedef struct
|
||||
ecma_value_t literal_id; /**< literal id */
|
||||
ecma_value_t literal_offset; /**< literal offset */
|
||||
} lit_mem_to_snapshot_id_map_entry_t;
|
||||
#endif /* ENABLED (JERRY_SNAPSHOT_SAVE) */
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
|
||||
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_string (const lit_utf8_byte_t *chars_p, lit_utf8_size_t size, bool is_ascii);
|
||||
ecma_value_t ecma_find_or_create_literal_number (ecma_number_t number_arg);
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
ecma_value_t ecma_find_or_create_literal_bigint (ecma_value_t bigint);
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
|
||||
#if ENABLED (JERRY_SNAPSHOT_SAVE)
|
||||
#if JERRY_SNAPSHOT_SAVE
|
||||
void ecma_save_literals_append_value (ecma_value_t value, ecma_collection_t *lit_pool_p);
|
||||
void ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_p,
|
||||
ecma_collection_t *lit_pool_p);
|
||||
bool ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, uint32_t *buffer_p, size_t buffer_size,
|
||||
size_t *in_out_buffer_offset_p, lit_mem_to_snapshot_id_map_entry_t **out_map_p,
|
||||
void ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, ecma_collection_t *lit_pool_p);
|
||||
bool ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p,
|
||||
uint32_t *buffer_p,
|
||||
size_t buffer_size,
|
||||
size_t *in_out_buffer_offset_p,
|
||||
lit_mem_to_snapshot_id_map_entry_t **out_map_p,
|
||||
uint32_t *out_map_len_p);
|
||||
#endif /* ENABLED (JERRY_SNAPSHOT_SAVE) */
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
|
||||
#if ENABLED (JERRY_SNAPSHOT_EXEC) || ENABLED (JERRY_SNAPSHOT_SAVE)
|
||||
ecma_value_t
|
||||
ecma_snapshot_get_literal (const uint8_t *literal_base_p, ecma_value_t literal_value);
|
||||
ecma_value_t *
|
||||
ecma_snapshot_resolve_serializable_values (ecma_compiled_code_t *compiled_code_p, uint8_t *byte_code_end_p);
|
||||
#endif /* ENABLED (JERRY_SNAPSHOT_EXEC) || ENABLED (JERRY_SNAPSHOT_SAVE) */
|
||||
#if JERRY_SNAPSHOT_EXEC || JERRY_SNAPSHOT_SAVE
|
||||
ecma_value_t ecma_snapshot_get_literal (const uint8_t *literal_base_p, ecma_value_t literal_value);
|
||||
ecma_value_t *ecma_snapshot_resolve_serializable_values (const ecma_compiled_code_t *compiled_code_p,
|
||||
uint8_t *byte_code_end_p);
|
||||
#endif /* JERRY_SNAPSHOT_EXEC || JERRY_SNAPSHOT_SAVE */
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
+1327
-1049
File diff suppressed because it is too large
Load Diff
@@ -16,13 +16,23 @@
|
||||
#ifndef ECMA_MODULE_H
|
||||
#define ECMA_MODULE_H
|
||||
|
||||
#include "common.h"
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if ENABLED (JERRY_MODULE_SYSTEM)
|
||||
#include "common.h"
|
||||
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
|
||||
#define ECMA_MODULE_MAX_PATH 255u
|
||||
|
||||
/**
|
||||
* Module status flags.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_MODULE_IS_NATIVE = (1 << 0), /**< native module */
|
||||
ECMA_MODULE_HAS_NAMESPACE = (1 << 1), /**< namespace object has been initialized */
|
||||
} ecma_module_flags_t;
|
||||
|
||||
/**
|
||||
* Imported or exported names, such as "a as b"
|
||||
* Note: See https://www.ecma-international.org/ecma-262/6.0/#table-39
|
||||
@@ -31,60 +41,57 @@
|
||||
typedef struct ecma_module_names
|
||||
{
|
||||
struct ecma_module_names *next_p; /**< next linked list node */
|
||||
ecma_string_t *imex_name_p; /**< Import/export name of the item */
|
||||
ecma_string_t *local_name_p; /**< Local name of the item */
|
||||
ecma_string_t *imex_name_p; /**< Import/export name of the item */
|
||||
ecma_string_t *local_name_p; /**< Local name of the item */
|
||||
} ecma_module_names_t;
|
||||
|
||||
/**
|
||||
* An enum identifing the current state of the module
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_MODULE_STATE_INIT = 0, /**< module is initialized */
|
||||
ECMA_MODULE_STATE_PARSING = 1, /**< module is currently being parsed */
|
||||
ECMA_MODULE_STATE_PARSED = 2, /**< module has been parsed */
|
||||
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
|
||||
*
|
||||
* Note:
|
||||
* The imports_p list follows the order of import-from/export-from statements in the source
|
||||
* code of a module, even if a given module specifier is only used by export-from statements.
|
||||
*/
|
||||
typedef struct ecma_module
|
||||
{
|
||||
/* Note: state is stored in header.u.class_prop.extra_info */
|
||||
ecma_extended_object_t header; /**< header part */
|
||||
/* 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_object_t *scope_p; /**< lexical lenvironment of the module */
|
||||
ecma_object_t *namespace_object_p; /**< namespace object of the module */
|
||||
struct ecma_module_node *imports_p; /**< import requests of the module */
|
||||
ecma_module_names_t *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 */
|
||||
|
||||
/* Code used for evaluating a module */
|
||||
union
|
||||
{
|
||||
ecma_compiled_code_t *compiled_code_p; /**< compiled code for the module */
|
||||
jerry_native_module_evaluate_cb_t callback; /**< callback for evaluating native modules */
|
||||
} u;
|
||||
} ecma_module_t;
|
||||
|
||||
/**
|
||||
* Module node to store imports / exports.
|
||||
*
|
||||
* Note:
|
||||
* Only one module node is created for each module specifier: the names are
|
||||
* concatenated if the same specifier is used multiple times in the source code.
|
||||
* However, multiple nodes are created for modules with multiple alias
|
||||
* (for example ./a.mjs and ././a.mjs can refer to the same module).
|
||||
*/
|
||||
typedef struct ecma_module_node
|
||||
{
|
||||
struct ecma_module_node *next_p; /**< next linked list 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
|
||||
*/
|
||||
typedef struct ecma_module_record
|
||||
{
|
||||
ecma_module_t *module_p; /**< module */
|
||||
ecma_string_t *name_p; /**< identifier name */
|
||||
} ecma_module_record_t;
|
||||
union
|
||||
{
|
||||
ecma_value_t path_or_module; /**< imports: module specifier (if string) or module reference (if object) */
|
||||
ecma_value_t *module_object_p; /**< non-imports: reference to a path_or_module field in the imports */
|
||||
} u;
|
||||
} ecma_module_node_t;
|
||||
|
||||
/**
|
||||
* A list of module records that can be used to identify circular imports during resolution
|
||||
@@ -92,7 +99,8 @@ typedef struct ecma_module_record
|
||||
typedef struct ecma_module_resolve_set
|
||||
{
|
||||
struct ecma_module_resolve_set *next_p; /**< next in linked list */
|
||||
ecma_module_record_t record; /**< module record */
|
||||
ecma_module_t *module_p; /**< module */
|
||||
ecma_string_t *name_p; /**< identifier name */
|
||||
} ecma_module_resolve_set_t;
|
||||
|
||||
/**
|
||||
@@ -101,36 +109,24 @@ typedef struct ecma_module_resolve_set
|
||||
typedef struct ecma_module_resolve_stack
|
||||
{
|
||||
struct ecma_module_resolve_stack *next_p; /**< next in linked list */
|
||||
ecma_module_t *module_p; /**< module request */
|
||||
ecma_string_t *export_name_p; /**< export identifier name */
|
||||
bool resolving; /**< flag storing wether the current frame started resolving */
|
||||
ecma_module_t *module_p; /**< module request */
|
||||
ecma_string_t *export_name_p; /**< export identifier name */
|
||||
bool resolving; /**< flag storing wether the current frame started resolving */
|
||||
} ecma_module_resolve_stack_t;
|
||||
|
||||
bool ecma_module_resolve_set_insert (ecma_module_resolve_set_t **set_p,
|
||||
ecma_module_t *const module_p,
|
||||
ecma_string_t *const export_name_p);
|
||||
void ecma_module_resolve_set_cleanup (ecma_module_resolve_set_t *set_p);
|
||||
|
||||
void ecma_module_resolve_stack_push (ecma_module_resolve_stack_t **stack_p,
|
||||
ecma_module_t *const module_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 lit_utf8_byte_t *char_p,
|
||||
lit_utf8_size_t size,
|
||||
ecma_string_t *const base_path_p);
|
||||
|
||||
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);
|
||||
ecma_module_t *ecma_module_get_resolved_module (ecma_value_t module_val);
|
||||
|
||||
void ecma_module_initialize_context (ecma_string_t *root_path_p);
|
||||
ecma_value_t ecma_module_link (ecma_module_t *module_p, jerry_module_resolve_cb_t callback_p, void *user_p);
|
||||
ecma_value_t ecma_module_evaluate (ecma_module_t *module_p);
|
||||
ecma_value_t ecma_module_import (ecma_value_t specifier, ecma_value_t user_value);
|
||||
|
||||
ecma_module_t *ecma_module_create (void);
|
||||
void ecma_module_cleanup_context (void);
|
||||
|
||||
void ecma_module_release_module_nodes (ecma_module_node_t *module_node_p);
|
||||
void ecma_module_cleanup (ecma_module_t *head_p);
|
||||
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
|
||||
void ecma_module_release_module_names (ecma_module_names_t *module_name_p);
|
||||
void ecma_module_release_module (ecma_module_t *module_p);
|
||||
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
|
||||
#endif /* !ECMA_MODULE_H */
|
||||
|
||||
@@ -13,11 +13,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-property-hashmap.h"
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-property-hashmap.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -26,7 +28,7 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if ENABLED (JERRY_PROPRETY_HASHMAP)
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
|
||||
/**
|
||||
* Compute the total size of the property hashmap.
|
||||
@@ -42,28 +44,26 @@
|
||||
/**
|
||||
* Stepping values for searching items in the hashmap.
|
||||
*/
|
||||
static const uint8_t ecma_property_hashmap_steps[ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS] JERRY_ATTR_CONST_DATA =
|
||||
{
|
||||
static const uint8_t ecma_property_hashmap_steps[ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS] JERRY_ATTR_CONST_DATA = {
|
||||
3, 5, 7, 11, 13, 17, 19, 23
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the value of a bit in a bitmap.
|
||||
*/
|
||||
#define ECMA_PROPERTY_HASHMAP_GET_BIT(byte_p, index) \
|
||||
((byte_p)[(index) >> 3] & (1 << ((index) & 0x7)))
|
||||
#define ECMA_PROPERTY_HASHMAP_GET_BIT(byte_p, index) ((byte_p)[(index) >> 3] & (1 << ((index) &0x7)))
|
||||
|
||||
/**
|
||||
* Clear the value of a bit in a bitmap.
|
||||
*/
|
||||
#define ECMA_PROPERTY_HASHMAP_CLEAR_BIT(byte_p, index) \
|
||||
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] & ~(1 << ((index) & 0x7))))
|
||||
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] & ~(1 << ((index) &0x7))))
|
||||
|
||||
/**
|
||||
* Set the value of a bit in a bitmap.
|
||||
*/
|
||||
#define ECMA_PROPERTY_HASHMAP_SET_BIT(byte_p, index) \
|
||||
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] | (1 << ((index) & 0x7))))
|
||||
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] | (1 << ((index) &0x7))))
|
||||
|
||||
/**
|
||||
* Create a new property hashmap for the object.
|
||||
@@ -156,8 +156,7 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */
|
||||
|
||||
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],
|
||||
property_pair_p->names_cp[i]);
|
||||
uint32_t entry_index = ecma_string_get_property_name_hash (prop_iter_p->types[i], property_pair_p->names_cp[i]);
|
||||
uint32_t step = ecma_property_hashmap_steps[entry_index & (ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS - 1)];
|
||||
|
||||
entry_index &= mask;
|
||||
@@ -202,8 +201,8 @@ ecma_property_hashmap_free (ecma_object_t *object_p) /**< object */
|
||||
/* Property hash must be exists and must be the first property. */
|
||||
JERRY_ASSERT (object_p->u1.property_list_cp != JMEM_CP_NULL);
|
||||
|
||||
ecma_property_header_t *property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
object_p->u1.property_list_cp);
|
||||
ecma_property_header_t *property_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, object_p->u1.property_list_cp);
|
||||
|
||||
JERRY_ASSERT (property_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
|
||||
@@ -211,8 +210,7 @@ ecma_property_hashmap_free (ecma_object_t *object_p) /**< object */
|
||||
|
||||
object_p->u1.property_list_cp = property_p->next_property_cp;
|
||||
|
||||
jmem_heap_free_block (hashmap_p,
|
||||
ECMA_PROPERTY_HASHMAP_GET_TOTAL_SIZE (hashmap_p->max_property_count));
|
||||
jmem_heap_free_block (hashmap_p, ECMA_PROPERTY_HASHMAP_GET_TOTAL_SIZE (hashmap_p->max_property_count));
|
||||
} /* ecma_property_hashmap_free */
|
||||
|
||||
/**
|
||||
@@ -226,8 +224,8 @@ ecma_property_hashmap_insert (ecma_object_t *object_p, /**< object */
|
||||
{
|
||||
JERRY_ASSERT (property_pair_p != NULL);
|
||||
|
||||
ecma_property_hashmap_t *hashmap_p = ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t,
|
||||
object_p->u1.property_list_cp);
|
||||
ecma_property_hashmap_t *hashmap_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t, object_p->u1.property_list_cp);
|
||||
|
||||
JERRY_ASSERT (hashmap_p->header.types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
|
||||
@@ -300,8 +298,8 @@ ecma_property_hashmap_delete (ecma_object_t *object_p, /**< object */
|
||||
jmem_cpointer_t name_cp, /**< property name */
|
||||
ecma_property_t *property_p) /**< property */
|
||||
{
|
||||
ecma_property_hashmap_t *hashmap_p = ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t,
|
||||
object_p->u1.property_list_cp);
|
||||
ecma_property_hashmap_t *hashmap_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t, object_p->u1.property_list_cp);
|
||||
|
||||
JERRY_ASSERT (hashmap_p->header.types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
|
||||
@@ -337,8 +335,8 @@ ecma_property_hashmap_delete (ecma_object_t *object_p, /**< object */
|
||||
offset = 1;
|
||||
}
|
||||
|
||||
ecma_property_pair_t *property_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t,
|
||||
pair_list_p[entry_index]);
|
||||
ecma_property_pair_t *property_pair_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, pair_list_p[entry_index]);
|
||||
|
||||
if ((property_pair_p->header.types + offset) == property_p)
|
||||
{
|
||||
@@ -393,9 +391,7 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
|
||||
{
|
||||
if (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[i]))
|
||||
{
|
||||
if (ecma_string_compare_to_property_name (prop_iter_p->types[i],
|
||||
prop_pair_p->names_cp[i],
|
||||
name_p))
|
||||
if (ecma_string_compare_to_property_name (prop_iter_p->types[i], prop_pair_p->names_cp[i], name_p))
|
||||
{
|
||||
/* Property is found */
|
||||
property_found = true;
|
||||
@@ -437,8 +433,8 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
|
||||
offset = 1;
|
||||
}
|
||||
|
||||
ecma_property_pair_t *property_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t,
|
||||
pair_list_p[entry_index]);
|
||||
ecma_property_pair_t *property_pair_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, pair_list_p[entry_index]);
|
||||
|
||||
ecma_property_t *property_p = property_pair_p->header.types + offset;
|
||||
|
||||
@@ -486,8 +482,8 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
|
||||
offset = 1;
|
||||
}
|
||||
|
||||
ecma_property_pair_t *property_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t,
|
||||
pair_list_p[entry_index]);
|
||||
ecma_property_pair_t *property_pair_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, pair_list_p[entry_index]);
|
||||
|
||||
ecma_property_t *property_p = property_pair_p->header.types + offset;
|
||||
|
||||
@@ -528,7 +524,7 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
}
|
||||
} /* ecma_property_hashmap_find */
|
||||
#endif /* ENABLED (JERRY_PROPRETY_HASHMAP) */
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#ifndef ECMA_PROPERTY_HASHMAP_H
|
||||
#define ECMA_PROPERTY_HASHMAP_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
@@ -36,7 +38,7 @@ typedef struct
|
||||
ecma_property_header_t header; /**< header of the property */
|
||||
uint32_t max_property_count; /**< maximum property count (power of 2) */
|
||||
uint32_t null_count; /**< number of NULLs in the map */
|
||||
uint32_t unused_count; /**< number of unused entires in the map */
|
||||
uint32_t unused_count; /**< number of unused entries in the map */
|
||||
|
||||
/*
|
||||
* The hash is followed by max_property_count ecma_cpointer_t
|
||||
@@ -53,7 +55,7 @@ typedef struct
|
||||
*/
|
||||
} ecma_property_hashmap_t;
|
||||
|
||||
#if ENABLED (JERRY_PROPRETY_HASHMAP)
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
|
||||
/**
|
||||
* Simple ecma values
|
||||
@@ -67,14 +69,17 @@ typedef enum
|
||||
|
||||
void ecma_property_hashmap_create (ecma_object_t *object_p);
|
||||
void ecma_property_hashmap_free (ecma_object_t *object_p);
|
||||
void ecma_property_hashmap_insert (ecma_object_t *object_p, ecma_string_t *name_p,
|
||||
ecma_property_pair_t *property_pair_p, int property_index);
|
||||
ecma_property_hashmap_delete_status ecma_property_hashmap_delete (ecma_object_t *object_p, jmem_cpointer_t name_cp,
|
||||
ecma_property_t *property_p);
|
||||
void ecma_property_hashmap_insert (ecma_object_t *object_p,
|
||||
ecma_string_t *name_p,
|
||||
ecma_property_pair_t *property_pair_p,
|
||||
int property_index);
|
||||
ecma_property_hashmap_delete_status
|
||||
ecma_property_hashmap_delete (ecma_object_t *object_p, jmem_cpointer_t name_cp, ecma_property_t *property_p);
|
||||
|
||||
ecma_property_t *ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, ecma_string_t *name_p,
|
||||
ecma_property_t *ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p,
|
||||
ecma_string_t *name_p,
|
||||
jmem_cpointer_t *property_real_name_cp);
|
||||
#endif /* ENABLED (JERRY_PROPRETY_HASHMAP) */
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/* 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-alloc.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-string-object.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-aggregateerror-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID aggregate_error_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
@@ -0,0 +1,34 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* AggregateError.prototype built-in description
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.11.7.8 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_AGGREGATE_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v5, 15.11.7.9 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_AGGREGATE_ERROR_UL, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v5, 15.11.7.10 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_MESSAGE, LIT_MAGIC_STRING__EMPTY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
@@ -0,0 +1,109 @@
|
||||
/* 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-alloc.h"
|
||||
#include "ecma-array-object.h"
|
||||
#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-iterator-object.h"
|
||||
#include "ecma-objects.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-aggregateerror.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID aggregate_error
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup aggregateerror ECMA AggregateError object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handle calling [[Call]] of built-in AggregateError object
|
||||
*
|
||||
* @return ecma value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_aggregate_error_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 message_val = ECMA_VALUE_UNDEFINED;
|
||||
ecma_value_t error_val = ECMA_VALUE_UNDEFINED;
|
||||
|
||||
if (arguments_list_len > 0)
|
||||
{
|
||||
error_val = arguments_list_p[0];
|
||||
|
||||
if (arguments_list_len > 1)
|
||||
{
|
||||
message_val = arguments_list_p[1];
|
||||
}
|
||||
}
|
||||
|
||||
return ecma_new_aggregate_error (error_val, message_val);
|
||||
} /* ecma_builtin_aggregate_error_dispatch_call */
|
||||
|
||||
/**
|
||||
* Handle calling [[Construct]] of built-in AggregateError object
|
||||
*
|
||||
* @return ecma value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_aggregate_error_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p),
|
||||
ECMA_BUILTIN_ID_AGGREGATE_ERROR_PROTOTYPE);
|
||||
|
||||
if (proto_p == NULL)
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_value_t result = ecma_builtin_aggregate_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;
|
||||
} /* ecma_builtin_aggregate_error_dispatch_construct */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,35 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* AggregateError built-in description
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
/* Number properties:
|
||||
* (property name, number value, writable, enumerable, configurable) */
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 2, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.11.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_AGGREGATE_ERROR_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_AGGREGATE_ERROR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
@@ -13,19 +13,31 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-iterator-object.h"
|
||||
#include "ecma-typedarray-object.h"
|
||||
#include "ecma-arraybuffer-object.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_ARRAY_ITERATOR_PROTOTYPE_ROUTINE_START = 0,
|
||||
ECMA_ARRAY_ITERATOR_PROTOTYPE_OBJECT_NEXT,
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-array-iterator-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID array_iterator_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID array_iterator_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -56,20 +68,19 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
/* 1 - 2. */
|
||||
if (!ecma_is_value_object (this_val))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an object."));
|
||||
return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT);
|
||||
}
|
||||
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (this_val);
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
/* 3. */
|
||||
if (ecma_get_object_type (obj_p) != ECMA_OBJECT_TYPE_PSEUDO_ARRAY
|
||||
|| ext_obj_p->u.pseudo_array.type != ECMA_PSEUDO_ARRAY_ITERATOR)
|
||||
if (!ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_ARRAY_ITERATOR))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an iterator."));
|
||||
return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_ITERATOR);
|
||||
}
|
||||
|
||||
ecma_value_t iterated_value = ext_obj_p->u.pseudo_array.u2.iterated_value;
|
||||
ecma_value_t iterated_value = ext_obj_p->u.cls.u3.iterated_value;
|
||||
|
||||
/* 4 - 5 */
|
||||
if (ecma_is_value_empty (iterated_value))
|
||||
@@ -87,7 +98,7 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
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."));
|
||||
return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED);
|
||||
}
|
||||
|
||||
/* b. */
|
||||
@@ -103,7 +114,7 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
}
|
||||
}
|
||||
|
||||
ecma_length_t index = ext_obj_p->u.pseudo_array.u1.iterator_index;
|
||||
ecma_length_t index = ext_obj_p->u.cls.u2.iterator_index;
|
||||
|
||||
if (JERRY_UNLIKELY (index == ECMA_ITERATOR_INDEX_LIMIT))
|
||||
{
|
||||
@@ -117,10 +128,7 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
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_length_value (index),
|
||||
true);
|
||||
ecma_value_t put_result = ecma_op_object_put (obj_p, prop_name_p, ecma_make_length_value (index), true);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_true (put_result));
|
||||
|
||||
@@ -129,17 +137,17 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
else
|
||||
{
|
||||
/* 11. */
|
||||
ext_obj_p->u.pseudo_array.u1.iterator_index++;
|
||||
ext_obj_p->u.cls.u2.iterator_index++;
|
||||
}
|
||||
|
||||
if (index >= length)
|
||||
{
|
||||
ext_obj_p->u.pseudo_array.u2.iterated_value = ECMA_VALUE_EMPTY;
|
||||
ext_obj_p->u.cls.u3.iterated_value = ECMA_VALUE_EMPTY;
|
||||
return ecma_create_iter_result_object (ECMA_VALUE_UNDEFINED, ECMA_VALUE_TRUE);
|
||||
}
|
||||
|
||||
/* 7. */
|
||||
uint8_t iterator_kind = ext_obj_p->u.pseudo_array.extra_info;
|
||||
uint8_t iterator_kind = ext_obj_p->u.cls.u1.iterator_kind;
|
||||
|
||||
if (iterator_kind == ECMA_ITERATOR_KEYS)
|
||||
{
|
||||
@@ -170,8 +178,7 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
|
||||
/* 17.b */
|
||||
ecma_value_t entry_array_value;
|
||||
entry_array_value = ecma_create_array_from_iter_element (get_value,
|
||||
ecma_make_length_value (index));
|
||||
entry_array_value = ecma_create_array_from_iter_element (get_value, ecma_make_length_value (index));
|
||||
|
||||
result = ecma_create_iter_result_object (entry_array_value, ECMA_VALUE_FALSE);
|
||||
ecma_free_value (entry_array_value);
|
||||
@@ -182,10 +189,36 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
return result;
|
||||
} /* ecma_builtin_array_iterator_prototype_object_next */
|
||||
|
||||
/**
|
||||
* 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_iterator_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in 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_2 (arguments_list_p, arguments_number);
|
||||
|
||||
switch (builtin_routine_id)
|
||||
{
|
||||
case ECMA_ARRAY_ITERATOR_PROTOTYPE_OBJECT_NEXT:
|
||||
{
|
||||
return ecma_builtin_array_iterator_prototype_object_next (this_arg);
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
}
|
||||
}
|
||||
} /* ecma_builtin_array_iterator_prototype_dispatch_routine */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
@@ -19,16 +19,10 @@
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_ARRAY_ITERATOR_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ARRAY_ITERATOR_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_NEXT, ecma_builtin_array_iterator_prototype_object_next, 0, 0)
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
ROUTINE (LIT_MAGIC_STRING_NEXT, ECMA_ARRAY_ITERATOR_PROTOTYPE_OBJECT_NEXT, 0, 0)
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -16,13 +16,9 @@
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-array-prototype-unscopables.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID array_prototype_unscopables
|
||||
#define BUILTIN_UNDERSCORED_ID array_prototype_unscopables
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
@@ -19,48 +19,26 @@
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_AT, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_COPY_WITHIN,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_COPY_WITHIN, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_ENTRIES,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_ENTRIES, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FILL,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FILL, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FIND,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FIND, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FIND_INDEX,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
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_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_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_INCLUDES, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_KEYS,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_KEYS, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_VALUES,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_VALUES, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,37 +19,28 @@
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_ARRAY)
|
||||
#if JERRY_BUILTIN_ARRAY
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.4.4.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
#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_ESNEXT) */
|
||||
|
||||
/* Number properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.4.4 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
0,
|
||||
ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 0, ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
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)
|
||||
@@ -58,6 +49,7 @@ ROUTINE (LIT_MAGIC_STRING_REVERSE, ECMA_ARRAY_PROTOTYPE_REVERSE, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_SHIFT, ECMA_ARRAY_PROTOTYPE_SHIFT, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_SLICE, ECMA_ARRAY_PROTOTYPE_SLICE, 2, 2)
|
||||
ROUTINE (LIT_MAGIC_STRING_SORT, ECMA_ARRAY_PROTOTYPE_SORT, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_AT, ECMA_ARRAY_PROTOTYPE_AT, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_SPLICE, ECMA_ARRAY_PROTOTYPE_SPLICE, NON_FIXED, 2)
|
||||
ROUTINE (LIT_MAGIC_STRING_UNSHIFT, ECMA_ARRAY_PROTOTYPE_UNSHIFT, NON_FIXED, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_INDEX_OF_UL, ECMA_ARRAY_PROTOTYPE_INDEX_OF, 2, 1)
|
||||
@@ -71,7 +63,6 @@ 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_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)
|
||||
@@ -81,14 +72,14 @@ 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,
|
||||
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_MAGIC_STRING_VALUES, LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES,
|
||||
INTRINSIC_PROPERTY (LIT_GLOBAL_SYMBOL_ITERATOR,
|
||||
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_ESNEXT) */
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_ARRAY) */
|
||||
#endif /* JERRY_BUILTIN_ARRAY */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
@@ -24,11 +25,11 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-iterator-object.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-array-object.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_ARRAY)
|
||||
#if JERRY_BUILTIN_ARRAY
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
@@ -45,15 +46,13 @@ 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
|
||||
#define BUILTIN_UNDERSCORED_ID array
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -66,7 +65,6 @@ enum
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
/**
|
||||
* The Array object's 'from' routine
|
||||
*
|
||||
@@ -96,7 +94,7 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
/* 3.a */
|
||||
if (!ecma_op_is_callable (mapfn))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Callback function is not callable."));
|
||||
return ecma_raise_type_error (ECMA_ERR_CALLBACK_IS_NOT_CALLABLE);
|
||||
}
|
||||
|
||||
/* 3.b */
|
||||
@@ -135,7 +133,7 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
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"));
|
||||
return ecma_raise_type_error (ECMA_ERR_CANNOT_CONVERT_TO_OBJECT);
|
||||
}
|
||||
|
||||
/* 6.c */
|
||||
@@ -185,10 +183,8 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
{
|
||||
/* 6.g.iv.1 */
|
||||
ecma_value_t len_value = ecma_make_uint32_value (k);
|
||||
ecma_value_t set_status = ecma_op_object_put (array_obj_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
|
||||
len_value,
|
||||
true);
|
||||
ecma_value_t set_status =
|
||||
ecma_op_object_put (array_obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), len_value, true);
|
||||
ecma_free_value (len_value);
|
||||
|
||||
/* 6.g.iv.2 */
|
||||
@@ -239,7 +235,7 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
}
|
||||
|
||||
/* 6.g.ix */
|
||||
const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW;
|
||||
const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | JERRY_PROP_SHOULD_THROW;
|
||||
ecma_value_t set_status = ecma_builtin_helper_def_prop_by_index (array_obj_p, k, mapped_value, flags);
|
||||
|
||||
ecma_free_value (mapped_value);
|
||||
@@ -298,7 +294,7 @@ iterator_cleanup:
|
||||
|
||||
if (ecma_is_value_undefined (array) || ecma_is_value_null (array))
|
||||
{
|
||||
ecma_raise_type_error (ECMA_ERR_MSG ("Cannot convert undefined or null to object"));
|
||||
ecma_raise_type_error (ECMA_ERR_CANNOT_CONVERT_TO_OBJECT);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@@ -359,7 +355,7 @@ iterator_cleanup:
|
||||
}
|
||||
|
||||
/* 16.f */
|
||||
const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW;
|
||||
const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | JERRY_PROP_SHOULD_THROW;
|
||||
ecma_value_t set_status = ecma_builtin_helper_def_prop_by_index (array_obj_p, k, mapped_value, flags);
|
||||
|
||||
ecma_free_value (mapped_value);
|
||||
@@ -376,10 +372,8 @@ iterator_cleanup:
|
||||
|
||||
/* 17. */
|
||||
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,
|
||||
true);
|
||||
ecma_value_t set_status =
|
||||
ecma_op_object_put (array_obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), len_value, true);
|
||||
ecma_free_value (len_value);
|
||||
|
||||
/* 18. */
|
||||
@@ -420,10 +414,8 @@ ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
|
||||
|
||||
ecma_value_t len = ecma_make_uint32_value (arguments_list_len);
|
||||
|
||||
ecma_value_t ret_val = ecma_op_function_construct (ecma_get_object_from_value (this_arg),
|
||||
ecma_get_object_from_value (this_arg),
|
||||
&len,
|
||||
1);
|
||||
ecma_value_t ret_val =
|
||||
ecma_op_function_construct (ecma_get_object_from_value (this_arg), ecma_get_object_from_value (this_arg), &len, 1);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (ret_val))
|
||||
{
|
||||
@@ -433,14 +425,12 @@ ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
|
||||
|
||||
uint32_t k = 0;
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (ret_val);
|
||||
const uint32_t prop_status_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW;
|
||||
const uint32_t prop_status_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | JERRY_PROP_SHOULD_THROW;
|
||||
|
||||
while (k < arguments_list_len)
|
||||
{
|
||||
ecma_value_t define_status = ecma_builtin_helper_def_prop_by_index (obj_p,
|
||||
k,
|
||||
arguments_list_p[k],
|
||||
prop_status_flags);
|
||||
ecma_value_t define_status =
|
||||
ecma_builtin_helper_def_prop_by_index (obj_p, k, arguments_list_p[k], prop_status_flags);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (define_status))
|
||||
{
|
||||
@@ -452,10 +442,7 @@ ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
|
||||
k++;
|
||||
}
|
||||
|
||||
ret_val = ecma_op_object_put (obj_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
|
||||
len,
|
||||
true);
|
||||
ret_val = ecma_op_object_put (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), len, true);
|
||||
|
||||
ecma_free_value (len);
|
||||
|
||||
@@ -468,8 +455,6 @@ ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
|
||||
return ecma_make_object_value (obj_p);
|
||||
} /* ecma_builtin_array_object_of */
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Handle calling [[Call]] of built-in Array object
|
||||
*
|
||||
@@ -482,8 +467,7 @@ ecma_builtin_array_dispatch_call (const ecma_value_t *arguments_list_p, /**< arg
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
if (arguments_list_len != 1
|
||||
|| !ecma_is_value_number (arguments_list_p[0]))
|
||||
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);
|
||||
}
|
||||
@@ -493,7 +477,7 @@ ecma_builtin_array_dispatch_call (const ecma_value_t *arguments_list_p, /**< arg
|
||||
|
||||
if (num != ((ecma_number_t) num_uint32))
|
||||
{
|
||||
return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid array length."));
|
||||
return ecma_raise_range_error (ECMA_ERR_INVALID_ARRAY_LENGTH);
|
||||
}
|
||||
|
||||
return ecma_make_object_value (ecma_op_new_array_object (num_uint32));
|
||||
@@ -511,11 +495,8 @@ ecma_builtin_array_dispatch_construct (const ecma_value_t *arguments_list_p, /**
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
#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);
|
||||
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)
|
||||
{
|
||||
@@ -534,7 +515,6 @@ ecma_builtin_array_dispatch_construct (const ecma_value_t *arguments_list_p, /**
|
||||
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_array_dispatch_construct */
|
||||
|
||||
/**
|
||||
@@ -550,15 +530,16 @@ ecma_builtin_array_dispatch_routine (uint8_t builtin_routine_id, /**< built-in w
|
||||
* passed to routine */
|
||||
uint32_t arguments_number) /**< length of arguments' list */
|
||||
{
|
||||
JERRY_UNUSED (arguments_number);
|
||||
|
||||
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;
|
||||
return ecma_is_value_array (arguments_list_p[0]);
|
||||
}
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
case ECMA_ARRAY_ROUTINE_FROM:
|
||||
{
|
||||
return ecma_builtin_array_object_from (this_arg, arguments_list_p, arguments_number);
|
||||
@@ -571,7 +552,6 @@ ecma_builtin_array_dispatch_routine (uint8_t builtin_routine_id, /**< built-in w
|
||||
{
|
||||
return ecma_copy_value (this_arg);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
@@ -585,4 +565,4 @@ ecma_builtin_array_dispatch_routine (uint8_t builtin_routine_id, /**< built-in w
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_ARRAY) */
|
||||
#endif /* JERRY_BUILTIN_ARRAY */
|
||||
|
||||
@@ -19,42 +19,29 @@
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_ARRAY)
|
||||
#if JERRY_BUILTIN_ARRAY
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.4.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_ARRAY_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ARRAY_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* Number properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ARRAY_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ARRAY_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_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_ARRAY_ROUTINE_SPECIES_GET,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES, ECMA_ARRAY_ROUTINE_SPECIES_GET, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#endif /* !(ENABLED (JERRY_BUILTIN_ARRAY)) */
|
||||
#endif /* !(JERRY_BUILTIN_ARRAY) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-conversion.h"
|
||||
@@ -22,17 +23,17 @@
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
#include "jrt.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_TYPEDARRAY)
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-arraybuffer-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID arraybuffer_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID arraybuffer_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -61,11 +62,11 @@ ecma_builtin_arraybuffer_prototype_bytelength_getter (ecma_value_t this_arg) /**
|
||||
{
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
if (ecma_object_class_is (object_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL))
|
||||
if (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER))
|
||||
{
|
||||
if (ecma_arraybuffer_is_detached (object_p))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has been detached."));
|
||||
return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED);
|
||||
}
|
||||
uint32_t len = ecma_arraybuffer_get_length (object_p);
|
||||
|
||||
@@ -73,7 +74,7 @@ ecma_builtin_arraybuffer_prototype_bytelength_getter (ecma_value_t this_arg) /**
|
||||
}
|
||||
}
|
||||
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a ArrayBuffer object."));
|
||||
return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_ARRAY_BUFFER_OBJECT);
|
||||
} /* ecma_builtin_arraybuffer_prototype_bytelength_getter */
|
||||
|
||||
/**
|
||||
@@ -92,139 +93,18 @@ ecma_builtin_arraybuffer_prototype_object_slice (ecma_value_t this_arg, /**< thi
|
||||
{
|
||||
if (!ecma_is_value_object (this_arg))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not object."));
|
||||
return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT);
|
||||
}
|
||||
|
||||
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))
|
||||
if (!ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an ArrayBuffer object."));
|
||||
return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_ARRAY_BUFFER_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."));
|
||||
}
|
||||
|
||||
/* 5. */
|
||||
uint32_t len = ecma_arraybuffer_get_length (object_p);
|
||||
|
||||
uint32_t start = 0;
|
||||
uint32_t end = len;
|
||||
|
||||
if (arguments_number > 0)
|
||||
{
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 ctor;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
|
||||
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;
|
||||
return ecma_builtin_arraybuffer_slice (this_arg, argument_list_p, arguments_number);
|
||||
} /* ecma_builtin_arraybuffer_prototype_object_slice */
|
||||
|
||||
/**
|
||||
@@ -233,4 +113,4 @@ free_new_arraybuffer:
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_TYPEDARRAY) */
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
|
||||
@@ -19,14 +19,12 @@
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_TYPEDARRAY)
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_ARRAYBUFFER,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ARRAYBUFFER, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* Readonly accessor properties */
|
||||
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
|
||||
@@ -34,14 +32,12 @@ ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* 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)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ARRAY_BUFFER_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_SLICE, ecma_builtin_arraybuffer_prototype_object_slice, NON_FIXED, 2)
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_TYPEDARRAY) */
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -13,23 +13,24 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-dataview-object.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
#include "ecma-dataview-object.h"
|
||||
#include "ecma-typedarray-object.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_TYPEDARRAY)
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-arraybuffer.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID arraybuffer
|
||||
#define BUILTIN_UNDERSCORED_ID arraybuffer
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -75,7 +76,7 @@ ecma_builtin_arraybuffer_dispatch_call (const ecma_value_t *arguments_list_p, /*
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor ArrayBuffer requires 'new'"));
|
||||
return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_ARRAYBUFFER_REQUIRES_NEW);
|
||||
} /* ecma_builtin_arraybuffer_dispatch_call */
|
||||
|
||||
/**
|
||||
@@ -110,4 +111,4 @@ ecma_builtin_arraybuffer_species_get (ecma_value_t this_value) /**< This Value *
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_TYPEDARRAY) */
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
|
||||
@@ -19,25 +19,19 @@
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_TYPEDARRAY)
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
|
||||
/* Number properties:
|
||||
* (property name, number value, writable, enumerable, configurable) */
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ARRAY_BUFFER_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ARRAY_BUFFER_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
@@ -46,10 +40,8 @@ STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
ROUTINE (LIT_MAGIC_STRING_IS_VIEW_UL, ecma_builtin_arraybuffer_object_is_view, 1, 1)
|
||||
|
||||
/* ES2015 24.1.3.3 */
|
||||
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES,
|
||||
ecma_builtin_arraybuffer_species_get,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES, ecma_builtin_arraybuffer_species_get, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_TYPEDARRAY) */
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -0,0 +1,355 @@
|
||||
/* 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 "jerryscript-types.h"
|
||||
|
||||
#include "ecma-builtin-handlers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-iterator-object.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-promise-object.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt.h"
|
||||
#include "lit-magic-strings.h"
|
||||
#include "lit-strings.h"
|
||||
#include "opcodes.h"
|
||||
#include "vm-defines.h"
|
||||
|
||||
#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_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_START = 0, /**< buitlin routine start id */
|
||||
ECMA_ASYNC_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_NEXT, /**< 'next' routine v11, 25.1.4.2.1 */
|
||||
ECMA_ASYNC_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_RETURN, /**< 'return' routine v11, 25.1.4.2.2 */
|
||||
ECMA_ASYNC_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_THROW /**< 'throw' routine v11, 25.1.4.2.3 */
|
||||
} ecma_async_from_sync_iterator_operation_type_t;
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-from-sync-iterator-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_from_sync_iterator_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup asyncfromsynciteratorprototype ECMA %AsyncFromSyncIteratorPrototype% object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* AsyncFromSyncIteratorContinuation operation
|
||||
*
|
||||
* See also:
|
||||
* ECMAScript v11, 25.1.4.4
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_op_async_from_sync_iterator_prototype_continuation (ecma_value_t result, /**< routine's 'result' argument */
|
||||
ecma_object_t *capability_obj_p) /**< promise capability */
|
||||
{
|
||||
/* 1. */
|
||||
ecma_value_t done = ecma_op_iterator_complete (result);
|
||||
|
||||
/* 2. */
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_op_if_abrupt_reject_promise (&done, capability_obj_p)))
|
||||
{
|
||||
return done;
|
||||
}
|
||||
|
||||
uint16_t done_flag = ecma_is_value_false (done) ? 0 : (1 << ECMA_NATIVE_HANDLER_COMMON_FLAGS_SHIFT);
|
||||
ecma_free_value (done);
|
||||
|
||||
/* 3. */
|
||||
ecma_value_t value = ecma_op_iterator_value (result);
|
||||
|
||||
/* 4. */
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_op_if_abrupt_reject_promise (&value, capability_obj_p)))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
/* 5. */
|
||||
ecma_value_t builtin_promise = ecma_make_object_value (ecma_builtin_get (ECMA_BUILTIN_ID_PROMISE));
|
||||
ecma_value_t value_wrapper = ecma_promise_reject_or_resolve (builtin_promise, value, true);
|
||||
ecma_free_value (value);
|
||||
|
||||
/* 6. */
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_op_if_abrupt_reject_promise (&value_wrapper, capability_obj_p)))
|
||||
{
|
||||
return value_wrapper;
|
||||
}
|
||||
|
||||
/* 8 - 9. */
|
||||
ecma_object_t *on_fullfilled = ecma_op_create_native_handler (ECMA_NATIVE_HANDLER_ASYNC_FROM_SYNC_ITERATOR_UNWRAP,
|
||||
sizeof (ecma_extended_object_t));
|
||||
((ecma_extended_object_t *) on_fullfilled)->u.built_in.u2.routine_flags = (uint8_t) done_flag;
|
||||
|
||||
/* 10. */
|
||||
ecma_value_t then_result = ecma_promise_perform_then (value_wrapper,
|
||||
ecma_make_object_value (on_fullfilled),
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
capability_obj_p);
|
||||
|
||||
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (then_result));
|
||||
ecma_deref_object (on_fullfilled);
|
||||
ecma_free_value (value_wrapper);
|
||||
|
||||
/* 11. */
|
||||
return then_result;
|
||||
} /* ecma_op_async_from_sync_iterator_prototype_continuation */
|
||||
|
||||
/**
|
||||
* The %AsyncFromSyncIteratorPrototype% object's 'next' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMAScript v11, 25.1.4.2.1
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_async_from_sync_iterator_prototype_next (ecma_async_from_sync_iterator_object_t *iter_p, /**< iterator
|
||||
* record*/
|
||||
ecma_object_t *capability_p, /**< promise capability */
|
||||
ecma_value_t value) /**< routine's 'value' argument */
|
||||
{
|
||||
/* 5. */
|
||||
ecma_value_t next_result =
|
||||
ecma_op_iterator_next (iter_p->header.u.cls.u3.sync_iterator, iter_p->sync_next_method, value);
|
||||
|
||||
/* 6. */
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_op_if_abrupt_reject_promise (&next_result, capability_p)))
|
||||
{
|
||||
return next_result;
|
||||
}
|
||||
|
||||
/* 7. */
|
||||
ecma_value_t result = ecma_op_async_from_sync_iterator_prototype_continuation (next_result, capability_p);
|
||||
ecma_free_value (next_result);
|
||||
|
||||
return result;
|
||||
} /* ecma_builtin_async_from_sync_iterator_prototype_next */
|
||||
|
||||
/**
|
||||
* The %AsyncFromSyncIteratorPrototype% object's 'return' and 'throw' routines
|
||||
*
|
||||
* See also:
|
||||
* ECMAScript v11, 25.1.4.2.2
|
||||
* ECMAScript v11, 25.1.4.2.3
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_async_from_sync_iterator_prototype_do (ecma_async_from_sync_iterator_object_t *iter_p, /**< iterator
|
||||
* record*/
|
||||
ecma_object_t *capability_obj_p, /**< promise capability */
|
||||
ecma_value_t value, /**< routine's 'value' argument */
|
||||
lit_magic_string_id_t method_id) /**< method id */
|
||||
{
|
||||
/* 5. */
|
||||
ecma_value_t sync_iterator = iter_p->header.u.cls.u3.sync_iterator;
|
||||
ecma_value_t method = ecma_op_get_method_by_magic_id (sync_iterator, method_id);
|
||||
|
||||
/* 6. */
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_op_if_abrupt_reject_promise (&method, capability_obj_p)))
|
||||
{
|
||||
return method;
|
||||
}
|
||||
|
||||
ecma_promise_capabality_t *capability_p = (ecma_promise_capabality_t *) capability_obj_p;
|
||||
|
||||
ecma_value_t call_arg;
|
||||
uint32_t arg_size;
|
||||
|
||||
if (ecma_is_value_empty (value))
|
||||
{
|
||||
arg_size = 0;
|
||||
call_arg = ECMA_VALUE_UNDEFINED;
|
||||
}
|
||||
else
|
||||
{
|
||||
arg_size = 1;
|
||||
call_arg = value;
|
||||
}
|
||||
|
||||
/* 7. */
|
||||
if (ecma_is_value_undefined (method))
|
||||
{
|
||||
ecma_value_t func_obj;
|
||||
|
||||
if (method_id == LIT_MAGIC_STRING_RETURN)
|
||||
{
|
||||
/* 7.a. */
|
||||
call_arg = ecma_create_iter_result_object (call_arg, ECMA_VALUE_TRUE);
|
||||
arg_size = 1;
|
||||
func_obj = capability_p->resolve;
|
||||
}
|
||||
else
|
||||
{
|
||||
func_obj = capability_p->reject;
|
||||
}
|
||||
|
||||
/* 7.b. */
|
||||
ecma_value_t resolve =
|
||||
ecma_op_function_call (ecma_get_object_from_value (func_obj), ECMA_VALUE_UNDEFINED, &call_arg, arg_size);
|
||||
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (resolve));
|
||||
ecma_free_value (resolve);
|
||||
|
||||
if (method_id == LIT_MAGIC_STRING_RETURN)
|
||||
{
|
||||
ecma_free_value (call_arg);
|
||||
}
|
||||
|
||||
/* 7.c. */
|
||||
return ecma_copy_value (capability_p->header.u.cls.u3.promise);
|
||||
}
|
||||
|
||||
/* 8. */
|
||||
ecma_value_t call_result = ecma_op_function_validated_call (method, sync_iterator, &call_arg, arg_size);
|
||||
ecma_free_value (method);
|
||||
|
||||
/* 9. */
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_op_if_abrupt_reject_promise (&call_result, capability_obj_p)))
|
||||
{
|
||||
return call_result;
|
||||
}
|
||||
|
||||
/* 10. */
|
||||
if (!ecma_is_value_object (call_result))
|
||||
{
|
||||
ecma_free_value (call_result);
|
||||
|
||||
#if JERRY_ERROR_MESSAGES
|
||||
const lit_utf8_byte_t *msg_p = (lit_utf8_byte_t *) ecma_get_error_msg (ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT);
|
||||
lit_utf8_size_t msg_size = ecma_get_error_size (ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT);
|
||||
ecma_string_t *error_msg_p = ecma_new_ecma_string_from_ascii (msg_p, msg_size);
|
||||
#else /* !JERRY_ERROR_MESSAGES */
|
||||
ecma_string_t *error_msg_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
|
||||
#endif /* JERRY_ERROR_MESSAGES */
|
||||
|
||||
ecma_object_t *type_error_obj_p = ecma_new_standard_error (JERRY_ERROR_TYPE, error_msg_p);
|
||||
|
||||
#if JERRY_ERROR_MESSAGES
|
||||
ecma_deref_ecma_string (error_msg_p);
|
||||
#endif /* JERRY_ERROR_MESSAGES */
|
||||
|
||||
ecma_value_t type_error = ecma_make_object_value (type_error_obj_p);
|
||||
|
||||
/* 10.a. */
|
||||
ecma_value_t reject =
|
||||
ecma_op_function_call (ecma_get_object_from_value (capability_p->reject), ECMA_VALUE_UNDEFINED, &type_error, 1);
|
||||
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (reject));
|
||||
ecma_deref_object (type_error_obj_p);
|
||||
ecma_free_value (reject);
|
||||
|
||||
/* 10.b. */
|
||||
return ecma_copy_value (capability_p->header.u.cls.u3.promise);
|
||||
}
|
||||
|
||||
ecma_value_t result = ecma_op_async_from_sync_iterator_prototype_continuation (call_result, capability_obj_p);
|
||||
ecma_free_value (call_result);
|
||||
|
||||
return result;
|
||||
} /* ecma_builtin_async_from_sync_iterator_prototype_do */
|
||||
|
||||
/**
|
||||
* Dispatcher of the %AsyncFromSyncIteratorPrototype% built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_async_from_sync_iterator_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_ASSERT (ecma_is_value_object (this_arg));
|
||||
|
||||
ecma_object_t *this_obj_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
JERRY_ASSERT (ecma_object_class_is (this_obj_p, ECMA_OBJECT_CLASS_ASYNC_FROM_SYNC_ITERATOR));
|
||||
|
||||
ecma_async_from_sync_iterator_object_t *iter_p = (ecma_async_from_sync_iterator_object_t *) this_obj_p;
|
||||
|
||||
ecma_value_t builtin_promise = ecma_make_object_value (ecma_builtin_get (ECMA_BUILTIN_ID_PROMISE));
|
||||
ecma_object_t *capability_p = ecma_promise_new_capability (builtin_promise, ECMA_VALUE_UNDEFINED);
|
||||
JERRY_ASSERT (capability_p != NULL);
|
||||
|
||||
ecma_value_t result;
|
||||
ecma_value_t arg = (arguments_number == 0 ? ECMA_VALUE_EMPTY : arguments_list_p[0]);
|
||||
|
||||
switch (builtin_routine_id)
|
||||
{
|
||||
case ECMA_ASYNC_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_NEXT:
|
||||
{
|
||||
result = ecma_builtin_async_from_sync_iterator_prototype_next (iter_p, capability_p, arg);
|
||||
break;
|
||||
}
|
||||
case ECMA_ASYNC_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_RETURN:
|
||||
{
|
||||
result = ecma_builtin_async_from_sync_iterator_prototype_do (iter_p, capability_p, arg, LIT_MAGIC_STRING_RETURN);
|
||||
break;
|
||||
}
|
||||
case ECMA_ASYNC_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_THROW:
|
||||
{
|
||||
result = ecma_builtin_async_from_sync_iterator_prototype_do (iter_p, capability_p, arg, LIT_MAGIC_STRING_THROW);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ecma_deref_object (capability_p);
|
||||
|
||||
return result;
|
||||
} /* ecma_builtin_async_from_sync_iterator_prototype_dispatch_routine */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
+10
-12
@@ -13,18 +13,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Allow project to override this partition scheme
|
||||
* The following variables are allowed to be defined:
|
||||
*
|
||||
* QUARK_START_PAGE the first page where the QUARK code is located
|
||||
* QUARK_NB_PAGE the number of pages reserved for the QUARK. The ARC gets the
|
||||
* remaining pages (out of 148).
|
||||
/*
|
||||
* %AsyncFromSyncIteratorPrototype% built-in description (AsyncFunction.prototype)
|
||||
*/
|
||||
#ifndef PROJECT_MAPPING_H
|
||||
#define PROJECT_MAPPING_H
|
||||
|
||||
#define QUARK_NB_PAGE 125
|
||||
#include "machine/soc/intel/quark_se/quark_se_mapping.h"
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#endif /* !PROJECT_MAPPING_H */
|
||||
/* 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_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_NEXT, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_RETURN, ECMA_ASYNC_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_RETURN, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_THROW, ECMA_ASYNC_FROM_SYNC_ITERATOR_PROTOTYPE_ROUTINE_THROW, 1, 1)
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
@@ -15,13 +15,11 @@
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-function-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_function_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID async_function_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -39,5 +37,3 @@
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
@@ -19,18 +19,10 @@
|
||||
|
||||
#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)
|
||||
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) */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ASYNC_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -15,14 +15,12 @@
|
||||
|
||||
#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
|
||||
#define BUILTIN_UNDERSCORED_ID async_function
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -47,9 +45,7 @@ ecma_builtin_async_function_dispatch_call (const ecma_value_t *arguments_list_p,
|
||||
{
|
||||
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);
|
||||
return ecma_op_create_dynamic_function (arguments_list_p, arguments_list_len, ECMA_PARSE_ASYNC_FUNCTION);
|
||||
} /* ecma_builtin_async_function_dispatch_call */
|
||||
|
||||
/**
|
||||
@@ -70,5 +66,3 @@ ecma_builtin_async_function_dispatch_construct (const ecma_value_t *arguments_li
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
@@ -19,23 +19,16 @@
|
||||
|
||||
#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)
|
||||
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)
|
||||
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)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ASYNC_FUNCTION_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
/* 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)
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -15,14 +15,12 @@
|
||||
|
||||
#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
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator_function
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -31,7 +29,7 @@
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup asyncgenerator ECMA AsyncGeneratorFunction object built-in
|
||||
* \addtogroup asyncgeneratorfunction ECMA AsyncGeneratorFunction object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
@@ -70,5 +68,3 @@ ecma_builtin_async_generator_function_dispatch_construct (const ecma_value_t *ar
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
@@ -19,23 +19,13 @@
|
||||
|
||||
#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)
|
||||
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)
|
||||
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) */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ASYNC_GENERATOR, ECMA_PROPERTY_FIXED)
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -21,18 +21,17 @@
|
||||
#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.
|
||||
*/
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_CUSTOM_DISPATCH
|
||||
|
||||
/**
|
||||
@@ -47,7 +46,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-generator-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -56,34 +55,34 @@ enum
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup asyncgenerator ECMA AsyncGenerator.prototype object built-in
|
||||
* \addtogroup asyncgeneratorprototype ECMA AsyncGenerator.prototype object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Convert routine type to operation type..
|
||||
* 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))
|
||||
((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,
|
||||
== 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,
|
||||
== 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,
|
||||
== 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.
|
||||
*/
|
||||
* 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 */
|
||||
@@ -102,23 +101,29 @@ ecma_builtin_async_generator_prototype_dispatch_routine (uint8_t builtin_routine
|
||||
{
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
if (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_CLASS)
|
||||
if (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_ASYNC_GENERATOR))
|
||||
{
|
||||
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;
|
||||
}
|
||||
executable_object_p = (vm_executable_object_t *) object_p;
|
||||
}
|
||||
}
|
||||
|
||||
if (executable_object_p == NULL)
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an async generator object."));
|
||||
const char *msg_p = ecma_get_error_msg (ECMA_ERR_ARGUMENT_THIS_NOT_ASYNC_GENERATOR);
|
||||
lit_utf8_size_t msg_size = ecma_get_error_size (ECMA_ERR_ARGUMENT_THIS_NOT_ASYNC_GENERATOR);
|
||||
ecma_string_t *error_msg_p = ecma_new_ecma_string_from_ascii ((const lit_utf8_byte_t *) msg_p, msg_size);
|
||||
|
||||
ecma_object_t *type_error_obj_p = ecma_new_standard_error (JERRY_ERROR_TYPE, error_msg_p);
|
||||
ecma_deref_ecma_string (error_msg_p);
|
||||
|
||||
ecma_value_t promise = ecma_op_create_promise_object (ECMA_VALUE_EMPTY, ECMA_VALUE_UNDEFINED, NULL);
|
||||
ecma_reject_promise (promise, ecma_make_object_value (type_error_obj_p));
|
||||
ecma_deref_object (type_error_obj_p);
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
if (executable_object_p->extended_object.u.class_prop.extra_info & ECMA_EXECUTABLE_OBJECT_COMPLETED)
|
||||
if (executable_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_COMPLETED)
|
||||
{
|
||||
ecma_value_t promise = ecma_make_object_value (ecma_builtin_get (ECMA_BUILTIN_ID_PROMISE));
|
||||
|
||||
@@ -143,5 +148,3 @@ ecma_builtin_async_generator_prototype_dispatch_routine (uint8_t builtin_routine
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
@@ -19,20 +19,14 @@
|
||||
|
||||
#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)
|
||||
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)
|
||||
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) */
|
||||
@@ -40,6 +34,4 @@ ROUTINE (LIT_MAGIC_STRING_NEXT, ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_NEXT, 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"
|
||||
|
||||
@@ -15,13 +15,11 @@
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-generator.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -39,5 +37,3 @@
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
@@ -19,23 +19,15 @@
|
||||
|
||||
#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)
|
||||
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)
|
||||
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"
|
||||
|
||||
@@ -17,13 +17,25 @@
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-iterator-object.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_BUILTIN_ASYNC_ITERATOR_PROTOTYPE_ROUTINE_START = 0,
|
||||
ECMA_BUILTIN_ASYNC_ITERATOR_PROTOTYPE_OBJECT_ASYNC_ITERATOR,
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-iterator-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_iterator_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID async_iterator_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -54,10 +66,38 @@ ecma_builtin_async_iterator_prototype_object_async_iterator (ecma_value_t this_v
|
||||
return ecma_copy_value (this_val);
|
||||
} /* ecma_builtin_async_iterator_prototype_object_async_iterator */
|
||||
|
||||
/**
|
||||
* Dispatcher of the built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_async_iterator_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_2 (arguments_list_p, arguments_number);
|
||||
|
||||
switch (builtin_routine_id)
|
||||
{
|
||||
case ECMA_BUILTIN_ASYNC_ITERATOR_PROTOTYPE_OBJECT_ASYNC_ITERATOR:
|
||||
{
|
||||
return ecma_builtin_async_iterator_prototype_object_async_iterator (this_arg);
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
}
|
||||
}
|
||||
} /* ecma_builtin_async_iterator_prototype_dispatch_routine */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
@@ -19,12 +19,8 @@
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/* 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)
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
ROUTINE (LIT_GLOBAL_SYMBOL_ASYNC_ITERATOR, ECMA_BUILTIN_ASYNC_ITERATOR_PROTOTYPE_OBJECT_ASYNC_ITERATOR, 0, 0)
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -0,0 +1,491 @@
|
||||
/* 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-arraybuffer-object.h"
|
||||
#include "ecma-atomics-object.h"
|
||||
#include "ecma-bigint.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-errors.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-shared-arraybuffer-object.h"
|
||||
#include "ecma-typedarray-object.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_BUILTIN_ATOMICS
|
||||
|
||||
#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_ATOMICS_ROUTINE_START = 0, /**< Special value, should be ignored */
|
||||
ECMA_ATOMICS_ROUTINE_ADD, /**< Atomics add routine */
|
||||
ECMA_ATOMICS_ROUTINE_AND, /**< Atomics and routine */
|
||||
ECMA_ATOMICS_ROUTINE_COMPAREEXCHANGE, /**< Atomics compare exchange routine */
|
||||
ECMA_ATOMICS_ROUTINE_EXCHANGE, /**< Atomics exchange routine */
|
||||
ECMA_ATOMICS_ROUTINE_ISLOCKFREE, /**< Atomics is lock free routine */
|
||||
ECMA_ATOMICS_ROUTINE_LOAD, /**< Atomics load routine */
|
||||
ECMA_ATOMICS_ROUTINE_OR, /**< Atomics or routine */
|
||||
ECMA_ATOMICS_ROUTINE_STORE, /**< Atomics store routine */
|
||||
ECMA_ATOMICS_ROUTINE_SUB, /**< Atomics sub routine */
|
||||
ECMA_ATOMICS_ROUTINE_WAIT, /**< Atomics wait routine */
|
||||
ECMA_ATOMICS_ROUTINE_NOTIFY, /**< Atomics notify routine */
|
||||
ECMA_ATOMICS_ROUTINE_XOR, /**< Atomics xor routine */
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-atomics.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID atomics
|
||||
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup atomics ECMA Atomics object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Convert ecma_number to the appropriate type according to the element type of typedarray.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_convert_number_to_typed_array_type (ecma_number_t num, /**< ecma_number argument */
|
||||
ecma_typedarray_type_t element_type) /**< element type of typedarray */
|
||||
{
|
||||
uint32_t value = ecma_typedarray_setter_number_to_uint32 (num);
|
||||
|
||||
switch (element_type)
|
||||
{
|
||||
case ECMA_INT8_ARRAY:
|
||||
{
|
||||
return ecma_make_number_value ((int8_t) value);
|
||||
}
|
||||
case ECMA_UINT8_ARRAY:
|
||||
{
|
||||
return ecma_make_number_value ((uint8_t) value);
|
||||
}
|
||||
case ECMA_INT16_ARRAY:
|
||||
{
|
||||
return ecma_make_number_value ((int16_t) value);
|
||||
}
|
||||
case ECMA_UINT16_ARRAY:
|
||||
{
|
||||
return ecma_make_number_value ((uint16_t) value);
|
||||
}
|
||||
case ECMA_INT32_ARRAY:
|
||||
{
|
||||
return ecma_make_number_value ((int32_t) value);
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_ASSERT (element_type == ECMA_UINT32_ARRAY);
|
||||
|
||||
return ecma_make_number_value (value);
|
||||
}
|
||||
}
|
||||
} /* ecma_convert_number_to_typed_array_type */
|
||||
|
||||
/**
|
||||
* The Atomics object's 'compareExchange' routine
|
||||
*
|
||||
* See also: ES12 25.4.4
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_atomics_compare_exchange (ecma_value_t typedarray, /**< typedArray argument */
|
||||
ecma_value_t index, /**< index argument */
|
||||
ecma_value_t expected_value, /**< expectedValue argument */
|
||||
ecma_value_t replacement_value) /**< replacementValue argument*/
|
||||
{
|
||||
ecma_value_t buffer = ecma_validate_integer_typedarray (typedarray, false);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (buffer))
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
|
||||
uint32_t idx = ecma_validate_atomic_access (typedarray, index);
|
||||
|
||||
if (idx == ECMA_STRING_NOT_ARRAY_INDEX)
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_object_t *typedarray_p = ecma_get_object_from_value (typedarray);
|
||||
ecma_typedarray_info_t target_info = ecma_typedarray_get_info (typedarray_p);
|
||||
|
||||
if (ECMA_ARRAYBUFFER_LAZY_ALLOC (target_info.array_buffer_p))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_typedarray_type_t element_type = target_info.id;
|
||||
ecma_value_t expected;
|
||||
ecma_value_t replacement;
|
||||
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
if (ECMA_TYPEDARRAY_IS_BIGINT_TYPE (element_type))
|
||||
{
|
||||
expected = ecma_bigint_to_bigint (expected_value, false);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (expected))
|
||||
{
|
||||
return expected;
|
||||
}
|
||||
|
||||
if (element_type == ECMA_BIGUINT64_ARRAY)
|
||||
{
|
||||
uint64_t num;
|
||||
bool sign;
|
||||
|
||||
ecma_bigint_get_digits_and_sign (expected, &num, 1, &sign);
|
||||
|
||||
if (sign)
|
||||
{
|
||||
num = (uint64_t) (-(int64_t) num);
|
||||
}
|
||||
|
||||
if (expected != ECMA_BIGINT_ZERO)
|
||||
{
|
||||
ecma_deref_bigint (ecma_get_extended_primitive_from_value (expected));
|
||||
}
|
||||
|
||||
expected = ecma_bigint_create_from_digits (&num, 1, false);
|
||||
}
|
||||
|
||||
replacement = ecma_bigint_to_bigint (replacement_value, false);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (replacement))
|
||||
{
|
||||
ecma_free_value (expected);
|
||||
return replacement;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
{
|
||||
ecma_number_t tmp_exp;
|
||||
ecma_number_t tmp_rep;
|
||||
|
||||
expected = ecma_op_to_integer (expected_value, &tmp_exp);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (expected))
|
||||
{
|
||||
return expected;
|
||||
}
|
||||
|
||||
expected = ecma_convert_number_to_typed_array_type (tmp_exp, element_type);
|
||||
|
||||
replacement = ecma_op_to_integer (replacement_value, &tmp_rep);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (replacement))
|
||||
{
|
||||
ecma_free_value (expected);
|
||||
return replacement;
|
||||
}
|
||||
|
||||
replacement = ecma_make_number_value (tmp_rep);
|
||||
}
|
||||
|
||||
uint8_t element_size = target_info.element_size;
|
||||
uint32_t offset = target_info.offset;
|
||||
uint32_t indexed_position = idx * element_size + offset;
|
||||
|
||||
if (ecma_arraybuffer_is_detached (ecma_get_object_from_value (buffer)))
|
||||
{
|
||||
ecma_free_value (expected);
|
||||
ecma_free_value (replacement);
|
||||
return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED);
|
||||
}
|
||||
|
||||
ecma_typedarray_getter_fn_t typedarray_getter_cb = ecma_get_typedarray_getter_fn (element_type);
|
||||
|
||||
ecma_object_t *buffer_obj_p = ecma_get_object_from_value (buffer);
|
||||
lit_utf8_byte_t *pos = ecma_arraybuffer_get_buffer (buffer_obj_p) + indexed_position;
|
||||
ecma_value_t stored_value = typedarray_getter_cb (pos);
|
||||
|
||||
// TODO: Handle shared array buffers differently.
|
||||
if (ecma_op_same_value (stored_value, expected))
|
||||
{
|
||||
ecma_typedarray_setter_fn_t typedarray_setter_cb = ecma_get_typedarray_setter_fn (element_type);
|
||||
typedarray_setter_cb (ecma_arraybuffer_get_buffer (buffer_obj_p) + indexed_position, replacement);
|
||||
}
|
||||
|
||||
ecma_free_value (expected);
|
||||
ecma_free_value (replacement);
|
||||
|
||||
return stored_value;
|
||||
} /* ecma_builtin_atomics_compare_exchange */
|
||||
|
||||
/**
|
||||
* The Atomics object's 'isLockFree' routine
|
||||
*
|
||||
* See also: ES11 24.4.6
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_atomics_is_lock_free (ecma_value_t size) /**< size argument */
|
||||
{
|
||||
JERRY_UNUSED (size);
|
||||
|
||||
return ECMA_VALUE_FALSE;
|
||||
} /* ecma_builtin_atomics_is_lock_free */
|
||||
|
||||
/**
|
||||
* The Atomics object's 'store' routine
|
||||
*
|
||||
* See also: ES11 24.4.9
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_atomics_store (ecma_value_t typedarray, /**< typedArray argument */
|
||||
ecma_value_t index, /**< index argument */
|
||||
ecma_value_t value) /**< value argument */
|
||||
{
|
||||
/* 1. */
|
||||
ecma_value_t buffer = ecma_validate_integer_typedarray (typedarray, false);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (buffer))
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/* 2. */
|
||||
uint32_t idx = ecma_validate_atomic_access (typedarray, index);
|
||||
|
||||
if (idx == ECMA_STRING_NOT_ARRAY_INDEX)
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_object_t *typedarray_p = ecma_get_object_from_value (typedarray);
|
||||
ecma_typedarray_info_t target_info = ecma_typedarray_get_info (typedarray_p);
|
||||
|
||||
if (ECMA_ARRAYBUFFER_LAZY_ALLOC (target_info.array_buffer_p))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_typedarray_type_t element_type = target_info.id;
|
||||
|
||||
ecma_typedarray_setter_fn_t typedarray_setter_cb = ecma_get_typedarray_setter_fn (element_type);
|
||||
|
||||
ecma_value_t value_to_store;
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
if (element_type == ECMA_BIGINT64_ARRAY || element_type == ECMA_BIGUINT64_ARRAY)
|
||||
{
|
||||
value_to_store = ecma_bigint_to_bigint (value, false);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (value_to_store))
|
||||
{
|
||||
return value_to_store;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
{
|
||||
ecma_number_t num_int;
|
||||
|
||||
value_to_store = ecma_op_to_integer (value, &num_int);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (value_to_store))
|
||||
{
|
||||
return value_to_store;
|
||||
}
|
||||
|
||||
if (ecma_number_is_zero (num_int) && ecma_number_is_negative (num_int))
|
||||
{
|
||||
num_int = (ecma_number_t) 0;
|
||||
}
|
||||
|
||||
value_to_store = ecma_make_number_value (num_int);
|
||||
}
|
||||
|
||||
ecma_object_t *buffer_obj_p = ecma_get_object_from_value (buffer);
|
||||
|
||||
if (ecma_arraybuffer_is_detached (buffer_obj_p))
|
||||
{
|
||||
ecma_free_value (value_to_store);
|
||||
return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED);
|
||||
}
|
||||
|
||||
uint8_t element_size = target_info.element_size;
|
||||
|
||||
uint32_t offset = target_info.offset;
|
||||
|
||||
uint32_t indexed_position = idx * element_size + offset;
|
||||
|
||||
// TODO: Handle shared array buffers differently.
|
||||
typedarray_setter_cb (ecma_arraybuffer_get_buffer (buffer_obj_p) + indexed_position, value_to_store);
|
||||
|
||||
return value_to_store;
|
||||
} /* ecma_builtin_atomics_store */
|
||||
|
||||
/**
|
||||
* The Atomics object's 'wait' routine
|
||||
*
|
||||
* See also: ES11 24.4.11
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_atomics_wait (ecma_value_t typedarray, /**< typedArray argument */
|
||||
ecma_value_t index, /**< index argument */
|
||||
ecma_value_t value, /**< value argument */
|
||||
ecma_value_t timeout) /**< timeout argument */
|
||||
{
|
||||
JERRY_UNUSED (typedarray);
|
||||
JERRY_UNUSED (index);
|
||||
JERRY_UNUSED (value);
|
||||
JERRY_UNUSED (timeout);
|
||||
|
||||
return ecma_make_uint32_value (0);
|
||||
} /* ecma_builtin_atomics_wait */
|
||||
|
||||
/**
|
||||
* The Atomics object's 'notify' routine
|
||||
*
|
||||
* See also: ES11 24.4.12
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_atomics_notify (ecma_value_t typedarray, /**< typedArray argument */
|
||||
ecma_value_t index, /**< index argument */
|
||||
ecma_value_t count) /**< count argument */
|
||||
{
|
||||
JERRY_UNUSED (typedarray);
|
||||
JERRY_UNUSED (index);
|
||||
JERRY_UNUSED (count);
|
||||
|
||||
return ecma_make_uint32_value (0);
|
||||
} /* ecma_builtin_atomics_notify */
|
||||
|
||||
/**
|
||||
* Dispatcher of the built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_atomics_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 (this_arg);
|
||||
ecma_value_t arg1 = arguments_list_p[0];
|
||||
ecma_value_t arg2 = arguments_list_p[1];
|
||||
ecma_value_t arg3 = arguments_list_p[2];
|
||||
ecma_value_t arg4 = (arguments_number > 3) ? arguments_list_p[3] : ECMA_VALUE_UNDEFINED;
|
||||
|
||||
ecma_atomics_op_t type;
|
||||
|
||||
switch (builtin_routine_id)
|
||||
{
|
||||
case ECMA_ATOMICS_ROUTINE_ADD:
|
||||
{
|
||||
type = ECMA_ATOMICS_ADD;
|
||||
break;
|
||||
}
|
||||
case ECMA_ATOMICS_ROUTINE_AND:
|
||||
{
|
||||
type = ECMA_ATOMICS_AND;
|
||||
break;
|
||||
}
|
||||
case ECMA_ATOMICS_ROUTINE_COMPAREEXCHANGE:
|
||||
{
|
||||
return ecma_builtin_atomics_compare_exchange (arg1, arg2, arg3, arg4);
|
||||
}
|
||||
case ECMA_ATOMICS_ROUTINE_EXCHANGE:
|
||||
{
|
||||
type = ECMA_ATOMICS_EXCHANGE;
|
||||
break;
|
||||
}
|
||||
case ECMA_ATOMICS_ROUTINE_ISLOCKFREE:
|
||||
{
|
||||
return ecma_builtin_atomics_is_lock_free (arg1);
|
||||
}
|
||||
case ECMA_ATOMICS_ROUTINE_LOAD:
|
||||
{
|
||||
return ecma_atomic_load (arg1, arg2);
|
||||
}
|
||||
case ECMA_ATOMICS_ROUTINE_OR:
|
||||
{
|
||||
type = ECMA_ATOMICS_OR;
|
||||
break;
|
||||
}
|
||||
case ECMA_ATOMICS_ROUTINE_STORE:
|
||||
{
|
||||
return ecma_builtin_atomics_store (arg1, arg2, arg3);
|
||||
}
|
||||
case ECMA_ATOMICS_ROUTINE_SUB:
|
||||
{
|
||||
type = ECMA_ATOMICS_SUBTRACT;
|
||||
break;
|
||||
}
|
||||
case ECMA_ATOMICS_ROUTINE_WAIT:
|
||||
{
|
||||
return ecma_builtin_atomics_wait (arg1, arg2, arg3, arg4);
|
||||
}
|
||||
case ECMA_ATOMICS_ROUTINE_NOTIFY:
|
||||
{
|
||||
return ecma_builtin_atomics_notify (arg1, arg2, arg3);
|
||||
}
|
||||
case ECMA_ATOMICS_ROUTINE_XOR:
|
||||
{
|
||||
type = ECMA_ATOMICS_XOR;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
}
|
||||
}
|
||||
return ecma_atomic_read_modify_write (arg1, arg2, arg3, type);
|
||||
} /* ecma_builtin_atomics_dispatch_routine */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* JERRY_BUILTIN_ATOMICS */
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Atomics built-in description
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if JERRY_BUILTIN_ATOMICS
|
||||
|
||||
/* ECMA-262 v11, 24.4.14 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ATOMICS_U, 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_ADD, ECMA_ATOMICS_ROUTINE_ADD, 3, 3)
|
||||
ROUTINE (LIT_MAGIC_STRING_ATOMICS_AND, ECMA_ATOMICS_ROUTINE_AND, 3, 3)
|
||||
ROUTINE (LIT_MAGIC_STRING_ATOMICS_COMPAREEXCHANGE, ECMA_ATOMICS_ROUTINE_COMPAREEXCHANGE, 4, 4)
|
||||
ROUTINE (LIT_MAGIC_STRING_ATOMICS_EXCHANGE, ECMA_ATOMICS_ROUTINE_EXCHANGE, 3, 3)
|
||||
ROUTINE (LIT_MAGIC_STRING_ATOMICS_ISLOCKFREE, ECMA_ATOMICS_ROUTINE_ISLOCKFREE, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_ATOMICS_LOAD, ECMA_ATOMICS_ROUTINE_LOAD, 2, 2)
|
||||
ROUTINE (LIT_MAGIC_STRING_ATOMICS_OR, ECMA_ATOMICS_ROUTINE_OR, 3, 3)
|
||||
ROUTINE (LIT_MAGIC_STRING_ATOMICS_STORE, ECMA_ATOMICS_ROUTINE_STORE, 3, 3)
|
||||
ROUTINE (LIT_MAGIC_STRING_ATOMICS_SUB, ECMA_ATOMICS_ROUTINE_SUB, 3, 3)
|
||||
ROUTINE (LIT_MAGIC_STRING_ATOMICS_WAIT, ECMA_ATOMICS_ROUTINE_WAIT, 4, 4)
|
||||
ROUTINE (LIT_MAGIC_STRING_ATOMICS_NOTIFY, ECMA_ATOMICS_ROUTINE_NOTIFY, 3, 3)
|
||||
ROUTINE (LIT_MAGIC_STRING_ATOMICS_XOR, ECMA_ATOMICS_ROUTINE_XOR, 3, 3)
|
||||
|
||||
#endif /* JERRY_BUILTIN_ATOMICS */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "ecma-bigint.h"
|
||||
#include "ecma-exceptions.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
@@ -24,8 +24,21 @@
|
||||
/**
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_CUSTOM_DISPATCH
|
||||
|
||||
/**
|
||||
* List of built-in routine identifiers.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
ECMA_BIGINT_PROTOTYPE_ROUTINE_START = 0,
|
||||
ECMA_BIGINT_PROTOTYPE_VALUE_OF,
|
||||
ECMA_BIGINT_PROTOTYPE_TO_STRING,
|
||||
ECMA_BIGINT_PROTOTYPE_TO_LOCALE_STRING,
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-bigint-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID bigint_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID bigint_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -59,17 +72,17 @@ ecma_builtin_bigint_prototype_object_value_of (ecma_value_t this_arg) /**< this
|
||||
{
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
if (ecma_object_class_is (object_p, LIT_MAGIC_STRING_BIGINT_UL))
|
||||
if (ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_BIGINT))
|
||||
{
|
||||
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));
|
||||
JERRY_ASSERT (ecma_is_value_bigint (ext_object_p->u.cls.u3.value));
|
||||
|
||||
return ecma_copy_value (ext_object_p->u.class_prop.u.value);
|
||||
return ecma_copy_value (ext_object_p->u.cls.u3.value);
|
||||
}
|
||||
}
|
||||
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("BigInt value expected."));
|
||||
return ecma_raise_type_error (ECMA_ERR_BIGINT_VALUE_EXCPECTED);
|
||||
} /* ecma_builtin_bigint_prototype_object_value_of */
|
||||
|
||||
/**
|
||||
@@ -86,13 +99,6 @@ ecma_builtin_bigint_prototype_object_to_string (ecma_value_t this_arg, /**< this
|
||||
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]))
|
||||
@@ -101,21 +107,18 @@ ecma_builtin_bigint_prototype_object_to_string (ecma_value_t this_arg, /**< this
|
||||
|
||||
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."));
|
||||
return ecma_raise_range_error (ECMA_ERR_RADIX_IS_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
radix = (uint32_t) arg_num;
|
||||
}
|
||||
|
||||
ecma_string_t *string_p = ecma_bigint_to_string (bigint, radix);
|
||||
ecma_free_value (bigint);
|
||||
ecma_string_t *string_p = ecma_bigint_to_string (this_arg, radix);
|
||||
|
||||
if (string_p == NULL)
|
||||
{
|
||||
@@ -125,10 +128,59 @@ ecma_builtin_bigint_prototype_object_to_string (ecma_value_t this_arg, /**< this
|
||||
return ecma_make_string_value (string_p);
|
||||
} /* ecma_builtin_bigint_prototype_object_to_string */
|
||||
|
||||
/**
|
||||
* Dispatcher of the built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_bigint_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 */
|
||||
{
|
||||
ecma_value_t this_value = ecma_builtin_bigint_prototype_object_value_of (this_arg);
|
||||
ecma_value_t ret_val;
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (this_value))
|
||||
{
|
||||
return this_value;
|
||||
}
|
||||
|
||||
switch (builtin_routine_id)
|
||||
{
|
||||
case ECMA_BIGINT_PROTOTYPE_VALUE_OF:
|
||||
{
|
||||
ret_val = this_value;
|
||||
break;
|
||||
}
|
||||
case ECMA_BIGINT_PROTOTYPE_TO_STRING:
|
||||
{
|
||||
ret_val = ecma_builtin_bigint_prototype_object_to_string (this_value, arguments_list_p, arguments_number);
|
||||
ecma_free_value (this_value);
|
||||
break;
|
||||
}
|
||||
case ECMA_BIGINT_PROTOTYPE_TO_LOCALE_STRING:
|
||||
{
|
||||
ret_val = ecma_builtin_bigint_prototype_object_to_string (this_value, 0, 0);
|
||||
ecma_free_value (this_value);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
}
|
||||
}
|
||||
return ret_val;
|
||||
} /* ecma_builtin_bigint_prototype_dispatch_routine */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
|
||||
@@ -19,26 +19,23 @@
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
#if 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)
|
||||
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)
|
||||
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)
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_STRING_UL, ECMA_BIGINT_PROTOTYPE_TO_STRING, NON_FIXED, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_VALUE_OF_UL, ECMA_BIGINT_PROTOTYPE_VALUE_OF, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_LOCALE_STRING_UL, ECMA_BIGINT_PROTOTYPE_TO_LOCALE_STRING, 0, 0)
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -13,17 +13,33 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-big-uint.h"
|
||||
#include "ecma-bigint.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-exceptions.h"
|
||||
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
|
||||
#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_BUILTIN_BIGINT_START = 0, /**< Special value, should be ignored */
|
||||
ECMA_BUILTIN_BIGINT_AS_INT_N, /**< The 'asIntN' routine of the BigInt object */
|
||||
ECMA_BUILTIN_BIGINT_AS_U_INT_N, /**< The 'asUintN' routine of the BigInt object */
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-bigint.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID bigint
|
||||
#define BUILTIN_UNDERSCORED_ID bigint
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -36,6 +52,286 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The BigInt object's 'asIntN' and 'asUintN' routines
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v15, 21.2.2
|
||||
*
|
||||
* @return ecma value
|
||||
* Truncated BigInt value for the given number of LSBs
|
||||
* as an integer or unsigned integer.
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_bigint_object_as_int_n (ecma_value_t bits, /**< number of bits */
|
||||
ecma_value_t bigint, /**< bigint number */
|
||||
bool is_signed) /**< The operation is signed */
|
||||
{
|
||||
ecma_number_t input_bits;
|
||||
ecma_value_t bit_value = ecma_op_to_index (bits, &input_bits);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (bit_value))
|
||||
{
|
||||
return bit_value;
|
||||
}
|
||||
|
||||
ecma_value_t bigint_value = ecma_bigint_to_bigint (bigint, false);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (bigint_value))
|
||||
{
|
||||
return bigint_value;
|
||||
}
|
||||
|
||||
if (input_bits == 0 || bigint_value == ECMA_BIGINT_ZERO)
|
||||
{
|
||||
ecma_free_value (bigint_value);
|
||||
return ECMA_BIGINT_ZERO;
|
||||
}
|
||||
|
||||
ecma_extended_primitive_t *input_bigint_p = ecma_get_extended_primitive_from_value (bigint_value);
|
||||
uint32_t bigint_size = ECMA_BIGINT_GET_SIZE (input_bigint_p);
|
||||
|
||||
if (input_bits >= UINT32_MAX)
|
||||
{
|
||||
return bigint_value;
|
||||
}
|
||||
|
||||
uint8_t input_bigint_sign = input_bigint_p->u.bigint_sign_and_size & ECMA_BIGINT_SIGN;
|
||||
const uint32_t size_of_divisor_in_bits = sizeof (uint32_t) * JERRY_BITSINBYTE;
|
||||
uint32_t whole_part = (uint32_t) input_bits / size_of_divisor_in_bits;
|
||||
uint32_t remainder = (uint32_t) input_bits % size_of_divisor_in_bits;
|
||||
uint32_t input_bit_length =
|
||||
(whole_part == 0 || remainder == 0) ? (uint32_t) input_bits : (whole_part + 1) * size_of_divisor_in_bits;
|
||||
|
||||
uint32_t input_byte_size = (uint32_t) input_bits / JERRY_BITSINBYTE;
|
||||
|
||||
if ((uint32_t) input_bits % JERRY_BITSINBYTE != 0)
|
||||
{
|
||||
input_byte_size += 1;
|
||||
}
|
||||
|
||||
const uint32_t input_bits_in_byte = (uint32_t) input_bit_length / JERRY_BITSINBYTE;
|
||||
uint32_t min_size = (input_bits_in_byte < bigint_size) ? input_bits_in_byte : bigint_size;
|
||||
|
||||
if (input_bigint_sign && (input_byte_size > bigint_size))
|
||||
{
|
||||
min_size = (input_bits_in_byte > bigint_size) ? input_bits_in_byte : bigint_size;
|
||||
}
|
||||
|
||||
if (min_size < sizeof (uint32_t))
|
||||
{
|
||||
min_size = sizeof (uint32_t);
|
||||
}
|
||||
|
||||
ecma_extended_primitive_t *result_p = ecma_bigint_create ((uint32_t) min_size);
|
||||
|
||||
if (JERRY_UNLIKELY (result_p == NULL))
|
||||
{
|
||||
ecma_deref_bigint (input_bigint_p);
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_bigint_digit_t *last_digit_p = ECMA_BIGINT_GET_DIGITS (input_bigint_p, bigint_size);
|
||||
|
||||
/* Calculate the leading zeros of the input_bigint */
|
||||
|
||||
ecma_bigint_digit_t zeros = ecma_big_uint_count_leading_zero (last_digit_p[-1]);
|
||||
uint32_t bits_of_bigint = (uint32_t) (bigint_size * JERRY_BITSINBYTE) - zeros;
|
||||
uint32_t exact_size =
|
||||
(input_bigint_sign || ((bits_of_bigint > (size_of_divisor_in_bits - 1)) && (input_byte_size < bigint_size)))
|
||||
? (uint32_t) input_byte_size
|
||||
: bigint_size;
|
||||
|
||||
if (input_bigint_sign)
|
||||
{
|
||||
bits_of_bigint += 1;
|
||||
}
|
||||
|
||||
if (bits_of_bigint > (input_bits - 1) || input_bigint_sign)
|
||||
{
|
||||
ecma_bigint_digit_t *digits_p = ECMA_BIGINT_GET_DIGITS (input_bigint_p, 0);
|
||||
ecma_bigint_digit_t *digits_end_p = ECMA_BIGINT_GET_DIGITS (input_bigint_p, exact_size);
|
||||
ecma_bigint_digit_t *result_number_p = ECMA_BIGINT_GET_DIGITS (result_p, 0);
|
||||
int32_t first_cell = 0;
|
||||
uint32_t surplus_bits =
|
||||
(whole_part > 0) ? (uint32_t) (whole_part * size_of_divisor_in_bits) : (uint32_t) size_of_divisor_in_bits;
|
||||
uint32_t mask_bit = (whole_part == 0) ? (uint32_t) input_bits : (uint32_t) input_bits - surplus_bits;
|
||||
|
||||
if (mask_bit == 0)
|
||||
{
|
||||
mask_bit = size_of_divisor_in_bits - 1;
|
||||
}
|
||||
|
||||
uint32_t check_sign_mask = (uint32_t) 1 << (mask_bit - 1);
|
||||
uint32_t mask = ((uint32_t) 1 << mask_bit) - 1;
|
||||
uint32_t last_cell = (exact_size >= sizeof (uint32_t)) ? (uint32_t) (min_size / sizeof (uint32_t)) - 1 : 0;
|
||||
bool is_positive = false;
|
||||
bool is_representation_positive = false;
|
||||
|
||||
if (is_signed)
|
||||
{
|
||||
if (input_bigint_sign && ((~digits_p[last_cell] + 1) & check_sign_mask) == 0)
|
||||
{
|
||||
is_positive = true;
|
||||
}
|
||||
|
||||
if ((digits_p[last_cell] & check_sign_mask) == 0)
|
||||
{
|
||||
is_representation_positive = true;
|
||||
}
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
*result_number_p++ =
|
||||
(is_representation_positive || (!is_signed && !input_bigint_sign)) ? *digits_p++ : ~(*digits_p++);
|
||||
first_cell--;
|
||||
} while (digits_p < digits_end_p);
|
||||
|
||||
int16_t equal_bits = 0;
|
||||
|
||||
if (remainder != 0)
|
||||
{
|
||||
equal_bits = -1;
|
||||
}
|
||||
|
||||
int32_t last_cell_negative = (last_cell != 0) ? ((int32_t) last_cell * (-1)) : -1;
|
||||
bool is_zero_values = false;
|
||||
|
||||
if (!is_signed)
|
||||
{
|
||||
if (input_bigint_sign)
|
||||
{
|
||||
is_zero_values = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((digits_p[-1] & check_sign_mask) > 0) || (result_number_p[-1] & check_sign_mask) > 0)
|
||||
{
|
||||
is_zero_values = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_zero_values)
|
||||
{
|
||||
result_number_p[first_cell] += 1;
|
||||
|
||||
if (result_number_p[first_cell] == 0)
|
||||
{
|
||||
do
|
||||
{
|
||||
result_number_p[++first_cell] += 1;
|
||||
} while (first_cell != equal_bits);
|
||||
|
||||
first_cell = last_cell_negative;
|
||||
}
|
||||
}
|
||||
|
||||
result_number_p[-1] &= mask;
|
||||
uint32_t surplus = (uint32_t) (min_size - exact_size) / sizeof (ecma_char_t);
|
||||
uint32_t new_size = result_p->u.bigint_sign_and_size;
|
||||
|
||||
if ((min_size - exact_size) % (sizeof (ecma_char_t)) > 0 && surplus == 0)
|
||||
{
|
||||
surplus += (uint32_t) sizeof (ecma_char_t);
|
||||
}
|
||||
else
|
||||
{
|
||||
surplus = (uint32_t) (surplus * sizeof (ecma_char_t));
|
||||
}
|
||||
|
||||
if (min_size / JERRY_BITSINBYTE < 1)
|
||||
{
|
||||
surplus = 0;
|
||||
}
|
||||
|
||||
if (is_signed)
|
||||
{
|
||||
if (result_p->u.bigint_sign_and_size > exact_size && min_size > sizeof (uint32_t)
|
||||
&& result_number_p[last_cell_negative] < 1)
|
||||
{
|
||||
new_size -= surplus;
|
||||
}
|
||||
|
||||
new_size += 1;
|
||||
|
||||
if (is_positive || ((digits_p[-1] & check_sign_mask) == 0 && !input_bigint_sign))
|
||||
{
|
||||
new_size -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
while (first_cell != 0 && result_number_p[first_cell] == 0)
|
||||
{
|
||||
first_cell++;
|
||||
}
|
||||
|
||||
if (first_cell == 0)
|
||||
{
|
||||
ecma_deref_bigint (result_p);
|
||||
ecma_deref_bigint (input_bigint_p);
|
||||
|
||||
return ECMA_BIGINT_ZERO;
|
||||
}
|
||||
|
||||
last_cell_negative = first_cell + (int32_t) last_cell;
|
||||
int16_t zero_section_cnt = 0;
|
||||
|
||||
while (last_cell_negative > first_cell)
|
||||
{
|
||||
if (result_number_p[last_cell_negative] == 0)
|
||||
{
|
||||
zero_section_cnt++;
|
||||
}
|
||||
|
||||
last_cell_negative--;
|
||||
}
|
||||
|
||||
uint32_t size_limit = sizeof (uint32_t);
|
||||
|
||||
if (zero_section_cnt >= 1)
|
||||
{
|
||||
size_limit = new_size - (uint32_t) zero_section_cnt * size_limit;
|
||||
new_size = (size_limit < sizeof (uint32_t)) ? (uint32_t) (JERRY_BITSINBYTE - size_limit) : size_limit;
|
||||
}
|
||||
|
||||
if (new_size < result_p->u.bigint_sign_and_size)
|
||||
{
|
||||
result_p->refs_and_type = ECMA_EXTENDED_PRIMITIVE_REF_ONE | ECMA_TYPE_BIGINT;
|
||||
uint32_t new_size_remainder = new_size % sizeof (uint32_t);
|
||||
ecma_extended_primitive_t *new_result_p = ecma_bigint_create (new_size - new_size_remainder);
|
||||
|
||||
new_result_p->u.bigint_sign_and_size += new_size_remainder;
|
||||
memcpy (new_result_p + 1, result_p + 1, new_size - new_size_remainder);
|
||||
|
||||
ecma_deref_bigint (result_p);
|
||||
ecma_deref_bigint (input_bigint_p);
|
||||
|
||||
return ecma_make_extended_primitive_value (new_result_p, ECMA_TYPE_BIGINT);
|
||||
}
|
||||
|
||||
result_p->u.bigint_sign_and_size = new_size;
|
||||
result_p->refs_and_type = ECMA_EXTENDED_PRIMITIVE_REF_ONE | ECMA_TYPE_BIGINT;
|
||||
|
||||
ecma_deref_bigint (input_bigint_p);
|
||||
return ecma_make_extended_primitive_value (result_p, ECMA_TYPE_BIGINT);
|
||||
}
|
||||
|
||||
memcpy (result_p + 1, input_bigint_p + 1, exact_size);
|
||||
result_p->refs_and_type = ECMA_EXTENDED_PRIMITIVE_REF_ONE | ECMA_TYPE_BIGINT;
|
||||
|
||||
if (input_bigint_p->u.bigint_sign_and_size & ECMA_BIGINT_SIGN)
|
||||
{
|
||||
ecma_deref_bigint (input_bigint_p);
|
||||
return ecma_bigint_negate (result_p);
|
||||
}
|
||||
|
||||
ecma_deref_bigint (input_bigint_p);
|
||||
return ecma_make_extended_primitive_value (result_p, ECMA_TYPE_BIGINT);
|
||||
} /* ecma_builtin_bigint_object_as_int_n */
|
||||
|
||||
/**
|
||||
* Handle calling [[Call]] of built-in BigInt object
|
||||
*
|
||||
@@ -68,13 +364,45 @@ ecma_builtin_bigint_dispatch_construct (const ecma_value_t *arguments_list_p, /*
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
return ecma_raise_type_error (ECMA_ERR_MSG ("BigInt function is not a constructor."));
|
||||
return ecma_raise_type_error (ECMA_ERR_BIGINT_FUNCTION_NOT_CONSTRUCTOR);
|
||||
} /* ecma_builtin_bigint_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_bigint_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_2 (this_arg, arguments_number);
|
||||
|
||||
switch (builtin_routine_id)
|
||||
{
|
||||
case ECMA_BUILTIN_BIGINT_AS_INT_N:
|
||||
{
|
||||
return ecma_builtin_bigint_object_as_int_n (arguments_list_p[0], arguments_list_p[1], true);
|
||||
}
|
||||
case ECMA_BUILTIN_BIGINT_AS_U_INT_N:
|
||||
{
|
||||
return ecma_builtin_bigint_object_as_int_n (arguments_list_p[0], arguments_list_p[1], false);
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
}
|
||||
}
|
||||
} /* ecma_builtin_bigint_dispatch_routine */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user