mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
[dart2js] Make KernelImpactConverter state settable.
By making `_impactBuilder` a settable field, it simplifies conditional impact registration. Change-Id: Icf684f1def18532755218e893bb3037d49de1490 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352181 Reviewed-by: Mayank Patke <fishythefish@google.com> Commit-Queue: Nate Biggs <natebiggs@google.com>
This commit is contained in:
parent
156eda1723
commit
1c5eccdd2b
|
@ -37,7 +37,6 @@ import 'element_map.dart';
|
|||
/// [ImpactRegistry] that converts kernel based impact data to world impact
|
||||
/// object based on the K model.
|
||||
class KernelImpactConverter implements ImpactRegistry {
|
||||
final WorldImpactBuilder impactBuilder;
|
||||
final KernelToElementMap elementMap;
|
||||
final DiagnosticReporter reporter;
|
||||
final CompilerOptions _options;
|
||||
|
@ -50,6 +49,8 @@ class KernelImpactConverter implements ImpactRegistry {
|
|||
final CustomElementsResolutionAnalysis _customElementsResolutionAnalysis;
|
||||
final RuntimeTypesNeedBuilder _rtiNeedBuilder;
|
||||
final AnnotationsData _annotationsData;
|
||||
WorldImpactBuilder? _impactBuilder;
|
||||
WorldImpactBuilder get impactBuilder => _impactBuilder!;
|
||||
|
||||
KernelImpactConverter(
|
||||
this.elementMap,
|
||||
|
@ -63,8 +64,7 @@ class KernelImpactConverter implements ImpactRegistry {
|
|||
this._backendUsageBuilder,
|
||||
this._customElementsResolutionAnalysis,
|
||||
this._rtiNeedBuilder,
|
||||
this._annotationsData)
|
||||
: this.impactBuilder = WorldImpactBuilderImpl(currentMember);
|
||||
this._annotationsData);
|
||||
|
||||
ir.TypeEnvironment get typeEnvironment => elementMap.typeEnvironment;
|
||||
|
||||
|
@ -815,33 +815,20 @@ class KernelImpactConverter implements ImpactRegistry {
|
|||
/// Converts a [ImpactData] object based on kernel to the corresponding
|
||||
/// [WorldImpact] based on the K model.
|
||||
WorldImpact convert(ImpactData impactData) {
|
||||
final oldBuilder = _impactBuilder;
|
||||
final newBuilder = _impactBuilder = WorldImpactBuilderImpl(currentMember);
|
||||
impactData.apply(this);
|
||||
return impactBuilder;
|
||||
_impactBuilder = oldBuilder;
|
||||
return newBuilder;
|
||||
}
|
||||
|
||||
@override
|
||||
void registerConditionalImpact(ConditionalImpactData impact) {
|
||||
final conditionalUse = ConditionalUse(
|
||||
// TODO(natebiggs): Make KernelImpactConverter stateless so that we
|
||||
// don't need one per impact.
|
||||
impact: KernelImpactConverter(
|
||||
elementMap,
|
||||
currentMember,
|
||||
reporter,
|
||||
_options,
|
||||
_constantValuefier,
|
||||
staticTypeContext,
|
||||
_impacts,
|
||||
_nativeResolutionEnqueuer,
|
||||
_backendUsageBuilder,
|
||||
_customElementsResolutionAnalysis,
|
||||
_rtiNeedBuilder,
|
||||
_annotationsData)
|
||||
.convert(impact.impactData),
|
||||
impact: convert(impact.impactData),
|
||||
conditions: impact.conditions.map(elementMap.getMember).toList(),
|
||||
source: impact.source,
|
||||
replacement: impact.replacement);
|
||||
|
||||
impactBuilder.registerConditionalUse(conditionalUse);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue