Fix missing var_decl.
JerryScript-DCO-1.0-Signed-off-by: Andrey Shitov a.shitov@samsung.com
This commit is contained in:
committed by
Ruben Ayrapetyan
parent
9b9e537d35
commit
b496e68d27
@@ -65,6 +65,7 @@ static void parse_statement (void);
|
|||||||
static operand parse_assignment_expression (bool);
|
static operand parse_assignment_expression (bool);
|
||||||
static void parse_source_element_list (bool);
|
static void parse_source_element_list (bool);
|
||||||
static operand parse_argument_list (varg_list_type, operand, uint8_t *, operand *);
|
static operand parse_argument_list (varg_list_type, operand, uint8_t *, operand *);
|
||||||
|
static void process_keyword_names (void);
|
||||||
static void skip_braces (void);
|
static void skip_braces (void);
|
||||||
static void skip_parens (void);
|
static void skip_parens (void);
|
||||||
|
|
||||||
@@ -2463,6 +2464,50 @@ skip_optional_name_and_parens (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void process_keyword_names ()
|
||||||
|
{
|
||||||
|
if (token_is (TOK_KEYWORD))
|
||||||
|
{
|
||||||
|
keyword kw = (keyword) token_data ();
|
||||||
|
skip_newlines ();
|
||||||
|
if (token_is (TOK_COLON))
|
||||||
|
{
|
||||||
|
lexer_add_keyword_or_numeric_literal_if_not_present (
|
||||||
|
create_literal_from_str_compute_len (lexer_keyword_to_string (kw)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lexer_save_token (tok);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (token_is (TOK_NAME))
|
||||||
|
{
|
||||||
|
if (literal_equal_type_s (lexer_get_literal_by_id (token_data ()), "get")
|
||||||
|
|| literal_equal_type_s (lexer_get_literal_by_id (token_data ()), "set"))
|
||||||
|
{
|
||||||
|
skip_newlines ();
|
||||||
|
if (token_is (TOK_KEYWORD))
|
||||||
|
{
|
||||||
|
keyword kw = (keyword) token_data ();
|
||||||
|
skip_newlines ();
|
||||||
|
if (token_is (TOK_OPEN_PAREN))
|
||||||
|
{
|
||||||
|
lexer_add_keyword_or_numeric_literal_if_not_present (
|
||||||
|
create_literal_from_str_compute_len (lexer_keyword_to_string (kw)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lexer_save_token (tok);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lexer_save_token (tok);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
skip_braces (void)
|
skip_braces (void)
|
||||||
{
|
{
|
||||||
@@ -2480,45 +2525,9 @@ skip_braces (void)
|
|||||||
{
|
{
|
||||||
nesting_level--;
|
nesting_level--;
|
||||||
}
|
}
|
||||||
else if (token_is (TOK_KEYWORD))
|
else
|
||||||
{
|
{
|
||||||
keyword kw = (keyword) token_data ();
|
process_keyword_names ();
|
||||||
skip_newlines ();
|
|
||||||
if (token_is (TOK_COLON))
|
|
||||||
{
|
|
||||||
lexer_add_keyword_or_numeric_literal_if_not_present (
|
|
||||||
create_literal_from_str_compute_len (lexer_keyword_to_string (kw)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lexer_save_token (tok);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (token_is (TOK_NAME))
|
|
||||||
{
|
|
||||||
if (literal_equal_type_s (lexer_get_literal_by_id (token_data ()), "get")
|
|
||||||
|| literal_equal_type_s (lexer_get_literal_by_id (token_data ()), "set"))
|
|
||||||
{
|
|
||||||
skip_newlines ();
|
|
||||||
if (token_is (TOK_KEYWORD))
|
|
||||||
{
|
|
||||||
keyword kw = (keyword) token_data ();
|
|
||||||
skip_newlines ();
|
|
||||||
if (token_is (TOK_OPEN_PAREN))
|
|
||||||
{
|
|
||||||
lexer_add_keyword_or_numeric_literal_if_not_present (
|
|
||||||
create_literal_from_str_compute_len (lexer_keyword_to_string (kw)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lexer_save_token (tok);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lexer_save_token (tok);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2649,9 +2658,18 @@ preparse_scope (bool is_global)
|
|||||||
|
|
||||||
dump_reg_var_decl_for_rewrite ();
|
dump_reg_var_decl_for_rewrite ();
|
||||||
|
|
||||||
while (!token_is (end_tt))
|
size_t nesting_level = 0;
|
||||||
|
while (nesting_level > 0 || !token_is (end_tt))
|
||||||
{
|
{
|
||||||
if (is_keyword (KW_VAR))
|
if (token_is (TOK_OPEN_BRACE))
|
||||||
|
{
|
||||||
|
nesting_level++;
|
||||||
|
}
|
||||||
|
else if (token_is (TOK_CLOSE_BRACE))
|
||||||
|
{
|
||||||
|
nesting_level--;
|
||||||
|
}
|
||||||
|
else if (is_keyword (KW_VAR))
|
||||||
{
|
{
|
||||||
preparse_var_decls ();
|
preparse_var_decls ();
|
||||||
}
|
}
|
||||||
@@ -2663,6 +2681,10 @@ preparse_scope (bool is_global)
|
|||||||
{
|
{
|
||||||
skip_braces ();
|
skip_braces ();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
process_keyword_names ();
|
||||||
|
}
|
||||||
skip_newlines ();
|
skip_newlines ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// Copyright 2015 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.
|
||||||
|
|
||||||
|
{
|
||||||
|
var y;
|
||||||
|
}
|
||||||
|
var x = y;
|
||||||
|
assert (x === undefined);
|
||||||
Reference in New Issue
Block a user