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

Unified Diff: pkg/front_end/lib/src/fasta/scope.dart

Issue 2788913002: Prepare for separate setter scope. (Closed)
Patch Set: Address 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 side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/scope.dart
diff --git a/pkg/front_end/lib/src/fasta/scope.dart b/pkg/front_end/lib/src/fasta/scope.dart
index 9376d64d713054781e2b64a814fcdebeba425189..4f3537c93ef7d304ac4e8a5b45ea83e528d4d299 100644
--- a/pkg/front_end/lib/src/fasta/scope.dart
+++ b/pkg/front_end/lib/src/fasta/scope.dart
@@ -12,6 +12,9 @@ class Scope {
/// Names declared in this scope.
final Map<String, Builder> local;
+ /// Setters declared in this scope.
+ final Map<String, Builder> setters;
+
/// The scope that this scope is nested within, or `null` if this is the top
/// level scope.
final Scope parent;
@@ -24,13 +27,27 @@ class Scope {
Map<String, Builder> forwardDeclaredLabels;
- Scope(this.local, this.parent, {this.isModifiable: true});
+ Scope(this.local, Map<String, Builder> setters, this.parent,
+ {this.isModifiable: true})
+ : setters = setters ?? const <String, Builder>{};
+
+ Scope.top({bool isModifiable: false})
+ : this(<String, Builder>{}, <String, Builder>{}, null,
+ isModifiable: isModifiable);
+
+ Scope.immutable()
+ : this(const <String, Builder>{}, const <String, Builder>{}, null,
+ isModifiable: false);
+
+ Scope.nested(Scope parent, {bool isModifiable: true})
+ : this(<String, Builder>{}, null, parent, isModifiable: isModifiable);
Scope createNestedScope({bool isModifiable: true}) {
- return new Scope(<String, Builder>{}, this, isModifiable: isModifiable);
+ return new Scope.nested(this, isModifiable: isModifiable);
}
- Builder lookup(String name, int charOffset, Uri fileUri) {
+ Builder lookup(String name, int charOffset, Uri fileUri,
+ {bool isInstanceScope: true}) {
Builder builder = local[name];
if (builder != null) {
if (builder.next != null) {
@@ -44,7 +61,8 @@ class Scope {
}
}
- Builder lookupSetter(String name, int charOffset, Uri fileUri) {
+ Builder lookupSetter(String name, int charOffset, Uri fileUri,
+ {bool isInstanceScope: true}) {
Builder builder = local[name];
if (builder != null) {
if (builder.next != null) {
@@ -131,6 +149,10 @@ class Scope {
internalError("Can't extend an unmodifiable scope.");
}
}
+
+ void forEach(f(String name, Builder member)) {
+ local.forEach(f);
+ }
}
abstract class ProblemBuilder extends Builder {
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/kernel_target.dart ('k') | pkg/front_end/lib/src/fasta/source/scope_listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698