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

Side by Side Diff: pkg/kernel/lib/ast.dart

Issue 2750013002: [kernel] Debugging of switch statement (Closed)
Patch Set: Addressed comments Created 3 years, 9 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 | « pkg/kernel/binary.md ('k') | pkg/kernel/lib/binary/ast_from_binary.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 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 3062 matching lines...) Expand 10 before | Expand all | Expand 10 after
3073 } 3073 }
3074 transformList(cases, v, this); 3074 transformList(cases, v, this);
3075 } 3075 }
3076 } 3076 }
3077 3077
3078 /// A group of `case` clauses and/or a `default` clause. 3078 /// A group of `case` clauses and/or a `default` clause.
3079 /// 3079 ///
3080 /// This is a potential target of [ContinueSwitchStatement]. 3080 /// This is a potential target of [ContinueSwitchStatement].
3081 class SwitchCase extends TreeNode { 3081 class SwitchCase extends TreeNode {
3082 final List<Expression> expressions; 3082 final List<Expression> expressions;
3083 final List<int> expressionOffsets;
3083 Statement body; 3084 Statement body;
3084 bool isDefault; 3085 bool isDefault;
3085 3086
3086 SwitchCase(this.expressions, this.body, {this.isDefault: false}) { 3087 SwitchCase(this.expressions, this.expressionOffsets, this.body,
3088 {this.isDefault: false}) {
3087 setParents(expressions, this); 3089 setParents(expressions, this);
3088 body?.parent = this; 3090 body?.parent = this;
3089 } 3091 }
3090 3092
3091 SwitchCase.defaultCase(this.body) 3093 SwitchCase.defaultCase(this.body)
3092 : isDefault = true, 3094 : isDefault = true,
3093 expressions = <Expression>[] { 3095 expressions = <Expression>[],
3096 expressionOffsets = <int>[] {
3094 body?.parent = this; 3097 body?.parent = this;
3095 } 3098 }
3096 3099
3097 SwitchCase.empty() 3100 SwitchCase.empty()
3098 : expressions = <Expression>[], 3101 : expressions = <Expression>[],
3102 expressionOffsets = <int>[],
3099 body = null, 3103 body = null,
3100 isDefault = false; 3104 isDefault = false;
3101 3105
3102 accept(TreeVisitor v) => v.visitSwitchCase(this); 3106 accept(TreeVisitor v) => v.visitSwitchCase(this);
3103 3107
3104 visitChildren(Visitor v) { 3108 visitChildren(Visitor v) {
3105 visitList(expressions, v); 3109 visitList(expressions, v);
3106 body?.accept(v); 3110 body?.accept(v);
3107 } 3111 }
3108 3112
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after
4096 /// library has not been assigned a canonical name yet. 4100 /// library has not been assigned a canonical name yet.
4097 /// 4101 ///
4098 /// Returns `null` if the library is `null`. 4102 /// Returns `null` if the library is `null`.
4099 CanonicalName getCanonicalNameOfLibrary(Library library) { 4103 CanonicalName getCanonicalNameOfLibrary(Library library) {
4100 if (library == null) return null; 4104 if (library == null) return null;
4101 if (library.canonicalName == null) { 4105 if (library.canonicalName == null) {
4102 throw '$library has no canonical name'; 4106 throw '$library has no canonical name';
4103 } 4107 }
4104 return library.canonicalName; 4108 return library.canonicalName;
4105 } 4109 }
OLDNEW
« no previous file with comments | « pkg/kernel/binary.md ('k') | pkg/kernel/lib/binary/ast_from_binary.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698