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

Side by Side Diff: src/preparser.h

Issue 422923004: Track usage of "this" and "arguments" in Scope (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 6 years, 4 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 | Annotate | Revision Log
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/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/func-name-inferrer.h" 10 #include "src/func-name-inferrer.h"
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 885
886 // When PreParser is in use, lazy compilation is already being done, 886 // When PreParser is in use, lazy compilation is already being done,
887 // things cannot get lazier than that. 887 // things cannot get lazier than that.
888 bool AllowsLazyCompilation() const { return false; } 888 bool AllowsLazyCompilation() const { return false; }
889 889
890 void set_start_position(int position) {} 890 void set_start_position(int position) {}
891 void set_end_position(int position) {} 891 void set_end_position(int position) {}
892 892
893 bool IsDeclared(const PreParserIdentifier& identifier) const { return false; } 893 bool IsDeclared(const PreParserIdentifier& identifier) const { return false; }
894 void DeclareParameter(const PreParserIdentifier& identifier, VariableMode) {} 894 void DeclareParameter(const PreParserIdentifier& identifier, VariableMode) {}
895 void RecordArgumentsUsage() {}
896 void RecordThisUsage() {}
895 897
896 // Allow scope->Foo() to work. 898 // Allow scope->Foo() to work.
897 PreParserScope* operator->() { return this; } 899 PreParserScope* operator->() { return this; }
898 900
899 private: 901 private:
900 ScopeType scope_type_; 902 ScopeType scope_type_;
901 StrictMode strict_mode_; 903 StrictMode strict_mode_;
902 }; 904 };
903 905
904 906
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 AllowEvalOrArgumentsAsIdentifier allow_eval_or_arguments, 1539 AllowEvalOrArgumentsAsIdentifier allow_eval_or_arguments,
1538 bool* ok) { 1540 bool* ok) {
1539 Token::Value next = Next(); 1541 Token::Value next = Next();
1540 if (next == Token::IDENTIFIER) { 1542 if (next == Token::IDENTIFIER) {
1541 IdentifierT name = this->GetSymbol(scanner()); 1543 IdentifierT name = this->GetSymbol(scanner());
1542 if (allow_eval_or_arguments == kDontAllowEvalOrArguments && 1544 if (allow_eval_or_arguments == kDontAllowEvalOrArguments &&
1543 strict_mode() == STRICT && this->IsEvalOrArguments(name)) { 1545 strict_mode() == STRICT && this->IsEvalOrArguments(name)) {
1544 ReportMessage("strict_eval_arguments"); 1546 ReportMessage("strict_eval_arguments");
1545 *ok = false; 1547 *ok = false;
1546 } 1548 }
1549 if (name->IsArguments()) scope_->RecordArgumentsUsage();
1547 return name; 1550 return name;
1548 } else if (strict_mode() == SLOPPY && 1551 } else if (strict_mode() == SLOPPY &&
1549 (next == Token::FUTURE_STRICT_RESERVED_WORD || 1552 (next == Token::FUTURE_STRICT_RESERVED_WORD ||
1550 (next == Token::LET) || 1553 (next == Token::LET) ||
1551 (next == Token::YIELD && !is_generator()))) { 1554 (next == Token::YIELD && !is_generator()))) {
1552 return this->GetSymbol(scanner()); 1555 return this->GetSymbol(scanner());
1553 } else { 1556 } else {
1554 this->ReportUnexpectedToken(next); 1557 this->ReportUnexpectedToken(next);
1555 *ok = false; 1558 *ok = false;
1556 return Traits::EmptyIdentifier(); 1559 return Traits::EmptyIdentifier();
(...skipping 10 matching lines...) Expand all
1567 *is_strict_reserved = false; 1570 *is_strict_reserved = false;
1568 } else if (next == Token::FUTURE_STRICT_RESERVED_WORD || 1571 } else if (next == Token::FUTURE_STRICT_RESERVED_WORD ||
1569 next == Token::LET || 1572 next == Token::LET ||
1570 (next == Token::YIELD && !this->is_generator())) { 1573 (next == Token::YIELD && !this->is_generator())) {
1571 *is_strict_reserved = true; 1574 *is_strict_reserved = true;
1572 } else { 1575 } else {
1573 ReportUnexpectedToken(next); 1576 ReportUnexpectedToken(next);
1574 *ok = false; 1577 *ok = false;
1575 return Traits::EmptyIdentifier(); 1578 return Traits::EmptyIdentifier();
1576 } 1579 }
1577 return this->GetSymbol(scanner()); 1580
1581 IdentifierT name = this->GetSymbol(scanner());
1582 if (name->IsArguments()) scope_->RecordArgumentsUsage();
1583 return name;
1578 } 1584 }
1579 1585
1580 1586
1581 template <class Traits> 1587 template <class Traits>
1582 typename ParserBase<Traits>::IdentifierT 1588 typename ParserBase<Traits>::IdentifierT
1583 ParserBase<Traits>::ParseIdentifierName(bool* ok) { 1589 ParserBase<Traits>::ParseIdentifierName(bool* ok) {
1584 Token::Value next = Next(); 1590 Token::Value next = Next();
1585 if (next != Token::IDENTIFIER && next != Token::FUTURE_RESERVED_WORD && 1591 if (next != Token::IDENTIFIER && next != Token::FUTURE_RESERVED_WORD &&
1586 next != Token::LET && next != Token::YIELD && 1592 next != Token::LET && next != Token::YIELD &&
1587 next != Token::FUTURE_STRICT_RESERVED_WORD && !Token::IsKeyword(next)) { 1593 next != Token::FUTURE_STRICT_RESERVED_WORD && !Token::IsKeyword(next)) {
1588 this->ReportUnexpectedToken(next); 1594 this->ReportUnexpectedToken(next);
1589 *ok = false; 1595 *ok = false;
1590 return Traits::EmptyIdentifier(); 1596 return Traits::EmptyIdentifier();
1591 } 1597 }
1592 return this->GetSymbol(scanner()); 1598
1599 IdentifierT name = this->GetSymbol(scanner());
1600 if (name->IsArguments()) scope_->RecordArgumentsUsage();
1601 return name;
1593 } 1602 }
1594 1603
1595 1604
1596 template <class Traits> 1605 template <class Traits>
1597 typename ParserBase<Traits>::IdentifierT 1606 typename ParserBase<Traits>::IdentifierT
1598 ParserBase<Traits>::ParseIdentifierNameOrGetOrSet(bool* is_get, 1607 ParserBase<Traits>::ParseIdentifierNameOrGetOrSet(bool* is_get,
1599 bool* is_set, 1608 bool* is_set,
1600 bool* ok) { 1609 bool* ok) {
1601 IdentifierT result = ParseIdentifierName(ok); 1610 IdentifierT result = ParseIdentifierName(ok);
1602 if (!*ok) return Traits::EmptyIdentifier(); 1611 if (!*ok) return Traits::EmptyIdentifier();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 // ObjectLiteral 1668 // ObjectLiteral
1660 // RegExpLiteral 1669 // RegExpLiteral
1661 // '(' Expression ')' 1670 // '(' Expression ')'
1662 1671
1663 int pos = peek_position(); 1672 int pos = peek_position();
1664 ExpressionT result = this->EmptyExpression(); 1673 ExpressionT result = this->EmptyExpression();
1665 Token::Value token = peek(); 1674 Token::Value token = peek();
1666 switch (token) { 1675 switch (token) {
1667 case Token::THIS: { 1676 case Token::THIS: {
1668 Consume(Token::THIS); 1677 Consume(Token::THIS);
1678 scope_->RecordThisUsage();
1669 result = this->ThisExpression(scope_, factory()); 1679 result = this->ThisExpression(scope_, factory());
1670 break; 1680 break;
1671 } 1681 }
1672 1682
1673 case Token::NULL_LITERAL: 1683 case Token::NULL_LITERAL:
1674 case Token::TRUE_LITERAL: 1684 case Token::TRUE_LITERAL:
1675 case Token::FALSE_LITERAL: 1685 case Token::FALSE_LITERAL:
1676 case Token::NUMBER: 1686 case Token::NUMBER:
1677 Next(); 1687 Next();
1678 result = this->ExpressionFromLiteral(token, pos, scanner(), factory()); 1688 result = this->ExpressionFromLiteral(token, pos, scanner(), factory());
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
2619 parser()->ReportMessage("accessor_get_set"); 2629 parser()->ReportMessage("accessor_get_set");
2620 } 2630 }
2621 *ok = false; 2631 *ok = false;
2622 } 2632 }
2623 } 2633 }
2624 2634
2625 2635
2626 } } // v8::internal 2636 } } // v8::internal
2627 2637
2628 #endif // V8_PREPARSER_H 2638 #endif // V8_PREPARSER_H
OLDNEW
« src/ast-value-factory.h ('K') | « src/ast-value-factory.h ('k') | src/scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698