Add support of function expressions scopes. Uncomment tests.
This commit is contained in:
@@ -1663,12 +1663,17 @@ opfunc_meta (opcode_t opdata, /**< operation data */
|
|||||||
{
|
{
|
||||||
return ecma_make_meta_completion_value ();
|
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_UNDEFINED:
|
||||||
case OPCODE_META_TYPE_THIS_ARG:
|
case OPCODE_META_TYPE_THIS_ARG:
|
||||||
|
|
||||||
case OPCODE_META_TYPE_FUNCTION_END:
|
case OPCODE_META_TYPE_FUNCTION_END:
|
||||||
case OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER:
|
case OPCODE_META_TYPE_CATCH_EXCEPTION_IDENTIFIER:
|
||||||
case OPCODE_META_TYPE_STRICT_CODE:
|
|
||||||
{
|
{
|
||||||
JERRY_UNREACHABLE ();
|
JERRY_UNREACHABLE ();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1331,6 +1331,7 @@ parse_function_expression (void)
|
|||||||
STACK_DECLARE_USAGE (IDX)
|
STACK_DECLARE_USAGE (IDX)
|
||||||
STACK_DECLARE_USAGE (U16)
|
STACK_DECLARE_USAGE (U16)
|
||||||
STACK_DECLARE_USAGE (nestings)
|
STACK_DECLARE_USAGE (nestings)
|
||||||
|
STACK_DECLARE_USAGE (U8)
|
||||||
|
|
||||||
assert_keyword (KW_FUNCTION);
|
assert_keyword (KW_FUNCTION);
|
||||||
|
|
||||||
@@ -1353,11 +1354,17 @@ parse_function_expression (void)
|
|||||||
|
|
||||||
token_after_newlines_must_be (TOK_OPEN_BRACE);
|
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 ();
|
skip_newlines ();
|
||||||
push_nesting (NESTING_FUNCTION);
|
push_nesting (NESTING_FUNCTION);
|
||||||
parse_source_element_list (false);
|
parse_source_element_list (false);
|
||||||
pop_nesting (NESTING_FUNCTION);
|
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);
|
next_token_must_be (TOK_CLOSE_BRACE);
|
||||||
|
|
||||||
DUMP_VOID_OPCODE (ret);
|
DUMP_VOID_OPCODE (ret);
|
||||||
@@ -1367,6 +1374,7 @@ parse_function_expression (void)
|
|||||||
STACK_DROP (IDX, 1);
|
STACK_DROP (IDX, 1);
|
||||||
STACK_DROP (U16, 1);
|
STACK_DROP (U16, 1);
|
||||||
|
|
||||||
|
STACK_CHECK_USAGE (U8);
|
||||||
STACK_CHECK_USAGE (U16);
|
STACK_CHECK_USAGE (U16);
|
||||||
STACK_CHECK_USAGE_LHS ();
|
STACK_CHECK_USAGE_LHS ();
|
||||||
STACK_CHECK_USAGE (nestings);
|
STACK_CHECK_USAGE (nestings);
|
||||||
@@ -3837,10 +3845,14 @@ preparse_scope (bool is_global)
|
|||||||
}
|
}
|
||||||
else if (is_keyword (KW_FUNCTION))
|
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_newlines ();
|
||||||
skip_optional_name_and_parens ();
|
skip_optional_name_and_parens ();
|
||||||
skip_newlines ();
|
skip_newlines ();
|
||||||
skip_braces ();
|
skip_braces ();
|
||||||
|
scopes_tree_set_strict_mode (STACK_TOP (scopes), STACK_TOP (U8) != 0);
|
||||||
|
STACK_DROP (U8, 1);
|
||||||
}
|
}
|
||||||
skip_newlines ();
|
skip_newlines ();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
var let = 1;
|
||||||
|
})();
|
||||||
Reference in New Issue
Block a user