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

Side by Side Diff: src/parser.h

Issue 1300103005: [parser] disallow language mode directive in body of function with non-simple parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: flag implications don't work in test suite? Created 5 years, 3 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/messages.h ('k') | src/parser.cc » ('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 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_PARSER_H_ 5 #ifndef V8_PARSER_H_
6 #define V8_PARSER_H_ 6 #define V8_PARSER_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/compiler.h" // TODO(titzer): remove this include dependency 10 #include "src/compiler.h" // TODO(titzer): remove this include dependency
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 ZoneList<v8::internal::Statement*>* body, bool* ok); 779 ZoneList<v8::internal::Statement*>* body, bool* ok);
780 780
781 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, 781 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type,
782 FunctionKind kind = kNormalFunction); 782 FunctionKind kind = kNormalFunction);
783 783
784 V8_INLINE void AddFormalParameter( 784 V8_INLINE void AddFormalParameter(
785 ParserFormalParameters* parameters, Expression* pattern, 785 ParserFormalParameters* parameters, Expression* pattern,
786 Expression* initializer, bool is_rest); 786 Expression* initializer, bool is_rest);
787 V8_INLINE void DeclareFormalParameter( 787 V8_INLINE void DeclareFormalParameter(
788 Scope* scope, const ParserFormalParameters::Parameter& parameter, 788 Scope* scope, const ParserFormalParameters::Parameter& parameter,
789 bool is_simple, ExpressionClassifier* classifier); 789 ExpressionClassifier* classifier);
790 void ParseArrowFunctionFormalParameters( 790 void ParseArrowFunctionFormalParameters(ParserFormalParameters* parameters,
791 ParserFormalParameters* parameters, Expression* params, 791 Expression* params,
792 const Scanner::Location& params_loc, 792 const Scanner::Location& params_loc,
793 Scanner::Location* duplicate_loc, bool* ok); 793 bool* ok);
794 void ParseArrowFunctionFormalParameterList( 794 void ParseArrowFunctionFormalParameterList(
795 ParserFormalParameters* parameters, Expression* params, 795 ParserFormalParameters* parameters, Expression* params,
796 const Scanner::Location& params_loc, 796 const Scanner::Location& params_loc,
797 Scanner::Location* duplicate_loc, bool* ok); 797 Scanner::Location* duplicate_loc, bool* ok);
798 798
799 void ReindexLiterals(const ParserFormalParameters& parameters); 799 void ReindexLiterals(const ParserFormalParameters& parameters);
800 800
801 // Temporary glue; these functions will move to ParserBase. 801 // Temporary glue; these functions will move to ParserBase.
802 Expression* ParseV8Intrinsic(bool* ok); 802 Expression* ParseV8Intrinsic(bool* ok);
803 FunctionLiteral* ParseFunctionLiteral( 803 FunctionLiteral* ParseFunctionLiteral(
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 ? pattern->AsVariableProxy()->raw_name() 1328 ? pattern->AsVariableProxy()->raw_name()
1329 : parser_->ast_value_factory()->empty_string(); 1329 : parser_->ast_value_factory()->empty_string();
1330 parameters->params.Add( 1330 parameters->params.Add(
1331 ParserFormalParameters::Parameter(name, pattern, initializer, is_rest), 1331 ParserFormalParameters::Parameter(name, pattern, initializer, is_rest),
1332 parameters->scope->zone()); 1332 parameters->scope->zone());
1333 } 1333 }
1334 1334
1335 1335
1336 void ParserTraits::DeclareFormalParameter( 1336 void ParserTraits::DeclareFormalParameter(
1337 Scope* scope, const ParserFormalParameters::Parameter& parameter, 1337 Scope* scope, const ParserFormalParameters::Parameter& parameter,
1338 bool is_simple, ExpressionClassifier* classifier) { 1338 ExpressionClassifier* classifier) {
1339 bool is_duplicate = false; 1339 bool is_duplicate = false;
1340 bool is_simple = classifier->is_simple_parameter_list();
1340 // TODO(caitp): Remove special handling for rest once desugaring is in. 1341 // TODO(caitp): Remove special handling for rest once desugaring is in.
1341 auto name = is_simple || parameter.is_rest 1342 auto name = is_simple || parameter.is_rest
1342 ? parameter.name : parser_->ast_value_factory()->empty_string(); 1343 ? parameter.name : parser_->ast_value_factory()->empty_string();
1343 auto mode = is_simple || parameter.is_rest ? VAR : TEMPORARY; 1344 auto mode = is_simple || parameter.is_rest ? VAR : TEMPORARY;
1345 if (!is_simple) scope->SetHasNonSimpleParameters();
1344 bool is_optional = parameter.initializer != nullptr; 1346 bool is_optional = parameter.initializer != nullptr;
1345 Variable* var = scope->DeclareParameter( 1347 Variable* var = scope->DeclareParameter(
1346 name, mode, is_optional, parameter.is_rest, &is_duplicate); 1348 name, mode, is_optional, parameter.is_rest, &is_duplicate);
1347 if (is_duplicate) { 1349 if (is_duplicate) {
1348 classifier->RecordDuplicateFormalParameterError( 1350 classifier->RecordDuplicateFormalParameterError(
1349 parser_->scanner()->location()); 1351 parser_->scanner()->location());
1350 } 1352 }
1351 if (is_sloppy(scope->language_mode())) { 1353 if (is_sloppy(scope->language_mode())) {
1352 // TODO(sigurds) Mark every parameter as maybe assigned. This is a 1354 // TODO(sigurds) Mark every parameter as maybe assigned. This is a
1353 // conservative approximation necessary to account for parameters 1355 // conservative approximation necessary to account for parameters
(...skipping 11 matching lines...) Expand all
1365 parser_->BuildParameterInitializationBlock(parameters, ok); 1367 parser_->BuildParameterInitializationBlock(parameters, ok);
1366 if (!*ok) return; 1368 if (!*ok) return;
1367 if (init_block != nullptr) { 1369 if (init_block != nullptr) {
1368 body->Add(init_block, parser_->zone()); 1370 body->Add(init_block, parser_->zone());
1369 } 1371 }
1370 } 1372 }
1371 } 1373 }
1372 } } // namespace v8::internal 1374 } } // namespace v8::internal
1373 1375
1374 #endif // V8_PARSER_H_ 1376 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « src/messages.h ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698