diff options
author | Virag Orkenyi <orkvi@inf.u-szeged.hu> | 2020-09-24 10:50:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-24 10:50:12 +0200 |
commit | be180ba159d0c1740fd923d6ed02359924c22e1a (patch) | |
tree | a2336d637ec60533e29d98fab8e9f9b77010add3 | |
parent | 3c723c9bc1aec08a54bc44bba7987e4324f440e4 (diff) |
Delete ECMA_OP_TO_NUMBER_TRY_CATCH macro (#4229)
JerryScript-DCO-1.0-Signed-off-by: Virag Orkenyi orkvi@inf.u-szeged.hu
52 files changed, 67 insertions, 143 deletions
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 c9cb3479..a6038cc3 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-arraybuffer-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-arraybuffer-prototype.c @@ -23,7 +23,6 @@ #include "ecma-helpers.h" #include "ecma-objects.h" #include "ecma-arraybuffer-object.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #include "jrt-libc-includes.h" diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-arraybuffer.c b/jerry-core/ecma/builtin-objects/ecma-builtin-arraybuffer.c index 861643a8..9dc0a8e9 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-arraybuffer.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-arraybuffer.c @@ -20,7 +20,6 @@ #include "ecma-helpers.h" #include "ecma-arraybuffer-object.h" #include "ecma-dataview-object.h" -#include "ecma-try-catch-macro.h" #include "ecma-typedarray-object.h" #include "jrt.h" diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-boolean.c b/jerry-core/ecma/builtin-objects/ecma-builtin-boolean.c index 7b6a08ce..388f145f 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-boolean.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-boolean.c @@ -22,7 +22,6 @@ #include "ecma-globals.h" #include "ecma-helpers.h" #include "ecma-objects.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #if ENABLED (JERRY_BUILTIN_BOOLEAN) 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 41c3e2be..6fe28418 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.c @@ -24,7 +24,6 @@ #include "ecma-helpers.h" #include "ecma-objects.h" #include "ecma-objects-general.h" -#include "ecma-try-catch-macro.h" #if ENABLED (JERRY_BUILTIN_DATE) @@ -622,16 +621,16 @@ ecma_builtin_date_prototype_dispatch_routine (uint16_t builtin_routine_id, /**< if (builtin_routine_id == ECMA_DATE_PROTOTYPE_SET_TIME) { - ecma_value_t ret_value = ECMA_VALUE_EMPTY; + ecma_number_t time_num; - /* 1. */ - ECMA_OP_TO_NUMBER_TRY_CATCH (time_num, arguments_list[0], ret_value); - *prim_value_p = ecma_date_time_clip (time_num); + if (ECMA_IS_VALUE_ERROR (ecma_op_to_number (arguments_list[0], &time_num))) + { + return ECMA_VALUE_ERROR; + } - ret_value = ecma_make_number_value (time_num); - ECMA_OP_TO_NUMBER_FINALIZE (time_num); + *prim_value_p = ecma_date_time_clip (time_num); - return ret_value; + return ecma_make_number_value (time_num); } if (builtin_routine_id <= ECMA_DATE_PROTOTYPE_SET_UTC_MILLISECONDS) 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 1d217cb2..cfc0d4ad 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-error-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-error-prototype.c @@ -23,7 +23,6 @@ #include "lit-char-helpers.h" #include "ecma-objects.h" #include "ecma-string-object.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #include "lit-magic-strings.h" diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-error.c b/jerry-core/ecma/builtin-objects/ecma-builtin-error.c index b3c41b7a..78e132eb 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-error.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-error.c @@ -22,7 +22,6 @@ #include "ecma-helpers.h" #include "ecma-builtin-helpers.h" #include "ecma-objects.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #define ECMA_BUILTINS_INTERNAL diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-evalerror-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-evalerror-prototype.c index e9efbf4b..3b288048 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-evalerror-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-evalerror-prototype.c @@ -22,7 +22,6 @@ #include "ecma-helpers.h" #include "ecma-objects.h" #include "ecma-string-object.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #if ENABLED (JERRY_BUILTIN_ERRORS) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-evalerror.c b/jerry-core/ecma/builtin-objects/ecma-builtin-evalerror.c index 5fecc165..7fd168fd 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-evalerror.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-evalerror.c @@ -22,7 +22,6 @@ #include "ecma-helpers.h" #include "ecma-builtin-helpers.h" #include "ecma-objects.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #if ENABLED (JERRY_BUILTIN_ERRORS) 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 5a363358..d71e44d0 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-function-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-function-prototype.c @@ -24,7 +24,6 @@ #include "ecma-function-object.h" #include "ecma-objects.h" #include "ecma-proxy-object.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #include "ecma-builtin-function-prototype.h" diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-function.c b/jerry-core/ecma/builtin-objects/ecma-builtin-function.c index 258899c5..562fab2f 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-function.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-function.c @@ -20,7 +20,6 @@ #include "ecma-gc.h" #include "ecma-function-object.h" #include "ecma-lex-env.h" -#include "ecma-try-catch-macro.h" #include "js-parser.h" #include "lit-magic-strings.h" diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-global.c b/jerry-core/ecma/builtin-objects/ecma-builtin-global.c index e2f97678..0f29091b 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-global.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-global.c @@ -21,7 +21,6 @@ #include "ecma-gc.h" #include "ecma-globals.h" #include "ecma-helpers.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #include "lit-char-helpers.h" #include "lit-magic-strings.h" diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-date.c b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-date.c index 467df302..fa372218 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-date.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-date.c @@ -21,7 +21,6 @@ #include "ecma-globals.h" #include "ecma-helpers.h" #include "ecma-objects.h" -#include "ecma-try-catch-macro.h" #include "lit-char-helpers.h" #if ENABLED (JERRY_BUILTIN_DATE) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-error.c b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-error.c index 66866c8d..dd579147 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-error.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-error.c @@ -22,7 +22,6 @@ #include "ecma-helpers.h" #include "ecma-builtin-helpers.h" #include "ecma-objects.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" /** \addtogroup ecma ECMA diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.c b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.c index 4da28306..05193772 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.c @@ -25,7 +25,6 @@ #include "ecma-helpers.h" #include "jmem.h" #include "ecma-objects.h" -#include "ecma-try-catch-macro.h" #include "lit-magic-strings.h" #include "lit-char-helpers.h" diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-math.c b/jerry-core/ecma/builtin-objects/ecma-builtin-math.c index 4a2e66f4..7ccea61e 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-math.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-math.c @@ -25,7 +25,6 @@ #include "ecma-number-arithmetic.h" #include "ecma-objects.h" #include "ecma-objects-general.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #include "jrt-libc-includes.h" 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 f44c0ea1..3bfb2fa9 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-number-prototype.c @@ -24,7 +24,6 @@ #include "ecma-helpers.h" #include "ecma-objects.h" #include "ecma-string-object.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #include "jrt-libc-includes.h" #include "lit-char-helpers.h" diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-number.c b/jerry-core/ecma/builtin-objects/ecma-builtin-number.c index d48d253b..3723cff9 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-number.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-number.c @@ -25,7 +25,6 @@ #include "ecma-helpers.h" #include "ecma-number-object.h" #include "ecma-objects.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #if ENABLED (JERRY_BUILTIN_NUMBER) 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 20cb8066..6981d8ca 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-object-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-object-prototype.c @@ -26,7 +26,6 @@ #include "ecma-objects.h" #include "ecma-proxy-object.h" #include "ecma-string-object.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #define ECMA_BUILTINS_INTERNAL diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-rangeerror-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-rangeerror-prototype.c index 194258bc..8fbfd406 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-rangeerror-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-rangeerror-prototype.c @@ -22,7 +22,6 @@ #include "ecma-helpers.h" #include "ecma-objects.h" #include "ecma-string-object.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #if ENABLED (JERRY_BUILTIN_ERRORS) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-rangeerror.c b/jerry-core/ecma/builtin-objects/ecma-builtin-rangeerror.c index bca3803d..65a381e0 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-rangeerror.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-rangeerror.c @@ -22,7 +22,6 @@ #include "ecma-helpers.h" #include "ecma-builtin-helpers.h" #include "ecma-objects.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #if ENABLED (JERRY_BUILTIN_ERRORS) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-referenceerror-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-referenceerror-prototype.c index 0ab1e8e3..af657830 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-referenceerror-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-referenceerror-prototype.c @@ -22,7 +22,6 @@ #include "ecma-helpers.h" #include "ecma-objects.h" #include "ecma-string-object.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #if ENABLED (JERRY_BUILTIN_ERRORS) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-referenceerror.c b/jerry-core/ecma/builtin-objects/ecma-builtin-referenceerror.c index 71146a86..c34739da 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-referenceerror.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-referenceerror.c @@ -22,7 +22,6 @@ #include "ecma-helpers.h" #include "ecma-builtin-helpers.h" #include "ecma-objects.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #if ENABLED (JERRY_BUILTIN_ERRORS) 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 3aaab571..c091546e 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.c @@ -25,7 +25,6 @@ #include "ecma-helpers.h" #include "ecma-objects.h" #include "ecma-regexp-object.h" -#include "ecma-try-catch-macro.h" #include "lit-char-helpers.h" #if ENABLED (JERRY_BUILTIN_REGEXP) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c index 5d220dea..7403fe4b 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp.c @@ -22,7 +22,6 @@ #include "jcontext.h" #include "ecma-objects.h" #include "ecma-regexp-object.h" -#include "ecma-try-catch-macro.h" #if ENABLED (JERRY_BUILTIN_REGEXP) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-string.c b/jerry-core/ecma/builtin-objects/ecma-builtin-string.c index fab14249..8a338f9b 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-string.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-string.c @@ -26,7 +26,6 @@ #if ENABLED (JERRY_ESNEXT) #include "ecma-symbol-object.h" #endif /* ENABLED (JERRY_ESNEXT) */ -#include "ecma-try-catch-macro.h" #include "jrt.h" #if ENABLED (JERRY_BUILTIN_STRING) @@ -69,9 +68,9 @@ ecma_builtin_string_object_from_char_code (ecma_value_t this_arg, /**< 'this' ar return ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY); } - ecma_value_t ret_value = ECMA_VALUE_EMPTY; - ecma_string_t *ret_string_p = NULL; lit_utf8_size_t utf8_buf_size = args_number * LIT_CESU8_MAX_BYTES_IN_CODE_UNIT; + ecma_string_t *ret_string_p = NULL; + bool isError = false; JMEM_DEFINE_LOCAL_ARRAY (utf8_buf_p, utf8_buf_size, @@ -80,10 +79,16 @@ ecma_builtin_string_object_from_char_code (ecma_value_t this_arg, /**< 'this' ar lit_utf8_size_t utf8_buf_used = 0; for (uint32_t arg_index = 0; - arg_index < args_number && ecma_is_value_empty (ret_value); + arg_index < args_number; arg_index++) { - ECMA_OP_TO_NUMBER_TRY_CATCH (arg_num, args[arg_index], ret_value); + ecma_number_t arg_num; + + if (ECMA_IS_VALUE_ERROR (ecma_op_to_number (args[arg_index], &arg_num))) + { + isError = true; + break; + } uint32_t uint32_char_code = ecma_number_to_uint32 (arg_num); ecma_char_t code_unit = (uint16_t) uint32_char_code; @@ -91,23 +96,16 @@ ecma_builtin_string_object_from_char_code (ecma_value_t this_arg, /**< 'this' ar JERRY_ASSERT (utf8_buf_used <= utf8_buf_size - LIT_UTF8_MAX_BYTES_IN_CODE_UNIT); utf8_buf_used += lit_code_unit_to_utf8 (code_unit, utf8_buf_p + utf8_buf_used); JERRY_ASSERT (utf8_buf_used <= utf8_buf_size); - - ECMA_OP_TO_NUMBER_FINALIZE (arg_num); } - if (ecma_is_value_empty (ret_value)) + if (!isError) { ret_string_p = ecma_new_ecma_string_from_utf8 (utf8_buf_p, utf8_buf_used); } JMEM_FINALIZE_LOCAL_ARRAY (utf8_buf_p); - if (ecma_is_value_empty (ret_value)) - { - ret_value = ecma_make_string_value (ret_string_p); - } - - return ret_value; + return isError ? ECMA_VALUE_ERROR : ecma_make_string_value (ret_string_p); } /* ecma_builtin_string_object_from_char_code */ #if ENABLED (JERRY_ESNEXT) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-symbol-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-symbol-prototype.c index aa33dcb2..9240c6b5 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-symbol-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-symbol-prototype.c @@ -22,7 +22,6 @@ #include "ecma-helpers.h" #include "ecma-objects.h" #include "ecma-symbol-object.h" - #include "ecma-try-catch-macro.h" #include "jrt.h" #if ENABLED (JERRY_ESNEXT) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-symbol.c b/jerry-core/ecma/builtin-objects/ecma-builtin-symbol.c index f402c898..d8cd3529 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-symbol.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-symbol.c @@ -23,7 +23,6 @@ #include "ecma-objects.h" #include "ecma-symbol-object.h" #include "ecma-literal-storage.h" - #include "ecma-try-catch-macro.h" #include "jcontext.h" #include "jrt.h" diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-syntaxerror-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-syntaxerror-prototype.c index d04ec0c9..3480c8fd 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-syntaxerror-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-syntaxerror-prototype.c @@ -22,7 +22,6 @@ #include "ecma-helpers.h" #include "ecma-objects.h" #include "ecma-string-object.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #if ENABLED (JERRY_BUILTIN_ERRORS) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-syntaxerror.c b/jerry-core/ecma/builtin-objects/ecma-builtin-syntaxerror.c index 2c462ceb..ee5796b7 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-syntaxerror.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-syntaxerror.c @@ -22,7 +22,6 @@ #include "ecma-helpers.h" #include "ecma-builtin-helpers.h" #include "ecma-objects.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #if ENABLED (JERRY_BUILTIN_ERRORS) 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 21eba97b..98a68f03 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 @@ -21,7 +21,6 @@ #include "ecma-globals.h" #include "ecma-helpers.h" #include "ecma-objects.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #define ECMA_BUILTINS_INTERNAL diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-typeerror-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-typeerror-prototype.c index 274a8283..ab96a5e5 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-typeerror-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-typeerror-prototype.c @@ -22,7 +22,6 @@ #include "ecma-helpers.h" #include "ecma-objects.h" #include "ecma-string-object.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #if ENABLED (JERRY_BUILTIN_ERRORS) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-typeerror.c b/jerry-core/ecma/builtin-objects/ecma-builtin-typeerror.c index c29bb0c6..9fd2b144 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-typeerror.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-typeerror.c @@ -22,7 +22,6 @@ #include "ecma-helpers.h" #include "ecma-builtin-helpers.h" #include "ecma-objects.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #if ENABLED (JERRY_BUILTIN_ERRORS) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-urierror-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-urierror-prototype.c index d03c2dba..4f97be4f 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-urierror-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-urierror-prototype.c @@ -22,7 +22,6 @@ #include "ecma-helpers.h" #include "ecma-objects.h" #include "ecma-string-object.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #if ENABLED (JERRY_BUILTIN_ERRORS) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-urierror.c b/jerry-core/ecma/builtin-objects/ecma-builtin-urierror.c index 911be2bc..d2ce3200 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-urierror.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-urierror.c @@ -22,7 +22,6 @@ #include "ecma-helpers.h" #include "ecma-builtin-helpers.h" #include "ecma-objects.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" #if ENABLED (JERRY_BUILTIN_ERRORS) 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 d52d4110..22971a11 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray.c @@ -20,7 +20,6 @@ #include "ecma-globals.h" #include "ecma-helpers.h" #include "ecma-typedarray-object.h" -#include "ecma-try-catch-macro.h" #include "ecma-function-object.h" #include "jrt.h" diff --git a/jerry-core/ecma/operations/ecma-arraybuffer-object.c b/jerry-core/ecma/operations/ecma-arraybuffer-object.c index e81ca9a6..58a1a148 100644 --- a/jerry-core/ecma/operations/ecma-arraybuffer-object.c +++ b/jerry-core/ecma/operations/ecma-arraybuffer-object.c @@ -14,7 +14,6 @@ */ #include "ecma-arraybuffer-object.h" -#include "ecma-try-catch-macro.h" #include "ecma-typedarray-object.h" #include "ecma-objects.h" #include "ecma-builtins.h" diff --git a/jerry-core/ecma/operations/ecma-comparison.c b/jerry-core/ecma/operations/ecma-comparison.c index 95d6acf8..c795745a 100644 --- a/jerry-core/ecma/operations/ecma-comparison.c +++ b/jerry-core/ecma/operations/ecma-comparison.c @@ -18,7 +18,6 @@ #include "ecma-conversion.h" #include "ecma-globals.h" #include "ecma-objects.h" -#include "ecma-try-catch-macro.h" #include "jrt.h" /** \addtogroup ecma ECMA @@ -388,8 +387,19 @@ ecma_op_abstract_relational_compare (ecma_value_t x, /**< first operand */ /* 3. */ /* a. */ - ECMA_OP_TO_NUMBER_TRY_CATCH (nx, px, ret_value); - ECMA_OP_TO_NUMBER_TRY_CATCH (ny, py, ret_value); + + ecma_number_t nx; + ecma_number_t ny; + + if (ECMA_IS_VALUE_ERROR (ecma_op_to_number (px, &nx))) + { + return ECMA_VALUE_ERROR; + } + + if (ECMA_IS_VALUE_ERROR (ecma_op_to_number (py, &ny))) + { + return ECMA_VALUE_ERROR; + } /* b. */ if (ecma_number_is_nan (nx) @@ -461,9 +471,6 @@ ecma_op_abstract_relational_compare (ecma_value_t x, /**< first operand */ ret_value = ecma_make_boolean_value (is_x_less_than_y); } - - ECMA_OP_TO_NUMBER_FINALIZE (ny); - ECMA_OP_TO_NUMBER_FINALIZE (nx); #if ENABLED (JERRY_BUILTIN_BIGINT) } else @@ -505,7 +512,11 @@ ecma_op_abstract_relational_compare (ecma_value_t x, /**< first operand */ } else { - ECMA_OP_TO_NUMBER_TRY_CATCH (ny, py, ret_value); + ecma_number_t ny; + if (ECMA_IS_VALUE_ERROR (ecma_op_to_number (py,&ny))) + { + return ECMA_VALUE_ERROR; + } if (ecma_number_is_nan (ny)) { @@ -515,8 +526,6 @@ ecma_op_abstract_relational_compare (ecma_value_t x, /**< first operand */ { compare_result = ecma_bigint_compare_to_number (px, ny); } - - ECMA_OP_TO_NUMBER_FINALIZE (ny); } if (ret_value == ECMA_VALUE_EMPTY) diff --git a/jerry-core/ecma/operations/ecma-function-object.c b/jerry-core/ecma/operations/ecma-function-object.c index 8e22d03d..5bb4315f 100644 --- a/jerry-core/ecma/operations/ecma-function-object.c +++ b/jerry-core/ecma/operations/ecma-function-object.c @@ -28,7 +28,6 @@ #include "ecma-objects-arguments.h" #include "ecma-proxy-object.h" #include "ecma-symbol-object.h" -#include "ecma-try-catch-macro.h" #include "jcontext.h" /** \addtogroup ecma ECMA diff --git a/jerry-core/ecma/operations/ecma-get-put-value.c b/jerry-core/ecma/operations/ecma-get-put-value.c index 1667184a..6affcc33 100644 --- a/jerry-core/ecma/operations/ecma-get-put-value.c +++ b/jerry-core/ecma/operations/ecma-get-put-value.c @@ -25,7 +25,7 @@ #include "ecma-objects.h" #include "ecma-function-object.h" #include "ecma-objects-general.h" -#include "ecma-try-catch-macro.h" + #include "ecma-reference.h" /** \addtogroup ecma ECMA diff --git a/jerry-core/ecma/operations/ecma-objects-arguments.c b/jerry-core/ecma/operations/ecma-objects-arguments.c index 37ac9e8d..02a06f83 100644 --- a/jerry-core/ecma/operations/ecma-objects-arguments.c +++ b/jerry-core/ecma/operations/ecma-objects-arguments.c @@ -24,7 +24,7 @@ #include "ecma-objects.h" #include "ecma-objects-arguments.h" #include "ecma-objects-general.h" -#include "ecma-try-catch-macro.h" + #include "jrt.h" /** \addtogroup ecma ECMA diff --git a/jerry-core/ecma/operations/ecma-objects-general.c b/jerry-core/ecma/operations/ecma-objects-general.c index 0166e26d..8ebb61bf 100644 --- a/jerry-core/ecma/operations/ecma-objects-general.c +++ b/jerry-core/ecma/operations/ecma-objects-general.c @@ -23,7 +23,6 @@ #include "ecma-objects.h" #include "ecma-objects-general.h" #include "ecma-proxy-object.h" -#include "ecma-try-catch-macro.h" /** \addtogroup ecma ECMA * @{ diff --git a/jerry-core/ecma/operations/ecma-objects.c b/jerry-core/ecma/operations/ecma-objects.c index faa7ced7..0deb0210 100644 --- a/jerry-core/ecma/operations/ecma-objects.c +++ b/jerry-core/ecma/operations/ecma-objects.c @@ -32,7 +32,6 @@ #if ENABLED (JERRY_BUILTIN_TYPEDARRAY) #include "ecma-typedarray-object.h" #include "ecma-arraybuffer-object.h" -#include "ecma-try-catch-macro.h" #endif /* ENABLED (JERRY_BUILTIN_TYPEDARRAY) */ /** \addtogroup ecma ECMA diff --git a/jerry-core/ecma/operations/ecma-regexp-object.c b/jerry-core/ecma/operations/ecma-regexp-object.c index 17198b77..42db85b2 100644 --- a/jerry-core/ecma/operations/ecma-regexp-object.c +++ b/jerry-core/ecma/operations/ecma-regexp-object.c @@ -23,7 +23,6 @@ #include "ecma-objects.h" #include "ecma-function-object.h" #include "ecma-regexp-object.h" -#include "ecma-try-catch-macro.h" #include "jcontext.h" #include "jrt-libc-includes.h" #include "lit-char-helpers.h" diff --git a/jerry-core/ecma/operations/ecma-try-catch-macro.h b/jerry-core/ecma/operations/ecma-try-catch-macro.h deleted file mode 100644 index 5960ad80..00000000 --- a/jerry-core/ecma/operations/ecma-try-catch-macro.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright JS Foundation and other contributors, http://js.foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ECMA_TRY_CATCH_MACRO_H -#define ECMA_TRY_CATCH_MACRO_H - -#include "ecma-helpers.h" - -/** - * The macro defines try-block that tries to perform ToNumber operation on given value - * and checks for exceptions that might be thrown during the operation. - * - * If no exception was thrown, then code after the try-block is executed. - * Otherwise, throw-completion value is just copied to return_value. - * - * Note: - * Each ECMA_OP_TO_NUMBER_TRY_CATCH should have it's own corresponding ECMA_OP_TO_NUMBER_FINALIZE - * statement with same argument as corresponding ECMA_OP_TO_NUMBER_TRY_CATCH's first argument. - */ -#define ECMA_OP_TO_NUMBER_TRY_CATCH(num_var, value, return_value) \ - JERRY_ASSERT (return_value == ECMA_VALUE_EMPTY); \ - ecma_number_t num_var; \ - return_value = ecma_op_to_number (value, &num_var); \ - \ - if (JERRY_LIKELY (ecma_is_value_empty (return_value))) \ - { - -/** - * The macro marks end of code block that is defined by corresponding ECMA_OP_TO_NUMBER_TRY_CATCH. - * - * Note: - * Each ECMA_OP_TO_NUMBER_TRY_CATCH should be followed by ECMA_OP_TO_NUMBER_FINALIZE - * with same argument as corresponding ECMA_OP_TO_NUMBER_TRY_CATCH's first argument. - */ -#define ECMA_OP_TO_NUMBER_FINALIZE(num_var) } - -#endif /* !ECMA_TRY_CATCH_MACRO_H */ diff --git a/jerry-core/ecma/operations/ecma-typedarray-object.c b/jerry-core/ecma/operations/ecma-typedarray-object.c index 198f93bd..49f5f6a6 100644 --- a/jerry-core/ecma/operations/ecma-typedarray-object.c +++ b/jerry-core/ecma/operations/ecma-typedarray-object.c @@ -22,7 +22,6 @@ #include "ecma-bigint.h" #include "ecma-big-uint.h" #include "ecma-builtin-helpers.h" -#include "ecma-try-catch-macro.h" #include "ecma-objects.h" #include "ecma-builtins.h" #include "ecma-exceptions.h" @@ -1345,8 +1344,12 @@ ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, /**< the arg li return ecma_raise_type_error (ECMA_ERR_MSG ("length argument is undefined")); } - ECMA_OP_TO_NUMBER_TRY_CATCH (num, arguments_list_p[0], ret); + ecma_number_t num; + if (ECMA_IS_VALUE_ERROR (ecma_op_to_number (arguments_list_p[0], &num))) + { + return ECMA_VALUE_ERROR; + } uint32_t length = ecma_number_to_uint32 (num); if (num != ((ecma_number_t) length)) @@ -1361,8 +1364,6 @@ ecma_op_create_typedarray (const ecma_value_t *arguments_list_p, /**< the arg li element_size_shift, typedarray_id); } - - ECMA_OP_TO_NUMBER_FINALIZE (num); } else if (ecma_is_value_object (arguments_list_p[0])) { diff --git a/jerry-core/parser/regexp/re-compiler.c b/jerry-core/parser/regexp/re-compiler.c index 0202299f..899f8db1 100644 --- a/jerry-core/parser/regexp/re-compiler.c +++ b/jerry-core/parser/regexp/re-compiler.c @@ -16,7 +16,6 @@ #include "ecma-exceptions.h" #include "ecma-helpers.h" #include "ecma-regexp-object.h" -#include "ecma-try-catch-macro.h" #include "lit-char-helpers.h" #include "jcontext.h" #include "jrt-libc-includes.h" diff --git a/jerry-core/parser/regexp/re-parser.c b/jerry-core/parser/regexp/re-parser.c index 25ff6536..54b7c140 100644 --- a/jerry-core/parser/regexp/re-parser.c +++ b/jerry-core/parser/regexp/re-parser.c @@ -15,7 +15,6 @@ #include "ecma-exceptions.h" #include "ecma-globals.h" -#include "ecma-try-catch-macro.h" #include "jcontext.h" #include "jrt-libc-includes.h" #include "lit-char-helpers.h" diff --git a/jerry-core/vm/opcodes-ecma-arithmetics.c b/jerry-core/vm/opcodes-ecma-arithmetics.c index 1bed3d82..c9fad58f 100644 --- a/jerry-core/vm/opcodes-ecma-arithmetics.c +++ b/jerry-core/vm/opcodes-ecma-arithmetics.c @@ -20,7 +20,6 @@ #include "ecma-helpers.h" #include "ecma-number-arithmetic.h" #include "ecma-objects.h" -#include "ecma-try-catch-macro.h" #include "opcodes.h" #include "jrt-libc-includes.h" @@ -61,7 +60,12 @@ do_number_arithmetic (number_arithmetic_op op, /**< number arithmetic operation if (JERRY_LIKELY (!ecma_is_value_bigint (left_value))) { #endif /* ENABLED (JERRY_BUILTIN_BIGINT) */ - ECMA_OP_TO_NUMBER_TRY_CATCH (right_number, right_value, ret_value); + + ecma_number_t right_number; + if (ECMA_IS_VALUE_ERROR (ecma_op_to_number (right_value, &right_number))) + { + return ECMA_VALUE_ERROR; + } ecma_number_t result = ECMA_NUMBER_ZERO; @@ -97,8 +101,6 @@ do_number_arithmetic (number_arithmetic_op op, /**< number arithmetic operation } ret_value = ecma_make_number_value (result); - - ECMA_OP_TO_NUMBER_FINALIZE (right_number); #if ENABLED (JERRY_BUILTIN_BIGINT) } else @@ -246,13 +248,17 @@ opfunc_addition (ecma_value_t left_value, /**< left value */ #endif /* ENABLED (JERRY_BUILTIN_BIGINT) */ else { - ECMA_OP_TO_NUMBER_TRY_CATCH (num_left, left_value, ret_value); - ECMA_OP_TO_NUMBER_TRY_CATCH (num_right, right_value, ret_value); - - ret_value = ecma_make_number_value (num_left + num_right); - - ECMA_OP_TO_NUMBER_FINALIZE (num_right); - ECMA_OP_TO_NUMBER_FINALIZE (num_left); + ecma_number_t num_left; + ecma_number_t num_right; + if (!ECMA_IS_VALUE_ERROR (ecma_op_to_number (left_value, &num_left)) + && !ECMA_IS_VALUE_ERROR (ecma_op_to_number (right_value, &num_right))) + { + ret_value = ecma_make_number_value (num_left + num_right); + } + else + { + ret_value = ECMA_VALUE_ERROR; + } } if (free_left_value) diff --git a/jerry-core/vm/opcodes-ecma-bitwise.c b/jerry-core/vm/opcodes-ecma-bitwise.c index 63179d40..584b7e44 100644 --- a/jerry-core/vm/opcodes-ecma-bitwise.c +++ b/jerry-core/vm/opcodes-ecma-bitwise.c @@ -19,7 +19,6 @@ #include "ecma-exceptions.h" #include "ecma-helpers.h" #include "ecma-objects.h" -#include "ecma-try-catch-macro.h" #include "opcodes.h" /** \addtogroup vm Virtual machine @@ -62,7 +61,12 @@ do_number_bitwise_logic (number_bitwise_logic_op op, /**< number bitwise logic o if (JERRY_LIKELY (!ecma_is_value_bigint (left_value))) { #endif /* ENABLED (JERRY_BUILTIN_BIGINT) */ - ECMA_OP_TO_NUMBER_TRY_CATCH (right_number, right_value, ret_value); + ecma_number_t right_number; + + if (ECMA_IS_VALUE_ERROR (ecma_op_to_number (right_value, &right_number))) + { + return ECMA_VALUE_ERROR; + } ecma_number_t result = ECMA_NUMBER_ZERO; uint32_t right_uint32 = ecma_number_to_uint32 (right_number); @@ -109,7 +113,6 @@ do_number_bitwise_logic (number_bitwise_logic_op op, /**< number bitwise logic o ret_value = ecma_make_number_value (result); - ECMA_OP_TO_NUMBER_FINALIZE (num_right); #if ENABLED (JERRY_BUILTIN_BIGINT) } else diff --git a/jerry-core/vm/opcodes-ecma-relational-equality.c b/jerry-core/vm/opcodes-ecma-relational-equality.c index 328c8988..f310439a 100644 --- a/jerry-core/vm/opcodes-ecma-relational-equality.c +++ b/jerry-core/vm/opcodes-ecma-relational-equality.c @@ -19,7 +19,6 @@ #include "ecma-function-object.h" #include "ecma-helpers.h" #include "ecma-objects.h" -#include "ecma-try-catch-macro.h" #include "opcodes.h" /** \addtogroup vm Virtual machine diff --git a/jerry-core/vm/opcodes.c b/jerry-core/vm/opcodes.c index edf83623..88c05c7c 100644 --- a/jerry-core/vm/opcodes.c +++ b/jerry-core/vm/opcodes.c @@ -28,7 +28,6 @@ #include "ecma-objects.h" #include "ecma-promise-object.h" #include "ecma-proxy-object.h" -#include "ecma-try-catch-macro.h" #include "jcontext.h" #include "opcodes.h" #include "vm-defines.h" diff --git a/jerry-core/vm/vm.c b/jerry-core/vm/vm.c index 0e7ae6dc..94a07a17 100644 --- a/jerry-core/vm/vm.c +++ b/jerry-core/vm/vm.c @@ -33,7 +33,6 @@ #include "ecma-objects-general.h" #include "ecma-promise-object.h" #include "ecma-regexp-object.h" -#include "ecma-try-catch-macro.h" #include "jcontext.h" #include "opcodes.h" #include "vm.h" |