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

Side by Side Diff: src/parser.h

Issue 1411203002: [es6] implement destructuring assignment [clean diff] (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rename `recorded_first()` to `FirstRecorded()` because non-accessor Created 5 years, 1 month 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 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 553
554 explicit ParserFormalParameters(Scope* scope) 554 explicit ParserFormalParameters(Scope* scope)
555 : FormalParametersBase(scope), params(4, scope->zone()) {} 555 : FormalParametersBase(scope), params(4, scope->zone()) {}
556 ZoneList<Parameter> params; 556 ZoneList<Parameter> params;
557 557
558 int Arity() const { return params.length(); } 558 int Arity() const { return params.length(); }
559 const Parameter& at(int i) const { return params[i]; } 559 const Parameter& at(int i) const { return params[i]; }
560 }; 560 };
561 561
562 562
563 struct MarkedAssignment {
564 Scope* scope;
565 Assignment* assignment;
566 };
567
568
563 class ParserTraits { 569 class ParserTraits {
564 public: 570 public:
565 struct Type { 571 struct Type {
566 // TODO(marja): To be removed. The Traits object should contain all the data 572 // TODO(marja): To be removed. The Traits object should contain all the data
567 // it needs. 573 // it needs.
568 typedef v8::internal::Parser* Parser; 574 typedef v8::internal::Parser* Parser;
569 575
570 typedef Variable GeneratorVariable; 576 typedef Variable GeneratorVariable;
571 577
572 typedef v8::internal::AstProperties AstProperties; 578 typedef v8::internal::AstProperties AstProperties;
(...skipping 11 matching lines...) Expand all
584 typedef ParserFormalParameters::Parameter FormalParameter; 590 typedef ParserFormalParameters::Parameter FormalParameter;
585 typedef ParserFormalParameters FormalParameters; 591 typedef ParserFormalParameters FormalParameters;
586 typedef ZoneList<v8::internal::Statement*>* StatementList; 592 typedef ZoneList<v8::internal::Statement*>* StatementList;
587 593
588 // For constructing objects returned by the traversing functions. 594 // For constructing objects returned by the traversing functions.
589 typedef AstNodeFactory Factory; 595 typedef AstNodeFactory Factory;
590 }; 596 };
591 597
592 explicit ParserTraits(Parser* parser) : parser_(parser) {} 598 explicit ParserTraits(Parser* parser) : parser_(parser) {}
593 599
600 V8_INLINE void MarkDestructuringAssignment(Assignment* assignment);
601
594 // Helper functions for recursive descent. 602 // Helper functions for recursive descent.
595 bool IsEval(const AstRawString* identifier) const; 603 bool IsEval(const AstRawString* identifier) const;
596 bool IsArguments(const AstRawString* identifier) const; 604 bool IsArguments(const AstRawString* identifier) const;
597 bool IsEvalOrArguments(const AstRawString* identifier) const; 605 bool IsEvalOrArguments(const AstRawString* identifier) const;
598 bool IsUndefined(const AstRawString* identifier) const; 606 bool IsUndefined(const AstRawString* identifier) const;
599 V8_INLINE bool IsFutureStrictReserved(const AstRawString* identifier) const; 607 V8_INLINE bool IsFutureStrictReserved(const AstRawString* identifier) const;
600 608
601 // Returns true if the expression is of type "this.foo". 609 // Returns true if the expression is of type "this.foo".
602 static bool IsThisProperty(Expression* expression); 610 static bool IsThisProperty(Expression* expression);
603 611
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 V8_INLINE ZoneList<v8::internal::Expression*>* PrepareSpreadArguments( 877 V8_INLINE ZoneList<v8::internal::Expression*>* PrepareSpreadArguments(
870 ZoneList<v8::internal::Expression*>* list); 878 ZoneList<v8::internal::Expression*>* list);
871 V8_INLINE void MaterializeUnspreadArgumentsLiterals(int count) {} 879 V8_INLINE void MaterializeUnspreadArgumentsLiterals(int count) {}
872 V8_INLINE Expression* SpreadCall(Expression* function, 880 V8_INLINE Expression* SpreadCall(Expression* function,
873 ZoneList<v8::internal::Expression*>* args, 881 ZoneList<v8::internal::Expression*>* args,
874 int pos); 882 int pos);
875 V8_INLINE Expression* SpreadCallNew(Expression* function, 883 V8_INLINE Expression* SpreadCallNew(Expression* function,
876 ZoneList<v8::internal::Expression*>* args, 884 ZoneList<v8::internal::Expression*>* args,
877 int pos); 885 int pos);
878 886
887 V8_INLINE Expression* RewriteDestructuringAssignmentExpression(
888 Expression* expression);
889
879 private: 890 private:
880 Parser* parser_; 891 Parser* parser_;
881 }; 892 };
882 893
883 894
884 class Parser : public ParserBase<ParserTraits> { 895 class Parser : public ParserBase<ParserTraits> {
885 public: 896 public:
886 explicit Parser(ParseInfo* info); 897 explicit Parser(ParseInfo* info);
887 ~Parser() { 898 ~Parser() {
888 delete reusable_preparser_; 899 delete reusable_preparser_;
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 Expression* tag); 1204 Expression* tag);
1194 uint32_t ComputeTemplateLiteralHash(const TemplateLiteral* lit); 1205 uint32_t ComputeTemplateLiteralHash(const TemplateLiteral* lit);
1195 1206
1196 ZoneList<v8::internal::Expression*>* PrepareSpreadArguments( 1207 ZoneList<v8::internal::Expression*>* PrepareSpreadArguments(
1197 ZoneList<v8::internal::Expression*>* list); 1208 ZoneList<v8::internal::Expression*>* list);
1198 Expression* SpreadCall(Expression* function, 1209 Expression* SpreadCall(Expression* function,
1199 ZoneList<v8::internal::Expression*>* args, int pos); 1210 ZoneList<v8::internal::Expression*>* args, int pos);
1200 Expression* SpreadCallNew(Expression* function, 1211 Expression* SpreadCallNew(Expression* function,
1201 ZoneList<v8::internal::Expression*>* args, int pos); 1212 ZoneList<v8::internal::Expression*>* args, int pos);
1202 1213
1214 Expression* RewriteDestructuringAssignmentExpression(Expression* expression);
1215
1203 Scanner scanner_; 1216 Scanner scanner_;
1204 PreParser* reusable_preparser_; 1217 PreParser* reusable_preparser_;
1205 Scope* original_scope_; // for ES5 function declarations in sloppy eval 1218 Scope* original_scope_; // for ES5 function declarations in sloppy eval
1206 Target* target_stack_; // for break, continue statements 1219 Target* target_stack_; // for break, continue statements
1207 ScriptCompiler::CompileOptions compile_options_; 1220 ScriptCompiler::CompileOptions compile_options_;
1208 ParseData* cached_parse_data_; 1221 ParseData* cached_parse_data_;
1209 1222
1210 PendingCompilationErrorHandler pending_error_handler_; 1223 PendingCompilationErrorHandler pending_error_handler_;
1211 1224
1212 // Other information which will be stored in Parser and moved to Isolate after 1225 // Other information which will be stored in Parser and moved to Isolate after
1213 // parsing. 1226 // parsing.
1214 int use_counts_[v8::Isolate::kUseCounterFeatureCount]; 1227 int use_counts_[v8::Isolate::kUseCounterFeatureCount];
1215 int total_preparse_skipped_; 1228 int total_preparse_skipped_;
1216 HistogramTimer* pre_parse_timer_; 1229 HistogramTimer* pre_parse_timer_;
1217 1230
1218 bool parsing_on_main_thread_; 1231 bool parsing_on_main_thread_;
1232
1233 // Track ambiguous expressions, to be rewritten later.
1234 Collector<MarkedAssignment> marked_assignments_collector_;
1219 }; 1235 };
1220 1236
1221 1237
1222 bool ParserTraits::IsFutureStrictReserved( 1238 bool ParserTraits::IsFutureStrictReserved(
1223 const AstRawString* identifier) const { 1239 const AstRawString* identifier) const {
1224 return parser_->scanner()->IdentifierIsFutureStrictReserved(identifier); 1240 return parser_->scanner()->IdentifierIsFutureStrictReserved(identifier);
1225 } 1241 }
1226 1242
1227 1243
1228 Scope* ParserTraits::NewScope(Scope* parent_scope, ScopeType scope_type, 1244 Scope* ParserTraits::NewScope(Scope* parent_scope, ScopeType scope_type,
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 } 1397 }
1382 } 1398 }
1383 } 1399 }
1384 1400
1385 1401
1386 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { 1402 DoExpression* ParserTraits::ParseDoExpression(bool* ok) {
1387 return parser_->ParseDoExpression(ok); 1403 return parser_->ParseDoExpression(ok);
1388 } 1404 }
1389 1405
1390 1406
1407 void ParserTraits::MarkDestructuringAssignment(Assignment* assignment) {
1408 DCHECK(assignment->IsAssignment());
1409 MarkedAssignment mark;
1410 mark.assignment = assignment;
1411 mark.scope = parser_->scope_;
1412 parser_->marked_assignments_collector_.Add(mark);
1413 }
1414
1415
1416 Expression* ParserTraits::RewriteDestructuringAssignmentExpression(
1417 Expression* expression) {
1418 return parser_->RewriteDestructuringAssignmentExpression(expression);
1419 }
1420
1421
1391 } // namespace internal 1422 } // namespace internal
1392 } // namespace v8 1423 } // namespace v8
1393 1424
1394 #endif // V8_PARSER_H_ 1425 #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