| OLD | NEW |
| 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 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1004 | 1004 |
| 1005 @override | 1005 @override |
| 1006 ir.StringConcatenation visitStringJuxtaposition(StringJuxtaposition node) { | 1006 ir.StringConcatenation visitStringJuxtaposition(StringJuxtaposition node) { |
| 1007 return new ir.StringConcatenation( | 1007 return new ir.StringConcatenation( |
| 1008 <ir.Expression>[visitForValue(node.first), visitForValue(node.second)]); | 1008 <ir.Expression>[visitForValue(node.first), visitForValue(node.second)]); |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 @override | 1011 @override |
| 1012 ir.SwitchCase visitSwitchCase(SwitchCase node) { | 1012 ir.SwitchCase visitSwitchCase(SwitchCase node) { |
| 1013 List<ir.Expression> expressions = <ir.Expression>[]; | 1013 List<ir.Expression> expressions = <ir.Expression>[]; |
| 1014 List<int> expressionOffsets = <int>[]; |
| 1014 for (var labelOrCase in node.labelsAndCases.nodes) { | 1015 for (var labelOrCase in node.labelsAndCases.nodes) { |
| 1015 CaseMatch match = labelOrCase.asCaseMatch(); | 1016 CaseMatch match = labelOrCase.asCaseMatch(); |
| 1016 if (match != null) { | 1017 if (match != null) { |
| 1017 expressions.add(visitForValue(match.expression)); | 1018 ir.TreeNode expression = visitForValue(match.expression); |
| 1019 expressions.add(expression); |
| 1020 expressionOffsets.add(expression.fileOffset); |
| 1018 } else { | 1021 } else { |
| 1019 // Assert that labelOrCase is one of two known types: [CaseMatch] or | 1022 // Assert that labelOrCase is one of two known types: [CaseMatch] or |
| 1020 // [Label]. We ignore cases, as any users have been resolved to use the | 1023 // [Label]. We ignore cases, as any users have been resolved to use the |
| 1021 // case directly. | 1024 // case directly. |
| 1022 assert(labelOrCase.asLabel() != null); | 1025 assert(labelOrCase.asLabel() != null); |
| 1023 } | 1026 } |
| 1024 } | 1027 } |
| 1025 // We ignore the node's statements here, they're generated below in | 1028 // We ignore the node's statements here, they're generated below in |
| 1026 // [visitSwitchStatement] once we've set up all the jump targets. | 1029 // [visitSwitchStatement] once we've set up all the jump targets. |
| 1027 return associateNode( | 1030 return associateNode( |
| 1028 new ir.SwitchCase(expressions, null, isDefault: node.isDefaultCase), | 1031 new ir.SwitchCase(expressions, expressionOffsets, null, |
| 1032 isDefault: node.isDefaultCase), |
| 1029 node); | 1033 node); |
| 1030 } | 1034 } |
| 1031 | 1035 |
| 1032 /// Returns true if [node] would let execution reach the next node (aka | 1036 /// Returns true if [node] would let execution reach the next node (aka |
| 1033 /// fall-through in switch cases). | 1037 /// fall-through in switch cases). |
| 1034 bool fallsThrough(ir.Statement node) { | 1038 bool fallsThrough(ir.Statement node) { |
| 1035 return !(node is ir.BreakStatement || | 1039 return !(node is ir.BreakStatement || |
| 1036 node is ir.ReturnStatement || | 1040 node is ir.ReturnStatement || |
| 1037 node is ir.ContinueSwitchStatement || | 1041 node is ir.ContinueSwitchStatement || |
| 1038 (node is ir.ExpressionStatement && node.expression is ir.Throw)); | 1042 (node is ir.ExpressionStatement && node.expression is ir.Throw)); |
| (...skipping 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2943 : this(null, true, node, initializers); | 2947 : this(null, true, node, initializers); |
| 2944 | 2948 |
| 2945 accept(ir.Visitor v) => throw "unsupported"; | 2949 accept(ir.Visitor v) => throw "unsupported"; |
| 2946 | 2950 |
| 2947 visitChildren(ir.Visitor v) => throw "unsupported"; | 2951 visitChildren(ir.Visitor v) => throw "unsupported"; |
| 2948 | 2952 |
| 2949 String toString() { | 2953 String toString() { |
| 2950 return "IrFunction($kind, $isConstructor, $node, $initializers)"; | 2954 return "IrFunction($kind, $isConstructor, $node, $initializers)"; |
| 2951 } | 2955 } |
| 2952 } | 2956 } |
| OLD | NEW |