OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/ast/ast-expression-rewriter.h" | 10 #include "src/ast/ast-expression-rewriter.h" |
(...skipping 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1705 Expression* Parser::RewriteDoExpression(Block* body, int pos, bool* ok) { | 1705 Expression* Parser::RewriteDoExpression(Block* body, int pos, bool* ok) { |
1706 Variable* result = NewTemporary(ast_value_factory()->dot_result_string()); | 1706 Variable* result = NewTemporary(ast_value_factory()->dot_result_string()); |
1707 DoExpression* expr = factory()->NewDoExpression(body, result, pos); | 1707 DoExpression* expr = factory()->NewDoExpression(body, result, pos); |
1708 if (!Rewriter::Rewrite(this, GetClosureScope(), expr, ast_value_factory())) { | 1708 if (!Rewriter::Rewrite(this, GetClosureScope(), expr, ast_value_factory())) { |
1709 *ok = false; | 1709 *ok = false; |
1710 return nullptr; | 1710 return nullptr; |
1711 } | 1711 } |
1712 return expr; | 1712 return expr; |
1713 } | 1713 } |
1714 | 1714 |
1715 Statement* Parser::ParseFunctionDeclaration(bool* ok) { | |
1716 Consume(Token::FUNCTION); | |
1717 int pos = position(); | |
1718 ParseFunctionFlags flags = ParseFunctionFlags::kIsNormal; | |
1719 if (Check(Token::MUL)) { | |
1720 flags |= ParseFunctionFlags::kIsGenerator; | |
1721 if (allow_harmony_restrictive_declarations()) { | |
1722 ReportMessageAt(scanner()->location(), | |
1723 MessageTemplate::kGeneratorInLegacyContext); | |
1724 *ok = false; | |
1725 return nullptr; | |
1726 } | |
1727 } | |
1728 | |
1729 return ParseHoistableDeclaration(pos, flags, nullptr, false, CHECK_OK); | |
1730 } | |
1731 | |
1732 Statement* Parser::RewriteSwitchStatement(Expression* tag, | 1715 Statement* Parser::RewriteSwitchStatement(Expression* tag, |
1733 SwitchStatement* switch_statement, | 1716 SwitchStatement* switch_statement, |
1734 ZoneList<CaseClause*>* cases, | 1717 ZoneList<CaseClause*>* cases, |
1735 Scope* scope) { | 1718 Scope* scope) { |
1736 // In order to get the CaseClauses to execute in their own lexical scope, | 1719 // In order to get the CaseClauses to execute in their own lexical scope, |
1737 // but without requiring downstream code to have special scope handling | 1720 // but without requiring downstream code to have special scope handling |
1738 // code for switch statements, desugar into blocks as follows: | 1721 // code for switch statements, desugar into blocks as follows: |
1739 // { // To group the statements--harmless to evaluate Expression in scope | 1722 // { // To group the statements--harmless to evaluate Expression in scope |
1740 // .tag_variable = Expression; | 1723 // .tag_variable = Expression; |
1741 // { // To give CaseClauses a scope | 1724 // { // To give CaseClauses a scope |
(...skipping 3714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5456 | 5439 |
5457 return final_loop; | 5440 return final_loop; |
5458 } | 5441 } |
5459 | 5442 |
5460 #undef CHECK_OK | 5443 #undef CHECK_OK |
5461 #undef CHECK_OK_VOID | 5444 #undef CHECK_OK_VOID |
5462 #undef CHECK_FAILED | 5445 #undef CHECK_FAILED |
5463 | 5446 |
5464 } // namespace internal | 5447 } // namespace internal |
5465 } // namespace v8 | 5448 } // namespace v8 |
OLD | NEW |