| 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 5543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5554 return true; | 5554 return true; |
| 5555 } | 5555 } |
| 5556 if (expr->IsBinaryOperation() && | 5556 if (expr->IsBinaryOperation() && |
| 5557 expr->AsBinaryOperation()->op() == Token::COMMA) { | 5557 expr->AsBinaryOperation()->op() == Token::COMMA) { |
| 5558 return true; | 5558 return true; |
| 5559 } | 5559 } |
| 5560 // Everything else does not need rewriting. | 5560 // Everything else does not need rewriting. |
| 5561 return false; | 5561 return false; |
| 5562 } | 5562 } |
| 5563 | 5563 |
| 5564 void VisitObjectLiteralProperty(ObjectLiteralProperty* property) override { |
| 5565 if (property == nullptr) return; |
| 5566 // Do not rewrite (computed) key expressions |
| 5567 AST_REWRITE_PROPERTY(Expression, property, value); |
| 5568 } |
| 5569 |
| 5564 Parser* parser_; | 5570 Parser* parser_; |
| 5565 }; | 5571 }; |
| 5566 | 5572 |
| 5567 | 5573 |
| 5568 Expression* Parser::RewriteNonPattern(Expression* expr, | 5574 Expression* Parser::RewriteNonPattern(Expression* expr, |
| 5569 const ExpressionClassifier* classifier, | 5575 const ExpressionClassifier* classifier, |
| 5570 bool* ok) { | 5576 bool* ok) { |
| 5571 ValidateExpression(classifier, ok); | 5577 ValidateExpression(classifier, ok); |
| 5572 if (!*ok) return expr; | 5578 if (!*ok) return expr; |
| 5573 NonPatternRewriter rewriter(stack_limit_, this); | 5579 NonPatternRewriter rewriter(stack_limit_, this); |
| 5574 Expression* result = reinterpret_cast<Expression*>(rewriter.Rewrite(expr)); | 5580 Expression* result = reinterpret_cast<Expression*>(rewriter.Rewrite(expr)); |
| 5575 DCHECK_NOT_NULL(result); | 5581 DCHECK_NOT_NULL(result); |
| 5576 return result; | 5582 return result; |
| 5577 } | 5583 } |
| 5578 | 5584 |
| 5579 | 5585 |
| 5580 ObjectLiteralProperty* Parser::RewriteNonPatternObjectLiteralProperty( | 5586 ObjectLiteralProperty* Parser::RewriteNonPatternObjectLiteralProperty( |
| 5581 ObjectLiteralProperty* property, const ExpressionClassifier* classifier, | 5587 ObjectLiteralProperty* property, const ExpressionClassifier* classifier, |
| 5582 bool* ok) { | 5588 bool* ok) { |
| 5583 if (property != nullptr) { | 5589 if (property != nullptr) { |
| 5584 Expression* key = RewriteNonPattern(property->key(), classifier, ok); | 5590 // Do not rewrite (computed) key expressions |
| 5585 property->set_key(key); | |
| 5586 Expression* value = RewriteNonPattern(property->value(), classifier, ok); | 5591 Expression* value = RewriteNonPattern(property->value(), classifier, ok); |
| 5587 property->set_value(value); | 5592 property->set_value(value); |
| 5588 } | 5593 } |
| 5589 return property; | 5594 return property; |
| 5590 } | 5595 } |
| 5591 | 5596 |
| 5592 | 5597 |
| 5593 void Parser::RewriteDestructuringAssignments() { | 5598 void Parser::RewriteDestructuringAssignments() { |
| 5594 FunctionState* func = function_state_; | 5599 FunctionState* func = function_state_; |
| 5595 if (!allow_harmony_destructuring_assignment()) return; | 5600 if (!allow_harmony_destructuring_assignment()) return; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5792 auto class_literal = value->AsClassLiteral(); | 5797 auto class_literal = value->AsClassLiteral(); |
| 5793 if (class_literal->raw_name() == nullptr) { | 5798 if (class_literal->raw_name() == nullptr) { |
| 5794 class_literal->set_raw_name(name); | 5799 class_literal->set_raw_name(name); |
| 5795 } | 5800 } |
| 5796 } | 5801 } |
| 5797 } | 5802 } |
| 5798 | 5803 |
| 5799 | 5804 |
| 5800 } // namespace internal | 5805 } // namespace internal |
| 5801 } // namespace v8 | 5806 } // namespace v8 |
| OLD | NEW |