mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2026-01-31 10:02:23 +00:00
Replace vera++ with clang-format (#4518)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
This commit is contained in:
parent
bc091e1742
commit
badfdf4dba
87
.clang-format
Normal file
87
.clang-format
Normal file
@ -0,0 +1,87 @@
|
||||
---
|
||||
Language: Cpp
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveMacros: true
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: false
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterReturnType: AllDefinitions
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
AfterControlStatement: Always
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
AfterExternBlock: false
|
||||
BeforeElse: true
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 120
|
||||
ContinuationIndentWidth: 2
|
||||
Cpp11BracedListStyle: false
|
||||
DeriveLineEnding: true
|
||||
DerivePointerAlignment: true
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: true
|
||||
IncludeBlocks: Regroup
|
||||
IncludeCategories:
|
||||
- Regex: '<windows.h>'
|
||||
Priority: 0
|
||||
- Regex: '<[-.a-z]*>'
|
||||
Priority: 1
|
||||
- Regex: '"jerryscript[-.a-z]*"'
|
||||
Priority: 2
|
||||
- Regex: '"ecma[-.a-z]*"'
|
||||
Priority: 3
|
||||
- Regex: '.*'
|
||||
Priority: 4
|
||||
IndentCaseLabels: true
|
||||
IndentGotoLabels: true
|
||||
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
|
||||
...
|
||||
9
.github/workflows/gh-actions.yml
vendored
9
.github/workflows/gh-actions.yml
vendored
@ -12,13 +12,16 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.8'
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install doxygen vera++ cppcheck pylint python-serial
|
||||
- run: sudo apt install doxygen clang-format-10 cppcheck pylint python-serial
|
||||
- run: $RUNNER --check-signed-off=gh-actions
|
||||
if: ${{ always() }}
|
||||
- run: $RUNNER --check-doxygen
|
||||
if: ${{ always() }}
|
||||
- run: $RUNNER --check-vera
|
||||
- run: $RUNNER --check-format
|
||||
if: ${{ always() }}
|
||||
- run: $RUNNER --check-license
|
||||
if: ${{ always() }}
|
||||
@ -145,7 +148,7 @@ jobs:
|
||||
- run: sudo apt update
|
||||
- run: sudo apt install gcc-multilib
|
||||
- run: $RUNNER -q --unittests
|
||||
# clang has bug in supporting lto
|
||||
# clang has bug in supporting lto
|
||||
- run: $RUNNER -q --buildoption-test --buildoptions=--lto=off
|
||||
|
||||
ASAN_Tests:
|
||||
|
||||
@ -11,11 +11,11 @@ Several scripts and tools help the building and development process, thus it is
|
||||
|
||||
- `bash` >= `4.3.11`
|
||||
- `cppcheck` >= `1.61`
|
||||
- `vera++` >= `1.2.1`
|
||||
- `clang-format-10` >= `10.0.0`
|
||||
- `python` >= `2.7.6`
|
||||
|
||||
```bash
|
||||
sudo apt-get install gcc gcc-arm-none-eabi cmake cppcheck vera++ python
|
||||
sudo apt-get install gcc gcc-arm-none-eabi cmake cppcheck clang-format-10 python
|
||||
```
|
||||
|
||||
To make our scripts run correctly, several shell utilities should be available on the system:
|
||||
@ -173,10 +173,10 @@ python tools/run-tests.py --check-signed-off
|
||||
python tools/run-tests.py --check-cppcheck
|
||||
```
|
||||
|
||||
**To run vera check**
|
||||
**To run format check**
|
||||
|
||||
```bash
|
||||
python tools/run-tests.py --check-vera
|
||||
python tools/run-tests.py --check-format
|
||||
```
|
||||
|
||||
**To get a list of all the available test options**
|
||||
|
||||
@ -12,7 +12,7 @@ review.
|
||||
* Tab characters are not allowed.
|
||||
* Maximum line length is 120 characters (excluding newline).
|
||||
* No trailing white space is allowed.
|
||||
* Run `tools/run-tests.py --check-vera` to check several
|
||||
* Run `tools/run-tests.py --check-format` to check several
|
||||
of the coding conventions automatically.
|
||||
|
||||
## Comments
|
||||
|
||||
@ -132,7 +132,7 @@ set(SOURCE_CORE_FILES
|
||||
api/jerry-debugger-transport.c
|
||||
api/jerry-debugger.c
|
||||
api/jerry-snapshot.c
|
||||
api/jerry.c
|
||||
api/jerryscript.c
|
||||
debugger/debugger.c
|
||||
ecma/base/ecma-alloc.c
|
||||
ecma/base/ecma-gc.c
|
||||
|
||||
@ -13,9 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "jerryscript.h"
|
||||
|
||||
#include "debugger.h"
|
||||
#include "jcontext.h"
|
||||
#include "jerryscript.h"
|
||||
|
||||
#if JERRY_DEBUGGER
|
||||
|
||||
@ -137,8 +138,7 @@ jerry_debugger_transport_close (void)
|
||||
current_p->close (current_p);
|
||||
|
||||
current_p = next_p;
|
||||
}
|
||||
while (current_p != NULL);
|
||||
} while (current_p != NULL);
|
||||
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "Debugger client connection closed.\n");
|
||||
|
||||
@ -164,8 +164,7 @@ jerry_debugger_transport_send (const uint8_t *message_p, /**< message to be sent
|
||||
|
||||
do
|
||||
{
|
||||
size_t fragment_length = (message_length <= max_send_size ? message_length
|
||||
: max_send_size);
|
||||
size_t fragment_length = (message_length <= max_send_size ? message_length : max_send_size);
|
||||
|
||||
memcpy (payload_p, message_p, fragment_length);
|
||||
|
||||
@ -176,8 +175,7 @@ jerry_debugger_transport_send (const uint8_t *message_p, /**< message to be sent
|
||||
|
||||
message_p += fragment_length;
|
||||
message_length -= fragment_length;
|
||||
}
|
||||
while (message_length > 0);
|
||||
} while (message_length > 0);
|
||||
|
||||
return true;
|
||||
} /* jerry_debugger_transport_send */
|
||||
|
||||
@ -13,9 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "jerryscript.h"
|
||||
|
||||
#include "debugger.h"
|
||||
#include "jcontext.h"
|
||||
#include "jerryscript.h"
|
||||
|
||||
/**
|
||||
* Checks whether the debugger is connected.
|
||||
|
||||
@ -13,6 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "jerry-snapshot.h"
|
||||
|
||||
#include "jerryscript.h"
|
||||
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-errors.h"
|
||||
#include "ecma-exceptions.h"
|
||||
@ -20,12 +24,11 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lex-env.h"
|
||||
#include "ecma-literal-storage.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jerryscript.h"
|
||||
#include "jerry-snapshot.h"
|
||||
#include "js-parser-internal.h"
|
||||
#include "js-parser.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "js-parser-internal.h"
|
||||
#include "re-compiler.h"
|
||||
|
||||
#if JERRY_SNAPSHOT_SAVE || JERRY_SNAPSHOT_EXEC
|
||||
@ -103,8 +106,8 @@ typedef struct
|
||||
static inline bool JERRY_ATTR_ALWAYS_INLINE
|
||||
snapshot_write_to_buffer_by_offset (uint8_t *buffer_p, /**< buffer */
|
||||
size_t buffer_size, /**< size of buffer */
|
||||
size_t *in_out_buffer_offset_p, /**< [in,out] offset to write to
|
||||
* incremented with data_size */
|
||||
size_t *in_out_buffer_offset_p, /**< [in,out] offset to write to
|
||||
* incremented with data_size */
|
||||
const void *data_p, /**< data */
|
||||
size_t data_size) /**< size of the writable data */
|
||||
{
|
||||
@ -150,8 +153,8 @@ snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, /**< co
|
||||
|
||||
if (globals_p->snapshot_buffer_write_offset > JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET)
|
||||
{
|
||||
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE,
|
||||
(const jerry_char_t *) ecma_error_maximum_snapshot_size);
|
||||
globals_p->snapshot_error =
|
||||
jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) ecma_error_maximum_snapshot_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -165,8 +168,8 @@ snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, /**< co
|
||||
#if JERRY_ESNEXT
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_HAS_TAGGED_LITERALS)
|
||||
{
|
||||
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE,
|
||||
(const jerry_char_t *) ecma_error_tagged_template_literals);
|
||||
globals_p->snapshot_error =
|
||||
jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) ecma_error_tagged_template_literals);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -182,8 +185,8 @@ snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, /**< co
|
||||
/* Regular expression. */
|
||||
if (globals_p->snapshot_buffer_write_offset + sizeof (ecma_compiled_code_t) > snapshot_buffer_size)
|
||||
{
|
||||
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE,
|
||||
(const jerry_char_t *) error_buffer_too_small_p);
|
||||
globals_p->snapshot_error =
|
||||
jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_buffer_too_small_p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -204,8 +207,8 @@ snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, /**< co
|
||||
buffer_p,
|
||||
buffer_size))
|
||||
{
|
||||
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE,
|
||||
(const jerry_char_t *) error_buffer_too_small_p);
|
||||
globals_p->snapshot_error =
|
||||
jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_buffer_too_small_p);
|
||||
/* cannot return inside ECMA_FINALIZE_UTF8_STRING */
|
||||
}
|
||||
|
||||
@ -217,8 +220,7 @@ snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, /**< co
|
||||
}
|
||||
|
||||
globals_p->regex_found = true;
|
||||
globals_p->snapshot_buffer_write_offset = JERRY_ALIGNUP (globals_p->snapshot_buffer_write_offset,
|
||||
JMEM_ALIGNMENT);
|
||||
globals_p->snapshot_buffer_write_offset = JERRY_ALIGNUP (globals_p->snapshot_buffer_write_offset, JMEM_ALIGNMENT);
|
||||
|
||||
/* Regexp character size is stored in refs. */
|
||||
copied_code_p->refs = (uint16_t) pattern_size;
|
||||
@ -274,8 +276,7 @@ snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, /**< co
|
||||
|
||||
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_start_p[i]);
|
||||
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, literal_start_p[i]);
|
||||
|
||||
if (bytecode_p == compiled_code_p)
|
||||
{
|
||||
@ -283,10 +284,7 @@ snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, /**< co
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t offset = snapshot_add_compiled_code (bytecode_p,
|
||||
snapshot_buffer_p,
|
||||
snapshot_buffer_size,
|
||||
globals_p);
|
||||
uint32_t offset = snapshot_add_compiled_code (bytecode_p, snapshot_buffer_p, snapshot_buffer_size, globals_p);
|
||||
|
||||
JERRY_ASSERT (!ecma_is_value_empty (globals_p->snapshot_error) || offset > start_offset);
|
||||
|
||||
@ -316,8 +314,7 @@ static_snapshot_error_unsupported_literal (snapshot_globals_t *globals_p, /**< s
|
||||
|
||||
ecma_deref_ecma_string (literal_string_p);
|
||||
|
||||
ecma_object_t *error_object_p = ecma_new_standard_error (JERRY_ERROR_RANGE,
|
||||
ecma_stringbuilder_finalize (&builder));
|
||||
ecma_object_t *error_object_p = ecma_new_standard_error (JERRY_ERROR_RANGE, ecma_stringbuilder_finalize (&builder));
|
||||
|
||||
globals_p->snapshot_error = ecma_create_error_object_reference (error_object_p);
|
||||
} /* static_snapshot_error_unsupported_literal */
|
||||
@ -342,8 +339,8 @@ static_snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p,
|
||||
|
||||
if (globals_p->snapshot_buffer_write_offset >= JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET)
|
||||
{
|
||||
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE,
|
||||
(const jerry_char_t *) ecma_error_maximum_snapshot_size);
|
||||
globals_p->snapshot_error =
|
||||
jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) ecma_error_maximum_snapshot_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -357,8 +354,8 @@ static_snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p,
|
||||
if (!CBC_IS_FUNCTION (compiled_code_p->status_flags))
|
||||
{
|
||||
/* Regular expression literals are not supported. */
|
||||
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE,
|
||||
(const jerry_char_t *) ecma_error_regular_expression_not_supported);
|
||||
globals_p->snapshot_error =
|
||||
jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) ecma_error_regular_expression_not_supported);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -368,8 +365,8 @@ static_snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p,
|
||||
compiled_code_p,
|
||||
((size_t) compiled_code_p->size) << JMEM_ALIGNMENT_LOG))
|
||||
{
|
||||
globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE,
|
||||
(const jerry_char_t *) ecma_error_snapshot_buffer_small);
|
||||
globals_p->snapshot_error =
|
||||
jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) ecma_error_snapshot_buffer_small);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -404,8 +401,7 @@ static_snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p,
|
||||
|
||||
for (uint32_t i = 0; i < const_literal_end; i++)
|
||||
{
|
||||
if (!ecma_is_value_direct (literal_start_p[i])
|
||||
&& !ecma_is_value_direct_string (literal_start_p[i]))
|
||||
if (!ecma_is_value_direct (literal_start_p[i]) && !ecma_is_value_direct_string (literal_start_p[i]))
|
||||
{
|
||||
static_snapshot_error_unsupported_literal (globals_p, literal_start_p[i]);
|
||||
return 0;
|
||||
@ -414,8 +410,7 @@ static_snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_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_start_p[i]);
|
||||
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, literal_start_p[i]);
|
||||
|
||||
if (bytecode_p == compiled_code_p)
|
||||
{
|
||||
@ -423,10 +418,8 @@ static_snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p,
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t offset = static_snapshot_add_compiled_code (bytecode_p,
|
||||
snapshot_buffer_p,
|
||||
snapshot_buffer_size,
|
||||
globals_p);
|
||||
uint32_t offset =
|
||||
static_snapshot_add_compiled_code (bytecode_p, snapshot_buffer_p, snapshot_buffer_size, globals_p);
|
||||
|
||||
JERRY_ASSERT (!ecma_is_value_empty (globals_p->snapshot_error) || offset > start_offset);
|
||||
|
||||
@ -439,8 +432,7 @@ static_snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p,
|
||||
|
||||
while (literal_start_p < (ecma_value_t *) buffer_p)
|
||||
{
|
||||
if (!ecma_is_value_direct_string (*literal_start_p)
|
||||
&& !ecma_is_value_empty (*literal_start_p))
|
||||
if (!ecma_is_value_direct_string (*literal_start_p) && !ecma_is_value_empty (*literal_start_p))
|
||||
{
|
||||
static_snapshot_error_unsupported_literal (globals_p, *literal_start_p);
|
||||
return 0;
|
||||
@ -535,8 +527,7 @@ jerry_snapshot_set_offsets (uint32_t *buffer_p, /**< buffer */
|
||||
JERRY_ASSERT ((code_size % sizeof (uint32_t)) == 0);
|
||||
buffer_p += code_size / sizeof (uint32_t);
|
||||
size -= code_size;
|
||||
}
|
||||
while (size > 0);
|
||||
} while (size > 0);
|
||||
} /* jerry_snapshot_set_offsets */
|
||||
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
@ -571,11 +562,9 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
|
||||
const uint8_t *regex_start_p = ((const uint8_t *) bytecode_p) + sizeof (ecma_compiled_code_t);
|
||||
|
||||
/* Real size is stored in refs. */
|
||||
ecma_string_t *pattern_str_p = ecma_new_ecma_string_from_utf8 (regex_start_p,
|
||||
bytecode_p->refs);
|
||||
ecma_string_t *pattern_str_p = ecma_new_ecma_string_from_utf8 (regex_start_p, bytecode_p->refs);
|
||||
|
||||
const re_compiled_code_t *re_bytecode_p = re_compile_bytecode (pattern_str_p,
|
||||
bytecode_p->status_flags);
|
||||
const re_compiled_code_t *re_bytecode_p = re_compile_bytecode (pattern_str_p, bytecode_p->status_flags);
|
||||
ecma_deref_ecma_string (pattern_str_p);
|
||||
|
||||
return (ecma_compiled_code_t *) re_bytecode_p;
|
||||
@ -622,8 +611,7 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (args_p->script_value, script_p);
|
||||
}
|
||||
|
||||
if (copy_bytecode
|
||||
|| (header_size + (literal_end * sizeof (uint16_t)) + BYTECODE_NO_COPY_THRESHOLD > code_size))
|
||||
if (copy_bytecode || (header_size + (literal_end * sizeof (uint16_t)) + BYTECODE_NO_COPY_THRESHOLD > code_size))
|
||||
{
|
||||
bytecode_p = (ecma_compiled_code_t *) jmem_heap_alloc_block (code_size);
|
||||
|
||||
@ -716,19 +704,15 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
|
||||
if (literal_offset == 0)
|
||||
{
|
||||
/* Self reference */
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (literal_start_p[i],
|
||||
bytecode_p);
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (literal_start_p[i], bytecode_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_compiled_code_t *literal_bytecode_p;
|
||||
literal_bytecode_p = snapshot_load_compiled_code (base_addr_p + literal_offset,
|
||||
literal_base_p,
|
||||
script_p,
|
||||
copy_bytecode);
|
||||
literal_bytecode_p =
|
||||
snapshot_load_compiled_code (base_addr_p + literal_offset, literal_base_p, script_p, copy_bytecode);
|
||||
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (literal_start_p[i],
|
||||
literal_bytecode_p);
|
||||
ECMA_SET_INTERNAL_VALUE_POINTER (literal_start_p[i], literal_bytecode_p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -805,8 +789,7 @@ jerry_generate_snapshot (jerry_value_t compiled_code, /**< parsed script or func
|
||||
}
|
||||
|
||||
snapshot_globals_t globals;
|
||||
const uint32_t aligned_header_size = JERRY_ALIGNUP (sizeof (jerry_snapshot_header_t),
|
||||
JMEM_ALIGNMENT);
|
||||
const uint32_t aligned_header_size = JERRY_ALIGNUP (sizeof (jerry_snapshot_header_t), JMEM_ALIGNMENT);
|
||||
|
||||
globals.snapshot_buffer_write_offset = aligned_header_size;
|
||||
globals.snapshot_error = ECMA_VALUE_EMPTY;
|
||||
@ -862,11 +845,7 @@ jerry_generate_snapshot (jerry_value_t compiled_code, /**< parsed script or func
|
||||
|
||||
size_t header_offset = 0;
|
||||
|
||||
snapshot_write_to_buffer_by_offset ((uint8_t *) buffer_p,
|
||||
buffer_size,
|
||||
&header_offset,
|
||||
&header,
|
||||
sizeof (header));
|
||||
snapshot_write_to_buffer_by_offset ((uint8_t *) buffer_p, buffer_size, &header_offset, &header, sizeof (header));
|
||||
|
||||
if (lit_map_p != NULL)
|
||||
{
|
||||
@ -904,11 +883,9 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */
|
||||
#if JERRY_SNAPSHOT_EXEC
|
||||
JERRY_ASSERT (snapshot_p != NULL);
|
||||
|
||||
uint32_t allowed_opts = (JERRY_SNAPSHOT_EXEC_COPY_DATA
|
||||
| JERRY_SNAPSHOT_EXEC_ALLOW_STATIC
|
||||
| JERRY_SNAPSHOT_EXEC_LOAD_AS_FUNCTION
|
||||
| JERRY_SNAPSHOT_EXEC_HAS_RESOURCE
|
||||
| JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE);
|
||||
uint32_t allowed_opts =
|
||||
(JERRY_SNAPSHOT_EXEC_COPY_DATA | JERRY_SNAPSHOT_EXEC_ALLOW_STATIC | JERRY_SNAPSHOT_EXEC_LOAD_AS_FUNCTION
|
||||
| JERRY_SNAPSHOT_EXEC_HAS_RESOURCE | JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE);
|
||||
|
||||
if ((exec_snapshot_opts & ~(allowed_opts)) != 0)
|
||||
{
|
||||
@ -916,8 +893,8 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */
|
||||
return ecma_create_error_reference_from_context ();
|
||||
}
|
||||
|
||||
const char * const invalid_version_error_p = "Invalid snapshot version or unsupported features present";
|
||||
const char * const invalid_format_error_p = "Invalid snapshot format";
|
||||
const char *const invalid_version_error_p = "Invalid snapshot version or unsupported features present";
|
||||
const char *const invalid_format_error_p = "Invalid snapshot format";
|
||||
const uint8_t *snapshot_data_p = (uint8_t *) snapshot_p;
|
||||
|
||||
if (snapshot_size <= sizeof (jerry_snapshot_header_t))
|
||||
@ -928,8 +905,7 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */
|
||||
|
||||
const jerry_snapshot_header_t *header_p = (const jerry_snapshot_header_t *) snapshot_data_p;
|
||||
|
||||
if (header_p->magic != JERRY_SNAPSHOT_MAGIC
|
||||
|| header_p->version != JERRY_SNAPSHOT_VERSION
|
||||
if (header_p->magic != JERRY_SNAPSHOT_MAGIC || header_p->version != JERRY_SNAPSHOT_VERSION
|
||||
|| !snapshot_check_global_flags (header_p->global_flags))
|
||||
{
|
||||
ecma_raise_type_error (invalid_version_error_p);
|
||||
@ -971,8 +947,7 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */
|
||||
{
|
||||
ecma_value_t user_value = ECMA_VALUE_EMPTY;
|
||||
|
||||
if ((exec_snapshot_opts & JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE)
|
||||
&& option_values_p != NULL)
|
||||
if ((exec_snapshot_opts & JERRY_SNAPSHOT_EXEC_HAS_USER_VALUE) && option_values_p != NULL)
|
||||
{
|
||||
user_value = option_values_p->user_value;
|
||||
}
|
||||
@ -995,8 +970,7 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */
|
||||
#if JERRY_RESOURCE_NAME
|
||||
ecma_value_t resource_name = ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON);
|
||||
|
||||
if ((exec_snapshot_opts & JERRY_SNAPSHOT_EXEC_HAS_RESOURCE)
|
||||
&& option_values_p != NULL
|
||||
if ((exec_snapshot_opts & JERRY_SNAPSHOT_EXEC_HAS_RESOURCE) && option_values_p != NULL
|
||||
&& ecma_is_value_string (option_values_p->resource_name) > 0)
|
||||
{
|
||||
ecma_ref_ecma_string (ecma_get_string_from_value (option_values_p->resource_name));
|
||||
@ -1113,8 +1087,7 @@ scan_snapshot_functions (const uint8_t *buffer_p, /**< snapshot buffer start */
|
||||
const ecma_compiled_code_t *bytecode_p = (ecma_compiled_code_t *) buffer_p;
|
||||
uint32_t code_size = ((uint32_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
|
||||
|
||||
if (CBC_IS_FUNCTION (bytecode_p->status_flags)
|
||||
&& !(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
|
||||
if (CBC_IS_FUNCTION (bytecode_p->status_flags) && !(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
|
||||
{
|
||||
const ecma_value_t *literal_start_p;
|
||||
uint32_t const_literal_end;
|
||||
@ -1159,8 +1132,7 @@ scan_snapshot_functions (const uint8_t *buffer_p, /**< snapshot buffer start */
|
||||
}
|
||||
|
||||
buffer_p += code_size;
|
||||
}
|
||||
while (buffer_p < buffer_end_p);
|
||||
} while (buffer_p < buffer_end_p);
|
||||
} /* scan_snapshot_functions */
|
||||
|
||||
/**
|
||||
@ -1179,8 +1151,7 @@ update_literal_offsets (uint8_t *buffer_p, /**< [in,out] snapshot buffer start *
|
||||
const ecma_compiled_code_t *bytecode_p = (ecma_compiled_code_t *) buffer_p;
|
||||
uint32_t code_size = ((uint32_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
|
||||
|
||||
if (CBC_IS_FUNCTION (bytecode_p->status_flags)
|
||||
&& !(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
|
||||
if (CBC_IS_FUNCTION (bytecode_p->status_flags) && !(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
|
||||
{
|
||||
ecma_value_t *literal_start_p;
|
||||
uint32_t const_literal_end;
|
||||
@ -1239,8 +1210,7 @@ update_literal_offsets (uint8_t *buffer_p, /**< [in,out] snapshot buffer start *
|
||||
}
|
||||
|
||||
buffer_p += code_size;
|
||||
}
|
||||
while (buffer_p < buffer_end_p);
|
||||
} while (buffer_p < buffer_end_p);
|
||||
} /* update_literal_offsets */
|
||||
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
@ -1283,8 +1253,7 @@ jerry_merge_snapshots (const uint32_t **inp_buffers_p, /**< array of (pointers t
|
||||
|
||||
const jerry_snapshot_header_t *header_p = (const jerry_snapshot_header_t *) inp_buffers_p[i];
|
||||
|
||||
if (header_p->magic != JERRY_SNAPSHOT_MAGIC
|
||||
|| header_p->version != JERRY_SNAPSHOT_VERSION
|
||||
if (header_p->magic != JERRY_SNAPSHOT_MAGIC || header_p->version != JERRY_SNAPSHOT_VERSION
|
||||
|| !snapshot_check_global_flags (header_p->global_flags))
|
||||
{
|
||||
*error_p = "invalid snapshot version or unsupported features present";
|
||||
@ -1303,10 +1272,7 @@ jerry_merge_snapshots (const uint32_t **inp_buffers_p, /**< array of (pointers t
|
||||
number_of_funcs += header_p->number_of_funcs;
|
||||
functions_size += header_p->lit_table_offset - start_offset;
|
||||
|
||||
scan_snapshot_functions (data_p + start_offset,
|
||||
literal_base_p,
|
||||
lit_pool_p,
|
||||
literal_base_p);
|
||||
scan_snapshot_functions (data_p + start_offset, literal_base_p, lit_pool_p, literal_base_p);
|
||||
}
|
||||
|
||||
JERRY_ASSERT (number_of_funcs > 0);
|
||||
@ -1436,14 +1402,12 @@ jerry_save_literals_heap_max (ecma_string_t *literals[], /**< array of literals
|
||||
{
|
||||
lit_utf8_size_t max_idx = node_idx;
|
||||
|
||||
if (child_idx1 < num_of_nodes
|
||||
&& jerry_save_literals_compare (literals[max_idx], literals[child_idx1]))
|
||||
if (child_idx1 < num_of_nodes && jerry_save_literals_compare (literals[max_idx], literals[child_idx1]))
|
||||
{
|
||||
max_idx = child_idx1;
|
||||
}
|
||||
|
||||
if (child_idx2 < num_of_nodes
|
||||
&& jerry_save_literals_compare (literals[max_idx], literals[child_idx2]))
|
||||
if (child_idx2 < num_of_nodes && jerry_save_literals_compare (literals[max_idx], literals[child_idx2]))
|
||||
{
|
||||
max_idx = child_idx2;
|
||||
}
|
||||
@ -1461,17 +1425,14 @@ jerry_save_literals_down_heap (ecma_string_t *literals[], /**< array of literals
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
lit_utf8_size_t max_idx = jerry_save_literals_heap_max (literals,
|
||||
num_of_nodes,
|
||||
node_idx,
|
||||
2 * node_idx + 1,
|
||||
2 * node_idx + 2);
|
||||
lit_utf8_size_t max_idx =
|
||||
jerry_save_literals_heap_max (literals, num_of_nodes, node_idx, 2 * node_idx + 1, 2 * node_idx + 2);
|
||||
if (max_idx == node_idx)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
ecma_string_t *tmp_str_p = literals[node_idx];
|
||||
ecma_string_t *tmp_str_p = literals[node_idx];
|
||||
literals[node_idx] = literals[max_idx];
|
||||
literals[max_idx] = tmp_str_p;
|
||||
|
||||
@ -1555,10 +1516,8 @@ jerry_append_ecma_string_to_buffer (uint8_t *buffer_p, /**< buffer */
|
||||
ECMA_STRING_TO_UTF8_STRING (string_p, str_buffer_p, str_buffer_size);
|
||||
|
||||
/* Append the string to the buffer. */
|
||||
uint8_t *new_buffer_p = jerry_append_chars_to_buffer (buffer_p,
|
||||
buffer_end_p,
|
||||
(const char *) str_buffer_p,
|
||||
str_buffer_size);
|
||||
uint8_t *new_buffer_p =
|
||||
jerry_append_chars_to_buffer (buffer_p, buffer_end_p, (const char *) str_buffer_p, str_buffer_size);
|
||||
|
||||
ECMA_FINALIZE_UTF8_STRING (str_buffer_p, str_buffer_size);
|
||||
|
||||
@ -1576,16 +1535,12 @@ jerry_append_number_to_buffer (uint8_t *buffer_p, /**< buffer */
|
||||
lit_utf8_size_t number) /**< number */
|
||||
{
|
||||
lit_utf8_byte_t uint32_to_str_buffer[ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32];
|
||||
lit_utf8_size_t utf8_str_size = ecma_uint32_to_utf8_string (number,
|
||||
uint32_to_str_buffer,
|
||||
ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32);
|
||||
lit_utf8_size_t utf8_str_size =
|
||||
ecma_uint32_to_utf8_string (number, uint32_to_str_buffer, ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32);
|
||||
|
||||
JERRY_ASSERT (utf8_str_size <= ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32);
|
||||
|
||||
return jerry_append_chars_to_buffer (buffer_p,
|
||||
buffer_end_p,
|
||||
(const char *) uint32_to_str_buffer,
|
||||
utf8_str_size);
|
||||
return jerry_append_chars_to_buffer (buffer_p, buffer_end_p, (const char *) uint32_to_str_buffer, utf8_str_size);
|
||||
} /* jerry_append_number_to_buffer */
|
||||
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
@ -1612,10 +1567,8 @@ jerry_get_literals_from_snapshot (const uint32_t *snapshot_p, /**< input snapsho
|
||||
const uint8_t *snapshot_data_p = (uint8_t *) snapshot_p;
|
||||
const jerry_snapshot_header_t *header_p = (const jerry_snapshot_header_t *) snapshot_data_p;
|
||||
|
||||
if (snapshot_size <= sizeof (jerry_snapshot_header_t)
|
||||
|| header_p->magic != JERRY_SNAPSHOT_MAGIC
|
||||
|| header_p->version != JERRY_SNAPSHOT_VERSION
|
||||
|| !snapshot_check_global_flags (header_p->global_flags))
|
||||
if (snapshot_size <= sizeof (jerry_snapshot_header_t) || header_p->magic != JERRY_SNAPSHOT_MAGIC
|
||||
|| header_p->version != JERRY_SNAPSHOT_VERSION || !snapshot_check_global_flags (header_p->global_flags))
|
||||
{
|
||||
/* Invalid snapshot format */
|
||||
return 0;
|
||||
@ -1625,10 +1578,7 @@ jerry_get_literals_from_snapshot (const uint32_t *snapshot_p, /**< input snapsho
|
||||
const uint8_t *literal_base_p = snapshot_data_p + header_p->lit_table_offset;
|
||||
|
||||
ecma_collection_t *lit_pool_p = ecma_new_collection ();
|
||||
scan_snapshot_functions (snapshot_data_p + header_p->func_offsets[0],
|
||||
literal_base_p,
|
||||
lit_pool_p,
|
||||
literal_base_p);
|
||||
scan_snapshot_functions (snapshot_data_p + header_p->func_offsets[0], literal_base_p, lit_pool_p, literal_base_p);
|
||||
|
||||
lit_utf8_size_t literal_count = 0;
|
||||
ecma_value_t *buffer_p = lit_pool_p->buffer_p;
|
||||
@ -1683,18 +1633,12 @@ jerry_get_literals_from_snapshot (const uint32_t *snapshot_p, /**< input snapsho
|
||||
if (is_c_format)
|
||||
{
|
||||
/* Save literal count. */
|
||||
lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p,
|
||||
buffer_end_p,
|
||||
"jerry_length_t literal_count = ",
|
||||
0);
|
||||
lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, buffer_end_p, "jerry_length_t literal_count = ", 0);
|
||||
|
||||
lit_buf_p = jerry_append_number_to_buffer (lit_buf_p, buffer_end_p, literal_count);
|
||||
|
||||
/* Save the array of literals. */
|
||||
lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p,
|
||||
buffer_end_p,
|
||||
";\n\njerry_char_t *literals[",
|
||||
0);
|
||||
lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, buffer_end_p, ";\n\njerry_char_t *literals[", 0);
|
||||
|
||||
lit_buf_p = jerry_append_number_to_buffer (lit_buf_p, buffer_end_p, literal_count);
|
||||
lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, buffer_end_p, "] =\n{\n", 0);
|
||||
@ -1735,10 +1679,7 @@ jerry_get_literals_from_snapshot (const uint32_t *snapshot_p, /**< input snapsho
|
||||
lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, buffer_end_p, "\n", 0);
|
||||
}
|
||||
|
||||
lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p,
|
||||
buffer_end_p,
|
||||
"};\n\njerry_length_t literal_sizes[",
|
||||
0);
|
||||
lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, buffer_end_p, "};\n\njerry_length_t literal_sizes[", 0);
|
||||
|
||||
lit_buf_p = jerry_append_number_to_buffer (lit_buf_p, buffer_end_p, literal_count);
|
||||
lit_buf_p = jerry_append_chars_to_buffer (lit_buf_p, buffer_end_p, "] =\n{\n", 0);
|
||||
|
||||
@ -13,10 +13,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "jerryscript.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "jerryscript-debugger-transport.h"
|
||||
|
||||
#include "debugger.h"
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
@ -37,17 +40,17 @@
|
||||
#include "ecma-lex-env.h"
|
||||
#include "ecma-line-info.h"
|
||||
#include "ecma-literal-storage.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-objects-general.h"
|
||||
#include "ecma-regexp-object.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-promise-object.h"
|
||||
#include "ecma-proxy-object.h"
|
||||
#include "ecma-regexp-object.h"
|
||||
#include "ecma-shared-arraybuffer-object.h"
|
||||
#include "ecma-symbol-object.h"
|
||||
#include "ecma-typedarray-object.h"
|
||||
|
||||
#include "debugger.h"
|
||||
#include "jcontext.h"
|
||||
#include "jerryscript.h"
|
||||
#include "jerryscript-debugger-transport.h"
|
||||
#include "jmem.h"
|
||||
#include "js-parser.h"
|
||||
#include "lit-char-helpers.h"
|
||||
@ -59,18 +62,18 @@ JERRY_STATIC_ASSERT (sizeof (jerry_value_t) == sizeof (ecma_value_t),
|
||||
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
JERRY_STATIC_ASSERT ((int) RE_FLAG_GLOBAL == (int) JERRY_REGEXP_FLAG_GLOBAL
|
||||
&& (int) RE_FLAG_MULTILINE == (int) JERRY_REGEXP_FLAG_MULTILINE
|
||||
&& (int) RE_FLAG_IGNORE_CASE == (int) JERRY_REGEXP_FLAG_IGNORE_CASE
|
||||
&& (int) RE_FLAG_STICKY== (int) JERRY_REGEXP_FLAG_STICKY
|
||||
&& (int) RE_FLAG_UNICODE == (int) JERRY_REGEXP_FLAG_UNICODE
|
||||
&& (int) RE_FLAG_DOTALL == (int) JERRY_REGEXP_FLAG_DOTALL,
|
||||
&& (int) RE_FLAG_MULTILINE == (int) JERRY_REGEXP_FLAG_MULTILINE
|
||||
&& (int) RE_FLAG_IGNORE_CASE == (int) JERRY_REGEXP_FLAG_IGNORE_CASE
|
||||
&& (int) RE_FLAG_STICKY == (int) JERRY_REGEXP_FLAG_STICKY
|
||||
&& (int) RE_FLAG_UNICODE == (int) JERRY_REGEXP_FLAG_UNICODE
|
||||
&& (int) RE_FLAG_DOTALL == (int) JERRY_REGEXP_FLAG_DOTALL,
|
||||
re_flags_t_must_be_equal_to_jerry_regexp_flags_t);
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
/* The internal ECMA_PROMISE_STATE_* values are "one byte away" from the API values */
|
||||
JERRY_STATIC_ASSERT ((int) ECMA_PROMISE_IS_PENDING == (int) JERRY_PROMISE_STATE_PENDING
|
||||
&& (int) ECMA_PROMISE_IS_FULFILLED == (int) JERRY_PROMISE_STATE_FULFILLED,
|
||||
&& (int) ECMA_PROMISE_IS_FULFILLED == (int) JERRY_PROMISE_STATE_FULFILLED,
|
||||
promise_internal_state_matches_external);
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
@ -80,9 +83,10 @@ JERRY_STATIC_ASSERT ((int) ECMA_PROMISE_IS_PENDING == (int) JERRY_PROMISE_STATE_
|
||||
#define ECMA_NUMBER_ARITHMETIC_OP_API_OFFSET (JERRY_BIN_OP_SUB - NUMBER_ARITHMETIC_SUBTRACTION)
|
||||
|
||||
JERRY_STATIC_ASSERT (((NUMBER_ARITHMETIC_SUBTRACTION + ECMA_NUMBER_ARITHMETIC_OP_API_OFFSET) == JERRY_BIN_OP_SUB)
|
||||
&& ((NUMBER_ARITHMETIC_MULTIPLICATION + ECMA_NUMBER_ARITHMETIC_OP_API_OFFSET) == JERRY_BIN_OP_MUL)
|
||||
&& ((NUMBER_ARITHMETIC_DIVISION + ECMA_NUMBER_ARITHMETIC_OP_API_OFFSET) == JERRY_BIN_OP_DIV)
|
||||
&& ((NUMBER_ARITHMETIC_REMAINDER + ECMA_NUMBER_ARITHMETIC_OP_API_OFFSET) == JERRY_BIN_OP_REM),
|
||||
&& ((NUMBER_ARITHMETIC_MULTIPLICATION + ECMA_NUMBER_ARITHMETIC_OP_API_OFFSET)
|
||||
== JERRY_BIN_OP_MUL)
|
||||
&& ((NUMBER_ARITHMETIC_DIVISION + ECMA_NUMBER_ARITHMETIC_OP_API_OFFSET) == JERRY_BIN_OP_DIV)
|
||||
&& ((NUMBER_ARITHMETIC_REMAINDER + ECMA_NUMBER_ARITHMETIC_OP_API_OFFSET) == JERRY_BIN_OP_REM),
|
||||
number_arithmetics_operation_type_matches_external);
|
||||
|
||||
#if !JERRY_PARSER && !JERRY_SNAPSHOT_EXEC
|
||||
@ -172,7 +176,8 @@ jerry_init (jerry_init_flag_t flags) /**< combination of Jerry flags */
|
||||
JERRY_ASSERT (!(JERRY_CONTEXT (status_flags) & ECMA_STATUS_API_AVAILABLE));
|
||||
|
||||
/* Zero out all non-external members. */
|
||||
memset ((char *) &JERRY_CONTEXT_STRUCT + offsetof (jerry_context_t, JERRY_CONTEXT_FIRST_MEMBER), 0,
|
||||
memset ((char *) &JERRY_CONTEXT_STRUCT + offsetof (jerry_context_t, JERRY_CONTEXT_FIRST_MEMBER),
|
||||
0,
|
||||
sizeof (jerry_context_t) - offsetof (jerry_context_t, JERRY_CONTEXT_FIRST_MEMBER));
|
||||
|
||||
JERRY_CONTEXT (jerry_init_flags) = flags;
|
||||
@ -200,9 +205,7 @@ jerry_cleanup (void)
|
||||
}
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
|
||||
for (jerry_context_data_header_t *this_p = JERRY_CONTEXT (context_data_p);
|
||||
this_p != NULL;
|
||||
this_p = this_p->next_p)
|
||||
for (jerry_context_data_header_t *this_p = JERRY_CONTEXT (context_data_p); this_p != NULL; this_p = this_p->next_p)
|
||||
{
|
||||
if (this_p->manager_p->deinit_cb)
|
||||
{
|
||||
@ -217,8 +220,7 @@ jerry_cleanup (void)
|
||||
ecma_finalize ();
|
||||
jerry_make_api_unavailable ();
|
||||
|
||||
for (jerry_context_data_header_t *this_p = JERRY_CONTEXT (context_data_p), *next_p = NULL;
|
||||
this_p != NULL;
|
||||
for (jerry_context_data_header_t *this_p = JERRY_CONTEXT (context_data_p), *next_p = NULL; this_p != NULL;
|
||||
this_p = next_p)
|
||||
{
|
||||
next_p = this_p->next_p;
|
||||
@ -278,14 +280,14 @@ jerry_get_context_data (const jerry_context_data_manager_t *manager_p)
|
||||
* Register external magic string array
|
||||
*/
|
||||
void
|
||||
jerry_register_magic_strings (const jerry_char_t * const *ex_str_items_p, /**< character arrays, representing
|
||||
* external magic strings' contents */
|
||||
jerry_register_magic_strings (const jerry_char_t *const *ex_str_items_p, /**< character arrays, representing
|
||||
* external magic strings' contents */
|
||||
uint32_t count, /**< number of the strings */
|
||||
const jerry_length_t *str_lengths_p) /**< lengths of all strings */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
lit_magic_strings_ex_set ((const lit_utf8_byte_t * const *) ex_str_items_p,
|
||||
lit_magic_strings_ex_set ((const lit_utf8_byte_t *const *) ex_str_items_p,
|
||||
count,
|
||||
(const lit_utf8_size_t *) str_lengths_p);
|
||||
} /* jerry_register_magic_strings */
|
||||
@ -327,13 +329,10 @@ jerry_get_memory_stats (jerry_heap_stats_t *out_stats_p) /**< [out] heap memory
|
||||
memset (&jmem_heap_stats, 0, sizeof (jmem_heap_stats));
|
||||
jmem_heap_get_stats (&jmem_heap_stats);
|
||||
|
||||
*out_stats_p = (jerry_heap_stats_t)
|
||||
{
|
||||
.version = 1,
|
||||
.size = jmem_heap_stats.size,
|
||||
.allocated_bytes = jmem_heap_stats.allocated_bytes,
|
||||
.peak_allocated_bytes = jmem_heap_stats.peak_allocated_bytes
|
||||
};
|
||||
*out_stats_p = (jerry_heap_stats_t){ .version = 1,
|
||||
.size = jmem_heap_stats.size,
|
||||
.allocated_bytes = jmem_heap_stats.allocated_bytes,
|
||||
.peak_allocated_bytes = jmem_heap_stats.peak_allocated_bytes };
|
||||
|
||||
return true;
|
||||
#else /* !JERRY_MEM_STATS */
|
||||
@ -394,30 +393,22 @@ jerry_parse_common (void *source_p, /**< script source */
|
||||
|
||||
if (options_p != NULL)
|
||||
{
|
||||
const uint32_t allowed_options = (JERRY_PARSE_STRICT_MODE
|
||||
| JERRY_PARSE_MODULE
|
||||
| JERRY_PARSE_HAS_ARGUMENT_LIST
|
||||
| JERRY_PARSE_HAS_RESOURCE
|
||||
| JERRY_PARSE_HAS_START
|
||||
| JERRY_PARSE_HAS_USER_VALUE);
|
||||
const uint32_t allowed_options = (JERRY_PARSE_STRICT_MODE | JERRY_PARSE_MODULE | JERRY_PARSE_HAS_ARGUMENT_LIST
|
||||
| JERRY_PARSE_HAS_RESOURCE | JERRY_PARSE_HAS_START | JERRY_PARSE_HAS_USER_VALUE);
|
||||
uint32_t options = options_p->options;
|
||||
|
||||
if ((options & ~allowed_options) != 0
|
||||
|| ((options_p->options & JERRY_PARSE_HAS_ARGUMENT_LIST)
|
||||
&& ((options_p->options & JERRY_PARSE_MODULE)
|
||||
|| !ecma_is_value_string (options_p->argument_list)))
|
||||
|| ((options_p->options & JERRY_PARSE_HAS_RESOURCE)
|
||||
&& !ecma_is_value_string (options_p->resource_name)))
|
||||
&& ((options_p->options & JERRY_PARSE_MODULE) || !ecma_is_value_string (options_p->argument_list)))
|
||||
|| ((options_p->options & JERRY_PARSE_HAS_RESOURCE) && !ecma_is_value_string (options_p->resource_name)))
|
||||
{
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
|
||||
}
|
||||
}
|
||||
|
||||
#if JERRY_DEBUGGER
|
||||
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
|
||||
&& options_p != NULL
|
||||
&& (options_p->options & JERRY_PARSE_HAS_RESOURCE)
|
||||
&& ecma_is_value_string (options_p->resource_name))
|
||||
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED) && options_p != NULL
|
||||
&& (options_p->options & JERRY_PARSE_HAS_RESOURCE) && ecma_is_value_string (options_p->resource_name))
|
||||
{
|
||||
ECMA_STRING_TO_UTF8_STRING (ecma_get_string_from_value (options_p->resource_name),
|
||||
resource_name_start_p,
|
||||
@ -471,8 +462,7 @@ jerry_parse_common (void *source_p, /**< script source */
|
||||
}
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
|
||||
if (JERRY_UNLIKELY (options_p != NULL
|
||||
&& (options_p->options & JERRY_PARSE_HAS_ARGUMENT_LIST)))
|
||||
if (JERRY_UNLIKELY (options_p != NULL && (options_p->options & JERRY_PARSE_HAS_ARGUMENT_LIST)))
|
||||
{
|
||||
ecma_object_t *global_object_p = ecma_builtin_get_global ();
|
||||
|
||||
@ -906,8 +896,8 @@ jerry_module_set_import_callback (jerry_module_import_callback_t callback_p, /**
|
||||
jerry_value_t
|
||||
jerry_native_module_create (jerry_native_module_evaluate_callback_t callback, /**< evaluation callback for
|
||||
* native modules */
|
||||
const jerry_value_t * const exports_p, /**< list of the exported bindings of the module,
|
||||
* must be valid string identifiers */
|
||||
const jerry_value_t *const exports_p, /**< list of the exported bindings of the module,
|
||||
* must be valid string identifiers */
|
||||
size_t number_of_exports) /**< number of exports in the exports_p list */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
@ -1033,14 +1023,13 @@ jerry_native_module_get_export (const jerry_value_t native_module_val, /**< a na
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_not_module_p)));
|
||||
}
|
||||
|
||||
if (!(module_p->header.u.cls.u2.module_flags & ECMA_MODULE_IS_NATIVE)
|
||||
|| !ecma_is_value_string (export_name_val))
|
||||
if (!(module_p->header.u.cls.u2.module_flags & ECMA_MODULE_IS_NATIVE) || !ecma_is_value_string (export_name_val))
|
||||
{
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
|
||||
}
|
||||
|
||||
ecma_property_t *property_p = ecma_find_named_property (module_p->scope_p,
|
||||
ecma_get_string_from_value (export_name_val));
|
||||
ecma_property_t *property_p =
|
||||
ecma_find_named_property (module_p->scope_p, ecma_get_string_from_value (export_name_val));
|
||||
|
||||
if (property_p == NULL)
|
||||
{
|
||||
@ -1080,24 +1069,21 @@ jerry_native_module_set_export (const jerry_value_t native_module_val, /**< a na
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_not_module_p)));
|
||||
}
|
||||
|
||||
if (!(module_p->header.u.cls.u2.module_flags & ECMA_MODULE_IS_NATIVE)
|
||||
|| !ecma_is_value_string (export_name_val)
|
||||
if (!(module_p->header.u.cls.u2.module_flags & ECMA_MODULE_IS_NATIVE) || !ecma_is_value_string (export_name_val)
|
||||
|| ecma_is_value_error_reference (value_to_set))
|
||||
{
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
|
||||
}
|
||||
|
||||
ecma_property_t *property_p = ecma_find_named_property (module_p->scope_p,
|
||||
ecma_get_string_from_value (export_name_val));
|
||||
ecma_property_t *property_p =
|
||||
ecma_find_named_property (module_p->scope_p, ecma_get_string_from_value (export_name_val));
|
||||
|
||||
if (property_p == NULL)
|
||||
{
|
||||
return jerry_throw (ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_unknown_export_p)));
|
||||
}
|
||||
|
||||
ecma_named_data_property_assign_value (module_p->scope_p,
|
||||
ECMA_PROPERTY_VALUE_PTR (property_p),
|
||||
value_to_set);
|
||||
ecma_named_data_property_assign_value (module_p->scope_p, ECMA_PROPERTY_VALUE_PTR (property_p), value_to_set);
|
||||
return ECMA_VALUE_TRUE;
|
||||
#else /* !JERRY_MODULE_SYSTEM */
|
||||
JERRY_UNUSED (native_module_val);
|
||||
@ -1287,9 +1273,7 @@ jerry_value_is_async_function (const jerry_value_t value) /**< api value */
|
||||
bytecode_data_p = ecma_op_function_get_compiled_code ((ecma_extended_object_t *) obj_p);
|
||||
uint16_t type = CBC_FUNCTION_GET_TYPE (bytecode_data_p->status_flags);
|
||||
|
||||
return (type == CBC_FUNCTION_ASYNC
|
||||
|| type == CBC_FUNCTION_ASYNC_ARROW
|
||||
|| type == CBC_FUNCTION_ASYNC_GENERATOR);
|
||||
return (type == CBC_FUNCTION_ASYNC || type == CBC_FUNCTION_ASYNC_ARROW || type == CBC_FUNCTION_ASYNC_GENERATOR);
|
||||
}
|
||||
}
|
||||
#else /* !JERRY_ESNEXT */
|
||||
@ -1352,8 +1336,7 @@ jerry_value_is_promise (const jerry_value_t value) /**< api value */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
#if JERRY_ESNEXT
|
||||
return (ecma_is_value_object (value)
|
||||
&& ecma_is_promise (ecma_get_object_from_value (value)));
|
||||
return (ecma_is_value_object (value) && ecma_is_promise (ecma_get_object_from_value (value)));
|
||||
#else /* !JERRY_ESNEXT */
|
||||
JERRY_UNUSED (value);
|
||||
return false;
|
||||
@ -1371,8 +1354,7 @@ jerry_value_is_proxy (const jerry_value_t value) /**< api value */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
return (ecma_is_value_object (value)
|
||||
&& ECMA_OBJECT_IS_PROXY (ecma_get_object_from_value (value)));
|
||||
return (ecma_is_value_object (value) && ECMA_OBJECT_IS_PROXY (ecma_get_object_from_value (value)));
|
||||
#else /* !JERRY_BUILTIN_PROXY */
|
||||
JERRY_UNUSED (value);
|
||||
return false;
|
||||
@ -1513,8 +1495,7 @@ jerry_value_get_type (const jerry_value_t value) /**< input value to check */
|
||||
/**
|
||||
* Used by jerry_object_get_type to get the type of class objects
|
||||
*/
|
||||
static const uint8_t jerry_class_object_type[] =
|
||||
{
|
||||
static const uint8_t jerry_class_object_type[] = {
|
||||
/* These objects require custom property resolving. */
|
||||
JERRY_OBJECT_TYPE_STRING, /**< type of ECMA_OBJECT_CLASS_STRING */
|
||||
JERRY_OBJECT_TYPE_ARGUMENTS, /**< type of ECMA_OBJECT_CLASS_ARGUMENTS */
|
||||
@ -1523,9 +1504,9 @@ static const uint8_t jerry_class_object_type[] =
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
JERRY_OBJECT_TYPE_MODULE_NAMESPACE, /**< type of ECMA_OBJECT_CLASS_MODULE_NAMESPACE */
|
||||
#endif
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
|
||||
/* These objects are marked by Garbage Collector. */
|
||||
/* These objects are marked by Garbage Collector. */
|
||||
#if JERRY_ESNEXT
|
||||
JERRY_OBJECT_TYPE_GENERATOR, /**< type of ECMA_OBJECT_CLASS_GENERATOR */
|
||||
JERRY_OBJECT_TYPE_GENERATOR, /**< type of ECMA_OBJECT_CLASS_ASYNC_GENERATOR */
|
||||
@ -1538,7 +1519,7 @@ static const uint8_t jerry_class_object_type[] =
|
||||
#endif /* JERRY_ESNEXT */
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
JERRY_OBJECT_TYPE_MODULE, /**< type of ECMA_OBJECT_CLASS_MODULE */
|
||||
#endif
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
#if JERRY_ESNEXT
|
||||
JERRY_OBJECT_TYPE_PROMISE, /**< type of ECMA_OBJECT_CLASS_PROMISE */
|
||||
JERRY_OBJECT_TYPE_GENERIC, /**< type of ECMA_OBJECT_CLASS_PROMISE_CAPABILITY */
|
||||
@ -1808,8 +1789,7 @@ jerry_is_feature_enabled (const jerry_feature_t feature) /**< feature to check *
|
||||
|| feature == JERRY_FEATURE_JSON
|
||||
#endif /* JERRY_BUILTIN_JSON */
|
||||
#if JERRY_ESNEXT
|
||||
|| feature == JERRY_FEATURE_PROMISE
|
||||
|| feature == JERRY_FEATURE_SYMBOL
|
||||
|| feature == JERRY_FEATURE_PROMISE || feature == JERRY_FEATURE_SYMBOL
|
||||
#endif /* JERRY_ESNEXT */
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
|| feature == JERRY_FEATURE_TYPEDARRAY
|
||||
@ -1836,9 +1816,7 @@ jerry_is_feature_enabled (const jerry_feature_t feature) /**< feature to check *
|
||||
|| feature == JERRY_FEATURE_GLOBAL_THIS
|
||||
#endif /* JERRY_BUILTIN_GLOBAL_THIS */
|
||||
#if JERRY_BUILTIN_CONTAINER
|
||||
|| feature == JERRY_FEATURE_MAP
|
||||
|| feature == JERRY_FEATURE_SET
|
||||
|| feature == JERRY_FEATURE_WEAKMAP
|
||||
|| feature == JERRY_FEATURE_MAP || feature == JERRY_FEATURE_SET || feature == JERRY_FEATURE_WEAKMAP
|
||||
|| feature == JERRY_FEATURE_WEAKSET
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
#if JERRY_BUILTIN_WEAKREF
|
||||
@ -1859,7 +1837,7 @@ jerry_is_feature_enabled (const jerry_feature_t feature) /**< feature to check *
|
||||
#if JERRY_FUNCTION_TO_STRING
|
||||
|| feature == JERRY_FEATURE_FUNCTION_TO_STRING
|
||||
#endif /* JERRY_FUNCTION_TO_STRING */
|
||||
);
|
||||
);
|
||||
} /* jerry_is_feature_enabled */
|
||||
|
||||
/**
|
||||
@ -1908,8 +1886,7 @@ jerry_binary_operation (jerry_binary_operation_t op, /**< operation */
|
||||
}
|
||||
case JERRY_BIN_OP_INSTANCEOF:
|
||||
{
|
||||
if (!ecma_is_value_object (lhs)
|
||||
|| !ecma_op_is_callable (rhs))
|
||||
if (!ecma_is_value_object (lhs) || !ecma_op_is_callable (rhs))
|
||||
{
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
|
||||
}
|
||||
@ -2054,8 +2031,9 @@ jerry_set_error_object_created_callback (jerry_error_object_created_callback_t c
|
||||
* When JERRY_VM_THROW is enabled, the callback passed to this
|
||||
* function is called when an error is thrown in ECMAScript code.
|
||||
*/
|
||||
void jerry_set_vm_throw_callback (jerry_vm_throw_callback_t throw_cb, /**< callback which is called on throws */
|
||||
void *user_p) /**< pointer passed to the function */
|
||||
void
|
||||
jerry_set_vm_throw_callback (jerry_vm_throw_callback_t throw_cb, /**< callback which is called on throws */
|
||||
void *user_p) /**< pointer passed to the function */
|
||||
{
|
||||
#if JERRY_VM_THROW
|
||||
JERRY_CONTEXT (vm_throw_callback_p) = throw_cb;
|
||||
@ -2270,7 +2248,6 @@ jerry_value_to_primitive (const jerry_value_t value) /**< input value */
|
||||
jerry_value_t
|
||||
jerry_value_to_string (const jerry_value_t value) /**< input value */
|
||||
{
|
||||
|
||||
jerry_assert_api_available ();
|
||||
|
||||
if (ecma_is_value_error_reference (value))
|
||||
@ -2474,9 +2451,7 @@ jerry_create_error (jerry_error_t error_type, /**< type of error */
|
||||
const jerry_char_t *message_p) /**< value of 'message' property
|
||||
* of constructed error object */
|
||||
{
|
||||
return jerry_create_error_sz (error_type,
|
||||
(lit_utf8_byte_t *) message_p,
|
||||
lit_zt_utf8_string_size (message_p));
|
||||
return jerry_create_error_sz (error_type, (lit_utf8_byte_t *) message_p, lit_zt_utf8_string_size (message_p));
|
||||
} /* jerry_create_error */
|
||||
|
||||
/**
|
||||
@ -2502,11 +2477,10 @@ jerry_create_error_sz (jerry_error_t error_type, /**< type of error */
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_string_t *message_string_p = ecma_new_ecma_string_from_utf8 ((lit_utf8_byte_t *) message_p,
|
||||
(lit_utf8_size_t) message_size);
|
||||
ecma_string_t *message_string_p =
|
||||
ecma_new_ecma_string_from_utf8 ((lit_utf8_byte_t *) message_p, (lit_utf8_size_t) message_size);
|
||||
|
||||
ecma_object_t *error_object_p = ecma_new_standard_error ((jerry_error_t) error_type,
|
||||
message_string_p);
|
||||
ecma_object_t *error_object_p = ecma_new_standard_error ((jerry_error_t) error_type, message_string_p);
|
||||
|
||||
ecma_deref_ecma_string (message_string_p);
|
||||
|
||||
@ -2660,8 +2634,7 @@ jerry_create_proxy (const jerry_value_t target, /**< target argument */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
if (ecma_is_value_error_reference (target)
|
||||
|| ecma_is_value_error_reference (handler))
|
||||
if (ecma_is_value_error_reference (target) || ecma_is_value_error_reference (handler))
|
||||
{
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
|
||||
}
|
||||
@ -2696,8 +2669,7 @@ jerry_create_special_proxy (const jerry_value_t target, /**< target argument */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
if (ecma_is_value_error_reference (target)
|
||||
|| ecma_is_value_error_reference (handler))
|
||||
if (ecma_is_value_error_reference (target) || ecma_is_value_error_reference (handler))
|
||||
{
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
|
||||
}
|
||||
@ -2741,8 +2713,8 @@ jerry_create_string_sz_from_utf8 (const jerry_char_t *str_p, /**< pointer to str
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
ecma_string_t *ecma_str_p = ecma_new_ecma_string_from_utf8_converted_to_cesu8 ((lit_utf8_byte_t *) str_p,
|
||||
(lit_utf8_size_t) str_size);
|
||||
ecma_string_t *ecma_str_p =
|
||||
ecma_new_ecma_string_from_utf8_converted_to_cesu8 ((lit_utf8_byte_t *) str_p, (lit_utf8_size_t) str_size);
|
||||
|
||||
return ecma_make_string_value (ecma_str_p);
|
||||
} /* jerry_create_string_sz_from_utf8 */
|
||||
@ -2775,8 +2747,7 @@ jerry_create_string_sz (const jerry_char_t *str_p, /**< pointer to string */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
ecma_string_t *ecma_str_p = ecma_new_ecma_string_from_utf8 ((lit_utf8_byte_t *) str_p,
|
||||
(lit_utf8_size_t) str_size);
|
||||
ecma_string_t *ecma_str_p = ecma_new_ecma_string_from_utf8 ((lit_utf8_byte_t *) str_p, (lit_utf8_size_t) str_size);
|
||||
return ecma_make_string_value (ecma_str_p);
|
||||
} /* jerry_create_string_sz */
|
||||
|
||||
@ -2810,9 +2781,8 @@ jerry_create_external_string_sz (const jerry_char_t *str_p, /**< pointer to stri
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
ecma_string_t *ecma_str_p = ecma_new_ecma_external_string_from_cesu8 ((lit_utf8_byte_t *) str_p,
|
||||
(lit_utf8_size_t) str_size,
|
||||
user_p);
|
||||
ecma_string_t *ecma_str_p =
|
||||
ecma_new_ecma_external_string_from_cesu8 ((lit_utf8_byte_t *) str_p, (lit_utf8_size_t) str_size, user_p);
|
||||
return ecma_make_string_value (ecma_str_p);
|
||||
} /* jerry_create_external_string_sz */
|
||||
|
||||
@ -2905,9 +2875,7 @@ jerry_create_regexp_sz (const jerry_char_t *pattern_p, /**< zero-terminated UTF-
|
||||
|
||||
ecma_string_t *ecma_pattern = ecma_new_ecma_string_from_utf8 (pattern_p, pattern_size);
|
||||
|
||||
jerry_value_t ret_val = ecma_op_create_regexp_with_flags (regexp_obj_p,
|
||||
ecma_make_string_value (ecma_pattern),
|
||||
flags);
|
||||
jerry_value_t ret_val = ecma_op_create_regexp_with_flags (regexp_obj_p, ecma_make_string_value (ecma_pattern), flags);
|
||||
ecma_deref_ecma_string (ecma_pattern);
|
||||
|
||||
return ret_val;
|
||||
@ -3085,9 +3053,7 @@ jerry_string_to_char_buffer (const jerry_value_t value, /**< input string value
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ecma_string_copy_to_cesu8_buffer (str_p,
|
||||
(lit_utf8_byte_t *) buffer_p,
|
||||
buffer_size);
|
||||
return ecma_string_copy_to_cesu8_buffer (str_p, (lit_utf8_byte_t *) buffer_p, buffer_size);
|
||||
} /* jerry_string_to_char_buffer */
|
||||
|
||||
/**
|
||||
@ -3124,9 +3090,7 @@ jerry_string_to_utf8_char_buffer (const jerry_value_t value, /**< input string v
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ecma_string_copy_to_utf8_buffer (str_p,
|
||||
(lit_utf8_byte_t *) buffer_p,
|
||||
buffer_size);
|
||||
return ecma_string_copy_to_utf8_buffer (str_p, (lit_utf8_byte_t *) buffer_p, buffer_size);
|
||||
} /* jerry_string_to_utf8_char_buffer */
|
||||
|
||||
/**
|
||||
@ -3156,11 +3120,7 @@ jerry_substring_to_char_buffer (const jerry_value_t value, /**< input string val
|
||||
|
||||
ecma_string_t *str_p = ecma_get_string_from_value (value);
|
||||
|
||||
return ecma_substring_copy_to_cesu8_buffer (str_p,
|
||||
start_pos,
|
||||
end_pos,
|
||||
(lit_utf8_byte_t *) buffer_p,
|
||||
buffer_size);
|
||||
return ecma_substring_copy_to_cesu8_buffer (str_p, start_pos, end_pos, (lit_utf8_byte_t *) buffer_p, buffer_size);
|
||||
} /* jerry_substring_to_char_buffer */
|
||||
|
||||
/**
|
||||
@ -3190,11 +3150,7 @@ jerry_substring_to_utf8_char_buffer (const jerry_value_t value, /**< input strin
|
||||
|
||||
ecma_string_t *str_p = ecma_get_string_from_value (value);
|
||||
|
||||
return ecma_substring_copy_to_utf8_buffer (str_p,
|
||||
start_pos,
|
||||
end_pos,
|
||||
(lit_utf8_byte_t *) buffer_p,
|
||||
buffer_size);
|
||||
return ecma_substring_copy_to_utf8_buffer (str_p, start_pos, end_pos, (lit_utf8_byte_t *) buffer_p, buffer_size);
|
||||
} /* jerry_substring_to_utf8_char_buffer */
|
||||
|
||||
/**
|
||||
@ -3262,14 +3218,15 @@ jerry_has_property (const jerry_value_t obj_val, /**< object value */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
if (!ecma_is_value_object (obj_val)
|
||||
|| !ecma_is_value_prop_name (prop_name_val))
|
||||
if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val))
|
||||
{
|
||||
return ECMA_VALUE_FALSE;
|
||||
}
|
||||
|
||||
return jerry_return (ecma_op_object_has_property (ecma_get_object_from_value (obj_val),
|
||||
ecma_get_prop_name_from_value (prop_name_val)));
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (obj_val);
|
||||
ecma_string_t *prop_name_p = ecma_get_prop_name_from_value (prop_name_val);
|
||||
|
||||
return jerry_return (ecma_op_object_has_property (obj_p, prop_name_p));
|
||||
} /* jerry_has_property */
|
||||
|
||||
/**
|
||||
@ -3284,8 +3241,7 @@ jerry_has_own_property (const jerry_value_t obj_val, /**< object value */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
if (!ecma_is_value_object (obj_val)
|
||||
|| !ecma_is_value_prop_name (prop_name_val))
|
||||
if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val))
|
||||
{
|
||||
return ECMA_VALUE_FALSE;
|
||||
}
|
||||
@ -3328,8 +3284,7 @@ jerry_has_internal_property (const jerry_value_t obj_val, /**< object value */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
if (!ecma_is_value_object (obj_val)
|
||||
|| !ecma_is_value_prop_name (prop_name_val))
|
||||
if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -3368,15 +3323,13 @@ jerry_delete_property (const jerry_value_t obj_val, /**< object value */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
if (!ecma_is_value_object (obj_val)
|
||||
|| !ecma_is_value_prop_name (prop_name_val))
|
||||
if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ecma_value_t ret_value = ecma_op_object_delete (ecma_get_object_from_value (obj_val),
|
||||
ecma_get_prop_name_from_value (prop_name_val),
|
||||
false);
|
||||
ecma_value_t ret_value =
|
||||
ecma_op_object_delete (ecma_get_object_from_value (obj_val), ecma_get_prop_name_from_value (prop_name_val), false);
|
||||
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
if (ECMA_IS_VALUE_ERROR (ret_value))
|
||||
@ -3407,9 +3360,7 @@ jerry_delete_property_by_index (const jerry_value_t obj_val, /**< object value *
|
||||
}
|
||||
|
||||
ecma_string_t *str_idx_p = ecma_new_ecma_string_from_uint32 (index);
|
||||
ecma_value_t ret_value = ecma_op_object_delete (ecma_get_object_from_value (obj_val),
|
||||
str_idx_p,
|
||||
false);
|
||||
ecma_value_t ret_value = ecma_op_object_delete (ecma_get_object_from_value (obj_val), str_idx_p, false);
|
||||
ecma_deref_ecma_string (str_idx_p);
|
||||
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
@ -3435,8 +3386,7 @@ jerry_delete_internal_property (const jerry_value_t obj_val, /**< object value *
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
if (!ecma_is_value_object (obj_val)
|
||||
|| !ecma_is_value_prop_name (prop_name_val))
|
||||
if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -3485,14 +3435,13 @@ jerry_get_property (const jerry_value_t obj_val, /**< object value */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
if (!ecma_is_value_object (obj_val)
|
||||
|| !ecma_is_value_prop_name (prop_name_val))
|
||||
if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val))
|
||||
{
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
|
||||
}
|
||||
|
||||
jerry_value_t ret_value = ecma_op_object_get (ecma_get_object_from_value (obj_val),
|
||||
ecma_get_prop_name_from_value (prop_name_val));
|
||||
jerry_value_t ret_value =
|
||||
ecma_op_object_get (ecma_get_object_from_value (obj_val), ecma_get_prop_name_from_value (prop_name_val));
|
||||
return jerry_return (ret_value);
|
||||
} /* jerry_get_property */
|
||||
|
||||
@ -3544,8 +3493,7 @@ jerry_get_own_property (const jerry_value_t obj_val, /**< object value */
|
||||
*found_p = false;
|
||||
}
|
||||
|
||||
if (!ecma_is_value_object (obj_val)
|
||||
|| !ecma_is_value_prop_name (prop_name_val)
|
||||
if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val)
|
||||
|| !ecma_is_value_object (receiver_val))
|
||||
{
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
|
||||
@ -3597,8 +3545,7 @@ jerry_get_internal_property (const jerry_value_t obj_val, /**< object value */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
if (!ecma_is_value_object (obj_val)
|
||||
|| !ecma_is_value_prop_name (prop_name_val))
|
||||
if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val))
|
||||
{
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
|
||||
}
|
||||
@ -3646,8 +3593,7 @@ jerry_set_property (const jerry_value_t obj_val, /**< object value */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
if (ecma_is_value_error_reference (value_to_set)
|
||||
|| !ecma_is_value_object (obj_val)
|
||||
if (ecma_is_value_error_reference (value_to_set) || !ecma_is_value_object (obj_val)
|
||||
|| !ecma_is_value_prop_name (prop_name_val))
|
||||
{
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
|
||||
@ -3675,16 +3621,13 @@ jerry_set_property_by_index (const jerry_value_t obj_val, /**< object value */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
if (ecma_is_value_error_reference (value_to_set)
|
||||
|| !ecma_is_value_object (obj_val))
|
||||
if (ecma_is_value_error_reference (value_to_set) || !ecma_is_value_object (obj_val))
|
||||
{
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
|
||||
}
|
||||
|
||||
ecma_value_t ret_value = ecma_op_object_put_by_index (ecma_get_object_from_value (obj_val),
|
||||
index,
|
||||
value_to_set,
|
||||
true);
|
||||
ecma_value_t ret_value =
|
||||
ecma_op_object_put_by_index (ecma_get_object_from_value (obj_val), index, value_to_set, true);
|
||||
|
||||
return jerry_return (ret_value);
|
||||
} /* jerry_set_property_by_index */
|
||||
@ -3706,8 +3649,7 @@ jerry_set_internal_property (const jerry_value_t obj_val, /**< object value */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
if (ecma_is_value_error_reference (value_to_set)
|
||||
|| !ecma_is_value_object (obj_val)
|
||||
if (ecma_is_value_error_reference (value_to_set) || !ecma_is_value_object (obj_val)
|
||||
|| !ecma_is_value_prop_name (prop_name_val))
|
||||
{
|
||||
return false;
|
||||
@ -3727,14 +3669,10 @@ jerry_set_internal_property (const jerry_value_t obj_val, /**< object value */
|
||||
|
||||
if (property_p == NULL)
|
||||
{
|
||||
ecma_property_value_t *value_p = ecma_create_named_data_property (obj_p,
|
||||
internal_string_p,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
|
||||
NULL);
|
||||
ecma_property_value_t *value_p =
|
||||
ecma_create_named_data_property (obj_p, internal_string_p, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, NULL);
|
||||
|
||||
internal_object_p = ecma_create_object (NULL,
|
||||
sizeof (ecma_extended_object_t),
|
||||
ECMA_OBJECT_TYPE_CLASS);
|
||||
internal_object_p = ecma_create_object (NULL, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS);
|
||||
{
|
||||
ecma_extended_object_t *container_p = (ecma_extended_object_t *) internal_object_p;
|
||||
container_p->u.cls.type = ECMA_OBJECT_CLASS_INTERNAL_OBJECT;
|
||||
@ -3954,8 +3892,7 @@ jerry_define_own_property (const jerry_value_t obj_val, /**< object value */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
if (!ecma_is_value_object (obj_val)
|
||||
|| !ecma_is_value_prop_name (prop_name_val))
|
||||
if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val))
|
||||
{
|
||||
return jerry_type_error_or_false (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p), prop_desc_p->flags);
|
||||
}
|
||||
@ -3985,14 +3922,13 @@ jerry_define_own_property (const jerry_value_t obj_val, /**< object value */
|
||||
* false - otherwise, the prop_desc_p is unchanged
|
||||
*/
|
||||
jerry_value_t
|
||||
jerry_get_own_property_descriptor (const jerry_value_t obj_val, /**< object value */
|
||||
jerry_get_own_property_descriptor (const jerry_value_t obj_val, /**< object value */
|
||||
const jerry_value_t prop_name_val, /**< property name (string value) */
|
||||
jerry_property_descriptor_t *prop_desc_p) /**< property descriptor */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
if (!ecma_is_value_object (obj_val)
|
||||
|| !ecma_is_value_prop_name (prop_name_val))
|
||||
if (!ecma_is_value_object (obj_val) || !ecma_is_value_prop_name (prop_name_val))
|
||||
{
|
||||
return ECMA_VALUE_FALSE;
|
||||
}
|
||||
@ -4016,10 +3952,9 @@ jerry_get_own_property_descriptor (const jerry_value_t obj_val, /**< object val
|
||||
}
|
||||
|
||||
/* The flags are always filled in the returned descriptor. */
|
||||
JERRY_ASSERT ((prop_desc.flags & JERRY_PROP_IS_CONFIGURABLE_DEFINED)
|
||||
&& (prop_desc.flags & JERRY_PROP_IS_ENUMERABLE_DEFINED)
|
||||
&& ((prop_desc.flags & JERRY_PROP_IS_WRITABLE_DEFINED)
|
||||
|| !(prop_desc.flags & JERRY_PROP_IS_VALUE_DEFINED)));
|
||||
JERRY_ASSERT (
|
||||
(prop_desc.flags & JERRY_PROP_IS_CONFIGURABLE_DEFINED) && (prop_desc.flags & JERRY_PROP_IS_ENUMERABLE_DEFINED)
|
||||
&& ((prop_desc.flags & JERRY_PROP_IS_WRITABLE_DEFINED) || !(prop_desc.flags & JERRY_PROP_IS_VALUE_DEFINED)));
|
||||
|
||||
prop_desc_p->flags = prop_desc.flags;
|
||||
prop_desc_p->value = ECMA_VALUE_UNDEFINED;
|
||||
@ -4110,10 +4045,7 @@ jerry_call_function (const jerry_value_t func_obj_val, /**< function object to c
|
||||
}
|
||||
}
|
||||
|
||||
return jerry_return (ecma_op_function_validated_call (func_obj_val,
|
||||
this_val,
|
||||
args_p,
|
||||
args_count));
|
||||
return jerry_return (ecma_op_function_validated_call (func_obj_val, this_val, args_p, args_count));
|
||||
} /* jerry_call_function */
|
||||
|
||||
/**
|
||||
@ -4171,8 +4103,8 @@ jerry_get_object_keys (const jerry_value_t obj_val) /**< object value */
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
|
||||
}
|
||||
|
||||
ecma_collection_t *prop_names = ecma_op_object_get_enumerable_property_names (ecma_get_object_from_value (obj_val),
|
||||
ECMA_ENUMERABLE_PROPERTY_KEYS);
|
||||
ecma_collection_t *prop_names =
|
||||
ecma_op_object_get_enumerable_property_names (ecma_get_object_from_value (obj_val), ECMA_ENUMERABLE_PROPERTY_KEYS);
|
||||
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
if (JERRY_UNLIKELY (prop_names == NULL))
|
||||
@ -4235,8 +4167,7 @@ jerry_set_prototype (const jerry_value_t obj_val, /**< object value */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
if (!ecma_is_value_object (obj_val)
|
||||
|| ecma_is_value_error_reference (proto_obj_val)
|
||||
if (!ecma_is_value_object (obj_val) || ecma_is_value_error_reference (proto_obj_val)
|
||||
|| (!ecma_is_value_object (proto_obj_val) && !ecma_is_value_null (proto_obj_val)))
|
||||
{
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
|
||||
@ -4262,8 +4193,8 @@ jerry_set_prototype (const jerry_value_t obj_val, /**< object value */
|
||||
* @returns true - if the user can access the object in the callback.
|
||||
* false - if the object is an internal object which should no be accessed by the user.
|
||||
*/
|
||||
static
|
||||
bool jerry_object_is_valid_foreach (ecma_object_t *object_p) /**< object to test */
|
||||
static bool
|
||||
jerry_object_is_valid_foreach (ecma_object_t *object_p) /**< object to test */
|
||||
{
|
||||
if (ecma_is_lexical_environment (object_p))
|
||||
{
|
||||
@ -4308,8 +4239,7 @@ jerry_objects_foreach (jerry_objects_foreach_t foreach_p, /**< function pointer
|
||||
{
|
||||
ecma_object_t *iter_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, iter_cp);
|
||||
|
||||
if (jerry_object_is_valid_foreach (iter_p)
|
||||
&& !foreach_p (ecma_make_object_value (iter_p), user_data_p))
|
||||
if (jerry_object_is_valid_foreach (iter_p) && !foreach_p (ecma_make_object_value (iter_p), user_data_p))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -4349,8 +4279,7 @@ jerry_objects_foreach_by_native_info (const jerry_object_native_info_t *native_i
|
||||
if (jerry_object_is_valid_foreach (iter_p))
|
||||
{
|
||||
native_pointer_p = ecma_get_native_pointer_value (iter_p, (void *) native_info_p);
|
||||
if (native_pointer_p
|
||||
&& !foreach_p (ecma_make_object_value (iter_p), native_pointer_p->native_p, user_data_p))
|
||||
if (native_pointer_p && !foreach_p (ecma_make_object_value (iter_p), native_pointer_p->native_p, user_data_p))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -4647,9 +4576,9 @@ jerry_object_get_property_names (const jerry_value_t obj_val, /**< object */
|
||||
uint32_t index = ecma_string_get_array_index (key_p);
|
||||
|
||||
/* Step 2. Filter by key type */
|
||||
if (filter & (JERRY_PROPERTY_FILTER_EXCLUDE_STRINGS
|
||||
| JERRY_PROPERTY_FILTER_EXCLUDE_SYMBOLS
|
||||
| JERRY_PROPERTY_FILTER_EXCLUDE_INTEGER_INDICES))
|
||||
if (filter
|
||||
& (JERRY_PROPERTY_FILTER_EXCLUDE_STRINGS | JERRY_PROPERTY_FILTER_EXCLUDE_SYMBOLS
|
||||
| JERRY_PROPERTY_FILTER_EXCLUDE_INTEGER_INDICES))
|
||||
{
|
||||
if (ecma_is_value_symbol (key))
|
||||
{
|
||||
@ -4674,9 +4603,9 @@ jerry_object_get_property_names (const jerry_value_t obj_val, /**< object */
|
||||
}
|
||||
|
||||
/* Step 3. Filter property attributes */
|
||||
if (filter & (JERRY_PROPERTY_FILTER_EXCLUDE_NON_CONFIGURABLE
|
||||
| JERRY_PROPERTY_FILTER_EXCLUDE_NON_ENUMERABLE
|
||||
| JERRY_PROPERTY_FILTER_EXCLUDE_NON_WRITABLE))
|
||||
if (filter
|
||||
& (JERRY_PROPERTY_FILTER_EXCLUDE_NON_CONFIGURABLE | JERRY_PROPERTY_FILTER_EXCLUDE_NON_ENUMERABLE
|
||||
| JERRY_PROPERTY_FILTER_EXCLUDE_NON_WRITABLE))
|
||||
{
|
||||
ecma_property_descriptor_t prop_desc;
|
||||
ecma_value_t status = ecma_op_object_get_own_property_descriptor (obj_iter_p, key_p, &prop_desc);
|
||||
@ -4695,19 +4624,15 @@ jerry_object_get_property_names (const jerry_value_t obj_val, /**< object */
|
||||
uint16_t flags = prop_desc.flags;
|
||||
ecma_free_property_descriptor (&prop_desc);
|
||||
|
||||
if ((!(flags & JERRY_PROP_IS_CONFIGURABLE)
|
||||
&& (filter & JERRY_PROPERTY_FILTER_EXCLUDE_NON_CONFIGURABLE))
|
||||
|| (!(flags & JERRY_PROP_IS_ENUMERABLE)
|
||||
&& (filter & JERRY_PROPERTY_FILTER_EXCLUDE_NON_ENUMERABLE))
|
||||
|| (!(flags & JERRY_PROP_IS_WRITABLE)
|
||||
&& (filter & JERRY_PROPERTY_FILTER_EXCLUDE_NON_WRITABLE)))
|
||||
if ((!(flags & JERRY_PROP_IS_CONFIGURABLE) && (filter & JERRY_PROPERTY_FILTER_EXCLUDE_NON_CONFIGURABLE))
|
||||
|| (!(flags & JERRY_PROP_IS_ENUMERABLE) && (filter & JERRY_PROPERTY_FILTER_EXCLUDE_NON_ENUMERABLE))
|
||||
|| (!(flags & JERRY_PROP_IS_WRITABLE) && (filter & JERRY_PROPERTY_FILTER_EXCLUDE_NON_WRITABLE)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (index != ECMA_STRING_NOT_ARRAY_INDEX
|
||||
&& (filter & JERRY_PROPERTY_FILTER_INTEGER_INDICES_AS_NUMBER))
|
||||
if (index != ECMA_STRING_NOT_ARRAY_INDEX && (filter & JERRY_PROPERTY_FILTER_INTEGER_INDICES_AS_NUMBER))
|
||||
{
|
||||
ecma_deref_ecma_string (key_p);
|
||||
key = ecma_make_uint32_value (index);
|
||||
@ -4930,9 +4855,10 @@ jerry_get_promise_state (const jerry_value_t promise) /**< promise object to get
|
||||
* Note:
|
||||
* the previous callback is overwritten
|
||||
*/
|
||||
void jerry_promise_set_callback (jerry_promise_event_filter_t filters, /**< combination of event filters */
|
||||
jerry_promise_callback_t callback, /**< notification callback */
|
||||
void *user_p) /**< user pointer passed to the callback */
|
||||
void
|
||||
jerry_promise_set_callback (jerry_promise_event_filter_t filters, /**< combination of event filters */
|
||||
jerry_promise_callback_t callback, /**< notification callback */
|
||||
void *user_p) /**< user pointer passed to the callback */
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
@ -4981,7 +4907,7 @@ jerry_get_well_known_symbol (jerry_well_known_symbol_t symbol) /**< jerry_well_k
|
||||
|
||||
return ECMA_VALUE_UNDEFINED;
|
||||
#endif /* JERRY_ESNEXT */
|
||||
} /** jerry_get_well_known_symbol */
|
||||
} /* jerry_get_well_known_symbol */
|
||||
|
||||
/**
|
||||
* Returns the description internal property of a symbol.
|
||||
@ -5039,7 +4965,7 @@ jerry_get_symbol_descriptive_string (const jerry_value_t symbol) /**< symbol val
|
||||
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_symbol_not_supported_p)));
|
||||
#endif /* JERRY_ESNEXT */
|
||||
} /** jerry_get_symbol_descriptive_string */
|
||||
} /* jerry_get_symbol_descriptive_string */
|
||||
|
||||
/**
|
||||
* Get the number of uint64 digits of a BigInt value
|
||||
@ -5173,9 +5099,7 @@ bool
|
||||
jerry_is_valid_utf8_string (const jerry_char_t *utf8_buf_p, /**< UTF-8 string */
|
||||
jerry_size_t buf_size) /**< string size */
|
||||
{
|
||||
return lit_is_valid_utf8_string ((lit_utf8_byte_t *) utf8_buf_p,
|
||||
(lit_utf8_size_t) buf_size,
|
||||
true);
|
||||
return lit_is_valid_utf8_string ((lit_utf8_byte_t *) utf8_buf_p, (lit_utf8_size_t) buf_size, true);
|
||||
} /* jerry_is_valid_utf8_string */
|
||||
|
||||
/**
|
||||
@ -5188,8 +5112,7 @@ bool
|
||||
jerry_is_valid_cesu8_string (const jerry_char_t *cesu8_buf_p, /**< CESU-8 string */
|
||||
jerry_size_t buf_size) /**< string size */
|
||||
{
|
||||
return lit_is_valid_cesu8_string ((lit_utf8_byte_t *) cesu8_buf_p,
|
||||
(lit_utf8_size_t) buf_size);
|
||||
return lit_is_valid_cesu8_string ((lit_utf8_byte_t *) cesu8_buf_p, (lit_utf8_size_t) buf_size);
|
||||
} /* jerry_is_valid_cesu8_string */
|
||||
|
||||
/**
|
||||
@ -5580,8 +5503,7 @@ jerry_get_source_info (const jerry_value_t value) /**< jerry api value */
|
||||
|
||||
if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_SCRIPT)
|
||||
{
|
||||
bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
ext_object_p->u.cls.u3.value);
|
||||
bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
|
||||
}
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
else if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_MODULE)
|
||||
@ -5657,8 +5579,8 @@ jerry_get_source_info (const jerry_value_t value) /**< jerry api value */
|
||||
{
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
object_p = ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t,
|
||||
ext_object_p->u.bound_function.target_function);
|
||||
object_p =
|
||||
ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, ext_object_p->u.bound_function.target_function);
|
||||
continue;
|
||||
}
|
||||
#if JERRY_ESNEXT
|
||||
@ -6382,12 +6304,9 @@ jerry_create_dataview (const jerry_value_t array_buffer, /**< arraybuffer to cre
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
|
||||
}
|
||||
|
||||
ecma_value_t arguments_p[3] =
|
||||
{
|
||||
array_buffer,
|
||||
ecma_make_uint32_value (byte_offset),
|
||||
ecma_make_uint32_value (byte_length)
|
||||
};
|
||||
ecma_value_t arguments_p[3] = { array_buffer,
|
||||
ecma_make_uint32_value (byte_offset),
|
||||
ecma_make_uint32_value (byte_length) };
|
||||
ecma_object_t *old_new_target_p = JERRY_CONTEXT (current_new_target_p);
|
||||
if (old_new_target_p == NULL)
|
||||
{
|
||||
@ -6516,26 +6435,21 @@ typedef struct
|
||||
/**
|
||||
* List of TypedArray mappings
|
||||
*/
|
||||
static jerry_typedarray_mapping_t jerry_typedarray_mappings[] =
|
||||
{
|
||||
#define TYPEDARRAY_ENTRY(NAME, LIT_NAME, SIZE_SHIFT) \
|
||||
{ JERRY_TYPEDARRAY_ ## NAME, ECMA_BUILTIN_ID_ ## NAME ## ARRAY_PROTOTYPE, \
|
||||
ECMA_ ## LIT_NAME ## _ARRAY, SIZE_SHIFT }
|
||||
static jerry_typedarray_mapping_t jerry_typedarray_mappings[] = {
|
||||
#define TYPEDARRAY_ENTRY(NAME, LIT_NAME, SIZE_SHIFT) \
|
||||
{ \
|
||||
JERRY_TYPEDARRAY_##NAME, ECMA_BUILTIN_ID_##NAME##ARRAY_PROTOTYPE, ECMA_##LIT_NAME##_ARRAY, SIZE_SHIFT \
|
||||
}
|
||||
|
||||
TYPEDARRAY_ENTRY (UINT8, UINT8, 0),
|
||||
TYPEDARRAY_ENTRY (UINT8CLAMPED, UINT8_CLAMPED, 0),
|
||||
TYPEDARRAY_ENTRY (INT8, INT8, 0),
|
||||
TYPEDARRAY_ENTRY (UINT16, UINT16, 1),
|
||||
TYPEDARRAY_ENTRY (INT16, INT16, 1),
|
||||
TYPEDARRAY_ENTRY (UINT32, UINT32, 2),
|
||||
TYPEDARRAY_ENTRY (INT32, INT32, 2),
|
||||
TYPEDARRAY_ENTRY (FLOAT32, FLOAT32, 2),
|
||||
TYPEDARRAY_ENTRY (UINT8, UINT8, 0), TYPEDARRAY_ENTRY (UINT8CLAMPED, UINT8_CLAMPED, 0),
|
||||
TYPEDARRAY_ENTRY (INT8, INT8, 0), TYPEDARRAY_ENTRY (UINT16, UINT16, 1),
|
||||
TYPEDARRAY_ENTRY (INT16, INT16, 1), TYPEDARRAY_ENTRY (UINT32, UINT32, 2),
|
||||
TYPEDARRAY_ENTRY (INT32, INT32, 2), TYPEDARRAY_ENTRY (FLOAT32, FLOAT32, 2),
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
TYPEDARRAY_ENTRY (FLOAT64, FLOAT64, 3),
|
||||
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
TYPEDARRAY_ENTRY (BIGINT64, BIGINT64, 3),
|
||||
TYPEDARRAY_ENTRY (BIGUINT64, BIGUINT64, 3),
|
||||
TYPEDARRAY_ENTRY (BIGINT64, BIGINT64, 3), TYPEDARRAY_ENTRY (BIGUINT64, BIGUINT64, 3),
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
#undef TYPEDARRAY_ENTRY
|
||||
};
|
||||
@ -6601,11 +6515,8 @@ jerry_create_typedarray (jerry_typedarray_type_t type_name, /**< type of TypedAr
|
||||
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (prototype_id);
|
||||
|
||||
ecma_value_t array_value = ecma_typedarray_create_object_with_length (length,
|
||||
NULL,
|
||||
prototype_obj_p,
|
||||
element_size_shift,
|
||||
id);
|
||||
ecma_value_t array_value =
|
||||
ecma_typedarray_create_object_with_length (length, NULL, prototype_obj_p, element_size_shift, id);
|
||||
|
||||
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (array_value));
|
||||
|
||||
@ -6655,12 +6566,7 @@ jerry_create_typedarray_for_arraybuffer_sz (jerry_typedarray_type_t type_name, /
|
||||
}
|
||||
|
||||
ecma_object_t *prototype_obj_p = ecma_builtin_get (prototype_id);
|
||||
ecma_value_t arguments_p[3] =
|
||||
{
|
||||
arraybuffer,
|
||||
ecma_make_uint32_value (byte_offset),
|
||||
ecma_make_uint32_value (length)
|
||||
};
|
||||
ecma_value_t arguments_p[3] = { arraybuffer, ecma_make_uint32_value (byte_offset), ecma_make_uint32_value (length) };
|
||||
|
||||
ecma_value_t array_value = ecma_op_create_typedarray (arguments_p, 3, prototype_obj_p, element_size_shift, id);
|
||||
ecma_free_value (arguments_p[1]);
|
||||
@ -6946,17 +6852,14 @@ jerry_create_container (jerry_container_type_t container_type, /**< Type of the
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Invalid container type")));
|
||||
}
|
||||
}
|
||||
ecma_object_t * old_new_target_p = JERRY_CONTEXT (current_new_target_p);
|
||||
ecma_object_t *old_new_target_p = JERRY_CONTEXT (current_new_target_p);
|
||||
|
||||
if (old_new_target_p == NULL)
|
||||
{
|
||||
JERRY_CONTEXT (current_new_target_p) = ecma_builtin_get (ctor_id);
|
||||
}
|
||||
|
||||
ecma_value_t container_value = ecma_op_container_create (arguments_list_p,
|
||||
arguments_list_len,
|
||||
lit_id,
|
||||
proto_id);
|
||||
ecma_value_t container_value = ecma_op_container_create (arguments_list_p, arguments_list_len, lit_id, proto_id);
|
||||
|
||||
JERRY_CONTEXT (current_new_target_p) = old_new_target_p;
|
||||
return container_value;
|
||||
@ -7123,11 +7026,11 @@ jerry_get_array_from_container (jerry_value_t value, /**< the container or itera
|
||||
}
|
||||
}
|
||||
return ecma_op_new_array_object_from_collection (collection_buffer, false);
|
||||
#else /* JERRY_BUILTIN_CONTAINER */
|
||||
#else /* !JERRY_BUILTIN_CONTAINER */
|
||||
JERRY_UNUSED (value);
|
||||
JERRY_UNUSED (is_key_value_p);
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_container_not_supported_p)));
|
||||
#endif
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
} /* jerry_get_array_from_container */
|
||||
|
||||
/**
|
||||
@ -7178,8 +7081,7 @@ jerry_container_operation (jerry_container_operation_t operation, /**< container
|
||||
}
|
||||
case JERRY_CONTAINER_OP_SET:
|
||||
{
|
||||
if (arguments_number != 2
|
||||
|| ecma_is_value_error_reference (arguments[0])
|
||||
if (arguments_number != 2 || ecma_is_value_error_reference (arguments[0])
|
||||
|| ecma_is_value_error_reference (arguments[1]))
|
||||
{
|
||||
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p)));
|
||||
@ -7269,7 +7171,7 @@ jerry_container_operation (jerry_container_operation_t operation, /**< container
|
||||
}
|
||||
}
|
||||
return jerry_return (result);
|
||||
#else /* JERRY_BUILTIN_CONTAINER */
|
||||
#else /* !JERRY_BUILTIN_CONTAINER */
|
||||
JERRY_UNUSED (operation);
|
||||
JERRY_UNUSED (container);
|
||||
JERRY_UNUSED (arguments);
|
||||
@ -29,102 +29,102 @@
|
||||
* By default all built-ins are enabled if they are not defined.
|
||||
*/
|
||||
#ifndef JERRY_BUILTINS
|
||||
# define JERRY_BUILTINS 1
|
||||
#define JERRY_BUILTINS 1
|
||||
#endif /* !defined (JERRY_BUILTINS) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_ANNEXB
|
||||
# define JERRY_BUILTIN_ANNEXB JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_ANNEXB JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_ANNEXB) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_ARRAY
|
||||
# define JERRY_BUILTIN_ARRAY JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_ARRAY JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_ARRAY) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_BOOLEAN
|
||||
# define JERRY_BUILTIN_BOOLEAN JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_BOOLEAN JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_BOOLEAN) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_DATE
|
||||
# define JERRY_BUILTIN_DATE JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_DATE JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_DATE) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_ERRORS
|
||||
# define JERRY_BUILTIN_ERRORS JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_ERRORS JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_ERRORS) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_JSON
|
||||
# define JERRY_BUILTIN_JSON JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_JSON JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_JSON) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_MATH
|
||||
# define JERRY_BUILTIN_MATH JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_MATH JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_MATH) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_NUMBER
|
||||
# define JERRY_BUILTIN_NUMBER JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_NUMBER JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_NUMBER) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_REGEXP
|
||||
# define JERRY_BUILTIN_REGEXP JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_REGEXP JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_REGEXP) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_STRING
|
||||
# define JERRY_BUILTIN_STRING JERRY_BUILTINS
|
||||
#define JERRY_BUILTIN_STRING JERRY_BUILTINS
|
||||
#endif /* !defined (JERRY_BUILTIN_STRING) */
|
||||
|
||||
/**
|
||||
* ES2015+ related features, by default all of them are enabled.
|
||||
*/
|
||||
#ifndef JERRY_ESNEXT
|
||||
# define JERRY_ESNEXT 1
|
||||
#define JERRY_ESNEXT 1
|
||||
#endif /* !defined (JERRY_ESNEXT) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_BIGINT
|
||||
# define JERRY_BUILTIN_BIGINT JERRY_ESNEXT
|
||||
#define JERRY_BUILTIN_BIGINT JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_BIGINT) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_CONTAINER
|
||||
# define JERRY_BUILTIN_CONTAINER JERRY_ESNEXT
|
||||
#define JERRY_BUILTIN_CONTAINER JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_CONTAINER) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_DATAVIEW
|
||||
# define JERRY_BUILTIN_DATAVIEW JERRY_ESNEXT
|
||||
#define JERRY_BUILTIN_DATAVIEW JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_DATAVIEW) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_GLOBAL_THIS
|
||||
# define JERRY_BUILTIN_GLOBAL_THIS JERRY_ESNEXT
|
||||
#define JERRY_BUILTIN_GLOBAL_THIS JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_GLOBAL_THIS) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_PROXY
|
||||
# define JERRY_BUILTIN_PROXY JERRY_ESNEXT
|
||||
#define JERRY_BUILTIN_PROXY JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_PROXY) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_REALMS
|
||||
# define JERRY_BUILTIN_REALMS JERRY_ESNEXT
|
||||
#define JERRY_BUILTIN_REALMS JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_REALMS) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_REFLECT
|
||||
# define JERRY_BUILTIN_REFLECT JERRY_ESNEXT
|
||||
#define JERRY_BUILTIN_REFLECT JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_REFLECT) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_TYPEDARRAY
|
||||
# define JERRY_BUILTIN_TYPEDARRAY JERRY_ESNEXT
|
||||
#define JERRY_BUILTIN_TYPEDARRAY JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_TYPEDARRAY) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_SHAREDARRAYBUFFER
|
||||
# define JERRY_BUILTIN_SHAREDARRAYBUFFER JERRY_ESNEXT
|
||||
#define JERRY_BUILTIN_SHAREDARRAYBUFFER JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_SHAREDARRAYBUFFER) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_ATOMICS
|
||||
# define JERRY_BUILTIN_ATOMICS JERRY_ESNEXT
|
||||
#define JERRY_BUILTIN_ATOMICS JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_ATOMICS) */
|
||||
|
||||
#ifndef JERRY_BUILTIN_WEAKREF
|
||||
# define JERRY_BUILTIN_WEAKREF JERRY_ESNEXT
|
||||
#define JERRY_BUILTIN_WEAKREF JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_BUILTIN_WEAKREF) */
|
||||
|
||||
#ifndef JERRY_MODULE_SYSTEM
|
||||
# define JERRY_MODULE_SYSTEM JERRY_ESNEXT
|
||||
#define JERRY_MODULE_SYSTEM JERRY_ESNEXT
|
||||
#endif /* !defined (JERRY_MODULE_SYSTEM) */
|
||||
|
||||
/**
|
||||
@ -142,7 +142,7 @@
|
||||
* For more details see: jmem/jmem.h
|
||||
*/
|
||||
#ifndef JERRY_CPOINTER_32_BIT
|
||||
# define JERRY_CPOINTER_32_BIT 0
|
||||
#define JERRY_CPOINTER_32_BIT 0
|
||||
#endif /* !defined (JERRY_CPOINTER_32_BIT) */
|
||||
|
||||
/**
|
||||
@ -153,7 +153,7 @@
|
||||
* 1: Enable the debugger.
|
||||
*/
|
||||
#ifndef JERRY_DEBUGGER
|
||||
# define JERRY_DEBUGGER 0
|
||||
#define JERRY_DEBUGGER 0
|
||||
#endif /* !defined (JERRY_DEBUGGER) */
|
||||
|
||||
/**
|
||||
@ -166,7 +166,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_ERROR_MESSAGES
|
||||
# define JERRY_ERROR_MESSAGES 0
|
||||
#define JERRY_ERROR_MESSAGES 0
|
||||
#endif /* !defined (JERRY_ERROR_MESSAGES) */
|
||||
|
||||
/**
|
||||
@ -179,7 +179,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_EXTERNAL_CONTEXT
|
||||
# define JERRY_EXTERNAL_CONTEXT 0
|
||||
#define JERRY_EXTERNAL_CONTEXT 0
|
||||
#endif /* !defined (JERRY_EXTERNAL_CONTEXT) */
|
||||
|
||||
/**
|
||||
@ -188,7 +188,7 @@
|
||||
* Default value: 512 KiB
|
||||
*/
|
||||
#ifndef JERRY_GLOBAL_HEAP_SIZE
|
||||
# define JERRY_GLOBAL_HEAP_SIZE (512)
|
||||
#define JERRY_GLOBAL_HEAP_SIZE (512)
|
||||
#endif /* !defined (JERRY_GLOBAL_HEAP_SIZE) */
|
||||
|
||||
/**
|
||||
@ -197,7 +197,7 @@
|
||||
* If value is 0, the default is 1/32 of JERRY_HEAP_SIZE
|
||||
*/
|
||||
#ifndef JERRY_GC_LIMIT
|
||||
# define JERRY_GC_LIMIT 0
|
||||
#define JERRY_GC_LIMIT 0
|
||||
#endif /* !defined (JERRY_GC_LIMIT) */
|
||||
|
||||
/**
|
||||
@ -210,7 +210,7 @@
|
||||
* Default value: 0, unlimited
|
||||
*/
|
||||
#ifndef JERRY_STACK_LIMIT
|
||||
# define JERRY_STACK_LIMIT (0)
|
||||
#define JERRY_STACK_LIMIT (0)
|
||||
#endif /* !defined (JERRY_STACK_LIMIT) */
|
||||
|
||||
/**
|
||||
@ -219,7 +219,7 @@
|
||||
* Default value: 8
|
||||
*/
|
||||
#ifndef JERRY_GC_MARK_LIMIT
|
||||
# define JERRY_GC_MARK_LIMIT (8)
|
||||
#define JERRY_GC_MARK_LIMIT (8)
|
||||
#endif /* !defined (JERRY_GC_MARK_LIMIT) */
|
||||
|
||||
/**
|
||||
@ -232,7 +232,7 @@
|
||||
* Default value: 1
|
||||
*/
|
||||
#ifndef JERRY_LCACHE
|
||||
# define JERRY_LCACHE 1
|
||||
#define JERRY_LCACHE 1
|
||||
#endif /* !defined (JERRY_LCACHE) */
|
||||
|
||||
/**
|
||||
@ -245,7 +245,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_FUNCTION_TO_STRING
|
||||
# define JERRY_FUNCTION_TO_STRING 0
|
||||
#define JERRY_FUNCTION_TO_STRING 0
|
||||
#endif /* !defined (JERRY_FUNCTION_TO_STRING) */
|
||||
|
||||
/**
|
||||
@ -258,7 +258,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_LINE_INFO
|
||||
# define JERRY_LINE_INFO 0
|
||||
#define JERRY_LINE_INFO 0
|
||||
#endif /* !defined (JERRY_LINE_INFO) */
|
||||
|
||||
/**
|
||||
@ -271,7 +271,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_LOGGING
|
||||
# define JERRY_LOGGING 0
|
||||
#define JERRY_LOGGING 0
|
||||
#endif /* !defined (JERRY_LOGGING) */
|
||||
|
||||
/**
|
||||
@ -286,7 +286,7 @@
|
||||
* Only enable it for debugging purposes.
|
||||
*/
|
||||
#ifndef JERRY_MEM_GC_BEFORE_EACH_ALLOC
|
||||
# define JERRY_MEM_GC_BEFORE_EACH_ALLOC 0
|
||||
#define JERRY_MEM_GC_BEFORE_EACH_ALLOC 0
|
||||
#endif /* !defined (JERRY_MEM_GC_BEFORE_EACH_ALLOC) */
|
||||
|
||||
/**
|
||||
@ -299,7 +299,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_MEM_STATS
|
||||
# define JERRY_MEM_STATS 0
|
||||
#define JERRY_MEM_STATS 0
|
||||
#endif /* !defined (JERRY_MEM_STATS) */
|
||||
|
||||
/**
|
||||
@ -313,7 +313,7 @@
|
||||
* Default value: 1
|
||||
*/
|
||||
#ifndef JERRY_NUMBER_TYPE_FLOAT64
|
||||
# define JERRY_NUMBER_TYPE_FLOAT64 1
|
||||
#define JERRY_NUMBER_TYPE_FLOAT64 1
|
||||
#endif /* !defined (JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
@ -326,7 +326,7 @@
|
||||
* Default value: 1
|
||||
*/
|
||||
#ifndef JERRY_PARSER
|
||||
# define JERRY_PARSER 1
|
||||
#define JERRY_PARSER 1
|
||||
#endif /* !defined (JERRY_PARSER) */
|
||||
|
||||
/**
|
||||
@ -341,7 +341,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_PARSER_DUMP_BYTE_CODE
|
||||
# define JERRY_PARSER_DUMP_BYTE_CODE 0
|
||||
#define JERRY_PARSER_DUMP_BYTE_CODE 0
|
||||
#endif /* defined (JERRY_PARSER_DUMP_BYTE_CODE) */
|
||||
|
||||
/**
|
||||
@ -354,7 +354,7 @@
|
||||
* Default value: 1
|
||||
*/
|
||||
#ifndef JERRY_PROPERTY_HASHMAP
|
||||
# define JERRY_PROPERTY_HASHMAP 1
|
||||
#define JERRY_PROPERTY_HASHMAP 1
|
||||
#endif /* !defined (JERRY_PROPERTY_HASHMAP) */
|
||||
|
||||
/**
|
||||
@ -363,7 +363,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_PROMISE_CALLBACK
|
||||
# define JERRY_PROMISE_CALLBACK 0
|
||||
#define JERRY_PROMISE_CALLBACK 0
|
||||
#endif /* !defined (JERRY_PROMISE_CALLBACK) */
|
||||
|
||||
/**
|
||||
@ -379,7 +379,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_REGEXP_DUMP_BYTE_CODE
|
||||
# define JERRY_REGEXP_DUMP_BYTE_CODE 0
|
||||
#define JERRY_REGEXP_DUMP_BYTE_CODE 0
|
||||
#endif /* !defined (JERRY_REGEXP_DUMP_BYTE_CODE) */
|
||||
|
||||
/**
|
||||
@ -388,7 +388,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_REGEXP_STRICT_MODE
|
||||
# define JERRY_REGEXP_STRICT_MODE 0
|
||||
#define JERRY_REGEXP_STRICT_MODE 0
|
||||
#endif /* !defined (JERRY_REGEXP_STRICT_MODE) */
|
||||
|
||||
/**
|
||||
@ -401,7 +401,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_SNAPSHOT_EXEC
|
||||
# define JERRY_SNAPSHOT_EXEC 0
|
||||
#define JERRY_SNAPSHOT_EXEC 0
|
||||
#endif /* !defined (JERRY_SNAPSHOT_EXEC) */
|
||||
|
||||
/**
|
||||
@ -412,7 +412,7 @@
|
||||
* 1: Enable snapshot save functions.
|
||||
*/
|
||||
#ifndef JERRY_SNAPSHOT_SAVE
|
||||
# define JERRY_SNAPSHOT_SAVE 0
|
||||
#define JERRY_SNAPSHOT_SAVE 0
|
||||
#endif /* !defined (JERRY_SNAPSHOT_SAVE) */
|
||||
|
||||
/**
|
||||
@ -425,7 +425,7 @@
|
||||
* Default value: 0
|
||||
*/
|
||||
#ifndef JERRY_SYSTEM_ALLOCATOR
|
||||
# define JERRY_SYSTEM_ALLOCATOR 0
|
||||
#define JERRY_SYSTEM_ALLOCATOR 0
|
||||
#endif /* !defined (JERRY_SYSTEM_ALLOCATOR) */
|
||||
|
||||
/**
|
||||
@ -433,7 +433,7 @@
|
||||
* By default Unicode case conversion is enabled.
|
||||
*/
|
||||
#ifndef JERRY_UNICODE_CASE_CONVERSION
|
||||
# define JERRY_UNICODE_CASE_CONVERSION 1
|
||||
#define JERRY_UNICODE_CASE_CONVERSION 1
|
||||
#endif /* !defined (JERRY_UNICODE_CASE_CONVERSION) */
|
||||
|
||||
/**
|
||||
@ -444,7 +444,7 @@
|
||||
* 1: Enable the Valgrind specific allocation notifications.
|
||||
*/
|
||||
#ifndef JERRY_VALGRIND
|
||||
# define JERRY_VALGRIND 0
|
||||
#define JERRY_VALGRIND 0
|
||||
#endif /* !defined (JERRY_VALGRIND) */
|
||||
|
||||
/**
|
||||
@ -455,7 +455,7 @@
|
||||
* 1: Enable vm exec stop callback support.
|
||||
*/
|
||||
#ifndef JERRY_VM_EXEC_STOP
|
||||
# define JERRY_VM_EXEC_STOP 0
|
||||
#define JERRY_VM_EXEC_STOP 0
|
||||
#endif /* !defined (JERRY_VM_EXEC_STOP) */
|
||||
|
||||
/**
|
||||
@ -466,7 +466,7 @@
|
||||
* 1: Enable vm throw callback support.
|
||||
*/
|
||||
#ifndef JERRY_VM_THROW
|
||||
# define JERRY_VM_THROW 0
|
||||
#define JERRY_VM_THROW 0
|
||||
#endif /* !defined (JERRY_VM_THROW) */
|
||||
|
||||
/**
|
||||
@ -487,7 +487,7 @@
|
||||
* # define JERRY_ATTR_CONST_DATA __attribute__((section(".rodata.const")))
|
||||
*/
|
||||
#ifndef JERRY_ATTR_CONST_DATA
|
||||
# define JERRY_ATTR_CONST_DATA
|
||||
#define JERRY_ATTR_CONST_DATA
|
||||
#endif /* !defined (JERRY_ATTR_CONST_DATA) */
|
||||
|
||||
/**
|
||||
@ -497,7 +497,7 @@
|
||||
* #define JERRY_ATTR_GLOBAL_HEAP __attribute__((section(".text.globalheap")))
|
||||
*/
|
||||
#ifndef JERRY_ATTR_GLOBAL_HEAP
|
||||
# define JERRY_ATTR_GLOBAL_HEAP
|
||||
#define JERRY_ATTR_GLOBAL_HEAP
|
||||
#endif /* !defined (JERRY_ATTR_GLOBAL_HEAP) */
|
||||
|
||||
/**
|
||||
@ -508,232 +508,194 @@
|
||||
/**
|
||||
* Check base builtins.
|
||||
*/
|
||||
#if !defined (JERRY_BUILTIN_ANNEXB) \
|
||||
|| ((JERRY_BUILTIN_ANNEXB != 0) && (JERRY_BUILTIN_ANNEXB != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_ANNEXB macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_ARRAY) \
|
||||
|| ((JERRY_BUILTIN_ARRAY != 0) && (JERRY_BUILTIN_ARRAY != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_ARRAY macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_BOOLEAN) \
|
||||
|| ((JERRY_BUILTIN_BOOLEAN != 0) && (JERRY_BUILTIN_BOOLEAN != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_BOOLEAN macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_DATE) \
|
||||
|| ((JERRY_BUILTIN_DATE != 0) && (JERRY_BUILTIN_DATE != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_DATE macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_ERRORS) \
|
||||
|| ((JERRY_BUILTIN_ERRORS != 0) && (JERRY_BUILTIN_ERRORS != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_ERRORS macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_JSON) \
|
||||
|| ((JERRY_BUILTIN_JSON != 0) && (JERRY_BUILTIN_JSON != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_JSON macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_MATH) \
|
||||
|| ((JERRY_BUILTIN_MATH != 0) && (JERRY_BUILTIN_MATH != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_MATH macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_NUMBER) \
|
||||
|| ((JERRY_BUILTIN_NUMBER != 0) && (JERRY_BUILTIN_NUMBER != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_NUMBER macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_REGEXP) \
|
||||
|| ((JERRY_BUILTIN_REGEXP != 0) && (JERRY_BUILTIN_REGEXP != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_REGEXP macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_STRING) \
|
||||
|| ((JERRY_BUILTIN_STRING != 0) && (JERRY_BUILTIN_STRING != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_STRING macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTINS) \
|
||||
|| ((JERRY_BUILTINS != 0) && (JERRY_BUILTINS != 1))
|
||||
# error "Invalid value for JERRY_BUILTINS macro."
|
||||
#endif
|
||||
#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) */
|
||||
|
||||
/**
|
||||
* Check ES2015+ features
|
||||
*/
|
||||
#if !defined (JERRY_ESNEXT) \
|
||||
|| ((JERRY_ESNEXT != 0) && (JERRY_ESNEXT != 1))
|
||||
# error "Invalid value for JERRY_ESNEXT macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_REALMS) \
|
||||
|| ((JERRY_BUILTIN_REALMS != 0) && (JERRY_BUILTIN_REALMS != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_REALMS macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_DATAVIEW) \
|
||||
|| ((JERRY_BUILTIN_DATAVIEW != 0) && (JERRY_BUILTIN_DATAVIEW != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_DATAVIEW macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_GLOBAL_THIS) \
|
||||
|| ((JERRY_BUILTIN_GLOBAL_THIS != 0) && (JERRY_BUILTIN_GLOBAL_THIS != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_GLOBAL_THIS macro."
|
||||
#endif /* !defined (JERRY_BUILTIN_GLOBAL_THIS) */
|
||||
#if !defined (JERRY_BUILTIN_REFLECT) \
|
||||
|| ((JERRY_BUILTIN_REFLECT != 0) && (JERRY_BUILTIN_REFLECT != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_REFLECT macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_WEAKREF) \
|
||||
|| ((JERRY_BUILTIN_WEAKREF != 0) && (JERRY_BUILTIN_WEAKREF != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_WEAKREF macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_PROXY) \
|
||||
|| ((JERRY_BUILTIN_PROXY != 0) && (JERRY_BUILTIN_PROXY != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_PROXY macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_TYPEDARRAY) \
|
||||
|| ((JERRY_BUILTIN_TYPEDARRAY != 0) && (JERRY_BUILTIN_TYPEDARRAY != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_TYPEDARRAY macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_SHAREDARRAYBUFFER) \
|
||||
|| ((JERRY_BUILTIN_SHAREDARRAYBUFFER != 0) && (JERRY_BUILTIN_SHAREDARRAYBUFFER != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_SHAREDARRAYBUFFER macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_ATOMICS) \
|
||||
|| ((JERRY_BUILTIN_ATOMICS != 0) && (JERRY_BUILTIN_ATOMICS != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_ATOMICS macro."
|
||||
#endif
|
||||
#if !defined (JERRY_BUILTIN_BIGINT) \
|
||||
|| ((JERRY_BUILTIN_BIGINT != 0) && (JERRY_BUILTIN_BIGINT != 1))
|
||||
# error "Invalid value for JERRY_BUILTIN_BIGINT macro."
|
||||
#endif
|
||||
#if !defined (JERRY_MODULE_SYSTEM) \
|
||||
|| ((JERRY_MODULE_SYSTEM != 0) && (JERRY_MODULE_SYSTEM != 1))
|
||||
# error "Invalid value for JERRY_MODULE_SYSTEM macro."
|
||||
#endif
|
||||
#if (JERRY_ESNEXT == 0) \
|
||||
&& ((JERRY_BUILTIN_DATAVIEW == 1) \
|
||||
|| (JERRY_BUILTIN_CONTAINER == 1) \
|
||||
|| (JERRY_BUILTIN_PROXY == 1) \
|
||||
|| (JERRY_BUILTIN_REFLECT == 1) \
|
||||
|| (JERRY_BUILTIN_TYPEDARRAY == 1) \
|
||||
|| (JERRY_BUILTIN_WEAKREF == 1))
|
||||
# error "JERRY_ESNEXT should be enabled too to enable JERRY_BUILTIN_xxxxx macro."
|
||||
#endif
|
||||
#if (JERRY_ESNEXT != 0) && (JERRY_ESNEXT != 1)
|
||||
#error "Invalid value for JERRY_ESNEXT macro."
|
||||
#endif /* (JERRY_ESNEXT != 0) && (JERRY_ESNEXT != 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_ESNEXT == 0) && (JERRY_BUILTIN_DATAVIEW == 1)
|
||||
#error "JERRY_ESNEXT should be enabled too to enable JERRY_BUILTIN_DATAVIEW macro."
|
||||
#endif /* (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_DATAVIEW == 1) */
|
||||
#if (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_CONTAINER == 1)
|
||||
#error "JERRY_ESNEXT should be enabled too to enable JERRY_BUILTIN_CONTAINER macro."
|
||||
#endif /* (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_CONTAINER == 1) */
|
||||
#if (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_PROXY == 1)
|
||||
#error "JERRY_ESNEXT should be enabled too to enable JERRY_BUILTIN_PROXY macro."
|
||||
#endif /* (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_PROXY == 1) */
|
||||
#if (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_REFLECT == 1)
|
||||
#error "JERRY_ESNEXT should be enabled too to enable JERRY_BUILTIN_REFLECT macro."
|
||||
#endif /* (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_REFLECT == 1) */
|
||||
#if (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_TYPEDARRAY == 1)
|
||||
#error "JERRY_ESNEXT should be enabled too to enable JERRY_BUILTIN_TYPEDARRAY macro."
|
||||
#endif /* (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_TYPEDARRAY == 1) */
|
||||
#if (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_WEAKREF == 1)
|
||||
#error "JERRY_ESNEXT should be enabled too to enable JERRY_BUILTIN_WEAKREF macro."
|
||||
#endif /* (JERRY_ESNEXT == 0) && (JERRY_BUILTIN_WEAKREF == 1) */
|
||||
#if (JERRY_ESNEXT == 0) && (JERRY_MODULE_SYSTEM == 1)
|
||||
# error "JERRY_ESNEXT should be enabled too to enable JERRY_MODULE_SYSTEM macro."
|
||||
#endif
|
||||
#error "JERRY_ESNEXT should be enabled too to enable JERRY_MODULE_SYSTEM macro."
|
||||
#endif /* (JERRY_ESNEXT == 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
|
||||
#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
|
||||
#error "JERRY_BUILTIN_SHAREDARRAYBUFFER should be enabled too to enable JERRY_BUILTIN_ATOMICS macro."
|
||||
#endif /* (JERRY_BUILTIN_SHAREDARRAYBUFFER == 0) && (JERRY_BUILTIN_ATOMICS == 1) */
|
||||
|
||||
/**
|
||||
* Internal options.
|
||||
*/
|
||||
#if !defined (JERRY_CPOINTER_32_BIT) \
|
||||
|| ((JERRY_CPOINTER_32_BIT != 0) && (JERRY_CPOINTER_32_BIT != 1))
|
||||
# error "Invalid value for 'JERRY_CPOINTER_32_BIT' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_DEBUGGER) \
|
||||
|| ((JERRY_DEBUGGER != 0) && (JERRY_DEBUGGER != 1))
|
||||
# error "Invalid value for 'JERRY_DEBUGGER' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_ERROR_MESSAGES) \
|
||||
|| ((JERRY_ERROR_MESSAGES != 0) && (JERRY_ERROR_MESSAGES != 1))
|
||||
# error "Invalid value for 'JERRY_ERROR_MESSAGES' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_EXTERNAL_CONTEXT) \
|
||||
|| ((JERRY_EXTERNAL_CONTEXT != 0) && (JERRY_EXTERNAL_CONTEXT != 1))
|
||||
# error "Invalid value for 'JERRY_EXTERNAL_CONTEXT' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_GLOBAL_HEAP_SIZE) || (JERRY_GLOBAL_HEAP_SIZE <= 0)
|
||||
# error "Invalid value for 'JERRY_GLOBAL_HEAP_SIZE' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_GC_LIMIT) || (JERRY_GC_LIMIT < 0)
|
||||
# error "Invalid value for 'JERRY_GC_LIMIT' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_STACK_LIMIT) || (JERRY_STACK_LIMIT < 0)
|
||||
# error "Invalid value for 'JERRY_STACK_LIMIT' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_GC_MARK_LIMIT) || (JERRY_GC_MARK_LIMIT < 0)
|
||||
# error "Invalid value for 'JERRY_GC_MARK_LIMIT' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_LCACHE) \
|
||||
|| ((JERRY_LCACHE != 0) && (JERRY_LCACHE != 1))
|
||||
# error "Invalid value for 'JERRY_LCACHE' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_FUNCTION_TO_STRING) \
|
||||
|| ((JERRY_FUNCTION_TO_STRING != 0) && (JERRY_FUNCTION_TO_STRING != 1))
|
||||
# error "Invalid value for 'JERRY_FUNCTION_TO_STRING' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_LINE_INFO) \
|
||||
|| ((JERRY_LINE_INFO != 0) && (JERRY_LINE_INFO != 1))
|
||||
# error "Invalid value for 'JERRY_LINE_INFO' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_LOGGING) \
|
||||
|| ((JERRY_LOGGING != 0) && (JERRY_LOGGING != 1))
|
||||
# error "Invalid value for 'JERRY_LOGGING' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_MEM_GC_BEFORE_EACH_ALLOC) \
|
||||
|| ((JERRY_MEM_GC_BEFORE_EACH_ALLOC != 0) && (JERRY_MEM_GC_BEFORE_EACH_ALLOC != 1))
|
||||
# error "Invalid value for 'JERRY_MEM_GC_BEFORE_EACH_ALLOC' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_MEM_STATS) \
|
||||
|| ((JERRY_MEM_STATS != 0) && (JERRY_MEM_STATS != 1))
|
||||
# error "Invalid value for 'JERRY_MEM_STATS' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_NUMBER_TYPE_FLOAT64) \
|
||||
|| ((JERRY_NUMBER_TYPE_FLOAT64 != 0) && (JERRY_NUMBER_TYPE_FLOAT64 != 1))
|
||||
# error "Invalid value for 'JERRY_NUMBER_TYPE_FLOAT64' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_PARSER) \
|
||||
|| ((JERRY_PARSER != 0) && (JERRY_PARSER != 1))
|
||||
# error "Invalid value for 'JERRY_PARSER' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_PARSER_DUMP_BYTE_CODE) \
|
||||
|| ((JERRY_PARSER_DUMP_BYTE_CODE != 0) && (JERRY_PARSER_DUMP_BYTE_CODE != 1))
|
||||
# error "Invalid value for 'JERRY_PARSER_DUMP_BYTE_CODE' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_PROPERTY_HASHMAP) \
|
||||
|| ((JERRY_PROPERTY_HASHMAP != 0) && (JERRY_PROPERTY_HASHMAP != 1))
|
||||
# error "Invalid value for 'JERRY_PROPERTY_HASHMAP' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_PROMISE_CALLBACK) \
|
||||
|| ((JERRY_PROMISE_CALLBACK != 0) && (JERRY_PROMISE_CALLBACK != 1))
|
||||
# error "Invalid value for 'JERRY_PROMISE_CALLBACK' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_REGEXP_DUMP_BYTE_CODE) \
|
||||
|| ((JERRY_REGEXP_DUMP_BYTE_CODE != 0) && (JERRY_REGEXP_DUMP_BYTE_CODE != 1))
|
||||
# error "Invalid value for 'JERRY_REGEXP_DUMP_BYTE_CODE' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_REGEXP_STRICT_MODE) \
|
||||
|| ((JERRY_REGEXP_STRICT_MODE != 0) && (JERRY_REGEXP_STRICT_MODE != 1))
|
||||
# error "Invalid value for 'JERRY_REGEXP_STRICT_MODE' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_SNAPSHOT_EXEC) \
|
||||
|| ((JERRY_SNAPSHOT_EXEC != 0) && (JERRY_SNAPSHOT_EXEC != 1))
|
||||
# error "Invalid value for 'JERRY_SNAPSHOT_EXEC' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_SNAPSHOT_SAVE) \
|
||||
|| ((JERRY_SNAPSHOT_SAVE != 0) && (JERRY_SNAPSHOT_SAVE != 1))
|
||||
# error "Invalid value for 'JERRY_SNAPSHOT_SAVE' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_SYSTEM_ALLOCATOR) \
|
||||
|| ((JERRY_SYSTEM_ALLOCATOR != 0) && (JERRY_SYSTEM_ALLOCATOR != 1))
|
||||
# error "Invalid value for 'JERRY_SYSTEM_ALLOCATOR' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_UNICODE_CASE_CONVERSION) \
|
||||
|| ((JERRY_UNICODE_CASE_CONVERSION != 0) && (JERRY_UNICODE_CASE_CONVERSION != 1))
|
||||
# error "Invalid value for 'JERRY_UNICODE_CASE_CONVERSION' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_VALGRIND) \
|
||||
|| ((JERRY_VALGRIND != 0) && (JERRY_VALGRIND != 1))
|
||||
# error "Invalid value for 'JERRY_VALGRIND' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_VM_EXEC_STOP) \
|
||||
|| ((JERRY_VM_EXEC_STOP != 0) && (JERRY_VM_EXEC_STOP != 1))
|
||||
# error "Invalid value for 'JERRY_VM_EXEC_STOP' macro."
|
||||
#endif
|
||||
#if !defined (JERRY_VM_THROW) \
|
||||
|| ((JERRY_VM_THROW != 0) && (JERRY_VM_THROW != 1))
|
||||
# error "Invalid value for 'JERRY_VM_THROW' macro."
|
||||
#endif
|
||||
#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_EXEC_STOP != 0) && (JERRY_VM_EXEC_STOP != 1)
|
||||
#error "Invalid value for 'JERRY_VM_EXEC_STOP' macro."
|
||||
#endif /* (JERRY_VM_EXEC_STOP != 0) && (JERRY_VM_EXEC_STOP != 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.
|
||||
@ -743,23 +705,23 @@
|
||||
* 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
|
||||
#error "Date does not support float32"
|
||||
#endif /* JERRY_BUILTIN_DATE && !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Promise support must be enabled if Promise callback support is enabled.
|
||||
*/
|
||||
#if JERRY_PROMISE_CALLBACK && !JERRY_ESNEXT
|
||||
# error "Promise callback support depends on ESNext support"
|
||||
#error "Promise callback support depends on ESNext support"
|
||||
#endif /* JERRY_PROMISE_CALLBACK && !JERRY_ESNEXT */
|
||||
|
||||
/**
|
||||
* Resource name related types into a single guard
|
||||
*/
|
||||
#if JERRY_LINE_INFO || JERRY_ERROR_MESSAGES || JERRY_MODULE_SYSTEM
|
||||
# define JERRY_RESOURCE_NAME 1
|
||||
#else
|
||||
# define JERRY_RESOURCE_NAME 0
|
||||
#endif
|
||||
#define JERRY_RESOURCE_NAME 1
|
||||
#else /* !(JERRY_LINE_INFO || JERRY_ERROR_MESSAGES || JERRY_MODULE_SYSTEM) */
|
||||
#define JERRY_RESOURCE_NAME 0
|
||||
#endif /* JERRY_LINE_INFO || JERRY_ERROR_MESSAGES || JERRY_MODULE_SYSTEM */
|
||||
|
||||
#endif /* !JERRYSCRIPT_CONFIG_H */
|
||||
|
||||
@ -13,16 +13,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "byte-code.h"
|
||||
#include "debugger.h"
|
||||
|
||||
#include "jerryscript-debugger.h"
|
||||
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-eval.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-objects.h"
|
||||
|
||||
#include "byte-code.h"
|
||||
#include "jcontext.h"
|
||||
#include "jerryscript-debugger.h"
|
||||
#include "lit-char-helpers.h"
|
||||
|
||||
#if JERRY_DEBUGGER
|
||||
@ -39,16 +42,14 @@ typedef struct
|
||||
* The number of message types in the debugger should reflect the
|
||||
* debugger versioning.
|
||||
*/
|
||||
JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 33
|
||||
&& JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT == 21
|
||||
&& JERRY_DEBUGGER_VERSION == 9,
|
||||
JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 33 && JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT == 21
|
||||
&& JERRY_DEBUGGER_VERSION == 9,
|
||||
debugger_version_correlates_to_message_type_count);
|
||||
|
||||
/**
|
||||
* Waiting for data from the client.
|
||||
*/
|
||||
#define JERRY_DEBUGGER_RECEIVE_DATA_MODE \
|
||||
(JERRY_DEBUGGER_BREAKPOINT_MODE | JERRY_DEBUGGER_CLIENT_SOURCE_MODE)
|
||||
#define JERRY_DEBUGGER_RECEIVE_DATA_MODE (JERRY_DEBUGGER_BREAKPOINT_MODE | JERRY_DEBUGGER_CLIENT_SOURCE_MODE)
|
||||
|
||||
/**
|
||||
* Type cast the debugger send buffer into a specific type.
|
||||
@ -59,8 +60,7 @@ JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 33
|
||||
/**
|
||||
* Type cast the debugger receive buffer into a specific type.
|
||||
*/
|
||||
#define JERRY_DEBUGGER_RECEIVE_BUFFER_AS(type, name_p) \
|
||||
type *name_p = ((type *) recv_buffer_p)
|
||||
#define JERRY_DEBUGGER_RECEIVE_BUFFER_AS(type, name_p) type *name_p = ((type *) recv_buffer_p)
|
||||
|
||||
/**
|
||||
* Free all unreferenced byte code structures which
|
||||
@ -71,17 +71,15 @@ jerry_debugger_free_unreferenced_byte_code (void)
|
||||
{
|
||||
jerry_debugger_byte_code_free_t *byte_code_free_p;
|
||||
|
||||
byte_code_free_p = JMEM_CP_GET_POINTER (jerry_debugger_byte_code_free_t,
|
||||
JERRY_CONTEXT (debugger_byte_code_free_tail));
|
||||
byte_code_free_p =
|
||||
JMEM_CP_GET_POINTER (jerry_debugger_byte_code_free_t, JERRY_CONTEXT (debugger_byte_code_free_tail));
|
||||
|
||||
while (byte_code_free_p != NULL)
|
||||
{
|
||||
jerry_debugger_byte_code_free_t *prev_byte_code_free_p;
|
||||
prev_byte_code_free_p = JMEM_CP_GET_POINTER (jerry_debugger_byte_code_free_t,
|
||||
byte_code_free_p->prev_cp);
|
||||
prev_byte_code_free_p = JMEM_CP_GET_POINTER (jerry_debugger_byte_code_free_t, byte_code_free_p->prev_cp);
|
||||
|
||||
jmem_heap_free_block (byte_code_free_p,
|
||||
((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
|
||||
jmem_heap_free_block (byte_code_free_p, ((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
|
||||
|
||||
byte_code_free_p = prev_byte_code_free_p;
|
||||
}
|
||||
@ -488,8 +486,7 @@ jerry_debugger_send_scope_variables (const uint8_t *recv_buffer_p) /**< pointer
|
||||
continue;
|
||||
}
|
||||
|
||||
ecma_string_t *prop_name = ecma_string_from_property_name (prop_iter_p->types[i],
|
||||
prop_pair_p->names_cp[i]);
|
||||
ecma_string_t *prop_name = ecma_string_from_property_name (prop_iter_p->types[i], prop_pair_p->names_cp[i]);
|
||||
|
||||
if (!jerry_debugger_copy_variables_to_string_message (JERRY_DEBUGGER_VALUE_NONE,
|
||||
prop_name,
|
||||
@ -509,10 +506,7 @@ jerry_debugger_send_scope_variables (const uint8_t *recv_buffer_p) /**< pointer
|
||||
ecma_string_t *str_p = ecma_op_to_string (prop_value_p.value);
|
||||
JERRY_ASSERT (str_p != NULL);
|
||||
|
||||
if (!jerry_debugger_copy_variables_to_string_message (variable_type,
|
||||
str_p,
|
||||
message_string_p,
|
||||
&buffer_pos))
|
||||
if (!jerry_debugger_copy_variables_to_string_message (variable_type, str_p, message_string_p, &buffer_pos))
|
||||
{
|
||||
ecma_deref_ecma_string (str_p);
|
||||
return;
|
||||
@ -591,21 +585,17 @@ jerry_debugger_send_eval (const lit_utf8_byte_t *eval_string_p, /**< evaluated s
|
||||
|
||||
if (ecma_is_value_object (result))
|
||||
{
|
||||
message = ecma_op_object_find (ecma_get_object_from_value (result),
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE));
|
||||
message =
|
||||
ecma_op_object_find (ecma_get_object_from_value (result), ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE));
|
||||
|
||||
if (!ecma_is_value_string (message)
|
||||
|| ecma_string_is_empty (ecma_get_string_from_value (message)))
|
||||
if (!ecma_is_value_string (message) || ecma_string_is_empty (ecma_get_string_from_value (message)))
|
||||
{
|
||||
ecma_free_value (message);
|
||||
lit_magic_string_id_t id = ecma_object_get_class_name (ecma_get_object_from_value (result));
|
||||
ecma_free_value (result);
|
||||
|
||||
const lit_utf8_byte_t *string_p = lit_get_magic_string_utf8 (id);
|
||||
jerry_debugger_send_string (JERRY_DEBUGGER_EVAL_RESULT,
|
||||
type,
|
||||
string_p,
|
||||
strlen ((const char *) string_p));
|
||||
jerry_debugger_send_string (JERRY_DEBUGGER_EVAL_RESULT, type, string_p, strlen ((const char *) string_p));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -635,12 +625,12 @@ jerry_debugger_send_eval (const lit_utf8_byte_t *eval_string_p, /**< evaluated s
|
||||
/**
|
||||
* Check received packet size.
|
||||
*/
|
||||
#define JERRY_DEBUGGER_CHECK_PACKET_SIZE(type) \
|
||||
if (message_size != sizeof (type)) \
|
||||
{ \
|
||||
#define JERRY_DEBUGGER_CHECK_PACKET_SIZE(type) \
|
||||
if (message_size != sizeof (type)) \
|
||||
{ \
|
||||
JERRY_ERROR_MSG ("Invalid message size\n"); \
|
||||
jerry_debugger_transport_close (); \
|
||||
return false; \
|
||||
jerry_debugger_transport_close (); \
|
||||
return false; \
|
||||
}
|
||||
|
||||
/**
|
||||
@ -658,8 +648,7 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
|
||||
{
|
||||
/* Process the received message. */
|
||||
|
||||
if (recv_buffer_p[0] >= JERRY_DEBUGGER_CONTINUE
|
||||
&& !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
|
||||
if (recv_buffer_p[0] >= JERRY_DEBUGGER_CONTINUE && !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
|
||||
{
|
||||
JERRY_ERROR_MSG ("Message requires breakpoint mode\n");
|
||||
jerry_debugger_transport_close ();
|
||||
@ -704,9 +693,7 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
|
||||
}
|
||||
|
||||
lit_utf8_byte_t *string_p = (lit_utf8_byte_t *) (uint8_data_p + 1);
|
||||
memcpy (string_p + uint8_data_p->uint8_offset,
|
||||
(lit_utf8_byte_t *) (uint8_data_part_p + 1),
|
||||
message_size);
|
||||
memcpy (string_p + uint8_data_p->uint8_offset, (lit_utf8_byte_t *) (uint8_data_part_p + 1), message_size);
|
||||
|
||||
if (message_size < expected_data)
|
||||
{
|
||||
@ -754,8 +741,7 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
|
||||
}
|
||||
|
||||
jerry_debugger_byte_code_free_t *byte_code_free_p;
|
||||
byte_code_free_p = JMEM_CP_GET_NON_NULL_POINTER (jerry_debugger_byte_code_free_t,
|
||||
byte_code_free_cp);
|
||||
byte_code_free_p = JMEM_CP_GET_NON_NULL_POINTER (jerry_debugger_byte_code_free_t, byte_code_free_cp);
|
||||
|
||||
if (byte_code_free_p->prev_cp != ECMA_NULL_POINTER)
|
||||
{
|
||||
@ -771,8 +757,7 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
|
||||
jmem_stats_free_byte_code_bytes (((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
jmem_heap_free_block (byte_code_free_p,
|
||||
((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
|
||||
jmem_heap_free_block (byte_code_free_p, ((size_t) byte_code_free_p->size) << JMEM_ALIGNMENT_LOG);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1023,8 +1008,8 @@ jerry_debugger_process_message (const uint8_t *recv_buffer_p, /**< pointer to th
|
||||
client_source_data_p = (jerry_debugger_uint8_data_t *) jmem_heap_alloc_block (client_source_data_size);
|
||||
|
||||
client_source_data_p->uint8_size = client_source_size;
|
||||
client_source_data_p->uint8_offset = (uint32_t) (message_size
|
||||
- sizeof (jerry_debugger_receive_client_source_first_t));
|
||||
client_source_data_p->uint8_offset =
|
||||
(uint32_t) (message_size - sizeof (jerry_debugger_receive_client_source_first_t));
|
||||
|
||||
lit_utf8_byte_t *client_source_string_p = (lit_utf8_byte_t *) (client_source_data_p + 1);
|
||||
memcpy (client_source_string_p,
|
||||
@ -1193,8 +1178,7 @@ jerry_debugger_breakpoint_hit (uint8_t message_type) /**< message type */
|
||||
|
||||
if (uint8_data != NULL)
|
||||
{
|
||||
jmem_heap_free_block (uint8_data,
|
||||
uint8_data->uint8_size + sizeof (jerry_debugger_uint8_data_t));
|
||||
jmem_heap_free_block (uint8_data, uint8_data->uint8_size + sizeof (jerry_debugger_uint8_data_t));
|
||||
}
|
||||
|
||||
JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_BREAKPOINT_MODE);
|
||||
@ -1460,13 +1444,13 @@ jerry_debugger_exception_object_to_string (ecma_value_t exception_obj_value) /**
|
||||
string_id = LIT_MAGIC_STRING_TYPE_ERROR_UL;
|
||||
break;
|
||||
}
|
||||
#if JERRY_ESNEXT
|
||||
#if JERRY_ESNEXT
|
||||
case ECMA_BUILTIN_ID_AGGREGATE_ERROR_PROTOTYPE:
|
||||
{
|
||||
string_id = LIT_MAGIC_STRING_AGGREGATE_ERROR_UL;
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_ESNEXT */
|
||||
#endif /* JERRY_ESNEXT */
|
||||
case ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE:
|
||||
{
|
||||
string_id = LIT_MAGIC_STRING_URI_ERROR_UL;
|
||||
@ -1544,10 +1528,8 @@ jerry_debugger_send_exception_string (ecma_value_t exception_value)
|
||||
|
||||
ECMA_STRING_TO_UTF8_STRING (string_p, string_data_p, string_size);
|
||||
|
||||
bool result = jerry_debugger_send_string (JERRY_DEBUGGER_EXCEPTION_STR,
|
||||
JERRY_DEBUGGER_NO_SUBTYPE,
|
||||
string_data_p,
|
||||
string_size);
|
||||
bool result =
|
||||
jerry_debugger_send_string (JERRY_DEBUGGER_EXCEPTION_STR, JERRY_DEBUGGER_NO_SUBTYPE, string_data_p, string_size);
|
||||
|
||||
ECMA_FINALIZE_UTF8_STRING (string_data_p, string_size);
|
||||
|
||||
|
||||
@ -16,9 +16,10 @@
|
||||
#ifndef DEBUGGER_H
|
||||
#define DEBUGGER_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "jerryscript-debugger-transport.h"
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if JERRY_DEBUGGER
|
||||
|
||||
/* JerryScript debugger protocol is a simplified version of RFC-6455 (WebSockets). */
|
||||
@ -51,8 +52,7 @@
|
||||
/**
|
||||
* Calculate the size of a message when a count number of items transmitted.
|
||||
*/
|
||||
#define JERRY_DEBUGGER_SEND_SIZE(count, type) \
|
||||
((size_t) ((count * sizeof (type)) + sizeof (jerry_debugger_send_type_t)))
|
||||
#define JERRY_DEBUGGER_SEND_SIZE(count, type) ((size_t) ((count * sizeof (type)) + sizeof (jerry_debugger_send_type_t)))
|
||||
|
||||
/**
|
||||
* Debugger operation modes:
|
||||
@ -113,8 +113,8 @@ typedef enum
|
||||
* Set and clear debugger flags.
|
||||
*/
|
||||
#define JERRY_DEBUGGER_UPDATE_FLAGS(flags_to_set, flags_to_clear) \
|
||||
JERRY_CONTEXT (debugger_flags) = ((JERRY_CONTEXT (debugger_flags) | (uint32_t) (flags_to_set)) \
|
||||
& (uint32_t) ~(flags_to_clear))
|
||||
JERRY_CONTEXT (debugger_flags) = \
|
||||
((JERRY_CONTEXT (debugger_flags) | (uint32_t) (flags_to_set)) & (uint32_t) ~(flags_to_clear))
|
||||
|
||||
/**
|
||||
* Types for the package.
|
||||
@ -455,7 +455,7 @@ typedef struct
|
||||
|
||||
/**
|
||||
* Incoming message: get scope variables
|
||||
*/
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< type of the message */
|
||||
|
||||
@ -14,10 +14,12 @@
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "ecma-gc.h"
|
||||
#include "jrt.h"
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
#include "jrt.h"
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_property_value_t) == sizeof (ecma_value_t),
|
||||
size_of_ecma_property_value_t_must_be_equal_to_size_of_ecma_value_t);
|
||||
@ -51,7 +53,7 @@ JERRY_STATIC_ASSERT (sizeof (ecma_extended_object_t) - sizeof (ecma_object_t) <=
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_number_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_number_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_number (void)
|
||||
{
|
||||
return (ecma_number_t *) jmem_pools_alloc (sizeof (ecma_number_t));
|
||||
@ -71,7 +73,7 @@ ecma_dealloc_number (ecma_number_t *number_p) /**< number to be freed */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_object_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_object_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_object (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
@ -99,7 +101,7 @@ ecma_dealloc_object (ecma_object_t *object_p) /**< object to be freed */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_extended_object_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_extended_object_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_extended_object (size_t size) /**< size of object */
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
@ -128,7 +130,7 @@ ecma_dealloc_extended_object (ecma_object_t *object_p, /**< extended object */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_string (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
@ -156,7 +158,7 @@ ecma_dealloc_string (ecma_string_t *string_p) /**< string to be freed */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_extended_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_extended_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_extended_string (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
@ -184,7 +186,7 @@ ecma_dealloc_extended_string (ecma_extended_string_t *ext_string_p) /**< extende
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_external_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_external_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_external_string (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
@ -212,7 +214,7 @@ ecma_dealloc_external_string (ecma_external_string_t *ext_string_p) /**< externa
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_string_buffer (size_t size) /**< size of string */
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
@ -241,7 +243,7 @@ ecma_dealloc_string_buffer (ecma_string_t *string_p, /**< string with data */
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern inline ecma_property_pair_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_property_pair_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_alloc_property_pair (void)
|
||||
{
|
||||
#if JERRY_MEM_STATS
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
* 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"
|
||||
|
||||
@ -20,114 +20,114 @@
|
||||
/**
|
||||
* Error message, if an argument is has an error flag
|
||||
*/
|
||||
const char * const ecma_error_value_msg_p = "Argument cannot be marked as error";
|
||||
const char* const ecma_error_value_msg_p = "Argument cannot be marked as error";
|
||||
|
||||
/**
|
||||
* Error message, if an argument has a wrong type
|
||||
*/
|
||||
const char * const ecma_error_wrong_args_msg_p = "This type of argument is not allowed";
|
||||
const char* const ecma_error_wrong_args_msg_p = "This type of argument is not allowed";
|
||||
|
||||
#if !JERRY_PARSER
|
||||
/**
|
||||
* Error message, if parsing is disabled
|
||||
*/
|
||||
const char * const ecma_error_parser_not_supported_p = "Source code parsing is disabled";
|
||||
const char* const ecma_error_parser_not_supported_p = "Source code parsing is disabled";
|
||||
#endif /* !JERRY_PARSER */
|
||||
|
||||
#if !JERRY_BUILTIN_JSON
|
||||
/**
|
||||
* Error message, if JSON support is disabled
|
||||
*/
|
||||
const char * const ecma_error_json_not_supported_p = "JSON support is disabled";
|
||||
const char* const ecma_error_json_not_supported_p = "JSON support is disabled";
|
||||
#endif /* !JERRY_BUILTIN_JSON */
|
||||
|
||||
#if !JERRY_ESNEXT
|
||||
/**
|
||||
* Error message, if Symbol support is disabled
|
||||
*/
|
||||
const char * const ecma_error_symbol_not_supported_p = "Symbol support is disabled";
|
||||
const char* const ecma_error_symbol_not_supported_p = "Symbol support is disabled";
|
||||
/**
|
||||
* Error message, if Promise support is disabled
|
||||
*/
|
||||
const char * const ecma_error_promise_not_supported_p = "Promise support is disabled";
|
||||
const char* const ecma_error_promise_not_supported_p = "Promise support is disabled";
|
||||
#endif /* !JERRY_ESNEXT */
|
||||
|
||||
#if !JERRY_BUILTIN_TYPEDARRAY
|
||||
/**
|
||||
* Error message, if TypedArray support is disabled
|
||||
*/
|
||||
const char * const ecma_error_typed_array_not_supported_p = "TypedArray support is disabled";
|
||||
const char* const ecma_error_typed_array_not_supported_p = "TypedArray support is disabled";
|
||||
#endif /* !JERRY_BUILTIN_TYPEDARRAY */
|
||||
|
||||
#if !JERRY_BUILTIN_SHAREDARRAYBUFFER
|
||||
/**
|
||||
* Error message, if SharedArrayBuffer support is disabled
|
||||
*/
|
||||
const char * const ecma_error_shared_arraybuffer_not_supported_p = "SharedArrayBuffer support is disabled";
|
||||
const char* const ecma_error_shared_arraybuffer_not_supported_p = "SharedArrayBuffer support is disabled";
|
||||
#endif /* !JERRY_BUILTIN_SHAREDARRAYBUFFER */
|
||||
|
||||
#if !JERRY_BUILTIN_DATAVIEW
|
||||
/**
|
||||
* Error message, if DataView support is disabled
|
||||
*/
|
||||
const char * const ecma_error_data_view_not_supported_p = "DataView support is disabled";
|
||||
const char* const ecma_error_data_view_not_supported_p = "DataView support is disabled";
|
||||
#endif /* !JERRY_BUILTIN_DATAVIEW */
|
||||
|
||||
#if !JERRY_BUILTIN_BIGINT
|
||||
/**
|
||||
* Error message, if BigInt support is disabled
|
||||
*/
|
||||
const char * const ecma_error_bigint_not_supported_p = "BigInt support is disabled";
|
||||
const char* const ecma_error_bigint_not_supported_p = "BigInt support is disabled";
|
||||
#endif /* !JERRY_BUILTIN_BIGINT */
|
||||
|
||||
#if !JERRY_BUILTIN_CONTAINER
|
||||
/**
|
||||
* Error message, if Container support is disabled
|
||||
*/
|
||||
const char * const ecma_error_container_not_supported_p = "Container support is disabled";
|
||||
const char* const ecma_error_container_not_supported_p = "Container support is disabled";
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
/**
|
||||
* Error message, if argument is not a module
|
||||
*/
|
||||
const char * const ecma_error_not_module_p = "Argument is not a module";
|
||||
const char* const ecma_error_not_module_p = "Argument is not a module";
|
||||
|
||||
/**
|
||||
* Error message, if a native module export is not found
|
||||
*/
|
||||
const char * const ecma_error_unknown_export_p = "Native module export not found";
|
||||
const char* const ecma_error_unknown_export_p = "Native module export not found";
|
||||
#else /* !JERRY_MODULE_SYSTEM */
|
||||
/**
|
||||
* Error message, if Module support is disabled
|
||||
*/
|
||||
const char * const ecma_error_module_not_supported_p = "Module support is disabled";
|
||||
const char* const ecma_error_module_not_supported_p = "Module support is disabled";
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
|
||||
/**
|
||||
* Error message, if callback function is not callable
|
||||
*/
|
||||
const char * const ecma_error_callback_is_not_callable = "Callback function is not callable";
|
||||
* Error message, if callback function is not callable
|
||||
*/
|
||||
const char* const ecma_error_callback_is_not_callable = "Callback function is not callable";
|
||||
|
||||
/**
|
||||
* Error message, if arrayBuffer is detached
|
||||
*/
|
||||
const char * const ecma_error_arraybuffer_is_detached = "ArrayBuffer has been detached";
|
||||
const char* const ecma_error_arraybuffer_is_detached = "ArrayBuffer has been detached";
|
||||
|
||||
/**
|
||||
* Error message, cannot convert undefined or null to object
|
||||
*/
|
||||
const char * const ecma_error_cannot_convert_to_object = "Cannot convert undefined or null to object";
|
||||
const char* const ecma_error_cannot_convert_to_object = "Cannot convert undefined or null to object";
|
||||
|
||||
/**
|
||||
* Error message, prototype property of a class is non-configurable
|
||||
*/
|
||||
const char * const ecma_error_class_is_non_configurable = "Prototype property of a class is non-configurable";
|
||||
const char* const ecma_error_class_is_non_configurable = "Prototype property of a class is non-configurable";
|
||||
|
||||
/**
|
||||
* Error message, argument is not an object
|
||||
*/
|
||||
const char * const ecma_error_argument_is_not_an_object = "Argument is not an object";
|
||||
const char* const ecma_error_argument_is_not_an_object = "Argument is not an object";
|
||||
|
||||
/**
|
||||
* Error message length of 'ecma_error_argument_is_not_an_object'
|
||||
@ -137,45 +137,45 @@ const int ecma_error_argument_is_not_an_object_length = 25;
|
||||
/**
|
||||
* Error message, argument is not a Proxy object
|
||||
*/
|
||||
const char * const ecma_error_argument_is_not_a_proxy = "Argument is not a Proxy object";
|
||||
const char* const ecma_error_argument_is_not_a_proxy = "Argument is not a Proxy object";
|
||||
|
||||
/**
|
||||
* Error message, target is not a constructor
|
||||
*/
|
||||
const char * const ecma_error_target_is_not_a_constructor = "Target is not a constructor";
|
||||
const char* const ecma_error_target_is_not_a_constructor = "Target is not a constructor";
|
||||
|
||||
/**
|
||||
* Error message, argument is not an regexp
|
||||
*/
|
||||
const char * const ecma_error_argument_is_not_an_regexp = "Argument 'this' is not a RegExp object";
|
||||
const char* const ecma_error_argument_is_not_an_regexp = "Argument 'this' is not a RegExp object";
|
||||
|
||||
/**
|
||||
* Error message, invalid array length
|
||||
*/
|
||||
const char * const ecma_error_invalid_array_length = "Invalid Array length";
|
||||
const char* const ecma_error_invalid_array_length = "Invalid Array length";
|
||||
|
||||
/**
|
||||
* Error message, local variable is redeclared
|
||||
*/
|
||||
const char * const ecma_error_local_variable_is_redeclared = "Local variable is redeclared";
|
||||
const char* const ecma_error_local_variable_is_redeclared = "Local variable is redeclared";
|
||||
|
||||
/**
|
||||
* Error message, expected a function
|
||||
*/
|
||||
const char * const ecma_error_expected_a_function = "Expected a function";
|
||||
const char* const ecma_error_expected_a_function = "Expected a function";
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
/**
|
||||
* Error message, class constructor invoked without new keyword
|
||||
*/
|
||||
const char * const ecma_error_class_constructor_new = "Class constructor cannot be invoked without 'new'";
|
||||
const char* const ecma_error_class_constructor_new = "Class constructor cannot be invoked without 'new'";
|
||||
|
||||
/**
|
||||
* Error message, variables declared by let/const must be initialized before reading their value
|
||||
*/
|
||||
const char * const ecma_error_let_const_not_initialized = ("Variables declared by let/const must be"
|
||||
" initialized before reading their value");
|
||||
const char* const ecma_error_let_const_not_initialized = ("Variables declared by let/const must be"
|
||||
" initialized before reading their value");
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
@ -186,31 +186,31 @@ const char * const ecma_error_let_const_not_initialized = ("Variables declared b
|
||||
/**
|
||||
* Error message, maximum snapshot size reached
|
||||
*/
|
||||
const char * const ecma_error_maximum_snapshot_size = "Maximum snapshot size reached";
|
||||
const char* const ecma_error_maximum_snapshot_size = "Maximum snapshot size reached";
|
||||
|
||||
/**
|
||||
* Error message, regular expressions literals are not supported
|
||||
*/
|
||||
const char * const ecma_error_regular_expression_not_supported = "Regular expression literals are not supported";
|
||||
const char* const ecma_error_regular_expression_not_supported = "Regular expression literals are not supported";
|
||||
|
||||
/**
|
||||
* Error message, snapshot buffer too small
|
||||
*/
|
||||
const char * const ecma_error_snapshot_buffer_small = "Snapshot buffer too small";
|
||||
const char* const ecma_error_snapshot_buffer_small = "Snapshot buffer too small";
|
||||
|
||||
/**
|
||||
* Error message, Unsupported generate snapshot flags specified
|
||||
*/
|
||||
const char * const ecma_error_snapshot_flag_not_supported = "Unsupported generate snapshot flags specified";
|
||||
const char* const ecma_error_snapshot_flag_not_supported = "Unsupported generate snapshot flags specified";
|
||||
|
||||
/**
|
||||
* Error message, Cannot allocate memory for literals
|
||||
*/
|
||||
const char * const ecma_error_cannot_allocate_memory_literals = "Cannot allocate memory for literals";
|
||||
const char* const ecma_error_cannot_allocate_memory_literals = "Cannot allocate memory for literals";
|
||||
|
||||
/**
|
||||
* Error message, Unsupported feature: tagged template literals
|
||||
*/
|
||||
const char * const ecma_error_tagged_template_literals = "Unsupported feature: tagged template literals";
|
||||
const char* const ecma_error_tagged_template_literals = "Unsupported feature: tagged template literals";
|
||||
|
||||
#endif /* JERRY_SNAPSHOT_SAVE || JERRY_SNAPSHOT_EXEC */
|
||||
|
||||
@ -20,75 +20,75 @@
|
||||
|
||||
#if JERRY_ERROR_MESSAGES
|
||||
|
||||
extern const char * const ecma_error_value_msg_p;
|
||||
extern const char * const ecma_error_wrong_args_msg_p;
|
||||
extern const char* const ecma_error_value_msg_p;
|
||||
extern const char* const ecma_error_wrong_args_msg_p;
|
||||
|
||||
#if !JERRY_PARSER
|
||||
extern const char * const ecma_error_parser_not_supported_p;
|
||||
extern const char* const ecma_error_parser_not_supported_p;
|
||||
#endif /* !JERRY_PARSER */
|
||||
|
||||
#if !JERRY_BUILTIN_JSON
|
||||
extern const char * const ecma_error_json_not_supported_p;
|
||||
extern const char* const ecma_error_json_not_supported_p;
|
||||
#endif /* !JERRY_BUILTIN_JSON */
|
||||
|
||||
#if !JERRY_ESNEXT
|
||||
extern const char * const ecma_error_symbol_not_supported_p;
|
||||
extern const char* const ecma_error_symbol_not_supported_p;
|
||||
|
||||
extern const char * const ecma_error_promise_not_supported_p;
|
||||
extern const char* const ecma_error_promise_not_supported_p;
|
||||
#endif /* !JERRY_ESNEXT */
|
||||
|
||||
#if !JERRY_BUILTIN_TYPEDARRAY
|
||||
extern const char * const ecma_error_typed_array_not_supported_p;
|
||||
extern const char* const ecma_error_typed_array_not_supported_p;
|
||||
#endif /* !JERRY_BUILTIN_TYPEDARRAY */
|
||||
|
||||
#if !JERRY_BUILTIN_SHAREDARRAYBUFFER
|
||||
extern const char * const ecma_error_shared_arraybuffer_not_supported_p;
|
||||
extern const char* const ecma_error_shared_arraybuffer_not_supported_p;
|
||||
#endif /* !JERRY_BUILTIN_SHAREDARRAYBUFFER */
|
||||
|
||||
#if !JERRY_BUILTIN_DATAVIEW
|
||||
extern const char * const ecma_error_data_view_not_supported_p;
|
||||
extern const char* const ecma_error_data_view_not_supported_p;
|
||||
#endif /* !JERRY_BUILTIN_DATAVIEW */
|
||||
|
||||
#if !JERRY_BUILTIN_BIGINT
|
||||
extern const char * const ecma_error_bigint_not_supported_p;
|
||||
extern const char* const ecma_error_bigint_not_supported_p;
|
||||
#endif /* !JERRY_BUILTIN_BIGINT */
|
||||
|
||||
#if !JERRY_BUILTIN_CONTAINER
|
||||
extern const char * const ecma_error_container_not_supported_p;
|
||||
extern const char* const ecma_error_container_not_supported_p;
|
||||
#endif /* !JERRY_BUILTIN_CONTAINER */
|
||||
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
extern const char * const ecma_error_not_module_p;
|
||||
extern const char * const ecma_error_unknown_export_p;
|
||||
extern const char* const ecma_error_not_module_p;
|
||||
extern const char* const ecma_error_unknown_export_p;
|
||||
#else /* !JERRY_MODULE_SYSTEM */
|
||||
extern const char * const ecma_error_module_not_supported_p;
|
||||
extern const char* const ecma_error_module_not_supported_p;
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
|
||||
extern const char * const ecma_error_callback_is_not_callable;
|
||||
extern const char * const ecma_error_arraybuffer_is_detached;
|
||||
extern const char * const ecma_error_cannot_convert_to_object;
|
||||
extern const char * const ecma_error_class_is_non_configurable;
|
||||
extern const char * const ecma_error_argument_is_not_an_object;
|
||||
extern const char* const ecma_error_callback_is_not_callable;
|
||||
extern const char* const ecma_error_arraybuffer_is_detached;
|
||||
extern const char* const ecma_error_cannot_convert_to_object;
|
||||
extern const char* const ecma_error_class_is_non_configurable;
|
||||
extern const char* const ecma_error_argument_is_not_an_object;
|
||||
extern const int ecma_error_argument_is_not_an_object_length;
|
||||
extern const char * const ecma_error_argument_is_not_a_proxy;
|
||||
extern const char * const ecma_error_target_is_not_a_constructor;
|
||||
extern const char * const ecma_error_argument_is_not_an_regexp;
|
||||
extern const char * const ecma_error_invalid_array_length;
|
||||
extern const char * const ecma_error_local_variable_is_redeclared;
|
||||
extern const char * const ecma_error_expected_a_function;
|
||||
extern const char* const ecma_error_argument_is_not_a_proxy;
|
||||
extern const char* const ecma_error_target_is_not_a_constructor;
|
||||
extern const char* const ecma_error_argument_is_not_an_regexp;
|
||||
extern const char* const ecma_error_invalid_array_length;
|
||||
extern const char* const ecma_error_local_variable_is_redeclared;
|
||||
extern const char* const ecma_error_expected_a_function;
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
extern const char * const ecma_error_class_constructor_new;
|
||||
extern const char * const ecma_error_let_const_not_initialized;
|
||||
extern const char* const ecma_error_class_constructor_new;
|
||||
extern const char* const ecma_error_let_const_not_initialized;
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
#endif /* JERRY_ERROR_MESSAGES */
|
||||
|
||||
/* snapshot errors */
|
||||
extern const char * const ecma_error_maximum_snapshot_size;
|
||||
extern const char * const ecma_error_regular_expression_not_supported;
|
||||
extern const char * const ecma_error_snapshot_buffer_small;
|
||||
extern const char * const ecma_error_snapshot_flag_not_supported;
|
||||
extern const char * const ecma_error_cannot_allocate_memory_literals;
|
||||
extern const char * const ecma_error_tagged_template_literals;
|
||||
#endif /* !ECMA_ERRORS_H */
|
||||
extern const char* const ecma_error_maximum_snapshot_size;
|
||||
extern const char* const ecma_error_regular_expression_not_supported;
|
||||
extern const char* const ecma_error_snapshot_buffer_small;
|
||||
extern const char* const ecma_error_snapshot_flag_not_supported;
|
||||
extern const char* const ecma_error_cannot_allocate_memory_literals;
|
||||
extern const char* const ecma_error_tagged_template_literals;
|
||||
#endif /* !ECMA_ERRORS_H */
|
||||
|
||||
@ -13,10 +13,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "byte-code.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-extended-info.h"
|
||||
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "byte-code.h"
|
||||
|
||||
#if JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@ -41,8 +43,7 @@ ecma_extended_info_decode_vlq (uint8_t **buffer_p) /**< [in/out] target buffer *
|
||||
{
|
||||
source_p--;
|
||||
value = (value << ECMA_EXTENDED_INFO_VLQ_SHIFT) | (*source_p & ECMA_EXTENDED_INFO_VLQ_MASK);
|
||||
}
|
||||
while (*source_p & ECMA_EXTENDED_INFO_VLQ_CONTINUE);
|
||||
} while (*source_p & ECMA_EXTENDED_INFO_VLQ_CONTINUE);
|
||||
|
||||
*buffer_p = source_p;
|
||||
return value;
|
||||
@ -71,8 +72,7 @@ ecma_extended_info_encode_vlq (uint8_t **buffer_p, /**< target buffer */
|
||||
{
|
||||
current_value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT;
|
||||
length++;
|
||||
}
|
||||
while (current_value > 0);
|
||||
} while (current_value > 0);
|
||||
|
||||
destination_p -= length;
|
||||
*buffer_p = destination_p;
|
||||
@ -81,8 +81,7 @@ ecma_extended_info_encode_vlq (uint8_t **buffer_p, /**< target buffer */
|
||||
{
|
||||
*destination_p++ = (uint8_t) (value | ECMA_EXTENDED_INFO_VLQ_CONTINUE);
|
||||
value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT;
|
||||
}
|
||||
while (value > 0);
|
||||
} while (value > 0);
|
||||
|
||||
**buffer_p &= ECMA_EXTENDED_INFO_VLQ_MASK;
|
||||
} /* ecma_extended_info_encode_vlq */
|
||||
@ -101,8 +100,7 @@ ecma_extended_info_get_encoded_length (uint32_t value) /**< encoded value */
|
||||
{
|
||||
value >>= ECMA_EXTENDED_INFO_VLQ_SHIFT;
|
||||
length++;
|
||||
}
|
||||
while (value > 0);
|
||||
} while (value > 0);
|
||||
|
||||
return length;
|
||||
} /* ecma_extended_info_get_encoded_length */
|
||||
|
||||
@ -23,10 +23,10 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#if JERRY_ESNEXT || JERRY_FUNCTION_TO_STRING
|
||||
|
||||
/**
|
||||
* Vlq encoding: flag which is set for all bytes except the last one.
|
||||
*/
|
||||
|
||||
@ -17,6 +17,8 @@
|
||||
* Garbage collector implementation
|
||||
*/
|
||||
|
||||
#include "ecma-gc.h"
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
@ -24,16 +26,16 @@
|
||||
#include "ecma-container-object.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lcache.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-property-hashmap.h"
|
||||
#include "ecma-proxy-object.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "jrt-bit-fields.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "jrt.h"
|
||||
#include "re-compiler.h"
|
||||
#include "vm-defines.h"
|
||||
#include "vm-stack.h"
|
||||
@ -300,8 +302,7 @@ ecma_gc_mark_properties (ecma_object_t *object_p, /**< object */
|
||||
|
||||
if (!ECMA_PROPERTY_IS_INTERNAL (property))
|
||||
{
|
||||
JERRY_ASSERT (property == ECMA_PROPERTY_TYPE_DELETED
|
||||
|| property == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
JERRY_ASSERT (property == ECMA_PROPERTY_TYPE_DELETED || property == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -314,8 +315,8 @@ ecma_gc_mark_properties (ecma_object_t *object_p, /**< object */
|
||||
case LIT_INTERNAL_MAGIC_STRING_ENVIRONMENT_RECORD:
|
||||
{
|
||||
ecma_environment_record_t *environment_record_p;
|
||||
environment_record_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_environment_record_t,
|
||||
property_pair_p->values[index].value);
|
||||
environment_record_p =
|
||||
ECMA_GET_INTERNAL_VALUE_POINTER (ecma_environment_record_t, property_pair_p->values[index].value);
|
||||
|
||||
if (environment_record_p->this_binding != ECMA_VALUE_UNINITIALIZED)
|
||||
{
|
||||
@ -397,8 +398,7 @@ ecma_gc_mark_properties (ecma_object_t *object_p, /**< object */
|
||||
{
|
||||
ecma_gc_set_object_visited (ecma_get_object_from_value (*value_p));
|
||||
}
|
||||
}
|
||||
while (++value_p < end_p);
|
||||
} while (++value_p < end_p);
|
||||
|
||||
if (property & ECMA_PROPERTY_FLAG_SINGLE_EXTERNAL)
|
||||
{
|
||||
@ -406,8 +406,7 @@ ecma_gc_mark_properties (ecma_object_t *object_p, /**< object */
|
||||
}
|
||||
|
||||
item_p = &(((ecma_native_pointer_chain_t *) item_p)->next_p->data);
|
||||
}
|
||||
while (item_p != NULL);
|
||||
} while (item_p != NULL);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -460,8 +459,8 @@ ecma_gc_mark_bound_function_object (ecma_object_t *object_p) /**< bound function
|
||||
ecma_bound_function_t *bound_func_p = (ecma_bound_function_t *) object_p;
|
||||
|
||||
ecma_object_t *target_func_p;
|
||||
target_func_p = ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t,
|
||||
bound_func_p->header.u.bound_function.target_function);
|
||||
target_func_p =
|
||||
ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, bound_func_p->header.u.bound_function.target_function);
|
||||
|
||||
ecma_gc_set_object_visited (target_func_p);
|
||||
|
||||
@ -547,12 +546,11 @@ ecma_gc_mark_map_object (ecma_object_t *object_p) /**< object */
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
map_object_p->u.cls.u3.value);
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value);
|
||||
ecma_value_t *start_p = ECMA_CONTAINER_START (container_p);
|
||||
uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p);
|
||||
|
||||
for (uint32_t i = 0; i < entry_count; i+= ECMA_CONTAINER_PAIR_SIZE)
|
||||
for (uint32_t i = 0; i < entry_count; i += ECMA_CONTAINER_PAIR_SIZE)
|
||||
{
|
||||
ecma_container_pair_t *entry_p = (ecma_container_pair_t *) (start_p + i);
|
||||
|
||||
@ -582,12 +580,11 @@ ecma_gc_mark_weakmap_object (ecma_object_t *object_p) /**< object */
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
map_object_p->u.cls.u3.value);
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value);
|
||||
ecma_value_t *start_p = ECMA_CONTAINER_START (container_p);
|
||||
uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p);
|
||||
|
||||
for (uint32_t i = 0; i < entry_count; i+= ECMA_CONTAINER_PAIR_SIZE)
|
||||
for (uint32_t i = 0; i < entry_count; i += ECMA_CONTAINER_PAIR_SIZE)
|
||||
{
|
||||
ecma_container_pair_t *entry_p = (ecma_container_pair_t *) (start_p + i);
|
||||
|
||||
@ -598,8 +595,7 @@ ecma_gc_mark_weakmap_object (ecma_object_t *object_p) /**< object */
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_object (entry_p->key));
|
||||
|
||||
if (ecma_is_value_object (entry_p->value)
|
||||
&& ecma_gc_is_object_visited (ecma_get_object_from_value (entry_p->key)))
|
||||
if (ecma_is_value_object (entry_p->value) && ecma_gc_is_object_visited (ecma_get_object_from_value (entry_p->key)))
|
||||
{
|
||||
ecma_gc_set_object_visited (ecma_get_object_from_value (entry_p->value));
|
||||
}
|
||||
@ -615,12 +611,11 @@ ecma_gc_mark_set_object (ecma_object_t *object_p) /**< object */
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
map_object_p->u.cls.u3.value);
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value);
|
||||
ecma_value_t *start_p = ECMA_CONTAINER_START (container_p);
|
||||
uint32_t entry_count = ECMA_CONTAINER_ENTRY_COUNT (container_p);
|
||||
|
||||
for (uint32_t i = 0; i < entry_count; i+= ECMA_CONTAINER_VALUE_SIZE)
|
||||
for (uint32_t i = 0; i < entry_count; i += ECMA_CONTAINER_VALUE_SIZE)
|
||||
{
|
||||
ecma_value_t *entry_p = start_p + i;
|
||||
|
||||
@ -728,8 +723,7 @@ ecma_gc_mark_executable_object (ecma_object_t *object_p) /**< object */
|
||||
do
|
||||
{
|
||||
ecma_gc_set_object_visited (ecma_get_object_from_value (*(--context_top_p)));
|
||||
}
|
||||
while (context_top_p > last_item_p);
|
||||
} while (context_top_p > last_item_p);
|
||||
|
||||
continue;
|
||||
}
|
||||
@ -750,8 +744,7 @@ ecma_gc_mark_executable_object (ecma_object_t *object_p) /**< object */
|
||||
|
||||
JERRY_ASSERT (context_top_p >= context_end_p + offsets);
|
||||
context_top_p -= offsets;
|
||||
}
|
||||
while (context_top_p > context_end_p);
|
||||
} while (context_top_p > context_end_p);
|
||||
}
|
||||
|
||||
register_end_p = executable_object_p->frame_ctx.stack_top_p;
|
||||
@ -891,8 +884,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
case ECMA_OBJECT_CLASS_SCRIPT:
|
||||
{
|
||||
const ecma_compiled_code_t *compiled_code_p;
|
||||
compiled_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
ext_object_p->u.cls.u3.value);
|
||||
compiled_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
|
||||
|
||||
JERRY_ASSERT (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION));
|
||||
ecma_gc_mark_compiled_code (((cbc_uint8_arguments_t *) compiled_code_p)->script_value);
|
||||
@ -910,8 +902,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
case ECMA_OBJECT_CLASS_MODULE_NAMESPACE:
|
||||
{
|
||||
JERRY_ASSERT (proto_cp == JMEM_CP_NULL);
|
||||
ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t,
|
||||
ext_object_p->u.cls.u3.value));
|
||||
ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, ext_object_p->u.cls.u3.value));
|
||||
ecma_gc_mark_properties (object_p, true);
|
||||
return;
|
||||
}
|
||||
@ -1114,8 +1105,8 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
case ECMA_OBJECT_TYPE_FUNCTION:
|
||||
{
|
||||
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
|
||||
ecma_gc_set_object_visited (ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t,
|
||||
ext_func_p->u.function.scope_cp));
|
||||
ecma_gc_set_object_visited (
|
||||
ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, ext_func_p->u.function.scope_cp));
|
||||
|
||||
const ecma_compiled_code_t *compiled_code_p = ecma_op_function_get_compiled_code (ext_func_p);
|
||||
|
||||
@ -1249,8 +1240,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
case ECMA_OBJECT_TYPE_NATIVE_FUNCTION:
|
||||
{
|
||||
ecma_native_function_t *native_function_p = (ecma_native_function_t *) object_p;
|
||||
ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t,
|
||||
native_function_p->realm_value));
|
||||
ecma_gc_set_object_visited (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, native_function_p->realm_value));
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_BUILTIN_REALMS */
|
||||
@ -1322,8 +1312,7 @@ ecma_gc_free_native_pointer (ecma_property_t property, /**< property descriptor
|
||||
jmem_heap_free_block (item_p, sizeof (ecma_native_pointer_chain_t));
|
||||
|
||||
item_p = next_p;
|
||||
}
|
||||
while (item_p != NULL);
|
||||
} while (item_p != NULL);
|
||||
} /* ecma_gc_free_native_pointer */
|
||||
|
||||
/**
|
||||
@ -1347,8 +1336,8 @@ ecma_free_arguments_object (ecma_extended_object_t *ext_object_p) /**< arguments
|
||||
if (!(mapped_arguments_p->unmapped.header.u.cls.u1.arguments_flags & ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE))
|
||||
#endif /* JERRY_SNAPSHOT_EXEC */
|
||||
{
|
||||
ecma_compiled_code_t *byte_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
mapped_arguments_p->u.byte_code);
|
||||
ecma_compiled_code_t *byte_code_p =
|
||||
ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, mapped_arguments_p->u.byte_code);
|
||||
|
||||
ecma_bytecode_deref (byte_code_p);
|
||||
}
|
||||
@ -1363,8 +1352,7 @@ ecma_free_arguments_object (ecma_extended_object_t *ext_object_p) /**< arguments
|
||||
ecma_free_value_if_not_object (argv_p[i]);
|
||||
}
|
||||
|
||||
uint32_t saved_argument_count = JERRY_MAX (arguments_number,
|
||||
arguments_p->header.u.cls.u2.formal_params_number);
|
||||
uint32_t saved_argument_count = JERRY_MAX (arguments_number, arguments_p->header.u.cls.u2.formal_params_number);
|
||||
|
||||
return object_size + (saved_argument_count * sizeof (ecma_value_t));
|
||||
} /* ecma_free_arguments_object */
|
||||
@ -1485,8 +1473,7 @@ ecma_gc_free_executable_object (ecma_object_t *object_p) /**< object */
|
||||
do
|
||||
{
|
||||
ecma_free_value_if_not_object (*(--context_top_p));
|
||||
}
|
||||
while (context_top_p > last_item_p);
|
||||
} while (context_top_p > last_item_p);
|
||||
|
||||
continue;
|
||||
}
|
||||
@ -1506,8 +1493,7 @@ ecma_gc_free_executable_object (ecma_object_t *object_p) /**< object */
|
||||
}
|
||||
|
||||
context_top_p = vm_stack_context_abort (&executable_object_p->frame_ctx, context_top_p);
|
||||
}
|
||||
while (context_top_p > context_end_p);
|
||||
} while (context_top_p > context_end_p);
|
||||
}
|
||||
|
||||
register_end_p = executable_object_p->frame_ctx.stack_top_p;
|
||||
@ -1526,8 +1512,7 @@ JERRY_STATIC_ASSERT (!ECMA_PROPERTY_IS_RAW (ECMA_PROPERTY_TYPE_DELETED),
|
||||
ecma_property_type_deleted_must_not_be_raw_property);
|
||||
JERRY_STATIC_ASSERT ((ECMA_PROPERTY_TYPE_DELETED & ECMA_PROPERTY_FLAG_LCACHED) == 0,
|
||||
ecma_property_type_deleted_must_not_have_lcached_flag);
|
||||
JERRY_STATIC_ASSERT (ECMA_GC_FREE_SECOND_PROPERTY == 1,
|
||||
ecma_gc_free_second_must_be_one);
|
||||
JERRY_STATIC_ASSERT (ECMA_GC_FREE_SECOND_PROPERTY == 1, ecma_gc_free_second_must_be_one);
|
||||
|
||||
/**
|
||||
* Free property of an object
|
||||
@ -1575,8 +1560,8 @@ ecma_gc_free_property (ecma_object_t *object_p, /**< object */
|
||||
|
||||
#if JERRY_CPOINTER_32_BIT
|
||||
ecma_getter_setter_pointers_t *getter_setter_pair_p;
|
||||
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t,
|
||||
prop_pair_p->values[index].getter_setter_pair_cp);
|
||||
getter_setter_pair_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t, prop_pair_p->values[index].getter_setter_pair_cp);
|
||||
jmem_pools_free (getter_setter_pair_p, sizeof (ecma_getter_setter_pointers_t));
|
||||
#endif /* JERRY_CPOINTER_32_BIT */
|
||||
return;
|
||||
@ -1655,8 +1640,7 @@ ecma_gc_free_properties (ecma_object_t *object_p, /**< object */
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
if (prop_iter_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
prop_iter_cp);
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
|
||||
if (prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
{
|
||||
ecma_property_hashmap_free (object_p);
|
||||
@ -1791,8 +1775,7 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
|
||||
case ECMA_OBJECT_CLASS_SCRIPT:
|
||||
{
|
||||
ecma_compiled_code_t *compiled_code_p;
|
||||
compiled_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
ext_object_p->u.cls.u3.value);
|
||||
compiled_code_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
|
||||
|
||||
ecma_bytecode_deref (compiled_code_p);
|
||||
break;
|
||||
@ -1813,8 +1796,8 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
|
||||
#if JERRY_BUILTIN_REGEXP
|
||||
case ECMA_OBJECT_CLASS_REGEXP:
|
||||
{
|
||||
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (ecma_compiled_code_t,
|
||||
ext_object_p->u.cls.u3.value);
|
||||
ecma_compiled_code_t *bytecode_p =
|
||||
ECMA_GET_INTERNAL_VALUE_ANY_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
|
||||
|
||||
ecma_bytecode_deref (bytecode_p);
|
||||
|
||||
@ -1886,8 +1869,8 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
|
||||
case ECMA_OBJECT_CLASS_CONTAINER:
|
||||
{
|
||||
ecma_extended_object_t *map_object_p = (ecma_extended_object_t *) object_p;
|
||||
ecma_collection_t *container_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
|
||||
map_object_p->u.cls.u3.value);
|
||||
ecma_collection_t *container_p =
|
||||
ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, map_object_p->u.cls.u3.value);
|
||||
ecma_op_container_free_entries (object_p);
|
||||
ecma_collection_destroy (container_p);
|
||||
break;
|
||||
@ -1978,8 +1961,8 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
|
||||
if (ext_func_p->u.function.bytecode_cp != ECMA_NULL_POINTER)
|
||||
{
|
||||
#endif /* JERRY_SNAPSHOT_EXEC */
|
||||
ecma_compiled_code_t *byte_code_p = (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
ext_func_p->u.function.bytecode_cp));
|
||||
ecma_compiled_code_t *byte_code_p =
|
||||
(ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_func_p->u.function.bytecode_cp));
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
if (CBC_FUNCTION_IS_ARROW (byte_code_p->status_flags))
|
||||
@ -2227,8 +2210,7 @@ ecma_gc_run (void)
|
||||
|
||||
obj_iter_cp = obj_next_cp;
|
||||
}
|
||||
}
|
||||
while (marked_anything_during_current_iteration);
|
||||
} while (marked_anything_during_current_iteration);
|
||||
|
||||
black_end_p->gc_next_cp = JMEM_CP_NULL;
|
||||
JERRY_CONTEXT (ecma_gc_objects_cp) = black_list_head.gc_next_cp;
|
||||
@ -2320,8 +2302,7 @@ ecma_free_unused_memory (jmem_pressure_t pressure) /**< current pressure */
|
||||
if (!ecma_is_lexical_environment (obj_iter_p)
|
||||
|| ecma_get_lex_env_type (obj_iter_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
|
||||
{
|
||||
if (!ecma_is_lexical_environment (obj_iter_p)
|
||||
&& ecma_op_object_is_fast_array (obj_iter_p))
|
||||
if (!ecma_is_lexical_environment (obj_iter_p) && ecma_op_object_is_fast_array (obj_iter_p))
|
||||
{
|
||||
obj_iter_cp = obj_iter_p->gc_next_cp;
|
||||
continue;
|
||||
@ -2338,7 +2319,6 @@ ecma_free_unused_memory (jmem_pressure_t pressure) /**< current pressure */
|
||||
ecma_property_hashmap_free (obj_iter_p);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
obj_iter_cp = obj_iter_p->gc_next_cp;
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#define ECMA_GC_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@ -17,10 +17,11 @@
|
||||
#define ECMA_GLOBALS_H
|
||||
|
||||
#include "ecma-errors.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "jmem.h"
|
||||
#include "jrt.h"
|
||||
#include "lit-magic-strings.h"
|
||||
#include "jmem.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@ -37,7 +38,7 @@
|
||||
*/
|
||||
#define ECMA_NULL_POINTER JMEM_CP_NULL
|
||||
|
||||
#if defined (JMEM_CAN_STORE_POINTER_VALUE_DIRECTLY)
|
||||
#if defined(JMEM_CAN_STORE_POINTER_VALUE_DIRECTLY)
|
||||
|
||||
/**
|
||||
* JMEM_ALIGNMENT_LOG aligned pointers can be stored directly in ecma_value_t
|
||||
@ -55,16 +56,16 @@
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_STATUS_API_AVAILABLE = (1u << 0), /**< api available */
|
||||
ECMA_STATUS_DIRECT_EVAL = (1u << 1), /**< eval is called directly */
|
||||
ECMA_STATUS_API_AVAILABLE = (1u << 0), /**< api available */
|
||||
ECMA_STATUS_DIRECT_EVAL = (1u << 1), /**< eval is called directly */
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
ECMA_STATUS_HIGH_PRESSURE_GC = (1u << 2), /**< last gc was under high pressure */
|
||||
ECMA_STATUS_HIGH_PRESSURE_GC = (1u << 2), /**< last gc was under high pressure */
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
ECMA_STATUS_EXCEPTION = (1u << 3), /**< last exception is a normal exception */
|
||||
ECMA_STATUS_ABORT = (1u << 4), /**< last exception is an abort */
|
||||
ECMA_STATUS_ERROR_UPDATE = (1u << 5), /**< the error_object_created_callback_p is called */
|
||||
ECMA_STATUS_EXCEPTION = (1u << 3), /**< last exception is a normal exception */
|
||||
ECMA_STATUS_ABORT = (1u << 4), /**< last exception is an abort */
|
||||
ECMA_STATUS_ERROR_UPDATE = (1u << 5), /**< the error_object_created_callback_p is called */
|
||||
#if JERRY_VM_THROW
|
||||
ECMA_STATUS_ERROR_THROWN = (1u << 6), /**< the vm_throw_callback_p is called */
|
||||
ECMA_STATUS_ERROR_THROWN = (1u << 6), /**< the vm_throw_callback_p is called */
|
||||
#endif /* JERRY_VM_THROW */
|
||||
} ecma_status_flag_t;
|
||||
|
||||
@ -190,8 +191,7 @@ typedef int32_t ecma_integer_value_t;
|
||||
/**
|
||||
* ECMA make simple value
|
||||
*/
|
||||
#define ECMA_MAKE_VALUE(value) \
|
||||
((((ecma_value_t) (value)) << ECMA_DIRECT_SHIFT) | ECMA_DIRECT_TYPE_SIMPLE_VALUE)
|
||||
#define ECMA_MAKE_VALUE(value) ((((ecma_value_t) (value)) << ECMA_DIRECT_SHIFT) | ECMA_DIRECT_TYPE_SIMPLE_VALUE)
|
||||
|
||||
/**
|
||||
* Simple ecma values
|
||||
@ -237,7 +237,7 @@ enum
|
||||
/**
|
||||
* Maximum integer number for an ecma value
|
||||
*/
|
||||
#define ECMA_INTEGER_NUMBER_MAX 0x7fffff
|
||||
#define ECMA_INTEGER_NUMBER_MAX 0x7fffff
|
||||
/**
|
||||
* Maximum integer number for an ecma value (shifted left with ECMA_DIRECT_SHIFT)
|
||||
*/
|
||||
@ -257,7 +257,7 @@ enum
|
||||
/**
|
||||
* Minimum integer number for an ecma value
|
||||
*/
|
||||
#define ECMA_INTEGER_NUMBER_MIN -0x7fffff
|
||||
#define ECMA_INTEGER_NUMBER_MIN -0x7fffff
|
||||
/**
|
||||
* Minimum integer number for an ecma value (shifted left with ECMA_DIRECT_SHIFT)
|
||||
*/
|
||||
@ -275,13 +275,12 @@ enum
|
||||
|
||||
#if ECMA_DIRECT_SHIFT != 4
|
||||
#error "Please update ECMA_INTEGER_NUMBER_MIN/MAX_SHIFTED according to the new value of ECMA_DIRECT_SHIFT."
|
||||
#endif
|
||||
#endif /* ECMA_DIRECT_SHIFT != 4 */
|
||||
|
||||
/**
|
||||
* Checks whether the integer number is in the integer number range.
|
||||
*/
|
||||
#define ECMA_IS_INTEGER_NUMBER(num) \
|
||||
(ECMA_INTEGER_NUMBER_MIN <= (num) && (num) <= ECMA_INTEGER_NUMBER_MAX)
|
||||
#define ECMA_IS_INTEGER_NUMBER(num) (ECMA_INTEGER_NUMBER_MIN <= (num) && (num) <= ECMA_INTEGER_NUMBER_MAX)
|
||||
|
||||
/**
|
||||
* Maximum integer number, which if squared, still fits in ecma_integer_value_t
|
||||
@ -295,8 +294,7 @@ enum
|
||||
/**
|
||||
* Checks whether the error flag is set.
|
||||
*/
|
||||
#define ECMA_IS_VALUE_ERROR(value) \
|
||||
(JERRY_UNLIKELY ((value) == ECMA_VALUE_ERROR))
|
||||
#define ECMA_IS_VALUE_ERROR(value) (JERRY_UNLIKELY ((value) == ECMA_VALUE_ERROR))
|
||||
|
||||
/**
|
||||
* Callback which tells whether the ECMAScript execution should be stopped.
|
||||
@ -422,32 +420,27 @@ typedef enum
|
||||
/**
|
||||
* Property flags configurable, enumerable.
|
||||
*/
|
||||
#define ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE \
|
||||
(ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_ENUMERABLE)
|
||||
#define ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE (ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_ENUMERABLE)
|
||||
|
||||
/**
|
||||
* Property flags configurable, enumerable.
|
||||
*/
|
||||
#define ECMA_PROPERTY_CONFIGURABLE_WRITABLE \
|
||||
(ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
#define ECMA_PROPERTY_CONFIGURABLE_WRITABLE (ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
|
||||
/**
|
||||
* Property flag built-in.
|
||||
*/
|
||||
#define ECMA_PROPERTY_BUILT_IN_FIXED \
|
||||
(ECMA_PROPERTY_FLAG_BUILT_IN)
|
||||
#define ECMA_PROPERTY_BUILT_IN_FIXED (ECMA_PROPERTY_FLAG_BUILT_IN)
|
||||
|
||||
/**
|
||||
* Property flags enumerable, writable.
|
||||
*/
|
||||
#define ECMA_PROPERTY_ENUMERABLE_WRITABLE \
|
||||
(ECMA_PROPERTY_FLAG_ENUMERABLE | ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
#define ECMA_PROPERTY_ENUMERABLE_WRITABLE (ECMA_PROPERTY_FLAG_ENUMERABLE | ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
|
||||
/**
|
||||
* Property flags built-in, configurable.
|
||||
*/
|
||||
#define ECMA_PROPERTY_BUILT_IN_CONFIGURABLE \
|
||||
(ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#define ECMA_PROPERTY_BUILT_IN_CONFIGURABLE (ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/**
|
||||
* Property flags built-in, configurable, enumerable.
|
||||
@ -458,14 +451,12 @@ typedef enum
|
||||
/**
|
||||
* Property flags built-in, configurable, writable.
|
||||
*/
|
||||
#define ECMA_PROPERTY_BUILT_IN_CONFIGURABLE_WRITABLE \
|
||||
(ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#define ECMA_PROPERTY_BUILT_IN_CONFIGURABLE_WRITABLE (ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/**
|
||||
* Property flags built-in, writable.
|
||||
*/
|
||||
#define ECMA_PROPERTY_BUILT_IN_WRITABLE \
|
||||
(ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
#define ECMA_PROPERTY_BUILT_IN_WRITABLE (ECMA_PROPERTY_FLAG_BUILT_IN | ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
|
||||
/**
|
||||
* Property flags built-in, configurable, enumerable, writable.
|
||||
@ -495,8 +486,7 @@ typedef enum
|
||||
/**
|
||||
* Type of hash-map property.
|
||||
*/
|
||||
#define ECMA_PROPERTY_TYPE_HASHMAP \
|
||||
(ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT)
|
||||
#define ECMA_PROPERTY_TYPE_HASHMAP (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT)
|
||||
|
||||
/**
|
||||
* Type of deleted property.
|
||||
@ -523,7 +513,7 @@ typedef enum
|
||||
/**
|
||||
* Checks whether a property is not found.
|
||||
*/
|
||||
#define ECMA_PROPERTY_IS_FOUND(property) \
|
||||
#define ECMA_PROPERTY_IS_FOUND(property) \
|
||||
(((property) & (ECMA_PROPERTY_FLAG_DATA | (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))) \
|
||||
!= (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))
|
||||
|
||||
@ -606,20 +596,17 @@ typedef struct
|
||||
/**
|
||||
* Get property name type.
|
||||
*/
|
||||
#define ECMA_PROPERTY_GET_NAME_TYPE(property) \
|
||||
((property) >> ECMA_PROPERTY_NAME_TYPE_SHIFT)
|
||||
#define ECMA_PROPERTY_GET_NAME_TYPE(property) ((property) >> ECMA_PROPERTY_NAME_TYPE_SHIFT)
|
||||
|
||||
/**
|
||||
* Returns true if the property pointer is a property pair.
|
||||
*/
|
||||
#define ECMA_PROPERTY_IS_PROPERTY_PAIR(property_header_p) \
|
||||
((property_header_p)->types[0] != ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
#define ECMA_PROPERTY_IS_PROPERTY_PAIR(property_header_p) ((property_header_p)->types[0] != ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
|
||||
/**
|
||||
* Property value of all internal properties
|
||||
*/
|
||||
#define ECMA_PROPERTY_INTERNAL \
|
||||
(ECMA_PROPERTY_FLAG_DATA | (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))
|
||||
#define ECMA_PROPERTY_INTERNAL (ECMA_PROPERTY_FLAG_DATA | (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))
|
||||
|
||||
/**
|
||||
* Checks whether a property is internal property
|
||||
@ -629,25 +616,23 @@ typedef struct
|
||||
/**
|
||||
* Checks whether a property is raw data or accessor property
|
||||
*/
|
||||
#define ECMA_PROPERTY_IS_RAW(property) \
|
||||
((property) < (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))
|
||||
#define ECMA_PROPERTY_IS_RAW(property) ((property) < (ECMA_DIRECT_STRING_SPECIAL << ECMA_PROPERTY_NAME_TYPE_SHIFT))
|
||||
|
||||
/**
|
||||
* Checks whether a property is raw data property (should only be used in assertions)
|
||||
*/
|
||||
#define ECMA_PROPERTY_IS_RAW_DATA(property) \
|
||||
(((property) & ECMA_PROPERTY_FLAG_DATA) && (property) < ECMA_PROPERTY_INTERNAL)
|
||||
(((property) &ECMA_PROPERTY_FLAG_DATA) && (property) < ECMA_PROPERTY_INTERNAL)
|
||||
|
||||
/**
|
||||
* Create internal property.
|
||||
*/
|
||||
#define ECMA_CREATE_INTERNAL_PROPERTY(object_p, name_p, property_p, property_value_p) \
|
||||
do \
|
||||
{ \
|
||||
#define ECMA_CREATE_INTERNAL_PROPERTY(object_p, name_p, property_p, property_value_p) \
|
||||
do \
|
||||
{ \
|
||||
(property_value_p) = ecma_create_named_data_property ((object_p), (name_p), 0, &(property_p)); \
|
||||
JERRY_ASSERT (*(property_p) == ECMA_PROPERTY_INTERNAL); \
|
||||
} \
|
||||
while (0)
|
||||
JERRY_ASSERT (*(property_p) == ECMA_PROPERTY_INTERNAL); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Property type of all virtual properties
|
||||
@ -657,7 +642,7 @@ typedef struct
|
||||
/**
|
||||
* Checks whether a property is virtual property
|
||||
*/
|
||||
#define ECMA_PROPERTY_IS_VIRTUAL(property) ECMA_PROPERTY_IS_INTERNAL(property)
|
||||
#define ECMA_PROPERTY_IS_VIRTUAL(property) ECMA_PROPERTY_IS_INTERNAL (property)
|
||||
|
||||
/**
|
||||
* Returns true if the property is named property.
|
||||
@ -681,8 +666,7 @@ typedef struct
|
||||
* Compute the property data pointer of a property.
|
||||
* The property must be part of a property pair.
|
||||
*/
|
||||
#define ECMA_PROPERTY_VALUE_PTR(property_p) \
|
||||
((ecma_property_value_t *) ECMA_PROPERTY_VALUE_DATA_PTR (property_p))
|
||||
#define ECMA_PROPERTY_VALUE_PTR(property_p) ((ecma_property_value_t *) ECMA_PROPERTY_VALUE_DATA_PTR (property_p))
|
||||
|
||||
/**
|
||||
* Property reference. It contains the value pointer
|
||||
@ -768,7 +752,7 @@ typedef enum
|
||||
ECMA_OBJECT_CLASS_MODULE_NAMESPACE, /**< Module Namespace (ECMAScript v11, 9.4.6) */
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
|
||||
/* These objects are marked by Garbage Collector. */
|
||||
/* These objects are marked by Garbage Collector. */
|
||||
#if JERRY_ESNEXT
|
||||
ECMA_OBJECT_CLASS_GENERATOR, /**< Generator object (ECMAScript v6, 25.2) */
|
||||
ECMA_OBJECT_CLASS_ASYNC_GENERATOR, /**< Async generator object (ECMAScript v11, 25.3) */
|
||||
@ -781,7 +765,7 @@ typedef enum
|
||||
#endif /* JERRY_ESNEXT */
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
ECMA_OBJECT_CLASS_MODULE, /**< Module (ECMAScript v6, 15.2) */
|
||||
#endif
|
||||
#endif /* JERRY_MODULE_SYSTEM */
|
||||
#if JERRY_ESNEXT
|
||||
ECMA_OBJECT_CLASS_PROMISE, /**< Promise (ECMAScript v6, 25.4) */
|
||||
ECMA_OBJECT_CLASS_PROMISE_CAPABILITY, /**< Promise capability (ECMAScript v6, 25.4.1.1) */
|
||||
@ -852,10 +836,10 @@ typedef enum
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_ITERATOR_KEYS, /**< keys iterator */
|
||||
ECMA_ITERATOR_VALUES, /**< values iterator */
|
||||
ECMA_ITERATOR_ENTRIES, /**< entries iterator */
|
||||
ECMA_ITERATOR__COUNT, /**< number of iterator kinds */
|
||||
ECMA_ITERATOR_KEYS, /**< keys iterator */
|
||||
ECMA_ITERATOR_VALUES, /**< values iterator */
|
||||
ECMA_ITERATOR_ENTRIES, /**< entries iterator */
|
||||
ECMA_ITERATOR__COUNT, /**< number of iterator kinds */
|
||||
} ecma_iterator_kind_t;
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
@ -868,9 +852,9 @@ typedef enum
|
||||
/**
|
||||
* Set JERRY_CONTEXT (status_flags) top 8 bits to the specified 'opts'.
|
||||
*/
|
||||
#define ECMA_SET_LOCAL_PARSE_OPTS(opts) \
|
||||
do \
|
||||
{ \
|
||||
#define ECMA_SET_LOCAL_PARSE_OPTS(opts) \
|
||||
do \
|
||||
{ \
|
||||
JERRY_CONTEXT (status_flags) |= ((uint32_t) opts << ECMA_LOCAL_PARSE_OPTS_OFFSET) | ECMA_STATUS_DIRECT_EVAL; \
|
||||
} while (0)
|
||||
|
||||
@ -883,9 +867,9 @@ typedef enum
|
||||
/**
|
||||
* Clear JERRY_CONTEXT (status_flags) top 8 bits.
|
||||
*/
|
||||
#define ECMA_CLEAR_LOCAL_PARSE_OPTS() \
|
||||
do \
|
||||
{ \
|
||||
#define ECMA_CLEAR_LOCAL_PARSE_OPTS() \
|
||||
do \
|
||||
{ \
|
||||
JERRY_CONTEXT (status_flags) &= ((1 << ECMA_LOCAL_PARSE_OPTS_OFFSET) - 1); \
|
||||
} while (0)
|
||||
|
||||
@ -971,8 +955,8 @@ typedef struct
|
||||
{
|
||||
jmem_cpointer_t property_list_cp; /**< compressed pointer to object's
|
||||
* or declerative lexical environments's property list */
|
||||
jmem_cpointer_t bound_object_cp; /**< compressed pointer to lexical environments's the bound object */
|
||||
jmem_cpointer_t home_object_cp; /**< compressed pointer to lexical environments's the home object */
|
||||
jmem_cpointer_t bound_object_cp; /**< compressed pointer to lexical environments's the bound object */
|
||||
jmem_cpointer_t home_object_cp; /**< compressed pointer to lexical environments's the home object */
|
||||
} u1;
|
||||
|
||||
/** object prototype or outer reference */
|
||||
@ -1038,11 +1022,11 @@ typedef ecma_value_t (*ecma_builtin_handler_t) (ecma_object_t *function_obj_p,
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_BUILTIN_ROUTINE_NO_OPTS = 0, /**< No options are provided */
|
||||
ECMA_BUILTIN_ROUTINE_LENGTH_INITIALIZED = (1u << 0), /**< 'length' property has been initialized */
|
||||
ECMA_BUILTIN_ROUTINE_NAME_INITIALIZED = (1u << 1), /**< 'name' property has been initialized */
|
||||
ECMA_BUILTIN_ROUTINE_GETTER = (1u << 2), /**< this routine is getter */
|
||||
ECMA_BUILTIN_ROUTINE_SETTER = (1u << 3), /**< this routine is setter */
|
||||
ECMA_BUILTIN_ROUTINE_NO_OPTS = 0, /**< No options are provided */
|
||||
ECMA_BUILTIN_ROUTINE_LENGTH_INITIALIZED = (1u << 0), /**< 'length' property has been initialized */
|
||||
ECMA_BUILTIN_ROUTINE_NAME_INITIALIZED = (1u << 1), /**< 'name' property has been initialized */
|
||||
ECMA_BUILTIN_ROUTINE_GETTER = (1u << 2), /**< this routine is getter */
|
||||
ECMA_BUILTIN_ROUTINE_SETTER = (1u << 3), /**< this routine is setter */
|
||||
} ecma_builtin_routine_flags_t;
|
||||
|
||||
/**
|
||||
@ -1239,13 +1223,13 @@ typedef struct
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t size; /**< real size >> JMEM_ALIGNMENT_LOG */
|
||||
uint16_t refs; /**< reference counter for the byte code */
|
||||
uint16_t status_flags; /**< various status flags:
|
||||
* CBC_IS_FUNCTION check tells whether the byte code
|
||||
* is function or regular expression.
|
||||
* If function, the other flags must be CBC_CODE_FLAGS...
|
||||
* If regexp, the other flags must be RE_FLAG... */
|
||||
uint16_t size; /**< real size >> JMEM_ALIGNMENT_LOG */
|
||||
uint16_t refs; /**< reference counter for the byte code */
|
||||
uint16_t status_flags; /**< various status flags:
|
||||
* CBC_IS_FUNCTION check tells whether the byte code
|
||||
* is function or regular expression.
|
||||
* If function, the other flags must be CBC_CODE_FLAGS...
|
||||
* If regexp, the other flags must be RE_FLAG... */
|
||||
} ecma_compiled_code_t;
|
||||
|
||||
/**
|
||||
@ -1331,26 +1315,22 @@ typedef struct
|
||||
/**
|
||||
* Size of the internal buffer.
|
||||
*/
|
||||
#define ECMA_CONTAINER_GET_SIZE(container_p) \
|
||||
(container_p->buffer_p[0])
|
||||
#define ECMA_CONTAINER_GET_SIZE(container_p) (container_p->buffer_p[0])
|
||||
|
||||
/**
|
||||
* Remove the size field of the internal buffer.
|
||||
*/
|
||||
#define ECMA_CONTAINER_SET_SIZE(container_p, size) \
|
||||
(container_p->buffer_p[0] = (ecma_value_t) (size))
|
||||
#define ECMA_CONTAINER_SET_SIZE(container_p, size) (container_p->buffer_p[0] = (ecma_value_t) (size))
|
||||
|
||||
/**
|
||||
* Number of entries of the internal buffer.
|
||||
*/
|
||||
#define ECMA_CONTAINER_ENTRY_COUNT(collection_p) \
|
||||
(collection_p->item_count - 1)
|
||||
#define ECMA_CONTAINER_ENTRY_COUNT(collection_p) (collection_p->item_count - 1)
|
||||
|
||||
/**
|
||||
* Pointer to the first entry of the internal buffer.
|
||||
*/
|
||||
#define ECMA_CONTAINER_START(collection_p) \
|
||||
(collection_p->buffer_p + 1)
|
||||
#define ECMA_CONTAINER_START(collection_p) (collection_p->buffer_p + 1)
|
||||
|
||||
#endif /* JERRY_BUILTIN_CONTAINER */
|
||||
|
||||
@ -1380,17 +1360,15 @@ typedef struct
|
||||
* - is_value_defined : true
|
||||
* - is_configurable_defined, is_writable_defined, is_enumerable_defined : true
|
||||
*/
|
||||
#define ECMA_NAME_DATA_PROPERTY_DESCRIPTOR_BITS ((uint16_t) (JERRY_PROP_IS_VALUE_DEFINED \
|
||||
| JERRY_PROP_IS_CONFIGURABLE_DEFINED \
|
||||
| JERRY_PROP_IS_ENUMERABLE_DEFINED \
|
||||
| JERRY_PROP_IS_WRITABLE_DEFINED))
|
||||
#define ECMA_NAME_DATA_PROPERTY_DESCRIPTOR_BITS \
|
||||
((uint16_t) (JERRY_PROP_IS_VALUE_DEFINED | JERRY_PROP_IS_CONFIGURABLE_DEFINED | JERRY_PROP_IS_ENUMERABLE_DEFINED \
|
||||
| JERRY_PROP_IS_WRITABLE_DEFINED))
|
||||
|
||||
/**
|
||||
* Bitmask to get a the physical property flags from an ecma_property_descriptor
|
||||
*/
|
||||
#define ECMA_PROPERTY_FLAGS_MASK ((uint16_t) (JERRY_PROP_IS_CONFIGURABLE \
|
||||
| JERRY_PROP_IS_ENUMERABLE \
|
||||
| JERRY_PROP_IS_WRITABLE))
|
||||
#define ECMA_PROPERTY_FLAGS_MASK \
|
||||
((uint16_t) (JERRY_PROP_IS_CONFIGURABLE | JERRY_PROP_IS_ENUMERABLE | JERRY_PROP_IS_WRITABLE))
|
||||
|
||||
#if !JERRY_NUMBER_TYPE_FLOAT64
|
||||
/**
|
||||
@ -1412,7 +1390,7 @@ typedef union
|
||||
/**
|
||||
* Maximum number of significant digits that ecma-number can store
|
||||
*/
|
||||
#define ECMA_NUMBER_MAX_DIGITS (9)
|
||||
#define ECMA_NUMBER_MAX_DIGITS (9)
|
||||
|
||||
/**
|
||||
* Width of sign field
|
||||
@ -1420,7 +1398,7 @@ typedef union
|
||||
* See also:
|
||||
* IEEE-754 2008, 3.6, Table 3.5
|
||||
*/
|
||||
#define ECMA_NUMBER_SIGN_WIDTH (1)
|
||||
#define ECMA_NUMBER_SIGN_WIDTH (1)
|
||||
|
||||
/**
|
||||
* Width of biased exponent field
|
||||
@ -1436,7 +1414,7 @@ typedef union
|
||||
* See also:
|
||||
* IEEE-754 2008, 3.6, Table 3.5
|
||||
*/
|
||||
#define ECMA_NUMBER_FRACTION_WIDTH (23)
|
||||
#define ECMA_NUMBER_FRACTION_WIDTH (23)
|
||||
#elif JERRY_NUMBER_TYPE_FLOAT64
|
||||
/**
|
||||
* Description of an ecma-number
|
||||
@ -1457,7 +1435,7 @@ typedef union
|
||||
/**
|
||||
* Maximum number of significant digits that ecma-number can store
|
||||
*/
|
||||
#define ECMA_NUMBER_MAX_DIGITS (19)
|
||||
#define ECMA_NUMBER_MAX_DIGITS (19)
|
||||
|
||||
/**
|
||||
* Width of sign field
|
||||
@ -1465,7 +1443,7 @@ typedef union
|
||||
* See also:
|
||||
* IEEE-754 2008, 3.6, Table 3.5
|
||||
*/
|
||||
#define ECMA_NUMBER_SIGN_WIDTH (1)
|
||||
#define ECMA_NUMBER_SIGN_WIDTH (1)
|
||||
|
||||
/**
|
||||
* Width of biased exponent field
|
||||
@ -1473,7 +1451,7 @@ typedef union
|
||||
* See also:
|
||||
* IEEE-754 2008, 3.6, Table 3.5
|
||||
*/
|
||||
#define ECMA_NUMBER_BIASED_EXP_WIDTH (11)
|
||||
#define ECMA_NUMBER_BIASED_EXP_WIDTH (11)
|
||||
|
||||
/**
|
||||
* Width of fraction field
|
||||
@ -1481,7 +1459,7 @@ typedef union
|
||||
* See also:
|
||||
* IEEE-754 2008, 3.6, Table 3.5
|
||||
*/
|
||||
#define ECMA_NUMBER_FRACTION_WIDTH (52)
|
||||
#define ECMA_NUMBER_FRACTION_WIDTH (52)
|
||||
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
@ -1492,12 +1470,12 @@ typedef union
|
||||
/**
|
||||
* Value '1' of ecma_number_t
|
||||
*/
|
||||
#define ECMA_NUMBER_ONE ((ecma_number_t) 1)
|
||||
#define ECMA_NUMBER_ONE ((ecma_number_t) 1)
|
||||
|
||||
/**
|
||||
* Value '2' of ecma_number_t
|
||||
*/
|
||||
#define ECMA_NUMBER_TWO ((ecma_number_t) 2)
|
||||
#define ECMA_NUMBER_TWO ((ecma_number_t) 2)
|
||||
|
||||
/**
|
||||
* Value '0.5' of ecma_number_t
|
||||
@ -1515,74 +1493,74 @@ typedef union
|
||||
*
|
||||
* See also: ECMA_262 v5, 15.7.3.3
|
||||
*/
|
||||
# define ECMA_NUMBER_MIN_VALUE (FLT_MIN)
|
||||
#define ECMA_NUMBER_MIN_VALUE (FLT_MIN)
|
||||
/**
|
||||
* Number.MAX_VALUE (i.e., the maximum value of ecma-number)
|
||||
*
|
||||
* See also: ECMA_262 v5, 15.7.3.2
|
||||
*/
|
||||
# define ECMA_NUMBER_MAX_VALUE (FLT_MAX)
|
||||
#define ECMA_NUMBER_MAX_VALUE (FLT_MAX)
|
||||
/**
|
||||
* Number.EPSILON
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.1
|
||||
*/
|
||||
# define ECMA_NUMBER_EPSILON ((ecma_number_t) 1.1920928955078125e-7)
|
||||
#define ECMA_NUMBER_EPSILON ((ecma_number_t) 1.1920928955078125e-7)
|
||||
|
||||
/**
|
||||
* Number.MAX_SAFE_INTEGER
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.6
|
||||
*/
|
||||
# define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0xFFFFFF)
|
||||
#define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0xFFFFFF)
|
||||
|
||||
/**
|
||||
* Number.MIN_SAFE_INTEGER
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.8
|
||||
*/
|
||||
# define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0xFFFFFF)
|
||||
#define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0xFFFFFF)
|
||||
#elif JERRY_NUMBER_TYPE_FLOAT64
|
||||
/**
|
||||
* Number.MAX_VALUE (i.e., the maximum value of ecma-number)
|
||||
*
|
||||
* See also: ECMA_262 v5, 15.7.3.2
|
||||
*/
|
||||
# define ECMA_NUMBER_MAX_VALUE ((ecma_number_t) 1.7976931348623157e+308)
|
||||
#define ECMA_NUMBER_MAX_VALUE ((ecma_number_t) 1.7976931348623157e+308)
|
||||
|
||||
/**
|
||||
* Number.MIN_VALUE (i.e., the smallest positive value of ecma-number)
|
||||
*
|
||||
* See also: ECMA_262 v5, 15.7.3.3
|
||||
*/
|
||||
# define ECMA_NUMBER_MIN_VALUE ((ecma_number_t) 5e-324)
|
||||
#define ECMA_NUMBER_MIN_VALUE ((ecma_number_t) 5e-324)
|
||||
|
||||
/**
|
||||
* Number.EPSILON
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.1
|
||||
*/
|
||||
# define ECMA_NUMBER_EPSILON ((ecma_number_t) 2.2204460492503130808472633361816e-16)
|
||||
#define ECMA_NUMBER_EPSILON ((ecma_number_t) 2.2204460492503130808472633361816e-16)
|
||||
|
||||
/**
|
||||
* Number.MAX_SAFE_INTEGER
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.6
|
||||
*/
|
||||
# define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0x1FFFFFFFFFFFFF)
|
||||
#define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0x1FFFFFFFFFFFFF)
|
||||
|
||||
/**
|
||||
* Number.MIN_SAFE_INTEGER
|
||||
*
|
||||
* See also: ECMA_262 v6, 20.1.2.8
|
||||
*/
|
||||
# define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0x1FFFFFFFFFFFFF)
|
||||
#define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0x1FFFFFFFFFFFFF)
|
||||
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
|
||||
/**
|
||||
* Euler number
|
||||
*/
|
||||
#define ECMA_NUMBER_E ((ecma_number_t) 2.7182818284590452354)
|
||||
#define ECMA_NUMBER_E ((ecma_number_t) 2.7182818284590452354)
|
||||
|
||||
/**
|
||||
* Natural logarithm of 10
|
||||
@ -1607,17 +1585,17 @@ typedef union
|
||||
/**
|
||||
* Pi number
|
||||
*/
|
||||
#define ECMA_NUMBER_PI ((ecma_number_t) 3.1415926535897932)
|
||||
#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)
|
||||
#define ECMA_NUMBER_SQRT_1_2 ((ecma_number_t) 0.7071067811865476)
|
||||
|
||||
/**
|
||||
* Square root of 2
|
||||
*/
|
||||
#define ECMA_NUMBER_SQRT2 ((ecma_number_t) 1.4142135623730951)
|
||||
#define ECMA_NUMBER_SQRT2 ((ecma_number_t) 1.4142135623730951)
|
||||
|
||||
/**
|
||||
* Maximum number of characters in string representation of ecma-number
|
||||
@ -1657,8 +1635,7 @@ typedef struct
|
||||
/**
|
||||
* Compute the total allocated size of the collection based on it's capacity
|
||||
*/
|
||||
#define ECMA_COLLECTION_ALLOCATED_SIZE(capacity) \
|
||||
(uint32_t) (capacity * sizeof (ecma_value_t))
|
||||
#define ECMA_COLLECTION_ALLOCATED_SIZE(capacity) (uint32_t) (capacity * sizeof (ecma_value_t))
|
||||
|
||||
/**
|
||||
* Initial allocated size of an ecma-collection
|
||||
@ -1724,8 +1701,7 @@ typedef enum
|
||||
/**
|
||||
* Checks whether the string is direct.
|
||||
*/
|
||||
#define ECMA_IS_DIRECT_STRING(string_p) \
|
||||
((((uintptr_t) (string_p)) & 0x1) != 0)
|
||||
#define ECMA_IS_DIRECT_STRING(string_p) ((((uintptr_t) (string_p)) & 0x1) != 0)
|
||||
|
||||
/**
|
||||
* Checks whether the string is direct.
|
||||
@ -1736,8 +1712,7 @@ typedef enum
|
||||
/**
|
||||
* Returns the type of a direct string.
|
||||
*/
|
||||
#define ECMA_GET_DIRECT_STRING_TYPE(string_p) \
|
||||
((((uintptr_t) (string_p)) >> ECMA_VALUE_SHIFT) & 0x3)
|
||||
#define ECMA_GET_DIRECT_STRING_TYPE(string_p) ((((uintptr_t) (string_p)) >> ECMA_VALUE_SHIFT) & 0x3)
|
||||
|
||||
/**
|
||||
* Shift applied to type conversions.
|
||||
@ -1753,8 +1728,7 @@ typedef enum
|
||||
/**
|
||||
* Returns the value of a direct string.
|
||||
*/
|
||||
#define ECMA_GET_DIRECT_STRING_VALUE(string_p) \
|
||||
(((uintptr_t) (string_p)) >> ECMA_DIRECT_STRING_SHIFT)
|
||||
#define ECMA_GET_DIRECT_STRING_VALUE(string_p) (((uintptr_t) (string_p)) >> ECMA_DIRECT_STRING_SHIFT)
|
||||
|
||||
/**
|
||||
* Maximum number of bytes that a long-utf8-string is able to store
|
||||
@ -1799,14 +1773,12 @@ typedef enum
|
||||
/**
|
||||
* Set an ecma-string as static string
|
||||
*/
|
||||
#define ECMA_SET_STRING_AS_STATIC(string_p) \
|
||||
(string_p)->refs_and_container |= ECMA_STATIC_STRING_FLAG
|
||||
#define ECMA_SET_STRING_AS_STATIC(string_p) (string_p)->refs_and_container |= ECMA_STATIC_STRING_FLAG
|
||||
|
||||
/**
|
||||
* Checks whether the ecma-string is static string
|
||||
*/
|
||||
#define ECMA_STRING_IS_STATIC(string_p) \
|
||||
((string_p)->refs_and_container & ECMA_STATIC_STRING_FLAG)
|
||||
#define ECMA_STRING_IS_STATIC(string_p) ((string_p)->refs_and_container & ECMA_STATIC_STRING_FLAG)
|
||||
|
||||
/**
|
||||
* Returns with the container type of a string.
|
||||
@ -1817,8 +1789,7 @@ typedef enum
|
||||
/**
|
||||
* Checks whether the reference counter is 1 of a string.
|
||||
*/
|
||||
#define ECMA_STRING_IS_REF_EQUALS_TO_ONE(string_desc_p) \
|
||||
(((string_desc_p)->refs_and_container >> 4) == 1)
|
||||
#define ECMA_STRING_IS_REF_EQUALS_TO_ONE(string_desc_p) (((string_desc_p)->refs_and_container >> 4) == 1)
|
||||
|
||||
/**
|
||||
* Checks whether the reference counter is 1 of an extended primitive.
|
||||
@ -1878,38 +1849,34 @@ typedef struct
|
||||
/**
|
||||
* Header size of an ecma ASCII string
|
||||
*/
|
||||
#define ECMA_ASCII_STRING_HEADER_SIZE \
|
||||
((lit_utf8_size_t) (sizeof (ecma_string_t) + sizeof (uint8_t)))
|
||||
#define ECMA_ASCII_STRING_HEADER_SIZE ((lit_utf8_size_t) (sizeof (ecma_string_t) + sizeof (uint8_t)))
|
||||
|
||||
/**
|
||||
* Get the size of an ecma ASCII string
|
||||
*/
|
||||
#define ECMA_ASCII_STRING_GET_SIZE(string_p) \
|
||||
((lit_utf8_size_t) *((lit_utf8_byte_t *) (string_p) + sizeof (ecma_string_t)) + 1)
|
||||
((lit_utf8_size_t) * ((lit_utf8_byte_t *) (string_p) + sizeof (ecma_string_t)) + 1)
|
||||
|
||||
/**
|
||||
* Set the size of an ecma ASCII string
|
||||
*/
|
||||
#define ECMA_ASCII_STRING_SET_SIZE(string_p, size) \
|
||||
(*((lit_utf8_byte_t *) (string_p) + sizeof (ecma_string_t)) = (uint8_t) ((size) - 1))
|
||||
(*((lit_utf8_byte_t *) (string_p) + sizeof (ecma_string_t)) = (uint8_t) ((size) -1))
|
||||
|
||||
/**
|
||||
* Get the start position of the string buffer of an ecma ASCII string
|
||||
*/
|
||||
#define ECMA_ASCII_STRING_GET_BUFFER(string_p) \
|
||||
((lit_utf8_byte_t *) (string_p) + ECMA_ASCII_STRING_HEADER_SIZE)
|
||||
#define ECMA_ASCII_STRING_GET_BUFFER(string_p) ((lit_utf8_byte_t *) (string_p) + ECMA_ASCII_STRING_HEADER_SIZE)
|
||||
|
||||
/**
|
||||
* Get the start position of the string buffer of an ecma UTF8 string
|
||||
*/
|
||||
#define ECMA_SHORT_STRING_GET_BUFFER(string_p) \
|
||||
((lit_utf8_byte_t *) (string_p) + sizeof (ecma_short_string_t))
|
||||
#define ECMA_SHORT_STRING_GET_BUFFER(string_p) ((lit_utf8_byte_t *) (string_p) + sizeof (ecma_short_string_t))
|
||||
|
||||
/**
|
||||
* Get the start position of the string buffer of an ecma long CESU8 string
|
||||
*/
|
||||
#define ECMA_LONG_STRING_BUFFER_START(string_p) \
|
||||
((lit_utf8_byte_t *) (string_p) + sizeof (ecma_long_string_t))
|
||||
#define ECMA_LONG_STRING_BUFFER_START(string_p) ((lit_utf8_byte_t *) (string_p) + sizeof (ecma_long_string_t))
|
||||
|
||||
/**
|
||||
* ECMA extended string-value descriptor
|
||||
@ -2074,18 +2041,18 @@ typedef ecma_value_t (*ecma_typedarray_setter_fn_t) (lit_utf8_byte_t *src, ecma_
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_INT8_ARRAY, /**< Int8Array */
|
||||
ECMA_UINT8_ARRAY, /**< Uint8Array */
|
||||
ECMA_INT8_ARRAY, /**< Int8Array */
|
||||
ECMA_UINT8_ARRAY, /**< Uint8Array */
|
||||
ECMA_UINT8_CLAMPED_ARRAY, /**< Uint8ClampedArray */
|
||||
ECMA_INT16_ARRAY, /**< Int16Array */
|
||||
ECMA_UINT16_ARRAY, /**< Uint16Array */
|
||||
ECMA_INT32_ARRAY, /**< Int32Array */
|
||||
ECMA_UINT32_ARRAY, /**< Uint32Array */
|
||||
ECMA_FLOAT32_ARRAY, /**< Float32Array */
|
||||
ECMA_FLOAT64_ARRAY, /**< Float64Array */
|
||||
ECMA_INT16_ARRAY, /**< Int16Array */
|
||||
ECMA_UINT16_ARRAY, /**< Uint16Array */
|
||||
ECMA_INT32_ARRAY, /**< Int32Array */
|
||||
ECMA_UINT32_ARRAY, /**< Uint32Array */
|
||||
ECMA_FLOAT32_ARRAY, /**< Float32Array */
|
||||
ECMA_FLOAT64_ARRAY, /**< Float64Array */
|
||||
/* ECMA_TYPEDARRAY_IS_BIGINT_TYPE macro should be updated when new types are added */
|
||||
ECMA_BIGINT64_ARRAY, /**< BigInt64Array */
|
||||
ECMA_BIGUINT64_ARRAY, /**< BigUInt64Array */
|
||||
ECMA_BIGINT64_ARRAY, /**< BigInt64Array */
|
||||
ECMA_BIGUINT64_ARRAY, /**< BigUInt64Array */
|
||||
} ecma_typedarray_type_t;
|
||||
|
||||
/**
|
||||
@ -2145,8 +2112,7 @@ typedef struct
|
||||
/**
|
||||
* Checks whether a given typedarray is BigInt type or not.
|
||||
**/
|
||||
#define ECMA_TYPEDARRAY_IS_BIGINT_TYPE(id) \
|
||||
((id) >= ECMA_BIGINT64_ARRAY)
|
||||
#define ECMA_TYPEDARRAY_IS_BIGINT_TYPE(id) ((id) >= ECMA_BIGINT64_ARRAY)
|
||||
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
@ -2187,7 +2153,7 @@ typedef enum
|
||||
/**
|
||||
* Checks whether the executable object is waiting for resuming.
|
||||
*/
|
||||
#define ECMA_EXECUTABLE_OBJECT_IS_SUSPENDED(executable_object_p) \
|
||||
#define ECMA_EXECUTABLE_OBJECT_IS_SUSPENDED(executable_object_p) \
|
||||
(!((executable_object_p)->extended_object.u.cls.u2.executable_obj_flags \
|
||||
& (ECMA_EXECUTABLE_OBJECT_COMPLETED | ECMA_EXECUTABLE_OBJECT_RUNNING)))
|
||||
|
||||
@ -2306,21 +2272,21 @@ typedef struct
|
||||
* Check the current stack usage. If the limit is reached a RangeError is raised.
|
||||
* The macro argument specifies the return value which is usally ECMA_VALUE_ERROR or NULL.
|
||||
*/
|
||||
#define ECMA_CHECK_STACK_USAGE_RETURN(RETURN_VALUE) \
|
||||
do \
|
||||
{ \
|
||||
if (ecma_get_current_stack_usage () > CONFIG_MEM_STACK_LIMIT) \
|
||||
{ \
|
||||
ecma_raise_range_error (ECMA_ERR_MSG ("Maximum call stack size exceeded")); \
|
||||
return RETURN_VALUE; \
|
||||
} \
|
||||
} while (0)
|
||||
#define ECMA_CHECK_STACK_USAGE_RETURN(RETURN_VALUE) \
|
||||
do \
|
||||
{ \
|
||||
if (ecma_get_current_stack_usage () > CONFIG_MEM_STACK_LIMIT) \
|
||||
{ \
|
||||
ecma_raise_range_error (ECMA_ERR_MSG ("Maximum call stack size exceeded")); \
|
||||
return RETURN_VALUE; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Specialized version of ECMA_CHECK_STACK_USAGE_RETURN which returns ECMA_VALUE_ERROR.
|
||||
* This version should be used in most cases.
|
||||
*/
|
||||
#define ECMA_CHECK_STACK_USAGE() ECMA_CHECK_STACK_USAGE_RETURN(ECMA_VALUE_ERROR)
|
||||
#define ECMA_CHECK_STACK_USAGE() ECMA_CHECK_STACK_USAGE_RETURN (ECMA_VALUE_ERROR)
|
||||
#else /* JERRY_STACK_LIMIT == 0) */
|
||||
/**
|
||||
* If the stack limit is unlimited, this check is an empty macro.
|
||||
@ -2446,11 +2412,11 @@ typedef struct
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_ARGUMENTS_OBJECT_NO_FLAGS = 0, /* unmapped arguments object */
|
||||
ECMA_ARGUMENTS_OBJECT_MAPPED = (1 << 0), /* mapped arguments object */
|
||||
ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE = (1 << 1), /* static mapped arguments object */
|
||||
ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED = (1 << 2), /* 'callee' property has been lazy initialized */
|
||||
ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED = (1 << 3), /* 'length' property has been lazy initialized */
|
||||
ECMA_ARGUMENTS_OBJECT_NO_FLAGS = 0, /* unmapped arguments object */
|
||||
ECMA_ARGUMENTS_OBJECT_MAPPED = (1 << 0), /* mapped arguments object */
|
||||
ECMA_ARGUMENTS_OBJECT_STATIC_BYTECODE = (1 << 1), /* static mapped arguments object */
|
||||
ECMA_ARGUMENTS_OBJECT_CALLEE_INITIALIZED = (1 << 2), /* 'callee' property has been lazy initialized */
|
||||
ECMA_ARGUMENTS_OBJECT_LENGTH_INITIALIZED = (1 << 3), /* 'length' property has been lazy initialized */
|
||||
ECMA_ARGUMENTS_OBJECT_ITERATOR_INITIALIZED = (1 << 4), /* 'Symbol.iterator' property has been lazy initialized */
|
||||
} ecma_arguments_object_flags_t;
|
||||
|
||||
@ -2522,4 +2488,4 @@ typedef struct
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !ECMA_GLOBALS_H */
|
||||
#endif /* !ECMA_GLOBALS_H */
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "lit-magic-strings.h"
|
||||
@ -55,8 +56,7 @@ ecma_round_high_to_uint64 (ecma_uint128_t *num_p)
|
||||
uint64_t masked_lo = num_p->lo & ~(1ULL << 63u);
|
||||
uint64_t masked_hi = num_p->hi & 0x1;
|
||||
|
||||
if ((num_p->lo >> 63u != 0)
|
||||
&& (masked_lo > 0 || masked_hi != 0))
|
||||
if ((num_p->lo >> 63u != 0) && (masked_lo > 0 || masked_hi != 0))
|
||||
{
|
||||
return (num_p->hi + 1);
|
||||
}
|
||||
@ -66,53 +66,52 @@ ecma_round_high_to_uint64 (ecma_uint128_t *num_p)
|
||||
/**
|
||||
* Check if 128-bit integer is zero
|
||||
*/
|
||||
#define ECMA_UINT128_IS_ZERO(name) \
|
||||
(name.hi == 0 && name.lo == 0)
|
||||
#define ECMA_UINT128_IS_ZERO(name) (name.hi == 0 && name.lo == 0)
|
||||
|
||||
/**
|
||||
* Left shift 128-bit integer by max 63 bits
|
||||
*/
|
||||
#define ECMA_UINT128_LEFT_SHIFT_MAX63(name, shift) \
|
||||
{ \
|
||||
name.hi = (name.hi << (shift)) | (name.lo >> (64 - (shift))); \
|
||||
name.lo <<= (shift); \
|
||||
}
|
||||
#define ECMA_UINT128_LEFT_SHIFT_MAX63(name, shift) \
|
||||
{ \
|
||||
name.hi = (name.hi << (shift)) | (name.lo >> (64 - (shift))); \
|
||||
name.lo <<= (shift); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Right shift 128-bit integer by max 63 bits
|
||||
*/
|
||||
#define ECMA_UINT128_RIGHT_SHIFT_MAX63(name, shift) \
|
||||
{ \
|
||||
name.lo = (name.lo >> (shift)) | (name.hi << (64 - (shift))); \
|
||||
name.hi >>= (shift); \
|
||||
}
|
||||
#define ECMA_UINT128_RIGHT_SHIFT_MAX63(name, shift) \
|
||||
{ \
|
||||
name.lo = (name.lo >> (shift)) | (name.hi << (64 - (shift))); \
|
||||
name.hi >>= (shift); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Add 128-bit integer
|
||||
*/
|
||||
#define ECMA_UINT128_ADD(name_add_to, name_to_add) \
|
||||
{ \
|
||||
name_add_to.hi += name_to_add.hi; \
|
||||
name_add_to.lo += name_to_add.lo; \
|
||||
if (name_add_to.lo < name_to_add.lo) \
|
||||
{ \
|
||||
name_add_to.hi++; \
|
||||
} \
|
||||
}
|
||||
{ \
|
||||
name_add_to.hi += name_to_add.hi; \
|
||||
name_add_to.lo += name_to_add.lo; \
|
||||
if (name_add_to.lo < name_to_add.lo) \
|
||||
{ \
|
||||
name_add_to.hi++; \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply 128-bit integer by 10
|
||||
*/
|
||||
#define ECMA_UINT128_MUL10(name) \
|
||||
{ \
|
||||
ECMA_UINT128_LEFT_SHIFT_MAX63 (name, 1u); \
|
||||
\
|
||||
ecma_uint128_t name ## _tmp = name; \
|
||||
\
|
||||
ECMA_UINT128_LEFT_SHIFT_MAX63 (name ## _tmp, 2u); \
|
||||
\
|
||||
ECMA_UINT128_ADD (name, name ## _tmp); \
|
||||
}
|
||||
#define ECMA_UINT128_MUL10(name) \
|
||||
{ \
|
||||
ECMA_UINT128_LEFT_SHIFT_MAX63 (name, 1u); \
|
||||
\
|
||||
ecma_uint128_t name##_tmp = name; \
|
||||
\
|
||||
ECMA_UINT128_LEFT_SHIFT_MAX63 (name##_tmp, 2u); \
|
||||
\
|
||||
ECMA_UINT128_ADD (name, name##_tmp); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide 128-bit integer by 10
|
||||
@ -129,84 +128,82 @@ ecma_round_high_to_uint64 (ecma_uint128_t *num_p)
|
||||
*
|
||||
* Q = Q3 *2^96 + Q2 *2^64 + Q1 *2^32 + Q0 *2^0 // 128-bit quotient
|
||||
*/
|
||||
#define ECMA_UINT128_DIV10(name) \
|
||||
{ \
|
||||
/* estimation of reciprocal of 10, 128 bits right of the binary point (T1 == T2) */ \
|
||||
const uint64_t tenth_l = 0x9999999aul; \
|
||||
const uint64_t tenth_m = 0x99999999ul; \
|
||||
const uint64_t tenth_h = 0x19999999ul; \
|
||||
\
|
||||
uint64_t l0 = ((uint32_t) name.lo) * tenth_l; \
|
||||
uint64_t l1 = (name.lo >> 32u) * tenth_l; \
|
||||
uint64_t l2 = ((uint32_t) name.hi) * tenth_l; \
|
||||
uint64_t l3 = (name.hi >> 32u) * tenth_l; \
|
||||
uint64_t m0 = ((uint32_t) name.lo) * tenth_m; \
|
||||
uint64_t m1 = (name.lo >> 32u) * tenth_m; \
|
||||
uint64_t m2 = ((uint32_t) name.hi) * tenth_m; \
|
||||
uint64_t m3 = (name.hi >> 32u) * tenth_m; \
|
||||
uint64_t h0 = ((uint32_t) name.lo) * tenth_h; \
|
||||
uint64_t h1 = (name.lo >> 32u) * tenth_h; \
|
||||
uint64_t h2 = ((uint32_t) name.hi) * tenth_h; \
|
||||
uint64_t h3 = (name.hi >> 32u) * tenth_h; \
|
||||
\
|
||||
uint64_t q0 = l0 >> 32u; \
|
||||
q0 += (uint32_t) l1; \
|
||||
q0 += (uint32_t) m0; \
|
||||
\
|
||||
q0 >>= 32u; \
|
||||
q0 += l1 >> 32u; \
|
||||
q0 += m0 >> 32u; \
|
||||
q0 += (uint32_t) l2; \
|
||||
q0 += (uint32_t) m1; \
|
||||
q0 += (uint32_t) m0; \
|
||||
\
|
||||
q0 >>= 32u; \
|
||||
q0 += l2 >> 32u; \
|
||||
q0 += m1 >> 32u; \
|
||||
q0 += m0 >> 32u; \
|
||||
q0 += (uint32_t) l3; \
|
||||
q0 += (uint32_t) m2; \
|
||||
q0 += (uint32_t) m1; \
|
||||
q0 += (uint32_t) h0; \
|
||||
\
|
||||
q0 >>=32u; \
|
||||
q0 += l3 >> 32u; \
|
||||
q0 += m2 >> 32u; \
|
||||
q0 += m1 >> 32u; \
|
||||
q0 += h0 >> 32u; \
|
||||
q0 += (uint32_t) m3; \
|
||||
q0 += (uint32_t) m2; \
|
||||
q0 += (uint32_t) h1; \
|
||||
\
|
||||
uint64_t q1 = q0 >> 32u; \
|
||||
q1 += m3 >> 32u; \
|
||||
q1 += m2 >> 32u; \
|
||||
q1 += h1 >> 32u; \
|
||||
q1 += (uint32_t) m3; \
|
||||
q1 += (uint32_t) h2; \
|
||||
\
|
||||
uint64_t q32 = q1 >> 32u; \
|
||||
q32 += m3 >> 32u; \
|
||||
q32 += h2 >> 32u; \
|
||||
q32 += h3; \
|
||||
\
|
||||
name.lo = (q1 << 32u) | ((uint32_t) q0); \
|
||||
name.hi = q32; \
|
||||
}
|
||||
#define ECMA_UINT128_DIV10(name) \
|
||||
{ \
|
||||
/* estimation of reciprocal of 10, 128 bits right of the binary point (T1 == T2) */ \
|
||||
const uint64_t tenth_l = 0x9999999aul; \
|
||||
const uint64_t tenth_m = 0x99999999ul; \
|
||||
const uint64_t tenth_h = 0x19999999ul; \
|
||||
\
|
||||
uint64_t l0 = ((uint32_t) name.lo) * tenth_l; \
|
||||
uint64_t l1 = (name.lo >> 32u) * tenth_l; \
|
||||
uint64_t l2 = ((uint32_t) name.hi) * tenth_l; \
|
||||
uint64_t l3 = (name.hi >> 32u) * tenth_l; \
|
||||
uint64_t m0 = ((uint32_t) name.lo) * tenth_m; \
|
||||
uint64_t m1 = (name.lo >> 32u) * tenth_m; \
|
||||
uint64_t m2 = ((uint32_t) name.hi) * tenth_m; \
|
||||
uint64_t m3 = (name.hi >> 32u) * tenth_m; \
|
||||
uint64_t h0 = ((uint32_t) name.lo) * tenth_h; \
|
||||
uint64_t h1 = (name.lo >> 32u) * tenth_h; \
|
||||
uint64_t h2 = ((uint32_t) name.hi) * tenth_h; \
|
||||
uint64_t h3 = (name.hi >> 32u) * tenth_h; \
|
||||
\
|
||||
uint64_t q0 = l0 >> 32u; \
|
||||
q0 += (uint32_t) l1; \
|
||||
q0 += (uint32_t) m0; \
|
||||
\
|
||||
q0 >>= 32u; \
|
||||
q0 += l1 >> 32u; \
|
||||
q0 += m0 >> 32u; \
|
||||
q0 += (uint32_t) l2; \
|
||||
q0 += (uint32_t) m1; \
|
||||
q0 += (uint32_t) m0; \
|
||||
\
|
||||
q0 >>= 32u; \
|
||||
q0 += l2 >> 32u; \
|
||||
q0 += m1 >> 32u; \
|
||||
q0 += m0 >> 32u; \
|
||||
q0 += (uint32_t) l3; \
|
||||
q0 += (uint32_t) m2; \
|
||||
q0 += (uint32_t) m1; \
|
||||
q0 += (uint32_t) h0; \
|
||||
\
|
||||
q0 >>= 32u; \
|
||||
q0 += l3 >> 32u; \
|
||||
q0 += m2 >> 32u; \
|
||||
q0 += m1 >> 32u; \
|
||||
q0 += h0 >> 32u; \
|
||||
q0 += (uint32_t) m3; \
|
||||
q0 += (uint32_t) m2; \
|
||||
q0 += (uint32_t) h1; \
|
||||
\
|
||||
uint64_t q1 = q0 >> 32u; \
|
||||
q1 += m3 >> 32u; \
|
||||
q1 += m2 >> 32u; \
|
||||
q1 += h1 >> 32u; \
|
||||
q1 += (uint32_t) m3; \
|
||||
q1 += (uint32_t) h2; \
|
||||
\
|
||||
uint64_t q32 = q1 >> 32u; \
|
||||
q32 += m3 >> 32u; \
|
||||
q32 += h2 >> 32u; \
|
||||
q32 += h3; \
|
||||
\
|
||||
name.lo = (q1 << 32u) | ((uint32_t) q0); \
|
||||
name.hi = q32; \
|
||||
}
|
||||
|
||||
#if defined (__GNUC__) || defined (__clang__)
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
|
||||
/**
|
||||
* Count leading zeros in the topmost 64 bits of a 128-bit integer.
|
||||
*/
|
||||
#define ECMA_UINT128_CLZ_MAX63(name) \
|
||||
__builtin_clzll (name.hi)
|
||||
#define ECMA_UINT128_CLZ_MAX63(name) __builtin_clzll (name.hi)
|
||||
|
||||
/**
|
||||
* Count leading zeros in the topmost 4 bits of a 128-bit integer.
|
||||
*/
|
||||
#define ECMA_UINT128_CLZ_MAX4(name) \
|
||||
__builtin_clzll (name.hi)
|
||||
#define ECMA_UINT128_CLZ_MAX4(name) __builtin_clzll (name.hi)
|
||||
|
||||
#else /* !__GNUC__ && !__clang__ */
|
||||
|
||||
@ -238,14 +235,12 @@ static const uint8_t ecma_uint4_clz[] = { 4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0,
|
||||
/**
|
||||
* Count leading zeros in the topmost 64 bits of a 128-bit integer.
|
||||
*/
|
||||
#define ECMA_UINT128_CLZ_MAX63(name) \
|
||||
ecma_uint64_clz (name.hi)
|
||||
#define ECMA_UINT128_CLZ_MAX63(name) ecma_uint64_clz (name.hi)
|
||||
|
||||
/**
|
||||
* Count leading zeros in the topmost 4 bits of a 128-bit integer.
|
||||
*/
|
||||
#define ECMA_UINT128_CLZ_MAX4(name) \
|
||||
ecma_uint4_clz[name.hi >> 60]
|
||||
#define ECMA_UINT128_CLZ_MAX4(name) ecma_uint4_clz[name.hi >> 60]
|
||||
|
||||
#endif /* __GNUC__ || __clang__ */
|
||||
|
||||
@ -308,7 +303,7 @@ ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 st
|
||||
{
|
||||
lit_code_point_t upper_limit = LIT_CHAR_0 + radix;
|
||||
|
||||
for (const lit_utf8_byte_t * iter_p = str_p; iter_p <= end_p; iter_p++)
|
||||
for (const lit_utf8_byte_t *iter_p = str_p; iter_p <= end_p; iter_p++)
|
||||
{
|
||||
int32_t digit_value;
|
||||
|
||||
@ -328,22 +323,19 @@ ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 st
|
||||
}
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
for (const lit_utf8_byte_t * iter_p = str_p; iter_p <= end_p; iter_p++)
|
||||
for (const lit_utf8_byte_t *iter_p = str_p; iter_p <= end_p; iter_p++)
|
||||
{
|
||||
int32_t digit_value;
|
||||
|
||||
if (*iter_p >= LIT_CHAR_0
|
||||
&& *iter_p <= LIT_CHAR_9)
|
||||
if (*iter_p >= LIT_CHAR_0 && *iter_p <= LIT_CHAR_9)
|
||||
{
|
||||
digit_value = (*iter_p - LIT_CHAR_0);
|
||||
}
|
||||
else if (*iter_p >= LIT_CHAR_LOWERCASE_A
|
||||
&& *iter_p <= LIT_CHAR_LOWERCASE_F)
|
||||
else if (*iter_p >= LIT_CHAR_LOWERCASE_A && *iter_p <= LIT_CHAR_LOWERCASE_F)
|
||||
{
|
||||
digit_value = 10 + (*iter_p - LIT_CHAR_LOWERCASE_A);
|
||||
}
|
||||
else if (*iter_p >= LIT_CHAR_UPPERCASE_A
|
||||
&& *iter_p <= LIT_CHAR_UPPERCASE_F)
|
||||
else if (*iter_p >= LIT_CHAR_UPPERCASE_A && *iter_p <= LIT_CHAR_UPPERCASE_F)
|
||||
{
|
||||
digit_value = 10 + (*iter_p - LIT_CHAR_UPPERCASE_A);
|
||||
}
|
||||
@ -393,20 +385,19 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
return ECMA_NUMBER_ZERO;
|
||||
}
|
||||
|
||||
if (end_p >= str_p + 2
|
||||
&& str_p[0] == LIT_CHAR_0)
|
||||
if (end_p >= str_p + 2 && str_p[0] == LIT_CHAR_0)
|
||||
{
|
||||
switch (LEXER_TO_ASCII_LOWERCASE (str_p[1]))
|
||||
{
|
||||
case LIT_CHAR_LOWERCASE_X :
|
||||
case LIT_CHAR_LOWERCASE_X:
|
||||
{
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 16 | options);
|
||||
}
|
||||
case LIT_CHAR_LOWERCASE_O :
|
||||
case LIT_CHAR_LOWERCASE_O:
|
||||
{
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 8 | options);
|
||||
}
|
||||
case LIT_CHAR_LOWERCASE_B :
|
||||
case LIT_CHAR_LOWERCASE_B:
|
||||
{
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 2 | options);
|
||||
}
|
||||
@ -455,8 +446,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
{
|
||||
int32_t digit_value;
|
||||
|
||||
if (*str_p >= LIT_CHAR_0
|
||||
&& *str_p <= LIT_CHAR_9)
|
||||
if (*str_p >= LIT_CHAR_0 && *str_p <= LIT_CHAR_9)
|
||||
{
|
||||
digit_seen = true;
|
||||
digit_value = (*str_p - LIT_CHAR_0);
|
||||
@ -489,8 +479,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
str_p++;
|
||||
}
|
||||
|
||||
if (str_p <= end_p
|
||||
&& *str_p == LIT_CHAR_DOT)
|
||||
if (str_p <= end_p && *str_p == LIT_CHAR_DOT)
|
||||
{
|
||||
str_p++;
|
||||
|
||||
@ -504,8 +493,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
{
|
||||
int32_t digit_value;
|
||||
|
||||
if (*str_p >= LIT_CHAR_0
|
||||
&& *str_p <= LIT_CHAR_9)
|
||||
if (*str_p >= LIT_CHAR_0 && *str_p <= LIT_CHAR_9)
|
||||
{
|
||||
digit_seen = true;
|
||||
digit_value = (*str_p - LIT_CHAR_0);
|
||||
@ -539,9 +527,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
int32_t e_in_lit = 0;
|
||||
bool e_in_lit_sign = false;
|
||||
|
||||
if (str_p <= end_p
|
||||
&& (*str_p == LIT_CHAR_LOWERCASE_E
|
||||
|| *str_p == LIT_CHAR_UPPERCASE_E))
|
||||
if (str_p <= end_p && (*str_p == LIT_CHAR_LOWERCASE_E || *str_p == LIT_CHAR_UPPERCASE_E))
|
||||
{
|
||||
str_p++;
|
||||
|
||||
@ -569,8 +555,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
{
|
||||
int32_t digit_value;
|
||||
|
||||
if (*str_p >= LIT_CHAR_0
|
||||
&& *str_p <= LIT_CHAR_9)
|
||||
if (*str_p >= LIT_CHAR_0 && *str_p <= LIT_CHAR_9)
|
||||
{
|
||||
digit_value = (*str_p - LIT_CHAR_0);
|
||||
}
|
||||
@ -587,7 +572,7 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
}
|
||||
|
||||
e_in_lit = e_in_lit * 10 + digit_value;
|
||||
int32_t e_check = e + (int32_t) digits - 1 + (e_in_lit_sign ? -e_in_lit : e_in_lit);
|
||||
int32_t e_check = e + (int32_t) digits - 1 + (e_in_lit_sign ? -e_in_lit : e_in_lit);
|
||||
|
||||
if (e_check > NUMBER_MAX_DECIMAL_EXPONENT)
|
||||
{
|
||||
@ -764,8 +749,7 @@ ecma_uint32_to_utf8_string (uint32_t value, /**< value to convert */
|
||||
buf_p--;
|
||||
*buf_p = (lit_utf8_byte_t) ((value % 10) + LIT_CHAR_0);
|
||||
value /= 10;
|
||||
}
|
||||
while (value != 0);
|
||||
} while (value != 0);
|
||||
|
||||
JERRY_ASSERT (buf_p >= out_buffer_p);
|
||||
|
||||
@ -807,8 +791,7 @@ ecma_number_to_uint32 (ecma_number_t num) /**< ecma-number */
|
||||
|
||||
if (abs_num >= num_2_pow_32)
|
||||
{
|
||||
num_in_uint32_range = ecma_number_calc_remainder (abs_num,
|
||||
num_2_pow_32);
|
||||
num_in_uint32_range = ecma_number_calc_remainder (abs_num, num_2_pow_32);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -822,8 +805,7 @@ ecma_number_to_uint32 (ecma_number_t num) /**< ecma-number */
|
||||
const uint32_t ret = sign ? -uint32_num : uint32_num;
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
if (sign
|
||||
&& uint32_num != 0)
|
||||
if (sign && uint32_num != 0)
|
||||
{
|
||||
JERRY_ASSERT (ret == uint64_2_pow_32 - uint32_num);
|
||||
}
|
||||
@ -885,16 +867,16 @@ ecma_number_to_int32 (ecma_number_t num) /**< ecma-number */
|
||||
} /* ecma_number_to_int32 */
|
||||
|
||||
/**
|
||||
* Perform conversion of ecma-number to decimal representation with decimal exponent.
|
||||
*
|
||||
* Note:
|
||||
* The calculated values correspond to s, n, k parameters in ECMA-262 v5, 9.8.1, item 5:
|
||||
* - parameter out_digits_p corresponds to s, the digits of the number;
|
||||
* - parameter out_decimal_exp_p corresponds to n, the decimal exponent;
|
||||
* - return value corresponds to k, the number of digits.
|
||||
*
|
||||
* @return the number of digits
|
||||
*/
|
||||
* Perform conversion of ecma-number to decimal representation with decimal exponent.
|
||||
*
|
||||
* Note:
|
||||
* The calculated values correspond to s, n, k parameters in ECMA-262 v5, 9.8.1, item 5:
|
||||
* - parameter out_digits_p corresponds to s, the digits of the number;
|
||||
* - parameter out_decimal_exp_p corresponds to n, the decimal exponent;
|
||||
* - return value corresponds to k, the number of digits.
|
||||
*
|
||||
* @return the number of digits
|
||||
*/
|
||||
lit_utf8_size_t
|
||||
ecma_number_to_decimal (ecma_number_t num, /**< ecma-number */
|
||||
lit_utf8_byte_t *out_digits_p, /**< [out] buffer to fill with digits */
|
||||
@ -951,7 +933,8 @@ ecma_number_to_utf8_string (ecma_number_t num, /**< ecma-number */
|
||||
if (ecma_number_is_infinity (num))
|
||||
{
|
||||
/* 4. */
|
||||
dst_p = lit_copy_magic_string_to_buffer (LIT_MAGIC_STRING_INFINITY_UL, dst_p,
|
||||
dst_p = lit_copy_magic_string_to_buffer (LIT_MAGIC_STRING_INFINITY_UL,
|
||||
dst_p,
|
||||
(lit_utf8_size_t) (buffer_p + buffer_size - dst_p));
|
||||
JERRY_ASSERT (dst_p <= buffer_p + buffer_size);
|
||||
return (lit_utf8_size_t) (dst_p - buffer_p);
|
||||
|
||||
@ -16,9 +16,9 @@
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-objects-general.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects-general.h"
|
||||
#include "ecma-objects.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@ -185,8 +185,7 @@ ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property
|
||||
|
||||
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);
|
||||
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)
|
||||
{
|
||||
@ -215,8 +214,7 @@ ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property
|
||||
}
|
||||
|
||||
item_p = item_p->next_p;
|
||||
}
|
||||
while (item_p != NULL);
|
||||
} while (item_p != NULL);
|
||||
|
||||
return NULL;
|
||||
} /* ecma_get_native_pointer_value */
|
||||
@ -259,8 +257,7 @@ ecma_delete_native_pointer_property (ecma_object_t *obj_p, /**< object to delete
|
||||
|
||||
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);
|
||||
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)
|
||||
{
|
||||
@ -326,8 +323,7 @@ ecma_delete_native_pointer_property (ecma_object_t *obj_p, /**< object to delete
|
||||
|
||||
prev_p = item_p;
|
||||
item_p = item_p->next_p;
|
||||
}
|
||||
while (item_p != NULL);
|
||||
} while (item_p != NULL);
|
||||
|
||||
return false;
|
||||
} /* ecma_delete_native_pointer_property */
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "ecma-conversion.h"
|
||||
|
||||
#include "lit-char-helpers.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@ -28,20 +29,17 @@
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_value_t) == sizeof (ecma_integer_value_t),
|
||||
size_of_ecma_value_t_must_be_equal_to_the_size_of_ecma_integer_value_t);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_DIRECT_SHIFT == ECMA_VALUE_SHIFT + 1,
|
||||
currently_directly_encoded_values_has_one_extra_flag);
|
||||
JERRY_STATIC_ASSERT (ECMA_DIRECT_SHIFT == ECMA_VALUE_SHIFT + 1, currently_directly_encoded_values_has_one_extra_flag);
|
||||
|
||||
JERRY_STATIC_ASSERT (((1 << (ECMA_DIRECT_SHIFT - 1)) | ECMA_TYPE_DIRECT) == ECMA_DIRECT_TYPE_SIMPLE_VALUE,
|
||||
currently_directly_encoded_values_start_after_direct_type_simple_value);
|
||||
/**
|
||||
* Position of the sign bit in ecma-numbers
|
||||
*/
|
||||
#define ECMA_NUMBER_SIGN_POS (ECMA_NUMBER_FRACTION_WIDTH + \
|
||||
ECMA_NUMBER_BIASED_EXP_WIDTH)
|
||||
#define ECMA_NUMBER_SIGN_POS (ECMA_NUMBER_FRACTION_WIDTH + ECMA_NUMBER_BIASED_EXP_WIDTH)
|
||||
|
||||
#if !JERRY_NUMBER_TYPE_FLOAT64
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint32_t),
|
||||
size_of_ecma_number_t_must_be_equal_to_4_bytes);
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint32_t), size_of_ecma_number_t_must_be_equal_to_4_bytes);
|
||||
|
||||
/**
|
||||
* Packing sign, fraction and biased exponent to ecma-number
|
||||
@ -56,9 +54,8 @@ ecma_number_pack (bool sign, /**< sign */
|
||||
JERRY_ASSERT ((biased_exp & ~((1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1)) == 0);
|
||||
JERRY_ASSERT ((fraction & ~((1ull << ECMA_NUMBER_FRACTION_WIDTH) - 1)) == 0);
|
||||
|
||||
uint32_t packed_value = (((sign ? 1u : 0u) << ECMA_NUMBER_SIGN_POS) |
|
||||
(biased_exp << ECMA_NUMBER_FRACTION_WIDTH) |
|
||||
((uint32_t) fraction));
|
||||
uint32_t packed_value =
|
||||
(((sign ? 1u : 0u) << ECMA_NUMBER_SIGN_POS) | (biased_exp << ECMA_NUMBER_FRACTION_WIDTH) | ((uint32_t) fraction));
|
||||
|
||||
ecma_number_accessor_t u;
|
||||
u.as_uint32_t = packed_value;
|
||||
@ -103,8 +100,7 @@ ecma_number_unpack (ecma_number_t num, /**< ecma-number */
|
||||
const int32_t ecma_number_exponent_bias = 127;
|
||||
|
||||
#elif JERRY_NUMBER_TYPE_FLOAT64
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint64_t),
|
||||
size_of_ecma_number_t_must_be_equal_to_8_bytes);
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_number_t) == sizeof (uint64_t), size_of_ecma_number_t_must_be_equal_to_8_bytes);
|
||||
|
||||
/**
|
||||
* Packing sign, fraction and biased exponent to ecma-number
|
||||
@ -116,9 +112,8 @@ ecma_number_pack (bool sign, /**< sign */
|
||||
uint32_t biased_exp, /**< biased exponent */
|
||||
uint64_t fraction) /**< fraction */
|
||||
{
|
||||
uint64_t packed_value = (((sign ? 1ull : 0ull) << ECMA_NUMBER_SIGN_POS) |
|
||||
(((uint64_t) biased_exp) << ECMA_NUMBER_FRACTION_WIDTH) |
|
||||
fraction);
|
||||
uint64_t packed_value = (((sign ? 1ull : 0ull) << ECMA_NUMBER_SIGN_POS)
|
||||
| (((uint64_t) biased_exp) << ECMA_NUMBER_FRACTION_WIDTH) | fraction);
|
||||
|
||||
JERRY_ASSERT ((biased_exp & ~((1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1)) == 0);
|
||||
JERRY_ASSERT ((fraction & ~((1ull << ECMA_NUMBER_FRACTION_WIDTH) - 1)) == 0);
|
||||
@ -228,9 +223,8 @@ ecma_number_is_nan (ecma_number_t num) /**< ecma-number */
|
||||
uint32_t biased_exp = ecma_number_get_biased_exponent_field (num);
|
||||
uint64_t fraction = ecma_number_get_fraction_field (num);
|
||||
|
||||
/* IEEE-754 2008, 3.4, a */
|
||||
bool is_nan_ieee754 = ((biased_exp == (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1)
|
||||
&& (fraction != 0));
|
||||
/* IEEE-754 2008, 3.4, a */
|
||||
bool is_nan_ieee754 = ((biased_exp == (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1) && (fraction != 0));
|
||||
|
||||
JERRY_ASSERT (is_nan == is_nan_ieee754);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
@ -251,7 +245,7 @@ ecma_number_make_nan (void)
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
f.as_uint64_t = 0x7ff8000000000000ull; /* double QNaN, same as the C99 nan("") returns. */
|
||||
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
f.as_uint32_t = 0x7fc00000u; /* float QNaN, same as the C99 nanf("") returns. */
|
||||
f.as_uint32_t = 0x7fc00000u; /* float QNaN, same as the C99 nanf("") returns. */
|
||||
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
|
||||
return f.as_ecma_number_t;
|
||||
} /* ecma_number_make_nan */
|
||||
@ -304,8 +298,8 @@ ecma_number_is_zero (ecma_number_t num) /**< ecma-number */
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
/* IEEE-754 2008, 3.4, e */
|
||||
bool is_zero_ieee754 = (ecma_number_get_fraction_field (num) == 0
|
||||
&& ecma_number_get_biased_exponent_field (num) == 0);
|
||||
bool is_zero_ieee754 =
|
||||
(ecma_number_get_fraction_field (num) == 0 && ecma_number_get_biased_exponent_field (num) == 0);
|
||||
|
||||
JERRY_ASSERT (is_zero == is_zero_ieee754);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
@ -327,8 +321,7 @@ ecma_number_is_infinity (ecma_number_t num) /**< ecma-number */
|
||||
uint64_t fraction = ecma_number_get_fraction_field (num);
|
||||
|
||||
/* IEEE-754 2008, 3.4, b */
|
||||
return ((biased_exp == (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1)
|
||||
&& (fraction == 0));
|
||||
return ((biased_exp == (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1) && (fraction == 0));
|
||||
} /* ecma_number_is_infinity */
|
||||
|
||||
/**
|
||||
@ -340,11 +333,11 @@ ecma_number_is_infinity (ecma_number_t num) /**< ecma-number */
|
||||
extern inline bool JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_number_is_finite (ecma_number_t num) /**< ecma-number */
|
||||
{
|
||||
#if defined (__GNUC__) || defined (__clang__)
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
return __builtin_isfinite (num);
|
||||
#elif defined (_WIN32)
|
||||
#elif defined(_WIN32)
|
||||
return isfinite (num);
|
||||
#else
|
||||
#else /* !(defined(__GNUC__) || defined(__clang__) || defined(_WIN32)) */
|
||||
return !ecma_number_is_nan (num) && !ecma_number_is_infinity (num);
|
||||
#endif /* defined (__GNUC__) || defined (__clang__) */
|
||||
} /* ecma_number_is_finite */
|
||||
@ -422,9 +415,7 @@ ecma_number_make_normal_positive_from_fraction_and_exponent (uint64_t fraction,
|
||||
JERRY_ASSERT ((fraction & ~((1ull << (ECMA_NUMBER_FRACTION_WIDTH + 1)) - 1)) == 0);
|
||||
JERRY_ASSERT ((fraction & (1ull << ECMA_NUMBER_FRACTION_WIDTH)) != 0);
|
||||
|
||||
return ecma_number_pack (false,
|
||||
biased_exp,
|
||||
fraction & ~(1ull << ECMA_NUMBER_FRACTION_WIDTH));
|
||||
return ecma_number_pack (false, biased_exp, fraction & ~(1ull << ECMA_NUMBER_FRACTION_WIDTH));
|
||||
} /* ecma_number_make_normal_positive_from_fraction_and_exponent */
|
||||
|
||||
/**
|
||||
@ -463,8 +454,7 @@ ecma_number_make_from_sign_mantissa_and_exponent (bool sign, /**< true - for neg
|
||||
}
|
||||
|
||||
/* Normalizing mantissa */
|
||||
while (mantissa != 0
|
||||
&& ((mantissa & (1ull << ECMA_NUMBER_FRACTION_WIDTH)) == 0))
|
||||
while (mantissa != 0 && ((mantissa & (1ull << ECMA_NUMBER_FRACTION_WIDTH)) == 0))
|
||||
{
|
||||
exponent--;
|
||||
mantissa <<= 1;
|
||||
@ -507,9 +497,7 @@ ecma_number_make_from_sign_mantissa_and_exponent (bool sign, /**< true - for neg
|
||||
JERRY_ASSERT (biased_exp < (1u << ECMA_NUMBER_BIASED_EXP_WIDTH) - 1);
|
||||
JERRY_ASSERT ((mantissa & ~((1ull << ECMA_NUMBER_FRACTION_WIDTH) - 1)) == 0);
|
||||
|
||||
return ecma_number_pack (sign,
|
||||
biased_exp,
|
||||
mantissa);
|
||||
return ecma_number_pack (sign, biased_exp, mantissa);
|
||||
} /* ecma_number_make_from_sign_mantissa_and_exponent */
|
||||
|
||||
/**
|
||||
@ -542,9 +530,7 @@ ecma_number_get_prev (ecma_number_t num) /**< ecma-number */
|
||||
fraction--;
|
||||
}
|
||||
|
||||
return ecma_number_pack (false,
|
||||
biased_exp,
|
||||
fraction);
|
||||
return ecma_number_pack (false, biased_exp, fraction);
|
||||
} /* ecma_number_get_prev */
|
||||
|
||||
/**
|
||||
@ -581,9 +567,7 @@ ecma_number_get_next (ecma_number_t num) /**< ecma-number */
|
||||
|
||||
fraction &= ~(1ull << ECMA_NUMBER_FRACTION_WIDTH);
|
||||
|
||||
return ecma_number_pack (false,
|
||||
biased_exp,
|
||||
fraction);
|
||||
return ecma_number_pack (false, biased_exp, fraction);
|
||||
} /* ecma_number_get_next */
|
||||
|
||||
/**
|
||||
@ -609,8 +593,7 @@ ecma_number_trunc (ecma_number_t num) /**< ecma-number */
|
||||
{
|
||||
fraction &= ~((1ull << (dot_shift - exponent)) - 1);
|
||||
|
||||
ecma_number_t tmp = ecma_number_make_normal_positive_from_fraction_and_exponent (fraction,
|
||||
exponent);
|
||||
ecma_number_t tmp = ecma_number_make_normal_positive_from_fraction_and_exponent (fraction, exponent);
|
||||
if (sign)
|
||||
{
|
||||
return -tmp;
|
||||
@ -639,18 +622,15 @@ ecma_number_t
|
||||
ecma_number_calc_remainder (ecma_number_t left_num, /**< left operand */
|
||||
ecma_number_t right_num) /**< right operand */
|
||||
{
|
||||
JERRY_ASSERT (!ecma_number_is_nan (left_num)
|
||||
&& !ecma_number_is_zero (left_num)
|
||||
JERRY_ASSERT (!ecma_number_is_nan (left_num) && !ecma_number_is_zero (left_num)
|
||||
&& !ecma_number_is_infinity (left_num));
|
||||
JERRY_ASSERT (!ecma_number_is_nan (right_num)
|
||||
&& !ecma_number_is_zero (right_num)
|
||||
JERRY_ASSERT (!ecma_number_is_nan (right_num) && !ecma_number_is_zero (right_num)
|
||||
&& !ecma_number_is_infinity (right_num));
|
||||
|
||||
const ecma_number_t q = ecma_number_trunc (left_num / right_num);
|
||||
ecma_number_t r = left_num - right_num * q;
|
||||
|
||||
if (ecma_number_is_zero (r)
|
||||
&& ecma_number_is_negative (left_num))
|
||||
if (ecma_number_is_zero (r) && ecma_number_is_negative (left_num))
|
||||
{
|
||||
r = -r;
|
||||
}
|
||||
@ -667,8 +647,7 @@ ecma_number_t
|
||||
ecma_number_pow (ecma_number_t x, /**< left operand */
|
||||
ecma_number_t y) /**< right operand */
|
||||
{
|
||||
if (ecma_number_is_nan (y) ||
|
||||
(ecma_number_is_infinity (y) && (x == 1.0 || x == -1.0)))
|
||||
if (ecma_number_is_nan (y) || (ecma_number_is_infinity (y) && (x == 1.0 || x == -1.0)))
|
||||
{
|
||||
/* Handle differences between ES5.1 and ISO C standards for pow. */
|
||||
return ecma_number_make_nan ();
|
||||
@ -692,7 +671,7 @@ extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_integer_multiply (ecma_integer_value_t left_integer, /**< left operand */
|
||||
ecma_integer_value_t right_integer) /**< right operand */
|
||||
{
|
||||
#if defined (__GNUC__) || defined (__clang__)
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
/* Check if left_integer is power of 2 */
|
||||
if (JERRY_UNLIKELY ((left_integer & (left_integer - 1)) == 0))
|
||||
{
|
||||
@ -720,16 +699,16 @@ ecma_integer_multiply (ecma_integer_value_t left_integer, /**< left operand */
|
||||
ecma_value_t
|
||||
ecma_number_parse_int (const lit_utf8_byte_t *string_buff, /**< routine's first argument's
|
||||
* string buffer */
|
||||
lit_utf8_size_t string_buff_size, /**< routine's first argument's
|
||||
* string buffer's size */
|
||||
ecma_value_t radix) /**< routine's second argument */
|
||||
lit_utf8_size_t string_buff_size, /**< routine's first argument's
|
||||
* string buffer's size */
|
||||
ecma_value_t radix) /**< routine's second argument */
|
||||
{
|
||||
if (string_buff_size == 0)
|
||||
{
|
||||
return ecma_make_nan_value ();
|
||||
}
|
||||
|
||||
/* 2. Remove leading whitespace. */
|
||||
/* 2. Remove leading whitespace. */
|
||||
|
||||
const lit_utf8_byte_t *string_end_p = string_buff + string_buff_size;
|
||||
const lit_utf8_byte_t *start_p = ecma_string_trim_front (string_buff, string_end_p);
|
||||
@ -796,9 +775,7 @@ ecma_number_parse_int (const lit_utf8_byte_t *string_buff, /**< routine's first
|
||||
}
|
||||
|
||||
/* 10. */
|
||||
if (strip_prefix
|
||||
&& ((end_p - start_p) >= 2)
|
||||
&& (current == LIT_CHAR_0))
|
||||
if (strip_prefix && ((end_p - start_p) >= 2) && (current == LIT_CHAR_0))
|
||||
{
|
||||
ecma_char_t next = *string_curr_p;
|
||||
if (next == LIT_CHAR_LOWERCASE_X || next == LIT_CHAR_UPPERCASE_X)
|
||||
@ -896,8 +873,8 @@ ecma_number_parse_int (const lit_utf8_byte_t *string_buff, /**< routine's first
|
||||
ecma_value_t
|
||||
ecma_number_parse_float (const lit_utf8_byte_t *string_buff, /**< routine's first argument's
|
||||
* string buffer */
|
||||
lit_utf8_size_t string_buff_size) /**< routine's first argument's
|
||||
* string buffer's size */
|
||||
lit_utf8_size_t string_buff_size) /**< routine's first argument's
|
||||
* string buffer's size */
|
||||
{
|
||||
if (string_buff_size == 0)
|
||||
{
|
||||
@ -937,8 +914,7 @@ ecma_number_parse_float (const lit_utf8_byte_t *string_buff, /**< routine's firs
|
||||
/* The input string should be at least the length of "Infinity" to be correctly processed as
|
||||
* the infinity value.
|
||||
*/
|
||||
if ((str_end_p - str_curr_p) >= (int) infinity_length
|
||||
&& memcmp (infinity_str_p, str_curr_p, infinity_length) == 0)
|
||||
if ((str_end_p - str_curr_p) >= (int) infinity_length && memcmp (infinity_str_p, str_curr_p, infinity_length) == 0)
|
||||
{
|
||||
/* String matched Infinity. */
|
||||
return ecma_make_number_value (ecma_number_make_infinity (sign));
|
||||
@ -1021,15 +997,13 @@ ecma_number_parse_float (const lit_utf8_byte_t *string_buff, /**< routine's firs
|
||||
}
|
||||
|
||||
/* Check exponent. */
|
||||
if ((current == LIT_CHAR_LOWERCASE_E || current == LIT_CHAR_UPPERCASE_E)
|
||||
&& (has_whole_part || has_fraction_part)
|
||||
if ((current == LIT_CHAR_LOWERCASE_E || current == LIT_CHAR_UPPERCASE_E) && (has_whole_part || has_fraction_part)
|
||||
&& str_curr_p < str_end_p)
|
||||
{
|
||||
current = *str_curr_p++;
|
||||
|
||||
/* Check sign of exponent. */
|
||||
if ((current == LIT_CHAR_PLUS || current == LIT_CHAR_MINUS)
|
||||
&& str_curr_p < str_end_p)
|
||||
if ((current == LIT_CHAR_PLUS || current == LIT_CHAR_MINUS) && str_curr_p < str_end_p)
|
||||
{
|
||||
current = *str_curr_p++;
|
||||
}
|
||||
|
||||
@ -19,9 +19,10 @@
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "jrt.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "lit-magic-strings.h"
|
||||
|
||||
@ -41,8 +42,7 @@ JERRY_STATIC_ASSERT ((ECMA_STRING_MAX_REF | ECMA_STRING_CONTAINER_MASK | ECMA_ST
|
||||
JERRY_STATIC_ASSERT (ECMA_STRING_NOT_ARRAY_INDEX == UINT32_MAX,
|
||||
ecma_string_not_array_index_must_be_equal_to_uint32_max);
|
||||
|
||||
JERRY_STATIC_ASSERT ((ECMA_TYPE_DIRECT_STRING & 0x1) != 0,
|
||||
ecma_type_direct_string_must_be_odd_number);
|
||||
JERRY_STATIC_ASSERT ((ECMA_TYPE_DIRECT_STRING & 0x1) != 0, ecma_type_direct_string_must_be_odd_number);
|
||||
|
||||
JERRY_STATIC_ASSERT (LIT_MAGIC_STRING__COUNT <= ECMA_DIRECT_STRING_MAX_IMM,
|
||||
all_magic_strings_must_be_encoded_as_direct_string);
|
||||
@ -96,8 +96,7 @@ ecma_string_to_array_index (const lit_utf8_byte_t *string_p, /**< utf-8 string *
|
||||
}
|
||||
|
||||
index = (index * 10) + (uint32_t) (*string_p++ - LIT_CHAR_0);
|
||||
}
|
||||
while (string_p < string_end_p);
|
||||
} while (string_p < string_end_p);
|
||||
|
||||
if (string_size < ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32)
|
||||
{
|
||||
@ -107,9 +106,7 @@ ecma_string_to_array_index (const lit_utf8_byte_t *string_p, /**< utf-8 string *
|
||||
|
||||
/* Overflow must be checked as well when size is
|
||||
* equal to ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32. */
|
||||
if (*string_p > LIT_CHAR_9
|
||||
|| *string_p < LIT_CHAR_0
|
||||
|| index > (UINT32_MAX / 10)
|
||||
if (*string_p > LIT_CHAR_9 || *string_p < LIT_CHAR_0 || index > (UINT32_MAX / 10)
|
||||
|| (index == (UINT32_MAX / 10) && *string_p > LIT_CHAR_5))
|
||||
{
|
||||
return false;
|
||||
@ -241,8 +238,7 @@ ecma_prop_name_is_symbol (ecma_string_t *string_p) /**< ecma-string */
|
||||
{
|
||||
JERRY_ASSERT (string_p != NULL);
|
||||
|
||||
return (!ECMA_IS_DIRECT_STRING (string_p)
|
||||
&& ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_SYMBOL);
|
||||
return (!ECMA_IS_DIRECT_STRING (string_p) && ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_SYMBOL);
|
||||
} /* ecma_prop_name_is_symbol */
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
@ -251,7 +247,7 @@ ecma_prop_name_is_symbol (ecma_string_t *string_p) /**< ecma-string */
|
||||
*
|
||||
* @return pointer to ecma-string descriptor
|
||||
*/
|
||||
static inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
static inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_new_ecma_string_from_utf8_buffer (lit_utf8_size_t length, /**< length of the buffer */
|
||||
lit_utf8_size_t size, /**< size of the buffer */
|
||||
lit_utf8_byte_t **data_p) /**< [out] pointer to the start of the string buffer */
|
||||
@ -382,9 +378,8 @@ ecma_new_ecma_string_from_utf8 (const lit_utf8_byte_t *string_p, /**< utf-8 stri
|
||||
}
|
||||
|
||||
lit_utf8_byte_t *data_p;
|
||||
string_desc_p = ecma_new_ecma_string_from_utf8_buffer (lit_utf8_string_length (string_p, string_size),
|
||||
string_size,
|
||||
&data_p);
|
||||
string_desc_p =
|
||||
ecma_new_ecma_string_from_utf8_buffer (lit_utf8_string_length (string_p, string_size), string_size, &data_p);
|
||||
|
||||
string_desc_p->u.hash = lit_utf8_string_calc_hash (string_p, string_size);
|
||||
memcpy (data_p, string_p, string_size);
|
||||
@ -446,9 +441,8 @@ ecma_new_ecma_string_from_utf8_converted_to_cesu8 (const lit_utf8_byte_t *string
|
||||
JERRY_ASSERT (lit_is_valid_utf8_string (string_p, string_size, false));
|
||||
|
||||
lit_utf8_byte_t *data_p;
|
||||
ecma_string_t *string_desc_p = ecma_new_ecma_string_from_utf8_buffer (converted_string_length,
|
||||
converted_string_size,
|
||||
&data_p);
|
||||
ecma_string_t *string_desc_p =
|
||||
ecma_new_ecma_string_from_utf8_buffer (converted_string_length, converted_string_size, &data_p);
|
||||
|
||||
const lit_utf8_byte_t *const begin_data_p = data_p;
|
||||
pos = 0;
|
||||
@ -661,8 +655,8 @@ ecma_new_ecma_string_from_number (ecma_number_t num) /**< ecma-number */
|
||||
|
||||
if (ecma_number_is_infinity (num))
|
||||
{
|
||||
lit_magic_string_id_t id = (ecma_number_is_negative (num) ? LIT_MAGIC_STRING_NEGATIVE_INFINITY_UL
|
||||
: LIT_MAGIC_STRING_INFINITY_UL);
|
||||
lit_magic_string_id_t id =
|
||||
(ecma_number_is_negative (num) ? LIT_MAGIC_STRING_NEGATIVE_INFINITY_UL : LIT_MAGIC_STRING_INFINITY_UL);
|
||||
return ecma_get_magic_string (id);
|
||||
}
|
||||
|
||||
@ -676,9 +670,8 @@ ecma_new_ecma_string_from_number (ecma_number_t num) /**< ecma-number */
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
lit_utf8_byte_t *data_p;
|
||||
ecma_string_t *string_desc_p = ecma_new_ecma_string_from_utf8_buffer (lit_utf8_string_length (str_buf, str_size),
|
||||
str_size,
|
||||
&data_p);
|
||||
ecma_string_t *string_desc_p =
|
||||
ecma_new_ecma_string_from_utf8_buffer (lit_utf8_string_length (str_buf, str_size), str_size, &data_p);
|
||||
|
||||
string_desc_p->u.hash = lit_utf8_string_calc_hash (str_buf, str_size);
|
||||
memcpy (data_p, str_buf, str_size);
|
||||
@ -694,7 +687,7 @@ ecma_new_ecma_string_from_number (ecma_number_t num) /**< ecma-number */
|
||||
*
|
||||
* @return pointer to ecma-string descriptor
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_magic_string (lit_magic_string_id_t id) /**< identifier of magic string */
|
||||
{
|
||||
JERRY_ASSERT (id < LIT_MAGIC_STRING__COUNT);
|
||||
@ -709,7 +702,7 @@ ecma_get_magic_string (lit_magic_string_id_t id) /**< identifier of magic string
|
||||
*
|
||||
* @return pointer to ecma-string descriptor
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_internal_string (lit_magic_string_id_t id) /**< identifier of magic string */
|
||||
{
|
||||
JERRY_ASSERT (id >= LIT_NON_INTERNAL_MAGIC_STRING__COUNT && id < LIT_MAGIC_STRING__COUNT);
|
||||
@ -743,11 +736,8 @@ ecma_append_chars_to_string (ecma_string_t *string1_p, /**< base ecma-string */
|
||||
uint8_t flags = ECMA_STRING_FLAG_IS_ASCII;
|
||||
lit_utf8_byte_t uint32_to_string_buffer[ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32];
|
||||
|
||||
const lit_utf8_byte_t *cesu8_string1_p = ecma_string_get_chars (string1_p,
|
||||
&cesu8_string1_size,
|
||||
&cesu8_string1_length,
|
||||
uint32_to_string_buffer,
|
||||
&flags);
|
||||
const lit_utf8_byte_t *cesu8_string1_p =
|
||||
ecma_string_get_chars (string1_p, &cesu8_string1_size, &cesu8_string1_length, uint32_to_string_buffer, &flags);
|
||||
|
||||
JERRY_ASSERT (!(flags & ECMA_STRING_FLAG_MUST_BE_FREED));
|
||||
JERRY_ASSERT (cesu8_string1_length > 0);
|
||||
@ -762,10 +752,8 @@ ecma_append_chars_to_string (ecma_string_t *string1_p, /**< base ecma-string */
|
||||
}
|
||||
|
||||
lit_magic_string_id_t magic_string_id;
|
||||
magic_string_id = lit_is_utf8_string_pair_magic (cesu8_string1_p,
|
||||
cesu8_string1_size,
|
||||
cesu8_string2_p,
|
||||
cesu8_string2_size);
|
||||
magic_string_id =
|
||||
lit_is_utf8_string_pair_magic (cesu8_string1_p, cesu8_string1_size, cesu8_string2_p, cesu8_string2_size);
|
||||
|
||||
if (magic_string_id != LIT_MAGIC_STRING__COUNT)
|
||||
{
|
||||
@ -789,10 +777,8 @@ ecma_append_chars_to_string (ecma_string_t *string1_p, /**< base ecma-string */
|
||||
if (lit_get_magic_string_ex_count () > 0)
|
||||
{
|
||||
lit_magic_string_ex_id_t magic_string_ex_id;
|
||||
magic_string_ex_id = lit_is_ex_utf8_string_pair_magic (cesu8_string1_p,
|
||||
cesu8_string1_size,
|
||||
cesu8_string2_p,
|
||||
cesu8_string2_size);
|
||||
magic_string_ex_id =
|
||||
lit_is_ex_utf8_string_pair_magic (cesu8_string1_p, cesu8_string1_size, cesu8_string2_p, cesu8_string2_size);
|
||||
|
||||
if (magic_string_ex_id < lit_get_magic_string_ex_count ())
|
||||
{
|
||||
@ -802,9 +788,8 @@ ecma_append_chars_to_string (ecma_string_t *string1_p, /**< base ecma-string */
|
||||
}
|
||||
|
||||
lit_utf8_byte_t *data_p;
|
||||
ecma_string_t *string_desc_p = ecma_new_ecma_string_from_utf8_buffer (cesu8_string1_length + cesu8_string2_length,
|
||||
new_size,
|
||||
&data_p);
|
||||
ecma_string_t *string_desc_p =
|
||||
ecma_new_ecma_string_from_utf8_buffer (cesu8_string1_length + cesu8_string2_length, new_size, &data_p);
|
||||
|
||||
lit_string_hash_t hash_start;
|
||||
|
||||
@ -857,18 +842,13 @@ ecma_concat_ecma_strings (ecma_string_t *string1_p, /**< first ecma-string */
|
||||
lit_utf8_byte_t uint32_to_string_buffer[ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32];
|
||||
uint8_t flags = ECMA_STRING_FLAG_IS_ASCII;
|
||||
|
||||
const lit_utf8_byte_t *cesu8_string2_p = ecma_string_get_chars (string2_p,
|
||||
&cesu8_string2_size,
|
||||
&cesu8_string2_length,
|
||||
uint32_to_string_buffer,
|
||||
&flags);
|
||||
const lit_utf8_byte_t *cesu8_string2_p =
|
||||
ecma_string_get_chars (string2_p, &cesu8_string2_size, &cesu8_string2_length, uint32_to_string_buffer, &flags);
|
||||
|
||||
JERRY_ASSERT (cesu8_string2_p != NULL);
|
||||
|
||||
ecma_string_t *result_p = ecma_append_chars_to_string (string1_p,
|
||||
cesu8_string2_p,
|
||||
cesu8_string2_size,
|
||||
cesu8_string2_length);
|
||||
ecma_string_t *result_p =
|
||||
ecma_append_chars_to_string (string1_p, cesu8_string2_p, cesu8_string2_size, cesu8_string2_length);
|
||||
|
||||
JERRY_ASSERT (!(flags & ECMA_STRING_FLAG_MUST_BE_FREED));
|
||||
|
||||
@ -1200,10 +1180,7 @@ ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_p, /**< ecma-string
|
||||
return size;
|
||||
}
|
||||
|
||||
size = lit_convert_cesu8_string_to_utf8_string (chars_p,
|
||||
size,
|
||||
buffer_p,
|
||||
buffer_size);
|
||||
size = lit_convert_cesu8_string_to_utf8_string (chars_p, size, buffer_p, buffer_size);
|
||||
|
||||
if (flags & ECMA_STRING_FLAG_MUST_BE_FREED)
|
||||
{
|
||||
@ -1606,7 +1583,6 @@ ecma_string_get_chars (const ecma_string_t *string_p, /**< ecma-string */
|
||||
JERRY_ASSERT (length == size);
|
||||
*flags_p |= ECMA_STRING_FLAG_IS_UINT32 | ECMA_STRING_FLAG_REHASH_NEEDED;
|
||||
break;
|
||||
|
||||
}
|
||||
default:
|
||||
{
|
||||
@ -1634,8 +1610,7 @@ ecma_string_get_chars (const ecma_string_t *string_p, /**< ecma-string */
|
||||
*length_p = length;
|
||||
}
|
||||
|
||||
if ((*flags_p & ECMA_STRING_FLAG_IS_ASCII)
|
||||
&& length != size)
|
||||
if ((*flags_p & ECMA_STRING_FLAG_IS_ASCII) && length != size)
|
||||
{
|
||||
*flags_p = (uint8_t) (*flags_p & (uint8_t) ~ECMA_STRING_FLAG_IS_ASCII);
|
||||
}
|
||||
@ -1685,7 +1660,7 @@ ecma_string_is_length (const ecma_string_t *string_p) /**< property name */
|
||||
*
|
||||
* @return pointer to the converted ecma string
|
||||
*/
|
||||
static inline ecma_string_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
static inline ecma_string_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_property_to_string (ecma_property_t property, /**< property name type */
|
||||
jmem_cpointer_t prop_name_cp) /**< property name compressed pointer */
|
||||
{
|
||||
@ -1964,8 +1939,7 @@ bool
|
||||
ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-string */
|
||||
const ecma_string_t *string2_p) /**< ecma-string */
|
||||
{
|
||||
if (ecma_compare_ecma_strings (string1_p,
|
||||
string2_p))
|
||||
if (ecma_compare_ecma_strings (string1_p, string2_p))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -2038,10 +2012,7 @@ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-
|
||||
}
|
||||
}
|
||||
|
||||
return lit_compare_utf8_strings_relational (utf8_string1_p,
|
||||
utf8_string1_size,
|
||||
utf8_string2_p,
|
||||
utf8_string2_size);
|
||||
return lit_compare_utf8_strings_relational (utf8_string1_p, utf8_string1_size, utf8_string2_p, utf8_string2_size);
|
||||
} /* ecma_compare_ecma_strings_relational */
|
||||
|
||||
/**
|
||||
@ -2071,8 +2042,7 @@ ecma_string_get_ascii_size (const ecma_string_t *string_p) /**< ecma-string */
|
||||
return ECMA_STRING_NO_ASCII_SIZE;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (ECMA_STRING_IS_ASCII (lit_get_magic_string_utf8 (id),
|
||||
lit_get_magic_string_size (id)));
|
||||
JERRY_ASSERT (ECMA_STRING_IS_ASCII (lit_get_magic_string_utf8 (id), lit_get_magic_string_size (id)));
|
||||
|
||||
return lit_get_magic_string_size (id);
|
||||
}
|
||||
@ -2120,8 +2090,7 @@ ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */
|
||||
JERRY_ASSERT ((uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) >= LIT_MAGIC_STRING__COUNT);
|
||||
|
||||
uint32_t id = (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) - LIT_MAGIC_STRING__COUNT;
|
||||
return lit_utf8_string_length (lit_get_magic_string_ex_utf8 (id),
|
||||
lit_get_magic_string_ex_size (id));
|
||||
return lit_utf8_string_length (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
|
||||
}
|
||||
|
||||
if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_HEAP_UTF8_STRING)
|
||||
@ -2137,8 +2106,7 @@ ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */
|
||||
JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
|
||||
|
||||
lit_magic_string_ex_id_t id = LIT_MAGIC_STRING__COUNT - string_p->u.magic_string_ex_id;
|
||||
return lit_utf8_string_length (lit_get_magic_string_ex_utf8 (id),
|
||||
lit_get_magic_string_ex_size (id));
|
||||
return lit_utf8_string_length (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
|
||||
} /* ecma_string_get_length */
|
||||
|
||||
/**
|
||||
@ -2162,8 +2130,7 @@ ecma_string_get_utf8_length (const ecma_string_t *string_p) /**< ecma-string */
|
||||
JERRY_ASSERT ((uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) >= LIT_MAGIC_STRING__COUNT);
|
||||
|
||||
uint32_t id = (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) - LIT_MAGIC_STRING__COUNT;
|
||||
return lit_get_utf8_length_of_cesu8_string (lit_get_magic_string_ex_utf8 (id),
|
||||
lit_get_magic_string_ex_size (id));
|
||||
return lit_get_utf8_length_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
|
||||
}
|
||||
|
||||
if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_HEAP_UTF8_STRING)
|
||||
@ -2196,8 +2163,7 @@ ecma_string_get_utf8_length (const ecma_string_t *string_p) /**< ecma-string */
|
||||
|
||||
lit_magic_string_ex_id_t id = LIT_MAGIC_STRING__COUNT - string_p->u.magic_string_ex_id;
|
||||
|
||||
return lit_get_utf8_length_of_cesu8_string (lit_get_magic_string_ex_utf8 (id),
|
||||
lit_get_magic_string_ex_size (id));
|
||||
return lit_get_utf8_length_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
|
||||
} /* ecma_string_get_utf8_length */
|
||||
|
||||
/**
|
||||
@ -2259,8 +2225,7 @@ ecma_string_get_utf8_size (const ecma_string_t *string_p) /**< ecma-string */
|
||||
JERRY_ASSERT ((uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) >= LIT_MAGIC_STRING__COUNT);
|
||||
|
||||
uint32_t id = (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p) - LIT_MAGIC_STRING__COUNT;
|
||||
return lit_get_utf8_size_of_cesu8_string (lit_get_magic_string_ex_utf8 (id),
|
||||
lit_get_magic_string_ex_size (id));
|
||||
return lit_get_utf8_size_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
|
||||
}
|
||||
|
||||
if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_HEAP_UTF8_STRING)
|
||||
@ -2291,8 +2256,7 @@ ecma_string_get_utf8_size (const ecma_string_t *string_p) /**< ecma-string */
|
||||
JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
|
||||
|
||||
lit_magic_string_ex_id_t id = LIT_MAGIC_STRING__COUNT - string_p->u.magic_string_ex_id;
|
||||
return lit_get_utf8_size_of_cesu8_string (lit_get_magic_string_ex_utf8 (id),
|
||||
lit_get_magic_string_ex_size (id));
|
||||
return lit_get_utf8_size_of_cesu8_string (lit_get_magic_string_ex_utf8 (id), lit_get_magic_string_ex_size (id));
|
||||
} /* ecma_string_get_utf8_size */
|
||||
|
||||
/**
|
||||
@ -2511,7 +2475,7 @@ ecma_string_substr (const ecma_string_t *string_p, /**< pointer to an ecma strin
|
||||
*/
|
||||
const lit_utf8_byte_t *
|
||||
ecma_string_trim_front (const lit_utf8_byte_t *start_p, /**< current string's start position */
|
||||
const lit_utf8_byte_t *end_p) /**< current string's end position */
|
||||
const lit_utf8_byte_t *end_p) /**< current string's end position */
|
||||
{
|
||||
ecma_char_t ch;
|
||||
|
||||
@ -2540,7 +2504,7 @@ ecma_string_trim_front (const lit_utf8_byte_t *start_p, /**< current string's st
|
||||
*/
|
||||
const lit_utf8_byte_t *
|
||||
ecma_string_trim_back (const lit_utf8_byte_t *start_p, /**< current string's start position */
|
||||
const lit_utf8_byte_t *end_p) /**< current string's end position */
|
||||
const lit_utf8_byte_t *end_p) /**< current string's end position */
|
||||
{
|
||||
ecma_char_t ch;
|
||||
|
||||
@ -2568,7 +2532,7 @@ ecma_string_trim_back (const lit_utf8_byte_t *start_p, /**< current string's sta
|
||||
*/
|
||||
extern inline void JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_string_trim_helper (const lit_utf8_byte_t **utf8_str_p, /**< [in, out] current string position */
|
||||
lit_utf8_size_t *utf8_str_size) /**< [in, out] size of the given string */
|
||||
lit_utf8_size_t *utf8_str_size) /**< [in, out] size of the given string */
|
||||
{
|
||||
const lit_utf8_byte_t *end_p = *utf8_str_p + *utf8_str_size;
|
||||
const lit_utf8_byte_t *start_p = *utf8_str_p;
|
||||
@ -2622,11 +2586,10 @@ ecma_string_trim (const ecma_string_t *string_p) /**< pointer to an ecma string
|
||||
ecma_value_t
|
||||
ecma_string_pad (ecma_value_t original_string_p, /**< Input ecma string */
|
||||
ecma_value_t max_length, /**< Length to pad to, including original length */
|
||||
ecma_value_t fill_string, /**< The string to pad with */
|
||||
ecma_value_t fill_string, /**< The string to pad with */
|
||||
bool pad_on_start) /**< true - if we are padding to the start, calling with padStart
|
||||
false - if we are padding to the end, calling with padEnd */
|
||||
{
|
||||
|
||||
/* 3 */
|
||||
ecma_length_t int_max_length;
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_op_to_length (max_length, &int_max_length)))
|
||||
@ -2723,7 +2686,7 @@ ecma_stringbuilder_create (void)
|
||||
jmem_stats_allocate_string_bytes (initial_size);
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
ecma_stringbuilder_t ret = {.header_p = header_p};
|
||||
ecma_stringbuilder_t ret = { .header_p = header_p };
|
||||
return ret;
|
||||
} /* ecma_stringbuilder_create */
|
||||
|
||||
@ -2744,12 +2707,11 @@ ecma_stringbuilder_create_from (ecma_string_t *string_p) /**< ecma string */
|
||||
jmem_stats_allocate_string_bytes (initial_size);
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
size_t copied_size = ecma_string_copy_to_cesu8_buffer (string_p,
|
||||
ECMA_STRINGBUILDER_STRING_PTR (header_p),
|
||||
string_size);
|
||||
size_t copied_size =
|
||||
ecma_string_copy_to_cesu8_buffer (string_p, ECMA_STRINGBUILDER_STRING_PTR (header_p), string_size);
|
||||
JERRY_ASSERT (copied_size == string_size);
|
||||
|
||||
ecma_stringbuilder_t ret = {.header_p = header_p};
|
||||
ecma_stringbuilder_t ret = { .header_p = header_p };
|
||||
return ret;
|
||||
} /* ecma_stringbuilder_create_from */
|
||||
|
||||
@ -2772,7 +2734,7 @@ ecma_stringbuilder_create_raw (const lit_utf8_byte_t *data_p, /**< pointer to da
|
||||
|
||||
memcpy (ECMA_STRINGBUILDER_STRING_PTR (header_p), data_p, data_size);
|
||||
|
||||
ecma_stringbuilder_t ret = {.header_p = header_p};
|
||||
ecma_stringbuilder_t ret = { .header_p = header_p };
|
||||
return ret;
|
||||
} /* ecma_stringbuilder_create_raw */
|
||||
|
||||
@ -2797,7 +2759,7 @@ ecma_stringbuilder_grow (ecma_stringbuilder_t *builder_p, /**< string builder */
|
||||
jmem_stats_allocate_string_bytes (required_size);
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
return ((lit_utf8_byte_t *) header_p) + header_p->current_size - required_size;
|
||||
return ((lit_utf8_byte_t *) header_p) + header_p->current_size - required_size;
|
||||
} /* ecma_stringbuilder_grow */
|
||||
|
||||
/**
|
||||
@ -2860,9 +2822,7 @@ ecma_stringbuilder_append (ecma_stringbuilder_t *builder_p, /**< string builder
|
||||
const lit_utf8_size_t string_size = ecma_string_get_size (string_p);
|
||||
lit_utf8_byte_t *dest_p = ecma_stringbuilder_grow (builder_p, string_size);
|
||||
|
||||
size_t copied_size = ecma_string_copy_to_cesu8_buffer (string_p,
|
||||
dest_p,
|
||||
string_size);
|
||||
size_t copied_size = ecma_string_copy_to_cesu8_buffer (string_p, dest_p, string_size);
|
||||
JERRY_ASSERT (copied_size == string_size);
|
||||
} /* ecma_stringbuilder_append */
|
||||
|
||||
@ -2953,7 +2913,7 @@ ecma_stringbuilder_finalize (ecma_stringbuilder_t *builder_p) /**< string builde
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
builder_p->header_p = NULL;
|
||||
#endif
|
||||
#endif /* !defined (JERRY_NDEBUG) */
|
||||
|
||||
size_t container_size = sizeof (ecma_short_string_t);
|
||||
const lit_string_hash_t hash = lit_utf8_string_calc_hash (string_begin_p, string_size);
|
||||
@ -2978,9 +2938,7 @@ ecma_stringbuilder_finalize (ecma_stringbuilder_t *builder_p) /**< string builde
|
||||
|
||||
const size_t utf8_string_size = string_size + container_size;
|
||||
header_p = jmem_heap_realloc_block (header_p, header_p->current_size, utf8_string_size);
|
||||
memmove (((lit_utf8_byte_t *) header_p + container_size),
|
||||
ECMA_STRINGBUILDER_STRING_PTR (header_p),
|
||||
string_size);
|
||||
memmove (((lit_utf8_byte_t *) header_p + container_size), ECMA_STRINGBUILDER_STRING_PTR (header_p), string_size);
|
||||
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_allocate_string_bytes (container_size - ECMA_ASCII_STRING_HEADER_SIZE);
|
||||
@ -3021,7 +2979,7 @@ ecma_stringbuilder_destroy (ecma_stringbuilder_t *builder_p) /**< string builder
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
builder_p->header_p = NULL;
|
||||
#endif
|
||||
#endif /* !defined (JERRY_NDEBUG) */
|
||||
|
||||
#if JERRY_MEM_STATS
|
||||
jmem_stats_free_string_bytes (size);
|
||||
|
||||
@ -15,20 +15,18 @@
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#include "jrt-bit-fields.h"
|
||||
#include "jrt.h"
|
||||
#include "vm-defines.h"
|
||||
|
||||
#include "ecma-function-object.h"
|
||||
JERRY_STATIC_ASSERT (ECMA_TYPE___MAX <= ECMA_VALUE_TYPE_MASK, ecma_types_must_be_less_than_mask);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_TYPE___MAX <= ECMA_VALUE_TYPE_MASK,
|
||||
ecma_types_must_be_less_than_mask);
|
||||
|
||||
JERRY_STATIC_ASSERT ((ECMA_VALUE_TYPE_MASK + 1) == (1 << ECMA_VALUE_SHIFT),
|
||||
ecma_value_part_must_start_after_flags);
|
||||
JERRY_STATIC_ASSERT ((ECMA_VALUE_TYPE_MASK + 1) == (1 << ECMA_VALUE_SHIFT), ecma_value_part_must_start_after_flags);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_VALUE_SHIFT <= JMEM_ALIGNMENT_LOG,
|
||||
ecma_value_shift_must_be_less_than_or_equal_than_mem_alignment_log);
|
||||
@ -42,18 +40,16 @@ JERRY_STATIC_ASSERT (sizeof (jmem_cpointer_t) <= sizeof (jmem_cpointer_tag_t),
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
|
||||
/* cppcheck-suppress zerodiv */
|
||||
JERRY_STATIC_ASSERT (sizeof (uintptr_t) <= sizeof (ecma_value_t),
|
||||
uintptr_t_must_fit_in_ecma_value_t);
|
||||
JERRY_STATIC_ASSERT (sizeof (uintptr_t) <= sizeof (ecma_value_t), uintptr_t_must_fit_in_ecma_value_t);
|
||||
|
||||
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (uintptr_t) > sizeof (ecma_value_t),
|
||||
uintptr_t_must_not_fit_in_ecma_value_t);
|
||||
JERRY_STATIC_ASSERT (sizeof (uintptr_t) > sizeof (ecma_value_t), uintptr_t_must_not_fit_in_ecma_value_t);
|
||||
|
||||
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
JERRY_STATIC_ASSERT ((ECMA_VALUE_FALSE | (1 << ECMA_DIRECT_SHIFT)) == ECMA_VALUE_TRUE
|
||||
&& ECMA_VALUE_FALSE != ECMA_VALUE_TRUE,
|
||||
&& ECMA_VALUE_FALSE != ECMA_VALUE_TRUE,
|
||||
only_the_lowest_bit_must_be_different_for_simple_value_true_and_false);
|
||||
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
@ -110,7 +106,7 @@ ecma_pointer_to_ecma_value (const void *ptr) /**< pointer */
|
||||
*
|
||||
* @return pointer
|
||||
*/
|
||||
static inline void * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
static inline void *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_pointer_from_ecma_value (ecma_value_t value) /**< value */
|
||||
{
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
@ -277,8 +273,7 @@ extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_are_values_integer_numbers (ecma_value_t first_value, /**< first ecma value */
|
||||
ecma_value_t second_value) /**< second ecma value */
|
||||
{
|
||||
JERRY_STATIC_ASSERT (ECMA_DIRECT_TYPE_INTEGER_VALUE == 0,
|
||||
ecma_direct_type_integer_value_must_be_zero);
|
||||
JERRY_STATIC_ASSERT (ECMA_DIRECT_TYPE_INTEGER_VALUE == 0, ecma_direct_type_integer_value_must_be_zero);
|
||||
|
||||
return ((first_value | second_value) & ECMA_DIRECT_TYPE_MASK) == ECMA_DIRECT_TYPE_INTEGER_VALUE;
|
||||
} /* ecma_are_values_integer_numbers */
|
||||
@ -304,8 +299,7 @@ ecma_is_value_float_number (ecma_value_t value) /**< ecma value */
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_number (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return (ecma_is_value_integer_number (value)
|
||||
|| ecma_is_value_float_number (value));
|
||||
return (ecma_is_value_integer_number (value) || ecma_is_value_float_number (value));
|
||||
} /* ecma_is_value_number */
|
||||
|
||||
JERRY_STATIC_ASSERT ((ECMA_TYPE_STRING | 0x4) == ECMA_TYPE_DIRECT_STRING,
|
||||
@ -362,12 +356,12 @@ ecma_is_value_magic_string (ecma_value_t value, /**< ecma value */
|
||||
extern inline bool JERRY_ATTR_CONST JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_is_value_bigint (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_BIGINT);
|
||||
#else /* !JERRY_BUILTIN_BIGINT */
|
||||
#else /* !JERRY_BUILTIN_BIGINT */
|
||||
JERRY_UNUSED (value);
|
||||
return false;
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
} /* ecma_is_value_bigint */
|
||||
|
||||
/**
|
||||
@ -441,14 +435,9 @@ ecma_is_value_error_reference (ecma_value_t value) /**< ecma value */
|
||||
void
|
||||
ecma_check_value_type_is_spec_defined (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_undefined (value)
|
||||
|| ecma_is_value_null (value)
|
||||
|| ecma_is_value_boolean (value)
|
||||
|| ecma_is_value_number (value)
|
||||
|| ecma_is_value_string (value)
|
||||
|| ecma_is_value_bigint (value)
|
||||
|| ecma_is_value_symbol (value)
|
||||
|| ecma_is_value_object (value));
|
||||
JERRY_ASSERT (ecma_is_value_undefined (value) || ecma_is_value_null (value) || ecma_is_value_boolean (value)
|
||||
|| ecma_is_value_number (value) || ecma_is_value_string (value) || ecma_is_value_bigint (value)
|
||||
|| ecma_is_value_symbol (value) || ecma_is_value_object (value));
|
||||
} /* ecma_check_value_type_is_spec_defined */
|
||||
|
||||
/**
|
||||
@ -768,7 +757,7 @@ ecma_get_float_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return floating point value
|
||||
*/
|
||||
extern inline ecma_number_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_number_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_pointer_from_float_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_FLOAT);
|
||||
@ -797,7 +786,7 @@ ecma_get_number_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the string pointer
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_string_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_string (value));
|
||||
@ -816,7 +805,7 @@ ecma_get_string_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the string pointer
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_symbol_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_symbol (value));
|
||||
@ -830,7 +819,7 @@ ecma_get_symbol_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the string pointer
|
||||
*/
|
||||
extern inline ecma_string_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_string_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_prop_name_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_prop_name (value));
|
||||
@ -848,7 +837,7 @@ ecma_get_prop_name_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the pointer
|
||||
*/
|
||||
extern inline ecma_object_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_object_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_object_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_object (value));
|
||||
@ -861,7 +850,7 @@ ecma_get_object_from_value (ecma_value_t value) /**< ecma value */
|
||||
*
|
||||
* @return the pointer
|
||||
*/
|
||||
extern inline ecma_extended_primitive_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_extended_primitive_t *JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_extended_primitive_from_value (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
#if JERRY_BUILTIN_BIGINT
|
||||
@ -892,7 +881,7 @@ ecma_invert_boolean_value (ecma_value_t value) /**< ecma value */
|
||||
* @return copy of the given value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_copy_value (ecma_value_t value) /**< value description */
|
||||
ecma_copy_value (ecma_value_t value) /**< value description */
|
||||
{
|
||||
switch (ecma_get_value_type_field (value))
|
||||
{
|
||||
@ -951,7 +940,7 @@ ecma_copy_value (ecma_value_t value) /**< value description */
|
||||
* @return copy of the given value
|
||||
*/
|
||||
extern inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_fast_copy_value (ecma_value_t value) /**< value description */
|
||||
ecma_fast_copy_value (ecma_value_t value) /**< value description */
|
||||
{
|
||||
return (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT) ? value : ecma_copy_value (value);
|
||||
} /* ecma_fast_copy_value */
|
||||
@ -1006,8 +995,7 @@ void
|
||||
ecma_value_assign_value (ecma_value_t *value_p, /**< [in, out] ecma value */
|
||||
ecma_value_t ecma_value) /**< value to assign */
|
||||
{
|
||||
JERRY_STATIC_ASSERT (ECMA_TYPE_DIRECT == 0,
|
||||
ecma_type_direct_must_be_zero_for_the_next_check);
|
||||
JERRY_STATIC_ASSERT (ECMA_TYPE_DIRECT == 0, ecma_type_direct_must_be_zero_for_the_next_check);
|
||||
|
||||
if (*value_p == ecma_value)
|
||||
{
|
||||
@ -1018,8 +1006,7 @@ ecma_value_assign_value (ecma_value_t *value_p, /**< [in, out] ecma value */
|
||||
{
|
||||
*value_p = ecma_value;
|
||||
}
|
||||
else if (ecma_is_value_float_number (ecma_value)
|
||||
&& ecma_is_value_float_number (*value_p))
|
||||
else if (ecma_is_value_float_number (ecma_value) && ecma_is_value_float_number (*value_p))
|
||||
{
|
||||
const ecma_number_t *num_src_p = (ecma_number_t *) ecma_get_pointer_from_ecma_value (ecma_value);
|
||||
ecma_number_t *num_dst_p = (ecma_number_t *) ecma_get_pointer_from_ecma_value (*value_p);
|
||||
|
||||
@ -13,20 +13,22 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lcache.h"
|
||||
#include "ecma-line-info.h"
|
||||
#include "ecma-property-hashmap.h"
|
||||
|
||||
#include "byte-code.h"
|
||||
#include "jcontext.h"
|
||||
#include "jrt-bit-fields.h"
|
||||
#include "byte-code.h"
|
||||
#include "re-compiler.h"
|
||||
#include "ecma-builtins.h"
|
||||
|
||||
#if JERRY_DEBUGGER
|
||||
#include "debugger.h"
|
||||
@ -62,13 +64,13 @@ JERRY_STATIC_ASSERT (ECMA_PROPERTY_FLAGS_MASK == ECMA_PROPERTY_CONFIGURABLE_ENUM
|
||||
|
||||
/* These checks are needed by ecma_get_object_base_type. */
|
||||
JERRY_STATIC_ASSERT ((int) ECMA_OBJECT_TYPE_BUILT_IN_GENERAL == ((int) ECMA_OBJECT_TYPE_GENERAL | 0x1)
|
||||
&& ((int) ECMA_OBJECT_TYPE_GENERAL & 0x1) == 0,
|
||||
&& ((int) ECMA_OBJECT_TYPE_GENERAL & 0x1) == 0,
|
||||
ecma_object_type_built_in_general_has_unexpected_value);
|
||||
JERRY_STATIC_ASSERT ((int) ECMA_OBJECT_TYPE_BUILT_IN_CLASS == ((int) ECMA_OBJECT_TYPE_CLASS | 0x1)
|
||||
&& ((int) ECMA_OBJECT_TYPE_CLASS & 0x1) == 0,
|
||||
&& ((int) ECMA_OBJECT_TYPE_CLASS & 0x1) == 0,
|
||||
ecma_object_type_built_in_class_has_unexpected_value);
|
||||
JERRY_STATIC_ASSERT ((int) ECMA_OBJECT_TYPE_BUILT_IN_ARRAY == ((int) ECMA_OBJECT_TYPE_ARRAY | 0x1)
|
||||
&& ((int) ECMA_OBJECT_TYPE_ARRAY & 0x1) == 0,
|
||||
&& ((int) ECMA_OBJECT_TYPE_ARRAY & 0x1) == 0,
|
||||
ecma_object_type_built_in_array_has_unexpected_value);
|
||||
|
||||
/**
|
||||
@ -147,8 +149,7 @@ ecma_object_t *
|
||||
ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< outer lexical environment */
|
||||
ecma_object_t *binding_obj_p) /**< binding object */
|
||||
{
|
||||
JERRY_ASSERT (binding_obj_p != NULL
|
||||
&& !ecma_is_lexical_environment (binding_obj_p));
|
||||
JERRY_ASSERT (binding_obj_p != NULL && !ecma_is_lexical_environment (binding_obj_p));
|
||||
|
||||
ecma_object_t *new_lexical_environment_p = ecma_alloc_object ();
|
||||
|
||||
@ -156,8 +157,7 @@ ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< out
|
||||
|
||||
ecma_init_gc_info (new_lexical_environment_p);
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER (new_lexical_environment_p->u1.bound_object_cp,
|
||||
binding_obj_p);
|
||||
ECMA_SET_NON_NULL_POINTER (new_lexical_environment_p->u1.bound_object_cp, binding_obj_p);
|
||||
|
||||
ECMA_SET_POINTER (new_lexical_environment_p->u2.outer_reference_cp, outer_lexical_environment_p);
|
||||
|
||||
@ -298,7 +298,7 @@ ecma_get_lex_env_type (const ecma_object_t *object_p) /**< lexical environment *
|
||||
*
|
||||
* @return pointer to ecma object
|
||||
*/
|
||||
extern inline ecma_object_t * JERRY_ATTR_PURE
|
||||
extern inline ecma_object_t *JERRY_ATTR_PURE
|
||||
ecma_get_lex_env_binding_object (const ecma_object_t *object_p) /**< object-bound lexical environment */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
@ -381,8 +381,7 @@ ecma_clone_decl_lexical_environment (ecma_object_t *lex_env_p, /**< declarative
|
||||
}
|
||||
|
||||
prop_iter_cp = prop_iter_p->next_property_cp;
|
||||
}
|
||||
while (prop_iter_cp != JMEM_CP_NULL);
|
||||
} while (prop_iter_cp != JMEM_CP_NULL);
|
||||
|
||||
ecma_deref_object (lex_env_p);
|
||||
return new_lex_env_p;
|
||||
@ -411,8 +410,8 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
if (*property_list_head_p != ECMA_NULL_POINTER)
|
||||
{
|
||||
/* If the first entry is free (deleted), it is reused. */
|
||||
ecma_property_header_t *first_property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
*property_list_head_p);
|
||||
ecma_property_header_t *first_property_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, *property_list_head_p);
|
||||
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
bool has_hashmap = false;
|
||||
@ -420,8 +419,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
if (first_property_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
{
|
||||
property_list_head_p = &first_property_p->next_property_cp;
|
||||
first_property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
*property_list_head_p);
|
||||
first_property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, *property_list_head_p);
|
||||
has_hashmap = true;
|
||||
}
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
@ -433,8 +431,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
ecma_property_pair_t *first_property_pair_p = (ecma_property_pair_t *) first_property_p;
|
||||
|
||||
ecma_property_t name_type;
|
||||
first_property_pair_p->names_cp[0] = ecma_string_to_property_name (name_p,
|
||||
&name_type);
|
||||
first_property_pair_p->names_cp[0] = ecma_string_to_property_name (name_p, &name_type);
|
||||
first_property_p->types[0] = (ecma_property_t) (type_and_flags | name_type);
|
||||
|
||||
ecma_property_t *property_p = first_property_p->types + 0;
|
||||
@ -456,10 +453,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
|
||||
if (has_hashmap)
|
||||
{
|
||||
ecma_property_hashmap_insert (object_p,
|
||||
name_p,
|
||||
first_property_pair_p,
|
||||
0);
|
||||
ecma_property_hashmap_insert (object_p, name_p, first_property_pair_p, 0);
|
||||
}
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
|
||||
@ -478,8 +472,8 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
|
||||
if (*property_list_head_p != ECMA_NULL_POINTER)
|
||||
{
|
||||
ecma_property_header_t *first_property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
*property_list_head_p);
|
||||
ecma_property_header_t *first_property_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, *property_list_head_p);
|
||||
|
||||
if (first_property_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
{
|
||||
@ -495,8 +489,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
first_property_pair_p->names_cp[0] = LIT_INTERNAL_MAGIC_STRING_DELETED;
|
||||
|
||||
ecma_property_t name_type;
|
||||
first_property_pair_p->names_cp[1] = ecma_string_to_property_name (name_p,
|
||||
&name_type);
|
||||
first_property_pair_p->names_cp[1] = ecma_string_to_property_name (name_p, &name_type);
|
||||
|
||||
first_property_pair_p->header.types[1] = (ecma_property_t) (type_and_flags | name_type);
|
||||
|
||||
@ -518,10 +511,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
|
||||
if (has_hashmap)
|
||||
{
|
||||
ecma_property_hashmap_insert (object_p,
|
||||
name_p,
|
||||
first_property_pair_p,
|
||||
1);
|
||||
ecma_property_hashmap_insert (object_p, name_p, first_property_pair_p, 1);
|
||||
}
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
|
||||
@ -542,8 +532,7 @@ ecma_create_named_data_property (ecma_object_t *object_p, /**< object */
|
||||
* if this field is non-NULL */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL && name_p != NULL);
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_p)
|
||||
|| !ecma_op_object_is_fast_array (object_p));
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_p) || !ecma_op_object_is_fast_array (object_p));
|
||||
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
|
||||
JERRY_ASSERT ((prop_attributes & ~ECMA_PROPERTY_BUILT_IN_CONFIGURABLE_ENUMERABLE_WRITABLE) == 0);
|
||||
|
||||
@ -570,8 +559,7 @@ ecma_create_named_accessor_property (ecma_object_t *object_p, /**< object */
|
||||
* if this field is non-NULL */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL && name_p != NULL);
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_p)
|
||||
|| !ecma_op_object_is_fast_array (object_p));
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_p) || !ecma_op_object_is_fast_array (object_p));
|
||||
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
|
||||
JERRY_ASSERT ((prop_attributes & ~ECMA_PROPERTY_BUILT_IN_CONFIGURABLE_ENUMERABLE) == 0);
|
||||
|
||||
@ -630,8 +618,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
|
||||
{
|
||||
JERRY_ASSERT (obj_p != NULL);
|
||||
JERRY_ASSERT (name_p != NULL);
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (obj_p)
|
||||
|| !ecma_op_object_is_fast_array (obj_p));
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (obj_p) || !ecma_op_object_is_fast_array (obj_p));
|
||||
|
||||
#if JERRY_LCACHE
|
||||
ecma_property_t *property_p = ecma_lcache_lookup (obj_p, name_p);
|
||||
@ -648,17 +635,13 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
if (prop_iter_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
prop_iter_cp);
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
|
||||
if (prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
{
|
||||
jmem_cpointer_t property_real_name_cp;
|
||||
property_p = ecma_property_hashmap_find ((ecma_property_hashmap_t *) prop_iter_p,
|
||||
name_p,
|
||||
&property_real_name_cp);
|
||||
property_p = ecma_property_hashmap_find ((ecma_property_hashmap_t *) prop_iter_p, name_p, &property_real_name_cp);
|
||||
#if JERRY_LCACHE
|
||||
if (property_p != NULL
|
||||
&& !ecma_is_property_lcached (property_p))
|
||||
if (property_p != NULL && !ecma_is_property_lcached (property_p))
|
||||
{
|
||||
ecma_lcache_insert (obj_p, property_real_name_cp, property_p);
|
||||
}
|
||||
@ -682,8 +665,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
|
||||
|
||||
while (prop_iter_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
prop_iter_cp);
|
||||
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));
|
||||
|
||||
@ -717,8 +699,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
|
||||
{
|
||||
while (prop_iter_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
prop_iter_cp);
|
||||
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));
|
||||
|
||||
@ -763,8 +744,7 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
|
||||
#if JERRY_LCACHE
|
||||
if (property_p != NULL
|
||||
&& !ecma_is_property_lcached (property_p))
|
||||
if (property_p != NULL && !ecma_is_property_lcached (property_p))
|
||||
{
|
||||
ecma_lcache_insert (obj_p, property_name_cp, property_p);
|
||||
}
|
||||
@ -788,8 +768,7 @@ ecma_get_named_data_property (ecma_object_t *obj_p, /**< object to find property
|
||||
{
|
||||
JERRY_ASSERT (obj_p != NULL);
|
||||
JERRY_ASSERT (name_p != NULL);
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (obj_p)
|
||||
|| !ecma_op_object_is_fast_array (obj_p));
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (obj_p) || !ecma_op_object_is_fast_array (obj_p));
|
||||
|
||||
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
|
||||
|
||||
@ -816,8 +795,7 @@ ecma_delete_property (ecma_object_t *object_p, /**< object */
|
||||
|
||||
if (cur_prop_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *cur_prop_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
cur_prop_cp);
|
||||
ecma_property_header_t *cur_prop_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, cur_prop_cp);
|
||||
|
||||
if (cur_prop_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
{
|
||||
@ -830,8 +808,7 @@ ecma_delete_property (ecma_object_t *object_p, /**< object */
|
||||
|
||||
while (cur_prop_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *cur_prop_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
cur_prop_cp);
|
||||
ecma_property_header_t *cur_prop_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, cur_prop_cp);
|
||||
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (cur_prop_p));
|
||||
|
||||
@ -846,9 +823,7 @@ ecma_delete_property (ecma_object_t *object_p, /**< object */
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
if (hashmap_status == ECMA_PROPERTY_HASHMAP_DELETE_HAS_HASHMAP)
|
||||
{
|
||||
hashmap_status = ecma_property_hashmap_delete (object_p,
|
||||
prop_pair_p->names_cp[i],
|
||||
cur_prop_p->types + i);
|
||||
hashmap_status = ecma_property_hashmap_delete (object_p, prop_pair_p->names_cp[i], cur_prop_p->types + i);
|
||||
}
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
|
||||
@ -988,8 +963,7 @@ ecma_set_named_accessor_property_getter (ecma_object_t *object_p, /**< the prope
|
||||
|
||||
#if JERRY_CPOINTER_32_BIT
|
||||
ecma_getter_setter_pointers_t *getter_setter_pair_p;
|
||||
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t,
|
||||
prop_value_p->getter_setter_pair_cp);
|
||||
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t, prop_value_p->getter_setter_pair_cp);
|
||||
ECMA_SET_POINTER (getter_setter_pair_p->getter_cp, getter_p);
|
||||
#else /* !JERRY_CPOINTER_32_BIT */
|
||||
ECMA_SET_POINTER (prop_value_p->getter_setter_pair.getter_cp, getter_p);
|
||||
@ -1008,8 +982,7 @@ ecma_set_named_accessor_property_setter (ecma_object_t *object_p, /**< the prope
|
||||
|
||||
#if JERRY_CPOINTER_32_BIT
|
||||
ecma_getter_setter_pointers_t *getter_setter_pair_p;
|
||||
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t,
|
||||
prop_value_p->getter_setter_pair_cp);
|
||||
getter_setter_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t, prop_value_p->getter_setter_pair_cp);
|
||||
ECMA_SET_POINTER (getter_setter_pair_p->setter_cp, setter_p);
|
||||
#else /* !JERRY_CPOINTER_32_BIT */
|
||||
ECMA_SET_POINTER (prop_value_p->getter_setter_pair.setter_cp, setter_p);
|
||||
@ -1059,7 +1032,7 @@ ecma_property_to_reference (ecma_property_t *property_p) /**< data or reference
|
||||
*
|
||||
* @return pointer to the value
|
||||
*/
|
||||
extern inline ecma_property_value_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_property_value_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_get_property_value_from_named_reference (ecma_property_value_t *reference_p) /**< data property reference */
|
||||
{
|
||||
ecma_value_t value = reference_p->value;
|
||||
@ -1248,14 +1221,12 @@ ecma_free_property_descriptor (ecma_property_descriptor_t *prop_desc_p) /**< pro
|
||||
ecma_free_value (prop_desc_p->value);
|
||||
}
|
||||
|
||||
if ((prop_desc_p->flags & JERRY_PROP_IS_GET_DEFINED)
|
||||
&& prop_desc_p->get_p != NULL)
|
||||
if ((prop_desc_p->flags & JERRY_PROP_IS_GET_DEFINED) && prop_desc_p->get_p != NULL)
|
||||
{
|
||||
ecma_deref_object (prop_desc_p->get_p);
|
||||
}
|
||||
|
||||
if ((prop_desc_p->flags & JERRY_PROP_IS_SET_DEFINED)
|
||||
&& prop_desc_p->set_p != NULL)
|
||||
if ((prop_desc_p->flags & JERRY_PROP_IS_SET_DEFINED) && prop_desc_p->set_p != NULL)
|
||||
{
|
||||
ecma_deref_object (prop_desc_p->set_p);
|
||||
}
|
||||
@ -1551,8 +1522,8 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
|
||||
for (uint32_t i = const_literal_end; i < literal_end; i++)
|
||||
{
|
||||
ecma_compiled_code_t *bytecode_literal_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
literal_start_p[i]);
|
||||
ecma_compiled_code_t *bytecode_literal_p =
|
||||
ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, literal_start_p[i]);
|
||||
|
||||
/* Self references are ignored. */
|
||||
if (bytecode_literal_p != bytecode_p)
|
||||
@ -1606,8 +1577,7 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
{
|
||||
jerry_debugger_byte_code_free_t *first_byte_code_free_p;
|
||||
|
||||
first_byte_code_free_p = JMEM_CP_GET_NON_NULL_POINTER (jerry_debugger_byte_code_free_t,
|
||||
byte_code_free_head);
|
||||
first_byte_code_free_p = JMEM_CP_GET_NON_NULL_POINTER (jerry_debugger_byte_code_free_t, byte_code_free_head);
|
||||
first_byte_code_free_p->prev_cp = byte_code_free_cp;
|
||||
}
|
||||
|
||||
@ -1629,8 +1599,7 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
#endif /* JERRY_BUILTIN_REGEXP */
|
||||
}
|
||||
|
||||
jmem_heap_free_block (bytecode_p,
|
||||
((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG);
|
||||
jmem_heap_free_block (bytecode_p, ((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG);
|
||||
} /* ecma_bytecode_deref */
|
||||
|
||||
/**
|
||||
@ -1659,8 +1628,7 @@ ecma_script_get_from_value (ecma_value_t value) /**< compiled code */
|
||||
|
||||
if (ext_object_p->u.cls.type == ECMA_OBJECT_CLASS_SCRIPT)
|
||||
{
|
||||
bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
ext_object_p->u.cls.u3.value);
|
||||
bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, ext_object_p->u.cls.u3.value);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1687,8 +1655,8 @@ ecma_script_get_from_value (ecma_value_t value) /**< compiled code */
|
||||
{
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
object_p = ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t,
|
||||
ext_object_p->u.bound_function.target_function);
|
||||
object_p =
|
||||
ECMA_GET_NON_NULL_POINTER_FROM_POINTER_TAG (ecma_object_t, ext_object_p->u.bound_function.target_function);
|
||||
continue;
|
||||
}
|
||||
#if JERRY_ESNEXT
|
||||
@ -1741,7 +1709,7 @@ ecma_compiled_code_resolve_arguments_start (const ecma_compiled_code_t *bytecode
|
||||
*
|
||||
* @return position of the function name of the compiled code
|
||||
*/
|
||||
extern inline ecma_value_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_value_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_compiled_code_resolve_function_name (const ecma_compiled_code_t *bytecode_header_p) /**< compiled code */
|
||||
{
|
||||
JERRY_ASSERT (bytecode_header_p != NULL);
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#define ECMA_HELPERS_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
#include "lit-strings.h"
|
||||
|
||||
@ -47,8 +48,8 @@
|
||||
* Set value of non-null compressed pointer so that it will correspond
|
||||
* to specified non_compressed_pointer.
|
||||
*/
|
||||
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) JMEM_CP_SET_NON_NULL_POINTER (field, \
|
||||
non_compressed_pointer)
|
||||
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) \
|
||||
JMEM_CP_SET_NON_NULL_POINTER (field, non_compressed_pointer)
|
||||
|
||||
/**
|
||||
* Set value of pointer-tag value so that it will correspond
|
||||
@ -88,42 +89,38 @@
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_STRING_FLAG_EMPTY = 0, /**< No options are provided. */
|
||||
ECMA_STRING_FLAG_IS_ASCII = (1 << 0), /**< The string contains only ASCII characters. */
|
||||
ECMA_STRING_FLAG_EMPTY = 0, /**< No options are provided. */
|
||||
ECMA_STRING_FLAG_IS_ASCII = (1 << 0), /**< The string contains only ASCII characters. */
|
||||
ECMA_STRING_FLAG_REHASH_NEEDED = (1 << 1), /**< The hash of the string must be recalculated.
|
||||
* For more details see ecma_append_chars_to_string */
|
||||
ECMA_STRING_FLAG_IS_UINT32 = (1 << 2), /**< The string repesents an UINT32 number */
|
||||
ECMA_STRING_FLAG_IS_UINT32 = (1 << 2), /**< The string repesents an UINT32 number */
|
||||
ECMA_STRING_FLAG_MUST_BE_FREED = (1 << 3), /**< The returned buffer must be freed */
|
||||
} ecma_string_flag_t;
|
||||
|
||||
/**
|
||||
* Underscore is ignored when this option is passed.
|
||||
*/
|
||||
#define ECMA_CONVERSION_ALLOW_UNDERSCORE 0x1
|
||||
#define ECMA_CONVERSION_ALLOW_UNDERSCORE 0x1
|
||||
|
||||
/**
|
||||
* Convert ecma-string's contents to a cesu-8 string and put it into a buffer.
|
||||
*/
|
||||
#define ECMA_STRING_TO_UTF8_STRING(ecma_str_ptr, /**< ecma string pointer */ \
|
||||
utf8_ptr, /**< [out] output buffer pointer */ \
|
||||
#define ECMA_STRING_TO_UTF8_STRING(ecma_str_ptr, /**< ecma string pointer */ \
|
||||
utf8_ptr, /**< [out] output buffer pointer */ \
|
||||
utf8_str_size) /**< [out] output buffer size */ \
|
||||
lit_utf8_size_t utf8_str_size; \
|
||||
uint8_t utf8_ptr ## flags = ECMA_STRING_FLAG_EMPTY; \
|
||||
const lit_utf8_byte_t *utf8_ptr = ecma_string_get_chars (ecma_str_ptr, \
|
||||
&utf8_str_size, \
|
||||
NULL, \
|
||||
NULL, \
|
||||
&utf8_ptr ## flags);
|
||||
lit_utf8_size_t utf8_str_size; \
|
||||
uint8_t utf8_ptr##flags = ECMA_STRING_FLAG_EMPTY; \
|
||||
const lit_utf8_byte_t *utf8_ptr = ecma_string_get_chars (ecma_str_ptr, &utf8_str_size, NULL, NULL, &utf8_ptr##flags);
|
||||
|
||||
/**
|
||||
* Free the cesu-8 string buffer allocated by 'ECMA_STRING_TO_UTF8_STRING'
|
||||
*/
|
||||
#define ECMA_FINALIZE_UTF8_STRING(utf8_ptr, /**< pointer to character buffer */ \
|
||||
utf8_str_size) /**< buffer size */ \
|
||||
if (utf8_ptr ## flags & ECMA_STRING_FLAG_MUST_BE_FREED) \
|
||||
{ \
|
||||
JERRY_ASSERT (utf8_ptr != NULL); \
|
||||
jmem_heap_free_block ((void *) utf8_ptr, utf8_str_size); \
|
||||
utf8_str_size) /**< buffer size */ \
|
||||
if (utf8_ptr##flags & ECMA_STRING_FLAG_MUST_BE_FREED) \
|
||||
{ \
|
||||
JERRY_ASSERT (utf8_ptr != NULL); \
|
||||
jmem_heap_free_block ((void *) utf8_ptr, utf8_str_size); \
|
||||
}
|
||||
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
@ -131,64 +128,54 @@ typedef enum
|
||||
/**
|
||||
* Set an internal property value from pointer.
|
||||
*/
|
||||
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) \
|
||||
((field) = ((ecma_value_t) pointer))
|
||||
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) ((field) = ((ecma_value_t) pointer))
|
||||
|
||||
/**
|
||||
* Set an internal property value from pointer. Pointer can be NULL.
|
||||
*/
|
||||
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) \
|
||||
((field) = ((ecma_value_t) pointer))
|
||||
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) ((field) = ((ecma_value_t) pointer))
|
||||
|
||||
/**
|
||||
* Convert an internal property value to pointer.
|
||||
*/
|
||||
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) \
|
||||
((type *) field)
|
||||
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) ((type *) field)
|
||||
|
||||
/**
|
||||
* Convert an internal property value to pointer. Result can be NULL.
|
||||
*/
|
||||
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) \
|
||||
((type *) field)
|
||||
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) ((type *) field)
|
||||
|
||||
/**
|
||||
* Checks whether an internal property is NULL.
|
||||
*/
|
||||
#define ECMA_IS_INTERNAL_VALUE_NULL(field) \
|
||||
((field) == ((ecma_value_t) NULL))
|
||||
#define ECMA_IS_INTERNAL_VALUE_NULL(field) ((field) == ((ecma_value_t) NULL))
|
||||
|
||||
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
/**
|
||||
* Set an internal property value from pointer.
|
||||
*/
|
||||
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) \
|
||||
ECMA_SET_NON_NULL_POINTER (field, pointer)
|
||||
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) ECMA_SET_NON_NULL_POINTER (field, pointer)
|
||||
|
||||
/**
|
||||
* Set an internal property value from pointer. Pointer can be NULL.
|
||||
*/
|
||||
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) \
|
||||
ECMA_SET_POINTER (field, pointer)
|
||||
#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) ECMA_SET_POINTER (field, pointer)
|
||||
|
||||
/**
|
||||
* Convert an internal property value to pointer.
|
||||
*/
|
||||
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) \
|
||||
ECMA_GET_NON_NULL_POINTER (type, field)
|
||||
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) ECMA_GET_NON_NULL_POINTER (type, field)
|
||||
|
||||
/**
|
||||
* Convert an internal property value to pointer. Result can be NULL.
|
||||
*/
|
||||
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) \
|
||||
ECMA_GET_POINTER (type, field)
|
||||
#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) ECMA_GET_POINTER (type, field)
|
||||
|
||||
/**
|
||||
* Checks whether an internal property is NULL.
|
||||
*/
|
||||
#define ECMA_IS_INTERNAL_VALUE_NULL(field) \
|
||||
((field) == ((ecma_value_t) JMEM_CP_NULL))
|
||||
#define ECMA_IS_INTERNAL_VALUE_NULL(field) ((field) == ((ecma_value_t) JMEM_CP_NULL))
|
||||
|
||||
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
@ -264,7 +251,7 @@ ecma_value_t JERRY_ATTR_PURE ecma_make_extended_primitive_value (const ecma_exte
|
||||
uint32_t type);
|
||||
ecma_integer_value_t JERRY_ATTR_CONST ecma_get_integer_from_value (ecma_value_t value);
|
||||
ecma_number_t JERRY_ATTR_PURE ecma_get_float_from_value (ecma_value_t value);
|
||||
ecma_number_t * ecma_get_pointer_from_float_value (ecma_value_t value);
|
||||
ecma_number_t *ecma_get_pointer_from_float_value (ecma_value_t value);
|
||||
ecma_number_t JERRY_ATTR_PURE ecma_get_number_from_value (ecma_value_t value);
|
||||
ecma_string_t JERRY_ATTR_PURE *ecma_get_string_from_value (ecma_value_t value);
|
||||
#if JERRY_ESNEXT
|
||||
@ -299,14 +286,12 @@ ecma_length_t ecma_op_advance_string_index (ecma_string_t *str_p, ecma_length_t
|
||||
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_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_external_string_from_cesu8 (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size, void *user_p);
|
||||
ecma_string_t *ecma_new_ecma_string_from_code_unit (ecma_char_t code_unit);
|
||||
#if JERRY_ESNEXT
|
||||
ecma_string_t *ecma_new_ecma_string_from_code_units (ecma_char_t first_code_unit, ecma_char_t second_code_unit);
|
||||
@ -331,28 +316,24 @@ void ecma_destroy_ecma_string (ecma_string_t *string_p);
|
||||
ecma_number_t ecma_string_to_number (const ecma_string_t *str_p);
|
||||
uint32_t ecma_string_get_array_index (const ecma_string_t *str_p);
|
||||
|
||||
lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT
|
||||
ecma_string_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT
|
||||
ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t
|
||||
ecma_substring_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_size_t start_pos,
|
||||
lit_utf8_size_t end_pos,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t
|
||||
ecma_substring_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_size_t start_pos,
|
||||
lit_utf8_size_t end_pos,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
void ecma_string_to_utf8_bytes (const ecma_string_t *string_desc_p, lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT ecma_string_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t JERRY_ATTR_WARN_UNUSED_RESULT ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t ecma_substring_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_size_t start_pos,
|
||||
lit_utf8_size_t end_pos,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
lit_utf8_size_t ecma_substring_copy_to_utf8_buffer (const ecma_string_t *string_desc_p,
|
||||
lit_utf8_size_t start_pos,
|
||||
lit_utf8_size_t end_pos,
|
||||
lit_utf8_byte_t *buffer_p,
|
||||
lit_utf8_size_t buffer_size);
|
||||
void
|
||||
ecma_string_to_utf8_bytes (const ecma_string_t *string_desc_p, lit_utf8_byte_t *buffer_p, lit_utf8_size_t buffer_size);
|
||||
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,
|
||||
@ -369,7 +350,8 @@ jmem_cpointer_t ecma_string_to_property_name (ecma_string_t *prop_name_p, ecma_p
|
||||
ecma_string_t *ecma_string_from_property_name (ecma_property_t property, jmem_cpointer_t prop_name_cp);
|
||||
lit_string_hash_t ecma_string_get_property_name_hash (ecma_property_t property, jmem_cpointer_t prop_name_cp);
|
||||
uint32_t ecma_string_get_property_index (ecma_property_t property, jmem_cpointer_t prop_name_cp);
|
||||
bool ecma_string_compare_to_property_name (ecma_property_t property, jmem_cpointer_t prop_name_cp,
|
||||
bool ecma_string_compare_to_property_name (ecma_property_t property,
|
||||
jmem_cpointer_t prop_name_cp,
|
||||
const ecma_string_t *string_p);
|
||||
|
||||
bool ecma_compare_ecma_strings (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
|
||||
@ -387,20 +369,16 @@ lit_string_hash_t ecma_string_hash (const ecma_string_t *string_p);
|
||||
ecma_string_t *ecma_string_substr (const ecma_string_t *string_p, lit_utf8_size_t start_pos, lit_utf8_size_t end_pos);
|
||||
const lit_utf8_byte_t *ecma_string_trim_front (const lit_utf8_byte_t *start_p, const lit_utf8_byte_t *end_p);
|
||||
const lit_utf8_byte_t *ecma_string_trim_back (const lit_utf8_byte_t *start_p, const lit_utf8_byte_t *end_p);
|
||||
void ecma_string_trim_helper (const lit_utf8_byte_t **utf8_str_p,
|
||||
lit_utf8_size_t *utf8_str_size);
|
||||
void ecma_string_trim_helper (const lit_utf8_byte_t **utf8_str_p, lit_utf8_size_t *utf8_str_size);
|
||||
ecma_string_t *ecma_string_trim (const ecma_string_t *string_p);
|
||||
#if JERRY_ESNEXT
|
||||
ecma_value_t ecma_string_pad (ecma_value_t original_string_p,
|
||||
ecma_value_t max_length,
|
||||
ecma_value_t fill_string,
|
||||
bool pad_on_start);
|
||||
ecma_value_t
|
||||
ecma_string_pad (ecma_value_t original_string_p, ecma_value_t max_length, ecma_value_t fill_string, bool pad_on_start);
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
ecma_stringbuilder_t ecma_stringbuilder_create (void);
|
||||
ecma_stringbuilder_t ecma_stringbuilder_create_from (ecma_string_t *string_p);
|
||||
ecma_stringbuilder_t ecma_stringbuilder_create_raw (const lit_utf8_byte_t *data_p,
|
||||
const lit_utf8_size_t data_size);
|
||||
ecma_stringbuilder_t ecma_stringbuilder_create_raw (const lit_utf8_byte_t *data_p, const lit_utf8_size_t data_size);
|
||||
lit_utf8_size_t ecma_stringbuilder_get_size (ecma_stringbuilder_t *builder_p);
|
||||
lit_utf8_byte_t *ecma_stringbuilder_get_data (ecma_stringbuilder_t *builder_p);
|
||||
void ecma_stringbuilder_revert (ecma_stringbuilder_t *builder_p, const lit_utf8_size_t size);
|
||||
@ -425,18 +403,15 @@ bool ecma_number_is_negative (ecma_number_t num);
|
||||
bool ecma_number_is_zero (ecma_number_t num);
|
||||
bool ecma_number_is_infinity (ecma_number_t num);
|
||||
bool ecma_number_is_finite (ecma_number_t num);
|
||||
ecma_number_t
|
||||
ecma_number_make_from_sign_mantissa_and_exponent (bool sign, uint64_t mantissa, int32_t exponent);
|
||||
ecma_number_t ecma_number_make_from_sign_mantissa_and_exponent (bool sign, uint64_t mantissa, int32_t exponent);
|
||||
ecma_number_t ecma_number_get_prev (ecma_number_t num);
|
||||
ecma_number_t ecma_number_get_next (ecma_number_t num);
|
||||
ecma_number_t ecma_number_trunc (ecma_number_t num);
|
||||
ecma_number_t ecma_number_calc_remainder (ecma_number_t left_num, ecma_number_t right_num);
|
||||
ecma_number_t ecma_number_pow (ecma_number_t x, ecma_number_t y);
|
||||
ecma_value_t ecma_number_parse_int (const lit_utf8_byte_t *string_buff,
|
||||
lit_utf8_size_t string_buff_size,
|
||||
ecma_value_t radix);
|
||||
ecma_value_t ecma_number_parse_float (const lit_utf8_byte_t *string_buff,
|
||||
lit_utf8_size_t string_buff_size);
|
||||
ecma_value_t
|
||||
ecma_number_parse_int (const lit_utf8_byte_t *string_buff, lit_utf8_size_t string_buff_size, ecma_value_t radix);
|
||||
ecma_value_t ecma_number_parse_float (const lit_utf8_byte_t *string_buff, lit_utf8_size_t string_buff_size);
|
||||
ecma_value_t ecma_integer_multiply (ecma_integer_value_t left_integer, ecma_integer_value_t right_integer);
|
||||
lit_utf8_size_t ecma_number_to_decimal (ecma_number_t num, lit_utf8_byte_t *out_digits_p, int32_t *out_decimal_exp_p);
|
||||
|
||||
@ -476,30 +451,33 @@ ecma_lexical_environment_type_t JERRY_ATTR_PURE ecma_get_lex_env_type (const ecm
|
||||
ecma_object_t JERRY_ATTR_PURE *ecma_get_lex_env_binding_object (const ecma_object_t *object_p);
|
||||
ecma_object_t *ecma_clone_decl_lexical_environment (ecma_object_t *lex_env_p, bool copy_values);
|
||||
|
||||
ecma_property_value_t *
|
||||
ecma_create_named_data_property (ecma_object_t *object_p, ecma_string_t *name_p, uint8_t prop_attributes,
|
||||
ecma_property_t **out_prop_p);
|
||||
ecma_property_value_t *
|
||||
ecma_create_named_accessor_property (ecma_object_t *object_p, ecma_string_t *name_p, ecma_object_t *get_p,
|
||||
ecma_object_t *set_p, uint8_t prop_attributes, ecma_property_t **out_prop_p);
|
||||
ecma_property_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);
|
||||
ecma_property_t *ecma_find_named_property (ecma_object_t *obj_p, ecma_string_t *name_p);
|
||||
ecma_property_value_t *ecma_get_named_data_property (ecma_object_t *obj_p, ecma_string_t *name_p);
|
||||
|
||||
void ecma_delete_property (ecma_object_t *object_p, ecma_property_value_t *prop_value_p);
|
||||
|
||||
void ecma_named_data_property_assign_value (ecma_object_t *obj_p, ecma_property_value_t *prop_value_p,
|
||||
ecma_value_t value);
|
||||
void
|
||||
ecma_named_data_property_assign_value (ecma_object_t *obj_p, ecma_property_value_t *prop_value_p, ecma_value_t value);
|
||||
|
||||
ecma_getter_setter_pointers_t *
|
||||
ecma_get_named_accessor_property (const ecma_property_value_t *prop_value_p);
|
||||
void ecma_set_named_accessor_property_getter (ecma_object_t *object_p, ecma_property_value_t *prop_value_p,
|
||||
ecma_getter_setter_pointers_t *ecma_get_named_accessor_property (const ecma_property_value_t *prop_value_p);
|
||||
void ecma_set_named_accessor_property_getter (ecma_object_t *object_p,
|
||||
ecma_property_value_t *prop_value_p,
|
||||
ecma_object_t *getter_p);
|
||||
void ecma_set_named_accessor_property_setter (ecma_object_t *object_p, ecma_property_value_t *prop_value_p,
|
||||
void ecma_set_named_accessor_property_setter (ecma_object_t *object_p,
|
||||
ecma_property_value_t *prop_value_p,
|
||||
ecma_object_t *setter_p);
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
ecma_value_t ecma_property_to_reference (ecma_property_t *property_p);
|
||||
@ -549,15 +527,15 @@ uintptr_t ecma_get_current_stack_usage (void);
|
||||
#endif /* (JERRY_STACK_LIMIT != 0) */
|
||||
|
||||
/* ecma-helpers-external-pointers.c */
|
||||
bool ecma_create_native_pointer_property (ecma_object_t *obj_p, void *native_p,
|
||||
bool ecma_create_native_pointer_property (ecma_object_t *obj_p,
|
||||
void *native_p,
|
||||
const jerry_object_native_info_t *native_info_p);
|
||||
ecma_native_pointer_t *ecma_get_native_pointer_value (ecma_object_t *obj_p,
|
||||
const jerry_object_native_info_t *native_info_p);
|
||||
bool ecma_delete_native_pointer_property (ecma_object_t *obj_p, const jerry_object_native_info_t *native_info_p);
|
||||
|
||||
/* ecma-helpers-conversion.c */
|
||||
ecma_number_t ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, lit_utf8_size_t str_size,
|
||||
uint32_t option);
|
||||
ecma_number_t ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, lit_utf8_size_t str_size, uint32_t option);
|
||||
lit_utf8_size_t ecma_uint32_to_utf8_string (uint32_t value, lit_utf8_byte_t *out_buffer_p, lit_utf8_size_t buffer_size);
|
||||
uint32_t ecma_number_to_uint32 (ecma_number_t num);
|
||||
int32_t ecma_number_to_int32 (ecma_number_t num);
|
||||
|
||||
@ -13,14 +13,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-init-finalize.h"
|
||||
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-init-finalize.h"
|
||||
#include "ecma-lex-env.h"
|
||||
#include "ecma-literal-storage.h"
|
||||
#include "jmem.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jmem.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@ -89,8 +91,7 @@ ecma_finalize (void)
|
||||
{
|
||||
jerry_fatal (ERR_UNTERMINATED_GC_LOOPS);
|
||||
}
|
||||
}
|
||||
while (JERRY_CONTEXT (ecma_gc_new_objects) != 0);
|
||||
} while (JERRY_CONTEXT (ecma_gc_new_objects) != 0);
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
jmem_cpointer_t *global_symbols_cp = JERRY_CONTEXT (global_symbols_cp);
|
||||
|
||||
@ -13,10 +13,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-lcache.h"
|
||||
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lcache.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@ -98,7 +100,7 @@ ecma_lcache_insert (const ecma_object_t *object_p, /**< object */
|
||||
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
|
||||
|
||||
size_t row_index = ecma_lcache_row_index (object_cp, name_cp);
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index];
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache)[row_index];
|
||||
ecma_lcache_hash_entry_t *entry_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH;
|
||||
|
||||
do
|
||||
@ -109,8 +111,7 @@ ecma_lcache_insert (const ecma_object_t *object_p, /**< object */
|
||||
}
|
||||
|
||||
entry_p++;
|
||||
}
|
||||
while (entry_p < entry_end_p);
|
||||
} while (entry_p < entry_end_p);
|
||||
|
||||
/* Invalidate the last entry. */
|
||||
ecma_lcache_invalidate_entry (--entry_p);
|
||||
@ -136,7 +137,7 @@ insert:
|
||||
* @return a pointer to an ecma_property_t if the lookup is successful
|
||||
* NULL otherwise
|
||||
*/
|
||||
extern inline ecma_property_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
extern inline ecma_property_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
|
||||
const ecma_string_t *prop_name_p) /**< property's name */
|
||||
{
|
||||
@ -161,7 +162,7 @@ ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
|
||||
|
||||
size_t row_index = ecma_lcache_row_index (object_cp, prop_name_cp);
|
||||
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index];
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache)[row_index];
|
||||
ecma_lcache_hash_entry_t *entry_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH;
|
||||
ecma_lcache_hash_entry_id_t id = ECMA_LCACHE_CREATE_ID (object_cp, prop_name_cp);
|
||||
|
||||
@ -173,8 +174,7 @@ ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
|
||||
return entry_p->prop_p;
|
||||
}
|
||||
entry_p++;
|
||||
}
|
||||
while (entry_p < entry_end_p);
|
||||
} while (entry_p < entry_end_p);
|
||||
|
||||
return NULL;
|
||||
} /* ecma_lcache_lookup */
|
||||
@ -195,12 +195,12 @@ ecma_lcache_invalidate (const ecma_object_t *object_p, /**< object */
|
||||
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
|
||||
|
||||
size_t row_index = ecma_lcache_row_index (object_cp, name_cp);
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache) [row_index];
|
||||
ecma_lcache_hash_entry_t *entry_p = JERRY_CONTEXT (lcache)[row_index];
|
||||
|
||||
while (true)
|
||||
{
|
||||
/* The property must be present. */
|
||||
JERRY_ASSERT (entry_p - JERRY_CONTEXT (lcache) [row_index] < ECMA_LCACHE_HASH_ROW_LENGTH);
|
||||
JERRY_ASSERT (entry_p - JERRY_CONTEXT (lcache)[row_index] < ECMA_LCACHE_HASH_ROW_LENGTH);
|
||||
|
||||
if (entry_p->id != 0 && entry_p->prop_p == prop_p)
|
||||
{
|
||||
|
||||
@ -23,6 +23,8 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
#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);
|
||||
|
||||
@ -13,9 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-line-info.h"
|
||||
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#if JERRY_LINE_INFO
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@ -45,8 +46,7 @@ ecma_line_info_decode_vlq (uint8_t **buffer_p) /**< [in/out] target buffer */
|
||||
do
|
||||
{
|
||||
value = (value << ECMA_LINE_INFO_VLQ_SHIFT) | (*source_p & ECMA_LINE_INFO_VLQ_MASK);
|
||||
}
|
||||
while (*source_p++ & ECMA_LINE_INFO_VLQ_CONTINUE);
|
||||
} while (*source_p++ & ECMA_LINE_INFO_VLQ_CONTINUE);
|
||||
|
||||
*buffer_p = source_p;
|
||||
return value;
|
||||
@ -169,8 +169,7 @@ ecma_line_info_get (uint8_t *line_info_p, /**< line info buffer */
|
||||
column = ecma_line_info_difference_update (column, value);
|
||||
|
||||
end_offset += end_offset_increase;
|
||||
}
|
||||
while (end_offset_increase != 0 && end_offset <= offset);
|
||||
} while (end_offset_increase != 0 && end_offset <= offset);
|
||||
|
||||
location_p->line = line;
|
||||
location_p->column = column;
|
||||
|
||||
@ -90,8 +90,7 @@
|
||||
/**
|
||||
* 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)
|
||||
#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);
|
||||
@ -99,8 +98,7 @@ uint32_t ecma_line_info_difference_update (uint32_t current_value, uint32_t diff
|
||||
|
||||
/* 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_backtrace_location_t *location_p);
|
||||
void ecma_line_info_get (uint8_t *line_info_p, uint32_t offset, jerry_backtrace_location_t *location_p);
|
||||
|
||||
#if JERRY_PARSER_DUMP_BYTE_CODE
|
||||
void ecma_line_info_dump (uint8_t *line_info_p);
|
||||
|
||||
@ -13,11 +13,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-bigint.h"
|
||||
#include "ecma-big-uint.h"
|
||||
#include "ecma-literal-storage.h"
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-big-uint.h"
|
||||
#include "ecma-bigint.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@ -42,8 +44,7 @@ ecma_free_symbol_list (jmem_cpointer_t symbol_list_cp) /**< symbol list */
|
||||
{
|
||||
if (symbol_list_p->values[i] != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
symbol_list_p->values[i]);
|
||||
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, symbol_list_p->values[i]);
|
||||
|
||||
JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (string_p));
|
||||
ecma_deref_ecma_string (string_p);
|
||||
@ -71,8 +72,7 @@ ecma_free_string_list (jmem_cpointer_t string_list_cp) /**< string list */
|
||||
{
|
||||
if (string_list_p->values[i] != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
string_list_p->values[i]);
|
||||
ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, string_list_p->values[i]);
|
||||
|
||||
JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (string_p));
|
||||
ecma_destroy_ecma_string (string_p);
|
||||
@ -93,8 +93,7 @@ ecma_free_number_list (jmem_cpointer_t number_list_cp) /**< number list */
|
||||
{
|
||||
while (number_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
|
||||
number_list_cp);
|
||||
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, number_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
@ -120,15 +119,14 @@ ecma_free_bigint_list (jmem_cpointer_t bigint_list_cp) /**< bigint list */
|
||||
{
|
||||
while (bigint_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
|
||||
bigint_list_cp);
|
||||
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, bigint_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
if (bigint_list_p->values[i] != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_extended_primitive_t *bigint_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t,
|
||||
bigint_list_p->values[i]);
|
||||
ecma_extended_primitive_t *bigint_p =
|
||||
JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t, bigint_list_p->values[i]);
|
||||
JERRY_ASSERT (ECMA_EXTENDED_PRIMITIVE_IS_REF_EQUALS_TO_ONE (bigint_p));
|
||||
ecma_deref_bigint (bigint_p);
|
||||
}
|
||||
@ -168,8 +166,8 @@ ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, /**< string
|
||||
lit_utf8_size_t size, /**< size of the string */
|
||||
bool is_ascii) /**< encode 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 =
|
||||
(is_ascii ? ecma_new_ecma_string_from_ascii (chars_p, size) : ecma_new_ecma_string_from_utf8 (chars_p, size));
|
||||
|
||||
if (ECMA_IS_DIRECT_STRING (string_p))
|
||||
{
|
||||
@ -194,8 +192,7 @@ ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, /**< string
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_string_t *value_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
string_list_p->values[i]);
|
||||
ecma_string_t *value_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, string_list_p->values[i]);
|
||||
|
||||
if (ecma_compare_ecma_strings (string_p, value_p))
|
||||
{
|
||||
@ -256,8 +253,7 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
|
||||
|
||||
while (number_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
|
||||
number_list_cp);
|
||||
ecma_lit_storage_item_t *number_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, number_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
@ -270,8 +266,7 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_number_t *number_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_t,
|
||||
number_list_p->values[i]);
|
||||
ecma_number_t *number_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_number_t, number_list_p->values[i]);
|
||||
|
||||
if (*number_p == number_arg)
|
||||
{
|
||||
@ -330,8 +325,7 @@ ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searc
|
||||
|
||||
while (bigint_list_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
|
||||
bigint_list_cp);
|
||||
ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t, bigint_list_cp);
|
||||
|
||||
for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
{
|
||||
@ -344,8 +338,8 @@ ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searc
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_extended_primitive_t *other_bigint_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t,
|
||||
bigint_list_p->values[i]);
|
||||
ecma_extended_primitive_t *other_bigint_p =
|
||||
JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t, bigint_list_p->values[i]);
|
||||
ecma_value_t other_bigint = ecma_make_extended_primitive_value (other_bigint_p, ECMA_TYPE_BIGINT);
|
||||
|
||||
if (ecma_bigint_is_equal_to_bigint (bigint, other_bigint))
|
||||
@ -417,8 +411,9 @@ ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searc
|
||||
/**
|
||||
* Append the value at the end of the appropriate list if it is not present there.
|
||||
*/
|
||||
void ecma_save_literals_append_value (ecma_value_t value, /**< value to be appended */
|
||||
ecma_collection_t *lit_pool_p) /**< list of known values */
|
||||
void
|
||||
ecma_save_literals_append_value (ecma_value_t value, /**< value to be appended */
|
||||
ecma_collection_t *lit_pool_p) /**< list of known values */
|
||||
{
|
||||
/* Unlike direct numbers, direct strings are converted to character literals. */
|
||||
if (!ecma_is_value_string (value)
|
||||
@ -498,11 +493,9 @@ ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_
|
||||
|
||||
for (uint32_t i = const_literal_end; i < literal_end; i++)
|
||||
{
|
||||
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
|
||||
literal_p[i]);
|
||||
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t, literal_p[i]);
|
||||
|
||||
if (CBC_IS_FUNCTION (bytecode_p->status_flags)
|
||||
&& bytecode_p != compiled_code_p)
|
||||
if (CBC_IS_FUNCTION (bytecode_p->status_flags) && bytecode_p != compiled_code_p)
|
||||
{
|
||||
ecma_save_literals_add_compiled_code (bytecode_p, lit_pool_p);
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#define ECMA_LIT_STORAGE_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "jmem.h"
|
||||
#include "lit-globals.h"
|
||||
|
||||
@ -48,18 +49,19 @@ ecma_value_t ecma_find_or_create_literal_bigint (ecma_value_t bigint);
|
||||
|
||||
#if JERRY_SNAPSHOT_SAVE
|
||||
void ecma_save_literals_append_value (ecma_value_t value, ecma_collection_t *lit_pool_p);
|
||||
void ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_p,
|
||||
ecma_collection_t *lit_pool_p);
|
||||
bool ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p, uint32_t *buffer_p, size_t buffer_size,
|
||||
size_t *in_out_buffer_offset_p, lit_mem_to_snapshot_id_map_entry_t **out_map_p,
|
||||
void ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, ecma_collection_t *lit_pool_p);
|
||||
bool ecma_save_literals_for_snapshot (ecma_collection_t *lit_pool_p,
|
||||
uint32_t *buffer_p,
|
||||
size_t buffer_size,
|
||||
size_t *in_out_buffer_offset_p,
|
||||
lit_mem_to_snapshot_id_map_entry_t **out_map_p,
|
||||
uint32_t *out_map_len_p);
|
||||
#endif /* JERRY_SNAPSHOT_SAVE */
|
||||
|
||||
#if JERRY_SNAPSHOT_EXEC || JERRY_SNAPSHOT_SAVE
|
||||
ecma_value_t
|
||||
ecma_snapshot_get_literal (const uint8_t *literal_base_p, ecma_value_t literal_value);
|
||||
ecma_value_t *
|
||||
ecma_snapshot_resolve_serializable_values (const ecma_compiled_code_t *compiled_code_p, uint8_t *byte_code_end_p);
|
||||
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 */
|
||||
|
||||
/**
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "ecma-module.h"
|
||||
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
@ -21,8 +21,9 @@
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lex-env.h"
|
||||
#include "ecma-module.h"
|
||||
#include "ecma-objects.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "vm.h"
|
||||
|
||||
@ -104,15 +105,15 @@ ecma_module_set_error_state (ecma_module_t *module_p) /**< module */
|
||||
{
|
||||
module_p->header.u.cls.u1.module_state = JERRY_MODULE_STATE_ERROR;
|
||||
|
||||
if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL
|
||||
&& !jcontext_has_pending_abort ())
|
||||
if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL && !jcontext_has_pending_abort ())
|
||||
{
|
||||
jerry_value_t exception = jcontext_take_exception ();
|
||||
|
||||
JERRY_CONTEXT (module_state_changed_callback_p) (JERRY_MODULE_STATE_ERROR,
|
||||
ecma_make_object_value (&module_p->header.object),
|
||||
exception,
|
||||
JERRY_CONTEXT (module_state_changed_callback_user_p));
|
||||
JERRY_CONTEXT (module_state_changed_callback_p)
|
||||
(JERRY_MODULE_STATE_ERROR,
|
||||
ecma_make_object_value (&module_p->header.object),
|
||||
exception,
|
||||
JERRY_CONTEXT (module_state_changed_callback_user_p));
|
||||
jcontext_raise_exception (exception);
|
||||
}
|
||||
} /* ecma_module_set_error_state */
|
||||
@ -122,7 +123,7 @@ ecma_module_set_error_state (ecma_module_t *module_p) /**< module */
|
||||
*
|
||||
* @return module pointer
|
||||
*/
|
||||
static inline ecma_module_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
static inline ecma_module_t *JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_module_get_from_object (ecma_value_t module_val) /**< module */
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_object (module_val));
|
||||
@ -210,8 +211,7 @@ ecma_module_resolve_set_append (ecma_module_resolve_set_t *set_p, /**< resolve s
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (current_p->module_p == module_p
|
||||
&& ecma_compare_ecma_strings (current_p->name_p, export_name_p))
|
||||
if (current_p->module_p == module_p && ecma_compare_ecma_strings (current_p->name_p, export_name_p))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -339,16 +339,14 @@ ecma_module_resolve_import (ecma_module_resolve_result_t *resolve_result_p, /**<
|
||||
{
|
||||
JERRY_ASSERT (import_node_p != NULL);
|
||||
|
||||
for (ecma_module_names_t *import_names_p = import_node_p->module_names_p;
|
||||
import_names_p != NULL;
|
||||
for (ecma_module_names_t *import_names_p = import_node_p->module_names_p; import_names_p != NULL;
|
||||
import_names_p = import_names_p->next_p)
|
||||
{
|
||||
if (ecma_compare_ecma_strings (local_name_p, import_names_p->local_name_p))
|
||||
{
|
||||
ecma_module_t *imported_module_p = ecma_module_get_from_object (import_node_p->u.path_or_module);
|
||||
|
||||
if (ecma_compare_ecma_string_to_magic_id (import_names_p->imex_name_p,
|
||||
LIT_MAGIC_STRING_ASTERIX_CHAR))
|
||||
if (ecma_compare_ecma_string_to_magic_id (import_names_p->imex_name_p, LIT_MAGIC_STRING_ASTERIX_CHAR))
|
||||
{
|
||||
/* Namespace import. */
|
||||
ecma_value_t namespace = ecma_make_object_value (imported_module_p->namespace_object_p);
|
||||
@ -401,19 +399,18 @@ ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */
|
||||
|
||||
if (current_module_p->header.u.cls.u2.module_flags & ECMA_MODULE_HAS_NAMESPACE)
|
||||
{
|
||||
ecma_property_t *property_p = ecma_find_named_property (current_module_p->namespace_object_p,
|
||||
current_export_name_p);
|
||||
ecma_property_t *property_p =
|
||||
ecma_find_named_property (current_module_p->namespace_object_p, current_export_name_p);
|
||||
|
||||
if (property_p != NULL)
|
||||
{
|
||||
ecma_property_value_t *property_value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
|
||||
|
||||
JERRY_ASSERT ((!(*property_p & ECMA_PROPERTY_FLAG_DATA)
|
||||
&& !(property_value_p->value & ECMA_MODULE_NAMESPACE_RESULT_FLAG))
|
||||
|| ((*property_p & ECMA_PROPERTY_FLAG_DATA)
|
||||
&& ecma_is_value_object (property_value_p->value)
|
||||
&& ecma_object_class_is (ecma_get_object_from_value (property_value_p->value),
|
||||
ECMA_OBJECT_CLASS_MODULE_NAMESPACE)));
|
||||
JERRY_ASSERT (
|
||||
(!(*property_p & ECMA_PROPERTY_FLAG_DATA) && !(property_value_p->value & ECMA_MODULE_NAMESPACE_RESULT_FLAG))
|
||||
|| ((*property_p & ECMA_PROPERTY_FLAG_DATA) && ecma_is_value_object (property_value_p->value)
|
||||
&& ecma_object_class_is (ecma_get_object_from_value (property_value_p->value),
|
||||
ECMA_OBJECT_CLASS_MODULE_NAMESPACE)));
|
||||
|
||||
if (!ecma_module_resolve_update (resolve_result_p, property_value_p->value))
|
||||
{
|
||||
@ -432,8 +429,8 @@ ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */
|
||||
{
|
||||
if (ecma_compare_ecma_strings (current_export_name_p, export_names_p->imex_name_p))
|
||||
{
|
||||
ecma_property_t *property_p = ecma_find_named_property (current_module_p->scope_p,
|
||||
export_names_p->local_name_p);
|
||||
ecma_property_t *property_p =
|
||||
ecma_find_named_property (current_module_p->scope_p, export_names_p->local_name_p);
|
||||
|
||||
if (property_p != NULL)
|
||||
{
|
||||
@ -473,8 +470,7 @@ ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */
|
||||
{
|
||||
ecma_module_t *target_module_p = ecma_module_get_from_object (*indirect_export_p->u.module_object_p);
|
||||
|
||||
if (ecma_compare_ecma_string_to_magic_id (export_names_p->local_name_p,
|
||||
LIT_MAGIC_STRING_ASTERIX_CHAR))
|
||||
if (ecma_compare_ecma_string_to_magic_id (export_names_p->local_name_p, LIT_MAGIC_STRING_ASTERIX_CHAR))
|
||||
{
|
||||
/* Namespace export. */
|
||||
ecma_value_t namespace = ecma_make_object_value (target_module_p->namespace_object_p);
|
||||
@ -525,10 +521,9 @@ ecma_module_resolve_export (ecma_module_t *const module_p, /**< base module */
|
||||
star_export_p = star_export_p->next_p;
|
||||
}
|
||||
|
||||
next_iteration:
|
||||
next_iteration:
|
||||
current_set_p = current_set_p->next_p;
|
||||
}
|
||||
while (current_set_p != NULL);
|
||||
} while (current_set_p != NULL);
|
||||
|
||||
exit:
|
||||
ecma_module_resolve_set_cleanup (resolve_set_p);
|
||||
@ -586,10 +581,11 @@ ecma_module_evaluate (ecma_module_t *module_p) /**< module */
|
||||
|
||||
if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL)
|
||||
{
|
||||
JERRY_CONTEXT (module_state_changed_callback_p) (JERRY_MODULE_STATE_EVALUATED,
|
||||
ecma_make_object_value (&module_p->header.object),
|
||||
ret_value,
|
||||
JERRY_CONTEXT (module_state_changed_callback_user_p));
|
||||
JERRY_CONTEXT (module_state_changed_callback_p)
|
||||
(JERRY_MODULE_STATE_EVALUATED,
|
||||
ecma_make_object_value (&module_p->header.object),
|
||||
ret_value,
|
||||
JERRY_CONTEXT (module_state_changed_callback_user_p));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -746,8 +742,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
#if JERRY_PROPERTY_HASHMAP
|
||||
if (prop_iter_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
prop_iter_cp);
|
||||
ecma_property_header_t *prop_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, prop_iter_cp);
|
||||
if (prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
|
||||
{
|
||||
prop_iter_cp = prop_iter_p->next_property_cp;
|
||||
@ -802,8 +797,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
}
|
||||
|
||||
export_names_p = export_names_p->next_p;
|
||||
}
|
||||
while (export_names_p != NULL);
|
||||
} while (export_names_p != NULL);
|
||||
}
|
||||
|
||||
ecma_module_node_t *indirect_export_p = current_module_p->indirect_exports_p;
|
||||
@ -848,8 +842,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
}
|
||||
|
||||
current_set_p = current_set_p->next_p;
|
||||
}
|
||||
while (current_set_p != NULL);
|
||||
} while (current_set_p != NULL);
|
||||
|
||||
ecma_value_t *buffer_p = properties_p->buffer_p;
|
||||
uint32_t item_count = properties_p->item_count;
|
||||
@ -863,8 +856,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
{
|
||||
end -= 2;
|
||||
ecma_module_heap_sort_shift_down (buffer_p, item_count, end);
|
||||
}
|
||||
while (end > 0);
|
||||
} while (end > 0);
|
||||
|
||||
end = item_count - 2;
|
||||
|
||||
@ -880,8 +872,7 @@ ecma_module_create_namespace_object (ecma_module_t *module_p) /**< module */
|
||||
|
||||
ecma_module_heap_sort_shift_down (buffer_p, end, 0);
|
||||
end -= 2;
|
||||
}
|
||||
while (end > 0);
|
||||
} while (end > 0);
|
||||
}
|
||||
|
||||
ecma_value_t *buffer_end_p = properties_p->buffer_p + item_count;
|
||||
@ -989,15 +980,12 @@ ecma_module_connect_imports (ecma_module_t *module_p)
|
||||
|
||||
while (import_names_p != NULL)
|
||||
{
|
||||
if (ecma_compare_ecma_string_to_magic_id (import_names_p->imex_name_p,
|
||||
LIT_MAGIC_STRING_ASTERIX_CHAR))
|
||||
if (ecma_compare_ecma_string_to_magic_id (import_names_p->imex_name_p, LIT_MAGIC_STRING_ASTERIX_CHAR))
|
||||
{
|
||||
/* Namespace import. */
|
||||
ecma_property_value_t *value_p;
|
||||
value_p = ecma_create_named_data_property (module_p->scope_p,
|
||||
import_names_p->local_name_p,
|
||||
ECMA_PROPERTY_FIXED,
|
||||
NULL);
|
||||
value_p =
|
||||
ecma_create_named_data_property (module_p->scope_p, import_names_p->local_name_p, ECMA_PROPERTY_FIXED, NULL);
|
||||
value_p->value = ecma_make_object_value (imported_module_p->namespace_object_p);
|
||||
}
|
||||
else
|
||||
@ -1021,9 +1009,7 @@ ecma_module_connect_imports (ecma_module_t *module_p)
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_create_named_reference_property (module_p->scope_p,
|
||||
import_names_p->local_name_p,
|
||||
resolve_result.result);
|
||||
ecma_create_named_reference_property (module_p->scope_p, import_names_p->local_name_p, resolve_result.result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1253,9 +1239,8 @@ restart:
|
||||
|
||||
if (current_module_p->namespace_object_p == NULL)
|
||||
{
|
||||
ecma_object_t *namespace_object_p = ecma_create_object (NULL,
|
||||
sizeof (ecma_extended_object_t),
|
||||
ECMA_OBJECT_TYPE_CLASS);
|
||||
ecma_object_t *namespace_object_p =
|
||||
ecma_create_object (NULL, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS);
|
||||
|
||||
namespace_object_p->type_flags_refs &= (ecma_object_descriptor_t) ~ECMA_OBJECT_FLAG_EXTENSIBLE;
|
||||
|
||||
@ -1297,8 +1282,7 @@ restart:
|
||||
}
|
||||
|
||||
iterator_p = iterator_p->prev_p;
|
||||
}
|
||||
while (iterator_p != end_p);
|
||||
} while (iterator_p != end_p);
|
||||
|
||||
iterator_p = last_p;
|
||||
|
||||
@ -1313,8 +1297,7 @@ restart:
|
||||
}
|
||||
|
||||
iterator_p = iterator_p->prev_p;
|
||||
}
|
||||
while (iterator_p != end_p);
|
||||
} while (iterator_p != end_p);
|
||||
|
||||
do
|
||||
{
|
||||
@ -1325,16 +1308,16 @@ restart:
|
||||
|
||||
if (JERRY_CONTEXT (module_state_changed_callback_p) != NULL)
|
||||
{
|
||||
JERRY_CONTEXT (module_state_changed_callback_p) (JERRY_MODULE_STATE_LINKED,
|
||||
ecma_make_object_value (&last_p->module_p->header.object),
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
JERRY_CONTEXT (module_state_changed_callback_user_p));
|
||||
JERRY_CONTEXT (module_state_changed_callback_p)
|
||||
(JERRY_MODULE_STATE_LINKED,
|
||||
ecma_make_object_value (&last_p->module_p->header.object),
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
JERRY_CONTEXT (module_state_changed_callback_user_p));
|
||||
}
|
||||
|
||||
jmem_heap_free_block (last_p, sizeof (ecma_module_stack_item_t));
|
||||
last_p = prev_p;
|
||||
}
|
||||
while (last_p != end_p);
|
||||
} while (last_p != end_p);
|
||||
|
||||
if (current_p == NULL)
|
||||
{
|
||||
@ -1357,8 +1340,7 @@ error:
|
||||
|
||||
jmem_heap_free_block (last_p, sizeof (ecma_module_stack_item_t));
|
||||
last_p = prev_p;
|
||||
}
|
||||
while (last_p != NULL);
|
||||
} while (last_p != NULL);
|
||||
|
||||
return ECMA_VALUE_ERROR;
|
||||
} /* ecma_module_link */
|
||||
@ -1397,8 +1379,7 @@ ecma_module_import (ecma_value_t specifier, /**< module specifier */
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (ecma_is_value_object (result)
|
||||
&& ecma_is_promise (ecma_get_object_from_value (result)))
|
||||
if (ecma_is_value_object (result) && ecma_is_promise (ecma_get_object_from_value (result)))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -16,9 +16,10 @@
|
||||
#ifndef ECMA_MODULE_H
|
||||
#define ECMA_MODULE_H
|
||||
|
||||
#include "common.h"
|
||||
#include "ecma-globals.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#if JERRY_MODULE_SYSTEM
|
||||
|
||||
#define ECMA_MODULE_MAX_PATH 255u
|
||||
@ -40,8 +41,8 @@ typedef enum
|
||||
typedef struct ecma_module_names
|
||||
{
|
||||
struct ecma_module_names *next_p; /**< next linked list node */
|
||||
ecma_string_t *imex_name_p; /**< Import/export name of the item */
|
||||
ecma_string_t *local_name_p; /**< Local name of the item */
|
||||
ecma_string_t *imex_name_p; /**< Import/export name of the item */
|
||||
ecma_string_t *local_name_p; /**< Local name of the item */
|
||||
} ecma_module_names_t;
|
||||
|
||||
/**
|
||||
@ -54,19 +55,19 @@ typedef struct ecma_module_names
|
||||
typedef struct ecma_module
|
||||
{
|
||||
/* Note: state is stored in header.u.class_prop.extra_info */
|
||||
ecma_extended_object_t header; /**< header part */
|
||||
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 */
|
||||
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 */
|
||||
ecma_compiled_code_t *compiled_code_p; /**< compiled code for the module */
|
||||
jerry_native_module_evaluate_callback_t callback; /**< callback for evaluating native modules */
|
||||
} u;
|
||||
} ecma_module_t;
|
||||
@ -98,8 +99,8 @@ typedef struct ecma_module_node
|
||||
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_t *module_p; /**< module */
|
||||
ecma_string_t *name_p; /**< identifier name */
|
||||
} ecma_module_resolve_set_t;
|
||||
|
||||
/**
|
||||
@ -108,17 +109,15 @@ typedef struct ecma_module_resolve_set
|
||||
typedef struct ecma_module_resolve_stack
|
||||
{
|
||||
struct ecma_module_resolve_stack *next_p; /**< next in linked list */
|
||||
ecma_module_t *module_p; /**< module request */
|
||||
ecma_string_t *export_name_p; /**< export identifier name */
|
||||
bool resolving; /**< flag storing wether the current frame started resolving */
|
||||
ecma_module_t *module_p; /**< module request */
|
||||
ecma_string_t *export_name_p; /**< export identifier name */
|
||||
bool resolving; /**< flag storing wether the current frame started resolving */
|
||||
} ecma_module_resolve_stack_t;
|
||||
|
||||
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_callback_t callback_p,
|
||||
void *user_p);
|
||||
ecma_value_t ecma_module_link (ecma_module_t *module_p, jerry_module_resolve_callback_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);
|
||||
|
||||
|
||||
@ -13,11 +13,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-property-hashmap.h"
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-property-hashmap.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt-libc-includes.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@ -42,28 +44,26 @@
|
||||
/**
|
||||
* Stepping values for searching items in the hashmap.
|
||||
*/
|
||||
static const uint8_t ecma_property_hashmap_steps[ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS] JERRY_ATTR_CONST_DATA =
|
||||
{
|
||||
static const uint8_t ecma_property_hashmap_steps[ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS] JERRY_ATTR_CONST_DATA = {
|
||||
3, 5, 7, 11, 13, 17, 19, 23
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the value of a bit in a bitmap.
|
||||
*/
|
||||
#define ECMA_PROPERTY_HASHMAP_GET_BIT(byte_p, index) \
|
||||
((byte_p)[(index) >> 3] & (1 << ((index) & 0x7)))
|
||||
#define ECMA_PROPERTY_HASHMAP_GET_BIT(byte_p, index) ((byte_p)[(index) >> 3] & (1 << ((index) &0x7)))
|
||||
|
||||
/**
|
||||
* Clear the value of a bit in a bitmap.
|
||||
*/
|
||||
#define ECMA_PROPERTY_HASHMAP_CLEAR_BIT(byte_p, index) \
|
||||
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] & ~(1 << ((index) & 0x7))))
|
||||
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] & ~(1 << ((index) &0x7))))
|
||||
|
||||
/**
|
||||
* Set the value of a bit in a bitmap.
|
||||
*/
|
||||
#define ECMA_PROPERTY_HASHMAP_SET_BIT(byte_p, index) \
|
||||
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] | (1 << ((index) & 0x7))))
|
||||
((byte_p)[(index) >> 3] = (uint8_t) ((byte_p)[(index) >> 3] | (1 << ((index) &0x7))))
|
||||
|
||||
/**
|
||||
* Create a new property hashmap for the object.
|
||||
@ -156,8 +156,7 @@ ecma_property_hashmap_create (ecma_object_t *object_p) /**< object */
|
||||
|
||||
ecma_property_pair_t *property_pair_p = (ecma_property_pair_t *) prop_iter_p;
|
||||
|
||||
uint32_t entry_index = ecma_string_get_property_name_hash (prop_iter_p->types[i],
|
||||
property_pair_p->names_cp[i]);
|
||||
uint32_t entry_index = ecma_string_get_property_name_hash (prop_iter_p->types[i], property_pair_p->names_cp[i]);
|
||||
uint32_t step = ecma_property_hashmap_steps[entry_index & (ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS - 1)];
|
||||
|
||||
entry_index &= mask;
|
||||
@ -202,8 +201,8 @@ ecma_property_hashmap_free (ecma_object_t *object_p) /**< object */
|
||||
/* Property hash must be exists and must be the first property. */
|
||||
JERRY_ASSERT (object_p->u1.property_list_cp != JMEM_CP_NULL);
|
||||
|
||||
ecma_property_header_t *property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
object_p->u1.property_list_cp);
|
||||
ecma_property_header_t *property_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_header_t, object_p->u1.property_list_cp);
|
||||
|
||||
JERRY_ASSERT (property_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
|
||||
@ -211,8 +210,7 @@ ecma_property_hashmap_free (ecma_object_t *object_p) /**< object */
|
||||
|
||||
object_p->u1.property_list_cp = property_p->next_property_cp;
|
||||
|
||||
jmem_heap_free_block (hashmap_p,
|
||||
ECMA_PROPERTY_HASHMAP_GET_TOTAL_SIZE (hashmap_p->max_property_count));
|
||||
jmem_heap_free_block (hashmap_p, ECMA_PROPERTY_HASHMAP_GET_TOTAL_SIZE (hashmap_p->max_property_count));
|
||||
} /* ecma_property_hashmap_free */
|
||||
|
||||
/**
|
||||
@ -226,8 +224,8 @@ ecma_property_hashmap_insert (ecma_object_t *object_p, /**< object */
|
||||
{
|
||||
JERRY_ASSERT (property_pair_p != NULL);
|
||||
|
||||
ecma_property_hashmap_t *hashmap_p = ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t,
|
||||
object_p->u1.property_list_cp);
|
||||
ecma_property_hashmap_t *hashmap_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t, object_p->u1.property_list_cp);
|
||||
|
||||
JERRY_ASSERT (hashmap_p->header.types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
|
||||
@ -300,8 +298,8 @@ ecma_property_hashmap_delete (ecma_object_t *object_p, /**< object */
|
||||
jmem_cpointer_t name_cp, /**< property name */
|
||||
ecma_property_t *property_p) /**< property */
|
||||
{
|
||||
ecma_property_hashmap_t *hashmap_p = ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t,
|
||||
object_p->u1.property_list_cp);
|
||||
ecma_property_hashmap_t *hashmap_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_hashmap_t, object_p->u1.property_list_cp);
|
||||
|
||||
JERRY_ASSERT (hashmap_p->header.types[0] == ECMA_PROPERTY_TYPE_HASHMAP);
|
||||
|
||||
@ -337,8 +335,8 @@ ecma_property_hashmap_delete (ecma_object_t *object_p, /**< object */
|
||||
offset = 1;
|
||||
}
|
||||
|
||||
ecma_property_pair_t *property_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t,
|
||||
pair_list_p[entry_index]);
|
||||
ecma_property_pair_t *property_pair_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, pair_list_p[entry_index]);
|
||||
|
||||
if ((property_pair_p->header.types + offset) == property_p)
|
||||
{
|
||||
@ -393,9 +391,7 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
|
||||
{
|
||||
if (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[i]))
|
||||
{
|
||||
if (ecma_string_compare_to_property_name (prop_iter_p->types[i],
|
||||
prop_pair_p->names_cp[i],
|
||||
name_p))
|
||||
if (ecma_string_compare_to_property_name (prop_iter_p->types[i], prop_pair_p->names_cp[i], name_p))
|
||||
{
|
||||
/* Property is found */
|
||||
property_found = true;
|
||||
@ -437,8 +433,8 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
|
||||
offset = 1;
|
||||
}
|
||||
|
||||
ecma_property_pair_t *property_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t,
|
||||
pair_list_p[entry_index]);
|
||||
ecma_property_pair_t *property_pair_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, pair_list_p[entry_index]);
|
||||
|
||||
ecma_property_t *property_p = property_pair_p->header.types + offset;
|
||||
|
||||
@ -486,8 +482,8 @@ ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, /**< hashmap */
|
||||
offset = 1;
|
||||
}
|
||||
|
||||
ecma_property_pair_t *property_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t,
|
||||
pair_list_p[entry_index]);
|
||||
ecma_property_pair_t *property_pair_p =
|
||||
ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t, pair_list_p[entry_index]);
|
||||
|
||||
ecma_property_t *property_p = property_pair_p->header.types + offset;
|
||||
|
||||
|
||||
@ -16,6 +16,8 @@
|
||||
#ifndef ECMA_PROPERTY_HASHMAP_H
|
||||
#define ECMA_PROPERTY_HASHMAP_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
*
|
||||
@ -67,12 +69,15 @@ typedef enum
|
||||
|
||||
void ecma_property_hashmap_create (ecma_object_t *object_p);
|
||||
void ecma_property_hashmap_free (ecma_object_t *object_p);
|
||||
void ecma_property_hashmap_insert (ecma_object_t *object_p, ecma_string_t *name_p,
|
||||
ecma_property_pair_t *property_pair_p, int property_index);
|
||||
ecma_property_hashmap_delete_status ecma_property_hashmap_delete (ecma_object_t *object_p, jmem_cpointer_t name_cp,
|
||||
ecma_property_t *property_p);
|
||||
void ecma_property_hashmap_insert (ecma_object_t *object_p,
|
||||
ecma_string_t *name_p,
|
||||
ecma_property_pair_t *property_pair_p,
|
||||
int property_index);
|
||||
ecma_property_hashmap_delete_status
|
||||
ecma_property_hashmap_delete (ecma_object_t *object_p, jmem_cpointer_t name_cp, ecma_property_t *property_p);
|
||||
|
||||
ecma_property_t *ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p, ecma_string_t *name_p,
|
||||
ecma_property_t *ecma_property_hashmap_find (ecma_property_hashmap_t *hashmap_p,
|
||||
ecma_string_t *name_p,
|
||||
jmem_cpointer_t *property_real_name_cp);
|
||||
#endif /* JERRY_PROPERTY_HASHMAP */
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-string-object.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
@ -30,7 +31,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-aggregateerror-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID aggregate_error_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID aggregate_error_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
@ -25,19 +25,13 @@
|
||||
* (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)
|
||||
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)
|
||||
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)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_MESSAGE, LIT_MAGIC_STRING__EMPTY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
@ -14,19 +14,20 @@
|
||||
*/
|
||||
|
||||
#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-builtin-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-iterator-object.h"
|
||||
#include "ecma-array-object.h"
|
||||
#include "jrt.h"
|
||||
#include "ecma-objects.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
@ -34,7 +35,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-aggregateerror.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID aggregate_error
|
||||
#define BUILTIN_UNDERSCORED_ID aggregate_error
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@ -24,21 +24,15 @@
|
||||
/* Number properties:
|
||||
* (property name, number value, writable, enumerable, configurable) */
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
2,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
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)
|
||||
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)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_AGGREGATE_ERROR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
@ -13,11 +13,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-iterator-object.h"
|
||||
#include "ecma-typedarray-object.h"
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
@ -39,7 +39,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-array-iterator-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID array_iterator_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID array_iterator_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@ -130,10 +130,7 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
index = (ecma_length_t) (ecma_get_number_from_value (index_value) + 1);
|
||||
}
|
||||
|
||||
ecma_value_t put_result = ecma_op_object_put (obj_p,
|
||||
prop_name_p,
|
||||
ecma_make_length_value (index),
|
||||
true);
|
||||
ecma_value_t put_result = ecma_op_object_put (obj_p, prop_name_p, ecma_make_length_value (index), true);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_true (put_result));
|
||||
|
||||
@ -183,8 +180,7 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t
|
||||
|
||||
/* 17.b */
|
||||
ecma_value_t entry_array_value;
|
||||
entry_array_value = ecma_create_array_from_iter_element (get_value,
|
||||
ecma_make_length_value (index));
|
||||
entry_array_value = ecma_create_array_from_iter_element (get_value, ecma_make_length_value (index));
|
||||
|
||||
result = ecma_create_iter_result_object (entry_array_value, ECMA_VALUE_FALSE);
|
||||
ecma_free_value (entry_array_value);
|
||||
|
||||
@ -21,9 +21,7 @@
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_ARRAY_ITERATOR_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ARRAY_ITERATOR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-array-prototype-unscopables.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID array_prototype_unscopables
|
||||
#define BUILTIN_UNDERSCORED_ID array_prototype_unscopables
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
@ -21,49 +21,27 @@
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_AT,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_AT, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_COPY_WITHIN,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_COPY_WITHIN, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_ENTRIES,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_ENTRIES, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FILL,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FILL, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FIND,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FIND, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FIND_INDEX,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FIND_INDEX, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FLAT,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FLAT, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FLATMAP,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_FLATMAP, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_INCLUDES,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_INCLUDES, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_KEYS,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_KEYS, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_VALUES,
|
||||
ECMA_VALUE_TRUE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
SIMPLE_VALUE (LIT_MAGIC_STRING_VALUES, ECMA_VALUE_TRUE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE)
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
@ -26,8 +26,9 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-string-object.h"
|
||||
#include "lit-char-helpers.h"
|
||||
|
||||
#include "jrt.h"
|
||||
#include "lit-char-helpers.h"
|
||||
|
||||
#if JERRY_BUILTIN_ARRAY
|
||||
|
||||
@ -45,7 +46,7 @@
|
||||
enum
|
||||
{
|
||||
ECMA_ARRAY_PROTOTYPE_ROUTINE_START = 0,
|
||||
/* Note: these 2 routine ids must be in this order */
|
||||
/* Note: these 2 routine ids must be in this order */
|
||||
#if !JERRY_ESNEXT
|
||||
ECMA_ARRAY_PROTOTYPE_TO_STRING,
|
||||
#endif /* !JERRY_ESNEXT */
|
||||
@ -85,7 +86,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-array-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID array_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID array_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@ -109,15 +110,12 @@ ecma_builtin_array_prototype_helper_set_length (ecma_object_t *object, /**< obje
|
||||
ecma_number_t length) /**< new length */
|
||||
{
|
||||
ecma_value_t length_value = ecma_make_number_value (length);
|
||||
ecma_value_t ret_value = ecma_op_object_put (object,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
|
||||
length_value,
|
||||
true);
|
||||
ecma_value_t ret_value =
|
||||
ecma_op_object_put (object, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), length_value, true);
|
||||
|
||||
ecma_free_value (length_value);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_boolean (ret_value)
|
||||
|| ecma_is_value_empty (ret_value)
|
||||
JERRY_ASSERT (ecma_is_value_boolean (ret_value) || ecma_is_value_empty (ret_value)
|
||||
|| ECMA_IS_VALUE_ERROR (ret_value));
|
||||
return ret_value;
|
||||
} /* ecma_builtin_array_prototype_helper_set_length */
|
||||
@ -202,9 +200,8 @@ ecma_builtin_array_prototype_object_concat (const ecma_value_t args[], /**< argu
|
||||
ecma_length_t new_length = 0;
|
||||
|
||||
/* 5.b - 5.c for this_arg */
|
||||
ecma_value_t concat_this_value = ecma_builtin_helper_array_concat_value (new_array_p,
|
||||
&new_length,
|
||||
ecma_make_object_value (obj_p));
|
||||
ecma_value_t concat_this_value =
|
||||
ecma_builtin_helper_array_concat_value (new_array_p, &new_length, ecma_make_object_value (obj_p));
|
||||
if (ECMA_IS_VALUE_ERROR (concat_this_value))
|
||||
{
|
||||
ecma_deref_object (new_array_p);
|
||||
@ -227,8 +224,8 @@ ecma_builtin_array_prototype_object_concat (const ecma_value_t args[], /**< argu
|
||||
JERRY_ASSERT (ecma_is_value_empty (concat_value));
|
||||
}
|
||||
|
||||
ecma_value_t set_length_value = ecma_builtin_array_prototype_helper_set_length (new_array_p,
|
||||
((ecma_number_t) new_length));
|
||||
ecma_value_t set_length_value =
|
||||
ecma_builtin_array_prototype_helper_set_length (new_array_p, ((ecma_number_t) new_length));
|
||||
if (ECMA_IS_VALUE_ERROR (set_length_value))
|
||||
{
|
||||
ecma_deref_object (new_array_p);
|
||||
@ -279,8 +276,7 @@ ecma_op_array_get_to_string_at_index (ecma_object_t *obj_p, /**< this object */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ecma_is_value_undefined (index_value)
|
||||
|| ecma_is_value_null (index_value))
|
||||
if (ecma_is_value_undefined (index_value) || ecma_is_value_null (index_value))
|
||||
{
|
||||
return ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
|
||||
}
|
||||
@ -370,7 +366,7 @@ static ecma_value_t
|
||||
ecma_builtin_array_prototype_object_pop (ecma_object_t *obj_p, /**< object */
|
||||
ecma_length_t len) /**< object's length */
|
||||
{
|
||||
/* 4. */
|
||||
/* 4. */
|
||||
if (len == 0)
|
||||
{
|
||||
/* 4.a */
|
||||
@ -523,14 +519,12 @@ ecma_builtin_array_prototype_object_reverse (ecma_value_t this_arg, /**< this ar
|
||||
ecma_object_t *obj_p, /**< object */
|
||||
ecma_length_t len) /**< object's length */
|
||||
{
|
||||
|
||||
if (ecma_op_object_is_fast_array (obj_p))
|
||||
{
|
||||
uint32_t middle = (uint32_t) len / 2;
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
if (ext_obj_p->u.array.length_prop_and_hole_count < ECMA_FAST_ARRAY_HOLE_ONE
|
||||
&& len != 0)
|
||||
if (ext_obj_p->u.array.length_prop_and_hole_count < ECMA_FAST_ARRAY_HOLE_ONE && len != 0)
|
||||
{
|
||||
ecma_value_t *buffer_p = ECMA_GET_NON_NULL_POINTER (ecma_value_t, obj_p->u1.property_list_cp);
|
||||
|
||||
@ -674,7 +668,7 @@ ecma_builtin_array_prototype_object_reverse (ecma_value_t this_arg, /**< this ar
|
||||
|
||||
ret_value = ECMA_VALUE_EMPTY;
|
||||
|
||||
clean_up:
|
||||
clean_up:
|
||||
ecma_free_value (upper_value);
|
||||
ecma_free_value (lower_value);
|
||||
ecma_deref_ecma_string (lower_str_p);
|
||||
@ -714,8 +708,7 @@ ecma_builtin_array_prototype_object_shift (ecma_object_t *obj_p, /**< object */
|
||||
{
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
if (ext_obj_p->u.array.length_prop_and_hole_count < ECMA_FAST_ARRAY_HOLE_ONE
|
||||
&& len != 0)
|
||||
if (ext_obj_p->u.array.length_prop_and_hole_count < ECMA_FAST_ARRAY_HOLE_ONE && len != 0)
|
||||
{
|
||||
ecma_value_t *buffer_p = ECMA_GET_NON_NULL_POINTER (ecma_value_t, obj_p->u1.property_list_cp);
|
||||
ecma_value_t ret_value = buffer_p[0];
|
||||
@ -817,9 +810,7 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t arg1, /**< start */
|
||||
ecma_length_t start = 0, end = len;
|
||||
|
||||
/* 5. 6.*/
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (arg1,
|
||||
len,
|
||||
&start)))
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (arg1, len, &start)))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
@ -832,9 +823,7 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t arg1, /**< start */
|
||||
else
|
||||
{
|
||||
/* 7. part 2, 8.*/
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (arg2,
|
||||
len,
|
||||
&end)))
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (arg2, len, &end)))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
@ -946,10 +935,7 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t arg1, /**< start */
|
||||
#else /* !JERRY_ESNEXT */
|
||||
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE;
|
||||
#endif /* JERRY_ESNEXT */
|
||||
put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p,
|
||||
n,
|
||||
get_value,
|
||||
prop_flags);
|
||||
put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, n, get_value, prop_flags);
|
||||
ecma_free_value (get_value);
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
@ -1057,10 +1043,7 @@ ecma_builtin_array_prototype_object_sort_compare_helper (ecma_value_t lhs, /**<
|
||||
|
||||
ecma_value_t compare_args[] = { lhs, rhs };
|
||||
|
||||
ecma_value_t call_value = ecma_op_function_call (comparefn_obj_p,
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
compare_args,
|
||||
2);
|
||||
ecma_value_t call_value = ecma_op_function_call (comparefn_obj_p, ECMA_VALUE_UNDEFINED, compare_args, 2);
|
||||
if (ECMA_IS_VALUE_ERROR (call_value))
|
||||
{
|
||||
return call_value;
|
||||
@ -1178,11 +1161,8 @@ ecma_builtin_array_prototype_object_sort (ecma_value_t this_arg, /**< this argum
|
||||
if (copied_num > 1)
|
||||
{
|
||||
const ecma_builtin_helper_sort_compare_fn_t sort_cb = &ecma_builtin_array_prototype_object_sort_compare_helper;
|
||||
ecma_value_t sort_value = ecma_builtin_helper_array_merge_sort_helper (values_buffer,
|
||||
(uint32_t) (copied_num),
|
||||
arg1,
|
||||
sort_cb,
|
||||
NULL);
|
||||
ecma_value_t sort_value =
|
||||
ecma_builtin_helper_array_merge_sort_helper (values_buffer, (uint32_t) (copied_num), arg1, sort_cb, NULL);
|
||||
if (ECMA_IS_VALUE_ERROR (sort_value))
|
||||
{
|
||||
goto clean_up;
|
||||
@ -1271,9 +1251,7 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu
|
||||
if (args_number > 0)
|
||||
{
|
||||
/* ES5.1: 6, ES11: 4. */
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (args[0],
|
||||
len,
|
||||
&actual_start)))
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (args[0], len, &actual_start)))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
@ -1295,8 +1273,8 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu
|
||||
}
|
||||
|
||||
/* ES5.1: 7 */
|
||||
actual_delete_count = (ecma_length_t) (JERRY_MIN (JERRY_MAX (delete_num, 0),
|
||||
(ecma_number_t) (len - actual_start)));
|
||||
actual_delete_count =
|
||||
(ecma_length_t) (JERRY_MIN (JERRY_MAX (delete_num, 0), (ecma_number_t) (len - actual_start)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1344,10 +1322,7 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu
|
||||
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE;
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p,
|
||||
k,
|
||||
from_present,
|
||||
prop_flags);
|
||||
ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, k, from_present, prop_flags);
|
||||
ecma_free_value (from_present);
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
@ -1364,8 +1339,8 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
/* ES11: 12. */
|
||||
ecma_value_t set_length = ecma_builtin_array_prototype_helper_set_length (new_array_p,
|
||||
((ecma_number_t) actual_delete_count));
|
||||
ecma_value_t set_length =
|
||||
ecma_builtin_array_prototype_helper_set_length (new_array_p, ((ecma_number_t) actual_delete_count));
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (set_length))
|
||||
{
|
||||
@ -1465,10 +1440,7 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu
|
||||
uint32_t idx = 0;
|
||||
for (uint32_t arg_index = 2; arg_index < args_number; arg_index++, idx++)
|
||||
{
|
||||
ecma_value_t put_value = ecma_op_object_put_by_index (obj_p,
|
||||
actual_start + idx,
|
||||
args[arg_index],
|
||||
true);
|
||||
ecma_value_t put_value = ecma_op_object_put_by_index (obj_p, actual_start + idx, args[arg_index], true);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (put_value))
|
||||
{
|
||||
@ -1506,13 +1478,11 @@ ecma_builtin_array_prototype_object_unshift (const ecma_value_t args[], /**< arg
|
||||
ecma_object_t *obj_p, /**< object */
|
||||
ecma_length_t len) /**< object's length */
|
||||
{
|
||||
|
||||
if (ecma_op_object_is_fast_array (obj_p))
|
||||
{
|
||||
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
|
||||
|
||||
if (ext_obj_p->u.array.length_prop_and_hole_count < ECMA_FAST_ARRAY_HOLE_ONE
|
||||
&& len != 0)
|
||||
if (ext_obj_p->u.array.length_prop_and_hole_count < ECMA_FAST_ARRAY_HOLE_ONE && len != 0)
|
||||
{
|
||||
if (args_number > UINT32_MAX - len)
|
||||
{
|
||||
@ -1730,8 +1700,7 @@ ecma_builtin_array_prototype_object_index_of (const ecma_value_t args[], /**< ar
|
||||
}
|
||||
|
||||
/* 9.b.i, 9.b.ii */
|
||||
if (ecma_is_value_found (get_value)
|
||||
&& ecma_op_strict_equality_compare (args[0], get_value))
|
||||
if (ecma_is_value_found (get_value) && ecma_op_strict_equality_compare (args[0], get_value))
|
||||
{
|
||||
ecma_free_value (get_value);
|
||||
return ecma_make_length_value (from_idx);
|
||||
@ -1822,7 +1791,7 @@ ecma_builtin_array_prototype_object_last_index_of (const ecma_value_t args[], /*
|
||||
}
|
||||
}
|
||||
|
||||
/* 8. */
|
||||
/* 8. */
|
||||
while (from_idx < len)
|
||||
{
|
||||
/* 8.a */
|
||||
@ -1834,8 +1803,7 @@ ecma_builtin_array_prototype_object_last_index_of (const ecma_value_t args[], /*
|
||||
}
|
||||
|
||||
/* 8.b.i, 8.b.ii */
|
||||
if (ecma_is_value_found (get_value)
|
||||
&& ecma_op_strict_equality_compare (search_element, get_value))
|
||||
if (ecma_is_value_found (get_value) && ecma_op_strict_equality_compare (search_element, get_value))
|
||||
{
|
||||
ecma_free_value (get_value);
|
||||
return ecma_make_length_value (from_idx);
|
||||
@ -2023,10 +1991,7 @@ ecma_builtin_array_prototype_object_map (ecma_value_t arg1, /**< callbackfn */
|
||||
#else /* !JERRY_ESNEXT */
|
||||
const uint32_t prop_flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE;
|
||||
#endif /* JERRY_ESNEXT */
|
||||
put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p,
|
||||
index,
|
||||
mapped_value,
|
||||
prop_flags);
|
||||
put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, index, mapped_value, prop_flags);
|
||||
|
||||
ecma_free_value (mapped_value);
|
||||
ecma_free_value (current_value);
|
||||
@ -2124,10 +2089,7 @@ ecma_builtin_array_prototype_object_filter (ecma_value_t arg1, /**< callbackfn *
|
||||
if (ecma_op_to_boolean (call_value))
|
||||
{
|
||||
ecma_value_t put_comp;
|
||||
put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p,
|
||||
new_array_index,
|
||||
get_value,
|
||||
prop_flags);
|
||||
put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, new_array_index, get_value, prop_flags);
|
||||
#if JERRY_ESNEXT
|
||||
if (ECMA_IS_VALUE_ERROR (put_comp))
|
||||
{
|
||||
@ -2206,8 +2168,7 @@ ecma_builtin_array_reduce_from (const ecma_value_t args_p[], /**< routine's argu
|
||||
k_present = true;
|
||||
|
||||
/* 8.b.ii-iii */
|
||||
ecma_value_t current_value = ecma_op_object_find_by_index (obj_p, start_from_left ? index
|
||||
: last_index - index);
|
||||
ecma_value_t current_value = ecma_op_object_find_by_index (obj_p, start_from_left ? index : last_index - index);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (current_value))
|
||||
{
|
||||
@ -2253,12 +2214,9 @@ ecma_builtin_array_reduce_from (const ecma_value_t args_p[], /**< routine's argu
|
||||
{
|
||||
/* 9.c.i, 9.c.ii */
|
||||
current_index = ecma_make_length_value (corrected_index);
|
||||
ecma_value_t call_args[] = {accumulator, current_value, current_index, ecma_make_object_value (obj_p)};
|
||||
ecma_value_t call_args[] = { accumulator, current_value, current_index, ecma_make_object_value (obj_p) };
|
||||
|
||||
ecma_value_t call_value = ecma_op_function_call (func_object_p,
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
call_args,
|
||||
4);
|
||||
ecma_value_t call_value = ecma_op_function_call (func_object_p, ECMA_VALUE_UNDEFINED, call_args, 4);
|
||||
ecma_free_value (current_index);
|
||||
ecma_free_value (accumulator);
|
||||
ecma_free_value (current_value);
|
||||
@ -2298,9 +2256,7 @@ ecma_builtin_array_prototype_fill (ecma_value_t value, /**< value */
|
||||
ecma_length_t k, final;
|
||||
|
||||
/* 5. 6. 7. */
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (start_val,
|
||||
len,
|
||||
&k)))
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (start_val, len, &k)))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
@ -2313,9 +2269,7 @@ ecma_builtin_array_prototype_fill (ecma_value_t value, /**< value */
|
||||
else
|
||||
{
|
||||
/* 8 part 2, 9, 10 */
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (end_val,
|
||||
len,
|
||||
&final)))
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_builtin_helper_array_index_normalize (end_val, len, &final)))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
@ -2728,7 +2682,7 @@ ecma_builtin_array_flatten_into_array (ecma_value_t target, /**< target will con
|
||||
{
|
||||
/* i-ii. */
|
||||
ecma_value_t source_val = ecma_make_length_value (source_index);
|
||||
ecma_value_t args[] = {element, source_val, ecma_make_object_value (source)};
|
||||
ecma_value_t args[] = { element, source_val, ecma_make_object_value (source) };
|
||||
ecma_value_t temp_element = ecma_op_function_call (ecma_get_object_from_value (mapped_value), thisArg, args, 3);
|
||||
|
||||
ecma_free_value (element);
|
||||
@ -2787,10 +2741,8 @@ ecma_builtin_array_flatten_into_array (ecma_value_t target, /**< target will con
|
||||
|
||||
/* vi. */
|
||||
const uint32_t flags = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | JERRY_PROP_SHOULD_THROW;
|
||||
ecma_value_t element_temp = ecma_builtin_helper_def_prop_by_index (ecma_get_object_from_value (target),
|
||||
target_index,
|
||||
element,
|
||||
flags);
|
||||
ecma_value_t element_temp =
|
||||
ecma_builtin_helper_def_prop_by_index (ecma_get_object_from_value (target), target_index, element, flags);
|
||||
|
||||
ecma_free_value (element);
|
||||
|
||||
@ -2885,13 +2837,8 @@ ecma_builtin_array_prototype_object_flat_map (ecma_value_t callback, /**< callba
|
||||
}
|
||||
|
||||
/* 5. */
|
||||
ecma_value_t flatten_val = ecma_builtin_array_flatten_into_array (ecma_make_object_value (new_array_p),
|
||||
obj_p,
|
||||
len,
|
||||
0,
|
||||
1,
|
||||
callback,
|
||||
this_arg);
|
||||
ecma_value_t flatten_val =
|
||||
ecma_builtin_array_flatten_into_array (ecma_make_object_value (new_array_p), obj_p, len, 0, 1, callback, this_arg);
|
||||
if (ECMA_IS_VALUE_ERROR (flatten_val))
|
||||
{
|
||||
ecma_deref_object (new_array_p);
|
||||
@ -2937,16 +2884,11 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
|
||||
#endif /* !JERRY_ESNEXT */
|
||||
if (builtin_routine_id == ECMA_ARRAY_PROTOTYPE_SORT)
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_sort (this_arg,
|
||||
arguments_list_p[0],
|
||||
obj_p);
|
||||
|
||||
ret_value = ecma_builtin_array_prototype_object_sort (this_arg, arguments_list_p[0], obj_p);
|
||||
}
|
||||
else if (builtin_routine_id == ECMA_ARRAY_PROTOTYPE_CONCAT)
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_concat (arguments_list_p,
|
||||
arguments_number,
|
||||
obj_p);
|
||||
ret_value = ecma_builtin_array_prototype_object_concat (arguments_list_p, arguments_number, obj_p);
|
||||
}
|
||||
|
||||
ecma_deref_object (obj_p);
|
||||
@ -3004,10 +2946,7 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_PUSH:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_push (arguments_list_p,
|
||||
arguments_number,
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_push (arguments_list_p, arguments_number, obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_REVERSE:
|
||||
@ -3022,49 +2961,32 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_SLICE:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_slice (arguments_list_p[0],
|
||||
arguments_list_p[1],
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_slice (arguments_list_p[0], arguments_list_p[1], obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_SPLICE:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_splice (arguments_list_p,
|
||||
arguments_number,
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_splice (arguments_list_p, arguments_number, obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_UNSHIFT:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_unshift (arguments_list_p,
|
||||
arguments_number,
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_unshift (arguments_list_p, arguments_number, obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_AT:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_at (arguments_list_p[0],
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_at (arguments_list_p[0], obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_INDEX_OF:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_index_of (arguments_list_p,
|
||||
arguments_number,
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_index_of (arguments_list_p, arguments_number, obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_LAST_INDEX_OF:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_last_index_of (arguments_list_p,
|
||||
arguments_number,
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_last_index_of (arguments_list_p, arguments_number, obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_EVERY:
|
||||
@ -3080,10 +3002,7 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_MAP:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_map (arguments_list_p[0],
|
||||
arguments_list_p[1],
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_map (arguments_list_p[0], arguments_list_p[1], obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_REDUCE:
|
||||
@ -3099,10 +3018,7 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
|
||||
#if JERRY_ESNEXT
|
||||
case ECMA_ARRAY_PROTOTYPE_COPY_WITHIN:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_copy_within (arguments_list_p,
|
||||
arguments_number,
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_copy_within (arguments_list_p, arguments_number, obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_FIND:
|
||||
@ -3126,26 +3042,18 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_INCLUDES:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_includes (arguments_list_p,
|
||||
arguments_number,
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_includes (arguments_list_p, arguments_number, obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_FLAT:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_flat (arguments_list_p,
|
||||
arguments_number,
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_flat (arguments_list_p, arguments_number, obj_p, length);
|
||||
break;
|
||||
}
|
||||
case ECMA_ARRAY_PROTOTYPE_FLATMAP:
|
||||
{
|
||||
ret_value = ecma_builtin_array_prototype_object_flat_map (arguments_list_p[0],
|
||||
arguments_list_p[1],
|
||||
obj_p,
|
||||
length);
|
||||
ret_value =
|
||||
ecma_builtin_array_prototype_object_flat_map (arguments_list_p[0], arguments_list_p[1], obj_p, length);
|
||||
break;
|
||||
}
|
||||
#endif /* JERRY_ESNEXT */
|
||||
@ -3153,10 +3061,7 @@ ecma_builtin_array_prototype_dispatch_routine (uint8_t builtin_routine_id, /**<
|
||||
{
|
||||
JERRY_ASSERT (builtin_routine_id == ECMA_ARRAY_PROTOTYPE_FILTER);
|
||||
|
||||
ret_value = ecma_builtin_array_prototype_object_filter (arguments_list_p[0],
|
||||
arguments_list_p[1],
|
||||
obj_p,
|
||||
length);
|
||||
ret_value = ecma_builtin_array_prototype_object_filter (arguments_list_p[0], arguments_list_p[1], obj_p, length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,9 +25,7 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.4.4.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_ARRAY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ARRAY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
/* ECMA-262 v6, 22.1.3.31 */
|
||||
@ -40,9 +38,7 @@ OBJECT_VALUE (LIT_GLOBAL_SYMBOL_UNSCOPABLES,
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.4.4 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
0,
|
||||
ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 0, ECMA_PROPERTY_FLAG_WRITABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
@ -82,11 +78,12 @@ ROUTINE (LIT_MAGIC_STRING_KEYS, ECMA_ARRAY_PROTOTYPE_KEYS, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_INCLUDES, ECMA_ARRAY_PROTOTYPE_INCLUDES, NON_FIXED, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_FLAT, ECMA_ARRAY_PROTOTYPE_FLAT, 1, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_FLATMAP, ECMA_ARRAY_PROTOTYPE_FLATMAP, 2, 1)
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_STRING_UL, LIT_MAGIC_STRING_TO_STRING_UL,
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_STRING_UL, LIT_MAGIC_STRING_TO_STRING_UL, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_VALUES,
|
||||
LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_VALUES, LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
INTRINSIC_PROPERTY (LIT_GLOBAL_SYMBOL_ITERATOR, LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES,
|
||||
INTRINSIC_PROPERTY (LIT_GLOBAL_SYMBOL_ITERATOR,
|
||||
LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
@ -14,8 +14,9 @@
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-array-object.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
@ -24,7 +25,7 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-iterator-object.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-array-object.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt.h"
|
||||
|
||||
@ -53,7 +54,7 @@ enum
|
||||
};
|
||||
|
||||
#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
|
||||
@ -185,10 +186,8 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
{
|
||||
/* 6.g.iv.1 */
|
||||
ecma_value_t len_value = ecma_make_uint32_value (k);
|
||||
ecma_value_t set_status = ecma_op_object_put (array_obj_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
|
||||
len_value,
|
||||
true);
|
||||
ecma_value_t set_status =
|
||||
ecma_op_object_put (array_obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), len_value, true);
|
||||
ecma_free_value (len_value);
|
||||
|
||||
/* 6.g.iv.2 */
|
||||
@ -255,7 +254,7 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
k++;
|
||||
}
|
||||
|
||||
iterator_cleanup:
|
||||
iterator_cleanup:
|
||||
ecma_free_value (iterator);
|
||||
ecma_free_value (next_method);
|
||||
ecma_deref_object (array_obj_p);
|
||||
@ -376,10 +375,8 @@ iterator_cleanup:
|
||||
|
||||
/* 17. */
|
||||
len_value = ecma_make_length_value (k);
|
||||
ecma_value_t set_status = ecma_op_object_put (array_obj_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
|
||||
len_value,
|
||||
true);
|
||||
ecma_value_t set_status =
|
||||
ecma_op_object_put (array_obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), len_value, true);
|
||||
ecma_free_value (len_value);
|
||||
|
||||
/* 18. */
|
||||
@ -420,10 +417,8 @@ ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
|
||||
|
||||
ecma_value_t len = ecma_make_uint32_value (arguments_list_len);
|
||||
|
||||
ecma_value_t ret_val = ecma_op_function_construct (ecma_get_object_from_value (this_arg),
|
||||
ecma_get_object_from_value (this_arg),
|
||||
&len,
|
||||
1);
|
||||
ecma_value_t ret_val =
|
||||
ecma_op_function_construct (ecma_get_object_from_value (this_arg), ecma_get_object_from_value (this_arg), &len, 1);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (ret_val))
|
||||
{
|
||||
@ -437,10 +432,8 @@ ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
|
||||
|
||||
while (k < arguments_list_len)
|
||||
{
|
||||
ecma_value_t define_status = ecma_builtin_helper_def_prop_by_index (obj_p,
|
||||
k,
|
||||
arguments_list_p[k],
|
||||
prop_status_flags);
|
||||
ecma_value_t define_status =
|
||||
ecma_builtin_helper_def_prop_by_index (obj_p, k, arguments_list_p[k], prop_status_flags);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (define_status))
|
||||
{
|
||||
@ -452,10 +445,7 @@ ecma_builtin_array_object_of (ecma_value_t this_arg, /**< 'this' argument */
|
||||
k++;
|
||||
}
|
||||
|
||||
ret_val = ecma_op_object_put (obj_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
|
||||
len,
|
||||
true);
|
||||
ret_val = ecma_op_object_put (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), len, true);
|
||||
|
||||
ecma_free_value (len);
|
||||
|
||||
@ -482,8 +472,7 @@ ecma_builtin_array_dispatch_call (const ecma_value_t *arguments_list_p, /**< arg
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
if (arguments_list_len != 1
|
||||
|| !ecma_is_value_number (arguments_list_p[0]))
|
||||
if (arguments_list_len != 1 || !ecma_is_value_number (arguments_list_p[0]))
|
||||
{
|
||||
return ecma_op_new_array_object_from_buffer (arguments_list_p, arguments_list_len);
|
||||
}
|
||||
@ -514,8 +503,8 @@ ecma_builtin_array_dispatch_construct (const ecma_value_t *arguments_list_p, /**
|
||||
#if !JERRY_ESNEXT
|
||||
return ecma_builtin_array_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
#else /* JERRY_ESNEXT */
|
||||
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p),
|
||||
ECMA_BUILTIN_ID_ARRAY_PROTOTYPE);
|
||||
ecma_object_t *proto_p =
|
||||
ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), ECMA_BUILTIN_ID_ARRAY_PROTOTYPE);
|
||||
|
||||
if (proto_p == NULL)
|
||||
{
|
||||
|
||||
@ -25,21 +25,15 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.4.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_ARRAY_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ARRAY_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* Number properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ARRAY_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ARRAY_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
/* Routine properties:
|
||||
@ -50,9 +44,7 @@ ROUTINE (LIT_MAGIC_STRING_FROM, ECMA_ARRAY_ROUTINE_FROM, NON_FIXED, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_OF, ECMA_ARRAY_ROUTINE_OF, NON_FIXED, 0)
|
||||
|
||||
/* ECMA-262 v6, 22.1.2.5 */
|
||||
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES,
|
||||
ECMA_ARRAY_ROUTINE_SPECIES_GET,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES, ECMA_ARRAY_ROUTINE_SPECIES_GET, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
#endif /* !(JERRY_BUILTIN_ARRAY) */
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-conversion.h"
|
||||
@ -22,9 +23,9 @@
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#include "jrt-libc-includes.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
|
||||
@ -32,7 +33,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-arraybuffer-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID arraybuffer_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID arraybuffer_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@ -24,9 +24,7 @@
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_ARRAYBUFFER,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ARRAYBUFFER, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* Readonly accessor properties */
|
||||
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
|
||||
@ -34,9 +32,7 @@ ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 24.1.4.4 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_ARRAY_BUFFER_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ARRAY_BUFFER_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
|
||||
@ -13,14 +13,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-dataview-object.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
#include "ecma-dataview-object.h"
|
||||
#include "ecma-typedarray-object.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_BUILTIN_TYPEDARRAY
|
||||
@ -29,7 +30,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-arraybuffer.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID arraybuffer
|
||||
#define BUILTIN_UNDERSCORED_ID arraybuffer
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@ -24,20 +24,14 @@
|
||||
/* Number properties:
|
||||
* (property name, number value, writable, enumerable, configurable) */
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ARRAY_BUFFER_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ARRAY_BUFFER_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
@ -46,9 +40,7 @@ STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
ROUTINE (LIT_MAGIC_STRING_IS_VIEW_UL, ecma_builtin_arraybuffer_object_is_view, 1, 1)
|
||||
|
||||
/* ES2015 24.1.3.3 */
|
||||
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES,
|
||||
ecma_builtin_arraybuffer_species_get,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
ACCESSOR_READ_ONLY (LIT_GLOBAL_SYMBOL_SPECIES, ecma_builtin_arraybuffer_species_get, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#endif /* JERRY_BUILTIN_TYPEDARRAY */
|
||||
|
||||
|
||||
@ -13,6 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "jerryscript-types.h"
|
||||
|
||||
#include "ecma-builtin-handlers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-exceptions.h"
|
||||
@ -23,8 +25,8 @@
|
||||
#include "ecma-iterator-object.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-promise-object.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jerryscript-types.h"
|
||||
#include "jrt.h"
|
||||
#include "lit-magic-strings.h"
|
||||
#include "lit-strings.h"
|
||||
@ -37,8 +39,8 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
/**
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_CUSTOM_DISPATCH
|
||||
|
||||
/**
|
||||
@ -53,7 +55,7 @@ enum
|
||||
} ecma_async_from_sync_iterator_operation_type_t;
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-from-sync-iterator-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_from_sync_iterator_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID async_from_sync_iterator_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@ -146,9 +148,8 @@ ecma_builtin_async_from_sync_iterator_prototype_next (ecma_async_from_sync_itera
|
||||
ecma_value_t value) /**< routine's 'value' argument */
|
||||
{
|
||||
/* 5. */
|
||||
ecma_value_t next_result = ecma_op_iterator_next (iter_p->header.u.cls.u3.sync_iterator,
|
||||
iter_p->sync_next_method,
|
||||
value);
|
||||
ecma_value_t next_result =
|
||||
ecma_op_iterator_next (iter_p->header.u.cls.u3.sync_iterator, iter_p->sync_next_method, value);
|
||||
|
||||
/* 6. */
|
||||
if (ECMA_IS_VALUE_ERROR (ecma_op_if_abrupt_reject_promise (&next_result, capability_p)))
|
||||
@ -224,10 +225,8 @@ ecma_builtin_async_from_sync_iterator_prototype_do (ecma_async_from_sync_iterato
|
||||
}
|
||||
|
||||
/* 7.b. */
|
||||
ecma_value_t resolve = ecma_op_function_call (ecma_get_object_from_value (func_obj),
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
&call_arg,
|
||||
arg_size);
|
||||
ecma_value_t resolve =
|
||||
ecma_op_function_call (ecma_get_object_from_value (func_obj), ECMA_VALUE_UNDEFINED, &call_arg, arg_size);
|
||||
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (resolve));
|
||||
ecma_free_value (resolve);
|
||||
|
||||
@ -273,10 +272,8 @@ ecma_builtin_async_from_sync_iterator_prototype_do (ecma_async_from_sync_iterato
|
||||
ecma_value_t type_error = ecma_make_object_value (type_error_obj_p);
|
||||
|
||||
/* 10.a. */
|
||||
ecma_value_t reject = ecma_op_function_call (ecma_get_object_from_value (capability_p->reject),
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
&type_error,
|
||||
1);
|
||||
ecma_value_t reject =
|
||||
ecma_op_function_call (ecma_get_object_from_value (capability_p->reject), ECMA_VALUE_UNDEFINED, &type_error, 1);
|
||||
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (reject));
|
||||
ecma_deref_object (type_error_obj_p);
|
||||
ecma_free_value (reject);
|
||||
@ -292,11 +289,11 @@ ecma_builtin_async_from_sync_iterator_prototype_do (ecma_async_from_sync_iterato
|
||||
} /* ecma_builtin_async_from_sync_iterator_prototype_do */
|
||||
|
||||
/**
|
||||
* Dispatcher of the %AsyncFromSyncIteratorPrototype% built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
* Dispatcher of the %AsyncFromSyncIteratorPrototype% built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_async_from_sync_iterator_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide
|
||||
* routine
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-function-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_function_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID async_function_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@ -22,14 +22,10 @@
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
/* ECMA-262 v11, 25.7.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_ASYNC_FUNCTION,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ASYNC_FUNCTION, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v11, 25.7.3.2 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_ASYNC_FUNCTION_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ASYNC_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include "ecma-function-object.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-function.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_function
|
||||
#define BUILTIN_UNDERSCORED_ID async_function
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@ -47,9 +47,7 @@ ecma_builtin_async_function_dispatch_call (const ecma_value_t *arguments_list_p,
|
||||
{
|
||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||
|
||||
return ecma_op_create_dynamic_function (arguments_list_p,
|
||||
arguments_list_len,
|
||||
ECMA_PARSE_ASYNC_FUNCTION);
|
||||
return ecma_op_create_dynamic_function (arguments_list_p, arguments_list_len, ECMA_PARSE_ASYNC_FUNCTION);
|
||||
} /* ecma_builtin_async_function_dispatch_call */
|
||||
|
||||
/**
|
||||
|
||||
@ -22,24 +22,16 @@
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
/* ECMA-262 v11, 25.7.2 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ASYNC_FUNCTION_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ASYNC_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v11, 25.7.2.1 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v10, 25.7.2.2 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_ASYNC_FUNCTION_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ASYNC_FUNCTION_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* ECMA-262 v11, 25.7.3.2 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_ASYNC_FUNCTION_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ASYNC_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include "ecma-function-object.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-generator-function.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator_function
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator_function
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@ -22,19 +22,13 @@
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
/* ECMA-262 v10, 25.3.2 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ASYNC_GENERATOR_FUNCTION_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ASYNC_GENERATOR_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v10, 25.3.2.1 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 25.3.2.2 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_ASYNC_GENERATOR,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ASYNC_GENERATOR, ECMA_PROPERTY_FIXED)
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-iterator-object.h"
|
||||
#include "ecma-promise-object.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "opcodes.h"
|
||||
#include "vm-defines.h"
|
||||
@ -31,8 +32,8 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
/**
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_CUSTOM_DISPATCH
|
||||
|
||||
/**
|
||||
@ -47,7 +48,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-generator-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@ -64,26 +65,26 @@ enum
|
||||
* Convert routine type to operation type..
|
||||
*/
|
||||
#define ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION(type) \
|
||||
((ecma_async_generator_operation_type_t) ((type) - ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_NEXT))
|
||||
((ecma_async_generator_operation_type_t) ((type) -ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_NEXT))
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION (ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_NEXT)
|
||||
== ECMA_ASYNC_GENERATOR_DO_NEXT,
|
||||
== ECMA_ASYNC_GENERATOR_DO_NEXT,
|
||||
convert_ecma_async_generator_routine_next_to_ecma_async_generator_do_next_failed);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION (ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_THROW)
|
||||
== ECMA_ASYNC_GENERATOR_DO_THROW,
|
||||
== ECMA_ASYNC_GENERATOR_DO_THROW,
|
||||
convert_ecma_async_generator_routine_throw_to_ecma_async_generator_do_throw_failed);
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_ASYNC_GENERATOR_ROUTINE_TO_OPERATION (ECMA_ASYNC_GENERATOR_PROTOTYPE_ROUTINE_RETURN)
|
||||
== ECMA_ASYNC_GENERATOR_DO_RETURN,
|
||||
== ECMA_ASYNC_GENERATOR_DO_RETURN,
|
||||
convert_ecma_async_generator_routine_return_to_ecma_async_generator_do_return_failed);
|
||||
|
||||
/**
|
||||
* Dispatcher of the Generator built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
* Dispatcher of the Generator built-in's routines
|
||||
*
|
||||
* @return ecma value
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_builtin_async_generator_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< built-in wide routine
|
||||
* identifier */
|
||||
|
||||
@ -25,14 +25,10 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v6, 25.3.1.5 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_ASYNC_GENERATOR_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ASYNC_GENERATOR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 25.2.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_ASYNC_GENERATOR,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ASYNC_GENERATOR, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-generator.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator
|
||||
#define BUILTIN_UNDERSCORED_ID async_generator
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@ -22,14 +22,10 @@
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
/* ECMA-262 v6, 25.3.2.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_ASYNC_GENERATOR_FUNCTION,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ASYNC_GENERATOR_FUNCTION, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 25.3.2.3.2 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_ASYNC_GENERATOR_PROTOTYPE,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ASYNC_GENERATOR_PROTOTYPE, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 25.3.2.3.3 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
|
||||
@ -37,7 +37,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-async-iterator-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID async_iterator_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID async_iterator_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_BUILTIN_ATOMICS
|
||||
@ -51,7 +52,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-atomics.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID atomics
|
||||
#define BUILTIN_UNDERSCORED_ID atomics
|
||||
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
@ -76,7 +77,7 @@ enum
|
||||
static ecma_value_t
|
||||
ecma_builtin_atomics_compare_exchange (ecma_value_t typedarray, /**< typedArray argument */
|
||||
ecma_value_t index, /**< index argument */
|
||||
ecma_value_t expected_value, /**< expectedValue argument */
|
||||
ecma_value_t expected_value, /**< expectedValue argument */
|
||||
ecma_value_t replacement_value) /**< replacementValue argument*/
|
||||
{
|
||||
JERRY_UNUSED (typedarray);
|
||||
|
||||
@ -22,9 +22,7 @@
|
||||
#if JERRY_BUILTIN_ATOMICS
|
||||
|
||||
/* ECMA-262 v11, 24.4.14 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_ATOMICS_U,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_ATOMICS_U, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
|
||||
@ -38,7 +38,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-bigint-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID bigint_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID bigint_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@ -25,14 +25,10 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v11, 20.2.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_BIGINT,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_BIGINT, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v11, 20.2.3.5 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_BIGINT_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_BIGINT_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-bigint.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID bigint
|
||||
#define BUILTIN_UNDERSCORED_ID bigint
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@ -25,22 +25,16 @@
|
||||
* (property name, number value, writable, enumerable, configurable) */
|
||||
|
||||
/* ECMA-262 v11, 20.2.1 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v11, 20.2.1 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_BIGINT_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_BIGINT_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v11, 20.2.2.3 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_BIGINT_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_BIGINT_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-string-object.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_BUILTIN_BOOLEAN
|
||||
@ -45,7 +46,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-boolean-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID boolean_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID boolean_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@ -25,14 +25,12 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.6.4.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_BOOLEAN,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_BOOLEAN, ECMA_PROPERTY_CONFIGURABLE_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_STRING_UL, ECMA_BOOLEAN_PROTOTYPE_ROUTINE_TO_STRING, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_VALUE_OF_UL, ECMA_BOOLEAN_PROTOTYPE_ROUTINE_VALUE_OF, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_VALUE_OF_UL, ECMA_BOOLEAN_PROTOTYPE_ROUTINE_VALUE_OF, 0, 0)
|
||||
|
||||
#endif /* JERRY_BUILTIN_BOOLEAN */
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_BUILTIN_BOOLEAN
|
||||
@ -30,7 +31,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-boolean.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID boolean
|
||||
#define BUILTIN_UNDERSCORED_ID boolean
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@ -25,21 +25,15 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.6.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* Number properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_BOOLEAN_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_BOOLEAN_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
#endif /* JERRY_BUILTIN_BOOLEAN */
|
||||
|
||||
@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
#include "ecma-arraybuffer-object.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-dataview-object.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-gc.h"
|
||||
|
||||
#if JERRY_BUILTIN_DATAVIEW
|
||||
@ -74,7 +74,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-dataview-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID dataview_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID dataview_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@ -179,7 +179,8 @@ ecma_builtin_dataview_prototype_dispatch_routine (uint8_t builtin_routine_id, /*
|
||||
return ecma_op_dataview_get_set_view_value (this_arg,
|
||||
arguments_list_p[0],
|
||||
arguments_list_p[1],
|
||||
ECMA_VALUE_EMPTY, id);
|
||||
ECMA_VALUE_EMPTY,
|
||||
id);
|
||||
}
|
||||
case ECMA_DATAVIEW_PROTOTYPE_SET_FLOAT32:
|
||||
#if JERRY_NUMBER_TYPE_FLOAT64
|
||||
|
||||
@ -25,14 +25,10 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v6, 24.2.3 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_DATAVIEW,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_DATAVIEW, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v6, 23.2.4.21 */
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG,
|
||||
LIT_MAGIC_STRING_DATAVIEW_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_GLOBAL_SYMBOL_TO_STRING_TAG, LIT_MAGIC_STRING_DATAVIEW_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
@ -64,9 +60,7 @@ ROUTINE (LIT_MAGIC_STRING_SET_BIGUINT64, ECMA_DATAVIEW_PROTOTYPE_SET_BIGUINT64,
|
||||
#endif /* JERRY_BUILTIN_BIGINT */
|
||||
|
||||
/* ECMA-262 v6, 24.2.4.1 */
|
||||
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BUFFER,
|
||||
ECMA_DATAVIEW_PROTOTYPE_BUFFER_GETTER,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BUFFER, ECMA_DATAVIEW_PROTOTYPE_BUFFER_GETTER, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 24.2.4.2 */
|
||||
ACCESSOR_READ_ONLY (LIT_MAGIC_STRING_BYTE_LENGTH_UL,
|
||||
|
||||
@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-dataview-object.h"
|
||||
#include "ecma-exceptions.h"
|
||||
|
||||
#if JERRY_BUILTIN_DATAVIEW
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-dataview.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID dataview
|
||||
#define BUILTIN_UNDERSCORED_ID dataview
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@ -25,22 +25,16 @@
|
||||
* (property name, number value, writable, enumerable, configurable) */
|
||||
|
||||
/* ECMA-262 v6, 23.1.2 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 23.1 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_DATAVIEW_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_DATAVIEW_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v6, 23.1.2.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_DATAVIEW_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_DATAVIEW_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
#endif /* JERRY_BUILTIN_DATAVIEW */
|
||||
|
||||
|
||||
@ -22,8 +22,8 @@
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-objects-general.h"
|
||||
#include "ecma-objects.h"
|
||||
|
||||
#if JERRY_BUILTIN_DATE
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
* Checks whether the function uses UTC time zone.
|
||||
*/
|
||||
#define BUILTIN_DATE_FUNCTION_IS_UTC(builtin_routine_id) \
|
||||
(((builtin_routine_id) - ECMA_DATE_PROTOTYPE_GET_FULL_YEAR) & 0x1)
|
||||
(((builtin_routine_id) -ECMA_DATE_PROTOTYPE_GET_FULL_YEAR) & 0x1)
|
||||
|
||||
/**
|
||||
* List of built-in routine identifiers.
|
||||
@ -108,7 +108,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-date-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID date_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID date_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@ -311,7 +311,7 @@ ecma_builtin_date_prototype_dispatch_get (uint16_t builtin_routine_id, /**< buil
|
||||
* Returns true, if the built-in id sets a year.
|
||||
*/
|
||||
#define ECMA_DATE_PROTOTYPE_IS_SET_YEAR_ROUTINE(builtin_routine_id) \
|
||||
((builtin_routine_id) == ECMA_DATE_PROTOTYPE_SET_FULL_YEAR \
|
||||
((builtin_routine_id) == ECMA_DATE_PROTOTYPE_SET_FULL_YEAR \
|
||||
|| (builtin_routine_id) == ECMA_DATE_PROTOTYPE_SET_UTC_FULL_YEAR \
|
||||
|| (builtin_routine_id) == ECMA_DATE_PROTOTYPE_SET_YEAR)
|
||||
|
||||
@ -321,7 +321,7 @@ ecma_builtin_date_prototype_dispatch_get (uint16_t builtin_routine_id, /**< buil
|
||||
* Returns true, if the built-in id sets a year.
|
||||
*/
|
||||
#define ECMA_DATE_PROTOTYPE_IS_SET_YEAR_ROUTINE(builtin_routine_id) \
|
||||
((builtin_routine_id) == ECMA_DATE_PROTOTYPE_SET_FULL_YEAR \
|
||||
((builtin_routine_id) == ECMA_DATE_PROTOTYPE_SET_FULL_YEAR \
|
||||
|| (builtin_routine_id) == ECMA_DATE_PROTOTYPE_SET_UTC_FULL_YEAR)
|
||||
|
||||
#endif /* JERRY_BUILTIN_ANNEXB */
|
||||
@ -677,7 +677,6 @@ ecma_builtin_date_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< b
|
||||
|
||||
if (builtin_routine_id <= ECMA_DATE_PROTOTYPE_SET_UTC_MILLISECONDS)
|
||||
{
|
||||
|
||||
if (builtin_routine_id <= ECMA_DATE_PROTOTYPE_GET_UTC_TIMEZONE_OFFSET)
|
||||
{
|
||||
if (!BUILTIN_DATE_FUNCTION_IS_UTC (builtin_routine_id))
|
||||
@ -706,10 +705,7 @@ ecma_builtin_date_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< b
|
||||
return ecma_builtin_date_prototype_dispatch_get (builtin_routine_id, date_value);
|
||||
}
|
||||
|
||||
return ecma_builtin_date_prototype_dispatch_set (builtin_routine_id,
|
||||
this_obj_p,
|
||||
arguments_list,
|
||||
arguments_number);
|
||||
return ecma_builtin_date_prototype_dispatch_set (builtin_routine_id, this_obj_p, arguments_list, arguments_number);
|
||||
}
|
||||
|
||||
if (builtin_routine_id == ECMA_DATE_PROTOTYPE_TO_ISO_STRING)
|
||||
|
||||
@ -21,9 +21,7 @@
|
||||
|
||||
#if JERRY_BUILTIN_DATE
|
||||
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_DATE,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_DATE, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_STRING_UL, ECMA_DATE_PROTOTYPE_TO_STRING, 0, 0)
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_DATE_STRING_UL, ECMA_DATE_PROTOTYPE_TO_DATE_STRING, 0, 0)
|
||||
@ -69,10 +67,12 @@ ROUTINE (LIT_MAGIC_STRING_TO_ISO_STRING_UL, ECMA_DATE_PROTOTYPE_TO_ISO_STRING, 0
|
||||
ROUTINE (LIT_MAGIC_STRING_TO_JSON_UL, ECMA_DATE_PROTOTYPE_TO_JSON, 1, 1)
|
||||
#if JERRY_ESNEXT
|
||||
ROUTINE_CONFIGURABLE_ONLY (LIT_GLOBAL_SYMBOL_TO_PRIMITIVE, ECMA_DATE_PROTOTYPE_TO_PRIMITIVE, 1, 1)
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_UTC_STRING_UL, LIT_MAGIC_STRING_TO_UTC_STRING_UL,
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_UTC_STRING_UL,
|
||||
LIT_MAGIC_STRING_TO_UTC_STRING_UL,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#if JERRY_BUILTIN_ANNEXB
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_GMT_STRING_UL, LIT_MAGIC_STRING_TO_UTC_STRING_UL,
|
||||
INTRINSIC_PROPERTY (LIT_MAGIC_STRING_TO_GMT_STRING_UL,
|
||||
LIT_MAGIC_STRING_TO_UTC_STRING_UL,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
#endif /* JERRY_BUILTIN_ANNEXB */
|
||||
#else /* !JERRY_ESNEXT */
|
||||
|
||||
@ -15,15 +15,16 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-builtin-helpers.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 "jcontext.h"
|
||||
#include "lit-char-helpers.h"
|
||||
|
||||
#if JERRY_BUILTIN_DATE
|
||||
@ -48,7 +49,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-date.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID date
|
||||
#define BUILTIN_UNDERSCORED_ID date
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@ -148,8 +149,7 @@ ecma_date_check_two_chars (const lit_utf8_byte_t *str_p, /**< pointer to the ces
|
||||
ecma_char_t expected_char1, /**< first expected character */
|
||||
ecma_char_t expected_char2) /**< second expected character */
|
||||
{
|
||||
return (str_p < str_end_p
|
||||
&& (*str_p == expected_char1 || *str_p == expected_char2));
|
||||
return (str_p < str_end_p && (*str_p == expected_char1 || *str_p == expected_char2));
|
||||
} /* ecma_date_check_two_chars */
|
||||
|
||||
/**
|
||||
@ -236,21 +236,20 @@ ecma_date_parse_month_name (const lit_utf8_byte_t **str_p, /**< pointer to the c
|
||||
} /* ecma_date_parse_month_name */
|
||||
|
||||
/**
|
||||
* Calculate MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli)) for Date constructor and UTC
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v11, 20.4.3.4
|
||||
*
|
||||
* @return false - if the operation fails
|
||||
* true - otherwise
|
||||
*/
|
||||
* Calculate MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli)) for Date constructor and UTC
|
||||
*
|
||||
* See also:
|
||||
* ECMA-262 v11, 20.4.3.4
|
||||
*
|
||||
* @return false - if the operation fails
|
||||
* true - otherwise
|
||||
*/
|
||||
static bool
|
||||
ecma_date_construct_helper (const ecma_value_t *args, /**< arguments passed to the Date constructor */
|
||||
uint32_t args_len, /**< number of arguments */
|
||||
ecma_number_t *tv_p) /**< [out] time value */
|
||||
{
|
||||
ecma_number_t date_nums[7] =
|
||||
{
|
||||
ecma_number_t date_nums[7] = {
|
||||
ECMA_NUMBER_ZERO, /* year */
|
||||
ECMA_NUMBER_ZERO, /* month */
|
||||
ECMA_NUMBER_ONE, /* date */
|
||||
@ -287,13 +286,8 @@ ecma_date_construct_helper (const ecma_value_t *args, /**< arguments passed to t
|
||||
}
|
||||
|
||||
/* 10. */
|
||||
*tv_p = ecma_date_make_date (ecma_date_make_day (date_nums[0],
|
||||
date_nums[1],
|
||||
date_nums[2]),
|
||||
ecma_date_make_time (date_nums[3],
|
||||
date_nums[4],
|
||||
date_nums[5],
|
||||
date_nums[6]));
|
||||
*tv_p = ecma_date_make_date (ecma_date_make_day (date_nums[0], date_nums[1], date_nums[2]),
|
||||
ecma_date_make_time (date_nums[3], date_nums[4], date_nums[5], date_nums[6]));
|
||||
return true;
|
||||
} /* ecma_date_construct_helper */
|
||||
|
||||
@ -324,10 +318,8 @@ ecma_builtin_date_parse_basic (const lit_utf8_byte_t *date_str_curr_p, /**< date
|
||||
year_limit = 999999;
|
||||
}
|
||||
|
||||
ecma_number_t year = ecma_date_parse_date_chars (&date_str_curr_p,
|
||||
date_str_end_p,
|
||||
year_digits,
|
||||
ECMA_DATE_LIMIT (0, year_limit));
|
||||
ecma_number_t year =
|
||||
ecma_date_parse_date_chars (&date_str_curr_p, date_str_end_p, year_digits, ECMA_DATE_LIMIT (0, year_limit));
|
||||
if (is_year_sign_negative)
|
||||
{
|
||||
year = -year;
|
||||
@ -466,8 +458,7 @@ ecma_builtin_date_parse_basic (const lit_utf8_byte_t *date_str_curr_p, /**< date
|
||||
* @return the parsed date as ecma_number_t or NaN otherwise
|
||||
*/
|
||||
static ecma_number_t
|
||||
ecma_builtin_date_parse_toString_formats (const lit_utf8_byte_t *date_str_curr_p,
|
||||
const lit_utf8_byte_t *date_str_end_p)
|
||||
ecma_builtin_date_parse_toString_formats (const lit_utf8_byte_t *date_str_curr_p, const lit_utf8_byte_t *date_str_end_p)
|
||||
{
|
||||
const ecma_number_t nan = ecma_number_make_nan ();
|
||||
|
||||
@ -582,8 +573,7 @@ ecma_builtin_date_parse_toString_formats (const lit_utf8_byte_t *date_str_curr_p
|
||||
}
|
||||
|
||||
const char gmt_p[] = " GMT";
|
||||
if (date_str_end_p - date_str_curr_p < 4
|
||||
|| memcmp (date_str_curr_p, gmt_p, 4) != 0)
|
||||
if (date_str_end_p - date_str_curr_p < 4 || memcmp (date_str_curr_p, gmt_p, 4) != 0)
|
||||
{
|
||||
return nan;
|
||||
}
|
||||
@ -725,8 +715,8 @@ ecma_builtin_date_create (ecma_number_t tv)
|
||||
#if JERRY_ESNEXT
|
||||
JERRY_ASSERT (JERRY_CONTEXT (current_new_target_p) != NULL);
|
||||
|
||||
ecma_object_t *prototype_obj_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p),
|
||||
ECMA_BUILTIN_ID_DATE_PROTOTYPE);
|
||||
ecma_object_t *prototype_obj_p =
|
||||
ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), ECMA_BUILTIN_ID_DATE_PROTOTYPE);
|
||||
|
||||
if (JERRY_UNLIKELY (prototype_obj_p == NULL))
|
||||
{
|
||||
@ -787,7 +777,6 @@ ecma_value_t
|
||||
ecma_builtin_date_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
|
||||
uint32_t arguments_list_len) /**< number of arguments */
|
||||
{
|
||||
|
||||
/* 20.4.2.3 */
|
||||
if (arguments_list_len == 0)
|
||||
{
|
||||
@ -804,7 +793,6 @@ ecma_builtin_date_dispatch_construct (const ecma_value_t *arguments_list_p, /**<
|
||||
if (ecma_is_value_object (argument)
|
||||
&& ecma_object_class_is (ecma_get_object_from_value (argument), ECMA_OBJECT_CLASS_DATE))
|
||||
{
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
tv = ((ecma_date_object_t *) ecma_get_object_from_value (argument))->date_value;
|
||||
#else /* !JERRY_ESNEXT */
|
||||
|
||||
@ -22,22 +22,16 @@
|
||||
#if JERRY_BUILTIN_DATE
|
||||
|
||||
/* ECMA-262 v5, 15.9.4.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_DATE_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_DATE_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
7,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 7, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
ROUTINE (LIT_MAGIC_STRING_PARSE, ECMA_DATE_ROUTINE_PARSE, 1, 1)
|
||||
ROUTINE (LIT_MAGIC_STRING_UTC_U, ECMA_DATE_ROUTINE_UTC, NON_FIXED, 7)
|
||||
ROUTINE (LIT_MAGIC_STRING_NOW, ECMA_DATE_ROUTINE_NOW, 0, 0)
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_DATE_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_DATE_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
#endif /* JERRY_BUILTIN_DATE */
|
||||
|
||||
@ -20,18 +20,19 @@
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-string-object.h"
|
||||
|
||||
#include "jrt.h"
|
||||
#include "lit-char-helpers.h"
|
||||
#include "lit-magic-strings.h"
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
/**
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
* This object has a custom dispatch function.
|
||||
*/
|
||||
#define BUILTIN_CUSTOM_DISPATCH
|
||||
|
||||
/**
|
||||
@ -44,7 +45,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-error-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID error_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID error_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@ -105,18 +106,16 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this
|
||||
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
|
||||
|
||||
ecma_string_t *name_string_p = ecma_builtin_error_prototype_object_to_string_helper (obj_p,
|
||||
LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ERROR_UL);
|
||||
ecma_string_t *name_string_p =
|
||||
ecma_builtin_error_prototype_object_to_string_helper (obj_p, LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ERROR_UL);
|
||||
|
||||
if (JERRY_UNLIKELY (name_string_p == NULL))
|
||||
{
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_string_t *msg_string_p = ecma_builtin_error_prototype_object_to_string_helper (obj_p,
|
||||
LIT_MAGIC_STRING_MESSAGE,
|
||||
LIT_MAGIC_STRING__EMPTY);
|
||||
ecma_string_t *msg_string_p =
|
||||
ecma_builtin_error_prototype_object_to_string_helper (obj_p, LIT_MAGIC_STRING_MESSAGE, LIT_MAGIC_STRING__EMPTY);
|
||||
|
||||
if (JERRY_UNLIKELY (msg_string_p == NULL))
|
||||
{
|
||||
@ -136,7 +135,7 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this
|
||||
|
||||
ecma_stringbuilder_t builder = ecma_stringbuilder_create_from (name_string_p);
|
||||
|
||||
ecma_stringbuilder_append_raw (&builder, (const lit_utf8_byte_t *)": ", 2);
|
||||
ecma_stringbuilder_append_raw (&builder, (const lit_utf8_byte_t *) ": ", 2);
|
||||
ecma_stringbuilder_append (&builder, msg_string_p);
|
||||
|
||||
ecma_deref_ecma_string (name_string_p);
|
||||
|
||||
@ -23,19 +23,13 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.11.4.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_ERROR,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v5, 15.11.4.2 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ERROR_UL, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v5, 15.11.4.3 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_MESSAGE,
|
||||
LIT_MAGIC_STRING__EMPTY,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_MESSAGE, LIT_MAGIC_STRING__EMPTY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* Routine properties:
|
||||
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
||||
|
||||
@ -14,23 +14,24 @@
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.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-builtin-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-error.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID error
|
||||
#define BUILTIN_UNDERSCORED_ID error
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@ -67,8 +68,8 @@ ecma_builtin_error_dispatch_construct (const ecma_value_t *arguments_list_p, /**
|
||||
#if !JERRY_ESNEXT
|
||||
return ecma_builtin_error_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
#else /* JERRY_ESNEXT */
|
||||
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p),
|
||||
ECMA_BUILTIN_ID_ERROR_PROTOTYPE);
|
||||
ecma_object_t *proto_p =
|
||||
ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), ECMA_BUILTIN_ID_ERROR_PROTOTYPE);
|
||||
|
||||
if (proto_p == NULL)
|
||||
{
|
||||
|
||||
@ -22,22 +22,16 @@
|
||||
/* Number properties:
|
||||
* (property name, number value, writable, enumerable, configurable) */
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
/* Object properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.7.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_ERROR_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_ERROR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-string-object.h"
|
||||
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_BUILTIN_ERRORS
|
||||
@ -30,7 +31,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-evalerror-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID eval_error_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID eval_error_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
#endif /* JERRY_BUILTIN_ERRORS */
|
||||
|
||||
@ -25,19 +25,13 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.11.7.8 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_EVAL_ERROR,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_EVAL_ERROR, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* ECMA-262 v5, 15.11.7.9 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_EVAL_ERROR_UL,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_EVAL_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)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_MESSAGE, LIT_MAGIC_STRING__EMPTY, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
#endif /* JERRY_BUILTIN_ERRORS */
|
||||
|
||||
|
||||
@ -14,17 +14,18 @@
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.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-builtin-helpers.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#include "jcontext.h"
|
||||
#include "jrt.h"
|
||||
|
||||
#if JERRY_BUILTIN_ERRORS
|
||||
|
||||
@ -32,7 +33,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-evalerror.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID eval_error
|
||||
#define BUILTIN_UNDERSCORED_ID eval_error
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@ -69,8 +70,8 @@ ecma_builtin_eval_error_dispatch_construct (const ecma_value_t *arguments_list_p
|
||||
#if !JERRY_ESNEXT
|
||||
return ecma_builtin_eval_error_dispatch_call (arguments_list_p, arguments_list_len);
|
||||
#else /* JERRY_ESNEXT */
|
||||
ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p),
|
||||
ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE);
|
||||
ecma_object_t *proto_p =
|
||||
ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target_p), ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE);
|
||||
|
||||
if (proto_p == NULL)
|
||||
{
|
||||
|
||||
@ -24,22 +24,16 @@
|
||||
/* Number properties:
|
||||
* (property name, number value, writable, enumerable, configurable) */
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, 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_EVAL_ERROR_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_EVAL_ERROR_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_EVAL_ERROR_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
#endif /* JERRY_BUILTIN_ERRORS */
|
||||
|
||||
@ -13,20 +13,22 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecma-builtin-function-prototype.h"
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-builtin-helpers.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-extended-info.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-objects.h"
|
||||
#include "ecma-proxy-object.h"
|
||||
|
||||
#include "jrt.h"
|
||||
#include "ecma-builtin-function-prototype.h"
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
@ -52,7 +54,7 @@ enum
|
||||
};
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-function-prototype.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID function_prototype
|
||||
#define BUILTIN_UNDERSCORED_ID function_prototype
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@ -209,7 +211,7 @@ ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, /**< th
|
||||
/* 2. */
|
||||
if (ecma_is_value_null (arg2) || ecma_is_value_undefined (arg2))
|
||||
{
|
||||
return ecma_op_function_call (func_obj_p, arg1, NULL, 0);
|
||||
return ecma_op_function_call (func_obj_p, arg1, NULL, 0);
|
||||
}
|
||||
|
||||
/* 3. */
|
||||
@ -256,10 +258,7 @@ ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, /**< th
|
||||
if (ecma_is_value_empty (ret_value))
|
||||
{
|
||||
JERRY_ASSERT (index == length);
|
||||
ret_value = ecma_op_function_call (func_obj_p,
|
||||
arg1,
|
||||
arguments_list_p,
|
||||
(uint32_t) length);
|
||||
ret_value = ecma_op_function_call (func_obj_p, arg1, arguments_list_p, (uint32_t) length);
|
||||
}
|
||||
|
||||
for (uint32_t remove_index = 0; remove_index < index; remove_index++)
|
||||
@ -282,17 +281,14 @@ ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, /**< th
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_function_prototype_object_call (ecma_object_t *func_obj_p , /**< this argument object */
|
||||
ecma_builtin_function_prototype_object_call (ecma_object_t *func_obj_p, /**< this argument object */
|
||||
const ecma_value_t *arguments_list_p, /**< list of arguments */
|
||||
uint32_t arguments_number) /**< number of arguments */
|
||||
{
|
||||
if (arguments_number == 0)
|
||||
{
|
||||
/* Even a 'this' argument is missing. */
|
||||
return ecma_op_function_call (func_obj_p,
|
||||
ECMA_VALUE_UNDEFINED,
|
||||
NULL,
|
||||
0);
|
||||
return ecma_op_function_call (func_obj_p, ECMA_VALUE_UNDEFINED, NULL, 0);
|
||||
}
|
||||
|
||||
return ecma_op_function_call (func_obj_p,
|
||||
@ -311,7 +307,7 @@ ecma_builtin_function_prototype_object_call (ecma_object_t *func_obj_p , /**< th
|
||||
* Returned value must be freed with ecma_free_value.
|
||||
*/
|
||||
static ecma_value_t
|
||||
ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**< this argument object */
|
||||
ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p, /**< this argument object */
|
||||
const ecma_value_t *arguments_list_p, /**< list of arguments */
|
||||
uint32_t arguments_number) /**< number of arguments */
|
||||
{
|
||||
@ -353,18 +349,13 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
|
||||
ecma_object_t *function_p;
|
||||
ecma_bound_function_t *bound_func_p;
|
||||
|
||||
if (arguments_number == 0
|
||||
|| (arguments_number == 1 && !ecma_is_value_integer_number (arguments_list_p[0])))
|
||||
if (arguments_number == 0 || (arguments_number == 1 && !ecma_is_value_integer_number (arguments_list_p[0])))
|
||||
{
|
||||
function_p = ecma_create_object (prototype_obj_p,
|
||||
sizeof (ecma_bound_function_t),
|
||||
ECMA_OBJECT_TYPE_BOUND_FUNCTION);
|
||||
function_p = ecma_create_object (prototype_obj_p, sizeof (ecma_bound_function_t), ECMA_OBJECT_TYPE_BOUND_FUNCTION);
|
||||
|
||||
/* 8. */
|
||||
bound_func_p = (ecma_bound_function_t *) function_p;
|
||||
ECMA_SET_NON_NULL_POINTER_TAG (bound_func_p->header.u.bound_function.target_function,
|
||||
this_arg_obj_p,
|
||||
0);
|
||||
ECMA_SET_NON_NULL_POINTER_TAG (bound_func_p->header.u.bound_function.target_function, this_arg_obj_p, 0);
|
||||
|
||||
bound_func_p->header.u.bound_function.args_len_or_this = ECMA_VALUE_UNDEFINED;
|
||||
|
||||
@ -379,15 +370,11 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
|
||||
|
||||
size_t obj_size = sizeof (ecma_bound_function_t) + (arguments_number * sizeof (ecma_value_t));
|
||||
|
||||
function_p = ecma_create_object (prototype_obj_p,
|
||||
obj_size,
|
||||
ECMA_OBJECT_TYPE_BOUND_FUNCTION);
|
||||
function_p = ecma_create_object (prototype_obj_p, obj_size, ECMA_OBJECT_TYPE_BOUND_FUNCTION);
|
||||
|
||||
/* 8. */
|
||||
bound_func_p = (ecma_bound_function_t *) function_p;
|
||||
ECMA_SET_NON_NULL_POINTER_TAG (bound_func_p->header.u.bound_function.target_function,
|
||||
this_arg_obj_p,
|
||||
0);
|
||||
ECMA_SET_NON_NULL_POINTER_TAG (bound_func_p->header.u.bound_function.target_function, this_arg_obj_p, 0);
|
||||
|
||||
/* NOTE: This solution provides temporary false data about the object's size
|
||||
but prevents GC from freeing it until it's not fully initialized. */
|
||||
@ -413,9 +400,7 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
|
||||
|
||||
ecma_string_t *len_string = ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH);
|
||||
ecma_property_descriptor_t prop_desc;
|
||||
ecma_value_t status = ecma_op_object_get_own_property_descriptor (this_arg_obj_p,
|
||||
len_string,
|
||||
&prop_desc);
|
||||
ecma_value_t status = ecma_op_object_get_own_property_descriptor (this_arg_obj_p, len_string, &prop_desc);
|
||||
|
||||
#if JERRY_BUILTIN_PROXY
|
||||
if (ECMA_IS_VALUE_ERROR (status))
|
||||
@ -428,8 +413,7 @@ ecma_builtin_function_prototype_object_bind (ecma_object_t *this_arg_obj_p , /**
|
||||
if (ecma_is_value_true (status))
|
||||
{
|
||||
ecma_free_property_descriptor (&prop_desc);
|
||||
ecma_value_t len_value = ecma_op_object_get (this_arg_obj_p,
|
||||
len_string);
|
||||
ecma_value_t len_value = ecma_op_object_get (this_arg_obj_p, len_string);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (len_value))
|
||||
{
|
||||
@ -552,9 +536,7 @@ ecma_builtin_function_prototype_dispatch_routine (uint8_t builtin_routine_id, /*
|
||||
}
|
||||
case ECMA_FUNCTION_PROTOTYPE_APPLY:
|
||||
{
|
||||
return ecma_builtin_function_prototype_object_apply (func_obj_p,
|
||||
arguments_list_p[0],
|
||||
arguments_list_p[1]);
|
||||
return ecma_builtin_function_prototype_object_apply (func_obj_p, arguments_list_p[0], arguments_list_p[1]);
|
||||
}
|
||||
case ECMA_FUNCTION_PROTOTYPE_CALL:
|
||||
{
|
||||
|
||||
@ -16,8 +16,9 @@
|
||||
#ifndef ECMA_BUILTIN_FUNCTION_PROTOTYPE_H
|
||||
#define ECMA_BUILTIN_FUNCTION_PROTOTYPE_H
|
||||
|
||||
ecma_value_t ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p,
|
||||
ecma_value_t arg1,
|
||||
ecma_value_t arg2);
|
||||
#include "ecma-globals.h"
|
||||
|
||||
ecma_value_t
|
||||
ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, ecma_value_t arg1, ecma_value_t arg2);
|
||||
|
||||
#endif /* !ECMA_BUILTIN_FUNCTION_PROTOTYPE_H */
|
||||
|
||||
@ -23,21 +23,15 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.3.4.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR,
|
||||
ECMA_BUILTIN_ID_FUNCTION,
|
||||
ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_CONSTRUCTOR, ECMA_BUILTIN_ID_FUNCTION, ECMA_PROPERTY_CONFIGURABLE_WRITABLE)
|
||||
|
||||
/* Number properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
0,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 0, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING__EMPTY,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING__EMPTY, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
/* Routine properties:
|
||||
|
||||
@ -15,11 +15,12 @@
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-conversion.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-eval.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-function-object.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-lex-env.h"
|
||||
|
||||
#include "js-parser.h"
|
||||
#include "lit-magic-strings.h"
|
||||
|
||||
@ -27,7 +28,7 @@
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-function.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID function
|
||||
#define BUILTIN_UNDERSCORED_ID function
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
|
||||
@ -23,21 +23,15 @@
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
/* ECMA-262 v5, 15.3.3.1 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE, ECMA_PROPERTY_FIXED)
|
||||
|
||||
/* Number properties:
|
||||
* (property name, object pointer getter) */
|
||||
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_DEFAULT_LENGTH)
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_FUNCTION_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
#include "ecma-function-object.h"
|
||||
|
||||
#define BUILTIN_INC_HEADER_NAME "ecma-builtin-generator-function.inc.h"
|
||||
#define BUILTIN_UNDERSCORED_ID generator_function
|
||||
#define BUILTIN_UNDERSCORED_ID generator_function
|
||||
#include "ecma-builtin-internal-routines-template.inc.h"
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
@ -53,7 +53,7 @@ ecma_builtin_generator_function_dispatch_call (const ecma_value_t *arguments_lis
|
||||
/**
|
||||
* Handle calling [[Construct]] of built-in GeneratorFunction object
|
||||
*
|
||||
* @return constructed generator function object - if success
|
||||
* @return constructed generator function object - if success
|
||||
* raised error otherwise
|
||||
*/
|
||||
ecma_value_t
|
||||
|
||||
@ -22,19 +22,13 @@
|
||||
#if JERRY_ESNEXT
|
||||
|
||||
/* ECMA-262 v6, 25.2.2 */
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME,
|
||||
LIT_MAGIC_STRING_GENERATOR_FUNCTION_UL,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
STRING_VALUE (LIT_MAGIC_STRING_NAME, LIT_MAGIC_STRING_GENERATOR_FUNCTION_UL, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 25.2.2.1 */
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
||||
1,
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH, 1, ECMA_PROPERTY_FLAG_CONFIGURABLE)
|
||||
|
||||
/* ECMA-262 v6, 25.2.2.2 */
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
||||
ECMA_BUILTIN_ID_GENERATOR,
|
||||
ECMA_PROPERTY_FIXED)
|
||||
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE, ECMA_BUILTIN_ID_GENERATOR, ECMA_PROPERTY_FIXED)
|
||||
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user