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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// ----------------------------------------------------------------------- | 5 /// ----------------------------------------------------------------------- |
6 /// ERROR HANDLING | 6 /// ERROR HANDLING |
7 /// ----------------------------------------------------------------------- | 7 /// ----------------------------------------------------------------------- |
8 /// | 8 /// |
9 /// As a rule of thumb, errors that can be detected statically are handled by | 9 /// As a rule of thumb, errors that can be detected statically are handled by |
10 /// the frontend, typically by translating the erroneous code into a 'throw' or | 10 /// the frontend, typically by translating the erroneous code into a 'throw' or |
(...skipping 3049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3060 } | 3060 } |
3061 transformList(cases, v, this); | 3061 transformList(cases, v, this); |
3062 } | 3062 } |
3063 } | 3063 } |
3064 | 3064 |
3065 /// A group of `case` clauses and/or a `default` clause. | 3065 /// A group of `case` clauses and/or a `default` clause. |
3066 /// | 3066 /// |
3067 /// This is a potential target of [ContinueSwitchStatement]. | 3067 /// This is a potential target of [ContinueSwitchStatement]. |
3068 class SwitchCase extends TreeNode { | 3068 class SwitchCase extends TreeNode { |
3069 final List<Expression> expressions; | 3069 final List<Expression> expressions; |
3070 final List<int> expressionsOffsets; | |
Kevin Millikin (Google)
2017/03/20 12:29:47
expressionsOffsets ==> expressionOffsets
jensj
2017/03/21 10:06:19
Done.
| |
3070 Statement body; | 3071 Statement body; |
3071 bool isDefault; | 3072 bool isDefault; |
3072 | 3073 |
3073 SwitchCase(this.expressions, this.body, {this.isDefault: false}) { | 3074 SwitchCase(this.expressions, this.expressionsOffsets, this.body, |
3075 {this.isDefault: false}) { | |
3074 setParents(expressions, this); | 3076 setParents(expressions, this); |
3075 body?.parent = this; | 3077 body?.parent = this; |
3076 } | 3078 } |
3077 | 3079 |
3078 SwitchCase.defaultCase(this.body) | 3080 SwitchCase.defaultCase(this.body) |
3079 : isDefault = true, | 3081 : isDefault = true, |
3080 expressions = <Expression>[] { | 3082 expressions = <Expression>[], |
3083 expressionsOffsets = <int>[] { | |
3081 body?.parent = this; | 3084 body?.parent = this; |
3082 } | 3085 } |
3083 | 3086 |
3084 SwitchCase.empty() | 3087 SwitchCase.empty() |
3085 : expressions = <Expression>[], | 3088 : expressions = <Expression>[], |
3089 expressionsOffsets = <int>[], | |
3086 body = null, | 3090 body = null, |
3087 isDefault = false; | 3091 isDefault = false; |
3088 | 3092 |
3089 accept(TreeVisitor v) => v.visitSwitchCase(this); | 3093 accept(TreeVisitor v) => v.visitSwitchCase(this); |
3090 | 3094 |
3091 visitChildren(Visitor v) { | 3095 visitChildren(Visitor v) { |
3092 visitList(expressions, v); | 3096 visitList(expressions, v); |
3093 body?.accept(v); | 3097 body?.accept(v); |
3094 } | 3098 } |
3095 | 3099 |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4074 /// library has not been assigned a canonical name yet. | 4078 /// library has not been assigned a canonical name yet. |
4075 /// | 4079 /// |
4076 /// Returns `null` if the library is `null`. | 4080 /// Returns `null` if the library is `null`. |
4077 CanonicalName getCanonicalNameOfLibrary(Library library) { | 4081 CanonicalName getCanonicalNameOfLibrary(Library library) { |
4078 if (library == null) return null; | 4082 if (library == null) return null; |
4079 if (library.canonicalName == null) { | 4083 if (library.canonicalName == null) { |
4080 throw '$library has no canonical name'; | 4084 throw '$library has no canonical name'; |
4081 } | 4085 } |
4082 return library.canonicalName; | 4086 return library.canonicalName; |
4083 } | 4087 } |
OLD | NEW |