| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 <cmath> | 5 #include <cmath> |
| 6 | 6 |
| 7 #include "src/allocation.h" | 7 #include "src/allocation.h" |
| 8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
| 9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
| 10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 PreParser::PreParseResult PreParser::PreParseLazyFunction( | 98 PreParser::PreParseResult PreParser::PreParseLazyFunction( |
| 99 LanguageMode language_mode, FunctionKind kind, ParserRecorder* log) { | 99 LanguageMode language_mode, FunctionKind kind, ParserRecorder* log) { |
| 100 log_ = log; | 100 log_ = log; |
| 101 // Lazy functions always have trivial outer scopes (no with/catch scopes). | 101 // Lazy functions always have trivial outer scopes (no with/catch scopes). |
| 102 Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE); | 102 Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE); |
| 103 PreParserFactory top_factory(NULL); | 103 PreParserFactory top_factory(NULL); |
| 104 FunctionState top_state(&function_state_, &scope_, top_scope, kNormalFunction, | 104 FunctionState top_state(&function_state_, &scope_, top_scope, kNormalFunction, |
| 105 &top_factory); | 105 &top_factory); |
| 106 scope_->SetLanguageMode(language_mode); | 106 scope_->SetLanguageMode(language_mode); |
| 107 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE); | 107 Scope* function_scope = |
| 108 NewScope(scope_, IsArrowFunction(kind) ? ARROW_SCOPE : FUNCTION_SCOPE); |
| 108 PreParserFactory function_factory(NULL); | 109 PreParserFactory function_factory(NULL); |
| 109 FunctionState function_state(&function_state_, &scope_, function_scope, kind, | 110 FunctionState function_state(&function_state_, &scope_, function_scope, kind, |
| 110 &function_factory); | 111 &function_factory); |
| 111 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); | 112 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); |
| 112 bool ok = true; | 113 bool ok = true; |
| 113 int start_position = peek_position(); | 114 int start_position = peek_position(); |
| 114 ParseLazyFunctionLiteralBody(&ok); | 115 ParseLazyFunctionLiteralBody(&ok); |
| 115 if (stack_overflow()) return kPreParseStackOverflow; | 116 if (stack_overflow()) return kPreParseStackOverflow; |
| 116 if (!ok) { | 117 if (!ok) { |
| 117 ReportUnexpectedToken(scanner()->current_token()); | 118 ReportUnexpectedToken(scanner()->current_token()); |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 int body_start = position(); | 954 int body_start = position(); |
| 954 ParseStatementList(Token::RBRACE, ok); | 955 ParseStatementList(Token::RBRACE, ok); |
| 955 if (!*ok) return; | 956 if (!*ok) return; |
| 956 | 957 |
| 957 // Position right after terminal '}'. | 958 // Position right after terminal '}'. |
| 958 DCHECK_EQ(Token::RBRACE, scanner()->peek()); | 959 DCHECK_EQ(Token::RBRACE, scanner()->peek()); |
| 959 int body_end = scanner()->peek_location().end_pos; | 960 int body_end = scanner()->peek_location().end_pos; |
| 960 log_->LogFunction(body_start, body_end, | 961 log_->LogFunction(body_start, body_end, |
| 961 function_state_->materialized_literal_count(), | 962 function_state_->materialized_literal_count(), |
| 962 function_state_->expected_property_count(), language_mode(), | 963 function_state_->expected_property_count(), language_mode(), |
| 963 scope_->uses_super_property()); | 964 scope_->uses_super_property(), scope_->uses_new_target()); |
| 964 } | 965 } |
| 965 | 966 |
| 966 | 967 |
| 967 PreParserExpression PreParser::ParseClassLiteral( | 968 PreParserExpression PreParser::ParseClassLiteral( |
| 968 PreParserIdentifier name, Scanner::Location class_name_location, | 969 PreParserIdentifier name, Scanner::Location class_name_location, |
| 969 bool name_is_strict_reserved, int pos, bool* ok) { | 970 bool name_is_strict_reserved, int pos, bool* ok) { |
| 970 // All parts of a ClassDeclaration and ClassExpression are strict code. | 971 // All parts of a ClassDeclaration and ClassExpression are strict code. |
| 971 if (name_is_strict_reserved) { | 972 if (name_is_strict_reserved) { |
| 972 ReportMessageAt(class_name_location, "unexpected_strict_reserved"); | 973 ReportMessageAt(class_name_location, "unexpected_strict_reserved"); |
| 973 *ok = false; | 974 *ok = false; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1023 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); | 1024 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); |
| 1024 ParseArguments(ok); | 1025 ParseArguments(ok); |
| 1025 | 1026 |
| 1026 return Expression::Default(); | 1027 return Expression::Default(); |
| 1027 } | 1028 } |
| 1028 | 1029 |
| 1029 #undef CHECK_OK | 1030 #undef CHECK_OK |
| 1030 | 1031 |
| 1031 | 1032 |
| 1032 } } // v8::internal | 1033 } } // v8::internal |
| OLD | NEW |