OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 #include <cmath> | 5 #include <cmath> |
6 | 6 |
7 #include "src/allocation.h" | 7 #include "src/allocation.h" |
8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 if (directive_prologue && peek() != Token::STRING) { | 225 if (directive_prologue && peek() != Token::STRING) { |
226 directive_prologue = false; | 226 directive_prologue = false; |
227 } | 227 } |
228 bool starts_with_identifier = peek() == Token::IDENTIFIER; | 228 bool starts_with_identifier = peek() == Token::IDENTIFIER; |
229 Scanner::Location token_loc = scanner()->peek_location(); | 229 Scanner::Location token_loc = scanner()->peek_location(); |
230 Scanner::Location old_this_loc = function_state_->this_location(); | 230 Scanner::Location old_this_loc = function_state_->this_location(); |
231 Scanner::Location old_super_loc = function_state_->super_location(); | 231 Scanner::Location old_super_loc = function_state_->super_location(); |
232 Statement statement = ParseStatementListItem(ok); | 232 Statement statement = ParseStatementListItem(ok); |
233 if (!*ok) return; | 233 if (!*ok) return; |
234 | 234 |
235 if (is_strong(language_mode()) && scope_->is_function_scope() && | 235 if (is_strong(language_mode()) && |
236 IsClassConstructor(function_state_->kind())) { | 236 scope_->is_function_scope() && |
| 237 i::IsConstructor(function_state_->kind())) { |
237 Scanner::Location this_loc = function_state_->this_location(); | 238 Scanner::Location this_loc = function_state_->this_location(); |
238 Scanner::Location super_loc = function_state_->super_location(); | 239 Scanner::Location super_loc = function_state_->super_location(); |
239 if (this_loc.beg_pos != old_this_loc.beg_pos && | 240 if (this_loc.beg_pos != old_this_loc.beg_pos && |
240 this_loc.beg_pos != token_loc.beg_pos) { | 241 this_loc.beg_pos != token_loc.beg_pos) { |
241 ReportMessageAt(this_loc, MessageTemplate::kStrongConstructorThis); | 242 ReportMessageAt(this_loc, MessageTemplate::kStrongConstructorThis); |
242 *ok = false; | 243 *ok = false; |
243 return; | 244 return; |
244 } | 245 } |
245 if (super_loc.beg_pos != old_super_loc.beg_pos && | 246 if (super_loc.beg_pos != old_super_loc.beg_pos && |
246 super_loc.beg_pos != token_loc.beg_pos) { | 247 super_loc.beg_pos != token_loc.beg_pos) { |
247 ReportMessageAt(super_loc, MessageTemplate::kStrongConstructorSuper); | 248 ReportMessageAt(super_loc, MessageTemplate::kStrongConstructorSuper); |
248 *ok = false; | 249 *ok = false; |
249 return; | 250 return; |
250 } | 251 } |
251 } | 252 } |
252 | 253 |
253 if (directive_prologue) { | 254 if (directive_prologue) { |
254 bool use_strict_found = statement.IsUseStrictLiteral(); | 255 bool use_strict_found = statement.IsUseStrictLiteral(); |
255 bool use_strong_found = | 256 bool use_strong_found = |
256 statement.IsUseStrongLiteral() && allow_strong_mode(); | 257 statement.IsUseStrongLiteral() && allow_strong_mode(); |
257 | 258 |
258 if (use_strict_found) { | 259 if (use_strict_found) { |
259 scope_->SetLanguageMode( | 260 scope_->SetLanguageMode( |
260 static_cast<LanguageMode>(scope_->language_mode() | STRICT)); | 261 static_cast<LanguageMode>(scope_->language_mode() | STRICT)); |
261 } else if (use_strong_found) { | 262 } else if (use_strong_found) { |
262 scope_->SetLanguageMode(static_cast<LanguageMode>( | 263 scope_->SetLanguageMode(static_cast<LanguageMode>( |
263 scope_->language_mode() | STRONG)); | 264 scope_->language_mode() | STRONG)); |
264 if (IsClassConstructor(function_state_->kind())) { | 265 if (i::IsConstructor(function_state_->kind())) { |
265 // "use strong" cannot occur in a class constructor body, to avoid | 266 // "use strong" cannot occur in a class constructor body, to avoid |
266 // unintuitive strong class object semantics. | 267 // unintuitive strong class object semantics. |
267 PreParserTraits::ReportMessageAt( | 268 PreParserTraits::ReportMessageAt( |
268 token_loc, MessageTemplate::kStrongConstructorDirective); | 269 token_loc, MessageTemplate::kStrongConstructorDirective); |
269 *ok = false; | 270 *ok = false; |
270 return; | 271 return; |
271 } | 272 } |
272 } else if (!statement.IsStringLiteral()) { | 273 } else if (!statement.IsStringLiteral()) { |
273 directive_prologue = false; | 274 directive_prologue = false; |
274 } | 275 } |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 case Token::CLASS: | 632 case Token::CLASS: |
632 ReportUnexpectedToken(Next()); | 633 ReportUnexpectedToken(Next()); |
633 *ok = false; | 634 *ok = false; |
634 return Statement::Default(); | 635 return Statement::Default(); |
635 | 636 |
636 case Token::THIS: | 637 case Token::THIS: |
637 if (!FLAG_strong_this) break; | 638 if (!FLAG_strong_this) break; |
638 // Fall through. | 639 // Fall through. |
639 case Token::SUPER: | 640 case Token::SUPER: |
640 if (is_strong(language_mode()) && | 641 if (is_strong(language_mode()) && |
641 IsClassConstructor(function_state_->kind())) { | 642 i::IsConstructor(function_state_->kind())) { |
642 bool is_this = peek() == Token::THIS; | 643 bool is_this = peek() == Token::THIS; |
643 Expression expr = Expression::Default(); | 644 Expression expr = Expression::Default(); |
644 ExpressionClassifier classifier; | 645 ExpressionClassifier classifier; |
645 if (is_this) { | 646 if (is_this) { |
646 expr = ParseStrongInitializationExpression(&classifier, CHECK_OK); | 647 expr = ParseStrongInitializationExpression(&classifier, CHECK_OK); |
647 } else { | 648 } else { |
648 expr = ParseStrongSuperCallExpression(&classifier, CHECK_OK); | 649 expr = ParseStrongSuperCallExpression(&classifier, CHECK_OK); |
649 } | 650 } |
650 ValidateExpression(&classifier, CHECK_OK); | 651 ValidateExpression(&classifier, CHECK_OK); |
651 switch (peek()) { | 652 switch (peek()) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 // contains a return statement that is not within the body of a | 783 // contains a return statement that is not within the body of a |
783 // function. See ECMA-262, section 12.9, page 67. | 784 // function. See ECMA-262, section 12.9, page 67. |
784 // This is not handled during preparsing. | 785 // This is not handled during preparsing. |
785 | 786 |
786 Token::Value tok = peek(); | 787 Token::Value tok = peek(); |
787 if (!scanner()->HasAnyLineTerminatorBeforeNext() && | 788 if (!scanner()->HasAnyLineTerminatorBeforeNext() && |
788 tok != Token::SEMICOLON && | 789 tok != Token::SEMICOLON && |
789 tok != Token::RBRACE && | 790 tok != Token::RBRACE && |
790 tok != Token::EOS) { | 791 tok != Token::EOS) { |
791 if (is_strong(language_mode()) && | 792 if (is_strong(language_mode()) && |
792 IsClassConstructor(function_state_->kind())) { | 793 i::IsConstructor(function_state_->kind())) { |
793 int pos = peek_position(); | 794 int pos = peek_position(); |
794 ReportMessageAt(Scanner::Location(pos, pos + 1), | 795 ReportMessageAt(Scanner::Location(pos, pos + 1), |
795 MessageTemplate::kStrongConstructorReturnValue); | 796 MessageTemplate::kStrongConstructorReturnValue); |
796 *ok = false; | 797 *ok = false; |
797 return Statement::Default(); | 798 return Statement::Default(); |
798 } | 799 } |
799 ParseExpression(true, CHECK_OK); | 800 ParseExpression(true, CHECK_OK); |
800 } | 801 } |
801 ExpectSemicolon(CHECK_OK); | 802 ExpectSemicolon(CHECK_OK); |
802 return Statement::Jump(); | 803 return Statement::Jump(); |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 | 1232 |
1232 DCHECK(!spread_pos.IsValid()); | 1233 DCHECK(!spread_pos.IsValid()); |
1233 | 1234 |
1234 return Expression::Default(); | 1235 return Expression::Default(); |
1235 } | 1236 } |
1236 | 1237 |
1237 #undef CHECK_OK | 1238 #undef CHECK_OK |
1238 | 1239 |
1239 | 1240 |
1240 } } // v8::internal | 1241 } } // v8::internal |
OLD | NEW |