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

Side by Side Diff: pkg/compiler/lib/src/ssa/loop_handler.dart

Issue 2637483002: Implement switch statement, without the "complex switch statement" (aka switch statement with conti… (Closed)
Patch Set: . Created 3 years, 11 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 6
7 import '../elements/elements.dart' show JumpTarget, LabelDefinition; 7 import '../elements/elements.dart' show JumpTarget, LabelDefinition;
8 import '../io/source_information.dart'; 8 import '../io/source_information.dart';
9 import '../tree/tree.dart' as ast; 9 import '../tree/tree.dart' as ast;
10 10
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 class KernelLoopHandler extends LoopHandler<ir.TreeNode> { 353 class KernelLoopHandler extends LoopHandler<ir.TreeNode> {
354 final KernelSsaBuilder builder; 354 final KernelSsaBuilder builder;
355 355
356 KernelAstAdapter get astAdapter => builder.astAdapter; 356 KernelAstAdapter get astAdapter => builder.astAdapter;
357 357
358 KernelLoopHandler(KernelSsaBuilder builder) 358 KernelLoopHandler(KernelSsaBuilder builder)
359 : this.builder = builder, 359 : this.builder = builder,
360 super(builder); 360 super(builder);
361 361
362 @override 362 @override
363 JumpHandler createJumpHandler(ir.TreeNode node, {bool isLoopJump}) { 363 JumpHandler createJumpHandler(ir.TreeNode node, {bool isLoopJump}) =>
364 if (node.parent is! ir.LabeledStatement) { 364 builder.createJumpHandler(node, isLoopJump: isLoopJump);
365 // No breaks or continues to this node.
366 return new NullJumpHandler(builder.compiler.reporter);
367 }
368 // We must have already created a JumpHandler for the labeled statement
369 JumpHandler result =
370 builder.jumpTargets[astAdapter.getJumpTarget(node.parent)];
371 assert(result != null);
372 return result;
373 }
374 365
375 @override 366 @override
376 ast.Node getNode(ir.TreeNode node) => astAdapter.getNode(node); 367 ast.Node getNode(ir.TreeNode node) => astAdapter.getNode(node);
377 368
378 @override 369 @override
379 JumpTarget getTargetDefinition(ir.TreeNode node) { 370 JumpTarget getTargetDefinition(ir.TreeNode node) =>
380 if (node.parent is ir.LabeledStatement) { 371 astAdapter.getJumpTarget(node.parent);
381 return astAdapter.getJumpTarget(node.parent);
382 }
383 return null;
384 }
385 372
386 @override 373 @override
387 int loopKind(ir.TreeNode node) => node.accept(new _KernelLoopTypeVisitor()); 374 int loopKind(ir.TreeNode node) => node.accept(new _KernelLoopTypeVisitor());
388 375
389 // TODO(het): return the actual source information 376 // TODO(het): return the actual source information
390 @override 377 @override
391 SourceInformation loopSourceInformation(ir.TreeNode node) => null; 378 SourceInformation loopSourceInformation(ir.TreeNode node) => null;
392 } 379 }
393 380
394 class _KernelLoopTypeVisitor extends ir.Visitor<int> { 381 class _KernelLoopTypeVisitor extends ir.Visitor<int> {
(...skipping 12 matching lines...) Expand all
407 HLoopBlockInformation.DO_WHILE_LOOP; 394 HLoopBlockInformation.DO_WHILE_LOOP;
408 395
409 @override 396 @override
410 int visitForInStatement(ir.ForInStatement node) => 397 int visitForInStatement(ir.ForInStatement node) =>
411 HLoopBlockInformation.FOR_IN_LOOP; 398 HLoopBlockInformation.FOR_IN_LOOP;
412 399
413 @override 400 @override
414 int visitSwitchStatement(ir.SwitchStatement node) => 401 int visitSwitchStatement(ir.SwitchStatement node) =>
415 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; 402 HLoopBlockInformation.SWITCH_CONTINUE_LOOP;
416 } 403 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart ('k') | pkg/compiler/lib/src/ssa/switch_continue_analysis.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698