pkg-compiler: drop Pair class, use Record
Change-Id: I19b05ffc6bd8e87e58990a62a21b8a2986fe9f54 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382760 Commit-Queue: Nate Biggs <natebiggs@google.com> Auto-Submit: Kevin Moore <kevmoo@google.com> Reviewed-by: Nate Biggs <natebiggs@google.com>
This commit is contained in:
committed by
Commit Queue
parent
6d72e53696
commit
07fd58715c
@@ -42,8 +42,8 @@ class CodegenImpact extends WorldImpact {
|
||||
throw UnsupportedError('CodegenImpact.writeToDataSink');
|
||||
}
|
||||
|
||||
Iterable<Pair<DartType, DartType>> get typeVariableBoundsSubtypeChecks {
|
||||
return const <Pair<DartType, DartType>>[];
|
||||
Iterable<(DartType, DartType)> get typeVariableBoundsSubtypeChecks {
|
||||
return const <(DartType, DartType)>[];
|
||||
}
|
||||
|
||||
Iterable<String> get constSymbols => const <String>[];
|
||||
@@ -71,7 +71,7 @@ class _CodegenImpact extends WorldImpactBuilderImpl implements CodegenImpact {
|
||||
|
||||
@override
|
||||
final MemberEntity member;
|
||||
Set<Pair<DartType, DartType>>? _typeVariableBoundsSubtypeChecks;
|
||||
Set<(DartType, DartType)>? _typeVariableBoundsSubtypeChecks;
|
||||
Set<String>? _constSymbols;
|
||||
List<Set<ClassEntity>>? _specializedGetInterceptors;
|
||||
bool _usesInterceptor = false;
|
||||
@@ -116,7 +116,7 @@ class _CodegenImpact extends WorldImpactBuilderImpl implements CodegenImpact {
|
||||
.readListOrNull(() => ConstantUse.readFromDataSource(source))
|
||||
?.toSet();
|
||||
final typeVariableBoundsSubtypeChecks = source.readListOrNull(() {
|
||||
return Pair(source.readDartType(), source.readDartType());
|
||||
return (source.readDartType(), source.readDartType());
|
||||
})?.toSet();
|
||||
final constSymbols = source.readStringsOrNull()?.toSet();
|
||||
final specializedGetInterceptors = source.readListOrNull(() {
|
||||
@@ -161,10 +161,10 @@ class _CodegenImpact extends WorldImpactBuilderImpl implements CodegenImpact {
|
||||
sink.writeList(typeUses, (TypeUse use) => use.writeToDataSink(sink));
|
||||
sink.writeList(
|
||||
constantUses, (ConstantUse use) => use.writeToDataSink(sink));
|
||||
sink.writeListOrNull<Pair<DartType, DartType>>(
|
||||
_typeVariableBoundsSubtypeChecks, (pair) {
|
||||
sink.writeDartType(pair.a);
|
||||
sink.writeDartType(pair.b);
|
||||
sink.writeListOrNull<(DartType, DartType)>(_typeVariableBoundsSubtypeChecks,
|
||||
(pair) {
|
||||
sink.writeDartType(pair.$1);
|
||||
sink.writeDartType(pair.$2);
|
||||
});
|
||||
sink.writeStringsOrNull(_constSymbols);
|
||||
sink.writeListOrNull(_specializedGetInterceptors, sink.writeClasses);
|
||||
@@ -184,12 +184,11 @@ class _CodegenImpact extends WorldImpactBuilderImpl implements CodegenImpact {
|
||||
|
||||
void registerTypeVariableBoundsSubtypeCheck(
|
||||
DartType subtype, DartType supertype) {
|
||||
(_typeVariableBoundsSubtypeChecks ??= {})
|
||||
.add(Pair<DartType, DartType>(subtype, supertype));
|
||||
(_typeVariableBoundsSubtypeChecks ??= {}).add((subtype, supertype));
|
||||
}
|
||||
|
||||
@override
|
||||
Iterable<Pair<DartType, DartType>> get typeVariableBoundsSubtypeChecks {
|
||||
Iterable<(DartType, DartType)> get typeVariableBoundsSubtypeChecks {
|
||||
return _typeVariableBoundsSubtypeChecks ?? const {};
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ import '../universe/member_hierarchy.dart';
|
||||
import '../universe/record_shape.dart';
|
||||
import '../universe/selector.dart';
|
||||
import '../universe/side_effects.dart';
|
||||
import '../util/util.dart';
|
||||
import 'engine.dart';
|
||||
import 'locals_handler.dart';
|
||||
import 'type_graph_nodes.dart';
|
||||
@@ -704,14 +703,14 @@ class KernelTypeGraphBuilder extends ir.VisitorDefault<TypeInformation?>
|
||||
@override
|
||||
TypeInformation visitMapLiteral(ir.MapLiteral node) {
|
||||
return createMapTypeInformation(
|
||||
node, node.entries.map((e) => Pair(visit(e.key)!, visit(e.value)!)),
|
||||
node, node.entries.map((e) => (visit(e.key)!, visit(e.value)!)),
|
||||
isConst: node.isConst,
|
||||
keyStaticType: _elementMap.getDartType(node.keyType),
|
||||
valueStaticType: _elementMap.getDartType(node.valueType));
|
||||
}
|
||||
|
||||
TypeInformation createMapTypeInformation(ir.TreeNode node,
|
||||
Iterable<Pair<TypeInformation, TypeInformation>> entryTypes,
|
||||
TypeInformation createMapTypeInformation(
|
||||
ir.TreeNode node, Iterable<(TypeInformation, TypeInformation)> entryTypes,
|
||||
{required bool isConst,
|
||||
required DartType keyStaticType,
|
||||
required DartType valueStaticType}) {
|
||||
@@ -719,9 +718,9 @@ class KernelTypeGraphBuilder extends ir.VisitorDefault<TypeInformation?>
|
||||
List<TypeInformation> keyTypes = [];
|
||||
List<TypeInformation> valueTypes = [];
|
||||
|
||||
for (Pair<TypeInformation, TypeInformation> entryType in entryTypes) {
|
||||
keyTypes.add(entryType.a);
|
||||
valueTypes.add(entryType.b);
|
||||
for ((TypeInformation, TypeInformation) entryType in entryTypes) {
|
||||
keyTypes.add(entryType.$1);
|
||||
valueTypes.add(entryType.$2);
|
||||
}
|
||||
|
||||
final type = isConst ? _types.constMapType : _types.mapType;
|
||||
@@ -2297,10 +2296,8 @@ class TypeInformationConstantVisitor
|
||||
|
||||
@override
|
||||
TypeInformation visitMapConstant(ir.MapConstant node) {
|
||||
return builder.createMapTypeInformation(
|
||||
ConstantReference(expression, node),
|
||||
node.entries
|
||||
.map((e) => Pair(visitConstant(e.key), visitConstant(e.value))),
|
||||
return builder.createMapTypeInformation(ConstantReference(expression, node),
|
||||
node.entries.map((e) => (visitConstant(e.key), visitConstant(e.value))),
|
||||
isConst: true,
|
||||
keyStaticType: builder._elementMap.getDartType(node.keyType),
|
||||
valueStaticType: builder._elementMap.getDartType(node.valueType));
|
||||
|
||||
@@ -10,7 +10,6 @@ import 'dart:math' show max;
|
||||
import 'package:js_shared/synced/async_status_codes.dart' as status_codes;
|
||||
|
||||
import '../common.dart';
|
||||
import '../util/util.dart' show Pair;
|
||||
import 'js.dart' as js;
|
||||
|
||||
/// Rewrites a [js.Fun] with async/sync*/async* functions and await and yield
|
||||
@@ -65,7 +64,7 @@ abstract class AsyncRewriterBase extends js.NodeVisitor<Object?> {
|
||||
/// are on the way to target (i.e. more nested than the jump target).
|
||||
List<js.Node> jumpTargets = [];
|
||||
|
||||
List<Pair<String, String>> variableRenamings = [];
|
||||
List<(String, String)> variableRenamings = [];
|
||||
|
||||
late final PreTranslationAnalysis analysis;
|
||||
|
||||
@@ -1559,7 +1558,7 @@ abstract class AsyncRewriterBase extends js.NodeVisitor<Object?> {
|
||||
// block so shadow any catch variable bindings that might collide with
|
||||
// this one so that references to this binding do not get renamed.
|
||||
variableRenamings
|
||||
.add(Pair(catchPart.declaration.name, catchPart.declaration.name));
|
||||
.add((catchPart.declaration.name, catchPart.declaration.name));
|
||||
translatedCatchPart =
|
||||
js.Catch(catchPart.declaration, translateToBlock(catchPart.body));
|
||||
variableRenamings.removeLast();
|
||||
@@ -1615,7 +1614,7 @@ abstract class AsyncRewriterBase extends js.NodeVisitor<Object?> {
|
||||
// section 12.14.
|
||||
String errorRename = freshName(catchPart.declaration.name);
|
||||
localVariables.add(js.VariableDeclaration(errorRename));
|
||||
variableRenamings.add(Pair(catchPart.declaration.name, errorRename));
|
||||
variableRenamings.add((catchPart.declaration.name, errorRename));
|
||||
addStatement(js.js.statement("# = #;", [errorRename, currentError]));
|
||||
visitStatement(catchPart.body);
|
||||
variableRenamings.removeLast();
|
||||
@@ -1695,7 +1694,7 @@ abstract class AsyncRewriterBase extends js.NodeVisitor<Object?> {
|
||||
@override
|
||||
js.Expression visitVariableUse(js.VariableUse node) {
|
||||
for (final renaming in variableRenamings.reversed) {
|
||||
if (renaming.a == node.name) return js.VariableUse(renaming.b);
|
||||
if (renaming.$1 == node.name) return js.VariableUse(renaming.$2);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import '../universe/feature.dart';
|
||||
import '../universe/selector.dart';
|
||||
import '../universe/use.dart';
|
||||
import '../universe/world_impact.dart' show TransformedWorldImpact, WorldImpact;
|
||||
import '../util/util.dart';
|
||||
import 'backend_impact.dart';
|
||||
import 'backend_usage.dart';
|
||||
import 'interceptor_data.dart';
|
||||
@@ -122,10 +121,9 @@ class CodegenImpactTransformer {
|
||||
}
|
||||
}
|
||||
|
||||
for (Pair<DartType, DartType> check
|
||||
in impact.typeVariableBoundsSubtypeChecks) {
|
||||
for ((DartType, DartType) check in impact.typeVariableBoundsSubtypeChecks) {
|
||||
_rtiChecksBuilder.registerTypeVariableBoundsSubtypeCheck(
|
||||
check.a, check.b);
|
||||
check.$1, check.$2);
|
||||
}
|
||||
|
||||
for (StaticUse staticUse in impact.staticUses) {
|
||||
|
||||
@@ -231,26 +231,6 @@ void writeJsonEscapedCharsOn(String string, StringSink buffer) {
|
||||
buffer.write(string);
|
||||
}
|
||||
|
||||
class Pair<A, B> {
|
||||
final A a;
|
||||
final B b;
|
||||
|
||||
Pair(this.a, this.b);
|
||||
|
||||
@override
|
||||
int get hashCode => 13 * a.hashCode + 17 * b.hashCode;
|
||||
|
||||
@override
|
||||
bool operator ==(var other) {
|
||||
if (identical(this, other)) return true;
|
||||
if (other is! Pair) return false;
|
||||
return a == other.a && b == other.b;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => '($a,$b)';
|
||||
}
|
||||
|
||||
int longestCommonPrefixLength(List<Object?> a, List<Object?> b) {
|
||||
int index = 0;
|
||||
for (; index < a.length && index < b.length; index++) {
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
library source_mapping.test.viewer;
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:_fe_analyzer_shared/src/util/filenames.dart';
|
||||
import 'package:compiler/src/util/util.dart';
|
||||
import 'source_mapping_tester.dart';
|
||||
|
||||
import '../helpers/sourcemap_helper.dart';
|
||||
import '../helpers/sourcemap_html_helper.dart';
|
||||
import '../helpers/sourcemap_html_templates.dart';
|
||||
import 'source_mapping_tester.dart';
|
||||
|
||||
const String DEFAULT_OUTPUT_PATH = 'out.js.map.html';
|
||||
|
||||
@@ -91,27 +92,21 @@ class OutputConfigurations implements Configurations {
|
||||
final Iterable<String> configs;
|
||||
@override
|
||||
final Iterable<String> files;
|
||||
final Map<Pair, String> pathMap = {};
|
||||
final Map<Pair, Uri> uriMap = {};
|
||||
final Map<(String, String), String> pathMap = {};
|
||||
final Map<(String, String), Uri> uriMap = {};
|
||||
|
||||
OutputConfigurations(this.configs, this.files);
|
||||
|
||||
void registerPathUri(String config, String file, String path, Uri uri) {
|
||||
Pair key = Pair(config, file);
|
||||
var key = (config, file);
|
||||
pathMap[key] = path;
|
||||
uriMap[key] = uri;
|
||||
}
|
||||
|
||||
Uri? getUri(String config, String file) {
|
||||
Pair key = Pair(config, file);
|
||||
return uriMap[key];
|
||||
}
|
||||
Uri? getUri(String config, String file) => uriMap[(config, file)];
|
||||
|
||||
@override
|
||||
String getPath(String config, String file) {
|
||||
Pair key = Pair(config, file);
|
||||
return pathMap[key]!;
|
||||
}
|
||||
String getPath(String config, String file) => pathMap[(config, file)]!;
|
||||
}
|
||||
|
||||
Future<Measurement> runTest(
|
||||
|
||||
Reference in New Issue
Block a user