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

Side by Side Diff: pkg/front_end/lib/src/fasta/scope.dart

Issue 2790923002: Special scope for labelled statements. (Closed)
Patch Set: Update status file. Created 3 years, 8 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/front_end/lib/src/fasta/kernel/body_builder.dart ('k') | tests/co19/co19-kernel.status » ('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 library fasta.scope; 5 library fasta.scope;
6 6
7 import 'builder/builder.dart' show Builder, MixedAccessor; 7 import 'builder/builder.dart' show Builder, MixedAccessor;
8 8
9 import 'errors.dart' show internalError; 9 import 'errors.dart' show internalError;
10 10
(...skipping 28 matching lines...) Expand all
39 : this(const <String, Builder>{}, const <String, Builder>{}, null, 39 : this(const <String, Builder>{}, const <String, Builder>{}, null,
40 isModifiable: false); 40 isModifiable: false);
41 41
42 Scope.nested(Scope parent, {bool isModifiable: true}) 42 Scope.nested(Scope parent, {bool isModifiable: true})
43 : this(<String, Builder>{}, null, parent, isModifiable: isModifiable); 43 : this(<String, Builder>{}, null, parent, isModifiable: isModifiable);
44 44
45 Scope createNestedScope({bool isModifiable: true}) { 45 Scope createNestedScope({bool isModifiable: true}) {
46 return new Scope.nested(this, isModifiable: isModifiable); 46 return new Scope.nested(this, isModifiable: isModifiable);
47 } 47 }
48 48
49 /// Create a special scope for use by labeled staments. This scope doesn't
50 /// introduce a new scope for local variables, only for labels. This deals
51 /// with corner cases like this:
52 ///
53 /// L: var x;
54 /// x = 42;
55 /// print("The answer is $x.");
56 Scope createNestedLabelScope() {
57 return new Scope(local, setters, parent, isModifiable: true);
58 }
59
49 Builder lookup(String name, int charOffset, Uri fileUri, 60 Builder lookup(String name, int charOffset, Uri fileUri,
50 {bool isInstanceScope: true}) { 61 {bool isInstanceScope: true}) {
51 Builder builder = local[name]; 62 Builder builder = local[name];
52 if (builder != null) { 63 if (builder != null) {
53 if (builder.next != null) { 64 if (builder.next != null) {
54 return lookupAmbiguous(name, builder, false, charOffset, fileUri); 65 return lookupAmbiguous(name, builder, false, charOffset, fileUri);
55 } 66 }
56 return builder.isSetter 67 return builder.isSetter
57 ? new AccessErrorBuilder(name, builder, charOffset, fileUri) 68 ? new AccessErrorBuilder(name, builder, charOffset, fileUri)
58 : builder; 69 : builder;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 214
204 String get message => "Access error: '$name'."; 215 String get message => "Access error: '$name'.";
205 } 216 }
206 217
207 class AmbiguousBuilder extends ProblemBuilder { 218 class AmbiguousBuilder extends ProblemBuilder {
208 AmbiguousBuilder(String name, Builder builder, int charOffset, Uri fileUri) 219 AmbiguousBuilder(String name, Builder builder, int charOffset, Uri fileUri)
209 : super(name, builder, charOffset, fileUri); 220 : super(name, builder, charOffset, fileUri);
210 221
211 String get message => "Duplicated named: '$name'."; 222 String get message => "Duplicated named: '$name'.";
212 } 223 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/body_builder.dart ('k') | tests/co19/co19-kernel.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698