Fix handling of SyntaxError in FormalParameterList during 'new Function' constructor operation.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
@@ -3127,8 +3127,6 @@ parse_source_element_list (bool is_global, /**< flag, indicating that we parsing
|
||||
static jsp_status_t
|
||||
parser_parse_program (const jerry_api_char_t *source_p, /**< source code buffer */
|
||||
size_t source_size, /**< source code size in bytes */
|
||||
bool in_dyn_constructed_function, /**< flag indicating if we are parsing body of a function,
|
||||
* constructed using 'new Function (...)'-like expression */
|
||||
bool in_eval, /**< flag indicating if we are parsing body of eval code */
|
||||
bool is_strict, /**< flag, indicating whether current code
|
||||
* inherited strict mode from code of an outer scope */
|
||||
@@ -3140,14 +3138,9 @@ parser_parse_program (const jerry_api_char_t *source_p, /**< source code buffer
|
||||
{
|
||||
JERRY_ASSERT (out_bytecode_data_p != NULL);
|
||||
|
||||
JERRY_ASSERT (!(in_dyn_constructed_function && in_eval));
|
||||
|
||||
inside_function = in_dyn_constructed_function;
|
||||
inside_eval = in_eval;
|
||||
|
||||
scope_type_t scope_type = (in_dyn_constructed_function ? SCOPE_TYPE_FUNCTION
|
||||
: (in_eval ? SCOPE_TYPE_EVAL
|
||||
: SCOPE_TYPE_GLOBAL));
|
||||
scope_type_t scope_type = (in_eval ? SCOPE_TYPE_EVAL : SCOPE_TYPE_GLOBAL);
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
volatile bool is_parse_finished = false;
|
||||
@@ -3201,11 +3194,7 @@ parser_parse_program (const jerry_api_char_t *source_p, /**< source code buffer
|
||||
skip_newlines ();
|
||||
JERRY_ASSERT (token_is (TOK_EOF));
|
||||
|
||||
if (in_dyn_constructed_function)
|
||||
{
|
||||
dump_ret ();
|
||||
}
|
||||
else if (inside_eval)
|
||||
if (inside_eval)
|
||||
{
|
||||
dump_retval (eval_ret_operand ());
|
||||
}
|
||||
@@ -3283,7 +3272,7 @@ parser_parse_script (const jerry_api_char_t *source, /**< source script */
|
||||
const bytecode_data_header_t **out_bytecode_data_p) /**< out: generated byte-code array
|
||||
* (in case there were no syntax errors) */
|
||||
{
|
||||
return parser_parse_program (source, source_size, false, false, false, out_bytecode_data_p, NULL);
|
||||
return parser_parse_program (source, source_size, false, false, out_bytecode_data_p, NULL);
|
||||
} /* parser_parse_script */
|
||||
|
||||
/**
|
||||
@@ -3306,48 +3295,12 @@ parser_parse_eval (const jerry_api_char_t *source, /**< string passed to eval()
|
||||
|
||||
return parser_parse_program (source,
|
||||
source_size,
|
||||
false,
|
||||
true,
|
||||
is_strict,
|
||||
out_bytecode_data_p,
|
||||
out_contains_functions_p);
|
||||
} /* parser_parse_eval */
|
||||
|
||||
/**
|
||||
* Parse a function created via new Function call
|
||||
*
|
||||
* NOTE: Array of arguments should contain at least one element.
|
||||
* In case of new Function() call without parameters, empty string should be passed as argument to this
|
||||
* function.
|
||||
*
|
||||
* @return true - if parse finished successfully (no SyntaxError were raised);
|
||||
* false - otherwise.
|
||||
*/
|
||||
jsp_status_t
|
||||
parser_parse_new_function (const jerry_api_char_t **params, /**< array of arguments of new Function (p1, p2, ..., pn,
|
||||
* body) call */
|
||||
const size_t *params_size, /**< sizes of arguments strings */
|
||||
size_t params_count, /**< total number of arguments passed to new Function (...) */
|
||||
const bytecode_data_header_t **out_bytecode_data_p) /**< out: generated byte-code array
|
||||
* (in case there were no syntax
|
||||
* errors) */
|
||||
{
|
||||
// Process arguments
|
||||
JERRY_ASSERT (params_count > 0);
|
||||
for (size_t i = 0; i < params_count - 1; ++i)
|
||||
{
|
||||
FIXME ("check parameter's name for syntax errors");
|
||||
lit_find_or_create_literal_from_utf8_string ((lit_utf8_byte_t *) params[i], (lit_utf8_size_t) params_size[i]);
|
||||
}
|
||||
return parser_parse_program (params[params_count - 1],
|
||||
params_size[params_count - 1],
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
out_bytecode_data_p,
|
||||
NULL);
|
||||
} /* parser_parse_new_function */
|
||||
|
||||
/**
|
||||
* Tell parser whether to dump bytecode
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user