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

Side by Side Diff: pkg/compiler/lib/src/kernel/kernel_visitor.dart

Issue 2360673003: kernel->ssa: Implement for-loops and while-loops (Closed)
Patch Set: Created 4 years, 3 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 | pkg/compiler/lib/src/ssa/builder.dart » ('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 (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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 import 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 import 'package:kernel/frontend/accessors.dart' 6 import 'package:kernel/frontend/accessors.dart'
7 show 7 show
8 Accessor, 8 Accessor,
9 IndexAccessor, 9 IndexAccessor,
10 NullAwarePropertyAccessor, 10 NullAwarePropertyAccessor,
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 } 767 }
768 ir.Expression condition = visitForValue(node.condition); 768 ir.Expression condition = visitForValue(node.condition);
769 List<ir.Expression> updates = <ir.Expression>[]; 769 List<ir.Expression> updates = <ir.Expression>[];
770 for (Expression update in node.update) { 770 for (Expression update in node.update) {
771 updates.add(visitForEffect(update)); 771 updates.add(visitForEffect(update));
772 } 772 }
773 773
774 JumpTarget jumpTarget = elements.getTargetDefinition(node); 774 JumpTarget jumpTarget = elements.getTargetDefinition(node);
775 ir.Statement body = 775 ir.Statement body =
776 buildContinueTarget(buildStatementInBlock(node.body), node, jumpTarget); 776 buildContinueTarget(buildStatementInBlock(node.body), node, jumpTarget);
777 ir.ForStatement forStatement = 777 ir.ForStatement forStatement = associateNode(
778 new ir.ForStatement(variables, condition, updates, body); 778 new ir.ForStatement(variables, condition, updates, body), node);
779 ir.Statement result = buildBreakTarget(forStatement, node, jumpTarget); 779 ir.Statement result = buildBreakTarget(forStatement, node, jumpTarget);
780 if (initializer != null) { 780 if (initializer != null) {
781 result = new ir.Block( 781 result = new ir.Block(
782 <ir.Statement>[new ir.ExpressionStatement(initializer), result]); 782 <ir.Statement>[new ir.ExpressionStatement(initializer), result]);
783 } 783 }
784 return result; 784 return result;
785 } 785 }
786 786
787 @override 787 @override
788 ir.FunctionDeclaration visitFunctionDeclaration(FunctionDeclaration node) { 788 ir.FunctionDeclaration visitFunctionDeclaration(FunctionDeclaration node) {
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 return internalError(node, "TypeVariable"); 1083 return internalError(node, "TypeVariable");
1084 } 1084 }
1085 1085
1086 @override 1086 @override
1087 ir.Statement visitWhile(While node) { 1087 ir.Statement visitWhile(While node) {
1088 ir.Expression condition = visitForValue(node.condition); 1088 ir.Expression condition = visitForValue(node.condition);
1089 JumpTarget jumpTarget = elements.getTargetDefinition(node); 1089 JumpTarget jumpTarget = elements.getTargetDefinition(node);
1090 ir.Statement body = 1090 ir.Statement body =
1091 buildContinueTarget(buildStatementInBlock(node.body), node, jumpTarget); 1091 buildContinueTarget(buildStatementInBlock(node.body), node, jumpTarget);
1092 return buildBreakTarget( 1092 return buildBreakTarget(
1093 new ir.WhileStatement(condition, body), node, jumpTarget); 1093 associateNode(new ir.WhileStatement(condition, body), node),
1094 node,
1095 jumpTarget);
1094 } 1096 }
1095 1097
1096 @override 1098 @override
1097 ir.YieldStatement visitYield(Yield node) { 1099 ir.YieldStatement visitYield(Yield node) {
1098 return new ir.YieldStatement(visitForValue(node.expression), 1100 return new ir.YieldStatement(visitForValue(node.expression),
1099 isYieldStar: node.hasStar); 1101 isYieldStar: node.hasStar);
1100 } 1102 }
1101 1103
1102 @override 1104 @override
1103 ir.InvalidExpression visitAbstractClassConstructorInvoke( 1105 ir.InvalidExpression visitAbstractClassConstructorInvoke(
(...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after
2756 : this(null, true, node, initializers); 2758 : this(null, true, node, initializers);
2757 2759
2758 accept(ir.Visitor v) => throw "unsupported"; 2760 accept(ir.Visitor v) => throw "unsupported";
2759 2761
2760 visitChildren(ir.Visitor v) => throw "unsupported"; 2762 visitChildren(ir.Visitor v) => throw "unsupported";
2761 2763
2762 String toString() { 2764 String toString() {
2763 return "IrFunction($kind, $isConstructor, $node, $initializers)"; 2765 return "IrFunction($kind, $isConstructor, $node, $initializers)";
2764 } 2766 }
2765 } 2767 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698