From c4b0cd2196adc3690a34284adf5a518664d52339 Mon Sep 17 00:00:00 2001 From: Andrey Shitov Date: Mon, 29 Jun 2015 18:37:27 +0300 Subject: [PATCH] Change ecma_length_t and jerry_api_length_t from uint16_t to uint32_t. JerryScript-DCO-1.0-Signed-off-by: Andrey Shitov a.shitov@samsung.com --- jerry-core/ecma/base/ecma-globals.h | 6 ++-- jerry-core/ecma/base/ecma-helpers-string.cpp | 18 +++++------ .../base/ecma-helpers-values-collection.cpp | 20 ++++++------- jerry-core/ecma/base/ecma-helpers.h | 2 +- .../ecma-builtin-error-prototype.cpp | 10 +++---- .../builtin-objects/ecma-builtin-global.cpp | 30 +++++++++---------- .../ecma-builtin-regexp-prototype.cpp | 4 +-- .../ecma-builtin-string-prototype.cpp | 5 ---- .../ecma/builtin-objects/ecma-builtins.cpp | 2 +- jerry-core/ecma/operations/ecma-eval.cpp | 4 +-- .../operations/ecma-objects-arguments.cpp | 4 +-- .../ecma/operations/ecma-regexp-object.cpp | 8 ++--- .../ecma/operations/ecma-string-object.cpp | 6 ++-- jerry-core/jerry-api.h | 4 +-- jerry-core/jerry.cpp | 4 +-- jerry-core/lit/lit-globals.h | 2 +- jerry-core/lit/lit-literal.cpp | 2 +- jerry-core/lit/lit-literal.h | 3 +- jerry-core/parser/regexp/re-compiler.cpp | 4 +-- jerry-core/vm/opcodes-native-call.cpp | 5 ++-- jerry-core/vm/opcodes.cpp | 4 +-- main-linux.cpp | 2 +- tests/unit/test-api.cpp | 6 ++-- 23 files changed, 74 insertions(+), 81 deletions(-) diff --git a/jerry-core/ecma/base/ecma-globals.h b/jerry-core/ecma/base/ecma-globals.h index e41689c70..fc95ec8bb 100644 --- a/jerry-core/ecma/base/ecma-globals.h +++ b/jerry-core/ecma/base/ecma-globals.h @@ -696,12 +696,12 @@ typedef double ecma_number_t; */ typedef struct { - /** Compressed pointer to next chunk with collection's data */ - mem_cpointer_t next_chunk_cp; - /** Number of elements in the collection */ ecma_length_t unit_number; + /** Compressed pointer to next chunk with collection's data */ + mem_cpointer_t next_chunk_cp; + /** Place for the collection's data */ uint8_t data[ sizeof (uint64_t) - sizeof (mem_cpointer_t) - sizeof (ecma_length_t) ]; } ecma_collection_header_t; diff --git a/jerry-core/ecma/base/ecma-helpers-string.cpp b/jerry-core/ecma/base/ecma-helpers-string.cpp index 1640b9ade..d8e20f832 100644 --- a/jerry-core/ecma/base/ecma-helpers-string.cpp +++ b/jerry-core/ecma/base/ecma-helpers-string.cpp @@ -467,7 +467,7 @@ ecma_new_ecma_string_from_uint32 (uint32_t uint32_number) /**< UInt32-represente ssize_t chars_copied = ecma_uint32_to_string (uint32_number, char_buf, ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32); - JERRY_ASSERT ((ecma_length_t) chars_copied == chars_copied); + JERRY_ASSERT ((ssize_t) ((ecma_length_t) chars_copied) == chars_copied); JERRY_ASSERT (string_desc_p->hash == ecma_chars_buffer_calc_hash_last_chars (char_buf, ecma_zt_string_length (char_buf))); @@ -906,7 +906,7 @@ ecma_string_to_number (const ecma_string_t *str_p) /**< ecma-string */ case ECMA_STRING_CONTAINER_MAGIC_STRING: case ECMA_STRING_CONTAINER_MAGIC_STRING_EX: { - const int32_t string_len = ecma_string_get_length (str_p); + const ecma_length_t string_len = ecma_string_get_length (str_p); const size_t string_buf_size = (size_t) (string_len + 1) * sizeof (ecma_char_t); ecma_char_t *str_buffer_p = (ecma_char_t*) mem_heap_alloc_block (string_buf_size, MEM_HEAP_ALLOC_SHORT_TERM); @@ -948,7 +948,7 @@ ecma_string_to_zt_string (const ecma_string_t *string_desc_p, /**< ecma-string d JERRY_ASSERT (buffer_p != NULL || buffer_size == 0); JERRY_ASSERT (buffer_size >= 0); - ssize_t required_buffer_size = ((ecma_string_get_length (string_desc_p) + 1) * ((ssize_t) sizeof (ecma_char_t))); + ssize_t required_buffer_size = (ssize_t) ((ecma_string_get_length (string_desc_p) + 1) * sizeof (ecma_char_t)); if (required_buffer_size > buffer_size || buffer_size == 0) @@ -990,7 +990,7 @@ ecma_string_to_zt_string (const ecma_string_t *string_desc_p, /**< ecma-string d ecma_length_t length = ecma_number_to_zt_string (*num_p, buffer_p, buffer_size); - JERRY_ASSERT (required_buffer_size == (length + 1) * ((ssize_t) sizeof (ecma_char_t))); + JERRY_ASSERT (required_buffer_size == (ssize_t) ((length + 1) * sizeof (ecma_char_t))); break; } @@ -1093,15 +1093,15 @@ ecma_compare_ecma_strings_longpath (const ecma_string_t *string1_p, /* ecma-stri } } - const int32_t string1_len = ecma_string_get_length (string1_p); - const int32_t string2_len = ecma_string_get_length (string2_p); + const ecma_length_t string1_len = ecma_string_get_length (string1_p); + const ecma_length_t string2_len = ecma_string_get_length (string2_p); if (string1_len != string2_len) { return false; } - const int32_t strings_len = string1_len; + const ecma_length_t strings_len = string1_len; if (strings_len == 0) { @@ -1348,7 +1348,7 @@ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma- * * @return number of characters in the string */ -int32_t +ecma_length_t ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */ { ecma_string_container_t container = (ecma_string_container_t) string_p->container; @@ -1385,7 +1385,7 @@ ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */ 1000000000u }; - int32_t length = 1; + ecma_length_t length = 1; while (length < max_uint32_len && uint32_number >= nums_with_ascending_length[length]) diff --git a/jerry-core/ecma/base/ecma-helpers-values-collection.cpp b/jerry-core/ecma/base/ecma-helpers-values-collection.cpp index 6812bd8d6..1826abbdc 100644 --- a/jerry-core/ecma/base/ecma-helpers-values-collection.cpp +++ b/jerry-core/ecma/base/ecma-helpers-values-collection.cpp @@ -191,20 +191,20 @@ ecma_collection_iterator_next (ecma_collection_iterator_t *iterator_p) /**< cont { JERRY_ASSERT (iterator_p->current_index == 0); iterator_p->current_value_p = (ecma_value_t*) iterator_p->header_p->data; - - return true; } - - if (iterator_p->current_index + 1 == iterator_p->header_p->unit_number) + else { - return false; + if (iterator_p->current_index + 1 == iterator_p->header_p->unit_number) + { + return false; + } + + JERRY_ASSERT (iterator_p->current_index + 1 < iterator_p->header_p->unit_number); + + iterator_p->current_index++; + iterator_p->current_value_p++; } - JERRY_ASSERT (iterator_p->current_index + 1 < iterator_p->header_p->unit_number); - - iterator_p->current_index++; - iterator_p->current_value_p++; - if (iterator_p->current_value_p == iterator_p->current_chunk_end_p) { ecma_collection_chunk_t *next_chunk_p = ECMA_GET_POINTER (ecma_collection_chunk_t, diff --git a/jerry-core/ecma/base/ecma-helpers.h b/jerry-core/ecma/base/ecma-helpers.h index 0c383ed0f..1e9ab0bd9 100644 --- a/jerry-core/ecma/base/ecma-helpers.h +++ b/jerry-core/ecma/base/ecma-helpers.h @@ -133,7 +133,7 @@ extern bool ecma_compare_ecma_strings (const ecma_string_t *string1_p, const ecma_string_t *string2_p); extern bool ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, const ecma_string_t *string2_p); -extern int32_t ecma_string_get_length (const ecma_string_t *string_p); +extern ecma_length_t ecma_string_get_length (const ecma_string_t *string_p); extern ecma_char_t ecma_string_get_char_at_pos (const ecma_string_t *string_p, uint32_t index); extern bool ecma_compare_zt_strings (const ecma_char_t *string1_p, const ecma_char_t *string2_p); extern bool ecma_compare_zt_strings_relational (const ecma_char_t *string1_p, const ecma_char_t *string2_p); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-error-prototype.cpp b/jerry-core/ecma/builtin-objects/ecma-builtin-error-prototype.cpp index 18ebe2026..7cd3b2e39 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-error-prototype.cpp +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-error-prototype.cpp @@ -134,12 +134,12 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this const ecma_char_t *colon_zt_magic_string_p = lit_get_magic_string_zt (LIT_MAGIC_STRING_COLON_CHAR); const ecma_char_t *space_zt_magic_string_p = lit_get_magic_string_zt (LIT_MAGIC_STRING_SPACE_CHAR); - const int32_t len = (ecma_string_get_length (name_string_p) + - ecma_string_get_length (msg_string_p) + - ecma_zt_string_length (colon_zt_magic_string_p) + - ecma_zt_string_length (space_zt_magic_string_p)); + const ecma_length_t len = (ecma_string_get_length (name_string_p) + + ecma_string_get_length (msg_string_p) + + ecma_zt_string_length (colon_zt_magic_string_p) + + ecma_zt_string_length (space_zt_magic_string_p)); - const ssize_t buffer_size = (len + 1) * (ssize_t) sizeof (ecma_char_t); + const ssize_t buffer_size = (ssize_t) ((len + 1) * sizeof (ecma_char_t)); ssize_t buffer_size_left = buffer_size; MEM_DEFINE_LOCAL_ARRAY (ret_str_buffer, buffer_size, ecma_char_t); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-global.cpp b/jerry-core/ecma/builtin-objects/ecma-builtin-global.cpp index b85bfff6d..e36d44c38 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-global.cpp +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-global.cpp @@ -108,7 +108,7 @@ ecma_builtin_global_object_parse_int (ecma_value_t this_arg __attr_unused___, /* ECMA_TRY_CATCH (string_var, ecma_op_to_string (string), ret_value); ecma_string_t *number_str_p = ecma_get_string_from_value (string_var); - int32_t string_len = ecma_string_get_length (number_str_p); + ecma_length_t string_len = ecma_string_get_length (number_str_p); MEM_DEFINE_LOCAL_ARRAY (zt_string_buff, string_len + 1, ecma_char_t); @@ -119,9 +119,9 @@ ecma_builtin_global_object_parse_int (ecma_value_t this_arg __attr_unused___, /* JERRY_ASSERT (bytes_copied > 0); /* 2. Remove leading whitespace. */ - int32_t start = string_len; - int32_t end = string_len; - for (int i = 0; i < end; i++) + ecma_length_t start = string_len; + ecma_length_t end = string_len; + for (ecma_length_t i = 0; i < end; i++) { if (!(isspace (zt_string_buff[i]))) { @@ -190,7 +190,7 @@ ecma_builtin_global_object_parse_int (ecma_value_t this_arg __attr_unused___, /* } /* 11. Check if characters are in [0, Radix - 1]. We also convert them to number values in the process. */ - for (int i = start; i < end; i++) + for (ecma_length_t i = start; i < end; i++) { if ((zt_string_buff[i]) >= 'a' && zt_string_buff[i] <= 'z') { @@ -233,7 +233,7 @@ ecma_builtin_global_object_parse_int (ecma_value_t this_arg __attr_unused___, /* ecma_number_t multiplier = 1.0f; /* 13. and 14. */ - for (int i = end - 1; i >= start; i--) + for (int32_t i = (int32_t) end - 1; i >= (int32_t) start; i--) { *value_p += (ecma_number_t) zt_string_buff[i] * multiplier; multiplier *= (ecma_number_t) rad; @@ -273,7 +273,7 @@ ecma_builtin_global_object_parse_float (ecma_value_t this_arg __attr_unused___, ECMA_TRY_CATCH (string_var, ecma_op_to_string (string), ret_value); ecma_string_t *number_str_p = ecma_get_string_from_value (string_var); - int32_t string_len = ecma_string_get_length (number_str_p); + ecma_length_t string_len = ecma_string_get_length (number_str_p); MEM_DEFINE_LOCAL_ARRAY (zt_string_buff, string_len + 1, ecma_char_t); @@ -284,8 +284,8 @@ ecma_builtin_global_object_parse_float (ecma_value_t this_arg __attr_unused___, JERRY_ASSERT (bytes_copied > 0); /* 2. Find first non whitespace char. */ - int32_t start = 0; - for (int i = 0; i < string_len; i++) + ecma_length_t start = 0; + for (ecma_length_t i = 0; i < string_len; i++) { if (!isspace (zt_string_buff[i])) { @@ -312,7 +312,7 @@ ecma_builtin_global_object_parse_float (ecma_value_t this_arg __attr_unused___, /* Check if string is equal to "Infinity". */ const ecma_char_t *infinity_zt_str_p = lit_get_magic_string_zt (LIT_MAGIC_STRING_INFINITY_UL); - for (int i = 0; infinity_zt_str_p[i] == zt_string_buff[start + i]; i++) + for (ecma_length_t i = 0; infinity_zt_str_p[i] == zt_string_buff[start + i]; i++) { if (infinity_zt_str_p[i + 1] == 0) { @@ -324,8 +324,8 @@ ecma_builtin_global_object_parse_float (ecma_value_t this_arg __attr_unused___, if (ecma_is_completion_value_empty (ret_value)) { - int32_t current = start; - int32_t end = string_len; + ecma_length_t current = start; + ecma_length_t end = string_len; bool has_whole_part = false; bool has_fraction_part = false; @@ -334,7 +334,7 @@ ecma_builtin_global_object_parse_float (ecma_value_t this_arg __attr_unused___, has_whole_part = true; /* Check digits of whole part. */ - for (int i = current; i < string_len; i++, current++) + for (ecma_length_t i = current; i < string_len; i++, current++) { if (!isdigit (zt_string_buff[current])) { @@ -355,7 +355,7 @@ ecma_builtin_global_object_parse_float (ecma_value_t this_arg __attr_unused___, has_fraction_part = true; /* Check digits of fractional part. */ - for (int i = current; i < string_len; i++, current++) + for (ecma_length_t i = current; i < string_len; i++, current++) { if (!isdigit (zt_string_buff[current])) { @@ -383,7 +383,7 @@ ecma_builtin_global_object_parse_float (ecma_value_t this_arg __attr_unused___, { /* Check digits of exponent part. */ - for (int i = current; i < string_len; i++, current++) + for (ecma_length_t i = current; i < string_len; i++, current++) { if (!isdigit (zt_string_buff[current])) { diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.cpp b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.cpp index 5669710ef..617fd464f 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.cpp +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-regexp-prototype.cpp @@ -77,11 +77,11 @@ ecma_builtin_regexp_prototype_exec (ecma_value_t this_arg, /**< this argument */ ecma_string_t *input_str_p = ecma_get_string_from_value (input_str_value); /* Convert ecma_String_t *to regexp_bytecode_t* */ - int32_t input_str_len = ecma_string_get_length (input_str_p); + ecma_length_t input_str_len = ecma_string_get_length (input_str_p); MEM_DEFINE_LOCAL_ARRAY (input_zt_str_p, input_str_len + 1, ecma_char_t); - ssize_t zt_str_size = (ssize_t) sizeof (ecma_char_t) * (input_str_len + 1); + ssize_t zt_str_size = (ssize_t) (sizeof (ecma_char_t) * (input_str_len + 1)); ecma_string_to_zt_string (input_str_p, input_zt_str_p, zt_str_size); ret_value = ecma_regexp_exec_helper (obj_p, bytecode_p, input_zt_str_p); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.cpp b/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.cpp index 00919bb5a..f49853a20 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.cpp +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.cpp @@ -163,8 +163,6 @@ ecma_builtin_string_prototype_object_concat (ecma_value_t this_arg, /**< this ar /* 4 */ ecma_string_t *string_to_return = ecma_copy_or_ref_ecma_string (ecma_get_string_from_value (to_string_val)); - JERRY_ASSERT (ecma_string_get_length (string_to_return) >= 0); - /* 5 */ for (uint32_t arg_index = 0; arg_index < arguments_number && ecma_is_completion_value_empty (ret_value); @@ -329,8 +327,6 @@ ecma_builtin_string_prototype_object_slice (ecma_value_t this_arg, /**< this arg /* 3. */ ecma_string_t *get_string_val = ecma_get_string_from_value (to_string_val); - JERRY_ASSERT (ecma_string_get_length (get_string_val) >= 0); - const uint32_t len = (uint32_t) ecma_string_get_length (get_string_val); /* 4. 6. */ @@ -509,7 +505,6 @@ ecma_builtin_string_prototype_object_trim (ecma_value_t this_arg) /**< this argu ret_value); ecma_string_t *original_string_p = ecma_get_string_from_value (to_string_val); - JERRY_ASSERT (ecma_string_get_length (original_string_p) >= 0); /* 3 */ const uint32_t len = (uint32_t) ecma_string_get_length (original_string_p); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtins.cpp b/jerry-core/ecma/builtin-objects/ecma-builtins.cpp index f1c6b8691..657bf4500 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtins.cpp +++ b/jerry-core/ecma/builtin-objects/ecma-builtins.cpp @@ -601,7 +601,7 @@ ecma_builtin_bin_search_for_magic_string_id_in_array (const lit_magic_string_id_ #endif /* !JERRY_NDEBUG */ int32_t min = 0; - int32_t max = array_length - 1; + int32_t max = (int32_t) array_length - 1; while (min <= max) { diff --git a/jerry-core/ecma/operations/ecma-eval.cpp b/jerry-core/ecma/operations/ecma-eval.cpp index de7363986..253e205b0 100644 --- a/jerry-core/ecma/operations/ecma-eval.cpp +++ b/jerry-core/ecma/operations/ecma-eval.cpp @@ -46,12 +46,12 @@ ecma_op_eval (ecma_string_t *code_p, /**< code string */ { ecma_completion_value_t ret_value; - int32_t chars_num = ecma_string_get_length (code_p); + ecma_length_t chars_num = ecma_string_get_length (code_p); MEM_DEFINE_LOCAL_ARRAY (code_zt_buffer_p, chars_num + 1, ecma_char_t); - const ssize_t buf_size = (ssize_t) sizeof (ecma_char_t) * (chars_num + 1); + const ssize_t buf_size = (ssize_t) (sizeof (ecma_char_t) * (chars_num + 1)); ssize_t buffer_size_req = ecma_string_to_zt_string (code_p, code_zt_buffer_p, buf_size); diff --git a/jerry-core/ecma/operations/ecma-objects-arguments.cpp b/jerry-core/ecma/operations/ecma-objects-arguments.cpp index a863163f8..9fab7fc3b 100644 --- a/jerry-core/ecma/operations/ecma-objects-arguments.cpp +++ b/jerry-core/ecma/operations/ecma-objects-arguments.cpp @@ -151,7 +151,7 @@ ecma_op_create_arguments_object (ecma_object_t *func_obj_p, /**< callee function } JERRY_ASSERT (param_index == formal_params_number); - for (int32_t indx = formal_params_number - 1; + for (int32_t indx = (int32_t) formal_params_number - 1; indx >= 0; indx--) { @@ -161,7 +161,7 @@ ecma_op_create_arguments_object (ecma_object_t *func_obj_p, /**< callee function // ii. for (int32_t indx2 = indx + 1; - indx2 < formal_params_number; + indx2 < (int32_t) formal_params_number; indx2++) { if (ecma_compare_ecma_strings (name_p, formal_params[indx2])) diff --git a/jerry-core/ecma/operations/ecma-regexp-object.cpp b/jerry-core/ecma/operations/ecma-regexp-object.cpp index 299222e71..2768e6a85 100644 --- a/jerry-core/ecma/operations/ecma-regexp-object.cpp +++ b/jerry-core/ecma/operations/ecma-regexp-object.cpp @@ -72,9 +72,9 @@ re_parse_regexp_flags (ecma_string_t *flags_str_p, /**< Input string with flags { ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); - int32_t flags_str_len = ecma_string_get_length (flags_str_p); + ecma_length_t flags_str_len = ecma_string_get_length (flags_str_p); MEM_DEFINE_LOCAL_ARRAY (flags_start_p, flags_str_len + 1, ecma_char_t); - ssize_t zt_str_size = (ssize_t) sizeof (ecma_char_t) * (flags_str_len + 1); + ssize_t zt_str_size = (ssize_t) (sizeof (ecma_char_t) * (flags_str_len + 1)); ecma_string_to_zt_string (flags_str_p, flags_start_p, zt_str_size); ecma_char_t *flags_char_p = flags_start_p; @@ -1181,7 +1181,7 @@ ecma_regexp_exec_helper (ecma_object_t *obj_p, /**< RegExp object */ const ecma_char_t *str_p) /**< start of the input string */ { ecma_completion_value_t ret_value = ecma_make_empty_completion_value (); - int32_t input_length = ecma_zt_string_length (str_p); + ecma_length_t input_length = ecma_zt_string_length (str_p); re_matcher_ctx_t re_ctx; re_ctx.input_start_p = str_p; re_ctx.input_end_p = str_p + strlen ((char *) str_p); @@ -1232,7 +1232,7 @@ ecma_regexp_exec_helper (ecma_object_t *obj_p, /**< RegExp object */ const ecma_char_t *sub_str_p; while (str_p && str_p <= re_ctx.input_end_p && ecma_is_completion_value_empty (ret_value)) { - if (index < 0 || index > input_length) + if (index < 0 || index > (int32_t) input_length) { ecma_string_t *magic_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL); ecma_number_t *lastindex_num_p = ecma_alloc_number (); diff --git a/jerry-core/ecma/operations/ecma-string-object.cpp b/jerry-core/ecma/operations/ecma-string-object.cpp index 25e758108..07384ef8e 100644 --- a/jerry-core/ecma/operations/ecma-string-object.cpp +++ b/jerry-core/ecma/operations/ecma-string-object.cpp @@ -70,8 +70,7 @@ ecma_op_create_string_object (const ecma_value_t *arguments_list_p, /**< list of JERRY_ASSERT (ecma_is_value_string (ecma_get_completion_value_value (to_str_arg_value))); prim_prop_str_value_p = ecma_get_string_from_completion_value (to_str_arg_value); - int32_t string_len = ecma_string_get_length (prim_prop_str_value_p); - JERRY_ASSERT (string_len >= 0); + ecma_length_t string_len = ecma_string_get_length (prim_prop_str_value_p); length_value = ecma_uint32_to_number ((uint32_t) string_len); } @@ -174,8 +173,7 @@ ecma_op_string_object_get_own_property (ecma_object_t *obj_p, /**< the string ob prim_value_prop_p->u.internal_property.value); // 6. - int32_t length = ecma_string_get_length (prim_value_str_p); - JERRY_ASSERT (length >= 0); + ecma_length_t length = ecma_string_get_length (prim_value_str_p); ecma_property_t *new_prop_p; diff --git a/jerry-core/jerry-api.h b/jerry-core/jerry-api.h index 21a5771e1..886f2676d 100644 --- a/jerry-core/jerry-api.h +++ b/jerry-core/jerry-api.h @@ -87,7 +87,7 @@ typedef jerry_api_char_t* jerry_api_char_ptr_t; /** * Jerry's length */ -typedef uint16_t jerry_api_length_t; +typedef uint32_t jerry_api_length_t; /** * Jerry's string value @@ -130,7 +130,7 @@ typedef bool (*jerry_external_handler_t) (const jerry_api_object_t *function_obj const jerry_api_value_t *this_p, jerry_api_value_t *ret_val_p, const jerry_api_value_t args_p[], - const uint16_t args_count); + const jerry_api_length_t args_count); /** * An object's native free callback diff --git a/jerry-core/jerry.cpp b/jerry-core/jerry.cpp index 74868f7b9..59ea2a32d 100644 --- a/jerry-core/jerry.cpp +++ b/jerry-core/jerry.cpp @@ -519,7 +519,7 @@ jerry_dispatch_external_function (ecma_object_t *function_object_p, /**< externa { jerry_assert_api_available (); - JERRY_STATIC_ASSERT (sizeof (args_count) == sizeof (uint16_t)); + JERRY_STATIC_ASSERT (sizeof (args_count) == sizeof (uint32_t)); ecma_completion_value_t completion_value; @@ -885,7 +885,7 @@ jerry_api_invoke_function (bool is_invoke_as_constructor, /**< true - invoke fun * or NULL (to ignore the values) */ const jerry_api_value_t args_p[], /**< function's call arguments * (NULL if arguments number is zero) */ - uint16_t args_count) /**< number of the arguments */ + jerry_api_length_t args_count) /**< number of the arguments */ { JERRY_ASSERT (args_count == 0 || args_p != NULL); JERRY_STATIC_ASSERT (sizeof (args_count) == sizeof (ecma_length_t)); diff --git a/jerry-core/lit/lit-globals.h b/jerry-core/lit/lit-globals.h index 9e86910bb..b5d3be7e8 100644 --- a/jerry-core/lit/lit-globals.h +++ b/jerry-core/lit/lit-globals.h @@ -43,7 +43,7 @@ typedef ecma_char_t *ecma_char_ptr_t; /** * Description of a collection's/string's length */ -typedef uint16_t ecma_length_t; +typedef uint32_t ecma_length_t; /** * ECMA string hash diff --git a/jerry-core/lit/lit-literal.cpp b/jerry-core/lit/lit-literal.cpp index 8ccc9ad37..26f3acdcc 100644 --- a/jerry-core/lit/lit-literal.cpp +++ b/jerry-core/lit/lit-literal.cpp @@ -544,7 +544,7 @@ lit_magic_record_ex_get_magic_str_id (literal_t lit) /**< literal */ return static_cast (lit)->get_magic_str_id (); } /* lit_magic_record_ex_get_magic_str_id */ -int32_t +ecma_length_t lit_charset_record_get_length (literal_t lit) /**< literal */ { return static_cast (lit)->get_length ();; diff --git a/jerry-core/lit/lit-literal.h b/jerry-core/lit/lit-literal.h index a4e7c2a1a..94f7f1585 100644 --- a/jerry-core/lit/lit-literal.h +++ b/jerry-core/lit/lit-literal.h @@ -42,13 +42,14 @@ bool lit_literal_equal_type_num (literal_t, ecma_number_t); bool lit_literal_equal_type (literal_t, literal_t); const ecma_char_t *lit_literal_to_charset (literal_t, ecma_char_t *, size_t); + const char *lit_literal_to_str_internal_buf (literal_t); literal_t lit_get_literal_by_cp (lit_cpointer_t); lit_string_hash_t lit_charset_literal_get_hash (literal_t); ecma_number_t lit_charset_literal_get_number (literal_t); -int32_t lit_charset_record_get_length (literal_t); +ecma_length_t lit_charset_record_get_length (literal_t); lit_magic_string_id_t lit_magic_record_get_magic_str_id (literal_t); lit_magic_string_ex_id_t lit_magic_record_ex_get_magic_str_id (literal_t); diff --git a/jerry-core/parser/regexp/re-compiler.cpp b/jerry-core/parser/regexp/re-compiler.cpp index f9f5145bc..7cf1a10b4 100644 --- a/jerry-core/parser/regexp/re-compiler.cpp +++ b/jerry-core/parser/regexp/re-compiler.cpp @@ -636,9 +636,9 @@ re_compile_bytecode (ecma_property_t *bytecode_p, /**< bytecode */ re_ctx.bytecode_ctx_p = &bc_ctx; - int32_t pattern_str_len = ecma_string_get_length (pattern_str_p); + ecma_length_t pattern_str_len = ecma_string_get_length (pattern_str_p); MEM_DEFINE_LOCAL_ARRAY (pattern_start_p, pattern_str_len + 1, ecma_char_t); - ssize_t zt_str_size = (ssize_t) sizeof (ecma_char_t) * (pattern_str_len + 1); + ssize_t zt_str_size = (ssize_t) (sizeof (ecma_char_t) * (pattern_str_len + 1)); ecma_string_to_zt_string (pattern_str_p, pattern_start_p, zt_str_size); re_parser_ctx_t parser_ctx; diff --git a/jerry-core/vm/opcodes-native-call.cpp b/jerry-core/vm/opcodes-native-call.cpp index 8aca18bda..d839c5af0 100644 --- a/jerry-core/vm/opcodes-native-call.cpp +++ b/jerry-core/vm/opcodes-native-call.cpp @@ -79,10 +79,9 @@ opfunc_native_call (opcode_t opdata, /**< operation data */ ecma_string_t *str_p = ecma_get_string_from_value (str_value); - int32_t chars = ecma_string_get_length (str_p); - JERRY_ASSERT (chars >= 0); + ecma_length_t chars = ecma_string_get_length (str_p); - ssize_t zt_str_size = (ssize_t) sizeof (ecma_char_t) * (chars + 1); + ssize_t zt_str_size = (ssize_t) (sizeof (ecma_char_t) * (chars + 1)); ecma_char_t *zt_str_p = (ecma_char_t*) mem_heap_alloc_block ((size_t) zt_str_size, MEM_HEAP_ALLOC_SHORT_TERM); if (zt_str_p == NULL) diff --git a/jerry-core/vm/opcodes.cpp b/jerry-core/vm/opcodes.cpp index 6d39ac839..bc603b15f 100644 --- a/jerry-core/vm/opcodes.cpp +++ b/jerry-core/vm/opcodes.cpp @@ -175,10 +175,10 @@ opfunc_assignment (opcode_t opdata, /**< operation data */ int_data->pos); ecma_string_t *string_p = ecma_new_ecma_string_from_lit_cp (lit_cp); - int32_t re_str_len = ecma_string_get_length (string_p); + ecma_length_t re_str_len = ecma_string_get_length (string_p); MEM_DEFINE_LOCAL_ARRAY (re_str_p, re_str_len + 1, ecma_char_t); - ssize_t zt_str_size = (ssize_t) sizeof (ecma_char_t) * (re_str_len + 1); + ssize_t zt_str_size = (ssize_t) (sizeof (ecma_char_t) * (re_str_len + 1)); ecma_string_to_zt_string (string_p, re_str_p, zt_str_size); ecma_char_t *ch_p = re_str_p; diff --git a/main-linux.cpp b/main-linux.cpp index 1001f4ab5..f06ae7164 100644 --- a/main-linux.cpp +++ b/main-linux.cpp @@ -117,7 +117,7 @@ assert_handler (const jerry_api_object_t *function_obj_p __attr_unused___, /** < const jerry_api_value_t *this_p __attr_unused___, /** < this arg */ jerry_api_value_t *ret_val_p __attr_unused___, /** < return argument */ const jerry_api_value_t args_p[], /** < function arguments */ - const uint16_t args_cnt) /** < number of function arguments */ + const jerry_api_length_t args_cnt) /** < number of function arguments */ { if (args_cnt > 0 && args_p[0].type == JERRY_API_DATA_TYPE_BOOLEAN diff --git a/tests/unit/test-api.cpp b/tests/unit/test-api.cpp index 5fb3ad751..518b619dc 100644 --- a/tests/unit/test-api.cpp +++ b/tests/unit/test-api.cpp @@ -109,7 +109,7 @@ handler (const jerry_api_object_t *function_obj_p, const jerry_api_value_t *this_p, jerry_api_value_t *ret_val_p, const jerry_api_value_t args_p[], - const uint16_t args_cnt) + const jerry_api_length_t args_cnt) { char buffer[32]; ssize_t sz; @@ -138,7 +138,7 @@ handler_throw_test (const jerry_api_object_t *function_obj_p, const jerry_api_value_t *this_p, jerry_api_value_t *ret_val_p, const jerry_api_value_t args_p[], - const uint16_t args_cnt) + const jerry_api_length_t args_cnt) { printf ("ok %p %p %p %d %p\n", function_obj_p, this_p, args_p, args_cnt, ret_val_p); @@ -165,7 +165,7 @@ handler_construct (const jerry_api_object_t *function_obj_p, const jerry_api_value_t *this_p, jerry_api_value_t *ret_val_p, const jerry_api_value_t args_p[], - const uint16_t args_cnt) + const jerry_api_length_t args_cnt) { printf ("ok construct %p %p %p %d %p\n", function_obj_p, this_p, args_p, args_cnt, ret_val_p);