Chromium Code Reviews| Index: src/parser.cc |
| diff --git a/src/parser.cc b/src/parser.cc |
| index ff7d61dcfb5d00445dfe5dbeca28e79746ecb466..158c6396369364198096e936fccecd389f6dfdc9 100644 |
| --- a/src/parser.cc |
| +++ b/src/parser.cc |
| @@ -870,7 +870,6 @@ Parser::Parser(ParseInfo* info) |
| DCHECK(!info->script().is_null() || info->source_stream() != NULL); |
| set_allow_lazy(info->allow_lazy_parsing()); |
| set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); |
| - set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping); |
| set_allow_harmony_modules(!info->is_native() && FLAG_harmony_modules); |
| set_allow_harmony_arrow_functions(FLAG_harmony_arrow_functions); |
| set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); |
| @@ -1028,7 +1027,7 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info, Scope** scope, |
| CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok); |
| } |
| - if (ok && allow_harmony_scoping() && is_strict(language_mode())) { |
| + if (ok && is_strict(language_mode())) { |
|
rossberg
2015/03/13 14:24:32
Can be merged with previous condition now.
Dmitry Lomov (no reviews)
2015/03/13 14:51:29
Done.
|
| CheckConflictingVarDeclarations(scope_, &ok); |
| } |
| @@ -1290,7 +1289,6 @@ Statement* Parser::ParseStatementListItem(bool* ok) { |
| case Token::VAR: |
| return ParseVariableStatement(kStatementListItem, NULL, ok); |
| case Token::LET: |
| - DCHECK(allow_harmony_scoping()); |
| if (is_strict(language_mode())) { |
| return ParseVariableStatement(kStatementListItem, NULL, ok); |
| } |
| @@ -1911,7 +1909,7 @@ Variable* Parser::Declare(Declaration* declaration, bool resolve, bool* ok) { |
| // because the var declaration is hoisted to the function scope where 'x' |
| // is already bound. |
| DCHECK(IsDeclaredVariableMode(var->mode())); |
| - if (allow_harmony_scoping() && is_strict(language_mode())) { |
| + if (is_strict(language_mode())) { |
| // In harmony we treat re-declarations as early errors. See |
| // ES5 16 for a definition of early errors. |
| ParserTraits::ReportMessage("var_redeclaration", name); |
| @@ -2062,12 +2060,13 @@ Statement* Parser::ParseFunctionDeclaration( |
| // In ES6, a function behaves as a lexical binding, except in |
| // a script scope, or the initial scope of eval or another function. |
| VariableMode mode = |
| - is_strong(language_mode()) ? CONST : |
| - allow_harmony_scoping() && is_strict(language_mode()) && |
| - !(scope_->is_script_scope() || scope_->is_eval_scope() || |
| - scope_->is_function_scope()) |
| - ? LET |
| - : VAR; |
| + is_strong(language_mode()) |
| + ? CONST |
| + : is_strict(language_mode()) && |
| + !(scope_->is_script_scope() || scope_->is_eval_scope() || |
| + scope_->is_function_scope()) |
| + ? LET |
| + : VAR; |
| VariableProxy* proxy = NewUnresolved(name, mode); |
| Declaration* declaration = |
| factory()->NewFunctionDeclaration(proxy, mode, fun, scope_, pos); |
| @@ -2124,7 +2123,7 @@ Statement* Parser::ParseClassDeclaration(ZoneList<const AstRawString*>* names, |
| Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok) { |
| - if (allow_harmony_scoping() && is_strict(language_mode())) { |
| + if (is_strict(language_mode())) { |
| return ParseScopedBlock(labels, ok); |
| } |
| @@ -2246,19 +2245,12 @@ Block* Parser::ParseVariableDeclarations( |
| init_op = Token::INIT_CONST_LEGACY; |
| } else { |
| DCHECK(var_context != kStatement); |
| - // In ES5 const is not allowed in strict mode. |
| - if (!allow_harmony_scoping()) { |
| - ReportMessage("strict_const"); |
| - *ok = false; |
| - return NULL; |
| - } |
| mode = CONST; |
| init_op = Token::INIT_CONST; |
| } |
| is_const = true; |
| needs_init = true; |
| } else if (peek() == Token::LET && is_strict(language_mode())) { |
| - DCHECK(allow_harmony_scoping()); |
| Consume(Token::LET); |
| DCHECK(var_context != kStatement); |
| mode = LET; |
| @@ -3733,13 +3725,12 @@ FunctionLiteral* Parser::ParseFunctionLiteral( |
| // nested function, and hoisting works normally relative to that. |
| Scope* declaration_scope = scope_->DeclarationScope(); |
| Scope* original_declaration_scope = original_scope_->DeclarationScope(); |
| - Scope* scope = |
| - function_type == FunctionLiteral::DECLARATION && |
| - (!allow_harmony_scoping() || is_sloppy(language_mode())) && |
| - (original_scope_ == original_declaration_scope || |
| - declaration_scope != original_declaration_scope) |
| - ? NewScope(declaration_scope, FUNCTION_SCOPE, kind) |
| - : NewScope(scope_, FUNCTION_SCOPE, kind); |
| + Scope* scope = function_type == FunctionLiteral::DECLARATION && |
| + is_sloppy(language_mode()) && |
| + (original_scope_ == original_declaration_scope || |
| + declaration_scope != original_declaration_scope) |
| + ? NewScope(declaration_scope, FUNCTION_SCOPE, kind) |
| + : NewScope(scope_, FUNCTION_SCOPE, kind); |
| ZoneList<Statement*>* body = NULL; |
| int materialized_literal_count = -1; |
| int expected_property_count = -1; |
| @@ -3847,12 +3838,11 @@ FunctionLiteral* Parser::ParseFunctionLiteral( |
| Variable* fvar = NULL; |
| Token::Value fvar_init_op = Token::INIT_CONST_LEGACY; |
| if (function_type == FunctionLiteral::NAMED_EXPRESSION) { |
| - if (allow_harmony_scoping() && is_strict(language_mode())) { |
| + if (is_strict(language_mode())) { |
| fvar_init_op = Token::INIT_CONST; |
| } |
| VariableMode fvar_mode = |
| - allow_harmony_scoping() && is_strict(language_mode()) ? CONST |
| - : CONST_LEGACY; |
| + is_strict(language_mode()) ? CONST : CONST_LEGACY; |
| DCHECK(function_name != NULL); |
| fvar = new (zone()) |
| Variable(scope_, function_name, fvar_mode, true /* is valid LHS */, |
| @@ -3926,7 +3916,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral( |
| CheckStrictOctalLiteral(scope->start_position(), scope->end_position(), |
| CHECK_OK); |
| } |
| - if (allow_harmony_scoping() && is_strict(language_mode())) { |
| + if (is_strict(language_mode())) { |
| CheckConflictingVarDeclarations(scope, CHECK_OK); |
| } |
| } |
| @@ -4126,7 +4116,6 @@ PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser( |
| NULL, stack_limit_); |
| reusable_preparser_->set_allow_lazy(true); |
| reusable_preparser_->set_allow_natives(allow_natives()); |
| - reusable_preparser_->set_allow_harmony_scoping(allow_harmony_scoping()); |
| reusable_preparser_->set_allow_harmony_modules(allow_harmony_modules()); |
| reusable_preparser_->set_allow_harmony_arrow_functions( |
| allow_harmony_arrow_functions()); |