Add support of function expressions scopes. Uncomment tests.

This commit is contained in:
Ilmir Usmanov
2014-10-21 22:22:04 +04:00
parent 62a42fa087
commit ec6572d501
5 changed files with 38 additions and 2 deletions
+7 -2
View File
@@ -1663,12 +1663,17 @@ opfunc_meta (opcode_t opdata, /**< operation data */
{
return ecma_make_meta_completion_value ();
}
case OPCODE_META_TYPE_STRICT_CODE:
{
FIXME (/* Handle in run_int_from_pos */);
return ecma_make_meta_completion_value ();
}
case OPCODE_META_TYPE_UNDEFINED:
case OPCODE_META_TYPE_THIS_ARG:
case OPCODE_META_TYPE_FUNCTION_END:
case OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER:
case OPCODE_META_TYPE_STRICT_CODE:
{
JERRY_UNREACHABLE ();
}
+12
View File
@@ -1331,6 +1331,7 @@ parse_function_expression (void)
STACK_DECLARE_USAGE (IDX)
STACK_DECLARE_USAGE (U16)
STACK_DECLARE_USAGE (nestings)
STACK_DECLARE_USAGE (U8)
assert_keyword (KW_FUNCTION);
@@ -1353,11 +1354,17 @@ parse_function_expression (void)
token_after_newlines_must_be (TOK_OPEN_BRACE);
STACK_PUSH (U8, scopes_tree_strict_mode (STACK_TOP (scopes)) ? 1 : 0);
scopes_tree_set_strict_mode (STACK_TOP (scopes), false);
skip_newlines ();
push_nesting (NESTING_FUNCTION);
parse_source_element_list (false);
pop_nesting (NESTING_FUNCTION);
scopes_tree_set_strict_mode (STACK_TOP (scopes), STACK_TOP (U8) != 0);
STACK_DROP (U8, 1);
next_token_must_be (TOK_CLOSE_BRACE);
DUMP_VOID_OPCODE (ret);
@@ -1367,6 +1374,7 @@ parse_function_expression (void)
STACK_DROP (IDX, 1);
STACK_DROP (U16, 1);
STACK_CHECK_USAGE (U8);
STACK_CHECK_USAGE (U16);
STACK_CHECK_USAGE_LHS ();
STACK_CHECK_USAGE (nestings);
@@ -3837,10 +3845,14 @@ preparse_scope (bool is_global)
}
else if (is_keyword (KW_FUNCTION))
{
STACK_PUSH (U8, scopes_tree_strict_mode (STACK_TOP (scopes)) ? 1 : 0);
scopes_tree_set_strict_mode (STACK_TOP (scopes), false);
skip_newlines ();
skip_optional_name_and_parens ();
skip_newlines ();
skip_braces ();
scopes_tree_set_strict_mode (STACK_TOP (scopes), STACK_TOP (U8) != 0);
STACK_DROP (U8, 1);
}
skip_newlines ();
}