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 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1015 CaseMatch match = labelOrCase.asCaseMatch(); | 1015 CaseMatch match = labelOrCase.asCaseMatch(); |
1016 if (match != null) { | 1016 if (match != null) { |
1017 expressions.add(visitForValue(match.expression)); | 1017 expressions.add(visitForValue(match.expression)); |
1018 } else { | 1018 } else { |
1019 // Assert that labelOrCase is one of two known types: [CaseMatch] or | 1019 // 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 | 1020 // [Label]. We ignore cases, as any users have been resolved to use the |
1021 // case directly. | 1021 // case directly. |
1022 assert(labelOrCase.asLabel() != null); | 1022 assert(labelOrCase.asLabel() != null); |
1023 } | 1023 } |
1024 } | 1024 } |
1025 List<int> expressionsOffsets = <int>[]; | |
Kevin Millikin (Google)
2017/03/20 12:29:47
Do this in the loop above. expressionsOffsets ==>
jensj
2017/03/21 10:06:19
Done.
| |
1026 for (ir.Expression expression in expressions) { | |
1027 expressionsOffsets.add(expression.fileOffset); | |
1028 } | |
1025 // We ignore the node's statements here, they're generated below in | 1029 // We ignore the node's statements here, they're generated below in |
1026 // [visitSwitchStatement] once we've set up all the jump targets. | 1030 // [visitSwitchStatement] once we've set up all the jump targets. |
1027 return associateNode( | 1031 return associateNode( |
1028 new ir.SwitchCase(expressions, null, isDefault: node.isDefaultCase), | 1032 new ir.SwitchCase(expressions, expressionsOffsets, null, |
1033 isDefault: node.isDefaultCase), | |
1029 node); | 1034 node); |
1030 } | 1035 } |
1031 | 1036 |
1032 /// Returns true if [node] would let execution reach the next node (aka | 1037 /// Returns true if [node] would let execution reach the next node (aka |
1033 /// fall-through in switch cases). | 1038 /// fall-through in switch cases). |
1034 bool fallsThrough(ir.Statement node) { | 1039 bool fallsThrough(ir.Statement node) { |
1035 return !(node is ir.BreakStatement || | 1040 return !(node is ir.BreakStatement || |
1036 node is ir.ReturnStatement || | 1041 node is ir.ReturnStatement || |
1037 node is ir.ContinueSwitchStatement || | 1042 node is ir.ContinueSwitchStatement || |
1038 (node is ir.ExpressionStatement && node.expression is ir.Throw)); | 1043 (node is ir.ExpressionStatement && node.expression is ir.Throw)); |
(...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2940 : this(null, true, node, initializers); | 2945 : this(null, true, node, initializers); |
2941 | 2946 |
2942 accept(ir.Visitor v) => throw "unsupported"; | 2947 accept(ir.Visitor v) => throw "unsupported"; |
2943 | 2948 |
2944 visitChildren(ir.Visitor v) => throw "unsupported"; | 2949 visitChildren(ir.Visitor v) => throw "unsupported"; |
2945 | 2950 |
2946 String toString() { | 2951 String toString() { |
2947 return "IrFunction($kind, $isConstructor, $node, $initializers)"; | 2952 return "IrFunction($kind, $isConstructor, $node, $initializers)"; |
2948 } | 2953 } |
2949 } | 2954 } |
OLD | NEW |