Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/preparser.h

Issue 1386253002: Use Scope::function_kind_ to distinguish arrow function scopes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef V8_PREPARSER_H 5 #ifndef V8_PREPARSER_H
6 #define V8_PREPARSER_H 6 #define V8_PREPARSER_H
7 7
8 #include "src/bailout-reason.h" 8 #include "src/bailout-reason.h"
9 #include "src/expression-classifier.h" 9 #include "src/expression-classifier.h"
10 #include "src/func-name-inferrer.h" 10 #include "src/func-name-inferrer.h"
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 ~ParsingModeScope() { 300 ~ParsingModeScope() {
301 parser_->mode_ = old_mode_; 301 parser_->mode_ = old_mode_;
302 } 302 }
303 303
304 private: 304 private:
305 ParserBase* parser_; 305 ParserBase* parser_;
306 Mode old_mode_; 306 Mode old_mode_;
307 }; 307 };
308 308
309 Scope* NewScope(Scope* parent, ScopeType scope_type) { 309 Scope* NewScope(Scope* parent, ScopeType scope_type) {
310 // Must always pass the function kind for FUNCTION_SCOPE and ARROW_SCOPE. 310 // Must always pass the function kind for FUNCTION_SCOPE.
311 DCHECK(scope_type != FUNCTION_SCOPE); 311 DCHECK(scope_type != FUNCTION_SCOPE);
312 DCHECK(scope_type != ARROW_SCOPE);
313 return NewScope(parent, scope_type, kNormalFunction); 312 return NewScope(parent, scope_type, kNormalFunction);
314 } 313 }
315 314
316 Scope* NewScope(Scope* parent, ScopeType scope_type, FunctionKind kind) { 315 Scope* NewScope(Scope* parent, ScopeType scope_type, FunctionKind kind) {
317 DCHECK(ast_value_factory()); 316 DCHECK(ast_value_factory());
318 DCHECK(scope_type != MODULE_SCOPE || FLAG_harmony_modules); 317 DCHECK(scope_type != MODULE_SCOPE || FLAG_harmony_modules);
319 DCHECK(!IsArrowFunction(kind) || scope_type == ARROW_SCOPE);
320 Scope* result = new (zone()) 318 Scope* result = new (zone())
321 Scope(zone(), parent, scope_type, ast_value_factory(), kind); 319 Scope(zone(), parent, scope_type, ast_value_factory(), kind);
322 result->Initialize(); 320 result->Initialize();
323 return result; 321 return result;
324 } 322 }
325 323
326 Scanner* scanner() const { return scanner_; } 324 Scanner* scanner() const { return scanner_; }
327 AstValueFactory* ast_value_factory() const { return ast_value_factory_; } 325 AstValueFactory* ast_value_factory() const { return ast_value_factory_; }
328 int position() { return scanner_->location().beg_pos; } 326 int position() { return scanner_->location().beg_pos; }
329 int peek_position() { return scanner_->peek_location().beg_pos; } 327 int peek_position() { return scanner_->peek_location().beg_pos; }
(...skipping 2592 matching lines...) Expand 10 before | Expand all | Expand 10 after
2922 ArrowFormalParametersUnexpectedToken(&arrow_formals_classifier); 2920 ArrowFormalParametersUnexpectedToken(&arrow_formals_classifier);
2923 } 2921 }
2924 ExpressionT expression = this->ParseConditionalExpression( 2922 ExpressionT expression = this->ParseConditionalExpression(
2925 accept_IN, &arrow_formals_classifier, CHECK_OK); 2923 accept_IN, &arrow_formals_classifier, CHECK_OK);
2926 if (peek() == Token::ARROW) { 2924 if (peek() == Token::ARROW) {
2927 BindingPatternUnexpectedToken(classifier); 2925 BindingPatternUnexpectedToken(classifier);
2928 ValidateArrowFormalParameters(&arrow_formals_classifier, expression, 2926 ValidateArrowFormalParameters(&arrow_formals_classifier, expression,
2929 parenthesized_formals, CHECK_OK); 2927 parenthesized_formals, CHECK_OK);
2930 Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos); 2928 Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos);
2931 Scope* scope = 2929 Scope* scope =
2932 this->NewScope(scope_, ARROW_SCOPE, FunctionKind::kArrowFunction); 2930 this->NewScope(scope_, FUNCTION_SCOPE, FunctionKind::kArrowFunction);
2933 FormalParametersT parameters(scope); 2931 FormalParametersT parameters(scope);
2934 if (!arrow_formals_classifier.is_simple_parameter_list()) { 2932 if (!arrow_formals_classifier.is_simple_parameter_list()) {
2935 scope->SetHasNonSimpleParameters(); 2933 scope->SetHasNonSimpleParameters();
2936 parameters.is_simple = false; 2934 parameters.is_simple = false;
2937 } 2935 }
2938 2936
2939 Scanner::Location duplicate_loc = Scanner::Location::invalid(); 2937 Scanner::Location duplicate_loc = Scanner::Location::invalid();
2940 this->ParseArrowFunctionFormalParameterList(&parameters, expression, loc, 2938 this->ParseArrowFunctionFormalParameterList(&parameters, expression, loc,
2941 &duplicate_loc, CHECK_OK); 2939 &duplicate_loc, CHECK_OK);
2942 2940
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after
4188 return; 4186 return;
4189 } 4187 }
4190 has_seen_constructor_ = true; 4188 has_seen_constructor_ = true;
4191 return; 4189 return;
4192 } 4190 }
4193 } 4191 }
4194 } // namespace internal 4192 } // namespace internal
4195 } // namespace v8 4193 } // namespace v8
4196 4194
4197 #endif // V8_PREPARSER_H 4195 #endif // V8_PREPARSER_H
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/preparser.cc » ('j') | test/mjsunit/es6/regress/regress-4466.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698