| 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 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |