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

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

Issue 2647043002: Fix hints reported by analyzer. (Closed)
Patch Set: Address review comments. 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.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 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 for (Link<Node> link = node.cases.nodes; 1025 for (Link<Node> link = node.cases.nodes;
1026 link.isNotEmpty; 1026 link.isNotEmpty;
1027 link = link.tail) { 1027 link = link.tail) {
1028 SwitchCase caseNode = link.head; 1028 SwitchCase caseNode = link.head;
1029 bool isLastCase = link.tail.isEmpty; 1029 bool isLastCase = link.tail.isEmpty;
1030 if (!casesIterator.moveNext()) { 1030 if (!casesIterator.moveNext()) {
1031 internalError(caseNode, "case node mismatch"); 1031 internalError(caseNode, "case node mismatch");
1032 } 1032 }
1033 ir.SwitchCase irCase = casesIterator.current; 1033 ir.SwitchCase irCase = casesIterator.current;
1034 List<ir.Statement> statements = <ir.Statement>[]; 1034 List<ir.Statement> statements = <ir.Statement>[];
1035 bool hasVariableDeclaration = false;
1036 for (Statement statement in caseNode.statements.nodes) { 1035 for (Statement statement in caseNode.statements.nodes) {
1037 if (buildStatement(statement, statements)) { 1036 buildStatement(statement, statements);
1038 hasVariableDeclaration = true;
1039 }
1040 } 1037 }
1041 if (statements.isEmpty || fallsThrough(statements.last)) { 1038 if (statements.isEmpty || fallsThrough(statements.last)) {
1042 if (isLastCase) { 1039 if (isLastCase) {
1043 if (!caseNode.isDefaultCase) { 1040 if (!caseNode.isDefaultCase) {
1044 statements.add(new ir.BreakStatement( 1041 statements.add(new ir.BreakStatement(
1045 getBreakTarget(elements.getTargetDefinition(node)))); 1042 getBreakTarget(elements.getTargetDefinition(node))));
1046 } 1043 }
1047 } else { 1044 } else {
1048 statements.add(new ir.ExpressionStatement(new ir.Throw( 1045 statements.add(new ir.ExpressionStatement(new ir.Throw(
1049 new ir.ConstructorInvocation( 1046 new ir.ConstructorInvocation(
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 internalError( 2099 internalError(
2103 function, "Unknown async maker: ${function.asyncMarker}"); 2100 function, "Unknown async maker: ${function.asyncMarker}");
2104 break; 2101 break;
2105 } 2102 }
2106 } 2103 }
2107 ir.Statement body; 2104 ir.Statement body;
2108 if (function.isExternal) { 2105 if (function.isExternal) {
2109 // [body] must be `null`. 2106 // [body] must be `null`.
2110 } else if (function.isConstructor) { 2107 } else if (function.isConstructor) {
2111 // TODO(johnniwinther): Clean this up pending kernel issue #28. 2108 // TODO(johnniwinther): Clean this up pending kernel issue #28.
2112 ConstructorElement constructor = function;
2113 if (bodyNode == null || bodyNode.asEmptyStatement() != null) { 2109 if (bodyNode == null || bodyNode.asEmptyStatement() != null) {
2114 body = new ir.EmptyStatement(); 2110 body = new ir.EmptyStatement();
2115 } else { 2111 } else {
2116 body = buildStatementInBlock(bodyNode); 2112 body = buildStatementInBlock(bodyNode);
2117 } 2113 }
2118 } else if (bodyNode != null) { 2114 } else if (bodyNode != null) {
2119 Return returnStatement = bodyNode.asReturn(); 2115 Return returnStatement = bodyNode.asReturn();
2120 if ((function.isSetter || function.name == Names.INDEX_SET_NAME.text) && 2116 if ((function.isSetter || function.name == Names.INDEX_SET_NAME.text) &&
2121 returnStatement != null) { 2117 returnStatement != null) {
2122 // Avoid encoding the implicit return of setters with arrow body: 2118 // Avoid encoding the implicit return of setters with arrow body:
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
2859 : this(null, true, node, initializers); 2855 : this(null, true, node, initializers);
2860 2856
2861 accept(ir.Visitor v) => throw "unsupported"; 2857 accept(ir.Visitor v) => throw "unsupported";
2862 2858
2863 visitChildren(ir.Visitor v) => throw "unsupported"; 2859 visitChildren(ir.Visitor v) => throw "unsupported";
2864 2860
2865 String toString() { 2861 String toString() {
2866 return "IrFunction($kind, $isConstructor, $node, $initializers)"; 2862 return "IrFunction($kind, $isConstructor, $node, $initializers)";
2867 } 2863 }
2868 } 2864 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart ('k') | pkg/compiler/lib/src/native/enqueue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698