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-visitor.h" | 9 #include "src/ast/ast-expression-visitor.h" |
10 #include "src/ast/ast-literal-reindexer.h" | 10 #include "src/ast/ast-literal-reindexer.h" |
(...skipping 4732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4743 proxy, CONST, block_scope, pos, is_class_declaration, | 4743 proxy, CONST, block_scope, pos, is_class_declaration, |
4744 scope_->class_declaration_group_start()); | 4744 scope_->class_declaration_group_start()); |
4745 Declare(declaration, DeclarationDescriptor::NORMAL, true, CHECK_OK); | 4745 Declare(declaration, DeclarationDescriptor::NORMAL, true, CHECK_OK); |
4746 } | 4746 } |
4747 | 4747 |
4748 Expression* extends = NULL; | 4748 Expression* extends = NULL; |
4749 if (Check(Token::EXTENDS)) { | 4749 if (Check(Token::EXTENDS)) { |
4750 block_scope->set_start_position(scanner()->location().end_pos); | 4750 block_scope->set_start_position(scanner()->location().end_pos); |
4751 ExpressionClassifier classifier; | 4751 ExpressionClassifier classifier; |
4752 extends = ParseLeftHandSideExpression(&classifier, CHECK_OK); | 4752 extends = ParseLeftHandSideExpression(&classifier, CHECK_OK); |
4753 extends = ParserTraits::RewriteExpression(extends, &classifier, CHECK_OK); | 4753 extends = ParserTraits::RewriteNonPattern(extends, &classifier, CHECK_OK); |
4754 } else { | 4754 } else { |
4755 block_scope->set_start_position(scanner()->location().end_pos); | 4755 block_scope->set_start_position(scanner()->location().end_pos); |
4756 } | 4756 } |
4757 | 4757 |
4758 | 4758 |
4759 ClassLiteralChecker checker(this); | 4759 ClassLiteralChecker checker(this); |
4760 ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4, zone()); | 4760 ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4, zone()); |
4761 FunctionLiteral* constructor = NULL; | 4761 FunctionLiteral* constructor = NULL; |
4762 bool has_seen_constructor = false; | 4762 bool has_seen_constructor = false; |
4763 | 4763 |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5385 SetLanguageMode(scope_, | 5385 SetLanguageMode(scope_, |
5386 static_cast<LanguageMode>(scope_->language_mode() | mode)); | 5386 static_cast<LanguageMode>(scope_->language_mode() | mode)); |
5387 } | 5387 } |
5388 | 5388 |
5389 | 5389 |
5390 void ParserTraits::RewriteDestructuringAssignments() { | 5390 void ParserTraits::RewriteDestructuringAssignments() { |
5391 parser_->RewriteDestructuringAssignments(); | 5391 parser_->RewriteDestructuringAssignments(); |
5392 } | 5392 } |
5393 | 5393 |
5394 | 5394 |
5395 Expression* ParserTraits::RewriteExpression( | 5395 Expression* ParserTraits::RewriteNonPattern( |
5396 Expression* expr, const ExpressionClassifier* classifier, bool* ok) { | 5396 Expression* expr, const ExpressionClassifier* classifier, bool* ok) { |
5397 return parser_->RewriteExpression(expr, classifier, ok); | 5397 return parser_->RewriteNonPattern(expr, classifier, ok); |
5398 } | 5398 } |
5399 | 5399 |
5400 | 5400 |
5401 ObjectLiteralProperty* ParserTraits::RewriteObjectLiteralProperty( | 5401 ObjectLiteralProperty* ParserTraits::RewriteObjectLiteralProperty( |
5402 ObjectLiteralProperty* property, const ExpressionClassifier* classifier, | 5402 ObjectLiteralProperty* property, const ExpressionClassifier* classifier, |
5403 bool* ok) { | 5403 bool* ok) { |
5404 return parser_->RewriteObjectLiteralProperty(property, classifier, ok); | 5404 return parser_->RewriteObjectLiteralProperty(property, classifier, ok); |
5405 } | 5405 } |
5406 | 5406 |
5407 | 5407 |
5408 Expression* Parser::RewriteExpression(Expression* expr, | 5408 Expression* Parser::RewriteNonPattern(Expression* expr, |
5409 const ExpressionClassifier* classifier, | 5409 const ExpressionClassifier* classifier, |
5410 bool* ok) { | 5410 bool* ok) { |
5411 // For the time being, this does no rewriting at all. | 5411 // For the time being, this does no rewriting at all. |
5412 ValidateExpression(classifier, ok); | 5412 ValidateExpression(classifier, ok); |
5413 return expr; | 5413 return expr; |
5414 } | 5414 } |
5415 | 5415 |
5416 | 5416 |
5417 ObjectLiteralProperty* Parser::RewriteObjectLiteralProperty( | 5417 ObjectLiteralProperty* Parser::RewriteObjectLiteralProperty( |
5418 ObjectLiteralProperty* property, const ExpressionClassifier* classifier, | 5418 ObjectLiteralProperty* property, const ExpressionClassifier* classifier, |
5419 bool* ok) { | 5419 bool* ok) { |
5420 if (property != nullptr) { | 5420 if (property != nullptr) { |
5421 Expression* key = RewriteExpression(property->key(), classifier, ok); | 5421 Expression* key = RewriteNonPattern(property->key(), classifier, ok); |
5422 property->set_key(key); | 5422 property->set_key(key); |
5423 Expression* value = RewriteExpression(property->value(), classifier, ok); | 5423 Expression* value = RewriteNonPattern(property->value(), classifier, ok); |
5424 property->set_value(value); | 5424 property->set_value(value); |
5425 } | 5425 } |
5426 return property; | 5426 return property; |
5427 } | 5427 } |
5428 | 5428 |
5429 | 5429 |
5430 void Parser::RewriteDestructuringAssignments() { | 5430 void Parser::RewriteDestructuringAssignments() { |
5431 FunctionState* func = function_state_; | 5431 FunctionState* func = function_state_; |
5432 if (!allow_harmony_destructuring_assignment()) return; | 5432 if (!allow_harmony_destructuring_assignment()) return; |
5433 const List<DestructuringAssignment>& assignments = | 5433 const List<DestructuringAssignment>& assignments = |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5487 auto class_literal = value->AsClassLiteral(); | 5487 auto class_literal = value->AsClassLiteral(); |
5488 if (class_literal->raw_name() == nullptr) { | 5488 if (class_literal->raw_name() == nullptr) { |
5489 class_literal->set_raw_name(name); | 5489 class_literal->set_raw_name(name); |
5490 } | 5490 } |
5491 } | 5491 } |
5492 } | 5492 } |
5493 | 5493 |
5494 | 5494 |
5495 } // namespace internal | 5495 } // namespace internal |
5496 } // namespace v8 | 5496 } // namespace v8 |
OLD | NEW |