From 271d9b2463704fb1ebfa47fd73ecffe7c83d76e0 Mon Sep 17 00:00:00 2001 From: Csaba Repasi Date: Thu, 25 Nov 2021 14:06:40 +0100 Subject: [PATCH] Outsource magic error messages (#4821) Modify tools/gen-magic-strings.py to generate error messages. JerryScript-DCO-1.0-Signed-off-by: Csaba Repasi repasics@inf.u-szeged.hu --- .github/workflows/gh-actions.yml | 2 +- jerry-core/CMakeLists.txt | 1 + jerry-core/api/jerry-snapshot.c | 55 +- jerry-core/api/jerryscript.c | 268 +++--- .../ecma/base/ecma-error-messages.inc.h | 856 ++++++++++++++++++ jerry-core/ecma/base/ecma-error-messages.ini | 326 +++++++ jerry-core/ecma/base/ecma-errors.c | 231 +---- jerry-core/ecma/base/ecma-errors.h | 89 +- jerry-core/ecma/base/ecma-globals.h | 16 +- jerry-core/ecma/base/ecma-helpers-string.c | 2 +- jerry-core/ecma/base/ecma-helpers-value.c | 2 +- jerry-core/ecma/base/ecma-module.c | 16 +- .../ecma-builtin-array-iterator-prototype.c | 6 +- .../ecma-builtin-array-prototype.c | 28 +- .../ecma/builtin-objects/ecma-builtin-array.c | 8 +- .../ecma-builtin-arraybuffer-prototype.c | 8 +- .../ecma-builtin-arraybuffer.c | 2 +- ...iltin-async-from-sync-iterator-prototype.c | 5 +- .../ecma-builtin-async-generator-prototype.c | 2 +- .../ecma-builtin-bigint-prototype.c | 4 +- .../builtin-objects/ecma-builtin-bigint.c | 2 +- .../ecma-builtin-boolean-prototype.c | 2 +- .../ecma-builtin-dataview-prototype.c | 4 +- .../builtin-objects/ecma-builtin-dataview.c | 2 +- .../ecma-builtin-date-prototype.c | 6 +- .../ecma-builtin-error-prototype.c | 2 +- .../ecma-builtin-function-prototype.c | 8 +- .../ecma-builtin-generator-prototype.c | 4 +- .../builtin-objects/ecma-builtin-global.c | 14 +- .../builtin-objects/ecma-builtin-helpers.c | 4 +- .../builtin-objects/ecma-builtin-intrinsic.c | 6 +- .../ecma/builtin-objects/ecma-builtin-json.c | 8 +- .../ecma/builtin-objects/ecma-builtin-map.c | 2 +- .../ecma-builtin-number-prototype.c | 10 +- .../ecma-builtin-object-prototype.c | 2 +- .../builtin-objects/ecma-builtin-object.c | 22 +- .../builtin-objects/ecma-builtin-promise.c | 10 +- .../ecma/builtin-objects/ecma-builtin-proxy.c | 2 +- .../builtin-objects/ecma-builtin-reflect.c | 16 +- .../ecma-builtin-regexp-prototype.c | 10 +- ...builtin-regexp-string-iterator-prototype.c | 4 +- .../builtin-objects/ecma-builtin-regexp.c | 2 +- .../ecma/builtin-objects/ecma-builtin-set.c | 2 +- ...cma-builtin-shared-arraybuffer-prototype.c | 6 +- .../ecma-builtin-shared-arraybuffer.c | 2 +- .../ecma-builtin-string-iterator-prototype.c | 4 +- .../ecma-builtin-string-prototype.c | 10 +- .../builtin-objects/ecma-builtin-string.c | 4 +- .../builtin-objects/ecma-builtin-symbol.c | 4 +- .../ecma-builtin-type-error-thrower.c | 3 +- .../builtin-objects/ecma-builtin-weakmap.c | 2 +- .../ecma-builtin-weakref-prototype.c | 4 +- .../builtin-objects/ecma-builtin-weakref.c | 4 +- .../builtin-objects/ecma-builtin-weakset.c | 2 +- .../ecma/builtin-objects/ecma-builtins.c | 2 +- .../typedarray/ecma-builtin-bigint64array.c | 2 +- .../typedarray/ecma-builtin-biguint64array.c | 2 +- .../typedarray/ecma-builtin-float32array.c | 2 +- .../typedarray/ecma-builtin-float64array.c | 2 +- .../typedarray/ecma-builtin-int16array.c | 2 +- .../typedarray/ecma-builtin-int32array.c | 2 +- .../typedarray/ecma-builtin-int8array.c | 2 +- .../ecma-builtin-typedarray-prototype.c | 32 +- .../typedarray/ecma-builtin-typedarray.c | 12 +- .../typedarray/ecma-builtin-uint16array.c | 2 +- .../typedarray/ecma-builtin-uint32array.c | 2 +- .../typedarray/ecma-builtin-uint8array.c | 2 +- .../ecma-builtin-uint8clampedarray.c | 2 +- .../ecma/operations/ecma-array-object.c | 6 +- .../ecma/operations/ecma-arraybuffer-object.c | 14 +- .../operations/ecma-async-generator-object.c | 15 +- .../ecma/operations/ecma-atomics-object.c | 10 +- jerry-core/ecma/operations/ecma-bigint.c | 18 +- .../ecma/operations/ecma-container-object.c | 14 +- jerry-core/ecma/operations/ecma-conversion.c | 24 +- .../ecma/operations/ecma-dataview-object.c | 16 +- jerry-core/ecma/operations/ecma-eval.c | 2 +- jerry-core/ecma/operations/ecma-exceptions.c | 40 +- jerry-core/ecma/operations/ecma-exceptions.h | 22 +- .../ecma/operations/ecma-function-object.c | 53 +- .../ecma/operations/ecma-function-object.h | 5 +- .../ecma/operations/ecma-get-put-value.c | 8 +- .../ecma/operations/ecma-iterator-object.c | 12 +- jerry-core/ecma/operations/ecma-lex-env.c | 11 +- .../ecma/operations/ecma-objects-general.c | 8 +- jerry-core/ecma/operations/ecma-objects.c | 18 +- jerry-core/ecma/operations/ecma-objects.h | 2 +- .../ecma/operations/ecma-promise-object.c | 20 +- .../ecma/operations/ecma-proxy-object.c | 77 +- jerry-core/ecma/operations/ecma-reference.c | 6 +- .../ecma/operations/ecma-regexp-object.c | 26 +- .../ecma-shared-arraybuffer-object.c | 2 +- .../ecma/operations/ecma-symbol-object.c | 2 +- .../ecma/operations/ecma-typedarray-object.c | 34 +- jerry-core/lit/lit-magic-strings.inc.h | 2 +- jerry-core/lit/lit-magic-strings.ini | 2 +- jerry-core/parser/js/js-parser-util.c | 2 +- jerry-core/parser/js/js-parser.c | 4 +- jerry-core/parser/regexp/re-parser.c | 44 +- jerry-core/vm/opcodes-ecma-arithmetics.c | 2 +- jerry-core/vm/opcodes-ecma-bitwise.c | 2 +- .../vm/opcodes-ecma-relational-equality.c | 4 +- jerry-core/vm/opcodes.c | 11 +- jerry-core/vm/vm-stack.c | 2 +- jerry-core/vm/vm.c | 39 +- tests/unit-core/test-to-integer.c | 4 +- tests/unit-core/test-to-length.c | 4 +- ...heck-magic-strings.sh => check-strings.sh} | 2 +- .../{gen-magic-strings.py => gen-strings.py} | 93 +- tools/run-tests.py | 4 +- tools/settings.py | 2 +- 111 files changed, 1947 insertions(+), 925 deletions(-) create mode 100644 jerry-core/ecma/base/ecma-error-messages.inc.h create mode 100644 jerry-core/ecma/base/ecma-error-messages.ini rename tools/{check-magic-strings.sh => check-strings.sh} (96%) rename tools/{gen-magic-strings.py => gen-strings.py} (76%) diff --git a/.github/workflows/gh-actions.yml b/.github/workflows/gh-actions.yml index f435eee246..5ea7af976a 100644 --- a/.github/workflows/gh-actions.yml +++ b/.github/workflows/gh-actions.yml @@ -25,7 +25,7 @@ jobs: if: ${{ always() }} - run: $RUNNER --check-license if: ${{ always() }} - - run: $RUNNER --check-magic-strings + - run: $RUNNER --check-strings if: ${{ always() }} - run: $RUNNER --check-pylint if: ${{ always() }} diff --git a/jerry-core/CMakeLists.txt b/jerry-core/CMakeLists.txt index e8d6a8bf6f..8833af063b 100644 --- a/jerry-core/CMakeLists.txt +++ b/jerry-core/CMakeLists.txt @@ -341,6 +341,7 @@ if(ENABLE_AMALGAM) api/jerry-snapshot.h debugger/debugger.h ecma/base/ecma-alloc.h + ecma/base/ecma-error-messages.inc.h ecma/base/ecma-errors.h ecma/base/ecma-gc.h ecma/base/ecma-globals.h diff --git a/jerry-core/api/jerry-snapshot.c b/jerry-core/api/jerry-snapshot.c index 04c33f45db..19ec199f86 100644 --- a/jerry-core/api/jerry-snapshot.c +++ b/jerry-core/api/jerry-snapshot.c @@ -33,6 +33,23 @@ #if JERRY_SNAPSHOT_SAVE || JERRY_SNAPSHOT_EXEC +/** + * Create an error object + * + * Note: + * - returned value must be freed with jerry_release_value, when it is no longer needed + * - the error flag is set for the returned value + * + * @return value of the constructed error object + */ +static jerry_value_t +jerry_create_error_from_id (jerry_error_t error_type, /**< type of error */ + ecma_error_msg_t msg) /**< ecma_error_msg id of value of 'message' property + * of constructed error object */ +{ + return jerry_create_error (error_type, (jerry_char_t *) ecma_get_error_utf8 (msg)); +} /* jerry_create_error_from_id */ + /** * Get snapshot configuration flags. * @@ -153,8 +170,7 @@ 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_from_id (JERRY_ERROR_RANGE, ECMA_ERR_MAXIMUM_SNAPSHOT_SIZE); return 0; } @@ -168,8 +184,7 @@ 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_from_id (JERRY_ERROR_RANGE, ECMA_ERR_TAGGED_TEMPLATE_LITERALS); return 0; } @@ -339,8 +354,7 @@ 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_from_id (JERRY_ERROR_RANGE, ECMA_ERR_MAXIMUM_SNAPSHOT_SIZE); return 0; } @@ -355,7 +369,7 @@ static_snapshot_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, { /* 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); + jerry_create_error_from_id (JERRY_ERROR_RANGE, ECMA_ERR_REGULAR_EXPRESSION_NOT_SUPPORTED); return 0; } @@ -365,8 +379,7 @@ 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_from_id (JERRY_ERROR_RANGE, ECMA_ERR_SNAPSHOT_BUFFER_SMALL); return 0; } @@ -753,7 +766,7 @@ jerry_generate_snapshot (jerry_value_t compiled_code, /**< parsed script or func if ((generate_snapshot_opts & ~allowed_options) != 0) { - return jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) ecma_error_snapshot_flag_not_supported); + return jerry_create_error_from_id (JERRY_ERROR_RANGE, ECMA_ERR_SNAPSHOT_FLAG_NOT_SUPPORTED); } const ecma_compiled_code_t *bytecode_data_p = NULL; @@ -785,7 +798,7 @@ jerry_generate_snapshot (jerry_value_t compiled_code, /**< parsed script or func if (JERRY_UNLIKELY (bytecode_data_p == NULL)) { - return jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) ECMA_ERR_MSG ("Unsupported compiled code")); + return jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) "Unsupported compiled code"); } snapshot_globals_t globals; @@ -835,7 +848,7 @@ jerry_generate_snapshot (jerry_value_t compiled_code, /**< parsed script or func &literals_num)) { JERRY_ASSERT (lit_map_p == NULL); - return jerry_create_error (JERRY_ERROR_COMMON, (const jerry_char_t *) ecma_error_cannot_allocate_memory_literals); + return jerry_create_error_from_id (JERRY_ERROR_COMMON, ECMA_ERR_CANNOT_ALLOCATE_MEMORY_LITERALS); } jerry_snapshot_set_offsets (buffer_p + (aligned_header_size / sizeof (uint32_t)), @@ -889,17 +902,15 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */ if ((exec_snapshot_opts & ~(allowed_opts)) != 0) { - ecma_raise_range_error (ECMA_ERR_MSG ("Unsupported snapshot exec flags are specified")); + ecma_raise_range_error (ECMA_ERR_UNSUPPORTED_SNAPSHOT_EXEC_FLAGS_ARE_SPECIFIED); 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 uint8_t *snapshot_data_p = (uint8_t *) snapshot_p; if (snapshot_size <= sizeof (jerry_snapshot_header_t)) { - ecma_raise_type_error (invalid_format_error_p); + ecma_raise_type_error (ECMA_ERR_INVALID_SNAPSHOT_FORMAT); return ecma_create_error_reference_from_context (); } @@ -908,19 +919,19 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */ 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); + ecma_raise_type_error (ECMA_ERR_INVALID_SNAPSHOT_VERSION_OR_FEATURES); return ecma_create_error_reference_from_context (); } if (header_p->lit_table_offset > snapshot_size) { - ecma_raise_type_error (invalid_version_error_p); + ecma_raise_type_error (ECMA_ERR_INVALID_SNAPSHOT_VERSION_OR_FEATURES); return ecma_create_error_reference_from_context (); } if (func_index >= header_p->number_of_funcs) { - ecma_raise_range_error (ECMA_ERR_MSG ("Function index is higher than maximum")); + ecma_raise_range_error (ECMA_ERR_FUNCTION_INDEX_IS_HIGHER_THAN_MAXIMUM); return ecma_create_error_reference_from_context (); } @@ -933,13 +944,13 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */ { if (!(exec_snapshot_opts & JERRY_SNAPSHOT_EXEC_ALLOW_STATIC)) { - ecma_raise_common_error (ECMA_ERR_MSG ("Static snapshots are not enabled")); + ecma_raise_common_error (ECMA_ERR_STATIC_SNAPSHOTS_ARE_NOT_ENABLED); return ecma_create_error_reference_from_context (); } if (exec_snapshot_opts & JERRY_SNAPSHOT_EXEC_COPY_DATA) { - ecma_raise_common_error (ECMA_ERR_MSG ("Static snapshots cannot be copied into memory")); + ecma_raise_common_error (ECMA_ERR_STATIC_SNAPSHOTS_CANNOT_BE_COPIED_INTO_MEMORY); return ecma_create_error_reference_from_context (); } } @@ -995,7 +1006,7 @@ jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */ { JERRY_ASSERT (script_p->refs_and_type >= CBC_SCRIPT_REF_ONE); jmem_heap_free_block (script_p, script_size); - return ecma_raise_type_error (invalid_format_error_p); + return ecma_raise_type_error (ECMA_ERR_INVALID_SNAPSHOT_FORMAT); } script_p->refs_and_type -= CBC_SCRIPT_REF_ONE; diff --git a/jerry-core/api/jerryscript.c b/jerry-core/api/jerryscript.c index 43b1d11ede..13e3fd651b 100644 --- a/jerry-core/api/jerryscript.c +++ b/jerry-core/api/jerryscript.c @@ -29,6 +29,7 @@ #include "ecma-comparison.h" #include "ecma-container-object.h" #include "ecma-dataview-object.h" +#include "ecma-errors.h" #include "ecma-eval.h" #include "ecma-exceptions.h" #include "ecma-extended-info.h" @@ -402,7 +403,7 @@ jerry_parse_common (void *source_p, /**< script source */ && ((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))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } } @@ -431,7 +432,7 @@ jerry_parse_common (void *source_p, /**< script source */ #if JERRY_MODULE_SYSTEM JERRY_CONTEXT (module_current_p) = ecma_module_create (); #else /* !JERRY_MODULE_SYSTEM */ - return jerry_throw (ecma_raise_syntax_error (ECMA_ERR_MSG (ecma_error_module_not_supported_p))); + return jerry_throw (ecma_raise_syntax_error (ECMA_ERR_MODULE_NOT_SUPPORTED)); #endif /* JERRY_MODULE_SYSTEM */ } @@ -510,7 +511,7 @@ jerry_parse (const jerry_char_t *source_p, /**< script source */ JERRY_UNUSED (source_size); JERRY_UNUSED (options_p); - return jerry_throw (ecma_raise_syntax_error (ECMA_ERR_MSG (ecma_error_parser_not_supported_p))); + return jerry_throw (ecma_raise_syntax_error (ECMA_ERR_PARSER_NOT_SUPPORTED)); #endif /* JERRY_PARSER */ } /* jerry_parse */ @@ -527,7 +528,7 @@ jerry_parse_value (const jerry_value_t source_value, /**< script source */ #if JERRY_PARSER if (!ecma_is_value_string (source_value)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } ecma_value_t source[1]; @@ -538,7 +539,7 @@ jerry_parse_value (const jerry_value_t source_value, /**< script source */ JERRY_UNUSED (source_value); JERRY_UNUSED (options_p); - return jerry_throw (ecma_raise_syntax_error (ECMA_ERR_MSG (ecma_error_parser_not_supported_p))); + return jerry_throw (ecma_raise_syntax_error (ECMA_ERR_PARSER_NOT_SUPPORTED)); #endif /* JERRY_PARSER */ } /* jerry_parse_value */ @@ -558,14 +559,14 @@ jerry_run (const jerry_value_t func_val) /**< function to run */ if (!ecma_is_value_object (func_val)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } ecma_object_t *object_p = ecma_get_object_from_value (func_val); if (!ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_SCRIPT)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; @@ -597,7 +598,7 @@ jerry_eval (const jerry_char_t *source_p, /**< source code */ if ((parse_opts & ~allowed_parse_options) != 0) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } parser_source_char_t source_char; @@ -633,7 +634,7 @@ jerry_module_link (const jerry_value_t module_val, /**< root module */ if (module_p == NULL) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_not_module_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_NOT_MODULE)); } return jerry_return (ecma_module_link (module_p, callback, user_p)); @@ -642,7 +643,7 @@ jerry_module_link (const jerry_value_t module_val, /**< root module */ JERRY_UNUSED (callback); JERRY_UNUSED (user_p); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_module_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_MODULE_NOT_SUPPORTED)); #endif /* JERRY_MODULE_SYSTEM */ } /* jerry_module_link */ @@ -665,19 +666,19 @@ jerry_module_evaluate (const jerry_value_t module_val) /**< root module */ if (module_p == NULL) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_not_module_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_NOT_MODULE)); } if (module_p->header.u.cls.u1.module_state != JERRY_MODULE_STATE_LINKED) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Module must be in linked state"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_MODULE_MUST_BE_IN_LINKED_STATE)); } return jerry_return (ecma_module_evaluate (module_p)); #else /* !JERRY_MODULE_SYSTEM */ JERRY_UNUSED (module_val); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_module_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_MODULE_NOT_SUPPORTED)); #endif /* JERRY_MODULE_SYSTEM */ } /* jerry_module_evaluate */ @@ -801,7 +802,7 @@ jerry_module_get_request (const jerry_value_t module_val, /**< module */ if (module_p == NULL) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_not_module_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_NOT_MODULE)); } ecma_module_node_t *node_p = module_p->imports_p; @@ -817,12 +818,12 @@ jerry_module_get_request (const jerry_value_t module_val, /**< module */ node_p = node_p->next_p; } - return jerry_throw (ecma_raise_range_error (ECMA_ERR_MSG ("Request is not available"))); + return jerry_throw (ecma_raise_range_error (ECMA_ERR_REQUEST_IS_NOT_AVAILABLE)); #else /* !JERRY_MODULE_SYSTEM */ JERRY_UNUSED (module_val); JERRY_UNUSED (request_index); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_module_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_MODULE_NOT_SUPPORTED)); #endif /* JERRY_MODULE_SYSTEM */ } /* jerry_module_get_request */ @@ -845,13 +846,13 @@ jerry_module_get_namespace (const jerry_value_t module_val) /**< module */ if (module_p == NULL) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_not_module_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_NOT_MODULE)); } if (module_p->header.u.cls.u1.module_state < JERRY_MODULE_STATE_LINKED || module_p->header.u.cls.u1.module_state > JERRY_MODULE_STATE_EVALUATED) { - return jerry_throw (ecma_raise_range_error (ECMA_ERR_MSG ("Namespace object is not available"))); + return jerry_throw (ecma_raise_range_error (ECMA_ERR_NAMESPACE_OBJECT_IS_NOT_AVAILABLE)); } JERRY_ASSERT (module_p->namespace_object_p != NULL); @@ -861,7 +862,7 @@ jerry_module_get_namespace (const jerry_value_t module_val) /**< module */ #else /* !JERRY_MODULE_SYSTEM */ JERRY_UNUSED (module_val); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_module_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_MODULE_NOT_SUPPORTED)); #endif /* JERRY_MODULE_SYSTEM */ } /* jerry_module_get_namespace */ @@ -913,7 +914,7 @@ jerry_native_module_create (jerry_native_module_evaluate_callback_t callback, /* { ecma_deref_object (scope_p); ecma_module_release_module_names (local_exports_p); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Module exports must be string values"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_MODULE_EXPORTS_MUST_BE_STRING_VALUES)); } ecma_string_t *name_str_p = ecma_get_string_from_value (exports_p[i]); @@ -957,7 +958,7 @@ jerry_native_module_create (jerry_native_module_evaluate_callback_t callback, /* { ecma_deref_object (scope_p); ecma_module_release_module_names (local_exports_p); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Module exports must be valid identifiers"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_MODULE_EXPORTS_MUST_BE_VALID_IDENTIFIERS)); } if (ecma_find_named_property (scope_p, name_str_p) != NULL) @@ -996,7 +997,7 @@ jerry_native_module_create (jerry_native_module_evaluate_callback_t callback, /* JERRY_UNUSED (exports_p); JERRY_UNUSED (number_of_exports); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_module_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_MODULE_NOT_SUPPORTED)); #endif /* JERRY_MODULE_SYSTEM */ } /* jerry_native_module_create */ @@ -1020,12 +1021,12 @@ jerry_native_module_get_export (const jerry_value_t native_module_val, /**< a na if (module_p == NULL) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_not_module_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_NOT_MODULE)); } 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))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } ecma_property_t *property_p = @@ -1033,7 +1034,7 @@ jerry_native_module_get_export (const jerry_value_t native_module_val, /**< a na if (property_p == NULL) { - return jerry_throw (ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_unknown_export_p))); + return jerry_throw (ecma_raise_reference_error (ECMA_ERR_UNKNOWN_EXPORT)); } return ecma_copy_value (ECMA_PROPERTY_VALUE_PTR (property_p)->value); @@ -1041,7 +1042,7 @@ jerry_native_module_get_export (const jerry_value_t native_module_val, /**< a na JERRY_UNUSED (native_module_val); JERRY_UNUSED (export_name_val); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_module_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_MODULE_NOT_SUPPORTED)); #endif /* JERRY_MODULE_SYSTEM */ } /* jerry_native_module_get_export */ @@ -1066,13 +1067,13 @@ jerry_native_module_set_export (const jerry_value_t native_module_val, /**< a na if (module_p == NULL) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_not_module_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_NOT_MODULE)); } 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))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } ecma_property_t *property_p = @@ -1080,7 +1081,7 @@ jerry_native_module_set_export (const jerry_value_t native_module_val, /**< a na if (property_p == NULL) { - return jerry_throw (ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_unknown_export_p))); + return jerry_throw (ecma_raise_reference_error (ECMA_ERR_UNKNOWN_EXPORT)); } ecma_named_data_property_assign_value (module_p->scope_p, ECMA_PROPERTY_VALUE_PTR (property_p), value_to_set); @@ -1090,7 +1091,7 @@ jerry_native_module_set_export (const jerry_value_t native_module_val, /**< a na JERRY_UNUSED (export_name_val); JERRY_UNUSED (value_to_set); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_module_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_MODULE_NOT_SUPPORTED)); #endif /* JERRY_MODULE_SYSTEM */ } /* jerry_native_module_set_export */ @@ -1855,7 +1856,7 @@ jerry_binary_operation (jerry_binary_operation_t op, /**< operation */ if (ecma_is_value_error_reference (lhs) || ecma_is_value_error_reference (rhs)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_value_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_VALUE_MSG)); } switch (op) @@ -1888,7 +1889,7 @@ jerry_binary_operation (jerry_binary_operation_t op, /**< operation */ { 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))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } ecma_object_t *proto_obj_p = ecma_get_object_from_value (rhs); @@ -1907,7 +1908,7 @@ jerry_binary_operation (jerry_binary_operation_t op, /**< operation */ } default: { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Unsupported binary operation"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_UNSUPPORTED_BINARY_OPERATION)); } } } /* jerry_binary_operation */ @@ -2178,7 +2179,7 @@ jerry_value_to_number (const jerry_value_t value) /**< input value */ if (ecma_is_value_error_reference (value)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_value_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_VALUE_MSG)); } ecma_number_t num; @@ -2208,7 +2209,7 @@ jerry_value_to_object (const jerry_value_t value) /**< input value */ if (ecma_is_value_error_reference (value)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_value_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_VALUE_MSG)); } return jerry_return (ecma_op_to_object (value)); @@ -2230,7 +2231,7 @@ jerry_value_to_primitive (const jerry_value_t value) /**< input value */ if (ecma_is_value_error_reference (value)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_value_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_VALUE_MSG)); } return jerry_return (ecma_op_to_primitive (value, ECMA_PREFERRED_TYPE_NO)); @@ -2252,7 +2253,7 @@ jerry_value_to_string (const jerry_value_t value) /**< input value */ if (ecma_is_value_error_reference (value)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_value_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_VALUE_MSG)); } ecma_string_t *str_p = ecma_op_to_string (value); @@ -2281,13 +2282,13 @@ jerry_value_to_bigint (const jerry_value_t value) /**< input value */ #if JERRY_BUILTIN_BIGINT if (ecma_is_value_error_reference (value)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_value_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_VALUE_MSG)); } return jerry_return (ecma_bigint_to_bigint (value, true)); #else /* !JERRY_BUILTIN_BIGINT */ JERRY_UNUSED (value); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_bigint_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_BIGINT_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_BIGINT */ } /* jerry_value_to_bigint */ @@ -2616,7 +2617,7 @@ jerry_create_promise (void) return promise_value; #else /* !JERRY_ESNEXT */ - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_promise_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_PROMISE_NOT_SUPPORTED)); #endif /* JERRY_ESNEXT */ } /* jerry_create_promise */ @@ -2636,14 +2637,14 @@ jerry_create_proxy (const jerry_value_t target, /**< target argument */ 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))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } #if JERRY_BUILTIN_PROXY ecma_object_t *proxy_p = ecma_proxy_create (target, handler, 0); return jerry_return (proxy_p == NULL ? ECMA_VALUE_ERROR : ecma_make_object_value (proxy_p)); #else /* !JERRY_BUILTIN_PROXY */ - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Proxy is not supported"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_PROXY_IS_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_PROXY */ } /* jerry_create_proxy */ @@ -2671,7 +2672,7 @@ jerry_create_special_proxy (const jerry_value_t target, /**< target argument */ 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))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } #if JERRY_BUILTIN_PROXY @@ -2681,7 +2682,7 @@ jerry_create_special_proxy (const jerry_value_t target, /**< target argument */ return jerry_return (proxy_p == NULL ? ECMA_VALUE_ERROR : ecma_make_object_value (proxy_p)); #else /* !JERRY_BUILTIN_PROXY */ JERRY_UNUSED (options); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Proxy is not supported"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_PROXY_IS_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_PROXY */ } /* jerry_create_special_proxy */ @@ -2803,13 +2804,13 @@ jerry_create_symbol (const jerry_value_t value) /**< api value */ if (ecma_is_value_error_reference (value)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } #if JERRY_ESNEXT return jerry_return (ecma_op_create_symbol (&value, 1)); #else /* !JERRY_ESNEXT */ - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_symbol_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_SYMBOL_NOT_SUPPORTED)); #endif /* JERRY_ESNEXT */ } /* jerry_create_symbol */ @@ -2832,7 +2833,7 @@ jerry_create_bigint (const uint64_t *digits_p, /**< BigInt digits (lowest digit JERRY_UNUSED (digits_p); JERRY_UNUSED (size); JERRY_UNUSED (sign); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_bigint_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_BIGINT_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_BIGINT */ } /* jerry_create_bigint */ @@ -2863,7 +2864,7 @@ jerry_create_regexp_sz (const jerry_char_t *pattern_p, /**< zero-terminated UTF- #if JERRY_BUILTIN_REGEXP if (!lit_is_valid_utf8_string (pattern_p, pattern_size, true)) { - return jerry_throw (ecma_raise_common_error (ECMA_ERR_MSG ("Input must be a valid utf8 string"))); + return jerry_throw (ecma_raise_common_error (ECMA_ERR_INPUT_MUST_BE_A_VALID_UTF8_STRING)); } ecma_object_t *regexp_obj_p = ecma_op_regexp_alloc (NULL); @@ -2885,7 +2886,7 @@ jerry_create_regexp_sz (const jerry_char_t *pattern_p, /**< zero-terminated UTF- JERRY_UNUSED (pattern_size); JERRY_UNUSED (flags); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("RegExp is not supported"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_REGEXP_IS_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_REGEXP */ } /* jerry_create_regexp_sz */ @@ -2903,7 +2904,7 @@ jerry_create_realm (void) ecma_global_object_t *global_object_p = ecma_builtin_create_global_object (); return ecma_make_object_value ((ecma_object_t *) global_object_p); #else /* !JERRY_BUILTIN_REALMS */ - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Realms are disabled"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_REALMS_ARE_DISABLED)); #endif /* JERRY_BUILTIN_REALMS */ } /* jerry_create_realm */ @@ -3437,7 +3438,7 @@ jerry_get_property (const jerry_value_t obj_val, /**< object value */ 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))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } jerry_value_t ret_value = @@ -3462,7 +3463,7 @@ jerry_get_property_by_index (const jerry_value_t obj_val, /**< object value */ if (!ecma_is_value_object (obj_val)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } ecma_value_t ret_value = ecma_op_object_get_by_index (ecma_get_object_from_value (obj_val), index); @@ -3496,7 +3497,7 @@ jerry_get_own_property (const jerry_value_t obj_val, /**< object value */ 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))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } ecma_object_t *object_p = ecma_get_object_from_value (obj_val); @@ -3547,7 +3548,7 @@ jerry_get_internal_property (const jerry_value_t obj_val, /**< object value */ 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))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } ecma_object_t *obj_p = ecma_get_object_from_value (obj_val); @@ -3596,7 +3597,7 @@ jerry_set_property (const jerry_value_t obj_val, /**< object value */ 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))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } return jerry_return (ecma_op_object_put (ecma_get_object_from_value (obj_val), @@ -3623,7 +3624,7 @@ jerry_set_property_by_index (const jerry_value_t obj_val, /**< object value */ 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))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } ecma_value_t ret_value = @@ -3864,7 +3865,7 @@ jerry_property_descriptor_to_ecma (const jerry_property_descriptor_t *prop_desc_ * false value - otherwise */ static jerry_value_t -jerry_type_error_or_false (const char *msg_p, /**< message */ +jerry_type_error_or_false (ecma_error_msg_t msg, /**< message */ uint16_t flags) /**< property descriptor flags */ { if (!(flags & JERRY_PROP_SHOULD_THROW)) @@ -3872,7 +3873,7 @@ jerry_type_error_or_false (const char *msg_p, /**< message */ return ECMA_VALUE_FALSE; } - return jerry_throw (ecma_raise_type_error (msg_p)); + return jerry_throw (ecma_raise_type_error (msg)); } /* jerry_type_error_or_false */ /** @@ -3894,20 +3895,20 @@ jerry_define_own_property (const jerry_value_t obj_val, /**< object value */ 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); + return jerry_type_error_or_false (ECMA_ERR_WRONG_ARGS_MSG, prop_desc_p->flags); } if (prop_desc_p->flags & (JERRY_PROP_IS_WRITABLE_DEFINED | JERRY_PROP_IS_VALUE_DEFINED) && prop_desc_p->flags & (JERRY_PROP_IS_GET_DEFINED | JERRY_PROP_IS_SET_DEFINED)) { - return jerry_type_error_or_false (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p), prop_desc_p->flags); + return jerry_type_error_or_false (ECMA_ERR_WRONG_ARGS_MSG, prop_desc_p->flags); } ecma_property_descriptor_t prop_desc = jerry_property_descriptor_to_ecma (prop_desc_p); if (ECMA_IS_VALUE_ERROR (prop_desc.value)) { - return jerry_type_error_or_false (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p), prop_desc_p->flags); + return jerry_type_error_or_false (ECMA_ERR_WRONG_ARGS_MSG, prop_desc_p->flags); } return jerry_return (ecma_op_object_define_own_property (ecma_get_object_from_value (obj_val), @@ -4034,14 +4035,14 @@ jerry_call_function (const jerry_value_t func_obj_val, /**< function object to c if (ecma_is_value_error_reference (this_val)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } for (jerry_size_t i = 0; i < args_count; i++) { if (ecma_is_value_error_reference (args_p[i])) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_value_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_VALUE_MSG)); } } @@ -4067,14 +4068,14 @@ jerry_construct_object (const jerry_value_t func_obj_val, /**< function object t if (!jerry_value_is_constructor (func_obj_val)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } for (jerry_size_t i = 0; i < args_count; i++) { if (ecma_is_value_error_reference (args_p[i])) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_value_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_VALUE_MSG)); } } @@ -4100,7 +4101,7 @@ jerry_get_object_keys (const jerry_value_t obj_val) /**< object value */ if (!ecma_is_value_object (obj_val)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } ecma_collection_t *prop_names = @@ -4132,7 +4133,7 @@ jerry_get_prototype (const jerry_value_t obj_val) /**< object value */ if (!ecma_is_value_object (obj_val)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } ecma_object_t *obj_p = ecma_get_object_from_value (obj_val); @@ -4170,7 +4171,7 @@ jerry_set_prototype (const jerry_value_t obj_val, /**< object value */ 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))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } ecma_object_t *obj_p = ecma_get_object_from_value (obj_val); @@ -4547,7 +4548,7 @@ jerry_object_get_property_names (const jerry_value_t obj_val, /**< object */ if (!ecma_is_value_object (obj_val)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } ecma_object_t *obj_p = ecma_get_object_from_value (obj_val); @@ -4722,7 +4723,7 @@ jerry_from_property_descriptor (const jerry_property_descriptor_t *src_prop_desc if (ECMA_IS_VALUE_ERROR (prop_desc.value)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } ecma_object_t *desc_obj_p = ecma_op_from_property_descriptor (&prop_desc); @@ -4774,12 +4775,12 @@ jerry_resolve_or_reject_promise (jerry_value_t promise, /**< the promise value * #if JERRY_ESNEXT if (!ecma_is_value_object (promise) || !ecma_is_promise (ecma_get_object_from_value (promise))) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } if (ecma_is_value_error_reference (argument)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_value_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_VALUE_MSG)); } if (is_resolve) @@ -4793,7 +4794,7 @@ jerry_resolve_or_reject_promise (jerry_value_t promise, /**< the promise value * JERRY_UNUSED (argument); JERRY_UNUSED (is_resolve); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_promise_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_PROMISE_NOT_SUPPORTED)); #endif /* JERRY_ESNEXT */ } /* jerry_resolve_or_reject_promise */ @@ -4811,13 +4812,13 @@ jerry_get_promise_result (const jerry_value_t promise) /**< promise object to ge #if JERRY_ESNEXT if (!jerry_value_is_promise (promise)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } return ecma_promise_get_result (ecma_get_object_from_value (promise)); #else /* !JERRY_ESNEXT */ JERRY_UNUSED (promise); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_promise_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_PROMISE_NOT_SUPPORTED)); #endif /* JERRY_ESNEXT */ } /* jerry_get_promise_result */ @@ -4926,7 +4927,7 @@ jerry_get_symbol_description (const jerry_value_t symbol) /**< symbol value */ #if JERRY_ESNEXT if (!ecma_is_value_symbol (symbol)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } /* Note: This operation cannot throw an error */ @@ -4934,7 +4935,7 @@ jerry_get_symbol_description (const jerry_value_t symbol) /**< symbol value */ #else /* !JERRY_ESNEXT */ JERRY_UNUSED (symbol); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_symbol_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_SYMBOL_NOT_SUPPORTED)); #endif /* JERRY_ESNEXT */ } /* jerry_get_symbol_description */ @@ -4955,7 +4956,7 @@ jerry_get_symbol_descriptive_string (const jerry_value_t symbol) /**< symbol val #if JERRY_ESNEXT if (!ecma_is_value_symbol (symbol)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } /* Note: This operation cannot throw an error */ @@ -4963,7 +4964,7 @@ jerry_get_symbol_descriptive_string (const jerry_value_t symbol) /**< symbol val #else /* !JERRY_ESNEXT */ JERRY_UNUSED (symbol); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_symbol_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_SYMBOL_NOT_SUPPORTED)); #endif /* JERRY_ESNEXT */ } /* jerry_get_symbol_descriptive_string */ @@ -5052,7 +5053,7 @@ jerry_get_proxy_target (jerry_value_t proxy_value) /**< proxy value */ JERRY_UNUSED (proxy_value); #endif /* JERRY_BUILTIN_PROXY */ - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_argument_is_not_a_proxy))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_ARGUMENT_IS_NOT_A_PROXY)); } /* jerry_get_proxy_target */ /** @@ -5086,7 +5087,7 @@ jerry_get_proxy_handler (jerry_value_t proxy_value) /**< proxy value */ JERRY_UNUSED (proxy_value); #endif /* JERRY_BUILTIN_PROXY */ - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_argument_is_not_a_proxy))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_ARGUMENT_IS_NOT_A_PROXY)); } /* jerry_get_proxy_handler */ /** @@ -5675,10 +5676,10 @@ jerry_set_realm (jerry_value_t realm_value) /**< jerry api value */ } } - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Passed argument is not a realm"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_PASSED_ARGUMENT_IS_NOT_A_REALM)); #else /* !JERRY_BUILTIN_REALMS */ JERRY_UNUSED (realm_value); - return jerry_throw (ecma_raise_reference_error (ECMA_ERR_MSG ("Realm is not available"))); + return jerry_throw (ecma_raise_reference_error (ECMA_ERR_REALM_IS_NOT_AVAILABLE)); #endif /* JERRY_BUILTIN_REALMS */ } /* jerry_set_realm */ @@ -5717,7 +5718,7 @@ jerry_realm_get_this (jerry_value_t realm_value) /**< realm value */ } #endif /* JERRY_BUILTIN_REALMS */ - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Passed argument is not a realm"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_PASSED_ARGUMENT_IS_NOT_A_REALM)); } /* jerry_realm_get_this */ /** @@ -5738,7 +5739,7 @@ jerry_realm_set_this (jerry_value_t realm_value, /**< realm value */ #if JERRY_BUILTIN_REALMS if (!ecma_is_value_object (this_value)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Second argument must be an object"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_SECOND_ARGUMENT_MUST_BE_AN_OBJECT)); } if (ecma_is_value_object (realm_value)) @@ -5761,11 +5762,11 @@ jerry_realm_set_this (jerry_value_t realm_value, /**< realm value */ } } - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("First argument is not a realm"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_FIRST_ARGUMENT_IS_NOT_A_REALM)); #else /* !JERRY_BUILTIN_REALMS */ JERRY_UNUSED (realm_value); JERRY_UNUSED (this_value); - return jerry_throw (ecma_raise_reference_error (ECMA_ERR_MSG ("Realm is not available"))); + return jerry_throw (ecma_raise_reference_error (ECMA_ERR_REALM_IS_NOT_AVAILABLE)); #endif /* JERRY_BUILTIN_REALMS */ } /* jerry_realm_set_this */ @@ -5808,7 +5809,7 @@ jerry_create_arraybuffer (const jerry_length_t size) /**< size of the backing st return jerry_return (ecma_make_object_value (ecma_arraybuffer_new_object (size))); #else /* !JERRY_BUILTIN_TYPEDARRAY */ JERRY_UNUSED (size); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_typed_array_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_TYPED_ARRAY_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_TYPEDARRAY */ } /* jerry_create_arraybuffer */ @@ -5856,7 +5857,7 @@ jerry_create_arraybuffer_external (const jerry_length_t size, /**< size of the b JERRY_UNUSED (size); JERRY_UNUSED (buffer_p); JERRY_UNUSED (arraybuffer_user_p); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_typed_array_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_TYPED_ARRAY_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_TYPEDARRAY */ } /* jerry_create_arraybuffer_external */ @@ -5894,7 +5895,7 @@ jerry_create_shared_arraybuffer (const jerry_length_t size) /**< size of the bac return jerry_return (ecma_make_object_value (ecma_shared_arraybuffer_new_object (size))); #else /* !JERRY_BUILTIN_SHAREDARRAYBUFFER */ JERRY_UNUSED (size); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_shared_arraybuffer_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_SHARED_ARRAYBUFFER_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */ } /* jerry_create_shared_arraybuffer */ @@ -5944,7 +5945,7 @@ jerry_create_shared_arraybuffer_external (const jerry_length_t size, /**< size o JERRY_UNUSED (size); JERRY_UNUSED (buffer_p); JERRY_UNUSED (arraybuffer_user_p); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_shared_arraybuffer_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_SHARED_ARRAYBUFFER_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */ } /* jerry_create_shared_arraybuffer_external */ @@ -6167,7 +6168,7 @@ jerry_is_arraybuffer_detachable (const jerry_value_t value) /**< ArrayBuffer */ #else /* !JERRY_BUILTIN_TYPEDARRAY */ JERRY_UNUSED (value); #endif /* JERRY_BUILTIN_TYPEDARRAY */ - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Expected an ArrayBuffer"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_EXPECTED_AN_ARRAYBUFFER)); } /* jerry_is_arraybuffer_detachable */ /** @@ -6192,12 +6193,12 @@ jerry_detach_arraybuffer (const jerry_value_t value) /**< ArrayBuffer */ { return ECMA_VALUE_NULL; } - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer has already been detached"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_ARRAY_BUFFER_DETACHED)); } #else /* !JERRY_BUILTIN_TYPEDARRAY */ JERRY_UNUSED (value); #endif /* JERRY_BUILTIN_TYPEDARRAY */ - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Expected an ArrayBuffer"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_EXPECTED_AN_ARRAYBUFFER)); } /* jerry_detach_arraybuffer */ /** @@ -6301,7 +6302,7 @@ jerry_create_dataview (const jerry_value_t array_buffer, /**< arraybuffer to cre #if JERRY_BUILTIN_DATAVIEW if (ecma_is_value_error_reference (array_buffer)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } ecma_value_t arguments_p[3] = { array_buffer, @@ -6320,7 +6321,7 @@ jerry_create_dataview (const jerry_value_t array_buffer, /**< arraybuffer to cre JERRY_UNUSED (array_buffer); JERRY_UNUSED (byte_offset); JERRY_UNUSED (byte_length); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_data_view_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_DATA_VIEW_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_DATAVIEW */ } /* jerry_create_dataview */ @@ -6365,7 +6366,7 @@ jerry_get_dataview_buffer (const jerry_value_t value, /**< DataView to get the a #if JERRY_BUILTIN_DATAVIEW if (ecma_is_value_error_reference (value)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } ecma_dataview_object_t *dataview_p = ecma_op_dataview_get_object (value); @@ -6393,7 +6394,7 @@ jerry_get_dataview_buffer (const jerry_value_t value, /**< DataView to get the a JERRY_UNUSED (value); JERRY_UNUSED (byte_offset); JERRY_UNUSED (byte_length); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_data_view_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_DATA_VIEW_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_DATAVIEW */ } /* jerry_get_dataview_buffer */ @@ -6510,7 +6511,7 @@ jerry_create_typedarray (jerry_typedarray_type_t type_name, /**< type of TypedAr if (!jerry_typedarray_find_by_type (type_name, &prototype_id, &id, &element_size_shift)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Incorrect type for TypedArray"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_INCORRECT_TYPE_FOR_TYPEDARRAY)); } ecma_object_t *prototype_obj_p = ecma_builtin_get (prototype_id); @@ -6524,7 +6525,7 @@ jerry_create_typedarray (jerry_typedarray_type_t type_name, /**< type of TypedAr #else /* !JERRY_BUILTIN_TYPEDARRAY */ JERRY_UNUSED (type_name); JERRY_UNUSED (length); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_typed_array_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_TYPED_ARRAY_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_TYPEDARRAY */ } /* jerry_create_typedarray */ @@ -6548,7 +6549,7 @@ jerry_create_typedarray_for_arraybuffer_sz (jerry_typedarray_type_t type_name, / #if JERRY_BUILTIN_TYPEDARRAY if (ecma_is_value_error_reference (arraybuffer)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_value_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_VALUE_MSG)); } ecma_builtin_id_t prototype_id = 0; @@ -6557,12 +6558,12 @@ jerry_create_typedarray_for_arraybuffer_sz (jerry_typedarray_type_t type_name, / if (!jerry_typedarray_find_by_type (type_name, &prototype_id, &id, &element_size_shift)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Incorrect type for TypedArray"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_INCORRECT_TYPE_FOR_TYPEDARRAY)); } if (!ecma_is_arraybuffer (arraybuffer)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Argument is not an ArrayBuffer"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_ARGUMENT_NOT_ARRAY_BUFFER)); } ecma_object_t *prototype_obj_p = ecma_builtin_get (prototype_id); @@ -6578,7 +6579,7 @@ jerry_create_typedarray_for_arraybuffer_sz (jerry_typedarray_type_t type_name, / JERRY_UNUSED (arraybuffer); JERRY_UNUSED (byte_offset); JERRY_UNUSED (length); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_typed_array_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_TYPED_ARRAY_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_TYPEDARRAY */ } /* jerry_create_typedarray_for_arraybuffer_sz */ @@ -6600,7 +6601,7 @@ jerry_create_typedarray_for_arraybuffer (jerry_typedarray_type_t type_name, /**< #if JERRY_BUILTIN_TYPEDARRAY if (ecma_is_value_error_reference (arraybuffer)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_value_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_VALUE_MSG)); } jerry_length_t byteLength = jerry_get_arraybuffer_byte_length (arraybuffer); @@ -6608,7 +6609,7 @@ jerry_create_typedarray_for_arraybuffer (jerry_typedarray_type_t type_name, /**< #else /* !JERRY_BUILTIN_TYPEDARRAY */ JERRY_UNUSED (type_name); JERRY_UNUSED (arraybuffer); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_typed_array_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_TYPED_ARRAY_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_TYPEDARRAY */ } /* jerry_create_typedarray_for_arraybuffer */ @@ -6691,7 +6692,7 @@ jerry_get_typedarray_buffer (jerry_value_t value, /**< TypedArray to get the arr #if JERRY_BUILTIN_TYPEDARRAY if (!ecma_is_typedarray (value)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Object is not a TypedArray"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_OBJECT_IS_NOT_A_TYPEDARRAY)); } ecma_object_t *array_p = ecma_get_object_from_value (value); @@ -6714,7 +6715,7 @@ jerry_get_typedarray_buffer (jerry_value_t value, /**< TypedArray to get the arr JERRY_UNUSED (value); JERRY_UNUSED (byte_length); JERRY_UNUSED (byte_offset); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_typed_array_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_TYPED_ARRAY_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_TYPEDARRAY */ } /* jerry_get_typedarray_buffer */ @@ -6740,7 +6741,7 @@ jerry_json_parse (const jerry_char_t *string_p, /**< json string */ if (ecma_is_value_undefined (ret_value)) { - ret_value = jerry_throw (ecma_raise_syntax_error (ECMA_ERR_MSG ("JSON string parse error"))); + ret_value = jerry_throw (ecma_raise_syntax_error (ECMA_ERR_JSON_STRING_PARSE_ERROR)); } return jerry_return (ret_value); @@ -6748,7 +6749,7 @@ jerry_json_parse (const jerry_char_t *string_p, /**< json string */ JERRY_UNUSED (string_p); JERRY_UNUSED (string_size); - return jerry_throw (ecma_raise_syntax_error (ECMA_ERR_MSG (ecma_error_json_not_supported_p))); + return jerry_throw (ecma_raise_syntax_error (ECMA_ERR_JSON_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_JSON */ } /* jerry_json_parse */ @@ -6770,21 +6771,21 @@ jerry_json_stringify (const jerry_value_t input_value) /**< a value to stringify #if JERRY_BUILTIN_JSON if (ecma_is_value_error_reference (input_value)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_value_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_VALUE_MSG)); } ecma_value_t ret_value = ecma_builtin_json_stringify_no_opts (input_value); if (ecma_is_value_undefined (ret_value)) { - ret_value = jerry_throw (ecma_raise_syntax_error (ECMA_ERR_MSG ("JSON stringify error"))); + ret_value = jerry_throw (ecma_raise_syntax_error (ECMA_ERR_JSON_STRINGIFY_ERROR)); } return jerry_return (ret_value); #else /* JERRY_BUILTIN_JSON */ JERRY_UNUSED (input_value); - return jerry_throw (ecma_raise_syntax_error (ECMA_ERR_MSG (ecma_error_json_not_supported_p))); + return jerry_throw (ecma_raise_syntax_error (ECMA_ERR_JSON_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_JSON */ } /* jerry_json_stringify */ @@ -6809,7 +6810,7 @@ jerry_create_container (jerry_container_type_t container_type, /**< Type of the { if (ecma_is_value_error_reference (arguments_list_p[i])) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_value_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_VALUE_MSG)); } } @@ -6849,7 +6850,7 @@ jerry_create_container (jerry_container_type_t container_type, /**< Type of the } default: { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Invalid container type"))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_INVALID_CONTAINER_TYPE)); } } ecma_object_t *old_new_target_p = JERRY_CONTEXT (current_new_target_p); @@ -6867,7 +6868,7 @@ jerry_create_container (jerry_container_type_t container_type, /**< Type of the JERRY_UNUSED (arguments_list_p); JERRY_UNUSED (arguments_list_len); JERRY_UNUSED (container_type); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_container_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_CONTAINER_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_CONTAINER */ } /* jerry_create_container */ @@ -6936,18 +6937,16 @@ jerry_get_array_from_container (jerry_value_t value, /**< the container or itera jerry_assert_api_available (); #if JERRY_BUILTIN_CONTAINER - const char *container_needed = ECMA_ERR_MSG ("Value is not a Container or Iterator"); - if (!ecma_is_value_object (value)) { - return jerry_throw (ecma_raise_type_error (container_needed)); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_CONTAINER_NEEDED)); } ecma_object_t *obj_p = ecma_get_object_from_value (value); if (ecma_get_object_type (obj_p) != ECMA_OBJECT_TYPE_CLASS) { - return jerry_throw (ecma_raise_type_error (container_needed)); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_CONTAINER_NEEDED)); } ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p; @@ -7000,7 +6999,7 @@ jerry_get_array_from_container (jerry_value_t value, /**< the container or itera } else { - return jerry_throw (ecma_raise_type_error (container_needed)); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_CONTAINER_NEEDED)); } *is_key_value_p = (iterator_kind == ECMA_ITERATOR_ENTRIES); @@ -7029,7 +7028,7 @@ jerry_get_array_from_container (jerry_value_t value, /**< the container or itera #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))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_CONTAINER_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_CONTAINER */ } /* jerry_get_array_from_container */ @@ -7049,14 +7048,14 @@ jerry_container_operation (jerry_container_operation_t operation, /**< container #if JERRY_BUILTIN_CONTAINER if (!ecma_is_value_object (container)) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Container is not an object."))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_CONTAINER_IS_NOT_AN_OBJECT)); } ecma_object_t *obj_p = ecma_get_object_from_value (container); if (ecma_get_object_type (obj_p) != ECMA_OBJECT_TYPE_CLASS) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Container is not a container object."))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_CONTAINER_IS_NOT_A_CONTAINER_OBJECT)); } uint16_t type = ((ecma_extended_object_t *) obj_p)->u.cls.u2.container_id; ecma_extended_object_t *container_object_p = ecma_op_container_get_object (container, type); @@ -7075,7 +7074,7 @@ jerry_container_operation (jerry_container_operation_t operation, /**< container { if (arguments_number != 1 || ecma_is_value_error_reference (arguments[0])) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } break; } @@ -7084,7 +7083,7 @@ jerry_container_operation (jerry_container_operation_t operation, /**< container 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))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } break; } @@ -7093,18 +7092,17 @@ jerry_container_operation (jerry_container_operation_t operation, /**< container { if (arguments_number != 0) { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } break; } default: { - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_wrong_args_msg_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_WRONG_ARGS_MSG)); } } jerry_value_t result; - const char *incorrect_type_call = ECMA_ERR_MSG ("Operator called on incorrect container type"); switch (operation) { @@ -7112,7 +7110,7 @@ jerry_container_operation (jerry_container_operation_t operation, /**< container { if (type == LIT_MAGIC_STRING_MAP_UL || type == LIT_MAGIC_STRING_WEAKMAP_UL) { - return jerry_throw (ecma_raise_type_error (incorrect_type_call)); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_INCORRECT_TYPE_CALL)); } result = ecma_op_container_set (container_object_p, arguments[0], arguments[0], type); break; @@ -7121,7 +7119,7 @@ jerry_container_operation (jerry_container_operation_t operation, /**< container { if (type == LIT_MAGIC_STRING_SET_UL || type == LIT_MAGIC_STRING_WEAKSET_UL) { - return jerry_throw (ecma_raise_type_error (incorrect_type_call)); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_INCORRECT_TYPE_CALL)); } result = ecma_op_container_get (container_object_p, arguments[0], type); break; @@ -7130,7 +7128,7 @@ jerry_container_operation (jerry_container_operation_t operation, /**< container { if (type == LIT_MAGIC_STRING_SET_UL || type == LIT_MAGIC_STRING_WEAKSET_UL) { - return jerry_throw (ecma_raise_type_error (incorrect_type_call)); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_INCORRECT_TYPE_CALL)); } result = ecma_op_container_set (container_object_p, arguments[0], arguments[1], type); break; @@ -7159,14 +7157,14 @@ jerry_container_operation (jerry_container_operation_t operation, /**< container { if (type == LIT_MAGIC_STRING_WEAKSET_UL || type == LIT_MAGIC_STRING_WEAKMAP_UL) { - return jerry_throw (ecma_raise_type_error (incorrect_type_call)); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_INCORRECT_TYPE_CALL)); } result = ecma_op_container_clear (container_object_p); break; } default: { - result = jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Unsupported container operation"))); + result = jerry_throw (ecma_raise_type_error (ECMA_ERR_UNSUPPORTED_CONTAINER_OPERATION)); break; } } @@ -7176,7 +7174,7 @@ jerry_container_operation (jerry_container_operation_t operation, /**< container JERRY_UNUSED (container); JERRY_UNUSED (arguments); JERRY_UNUSED (arguments_number); - return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_container_not_supported_p))); + return jerry_throw (ecma_raise_type_error (ECMA_ERR_CONTAINER_NOT_SUPPORTED)); #endif /* JERRY_BUILTIN_CONTAINER */ } /* jerry_container_operation */ diff --git a/jerry-core/ecma/base/ecma-error-messages.inc.h b/jerry-core/ecma/base/ecma-error-messages.inc.h new file mode 100644 index 0000000000..380c55a269 --- /dev/null +++ b/jerry-core/ecma/base/ecma-error-messages.inc.h @@ -0,0 +1,856 @@ +/* Copyright JS Foundation and other contributors, http://js.foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* This file is automatically generated by the gen-strings.py script + * from ecma-error-messages.ini. Do not edit! */ + +#if JERRY_BUILTIN_REGEXP +ECMA_ERROR_DEF (ECMA_ERR_INVALID_GROUP, "Invalid group") +ECMA_ERROR_DEF (ECMA_ERR_INVALID_ESCAPE, "Invalid escape") +#endif /* JERRY_BUILTIN_REGEXP */ +#if JERRY_BUILTIN_ATOMICS || JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_INVALID_LENGTH, "Invalid length") +#endif /* JERRY_BUILTIN_ATOMICS \ +|| JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_INVALID_OFFSET, "Invalid offset") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +ECMA_ERROR_DEF (ECMA_ERR_OBJECT_EXPECTED, "Object expected") +#if JERRY_BUILTIN_ANNEXB && JERRY_BUILTIN_REGEXP +ECMA_ERROR_DEF (ECMA_ERR_INVALID_ARGUMENT, "Invalid argument") +#endif /* JERRY_BUILTIN_ANNEXB && JERRY_BUILTIN_REGEXP */ +#if JERRY_BUILTIN_REGEXP +ECMA_ERROR_DEF (ECMA_ERR_NOTHING_TO_REPEAT, "Nothing to repeat") +#endif /* JERRY_BUILTIN_REGEXP */ +ECMA_ERROR_DEF (ECMA_ERR_EXPECTED_AN_OBJECT, "Expected an object") +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_INVALID_CAPABILITY, "Invalid capability") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_STRING && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_INVALID_CODE_POINT, "Invalid code point") +#endif /* JERRY_BUILTIN_STRING && JERRY_ESNEXT */ +#if JERRY_BUILTIN_REGEXP +ECMA_ERROR_DEF (ECMA_ERR_INVALID_QUANTIFIER, "Invalid quantifier") +#endif /* JERRY_BUILTIN_REGEXP */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_NO_SOURCE_ARGUMENT, "No source argument") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_BUILTIN_REGEXP +ECMA_ERROR_DEF (ECMA_ERR_UNTERMINATED_GROUP, "Unterminated group") +#endif /* JERRY_BUILTIN_REGEXP */ +ECMA_ERROR_DEF (ECMA_ERR_EXPECTED_A_FUNCTION, "Expected a function") +#if JERRY_BUILTIN_JSON +ECMA_ERROR_DEF (ECMA_ERR_INVALID_JSON_FORMAT, "Invalid JSON format") +#endif /* JERRY_BUILTIN_JSON */ +ECMA_ERROR_DEF (ECMA_ERR_INVALID_UTF8_STRING, "Invalid UTF8 string") +#if JERRY_BUILTIN_STRING && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_INVALID_COUNT_VALUE, "Invalid count value") +#endif /* JERRY_BUILTIN_STRING && JERRY_ESNEXT */ +#if !(JERRY_BUILTIN_REALMS) +ECMA_ERROR_DEF (ECMA_ERR_REALMS_ARE_DISABLED, "Realms are disabled") +#endif /* !(JERRY_BUILTIN_REALMS) */ +ECMA_ERROR_DEF (ECMA_ERR_UNDEFINED_REFERENCE, "Undefined reference") +ECMA_ERROR_DEF (ECMA_ERR_INVALID_ARRAY_LENGTH, "Invalid Array length") +#if JERRY_BUILTIN_REGEXP +ECMA_ERROR_DEF (ECMA_ERR_INVALID_REGEXP_FLAGS, "Invalid RegExp flags") +#endif /* JERRY_BUILTIN_REGEXP */ +#if JERRY_BUILTIN_JSON +ECMA_ERROR_DEF (ECMA_ERR_JSON_STRINGIFY_ERROR, "JSON stringify error") +#endif /* JERRY_BUILTIN_JSON */ +#if JERRY_BUILTIN_REGEXP +ECMA_ERROR_DEF (ECMA_ERR_STACK_LIMIT_EXCEEDED, "Stack limit exceeded") +#endif /* JERRY_BUILTIN_REGEXP */ +#if JERRY_BUILTIN_WEAKREF +ECMA_ERROR_DEF (ECMA_ERR_TARGET_IS_NOT_OBJECT, "Target is not Object") +#endif /* JERRY_BUILTIN_WEAKREF */ +#if JERRY_BUILTIN_BIGINT +ECMA_ERROR_DEF (ECMA_ERR_BIGINT_VALUE_EXCPECTED, "BigInt value expected") +#endif /* JERRY_BUILTIN_BIGINT */ +ECMA_ERROR_DEF (ECMA_ERR_BINDING_CANNOT_SET, "Binding cannot be set") +#if JERRY_BUILTIN_STRING && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_INVALID_STRING_, "Invalid string length") +#endif /* JERRY_BUILTIN_STRING && JERRY_ESNEXT */ +#if JERRY_BUILTIN_CONTAINER +ECMA_ERROR_DEF (ECMA_ERR_KEY_MUST_BE_AN_OBJECT, "Key must be an object") +#endif /* JERRY_BUILTIN_CONTAINER */ +#if JERRY_BUILTIN_ARRAY +ECMA_ERROR_DEF (ECMA_ERR_MISSING_ARRAY_ELEMENT, "Missing Array element") +#endif /* JERRY_BUILTIN_ARRAY */ +#if JERRY_BUILTIN_WEAKREF +ECMA_ERROR_DEF (ECMA_ERR_TARGET_IS_NOT_WEAKREF, "Target is not weakRef") +#endif /* JERRY_BUILTIN_WEAKREF */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_TARGET_NOT_EXTENSIBLE, "Target not extensible") +#endif /* JERRY_BUILTIN_PROXY */ +#if JERRY_ESNEXT && JERRY_BUILTIN_ANNEXB +ECMA_ERROR_DEF (ECMA_ERR_GETTER_IS_NOT_CALLABLE, "Getter is not callable") +#endif /* JERRY_ESNEXT && JERRY_BUILTIN_ANNEXB */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_HANDLER_CANNOT_BE_NULL, "Handler cannot be null") +#endif /* JERRY_BUILTIN_PROXY */ +ECMA_ERROR_DEF (ECMA_ERR_INVALID_UTF8_CHARACTER, "Invalid UTF8 character") +ECMA_ERROR_DEF (ECMA_ERR_INVALID_UTF8_CODEPOINT, "Invalid UTF8 codepoint") +#if JERRY_BUILTIN_CONTAINER +ECMA_ERROR_DEF (ECMA_ERR_INVALID_CONTAINER_TYPE, "Invalid container type") +#endif /* JERRY_BUILTIN_CONTAINER */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_INVALID_RANGE_OF_INDEX, "Invalid range of index") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if !(JERRY_BUILTIN_PROXY) +ECMA_ERROR_DEF (ECMA_ERR_PROXY_IS_NOT_SUPPORTED, "Proxy is not supported") +#endif /* !(JERRY_BUILTIN_PROXY) */ +#if !(JERRY_BUILTIN_REALMS) +ECMA_ERROR_DEF (ECMA_ERR_REALM_IS_NOT_AVAILABLE, "Realm is not available") +#endif /* !(JERRY_BUILTIN_REALMS) */ +#if JERRY_BUILTIN_BIGINT +ECMA_ERROR_DEF (ECMA_ERR_BIGINT_ZERO_DIVISION, "BigInt division by zero") +#endif /* JERRY_BUILTIN_BIGINT */ +ECMA_ERROR_DEF (ECMA_ERR_EXPECTED_AN_ARRAYBUFFER, "Expected an ArrayBuffer") +#if JERRY_BUILTIN_REGEXP && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_INVALID_CHARACTER_CLASS, "Invalid character class") +ECMA_ERROR_DEF (ECMA_ERR_INVALID_ESCAPE_SEQUENCE, "Invalid escape sequence") +#endif /* JERRY_BUILTIN_REGEXP && JERRY_ESNEXT */ +#if JERRY_SNAPSHOT_EXEC +ECMA_ERROR_DEF (ECMA_ERR_INVALID_SNAPSHOT_FORMAT, "Invalid snapshot format") +#endif /* JERRY_SNAPSHOT_EXEC */ +#if JERRY_BUILTIN_JSON +ECMA_ERROR_DEF (ECMA_ERR_JSON_STRING_PARSE_ERROR, "JSON string parse error") +#endif /* JERRY_BUILTIN_JSON */ +#if JERRY_BUILTIN_REGEXP && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_LONE_QUANTIFIER_BRACKET, "Lone quantifier bracket") +#endif /* JERRY_BUILTIN_REGEXP && JERRY_ESNEXT */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_OBJECT_CANNOT_BE_FROZEN, "Object cannot be frozen") +ECMA_ERROR_DEF (ECMA_ERR_OBJECT_CANNOT_BE_SEALED, "Object cannot be sealed") +#endif /* JERRY_BUILTIN_PROXY */ +#if !(JERRY_BUILTIN_REGEXP) +ECMA_ERROR_DEF (ECMA_ERR_REGEXP_IS_NOT_SUPPORTED, "RegExp is not supported") +#endif /* !(JERRY_BUILTIN_REGEXP) */ +#if JERRY_BUILTIN_REGEXP +ECMA_ERROR_DEF (ECMA_ERR_UNMATCHED_CLOSE_BRACKET, "Unmatched close bracket") +#endif /* JERRY_BUILTIN_REGEXP */ +#if JERRY_MODULE_SYSTEM +ECMA_ERROR_DEF (ECMA_ERR_NOT_MODULE, "Argument is not a module") +#endif /* JERRY_MODULE_SYSTEM */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_SET_PROTOTYPE, "Cannot set [[Prototype]]") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_ARRAY && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_INVALID_NEW_ARRAY_LENGTH, "Invalid new Array length") +#endif /* JERRY_BUILTIN_ARRAY && JERRY_ESNEXT */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_IS_NOT_CALLABLE, "Iterator is not callable") +#endif /* JERRY_ESNEXT */ +#if !(JERRY_BUILTIN_JSON) +ECMA_ERROR_DEF (ECMA_ERR_JSON_NOT_SUPPORTED, "JSON support is disabled") +#endif /* !(JERRY_BUILTIN_JSON) */ +#if JERRY_MODULE_SYSTEM +ECMA_ERROR_DEF (ECMA_ERR_MODULE_IS_IN_ERROR_STATE, "Module is in error state") +#endif /* JERRY_MODULE_SYSTEM */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_REJECT_MUST_BE_UNDEFINED, "Reject must be undefined") +#endif /* JERRY_ESNEXT */ +#if JERRY_MODULE_SYSTEM +ECMA_ERROR_DEF (ECMA_ERR_REQUEST_IS_NOT_AVAILABLE, "Request is not available") +#endif /* JERRY_MODULE_SYSTEM */ +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT, "Argument is not an object") +#if JERRY_BUILTIN_ATOMICS +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_NOT_SUPPORTED, "Argument is not supported") +#endif /* JERRY_BUILTIN_ATOMICS */ +#if JERRY_BUILTIN_STRING && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_INVALID_CODE_POINT_ERROR, "Error: Invalid code point") +#endif /* JERRY_BUILTIN_STRING && JERRY_ESNEXT */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_INVALID_TYPEDARRAY_LENGTH, "Invalid TypedArray length") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +ECMA_ERROR_DEF (ECMA_ERR_INVALID_HEXADECIMAL_VALUE, "Invalid hexadecimal value") +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_IS_NOT_AN_OBJECT, "Iterator is not an object") +ECMA_ERROR_DEF (ECMA_ERR_RESOLVE_MUST_BE_UNDEFINED, "Resolve must be undefined") +#endif /* JERRY_ESNEXT */ +#if JERRY_SNAPSHOT_SAVE +ECMA_ERROR_DEF (ECMA_ERR_SNAPSHOT_BUFFER_SMALL, "Snapshot buffer too small") +#endif /* JERRY_SNAPSHOT_SAVE */ +#if JERRY_BUILTIN_JSON +ECMA_ERROR_DEF (ECMA_ERR_THE_STRUCTURE_IS_CYCLICAL, "The structure is cyclical") +#endif /* JERRY_BUILTIN_JSON */ +#if JERRY_BUILTIN_REGEXP +ECMA_ERROR_DEF (ECMA_ERR_UNEXPECTED_END_OF_PATTERN, "Unexpected end of pattern") +#endif /* JERRY_BUILTIN_REGEXP */ +#if !(JERRY_BUILTIN_BIGINT) +ECMA_ERROR_DEF (ECMA_ERR_BIGINT_NOT_SUPPORTED, "BigInt support is disabled") +#endif /* !(JERRY_BUILTIN_BIGINT) */ +#if JERRY_BUILTIN_DATAVIEW +ECMA_ERROR_DEF (ECMA_ERR_EXPECTED_A_DATAVIEW_OBJECT, "Expected a DataView object") +#endif /* JERRY_BUILTIN_DATAVIEW */ +ECMA_ERROR_DEF (ECMA_ERR_EXPECTED_A_FUNCTION_OBJECT, "Expected a function object") +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_INVALID_ARRAYBUFFER_LENGTH, "Invalid ArrayBuffer length") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if !(JERRY_MODULE_SYSTEM) +ECMA_ERROR_DEF (ECMA_ERR_MODULE_NOT_SUPPORTED, "Module support is disabled") +#endif /* !(JERRY_MODULE_SYSTEM) */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_OBJECT_IS_NOT_A_TYPEDARRAY, "Object is not a TypedArray") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_RECEIVER_MUST_BE_AN_OBJECT, "Receiver must be an object") +#endif /* JERRY_ESNEXT */ +#if !(JERRY_ESNEXT) +ECMA_ERROR_DEF (ECMA_ERR_SYMBOL_NOT_SUPPORTED, "Symbol support is disabled") +#endif /* !(JERRY_ESNEXT) */ +#if JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_JSON +ECMA_ERROR_DEF (ECMA_ERR_BIGINT_SERIALIZED, "BigInt cannot be serialized") +#endif /* JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_JSON */ +#if JERRY_BUILTIN_CONTAINER +ECMA_ERROR_DEF (ECMA_ERR_CONTAINER_IS_NOT_AN_OBJECT, "Container is not an object.") +#endif /* JERRY_BUILTIN_CONTAINER */ +#if JERRY_BUILTIN_REGEXP && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_INVALID_HEX_ESCAPE_SEQUENCE, "Invalid hex escape sequence") +#endif /* JERRY_BUILTIN_REGEXP && JERRY_ESNEXT */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_INVALID_SPECIES_CONSTRUCTOR, "Invalid species constructor") +#endif /* JERRY_ESNEXT */ +#if !(JERRY_ESNEXT) +ECMA_ERROR_DEF (ECMA_ERR_PROMISE_NOT_SUPPORTED, "Promise support is disabled") +#endif /* !(JERRY_ESNEXT) */ +#if JERRY_BUILTIN_PROXY || JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_PROXY_TRAP_RETURNED_FALSISH, "Proxy trap returned falsish") +#endif /* JERRY_BUILTIN_PROXY \ +|| JERRY_ESNEXT */ +#if JERRY_BUILTIN_REGEXP +ECMA_ERROR_DEF (ECMA_ERR_MIN_GREATER_THAN_MAX, "Quantifier error: min > max") +#endif /* JERRY_BUILTIN_REGEXP */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_SYMBOL_IS_NOT_A_CONSTRUCTOR, "Symbol is not a constructor") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_REFLECT +ECMA_ERROR_DEF (ECMA_ERR_TARGET_IS_NOT_A_CONSTRUCTOR, "Target is not a constructor") +#endif /* JERRY_BUILTIN_REFLECT */ +ECMA_ERROR_DEF (ECMA_ERR_ACCESSOR_WRITABLE, "Accessors cannot be writable") +#if !(JERRY_BUILTIN_DATAVIEW) +ECMA_ERROR_DEF (ECMA_ERR_DATA_VIEW_NOT_SUPPORTED, "DataView support is disabled") +#endif /* !(JERRY_BUILTIN_DATAVIEW) */ +#if JERRY_BUILTIN_DATE +ECMA_ERROR_DEF (ECMA_ERR_DATE_MUST_BE_A_FINITE_NUMBER, "Date must be a finite number") +#endif /* JERRY_BUILTIN_DATE */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_LOCAL_VARIABLE_IS_REDECLARED, "Local variable is redeclared") +#endif /* JERRY_ESNEXT */ +ECMA_ERROR_DEF (ECMA_ERR_UNSUPPORTED_BINARY_OPERATION, "Unsupported binary operation") +#if JERRY_BUILTIN_REGEXP +ECMA_ERROR_DEF (ECMA_ERR_UNTERMINATED_CHARACTER_CLASS, "Unterminated character class") +#endif /* JERRY_BUILTIN_REGEXP */ +#if JERRY_BUILTIN_DATAVIEW || JERRY_BUILTIN_TYPEDARRAY || JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_ARRAYBUFFER_IS_DETACHED, "ArrayBuffer has been detached") +#endif /* JERRY_BUILTIN_DATAVIEW \ +|| JERRY_BUILTIN_TYPEDARRAY \ +|| JERRY_ESNEXT */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_NOT_AN_OBJECT, "Constructor must be an object") +#endif /* JERRY_ESNEXT */ +#if !(JERRY_BUILTIN_CONTAINER) +ECMA_ERROR_DEF (ECMA_ERR_CONTAINER_NOT_SUPPORTED, "Container support is disabled") +#endif /* !(JERRY_BUILTIN_CONTAINER) */ +#if JERRY_BUILTIN_REALMS +ECMA_ERROR_DEF (ECMA_ERR_FIRST_ARGUMENT_IS_NOT_A_REALM, "First argument is not a realm") +#endif /* JERRY_BUILTIN_REALMS */ +#if JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_INCOMPATIBLE_TYPEDARRAY_TYPES, "Incompatible TypedArray types") +#endif /* JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_INCORRECT_TYPE_FOR_TYPEDARRAY, "Incorrect type for TypedArray") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_INVALID_OR_OUT_OF_RANGE_INDEX, "Invalid or out-of-range index") +#endif /* JERRY_ESNEXT */ +#if JERRY_SNAPSHOT_SAVE +ECMA_ERROR_DEF (ECMA_ERR_MAXIMUM_SNAPSHOT_SIZE, "Maximum snapshot size reached") +#endif /* JERRY_SNAPSHOT_SAVE */ +#if JERRY_MODULE_SYSTEM +ECMA_ERROR_DEF (ECMA_ERR_MODULE_CANNOT_BE_INSTANTIATED, "Module cannot be instantiated") +#endif /* JERRY_MODULE_SYSTEM */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_SPECIES_MUST_BE_A_CONSTRUCTOR, "Species must be a constructor") +#endif /* JERRY_ESNEXT */ +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_IS_NOT_A_PROXY, "Argument is not a Proxy object") +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_NOT_ARRAY_BUFFER, "Argument is not an ArrayBuffer") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_BUILTIN_CONTAINER +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_MAP_REQUIRES_NEW, "Constructor Map requires 'new'") +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_SET_REQUIRES_NEW, "Constructor Set requires 'new'") +#endif /* JERRY_BUILTIN_CONTAINER */ +#if JERRY_MODULE_SYSTEM +ECMA_ERROR_DEF (ECMA_ERR_MODULE_MUST_BE_IN_LINKED_STATE, "Module must be in linked state") +ECMA_ERROR_DEF (ECMA_ERR_UNKNOWN_EXPORT, "Native module export not found") +#endif /* JERRY_MODULE_SYSTEM */ +ECMA_ERROR_DEF (ECMA_ERR_PASSED_ARGUMENT_IS_NOT_A_REALM, "Passed argument is not a realm") +#if JERRY_BUILTIN_BIGINT || JERRY_BUILTIN_NUMBER +ECMA_ERROR_DEF (ECMA_ERR_RADIX_IS_OUT_OF_RANGE, "Radix must be between 2 and 36") +#endif /* JERRY_BUILTIN_BIGINT \ +|| JERRY_BUILTIN_NUMBER */ +#if !(JERRY_BUILTIN_TYPEDARRAY) +ECMA_ERROR_DEF (ECMA_ERR_TYPED_ARRAY_NOT_SUPPORTED, "TypedArray support is disabled") +#endif /* !(JERRY_BUILTIN_TYPEDARRAY) */ +ECMA_ERROR_DEF (ECMA_ERR_UNICODE_SURROGATE_PAIR_MISSING, "Unicode surrogate pair missing") +#if JERRY_BUILTIN_REGEXP && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_INVALID_CONTROL_ESCAPE_SEQUENCE, "Invalid control escape sequence") +ECMA_ERROR_DEF (ECMA_ERR_INVALID_UNICODE_ESCAPE_SEQUENCE, "Invalid unicode escape sequence") +#endif /* JERRY_BUILTIN_REGEXP && JERRY_ESNEXT */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_NEXT_IS_NOT_CALLABLE, "Iterator 'next' is not callable") +ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_VALUE_IS_NOT_AN_OBJECT, "Iterator value is not an object") +ECMA_ERROR_DEF (ECMA_ERR_RESOLVE_METHOD_MUST_BE_CALLABLE, "Resolve method must be callable") +#endif /* JERRY_ESNEXT */ +#if !(JERRY_PARSER) +ECMA_ERROR_DEF (ECMA_ERR_PARSER_NOT_SUPPORTED, "Source code parsing is disabled") +#endif /* !(JERRY_PARSER) */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_TRAP_MUST_RETURN_WITH_AN_OBJECT, "Trap must return with an object") +#endif /* JERRY_BUILTIN_PROXY */ +#if JERRY_BUILTIN_CONTAINER +ECMA_ERROR_DEF (ECMA_ERR_UNSUPPORTED_CONTAINER_OPERATION, "Unsupported container operation") +#endif /* JERRY_BUILTIN_CONTAINER */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_METHOD_RETURN_IS_NOT_CALLABLE, "method 'return' is not callable") +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_PROMISE, "Argument 'this' is not a Promise") +#endif /* JERRY_ESNEXT */ +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT, "Argument 'this' is not an object") +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_SYMBOL, "Argument 'this' must be a Symbol") +#endif /* JERRY_ESNEXT */ +#if JERRY_MODULE_SYSTEM +ECMA_ERROR_DEF (ECMA_ERR_CALLBACK_RESULT_NOT_MODULE, "Callback result must be a module") +#endif /* JERRY_MODULE_SYSTEM */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_CLASS_CONSTRUCTOR_REQUIRES_NEW, "Class constructor requires 'new'") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_ARRAY +ECMA_ERROR_DEF (ECMA_ERR_COMPARE_FUNC_NOT_CALLABLE, "Compare function is not callable") +#endif /* JERRY_BUILTIN_ARRAY */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_PROXY_REQUIRES_NEW, "Constructor Proxy requires 'new'") +#endif /* JERRY_BUILTIN_PROXY */ +ECMA_ERROR_DEF (ECMA_ERR_EXPECTED_A_CONFIGURABLE_PROPERTY, "Expected a configurable property") +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_FIRST_PARAMETER_MUST_BE_CALLABLE, "First parameter must be callable") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_CONTAINER && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_FUNCTION_ADD_ORSET_IS_NOT_CALLABLE, "Function add/set is not callable") +#endif /* JERRY_BUILTIN_CONTAINER && JERRY_ESNEXT */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_RESULT_IS_NOT_AN_OBJECT, "Iterator result is not an object") +#endif /* JERRY_ESNEXT */ +#if (JERRY_STACK_LIMIT != 0) +ECMA_ERROR_DEF (ECMA_ERR_MAXIMUM_CALL_STACK_SIZE_EXCEEDED, "Maximum call stack size exceeded") +#endif /* (JERRY_STACK_LIMIT != 0) */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_MAXIMUM_STRING_LENGTH_IS_REACHED, "Maximum string length is reached") +#endif /* JERRY_ESNEXT */ +#if JERRY_MODULE_SYSTEM +ECMA_ERROR_DEF (ECMA_ERR_MODULE_MUST_BE_IN_UNLINKED_STATE, "Module must be in unlinked state") +#endif /* JERRY_MODULE_SYSTEM */ +#if JERRY_SNAPSHOT_EXEC +ECMA_ERROR_DEF (ECMA_ERR_STATIC_SNAPSHOTS_ARE_NOT_ENABLED, "Static snapshots are not enabled") +#endif /* JERRY_SNAPSHOT_EXEC */ +#if JERRY_BUILTIN_WEAKREF +ECMA_ERROR_DEF (ECMA_ERR_WEAKREF_TARGET_MUST_BE_AN_OBJECT, "WeakRef target must be an object") +#endif /* JERRY_BUILTIN_WEAKREF */ +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_FUNCTION, "Argument 'this' is not a function") +#if JERRY_BUILTIN_ATOMICS +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_NOT_SHARED_ARRAY_BUFFER, "Argument is not SharedArrayBuffer") +#endif /* JERRY_BUILTIN_ATOMICS */ +#if JERRY_BUILTIN_ARRAY || JERRY_BUILTIN_CONTAINER || JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_CALLBACK_IS_NOT_CALLABLE, "Callback function is not callable") +#endif /* JERRY_BUILTIN_ARRAY \ +|| JERRY_BUILTIN_CONTAINER \ +|| JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_INITIAL_VALUE_CANNOT_BE_UNDEFINED, "Initial value cannot be undefined") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_BUILTIN_REGEXP +ECMA_ERROR_DEF (ECMA_ERR_INPUT_MUST_BE_A_VALID_UTF8_STRING, "Input must be a valid utf8 string") +#endif /* JERRY_BUILTIN_REGEXP */ +#if JERRY_BUILTIN_SHAREDARRAYBUFFER +ECMA_ERROR_DEF (ECMA_ERR_INVALID_SHARED_ARRAYBUFFER_LENGTH, "Invalid Shared ArrayBuffer length") +#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */ +ECMA_ERROR_DEF (ECMA_ERR_INVALID_TYPE_FOR_CONSTRUCTOR_CALL, "Invalid type for constructor call") +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_THROW_IS_NOT_AVAILABLE, "Iterator 'throw' is not available") +#endif /* JERRY_ESNEXT */ +#if JERRY_MODULE_SYSTEM +ECMA_ERROR_DEF (ECMA_ERR_NAMESPACE_OBJECT_IS_NOT_AVAILABLE, "Namespace object is not available") +#endif /* JERRY_MODULE_SYSTEM */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_PROXY_TARGET_IS_NOT_A_CONSTRUCTOR, "Proxy target is not a constructor") +#endif /* JERRY_BUILTIN_PROXY */ +#if JERRY_BUILTIN_REALMS +ECMA_ERROR_DEF (ECMA_ERR_SECOND_ARGUMENT_MUST_BE_AN_OBJECT, "Second argument must be an object") +#endif /* JERRY_BUILTIN_REALMS */ +#if JERRY_BUILTIN_DATAVIEW +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_BUFFER_NOT_OBJECT, "Argument 'buffer' is not an object") +#endif /* JERRY_BUILTIN_DATAVIEW */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_ITERATOR, "Argument 'this' is not an iterator") +#endif /* JERRY_ESNEXT */ +ECMA_ERROR_DEF (ECMA_ERR_VALUE_MSG, "Argument cannot be marked as error") +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_PROMISE_REQUIRES_NEW, "Constructor Promise requires 'new'") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_CONTAINER +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_WEAKMAP_REQUIRES_NEW, "Constructor WeakMap requires 'new'") +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_WEAKSET_REQUIRES_NEW, "Constructor WeakSet requires 'new'") +#endif /* JERRY_BUILTIN_CONTAINER */ +#if JERRY_DEBUGGER +ECMA_ERROR_DEF (ECMA_ERR_INVALID_SCOPE_CHAIN_INDEX_FOR_EVAL, "Invalid scope chain index for eval") +#endif /* JERRY_DEBUGGER */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_MAXIMUM_TYPEDARRAY_SIZE_IS_REACHED, "Maximum TypedArray size is reached") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_THE_GIVEN_ARGUMENT_IS_NOT_A_SYMBOL, "The given argument is not a Symbol") +ECMA_ERROR_DEF (ECMA_ERR_PARAMETER_REJECT_MUST_BE_CALLABLE, "'reject' parameter must be callable") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_TYPEDARRAY || JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_TYPED_ARRAY, "Argument 'this' is not a TypedArray") +#endif /* JERRY_BUILTIN_TYPEDARRAY \ +|| JERRY_ESNEXT */ +#if JERRY_SNAPSHOT_SAVE +ECMA_ERROR_DEF (ECMA_ERR_CANNOT_ALLOCATE_MEMORY_LITERALS, "Cannot allocate memory for literals") +#endif /* JERRY_SNAPSHOT_SAVE */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_INVOKE_NULLABLE_SUPER_METHOD, "Cannot invoke nullable super method") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_DATAVIEW +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_DATAVIEW_REQUIRES_NEW, "Constructor DataView requires 'new'") +#endif /* JERRY_BUILTIN_DATAVIEW */ +#if JERRY_BUILTIN_WEAKREF +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_WEAKREF_REQUIRES_NEW, "Constructor WeakRef requires 'new'.") +#endif /* JERRY_BUILTIN_WEAKREF */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_SUPER_BINDING_MUST_BE_A_CONSTRUCTOR, "Super binding must be a constructor") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_BIGINT +ECMA_ERROR_DEF (ECMA_ERR_VALUE_CANNOT_BE_CONVERTED_TO_BIGINT, "Value cannot be converted to BigInt") +#endif /* JERRY_BUILTIN_BIGINT */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_PARAMETER_RESOLVE_MUST_BE_CALLABLE, "'resolve' parameter must be callable") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_DATE || JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_DATE_OBJECT, "Argument 'this' is not a Date object") +#endif /* JERRY_BUILTIN_DATE \ +|| JERRY_ESNEXT */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_CONSTRUCTOR, "Argument 'this' is not a constructor") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_BUILTIN_BIGINT +ECMA_ERROR_DEF (ECMA_ERR_BIGINT_FUNCTION_NOT_CONSTRUCTOR, "BigInt function is not a constructor") +#endif /* JERRY_BUILTIN_BIGINT */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTED_OBJECT_IS_NOT_TYPEDARRAY, "Constructed object is not TypedArray") +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_INT8_ARRAY_REQUIRES_NEW, "Constructor Int8Array requires 'new'") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_BUILTIN_CONTAINER +ECMA_ERROR_DEF (ECMA_ERR_CONTAINER_IS_NOT_A_CONTAINER_OBJECT, "Container is not a container object.") +#endif /* JERRY_BUILTIN_CONTAINER */ +#if JERRY_BUILTIN_DATE && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_INVALID_ARGUMENT_TYPE_IN_TOPRIMITIVE, "Invalid argument type in toPrimitive") +#endif /* JERRY_BUILTIN_DATE && JERRY_ESNEXT */ +#if JERRY_ERROR_MESSAGES && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_METHODS_INVOKE_WITH_NEW, "Methods cannot be invoked with 'new'") +#endif /* JERRY_ERROR_MESSAGES && JERRY_ESNEXT */ +#if JERRY_MODULE_SYSTEM +ECMA_ERROR_DEF (ECMA_ERR_MODULE_EXPORTS_MUST_BE_STRING_VALUES, "Module exports must be string values") +#endif /* JERRY_MODULE_SYSTEM */ +#if JERRY_BUILTIN_REFLECT || JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_PROTOTYPE_IS_NEITHER_OBJECT_NOR_NULL, "Prototype is neither object nor null") +#endif /* JERRY_BUILTIN_REFLECT \ +|| JERRY_ESNEXT */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_THE_MAPFN_ARGUMENT_IS_NOT_CALLABLE, "The 'mapfn' argument is not callable") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_THE_TWO_DESCRIPTORS_ARE_INCOMPATIBLE, "The two descriptors are incompatible") +#endif /* JERRY_BUILTIN_PROXY */ +ECMA_ERROR_DEF (ECMA_ERR_WRONG_ARGS_MSG, "This type of argument is not allowed") +#if JERRY_BUILTIN_CONTAINER +ECMA_ERROR_DEF (ECMA_ERR_CONTAINER_NEEDED, "Value is not a Container or Iterator") +#endif /* JERRY_BUILTIN_CONTAINER */ +#if JERRY_BUILTIN_REGEXP +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_REG_EXP, "Argument 'this' is not a valid RegExp") +#endif /* JERRY_BUILTIN_REGEXP */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_ARRAY_BUFFER_DETACHED, "ArrayBuffer has already been detached") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +ECMA_ERROR_DEF (ECMA_ERR_BULTIN_ROUTINES_HAVE_NO_CONSTRUCTOR, "Built-in routines have no constructor") +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_INT16_ARRAY_REQUIRES_NEW, "Constructor Int16Array requires 'new'") +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_INT32_ARRAY_REQUIRES_NEW, "Constructor Int32Array requires 'new'") +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_UINT8_ARRAY_REQUIRES_NEW, "Constructor Uint8Array requires 'new'") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_SNAPSHOT_EXEC +ECMA_ERROR_DEF (ECMA_ERR_FUNCTION_INDEX_IS_HIGHER_THAN_MAXIMUM, "Function index is higher than maximum") +#endif /* JERRY_SNAPSHOT_EXEC */ +#if JERRY_BUILTIN_REGEXP +ECMA_ERROR_DEF (ECMA_ERR_RANGE_OUT_OF_ORDER_IN_CHARACTER_CLASS, "Range out of order in character class") +#endif /* JERRY_BUILTIN_REGEXP */ +ECMA_ERROR_DEF (ECMA_ERR_RESULT_OF_DEFAULTVALUE_IS_INVALID, "Result of [[DefaultValue]] is invalid") +ECMA_ERROR_DEF (ECMA_ERR_RIGHT_VALUE_OF_IN_MUST_BE_AN_OBJECT, "Right value of 'in' must be an object") +#if !(JERRY_BUILTIN_SHAREDARRAYBUFFER) +ECMA_ERROR_DEF (ECMA_ERR_SHARED_ARRAYBUFFER_NOT_SUPPORTED, "SharedArrayBuffer support is disabled") +#endif /* !(JERRY_BUILTIN_SHAREDARRAYBUFFER) */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_TRAP_RETURNED_NEITHER_OBJECT_NOR_NULL, "Trap returned neither object nor null") +ECMA_ERROR_DEF (ECMA_ERR_TRAP_WITH_DUPLICATED_ENTRIES, "Trap returned with duplicated entries") +#endif /* JERRY_BUILTIN_PROXY */ +#if JERRY_BUILTIN_BIGINT +ECMA_ERROR_DEF (ECMA_ERR_UNARY_PLUS_IS_NOT_ALLOWED_FOR_BIGINTS, "Unary plus is not allowed for BigInts") +#endif /* JERRY_BUILTIN_BIGINT */ +#if !JERRY_ESNEXT && JERRY_BUILTIN_ANNEXB && JERRY_BUILTIN_REGEXP || JERRY_BUILTIN_REGEXP && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_IS_NOT_AN_REGEXP, "Argument 'this' is not a RegExp object") +#endif /* !JERRY_ESNEXT && JERRY_BUILTIN_ANNEXB && JERRY_BUILTIN_REGEXP \ +|| JERRY_BUILTIN_REGEXP && JERRY_ESNEXT */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_ALLOCATE_ARRAY_BUFFER, "Cannot allocate memory for ArrayBuffer") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_CONSTANT_BINDINGS_CANNOT_BE_REASSIGNED, "Constant bindings cannot be reassigned") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_ARRAYBUFFER_REQUIRES_NEW, "Constructor ArrayBuffer requires 'new'") +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_UINT16_ARRAY_REQUIRES_NEW, "Constructor Uint16Array requires 'new'") +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_UINT32_ARRAY_REQUIRES_NEW, "Constructor Uint32Array requires 'new'") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_GENERATOR_IS_CURRENTLY_UNDER_EXECUTION, "Generator is currently under execution") +ECMA_ERROR_DEF (ECMA_ERR_ITERATOR_RETURN_RESULT_IS_NOT_OBJECT, "Iterator 'return' result is not object") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_RETURNED_ARRAYBUFFER_HAS_BEEN_DETACHED, "Returned ArrayBuffer has been detached") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_SEARCH_STRING_CANNOT_BE_OF_TYPE_REGEXP, "Search string can't be of type: RegExp") +ECMA_ERROR_DEF (ECMA_ERR_VALUE_RECEIVED_BY_YIELD_IS_NOT_OBJECT, "Value received by yield* is not object") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_BOOLEAN +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_BOOLEAN_OBJECT, "Argument 'this' is not a Boolean object") +#endif /* JERRY_BUILTIN_BOOLEAN */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_FLOAT32_ARRAY_REQUIRES_NEW, "Constructor Float32Array requires 'new'") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_BUILTIN_TYPEDARRAY && JERRY_NUMBER_TYPE_FLOAT64 +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_FLOAT64_ARRAY_REQUIRES_NEW, "Constructor Float64Array requires 'new'") +#endif /* JERRY_BUILTIN_TYPEDARRAY && JERRY_NUMBER_TYPE_FLOAT64 */ +ECMA_ERROR_DEF (ECMA_ERR_FUNCTION_PROTOTYPE_NOT_A_CONSTRUCTOR, "Function.prototype is not a constructor") +#if JERRY_MODULE_SYSTEM +ECMA_ERROR_DEF (ECMA_ERR_IMPORTED_BINDING_SHADOWS_LOCAL_VARIABLE, "Imported binding shadows local variable") +#endif /* JERRY_MODULE_SYSTEM */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_PROTOTYPE_FROM_REVOKED_PROXY_IS_INVALID, "Prototype from revoked Proxy is invalid") +#endif /* JERRY_BUILTIN_PROXY */ +#if JERRY_BUILTIN_REGEXP && JERRY_BUILTIN_STRING && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_REGEXP_ARGUMENT_SHOULD_HAVE_GLOBAL_FLAG, "RegExp argument should have global flag") +#endif /* JERRY_BUILTIN_REGEXP && JERRY_BUILTIN_STRING && JERRY_ESNEXT */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_TRAP_IS_NEITHER_AN_OBJECT_NOR_UNDEFINED, "Trap is neither an object nor undefined") +#endif /* JERRY_BUILTIN_PROXY */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_PROMISE_RESOLVE_ITSELF, "A promise cannot be resolved with itself") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_BIGINT64_ARRAY_REQUIRES_NEW, "Constructor BigInt64Array requires 'new'") +#endif /* JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_MODULE_SYSTEM +ECMA_ERROR_DEF (ECMA_ERR_MODULE_EXPORTS_MUST_BE_VALID_IDENTIFIERS, "Module exports must be valid identifiers") +#endif /* JERRY_MODULE_SYSTEM */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_GENERATOR_OBJECT, "Argument 'this' is not a generator object") +#endif /* JERRY_ESNEXT */ +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_CANNOT_CONVERT_TO_OBJECT, "Argument cannot be converted to an object") +#if JERRY_BUILTIN_BIGINT +ECMA_ERROR_DEF (ECMA_ERR_ALLOCATE_BIGINT_VALUE, "Cannot allocate memory for a BigInt value") +ECMA_ERROR_DEF (ECMA_ERR_CONVERT_BIGINT_TO_NUMBER, "Cannot convert a BigInt value to a number") +#endif /* JERRY_BUILTIN_BIGINT */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_CONVERT_SYMBOL_TO_NUMBER, "Cannot convert a Symbol value to a number") +ECMA_ERROR_DEF (ECMA_ERR_CONVERT_SYMBOL_TO_STRING, "Cannot convert a Symbol value to a string") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_BIG_UINT64_ARRAY_REQUIRES_NEW, "Constructor BigUInt64Array requires 'new'") +#endif /* JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_BUILTIN_NUMBER +ECMA_ERROR_DEF (ECMA_ERR_FRACTION_DIGITS_OUT_OF_RANGE, "Fraction digits must be between 0 and 100") +#endif /* JERRY_BUILTIN_NUMBER */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_RETURN_VALUE_IS_NOT_AN_ARRAYBUFFER_OBJECT, "Return value is not an ArrayBuffer object") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_SUPER_CONSTRUCTOR_MAY_ONLY_BE_CALLED_ONCE, "Super constructor may only be called once") +#endif /* JERRY_ESNEXT */ +ECMA_ERROR_DEF (ECMA_ERR_BINDING_NOT_EXIST_OR_UNINITIALIZED, "Binding does not exist or is uninitialised") +#if JERRY_BUILTIN_ARRAY && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_CANNOT_CONVERT_TO_OBJECT, "Cannot convert undefined or null to object") +#endif /* JERRY_BUILTIN_ARRAY && JERRY_ESNEXT */ +#if JERRY_BUILTIN_NUMBER +ECMA_ERROR_DEF (ECMA_ERR_PRECISION_DIGITS_MUST_BE_BETWEEN_IN_RANGE, "Precision digits must be between 1 and 100") +#endif /* JERRY_BUILTIN_NUMBER */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_PROPERTY_NAME_IS_NEITHER_SYMBOL_NOR_STRING, "Property name is neither Symbol nor string") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_BIGINT +ECMA_ERROR_DEF (ECMA_ERR_STRING_CANNOT_BE_CONVERTED_TO_BIGINT_VALUE, "String cannot be converted to BigInt value") +#endif /* JERRY_BUILTIN_BIGINT */ +#if JERRY_BUILTIN_CONTAINER +ECMA_ERROR_DEF (ECMA_ERR_INCORRECT_TYPE_CALL, "Operator called on incorrect container type") +#endif /* JERRY_BUILTIN_CONTAINER */ +#if JERRY_BUILTIN_ARRAY +ECMA_ERROR_DEF (ECMA_ERR_REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE, "Reduce of empty Array with no initial value") +#endif /* JERRY_BUILTIN_ARRAY */ +#if JERRY_BUILTIN_REGEXP && !(!JERRY_ESNEXT) +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_REG_EXP_OBJECT, "Argument 'this' is not a valid RegExp object") +#endif /* JERRY_BUILTIN_REGEXP && !(!JERRY_ESNEXT) */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_ARRAY_BUFFER_OBJECT, "Argument 'this' is not an ArrayBuffer object") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_ERROR_MESSAGES && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_ARROW_FUNCTIONS_INVOKE_WITH_NEW, "Arrow functions cannot be invoked with 'new'") +ECMA_ERROR_DEF (ECMA_ERR_ASYNC_FUNCTIONS_INVOKE_WITH_NEW, "Async functions cannot be invoked with 'new'") +#endif /* JERRY_ERROR_MESSAGES && JERRY_ESNEXT */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_SET_EXTENSIBLE_PROPERTY, "Cannot set [[Extensible]] property of object") +#endif /* JERRY_BUILTIN_PROXY */ +#if JERRY_BUILTIN_SHAREDARRAYBUFFER +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_SHAREDARRAYBUFFER_REQUIRES_NEW, "Constructor SharedArrayBuffer requires 'new'") +#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_UINT8_CLAMPED_ARRAY_REQUIRES_NEW, "Constructor Uint8ClampedArray requires 'new'") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_BUILTIN_BIGINT && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_NEGATIVE_EXPONENT_IS_NOT_ALLOWED_FOR_BIGINTS, "Negative exponent is not allowed for BigInts") +#endif /* JERRY_BUILTIN_BIGINT && JERRY_ESNEXT */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_PROMISE_ALL_REMAINING_ELEMENTS_LIMIT_REACHED, "Promise.all remaining elements limit reached") +ECMA_ERROR_DEF (ECMA_ERR_VALUE_RECEIVED_BY_FOR_ASYNC_OF_IS_NOT_OBJECT, "Value received by for-async-of is not object") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_BIGINT +ECMA_ERROR_DEF (ECMA_ERR_INFINITY_OR_NAN_CANNOT_BE_CONVERTED_TO_BIGINT, "Infinity or NaN cannot be converted to BigInt") +#endif /* JERRY_BUILTIN_BIGINT */ +#if JERRY_BUILTIN_REGEXP && !(JERRY_ESNEXT) +ECMA_ERROR_DEF (ECMA_ERR_INVALID_ARGUMENT_IS_PASSED_TO_REGEXP_FUNCTION, "Invalid argument is passed to RegExp function") +#endif /* JERRY_BUILTIN_REGEXP && !(JERRY_ESNEXT) */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_OPERATOR_DELETE_RETURNED_FALSE_IN_STRICT_MODE, "Operator delete returned false in strict mode") +ECMA_ERROR_DEF (ECMA_ERR_PROPERTY_PROTOTYPE_IS_NOT_AN_OBJECT, "Property 'prototype' is not an object or null") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_PROXY_HANDLER_IS_NULL_FOR_ISARRAY_OPERATION, "Proxy handler is null for 'isArray' operation") +#endif /* JERRY_BUILTIN_PROXY */ +#if JERRY_SNAPSHOT_SAVE +ECMA_ERROR_DEF (ECMA_ERR_REGULAR_EXPRESSION_NOT_SUPPORTED, "Regular expression literals are not supported") +#endif /* JERRY_SNAPSHOT_SAVE */ +ECMA_ERROR_DEF (ECMA_ERR_RIGHT_VALUE_OF_INSTANCEOF_MUST_BE_AN_OBJECT, "Right value of 'instanceof' must be an object") +#if JERRY_SNAPSHOT_EXEC +ECMA_ERROR_DEF (ECMA_ERR_STATIC_SNAPSHOTS_CANNOT_BE_COPIED_INTO_MEMORY, "Static snapshots cannot be copied into memory") +#endif /* JERRY_SNAPSHOT_EXEC */ +#if JERRY_ESNEXT && JERRY_SNAPSHOT_SAVE +ECMA_ERROR_DEF (ECMA_ERR_TAGGED_TEMPLATE_LITERALS, "Unsupported feature: tagged template literals") +#endif /* JERRY_ESNEXT && JERRY_SNAPSHOT_SAVE */ +#if JERRY_SNAPSHOT_SAVE +ECMA_ERROR_DEF (ECMA_ERR_SNAPSHOT_FLAG_NOT_SUPPORTED, "Unsupported generate snapshot flags specified") +#endif /* JERRY_SNAPSHOT_SAVE */ +#if JERRY_SNAPSHOT_EXEC +ECMA_ERROR_DEF (ECMA_ERR_UNSUPPORTED_SNAPSHOT_EXEC_FLAGS_ARE_SPECIFIED, "Unsupported snapshot exec flags are specified") +#endif /* JERRY_SNAPSHOT_EXEC */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_VALUE_FOR_CLASS_HERITAGE_IS_NOT_A_CONSTRUCTOR, "Value for class heritage is not a constructor") +#endif /* JERRY_ESNEXT */ +ECMA_ERROR_DEF (ECMA_ERR_TOO_MANY_ARGUMENTS_DECLARED_FOR_FUNCTION_APPLY, + "Too many arguments declared for Function.apply") +#if JERRY_ERROR_MESSAGES && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_ACCESSOR_FUNCTIONS_INVOKE_WITH_NEW, "Accessor functions cannot be invoked with 'new'") +#endif /* JERRY_ERROR_MESSAGES && JERRY_ESNEXT */ +#if JERRY_MODULE_SYSTEM +ECMA_ERROR_DEF (ECMA_ERR_LINK_TO_MODULE_IN_ERROR_STATE, "Cannot link to a module which is in error state") +#endif /* JERRY_MODULE_SYSTEM */ +#if JERRY_BUILTIN_BIGINT +ECMA_ERROR_DEF (ECMA_ERR_ONLY_INTEGER_NUMBERS_CAN_BE_CONVERTED_TO_BIGINT, + "Only integer numbers can be converted to BigInt") +#endif /* JERRY_BUILTIN_BIGINT */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_TYPEDARRAY_INTRINSTIC_DIRECTLY_CALLED, "TypedArray intrinstic cannot be directly called") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_BUILTIN_BIGINT +ECMA_ERROR_DEF (ECMA_ERR_UNSIGNED_RIGHT_SHIFT_IS_NOT_ALLOWED_FOR_BIGINTS, + "Unsigned right shift is not allowed for BigInts") +#endif /* JERRY_BUILTIN_BIGINT */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_ASYNC_GENERATOR, "Argument 'this' is not an async generator object") +ECMA_ERROR_DEF (ECMA_ERR_CLASS_EXTENDS_NOT_CONSTRUCTOR, "Class extends value is not a constructor or null") +#endif /* JERRY_ESNEXT */ +#if JERRY_ERROR_MESSAGES && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_GENERATOR_FUNCTIONS_INVOKE_WITH_NEW, "Generator functions cannot be invoked with 'new'") +#endif /* JERRY_ERROR_MESSAGES && JERRY_ESNEXT */ +#if JERRY_BUILTIN_REGEXP && JERRY_ESNEXT || JERRY_BUILTIN_REGEXP && !(!JERRY_ESNEXT) +ECMA_ERROR_DEF (ECMA_ERR_RETURN_VALUE_OF_EXEC_MUST_BE_AN_OBJECT_OR_NULL, + "Return value of 'exec' must be an object or null") +#endif /* JERRY_BUILTIN_REGEXP && JERRY_ESNEXT \ +|| JERRY_BUILTIN_REGEXP && !(!JERRY_ESNEXT) */ +#if JERRY_BUILTIN_DATAVIEW +ECMA_ERROR_DEF (ECMA_ERR_START_OFFSET_IS_OUTSIDE_THE_BOUNDS_OF_THE_BUFFER, + "Start offset is outside the bounds of the buffer") +#endif /* JERRY_BUILTIN_DATAVIEW */ +#if JERRY_BUILTIN_SHAREDARRAYBUFFER +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_SHARED_ARRAY_BUFFER, "Argument 'this' is not a SharedArrayBuffer object") +#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_CLASS_CONSTRUCTOR_NEW, "Class constructor cannot be invoked without 'new'") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_INCORRECT_RETURN_PROXY_GET_TRAP, "Incorrect value is returned by a Proxy 'get' trap") +ECMA_ERROR_DEF (ECMA_ERR_INCORRECT_RETURN_PROXY_SET_TRAP, "Incorrect value is returned by a Proxy 'set' trap") +#endif /* JERRY_BUILTIN_PROXY */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_CLASS_IS_NON_CONFIGURABLE, "Prototype property of a class is non-configurable") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_ARRAY && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_PUSHING_TOO_HIGH_ELEMENT, "Pushing element over 2**53-1 length is disallowed") +#endif /* JERRY_BUILTIN_ARRAY && JERRY_ESNEXT */ +ECMA_ERROR_DEF (ECMA_ERR_THE_REQUESTED_PROPERTY_UPDATE_CANNOT_BE_PERFORMED, + "The requested property update cannot be performed") +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_TRAP_RESULT_NOT_INCLUDE_ALL_CONFIGURABLE_KEYS, + "Trap result did not include all configurable keys") +ECMA_ERROR_DEF (ECMA_ERR_TRAP_TRUISH_TARGET_NOT_EXTENSIBLE, "Trap returned truish for target is not extensible") +#endif /* JERRY_BUILTIN_PROXY */ +#if JERRY_BUILTIN_NUMBER +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_NUMBER, "Argument 'this' is not a number or a Number object") +#endif /* JERRY_BUILTIN_NUMBER */ +#if JERRY_BUILTIN_STRING +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_STRING_OBJECT, "Argument 'this' is not a string or a String object") +#endif /* JERRY_BUILTIN_STRING */ +#if JERRY_BUILTIN_SHAREDARRAYBUFFER +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_SHARED_ARRAY_BUFFER_OBJECT, + "Argument 'this' is not an SharedArrayBuffer object") +#endif /* JERRY_BUILTIN_SHAREDARRAYBUFFER */ +#if JERRY_ERROR_MESSAGES && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_ASYNC_ARROW_FUNCTIONS_INVOKE_WITH_NEW, "Async arrow functions cannot be invoked with 'new'") +#endif /* JERRY_ERROR_MESSAGES && JERRY_ESNEXT */ +#if JERRY_BUILTIN_ARRAY && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_UNSHIFT_TOO_HIGH, "Unshift elements over 2**53-1 length is disallowed") +#endif /* JERRY_BUILTIN_ARRAY && JERRY_ESNEXT */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_TRAP_RESULT_NOT_INCLUDE_ALL_NON_CONFIGURABLE_KEYS, + "Trap result did not include all non-configurable keys") +#endif /* JERRY_BUILTIN_PROXY */ +#if JERRY_ERROR_MESSAGES && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_ASYNC_GENERATOR_FUNCTIONS_INVOKE_WITH_NEW, + "Async generator functions cannot be invoked with 'new'") +#endif /* JERRY_ERROR_MESSAGES && JERRY_ESNEXT */ +#if JERRY_BUILTIN_REFLECT +ECMA_ERROR_DEF (ECMA_ERR_REFLECT_EXPECTS_AN_OBJECT_AS_SECOND_ARGUMENT, + "Reflect.construct expects an object as second argument") +#endif /* JERRY_BUILTIN_REFLECT */ +#if JERRY_ERROR_MESSAGES && JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_SCRIPT_GLOBAL_FUNCTIONS_INVOKE_WITH_NEW, + "Script (global) functions cannot be invoked with 'new'") +#endif /* JERRY_ERROR_MESSAGES && JERRY_ESNEXT */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_CANNOT_CREATE_PROXY, "Cannot create Proxy with a non-object target or handler") +#endif /* JERRY_BUILTIN_PROXY */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_DERIVED_CTOR_RETURN_NOR_OBJECT_OR_UNDEFINED, + "Derived constructors may only return object or undefined") +#endif /* JERRY_ESNEXT */ +#if JERRY_SNAPSHOT_EXEC +ECMA_ERROR_DEF (ECMA_ERR_INVALID_SNAPSHOT_VERSION_OR_FEATURES, + "Invalid snapshot version or unsupported features present") +#endif /* JERRY_SNAPSHOT_EXEC */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_TYPEDARRAY_SMALLER_THAN_FILTER_CALL_RESULT, + "Constructed TypedArray is smaller than filter call result") +ECMA_ERROR_DEF (ECMA_ERR_DERIVED_ARRAY_BUFFER_CTOR_BUFFER_TOO_SMALL, + "Derived ArrayBuffer constructor created a too small buffer") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_TRAP_RESULT_NOT_REFLECT_TARGET_EXTENSIBILITY, + "Trap result does not reflect extensibility of Proxy target") +ECMA_ERROR_DEF (ECMA_ERR_TRAP_EXTRA_KEYS_FOR_A_NON_EXTENSIBLE_TARGET, + "Trap returned extra keys for a non-extensible Proxy target") +#endif /* JERRY_BUILTIN_PROXY */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_ARRAY_BUFFER_RETURNED_THIS_FROM_CONSTRUCTOR, + "ArrayBuffer subclass returned this from species constructor") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_BUILTIN_DATAVIEW +ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_BUFFER_NOT_ARRAY_OR_SHARED_BUFFER, + "Argument 'buffer' is not an ArrayBuffer or SharedArrayBuffer") +#endif /* JERRY_BUILTIN_DATAVIEW */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_TRAP_RESULT_NOT_REFLECT_TARGET_INEXTENSIBILITY, + "Trap result does not reflect inextensibility of Proxy target") +#endif /* JERRY_BUILTIN_PROXY */ +#if JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_TYPEDARRAY_INTRINSTIC_CALLED_BY_NEW_EXPRESSION, + "TypedArray intrinstic cannot be called by a 'new' expression") +#endif /* JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY +ECMA_ERROR_DEF (ECMA_ERR_CONTENTTYPE_RETURNED_TYPEDARRAY_NOT_MATCH_SOURCE, + "TypedArray returned by [[ContentType]] does not match source") +#endif /* JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY */ +#if JERRY_BUILTIN_BIGINT +ECMA_ERROR_DEF (ECMA_ERR_ALLOCATE_BIGINT_STRING, "Cannot allocate memory for a string representation of a BigInt value") +#endif /* JERRY_BUILTIN_BIGINT */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_TARGET_NOT_EXTENSIBLE_DIFFERENT_PROTOTYPE_RETURNED, + "Target object is non-extensible and trap returned different prototype") +ECMA_ERROR_DEF (ECMA_ERR_TRAP_TRUISH_ADDING_PROPERTY_NON_EXTENSIBLE_TARGET, + "Trap returned truish for adding property to the non-extensible target") +ECMA_ERROR_DEF (ECMA_ERR_GIVEN_PROPERTY_IS_A_NON_CONFIGURABLE, + "Given property is a non-configurable data property on the proxy target") +ECMA_ERROR_DEF (ECMA_ERR_TRAP_FALSISH_PROPERTY_TARGET_NOT_EXTENSIBLE, + "Trap returned falsish for property but the proxy target is not extensible") +ECMA_ERROR_DEF (ECMA_ERR_PROXY_PROPERTY_NOT_CONFIGURABLE_NOT_HAVE_GETTER, + "Property of a Proxy is non-configurable and does not have a getter function") +ECMA_ERROR_DEF (ECMA_ERR_TARGET_PROPERTY_CONFIGURE_ACCESSOR_WITHOUT_SETTER, + "The property of a Proxy target is a non configurable accessor without a setter") +#endif /* JERRY_BUILTIN_PROXY */ +#if JERRY_ESNEXT || JERRY_MODULE_SYSTEM +ECMA_ERROR_DEF (ECMA_ERR_LET_CONST_NOT_INITIALIZED, + "Variables declared by let/const must be initialized before reading their value") +#endif /* JERRY_ESNEXT \ +|| JERRY_MODULE_SYSTEM */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_TRAP_TRUISH_PROPERTY_NON_CONFIGURABLE, + "Trap returned truish for property which is non-configurable in the proxy target") +ECMA_ERROR_DEF (ECMA_ERR_TARGET_NOT_EXTENSIBLE_NOT_RETURNED_ITS_PROTOTYPE, + "Proxy target is non-extensible, but the trap did not return its actual prototype") +ECMA_ERROR_DEF (ECMA_ERR_TRAP_FALSISH_PROPERTY_NON_CONFIGURABLE, + "Trap returned falsish for property which exists in the proxy target as non-configurable") +#endif /* JERRY_BUILTIN_PROXY */ +#if JERRY_ESNEXT +ECMA_ERROR_DEF (ECMA_ERR_CALL_SUPER_CONSTRUCTOR_DERIVED_CLASS_BEFORE_THIS, + "Must call super constructor in derived class before accessing 'this' or returning from it") +#endif /* JERRY_ESNEXT */ +#if JERRY_BUILTIN_PROXY +ECMA_ERROR_DEF (ECMA_ERR_TRAP_TRUISH_DEFINING_NON_EXISTENT_PROPERTY, + "Trap returned truish for defining non-configurable property which is non-existent in the target") +ECMA_ERROR_DEF ( + ECMA_ERR_TRAP_TRUISH_ADD_PROPERTY_INCOMPATIBLE_OTHER_PROP, + "Trap returned truish for adding property that is incompatible with the existing property in the target") +#endif /* JERRY_BUILTIN_PROXY */ +ECMA_ERROR_DEF (ECMA_ERR_CANNOT_ACCESS_CALLER_CALLE_ARGUMENTS, + "'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the " + "arguments objects for calls to them") diff --git a/jerry-core/ecma/base/ecma-error-messages.ini b/jerry-core/ecma/base/ecma-error-messages.ini new file mode 100644 index 0000000000..c4bb36b270 --- /dev/null +++ b/jerry-core/ecma/base/ecma-error-messages.ini @@ -0,0 +1,326 @@ +# Copyright JS Foundation and other contributors, http://js.foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +[ECMA_ERROR_MESSAGES] + +ECMA_ERR_CANNOT_ACCESS_CALLER_CALLE_ARGUMENTS = "'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them" +ECMA_ERR_PARAMETER_REJECT_MUST_BE_CALLABLE = "'reject' parameter must be callable" +ECMA_ERR_PARAMETER_RESOLVE_MUST_BE_CALLABLE = "'resolve' parameter must be callable" +ECMA_ERR_PROMISE_RESOLVE_ITSELF = "A promise cannot be resolved with itself" +ECMA_ERR_ACCESSOR_WRITABLE = "Accessors cannot be writable" +ECMA_ERR_ARGUMENT_BUFFER_NOT_ARRAY_OR_SHARED_BUFFER = "Argument 'buffer' is not an ArrayBuffer or SharedArrayBuffer" +ECMA_ERR_ARGUMENT_BUFFER_NOT_OBJECT = "Argument 'buffer' is not an object" +ECMA_ERR_ARGUMENT_THIS_NOT_ARRAY_BUFFER_OBJECT = "Argument 'this' is not an ArrayBuffer object" +ECMA_ERR_ARGUMENT_THIS_NOT_BOOLEAN_OBJECT = "Argument 'this' is not a Boolean object" +ECMA_ERR_ARGUMENT_THIS_NOT_DATE_OBJECT = "Argument 'this' is not a Date object" +ECMA_ERR_ARGUMENT_THIS_NOT_PROMISE = "Argument 'this' is not a Promise" +ECMA_ERR_ARGUMENT_THIS_NOT_SHARED_ARRAY_BUFFER = "Argument 'this' is not a SharedArrayBuffer object" +ECMA_ERR_ARGUMENT_THIS_NOT_TYPED_ARRAY = "Argument 'this' is not a TypedArray" +ECMA_ERR_ARGUMENT_THIS_NOT_CONSTRUCTOR = "Argument 'this' is not a constructor" +ECMA_ERR_ARGUMENT_THIS_NOT_FUNCTION = "Argument 'this' is not a function" +ECMA_ERR_ARGUMENT_THIS_NOT_GENERATOR_OBJECT = "Argument 'this' is not a generator object" +ECMA_ERR_ARGUMENT_THIS_NOT_NUMBER = "Argument 'this' is not a number or a Number object" +ECMA_ERR_ARGUMENT_THIS_NOT_STRING_OBJECT = "Argument 'this' is not a string or a String object" +ECMA_ERR_ARGUMENT_THIS_NOT_REG_EXP = "Argument 'this' is not a valid RegExp" +ECMA_ERR_ARGUMENT_THIS_NOT_REG_EXP_OBJECT = "Argument 'this' is not a valid RegExp object" +ECMA_ERR_ARGUMENT_THIS_NOT_SHARED_ARRAY_BUFFER_OBJECT = "Argument 'this' is not an SharedArrayBuffer object" +ECMA_ERR_ARGUMENT_THIS_NOT_ASYNC_GENERATOR = "Argument 'this' is not an async generator object" +ECMA_ERR_ARGUMENT_THIS_NOT_ITERATOR = "Argument 'this' is not an iterator" +ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT = "Argument 'this' is not an object" +ECMA_ERR_ARGUMENT_THIS_NOT_SYMBOL = "Argument 'this' must be a Symbol" +ECMA_ERR_ARGUMENT_CANNOT_CONVERT_TO_OBJECT = "Argument cannot be converted to an object" +ECMA_ERR_ARGUMENT_NOT_SHARED_ARRAY_BUFFER = "Argument is not SharedArrayBuffer" +ECMA_ERR_ARGUMENT_NOT_ARRAY_BUFFER = "Argument is not an ArrayBuffer" +ECMA_ERR_ARGUMENT_NOT_SUPPORTED = "Argument is not supported" +ECMA_ERR_ARRAY_BUFFER_DETACHED = "ArrayBuffer has already been detached" +ECMA_ERR_ARRAY_BUFFER_RETURNED_THIS_FROM_CONSTRUCTOR = "ArrayBuffer subclass returned this from species constructor" +ECMA_ERR_BIGINT_SERIALIZED = "BigInt cannot be serialized" +ECMA_ERR_BIGINT_ZERO_DIVISION = "BigInt division by zero" +ECMA_ERR_BIGINT_FUNCTION_NOT_CONSTRUCTOR = "BigInt function is not a constructor" +ECMA_ERR_BIGINT_VALUE_EXCPECTED = "BigInt value expected" +ECMA_ERR_BINDING_CANNOT_SET = "Binding cannot be set" +ECMA_ERR_BINDING_NOT_EXIST_OR_UNINITIALIZED = "Binding does not exist or is uninitialised" +ECMA_ERR_BULTIN_ROUTINES_HAVE_NO_CONSTRUCTOR = "Built-in routines have no constructor" +ECMA_ERR_CALLBACK_RESULT_NOT_MODULE = "Callback result must be a module" +ECMA_ERR_ALLOCATE_ARRAY_BUFFER = "Cannot allocate memory for ArrayBuffer" +ECMA_ERR_ALLOCATE_BIGINT_VALUE = "Cannot allocate memory for a BigInt value" +ECMA_ERR_ALLOCATE_BIGINT_STRING = "Cannot allocate memory for a string representation of a BigInt value" +ECMA_ERR_CONVERT_BIGINT_TO_NUMBER = "Cannot convert a BigInt value to a number" +ECMA_ERR_CONVERT_SYMBOL_TO_NUMBER = "Cannot convert a Symbol value to a number" +ECMA_ERR_CONVERT_SYMBOL_TO_STRING = "Cannot convert a Symbol value to a string" +ECMA_ERR_CANNOT_CREATE_PROXY = "Cannot create Proxy with a non-object target or handler" +ECMA_ERR_INVOKE_NULLABLE_SUPER_METHOD = "Cannot invoke nullable super method" +ECMA_ERR_LINK_TO_MODULE_IN_ERROR_STATE = "Cannot link to a module which is in error state" +ECMA_ERR_SET_EXTENSIBLE_PROPERTY = "Cannot set [[Extensible]] property of object" +ECMA_ERR_SET_PROTOTYPE = "Cannot set [[Prototype]]" +ECMA_ERR_CLASS_CONSTRUCTOR_REQUIRES_NEW = "Class constructor requires 'new'" +ECMA_ERR_CLASS_EXTENDS_NOT_CONSTRUCTOR = "Class extends value is not a constructor or null" +ECMA_ERR_COMPARE_FUNC_NOT_CALLABLE = "Compare function is not callable" +ECMA_ERR_CONSTANT_BINDINGS_CANNOT_BE_REASSIGNED = "Constant bindings cannot be reassigned" +ECMA_ERR_TYPEDARRAY_SMALLER_THAN_FILTER_CALL_RESULT = "Constructed TypedArray is smaller than filter call result" +ECMA_ERR_CONSTRUCTED_OBJECT_IS_NOT_TYPEDARRAY = "Constructed object is not TypedArray" +ECMA_ERR_CONSTRUCTOR_ARRAYBUFFER_REQUIRES_NEW = "Constructor ArrayBuffer requires 'new'" +ECMA_ERR_CONSTRUCTOR_BIGINT64_ARRAY_REQUIRES_NEW = "Constructor BigInt64Array requires 'new'" +ECMA_ERR_CONSTRUCTOR_BIG_UINT64_ARRAY_REQUIRES_NEW = "Constructor BigUInt64Array requires 'new'" +ECMA_ERR_CONSTRUCTOR_DATAVIEW_REQUIRES_NEW = "Constructor DataView requires 'new'" +ECMA_ERR_CONSTRUCTOR_FLOAT32_ARRAY_REQUIRES_NEW = "Constructor Float32Array requires 'new'" +ECMA_ERR_CONSTRUCTOR_FLOAT64_ARRAY_REQUIRES_NEW = "Constructor Float64Array requires 'new'" +ECMA_ERR_CONSTRUCTOR_INT16_ARRAY_REQUIRES_NEW = "Constructor Int16Array requires 'new'" +ECMA_ERR_CONSTRUCTOR_INT32_ARRAY_REQUIRES_NEW = "Constructor Int32Array requires 'new'" +ECMA_ERR_CONSTRUCTOR_INT8_ARRAY_REQUIRES_NEW = "Constructor Int8Array requires 'new'" +ECMA_ERR_CONSTRUCTOR_MAP_REQUIRES_NEW = "Constructor Map requires 'new'" +ECMA_ERR_CONSTRUCTOR_PROMISE_REQUIRES_NEW = "Constructor Promise requires 'new'" +ECMA_ERR_CONSTRUCTOR_PROXY_REQUIRES_NEW = "Constructor Proxy requires 'new'" +ECMA_ERR_CONSTRUCTOR_SET_REQUIRES_NEW = "Constructor Set requires 'new'" +ECMA_ERR_CONSTRUCTOR_SHAREDARRAYBUFFER_REQUIRES_NEW = "Constructor SharedArrayBuffer requires 'new'" +ECMA_ERR_CONSTRUCTOR_UINT16_ARRAY_REQUIRES_NEW = "Constructor Uint16Array requires 'new'" +ECMA_ERR_CONSTRUCTOR_UINT32_ARRAY_REQUIRES_NEW = "Constructor Uint32Array requires 'new'" +ECMA_ERR_CONSTRUCTOR_UINT8_ARRAY_REQUIRES_NEW = "Constructor Uint8Array requires 'new'" +ECMA_ERR_CONSTRUCTOR_UINT8_CLAMPED_ARRAY_REQUIRES_NEW = "Constructor Uint8ClampedArray requires 'new'" +ECMA_ERR_CONSTRUCTOR_WEAKMAP_REQUIRES_NEW = "Constructor WeakMap requires 'new'" +ECMA_ERR_CONSTRUCTOR_WEAKREF_REQUIRES_NEW = "Constructor WeakRef requires 'new'." +ECMA_ERR_CONSTRUCTOR_WEAKSET_REQUIRES_NEW = "Constructor WeakSet requires 'new'" +ECMA_ERR_CONSTRUCTOR_NOT_AN_OBJECT = "Constructor must be an object" +ECMA_ERR_CONTAINER_IS_NOT_A_CONTAINER_OBJECT = "Container is not a container object." +ECMA_ERR_CONTAINER_IS_NOT_AN_OBJECT = "Container is not an object." +ECMA_ERR_DATE_MUST_BE_A_FINITE_NUMBER = "Date must be a finite number" +ECMA_ERR_DERIVED_ARRAY_BUFFER_CTOR_BUFFER_TOO_SMALL = "Derived ArrayBuffer constructor created a too small buffer" +ECMA_ERR_DERIVED_CTOR_RETURN_NOR_OBJECT_OR_UNDEFINED = "Derived constructors may only return object or undefined" +ECMA_ERR_INVALID_CODE_POINT_ERROR = "Error: Invalid code point" +ECMA_ERR_EXPECTED_A_DATAVIEW_OBJECT = "Expected a DataView object" +ECMA_ERR_EXPECTED_A_CONFIGURABLE_PROPERTY = "Expected a configurable property" +ECMA_ERR_EXPECTED_A_FUNCTION_OBJECT = "Expected a function object" +ECMA_ERR_EXPECTED_AN_ARRAYBUFFER = "Expected an ArrayBuffer" +ECMA_ERR_EXPECTED_AN_OBJECT = "Expected an object" +ECMA_ERR_FIRST_ARGUMENT_IS_NOT_A_REALM = "First argument is not a realm" +ECMA_ERR_FIRST_PARAMETER_MUST_BE_CALLABLE = "First parameter must be callable" +ECMA_ERR_FRACTION_DIGITS_OUT_OF_RANGE = "Fraction digits must be between 0 and 100" +ECMA_ERR_FUNCTION_ADD_ORSET_IS_NOT_CALLABLE = "Function add/set is not callable" +ECMA_ERR_FUNCTION_INDEX_IS_HIGHER_THAN_MAXIMUM = "Function index is higher than maximum" +ECMA_ERR_FUNCTION_PROTOTYPE_NOT_A_CONSTRUCTOR = "Function.prototype is not a constructor" +ECMA_ERR_GENERATOR_IS_CURRENTLY_UNDER_EXECUTION = "Generator is currently under execution" +ECMA_ERR_GETTER_IS_NOT_CALLABLE = "Getter is not callable" +ECMA_ERR_GIVEN_PROPERTY_IS_A_NON_CONFIGURABLE = "Given property is a non-configurable data property on the proxy target" +ECMA_ERR_HANDLER_CANNOT_BE_NULL = "Handler cannot be null" +ECMA_ERR_IMPORTED_BINDING_SHADOWS_LOCAL_VARIABLE = "Imported binding shadows local variable" +ECMA_ERR_INCOMPATIBLE_TYPEDARRAY_TYPES = "Incompatible TypedArray types" +ECMA_ERR_INCORRECT_TYPE_FOR_TYPEDARRAY = "Incorrect type for TypedArray" +ECMA_ERR_INCORRECT_RETURN_PROXY_GET_TRAP = "Incorrect value is returned by a Proxy 'get' trap" +ECMA_ERR_INCORRECT_RETURN_PROXY_SET_TRAP = "Incorrect value is returned by a Proxy 'set' trap" +ECMA_ERR_INFINITY_OR_NAN_CANNOT_BE_CONVERTED_TO_BIGINT = "Infinity or NaN cannot be converted to BigInt" +ECMA_ERR_INITIAL_VALUE_CANNOT_BE_UNDEFINED = "Initial value cannot be undefined" +ECMA_ERR_INPUT_MUST_BE_A_VALID_UTF8_STRING = "Input must be a valid utf8 string" +ECMA_ERR_INVALID_ARRAYBUFFER_LENGTH = "Invalid ArrayBuffer length" +ECMA_ERR_INVALID_JSON_FORMAT = "Invalid JSON format" +ECMA_ERR_INVALID_REGEXP_FLAGS = "Invalid RegExp flags" +ECMA_ERR_INVALID_SHARED_ARRAYBUFFER_LENGTH = "Invalid Shared ArrayBuffer length" +ECMA_ERR_INVALID_TYPEDARRAY_LENGTH = "Invalid TypedArray length" +ECMA_ERR_INVALID_UTF8_CHARACTER = "Invalid UTF8 character" +ECMA_ERR_INVALID_UTF8_CODEPOINT = "Invalid UTF8 codepoint" +ECMA_ERR_INVALID_UTF8_STRING = "Invalid UTF8 string" +ECMA_ERR_INVALID_ARGUMENT = "Invalid argument" +ECMA_ERR_INVALID_ARGUMENT_IS_PASSED_TO_REGEXP_FUNCTION = "Invalid argument is passed to RegExp function" +ECMA_ERR_INVALID_ARGUMENT_TYPE_IN_TOPRIMITIVE = "Invalid argument type in toPrimitive" +ECMA_ERR_INVALID_CAPABILITY = "Invalid capability" +ECMA_ERR_INVALID_CHARACTER_CLASS = "Invalid character class" +ECMA_ERR_INVALID_CODE_POINT = "Invalid code point" +ECMA_ERR_INVALID_CONTAINER_TYPE = "Invalid container type" +ECMA_ERR_INVALID_CONTROL_ESCAPE_SEQUENCE = "Invalid control escape sequence" +ECMA_ERR_INVALID_COUNT_VALUE = "Invalid count value" +ECMA_ERR_INVALID_ESCAPE = "Invalid escape" +ECMA_ERR_INVALID_ESCAPE_SEQUENCE = "Invalid escape sequence" +ECMA_ERR_INVALID_GROUP = "Invalid group" +ECMA_ERR_INVALID_HEX_ESCAPE_SEQUENCE = "Invalid hex escape sequence" +ECMA_ERR_INVALID_HEXADECIMAL_VALUE = "Invalid hexadecimal value" +ECMA_ERR_INVALID_LENGTH = "Invalid length" +ECMA_ERR_INVALID_NEW_ARRAY_LENGTH = "Invalid new Array length" +ECMA_ERR_INVALID_OFFSET = "Invalid offset" +ECMA_ERR_INVALID_OR_OUT_OF_RANGE_INDEX = "Invalid or out-of-range index" +ECMA_ERR_INVALID_QUANTIFIER = "Invalid quantifier" +ECMA_ERR_INVALID_RANGE_OF_INDEX = "Invalid range of index" +ECMA_ERR_INVALID_SCOPE_CHAIN_INDEX_FOR_EVAL = "Invalid scope chain index for eval" +ECMA_ERR_INVALID_SPECIES_CONSTRUCTOR = "Invalid species constructor" +ECMA_ERR_INVALID_STRING_ = "Invalid string length" +ECMA_ERR_INVALID_UNICODE_ESCAPE_SEQUENCE = "Invalid unicode escape sequence" +ECMA_ERR_ITERATOR_NEXT_IS_NOT_CALLABLE = "Iterator 'next' is not callable" +ECMA_ERR_ITERATOR_RETURN_RESULT_IS_NOT_OBJECT = "Iterator 'return' result is not object" +ECMA_ERR_ITERATOR_THROW_IS_NOT_AVAILABLE = "Iterator 'throw' is not available" +ECMA_ERR_ITERATOR_IS_NOT_AN_OBJECT = "Iterator is not an object" +ECMA_ERR_ITERATOR_IS_NOT_CALLABLE = "Iterator is not callable" +ECMA_ERR_ITERATOR_RESULT_IS_NOT_AN_OBJECT = "Iterator result is not an object" +ECMA_ERR_ITERATOR_VALUE_IS_NOT_AN_OBJECT = "Iterator value is not an object" +ECMA_ERR_JSON_STRING_PARSE_ERROR = "JSON string parse error" +ECMA_ERR_JSON_STRINGIFY_ERROR = "JSON stringify error" +ECMA_ERR_KEY_MUST_BE_AN_OBJECT = "Key must be an object" +ECMA_ERR_LONE_QUANTIFIER_BRACKET = "Lone quantifier bracket" +ECMA_ERR_MAXIMUM_TYPEDARRAY_SIZE_IS_REACHED = "Maximum TypedArray size is reached" +ECMA_ERR_MAXIMUM_STRING_LENGTH_IS_REACHED = "Maximum string length is reached" +ECMA_ERR_MISSING_ARRAY_ELEMENT = "Missing Array element" +ECMA_ERR_MODULE_CANNOT_BE_INSTANTIATED = "Module cannot be instantiated" +ECMA_ERR_MODULE_EXPORTS_MUST_BE_STRING_VALUES = "Module exports must be string values" +ECMA_ERR_MODULE_EXPORTS_MUST_BE_VALID_IDENTIFIERS = "Module exports must be valid identifiers" +ECMA_ERR_MODULE_IS_IN_ERROR_STATE = "Module is in error state" +ECMA_ERR_MODULE_MUST_BE_IN_LINKED_STATE = "Module must be in linked state" +ECMA_ERR_MODULE_MUST_BE_IN_UNLINKED_STATE = "Module must be in unlinked state" +ECMA_ERR_CALL_SUPER_CONSTRUCTOR_DERIVED_CLASS_BEFORE_THIS = "Must call super constructor in derived class before accessing 'this' or returning from it" +ECMA_ERR_NAMESPACE_OBJECT_IS_NOT_AVAILABLE = "Namespace object is not available" +ECMA_ERR_NEGATIVE_EXPONENT_IS_NOT_ALLOWED_FOR_BIGINTS = "Negative exponent is not allowed for BigInts" +ECMA_ERR_NO_SOURCE_ARGUMENT = "No source argument" +ECMA_ERR_NOTHING_TO_REPEAT = "Nothing to repeat" +ECMA_ERR_OBJECT_CANNOT_BE_FROZEN = "Object cannot be frozen" +ECMA_ERR_OBJECT_CANNOT_BE_SEALED = "Object cannot be sealed" +ECMA_ERR_OBJECT_EXPECTED = "Object expected" +ECMA_ERR_OBJECT_IS_NOT_A_TYPEDARRAY = "Object is not a TypedArray" +ECMA_ERR_ONLY_INTEGER_NUMBERS_CAN_BE_CONVERTED_TO_BIGINT = "Only integer numbers can be converted to BigInt" +ECMA_ERR_OPERATOR_DELETE_RETURNED_FALSE_IN_STRICT_MODE = "Operator delete returned false in strict mode" +ECMA_ERR_PASSED_ARGUMENT_IS_NOT_A_REALM = "Passed argument is not a realm" +ECMA_ERR_PRECISION_DIGITS_MUST_BE_BETWEEN_IN_RANGE = "Precision digits must be between 1 and 100" +ECMA_ERR_PROMISE_ALL_REMAINING_ELEMENTS_LIMIT_REACHED = "Promise.all remaining elements limit reached" +ECMA_ERR_PROPERTY_PROTOTYPE_IS_NOT_AN_OBJECT = "Property 'prototype' is not an object or null" +ECMA_ERR_PROPERTY_NAME_IS_NEITHER_SYMBOL_NOR_STRING = "Property name is neither Symbol nor string" +ECMA_ERR_PROXY_PROPERTY_NOT_CONFIGURABLE_NOT_HAVE_GETTER = "Property of a Proxy is non-configurable and does not have a getter function" +ECMA_ERR_PROTOTYPE_FROM_REVOKED_PROXY_IS_INVALID = "Prototype from revoked Proxy is invalid" +ECMA_ERR_PROTOTYPE_IS_NEITHER_OBJECT_NOR_NULL = "Prototype is neither object nor null" +ECMA_ERR_PROXY_HANDLER_IS_NULL_FOR_ISARRAY_OPERATION = "Proxy handler is null for 'isArray' operation" +ECMA_ERR_PROXY_IS_NOT_SUPPORTED = "Proxy is not supported" +ECMA_ERR_TARGET_NOT_EXTENSIBLE_NOT_RETURNED_ITS_PROTOTYPE = "Proxy target is non-extensible, but the trap did not return its actual prototype" +ECMA_ERR_PROXY_TRAP_RETURNED_FALSISH = "Proxy trap returned falsish" +ECMA_ERR_PUSHING_TOO_HIGH_ELEMENT = "Pushing element over 2**53-1 length is disallowed" +ECMA_ERR_MIN_GREATER_THAN_MAX = "Quantifier error: min > max" +ECMA_ERR_RADIX_IS_OUT_OF_RANGE = "Radix must be between 2 and 36" +ECMA_ERR_RANGE_OUT_OF_ORDER_IN_CHARACTER_CLASS = "Range out of order in character class" +ECMA_ERR_REALM_IS_NOT_AVAILABLE = "Realm is not available" +ECMA_ERR_REALMS_ARE_DISABLED = "Realms are disabled" +ECMA_ERR_REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE = "Reduce of empty Array with no initial value" +ECMA_ERR_REFLECT_EXPECTS_AN_OBJECT_AS_SECOND_ARGUMENT = "Reflect.construct expects an object as second argument" +ECMA_ERR_REGEXP_ARGUMENT_SHOULD_HAVE_GLOBAL_FLAG = "RegExp argument should have global flag" +ECMA_ERR_REGEXP_IS_NOT_SUPPORTED = "RegExp is not supported" +ECMA_ERR_REJECT_MUST_BE_UNDEFINED = "Reject must be undefined" +ECMA_ERR_REQUEST_IS_NOT_AVAILABLE = "Request is not available" +ECMA_ERR_RESOLVE_METHOD_MUST_BE_CALLABLE = "Resolve method must be callable" +ECMA_ERR_RESOLVE_MUST_BE_UNDEFINED = "Resolve must be undefined" +ECMA_ERR_RESULT_OF_DEFAULTVALUE_IS_INVALID = "Result of [[DefaultValue]] is invalid" +ECMA_ERR_RETURN_VALUE_IS_NOT_AN_ARRAYBUFFER_OBJECT = "Return value is not an ArrayBuffer object" +ECMA_ERR_RETURN_VALUE_OF_EXEC_MUST_BE_AN_OBJECT_OR_NULL = "Return value of 'exec' must be an object or null" +ECMA_ERR_RETURNED_ARRAYBUFFER_HAS_BEEN_DETACHED = "Returned ArrayBuffer has been detached" +ECMA_ERR_RIGHT_VALUE_OF_IN_MUST_BE_AN_OBJECT = "Right value of 'in' must be an object" +ECMA_ERR_RIGHT_VALUE_OF_INSTANCEOF_MUST_BE_AN_OBJECT = "Right value of 'instanceof' must be an object" +ECMA_ERR_SEARCH_STRING_CANNOT_BE_OF_TYPE_REGEXP = "Search string can't be of type: RegExp" +ECMA_ERR_SECOND_ARGUMENT_MUST_BE_AN_OBJECT = "Second argument must be an object" +ECMA_ERR_SPECIES_MUST_BE_A_CONSTRUCTOR = "Species must be a constructor" +ECMA_ERR_STACK_LIMIT_EXCEEDED = "Stack limit exceeded" +ECMA_ERR_START_OFFSET_IS_OUTSIDE_THE_BOUNDS_OF_THE_BUFFER = "Start offset is outside the bounds of the buffer" +ECMA_ERR_STATIC_SNAPSHOTS_ARE_NOT_ENABLED = "Static snapshots are not enabled" +ECMA_ERR_STATIC_SNAPSHOTS_CANNOT_BE_COPIED_INTO_MEMORY = "Static snapshots cannot be copied into memory" +ECMA_ERR_STRING_CANNOT_BE_CONVERTED_TO_BIGINT_VALUE = "String cannot be converted to BigInt value" +ECMA_ERR_SUPER_BINDING_MUST_BE_A_CONSTRUCTOR = "Super binding must be a constructor" +ECMA_ERR_SUPER_CONSTRUCTOR_MAY_ONLY_BE_CALLED_ONCE = "Super constructor may only be called once" +ECMA_ERR_SYMBOL_IS_NOT_A_CONSTRUCTOR = "Symbol is not a constructor" +ECMA_ERR_TARGET_IS_NOT_OBJECT = "Target is not Object" +ECMA_ERR_TARGET_IS_NOT_WEAKREF = "Target is not weakRef" +ECMA_ERR_TARGET_NOT_EXTENSIBLE = "Target not extensible" +ECMA_ERR_TARGET_NOT_EXTENSIBLE_DIFFERENT_PROTOTYPE_RETURNED = "Target object is non-extensible and trap returned different prototype" +ECMA_ERR_THE_MAPFN_ARGUMENT_IS_NOT_CALLABLE = "The 'mapfn' argument is not callable" +ECMA_ERR_THE_GIVEN_ARGUMENT_IS_NOT_A_SYMBOL = "The given argument is not a Symbol" +ECMA_ERR_TARGET_PROPERTY_CONFIGURE_ACCESSOR_WITHOUT_SETTER = "The property of a Proxy target is a non configurable accessor without a setter" +ECMA_ERR_THE_REQUESTED_PROPERTY_UPDATE_CANNOT_BE_PERFORMED = "The requested property update cannot be performed" +ECMA_ERR_THE_STRUCTURE_IS_CYCLICAL = "The structure is cyclical" +ECMA_ERR_THE_TWO_DESCRIPTORS_ARE_INCOMPATIBLE = "The two descriptors are incompatible" +ECMA_ERR_TOO_MANY_ARGUMENTS_DECLARED_FOR_FUNCTION_APPLY = "Too many arguments declared for Function.apply" +ECMA_ERR_TRAP_IS_NEITHER_AN_OBJECT_NOR_UNDEFINED = "Trap is neither an object nor undefined" +ECMA_ERR_TRAP_MUST_RETURN_WITH_AN_OBJECT = "Trap must return with an object" +ECMA_ERR_TRAP_RESULT_NOT_INCLUDE_ALL_CONFIGURABLE_KEYS = "Trap result did not include all configurable keys" +ECMA_ERR_TRAP_RESULT_NOT_INCLUDE_ALL_NON_CONFIGURABLE_KEYS = "Trap result did not include all non-configurable keys" +ECMA_ERR_TRAP_RESULT_NOT_REFLECT_TARGET_EXTENSIBILITY = "Trap result does not reflect extensibility of Proxy target" +ECMA_ERR_TRAP_RESULT_NOT_REFLECT_TARGET_INEXTENSIBILITY = "Trap result does not reflect inextensibility of Proxy target" +ECMA_ERR_TRAP_EXTRA_KEYS_FOR_A_NON_EXTENSIBLE_TARGET = "Trap returned extra keys for a non-extensible Proxy target" +ECMA_ERR_TRAP_FALSISH_PROPERTY_TARGET_NOT_EXTENSIBLE = "Trap returned falsish for property but the proxy target is not extensible" +ECMA_ERR_TRAP_FALSISH_PROPERTY_NON_CONFIGURABLE = "Trap returned falsish for property which exists in the proxy target as non-configurable" +ECMA_ERR_TRAP_RETURNED_NEITHER_OBJECT_NOR_NULL = "Trap returned neither object nor null" +ECMA_ERR_TRAP_TRUISH_ADDING_PROPERTY_NON_EXTENSIBLE_TARGET = "Trap returned truish for adding property to the non-extensible target" +ECMA_ERR_TRAP_TRUISH_ADD_PROPERTY_INCOMPATIBLE_OTHER_PROP = "Trap returned truish for adding property that is incompatible with the existing property in the target" +ECMA_ERR_TRAP_TRUISH_DEFINING_NON_EXISTENT_PROPERTY = "Trap returned truish for defining non-configurable property which is non-existent in the target" +ECMA_ERR_TRAP_TRUISH_PROPERTY_NON_CONFIGURABLE = "Trap returned truish for property which is non-configurable in the proxy target" +ECMA_ERR_TRAP_TRUISH_TARGET_NOT_EXTENSIBLE = "Trap returned truish for target is not extensible" +ECMA_ERR_TRAP_WITH_DUPLICATED_ENTRIES = "Trap returned with duplicated entries" +ECMA_ERR_TYPEDARRAY_INTRINSTIC_CALLED_BY_NEW_EXPRESSION = "TypedArray intrinstic cannot be called by a 'new' expression" +ECMA_ERR_TYPEDARRAY_INTRINSTIC_DIRECTLY_CALLED = "TypedArray intrinstic cannot be directly called" +ECMA_ERR_CONTENTTYPE_RETURNED_TYPEDARRAY_NOT_MATCH_SOURCE = "TypedArray returned by [[ContentType]] does not match source" +ECMA_ERR_UNARY_PLUS_IS_NOT_ALLOWED_FOR_BIGINTS = "Unary plus is not allowed for BigInts" +ECMA_ERR_UNDEFINED_REFERENCE = "Undefined reference" +ECMA_ERR_UNEXPECTED_END_OF_PATTERN = "Unexpected end of pattern" +ECMA_ERR_UNICODE_SURROGATE_PAIR_MISSING = "Unicode surrogate pair missing" +ECMA_ERR_UNMATCHED_CLOSE_BRACKET = "Unmatched close bracket" +ECMA_ERR_UNSHIFT_TOO_HIGH = "Unshift elements over 2**53-1 length is disallowed" +ECMA_ERR_UNSIGNED_RIGHT_SHIFT_IS_NOT_ALLOWED_FOR_BIGINTS = "Unsigned right shift is not allowed for BigInts" +ECMA_ERR_UNSUPPORTED_BINARY_OPERATION = "Unsupported binary operation" +ECMA_ERR_UNSUPPORTED_CONTAINER_OPERATION = "Unsupported container operation" +ECMA_ERR_UNSUPPORTED_SNAPSHOT_EXEC_FLAGS_ARE_SPECIFIED = "Unsupported snapshot exec flags are specified" +ECMA_ERR_UNTERMINATED_CHARACTER_CLASS = "Unterminated character class" +ECMA_ERR_UNTERMINATED_GROUP = "Unterminated group" +ECMA_ERR_VALUE_CANNOT_BE_CONVERTED_TO_BIGINT = "Value cannot be converted to BigInt" +ECMA_ERR_VALUE_FOR_CLASS_HERITAGE_IS_NOT_A_CONSTRUCTOR = "Value for class heritage is not a constructor" +ECMA_ERR_VALUE_RECEIVED_BY_FOR_ASYNC_OF_IS_NOT_OBJECT = "Value received by for-async-of is not object" +ECMA_ERR_VALUE_RECEIVED_BY_YIELD_IS_NOT_OBJECT = "Value received by yield* is not object" +ECMA_ERR_WEAKREF_TARGET_MUST_BE_AN_OBJECT = "WeakRef target must be an object" +ECMA_ERR_METHOD_RETURN_IS_NOT_CALLABLE = "method 'return' is not callable" +ECMA_ERR_VALUE_MSG = "Argument cannot be marked as error" +ECMA_ERR_WRONG_ARGS_MSG = "This type of argument is not allowed" +ECMA_ERR_PARSER_NOT_SUPPORTED = "Source code parsing is disabled" +ECMA_ERR_JSON_NOT_SUPPORTED = "JSON support is disabled" +ECMA_ERR_SYMBOL_NOT_SUPPORTED = "Symbol support is disabled" +ECMA_ERR_PROMISE_NOT_SUPPORTED = "Promise support is disabled" +ECMA_ERR_TYPED_ARRAY_NOT_SUPPORTED = "TypedArray support is disabled" +ECMA_ERR_SHARED_ARRAYBUFFER_NOT_SUPPORTED = "SharedArrayBuffer support is disabled" +ECMA_ERR_DATA_VIEW_NOT_SUPPORTED = "DataView support is disabled" +ECMA_ERR_BIGINT_NOT_SUPPORTED = "BigInt support is disabled" +ECMA_ERR_CONTAINER_NOT_SUPPORTED = "Container support is disabled" +ECMA_ERR_NOT_MODULE = "Argument is not a module" +ECMA_ERR_UNKNOWN_EXPORT = "Native module export not found" +ECMA_ERR_MODULE_NOT_SUPPORTED = "Module support is disabled" +ECMA_ERR_CALLBACK_IS_NOT_CALLABLE = "Callback function is not callable" +ECMA_ERR_ARRAYBUFFER_IS_DETACHED = "ArrayBuffer has been detached" +ECMA_ERR_CANNOT_CONVERT_TO_OBJECT = "Cannot convert undefined or null to object" +ECMA_ERR_CLASS_IS_NON_CONFIGURABLE = "Prototype property of a class is non-configurable" +ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT = "Argument is not an object" +ECMA_ERR_ARGUMENT_IS_NOT_A_PROXY = "Argument is not a Proxy object" +ECMA_ERR_TARGET_IS_NOT_A_CONSTRUCTOR = "Target is not a constructor" +ECMA_ERR_ARGUMENT_IS_NOT_AN_REGEXP = "Argument 'this' is not a RegExp object" +ECMA_ERR_INVALID_ARRAY_LENGTH = "Invalid Array length" +ECMA_ERR_LOCAL_VARIABLE_IS_REDECLARED = "Local variable is redeclared" +ECMA_ERR_EXPECTED_A_FUNCTION = "Expected a function" +ECMA_ERR_CLASS_CONSTRUCTOR_NEW = "Class constructor cannot be invoked without 'new'" +ECMA_ERR_LET_CONST_NOT_INITIALIZED = "Variables declared by let/const must be initialized before reading their value" +ECMA_ERR_MAXIMUM_SNAPSHOT_SIZE = "Maximum snapshot size reached" +ECMA_ERR_REGULAR_EXPRESSION_NOT_SUPPORTED = "Regular expression literals are not supported" +ECMA_ERR_SNAPSHOT_BUFFER_SMALL = "Snapshot buffer too small" +ECMA_ERR_SNAPSHOT_FLAG_NOT_SUPPORTED = "Unsupported generate snapshot flags specified" +ECMA_ERR_CANNOT_ALLOCATE_MEMORY_LITERALS = "Cannot allocate memory for literals" +ECMA_ERR_TAGGED_TEMPLATE_LITERALS = "Unsupported feature: tagged template literals" +ECMA_ERR_CONTAINER_NEEDED = "Value is not a Container or Iterator" +ECMA_ERR_INCORRECT_TYPE_CALL = "Operator called on incorrect container type" +ECMA_ERR_INVALID_TYPE_FOR_CONSTRUCTOR_CALL = "Invalid type for constructor call" +ECMA_ERR_SCRIPT_GLOBAL_FUNCTIONS_INVOKE_WITH_NEW = "Script (global) functions cannot be invoked with 'new'" +ECMA_ERR_GENERATOR_FUNCTIONS_INVOKE_WITH_NEW = "Generator functions cannot be invoked with 'new'" +ECMA_ERR_ASYNC_FUNCTIONS_INVOKE_WITH_NEW = "Async functions cannot be invoked with 'new'" +ECMA_ERR_ASYNC_GENERATOR_FUNCTIONS_INVOKE_WITH_NEW = "Async generator functions cannot be invoked with 'new'" +ECMA_ERR_ACCESSOR_FUNCTIONS_INVOKE_WITH_NEW = "Accessor functions cannot be invoked with 'new'" +ECMA_ERR_METHODS_INVOKE_WITH_NEW = "Methods cannot be invoked with 'new'" +ECMA_ERR_ARROW_FUNCTIONS_INVOKE_WITH_NEW = "Arrow functions cannot be invoked with 'new'" +ECMA_ERR_ASYNC_ARROW_FUNCTIONS_INVOKE_WITH_NEW = "Async arrow functions cannot be invoked with 'new'" +ECMA_ERR_PROXY_TARGET_IS_NOT_A_CONSTRUCTOR = "Proxy target is not a constructor" +ECMA_ERR_MAXIMUM_CALL_STACK_SIZE_EXCEEDED = "Maximum call stack size exceeded" +ECMA_ERR_INVALID_SNAPSHOT_FORMAT = "Invalid snapshot format" +ECMA_ERR_INVALID_SNAPSHOT_VERSION_OR_FEATURES = "Invalid snapshot version or unsupported features present" +ECMA_ERR_RECEIVER_MUST_BE_AN_OBJECT = "Receiver must be an object" \ No newline at end of file diff --git a/jerry-core/ecma/base/ecma-errors.c b/jerry-core/ecma/base/ecma-errors.c index eea386bd1f..ed46cb48b9 100644 --- a/jerry-core/ecma/base/ecma-errors.c +++ b/jerry-core/ecma/base/ecma-errors.c @@ -16,201 +16,56 @@ #include "ecma-errors.h" #if JERRY_ERROR_MESSAGES - -/** - * Error message, if an argument is has an error flag - */ -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"; - -#if !JERRY_PARSER -/** - * Error message, if 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"; -#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"; -/** - * Error message, if 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"; -#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"; -#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"; -#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"; -#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"; -#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"; - -/** - * Error message, if a native module export is 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"; -#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 arrayBuffer is 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"; - -/** - * 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"; - -/** - * Error message, 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' - */ -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"; - -/** - * Error message, 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"; - -/** - * Error message, 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"; - -/** - * Error message, 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'"; - -/** - * 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"); - -#endif /* JERRY_ESNEXT */ - + * Struct to store ecma error message with its size. + */ +typedef struct +{ + lit_utf8_byte_t *text; /* Text of ecma error message. */ + uint8_t size; /* Size of ecma error message. */ +} ecma_error_message_t; + +/* Error message texts with size. */ +static ecma_error_message_t ecma_error_messages[] JERRY_ATTR_CONST_DATA = { + { (lit_utf8_byte_t *) "", 0 }, /* ECMA_ERR_EMPTY */ +/** @cond doxygen_suppress */ +#define ECMA_ERROR_DEF(id, utf8_string) { (lit_utf8_byte_t *) utf8_string, sizeof (utf8_string) - 1 }, +#include "ecma-error-messages.inc.h" +#undef ECMA_ERROR_DEF + /** @endcond */ +}; #endif /* JERRY_ERROR_MESSAGES */ -#if JERRY_SNAPSHOT_SAVE || JERRY_SNAPSHOT_EXEC - -/** - * Error message, 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"; - -/** - * Error message, snapshot buffer too small - */ -const char* const ecma_error_snapshot_buffer_small = "Snapshot buffer too small"; - -/** - * Error message, Unsupported generate snapshot flags specified + * Get specified ecma error as zero-terminated string + * + * @return pointer to zero-terminated ecma error */ -const char* const ecma_error_snapshot_flag_not_supported = "Unsupported generate snapshot flags specified"; +const lit_utf8_byte_t * +ecma_get_error_utf8 (uint32_t id) /**< ecma error id */ +{ + JERRY_ASSERT (id != ECMA_IS_VALID_CONSTRUCTOR); -/** - * Error message, Cannot allocate memory for literals - */ -const char* const ecma_error_cannot_allocate_memory_literals = "Cannot allocate memory for literals"; +#if JERRY_ERROR_MESSAGES + return ecma_error_messages[id].text; +#else /* !JERRY_ERROR_MESSAGES */ + return NULL; +#endif /* JERRY_ERROR_MESSAGES */ +} /* ecma_get_error_utf8 */ /** - * Error message, Unsupported feature: tagged template literals + * Get size of specified ecma error + * + * @return size in bytes */ -const char* const ecma_error_tagged_template_literals = "Unsupported feature: tagged template literals"; +lit_utf8_size_t +ecma_get_error_size (uint32_t id) /**< ecma error id */ +{ + JERRY_ASSERT (id != ECMA_IS_VALID_CONSTRUCTOR); -#endif /* JERRY_SNAPSHOT_SAVE || JERRY_SNAPSHOT_EXEC */ +#if JERRY_ERROR_MESSAGES + return ecma_error_messages[id].size; +#else /* !JERRY_ERROR_MESSAGES */ + return 0; +#endif /* JERRY_ERROR_MESSAGES */ +} /* ecma_get_error_size */ diff --git a/jerry-core/ecma/base/ecma-errors.h b/jerry-core/ecma/base/ecma-errors.h index 6adba1d55a..55fcd7f3f8 100644 --- a/jerry-core/ecma/base/ecma-errors.h +++ b/jerry-core/ecma/base/ecma-errors.h @@ -13,82 +13,27 @@ * limitations under the License. */ -#include "config.h" - #ifndef ECMA_ERRORS_H #define ECMA_ERRORS_H -#if JERRY_ERROR_MESSAGES - -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; -#endif /* !JERRY_PARSER */ - -#if !JERRY_BUILTIN_JSON -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_promise_not_supported_p; -#endif /* !JERRY_ESNEXT */ - -#if !JERRY_BUILTIN_TYPEDARRAY -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; -#endif /* !JERRY_BUILTIN_SHAREDARRAYBUFFER */ - -#if !JERRY_BUILTIN_DATAVIEW -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; -#endif /* !JERRY_BUILTIN_BIGINT */ - -#if !JERRY_BUILTIN_CONTAINER -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; -#else /* !JERRY_MODULE_SYSTEM */ -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 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; - -#if JERRY_ESNEXT -extern const char* const ecma_error_class_constructor_new; -extern const char* const ecma_error_let_const_not_initialized; -#endif /* JERRY_ESNEXT */ +#include "lit-globals.h" +typedef enum +{ + ECMA_ERR_EMPTY, +/** @cond doxygen_suppress */ +#if JERRY_ERROR_MESSAGES +#define ECMA_ERROR_DEF(id, ascii_zt_string) id, +#else /* !JERRY_ERROR_MESSAGES */ +#define ECMA_ERROR_DEF(id, ascii_zt_string) id = ECMA_ERR_EMPTY, #endif /* JERRY_ERROR_MESSAGES */ +#include "ecma-error-messages.inc.h" +#undef ECMA_ERROR_DEF + /** @endcond */ + ECMA_IS_VALID_CONSTRUCTOR /* used as return value when checking constructor */ +} ecma_error_msg_t; + +const lit_utf8_byte_t* ecma_get_error_utf8 (uint32_t id); +lit_utf8_size_t ecma_get_error_size (uint32_t id); -/* 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 */ diff --git a/jerry-core/ecma/base/ecma-globals.h b/jerry-core/ecma/base/ecma-globals.h index b7a38de576..db45985741 100644 --- a/jerry-core/ecma/base/ecma-globals.h +++ b/jerry-core/ecma/base/ecma-globals.h @@ -2272,14 +2272,14 @@ 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; \ - } \ +#define ECMA_CHECK_STACK_USAGE_RETURN(RETURN_VALUE) \ + do \ + { \ + if (ecma_get_current_stack_usage () > CONFIG_MEM_STACK_LIMIT) \ + { \ + ecma_raise_maximum_callstack_error (); \ + return RETURN_VALUE; \ + } \ } while (0) /** diff --git a/jerry-core/ecma/base/ecma-helpers-string.c b/jerry-core/ecma/base/ecma-helpers-string.c index a4d6749b46..be7e31fd89 100644 --- a/jerry-core/ecma/base/ecma-helpers-string.c +++ b/jerry-core/ecma/base/ecma-helpers-string.c @@ -2625,7 +2625,7 @@ ecma_string_pad (ecma_value_t original_string_p, /**< Input ecma string */ if (int_max_length >= UINT32_MAX) { ecma_deref_ecma_string (filler_p); - return ecma_raise_range_error (ECMA_ERR_MSG ("Maximum string length is reached")); + return ecma_raise_range_error (ECMA_ERR_MAXIMUM_STRING_LENGTH_IS_REACHED); } /* 9 */ diff --git a/jerry-core/ecma/base/ecma-helpers-value.c b/jerry-core/ecma/base/ecma-helpers-value.c index 8b3598a921..4bd673d401 100644 --- a/jerry-core/ecma/base/ecma-helpers-value.c +++ b/jerry-core/ecma/base/ecma-helpers-value.c @@ -468,7 +468,7 @@ ecma_is_value_array (ecma_value_t arg) /**< argument */ if (proxy_obj_p->handler == ECMA_VALUE_NULL) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Proxy handler is null for 'isArray' operation")); + return ecma_raise_type_error (ECMA_ERR_PROXY_HANDLER_IS_NULL_FOR_ISARRAY_OPERATION); } return ecma_is_value_array (proxy_obj_p->target); diff --git a/jerry-core/ecma/base/ecma-module.c b/jerry-core/ecma/base/ecma-module.c index 3a3624a406..4349805d6f 100644 --- a/jerry-core/ecma/base/ecma-module.c +++ b/jerry-core/ecma/base/ecma-module.c @@ -282,7 +282,7 @@ ecma_module_resolve_throw (ecma_module_resolve_result_t *resolve_result_p, /**< JERRY_UNUSED (resolve_result_p); JERRY_UNUSED (name_p); - return ecma_raise_syntax_error (NULL); + return ecma_raise_syntax_error (ECMA_ERR_EMPTY); #endif /* !JERRY_ERROR_MESSAGES */ } /* ecma_module_resolve_throw */ @@ -540,7 +540,7 @@ ecma_module_evaluate (ecma_module_t *module_p) /**< module */ { if (module_p->header.u.cls.u1.module_state == JERRY_MODULE_STATE_ERROR) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Module is in error state")); + return ecma_raise_range_error (ECMA_ERR_MODULE_IS_IN_ERROR_STATE); } if (module_p->header.u.cls.u1.module_state >= JERRY_MODULE_STATE_EVALUATING) @@ -947,7 +947,7 @@ ecma_module_connect_imports (ecma_module_t *module_p) if (binding_p != NULL) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Imported binding shadows local variable")); + return ecma_raise_syntax_error (ECMA_ERR_IMPORTED_BINDING_SHADOWS_LOCAL_VARIABLE); } ecma_value_t status = ecma_op_has_binding (lex_env_p, import_names_p->local_name_p); @@ -961,7 +961,7 @@ ecma_module_connect_imports (ecma_module_t *module_p) if (ecma_is_value_true (status)) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Imported binding shadows local variable")); + return ecma_raise_syntax_error (ECMA_ERR_IMPORTED_BINDING_SHADOWS_LOCAL_VARIABLE); } import_names_p = import_names_p->next_p; @@ -1104,7 +1104,7 @@ ecma_module_link (ecma_module_t *module_p, /**< root module */ { if (module_p->header.u.cls.u1.module_state != JERRY_MODULE_STATE_UNLINKED) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Module must be in unlinked state")); + return ecma_raise_type_error (ECMA_ERR_MODULE_MUST_BE_IN_UNLINKED_STATE); } module_p->header.u.cls.u1.module_state = JERRY_MODULE_STATE_LINKING; @@ -1152,7 +1152,7 @@ ecma_module_link (ecma_module_t *module_p, /**< root module */ if (resolved_module_p == NULL) { ecma_free_value (resolve_result); - ecma_raise_type_error (ECMA_ERR_MSG ("Callback result must be a module")); + ecma_raise_type_error (ECMA_ERR_CALLBACK_RESULT_NOT_MODULE); goto error; } @@ -1167,7 +1167,7 @@ ecma_module_link (ecma_module_t *module_p, /**< root module */ if (resolved_module_p->header.u.cls.u1.module_state == JERRY_MODULE_STATE_ERROR) { - ecma_raise_type_error (ECMA_ERR_MSG ("Cannot link to a module which is in error state")); + ecma_raise_type_error (ECMA_ERR_LINK_TO_MODULE_IN_ERROR_STATE); goto error; } @@ -1404,7 +1404,7 @@ ecma_module_import (ecma_value_t specifier, /**< module specifier */ return result; error_module_instantiate: - ecma_raise_range_error (ECMA_ERR_MSG ("Module cannot be instantiated")); + ecma_raise_range_error (ECMA_ERR_MODULE_CANNOT_BE_INSTANTIATED); error: if (jcontext_has_pending_abort ()) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-array-iterator-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-array-iterator-prototype.c index 3c0c49bdba..308845ff0b 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-array-iterator-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-array-iterator-prototype.c @@ -70,7 +70,7 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t /* 1 - 2. */ if (!ecma_is_value_object (this_val)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT); } ecma_object_t *obj_p = ecma_get_object_from_value (this_val); @@ -79,7 +79,7 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t /* 3. */ if (!ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_ARRAY_ITERATOR)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an iterator")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_ITERATOR); } ecma_value_t iterated_value = ext_obj_p->u.cls.u3.iterated_value; @@ -100,7 +100,7 @@ ecma_builtin_array_iterator_prototype_object_next (ecma_value_t this_val) /**< t ecma_object_t *arraybuffer_p = ecma_typedarray_get_arraybuffer (array_object_p); if (ecma_arraybuffer_is_detached (arraybuffer_p)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached)); + return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); } /* b. */ diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c index 211d5f1764..db99022f8e 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c @@ -434,7 +434,7 @@ ecma_builtin_array_prototype_object_push (const ecma_value_t *argument_list_p, / { if ((ecma_number_t) (length + arguments_number) > UINT32_MAX) { - return ecma_raise_range_error (ECMA_ERR_MSG (ecma_error_invalid_array_length)); + return ecma_raise_range_error (ECMA_ERR_INVALID_ARRAY_LENGTH); } if (arguments_number == 0) @@ -460,7 +460,7 @@ ecma_builtin_array_prototype_object_push (const ecma_value_t *argument_list_p, / /* 5. */ if ((ecma_number_t) (length + arguments_number) > ECMA_NUMBER_MAX_SAFE_INTEGER) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Pushing element over 2**53-1 length is disallowed")); + return ecma_raise_type_error (ECMA_ERR_PUSHING_TOO_HIGH_ELEMENT); } /* 6. */ @@ -1089,7 +1089,7 @@ ecma_builtin_array_prototype_object_sort (ecma_value_t this_arg, /**< this argum /* Check if the provided compare function is callable. */ if (!ecma_is_value_undefined (arg1) && !ecma_op_is_callable (arg1)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Compare function is not callable")); + return ecma_raise_type_error (ECMA_ERR_COMPARE_FUNC_NOT_CALLABLE); } ecma_length_t len; @@ -1284,7 +1284,7 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu /* ES11: 8. */ if ((ecma_number_t) new_length > ECMA_NUMBER_MAX_SAFE_INTEGER) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Invalid new Array length")); + return ecma_raise_type_error (ECMA_ERR_INVALID_NEW_ARRAY_LENGTH); } /* ES11: 9. */ @@ -1486,7 +1486,7 @@ ecma_builtin_array_prototype_object_unshift (const ecma_value_t args[], /**< arg { if (args_number > UINT32_MAX - len) { - return ecma_raise_range_error (ECMA_ERR_MSG (ecma_error_invalid_array_length)); + return ecma_raise_range_error (ECMA_ERR_INVALID_ARRAY_LENGTH); } if (args_number == 0) @@ -1523,7 +1523,7 @@ ecma_builtin_array_prototype_object_unshift (const ecma_value_t args[], /**< arg /* ES11:4.a. */ if ((ecma_number_t) (len + args_number) > ECMA_NUMBER_MAX_SAFE_INTEGER) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Unshift elements over 2**53-1 length is disallowed")); + return ecma_raise_type_error (ECMA_ERR_UNSHIFT_TOO_HIGH); } #endif /* JERRY_ESNEXT */ @@ -1854,7 +1854,7 @@ ecma_builtin_array_apply (ecma_value_t arg1, /**< callbackfn */ /* 4. */ if (!ecma_op_is_callable (arg1)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_callback_is_not_callable)); + return ecma_raise_type_error (ECMA_ERR_CALLBACK_IS_NOT_CALLABLE); } /* We already checked that arg1 is callable */ @@ -1937,7 +1937,7 @@ ecma_builtin_array_prototype_object_map (ecma_value_t arg1, /**< callbackfn */ /* 4. */ if (!ecma_op_is_callable (arg1)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_callback_is_not_callable)); + return ecma_raise_type_error (ECMA_ERR_CALLBACK_IS_NOT_CALLABLE); } /* 6. */ @@ -2028,7 +2028,7 @@ ecma_builtin_array_prototype_object_filter (ecma_value_t arg1, /**< callbackfn * /* 4. */ if (!ecma_op_is_callable (arg1)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_callback_is_not_callable)); + return ecma_raise_type_error (ECMA_ERR_CALLBACK_IS_NOT_CALLABLE); } /* 6. */ @@ -2133,13 +2133,13 @@ ecma_builtin_array_reduce_from (const ecma_value_t args_p[], /**< routine's argu /* 4. */ if (!ecma_op_is_callable (args_p[0])) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_callback_is_not_callable)); + return ecma_raise_type_error (ECMA_ERR_CALLBACK_IS_NOT_CALLABLE); } /* 5. */ if (len == 0 && args_number == 1) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Reduce of empty Array with no initial value")); + return ecma_raise_type_error (ECMA_ERR_REDUCE_OF_EMPTY_ARRAY_WITH_NO_INITIAL_VALUE); } JERRY_ASSERT (ecma_is_value_object (args_p[0])); @@ -2191,7 +2191,7 @@ ecma_builtin_array_reduce_from (const ecma_value_t args_p[], /**< routine's argu /* 8.c */ if (!k_present) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Missing Array element")); + return ecma_raise_type_error (ECMA_ERR_MISSING_ARRAY_ELEMENT); } } /* 9. */ @@ -2343,7 +2343,7 @@ ecma_builtin_array_prototype_object_find (ecma_value_t predicate, /**< callback /* 5. */ if (!ecma_op_is_callable (predicate)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_callback_is_not_callable)); + return ecma_raise_type_error (ECMA_ERR_CALLBACK_IS_NOT_CALLABLE); } /* We already checked that predicate is callable, so it will always be an object. */ @@ -2825,7 +2825,7 @@ ecma_builtin_array_prototype_object_flat_map (ecma_value_t callback, /**< callba { if (!ecma_op_is_callable (callback)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_callback_is_not_callable)); + return ecma_raise_type_error (ECMA_ERR_CALLBACK_IS_NOT_CALLABLE); } /* 4. */ diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-array.c b/jerry-core/ecma/builtin-objects/ecma-builtin-array.c index 59abb4481b..bfd782e873 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-array.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-array.c @@ -97,7 +97,7 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */ /* 3.a */ if (!ecma_op_is_callable (mapfn)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_callback_is_not_callable)); + return ecma_raise_type_error (ECMA_ERR_CALLBACK_IS_NOT_CALLABLE); } /* 3.b */ @@ -136,7 +136,7 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */ if (ecma_is_value_undefined (array) || ecma_is_value_null (array)) { ecma_free_value (using_iterator); - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_cannot_convert_to_object)); + return ecma_raise_type_error (ECMA_ERR_CANNOT_CONVERT_TO_OBJECT); } /* 6.c */ @@ -297,7 +297,7 @@ ecma_builtin_array_object_from (ecma_value_t this_arg, /**< 'this' argument */ if (ecma_is_value_undefined (array) || ecma_is_value_null (array)) { - ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_cannot_convert_to_object)); + ecma_raise_type_error (ECMA_ERR_CANNOT_CONVERT_TO_OBJECT); goto cleanup; } @@ -482,7 +482,7 @@ ecma_builtin_array_dispatch_call (const ecma_value_t *arguments_list_p, /**< arg if (num != ((ecma_number_t) num_uint32)) { - return ecma_raise_range_error (ECMA_ERR_MSG (ecma_error_invalid_array_length)); + return ecma_raise_range_error (ECMA_ERR_INVALID_ARRAY_LENGTH); } return ecma_make_object_value (ecma_op_new_array_object (num_uint32)); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-arraybuffer-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-arraybuffer-prototype.c index d1aee322b9..3e47e06879 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-arraybuffer-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-arraybuffer-prototype.c @@ -66,7 +66,7 @@ ecma_builtin_arraybuffer_prototype_bytelength_getter (ecma_value_t this_arg) /** { if (ecma_arraybuffer_is_detached (object_p)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached)); + return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); } uint32_t len = ecma_arraybuffer_get_length (object_p); @@ -74,7 +74,7 @@ ecma_builtin_arraybuffer_prototype_bytelength_getter (ecma_value_t this_arg) /** } } - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a ArrayBuffer object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_ARRAY_BUFFER_OBJECT); } /* ecma_builtin_arraybuffer_prototype_bytelength_getter */ /** @@ -93,7 +93,7 @@ ecma_builtin_arraybuffer_prototype_object_slice (ecma_value_t this_arg, /**< thi { if (!ecma_is_value_object (this_arg)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT); } ecma_object_t *object_p = ecma_get_object_from_value (this_arg); @@ -101,7 +101,7 @@ ecma_builtin_arraybuffer_prototype_object_slice (ecma_value_t this_arg, /**< thi /* 2. */ if (!ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an ArrayBuffer object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_ARRAY_BUFFER_OBJECT); } return ecma_builtin_arraybuffer_slice (this_arg, argument_list_p, arguments_number); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-arraybuffer.c b/jerry-core/ecma/builtin-objects/ecma-builtin-arraybuffer.c index 1ad9d9bfe4..cb26f0a99c 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-arraybuffer.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-arraybuffer.c @@ -76,7 +76,7 @@ ecma_builtin_arraybuffer_dispatch_call (const ecma_value_t *arguments_list_p, /* { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor ArrayBuffer requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_ARRAYBUFFER_REQUIRES_NEW); } /* ecma_builtin_arraybuffer_dispatch_call */ /** diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-async-from-sync-iterator-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-async-from-sync-iterator-prototype.c index 0f2c5552a7..70ee6e5394 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-async-from-sync-iterator-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-async-from-sync-iterator-prototype.c @@ -255,9 +255,8 @@ ecma_builtin_async_from_sync_iterator_prototype_do (ecma_async_from_sync_iterato ecma_free_value (call_result); #if JERRY_ERROR_MESSAGES - const lit_utf8_byte_t *msg_p = (const lit_utf8_byte_t *) ecma_error_argument_is_not_an_object; - lit_utf8_size_t msg_size = (lit_utf8_size_t) ecma_error_argument_is_not_an_object_length; - JERRY_ASSERT (lit_zt_utf8_string_size (msg_p) == msg_size); + const lit_utf8_byte_t *msg_p = ecma_get_error_utf8 (ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT); + lit_utf8_size_t msg_size = ecma_get_error_size (ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT); ecma_string_t *error_msg_p = ecma_new_ecma_string_from_ascii (msg_p, msg_size); #else /* !JERRY_ERROR_MESSAGES */ ecma_string_t *error_msg_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-async-generator-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-async-generator-prototype.c index 0d710f26ed..fe5d4fcf2e 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-async-generator-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-async-generator-prototype.c @@ -111,7 +111,7 @@ ecma_builtin_async_generator_prototype_dispatch_routine (uint8_t builtin_routine if (executable_object_p == NULL) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an async generator object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_ASYNC_GENERATOR); } if (executable_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_COMPLETED) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-bigint-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-bigint-prototype.c index 3c32e7245f..4e6ad9bffd 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-bigint-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-bigint-prototype.c @@ -82,7 +82,7 @@ ecma_builtin_bigint_prototype_object_value_of (ecma_value_t this_arg) /**< this } } - return ecma_raise_type_error (ECMA_ERR_MSG ("BigInt value expected")); + return ecma_raise_type_error (ECMA_ERR_BIGINT_VALUE_EXCPECTED); } /* ecma_builtin_bigint_prototype_object_value_of */ /** @@ -112,7 +112,7 @@ ecma_builtin_bigint_prototype_object_to_string (ecma_value_t this_arg, /**< this if (arg_num < 2 || arg_num > 36) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Radix must be between 2 and 36")); + return ecma_raise_range_error (ECMA_ERR_RADIX_IS_OUT_OF_RANGE); } radix = (uint32_t) arg_num; diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-bigint.c b/jerry-core/ecma/builtin-objects/ecma-builtin-bigint.c index 1c7e9f0cc8..b349db16cf 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-bigint.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-bigint.c @@ -68,7 +68,7 @@ ecma_builtin_bigint_dispatch_construct (const ecma_value_t *arguments_list_p, /* { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("BigInt function is not a constructor")); + return ecma_raise_type_error (ECMA_ERR_BIGINT_FUNCTION_NOT_CONSTRUCTOR); } /* ecma_builtin_bigint_dispatch_construct */ /** diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-boolean-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-boolean-prototype.c index cd175dd4cf..0d71a0677c 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-boolean-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-boolean-prototype.c @@ -89,7 +89,7 @@ ecma_builtin_boolean_prototype_object_value_of (ecma_value_t this_arg) /**< this } } - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a Boolean object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_BOOLEAN_OBJECT); } /* ecma_builtin_boolean_prototype_object_value_of */ /** diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-dataview-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-dataview-prototype.c index edebf7b73c..6cb9ba3a65 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-dataview-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-dataview-prototype.c @@ -122,7 +122,7 @@ ecma_builtin_dataview_prototype_object_getters (ecma_value_t this_arg, /**< this { if (ecma_arraybuffer_is_detached (obj_p->buffer_p)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached)); + return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); } return ecma_make_uint32_value (obj_p->header.u.cls.u3.length); } @@ -132,7 +132,7 @@ ecma_builtin_dataview_prototype_object_getters (ecma_value_t this_arg, /**< this if (ecma_arraybuffer_is_detached (obj_p->buffer_p)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached)); + return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); } return ecma_make_uint32_value (obj_p->byte_offset); } diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-dataview.c b/jerry-core/ecma/builtin-objects/ecma-builtin-dataview.c index 6e86c6dc29..bfdb33f0ef 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-dataview.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-dataview.c @@ -47,7 +47,7 @@ ecma_builtin_dataview_dispatch_call (const ecma_value_t *arguments_list_p, /**< { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor DataView requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_DATAVIEW_REQUIRES_NEW); } /* ecma_builtin_dataview_dispatch_call */ /** diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.c index 2a3120bc06..61c81352e2 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.c @@ -214,7 +214,7 @@ ecma_builtin_date_prototype_to_primitive (ecma_value_t this_arg, /**< this argum } } - return ecma_raise_type_error (ECMA_ERR_MSG ("Invalid argument type in toPrimitive")); + return ecma_raise_type_error (ECMA_ERR_INVALID_ARGUMENT_TYPE_IN_TOPRIMITIVE); } /* ecma_builtin_date_prototype_to_primitive */ #endif /* JERRY_ESNEXT */ @@ -638,7 +638,7 @@ ecma_builtin_date_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< b if (!ecma_is_value_object (this_arg) || !ecma_object_class_is (ecma_get_object_from_value (this_arg), ECMA_OBJECT_CLASS_DATE)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a Date object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_DATE_OBJECT); } ecma_object_t *this_obj_p = ecma_get_object_from_value (this_arg); @@ -712,7 +712,7 @@ ecma_builtin_date_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< b { if (ecma_number_is_nan (date_value)) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Date must be a finite number")); + return ecma_raise_range_error (ECMA_ERR_DATE_MUST_BE_A_FINITE_NUMBER); } return ecma_date_value_to_iso_string (date_value); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-error-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-error-prototype.c index 861d822668..db69f1b912 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-error-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-error-prototype.c @@ -101,7 +101,7 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this /* 2. */ if (!ecma_is_value_object (this_arg)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT); } ecma_object_t *obj_p = ecma_get_object_from_value (this_arg); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-function-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-function-prototype.c index 44e303473b..8910eaaa74 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-function-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-function-prototype.c @@ -217,7 +217,7 @@ ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, /**< th /* 3. */ if (!ecma_is_value_object (arg2)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_argument_is_not_an_object)); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT); } ecma_object_t *obj_p = ecma_get_object_from_value (arg2); @@ -233,7 +233,7 @@ ecma_builtin_function_prototype_object_apply (ecma_object_t *func_obj_p, /**< th if (length >= ECMA_FUNCTION_APPLY_ARGUMENT_COUNT_LIMIT) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Too many arguments declared for Function.apply")); + return ecma_raise_range_error (ECMA_ERR_TOO_MANY_ARGUMENTS_DECLARED_FOR_FUNCTION_APPLY); } /* 6. */ @@ -498,7 +498,7 @@ ecma_builtin_function_prototype_dispatch_construct (const ecma_value_t *argument { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Function.prototype is not a constructor")); + return ecma_raise_type_error (ECMA_ERR_FUNCTION_PROTOTYPE_NOT_A_CONSTRUCTOR); } /* ecma_builtin_function_prototype_dispatch_construct */ /** @@ -523,7 +523,7 @@ ecma_builtin_function_prototype_dispatch_routine (uint8_t builtin_routine_id, /* } #endif /* JERRY_ESNEXT */ - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a function")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_FUNCTION); } ecma_object_t *func_obj_p = ecma_get_object_from_value (this_arg); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-generator-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-generator-prototype.c index 815e939304..703f6e1d15 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-generator-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-generator-prototype.c @@ -223,12 +223,12 @@ ecma_builtin_generator_prototype_dispatch_routine (uint8_t builtin_routine_id, / if (executable_object_p == NULL) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a generator object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_GENERATOR_OBJECT); } if (executable_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_RUNNING) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Generator is currently under execution")); + return ecma_raise_type_error (ECMA_ERR_GENERATOR_IS_CURRENTLY_UNDER_EXECUTION); } if (executable_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_COMPLETED) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-global.c b/jerry-core/ecma/builtin-objects/ecma-builtin-global.c index f02303848e..2795017bcd 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-global.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-global.c @@ -210,7 +210,7 @@ ecma_builtin_global_object_decode_uri_helper (lit_utf8_byte_t *input_start_p, /* if (hex_value == UINT32_MAX) { ecma_stringbuilder_destroy (&builder); - return ecma_raise_uri_error (ECMA_ERR_MSG ("Invalid hexadecimal value")); + return ecma_raise_uri_error (ECMA_ERR_INVALID_HEXADECIMAL_VALUE); } ecma_char_t decoded_byte = (ecma_char_t) hex_value; @@ -248,7 +248,7 @@ ecma_builtin_global_object_decode_uri_helper (lit_utf8_byte_t *input_start_p, /* else { ecma_stringbuilder_destroy (&builder); - return ecma_raise_uri_error (ECMA_ERR_MSG ("Invalid UTF8 character")); + return ecma_raise_uri_error (ECMA_ERR_INVALID_UTF8_CHARACTER); } lit_utf8_byte_t octets[LIT_UTF8_MAX_BYTES_IN_CODE_POINT]; @@ -280,7 +280,7 @@ ecma_builtin_global_object_decode_uri_helper (lit_utf8_byte_t *input_start_p, /* if (!is_valid || !lit_is_valid_utf8_string (octets, bytes_count, true)) { ecma_stringbuilder_destroy (&builder); - return ecma_raise_uri_error (ECMA_ERR_MSG ("Invalid UTF8 string")); + return ecma_raise_uri_error (ECMA_ERR_INVALID_UTF8_STRING); } lit_code_point_t cp; @@ -289,7 +289,7 @@ ecma_builtin_global_object_decode_uri_helper (lit_utf8_byte_t *input_start_p, /* if (lit_is_code_point_utf16_high_surrogate (cp) || lit_is_code_point_utf16_low_surrogate (cp)) { ecma_stringbuilder_destroy (&builder); - return ecma_raise_uri_error (ECMA_ERR_MSG ("Invalid UTF8 codepoint")); + return ecma_raise_uri_error (ECMA_ERR_INVALID_UTF8_CODEPOINT); } lit_utf8_byte_t result_chars[LIT_CESU8_MAX_BYTES_IN_CODE_POINT]; @@ -348,7 +348,7 @@ ecma_builtin_global_object_encode_uri_helper (lit_utf8_byte_t *input_start_p, /* if (lit_is_code_point_utf16_low_surrogate (ch)) { ecma_stringbuilder_destroy (&builder); - return ecma_raise_uri_error (ECMA_ERR_MSG ("Unicode surrogate pair missing")); + return ecma_raise_uri_error (ECMA_ERR_UNICODE_SURROGATE_PAIR_MISSING); } lit_code_point_t cp = ch; @@ -358,7 +358,7 @@ ecma_builtin_global_object_encode_uri_helper (lit_utf8_byte_t *input_start_p, /* if (input_char_p == input_end_p) { ecma_stringbuilder_destroy (&builder); - return ecma_raise_uri_error (ECMA_ERR_MSG ("Unicode surrogate pair missing")); + return ecma_raise_uri_error (ECMA_ERR_UNICODE_SURROGATE_PAIR_MISSING); } ecma_char_t next_ch; @@ -372,7 +372,7 @@ ecma_builtin_global_object_encode_uri_helper (lit_utf8_byte_t *input_start_p, /* else { ecma_stringbuilder_destroy (&builder); - return ecma_raise_uri_error (ECMA_ERR_MSG ("Unicode surrogate pair missing")); + return ecma_raise_uri_error (ECMA_ERR_UNICODE_SURROGATE_PAIR_MISSING); } } diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.c b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.c index 3edab6f2c4..d065b7e850 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.c @@ -368,7 +368,7 @@ ecma_builtin_helper_array_concat_value (ecma_object_t *array_obj_p, /**< array * /* 4 . */ if ((ecma_number_t) (*length_p + arg_len) > ECMA_NUMBER_MAX_SAFE_INTEGER) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_invalid_array_length)); + return ecma_raise_type_error (ECMA_ERR_INVALID_ARRAY_LENGTH); } #else /* !JERRY_ESNEXT */ /* 5.b.ii */ @@ -591,7 +591,7 @@ ecma_builtin_helper_string_prototype_object_index_of (ecma_string_t *original_st if (regexp == ECMA_VALUE_TRUE) { JERRY_ASSERT (ECMA_STRING_LAST_INDEX_OF < mode && mode <= ECMA_STRING_ENDS_WITH); - return ecma_raise_type_error (ECMA_ERR_MSG ("Search string can't be of type: RegExp")); + return ecma_raise_type_error (ECMA_ERR_SEARCH_STRING_CANNOT_BE_OF_TYPE_REGEXP); } } #endif /* JERRY_ESNEXT */ diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-intrinsic.c b/jerry-core/ecma/builtin-objects/ecma-builtin-intrinsic.c index fc11a6be4b..0134afa65f 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-intrinsic.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-intrinsic.c @@ -172,12 +172,12 @@ ecma_builtin_intrinsic_dispatch_routine (uint8_t builtin_routine_id, /**< built- { if (!ecma_is_typedarray (this_arg)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a TypedArray")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_TYPED_ARRAY); } if (ecma_arraybuffer_is_detached (ecma_typedarray_get_arraybuffer (ecma_get_object_from_value (this_arg)))) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached)); + return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); } return ecma_typedarray_iterators_helper (this_arg, ECMA_ITERATOR_VALUES); @@ -208,7 +208,7 @@ ecma_builtin_intrinsic_dispatch_routine (uint8_t builtin_routine_id, /**< built- if (!ecma_is_value_object (this_arg) || !ecma_object_class_is (ecma_get_object_from_value (this_arg), ECMA_OBJECT_CLASS_DATE)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a Date object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_DATE_OBJECT); } #if JERRY_ESNEXT diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-json.c b/jerry-core/ecma/builtin-objects/ecma-builtin-json.c index ef2a7dbd00..0462ca3295 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-json.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-json.c @@ -811,7 +811,7 @@ ecma_builtin_json_parse_buffer (const lit_utf8_byte_t *str_start_p, /**< String ecma_free_value (result); } - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid JSON format")); + return ecma_raise_syntax_error (ECMA_ERR_INVALID_JSON_FORMAT); } /* ecma_builtin_json_parse_buffer */ /** @@ -987,7 +987,7 @@ ecma_builtin_json_serialize_object (ecma_json_stringify_context_t *context_p, /* /* 1. */ if (ecma_json_has_object_in_stack (context_p->occurrence_stack_last_p, obj_p)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("The structure is cyclical")); + return ecma_raise_type_error (ECMA_ERR_THE_STRUCTURE_IS_CYCLICAL); } /* 2. */ @@ -1124,7 +1124,7 @@ ecma_builtin_json_serialize_array (ecma_json_stringify_context_t *context_p, /** /* 1. */ if (ecma_json_has_object_in_stack (context_p->occurrence_stack_last_p, obj_p)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("The structure is cyclical")); + return ecma_raise_type_error (ECMA_ERR_THE_STRUCTURE_IS_CYCLICAL); } /* 2. */ @@ -1414,7 +1414,7 @@ ecma_builtin_json_serialize_property (ecma_json_stringify_context_t *context_p, if (ecma_is_value_bigint (value)) { ecma_free_value (value); - return ecma_raise_type_error (ECMA_ERR_MSG ("BigInt cannot be serialized")); + return ecma_raise_type_error (ECMA_ERR_BIGINT_SERIALIZED); } #endif /* JERRY_BUILTIN_BIGINT */ diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-map.c b/jerry-core/ecma/builtin-objects/ecma-builtin-map.c index f79cccd5ec..817b5f947e 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-map.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-map.c @@ -47,7 +47,7 @@ ecma_builtin_map_dispatch_call (const ecma_value_t *arguments_list_p, /**< argum { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor Map requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_MAP_REQUIRES_NEW); } /* ecma_builtin_map_dispatch_call */ /** diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c index 6b2bdd5293..2e94f3a10b 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c @@ -165,7 +165,7 @@ ecma_builtin_number_prototype_object_to_string (ecma_number_t this_arg_number, / if (radix < 2 || radix > 36) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Radix must be between 2 and 36")); + return ecma_raise_range_error (ECMA_ERR_RADIX_IS_OUT_OF_RANGE); } } @@ -451,7 +451,7 @@ ecma_builtin_number_prototype_object_value_of (ecma_value_t this_arg) /**< this } } - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a number or a Number object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_NUMBER); } /* ecma_builtin_number_prototype_object_value_of */ /** @@ -489,7 +489,7 @@ ecma_builtin_number_prototype_object_to_number_convert (ecma_number_t this_num, /* Argument boundary check for toFixed method */ if (mode == NUMBER_ROUTINE_TO_FIXED && (arg_num <= -1 || arg_num >= 101)) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Fraction digits must be between 0 and 100")); + return ecma_raise_range_error (ECMA_ERR_FRACTION_DIGITS_OUT_OF_RANGE); } /* Handle NaN separately */ @@ -557,12 +557,12 @@ ecma_builtin_number_prototype_object_to_number_convert (ecma_number_t this_num, if (mode == NUMBER_ROUTINE_TO_EXPONENTIAL && (arg_num <= -1 || arg_num >= 101)) { ecma_stringbuilder_destroy (&builder); - return ecma_raise_range_error (ECMA_ERR_MSG ("Fraction digits must be between 0 and 100")); + return ecma_raise_range_error (ECMA_ERR_FRACTION_DIGITS_OUT_OF_RANGE); } else if (mode == NUMBER_ROUTINE_TO_PRECISION && (arg_num < 1 || arg_num > 100)) { ecma_stringbuilder_destroy (&builder); - return ecma_raise_range_error (ECMA_ERR_MSG ("Precision digits must be between 1 and 100")); + return ecma_raise_range_error (ECMA_ERR_PRECISION_DIGITS_MUST_BE_BETWEEN_IN_RANGE); } num_of_digits = ecma_number_to_decimal (this_num, digits, &exponent); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-object-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-object-prototype.c index 7bdf27daad..71417fad55 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-object-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-object-prototype.c @@ -241,7 +241,7 @@ ecma_builtin_object_prototype_define_getter_setter (ecma_value_t this_arg, /**< if (!ecma_op_is_callable (accessor)) { ecma_deref_object (obj_p); - return ecma_raise_type_error (ECMA_ERR_MSG ("Getter is not callable")); + return ecma_raise_type_error (ECMA_ERR_GETTER_IS_NOT_CALLABLE); } ecma_object_t *accessor_obj_p = ecma_get_object_from_value (accessor); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-object.c b/jerry-core/ecma/builtin-objects/ecma-builtin-object.c index 6f7da09998..b94cb129a0 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-object.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-object.c @@ -198,7 +198,7 @@ ecma_builtin_object_object_set_prototype_of (ecma_value_t arg1, /**< routine's f /* 3. */ if (!ecma_is_value_object (arg2) && !ecma_is_value_null (arg2)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Prototype is neither object nor null")); + return ecma_raise_type_error (ECMA_ERR_PROTOTYPE_IS_NEITHER_OBJECT_NOR_NULL); } /* 4. */ @@ -231,7 +231,7 @@ ecma_builtin_object_object_set_prototype_of (ecma_value_t arg1, /**< routine's f if (ecma_is_value_false (status)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Cannot set [[Prototype]]")); + return ecma_raise_type_error (ECMA_ERR_SET_PROTOTYPE); } JERRY_ASSERT (ecma_is_value_true (status)); @@ -295,7 +295,7 @@ ecma_builtin_object_object_set_proto (ecma_value_t arg1, /**< routine's first ar if (ecma_is_value_false (status)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Cannot set [[Prototype]]")); + return ecma_raise_type_error (ECMA_ERR_SET_PROTOTYPE); } JERRY_ASSERT (ecma_is_value_true (status)); @@ -465,7 +465,7 @@ ecma_builtin_object_object_seal (ecma_object_t *obj_p) /**< routine's argument * #if JERRY_BUILTIN_PROXY if (ecma_is_value_false (status)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Object cannot be sealed")); + return ecma_raise_type_error (ECMA_ERR_OBJECT_CANNOT_BE_SEALED); } #endif /* JERRY_BUILTIN_PROXY */ @@ -496,7 +496,7 @@ ecma_builtin_object_object_freeze (ecma_object_t *obj_p) /**< routine's argument #if JERRY_BUILTIN_PROXY if (ecma_is_value_false (status)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Object cannot be frozen")); + return ecma_raise_type_error (ECMA_ERR_OBJECT_CANNOT_BE_FROZEN); } #endif /* JERRY_BUILTIN_PROXY */ @@ -529,7 +529,7 @@ ecma_builtin_object_object_prevent_extensions (ecma_object_t *obj_p) /**< routin if (ecma_is_value_false (status)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Cannot set [[Extensible]] property of object")); + return ecma_raise_type_error (ECMA_ERR_SET_EXTENSIBLE_PROPERTY); } JERRY_ASSERT (ecma_is_value_true (status)); @@ -945,7 +945,7 @@ ecma_builtin_object_object_create (ecma_value_t arg1, /**< routine's first argum /* 1. */ if (!ecma_is_value_object (arg1) && !ecma_is_value_null (arg1)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_argument_is_not_an_object)); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT); } ecma_object_t *obj_p = NULL; @@ -1012,7 +1012,7 @@ ecma_builtin_object_object_define_property (ecma_object_t *obj_p, /**< routine's if (ecma_is_value_false (define_own_prop_ret)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("The requested property update cannot be performed")); + return ecma_raise_type_error (ECMA_ERR_THE_REQUESTED_PROPERTY_UPDATE_CANNOT_BE_PERFORMED); } JERRY_ASSERT (ecma_is_value_true (define_own_prop_ret)); @@ -1211,7 +1211,7 @@ ecma_builtin_object_from_entries (ecma_value_t iterator) /**< object's iterator if (!ecma_is_value_object (result)) { ecma_free_value (result); - ecma_raise_type_error (ECMA_ERR_MSG ("Iterator value is not an object")); + ecma_raise_type_error (ECMA_ERR_ITERATOR_VALUE_IS_NOT_AN_OBJECT); result = ecma_op_iterator_close (original_iterator); JERRY_ASSERT (ECMA_IS_VALUE_ERROR (result)); goto cleanup_iterator; @@ -1403,7 +1403,7 @@ ecma_builtin_object_dispatch_routine (uint8_t builtin_routine_id, /**< built-in #if !JERRY_ESNEXT if (!ecma_is_value_object (arg1)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_argument_is_not_an_object)); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT); } #endif /* !JERRY_ESNEXT */ @@ -1412,7 +1412,7 @@ ecma_builtin_object_dispatch_routine (uint8_t builtin_routine_id, /**< built-in #if JERRY_ESNEXT if (!ecma_is_value_object (arg1)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_argument_is_not_an_object)); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT); } #endif /* JERRY_ESNEXT */ diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-promise.c b/jerry-core/ecma/builtin-objects/ecma-builtin-promise.c index 4de450bf83..7a53b9c10b 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-promise.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-promise.c @@ -98,7 +98,7 @@ ecma_builtin_promise_perform_race (ecma_value_t iterator, /**< the iterator for if (!ecma_op_is_callable (resolve)) { ecma_free_value (resolve); - return ecma_raise_type_error (ECMA_ERR_MSG ("Resolve method must be callable")); + return ecma_raise_type_error (ECMA_ERR_RESOLVE_METHOD_MUST_BE_CALLABLE); } ecma_object_t *resolve_func_p = ecma_get_object_from_value (resolve); @@ -196,7 +196,7 @@ ecma_builtin_promise_perform (ecma_value_t iterator, /**< iteratorRecord */ if (!ecma_op_is_callable (resolve)) { ecma_free_value (resolve); - return ecma_raise_type_error (ECMA_ERR_MSG ("Resolve method must be callable")); + return ecma_raise_type_error (ECMA_ERR_RESOLVE_METHOD_MUST_BE_CALLABLE); } ecma_object_t *resolve_func_p = ecma_get_object_from_value (resolve); @@ -281,7 +281,7 @@ ecma_builtin_promise_perform (ecma_value_t iterator, /**< iteratorRecord */ if (JERRY_UNLIKELY (idx == UINT32_MAX - 1)) { - ecma_raise_range_error (ECMA_ERR_MSG ("Promise.all remaining elements limit reached")); + ecma_raise_range_error (ECMA_ERR_PROMISE_ALL_REMAINING_ELEMENTS_LIMIT_REACHED); goto exit; } @@ -456,7 +456,7 @@ ecma_builtin_promise_dispatch_call (const ecma_value_t *arguments_list_p, /**< a { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor Promise requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_PROMISE_REQUIRES_NEW); } /* ecma_builtin_promise_dispatch_call */ /** @@ -472,7 +472,7 @@ ecma_builtin_promise_dispatch_construct (const ecma_value_t *arguments_list_p, / if (arguments_list_len == 0 || !ecma_op_is_callable (arguments_list_p[0])) { - return ecma_raise_type_error (ECMA_ERR_MSG ("First parameter must be callable")); + return ecma_raise_type_error (ECMA_ERR_FIRST_PARAMETER_MUST_BE_CALLABLE); } return ecma_op_create_promise_object (arguments_list_p[0], diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-proxy.c b/jerry-core/ecma/builtin-objects/ecma-builtin-proxy.c index 1fe6ac2384..2a2097d34d 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-proxy.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-proxy.c @@ -93,7 +93,7 @@ ecma_builtin_proxy_dispatch_call (const ecma_value_t *arguments_list_p, /**< arg JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); /* 1. */ - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor Proxy requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_PROXY_REQUIRES_NEW); } /* ecma_builtin_proxy_dispatch_call */ /** diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-reflect.c b/jerry-core/ecma/builtin-objects/ecma-builtin-reflect.c index 32c32dc719..056a6b5f61 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-reflect.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-reflect.c @@ -91,7 +91,7 @@ ecma_builtin_reflect_dispatch_routine (uint8_t builtin_routine_id, /**< built-in /* 1. */ if (arguments_number == 0 || !ecma_is_value_object (arguments_list[0])) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_argument_is_not_an_object)); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT); } /* 2. */ @@ -158,7 +158,7 @@ ecma_builtin_reflect_dispatch_routine (uint8_t builtin_routine_id, /**< built-in /* 1. */ if (arguments_number == 0 || !ecma_is_value_object (arguments_list[0])) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_argument_is_not_an_object)); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT); } ecma_object_t *target_p = ecma_get_object_from_value (arguments_list[0]); @@ -182,7 +182,7 @@ ecma_builtin_reflect_dispatch_routine (uint8_t builtin_routine_id, /**< built-in /* 1. */ if (arguments_number < 1 || !ecma_is_constructor (arguments_list[0])) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_target_is_not_a_constructor)); + return ecma_raise_type_error (ECMA_ERR_TARGET_IS_NOT_A_CONSTRUCTOR); } ecma_object_t *target_p = ecma_get_object_from_value (arguments_list[0]); @@ -195,7 +195,7 @@ ecma_builtin_reflect_dispatch_routine (uint8_t builtin_routine_id, /**< built-in /* 3. */ if (!ecma_is_constructor (arguments_list[2])) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_target_is_not_a_constructor)); + return ecma_raise_type_error (ECMA_ERR_TARGET_IS_NOT_A_CONSTRUCTOR); } new_target_p = ecma_get_object_from_value (arguments_list[2]); @@ -204,7 +204,7 @@ ecma_builtin_reflect_dispatch_routine (uint8_t builtin_routine_id, /**< built-in /* 4. */ if (arguments_number < 2) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Reflect.construct expects an object as second argument")); + return ecma_raise_type_error (ECMA_ERR_REFLECT_EXPECTS_AN_OBJECT_AS_SECOND_ARGUMENT); } ecma_collection_t *coll_p = ecma_op_create_list_from_array_like (arguments_list[1], false); @@ -222,7 +222,7 @@ ecma_builtin_reflect_dispatch_routine (uint8_t builtin_routine_id, /**< built-in if (!ecma_is_value_object (arguments_list[0])) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_argument_is_not_an_object)); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT); } switch (builtin_routine_id) @@ -235,7 +235,7 @@ ecma_builtin_reflect_dispatch_routine (uint8_t builtin_routine_id, /**< built-in { if (!ecma_is_value_object (arguments_list[1]) && !ecma_is_value_null (arguments_list[1])) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Prototype is neither object nor null")); + return ecma_raise_type_error (ECMA_ERR_PROTOTYPE_IS_NEITHER_OBJECT_NOR_NULL); } ecma_object_t *obj_p = ecma_get_object_from_value (arguments_list[0]); @@ -258,7 +258,7 @@ ecma_builtin_reflect_dispatch_routine (uint8_t builtin_routine_id, /**< built-in { if (!ecma_op_is_callable (arguments_list[0])) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a function")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_FUNCTION); } ecma_object_t *func_obj_p = ecma_get_object_from_value (arguments_list[0]); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.c index 12b3b08ec5..69fa1e47a8 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.c @@ -261,7 +261,7 @@ ecma_builtin_regexp_prototype_compile (ecma_value_t this_arg, /**< this */ #if !JERRY_ESNEXT if (ecma_get_object_from_value (this_arg) == ecma_builtin_get (ECMA_BUILTIN_ID_REGEXP_PROTOTYPE)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_argument_is_not_an_regexp)); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_IS_NOT_AN_REGEXP); } #endif /* !JERRY_ESNEXT */ @@ -275,7 +275,7 @@ ecma_builtin_regexp_prototype_compile (ecma_value_t this_arg, /**< this */ { if (!ecma_is_value_undefined (flags_arg)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Invalid argument")); + return ecma_raise_type_error (ECMA_ERR_INVALID_ARGUMENT); } ecma_extended_object_t *pattern_obj_p = (ecma_extended_object_t *) ecma_get_object_from_value (pattern_arg); @@ -666,7 +666,7 @@ ecma_builtin_regexp_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< if (obj_p == NULL) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT); } switch (builtin_routine_id) @@ -723,7 +723,7 @@ ecma_builtin_regexp_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< return ecma_make_magic_string_value (LIT_MAGIC_STRING_EMPTY_NON_CAPTURE_GROUP); } - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_argument_is_not_an_regexp)); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_IS_NOT_AN_REGEXP); } ecma_extended_object_t *re_obj_p = (ecma_extended_object_t *) obj_p; @@ -743,7 +743,7 @@ ecma_builtin_regexp_prototype_dispatch_routine (uint8_t builtin_routine_id, /**< return ECMA_VALUE_UNDEFINED; } - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_argument_is_not_an_regexp)); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_IS_NOT_AN_REGEXP); } ecma_extended_object_t *re_obj_p = (ecma_extended_object_t *) obj_p; diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-string-iterator-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-string-iterator-prototype.c index d2d0d56ece..83070766ff 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-string-iterator-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-string-iterator-prototype.c @@ -57,7 +57,7 @@ ecma_builtin_regexp_string_iterator_prototype_object_next (ecma_value_t this_val /* 2. */ if (!ecma_is_value_object (this_val)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT); } ecma_object_t *obj_p = ecma_get_object_from_value (this_val); @@ -65,7 +65,7 @@ ecma_builtin_regexp_string_iterator_prototype_object_next (ecma_value_t this_val /* 3. */ if (!ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_REGEXP_STRING_ITERATOR)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an iterator")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_ITERATOR); } ecma_regexp_string_iterator_t *regexp_string_iterator_obj = (ecma_regexp_string_iterator_t *) obj_p; diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c index e999042940..a2dc4353b0 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c @@ -152,7 +152,7 @@ ecma_builtin_regexp_dispatch_helper (const ecma_value_t *arguments_list_p, /**< return ecma_copy_value (pattern_value); } - return ecma_raise_type_error (ECMA_ERR_MSG ("Invalid argument is passed to RegExp function")); + return ecma_raise_type_error (ECMA_ERR_INVALID_ARGUMENT_IS_PASSED_TO_REGEXP_FUNCTION); } #endif /* JERRY_ESNEXT */ diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-set.c b/jerry-core/ecma/builtin-objects/ecma-builtin-set.c index 8210cc94f5..d875fdafd6 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-set.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-set.c @@ -47,7 +47,7 @@ ecma_builtin_set_dispatch_call (const ecma_value_t *arguments_list_p, /**< argum { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor Set requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_SET_REQUIRES_NEW); } /* ecma_builtin_set_dispatch_call */ /** diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-shared-arraybuffer-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-shared-arraybuffer-prototype.c index dc6fc22f17..321c2c8217 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-shared-arraybuffer-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-shared-arraybuffer-prototype.c @@ -71,7 +71,7 @@ ecma_builtin_shared_arraybuffer_prototype_bytelength_getter (ecma_value_t this_a } } - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a SharedArrayBuffer object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_SHARED_ARRAY_BUFFER); } /* ecma_builtin_shared_arraybuffer_prototype_bytelength_getter */ /** @@ -90,7 +90,7 @@ ecma_builtin_shared_arraybuffer_prototype_object_slice (ecma_value_t this_arg, / { if (!ecma_is_value_object (this_arg)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT); } ecma_object_t *object_p = ecma_get_object_from_value (this_arg); @@ -98,7 +98,7 @@ ecma_builtin_shared_arraybuffer_prototype_object_slice (ecma_value_t this_arg, / /* 2. */ if (!ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_SHARED_ARRAY_BUFFER)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an SharedArrayBuffer object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_SHARED_ARRAY_BUFFER_OBJECT); } return ecma_builtin_arraybuffer_slice (this_arg, argument_list_p, arguments_number); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-shared-arraybuffer.c b/jerry-core/ecma/builtin-objects/ecma-builtin-shared-arraybuffer.c index 473287ec49..38fc8f125d 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-shared-arraybuffer.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-shared-arraybuffer.c @@ -58,7 +58,7 @@ ecma_builtin_shared_arraybuffer_dispatch_call (const ecma_value_t *arguments_lis { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor SharedArrayBuffer requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_SHAREDARRAYBUFFER_REQUIRES_NEW); } /* ecma_builtin_shared_arraybuffer_dispatch_call */ /** diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-string-iterator-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-string-iterator-prototype.c index a939a8886a..c78082395a 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-string-iterator-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-string-iterator-prototype.c @@ -68,7 +68,7 @@ ecma_builtin_string_iterator_prototype_object_next (ecma_value_t this_val) /**< /* 1 - 2. */ if (!ecma_is_value_object (this_val)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT); } ecma_object_t *obj_p = ecma_get_object_from_value (this_val); @@ -77,7 +77,7 @@ ecma_builtin_string_iterator_prototype_object_next (ecma_value_t this_val) /**< /* 3. */ if (!ecma_object_class_is (obj_p, ECMA_OBJECT_CLASS_STRING_ITERATOR)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an iterator")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_ITERATOR); } ecma_value_t iterated_value = ext_obj_p->u.cls.u3.iterated_value; diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c index dafde43ed7..9481fb69fe 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c @@ -142,7 +142,7 @@ ecma_builtin_string_prototype_object_to_string (ecma_value_t this_arg) /**< this } } - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a string or a String object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_STRING_OBJECT); } /* ecma_builtin_string_prototype_object_to_string */ /** @@ -447,7 +447,7 @@ ecma_builtin_string_prototype_object_match_all (ecma_value_t this_argument, /**< if (!(parsed_flag & RE_FLAG_GLOBAL)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("RegExp argument should have global flag")); + return ecma_raise_type_error (ECMA_ERR_REGEXP_ARGUMENT_SHOULD_HAVE_GLOBAL_FLAG); } } @@ -567,7 +567,7 @@ ecma_builtin_string_prototype_object_replace_helper (ecma_value_t this_value, /* if (!have_global_flag) { - return ecma_raise_type_error (ECMA_ERR_MSG ("RegExp argument should have global flag")); + return ecma_raise_type_error (ECMA_ERR_REGEXP_ARGUMENT_SHOULD_HAVE_GLOBAL_FLAG); } } } @@ -1258,7 +1258,7 @@ ecma_builtin_string_prototype_object_repeat (ecma_string_t *original_string_p, / /* 6, 7 */ if (count_number < 0 || (!isNan && ecma_number_is_infinity (count_number))) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid count value")); + return ecma_raise_range_error (ECMA_ERR_INVALID_COUNT_VALUE); } lit_utf8_size_t size = ecma_string_get_size (original_string_p); @@ -1270,7 +1270,7 @@ ecma_builtin_string_prototype_object_repeat (ecma_string_t *original_string_p, / if ((uint32_t) repeat_count >= (ECMA_STRING_SIZE_LIMIT / size)) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid string length")); + return ecma_raise_range_error (ECMA_ERR_INVALID_STRING_); } lit_utf8_size_t total_size = size * (lit_utf8_size_t) repeat_count; diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-string.c b/jerry-core/ecma/builtin-objects/ecma-builtin-string.c index 206889ba56..13207c420d 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-string.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-string.c @@ -305,7 +305,7 @@ ecma_builtin_string_object_from_code_point (const ecma_value_t args[], /**< argu if (!ecma_op_is_integer (to_number_num)) { ecma_stringbuilder_destroy (&builder); - return ecma_raise_range_error ("Error: Invalid code point"); + return ecma_raise_range_error (ECMA_ERR_INVALID_CODE_POINT_ERROR); } ecma_free_value (to_number_value); @@ -313,7 +313,7 @@ ecma_builtin_string_object_from_code_point (const ecma_value_t args[], /**< argu if (to_number_num < 0 || to_number_num > LIT_UNICODE_CODE_POINT_MAX) { ecma_stringbuilder_destroy (&builder); - return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid code point")); + return ecma_raise_range_error (ECMA_ERR_INVALID_CODE_POINT); } lit_code_point_t code_point = (lit_code_point_t) to_number_num; diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-symbol.c b/jerry-core/ecma/builtin-objects/ecma-builtin-symbol.c index 646a4daa86..38c13297bb 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-symbol.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-symbol.c @@ -76,7 +76,7 @@ ecma_builtin_symbol_dispatch_construct (const ecma_value_t *arguments_list_p, /* { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Symbol is not a constructor")); + return ecma_raise_type_error (ECMA_ERR_SYMBOL_IS_NOT_A_CONSTRUCTOR); } /* ecma_builtin_symbol_dispatch_construct */ /** @@ -241,7 +241,7 @@ ecma_builtin_symbol_key_for (ecma_value_t this_arg, /**< this argument */ /* 1. */ if (!ecma_is_value_symbol (symbol)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("The given argument is not a Symbol")); + return ecma_raise_type_error (ECMA_ERR_THE_GIVEN_ARGUMENT_IS_NOT_A_SYMBOL); } /* 2-4. */ diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-type-error-thrower.c b/jerry-core/ecma/builtin-objects/ecma-builtin-type-error-thrower.c index 3e2f9df37b..253a8deb97 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-type-error-thrower.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-type-error-thrower.c @@ -55,8 +55,7 @@ ecma_builtin_type_error_thrower_dispatch_call (const ecma_value_t *arguments_lis { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("'caller', 'callee', and 'arguments' properties may not be accessed" - " on strict mode functions or the arguments objects for calls to them")); + return ecma_raise_type_error (ECMA_ERR_CANNOT_ACCESS_CALLER_CALLE_ARGUMENTS); } /* ecma_builtin_type_error_thrower_dispatch_call */ /** diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-weakmap.c b/jerry-core/ecma/builtin-objects/ecma-builtin-weakmap.c index 76dcfedf36..afc2f66753 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-weakmap.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-weakmap.c @@ -47,7 +47,7 @@ ecma_builtin_weakmap_dispatch_call (const ecma_value_t *arguments_list_p, /**< a { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor WeakMap requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_WEAKMAP_REQUIRES_NEW); } /* ecma_builtin_weakmap_dispatch_call */ /** diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-weakref-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-weakref-prototype.c index be72d0665b..4b4caf26a5 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-weakref-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-weakref-prototype.c @@ -63,7 +63,7 @@ ecma_builtin_weakref_prototype_object_deref (ecma_value_t this_arg) /**< this ar { if (!ecma_is_value_object (this_arg)) { - return ecma_raise_type_error ("Target is not Object"); + return ecma_raise_type_error (ECMA_ERR_TARGET_IS_NOT_OBJECT); } ecma_object_t *object_p = ecma_get_object_from_value (this_arg); @@ -71,7 +71,7 @@ ecma_builtin_weakref_prototype_object_deref (ecma_value_t this_arg) /**< this ar if (!ecma_object_class_is (object_p, ECMA_OBJECT_CLASS_WEAKREF)) { - return ecma_raise_type_error ("Target is not weakRef"); + return ecma_raise_type_error (ECMA_ERR_TARGET_IS_NOT_WEAKREF); } return ecma_copy_value (this_ext_obj->u.cls.u3.target); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-weakref.c b/jerry-core/ecma/builtin-objects/ecma-builtin-weakref.c index 286c76e8fa..bf15aae1c2 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-weakref.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-weakref.c @@ -50,7 +50,7 @@ ecma_builtin_weakref_dispatch_call (const ecma_value_t *arguments_list_p, /**< a { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor WeakRef requires 'new'.")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_WEAKREF_REQUIRES_NEW); } /* ecma_builtin_weakref_dispatch_call */ /** @@ -64,7 +64,7 @@ ecma_builtin_weakref_dispatch_construct (const ecma_value_t *arguments_list_p, / { if (arguments_list_len == 0 || !ecma_is_value_object (arguments_list_p[0])) { - return ecma_raise_type_error (ECMA_ERR_MSG ("WeakRef target must be an object")); + return ecma_raise_type_error (ECMA_ERR_WEAKREF_TARGET_MUST_BE_AN_OBJECT); } JERRY_ASSERT (JERRY_CONTEXT (current_new_target_p) != NULL); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-weakset.c b/jerry-core/ecma/builtin-objects/ecma-builtin-weakset.c index 1bd04ec463..f30c6c25f1 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-weakset.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-weakset.c @@ -47,7 +47,7 @@ ecma_builtin_weakset_dispatch_call (const ecma_value_t *arguments_list_p, /**< a { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor WeakSet requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_WEAKSET_REQUIRES_NEW); } /* ecma_builtin_weakset_dispatch_call */ /** diff --git a/jerry-core/ecma/builtin-objects/ecma-builtins.c b/jerry-core/ecma/builtin-objects/ecma-builtins.c index b2473bef04..b7f4aa45dc 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtins.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtins.c @@ -1592,7 +1592,7 @@ ecma_builtin_dispatch_construct (ecma_object_t *obj_p, /**< built-in object */ if (ecma_builtin_function_is_routine (obj_p)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Built-in routines have no constructor")); + return ecma_raise_type_error (ECMA_ERR_BULTIN_ROUTINES_HAVE_NO_CONSTRUCTOR); } ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p; diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-bigint64array.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-bigint64array.c index 1f8b29f6bc..ae7fc96471 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-bigint64array.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-bigint64array.c @@ -54,7 +54,7 @@ ecma_builtin_bigint64array_dispatch_call (const ecma_value_t *arguments_list_p, { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor BigInt64Array requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_BIGINT64_ARRAY_REQUIRES_NEW); } /* ecma_builtin_bigint64array_dispatch_call */ /** diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-biguint64array.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-biguint64array.c index 214fa716db..2482ec2e5d 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-biguint64array.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-biguint64array.c @@ -54,7 +54,7 @@ ecma_builtin_biguint64array_dispatch_call (const ecma_value_t *arguments_list_p, { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor BigUInt64Array requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_BIG_UINT64_ARRAY_REQUIRES_NEW); } /* ecma_builtin_biguint64array_dispatch_call */ /** diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-float32array.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-float32array.c index b69cc4c046..f4f3959f0d 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-float32array.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-float32array.c @@ -53,7 +53,7 @@ ecma_builtin_float32array_dispatch_call (const ecma_value_t *arguments_list_p, / { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor Float32Array requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_FLOAT32_ARRAY_REQUIRES_NEW); } /* ecma_builtin_float32array_dispatch_call */ /** diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-float64array.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-float64array.c index 997fb5a7b3..fe3cebb874 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-float64array.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-float64array.c @@ -54,7 +54,7 @@ ecma_builtin_float64array_dispatch_call (const ecma_value_t *arguments_list_p, / { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor Float64Array requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_FLOAT64_ARRAY_REQUIRES_NEW); } /* ecma_builtin_float64array_dispatch_call */ /** diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-int16array.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-int16array.c index 6945114a31..076a853b52 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-int16array.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-int16array.c @@ -53,7 +53,7 @@ ecma_builtin_int16array_dispatch_call (const ecma_value_t *arguments_list_p, /** { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor Int16Array requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_INT16_ARRAY_REQUIRES_NEW); } /* ecma_builtin_int16array_dispatch_call */ /** diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-int32array.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-int32array.c index d3d899c1fe..a322a30151 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-int32array.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-int32array.c @@ -53,7 +53,7 @@ ecma_builtin_int32array_dispatch_call (const ecma_value_t *arguments_list_p, /** { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor Int32Array requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_INT32_ARRAY_REQUIRES_NEW); } /* ecma_builtin_int32array_dispatch_call */ /** diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-int8array.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-int8array.c index 87ea168cc8..402e38388e 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-int8array.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-int8array.c @@ -53,7 +53,7 @@ ecma_builtin_int8array_dispatch_call (const ecma_value_t *arguments_list_p, /**< { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor Int8Array requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_INT8_ARRAY_REQUIRES_NEW); } /* ecma_builtin_int8array_dispatch_call */ /** diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c index b93c429c56..52f72fadf0 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-prototype.c @@ -156,7 +156,7 @@ ecma_builtin_typedarray_prototype_exec_routine (ecma_value_t this_arg, /**< this if (ecma_arraybuffer_is_detached (info_p->array_buffer_p)) { ecma_free_value (call_value); - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached)); + return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); } bool to_bool_result = ecma_op_to_boolean (call_value); @@ -263,7 +263,7 @@ ecma_builtin_typedarray_prototype_map (ecma_value_t this_arg, /**< this object * { ecma_free_value (mapped_value); ecma_free_value (new_typedarray); - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached)); + return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); } ecma_value_t set_element = target_typedarray_setter_cb (target_buffer_p, mapped_value); @@ -301,7 +301,7 @@ ecma_builtin_typedarray_prototype_reduce_with_direction (ecma_value_t this_arg, { if (arguments_number < 2) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Initial value cannot be undefined")); + return ecma_raise_type_error (ECMA_ERR_INITIAL_VALUE_CANNOT_BE_UNDEFINED); } return ecma_copy_value (arguments_list_p[1]); @@ -368,7 +368,7 @@ ecma_builtin_typedarray_prototype_reduce_with_direction (ecma_value_t this_arg, if (ecma_arraybuffer_is_detached (info_p->array_buffer_p)) { ecma_free_value (call_value); - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached)); + return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); } accumulator = call_value; @@ -448,7 +448,7 @@ ecma_builtin_typedarray_prototype_filter (ecma_value_t this_arg, /**< this objec { ecma_free_value (call_value); ecma_fast_free_value (get_value); - ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached)); + ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); goto cleanup; } @@ -563,7 +563,7 @@ ecma_op_typedarray_set_with_typedarray (ecma_value_t this_arg, /**< this argumen if (target_offset_num <= -1.0 || target_offset_num >= (ecma_number_t) UINT32_MAX + 0.5) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid offset")); + return ecma_raise_range_error (ECMA_ERR_INVALID_OFFSET); } ecma_object_t *target_typedarray_p = ecma_get_object_from_value (this_arg); @@ -588,7 +588,7 @@ ecma_op_typedarray_set_with_typedarray (ecma_value_t this_arg, /**< this argumen if ((int64_t) src_info.length + target_offset_uint32 > target_info.length) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid range of index")); + return ecma_raise_range_error (ECMA_ERR_INVALID_RANGE_OF_INDEX); } /* Fast path first. If the source and target arrays are the same we do not need to copy anything. */ @@ -663,7 +663,7 @@ ecma_builtin_typedarray_prototype_set (ecma_value_t this_arg, /**< this argument if (target_offset_num <= -1.0 || target_offset_num >= (ecma_number_t) UINT32_MAX + 0.5) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid offset")); + return ecma_raise_range_error (ECMA_ERR_INVALID_OFFSET); } uint32_t target_offset_uint32 = ecma_number_to_uint32 (target_offset_num); @@ -700,7 +700,7 @@ ecma_builtin_typedarray_prototype_set (ecma_value_t this_arg, /**< this argument if ((int64_t) source_length + target_offset_uint32 > target_info.length) { ecma_deref_object (source_obj_p); - return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid range of index")); + return ecma_raise_range_error (ECMA_ERR_INVALID_RANGE_OF_INDEX); } JERRY_ASSERT (source_length <= UINT32_MAX); uint32_t source_length_uint32 = (uint32_t) source_length; @@ -755,7 +755,7 @@ ecma_builtin_typedarray_prototype_set (ecma_value_t this_arg, /**< this argument { ecma_deref_object (source_obj_p); ecma_free_value (value_to_set); - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached)); + return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); } ecma_value_t set_element = target_typedarray_setter_cb (target_buffer_p, value_to_set); @@ -1142,7 +1142,7 @@ ecma_builtin_typedarray_prototype_sort_compare_helper (ecma_value_t lhs, /**< le if (ecma_arraybuffer_is_detached (array_buffer_p)) { ecma_free_value (number_result); - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached)); + return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); } // If the coerced value can't be represented as a Number, compare them as equals. @@ -1214,7 +1214,7 @@ ecma_builtin_typedarray_prototype_sort (ecma_value_t this_arg, /**< this argumen if (ecma_arraybuffer_is_detached (info_p->array_buffer_p)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached)); + return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); } ecma_typedarray_setter_fn_t typedarray_setter_cb = ecma_get_typedarray_setter_fn (info_p->id); @@ -1295,7 +1295,7 @@ ecma_builtin_typedarray_prototype_find_helper (ecma_value_t this_arg, /**< this { ecma_free_value (element_value); ecma_free_value (call_value); - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached)); + return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); } bool call_result = ecma_op_to_boolean (call_value); @@ -1827,7 +1827,7 @@ ecma_builtin_typedarray_prototype_dispatch_routine (uint8_t builtin_routine_id, return ECMA_VALUE_UNDEFINED; } - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a TypedArray")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_TYPED_ARRAY); } ecma_object_t *typedarray_p = ecma_get_object_from_value (this_arg); @@ -1846,7 +1846,7 @@ ecma_builtin_typedarray_prototype_dispatch_routine (uint8_t builtin_routine_id, if (builtin_routine_id < ECMA_TYPEDARRAY_PROTOTYPE_ROUTINE_INDEX_OF && !ecma_op_is_callable (arguments_list_p[0])) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_callback_is_not_callable)); + return ecma_raise_type_error (ECMA_ERR_CALLBACK_IS_NOT_CALLABLE); } switch (builtin_routine_id) @@ -1913,7 +1913,7 @@ ecma_builtin_typedarray_prototype_dispatch_routine (uint8_t builtin_routine_id, { if (!ecma_is_value_undefined (arguments_list_p[0]) && !ecma_op_is_callable (arguments_list_p[0])) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_callback_is_not_callable)); + return ecma_raise_type_error (ECMA_ERR_CALLBACK_IS_NOT_CALLABLE); } return ecma_builtin_typedarray_prototype_sort (this_arg, &info, arguments_list_p[0]); diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray.c index 898492fa84..1aa3ecf6d0 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray.c @@ -61,7 +61,7 @@ ecma_builtin_typedarray_from (ecma_value_t this_arg, /**< 'this' argument */ if (!ecma_is_constructor (this_arg)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a constructor")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_CONSTRUCTOR); } ecma_value_t source; @@ -70,7 +70,7 @@ ecma_builtin_typedarray_from (ecma_value_t this_arg, /**< 'this' argument */ if (arguments_list_len == 0) { - return ecma_raise_type_error (ECMA_ERR_MSG ("No source argument")); + return ecma_raise_type_error (ECMA_ERR_NO_SOURCE_ARGUMENT); } source = arguments_list_p[0]; @@ -81,7 +81,7 @@ ecma_builtin_typedarray_from (ecma_value_t this_arg, /**< 'this' argument */ if (!ecma_op_is_callable (map_fn)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("The 'mapfn' argument is not callable")); + return ecma_raise_type_error (ECMA_ERR_THE_MAPFN_ARGUMENT_IS_NOT_CALLABLE); } if (arguments_list_len > 2) @@ -110,7 +110,7 @@ ecma_builtin_typedarray_of (ecma_value_t this_arg, /**< 'this' argument */ { if (!ecma_is_constructor (this_arg)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a constructor")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_CONSTRUCTOR); } ecma_object_t *constructor_obj_p = ecma_get_object_from_value (this_arg); @@ -166,7 +166,7 @@ ecma_builtin_typedarray_dispatch_call (const ecma_value_t *arguments_list_p, /** { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("TypedArray intrinstic cannot be directly called")); + return ecma_raise_type_error (ECMA_ERR_TYPEDARRAY_INTRINSTIC_DIRECTLY_CALLED); } /* ecma_builtin_typedarray_dispatch_call */ /** @@ -183,7 +183,7 @@ ecma_builtin_typedarray_dispatch_construct (const ecma_value_t *arguments_list_p { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("TypedArray intrinstic cannot be called by a 'new' expression")); + return ecma_raise_type_error (ECMA_ERR_TYPEDARRAY_INTRINSTIC_CALLED_BY_NEW_EXPRESSION); } /* ecma_builtin_typedarray_dispatch_construct */ /** diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint16array.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint16array.c index db0367ddec..18e5c6b390 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint16array.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint16array.c @@ -53,7 +53,7 @@ ecma_builtin_uint16array_dispatch_call (const ecma_value_t *arguments_list_p, /* { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor Uint16Array requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_UINT16_ARRAY_REQUIRES_NEW); } /* ecma_builtin_uint16array_dispatch_call */ /** diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint32array.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint32array.c index 51abd555fd..cb49561579 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint32array.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint32array.c @@ -53,7 +53,7 @@ ecma_builtin_uint32array_dispatch_call (const ecma_value_t *arguments_list_p, /* { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor Uint32Array requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_UINT32_ARRAY_REQUIRES_NEW); } /* ecma_builtin_uint32array_dispatch_call */ /** diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint8array.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint8array.c index d646611c22..5d20b7aad6 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint8array.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint8array.c @@ -53,7 +53,7 @@ ecma_builtin_uint8array_dispatch_call (const ecma_value_t *arguments_list_p, /** { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor Uint8Array requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_UINT8_ARRAY_REQUIRES_NEW); } /* ecma_builtin_uint8array_dispatch_call */ /** diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray.c index f3678f473d..9b348c24cd 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray.c @@ -53,7 +53,7 @@ ecma_builtin_uint8clampedarray_dispatch_call (const ecma_value_t *arguments_list { JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor Uint8ClampedArray requires 'new'")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_UINT8_CLAMPED_ARRAY_REQUIRES_NEW); } /* ecma_builtin_uint8clampedarray_dispatch_call */ /** diff --git a/jerry-core/ecma/operations/ecma-array-object.c b/jerry-core/ecma/operations/ecma-array-object.c index 7ea3e6c68f..0e79351694 100644 --- a/jerry-core/ecma/operations/ecma-array-object.c +++ b/jerry-core/ecma/operations/ecma-array-object.c @@ -172,7 +172,7 @@ ecma_op_new_array_object_from_length (ecma_length_t length) /**< length of the n #if JERRY_ESNEXT if (length > UINT32_MAX) { - ecma_raise_range_error (ECMA_ERR_MSG (ecma_error_invalid_array_length)); + ecma_raise_range_error (ECMA_ERR_INVALID_ARRAY_LENGTH); return NULL; } #endif /* JERRY_ESNEXT */ @@ -757,7 +757,7 @@ ecma_op_array_species_create (ecma_object_t *original_array_p, /**< The object f if (!ecma_is_constructor (constructor)) { ecma_free_value (constructor); - ecma_raise_type_error (ECMA_ERR_MSG ("Invalid species constructor")); + ecma_raise_type_error (ECMA_ERR_INVALID_SPECIES_CONSTRUCTOR); return NULL; } @@ -997,7 +997,7 @@ ecma_op_array_object_set_length (ecma_object_t *object_p, /**< the array object if (((ecma_number_t) new_len_uint32) != new_len_num) { - return ecma_raise_range_error (ECMA_ERR_MSG (ecma_error_invalid_array_length)); + return ecma_raise_range_error (ECMA_ERR_INVALID_ARRAY_LENGTH); } /* Only the writable and data properties can be modified. */ diff --git a/jerry-core/ecma/operations/ecma-arraybuffer-object.c b/jerry-core/ecma/operations/ecma-arraybuffer-object.c index 3457066ca3..2c0f2d7d11 100644 --- a/jerry-core/ecma/operations/ecma-arraybuffer-object.c +++ b/jerry-core/ecma/operations/ecma-arraybuffer-object.c @@ -190,14 +190,14 @@ ecma_arraybuffer_allocate_buffer_throw (ecma_object_t *arraybuffer_p) if (ECMA_ARRAYBUFFER_GET_FLAGS (arraybuffer_p) & ECMA_ARRAYBUFFER_DETACHED) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached)); + return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); } uint8_t *buffer_p = ecma_arraybuffer_allocate_buffer (arraybuffer_p); if (buffer_p == NULL) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Cannot allocate memory for ArrayBuffer")); + return ecma_raise_range_error (ECMA_ERR_ALLOCATE_ARRAY_BUFFER); } return ECMA_VALUE_UNDEFINED; @@ -290,7 +290,7 @@ ecma_op_create_arraybuffer_object (const ecma_value_t *arguments_list_p, /**< li if (length_num <= -1.0 || length_num > (ecma_number_t) maximum_size_in_byte + 0.5) { ecma_deref_object (proto_p); - return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid ArrayBuffer length")); + return ecma_raise_range_error (ECMA_ERR_INVALID_ARRAYBUFFER_LENGTH); } } @@ -491,28 +491,28 @@ ecma_builtin_arraybuffer_slice (ecma_value_t this_arg, const ecma_value_t *argum if (!(ecma_object_class_is (new_arraybuffer_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER) || ecma_object_is_shared_arraybuffer (new_arraybuffer_p))) { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Return value is not an ArrayBuffer object")); + ret_value = ecma_raise_type_error (ECMA_ERR_RETURN_VALUE_IS_NOT_AN_ARRAYBUFFER_OBJECT); goto free_new_arraybuffer; } /* 14-15. */ if (ECMA_ARRAYBUFFER_CHECK_BUFFER_ERROR (new_arraybuffer_p)) { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Returned ArrayBuffer has been detached")); + ret_value = ecma_raise_type_error (ECMA_ERR_RETURNED_ARRAYBUFFER_HAS_BEEN_DETACHED); goto free_new_arraybuffer; } /* 16. */ if (new_arraybuffer == this_arg) { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer subclass returned this from species constructor")); + ret_value = ecma_raise_type_error (ECMA_ERR_ARRAY_BUFFER_RETURNED_THIS_FROM_CONSTRUCTOR); goto free_new_arraybuffer; } /* 17. */ if (ecma_arraybuffer_get_length (new_arraybuffer_p) < new_len) { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Derived ArrayBuffer constructor created a too small buffer")); + ret_value = ecma_raise_type_error (ECMA_ERR_DERIVED_ARRAY_BUFFER_CTOR_BUFFER_TOO_SMALL); goto free_new_arraybuffer; } diff --git a/jerry-core/ecma/operations/ecma-async-generator-object.c b/jerry-core/ecma/operations/ecma-async-generator-object.c index fcb249d93d..f40dc5b17f 100644 --- a/jerry-core/ecma/operations/ecma-async-generator-object.c +++ b/jerry-core/ecma/operations/ecma-async-generator-object.c @@ -17,6 +17,7 @@ #include "ecma-alloc.h" #include "ecma-builtins.h" +#include "ecma-errors.h" #include "ecma-exceptions.h" #include "ecma-function-object.h" #include "ecma-gc.h" @@ -144,7 +145,7 @@ ecma_async_yield_throw (vm_executable_object_t *async_generator_object_p, /**< a if (result == ECMA_VALUE_UNDEFINED) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Iterator 'throw' is not available")); + return ecma_raise_type_error (ECMA_ERR_ITERATOR_THROW_IS_NOT_AVAILABLE); } result = ecma_async_yield_call (result, async_generator_object_p, ECMA_VALUE_EMPTY); @@ -351,7 +352,7 @@ ecma_await_continue (vm_executable_object_t *executable_object_p, /**< executabl if (!ecma_is_value_object (value)) { ecma_free_value (value); - return ecma_raise_type_error (ECMA_ERR_MSG ("Value received by yield* is not object")); + return ecma_raise_type_error (ECMA_ERR_VALUE_RECEIVED_BY_YIELD_IS_NOT_OBJECT); } ecma_object_t *result_obj_p = ecma_get_object_from_value (value); @@ -432,11 +433,11 @@ ecma_await_continue (vm_executable_object_t *executable_object_p, /**< executabl } case ECMA_AWAIT_YIELD_CLOSE: { - const char *msg_p = (ecma_is_value_object (value) ? ECMA_ERR_MSG ("Iterator 'throw' is not available") - : ECMA_ERR_MSG ("Value received by yield* is not object")); + ecma_error_msg_t msg = (ecma_is_value_object (value) ? ECMA_ERR_ITERATOR_THROW_IS_NOT_AVAILABLE + : ECMA_ERR_VALUE_RECEIVED_BY_YIELD_IS_NOT_OBJECT); ecma_free_value (value); - return ecma_raise_type_error (msg_p); + return ecma_raise_type_error (msg); } case ECMA_AWAIT_FOR_CLOSE: { @@ -447,7 +448,7 @@ ecma_await_continue (vm_executable_object_t *executable_object_p, /**< executabl if (!is_value_object && VM_GET_CONTEXT_TYPE (executable_object_p->frame_ctx.stack_top_p[-1]) != VM_CONTEXT_FINALLY_THROW) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Iterator 'return' result is not object")); + return ecma_raise_type_error (ECMA_ERR_ITERATOR_RETURN_RESULT_IS_NOT_OBJECT); } return ECMA_VALUE_EMPTY; } @@ -460,7 +461,7 @@ ecma_await_continue (vm_executable_object_t *executable_object_p, /**< executabl if (!ecma_is_value_object (value)) { ecma_free_value (value); - return ecma_raise_type_error (ECMA_ERR_MSG ("Value received by for-async-of is not object")); + return ecma_raise_type_error (ECMA_ERR_VALUE_RECEIVED_BY_FOR_ASYNC_OF_IS_NOT_OBJECT); } ecma_object_t *result_obj_p = ecma_get_object_from_value (value); diff --git a/jerry-core/ecma/operations/ecma-atomics-object.c b/jerry-core/ecma/operations/ecma-atomics-object.c index 24a156c8ec..25a7349c83 100644 --- a/jerry-core/ecma/operations/ecma-atomics-object.c +++ b/jerry-core/ecma/operations/ecma-atomics-object.c @@ -53,7 +53,7 @@ ecma_validate_shared_integer_typedarray (ecma_value_t typedarray, /**< typedArra /* 2. */ if (!ecma_is_value_object (typedarray)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT); } /* 3-4. */ @@ -65,7 +65,7 @@ ecma_validate_shared_integer_typedarray (ecma_value_t typedarray, /**< typedArra { if (!(target_info.id == ECMA_BIGINT64_ARRAY || target_info.id == ECMA_INT32_ARRAY)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument is not supported")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_NOT_SUPPORTED); } } else @@ -73,7 +73,7 @@ ecma_validate_shared_integer_typedarray (ecma_value_t typedarray, /**< typedArra if (target_info.id == ECMA_UINT8_CLAMPED_ARRAY || target_info.id == ECMA_FLOAT32_ARRAY || target_info.id == ECMA_FLOAT64_ARRAY) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument is not supported")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_NOT_SUPPORTED); } } @@ -85,7 +85,7 @@ ecma_validate_shared_integer_typedarray (ecma_value_t typedarray, /**< typedArra if (!ecma_object_class_is (buffer, ECMA_OBJECT_CLASS_SHARED_ARRAY_BUFFER)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument is not SharedArrayBuffer")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_NOT_SHARED_ARRAY_BUFFER); } return ecma_make_object_value (buffer); @@ -124,7 +124,7 @@ ecma_validate_atomic_access (ecma_value_t typedarray, /**< typedArray argument * /* 5-6. */ if (JERRY_UNLIKELY (access_index >= target_info.length)) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid length")); + return ecma_raise_range_error (ECMA_ERR_INVALID_LENGTH); } return ecma_make_number_value (access_index); diff --git a/jerry-core/ecma/operations/ecma-bigint.c b/jerry-core/ecma/operations/ecma-bigint.c index 66c25843a6..2415a1f3b0 100644 --- a/jerry-core/ecma/operations/ecma-bigint.c +++ b/jerry-core/ecma/operations/ecma-bigint.c @@ -33,7 +33,7 @@ static ecma_value_t ecma_bigint_raise_memory_error (void) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Cannot allocate memory for a BigInt value")); + return ecma_raise_range_error (ECMA_ERR_ALLOCATE_BIGINT_VALUE); } /* ecma_bigint_raise_memory_error */ /** @@ -172,7 +172,7 @@ ecma_bigint_parse_string (const lit_utf8_byte_t *string_p, /**< string represena { return ECMA_VALUE_FALSE; } - return ecma_raise_syntax_error (ECMA_ERR_MSG ("String cannot be converted to BigInt value")); + return ecma_raise_syntax_error (ECMA_ERR_STRING_CANNOT_BE_CONVERTED_TO_BIGINT_VALUE); } result_p = ecma_big_uint_mul_digit (result_p, radix, digit); @@ -239,7 +239,7 @@ ecma_bigint_to_string (ecma_value_t value, /**< BigInt value */ if (JERRY_UNLIKELY (string_buffer_p == NULL)) { - ecma_raise_range_error (ECMA_ERR_MSG ("Cannot allocate memory for a string representation of a BigInt value")); + ecma_raise_range_error (ECMA_ERR_ALLOCATE_BIGINT_STRING); return NULL; } @@ -382,7 +382,7 @@ ecma_bigint_number_to_bigint (ecma_number_t number) /**< ecma number */ { if (ecma_number_is_nan (number) || ecma_number_is_infinity (number)) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Infinity or NaN cannot be converted to BigInt")); + return ecma_raise_range_error (ECMA_ERR_INFINITY_OR_NAN_CANNOT_BE_CONVERTED_TO_BIGINT); } ecma_bigint_digit_t digits[3]; @@ -393,7 +393,7 @@ ecma_bigint_number_to_bigint (ecma_number_t number) /**< ecma number */ if (result & ECMA_BIGINT_NUMBER_TO_DIGITS_HAS_FRACTION) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Only integer numbers can be converted to BigInt")); + return ecma_raise_range_error (ECMA_ERR_ONLY_INTEGER_NUMBERS_CAN_BE_CONVERTED_TO_BIGINT); } uint32_t digits_size = ECMA_BIGINT_NUMBER_TO_DIGITS_GET_DIGITS_SIZE (result); @@ -483,7 +483,7 @@ ecma_bigint_to_bigint (ecma_value_t value, /**< any value */ } else { - result = ecma_raise_type_error (ECMA_ERR_MSG ("Value cannot be converted to BigInt")); + result = ecma_raise_type_error (ECMA_ERR_VALUE_CANNOT_BE_CONVERTED_TO_BIGINT); } if (free_value) @@ -665,7 +665,7 @@ ecma_bigint_get_bigint (ecma_value_t value, /**< any value */ ecma_free_value (default_value); } - return ecma_raise_type_error (ECMA_ERR_MSG ("Cannot convert a BigInt value to a number")); + return ecma_raise_type_error (ECMA_ERR_CONVERT_BIGINT_TO_NUMBER); } /* ecma_bigint_get_bigint */ /** @@ -1306,7 +1306,7 @@ ecma_bigint_div_mod (ecma_value_t left_value, /**< left BigInt value */ if (right_value == ECMA_BIGINT_ZERO) { - return ecma_raise_range_error (ECMA_ERR_MSG ("BigInt division by zero")); + return ecma_raise_range_error (ECMA_ERR_BIGINT_ZERO_DIVISION); } if (left_value == ECMA_BIGINT_ZERO) @@ -1473,7 +1473,7 @@ ecma_bigint_pow (ecma_value_t left_value, /**< left BigInt value */ if (right_p->u.bigint_sign_and_size & ECMA_BIGINT_SIGN) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Negative exponent is not allowed for BigInts")); + return ecma_raise_range_error (ECMA_ERR_NEGATIVE_EXPONENT_IS_NOT_ALLOWED_FOR_BIGINTS); } if (left_value == ECMA_BIGINT_ZERO) diff --git a/jerry-core/ecma/operations/ecma-container-object.c b/jerry-core/ecma/operations/ecma-container-object.c index e049104189..f975c39a92 100644 --- a/jerry-core/ecma/operations/ecma-container-object.c +++ b/jerry-core/ecma/operations/ecma-container-object.c @@ -415,7 +415,7 @@ ecma_op_container_create (const ecma_value_t *arguments_list_p, /**< arguments l if (!ecma_op_is_callable (result)) { ecma_free_value (result); - result = ecma_raise_type_error (ECMA_ERR_MSG ("Function add/set is not callable")); + result = ecma_raise_type_error (ECMA_ERR_FUNCTION_ADD_ORSET_IS_NOT_CALLABLE); goto cleanup_object; } @@ -468,7 +468,7 @@ ecma_op_container_create (const ecma_value_t *arguments_list_p, /**< arguments l if (!ecma_is_value_object (result)) { ecma_free_value (result); - ecma_raise_type_error (ECMA_ERR_MSG ("Iterator value is not an object")); + ecma_raise_type_error (ECMA_ERR_ITERATOR_VALUE_IS_NOT_AN_OBJECT); result = ecma_op_iterator_close (iterator); JERRY_ASSERT (ECMA_IS_VALUE_ERROR (result)); goto cleanup_iterator; @@ -560,7 +560,7 @@ ecma_op_container_get_object (ecma_value_t this_arg, /**< this argument */ "Expected a % object", ecma_make_string_value (ecma_get_magic_string (lit_id))); #else /* !JERRY_ERROR_MESSAGES */ - ecma_raise_type_error (NULL); + ecma_raise_type_error (ECMA_ERR_EMPTY); #endif /* JERRY_ERROR_MESSAGES */ return NULL; @@ -681,7 +681,7 @@ ecma_op_container_set (ecma_extended_object_t *map_object_p, /**< map object */ if ((map_object_p->u.cls.u1.container_flags & ECMA_CONTAINER_FLAGS_WEAK) != 0 && !ecma_is_value_object (key_arg)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Key must be an object")); + return ecma_raise_type_error (ECMA_ERR_KEY_MUST_BE_AN_OBJECT); } ecma_value_t *entry_p = ecma_op_internal_buffer_find (container_p, key_arg, lit_id); @@ -720,7 +720,7 @@ ecma_op_container_foreach (ecma_extended_object_t *map_object_p, /**< map object { if (!ecma_op_is_callable (predicate)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_callback_is_not_callable)); + return ecma_raise_type_error (ECMA_ERR_CALLBACK_IS_NOT_CALLABLE); } JERRY_ASSERT (ecma_is_value_object (predicate)); @@ -972,7 +972,7 @@ ecma_op_container_iterator_next (ecma_value_t this_val, /**< this argument */ { if (!ecma_is_value_object (this_val)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT); } ecma_object_t *obj_p = ecma_get_object_from_value (this_val); @@ -980,7 +980,7 @@ ecma_op_container_iterator_next (ecma_value_t this_val, /**< this argument */ if (!ecma_object_class_is (obj_p, iterator_type)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an iterator")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_ITERATOR); } ecma_value_t iterated_value = ext_obj_p->u.cls.u3.iterated_value; diff --git a/jerry-core/ecma/operations/ecma-conversion.c b/jerry-core/ecma/operations/ecma-conversion.c index 8cc82e0827..661c551491 100644 --- a/jerry-core/ecma/operations/ecma-conversion.c +++ b/jerry-core/ecma/operations/ecma-conversion.c @@ -61,7 +61,7 @@ ecma_op_require_object_coercible (ecma_value_t value) /**< ecma value */ if (ecma_is_value_undefined (value) || ecma_is_value_null (value)) { - ecma_raise_type_error (ECMA_ERR_MSG ("Argument cannot be converted to an object")); + ecma_raise_type_error (ECMA_ERR_ARGUMENT_CANNOT_CONVERT_TO_OBJECT); return false; } @@ -339,7 +339,7 @@ ecma_op_to_numeric (ecma_value_t value, /**< ecma value */ #if JERRY_ESNEXT if (ecma_is_value_symbol (value)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Cannot convert a Symbol value to a number")); + return ecma_raise_type_error (ECMA_ERR_CONVERT_SYMBOL_TO_NUMBER); } #endif /* JERRY_ESNEXT */ @@ -350,7 +350,7 @@ ecma_op_to_numeric (ecma_value_t value, /**< ecma value */ { return ecma_copy_value (value); } - return ecma_raise_type_error (ECMA_ERR_MSG ("Cannot convert a BigInt value to a number")); + return ecma_raise_type_error (ECMA_ERR_CONVERT_BIGINT_TO_NUMBER); } #endif /* JERRY_BUILTIN_BIGINT */ @@ -436,7 +436,7 @@ ecma_op_to_string (ecma_value_t value) /**< ecma value */ #if JERRY_ESNEXT if (ecma_is_value_symbol (value)) { - ecma_raise_type_error (ECMA_ERR_MSG ("Cannot convert a Symbol value to a string")); + ecma_raise_type_error (ECMA_ERR_CONVERT_SYMBOL_TO_STRING); return NULL; } #endif /* JERRY_ESNEXT */ @@ -564,7 +564,7 @@ ecma_op_to_object (ecma_value_t value) /**< ecma value */ { if (ecma_is_value_undefined (value) || ecma_is_value_null (value)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument cannot be converted to an object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_CANNOT_CONVERT_TO_OBJECT); } else { @@ -695,7 +695,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */ /* 1. */ if (!ecma_is_value_object (obj_value)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Expected an object")); + return ecma_raise_type_error (ECMA_ERR_EXPECTED_AN_OBJECT); } ecma_object_t *obj_p = ecma_get_object_from_value (obj_value); @@ -786,7 +786,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */ if (!ecma_op_is_callable (get_prop_value) && !ecma_is_value_undefined (get_prop_value)) { ecma_free_value (get_prop_value); - ret_value = ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_expected_a_function)); + ret_value = ecma_raise_type_error (ECMA_ERR_EXPECTED_A_FUNCTION); goto free_desc; } @@ -822,7 +822,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */ if (!ecma_op_is_callable (set_prop_value) && !ecma_is_value_undefined (set_prop_value)) { ecma_free_value (set_prop_value); - ret_value = ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_expected_a_function)); + ret_value = ecma_raise_type_error (ECMA_ERR_EXPECTED_A_FUNCTION); goto free_desc; } @@ -849,7 +849,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */ if ((prop_desc.flags & (JERRY_PROP_IS_VALUE_DEFINED | JERRY_PROP_IS_WRITABLE_DEFINED)) && (prop_desc.flags & (JERRY_PROP_IS_GET_DEFINED | JERRY_PROP_IS_SET_DEFINED))) { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Accessors cannot be writable")); + ret_value = ecma_raise_type_error (ECMA_ERR_ACCESSOR_WRITABLE); } else { @@ -1035,7 +1035,7 @@ ecma_op_to_index (ecma_value_t value, /**< ecma value */ /* 2.b - 2.d */ if (integer_index < 0.0f || integer_index > ECMA_NUMBER_MAX_SAFE_INTEGER) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid or out-of-range index")); + return ecma_raise_range_error (ECMA_ERR_INVALID_OR_OUT_OF_RANGE_INDEX); } /* 3. */ @@ -1064,7 +1064,7 @@ ecma_op_create_list_from_array_like (ecma_value_t arr, /**< array value */ /* 3. */ if (!ecma_is_value_object (arr)) { - ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_argument_is_not_an_object)); + ecma_raise_type_error (ECMA_ERR_ARGUMENT_IS_NOT_AN_OBJECT); return NULL; } ecma_object_t *obj_p = ecma_get_object_from_value (arr); @@ -1093,7 +1093,7 @@ ecma_op_create_list_from_array_like (ecma_value_t arr, /**< array value */ { ecma_free_value (next); ecma_collection_free (list_ptr); - ecma_raise_type_error (ECMA_ERR_MSG ("Property name is neither Symbol nor string")); + ecma_raise_type_error (ECMA_ERR_PROPERTY_NAME_IS_NEITHER_SYMBOL_NOR_STRING); return NULL; } diff --git a/jerry-core/ecma/operations/ecma-dataview-object.c b/jerry-core/ecma/operations/ecma-dataview-object.c index 06741073a5..1629867b88 100644 --- a/jerry-core/ecma/operations/ecma-dataview-object.c +++ b/jerry-core/ecma/operations/ecma-dataview-object.c @@ -58,7 +58,7 @@ ecma_op_dataview_create (const ecma_value_t *arguments_list_p, /**< arguments li /* 2. */ if (!ecma_is_value_object (buffer)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'buffer' is not an object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_BUFFER_NOT_OBJECT); } ecma_object_t *buffer_p = ecma_get_object_from_value (buffer); @@ -66,7 +66,7 @@ ecma_op_dataview_create (const ecma_value_t *arguments_list_p, /**< arguments li if (!(ecma_object_class_is (buffer_p, ECMA_OBJECT_CLASS_ARRAY_BUFFER) || ecma_object_is_shared_arraybuffer (buffer_p))) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'buffer' is not an ArrayBuffer or SharedArrayBuffer")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_BUFFER_NOT_ARRAY_OR_SHARED_BUFFER); } /* 3. */ @@ -84,7 +84,7 @@ ecma_op_dataview_create (const ecma_value_t *arguments_list_p, /**< arguments li /* 4. */ if (ecma_arraybuffer_is_detached (buffer_p)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached)); + return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); } /* 5. */ @@ -93,7 +93,7 @@ ecma_op_dataview_create (const ecma_value_t *arguments_list_p, /**< arguments li /* 6. */ if (offset > buffer_byte_length) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Start offset is outside the bounds of the buffer")); + return ecma_raise_range_error (ECMA_ERR_START_OFFSET_IS_OUTSIDE_THE_BOUNDS_OF_THE_BUFFER); } /* 7. */ @@ -112,7 +112,7 @@ ecma_op_dataview_create (const ecma_value_t *arguments_list_p, /**< arguments li /* 8.b */ if (offset + byte_length_to_index > buffer_byte_length) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Start offset is outside the bounds of the buffer")); + return ecma_raise_range_error (ECMA_ERR_START_OFFSET_IS_OUTSIDE_THE_BOUNDS_OF_THE_BUFFER); } JERRY_ASSERT (byte_length_to_index <= UINT32_MAX); @@ -136,7 +136,7 @@ ecma_op_dataview_create (const ecma_value_t *arguments_list_p, /**< arguments li if (ecma_arraybuffer_is_detached (buffer_p)) { ecma_deref_object (prototype_obj_p); - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached)); + return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); } /* 9. */ @@ -179,7 +179,7 @@ ecma_op_dataview_get_object (ecma_value_t this_arg) /**< this argument */ } } - ecma_raise_type_error (ECMA_ERR_MSG ("Expected a DataView object")); + ecma_raise_type_error (ECMA_ERR_EXPECTED_A_DATAVIEW_OBJECT); return NULL; } /* ecma_op_dataview_get_object */ @@ -317,7 +317,7 @@ ecma_op_dataview_get_set_view_value (ecma_value_t view, /**< the operation's 'vi if (get_index + element_size > (ecma_number_t) view_size) { ecma_free_value (value_to_set); - return ecma_raise_range_error (ECMA_ERR_MSG ("Start offset is outside the bounds of the buffer")); + return ecma_raise_range_error (ECMA_ERR_START_OFFSET_IS_OUTSIDE_THE_BOUNDS_OF_THE_BUFFER); } if (ECMA_ARRAYBUFFER_CHECK_BUFFER_ERROR (buffer_p)) diff --git a/jerry-core/ecma/operations/ecma-eval.c b/jerry-core/ecma/operations/ecma-eval.c index d28a0d5348..e4a2d73420 100644 --- a/jerry-core/ecma/operations/ecma-eval.c +++ b/jerry-core/ecma/operations/ecma-eval.c @@ -98,7 +98,7 @@ ecma_op_eval_chars_buffer (void *source_p, /**< source code */ JERRY_UNUSED (code_buffer_size); JERRY_UNUSED (parse_opts); - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Source code parsing is disabled")); + return ecma_raise_syntax_error (ECMA_ERR_PARSER_NOT_SUPPORTED); #endif /* JERRY_PARSER */ } /* ecma_op_eval_chars_buffer */ diff --git a/jerry-core/ecma/operations/ecma-exceptions.c b/jerry-core/ecma/operations/ecma-exceptions.c index 3c24240fff..2ba43e3570 100644 --- a/jerry-core/ecma/operations/ecma-exceptions.c +++ b/jerry-core/ecma/operations/ecma-exceptions.c @@ -298,7 +298,7 @@ ecma_get_error_type (ecma_object_t *error_object_p) /**< possible error object * * @return ecma value * Returned value must be freed with ecma_free_value */ -static ecma_value_t +ecma_value_t ecma_raise_standard_error (jerry_error_t error_type, /**< error type */ const lit_utf8_byte_t *msg_p) /**< error message */ { @@ -414,9 +414,9 @@ ecma_raise_standard_error_with_format (jerry_error_t error_type, /**< error type * Returned value must be freed with ecma_free_value */ ecma_value_t -ecma_raise_common_error (const char *msg_p) /**< error message */ +ecma_raise_common_error (ecma_error_msg_t msg) /**< error message */ { - return ecma_raise_standard_error (JERRY_ERROR_COMMON, (const lit_utf8_byte_t *) msg_p); + return ecma_raise_standard_error (JERRY_ERROR_COMMON, ecma_get_error_utf8 (msg)); } /* ecma_raise_common_error */ /** @@ -428,9 +428,9 @@ ecma_raise_common_error (const char *msg_p) /**< error message */ * Returned value must be freed with ecma_free_value */ ecma_value_t -ecma_raise_range_error (const char *msg_p) /**< error message */ +ecma_raise_range_error (ecma_error_msg_t msg) /**< error message */ { - return ecma_raise_standard_error (JERRY_ERROR_RANGE, (const lit_utf8_byte_t *) msg_p); + return ecma_raise_standard_error (JERRY_ERROR_RANGE, ecma_get_error_utf8 (msg)); } /* ecma_raise_range_error */ /** @@ -442,9 +442,9 @@ ecma_raise_range_error (const char *msg_p) /**< error message */ * Returned value must be freed with ecma_free_value */ ecma_value_t -ecma_raise_reference_error (const char *msg_p) /**< error message */ +ecma_raise_reference_error (ecma_error_msg_t msg) /**< error message */ { - return ecma_raise_standard_error (JERRY_ERROR_REFERENCE, (const lit_utf8_byte_t *) msg_p); + return ecma_raise_standard_error (JERRY_ERROR_REFERENCE, ecma_get_error_utf8 (msg)); } /* ecma_raise_reference_error */ /** @@ -456,9 +456,9 @@ ecma_raise_reference_error (const char *msg_p) /**< error message */ * Returned value must be freed with ecma_free_value */ ecma_value_t -ecma_raise_syntax_error (const char *msg_p) /**< error message */ +ecma_raise_syntax_error (ecma_error_msg_t msg) /**< error message */ { - return ecma_raise_standard_error (JERRY_ERROR_SYNTAX, (const lit_utf8_byte_t *) msg_p); + return ecma_raise_standard_error (JERRY_ERROR_SYNTAX, ecma_get_error_utf8 (msg)); } /* ecma_raise_syntax_error */ /** @@ -470,9 +470,9 @@ ecma_raise_syntax_error (const char *msg_p) /**< error message */ * Returned value must be freed with ecma_free_value */ ecma_value_t -ecma_raise_type_error (const char *msg_p) /**< error message */ +ecma_raise_type_error (ecma_error_msg_t msg) /**< error message */ { - return ecma_raise_standard_error (JERRY_ERROR_TYPE, (const lit_utf8_byte_t *) msg_p); + return ecma_raise_standard_error (JERRY_ERROR_TYPE, ecma_get_error_utf8 (msg)); } /* ecma_raise_type_error */ /** @@ -484,11 +484,25 @@ ecma_raise_type_error (const char *msg_p) /**< error message */ * Returned value must be freed with ecma_free_value */ ecma_value_t -ecma_raise_uri_error (const char *msg_p) /**< error message */ +ecma_raise_uri_error (ecma_error_msg_t msg) /**< error message */ { - return ecma_raise_standard_error (JERRY_ERROR_URI, (const lit_utf8_byte_t *) msg_p); + return ecma_raise_standard_error (JERRY_ERROR_URI, ecma_get_error_utf8 (msg)); } /* ecma_raise_uri_error */ +#if (JERRY_STACK_LIMIT != 0) +/** + * Raise a RangeError with "Maximum call stack size exceeded" message. + * + * @return ecma value + * Returned value must be freed with ecma_free_value + */ +ecma_value_t +ecma_raise_maximum_callstack_error (void) +{ + return ecma_raise_range_error (ECMA_ERR_MAXIMUM_CALL_STACK_SIZE_EXCEEDED); +} /* ecma_raise_maximum_callstack_error */ +#endif /* (JERRY_STACK_LIMIT != 0) */ + #if JERRY_ESNEXT /** diff --git a/jerry-core/ecma/operations/ecma-exceptions.h b/jerry-core/ecma/operations/ecma-exceptions.h index f8e525e3cb..f3fe4198af 100644 --- a/jerry-core/ecma/operations/ecma-exceptions.h +++ b/jerry-core/ecma/operations/ecma-exceptions.h @@ -27,23 +27,21 @@ * @{ */ -#if JERRY_ERROR_MESSAGES -#define ECMA_ERR_MSG(msg) msg -#else /* !JERRY_ERROR_MESSAGES */ -#define ECMA_ERR_MSG(msg) NULL -#endif /* JERRY_ERROR_MESSAGES */ - jerry_error_t ecma_get_error_type (ecma_object_t *error_object_p); ecma_object_t *ecma_new_standard_error (jerry_error_t error_type, ecma_string_t *message_string_p); #if JERRY_ERROR_MESSAGES ecma_value_t ecma_raise_standard_error_with_format (jerry_error_t error_type, const char *msg_p, ...); #endif /* JERRY_ERROR_MESSAGES */ -ecma_value_t ecma_raise_common_error (const char *msg_p); -ecma_value_t ecma_raise_range_error (const char *msg_p); -ecma_value_t ecma_raise_reference_error (const char *msg_p); -ecma_value_t ecma_raise_syntax_error (const char *msg_p); -ecma_value_t ecma_raise_type_error (const char *msg_p); -ecma_value_t ecma_raise_uri_error (const char *msg_p); +ecma_value_t ecma_raise_standard_error (jerry_error_t error_type, const lit_utf8_byte_t *msg_p); +ecma_value_t ecma_raise_common_error (ecma_error_msg_t msg); +ecma_value_t ecma_raise_range_error (ecma_error_msg_t msg); +ecma_value_t ecma_raise_reference_error (ecma_error_msg_t msg); +ecma_value_t ecma_raise_syntax_error (ecma_error_msg_t msg); +ecma_value_t ecma_raise_type_error (ecma_error_msg_t msg); +ecma_value_t ecma_raise_uri_error (ecma_error_msg_t msg); +#if (JERRY_STACK_LIMIT != 0) +ecma_value_t ecma_raise_maximum_callstack_error (void); +#endif /* (JERRY_STACK_LIMIT != 0) */ #if JERRY_ESNEXT ecma_value_t ecma_new_aggregate_error (ecma_value_t error_list_val, ecma_value_t message_val); ecma_value_t ecma_raise_aggregate_error (ecma_value_t error_list_val, ecma_value_t message_val); diff --git a/jerry-core/ecma/operations/ecma-function-object.c b/jerry-core/ecma/operations/ecma-function-object.c index befad242c3..361d47e213 100644 --- a/jerry-core/ecma/operations/ecma-function-object.c +++ b/jerry-core/ecma/operations/ecma-function-object.c @@ -18,6 +18,7 @@ #include "ecma-alloc.h" #include "ecma-builtin-handlers.h" #include "ecma-builtin-helpers.h" +#include "ecma-errors.h" #include "ecma-exceptions.h" #include "ecma-extended-info.h" #include "ecma-gc.h" @@ -153,9 +154,9 @@ ecma_op_is_callable (ecma_value_t value) /**< ecma value */ * * * @return ECMA_IS_VALID_CONSTRUCTOR - if object is a valid for constructor call - * any other value - if object is not a valid constructor, the pointer contains the error message. + * ecma_error_msg_t id of error - otherwise */ -char * +ecma_error_msg_t ecma_object_check_constructor (ecma_object_t *obj_p) /**< ecma object */ { JERRY_ASSERT (!ecma_is_lexical_environment (obj_p)); @@ -164,7 +165,7 @@ ecma_object_check_constructor (ecma_object_t *obj_p) /**< ecma object */ if (JERRY_UNLIKELY (type < ECMA_OBJECT_TYPE_PROXY)) { - return ECMA_ERR_MSG ("Invalid type for constructor call"); + return ECMA_ERR_INVALID_TYPE_FOR_CONSTRUCTOR_CALL; } while (JERRY_UNLIKELY (type == ECMA_OBJECT_TYPE_BOUND_FUNCTION)) @@ -189,40 +190,40 @@ ecma_object_check_constructor (ecma_object_t *obj_p) /**< ecma object */ { case CBC_FUNCTION_SCRIPT: { - return "Script (global) functions cannot be invoked with 'new'"; + return ECMA_ERR_SCRIPT_GLOBAL_FUNCTIONS_INVOKE_WITH_NEW; } case CBC_FUNCTION_GENERATOR: { - return "Generator functions cannot be invoked with 'new'"; + return ECMA_ERR_GENERATOR_FUNCTIONS_INVOKE_WITH_NEW; } case CBC_FUNCTION_ASYNC: { - return "Async functions cannot be invoked with 'new'"; + return ECMA_ERR_ASYNC_FUNCTIONS_INVOKE_WITH_NEW; } case CBC_FUNCTION_ASYNC_GENERATOR: { - return "Async generator functions cannot be invoked with 'new'"; + return ECMA_ERR_ASYNC_GENERATOR_FUNCTIONS_INVOKE_WITH_NEW; } case CBC_FUNCTION_ACCESSOR: { - return "Accessor functions cannot be invoked with 'new'"; + return ECMA_ERR_ACCESSOR_FUNCTIONS_INVOKE_WITH_NEW; } case CBC_FUNCTION_METHOD: { - return "Methods cannot be invoked with 'new'"; + return ECMA_ERR_METHODS_INVOKE_WITH_NEW; } case CBC_FUNCTION_ARROW: { - return "Arrow functions cannot be invoked with 'new'"; + return ECMA_ERR_ARROW_FUNCTIONS_INVOKE_WITH_NEW; } default: { JERRY_ASSERT (CBC_FUNCTION_GET_TYPE (byte_code_p->status_flags) == CBC_FUNCTION_ASYNC_ARROW); - return "Async arrow functions cannot be invoked with 'new'"; + return ECMA_ERR_ASYNC_ARROW_FUNCTIONS_INVOKE_WITH_NEW; } } #else /* !JERRY_ERROR_MESSAGES */ - return NULL; + return ECMA_ERR_EMPTY; #endif /* JERRY_ERROR_MESSAGES */ } #endif /* JERRY_NEXT */ @@ -235,7 +236,7 @@ ecma_object_check_constructor (ecma_object_t *obj_p) /**< ecma object */ { if (!(obj_p->u2.prototype_cp & ECMA_PROXY_IS_CONSTRUCTABLE)) { - return ECMA_ERR_MSG ("Proxy target is not a constructor"); + return ECMA_ERR_PROXY_TARGET_IS_NOT_A_CONSTRUCTOR; } return ECMA_IS_VALID_CONSTRUCTOR; @@ -249,7 +250,7 @@ ecma_object_check_constructor (ecma_object_t *obj_p) /**< ecma object */ { if (ecma_builtin_function_is_routine (obj_p)) { - return ECMA_ERR_MSG ("Built-in routines have no constructor"); + return ECMA_ERR_BULTIN_ROUTINES_HAVE_NO_CONSTRUCTOR; } #if JERRY_ESNEXT @@ -264,14 +265,14 @@ ecma_object_check_constructor (ecma_object_t *obj_p) /**< ecma object */ * Implement IsConstructor abstract operation. * * @return ECMA_IS_VALID_CONSTRUCTOR - if the input value is a constructor. - * any other value - if the input value is not a valid constructor, the pointer contains the error message. + * ecma_error_msg_t id of error - otherwise */ -extern inline char *JERRY_ATTR_ALWAYS_INLINE +extern inline ecma_error_msg_t JERRY_ATTR_ALWAYS_INLINE ecma_check_constructor (ecma_value_t value) /**< ecma object */ { if (!ecma_is_value_object (value)) { - return ECMA_ERR_MSG ("Invalid type for constructor call"); + return ECMA_ERR_INVALID_TYPE_FOR_CONSTRUCTOR_CALL; } return ecma_object_check_constructor (ecma_get_object_from_value (value)); @@ -824,7 +825,7 @@ ecma_op_function_get_function_realm (ecma_object_t *func_obj_p) /**< function ob ecma_proxy_object_t *proxy_obj_p = (ecma_proxy_object_t *) func_obj_p; if (ecma_is_value_null (proxy_obj_p->handler)) { - ecma_raise_type_error (ECMA_ERR_MSG ("Prototype from revoked Proxy is invalid")); + ecma_raise_type_error (ECMA_ERR_PROTOTYPE_FROM_REVOKED_PROXY_IS_INVALID); return NULL; } func_obj_p = ecma_get_object_from_value (proxy_obj_p->target); @@ -888,7 +889,7 @@ ecma_op_function_has_instance (ecma_object_t *func_obj_p, /**< Function object * if (!ecma_is_value_object (prototype_obj_value)) { ecma_free_value (prototype_obj_value); - return ecma_raise_type_error (ECMA_ERR_MSG ("Object expected")); + return ecma_raise_type_error (ECMA_ERR_OBJECT_EXPECTED); } ecma_object_t *prototype_obj_p = ecma_get_object_from_value (prototype_obj_value); @@ -959,7 +960,7 @@ ecma_op_function_get_super_constructor (ecma_object_t *func_obj_p) /**< function { ecma_deref_object (super_ctor_p); } - return ecma_raise_type_error (ECMA_ERR_MSG ("Super binding must be a constructor")); + return ecma_raise_type_error (ECMA_ERR_SUPER_BINDING_MUST_BE_A_CONSTRUCTOR); } return ecma_make_object_value (super_ctor_p); @@ -1002,7 +1003,7 @@ ecma_op_get_prototype_from_constructor (ecma_object_t *ctor_obj_p, /**< construc ecma_proxy_object_t *proxy_obj_p = (ecma_proxy_object_t *) ctor_obj_p; if (ecma_is_value_null (proxy_obj_p->handler)) { - ecma_raise_type_error (ECMA_ERR_MSG ("Prototype from revoked Proxy is invalid")); + ecma_raise_type_error (ECMA_ERR_PROTOTYPE_FROM_REVOKED_PROXY_IS_INVALID); return NULL; } } @@ -1042,7 +1043,7 @@ ecma_op_function_call_constructor (vm_frame_ctx_shared_args_t *shared_args_p, /* if (JERRY_CONTEXT (current_new_target_p) == NULL) { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Class constructor requires 'new'")); + ret_value = ecma_raise_type_error (ECMA_ERR_CLASS_CONSTRUCTOR_REQUIRES_NEW); goto exit; } @@ -1073,7 +1074,7 @@ ecma_op_function_call_constructor (vm_frame_ctx_shared_args_t *shared_args_p, /* if (!ecma_is_value_undefined (ret_value)) { ecma_free_value (ret_value); - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Derived constructors may only return object or undefined")); + ret_value = ecma_raise_type_error (ECMA_ERR_DERIVED_CTOR_RETURN_NOR_OBJECT_OR_UNDEFINED); } else { @@ -1395,7 +1396,7 @@ ecma_op_function_validated_call (ecma_value_t callee, /**< callee */ { if (!ecma_is_value_object (callee)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_expected_a_function)); + return ecma_raise_type_error (ECMA_ERR_EXPECTED_A_FUNCTION); } return ecma_op_function_call (ecma_get_object_from_value (callee), @@ -1453,7 +1454,7 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */ #if JERRY_ESNEXT case ECMA_OBJECT_TYPE_CONSTRUCTOR_FUNCTION: { - result = ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_class_constructor_new)); + result = ecma_raise_type_error (ECMA_ERR_CLASS_CONSTRUCTOR_NEW); break; } #endif /* JERRY_ESNEXT */ @@ -1469,7 +1470,7 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */ } default: { - result = ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_expected_a_function)); + result = ecma_raise_type_error (ECMA_ERR_EXPECTED_A_FUNCTION); break; } } diff --git a/jerry-core/ecma/operations/ecma-function-object.h b/jerry-core/ecma/operations/ecma-function-object.h index 1531d85e80..3f9c602d2b 100644 --- a/jerry-core/ecma/operations/ecma-function-object.h +++ b/jerry-core/ecma/operations/ecma-function-object.h @@ -46,10 +46,9 @@ bool ecma_object_is_constructor (ecma_object_t *obj_p); * * Use after the ecma_*_check_constructor calls. */ -#define ECMA_IS_VALID_CONSTRUCTOR ((char *) 0x1) -char *ecma_object_check_constructor (ecma_object_t *obj_p); -char *ecma_check_constructor (ecma_value_t value); +ecma_error_msg_t ecma_object_check_constructor (ecma_object_t *obj_p); +ecma_error_msg_t ecma_check_constructor (ecma_value_t value); ecma_object_t *ecma_op_create_simple_function_object (ecma_object_t *scope_p, const ecma_compiled_code_t *bytecode_data_p); diff --git a/jerry-core/ecma/operations/ecma-get-put-value.c b/jerry-core/ecma/operations/ecma-get-put-value.c index 86dbc81bad..964c39efbb 100644 --- a/jerry-core/ecma/operations/ecma-get-put-value.c +++ b/jerry-core/ecma/operations/ecma-get-put-value.c @@ -65,7 +65,7 @@ ecma_op_get_value_lex_env_base (ecma_object_t *lex_env_p, /**< lexical environme #if JERRY_ESNEXT if (JERRY_UNLIKELY (property_value_p->value == ECMA_VALUE_UNINITIALIZED)) { - return ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_let_const_not_initialized)); + return ecma_raise_reference_error (ECMA_ERR_LET_CONST_NOT_INITIALIZED); } #endif /* JERRY_ESNEXT */ @@ -93,7 +93,7 @@ ecma_op_get_value_lex_env_base (ecma_object_t *lex_env_p, /**< lexical environme if (JERRY_UNLIKELY (property_value_p->value == ECMA_VALUE_UNINITIALIZED)) { - return ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_let_const_not_initialized)); + return ecma_raise_reference_error (ECMA_ERR_LET_CONST_NOT_INITIALIZED); } return ecma_fast_copy_value (property_value_p->value); @@ -134,7 +134,7 @@ ecma_op_get_value_lex_env_base (ecma_object_t *lex_env_p, /**< lexical environme "% is not defined", ecma_make_string_value (name_p)); #else /* JERRY_ERROR_MESSAGES */ - return ecma_raise_reference_error (NULL); + return ecma_raise_reference_error (ECMA_ERR_EMPTY); #endif /* JERRY_ERROR_MESSAGES */ } /* ecma_op_get_value_lex_env_base */ @@ -322,7 +322,7 @@ ecma_op_put_value_lex_env_base (ecma_object_t *lex_env_p, /**< lexical environme "% is not defined", ecma_make_string_value (name_p)); #else /* !JERRY_ERROR_MESSAGES */ - return ecma_raise_reference_error (NULL); + return ecma_raise_reference_error (ECMA_ERR_EMPTY); #endif /* JERRY_ERROR_MESSAGES */ } diff --git a/jerry-core/ecma/operations/ecma-iterator-object.c b/jerry-core/ecma/operations/ecma-iterator-object.c index a40c9e02e2..943df3e6a6 100644 --- a/jerry-core/ecma/operations/ecma-iterator-object.c +++ b/jerry-core/ecma/operations/ecma-iterator-object.c @@ -259,7 +259,7 @@ ecma_op_get_iterator (ecma_value_t value, /**< value to get iterator from */ if (!ecma_is_value_object (iterator)) { ecma_free_value (iterator); - return ecma_raise_type_error (ECMA_ERR_MSG ("Iterator is not an object")); + return ecma_raise_type_error (ECMA_ERR_ITERATOR_IS_NOT_AN_OBJECT); } ecma_object_t *obj_p = ecma_get_object_from_value (iterator); @@ -305,7 +305,7 @@ ecma_op_iterator_next (ecma_value_t iterator, /**< iterator value */ /* 1 - 2. */ if (next_method == ECMA_VALUE_UNDEFINED) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Iterator 'next' is not callable")); + return ecma_raise_type_error (ECMA_ERR_ITERATOR_NEXT_IS_NOT_CALLABLE); } ecma_object_t *next_method_obj_p = ecma_get_object_from_value (next_method); @@ -391,7 +391,7 @@ ecma_op_iterator_throw (ecma_value_t iterator, /**< iterator value */ } ecma_free_value (result); - return ecma_raise_type_error (ECMA_ERR_MSG ("Iterator 'throw' is not available")); + return ecma_raise_type_error (ECMA_ERR_ITERATOR_THROW_IS_NOT_AVAILABLE); } ecma_value_t result = ecma_op_function_validated_call (func_throw, iterator, &value, 1); @@ -530,7 +530,7 @@ ecma_op_iterator_close (ecma_value_t iterator) /**< iterator value */ if (!is_object) { ecma_free_value (completion); - return ecma_raise_type_error (ECMA_ERR_MSG ("method 'return' is not callable")); + return ecma_raise_type_error (ECMA_ERR_METHOD_RETURN_IS_NOT_CALLABLE); } /* 10. */ @@ -570,7 +570,7 @@ ecma_op_iterator_step (ecma_value_t iterator, /**< iterator value */ if (!ecma_is_value_object (result)) { ecma_free_value (result); - return ecma_raise_type_error (ECMA_ERR_MSG ("Iterator result is not an object")); + return ecma_raise_type_error (ECMA_ERR_ITERATOR_RESULT_IS_NOT_AN_OBJECT); } /* 3. */ @@ -638,7 +638,7 @@ ecma_op_iterator_do (ecma_iterator_command_type_t command, /**< command to be ex if (!ecma_is_value_object (result)) { ecma_free_value (result); - return ecma_raise_type_error (ECMA_ERR_MSG ("Iterator result is not an object")); + return ecma_raise_type_error (ECMA_ERR_ITERATOR_RESULT_IS_NOT_AN_OBJECT); } ecma_object_t *obj_p = ecma_get_object_from_value (result); diff --git a/jerry-core/ecma/operations/ecma-lex-env.c b/jerry-core/ecma/operations/ecma-lex-env.c index 804822bcbc..d081d3b7a8 100644 --- a/jerry-core/ecma/operations/ecma-lex-env.c +++ b/jerry-core/ecma/operations/ecma-lex-env.c @@ -110,18 +110,18 @@ ecma_op_raise_set_binding_error (ecma_property_t *property_p, /**< property */ if (JERRY_UNLIKELY (property_value_p->value == ECMA_VALUE_UNINITIALIZED)) { - return ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_let_const_not_initialized)); + return ecma_raise_reference_error (ECMA_ERR_LET_CONST_NOT_INITIALIZED); } JERRY_ASSERT (!ecma_is_property_writable (*property_p)); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constant bindings cannot be reassigned")); + return ecma_raise_type_error (ECMA_ERR_CONSTANT_BINDINGS_CANNOT_BE_REASSIGNED); } #endif /* JERRY_ESNEXT */ if (is_strict) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Binding cannot be set")); + return ecma_raise_type_error (ECMA_ERR_BINDING_CANNOT_SET); } return ECMA_VALUE_EMPTY; } /* ecma_op_raise_set_binding_error */ @@ -387,7 +387,7 @@ ecma_op_get_binding_value (ecma_object_t *lex_env_p, /**< lexical environment */ { if (is_strict) { - result = ecma_raise_reference_error (ECMA_ERR_MSG ("Binding does not exist or is uninitialised")); + result = ecma_raise_reference_error (ECMA_ERR_BINDING_NOT_EXIST_OR_UNINITIALIZED); } else { @@ -636,8 +636,7 @@ ecma_op_get_this_binding (ecma_object_t *lex_env_p) /**< lexical environment */ if (this_value == ECMA_VALUE_UNINITIALIZED) { - return ecma_raise_reference_error (ECMA_ERR_MSG ("Must call super constructor in derived class before " - "accessing 'this' or returning from it")); + return ecma_raise_reference_error (ECMA_ERR_CALL_SUPER_CONSTRUCTOR_DERIVED_CLASS_BEFORE_THIS); } ecma_ref_object (ecma_get_object_from_value (this_value)); diff --git a/jerry-core/ecma/operations/ecma-objects-general.c b/jerry-core/ecma/operations/ecma-objects-general.c index 438bfd7551..a6c8f03633 100644 --- a/jerry-core/ecma/operations/ecma-objects-general.c +++ b/jerry-core/ecma/operations/ecma-objects-general.c @@ -112,7 +112,7 @@ ecma_op_general_object_delete (ecma_object_t *obj_p, /**< the object */ /* 4. */ if (is_throw) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Expected a configurable property")); + return ecma_raise_type_error (ECMA_ERR_EXPECTED_A_CONFIGURABLE_PROPERTY); } /* 5. */ @@ -258,7 +258,7 @@ ecma_op_general_object_default_value (ecma_object_t *obj_p, /**< the object */ ecma_free_value (result); - return ecma_raise_type_error (ECMA_ERR_MSG ("Result of [[DefaultValue]] is invalid")); + return ecma_raise_type_error (ECMA_ERR_RESULT_OF_DEFAULTVALUE_IS_INVALID); } ecma_free_value (exotic_to_prim); @@ -330,7 +330,7 @@ ecma_op_general_object_ordinary_value (ecma_object_t *obj_p, /**< the object */ ecma_free_value (call_completion); } - return ecma_raise_type_error (ECMA_ERR_MSG ("Result of [[DefaultValue]] is invalid")); + return ecma_raise_type_error (ECMA_ERR_RESULT_OF_DEFAULTVALUE_IS_INVALID); } /* ecma_op_general_object_ordinary_value */ /** @@ -475,7 +475,7 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob { if (JERRY_UNLIKELY (ext_property_ref.property_ref.virtual_value == ECMA_VALUE_UNINITIALIZED)) { - return ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_let_const_not_initialized)); + return ecma_raise_reference_error (ECMA_ERR_LET_CONST_NOT_INITIALIZED); } if (property_desc_p->flags & JERRY_PROP_IS_WRITABLE_DEFINED) diff --git a/jerry-core/ecma/operations/ecma-objects.c b/jerry-core/ecma/operations/ecma-objects.c index 730ddbe84c..a3843f82e8 100644 --- a/jerry-core/ecma/operations/ecma-objects.c +++ b/jerry-core/ecma/operations/ecma-objects.c @@ -614,7 +614,7 @@ ecma_op_object_find_own (ecma_value_t base_value, /**< base value */ if (JERRY_UNLIKELY (prop_value_p->value == ECMA_VALUE_UNINITIALIZED)) { - return ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_let_const_not_initialized)); + return ecma_raise_reference_error (ECMA_ERR_LET_CONST_NOT_INITIALIZED); } } @@ -1096,7 +1096,7 @@ ecma_op_get_method (ecma_value_t value, /**< ecma value */ if (!ecma_op_is_callable (func)) { ecma_free_value (func); - return ecma_raise_type_error (ECMA_ERR_MSG ("Iterator is not callable")); + return ecma_raise_type_error (ECMA_ERR_ITERATOR_IS_NOT_CALLABLE); } /* 6. */ @@ -1219,7 +1219,7 @@ ecma_op_object_put_apply_receiver (ecma_value_t receiver, /**< receiver */ /* 5.b */ if (!ecma_is_value_object (receiver)) { - return ECMA_REJECT (is_throw, "Receiver must be an object"); + return ECMA_REJECT (is_throw, ECMA_ERR_RECEIVER_MUST_BE_AN_OBJECT); } ecma_object_t *receiver_obj_p = ecma_get_object_from_value (receiver); @@ -1257,7 +1257,7 @@ ecma_op_object_put_apply_receiver (ecma_value_t receiver, /**< receiver */ if (JERRY_UNLIKELY (ecma_is_value_false (result))) { - result = ECMA_REJECT (is_throw, "Proxy trap returned falsish"); + result = ECMA_REJECT (is_throw, ECMA_ERR_PROXY_TRAP_RETURNED_FALSISH); } } @@ -1279,7 +1279,7 @@ ecma_op_object_put_apply_receiver (ecma_value_t receiver, /**< receiver */ if (JERRY_UNLIKELY (ecma_is_value_false (ret_value))) { - ret_value = ECMA_REJECT (is_throw, "Proxy trap returned falsish"); + ret_value = ECMA_REJECT (is_throw, ECMA_ERR_PROXY_TRAP_RETURNED_FALSISH); } return ret_value; @@ -1906,7 +1906,7 @@ ecma_op_object_get_own_property_descriptor (ecma_object_t *object_p, /**< the ob #if JERRY_MODULE_SYSTEM if (JERRY_UNLIKELY (property_ref.virtual_value == ECMA_VALUE_UNINITIALIZED)) { - return ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_let_const_not_initialized)); + return ecma_raise_reference_error (ECMA_ERR_LET_CONST_NOT_INITIALIZED); } #endif /* JERRY_MODULE_SYSTEM */ prop_desc_p->value = property_ref.virtual_value; @@ -1990,7 +1990,7 @@ ecma_op_object_has_instance (ecma_object_t *obj_p, /**< the object */ return ecma_op_function_has_instance (obj_p, value); } - return ecma_raise_type_error (ECMA_ERR_MSG ("Expected a function object")); + return ecma_raise_type_error (ECMA_ERR_EXPECTED_A_FUNCTION_OBJECT); } /* ecma_op_object_has_instance */ /** @@ -3131,7 +3131,7 @@ ecma_op_species_constructor (ecma_object_t *this_value, /**< This Value */ if (!ecma_is_value_object (constructor)) { ecma_free_value (constructor); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructor must be an object")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTOR_NOT_AN_OBJECT); } ecma_object_t *ctor_object_p = ecma_get_object_from_value (constructor); @@ -3152,7 +3152,7 @@ ecma_op_species_constructor (ecma_object_t *this_value, /**< This Value */ if (!ecma_is_constructor (species)) { ecma_free_value (species); - return ecma_raise_type_error (ECMA_ERR_MSG ("Species must be a constructor")); + return ecma_raise_type_error (ECMA_ERR_SPECIES_MUST_BE_A_CONSTRUCTOR); } return species; diff --git a/jerry-core/ecma/operations/ecma-objects.h b/jerry-core/ecma/operations/ecma-objects.h index c4382cb21f..e148b4db45 100644 --- a/jerry-core/ecma/operations/ecma-objects.h +++ b/jerry-core/ecma/operations/ecma-objects.h @@ -47,7 +47,7 @@ /** * Reject with TypeError depending on is_throw flags wit the given message */ -#define ECMA_REJECT(is_throw, msg) ((is_throw) ? ecma_raise_type_error (NULL) : ECMA_VALUE_FALSE) +#define ECMA_REJECT(is_throw, msg) ((is_throw) ? ecma_raise_type_error (ECMA_ERR_EMPTY) : ECMA_VALUE_FALSE) #endif /* JERRY_ERROR_MESSAGES */ ecma_value_t ecma_raise_property_redefinition (ecma_string_t *property_name_p, uint16_t flags); diff --git a/jerry-core/ecma/operations/ecma-promise-object.c b/jerry-core/ecma/operations/ecma-promise-object.c index e23112ce75..b2edf51f92 100644 --- a/jerry-core/ecma/operations/ecma-promise-object.c +++ b/jerry-core/ecma/operations/ecma-promise-object.c @@ -250,7 +250,7 @@ ecma_fulfill_promise (ecma_value_t promise, /**< promise */ if (promise == value) { - ecma_raise_type_error (ECMA_ERR_MSG ("A promise cannot be resolved with itself")); + ecma_raise_type_error (ECMA_ERR_PROMISE_RESOLVE_ITSELF); ecma_value_t exception = jcontext_take_exception (); ecma_reject_promise (promise, exception); ecma_free_value (exception); @@ -699,13 +699,13 @@ ecma_op_get_capabilities_executor_cb (ecma_object_t *function_obj_p, /**< functi /* 4. */ if (!ecma_is_value_undefined (capability_p->resolve)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Resolve must be undefined")); + return ecma_raise_type_error (ECMA_ERR_RESOLVE_MUST_BE_UNDEFINED); } /* 5. */ if (!ecma_is_value_undefined (capability_p->reject)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Reject must be undefined")); + return ecma_raise_type_error (ECMA_ERR_REJECT_MUST_BE_UNDEFINED); } /* 6. */ @@ -732,7 +732,7 @@ ecma_promise_new_capability (ecma_value_t constructor, /**< constructor function /* 1. */ if (!ecma_is_constructor (constructor)) { - ecma_raise_type_error (ECMA_ERR_MSG ("Invalid capability")); + ecma_raise_type_error (ECMA_ERR_INVALID_CAPABILITY); return NULL; } @@ -783,7 +783,7 @@ ecma_promise_new_capability (ecma_value_t constructor, /**< constructor function { ecma_free_value (promise); ecma_deref_object (capability_obj_p); - ecma_raise_type_error (ECMA_ERR_MSG ("'resolve' parameter must be callable")); + ecma_raise_type_error (ECMA_ERR_PARAMETER_RESOLVE_MUST_BE_CALLABLE); return NULL; } @@ -792,7 +792,7 @@ ecma_promise_new_capability (ecma_value_t constructor, /**< constructor function { ecma_free_value (promise); ecma_deref_object (capability_obj_p); - ecma_raise_type_error (ECMA_ERR_MSG ("'reject' parameter must be callable")); + ecma_raise_type_error (ECMA_ERR_PARAMETER_REJECT_MUST_BE_CALLABLE); return NULL; } @@ -818,7 +818,7 @@ ecma_promise_reject_or_resolve (ecma_value_t this_arg, /**< "this" argument */ { if (!ecma_is_value_object (this_arg)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT); } if (is_resolve && ecma_is_value_object (value) && ecma_is_promise (ecma_get_object_from_value (value))) @@ -882,14 +882,14 @@ ecma_promise_then (ecma_value_t promise, /**< the promise which call 'then' */ { if (!ecma_is_value_object (promise)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT); } ecma_object_t *obj = ecma_get_object_from_value (promise); if (!ecma_is_promise (obj)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not a Promise")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_PROMISE); } ecma_value_t species = ecma_op_species_constructor (obj, ECMA_BUILTIN_ID_PROMISE); @@ -1064,7 +1064,7 @@ ecma_promise_finally (ecma_value_t promise, /**< the promise which call 'finally /* 2. */ if (!ecma_is_value_object (promise)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT); } ecma_object_t *obj = ecma_get_object_from_value (promise); diff --git a/jerry-core/ecma/operations/ecma-proxy-object.c b/jerry-core/ecma/operations/ecma-proxy-object.c index 5d218106ad..35ff2bf00e 100644 --- a/jerry-core/ecma/operations/ecma-proxy-object.c +++ b/jerry-core/ecma/operations/ecma-proxy-object.c @@ -57,7 +57,7 @@ ecma_proxy_create (ecma_value_t target, /**< proxy target */ /* ES11+: 1 - 2. */ if (!ecma_is_value_object (target) || !ecma_is_value_object (handler)) { - ecma_raise_type_error (ECMA_ERR_MSG ("Cannot create Proxy with a non-object target or handler")); + ecma_raise_type_error (ECMA_ERR_CANNOT_CREATE_PROXY); return NULL; } @@ -240,7 +240,7 @@ ecma_validate_proxy_object (ecma_value_t handler, /**< proxy handler */ { if (ecma_is_value_null (handler)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Handler cannot be null")); + return ecma_raise_type_error (ECMA_ERR_HANDLER_CANNOT_BE_NULL); } JERRY_ASSERT (ecma_is_value_object (handler)); @@ -308,7 +308,7 @@ ecma_proxy_object_get_prototype_of (ecma_object_t *obj_p) /**< proxy object */ { ecma_free_value (handler_proto); - return ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned neither object nor null")); + return ecma_raise_type_error (ECMA_ERR_TRAP_RETURNED_NEITHER_OBJECT_NOR_NULL); } if (obj_p->u2.prototype_cp & JERRY_PROXY_SKIP_RESULT_VALIDATION) @@ -349,8 +349,7 @@ ecma_proxy_object_get_prototype_of (ecma_object_t *obj_p) /**< proxy object */ { ecma_free_value (handler_proto); - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Proxy target is non-extensible, but the trap did not " - "return its actual prototype")); + ret_value = ecma_raise_type_error (ECMA_ERR_TARGET_NOT_EXTENSIBLE_NOT_RETURNED_ITS_PROTOTYPE); } ecma_free_value (target_proto); @@ -471,8 +470,7 @@ ecma_proxy_object_set_prototype_of (ecma_object_t *obj_p, /**< proxy object */ /* 16. */ if (boolean_trap_result && (target_proto != proto)) { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Target object is non-extensible and trap " - "returned different prototype")); + ret_value = ecma_raise_type_error (ECMA_ERR_TARGET_NOT_EXTENSIBLE_DIFFERENT_PROTOTYPE_RETURNED); } ecma_free_value (target_proto); @@ -567,7 +565,7 @@ ecma_proxy_object_is_extensible (ecma_object_t *obj_p) /**< proxy object */ /* 12. */ if (boolean_trap_result != target_result) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Trap result does not reflect extensibility of Proxy target")); + return ecma_raise_type_error (ECMA_ERR_TRAP_RESULT_NOT_REFLECT_TARGET_EXTENSIBILITY); } return ecma_make_boolean_value (boolean_trap_result); @@ -651,7 +649,7 @@ ecma_proxy_object_prevent_extensions (ecma_object_t *obj_p) /**< proxy object */ if (ecma_is_value_true (target_is_ext)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Trap result does not reflect inextensibility of Proxy target")); + return ecma_raise_type_error (ECMA_ERR_TRAP_RESULT_NOT_REFLECT_TARGET_INEXTENSIBILITY); } } @@ -723,7 +721,7 @@ ecma_proxy_object_get_own_property_descriptor (ecma_object_t *obj_p, /**< proxy if (!ecma_is_value_object (trap_result) && !ecma_is_value_undefined (trap_result)) { ecma_free_value (trap_result); - return ecma_raise_type_error (ECMA_ERR_MSG ("Trap is neither an object nor undefined")); + return ecma_raise_type_error (ECMA_ERR_TRAP_IS_NEITHER_AN_OBJECT_NOR_UNDEFINED); } if (obj_p->u2.prototype_cp & JERRY_PROXY_SKIP_RESULT_VALIDATION) @@ -768,8 +766,7 @@ ecma_proxy_object_get_own_property_descriptor (ecma_object_t *obj_p, /**< proxy if (!(target_desc.flags & JERRY_PROP_IS_CONFIGURABLE)) { ecma_free_property_descriptor (&target_desc); - return ecma_raise_type_error (ECMA_ERR_MSG ("Given property is a non-configurable" - " data property on the proxy target")); + return ecma_raise_type_error (ECMA_ERR_GIVEN_PROPERTY_IS_A_NON_CONFIGURABLE); } /* .c */ @@ -788,7 +785,7 @@ ecma_proxy_object_get_own_property_descriptor (ecma_object_t *obj_p, /**< proxy /* .f */ if (ecma_is_value_false (extensible_target)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Target not extensible")); + return ecma_raise_type_error (ECMA_ERR_TARGET_NOT_EXTENSIBLE); } /* .g */ @@ -846,7 +843,7 @@ ecma_proxy_object_get_own_property_descriptor (ecma_object_t *obj_p, /**< proxy if (!is_valid) { ecma_free_property_descriptor (prop_desc_p); - return ecma_raise_type_error (ECMA_ERR_MSG ("The two descriptors are incompatible")); + return ecma_raise_type_error (ECMA_ERR_THE_TWO_DESCRIPTORS_ARE_INCOMPATIBLE); } /* 22. */ @@ -858,7 +855,7 @@ ecma_proxy_object_get_own_property_descriptor (ecma_object_t *obj_p, /**< proxy || ((prop_desc_p->flags & mask) == JERRY_PROP_IS_WRITABLE_DEFINED && target_is_writable)) { ecma_free_property_descriptor (prop_desc_p); - return ecma_raise_type_error (ECMA_ERR_MSG ("The two descriptors are incompatible")); + return ecma_raise_type_error (ECMA_ERR_THE_TWO_DESCRIPTORS_ARE_INCOMPATIBLE); } } return ECMA_VALUE_TRUE; @@ -981,14 +978,12 @@ ecma_proxy_object_define_own_property (ecma_object_t *obj_p, /**< proxy object * { if (!is_target_ext) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned truish for adding property " - "to the non-extensible target")); + return ecma_raise_type_error (ECMA_ERR_TRAP_TRUISH_ADDING_PROPERTY_NON_EXTENSIBLE_TARGET); } if (setting_config_false) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned truish for defining non-configurable property " - "which is non-existent in the target")); + return ecma_raise_type_error (ECMA_ERR_TRAP_TRUISH_DEFINING_NON_EXISTENT_PROPERTY); } } /* 20. */ @@ -998,13 +993,11 @@ ecma_proxy_object_define_own_property (ecma_object_t *obj_p, /**< proxy object * if (!ecma_op_is_compatible_property_descriptor (prop_desc_p, &target_desc, is_target_ext)) { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned truish for adding property that is " - "incompatible with the existing property in the target")); + ret_value = ecma_raise_type_error (ECMA_ERR_TRAP_TRUISH_ADD_PROPERTY_INCOMPATIBLE_OTHER_PROP); } else if (setting_config_false && (target_desc.flags & JERRY_PROP_IS_CONFIGURABLE)) { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned truish for defining non-configurable property " - "which is configurable in the target")); + ret_value = ecma_raise_type_error (ECMA_ERR_TRAP_TRUISH_DEFINING_NON_EXISTENT_PROPERTY); } /* ES11: 16.c */ else if ((target_desc.flags & (JERRY_PROP_IS_VALUE_DEFINED | JERRY_PROP_IS_WRITABLE_DEFINED)) != 0 @@ -1013,8 +1006,7 @@ ecma_proxy_object_define_own_property (ecma_object_t *obj_p, /**< proxy object * && (target_desc.flags & (JERRY_PROP_IS_WRITABLE | JERRY_PROP_IS_CONFIGURABLE)) == JERRY_PROP_IS_WRITABLE) { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned truish for defining non-configurable property " - "which is configurable in the target")); + ret_value = ecma_raise_type_error (ECMA_ERR_TRAP_TRUISH_DEFINING_NON_EXISTENT_PROPERTY); } ecma_free_property_descriptor (&target_desc); @@ -1110,8 +1102,7 @@ ecma_proxy_object_has (ecma_object_t *obj_p, /**< proxy object */ if (!prop_is_configurable) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned falsish for property which exists " - "in the proxy target as non-configurable")); + return ecma_raise_type_error (ECMA_ERR_TRAP_FALSISH_PROPERTY_NON_CONFIGURABLE); } ecma_value_t extensible_target = ecma_builtin_object_object_is_extensible (target_obj_p); @@ -1123,8 +1114,7 @@ ecma_proxy_object_has (ecma_object_t *obj_p, /**< proxy object */ if (ecma_is_value_false (extensible_target)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned falsish for property but " - "the proxy target is not extensible")); + return ecma_raise_type_error (ECMA_ERR_TRAP_FALSISH_PROPERTY_TARGET_NOT_EXTENSIBLE); } } } @@ -1209,14 +1199,13 @@ ecma_proxy_object_get (ecma_object_t *obj_p, /**< proxy object */ if ((target_desc.flags & JERRY_PROP_IS_VALUE_DEFINED) && !(target_desc.flags & JERRY_PROP_IS_CONFIGURABLE) && !(target_desc.flags & JERRY_PROP_IS_WRITABLE) && !ecma_op_same_value (trap_result, target_desc.value)) { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Incorrect value is returned by a Proxy 'get' trap")); + ret_value = ecma_raise_type_error (ECMA_ERR_INCORRECT_RETURN_PROXY_GET_TRAP); } else if (!(target_desc.flags & JERRY_PROP_IS_CONFIGURABLE) && (target_desc.flags & (JERRY_PROP_IS_GET_DEFINED | JERRY_PROP_IS_SET_DEFINED)) && target_desc.get_p == NULL && !ecma_is_value_undefined (trap_result)) { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Property of a Proxy is non-configurable and " - "does not have a getter function")); + ret_value = ecma_raise_type_error (ECMA_ERR_PROXY_PROPERTY_NOT_CONFIGURABLE_NOT_HAVE_GETTER); } ecma_free_property_descriptor (&target_desc); @@ -1303,7 +1292,7 @@ ecma_proxy_object_set (ecma_object_t *obj_p, /**< proxy object */ { if (is_strict) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Proxy trap returned falsish")); + return ecma_raise_type_error (ECMA_ERR_PROXY_TRAP_RETURNED_FALSISH); } return ECMA_VALUE_FALSE; @@ -1333,14 +1322,13 @@ ecma_proxy_object_set (ecma_object_t *obj_p, /**< proxy object */ if ((target_desc.flags & JERRY_PROP_IS_VALUE_DEFINED) && !(target_desc.flags & JERRY_PROP_IS_CONFIGURABLE) && !(target_desc.flags & JERRY_PROP_IS_WRITABLE) && !ecma_op_same_value (value, target_desc.value)) { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Incorrect value is returned by a Proxy 'set' trap")); + ret_value = ecma_raise_type_error (ECMA_ERR_INCORRECT_RETURN_PROXY_SET_TRAP); } else if (!(target_desc.flags & JERRY_PROP_IS_CONFIGURABLE) && (target_desc.flags & (JERRY_PROP_IS_GET_DEFINED | JERRY_PROP_IS_SET_DEFINED)) && target_desc.set_p == NULL) { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("The property of a Proxy target is a non " - "configurable accessor without a setter")); + ret_value = ecma_raise_type_error (ECMA_ERR_TARGET_PROPERTY_CONFIGURE_ACCESSOR_WITHOUT_SETTER); } ecma_free_property_descriptor (&target_desc); @@ -1451,15 +1439,14 @@ ecma_proxy_object_delete_property (ecma_object_t *obj_p, /**< proxy object */ /* 15. */ if (!(target_desc.flags & JERRY_PROP_IS_CONFIGURABLE)) { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned truish for property which is " - "non-configurable in the proxy target")); + ret_value = ecma_raise_type_error (ECMA_ERR_TRAP_TRUISH_PROPERTY_NON_CONFIGURABLE); } /* ES11: 13-14 */ ecma_value_t extensible_target = ecma_builtin_object_object_is_extensible (target_obj_p); if (!ecma_is_value_true (extensible_target)) { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned truish for target is not extensible")); + ret_value = ecma_raise_type_error (ECMA_ERR_TRAP_TRUISH_TARGET_NOT_EXTENSIBLE); } ecma_free_property_descriptor (&target_desc); @@ -1551,7 +1538,7 @@ ecma_proxy_check_invariants_for_own_prop_keys (ecma_collection_t *trap_result, unchecked_result_keys, &unchecked_prop_name_counter))) { - ecma_raise_type_error (ECMA_ERR_MSG ("Trap result did not include all non-configurable keys")); + ecma_raise_type_error (ECMA_ERR_TRAP_RESULT_NOT_INCLUDE_ALL_NON_CONFIGURABLE_KEYS); } /* 22. */ else if (ecma_is_value_true (extensible_target)) @@ -1563,12 +1550,12 @@ ecma_proxy_check_invariants_for_own_prop_keys (ecma_collection_t *trap_result, unchecked_result_keys, &unchecked_prop_name_counter))) { - ecma_raise_type_error (ECMA_ERR_MSG ("Trap result did not include all configurable keys")); + ecma_raise_type_error (ECMA_ERR_TRAP_RESULT_NOT_INCLUDE_ALL_CONFIGURABLE_KEYS); } /* 24. */ else if (unchecked_result_keys->item_count != unchecked_prop_name_counter) { - ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned extra keys for a non-extensible Proxy target")); + ecma_raise_type_error (ECMA_ERR_TRAP_EXTRA_KEYS_FOR_A_NON_EXTENSIBLE_TARGET); } /* 25. */ else @@ -1649,7 +1636,7 @@ ecma_proxy_object_own_property_keys (ecma_object_t *obj_p) /**< proxy object */ if (ecma_collection_check_duplicated_entries (trap_result)) { ecma_collection_free (trap_result); - ecma_raise_type_error (ECMA_ERR_MSG ("Trap returned with duplicated entries")); + ecma_raise_type_error (ECMA_ERR_TRAP_WITH_DUPLICATED_ENTRIES); return NULL; } @@ -1760,7 +1747,7 @@ ecma_proxy_object_call (ecma_object_t *obj_p, /**< proxy object */ if (!ecma_op_proxy_object_is_callable (obj_p)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_expected_a_function)); + return ecma_raise_type_error (ECMA_ERR_EXPECTED_A_FUNCTION); } ECMA_CHECK_STACK_USAGE (); @@ -1873,7 +1860,7 @@ ecma_proxy_object_construct (ecma_object_t *obj_p, /**< proxy object */ { ecma_free_value (new_obj); - return ecma_raise_type_error (ECMA_ERR_MSG ("Trap must return with an object")); + return ecma_raise_type_error (ECMA_ERR_TRAP_MUST_RETURN_WITH_AN_OBJECT); } /* 12. */ diff --git a/jerry-core/ecma/operations/ecma-reference.c b/jerry-core/ecma/operations/ecma-reference.c index 4693ef1522..27bd12fd66 100644 --- a/jerry-core/ecma/operations/ecma-reference.c +++ b/jerry-core/ecma/operations/ecma-reference.c @@ -308,7 +308,7 @@ ecma_op_resolve_reference_value (ecma_object_t *lex_env_p, /**< starting lexical #if JERRY_ESNEXT if (JERRY_UNLIKELY (property_value_p->value == ECMA_VALUE_UNINITIALIZED)) { - return ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_let_const_not_initialized)); + return ecma_raise_reference_error (ECMA_ERR_LET_CONST_NOT_INITIALIZED); } #endif /* JERRY_ESNEXT */ @@ -336,7 +336,7 @@ ecma_op_resolve_reference_value (ecma_object_t *lex_env_p, /**< starting lexical if (JERRY_UNLIKELY (property_value_p->value == ECMA_VALUE_UNINITIALIZED)) { - return ecma_raise_reference_error (ECMA_ERR_MSG (ecma_error_let_const_not_initialized)); + return ecma_raise_reference_error (ECMA_ERR_LET_CONST_NOT_INITIALIZED); } return ecma_fast_copy_value (property_value_p->value); @@ -410,7 +410,7 @@ ecma_op_resolve_reference_value (ecma_object_t *lex_env_p, /**< starting lexical ecma_value_t error_value = ecma_raise_standard_error_with_format (JERRY_ERROR_REFERENCE, "% is not defined", name_val); #else /* JERRY_ERROR_MESSAGES */ - ecma_value_t error_value = ecma_raise_reference_error (NULL); + ecma_value_t error_value = ecma_raise_reference_error (ECMA_ERR_EMPTY); #endif /* !JERRY_ERROR_MESSAGES */ return error_value; } /* ecma_op_resolve_reference_value */ diff --git a/jerry-core/ecma/operations/ecma-regexp-object.c b/jerry-core/ecma/operations/ecma-regexp-object.c index 481aafba7b..31a479cb70 100644 --- a/jerry-core/ecma/operations/ecma-regexp-object.c +++ b/jerry-core/ecma/operations/ecma-regexp-object.c @@ -114,7 +114,7 @@ ecma_regexp_parse_flags (ecma_string_t *flags_str_p, /**< Input string with flag if (flag == RE_FLAG_EMPTY || (result_flags & flag) != 0) { - ret_value = ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid RegExp flags")); + ret_value = ecma_raise_syntax_error (ECMA_ERR_INVALID_REGEXP_FLAGS); break; } @@ -1883,7 +1883,7 @@ ecma_regexp_exec_helper (ecma_object_t *regexp_object_p, /**< RegExp object */ if (ECMA_RE_STACK_LIMIT_REACHED (matched_p)) { - ret_value = ecma_raise_range_error (ECMA_ERR_MSG ("Stack limit exceeded")); + ret_value = ecma_raise_range_error (ECMA_ERR_STACK_LIMIT_EXCEEDED); goto cleanup_context; } @@ -1973,7 +1973,7 @@ ecma_regexp_search_helper (ecma_value_t regexp_arg, /**< regexp argument */ /* 2. */ if (!ecma_is_value_object (regexp_arg)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT); } ecma_value_t result = ECMA_VALUE_ERROR; @@ -2079,7 +2079,7 @@ ecma_regexp_split_helper (ecma_value_t this_arg, /**< this value */ /* 2. */ if (!ecma_is_value_object (this_arg)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' is not an object")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_OBJECT); } ecma_value_t result = ECMA_VALUE_ERROR; @@ -2447,7 +2447,7 @@ ecma_regexp_split_helper (ecma_value_t this_arg, /**< this value */ if (ECMA_RE_STACK_LIMIT_REACHED (matched_p)) { - result = ecma_raise_range_error (ECMA_ERR_MSG ("Stack limit exceeded")); + result = ecma_raise_range_error (ECMA_ERR_STACK_LIMIT_EXCEEDED); goto cleanup_array; } @@ -2472,7 +2472,7 @@ ecma_regexp_split_helper (ecma_value_t this_arg, /**< this value */ if (ECMA_RE_STACK_LIMIT_REACHED (matched_p)) { - result = ecma_raise_range_error (ECMA_ERR_MSG ("Stack limit exceeded")); + result = ecma_raise_range_error (ECMA_ERR_STACK_LIMIT_EXCEEDED); goto cleanup_array; } @@ -2658,7 +2658,7 @@ ecma_regexp_replace_helper_fast (ecma_replace_context_t *ctx_p, /** (ecma_number_t) maximum_size_in_byte + 0.5) { ecma_deref_object (proto_p); - return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid Shared ArrayBuffer length")); + return ecma_raise_range_error (ECMA_ERR_INVALID_SHARED_ARRAYBUFFER_LENGTH); } } diff --git a/jerry-core/ecma/operations/ecma-symbol-object.c b/jerry-core/ecma/operations/ecma-symbol-object.c index 22cd9d49c7..99d6256247 100644 --- a/jerry-core/ecma/operations/ecma-symbol-object.c +++ b/jerry-core/ecma/operations/ecma-symbol-object.c @@ -170,7 +170,7 @@ ecma_symbol_this_value (ecma_value_t this_arg) /**< this argument value */ } /* 3. */ - return ecma_raise_type_error (ECMA_ERR_MSG ("Argument 'this' must be a Symbol")); + return ecma_raise_type_error (ECMA_ERR_ARGUMENT_THIS_NOT_SYMBOL); } /* ecma_symbol_this_value */ #endif /* JERRY_ESNEXT */ diff --git a/jerry-core/ecma/operations/ecma-typedarray-object.c b/jerry-core/ecma/operations/ecma-typedarray-object.c index 95af9216f1..7a2d171a1c 100644 --- a/jerry-core/ecma/operations/ecma-typedarray-object.c +++ b/jerry-core/ecma/operations/ecma-typedarray-object.c @@ -811,7 +811,7 @@ ecma_typedarray_create_object_with_length (uint32_t array_length, /**< length of ecma_free_value (array_length_value); return result; #else /* !JERRY_ERROR_MESSAGES */ - return ecma_raise_range_error (NULL); + return ecma_raise_range_error (ECMA_ERR_EMPTY); #endif /* JERRY_ERROR_MESSAGES */ } @@ -850,7 +850,7 @@ ecma_typedarray_create_object_with_length (uint32_t array_length, /**< length of if (ecma_arraybuffer_is_detached (src_buffer_p)) { ecma_deref_object (new_arraybuffer_p); - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached)); + return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); } } @@ -925,7 +925,7 @@ ecma_typedarray_create_object_with_typedarray (ecma_object_t *typedarray_p, /**< if ((ECMA_TYPEDARRAY_IS_BIGINT_TYPE (src_id) ^ ECMA_TYPEDARRAY_IS_BIGINT_TYPE (typedarray_id)) == 1) { ecma_deref_object (new_typedarray_p); - return ecma_raise_type_error (ECMA_ERR_MSG ("Incompatible TypedArray types")); + return ecma_raise_type_error (ECMA_ERR_INCOMPATIBLE_TYPEDARRAY_TYPES); } #endif /* JERRY_BUILTIN_BIGINT */ @@ -1159,7 +1159,7 @@ ecma_typedarray_create_object_with_object (ecma_value_t items_val, /**< the sour if (length_index >= UINT32_MAX) { ecma_deref_object (arraylike_object_p); - return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid TypedArray length")); + return ecma_raise_range_error (ECMA_ERR_INVALID_TYPEDARRAY_LENGTH); } uint32_t len = (uint32_t) length_index; @@ -1392,7 +1392,7 @@ ecma_op_typedarray_from (ecma_value_t this_val, /**< this value */ if (length_index >= UINT32_MAX) { ecma_deref_object (arraylike_object_p); - return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid TypedArray length")); + return ecma_raise_range_error (ECMA_ERR_INVALID_TYPEDARRAY_LENGTH); } uint32_t len = (uint32_t) length_index; @@ -1614,7 +1614,7 @@ ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, /**< the arg li "Invalid typed array length: %", arguments_list_p[0]); #else /* !JERRY_ERROR_MESSAGES */ - return ecma_raise_range_error (NULL); + return ecma_raise_range_error (ECMA_ERR_EMPTY); #endif /* JERRY_ERROR_MESSAGES */ } @@ -1658,7 +1658,7 @@ ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, /**< the arg li } else { - return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid offset")); + return ecma_raise_range_error (ECMA_ERR_INVALID_OFFSET); } } @@ -1671,14 +1671,12 @@ ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, /**< the arg li if (ecma_arraybuffer_is_detached (arraybuffer_p)) { - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached)); + return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); } - const char *invalid_length_p = ECMA_ERR_MSG ("Invalid length"); - if (offset > UINT32_MAX) { - return ecma_raise_range_error (invalid_length_p); + return ecma_raise_range_error (ECMA_ERR_INVALID_LENGTH); } uint32_t byte_offset = (uint32_t) offset; @@ -1690,7 +1688,7 @@ ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, /**< the arg li { if ((buf_byte_length % (uint32_t) (1 << element_size_shift) != 0) || (buf_byte_length < byte_offset)) { - return ecma_raise_range_error (invalid_length_p); + return ecma_raise_range_error (ECMA_ERR_INVALID_LENGTH); } new_byte_length = (uint32_t) (buf_byte_length - byte_offset); @@ -1699,14 +1697,14 @@ ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, /**< the arg li { if (new_length > (UINT32_MAX >> element_size_shift)) { - return ecma_raise_range_error (ECMA_ERR_MSG ("Maximum TypedArray size is reached")); + return ecma_raise_range_error (ECMA_ERR_MAXIMUM_TYPEDARRAY_SIZE_IS_REACHED); } new_byte_length = (uint32_t) new_length << element_size_shift; if (byte_offset > buf_byte_length || new_byte_length > (buf_byte_length - byte_offset)) { - return ecma_raise_range_error (invalid_length_p); + return ecma_raise_range_error (ECMA_ERR_INVALID_LENGTH); } } @@ -1927,7 +1925,7 @@ ecma_typedarray_create (ecma_object_t *constructor_p, /**< constructor function if (!ecma_is_typedarray (ret_val)) { ecma_free_value (ret_val); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructed object is not TypedArray")); + return ecma_raise_type_error (ECMA_ERR_CONSTRUCTED_OBJECT_IS_NOT_TYPEDARRAY); } ecma_object_t *typedarray_p = ecma_get_object_from_value (ret_val); @@ -1937,7 +1935,7 @@ ecma_typedarray_create (ecma_object_t *constructor_p, /**< constructor function if (ecma_arraybuffer_is_detached (arraybuffer_p)) { ecma_deref_object (typedarray_p); - return ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_arraybuffer_is_detached)); + return ecma_raise_type_error (ECMA_ERR_ARRAYBUFFER_IS_DETACHED); } if ((arguments_list_len == 1) && (ecma_is_value_number (arguments_list_p[0]))) @@ -1948,7 +1946,7 @@ ecma_typedarray_create (ecma_object_t *constructor_p, /**< constructor function if (info.length < num) { ecma_free_value (ret_val); - return ecma_raise_type_error (ECMA_ERR_MSG ("Constructed TypedArray is smaller than filter call result")); + return ecma_raise_type_error (ECMA_ERR_TYPEDARRAY_SMALLER_THAN_FILTER_CALL_RESULT); } } return ret_val; @@ -2000,7 +1998,7 @@ ecma_typedarray_species_create (ecma_value_t this_arg, /**< this argument */ if (ECMA_TYPEDARRAY_IS_BIGINT_TYPE (info.id) ^ ECMA_TYPEDARRAY_IS_BIGINT_TYPE (result_info.id)) { ecma_free_value (result); - return ecma_raise_type_error (ECMA_ERR_MSG ("TypedArray returned by [[ContentType]] does not match source")); + return ecma_raise_type_error (ECMA_ERR_CONTENTTYPE_RETURNED_TYPEDARRAY_NOT_MATCH_SOURCE); } #endif /* JERRY_BUILTIN_BIGINT */ diff --git a/jerry-core/lit/lit-magic-strings.inc.h b/jerry-core/lit/lit-magic-strings.inc.h index 4b7c21d788..115d89c0f5 100644 --- a/jerry-core/lit/lit-magic-strings.inc.h +++ b/jerry-core/lit/lit-magic-strings.inc.h @@ -13,7 +13,7 @@ * limitations under the License. */ -/* This file is automatically generated by the gen-magic-strings.py script +/* This file is automatically generated by the gen-strings.py script * from lit-magic-strings.ini. Do not edit! */ LIT_MAGIC_STRING_DEF (LIT_MAGIC_STRING__EMPTY, "") diff --git a/jerry-core/lit/lit-magic-strings.ini b/jerry-core/lit/lit-magic-strings.ini index c3f6ed570a..fb9496891c 100644 --- a/jerry-core/lit/lit-magic-strings.ini +++ b/jerry-core/lit/lit-magic-strings.ini @@ -18,7 +18,7 @@ # magic strings, because it must be the terminator character of all magic # strings. # -# If the list is modified, tools/gen-magic-strings.py must be executed! +# If the list is modified, tools/gen-strings.py must be executed! [LIT_MAGIC_STRINGS] diff --git a/jerry-core/parser/js/js-parser-util.c b/jerry-core/parser/js/js-parser-util.c index 66a6356219..a0dcbfe26d 100644 --- a/jerry-core/parser/js/js-parser-util.c +++ b/jerry-core/parser/js/js-parser-util.c @@ -1237,7 +1237,7 @@ parser_error_to_string (parser_error_t error) /**< error code */ #if JERRY_ESNEXT case PARSER_ERR_VARIABLE_REDECLARED: { - return ecma_error_local_variable_is_redeclared; + return (const char *) ecma_get_error_utf8 (ECMA_ERR_LOCAL_VARIABLE_IS_REDECLARED); } case PARSER_ERR_LEXICAL_SINGLE_STATEMENT: { diff --git a/jerry-core/parser/js/js-parser.c b/jerry-core/parser/js/js-parser.c index 2ba45777bc..4229425657 100644 --- a/jerry-core/parser/js/js-parser.c +++ b/jerry-core/parser/js/js-parser.c @@ -2359,7 +2359,7 @@ parser_parse_source (void *source_p, /**< source code */ jcontext_release_exception (); } - ecma_raise_syntax_error (""); + ecma_raise_syntax_error (ECMA_ERR_EMPTY); #endif /* JERRY_ERROR_MESSAGES */ return NULL; @@ -3132,7 +3132,7 @@ parser_parse_script (void *source_p, /**< source code */ JERRY_UNUSED (parse_opts); JERRY_UNUSED (resource_name); - ecma_raise_syntax_error (ECMA_ERR_MSG ("Source code parsing is disabled")); + ecma_raise_syntax_error (ECMA_ERR_PARSER_NOT_SUPPORTED); return NULL; #endif /* JERRY_PARSER */ } /* parser_parse_script */ diff --git a/jerry-core/parser/regexp/re-parser.c b/jerry-core/parser/regexp/re-parser.c index cd12aa565a..0361b34ec1 100644 --- a/jerry-core/parser/regexp/re-parser.c +++ b/jerry-core/parser/regexp/re-parser.c @@ -228,7 +228,7 @@ re_check_quantifier (re_compiler_ctx_t *re_ctx_p) if (re_ctx_p->token.qmin > re_ctx_p->token.qmax) { /* ECMA-262 v5.1 15.10.2.5 */ - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Quantifier error: min > max")); + return ecma_raise_syntax_error (ECMA_ERR_MIN_GREATER_THAN_MAX); } return ECMA_VALUE_EMPTY; @@ -432,7 +432,7 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context #if JERRY_ESNEXT if (re_ctx_p->flags & RE_FLAG_UNICODE) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid escape sequence")); + return ecma_raise_syntax_error (ECMA_ERR_INVALID_ESCAPE_SEQUENCE); } #endif /* JERRY_ESNEXT */ @@ -534,7 +534,7 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context #if JERRY_ESNEXT if (re_ctx_p->flags & RE_FLAG_UNICODE) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid control escape sequence")); + return ecma_raise_syntax_error (ECMA_ERR_INVALID_CONTROL_ESCAPE_SEQUENCE); } #endif /* JERRY_ESNEXT */ @@ -557,7 +557,7 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context #if JERRY_ESNEXT if (re_ctx_p->flags & RE_FLAG_UNICODE) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid hex escape sequence")); + return ecma_raise_syntax_error (ECMA_ERR_INVALID_HEX_ESCAPE_SEQUENCE); } #endif /* JERRY_ESNEXT */ @@ -606,7 +606,7 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context if (JERRY_UNLIKELY (cp > LIT_UNICODE_CODE_POINT_MAX)) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid unicode escape sequence")); + return ecma_raise_syntax_error (ECMA_ERR_INVALID_UNICODE_ESCAPE_SEQUENCE); } } @@ -618,7 +618,7 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context } } - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid unicode escape sequence")); + return ecma_raise_syntax_error (ECMA_ERR_INVALID_UNICODE_ESCAPE_SEQUENCE); } #endif /* JERRY_ESNEXT */ @@ -632,7 +632,7 @@ re_parse_char_escape (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context /* Must be '/', or one of SyntaxCharacter */ if (re_ctx_p->flags & RE_FLAG_UNICODE && ch != LIT_CHAR_SLASH && !re_is_syntax_char (ch)) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid escape")); + return ecma_raise_syntax_error (ECMA_ERR_INVALID_ESCAPE); } #endif /* JERRY_ESNEXT */ re_ctx_p->token.value = ch; @@ -688,7 +688,7 @@ re_parse_next_token (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context * { if (re_ctx_p->input_curr_p >= re_ctx_p->input_end_p) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid escape")); + return ecma_raise_syntax_error (ECMA_ERR_INVALID_ESCAPE); } /* DecimalEscape, Backreferences cannot start with a zero digit. */ @@ -741,7 +741,7 @@ re_parse_next_token (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context * { if (re_ctx_p->input_curr_p >= re_ctx_p->input_end_p) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Unterminated group")); + return ecma_raise_syntax_error (ECMA_ERR_UNTERMINATED_GROUP); } if (*re_ctx_p->input_curr_p == LIT_CHAR_QUESTION) @@ -749,7 +749,7 @@ re_parse_next_token (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context * re_ctx_p->input_curr_p++; if (re_ctx_p->input_curr_p >= re_ctx_p->input_end_p) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid group")); + return ecma_raise_syntax_error (ECMA_ERR_INVALID_GROUP); } ch = *re_ctx_p->input_curr_p++; @@ -770,7 +770,7 @@ re_parse_next_token (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context * } else { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid group")); + return ecma_raise_syntax_error (ECMA_ERR_INVALID_GROUP); } } else @@ -792,7 +792,7 @@ re_parse_next_token (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context * if (re_ctx_p->input_curr_p >= re_ctx_p->input_end_p) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Unterminated character class")); + return ecma_raise_syntax_error (ECMA_ERR_UNTERMINATED_CHARACTER_CLASS); } return ECMA_VALUE_EMPTY; @@ -801,20 +801,20 @@ re_parse_next_token (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context * case LIT_CHAR_ASTERISK: case LIT_CHAR_PLUS: { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid quantifier")); + return ecma_raise_syntax_error (ECMA_ERR_INVALID_QUANTIFIER); } case LIT_CHAR_LEFT_BRACE: { re_ctx_p->input_curr_p--; if (ecma_is_value_true (re_parse_quantifier (re_ctx_p))) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Nothing to repeat")); + return ecma_raise_syntax_error (ECMA_ERR_NOTHING_TO_REPEAT); } #if JERRY_ESNEXT if (re_ctx_p->flags & RE_FLAG_UNICODE) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Lone quantifier bracket")); + return ecma_raise_syntax_error (ECMA_ERR_LONE_QUANTIFIER_BRACKET); } #endif /* JERRY_ESNEXT */ @@ -831,7 +831,7 @@ re_parse_next_token (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context * { if (re_ctx_p->flags & RE_FLAG_UNICODE) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Lone quantifier bracket")); + return ecma_raise_syntax_error (ECMA_ERR_LONE_QUANTIFIER_BRACKET); } /* FALLTHRU */ @@ -937,7 +937,7 @@ re_parse_char_class (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context * { if (re_ctx_p->input_curr_p >= re_ctx_p->input_end_p) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Unterminated character class")); + return ecma_raise_syntax_error (ECMA_ERR_UNTERMINATED_CHARACTER_CLASS); } if (*re_ctx_p->input_curr_p == LIT_CHAR_RIGHT_SQUARE) @@ -966,7 +966,7 @@ re_parse_char_class (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context * re_ctx_p->input_curr_p++; if (re_ctx_p->input_curr_p >= re_ctx_p->input_end_p) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid escape")); + return ecma_raise_syntax_error (ECMA_ERR_INVALID_ESCAPE); } if (*re_ctx_p->input_curr_p == LIT_CHAR_LOWERCASE_B) @@ -1028,7 +1028,7 @@ re_parse_char_class (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context * { if (start > current) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Range out of order in character class")); + return ecma_raise_syntax_error (ECMA_ERR_RANGE_OUT_OF_ORDER_IN_CHARACTER_CLASS); } re_class_add_range (re_ctx_p, start, current); @@ -1039,7 +1039,7 @@ re_parse_char_class (re_compiler_ctx_t *re_ctx_p) /**< RegExp compiler context * #if JERRY_ESNEXT if (re_ctx_p->flags & RE_FLAG_UNICODE) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid character class")); + return ecma_raise_syntax_error (ECMA_ERR_INVALID_CHARACTER_CLASS); } #endif /* JERRY_ESNEXT */ @@ -1292,7 +1292,7 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context { if (expect_eof) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Unmatched close bracket")); + return ecma_raise_syntax_error (ECMA_ERR_UNMATCHED_CLOSE_BRACKET); } if (!first_alternative) @@ -1307,7 +1307,7 @@ re_parse_alternative (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context { if (!expect_eof) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("Unexpected end of pattern")); + return ecma_raise_syntax_error (ECMA_ERR_UNEXPECTED_END_OF_PATTERN); } if (!first_alternative) diff --git a/jerry-core/vm/opcodes-ecma-arithmetics.c b/jerry-core/vm/opcodes-ecma-arithmetics.c index a880b5cc89..a0b15c81ab 100644 --- a/jerry-core/vm/opcodes-ecma-arithmetics.c +++ b/jerry-core/vm/opcodes-ecma-arithmetics.c @@ -303,7 +303,7 @@ opfunc_unary_operation (ecma_value_t left_value, /**< left value */ if (is_plus) { - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Unary plus is not allowed for BigInts")); + ret_value = ecma_raise_type_error (ECMA_ERR_UNARY_PLUS_IS_NOT_ALLOWED_FOR_BIGINTS); } else { diff --git a/jerry-core/vm/opcodes-ecma-bitwise.c b/jerry-core/vm/opcodes-ecma-bitwise.c index 16eeee86a8..de692345cc 100644 --- a/jerry-core/vm/opcodes-ecma-bitwise.c +++ b/jerry-core/vm/opcodes-ecma-bitwise.c @@ -157,7 +157,7 @@ do_number_bitwise_logic (number_bitwise_logic_op op, /**< number bitwise logic o { JERRY_ASSERT (op == NUMBER_BITWISE_SHIFT_URIGHT); - ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Unsigned right shift is not allowed for BigInts")); + ret_value = ecma_raise_type_error (ECMA_ERR_UNSIGNED_RIGHT_SHIFT_IS_NOT_ALLOWED_FOR_BIGINTS); break; } } diff --git a/jerry-core/vm/opcodes-ecma-relational-equality.c b/jerry-core/vm/opcodes-ecma-relational-equality.c index 9362cff1d5..23040e032a 100644 --- a/jerry-core/vm/opcodes-ecma-relational-equality.c +++ b/jerry-core/vm/opcodes-ecma-relational-equality.c @@ -104,7 +104,7 @@ opfunc_instanceof (ecma_value_t left_value, /**< left value */ { if (!ecma_is_value_object (right_value)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Right value of 'instanceof' must be an object")); + return ecma_raise_type_error (ECMA_ERR_RIGHT_VALUE_OF_INSTANCEOF_MUST_BE_AN_OBJECT); } #if JERRY_ESNEXT @@ -153,7 +153,7 @@ opfunc_in (ecma_value_t left_value, /**< left value */ { if (!ecma_is_value_object (right_value)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Right value of 'in' must be an object")); + return ecma_raise_type_error (ECMA_ERR_RIGHT_VALUE_OF_IN_MUST_BE_AN_OBJECT); } ecma_string_t *property_name_p = ecma_op_to_property_key (left_value); diff --git a/jerry-core/vm/opcodes.c b/jerry-core/vm/opcodes.c index 25da75959d..7df87a6e3f 100644 --- a/jerry-core/vm/opcodes.c +++ b/jerry-core/vm/opcodes.c @@ -218,7 +218,7 @@ vm_op_delete_prop (ecma_value_t object, /**< base object */ #if JERRY_ESNEXT if (is_strict && ecma_is_value_false (delete_op_ret)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Operator delete returned false in strict mode")); + return ecma_raise_type_error (ECMA_ERR_OPERATOR_DELETE_RETURNED_FALSE_IN_STRICT_MODE); } #endif /* JERRY_ESNEXT */ @@ -1159,7 +1159,7 @@ opfunc_init_class (vm_frame_ctx_t *frame_ctx_p, /**< frame context */ /* 6.f, 6.g.i */ if (!ecma_is_constructor (super_class)) { - return ecma_raise_type_error ("Class extends value is not a constructor or null"); + return ecma_raise_type_error (ECMA_ERR_CLASS_EXTENDS_NOT_CONSTRUCTOR); } ecma_object_t *parent_p = ecma_get_object_from_value (super_class); @@ -1186,7 +1186,7 @@ opfunc_init_class (vm_frame_ctx_t *frame_ctx_p, /**< frame context */ else { ecma_free_value (proto_parent); - return ecma_raise_type_error ("Property 'prototype' is not an object or null"); + return ecma_raise_type_error (ECMA_ERR_PROPERTY_PROTOTYPE_IS_NOT_AN_OBJECT); } /* 6.g.v */ @@ -1391,8 +1391,7 @@ opfunc_form_super_reference (ecma_value_t **vm_stack_top_p, /**< current vm stac if (!ecma_op_this_binding_is_initialized (environment_record_p)) { - return ecma_raise_reference_error (ECMA_ERR_MSG ("Must call super constructor in derived class before " - "accessing 'this' or returning from it")); + return ecma_raise_reference_error (ECMA_ERR_CALL_SUPER_CONSTRUCTOR_DERIVED_CLASS_BEFORE_THIS); } } @@ -1400,7 +1399,7 @@ opfunc_form_super_reference (ecma_value_t **vm_stack_top_p, /**< current vm stac if (ECMA_IS_VALUE_ERROR (parent)) { - return ecma_raise_type_error (ECMA_ERR_MSG ("Cannot invoke nullable super method")); + return ecma_raise_type_error (ECMA_ERR_INVOKE_NULLABLE_SUPER_METHOD); } if (!ecma_op_require_object_coercible (parent)) diff --git a/jerry-core/vm/vm-stack.c b/jerry-core/vm/vm-stack.c index e41e68c297..38a9e72da5 100644 --- a/jerry-core/vm/vm-stack.c +++ b/jerry-core/vm/vm-stack.c @@ -417,7 +417,7 @@ vm_stack_find_finally (vm_frame_ctx_t *frame_ctx_p, /**< frame context */ if (!is_object) { - result = ecma_raise_type_error (ECMA_ERR_MSG ("Iterator 'return' result is not object")); + result = ecma_raise_type_error (ECMA_ERR_ITERATOR_RETURN_RESULT_IS_NOT_OBJECT); } } } diff --git a/jerry-core/vm/vm.c b/jerry-core/vm/vm.c index 409c8e2527..50f96a4ae9 100644 --- a/jerry-core/vm/vm.c +++ b/jerry-core/vm/vm.c @@ -23,6 +23,7 @@ #include "ecma-builtins.h" #include "ecma-comparison.h" #include "ecma-conversion.h" +#include "ecma-errors.h" #include "ecma-exceptions.h" #include "ecma-function-object.h" #include "ecma-gc.h" @@ -124,7 +125,7 @@ vm_op_get_value (ecma_value_t object, /**< base object */ ecma_value_t error_value = ecma_raise_standard_error_with_format (JERRY_ERROR_TYPE, "Cannot read property '%' of %", property, object); #else /* !JERRY_ERROR_MESSAGES */ - ecma_value_t error_value = ecma_raise_type_error (NULL); + ecma_value_t error_value = ecma_raise_type_error (ECMA_ERR_EMPTY); #endif /* JERRY_ERROR_MESSAGES */ return error_value; } @@ -168,7 +169,7 @@ vm_op_set_value (ecma_value_t base, /**< base object */ #if JERRY_ERROR_MESSAGES result = ecma_raise_standard_error_with_format (JERRY_ERROR_TYPE, "Cannot set property '%' of %", property, base); #else /* !JERRY_ERROR_MESSAGES */ - result = ecma_raise_type_error (NULL); + result = ecma_raise_type_error (ECMA_ERR_EMPTY); #endif /* JERRY_ERROR_MESSAGES */ ecma_free_value (property); return result; @@ -323,7 +324,7 @@ vm_run_eval (ecma_compiled_code_t *bytecode_data_p, /**< byte-code data */ { ecma_bytecode_deref (bytecode_data_p); ecma_free_value (this_binding); - return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid scope chain index for eval")); + return ecma_raise_range_error (ECMA_ERR_INVALID_SCOPE_CHAIN_INDEX_FOR_EVAL); } lex_env_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, lex_env_p->u2.outer_reference_cp); @@ -568,7 +569,7 @@ vm_super_call (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ if (!ecma_is_constructor (func_value)) { - completion_value = ecma_raise_type_error (ECMA_ERR_MSG ("Value for class heritage is not a constructor")); + completion_value = ecma_raise_type_error (ECMA_ERR_VALUE_FOR_CLASS_HERITAGE_IS_NOT_A_CONSTRUCTOR); } else { @@ -579,7 +580,7 @@ vm_super_call (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ if (!ECMA_IS_VALUE_ERROR (completion_value) && ecma_op_this_binding_is_initialized (environment_record_p)) { ecma_free_value (completion_value); - completion_value = ecma_raise_reference_error (ECMA_ERR_MSG ("Super constructor may only be called once")); + completion_value = ecma_raise_reference_error (ECMA_ERR_SUPER_CONSTRUCTOR_MAY_ONLY_BE_CALLED_ONCE); } } @@ -659,10 +660,10 @@ vm_spread_operation (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ if (frame_ctx_p->byte_code_p[1] == CBC_EXT_SPREAD_NEW) { - const char *constructor_message_p = ecma_check_constructor (func_value); - if (constructor_message_p != ECMA_IS_VALID_CONSTRUCTOR) + ecma_error_msg_t constructor_message_id = ecma_check_constructor (func_value); + if (constructor_message_id != ECMA_IS_VALID_CONSTRUCTOR) { - completion_value = ecma_raise_type_error (constructor_message_p); + completion_value = ecma_raise_type_error (constructor_message_id); } else { @@ -680,7 +681,7 @@ vm_spread_operation (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ if (!ecma_is_value_object (func_value) || !ecma_op_object_is_callable (ecma_get_object_from_value (func_value))) { - completion_value = ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_expected_a_function)); + completion_value = ecma_raise_type_error (ECMA_ERR_EXPECTED_A_FUNCTION); } else { @@ -831,10 +832,10 @@ opfunc_construct (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ ecma_value_t constructor_value = stack_top_p[-1]; ecma_value_t completion_value; - const char *constructor_message_p = ecma_check_constructor (constructor_value); - if (constructor_message_p != ECMA_IS_VALID_CONSTRUCTOR) + ecma_error_msg_t constructor_message_id = ecma_check_constructor (constructor_value); + if (constructor_message_id != ECMA_IS_VALID_CONSTRUCTOR) { - completion_value = ecma_raise_type_error (constructor_message_p); + completion_value = ecma_raise_type_error (constructor_message_id); } else { @@ -1591,7 +1592,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ if (binding_p != NULL) { - result = ecma_raise_syntax_error (ECMA_ERR_MSG (ecma_error_local_variable_is_redeclared)); + result = ecma_raise_syntax_error (ECMA_ERR_LOCAL_VARIABLE_IS_REDECLARED); goto error; } @@ -1616,7 +1617,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ { if (ecma_is_value_true (result)) { - result = ecma_raise_syntax_error (ECMA_ERR_MSG (ecma_error_local_variable_is_redeclared)); + result = ecma_raise_syntax_error (ECMA_ERR_LOCAL_VARIABLE_IS_REDECLARED); } JERRY_ASSERT (ECMA_IS_VALUE_ERROR (result)); @@ -1637,7 +1638,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ if (ecma_is_value_true (result)) { - result = ecma_raise_syntax_error (ECMA_ERR_MSG (ecma_error_local_variable_is_redeclared)); + result = ecma_raise_syntax_error (ECMA_ERR_LOCAL_VARIABLE_IS_REDECLARED); goto error; } @@ -1705,7 +1706,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ } case VM_OC_THROW_CONST_ERROR: { - result = ecma_raise_type_error (ECMA_ERR_MSG ("Constant bindings cannot be reassigned")); + result = ecma_raise_type_error (ECMA_ERR_CONSTANT_BINDINGS_CANNOT_BE_REASSIGNED); goto error; } case VM_OC_COPY_TO_GLOBAL: @@ -1891,7 +1892,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ if (JERRY_UNLIKELY (ecma_compare_ecma_string_to_magic_id (prop_name_p, LIT_MAGIC_STRING_PROTOTYPE)) && !(opcode_data & VM_OC_NON_STATIC_FLAG)) { - result = ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_class_is_non_configurable)); + result = ecma_raise_type_error (ECMA_ERR_CLASS_IS_NON_CONFIGURABLE); goto error; } @@ -1924,7 +1925,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ if (JERRY_UNLIKELY (ecma_compare_ecma_string_to_magic_id (prop_name_p, LIT_MAGIC_STRING_PROTOTYPE)) && !(opcode_data & VM_OC_NON_STATIC_FLAG)) { - result = ecma_raise_type_error (ECMA_ERR_MSG (ecma_error_class_is_non_configurable)); + result = ecma_raise_type_error (ECMA_ERR_CLASS_IS_NON_CONFIGURABLE); goto error; } @@ -3064,7 +3065,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ } case VM_OC_THROW_REFERENCE_ERROR: { - result = ecma_raise_reference_error (ECMA_ERR_MSG ("Undefined reference")); + result = ecma_raise_reference_error (ECMA_ERR_UNDEFINED_REFERENCE); goto error; } case VM_OC_EVAL: diff --git a/tests/unit-core/test-to-integer.c b/tests/unit-core/test-to-integer.c index a82b95ed01..6c2ec93a36 100644 --- a/tests/unit-core/test-to-integer.c +++ b/tests/unit-core/test-to-integer.c @@ -23,6 +23,7 @@ #include "ecma-init-finalize.h" #include "jcontext.h" +#include "lit-globals.h" #include "test-common.h" /** @@ -48,7 +49,8 @@ main (void) TEST_ASSERT (num == 123); /* 2 */ - ecma_value_t error = ecma_raise_type_error (ECMA_ERR_MSG ("I am a neat little error message")); + ecma_value_t error = + ecma_raise_standard_error (JERRY_ERROR_TYPE, (const lit_utf8_byte_t *) "I am a neat little error message"); result = ecma_op_to_integer (error, &num); diff --git a/tests/unit-core/test-to-length.c b/tests/unit-core/test-to-length.c index fc98dac75e..b5a435013b 100644 --- a/tests/unit-core/test-to-length.c +++ b/tests/unit-core/test-to-length.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include "jerryscript-types.h" #include "jerryscript.h" #include "ecma-conversion.h" @@ -23,6 +24,7 @@ #include "ecma-init-finalize.h" #include "jcontext.h" +#include "lit-globals.h" #include "test-common.h" /** @@ -48,7 +50,7 @@ main (void) TEST_ASSERT (num == 123); /* 1, 3 */ - ecma_value_t error_throw = ecma_raise_type_error (ECMA_ERR_MSG ("I'm an error")); + ecma_value_t error_throw = ecma_raise_standard_error (JERRY_ERROR_TYPE, (const lit_utf8_byte_t *) "I'm an error"); result = ecma_op_to_length (error_throw, &num); diff --git a/tools/check-magic-strings.sh b/tools/check-strings.sh similarity index 96% rename from tools/check-magic-strings.sh rename to tools/check-strings.sh index 3c8e54dd21..fdb917771e 100755 --- a/tools/check-magic-strings.sh +++ b/tools/check-strings.sh @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -MAGIC_STRINGS_GEN="tools/gen-magic-strings.py" +MAGIC_STRINGS_GEN="tools/gen-strings.py" MAGIC_STRINGS_INC_H="jerry-core/lit/lit-magic-strings.inc.h" MAGIC_STRINGS_TEMP=`mktemp lit-magic-strings.inc.h.XXXXXXXXXX` diff --git a/tools/gen-magic-strings.py b/tools/gen-strings.py similarity index 76% rename from tools/gen-magic-strings.py rename to tools/gen-strings.py index 4d77f1d5a6..d7faf8009a 100755 --- a/tools/gen-magic-strings.py +++ b/tools/gen-strings.py @@ -34,6 +34,11 @@ MAGIC_STRINGS_INI = os.path.join(PROJECT_DIR, 'jerry-core', 'lit', 'lit-magic-strings.ini') MAGIC_STRINGS_INC_H = os.path.join(PROJECT_DIR, 'jerry-core', 'lit', 'lit-magic-strings.inc.h') +ECMA_ERRORS_INI = os.path.join(PROJECT_DIR, 'jerry-core', 'ecma', 'base', 'ecma-error-messages.ini') +ECMA_ERRORS_INC_H = os.path.join(PROJECT_DIR, 'jerry-core', 'ecma', 'base', 'ecma-error-messages.inc.h') + +LIMIT_MAGIC_STR_LENGTH = 255 + def debug_dump(obj): def deepcopy(obj): if isinstance(obj, (list, tuple)): @@ -46,7 +51,7 @@ def deepcopy(obj): return json.dumps(deepcopy(obj), indent=4) -def read_magic_string_defs(debug=False): +def read_magic_string_defs(debug, ini_path, item_name): # Read the `jerry-core/lit/lit-magic-strings.ini` file and returns the magic # string definitions found therein in the form of # [LIT_MAGIC_STRINGS] @@ -57,12 +62,18 @@ def read_magic_string_defs(debug=False): # sorted by length and alpha. ini_parser = ConfigParser() ini_parser.optionxform = str # case sensitive options (magic string IDs) - ini_parser.read(MAGIC_STRINGS_INI) + ini_parser.read(ini_path) defs = [(str_ref, json.loads(str_value) if str_value != '' else '') - for str_ref, str_value in ini_parser.items('LIT_MAGIC_STRINGS')] + for str_ref, str_value in ini_parser.items(item_name)] defs = sorted(defs, key=lambda ref_value: (len(ref_value[1]), ref_value[1])) + if len(defs[-1][1]) > LIMIT_MAGIC_STR_LENGTH: + for str_ref, str_value in [x for x in defs if len(x[1]) > LIMIT_MAGIC_STR_LENGTH]: + print("error: The maximum allowed magic string size is {limit} but {str_ref} is {str_len} long.".format( + limit=LIMIT_MAGIC_STR_LENGTH, str_ref=str_ref, str_len=len(str_value))) + exit(1) + if debug: print('debug: magic string definitions: {dump}' .format(dump=debug_dump(defs))) @@ -70,25 +81,28 @@ def read_magic_string_defs(debug=False): return defs -def extract_magic_string_refs(debug=False): +def extract_magic_string_refs(debug, pattern, inc_h_filename): results = {} - def process_line(fname, lnum, line, guard_stack): + def process_line(fname, lnum, line, guard_stack, pattern): # Build `results` dictionary as # results['LIT_MAGIC_STRING_xxx'][('!defined (CONFIG_DISABLE_yyy_BUILTIN)', ...)] # = [('zzz.c', 123), ...] # meaning that the given literal is referenced under the given guards at # the listed (file, line number) locations. - for str_ref in re.findall('LIT_MAGIC_STRING_[a-zA-Z0-9_]+', line): - if str_ref in ['LIT_MAGIC_STRING_DEF', - 'LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE', - 'LIT_MAGIC_STRING_LENGTH_LIMIT', - 'LIT_MAGIC_STRING__COUNT']: + exception_list = ['%s_DEF' % pattern, + '%s_FIRST_STRING_WITH_SIZE' % pattern, + '%s_LENGTH_LIMIT' % pattern, + '%s__COUNT' % pattern] + + for str_ref in re.findall('%s_[a-zA-Z0-9_]+' % pattern, line): + if str_ref in exception_list: continue guard_set = set() for guards in guard_stack: guard_set.update(guards) + guard_tuple = tuple(sorted(guard_set)) if str_ref not in results: @@ -111,7 +125,7 @@ def process_guard(guard): guard = guard.replace('def ', 'defined (', 1) + ')' return guard - def process_file(fname): + def process_file(fname, pattern): # Builds `guard_stack` list for each line of a file as # [['!defined (CONFIG_DISABLE_yyy_BUILTIN)', ...], ...] # meaning that all the listed guards (conditionals) have to hold for the @@ -136,7 +150,7 @@ def process_file(fname): guard_stack.pop() lnum = fileinput.filelineno() - process_line(fname, lnum, line, guard_stack) + process_line(fname, lnum, line, guard_stack, pattern) if guard_stack: print('warning: {fname}: unbalanced preprocessor conditional ' @@ -147,8 +161,8 @@ def process_file(fname): for root, _, files in os.walk(os.path.join(PROJECT_DIR, 'jerry-core')): for fname in files: if (fname.endswith('.c') or fname.endswith('.h')) \ - and fname != 'lit-magic-strings.inc.h': - process_file(os.path.join(root, fname)) + and fname != inc_h_filename: + process_file(os.path.join(root, fname), pattern) if debug: print('debug: magic string references: {dump}' @@ -202,7 +216,7 @@ def guards_to_str(guards): for guard in sorted(guards)) -def generate_header(gen_file): +def generate_header(gen_file, ini_path): header = \ """/* Copyright JS Foundation and other contributors, http://js.foundation * @@ -221,11 +235,11 @@ def generate_header(gen_file): /* This file is automatically generated by the %s script * from %s. Do not edit! */ -""" % (os.path.basename(__file__), os.path.basename(MAGIC_STRINGS_INI)) +""" % (os.path.basename(__file__), os.path.basename(ini_path)) print(header, file=gen_file) -def generate_magic_string_defs(gen_file, defs): +def generate_magic_string_defs(gen_file, defs, def_macro): last_guards = set([()]) for str_ref, str_value, guards in defs: if last_guards != guards: @@ -234,8 +248,8 @@ def generate_magic_string_defs(gen_file, defs): if () not in guards: print('#if {guards}'.format(guards=guards_to_str(guards)), file=gen_file) - print('LIT_MAGIC_STRING_DEF ({str_ref}, {str_value})' - .format(str_ref=str_ref, str_value=json.dumps(str_value)), file=gen_file) + print('{macro} ({str_ref}, {str_value})' + .format(macro=def_macro, str_ref=str_ref, str_value=json.dumps(str_value)), file=gen_file) last_guards = guards @@ -243,7 +257,7 @@ def generate_magic_string_defs(gen_file, defs): print('#endif /* {guards} */'.format(guards=guards_to_str(last_guards)), file=gen_file) -def generate_first_magic_strings(gen_file, defs): +def generate_first_magic_strings(gen_file, defs, with_size_macro): print(file=gen_file) # empty line separator max_size = len(defs[-1][1]) @@ -260,8 +274,8 @@ def generate_first_magic_strings(gen_file, defs): elif () in guards and () not in last_guards: print('#else /* !({guards}) */'.format(guards=guards_to_str(last_guards)), file=gen_file) - print('LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE ({size}, {str_ref})' - .format(size=size, str_ref=str_ref), file=gen_file) + print('{macro} ({size}, {str_ref})' + .format(macro=with_size_macro, size=size, str_ref=str_ref), file=gen_file) if () in guards: break @@ -271,20 +285,37 @@ def generate_first_magic_strings(gen_file, defs): if () not in last_guards: print('#endif /* {guards} */'.format(guards=guards_to_str(last_guards)), file=gen_file) +def generate_magic_strings(args, ini_path, item_name, pattern, inc_h_path, def_macro, with_size_macro=None): + defs = read_magic_string_defs(args.debug, ini_path, item_name) + uses = extract_magic_string_refs(args.debug, pattern, os.path.basename(inc_h_path)) + + extended_defs = calculate_magic_string_guards(defs, uses, debug=args.debug) + + with open(inc_h_path, 'w') as gen_file: + generate_header(gen_file, ini_path) + generate_magic_string_defs(gen_file, extended_defs, def_macro) + if with_size_macro: + generate_first_magic_strings(gen_file, extended_defs, with_size_macro) + def main(): parser = argparse.ArgumentParser(description='lit-magic-strings.inc.h generator') parser.add_argument('--debug', action='store_true', help='enable debug output') args = parser.parse_args() - defs = read_magic_string_defs(debug=args.debug) - uses = extract_magic_string_refs(debug=args.debug) - - extended_defs = calculate_magic_string_guards(defs, uses, debug=args.debug) - - with open(MAGIC_STRINGS_INC_H, 'w') as gen_file: - generate_header(gen_file) - generate_magic_string_defs(gen_file, extended_defs) - generate_first_magic_strings(gen_file, extended_defs) + generate_magic_strings(args, + MAGIC_STRINGS_INI, + 'LIT_MAGIC_STRINGS', + 'LIT_MAGIC_STRING', + MAGIC_STRINGS_INC_H, + 'LIT_MAGIC_STRING_DEF', + 'LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE') + + generate_magic_strings(args, + ECMA_ERRORS_INI, + 'ECMA_ERROR_MESSAGES', + 'ECMA_ERR', + ECMA_ERRORS_INC_H, + 'ECMA_ERROR_DEF') subprocess.call([FORMAT_SCRIPT, '--fix']) diff --git a/tools/run-tests.py b/tools/run-tests.py index dd5cf68aaa..2012f2db62 100755 --- a/tools/run-tests.py +++ b/tools/run-tests.py @@ -192,7 +192,7 @@ def get_arguments(): help='Run format check') parser.add_argument('--check-license', action='store_true', help='Run license check') - parser.add_argument('--check-magic-strings', action='store_true', + parser.add_argument('--check-strings', action='store_true', help='Run "magic string source code generator should be executed" check') parser.add_argument('--build-debug', action='store_true', help='Build debug version jerryscript') @@ -506,7 +506,7 @@ def main(options): Check(options.check_pylint, run_check, [settings.PYLINT_SCRIPT]), Check(options.check_format, run_check, [settings.FORMAT_SCRIPT]), Check(options.check_license, run_check, [settings.LICENSE_SCRIPT]), - Check(options.check_magic_strings, run_check, [settings.MAGIC_STRINGS_SCRIPT]), + Check(options.check_strings, run_check, [settings.STRINGS_SCRIPT]), Check(options.jerry_debugger, run_jerry_debugger_tests, options), Check(options.jerry_tests, run_jerry_tests, options), Check(options.test262 or options.test262_es2015 or options.test262_esnext, run_test262_test_suite, options), diff --git a/tools/settings.py b/tools/settings.py index 095b52b1d0..5e48d89a2f 100755 --- a/tools/settings.py +++ b/tools/settings.py @@ -28,7 +28,7 @@ DEBUGGER_TEST_RUNNER_SCRIPT = path.join(TOOLS_DIR, 'runners/run-debugger-test.sh') DOXYGEN_SCRIPT = path.join(TOOLS_DIR, 'check-doxygen.sh') LICENSE_SCRIPT = path.join(TOOLS_DIR, 'check-license.py') -MAGIC_STRINGS_SCRIPT = path.join(TOOLS_DIR, 'check-magic-strings.sh') +STRINGS_SCRIPT = path.join(TOOLS_DIR, 'check-strings.sh') PYLINT_SCRIPT = path.join(TOOLS_DIR, 'check-pylint.sh') SIGNED_OFF_SCRIPT = path.join(TOOLS_DIR, 'check-signed-off.sh') TEST_RUNNER_SCRIPT = path.join(TOOLS_DIR, 'runners/run-test-suite.py')