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 "src/api.h" | 7 #include "src/api.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/ast-expression-visitor.h" | 9 #include "src/ast/ast-expression-visitor.h" |
10 #include "src/ast/ast-literal-reindexer.h" | 10 #include "src/ast/ast-literal-reindexer.h" |
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 DCHECK(info->language_mode() == shared_info->language_mode()); | 1029 DCHECK(info->language_mode() == shared_info->language_mode()); |
1030 FunctionLiteral::FunctionType function_type = | 1030 FunctionLiteral::FunctionType function_type = |
1031 shared_info->is_expression() | 1031 shared_info->is_expression() |
1032 ? (shared_info->is_anonymous() | 1032 ? (shared_info->is_anonymous() |
1033 ? FunctionLiteral::kAnonymousExpression | 1033 ? FunctionLiteral::kAnonymousExpression |
1034 : FunctionLiteral::kNamedExpression) | 1034 : FunctionLiteral::kNamedExpression) |
1035 : FunctionLiteral::kDeclaration; | 1035 : FunctionLiteral::kDeclaration; |
1036 bool ok = true; | 1036 bool ok = true; |
1037 | 1037 |
1038 if (shared_info->is_arrow()) { | 1038 if (shared_info->is_arrow()) { |
| 1039 // TODO(adamk): We should construct this scope from the ScopeInfo. |
1039 Scope* scope = | 1040 Scope* scope = |
1040 NewScope(scope_, FUNCTION_SCOPE, FunctionKind::kArrowFunction); | 1041 NewScope(scope_, FUNCTION_SCOPE, FunctionKind::kArrowFunction); |
| 1042 |
| 1043 // These two bits only need to be explicitly set because we're |
| 1044 // not passing the ScopeInfo to the Scope constructor. |
| 1045 // TODO(adamk): Remove these calls once the above NewScope call |
| 1046 // passes the ScopeInfo. |
| 1047 if (shared_info->scope_info()->CallsEval()) { |
| 1048 scope->RecordEvalCall(); |
| 1049 } |
1041 SetLanguageMode(scope, shared_info->language_mode()); | 1050 SetLanguageMode(scope, shared_info->language_mode()); |
| 1051 |
1042 scope->set_start_position(shared_info->start_position()); | 1052 scope->set_start_position(shared_info->start_position()); |
1043 ExpressionClassifier formals_classifier; | 1053 ExpressionClassifier formals_classifier; |
1044 ParserFormalParameters formals(scope); | 1054 ParserFormalParameters formals(scope); |
1045 Checkpoint checkpoint(this); | 1055 Checkpoint checkpoint(this); |
1046 { | 1056 { |
1047 // Parsing patterns as variable reference expression creates | 1057 // Parsing patterns as variable reference expression creates |
1048 // NewUnresolved references in current scope. Entrer arrow function | 1058 // NewUnresolved references in current scope. Entrer arrow function |
1049 // scope for formal parameter parsing. | 1059 // scope for formal parameter parsing. |
1050 BlockState block_state(&scope_, scope); | 1060 BlockState block_state(&scope_, scope); |
1051 if (Check(Token::LPAREN)) { | 1061 if (Check(Token::LPAREN)) { |
(...skipping 4387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5439 auto class_literal = value->AsClassLiteral(); | 5449 auto class_literal = value->AsClassLiteral(); |
5440 if (class_literal->raw_name() == nullptr) { | 5450 if (class_literal->raw_name() == nullptr) { |
5441 class_literal->set_raw_name(name); | 5451 class_literal->set_raw_name(name); |
5442 } | 5452 } |
5443 } | 5453 } |
5444 } | 5454 } |
5445 | 5455 |
5446 | 5456 |
5447 } // namespace internal | 5457 } // namespace internal |
5448 } // namespace v8 | 5458 } // namespace v8 |
OLD | NEW |