Merged conditions of if statements where possible. (#2380)
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
This commit is contained in:
@@ -1511,13 +1511,11 @@ ecma_string_get_chars (const ecma_string_t *string_p, /**< ecma-string */
|
||||
}
|
||||
|
||||
*size_p = size;
|
||||
if (*flags_p & ECMA_STRING_FLAG_IS_ASCII)
|
||||
{
|
||||
if (length != size)
|
||||
if ((*flags_p & ECMA_STRING_FLAG_IS_ASCII)
|
||||
&& length != size)
|
||||
{
|
||||
*flags_p = (uint8_t) (*flags_p & ~ECMA_STRING_FLAG_IS_ASCII);
|
||||
}
|
||||
}
|
||||
|
||||
return result_p;
|
||||
} /* ecma_string_get_chars */
|
||||
|
||||
@@ -771,15 +771,13 @@ ecma_free_property (ecma_object_t *object_p, /**< object the property belongs to
|
||||
{
|
||||
case ECMA_PROPERTY_TYPE_NAMEDDATA:
|
||||
{
|
||||
if (ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == ECMA_DIRECT_STRING_MAGIC)
|
||||
{
|
||||
if (name_cp == LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE
|
||||
|| name_cp == LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER)
|
||||
if (ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == ECMA_DIRECT_STRING_MAGIC
|
||||
&& (name_cp == LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE
|
||||
|| name_cp == LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER))
|
||||
{
|
||||
ecma_free_native_pointer (property_p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ecma_free_value_if_not_object (ECMA_PROPERTY_VALUE_PTR (property_p)->value);
|
||||
break;
|
||||
|
||||
@@ -1716,14 +1716,12 @@ ecma_builtin_array_prototype_object_index_of (ecma_value_t this_arg, /**< this a
|
||||
/* 9.a */
|
||||
ECMA_TRY_CATCH (get_value, ecma_op_object_find (obj_p, idx_str_p), ret_value);
|
||||
|
||||
if (ecma_is_value_found (get_value))
|
||||
{
|
||||
/* 9.b.i, 9.b.ii */
|
||||
if (ecma_op_strict_equality_compare (arg1, get_value))
|
||||
if (ecma_is_value_found (get_value)
|
||||
&& ecma_op_strict_equality_compare (arg1, get_value))
|
||||
{
|
||||
found_index = ((ecma_number_t) from_idx);
|
||||
}
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (get_value);
|
||||
|
||||
@@ -1863,14 +1861,12 @@ ecma_builtin_array_prototype_object_last_index_of (ecma_value_t this_arg, /**< t
|
||||
/* 8.a */
|
||||
ECMA_TRY_CATCH (get_value, ecma_op_object_find (obj_p, idx_str_p), ret_value);
|
||||
|
||||
if (ecma_is_value_found (get_value))
|
||||
{
|
||||
/* 8.b.i, 8.b.ii */
|
||||
if (ecma_op_strict_equality_compare (search_element, get_value))
|
||||
if (ecma_is_value_found (get_value)
|
||||
&& ecma_op_strict_equality_compare (search_element, get_value))
|
||||
{
|
||||
num = ((ecma_number_t) from_idx);
|
||||
}
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (get_value);
|
||||
|
||||
|
||||
@@ -190,9 +190,9 @@ ecma_builtin_global_object_parse_int (ecma_value_t this_arg, /**< this argument
|
||||
if (ecma_is_value_empty (ret_value))
|
||||
{
|
||||
/* 10. */
|
||||
if (strip_prefix)
|
||||
{
|
||||
if (end_p - start_p >= 2 && current == LIT_CHAR_0)
|
||||
if (strip_prefix
|
||||
&& ((end_p - start_p) >= 2)
|
||||
&& (current == LIT_CHAR_0))
|
||||
{
|
||||
ecma_char_t next = *string_curr_p;
|
||||
if (next == LIT_CHAR_LOWERCASE_X || next == LIT_CHAR_UPPERCASE_X)
|
||||
@@ -202,7 +202,6 @@ ecma_builtin_global_object_parse_int (ecma_value_t this_arg, /**< this argument
|
||||
rad = 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 11. Check if characters are in [0, Radix - 1]. We also convert them to number values in the process. */
|
||||
string_curr_p = start_p;
|
||||
|
||||
@@ -213,9 +213,8 @@ ecma_builtin_math_dispatch_routine (uint16_t builtin_routine_id, /**< built-in w
|
||||
}
|
||||
}
|
||||
|
||||
if (builtin_routine_id >= ECMA_MATH_OBJECT_ATAN2)
|
||||
{
|
||||
if (arguments_number >= 2)
|
||||
if (builtin_routine_id >= ECMA_MATH_OBJECT_ATAN2
|
||||
&& arguments_number >= 2)
|
||||
{
|
||||
if (ecma_is_value_number (arguments_list[1]))
|
||||
{
|
||||
@@ -235,7 +234,6 @@ ecma_builtin_math_dispatch_routine (uint16_t builtin_routine_id, /**< built-in w
|
||||
ecma_fast_free_value (value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (builtin_routine_id)
|
||||
{
|
||||
|
||||
@@ -198,13 +198,11 @@ ecma_builtin_typedarray_prototype_exec_routine (ecma_value_t this_arg, /**< this
|
||||
ret_value = ECMA_VALUE_FALSE;
|
||||
}
|
||||
}
|
||||
else if (mode == TYPEDARRAY_ROUTINE_SOME)
|
||||
{
|
||||
if (ecma_op_to_boolean (call_value))
|
||||
else if (mode == TYPEDARRAY_ROUTINE_SOME
|
||||
&& ecma_op_to_boolean (call_value))
|
||||
{
|
||||
ret_value = ECMA_VALUE_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (call_value);
|
||||
|
||||
|
||||
@@ -775,16 +775,12 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
|
||||
JERRY_ASSERT (ecma_is_value_empty (ret_value));
|
||||
|
||||
/* 9. */
|
||||
if (prop_desc.is_get_defined
|
||||
|| prop_desc.is_set_defined)
|
||||
{
|
||||
if (prop_desc.is_value_defined
|
||||
|| prop_desc.is_writable_defined)
|
||||
if ((prop_desc.is_get_defined || prop_desc.is_set_defined)
|
||||
&& (prop_desc.is_value_defined || prop_desc.is_writable_defined))
|
||||
{
|
||||
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Accessors cannot be writable."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!ECMA_IS_VALUE_ERROR (ret_value))
|
||||
{
|
||||
|
||||
@@ -264,9 +264,8 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */
|
||||
{
|
||||
uint32_t index = ecma_string_get_array_index (property_name_p);
|
||||
|
||||
if (index != ECMA_STRING_NOT_ARRAY_INDEX)
|
||||
{
|
||||
if (index < ext_object_p->u.pseudo_array.u1.length)
|
||||
if (index != ECMA_STRING_NOT_ARRAY_INDEX
|
||||
&& index < ext_object_p->u.pseudo_array.u1.length)
|
||||
{
|
||||
ecma_value_t *arg_Literal_p = (ecma_value_t *) (ext_object_p + 1);
|
||||
|
||||
@@ -290,7 +289,6 @@ ecma_op_object_get_own_property (ecma_object_t *object_p, /**< the object */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (options & ECMA_PROPERTY_GET_EXT_REFERENCE)
|
||||
{
|
||||
@@ -456,9 +454,8 @@ ecma_op_object_find_own (ecma_value_t base_value, /**< base value */
|
||||
{
|
||||
uint32_t index = ecma_string_get_array_index (property_name_p);
|
||||
|
||||
if (index != ECMA_STRING_NOT_ARRAY_INDEX)
|
||||
{
|
||||
if (index < ext_object_p->u.pseudo_array.u1.length)
|
||||
if (index != ECMA_STRING_NOT_ARRAY_INDEX
|
||||
&& index < ext_object_p->u.pseudo_array.u1.length)
|
||||
{
|
||||
ecma_value_t *arg_Literal_p = (ecma_value_t *) (ext_object_p + 1);
|
||||
|
||||
@@ -476,7 +473,6 @@ ecma_op_object_find_own (ecma_value_t base_value, /**< base value */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
|
||||
/* ES2015 9.4.5.4 */
|
||||
if (ecma_is_typedarray (ecma_make_object_value (object_p)))
|
||||
@@ -781,9 +777,8 @@ ecma_op_object_put (ecma_object_t *object_p, /**< the object */
|
||||
{
|
||||
uint32_t index = ecma_string_get_array_index (property_name_p);
|
||||
|
||||
if (index != ECMA_STRING_NOT_ARRAY_INDEX)
|
||||
{
|
||||
if (index < ext_object_p->u.pseudo_array.u1.length)
|
||||
if (index != ECMA_STRING_NOT_ARRAY_INDEX
|
||||
&& index < ext_object_p->u.pseudo_array.u1.length)
|
||||
{
|
||||
ecma_value_t *arg_Literal_p = (ecma_value_t *) (ext_object_p + 1);
|
||||
|
||||
@@ -802,7 +797,6 @@ ecma_op_object_put (ecma_object_t *object_p, /**< the object */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
|
||||
/* ES2015 9.4.5.5 */
|
||||
if (ecma_is_typedarray (ecma_make_object_value (object_p)))
|
||||
|
||||
@@ -1777,16 +1777,14 @@ lexer_construct_number_object (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
int32_t int_num = (int32_t) num;
|
||||
|
||||
if (int_num == num)
|
||||
{
|
||||
if (int_num <= CBC_PUSH_NUMBER_BYTE_RANGE_END
|
||||
if (int_num == num
|
||||
&& int_num <= CBC_PUSH_NUMBER_BYTE_RANGE_END
|
||||
&& (int_num != 0 || !is_negative_number))
|
||||
{
|
||||
context_p->lit_object.index = (uint16_t) int_num;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_negative_number)
|
||||
{
|
||||
|
||||
@@ -60,10 +60,9 @@ parser_push_result (parser_context_t *context_p) /**< context */
|
||||
{
|
||||
JERRY_ASSERT (CBC_SAME_ARGS (context_p->last_cbc_opcode, context_p->last_cbc_opcode + 1));
|
||||
|
||||
if (context_p->last_cbc_opcode == CBC_POST_INCR
|
||||
if ((context_p->last_cbc_opcode == CBC_POST_INCR
|
||||
|| context_p->last_cbc_opcode == CBC_POST_DECR)
|
||||
{
|
||||
if (context_p->stack_depth >= context_p->stack_limit)
|
||||
&& context_p->stack_depth >= context_p->stack_limit)
|
||||
{
|
||||
/* Stack limit is increased for CBC_POST_INCR_PUSH_RESULT
|
||||
* and CBC_POST_DECR_PUSH_RESULT opcodes. Needed by vm.c. */
|
||||
@@ -76,7 +75,6 @@ parser_push_result (parser_context_t *context_p) /**< context */
|
||||
parser_raise_error (context_p, PARSER_ERR_STACK_LIMIT_REACHED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context_p->last_cbc_opcode++;
|
||||
parser_flush_cbc (context_p);
|
||||
@@ -1501,9 +1499,8 @@ parser_process_binary_opcodes (parser_context_t *context_p, /**< context */
|
||||
opcode = (cbc_opcode_t) context_p->stack_top_uint8;
|
||||
parser_stack_pop_uint8 (context_p);
|
||||
|
||||
if (context_p->last_cbc_opcode == CBC_PUSH_LITERAL)
|
||||
{
|
||||
if (opcode == CBC_ASSIGN_SET_IDENT)
|
||||
if (context_p->last_cbc_opcode == CBC_PUSH_LITERAL
|
||||
&& opcode == CBC_ASSIGN_SET_IDENT)
|
||||
{
|
||||
JERRY_ASSERT (CBC_ARGS_EQ (CBC_ASSIGN_LITERAL_SET_IDENT,
|
||||
CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2));
|
||||
@@ -1511,7 +1508,6 @@ parser_process_binary_opcodes (parser_context_t *context_p, /**< context */
|
||||
context_p->last_cbc_opcode = CBC_ASSIGN_LITERAL_SET_IDENT;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (cbc_flags[opcode] & CBC_HAS_LITERAL_ARG)
|
||||
{
|
||||
|
||||
@@ -1245,15 +1245,13 @@ parser_parse_try_statement_end (parser_context_t *context_p) /**< context */
|
||||
try_statement.type = parser_finally_block;
|
||||
}
|
||||
}
|
||||
else if (try_statement.type == parser_try_block)
|
||||
{
|
||||
if (context_p->token.type != LEXER_KEYW_CATCH
|
||||
else if (try_statement.type == parser_try_block
|
||||
&& context_p->token.type != LEXER_KEYW_CATCH
|
||||
&& context_p->token.type != LEXER_KEYW_FINALLY)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_CATCH_FINALLY_EXPECTED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (try_statement.type == parser_finally_block)
|
||||
{
|
||||
@@ -1694,13 +1692,12 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
lexer_next_token (context_p);
|
||||
|
||||
if (context_p->token.type != LEXER_SEMICOLON
|
||||
&& context_p->token.type != LEXER_RIGHT_BRACE)
|
||||
{
|
||||
if (!(context_p->token.flags & LEXER_WAS_NEWLINE)
|
||||
&& context_p->token.type != LEXER_RIGHT_BRACE
|
||||
&& (!(context_p->token.flags & LEXER_WAS_NEWLINE)
|
||||
|| LEXER_IS_BINARY_OP_TOKEN (context_p->token.type)
|
||||
|| context_p->token.type == LEXER_LEFT_PAREN
|
||||
|| context_p->token.type == LEXER_LEFT_SQUARE
|
||||
|| context_p->token.type == LEXER_DOT)
|
||||
|| context_p->token.type == LEXER_DOT))
|
||||
{
|
||||
/* The string is part of an expression statement. */
|
||||
context_p->status_flags = status_flags;
|
||||
@@ -1729,7 +1726,6 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
context_p->token.type = LEXER_EXPRESSION_START;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PARSER_DUMP_BYTE_CODE
|
||||
if (context_p->is_show_opcodes
|
||||
@@ -1746,10 +1742,9 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
|
||||
/* The last directive prologue can be the result of the script. */
|
||||
if (!(context_p->status_flags & PARSER_IS_FUNCTION))
|
||||
{
|
||||
if (context_p->token.type != LEXER_LITERAL
|
||||
|| context_p->token.lit_location.type != LEXER_STRING_LITERAL)
|
||||
if (!(context_p->status_flags & PARSER_IS_FUNCTION)
|
||||
&& (context_p->token.type != LEXER_LITERAL
|
||||
|| context_p->token.lit_location.type != LEXER_STRING_LITERAL))
|
||||
{
|
||||
lexer_construct_literal_object (context_p, &lit_location, LEXER_STRING_LITERAL);
|
||||
parser_emit_cbc_literal_from_token (context_p, CBC_PUSH_LITERAL);
|
||||
@@ -1757,7 +1752,6 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
parser_flush_cbc (context_p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (context_p->status_flags & PARSER_IS_STRICT
|
||||
&& context_p->status_flags & PARSER_HAS_NON_STRICT_ARG)
|
||||
|
||||
Reference in New Issue
Block a user