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

Side by Side Diff: src/parsing/preparser.cc

Issue 1712833002: Don't reflect ES2015 Function name inference in Function.prototype.toString (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Move bits around to make STATIC_ASSERT happy Created 4 years, 10 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
« no previous file with comments | « src/parsing/preparser.h ('k') | test/mjsunit/harmony/function-name.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 PreParserExpression PreParserTraits::ParseV8Intrinsic(bool* ok) { 88 PreParserExpression PreParserTraits::ParseV8Intrinsic(bool* ok) {
89 return pre_parser_->ParseV8Intrinsic(ok); 89 return pre_parser_->ParseV8Intrinsic(ok);
90 } 90 }
91 91
92 92
93 PreParserExpression PreParserTraits::ParseFunctionLiteral( 93 PreParserExpression PreParserTraits::ParseFunctionLiteral(
94 PreParserIdentifier name, Scanner::Location function_name_location, 94 PreParserIdentifier name, Scanner::Location function_name_location,
95 FunctionNameValidity function_name_validity, FunctionKind kind, 95 FunctionNameValidity function_name_validity, FunctionKind kind,
96 int function_token_position, FunctionLiteral::FunctionType type, 96 int function_token_position, FunctionLiteral::FunctionType type,
97 FunctionLiteral::ArityRestriction arity_restriction,
98 LanguageMode language_mode, bool* ok) { 97 LanguageMode language_mode, bool* ok) {
99 return pre_parser_->ParseFunctionLiteral( 98 return pre_parser_->ParseFunctionLiteral(
100 name, function_name_location, function_name_validity, kind, 99 name, function_name_location, function_name_validity, kind,
101 function_token_position, type, arity_restriction, language_mode, ok); 100 function_token_position, type, language_mode, ok);
102 } 101 }
103 102
104 103
105 PreParser::PreParseResult PreParser::PreParseLazyFunction( 104 PreParser::PreParseResult PreParser::PreParseLazyFunction(
106 LanguageMode language_mode, FunctionKind kind, bool has_simple_parameters, 105 LanguageMode language_mode, FunctionKind kind, bool has_simple_parameters,
107 ParserRecorder* log, Scanner::BookmarkScope* bookmark) { 106 ParserRecorder* log, Scanner::BookmarkScope* bookmark) {
108 log_ = log; 107 log_ = log;
109 // Lazy functions always have trivial outer scopes (no with/catch scopes). 108 // Lazy functions always have trivial outer scopes (no with/catch scopes).
110 Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE); 109 Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE);
111 PreParserFactory top_factory(NULL); 110 PreParserFactory top_factory(NULL);
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 int pos = position(); 443 int pos = position();
445 bool is_generator = Check(Token::MUL); 444 bool is_generator = Check(Token::MUL);
446 bool is_strict_reserved = false; 445 bool is_strict_reserved = false;
447 Identifier name = ParseIdentifierOrStrictReservedWord( 446 Identifier name = ParseIdentifierOrStrictReservedWord(
448 &is_strict_reserved, CHECK_OK); 447 &is_strict_reserved, CHECK_OK);
449 ParseFunctionLiteral(name, scanner()->location(), 448 ParseFunctionLiteral(name, scanner()->location(),
450 is_strict_reserved ? kFunctionNameIsStrictReserved 449 is_strict_reserved ? kFunctionNameIsStrictReserved
451 : kFunctionNameValidityUnknown, 450 : kFunctionNameValidityUnknown,
452 is_generator ? FunctionKind::kGeneratorFunction 451 is_generator ? FunctionKind::kGeneratorFunction
453 : FunctionKind::kNormalFunction, 452 : FunctionKind::kNormalFunction,
454 pos, FunctionLiteral::kDeclaration, 453 pos, FunctionLiteral::kDeclaration, language_mode(),
455 FunctionLiteral::kNormalArity, language_mode(),
456 CHECK_OK); 454 CHECK_OK);
457 return Statement::FunctionDeclaration(); 455 return Statement::FunctionDeclaration();
458 } 456 }
459 457
460 458
461 PreParser::Statement PreParser::ParseClassDeclaration(bool* ok) { 459 PreParser::Statement PreParser::ParseClassDeclaration(bool* ok) {
462 Expect(Token::CLASS, CHECK_OK); 460 Expect(Token::CLASS, CHECK_OK);
463 if (!allow_harmony_sloppy() && is_sloppy(language_mode())) { 461 if (!allow_harmony_sloppy() && is_sloppy(language_mode())) {
464 ReportMessage(MessageTemplate::kSloppyLexical); 462 ReportMessage(MessageTemplate::kSloppyLexical);
465 *ok = false; 463 *ok = false;
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 if (!*ok) return Expression::Default(); \ 1095 if (!*ok) return Expression::Default(); \
1098 ((void)0 1096 ((void)0
1099 #define DUMMY ) // to make indentation work 1097 #define DUMMY ) // to make indentation work
1100 #undef DUMMY 1098 #undef DUMMY
1101 1099
1102 1100
1103 PreParser::Expression PreParser::ParseFunctionLiteral( 1101 PreParser::Expression PreParser::ParseFunctionLiteral(
1104 Identifier function_name, Scanner::Location function_name_location, 1102 Identifier function_name, Scanner::Location function_name_location,
1105 FunctionNameValidity function_name_validity, FunctionKind kind, 1103 FunctionNameValidity function_name_validity, FunctionKind kind,
1106 int function_token_pos, FunctionLiteral::FunctionType function_type, 1104 int function_token_pos, FunctionLiteral::FunctionType function_type,
1107 FunctionLiteral::ArityRestriction arity_restriction,
1108 LanguageMode language_mode, bool* ok) { 1105 LanguageMode language_mode, bool* ok) {
1109 // Function :: 1106 // Function ::
1110 // '(' FormalParameterList? ')' '{' FunctionBody '}' 1107 // '(' FormalParameterList? ')' '{' FunctionBody '}'
1111 1108
1112 // Parse function body. 1109 // Parse function body.
1113 bool outer_is_script_scope = scope_->is_script_scope(); 1110 bool outer_is_script_scope = scope_->is_script_scope();
1114 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE, kind); 1111 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE, kind);
1115 function_scope->SetLanguageMode(language_mode); 1112 function_scope->SetLanguageMode(language_mode);
1116 PreParserFactory factory(NULL); 1113 PreParserFactory factory(NULL);
1117 FunctionState function_state(&function_state_, &scope_, function_scope, kind, 1114 FunctionState function_state(&function_state_, &scope_, function_scope, kind,
1118 &factory); 1115 &factory);
1119 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); 1116 DuplicateFinder duplicate_finder(scanner()->unicode_cache());
1120 ExpressionClassifier formals_classifier(&duplicate_finder); 1117 ExpressionClassifier formals_classifier(&duplicate_finder);
1121 1118
1122 Expect(Token::LPAREN, CHECK_OK); 1119 Expect(Token::LPAREN, CHECK_OK);
1123 int start_position = scanner()->location().beg_pos; 1120 int start_position = scanner()->location().beg_pos;
1124 function_scope->set_start_position(start_position); 1121 function_scope->set_start_position(start_position);
1125 PreParserFormalParameters formals(function_scope); 1122 PreParserFormalParameters formals(function_scope);
1126 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK); 1123 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK);
1127 Expect(Token::RPAREN, CHECK_OK); 1124 Expect(Token::RPAREN, CHECK_OK);
1128 int formals_end_position = scanner()->location().end_pos; 1125 int formals_end_position = scanner()->location().end_pos;
1129 1126
1130 CheckArityRestrictions(formals.arity, arity_restriction, 1127 CheckArityRestrictions(formals.arity, kind, formals.has_rest, start_position,
1131 formals.has_rest, start_position,
1132 formals_end_position, CHECK_OK); 1128 formals_end_position, CHECK_OK);
1133 1129
1134 // See Parser::ParseFunctionLiteral for more information about lazy parsing 1130 // See Parser::ParseFunctionLiteral for more information about lazy parsing
1135 // and lazy compilation. 1131 // and lazy compilation.
1136 bool is_lazily_parsed = 1132 bool is_lazily_parsed =
1137 (outer_is_script_scope && allow_lazy() && !parenthesized_function_); 1133 (outer_is_script_scope && allow_lazy() && !parenthesized_function_);
1138 parenthesized_function_ = false; 1134 parenthesized_function_ = false;
1139 1135
1140 Expect(Token::LBRACE, CHECK_OK); 1136 Expect(Token::LBRACE, CHECK_OK);
1141 if (is_lazily_parsed) { 1137 if (is_lazily_parsed) {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 Expect(Token::RBRACE, CHECK_OK); 1284 Expect(Token::RBRACE, CHECK_OK);
1289 return PreParserExpression::Default(); 1285 return PreParserExpression::Default();
1290 } 1286 }
1291 } 1287 }
1292 1288
1293 #undef CHECK_OK 1289 #undef CHECK_OK
1294 1290
1295 1291
1296 } // namespace internal 1292 } // namespace internal
1297 } // namespace v8 1293 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/preparser.h ('k') | test/mjsunit/harmony/function-name.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698