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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 parsing_module_ = parsing_module; | 129 parsing_module_ = parsing_module; |
130 log_ = log; | 130 log_ = log; |
131 use_counts_ = use_counts; | 131 use_counts_ = use_counts; |
132 // Lazy functions always have trivial outer scopes (no with/catch scopes). | 132 // Lazy functions always have trivial outer scopes (no with/catch scopes). |
133 DCHECK_NULL(scope_state_); | 133 DCHECK_NULL(scope_state_); |
134 Scope* top_scope = NewScope(nullptr, SCRIPT_SCOPE); | 134 Scope* top_scope = NewScope(nullptr, SCRIPT_SCOPE); |
135 PreParserFactory top_factory(nullptr); | 135 PreParserFactory top_factory(nullptr); |
136 FunctionState top_state(&function_state_, &scope_state_, top_scope, | 136 FunctionState top_state(&function_state_, &scope_state_, top_scope, |
137 kNormalFunction, &top_factory); | 137 kNormalFunction, &top_factory); |
138 scope()->SetLanguageMode(language_mode); | 138 scope()->SetLanguageMode(language_mode); |
139 Scope* function_scope = NewFunctionScope(scope(), kind); | 139 Scope* function_scope = NewFunctionScope(kind); |
140 if (!has_simple_parameters) function_scope->SetHasNonSimpleParameters(); | 140 if (!has_simple_parameters) function_scope->SetHasNonSimpleParameters(); |
141 PreParserFactory function_factory(nullptr); | 141 PreParserFactory function_factory(nullptr); |
142 FunctionState function_state(&function_state_, &scope_state_, function_scope, | 142 FunctionState function_state(&function_state_, &scope_state_, function_scope, |
143 kind, &function_factory); | 143 kind, &function_factory); |
144 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); | 144 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); |
145 bool ok = true; | 145 bool ok = true; |
146 int start_position = peek_position(); | 146 int start_position = peek_position(); |
147 ParseLazyFunctionLiteralBody(&ok, bookmark); | 147 ParseLazyFunctionLiteralBody(&ok, bookmark); |
148 use_counts_ = nullptr; | 148 use_counts_ = nullptr; |
149 if (bookmark && bookmark->HasBeenReset()) { | 149 if (bookmark && bookmark->HasBeenReset()) { |
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 PreParser::Expression PreParser::ParseFunctionLiteral( | 1104 PreParser::Expression PreParser::ParseFunctionLiteral( |
1105 Identifier function_name, Scanner::Location function_name_location, | 1105 Identifier function_name, Scanner::Location function_name_location, |
1106 FunctionNameValidity function_name_validity, FunctionKind kind, | 1106 FunctionNameValidity function_name_validity, FunctionKind kind, |
1107 int function_token_pos, FunctionLiteral::FunctionType function_type, | 1107 int function_token_pos, FunctionLiteral::FunctionType function_type, |
1108 LanguageMode language_mode, bool* ok) { | 1108 LanguageMode language_mode, bool* ok) { |
1109 // Function :: | 1109 // Function :: |
1110 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 1110 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
1111 | 1111 |
1112 // Parse function body. | 1112 // Parse function body. |
1113 bool outer_is_script_scope = scope()->is_script_scope(); | 1113 bool outer_is_script_scope = scope()->is_script_scope(); |
1114 Scope* function_scope = NewFunctionScope(scope(), kind); | 1114 Scope* function_scope = NewFunctionScope(kind); |
1115 function_scope->SetLanguageMode(language_mode); | 1115 function_scope->SetLanguageMode(language_mode); |
1116 PreParserFactory factory(NULL); | 1116 PreParserFactory factory(NULL); |
1117 FunctionState function_state(&function_state_, &scope_state_, function_scope, | 1117 FunctionState function_state(&function_state_, &scope_state_, function_scope, |
1118 kind, &factory); | 1118 kind, &factory); |
1119 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); | 1119 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); |
1120 ExpressionClassifier formals_classifier(this, &duplicate_finder); | 1120 ExpressionClassifier formals_classifier(this, &duplicate_finder); |
1121 | 1121 |
1122 Expect(Token::LPAREN, CHECK_OK); | 1122 Expect(Token::LPAREN, CHECK_OK); |
1123 int start_position = scanner()->location().beg_pos; | 1123 int start_position = scanner()->location().beg_pos; |
1124 function_scope->set_start_position(start_position); | 1124 function_scope->set_start_position(start_position); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 | 1321 |
1322 body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); | 1322 body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); |
1323 } | 1323 } |
1324 | 1324 |
1325 #undef CHECK_OK | 1325 #undef CHECK_OK |
1326 #undef CHECK_OK_CUSTOM | 1326 #undef CHECK_OK_CUSTOM |
1327 | 1327 |
1328 | 1328 |
1329 } // namespace internal | 1329 } // namespace internal |
1330 } // namespace v8 | 1330 } // namespace v8 |
OLD | NEW |