Remove shadowed declarations, undefined identifiers, and specify argument types where it is required. (#1601)

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
This commit is contained in:
Robert Sipka
2017-02-22 10:34:44 +01:00
committed by GitHub
parent 5ef305dfee
commit 39dc4a6273
26 changed files with 75 additions and 82 deletions
+1 -1
View File
@@ -170,7 +170,7 @@ ecma_string_t *ecma_new_ecma_string_from_uint32 (uint32_t uint32_number);
ecma_string_t *ecma_new_ecma_string_from_number (ecma_number_t num);
ecma_string_t *ecma_new_ecma_string_from_magic_string_id (lit_magic_string_id_t id);
ecma_string_t *ecma_new_ecma_string_from_magic_string_ex_id (lit_magic_string_ex_id_t id);
ecma_string_t *ecma_new_ecma_length_string ();
ecma_string_t *ecma_new_ecma_length_string (void);
ecma_string_t *ecma_concat_ecma_strings (ecma_string_t *string1_p, ecma_string_t *string2_p);
void ecma_ref_ecma_string (ecma_string_t *string_p);
void ecma_deref_ecma_string (ecma_string_t *string_p);
@@ -783,10 +783,10 @@ ecma_builtin_array_prototype_object_shift (ecma_value_t this_arg) /**< this argu
if (ecma_is_value_empty (ret_value))
{
len--;
ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 (len);
ecma_string_t *len_str_p = ecma_new_ecma_string_from_uint32 (len);
/* 8. */
ECMA_TRY_CATCH (del_value, ecma_op_object_delete (obj_p, index_str_p, true), ret_value);
ECMA_TRY_CATCH (del_value, ecma_op_object_delete (obj_p, len_str_p, true), ret_value);
/* 9. */
ECMA_TRY_CATCH (set_length_value,
@@ -797,7 +797,7 @@ ecma_builtin_array_prototype_object_shift (ecma_value_t this_arg) /**< this argu
ECMA_FINALIZE (set_length_value);
ECMA_FINALIZE (del_value);
ecma_deref_ecma_string (index_str_p);
ecma_deref_ecma_string (len_str_p);
}
ECMA_FINALIZE (first_value);
@@ -1426,11 +1426,9 @@ ecma_builtin_array_prototype_object_splice (ecma_value_t this_arg, /**< this arg
}
/* 8-9. */
uint32_t k;
uint32_t k = 0;
for (uint32_t del_item_idx, k = 0;
k < delete_count && ecma_is_value_empty (ret_value);
k++)
for (uint32_t del_item_idx; k < delete_count && ecma_is_value_empty (ret_value); k++)
{
/* 9.a */
del_item_idx = k + start;
@@ -319,11 +319,11 @@ ecma_builtin_date_parse (ecma_value_t this_arg, /**< this argument */
else if (date_str_curr_p < date_str_end_p
&& (*date_str_curr_p == '+' || *date_str_curr_p == '-'))
{
ecma_length_t remaining_length;
remaining_length = lit_utf8_string_length (date_str_curr_p,
(lit_utf8_size_t) (date_str_end_p - date_str_curr_p)) - 1;
ecma_length_t remaining_date_length;
remaining_date_length = lit_utf8_string_length (date_str_curr_p,
(lit_utf8_size_t) (date_str_end_p - date_str_curr_p)) - 1;
if (remaining_length == 5)
if (remaining_date_length == 5)
{
bool is_negative = false;
@@ -934,11 +934,10 @@ ecma_builtin_json_stringify (ecma_value_t this_arg, /**< 'this' argument */
array_length,
ret_value);
uint32_t array_length = ecma_number_to_uint32 (array_length_num);
uint32_t index = 0;
/* 4.b.ii */
while ((index < array_length) && ecma_is_value_empty (ret_value))
while ((index < ecma_number_to_uint32 (array_length_num)) && ecma_is_value_empty (ret_value))
{
ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 (index);
@@ -1060,23 +1059,24 @@ ecma_builtin_json_stringify (ecma_value_t this_arg, /**< 'this' argument */
/* 6.a */
int32_t num_of_spaces = ecma_number_to_int32 (array_length_num);
int32_t space = (num_of_spaces > 10) ? 10 : num_of_spaces;
num_of_spaces = (num_of_spaces > 10) ? 10 : num_of_spaces;
/* 6.b */
if (space < 1)
if (num_of_spaces < 1)
{
context.gap_str_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
}
else
{
JMEM_DEFINE_LOCAL_ARRAY (space_buff, space, char);
JMEM_DEFINE_LOCAL_ARRAY (space_buff, num_of_spaces, char);
for (int32_t i = 0; i < space; i++)
for (int32_t i = 0; i < num_of_spaces; i++)
{
space_buff[i] = LIT_CHAR_SP;
}
context.gap_str_p = ecma_new_ecma_string_from_utf8 ((lit_utf8_byte_t *) space_buff, (lit_utf8_size_t) space);
context.gap_str_p = ecma_new_ecma_string_from_utf8 ((lit_utf8_byte_t *) space_buff,
(lit_utf8_size_t) num_of_spaces);
JMEM_FINALIZE_LOCAL_ARRAY (space_buff);
}
@@ -1738,11 +1738,9 @@ ecma_builtin_json_array (ecma_object_t *obj_p, /**< the array object*/
array_length,
ret_value);
uint32_t array_length = ecma_number_to_uint32 (array_length_num);
/* 7. - 8. */
for (uint32_t index = 0;
index < array_length && ecma_is_value_empty (ret_value);
index < ecma_number_to_uint32 (array_length_num) && ecma_is_value_empty (ret_value);
index++)
{
@@ -998,7 +998,6 @@ ecma_builtin_string_prototype_object_replace_get_string (ecma_builtin_replace_se
}
ecma_string_t *index_string_p = ecma_new_ecma_string_from_uint32 (index);
ecma_object_t *match_object_p = ecma_get_object_from_value (match_value);
ECMA_TRY_CATCH (submatch_value,
ecma_op_object_get (match_object_p, index_string_p),
@@ -1863,18 +1862,18 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_arg, /**< this arg
ecma_string_t *idx_str_p = ecma_new_ecma_string_from_uint32 (i);
ecma_string_t *new_array_idx_str_p = ecma_new_ecma_string_from_uint32 (new_array_length);
ecma_value_t match_comp_value = ecma_op_object_get (match_array_obj_p, idx_str_p);
match_comp_value = ecma_op_object_get (match_array_obj_p, idx_str_p);
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (match_comp_value));
/* 13.c.iii.7.b */
ecma_value_t put_comp = ecma_builtin_helper_def_prop (new_array_p,
new_array_idx_str_p,
match_comp_value,
true,
true,
true,
false);
put_comp = ecma_builtin_helper_def_prop (new_array_p,
new_array_idx_str_p,
match_comp_value,
true,
true,
true,
false);
JERRY_ASSERT (ecma_is_value_true (put_comp));
+3 -4
View File
@@ -864,9 +864,9 @@ ecma_op_object_put (ecma_object_t *object_p, /**< the object */
if (create_new_property
&& ecma_get_object_extensible (object_p))
{
const ecma_object_type_t type = ecma_get_object_type (object_p);
const ecma_object_type_t obj_type = ecma_get_object_type (object_p);
if (type == ECMA_OBJECT_TYPE_PSEUDO_ARRAY)
if (obj_type == ECMA_OBJECT_TYPE_PSEUDO_ARRAY)
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
@@ -884,7 +884,7 @@ ecma_op_object_put (ecma_object_t *object_p, /**< the object */
uint32_t index = ecma_string_get_array_index (property_name_p);
if (type == ECMA_OBJECT_TYPE_ARRAY
if (obj_type == ECMA_OBJECT_TYPE_ARRAY
&& index != ECMA_STRING_NOT_ARRAY_INDEX)
{
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
@@ -1622,7 +1622,6 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
/* name with same hash already occured */
bool is_equal_found = false;
ecma_collection_iterator_t iter;
ecma_collection_iterator_init (&iter, ret_p);
while (ecma_collection_iterator_next (&iter))
@@ -1008,7 +1008,7 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */
old_start_p = re_ctx_p->saved_p[start_idx];
re_ctx_p->saved_p[start_idx] = str_curr_p;
ecma_value_t match_value = re_match_regexp (re_ctx_p, bc_p, str_curr_p, &sub_str_p);
match_value = re_match_regexp (re_ctx_p, bc_p, str_curr_p, &sub_str_p);
if (ecma_is_value_true (match_value))
{