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

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

Issue 2788913002: Prepare for separate setter scope. (Closed)
Patch Set: Address comments. 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
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.class_builder; 5 library fasta.class_builder;
6 6
7 import '../errors.dart' show internalError; 7 import '../errors.dart' show internalError;
8 8
9 import 'builder.dart' 9 import 'builder.dart'
10 show 10 show
11 Builder, 11 Builder,
12 ConstructorReferenceBuilder, 12 ConstructorReferenceBuilder,
13 LibraryBuilder, 13 LibraryBuilder,
14 MemberBuilder,
14 MetadataBuilder, 15 MetadataBuilder,
15 MixinApplicationBuilder, 16 MixinApplicationBuilder,
16 NamedTypeBuilder, 17 NamedTypeBuilder,
17 TypeBuilder, 18 TypeBuilder,
18 TypeDeclarationBuilder, 19 TypeDeclarationBuilder,
19 TypeVariableBuilder; 20 TypeVariableBuilder;
20 21
21 import '../scope.dart' show AccessErrorBuilder, AmbiguousBuilder, Scope; 22 import '../scope.dart' show AccessErrorBuilder, AmbiguousBuilder, Scope;
22 23
23 abstract class ClassBuilder<T extends TypeBuilder, R> 24 abstract class ClassBuilder<T extends TypeBuilder, R>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 68 }
68 return constructorReferences.length; 69 return constructorReferences.length;
69 } 70 }
70 71
71 Scope computeInstanceScope(Scope parent) { 72 Scope computeInstanceScope(Scope parent) {
72 if (typeVariables != null) { 73 if (typeVariables != null) {
73 Map<String, Builder> local = <String, Builder>{}; 74 Map<String, Builder> local = <String, Builder>{};
74 for (TypeVariableBuilder t in typeVariables) { 75 for (TypeVariableBuilder t in typeVariables) {
75 local[t.name] = t; 76 local[t.name] = t;
76 } 77 }
77 parent = new Scope(local, parent, isModifiable: false); 78 parent = new Scope(local, null, parent, isModifiable: false);
78 } 79 }
79 return new Scope(membersInScope, parent, isModifiable: false); 80 return new Scope(membersInScope, null, parent, isModifiable: false);
80 } 81 }
81 82
82 /// Used to lookup a static member of this class. 83 /// Used to lookup a static member of this class.
83 Builder findStaticBuilder(String name, int charOffset, Uri fileUri, 84 Builder findStaticBuilder(String name, int charOffset, Uri fileUri,
84 {bool isSetter: false}) { 85 {bool isSetter: false}) {
85 Builder builder = members[name]; 86 Builder builder = members[name];
86 if (builder?.next != null) { 87 if (builder?.next != null) {
87 Builder getterBuilder; 88 Builder getterBuilder;
88 Builder setterBuilder; 89 Builder setterBuilder;
89 Builder current = builder; 90 Builder current = builder;
(...skipping 26 matching lines...) Expand all
116 } 117 }
117 if (builder == null) { 118 if (builder == null) {
118 return null; 119 return null;
119 } else if (isSetter && builder.isGetter) { 120 } else if (isSetter && builder.isGetter) {
120 return null; 121 return null;
121 } else { 122 } else {
122 return builder.isInstanceMember ? null : builder; 123 return builder.isInstanceMember ? null : builder;
123 } 124 }
124 } 125 }
125 126
126 Builder findConstructorOrFactory(String name); 127 Builder findConstructorOrFactory(String name, int charOffset, Uri uri) {
128 return constructors[name];
129 }
127 130
128 /// Returns a map which maps the type variables of [superclass] to their 131 /// Returns a map which maps the type variables of [superclass] to their
129 /// respective values as defined by the superclass clause of this class (and 132 /// respective values as defined by the superclass clause of this class (and
130 /// its superclasses). 133 /// its superclasses).
131 /// 134 ///
132 /// It's assumed that [superclass] is a superclass of this class. 135 /// It's assumed that [superclass] is a superclass of this class.
133 /// 136 ///
134 /// For example, given: 137 /// For example, given:
135 /// 138 ///
136 /// class Box<T> {} 139 /// class Box<T> {}
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 argument = argument.subst(substitutionMap); 184 argument = argument.subst(substitutionMap);
182 } 185 }
183 directSubstitutionMap[variables[i]] = argument; 186 directSubstitutionMap[variables[i]] = argument;
184 } 187 }
185 substitutionMap = directSubstitutionMap; 188 substitutionMap = directSubstitutionMap;
186 } 189 }
187 } 190 }
188 return substitutionMap; 191 return substitutionMap;
189 } 192 }
190 193
194 void forEach(void f(String name, MemberBuilder builder)) {
195 members.forEach(f);
196 }
197
198 /// Don't use for scope lookup. Only use when an element is known to exist
199 /// (and isn't a setter).
200 MemberBuilder operator [](String name) {
201 // TODO(ahe): Rename this to getLocalMember.
202 return members[name] ?? internalError("Not found: '$name'.");
203 }
204
191 void addCompileTimeError(int charOffset, String message) { 205 void addCompileTimeError(int charOffset, String message) {
192 library.addCompileTimeError(charOffset, message, fileUri: fileUri); 206 library.addCompileTimeError(charOffset, message, fileUri: fileUri);
193 } 207 }
194 208
195 void addWarning(int charOffset, String message) { 209 void addWarning(int charOffset, String message) {
196 library.addWarning(charOffset, message, fileUri: fileUri); 210 library.addWarning(charOffset, message, fileUri: fileUri);
197 } 211 }
198 212
199 void addNit(int charOffset, String message) { 213 void addNit(int charOffset, String message) {
200 library.addNit(charOffset, message, fileUri: fileUri); 214 library.addNit(charOffset, message, fileUri: fileUri);
201 } 215 }
202 } 216 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698