| 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); |  | 
|  4899  |  4898  | 
|  4900   DCHECK(!spread_pos.IsValid()); |  4899   DCHECK(!spread_pos.IsValid()); | 
|  4901  |  4900  | 
|  4902   if (extension_ != NULL) { |  4901   if (extension_ != NULL) { | 
|  4903     // The extension structures are only accessible while parsing the |  4902     // The extension structures are only accessible while parsing the | 
|  4904     // very first time not when reparsing because of lazy compilation. |  4903     // very first time not when reparsing because of lazy compilation. | 
|  4905     scope_->DeclarationScope()->ForceEagerCompilation(); |  4904     scope_->DeclarationScope()->ForceEagerCompilation(); | 
|  4906   } |  4905   } | 
|  4907  |  4906  | 
|  4908   const Runtime::Function* function = Runtime::FunctionForName(name->string()); |  4907   const Runtime::Function* function = Runtime::FunctionForName(name->string()); | 
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  5457   parser_->RewriteDestructuringAssignments(); |  5456   parser_->RewriteDestructuringAssignments(); | 
|  5458 } |  5457 } | 
|  5459  |  5458  | 
|  5460  |  5459  | 
|  5461 Expression* ParserTraits::RewriteNonPattern( |  5460 Expression* ParserTraits::RewriteNonPattern( | 
|  5462     Expression* expr, const ExpressionClassifier* classifier, bool* ok) { |  5461     Expression* expr, const ExpressionClassifier* classifier, bool* ok) { | 
|  5463   return parser_->RewriteNonPattern(expr, classifier, ok); |  5462   return parser_->RewriteNonPattern(expr, classifier, ok); | 
|  5464 } |  5463 } | 
|  5465  |  5464  | 
|  5466  |  5465  | 
|  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( |  5466 ObjectLiteralProperty* ParserTraits::RewriteNonPatternObjectLiteralProperty( | 
|  5475     ObjectLiteralProperty* property, const ExpressionClassifier* classifier, |  5467     ObjectLiteralProperty* property, const ExpressionClassifier* classifier, | 
|  5476     bool* ok) { |  5468     bool* ok) { | 
|  5477   return parser_->RewriteNonPatternObjectLiteralProperty(property, classifier, |  5469   return parser_->RewriteNonPatternObjectLiteralProperty(property, classifier, | 
|  5478                                                          ok); |  5470                                                          ok); | 
|  5479 } |  5471 } | 
|  5480  |  5472  | 
|  5481  |  5473  | 
|  5482 class NonPatternRewriter : public AstExpressionRewriter { |  5474 class NonPatternRewriter : public AstExpressionRewriter { | 
|  5483  public: |  5475  public: | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  5515                                       bool* ok) { |  5507                                       bool* ok) { | 
|  5516   ValidateExpression(classifier, ok); |  5508   ValidateExpression(classifier, ok); | 
|  5517   if (!*ok) return expr; |  5509   if (!*ok) return expr; | 
|  5518   NonPatternRewriter rewriter(stack_limit_, this); |  5510   NonPatternRewriter rewriter(stack_limit_, this); | 
|  5519   Expression* result = reinterpret_cast<Expression*>(rewriter.Rewrite(expr)); |  5511   Expression* result = reinterpret_cast<Expression*>(rewriter.Rewrite(expr)); | 
|  5520   DCHECK_NOT_NULL(result); |  5512   DCHECK_NOT_NULL(result); | 
|  5521   return result; |  5513   return result; | 
|  5522 } |  5514 } | 
|  5523  |  5515  | 
|  5524  |  5516  | 
|  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( |  5517 ObjectLiteralProperty* Parser::RewriteNonPatternObjectLiteralProperty( | 
|  5542     ObjectLiteralProperty* property, const ExpressionClassifier* classifier, |  5518     ObjectLiteralProperty* property, const ExpressionClassifier* classifier, | 
|  5543     bool* ok) { |  5519     bool* ok) { | 
|  5544   if (property != nullptr) { |  5520   if (property != nullptr) { | 
|  5545     Expression* key = RewriteNonPattern(property->key(), classifier, ok); |  5521     Expression* key = RewriteNonPattern(property->key(), classifier, ok); | 
|  5546     property->set_key(key); |  5522     property->set_key(key); | 
|  5547     Expression* value = RewriteNonPattern(property->value(), classifier, ok); |  5523     Expression* value = RewriteNonPattern(property->value(), classifier, ok); | 
|  5548     property->set_value(value); |  5524     property->set_value(value); | 
|  5549   } |  5525   } | 
|  5550   return property; |  5526   return property; | 
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  5753     auto class_literal = value->AsClassLiteral(); |  5729     auto class_literal = value->AsClassLiteral(); | 
|  5754     if (class_literal->raw_name() == nullptr) { |  5730     if (class_literal->raw_name() == nullptr) { | 
|  5755       class_literal->set_raw_name(name); |  5731       class_literal->set_raw_name(name); | 
|  5756     } |  5732     } | 
|  5757   } |  5733   } | 
|  5758 } |  5734 } | 
|  5759  |  5735  | 
|  5760  |  5736  | 
|  5761 }  // namespace internal |  5737 }  // namespace internal | 
|  5762 }  // namespace v8 |  5738 }  // namespace v8 | 
| OLD | NEW |