Skip to content

Commit 5151f91

Browse files
rtakacszherczeg
authored andcommitted
Use logical operators for bool converions. (#2620)
The explicit boolean type conversion (introduced by #2575) desn't work with TizenRT if custom boolean representation is used. Of course, TizenRT gives an opportunity to use the C99 standard boolean (that works well if that is set). I've replaced all the explicit boolean type conversions with double negations that helps to work JerryScript well with custom boolean types. JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs.uszeged@partner.samsung.com
1 parent 17178ec commit 5151f91

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

jerry-core/ecma/operations/ecma-function-object.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,16 +666,16 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
666666
const ecma_compiled_code_t *bytecode_data_p = ecma_op_function_get_compiled_code (ext_func_p);
667667

668668
#ifndef CONFIG_DISABLE_ES2015_CLASS
669-
bool is_class_constructor = (bool) (bytecode_data_p->status_flags & CBC_CODE_FLAGS_CONSTRUCTOR);
669+
bool is_class_constructor = (bytecode_data_p->status_flags & CBC_CODE_FLAGS_CONSTRUCTOR) != 0;
670670

671671
if (is_class_constructor && !ecma_op_function_has_construct_flag (arguments_list_p))
672672
{
673673
return ecma_raise_type_error (ECMA_ERR_MSG ("Class constructor cannot be invoked without 'new'."));
674674
}
675675
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
676676

677-
bool is_strict = (bool) (bytecode_data_p->status_flags & CBC_CODE_FLAGS_STRICT_MODE);
678-
bool is_no_lex_env = (bool) (bytecode_data_p->status_flags & CBC_CODE_FLAGS_LEXICAL_ENV_NOT_NEEDED);
677+
bool is_strict = (bytecode_data_p->status_flags & CBC_CODE_FLAGS_STRICT_MODE) != 0;
678+
bool is_no_lex_env = (bytecode_data_p->status_flags & CBC_CODE_FLAGS_LEXICAL_ENV_NOT_NEEDED) != 0;
679679

680680
/* 1. */
681681
if (!is_strict)
@@ -775,7 +775,7 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
775775

776776
const ecma_compiled_code_t *bytecode_data_p = ecma_op_arrow_function_get_compiled_code (arrow_func_p);
777777

778-
is_no_lex_env = (bool) (bytecode_data_p->status_flags & CBC_CODE_FLAGS_LEXICAL_ENV_NOT_NEEDED);
778+
is_no_lex_env = (bytecode_data_p->status_flags & CBC_CODE_FLAGS_LEXICAL_ENV_NOT_NEEDED) != 0;
779779

780780
ecma_object_t *local_env_p = scope_p;
781781

jerry-core/parser/js/js-lexer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2194,7 +2194,7 @@ lexer_construct_regexp_object (parser_context_t *context_p, /**< context */
21942194
current_flags);
21952195
ecma_deref_ecma_string (pattern_str_p);
21962196

2197-
bool is_throw = (bool) ECMA_IS_VALUE_ERROR (completion_value);
2197+
bool is_throw = ECMA_IS_VALUE_ERROR (completion_value) != 0;
21982198

21992199
ecma_free_value (completion_value);
22002200

jerry-core/parser/js/js-parser-expr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ parser_parse_class_literal (parser_context_t *context_p) /**< context */
418418
JERRY_ASSERT (context_p->last_cbc_opcode == CBC_PUSH_LITERAL);
419419

420420
cbc_ext_opcode_t opcode;
421-
bool is_static = (bool) (status_flags & PARSER_CLASS_STATIC_FUNCTION);
421+
bool is_static = (status_flags & PARSER_CLASS_STATIC_FUNCTION) != 0;
422422

423423
if (is_computed)
424424
{
@@ -1366,7 +1366,7 @@ parser_parse_unary_expression (parser_context_t *context_p, /**< context */
13661366
break;
13671367
}
13681368

1369-
bool is_static = (bool) (context_p->status_flags & PARSER_CLASS_STATIC_FUNCTION);
1369+
bool is_static = (context_p->status_flags & PARSER_CLASS_STATIC_FUNCTION) != 0;
13701370
parser_emit_cbc_ext (context_p, is_static ? CBC_EXT_PUSH_STATIC_SUPER : CBC_EXT_PUSH_SUPER);
13711371
break;
13721372
}

0 commit comments

Comments
 (0)