Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(907)

Side by Side Diff: src/parsing/pattern-rewriter.cc

Issue 1657783002: Gracefully handle syntax errors in Parser::PatternRewriter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Unit test. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parsing/parser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/ast/ast.h" 5 #include "src/ast/ast.h"
6 #include "src/messages.h" 6 #include "src/messages.h"
7 #include "src/parsing/parameter-initializer-rewriter.h" 7 #include "src/parsing/parameter-initializer-rewriter.h"
8 #include "src/parsing/parser.h" 8 #include "src/parsing/parser.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 rewriter.parser_ = parser; 43 rewriter.parser_ = parser;
44 rewriter.context_ = ASSIGNMENT; 44 rewriter.context_ = ASSIGNMENT;
45 rewriter.pattern_ = to_rewrite; 45 rewriter.pattern_ = to_rewrite;
46 rewriter.block_ = nullptr; 46 rewriter.block_ = nullptr;
47 rewriter.descriptor_ = nullptr; 47 rewriter.descriptor_ = nullptr;
48 rewriter.names_ = nullptr; 48 rewriter.names_ = nullptr;
49 rewriter.ok_ = &ok; 49 rewriter.ok_ = &ok;
50 rewriter.recursion_level_ = 0; 50 rewriter.recursion_level_ = 0;
51 51
52 rewriter.RecurseIntoSubpattern(rewriter.pattern_, nullptr); 52 rewriter.RecurseIntoSubpattern(rewriter.pattern_, nullptr);
53 DCHECK(ok); 53 CHECK(ok);
54 } 54 }
55 55
56 56
57 Expression* Parser::PatternRewriter::RewriteDestructuringAssignment( 57 Expression* Parser::PatternRewriter::RewriteDestructuringAssignment(
58 Parser* parser, Assignment* assignment, Scope* scope) { 58 Parser* parser, Assignment* assignment, Scope* scope) {
59 DCHECK_NOT_NULL(assignment); 59 DCHECK_NOT_NULL(assignment);
60 DCHECK_EQ(Token::ASSIGN, assignment->op()); 60 DCHECK_EQ(Token::ASSIGN, assignment->op());
61 auto to_rewrite = 61 auto to_rewrite =
62 parser->factory()->NewRewritableAssignmentExpression(assignment); 62 parser->factory()->NewRewritableAssignmentExpression(assignment);
63 RewriteDestructuringAssignment(parser, to_rewrite, scope); 63 RewriteDestructuringAssignment(parser, to_rewrite, scope);
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 zone()); 568 zone());
569 } 569 }
570 570
571 571
572 // =============== UNREACHABLE ============================= 572 // =============== UNREACHABLE =============================
573 573
574 void Parser::PatternRewriter::Visit(AstNode* node) { UNREACHABLE(); } 574 void Parser::PatternRewriter::Visit(AstNode* node) { UNREACHABLE(); }
575 575
576 #define NOT_A_PATTERN(Node) \ 576 #define NOT_A_PATTERN(Node) \
577 void Parser::PatternRewriter::Visit##Node(v8::internal::Node*) { \ 577 void Parser::PatternRewriter::Visit##Node(v8::internal::Node*) { \
578 UNREACHABLE(); \ 578 parser_->ReportMessage(MessageTemplate::kUnsupported); \
579 *ok_ = false; \
579 } 580 }
580 581
581 NOT_A_PATTERN(BinaryOperation) 582 NOT_A_PATTERN(BinaryOperation)
582 NOT_A_PATTERN(Block) 583 NOT_A_PATTERN(Block)
583 NOT_A_PATTERN(BreakStatement) 584 NOT_A_PATTERN(BreakStatement)
584 NOT_A_PATTERN(Call) 585 NOT_A_PATTERN(Call)
585 NOT_A_PATTERN(CallNew) 586 NOT_A_PATTERN(CallNew)
586 NOT_A_PATTERN(CallRuntime) 587 NOT_A_PATTERN(CallRuntime)
587 NOT_A_PATTERN(CaseClause) 588 NOT_A_PATTERN(CaseClause)
588 NOT_A_PATTERN(ClassLiteral) 589 NOT_A_PATTERN(ClassLiteral)
(...skipping 30 matching lines...) Expand all
619 NOT_A_PATTERN(TryFinallyStatement) 620 NOT_A_PATTERN(TryFinallyStatement)
620 NOT_A_PATTERN(UnaryOperation) 621 NOT_A_PATTERN(UnaryOperation)
621 NOT_A_PATTERN(VariableDeclaration) 622 NOT_A_PATTERN(VariableDeclaration)
622 NOT_A_PATTERN(WhileStatement) 623 NOT_A_PATTERN(WhileStatement)
623 NOT_A_PATTERN(WithStatement) 624 NOT_A_PATTERN(WithStatement)
624 NOT_A_PATTERN(Yield) 625 NOT_A_PATTERN(Yield)
625 626
626 #undef NOT_A_PATTERN 627 #undef NOT_A_PATTERN
627 } // namespace internal 628 } // namespace internal
628 } // namespace v8 629 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698