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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 ast_value_factory()->arguments_string(), VAR); | 137 ast_value_factory()->arguments_string(), VAR); |
138 function_scope->DeclareVariableName(ast_value_factory()->this_string(), | 138 function_scope->DeclareVariableName(ast_value_factory()->this_string(), |
139 VAR); | 139 VAR); |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 Expect(Token::LBRACE, CHECK_OK_VALUE(kPreParseSuccess)); | 143 Expect(Token::LBRACE, CHECK_OK_VALUE(kPreParseSuccess)); |
144 LazyParsingResult result = ParseStatementListAndLogFunction( | 144 LazyParsingResult result = ParseStatementListAndLogFunction( |
145 &formals, has_duplicate_parameters, may_abort, ok); | 145 &formals, has_duplicate_parameters, may_abort, ok); |
146 | 146 |
| 147 if (is_sloppy(function_scope->language_mode())) { |
| 148 function_scope->HoistSloppyBlockFunctions(nullptr); |
| 149 } |
| 150 |
147 use_counts_ = nullptr; | 151 use_counts_ = nullptr; |
148 track_unresolved_variables_ = false; | 152 track_unresolved_variables_ = false; |
149 | 153 |
150 if (result == kLazyParsingAborted) { | 154 if (result == kLazyParsingAborted) { |
151 return kPreParseAbort; | 155 return kPreParseAbort; |
152 } else if (stack_overflow()) { | 156 } else if (stack_overflow()) { |
153 return kPreParseStackOverflow; | 157 return kPreParseStackOverflow; |
154 } else if (!*ok) { | 158 } else if (!*ok) { |
155 DCHECK(pending_error_handler_->has_pending_error()); | 159 DCHECK(pending_error_handler_->has_pending_error()); |
156 } else { | 160 } else { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 CheckArityRestrictions(formals.arity, kind, formals.has_rest, start_position, | 229 CheckArityRestrictions(formals.arity, kind, formals.has_rest, start_position, |
226 formals_end_position, CHECK_OK); | 230 formals_end_position, CHECK_OK); |
227 | 231 |
228 Expect(Token::LBRACE, CHECK_OK); | 232 Expect(Token::LBRACE, CHECK_OK); |
229 ParseStatementList(body, Token::RBRACE, CHECK_OK); | 233 ParseStatementList(body, Token::RBRACE, CHECK_OK); |
230 Expect(Token::RBRACE, CHECK_OK); | 234 Expect(Token::RBRACE, CHECK_OK); |
231 | 235 |
232 // Parsing the body may change the language mode in our scope. | 236 // Parsing the body may change the language mode in our scope. |
233 language_mode = function_scope->language_mode(); | 237 language_mode = function_scope->language_mode(); |
234 | 238 |
| 239 if (is_sloppy(language_mode)) { |
| 240 function_scope->HoistSloppyBlockFunctions(nullptr); |
| 241 } |
| 242 |
235 // Validate name and parameter names. We can do this only after parsing the | 243 // Validate name and parameter names. We can do this only after parsing the |
236 // function, since the function can declare itself strict. | 244 // function, since the function can declare itself strict. |
237 CheckFunctionName(language_mode, function_name, function_name_validity, | 245 CheckFunctionName(language_mode, function_name, function_name_validity, |
238 function_name_location, CHECK_OK); | 246 function_name_location, CHECK_OK); |
239 const bool allow_duplicate_parameters = | 247 const bool allow_duplicate_parameters = |
240 is_sloppy(language_mode) && formals.is_simple && !IsConciseMethod(kind); | 248 is_sloppy(language_mode) && formals.is_simple && !IsConciseMethod(kind); |
241 ValidateFormalParameters(language_mode, allow_duplicate_parameters, CHECK_OK); | 249 ValidateFormalParameters(language_mode, allow_duplicate_parameters, CHECK_OK); |
242 | 250 |
243 int end_position = scanner()->location().end_pos; | 251 int end_position = scanner()->location().end_pos; |
244 if (is_strict(language_mode)) { | 252 if (is_strict(language_mode)) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 } | 316 } |
309 } | 317 } |
310 } | 318 } |
311 | 319 |
312 #undef CHECK_OK | 320 #undef CHECK_OK |
313 #undef CHECK_OK_CUSTOM | 321 #undef CHECK_OK_CUSTOM |
314 | 322 |
315 | 323 |
316 } // namespace internal | 324 } // namespace internal |
317 } // namespace v8 | 325 } // namespace v8 |
OLD | NEW |