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

Side by Side Diff: src/ast-expression-visitor.cc

Issue 1316633002: Fix AstExpressionVisitor to correctly handle switch + for. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 5 years, 4 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 | « no previous file | test/cctest/test-ast-expression-visitor.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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/ast-expression-visitor.h" 7 #include "src/ast-expression-visitor.h"
8 8
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 105
106 106
107 void AstExpressionVisitor::VisitSwitchStatement(SwitchStatement* stmt) { 107 void AstExpressionVisitor::VisitSwitchStatement(SwitchStatement* stmt) {
108 RECURSE(Visit(stmt->tag())); 108 RECURSE(Visit(stmt->tag()));
109 109
110 ZoneList<CaseClause*>* clauses = stmt->cases(); 110 ZoneList<CaseClause*>* clauses = stmt->cases();
111 111
112 for (int i = 0; i < clauses->length(); ++i) { 112 for (int i = 0; i < clauses->length(); ++i) {
113 CaseClause* clause = clauses->at(i); 113 CaseClause* clause = clauses->at(i);
114 Expression* label = clause->label(); 114 if (!clause->is_default()) {
115 RECURSE(Visit(label)); 115 Expression* label = clause->label();
116 RECURSE(Visit(label));
117 }
116 ZoneList<Statement*>* stmts = clause->statements(); 118 ZoneList<Statement*>* stmts = clause->statements();
117 RECURSE(VisitStatements(stmts)); 119 RECURSE(VisitStatements(stmts));
118 } 120 }
119 } 121 }
120 122
121 123
122 void AstExpressionVisitor::VisitCaseClause(CaseClause* clause) { 124 void AstExpressionVisitor::VisitCaseClause(CaseClause* clause) {
123 UNREACHABLE(); 125 UNREACHABLE();
124 } 126 }
125 127
126 128
127 void AstExpressionVisitor::VisitDoWhileStatement(DoWhileStatement* stmt) { 129 void AstExpressionVisitor::VisitDoWhileStatement(DoWhileStatement* stmt) {
128 RECURSE(Visit(stmt->body())); 130 RECURSE(Visit(stmt->body()));
129 RECURSE(Visit(stmt->cond())); 131 RECURSE(Visit(stmt->cond()));
130 } 132 }
131 133
132 134
133 void AstExpressionVisitor::VisitWhileStatement(WhileStatement* stmt) { 135 void AstExpressionVisitor::VisitWhileStatement(WhileStatement* stmt) {
134 RECURSE(Visit(stmt->cond())); 136 RECURSE(Visit(stmt->cond()));
135 RECURSE(Visit(stmt->body())); 137 RECURSE(Visit(stmt->body()));
136 } 138 }
137 139
138 140
139 void AstExpressionVisitor::VisitForStatement(ForStatement* stmt) { 141 void AstExpressionVisitor::VisitForStatement(ForStatement* stmt) {
140 RECURSE(Visit(stmt->init())); 142 if (stmt->init() != NULL) {
141 RECURSE(Visit(stmt->cond())); 143 RECURSE(Visit(stmt->init()));
142 RECURSE(Visit(stmt->next())); 144 }
145 if (stmt->cond() != NULL) {
146 RECURSE(Visit(stmt->cond()));
147 }
148 if (stmt->next() != NULL) {
149 RECURSE(Visit(stmt->next()));
150 }
143 RECURSE(Visit(stmt->body())); 151 RECURSE(Visit(stmt->body()));
144 } 152 }
145 153
146 154
147 void AstExpressionVisitor::VisitForInStatement(ForInStatement* stmt) { 155 void AstExpressionVisitor::VisitForInStatement(ForInStatement* stmt) {
148 RECURSE(Visit(stmt->enumerable())); 156 RECURSE(Visit(stmt->enumerable()));
149 RECURSE(Visit(stmt->body())); 157 RECURSE(Visit(stmt->body()));
150 } 158 }
151 159
152 160
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 336
329 void AstExpressionVisitor::VisitSuperPropertyReference( 337 void AstExpressionVisitor::VisitSuperPropertyReference(
330 SuperPropertyReference* expr) {} 338 SuperPropertyReference* expr) {}
331 339
332 340
333 void AstExpressionVisitor::VisitSuperCallReference(SuperCallReference* expr) {} 341 void AstExpressionVisitor::VisitSuperCallReference(SuperCallReference* expr) {}
334 } 342 }
335 343
336 344
337 } // namespace v8::internal 345 } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-ast-expression-visitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698