| OLD | NEW |
| 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_PARSING_PREPARSER_H | 5 #ifndef V8_PARSING_PREPARSER_H |
| 6 #define V8_PARSING_PREPARSER_H | 6 #define V8_PARSING_PREPARSER_H |
| 7 | 7 |
| 8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
| 9 #include "src/parsing/parser-base.h" | 9 #include "src/parsing/parser-base.h" |
| 10 | 10 |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 // The pre-parser doesn't need to build lists of expressions, identifiers, or | 403 // The pre-parser doesn't need to build lists of expressions, identifiers, or |
| 404 // the like. If the PreParser is used in identifier tracking mode, it needs to | 404 // the like. If the PreParser is used in identifier tracking mode, it needs to |
| 405 // build lists of identifiers though. | 405 // build lists of identifiers though. |
| 406 template <typename T> | 406 template <typename T> |
| 407 class PreParserList { | 407 class PreParserList { |
| 408 public: | 408 public: |
| 409 // These functions make list->Add(some_expression) work (and do nothing). | 409 // These functions make list->Add(some_expression) work (and do nothing). |
| 410 PreParserList() : length_(0), identifiers_(nullptr) {} | 410 PreParserList() : length_(0), identifiers_(nullptr) {} |
| 411 PreParserList* operator->() { return this; } | 411 PreParserList* operator->() { return this; } |
| 412 void Add(T, Zone* zone); | 412 void Add(T, Zone* zone); |
| 413 void push_back(T); |
| 413 int length() const { return length_; } | 414 int length() const { return length_; } |
| 415 int size() const { return length_; } |
| 414 static PreParserList Null() { return PreParserList(-1); } | 416 static PreParserList Null() { return PreParserList(-1); } |
| 415 bool IsNull() const { return length_ == -1; } | 417 bool IsNull() const { return length_ == -1; } |
| 416 | 418 |
| 417 private: | 419 private: |
| 418 explicit PreParserList(int n) : length_(n), identifiers_(nullptr) {} | 420 explicit PreParserList(int n) : length_(n), identifiers_(nullptr) {} |
| 419 int length_; | 421 int length_; |
| 420 ZoneList<const AstRawString*>* identifiers_; | 422 ZoneList<const AstRawString*>* identifiers_; |
| 421 | 423 |
| 422 friend class PreParser; | 424 friend class PreParser; |
| 423 friend class PreParserFactory; | 425 friend class PreParserFactory; |
| 424 }; | 426 }; |
| 425 | 427 |
| 426 template <> | 428 template <> |
| 427 inline void PreParserList<PreParserExpression>::Add( | 429 inline void PreParserList<PreParserExpression>::Add( |
| 428 PreParserExpression expression, Zone* zone) { | 430 PreParserExpression expression, Zone* zone) { |
| 429 if (expression.identifiers_ != nullptr) { | 431 if (expression.identifiers_ != nullptr) { |
| 430 DCHECK(FLAG_lazy_inner_functions); | 432 DCHECK(FLAG_lazy_inner_functions); |
| 431 DCHECK(zone != nullptr); | 433 DCHECK(zone != nullptr); |
| 432 if (identifiers_ == nullptr) { | 434 if (identifiers_ == nullptr) { |
| 433 identifiers_ = new (zone) ZoneList<const AstRawString*>(1, zone); | 435 identifiers_ = new (zone) ZoneList<const AstRawString*>(1, zone); |
| 434 } | 436 } |
| 435 for (auto identifier : (*expression.identifiers_)) { | 437 for (auto identifier : (*expression.identifiers_)) { |
| 436 identifiers_->Add(identifier, zone); | 438 identifiers_->Add(identifier, zone); |
| 437 } | 439 } |
| 438 } | 440 } |
| 439 ++length_; | 441 ++length_; |
| 440 } | 442 } |
| 441 | 443 |
| 444 template <> |
| 445 inline void PreParserList<PreParserExpression>::push_back( |
| 446 PreParserExpression expression) { |
| 447 UNREACHABLE(); |
| 448 } |
| 449 |
| 450 template <typename T> |
| 451 void PreParserList<T>::Add(T, Zone*) { |
| 452 ++length_; |
| 453 } |
| 454 |
| 442 template <typename T> | 455 template <typename T> |
| 443 void PreParserList<T>::Add(T, Zone* zone) { | 456 void PreParserList<T>::push_back(T) { |
| 444 ++length_; | 457 ++length_; |
| 445 } | 458 } |
| 446 | 459 |
| 447 typedef PreParserList<PreParserExpression> PreParserExpressionList; | 460 typedef PreParserList<PreParserExpression> PreParserExpressionList; |
| 448 | 461 |
| 449 class PreParserStatement; | 462 class PreParserStatement; |
| 450 typedef PreParserList<PreParserStatement> PreParserStatementList; | 463 typedef PreParserList<PreParserStatement> PreParserStatementList; |
| 451 | 464 |
| 452 class PreParserStatement { | 465 class PreParserStatement { |
| 453 public: | 466 public: |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 | 685 |
| 673 PreParserExpression NewEmptyParentheses(int pos) { | 686 PreParserExpression NewEmptyParentheses(int pos) { |
| 674 return PreParserExpression::Default(); | 687 return PreParserExpression::Default(); |
| 675 } | 688 } |
| 676 | 689 |
| 677 PreParserStatement NewEmptyStatement(int pos) { | 690 PreParserStatement NewEmptyStatement(int pos) { |
| 678 return PreParserStatement::Default(); | 691 return PreParserStatement::Default(); |
| 679 } | 692 } |
| 680 | 693 |
| 681 PreParserStatement NewBlock(ZoneList<const AstRawString*>* labels, | 694 PreParserStatement NewBlock(ZoneList<const AstRawString*>* labels, |
| 682 int capacity, bool ignore_completion_value, | 695 bool ignore_completion_value, int pos) { |
| 683 int pos) { | |
| 684 return PreParserStatement::Default(); | 696 return PreParserStatement::Default(); |
| 685 } | 697 } |
| 686 | 698 |
| 687 PreParserStatement NewDebuggerStatement(int pos) { | 699 PreParserStatement NewDebuggerStatement(int pos) { |
| 688 return PreParserStatement::Default(); | 700 return PreParserStatement::Default(); |
| 689 } | 701 } |
| 690 | 702 |
| 691 PreParserStatement NewExpressionStatement(PreParserExpression expr, int pos) { | 703 PreParserStatement NewExpressionStatement(PreParserExpression expr, int pos) { |
| 692 return PreParserStatement::ExpressionStatement(expr); | 704 return PreParserStatement::ExpressionStatement(expr); |
| 693 } | 705 } |
| (...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1540 function_state_->NextMaterializedLiteralIndex(); | 1552 function_state_->NextMaterializedLiteralIndex(); |
| 1541 function_state_->NextMaterializedLiteralIndex(); | 1553 function_state_->NextMaterializedLiteralIndex(); |
| 1542 } | 1554 } |
| 1543 return EmptyExpression(); | 1555 return EmptyExpression(); |
| 1544 } | 1556 } |
| 1545 | 1557 |
| 1546 } // namespace internal | 1558 } // namespace internal |
| 1547 } // namespace v8 | 1559 } // namespace v8 |
| 1548 | 1560 |
| 1549 #endif // V8_PARSING_PREPARSER_H | 1561 #endif // V8_PARSING_PREPARSER_H |
| OLD | NEW |