Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 63f739e5a0 | |||
| a59cbfe1a2 | |||
| de9c27b122 | |||
| 57d8b39f3f |
@@ -1,87 +0,0 @@
|
||||
---
|
||||
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
|
||||
...
|
||||
@@ -1,77 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
|
||||
---
|
||||
|
||||
First of all, when reporting a bug, give the issue a descriptive title.
|
||||
|
||||
In the body of the issue, optionally give a free-form text description of the
|
||||
bug. Give the context necessary for others to understand the problem.
|
||||
|
||||
Then, provide information necessary to reproduce the bug.
|
||||
Omit sections that are irrelevant for the bug report, but note that information
|
||||
like git revision, build platform, build command, and test case are required in
|
||||
almost all cases.
|
||||
|
||||
###### JerryScript revision
|
||||
Identify the git hash(es) or tag(s) where the issue was observed.
|
||||
|
||||
###### Build platform
|
||||
Name the build platform. E.g., copy the output of
|
||||
`echo "$(lsb_release -ds) ($(uname -mrs))"` (on Linux),
|
||||
`echo "$(sw_vers -productName) $(sw_vers -productVersion) ($(uname -mrs))"` (on macOS), or
|
||||
`python -c "import platform; print(platform.platform())"` (should work everywhere).
|
||||
|
||||
###### Build steps
|
||||
Describe how to build JerryScript. Give all the necessary details of the build
|
||||
(e.g., environment variables, command(s), profile, command line options, etc.).
|
||||
|
||||
E.g.:
|
||||
```sh
|
||||
tools/build.py --clean --debug
|
||||
```
|
||||
Or:
|
||||
```sh
|
||||
mkdir build && cmake -H. -Bbuild && make -C build
|
||||
```
|
||||
|
||||
Even if the bug was originally observed when JerryScript was integrated into a
|
||||
larger project, try to reproduce it with as few external code as possible,
|
||||
preferably by building the `jerry` command line tool.
|
||||
|
||||
###### Build log
|
||||
Copy the build log if the reported issue is a build problem. Do a verbose build
|
||||
if necessary. Try and trim the log to relevant parts.
|
||||
|
||||
###### Test case
|
||||
Give the JavaScript input that should be passed to the engine to trigger the
|
||||
bug. Try and post a reduced test case that is minimally necessary to reproduce
|
||||
the issue. As a rule of thumb, use Markdown's fenced code block syntax for the
|
||||
test case. Attach the file (renamed to .txt) if the test case contains
|
||||
'problematic' bytes that cannot be copied in the bug report directly.
|
||||
|
||||
###### Execution platform
|
||||
Unnecessary if the same as the build platform.
|
||||
|
||||
###### Execution steps
|
||||
List the steps that trigger the bug.
|
||||
|
||||
E.g., if a bug is snapshot-specific:
|
||||
```sh
|
||||
build/bin/jerry-snapshot generate -o testcase.js.snapshot testcase.js
|
||||
build/bin/jerry --exec-snapshot testcase.js.snapshot
|
||||
```
|
||||
|
||||
Unnecessary if trivial (i.e., `build/bin/jerry testcase.js`).
|
||||
|
||||
###### Output
|
||||
Copy relevant output from the standard output and/or error channels.
|
||||
|
||||
###### Backtrace
|
||||
In case of a crash (assertion failure, etc.), try to copy the backtrace from a
|
||||
debugger at the point of failure.
|
||||
|
||||
###### Expected behavior
|
||||
Describe what should happen instead of current behavior. Unnecessary if trivial
|
||||
(e.g., in case of a crash, the trivial expected behavior is not to crash).
|
||||
@@ -1,19 +0,0 @@
|
||||
**PLEASE REMOVE THIS TEMPLATE BEFORE SUBMITTING**
|
||||
|
||||
Before submitting a PR, please, make sure that:
|
||||
|
||||
- Changes are in a separate branch, not in master.
|
||||
- The branch contains only one commit on top of master (if not, squash them into
|
||||
one commit).
|
||||
- The commit has a descriptive commit message with a concise title (first line).
|
||||
- The commit message contains `fixes #XXXX` or `closes #XXXX` to auto-close the
|
||||
issue(s) that the PR fixes (if any).
|
||||
- Tests for the changes have been added (for bug fixes / features).
|
||||
- Documentation has been added / updated (if applicable).
|
||||
- All new and existing tests passed locally (if not, fix them first and amend
|
||||
the commit).
|
||||
|
||||
IMPORTANT: Please review the CONTRIBUTING.md file for detailed contributing
|
||||
guidelines.
|
||||
|
||||
**PLEASE REMOVE THIS TEMPLATE BEFORE SUBMITTING**
|
||||
@@ -1,401 +0,0 @@
|
||||
name: JerryScript CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
RUNNER: tools/run-tests.py
|
||||
|
||||
jobs:
|
||||
Checks:
|
||||
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 pylint doxygen cppcheck clang-format-15
|
||||
- run: $RUNNER --check-signed-off=gh-actions
|
||||
if: ${{ always() }}
|
||||
- run: $RUNNER --check-doxygen
|
||||
if: ${{ always() }}
|
||||
- run: $RUNNER --check-format
|
||||
if: ${{ always() }}
|
||||
- run: $RUNNER --check-license
|
||||
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@v4
|
||||
with:
|
||||
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
|
||||
|
||||
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_ESNext:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@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-ESNext-results
|
||||
path: |
|
||||
build/tests/test262_tests_esnext/local/bin/test262.report
|
||||
|
||||
Conformance_Tests_ESNext_Debug_A:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@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-Debug-A-results
|
||||
path: |
|
||||
build/tests/test262_tests_esnext-debug/local/bin/test262.report
|
||||
|
||||
Conformance_Tests_ESNext_Debug_B:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@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-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
|
||||
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
|
||||
--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
|
||||
|
||||
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
|
||||
env:
|
||||
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
|
||||
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
|
||||
--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:
|
||||
RUNTIME: qemu-aarch64-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-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
|
||||
|
||||
Linux_AArch64_Tests_Debug:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUNTIME: qemu-aarch64-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-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
|
||||
|
||||
MbedOS_K64F_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 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/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/os/nuttx/Makefile.travis install-noapt
|
||||
- run: make -f ./targets/os/nuttx/Makefile.travis script
|
||||
|
||||
RIOT_STM32F4_Build_Test:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
CC: clang
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- 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_RTOS_SDK_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/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: false && github.event_name == 'push' && github.repository == 'jerryscript-project/jerryscript'
|
||||
steps:
|
||||
- uses: rectalogic/notify-irc@v1
|
||||
with:
|
||||
channel: '#jerryscript'
|
||||
nickname: jerryscript-notification
|
||||
message: |
|
||||
@${{ github.actor }}: ${{ github.repository }} (${{ github.ref }}#${{ github.sha }})
|
||||
${{ join(github.event.commits.*.message) }}
|
||||
${{ github.event.compare }}
|
||||
+11
-12
@@ -1,11 +1,11 @@
|
||||
# Produced files
|
||||
.mbedignore
|
||||
|
||||
build/*
|
||||
|
||||
# IDE related files
|
||||
nbproject
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
**.sublime-project
|
||||
**.sublime-workspace
|
||||
.idea
|
||||
|
||||
# Random Trash
|
||||
@@ -14,28 +14,27 @@ nbproject
|
||||
*~
|
||||
core
|
||||
vgcore.*
|
||||
*.orig
|
||||
*.directory
|
||||
*.patch
|
||||
**.orig
|
||||
**.directory
|
||||
**.patch
|
||||
.tags*
|
||||
cscope.*
|
||||
__pycache__
|
||||
*.pyc
|
||||
.DS_Store
|
||||
|
||||
# ctags and ID database
|
||||
tags
|
||||
ID
|
||||
|
||||
# targets
|
||||
jerry-targetjs.h
|
||||
jerry_targetjs.h
|
||||
targets/mbedk64f/libjerry
|
||||
targets/mbedk64f/build
|
||||
targets/mbedk64f/yotta_modules
|
||||
targets/mbedk64f/yotta_targets
|
||||
.output
|
||||
targets/esp8266/output.map
|
||||
targets/esp8266/libs
|
||||
|
||||
# Generated documentation
|
||||
docs/doxygen
|
||||
|
||||
# Tests
|
||||
tests/test262/
|
||||
.vs
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
language: c
|
||||
|
||||
os: linux
|
||||
dist: trusty
|
||||
sudo: required
|
||||
|
||||
before_install:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then tools/apt-get-install-deps.sh; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then tools/apt-get-install-qemu-arm.sh; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then tools/brew-install-deps.sh; fi
|
||||
|
||||
install:
|
||||
|
||||
script: "python tools/run-tests.py $OPTS"
|
||||
|
||||
env:
|
||||
- OPTS="--check-signed-off --check-cppcheck --check-vera"
|
||||
- OPTS="--jerry-tests --jerry-test-suite"
|
||||
- OPTS="--jerry-tests --jerry-test-suite --toolchain=cmake/toolchain_linux_armv7l.cmake" TIMEOUT=300
|
||||
- OPTS=--buildoption-test
|
||||
- OPTS=--unittests
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: osx
|
||||
env: OPTS="--jerry-tests --jerry-test-suite"
|
||||
- os: osx
|
||||
env: OPTS=--unittests
|
||||
allow_failures:
|
||||
- os: osx
|
||||
+131
-231
@@ -1,4 +1,5 @@
|
||||
# Copyright JS Foundation and other contributors, http://js.foundation
|
||||
# Copyright 2015-2016 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2016 University of Szeged.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -12,154 +13,73 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
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
|
||||
OUTPUT_VARIABLE JERRY_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
cmake_minimum_required (VERSION 2.8.12)
|
||||
project (Jerry C ASM)
|
||||
|
||||
# Determining platform
|
||||
set(PLATFORM "${CMAKE_SYSTEM_NAME}")
|
||||
string(TOUPPER "${PLATFORM}" PLATFORM)
|
||||
|
||||
# Determining compiler
|
||||
if(MSVC)
|
||||
set(USING_MSVC 1)
|
||||
endif()
|
||||
# Remove rdynamic option
|
||||
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS )
|
||||
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
|
||||
set(USING_GCC 1)
|
||||
endif()
|
||||
|
||||
# Clang may support for MSVC
|
||||
if(NOT USING_MSVC AND CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
set(USING_CLANG 1)
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "TI")
|
||||
set(USING_TI 1)
|
||||
endif()
|
||||
|
||||
# Determining build type
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "MinSizeRel")
|
||||
endif()
|
||||
|
||||
# Optional components
|
||||
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 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?")
|
||||
set(DOCTESTS OFF CACHE BOOL "Build doc tests?")
|
||||
# Components
|
||||
set(JERRY_CORE ON CACHE BOOL "Use jerry-core?")
|
||||
set(JERRY_LIBC ON CACHE BOOL "Use jerry-libc?")
|
||||
set(JERRY_LIBM ON CACHE BOOL "Use jerry-libm?")
|
||||
set(JERRY_CMDLINE ON CACHE BOOL "Use jerry command line tool?")
|
||||
set(UNITTESTS OFF CACHE BOOL "Use unit tests?")
|
||||
|
||||
# Optional build settings
|
||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries?")
|
||||
set(ENABLE_AMALGAM OFF CACHE BOOL "Enable amalgamated build?")
|
||||
set(ENABLE_LTO ON CACHE BOOL "Enable LTO build?")
|
||||
set(ENABLE_STRIP ON CACHE BOOL "Enable stripping all symbols from release binary?")
|
||||
set(ENABLE_COMPILE_COMMANDS ON CACHE BOOL "Enable generating compile_commands.json?")
|
||||
set(PORT_DIR "${CMAKE_SOURCE_DIR}/targets/default" CACHE STRING "Should we use default or external port?")
|
||||
set(COMPILER_DEFAULT_LIBC OFF CACHE BOOL "Enable compiler default libc?")
|
||||
set(ENABLE_LTO OFF CACHE BOOL "Enable LTO build?")
|
||||
set(ENABLE_ALL_IN_ONE ON CACHE BOOL "Enable all-in-one build?")
|
||||
set(ENABLE_STRIP ON CACHE BOOL "Discards all symbols from object files?")
|
||||
|
||||
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)
|
||||
|
||||
set(JERRY_LIBFUZZER_MESSAGE " (FORCED BY COMPILER)")
|
||||
endif()
|
||||
|
||||
if(JERRY_CMDLINE OR JERRY_CMDLINE_TEST OR JERRY_CMDLINE_SNAPSHOT OR JERRY_LIBFUZZER OR UNITTESTS OR DOCTESTS)
|
||||
set(JERRY_PORT ON)
|
||||
|
||||
set(JERRY_PORT_MESSAGE " (FORCED BY CMDLINE OR LIBFUZZER OR TESTS)")
|
||||
endif()
|
||||
|
||||
if(JERRY_CMDLINE OR DOCTESTS)
|
||||
set(JERRY_EXT ON)
|
||||
|
||||
set(JERRY_EXT_MESSAGE " (FORCED BY CMDLINE OR TESTS)")
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
endif()
|
||||
|
||||
if("${PLATFORM}" STREQUAL "DARWIN")
|
||||
set(ENABLE_LTO OFF)
|
||||
set(ENABLE_STRIP OFF)
|
||||
|
||||
set(ENABLE_LTO_MESSAGE " (FORCED BY PLATFORM)")
|
||||
set(ENABLE_STRIP_MESSAGE " (FORCED BY PLATFORM)")
|
||||
set(ENABLE_LTO "OFF")
|
||||
set(ENABLE_ALL_IN_ONE "ON")
|
||||
set(JERRY_LIBC "OFF")
|
||||
set(JERRY_LIBM "OFF")
|
||||
set(COMPILER_DEFAULT_LIBC "ON")
|
||||
endif()
|
||||
|
||||
if("${PLATFORM}" STREQUAL "ESP-IDF")
|
||||
set(ENABLE_LTO OFF)
|
||||
set(ENABLE_STRIP OFF)
|
||||
|
||||
set(ENABLE_LTO_MESSAGE " (FORCED BY PLATFORM)")
|
||||
set(ENABLE_STRIP_MESSAGE " (FORCED BY PLATFORM)")
|
||||
if(JERRY_LIBC AND COMPILER_DEFAULT_LIBC)
|
||||
message(FATAL_ERROR "JERRY_LIBC and COMPILER_DEFAULT_LIBC is enabled at the same time!")
|
||||
endif()
|
||||
|
||||
if(USING_TI)
|
||||
set(ENABLE_STRIP OFF)
|
||||
|
||||
set(ENABLE_STRIP_MESSAGE " (FORCED BY COMPILER)")
|
||||
endif()
|
||||
|
||||
if(USING_MSVC)
|
||||
set(ENABLE_STRIP OFF)
|
||||
|
||||
set(ENABLE_STRIP_MESSAGE " (FORCED BY COMPILER)")
|
||||
endif()
|
||||
|
||||
if(CYGWIN OR MINGW OR MSYS)
|
||||
set(ENABLE_LTO OFF)
|
||||
|
||||
set(ENABLE_LTO_MESSAGE " (FORCED BY PLATFORM)")
|
||||
endif()
|
||||
|
||||
# Generate compile_commands.json
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ${ENABLE_COMPILE_COMMANDS})
|
||||
|
||||
# Status messages
|
||||
message(STATUS "CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE})
|
||||
message(STATUS "CMAKE_C_COMPILER_ID " ${CMAKE_C_COMPILER_ID})
|
||||
message(STATUS "CMAKE_SYSTEM_NAME " ${CMAKE_SYSTEM_NAME})
|
||||
message(STATUS "CMAKE_SYSTEM_PROCESSOR " ${CMAKE_SYSTEM_PROCESSOR})
|
||||
message(STATUS "BUILD_SHARED_LIBS " ${BUILD_SHARED_LIBS})
|
||||
message(STATUS "ENABLE_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 " ${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})
|
||||
message(STATUS "DOCTESTS " ${DOCTESTS})
|
||||
message(STATUS "CMAKE_SYSTEM_NAME " ${CMAKE_SYSTEM_NAME})
|
||||
message(STATUS "CMAKE_SYSTEM_PROCESSOR " ${CMAKE_SYSTEM_PROCESSOR})
|
||||
message(STATUS "CMAKE_BUILD_TYPE " ${CMAKE_BUILD_TYPE})
|
||||
message(STATUS "JERRY_CORE " ${JERRY_CORE})
|
||||
message(STATUS "JERRY_LIBC " ${JERRY_LIBC})
|
||||
message(STATUS "JERRY_LIBM " ${JERRY_LIBM})
|
||||
message(STATUS "JERRY_CMDLINE " ${JERRY_CMDLINE})
|
||||
message(STATUS "UNITTESTS " ${UNITTESTS})
|
||||
message(STATUS "PORT_DIR " ${PORT_DIR})
|
||||
message(STATUS "COMPILER_DEFAULT_LIBC " ${COMPILER_DEFAULT_LIBC})
|
||||
message(STATUS "ENABLE_LTO " ${ENABLE_LTO})
|
||||
message(STATUS "ENABLE_ALL_IN_ONE " ${ENABLE_ALL_IN_ONE})
|
||||
message(STATUS "ENABLE_STRIP " ${ENABLE_STRIP})
|
||||
|
||||
# Setup directories
|
||||
# Note: This mimics a conventional file system layout in the build directory for
|
||||
# the sake of convenient location of build artefacts. Proper installation to
|
||||
# traditional locations is also supported, e.g., to /usr/local.
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/")
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/")
|
||||
# Project binary dir
|
||||
set(PROJECT_BINARY_DIR "${CMAKE_BINARY_DIR}")
|
||||
|
||||
# Remove rdynamic option
|
||||
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS )
|
||||
# Library output directory
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/")
|
||||
|
||||
# Executable output directory
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/")
|
||||
|
||||
# Archive targets output Directory
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/")
|
||||
|
||||
# Compile/link flags
|
||||
# Helper macros
|
||||
@@ -176,7 +96,9 @@ endmacro()
|
||||
macro(jerry_add_compile_warnings)
|
||||
foreach(_warning ${ARGV})
|
||||
jerry_add_compile_flags(-W${_warning})
|
||||
jerry_add_compile_flags(-Werror=${_warning})
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
jerry_add_compile_flags(-Werror=${_warning})
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
@@ -184,101 +106,88 @@ macro(jerry_add_link_flags)
|
||||
jerry_add_flags(LINKER_FLAGS_COMMON ${ARGV})
|
||||
endmacro()
|
||||
|
||||
# build mode specific compile/link flags
|
||||
set(CMAKE_C_FLAGS_RELEASE "-Os")
|
||||
|
||||
# Architecture-specific compile/link flags
|
||||
jerry_add_compile_flags(${FLAGS_COMMON_ARCH})
|
||||
jerry_add_flags(CMAKE_EXE_LINKER_FLAGS ${FLAGS_COMMON_ARCH})
|
||||
|
||||
# LTO
|
||||
if(ENABLE_LTO)
|
||||
if(USING_GCC OR USING_CLANG)
|
||||
jerry_add_compile_flags(-flto)
|
||||
jerry_add_link_flags(-flto)
|
||||
endif()
|
||||
if(USING_GCC)
|
||||
jerry_add_compile_flags(-fno-fat-lto-objects)
|
||||
jerry_add_compile_flags(-flto)
|
||||
jerry_add_link_flags(-flto)
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
if(NOT "${PLATFORM}" STREQUAL "DARWIN")
|
||||
jerry_add_compile_flags(-fno-fat-lto-objects)
|
||||
endif()
|
||||
# Use gcc-ar and gcc-ranlib to support LTO
|
||||
set(CMAKE_AR "gcc-ar")
|
||||
set(CMAKE_RANLIB "gcc-ranlib")
|
||||
endif()
|
||||
if(USING_TI)
|
||||
jerry_add_link_flags(-lto)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Define _BSD_SOURCE if we use default port and compiler default libc
|
||||
if(${PORT_DIR} STREQUAL "${CMAKE_SOURCE_DIR}/targets/default" AND COMPILER_DEFAULT_LIBC)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} _BSD_SOURCE)
|
||||
endif()
|
||||
|
||||
# Imported targets prefix
|
||||
set(PREFIX_IMPORTED_LIB imported_)
|
||||
|
||||
# Imported libraries
|
||||
if(("${PLATFORM}" STREQUAL "DARWIN") AND (NOT CMAKE_COMPILER_IS_GNUCC))
|
||||
# libclang_rt.osx
|
||||
set(IMPORTED_LIB "${PREFIX_IMPORTED_LIB}libclang_rt.osx")
|
||||
add_library(${IMPORTED_LIB} STATIC IMPORTED)
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} ${FLAGS_COMMON_ARCH} -print-file-name=
|
||||
OUTPUT_VARIABLE IMPORTED_LIBCLANG_RT_LOCATION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
set(IMPORTED_LIBCLANG_RT_LOCATION "${IMPORTED_LIBCLANG_RT_LOCATION}/lib/darwin/libclang_rt.osx.a")
|
||||
set_property(TARGET ${IMPORTED_LIB}
|
||||
PROPERTY IMPORTED_LOCATION ${IMPORTED_LIBCLANG_RT_LOCATION})
|
||||
else()
|
||||
# libgcc
|
||||
set(IMPORTED_LIB "${PREFIX_IMPORTED_LIB}libgcc")
|
||||
add_library(${IMPORTED_LIB} STATIC IMPORTED)
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} ${FLAGS_COMMON_ARCH} -print-file-name=libgcc.a
|
||||
OUTPUT_VARIABLE IMPORTED_LIBGCC_LOCATION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
set_property(TARGET ${IMPORTED_LIB}
|
||||
PROPERTY IMPORTED_LOCATION ${IMPORTED_LIBGCC_LOCATION})
|
||||
endif()
|
||||
|
||||
# Compiler / Linker flags
|
||||
if("${PLATFORM}" STREQUAL "DARWIN")
|
||||
jerry_add_compile_flags(-fno-builtin)
|
||||
if(("${PLATFORM}" STREQUAL "DARWIN"))
|
||||
jerry_add_link_flags(-lSystem)
|
||||
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Sqc <TARGET> <LINK_FLAGS> <OBJECTS>")
|
||||
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))
|
||||
else()
|
||||
jerry_add_link_flags(-Wl,-z,noexecstack)
|
||||
endif()
|
||||
|
||||
if(USING_GCC OR USING_CLANG)
|
||||
jerry_add_compile_flags(-std=c99 -pedantic)
|
||||
if(JERRY_MATH)
|
||||
jerry_add_compile_flags(-fno-builtin)
|
||||
endif()
|
||||
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)
|
||||
# Turn off linking to compiler's default libc, in case jerry-libc or external is used
|
||||
if(NOT COMPILER_DEFAULT_LIBC)
|
||||
jerry_add_link_flags(-nostdlib)
|
||||
endif()
|
||||
|
||||
if(USING_GCC)
|
||||
# Turn off stack protector
|
||||
jerry_add_compile_flags(-fno-stack-protector)
|
||||
|
||||
# Debug information
|
||||
jerry_add_compile_flags(-g -gdwarf-4)
|
||||
|
||||
jerry_add_compile_warnings(all extra format-nonliteral init-self conversion sign-conversion format-security missing-declarations)
|
||||
jerry_add_compile_flags(-Wno-stack-protector -Wno-attributes)
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
if(JERRY_LIBC)
|
||||
jerry_add_compile_flags(-Werror)
|
||||
endif()
|
||||
jerry_add_compile_warnings(logical-op)
|
||||
# TODO: Remove workaround for gcc 7 bug if the fallthrough comment detection is fixed.
|
||||
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER 7.0)
|
||||
jerry_add_compile_flags(-Wno-implicit-fallthrough)
|
||||
endif()
|
||||
else()
|
||||
jerry_add_compile_flags(-Wno-nested-anon-types)
|
||||
endif()
|
||||
|
||||
if(USING_CLANG)
|
||||
jerry_add_compile_flags(-Wno-nested-anon-types -Wno-static-in-inline)
|
||||
endif()
|
||||
|
||||
if(USING_TI)
|
||||
jerry_add_compile_flags(--c99)
|
||||
endif()
|
||||
|
||||
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)
|
||||
jerry_add_compile_flags(-fsanitize=fuzzer-no-link)
|
||||
endif()
|
||||
|
||||
# Strip binary
|
||||
if(ENABLE_STRIP AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
jerry_add_link_flags(-s)
|
||||
endif()
|
||||
|
||||
# External compiler & linker flags
|
||||
if(DEFINED EXTERNAL_COMPILE_FLAGS)
|
||||
jerry_add_compile_flags(${EXTERNAL_COMPILE_FLAGS})
|
||||
endif()
|
||||
@@ -287,44 +196,35 @@ if(DEFINED EXTERNAL_LINKER_FLAGS)
|
||||
jerry_add_link_flags(${EXTERNAL_LINKER_FLAGS})
|
||||
endif()
|
||||
|
||||
# Used as placeholder to attach amalgamated build targets to
|
||||
add_custom_target(amalgam)
|
||||
# C
|
||||
jerry_add_compile_flags(-std=c99 -pedantic)
|
||||
|
||||
# Strip binary
|
||||
if(ENABLE_STRIP AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
jerry_add_link_flags(-s)
|
||||
endif()
|
||||
|
||||
# Jerry's libc
|
||||
if(JERRY_LIBC)
|
||||
add_subdirectory(jerry-libc)
|
||||
endif()
|
||||
|
||||
# Jerry's libm
|
||||
if(JERRY_MATH)
|
||||
add_subdirectory(jerry-math)
|
||||
if(JERRY_LIBM)
|
||||
add_subdirectory(jerry-libm)
|
||||
endif()
|
||||
|
||||
# Jerry's core
|
||||
add_subdirectory(jerry-core)
|
||||
|
||||
# Jerry's extension tools
|
||||
if(JERRY_EXT)
|
||||
add_subdirectory(jerry-ext)
|
||||
if(JERRY_CORE)
|
||||
add_subdirectory(jerry-core)
|
||||
endif()
|
||||
|
||||
# Jerry's default port implementation
|
||||
if(JERRY_PORT)
|
||||
add_subdirectory(jerry-port)
|
||||
endif()
|
||||
|
||||
# Jerry command line tool
|
||||
if(JERRY_CMDLINE OR JERRY_CMDLINE_TEST OR JERRY_CMDLINE_SNAPSHOT OR JERRY_LIBFUZZER)
|
||||
# Jerry commandline tool
|
||||
if(JERRY_CMDLINE)
|
||||
add_subdirectory(jerry-main)
|
||||
endif()
|
||||
|
||||
# Unittests
|
||||
if(UNITTESTS)
|
||||
add_subdirectory(tests/unit-core)
|
||||
if(JERRY_MATH)
|
||||
add_subdirectory(tests/unit-math)
|
||||
endif()
|
||||
if(JERRY_EXT)
|
||||
add_subdirectory(tests/unit-ext)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Doctests
|
||||
if(DOCTESTS)
|
||||
add_subdirectory(tests/unit-doc)
|
||||
add_subdirectory(tests/unit)
|
||||
endif()
|
||||
|
||||
-101
@@ -1,101 +0,0 @@
|
||||
# Contribution Guidelines
|
||||
## Patch Submission Process
|
||||
|
||||
The following guidelines on the submission process are provided to help you be more effective when submitting code to the JerryScript project.
|
||||
|
||||
When development is complete, a patch set should be submitted via GitHub pull requests. A review of the patch set will take place. When accepted, the patch set will be integrated into the master branch, verified, and tested. It is then the responsibility of the authoring developer to maintain the code throughout its lifecycle.
|
||||
|
||||
Please submit all patches in public by opening a pull request. Patches sent privately to Maintainers and Committers will not be considered. Because the JerryScript Project is an Open Source project, be prepared for feedback and criticism-it happens to everyone-. If asked to rework your code, be persistent and resubmit after making changes.
|
||||
|
||||
### 1. Scope the patch
|
||||
|
||||
Smaller patches are generally easier to understand and test, so please submit changes in the smallest increments possible, within reason. Smaller patches are less likely to have unintended consequences, and if they do, getting to the root cause is much easier for you and the Maintainers and Committers. Additionally, smaller patches are much more likely to be accepted.
|
||||
|
||||
### 2. Ensure all files have a proper license header and copyright notice
|
||||
|
||||
Any code that you want to contribute to the project must be licensed under the [Apache License 2.0](LICENSE). Contributions under a different license can not be accepted. Each file should start with the following header:
|
||||
|
||||
```c
|
||||
/* 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.
|
||||
*/
|
||||
```
|
||||
|
||||
Adding copyright notices other than the project-wide notice ("Copyright JS Foundation and other contributors, http://js.foundation") is not permitted. The only exception is adding third-party code which requires copyright notices to be preserved. Adding third-party code to the project generally requires a strong justification.
|
||||
|
||||
### 3. Sign your work with the JerryScript [Developer's Certificate of Origin](DCO.md)
|
||||
|
||||
The sign-off is a simple line at the end of the commit message of the patch, which certifies that you wrote it or otherwise have the right to pass it on as an Open Source patch. The sign-off is required for a patch to be accepted.
|
||||
|
||||
We have the same requirements for using the signed-off-by process as the Linux kernel.
|
||||
In short, you need to include a signed-off-by tag in every patch.
|
||||
|
||||
You should use your real name and email address in the format below:
|
||||
|
||||
> JerryScript-DCO-1.0-Signed-off-by: Random J Developer random@developer.example.org
|
||||
|
||||
"JerryScript-DCO-1.0-Signed-off-by:" this is a developer's certification that he or she has the right to submit the patch for inclusion into the project. It is an agreement to the JerryScript [Developer's Certificate of Origin](DCO.md). **Code without a proper signoff cannot be merged into the mainline.**
|
||||
|
||||
### 4. Open a GitHub [pull request](https://github.com/jerryscript-project/jerryscript/pulls)
|
||||
|
||||
You can find instructions about opening a pull request [here](https://help.github.com/articles/creating-a-pull-request).
|
||||
|
||||
### 5. What if my patch is rejected?
|
||||
|
||||
It happens all the time, for many reasons, and not necessarily because the code is bad. Take the feedback, adapt your code, and try again. Remember, the ultimate goal is to preserve the quality of the code and maintain the focus of the Project through intensive review.
|
||||
|
||||
Maintainers and Committers typically have to process a lot of submissions, and the time for any individual response is generally limited. If the reason for rejection is unclear, please ask for more information from the Maintainers and Committers.
|
||||
If you have a solid technical reason to disagree with feedback and you feel that reason has been overlooked, take the time to thoroughly explain it in your response.
|
||||
|
||||
### 6. Code review
|
||||
|
||||
Code review can be performed by all the members of the Project (not just Maintainers and Committers). Members can review code changes and share their opinion through comments guided by the following principles:
|
||||
* Discuss code; never discuss the code's author
|
||||
* Respect and acknowledge contributions, suggestions, and comments
|
||||
* Listen and be open to all different opinions
|
||||
* Help each other
|
||||
|
||||
Changes are submitted via pull requests and only the Maintainers and Committers should approve or reject the pull request (note that only Maintainers can give binding review scores).
|
||||
Changes should be reviewed in reasonable amount of time. Maintainers and Committers should leave changes open for some time (at least 1 full business day) so others can offer feedback. Review times increase with the complexity of the review.
|
||||
|
||||
## Tips on GitHub Pull Requests
|
||||
|
||||
* [Fork](https://guides.github.com/activities/forking) the GitHub repository and clone it locally
|
||||
* Connect your local repository to the original upstream repository by adding it as a remote
|
||||
* Create a [branch](https://guides.github.com/introduction/flow) for your edits
|
||||
* Pull in upstream changes often to stay up-to-date so that when you submit your pull request, merge conflicts will be less likely
|
||||
|
||||
For more details, see the GitHub [fork syncing](https://help.github.com/articles/syncing-a-fork) guidelines.
|
||||
|
||||
## How to add the DCO line to every single commit automatically
|
||||
|
||||
It is easy to forget adding the DCO line to the end of every commit message. Fortunately there is a nice way to do it automatically. Once you've cloned the repository into your local machine, you can add `prepare commit message hook` in `.git/hooks` directory like this:
|
||||
|
||||
```
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
commit_msg_filepath = sys.argv[1]
|
||||
|
||||
with open(commit_msg_filepath, "r+") as f:
|
||||
content = f.read()
|
||||
f.seek(0, 0)
|
||||
if "Signed-off-by" not in content:
|
||||
f.write("\n\nJerryScript-DCO-1.0-Signed-off-by: <Your Name> <Your Email>\n%s" % content)
|
||||
else:
|
||||
f.write(content)
|
||||
```
|
||||
|
||||
Please refer [Git Hooks](http://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) for more information.
|
||||
@@ -1,22 +0,0 @@
|
||||
# JerryScript Developer's Certificate of Origin
|
||||
|
||||
The JerryScript project uses the signed-off-by language and process to give us a clear chain of trust for every patch received.
|
||||
|
||||
> By making a contribution to this project, I certify that:
|
||||
|
||||
> (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or
|
||||
|
||||
> (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or
|
||||
|
||||
> (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.
|
||||
|
||||
> (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project, under the same open source license.
|
||||
|
||||
We have the same requirements for using the signed-off-by process as the Linux kernel.
|
||||
In short, you need to include a signed-off-by tag in the commit message of every patch.
|
||||
|
||||
You should use your real name and email address in the format below:
|
||||
|
||||
> JerryScript-DCO-1.0-Signed-off-by: Random J Developer random@developer.example.org
|
||||
|
||||
"JerryScript-DCO-1.0-Signed-off-by:" this is a developer's certification that he or she has the right to submit the patch for inclusion into the project. It is an agreement to the Developer's Certificate of Origin (above). **Code without a proper signoff cannot be merged into the mainline.**
|
||||
@@ -1,4 +1,4 @@
|
||||
# Doxyfile 1.9.1
|
||||
# Doxyfile 1.8.9.1
|
||||
|
||||
# This file describes the settings to be used by the documentation system
|
||||
# doxygen (www.doxygen.org) for a project.
|
||||
@@ -17,11 +17,11 @@
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# This tag specifies the encoding used for all characters in the configuration
|
||||
# file that follow. The default is UTF-8 which is also the encoding used for all
|
||||
# text before the first occurrence of this tag. Doxygen uses libiconv (or the
|
||||
# iconv built into libc) for the transcoding. See
|
||||
# https://www.gnu.org/software/libiconv/ for the list of possible encodings.
|
||||
# This tag specifies the encoding used for all characters in the config file
|
||||
# that follow. The default is UTF-8 which is also the encoding used for all text
|
||||
# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv
|
||||
# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv
|
||||
# for the list of possible encodings.
|
||||
# The default value is: UTF-8.
|
||||
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
@@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
|
||||
# title of most generated pages and in a few other places.
|
||||
# The default value is: My Project.
|
||||
|
||||
PROJECT_NAME = JerryScript
|
||||
PROJECT_NAME = "JerryScript"
|
||||
|
||||
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
@@ -58,7 +58,7 @@ PROJECT_LOGO =
|
||||
# entered, it will be relative to the location where doxygen was started. If
|
||||
# left blank the current directory will be used.
|
||||
|
||||
OUTPUT_DIRECTORY = docs/doxygen
|
||||
OUTPUT_DIRECTORY = "docs/doxygen"
|
||||
|
||||
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
|
||||
# directories (in 2 levels) under the output directory of each output format and
|
||||
@@ -93,14 +93,6 @@ ALLOW_UNICODE_NAMES = NO
|
||||
|
||||
OUTPUT_LANGUAGE = English
|
||||
|
||||
# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all
|
||||
# documentation generated by doxygen is written. Doxygen will use this
|
||||
# information to generate all generated output in the proper direction.
|
||||
# Possible values are: None, LTR, RTL and Context.
|
||||
# The default value is: None.
|
||||
|
||||
OUTPUT_TEXT_DIRECTION = None
|
||||
|
||||
# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member
|
||||
# descriptions after the members that are listed in the file and class
|
||||
# documentation (similar to Javadoc). Set to NO to disable this.
|
||||
@@ -187,16 +179,6 @@ SHORT_NAMES = NO
|
||||
|
||||
JAVADOC_AUTOBRIEF = YES
|
||||
|
||||
# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line
|
||||
# such as
|
||||
# /***************
|
||||
# as being the beginning of a Javadoc-style comment "banner". If set to NO, the
|
||||
# Javadoc-style will behave just like regular comments and it will not be
|
||||
# interpreted by doxygen.
|
||||
# The default value is: NO.
|
||||
|
||||
JAVADOC_BANNER = NO
|
||||
|
||||
# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
|
||||
# line (until the first dot) of a Qt-style comment as the brief description. If
|
||||
# set to NO, the Qt-style will behave just like regular Qt-style comments (thus
|
||||
@@ -217,14 +199,6 @@ QT_AUTOBRIEF = NO
|
||||
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
|
||||
# By default Python docstrings are displayed as preformatted text and doxygen's
|
||||
# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the
|
||||
# doxygen's special commands can be used and the contents of the docstring
|
||||
# documentation blocks is shown as doxygen documentation.
|
||||
# The default value is: YES.
|
||||
|
||||
PYTHON_DOCSTRING = YES
|
||||
|
||||
# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the
|
||||
# documentation from any documented member that it re-implements.
|
||||
# The default value is: YES.
|
||||
@@ -252,15 +226,16 @@ TAB_SIZE = 2
|
||||
# will allow you to put the command \sideeffect (or @sideeffect) in the
|
||||
# documentation, which will result in a user-defined paragraph with heading
|
||||
# "Side Effects:". You can put \n's in the value part of an alias to insert
|
||||
# newlines (in the resulting output). You can put ^^ in the value part of an
|
||||
# alias to insert a newline as if a physical newline was in the original file.
|
||||
# When you need a literal { or } or , in the value part of an alias you have to
|
||||
# escape them by means of a backslash (\), this can lead to conflicts with the
|
||||
# commands \{ and \} for these it is advised to use the version @{ and @} or use
|
||||
# a double escape (\\{ and \\})
|
||||
# newlines.
|
||||
|
||||
ALIASES =
|
||||
|
||||
# This tag can be used to specify a number of word-keyword mappings (TCL only).
|
||||
# A mapping has the form "name=value". For example adding "class=itcl::class"
|
||||
# will allow you to use the command class in the itcl::class meaning.
|
||||
|
||||
TCL_SUBST =
|
||||
|
||||
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
|
||||
# only. Doxygen will then generate output that is more tailored for C. For
|
||||
# instance, some of the names that are used will be different. The list of all
|
||||
@@ -289,40 +264,28 @@ OPTIMIZE_FOR_FORTRAN = NO
|
||||
|
||||
OPTIMIZE_OUTPUT_VHDL = NO
|
||||
|
||||
# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice
|
||||
# sources only. Doxygen will then generate output that is more tailored for that
|
||||
# language. For instance, namespaces will be presented as modules, types will be
|
||||
# separated into more groups, etc.
|
||||
# The default value is: NO.
|
||||
|
||||
OPTIMIZE_OUTPUT_SLICE = NO
|
||||
|
||||
# Doxygen selects the parser to use depending on the extension of the files it
|
||||
# parses. With this tag you can assign which parser to use for a given
|
||||
# extension. Doxygen has a built-in mapping, but you can override or extend it
|
||||
# using this tag. The format is ext=language, where ext is a file extension, and
|
||||
# language is one of the parsers supported by doxygen: IDL, Java, JavaScript,
|
||||
# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, VHDL,
|
||||
# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran:
|
||||
# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser
|
||||
# tries to guess whether the code is fixed or free formatted code, this is the
|
||||
# default for Fortran type files). For instance to make doxygen treat .inc files
|
||||
# as Fortran files (default is PHP), and .f files as C (default is Fortran),
|
||||
# use: inc=Fortran f=C.
|
||||
# language is one of the parsers supported by doxygen: IDL, Java, Javascript,
|
||||
# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran:
|
||||
# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran:
|
||||
# Fortran. In the later case the parser tries to guess whether the code is fixed
|
||||
# or free formatted code, this is the default for Fortran type files), VHDL. For
|
||||
# instance to make doxygen treat .inc files as Fortran files (default is PHP),
|
||||
# and .f files as C (default is Fortran), use: inc=Fortran f=C.
|
||||
#
|
||||
# Note: For files without extension you can use no_extension as a placeholder.
|
||||
#
|
||||
# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
|
||||
# the files are not read by doxygen. When specifying no_extension you should add
|
||||
# * to the FILE_PATTERNS.
|
||||
#
|
||||
# Note see also the list of default file extension mappings.
|
||||
# the files are not read by doxygen.
|
||||
|
||||
EXTENSION_MAPPING =
|
||||
|
||||
# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
|
||||
# according to the Markdown format, which allows for more readable
|
||||
# documentation. See https://daringfireball.net/projects/markdown/ for details.
|
||||
# documentation. See http://daringfireball.net/projects/markdown/ for details.
|
||||
# The output of markdown processing is further processed by doxygen, so you can
|
||||
# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in
|
||||
# case of backward compatibilities issues.
|
||||
@@ -330,15 +293,6 @@ EXTENSION_MAPPING =
|
||||
|
||||
MARKDOWN_SUPPORT = YES
|
||||
|
||||
# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up
|
||||
# to that level are automatically included in the table of contents, even if
|
||||
# they do not have an id attribute.
|
||||
# Note: This feature currently applies only to Markdown headings.
|
||||
# Minimum value: 0, maximum value: 99, default value: 5.
|
||||
# This tag requires that the tag MARKDOWN_SUPPORT is set to YES.
|
||||
|
||||
TOC_INCLUDE_HEADINGS = 5
|
||||
|
||||
# When enabled doxygen tries to link words that correspond to documented
|
||||
# classes, or namespaces to their corresponding documentation. Such a link can
|
||||
# be prevented in individual cases by putting a % sign in front of the word or
|
||||
@@ -364,7 +318,7 @@ BUILTIN_STL_SUPPORT = NO
|
||||
CPP_CLI_SUPPORT = NO
|
||||
|
||||
# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
|
||||
# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen
|
||||
# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen
|
||||
# will parse them like normal C++ but will assume all classes use public instead
|
||||
# of private inheritance when no explicit protection keyword is present.
|
||||
# The default value is: NO.
|
||||
@@ -387,14 +341,7 @@ IDL_PROPERTY_SUPPORT = YES
|
||||
# all members of a group must be documented explicitly.
|
||||
# The default value is: NO.
|
||||
|
||||
DISTRIBUTE_GROUP_DOC = YES
|
||||
|
||||
# If one adds a struct or class to a group and this option is enabled, then also
|
||||
# any nested class or struct is added to the same group. By default this option
|
||||
# is disabled and one has to add nested compounds explicitly via \ingroup.
|
||||
# The default value is: NO.
|
||||
|
||||
GROUP_NESTED_COMPOUNDS = NO
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
|
||||
# Set the SUBGROUPING tag to YES to allow class member groups of the same type
|
||||
# (for instance a group of public functions) to be put as a subgroup of that
|
||||
@@ -450,19 +397,6 @@ TYPEDEF_HIDES_STRUCT = NO
|
||||
|
||||
LOOKUP_CACHE_SIZE = 0
|
||||
|
||||
# The NUM_PROC_THREADS specifies the number threads doxygen is allowed to use
|
||||
# during processing. When set to 0 doxygen will based this on the number of
|
||||
# cores available in the system. You can set it explicitly to a value larger
|
||||
# than 0 to get more control over the balance between CPU load and processing
|
||||
# speed. At this moment only the input processing can be done using multiple
|
||||
# threads. Since this is still an experimental feature the default is set to 1,
|
||||
# which efficively disables parallel processing. Please report any issues you
|
||||
# encounter. Generating dot graphs in parallel is controlled by the
|
||||
# DOT_NUM_THREADS setting.
|
||||
# Minimum value: 0, maximum value: 32, default value: 1.
|
||||
|
||||
NUM_PROC_THREADS = 1
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -475,7 +409,7 @@ NUM_PROC_THREADS = 1
|
||||
# normally produced when WARNINGS is set to YES.
|
||||
# The default value is: NO.
|
||||
|
||||
EXTRACT_ALL = NO
|
||||
EXTRACT_ALL = YES
|
||||
|
||||
# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will
|
||||
# be included in the documentation.
|
||||
@@ -483,12 +417,6 @@ EXTRACT_ALL = NO
|
||||
|
||||
EXTRACT_PRIVATE = YES
|
||||
|
||||
# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual
|
||||
# methods of a class will be included in the documentation.
|
||||
# The default value is: NO.
|
||||
|
||||
EXTRACT_PRIV_VIRTUAL = NO
|
||||
|
||||
# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
|
||||
# scope will be included in the documentation.
|
||||
# The default value is: NO.
|
||||
@@ -526,13 +454,6 @@ EXTRACT_LOCAL_METHODS = YES
|
||||
|
||||
EXTRACT_ANON_NSPACES = NO
|
||||
|
||||
# If this flag is set to YES, the name of an unnamed parameter in a declaration
|
||||
# will be determined by the corresponding definition. By default unnamed
|
||||
# parameters remain unnamed in the output.
|
||||
# The default value is: YES.
|
||||
|
||||
RESOLVE_UNNAMED_PARAMS = YES
|
||||
|
||||
# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all
|
||||
# undocumented members inside documented classes or files. If set to NO these
|
||||
# members will be included in the various overviews, but no documentation
|
||||
@@ -550,8 +471,8 @@ HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
|
||||
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
|
||||
# declarations. If set to NO, these declarations will be included in the
|
||||
# documentation.
|
||||
# (class|struct|union) declarations. If set to NO, these declarations will be
|
||||
# included in the documentation.
|
||||
# The default value is: NO.
|
||||
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
@@ -570,18 +491,11 @@ HIDE_IN_BODY_DOCS = NO
|
||||
|
||||
INTERNAL_DOCS = NO
|
||||
|
||||
# With the correct setting of option CASE_SENSE_NAMES doxygen will better be
|
||||
# able to match the capabilities of the underlying filesystem. In case the
|
||||
# filesystem is case sensitive (i.e. it supports files in the same directory
|
||||
# whose names only differ in casing), the option must be set to YES to properly
|
||||
# deal with such files in case they appear in the input. For filesystems that
|
||||
# are not case sensitive the option should be be set to NO to properly deal with
|
||||
# output files written for symbols that only differ in casing, such as for two
|
||||
# classes, one named CLASS and the other named Class, and to also support
|
||||
# references to files without having to specify the exact matching casing. On
|
||||
# Windows (including Cygwin) and MacOS, users should typically set this option
|
||||
# to NO, whereas on Linux or other Unix flavors it should typically be set to
|
||||
# YES.
|
||||
# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file
|
||||
# names in lower-case letters. If set to YES, upper-case letters are also
|
||||
# allowed. This is useful if you have classes or files whose names only differ
|
||||
# in case and if your file system supports case sensitive file names. Windows
|
||||
# and Mac users are advised to set this option to NO.
|
||||
# The default value is: system dependent.
|
||||
|
||||
CASE_SENSE_NAMES = YES
|
||||
@@ -768,7 +682,7 @@ LAYOUT_FILE =
|
||||
# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
|
||||
# the reference definitions. This must be a list of .bib files. The .bib
|
||||
# extension is automatically appended if omitted. This requires the bibtex tool
|
||||
# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info.
|
||||
# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.
|
||||
# For LaTeX the style of the bibliography can be controlled using
|
||||
# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
|
||||
# search path. See also \cite for info how to create references.
|
||||
@@ -813,20 +727,10 @@ WARN_IF_DOC_ERROR = YES
|
||||
# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
|
||||
# are documented, but have no documentation for their parameters or return
|
||||
# value. If set to NO, doxygen will only warn about wrong or incomplete
|
||||
# parameter documentation, but not about the absence of documentation. If
|
||||
# EXTRACT_ALL is set to YES then this flag will automatically be disabled.
|
||||
# parameter documentation, but not about the absence of documentation.
|
||||
# The default value is: NO.
|
||||
|
||||
WARN_NO_PARAMDOC = YES
|
||||
|
||||
# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when
|
||||
# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS
|
||||
# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but
|
||||
# at the end of the doxygen process doxygen will return with a non-zero status.
|
||||
# Possible values are: NO, YES and FAIL_ON_WARNINGS.
|
||||
# The default value is: NO.
|
||||
|
||||
WARN_AS_ERROR = NO
|
||||
WARN_NO_PARAMDOC = NO
|
||||
|
||||
# The WARN_FORMAT tag determines the format of the warning messages that doxygen
|
||||
# can produce. The string should contain the $file, $line, and $text tags, which
|
||||
@@ -851,42 +755,30 @@ WARN_LOGFILE =
|
||||
# The INPUT tag is used to specify the files and/or directories that contain
|
||||
# documented source files. You may enter file names like myfile.cpp or
|
||||
# directories like /usr/src/myproject. Separate the files or directories with
|
||||
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
|
||||
# spaces.
|
||||
# Note: If this tag is empty the current directory is searched.
|
||||
|
||||
INPUT = jerry-core \
|
||||
jerry-ext \
|
||||
jerry-port
|
||||
INPUT = jerry-core jerry-libc
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||
# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
|
||||
# documentation (see:
|
||||
# https://www.gnu.org/software/libiconv/) for the list of possible encodings.
|
||||
# documentation (see: http://www.gnu.org/software/libiconv) for the list of
|
||||
# possible encodings.
|
||||
# The default value is: UTF-8.
|
||||
|
||||
INPUT_ENCODING = UTF-8
|
||||
|
||||
# If the value of the INPUT tag contains directories, you can use the
|
||||
# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and
|
||||
# *.h) to filter out the source-files in the directories.
|
||||
#
|
||||
# Note that for custom extensions or not directly supported extensions you also
|
||||
# need to set EXTENSION_MAPPING for the extension otherwise the files are not
|
||||
# read by doxygen.
|
||||
#
|
||||
# Note the list of default checked file patterns might differ from the list of
|
||||
# default file extension mappings.
|
||||
#
|
||||
# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
|
||||
# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
|
||||
# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
|
||||
# *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment),
|
||||
# *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, *.vhdl,
|
||||
# *.ucf, *.qsf and *.ice.
|
||||
# *.h) to filter out the source-files in the directories. If left blank the
|
||||
# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii,
|
||||
# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp,
|
||||
# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown,
|
||||
# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf,
|
||||
# *.qsf, *.as and *.js.
|
||||
|
||||
FILE_PATTERNS = *.h \
|
||||
*.c
|
||||
FILE_PATTERNS =
|
||||
|
||||
# The RECURSIVE tag can be used to specify whether or not subdirectories should
|
||||
# be searched for input files as well.
|
||||
@@ -901,19 +793,7 @@ RECURSIVE = YES
|
||||
# Note that relative paths are relative to the directory from which doxygen is
|
||||
# run.
|
||||
|
||||
# FIXME: None of these files are excluded light-heartedly. They should be
|
||||
# removed one-by-one and warnings reported by doxygen should be fixed by those
|
||||
# who are familiar with the undocumented parts.
|
||||
EXCLUDE = jerry-core/ecma/base/ecma-globals.h \
|
||||
jerry-core/ecma/operations/ecma-exceptions.h \
|
||||
jerry-core/include/jerryscript-debugger-transport.h \
|
||||
jerry-core/jcontext/jcontext.h \
|
||||
jerry-core/parser/js/byte-code.h \
|
||||
jerry-core/parser/js/common.h \
|
||||
jerry-core/parser/js/js-lexer.h \
|
||||
jerry-core/parser/js/js-parser-internal.h \
|
||||
jerry-core/parser/regexp/re-parser.h \
|
||||
jerry-core/vm/vm-stack.h
|
||||
EXCLUDE =
|
||||
|
||||
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
||||
# directories that are symbolic links (a Unix file system feature) are excluded
|
||||
@@ -929,7 +809,7 @@ EXCLUDE_SYMLINKS = NO
|
||||
# Note that the wildcards are matched against the file with absolute path, so to
|
||||
# exclude all test directories for example use the pattern */test/*
|
||||
|
||||
EXCLUDE_PATTERNS = *.inc.h
|
||||
EXCLUDE_PATTERNS =
|
||||
|
||||
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
|
||||
# (namespaces, classes, functions, etc.) that should be excluded from the
|
||||
@@ -982,10 +862,6 @@ IMAGE_PATH =
|
||||
# Note that the filter must not add or remove lines; it is applied before the
|
||||
# code is scanned, but not when the output code is generated. If lines are added
|
||||
# or removed, the anchors will not be placed correctly.
|
||||
#
|
||||
# Note that for custom extensions or not directly supported extensions you also
|
||||
# need to set EXTENSION_MAPPING for the extension otherwise the files are not
|
||||
# properly processed by doxygen.
|
||||
|
||||
INPUT_FILTER =
|
||||
|
||||
@@ -995,10 +871,6 @@ INPUT_FILTER =
|
||||
# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how
|
||||
# filters are used. If the FILTER_PATTERNS tag is empty or if none of the
|
||||
# patterns match the file name, INPUT_FILTER is applied.
|
||||
#
|
||||
# Note that for custom extensions or not directly supported extensions you also
|
||||
# need to set EXTENSION_MAPPING for the extension otherwise the files are not
|
||||
# properly processed by doxygen.
|
||||
|
||||
FILTER_PATTERNS =
|
||||
|
||||
@@ -1051,7 +923,7 @@ INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
|
||||
# If the REFERENCED_BY_RELATION tag is set to YES then for each documented
|
||||
# entity all documented functions referencing it will be listed.
|
||||
# function all documented functions referencing it will be listed.
|
||||
# The default value is: NO.
|
||||
|
||||
REFERENCED_BY_RELATION = NO
|
||||
@@ -1083,12 +955,12 @@ SOURCE_TOOLTIPS = YES
|
||||
# If the USE_HTAGS tag is set to YES then the references to source code will
|
||||
# point to the HTML generated by the htags(1) tool instead of doxygen built-in
|
||||
# source browser. The htags tool is part of GNU's global source tagging system
|
||||
# (see https://www.gnu.org/software/global/global.html). You will need version
|
||||
# (see http://www.gnu.org/software/global/global.html). You will need version
|
||||
# 4.8.6 or higher.
|
||||
#
|
||||
# To use it do the following:
|
||||
# - Install the latest version of global
|
||||
# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file
|
||||
# - Enable SOURCE_BROWSER and USE_HTAGS in the config file
|
||||
# - Make sure the INPUT points to the root of the source tree
|
||||
# - Run doxygen as normal
|
||||
#
|
||||
@@ -1111,22 +983,16 @@ USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = YES
|
||||
|
||||
# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the
|
||||
# clang parser (see:
|
||||
# http://clang.llvm.org/) for more accurate parsing at the cost of reduced
|
||||
# performance. This can be particularly helpful with template rich C++ code for
|
||||
# which doxygen's built-in parser lacks the necessary type information.
|
||||
# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the
|
||||
# cost of reduced performance. This can be particularly helpful with template
|
||||
# rich C++ code for which doxygen's built-in parser lacks the necessary type
|
||||
# information.
|
||||
# Note: The availability of this option depends on whether or not doxygen was
|
||||
# generated with the -Duse_libclang=ON option for CMake.
|
||||
# compiled with the --with-libclang option.
|
||||
# The default value is: NO.
|
||||
|
||||
CLANG_ASSISTED_PARSING = NO
|
||||
|
||||
# If clang assisted parsing is enabled and the CLANG_ADD_INC_PATHS tag is set to
|
||||
# YES then doxygen will add the directory of each input to the include path.
|
||||
# The default value is: YES.
|
||||
|
||||
CLANG_ADD_INC_PATHS = YES
|
||||
|
||||
# If clang assisted parsing is enabled you can provide the compiler with command
|
||||
# line options that you would normally use when invoking the compiler. Note that
|
||||
# the include paths will already be set by doxygen for the files and directories
|
||||
@@ -1135,19 +1001,6 @@ CLANG_ADD_INC_PATHS = YES
|
||||
|
||||
CLANG_OPTIONS =
|
||||
|
||||
# If clang assisted parsing is enabled you can provide the clang parser with the
|
||||
# path to the directory containing a file called compile_commands.json. This
|
||||
# file is the compilation database (see:
|
||||
# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the
|
||||
# options used when the source files were built. This is equivalent to
|
||||
# specifying the -p option to a clang tool, such as clang-check. These options
|
||||
# will then be passed to the parser. Any options specified with CLANG_OPTIONS
|
||||
# will be added as well.
|
||||
# Note: The availability of this option depends on whether or not doxygen was
|
||||
# generated with the -Duse_libclang=ON option for CMake.
|
||||
|
||||
CLANG_DATABASE_PATH =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -1159,6 +1012,13 @@ CLANG_DATABASE_PATH =
|
||||
|
||||
ALPHABETICAL_INDEX = YES
|
||||
|
||||
# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
|
||||
# which the alphabetical index list will be split.
|
||||
# Minimum value: 1, maximum value: 20, default value: 5.
|
||||
# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
|
||||
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
|
||||
# In case all classes in a project start with a common prefix, all classes will
|
||||
# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
|
||||
# can be used to specify a prefix (or a list of prefixes) that should be ignored
|
||||
@@ -1259,7 +1119,7 @@ HTML_EXTRA_FILES =
|
||||
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
|
||||
# will adjust the colors in the style sheet and background images according to
|
||||
# this color. Hue is specified as an angle on a colorwheel, see
|
||||
# https://en.wikipedia.org/wiki/Hue for more information. For instance the value
|
||||
# http://en.wikipedia.org/wiki/Hue for more information. For instance the value
|
||||
# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
|
||||
# purple, and 360 is red again.
|
||||
# Minimum value: 0, maximum value: 359, default value: 220.
|
||||
@@ -1295,17 +1155,6 @@ HTML_COLORSTYLE_GAMMA = 80
|
||||
|
||||
HTML_TIMESTAMP = NO
|
||||
|
||||
# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
|
||||
# documentation will contain a main index with vertical navigation menus that
|
||||
# are dynamically created via JavaScript. If disabled, the navigation index will
|
||||
# consists of multiple levels of tabs that are statically embedded in every HTML
|
||||
# page. Disable this option to support browsers that do not have JavaScript,
|
||||
# like the Qt help browser.
|
||||
# The default value is: YES.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
HTML_DYNAMIC_MENUS = YES
|
||||
|
||||
# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
|
||||
# documentation will contain sections that can be hidden and shown after the
|
||||
# page has loaded.
|
||||
@@ -1329,14 +1178,13 @@ HTML_INDEX_NUM_ENTRIES = 100
|
||||
|
||||
# If the GENERATE_DOCSET tag is set to YES, additional index files will be
|
||||
# generated that can be used as input for Apple's Xcode 3 integrated development
|
||||
# environment (see:
|
||||
# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To
|
||||
# create a documentation set, doxygen will generate a Makefile in the HTML
|
||||
# output directory. Running make will produce the docset in that directory and
|
||||
# running make install will install the docset in
|
||||
# environment (see: http://developer.apple.com/tools/xcode/), introduced with
|
||||
# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a
|
||||
# Makefile in the HTML output directory. Running make will produce the docset in
|
||||
# that directory and running make install will install the docset in
|
||||
# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
|
||||
# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy
|
||||
# genXcode/_index.html for more information.
|
||||
# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
|
||||
# for more information.
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
@@ -1375,8 +1223,8 @@ DOCSET_PUBLISHER_NAME = Publisher
|
||||
# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
|
||||
# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
|
||||
# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
|
||||
# (see:
|
||||
# https://www.microsoft.com/en-us/download/details.aspx?id=21138) on Windows.
|
||||
# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on
|
||||
# Windows.
|
||||
#
|
||||
# The HTML Help Workshop contains a compiler that can convert all HTML output
|
||||
# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML
|
||||
@@ -1406,7 +1254,7 @@ CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
|
||||
# The GENERATE_CHI flag controls if a separate .chi index file is generated
|
||||
# (YES) or that it should be included in the main .chm file (NO).
|
||||
# (YES) or that it should be included in the master .chm file (NO).
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
|
||||
|
||||
@@ -1451,8 +1299,7 @@ QCH_FILE =
|
||||
|
||||
# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
|
||||
# Project output. For more information please see Qt Help Project / Namespace
|
||||
# (see:
|
||||
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace).
|
||||
# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace).
|
||||
# The default value is: org.doxygen.Project.
|
||||
# This tag requires that the tag GENERATE_QHP is set to YES.
|
||||
|
||||
@@ -1460,8 +1307,8 @@ QHP_NAMESPACE = org.doxygen.Project
|
||||
|
||||
# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
|
||||
# Help Project output. For more information please see Qt Help Project / Virtual
|
||||
# Folders (see:
|
||||
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders).
|
||||
# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual-
|
||||
# folders).
|
||||
# The default value is: doc.
|
||||
# This tag requires that the tag GENERATE_QHP is set to YES.
|
||||
|
||||
@@ -1469,30 +1316,30 @@ QHP_VIRTUAL_FOLDER = doc
|
||||
|
||||
# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
|
||||
# filter to add. For more information please see Qt Help Project / Custom
|
||||
# Filters (see:
|
||||
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters).
|
||||
# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
|
||||
# filters).
|
||||
# This tag requires that the tag GENERATE_QHP is set to YES.
|
||||
|
||||
QHP_CUST_FILTER_NAME =
|
||||
|
||||
# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
|
||||
# custom filter to add. For more information please see Qt Help Project / Custom
|
||||
# Filters (see:
|
||||
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters).
|
||||
# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
|
||||
# filters).
|
||||
# This tag requires that the tag GENERATE_QHP is set to YES.
|
||||
|
||||
QHP_CUST_FILTER_ATTRS =
|
||||
|
||||
# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
|
||||
# project's filter section matches. Qt Help Project / Filter Attributes (see:
|
||||
# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes).
|
||||
# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes).
|
||||
# This tag requires that the tag GENERATE_QHP is set to YES.
|
||||
|
||||
QHP_SECT_FILTER_ATTRS =
|
||||
|
||||
# The QHG_LOCATION tag can be used to specify the location (absolute path
|
||||
# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to
|
||||
# run qhelpgenerator on the generated .qhp file.
|
||||
# The QHG_LOCATION tag can be used to specify the location of Qt's
|
||||
# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the
|
||||
# generated .qhp file.
|
||||
# This tag requires that the tag GENERATE_QHP is set to YES.
|
||||
|
||||
QHG_LOCATION =
|
||||
@@ -1569,17 +1416,6 @@ TREEVIEW_WIDTH = 250
|
||||
|
||||
EXT_LINKS_IN_WINDOW = NO
|
||||
|
||||
# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg
|
||||
# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see
|
||||
# https://inkscape.org) to generate formulas as SVG images instead of PNGs for
|
||||
# the HTML output. These images will generally look nicer at scaled resolutions.
|
||||
# Possible values are: png (the default) and svg (looks nicer but requires the
|
||||
# pdf2svg or inkscape tool).
|
||||
# The default value is: png.
|
||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||
|
||||
HTML_FORMULA_FORMAT = png
|
||||
|
||||
# Use this tag to change the font size of LaTeX formulas included as images in
|
||||
# the HTML documentation. When you change the font size after a successful
|
||||
# doxygen run you need to manually remove any form_*.png images from the HTML
|
||||
@@ -1589,7 +1425,7 @@ HTML_FORMULA_FORMAT = png
|
||||
|
||||
FORMULA_FONTSIZE = 10
|
||||
|
||||
# Use the FORMULA_TRANSPARENT tag to determine whether or not the images
|
||||
# Use the FORMULA_TRANPARENT tag to determine whether or not the images
|
||||
# generated for formulas are transparent PNGs. Transparent PNGs are not
|
||||
# supported properly for IE 6.0, but are supported on all modern browsers.
|
||||
#
|
||||
@@ -1600,14 +1436,8 @@ FORMULA_FONTSIZE = 10
|
||||
|
||||
FORMULA_TRANSPARENT = YES
|
||||
|
||||
# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands
|
||||
# to create new LaTeX commands to be used in formulas as building blocks. See
|
||||
# the section "Including formulas" for details.
|
||||
|
||||
FORMULA_MACROFILE =
|
||||
|
||||
# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
|
||||
# https://www.mathjax.org) which uses client side JavaScript for the rendering
|
||||
# http://www.mathjax.org) which uses client side Javascript for the rendering
|
||||
# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
|
||||
# installed or if you want to formulas look prettier in the HTML output. When
|
||||
# enabled you may also need to install MathJax separately and configure the path
|
||||
@@ -1619,7 +1449,7 @@ USE_MATHJAX = NO
|
||||
|
||||
# When MathJax is enabled you can set the default output format to be used for
|
||||
# the MathJax output. See the MathJax site (see:
|
||||
# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details.
|
||||
# http://docs.mathjax.org/en/latest/output.html) for more details.
|
||||
# Possible values are: HTML-CSS (which is slower, but has the best
|
||||
# compatibility), NativeMML (i.e. MathML) and SVG.
|
||||
# The default value is: HTML-CSS.
|
||||
@@ -1634,8 +1464,8 @@ MATHJAX_FORMAT = HTML-CSS
|
||||
# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
|
||||
# Content Delivery Network so you can quickly see the result without installing
|
||||
# MathJax. However, it is strongly recommended to install a local copy of
|
||||
# MathJax from https://www.mathjax.org before deployment.
|
||||
# The default value is: https://cdn.jsdelivr.net/npm/mathjax@2.
|
||||
# MathJax from http://www.mathjax.org before deployment.
|
||||
# The default value is: http://cdn.mathjax.org/mathjax/latest.
|
||||
# This tag requires that the tag USE_MATHJAX is set to YES.
|
||||
|
||||
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
|
||||
@@ -1649,8 +1479,7 @@ MATHJAX_EXTENSIONS =
|
||||
|
||||
# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces
|
||||
# of code that will be used on startup of the MathJax code. See the MathJax site
|
||||
# (see:
|
||||
# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an
|
||||
# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an
|
||||
# example see the documentation.
|
||||
# This tag requires that the tag USE_MATHJAX is set to YES.
|
||||
|
||||
@@ -1678,7 +1507,7 @@ MATHJAX_CODEFILE =
|
||||
SEARCHENGINE = YES
|
||||
|
||||
# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
|
||||
# implemented using a web server instead of a web client using JavaScript. There
|
||||
# implemented using a web server instead of a web client using Javascript. There
|
||||
# are two flavors of web server based searching depending on the EXTERNAL_SEARCH
|
||||
# setting. When disabled, doxygen will generate a PHP script for searching and
|
||||
# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing
|
||||
@@ -1697,8 +1526,7 @@ SERVER_BASED_SEARCH = NO
|
||||
#
|
||||
# Doxygen ships with an example indexer (doxyindexer) and search engine
|
||||
# (doxysearch.cgi) which are based on the open source search engine library
|
||||
# Xapian (see:
|
||||
# https://xapian.org/).
|
||||
# Xapian (see: http://xapian.org/).
|
||||
#
|
||||
# See the section "External Indexing and Searching" for details.
|
||||
# The default value is: NO.
|
||||
@@ -1711,9 +1539,8 @@ EXTERNAL_SEARCH = NO
|
||||
#
|
||||
# Doxygen ships with an example indexer (doxyindexer) and search engine
|
||||
# (doxysearch.cgi) which are based on the open source search engine library
|
||||
# Xapian (see:
|
||||
# https://xapian.org/). See the section "External Indexing and Searching" for
|
||||
# details.
|
||||
# Xapian (see: http://xapian.org/). See the section "External Indexing and
|
||||
# Searching" for details.
|
||||
# This tag requires that the tag SEARCHENGINE is set to YES.
|
||||
|
||||
SEARCHENGINE_URL =
|
||||
@@ -1764,35 +1591,21 @@ LATEX_OUTPUT = latex
|
||||
# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
|
||||
# invoked.
|
||||
#
|
||||
# Note that when not enabling USE_PDFLATEX the default is latex when enabling
|
||||
# USE_PDFLATEX the default is pdflatex and when in the later case latex is
|
||||
# chosen this is overwritten by pdflatex. For specific output languages the
|
||||
# default can have been set differently, this depends on the implementation of
|
||||
# the output language.
|
||||
# Note that when enabling USE_PDFLATEX this option is only used for generating
|
||||
# bitmaps for formulas in the HTML output, but not in the Makefile that is
|
||||
# written to the output directory.
|
||||
# The default file is: latex.
|
||||
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
||||
|
||||
LATEX_CMD_NAME = latex
|
||||
|
||||
# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate
|
||||
# index for LaTeX.
|
||||
# Note: This tag is used in the Makefile / make.bat.
|
||||
# See also: LATEX_MAKEINDEX_CMD for the part in the generated output file
|
||||
# (.tex).
|
||||
# The default file is: makeindex.
|
||||
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
||||
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
|
||||
# The LATEX_MAKEINDEX_CMD tag can be used to specify the command name to
|
||||
# generate index for LaTeX. In case there is no backslash (\) as first character
|
||||
# it will be automatically added in the LaTeX code.
|
||||
# Note: This tag is used in the generated output file (.tex).
|
||||
# See also: MAKEINDEX_CMD_NAME for the part in the Makefile / make.bat.
|
||||
# The default value is: makeindex.
|
||||
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
||||
|
||||
LATEX_MAKEINDEX_CMD = makeindex
|
||||
|
||||
# If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX
|
||||
# documents. This may be useful for small projects and may help to save some
|
||||
# trees in general.
|
||||
@@ -1811,12 +1624,9 @@ COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4
|
||||
|
||||
# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names
|
||||
# that should be included in the LaTeX output. The package can be specified just
|
||||
# by its name or with the correct syntax as to be used with the LaTeX
|
||||
# \usepackage command. To get the times font for instance you can specify :
|
||||
# EXTRA_PACKAGES=times or EXTRA_PACKAGES={times}
|
||||
# To use the option intlimits with the amsmath package you can specify:
|
||||
# EXTRA_PACKAGES=[intlimits]{amsmath}
|
||||
# that should be included in the LaTeX output. To get the times font for
|
||||
# instance you can specify
|
||||
# EXTRA_PACKAGES=times
|
||||
# If left blank no extra packages will be included.
|
||||
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
||||
|
||||
@@ -1877,11 +1687,9 @@ LATEX_EXTRA_FILES =
|
||||
|
||||
PDF_HYPERLINKS = YES
|
||||
|
||||
# If the USE_PDFLATEX tag is set to YES, doxygen will use the engine as
|
||||
# specified with LATEX_CMD_NAME to generate the PDF file directly from the LaTeX
|
||||
# files. Set this option to YES, to get a higher quality PDF documentation.
|
||||
#
|
||||
# See also section LATEX_CMD_NAME for selecting the engine.
|
||||
# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
|
||||
# the PDF file directly from the LaTeX files. Set this option to YES, to get a
|
||||
# higher quality PDF documentation.
|
||||
# The default value is: YES.
|
||||
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
||||
|
||||
@@ -1915,28 +1723,12 @@ LATEX_SOURCE_CODE = NO
|
||||
|
||||
# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
|
||||
# bibliography, e.g. plainnat, or ieeetr. See
|
||||
# https://en.wikipedia.org/wiki/BibTeX and \cite for more info.
|
||||
# http://en.wikipedia.org/wiki/BibTeX and \cite for more info.
|
||||
# The default value is: plain.
|
||||
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
||||
|
||||
LATEX_BIB_STYLE = plain
|
||||
|
||||
# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated
|
||||
# page will contain the date and time when the page was generated. Setting this
|
||||
# to NO can help when comparing the output of multiple runs.
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
||||
|
||||
LATEX_TIMESTAMP = NO
|
||||
|
||||
# The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute)
|
||||
# path from which the emoji images will be read. If a relative path is entered,
|
||||
# it will be relative to the LATEX_OUTPUT directory. If left blank the
|
||||
# LATEX_OUTPUT directory will be used.
|
||||
# This tag requires that the tag GENERATE_LATEX is set to YES.
|
||||
|
||||
LATEX_EMOJI_DIRECTORY =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -1976,9 +1768,9 @@ COMPACT_RTF = NO
|
||||
|
||||
RTF_HYPERLINKS = NO
|
||||
|
||||
# Load stylesheet definitions from file. Syntax is similar to doxygen's
|
||||
# configuration file, i.e. a series of assignments. You only have to provide
|
||||
# replacements, missing definitions are set to their default value.
|
||||
# Load stylesheet definitions from file. Syntax is similar to doxygen's config
|
||||
# file, i.e. a series of assignments. You only have to provide replacements,
|
||||
# missing definitions are set to their default value.
|
||||
#
|
||||
# See also section "Doxygen usage" for information on how to generate the
|
||||
# default style sheet that doxygen normally uses.
|
||||
@@ -1987,8 +1779,8 @@ RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
|
||||
# Set optional variables used in the generation of an RTF document. Syntax is
|
||||
# similar to doxygen's configuration file. A template extensions file can be
|
||||
# generated using doxygen -e rtf extensionFile.
|
||||
# similar to doxygen's config file. A template extensions file can be generated
|
||||
# using doxygen -e rtf extensionFile.
|
||||
# This tag requires that the tag GENERATE_RTF is set to YES.
|
||||
|
||||
RTF_EXTENSIONS_FILE =
|
||||
@@ -2074,13 +1866,6 @@ XML_OUTPUT = xml
|
||||
|
||||
XML_PROGRAMLISTING = YES
|
||||
|
||||
# If the XML_NS_MEMB_FILE_SCOPE tag is set to YES, doxygen will include
|
||||
# namespace members in file scope as well, matching the HTML output.
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag GENERATE_XML is set to YES.
|
||||
|
||||
XML_NS_MEMB_FILE_SCOPE = NO
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the DOCBOOK output
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -2113,9 +1898,9 @@ DOCBOOK_PROGRAMLISTING = NO
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an
|
||||
# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures
|
||||
# the structure of the code including all documentation. Note that this feature
|
||||
# is still experimental and incomplete at the moment.
|
||||
# AutoGen Definitions (see http://autogen.sf.net) file that captures the
|
||||
# structure of the code including all documentation. Note that this feature is
|
||||
# still experimental and incomplete at the moment.
|
||||
# The default value is: NO.
|
||||
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
@@ -2175,7 +1960,7 @@ ENABLE_PREPROCESSING = YES
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
|
||||
|
||||
MACRO_EXPANSION = YES
|
||||
MACRO_EXPANSION = NO
|
||||
|
||||
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
|
||||
# the macro expansion is limited to the macros specified with the PREDEFINED and
|
||||
@@ -2183,7 +1968,7 @@ MACRO_EXPANSION = YES
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
|
||||
|
||||
EXPAND_ONLY_PREDEF = YES
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
|
||||
# If the SEARCH_INCLUDES tag is set to YES, the include files in the
|
||||
# INCLUDE_PATH will be searched if a #include is found.
|
||||
@@ -2215,15 +2000,7 @@ INCLUDE_FILE_PATTERNS =
|
||||
# recursively expanded use the := operator instead of the = operator.
|
||||
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
|
||||
|
||||
PREDEFINED = "JERRY_STATIC_ASSERT(x,y)=" \
|
||||
"JERRY_ATTR_FORMAT(x,y,z)=" \
|
||||
"JERRY_ATTR_ALWAYS_INLINE=" \
|
||||
"JERRY_ATTR_NOINLINE=" \
|
||||
"JERRY_ATTR_PURE=" \
|
||||
"JERRY_ATTR_CONST=" \
|
||||
"JERRY_ATTR_HOT=" \
|
||||
"JERRY_ATTR_NORETURN=" \
|
||||
"JERRY_ATTR_WEAK="
|
||||
PREDEFINED =
|
||||
|
||||
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
|
||||
# tag can be used to specify a list of macro names that should be expanded. The
|
||||
@@ -2290,6 +2067,12 @@ EXTERNAL_GROUPS = YES
|
||||
|
||||
EXTERNAL_PAGES = YES
|
||||
|
||||
# The PERL_PATH should be the absolute path and name of the perl script
|
||||
# interpreter (i.e. the result of 'which perl').
|
||||
# The default file (with absolute path) is: /usr/bin/perl.
|
||||
|
||||
PERL_PATH = /usr/bin/perl
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -2303,6 +2086,15 @@ EXTERNAL_PAGES = YES
|
||||
|
||||
CLASS_DIAGRAMS = YES
|
||||
|
||||
# You can define message sequence charts within doxygen comments using the \msc
|
||||
# command. Doxygen will then run the mscgen tool (see:
|
||||
# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the
|
||||
# documentation. The MSCGEN_PATH tag allows you to specify the directory where
|
||||
# the mscgen tool resides. If left empty the tool is assumed to be found in the
|
||||
# default search path.
|
||||
|
||||
MSCGEN_PATH =
|
||||
|
||||
# You can include diagrams made with dia in doxygen documentation. Doxygen will
|
||||
# then run dia to produce the diagram and insert it in the documentation. The
|
||||
# DIA_PATH tag allows you to specify the directory where the dia binary resides.
|
||||
@@ -2400,31 +2192,9 @@ UML_LOOK = NO
|
||||
# but if the number exceeds 15, the total amount of fields shown is limited to
|
||||
# 10.
|
||||
# Minimum value: 0, maximum value: 100, default value: 10.
|
||||
# This tag requires that the tag UML_LOOK is set to YES.
|
||||
|
||||
UML_LIMIT_NUM_FIELDS = 10
|
||||
|
||||
# If the DOT_UML_DETAILS tag is set to NO, doxygen will show attributes and
|
||||
# methods without types and arguments in the UML graphs. If the DOT_UML_DETAILS
|
||||
# tag is set to YES, doxygen will add type and arguments for attributes and
|
||||
# methods in the UML graphs. If the DOT_UML_DETAILS tag is set to NONE, doxygen
|
||||
# will not generate fields with class member information in the UML graphs. The
|
||||
# class diagrams will look similar to the default class diagrams but using UML
|
||||
# notation for the relationships.
|
||||
# Possible values are: NO, YES and NONE.
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag UML_LOOK is set to YES.
|
||||
|
||||
DOT_UML_DETAILS = NO
|
||||
|
||||
# The DOT_WRAP_THRESHOLD tag can be used to set the maximum number of characters
|
||||
# to display on a single line. If the actual line length exceeds this threshold
|
||||
# significantly it will wrapped across multiple lines. Some heuristics are apply
|
||||
# to avoid ugly line breaks.
|
||||
# Minimum value: 0, maximum value: 1000, default value: 17.
|
||||
# This tag requires that the tag HAVE_DOT is set to YES.
|
||||
|
||||
DOT_WRAP_THRESHOLD = 17
|
||||
UML_LIMIT_NUM_FIELDS = 10
|
||||
|
||||
# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and
|
||||
# collaboration graphs will show the relations between templates and their
|
||||
@@ -2457,8 +2227,7 @@ INCLUDED_BY_GRAPH = YES
|
||||
#
|
||||
# Note that enabling this option will significantly increase the time of a run.
|
||||
# So in most cases it will be better to enable call graphs for selected
|
||||
# functions only using the \callgraph command. Disabling a call graph can be
|
||||
# accomplished by means of the command \hidecallgraph.
|
||||
# functions only using the \callgraph command.
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag HAVE_DOT is set to YES.
|
||||
|
||||
@@ -2469,8 +2238,7 @@ CALL_GRAPH = NO
|
||||
#
|
||||
# Note that enabling this option will significantly increase the time of a run.
|
||||
# So in most cases it will be better to enable caller graphs for selected
|
||||
# functions only using the \callergraph command. Disabling a caller graph can be
|
||||
# accomplished by means of the command \hidecallergraph.
|
||||
# functions only using the \callergraph command.
|
||||
# The default value is: NO.
|
||||
# This tag requires that the tag HAVE_DOT is set to YES.
|
||||
|
||||
@@ -2493,17 +2261,13 @@ GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
|
||||
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
|
||||
# generated by dot. For an explanation of the image formats see the section
|
||||
# output formats in the documentation of the dot tool (Graphviz (see:
|
||||
# http://www.graphviz.org/)).
|
||||
# generated by dot.
|
||||
# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order
|
||||
# to make the SVG files visible in IE 9+ (other browsers do not have this
|
||||
# requirement).
|
||||
# Possible values are: png, png:cairo, png:cairo:cairo, png:cairo:gd, png:gd,
|
||||
# png:gd:gd, jpg, jpg:cairo, jpg:cairo:gd, jpg:gd, jpg:gd:gd, gif, gif:cairo,
|
||||
# gif:cairo:gd, gif:gd, gif:gd:gd, svg, png:gd, png:gd:gd, png:cairo,
|
||||
# png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and
|
||||
# png:gdiplus:gdiplus.
|
||||
# gif:cairo:gd, gif:gd, gif:gd:gd and svg.
|
||||
# The default value is: png.
|
||||
# This tag requires that the tag HAVE_DOT is set to YES.
|
||||
|
||||
@@ -2554,11 +2318,6 @@ DIAFILE_DIRS =
|
||||
|
||||
PLANTUML_JAR_PATH =
|
||||
|
||||
# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a
|
||||
# configuration file for plantuml.
|
||||
|
||||
PLANTUML_CFG_FILE =
|
||||
|
||||
# When using plantuml, the specified paths are searched for files specified by
|
||||
# the !include statement in a plantuml block.
|
||||
|
||||
@@ -2617,11 +2376,9 @@ DOT_MULTI_TARGETS = NO
|
||||
|
||||
GENERATE_LEGEND = YES
|
||||
|
||||
# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate
|
||||
# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot
|
||||
# files that are used to generate the various graphs.
|
||||
#
|
||||
# Note: This setting is not only used for dot files but also for msc and
|
||||
# plantuml temporary files.
|
||||
# The default value is: YES.
|
||||
# This tag requires that the tag HAVE_DOT is set to YES.
|
||||
|
||||
DOT_CLEANUP = YES
|
||||
|
||||
@@ -1,203 +1,13 @@
|
||||
Copyright JS Foundation and other contributors, http://js.foundation
|
||||
Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
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
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
@@ -1,30 +1,27 @@
|
||||

|
||||

|
||||
# JerryScript: JavaScript engine for the Internet of Things
|
||||
[](LICENSE)
|
||||
[](https://github.com/jerryscript-project/jerryscript/actions)
|
||||
[](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)
|
||||
[](https://travis-ci.org/Samsung/jerryscript)
|
||||
|
||||
JerryScript is a lightweight JavaScript engine for resource-constrained devices such as microcontrollers. It can run on devices with less than 64 KB of RAM and less than 200 KB of flash memory.
|
||||
|
||||
Key characteristics of JerryScript:
|
||||
* Full ECMAScript 5.1 standard compliance
|
||||
* 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
|
||||
* 160K 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
|
||||
* Mature C API, easy to embed in applications
|
||||
|
||||
Additional information can be found on our [project page](http://jerryscript.net) and [Wiki](https://github.com/jerryscript-project/jerryscript/wiki).
|
||||
Additional information can be found on our [project page](http://samsung.github.io/jerryscript) and [Wiki](https://github.com/Samsung/jerryscript/wiki).
|
||||
|
||||
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).
|
||||
IRC channel: #jerryscript on [freenode](https://freenode.net)
|
||||
Mailing list: jerryscript-dev@gna.org, you can subscribe [here](https://mail.gna.org/listinfo/jerryscript-dev) and access the mailing list archive [here](https://mail.gna.org/public/jerryscript-dev).
|
||||
|
||||
## Quick Start
|
||||
### Getting the sources
|
||||
```bash
|
||||
git clone https://github.com/jerryscript-project/jerryscript.git
|
||||
git clone https://github.com/Samsung/jerryscript.git
|
||||
cd jerryscript
|
||||
```
|
||||
|
||||
@@ -33,34 +30,17 @@ cd jerryscript
|
||||
python tools/build.py
|
||||
```
|
||||
|
||||
For additional information see [Getting Started](docs/00.GETTING-STARTED.md).
|
||||
For additional information see [Getting Started](docs/01.GETTING-STARTED.md).
|
||||
|
||||
## Documentation
|
||||
- [Getting Started](docs/00.GETTING-STARTED.md)
|
||||
- [Configuration](docs/01.CONFIGURATION.md)
|
||||
- [Getting Started](docs/01.GETTING-STARTED.md)
|
||||
- [API Reference](docs/02.API-REFERENCE.md)
|
||||
- [API Example](docs/03.API-EXAMPLE.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
|
||||
The project can only accept contributions which are licensed under the [Apache License 2.0](LICENSE) and are signed according to the JerryScript [Developer's Certificate of Origin](DCO.md). For further information please see our [Contribution Guidelines](CONTRIBUTING.md).
|
||||
- [Internals](docs/04.INTERNALS.md)
|
||||
|
||||
## License
|
||||
JerryScript is open source software under the [Apache License 2.0](LICENSE). Complete license and copyright information can be found in the source code.
|
||||
JerryScript is Open Source software under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). Complete license and copyright information can be found in the source code.
|
||||
|
||||
[](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fjerryscript-project%2Fjerryscript?ref=badge_large)
|
||||
|
||||
> Copyright JS Foundation and other contributors, http://js.foundation
|
||||
> Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
|
||||
> 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.
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
# Copyright JS Foundation and other contributors, http://js.foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set(CMAKE_SYSTEM_NAME esp-idf)
|
||||
set(CMAKE_SYSTEM_PROCESSOR xtensa)
|
||||
|
||||
set(CMAKE_C_COMPILER xtensa-esp32-elf-gcc)
|
||||
set(CMAKE_CXX_COMPILER xtensa-esp32-elf-g++)
|
||||
set(CMAKE_ASM_COMPILER xtensa-esp32-elf-gcc)
|
||||
|
||||
# uncomment that if you want 4-bytes float (much faster on esp32)
|
||||
#add_definitions(-DJERRY_NUMBER_TYPE_FLOAT64=0)
|
||||
|
||||
set(CMAKE_C_FLAGS "-mlongcalls -Wno-frame-address" CACHE STRING "C Compiler Base Flags")
|
||||
set(CMAKE_CXX_FLAGS "-mlongcalls -Wno-frame-address" CACHE STRING "C++ Compiler Base Flags")
|
||||
|
||||
# Can be removed after gcc 5.2.0 support is removed (ref GCC_NOT_5_2_0)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-nostdlib" CACHE STRING "Linker Base Flags")
|
||||
@@ -0,0 +1,20 @@
|
||||
# Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
#
|
||||
# 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(CMakeForceCompiler)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME EXTERNAL)
|
||||
set(CMAKE_SYSTEM_PROCESSOR "${EXTERNAL_CMAKE_SYSTEM_PROCESSOR}")
|
||||
|
||||
CMAKE_FORCE_C_COMPILER(${EXTERNAL_CMAKE_C_COMPILER} ${EXTERNAL_CMAKE_C_COMPILER_ID})
|
||||
@@ -1,18 +0,0 @@
|
||||
# Copyright JS Foundation and other contributors, http://js.foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR aarch64)
|
||||
|
||||
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright JS Foundation and other contributors, http://js.foundation
|
||||
# Copyright 2015-2016 Samsung Electronics Co., Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright JS Foundation and other contributors, http://js.foundation
|
||||
# Copyright 2015-2016 Samsung Electronics Co., Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# Copyright JS Foundation and other contributors, http://js.foundation
|
||||
# Copyright 2016 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2016 University of Szeged.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright JS Foundation and other contributors, http://js.foundation
|
||||
# Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -12,11 +12,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
include(CMakeForceCompiler)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME MCU)
|
||||
set(CMAKE_SYSTEM_PROCESSOR armv7l)
|
||||
set(CMAKE_SYSTEM_VERSION STM32F3)
|
||||
|
||||
set(FLAGS_COMMON_ARCH -mlittle-endian -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard)
|
||||
|
||||
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
|
||||
set(CMAKE_C_COMPILER_WORKS TRUE)
|
||||
CMAKE_FORCE_C_COMPILER(arm-none-eabi-gcc GNU)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright JS Foundation and other contributors, http://js.foundation
|
||||
# Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -12,11 +12,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
include(CMakeForceCompiler)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME MCU)
|
||||
set(CMAKE_SYSTEM_PROCESSOR armv7l)
|
||||
set(CMAKE_SYSTEM_VERSION STM32F4)
|
||||
|
||||
set(FLAGS_COMMON_ARCH -mlittle-endian -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard)
|
||||
|
||||
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
|
||||
set(CMAKE_C_COMPILER_WORKS TRUE)
|
||||
CMAKE_FORCE_C_COMPILER(arm-none-eabi-gcc GNU)
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
# Copyright JS Foundation and other contributors, http://js.foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set(CMAKE_SYSTEM_NAME MCU)
|
||||
set(CMAKE_SYSTEM_PROCESSOR armv7l)
|
||||
set(CMAKE_SYSTEM_VERSION STM32F7)
|
||||
|
||||
set(FLAGS_COMMON_ARCH -mthumb -mcpu=cortex-m7 -march=armv7e-m -mfloat-abi=hard)
|
||||
|
||||
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
|
||||
set(CMAKE_C_COMPILER_WORKS TRUE)
|
||||
@@ -1,33 +0,0 @@
|
||||
# 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(CMakeForceCompiler)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME MCU)
|
||||
set(CMAKE_SYSTEM_PROCESSOR armv7l)
|
||||
set(CMAKE_SYSTEM_VERSION TIM4F)
|
||||
|
||||
set(FLAGS_COMMON_ARCH --little_endian --silicon_version=7M4 --float_support=FPv4SPD16)
|
||||
|
||||
CMAKE_FORCE_C_COMPILER(armcl TI)
|
||||
|
||||
SET (CMAKE_C_FLAGS_DEBUG_INIT "-g")
|
||||
SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "-o4 -mf0 -DNDEBUG")
|
||||
SET (CMAKE_C_FLAGS_RELEASE_INIT "-o4 -DNDEBUG")
|
||||
SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-o2 -g")
|
||||
|
||||
SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-g")
|
||||
SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-o4 -mf0 -DNDEBUG")
|
||||
SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-o4 -DNDEBUG")
|
||||
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-o2 -g")
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright JS Foundation and other contributors, http://js.foundation
|
||||
# Copyright 2016 Samsung Electronics Co., Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -15,4 +15,4 @@
|
||||
set(CMAKE_SYSTEM_NAME Openwrt)
|
||||
set(CMAKE_SYSTEM_PROCESSOR mips)
|
||||
|
||||
set(CMAKE_C_COMPILER mips-openwrt-linux-gcc)
|
||||
set(CMAKE_C_COMPILER mipsel-openwrt-linux-gcc)
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
# Copyright JS Foundation and other contributors, http://js.foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Openwrt)
|
||||
set(CMAKE_SYSTEM_PROCESSOR mips)
|
||||
|
||||
set(CMAKE_C_COMPILER mipsel-openwrt-linux-gcc)
|
||||
@@ -1,186 +0,0 @@
|
||||
## Setting up prerequisites
|
||||
|
||||
Currently, only Ubuntu 18.04+ is officially supported as primary development environment.
|
||||
|
||||
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` >= `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` >= `2.7`
|
||||
- `clang-format-15`
|
||||
- `python` >= `3.10`
|
||||
|
||||
```bash
|
||||
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:
|
||||
|
||||
- `awk`
|
||||
- `bc`
|
||||
- `find`
|
||||
- `sed`
|
||||
|
||||
## Building JerryScript
|
||||
|
||||
**To build debug version for Linux**
|
||||
|
||||
```bash
|
||||
python tools/build.py --debug
|
||||
```
|
||||
|
||||
**To build debug version for Linux without LTO (Link Time Optimization)**
|
||||
|
||||
```bash
|
||||
python tools/build.py --debug --lto=off
|
||||
```
|
||||
|
||||
**To enable more verbose outputs for debugging**
|
||||
|
||||
```bash
|
||||
tools/build.py --debug --logging=on --error-messages=on --line-info=on
|
||||
```
|
||||
|
||||
**Add custom arguments to CMake**
|
||||
|
||||
```bash
|
||||
python tools/build.py --cmake-param=CMAKE_PARAM
|
||||
```
|
||||
|
||||
**Set a profile mode (es.next, minimal)**
|
||||
|
||||
```bash
|
||||
python tools/build.py --profile=es.next|minimal
|
||||
```
|
||||
|
||||
See also the related [README.md](../jerry-core/profiles/README.md).
|
||||
|
||||
**Use (compiler-default, external) libc**
|
||||
|
||||
The default libc is the compiler-default libc but you can use an external libc as well:
|
||||
|
||||
- compiler-default libc:
|
||||
|
||||
```bash
|
||||
python tools/build.py
|
||||
```
|
||||
|
||||
- external libc:
|
||||
|
||||
```bash
|
||||
python tools/build.py --compile-flag="-nostdlib -I/path/to/ext-libc/include" --link-lib="ext-c"
|
||||
```
|
||||
|
||||
**Add toolchain file**
|
||||
|
||||
The ```cmake``` dir already contains some usable toolchain files, which you can use in the following format:
|
||||
|
||||
```bash
|
||||
python tools/build.py --toolchain=TOOLCHAIN
|
||||
```
|
||||
|
||||
For example the cross-compile to RaspberryPi 2 is something like this:
|
||||
|
||||
```bash
|
||||
python tools/build.py --toolchain=cmake/toolchain_linux_armv7l.cmake
|
||||
```
|
||||
|
||||
**Use system memory allocator**
|
||||
|
||||
```bash
|
||||
python tools/build.py --system-allocator=on
|
||||
```
|
||||
|
||||
*Note*: System allocator is only supported on 32 bit systems.
|
||||
|
||||
**Enable 32bit compressed pointers**
|
||||
|
||||
```bash
|
||||
python tools/build.py --cpointer-32bit=on
|
||||
```
|
||||
|
||||
*Note*: There is no compression/decompression on 32 bit systems, if enabled.
|
||||
|
||||
**Change default heap size (512K)**
|
||||
|
||||
```bash
|
||||
python tools/build.py --mem-heap=256
|
||||
```
|
||||
|
||||
If you would like to use more than 512K, then you must enable the 32 bit compressed pointers.
|
||||
|
||||
```bash
|
||||
python tools/build.py --cpointer-32bit=on --mem-heap=1024
|
||||
```
|
||||
|
||||
*Note*: The heap size will be allocated statically at compile time, when JerryScript memory
|
||||
allocator is used.
|
||||
|
||||
**To build with libfuzzer support**
|
||||
|
||||
```bash
|
||||
CC=clang python tools/build.py --libfuzzer=on --compile-flag=-fsanitize=address --lto=off
|
||||
```
|
||||
|
||||
Check the documentation of libfuzzer to get the runtime settings of the created fuzzer
|
||||
binary: https://llvm.org/docs/LibFuzzer.html.
|
||||
|
||||
**To get a list of all the available buildoptions for Linux**
|
||||
|
||||
```bash
|
||||
python tools/build.py --help
|
||||
```
|
||||
|
||||
## Checking patch
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --precommit
|
||||
```
|
||||
|
||||
### Running only one type of test
|
||||
|
||||
**To run build option tests**
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --buildoption-test
|
||||
```
|
||||
|
||||
**To run unittests**
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --unittests
|
||||
```
|
||||
|
||||
**To run jerry-tests**
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --jerry-tests
|
||||
```
|
||||
|
||||
**To run signed-off check**
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --check-signed-off
|
||||
```
|
||||
|
||||
**To run cppcheck**
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --check-cppcheck
|
||||
```
|
||||
|
||||
**To run format check**
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --check-format
|
||||
```
|
||||
|
||||
**To get a list of all the available test options**
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --help
|
||||
```
|
||||
@@ -1,400 +0,0 @@
|
||||
# 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 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.
|
||||
|
||||
|
||||
### Amalgamated build
|
||||
|
||||
Enables the amalgamated build process, which aggregates the contents of each source file per library
|
||||
(i.e., JerryScript's core, port, and math libraries), and uses these combined files to compile the project.
|
||||
This process can provide comparable results to link-time optimization, and can be useful when LTO is not available otherwise.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `<none>` |
|
||||
| CMake: | `-DENABLE_AMALGAM=ON/OFF` |
|
||||
| Python: | `--amalgam=ON/OFF` |
|
||||
|
||||
See also: [Amalgamated sources](#amalgamated-sources)
|
||||
|
||||
### Jerry debugger
|
||||
|
||||
Enables debugger support in the engine, which can be used to debug running JavaScript code. For more information on using the debugger see [Debugger](07.DEBUGGER.md).
|
||||
The debugger is disabled by default.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_DEBUGGER=0/1` |
|
||||
| CMake: | `-DJERRY_DEBUGGER=ON/OFF` |
|
||||
| Python: | `--jerry-debugger=ON/OFF` |
|
||||
|
||||
### Line information
|
||||
|
||||
By default, all source code information is discarded after parsing is complete. This option can be used to augment the created bytecode to provide line information during runtime,
|
||||
that can be used by the debugger to identify the currently executed source context. See [Debugger](07.DEBUGGER.md).
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_LINE_INFO=0/1` |
|
||||
| CMake: | `-DJERRY_LINE_INFO=ON/OFF` |
|
||||
| Python: | `--line-info=ON/OFF` |
|
||||
|
||||
### 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` 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 | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `<see description>` |
|
||||
| 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.
|
||||
When this option is enabled, an externally allocated memory region can be provided through the port API to the engine, to be used as the context.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_EXTERNAL_CONTEXT=0/1` |
|
||||
| CMake: | `-DJERRY_EXTERNAL_CONTEXT=ON/OFF` |
|
||||
| Python: | `--external-context=ON/OFF` |
|
||||
|
||||
### Snapshot execution
|
||||
|
||||
This option can be used to enable snapshot execution in the engine.
|
||||
This option is disabled by default.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_SNAPSHOT_EXEC=0/1` |
|
||||
| CMake: | `-DJERRY_SNAPSHOT_EXEC=ON/OFF` |
|
||||
| Python: | `--snapshot-exec=ON/OFF` |
|
||||
|
||||
### Snapshot saving
|
||||
|
||||
This option can be used to enable snapshot saving in the engine.
|
||||
This option is disabled by default.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_SNAPSHOT_SAVE=0/1` |
|
||||
| CMake: | `-DJERRY_SNAPSHOT_SAVE=ON/OFF` |
|
||||
| Python: | `--snapshot-save=ON/OFF` |
|
||||
|
||||
### Jerry parser
|
||||
|
||||
This option can be used to enable or disable the parser. When the parser is disabled all features that depend on source parsing are unavailable (eg. `jerry_parse`, `eval`, Function constructor).
|
||||
This option can be useful in combination with the snapshot feature. The parser is enabled by default.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_PARSER=0/1` |
|
||||
| CMake: | `-DJERRY_PARSER=ON/OFF` |
|
||||
| Python: | `--js-parser=ON/OFF` |
|
||||
|
||||
### Dump bytecode
|
||||
|
||||
This option can be used to display created bytecode in a human readable format. See [Internals](04.INTERNALS.md#byte-code) for more details.
|
||||
This option is disabled by default.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_PARSER_DUMP_BYTE_CODE=0/1` |
|
||||
| CMake: | `-DJERRY_PARSER_DUMP_BYTE_CODE=ON/OFF` |
|
||||
| Python: | `--show-opcodes=ON/OFF` |
|
||||
|
||||
### Dump RegExp bytecode
|
||||
|
||||
This option can be used to display created RegExp bytecode in a human readable format. The RegExp bytecode is different from the bytecode used by the virtual machine.
|
||||
This option is disabled by default.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_REGEXP_DUMP_BYTE_CODE=0/1` |
|
||||
| CMake: | `-DJERRY_REGEXP_DUMP_BYTE_CODE=ON/OFF` |
|
||||
| Python: | `--show-regexp-opcodes=ON/OFF` |
|
||||
|
||||
### Strict RegExp
|
||||
|
||||
This option can be used to enable strict RegExp mode. The standard RegExp syntax is a lot stricter than what is common in current JavaScript implementations.
|
||||
When enabled, this flag disables all of the non-standard, quality-of-life RegExp features, that are implemented to provide compatibility with other commonly used engines.
|
||||
This option is disabled by default.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_REGEXP_STRICT_MODE=0/1` |
|
||||
| CMake: | `-DJERRY_REGEXP_STRICT_MODE=ON/OFF` |
|
||||
| Python: | `--regexp-strict-mode=ON/OFF` |
|
||||
|
||||
### Error messages
|
||||
|
||||
Enables error messages for thrown Error objects. By default, error messages are omitted to reduce memory usage.
|
||||
Enabling this feature provides detailed error messages where available, like line information for Syntax errors, variable names for Reference errors, Type/Range error messages for built-in routines, etc.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_ERROR_MESSAGES=0/1` |
|
||||
| CMake: | `-DJERRY_ERROR_MESSAGES=ON/OFF` |
|
||||
| Python: | `--error-messages=ON/OFF` |
|
||||
|
||||
### Logging
|
||||
|
||||
This option can be used to enable log messages during runtime. When enabled the engine will use the `jerry_port_log` port API function to print relevant log messages.
|
||||
This feature is disabled by default.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_LOGGING=0/1` |
|
||||
| CMake: | `-DJERRY_LOGGING=ON/OFF` |
|
||||
| Python: | `--logging=ON/OFF` |
|
||||
|
||||
### LCache
|
||||
|
||||
This option enables the LCache, allowing faster access to object properties. The LCache uses a statically allocated hash-map, which increases memory consumption.
|
||||
See [Internals](04.INTERNALS.md#lcache) for further details.
|
||||
This option is enabled by default.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_LCACHE=0/1` |
|
||||
| CMake: | `<none>` |
|
||||
| Python: | `<none>` |
|
||||
|
||||
### Property hashmaps
|
||||
|
||||
This option enables the creation of hashmaps for object properties, which allows faster property access, at the cost of increased memory consumption.
|
||||
See [Internals](04.INTERNALS.md#property-hashmap) for further details.
|
||||
This option is enabled by default.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| 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_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 | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_MEM_STATS=0/1` |
|
||||
| CMake: | `-DJERRY_MEM_STATS=ON/OFF` |
|
||||
| Python: | `--mem-stats=ON/OFF` |
|
||||
|
||||
### Heap size
|
||||
|
||||
This option can be used to adjust the size of the internal heap, represented in kilobytes. The provided value should be an integer. Values larger than 512 require 32-bit compressed pointers to be enabled.
|
||||
The default value is 512.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_GLOBAL_HEAP_SIZE=(int)` |
|
||||
| CMake: | `-DJERRY_GLOBAL_HEAP_SIZE=(int)` |
|
||||
| Python: | `--mem-heap=(int)` |
|
||||
|
||||
### Garbage collection limit
|
||||
|
||||
This option can be used to adjust the maximum allowed heap usage increase until triggering the next garbage collection, in bytes.
|
||||
When the total allocated memory size reaches the current gc limit, garbage collection will be triggered to try and reduce clutter from unreachable objects.
|
||||
If the total allocated memory can't be reduced below the current limit, then the limit will be increased by the amount specified via this option.
|
||||
Similarly, when the total allocated memory goes well below the current gc limit, the limit is reduced by this amount.
|
||||
The default value is 1/32 of the total heap size, but not greater than 8192 bytes.
|
||||
A value of 0 will use the default value.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_GC_LIMIT=(int)` |
|
||||
| CMake: | `-DJERRY_GC_LIMIT=(int)` |
|
||||
| Python: | `--gc-limit=(int)` |
|
||||
|
||||
### GC mark recursion limit
|
||||
|
||||
This option can be used to adjust the maximum recursion depth during the GC mark phase. The provided value should be an integer, which represents the allowed number of recursive calls. Increasing the depth of the recursion reduces the time of GC cycles, however increases stack usage.
|
||||
A value of 0 will prevent any recursive GC calls.
|
||||
|
||||
| Options | |
|
||||
|---------|---------------------------------------------------|
|
||||
| C: | `-DJERRY_GC_MARK_LIMIT=(int)` |
|
||||
| CMake: | `-DJERRY_GC_MARK_LIMIT=(int)` |
|
||||
| Python: | `--gc-mark-limit=(int)` |
|
||||
|
||||
### Stack limit
|
||||
|
||||
This option can be used to cap the stack usage of the engine, and prevent stack overflows due to recursion. The provided value should be an integer, which represents the allowed stack usage in kilobytes.
|
||||
The default value is 0 (unlimited).
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_STACK_LIMIT=(int)` |
|
||||
| CMake: | `-DJERRY_STACK_LIMIT=(int)` |
|
||||
| Python: | `--stack-limit=(int)` |
|
||||
|
||||
### 32-bit compressed pointers
|
||||
|
||||
Enables 32-bit pointers instead of the default 16-bit compressed pointers. This allows the engine to use a much larger heap, but also comes with slightly increased memory usage, as objects can't be packed as tightly.
|
||||
This option must be enabled when using the system allocator.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_CPOINTER_32_BIT=0/1` |
|
||||
| CMake: | `-DJERRY_CPOINTER_32_BIT=ON/OFF` |
|
||||
| Python: | `--cpointer-32bit=ON/OFF` |
|
||||
|
||||
### System allocator
|
||||
|
||||
This option enables the use of malloc/free instead of the internal JerryScript allocator. This feature requires 32-bit compressed pointers, and is unsupported on 64-bit architectures.
|
||||
This option is disabled by default.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_SYSTEM_ALLOCATOR=0/1` |
|
||||
| CMake: | `-DJERRY_SYSTEM_ALLOCATOR=ON/OFF` |
|
||||
| Python: | `--system-allocator=ON/OFF` |
|
||||
|
||||
### Valgrind support
|
||||
|
||||
This option enables valgrind support for the internal allocator. When enabled, valgrind will be able to properly identify allocated memory regions, and report leaks or out-of-bounds memory accesses.
|
||||
This option is disabled by default.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_VALGRIND=0/1` |
|
||||
| CMake: | `-DJERRY_VALGRIND=ON/OFF` |
|
||||
| Python: | `--valgrind=ON/OFF` |
|
||||
|
||||
### Memory stress test
|
||||
|
||||
This option can be used to stress test memory management, by running garbage collection before every allocation attempt.
|
||||
This option is disabled by default.
|
||||
|
||||
| Options | |
|
||||
|---------|----------------------------------------------|
|
||||
| C: | `-DJERRY_MEM_GC_BEFORE_EACH_ALLOC=0/1` |
|
||||
| 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
|
||||
|
||||
The sources of JerryScript can be combined into a handful of files to allow their easy integration
|
||||
in other projects. To achieve this, the following command can be executed to create a set of files
|
||||
into the `amalgam` directory:
|
||||
|
||||
```sh
|
||||
$ python tools/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
|
||||
not mandatory.)
|
||||
|
||||
The command creates the following files in the `amalgam` dir:
|
||||
|
||||
* `jerryscript.c`
|
||||
* `jerryscript.h`
|
||||
* `jerryscript-config.h`
|
||||
* `jerryscript-port.c`
|
||||
* `jerryscript-math.c`
|
||||
* `math.h`
|
||||
|
||||
**Important**: the `jerryscript-config.h` contains the configurations mentioned above and
|
||||
should be adapted to the required use-case. See the file contents for more details and for the
|
||||
default configuration. (Note: This config file is created from the the `jerry-core/config.h` file.)
|
||||
|
||||
These files can be directly compiled with an application using the JerryScript API.
|
||||
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.c amalgam/jerryscript-math.c -Iamalgam/
|
||||
```
|
||||
|
||||
(Note: The headers must be available on the include path.)
|
||||
|
||||
This approach is also under the hood of the [amalgamated build](#amalgamated-build) process.
|
||||
|
||||
# Target specific information
|
||||
|
||||
## x86 with GCC
|
||||
|
||||
When building for Intel 32 bit architecture it is possible that GCC uses conservative options, thus assuming the most
|
||||
basic floating-point support (that is it does not generate SSE or others instructions).
|
||||
However this could lead to loss off precision and/or different results than what is required by the JavaScript standard
|
||||
in regards of floating-point values and arithmetic.
|
||||
|
||||
To resolve this precision problem it is advised to use at least SSE2.
|
||||
To do this with GCC please provide the `-mfpmath=sse -msse2` options during build.
|
||||
|
||||
These options can also be specified via the `build.py` script:
|
||||
|
||||
```sh
|
||||
$ ./tools/build.py --compile-flag=-mfpmath=sse --compile-flag=-msse2 --compile-flag=-m32
|
||||
```
|
||||
@@ -0,0 +1,143 @@
|
||||
## Setting up prerequisites
|
||||
|
||||
Currently, only Ubuntu 14.04+ is officially supported as primary development environment.
|
||||
|
||||
There are several dependencies, that should be installed manually. The following list is required for building:
|
||||
|
||||
- `gcc` or any C99-compliant compiler
|
||||
- native
|
||||
- arm-none-eabi
|
||||
- `cmake` >= `2.8.12.2`
|
||||
- `bash` >= `4.3.11`
|
||||
- `cppcheck` >= `1.61`
|
||||
- `vera++` >= `1.2.1`
|
||||
- `python` >= `2.7.6`
|
||||
|
||||
```bash
|
||||
sudo apt-get install gcc g++ gcc-arm-none-eabi cmake cppcheck vera++ python
|
||||
```
|
||||
|
||||
To make our scripts run correctly, several shell utilities should be available on the system:
|
||||
|
||||
- `awk`
|
||||
- `bc`
|
||||
- `find`
|
||||
- `sed`
|
||||
|
||||
## Building JerryScript
|
||||
|
||||
**To build debug version for Linux**
|
||||
|
||||
```bash
|
||||
python tools/build.py --debug
|
||||
```
|
||||
|
||||
**To build debug version for Linux without LTO (Link Time Optimization)**
|
||||
|
||||
```bash
|
||||
python tools/build.py --debug --lto=off
|
||||
```
|
||||
|
||||
**Add custom arguments to CMake**
|
||||
|
||||
```bash
|
||||
python tools/build.py --cmake-param=CMAKE_PARAM
|
||||
```
|
||||
|
||||
**Set a profile mode (full, minimal)**
|
||||
|
||||
```bash
|
||||
python tools/build.py --feature=full|minimal
|
||||
```
|
||||
|
||||
**Use (jerry, compiler-default, external) libc**
|
||||
|
||||
The default libc is jerry-libc, but you can use compiler-default libc or an external libc:
|
||||
|
||||
- compiler-default libc:
|
||||
|
||||
```bash
|
||||
python tools/build.py --jerry-libc=off --compiler-default-libc=on
|
||||
```
|
||||
|
||||
- external libc:
|
||||
|
||||
```bash
|
||||
python tools/build.py --jerry-libc=off --compiler-default-libc=off --compile-flag="-I/path/to/libc/include"
|
||||
```
|
||||
|
||||
**Add toolchain file**
|
||||
|
||||
The ```cmake``` dir already contains some usable toolchain files, which you can use in the following format:
|
||||
|
||||
```bash
|
||||
python tools/build.py --toolchain=TOOLCHAIN
|
||||
```
|
||||
|
||||
For example the cross-compile to RaspberryPi 2 is something like this:
|
||||
|
||||
```bash
|
||||
python tools/build.py --toolchain=cmake/toolchain_linux_armv7l.cmake
|
||||
```
|
||||
|
||||
**To get a list of all the available buildoptions for Linux**
|
||||
|
||||
```bash
|
||||
python tools/build.py --help
|
||||
```
|
||||
|
||||
## Checking patch
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --precommit
|
||||
```
|
||||
|
||||
### Running only one type of test
|
||||
|
||||
**To run build option tests**
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --buildoption-test
|
||||
```
|
||||
|
||||
**To run unittests**
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --unittests
|
||||
```
|
||||
|
||||
**To run jerry-tests**
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --jerry-tests
|
||||
```
|
||||
|
||||
**To run jerry-test-suite**
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --jerry-test-suite
|
||||
```
|
||||
|
||||
**To run signed-off check**
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --check-signed-off
|
||||
```
|
||||
|
||||
**To run cppcheck**
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --check-cppcheck
|
||||
```
|
||||
|
||||
**To run vera check**
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --check-vera
|
||||
```
|
||||
|
||||
**To get a list of all the available test options**
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --help
|
||||
```
|
||||
+926
-11623
File diff suppressed because it is too large
Load Diff
+166
-729
File diff suppressed because it is too large
Load Diff
+27
-30
@@ -23,7 +23,7 @@ Expression parser is responsible for parsing JavaScript expressions. It is imple
|
||||
|
||||
JavaScript statements are parsed by this component. It uses the [Expression parser](#expression-parser) to parse the constituent expressions. The implementation of Statement parser is located in `./jerry-core/parser/js/js-parser-statm.c`.
|
||||
|
||||
Function `parser_parse_source` carries out the parsing and compiling of the input ECMAScript source code. When a function appears in the source `parser_parse_source` calls `parser_parse_function` which is responsible for processing the source code of functions recursively including argument parsing and context handling. After the parsing, function `parser_post_processing` dumps the created opcodes and returns an `ecma_compiled_code_t*` that points to the compiled bytecode sequence.
|
||||
Function `parser_parse_source` carries out the parsing and compiling of the input EcmaScript source code. When a function appears in the source `parser_parse_source` calls `parser_parse_function` which is responsible for processing the source code of functions recursively including argument parsing and context handling. After the parsing, function `parser_post_processing` dumps the created opcodes and returns an `ecma_compiled_code_t*` that points to the compiled bytecode sequence.
|
||||
|
||||
The interactions between the major components shown on the following figure.
|
||||
|
||||
@@ -31,21 +31,21 @@ The interactions between the major components shown on the following figure.
|
||||
|
||||
# Byte-code
|
||||
|
||||
This section describes the compact byte-code (CBC) representation. The key focus is reducing memory consumption of the byte-code representation without sacrificing considerable performance. Other byte-code representations often focus on performance only so inventing this representation is an original research.
|
||||
This section describes the compact byte-code (CBC) byte-code representation. The key focus is reducing memory consumption of the byte-code representation without sacrificing considerable performance. Other byte-code representations often focus on performance only so inventing this representation is an original research.
|
||||
|
||||
CBC is a CISC like instruction set which assigns shorter instructions for frequent operations. Many instructions represent multiple atomic tasks which reduces the bytecode size. This technique is basically a data compression method.
|
||||
CBC is a CISC like instruction set which assigns shorter instructions for frequent operations. Many instructions represent multiple atomic tasks which reduces the byte code size. This technique is basically a data compression method.
|
||||
|
||||
## Compiled Code Format
|
||||
|
||||
The memory layout of the compiled bytecode is the following.
|
||||
The memory layout of the compiled byte code is the following.
|
||||
|
||||

|
||||
|
||||
The header is a `cbc_compiled_code` structure with several fields. These fields contain the key properties of the compiled code.
|
||||
|
||||
The literals part is an array of ecma values. These values can contain any ECMAScript value types, e.g. strings, numbers, functions and regexp templates. The number of literals is stored in the `literal_end` field of the header.
|
||||
The literals part is an array of ecma values. These values can contain any EcmaScript value types, e.g. strings, numbers, function and regexp templates. The number of literals is stored in the `literal_end` field of the header.
|
||||
|
||||
CBC instruction list is a sequence of bytecode instructions which represents the compiled code.
|
||||
CBC instruction list is a sequence of byte code instructions which represents the compiled code.
|
||||
|
||||
## Byte-code Format
|
||||
|
||||
@@ -55,7 +55,7 @@ The memory layout of a byte-code is the following:
|
||||
|
||||
Each byte-code starts with an opcode. The opcode is one byte long for frequent and two byte long for rare instructions. The first byte of the rare instructions is always zero (`CBC_EXT_OPCODE`), and the second byte represents the extended opcode. The name of common and rare instructions start with `CBC_` and `CBC_EXT_` prefix respectively.
|
||||
|
||||
The maximum number of opcodes is 511, since 255 common (zero value excluded) and 256 rare instructions can be defined. Currently around 215 frequent and 70 rare instructions are available.
|
||||
The maximum number of opcodes is 511, since 255 common (zero value excluded) and 256 rare instructions can be defined. Currently around 230 frequent and 120 rare instructions are available.
|
||||
|
||||
There are three types of bytecode arguments in CBC:
|
||||
|
||||
@@ -63,7 +63,7 @@ There are three types of bytecode arguments in CBC:
|
||||
|
||||
* __literal argument__: An integer index which is greater or equal than zero and less than the `literal_end` field of the header. For further information see next section Literals (next).
|
||||
|
||||
* __relative branch__: An 1-3 byte long offset. The branch argument might also represent the end of an instruction range. For example the branch argument of `CBC_EXT_WITH_CREATE_CONTEXT` shows the end of a `with` statement. More precisely the position after the last instruction in the with clause.
|
||||
* __relative branch__: An 1-3 byte long offset. The branch argument might also represent the end of an instruction range. For example the branch argument of `CBC_EXT_WITH_CREATE_CONTEXT` shows the end of a `with` statement. More precisely the position after the last instruction.
|
||||
|
||||
Argument combinations are limited to the following seven forms:
|
||||
|
||||
@@ -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 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`
|
||||
(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`
|
||||
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_.
|
||||
@@ -137,12 +137,12 @@ Byte-codes of this category serve for placing objects onto the stack. As there a
|
||||
|
||||
<span class="CSSTableGenerator" markdown="block">
|
||||
|
||||
| byte-code | description |
|
||||
| --------------------- | ----------------------------------------------------- |
|
||||
| CBC_PUSH_LITERAL | Pushes the value of the given literal argument. |
|
||||
| CBC_PUSH_TWO_LITERALS | Pushes the values of the given two literal arguments. |
|
||||
| CBC_PUSH_UNDEFINED | Pushes an undefined value. |
|
||||
| CBC_PUSH_TRUE | Pushes a logical true. |
|
||||
| byte-code | description |
|
||||
| --------------------- | ---------------------------------------------------- |
|
||||
| CBC_PUSH_LITERAL | Pushes the value of the given literal argument. |
|
||||
| CBC_PUSH_TWO_LITERALS | Pushes the value of the given two literal arguments. |
|
||||
| CBC_PUSH_UNDEFINED | Pushes an undefined value. |
|
||||
| CBC_PUSH_TRUE | Pushes a logical true. |
|
||||
| CBC_PUSH_PROP_LITERAL | Pushes a property whose base object is popped from the stack, and the property name is passed as a literal argument. |
|
||||
|
||||
</span>
|
||||
@@ -196,7 +196,7 @@ Branch byte-codes are used to perform conditional and unconditional jumps in the
|
||||
| CBC_JUMP_BACKWARD | Jumps backward by the 1 byte long relative offset argument. |
|
||||
| CBC_JUMP_BACKWARD_2 | Jumps backward by the 2 byte long relative offset argument. |
|
||||
| CBC_JUMP_BACKWARD_3 | Jumps backward by the 3 byte long relative offset argument. |
|
||||
| CBC_BRANCH_IF_TRUE_FORWARD | Jumps forward if the value on the top of the stack is true by the 1 byte long relative offset argument. |
|
||||
| CBC_BRANCH_IF_TRUE_FORWARD | Jumps if the value on the top of the stack is true by the 1 byte long relative offset argument. |
|
||||
|
||||
</span>
|
||||
|
||||
@@ -219,14 +219,12 @@ ECMA component of the engine is responsible for the following notions:
|
||||
|
||||
## Data Representation
|
||||
|
||||
The major structure for data representation is `ECMA_value`. The lower three bits of this structure encode value tag, which determines the type of the value:
|
||||
The major structure for data representation is `ECMA_value`. The lower two bits of this structure encode value tag, which determines the type of the value:
|
||||
|
||||
* simple
|
||||
* number
|
||||
* string
|
||||
* object
|
||||
* symbol
|
||||
* error
|
||||
|
||||

|
||||
|
||||
@@ -245,17 +243,16 @@ Compressed pointers were introduced to save heap space.
|
||||
|
||||

|
||||
|
||||
These pointers are 8 byte aligned 16 bit long pointers which can address 512 Kb of
|
||||
memory which is also the maximum size of the JerryScript heap. To support even more
|
||||
memory the size of compressed pointers can be extended to 32 bit to cover the entire
|
||||
address space of a 32 bit system by passing "--cpointer_32_bit on" to the build
|
||||
system. These "uncompressed pointers" increases the memory consumption by around 20%.
|
||||
These pointers are 8 byte aligned 16 bit long pointers which can address 512 Kb of memory which is also the maximum size of the JerryScript heap.
|
||||
|
||||
ECMA data elements are allocated in pools (pools are allocated on heap)
|
||||
Chunk size of the pool is 8 bytes (reduces fragmentation).
|
||||
|
||||
### Number
|
||||
|
||||
There are two possible representation of numbers according to standard IEEE 754:
|
||||
The default is 8-byte (double),
|
||||
but the engine supports the 4-byte (single precision) representation by setting JERRY_NUMBER_TYPE_FLOAT64 to 0 as well.
|
||||
but the engine supports the 4-byte (single precision) representation by setting CONFIG_ECMA_NUMBER_TYPE as well.
|
||||
|
||||

|
||||
|
||||
@@ -263,7 +260,7 @@ Several references to single allocated number are not supported. Each reference
|
||||
|
||||
### String
|
||||
|
||||
Strings in JerryScript are not just character sequences, but can hold numbers and so-called magic ids too. For common character sequences (defined in `./jerry-core/lit/lit-magic-strings.ini`) there is a table in the read only memory that contains magic id and character sequence pairs. If a string is already in this table, the magic id of its string is stored, not the character sequence itself. Using numbers speeds up the property access. These techniques save memory.
|
||||
Strings in JerryScript are not just character sequences, but can hold numbers and so-called magic ids too. For common character sequences there is a table in the read only memory that contains magic id and character sequence pairs. If a string is already in this table, the magic id of its string is stored, not the character sequence itself. Using numbers speeds up the property access. These techniques save memory.
|
||||
|
||||
### Object / Lexical Environment
|
||||
|
||||
@@ -271,12 +268,13 @@ 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:
|
||||
|
||||
* Reference counter - number of hard (non-property) references
|
||||
* Next object pointer for the garbage collector
|
||||
* GC's visited flag
|
||||
* type (function object, lexical environment, etc.)
|
||||
|
||||
### Properties of Objects
|
||||
@@ -284,8 +282,7 @@ The objects are represented as following structure:
|
||||

|
||||
|
||||
Objects have a linked list that contains their properties. This list actually contains property pairs, in order to save memory described in the followings:
|
||||
A property has a one byte long descriptor, a two byte long name and four byte long value. Hence 14 bytes consumed by a property pair. Another two bytes is
|
||||
used to show the next property pair, so the total size (16 byte) is divisible by 8.
|
||||
A property is 7 bit long and its type field is 2 bit long which consumes 9 bit which does not fit into 1 byte but consumes 2 bytes. Hence, placing together two properties (14 bit) with the 2 bit long type field fits into 2 bytes.
|
||||
|
||||
#### Property Hashmap
|
||||
|
||||
@@ -325,7 +322,7 @@ Collections are array-like data structures, which are optimized to save memory.
|
||||
|
||||
### Exception Handling
|
||||
|
||||
In order to implement a sense of exception handling, the return values of JerryScript functions are able to indicate their faulty or "exceptional" operation. The return values are ECMA values (see section [Data Representation](#data-representation)) and if an erroneous operation occurred the ECMA_VALUE_ERROR simple value is returned.
|
||||
In order to implement a sense of exception handling, the return values of JerryScript functions are able to indicate their faulty or "exceptional" operation. The return values are actually ECMA values (see section [Data Representation](#data-representation)) in which the error bit is set if an erroneous operation is occurred.
|
||||
|
||||
### Value Management and Ownership
|
||||
|
||||
|
||||
+160
-228
@@ -1,16 +1,9 @@
|
||||
# Reference
|
||||
|
||||
## Process management
|
||||
## Termination
|
||||
|
||||
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
|
||||
@@ -18,8 +11,7 @@ void jerry_port_init (void);
|
||||
*
|
||||
* @param code gives the cause of the error.
|
||||
*
|
||||
* Note:
|
||||
* Jerry expects the function not to return.
|
||||
* Note: jerry expects the function not to return.
|
||||
*
|
||||
* Example: a libc-based port may implement this with exit() or abort(), or both.
|
||||
*/
|
||||
@@ -31,248 +23,188 @@ Error codes
|
||||
```c
|
||||
typedef enum
|
||||
{
|
||||
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
|
||||
ERR_OUT_OF_MEMORY = 10,
|
||||
ERR_SYSCALL = 11,
|
||||
ERR_REF_COUNT_LIMIT = 12,
|
||||
ERR_FAILED_INTERNAL_ASSERTION = 120
|
||||
} jerry_fatal_code_t;
|
||||
```
|
||||
|
||||
```c
|
||||
/**
|
||||
* Makes the process sleep for a given time.
|
||||
*
|
||||
* Note:
|
||||
* This port function is called by jerry-core when JERRY_DEBUGGER is set to 1.
|
||||
* Otherwise this function is not used.
|
||||
*
|
||||
* @param sleep_time milliseconds to sleep.
|
||||
*/
|
||||
void jerry_port_sleep (uint32_t sleep_time);
|
||||
```
|
||||
|
||||
## External context
|
||||
|
||||
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
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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
|
||||
|
||||
These are the only I/O functions jerry calls.
|
||||
|
||||
```c
|
||||
/**
|
||||
* Display or log a debug/error message.
|
||||
* Print a string to the console. The function should implement a printf-like
|
||||
* interface, where the first argument specifies a format string on how to
|
||||
* stringify the rest of the parameter list.
|
||||
*
|
||||
* 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 only called with strings coming from the executed ECMAScript
|
||||
* wanting to print something as the result of its normal operation.
|
||||
*
|
||||
* This function is called with messages coming from the jerry engine as
|
||||
* the result of some abnormal operation or describing its internal operations
|
||||
* It should be the port that decides what a "console" is.
|
||||
*
|
||||
* Example: a libc-based port may implement this with vprintf().
|
||||
*/
|
||||
void jerry_port_console (const char *fmt, ...);
|
||||
|
||||
/**
|
||||
* 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. 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).
|
||||
*
|
||||
* The implementation can decide whether error and debug messages are logged to
|
||||
* 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.
|
||||
*
|
||||
* @param message_p: the message to log.
|
||||
*
|
||||
* Example: a libc-based port may implement this with vfprintf(stderr) or
|
||||
* vfprintf(logfile), or both, depending on log level.
|
||||
*/
|
||||
void jerry_port_log (const char *message_p);
|
||||
```
|
||||
|
||||
```c
|
||||
/**
|
||||
* 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_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);
|
||||
void jerry_port_log (jerry_log_level_t level, const char *fmt, ...);
|
||||
```
|
||||
|
||||
## Date
|
||||
|
||||
```c
|
||||
/**
|
||||
* Get local time zone adjustment in milliseconds for the given input time.
|
||||
*
|
||||
* 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 time zone structure
|
||||
*/
|
||||
int32_t jerry_port_local_tza (double unix_ms);
|
||||
```
|
||||
typedef struct
|
||||
{
|
||||
int offset; /**< minutes from west */
|
||||
int daylight_saving_time; /**< daylight saving time (1 - DST applies, 0 - not on DST) */
|
||||
} jerry_time_zone_t;
|
||||
|
||||
```c
|
||||
/**
|
||||
* Get the current system time in UTC.
|
||||
* Get timezone and daylight saving data
|
||||
*
|
||||
* 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 true - if success
|
||||
* false - otherwise
|
||||
*/
|
||||
bool jerry_port_get_time_zone (jerry_time_zone_t *);
|
||||
|
||||
/**
|
||||
* Get system time
|
||||
*
|
||||
* @return milliseconds since Unix epoch
|
||||
*/
|
||||
double jerry_port_current_time (void);
|
||||
double jerry_port_get_current_time (void);
|
||||
```
|
||||
|
||||
# How to port JerryScript
|
||||
|
||||
This section describes a basic port implementation which was created for Unix based systems.
|
||||
|
||||
## Termination
|
||||
|
||||
```c
|
||||
#include <stdlib.h>
|
||||
#include "jerry-port.h"
|
||||
|
||||
/**
|
||||
* Default implementation of jerry_port_fatal.
|
||||
*/
|
||||
void jerry_port_fatal (jerry_fatal_code_t code)
|
||||
{
|
||||
exit (code);
|
||||
} /* jerry_port_fatal */
|
||||
```
|
||||
|
||||
## I/O
|
||||
|
||||
```c
|
||||
#include <stdarg.h>
|
||||
#include "jerry-port.h"
|
||||
|
||||
/**
|
||||
* Provide console message implementation for the engine.
|
||||
*/
|
||||
void
|
||||
jerry_port_console (const char *format, /**< format string */
|
||||
...) /**< parameters */
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, format);
|
||||
vfprintf (stdout, format, args);
|
||||
va_end (args);
|
||||
} /* jerry_port_console */
|
||||
|
||||
/**
|
||||
* Provide log message implementation for the engine.
|
||||
*
|
||||
* Note:
|
||||
* This example ignores the log level.
|
||||
*/
|
||||
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 */
|
||||
```
|
||||
|
||||
## Date
|
||||
|
||||
```c
|
||||
#include <sys/time.h>
|
||||
#include "jerry-port.h"
|
||||
|
||||
/**
|
||||
* Default implementation of jerry_port_get_time_zone.
|
||||
*/
|
||||
bool jerry_port_get_time_zone (jerry_time_zone_t *tz_p)
|
||||
{
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
|
||||
/* gettimeofday may not fill tz, so zero-initializing */
|
||||
tz.tz_minuteswest = 0;
|
||||
tz.tz_dsttime = 0;
|
||||
|
||||
if (gettimeofday (&tv, &tz) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
tz_p->offset = tz.tz_minuteswest;
|
||||
tz_p->daylight_saving_time = tz.tz_dsttime > 0 ? 1 : 0;
|
||||
|
||||
return true;
|
||||
} /* jerry_port_get_time_zone */
|
||||
|
||||
/**
|
||||
* Default implementation of jerry_port_get_current_time.
|
||||
*/
|
||||
double jerry_port_get_current_time ()
|
||||
{
|
||||
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 */
|
||||
```
|
||||
|
||||
@@ -1,176 +0,0 @@
|
||||
## Reference counting in JerryScript
|
||||
|
||||
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_value_free`.
|
||||
|
||||
```c
|
||||
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
|
||||
* own live reference to the global object. These two references
|
||||
* are independent, and both must be destroyed before the global
|
||||
* object can be freed. */
|
||||
|
||||
jerry_value_free (global);
|
||||
|
||||
/* 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. */
|
||||
```
|
||||
|
||||
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_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_value_free (pi_ref1);
|
||||
jerry_value_free (pi_ref2);
|
||||
```
|
||||
|
||||
Releasing the same `jerry_value_t` twice to release two live
|
||||
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_value_free (pi_ref1);
|
||||
jerry_value_free (pi_ref1);
|
||||
```
|
||||
|
||||
JerryScript API functions returning with a `jerry_value_t` always
|
||||
return with a new live reference. Passing a `jerry_value_t` to
|
||||
an API function never releases its reference (unless explicitly
|
||||
stated in the documentation). The next example shows this
|
||||
behaviour through property getting and setting.
|
||||
|
||||
```c
|
||||
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
|
||||
* the same JavaScript value. When the operation fails, the
|
||||
* prop_value contains a live reference to an error object.
|
||||
* This reference must be released as well. */
|
||||
|
||||
if (jerry_value_is_exception (prop_value))
|
||||
{
|
||||
/* Errors can be handled here. */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The application has a live reference to the property
|
||||
* value even if the base object is freed by the garbage
|
||||
* collector. */
|
||||
}
|
||||
|
||||
/* The prop_value must be released. */
|
||||
jerry_value_free (prop_value);
|
||||
|
||||
/* Property setting is the same. */
|
||||
|
||||
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
|
||||
* reference must be released regardless of whether the operation
|
||||
* is successful. */
|
||||
|
||||
/* The new_prop_value can be passed to other JerryScript API
|
||||
* functions before the jerry_value_free () call. */
|
||||
|
||||
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_exception (result))
|
||||
{
|
||||
/* Errors can be handled here. */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* A reference to a true primitive value is returned. */
|
||||
}
|
||||
|
||||
jerry_value_free (result);
|
||||
```
|
||||
|
||||
The simplest form of setting a property without error checking
|
||||
is the following:
|
||||
|
||||
```c
|
||||
/* There are no 'ifs' in this snippet. */
|
||||
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
|
||||
transfers the ownership of the live reference. Otherwise the
|
||||
referenced object could be freed by the garbage collector.
|
||||
|
||||
```c
|
||||
jerry_value_t my_external_handler (const jerry_value_t function_obj,
|
||||
const jerry_value_t this_val,
|
||||
const jerry_value_t args_p[],
|
||||
const jerry_length_t args_count
|
||||
{
|
||||
/* Do not release function_obj, this_val, and args_p because
|
||||
* 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_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_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_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_value_free (undef2);
|
||||
|
||||
/* Dead references can be reassigned again. */
|
||||
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_boolean (true);
|
||||
|
||||
jerry_value_t b = a;
|
||||
jerry_value_t c = a;
|
||||
|
||||
/* A new reference is assigned to 'a'. */
|
||||
a = jerry_boolean (false);
|
||||
|
||||
[...]
|
||||
|
||||
jerry_value_free (a);
|
||||
/* The 'a' (boolean false) reference becomes dead (invalid). */
|
||||
|
||||
jerry_value_free (c);
|
||||
/* Both 'b' and 'c' (boolean true) references become dead. */
|
||||
|
||||
/* Since all references are released, no memory leak occurs. */
|
||||
```
|
||||
@@ -1,415 +0,0 @@
|
||||
## JerryScript debugger interface
|
||||
|
||||
JerryScript provides a remote debugger which allows debugging
|
||||
JavaScript programs. The debugger has two main components:
|
||||
a server which is part of the JerryScript binary and a
|
||||
separate client application. Currently a Python-based debugger
|
||||
client is available in the /jerry-debugger subdirectory.
|
||||
This simple application demonstrates the communication protocol
|
||||
between the client and server, and can be reused by integrated
|
||||
development environments.
|
||||
|
||||
## Setting up the debugger server
|
||||
|
||||
The following arguments must be passed to `tools/build.py`:
|
||||
|
||||
`--jerry-debugger=on`
|
||||
|
||||
The transport layer of the communication protocol is pluggable.
|
||||
At the moment, a WebSocket-based implementation is provided as a
|
||||
JerryScript extension, which transmits messages over TCP/IP networks.
|
||||
If necessary/implemented, any reliable stream or datagram based
|
||||
protocol can be used for transmitting debugger messages.
|
||||
|
||||
## Debugging JavaScript applications
|
||||
|
||||
The debugger client must be connected to the server before the
|
||||
JavaScript application runs. On-the-fly attachment is supported
|
||||
for more than one file, right after the engine initialization
|
||||
(this feature is available with the python client). The debugging
|
||||
information (e.g. line index of each possible breakpoint location)
|
||||
is not preserved by JerryScript. The client is expected to be run
|
||||
on a system with much more resources and it should be capable of
|
||||
storing this information. JerryScript frees all debug information
|
||||
after it is transmitted to the client to save memory.
|
||||
|
||||
The following argument makes JerryScript wait for a client
|
||||
connection:
|
||||
|
||||
`--start-debug-server`
|
||||
|
||||
The following argument makes JerryScript wait for a client
|
||||
source code:
|
||||
|
||||
`--debugger-wait-source`
|
||||
|
||||
It is also recommended to increase the log level to see
|
||||
the *Waiting for client connection* message:
|
||||
|
||||
`--log-level 2`
|
||||
|
||||
The Python client can connect to the server by specifying its
|
||||
IP address on the command line. The address can be localhost
|
||||
if the server and the client are running on the same machine.
|
||||
|
||||
After the connection is established the execution can be
|
||||
controlled by the debugger. The debugger always stops at
|
||||
the first possible breakpoint location. The effect is the
|
||||
same as using the `stop` command. This allows inserting
|
||||
breakpoints right before the meaningful part of the execution
|
||||
starts.
|
||||
|
||||
All available commands of the client can be queried by the
|
||||
`help` command.
|
||||
|
||||
## Integrating debugger support into applications using JerryScript
|
||||
|
||||
When using the extension-provided WebSocket transport layer, the
|
||||
debugger can be enabled by calling `jerryx_debugger_after_connect
|
||||
(jerryx_debugger_tcp_create (debug_port) && jerryx_debugger_ws_create ())`
|
||||
after the `jerry_init ()` function. It initializes the debugger and
|
||||
blocks until a client connects.
|
||||
(Custom transport layers may be implemented and initialized similarly.
|
||||
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 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
|
||||
|
||||
The following section describes the debugger functions
|
||||
available to the host application.
|
||||
|
||||
## JerryScript debugger types
|
||||
|
||||
## jerry_debugger_wait_for_source_callback_t
|
||||
|
||||
**Summary**
|
||||
|
||||
This callback function is called by
|
||||
[jerry_debugger_wait_for_client_source](#jerry_debugger_wait_for_client_source)
|
||||
when a source code is received successfully.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
typedef jerry_value_t
|
||||
(*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);
|
||||
```
|
||||
|
||||
- `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)
|
||||
|
||||
|
||||
## JerryScript debugger functions
|
||||
|
||||
### jerry_debugger_is_connected
|
||||
|
||||
**Summary**
|
||||
|
||||
Returns true if a remote debugger client is connected.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
bool
|
||||
jerry_debugger_is_connected (void);
|
||||
```
|
||||
|
||||
**Example**
|
||||
|
||||
[doctest]: # (test="link")
|
||||
|
||||
```c
|
||||
#include <stdio.h>
|
||||
|
||||
#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 ());
|
||||
|
||||
if (jerry_debugger_is_connected ())
|
||||
{
|
||||
printf ("A remote debugger client is connected.");
|
||||
}
|
||||
|
||||
jerry_cleanup ();
|
||||
}
|
||||
```
|
||||
|
||||
### jerry_debugger_stop
|
||||
|
||||
**Summary**
|
||||
|
||||
Stops execution at the next available breakpoint if a remote
|
||||
debugger client is connected and the engine is not waiting at
|
||||
a breakpoint. The engine will stop regardless the breakpoint
|
||||
is enabled or not.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
void
|
||||
jerry_debugger_stop (void)
|
||||
```
|
||||
|
||||
**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_debugger_stop ();
|
||||
|
||||
jerry_cleanup ();
|
||||
}
|
||||
```
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerry_debugger_continue](#jerry_debugger_continue)
|
||||
|
||||
### jerry_debugger_continue
|
||||
|
||||
**Summary**
|
||||
|
||||
If the engine would stop at the next available breakpoint it
|
||||
cancels this effect. The engine will still stop at enabled
|
||||
breakpoints. This function effectively negates the effect of
|
||||
[jerry_debugger_stop ()](#jerry_debugger_stop) calls or stop
|
||||
requests issued by the debugger client.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
void
|
||||
jerry_debugger_continue (void)
|
||||
```
|
||||
|
||||
**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_debugger_continue ();
|
||||
|
||||
jerry_cleanup ();
|
||||
}
|
||||
```
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerry_debugger_stop](#jerry_debugger_stop)
|
||||
|
||||
### jerry_debugger_stop_at_breakpoint
|
||||
|
||||
**Summary**
|
||||
|
||||
Enables or disables stopping at breakpoints. When stopping is
|
||||
disabled all breakpoints are ignored including user enabled
|
||||
breakpoints. This allows hidden execution of ECMAScript code.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
void
|
||||
jerry_debugger_stop_at_breakpoint (bool enable_stop_at_breakpoint)
|
||||
```
|
||||
|
||||
- `enable_stop_at_breakpoint` - enable (=`true`) or disable (=`false`) stopping at breakpoints
|
||||
|
||||
**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_debugger_stop_at_breakpoint (true);
|
||||
|
||||
// Protected execution of JavaScript code.
|
||||
const jerry_char_t script[] = "42";
|
||||
jerry_eval (script, sizeof (script) - 1, JERRY_PARSE_NO_OPTS);
|
||||
|
||||
jerry_debugger_stop_at_breakpoint (false);
|
||||
|
||||
jerry_cleanup ();
|
||||
}
|
||||
```
|
||||
|
||||
### jerry_debugger_wait_for_client_source
|
||||
|
||||
**Summary**
|
||||
|
||||
Asks the client to provide the next source code. The function
|
||||
waits until the whole source code is received. As a reply the
|
||||
the client may request a context reset or notify that no more
|
||||
source is available. These notifications are passed back as the
|
||||
return value of the function.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```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)
|
||||
```
|
||||
|
||||
**Example**
|
||||
|
||||
[doctest]: # (test="link")
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/debugger.h"
|
||||
|
||||
/**
|
||||
* Runs the source code received by jerry_debugger_wait_for_client_source.
|
||||
*/
|
||||
static jerry_value_t
|
||||
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_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);
|
||||
|
||||
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_value_free (func_val);
|
||||
}
|
||||
|
||||
return ret_val;
|
||||
} /* wait_for_source_callback */
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
jerry_debugger_wait_for_source_status_t receive_status;
|
||||
|
||||
do
|
||||
{
|
||||
/* Create a new JerryScript instance when a context reset is
|
||||
* received. Applications usually registers their core bindings
|
||||
* here as well (e.g. print, setTimeout). */
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
jerryx_debugger_after_connect (jerryx_debugger_tcp_create (5001)
|
||||
&& jerryx_debugger_ws_create ());
|
||||
|
||||
do
|
||||
{
|
||||
jerry_value_t run_result;
|
||||
|
||||
receive_status = jerry_debugger_wait_for_client_source (wait_for_source_callback,
|
||||
NULL,
|
||||
&run_result);
|
||||
|
||||
jerry_value_free (run_result);
|
||||
}
|
||||
while (receive_status == JERRY_DEBUGGER_SOURCE_RECEIVED);
|
||||
|
||||
jerry_cleanup ();
|
||||
}
|
||||
while (receive_status == JERRY_DEBUGGER_CONTEXT_RESET_RECEIVED);
|
||||
|
||||
if (receive_status == JERRY_DEBUGGER_SOURCE_RECEIVE_FAILED)
|
||||
{
|
||||
// Handle the failure (e.g. display an error).
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
### jerry_debugger_send_output
|
||||
|
||||
**Summary**
|
||||
|
||||
Sends the program's output to the debugger client.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
void
|
||||
jerry_debugger_send_output (const jerry_char_t *buffer, jerry_size_t str_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_output[] = "Hey, this should be sent too!";
|
||||
jerry_size_t my_output_size = sizeof (my_output);
|
||||
|
||||
jerry_debugger_send_output (my_output, my_output_size);
|
||||
|
||||
jerry_cleanup ();
|
||||
}
|
||||
```
|
||||
@@ -1,803 +0,0 @@
|
||||
# JerryScript Coding Standards
|
||||
|
||||
This text is a brief overview of JerryScript Coding Standards.
|
||||
Each rule starts with a short description followed by several
|
||||
examples. We believe examples are better than long explanations.
|
||||
Please follow these guidelines when you submit a patch for
|
||||
review.
|
||||
|
||||
## General rules
|
||||
|
||||
* Indentation is two spaces.
|
||||
* 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-format` to check several
|
||||
of the coding conventions automatically.
|
||||
|
||||
## Comments
|
||||
|
||||
Only block comments (`/* */`) are allowed in JerryScript.
|
||||
Comments should be complete sentences (e.g. start with an
|
||||
upper case letter), except for return value, field and
|
||||
argument descriptions (see the exceptions below). The
|
||||
text part of a comment should focus on explaining *why*
|
||||
the code is doing something rather than *what* the code
|
||||
is doing.
|
||||
|
||||
```diff
|
||||
+++ Good +++
|
||||
```
|
||||
|
||||
```c
|
||||
/* A perfect comment. */
|
||||
|
||||
/* A perfect multiline
|
||||
* comment. Each line should
|
||||
* start with an asterisk. */
|
||||
```
|
||||
|
||||
```diff
|
||||
--- Bad ---
|
||||
```
|
||||
|
||||
```c
|
||||
// Double slash comments are not allowed.
|
||||
|
||||
/* not a complete sentence */
|
||||
|
||||
/* A bad multiline
|
||||
comment. */
|
||||
```
|
||||
|
||||
All types, constants and functions require a description in
|
||||
JerryScript. These comments should start with `/**`. The starting
|
||||
`/**` and ending `*/` must be on separate lines.
|
||||
|
||||
```diff
|
||||
+++ Good +++
|
||||
```
|
||||
|
||||
```c
|
||||
/**
|
||||
* A correct description.
|
||||
*/
|
||||
```
|
||||
|
||||
```diff
|
||||
--- Bad ---
|
||||
```
|
||||
|
||||
```c
|
||||
/** An incorrect description. */
|
||||
```
|
||||
|
||||
## Preprocessor defines
|
||||
|
||||
The name of a preprocessor macro must be an uppercase string
|
||||
and these macros must be preceded by a description.
|
||||
Abbreviations are allowed but not preferred in new code.
|
||||
|
||||
```diff
|
||||
+++ Good +++
|
||||
```
|
||||
|
||||
```c
|
||||
/**
|
||||
* Short description about the constant.
|
||||
*/
|
||||
#define JERRY_VALUE_SEVEN 7
|
||||
|
||||
/**
|
||||
* Short description about the macro function.
|
||||
*/
|
||||
#define JERRY_ADD_TWO_NUMBERS(arg1, arg2) \
|
||||
((arg1) + (arg2))
|
||||
|
||||
/**
|
||||
* Although this is correct, a reviewer might request
|
||||
* to change NUMS to NUMBERS. Hence it is recommended
|
||||
* to use NUMBERS in the first place.
|
||||
*/
|
||||
#define JERRY_ADD_TWO_NUMS(arg1, arg2) \
|
||||
((arg1) + (arg2))
|
||||
```
|
||||
|
||||
```diff
|
||||
--- Bad ---
|
||||
```
|
||||
|
||||
```c
|
||||
#define JERRY_CONSTANT_WITHOUT_DESCRIPTION 5
|
||||
|
||||
#define JeRrY_mIxEd_CaSe_NaMe "str"
|
||||
```
|
||||
|
||||
## Conditional preprocessor directives
|
||||
|
||||
A comment is required after `#else` and `#endif` in JerryScript.
|
||||
The defined keyword should be omitted from these comments.
|
||||
|
||||
```diff
|
||||
+++ Good +++
|
||||
```
|
||||
|
||||
```c
|
||||
#ifdef JERRY_A
|
||||
|
||||
#else /* !JERRY_A */
|
||||
|
||||
#endif /* JERRY_A */
|
||||
|
||||
#ifdef JERRY_A
|
||||
#if defined JERRY_B && defined JERRY_C && (JERRY_C > 6)
|
||||
|
||||
#else /* !(JERRY_B && JERRY_C && (JERRY_C > 6)) */
|
||||
|
||||
#endif /* JERRY_B && JERRY_C && (JERRY_C > 6) */
|
||||
#endif /* JERRY_A */
|
||||
```
|
||||
|
||||
```diff
|
||||
--- Bad ---
|
||||
```
|
||||
|
||||
```c
|
||||
#ifdef JERRY_A
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef JERRY_A
|
||||
|
||||
#endif /* defined JERRY_A */
|
||||
|
||||
#ifdef JERRY_B
|
||||
/* Missing comment after else. */
|
||||
#else
|
||||
|
||||
#endif /* JERRY_B */
|
||||
```
|
||||
|
||||
## Code blocks
|
||||
|
||||
Each code block must be enclosed in curly braces even
|
||||
if it is a single line statement. These braces must
|
||||
be on separate lines. There must be a single space
|
||||
before the opening parenthesis of the expression
|
||||
after if/while/switch keywords.
|
||||
|
||||
```diff
|
||||
+++ Good +++
|
||||
```
|
||||
|
||||
```c
|
||||
if (value > 6)
|
||||
{
|
||||
function_call ();
|
||||
}
|
||||
|
||||
if (value > 1)
|
||||
{
|
||||
function_call_a ();
|
||||
}
|
||||
else
|
||||
{
|
||||
function_call_b ();
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
function_call ();
|
||||
value++;
|
||||
}
|
||||
while (value < 6);
|
||||
|
||||
switch (value)
|
||||
{
|
||||
case A:
|
||||
{
|
||||
/* FALLTHRU comment is allowed if a
|
||||
* switch-case is not terminated by
|
||||
* break/continue/return. */
|
||||
|
||||
/* FALLTHRU */
|
||||
}
|
||||
case B:
|
||||
case C:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case D:
|
||||
{
|
||||
/* We can use continue if we are in a loop. */
|
||||
continue;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```diff
|
||||
--- Bad ---
|
||||
```
|
||||
|
||||
```c
|
||||
if (value > 6)
|
||||
function_call_a ();
|
||||
else
|
||||
function_call_b ();
|
||||
|
||||
if (value > 6) {
|
||||
function_call_a ();
|
||||
}
|
||||
|
||||
if (value > 6) function_call_a ();
|
||||
else { function_call_b (); }
|
||||
|
||||
if
|
||||
(value > 6)
|
||||
{
|
||||
}
|
||||
|
||||
switch (value) {
|
||||
case 0: break;
|
||||
default: {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
|
||||
switch (value)
|
||||
{
|
||||
case A:
|
||||
{
|
||||
if (value > 6)
|
||||
{
|
||||
CASE B:
|
||||
{
|
||||
/* This is allowed in C but
|
||||
* not in JerryScript. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do
|
||||
value++;
|
||||
while (value < 5);
|
||||
|
||||
do {
|
||||
value++;
|
||||
} while (value < 5);
|
||||
|
||||
do
|
||||
{
|
||||
value++;
|
||||
} while (value < 5);
|
||||
```
|
||||
|
||||
## Newlines
|
||||
|
||||
A newline in JerryScript is a separator which separates different
|
||||
parts of the source code. Its primary purpose is to improve
|
||||
readability. Unlike other rules developers have some freedom
|
||||
to add newlines to their code. However there are some rules.
|
||||
|
||||
* Only a single newline separator is allowed.
|
||||
* Source files must be terminated by a newline.
|
||||
* Global declarations must be separated by a newline.
|
||||
* Newlines are not allowed after an opening curly brace or before
|
||||
a closing curly brace
|
||||
* No newlines are allowed between control statements (if-else, while,
|
||||
for, switch, etc.) and their code blocks.
|
||||
* There should be a newline after the variable declarations
|
||||
if they are the first statements of a block.
|
||||
|
||||
```diff
|
||||
+++ Good +++
|
||||
```
|
||||
|
||||
```c
|
||||
if (a > 5)
|
||||
{
|
||||
/* Newline must be present after the first
|
||||
* variable declarations of a code block. */
|
||||
int j = a - 1;
|
||||
int k = a * 2;
|
||||
|
||||
return j + k;
|
||||
}
|
||||
|
||||
while (a < 5)
|
||||
{
|
||||
a++;
|
||||
|
||||
/* It is recommended to put a newline after
|
||||
* intermediate variable declarations. */
|
||||
int i = a * 2;
|
||||
|
||||
b = i - 3;
|
||||
}
|
||||
|
||||
/* It is a recommended to put newlines around asserts. */
|
||||
a = b + 5;
|
||||
|
||||
JERRY_ASSERT (a < 20);
|
||||
|
||||
c = a + 7;
|
||||
|
||||
/* It is a good practice to put a newline after a multiline
|
||||
* function call (see Function calls later). */
|
||||
f (a,
|
||||
b,
|
||||
c);
|
||||
|
||||
a = 6;
|
||||
```
|
||||
|
||||
```diff
|
||||
--- Bad ---
|
||||
```
|
||||
|
||||
```c
|
||||
/* No newlines are allowed after an opening curly
|
||||
* brace or before a closing curly brace */
|
||||
|
||||
while (a > 0)
|
||||
{
|
||||
|
||||
a = 6;
|
||||
|
||||
}
|
||||
|
||||
if (a > 5)
|
||||
{
|
||||
while (b < 6)
|
||||
{
|
||||
|
||||
b++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Two or more newlines are not allowed. */
|
||||
a = 6;
|
||||
|
||||
|
||||
b = 7;
|
||||
|
||||
/* No newlines are allowed between control statements
|
||||
* and their code blocks. */
|
||||
|
||||
if (a > 6)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
do
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
while (a < 6);
|
||||
```
|
||||
|
||||
## Expressions
|
||||
|
||||
Spaces are required around binary operators. No space is
|
||||
needed otherwise.
|
||||
|
||||
```diff
|
||||
+++ Good +++
|
||||
```
|
||||
|
||||
```c
|
||||
a = b + c;
|
||||
a = (b + c) << 3;
|
||||
a = b = c + ~d;
|
||||
a += ++c + d++;
|
||||
call_function (a * (b + !!c) - d + (e % f));
|
||||
if (a)
|
||||
{
|
||||
}
|
||||
```
|
||||
|
||||
```diff
|
||||
--- Bad ---
|
||||
```
|
||||
|
||||
```c
|
||||
a=b+c;
|
||||
a = b+c;
|
||||
a += c + ( d );
|
||||
/* Introduce temporary variables or macros
|
||||
* if the expression is too long. Occurs rarely.. */
|
||||
a = b
|
||||
+ c;
|
||||
if ( a + b > 0 )
|
||||
{
|
||||
}
|
||||
```
|
||||
|
||||
## Logical operators
|
||||
|
||||
All expressions with && and || logical operators must be
|
||||
enclosed in parentheses. A single and multiline form is
|
||||
allowed for these expressions. In the latter case each
|
||||
line must start with the logical operator and each line
|
||||
must be aligned to the column right after the opening
|
||||
parenthesis.
|
||||
|
||||
```diff
|
||||
+++ Good +++
|
||||
```
|
||||
|
||||
```c
|
||||
/* Single line form. */
|
||||
a = ((c && d) || (e && f));
|
||||
|
||||
a = (c
|
||||
&& d);
|
||||
|
||||
a = (c
|
||||
&& (d || e)
|
||||
&& f);
|
||||
|
||||
do
|
||||
{
|
||||
}
|
||||
while (a
|
||||
&& b);
|
||||
|
||||
/* This form is rarely used but it is ok. */
|
||||
if (a
|
||||
&& (b
|
||||
|| c
|
||||
|| d)
|
||||
&& e)
|
||||
{
|
||||
}
|
||||
```
|
||||
|
||||
```diff
|
||||
--- Bad ---
|
||||
```
|
||||
|
||||
```c
|
||||
if (a || b ||
|
||||
c)
|
||||
{
|
||||
}
|
||||
|
||||
/* Parentheses are missing. */
|
||||
a = b || c;
|
||||
|
||||
/* Misaligned &&. */
|
||||
if (a
|
||||
&& b)
|
||||
{
|
||||
}
|
||||
```
|
||||
|
||||
## Ternary conditional operators
|
||||
|
||||
A special form of ternary conditional operators are allowed
|
||||
in JerryScript where the ? and : operators are on separate
|
||||
lines in the same column.
|
||||
|
||||
```diff
|
||||
+++ Good +++
|
||||
```
|
||||
|
||||
```c
|
||||
a = (b ? c
|
||||
: d);
|
||||
|
||||
/* Single line form is accepted as well. */
|
||||
a = (b ? c : d);
|
||||
|
||||
/* This form is rarely used but it is ok. */
|
||||
if (a ? b
|
||||
: (c ? d
|
||||
: e))
|
||||
{
|
||||
}
|
||||
```
|
||||
|
||||
```diff
|
||||
--- Bad ---
|
||||
```
|
||||
|
||||
```c
|
||||
a = b ?
|
||||
c : d;
|
||||
|
||||
while (a ? b
|
||||
: c)
|
||||
{
|
||||
}
|
||||
|
||||
if (a
|
||||
? b
|
||||
: c)
|
||||
{
|
||||
}
|
||||
```
|
||||
|
||||
## Function calls
|
||||
|
||||
There must be a space after the function name. Each argument
|
||||
must be in the same or separated lines. In the former case
|
||||
there must be a space before the next argument and in the
|
||||
latter case all arguments must be aligned to the same column.
|
||||
|
||||
```diff
|
||||
+++ Good +++
|
||||
```
|
||||
|
||||
```c
|
||||
function_a ();
|
||||
function_b (a);
|
||||
function_c (a, b, c);
|
||||
|
||||
function_c (a,
|
||||
b,
|
||||
c);
|
||||
|
||||
function_c (a,
|
||||
b,
|
||||
function_c (a,
|
||||
b,
|
||||
c);
|
||||
```
|
||||
|
||||
```diff
|
||||
--- Bad ---
|
||||
```
|
||||
|
||||
```c
|
||||
/* No space before the opening parenthesis. */
|
||||
function_f();
|
||||
|
||||
function_f (
|
||||
);
|
||||
|
||||
function_g(a);
|
||||
|
||||
function_g
|
||||
(a
|
||||
);
|
||||
|
||||
/* Two arguments on the same line. */
|
||||
function_h (a, b,
|
||||
c);
|
||||
|
||||
function_h (a,
|
||||
b, c);
|
||||
|
||||
/* Misaligned arguments. */
|
||||
function_h (a,
|
||||
b,
|
||||
c);
|
||||
```
|
||||
|
||||
## Variable declarations
|
||||
|
||||
JerryScript is a pure C99 codebase so variable
|
||||
declarations can be anywhere in the code including
|
||||
inside for-loops. It is recommended to declare a
|
||||
variable before the first use.
|
||||
|
||||
```diff
|
||||
+++ Good +++
|
||||
```
|
||||
|
||||
```c
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
int j = i + 1;
|
||||
while (j < 10)
|
||||
{
|
||||
++j;
|
||||
}
|
||||
}
|
||||
|
||||
/* Multiline form of for loops. */
|
||||
for (int i = 0;
|
||||
i < 10;
|
||||
i++)
|
||||
{
|
||||
}
|
||||
```
|
||||
|
||||
## Type casting
|
||||
|
||||
There must be a space after the closing parenthesis
|
||||
of the type cast. Type casting has no multiline form
|
||||
in JerryScript.
|
||||
|
||||
```diff
|
||||
+++ Good +++
|
||||
```
|
||||
|
||||
```c
|
||||
int a = (int) double_variable;
|
||||
|
||||
int a = (int) (long) (float) double_variable;
|
||||
```
|
||||
|
||||
```diff
|
||||
--- Bad ---
|
||||
```
|
||||
|
||||
```c
|
||||
/* Wrong spaces. */
|
||||
int a = ( int )double_variable;
|
||||
|
||||
/* No multiline form. */
|
||||
int a = (int)
|
||||
double_variable;
|
||||
```
|
||||
|
||||
## Pointers and asterisk character
|
||||
|
||||
Each pointer in JerryScript must be a lowercase string
|
||||
which is ending with a `_p` suffix. Furthermore there
|
||||
must be a space before the asterisk character.
|
||||
|
||||
```diff
|
||||
+++ Good +++
|
||||
```
|
||||
|
||||
```c
|
||||
int *int_p;
|
||||
|
||||
/* No need to add multiple _p-s for multiple indirections.
|
||||
* It is recommended to avoid these constructs using typedef
|
||||
* declarations. A reviewer might request such a change. */
|
||||
int ***int_p;
|
||||
|
||||
/* This rule applies for type casting as well. */
|
||||
char = *(char *) type_p;
|
||||
```
|
||||
|
||||
```diff
|
||||
--- Bad ---
|
||||
```
|
||||
|
||||
```c
|
||||
/* No _p after the name. */
|
||||
int *ptr;
|
||||
|
||||
/* Wrong asterisk position. */
|
||||
int* ptr_p;
|
||||
|
||||
char_p = * (char*)type_p;
|
||||
```
|
||||
|
||||
## Types
|
||||
|
||||
Each type in JerryScript must be a lowercase string
|
||||
which ends with a `_t` suffix. Furthermore each type
|
||||
declaration must be preceded by a short description
|
||||
of the type and each field must have a short description
|
||||
as well.
|
||||
|
||||
```diff
|
||||
+++ Good +++
|
||||
```
|
||||
|
||||
```c
|
||||
/**
|
||||
* Short description of the following structure.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/* Field descriptions do not start with capital letters
|
||||
* and there is no full stop at the end. */
|
||||
field1_t field1; /**< description of field 1 */
|
||||
field2_t field2; /**< description of field 2 */
|
||||
|
||||
field_n_t field_n; /**< description of field n */
|
||||
} structure_name_t;
|
||||
|
||||
/**
|
||||
* Another integer type.
|
||||
*/
|
||||
typedef int jerry_int;
|
||||
```
|
||||
|
||||
```diff
|
||||
--- Bad ---
|
||||
```
|
||||
|
||||
```c
|
||||
typedef struct
|
||||
{
|
||||
field_t field_without_description;
|
||||
} structure_without_description_t;
|
||||
|
||||
typedef struct { int a; } single_line_struct;
|
||||
|
||||
typedef
|
||||
union {
|
||||
}
|
||||
wrong_newlines_t;
|
||||
|
||||
/*
|
||||
* Bad comment format.
|
||||
*/
|
||||
typedef
|
||||
char wrong_newlines_again_t;
|
||||
```
|
||||
|
||||
### Type usage conventions
|
||||
|
||||
- Passing the number of arguments for a function call is always `uint32_t`
|
||||
- String size/length/position related operation should use `lit_utf8_size_t`
|
||||
- Extended objects internal fields must be `uint32_t`
|
||||
|
||||
## Function declarations
|
||||
|
||||
Function declarations in JerryScript are verbose but this format
|
||||
reduces the maintenance cost and allows faster understanding of
|
||||
the code.
|
||||
|
||||
```diff
|
||||
+++ Good +++
|
||||
```
|
||||
|
||||
```c
|
||||
/**
|
||||
* Short overview about the purpose of this function.
|
||||
*
|
||||
* A more detailed explanation if needed.
|
||||
*
|
||||
* Note:
|
||||
* Extra notes if needed.
|
||||
*
|
||||
* @return short description about the value
|
||||
* returned by the function
|
||||
*/
|
||||
return_value_type_t
|
||||
function_name (argument1, /**< description of argument1 */
|
||||
argument2, /**< description of argument2 */
|
||||
...
|
||||
argument_n, /**< description of argument n */
|
||||
{
|
||||
|
||||
/* Function body. */
|
||||
|
||||
} /* function_name */
|
||||
```
|
||||
|
||||
```diff
|
||||
--- Bad ---
|
||||
```
|
||||
|
||||
```c
|
||||
static int
|
||||
print (char *text) /**< description of text argument */
|
||||
{
|
||||
/* Missing comment before the function. */
|
||||
} /* print */
|
||||
|
||||
/**
|
||||
* Prints the text received by the function.
|
||||
*
|
||||
* @return number of characters printed by the function
|
||||
*/
|
||||
int print(char *text)
|
||||
{
|
||||
/* No description of text argument. */
|
||||
/* Missing comment at the end of the function. */
|
||||
}
|
||||
```
|
||||
@@ -1,894 +0,0 @@
|
||||
# jerryx_arg types
|
||||
|
||||
## jerryx_arg_t
|
||||
|
||||
**Summary**
|
||||
|
||||
The structure defining a single validation/transformation step.
|
||||
|
||||
*Note*: For commonly used validators, `arg.h` provides helpers to create the `jerryx_arg_t`s.
|
||||
For example, `jerryx_arg_number ()`, `jerryx_arg_boolean ()`, etc.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
typedef struct
|
||||
{
|
||||
/** the transform function */
|
||||
jerryx_arg_transform_func_t func;
|
||||
/** pointer to destination where func should store the result */
|
||||
void *dest;
|
||||
/** extra information, specific to func */
|
||||
uintptr_t extra_info;
|
||||
} jerryx_arg_t;
|
||||
```
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_number](#jerryx_arg_number)
|
||||
- [jerryx_arg_boolean](#jerryx_arg_boolean)
|
||||
- [jerryx_arg_string](#jerryx_arg_string)
|
||||
- [jerryx_arg_utf8_string](#jerryx_arg_utf8_string)
|
||||
- [jerryx_arg_function](#jerryx_arg_function)
|
||||
- [jerryx_arg_native_pointer](#jerryx_arg_native_pointer)
|
||||
- [jerryx_arg_ignore](#jerryx_arg_ignore)
|
||||
- [jerryx_arg_object_properties](#jerryx_arg_object_properties)
|
||||
|
||||
## jerryx_arg_object_props_t
|
||||
|
||||
**Summary**
|
||||
|
||||
The structure is used in `jerryx_arg_object_properties`. It provides the properties' names,
|
||||
its corresponding JS-to-C mapping and other related information.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
typedef struct
|
||||
{
|
||||
const jerry_char_t **name_p; /**< property name list of the JS object */
|
||||
jerry_length_t name_cnt; /**< count of the name list */
|
||||
const jerryx_arg_t *c_arg_p; /**< points to the array of transformation steps */
|
||||
jerry_length_t c_arg_cnt; /**< the count of the `c_arg_p` array */
|
||||
} jerryx_arg_object_props_t;
|
||||
```
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_object_properties](#jerryx_arg_object_properties)
|
||||
|
||||
## jerryx_arg_array_items_t
|
||||
|
||||
**Summary**
|
||||
|
||||
The structure is used in `jerryx_arg_array`. It provides the array items' corresponding
|
||||
JS-to-C mappings and count.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
typedef struct
|
||||
{
|
||||
const jerryx_arg_t *c_arg_p; /**< points to the array of transformation steps */
|
||||
jerry_length_t c_arg_cnt; /**< the count of the `c_arg_p` array */
|
||||
} jerryx_arg_array_items_t;
|
||||
```
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_array](#jerryx_arg_array)
|
||||
|
||||
## jerryx_arg_transform_func_t
|
||||
|
||||
**Summary**
|
||||
|
||||
Signature of the transform function.
|
||||
|
||||
Users can create custom transformations by implementing a transform function
|
||||
and using `jerryx_arg_custom ()`.
|
||||
|
||||
The function is expected to return `undefined` if it ran successfully or
|
||||
return an `Error` in case it failed. The function can use the iterator and the
|
||||
helpers `jerryx_arg_js_iterator_pop ()` and `jerryx_arg_js_iterator_peek ()` to
|
||||
get the next input value.
|
||||
|
||||
*Note*: A transform function is allowed to consume any number of input values!
|
||||
This enables complex validation like handling different JS function signatures,
|
||||
mapping multiple input arguments to a C struct, etc.
|
||||
|
||||
The function is expected to store the result of
|
||||
a successful transformation into `c_arg_p->dest`. In case the validation did
|
||||
not pass, the transform should not modify `c_arg_p->dest`.
|
||||
|
||||
Additional parameters can be provided to the function through `c_arg_p->extra_info`.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
typedef jerry_value_t (*jerryx_arg_transform_func_t) (jerryx_arg_js_iterator_t *js_arg_iter_p,
|
||||
const jerryx_arg_t *c_arg_p);
|
||||
```
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_custom](#jerryx_arg_custom)
|
||||
- [jerryx_arg_js_iterator_pop](#jerryx_arg_js_iterator_pop)
|
||||
- [jerryx_arg_js_iterator_peek](#jerryx_arg_js_iterator_peek)
|
||||
|
||||
|
||||
## jerryx_arg_coerce_t
|
||||
|
||||
Enum that indicates whether an argument is allowed to be coerced into the expected JS type.
|
||||
|
||||
- JERRYX_ARG_COERCE - the transform will invoke toNumber, toBoolean, toString, etc.
|
||||
- JERRYX_ARG_NO_COERCE - the type coercion is not allowed. The transform will fail if the type does not match the expectation.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_number](#jerryx_arg_number)
|
||||
- [jerryx_arg_boolean](#jerryx_arg_boolean)
|
||||
- [jerryx_arg_string](#jerryx_arg_string)
|
||||
|
||||
## jerryx_arg_optional_t
|
||||
|
||||
Enum that indicates whether an argument is optional or required.
|
||||
|
||||
- JERRYX_ARG_OPTIONAL - The argument is optional. If the argument is `undefined` the transform is successful and `c_arg_p->dest` remains untouched.
|
||||
- JERRYX_ARG_REQUIRED - The argument is required. If the argument is `undefined` the transform will fail and `c_arg_p->dest` remains untouched.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_number](#jerryx_arg_number)
|
||||
- [jerryx_arg_boolean](#jerryx_arg_boolean)
|
||||
- [jerryx_arg_string](#jerryx_arg_string)
|
||||
- [jerryx_arg_function](#jerryx_arg_function)
|
||||
- [jerryx_arg_native_pointer](#jerryx_arg_native_pointer)
|
||||
|
||||
## jerryx_arg_round_t
|
||||
|
||||
Enum that indicates the rounding policy which will be chosen to transform an integer.
|
||||
|
||||
- JERRYX_ARG_ROUND - use round() method.
|
||||
- JERRYX_ARG_FLOOR - use floor() method.
|
||||
- JERRYX_ARG_CEIL - use ceil() method.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_uint8](#jerryx_arg_uint8)
|
||||
- [jerryx_arg_uint16](#jerryx_arg_uint16)
|
||||
- [jerryx_arg_uint32](#jerryx_arg_uint32)
|
||||
- [jerryx_arg_int8](#jerryx_arg_int8)
|
||||
- [jerryx_arg_int16](#jerryx_arg_int16)
|
||||
- [jerryx_arg_int32](#jerryx_arg_int32)
|
||||
|
||||
|
||||
## jerryx_arg_clamp_t
|
||||
|
||||
Indicates the clamping policy which will be chosen to transform an integer.
|
||||
If the policy is NO_CLAMP, and the number is out of range,
|
||||
then the transformer will throw a range error.
|
||||
|
||||
- JERRYX_ARG_CLAMP - clamp the number when it is out of range
|
||||
- JERRYX_ARG_NO_CLAMP - throw a range error
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_uint8](#jerryx_arg_uint8)
|
||||
- [jerryx_arg_uint16](#jerryx_arg_uint16)
|
||||
- [jerryx_arg_uint32](#jerryx_arg_uint32)
|
||||
- [jerryx_arg_int8](#jerryx_arg_int8)
|
||||
- [jerryx_arg_int16](#jerryx_arg_int16)
|
||||
- [jerryx_arg_int32](#jerryx_arg_int32)
|
||||
|
||||
# Main functions
|
||||
|
||||
## jerryx_arg_transform_this_and_args
|
||||
|
||||
**Summary**
|
||||
|
||||
Validate the this value and the JS arguments, and assign them to the native arguments.
|
||||
This function is useful to perform input validation inside external function handlers (see `jerry_external_handler_t`).
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerryx_arg_transform_this_and_args (const jerry_value_t this_val,
|
||||
const jerry_value_t *js_arg_p,
|
||||
const jerry_length_t js_arg_cnt,
|
||||
const jerryx_arg_t *c_arg_p,
|
||||
jerry_length_t c_arg_cnt)
|
||||
```
|
||||
|
||||
- `this_val` - `this` value. Note this is processed as the first value, before the array of arguments.
|
||||
- `js_arg_p` - points to the array with JS arguments.
|
||||
- `js_arg_cnt` - the count of the `js_arg_p` array.
|
||||
- `c_arg_p` - points to the array of validation/transformation steps
|
||||
- `c_arg_cnt` - the count of the `c_arg_p` array.
|
||||
- return value - a `jerry_value_t` representing `undefined` if all validators passed or an `Error` if a validator failed.
|
||||
|
||||
**Example**
|
||||
|
||||
[doctest]: # (test="compile")
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/arg.h"
|
||||
|
||||
/* JS signature: function (requiredBool, requiredString, optionalNumber) */
|
||||
static jerry_value_t
|
||||
my_external_handler (const jerry_value_t function_obj,
|
||||
const jerry_value_t this_val,
|
||||
const jerry_value_t args_p[],
|
||||
const jerry_length_t args_count)
|
||||
{
|
||||
bool required_bool;
|
||||
char required_str[16];
|
||||
double optional_num = 1234.567; // default value
|
||||
|
||||
/* "mapping" defines the steps to transform input arguments to C variables. */
|
||||
const jerryx_arg_t mapping[] =
|
||||
{
|
||||
/* `this` is the first value. No checking needed on `this` for this function. */
|
||||
jerryx_arg_ignore (),
|
||||
|
||||
jerryx_arg_boolean (&required_bool, JERRYX_ARG_NO_COERCE, JERRYX_ARG_REQUIRED),
|
||||
jerryx_arg_string (required_str, sizeof (required_str), JERRYX_ARG_NO_COERCE, JERRYX_ARG_REQUIRED),
|
||||
jerryx_arg_number (&optional_num, JERRYX_ARG_NO_COERCE, JERRYX_ARG_OPTIONAL),
|
||||
};
|
||||
|
||||
/* Validate and transform. */
|
||||
const jerry_value_t rv = jerryx_arg_transform_this_and_args (this_val,
|
||||
args_p,
|
||||
args_count,
|
||||
mapping,
|
||||
4);
|
||||
|
||||
if (jerry_value_is_exception (rv))
|
||||
{
|
||||
/* Handle error. */
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* Validated and transformed successfully!
|
||||
* required_bool, required_str and optional_num can now be used.
|
||||
*/
|
||||
|
||||
return jerry_undefined (); /* Or return something more meaningful. */
|
||||
}
|
||||
```
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_ignore](#jerryx_arg_ignore)
|
||||
- [jerryx_arg_number](#jerryx_arg_number)
|
||||
- [jerryx_arg_boolean](#jerryx_arg_boolean)
|
||||
- [jerryx_arg_string](#jerryx_arg_string)
|
||||
- [jerryx_arg_function](#jerryx_arg_function)
|
||||
- [jerryx_arg_native_pointer](#jerryx_arg_native_pointer)
|
||||
- [jerryx_arg_custom](#jerryx_arg_custom)
|
||||
- [jerryx_arg_object_properties](#jerryx_arg_object_properties)
|
||||
|
||||
|
||||
## jerryx_arg_transform_args
|
||||
|
||||
**Summary**
|
||||
|
||||
Validate an array of `jerry_value_t` and assign them to the native arguments.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerryx_arg_transform_args (const jerry_value_t *js_arg_p,
|
||||
const jerry_length_t js_arg_cnt,
|
||||
const jerryx_arg_t *c_arg_p,
|
||||
jerry_length_t c_arg_cnt)
|
||||
```
|
||||
|
||||
- `js_arg_p` - points to the array with JS arguments.
|
||||
- `js_arg_cnt` - the count of the `js_arg_p` array.
|
||||
- `c_arg_p` - points to the array of validation/transformation steps
|
||||
- `c_arg_cnt` - the count of the `c_arg_p` array.
|
||||
- return value - a `jerry_value_t` representing `undefined` if all validators passed or an `Error` if a validator failed.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_transform_this_and_args](#jerryx_arg_transform_this_and_args)
|
||||
|
||||
|
||||
## jerryx_arg_transform_object_properties
|
||||
|
||||
**Summary**
|
||||
|
||||
Validate the properties of a JS object and assign them to the native arguments.
|
||||
|
||||
*Note*: This function transforms properties of a single JS object into native C values.
|
||||
To transform multiple objects in one pass (for example when converting multiple arguments
|
||||
to an external handler), please use `jerryx_arg_object_properties` together with
|
||||
`jerryx_arg_transform_this_and_args` or `jerryx_arg_transform_args`.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerryx_arg_transform_object_properties (const jerry_value_t obj_val,
|
||||
const jerry_char_t **name_p,
|
||||
const jerry_length_t name_cnt,
|
||||
const jerryx_arg_t *c_arg_p,
|
||||
jerry_length_t c_arg_cnt);
|
||||
|
||||
```
|
||||
|
||||
- `obj_val` - the JS object.
|
||||
- `name_p` - points to the array of property names.
|
||||
- `name_cnt` - the count of the `name_p` array.
|
||||
- `c_arg_p` - points to the array of validation/transformation steps
|
||||
- `c_arg_cnt` - the count of the `c_arg_p` array.
|
||||
- return value - a `jerry_value_t` representing `undefined` if all validators passed or an `Error` if a validator failed.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_object_properties](#jerryx_arg_object_properties)
|
||||
|
||||
## jerryx_arg_transform_array
|
||||
|
||||
**Summary**
|
||||
|
||||
Validate the JS array and assign its items to the native arguments.
|
||||
|
||||
*Note*: This function transforms items of a single JS array into native C values.
|
||||
To transform multiple JS arguments in one pass, please use `jerryx_arg_array` together with
|
||||
`jerryx_arg_transform_this_and_args` or `jerryx_arg_transform_args`.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerryx_arg_transform_array (const jerry_value_t array_val,
|
||||
const jerryx_arg_t *c_arg_p,
|
||||
jerry_length_t c_arg_cnt);
|
||||
|
||||
```
|
||||
|
||||
- `array_val` - the JS array.
|
||||
- `c_arg_p` - points to the array of validation/transformation steps
|
||||
- `c_arg_cnt` - the count of the `c_arg_p` array.
|
||||
- return value - a `jerry_value_t` representing `undefined` if all validators passed or an `Error` if a validator failed.
|
||||
|
||||
**See also**
|
||||
|
||||
- [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
|
||||
|
||||
## jerryx_arg_uint8
|
||||
|
||||
## jerryx_arg_uint16
|
||||
|
||||
## jerryx_arg_uint32
|
||||
|
||||
## jerryx_arg_int8
|
||||
|
||||
## jerryx_arg_int16
|
||||
|
||||
## jerryx_arg_int32
|
||||
|
||||
**Summary**
|
||||
|
||||
All above jerryx_arg_[u]intX functions are used to create a validation/transformation step
|
||||
(`jerryx_arg_t`) that expects to consume one `number` JS argument
|
||||
and stores it into a C integer (uint8, int8, uint16, ...)
|
||||
|
||||
**Prototype**
|
||||
|
||||
Take jerryx_arg_int32 as an example
|
||||
|
||||
```c
|
||||
static inline jerryx_arg_t
|
||||
jerryx_arg_int32 (int32_t *dest,
|
||||
jerryx_arg_round_t round_flag,
|
||||
jerryx_arg_clamp_t clamp_flag,
|
||||
jerryx_arg_coerce_t coerce_flag,
|
||||
jerryx_arg_optional_t opt_flag);
|
||||
```
|
||||
|
||||
- return value - the created `jerryx_arg_t` instance.
|
||||
- `dest` - pointer to the `int32_t` where the result should be stored.
|
||||
- `round_flag` - the rounding policy.
|
||||
- `clamp_flag` - the clamping policy.
|
||||
- `coerce_flag` - whether type coercion is allowed.
|
||||
- `opt_flag` - whether the argument is optional.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_transform_this_and_args](#jerryx_arg_transform_this_and_args)
|
||||
|
||||
|
||||
## jerryx_arg_number
|
||||
|
||||
**Summary**
|
||||
|
||||
Create a validation/transformation step (`jerryx_arg_t`) that expects to consume
|
||||
one `number` JS argument and stores it into a C `double`.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
static inline jerryx_arg_t
|
||||
jerryx_arg_number (double *dest,
|
||||
jerryx_arg_coerce_t coerce_flag,
|
||||
jerryx_arg_optional_t opt_flag)
|
||||
```
|
||||
|
||||
- return value - the created `jerryx_arg_t` instance.
|
||||
- `dest` - pointer to the `double` where the result should be stored.
|
||||
- `coerce_flag` - whether type coercion is allowed.
|
||||
- `opt_flag` - whether the argument is optional.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_transform_this_and_args](#jerryx_arg_transform_this_and_args)
|
||||
|
||||
## jerryx_arg_boolean
|
||||
|
||||
**Summary**
|
||||
|
||||
Create a validation/transformation step (`jerryx_arg_t`) that expects to
|
||||
consume one `boolean` JS argument and stores it into a C `bool`.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
static inline jerryx_arg_t
|
||||
jerryx_arg_boolean (bool *dest,
|
||||
jerryx_arg_coerce_t coerce_flag,
|
||||
jerryx_arg_optional_t opt_flag)
|
||||
```
|
||||
- return value - the created `jerryx_arg_t` instance.
|
||||
- `dest` - pointer to the `bool` where the result should be stored.
|
||||
- `coerce_flag` - whether type coercion is allowed.
|
||||
- `opt_flag` - whether the argument is optional.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_transform_this_and_args](#jerryx_arg_transform_this_and_args)
|
||||
|
||||
|
||||
## jerryx_arg_string
|
||||
|
||||
**Summary**
|
||||
|
||||
Create a validation/transformation step (`jerryx_arg_t`) that expects to
|
||||
consume one `string` JS argument and stores it into a CESU-8 C `char` array.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
static inline jerryx_arg_t
|
||||
jerryx_arg_string (char *dest,
|
||||
uint32_t size,
|
||||
jerryx_arg_coerce_t coerce_flag,
|
||||
jerryx_arg_optional_t opt_flag)
|
||||
```
|
||||
|
||||
- return value - the created `jerryx_arg_t` instance.
|
||||
- `dest` - pointer to the native char array where the result should be stored.
|
||||
- `size` - the size of native char array.
|
||||
- `coerce_flag` - whether type coercion is allowed.
|
||||
- `opt_flag` - whether the argument is optional.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_transform_this_and_args](#jerryx_arg_transform_this_and_args)
|
||||
- [jerry_arg_utf8_string](#jerry_arg_utf8_string)
|
||||
|
||||
|
||||
## jerryx_arg_utf8_string
|
||||
|
||||
**Summary**
|
||||
|
||||
Create a validation/transformation step (`jerryx_arg_t`) that expects to
|
||||
consume one `string` JS argument and stores it into a UTF-8 C `char` array.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
static inline jerryx_arg_t
|
||||
jerryx_arg_utf8_string (char *dest,
|
||||
uint32_t size,
|
||||
jerryx_arg_coerce_t coerce_flag,
|
||||
jerryx_arg_optional_t opt_flag)
|
||||
```
|
||||
|
||||
- return value - the created `jerryx_arg_t` instance.
|
||||
- `dest` - pointer to the native char array where the result should be stored.
|
||||
- `size` - the size of native char array.
|
||||
- `coerce_flag` - whether type coercion is allowed.
|
||||
- `opt_flag` - whether the argument is optional.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_transform_this_and_args](#jerryx_arg_transform_this_and_args)
|
||||
- [jerry_arg_string](#jerry_arg_string)
|
||||
|
||||
|
||||
## jerryx_arg_function
|
||||
|
||||
**Summary**
|
||||
|
||||
Create a validation/transformation step (`jerryx_arg_t`) that expects to
|
||||
consume one `function` JS argument and stores it into a C `jerry_value_t`.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
static inline jerryx_arg_t
|
||||
jerryx_arg_function (jerry_value_t *dest,
|
||||
jerryx_arg_optional_t opt_flag)
|
||||
|
||||
```
|
||||
- return value - the created `jerryx_arg_t` instance.
|
||||
- `dest` - pointer to the `jerry_value_t` where the result should be stored.
|
||||
- `opt_flag` - whether the argument is optional.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_transform_this_and_args](#jerryx_arg_transform_this_and_args)
|
||||
|
||||
## jerryx_arg_native_pointer
|
||||
|
||||
**Summary**
|
||||
|
||||
Create a validation/transformation step (`jerryx_arg_t`) that expects to
|
||||
consume one `object` JS argument that is 'backed' with a native pointer with
|
||||
a given type info. In case the native pointer info matches, the transform
|
||||
will succeed and the object's native pointer will be assigned to `*dest`.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
static inline jerryx_arg_t
|
||||
jerryx_arg_native_pointer (void **dest,
|
||||
const jerry_object_native_info_t *info_p,
|
||||
jerryx_arg_optional_t opt_flag)
|
||||
```
|
||||
- return value - the created `jerryx_arg_t` instance.
|
||||
- `dest` - pointer to where the resulting native pointer should be stored.
|
||||
- `info_p` - expected the type info.
|
||||
- `opt_flag` - whether the argument is optional.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_transform_this_and_args](#jerryx_arg_transform_this_and_args)
|
||||
|
||||
## jerryx_arg_object_properties
|
||||
|
||||
**Summary**
|
||||
|
||||
Create a validation/transformation step (`jerryx_arg_t`) that expects to
|
||||
consume one `object` JS argument and call `jerryx_arg_transform_object_properties` inside
|
||||
to transform its properties to native arguments.
|
||||
User should prepare the `jerryx_arg_object_props_t` instance, and pass it to this function.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
static inline jerryx_arg_t
|
||||
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.
|
||||
- `obj_prop_p` - provides information for properties transform.
|
||||
- `opt_flag` - whether the argument is optional.
|
||||
|
||||
**Example**
|
||||
|
||||
[doctest]: # (test="compile")
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/arg.h"
|
||||
|
||||
/**
|
||||
* The binding function expects args_p[0] is an object, which has 3 properties:
|
||||
* "enable": boolean
|
||||
* "data": number
|
||||
* "extra_data": number, optional
|
||||
*/
|
||||
static jerry_value_t
|
||||
my_external_handler (const jerry_value_t function_obj,
|
||||
const jerry_value_t this_val,
|
||||
const jerry_value_t args_p[],
|
||||
const jerry_length_t args_count)
|
||||
{
|
||||
bool required_bool;
|
||||
double required_num;
|
||||
double optional_num = 1234.567; // default value
|
||||
|
||||
/* "prop_name_p" defines the name list of the expected properties' names. */
|
||||
const char *prop_name_p[] = { "enable", "data", "extra_data" };
|
||||
|
||||
/* "prop_mapping" defines the steps to transform properties to C variables. */
|
||||
const jerryx_arg_t prop_mapping[] =
|
||||
{
|
||||
jerryx_arg_boolean (&required_bool, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
|
||||
jerryx_arg_number (&required_num, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
|
||||
jerryx_arg_number (&optional_num, JERRYX_ARG_COERCE, JERRYX_ARG_OPTIONAL)
|
||||
};
|
||||
|
||||
/* Prepare the jerryx_arg_object_props_t instance. */
|
||||
const jerryx_arg_object_props_t prop_info =
|
||||
{
|
||||
.name_p = (const jerry_char_t **) prop_name_p,
|
||||
.name_cnt = 3,
|
||||
.c_arg_p = prop_mapping,
|
||||
.c_arg_cnt = 3
|
||||
};
|
||||
|
||||
/* It is the mapping used in the jerryx_arg_transform_args. */
|
||||
const jerryx_arg_t mapping[] =
|
||||
{
|
||||
jerryx_arg_object_properties (&prop_info, JERRYX_ARG_REQUIRED)
|
||||
};
|
||||
|
||||
/* Validate and transform. */
|
||||
const jerry_value_t rv = jerryx_arg_transform_args (args_p,
|
||||
args_count,
|
||||
mapping,
|
||||
1);
|
||||
|
||||
if (jerry_value_is_exception (rv))
|
||||
{
|
||||
/* Handle error. */
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* Validated and transformed successfully!
|
||||
* required_bool, required_num and optional_num can now be used.
|
||||
*/
|
||||
|
||||
return jerry_undefined (); /* Or return something more meaningful. */
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_transform_this_and_args](#jerryx_arg_transform_this_and_args)
|
||||
- [jerryx_arg_transform_object_properties](#jerryx_arg_transform_object_properties)
|
||||
|
||||
## jerryx_arg_array
|
||||
|
||||
**Summary**
|
||||
|
||||
Create a validation/transformation step (`jerryx_arg_t`) that expects to
|
||||
consume one `array` JS argument and call `jerryx_arg_transform_array_items` inside
|
||||
to transform its items to native arguments.
|
||||
User should prepare the `jerryx_arg_array_items_t` instance, and pass it to this function.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
static inline jerryx_arg_t
|
||||
jerryx_arg_array (const jerryx_arg_array_items_t *array_items_p, jerryx_arg_optional_t opt_flag);
|
||||
```
|
||||
- return value - the created `jerryx_arg_t` instance.
|
||||
- `array_items_p` - provides items information for transform.
|
||||
- `opt_flag` - whether the argument is optional.
|
||||
|
||||
**Example**
|
||||
|
||||
[doctest]: # (test="compile")
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/arg.h"
|
||||
|
||||
/**
|
||||
* The binding function expects args_p[0] is an array, which has 3 items:
|
||||
* first: boolean
|
||||
* second: number
|
||||
* third: number, optional
|
||||
*/
|
||||
static jerry_value_t
|
||||
my_external_handler (const jerry_value_t function_obj,
|
||||
const jerry_value_t this_val,
|
||||
const jerry_value_t args_p[],
|
||||
const jerry_length_t args_count)
|
||||
{
|
||||
bool required_bool;
|
||||
double required_num;
|
||||
double optional_num = 1234.567; // default value
|
||||
|
||||
/* "item_mapping" defines the steps to transform array items to C variables. */
|
||||
const jerryx_arg_t item_mapping[] =
|
||||
{
|
||||
jerryx_arg_boolean (&required_bool, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
|
||||
jerryx_arg_number (&required_num, JERRYX_ARG_COERCE, JERRYX_ARG_REQUIRED),
|
||||
jerryx_arg_number (&optional_num, JERRYX_ARG_COERCE, JERRYX_ARG_OPTIONAL)
|
||||
};
|
||||
|
||||
/* Prepare the jerryx_arg_array_items_t instance. */
|
||||
const jerryx_arg_array_items_t array_info =
|
||||
{
|
||||
.c_arg_p = item_mapping,
|
||||
.c_arg_cnt = 3
|
||||
};
|
||||
|
||||
/* It is the mapping used in the jerryx_arg_transform_args. */
|
||||
const jerryx_arg_t mapping[] =
|
||||
{
|
||||
jerryx_arg_array (&array_info, JERRYX_ARG_REQUIRED)
|
||||
};
|
||||
|
||||
/* Validate and transform. */
|
||||
const jerry_value_t rv = jerryx_arg_transform_args (args_p,
|
||||
args_count,
|
||||
mapping,
|
||||
1);
|
||||
|
||||
if (jerry_value_is_exception (rv))
|
||||
{
|
||||
/* Handle error. */
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* Validated and transformed successfully!
|
||||
* required_bool, required_num and optional_num can now be used.
|
||||
*/
|
||||
|
||||
return jerry_undefined (); /* Or return something more meaningful. */
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_transform_this_and_args](#jerryx_arg_transform_this_and_args)
|
||||
- [jerryx_arg_transform_object_properties](#jerryx_arg_transform_object_properties)
|
||||
|
||||
# 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**
|
||||
|
||||
Create a jerryx_arg_t instance with custom transform.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
static inline jerryx_arg_t
|
||||
jerryx_arg_custom (void *dest,
|
||||
uintptr_t extra_info,
|
||||
jerryx_arg_transform_func_t func)
|
||||
|
||||
```
|
||||
- return value - the created `jerryx_arg_t` instance.
|
||||
- `dest` - pointer to the native argument where the result should be stored.
|
||||
- `extra_info` - the extra parameter data, specific to the transform function.
|
||||
- `func` - the custom transform function.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_arg_transform_this_and_args](#jerryx_arg_transform_this_and_args)
|
||||
|
||||
|
||||
|
||||
## jerryx_arg_js_iterator_pop
|
||||
|
||||
**Summary**
|
||||
|
||||
Pop the current `jerry_value_t` argument from the iterator.
|
||||
It will change the `js_arg_idx` and `js_arg_p` value in the iterator.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerryx_arg_js_iterator_pop (jerryx_arg_js_iterator_t *js_arg_iter_p)
|
||||
```
|
||||
- return value - the `jerry_value_t` argument that was popped.
|
||||
- `js_arg_iter_p` - the JS arg iterator from which to pop.
|
||||
|
||||
## jerryx_arg_js_iterator_peek
|
||||
|
||||
**Summary**
|
||||
|
||||
Get the current JS argument from the iterator, without moving the iterator forward.
|
||||
*Note:* Unlike `jerryx_arg_js_iterator_pop ()`, it will not change `js_arg_idx` and
|
||||
`js_arg_p` value in the iterator.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerryx_arg_js_iterator_peek (jerryx_arg_js_iterator_t *js_arg_iter_p)
|
||||
```
|
||||
- return value - the current `jerry_value_t` argument.
|
||||
- `js_arg_iter_p` - the JS arg iterator from which to peek.
|
||||
|
||||
## jerryx_arg_js_iterator_restore
|
||||
|
||||
**Summary**
|
||||
|
||||
Restore the last item popped from the stack. This can be called as
|
||||
many times as there are arguments on the stack -- if called when the
|
||||
first element in the array is the current top of the stack, this
|
||||
function does nothing.
|
||||
|
||||
*Note:* This function relies on the underlying implementation of the
|
||||
arg stack as an array, as its function is to simply back up the "top
|
||||
of stack" pointer to point to the previous element of the array.
|
||||
|
||||
*Note:* Like `jerryx_arg_js_iterator_pop ()`, this function will
|
||||
change the `js_arg_idx` and `js_arg_p` values in the iterator.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerryx_arg_js_iterator_restore (jerryx_arg_js_iterator_t *js_arg_iter_p)
|
||||
```
|
||||
- return value - the the new top of the stack.
|
||||
- `js_arg_iter_p` - the JS arg iterator to restore.
|
||||
|
||||
|
||||
## jerryx_arg_js_iterator_index
|
||||
|
||||
**Summary**
|
||||
|
||||
Get the index of the current JS argument from the iterator.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_length_t
|
||||
jerryx_arg_js_iterator_index (jerryx_arg_js_iterator_t *js_arg_iter_p)
|
||||
```
|
||||
- return value - the index of current JS argument.
|
||||
- `js_arg_iter_p` - the JS arg iterator from which to peek.
|
||||
@@ -1,407 +0,0 @@
|
||||
# Common methods to handle properties
|
||||
|
||||
The `jerryscript-ext/properties.h` header defines a set of convenience methods
|
||||
which makes the property access a bit straightforward.
|
||||
|
||||
# Utility to register multiple properties in bulk
|
||||
|
||||
In some cases it is useful to register multiple properties for a given object
|
||||
for this the following utility structures and methods are provided.
|
||||
|
||||
## jerryx_property_entry
|
||||
|
||||
**Summary**
|
||||
|
||||
Structure to define an array of properties with `name` and `value` fields which
|
||||
can be registered to a target object.
|
||||
|
||||
The engine must be initialized before specifying the `jerry_value_t` in the struct.
|
||||
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
typedef struct {
|
||||
const char *name;
|
||||
jerry_value_t value;
|
||||
} jerryx_property_entry;
|
||||
```
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_set_properties](#jerryx_set_properties)
|
||||
|
||||
|
||||
## jerryx_register_result
|
||||
|
||||
**Summary**
|
||||
|
||||
Structure returned as the result of the [jerryx_set_properties](#jerryx_set_properties) operation.
|
||||
The `result` field will either be a JavaScript undefined value or an error object.
|
||||
In every case the `registered` field is used to indicated the number of
|
||||
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 occurred during the property registration the `result` field of the structure
|
||||
must be manually released after processing the error value.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
typedef struct {
|
||||
jerry_value_t result;
|
||||
uint32_t registered;
|
||||
} jerryx_register_result;
|
||||
```
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_set_properties](#jerryx_set_properties)
|
||||
- [jerryx_release_property_entry](#jerryx_release_property_entry)
|
||||
|
||||
|
||||
## jerryx_set_properties
|
||||
|
||||
**Summary**
|
||||
|
||||
Set multiple properties on a target object.
|
||||
|
||||
The properties are an array of (name, jerry_value_t) pairs and
|
||||
this list must end with a (NULL, 0) entry.
|
||||
|
||||
Important notes:
|
||||
* Each property value in the input array is released after a successful property registration.
|
||||
* The method [jerryx_release_property_entry](#jerryx_release_property_entry) must be called if there is any failed registration
|
||||
to release the values in the entries array.
|
||||
It is safe to call this cleanup method in every case not just in case of failure.
|
||||
* If the error value is reported via the result it must be freed manually.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerryx_register_result
|
||||
jerryx_set_properties (const jerry_value_t target_object,
|
||||
const jerryx_property_entry entries[]);
|
||||
```
|
||||
|
||||
- `target_object` - object on which the entries will be set.
|
||||
- `entries` - array of (name, jerry_value_t) pairs.
|
||||
- return a [jerryx_register_result](#jerryx_register_result).
|
||||
- if everything is ok, the struct's `result` field is set to a JS undefined value.
|
||||
- otherwise the `result` field is an error object indicating the problem.
|
||||
- in every case the `registered` field contains the number of successfully registered properties.
|
||||
|
||||
**Example**
|
||||
|
||||
[doctest]: # ()
|
||||
|
||||
```c
|
||||
#include <stdio.h>
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/handlers.h"
|
||||
#include "jerryscript-ext/properties.h"
|
||||
|
||||
static jerry_value_t
|
||||
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_boolean (true);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
|
||||
jerryx_property_entry methods[] =
|
||||
{
|
||||
{ "demo", jerry_function_external (handler) },
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
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_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_value_free (reg.result);
|
||||
}
|
||||
|
||||
jerry_value_free (global);
|
||||
|
||||
jerry_cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
**Convenience macros**
|
||||
|
||||
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, 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.
|
||||
* `JERRYX_PROPERTY_LIST_END()` - indicates the end of the property list.
|
||||
|
||||
**Example usage of Convenience macros**
|
||||
|
||||
[doctest]: # ()
|
||||
|
||||
```c
|
||||
#include <stdio.h>
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/handlers.h"
|
||||
#include "jerryscript-ext/properties.h"
|
||||
|
||||
static jerry_value_t
|
||||
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_boolean (true);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
|
||||
/**
|
||||
* Create a array of properties to be registered.
|
||||
* This must be done after initializing the engine as creating `jerry_value_t`
|
||||
* elements are invalid before `jerry_init`.
|
||||
*/
|
||||
jerryx_property_entry methods[] =
|
||||
{
|
||||
JERRYX_PROPERTY_FUNCTION ("demo", handler),
|
||||
JERRYX_PROPERTY_NUMBER ("test_num", 2.3),
|
||||
JERRYX_PROPERTY_UNDEFINED ("this_is_undefined"),
|
||||
JERRYX_PROPERTY_LIST_END(),
|
||||
};
|
||||
|
||||
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_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_value_free (reg.result);
|
||||
}
|
||||
|
||||
jerry_value_free (global);
|
||||
|
||||
jerry_cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_property_entry](#jerryx_property_entry)
|
||||
- [jerryx_release_property_entry](#jerryx_release_property_entry)
|
||||
- [jerryx_register_result](#jerryx_register_result)
|
||||
|
||||
## jerryx_release_property_entry
|
||||
|
||||
**Summary**
|
||||
|
||||
Release all `jerry_value_t` in a `jerryx_property_entry` array based on a previous [jerryx_set_properties](#jerryx_set_properties) call
|
||||
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 `entries` array should not be used as all values are released.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```
|
||||
void
|
||||
jerryx_release_property_entry (const jerryx_property_entry entries[],
|
||||
const jerryx_register_result register_result);
|
||||
```
|
||||
|
||||
- `entries` - array of [jerryx_property_entry](#jerryx_property_entry).
|
||||
- `register_result` - result of a previous [jerryx_set_properties](#jerryx_set_properties) call.
|
||||
|
||||
**Example**
|
||||
|
||||
For example usage see [jerryx_set_properties](#jerryx_set_properties).
|
||||
|
||||
|
||||
# Common external function handlers
|
||||
|
||||
## jerryx_handler_assert
|
||||
|
||||
**Summary**
|
||||
|
||||
Hard assert for scripts. The routine calls `jerry_port_fatal` on assertion failure.
|
||||
|
||||
If the `JERRY_FEATURE_LINE_INFO` runtime feature is enabled (build option: `JERRY_LINE_INFO`)
|
||||
a backtrace is also printed out.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerryx_handler_assert (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t args_p[],
|
||||
const jerry_length_t args_cnt);
|
||||
```
|
||||
|
||||
- `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
|
||||
was passed and that argument was a boolean true. Note that the function does
|
||||
not return otherwise.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_register_global](#jerryx_register_global)
|
||||
|
||||
|
||||
## jerryx_handler_gc
|
||||
|
||||
**Summary**
|
||||
|
||||
Expose garbage collector to scripts. If the first argument of the function
|
||||
is logical true, it performs a high pressure gc. Otherwise a low pressure
|
||||
gc is performed, which is also the default if no parameters passed.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerryx_handler_gc (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t args_p[],
|
||||
const jerry_length_t args_cnt);
|
||||
```
|
||||
|
||||
- `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_register_global](#jerryx_register_global)
|
||||
|
||||
|
||||
## jerryx_handler_print
|
||||
|
||||
**Summary**
|
||||
|
||||
Provide a `print` implementation for scripts. The routine converts all of its
|
||||
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_buffer`.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerryx_handler_print (const jerry_call_info_t *call_info_p,
|
||||
const jerry_value_t args_p[],
|
||||
const jerry_length_t args_cnt);
|
||||
```
|
||||
|
||||
- `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
|
||||
be converted to strings, an `Error` otherwise.
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerryx_register_global](#jerryx_register_global)
|
||||
- [jerry_port_print_buffer](05.PORT-API.md#jerry_port_print_buffer)
|
||||
|
||||
|
||||
# Handler registration helper
|
||||
|
||||
## jerryx_register_global
|
||||
|
||||
**Summary**
|
||||
|
||||
Register a JavaScript function in the global object.
|
||||
|
||||
*Note*: Returned value must be freed with `jerry_value_free`, when it is no
|
||||
longer needed.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerryx_register_global (const char *name_p,
|
||||
jerry_external_handler_t handler_p);
|
||||
```
|
||||
|
||||
- `name_p` - the name of the function to be registered.
|
||||
- `handler_p` - the address of the external function handler.
|
||||
- return value - `jerry_value_t` representing boolean true, if the operation was
|
||||
successful, an `Error` otherwise.
|
||||
|
||||
**Example**
|
||||
|
||||
[doctest]: # (test="compile")
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/handlers.h"
|
||||
#include "jerryscript-ext/properties.h"
|
||||
|
||||
static const struct {
|
||||
const char *name_p;
|
||||
jerry_external_handler_t handler_p;
|
||||
} common_functions[] =
|
||||
{
|
||||
{ "assert", jerryx_handler_assert },
|
||||
{ "gc", jerryx_handler_gc },
|
||||
{ "print", jerryx_handler_print },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
register_common_functions (void)
|
||||
{
|
||||
jerry_value_t ret = jerry_undefined ();
|
||||
|
||||
for (int i = 0; common_functions[i].name_p != NULL && !jerry_value_is_exception (ret); i++)
|
||||
{
|
||||
ret = jerryx_register_global (common_functions[i].name_p,
|
||||
common_functions[i].handler_p);
|
||||
}
|
||||
|
||||
jerry_value_free (ret);
|
||||
}
|
||||
```
|
||||
@@ -1,50 +0,0 @@
|
||||
# Autorelease values
|
||||
|
||||
## JERRYX_AR_VALUE_T
|
||||
|
||||
**Summary**
|
||||
|
||||
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
|
||||
using the `__cleanup__` variable attribute. For other compilers, no support has been added yet.
|
||||
|
||||
**Example**
|
||||
|
||||
[doctest]: # (test="compile", name="11.EXT-REFERENCE-AUTORELEASE.c")
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/autorelease.h"
|
||||
|
||||
static void
|
||||
foo (bool enable)
|
||||
{
|
||||
JERRYX_AR_VALUE_T bar = jerry_string_sz ("...");
|
||||
|
||||
if (enable)
|
||||
{
|
||||
JERRYX_AR_VALUE_T baz = jerry_current_realm ();
|
||||
|
||||
/* bar and baz can now be used. */
|
||||
|
||||
/*
|
||||
* jerry_value_free (baz) and jerry_value_free (bar) is called automatically before
|
||||
* returning, because `baz` and `bar` go out of scope.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* jerry_value_free (bar) is called automatically when the function returns,
|
||||
* because `bar` goes out of scope.
|
||||
*/
|
||||
}
|
||||
```
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerry_value_t](../docs/02.API-REFERENCE.md#jerry_value_t)
|
||||
- [jerry_value_copy](../docs/02.API-REFERENCE.md#jerry_value_copy)
|
||||
- [jerry_value_free](../docs/02.API-REFERENCE.md#jerry_value_free)
|
||||
@@ -1,314 +0,0 @@
|
||||
# Module API
|
||||
|
||||
This is a JerryScript extension that provides a means of loading modules. Fundamentally, a module is a name (stored as
|
||||
a string) that resolves to a `jerry_value_t`. This extension provides the function `jerryx_module_resolve()` which
|
||||
accepts the name of the module being requested as well as an array of so-called "resolvers" - structures containing two
|
||||
function pointers: one for a function which computes a canonical name for the requested module or returns a reference
|
||||
to the requested name, and one that converts a canonical name to a `jerry_value_t`, thus "resolving" or "loading" the
|
||||
requested module.
|
||||
|
||||
The resolvers are first called in sequence to each compute the canonical name of the requested module. This is
|
||||
accomplished by calling the `get_canonical_name` function pointer they provide. If the function pointer is `NULL`, the
|
||||
requested module name is assumed to be what the resolver considers to be its canonical name. `jerryx_module_resolve`
|
||||
searches its cache of loaded modules for each canonical name as returned by a `get_canonical_name` function pointer. If
|
||||
one of the loaded modules in the cache corresponds to a canonical name, it is returned.
|
||||
|
||||
If no cached module is found, `jerryx_module_resolve` calls each resolver's `resolve` function pointer, passing it its
|
||||
previously computed interpretation of the requested module's canonical name. If the resolver successfully creates the
|
||||
`jerry_value_t` that represents the loaded module, it returns `true` and the `jerry_value_t` in its out parameter.
|
||||
|
||||
When `jerryx_module_resolve` receives a value of `true` from a resolver, it stops iterating over the remaining
|
||||
resolvers in the sequence and, if the `jerry_value_t` returned from the resolver's `resolve` does not have the error
|
||||
flag set, it will add the `jerry_value_t` to its cache under the module's canonical name and return it. Thus, on
|
||||
subsequent calls to `jerryx_module_resolve` with a module name whose canonical name is associated with the
|
||||
`jerry_value_t`, no `resolve` callback need be called again.
|
||||
|
||||
The purpose of having resolvers is to be able to account for the fact that different types of modules may be structured
|
||||
differently and thus, for each type of module a module resolver must be supplied at the point where an instance of that
|
||||
type of module is requested.
|
||||
|
||||
Individual modules may be removed from the cache by calling `jerryx_module_clear_cache`. This function behaves
|
||||
identically to `jerryx_module_resolve` in that it first checks the cache for the requested module, except that it
|
||||
removes the module if found. Additionally, it clears the entire cache of all modules if called using a JavaScript value
|
||||
of `undefined` as its first parameter.
|
||||
|
||||
Additionally, this extension provides a means of easily defining so-called "native" JerryScript modules which can be
|
||||
resolved using the native JerryScript module resolver `jerryx_module_native_resolver`, which can be passed to
|
||||
`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: On windows, `FEATURE_INIT_FINI` build flag only supported with GNU toolchain or Microsoft Visual C/C++ Compiler
|
||||
2008 and upper.
|
||||
|
||||
## jerryx_module_resolve
|
||||
|
||||
**Summary**
|
||||
|
||||
Load a copy of a module into the current context or return one that was already loaded if it is found.
|
||||
|
||||
For each resolver passed in via `resolvers_p`, its `get_canonical_name` function pointer gets called in order to
|
||||
establish the resolver's interpretation of what the canonical name for the module should be. If `get_canonical_name` is
|
||||
`NULL`, it is assumed that the requested module's name as passed in is its canonical name.
|
||||
|
||||
Then, for each resolver passed in via `resolvers_p`, its `resolve` function pointer gets called with its interpretation
|
||||
of what the module's canonical name should be, as computed in the previous step.
|
||||
|
||||
If the resolver's `resolve` function pointer returns `true`, the `jerry_value_t` returned in its out-parameter will be
|
||||
returned by `jerryx_module_resolve` as the result of the request. If no error flag is set on the `jerry_value_t` it
|
||||
will be cached under its canonical name so as to avoid loading the same module twice in the event of a subsequent call
|
||||
to `jerryx_module_resolve` with a module name whose canonical name matches an already loaded module.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerryx_module_resolve (const jerry_value_t name,
|
||||
const jerryx_module_resolver_t **resolvers_p,
|
||||
size_t resolver_count);
|
||||
```
|
||||
|
||||
- `name` - the name of the module to load
|
||||
- `resolvers_p` - the list of resolvers to call in sequence
|
||||
- `resolver_count` - the number of resolvers in `resolvers_p`
|
||||
- return value - `jerry_value_t` representing the module that was loaded, or the error that occurred in the process.
|
||||
|
||||
|
||||
## jerryx_module_clear_cache
|
||||
|
||||
**Summary**
|
||||
|
||||
Remove a module from the current context's cache, or clear the cache entirely.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
void
|
||||
jerryx_module_clear_cache (const jerry_value_t name,
|
||||
const jerryx_module_resolver_t **resolvers_p,
|
||||
size_t resolver_count);
|
||||
```
|
||||
|
||||
- `name` - the name of the module to remove from cache or a JavaScript `undefined` to clear the entire cache
|
||||
- `resolvers_p` - the list of resolvers to call in sequence
|
||||
- `resolver_count` - the number of resolvers in `resolvers_p`
|
||||
|
||||
|
||||
## jerryx_module_native_resolver
|
||||
|
||||
**Summary**
|
||||
|
||||
The resolver for native JerryScript modules. A pointer to this structure can be passed in the second parameter to
|
||||
`jerryx_module_resolve` to search for the module among the native JerryScript modules built into the binary. This
|
||||
function is available only if the preprocessor directive `JERRYX_NATIVE_MODULES_SUPPORTED` is defined.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
extern jerry_module_resolver_t jerryx_native_module_resolver;
|
||||
```
|
||||
|
||||
# Module data types
|
||||
|
||||
## jerryx_module_get_canonical_name_t
|
||||
|
||||
**Summary**
|
||||
|
||||
The function pointer type for converting a module's requested name to its canonical name.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
typedef jerry_value_t (*jerryx_module_get_canonical_name_t) (const jerry_value_t name);
|
||||
```
|
||||
|
||||
## jerryx_module_resolve_t
|
||||
|
||||
**Summary**
|
||||
|
||||
Function pointer type for module resolution.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
typedef bool (*jerryx_module_resolve_t) (const jerry_value_t canonical_name,
|
||||
jerry_value_t *result);
|
||||
```
|
||||
|
||||
## jerryx_module_resolver_t
|
||||
|
||||
**Summary**
|
||||
|
||||
Structure defining a module resolver.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
typedef struct
|
||||
{
|
||||
jerryx_module_get_canonical_name_t get_canonical_name_p;
|
||||
jerryx_module_resolve_t resolve_p;
|
||||
} jerryx_module_resolver_t;
|
||||
```
|
||||
|
||||
- `get_canonical_name_p` - function pointer to be called when the canonical name corresponding to the requested name
|
||||
of a module must be established.
|
||||
- `resolve_p` - function pointer to be called when a module with the given canonical name needs to be converted to the
|
||||
`jerry_value_t` that will become the loaded module.
|
||||
|
||||
**Example**
|
||||
```c
|
||||
static bool
|
||||
load_and_evaluate_js_file (const jerry_value_t name, jerry_value_t *result)
|
||||
{
|
||||
bool return_value = false;
|
||||
char *js_file_contents = NULL;
|
||||
int file_size = 0;
|
||||
|
||||
jerry_size_t name_size = jerry_string_size (name, JERRY_ENCODING_UTF8);
|
||||
jerry_char_t name_string[name_size + 1];
|
||||
jerry_string_to_buffer (name, JERRY_ENCODING_UTF8, name_string, name_size);
|
||||
name_string[name_size] = 0;
|
||||
|
||||
FILE *js_file = fopen (name_string, "r");
|
||||
|
||||
if (js_file)
|
||||
{
|
||||
/* We have successfully opened the file. Now, we establish its size. */
|
||||
file_size = fseek (js_file, 0, SEEK_END);
|
||||
fseek (js_file, 0, SEEK_SET);
|
||||
|
||||
/* We allocate enough memory to store the contents of the file. */
|
||||
js_file_contents = malloc (file_size);
|
||||
if (js_file_contents)
|
||||
{
|
||||
/* We read the file into memory and call jerry_eval (), assigning the result to the out-parameter. */
|
||||
fread (js_file_contents, file_size, 1, js_file);
|
||||
(*result) = jerry_eval (js_file_contents, file_size, JERRY_PARSE_NO_OPTS);
|
||||
|
||||
/* We release the memory holding the contents of the file. */
|
||||
free (js_file_contents);
|
||||
return_value = true;
|
||||
}
|
||||
|
||||
/* We close the file. */
|
||||
fclose (js_file);
|
||||
}
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
static jerry_value_t
|
||||
canonicalize_file_path (const jerry_value_t name)
|
||||
{
|
||||
jerry_value_t absolute_path;
|
||||
|
||||
/**
|
||||
* 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_string () and return
|
||||
* it, because it is the canonical name for this module. Thus, we avoid loading the same JavaScript file twice.
|
||||
*/
|
||||
|
||||
return absolute_path;
|
||||
}
|
||||
|
||||
static jerryx_module_resolver_t js_file_loader
|
||||
{
|
||||
canonicalize_file_path,
|
||||
load_and_evaluate_js_file
|
||||
};
|
||||
```
|
||||
|
||||
We can now load JavaScript files:
|
||||
```c
|
||||
static const jerryx_module_resolver_t *resolvers[] =
|
||||
{
|
||||
/*
|
||||
* Consult the resolver for native JerryScript modules first, in case the requested module is a native JerryScript
|
||||
* module.
|
||||
*/
|
||||
&jerryx_module_native_resolver,
|
||||
|
||||
/*
|
||||
* If the requested module is not a native JerryScript module, assume it is a JavaScript file on disk and use the
|
||||
* above-defined JavaScript file loader to load it.
|
||||
*/
|
||||
&js_file_loader
|
||||
};
|
||||
jerry_value_t js_module = jerryx_module_resolve (requested_module, resolvers, 2);
|
||||
```
|
||||
|
||||
# Module helper macros
|
||||
|
||||
## JERRYX_NATIVE_MODULE
|
||||
|
||||
**Summary**
|
||||
|
||||
Helper macro to define a native JerryScript module. Currently declares a global static structure of type
|
||||
`jerryx_native_module_t` and a constructor/destructor pair that calls `jerryx_native_module_register()` resp.
|
||||
`jerryx_native_module_unregister()`. If the extension is built without the FEATURE_INIT_FINI flag, indicating that
|
||||
support for library constructors and destructors is absent, the constructor and destructor are declared as global
|
||||
symbols so that they may be called explicitly from within the application.
|
||||
|
||||
**Note**: The helper macro must appear at the bottom of a source file, and no semicolon must follow it.
|
||||
|
||||
**Prototype**
|
||||
```c
|
||||
#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 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.
|
||||
|
||||
**Example**
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/module.h"
|
||||
|
||||
static jerry_value_t
|
||||
my_module_on_resolve (void)
|
||||
{
|
||||
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. */
|
||||
JERRYX_NATIVE_MODULE (my_module, my_module_on_resolve)
|
||||
```
|
||||
|
||||
**Example Usage When Library Constructors Are Unavailable**
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/module.h"
|
||||
|
||||
/**
|
||||
* Forward-declare the module registration and unregistration function.
|
||||
*/
|
||||
extern void my_module_register (void);
|
||||
extern void my_module_unregister (void);
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
jerryx_module_resolver_t resolvers[] =
|
||||
{
|
||||
jerryx_native_module_resolver
|
||||
};
|
||||
|
||||
/* This plays the role of the library constructor. */
|
||||
my_module_register ();
|
||||
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
...
|
||||
jerry_value_t my_module = jerryx_module_resolve ("my_module", resolvers, 1);
|
||||
...
|
||||
jerry_cleanup ();
|
||||
|
||||
/* This plays the role of the library destructor */
|
||||
my_module_unregister();
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
@@ -1,220 +0,0 @@
|
||||
# JerryScript debugger transport interface
|
||||
|
||||
The transport interface support allows dynamic selection of transportation
|
||||
layers which can encode/decode or send/receive messages transmitted between
|
||||
the debugger client and server.
|
||||
|
||||
# Types
|
||||
|
||||
## jerry_debugger_transport_receive_context_t
|
||||
|
||||
**Summary**
|
||||
|
||||
This context represents the current status of processing received data.
|
||||
The final state is returned by
|
||||
[jerry_debugger_transport_receive](#jerry_debugger_transport_receive)
|
||||
and must be passed to
|
||||
[jerry_debugger_transport_receive_completed](#jerry_debugger_transport_receive_completed)
|
||||
after the message is processed.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
typedef struct
|
||||
{
|
||||
uint8_t *buffer_p; /**< buffer for storing the received data */
|
||||
size_t received_length; /**< number of currently received bytes */
|
||||
uint8_t *message_p; /**< start of the received message */
|
||||
size_t message_length; /**< length of the received message */
|
||||
size_t message_total_length; /**< total length for datagram protocols,
|
||||
* 0 for stream protocols */
|
||||
} jerry_debugger_transport_receive_context_t;
|
||||
```
|
||||
|
||||
## jerry_debugger_transport_header_t
|
||||
|
||||
**Summary**
|
||||
|
||||
Shared header for each transport interface. It mostly contains callback functions
|
||||
used by the JerryScript debugger server.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
typedef struct jerry_debugger_transport_layer_t
|
||||
{
|
||||
/* The following fields must be filled before calling jerry_debugger_transport_add(). */
|
||||
jerry_debugger_transport_close_t close; /**< close connection callback */
|
||||
jerry_debugger_transport_send_t send; /**< send data callback */
|
||||
jerry_debugger_transport_receive_t receive; /**< receive data callback */
|
||||
|
||||
/* The following fields are filled by jerry_debugger_transport_add(). */
|
||||
struct jerry_debugger_transport_layer_t *next_p; /**< next transport layer */
|
||||
} jerry_debugger_transport_header_t;
|
||||
```
|
||||
|
||||
## jerry_debugger_transport_close_t
|
||||
|
||||
**Summary**
|
||||
|
||||
Called when the connection is closed. Must release all resources (including the
|
||||
memory area for the transport interface) allocated for the transport interface.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
typedef void (*jerry_debugger_transport_close_t) (struct jerry_debugger_transport_interface_t *header_p);
|
||||
```
|
||||
|
||||
## jerry_debugger_transport_send_t
|
||||
|
||||
**Summary**
|
||||
|
||||
Called when a message needs to be sent. Must either transmit the message or call
|
||||
the `header_p->next_p->send()` method.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
typedef bool (*jerry_debugger_transport_send_t) (struct jerry_debugger_transport_interface_t *header_p,
|
||||
uint8_t *message_p,
|
||||
size_t message_length);
|
||||
```
|
||||
|
||||
## jerry_debugger_transport_receive_t
|
||||
|
||||
**Summary**
|
||||
|
||||
Called during message processing. If messages are available it must return with
|
||||
the next message.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
typedef bool (*jerry_debugger_transport_receive_t) (struct jerry_debugger_transport_interface_t *header_p,
|
||||
jerry_debugger_transport_receive_context_t *context_p);
|
||||
```
|
||||
|
||||
# Transport interface API functions
|
||||
|
||||
## jerry_debugger_transport_add
|
||||
|
||||
**Summary**
|
||||
|
||||
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);
|
||||
```
|
||||
|
||||
- `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.
|
||||
- `max_receive_message_size`: maximum incoming message size supported by the interface.
|
||||
|
||||
## jerry_debugger_transport_start
|
||||
|
||||
**Summary**
|
||||
|
||||
Starts the communication to the debugger client. Must be called after the
|
||||
connection is successfully established.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
void jerry_debugger_transport_start (void);
|
||||
```
|
||||
|
||||
## jerry_debugger_transport_is_connected
|
||||
|
||||
**Summary**
|
||||
|
||||
Tells whether a debugger client is connected to the debugger server.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
bool jerry_debugger_transport_is_connected (void);
|
||||
```
|
||||
|
||||
- return value: `true`, if a client is connected, `false` otherwise.
|
||||
|
||||
## jerry_debugger_transport_close
|
||||
|
||||
**Summary**
|
||||
|
||||
Disconnect from the current debugger client. It does nothing if a client is
|
||||
not connected.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
void jerry_debugger_transport_close (void);
|
||||
```
|
||||
|
||||
## jerry_debugger_transport_send
|
||||
|
||||
**Summary**
|
||||
|
||||
Send message to the client.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
bool jerry_debugger_transport_send (const uint8_t *message_p, size_t message_length);
|
||||
```
|
||||
|
||||
- `message_p`: message to be sent.
|
||||
- `message_length`: message length in bytes.
|
||||
- return value: `true`, if a client is still connected, `false` otherwise.
|
||||
|
||||
## jerry_debugger_transport_receive
|
||||
|
||||
**Summary**
|
||||
|
||||
Receive message from the client.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
bool jerry_debugger_transport_receive (jerry_debugger_transport_receive_context_t *context_p);
|
||||
```
|
||||
|
||||
- `context_p`: an unused [jerry_debugger_transport_receive_context_t](#jerry_debugger_transport_receive_context_t).
|
||||
- return value: `true`, if a client is still connected, `false` otherwise.
|
||||
|
||||
## jerry_debugger_transport_receive_completed
|
||||
|
||||
**Summary**
|
||||
|
||||
Must be called after [jerry_debugger_transport_receive](#jerry_debugger_transport_receive)
|
||||
returns with a valid message. Must not be called otherwise.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
void jerry_debugger_transport_receive_completed (jerry_debugger_transport_receive_context_t *context_p);
|
||||
```
|
||||
|
||||
- `context_p`: a [jerry_debugger_transport_receive_context_t](#jerry_debugger_transport_receive_context_t)
|
||||
passed to [jerry_debugger_transport_receive](#jerry_debugger_transport_receive).
|
||||
|
||||
## jerry_debugger_transport_sleep
|
||||
|
||||
**Summary**
|
||||
|
||||
Can be used to wait for incoming messages. Currently the delay is 100ms.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
void jerry_debugger_transport_sleep (void);
|
||||
```
|
||||
@@ -1,112 +0,0 @@
|
||||
# Handle Scope
|
||||
|
||||
## jerryx_handle_scope
|
||||
|
||||
**Summary**
|
||||
It is often necessary to make the lifespan of handles shorter than the lifespan of a native method. Even though the native code could only use the most recent handle, all of the associated objects would also be kept alive since they all share the same scope.
|
||||
|
||||
To handle this case, JerryScript HandleScope extension provides the ability to establish a new 'scope' to which newly created handles will be associated. Once those handles are no longer required, the scope can be 'closed' and any handles associated with the scope are invalidated. The methods available to open/close scopes are `jerryx_open_handle_scope` and `jerryx_close_handle_scope`.
|
||||
|
||||
JerryScript only supports a single nested hierarchy of scopes. There is only one active scope at any time, and all new handles will be associated with that scope while it is active. Scopes must be closed in the reverse order from which they are opened. In addition, all scopes created within a native method must be closed before returning from that method.
|
||||
|
||||
**Example**
|
||||
|
||||
[doctest]: # ()
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/handle-scope.h"
|
||||
|
||||
static jerry_value_t
|
||||
create_object (void)
|
||||
{
|
||||
jerry_value_t obj = jerry_object ();
|
||||
return obj;
|
||||
} /* create_object */
|
||||
|
||||
static void
|
||||
test_handle_scope_val (void)
|
||||
{
|
||||
jerryx_handle_scope scope;
|
||||
jerryx_open_handle_scope (&scope);
|
||||
jerry_value_t obj = jerryx_create_handle (create_object ());
|
||||
|
||||
jerryx_close_handle_scope (scope);
|
||||
// now obj has been released
|
||||
} /* test_handle_scope_val */
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
|
||||
test_handle_scope_val ();
|
||||
jerry_heap_gc (JERRY_GC_PRESSURE_LOW);
|
||||
|
||||
jerry_cleanup ();
|
||||
} /* main */
|
||||
```
|
||||
|
||||
## jerryx_escapable_handle_scope
|
||||
|
||||
**Summary**
|
||||
|
||||
It is necessary in common cases that a handle has to be promote to outer scope and prevent from been garbage collected. To handle this case, a escapable handle scope has been proposed from which one object can be promoted to the outer scope. The method available to escape an object from been release at current scope is `jerryx_escape_handle`.
|
||||
|
||||
**Example**
|
||||
|
||||
[doctest]: # ()
|
||||
|
||||
```c
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-ext/handle-scope.h"
|
||||
|
||||
static jerry_value_t
|
||||
create_object (void)
|
||||
{
|
||||
jerryx_escapable_handle_scope scope;
|
||||
jerryx_open_escapable_handle_scope (&scope);
|
||||
jerry_value_t obj = jerryx_create_handle (jerry_object ());
|
||||
|
||||
jerry_value_t escaped_obj;
|
||||
jerryx_escape_handle(scope, obj, &escaped_obj);
|
||||
jerryx_close_handle_scope (scope);
|
||||
// escaped_obj has now been escaped to outer scope, thus not released at this point
|
||||
|
||||
return escaped_obj;
|
||||
} /* create_object */
|
||||
|
||||
static void
|
||||
test_handle_scope_val (void)
|
||||
{
|
||||
jerryx_handle_scope scope;
|
||||
jerryx_open_handle_scope (&scope);
|
||||
jerry_value_t obj = create_object ();
|
||||
|
||||
jerryx_close_handle_scope (scope);
|
||||
// now obj has been released
|
||||
} /* test_handle_scope_val */
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
|
||||
test_handle_scope_val ();
|
||||
jerry_heap_gc (JERRY_GC_PRESSURE_LOW);
|
||||
|
||||
jerry_cleanup ();
|
||||
} /* main */
|
||||
```
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerry_value_t](../docs/02.API-REFERENCE.md#jerry_value_t)
|
||||
- [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
|
||||
|
||||
To prevent trapping into system calls frequently, a pre-allocated dedicated list mechanism has been introduced to the implementation of JerryX handle scope.
|
||||
|
||||
To change the size of pre-allocation list, use build definition `JERRYX_HANDLE_PRELIST_SIZE` and `JERRYX_SCOPE_PRELIST_SIZE` to alter the default value of 20.
|
||||
@@ -1,159 +0,0 @@
|
||||
# ES6 module support for JerryScript
|
||||
|
||||
The module system allows users to write import and export statements in scripts, which can be used to separate the logic of the application into custom modules.
|
||||
The standard's relevant part can be found [here](https://www.ecma-international.org/ecma-262/6.0/#sec-modules).
|
||||
Embedders wishing to use native builtin modules with ES6 imports can use the [Port API](05.PORT-API.md#jerry-module-system) to do so.
|
||||
|
||||
## 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.
|
||||
|
||||
main.js
|
||||
|
||||
```js
|
||||
import { exported_value } from "./module.js"
|
||||
|
||||
print (exported_value);
|
||||
```
|
||||
|
||||
module.js
|
||||
|
||||
```js
|
||||
var exported_value = 42;
|
||||
|
||||
export exported_value;
|
||||
```
|
||||
|
||||
## Supported features
|
||||
|
||||
* exporting identifiers from the module's lexical environment
|
||||
* specifying export names for the exported values
|
||||
* importing exported identifiers from a module
|
||||
* specifying local binding names for the imported values
|
||||
* module namespace imports
|
||||
* `import * as module from 'module.js`
|
||||
* indirect export statements
|
||||
* `export {variable} from 'module.js'`
|
||||
* star export statements
|
||||
* `export * from 'module.js'`
|
||||
* importing a module for side-effects
|
||||
* `import 'module.js'`
|
||||
* default import and export statements
|
||||
* `export default local_identifier`
|
||||
* `import def from 'module.js'`
|
||||
* anonymous default exports
|
||||
* `export default function () {}`
|
||||
|
||||
### Example
|
||||
|
||||
```js
|
||||
import {
|
||||
engine,
|
||||
version as v
|
||||
} from "./module.js"
|
||||
|
||||
import { getFeatureDetails } from "./module_2.js"
|
||||
|
||||
var version = "v3.1415";
|
||||
|
||||
print("> main.js");
|
||||
|
||||
print(">> Engine: " + engine);
|
||||
print(">> Version: " + v);
|
||||
|
||||
print (">> " + getFeatureDetails());
|
||||
print (">> Script version: " + version);
|
||||
```
|
||||
|
||||
```js
|
||||
// module.js
|
||||
var _engine = "JerryScript";
|
||||
export _engine as engine;
|
||||
|
||||
export var version = "1.0 (e92ae0fb)";
|
||||
```
|
||||
|
||||
```js
|
||||
// module_2.js
|
||||
var featureName = "ECMAScript modules";
|
||||
var year = 2018;
|
||||
|
||||
export function getFeatureDetails() {
|
||||
return "Feature name: " + featureName + " | developed in " + year;
|
||||
}
|
||||
```
|
||||
|
||||
### 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 excluded from the namespace object.
|
||||
|
||||
```js
|
||||
import * as module from './module.js';
|
||||
|
||||
print(">> Engine: " + module.engine);
|
||||
print(">> Version: " + module.version);
|
||||
```
|
||||
|
||||
### Indirect export statements
|
||||
|
||||
An export statement can transitively export variables from another module, either via named indirect exports or a star export statement. In this case the resolving process will follow the chain until it reaches a module containing a local binding for that export name. If there are multiple modules which satisfy the export, that means the export is ambiguous, and will result in a SyntaxError.
|
||||
|
||||
```js
|
||||
import { a, b } from 'module.js'
|
||||
|
||||
print (a + b);
|
||||
```
|
||||
|
||||
```js
|
||||
// module.js
|
||||
export var a = 2;
|
||||
export { b } from 'module2.js'
|
||||
```
|
||||
|
||||
```js
|
||||
// module2.js
|
||||
export var b = 40;
|
||||
```
|
||||
|
||||
### Default imports and exports
|
||||
|
||||
Each module can optionally provide a single default export by using the `export default` statement. Default exports can either reference identifiers in the module's lexical environment, or be an anonymous default export, in which case they will only be accessible by an importing script.
|
||||
|
||||
```js
|
||||
import defaultExport, { b as c } from 'module.js'
|
||||
|
||||
print (defaultExport); // 2
|
||||
print (c ()); // 42
|
||||
```
|
||||
|
||||
```js
|
||||
// module.js
|
||||
export default 2;
|
||||
export function b () {
|
||||
return 42;
|
||||
}
|
||||
```
|
||||
|
||||
### Importing modules for side-effects
|
||||
|
||||
Evaluate a module without importing anything. Any errors encountered in the module will be propagated.
|
||||
|
||||
```js
|
||||
import 'module.js' // > module.js
|
||||
// "> module.js" is printed
|
||||
b (); // (ReferenceError) b is not defined
|
||||
```
|
||||
|
||||
```js
|
||||
// module.js
|
||||
export function b () {
|
||||
print ("> module.js");
|
||||
return 42;
|
||||
}
|
||||
b ();
|
||||
```
|
||||
|
||||
## Unsupported features
|
||||
|
||||
* **snapshot**
|
||||
@@ -1,781 +0,0 @@
|
||||
# Migration guide
|
||||
|
||||
This guide intends to describe the major changes between the JerryScript 1.0 and 2.0 versions.
|
||||
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 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.
|
||||
|
||||
# Short list of removed/renamed headers, types, functions, and macros
|
||||
|
||||
***Removed legacy headers***
|
||||
|
||||
- `jerry-internal.h`
|
||||
|
||||
***Renamed headers***
|
||||
|
||||
- `jerry-api.h` to `jerryscript.h`
|
||||
- `jerry-port.h` to `jerryscript-port.h`
|
||||
|
||||
***Removed API types***
|
||||
|
||||
- `jerry_char_ptr_t` usage replaced with `jerry_char_t *`
|
||||
- `jerry_object_free_callback_t` replaced by `jerry_object_native_free_callback_t`
|
||||
|
||||
***Removed API methods***
|
||||
|
||||
- `jerry_get_memory_limits`
|
||||
- `jerry_get_object_native_handle` replaced by `jerry_get_object_native_pointer`
|
||||
- `jerry_set_object_native_handle` replaced by `jerry_set_object_native_pointer`
|
||||
- `jerry_value_set_abort_flag` replaced by `jerry_create_abort_from_value`
|
||||
- `jerry_value_has_abort_flag` replaced by `jerry_value_is_abort`
|
||||
- `jerry_value_set_error_flag` replaced by `jerry_create_error_from_value`
|
||||
- `jerry_value_has_error_flag` replaced by `jerry_value_is_error`
|
||||
- `jerry_value_clear_error_flag` replaced by `jerry_get_value_from_error`
|
||||
- `jerry_get_value_without_error_flag` replaced by `jerry_get_value_from_error`
|
||||
- `jerry_parse_and_save_snapshot` replaced by `jerry_generate_snapshot`
|
||||
- `jerry_parse_and_save_function_snapshot` replaced by `jerry_generate_function_snapshot`
|
||||
|
||||
|
||||
***Removed unused configuration macros***
|
||||
|
||||
- `CONFIG_MEM_DATA_LIMIT_MINUS_HEAP_SIZE`
|
||||
- `CONFIG_MEM_STACK_LIMIT`
|
||||
- `CONFIG_VM_STACK_FRAME_INLINED_VALUES_NUMBER`
|
||||
- `CONFIG_ECMA_GLOBAL_ENVIRONMENT_DECLARATIVE`
|
||||
- All `CONFIG_..` macros have been renamed to use the `JERRY_` prefix format.
|
||||
|
||||
|
||||
# Modified API functions
|
||||
|
||||
## Error manipulating functions
|
||||
|
||||
The most important changes in the API are related to error handling and manipulation.
|
||||
|
||||
### jerry_value_set_abort_flag
|
||||
|
||||
This function was replaced with [`jerry_create_abort_from_value`](02.API-REFERENCE.md#jerry_create_abort_from_value).
|
||||
Take note of the second argument of the new `jerry_create_abort_from_value` function which controls if the
|
||||
first argument should be usable after the call or not.
|
||||
|
||||
**Before**
|
||||
|
||||
```c
|
||||
{
|
||||
jerry_value_t value;
|
||||
// create or acquire value
|
||||
// ...
|
||||
|
||||
jerry_value_set_abort_flag (&value);
|
||||
|
||||
jerry_release_value (value);
|
||||
}
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```c
|
||||
{
|
||||
jerry_value_t value;
|
||||
// create or acquire value
|
||||
// ...
|
||||
|
||||
jerry_value_t abort = jerry_create_abort_from_value (value, true);
|
||||
// using the 'value' variable after release is invalid
|
||||
|
||||
jerry_release_value (abort);
|
||||
}
|
||||
```
|
||||
|
||||
- OR
|
||||
|
||||
```c
|
||||
{
|
||||
jerry_value_t value;
|
||||
... // create or acquire value
|
||||
|
||||
jerry_value_t abort = jerry_create_abort_from_value (value, false);
|
||||
// both 'abort' and 'value' can be used and must be released when they are no longer needed
|
||||
|
||||
jerry_release_value (abort);
|
||||
jerry_release_value (value);
|
||||
}
|
||||
```
|
||||
|
||||
### jerry_value_has_abort_flag
|
||||
|
||||
This function was renamed to [`jerry_value_is_abort`](02.API-REFERENCE.md#jerry_value_is_abort).
|
||||
|
||||
**Before**
|
||||
|
||||
```c
|
||||
{
|
||||
jerry_value_t value;
|
||||
// create or acquire value
|
||||
// ...
|
||||
|
||||
if (jerry_value_has_abort_flag (value))
|
||||
{
|
||||
// ...
|
||||
}
|
||||
|
||||
jerry_release_value (value);
|
||||
}
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```c
|
||||
{
|
||||
jerry_value_t value;
|
||||
// create or acquire value
|
||||
// ...
|
||||
|
||||
if (jerry_value_is_abort (value))
|
||||
{
|
||||
// ...
|
||||
}
|
||||
|
||||
jerry_release_value (value);
|
||||
}
|
||||
```
|
||||
|
||||
### jerry_value_set_error_flag
|
||||
|
||||
This function was replaced with [`jerry_create_error_from_value`](02.API-REFERENCE.md#jerry_create_error_from_value).
|
||||
Take note of the second argument of the new `jerry_create_error_from_value` function which controls if the
|
||||
first argument should be usable after the call or not.
|
||||
|
||||
**Before**
|
||||
|
||||
```c
|
||||
{
|
||||
jerry_value_t value;
|
||||
// create or acquire value
|
||||
// ...
|
||||
|
||||
jerry_value_set_error_flag (&value);
|
||||
|
||||
jerry_release_value (value);
|
||||
}
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```c
|
||||
{
|
||||
jerry_value_t value;
|
||||
// create or acquire value
|
||||
// ...
|
||||
|
||||
jerry_value_t error = jerry_create_error_from_value (value, true);
|
||||
// using the 'value' variable after release is invalid
|
||||
|
||||
jerry_release_value (error);
|
||||
}
|
||||
```
|
||||
|
||||
- OR
|
||||
|
||||
```c
|
||||
{
|
||||
jerry_value_t value;
|
||||
// create or acquire value
|
||||
// ...
|
||||
|
||||
jerry_value_t error = jerry_create_error_from_value (value, false);
|
||||
// both 'error' and 'value' can be used and must be released when they are no longer needed
|
||||
|
||||
jerry_release_value (error);
|
||||
jerry_release_value (value);
|
||||
}
|
||||
```
|
||||
|
||||
### jerry_value_has_error_flag
|
||||
|
||||
This function was renamed to [`jerry_value_is_error`](02.API-REFERENCE.md#jerry_value_is_error).
|
||||
|
||||
**Before**
|
||||
|
||||
```c
|
||||
{
|
||||
jerry_value_t value;
|
||||
// create or acquire value
|
||||
// ...
|
||||
|
||||
if (jerry_value_has_error_flag (value))
|
||||
{
|
||||
// ...
|
||||
}
|
||||
|
||||
jerry_release_value (value);
|
||||
}
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```c
|
||||
{
|
||||
jerry_value_t value;
|
||||
// create or acquire value
|
||||
// ...
|
||||
|
||||
if (jerry_value_is_error (value))
|
||||
{
|
||||
// ...
|
||||
}
|
||||
|
||||
jerry_release_value (value);
|
||||
}
|
||||
```
|
||||
|
||||
### jerry_value_clear_error_flag AND jerry_get_value_without_error_flag
|
||||
|
||||
These functions were merged into [`jerry_get_value_from_error`](02.API-REFERENCE.md#jerry_get_value_from_error).
|
||||
Please note the second argument of the new function which controls if the first argument passed should be released
|
||||
or not.
|
||||
|
||||
**Before**
|
||||
|
||||
```c
|
||||
{
|
||||
jerry_value_t value;
|
||||
// create or acquire value
|
||||
// ...
|
||||
|
||||
jerry_value_set_error_flag (&value);
|
||||
jerry_value_clear_error_flag (&value);
|
||||
// or
|
||||
jerry_value_t real_value = jerry_get_value_without_error_flag (value);
|
||||
|
||||
jerry_release_value (value);
|
||||
jerry_release_value (real_value);
|
||||
}
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```c
|
||||
{
|
||||
jerry_value_t value;
|
||||
// create or acquire value
|
||||
// ...
|
||||
|
||||
jerry_value_t error = jerry_create_error_from_value (value, true);
|
||||
|
||||
jerry_value_t real_value = jerry_get_value_from_error (error, true);
|
||||
|
||||
jerry_release_value (real_value);
|
||||
}
|
||||
```
|
||||
|
||||
## Other functions changed
|
||||
|
||||
### jerry_register_magic_strings
|
||||
|
||||
In case of the `jerry_register_magic_strings` function the change is that
|
||||
the first argument's base type `jerry_char_ptr_t` was changed to `jerry_char_t*`.
|
||||
For more details see: [`jerry_register_magic_strings`](02.API-REFERENCE.md#jerry_register_magic_strings).
|
||||
|
||||
In the following code parts please take note of the type used for the `magic_string_items` array.
|
||||
|
||||
**Before**
|
||||
|
||||
```c
|
||||
{
|
||||
// must be static, because 'jerry_register_magic_strings' does not copy
|
||||
// the items must be sorted by size at first, then lexicographically
|
||||
static const jerry_char_ptr_t magic_string_items[] = {
|
||||
(const jerry_char_ptr_t) "magicstring1",
|
||||
(const jerry_char_ptr_t) "magicstring2",
|
||||
(const jerry_char_ptr_t) "magicstring3"
|
||||
};
|
||||
uint32_t num_magic_string_items = (uint32_t) (sizeof (magic_string_items) / sizeof (jerry_char_ptr_t));
|
||||
|
||||
// must be static, because 'jerry_register_magic_strings' does not copy
|
||||
static const jerry_length_t magic_string_lengths[] = { 12, 12, 12 };
|
||||
jerry_register_magic_strings (magic_string_items, num_magic_string_items, magic_string_lengths);
|
||||
}
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```c
|
||||
{
|
||||
// must be static, because 'jerry_register_magic_strings' does not copy
|
||||
// the items must be sorted by size at first, then lexicographically
|
||||
static const jerry_char_t *magic_string_items[] = {
|
||||
(const jerry_char_t *) "magicstring1",
|
||||
(const jerry_char_t *) "magicstring2",
|
||||
(const jerry_char_t *) "magicstring3"
|
||||
};
|
||||
uint32_t num_magic_string_items = (uint32_t) (sizeof (magic_string_items) / sizeof (jerry_char_t *));
|
||||
|
||||
// must be static, because 'jerry_register_magic_strings' does not copy
|
||||
static const jerry_length_t magic_string_lengths[] = { 12, 12, 12 };
|
||||
jerry_register_magic_strings (magic_string_items, num_magic_string_items, magic_string_lengths);
|
||||
}
|
||||
```
|
||||
|
||||
## Snapshot generating API
|
||||
|
||||
### jerry_parse_and_save_snapshot
|
||||
|
||||
This function was replaced with [`jerry_generate_snapshot`](02.API-REFERENCE.md#jerry_generate_snapshot).
|
||||
The function returns an error object if there was any problem during snapshot generation and
|
||||
if there was no problem the return value is a number value containing the snapshot size in bytes.
|
||||
|
||||
**Before**
|
||||
|
||||
```c
|
||||
{
|
||||
static uint32_t global_mode_snapshot_buffer[256];
|
||||
const jerry_char_t *code_to_snapshot_p = (const jerry_char_t *) "(function () { return 'string from snapshot'; }) ();";
|
||||
|
||||
size_t global_mode_snapshot_size =
|
||||
jerry_parse_and_save_snapshot (code_to_snapshot_p,
|
||||
strlen ((const char *) code_to_snapshot_p),
|
||||
true,
|
||||
false,
|
||||
global_mode_snapshot_buffer,
|
||||
sizeof (global_mode_snapshot_buffer) / sizeof (uint32_t));
|
||||
// use "global_mode_snapshot_buffer"
|
||||
}
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```c
|
||||
{
|
||||
static uint32_t global_mode_snapshot_buffer[256];
|
||||
const jerry_char_t *code_to_snapshot_p = (const jerry_char_t *) "(function () { return 'string from snapshot'; }) ();";
|
||||
|
||||
jerry_value_t generate_result;
|
||||
generate_result = jerry_generate_snapshot (NULL,
|
||||
0,
|
||||
code_to_snapshot_p,
|
||||
strlen ((const char *) code_to_snapshot_p),
|
||||
global_mode_snapshot_buffer,
|
||||
sizeof (global_mode_snapshot_buffer) / sizeof (uint32_t));
|
||||
if (jerry_value_is_error (generate_result))
|
||||
{
|
||||
// There was a problem during snapshot generation, for example there is a SyntaxError.
|
||||
// Use the "generate_result" to check the error.
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t snapshot_size = (size_t) jerry_get_number_value (generate_result);
|
||||
// use "global_mode_snapshot_buffer"
|
||||
}
|
||||
jerry_release_value (generate_result);
|
||||
}
|
||||
```
|
||||
|
||||
### jerry_parse_and_save_function_snapshot
|
||||
|
||||
This function was replaced with [`jerry_generate_function_snapshot`](02.API-REFERENCE.md#jerry_parse_and_save_function_snapshot).
|
||||
The function returns an error object if there was any problem during snapshot generation and
|
||||
if there was no problem the return value is a number value containing the snapshot size in bytes.
|
||||
|
||||
**Before**
|
||||
|
||||
```c
|
||||
{
|
||||
static uint32_t func_snapshot_buffer[1024];
|
||||
|
||||
const jerry_char_t *args_p = (const jerry_char_t *) "a, b";
|
||||
const jerry_char_t *src_p = (const jerry_char_t *) "return a + b;";
|
||||
|
||||
size_t func_snapshot_size =
|
||||
jerry_parse_and_save_function_snapshot (src_p,
|
||||
strlen ((const char *) src_p),
|
||||
args_p,
|
||||
strlen ((const char *) args_p),
|
||||
false,
|
||||
func_snapshot_buffer,
|
||||
sizeof (func_snapshot_buffer) / sizeof (uint32_t));
|
||||
// check "function_snapshot_size" and use "func_snapshot_buffer"
|
||||
}
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```c
|
||||
{
|
||||
static uint32_t func_snapshot_buffer[1024];
|
||||
|
||||
const jerry_char_t *args_p = (const jerry_char_t *) "a, b";
|
||||
const jerry_char_t *src_p = (const jerry_char_t *) "return a + b;";
|
||||
|
||||
jerry_value_t generate_result;
|
||||
generate_result = jerry_generate_function_snapshot (NULL,
|
||||
0,
|
||||
src_p,
|
||||
strlen ((const char *) src_p),
|
||||
args_p,
|
||||
strlen ((const char *) args_p),
|
||||
0,
|
||||
func_snapshot_buffer,
|
||||
sizeof (func_snapshot_buffer) / sizeof (uint32_t));
|
||||
if (jerry_value_is_error (generate_result))
|
||||
{
|
||||
// There was a problem during snapshot generation, for example there is a SyntaxError.
|
||||
// Use the "generate_result" to check the error.
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t snapshot_size = (size_t) jerry_get_number_value (generate_result);
|
||||
// use "func_snapshot_buffer"
|
||||
}
|
||||
|
||||
jerry_release_value (generate_result)
|
||||
}
|
||||
```
|
||||
|
||||
## Garbage collection
|
||||
|
||||
### jerry_gc
|
||||
|
||||
The [`jerry_gc`](02.API-REFERENCE.md#jerry_gc) function was modified to handle an argument which represents the pressure for the garbage collector.
|
||||
For more information checkout the [`jerry_gc_mode_t`](02.API-REFERENCE.md#jerry_gc_mode_t) reference.
|
||||
|
||||
**Before**
|
||||
|
||||
```c
|
||||
{
|
||||
jerry_gc ();
|
||||
}
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```c
|
||||
{
|
||||
jerry_gc (JERRY_GC_PRESSURE_LOW);
|
||||
}
|
||||
```
|
||||
|
||||
## jerry_eval
|
||||
|
||||
The third argument of [`jerry_eval`](02.API-REFERENCE.md#jerry_eval) has been changed
|
||||
from `bool` to [`jerry_parse_opts_t`](02.API-REFERENCE.md#jerry_parse_opts_t).
|
||||
|
||||
**Before**
|
||||
|
||||
```c
|
||||
const jerry_char_t *str_to_eval = (const jerry_char_t *) "1 + 1";
|
||||
jerry_value_t ret_val = jerry_eval (str_to_eval,
|
||||
strlen ((const char *) str_to_eval),
|
||||
false);
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```c
|
||||
const jerry_char_t *str_to_eval = (const jerry_char_t *) "1 + 1";
|
||||
jerry_value_t ret_val = jerry_eval (str_to_eval,
|
||||
strlen ((const char *) str_to_eval),
|
||||
JERRY_PARSE_NO_OPTS);
|
||||
```
|
||||
|
||||
## Port API
|
||||
|
||||
### jerry_port_get_time_zone
|
||||
|
||||
The port API of handling timezones has been changed. The previous interface did not
|
||||
allow timezones to be handled correctly, even if the host system was up to the task.
|
||||
Check [the related issue](https://github.com/jerryscript-project/jerryscript/issues/1661)
|
||||
for more details.
|
||||
|
||||
The new port API function name is [jerry_port_get_local_time_zone_adjustment](05.PORT-API.md#date-1].
|
||||
|
||||
Below is the default implementations for both versions:
|
||||
|
||||
**Before**
|
||||
|
||||
```c
|
||||
bool jerry_port_get_time_zone (jerry_time_zone_t *tz_p)
|
||||
{
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
|
||||
/* gettimeofday may not fill tz, so zero-initializing */
|
||||
tz.tz_minuteswest = 0;
|
||||
tz.tz_dsttime = 0;
|
||||
|
||||
if (gettimeofday (&tv, &tz) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
tz_p->offset = tz.tz_minuteswest;
|
||||
tz_p->daylight_saving_time = tz.tz_dsttime > 0 ? 1 : 0;
|
||||
|
||||
return true;
|
||||
} /* jerry_port_get_time_zone */
|
||||
```
|
||||
|
||||
**After**
|
||||
|
||||
```c
|
||||
double jerry_port_get_local_time_zone_adjustment (double unix_ms,
|
||||
bool is_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 */
|
||||
```
|
||||
|
||||
## Native pointers
|
||||
|
||||
The assignment of native pointers (previously called handles) have been changed
|
||||
since v1.0. In the previous version only one native pointer could be assigned to
|
||||
a `jerry_value_t`. Now it is allowed to register multiple native infos, which
|
||||
can be accessed with the corresponding
|
||||
[`jerry_object_native_info_t`](02.API-REFERENCE.md#jerry_object_native_info_t).
|
||||
The old functions were removed and replaced by new ones.
|
||||
|
||||
- `jerry_object_free_callback_t` callback type is replaced by `jerry_object_native_info_t`
|
||||
- `jerry_get_object_native_handle` is replaced by [`jerry_get_object_native_pointer`](02.API-REFERENCE.md#jerry_get_object_native_pointer)
|
||||
- `jerry_set_object_native_handle` is replaced by [`jerry_set_object_native_pointer`](02.API-REFERENCE.md#jerry_set_object_native_pointer)
|
||||
|
||||
**Before**
|
||||
|
||||
```c
|
||||
struct
|
||||
{
|
||||
int data;
|
||||
} my_info;
|
||||
|
||||
static void
|
||||
handler_construct_freecb (uintptr_t native_p)
|
||||
{
|
||||
// Invoked when the JS object is released and the
|
||||
// native data should be freed.
|
||||
|
||||
struct my_info *info = (struct my_info *) native_p;
|
||||
free (info);
|
||||
}
|
||||
|
||||
void
|
||||
demo (void)
|
||||
{
|
||||
jerry_value_t this_val;
|
||||
// create or acquire this_val
|
||||
// ...
|
||||
|
||||
struct my_info *info = (struct my_info *) malloc (sizeof (struct my_info));
|
||||
info->data = 11;
|
||||
|
||||
// setting the native handle
|
||||
jerry_set_object_native_handle (this_val,
|
||||
(uintptr_t) info,
|
||||
handler_construct_freecb);
|
||||
// ...
|
||||
// reading back the native handle
|
||||
uintptr_t ptr = (uintptr_t) NULL;
|
||||
bool is_ok = jerry_get_object_native_handle (this_val, &ptr);
|
||||
if (is_ok)
|
||||
{
|
||||
struct my_info *obj_info = (struct my_info *) ptr;
|
||||
// use "obj_info"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
**After**
|
||||
|
||||
```c
|
||||
struct
|
||||
{
|
||||
int data;
|
||||
} my_info;
|
||||
|
||||
static void
|
||||
handler_construct_freecb (void *native_p)
|
||||
{
|
||||
// Invoked when the JS object is released and the
|
||||
// native data should be freed.
|
||||
|
||||
struct my_info *info = (struct my_info *) native_p;
|
||||
free (info);
|
||||
}
|
||||
|
||||
static const jerry_object_native_info_t my_info_type_info =
|
||||
{
|
||||
.free_cb = handler_construct_freecb
|
||||
};
|
||||
|
||||
void
|
||||
demo (void)
|
||||
{
|
||||
jerry_value_t this_val;
|
||||
// create or acquire this_val
|
||||
// ...
|
||||
|
||||
struct my_info *info = (struct my_info *) malloc (sizeof (struct my_info));
|
||||
info->data = 11;
|
||||
|
||||
// setting the native handle
|
||||
jerry_set_object_native_pointer (this_val,
|
||||
info,
|
||||
&my_info_type_info);
|
||||
// ...
|
||||
// reading back the native handle pointed by the "my_info_type_info" variable
|
||||
void *ptr = NULL;
|
||||
bool has_p = jerry_get_object_native_pointer (this_val, &ptr, &my_info_type_info);
|
||||
if (has_p)
|
||||
{
|
||||
struct my_info *obj_info = (struct my_info *) ptr;
|
||||
// use "obj_info"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
# New API functions
|
||||
|
||||
In this section the new API functions are listed.
|
||||
|
||||
## Built-in objects
|
||||
|
||||
***ArrayBuffer***
|
||||
|
||||
- [`jerry_create_arraybuffer`](02.API-REFERENCE.md#jerry_create_arraybuffer)
|
||||
- [`jerry_create_arraybuffer_external`](02.API-REFERENCE.md#jerry_create_arraybuffer_external)
|
||||
- [`jerry_get_arraybuffer_pointer`](02.API-REFERENCE.md#jerry_get_arraybuffer_pointer)
|
||||
|
||||
***DataView***
|
||||
|
||||
- [`jerry_create_dataview`](02.API-REFERENCE.md#jerry_create_dataview)
|
||||
- [`jerry_value_is_dataview`](02.API-REFERENCE.md#jerry_value_is_dataview)
|
||||
- [`jerry_get_dataview_buffer`](02.API-REFERENCE.md#jerry_get_dataview_buffer)
|
||||
|
||||
***JSON***
|
||||
|
||||
- [`jerry_json_parse`](02.API-REFERENCE.md#jerry_json_parse)
|
||||
- [`jerry_json_stringify`](02.API-REFERENCE.md#jerry_json_stringify)
|
||||
|
||||
***Number***
|
||||
|
||||
- [`jerry_create_number_infinity`](02.API-REFERENCE.md#jerry_create_number_infinity)
|
||||
- [`jerry_create_number_nan`](02.API-REFERENCE.md#jerry_create_number_nan)
|
||||
|
||||
***Promise***
|
||||
|
||||
- [`jerry_run_all_enqueued_jobs`](02.API-REFERENCE.md#jerry_run_all_enqueued_jobs)
|
||||
- [`jerry_create_promise`](02.API-REFERENCE.md#jerry_create_promise)
|
||||
- [`jerry_resolve_or_reject_promise`](02.API-REFERENCE.md#jerry_resolve_or_reject_promise)
|
||||
- [`jerry_value_is_promise`](02.API-REFERENCE.md#jerry_value_is_promise)
|
||||
|
||||
***RegExp***
|
||||
|
||||
- [`jerry_create_regexp`](02.API-REFERENCE.md#jerry_create_regexp)
|
||||
- [`jerry_create_regexp_sz`](02.API-REFERENCE.md#jerry_create_regexp_sz)
|
||||
|
||||
***String***
|
||||
|
||||
- [`jerry_substring_to_utf8_char_buffer`](02.API-REFERENCE.md#jerry_substring_to_utf8_char_buffer)
|
||||
- [`jerry_get_utf8_string_size`](02.API-REFERENCE.md#jerry_get_utf8_string_size)
|
||||
- [`jerry_get_utf8_string_length`](02.API-REFERENCE.md#jerry_get_utf8_string_length)
|
||||
- [`jerry_create_string_from_utf8`](02.API-REFERENCE.md#jerry_create_string_from_utf8)
|
||||
- [`jerry_create_string_sz_from_utf8`](02.API-REFERENCE.md#jerry_create_string_sz_from_utf8)
|
||||
|
||||
***Symbol***
|
||||
|
||||
- [`jerry_create_symbol`](02.API-REFERENCE.md#jerry_create_symbol)
|
||||
- [`jerry_get_symbol_descriptive_string`](02.API-REFERENCE.md#jerry_get_symbol_descriptive_string)
|
||||
- [`jerry_value_is_symbol`](02.API-REFERENCE.md#jerry_value_is_symbol)
|
||||
|
||||
***TypedArray***
|
||||
|
||||
- [`jerry_create_typedarray`](02.API-REFERENCE.md#jerry_create_typedarray)
|
||||
- [`jerry_create_typedarray_for_arraybuffer`](02.API-REFERENCE.md#jerry_create_typedarray_for_arraybuffer)
|
||||
- [`jerry_create_typedarray_for_arraybuffer_sz`](02.API-REFERENCE.md#jerry_create_typedarray_for_arraybuffer_sz)
|
||||
- [`jerry_get_typedarray_type`](02.API-REFERENCE.md#jerry_get_typedarray_type)
|
||||
- [`jerry_get_typedarray_length`](02.API-REFERENCE.md#jerry_get_typedarray_length)
|
||||
- [`jerry_get_typedarray_buffer`](02.API-REFERENCE.md#jerry_get_typedarray_buffer)
|
||||
- [`jerry_value_is_typedarray`](02.API-REFERENCE.md#jerry_value_is_typedarray)
|
||||
|
||||
|
||||
## Instances and memory management
|
||||
|
||||
***JerryScript instances***
|
||||
|
||||
- [`jerry_create_context`](02.API-REFERENCE.md#jerry_create_context)
|
||||
- [`jerry_get_context_data`](02.API-REFERENCE.md#jerry_get_context_data)
|
||||
|
||||
***Memory management***
|
||||
|
||||
- [`jerry_heap_alloc`](02.API-REFERENCE.md#jerry_heap_alloc)
|
||||
- [`jerry_heap_free`](02.API-REFERENCE.md#jerry_heap_free)
|
||||
|
||||
|
||||
## Operations with JavaScript values
|
||||
|
||||
***Binary operations***
|
||||
|
||||
- [`jerry_binary_operation`](02.API-REFERENCE.md#jerry_binary_operation)
|
||||
|
||||
***Error manipulating***
|
||||
|
||||
- [`jerry_get_error_type`](02.API-REFERENCE.md#jerry_get_error_type)
|
||||
- [`jerry_get_backtrace`](02.API-REFERENCE.md#jerry_get_backtrace)
|
||||
|
||||
***Native pointers***
|
||||
|
||||
- [`jerry_delete_object_native_pointer`](02.API-REFERENCE.md#jerry_delete_object_native_pointer)
|
||||
- [`jerry_objects_foreach_by_native_info`](02.API-REFERENCE.md#jerry_objects_foreach_by_native_info)
|
||||
|
||||
***Property***
|
||||
|
||||
- [`jerry_delete_property_by_index`](02.API-REFERENCE.md#jerry_delete_property_by_index)
|
||||
- [`jerry_objects_foreach`](02.API-REFERENCE.md#jerry_objects_foreach)
|
||||
|
||||
|
||||
## Debugger
|
||||
|
||||
- [`jerry_debugger_is_connected`](07.DEBUGGER.md#jerry_debugger_is_connected)
|
||||
- [`jerry_debugger_stop`](07.DEBUGGER.md#jerry_debugger_stop)
|
||||
- [`jerry_debugger_continue`](07.DEBUGGER.md#jerry_debugger_continue)
|
||||
- [`jerry_debugger_stop_at_breakpoint`](07.DEBUGGER.md#jerry_debugger_stop_at_breakpoint)
|
||||
- [`jerry_debugger_wait_for_client_source`](07.DEBUGGER.md#jerry_debugger_wait_for_client_source)
|
||||
- [`jerry_debugger_send_output`](07.DEBUGGER.md#jerry_debugger_send_output)
|
||||
- [`jerry_debugger_send_log`](07.DEBUGGER.md#jerry_debugger_send_log)
|
||||
|
||||
|
||||
## Other
|
||||
|
||||
- [`jerry_is_feature_enabled`](02.API-REFERENCE.md#jerry_is_feature_enabled)
|
||||
- [`jerry_parse_and_save_literals`](02.API-REFERENCE.md#jerry_parse_and_save_literals)
|
||||
- [`jerry_set_vm_exec_stop_callback`](02.API-REFERENCE.md#jerry_set_vm_exec_stop_callback)
|
||||
|
||||
|
||||
## Port API functions
|
||||
|
||||
- [`jerry_port_normalize_path`](05.PORT-API.md#jerry_port_normalize_path)
|
||||
- [`jerry_port_read_source`](05.PORT-API.md#jerry_port_read_source)
|
||||
- [`jerry_port_release_source`](05.PORT-API.md#jerry_port_release_source)
|
||||
- [`jerry_port_print_char`](05.PORT-API.md#jerry_port_print_char)
|
||||
- [`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.*
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 27 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 7.0 KiB |
+170
-726
@@ -1,4 +1,5 @@
|
||||
# Copyright JS Foundation and other contributors, http://js.foundation
|
||||
# Copyright 2015-2016 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2016 University of Szeged.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -12,108 +13,41 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
cmake_minimum_required (VERSION 3.10)
|
||||
cmake_minimum_required (VERSION 2.8.12)
|
||||
set(JERRY_CORE_NAME jerry-core)
|
||||
project (${JERRY_CORE_NAME} C)
|
||||
|
||||
include(CheckLibraryExists)
|
||||
|
||||
# Optional features
|
||||
set(JERRY_CPOINTER_32_BIT OFF CACHE BOOL "Enable 32 bit compressed pointers?")
|
||||
set(JERRY_DEBUGGER OFF CACHE BOOL "Enable JerryScript debugger?")
|
||||
set(JERRY_ERROR_MESSAGES OFF CACHE BOOL "Enable error messages?")
|
||||
set(JERRY_EXTERNAL_CONTEXT OFF CACHE BOOL "Enable external context?")
|
||||
set(JERRY_PARSER ON CACHE BOOL "Enable javascript-parser?")
|
||||
set(JERRY_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_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")
|
||||
set(JERRY_GC_MARK_LIMIT "(8)" CACHE STRING "Maximum depth of recursion during GC mark phase")
|
||||
|
||||
# Option overrides
|
||||
if(JERRY_SYSTEM_ALLOCATOR)
|
||||
set(JERRY_CPOINTER_32_BIT ON)
|
||||
|
||||
set(JERRY_CPOINTER_32_BIT_MESSAGE " (FORCED BY SYSTEM ALLOCATOR)")
|
||||
endif()
|
||||
|
||||
if (JERRY_GLOBAL_HEAP_SIZE GREATER 512)
|
||||
set(JERRY_CPOINTER_32_BIT ON)
|
||||
|
||||
set(JERRY_CPOINTER_32_BIT_MESSAGE " (FORCED BY HEAP SIZE)")
|
||||
endif()
|
||||
|
||||
if(NOT JERRY_PARSER)
|
||||
set(JERRY_SNAPSHOT_EXEC ON)
|
||||
set(JERRY_PARSER_DUMP OFF)
|
||||
|
||||
set(JERRY_SNAPSHOT_EXEC_MESSAGE " (FORCED BY DISABLED JS PARSER)")
|
||||
set(JERRY_PARSER_DUMP_MESSAGE " (FORCED BY DISABLED JS PARSER)")
|
||||
endif()
|
||||
|
||||
if(JERRY_CMDLINE_SNAPSHOT)
|
||||
set(JERRY_SNAPSHOT_SAVE ON)
|
||||
|
||||
set(JERRY_SNAPSHOT_SAVE_MESSAGE " (FORCED BY SNAPSHOT TOOL)")
|
||||
endif()
|
||||
|
||||
if(JERRY_MEM_STATS OR JERRY_PARSER_DUMP_BYTE_CODE OR JERRY_REGEXP_DUMP_BYTE_CODE)
|
||||
set(JERRY_LOGGING ON)
|
||||
|
||||
set(JERRYRE_LOGGING_MESSAGE " (FORCED BY STATS OR DUMP)")
|
||||
endif()
|
||||
set(FEATURE_PROFILE "full" CACHE STRING "Profile types: full, minimal")
|
||||
set(FEATURE_ERROR_MESSAGES OFF CACHE BOOL "Enable error messages?")
|
||||
set(FEATURE_VALGRIND OFF CACHE BOOL "Enable Valgrind support?")
|
||||
set(FEATURE_VALGRIND_FREYA OFF CACHE BOOL "Enable Valgrind-Freya support?")
|
||||
set(FEATURE_MEM_STRESS_TEST OFF CACHE BOOL "Enable mem-stress test?")
|
||||
set(FEATURE_MEM_STATS OFF CACHE BOOL "Enable memory statistics?")
|
||||
set(FEATURE_PARSER_DUMP OFF CACHE BOOL "Enable parser byte-code dumps?")
|
||||
set(FEATURE_REGEXP_DUMP OFF CACHE BOOL "Enable regexp byte-code dumps?")
|
||||
set(FEATURE_SNAPSHOT_SAVE OFF CACHE BOOL "Allow to save snapshot files?")
|
||||
set(FEATURE_SNAPSHOT_EXEC OFF CACHE BOOL "Allow to execute snapshot files?")
|
||||
set(MEM_HEAP_SIZE_KB "512" CACHE STRING "Size of memory heap, in kilobytes")
|
||||
|
||||
# Status messages
|
||||
message(STATUS "JERRY_CPOINTER_32_BIT " ${JERRY_CPOINTER_32_BIT} ${JERRY_CPOINTER_32_BIT_MESSAGE})
|
||||
message(STATUS "JERRY_DEBUGGER " ${JERRY_DEBUGGER})
|
||||
message(STATUS "JERRY_ERROR_MESSAGES " ${JERRY_ERROR_MESSAGES})
|
||||
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_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})
|
||||
message(STATUS "JERRY_GC_MARK_LIMIT " ${JERRY_GC_MARK_LIMIT})
|
||||
message(STATUS "FEATURE_PROFILE " ${FEATURE_PROFILE})
|
||||
message(STATUS "FEATURE_ERROR_MESSAGES " ${FEATURE_ERROR_MESSAGES})
|
||||
message(STATUS "FEATURE_VALGRIND " ${FEATURE_VALGRIND})
|
||||
message(STATUS "FEATURE_VALGRIND_FREYA " ${FEATURE_VALGRIND_FREYA})
|
||||
message(STATUS "FEATURE_MEM_STRESS_TEST " ${FEATURE_MEM_STRESS_TEST})
|
||||
message(STATUS "FEATURE_MEM_STATS " ${FEATURE_MEM_STATS})
|
||||
message(STATUS "FEATURE_PARSER_DUMP " ${FEATURE_PARSER_DUMP})
|
||||
message(STATUS "FEATURE_REGEXP_DUMP " ${FEATURE_REGEXP_DUMP})
|
||||
message(STATUS "FEATURE_SNAPSHOT_SAVE " ${FEATURE_SNAPSHOT_SAVE})
|
||||
message(STATUS "FEATURE_SNAPSHOT_EXEC " ${FEATURE_SNAPSHOT_EXEC})
|
||||
message(STATUS "MEM_HEAP_SIZE_KB " ${MEM_HEAP_SIZE_KB})
|
||||
|
||||
# Include directories
|
||||
set(INCLUDE_CORE_PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
set(INCLUDE_CORE_PRIVATE
|
||||
set(INCLUDE_CORE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/api"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/debugger"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/ecma/base"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/ecma/builtin-objects"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/ecma/builtin-objects/typedarray"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/ecma/operations"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/jcontext"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/jmem"
|
||||
@@ -123,663 +57,173 @@ set(INCLUDE_CORE_PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/parser/regexp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/vm")
|
||||
|
||||
# Sources
|
||||
# Jerry core
|
||||
file(GLOB SOURCE_CORE_API *.c)
|
||||
file(GLOB SOURCE_CORE_ECMA_BASE ecma/base/*.c)
|
||||
file(GLOB SOURCE_CORE_ECMA_BUILTINS ecma/builtin-objects/*.c)
|
||||
file(GLOB SOURCE_CORE_ECMA_OPERATIONS ecma/operations/*.c)
|
||||
file(GLOB SOURCE_CORE_JCONTEXT jcontext/*.c)
|
||||
file(GLOB SOURCE_CORE_JMEM jmem/*.c)
|
||||
file(GLOB SOURCE_CORE_JRT jrt/*.c)
|
||||
file(GLOB SOURCE_CORE_LIT lit/*.c)
|
||||
file(GLOB SOURCE_CORE_PARSER_JS parser/js/*.c)
|
||||
file(GLOB SOURCE_CORE_PARSER_REGEXP parser/regexp/*.c)
|
||||
file(GLOB SOURCE_CORE_VM vm/*.c)
|
||||
|
||||
set(SOURCE_CORE_FILES
|
||||
${SOURCE_CORE_API}
|
||||
${SOURCE_CORE_ECMA_BASE}
|
||||
${SOURCE_CORE_ECMA_BUILTINS}
|
||||
${SOURCE_CORE_ECMA_OPERATIONS}
|
||||
${SOURCE_CORE_JCONTEXT}
|
||||
${SOURCE_CORE_JMEM}
|
||||
${SOURCE_CORE_JRT}
|
||||
${SOURCE_CORE_LIT}
|
||||
${SOURCE_CORE_PARSER_JS}
|
||||
${SOURCE_CORE_PARSER_REGEXP}
|
||||
${SOURCE_CORE_VM})
|
||||
|
||||
# Jerry port
|
||||
file(GLOB SOURCE_PORT_FILES "${PORT_DIR}/*.c")
|
||||
|
||||
# All-in-one build
|
||||
if(ENABLE_ALL_IN_ONE)
|
||||
set(ALL_IN_FILE "${CMAKE_BINARY_DIR}/jerry-all-in.c")
|
||||
list(SORT SOURCE_CORE_FILES)
|
||||
file(REMOVE ${ALL_IN_FILE})
|
||||
|
||||
foreach(FILE ${SOURCE_CORE_FILES})
|
||||
file(APPEND ${ALL_IN_FILE} "#include \"${FILE}\"\n")
|
||||
endforeach()
|
||||
|
||||
foreach(FILE ${SOURCE_PORT_FILES})
|
||||
file(APPEND ${ALL_IN_FILE} "#include \"${FILE}\"\n")
|
||||
endforeach()
|
||||
|
||||
set(SOURCE_CORE ${ALL_IN_FILE})
|
||||
else()
|
||||
set(SOURCE_CORE ${SOURCE_CORE_FILES} ${SOURCE_PORT_FILES})
|
||||
endif()
|
||||
|
||||
# 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})
|
||||
|
||||
# Definitions
|
||||
# Get version information from git
|
||||
if(IS_DIRECTORY "${CMAKE_SOURCE_DIR}/.git")
|
||||
execute_process(COMMAND git symbolic-ref -q HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE JERRY_GIT_BRANCH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(COMMAND git rev-parse HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE JERRY_GIT_COMMIT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
else()
|
||||
set(JERRY_GIT_BRANCH "UNDEFINED")
|
||||
set(JERRY_GIT_COMMIT "UNDEFINED")
|
||||
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
|
||||
# Get build date
|
||||
execute_process(COMMAND date +%d/%m/%Y
|
||||
OUTPUT_VARIABLE JERRY_BUILD_DATE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Sources
|
||||
# Jerry core
|
||||
set(SOURCE_CORE_FILES
|
||||
api/jerry-debugger-transport.c
|
||||
api/jerry-debugger.c
|
||||
api/jerry-module.c
|
||||
api/jerry-snapshot.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
|
||||
ecma/base/ecma-helpers-external-pointers.c
|
||||
ecma/base/ecma-helpers-number.c
|
||||
ecma/base/ecma-helpers-string.c
|
||||
ecma/base/ecma-helpers-value.c
|
||||
ecma/base/ecma-helpers.c
|
||||
ecma/base/ecma-init-finalize.c
|
||||
ecma/base/ecma-lcache.c
|
||||
ecma/base/ecma-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
|
||||
ecma/builtin-objects/ecma-builtin-boolean.c
|
||||
ecma/builtin-objects/ecma-builtin-dataview-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-dataview.c
|
||||
ecma/builtin-objects/ecma-builtin-date-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-date.c
|
||||
ecma/builtin-objects/ecma-builtin-error-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-error.c
|
||||
ecma/builtin-objects/ecma-builtin-evalerror-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-evalerror.c
|
||||
ecma/builtin-objects/ecma-builtin-function-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-function.c
|
||||
ecma/builtin-objects/ecma-builtin-generator-function.c
|
||||
ecma/builtin-objects/ecma-builtin-generator-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-generator.c
|
||||
ecma/builtin-objects/ecma-builtin-global.c
|
||||
ecma/builtin-objects/ecma-builtin-handlers.c
|
||||
ecma/builtin-objects/ecma-builtin-helpers-date.c
|
||||
ecma/builtin-objects/ecma-builtin-helpers-error.c
|
||||
ecma/builtin-objects/ecma-builtin-helpers-json.c
|
||||
ecma/builtin-objects/ecma-builtin-helpers-sort.c
|
||||
ecma/builtin-objects/ecma-builtin-helpers.c
|
||||
ecma/builtin-objects/ecma-builtin-intrinsic.c
|
||||
ecma/builtin-objects/ecma-builtin-iterator-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-json.c
|
||||
ecma/builtin-objects/ecma-builtin-map-iterator-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-map-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-map.c
|
||||
ecma/builtin-objects/ecma-builtin-math.c
|
||||
ecma/builtin-objects/ecma-builtin-number-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-number.c
|
||||
ecma/builtin-objects/ecma-builtin-object-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-object.c
|
||||
ecma/builtin-objects/ecma-builtin-promise-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-promise.c
|
||||
ecma/builtin-objects/ecma-builtin-proxy.c
|
||||
ecma/builtin-objects/ecma-builtin-rangeerror-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-rangeerror.c
|
||||
ecma/builtin-objects/ecma-builtin-referenceerror-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-referenceerror.c
|
||||
ecma/builtin-objects/ecma-builtin-reflect.c
|
||||
ecma/builtin-objects/ecma-builtin-regexp-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-regexp-string-iterator-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-regexp.c
|
||||
ecma/builtin-objects/ecma-builtin-set-iterator-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-set-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-set.c
|
||||
ecma/builtin-objects/ecma-builtin-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
|
||||
ecma/builtin-objects/ecma-builtin-symbol-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-symbol.c
|
||||
ecma/builtin-objects/ecma-builtin-syntaxerror-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-syntaxerror.c
|
||||
ecma/builtin-objects/ecma-builtin-type-error-thrower.c
|
||||
ecma/builtin-objects/ecma-builtin-typeerror-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-typeerror.c
|
||||
ecma/builtin-objects/ecma-builtin-urierror-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-urierror.c
|
||||
ecma/builtin-objects/ecma-builtin-weakmap-prototype.c
|
||||
ecma/builtin-objects/ecma-builtin-weakmap.c
|
||||
ecma/builtin-objects/ecma-builtin-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
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-bigint64array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-bigint64array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-biguint64array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-biguint64array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-float32array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-float32array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-float64array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-float64array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-int16array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-int16array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-int32array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-int32array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-int8array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-int8array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-typedarray-helpers.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-typedarray.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-uint16array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-uint16array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-uint32array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-uint32array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-uint8array-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-uint8array.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray-prototype.c
|
||||
ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray.c
|
||||
ecma/operations/ecma-arguments-object.c
|
||||
ecma/operations/ecma-array-object.c
|
||||
ecma/operations/ecma-arraybuffer-object.c
|
||||
ecma/operations/ecma-async-generator-object.c
|
||||
ecma/operations/ecma-atomics-object.c
|
||||
ecma/operations/ecma-big-uint.c
|
||||
ecma/operations/ecma-bigint-object.c
|
||||
ecma/operations/ecma-bigint.c
|
||||
ecma/operations/ecma-boolean-object.c
|
||||
ecma/operations/ecma-comparison.c
|
||||
ecma/operations/ecma-container-object.c
|
||||
ecma/operations/ecma-conversion.c
|
||||
ecma/operations/ecma-dataview-object.c
|
||||
ecma/operations/ecma-eval.c
|
||||
ecma/operations/ecma-exceptions.c
|
||||
ecma/operations/ecma-function-object.c
|
||||
ecma/operations/ecma-get-put-value.c
|
||||
ecma/operations/ecma-iterator-object.c
|
||||
ecma/operations/ecma-jobqueue.c
|
||||
ecma/operations/ecma-lex-env.c
|
||||
ecma/operations/ecma-number-object.c
|
||||
ecma/operations/ecma-objects-general.c
|
||||
ecma/operations/ecma-objects.c
|
||||
ecma/operations/ecma-promise-object.c
|
||||
ecma/operations/ecma-proxy-object.c
|
||||
ecma/operations/ecma-reference.c
|
||||
ecma/operations/ecma-regexp-object.c
|
||||
ecma/operations/ecma-shared-arraybuffer-object.c
|
||||
ecma/operations/ecma-string-object.c
|
||||
ecma/operations/ecma-symbol-object.c
|
||||
ecma/operations/ecma-typedarray-object.c
|
||||
jcontext/jcontext.c
|
||||
jmem/jmem-allocator.c
|
||||
jmem/jmem-heap.c
|
||||
jmem/jmem-poolman.c
|
||||
jrt/jrt-fatals.c
|
||||
jrt/jrt-logging.c
|
||||
lit/lit-char-helpers.c
|
||||
lit/lit-magic-strings.c
|
||||
lit/lit-strings.c
|
||||
parser/js/byte-code.c
|
||||
parser/js/common.c
|
||||
parser/js/js-lexer.c
|
||||
parser/js/js-parser-expr.c
|
||||
parser/js/js-parser-line-info-create.c
|
||||
parser/js/js-parser-mem.c
|
||||
parser/js/js-parser-module.c
|
||||
parser/js/js-parser-statm.c
|
||||
parser/js/js-parser-tagged-template-literal.c
|
||||
parser/js/js-parser-util.c
|
||||
parser/js/js-parser.c
|
||||
parser/js/js-scanner-ops.c
|
||||
parser/js/js-scanner-util.c
|
||||
parser/js/js-scanner.c
|
||||
parser/js/parser-errors.c
|
||||
parser/regexp/re-bytecode.c
|
||||
parser/regexp/re-compiler.c
|
||||
parser/regexp/re-parser.c
|
||||
vm/opcodes-ecma-arithmetics.c
|
||||
vm/opcodes-ecma-bitwise.c
|
||||
vm/opcodes-ecma-relational-equality.c
|
||||
vm/opcodes.c
|
||||
vm/vm-stack.c
|
||||
vm/vm-utils.c
|
||||
vm/vm.c
|
||||
)
|
||||
|
||||
# Amalgamated JerryScript source/header build.
|
||||
# The process will create the following files:
|
||||
# * jerryscript.c
|
||||
# * jerryscript.h
|
||||
# * jerryscript-config.h
|
||||
if(ENABLE_AMALGAM)
|
||||
|
||||
# Create single C/H file
|
||||
set(HEADER_CORE_FILES
|
||||
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
|
||||
ecma/builtin-objects/ecma-builtin-boolean.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-dataview-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-dataview.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-date-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-date.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-error-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-error.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-evalerror-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-evalerror.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-function-prototype.h
|
||||
ecma/builtin-objects/ecma-builtin-function-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-function.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-generator-function.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-generator-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-generator.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-global.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-handlers.h
|
||||
ecma/builtin-objects/ecma-builtin-handlers.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-helpers-macro-defines.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-helpers-macro-undefs.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-helpers.h
|
||||
ecma/builtin-objects/ecma-builtin-internal-routines-template.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-intrinsic.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-iterator-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-json.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-map-iterator-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-map-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-map.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-math.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-number-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-number.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-object-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-object.h
|
||||
ecma/builtin-objects/ecma-builtin-object.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-promise-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-promise.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-proxy.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-rangeerror-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-rangeerror.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-referenceerror-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-referenceerror.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-reflect.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-regexp-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-regexp-string-iterator-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-regexp.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-set-iterator-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-set-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-set.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-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
|
||||
ecma/builtin-objects/ecma-builtin-symbol-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-symbol.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-syntaxerror-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-syntaxerror.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-type-error-thrower.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-typeerror-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-typeerror.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-urierror-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-urierror.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-weakmap-prototype.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-weakmap.inc.h
|
||||
ecma/builtin-objects/ecma-builtin-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
|
||||
ecma/builtin-objects/ecma-builtins.h
|
||||
ecma/builtin-objects/ecma-builtins.inc.h
|
||||
ecma/operations/ecma-arguments-object.h
|
||||
ecma/operations/ecma-array-object.h
|
||||
ecma/operations/ecma-arraybuffer-object.h
|
||||
ecma/operations/ecma-async-generator-object.h
|
||||
ecma/operations/ecma-atomics-object.h
|
||||
ecma/operations/ecma-big-uint.h
|
||||
ecma/operations/ecma-bigint-object.h
|
||||
ecma/operations/ecma-bigint.h
|
||||
ecma/operations/ecma-boolean-object.h
|
||||
ecma/operations/ecma-comparison.h
|
||||
ecma/operations/ecma-container-object.h
|
||||
ecma/operations/ecma-conversion.h
|
||||
ecma/operations/ecma-dataview-object.h
|
||||
ecma/operations/ecma-eval.h
|
||||
ecma/operations/ecma-exceptions.h
|
||||
ecma/operations/ecma-function-object.h
|
||||
ecma/operations/ecma-iterator-object.h
|
||||
ecma/operations/ecma-jobqueue.h
|
||||
ecma/operations/ecma-lex-env.h
|
||||
ecma/operations/ecma-number-object.h
|
||||
ecma/operations/ecma-objects-general.h
|
||||
ecma/operations/ecma-objects.h
|
||||
ecma/operations/ecma-promise-object.h
|
||||
ecma/operations/ecma-proxy-object.h
|
||||
ecma/operations/ecma-reference.h
|
||||
ecma/operations/ecma-regexp-object.h
|
||||
ecma/operations/ecma-shared-arraybuffer-object.h
|
||||
ecma/operations/ecma-string-object.h
|
||||
ecma/operations/ecma-symbol-object.h
|
||||
ecma/operations/ecma-typedarray-object.h
|
||||
include/jerryscript-compiler.h
|
||||
include/jerryscript-core.h
|
||||
include/jerryscript-debugger-transport.h
|
||||
include/jerryscript-debugger.h
|
||||
include/jerryscript-port.h
|
||||
include/jerryscript-snapshot.h
|
||||
include/jerryscript.h
|
||||
jcontext/jcontext.h
|
||||
jmem/jmem-allocator-internal.h
|
||||
jmem/jmem.h
|
||||
jrt/jrt-bit-fields.h
|
||||
jrt/jrt-libc-includes.h
|
||||
jrt/jrt-types.h
|
||||
jrt/jrt.h
|
||||
lit/lit-char-helpers.h
|
||||
lit/lit-globals.h
|
||||
lit/lit-magic-strings.h
|
||||
lit/lit-magic-strings.inc.h
|
||||
lit/lit-strings.h
|
||||
lit/lit-unicode-conversions-sup.inc.h
|
||||
lit/lit-unicode-conversions.inc.h
|
||||
lit/lit-unicode-folding.inc.h
|
||||
lit/lit-unicode-ranges-sup.inc.h
|
||||
lit/lit-unicode-ranges.inc.h
|
||||
vm/opcodes.h
|
||||
vm/vm-defines.h
|
||||
vm/vm-stack.h
|
||||
vm/vm.h
|
||||
)
|
||||
|
||||
# Generated files
|
||||
set(AMALGAM_CORE_C "${CMAKE_BINARY_DIR}/amalgam/jerryscript.c")
|
||||
set(AMALGAM_CORE_H "${CMAKE_BINARY_DIR}/amalgam/jerryscript.h")
|
||||
set(AMALGAM_CONFIG_H "${CMAKE_BINARY_DIR}/amalgam/jerryscript-config.h")
|
||||
|
||||
add_custom_command(OUTPUT ${AMALGAM_CORE_C} ${AMALGAM_CORE_H}
|
||||
COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/tools/amalgam.py
|
||||
--jerry-core
|
||||
--output-dir ${CMAKE_BINARY_DIR}/amalgam
|
||||
DEPENDS ${SOURCE_CORE_FILES}
|
||||
${HEADER_CORE_FILES}
|
||||
${CMAKE_SOURCE_DIR}/tools/amalgam.py
|
||||
)
|
||||
|
||||
# The "true" jerryscript-config.h will be generated by the configure_file below,
|
||||
# which contains the default options and the ones passed for the CMake.
|
||||
# The input for this is the jerryscript-config.h generated by the command above.
|
||||
set(JERRYSCRIPT_GEN_CONFIG_H ${CMAKE_CURRENT_BINARY_DIR}/jerryscript-config.h)
|
||||
add_custom_command(OUTPUT ${AMALGAM_CONFIG_H}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${JERRYSCRIPT_GEN_CONFIG_H} ${AMALGAM_CONFIG_H}
|
||||
DEPENDS ${AMALGAM_CORE_C} ${AMALGAM_CORE_H})
|
||||
add_custom_target(amalgam-jerry DEPENDS ${AMALGAM_CORE_C} ${AMALGAM_CORE_H} ${AMALGAM_CONFIG_H})
|
||||
add_dependencies(amalgam amalgam-jerry)
|
||||
|
||||
set(SOURCE_CORE_FILES ${AMALGAM_CORE_C} ${AMALGAM_CORE_H} ${AMALGAM_CONFIG_H})
|
||||
set(INCLUDE_CORE_PUBLIC PARENT_SCOPE)
|
||||
set(INCLUDE_CORE_PRIVATE PARENT_SCOPE)
|
||||
endif()
|
||||
set(DEFINES_JERRY
|
||||
${DEFINES_JERRY}
|
||||
JERRY_BUILD_DATE="${JERRY_BUILD_DATE}"
|
||||
JERRY_COMMIT_HASH="${JERRY_GIT_COMMIT}"
|
||||
JERRY_BRANCH_NAME="${JERRY_GIT_BRANCH}")
|
||||
|
||||
# build mode specific compile/link flags
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} $<$<NOT:$<CONFIG:Debug>>:JERRY_NDEBUG>)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_PRETTY_PRINTER)
|
||||
else()
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_NDEBUG)
|
||||
endif()
|
||||
|
||||
# Profile modes
|
||||
# Minimal profile
|
||||
if(FEATURE_PROFILE STREQUAL "minimal")
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY}
|
||||
CONFIG_DISABLE_NUMBER_BUILTIN
|
||||
CONFIG_DISABLE_STRING_BUILTIN
|
||||
CONFIG_DISABLE_BOOLEAN_BUILTIN
|
||||
CONFIG_DISABLE_ERROR_BUILTINS
|
||||
CONFIG_DISABLE_ARRAY_BUILTIN
|
||||
CONFIG_DISABLE_MATH_BUILTIN
|
||||
CONFIG_DISABLE_JSON_BUILTIN
|
||||
CONFIG_DISABLE_DATE_BUILTIN
|
||||
CONFIG_DISABLE_REGEXP_BUILTIN
|
||||
CONFIG_DISABLE_ANNEXB_BUILTIN)
|
||||
elseif(NOT FEATURE_PROFILE STREQUAL "full")
|
||||
message(FATAL_ERROR "FEATURE_PROFILE='${FEATURE_PROFILE}' doesn't supported")
|
||||
endif()
|
||||
|
||||
# Jerry heap-section
|
||||
if(DEFINED JERRY_ATTR_GLOBAL_HEAP)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ATTR_GLOBAL_HEAP=${JERRY_ATTR_GLOBAL_HEAP})
|
||||
if(DEFINED JERRY_HEAP_SECTION_ATTR)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_HEAP_SECTION_ATTR=${JERRY_HEAP_SECTION_ATTR})
|
||||
endif()
|
||||
|
||||
# Memory usage limit for triggering garbage collection
|
||||
if(JERRY_GC_LIMIT)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_GC_LIMIT=${JERRY_GC_LIMIT})
|
||||
endif()
|
||||
|
||||
# Helper macro to set 0/1 switch as Jerry Defines
|
||||
macro(jerry_add_define01 NAME)
|
||||
if(${NAME})
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} ${NAME}=1)
|
||||
else()
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} ${NAME}=0)
|
||||
endif()
|
||||
endmacro(jerry_add_define01)
|
||||
|
||||
# Checks the optional features
|
||||
# Enable 32 bit cpointers
|
||||
jerry_add_define01(JERRY_CPOINTER_32_BIT)
|
||||
|
||||
# Fill error messages for builtin error objects
|
||||
jerry_add_define01(JERRY_ERROR_MESSAGES)
|
||||
|
||||
# Use external context instead of static one
|
||||
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)
|
||||
|
||||
# Logging
|
||||
jerry_add_define01(JERRY_LOGGING)
|
||||
|
||||
# Memory statistics
|
||||
jerry_add_define01(JERRY_MEM_STATS)
|
||||
|
||||
# Enable debugger
|
||||
jerry_add_define01(JERRY_DEBUGGER)
|
||||
|
||||
# Memory management stress-test mode
|
||||
jerry_add_define01(JERRY_MEM_GC_BEFORE_EACH_ALLOC)
|
||||
|
||||
# Parser byte-code dumps
|
||||
jerry_add_define01(JERRY_PARSER_DUMP_BYTE_CODE)
|
||||
|
||||
# Profile
|
||||
if (${JERRY_PROFILE} STREQUAL "es2015-subset")
|
||||
message(DEPRECATION "'es2015-subset' profile is deprecated, please use 'es.next' instead.")
|
||||
if(FEATURE_ERROR_MESSAGES)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_ERROR_MESSAGES)
|
||||
endif()
|
||||
|
||||
if (NOT IS_ABSOLUTE ${JERRY_PROFILE})
|
||||
set(JERRY_PROFILE "${CMAKE_CURRENT_SOURCE_DIR}/profiles/${JERRY_PROFILE}.profile")
|
||||
endif()
|
||||
|
||||
if(EXISTS ${JERRY_PROFILE})
|
||||
file(READ "${JERRY_PROFILE}" PROFILE_SETTINGS)
|
||||
string(REGEX REPLACE "[ \t]*#[^\n]*" "" PROFILE_SETTINGS "${PROFILE_SETTINGS}")
|
||||
string(REGEX REPLACE "[\r\n]" ";" PROFILE_SETTINGS "${PROFILE_SETTINGS}")
|
||||
|
||||
# Process entries and save them as CMake variables.
|
||||
# This is required to correctly generate the jerryscript-config.h file.
|
||||
foreach(PROFILE_ENTRY ${PROFILE_SETTINGS})
|
||||
string(REPLACE "=" ";" PROFILE_ENTRY "${PROFILE_ENTRY}")
|
||||
list(GET PROFILE_ENTRY 0 PROFILE_KEY)
|
||||
list(GET PROFILE_ENTRY 1 PROFILE_VALUE)
|
||||
set(${PROFILE_KEY} ${PROFILE_VALUE})
|
||||
endforeach()
|
||||
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} ${PROFILE_SETTINGS})
|
||||
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)
|
||||
|
||||
# RegExp byte-code dumps
|
||||
jerry_add_define01(JERRY_REGEXP_DUMP_BYTE_CODE)
|
||||
|
||||
# Snapshot exec
|
||||
jerry_add_define01(JERRY_SNAPSHOT_EXEC)
|
||||
|
||||
# Snapshot save
|
||||
jerry_add_define01(JERRY_SNAPSHOT_SAVE)
|
||||
|
||||
# Enable system allocator
|
||||
jerry_add_define01(JERRY_SYSTEM_ALLOCATOR)
|
||||
|
||||
# Valgrind
|
||||
jerry_add_define01(JERRY_VALGRIND)
|
||||
if(FEATURE_VALGRIND)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_VALGRIND)
|
||||
set(INCLUDE_CORE ${INCLUDE_CORE} ${INCLUDE_THIRD_PARTY_VALGRIND})
|
||||
endif()
|
||||
|
||||
# Enable VM execution stop callback
|
||||
jerry_add_define01(JERRY_VM_HALT)
|
||||
# Valgrind Freya
|
||||
if(FEATURE_VALGRIND_FREYA)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_VALGRIND_FREYA)
|
||||
set(INCLUDE_CORE ${INCLUDE_CORE} ${INCLUDE_THIRD_PARTY_VALGRIND})
|
||||
endif()
|
||||
|
||||
# Enable VM throw callback
|
||||
jerry_add_define01(JERRY_VM_THROW)
|
||||
# Memory management stress-test mode
|
||||
if(FEATURE_MEM_STRESS_TEST)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JMEM_GC_BEFORE_EACH_ALLOC)
|
||||
endif()
|
||||
|
||||
# Memory statistics
|
||||
if(FEATURE_MEM_STATS)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JMEM_STATS)
|
||||
endif()
|
||||
|
||||
# Parser byte-code dumps
|
||||
if(FEATURE_PARSER_DUMP)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} PARSER_DUMP_BYTE_CODE)
|
||||
endif()
|
||||
|
||||
# RegExp byte-code dumps
|
||||
if(FEATURE_REGEXP_DUMP)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} REGEXP_DUMP_BYTE_CODE)
|
||||
endif()
|
||||
|
||||
# Snapshot save
|
||||
if(FEATURE_SNAPSHOT_SAVE)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_SNAPSHOT_SAVE)
|
||||
endif()
|
||||
|
||||
# Snapshot exec
|
||||
if(FEATURE_SNAPSHOT_EXEC)
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_SNAPSHOT_EXEC)
|
||||
endif()
|
||||
|
||||
# Size of heap
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_GLOBAL_HEAP_SIZE=${JERRY_GLOBAL_HEAP_SIZE})
|
||||
math(EXPR MEM_HEAP_AREA_SIZE "${MEM_HEAP_SIZE_KB} * 1024")
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} CONFIG_MEM_HEAP_AREA_SIZE=${MEM_HEAP_AREA_SIZE})
|
||||
|
||||
# Maximum size of stack memory usage
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_STACK_LIMIT=${JERRY_STACK_LIMIT})
|
||||
|
||||
# Maximum depth of recursion during GC mark phase
|
||||
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_GC_MARK_LIMIT=${JERRY_GC_MARK_LIMIT})
|
||||
|
||||
## This function is to read "config.h" for default values
|
||||
function(read_set_defines FILE PREFIX OUTPUTVAR)
|
||||
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/${FILE}" INPUT_FILE_CONTENTS)
|
||||
|
||||
# match all "#define <PREFIX>\n" lines
|
||||
# notes:
|
||||
# * before the "#" there must be a newline and any number of spaces.
|
||||
# * after the "#" there can be any number of spaces.
|
||||
string(REGEX MATCHALL "\r?\n[ ]*#[ ]*define ${PREFIX}[^\n]*"
|
||||
RAW_DEFINES "${INPUT_FILE_CONTENTS}")
|
||||
|
||||
set(SELECTED_VARS )
|
||||
|
||||
# Transform the defines to a list of (<name>; <value>; <name 2>; <value 2>; ...) list
|
||||
foreach(DEFINE_ENTRY ${RAW_DEFINES})
|
||||
# by default every define value is empty
|
||||
set(DEFINE_VALUE " ")
|
||||
|
||||
# split up the define at the space between the define name and value (if there is any)
|
||||
|
||||
# first remove "#define" part of the string
|
||||
string(REGEX REPLACE "\r?\n[ ]*#[ ]*define[ ]+" "" DEFINE_KEY_VALUE "${DEFINE_ENTRY}")
|
||||
string(FIND "${DEFINE_KEY_VALUE}" " " DEFINE_KEY_IDX)
|
||||
string(LENGTH "${DEFINE_KEY_VALUE}" DEFINE_LENGTH)
|
||||
|
||||
if (DEFINE_KEY_IDX EQUAL "-1")
|
||||
set(DEFINE_KEY ${DEFINE_KEY_VALUE})
|
||||
else()
|
||||
string(SUBSTRING "${DEFINE_KEY_VALUE}" 0 ${DEFINE_KEY_IDX} DEFINE_KEY)
|
||||
string(SUBSTRING "${DEFINE_KEY_VALUE}" ${DEFINE_KEY_IDX} -1 DEFINE_VALUE)
|
||||
string(STRIP "${DEFINE_VALUE}" DEFINE_VALUE)
|
||||
endif()
|
||||
|
||||
list(APPEND SELECTED_VARS ${DEFINE_KEY} ${DEFINE_VALUE})
|
||||
endforeach()
|
||||
|
||||
set(${OUTPUTVAR} ${SELECTED_VARS} PARENT_SCOPE)
|
||||
endfunction(read_set_defines)
|
||||
|
||||
# CONFIG_DEFAULTS contains define name and values which have the JERRY_ prefix
|
||||
# as a list of (<name>; <value>; <name 2>; <value 2>; ...)
|
||||
read_set_defines("config.h" JERRY_ CONFIG_DEFAULTS)
|
||||
|
||||
|
||||
## Process the default values and build options to generate build config defines
|
||||
list(LENGTH CONFIG_DEFAULTS CONFIG_DEFAULT_LENGTH)
|
||||
math(EXPR CONFIG_DEFAULT_LENGTH "${CONFIG_DEFAULT_LENGTH} - 1")
|
||||
|
||||
set(JERRY_MODIFIED_OPTIONS)
|
||||
foreach(CONFIG_IDX RANGE 0 ${CONFIG_DEFAULT_LENGTH} 2)
|
||||
list(GET CONFIG_DEFAULTS ${CONFIG_IDX} KEY)
|
||||
math(EXPR VALUE_IDX "${CONFIG_IDX} + 1")
|
||||
list(GET CONFIG_DEFAULTS ${VALUE_IDX} VALUE)
|
||||
|
||||
# ${KEY} is the value for the given variable (aka define)
|
||||
# normalize ON/OFF cmake values to 1/0 for easier processing.
|
||||
if(${KEY} STREQUAL "ON")
|
||||
set(${KEY} 1)
|
||||
elseif(${KEY} STREQUAL "OFF")
|
||||
set(${KEY} 0)
|
||||
endif()
|
||||
|
||||
# Generate "#define JERRY_<CONFIG> <CONFIG_VALUE>" entries if it is different from
|
||||
# the config default.
|
||||
|
||||
# If the define loaded from the config file have a different value than the
|
||||
# relevant option passed for the CMake means that it does not have a default value.
|
||||
if(DEFINED ${KEY} AND NOT (${KEY} STREQUAL ${VALUE}))
|
||||
set(JERRY_MODIFIED_OPTIONS "${JERRY_MODIFIED_OPTIONS}#define ${KEY} ${${KEY}}\n")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Generate the jerryscript-config.h file into the build directory
|
||||
# This file will contain the options different from the default (aka it's the build config).
|
||||
if(JERRY_MODIFIED_OPTIONS)
|
||||
set(JERRY_BUILD_CFG
|
||||
"Generated differences from default by CMake based on build options:\n${JERRY_MODIFIED_OPTIONS}")
|
||||
else()
|
||||
set(JERRY_BUILD_CFG "JerryScript configuration")
|
||||
endif()
|
||||
configure_file(config.h jerryscript-config.h @ONLY)
|
||||
|
||||
add_library(${JERRY_CORE_NAME} ${SOURCE_CORE_FILES})
|
||||
add_library(${JERRY_CORE_NAME} STATIC ${SOURCE_CORE})
|
||||
|
||||
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)
|
||||
target_include_directories(${JERRY_CORE_NAME} PUBLIC ${INCLUDE_CORE})
|
||||
|
||||
set(JERRY_CORE_PKGCONFIG_REQUIRES)
|
||||
set(JERRY_CORE_PKGCONFIG_LIBS)
|
||||
set(JERRY_CORE_PKGCONFIG_CFLAGS)
|
||||
|
||||
if(ENABLE_LTO)
|
||||
set(JERRY_CORE_PKGCONFIG_CFLAGS "${JERRY_CORE_PKGCONFIG_CFLAGS} -flto")
|
||||
if (JERRY_LIBC)
|
||||
target_include_directories(${JERRY_CORE_NAME} SYSTEM PRIVATE "${CMAKE_SOURCE_DIR}/jerry-libc/include")
|
||||
endif()
|
||||
|
||||
if(JERRY_MATH)
|
||||
target_link_libraries(${JERRY_CORE_NAME} jerry-math)
|
||||
set(JERRY_CORE_PKGCONFIG_REQUIRES libjerry-math)
|
||||
else()
|
||||
if(USING_GCC OR USING_CLANG)
|
||||
set(CMAKE_REQUIRED_FLAGS "-Wno-error -Wno-error=strict-prototypes")
|
||||
endif()
|
||||
check_library_exists(m sin "" HAVE_M_LIB)
|
||||
if(HAVE_M_LIB)
|
||||
target_link_libraries(${JERRY_CORE_NAME} m)
|
||||
set(JERRY_CORE_PKGCONFIG_LIBS "${JERRY_CORE_PKGCONFIG_LIBS} -lm")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
separate_arguments(EXTERNAL_LINK_LIBS)
|
||||
foreach(EXT_LIB ${EXTERNAL_LINK_LIBS})
|
||||
target_link_libraries(${JERRY_CORE_NAME} ${EXT_LIB})
|
||||
set(JERRY_CORE_PKGCONFIG_LIBS "${JERRY_CORE_PKGCONFIG_LIBS} -l${EXT_LIB}")
|
||||
endforeach()
|
||||
|
||||
configure_file(libjerry-core.pc.in libjerry-core.pc @ONLY)
|
||||
|
||||
install(TARGETS ${JERRY_CORE_NAME} DESTINATION lib)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libjerry-core.pc DESTINATION lib/pkgconfig)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jerryscript-config.h DESTINATION include)
|
||||
install(DIRECTORY ${INCLUDE_CORE_PUBLIC}/ DESTINATION include)
|
||||
|
||||
@@ -1,248 +0,0 @@
|
||||
/* 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.h"
|
||||
|
||||
#include "debugger.h"
|
||||
#include "jcontext.h"
|
||||
|
||||
#if JERRY_DEBUGGER
|
||||
|
||||
/**
|
||||
* Minimum number of bytes transmitted or received.
|
||||
*/
|
||||
#define JERRY_DEBUGGER_TRANSPORT_MIN_BUFFER_SIZE 64
|
||||
|
||||
/**
|
||||
* Sleep time in milliseconds between each jerry_debugger_receive call
|
||||
*/
|
||||
#define JERRY_DEBUGGER_TRANSPORT_TIMEOUT 100
|
||||
|
||||
/**
|
||||
* Add a new transport layer.
|
||||
*/
|
||||
void
|
||||
jerry_debugger_transport_add (jerry_debugger_transport_header_t *header_p, /**< transport implementation */
|
||||
size_t send_message_header_size, /**< header bytes reserved for outgoing messages */
|
||||
size_t max_send_message_size, /**< maximum number of bytes transmitted in a message */
|
||||
size_t receive_message_header_size, /**< header bytes reserved for incoming messages */
|
||||
size_t max_receive_message_size) /**< maximum number of bytes received in a message */
|
||||
{
|
||||
JERRY_ASSERT (max_send_message_size > JERRY_DEBUGGER_TRANSPORT_MIN_BUFFER_SIZE
|
||||
&& max_receive_message_size > JERRY_DEBUGGER_TRANSPORT_MIN_BUFFER_SIZE);
|
||||
|
||||
header_p->next_p = JERRY_CONTEXT (debugger_transport_header_p);
|
||||
JERRY_CONTEXT (debugger_transport_header_p) = header_p;
|
||||
|
||||
uint8_t *payload_p;
|
||||
size_t max_send_size;
|
||||
size_t max_receive_size;
|
||||
|
||||
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
|
||||
{
|
||||
payload_p = JERRY_CONTEXT (debugger_send_buffer_payload_p);
|
||||
max_send_size = JERRY_CONTEXT (debugger_max_send_size);
|
||||
max_receive_size = JERRY_CONTEXT (debugger_max_receive_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_CONNECTED);
|
||||
payload_p = JERRY_CONTEXT (debugger_send_buffer);
|
||||
max_send_size = JERRY_DEBUGGER_TRANSPORT_MAX_BUFFER_SIZE;
|
||||
max_receive_size = JERRY_DEBUGGER_TRANSPORT_MAX_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (max_send_size > JERRY_DEBUGGER_TRANSPORT_MIN_BUFFER_SIZE + send_message_header_size);
|
||||
JERRY_ASSERT (max_receive_size > JERRY_DEBUGGER_TRANSPORT_MIN_BUFFER_SIZE + receive_message_header_size);
|
||||
|
||||
JERRY_CONTEXT (debugger_send_buffer_payload_p) = payload_p + send_message_header_size;
|
||||
|
||||
max_send_size = max_send_size - send_message_header_size;
|
||||
max_receive_size = max_receive_size - receive_message_header_size;
|
||||
|
||||
if (max_send_size > max_send_message_size)
|
||||
{
|
||||
max_send_size = max_send_message_size;
|
||||
}
|
||||
|
||||
if (max_receive_size > max_receive_message_size)
|
||||
{
|
||||
max_receive_size = max_receive_message_size;
|
||||
}
|
||||
|
||||
JERRY_CONTEXT (debugger_max_send_size) = (uint8_t) max_send_size;
|
||||
JERRY_CONTEXT (debugger_max_receive_size) = (uint8_t) max_receive_size;
|
||||
} /* jerry_debugger_transport_add */
|
||||
|
||||
/**
|
||||
* Starts the communication to the debugger client.
|
||||
* Must be called after the connection is successfully established.
|
||||
*/
|
||||
void
|
||||
jerry_debugger_transport_start (void)
|
||||
{
|
||||
JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED);
|
||||
|
||||
if (jerry_debugger_send_configuration (JERRY_CONTEXT (debugger_max_receive_size)))
|
||||
{
|
||||
JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_STOP);
|
||||
JERRY_CONTEXT (debugger_stop_context) = NULL;
|
||||
}
|
||||
} /* jerry_debugger_transport_start */
|
||||
|
||||
/**
|
||||
* Returns true if a debugger client is connected.
|
||||
*
|
||||
* @return true - a debugger client is connected,
|
||||
* false - otherwise
|
||||
*/
|
||||
bool
|
||||
jerry_debugger_transport_is_connected (void)
|
||||
{
|
||||
return (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED) != 0;
|
||||
} /* jerry_debugger_transport_is_connected */
|
||||
|
||||
/**
|
||||
* Notifies the debugger server that the connection is closed.
|
||||
*/
|
||||
void
|
||||
jerry_debugger_transport_close (void)
|
||||
{
|
||||
if (!(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
JERRY_CONTEXT (debugger_flags) = JERRY_DEBUGGER_VM_IGNORE;
|
||||
|
||||
jerry_debugger_transport_header_t *current_p = JERRY_CONTEXT (debugger_transport_header_p);
|
||||
|
||||
JERRY_ASSERT (current_p != NULL);
|
||||
|
||||
do
|
||||
{
|
||||
jerry_debugger_transport_header_t *next_p = current_p->next_p;
|
||||
|
||||
current_p->close (current_p);
|
||||
|
||||
current_p = next_p;
|
||||
} while (current_p != NULL);
|
||||
|
||||
jerry_log (JERRY_LOG_LEVEL_DEBUG, "Debugger client connection closed.\n");
|
||||
|
||||
jerry_debugger_free_unreferenced_byte_code ();
|
||||
} /* jerry_debugger_transport_close */
|
||||
|
||||
/**
|
||||
* Send data over the current connection
|
||||
*
|
||||
* @return true - data sent successfully,
|
||||
* false - connection closed
|
||||
*/
|
||||
bool
|
||||
jerry_debugger_transport_send (const uint8_t *message_p, /**< message to be sent */
|
||||
size_t message_length) /**< message length in bytes */
|
||||
{
|
||||
JERRY_ASSERT (jerry_debugger_transport_is_connected ());
|
||||
JERRY_ASSERT (message_length > 0);
|
||||
|
||||
jerry_debugger_transport_header_t *header_p = JERRY_CONTEXT (debugger_transport_header_p);
|
||||
uint8_t *payload_p = JERRY_CONTEXT (debugger_send_buffer_payload_p);
|
||||
size_t max_send_size = JERRY_CONTEXT (debugger_max_send_size);
|
||||
|
||||
do
|
||||
{
|
||||
size_t fragment_length = (message_length <= max_send_size ? message_length : max_send_size);
|
||||
|
||||
memcpy (payload_p, message_p, fragment_length);
|
||||
|
||||
if (!header_p->send (header_p, payload_p, fragment_length))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
message_p += fragment_length;
|
||||
message_length -= fragment_length;
|
||||
} while (message_length > 0);
|
||||
|
||||
return true;
|
||||
} /* jerry_debugger_transport_send */
|
||||
|
||||
/**
|
||||
* Receive data from the current connection
|
||||
*
|
||||
* Note:
|
||||
* A message is received if message_start_p is not NULL
|
||||
*
|
||||
* @return true - function successfully completed,
|
||||
* false - connection closed
|
||||
*/
|
||||
bool
|
||||
jerry_debugger_transport_receive (jerry_debugger_transport_receive_context_t *context_p) /**< [out] receive
|
||||
* context */
|
||||
{
|
||||
JERRY_ASSERT (jerry_debugger_transport_is_connected ());
|
||||
|
||||
context_p->buffer_p = JERRY_CONTEXT (debugger_receive_buffer);
|
||||
context_p->received_length = JERRY_CONTEXT (debugger_received_length);
|
||||
context_p->message_p = NULL;
|
||||
context_p->message_length = 0;
|
||||
context_p->message_total_length = 0;
|
||||
|
||||
jerry_debugger_transport_header_t *header_p = JERRY_CONTEXT (debugger_transport_header_p);
|
||||
|
||||
return header_p->receive (header_p, context_p);
|
||||
} /* jerry_debugger_transport_receive */
|
||||
|
||||
/**
|
||||
* Clear the message buffer after the message is processed
|
||||
*/
|
||||
void
|
||||
jerry_debugger_transport_receive_completed (jerry_debugger_transport_receive_context_t *context_p) /**< receive
|
||||
* context */
|
||||
{
|
||||
JERRY_ASSERT (context_p->message_p != NULL);
|
||||
JERRY_ASSERT (context_p->buffer_p == JERRY_CONTEXT (debugger_receive_buffer));
|
||||
|
||||
size_t message_total_length = context_p->message_total_length;
|
||||
size_t received_length = context_p->received_length;
|
||||
|
||||
JERRY_ASSERT (message_total_length <= received_length);
|
||||
|
||||
if (message_total_length == 0 || message_total_length == received_length)
|
||||
{
|
||||
/* All received data is processed. */
|
||||
JERRY_CONTEXT (debugger_received_length) = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t *buffer_p = context_p->buffer_p;
|
||||
received_length -= message_total_length;
|
||||
|
||||
memmove (buffer_p, buffer_p + message_total_length, received_length);
|
||||
|
||||
JERRY_CONTEXT (debugger_received_length) = (uint16_t) received_length;
|
||||
} /* jerry_debugger_transport_receive_completed */
|
||||
|
||||
/**
|
||||
* Suspend execution for a predefined time (JERRY_DEBUGGER_TRANSPORT_TIMEOUT ms).
|
||||
*/
|
||||
void
|
||||
jerry_debugger_transport_sleep (void)
|
||||
{
|
||||
jerry_port_sleep (JERRY_DEBUGGER_TRANSPORT_TIMEOUT);
|
||||
} /* jerry_debugger_transport_sleep */
|
||||
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
@@ -1,208 +0,0 @@
|
||||
/* 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.h"
|
||||
|
||||
#include "debugger.h"
|
||||
#include "jcontext.h"
|
||||
|
||||
/**
|
||||
* Checks whether the debugger is connected.
|
||||
*
|
||||
* @return true - if the debugger is connected
|
||||
* false - otherwise
|
||||
*/
|
||||
bool
|
||||
jerry_debugger_is_connected (void)
|
||||
{
|
||||
#if JERRY_DEBUGGER
|
||||
return JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED;
|
||||
#else /* !JERRY_DEBUGGER */
|
||||
return false;
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
} /* jerry_debugger_is_connected */
|
||||
|
||||
/**
|
||||
* Stop execution at the next available breakpoint.
|
||||
*/
|
||||
void
|
||||
jerry_debugger_stop (void)
|
||||
{
|
||||
#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 /* JERRY_DEBUGGER */
|
||||
} /* jerry_debugger_stop */
|
||||
|
||||
/**
|
||||
* Continue execution.
|
||||
*/
|
||||
void
|
||||
jerry_debugger_continue (void)
|
||||
{
|
||||
#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 /* JERRY_DEBUGGER */
|
||||
} /* jerry_debugger_continue */
|
||||
|
||||
/**
|
||||
* Sets whether the engine should stop at breakpoints.
|
||||
*/
|
||||
void
|
||||
jerry_debugger_stop_at_breakpoint (bool enable_stop_at_breakpoint) /**< enable/disable stop at breakpoint */
|
||||
{
|
||||
#if JERRY_DEBUGGER
|
||||
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED
|
||||
&& !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
|
||||
{
|
||||
if (enable_stop_at_breakpoint)
|
||||
{
|
||||
JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_IGNORE);
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_VM_IGNORE);
|
||||
}
|
||||
}
|
||||
#else /* !JERRY_DEBUGGER */
|
||||
JERRY_UNUSED (enable_stop_at_breakpoint);
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
} /* jerry_debugger_stop_at_breakpoint */
|
||||
|
||||
/**
|
||||
* Sets whether the engine should wait and run a source.
|
||||
*
|
||||
* @return enum JERRY_DEBUGGER_SOURCE_RECEIVE_FAILED - if the source is not received
|
||||
* JERRY_DEBUGGER_SOURCE_RECEIVED - if a source code received
|
||||
* JERRY_DEBUGGER_SOURCE_END - the end of the source codes
|
||||
* JERRY_DEBUGGER_CONTEXT_RESET_RECEIVED - the end of the context
|
||||
*/
|
||||
jerry_debugger_wait_for_source_status_t
|
||||
jerry_debugger_wait_for_client_source (jerry_debugger_wait_for_source_callback_t callback_p, /**< callback function */
|
||||
void *user_p, /**< user pointer passed to the callback */
|
||||
jerry_value_t *return_value) /**< [out] parse and run return value */
|
||||
{
|
||||
*return_value = jerry_undefined ();
|
||||
|
||||
#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_CLIENT_SOURCE_MODE);
|
||||
jerry_debugger_uint8_data_t *client_source_data_p = NULL;
|
||||
jerry_debugger_wait_for_source_status_t ret_type = JERRY_DEBUGGER_SOURCE_RECEIVE_FAILED;
|
||||
|
||||
/* Notify the client about that the engine is waiting for a source. */
|
||||
jerry_debugger_send_type (JERRY_DEBUGGER_WAIT_FOR_SOURCE);
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (jerry_debugger_receive (&client_source_data_p))
|
||||
{
|
||||
if (!(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
/* Stop executing the current context. */
|
||||
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONTEXT_RESET_MODE))
|
||||
{
|
||||
ret_type = JERRY_DEBUGGER_CONTEXT_RESET_RECEIVED;
|
||||
JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_CONTEXT_RESET_MODE);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Stop waiting for a new source file. */
|
||||
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CLIENT_NO_SOURCE))
|
||||
{
|
||||
ret_type = JERRY_DEBUGGER_SOURCE_END;
|
||||
JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_CLIENT_SOURCE_MODE);
|
||||
break;
|
||||
}
|
||||
|
||||
/* The source arrived. */
|
||||
if (!(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CLIENT_SOURCE_MODE))
|
||||
{
|
||||
JERRY_ASSERT (client_source_data_p != NULL);
|
||||
|
||||
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 (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;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
jerry_debugger_transport_sleep ();
|
||||
}
|
||||
|
||||
JERRY_ASSERT (!(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CLIENT_SOURCE_MODE)
|
||||
|| !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED));
|
||||
|
||||
if (client_source_data_p != NULL)
|
||||
{
|
||||
/* The data may partly arrived. */
|
||||
jmem_heap_free_block (client_source_data_p,
|
||||
client_source_data_p->uint8_size + sizeof (jerry_debugger_uint8_data_t));
|
||||
}
|
||||
|
||||
return ret_type;
|
||||
}
|
||||
|
||||
return JERRY_DEBUGGER_SOURCE_RECEIVE_FAILED;
|
||||
#else /* !JERRY_DEBUGGER */
|
||||
JERRY_UNUSED (callback_p);
|
||||
JERRY_UNUSED (user_p);
|
||||
|
||||
return JERRY_DEBUGGER_SOURCE_RECEIVE_FAILED;
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
} /* jerry_debugger_wait_for_client_source */
|
||||
|
||||
/**
|
||||
* Send the output of the program to the debugger client.
|
||||
* Currently only sends print output.
|
||||
*/
|
||||
void
|
||||
jerry_debugger_send_output (const jerry_char_t *buffer, /**< buffer */
|
||||
jerry_size_t str_size) /**< string size */
|
||||
{
|
||||
#if JERRY_DEBUGGER
|
||||
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
|
||||
{
|
||||
jerry_debugger_send_string (JERRY_DEBUGGER_OUTPUT_RESULT,
|
||||
JERRY_DEBUGGER_OUTPUT_PRINT,
|
||||
(const uint8_t *) buffer,
|
||||
sizeof (uint8_t) * str_size);
|
||||
}
|
||||
#else /* !JERRY_DEBUGGER */
|
||||
JERRY_UNUSED (buffer);
|
||||
JERRY_UNUSED (str_size);
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
} /* jerry_debugger_send_output */
|
||||
@@ -1,247 +0,0 @@
|
||||
/* 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 */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,53 +0,0 @@
|
||||
/* 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 JERRY_SNAPSHOT_H
|
||||
#define JERRY_SNAPSHOT_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
/**
|
||||
* Snapshot header
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/* The size of this structure is recommended to be divisible by
|
||||
* uint32_t alignment. Otherwise some bytes after the header are wasted. */
|
||||
uint32_t magic; /**< four byte magic number */
|
||||
uint32_t version; /**< version number */
|
||||
uint32_t global_flags; /**< global configuration and feature flags */
|
||||
uint32_t lit_table_offset; /**< byte offset of the literal table */
|
||||
uint32_t number_of_funcs; /**< number of primary ECMAScript functions */
|
||||
uint32_t func_offsets[1]; /**< function offsets (lowest bit: global(0) or eval(1) context) */
|
||||
} jerry_snapshot_header_t;
|
||||
|
||||
/**
|
||||
* Jerry snapshot magic marker.
|
||||
*/
|
||||
#define JERRY_SNAPSHOT_MAGIC (0x5952524Au)
|
||||
|
||||
/**
|
||||
* Snapshot configuration flags.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/* 8 bits are reserved for dynamic features */
|
||||
JERRY_SNAPSHOT_HAS_REGEX_LITERAL = (1u << 0), /**< byte code has regex literal */
|
||||
JERRY_SNAPSHOT_HAS_CLASS_LITERAL = (1u << 1), /**< byte code has class literal */
|
||||
/* 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;
|
||||
|
||||
#endif /* !JERRY_SNAPSHOT_H */
|
||||
File diff suppressed because it is too large
Load Diff
+84
-609
@@ -1,4 +1,5 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 University of Szeged.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,673 +14,147 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef JERRYSCRIPT_CONFIG_H
|
||||
#define JERRYSCRIPT_CONFIG_H
|
||||
|
||||
// @JERRY_BUILD_CFG@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
/**
|
||||
* Built-in configurations
|
||||
*
|
||||
* Allowed values for built-in defines:
|
||||
* 0: Disable the given built-in.
|
||||
* 1: Enable the given built-in.
|
||||
* Limit of data (system heap, engine's data except engine's own heap)
|
||||
*/
|
||||
/*
|
||||
* By default all built-ins are enabled if they are not defined.
|
||||
*/
|
||||
#ifndef JERRY_BUILTINS
|
||||
#define JERRY_BUILTINS 1
|
||||
#endif /* !defined (JERRY_BUILTINS) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_ANNEXB
|
||||
#define JERRY_BUILTIN_ANNEXB JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_ANNEXB) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_ARRAY
|
||||
#define JERRY_BUILTIN_ARRAY JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_ARRAY) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_BOOLEAN
|
||||
#define JERRY_BUILTIN_BOOLEAN JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_BOOLEAN) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_DATE
|
||||
#define JERRY_BUILTIN_DATE JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_DATE) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_ERRORS
|
||||
#define JERRY_BUILTIN_ERRORS JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_ERRORS) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_JSON
|
||||
#define JERRY_BUILTIN_JSON JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_JSON) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_MATH
|
||||
#define JERRY_BUILTIN_MATH JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_MATH) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_NUMBER
|
||||
#define JERRY_BUILTIN_NUMBER JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_NUMBER) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_REGEXP
|
||||
#define JERRY_BUILTIN_REGEXP JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_REGEXP) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_STRING
|
||||
#define JERRY_BUILTIN_STRING JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_STRING) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_BIGINT
|
||||
#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_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_DATAVIEW) */
|
||||
|
||||
#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_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_PROXY) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_REALMS
|
||||
#define JERRY_BUILTIN_REALMS JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_REALMS) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_REFLECT
|
||||
#define JERRY_BUILTIN_REFLECT JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_REFLECT) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_TYPEDARRAY
|
||||
#define JERRY_BUILTIN_TYPEDARRAY JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_TYPEDARRAY) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_SHAREDARRAYBUFFER
|
||||
#define JERRY_BUILTIN_SHAREDARRAYBUFFER JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_SHAREDARRAYBUFFER) */
|
||||
|
||||
#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_BUILTINS
|
||||
#endif /* !defined (JERRY_MODULE_SYSTEM) */
|
||||
#define CONFIG_MEM_DATA_LIMIT_MINUS_HEAP_SIZE (1024)
|
||||
|
||||
/**
|
||||
* Engine internal and misc configurations.
|
||||
* Limit of stack size
|
||||
*/
|
||||
#define CONFIG_MEM_STACK_LIMIT (4096)
|
||||
|
||||
/**
|
||||
* Specifies the compressed pointer representation
|
||||
* Size of pool chunk
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: use 16 bit representation
|
||||
* 1: use 32 bit representation
|
||||
*
|
||||
* Default value: 0
|
||||
* For more details see: jmem/jmem.h
|
||||
* Should not be less than size of any of ECMA Object Model's data types.
|
||||
*/
|
||||
#ifndef JERRY_CPOINTER_32_BIT
|
||||
#define JERRY_CPOINTER_32_BIT 0
|
||||
#endif /* !defined (JERRY_CPOINTER_32_BIT) */
|
||||
#define CONFIG_MEM_POOL_CHUNK_SIZE (8)
|
||||
|
||||
/**
|
||||
* Enable/Disable the engine's JavaScript debugger interface
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable the debugger parts.
|
||||
* 1: Enable the debugger.
|
||||
* Size of heap
|
||||
*/
|
||||
#ifndef JERRY_DEBUGGER
|
||||
#define JERRY_DEBUGGER 0
|
||||
#endif /* !defined (JERRY_DEBUGGER) */
|
||||
#ifndef CONFIG_MEM_HEAP_AREA_SIZE
|
||||
# define CONFIG_MEM_HEAP_AREA_SIZE (512 * 1024)
|
||||
#elif CONFIG_MEM_HEAP_AREA_SIZE > (512 * 1024)
|
||||
# error "Currently, maximum 512 kilobytes heap size is supported"
|
||||
#endif /* !CONFIG_MEM_HEAP_AREA_SIZE */
|
||||
|
||||
/**
|
||||
* Enable/Disable built-in error messages for error objects.
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable error messages.
|
||||
* 1: Enable error message.
|
||||
*
|
||||
* Default value: 0
|
||||
* Max heap usage limit
|
||||
*/
|
||||
#ifndef JERRY_ERROR_MESSAGES
|
||||
#define JERRY_ERROR_MESSAGES 0
|
||||
#endif /* !defined (JERRY_ERROR_MESSAGES) */
|
||||
#define CONFIG_MEM_HEAP_MAX_LIMIT 8192
|
||||
|
||||
/**
|
||||
* Enable/Disable external context.
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable external context.
|
||||
* 1: Enable external context support.
|
||||
*
|
||||
* Default value: 0
|
||||
* Desired limit of heap usage
|
||||
*/
|
||||
#ifndef JERRY_EXTERNAL_CONTEXT
|
||||
#define JERRY_EXTERNAL_CONTEXT 0
|
||||
#endif /* !defined (JERRY_EXTERNAL_CONTEXT) */
|
||||
#define CONFIG_MEM_HEAP_DESIRED_LIMIT (JERRY_MIN (CONFIG_MEM_HEAP_AREA_SIZE / 32, CONFIG_MEM_HEAP_MAX_LIMIT))
|
||||
|
||||
/**
|
||||
* Maximum size of heap in kilobytes
|
||||
* Log2 of maximum possible offset in the heap
|
||||
*
|
||||
* Default value: 512 KiB
|
||||
* The option affects size of compressed pointer that in turn
|
||||
* affects size of ECMA Object Model's data types.
|
||||
*
|
||||
* In any case size of any of the types should not exceed CONFIG_MEM_POOL_CHUNK_SIZE.
|
||||
*
|
||||
* On the other hand, value 2 ^ CONFIG_MEM_HEAP_OFFSET_LOG should not be less than CONFIG_MEM_HEAP_AREA_SIZE.
|
||||
*/
|
||||
#ifndef JERRY_GLOBAL_HEAP_SIZE
|
||||
#define JERRY_GLOBAL_HEAP_SIZE (512)
|
||||
#endif /* !defined (JERRY_GLOBAL_HEAP_SIZE) */
|
||||
#define CONFIG_MEM_HEAP_OFFSET_LOG (19)
|
||||
|
||||
/**
|
||||
* The allowed heap usage limit until next garbage collection, in bytes.
|
||||
*
|
||||
* If value is 0, the default is 1/32 of JERRY_HEAP_SIZE
|
||||
* Number of lower bits in key of literal hash table.
|
||||
*/
|
||||
#ifndef JERRY_GC_LIMIT
|
||||
#define JERRY_GC_LIMIT 0
|
||||
#endif /* !defined (JERRY_GC_LIMIT) */
|
||||
#define CONFIG_LITERAL_HASH_TABLE_KEY_BITS (7)
|
||||
|
||||
/**
|
||||
* Maximum stack usage size in kilobytes
|
||||
* Width of fields used for holding counter of references to ecma-strings and ecma-objects
|
||||
*
|
||||
* Note: This feature cannot be used when 'detect_stack_use_after_return=1' ASAN option is enabled.
|
||||
* For more detailed description:
|
||||
* - https://github.com/google/sanitizers/wiki/AddressSanitizerUseAfterReturn#compatibility
|
||||
* The option affects maximum number of simultaneously existing:
|
||||
* - references to one string;
|
||||
* - stack references to one object
|
||||
* The number is ((2 ^ CONFIG_ECMA_REFERENCE_COUNTER_WIDTH) - 1).
|
||||
*
|
||||
* Default value: 0, unlimited
|
||||
* Also the option affects size of ECMA Object Model's data types.
|
||||
* In any case size of any of the types should not exceed CONFIG_MEM_POOL_CHUNK_SIZE.
|
||||
*/
|
||||
#ifndef JERRY_STACK_LIMIT
|
||||
#define JERRY_STACK_LIMIT (0)
|
||||
#endif /* !defined (JERRY_STACK_LIMIT) */
|
||||
#define CONFIG_ECMA_REFERENCE_COUNTER_WIDTH (12)
|
||||
|
||||
/**
|
||||
* Maximum depth of recursion during GC mark phase
|
||||
*
|
||||
* Default value: 8
|
||||
*/
|
||||
#ifndef JERRY_GC_MARK_LIMIT
|
||||
#define JERRY_GC_MARK_LIMIT (8)
|
||||
#endif /* !defined (JERRY_GC_MARK_LIMIT) */
|
||||
|
||||
/**
|
||||
* Enable/Disable property lookup cache.
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable lookup cache.
|
||||
* 1: Enable lookup cache.
|
||||
*
|
||||
* Default value: 1
|
||||
*/
|
||||
#ifndef JERRY_LCACHE
|
||||
#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.
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable line-info in the engine.
|
||||
* 1: Enable line-info management.
|
||||
*
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_LINE_INFO
|
||||
#define JERRY_LINE_INFO 0
|
||||
#endif /* !defined (JERRY_LINE_INFO) */
|
||||
|
||||
/**
|
||||
* Enable/Disable logging inside the engine.
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable internal logging.
|
||||
* 1: Enable internal logging.
|
||||
*
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_LOGGING
|
||||
#define JERRY_LOGGING 0
|
||||
#endif /* !defined (JERRY_LOGGING) */
|
||||
|
||||
/**
|
||||
* Enable/Disable gc call before every allocation.
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable gc call before each allocation.
|
||||
* 1: Enable and force gc call before each allocation.
|
||||
*
|
||||
* Default value: 0
|
||||
* Warning!: This is an advanced option and will slow down the engine!
|
||||
* Only enable it for debugging purposes.
|
||||
*/
|
||||
#ifndef JERRY_MEM_GC_BEFORE_EACH_ALLOC
|
||||
#define JERRY_MEM_GC_BEFORE_EACH_ALLOC 0
|
||||
#endif /* !defined (JERRY_MEM_GC_BEFORE_EACH_ALLOC) */
|
||||
|
||||
/**
|
||||
* Enable/Disable the collection if run-time memory statistics.
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable run-time memory information collection.
|
||||
* 1: Enable run-time memory statistics collection.
|
||||
*
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_MEM_STATS
|
||||
#define JERRY_MEM_STATS 0
|
||||
#endif /* !defined (JERRY_MEM_STATS) */
|
||||
#define CONFIG_ECMA_REFERENCE_COUNTER_LIMIT ((1u << CONFIG_ECMA_REFERENCE_COUNTER_WIDTH) - 1u)
|
||||
|
||||
/**
|
||||
* Use 32-bit/64-bit float for ecma-numbers
|
||||
* This option is for expert use only!
|
||||
*
|
||||
* Allowed values:
|
||||
* 1: use 64-bit floating point number mode
|
||||
* 0: use 32-bit floating point number mode
|
||||
*
|
||||
* Default value: 1
|
||||
*/
|
||||
#ifndef JERRY_NUMBER_TYPE_FLOAT64
|
||||
#define JERRY_NUMBER_TYPE_FLOAT64 1
|
||||
#endif /* !defined (JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
#define CONFIG_ECMA_NUMBER_FLOAT32 (1u) /* 32-bit float */
|
||||
#define CONFIG_ECMA_NUMBER_FLOAT64 (2u) /* 64-bit float */
|
||||
|
||||
#ifndef CONFIG_ECMA_NUMBER_TYPE
|
||||
# define CONFIG_ECMA_NUMBER_TYPE CONFIG_ECMA_NUMBER_FLOAT64
|
||||
#else /* CONFIG_ECMA_NUMBER_TYPE */
|
||||
# if (CONFIG_ECMA_NUMBER_TYPE != CONFIG_ECMA_NUMBER_FLOAT32 \
|
||||
&& CONFIG_ECMA_NUMBER_TYPE != CONFIG_ECMA_NUMBER_FLOAT64)
|
||||
# error "ECMA-number storage is configured incorrectly"
|
||||
# endif /* CONFIG_ECMA_NUMBER_TYPE != CONFIG_ECMA_NUMBER_FLOAT32
|
||||
&& CONFIG_ECMA_NUMBER_TYPE != CONFIG_ECMA_NUMBER_FLOAT64 */
|
||||
#endif /* !CONFIG_ECMA_NUMBER_TYPE */
|
||||
|
||||
/**
|
||||
* Enable/Disable the JavaScript parser.
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable the JavaScript parser and all related functionallity.
|
||||
* 1: Enable the JavaScript parser.
|
||||
*
|
||||
* Default value: 1
|
||||
* Representation for ecma-characters
|
||||
*/
|
||||
#ifndef JERRY_PARSER
|
||||
#define JERRY_PARSER 1
|
||||
#endif /* !defined (JERRY_PARSER) */
|
||||
#define CONFIG_ECMA_CHAR_ASCII (1) /* ASCII */
|
||||
#define CONFIG_ECMA_CHAR_UTF16 (2) /* UTF-16 */
|
||||
|
||||
#ifndef CONFIG_ECMA_CHAR_ENCODING
|
||||
# define CONFIG_ECMA_CHAR_ENCODING CONFIG_ECMA_CHAR_ASCII
|
||||
#else /* CONFIG_ECMA_CHAR_ENCODING */
|
||||
# if (CONFIG_ECMA_CHAR_ENCODING != CONFIG_ECMA_CHAR_ASCII \
|
||||
&& CONFIG_ECMA_CHAR_ENCODING != CONFIG_ECMA_CHAR_UTF16)
|
||||
# error "ECMA-char encoding is configured incorrectly"
|
||||
# endif /* CONFIG_ECMA_CHAR_ENCODING != CONFIG_ECMA_CHAR_ASCII
|
||||
&& CONFIG_ECMA_CHAR_ENCODING != CONFIG_ECMA_CHAR_UTF16 */
|
||||
#endif /* !CONFIG_ECMA_CHAR_ENCODING */
|
||||
|
||||
/**
|
||||
* Enable/Disable JerryScript byte code dump functions during parsing.
|
||||
* To dump the JerryScript byte code the engine must be initialized with opcodes
|
||||
* display flag. This option does not influence RegExp byte code dumps.
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable all bytecode dump functions.
|
||||
* 1: Enable bytecode dump functions.
|
||||
*
|
||||
* Default value: 0
|
||||
* Disable ECMA lookup cache
|
||||
*/
|
||||
#ifndef JERRY_PARSER_DUMP_BYTE_CODE
|
||||
#define JERRY_PARSER_DUMP_BYTE_CODE 0
|
||||
#endif /* defined (JERRY_PARSER_DUMP_BYTE_CODE) */
|
||||
// #define CONFIG_ECMA_LCACHE_DISABLE
|
||||
|
||||
/**
|
||||
* Enable/Disable ECMA property hashmap.
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable property hasmap.
|
||||
* 1: Enable property hashmap.
|
||||
*
|
||||
* Default value: 1
|
||||
* Disable ECMA property hashmap
|
||||
*/
|
||||
#ifndef JERRY_PROPERTY_HASHMAP
|
||||
#define JERRY_PROPERTY_HASHMAP 1
|
||||
#endif /* !defined (JERRY_PROPERTY_HASHMAP) */
|
||||
// #define CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE
|
||||
|
||||
/**
|
||||
* Enables/disables the Promise event callbacks
|
||||
* Share of newly allocated since last GC objects among all currently allocated objects,
|
||||
* after achieving which, GC is started upon low severity try-give-memory-back requests.
|
||||
*
|
||||
* Default value: 0
|
||||
* Share is calculated as the following:
|
||||
* 1.0 / CONFIG_ECMA_GC_NEW_OBJECTS_SHARE_TO_START_GC
|
||||
*/
|
||||
#ifndef JERRY_PROMISE_CALLBACK
|
||||
#define JERRY_PROMISE_CALLBACK 0
|
||||
#endif /* !defined (JERRY_PROMISE_CALLBACK) */
|
||||
#define CONFIG_ECMA_GC_NEW_OBJECTS_SHARE_TO_START_GC (16)
|
||||
|
||||
/**
|
||||
* Enable/Disable byte code dump functions for RegExp objects.
|
||||
* To dump the RegExp byte code the engine must be initialized with
|
||||
* regexp opcodes display flag. This option does not influence the
|
||||
* JerryScript byte code dumps.
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable all bytecode dump functions.
|
||||
* 1: Enable bytecode dump functions.
|
||||
*
|
||||
* Default value: 0
|
||||
* Link Global Environment to an empty declarative lexical environment
|
||||
* instead of lexical environment bound to Global Object.
|
||||
*/
|
||||
#ifndef JERRY_REGEXP_DUMP_BYTE_CODE
|
||||
#define JERRY_REGEXP_DUMP_BYTE_CODE 0
|
||||
#endif /* !defined (JERRY_REGEXP_DUMP_BYTE_CODE) */
|
||||
// #define CONFIG_ECMA_GLOBAL_ENVIRONMENT_DECLARATIVE
|
||||
|
||||
/**
|
||||
* Enables/disables the RegExp strict mode
|
||||
*
|
||||
* Default value: 0
|
||||
* Number of ecma values inlined into VM stack frame
|
||||
*/
|
||||
#ifndef JERRY_REGEXP_STRICT_MODE
|
||||
#define JERRY_REGEXP_STRICT_MODE 0
|
||||
#endif /* !defined (JERRY_REGEXP_STRICT_MODE) */
|
||||
#define CONFIG_VM_STACK_FRAME_INLINED_VALUES_NUMBER (16)
|
||||
|
||||
/**
|
||||
* Enable/Disable the snapshot execution functions.
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable snapshot execution.
|
||||
* 1: Enable snapshot execution.
|
||||
*
|
||||
* Default value: 0
|
||||
* Run GC after execution of each byte-code instruction
|
||||
*/
|
||||
#ifndef JERRY_SNAPSHOT_EXEC
|
||||
#define JERRY_SNAPSHOT_EXEC 0
|
||||
#endif /* !defined (JERRY_SNAPSHOT_EXEC) */
|
||||
// #define CONFIG_VM_RUN_GC_AFTER_EACH_OPCODE
|
||||
|
||||
/**
|
||||
* Enable/Disable the snapshot save functions.
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable snapshot save functions.
|
||||
* 1: Enable snapshot save functions.
|
||||
* Flag, indicating whether to enable parser-time byte-code optimizations
|
||||
*/
|
||||
#ifndef JERRY_SNAPSHOT_SAVE
|
||||
#define JERRY_SNAPSHOT_SAVE 0
|
||||
#endif /* !defined (JERRY_SNAPSHOT_SAVE) */
|
||||
#define CONFIG_PARSER_ENABLE_PARSE_TIME_BYTE_CODE_OPTIMIZER
|
||||
|
||||
/**
|
||||
* Enable/Disable usage of system allocator.
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable usage of system allocator.
|
||||
* 1: Enable usage of system allocator.
|
||||
*
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_SYSTEM_ALLOCATOR
|
||||
#define JERRY_SYSTEM_ALLOCATOR 0
|
||||
#endif /* !defined (JERRY_SYSTEM_ALLOCATOR) */
|
||||
|
||||
/**
|
||||
* Enables/disables the unicode case conversion in the engine.
|
||||
* By default Unicode case conversion is enabled.
|
||||
*/
|
||||
#ifndef JERRY_UNICODE_CASE_CONVERSION
|
||||
#define JERRY_UNICODE_CASE_CONVERSION 1
|
||||
#endif /* !defined (JERRY_UNICODE_CASE_CONVERSION) */
|
||||
|
||||
/**
|
||||
* Configures if the internal memory allocations are exposed to Valgrind or not.
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable the Valgrind specific memory allocation notifications.
|
||||
* 1: Enable the Valgrind specific allocation notifications.
|
||||
*/
|
||||
#ifndef JERRY_VALGRIND
|
||||
#define JERRY_VALGRIND 0
|
||||
#endif /* !defined (JERRY_VALGRIND) */
|
||||
|
||||
/**
|
||||
* Enable/Disable the vm execution stop callback function.
|
||||
*
|
||||
* Allowed values:
|
||||
* 0: Disable vm exec stop callback support.
|
||||
* 1: Enable vm exec stop callback support.
|
||||
*/
|
||||
#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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Allow configuring attributes on a few constant data inside the engine.
|
||||
*
|
||||
* One of the main usages:
|
||||
* Normally compilers store const(ant)s in ROM. Thus saving RAM.
|
||||
* But if your compiler does not support it then the directive below can force it.
|
||||
*
|
||||
* For the moment it is mainly meant for the following targets:
|
||||
* - ESP8266
|
||||
*
|
||||
* Example configuration for moving (some) constatns into a given section:
|
||||
* # define JERRY_ATTR_CONST_DATA __attribute__((section(".rodata.const")))
|
||||
*/
|
||||
#ifndef JERRY_ATTR_CONST_DATA
|
||||
#define JERRY_ATTR_CONST_DATA
|
||||
#endif /* !defined (JERRY_ATTR_CONST_DATA) */
|
||||
|
||||
/**
|
||||
* The JERRY_ATTR_GLOBAL_HEAP allows adding extra attributes for the Jerry global heap.
|
||||
*
|
||||
* Example on how to move the global heap into it's own section:
|
||||
* #define JERRY_ATTR_GLOBAL_HEAP __attribute__((section(".text.globalheap")))
|
||||
*/
|
||||
#ifndef JERRY_ATTR_GLOBAL_HEAP
|
||||
#define JERRY_ATTR_GLOBAL_HEAP
|
||||
#endif /* !defined (JERRY_ATTR_GLOBAL_HEAP) */
|
||||
|
||||
/**
|
||||
* Sanity check for macros to see if the values are 0 or 1
|
||||
*
|
||||
* If a new feature is added this should be updated.
|
||||
*/
|
||||
/**
|
||||
* Check base builtins.
|
||||
*/
|
||||
#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 (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.
|
||||
*/
|
||||
#if JERRY_BUILTIN_DATE && !JERRY_NUMBER_TYPE_FLOAT64
|
||||
#error "Date does not support float32"
|
||||
#endif /* JERRY_BUILTIN_DATE && !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Source name related types into a single guard
|
||||
*/
|
||||
#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 */
|
||||
#endif /* !CONFIG_H */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,488 +0,0 @@
|
||||
/* 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 DEBUGGER_H
|
||||
#define DEBUGGER_H
|
||||
|
||||
#include "jerryscript-debugger-transport.h"
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if JERRY_DEBUGGER
|
||||
|
||||
/* JerryScript debugger protocol is a simplified version of RFC-6455 (WebSockets). */
|
||||
|
||||
/**
|
||||
* Frequency of calling jerry_debugger_receive() by the VM.
|
||||
*/
|
||||
#define JERRY_DEBUGGER_MESSAGE_FREQUENCY 5
|
||||
|
||||
/**
|
||||
* This constant represents that the string to be sent has no subtype.
|
||||
*/
|
||||
#define JERRY_DEBUGGER_NO_SUBTYPE 0
|
||||
|
||||
/**
|
||||
* Limited resources available for the engine, so it is important to
|
||||
* check the maximum buffer size. It needs to be between 64 and 256 bytes.
|
||||
*/
|
||||
#if JERRY_DEBUGGER_TRANSPORT_MAX_BUFFER_SIZE < 64 || JERRY_DEBUGGER_TRANSPORT_MAX_BUFFER_SIZE > 256
|
||||
#error Please define the MAX_BUFFER_SIZE between 64 and 256 bytes.
|
||||
#endif /* JERRY_DEBUGGER_TRANSPORT_MAX_BUFFER_SIZE < 64 || JERRY_DEBUGGER_TRANSPORT_MAX_BUFFER_SIZE > 256 */
|
||||
|
||||
/**
|
||||
* Calculate the maximum number of items for a given type
|
||||
* which can be transmitted in one message.
|
||||
*/
|
||||
#define JERRY_DEBUGGER_SEND_MAX(type) \
|
||||
((size_t) ((JERRY_CONTEXT (debugger_max_send_size) - sizeof (jerry_debugger_send_type_t)) / sizeof (type)))
|
||||
|
||||
/**
|
||||
* 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)))
|
||||
|
||||
/**
|
||||
* Debugger operation modes:
|
||||
*
|
||||
* The debugger has two operation modes: run mode and breakpoint mode.
|
||||
*
|
||||
* In run mode the debugger server accepts only a limited number of message
|
||||
* types from the debugger client (e.g. stop execution, set breakpoint).
|
||||
*
|
||||
* In breakpoint mode the JavaScript execution is stopped at a breakpoint and
|
||||
* more message types are accepted (e.g. get backtrace, evaluate expression).
|
||||
*
|
||||
* Switching between modes:
|
||||
*
|
||||
* When the JavaScript execution stops at a breakpoint the server sends a
|
||||
* JERRY_DEBUGGER_BREAKPOINT_HIT message to the client. The client can only
|
||||
* issue breakpoint mode commands after this message is received.
|
||||
*
|
||||
* Certain breakpoint mode commands (e.g. continue) resumes the JavaScript
|
||||
* execution and the client must not send any breakpoint mode messages
|
||||
* until the JERRY_DEBUGGER_BREAKPOINT_HIT is received again.
|
||||
*
|
||||
* The debugger server starts in run mode but stops at the first available
|
||||
* breakpoint.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Debugger option flags.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
JERRY_DEBUGGER_CONNECTED = 1u << 0, /**< debugger is connected */
|
||||
JERRY_DEBUGGER_BREAKPOINT_MODE = 1u << 1, /**< debugger waiting at a breakpoint */
|
||||
JERRY_DEBUGGER_VM_STOP = 1u << 2, /**< stop at the next breakpoint even if disabled */
|
||||
JERRY_DEBUGGER_VM_IGNORE = 1u << 3, /**< ignore all breakpoints */
|
||||
JERRY_DEBUGGER_VM_IGNORE_EXCEPTION = 1u << 4, /**< debugger doesn't stop at any exception */
|
||||
JERRY_DEBUGGER_VM_EXCEPTION_THROWN = 1u << 5, /**< no need to stop for this exception */
|
||||
JERRY_DEBUGGER_PARSER_WAIT = 1u << 6, /**< debugger should wait after parsing is completed */
|
||||
JERRY_DEBUGGER_PARSER_WAIT_MODE = 1u << 7, /**< debugger is waiting after parsing is completed */
|
||||
JERRY_DEBUGGER_CLIENT_SOURCE_MODE = 1u << 8, /**< debugger waiting for client code */
|
||||
JERRY_DEBUGGER_CLIENT_NO_SOURCE = 1u << 9, /**< debugger leaving the client source loop */
|
||||
JERRY_DEBUGGER_CONTEXT_RESET_MODE = 1u << 10, /**< debugger and engine reinitialization mode */
|
||||
} jerry_debugger_flags_t;
|
||||
|
||||
/**
|
||||
* Set debugger flags.
|
||||
*/
|
||||
#define JERRY_DEBUGGER_SET_FLAGS(flags) \
|
||||
JERRY_CONTEXT (debugger_flags) = (JERRY_CONTEXT (debugger_flags) | (uint32_t) (flags))
|
||||
|
||||
/**
|
||||
* Clear debugger flags.
|
||||
*/
|
||||
#define JERRY_DEBUGGER_CLEAR_FLAGS(flags) \
|
||||
JERRY_CONTEXT (debugger_flags) = (JERRY_CONTEXT (debugger_flags) & (uint32_t) ~(flags))
|
||||
|
||||
/**
|
||||
* 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))
|
||||
|
||||
/**
|
||||
* Types for the package.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/* Messages sent by the server to client. */
|
||||
/* This is a handshake message, sent once during initialization. */
|
||||
JERRY_DEBUGGER_CONFIGURATION = 1, /**< debugger configuration */
|
||||
/* These messages are sent by the parser. */
|
||||
JERRY_DEBUGGER_PARSE_ERROR = 2, /**< parse error */
|
||||
JERRY_DEBUGGER_BYTE_CODE_CP = 3, /**< byte code compressed pointer */
|
||||
JERRY_DEBUGGER_PARSE_FUNCTION = 4, /**< parsing a new function */
|
||||
JERRY_DEBUGGER_BREAKPOINT_LIST = 5, /**< list of line offsets */
|
||||
JERRY_DEBUGGER_BREAKPOINT_OFFSET_LIST = 6, /**< list of byte code offsets */
|
||||
JERRY_DEBUGGER_SOURCE_CODE = 7, /**< source code fragment */
|
||||
JERRY_DEBUGGER_SOURCE_CODE_END = 8, /**< source code last fragment */
|
||||
JERRY_DEBUGGER_SOURCE_CODE_NAME = 9, /**< source code name fragment */
|
||||
JERRY_DEBUGGER_SOURCE_CODE_NAME_END = 10, /**< source code name last fragment */
|
||||
JERRY_DEBUGGER_FUNCTION_NAME = 11, /**< function name fragment */
|
||||
JERRY_DEBUGGER_FUNCTION_NAME_END = 12, /**< function name last fragment */
|
||||
JERRY_DEBUGGER_WAITING_AFTER_PARSE = 13, /**< engine waiting for a parser resume */
|
||||
/* These messages are generic messages. */
|
||||
JERRY_DEBUGGER_RELEASE_BYTE_CODE_CP = 14, /**< invalidate byte code compressed pointer */
|
||||
JERRY_DEBUGGER_MEMSTATS_RECEIVE = 15, /**< memstats sent to the client */
|
||||
JERRY_DEBUGGER_BREAKPOINT_HIT = 16, /**< notify breakpoint hit */
|
||||
JERRY_DEBUGGER_EXCEPTION_HIT = 17, /**< notify exception hit */
|
||||
JERRY_DEBUGGER_EXCEPTION_STR = 18, /**< exception string fragment */
|
||||
JERRY_DEBUGGER_EXCEPTION_STR_END = 19, /**< exception string last fragment */
|
||||
JERRY_DEBUGGER_BACKTRACE_TOTAL = 20, /**< number of total frames */
|
||||
JERRY_DEBUGGER_BACKTRACE = 21, /**< backtrace data */
|
||||
JERRY_DEBUGGER_BACKTRACE_END = 22, /**< last backtrace data */
|
||||
JERRY_DEBUGGER_EVAL_RESULT = 23, /**< eval result */
|
||||
JERRY_DEBUGGER_EVAL_RESULT_END = 24, /**< last part of eval result */
|
||||
JERRY_DEBUGGER_WAIT_FOR_SOURCE = 25, /**< engine waiting for source code */
|
||||
JERRY_DEBUGGER_OUTPUT_RESULT = 26, /**< output sent by the program to the debugger */
|
||||
JERRY_DEBUGGER_OUTPUT_RESULT_END = 27, /**< last output result data */
|
||||
JERRY_DEBUGGER_SCOPE_CHAIN = 28, /**< scope chain */
|
||||
JERRY_DEBUGGER_SCOPE_CHAIN_END = 29, /**< last output of scope chain */
|
||||
JERRY_DEBUGGER_SCOPE_VARIABLES = 30, /**< scope variables */
|
||||
JERRY_DEBUGGER_SCOPE_VARIABLES_END = 31, /**< last output of scope variables */
|
||||
JERRY_DEBUGGER_CLOSE_CONNECTION = 32, /**< close connection with the client */
|
||||
JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT, /**< number of different type of output messages by the debugger */
|
||||
|
||||
/* Messages sent by the client to server. */
|
||||
|
||||
/* The following messages are accepted in both run and breakpoint modes. */
|
||||
JERRY_DEBUGGER_FREE_BYTE_CODE_CP = 1, /**< free byte code compressed pointer */
|
||||
JERRY_DEBUGGER_UPDATE_BREAKPOINT = 2, /**< update breakpoint status */
|
||||
JERRY_DEBUGGER_EXCEPTION_CONFIG = 3, /**< exception handler config */
|
||||
JERRY_DEBUGGER_PARSER_CONFIG = 4, /**< parser config */
|
||||
JERRY_DEBUGGER_MEMSTATS = 5, /**< list memory statistics */
|
||||
JERRY_DEBUGGER_STOP = 6, /**< stop execution */
|
||||
/* The following message is only available in waiting after parse mode. */
|
||||
JERRY_DEBUGGER_PARSER_RESUME = 7, /**< stop waiting after parse */
|
||||
/* The following four messages are only available in client switch mode. */
|
||||
JERRY_DEBUGGER_CLIENT_SOURCE = 8, /**< first message of client source */
|
||||
JERRY_DEBUGGER_CLIENT_SOURCE_PART = 9, /**< next message of client source */
|
||||
JERRY_DEBUGGER_NO_MORE_SOURCES = 10, /**< no more sources notification */
|
||||
JERRY_DEBUGGER_CONTEXT_RESET = 11, /**< context reset request */
|
||||
/* The following messages are only available in breakpoint
|
||||
* mode and they switch the engine to run mode. */
|
||||
JERRY_DEBUGGER_CONTINUE = 12, /**< continue execution */
|
||||
JERRY_DEBUGGER_STEP = 13, /**< next breakpoint, step into functions */
|
||||
JERRY_DEBUGGER_NEXT = 14, /**< next breakpoint in the same context */
|
||||
JERRY_DEBUGGER_FINISH = 15, /**< Continue running just after the function in the current stack frame returns */
|
||||
/* The following messages are only available in breakpoint
|
||||
* mode and this mode is kept after the message is processed. */
|
||||
JERRY_DEBUGGER_GET_BACKTRACE = 16, /**< get backtrace */
|
||||
JERRY_DEBUGGER_EVAL = 17, /**< first message of evaluating a string */
|
||||
JERRY_DEBUGGER_EVAL_PART = 18, /**< next message of evaluating a string */
|
||||
JERRY_DEBUGGER_GET_SCOPE_CHAIN = 19, /**< get type names of the scope chain */
|
||||
JERRY_DEBUGGER_GET_SCOPE_VARIABLES = 20, /**< get variables of a scope */
|
||||
JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT, /**< number of different type of input messages */
|
||||
} jerry_debugger_header_type_t;
|
||||
|
||||
/**
|
||||
* Debugger option flags.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
JERRY_DEBUGGER_LITTLE_ENDIAN = 1u << 0, /**< little endian */
|
||||
} jerry_debugger_configuration_flags_t;
|
||||
|
||||
/**
|
||||
* Subtypes of eval.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
JERRY_DEBUGGER_EVAL_EVAL = 0, /**< evaluate expression */
|
||||
JERRY_DEBUGGER_EVAL_THROW = 1, /**< evaluate expression and throw the result */
|
||||
JERRY_DEBUGGER_EVAL_ABORT = 2, /**< evaluate expression and abrot with the result */
|
||||
} jerry_debugger_eval_type_t;
|
||||
|
||||
/**
|
||||
* Subtypes of eval_result.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
JERRY_DEBUGGER_EVAL_OK = 1, /**< eval result, no error */
|
||||
JERRY_DEBUGGER_EVAL_ERROR = 2, /**< eval result when an error has occurred */
|
||||
} jerry_debugger_eval_result_type_t;
|
||||
|
||||
/**
|
||||
* Subtypes of output_result.
|
||||
*
|
||||
* Note:
|
||||
* This enum has to be kept in sync with jerry_log_level_t with an offset
|
||||
* of +2.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
JERRY_DEBUGGER_OUTPUT_PRINT = 1, /**< printed output */
|
||||
JERRY_DEBUGGER_OUTPUT_LOG = 2, /**< logged output */
|
||||
} jerry_debugger_output_subtype_t;
|
||||
|
||||
/**
|
||||
* Types of scopes.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
JERRY_DEBUGGER_SCOPE_WITH = 1, /**< with */
|
||||
JERRY_DEBUGGER_SCOPE_LOCAL = 2, /**< local */
|
||||
JERRY_DEBUGGER_SCOPE_CLOSURE = 3, /**< closure */
|
||||
JERRY_DEBUGGER_SCOPE_GLOBAL = 4, /**< global */
|
||||
JERRY_DEBUGGER_SCOPE_NON_CLOSURE = 5 /**< non closure */
|
||||
} jerry_debugger_scope_chain_type_t;
|
||||
|
||||
/**
|
||||
* Type of scope variables.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
JERRY_DEBUGGER_VALUE_NONE = 1,
|
||||
JERRY_DEBUGGER_VALUE_UNDEFINED = 2,
|
||||
JERRY_DEBUGGER_VALUE_NULL = 3,
|
||||
JERRY_DEBUGGER_VALUE_BOOLEAN = 4,
|
||||
JERRY_DEBUGGER_VALUE_NUMBER = 5,
|
||||
JERRY_DEBUGGER_VALUE_STRING = 6,
|
||||
JERRY_DEBUGGER_VALUE_FUNCTION = 7,
|
||||
JERRY_DEBUGGER_VALUE_ARRAY = 8,
|
||||
JERRY_DEBUGGER_VALUE_OBJECT = 9
|
||||
} jerry_debugger_scope_variable_type_t;
|
||||
|
||||
/**
|
||||
* Byte data for evaluating expressions and receiving client source.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t uint8_size; /**< total size of the client source */
|
||||
uint32_t uint8_offset; /**< current offset in the client source */
|
||||
} jerry_debugger_uint8_data_t;
|
||||
|
||||
/**
|
||||
* Delayed free of byte code data.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t size; /**< size of the byte code header divided by JMEM_ALIGNMENT */
|
||||
jmem_cpointer_t prev_cp; /**< previous byte code data to be freed */
|
||||
} jerry_debugger_byte_code_free_t;
|
||||
|
||||
/**
|
||||
* Outgoing message: JerryScript configuration.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
uint8_t configuration; /**< configuration option bits */
|
||||
uint8_t version[sizeof (uint32_t)]; /**< debugger version */
|
||||
uint8_t max_message_size; /**< maximum incoming message size */
|
||||
uint8_t cpointer_size; /**< size of compressed pointers */
|
||||
} jerry_debugger_send_configuration_t;
|
||||
|
||||
/**
|
||||
* Outgoing message: message without arguments.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
} jerry_debugger_send_type_t;
|
||||
|
||||
/**
|
||||
* Incoming message: message without arguments.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
} jerry_debugger_receive_type_t;
|
||||
|
||||
/**
|
||||
* Outgoing message: string (Source file name or function name).
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
uint8_t string[]; /**< string data */
|
||||
} jerry_debugger_send_string_t;
|
||||
|
||||
/**
|
||||
* Outgoing message: uint32 value.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
uint8_t line[sizeof (uint32_t)]; /**< value data */
|
||||
uint8_t column[sizeof (uint32_t)]; /**< value data */
|
||||
} jerry_debugger_send_parse_function_t;
|
||||
|
||||
/**
|
||||
* Outgoing message: byte code compressed pointer.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
uint8_t byte_code_cp[sizeof (jmem_cpointer_t)]; /**< byte code compressed pointer */
|
||||
} jerry_debugger_send_byte_code_cp_t;
|
||||
|
||||
/**
|
||||
* Incoming message: byte code compressed pointer.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
uint8_t byte_code_cp[sizeof (jmem_cpointer_t)]; /**< byte code compressed pointer */
|
||||
} jerry_debugger_receive_byte_code_cp_t;
|
||||
|
||||
/**
|
||||
* Incoming message: update (enable/disable) breakpoint status.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
uint8_t is_set_breakpoint; /**< set or clear breakpoint */
|
||||
uint8_t byte_code_cp[sizeof (jmem_cpointer_t)]; /**< byte code compressed pointer */
|
||||
uint8_t offset[sizeof (uint32_t)]; /**< breakpoint offset */
|
||||
} jerry_debugger_receive_update_breakpoint_t;
|
||||
|
||||
/**
|
||||
* Outgoing message: send memory statistics
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
uint8_t allocated_bytes[sizeof (uint32_t)]; /**< allocated bytes */
|
||||
uint8_t byte_code_bytes[sizeof (uint32_t)]; /**< byte code bytes */
|
||||
uint8_t string_bytes[sizeof (uint32_t)]; /**< string bytes */
|
||||
uint8_t object_bytes[sizeof (uint32_t)]; /**< object bytes */
|
||||
uint8_t property_bytes[sizeof (uint32_t)]; /**< property bytes */
|
||||
} jerry_debugger_send_memstats_t;
|
||||
|
||||
/**
|
||||
* Outgoing message: notify breakpoint hit.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
uint8_t byte_code_cp[sizeof (jmem_cpointer_t)]; /**< byte code compressed pointer */
|
||||
uint8_t offset[sizeof (uint32_t)]; /**< breakpoint offset */
|
||||
} jerry_debugger_send_breakpoint_hit_t;
|
||||
|
||||
/**
|
||||
* Stack frame descriptor for sending backtrace information.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t byte_code_cp[sizeof (jmem_cpointer_t)]; /**< byte code compressed pointer */
|
||||
uint8_t offset[sizeof (uint32_t)]; /**< last breakpoint offset */
|
||||
} jerry_debugger_frame_t;
|
||||
|
||||
/**
|
||||
* Outgoing message: backtrace information.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
jerry_debugger_frame_t frames[]; /**< frames */
|
||||
} jerry_debugger_send_backtrace_t;
|
||||
|
||||
/**
|
||||
* Outgoing message: scope chain.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
uint8_t scope_types[]; /**< scope types */
|
||||
} jerry_debugger_send_scope_chain_t;
|
||||
|
||||
/**
|
||||
* Outgoing message: number of total frames in backtrace.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
uint8_t frame_count[sizeof (uint32_t)]; /**< total number of frames */
|
||||
} jerry_debugger_send_backtrace_total_t;
|
||||
|
||||
/**
|
||||
* Incoming message: set behaviour when exception occures.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
uint8_t enable; /**< non-zero: enable stop at exception */
|
||||
} jerry_debugger_receive_exception_config_t;
|
||||
|
||||
/**
|
||||
* Incoming message: set parser configuration.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
uint8_t enable_wait; /**< non-zero: wait after parsing is completed */
|
||||
} jerry_debugger_receive_parser_config_t;
|
||||
|
||||
/**
|
||||
* Incoming message: get backtrace.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
uint8_t min_depth[sizeof (uint32_t)]; /**< minimum depth*/
|
||||
uint8_t max_depth[sizeof (uint32_t)]; /**< maximum depth (0 - unlimited) */
|
||||
uint8_t get_total_frame_count; /**< non-zero: if total frame count is also requested */
|
||||
} jerry_debugger_receive_get_backtrace_t;
|
||||
|
||||
/**
|
||||
* Incoming message: first message of evaluating expression.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
uint8_t eval_size[sizeof (uint32_t)]; /**< total size of the message */
|
||||
} jerry_debugger_receive_eval_first_t;
|
||||
|
||||
/**
|
||||
* Incoming message: get scope variables
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
uint8_t chain_index[sizeof (uint32_t)]; /**< index element of the scope */
|
||||
} jerry_debugger_receive_get_scope_variables_t;
|
||||
|
||||
/**
|
||||
* Incoming message: first message of client source.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
uint8_t code_size[sizeof (uint32_t)]; /**< total size of the message */
|
||||
} jerry_debugger_receive_client_source_first_t;
|
||||
|
||||
void jerry_debugger_free_unreferenced_byte_code (void);
|
||||
|
||||
bool jerry_debugger_receive (jerry_debugger_uint8_data_t **message_data_p);
|
||||
|
||||
void jerry_debugger_breakpoint_hit (uint8_t message_type);
|
||||
|
||||
void jerry_debugger_send_type (jerry_debugger_header_type_t type);
|
||||
bool jerry_debugger_send_configuration (uint8_t max_message_size);
|
||||
void jerry_debugger_send_data (jerry_debugger_header_type_t type, const void *data, size_t size);
|
||||
bool jerry_debugger_send_string (uint8_t message_type, uint8_t sub_type, const uint8_t *string_p, size_t string_length);
|
||||
bool jerry_debugger_send_function_cp (jerry_debugger_header_type_t type, ecma_compiled_code_t *compiled_code_p);
|
||||
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 /* JERRY_DEBUGGER */
|
||||
|
||||
#endif /* !DEBUGGER_H */
|
||||
@@ -1,4 +1,5 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 University of Szeged.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,20 +15,32 @@
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-lcache.h"
|
||||
#include "jrt.h"
|
||||
#include "jmem-poolman.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);
|
||||
JERRY_STATIC_ASSERT (((sizeof (ecma_property_value_t) - 1) & sizeof (ecma_property_value_t)) == 0,
|
||||
size_of_ecma_property_value_t_must_be_power_of_2);
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_property_pair_t) == sizeof (uint64_t) * 2,
|
||||
size_of_ecma_property_pair_t_must_be_equal_to_16_bytes);
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_extended_object_t) - sizeof (ecma_object_t) <= sizeof (uint64_t),
|
||||
size_of_ecma_extended_object_part_must_be_less_than_or_equal_to_8_bytes);
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_object_t) <= sizeof (uint64_t),
|
||||
size_of_ecma_object_t_must_be_less_than_or_equal_to_8_bytes);
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_extended_object_t) <= sizeof (uint64_t) * 2,
|
||||
size_of_ecma_extended_object_t_must_be_less_than_or_equal_to_16_bytes);
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_collection_header_t) == sizeof (uint64_t),
|
||||
size_of_ecma_collection_header_t_must_be_less_than_or_equal_to_8_bytes);
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_collection_chunk_t) == sizeof (uint64_t),
|
||||
size_of_ecma_collection_chunk_t_must_be_less_than_or_equal_to_8_bytes);
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_string_t) == sizeof (uint64_t),
|
||||
size_of_ecma_string_t_must_be_less_than_or_equal_to_8_bytes);
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_getter_setter_pointers_t) <= sizeof (uint64_t),
|
||||
size_of_ecma_getter_setter_pointers_t_must_be_less_than_or_equal_to_8_bytes);
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -49,220 +62,79 @@ JERRY_STATIC_ASSERT (sizeof (ecma_extended_object_t) - sizeof (ecma_object_t) <=
|
||||
*/
|
||||
|
||||
/**
|
||||
* Allocate memory for ecma-number
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
* Template of an allocation routine.
|
||||
*/
|
||||
extern inline ecma_number_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_number (void)
|
||||
{
|
||||
return (ecma_number_t *) jmem_pools_alloc (sizeof (ecma_number_t));
|
||||
} /* ecma_alloc_number */
|
||||
#define ALLOC(ecma_type) ecma_ ## ecma_type ## _t * \
|
||||
ecma_alloc_ ## ecma_type (void) \
|
||||
{ \
|
||||
ecma_ ## ecma_type ## _t *p ## ecma_type = (ecma_ ## ecma_type ## _t *) jmem_pools_alloc (); \
|
||||
\
|
||||
JERRY_ASSERT (p ## ecma_type != NULL); \
|
||||
\
|
||||
return p ## ecma_type; \
|
||||
}
|
||||
|
||||
/**
|
||||
* Dealloc memory from an ecma-number
|
||||
* Deallocation routine template
|
||||
*/
|
||||
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));
|
||||
} /* ecma_dealloc_number */
|
||||
#define DEALLOC(ecma_type) void \
|
||||
ecma_dealloc_ ## ecma_type (ecma_ ## ecma_type ## _t *p ## ecma_type) \
|
||||
{ \
|
||||
jmem_pools_free ((uint8_t *) p ## ecma_type); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate memory for ecma-object
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
* Declaration of alloc/free routine for specified ecma-type.
|
||||
*/
|
||||
extern inline ecma_object_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_object (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_allocate_object_bytes (sizeof (ecma_object_t));
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
#define DECLARE_ROUTINES_FOR(ecma_type) \
|
||||
ALLOC (ecma_type) \
|
||||
DEALLOC (ecma_type)
|
||||
|
||||
return (ecma_object_t *) jmem_pools_alloc (sizeof (ecma_object_t));
|
||||
} /* ecma_alloc_object */
|
||||
|
||||
/**
|
||||
* Dealloc memory from an ecma-object
|
||||
*/
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_dealloc_object (ecma_object_t *object_p) /**< object to be freed */
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_free_object_bytes (sizeof (ecma_object_t));
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
jmem_pools_free (object_p, sizeof (ecma_object_t));
|
||||
} /* ecma_dealloc_object */
|
||||
DECLARE_ROUTINES_FOR (object)
|
||||
DECLARE_ROUTINES_FOR (number)
|
||||
DECLARE_ROUTINES_FOR (collection_header)
|
||||
DECLARE_ROUTINES_FOR (collection_chunk)
|
||||
DECLARE_ROUTINES_FOR (string)
|
||||
DECLARE_ROUTINES_FOR (getter_setter_pointers)
|
||||
DECLARE_ROUTINES_FOR (external_pointer)
|
||||
|
||||
/**
|
||||
* Allocate memory for extended object
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_extended_object_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_extended_object (size_t size) /**< size of object */
|
||||
inline ecma_extended_object_t * __attr_always_inline___
|
||||
ecma_alloc_extended_object (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_allocate_object_bytes (size);
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
return jmem_heap_alloc_block (size);
|
||||
return jmem_heap_alloc_block (sizeof (ecma_extended_object_t));
|
||||
} /* ecma_alloc_extended_object */
|
||||
|
||||
/**
|
||||
* Dealloc memory of an extended object
|
||||
*/
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_dealloc_extended_object (ecma_object_t *object_p, /**< extended object */
|
||||
size_t size) /**< size of object */
|
||||
inline void __attr_always_inline___
|
||||
ecma_dealloc_extended_object (ecma_extended_object_t *ext_object_p) /**< property pair to be freed */
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_free_object_bytes (size);
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
jmem_heap_free_block (object_p, size);
|
||||
jmem_heap_free_block (ext_object_p, sizeof (ecma_extended_object_t));
|
||||
} /* ecma_dealloc_extended_object */
|
||||
|
||||
/**
|
||||
* Allocate memory for ecma-string descriptor
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_string (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_allocate_string_bytes (sizeof (ecma_string_t));
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
return (ecma_string_t *) jmem_pools_alloc (sizeof (ecma_string_t));
|
||||
} /* ecma_alloc_string */
|
||||
|
||||
/**
|
||||
* Dealloc memory from ecma-string descriptor
|
||||
*/
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_dealloc_string (ecma_string_t *string_p) /**< string to be freed */
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_free_string_bytes (sizeof (ecma_string_t));
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
jmem_pools_free (string_p, sizeof (ecma_string_t));
|
||||
} /* ecma_dealloc_string */
|
||||
|
||||
/**
|
||||
* Allocate memory for extended ecma-string descriptor
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_extended_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_extended_string (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_allocate_string_bytes (sizeof (ecma_extended_string_t));
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
return (ecma_extended_string_t *) jmem_heap_alloc_block (sizeof (ecma_extended_string_t));
|
||||
} /* ecma_alloc_extended_string */
|
||||
|
||||
/**
|
||||
* Dealloc memory from extended ecma-string descriptor
|
||||
*/
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_dealloc_extended_string (ecma_extended_string_t *ext_string_p) /**< extended string to be freed */
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_free_string_bytes (sizeof (ecma_extended_string_t));
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
jmem_heap_free_block (ext_string_p, sizeof (ecma_extended_string_t));
|
||||
} /* ecma_dealloc_extended_string */
|
||||
|
||||
/**
|
||||
* Allocate memory for external ecma-string descriptor
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_external_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_external_string (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_allocate_string_bytes (sizeof (ecma_external_string_t));
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
return (ecma_external_string_t *) jmem_heap_alloc_block (sizeof (ecma_external_string_t));
|
||||
} /* ecma_alloc_external_string */
|
||||
|
||||
/**
|
||||
* Dealloc memory from external ecma-string descriptor
|
||||
*/
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_dealloc_external_string (ecma_external_string_t *ext_string_p) /**< external string to be freed */
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_free_string_bytes (sizeof (ecma_external_string_t));
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
jmem_heap_free_block (ext_string_p, sizeof (ecma_external_string_t));
|
||||
} /* ecma_dealloc_external_string */
|
||||
|
||||
/**
|
||||
* Allocate memory for an string with character data
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_string_buffer (size_t size) /**< size of string */
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_allocate_string_bytes (size);
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
return jmem_heap_alloc_block (size);
|
||||
} /* ecma_alloc_string_buffer */
|
||||
|
||||
/**
|
||||
* Dealloc memory of a string with character data
|
||||
*/
|
||||
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 JERRY_MEM_STATS
|
||||
jmem_stats_free_string_bytes (size);
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
jmem_heap_free_block (string_p, size);
|
||||
} /* ecma_dealloc_string_buffer */
|
||||
|
||||
/**
|
||||
* Allocate memory for ecma-property pair
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_property_pair_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
inline ecma_property_pair_t * __attr_always_inline___
|
||||
ecma_alloc_property_pair (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_allocate_property_bytes (sizeof (ecma_property_pair_t));
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
return jmem_heap_alloc_block (sizeof (ecma_property_pair_t));
|
||||
} /* ecma_alloc_property_pair */
|
||||
|
||||
/**
|
||||
* Dealloc memory of an ecma-property
|
||||
*/
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
inline void __attr_always_inline___
|
||||
ecma_dealloc_property_pair (ecma_property_pair_t *property_pair_p) /**< property pair to be freed */
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_free_property_bytes (sizeof (ecma_property_pair_t));
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
jmem_heap_free_block (property_pair_p, sizeof (ecma_property_pair_t));
|
||||
} /* ecma_dealloc_property_pair */
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,96 +30,108 @@
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
ecma_object_t *ecma_alloc_object (void);
|
||||
extern ecma_object_t *ecma_alloc_object (void);
|
||||
|
||||
/**
|
||||
* Dealloc memory from an ecma-object
|
||||
*/
|
||||
void ecma_dealloc_object (ecma_object_t *object_p);
|
||||
|
||||
/**
|
||||
* Allocate memory for extended object
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
ecma_extended_object_t *ecma_alloc_extended_object (size_t size);
|
||||
|
||||
/**
|
||||
* Dealloc memory of an extended object
|
||||
*/
|
||||
void ecma_dealloc_extended_object (ecma_object_t *object_p, size_t size);
|
||||
extern void ecma_dealloc_object (ecma_object_t *);
|
||||
|
||||
/**
|
||||
* Allocate memory for ecma-number
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
ecma_number_t *ecma_alloc_number (void);
|
||||
extern ecma_number_t *ecma_alloc_number (void);
|
||||
|
||||
/**
|
||||
* Dealloc memory from an ecma-number
|
||||
*/
|
||||
void ecma_dealloc_number (ecma_number_t *number_p);
|
||||
extern void ecma_dealloc_number (ecma_number_t *);
|
||||
|
||||
/**
|
||||
* Allocate memory for header of a collection
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern ecma_collection_header_t *ecma_alloc_collection_header (void);
|
||||
|
||||
/**
|
||||
* Dealloc memory from the collection's header
|
||||
*/
|
||||
extern void ecma_dealloc_collection_header (ecma_collection_header_t *);
|
||||
|
||||
/**
|
||||
* Allocate memory for non-first chunk of a collection
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern ecma_collection_chunk_t *ecma_alloc_collection_chunk (void);
|
||||
|
||||
/**
|
||||
* Dealloc memory from non-first chunk of a collection
|
||||
*/
|
||||
extern void ecma_dealloc_collection_chunk (ecma_collection_chunk_t *);
|
||||
|
||||
/**
|
||||
* Allocate memory for ecma-string descriptor
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
ecma_string_t *ecma_alloc_string (void);
|
||||
extern ecma_string_t *ecma_alloc_string (void);
|
||||
|
||||
/**
|
||||
* Dealloc memory from ecma-string descriptor
|
||||
*/
|
||||
void ecma_dealloc_string (ecma_string_t *string_p);
|
||||
extern void ecma_dealloc_string (ecma_string_t *);
|
||||
|
||||
/**
|
||||
* Allocate memory for extended ecma-string descriptor
|
||||
* Allocate memory for getter-setter pointer pair
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
ecma_extended_string_t *ecma_alloc_extended_string (void);
|
||||
extern ecma_getter_setter_pointers_t *ecma_alloc_getter_setter_pointers (void);
|
||||
|
||||
/**
|
||||
* Dealloc memory from extended ecma-string descriptor
|
||||
* Dealloc memory from getter-setter pointer pair
|
||||
*/
|
||||
void ecma_dealloc_extended_string (ecma_extended_string_t *string_p);
|
||||
extern void ecma_dealloc_getter_setter_pointers (ecma_getter_setter_pointers_t *);
|
||||
|
||||
/**
|
||||
* Allocate memory for external ecma-string descriptor
|
||||
* Allocate memory for external pointer
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern ecma_external_pointer_t *ecma_alloc_external_pointer (void);
|
||||
|
||||
/**
|
||||
* Dealloc memory from external pointer
|
||||
*/
|
||||
extern void ecma_dealloc_external_pointer (ecma_external_pointer_t *);
|
||||
|
||||
/*
|
||||
* Allocate memory for extended object
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
ecma_external_string_t *ecma_alloc_external_string (void);
|
||||
extern ecma_extended_object_t *ecma_alloc_extended_object (void);
|
||||
|
||||
/**
|
||||
* Dealloc memory from external ecma-string descriptor
|
||||
* Dealloc memory of an extended object
|
||||
*/
|
||||
void ecma_dealloc_external_string (ecma_external_string_t *string_p);
|
||||
|
||||
/**
|
||||
* Allocate memory for string with character data
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
ecma_string_t *ecma_alloc_string_buffer (size_t size);
|
||||
|
||||
/**
|
||||
* Dealloc memory of a string with character data
|
||||
*/
|
||||
void ecma_dealloc_string_buffer (ecma_string_t *string_p, size_t size);
|
||||
extern void ecma_dealloc_extended_object (ecma_extended_object_t *);
|
||||
|
||||
/**
|
||||
* Allocate memory for ecma-property pair
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
ecma_property_pair_t *ecma_alloc_property_pair (void);
|
||||
extern ecma_property_pair_t *ecma_alloc_property_pair (void);
|
||||
|
||||
/**
|
||||
* Dealloc memory from an ecma-property pair
|
||||
*/
|
||||
void ecma_dealloc_property_pair (ecma_property_pair_t *property_pair_p);
|
||||
extern void ecma_dealloc_property_pair (ecma_property_pair_t *);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -1,759 +0,0 @@
|
||||
/* 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")
|
||||
@@ -1,330 +0,0 @@
|
||||
# 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"
|
||||
@@ -1,71 +0,0 @@
|
||||
/* 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 */
|
||||
@@ -1,39 +0,0 @@
|
||||
/* 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 */
|
||||
@@ -1,144 +0,0 @@
|
||||
/* 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 */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
@@ -1,54 +0,0 @@
|
||||
/* 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 */
|
||||
+412
-2148
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,8 +17,7 @@
|
||||
#define ECMA_GC_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
#include "jmem-allocator.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -27,24 +26,11 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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_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);
|
||||
extern void ecma_init_gc_info (ecma_object_t *);
|
||||
extern void ecma_ref_object (ecma_object_t *);
|
||||
extern void ecma_deref_object (ecma_object_t *);
|
||||
extern void ecma_gc_run (jmem_free_unused_memory_severity_t);
|
||||
extern void ecma_free_unused_memory (jmem_free_unused_memory_severity_t);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
+485
-1776
File diff suppressed because it is too large
Load Diff
@@ -1,444 +0,0 @@
|
||||
/* 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-conversion.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmahelpers Helpers for operations with ECMA data types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Allocate a collection of ecma values.
|
||||
*
|
||||
* @return pointer to the collection
|
||||
*/
|
||||
ecma_collection_t *
|
||||
ecma_new_collection (void)
|
||||
{
|
||||
ecma_collection_t *collection_p;
|
||||
collection_p = (ecma_collection_t *) jmem_heap_alloc_block (sizeof (ecma_collection_t));
|
||||
|
||||
collection_p->item_count = 0;
|
||||
collection_p->capacity = ECMA_COLLECTION_INITIAL_CAPACITY;
|
||||
const uint32_t size = ECMA_COLLECTION_ALLOCATED_SIZE (ECMA_COLLECTION_INITIAL_CAPACITY);
|
||||
collection_p->buffer_p = (ecma_value_t *) jmem_heap_alloc_block (size);
|
||||
|
||||
return collection_p;
|
||||
} /* ecma_new_collection */
|
||||
|
||||
/**
|
||||
* Deallocate a collection of ecma values without freeing it's values
|
||||
*/
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_collection_destroy (ecma_collection_t *collection_p) /**< value collection */
|
||||
{
|
||||
JERRY_ASSERT (collection_p != NULL);
|
||||
|
||||
jmem_heap_free_block (collection_p->buffer_p, ECMA_COLLECTION_ALLOCATED_SIZE (collection_p->capacity));
|
||||
jmem_heap_free_block (collection_p, sizeof (ecma_collection_t));
|
||||
} /* ecma_collection_destroy */
|
||||
|
||||
/**
|
||||
* Free the object collection elements and deallocate the collection
|
||||
*/
|
||||
void
|
||||
ecma_collection_free_objects (ecma_collection_t *collection_p) /**< value collection */
|
||||
{
|
||||
JERRY_ASSERT (collection_p != NULL);
|
||||
|
||||
ecma_value_t *buffer_p = collection_p->buffer_p;
|
||||
|
||||
for (uint32_t i = 0; i < collection_p->item_count; i++)
|
||||
{
|
||||
if (ecma_is_value_object (buffer_p[i]))
|
||||
{
|
||||
ecma_deref_object (ecma_get_object_from_value (buffer_p[i]));
|
||||
}
|
||||
}
|
||||
|
||||
ecma_collection_destroy (collection_p);
|
||||
} /* ecma_collection_free_objects */
|
||||
|
||||
/**
|
||||
* Free the template literal objects and deallocate the collection
|
||||
*/
|
||||
void
|
||||
ecma_collection_free_template_literal (ecma_collection_t *collection_p) /**< value collection */
|
||||
{
|
||||
for (uint32_t i = 0; i < collection_p->item_count; i++)
|
||||
{
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (collection_p->buffer_p[i]);
|
||||
|
||||
JERRY_ASSERT (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_ARRAY);
|
||||
|
||||
ecma_extended_object_t *array_object_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
JERRY_ASSERT (array_object_p->u.array.length_prop_and_hole_count & ECMA_ARRAY_TEMPLATE_LITERAL);
|
||||
array_object_p->u.array.length_prop_and_hole_count &= (uint32_t) ~ECMA_ARRAY_TEMPLATE_LITERAL;
|
||||
|
||||
ecma_property_value_t *property_value_p;
|
||||
|
||||
property_value_p = ecma_get_named_data_property (object_p, ecma_get_magic_string (LIT_MAGIC_STRING_RAW));
|
||||
ecma_object_t *raw_object_p = ecma_get_object_from_value (property_value_p->value);
|
||||
|
||||
JERRY_ASSERT (ecma_get_object_type (raw_object_p) == ECMA_OBJECT_TYPE_ARRAY);
|
||||
|
||||
array_object_p = (ecma_extended_object_t *) raw_object_p;
|
||||
|
||||
JERRY_ASSERT (array_object_p->u.array.length_prop_and_hole_count & ECMA_ARRAY_TEMPLATE_LITERAL);
|
||||
array_object_p->u.array.length_prop_and_hole_count &= (uint32_t) ~ECMA_ARRAY_TEMPLATE_LITERAL;
|
||||
|
||||
ecma_deref_object (raw_object_p);
|
||||
ecma_deref_object (object_p);
|
||||
}
|
||||
|
||||
ecma_collection_destroy (collection_p);
|
||||
} /* ecma_collection_free_template_literal */
|
||||
|
||||
/**
|
||||
* Free the non-object collection elements and deallocate the collection
|
||||
*/
|
||||
void
|
||||
ecma_collection_free_if_not_object (ecma_collection_t *collection_p) /**< value collection */
|
||||
{
|
||||
JERRY_ASSERT (collection_p != NULL);
|
||||
|
||||
ecma_value_t *buffer_p = collection_p->buffer_p;
|
||||
|
||||
for (uint32_t i = 0; i < collection_p->item_count; i++)
|
||||
{
|
||||
ecma_free_value_if_not_object (buffer_p[i]);
|
||||
}
|
||||
|
||||
ecma_collection_destroy (collection_p);
|
||||
} /* ecma_collection_free_if_not_object */
|
||||
|
||||
/**
|
||||
* Free the collection elements and deallocate the collection
|
||||
*/
|
||||
void
|
||||
ecma_collection_free (ecma_collection_t *collection_p) /**< value collection */
|
||||
{
|
||||
JERRY_ASSERT (collection_p != NULL);
|
||||
|
||||
ecma_value_t *buffer_p = collection_p->buffer_p;
|
||||
|
||||
for (uint32_t i = 0; i < collection_p->item_count; i++)
|
||||
{
|
||||
ecma_free_value (buffer_p[i]);
|
||||
}
|
||||
|
||||
ecma_collection_destroy (collection_p);
|
||||
} /* ecma_collection_free */
|
||||
|
||||
/**
|
||||
* Append new value to ecma values collection
|
||||
*
|
||||
* Note: The reference count of the values are not increased
|
||||
*/
|
||||
void
|
||||
ecma_collection_push_back (ecma_collection_t *collection_p, /**< value collection */
|
||||
ecma_value_t value) /**< ecma value to append */
|
||||
{
|
||||
JERRY_ASSERT (collection_p != NULL);
|
||||
|
||||
ecma_value_t *buffer_p = collection_p->buffer_p;
|
||||
|
||||
if (JERRY_LIKELY (collection_p->item_count < collection_p->capacity))
|
||||
{
|
||||
buffer_p[collection_p->item_count++] = value;
|
||||
return;
|
||||
}
|
||||
|
||||
const uint32_t new_capacity = collection_p->capacity + ECMA_COLLECTION_GROW_FACTOR;
|
||||
const uint32_t old_size = ECMA_COLLECTION_ALLOCATED_SIZE (collection_p->capacity);
|
||||
const uint32_t new_size = ECMA_COLLECTION_ALLOCATED_SIZE (new_capacity);
|
||||
|
||||
buffer_p = jmem_heap_realloc_block (buffer_p, old_size, new_size);
|
||||
buffer_p[collection_p->item_count++] = value;
|
||||
collection_p->capacity = new_capacity;
|
||||
|
||||
collection_p->buffer_p = buffer_p;
|
||||
} /* ecma_collection_push_back */
|
||||
|
||||
/**
|
||||
* Reserve space for the given amount of ecma_values in the collection
|
||||
*/
|
||||
void
|
||||
ecma_collection_reserve (ecma_collection_t *collection_p, /**< value collection */
|
||||
uint32_t count) /**< number of ecma values to reserve */
|
||||
{
|
||||
JERRY_ASSERT (collection_p != NULL);
|
||||
JERRY_ASSERT (UINT32_MAX - count > collection_p->capacity);
|
||||
|
||||
const uint32_t new_capacity = collection_p->capacity + count;
|
||||
const uint32_t old_size = ECMA_COLLECTION_ALLOCATED_SIZE (collection_p->capacity);
|
||||
const uint32_t new_size = ECMA_COLLECTION_ALLOCATED_SIZE (new_capacity);
|
||||
|
||||
ecma_value_t *buffer_p = collection_p->buffer_p;
|
||||
buffer_p = jmem_heap_realloc_block (buffer_p, old_size, new_size);
|
||||
|
||||
collection_p->capacity = new_capacity;
|
||||
collection_p->buffer_p = buffer_p;
|
||||
} /* ecma_collection_reserve */
|
||||
|
||||
/**
|
||||
* Append a list of values to the end of the collection
|
||||
*/
|
||||
void
|
||||
ecma_collection_append (ecma_collection_t *collection_p, /**< value collection */
|
||||
const ecma_value_t *buffer_p, /**< values to append */
|
||||
uint32_t count) /**< number of ecma values to append */
|
||||
{
|
||||
JERRY_ASSERT (collection_p != NULL);
|
||||
JERRY_ASSERT (collection_p->capacity >= collection_p->item_count);
|
||||
|
||||
uint32_t free_count = collection_p->capacity - collection_p->item_count;
|
||||
|
||||
if (free_count < count)
|
||||
{
|
||||
ecma_collection_reserve (collection_p, count - free_count);
|
||||
}
|
||||
|
||||
memcpy (collection_p->buffer_p + collection_p->item_count, buffer_p, count * sizeof (ecma_value_t));
|
||||
collection_p->item_count += count;
|
||||
} /* ecma_collection_append */
|
||||
|
||||
/**
|
||||
* Helper function to check if a given collection have duplicated properties or not
|
||||
*
|
||||
* @return true - if there are duplicated properties in the collection
|
||||
* false - otherwise
|
||||
*/
|
||||
bool
|
||||
ecma_collection_check_duplicated_entries (ecma_collection_t *collection_p) /**< prop name collection */
|
||||
{
|
||||
if (collection_p->item_count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ecma_value_t *buffer_p = collection_p->buffer_p;
|
||||
|
||||
for (uint32_t i = 0; i < collection_p->item_count - 1; i++)
|
||||
{
|
||||
ecma_string_t *current_name_p = ecma_get_prop_name_from_value (buffer_p[i]);
|
||||
|
||||
for (uint32_t j = i + 1; j < collection_p->item_count; j++)
|
||||
{
|
||||
if (ecma_compare_ecma_strings (current_name_p, ecma_get_prop_name_from_value (buffer_p[j])))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} /* ecma_collection_check_duplicated_entries */
|
||||
|
||||
/**
|
||||
* Check the string value existance in the collection.
|
||||
*
|
||||
* Used by:
|
||||
* - ecma_builtin_json_stringify step 4.b.ii.5
|
||||
* - ecma_op_object_enumerate
|
||||
*
|
||||
* @return true, if the string is already in the collection.
|
||||
*/
|
||||
bool
|
||||
ecma_collection_has_string_value (ecma_collection_t *collection_p, /**< collection */
|
||||
ecma_string_t *string_p) /**< string */
|
||||
{
|
||||
ecma_value_t *buffer_p = collection_p->buffer_p;
|
||||
|
||||
for (uint32_t i = 0; i < collection_p->item_count; i++)
|
||||
{
|
||||
ecma_string_t *current_p = ecma_get_string_from_value (buffer_p[i]);
|
||||
|
||||
if (ecma_compare_ecma_strings (current_p, string_p))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} /* ecma_collection_has_string_value */
|
||||
|
||||
/**
|
||||
* Initial capacity of an ecma-collection
|
||||
*/
|
||||
#define ECMA_COMPACT_COLLECTION_GROWTH 8
|
||||
|
||||
/**
|
||||
* Set the size of the compact collection
|
||||
*/
|
||||
#define ECMA_COMPACT_COLLECTION_SET_SIZE(compact_collection_p, item_count, unused_items) \
|
||||
((compact_collection_p)[0] = (((item_count) << ECMA_COMPACT_COLLECTION_SIZE_SHIFT) | (unused_items)))
|
||||
|
||||
/**
|
||||
* Set the size of the compact collection
|
||||
*/
|
||||
#define ECMA_COMPACT_COLLECTION_GET_UNUSED_ITEM_COUNT(compact_collection_p) \
|
||||
((compact_collection_p)[0] & ((1 << ECMA_COMPACT_COLLECTION_SIZE_SHIFT) - 1))
|
||||
|
||||
/**
|
||||
* Allocate a compact collection of ecma values
|
||||
*
|
||||
* @return pointer to the compact collection
|
||||
*/
|
||||
ecma_value_t *
|
||||
ecma_new_compact_collection (void)
|
||||
{
|
||||
size_t size = (ECMA_COMPACT_COLLECTION_GROWTH / 2) * sizeof (ecma_value_t);
|
||||
ecma_value_t *compact_collection_p = (ecma_value_t *) jmem_heap_alloc_block (size);
|
||||
|
||||
ECMA_COMPACT_COLLECTION_SET_SIZE (compact_collection_p,
|
||||
ECMA_COMPACT_COLLECTION_GROWTH / 2,
|
||||
(ECMA_COMPACT_COLLECTION_GROWTH / 2) - 1);
|
||||
return compact_collection_p;
|
||||
} /* ecma_new_compact_collection */
|
||||
|
||||
/**
|
||||
* Append a value to the compact collection
|
||||
*
|
||||
* @return updated pointer to the compact collection
|
||||
*/
|
||||
ecma_value_t *
|
||||
ecma_compact_collection_push_back (ecma_value_t *compact_collection_p, /**< compact collection */
|
||||
ecma_value_t value) /**< ecma value to append */
|
||||
{
|
||||
ecma_value_t size = ECMA_COMPACT_COLLECTION_GET_SIZE (compact_collection_p);
|
||||
ecma_value_t unused_items = ECMA_COMPACT_COLLECTION_GET_UNUSED_ITEM_COUNT (compact_collection_p);
|
||||
|
||||
if (unused_items > 0)
|
||||
{
|
||||
compact_collection_p[size - unused_items] = value;
|
||||
(*compact_collection_p)--;
|
||||
return compact_collection_p;
|
||||
}
|
||||
|
||||
if (size == ECMA_COMPACT_COLLECTION_GROWTH / 2)
|
||||
{
|
||||
size_t old_size = (ECMA_COMPACT_COLLECTION_GROWTH / 2) * sizeof (ecma_value_t);
|
||||
size_t new_size = ECMA_COMPACT_COLLECTION_GROWTH * sizeof (ecma_value_t);
|
||||
compact_collection_p = jmem_heap_realloc_block (compact_collection_p, old_size, new_size);
|
||||
|
||||
compact_collection_p[ECMA_COMPACT_COLLECTION_GROWTH / 2] = value;
|
||||
|
||||
ECMA_COMPACT_COLLECTION_SET_SIZE (compact_collection_p,
|
||||
ECMA_COMPACT_COLLECTION_GROWTH,
|
||||
(ECMA_COMPACT_COLLECTION_GROWTH / 2) - 1);
|
||||
return compact_collection_p;
|
||||
}
|
||||
|
||||
size_t old_size = size * sizeof (ecma_value_t);
|
||||
size_t new_size = old_size + (ECMA_COMPACT_COLLECTION_GROWTH * sizeof (ecma_value_t));
|
||||
|
||||
compact_collection_p = jmem_heap_realloc_block (compact_collection_p, old_size, new_size);
|
||||
compact_collection_p[size] = value;
|
||||
|
||||
ECMA_COMPACT_COLLECTION_SET_SIZE (compact_collection_p,
|
||||
size + ECMA_COMPACT_COLLECTION_GROWTH,
|
||||
ECMA_COMPACT_COLLECTION_GROWTH - 1);
|
||||
return compact_collection_p;
|
||||
} /* ecma_compact_collection_push_back */
|
||||
|
||||
/**
|
||||
* Discard the unused elements of a compact collection
|
||||
*
|
||||
* Note:
|
||||
* further items should not be added after this call
|
||||
*
|
||||
* @return updated pointer to the compact collection
|
||||
*/
|
||||
ecma_value_t *
|
||||
ecma_compact_collection_shrink (ecma_value_t *compact_collection_p) /**< compact collection */
|
||||
{
|
||||
ecma_value_t unused_items = ECMA_COMPACT_COLLECTION_GET_UNUSED_ITEM_COUNT (compact_collection_p);
|
||||
|
||||
if (unused_items == 0)
|
||||
{
|
||||
return compact_collection_p;
|
||||
}
|
||||
|
||||
ecma_value_t size = ECMA_COMPACT_COLLECTION_GET_SIZE (compact_collection_p);
|
||||
|
||||
size_t old_size = size * sizeof (ecma_value_t);
|
||||
size_t new_size = (size - unused_items) * sizeof (ecma_value_t);
|
||||
|
||||
compact_collection_p = jmem_heap_realloc_block (compact_collection_p, old_size, new_size);
|
||||
|
||||
ECMA_COMPACT_COLLECTION_SET_SIZE (compact_collection_p, size - unused_items, 0);
|
||||
return compact_collection_p;
|
||||
} /* ecma_compact_collection_shrink */
|
||||
|
||||
/**
|
||||
* Free a compact collection
|
||||
*/
|
||||
void
|
||||
ecma_compact_collection_free (ecma_value_t *compact_collection_p) /**< compact collection */
|
||||
{
|
||||
ecma_value_t size = ECMA_COMPACT_COLLECTION_GET_SIZE (compact_collection_p);
|
||||
ecma_value_t unused_items = ECMA_COMPACT_COLLECTION_GET_UNUSED_ITEM_COUNT (compact_collection_p);
|
||||
|
||||
ecma_value_t *end_p = compact_collection_p + size - unused_items;
|
||||
ecma_value_t *current_p = compact_collection_p + 1;
|
||||
|
||||
while (current_p < end_p)
|
||||
{
|
||||
ecma_free_value (*current_p++);
|
||||
}
|
||||
|
||||
jmem_heap_free_block (compact_collection_p, size * sizeof (ecma_value_t));
|
||||
} /* ecma_compact_collection_free */
|
||||
|
||||
/**
|
||||
* 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
@@ -1,4 +1,5 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
/* Copyright 2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 University of Szeged
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,6 +39,7 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -54,17 +56,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Floating point format definitions (next float value)
|
||||
* Floating point format definitions
|
||||
*/
|
||||
#define ECMA_NEXT_FLOAT(value) (nextafter ((value), INFINITY))
|
||||
/**
|
||||
* Floating point format definitions (previous float value)
|
||||
*/
|
||||
#define ECMA_PREV_FLOAT(value) (nextafter ((value), -INFINITY))
|
||||
|
||||
/**
|
||||
* Value of epsilon
|
||||
*/
|
||||
#define ERROL0_EPSILON 0.0000001
|
||||
|
||||
/**
|
||||
@@ -79,7 +75,7 @@ typedef struct
|
||||
/**
|
||||
* Normalize the number by factoring in the error.
|
||||
*/
|
||||
static inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
static inline void __attr_always_inline___
|
||||
ecma_normalize_high_prec_data (ecma_high_prec_t *hp_data_p) /**< [in, out] float pair */
|
||||
{
|
||||
double val = hp_data_p->value;
|
||||
@@ -91,7 +87,7 @@ ecma_normalize_high_prec_data (ecma_high_prec_t *hp_data_p) /**< [in, out] float
|
||||
/**
|
||||
* Multiply the high-precision number by ten.
|
||||
*/
|
||||
static inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
static inline void __attr_always_inline___
|
||||
ecma_multiply_high_prec_by_10 (ecma_high_prec_t *hp_data_p) /**< [in, out] high-precision number */
|
||||
{
|
||||
double value = hp_data_p->value;
|
||||
@@ -133,13 +129,13 @@ ecma_divide_high_prec_by_10 (ecma_high_prec_t *hp_data_p) /**< [in, out] high-pr
|
||||
*
|
||||
* @return number of generated digits
|
||||
*/
|
||||
extern inline lit_utf8_size_t JERRY_ATTR_ALWAYS_INLINE
|
||||
inline lit_utf8_size_t __attr_always_inline___
|
||||
ecma_errol0_dtoa (double val, /**< ecma number */
|
||||
lit_utf8_byte_t *buffer_p, /**< buffer to generate digits into */
|
||||
int32_t *exp_p) /**< [out] exponent */
|
||||
{
|
||||
double power_of_10 = 1.0;
|
||||
int32_t exponent = 1;
|
||||
int32_t exp = 1;
|
||||
|
||||
/* normalize the midpoint */
|
||||
ecma_high_prec_t mid;
|
||||
@@ -147,16 +143,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))) && (exponent < 308))
|
||||
while (((mid.value > 10.0) || ((mid.value == 10.0) && (mid.offset >= 0.0))) && (exp < 308))
|
||||
{
|
||||
exponent++;
|
||||
exp++;
|
||||
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))) && (exponent > -307))
|
||||
while (((mid.value < 1.0) || ((mid.value == 1.0) && (mid.offset < 0.0))) && (exp > -307))
|
||||
{
|
||||
exponent--;
|
||||
exp--;
|
||||
ecma_multiply_high_prec_by_10 (&mid);
|
||||
power_of_10 *= 10.0;
|
||||
}
|
||||
@@ -181,14 +177,14 @@ ecma_errol0_dtoa (double val, /**< ecma number */
|
||||
|
||||
while (high_bound.value > 10.0 || (high_bound.value == 10.0 && (high_bound.offset >= 0.0)))
|
||||
{
|
||||
exponent++;
|
||||
exp++;
|
||||
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)))
|
||||
{
|
||||
exponent--;
|
||||
exp--;
|
||||
ecma_multiply_high_prec_by_10 (&high_bound);
|
||||
ecma_multiply_high_prec_by_10 (&low_bound);
|
||||
}
|
||||
@@ -230,7 +226,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 = exponent;
|
||||
*exp_p = exp;
|
||||
|
||||
return (lit_utf8_size_t) (dst_p - buffer_p);
|
||||
} /* ecma_errol0_dtoa */
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
/* Copyright 2015-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 University of Szeged.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,11 +15,8 @@
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects-general.h"
|
||||
#include "ecma-objects.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -28,305 +26,141 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a native pointer property to store the native pointer and its type info.
|
||||
*
|
||||
* @return true - if property was just created with specified value,
|
||||
* false - otherwise, if property existed before the call, it's value was updated
|
||||
*/
|
||||
bool
|
||||
ecma_create_native_pointer_property (ecma_object_t *obj_p, /**< object to create property in */
|
||||
void *native_p, /**< native pointer */
|
||||
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);
|
||||
}
|
||||
|
||||
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
|
||||
|
||||
bool is_new = (property_p == NULL);
|
||||
|
||||
ecma_native_pointer_t *native_pointer_p;
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
if (value_p->value == JMEM_CP_NULL)
|
||||
{
|
||||
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);
|
||||
|
||||
*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);
|
||||
|
||||
/* There should be at least 2 native pointers in the chain */
|
||||
JERRY_ASSERT (item_p != NULL && item_p->next_p != NULL);
|
||||
|
||||
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->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 */
|
||||
|
||||
/**
|
||||
* Get value of native package stored in the object's property with specified identifier
|
||||
* Create internal property with specified identifier and store external pointer in the property.
|
||||
*
|
||||
* Note:
|
||||
* property identifier should be one of the following:
|
||||
* - LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER
|
||||
* - ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE;
|
||||
* - ECMA_INTERNAL_PROPERTY_FREE_CALLBACK.
|
||||
*
|
||||
* @return native pointer data if property exists
|
||||
* NULL otherwise
|
||||
*/
|
||||
ecma_native_pointer_t *
|
||||
ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property value from */
|
||||
const jerry_object_native_info_t *native_info_p) /**< native type info */
|
||||
{
|
||||
if (ecma_op_object_is_fast_array (obj_p))
|
||||
{
|
||||
/* Fast access mode array can not have native pointer properties */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ecma_property_value_t *value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
|
||||
|
||||
if (JERRY_LIKELY (*property_p & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
* Delete the previously set native pointer by the native type info from the specified object.
|
||||
*
|
||||
* Note:
|
||||
* If the specified object has no matching native pointer for the given native type info
|
||||
* the function has no effect.
|
||||
*
|
||||
* @return true - if the native pointer has been deleted succesfully
|
||||
* false - otherwise
|
||||
* @return true - if property was just created with specified value,
|
||||
* false - otherwise, if property existed before the call, it's value was updated.
|
||||
*/
|
||||
bool
|
||||
ecma_delete_native_pointer_property (ecma_object_t *obj_p, /**< object to delete property from */
|
||||
const jerry_object_native_info_t *native_info_p) /**< native type info */
|
||||
ecma_create_external_pointer_property (ecma_object_t *obj_p, /**< object to create property in */
|
||||
ecma_internal_property_id_t id, /**< identifier of internal
|
||||
* property to create */
|
||||
ecma_external_pointer_t ptr_value) /**< value to store in the property */
|
||||
{
|
||||
if (ecma_op_object_is_fast_array (obj_p))
|
||||
JERRY_ASSERT (id == ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE
|
||||
|| id == ECMA_INTERNAL_PROPERTY_FREE_CALLBACK);
|
||||
|
||||
bool is_new;
|
||||
ecma_property_t *prop_p = ecma_find_internal_property (obj_p, id);
|
||||
|
||||
if (prop_p == NULL)
|
||||
{
|
||||
/* Fast access mode array can not have native pointer properties */
|
||||
prop_p = ecma_create_internal_property (obj_p, id);
|
||||
|
||||
is_new = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
is_new = false;
|
||||
}
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (uint32_t) <= sizeof (ECMA_PROPERTY_VALUE_PTR (prop_p)->value),
|
||||
size_of_internal_property_value_must_be_greater_than_or_equal_to_4_bytes);
|
||||
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
|
||||
ECMA_PROPERTY_VALUE_PTR (prop_p)->value = (ecma_value_t) ptr_value;
|
||||
|
||||
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
ecma_external_pointer_t *handler_p;
|
||||
|
||||
if (is_new)
|
||||
{
|
||||
handler_p = ecma_alloc_external_pointer ();
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER (ECMA_PROPERTY_VALUE_PTR (prop_p)->value, handler_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
handler_p = ECMA_GET_NON_NULL_POINTER (ecma_external_pointer_t,
|
||||
ECMA_PROPERTY_VALUE_PTR (prop_p)->value);
|
||||
}
|
||||
|
||||
*handler_p = ptr_value;
|
||||
|
||||
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
return is_new;
|
||||
} /* ecma_create_external_pointer_property */
|
||||
|
||||
/**
|
||||
* Get value of external pointer stored in the object's property with specified identifier
|
||||
*
|
||||
* Note:
|
||||
* property identifier should be one of the following:
|
||||
* - ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE;
|
||||
* - ECMA_INTERNAL_PROPERTY_FREE_CALLBACK.
|
||||
*
|
||||
* @return true - if property exists and it's value is returned through out_pointer_p,
|
||||
* false - otherwise (value returned through out_pointer_p is NULL).
|
||||
*/
|
||||
bool
|
||||
ecma_get_external_pointer_value (ecma_object_t *obj_p, /**< object to get property value from */
|
||||
ecma_internal_property_id_t id, /**< identifier of internal property
|
||||
* to get value from */
|
||||
ecma_external_pointer_t *out_pointer_p) /**< [out] value of the external pointer */
|
||||
{
|
||||
JERRY_ASSERT (id == ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE
|
||||
|| id == ECMA_INTERNAL_PROPERTY_FREE_CALLBACK);
|
||||
|
||||
ecma_property_t *prop_p = ecma_find_internal_property (obj_p, id);
|
||||
|
||||
if (prop_p == NULL)
|
||||
{
|
||||
*out_pointer_p = (ecma_external_pointer_t) NULL;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ecma_string_t *name_p = ecma_get_internal_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
|
||||
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);
|
||||
}
|
||||
*out_pointer_p = ECMA_PROPERTY_VALUE_PTR (prop_p)->value;
|
||||
|
||||
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
|
||||
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
if (property_p == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
ecma_external_pointer_t *handler_p = ECMA_GET_NON_NULL_POINTER (ecma_external_pointer_t,
|
||||
ECMA_PROPERTY_VALUE_PTR (prop_p)->value);
|
||||
*out_pointer_p = *handler_p;
|
||||
|
||||
ecma_property_value_t *value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
|
||||
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
if (JERRY_LIKELY (*property_p & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL))
|
||||
{
|
||||
ecma_native_pointer_t *native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, value_p->value);
|
||||
return true;
|
||||
} /* ecma_get_external_pointer_value */
|
||||
|
||||
if (native_pointer_p->native_info_p != native_info_p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Free memory associated with external pointer stored in the property
|
||||
*
|
||||
* Note:
|
||||
* property identifier should be one of the following:
|
||||
* - ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE;
|
||||
* - ECMA_INTERNAL_PROPERTY_FREE_CALLBACK.
|
||||
*/
|
||||
void
|
||||
ecma_free_external_pointer_in_property (ecma_property_t *prop_p) /**< internal property */
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_INTERNAL_PROPERTY_TYPE (prop_p) == ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE
|
||||
|| ECMA_PROPERTY_GET_INTERNAL_PROPERTY_TYPE (prop_p) == ECMA_INTERNAL_PROPERTY_FREE_CALLBACK);
|
||||
|
||||
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;
|
||||
}
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
|
||||
if (value_p->value == JMEM_CP_NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/* no additional memory was allocated for the pointer storage */
|
||||
|
||||
ecma_native_pointer_chain_t *first_p;
|
||||
first_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_chain_t, value_p->value);
|
||||
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
/* There should be at least 2 native pointers in the chain */
|
||||
JERRY_ASSERT (first_p != NULL && first_p->next_p != NULL);
|
||||
ecma_external_pointer_t *handler_p = ECMA_GET_NON_NULL_POINTER (ecma_external_pointer_t,
|
||||
ECMA_PROPERTY_VALUE_PTR (prop_p)->value);
|
||||
|
||||
ecma_native_pointer_chain_t *item_p = first_p;
|
||||
ecma_native_pointer_chain_t *prev_p = NULL;
|
||||
ecma_dealloc_external_pointer (handler_p);
|
||||
|
||||
do
|
||||
{
|
||||
if (item_p->data.native_info_p == native_info_p)
|
||||
{
|
||||
if (prev_p == NULL)
|
||||
{
|
||||
/* 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
|
||||
{
|
||||
/* A non-first element is deleted from the chain: update the previous pointer. */
|
||||
prev_p->next_p = item_p->next_p;
|
||||
}
|
||||
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
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 = item_p;
|
||||
item_p = item_p->next_p;
|
||||
} while (item_p != NULL);
|
||||
|
||||
return false;
|
||||
} /* ecma_delete_native_pointer_property */
|
||||
} /* ecma_free_external_pointer_in_property */
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,245 +0,0 @@
|
||||
/* 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 */
|
||||
+1038
-2252
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,374 @@
|
||||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 University of Szeged.
|
||||
*
|
||||
* 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-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "jrt.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmahelpers Helpers for operations with ECMA data types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Allocate a collection of ecma values.
|
||||
*
|
||||
* @return pointer to the collection's header
|
||||
*/
|
||||
ecma_collection_header_t *
|
||||
ecma_new_values_collection (const ecma_value_t values_buffer[], /**< ecma values */
|
||||
ecma_length_t values_number, /**< number of ecma values */
|
||||
bool do_ref_if_object) /**< if the value is object value,
|
||||
increase reference counter of the object */
|
||||
{
|
||||
JERRY_ASSERT (values_buffer != NULL || values_number == 0);
|
||||
|
||||
const size_t values_in_chunk = JERRY_SIZE_OF_STRUCT_MEMBER (ecma_collection_chunk_t, data) / sizeof (ecma_value_t);
|
||||
|
||||
ecma_collection_header_t *header_p = ecma_alloc_collection_header ();
|
||||
|
||||
header_p->unit_number = values_number;
|
||||
|
||||
jmem_cpointer_t *next_chunk_cp_p = &header_p->first_chunk_cp;
|
||||
ecma_collection_chunk_t *last_chunk_p = NULL;
|
||||
ecma_value_t *cur_value_buf_iter_p = NULL;
|
||||
ecma_value_t *cur_value_buf_end_p = NULL;
|
||||
|
||||
for (ecma_length_t value_index = 0;
|
||||
value_index < values_number;
|
||||
value_index++)
|
||||
{
|
||||
if (cur_value_buf_iter_p == cur_value_buf_end_p)
|
||||
{
|
||||
ecma_collection_chunk_t *chunk_p = ecma_alloc_collection_chunk ();
|
||||
ECMA_SET_POINTER (*next_chunk_cp_p, chunk_p);
|
||||
next_chunk_cp_p = &chunk_p->next_chunk_cp;
|
||||
|
||||
cur_value_buf_iter_p = (ecma_value_t *) chunk_p->data;
|
||||
cur_value_buf_end_p = cur_value_buf_iter_p + values_in_chunk;
|
||||
|
||||
last_chunk_p = chunk_p;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (cur_value_buf_iter_p + 1 <= cur_value_buf_end_p);
|
||||
|
||||
if (do_ref_if_object)
|
||||
{
|
||||
*cur_value_buf_iter_p++ = ecma_copy_value (values_buffer[value_index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
*cur_value_buf_iter_p++ = ecma_copy_value_if_not_object (values_buffer[value_index]);
|
||||
}
|
||||
}
|
||||
|
||||
*next_chunk_cp_p = ECMA_NULL_POINTER;
|
||||
ECMA_SET_POINTER (header_p->last_chunk_cp, last_chunk_p);
|
||||
|
||||
return header_p;
|
||||
} /* ecma_new_values_collection */
|
||||
|
||||
/**
|
||||
* Free the collection of ecma values.
|
||||
*/
|
||||
void
|
||||
ecma_free_values_collection (ecma_collection_header_t *header_p, /**< collection's header */
|
||||
bool do_deref_if_object) /**< if the value is object value,
|
||||
decrement reference counter of the object */
|
||||
{
|
||||
JERRY_ASSERT (header_p != NULL);
|
||||
|
||||
const size_t values_in_chunk = JERRY_SIZE_OF_STRUCT_MEMBER (ecma_collection_chunk_t, data) / sizeof (ecma_value_t);
|
||||
|
||||
ecma_collection_chunk_t *chunk_p = ECMA_GET_POINTER (ecma_collection_chunk_t,
|
||||
header_p->first_chunk_cp);
|
||||
ecma_length_t value_index = 0;
|
||||
|
||||
while (chunk_p != NULL)
|
||||
{
|
||||
JERRY_ASSERT (value_index < header_p->unit_number);
|
||||
|
||||
ecma_value_t *cur_value_buf_iter_p = (ecma_value_t *) chunk_p->data;
|
||||
ecma_value_t *cur_value_buf_end_p = cur_value_buf_iter_p + values_in_chunk;
|
||||
|
||||
while (cur_value_buf_iter_p != cur_value_buf_end_p
|
||||
&& value_index < header_p->unit_number)
|
||||
{
|
||||
JERRY_ASSERT (cur_value_buf_iter_p < cur_value_buf_end_p);
|
||||
|
||||
if (do_deref_if_object)
|
||||
{
|
||||
ecma_free_value (*cur_value_buf_iter_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_free_value_if_not_object (*cur_value_buf_iter_p);
|
||||
}
|
||||
|
||||
cur_value_buf_iter_p++;
|
||||
value_index++;
|
||||
}
|
||||
|
||||
ecma_collection_chunk_t *next_chunk_p = ECMA_GET_POINTER (ecma_collection_chunk_t,
|
||||
chunk_p->next_chunk_cp);
|
||||
ecma_dealloc_collection_chunk (chunk_p);
|
||||
chunk_p = next_chunk_p;
|
||||
}
|
||||
|
||||
ecma_dealloc_collection_header (header_p);
|
||||
} /* ecma_free_values_collection */
|
||||
|
||||
/**
|
||||
* Append new value to ecma values collection
|
||||
*/
|
||||
void
|
||||
ecma_append_to_values_collection (ecma_collection_header_t *header_p, /**< collection's header */
|
||||
ecma_value_t v, /**< ecma value to append */
|
||||
bool do_ref_if_object) /**< if the value is object value,
|
||||
increase reference counter of the object */
|
||||
{
|
||||
const size_t values_in_chunk = JERRY_SIZE_OF_STRUCT_MEMBER (ecma_collection_chunk_t, data) / sizeof (ecma_value_t);
|
||||
|
||||
size_t values_number = header_p->unit_number;
|
||||
size_t pos_of_new_value_in_chunk = values_number % values_in_chunk;
|
||||
|
||||
values_number++;
|
||||
|
||||
if ((ecma_length_t) values_number == values_number)
|
||||
{
|
||||
header_p->unit_number = (ecma_length_t) values_number;
|
||||
}
|
||||
else
|
||||
{
|
||||
jerry_fatal (ERR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
ecma_collection_chunk_t *chunk_p = ECMA_GET_POINTER (ecma_collection_chunk_t,
|
||||
header_p->last_chunk_cp);
|
||||
|
||||
if (pos_of_new_value_in_chunk == 0)
|
||||
{
|
||||
/* all chunks are currently filled with values */
|
||||
|
||||
chunk_p = ecma_alloc_collection_chunk ();
|
||||
chunk_p->next_chunk_cp = ECMA_NULL_POINTER;
|
||||
|
||||
if (header_p->last_chunk_cp == ECMA_NULL_POINTER)
|
||||
{
|
||||
JERRY_ASSERT (header_p->first_chunk_cp == ECMA_NULL_POINTER);
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER (header_p->first_chunk_cp, chunk_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_collection_chunk_t *last_chunk_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_chunk_t,
|
||||
header_p->last_chunk_cp);
|
||||
|
||||
JERRY_ASSERT (last_chunk_p->next_chunk_cp == ECMA_NULL_POINTER);
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER (last_chunk_p->next_chunk_cp, chunk_p);
|
||||
}
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER (header_p->last_chunk_cp, chunk_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* last chunk can be appended with the new value */
|
||||
JERRY_ASSERT (chunk_p != NULL);
|
||||
}
|
||||
|
||||
ecma_value_t *values_p = (ecma_value_t *) chunk_p->data;
|
||||
|
||||
JERRY_ASSERT ((uint8_t *) (values_p + pos_of_new_value_in_chunk + 1) <= (uint8_t *) (chunk_p + 1));
|
||||
|
||||
if (do_ref_if_object)
|
||||
{
|
||||
values_p[pos_of_new_value_in_chunk] = ecma_copy_value (v);
|
||||
}
|
||||
else
|
||||
{
|
||||
values_p[pos_of_new_value_in_chunk] = ecma_copy_value_if_not_object (v);
|
||||
}
|
||||
} /* ecma_append_to_values_collection */
|
||||
|
||||
/**
|
||||
* Remove last element of the collection
|
||||
*
|
||||
* Warning:
|
||||
* the function invalidates all iterators that are configured to access the passed collection
|
||||
*/
|
||||
void
|
||||
ecma_remove_last_value_from_values_collection (ecma_collection_header_t *header_p) /**< collection's header */
|
||||
{
|
||||
JERRY_ASSERT (header_p != NULL && header_p->unit_number > 0);
|
||||
|
||||
const size_t values_in_chunk = JERRY_SIZE_OF_STRUCT_MEMBER (ecma_collection_chunk_t, data) / sizeof (ecma_value_t);
|
||||
size_t values_number = header_p->unit_number;
|
||||
size_t pos_of_value_to_remove_in_chunk = (values_number - 1u) % values_in_chunk;
|
||||
|
||||
ecma_collection_chunk_t *last_chunk_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_chunk_t,
|
||||
header_p->last_chunk_cp);
|
||||
|
||||
ecma_value_t *values_p = (ecma_value_t *) last_chunk_p->data;
|
||||
JERRY_ASSERT ((uint8_t *) (values_p + pos_of_value_to_remove_in_chunk + 1) <= (uint8_t *) (last_chunk_p + 1));
|
||||
|
||||
ecma_value_t value_to_remove = values_p[pos_of_value_to_remove_in_chunk];
|
||||
|
||||
ecma_free_value (value_to_remove);
|
||||
|
||||
header_p->unit_number--;
|
||||
|
||||
if (pos_of_value_to_remove_in_chunk == 0)
|
||||
{
|
||||
ecma_collection_chunk_t *chunk_to_remove_p = last_chunk_p;
|
||||
|
||||
/* free last chunk */
|
||||
if (header_p->first_chunk_cp == header_p->last_chunk_cp)
|
||||
{
|
||||
header_p->first_chunk_cp = ECMA_NULL_POINTER;
|
||||
header_p->last_chunk_cp = ECMA_NULL_POINTER;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_collection_chunk_t *chunk_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_chunk_t,
|
||||
header_p->first_chunk_cp);
|
||||
|
||||
while (chunk_iter_p->next_chunk_cp != header_p->last_chunk_cp)
|
||||
{
|
||||
chunk_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_chunk_t,
|
||||
chunk_iter_p->next_chunk_cp);
|
||||
}
|
||||
|
||||
ecma_collection_chunk_t *new_last_chunk_p = chunk_iter_p;
|
||||
|
||||
JERRY_ASSERT (ECMA_GET_NON_NULL_POINTER (ecma_collection_chunk_t,
|
||||
new_last_chunk_p->next_chunk_cp) == chunk_to_remove_p);
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER (header_p->last_chunk_cp, new_last_chunk_p);
|
||||
new_last_chunk_p->next_chunk_cp = ECMA_NULL_POINTER;
|
||||
}
|
||||
|
||||
ecma_dealloc_collection_chunk (chunk_to_remove_p);
|
||||
}
|
||||
} /* ecma_remove_last_value_from_values_collection */
|
||||
|
||||
/**
|
||||
* Allocate a collection of ecma-strings.
|
||||
*
|
||||
* @return pointer to the collection's header
|
||||
*/
|
||||
ecma_collection_header_t *
|
||||
ecma_new_strings_collection (ecma_string_t *string_ptrs_buffer[], /**< pointers to ecma-strings */
|
||||
ecma_length_t strings_number) /**< number of ecma-strings */
|
||||
{
|
||||
JERRY_ASSERT (string_ptrs_buffer != NULL || strings_number == 0);
|
||||
|
||||
ecma_collection_header_t *new_collection_p;
|
||||
|
||||
new_collection_p = ecma_new_values_collection (NULL, 0, false);
|
||||
|
||||
for (ecma_length_t string_index = 0;
|
||||
string_index < strings_number;
|
||||
string_index++)
|
||||
{
|
||||
ecma_append_to_values_collection (new_collection_p,
|
||||
ecma_make_string_value (string_ptrs_buffer[string_index]),
|
||||
false);
|
||||
}
|
||||
|
||||
return new_collection_p;
|
||||
} /* ecma_new_strings_collection */
|
||||
|
||||
/**
|
||||
* Initialize new collection iterator for the collection
|
||||
*/
|
||||
void
|
||||
ecma_collection_iterator_init (ecma_collection_iterator_t *iterator_p, /**< context of iterator */
|
||||
ecma_collection_header_t *collection_p) /**< header of collection */
|
||||
{
|
||||
iterator_p->header_p = collection_p;
|
||||
iterator_p->next_chunk_cp = (collection_p != NULL ? collection_p->first_chunk_cp : JMEM_CP_NULL);
|
||||
iterator_p->current_index = 0;
|
||||
iterator_p->current_value_p = NULL;
|
||||
iterator_p->current_chunk_end_p = NULL;
|
||||
} /* ecma_collection_iterator_init */
|
||||
|
||||
/**
|
||||
* Move collection iterator to next element if there is any.
|
||||
*
|
||||
* @return true - if iterator moved,
|
||||
* false - otherwise (current element is last element in the collection)
|
||||
*/
|
||||
bool
|
||||
ecma_collection_iterator_next (ecma_collection_iterator_t *iterator_p) /**< context of iterator */
|
||||
{
|
||||
if (iterator_p->header_p == NULL
|
||||
|| unlikely (iterator_p->header_p->unit_number == 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const size_t values_in_chunk = JERRY_SIZE_OF_STRUCT_MEMBER (ecma_collection_chunk_t, data) / sizeof (ecma_value_t);
|
||||
|
||||
if (iterator_p->current_value_p == NULL)
|
||||
{
|
||||
JERRY_ASSERT (iterator_p->current_index == 0);
|
||||
|
||||
ecma_collection_chunk_t *first_chunk_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_chunk_t,
|
||||
iterator_p->header_p->first_chunk_cp);
|
||||
|
||||
iterator_p->next_chunk_cp = first_chunk_p->next_chunk_cp;
|
||||
iterator_p->current_value_p = (ecma_value_t *) &first_chunk_p->data;
|
||||
iterator_p->current_chunk_end_p = (iterator_p->current_value_p + values_in_chunk);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (iterator_p->current_index + 1 == iterator_p->header_p->unit_number)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (iterator_p->current_index + 1 < iterator_p->header_p->unit_number);
|
||||
|
||||
iterator_p->current_index++;
|
||||
iterator_p->current_value_p++;
|
||||
}
|
||||
|
||||
if (iterator_p->current_value_p == iterator_p->current_chunk_end_p)
|
||||
{
|
||||
ecma_collection_chunk_t *next_chunk_p = ECMA_GET_POINTER (ecma_collection_chunk_t,
|
||||
iterator_p->next_chunk_cp);
|
||||
JERRY_ASSERT (next_chunk_p != NULL);
|
||||
|
||||
iterator_p->next_chunk_cp = next_chunk_p->next_chunk_cp;
|
||||
iterator_p->current_value_p = (ecma_value_t *) &next_chunk_p->data;
|
||||
iterator_p->current_chunk_end_p = iterator_p->current_value_p + values_in_chunk;
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (iterator_p->current_value_p < iterator_p->current_chunk_end_p);
|
||||
}
|
||||
|
||||
return true;
|
||||
} /* ecma_collection_iterator_next */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
+795
-1115
File diff suppressed because it is too large
Load Diff
+228
-411
@@ -1,4 +1,5 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2015-2016 University of Szeged.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,8 +18,7 @@
|
||||
#define ECMA_HELPERS_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
#include "jmem-allocator.h"
|
||||
#include "lit-strings.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -33,12 +33,6 @@
|
||||
*/
|
||||
#define ECMA_GET_NON_NULL_POINTER(type, field) JMEM_CP_GET_NON_NULL_POINTER (type, field)
|
||||
|
||||
/**
|
||||
* Extract value of pointer from specified pointer-tag value
|
||||
*/
|
||||
#define ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG(type, field) \
|
||||
JMEM_CP_GET_NON_NULL_POINTER_FROM_POINTER_TAG (type, field)
|
||||
|
||||
/**
|
||||
* Get value of pointer from specified compressed pointer.
|
||||
*/
|
||||
@@ -48,15 +42,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)
|
||||
|
||||
/**
|
||||
* Set value of pointer-tag value so that it will correspond
|
||||
* to specified non_compressed_pointer along with tag
|
||||
*/
|
||||
#define ECMA_SET_NON_NULL_POINTER_TAG(field, non_compressed_pointer, tag) \
|
||||
JMEM_CP_SET_NON_NULL_POINTER_TAG (field, non_compressed_pointer, tag)
|
||||
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) JMEM_CP_SET_NON_NULL_POINTER (field, \
|
||||
non_compressed_pointer)
|
||||
|
||||
/**
|
||||
* Set value of compressed pointer so that it will correspond
|
||||
@@ -64,457 +51,287 @@
|
||||
*/
|
||||
#define ECMA_SET_POINTER(field, non_compressed_pointer) JMEM_CP_SET_POINTER (field, non_compressed_pointer)
|
||||
|
||||
/**
|
||||
* Get value of each tag bit from specified pointer-tag value
|
||||
*/
|
||||
#define ECMA_GET_FIRST_BIT_FROM_POINTER_TAG(field) \
|
||||
JMEM_CP_GET_FIRST_BIT_FROM_POINTER_TAG (field) /**< get first tag bit from jmem_cpointer_tag_t **/
|
||||
#define ECMA_GET_SECOND_BIT_FROM_POINTER_TAG(field) \
|
||||
JMEM_CP_GET_SECOND_BIT_FROM_POINTER_TAG (field) /**< get second tag bit from jmem_cpointer_tag_t **/
|
||||
#define ECMA_GET_THIRD_BIT_FROM_POINTER_TAG(field) \
|
||||
JMEM_CP_GET_THIRD_BIT_FROM_POINTER_TAG (field) /**< get third tag bit from jmem_cpointer_tag_t **/
|
||||
|
||||
/**
|
||||
* Set value of each tag bit to specified pointer-tag value
|
||||
*/
|
||||
#define ECMA_SET_FIRST_BIT_TO_POINTER_TAG(field) \
|
||||
JMEM_CP_SET_FIRST_BIT_TO_POINTER_TAG (field) /**< set first tag bit to jmem_cpointer_tag_t **/
|
||||
#define ECMA_SET_SECOND_BIT_TO_POINTER_TAG(field) \
|
||||
JMEM_CP_SET_SECOND_BIT_TO_POINTER_TAG (field) /**< set second tag bit to jmem_cpointer_tag_t **/
|
||||
#define ECMA_SET_THIRD_BIT_TO_POINTER_TAG(field) \
|
||||
JMEM_CP_SET_THIRD_BIT_TO_POINTER_TAG (field) /**< set third tag bit to jmem_cpointer_tag_t **/
|
||||
|
||||
/**
|
||||
* Status flags for ecma_string_get_chars function
|
||||
*/
|
||||
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_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_MUST_BE_FREED = (1 << 3), /**< The returned buffer must be freed */
|
||||
} ecma_string_flag_t;
|
||||
|
||||
/**
|
||||
* Underscore is ignored when this option is passed.
|
||||
*/
|
||||
#define ECMA_CONVERSION_ALLOW_UNDERSCORE 0x1
|
||||
|
||||
/**
|
||||
* Convert ecma-string's contents to a cesu-8 string and put it into a buffer.
|
||||
*/
|
||||
#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);
|
||||
|
||||
/**
|
||||
* 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); \
|
||||
lit_utf8_size_t utf8_str_size; \
|
||||
bool utf8_ptr ## must_be_freed; \
|
||||
const lit_utf8_byte_t *utf8_ptr = ecma_string_raw_chars (ecma_str_ptr, &utf8_str_size, &utf8_ptr ## must_be_freed); \
|
||||
utf8_ptr ## must_be_freed = false; /* it was used as 'is_ascii' in 'ecma_string_raw_chars', so we must reset it */ \
|
||||
\
|
||||
if (utf8_ptr == NULL) \
|
||||
{ \
|
||||
utf8_ptr = (const lit_utf8_byte_t *) jmem_heap_alloc_block (utf8_str_size); \
|
||||
ecma_string_to_utf8_bytes (ecma_str_ptr, (lit_utf8_byte_t *) utf8_ptr, utf8_str_size); \
|
||||
utf8_ptr ## must_be_freed = true; \
|
||||
}
|
||||
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
|
||||
/**
|
||||
* Set an internal property value from pointer.
|
||||
* Set an internal property value of 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.
|
||||
* Get an internal property value of 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)
|
||||
|
||||
/**
|
||||
* Convert an internal property value to pointer. Result can be NULL.
|
||||
*/
|
||||
#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_GET_INTERNAL_VALUE_POINTER(type, field) \
|
||||
((type *) field)
|
||||
|
||||
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
/**
|
||||
* Set an internal property value from pointer.
|
||||
* Set an internal property value of non-null pointer so that it will correspond
|
||||
* to specified non_compressed_pointer.
|
||||
*/
|
||||
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) ECMA_SET_NON_NULL_POINTER (field, pointer)
|
||||
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, non_compressed_pointer) \
|
||||
ECMA_SET_NON_NULL_POINTER (field, non_compressed_pointer)
|
||||
|
||||
/**
|
||||
* Set an internal property value from pointer. Pointer can be NULL.
|
||||
* Get an internal property value of pointer from specified compressed 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)
|
||||
|
||||
/**
|
||||
* 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)
|
||||
|
||||
/**
|
||||
* Checks whether an internal property is NULL.
|
||||
*/
|
||||
#define ECMA_IS_INTERNAL_VALUE_NULL(field) ((field) == ((ecma_value_t) JMEM_CP_NULL))
|
||||
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) \
|
||||
ECMA_GET_POINTER (type, field)
|
||||
|
||||
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
/**
|
||||
* Convert boolean to bitfield value.
|
||||
* Free the cesu-8 string buffer allocated by 'ECMA_STRING_TO_UTF8_STRING'
|
||||
*/
|
||||
#define ECMA_BOOL_TO_BITFIELD(x) ((x) ? 1 : 0)
|
||||
|
||||
/**
|
||||
* Check whether the given type is ECMA_OBJECT_TYPE_PROXY
|
||||
*
|
||||
* @param type object type
|
||||
*/
|
||||
#define ECMA_OBJECT_TYPE_IS_PROXY(type) (JERRY_UNLIKELY ((type) == ECMA_OBJECT_TYPE_PROXY))
|
||||
|
||||
/**
|
||||
* Check whether the given object has [[ProxyHandler]] and [[ProxyTarger]] internal slots
|
||||
*
|
||||
* @param obj_p ecma-object
|
||||
*/
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
#define ECMA_OBJECT_IS_PROXY(obj_p) (ECMA_OBJECT_TYPE_IS_PROXY (ecma_get_object_type ((obj_p))))
|
||||
#else /* !JERRY_BUILTIN_PROXY */
|
||||
#define ECMA_OBJECT_IS_PROXY(obj_p) (false)
|
||||
#endif /* JERRY_BUILTIN_PROXY */
|
||||
#define ECMA_FINALIZE_UTF8_STRING(utf8_ptr, /**< pointer to character buffer */ \
|
||||
utf8_str_size) /**< buffer size */ \
|
||||
if (utf8_ptr ## must_be_freed) \
|
||||
{ \
|
||||
JERRY_ASSERT (utf8_ptr != NULL); \
|
||||
jmem_heap_free_block ((void *) utf8_ptr, utf8_str_size); \
|
||||
}
|
||||
|
||||
/* ecma-helpers-value.c */
|
||||
ecma_type_t JERRY_ATTR_CONST ecma_get_value_type_field (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_direct (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_simple (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_empty (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_undefined (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_null (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_boolean (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_true (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_false (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_found (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_array_hole (ecma_value_t value);
|
||||
extern bool ecma_is_value_direct (ecma_value_t) __attr_pure___;
|
||||
extern bool ecma_is_value_simple (ecma_value_t) __attr_pure___;
|
||||
extern bool ecma_is_value_empty (ecma_value_t) __attr_pure___;
|
||||
extern bool ecma_is_value_undefined (ecma_value_t) __attr_pure___;
|
||||
extern bool ecma_is_value_null (ecma_value_t) __attr_pure___;
|
||||
extern bool ecma_is_value_boolean (ecma_value_t) __attr_pure___;
|
||||
extern bool ecma_is_value_true (ecma_value_t) __attr_pure___;
|
||||
extern bool ecma_is_value_false (ecma_value_t) __attr_pure___;
|
||||
extern bool ecma_is_value_array_hole (ecma_value_t) __attr_pure___;
|
||||
|
||||
bool JERRY_ATTR_CONST ecma_is_value_integer_number (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_are_values_integer_numbers (ecma_value_t first_value, ecma_value_t second_value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_float_number (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_number (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_string (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_symbol (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_magic_string (ecma_value_t value, lit_magic_string_id_t id);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_bigint (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_prop_name (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_direct_string (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_non_direct_string (ecma_value_t value);
|
||||
bool JERRY_ATTR_CONST ecma_is_value_object (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);
|
||||
extern bool ecma_is_value_integer_number (ecma_value_t) __attr_pure___;
|
||||
extern bool ecma_are_values_integer_numbers (ecma_value_t, ecma_value_t) __attr_pure___;
|
||||
extern bool ecma_is_value_float_number (ecma_value_t) __attr_pure___;
|
||||
extern bool ecma_is_value_number (ecma_value_t) __attr_pure___;
|
||||
extern bool ecma_is_value_string (ecma_value_t) __attr_pure___;
|
||||
extern bool ecma_is_value_object (ecma_value_t) __attr_pure___;
|
||||
|
||||
void ecma_check_value_type_is_spec_defined (ecma_value_t value);
|
||||
extern void ecma_check_value_type_is_spec_defined (ecma_value_t);
|
||||
|
||||
ecma_value_t JERRY_ATTR_CONST ecma_make_boolean_value (bool boolean_value);
|
||||
ecma_value_t JERRY_ATTR_CONST ecma_make_integer_value (ecma_integer_value_t integer_value);
|
||||
ecma_value_t ecma_make_nan_value (void);
|
||||
ecma_value_t ecma_make_float_value (ecma_number_t *ecma_num_p);
|
||||
ecma_value_t ecma_make_length_value (ecma_length_t length);
|
||||
ecma_value_t ecma_make_number_value (ecma_number_t ecma_number);
|
||||
ecma_value_t ecma_make_int32_value (int32_t int32_number);
|
||||
ecma_value_t ecma_make_uint32_value (uint32_t uint32_number);
|
||||
ecma_value_t JERRY_ATTR_PURE ecma_make_string_value (const ecma_string_t *ecma_string_p);
|
||||
ecma_value_t JERRY_ATTR_PURE ecma_make_symbol_value (const ecma_string_t *ecma_symbol_p);
|
||||
ecma_value_t JERRY_ATTR_PURE ecma_make_prop_name_value (const ecma_string_t *ecma_prop_name_p);
|
||||
ecma_value_t JERRY_ATTR_PURE ecma_make_magic_string_value (lit_magic_string_id_t id);
|
||||
ecma_value_t JERRY_ATTR_PURE ecma_make_object_value (const ecma_object_t *object_p);
|
||||
ecma_value_t JERRY_ATTR_PURE ecma_make_extended_primitive_value (const ecma_extended_primitive_t *primitve_p,
|
||||
uint32_t type);
|
||||
ecma_integer_value_t JERRY_ATTR_CONST ecma_get_integer_from_value (ecma_value_t value);
|
||||
ecma_number_t JERRY_ATTR_PURE ecma_get_float_from_value (ecma_value_t value);
|
||||
ecma_number_t *ecma_get_pointer_from_float_value (ecma_value_t value);
|
||||
ecma_number_t JERRY_ATTR_PURE ecma_get_number_from_value (ecma_value_t value);
|
||||
ecma_string_t JERRY_ATTR_PURE *ecma_get_string_from_value (ecma_value_t value);
|
||||
ecma_string_t JERRY_ATTR_PURE *ecma_get_symbol_from_value (ecma_value_t value);
|
||||
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);
|
||||
ecma_value_t JERRY_ATTR_CONST ecma_invert_boolean_value (ecma_value_t value);
|
||||
ecma_value_t ecma_copy_value (ecma_value_t value);
|
||||
ecma_value_t ecma_fast_copy_value (ecma_value_t value);
|
||||
ecma_value_t ecma_copy_value_if_not_object (ecma_value_t value);
|
||||
void ecma_ref_if_object (ecma_value_t value);
|
||||
void ecma_deref_if_object (ecma_value_t value);
|
||||
ecma_value_t ecma_update_float_number (ecma_value_t float_value, ecma_number_t new_number);
|
||||
void ecma_value_assign_value (ecma_value_t *value_p, ecma_value_t ecma_value);
|
||||
void ecma_value_assign_number (ecma_value_t *value_p, ecma_number_t ecma_number);
|
||||
void ecma_free_value (ecma_value_t value);
|
||||
void ecma_fast_free_value (ecma_value_t value);
|
||||
void ecma_free_value_if_not_object (ecma_value_t value);
|
||||
void ecma_free_object (ecma_value_t value);
|
||||
void ecma_free_number (ecma_value_t value);
|
||||
lit_magic_string_id_t ecma_get_typeof_lit_id (ecma_value_t value);
|
||||
extern ecma_value_t ecma_make_simple_value (const ecma_simple_value_t value) __attr_const___;
|
||||
extern ecma_value_t ecma_make_boolean_value (bool) __attr_const___;
|
||||
extern ecma_value_t ecma_make_integer_value (ecma_integer_value_t) __attr_const___;
|
||||
extern ecma_value_t ecma_make_nan_value (void);
|
||||
extern ecma_value_t ecma_make_number_value (ecma_number_t);
|
||||
extern ecma_value_t ecma_make_int32_value (int32_t);
|
||||
extern ecma_value_t ecma_make_uint32_value (uint32_t);
|
||||
extern ecma_value_t ecma_make_string_value (const ecma_string_t *);
|
||||
extern ecma_value_t ecma_make_object_value (const ecma_object_t *);
|
||||
extern ecma_value_t ecma_make_error_value (ecma_value_t);
|
||||
extern ecma_value_t ecma_make_error_obj_value (const ecma_object_t *);
|
||||
extern ecma_integer_value_t ecma_get_integer_from_value (ecma_value_t) __attr_pure___;
|
||||
extern ecma_number_t ecma_get_float_from_value (ecma_value_t) __attr_pure___;
|
||||
extern ecma_number_t ecma_get_number_from_value (ecma_value_t) __attr_pure___;
|
||||
extern uint32_t ecma_get_uint32_from_value (ecma_value_t) __attr_pure___;
|
||||
extern ecma_string_t *ecma_get_string_from_value (ecma_value_t) __attr_pure___;
|
||||
extern ecma_object_t *ecma_get_object_from_value (ecma_value_t) __attr_pure___;
|
||||
extern ecma_value_t ecma_get_value_from_error_value (ecma_value_t) __attr_pure___;
|
||||
extern ecma_value_t ecma_invert_boolean_value (ecma_value_t) __attr_pure___;
|
||||
extern ecma_value_t ecma_copy_value (ecma_value_t);
|
||||
extern ecma_value_t ecma_fast_copy_value (ecma_value_t);
|
||||
extern ecma_value_t ecma_copy_value_if_not_object (ecma_value_t);
|
||||
extern ecma_value_t ecma_update_float_number (ecma_value_t, ecma_number_t);
|
||||
extern void ecma_value_assign_value (ecma_value_t *, ecma_value_t);
|
||||
extern void ecma_value_assign_number (ecma_value_t *, ecma_number_t);
|
||||
extern void ecma_value_assign_uint32 (ecma_value_t *, uint32_t);
|
||||
extern void ecma_free_value (ecma_value_t);
|
||||
extern void ecma_fast_free_value (ecma_value_t);
|
||||
extern void ecma_free_value_if_not_object (ecma_value_t);
|
||||
|
||||
/* ecma-helpers-string.c */
|
||||
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);
|
||||
#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 /* 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, void *user_p);
|
||||
ecma_string_t *ecma_new_ecma_string_from_code_unit (ecma_char_t code_unit);
|
||||
ecma_string_t *ecma_new_ecma_string_from_code_units (ecma_char_t first_code_unit, ecma_char_t second_code_unit);
|
||||
ecma_string_t *ecma_new_ecma_string_from_length (ecma_length_t index);
|
||||
ecma_string_t *ecma_new_ecma_string_from_uint32 (uint32_t uint32_number);
|
||||
ecma_string_t *ecma_new_non_direct_string_from_uint32 (uint32_t uint32_number);
|
||||
ecma_string_t *ecma_get_ecma_string_from_uint32 (uint32_t uint32_number);
|
||||
ecma_string_t *ecma_new_ecma_string_from_number (ecma_number_t num);
|
||||
ecma_string_t *ecma_get_magic_string (lit_magic_string_id_t id);
|
||||
ecma_string_t *ecma_get_internal_string (lit_magic_string_id_t id);
|
||||
ecma_string_t *ecma_append_chars_to_string (ecma_string_t *string1_p,
|
||||
const lit_utf8_byte_t *cesu8_string2_p,
|
||||
lit_utf8_size_t cesu8_string2_size,
|
||||
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);
|
||||
extern ecma_string_t *ecma_new_ecma_string_from_utf8 (const lit_utf8_byte_t *, lit_utf8_size_t);
|
||||
extern ecma_string_t *ecma_new_ecma_string_from_code_unit (ecma_char_t);
|
||||
extern ecma_string_t *ecma_new_ecma_string_from_uint32 (uint32_t);
|
||||
extern ecma_string_t *ecma_new_ecma_string_from_number (ecma_number_t);
|
||||
extern ecma_string_t *ecma_new_ecma_string_from_magic_string_id (lit_magic_string_id_t);
|
||||
extern ecma_string_t *ecma_new_ecma_string_from_magic_string_ex_id (lit_magic_string_ex_id_t);
|
||||
extern ecma_string_t *ecma_new_ecma_length_string ();
|
||||
extern ecma_string_t *ecma_concat_ecma_strings (ecma_string_t *, ecma_string_t *);
|
||||
extern void ecma_ref_ecma_string (ecma_string_t *);
|
||||
extern void ecma_deref_ecma_string (ecma_string_t *);
|
||||
extern ecma_number_t ecma_string_to_number (const ecma_string_t *);
|
||||
extern bool ecma_string_get_array_index (const ecma_string_t *, uint32_t *);
|
||||
|
||||
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,
|
||||
lit_utf8_byte_t *uint32_buff_p,
|
||||
uint8_t *flags_p);
|
||||
bool ecma_compare_ecma_string_to_magic_id (const ecma_string_t *string_p, lit_magic_string_id_t id);
|
||||
bool ecma_string_is_empty (const ecma_string_t *string_p);
|
||||
bool ecma_string_is_length (const ecma_string_t *string_p);
|
||||
extern lit_utf8_size_t __attr_return_value_should_be_checked___
|
||||
ecma_string_copy_to_utf8_buffer (const ecma_string_t *, lit_utf8_byte_t *, lit_utf8_size_t);
|
||||
extern void ecma_string_to_utf8_bytes (const ecma_string_t *, lit_utf8_byte_t *, lit_utf8_size_t);
|
||||
extern const lit_utf8_byte_t *ecma_string_raw_chars (const ecma_string_t *, lit_utf8_size_t *, bool *);
|
||||
extern void ecma_init_ecma_string_from_uint32 (ecma_string_t *, uint32_t);
|
||||
extern void ecma_init_ecma_length_string (ecma_string_t *);
|
||||
extern bool ecma_string_is_empty (const ecma_string_t *);
|
||||
extern bool ecma_string_is_length (const ecma_string_t *);
|
||||
|
||||
jmem_cpointer_t ecma_string_to_property_name (ecma_string_t *prop_name_p, ecma_property_t *name_type_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,
|
||||
const ecma_string_t *string_p);
|
||||
extern bool ecma_compare_ecma_strings_equal_hashes (const ecma_string_t *, const ecma_string_t *);
|
||||
extern bool ecma_compare_ecma_strings (const ecma_string_t *, const ecma_string_t *);
|
||||
extern bool ecma_compare_ecma_strings_relational (const ecma_string_t *, const ecma_string_t *);
|
||||
extern ecma_length_t ecma_string_get_length (const ecma_string_t *);
|
||||
extern lit_utf8_size_t ecma_string_get_size (const ecma_string_t *);
|
||||
extern ecma_char_t ecma_string_get_char_at_pos (const ecma_string_t *, ecma_length_t);
|
||||
|
||||
bool ecma_compare_ecma_strings (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
|
||||
bool ecma_compare_ecma_non_direct_strings (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
|
||||
bool ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
|
||||
lit_utf8_size_t ecma_string_get_length (const ecma_string_t *string_p);
|
||||
lit_utf8_size_t ecma_string_get_utf8_length (const ecma_string_t *string_p);
|
||||
lit_utf8_size_t ecma_string_get_size (const ecma_string_t *string_p);
|
||||
lit_utf8_size_t ecma_string_get_utf8_size (const ecma_string_t *string_p);
|
||||
ecma_char_t ecma_string_get_char_at_pos (const ecma_string_t *string_p, lit_utf8_size_t index);
|
||||
extern ecma_string_t *ecma_get_magic_string (lit_magic_string_id_t);
|
||||
extern ecma_string_t *ecma_get_magic_string_ex (lit_magic_string_ex_id_t);
|
||||
extern bool ecma_is_string_magic (const ecma_string_t *, lit_magic_string_id_t *);
|
||||
|
||||
lit_magic_string_id_t ecma_get_string_magic (const ecma_string_t *string_p);
|
||||
|
||||
lit_string_hash_t ecma_string_hash (const ecma_string_t *string_p);
|
||||
ecma_string_t *ecma_string_substr (const ecma_string_t *string_p, lit_utf8_size_t start_pos, lit_utf8_size_t end_pos);
|
||||
const lit_utf8_byte_t *ecma_string_trim_front (const lit_utf8_byte_t *start_p, const lit_utf8_byte_t *end_p);
|
||||
const lit_utf8_byte_t *ecma_string_trim_back (const lit_utf8_byte_t *start_p, const lit_utf8_byte_t *end_p);
|
||||
void ecma_string_trim_helper (const lit_utf8_byte_t **utf8_str_p, lit_utf8_size_t *utf8_str_size);
|
||||
ecma_string_t *ecma_string_trim (const ecma_string_t *string_p);
|
||||
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);
|
||||
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);
|
||||
void ecma_stringbuilder_append (ecma_stringbuilder_t *builder_p, const ecma_string_t *string_p);
|
||||
void ecma_stringbuilder_append_magic (ecma_stringbuilder_t *builder_p, const lit_magic_string_id_t id);
|
||||
void ecma_stringbuilder_append_raw (ecma_stringbuilder_t *builder_p,
|
||||
const lit_utf8_byte_t *data_p,
|
||||
const lit_utf8_size_t data_size);
|
||||
void ecma_stringbuilder_append_codepoint (ecma_stringbuilder_t *builder_p, lit_code_point_t cp);
|
||||
void ecma_stringbuilder_append_char (ecma_stringbuilder_t *builder_p, const ecma_char_t c);
|
||||
void ecma_stringbuilder_append_byte (ecma_stringbuilder_t *builder_p, const lit_utf8_byte_t);
|
||||
ecma_string_t *ecma_stringbuilder_finalize (ecma_stringbuilder_t *builder_p);
|
||||
void ecma_stringbuilder_destroy (ecma_stringbuilder_t *builder_p);
|
||||
extern lit_string_hash_t ecma_string_hash (const ecma_string_t *);
|
||||
extern ecma_string_t *ecma_string_substr (const ecma_string_t *, ecma_length_t, ecma_length_t);
|
||||
extern ecma_string_t *ecma_string_trim (const ecma_string_t *);
|
||||
|
||||
/* ecma-helpers-number.c */
|
||||
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);
|
||||
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_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_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_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);
|
||||
extern ecma_number_t ecma_number_make_nan (void);
|
||||
extern ecma_number_t ecma_number_make_infinity (bool);
|
||||
extern bool ecma_number_is_nan (ecma_number_t);
|
||||
extern bool ecma_number_is_negative (ecma_number_t);
|
||||
extern bool ecma_number_is_zero (ecma_number_t);
|
||||
extern bool ecma_number_is_infinity (ecma_number_t);
|
||||
extern int32_t
|
||||
ecma_number_get_fraction_and_exponent (ecma_number_t, uint64_t *, int32_t *);
|
||||
extern ecma_number_t
|
||||
ecma_number_make_normal_positive_from_fraction_and_exponent (uint64_t, int32_t);
|
||||
extern ecma_number_t
|
||||
ecma_number_make_from_sign_mantissa_and_exponent (bool, uint64_t, int32_t);
|
||||
extern ecma_number_t ecma_number_get_prev (ecma_number_t);
|
||||
extern ecma_number_t ecma_number_get_next (ecma_number_t);
|
||||
extern ecma_number_t ecma_number_negate (ecma_number_t);
|
||||
extern ecma_number_t ecma_number_trunc (ecma_number_t);
|
||||
extern ecma_number_t ecma_number_calc_remainder (ecma_number_t, ecma_number_t);
|
||||
extern ecma_number_t ecma_number_add (ecma_number_t, ecma_number_t);
|
||||
extern ecma_number_t ecma_number_substract (ecma_number_t, ecma_number_t);
|
||||
extern ecma_number_t ecma_number_multiply (ecma_number_t, ecma_number_t);
|
||||
extern ecma_number_t ecma_number_divide (ecma_number_t, ecma_number_t);
|
||||
extern lit_utf8_size_t ecma_number_to_decimal (ecma_number_t, lit_utf8_byte_t *, int32_t *);
|
||||
|
||||
/* ecma-helpers-collection.c */
|
||||
ecma_collection_t *ecma_new_collection (void);
|
||||
void ecma_collection_push_back (ecma_collection_t *collection_p, ecma_value_t value);
|
||||
void ecma_collection_reserve (ecma_collection_t *collection_p, uint32_t count);
|
||||
void ecma_collection_append (ecma_collection_t *collection_p, const ecma_value_t *buffer_p, uint32_t count);
|
||||
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);
|
||||
void ecma_collection_free_template_literal (ecma_collection_t *collection_p);
|
||||
bool ecma_collection_check_duplicated_entries (ecma_collection_t *collection_p);
|
||||
bool ecma_collection_has_string_value (ecma_collection_t *collection_p, ecma_string_t *string_p);
|
||||
/* ecma-helpers-values-collection.c */
|
||||
extern ecma_collection_header_t *ecma_new_values_collection (const ecma_value_t[], ecma_length_t, bool);
|
||||
extern void ecma_free_values_collection (ecma_collection_header_t *, bool);
|
||||
extern void ecma_append_to_values_collection (ecma_collection_header_t *, ecma_value_t, bool);
|
||||
extern void ecma_remove_last_value_from_values_collection (ecma_collection_header_t *);
|
||||
extern ecma_collection_header_t *ecma_new_strings_collection (ecma_string_t *[], ecma_length_t);
|
||||
|
||||
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);
|
||||
/**
|
||||
* Context of ecma values' collection iterator
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ecma_collection_header_t *header_p; /**< collection header */
|
||||
jmem_cpointer_t next_chunk_cp; /**< compressed pointer to next chunk */
|
||||
ecma_length_t current_index; /**< index of current element */
|
||||
const ecma_value_t *current_value_p; /**< pointer to current element */
|
||||
const ecma_value_t *current_chunk_beg_p; /**< pointer to beginning of current chunk's data */
|
||||
const ecma_value_t *current_chunk_end_p; /**< pointer to place right after the end of current chunk's data */
|
||||
} ecma_collection_iterator_t;
|
||||
|
||||
extern void
|
||||
ecma_collection_iterator_init (ecma_collection_iterator_t *, ecma_collection_header_t *);
|
||||
extern bool
|
||||
ecma_collection_iterator_next (ecma_collection_iterator_t *);
|
||||
|
||||
/* 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_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);
|
||||
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);
|
||||
extern ecma_object_t *ecma_create_object (ecma_object_t *, bool, bool, ecma_object_type_t);
|
||||
extern ecma_object_t *ecma_create_decl_lex_env (ecma_object_t *);
|
||||
extern ecma_object_t *ecma_create_object_lex_env (ecma_object_t *, ecma_object_t *, bool);
|
||||
extern bool ecma_is_lexical_environment (const ecma_object_t *) __attr_pure___;
|
||||
extern bool ecma_get_object_extensible (const ecma_object_t *) __attr_pure___;
|
||||
extern void ecma_set_object_extensible (ecma_object_t *, bool);
|
||||
extern ecma_object_type_t ecma_get_object_type (const ecma_object_t *) __attr_pure___;
|
||||
extern void ecma_set_object_type (ecma_object_t *, ecma_object_type_t);
|
||||
extern ecma_object_t *ecma_get_object_prototype (const ecma_object_t *) __attr_pure___;
|
||||
extern bool ecma_get_object_is_builtin (const ecma_object_t *) __attr_pure___;
|
||||
extern void ecma_set_object_is_builtin (ecma_object_t *);
|
||||
extern ecma_lexical_environment_type_t ecma_get_lex_env_type (const ecma_object_t *) __attr_pure___;
|
||||
extern ecma_object_t *ecma_get_lex_env_outer_reference (const ecma_object_t *) __attr_pure___;
|
||||
extern ecma_property_header_t *ecma_get_property_list (const ecma_object_t *) __attr_pure___;
|
||||
extern ecma_object_t *ecma_get_lex_env_binding_object (const ecma_object_t *) __attr_pure___;
|
||||
extern bool ecma_get_lex_env_provide_this (const ecma_object_t *) __attr_pure___;
|
||||
|
||||
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);
|
||||
extern ecma_property_t *ecma_create_internal_property (ecma_object_t *, ecma_internal_property_id_t);
|
||||
extern ecma_property_t *ecma_find_internal_property (ecma_object_t *, ecma_internal_property_id_t);
|
||||
extern ecma_property_t *ecma_get_internal_property (ecma_object_t *, ecma_internal_property_id_t);
|
||||
|
||||
void ecma_delete_property (ecma_object_t *object_p, ecma_property_value_t *prop_value_p);
|
||||
extern ecma_property_t *
|
||||
ecma_create_named_data_property (ecma_object_t *, ecma_string_t *, uint8_t);
|
||||
extern ecma_property_t *
|
||||
ecma_create_named_accessor_property (ecma_object_t *, ecma_string_t *, ecma_object_t *, ecma_object_t *, uint8_t);
|
||||
extern ecma_property_t *
|
||||
ecma_find_named_property (ecma_object_t *, ecma_string_t *);
|
||||
extern ecma_property_t *
|
||||
ecma_get_named_property (ecma_object_t *, ecma_string_t *);
|
||||
extern ecma_property_t *
|
||||
ecma_get_named_data_property (ecma_object_t *, ecma_string_t *);
|
||||
|
||||
void
|
||||
ecma_named_data_property_assign_value (ecma_object_t *obj_p, ecma_property_value_t *prop_value_p, ecma_value_t value);
|
||||
extern void ecma_free_property (ecma_object_t *, ecma_string_t *, ecma_property_t *);
|
||||
|
||||
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,
|
||||
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);
|
||||
void ecma_set_property_enumerable_attr (ecma_property_t *property_p, bool is_enumerable);
|
||||
bool ecma_is_property_configurable (ecma_property_t property);
|
||||
void ecma_set_property_configurable_attr (ecma_property_t *property_p, bool is_configurable);
|
||||
extern void ecma_delete_property (ecma_object_t *, ecma_property_t *);
|
||||
|
||||
#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 /* JERRY_LCACHE */
|
||||
extern ecma_value_t ecma_get_named_data_property_value (const ecma_property_t *);
|
||||
extern void ecma_set_named_data_property_value (ecma_property_t *, ecma_value_t);
|
||||
extern void ecma_named_data_property_assign_value (ecma_object_t *, ecma_property_t *, ecma_value_t);
|
||||
|
||||
ecma_property_descriptor_t ecma_make_empty_property_descriptor (void);
|
||||
void ecma_free_property_descriptor (ecma_property_descriptor_t *prop_desc_p);
|
||||
extern ecma_value_t ecma_get_internal_property_value (const ecma_property_t *);
|
||||
extern void ecma_set_internal_property_value (ecma_property_t *, ecma_value_t);
|
||||
|
||||
void ecma_ref_extended_primitive (ecma_extended_primitive_t *primitve_p);
|
||||
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 /* JERRY_BUILTIN_BIGINT */
|
||||
extern ecma_object_t *ecma_get_named_accessor_property_getter (const ecma_property_t *);
|
||||
extern ecma_object_t *ecma_get_named_accessor_property_setter (const ecma_property_t *);
|
||||
extern void ecma_set_named_accessor_property_getter (ecma_object_t *, ecma_property_t *, ecma_object_t *);
|
||||
extern void ecma_set_named_accessor_property_setter (ecma_object_t *, ecma_property_t *, ecma_object_t *);
|
||||
extern bool ecma_is_property_writable (ecma_property_t *);
|
||||
extern void ecma_set_property_writable_attr (ecma_property_t *, bool);
|
||||
extern bool ecma_is_property_enumerable (ecma_property_t *);
|
||||
extern void ecma_set_property_enumerable_attr (ecma_property_t *, bool);
|
||||
extern bool ecma_is_property_configurable (ecma_property_t *);
|
||||
extern void ecma_set_property_configurable_attr (ecma_property_t *, bool);
|
||||
|
||||
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);
|
||||
extern bool ecma_is_property_lcached (ecma_property_t *);
|
||||
extern void ecma_set_property_lcached (ecma_property_t *, bool);
|
||||
|
||||
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);
|
||||
ecma_value_t *ecma_compiled_code_resolve_function_name (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);
|
||||
#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) */
|
||||
extern ecma_property_descriptor_t ecma_make_empty_property_descriptor (void);
|
||||
extern void ecma_free_property_descriptor (ecma_property_descriptor_t *);
|
||||
extern ecma_property_descriptor_t ecma_get_property_descriptor_from_property (ecma_property_t *);
|
||||
|
||||
extern ecma_property_t *ecma_get_next_property_pair (ecma_property_pair_t *);
|
||||
|
||||
extern void ecma_bytecode_ref (ecma_compiled_code_t *);
|
||||
extern void ecma_bytecode_deref (ecma_compiled_code_t *);
|
||||
|
||||
/* ecma-helpers-external-pointers.c */
|
||||
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);
|
||||
extern bool
|
||||
ecma_create_external_pointer_property (ecma_object_t *, ecma_internal_property_id_t, ecma_external_pointer_t);
|
||||
extern bool
|
||||
ecma_get_external_pointer_value (ecma_object_t *, ecma_internal_property_id_t, ecma_external_pointer_t *);
|
||||
extern void
|
||||
ecma_free_external_pointer_in_property (ecma_property_t *);
|
||||
|
||||
/* 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_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);
|
||||
lit_utf8_size_t ecma_number_to_utf8_string (ecma_number_t num, lit_utf8_byte_t *buffer_p, lit_utf8_size_t buffer_size);
|
||||
extern ecma_number_t ecma_utf8_string_to_number (const lit_utf8_byte_t *, lit_utf8_size_t);
|
||||
extern lit_utf8_size_t ecma_uint32_to_utf8_string (uint32_t, lit_utf8_byte_t *, lit_utf8_size_t);
|
||||
extern uint32_t ecma_number_to_uint32 (ecma_number_t);
|
||||
extern int32_t ecma_number_to_int32 (ecma_number_t);
|
||||
extern lit_utf8_size_t ecma_number_to_utf8_string (ecma_number_t, lit_utf8_byte_t *, lit_utf8_size_t);
|
||||
|
||||
/* ecma-helpers-errol.c */
|
||||
lit_utf8_size_t ecma_errol0_dtoa (double val, lit_utf8_byte_t *buffer_p, int32_t *exp_p);
|
||||
extern lit_utf8_size_t ecma_errol0_dtoa (double, lit_utf8_byte_t *, int32_t *);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,16 +13,14 @@
|
||||
* 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-lcache.h"
|
||||
#include "ecma-lex-env.h"
|
||||
#include "ecma-literal-storage.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jmem.h"
|
||||
#include "jmem-allocator.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -31,40 +29,16 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Maximum number of GC loops on cleanup.
|
||||
*/
|
||||
#define JERRY_GC_LOOP_LIMIT 100
|
||||
|
||||
/**
|
||||
* Initialize ECMA components
|
||||
*/
|
||||
void
|
||||
ecma_init (void)
|
||||
{
|
||||
#if (JERRY_GC_MARK_LIMIT != 0)
|
||||
JERRY_CONTEXT (ecma_gc_mark_recursion_limit) = JERRY_GC_MARK_LIMIT;
|
||||
#endif /* (JERRY_GC_MARK_LIMIT != 0) */
|
||||
ecma_lcache_init ();
|
||||
ecma_init_global_lex_env ();
|
||||
|
||||
ecma_init_global_environment ();
|
||||
|
||||
#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 /* JERRY_PROPERTY_HASHMAP */
|
||||
|
||||
#if (JERRY_STACK_LIMIT != 0)
|
||||
volatile int sp;
|
||||
JERRY_CONTEXT (stack_base) = (uintptr_t) &sp;
|
||||
#endif /* (JERRY_STACK_LIMIT != 0) */
|
||||
|
||||
ecma_job_queue_init ();
|
||||
|
||||
JERRY_CONTEXT (current_new_target_p) = NULL;
|
||||
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
JERRY_CONTEXT (arraybuffer_compact_allocation_limit) = 256;
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
jmem_register_free_unused_memory_callback (ecma_free_unused_memory);
|
||||
} /* ecma_init */
|
||||
|
||||
/**
|
||||
@@ -73,30 +47,11 @@ ecma_init (void)
|
||||
void
|
||||
ecma_finalize (void)
|
||||
{
|
||||
JERRY_ASSERT (JERRY_CONTEXT (current_new_target_p) == NULL);
|
||||
|
||||
ecma_finalize_global_environment ();
|
||||
uint8_t runs = 0;
|
||||
|
||||
do
|
||||
{
|
||||
ecma_gc_run ();
|
||||
if (++runs >= JERRY_GC_LOOP_LIMIT)
|
||||
{
|
||||
jerry_fatal (JERRY_FATAL_UNTERMINATED_GC_LOOPS);
|
||||
}
|
||||
} while (JERRY_CONTEXT (ecma_gc_new_objects) != 0);
|
||||
|
||||
jmem_cpointer_t *global_symbols_cp = JERRY_CONTEXT (global_symbols_cp);
|
||||
|
||||
for (uint32_t i = 0; i < ECMA_BUILTIN_GLOBAL_SYMBOL_COUNT; i++)
|
||||
{
|
||||
if (global_symbols_cp[i] != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_deref_ecma_string (ECMA_GET_NON_NULL_POINTER (ecma_string_t, global_symbols_cp[i]));
|
||||
}
|
||||
}
|
||||
jmem_unregister_free_unused_memory_callback (ecma_free_unused_memory);
|
||||
|
||||
ecma_finalize_global_lex_env ();
|
||||
ecma_finalize_builtins ();
|
||||
ecma_gc_run (JMEM_FREE_UNUSED_MEMORY_SEVERITY_LOW);
|
||||
ecma_finalize_lit_storage ();
|
||||
} /* ecma_finalize */
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,8 +23,8 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
void ecma_init (void);
|
||||
void ecma_finalize (void);
|
||||
extern void ecma_init (void);
|
||||
extern void ecma_finalize (void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 University of Szeged.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,12 +14,10 @@
|
||||
* 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
|
||||
@@ -28,44 +27,39 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if JERRY_LCACHE
|
||||
|
||||
/**
|
||||
* Bitshift index for calculating hash.
|
||||
*/
|
||||
#if JERRY_CPOINTER_32_BIT
|
||||
#define ECMA_LCACHE_HASH_BITSHIFT_INDEX (2 * JMEM_ALIGNMENT_LOG)
|
||||
#else /* !JERRY_CPOINTER_32_BIT */
|
||||
#define ECMA_LCACHE_HASH_BITSHIFT_INDEX 0
|
||||
#endif /* JERRY_CPOINTER_32_BIT */
|
||||
#ifndef CONFIG_ECMA_LCACHE_DISABLE
|
||||
|
||||
/**
|
||||
* Mask for hash bits
|
||||
*/
|
||||
#define ECMA_LCACHE_HASH_MASK ((ECMA_LCACHE_HASH_ROWS_COUNT - 1) << ECMA_LCACHE_HASH_BITSHIFT_INDEX)
|
||||
#define ECMA_LCACHE_HASH_MASK (ECMA_LCACHE_HASH_ROWS_COUNT - 1)
|
||||
|
||||
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
|
||||
|
||||
/**
|
||||
* Bitshift index for creating property identifier
|
||||
* Initialize LCache
|
||||
*/
|
||||
#define ECMA_LCACHE_HASH_ENTRY_ID_SHIFT (8 * sizeof (jmem_cpointer_t))
|
||||
|
||||
/**
|
||||
* Create property identifier
|
||||
*/
|
||||
#define ECMA_LCACHE_CREATE_ID(object_cp, name_cp) \
|
||||
(((ecma_lcache_hash_entry_id_t) (object_cp) << ECMA_LCACHE_HASH_ENTRY_ID_SHIFT) | (name_cp))
|
||||
void
|
||||
ecma_lcache_init (void)
|
||||
{
|
||||
#ifndef CONFIG_ECMA_LCACHE_DISABLE
|
||||
memset (JERRY_HASH_TABLE_CONTEXT (table), 0, sizeof (jerry_hash_table_t));
|
||||
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
|
||||
} /* ecma_lcache_init */
|
||||
|
||||
#ifndef CONFIG_ECMA_LCACHE_DISABLE
|
||||
/**
|
||||
* Invalidate specified LCache entry
|
||||
*/
|
||||
static inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
static inline void __attr_always_inline___
|
||||
ecma_lcache_invalidate_entry (ecma_lcache_hash_entry_t *entry_p) /**< entry to invalidate */
|
||||
{
|
||||
JERRY_ASSERT (entry_p != NULL);
|
||||
JERRY_ASSERT (entry_p->id != 0);
|
||||
JERRY_ASSERT (entry_p->object_cp != ECMA_NULL_POINTER);
|
||||
JERRY_ASSERT (entry_p->prop_name_cp != ECMA_NULL_POINTER);
|
||||
JERRY_ASSERT (entry_p->prop_p != NULL);
|
||||
|
||||
entry_p->id = 0;
|
||||
entry_p->object_cp = ECMA_NULL_POINTER;
|
||||
ecma_set_property_lcached (entry_p->prop_p, false);
|
||||
} /* ecma_lcache_invalidate_entry */
|
||||
|
||||
@@ -74,61 +68,68 @@ ecma_lcache_invalidate_entry (ecma_lcache_hash_entry_t *entry_p) /**< entry to i
|
||||
*
|
||||
* @return row index
|
||||
*/
|
||||
static inline size_t JERRY_ATTR_ALWAYS_INLINE
|
||||
static inline size_t __attr_always_inline___
|
||||
ecma_lcache_row_index (jmem_cpointer_t object_cp, /**< compressed pointer to object */
|
||||
jmem_cpointer_t name_cp) /**< compressed pointer to property name */
|
||||
const ecma_string_t *prop_name_p) /**< proeprty name */
|
||||
{
|
||||
/* Randomize the property name with the object pointer using a xor operation,
|
||||
/* Randomize the hash of the property name with the object pointer using a xor operation,
|
||||
* so properties of different objects with the same name can be cached effectively. */
|
||||
return (size_t) (((name_cp ^ object_cp) & ECMA_LCACHE_HASH_MASK) >> ECMA_LCACHE_HASH_BITSHIFT_INDEX);
|
||||
return (size_t) ((ecma_string_hash (prop_name_p) ^ object_cp) & ECMA_LCACHE_HASH_MASK);
|
||||
} /* ecma_lcache_row_index */
|
||||
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
|
||||
|
||||
/**
|
||||
* Insert an entry into LCache
|
||||
*/
|
||||
void
|
||||
ecma_lcache_insert (const ecma_object_t *object_p, /**< object */
|
||||
const jmem_cpointer_t name_cp, /**< property name */
|
||||
ecma_lcache_insert (ecma_object_t *object_p, /**< object */
|
||||
ecma_string_t *prop_name_p, /**< property name */
|
||||
ecma_property_t *prop_p) /**< property */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (prop_name_p != NULL);
|
||||
JERRY_ASSERT (prop_p != NULL && !ecma_is_property_lcached (prop_p));
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (*prop_p));
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|
||||
|| ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
|
||||
#ifndef CONFIG_ECMA_LCACHE_DISABLE
|
||||
jmem_cpointer_t object_cp;
|
||||
|
||||
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_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH;
|
||||
size_t row_index = ecma_lcache_row_index (object_cp, prop_name_p);
|
||||
ecma_lcache_hash_entry_t *entries_p = JERRY_HASH_TABLE_CONTEXT (table)[row_index];
|
||||
|
||||
do
|
||||
int32_t entry_index;
|
||||
for (entry_index = 0; entry_index < ECMA_LCACHE_HASH_ROW_LENGTH; entry_index++)
|
||||
{
|
||||
if (entry_p->id == 0)
|
||||
if (entries_p[entry_index].object_cp == ECMA_NULL_POINTER)
|
||||
{
|
||||
goto insert;
|
||||
break;
|
||||
}
|
||||
|
||||
entry_p++;
|
||||
} while (entry_p < entry_end_p);
|
||||
|
||||
/* Invalidate the last entry. */
|
||||
ecma_lcache_invalidate_entry (--entry_p);
|
||||
|
||||
/* Shift other entries towards the end. */
|
||||
for (uint32_t i = 0; i < ECMA_LCACHE_HASH_ROW_LENGTH - 1; i++)
|
||||
{
|
||||
entry_p->id = entry_p[-1].id;
|
||||
entry_p->prop_p = entry_p[-1].prop_p;
|
||||
entry_p--;
|
||||
}
|
||||
|
||||
insert:
|
||||
if (entry_index == ECMA_LCACHE_HASH_ROW_LENGTH)
|
||||
{
|
||||
/* Invalidate the last entry. */
|
||||
ecma_lcache_invalidate_entry (entries_p + ECMA_LCACHE_HASH_ROW_LENGTH - 1);
|
||||
|
||||
/* Shift other entries towards the end. */
|
||||
for (uint32_t i = ECMA_LCACHE_HASH_ROW_LENGTH - 1; i > 0; i--)
|
||||
{
|
||||
entries_p[i] = entries_p[i - 1];
|
||||
}
|
||||
|
||||
entry_index = 0;
|
||||
}
|
||||
|
||||
ecma_lcache_hash_entry_t *entry_p = entries_p + entry_index;
|
||||
ECMA_SET_NON_NULL_POINTER (entry_p->object_cp, object_p);
|
||||
ECMA_SET_NON_NULL_POINTER (entry_p->prop_name_cp, prop_name_p);
|
||||
entry_p->prop_p = prop_p;
|
||||
entry_p->id = ECMA_LCACHE_CREATE_ID (object_cp, name_cp);
|
||||
|
||||
ecma_set_property_lcached (entry_p->prop_p, true);
|
||||
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
|
||||
} /* ecma_lcache_insert */
|
||||
|
||||
/**
|
||||
@@ -137,44 +138,49 @@ 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
|
||||
ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
|
||||
inline ecma_property_t * __attr_always_inline___
|
||||
ecma_lcache_lookup (ecma_object_t *object_p, /**< object */
|
||||
const ecma_string_t *prop_name_p) /**< property's name */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (prop_name_p != NULL);
|
||||
|
||||
#ifndef CONFIG_ECMA_LCACHE_DISABLE
|
||||
jmem_cpointer_t object_cp;
|
||||
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
|
||||
|
||||
ecma_property_t prop_name_type = ECMA_DIRECT_STRING_PTR;
|
||||
jmem_cpointer_t prop_name_cp;
|
||||
|
||||
if (JERRY_UNLIKELY (ECMA_IS_DIRECT_STRING (prop_name_p)))
|
||||
{
|
||||
prop_name_type = (ecma_property_t) ECMA_GET_DIRECT_STRING_TYPE (prop_name_p);
|
||||
prop_name_cp = (jmem_cpointer_t) ECMA_GET_DIRECT_STRING_VALUE (prop_name_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
ECMA_SET_NON_NULL_POINTER (prop_name_cp, prop_name_p);
|
||||
}
|
||||
|
||||
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];
|
||||
size_t row_index = ecma_lcache_row_index (object_cp, prop_name_p);
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_HASH_TABLE_CONTEXT (table) [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);
|
||||
ecma_string_container_t prop_container = ECMA_STRING_GET_CONTAINER (prop_name_p);
|
||||
|
||||
do
|
||||
while (entry_p < entry_end_p)
|
||||
{
|
||||
if (entry_p->id == id && JERRY_LIKELY (ECMA_PROPERTY_GET_NAME_TYPE (*entry_p->prop_p) == prop_name_type))
|
||||
if (entry_p->object_cp == object_cp)
|
||||
{
|
||||
JERRY_ASSERT (entry_p->prop_p != NULL && ecma_is_property_lcached (entry_p->prop_p));
|
||||
return entry_p->prop_p;
|
||||
ecma_string_t *entry_prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
entry_p->prop_name_cp);
|
||||
|
||||
JERRY_ASSERT ((prop_name_p->hash & ECMA_LCACHE_HASH_MASK) == (entry_prop_name_p->hash & ECMA_LCACHE_HASH_MASK));
|
||||
|
||||
if (prop_name_p == entry_prop_name_p
|
||||
|| (prop_container > ECMA_STRING_CONTAINER_HEAP_LONG_UTF8_STRING
|
||||
&& prop_container == ECMA_STRING_GET_CONTAINER (entry_prop_name_p)
|
||||
&& prop_name_p->u.common_field == entry_prop_name_p->u.common_field))
|
||||
{
|
||||
ecma_property_t *prop_p = entry_p->prop_p;
|
||||
JERRY_ASSERT (prop_p != NULL && ecma_is_property_lcached (prop_p));
|
||||
|
||||
return prop_p;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* They can be equal, but generic string comparison is too costly. */
|
||||
}
|
||||
}
|
||||
entry_p++;
|
||||
} while (entry_p < entry_end_p);
|
||||
}
|
||||
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
|
||||
|
||||
return NULL;
|
||||
} /* ecma_lcache_lookup */
|
||||
@@ -183,37 +189,41 @@ ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
|
||||
* Invalidate LCache entries associated with given object and property name / property
|
||||
*/
|
||||
void
|
||||
ecma_lcache_invalidate (const ecma_object_t *object_p, /**< object */
|
||||
const jmem_cpointer_t name_cp, /**< property name */
|
||||
ecma_lcache_invalidate (ecma_object_t *object_p, /**< object */
|
||||
ecma_string_t *prop_name_p, /**< property's name */
|
||||
ecma_property_t *prop_p) /**< property */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (prop_name_p != NULL);
|
||||
JERRY_ASSERT (prop_p != NULL && ecma_is_property_lcached (prop_p));
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (*prop_p));
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|
||||
|| ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
|
||||
#ifndef CONFIG_ECMA_LCACHE_DISABLE
|
||||
jmem_cpointer_t object_cp;
|
||||
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];
|
||||
size_t row_index = ecma_lcache_row_index (object_cp, prop_name_p);
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_HASH_TABLE_CONTEXT (table) [row_index];
|
||||
|
||||
while (true)
|
||||
for (uint32_t entry_index = 0; entry_index < ECMA_LCACHE_HASH_ROW_LENGTH; entry_index++)
|
||||
{
|
||||
/* The property must be present. */
|
||||
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)
|
||||
if (entry_p->object_cp != ECMA_NULL_POINTER && entry_p->prop_p == prop_p)
|
||||
{
|
||||
JERRY_ASSERT (entry_p->id == ECMA_LCACHE_CREATE_ID (object_cp, name_cp));
|
||||
JERRY_ASSERT (ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
entry_p->prop_name_cp) == prop_name_p);
|
||||
JERRY_ASSERT (entry_p->object_cp == object_cp);
|
||||
|
||||
ecma_lcache_invalidate_entry (entry_p);
|
||||
return;
|
||||
}
|
||||
entry_p++;
|
||||
}
|
||||
} /* ecma_lcache_invalidate */
|
||||
|
||||
#endif /* JERRY_LCACHE */
|
||||
/* The property must be present. */
|
||||
JERRY_UNREACHABLE ();
|
||||
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
|
||||
} /* ecma_lcache_invalidate */
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,14 +23,10 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#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 /* JERRY_LCACHE */
|
||||
extern void ecma_lcache_init (void);
|
||||
extern void ecma_lcache_insert (ecma_object_t *, ecma_string_t *, ecma_property_t *);
|
||||
extern ecma_property_t *ecma_lcache_lookup (ecma_object_t *, const ecma_string_t *);
|
||||
extern void ecma_lcache_invalidate (ecma_object_t *, ecma_string_t *, ecma_property_t *);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -1,271 +0,0 @@
|
||||
/* 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 */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
@@ -1,114 +0,0 @@
|
||||
/* 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 */
|
||||
@@ -1,4 +1,5 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
/* Copyright 2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 University of Szeged.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,12 +15,7 @@
|
||||
*/
|
||||
|
||||
#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
|
||||
@@ -29,127 +25,43 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_lit_storage_item_t) <= sizeof (uint64_t),
|
||||
size_of_ecma_lit_storage_item_t_must_be_less_than_or_equal_to_8_bytes);
|
||||
|
||||
/**
|
||||
* Free symbol list
|
||||
* Free string list
|
||||
*/
|
||||
static void
|
||||
ecma_free_symbol_list (jmem_cpointer_t symbol_list_cp) /**< symbol list */
|
||||
ecma_free_string_list (ecma_lit_storage_item_t *string_list_p) /**< string list */
|
||||
{
|
||||
while (symbol_list_cp != JMEM_CP_NULL)
|
||||
while (string_list_p != NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *symbol_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, symbol_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
if (symbol_list_p->values[i] != JMEM_CP_NULL)
|
||||
if (string_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,
|
||||
string_list_p->values[i]);
|
||||
|
||||
JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (string_p));
|
||||
ecma_deref_ecma_string (string_p);
|
||||
}
|
||||
}
|
||||
|
||||
jmem_cpointer_t next_item_cp = symbol_list_p->next_cp;
|
||||
jmem_pools_free (symbol_list_p, sizeof (ecma_lit_storage_item_t));
|
||||
symbol_list_cp = next_item_cp;
|
||||
}
|
||||
} /* ecma_free_symbol_list */
|
||||
|
||||
/**
|
||||
* Free string list
|
||||
*/
|
||||
static void
|
||||
ecma_free_string_list (jmem_cpointer_t string_list_cp) /**< string list */
|
||||
{
|
||||
while (string_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *string_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, string_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
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]);
|
||||
|
||||
JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (string_p));
|
||||
ecma_destroy_ecma_string (string_p);
|
||||
}
|
||||
}
|
||||
|
||||
jmem_cpointer_t next_item_cp = string_list_p->next_cp;
|
||||
jmem_pools_free (string_list_p, sizeof (ecma_lit_storage_item_t));
|
||||
string_list_cp = next_item_cp;
|
||||
ecma_lit_storage_item_t *prev_item = string_list_p;
|
||||
string_list_p = JMEM_CP_GET_POINTER (ecma_lit_storage_item_t, string_list_p->next_cp);
|
||||
jmem_pools_free (prev_item);
|
||||
}
|
||||
} /* ecma_free_string_list */
|
||||
|
||||
/**
|
||||
* Free number list
|
||||
*/
|
||||
static void
|
||||
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);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
if (number_list_p->values[i] != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_dealloc_number (JMEM_CP_GET_NON_NULL_POINTER (ecma_number_t, number_list_p->values[i]));
|
||||
}
|
||||
}
|
||||
|
||||
jmem_cpointer_t next_item_cp = number_list_p->next_cp;
|
||||
jmem_pools_free (number_list_p, sizeof (ecma_lit_storage_item_t));
|
||||
number_list_cp = next_item_cp;
|
||||
}
|
||||
} /* ecma_free_number_list */
|
||||
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
|
||||
/**
|
||||
* Free bigint list
|
||||
*/
|
||||
static void
|
||||
ecma_free_bigint_list (jmem_cpointer_t bigint_list_cp) /**< bigint list */
|
||||
{
|
||||
while (bigint_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, bigint_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
if (bigint_list_p->values[i] != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_extended_primitive_t *bigint_p =
|
||||
JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t, bigint_list_p->values[i]);
|
||||
JERRY_ASSERT (ECMA_EXTENDED_PRIMITIVE_IS_REF_EQUALS_TO_ONE (bigint_p));
|
||||
ecma_deref_bigint (bigint_p);
|
||||
}
|
||||
}
|
||||
|
||||
jmem_cpointer_t next_item_cp = bigint_list_p->next_cp;
|
||||
jmem_pools_free (bigint_list_p, sizeof (ecma_lit_storage_item_t));
|
||||
bigint_list_cp = next_item_cp;
|
||||
}
|
||||
} /* ecma_free_bigint_list */
|
||||
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
|
||||
/**
|
||||
* Finalize literal storage
|
||||
*/
|
||||
void
|
||||
ecma_finalize_lit_storage (void)
|
||||
{
|
||||
ecma_free_symbol_list (JERRY_CONTEXT (symbol_list_first_cp));
|
||||
ecma_free_string_list (JERRY_CONTEXT (string_list_first_cp));
|
||||
ecma_free_number_list (JERRY_CONTEXT (number_list_first_cp));
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
ecma_free_bigint_list (JERRY_CONTEXT (bigint_list_first_cp));
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
ecma_free_string_list (JERRY_CONTEXT (string_list_first_p));
|
||||
ecma_free_string_list (JERRY_CONTEXT (number_list_first_p));
|
||||
} /* ecma_finalize_lit_storage */
|
||||
|
||||
/**
|
||||
@@ -157,26 +69,17 @@ ecma_finalize_lit_storage (void)
|
||||
*
|
||||
* @return ecma_string_t compressed pointer
|
||||
*/
|
||||
ecma_value_t
|
||||
jmem_cpointer_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 */
|
||||
bool is_ascii) /**< encode of the string */
|
||||
lit_utf8_size_t size) /**< size of the string */
|
||||
{
|
||||
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));
|
||||
ecma_string_t *string_p = ecma_new_ecma_string_from_utf8 (chars_p, size);
|
||||
|
||||
if (ECMA_IS_DIRECT_STRING (string_p))
|
||||
{
|
||||
return ecma_make_string_value (string_p);
|
||||
}
|
||||
|
||||
jmem_cpointer_t string_list_cp = JERRY_CONTEXT (string_list_first_cp);
|
||||
ecma_lit_storage_item_t *string_list_p = JERRY_CONTEXT (string_list_first_p);
|
||||
jmem_cpointer_t *empty_cpointer_p = NULL;
|
||||
|
||||
while (string_list_cp != JMEM_CP_NULL)
|
||||
while (string_list_p != NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *string_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, string_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
if (string_list_p->values[i] == JMEM_CP_NULL)
|
||||
@@ -188,32 +91,31 @@ 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))
|
||||
{
|
||||
/* Return with string if found in the list. */
|
||||
ecma_deref_ecma_string (string_p);
|
||||
return ecma_make_string_value (value_p);
|
||||
return string_list_p->values[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string_list_cp = string_list_p->next_cp;
|
||||
string_list_p = JMEM_CP_GET_POINTER (ecma_lit_storage_item_t, string_list_p->next_cp);
|
||||
}
|
||||
|
||||
ECMA_SET_STRING_AS_STATIC (string_p);
|
||||
jmem_cpointer_t result;
|
||||
JMEM_CP_SET_NON_NULL_POINTER (result, string_p);
|
||||
|
||||
if (empty_cpointer_p != NULL)
|
||||
{
|
||||
*empty_cpointer_p = result;
|
||||
return ecma_make_string_value (string_p);
|
||||
return result;
|
||||
}
|
||||
|
||||
ecma_lit_storage_item_t *new_item_p;
|
||||
new_item_p = (ecma_lit_storage_item_t *) jmem_pools_alloc (sizeof (ecma_lit_storage_item_t));
|
||||
ecma_lit_storage_item_t *new_item_p = (ecma_lit_storage_item_t *) jmem_pools_alloc ();
|
||||
|
||||
new_item_p->values[0] = result;
|
||||
for (int i = 1; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
@@ -221,36 +123,27 @@ ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, /**< string
|
||||
new_item_p->values[i] = JMEM_CP_NULL;
|
||||
}
|
||||
|
||||
new_item_p->next_cp = JERRY_CONTEXT (string_list_first_cp);
|
||||
JMEM_CP_SET_NON_NULL_POINTER (JERRY_CONTEXT (string_list_first_cp), new_item_p);
|
||||
JMEM_CP_SET_POINTER (new_item_p->next_cp, JERRY_CONTEXT (string_list_first_p));
|
||||
JERRY_CONTEXT (string_list_first_p) = new_item_p;
|
||||
|
||||
return ecma_make_string_value (string_p);
|
||||
return result;
|
||||
} /* ecma_find_or_create_literal_string */
|
||||
|
||||
/**
|
||||
* Find or create a literal number.
|
||||
*
|
||||
* @return ecma value
|
||||
* @return ecma_string_t compressed pointer
|
||||
*/
|
||||
ecma_value_t
|
||||
jmem_cpointer_t
|
||||
ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be searched */
|
||||
{
|
||||
ecma_value_t num = ecma_make_number_value (number_arg);
|
||||
|
||||
if (ecma_is_value_integer_number (num))
|
||||
{
|
||||
return num;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_float_number (num));
|
||||
|
||||
jmem_cpointer_t number_list_cp = JERRY_CONTEXT (number_list_first_cp);
|
||||
ecma_lit_storage_item_t *number_list_p = JERRY_CONTEXT (number_list_first_p);
|
||||
jmem_cpointer_t *empty_cpointer_p = NULL;
|
||||
|
||||
while (number_list_cp != JMEM_CP_NULL)
|
||||
while (number_list_p != NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, number_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
if (number_list_p->values[i] == JMEM_CP_NULL)
|
||||
@@ -262,30 +155,47 @@ 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_string_t *value_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
number_list_p->values[i]);
|
||||
|
||||
if (*number_p == number_arg)
|
||||
JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (value_p) == ECMA_STRING_LITERAL_NUMBER);
|
||||
|
||||
if (ecma_is_value_integer_number (num))
|
||||
{
|
||||
ecma_free_value (num);
|
||||
return ecma_make_float_value (number_p);
|
||||
if (value_p->u.lit_number == num)
|
||||
{
|
||||
return number_list_p->values[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ecma_is_value_float_number (value_p->u.lit_number)
|
||||
&& ecma_get_float_from_value (value_p->u.lit_number) == ecma_get_float_from_value (num))
|
||||
{
|
||||
ecma_free_value (num);
|
||||
return number_list_p->values[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
number_list_cp = number_list_p->next_cp;
|
||||
number_list_p = JMEM_CP_GET_POINTER (ecma_lit_storage_item_t, number_list_p->next_cp);
|
||||
}
|
||||
|
||||
ecma_string_t *string_p = (ecma_string_t *) jmem_pools_alloc ();
|
||||
string_p->refs_and_container = ECMA_STRING_REF_ONE | ECMA_STRING_LITERAL_NUMBER;
|
||||
string_p->u.lit_number = num;
|
||||
|
||||
jmem_cpointer_t result;
|
||||
JMEM_CP_SET_NON_NULL_POINTER (result, ecma_get_pointer_from_float_value (num));
|
||||
JMEM_CP_SET_NON_NULL_POINTER (result, string_p);
|
||||
|
||||
if (empty_cpointer_p != NULL)
|
||||
{
|
||||
*empty_cpointer_p = result;
|
||||
return num;
|
||||
return result;
|
||||
}
|
||||
|
||||
ecma_lit_storage_item_t *new_item_p;
|
||||
new_item_p = (ecma_lit_storage_item_t *) jmem_pools_alloc (sizeof (ecma_lit_storage_item_t));
|
||||
ecma_lit_storage_item_t *new_item_p = (ecma_lit_storage_item_t *) jmem_pools_alloc ();
|
||||
|
||||
new_item_p->values[0] = result;
|
||||
for (int i = 1; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
@@ -293,447 +203,311 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
|
||||
new_item_p->values[i] = JMEM_CP_NULL;
|
||||
}
|
||||
|
||||
new_item_p->next_cp = JERRY_CONTEXT (number_list_first_cp);
|
||||
JMEM_CP_SET_NON_NULL_POINTER (JERRY_CONTEXT (number_list_first_cp), new_item_p);
|
||||
JMEM_CP_SET_POINTER (new_item_p->next_cp, JERRY_CONTEXT (number_list_first_p));
|
||||
JERRY_CONTEXT (number_list_first_p) = new_item_p;
|
||||
|
||||
return num;
|
||||
return result;
|
||||
} /* ecma_find_or_create_literal_number */
|
||||
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
|
||||
/**
|
||||
* Find or create a literal BigInt.
|
||||
*
|
||||
* @return BigInt value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searched */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_bigint (bigint));
|
||||
|
||||
if (bigint == ECMA_BIGINT_ZERO)
|
||||
{
|
||||
return bigint;
|
||||
}
|
||||
|
||||
jmem_cpointer_t bigint_list_cp = JERRY_CONTEXT (bigint_list_first_cp);
|
||||
jmem_cpointer_t *empty_cpointer_p = NULL;
|
||||
|
||||
while (bigint_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, bigint_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
if (bigint_list_p->values[i] == JMEM_CP_NULL)
|
||||
{
|
||||
if (empty_cpointer_p == NULL)
|
||||
{
|
||||
empty_cpointer_p = bigint_list_p->values + i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_extended_primitive_t *other_bigint_p =
|
||||
JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t, bigint_list_p->values[i]);
|
||||
ecma_value_t other_bigint = ecma_make_extended_primitive_value (other_bigint_p, ECMA_TYPE_BIGINT);
|
||||
|
||||
if (ecma_bigint_is_equal_to_bigint (bigint, other_bigint))
|
||||
{
|
||||
ecma_free_value (bigint);
|
||||
return other_bigint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bigint_list_cp = bigint_list_p->next_cp;
|
||||
}
|
||||
|
||||
jmem_cpointer_t result;
|
||||
JMEM_CP_SET_NON_NULL_POINTER (result, ecma_get_extended_primitive_from_value (bigint));
|
||||
|
||||
if (empty_cpointer_p != NULL)
|
||||
{
|
||||
*empty_cpointer_p = result;
|
||||
return bigint;
|
||||
}
|
||||
|
||||
ecma_lit_storage_item_t *new_item_p;
|
||||
new_item_p = (ecma_lit_storage_item_t *) jmem_pools_alloc (sizeof (ecma_lit_storage_item_t));
|
||||
|
||||
new_item_p->values[0] = result;
|
||||
for (int i = 1; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
new_item_p->values[i] = JMEM_CP_NULL;
|
||||
}
|
||||
|
||||
new_item_p->next_cp = JERRY_CONTEXT (bigint_list_first_cp);
|
||||
JMEM_CP_SET_NON_NULL_POINTER (JERRY_CONTEXT (bigint_list_first_cp), new_item_p);
|
||||
|
||||
return bigint;
|
||||
} /* ecma_find_or_create_literal_bigint */
|
||||
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
|
||||
/**
|
||||
* Log2 of snapshot literal alignment.
|
||||
*/
|
||||
#define JERRY_SNAPSHOT_LITERAL_ALIGNMENT_LOG 1
|
||||
#define JERRY_SNAPSHOT_LITERAL_ALIGNMENT_LOG 2
|
||||
|
||||
/**
|
||||
* Snapshot literal alignment.
|
||||
*/
|
||||
#define JERRY_SNAPSHOT_LITERAL_ALIGNMENT (1u << JERRY_SNAPSHOT_LITERAL_ALIGNMENT_LOG)
|
||||
|
||||
/**
|
||||
* Literal offset shift.
|
||||
*/
|
||||
#define JERRY_SNAPSHOT_LITERAL_SHIFT (ECMA_VALUE_SHIFT + 2)
|
||||
|
||||
/**
|
||||
* Literal value is number.
|
||||
*/
|
||||
#define JERRY_SNAPSHOT_LITERAL_IS_NUMBER (1u << ECMA_VALUE_SHIFT)
|
||||
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
/**
|
||||
* Literal value is BigInt.
|
||||
*/
|
||||
#define JERRY_SNAPSHOT_LITERAL_IS_BIGINT (2u << ECMA_VALUE_SHIFT)
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
|
||||
#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 */
|
||||
{
|
||||
/* Unlike direct numbers, direct strings are converted to character literals. */
|
||||
if (!ecma_is_value_string (value)
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
&& (!ecma_is_value_bigint (value) || value == ECMA_BIGINT_ZERO)
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
&& !ecma_is_value_float_number (value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ecma_value_t *buffer_p = lit_pool_p->buffer_p;
|
||||
|
||||
for (uint32_t i = 0; i < lit_pool_p->item_count; i++)
|
||||
{
|
||||
/* Strings / numbers are direct strings or stored in the literal storage.
|
||||
* Therefore direct comparison is enough to find the same strings / numbers. */
|
||||
if (buffer_p[i] == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ecma_collection_push_back (lit_pool_p, value);
|
||||
} /* ecma_save_literals_append_value */
|
||||
|
||||
/**
|
||||
* Add names from a byte-code data to a list.
|
||||
*/
|
||||
void
|
||||
ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, /**< byte-code data */
|
||||
ecma_collection_t *lit_pool_p) /**< list of known values */
|
||||
{
|
||||
ecma_value_t *literal_p;
|
||||
uint32_t argument_end;
|
||||
uint32_t register_end;
|
||||
uint32_t const_literal_end;
|
||||
uint32_t literal_end;
|
||||
|
||||
JERRY_ASSERT (CBC_IS_FUNCTION (compiled_code_p->status_flags));
|
||||
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
|
||||
{
|
||||
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) compiled_code_p;
|
||||
uint8_t *byte_p = (uint8_t *) compiled_code_p;
|
||||
|
||||
literal_p = (ecma_value_t *) (byte_p + sizeof (cbc_uint16_arguments_t));
|
||||
register_end = args_p->register_end;
|
||||
const_literal_end = args_p->const_literal_end - register_end;
|
||||
literal_end = args_p->literal_end - register_end;
|
||||
argument_end = args_p->argument_end;
|
||||
}
|
||||
else
|
||||
{
|
||||
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) compiled_code_p;
|
||||
uint8_t *byte_p = (uint8_t *) compiled_code_p;
|
||||
|
||||
literal_p = (ecma_value_t *) (byte_p + sizeof (cbc_uint8_arguments_t));
|
||||
register_end = args_p->register_end;
|
||||
const_literal_end = args_p->const_literal_end - register_end;
|
||||
literal_end = args_p->literal_end - register_end;
|
||||
argument_end = args_p->argument_end;
|
||||
}
|
||||
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_MAPPED_ARGUMENTS_NEEDED)
|
||||
{
|
||||
for (uint32_t i = 0; i < argument_end; i++)
|
||||
{
|
||||
ecma_save_literals_append_value (literal_p[i], lit_pool_p);
|
||||
}
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < const_literal_end; i++)
|
||||
{
|
||||
ecma_save_literals_append_value (literal_p[i], lit_pool_p);
|
||||
}
|
||||
|
||||
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]);
|
||||
|
||||
if (CBC_IS_FUNCTION (bytecode_p->status_flags) && bytecode_p != compiled_code_p)
|
||||
{
|
||||
ecma_save_literals_add_compiled_code (bytecode_p, lit_pool_p);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t *byte_p = ((uint8_t *) compiled_code_p) + (((size_t) compiled_code_p->size) << JMEM_ALIGNMENT_LOG);
|
||||
literal_p = ecma_snapshot_resolve_serializable_values ((ecma_compiled_code_t *) compiled_code_p, byte_p);
|
||||
|
||||
while (literal_p < (ecma_value_t *) byte_p)
|
||||
{
|
||||
ecma_save_literals_append_value (*literal_p, lit_pool_p);
|
||||
literal_p++;
|
||||
}
|
||||
} /* ecma_save_literals_add_compiled_code */
|
||||
#ifdef JERRY_ENABLE_SNAPSHOT_SAVE
|
||||
|
||||
/**
|
||||
* Save literals to specified snapshot buffer.
|
||||
*
|
||||
* Note:
|
||||
* Frees 'lit_pool_p' regardless of success.
|
||||
*
|
||||
* @return true - if save was performed successfully (i.e. buffer size is sufficient),
|
||||
* false - otherwise
|
||||
* @return true, if save was performed successfully (i.e. buffer size is sufficient),
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool
|
||||
ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, /**< list of known values */
|
||||
uint32_t *buffer_p, /**< [out] output snapshot buffer */
|
||||
ecma_save_literals_for_snapshot (uint8_t *buffer_p, /**< [out] output snapshot buffer */
|
||||
size_t buffer_size, /**< size of the buffer */
|
||||
size_t *in_out_buffer_offset_p, /**< [in,out] write position in the buffer */
|
||||
lit_mem_to_snapshot_id_map_entry_t **out_map_p, /**< [out] map from literal identifiers
|
||||
* to the literal offsets
|
||||
* in snapshot */
|
||||
uint32_t *out_map_len_p) /**< [out] number of literals */
|
||||
uint32_t *out_map_len_p, /**< [out] number of literals */
|
||||
uint32_t *out_lit_table_size_p) /**< [out] number of bytes, saved to snapshot buffer */
|
||||
{
|
||||
if (lit_pool_p->item_count == 0)
|
||||
/* Count literals and literal space. */
|
||||
uint32_t string_count = 0;
|
||||
uint32_t number_count = 0;
|
||||
uint32_t lit_table_size = 2 * sizeof (uint32_t);
|
||||
|
||||
ecma_lit_storage_item_t *string_list_p = JERRY_CONTEXT (string_list_first_p);
|
||||
|
||||
while (string_list_p != NULL)
|
||||
{
|
||||
*out_map_p = NULL;
|
||||
*out_map_len_p = 0;
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
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]);
|
||||
|
||||
lit_table_size += (uint32_t) JERRY_ALIGNUP (sizeof (uint16_t) + ecma_string_get_size (string_p),
|
||||
JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
|
||||
string_count++;
|
||||
}
|
||||
}
|
||||
|
||||
string_list_p = JMEM_CP_GET_POINTER (ecma_lit_storage_item_t, string_list_p->next_cp);
|
||||
}
|
||||
|
||||
uint32_t lit_table_size = 0;
|
||||
size_t max_lit_table_size = buffer_size - *in_out_buffer_offset_p;
|
||||
ecma_lit_storage_item_t *number_list_p = JERRY_CONTEXT (number_list_first_p);
|
||||
|
||||
if (max_lit_table_size > (UINT32_MAX >> JERRY_SNAPSHOT_LITERAL_SHIFT))
|
||||
while (number_list_p != NULL)
|
||||
{
|
||||
max_lit_table_size = (UINT32_MAX >> JERRY_SNAPSHOT_LITERAL_SHIFT);
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
if (number_list_p->values[i] != JMEM_CP_NULL)
|
||||
{
|
||||
lit_table_size += (uint32_t) sizeof (ecma_number_t);
|
||||
number_count++;
|
||||
}
|
||||
}
|
||||
|
||||
number_list_p = JMEM_CP_GET_POINTER (ecma_lit_storage_item_t, number_list_p->next_cp);
|
||||
}
|
||||
|
||||
ecma_value_t *lit_buffer_p = lit_pool_p->buffer_p;
|
||||
|
||||
/* Compute the size of the literal pool. */
|
||||
for (uint32_t i = 0; i < lit_pool_p->item_count; i++)
|
||||
/* Check whether enough space is available. */
|
||||
if (*in_out_buffer_offset_p + lit_table_size > buffer_size)
|
||||
{
|
||||
if (ecma_is_value_float_number (lit_buffer_p[i]))
|
||||
{
|
||||
lit_table_size += (uint32_t) sizeof (ecma_number_t);
|
||||
}
|
||||
#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]);
|
||||
|
||||
lit_table_size += (uint32_t) JERRY_ALIGNUP (sizeof (uint32_t) + ECMA_BIGINT_GET_SIZE (bigint_p),
|
||||
JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
else
|
||||
{
|
||||
ecma_string_t *string_p = ecma_get_string_from_value (lit_buffer_p[i]);
|
||||
|
||||
lit_table_size += (uint32_t) JERRY_ALIGNUP (sizeof (uint16_t) + ecma_string_get_size (string_p),
|
||||
JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
|
||||
}
|
||||
|
||||
/* Check whether enough space is available and the maximum size is not reached. */
|
||||
if (lit_table_size > max_lit_table_size)
|
||||
{
|
||||
ecma_collection_destroy (lit_pool_p);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Check whether the maximum literal table size is reached. */
|
||||
if ((lit_table_size >> JERRY_SNAPSHOT_LITERAL_ALIGNMENT_LOG) > UINT16_MAX)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t total_count = string_count + number_count;
|
||||
lit_mem_to_snapshot_id_map_entry_t *map_p;
|
||||
uint32_t total_count = lit_pool_p->item_count;
|
||||
|
||||
map_p = jmem_heap_alloc_block (total_count * sizeof (lit_mem_to_snapshot_id_map_entry_t));
|
||||
|
||||
/* Set return values (no error is possible from here). */
|
||||
JERRY_ASSERT ((*in_out_buffer_offset_p % sizeof (uint32_t)) == 0);
|
||||
|
||||
uint8_t *destination_p = (uint8_t *) (buffer_p + (*in_out_buffer_offset_p / sizeof (uint32_t)));
|
||||
uint32_t literal_offset = 0;
|
||||
|
||||
buffer_p += *in_out_buffer_offset_p;
|
||||
*in_out_buffer_offset_p += lit_table_size;
|
||||
*out_map_p = map_p;
|
||||
*out_map_len_p = total_count;
|
||||
*out_lit_table_size_p = lit_table_size;
|
||||
|
||||
lit_buffer_p = lit_pool_p->buffer_p;
|
||||
/* Write data into the buffer. */
|
||||
|
||||
/* Generate literal pool data. */
|
||||
for (uint32_t i = 0; i < lit_pool_p->item_count; i++)
|
||||
/* The zero value is reserved for NULL (no literal)
|
||||
* constant so the first literal must have offset one. */
|
||||
uint32_t literal_offset = JERRY_SNAPSHOT_LITERAL_ALIGNMENT;
|
||||
|
||||
((uint32_t *) buffer_p)[0] = string_count;
|
||||
((uint32_t *) buffer_p)[1] = number_count;
|
||||
buffer_p += 2 * sizeof (uint32_t);
|
||||
|
||||
string_list_p = JERRY_CONTEXT (string_list_first_p);
|
||||
|
||||
while (string_list_p != NULL)
|
||||
{
|
||||
map_p->literal_id = lit_buffer_p[i];
|
||||
map_p->literal_offset = (literal_offset << JERRY_SNAPSHOT_LITERAL_SHIFT) | ECMA_TYPE_SNAPSHOT_OFFSET;
|
||||
|
||||
lit_utf8_size_t length;
|
||||
|
||||
if (ecma_is_value_float_number (lit_buffer_p[i]))
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
map_p->literal_offset |= JERRY_SNAPSHOT_LITERAL_IS_NUMBER;
|
||||
if (string_list_p->values[i] != JMEM_CP_NULL)
|
||||
{
|
||||
map_p->literal_id = string_list_p->values[i];
|
||||
map_p->literal_offset = (jmem_cpointer_t) (literal_offset >> JERRY_SNAPSHOT_LITERAL_ALIGNMENT_LOG);
|
||||
map_p++;
|
||||
|
||||
ecma_number_t num = ecma_get_float_from_value (lit_buffer_p[i]);
|
||||
memcpy (destination_p, &num, sizeof (ecma_number_t));
|
||||
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
string_list_p->values[i]);
|
||||
|
||||
length = JERRY_ALIGNUP (sizeof (ecma_number_t), JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
|
||||
}
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
else if (ecma_is_value_bigint (lit_buffer_p[i]))
|
||||
{
|
||||
map_p->literal_offset |= JERRY_SNAPSHOT_LITERAL_IS_BIGINT;
|
||||
ecma_length_t length = ecma_string_get_size (string_p);
|
||||
|
||||
ecma_extended_primitive_t *bigint_p = ecma_get_extended_primitive_from_value (lit_buffer_p[i]);
|
||||
uint32_t size = ECMA_BIGINT_GET_SIZE (bigint_p);
|
||||
*((uint16_t *) buffer_p) = (uint16_t) length;
|
||||
ecma_string_to_utf8_bytes (string_p, buffer_p + sizeof (uint16_t), length);
|
||||
|
||||
memcpy (destination_p, &bigint_p->u.bigint_sign_and_size, sizeof (uint32_t));
|
||||
memcpy (destination_p + sizeof (uint32_t), ECMA_BIGINT_GET_DIGITS (bigint_p, 0), size);
|
||||
length = JERRY_ALIGNUP (sizeof (uint16_t) + length,
|
||||
JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
|
||||
|
||||
length = JERRY_ALIGNUP (sizeof (uint32_t) + size, JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
else
|
||||
{
|
||||
ecma_string_t *string_p = ecma_get_string_from_value (lit_buffer_p[i]);
|
||||
length = ecma_string_get_size (string_p);
|
||||
|
||||
*(uint16_t *) destination_p = (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);
|
||||
buffer_p += length;
|
||||
literal_offset += length;
|
||||
}
|
||||
}
|
||||
|
||||
JERRY_ASSERT ((length % sizeof (uint16_t)) == 0);
|
||||
destination_p += length;
|
||||
literal_offset += length;
|
||||
|
||||
map_p++;
|
||||
string_list_p = JMEM_CP_GET_POINTER (ecma_lit_storage_item_t, string_list_p->next_cp);
|
||||
}
|
||||
|
||||
number_list_p = JERRY_CONTEXT (number_list_first_p);
|
||||
|
||||
while (number_list_p != NULL)
|
||||
{
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
if (number_list_p->values[i] != JMEM_CP_NULL)
|
||||
{
|
||||
map_p->literal_id = number_list_p->values[i];
|
||||
map_p->literal_offset = (jmem_cpointer_t) (literal_offset >> JERRY_SNAPSHOT_LITERAL_ALIGNMENT_LOG);
|
||||
map_p++;
|
||||
|
||||
ecma_string_t *value_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
number_list_p->values[i]);
|
||||
|
||||
JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (value_p) == ECMA_STRING_LITERAL_NUMBER);
|
||||
|
||||
ecma_number_t num = ecma_get_number_from_value (value_p->u.lit_number);
|
||||
memcpy (buffer_p, &num, sizeof (ecma_number_t));
|
||||
|
||||
ecma_length_t length = JERRY_ALIGNUP (sizeof (ecma_number_t),
|
||||
JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
|
||||
|
||||
buffer_p += length;
|
||||
literal_offset += length;
|
||||
}
|
||||
}
|
||||
|
||||
number_list_p = JMEM_CP_GET_POINTER (ecma_lit_storage_item_t, number_list_p->next_cp);
|
||||
}
|
||||
|
||||
ecma_collection_destroy (lit_pool_p);
|
||||
return true;
|
||||
} /* ecma_save_literals_for_snapshot */
|
||||
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
#endif /* JERRY_ENABLE_SNAPSHOT_SAVE */
|
||||
|
||||
#if JERRY_SNAPSHOT_EXEC || JERRY_SNAPSHOT_SAVE
|
||||
#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
|
||||
|
||||
/**
|
||||
* Get the compressed pointer of a given literal.
|
||||
* Helper function for ecma_load_literals_from_snapshot.
|
||||
*
|
||||
* @return literal compressed pointer
|
||||
* Note: always inline because it is used only once.
|
||||
*
|
||||
* @return true, if load was performed successfully
|
||||
* false - otherwise (i.e. buffer length is incorrect).
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_snapshot_get_literal (const uint8_t *literal_base_p, /**< literal start */
|
||||
ecma_value_t literal_value) /**< string / number offset */
|
||||
static inline bool __attr_always_inline___
|
||||
ecma_load_literals_from_buffer (const uint8_t *buffer_p, /**< buffer with literal table in snapshot */
|
||||
uint32_t lit_table_size, /**< size of literal table in snapshot */
|
||||
lit_mem_to_snapshot_id_map_entry_t *map_p, /**< literal map */
|
||||
uint32_t string_count, /**< number of strings */
|
||||
uint32_t number_count) /**< number of numbers */
|
||||
{
|
||||
JERRY_ASSERT ((literal_value & ECMA_VALUE_TYPE_MASK) == ECMA_TYPE_SNAPSHOT_OFFSET);
|
||||
/* The zero value is reserved for NULL (no literal)
|
||||
* constant so the first literal must have offset one. */
|
||||
uint32_t literal_offset = JERRY_SNAPSHOT_LITERAL_ALIGNMENT;
|
||||
|
||||
const uint8_t *literal_p = literal_base_p + (literal_value >> JERRY_SNAPSHOT_LITERAL_SHIFT);
|
||||
|
||||
if (literal_value & JERRY_SNAPSHOT_LITERAL_IS_NUMBER)
|
||||
/* Load strings first. */
|
||||
while (string_count > 0)
|
||||
{
|
||||
if (lit_table_size < literal_offset + sizeof (uint32_t))
|
||||
{
|
||||
/* Buffer is not sufficent. */
|
||||
return false;
|
||||
}
|
||||
|
||||
lit_utf8_size_t length = *((uint16_t *) buffer_p);
|
||||
lit_utf8_size_t aligned_length = JERRY_ALIGNUP (sizeof (uint16_t) + length,
|
||||
JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
|
||||
|
||||
if (lit_table_size < literal_offset + aligned_length)
|
||||
{
|
||||
/* Buffer is not sufficent. */
|
||||
return false;
|
||||
}
|
||||
|
||||
map_p->literal_id = ecma_find_or_create_literal_string (buffer_p + sizeof (uint16_t), length);
|
||||
map_p->literal_offset = (jmem_cpointer_t) (literal_offset >> JERRY_SNAPSHOT_LITERAL_ALIGNMENT_LOG);
|
||||
map_p++;
|
||||
|
||||
buffer_p += aligned_length;
|
||||
literal_offset += aligned_length;
|
||||
|
||||
string_count--;
|
||||
}
|
||||
|
||||
/* Load numbers. */
|
||||
while (number_count > 0)
|
||||
{
|
||||
if (lit_table_size < literal_offset + sizeof (ecma_number_t))
|
||||
{
|
||||
/* Buffer is not sufficent. */
|
||||
return false;
|
||||
}
|
||||
|
||||
ecma_number_t num;
|
||||
memcpy (&num, literal_p, sizeof (ecma_number_t));
|
||||
return ecma_find_or_create_literal_number (num);
|
||||
memcpy (&num, buffer_p, sizeof (ecma_number_t));
|
||||
|
||||
map_p->literal_id = ecma_find_or_create_literal_number (num);
|
||||
map_p->literal_offset = (jmem_cpointer_t) (literal_offset >> JERRY_SNAPSHOT_LITERAL_ALIGNMENT_LOG);
|
||||
map_p++;
|
||||
|
||||
ecma_length_t length = JERRY_ALIGNUP (sizeof (ecma_number_t),
|
||||
JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
|
||||
|
||||
buffer_p += length;
|
||||
literal_offset += length;
|
||||
|
||||
number_count--;
|
||||
}
|
||||
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
if (literal_value & JERRY_SNAPSHOT_LITERAL_IS_BIGINT)
|
||||
{
|
||||
uint32_t bigint_sign_and_size = *(uint32_t *) literal_p;
|
||||
uint32_t size = bigint_sign_and_size & ~(uint32_t) (sizeof (ecma_bigint_digit_t) - 1);
|
||||
|
||||
ecma_extended_primitive_t *bigint_p = ecma_bigint_create (size);
|
||||
|
||||
if (bigint_p == NULL)
|
||||
{
|
||||
jerry_fatal (JERRY_FATAL_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
/* Only the sign bit can differ. */
|
||||
JERRY_ASSERT (bigint_p->u.bigint_sign_and_size == (bigint_sign_and_size & ~(uint32_t) ECMA_BIGINT_SIGN));
|
||||
|
||||
bigint_p->u.bigint_sign_and_size = bigint_sign_and_size;
|
||||
memcpy (ECMA_BIGINT_GET_DIGITS (bigint_p, 0), literal_p + sizeof (uint32_t), size);
|
||||
return ecma_find_or_create_literal_bigint (ecma_make_extended_primitive_value (bigint_p, ECMA_TYPE_BIGINT));
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
|
||||
uint16_t length = *(const uint16_t *) literal_p;
|
||||
|
||||
return ecma_find_or_create_literal_string (literal_p + sizeof (uint16_t), length, false);
|
||||
} /* ecma_snapshot_get_literal */
|
||||
return (lit_table_size == (literal_offset + 2 * sizeof (uint32_t) - JERRY_SNAPSHOT_LITERAL_ALIGNMENT));
|
||||
} /* ecma_load_literals_from_buffer */
|
||||
|
||||
/**
|
||||
* 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
|
||||
* Load literals from snapshot.
|
||||
*
|
||||
* @return pointer to the beginning of the serializable ecma-values
|
||||
* @return true, if load was performed successfully (i.e. literals saved in the snapshot are consistent),
|
||||
* false - otherwise (i.e. snapshot is incorrect).
|
||||
*/
|
||||
ecma_value_t *
|
||||
ecma_snapshot_resolve_serializable_values (const ecma_compiled_code_t *compiled_code_p, /**< compiled code */
|
||||
uint8_t *bytecode_end_p) /**< end of the bytecode */
|
||||
bool
|
||||
ecma_load_literals_from_snapshot (const uint8_t *buffer_p, /**< buffer with literal table in snapshot */
|
||||
uint32_t lit_table_size, /**< size of literal table in snapshot */
|
||||
lit_mem_to_snapshot_id_map_entry_t **out_map_p, /**< [out] map from literal offsets
|
||||
* in snapshot to identifiers
|
||||
* of loaded literals in literal
|
||||
* storage */
|
||||
uint32_t *out_map_len_p) /**< [out] literals number */
|
||||
{
|
||||
ecma_value_t *base_p = (ecma_value_t *) bytecode_end_p;
|
||||
*out_map_p = NULL;
|
||||
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_MAPPED_ARGUMENTS_NEEDED)
|
||||
if (lit_table_size < 2 * sizeof (uint32_t))
|
||||
{
|
||||
uint32_t argument_end;
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
|
||||
{
|
||||
argument_end = ((cbc_uint16_arguments_t *) compiled_code_p)->argument_end;
|
||||
}
|
||||
else
|
||||
{
|
||||
argument_end = ((cbc_uint8_arguments_t *) compiled_code_p)->argument_end;
|
||||
}
|
||||
|
||||
base_p -= argument_end;
|
||||
/* Buffer is not sufficent. */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* function name */
|
||||
if (CBC_FUNCTION_GET_TYPE (compiled_code_p->status_flags) != CBC_FUNCTION_CONSTRUCTOR)
|
||||
uint32_t string_count = ((uint32_t *) buffer_p)[0];
|
||||
uint32_t number_count = ((uint32_t *) buffer_p)[1];
|
||||
buffer_p += 2 * sizeof (uint32_t);
|
||||
|
||||
uint32_t total_count = string_count + number_count;
|
||||
lit_mem_to_snapshot_id_map_entry_t *map_p;
|
||||
|
||||
*out_map_len_p = total_count;
|
||||
|
||||
if (total_count == 0)
|
||||
{
|
||||
base_p--;
|
||||
return true;
|
||||
}
|
||||
|
||||
return base_p;
|
||||
} /* ecma_snapshot_resolve_serializable_values */
|
||||
#endif /* JERRY_SNAPSHOT_EXEC || JERRY_SNAPSHOT_SAVE */
|
||||
map_p = jmem_heap_alloc_block (total_count * sizeof (lit_mem_to_snapshot_id_map_entry_t));
|
||||
*out_map_p = map_p;
|
||||
|
||||
if (ecma_load_literals_from_buffer (buffer_p, lit_table_size, map_p, string_count, number_count))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
jmem_heap_free_block (map_p, total_count * sizeof (lit_mem_to_snapshot_id_map_entry_t));
|
||||
*out_map_p = NULL;
|
||||
return false;
|
||||
} /* ecma_load_literals_from_snapshot */
|
||||
|
||||
#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
/* Copyright 2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 University of Szeged.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,8 +18,7 @@
|
||||
#define ECMA_LIT_STORAGE_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
#include "jmem-allocator.h"
|
||||
#include "lit-globals.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -28,41 +28,31 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if JERRY_SNAPSHOT_SAVE
|
||||
/**
|
||||
* Snapshot literal - offset map
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ecma_value_t literal_id; /**< literal id */
|
||||
ecma_value_t literal_offset; /**< literal offset */
|
||||
jmem_cpointer_t literal_id; /**< literal id */
|
||||
jmem_cpointer_t literal_offset; /**< literal offset */
|
||||
} lit_mem_to_snapshot_id_map_entry_t;
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
|
||||
void ecma_finalize_lit_storage (void);
|
||||
extern 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, bool is_ascii);
|
||||
ecma_value_t ecma_find_or_create_literal_number (ecma_number_t number_arg);
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
ecma_value_t ecma_find_or_create_literal_bigint (ecma_value_t bigint);
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
extern jmem_cpointer_t ecma_find_or_create_literal_string (const lit_utf8_byte_t *, lit_utf8_size_t);
|
||||
extern jmem_cpointer_t ecma_find_or_create_literal_number (ecma_number_t);
|
||||
|
||||
#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,
|
||||
uint32_t *out_map_len_p);
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
#ifdef JERRY_ENABLE_SNAPSHOT_SAVE
|
||||
extern bool
|
||||
ecma_save_literals_for_snapshot (uint8_t *, size_t, size_t *,
|
||||
lit_mem_to_snapshot_id_map_entry_t **, uint32_t *, uint32_t *);
|
||||
#endif /* JERRY_ENABLE_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 */
|
||||
#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
|
||||
extern bool
|
||||
ecma_load_literals_from_snapshot (const uint8_t *, uint32_t,
|
||||
lit_mem_to_snapshot_id_map_entry_t **, uint32_t *);
|
||||
#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,132 +0,0 @@
|
||||
/* 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_MODULE_H
|
||||
#define ECMA_MODULE_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#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
|
||||
* and https://www.ecma-international.org/ecma-262/6.0/#table-41
|
||||
*/
|
||||
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_module_names_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 */
|
||||
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 */
|
||||
ecma_module_names_t *module_names_p; /**< names of the requested import/export node */
|
||||
|
||||
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
|
||||
*/
|
||||
typedef struct ecma_module_resolve_set
|
||||
{
|
||||
struct ecma_module_resolve_set *next_p; /**< next in linked list */
|
||||
ecma_module_t *module_p; /**< module */
|
||||
ecma_string_t *name_p; /**< identifier name */
|
||||
} ecma_module_resolve_set_t;
|
||||
|
||||
/**
|
||||
* A list that is used like a stack to drive the resolution process, instead of recursion.
|
||||
*/
|
||||
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_resolve_stack_t;
|
||||
|
||||
ecma_value_t ecma_module_initialize (ecma_module_t *module_p);
|
||||
ecma_module_t *ecma_module_get_resolved_module (ecma_value_t module_val);
|
||||
|
||||
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_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 */
|
||||
@@ -1,4 +1,5 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 University of Szeged.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,12 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-property-hashmap.h"
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "ecma-property-hashmap.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@@ -28,7 +26,7 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
#ifndef CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE
|
||||
|
||||
/**
|
||||
* Compute the total size of the property hashmap.
|
||||
@@ -44,26 +42,30 @@
|
||||
/**
|
||||
* 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_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))))
|
||||
|
||||
#endif /* !CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
|
||||
|
||||
/**
|
||||
* Create a new property hashmap for the object.
|
||||
@@ -72,39 +74,29 @@ static const uint8_t ecma_property_hashmap_steps[ECMA_PROPERTY_HASHMAP_NUMBER_OF
|
||||
void
|
||||
ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
if (JERRY_CONTEXT (ecma_prop_hashmap_alloc_state) != ECMA_PROP_HASHMAP_ALLOC_ON)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
jmem_cpointer_t prop_iter_cp = object_p->u1.property_list_cp;
|
||||
|
||||
if (prop_iter_cp == JMEM_CP_NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#ifndef CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE
|
||||
JERRY_ASSERT (ecma_get_property_list (object_p) != NULL);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (ecma_get_property_list (object_p)));
|
||||
|
||||
uint32_t named_property_count = 0;
|
||||
|
||||
while (prop_iter_cp != JMEM_CP_NULL)
|
||||
ecma_property_header_t *prop_iter_p = ecma_get_property_list (object_p);
|
||||
|
||||
while (prop_iter_p != NULL)
|
||||
{
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
|
||||
|
||||
for (int i = 0; i < ECMA_PROPERTY_PAIR_ITEM_COUNT; i++)
|
||||
{
|
||||
if (prop_iter_p->types[i] != ECMA_PROPERTY_TYPE_DELETED)
|
||||
ecma_property_types_t type = ECMA_PROPERTY_GET_TYPE (prop_iter_p->types + i);
|
||||
|
||||
if (type == ECMA_PROPERTY_TYPE_NAMEDDATA || type == ECMA_PROPERTY_TYPE_NAMEDACCESSOR)
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[i]));
|
||||
named_property_count++;
|
||||
}
|
||||
}
|
||||
prop_iter_cp = prop_iter_p->next_property_cp;
|
||||
}
|
||||
|
||||
if (named_property_count < (ECMA_PROPERTY_HASMAP_MINIMUM_SIZE / 2))
|
||||
{
|
||||
return;
|
||||
prop_iter_p = ECMA_GET_POINTER (ecma_property_header_t,
|
||||
prop_iter_p->next_property_cp);
|
||||
}
|
||||
|
||||
/* The max_property_count must be power of 2. */
|
||||
@@ -127,39 +119,65 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */
|
||||
|
||||
memset (hashmap_p, 0, total_size);
|
||||
|
||||
hashmap_p->header.types[0] = ECMA_PROPERTY_TYPE_HASHMAP;
|
||||
hashmap_p->header.next_property_cp = object_p->u1.property_list_cp;
|
||||
hashmap_p->header.types[0].type_and_flags = ECMA_PROPERTY_TYPE_HASHMAP;
|
||||
hashmap_p->header.next_property_cp = object_p->property_list_or_bound_object_cp;
|
||||
hashmap_p->max_property_count = max_property_count;
|
||||
hashmap_p->null_count = max_property_count - named_property_count;
|
||||
hashmap_p->unused_count = max_property_count - named_property_count;
|
||||
|
||||
jmem_cpointer_t *pair_list_p = (jmem_cpointer_t *) (hashmap_p + 1);
|
||||
uint8_t *bits_p = (uint8_t *) (pair_list_p + max_property_count);
|
||||
uint32_t mask = max_property_count - 1;
|
||||
|
||||
prop_iter_cp = object_p->u1.property_list_cp;
|
||||
ECMA_SET_NON_NULL_POINTER (object_p->u1.property_list_cp, hashmap_p);
|
||||
uint8_t shift_counter = 0;
|
||||
|
||||
while (prop_iter_cp != JMEM_CP_NULL)
|
||||
if (max_property_count <= LIT_STRING_HASH_LIMIT)
|
||||
{
|
||||
hashmap_p->header.types[1].type_and_flags = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (max_property_count > LIT_STRING_HASH_LIMIT)
|
||||
{
|
||||
shift_counter++;
|
||||
max_property_count >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
hashmap_p->header.types[1].type_and_flags = shift_counter;
|
||||
|
||||
prop_iter_p = ecma_get_property_list (object_p);
|
||||
ECMA_SET_POINTER (object_p->property_list_or_bound_object_cp, hashmap_p);
|
||||
|
||||
while (prop_iter_p != NULL)
|
||||
{
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
|
||||
|
||||
for (int i = 0; i < ECMA_PROPERTY_PAIR_ITEM_COUNT; i++)
|
||||
{
|
||||
if (prop_iter_p->types[i] == ECMA_PROPERTY_TYPE_DELETED)
|
||||
ecma_property_types_t type = ECMA_PROPERTY_GET_TYPE (prop_iter_p->types + i);
|
||||
|
||||
if (!(type == ECMA_PROPERTY_TYPE_NAMEDDATA || type == ECMA_PROPERTY_TYPE_NAMEDACCESSOR))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[i]));
|
||||
|
||||
ecma_property_pair_t *property_pair_p = (ecma_property_pair_t *) prop_iter_p;
|
||||
ecma_string_t *name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
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 entry_index = name_p->hash;
|
||||
uint32_t step = ecma_property_hashmap_steps[entry_index & (ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS - 1)];
|
||||
|
||||
entry_index &= mask;
|
||||
if (mask < LIT_STRING_HASH_LIMIT)
|
||||
{
|
||||
entry_index &= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
entry_index <<= shift_counter;
|
||||
JERRY_ASSERT (entry_index <= mask);
|
||||
}
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
/* Because max_property_count (power of 2) and step (a prime
|
||||
* number) are relative primes, all entries of the hasmap are
|
||||
@@ -179,7 +197,7 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
}
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER (pair_list_p[entry_index], property_pair_p);
|
||||
ECMA_SET_POINTER (pair_list_p[entry_index], property_pair_p);
|
||||
|
||||
if (i != 0)
|
||||
{
|
||||
@@ -187,8 +205,12 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */
|
||||
}
|
||||
}
|
||||
|
||||
prop_iter_cp = prop_iter_p->next_property_cp;
|
||||
prop_iter_p = ECMA_GET_POINTER (ecma_property_header_t,
|
||||
prop_iter_p->next_property_cp);
|
||||
}
|
||||
#else /* CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
|
||||
JERRY_UNUSED (object_p);
|
||||
#endif /* !CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
|
||||
} /* ecma_property_hashmap_create */
|
||||
|
||||
/**
|
||||
@@ -198,19 +220,22 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */
|
||||
void
|
||||
ecma_property_hashmap_free (ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
#ifndef CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE
|
||||
/* 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_property_list (object_p);
|
||||
|
||||
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);
|
||||
JERRY_ASSERT (property_p != NULL
|
||||
&& ECMA_PROPERTY_GET_TYPE (property_p->types + 0) == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
|
||||
ecma_property_hashmap_t *hashmap_p = (ecma_property_hashmap_t *) property_p;
|
||||
|
||||
object_p->u1.property_list_cp = property_p->next_property_cp;
|
||||
object_p->property_list_or_bound_object_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));
|
||||
#else /* CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
|
||||
JERRY_UNUSED (object_p);
|
||||
#endif /* !CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
|
||||
} /* ecma_property_hashmap_free */
|
||||
|
||||
/**
|
||||
@@ -222,12 +247,11 @@ ecma_property_hashmap_insert (ecma_object_t *object_p, /**< object */
|
||||
ecma_property_pair_t *property_pair_p, /**< property pair */
|
||||
int property_index) /**< property index in the pair (0 or 1) */
|
||||
{
|
||||
JERRY_ASSERT (property_pair_p != NULL);
|
||||
#ifndef CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE
|
||||
ecma_property_hashmap_t *hashmap_p = ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t,
|
||||
object_p->property_list_or_bound_object_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);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (hashmap_p->header.types + 0) == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
|
||||
/* The NULLs are reduced below 1/8 of the hashmap. */
|
||||
if (hashmap_p->null_count < (hashmap_p->max_property_count >> 3))
|
||||
@@ -239,10 +263,18 @@ ecma_property_hashmap_insert (ecma_object_t *object_p, /**< object */
|
||||
|
||||
JERRY_ASSERT (property_index < ECMA_PROPERTY_PAIR_ITEM_COUNT);
|
||||
|
||||
uint32_t entry_index = ecma_string_hash (name_p);
|
||||
uint32_t entry_index = name_p->hash;
|
||||
uint32_t step = ecma_property_hashmap_steps[entry_index & (ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS - 1)];
|
||||
uint32_t mask = hashmap_p->max_property_count - 1;
|
||||
entry_index &= mask;
|
||||
|
||||
if (mask < LIT_STRING_HASH_LIMIT)
|
||||
{
|
||||
entry_index &= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
entry_index <<= hashmap_p->header.types[1].type_and_flags;
|
||||
}
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
/* See the comment for this variable in ecma_property_hashmap_create. */
|
||||
@@ -260,7 +292,7 @@ ecma_property_hashmap_insert (ecma_object_t *object_p, /**< object */
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
}
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER (pair_list_p[entry_index], property_pair_p);
|
||||
ECMA_SET_POINTER (pair_list_p[entry_index], property_pair_p);
|
||||
|
||||
uint8_t *bits_p = (uint8_t *) (pair_list_p + hashmap_p->max_property_count);
|
||||
bits_p += (entry_index >> 3);
|
||||
@@ -274,9 +306,6 @@ ecma_property_hashmap_insert (ecma_object_t *object_p, /**< object */
|
||||
JERRY_ASSERT (hashmap_p->null_count > 0);
|
||||
}
|
||||
|
||||
hashmap_p->unused_count--;
|
||||
JERRY_ASSERT (hashmap_p->unused_count > 0);
|
||||
|
||||
if (property_index == 0)
|
||||
{
|
||||
*bits_p = (uint8_t) ((*bits_p) & ~mask);
|
||||
@@ -285,39 +314,43 @@ ecma_property_hashmap_insert (ecma_object_t *object_p, /**< object */
|
||||
{
|
||||
*bits_p = (uint8_t) ((*bits_p) | mask);
|
||||
}
|
||||
#else /* CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
|
||||
JERRY_UNUSED (object_p);
|
||||
JERRY_UNUSED (name_p);
|
||||
JERRY_UNUSED (property_pair_p);
|
||||
JERRY_UNUSED (property_index);
|
||||
#endif /* !CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
|
||||
} /* ecma_property_hashmap_insert */
|
||||
|
||||
/**
|
||||
* Delete named property from the hashmap.
|
||||
*
|
||||
* @return ECMA_PROPERTY_HASHMAP_DELETE_RECREATE_HASHMAP if hashmap should be recreated
|
||||
* ECMA_PROPERTY_HASHMAP_DELETE_HAS_HASHMAP otherwise
|
||||
*/
|
||||
ecma_property_hashmap_delete_status
|
||||
void
|
||||
ecma_property_hashmap_delete (ecma_object_t *object_p, /**< object */
|
||||
jmem_cpointer_t name_cp, /**< property name */
|
||||
ecma_string_t *name_p, /**< name of the property */
|
||||
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);
|
||||
#ifndef CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE
|
||||
ecma_property_hashmap_t *hashmap_p = ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t,
|
||||
object_p->property_list_or_bound_object_cp);
|
||||
|
||||
JERRY_ASSERT (hashmap_p->header.types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (hashmap_p->header.types + 0) == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
|
||||
hashmap_p->unused_count++;
|
||||
|
||||
/* The NULLs are above 3/4 of the hashmap. */
|
||||
if (hashmap_p->unused_count > ((hashmap_p->max_property_count * 3) >> 2))
|
||||
{
|
||||
return ECMA_PROPERTY_HASHMAP_DELETE_RECREATE_HASHMAP;
|
||||
}
|
||||
|
||||
uint32_t entry_index = ecma_string_get_property_name_hash (*property_p, name_cp);
|
||||
uint32_t entry_index = name_p->hash;
|
||||
uint32_t step = ecma_property_hashmap_steps[entry_index & (ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS - 1)];
|
||||
uint32_t mask = hashmap_p->max_property_count - 1;
|
||||
jmem_cpointer_t *pair_list_p = (jmem_cpointer_t *) (hashmap_p + 1);
|
||||
uint8_t *bits_p = (uint8_t *) (pair_list_p + hashmap_p->max_property_count);
|
||||
|
||||
entry_index &= mask;
|
||||
if (mask < LIT_STRING_HASH_LIMIT)
|
||||
{
|
||||
entry_index &= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
entry_index <<= hashmap_p->header.types[1].type_and_flags;
|
||||
JERRY_ASSERT (entry_index <= mask);
|
||||
}
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
/* See the comment for this variable in ecma_property_hashmap_create. */
|
||||
@@ -329,22 +362,23 @@ ecma_property_hashmap_delete (ecma_object_t *object_p, /**< object */
|
||||
if (pair_list_p[entry_index] != ECMA_NULL_POINTER)
|
||||
{
|
||||
size_t offset = 0;
|
||||
|
||||
if (ECMA_PROPERTY_HASHMAP_GET_BIT (bits_p, entry_index))
|
||||
{
|
||||
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)
|
||||
{
|
||||
JERRY_ASSERT (property_pair_p->names_cp[offset] == name_cp);
|
||||
JERRY_ASSERT (ecma_compare_ecma_strings (ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
property_pair_p->names_cp[offset]),
|
||||
name_p));
|
||||
|
||||
pair_list_p[entry_index] = ECMA_NULL_POINTER;
|
||||
ECMA_PROPERTY_HASHMAP_SET_BIT (bits_p, entry_index);
|
||||
return ECMA_PROPERTY_HASHMAP_DELETE_HAS_HASHMAP;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -359,8 +393,14 @@ ecma_property_hashmap_delete (ecma_object_t *object_p, /**< object */
|
||||
JERRY_ASSERT (entry_index != start_entry_index);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
}
|
||||
#else /* CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
|
||||
JERRY_UNUSED (object_p);
|
||||
JERRY_UNUSED (name_p);
|
||||
JERRY_UNUSED (property_p);
|
||||
#endif /* !CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
|
||||
} /* ecma_property_hashmap_delete */
|
||||
|
||||
#ifndef CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE
|
||||
/**
|
||||
* Find a named property.
|
||||
*
|
||||
@@ -369,7 +409,7 @@ ecma_property_hashmap_delete (ecma_object_t *object_p, /**< object */
|
||||
ecma_property_t *
|
||||
ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
|
||||
ecma_string_t *name_p, /**< property name */
|
||||
jmem_cpointer_t *property_real_name_cp) /**< [out] property real name */
|
||||
ecma_string_t **property_real_name_p) /**< [out] property real name */
|
||||
{
|
||||
#ifndef JERRY_NDEBUG
|
||||
/* A sanity check in debug mode: a named property must be present
|
||||
@@ -377,101 +417,56 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
|
||||
* from both data collection. The following code checks the property
|
||||
* chain, and sets the property_found variable. */
|
||||
bool property_found = false;
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_POINTER (ecma_property_header_t,
|
||||
hashmap_p->header.next_property_cp);
|
||||
|
||||
jmem_cpointer_t prop_iter_cp = hashmap_p->header.next_property_cp;
|
||||
|
||||
while (prop_iter_cp != JMEM_CP_NULL && !property_found)
|
||||
while (prop_iter_p != NULL && !property_found)
|
||||
{
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
|
||||
|
||||
ecma_property_pair_t *prop_pair_p = (ecma_property_pair_t *) prop_iter_p;
|
||||
|
||||
for (int i = 0; i < ECMA_PROPERTY_PAIR_ITEM_COUNT; i++)
|
||||
{
|
||||
if (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[i]))
|
||||
if (prop_pair_p->names_cp[i] != ECMA_NULL_POINTER)
|
||||
{
|
||||
if (ecma_string_compare_to_property_name (prop_iter_p->types[i], prop_pair_p->names_cp[i], name_p))
|
||||
ecma_string_t *property_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
prop_pair_p->names_cp[i]);
|
||||
|
||||
if (ecma_compare_ecma_strings (name_p, property_name_p))
|
||||
{
|
||||
/* Property is found */
|
||||
property_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prop_iter_cp = prop_iter_p->next_property_cp;
|
||||
prop_iter_p = ECMA_GET_POINTER (ecma_property_header_t,
|
||||
prop_iter_p->next_property_cp);
|
||||
}
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
uint32_t entry_index = ecma_string_hash (name_p);
|
||||
uint32_t entry_index = name_p->hash;
|
||||
uint32_t step = ecma_property_hashmap_steps[entry_index & (ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS - 1)];
|
||||
uint32_t mask = hashmap_p->max_property_count - 1;
|
||||
jmem_cpointer_t *pair_list_p = (jmem_cpointer_t *) (hashmap_p + 1);
|
||||
uint8_t *bits_p = (uint8_t *) (pair_list_p + hashmap_p->max_property_count);
|
||||
entry_index &= mask;
|
||||
|
||||
if (mask < LIT_STRING_HASH_LIMIT)
|
||||
{
|
||||
entry_index &= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
entry_index <<= hashmap_p->header.types[1].type_and_flags;
|
||||
JERRY_ASSERT (entry_index <= mask);
|
||||
}
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
/* See the comment for this variable in ecma_property_hashmap_create. */
|
||||
uint32_t start_entry_index = entry_index;
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
if (ECMA_IS_DIRECT_STRING (name_p))
|
||||
{
|
||||
ecma_property_t prop_name_type = (ecma_property_t) ECMA_GET_DIRECT_STRING_TYPE (name_p);
|
||||
jmem_cpointer_t property_name_cp = (jmem_cpointer_t) ECMA_GET_DIRECT_STRING_VALUE (name_p);
|
||||
|
||||
JERRY_ASSERT (prop_name_type > 0);
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (pair_list_p[entry_index] != ECMA_NULL_POINTER)
|
||||
{
|
||||
size_t offset = 0;
|
||||
if (ECMA_PROPERTY_HASHMAP_GET_BIT (bits_p, entry_index))
|
||||
{
|
||||
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_t *property_p = property_pair_p->header.types + offset;
|
||||
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (*property_p));
|
||||
|
||||
if (property_pair_p->names_cp[offset] == property_name_cp
|
||||
&& ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == prop_name_type)
|
||||
{
|
||||
#ifndef JERRY_NDEBUG
|
||||
JERRY_ASSERT (property_found);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
*property_real_name_cp = property_name_cp;
|
||||
return property_p;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ECMA_PROPERTY_HASHMAP_GET_BIT (bits_p, entry_index))
|
||||
{
|
||||
#ifndef JERRY_NDEBUG
|
||||
JERRY_ASSERT (!property_found);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
/* Otherwise it is a deleted entry. */
|
||||
}
|
||||
|
||||
entry_index = (entry_index + step) & mask;
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
JERRY_ASSERT (entry_index != start_entry_index);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
}
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (pair_list_p[entry_index] != ECMA_NULL_POINTER)
|
||||
@@ -482,26 +477,19 @@ 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;
|
||||
ecma_string_t *property_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
property_pair_p->names_cp[offset]);
|
||||
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (*property_p));
|
||||
|
||||
if (ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == ECMA_DIRECT_STRING_PTR)
|
||||
if (ecma_compare_ecma_strings (name_p, property_name_p))
|
||||
{
|
||||
ecma_string_t *prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t, property_pair_p->names_cp[offset]);
|
||||
|
||||
if (ecma_compare_ecma_non_direct_strings (prop_name_p, name_p))
|
||||
{
|
||||
#ifndef JERRY_NDEBUG
|
||||
JERRY_ASSERT (property_found);
|
||||
JERRY_ASSERT (property_found);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
*property_real_name_cp = property_pair_p->names_cp[offset];
|
||||
return property_p;
|
||||
}
|
||||
*property_real_name_p = property_name_p;
|
||||
return property_pair_p->header.types + offset;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -511,7 +499,6 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
|
||||
#ifndef JERRY_NDEBUG
|
||||
JERRY_ASSERT (!property_found);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
/* Otherwise it is a deleted entry. */
|
||||
@@ -524,7 +511,7 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
}
|
||||
} /* ecma_property_hashmap_find */
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
#endif /* !CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
/* Copyright 2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 University of Szeged.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,8 +17,6 @@
|
||||
#ifndef ECMA_PROPERTY_HASHMAP_H
|
||||
#define ECMA_PROPERTY_HASHMAP_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
@@ -38,7 +37,6 @@ 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 entries in the map */
|
||||
|
||||
/*
|
||||
* The hash is followed by max_property_count ecma_cpointer_t
|
||||
@@ -55,31 +53,14 @@ typedef struct
|
||||
*/
|
||||
} ecma_property_hashmap_t;
|
||||
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
extern void ecma_property_hashmap_create (ecma_object_t *);
|
||||
extern void ecma_property_hashmap_free (ecma_object_t *);
|
||||
extern void ecma_property_hashmap_insert (ecma_object_t *, ecma_string_t *, ecma_property_pair_t *, int);
|
||||
extern void ecma_property_hashmap_delete (ecma_object_t *, ecma_string_t *, ecma_property_t *);
|
||||
|
||||
/**
|
||||
* Simple ecma values
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_PROPERTY_HASHMAP_DELETE_NO_HASHMAP, /**< object has no hashmap */
|
||||
ECMA_PROPERTY_HASHMAP_DELETE_HAS_HASHMAP, /**< object has hashmap */
|
||||
ECMA_PROPERTY_HASHMAP_DELETE_RECREATE_HASHMAP, /**< hashmap should be recreated */
|
||||
} ecma_property_hashmap_delete_status;
|
||||
|
||||
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);
|
||||
|
||||
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 /* JERRY_PROPERTY_HASHMAP */
|
||||
#ifndef CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE
|
||||
extern ecma_property_t *ecma_property_hashmap_find (ecma_property_hashmap_t *, ecma_string_t *, ecma_string_t **);
|
||||
#endif /* !CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/* 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"
|
||||
@@ -1,34 +0,0 @@
|
||||
/* 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"
|
||||
@@ -1,109 +0,0 @@
|
||||
/* 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 */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
@@ -1,35 +0,0 @@
|
||||
/* 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"
|
||||
@@ -1,224 +0,0 @@
|
||||
/* 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-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-iterator-object.h"
|
||||
#include "ecma-typedarray-object.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_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
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmabuiltins
|
||||
* @{
|
||||
*
|
||||
* \addtogroup %arrayiteratorprototype% ECMA %ArrayIteratorPrototype% object built-in
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The %ArrayIteratorPrototype% object's 'next' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 22.1.5.2.1
|
||||
*
|
||||
* Note:
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*
|
||||
* @return iterator result object, if success
|
||||
* error - otherwise
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< this argument */
|
||||
{
|
||||
/* 1 - 2. */
|
||||
if (!ecma_is_value_object (this_val))
|
||||
{
|
||||
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_object_class_is (obj_p, ECMA_OBJECT_CLASS_ARRAY_ITERATOR))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_ITERATOR);
|
||||
}
|
||||
|
||||
ecma_value_t iterated_value = ext_obj_p->u.cls.u3.iterated_value;
|
||||
|
||||
/* 4 - 5 */
|
||||
if (ecma_is_value_empty (iterated_value))
|
||||
{
|
||||
return ecma_create_iter_result_object (ECMA_VALUE_UNDEFINED, ECMA_VALUE_TRUE);
|
||||
}
|
||||
|
||||
ecma_object_t *array_object_p = ecma_get_object_from_value (iterated_value);
|
||||
|
||||
/* 8. */
|
||||
ecma_length_t length;
|
||||
if (ecma_object_is_typedarray (array_object_p))
|
||||
{
|
||||
/* a. */
|
||||
ecma_object_t *arraybuffer_p = ecma_typedarray_get_arraybuffer (array_object_p);
|
||||
if (ecma_arraybuffer_is_detached (arraybuffer_p))
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED);
|
||||
}
|
||||
|
||||
/* b. */
|
||||
length = ecma_typedarray_get_length (array_object_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_value_t len_value = ecma_op_object_get_length (array_object_p, &length);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (len_value))
|
||||
{
|
||||
return len_value;
|
||||
}
|
||||
}
|
||||
|
||||
ecma_length_t index = ext_obj_p->u.cls.u2.iterator_index;
|
||||
|
||||
if (JERRY_UNLIKELY (index == ECMA_ITERATOR_INDEX_LIMIT))
|
||||
{
|
||||
/* After the ECMA_ITERATOR_INDEX_LIMIT limit is reached the [[%Iterator%NextIndex]]
|
||||
property is stored as an internal property */
|
||||
ecma_string_t *prop_name_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_ITERATOR_NEXT_INDEX);
|
||||
ecma_value_t index_value = ecma_op_object_get (obj_p, prop_name_p);
|
||||
|
||||
if (!ecma_is_value_undefined (index_value))
|
||||
{
|
||||
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);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_true (put_result));
|
||||
|
||||
ecma_free_value (index_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 11. */
|
||||
ext_obj_p->u.cls.u2.iterator_index++;
|
||||
}
|
||||
|
||||
if (index >= length)
|
||||
{
|
||||
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.cls.u1.iterator_kind;
|
||||
|
||||
if (iterator_kind == ECMA_ITERATOR_KEYS)
|
||||
{
|
||||
/* 12. */
|
||||
return ecma_create_iter_result_object (ecma_make_length_value (index), ECMA_VALUE_FALSE);
|
||||
}
|
||||
|
||||
/* 14. */
|
||||
ecma_value_t get_value = ecma_op_object_get_by_index (array_object_p, index);
|
||||
|
||||
/* 15. */
|
||||
if (ECMA_IS_VALUE_ERROR (get_value))
|
||||
{
|
||||
return get_value;
|
||||
}
|
||||
|
||||
ecma_value_t result;
|
||||
|
||||
/* 16. */
|
||||
if (iterator_kind == ECMA_ITERATOR_VALUES)
|
||||
{
|
||||
result = ecma_create_iter_result_object (get_value, ECMA_VALUE_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 17.a */
|
||||
JERRY_ASSERT (iterator_kind == ECMA_ITERATOR_ENTRIES);
|
||||
|
||||
/* 17.b */
|
||||
ecma_value_t entry_array_value;
|
||||
entry_array_value = ecma_create_array_from_iter_element (get_value, ecma_make_length_value (index));
|
||||
|
||||
result = ecma_create_iter_result_object (entry_array_value, ECMA_VALUE_FALSE);
|
||||
ecma_free_value (entry_array_value);
|
||||
}
|
||||
|
||||
ecma_free_value (get_value);
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
@@ -1,28 +0,0 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* %ArrayIteratorPrototype% built-in description
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
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_ARRAY_ITERATOR_PROTOTYPE_OBJECT_NEXT, 0, 0)
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
@@ -1,24 +0,0 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
|
||||
#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
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
@@ -1,44 +0,0 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Array.prototype[@@unscopables] built-in description
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
|
||||
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_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_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_FLAT, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FLATMAP, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_INCLUDES, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_KEYS, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
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
@@ -1,4 +1,5 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2015 University of Szeged.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,69 +18,69 @@
|
||||
* Array.prototype built-in description
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
#ifndef OBJECT_ID
|
||||
# define OBJECT_ID(builtin_object_id)
|
||||
#endif /* !OBJECT_ID */
|
||||
|
||||
#if JERRY_BUILTIN_ARRAY
|
||||
#ifndef OBJECT_VALUE
|
||||
# define OBJECT_VALUE(name, obj_builtin_id, prop_attributes)
|
||||
#endif /* !OBJECT_VALUE */
|
||||
|
||||
#ifndef NUMBER_VALUE
|
||||
# define NUMBER_VALUE(name, number_value, prop_attributes)
|
||||
#endif /* !NUMBER_VALUE */
|
||||
|
||||
#ifndef ROUTINE
|
||||
# define ROUTINE(name, c_function_name, args_number, length_prop_value)
|
||||
#endif /* !ROUTINE */
|
||||
|
||||
/* Object identifier */
|
||||
OBJECT_ID (ECMA_BUILTIN_ID_ARRAY_PROTOTYPE)
|
||||
|
||||
/* 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)
|
||||
|
||||
/* ECMA-262 v6, 22.1.3.31 */
|
||||
OBJECT_VALUE (LIT_GLOBAL_SYMBOL_UNSCOPABLES,
|
||||
ECMA_BUILTIN_ID_ARRAY_PROTOTYPE_UNSCOPABLES,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
// 15.4.4.1
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* Number properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.4.4 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 0, ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
// 15.4.4
|
||||
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)
|
||||
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)
|
||||
ROUTINE (LIT_MAGIC_STRING_PUSH, ECMA_ARRAY_PROTOTYPE_PUSH, NON_FIXED, 1)
|
||||
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)
|
||||
ROUTINE (LIT_MAGIC_STRING_LAST_INDEX_OF_UL, ECMA_ARRAY_PROTOTYPE_LAST_INDEX_OF, NON_FIXED, 1)
|
||||
/* Note these 3 routines must be in this order */
|
||||
ROUTINE (LIT_MAGIC_STRING_EVERY, ECMA_ARRAY_PROTOTYPE_EVERY, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_SOME, ECMA_ARRAY_PROTOTYPE_SOME, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_FOR_EACH_UL, ECMA_ARRAY_PROTOTYPE_FOR_EACH, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_MAP, ECMA_ARRAY_PROTOTYPE_MAP, 2, 1)
|
||||
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)
|
||||
ROUTINE (LIT_MAGIC_STRING_FIND, ECMA_ARRAY_PROTOTYPE_FIND, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_FIND_INDEX, ECMA_ARRAY_PROTOTYPE_FIND_INDEX, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_FILL, ECMA_ARRAY_PROTOTYPE_FILL, 3, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_COPY_WITHIN, ECMA_ARRAY_PROTOTYPE_COPY_WITHIN, NON_FIXED, 2)
|
||||
ROUTINE (LIT_MAGIC_STRING_ENTRIES, ECMA_ARRAY_PROTOTYPE_ENTRIES, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_KEYS, ECMA_ARRAY_PROTOTYPE_KEYS, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_INCLUDES, ECMA_ARRAY_PROTOTYPE_INCLUDES, NON_FIXED, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_FLAT, ECMA_ARRAY_PROTOTYPE_FLAT, 1, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_FLATMAP, ECMA_ARRAY_PROTOTYPE_FLATMAP, 2, 1)
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_STRING_UL, LIT_MAGIC_STRING_TO_STRING_UL, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_VALUES,
|
||||
LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
INTRINSIC_PROPERTY (LIT_GLOBAL_SYMBOL_ITERATOR,
|
||||
LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_STRING_UL, ecma_builtin_array_prototype_object_to_string, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_LOCALE_STRING_UL, ecma_builtin_array_prototype_object_to_locale_string, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_CONCAT, ecma_builtin_array_prototype_object_concat, NON_FIXED, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_JOIN, ecma_builtin_array_prototype_join, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_POP, ecma_builtin_array_prototype_object_pop, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_PUSH, ecma_builtin_array_prototype_object_push, NON_FIXED, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_REVERSE, ecma_builtin_array_prototype_object_reverse, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_SHIFT, ecma_builtin_array_prototype_object_shift, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_SLICE, ecma_builtin_array_prototype_object_slice, 2, 2)
|
||||
ROUTINE (LIT_MAGIC_STRING_SORT, ecma_builtin_array_prototype_object_sort, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_SPLICE, ecma_builtin_array_prototype_object_splice, NON_FIXED, 2)
|
||||
ROUTINE (LIT_MAGIC_STRING_UNSHIFT, ecma_builtin_array_prototype_object_unshift, NON_FIXED, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_INDEX_OF_UL, ecma_builtin_array_prototype_object_index_of, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_LAST_INDEX_OF_UL, ecma_builtin_array_prototype_object_last_index_of, NON_FIXED, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_EVERY, ecma_builtin_array_prototype_object_every, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_SOME, ecma_builtin_array_prototype_object_some, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_FOR_EACH_UL, ecma_builtin_array_prototype_object_for_each, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_MAP, ecma_builtin_array_prototype_object_map, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_FILTER, ecma_builtin_array_prototype_object_filter, 2, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_REDUCE, ecma_builtin_array_prototype_object_reduce, NON_FIXED, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_REDUCE_RIGHT_UL, ecma_builtin_array_prototype_object_reduce_right, NON_FIXED, 1)
|
||||
|
||||
#endif /* JERRY_BUILTIN_ARRAY */
|
||||
#undef OBJECT_ID
|
||||
#undef SIMPLE_VALUE
|
||||
#undef NUMBER_VALUE
|
||||
#undef STRING_VALUE
|
||||
#undef OBJECT_VALUE
|
||||
#undef ROUTINE
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,45 +14,24 @@
|
||||
*/
|
||||
|
||||
#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 "ecma-array-object.h"
|
||||
#include "ecma-try-catch-macro.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_BUILTIN_ARRAY
|
||||
#ifndef CONFIG_DISABLE_ARRAY_BUILTIN
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
/**
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_CUSTOM_DISPATCH
|
||||
|
||||
/**
|
||||
* List of built-in routine identifiers.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
ECMA_ARRAY_ROUTINE_START = 0,
|
||||
ECMA_ARRAY_ROUTINE_IS_ARRAY,
|
||||
ECMA_ARRAY_ROUTINE_FROM,
|
||||
ECMA_ARRAY_ROUTINE_OF,
|
||||
ECMA_ARRAY_ROUTINE_SPECIES_GET
|
||||
};
|
||||
|
||||
#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,503 +45,66 @@ enum
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Array object's 'from' routine
|
||||
* The Array object's 'isArray' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 22.1.2.1
|
||||
* ECMA-262 v5, 15.4.3.2
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
ecma_builtin_array_object_is_array (ecma_value_t this_arg, /**< 'this' argument */
|
||||
ecma_value_t arg) /**< first argument */
|
||||
{
|
||||
/* 1. */
|
||||
ecma_value_t constructor = this_arg;
|
||||
ecma_value_t call_this_arg = ECMA_VALUE_UNDEFINED;
|
||||
ecma_value_t items = arguments_list_p[0];
|
||||
ecma_value_t mapfn = (arguments_list_len > 1) ? arguments_list_p[1] : ECMA_VALUE_UNDEFINED;
|
||||
JERRY_UNUSED (this_arg);
|
||||
ecma_simple_value_t is_array = ECMA_SIMPLE_VALUE_FALSE;
|
||||
|
||||
/* 2. */
|
||||
ecma_object_t *mapfn_obj_p = NULL;
|
||||
|
||||
/* 3. */
|
||||
if (!ecma_is_value_undefined (mapfn))
|
||||
if (ecma_is_value_object (arg))
|
||||
{
|
||||
/* 3.a */
|
||||
if (!ecma_op_is_callable (mapfn))
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (arg);
|
||||
|
||||
if (ecma_object_get_class_name (obj_p) == LIT_MAGIC_STRING_ARRAY_UL)
|
||||
{
|
||||
return ecma_raise_type_error (ECMA_ERR_CALLBACK_IS_NOT_CALLABLE);
|
||||
}
|
||||
|
||||
/* 3.b */
|
||||
if (arguments_list_len > 2)
|
||||
{
|
||||
call_this_arg = arguments_list_p[2];
|
||||
}
|
||||
|
||||
/* 3.c */
|
||||
mapfn_obj_p = ecma_get_object_from_value (mapfn);
|
||||
}
|
||||
|
||||
/* 4. */
|
||||
ecma_value_t using_iterator = ecma_op_get_method_by_symbol_id (items, LIT_GLOBAL_SYMBOL_ITERATOR);
|
||||
|
||||
/* 5. */
|
||||
if (ECMA_IS_VALUE_ERROR (using_iterator))
|
||||
{
|
||||
return using_iterator;
|
||||
}
|
||||
|
||||
ecma_value_t ret_value = ECMA_VALUE_ERROR;
|
||||
|
||||
/* 6. */
|
||||
if (!ecma_is_value_undefined (using_iterator))
|
||||
{
|
||||
ecma_object_t *array_obj_p;
|
||||
|
||||
/* 6.a */
|
||||
if (ecma_is_constructor (constructor))
|
||||
{
|
||||
ecma_object_t *constructor_obj_p = ecma_get_object_from_value (constructor);
|
||||
|
||||
ecma_value_t array = ecma_op_function_construct (constructor_obj_p, constructor_obj_p, NULL, 0);
|
||||
|
||||
if (ecma_is_value_undefined (array) || ecma_is_value_null (array))
|
||||
{
|
||||
ecma_free_value (using_iterator);
|
||||
return ecma_raise_type_error (ECMA_ERR_CANNOT_CONVERT_TO_OBJECT);
|
||||
}
|
||||
|
||||
/* 6.c */
|
||||
if (ECMA_IS_VALUE_ERROR (array))
|
||||
{
|
||||
ecma_free_value (using_iterator);
|
||||
return array;
|
||||
}
|
||||
|
||||
array_obj_p = ecma_get_object_from_value (array);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 6.b */
|
||||
array_obj_p = ecma_op_new_array_object (0);
|
||||
}
|
||||
|
||||
/* 6.d */
|
||||
ecma_value_t next_method;
|
||||
ecma_value_t iterator = ecma_op_get_iterator (items, using_iterator, &next_method);
|
||||
ecma_free_value (using_iterator);
|
||||
|
||||
/* 6.e */
|
||||
if (ECMA_IS_VALUE_ERROR (iterator))
|
||||
{
|
||||
ecma_deref_object (array_obj_p);
|
||||
return iterator;
|
||||
}
|
||||
|
||||
/* 6.f */
|
||||
uint32_t k = 0;
|
||||
|
||||
/* 6.g */
|
||||
while (true)
|
||||
{
|
||||
/* 6.g.ii */
|
||||
ecma_value_t next = ecma_op_iterator_step (iterator, next_method);
|
||||
|
||||
/* 6.g.iii */
|
||||
if (ECMA_IS_VALUE_ERROR (next))
|
||||
{
|
||||
goto iterator_cleanup;
|
||||
}
|
||||
|
||||
/* 6.g.iii */
|
||||
if (ecma_is_value_false (next))
|
||||
{
|
||||
/* 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_free_value (len_value);
|
||||
|
||||
/* 6.g.iv.2 */
|
||||
if (ECMA_IS_VALUE_ERROR (set_status))
|
||||
{
|
||||
goto iterator_cleanup;
|
||||
}
|
||||
|
||||
ecma_free_value (iterator);
|
||||
ecma_free_value (next_method);
|
||||
/* 6.g.iv.3 */
|
||||
return ecma_make_object_value (array_obj_p);
|
||||
}
|
||||
|
||||
/* 6.g.v */
|
||||
ecma_value_t next_value = ecma_op_iterator_value (next);
|
||||
|
||||
ecma_free_value (next);
|
||||
|
||||
/* 6.g.vi */
|
||||
if (ECMA_IS_VALUE_ERROR (next_value))
|
||||
{
|
||||
goto iterator_cleanup;
|
||||
}
|
||||
|
||||
ecma_value_t mapped_value;
|
||||
/* 6.g.vii */
|
||||
if (mapfn_obj_p != NULL)
|
||||
{
|
||||
/* 6.g.vii.1 */
|
||||
ecma_value_t args_p[2] = { next_value, ecma_make_uint32_value (k) };
|
||||
/* 6.g.vii.3 */
|
||||
mapped_value = ecma_op_function_call (mapfn_obj_p, call_this_arg, args_p, 2);
|
||||
ecma_free_value (args_p[1]);
|
||||
ecma_free_value (next_value);
|
||||
|
||||
/* 6.g.vii.2 */
|
||||
if (ECMA_IS_VALUE_ERROR (mapped_value))
|
||||
{
|
||||
ecma_op_iterator_close (iterator);
|
||||
goto iterator_cleanup;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 6.g.viii */
|
||||
mapped_value = next_value;
|
||||
}
|
||||
|
||||
/* 6.g.ix */
|
||||
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);
|
||||
|
||||
/* 6.g.x */
|
||||
if (ECMA_IS_VALUE_ERROR (set_status))
|
||||
{
|
||||
ecma_op_iterator_close (iterator);
|
||||
goto iterator_cleanup;
|
||||
}
|
||||
|
||||
/* 6.g.xi */
|
||||
k++;
|
||||
}
|
||||
|
||||
iterator_cleanup:
|
||||
ecma_free_value (iterator);
|
||||
ecma_free_value (next_method);
|
||||
ecma_deref_object (array_obj_p);
|
||||
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
/* 8. */
|
||||
ecma_value_t array_like = ecma_op_to_object (items);
|
||||
|
||||
/* 9. */
|
||||
if (ECMA_IS_VALUE_ERROR (array_like))
|
||||
{
|
||||
return array_like;
|
||||
}
|
||||
|
||||
ecma_object_t *array_like_obj_p = ecma_get_object_from_value (array_like);
|
||||
|
||||
/* 10. */
|
||||
ecma_length_t len;
|
||||
ecma_value_t len_value = ecma_op_object_get_length (array_like_obj_p, &len);
|
||||
|
||||
/* 11. */
|
||||
if (ECMA_IS_VALUE_ERROR (len_value))
|
||||
{
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* 12. */
|
||||
ecma_object_t *array_obj_p;
|
||||
|
||||
/* 12.a */
|
||||
if (ecma_is_constructor (constructor))
|
||||
{
|
||||
ecma_object_t *constructor_obj_p = ecma_get_object_from_value (constructor);
|
||||
|
||||
len_value = ecma_make_length_value (len);
|
||||
ecma_value_t array = ecma_op_function_construct (constructor_obj_p, constructor_obj_p, &len_value, 1);
|
||||
ecma_free_value (len_value);
|
||||
|
||||
if (ecma_is_value_undefined (array) || ecma_is_value_null (array))
|
||||
{
|
||||
ecma_raise_type_error (ECMA_ERR_CANNOT_CONVERT_TO_OBJECT);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* 14. */
|
||||
if (ECMA_IS_VALUE_ERROR (array))
|
||||
{
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
array_obj_p = ecma_get_object_from_value (array);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 13.a */
|
||||
array_obj_p = ecma_op_new_array_object_from_length (len);
|
||||
|
||||
if (JERRY_UNLIKELY (array_obj_p == NULL))
|
||||
{
|
||||
goto cleanup;
|
||||
is_array = ECMA_SIMPLE_VALUE_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* 15. */
|
||||
ecma_length_t k = 0;
|
||||
|
||||
/* 16. */
|
||||
while (k < len)
|
||||
{
|
||||
/* 16.b */
|
||||
ecma_value_t k_value = ecma_op_object_get_by_index (array_like_obj_p, k);
|
||||
|
||||
/* 16.c */
|
||||
if (ECMA_IS_VALUE_ERROR (k_value))
|
||||
{
|
||||
goto construct_cleanup;
|
||||
}
|
||||
|
||||
ecma_value_t mapped_value;
|
||||
/* 16.d */
|
||||
if (mapfn_obj_p != NULL)
|
||||
{
|
||||
/* 16.d.i */
|
||||
ecma_value_t args_p[2] = { k_value, ecma_make_length_value (k) };
|
||||
mapped_value = ecma_op_function_call (mapfn_obj_p, call_this_arg, args_p, 2);
|
||||
ecma_free_value (args_p[1]);
|
||||
ecma_free_value (k_value);
|
||||
|
||||
/* 16.d.ii */
|
||||
if (ECMA_IS_VALUE_ERROR (mapped_value))
|
||||
{
|
||||
goto construct_cleanup;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 16.e */
|
||||
mapped_value = k_value;
|
||||
}
|
||||
|
||||
/* 16.f */
|
||||
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);
|
||||
|
||||
/* 16.g */
|
||||
if (ECMA_IS_VALUE_ERROR (set_status))
|
||||
{
|
||||
goto construct_cleanup;
|
||||
}
|
||||
|
||||
/* 16.h */
|
||||
k++;
|
||||
}
|
||||
|
||||
/* 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_free_value (len_value);
|
||||
|
||||
/* 18. */
|
||||
if (ECMA_IS_VALUE_ERROR (set_status))
|
||||
{
|
||||
goto construct_cleanup;
|
||||
}
|
||||
|
||||
/* 19. */
|
||||
ecma_deref_object (array_like_obj_p);
|
||||
return ecma_make_object_value (array_obj_p);
|
||||
|
||||
construct_cleanup:
|
||||
ecma_deref_object (array_obj_p);
|
||||
cleanup:
|
||||
ecma_deref_object (array_like_obj_p);
|
||||
return ret_value;
|
||||
} /* ecma_builtin_array_object_from */
|
||||
|
||||
/**
|
||||
* The Array object's 'of' routine
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v6, 22.1.2.3
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
|
||||
const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
if (!ecma_is_constructor (this_arg))
|
||||
{
|
||||
return ecma_op_new_array_object_from_buffer (arguments_list_p, arguments_list_len);
|
||||
}
|
||||
|
||||
ecma_value_t len = ecma_make_uint32_value (arguments_list_len);
|
||||
|
||||
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))
|
||||
{
|
||||
ecma_free_value (len);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
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 | 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);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (define_status))
|
||||
{
|
||||
ecma_free_value (len);
|
||||
ecma_deref_object (obj_p);
|
||||
return define_status;
|
||||
}
|
||||
|
||||
k++;
|
||||
}
|
||||
|
||||
ret_val = ecma_op_object_put (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), len, true);
|
||||
|
||||
ecma_free_value (len);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (ret_val))
|
||||
{
|
||||
ecma_deref_object (obj_p);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
return ecma_make_object_value (obj_p);
|
||||
} /* ecma_builtin_array_object_of */
|
||||
return ecma_make_simple_value (is_array);
|
||||
} /* ecma_builtin_array_object_is_array */
|
||||
|
||||
/**
|
||||
* Handle calling [[Call]] of built-in Array object
|
||||
*
|
||||
* @return ECMA_VALUE_ERROR - if the array construction fails
|
||||
* constructed array object - otherwise
|
||||
* @return ecma value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_array_dispatch_call (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
if (arguments_list_len != 1 || !ecma_is_value_number (arguments_list_p[0]))
|
||||
{
|
||||
return ecma_op_new_array_object_from_buffer (arguments_list_p, arguments_list_len);
|
||||
}
|
||||
|
||||
ecma_number_t num = ecma_get_number_from_value (arguments_list_p[0]);
|
||||
uint32_t num_uint32 = ecma_number_to_uint32 (num);
|
||||
|
||||
if (num != ((ecma_number_t) num_uint32))
|
||||
{
|
||||
return ecma_raise_range_error (ECMA_ERR_INVALID_ARRAY_LENGTH);
|
||||
}
|
||||
|
||||
return ecma_make_object_value (ecma_op_new_array_object (num_uint32));
|
||||
return ecma_builtin_array_dispatch_construct (arguments_list_p, arguments_list_len);
|
||||
} /* ecma_builtin_array_dispatch_call */
|
||||
|
||||
/**
|
||||
* Handle calling [[Construct]] of built-in Array object
|
||||
*
|
||||
* @return ECMA_VALUE_ERROR - if the array construction fails
|
||||
* constructed array object - otherwise
|
||||
* @return ecma value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_array_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
ecma_length_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
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)
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_value_t result = ecma_builtin_array_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
{
|
||||
ecma_deref_object (proto_p);
|
||||
return 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;
|
||||
return ecma_op_create_array_object (arguments_list_p, arguments_list_len, true);
|
||||
} /* ecma_builtin_array_dispatch_construct */
|
||||
|
||||
/**
|
||||
* Dispatcher of the built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_array_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide routine identifier */
|
||||
ecma_value_t this_arg, /**< 'this' argument value */
|
||||
const ecma_value_t arguments_list_p[], /**< list of arguments
|
||||
* passed to routine */
|
||||
uint32_t arguments_number) /**< length of arguments' list */
|
||||
{
|
||||
JERRY_UNUSED (arguments_number);
|
||||
|
||||
switch (builtin_routine_id)
|
||||
{
|
||||
case ECMA_ARRAY_ROUTINE_IS_ARRAY:
|
||||
{
|
||||
JERRY_UNUSED (this_arg);
|
||||
|
||||
return ecma_is_value_array (arguments_list_p[0]);
|
||||
}
|
||||
case ECMA_ARRAY_ROUTINE_FROM:
|
||||
{
|
||||
return ecma_builtin_array_object_from (this_arg, arguments_list_p, arguments_number);
|
||||
}
|
||||
case ECMA_ARRAY_ROUTINE_OF:
|
||||
{
|
||||
return ecma_builtin_array_object_of (this_arg, arguments_list_p, arguments_number);
|
||||
}
|
||||
case ECMA_ARRAY_ROUTINE_SPECIES_GET:
|
||||
{
|
||||
return ecma_copy_value (this_arg);
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
}
|
||||
}
|
||||
} /* ecma_builtin_array_dispatch_routine */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* JERRY_BUILTIN_ARRAY */
|
||||
#endif /* !CONFIG_DISABLE_ARRAY_BUILTIN */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright JS Foundation and other contributors, http://js.foundation
|
||||
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,31 +17,49 @@
|
||||
* Array description
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
||||
#ifndef OBJECT_ID
|
||||
# define OBJECT_ID(builtin_object_id)
|
||||
#endif /* !OBJECT_ID */
|
||||
|
||||
#if JERRY_BUILTIN_ARRAY
|
||||
#ifndef OBJECT_VALUE
|
||||
# define OBJECT_VALUE(name, obj_builtin_id, prop_attributes)
|
||||
#endif /* !OBJECT_VALUE */
|
||||
|
||||
#ifndef NUMBER_VALUE
|
||||
# define NUMBER_VALUE(name, number_value, prop_attributes)
|
||||
#endif /* !NUMBER_VALUE */
|
||||
|
||||
#ifndef ROUTINE
|
||||
# define ROUTINE(name, c_function_name, args_number, length_prop_value)
|
||||
#endif /* !ROUTINE */
|
||||
|
||||
/* Object identifier */
|
||||
OBJECT_ID (ECMA_BUILTIN_ID_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)
|
||||
// 15.4.3.1
|
||||
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)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ARRAY_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
// 15.4.3
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* 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)
|
||||
ROUTINE (LIT_MAGIC_STRING_FROM, ECMA_ARRAY_ROUTINE_FROM, NON_FIXED, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_OF, ECMA_ARRAY_ROUTINE_OF, NON_FIXED, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_IS_ARRAY_UL, ecma_builtin_array_object_is_array, 1, 1)
|
||||
|
||||
/* ECMA-262 v6, 22.1.2.5 */
|
||||
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES, ECMA_ARRAY_ROUTINE_SPECIES_GET, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#undef OBJECT_ID
|
||||
#undef SIMPLE_VALUE
|
||||
#undef NUMBER_VALUE
|
||||
#undef STRING_VALUE
|
||||
#undef OBJECT_VALUE
|
||||
#undef ROUTINE
|
||||
|
||||
#endif /* !(JERRY_BUILTIN_ARRAY) */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user