| 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_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/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| (...skipping 2053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2064 // TODO(dslomov): allow 'undefined' in nested patterns. | 2064 // TODO(dslomov): allow 'undefined' in nested patterns. |
| 2065 classifier->RecordBindingPatternError(scanner()->location(), | 2065 classifier->RecordBindingPatternError(scanner()->location(), |
| 2066 "strong_undefined"); | 2066 "strong_undefined"); |
| 2067 classifier->RecordAssignmentPatternError(scanner()->location(), | 2067 classifier->RecordAssignmentPatternError(scanner()->location(), |
| 2068 "strong_undefined"); | 2068 "strong_undefined"); |
| 2069 } | 2069 } |
| 2070 if (is_strong(language_mode()) && this->IsArguments(name)) { | 2070 if (is_strong(language_mode()) && this->IsArguments(name)) { |
| 2071 classifier->RecordExpressionError(scanner()->location(), | 2071 classifier->RecordExpressionError(scanner()->location(), |
| 2072 "strong_arguments"); | 2072 "strong_arguments"); |
| 2073 } | 2073 } |
| 2074 if (this->IsArguments(name)) scope_->RecordArgumentsUsage(); | |
| 2075 return name; | 2074 return name; |
| 2076 } else if (is_sloppy(language_mode()) && | 2075 } else if (is_sloppy(language_mode()) && |
| 2077 (next == Token::FUTURE_STRICT_RESERVED_WORD || | 2076 (next == Token::FUTURE_STRICT_RESERVED_WORD || |
| 2078 next == Token::LET || next == Token::STATIC || | 2077 next == Token::LET || next == Token::STATIC || |
| 2079 (next == Token::YIELD && !is_generator()))) { | 2078 (next == Token::YIELD && !is_generator()))) { |
| 2080 return this->GetSymbol(scanner()); | 2079 return this->GetSymbol(scanner()); |
| 2081 } else { | 2080 } else { |
| 2082 this->ReportUnexpectedToken(next); | 2081 this->ReportUnexpectedToken(next); |
| 2083 *ok = false; | 2082 *ok = false; |
| 2084 return Traits::EmptyIdentifier(); | 2083 return Traits::EmptyIdentifier(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2097 next == Token::STATIC || | 2096 next == Token::STATIC || |
| 2098 (next == Token::YIELD && !this->is_generator())) { | 2097 (next == Token::YIELD && !this->is_generator())) { |
| 2099 *is_strict_reserved = true; | 2098 *is_strict_reserved = true; |
| 2100 } else { | 2099 } else { |
| 2101 ReportUnexpectedToken(next); | 2100 ReportUnexpectedToken(next); |
| 2102 *ok = false; | 2101 *ok = false; |
| 2103 return Traits::EmptyIdentifier(); | 2102 return Traits::EmptyIdentifier(); |
| 2104 } | 2103 } |
| 2105 | 2104 |
| 2106 IdentifierT name = this->GetSymbol(scanner()); | 2105 IdentifierT name = this->GetSymbol(scanner()); |
| 2107 if (this->IsArguments(name)) scope_->RecordArgumentsUsage(); | |
| 2108 return name; | 2106 return name; |
| 2109 } | 2107 } |
| 2110 | 2108 |
| 2111 | 2109 |
| 2112 template <class Traits> | 2110 template <class Traits> |
| 2113 typename ParserBase<Traits>::IdentifierT | 2111 typename ParserBase<Traits>::IdentifierT |
| 2114 ParserBase<Traits>::ParseIdentifierName(bool* ok) { | 2112 ParserBase<Traits>::ParseIdentifierName(bool* ok) { |
| 2115 Token::Value next = Next(); | 2113 Token::Value next = Next(); |
| 2116 if (next != Token::IDENTIFIER && next != Token::FUTURE_RESERVED_WORD && | 2114 if (next != Token::IDENTIFIER && next != Token::FUTURE_RESERVED_WORD && |
| 2117 next != Token::LET && next != Token::STATIC && next != Token::YIELD && | 2115 next != Token::LET && next != Token::STATIC && next != Token::YIELD && |
| 2118 next != Token::FUTURE_STRICT_RESERVED_WORD && !Token::IsKeyword(next)) { | 2116 next != Token::FUTURE_STRICT_RESERVED_WORD && !Token::IsKeyword(next)) { |
| 2119 this->ReportUnexpectedToken(next); | 2117 this->ReportUnexpectedToken(next); |
| 2120 *ok = false; | 2118 *ok = false; |
| 2121 return Traits::EmptyIdentifier(); | 2119 return Traits::EmptyIdentifier(); |
| 2122 } | 2120 } |
| 2123 | 2121 |
| 2124 IdentifierT name = this->GetSymbol(scanner()); | 2122 IdentifierT name = this->GetSymbol(scanner()); |
| 2125 if (this->IsArguments(name)) scope_->RecordArgumentsUsage(); | |
| 2126 return name; | 2123 return name; |
| 2127 } | 2124 } |
| 2128 | 2125 |
| 2129 | 2126 |
| 2130 template <class Traits> | 2127 template <class Traits> |
| 2131 typename ParserBase<Traits>::IdentifierT | 2128 typename ParserBase<Traits>::IdentifierT |
| 2132 ParserBase<Traits>::ParseIdentifierNameOrGetOrSet(bool* is_get, | 2129 ParserBase<Traits>::ParseIdentifierNameOrGetOrSet(bool* is_get, |
| 2133 bool* is_set, | 2130 bool* is_set, |
| 2134 bool* ok) { | 2131 bool* ok) { |
| 2135 IdentifierT result = ParseIdentifierName(ok); | 2132 IdentifierT result = ParseIdentifierName(ok); |
| (...skipping 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3838 *ok = false; | 3835 *ok = false; |
| 3839 return; | 3836 return; |
| 3840 } | 3837 } |
| 3841 has_seen_constructor_ = true; | 3838 has_seen_constructor_ = true; |
| 3842 return; | 3839 return; |
| 3843 } | 3840 } |
| 3844 } | 3841 } |
| 3845 } } // v8::internal | 3842 } } // v8::internal |
| 3846 | 3843 |
| 3847 #endif // V8_PREPARSER_H | 3844 #endif // V8_PREPARSER_H |
| OLD | NEW |