mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2026-02-07 16:26:36 +00:00
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:
parent
b61d0ed856
commit
b4b0b7d572
@ -1511,12 +1511,10 @@ ecma_string_get_chars (const ecma_string_t *string_p, /**< ecma-string */
|
||||
}
|
||||
|
||||
*size_p = size;
|
||||
if (*flags_p & ECMA_STRING_FLAG_IS_ASCII)
|
||||
if ((*flags_p & ECMA_STRING_FLAG_IS_ASCII)
|
||||
&& length != size)
|
||||
{
|
||||
if (length != size)
|
||||
{
|
||||
*flags_p = (uint8_t) (*flags_p & ~ECMA_STRING_FLAG_IS_ASCII);
|
||||
}
|
||||
*flags_p = (uint8_t) (*flags_p & ~ECMA_STRING_FLAG_IS_ASCII);
|
||||
}
|
||||
|
||||
return result_p;
|
||||
|
||||
@ -771,14 +771,12 @@ 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 (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))
|
||||
{
|
||||
if (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_native_pointer (property_p);
|
||||
break;
|
||||
}
|
||||
|
||||
ecma_free_value_if_not_object (ECMA_PROPERTY_VALUE_PTR (property_p)->value);
|
||||
|
||||
@ -1716,13 +1716,11 @@ 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_is_value_found (get_value)
|
||||
&& ecma_op_strict_equality_compare (arg1, get_value))
|
||||
{
|
||||
/* 9.b.i, 9.b.ii */
|
||||
if (ecma_op_strict_equality_compare (arg1, get_value))
|
||||
{
|
||||
found_index = ((ecma_number_t) from_idx);
|
||||
}
|
||||
found_index = ((ecma_number_t) from_idx);
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (get_value);
|
||||
@ -1863,13 +1861,11 @@ 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_is_value_found (get_value)
|
||||
&& ecma_op_strict_equality_compare (search_element, get_value))
|
||||
{
|
||||
/* 8.b.i, 8.b.ii */
|
||||
if (ecma_op_strict_equality_compare (search_element, get_value))
|
||||
{
|
||||
num = ((ecma_number_t) from_idx);
|
||||
}
|
||||
num = ((ecma_number_t) from_idx);
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (get_value);
|
||||
|
||||
@ -190,17 +190,16 @@ 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 (strip_prefix
|
||||
&& ((end_p - start_p) >= 2)
|
||||
&& (current == LIT_CHAR_0))
|
||||
{
|
||||
if (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)
|
||||
{
|
||||
ecma_char_t next = *string_curr_p;
|
||||
if (next == LIT_CHAR_LOWERCASE_X || next == LIT_CHAR_UPPERCASE_X)
|
||||
{
|
||||
/* Skip the 'x' or 'X' characters. */
|
||||
start_p = ++string_curr_p;
|
||||
rad = 16;
|
||||
}
|
||||
/* Skip the 'x' or 'X' characters. */
|
||||
start_p = ++string_curr_p;
|
||||
rad = 16;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -213,27 +213,25 @@ ecma_builtin_math_dispatch_routine (uint16_t builtin_routine_id, /**< built-in w
|
||||
}
|
||||
}
|
||||
|
||||
if (builtin_routine_id >= ECMA_MATH_OBJECT_ATAN2)
|
||||
if (builtin_routine_id >= ECMA_MATH_OBJECT_ATAN2
|
||||
&& arguments_number >= 2)
|
||||
{
|
||||
if (arguments_number >= 2)
|
||||
if (ecma_is_value_number (arguments_list[1]))
|
||||
{
|
||||
if (ecma_is_value_number (arguments_list[1]))
|
||||
y = ecma_get_number_from_value (arguments_list[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_value_t value = ecma_op_to_number (arguments_list[1]);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (value))
|
||||
{
|
||||
y = ecma_get_number_from_value (arguments_list[1]);
|
||||
return value;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_value_t value = ecma_op_to_number (arguments_list[1]);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
y = ecma_get_number_from_value (value);
|
||||
|
||||
y = ecma_get_number_from_value (value);
|
||||
|
||||
ecma_fast_free_value (value);
|
||||
}
|
||||
ecma_fast_free_value (value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -198,12 +198,10 @@ ecma_builtin_typedarray_prototype_exec_routine (ecma_value_t this_arg, /**< this
|
||||
ret_value = ECMA_VALUE_FALSE;
|
||||
}
|
||||
}
|
||||
else if (mode == TYPEDARRAY_ROUTINE_SOME)
|
||||
else if (mode == TYPEDARRAY_ROUTINE_SOME
|
||||
&& ecma_op_to_boolean (call_value))
|
||||
{
|
||||
if (ecma_op_to_boolean (call_value))
|
||||
{
|
||||
ret_value = ECMA_VALUE_TRUE;
|
||||
}
|
||||
ret_value = ECMA_VALUE_TRUE;
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (call_value);
|
||||
|
||||
@ -775,14 +775,10 @@ 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_get_defined || prop_desc.is_set_defined)
|
||||
&& (prop_desc.is_value_defined || prop_desc.is_writable_defined))
|
||||
{
|
||||
if (prop_desc.is_value_defined
|
||||
|| prop_desc.is_writable_defined)
|
||||
{
|
||||
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Accessors cannot be writable."));
|
||||
}
|
||||
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Accessors cannot be writable."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -264,29 +264,27 @@ 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 != ECMA_STRING_NOT_ARRAY_INDEX
|
||||
&& index < ext_object_p->u.pseudo_array.u1.length)
|
||||
{
|
||||
if (index < ext_object_p->u.pseudo_array.u1.length)
|
||||
ecma_value_t *arg_Literal_p = (ecma_value_t *) (ext_object_p + 1);
|
||||
|
||||
if (arg_Literal_p[index] != ECMA_VALUE_EMPTY)
|
||||
{
|
||||
ecma_value_t *arg_Literal_p = (ecma_value_t *) (ext_object_p + 1);
|
||||
ecma_string_t *arg_name_p = ecma_get_string_from_value (arg_Literal_p[index]);
|
||||
|
||||
if (arg_Literal_p[index] != ECMA_VALUE_EMPTY)
|
||||
{
|
||||
ecma_string_t *arg_name_p = ecma_get_string_from_value (arg_Literal_p[index]);
|
||||
ecma_object_t *lex_env_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t,
|
||||
ext_object_p->u.pseudo_array.u2.lex_env_cp);
|
||||
|
||||
ecma_object_t *lex_env_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t,
|
||||
ext_object_p->u.pseudo_array.u2.lex_env_cp);
|
||||
JERRY_ASSERT (lex_env_p != NULL
|
||||
&& ecma_is_lexical_environment (lex_env_p));
|
||||
|
||||
JERRY_ASSERT (lex_env_p != NULL
|
||||
&& ecma_is_lexical_environment (lex_env_p));
|
||||
ecma_value_t binding_value = ecma_op_get_binding_value (lex_env_p, arg_name_p, true);
|
||||
|
||||
ecma_value_t binding_value = ecma_op_get_binding_value (lex_env_p, arg_name_p, true);
|
||||
|
||||
ecma_named_data_property_assign_value (object_p,
|
||||
ECMA_PROPERTY_VALUE_PTR (property_p),
|
||||
binding_value);
|
||||
ecma_free_value (binding_value);
|
||||
}
|
||||
ecma_named_data_property_assign_value (object_p,
|
||||
ECMA_PROPERTY_VALUE_PTR (property_p),
|
||||
binding_value);
|
||||
ecma_free_value (binding_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -456,24 +454,22 @@ 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 != ECMA_STRING_NOT_ARRAY_INDEX
|
||||
&& index < ext_object_p->u.pseudo_array.u1.length)
|
||||
{
|
||||
if (index < ext_object_p->u.pseudo_array.u1.length)
|
||||
ecma_value_t *arg_Literal_p = (ecma_value_t *) (ext_object_p + 1);
|
||||
|
||||
if (arg_Literal_p[index] != ECMA_VALUE_EMPTY)
|
||||
{
|
||||
ecma_value_t *arg_Literal_p = (ecma_value_t *) (ext_object_p + 1);
|
||||
ecma_string_t *arg_name_p = ecma_get_string_from_value (arg_Literal_p[index]);
|
||||
|
||||
if (arg_Literal_p[index] != ECMA_VALUE_EMPTY)
|
||||
{
|
||||
ecma_string_t *arg_name_p = ecma_get_string_from_value (arg_Literal_p[index]);
|
||||
ecma_object_t *lex_env_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t,
|
||||
ext_object_p->u.pseudo_array.u2.lex_env_cp);
|
||||
|
||||
ecma_object_t *lex_env_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t,
|
||||
ext_object_p->u.pseudo_array.u2.lex_env_cp);
|
||||
JERRY_ASSERT (lex_env_p != NULL
|
||||
&& ecma_is_lexical_environment (lex_env_p));
|
||||
|
||||
JERRY_ASSERT (lex_env_p != NULL
|
||||
&& ecma_is_lexical_environment (lex_env_p));
|
||||
|
||||
return ecma_op_get_binding_value (lex_env_p, arg_name_p, true);
|
||||
}
|
||||
return ecma_op_get_binding_value (lex_env_p, arg_name_p, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -781,25 +777,23 @@ 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 != ECMA_STRING_NOT_ARRAY_INDEX
|
||||
&& index < ext_object_p->u.pseudo_array.u1.length)
|
||||
{
|
||||
if (index < ext_object_p->u.pseudo_array.u1.length)
|
||||
ecma_value_t *arg_Literal_p = (ecma_value_t *) (ext_object_p + 1);
|
||||
|
||||
if (arg_Literal_p[index] != ECMA_VALUE_EMPTY)
|
||||
{
|
||||
ecma_value_t *arg_Literal_p = (ecma_value_t *) (ext_object_p + 1);
|
||||
ecma_string_t *arg_name_p = ecma_get_string_from_value (arg_Literal_p[index]);
|
||||
|
||||
if (arg_Literal_p[index] != ECMA_VALUE_EMPTY)
|
||||
{
|
||||
ecma_string_t *arg_name_p = ecma_get_string_from_value (arg_Literal_p[index]);
|
||||
ecma_object_t *lex_env_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t,
|
||||
ext_object_p->u.pseudo_array.u2.lex_env_cp);
|
||||
|
||||
ecma_object_t *lex_env_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t,
|
||||
ext_object_p->u.pseudo_array.u2.lex_env_cp);
|
||||
JERRY_ASSERT (lex_env_p != NULL
|
||||
&& ecma_is_lexical_environment (lex_env_p));
|
||||
|
||||
JERRY_ASSERT (lex_env_p != NULL
|
||||
&& ecma_is_lexical_environment (lex_env_p));
|
||||
|
||||
ecma_op_set_mutable_binding (lex_env_p, arg_name_p, value, true);
|
||||
return ECMA_VALUE_TRUE;
|
||||
}
|
||||
ecma_op_set_mutable_binding (lex_env_p, arg_name_p, value, true);
|
||||
return ECMA_VALUE_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1777,14 +1777,12 @@ lexer_construct_number_object (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
int32_t int_num = (int32_t) num;
|
||||
|
||||
if (int_num == num)
|
||||
if (int_num == num
|
||||
&& int_num <= CBC_PUSH_NUMBER_BYTE_RANGE_END
|
||||
&& (int_num != 0 || !is_negative_number))
|
||||
{
|
||||
if (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;
|
||||
}
|
||||
context_p->lit_object.index = (uint16_t) int_num;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -60,21 +60,19 @@ 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
|
||||
|| context_p->last_cbc_opcode == CBC_POST_DECR)
|
||||
if ((context_p->last_cbc_opcode == CBC_POST_INCR
|
||||
|| context_p->last_cbc_opcode == CBC_POST_DECR)
|
||||
&& context_p->stack_depth >= context_p->stack_limit)
|
||||
{
|
||||
if (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. */
|
||||
JERRY_ASSERT (context_p->stack_depth == context_p->stack_limit);
|
||||
|
||||
context_p->stack_limit++;
|
||||
|
||||
if (context_p->stack_limit > PARSER_MAXIMUM_STACK_LIMIT)
|
||||
{
|
||||
/* Stack limit is increased for CBC_POST_INCR_PUSH_RESULT
|
||||
* and CBC_POST_DECR_PUSH_RESULT opcodes. Needed by vm.c. */
|
||||
JERRY_ASSERT (context_p->stack_depth == context_p->stack_limit);
|
||||
|
||||
context_p->stack_limit++;
|
||||
|
||||
if (context_p->stack_limit > PARSER_MAXIMUM_STACK_LIMIT)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_STACK_LIMIT_REACHED);
|
||||
}
|
||||
parser_raise_error (context_p, PARSER_ERR_STACK_LIMIT_REACHED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1501,16 +1499,14 @@ 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 (context_p->last_cbc_opcode == CBC_PUSH_LITERAL
|
||||
&& opcode == CBC_ASSIGN_SET_IDENT)
|
||||
{
|
||||
if (opcode == CBC_ASSIGN_SET_IDENT)
|
||||
{
|
||||
JERRY_ASSERT (CBC_ARGS_EQ (CBC_ASSIGN_LITERAL_SET_IDENT,
|
||||
CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2));
|
||||
context_p->last_cbc.value = parser_stack_pop_uint16 (context_p);
|
||||
context_p->last_cbc_opcode = CBC_ASSIGN_LITERAL_SET_IDENT;
|
||||
continue;
|
||||
}
|
||||
JERRY_ASSERT (CBC_ARGS_EQ (CBC_ASSIGN_LITERAL_SET_IDENT,
|
||||
CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2));
|
||||
context_p->last_cbc.value = parser_stack_pop_uint16 (context_p);
|
||||
context_p->last_cbc_opcode = CBC_ASSIGN_LITERAL_SET_IDENT;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cbc_flags[opcode] & CBC_HAS_LITERAL_ARG)
|
||||
|
||||
@ -1245,13 +1245,11 @@ 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)
|
||||
else if (try_statement.type == parser_try_block
|
||||
&& context_p->token.type != LEXER_KEYW_CATCH
|
||||
&& context_p->token.type != LEXER_KEYW_FINALLY)
|
||||
{
|
||||
if (context_p->token.type != LEXER_KEYW_CATCH
|
||||
&& context_p->token.type != LEXER_KEYW_FINALLY)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_CATCH_FINALLY_EXPECTED);
|
||||
}
|
||||
parser_raise_error (context_p, PARSER_ERR_CATCH_FINALLY_EXPECTED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1694,41 +1692,39 @@ 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)
|
||||
&& 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))
|
||||
{
|
||||
if (!(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)
|
||||
{
|
||||
/* The string is part of an expression statement. */
|
||||
context_p->status_flags = status_flags;
|
||||
/* The string is part of an expression statement. */
|
||||
context_p->status_flags = status_flags;
|
||||
|
||||
#ifdef JERRY_DEBUGGER
|
||||
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
|
||||
{
|
||||
JERRY_ASSERT (context_p->last_breakpoint_line == 0);
|
||||
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
|
||||
{
|
||||
JERRY_ASSERT (context_p->last_breakpoint_line == 0);
|
||||
|
||||
parser_emit_cbc (context_p, CBC_BREAKPOINT_DISABLED);
|
||||
parser_flush_cbc (context_p);
|
||||
parser_emit_cbc (context_p, CBC_BREAKPOINT_DISABLED);
|
||||
parser_flush_cbc (context_p);
|
||||
|
||||
parser_append_breakpoint_info (context_p, JERRY_DEBUGGER_BREAKPOINT_LIST, context_p->token.line);
|
||||
parser_append_breakpoint_info (context_p, JERRY_DEBUGGER_BREAKPOINT_LIST, context_p->token.line);
|
||||
|
||||
context_p->last_breakpoint_line = context_p->token.line;
|
||||
}
|
||||
context_p->last_breakpoint_line = context_p->token.line;
|
||||
}
|
||||
#endif /* JERRY_DEBUGGER */
|
||||
#ifdef JERRY_ENABLE_LINE_INFO
|
||||
parser_emit_line_info (context_p, context_p->token.line, false);
|
||||
parser_emit_line_info (context_p, context_p->token.line, false);
|
||||
#endif /* JERRY_ENABLE_LINE_INFO */
|
||||
|
||||
lexer_construct_literal_object (context_p, &lit_location, LEXER_STRING_LITERAL);
|
||||
parser_emit_cbc_literal_from_token (context_p, CBC_PUSH_LITERAL);
|
||||
/* The extra_value is used for saving the token. */
|
||||
context_p->token.extra_value = context_p->token.type;
|
||||
context_p->token.type = LEXER_EXPRESSION_START;
|
||||
break;
|
||||
}
|
||||
lexer_construct_literal_object (context_p, &lit_location, LEXER_STRING_LITERAL);
|
||||
parser_emit_cbc_literal_from_token (context_p, CBC_PUSH_LITERAL);
|
||||
/* The extra_value is used for saving the token. */
|
||||
context_p->token.extra_value = context_p->token.type;
|
||||
context_p->token.type = LEXER_EXPRESSION_START;
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef PARSER_DUMP_BYTE_CODE
|
||||
@ -1746,16 +1742,14 @@ 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->status_flags & PARSER_IS_FUNCTION)
|
||||
&& (context_p->token.type != LEXER_LITERAL
|
||||
|| context_p->token.lit_location.type != LEXER_STRING_LITERAL))
|
||||
{
|
||||
if (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);
|
||||
parser_emit_cbc (context_p, CBC_POP_BLOCK);
|
||||
parser_flush_cbc (context_p);
|
||||
}
|
||||
lexer_construct_literal_object (context_p, &lit_location, LEXER_STRING_LITERAL);
|
||||
parser_emit_cbc_literal_from_token (context_p, CBC_PUSH_LITERAL);
|
||||
parser_emit_cbc (context_p, CBC_POP_BLOCK);
|
||||
parser_flush_cbc (context_p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user