Chromium Code Reviews| 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 #include "src/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/ast/ast-expression-rewriter.h" | 9 #include "src/ast/ast-expression-rewriter.h" |
| 10 #include "src/ast/ast-expression-visitor.h" | 10 #include "src/ast/ast-expression-visitor.h" |
| (...skipping 4877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4888 | 4888 |
| 4889 int pos = peek_position(); | 4889 int pos = peek_position(); |
| 4890 Expect(Token::MOD, CHECK_OK); | 4890 Expect(Token::MOD, CHECK_OK); |
| 4891 // Allow "eval" or "arguments" for backward compatibility. | 4891 // Allow "eval" or "arguments" for backward compatibility. |
| 4892 const AstRawString* name = ParseIdentifier(kAllowRestrictedIdentifiers, | 4892 const AstRawString* name = ParseIdentifier(kAllowRestrictedIdentifiers, |
| 4893 CHECK_OK); | 4893 CHECK_OK); |
| 4894 Scanner::Location spread_pos; | 4894 Scanner::Location spread_pos; |
| 4895 ExpressionClassifier classifier; | 4895 ExpressionClassifier classifier; |
| 4896 ZoneList<Expression*>* args = | 4896 ZoneList<Expression*>* args = |
| 4897 ParseArguments(&spread_pos, &classifier, CHECK_OK); | 4897 ParseArguments(&spread_pos, &classifier, CHECK_OK); |
| 4898 args = RewriteNonPatternArguments(args, &classifier, CHECK_OK); | 4898 ValidateExpression(&classifier, CHECK_OK); |
|
rossberg
2016/01/21 14:16:37
Hm, isn't this redundant as well? If the thing has
nickie
2016/01/21 14:29:25
Honestly, I don't know. This line was replaced wi
rossberg
2016/01/21 14:46:00
Let's remove it then it see. Having a dangling Val
nickie
2016/01/21 15:02:53
Acknowledged.
| |
| 4899 | 4899 |
| 4900 DCHECK(!spread_pos.IsValid()); | 4900 DCHECK(!spread_pos.IsValid()); |
| 4901 | 4901 |
| 4902 if (extension_ != NULL) { | 4902 if (extension_ != NULL) { |
| 4903 // The extension structures are only accessible while parsing the | 4903 // The extension structures are only accessible while parsing the |
| 4904 // very first time not when reparsing because of lazy compilation. | 4904 // very first time not when reparsing because of lazy compilation. |
| 4905 scope_->DeclarationScope()->ForceEagerCompilation(); | 4905 scope_->DeclarationScope()->ForceEagerCompilation(); |
| 4906 } | 4906 } |
| 4907 | 4907 |
| 4908 const Runtime::Function* function = Runtime::FunctionForName(name->string()); | 4908 const Runtime::Function* function = Runtime::FunctionForName(name->string()); |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5457 parser_->RewriteDestructuringAssignments(); | 5457 parser_->RewriteDestructuringAssignments(); |
| 5458 } | 5458 } |
| 5459 | 5459 |
| 5460 | 5460 |
| 5461 Expression* ParserTraits::RewriteNonPattern( | 5461 Expression* ParserTraits::RewriteNonPattern( |
| 5462 Expression* expr, const ExpressionClassifier* classifier, bool* ok) { | 5462 Expression* expr, const ExpressionClassifier* classifier, bool* ok) { |
| 5463 return parser_->RewriteNonPattern(expr, classifier, ok); | 5463 return parser_->RewriteNonPattern(expr, classifier, ok); |
| 5464 } | 5464 } |
| 5465 | 5465 |
| 5466 | 5466 |
| 5467 ZoneList<Expression*>* ParserTraits::RewriteNonPatternArguments( | |
| 5468 ZoneList<Expression*>* args, const ExpressionClassifier* classifier, | |
| 5469 bool* ok) { | |
| 5470 return parser_->RewriteNonPatternArguments(args, classifier, ok); | |
| 5471 } | |
| 5472 | |
| 5473 | |
| 5474 ObjectLiteralProperty* ParserTraits::RewriteNonPatternObjectLiteralProperty( | 5467 ObjectLiteralProperty* ParserTraits::RewriteNonPatternObjectLiteralProperty( |
| 5475 ObjectLiteralProperty* property, const ExpressionClassifier* classifier, | 5468 ObjectLiteralProperty* property, const ExpressionClassifier* classifier, |
| 5476 bool* ok) { | 5469 bool* ok) { |
| 5477 return parser_->RewriteNonPatternObjectLiteralProperty(property, classifier, | 5470 return parser_->RewriteNonPatternObjectLiteralProperty(property, classifier, |
| 5478 ok); | 5471 ok); |
| 5479 } | 5472 } |
| 5480 | 5473 |
| 5481 | 5474 |
| 5482 class NonPatternRewriter : public AstExpressionRewriter { | 5475 class NonPatternRewriter : public AstExpressionRewriter { |
| 5483 public: | 5476 public: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5515 bool* ok) { | 5508 bool* ok) { |
| 5516 ValidateExpression(classifier, ok); | 5509 ValidateExpression(classifier, ok); |
| 5517 if (!*ok) return expr; | 5510 if (!*ok) return expr; |
| 5518 NonPatternRewriter rewriter(stack_limit_, this); | 5511 NonPatternRewriter rewriter(stack_limit_, this); |
| 5519 Expression* result = reinterpret_cast<Expression*>(rewriter.Rewrite(expr)); | 5512 Expression* result = reinterpret_cast<Expression*>(rewriter.Rewrite(expr)); |
| 5520 DCHECK_NOT_NULL(result); | 5513 DCHECK_NOT_NULL(result); |
| 5521 return result; | 5514 return result; |
| 5522 } | 5515 } |
| 5523 | 5516 |
| 5524 | 5517 |
| 5525 ZoneList<Expression*>* Parser::RewriteNonPatternArguments( | |
| 5526 ZoneList<Expression*>* args, const ExpressionClassifier* classifier, | |
| 5527 bool* ok) { | |
| 5528 ValidateExpression(classifier, ok); | |
| 5529 if (!*ok) return args; | |
| 5530 for (int i = 0; i < args->length(); i++) { | |
| 5531 NonPatternRewriter rewriter(stack_limit_, this); | |
| 5532 Expression* result = | |
| 5533 reinterpret_cast<Expression*>(rewriter.Rewrite(args->at(i))); | |
| 5534 DCHECK_NOT_NULL(result); | |
| 5535 args->Set(i, result); | |
| 5536 } | |
| 5537 return args; | |
| 5538 } | |
| 5539 | |
| 5540 | |
| 5541 ObjectLiteralProperty* Parser::RewriteNonPatternObjectLiteralProperty( | 5518 ObjectLiteralProperty* Parser::RewriteNonPatternObjectLiteralProperty( |
| 5542 ObjectLiteralProperty* property, const ExpressionClassifier* classifier, | 5519 ObjectLiteralProperty* property, const ExpressionClassifier* classifier, |
| 5543 bool* ok) { | 5520 bool* ok) { |
| 5544 if (property != nullptr) { | 5521 if (property != nullptr) { |
| 5545 Expression* key = RewriteNonPattern(property->key(), classifier, ok); | 5522 Expression* key = RewriteNonPattern(property->key(), classifier, ok); |
| 5546 property->set_key(key); | 5523 property->set_key(key); |
| 5547 Expression* value = RewriteNonPattern(property->value(), classifier, ok); | 5524 Expression* value = RewriteNonPattern(property->value(), classifier, ok); |
| 5548 property->set_value(value); | 5525 property->set_value(value); |
| 5549 } | 5526 } |
| 5550 return property; | 5527 return property; |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5753 auto class_literal = value->AsClassLiteral(); | 5730 auto class_literal = value->AsClassLiteral(); |
| 5754 if (class_literal->raw_name() == nullptr) { | 5731 if (class_literal->raw_name() == nullptr) { |
| 5755 class_literal->set_raw_name(name); | 5732 class_literal->set_raw_name(name); |
| 5756 } | 5733 } |
| 5757 } | 5734 } |
| 5758 } | 5735 } |
| 5759 | 5736 |
| 5760 | 5737 |
| 5761 } // namespace internal | 5738 } // namespace internal |
| 5762 } // namespace v8 | 5739 } // namespace v8 |
| OLD | NEW |