Fix direct call to eval from strict mode code.

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
Ruben Ayrapetyan
2015-06-28 22:26:50 +03:00
committed by Evgeny Gavrin
parent 6573ffd632
commit 984e269db6
4 changed files with 28 additions and 5 deletions
+13 -3
View File
@@ -3062,6 +3062,8 @@ parser_parse_program (const char *source_p, /**< source code buffer */
size_t source_size, /**< source code size in bytes */
bool in_function, /**< flag indicating if we are parsing body of a function */
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 */
const opcode_t **out_opcodes_p) /**< out: generated byte-code array
* (in case there were no syntax errors) */
{
@@ -3088,6 +3090,7 @@ parser_parse_program (const char *source_p, /**< source code buffer */
STACK_INIT (scopes);
STACK_PUSH (scopes, scopes_tree_init (NULL));
serializer_set_scope (STACK_TOP (scopes));
scopes_tree_set_strict_mode (STACK_TOP (scopes), is_strict);
lexer_set_strict_mode (scopes_tree_strict_mode (STACK_TOP (scopes)));
jmp_buf *syntax_error_label_p = syntax_get_syntax_error_longjmp_label ();
@@ -3165,7 +3168,7 @@ parser_parse_script (const char *source, /**< source script */
const opcode_t **opcodes_p) /**< out: generated byte-code array
* (in case there were no syntax errors) */
{
return parser_parse_program (source, source_size, false, false, opcodes_p);
return parser_parse_program (source, source_size, false, false, false, opcodes_p);
} /* parser_parse_script */
/**
@@ -3177,10 +3180,12 @@ parser_parse_script (const char *source, /**< source script */
bool
parser_parse_eval (const char *source, /**< string passed to eval() */
size_t source_size, /**< string size in bytes */
bool is_strict, /**< flag, indicating whether eval is called
* from strict code in direct mode */
const opcode_t **opcodes_p) /**< out: generated byte-code array
* (in case there were no syntax errors) */
{
return parser_parse_program (source, source_size, false, true, opcodes_p);
return parser_parse_program (source, source_size, false, true, is_strict, opcodes_p);
} /* parser_parse_eval */
/**
@@ -3206,7 +3211,12 @@ parser_parse_new_function (const char **params, /**< array of arguments of new F
FIXME ("check parameter's name for syntax errors");
lit_find_or_create_literal_from_charset ((ecma_char_t *) params[i], (ecma_length_t) strlen (params[i]));
}
return parser_parse_program (params[params_count - 1], strlen (params[params_count - 1]), true, false, out_opcodes_p);
return parser_parse_program (params[params_count - 1],
strlen (params[params_count - 1]),
true,
false,
false,
out_opcodes_p);
} /* parser_parse_new_function */
/**