Index: pkg/front_end/lib/src/fasta/builder/scope.dart |
diff --git a/pkg/front_end/lib/src/fasta/builder/scope.dart b/pkg/front_end/lib/src/fasta/builder/scope.dart |
index 73560239088d53f87ef8df5b6923d2df30baff8b..159d2ba66905d6c0076b4c7c0191503fe5ab7811 100644 |
--- a/pkg/front_end/lib/src/fasta/builder/scope.dart |
+++ b/pkg/front_end/lib/src/fasta/builder/scope.dart |
@@ -20,6 +20,8 @@ class Scope { |
/// succeed. |
final bool isModifiable; |
+ Map<String, Builder> labels; |
+ |
Scope(this.local, this.parent, {this.isModifiable: true}); |
Scope createNestedScope({bool isModifiable: true}) { |
@@ -86,6 +88,21 @@ class Scope { |
return setter ? setterBuilder : getterBuilder; |
} |
+ bool hasLocalLabel(String name) => labels != null && labels.containsKey(name); |
+ |
+ void declareLabel(String name, Builder target) { |
+ if (isModifiable) { |
+ labels ??= <String, Builder>{}; |
+ labels[name] = target; |
+ } else { |
+ internalError("Can't extend an unmodifiable scope."); |
+ } |
+ } |
+ |
+ Builder lookupLabel(String name) { |
+ return (labels == null ? null : labels[name]) ?? parent?.lookupLabel(name); |
+ } |
+ |
// TODO(ahe): Rename to extend or something. |
void operator []=(String name, Builder member) { |
if (isModifiable) { |