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

Side by Side Diff: pkg/analyzer2dart/lib/src/cps_generator.dart

Issue 662363002: Support if-statements in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer2dart.cps_generator; 5 library analyzer2dart.cps_generator;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 8
9 import 'package:compiler/implementation/elements/elements.dart' as dart2js; 9 import 'package:compiler/implementation/elements/elements.dart' as dart2js;
10 import 'package:analyzer/src/generated/source.dart'; 10 import 'package:analyzer/src/generated/source.dart';
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 switch (op) { 214 switch (op) {
215 case '||': 215 case '||':
216 case '&&': 216 case '&&':
217 return handleLazyOperator(node, isLazyOr: op == '||'); 217 return handleLazyOperator(node, isLazyOr: op == '||');
218 case '!=': 218 case '!=':
219 return irBuilder.buildNegation(handleBinaryExpression(node, '==')); 219 return irBuilder.buildNegation(handleBinaryExpression(node, '=='));
220 default: 220 default:
221 return handleBinaryExpression(node, op); 221 return handleBinaryExpression(node, op);
222 } 222 }
223 } 223 }
224
225 @override
226 visitIfStatement(IfStatement node) {
227 ir.Primitive condition = node.condition.accept(this);
228
229 void buildThenPart(IrBuilder thenBuilder) {
230 withBuilder(thenBuilder, () => node.thenStatement.accept(this));
231 }
232
233 void buildElsePart(IrBuilder elseBuilder) {
234 if (node.elseStatement != null) {
235 withBuilder(elseBuilder, () => node.elseStatement.accept(this));
236 }
237 }
238
239 irBuilder.buildIf(condition, buildThenPart, buildElsePart);
240 }
224 } 241 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698