Skip to content

Commit 3e71d18

Browse files
johnniwintherCommit Queue
authored andcommitted
[cfe] Use references for export members
This avoid the dependency on the Member nodes during compilation of the library scopes. Change-Id: Ieff93185a0ede69ac7099d5a96ced8547ec10f3a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391643 Commit-Queue: Johnni Winther <[email protected]> Reviewed-by: Chloe Stefantsova <[email protected]>
1 parent 253e715 commit 3e71d18

12 files changed

+110
-56
lines changed

pkg/front_end/lib/src/base/scope.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ mixin ErroneousMemberBuilderMixin implements SourceMemberBuilder {
659659

660660
@override
661661
// Coverage-ignore(suite): Not run.
662-
Iterable<Member> get exportedMembers => const [];
662+
Iterable<Reference> get exportedMemberReferences => const [];
663663

664664
@override
665665
// Coverage-ignore(suite): Not run.

pkg/front_end/lib/src/builder/member_builder.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ abstract class MemberBuilder implements Builder {
4242
/// a factory this is the member itself. For a setter this is `null`.
4343
Member? get invokeTarget;
4444

45-
/// The members from this builder that are accessible in exports through
46-
/// the name of the builder.
45+
/// The references to the members from this builder that are accessible in
46+
/// exports through the name of the builder.
4747
///
4848
/// This is used to allow a single builder to create separate members for
4949
/// the getter and setter capabilities.
50-
Iterable<Member> get exportedMembers;
50+
Iterable<Reference> get exportedMemberReferences;
5151

5252
// TODO(johnniwinther): Remove this and create a [ProcedureBuilder] interface.
5353
ProcedureKind? get kind;

pkg/front_end/lib/src/dill/dill_extension_member_builder.dart

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ class DillExtensionFieldBuilder extends DillExtensionMemberBuilder {
6565

6666
@override
6767
bool get isAssignable => field.hasSetter;
68+
69+
@override
70+
// Coverage-ignore(suite): Not run.
71+
Iterable<Reference> get exportedMemberReferences =>
72+
[field.getterReference, if (field.hasSetter) field.setterReference!];
6873
}
6974

7075
class DillExtensionSetterBuilder extends DillExtensionMemberBuilder {
@@ -87,6 +92,10 @@ class DillExtensionSetterBuilder extends DillExtensionMemberBuilder {
8792
@override
8893
// Coverage-ignore(suite): Not run.
8994
Member? get invokeTarget => null;
95+
96+
@override
97+
// Coverage-ignore(suite): Not run.
98+
Iterable<Reference> get exportedMemberReferences => [procedure.reference];
9099
}
91100

92101
class DillExtensionGetterBuilder extends DillExtensionMemberBuilder {
@@ -109,6 +118,10 @@ class DillExtensionGetterBuilder extends DillExtensionMemberBuilder {
109118

110119
@override
111120
Member get invokeTarget => procedure;
121+
122+
@override
123+
// Coverage-ignore(suite): Not run.
124+
Iterable<Reference> get exportedMemberReferences => [procedure.reference];
112125
}
113126

114127
class DillExtensionOperatorBuilder extends DillExtensionMemberBuilder {
@@ -131,6 +144,10 @@ class DillExtensionOperatorBuilder extends DillExtensionMemberBuilder {
131144

132145
@override
133146
Member get invokeTarget => procedure;
147+
148+
@override
149+
// Coverage-ignore(suite): Not run.
150+
Iterable<Reference> get exportedMemberReferences => [procedure.reference];
134151
}
135152

136153
class DillExtensionStaticMethodBuilder extends DillExtensionMemberBuilder {
@@ -154,6 +171,10 @@ class DillExtensionStaticMethodBuilder extends DillExtensionMemberBuilder {
154171

155172
@override
156173
Member get invokeTarget => procedure;
174+
175+
@override
176+
// Coverage-ignore(suite): Not run.
177+
Iterable<Reference> get exportedMemberReferences => [procedure.reference];
157178
}
158179

159180
class DillExtensionInstanceMethodBuilder extends DillExtensionMemberBuilder {
@@ -172,7 +193,8 @@ class DillExtensionInstanceMethodBuilder extends DillExtensionMemberBuilder {
172193

173194
@override
174195
// Coverage-ignore(suite): Not run.
175-
Iterable<Member> get exportedMembers => [procedure, _extensionTearOff];
196+
Iterable<Reference> get exportedMemberReferences =>
197+
[procedure.reference, _extensionTearOff.reference];
176198

177199
@override
178200
Member get readTarget => _extensionTearOff;

pkg/front_end/lib/src/dill/dill_extension_type_member_builder.dart

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ class DillExtensionTypeFieldBuilder extends DillExtensionTypeMemberBuilder {
107107

108108
@override
109109
bool get isAssignable => field.hasSetter;
110+
111+
@override
112+
// Coverage-ignore(suite): Not run.
113+
Iterable<Reference> get exportedMemberReferences =>
114+
[field.getterReference, if (field.hasSetter) field.setterReference!];
110115
}
111116

112117
class DillExtensionTypeSetterBuilder extends DillExtensionTypeMemberBuilder {
@@ -127,6 +132,10 @@ class DillExtensionTypeSetterBuilder extends DillExtensionTypeMemberBuilder {
127132

128133
@override
129134
Member? get invokeTarget => null;
135+
136+
@override
137+
// Coverage-ignore(suite): Not run.
138+
Iterable<Reference> get exportedMemberReferences => [procedure.reference];
130139
}
131140

132141
class DillExtensionTypeGetterBuilder extends DillExtensionTypeMemberBuilder {
@@ -148,6 +157,10 @@ class DillExtensionTypeGetterBuilder extends DillExtensionTypeMemberBuilder {
148157

149158
@override
150159
Member get invokeTarget => procedure;
160+
161+
@override
162+
// Coverage-ignore(suite): Not run.
163+
Iterable<Reference> get exportedMemberReferences => [procedure.reference];
151164
}
152165

153166
class DillExtensionTypeOperatorBuilder extends DillExtensionTypeMemberBuilder {
@@ -169,6 +182,10 @@ class DillExtensionTypeOperatorBuilder extends DillExtensionTypeMemberBuilder {
169182

170183
@override
171184
Member get invokeTarget => procedure;
185+
186+
@override
187+
// Coverage-ignore(suite): Not run.
188+
Iterable<Reference> get exportedMemberReferences => [procedure.reference];
172189
}
173190

174191
class DillExtensionTypeStaticMethodBuilder
@@ -192,6 +209,10 @@ class DillExtensionTypeStaticMethodBuilder
192209

193210
@override
194211
Member get invokeTarget => procedure;
212+
213+
@override
214+
// Coverage-ignore(suite): Not run.
215+
Iterable<Reference> get exportedMemberReferences => [procedure.reference];
195216
}
196217

197218
class DillExtensionTypeInstanceMethodBuilder
@@ -210,7 +231,8 @@ class DillExtensionTypeInstanceMethodBuilder
210231

211232
@override
212233
// Coverage-ignore(suite): Not run.
213-
Iterable<Member> get exportedMembers => [procedure, _extensionTearOff];
234+
Iterable<Reference> get exportedMemberReferences =>
235+
[procedure.reference, _extensionTearOff.reference];
214236

215237
@override
216238
Member get readTarget => _extensionTearOff;
@@ -253,6 +275,10 @@ class DillExtensionTypeConstructorBuilder extends DillExtensionTypeMemberBuilder
253275

254276
@override
255277
Procedure get invokeTarget => constructor;
278+
279+
@override
280+
// Coverage-ignore(suite): Not run.
281+
Iterable<Reference> get exportedMemberReferences => [constructor.reference];
256282
}
257283

258284
class DillExtensionTypeFactoryBuilder extends DillExtensionTypeMemberBuilder {
@@ -276,4 +302,8 @@ class DillExtensionTypeFactoryBuilder extends DillExtensionTypeMemberBuilder {
276302

277303
@override
278304
Member get invokeTarget => _procedure;
305+
306+
@override
307+
// Coverage-ignore(suite): Not run.
308+
Iterable<Reference> get exportedMemberReferences => [_procedure.reference];
279309
}

pkg/front_end/lib/src/dill/dill_member_builder.dart

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import 'package:kernel/ast.dart'
1515
Procedure,
1616
ProcedureKind,
1717
ProcedureStubKind;
18+
import 'package:kernel/canonical_name.dart';
1819

1920
import '../builder/builder.dart';
2021
import '../builder/constructor_builder.dart';
@@ -48,9 +49,6 @@ abstract class DillMemberBuilder extends MemberBuilderImpl {
4849
@override
4950
Builder get parent => declarationBuilder ?? libraryBuilder;
5051

51-
@override
52-
Iterable<Member> get exportedMembers => [member];
53-
5452
@override
5553
String get name => member.name.text;
5654

@@ -158,6 +156,10 @@ class DillFieldBuilder extends DillMemberBuilder implements FieldBuilder {
158156

159157
@override
160158
bool get isStatic => field.isStatic;
159+
160+
@override
161+
Iterable<Reference> get exportedMemberReferences =>
162+
[field.getterReference, if (field.hasSetter) field.setterReference!];
161163
}
162164

163165
abstract class DillProcedureBuilder extends DillMemberBuilder
@@ -180,6 +182,9 @@ abstract class DillProcedureBuilder extends DillMemberBuilder
180182

181183
@override
182184
bool get isStatic => procedure.isStatic;
185+
186+
@override
187+
Iterable<Reference> get exportedMemberReferences => [procedure.reference];
183188
}
184189

185190
class DillGetterBuilder extends DillProcedureBuilder {
@@ -305,6 +310,10 @@ class DillConstructorBuilder extends DillMemberBuilder
305310
@override
306311
// Coverage-ignore(suite): Not run.
307312
bool get isConst => constructor.isConst;
313+
314+
@override
315+
// Coverage-ignore(suite): Not run.
316+
Iterable<Reference> get exportedMemberReferences => [constructor.reference];
308317
}
309318

310319
class DillClassMember extends BuilderClassMember {

pkg/front_end/lib/src/kernel/body_builder_context.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,34 +137,34 @@ abstract class BodyBuilderContext {
137137
/// constructor declaration.
138138
bool get isConstructor => false;
139139

140+
// Coverage-ignore(suite): Not run.
140141
/// Returns `true` if the member whose body is being built is a non-factory
141142
/// constructor declaration marked as `external`.
142-
// Coverage-ignore(suite): Not run.
143143
bool get isExternalConstructor => false;
144144

145+
// Coverage-ignore(suite): Not run.
145146
/// Returns `true` if the member whose body is being built is a constructor,
146147
/// factory, method, getter, or setter marked as `external`.
147-
// Coverage-ignore(suite): Not run.
148148
bool get isExternalFunction => false;
149149

150+
// Coverage-ignore(suite): Not run.
150151
/// Returns `true` if the member whose body is being built is a setter
151152
/// declaration.
152-
// Coverage-ignore(suite): Not run.
153153
bool get isSetter => false;
154154

155+
// Coverage-ignore(suite): Not run.
155156
/// Returns `true` if the member whose body is being built is a non-factory
156157
/// constructor declaration marked as `const`.
157-
// Coverage-ignore(suite): Not run.
158158
bool get isConstConstructor => false;
159159

160+
// Coverage-ignore(suite): Not run.
160161
/// Returns `true` if the member whose body is being built is a (redirecting)
161162
/// factory declaration.
162-
// Coverage-ignore(suite): Not run.
163163
bool get isFactory => false;
164164

165+
// Coverage-ignore(suite): Not run.
165166
/// Returns `true` if the member whose body is being built is marked as
166167
/// native.
167-
// Coverage-ignore(suite): Not run.
168168
bool get isNativeMethod => false;
169169

170170
/// Returns `true` if the member whose body is built is an instance member
@@ -222,19 +222,19 @@ abstract class BodyBuilderContext {
222222
/// Returns the [ConstantContext] for the body currently being built.
223223
ConstantContext get constantContext => ConstantContext.none;
224224

225+
// Coverage-ignore(suite): Not run.
225226
/// Returns `true` if the member whose body is being built is a late field
226227
/// declaration.
227-
// Coverage-ignore(suite): Not run.
228228
bool get isLateField => false;
229229

230+
// Coverage-ignore(suite): Not run.
230231
/// Returns `true` if the member whose body is being built is an abstract
231232
/// field declaration.
232-
// Coverage-ignore(suite): Not run.
233233
bool get isAbstractField => false;
234234

235+
// Coverage-ignore(suite): Not run.
235236
/// Returns `true` if the member whose body is being built is an external
236237
/// field declaration.
237-
// Coverage-ignore(suite): Not run.
238238
bool get isExternalField => false;
239239

240240
/// Returns `true` if the enclosing class of the member whose body is being
@@ -331,9 +331,9 @@ abstract class BodyBuilderContext {
331331
throw new UnsupportedError('${runtimeType}.inferInitializer');
332332
}
333333

334+
// Coverage-ignore(suite): Not run.
334335
/// Returns the target for using the `augmented` expression in an augmenting
335336
/// member.
336-
// Coverage-ignore(suite): Not run.
337337
AugmentSuperTarget? get augmentSuperTarget {
338338
return null;
339339
}

pkg/front_end/lib/src/source/source_constructor_builder.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ class DeclaredSourceConstructorBuilder
493493

494494
@override
495495
// Coverage-ignore(suite): Not run.
496-
Iterable<Member> get exportedMembers => [constructor];
496+
Iterable<Reference> get exportedMemberReferences => [constructor.reference];
497497

498498
@override
499499
List<Initializer> get initializers => _constructor.initializers;
@@ -1072,7 +1072,7 @@ class SyntheticSourceConstructorBuilder extends MemberBuilderImpl
10721072

10731073
@override
10741074
// Coverage-ignore(suite): Not run.
1075-
Iterable<Member> get exportedMembers => [_constructor];
1075+
Iterable<Reference> get exportedMemberReferences => [_constructor.reference];
10761076

10771077
@override
10781078
String get name => _constructor.name.text;
@@ -1312,7 +1312,7 @@ class SourceExtensionTypeConstructorBuilder
13121312

13131313
@override
13141314
// Coverage-ignore(suite): Not run.
1315-
Iterable<Member> get exportedMembers => [_constructor];
1315+
Iterable<Reference> get exportedMemberReferences => [_constructor.reference];
13161316

13171317
@override
13181318
// Coverage-ignore(suite): Not run.

pkg/front_end/lib/src/source/source_factory_builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class SourceFactoryBuilder extends SourceFunctionBuilderImpl {
181181

182182
@override
183183
// Coverage-ignore(suite): Not run.
184-
Iterable<Member> get exportedMembers => [_procedure];
184+
Iterable<Reference> get exportedMemberReferences => [_procedure.reference];
185185

186186
@override
187187
void buildOutlineNodes(BuildNodesCallback f) {

0 commit comments

Comments
 (0)