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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 parsing_module_ = parsing_module; | 90 parsing_module_ = parsing_module; |
91 log_ = log; | 91 log_ = log; |
92 use_counts_ = use_counts; | 92 use_counts_ = use_counts; |
93 DCHECK(!track_unresolved_variables_); | 93 DCHECK(!track_unresolved_variables_); |
94 track_unresolved_variables_ = is_inner_function; | 94 track_unresolved_variables_ = is_inner_function; |
95 | 95 |
96 // The caller passes the function_scope which is not yet inserted into the | 96 // The caller passes the function_scope which is not yet inserted into the |
97 // scope_state_. All scopes above the function_scope are ignored by the | 97 // scope_state_. All scopes above the function_scope are ignored by the |
98 // PreParser. | 98 // PreParser. |
99 DCHECK_NULL(scope_state_); | 99 DCHECK_NULL(scope_state_); |
100 FunctionState function_state(&function_state_, &scope_state_, function_scope, | 100 FunctionState function_state(&function_state_, &scope_state_, function_scope); |
101 function_scope->function_kind()); | |
102 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); | 101 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); |
103 bool ok = true; | 102 bool ok = true; |
104 int start_position = peek_position(); | 103 int start_position = peek_position(); |
105 LazyParsingResult result = ParseLazyFunctionLiteralBody(may_abort, &ok); | 104 LazyParsingResult result = ParseLazyFunctionLiteralBody(may_abort, &ok); |
106 use_counts_ = nullptr; | 105 use_counts_ = nullptr; |
107 track_unresolved_variables_ = false; | 106 track_unresolved_variables_ = false; |
108 if (result == kLazyParsingAborted) { | 107 if (result == kLazyParsingAborted) { |
109 return kPreParseAbort; | 108 return kPreParseAbort; |
110 } else if (stack_overflow()) { | 109 } else if (stack_overflow()) { |
111 return kPreParseStackOverflow; | 110 return kPreParseStackOverflow; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 int function_token_pos, FunctionLiteral::FunctionType function_type, | 188 int function_token_pos, FunctionLiteral::FunctionType function_type, |
190 LanguageMode language_mode, bool* ok) { | 189 LanguageMode language_mode, bool* ok) { |
191 // Function :: | 190 // Function :: |
192 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 191 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
193 | 192 |
194 // Parse function body. | 193 // Parse function body. |
195 PreParserStatementList body; | 194 PreParserStatementList body; |
196 bool outer_is_script_scope = scope()->is_script_scope(); | 195 bool outer_is_script_scope = scope()->is_script_scope(); |
197 DeclarationScope* function_scope = NewFunctionScope(kind); | 196 DeclarationScope* function_scope = NewFunctionScope(kind); |
198 function_scope->SetLanguageMode(language_mode); | 197 function_scope->SetLanguageMode(language_mode); |
199 FunctionState function_state(&function_state_, &scope_state_, function_scope, | 198 FunctionState function_state(&function_state_, &scope_state_, function_scope); |
200 kind); | |
201 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); | 199 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); |
202 ExpressionClassifier formals_classifier(this, &duplicate_finder); | 200 ExpressionClassifier formals_classifier(this, &duplicate_finder); |
203 | 201 |
204 Expect(Token::LPAREN, CHECK_OK); | 202 Expect(Token::LPAREN, CHECK_OK); |
205 int start_position = scanner()->location().beg_pos; | 203 int start_position = scanner()->location().beg_pos; |
206 function_scope->set_start_position(start_position); | 204 function_scope->set_start_position(start_position); |
207 PreParserFormalParameters formals(function_scope); | 205 PreParserFormalParameters formals(function_scope); |
208 ParseFormalParameterList(&formals, CHECK_OK); | 206 ParseFormalParameterList(&formals, CHECK_OK); |
209 Expect(Token::RPAREN, CHECK_OK); | 207 Expect(Token::RPAREN, CHECK_OK); |
210 int formals_end_position = scanner()->location().end_pos; | 208 int formals_end_position = scanner()->location().end_pos; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 } | 367 } |
370 return PreParserExpression::FromIdentifier(name); | 368 return PreParserExpression::FromIdentifier(name); |
371 } | 369 } |
372 | 370 |
373 #undef CHECK_OK | 371 #undef CHECK_OK |
374 #undef CHECK_OK_CUSTOM | 372 #undef CHECK_OK_CUSTOM |
375 | 373 |
376 | 374 |
377 } // namespace internal | 375 } // namespace internal |
378 } // namespace v8 | 376 } // namespace v8 |
OLD | NEW |