[dart2js] Remove references to new-rti/old-rti.
The "new" rti library has been standard for years now and no one should
be passing `--experiment-new-rti` or `--use-old-rti`. We can now clean
up any references to different versions of rtis.
Change-Id: I4421b8943fe5034ed4d259477e8112b25ba0c763
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416326
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 926f7c2..9d35e01 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -77,6 +77,10 @@
In the future this will likely be a compile-time error and will be entirely
disallowed.
+#### Dart to Javascript Compiler (dart2js)
+
+Removed the `--experiment-new-rti` and `--use-old-rti` flags.
+
## 3.7.0
**Released on:** 2025-02-12
diff --git a/benchmarks/SoundSplayTreeSieve/dart/README.md b/benchmarks/SoundSplayTreeSieve/dart/README.md
index 7a8baec..d60a944 100644
--- a/benchmarks/SoundSplayTreeSieve/dart/README.md
+++ b/benchmarks/SoundSplayTreeSieve/dart/README.md
@@ -15,17 +15,17 @@
**Dart2JS**
```
-$ sdk/bin/dart2js_developer benchmarks/SoundSplayTreeSieve/dart/SoundSplayTreeSieve.dart --enable-experiment=variance --experiment-new-rti --out=soundsplay_d2js.js
+$ sdk/bin/dart2js_developer benchmarks/SoundSplayTreeSieve/dart/SoundSplayTreeSieve.dart --enable-experiment=variance --out=soundsplay_d2js.js
$ third_party/d8/linux/d8 soundsplay_d2js.js
```
**Dart2JS (Omit implicit checks)**
```
-$ sdk/bin/dart2js_developer benchmarks/SoundSplayTreeSieve/dart/SoundSplayTreeSieve.dart --enable-experiment=variance --experiment-new-rti --omit-implicit-checks --out=soundsplay_d2js_omit.js --lax-runtime-type-to-string
+$ sdk/bin/dart2js_developer benchmarks/SoundSplayTreeSieve/dart/SoundSplayTreeSieve.dart --enable-experiment=variance --omit-implicit-checks --out=soundsplay_d2js_omit.js --lax-runtime-type-to-string
$ third_party/d8/linux/d8 soundsplay_d2js_omit.js
```
**DDK**
```
$ pkg/dev_compiler/tool/ddb -d -r chrome --enable-experiment=variance -k benchmarks/SoundSplayTreeSieve/dart/SoundSplayTreeSieve.dart
-```
\ No newline at end of file
+```
diff --git a/benchmarks/SoundSplayTreeSieve/dart2/README.md b/benchmarks/SoundSplayTreeSieve/dart2/README.md
index 7a8baec..d60a944 100644
--- a/benchmarks/SoundSplayTreeSieve/dart2/README.md
+++ b/benchmarks/SoundSplayTreeSieve/dart2/README.md
@@ -15,17 +15,17 @@
**Dart2JS**
```
-$ sdk/bin/dart2js_developer benchmarks/SoundSplayTreeSieve/dart/SoundSplayTreeSieve.dart --enable-experiment=variance --experiment-new-rti --out=soundsplay_d2js.js
+$ sdk/bin/dart2js_developer benchmarks/SoundSplayTreeSieve/dart/SoundSplayTreeSieve.dart --enable-experiment=variance --out=soundsplay_d2js.js
$ third_party/d8/linux/d8 soundsplay_d2js.js
```
**Dart2JS (Omit implicit checks)**
```
-$ sdk/bin/dart2js_developer benchmarks/SoundSplayTreeSieve/dart/SoundSplayTreeSieve.dart --enable-experiment=variance --experiment-new-rti --omit-implicit-checks --out=soundsplay_d2js_omit.js --lax-runtime-type-to-string
+$ sdk/bin/dart2js_developer benchmarks/SoundSplayTreeSieve/dart/SoundSplayTreeSieve.dart --enable-experiment=variance --omit-implicit-checks --out=soundsplay_d2js_omit.js --lax-runtime-type-to-string
$ third_party/d8/linux/d8 soundsplay_d2js_omit.js
```
**DDK**
```
$ pkg/dev_compiler/tool/ddb -d -r chrome --enable-experiment=variance -k benchmarks/SoundSplayTreeSieve/dart/SoundSplayTreeSieve.dart
-```
\ No newline at end of file
+```
diff --git a/pkg/compiler/lib/src/commandline_options.dart b/pkg/compiler/lib/src/commandline_options.dart
index 9dc830f..e9299e1 100644
--- a/pkg/compiler/lib/src/commandline_options.dart
+++ b/pkg/compiler/lib/src/commandline_options.dart
@@ -58,8 +58,6 @@
static const String experimentCallInstrumentation =
'--experiment-call-instrumentation';
- static const String experimentNewRti = '--experiment-new-rti';
-
static const String enableLanguageExperiments = '--enable-experiment';
static const String fastStartup = '--fast-startup';
@@ -107,7 +105,6 @@
'--experimental-trust-js-interop-type-annotations';
static const String useMultiSourceInfo = '--use-multi-source-info';
static const String useNewSourceInfo = '--use-new-source-info';
- static const String useOldRti = '--use-old-rti';
static const String useSimpleLoadIds = '--simple-load-ids';
static const String verbose = '--verbose';
static const String verbosity = '--verbosity';
diff --git a/pkg/compiler/lib/src/common/elements.dart b/pkg/compiler/lib/src/common/elements.dart
index e68c862..c381ce5 100644
--- a/pkg/compiler/lib/src/common/elements.dart
+++ b/pkg/compiler/lib/src/common/elements.dart
@@ -1109,7 +1109,7 @@
FunctionEntity get specializedAsStringNullable =>
_findRtiFunction('_asStringQ');
- FunctionEntity get instantiatedGenericFunctionTypeNewRti =>
+ FunctionEntity get instantiatedGenericFunctionType =>
_findRtiFunction('instantiatedGenericFunctionType');
FunctionEntity get closureFunctionType =>
diff --git a/pkg/compiler/lib/src/dart2js.dart b/pkg/compiler/lib/src/dart2js.dart
index c08a302..184131c 100644
--- a/pkg/compiler/lib/src/dart2js.dart
+++ b/pkg/compiler/lib/src/dart2js.dart
@@ -531,7 +531,6 @@
_OneOption(Flags.generateCodeWithCompileTimeErrors, ignoreOption),
_OneOption(Flags.useMultiSourceInfo, passThrough),
_OneOption(Flags.useNewSourceInfo, passThrough),
- _OneOption(Flags.useOldRti, passThrough),
_OneOption(Flags.useSimpleLoadIds, passThrough),
_OneOption(Flags.testMode, passThrough),
_OneOption('${Flags.dumpSsa}=.+', passThrough),
@@ -552,7 +551,6 @@
_OneOption(Flags.experimentToBoolean, passThrough),
_OneOption(Flags.experimentUnreachableMethodsThrow, passThrough),
_OneOption(Flags.experimentCallInstrumentation, passThrough),
- _OneOption(Flags.experimentNewRti, ignoreOption),
_OneOption('${Flags.mergeFragmentsThreshold}=.+', passThrough),
// Wire up feature flags.
diff --git a/pkg/compiler/lib/src/deferred_load/entity_data_info.dart b/pkg/compiler/lib/src/deferred_load/entity_data_info.dart
index 98ee3927..908fd96 100644
--- a/pkg/compiler/lib/src/deferred_load/entity_data_info.dart
+++ b/pkg/compiler/lib/src/deferred_load/entity_data_info.dart
@@ -237,7 +237,7 @@
break;
case TypeUseKind.rtiValue:
case TypeUseKind.typeArgument:
- case TypeUseKind.namedTypeVariableNewRti:
+ case TypeUseKind.namedTypeVariable:
case TypeUseKind.constructorReference:
failedAt(parent!, "Unexpected type use: $typeUse.");
}
diff --git a/pkg/compiler/lib/src/js_backend/backend_impact.dart b/pkg/compiler/lib/src/js_backend/backend_impact.dart
index df333c9..4094674 100644
--- a/pkg/compiler/lib/src/js_backend/backend_impact.dart
+++ b/pkg/compiler/lib/src/js_backend/backend_impact.dart
@@ -98,7 +98,7 @@
late final BackendImpact getRuntimeTypeArgument = BackendImpact(
globalUses: [],
- otherImpacts: [newRtiImpact],
+ otherImpacts: [rtiImpact],
);
late final BackendImpact computeSignature = BackendImpact(
@@ -153,7 +153,7 @@
late final BackendImpact asCheck = BackendImpact(
staticUses: [],
- otherImpacts: [newRtiImpact],
+ otherImpacts: [rtiImpact],
);
late final BackendImpact stringValues = BackendImpact(
@@ -322,7 +322,7 @@
);
late final BackendImpact typeCheck = BackendImpact(
- otherImpacts: [boolValues, newRtiImpact],
+ otherImpacts: [boolValues, rtiImpact],
);
late final BackendImpact genericTypeCheck = BackendImpact(
@@ -330,26 +330,26 @@
// TODO(johnniwinther): Investigate why this is needed.
_commonElements.setArrayType,
],
- otherImpacts: [listValues, getRuntimeTypeArgument, newRtiImpact],
+ otherImpacts: [listValues, getRuntimeTypeArgument, rtiImpact],
);
late final BackendImpact genericIsCheck = BackendImpact(
- otherImpacts: [intValues, newRtiImpact],
+ otherImpacts: [intValues, rtiImpact],
);
late final BackendImpact typeVariableTypeCheck = BackendImpact(
staticUses: [],
- otherImpacts: [newRtiImpact],
+ otherImpacts: [rtiImpact],
);
late final BackendImpact functionTypeCheck = BackendImpact(
staticUses: [/*helpers.functionTypeTestMetaHelper*/],
- otherImpacts: [newRtiImpact],
+ otherImpacts: [rtiImpact],
);
late final BackendImpact futureOrTypeCheck = BackendImpact(
staticUses: [],
- otherImpacts: [newRtiImpact],
+ otherImpacts: [rtiImpact],
);
late final BackendImpact nativeTypeCheck = BackendImpact(
@@ -359,7 +359,7 @@
// [:defineProperty:] is compiled.
_commonElements.defineProperty,
],
- otherImpacts: [newRtiImpact],
+ otherImpacts: [rtiImpact],
);
late final BackendImpact closure = BackendImpact(
@@ -532,7 +532,7 @@
_genericInstantiation[typeArgumentCount] ??= BackendImpact(
staticUses: [
_commonElements.getInstantiateFunction(typeArgumentCount),
- _commonElements.instantiatedGenericFunctionTypeNewRti,
+ _commonElements.instantiatedGenericFunctionType,
_commonElements.closureFunctionType,
],
instantiatedClasses: [
@@ -541,7 +541,7 @@
);
// TODO(sra): Split into refined impacts.
- late final BackendImpact newRtiImpact = BackendImpact(
+ late final BackendImpact rtiImpact = BackendImpact(
staticUses: [
if (_options.interopNullAssertions) _commonElements.interopNullAssertion,
_commonElements.findType,
diff --git a/pkg/compiler/lib/src/js_backend/codegen_listener.dart b/pkg/compiler/lib/src/js_backend/codegen_listener.dart
index bd63d78..eb9653d 100644
--- a/pkg/compiler/lib/src/js_backend/codegen_listener.dart
+++ b/pkg/compiler/lib/src/js_backend/codegen_listener.dart
@@ -45,7 +45,7 @@
final CodegenWorldBuilder _worldBuilder;
bool _isNoSuchMethodUsed = false;
- bool _isNewRtiUsed = false;
+ bool _isRtiUsed = false;
CodegenEnqueuerListener(
this._options,
@@ -149,30 +149,30 @@
}
// TODO(fishythefish): Avoid registering unnecessary impacts.
- if (!_isNewRtiUsed) {
- WorldImpactBuilderImpl newRtiImpact = WorldImpactBuilderImpl();
- newRtiImpact.registerStaticUse(
+ if (!_isRtiUsed) {
+ WorldImpactBuilderImpl rtiImpact = WorldImpactBuilderImpl();
+ rtiImpact.registerStaticUse(
StaticUse.staticInvoke(
_commonElements.rtiAddRulesMethod,
CallStructure.twoArgs,
),
);
- newRtiImpact.registerStaticUse(
+ rtiImpact.registerStaticUse(
StaticUse.staticInvoke(
_commonElements.rtiAddErasedTypesMethod,
CallStructure.twoArgs,
),
);
if (_options.enableVariance) {
- newRtiImpact.registerStaticUse(
+ rtiImpact.registerStaticUse(
StaticUse.staticInvoke(
_commonElements.rtiAddTypeParameterVariancesMethod,
CallStructure.twoArgs,
),
);
}
- enqueuer.applyImpact(newRtiImpact);
- _isNewRtiUsed = true;
+ enqueuer.applyImpact(rtiImpact);
+ _isRtiUsed = true;
}
if (_nativeData.isAllowInteropUsed) {
@@ -257,7 +257,7 @@
impactBuilder.registerStaticUse(
StaticUse.staticInvoke(
- _commonElements.instantiatedGenericFunctionTypeNewRti,
+ _commonElements.instantiatedGenericFunctionType,
CallStructure.twoArgs,
),
);
diff --git a/pkg/compiler/lib/src/js_backend/constant_emitter.dart b/pkg/compiler/lib/src/js_backend/constant_emitter.dart
index 5ed468f..6a91a64 100644
--- a/pkg/compiler/lib/src/js_backend/constant_emitter.dart
+++ b/pkg/compiler/lib/src/js_backend/constant_emitter.dart
@@ -273,7 +273,7 @@
.toList(growable: false);
js_ast.ArrayInitializer array = js_ast.ArrayInitializer(elements);
js_ast.Expression value = _makeConstantList(array);
- return maybeAddListTypeArgumentsNewRti(constant, constant.type, value);
+ return maybeAddListTypeArguments(constant, constant.type, value);
}
@override
@@ -296,7 +296,7 @@
_constantReferenceGenerator(constant.indexObject!),
js.number(constant.length),
if (_rtiNeed.classNeedsTypeArguments(classElement))
- _reifiedTypeNewRti(sourceType),
+ _reifiedType(sourceType),
];
js_ast.Expression constructor = _emitter.constructorAccess(classElement);
return js_ast.New(constructor, arguments);
@@ -313,7 +313,7 @@
_constantReferenceGenerator(value),
]),
if (_rtiNeed.classNeedsTypeArguments(classElement))
- _reifiedTypeNewRti(sourceType),
+ _reifiedType(sourceType),
];
js_ast.Expression constructor = _emitter.constructorAccess(classElement);
return js_ast.New(constructor, arguments);
@@ -412,7 +412,7 @@
}
if (_rtiNeed.classNeedsTypeArguments(classElement)) {
- arguments.add(_reifiedTypeNewRti(constant.type));
+ arguments.add(_reifiedType(constant.type));
}
js_ast.Expression constructor = _emitter.constructorAccess(classElement);
@@ -491,7 +491,7 @@
}
});
if (_rtiNeed.classNeedsTypeArguments(constant.type.element)) {
- fields.add(_reifiedTypeNewRti(constant.type));
+ fields.add(_reifiedType(constant.type));
}
return js_ast.New(constructor, fields);
}
@@ -527,7 +527,7 @@
_constantReferenceGenerator(constant.function),
];
fields.add(
- _reifiedTypeNewRti(
+ _reifiedType(
_commonElements.dartTypes.interfaceType(cls, constant.typeArguments),
),
);
@@ -539,7 +539,7 @@
return rawJavaScript.replaceAll(commentRE, '');
}
- js_ast.Expression maybeAddListTypeArgumentsNewRti(
+ js_ast.Expression maybeAddListTypeArguments(
ConstantValue constant,
InterfaceType type,
js_ast.Expression value,
@@ -548,13 +548,13 @@
if (_rtiNeed.classNeedsTypeArguments(type.element)) {
return js_ast.Call(getHelperProperty(_commonElements.setArrayType), [
value,
- _reifiedTypeNewRti(type),
+ _reifiedType(type),
]);
}
return value;
}
- js_ast.Expression _reifiedTypeNewRti(DartType type) {
+ js_ast.Expression _reifiedType(DartType type) {
assert(!type.containsTypeVariables);
return TypeReference(TypeExpressionRecipe(type))..forConstant = true;
}
diff --git a/pkg/compiler/lib/src/js_backend/enqueuer.dart b/pkg/compiler/lib/src/js_backend/enqueuer.dart
index ccc3648..1f710b6 100644
--- a/pkg/compiler/lib/src/js_backend/enqueuer.dart
+++ b/pkg/compiler/lib/src/js_backend/enqueuer.dart
@@ -240,8 +240,8 @@
break;
case TypeUseKind.constInstantiation:
failedAt(currentElementSpannable, "Unexpected type use: $typeUse.");
- case TypeUseKind.namedTypeVariableNewRti:
- _registerNamedTypeVariableNewRti(type as TypeVariableType);
+ case TypeUseKind.namedTypeVariable:
+ _registerNamedTypeVariable(type as TypeVariableType);
break;
}
}
@@ -260,8 +260,8 @@
worldBuilder.registerIsCheck(type);
}
- void _registerNamedTypeVariableNewRti(TypeVariableType type) {
- worldBuilder.registerNamedTypeVariableNewRti(type);
+ void _registerNamedTypeVariable(TypeVariableType type) {
+ worldBuilder.registerNamedTypeVariable(type);
}
void _registerClosurizedMember(FunctionEntity element) {
diff --git a/pkg/compiler/lib/src/js_backend/runtime_types_new.dart b/pkg/compiler/lib/src/js_backend/runtime_types_new.dart
index 77b817f..6b73c23 100644
--- a/pkg/compiler/lib/src/js_backend/runtime_types_new.dart
+++ b/pkg/compiler/lib/src/js_backend/runtime_types_new.dart
@@ -259,7 +259,7 @@
return;
}
- js_ast.Name name = _emitter.typeVariableAccessNewRti(type.element);
+ js_ast.Name name = _emitter.typeVariableAccess(type.element);
_emitName(name);
typeVariables.add(type);
return;
@@ -295,7 +295,7 @@
@override
void visitInterfaceType(InterfaceType type, _) {
- js_ast.Name name = _emitter.typeAccessNewRti(type.element);
+ js_ast.Name name = _emitter.typeAccess(type.element);
if (type.typeArguments.isEmpty) {
// Push the name, which is later converted by an implicit toType
// operation.
@@ -543,11 +543,11 @@
MapEntry<ClassEntity, ClassEntity> redirection,
) => js.concatenateStrings([
_doubleQuote,
- _emitter.typeAccessNewRti(redirection.key),
+ _emitter.typeAccess(redirection.key),
_doubleQuote,
_colon,
_doubleQuote,
- _emitter.typeAccessNewRti(redirection.value),
+ _emitter.typeAccess(redirection.value),
_doubleQuote,
]);
@@ -555,7 +555,7 @@
MapEntry<InterfaceType, _RulesetEntry> entry,
) => js.concatenateStrings([
_doubleQuote,
- _emitter.typeAccessNewRti(entry.key.element),
+ _emitter.typeAccess(entry.key.element),
_doubleQuote,
_colon,
_leftBrace,
@@ -576,7 +576,7 @@
InterfaceType supertype,
) => js.concatenateStrings([
_doubleQuote,
- _emitter.typeAccessNewRti(supertype.element),
+ _emitter.typeAccess(supertype.element),
_doubleQuote,
_colon,
_leftBracket,
@@ -596,7 +596,7 @@
DartType supertypeArgument,
) => js.concatenateStrings([
_doubleQuote,
- _emitter.typeVariableAccessNewRti(typeVariable.element),
+ _emitter.typeVariableAccess(typeVariable.element),
_doubleQuote,
_colon,
_encodeSupertypeArgument(targetType, supertypeArgument),
@@ -627,7 +627,7 @@
MapEntry<ClassEntity, int> entry,
) => js.concatenateStrings([
_doubleQuote,
- _emitter.typeAccessNewRti(entry.key),
+ _emitter.typeAccess(entry.key),
_doubleQuote,
_colon,
js.number(entry.value),
@@ -648,7 +648,7 @@
MapEntry<ClassEntity, List<Variance>> classEntry,
) => js.concatenateStrings([
_doubleQuote,
- _emitter.typeAccessNewRti(classEntry.key),
+ _emitter.typeAccess(classEntry.key),
_doubleQuote,
_colon,
_leftBracket,
@@ -710,4 +710,4 @@
bool mustCheckAllSubtypes(JClosedWorld world, ClassEntity cls) =>
world.isUsedAsMixin(cls) ||
- world.extractTypeArgumentsInterfacesNewRti.contains(cls);
+ world.extractTypeArgumentsInterfaces.contains(cls);
diff --git a/pkg/compiler/lib/src/js_emitter/code_emitter_task.dart b/pkg/compiler/lib/src/js_emitter/code_emitter_task.dart
index 5b70270..5b1f4df 100644
--- a/pkg/compiler/lib/src/js_emitter/code_emitter_task.dart
+++ b/pkg/compiler/lib/src/js_emitter/code_emitter_task.dart
@@ -178,10 +178,10 @@
js_ast.Expression constructorAccess(ClassEntity e);
/// Returns the JS name representing the type [e].
- js_ast.Name typeAccessNewRti(ClassEntity e);
+ js_ast.Name typeAccess(ClassEntity e);
/// Returns the JS name representing the type variable [e].
- js_ast.Name typeVariableAccessNewRti(TypeVariableEntity e);
+ js_ast.Name typeVariableAccess(TypeVariableEntity e);
/// Returns the JS code for accessing the embedded [global].
js_ast.Expression generateEmbeddedGlobalAccess(String global);
diff --git a/pkg/compiler/lib/src/js_emitter/instantiation_stub_generator.dart b/pkg/compiler/lib/src/js_emitter/instantiation_stub_generator.dart
index 46e64e9..78003e5 100644
--- a/pkg/compiler/lib/src/js_emitter/instantiation_stub_generator.dart
+++ b/pkg/compiler/lib/src/js_emitter/instantiation_stub_generator.dart
@@ -114,7 +114,7 @@
///
/// ```
/// $signature:: function() {
- /// return H.instantiatedGenericFunctionTypeNewRti(
+ /// return H.instantiatedGenericFunctionType(
/// H.closureFunctionType(this._genericClosure),
/// this.$ti);
/// }
@@ -124,7 +124,7 @@
_namer.fixedNames.operatorSignature,
);
- js_ast.Fun function = _generateSignatureNewRti(functionField);
+ js_ast.Fun function = _generateSignature(functionField);
// TODO(sra): Generate source information for stub that has no member.
// TODO(sra): .withSourceInformation(sourceInformation);
@@ -137,10 +137,10 @@
);
}
- js_ast.Fun _generateSignatureNewRti(FieldEntity functionField) =>
+ js_ast.Fun _generateSignature(FieldEntity functionField) =>
js('function() { return #(#(this.#), this.#); }', [
_emitter.staticFunctionAccess(
- _commonElements.instantiatedGenericFunctionTypeNewRti,
+ _commonElements.instantiatedGenericFunctionType,
),
_emitter.staticFunctionAccess(_commonElements.closureFunctionType),
_namer.instanceFieldPropertyName(functionField),
diff --git a/pkg/compiler/lib/src/js_emitter/metadata_collector.dart b/pkg/compiler/lib/src/js_emitter/metadata_collector.dart
index 00ae9ad..b61e5dc 100644
--- a/pkg/compiler/lib/src/js_emitter/metadata_collector.dart
+++ b/pkg/compiler/lib/src/js_emitter/metadata_collector.dart
@@ -145,7 +145,7 @@
return _addTypeInOutputUnit(type, outputUnit);
}
- js_ast.Expression _computeTypeRepresentationNewRti(DartType type) {
+ js_ast.Expression _computeTypeRepresentation(DartType type) {
return _rtiRecipeEncoder.encodeGroundRecipe(
_emitter,
TypeExpressionRecipe(type),
@@ -156,7 +156,7 @@
final typeMap = _typesMap[outputUnit] ??= {};
final metadataEntryList =
(typeMap[type] ??= [
- BoundMetadataEntry(_computeTypeRepresentationNewRti(type)),
+ BoundMetadataEntry(_computeTypeRepresentation(type)),
]);
return metadataEntryList.single;
}
diff --git a/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart b/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
index 1fd0591..33ca725 100644
--- a/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
+++ b/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
@@ -101,7 +101,7 @@
/// True if the program should store function types in the metadata.
bool _storeFunctionTypesInMetadata = false;
- final Set<TypeVariableType> _lateNamedTypeVariablesNewRti = {};
+ final Set<TypeVariableType> _lateNamedTypeVariables = {};
ClassHierarchy get _classHierarchy => _closedWorld.classHierarchy;
DartTypes get _dartTypes => _closedWorld.dartTypes;
@@ -262,7 +262,7 @@
_markEagerClasses();
- associateNamedTypeVariablesNewRti();
+ associateNamedTypeVariables();
bool needsNativeSupport =
_nativeCodegenEnqueuer.hasInstantiatedNativeClasses ||
@@ -914,9 +914,9 @@
() => ClassTypeData(cls, _rtiChecks.requiredChecks[cls]),
);
- void associateNamedTypeVariablesNewRti() {
- for (TypeVariableType typeVariable in _codegenWorld.namedTypeVariablesNewRti
- .union(_lateNamedTypeVariablesNewRti)) {
+ void associateNamedTypeVariables() {
+ for (TypeVariableType typeVariable in _codegenWorld.namedTypeVariables
+ .union(_lateNamedTypeVariables)) {
final declaration = typeVariable.element.typeDeclaration as ClassEntity;
Iterable<ClassEntity> subtypes =
new_rti.mustCheckAllSubtypes(_closedWorld, declaration)
@@ -1086,12 +1086,6 @@
ClassEntity? enclosingClass,
FunctionType type,
OutputUnit outputUnit,
- ) => _generateFunctionTypeNewRti(enclosingClass, type, outputUnit);
-
- js.Expression _generateFunctionTypeNewRti(
- ClassEntity? enclosingClass,
- FunctionType type,
- OutputUnit outputUnit,
) {
InterfaceType? enclosingType;
if (enclosingClass != null && type.containsTypeVariables) {
@@ -1118,7 +1112,7 @@
FullTypeEnvironmentStructure(classType: enclosingType),
TypeExpressionRecipe(type),
);
- _lateNamedTypeVariablesNewRti.addAll(encoding.typeVariables);
+ _lateNamedTypeVariables.addAll(encoding.typeVariables);
return encoding.recipe;
} else {
return _task.metadataCollector.reifyType(type, outputUnit);
diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/emitter.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/emitter.dart
index 34e9ec0..4edfb3a 100644
--- a/pkg/compiler/lib/src/js_emitter/startup_emitter/emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/emitter.dart
@@ -79,12 +79,12 @@
}
@override
- js.Name typeAccessNewRti(ClassEntity element) {
+ js.Name typeAccess(ClassEntity element) {
return _namer.className(element);
}
@override
- js.Name typeVariableAccessNewRti(TypeVariableEntity element) {
+ js.Name typeVariableAccess(TypeVariableEntity element) {
return _namer.globalNameForInterfaceTypeVariable(element);
}
diff --git a/pkg/compiler/lib/src/js_model/js_world.dart b/pkg/compiler/lib/src/js_model/js_world.dart
index 3de8f3d..773602a 100644
--- a/pkg/compiler/lib/src/js_model/js_world.dart
+++ b/pkg/compiler/lib/src/js_model/js_world.dart
@@ -101,7 +101,7 @@
/// Returns the set of interfaces passed as type arguments to the internal
/// `extractTypeArguments` function.
- final Set<ClassEntity> extractTypeArgumentsInterfacesNewRti;
+ final Set<ClassEntity> extractTypeArgumentsInterfaces;
final ClassHierarchy classHierarchy;
@@ -133,7 +133,7 @@
this.liveAbstractInstanceMembers,
this.assignedInstanceMembers,
this.processedMembers,
- this.extractTypeArgumentsInterfacesNewRti,
+ this.extractTypeArgumentsInterfaces,
this.mixinUses,
this.typesImplementedBySubclasses,
this.classHierarchy,
@@ -192,7 +192,7 @@
Set<ClassEntity> implementedClasses = source.readClasses().toSet();
Set<ClassEntity> liveNativeClasses = source.readClasses().toSet();
- Set<ClassEntity> extractTypeArgumentsInterfacesNewRti =
+ Set<ClassEntity> extractTypeArgumentsInterfaces =
source.readClasses().toSet();
Set<MemberEntity> liveInstanceMembers = source.readMembers().toSet();
Set<MemberEntity> liveAbstractInstanceMembers =
@@ -242,7 +242,7 @@
liveAbstractInstanceMembers,
assignedInstanceMembers,
processedMembers,
- extractTypeArgumentsInterfacesNewRti,
+ extractTypeArgumentsInterfaces,
mixinUses,
typesImplementedBySubclasses,
classHierarchy,
@@ -268,7 +268,7 @@
noSuchMethodData.writeToDataSink(sink);
sink.writeClasses(implementedClasses);
sink.writeClasses(liveNativeClasses);
- sink.writeClasses(extractTypeArgumentsInterfacesNewRti);
+ sink.writeClasses(extractTypeArgumentsInterfaces);
sink.writeMembers(liveInstanceMembers);
sink.writeMembers(liveAbstractInstanceMembers);
sink.writeMembers(assignedInstanceMembers);
@@ -704,7 +704,7 @@
/// Registers [interface] as a type argument to `extractTypeArguments`.
void registerExtractTypeArguments(ClassEntity interface) {
- extractTypeArgumentsInterfacesNewRti.add(interface);
+ extractTypeArgumentsInterfaces.add(interface);
}
late final Set<ClassEntity> _defaultSuperclasses = {
diff --git a/pkg/compiler/lib/src/js_model/js_world_builder.dart b/pkg/compiler/lib/src/js_model/js_world_builder.dart
index e05dc73..f0cc48c 100644
--- a/pkg/compiler/lib/src/js_model/js_world_builder.dart
+++ b/pkg/compiler/lib/src/js_model/js_world_builder.dart
@@ -150,7 +150,7 @@
closedWorld.liveMemberUsage.keys,
);
- Set<ClassEntity> extractTypeArgumentsInterfacesNewRti = {};
+ Set<ClassEntity> extractTypeArgumentsInterfaces = {};
RuntimeTypesNeed rtiNeed;
@@ -281,7 +281,7 @@
liveAbstractInstanceMembers,
assignedInstanceMembers,
processedMembers,
- extractTypeArgumentsInterfacesNewRti,
+ extractTypeArgumentsInterfaces,
mixinUses,
typesImplementedBySubclasses,
ClassHierarchyImpl(
diff --git a/pkg/compiler/lib/src/kernel/kernel_world.dart b/pkg/compiler/lib/src/kernel/kernel_world.dart
index 34c3f47..03a3199 100644
--- a/pkg/compiler/lib/src/kernel/kernel_world.dart
+++ b/pkg/compiler/lib/src/kernel/kernel_world.dart
@@ -61,7 +61,7 @@
final Set<DartType> isChecks;
@override
- final Set<TypeVariableType> namedTypeVariablesNewRti;
+ final Set<TypeVariableType> namedTypeVariables;
final Map<Entity, Set<DartType>> staticTypeArgumentDependencies;
@@ -114,7 +114,7 @@
required this.classHierarchy,
required this.annotationsData,
required this.isChecks,
- required this.namedTypeVariablesNewRti,
+ required this.namedTypeVariables,
required this.staticTypeArgumentDependencies,
required this.dynamicTypeArgumentDependencies,
required this.typeVariableTypeLiterals,
diff --git a/pkg/compiler/lib/src/resolution/enqueuer.dart b/pkg/compiler/lib/src/resolution/enqueuer.dart
index 60c684d..1a128a3 100644
--- a/pkg/compiler/lib/src/resolution/enqueuer.dart
+++ b/pkg/compiler/lib/src/resolution/enqueuer.dart
@@ -256,8 +256,8 @@
case TypeUseKind.typeArgument:
case TypeUseKind.constructorReference:
failedAt(currentElementSpannable, "Unexpected type use: $typeUse.");
- case TypeUseKind.namedTypeVariableNewRti:
- _registerNamedTypeVariableNewRti(type as TypeVariableType);
+ case TypeUseKind.namedTypeVariable:
+ _registerNamedTypeVariable(type as TypeVariableType);
break;
}
}
@@ -270,8 +270,8 @@
worldBuilder.registerIsCheck(type);
}
- void _registerNamedTypeVariableNewRti(TypeVariableType type) {
- worldBuilder.registerNamedTypeVariableNewRti(type);
+ void _registerNamedTypeVariable(TypeVariableType type) {
+ worldBuilder.registerNamedTypeVariable(type);
}
void _registerClosurizedMember(FunctionEntity element) {
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index 849e50e..646a5cd 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -568,7 +568,7 @@
"$targetElement inside a non-closure: $target",
);
}
- _buildMethodSignatureNewRti(originalClosureNode);
+ _buildMethodSignature(originalClosureNode);
break;
case MemberKind.parameterStub:
_buildParameterStub(
@@ -1380,7 +1380,7 @@
}
/// Constructs a special signature function for a closure.
- void _buildMethodSignatureNewRti(ir.FunctionNode originalClosureNode) {
+ void _buildMethodSignature(ir.FunctionNode originalClosureNode) {
// The signature function has no corresponding ir.Node, so we just use the
// targetElement to set up the type environment.
_openFunction(targetElement, checks: TargetChecks.none);
diff --git a/pkg/compiler/lib/src/ssa/codegen.dart b/pkg/compiler/lib/src/ssa/codegen.dart
index 8341e1f..26fabe4 100644
--- a/pkg/compiler/lib/src/ssa/codegen.dart
+++ b/pkg/compiler/lib/src/ssa/codegen.dart
@@ -3880,7 +3880,7 @@
js.Expression recipe = encoding.recipe;
for (TypeVariableType typeVariable in encoding.typeVariables) {
- _registry.registerTypeUse(TypeUse.namedTypeVariableNewRti(typeVariable));
+ _registry.registerTypeUse(TypeUse.namedTypeVariable(typeVariable));
}
final method = _commonElements.rtiEvalMethod;
diff --git a/pkg/compiler/lib/src/ssa/ssa.dart b/pkg/compiler/lib/src/ssa/ssa.dart
index 2e2f98b..01959eb 100644
--- a/pkg/compiler/lib/src/ssa/ssa.dart
+++ b/pkg/compiler/lib/src/ssa/ssa.dart
@@ -250,7 +250,7 @@
/// added as a function parameter to the rewritten code.
// TODO(sra): We could also return an empty list if the generator takes no
// type (e.g. due to rtiNeed optimization).
- List<js.Expression>? _fetchItemTypeNewRti(
+ List<js.Expression>? _fetchItemType(
CommonElements commonElements,
CodegenRegistry registry,
DartType? type,
@@ -277,7 +277,7 @@
FunctionEntity startFunction = commonElements.asyncHelperStartSync;
FunctionEntity completerFactory = commonElements.asyncAwaitCompleterFactory;
- final itemTypeExpression = _fetchItemTypeNewRti(
+ final itemTypeExpression = _fetchItemType(
commonElements,
registry,
elementType,
@@ -353,7 +353,7 @@
DartType? asyncTypeParameter,
js.Name name,
) {
- final itemTypeExpression = _fetchItemTypeNewRti(
+ final itemTypeExpression = _fetchItemType(
commonElements,
registry,
asyncTypeParameter,
diff --git a/pkg/compiler/lib/src/universe/codegen_world_builder.dart b/pkg/compiler/lib/src/universe/codegen_world_builder.dart
index 81bfb60..fa9f49f 100644
--- a/pkg/compiler/lib/src/universe/codegen_world_builder.dart
+++ b/pkg/compiler/lib/src/universe/codegen_world_builder.dart
@@ -161,7 +161,7 @@
final Set<DartType> _constTypeLiterals = {};
final Set<DartType> _liveTypeArguments = {};
- final Set<TypeVariableType> _namedTypeVariablesNewRti = {};
+ final Set<TypeVariableType> _namedTypeVariables = {};
final Set<ClassEntity> _constructorReferences = {};
final Map<FunctionEntity, List<JParameterStub>> _parameterStubs = {};
@@ -362,8 +362,8 @@
_isChecks.add(type);
}
- void registerNamedTypeVariableNewRti(TypeVariableType type) {
- _namedTypeVariablesNewRti.add(type);
+ void registerNamedTypeVariable(TypeVariableType type) {
+ _namedTypeVariables.add(type);
}
void registerStaticUse(StaticUse staticUse, MemberUsedCallback memberUsed) {
@@ -884,7 +884,7 @@
typeVariableTypeLiterals: typeVariableTypeLiterals,
instantiatedClasses: instantiatedClasses,
isChecks: _isChecks,
- namedTypeVariablesNewRti: _namedTypeVariablesNewRti,
+ namedTypeVariables: _namedTypeVariables,
instantiatedTypes: _instantiatedTypes,
liveTypeArguments: _liveTypeArguments,
compiledConstants: _compiledConstants,
@@ -924,7 +924,7 @@
final Iterable<DartType> isChecks;
@override
- final Set<TypeVariableType> namedTypeVariablesNewRti;
+ final Set<TypeVariableType> namedTypeVariables;
@override
final Iterable<InterfaceType> instantiatedTypes;
@@ -959,7 +959,7 @@
required this.typeVariableTypeLiterals,
required this.instantiatedClasses,
required this.isChecks,
- required this.namedTypeVariablesNewRti,
+ required this.namedTypeVariables,
required this.instantiatedTypes,
required this.liveTypeArguments,
required Map<FunctionEntity, List<JParameterStub>> parameterStubs,
diff --git a/pkg/compiler/lib/src/universe/resolution_world_builder.dart b/pkg/compiler/lib/src/universe/resolution_world_builder.dart
index 60949af..8fd33d8 100644
--- a/pkg/compiler/lib/src/universe/resolution_world_builder.dart
+++ b/pkg/compiler/lib/src/universe/resolution_world_builder.dart
@@ -241,7 +241,7 @@
final Set<FieldEntity> _fieldSetters = {};
final Set<DartType> _isChecks = {};
- final Set<TypeVariableType> _namedTypeVariablesNewRti = {};
+ final Set<TypeVariableType> _namedTypeVariables = {};
final Set<RecordType> _instantiatedRecordTypes = {};
@@ -563,8 +563,8 @@
_isChecks.add(type);
}
- void registerNamedTypeVariableNewRti(TypeVariableType type) {
- _namedTypeVariablesNewRti.add(type);
+ void registerNamedTypeVariable(TypeVariableType type) {
+ _namedTypeVariables.add(type);
}
/// Register the constant [use] with this world builder. Returns `true` if
@@ -1115,7 +1115,7 @@
localFunctions: _localFunctions,
instantiatedTypes: instantiatedTypes,
instantiatedRecordTypes: _instantiatedRecordTypes,
- namedTypeVariablesNewRti: _namedTypeVariablesNewRti,
+ namedTypeVariables: _namedTypeVariables,
);
if (retainDataForTesting) {
_closedWorldCache = closedWorld;
diff --git a/pkg/compiler/lib/src/universe/use.dart b/pkg/compiler/lib/src/universe/use.dart
index b33ea06..90fa7934 100644
--- a/pkg/compiler/lib/src/universe/use.dart
+++ b/pkg/compiler/lib/src/universe/use.dart
@@ -964,7 +964,7 @@
parameterCheck,
rtiValue,
typeArgument,
- namedTypeVariableNewRti,
+ namedTypeVariable,
typeVariableBoundCheck,
}
@@ -1041,7 +1041,7 @@
case TypeUseKind.typeArgument:
sb.write('typeArg:');
break;
- case TypeUseKind.namedTypeVariableNewRti:
+ case TypeUseKind.namedTypeVariable:
sb.write('named:');
break;
case TypeUseKind.typeVariableBoundCheck:
@@ -1141,8 +1141,8 @@
}
/// [type] used as a named type variable in a recipe.
- factory TypeUse.namedTypeVariableNewRti(TypeVariableType type) =>
- TypeUse.internal(type, TypeUseKind.namedTypeVariableNewRti);
+ factory TypeUse.namedTypeVariable(TypeVariableType type) =>
+ TypeUse.internal(type, TypeUseKind.namedTypeVariable);
/// [type] used as a bound on a type variable.
factory TypeUse.typeVariableBoundCheck(DartType type) =>
diff --git a/pkg/compiler/lib/src/world.dart b/pkg/compiler/lib/src/world.dart
index a1fbdc0..9f4e1d8 100644
--- a/pkg/compiler/lib/src/world.dart
+++ b/pkg/compiler/lib/src/world.dart
@@ -22,7 +22,7 @@
Iterable<DartType> get isChecks;
/// All type variables named in recipes.
- Set<TypeVariableType> get namedTypeVariablesNewRti;
+ Set<TypeVariableType> get namedTypeVariables;
/// All directly instantiated types, that is, the types of
/// [directlyInstantiatedClasses].
diff --git a/sdk/lib/_internal/js_runtime/lib/instantiation.dart b/sdk/lib/_internal/js_runtime/lib/instantiation.dart
index bcf943f..8baf79f 100644
--- a/sdk/lib/_internal/js_runtime/lib/instantiation.dart
+++ b/sdk/lib/_internal/js_runtime/lib/instantiation.dart
@@ -18,7 +18,7 @@
if (JS('bool', 'false')) {
// [instantiatedGenericFunctionType] is called from injected $signature
// methods with runtime type representations.
- newRti.instantiatedGenericFunctionType(JS('', '0'), JS('', '0'));
+ rti.instantiatedGenericFunctionType(JS('', '0'), JS('', '0'));
}
}
@@ -107,133 +107,318 @@
List get _types => [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12];
}
-final class Instantiation13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
- T13> extends Instantiation {
+final class Instantiation13<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13
+>
+ extends Instantiation {
Instantiation13(Closure f) : super(f);
List get _types => [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13];
}
-final class Instantiation14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
- T13, T14> extends Instantiation {
+final class Instantiation14<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14
+>
+ extends Instantiation {
Instantiation14(Closure f) : super(f);
- List get _types =>
- [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14];
+ List get _types => [
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ ];
}
-final class Instantiation15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
- T13, T14, T15> extends Instantiation {
+final class Instantiation15<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15
+>
+ extends Instantiation {
Instantiation15(Closure f) : super(f);
- List get _types =>
- [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15];
+ List get _types => [
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ ];
}
-final class Instantiation16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
- T13, T14, T15, T16> extends Instantiation {
+final class Instantiation16<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16
+>
+ extends Instantiation {
Instantiation16(Closure f) : super(f);
- List get _types =>
- [T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16];
+ List get _types => [
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16,
+ ];
}
-final class Instantiation17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
- T13, T14, T15, T16, T17> extends Instantiation {
+final class Instantiation17<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16,
+ T17
+>
+ extends Instantiation {
Instantiation17(Closure f) : super(f);
List get _types => [
- T1,
- T2,
- T3,
- T4,
- T5,
- T6,
- T7,
- T8,
- T9,
- T10,
- T11,
- T12,
- T13,
- T14,
- T15,
- T16,
- T17
- ];
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16,
+ T17,
+ ];
}
-final class Instantiation18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
- T13, T14, T15, T16, T17, T18> extends Instantiation {
+final class Instantiation18<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16,
+ T17,
+ T18
+>
+ extends Instantiation {
Instantiation18(Closure f) : super(f);
List get _types => [
- T1,
- T2,
- T3,
- T4,
- T5,
- T6,
- T7,
- T8,
- T9,
- T10,
- T11,
- T12,
- T13,
- T14,
- T15,
- T16,
- T17,
- T18
- ];
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16,
+ T17,
+ T18,
+ ];
}
-final class Instantiation19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
- T13, T14, T15, T16, T17, T18, T19> extends Instantiation {
+final class Instantiation19<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16,
+ T17,
+ T18,
+ T19
+>
+ extends Instantiation {
Instantiation19(Closure f) : super(f);
List get _types => [
- T1,
- T2,
- T3,
- T4,
- T5,
- T6,
- T7,
- T8,
- T9,
- T10,
- T11,
- T12,
- T13,
- T14,
- T15,
- T16,
- T17,
- T18,
- T19
- ];
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16,
+ T17,
+ T18,
+ T19,
+ ];
}
-final class Instantiation20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
- T13, T14, T15, T16, T17, T18, T19, T20> extends Instantiation {
+final class Instantiation20<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16,
+ T17,
+ T18,
+ T19,
+ T20
+>
+ extends Instantiation {
Instantiation20(Closure f) : super(f);
List get _types => [
- T1,
- T2,
- T3,
- T4,
- T5,
- T6,
- T7,
- T8,
- T9,
- T10,
- T11,
- T12,
- T13,
- T14,
- T15,
- T16,
- T17,
- T18,
- T19,
- T20
- ];
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16,
+ T17,
+ T18,
+ T19,
+ T20,
+ ];
}
Instantiation instantiate1<T1>(Closure f) {
@@ -273,66 +458,331 @@
}
Instantiation instantiate10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
- Closure f) {
+ Closure f,
+) {
return Instantiation10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(f);
}
Instantiation instantiate11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(
- Closure f) {
+ Closure f,
+) {
return Instantiation11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(f);
}
Instantiation instantiate12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(
- Closure f) {
+ Closure f,
+) {
return Instantiation12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(f);
}
-Instantiation
- instantiate13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(
- Closure f) {
- return Instantiation13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
- T13>(f);
+Instantiation instantiate13<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13
+>(Closure f) {
+ return Instantiation13<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13
+ >(f);
}
-Instantiation
- instantiate14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(
- Closure f) {
- return Instantiation14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
- T14>(f);
+Instantiation instantiate14<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14
+>(Closure f) {
+ return Instantiation14<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14
+ >(f);
}
-Instantiation instantiate15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
- T13, T14, T15>(Closure f) {
- return Instantiation15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
- T14, T15>(f);
+Instantiation instantiate15<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15
+>(Closure f) {
+ return Instantiation15<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15
+ >(f);
}
-Instantiation instantiate16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
- T13, T14, T15, T16>(Closure f) {
- return Instantiation16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
- T14, T15, T16>(f);
+Instantiation instantiate16<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16
+>(Closure f) {
+ return Instantiation16<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16
+ >(f);
}
-Instantiation instantiate17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
- T13, T14, T15, T16, T17>(Closure f) {
- return Instantiation17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
- T14, T15, T16, T17>(f);
+Instantiation instantiate17<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16,
+ T17
+>(Closure f) {
+ return Instantiation17<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16,
+ T17
+ >(f);
}
-Instantiation instantiate18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
- T13, T14, T15, T16, T17, T18>(Closure f) {
- return Instantiation18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
- T14, T15, T16, T17, T18>(f);
+Instantiation instantiate18<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16,
+ T17,
+ T18
+>(Closure f) {
+ return Instantiation18<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16,
+ T17,
+ T18
+ >(f);
}
-Instantiation instantiate19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
- T13, T14, T15, T16, T17, T18, T19>(Closure f) {
- return Instantiation19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
- T14, T15, T16, T17, T18, T19>(f);
+Instantiation instantiate19<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16,
+ T17,
+ T18,
+ T19
+>(Closure f) {
+ return Instantiation19<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16,
+ T17,
+ T18,
+ T19
+ >(f);
}
-Instantiation instantiate20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
- T13, T14, T15, T16, T17, T18, T19, T20>(Closure f) {
- return Instantiation20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
- T14, T15, T16, T17, T18, T19, T20>(f);
+Instantiation instantiate20<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16,
+ T17,
+ T18,
+ T19,
+ T20
+>(Closure f) {
+ return Instantiation20<
+ T1,
+ T2,
+ T3,
+ T4,
+ T5,
+ T6,
+ T7,
+ T8,
+ T9,
+ T10,
+ T11,
+ T12,
+ T13,
+ T14,
+ T15,
+ T16,
+ T17,
+ T18,
+ T19,
+ T20
+ >(f);
}
diff --git a/sdk/lib/_internal/js_runtime/lib/js_helper.dart b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
index 5404cfe..a207670 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
@@ -64,7 +64,8 @@
import 'dart:_js_names' show unmangleGlobalNameIfPreservedAnyways;
-import 'dart:_rti' as newRti
+import 'dart:_rti'
+ as rti
show
createRuntimeType,
evalInInstance,
@@ -111,7 +112,10 @@
@pragma('dart2js:tryInline')
getMetadata(int index) {
return JS_BUILTIN(
- 'returns:var;effects:none;depends:none', JsBuiltin.getMetadata, index);
+ 'returns:var;effects:none;depends:none',
+ JsBuiltin.getMetadata,
+ index,
+ );
}
/// Returns the type of the given [index].
@@ -119,7 +123,10 @@
@pragma('dart2js:tryInline')
getType(int index) {
return JS_BUILTIN(
- 'returns:var;effects:none;depends:none', JsBuiltin.getType, index);
+ 'returns:var;effects:none;depends:none',
+ JsBuiltin.getType,
+ index,
+ );
}
/// No-op method that is called to inform the compiler that preambles might
@@ -152,24 +159,51 @@
var result = value.toString();
if (result is! String) {
throw ArgumentError.value(
- value, 'object', "toString method returned 'null'");
+ value,
+ 'object',
+ "toString method returned 'null'",
+ );
}
return result;
}
// Called from generated code.
createInvocationMirror(
- String name, internalName, kind, arguments, argumentNames, types) {
+ String name,
+ internalName,
+ kind,
+ arguments,
+ argumentNames,
+ types,
+) {
// TODO(sra): [types] (the number of type arguments) could be omitted in the
// generated stub code to save an argument. Then we would use `types ?? 0`.
return JSInvocationMirror(
- name, internalName, kind, arguments, argumentNames, types);
+ name,
+ internalName,
+ kind,
+ arguments,
+ argumentNames,
+ types,
+ );
}
createUnmangledInvocationMirror(
- Symbol symbol, internalName, kind, arguments, argumentNames, types) {
+ Symbol symbol,
+ internalName,
+ kind,
+ arguments,
+ argumentNames,
+ types,
+) {
return JSInvocationMirror(
- symbol, internalName, kind, arguments, argumentNames, types);
+ symbol,
+ internalName,
+ kind,
+ arguments,
+ argumentNames,
+ types,
+ );
}
void throwInvalidReflectionError(String memberName) {
@@ -194,8 +228,8 @@
// overflow. This approach here is simpler than making the compiler smart
// about how to generate traceHelper calls more carefully.
JS(
- '',
- r'''
+ '',
+ r'''
(function (id, name) {
var hook = self.dartCallInstrumentation;
if (typeof hook === "function") {
@@ -210,8 +244,9 @@
this.callInstrumentationCache[id] = true;
}
})(#, #)''',
- id,
- qualifiedName);
+ id,
+ qualifiedName,
+ );
}
class JSInvocationMirror implements Invocation {
@@ -224,8 +259,14 @@
final List _namedArgumentNames;
final int _typeArgumentCount;
- JSInvocationMirror(this._memberName, this._internalName, this._kind,
- this._arguments, this._namedArgumentNames, this._typeArgumentCount);
+ JSInvocationMirror(
+ this._memberName,
+ this._internalName,
+ this._kind,
+ this._arguments,
+ this._namedArgumentNames,
+ this._typeArgumentCount,
+ );
Symbol get memberName {
if (_memberName is Symbol) return _memberName;
@@ -242,7 +283,7 @@
int start = _arguments.length - _typeArgumentCount;
var list = <Type>[];
for (int index = 0; index < _typeArgumentCount; index++) {
- list.add(newRti.createRuntimeType(_arguments[start + index]));
+ list.add(rti.createRuntimeType(_arguments[start + index]));
}
return JSArray.markUnmodifiableList(list);
}
@@ -372,10 +413,11 @@
// - a Dart double literal
// We do allow leading or trailing whitespace.
if (!JS(
- 'bool',
- r'/^\s*[+-]?(?:Infinity|NaN|'
- r'(?:\.\d+|\d+(?:\.\d*)?)(?:[eE][+-]?\d+)?)\s*$/.test(#)',
- source)) {
+ 'bool',
+ r'/^\s*[+-]?(?:Infinity|NaN|'
+ r'(?:\.\d+|\d+(?:\.\d*)?)(?:[eE][+-]?\d+)?)\s*$/.test(#)',
+ source,
+ )) {
return null;
}
double result = JS('double', r'parseFloat(#)', source);
@@ -396,14 +438,14 @@
return source == "true"
? true
: source == "false"
- ? false
- : null;
+ ? false
+ : null;
}
return _compareIgnoreCase(source, "true")
? true
: _compareIgnoreCase(source, "false")
- ? false
- : null;
+ ? false
+ : null;
}
static bool _compareIgnoreCase(String input, String lowerCaseTarget) {
@@ -426,19 +468,12 @@
/// them with 'minified:'.
@pragma('dart2js:noInline')
static String objectTypeName(Object? object) {
- return _objectTypeNameNewRti(object);
- }
-
- /// Returns the type of [object] as a string (including type arguments).
- /// Tries to return a sensible name for non-Dart objects.
- ///
- /// In minified mode, uses the unminified names if available, otherwise tags
- /// them with 'minified:'.
- static String _objectTypeNameNewRti(Object? object) {
var dartObjectConstructor = JS_BUILTIN(
- 'depends:none;effects:none;', JsBuiltin.dartObjectConstructor);
+ 'depends:none;effects:none;',
+ JsBuiltin.dartObjectConstructor,
+ );
if (JS('bool', '# instanceof #', object, dartObjectConstructor)) {
- return newRti.instanceTypeName(object);
+ return rti.instanceTypeName(object);
}
var interceptor = getInterceptor(object);
@@ -473,7 +508,7 @@
}
}
- return newRti.instanceTypeName(object);
+ return rti.instanceTypeName(object);
}
static bool _saneNativeClassName(name) =>
@@ -558,12 +593,13 @@
for (int i = 0; i < end; i += kMaxApply) {
int chunkEnd = (i + kMaxApply < end) ? i + kMaxApply : end;
result = JS(
- 'String',
- r'# + String.fromCharCode.apply(null, #.slice(#, #))',
- result,
- array,
- i,
- chunkEnd);
+ 'String',
+ r'# + String.fromCharCode.apply(null, #.slice(#, #))',
+ result,
+ array,
+ i,
+ chunkEnd,
+ );
}
return result;
}
@@ -595,7 +631,10 @@
// [start] and [end] are validated.
static String stringFromNativeUint8List(
- NativeUint8List charCodes, int start, int end) {
+ NativeUint8List charCodes,
+ int start,
+ int end,
+ ) {
const kMaxApply = 500;
if (end <= kMaxApply && start == 0 && end == charCodes.length) {
return JS('String', r'String.fromCharCode.apply(null, #)', charCodes);
@@ -604,12 +643,13 @@
for (int i = start; i < end; i += kMaxApply) {
int chunkEnd = (i + kMaxApply < end) ? i + kMaxApply : end;
result = JS(
- 'String',
- r'# + String.fromCharCode.apply(null, #.subarray(#, #))',
- result,
- charCodes,
- i,
- chunkEnd);
+ 'String',
+ r'# + String.fromCharCode.apply(null, #.subarray(#, #))',
+ result,
+ charCodes,
+ i,
+ chunkEnd,
+ );
}
return result;
}
@@ -617,15 +657,22 @@
static String stringFromCharCode(int charCode) {
if (0 <= charCode) {
if (charCode <= 0xffff) {
- return JS('returns:String;effects:none;depends:none',
- 'String.fromCharCode(#)', charCode);
+ return JS(
+ 'returns:String;effects:none;depends:none',
+ 'String.fromCharCode(#)',
+ charCode,
+ );
}
if (charCode <= 0x10ffff) {
var bits = charCode - 0x10000;
var low = 0xDC00 | (bits & 0x3ff);
var high = 0xD800 | (bits >> 10);
- return JS('returns:String;effects:none;depends:none',
- 'String.fromCharCode(#, #)', high, low);
+ return JS(
+ 'returns:String;effects:none;depends:none',
+ 'String.fromCharCode(#, #)',
+ high,
+ low,
+ );
}
}
throw RangeError.range(charCode, 0, 0x10ffff);
@@ -636,8 +683,13 @@
}
static String flattenString(String str) {
- return JS('returns:String;depends:none;effects:none;throws:never;gvn:true',
- '#.charCodeAt(0) == 0 ? # : #', str, str, str);
+ return JS(
+ 'returns:String;depends:none;effects:none;throws:never;gvn:true',
+ '#.charCodeAt(0) == 0 ? # : #',
+ str,
+ str,
+ str,
+ );
}
static String getTimeZoneName(DateTime receiver) {
@@ -651,19 +703,20 @@
// Internet Explorer 10+ emits the zone name without parenthesis:
// Example: Thu Oct 31 14:07:44 PDT 2013
match = JS(
- 'JSArray|Null',
- // Thu followed by a space.
- r'/^[A-Z,a-z]{3}\s'
- // Oct 31 followed by space.
- r'[A-Z,a-z]{3}\s\d+\s'
- // Time followed by a space.
- r'\d{2}:\d{2}:\d{2}\s'
- // The time zone name followed by a space.
- r'([A-Z]{3,5})\s'
- // The year.
- r'\d{4}$/'
- '.exec(#.toString())',
- d);
+ 'JSArray|Null',
+ // Thu followed by a space.
+ r'/^[A-Z,a-z]{3}\s'
+ // Oct 31 followed by space.
+ r'[A-Z,a-z]{3}\s\d+\s'
+ // Time followed by a space.
+ r'\d{2}:\d{2}:\d{2}\s'
+ // The time zone name followed by a space.
+ r'([A-Z]{3,5})\s'
+ // The year.
+ r'\d{4}$/'
+ '.exec(#.toString())',
+ d,
+ );
if (match != null) return match[1];
// IE 9 and Opera don't provide the zone name. We fall back to emitting the
@@ -679,21 +732,25 @@
// Note that JavaScript's Date and and Dart's DateTime disagree on the sign
// of the offset. Subtract to avoid -0.0. The offset in minutes could
// contain 'seconds' as fractional minutes.
- num offsetInMinutes =
- JS('num', r'#.getTimezoneOffset()', lazyAsJsDate(receiver));
+ num offsetInMinutes = JS(
+ 'num',
+ r'#.getTimezoneOffset()',
+ lazyAsJsDate(receiver),
+ );
return (0 - offsetInMinutes * 60).toInt();
}
static int? valueFromDecomposedDate(
- int years,
- int month,
- int day,
- int hours,
- int minutes,
- int seconds,
- int milliseconds,
- int microseconds,
- bool isUtc) {
+ int years,
+ int month,
+ int day,
+ int hours,
+ int minutes,
+ int seconds,
+ int milliseconds,
+ int microseconds,
+ bool isUtc,
+ ) {
final int MAX_MILLISECONDS_SINCE_EPOCH = 8640000000000000;
checkInt(years);
checkInt(month);
@@ -720,11 +777,29 @@
microseconds = remainder;
num value;
if (isUtc) {
- value = JS('num', r'Date.UTC(#, #, #, #, #, #, #)', years, jsMonth, day,
- hours, minutes, seconds, milliseconds);
+ value = JS(
+ 'num',
+ r'Date.UTC(#, #, #, #, #, #, #)',
+ years,
+ jsMonth,
+ day,
+ hours,
+ minutes,
+ seconds,
+ milliseconds,
+ );
} else {
- value = JS('num', r'new Date(#, #, #, #, #, #, #).valueOf()', years,
- jsMonth, day, hours, minutes, seconds, milliseconds);
+ value = JS(
+ 'num',
+ r'new Date(#, #, #, #, #, #, #).valueOf()',
+ years,
+ jsMonth,
+ day,
+ hours,
+ minutes,
+ seconds,
+ milliseconds,
+ );
}
if (value.isNaN ||
value < -MAX_MILLISECONDS_SINCE_EPOCH ||
@@ -738,8 +813,12 @@
// Lazily keep a JS Date stored in the JS object.
static lazyAsJsDate(DateTime receiver) {
if (JS('bool', r'#.date === (void 0)', receiver)) {
- JS('void', r'#.date = new Date(#)', receiver,
- receiver.millisecondsSinceEpoch);
+ JS(
+ 'void',
+ r'#.date = new Date(#)',
+ receiver,
+ receiver.millisecondsSinceEpoch,
+ );
}
return JS('var', r'#.date', receiver);
}
@@ -818,7 +897,10 @@
static int getMilliseconds(DateTime receiver) {
return (receiver.isUtc)
? JS(
- 'JSUInt31', r'(#.getUTCMilliseconds() + 0)', lazyAsJsDate(receiver))
+ 'JSUInt31',
+ r'(#.getUTCMilliseconds() + 0)',
+ lazyAsJsDate(receiver),
+ )
: JS('JSUInt31', r'(#.getMilliseconds() + 0)', lazyAsJsDate(receiver));
}
@@ -826,9 +908,10 @@
@pragma('dart2js:noThrows')
@pragma('dart2js:noInline')
static int getWeekday(DateTime receiver) {
- int weekday = (receiver.isUtc)
- ? JS('int', r'#.getUTCDay() + 0', lazyAsJsDate(receiver))
- : JS('int', r'#.getDay() + 0', lazyAsJsDate(receiver));
+ int weekday =
+ (receiver.isUtc)
+ ? JS('int', r'#.getUTCDay() + 0', lazyAsJsDate(receiver))
+ : JS('int', r'#.getDay() + 0', lazyAsJsDate(receiver));
// Adjust by one because JS weeks start on Sunday.
return (weekday + 6) % 7 + 1;
}
@@ -847,8 +930,11 @@
JS('void', '#[#] = #', object, key, value);
}
- static functionNoSuchMethod(function, List? positionalArguments,
- Map<String, dynamic>? namedArguments) {
+ static functionNoSuchMethod(
+ function,
+ List? positionalArguments,
+ Map<String, dynamic>? namedArguments,
+ ) {
int argumentCount = 0;
List arguments = [];
List namedArgumentList = [];
@@ -871,8 +957,16 @@
String selectorName =
'${JS_GET_NAME(JsGetName.CALL_PREFIX)}\$$argumentCount$names';
- return function.noSuchMethod(createUnmangledInvocationMirror(
- #call, selectorName, mirrors.method, arguments, namedArgumentList, 0));
+ return function.noSuchMethod(
+ createUnmangledInvocationMirror(
+ #call,
+ selectorName,
+ mirrors.method,
+ arguments,
+ namedArgumentList,
+ 0,
+ ),
+ );
}
/// Implements [Function.apply] for the lazy and startup emitters.
@@ -906,8 +1000,11 @@
/// instead. For example, if the catch-all property contains the string
/// "call$4", then the object's "call$4" property should be used as if it was
/// the value of the catch-all property.
- static applyFunction(Function function, List? positionalArguments,
- Map<String, dynamic>? namedArguments) {
+ static applyFunction(
+ Function function,
+ List? positionalArguments,
+ Map<String, dynamic>? namedArguments,
+ ) {
// Fast path for common cases.
if (positionalArguments is JSArray &&
(namedArguments == null || namedArguments.isEmpty)) {
@@ -926,34 +1023,56 @@
} else if (argumentCount == 2) {
String selectorName = JS_GET_NAME(JsGetName.CALL_PREFIX2);
if (JS('bool', '!!#[#]', function, selectorName)) {
- return JS('', '#[#](#[0],#[1])', function, selectorName, arguments,
- arguments);
+ return JS(
+ '',
+ '#[#](#[0],#[1])',
+ function,
+ selectorName,
+ arguments,
+ arguments,
+ );
}
} else if (argumentCount == 3) {
String selectorName = JS_GET_NAME(JsGetName.CALL_PREFIX3);
if (JS('bool', '!!#[#]', function, selectorName)) {
- return JS('', '#[#](#[0],#[1],#[2])', function, selectorName,
- arguments, arguments, arguments);
+ return JS(
+ '',
+ '#[#](#[0],#[1],#[2])',
+ function,
+ selectorName,
+ arguments,
+ arguments,
+ arguments,
+ );
}
} else if (argumentCount == 4) {
String selectorName = JS_GET_NAME(JsGetName.CALL_PREFIX4);
if (JS('bool', '!!#[#]', function, selectorName)) {
- return JS('', '#[#](#[0],#[1],#[2],#[3])', function, selectorName,
- arguments, arguments, arguments, arguments);
+ return JS(
+ '',
+ '#[#](#[0],#[1],#[2],#[3])',
+ function,
+ selectorName,
+ arguments,
+ arguments,
+ arguments,
+ arguments,
+ );
}
} else if (argumentCount == 5) {
String selectorName = JS_GET_NAME(JsGetName.CALL_PREFIX5);
if (JS('bool', '!!#[#]', function, selectorName)) {
return JS(
- '',
- '#[#](#[0],#[1],#[2],#[3],#[4])',
- function,
- selectorName,
- arguments,
- arguments,
- arguments,
- arguments,
- arguments);
+ '',
+ '#[#](#[0],#[1],#[2],#[3],#[4])',
+ function,
+ selectorName,
+ arguments,
+ arguments,
+ arguments,
+ arguments,
+ arguments,
+ );
}
}
String selectorName =
@@ -967,8 +1086,11 @@
return _generalApplyFunction(function, positionalArguments, namedArguments);
}
- static _generalApplyFunction(Function function, List? positionalArguments,
- Map<String, dynamic>? namedArguments) {
+ static _generalApplyFunction(
+ Function function,
+ List? positionalArguments,
+ Map<String, dynamic>? namedArguments,
+ ) {
List arguments;
if (positionalArguments != null) {
if (positionalArguments is JSArray) {
@@ -982,15 +1104,23 @@
int argumentCount = arguments.length;
- int requiredParameterCount = JS('int', r'#[#]', function,
- JS_GET_NAME(JsGetName.REQUIRED_PARAMETER_PROPERTY));
+ int requiredParameterCount = JS(
+ 'int',
+ r'#[#]',
+ function,
+ JS_GET_NAME(JsGetName.REQUIRED_PARAMETER_PROPERTY),
+ );
if (argumentCount < requiredParameterCount) {
return functionNoSuchMethod(function, arguments, namedArguments);
}
- var defaultValuesClosure = JS('var', r'#[#]', function,
- JS_GET_NAME(JsGetName.DEFAULT_VALUES_PROPERTY));
+ var defaultValuesClosure = JS(
+ 'var',
+ r'#[#]',
+ function,
+ JS_GET_NAME(JsGetName.DEFAULT_VALUES_PROPERTY),
+ );
bool acceptsOptionalArguments = defaultValuesClosure != null;
@@ -1000,8 +1130,12 @@
acceptsOptionalArguments ? JS('', '#()', defaultValuesClosure) : null;
var interceptor = getInterceptor(function);
- var jsFunction =
- JS('', '#[#]', interceptor, JS_GET_NAME(JsGetName.CALL_CATCH_ALL));
+ var jsFunction = JS(
+ '',
+ '#[#]',
+ interceptor,
+ JS_GET_NAME(JsGetName.CALL_CATCH_ALL),
+ );
if (jsFunction is String) {
// Anonymous closures redirect to the catch-all property instead of
// storing the catch-all method directly in the catch-all property.
@@ -1036,8 +1170,12 @@
return functionNoSuchMethod(function, arguments, null);
}
if (argumentCount < maxArguments) {
- List missingDefaults = JS('JSArray', '#.slice(#)', defaultValues,
- argumentCount - requiredParameterCount);
+ List missingDefaults = JS(
+ 'JSArray',
+ '#.slice(#)',
+ defaultValues,
+ argumentCount - requiredParameterCount,
+ );
if (identical(arguments, positionalArguments)) {
// Defensive copy to avoid modifying passed-in List.
arguments = List.of(arguments);
@@ -1137,8 +1275,12 @@
// [IndexError.check] with no optional parameters
// provided.
if (index < 0 || index >= length) {
- return IndexError.withLength(index, length,
- indexable: indexable, name: 'index');
+ return IndexError.withLength(
+ index,
+ length,
+ indexable: indexable,
+ name: 'index',
+ );
}
// The above should always match, but if it does not, use the following.
return RangeError.value(index, 'index');
@@ -1227,8 +1369,12 @@
// (https://code.google.com/p/v8/issues/detail?id=2519). The default
// toString on Error returns the value of 'message' if 'name' is
// empty. Setting toString directly doesn't work, see the bug.
- JS('void', 'Object.defineProperty(#, "message", { get: # })', wrapper,
- DART_CLOSURE_TO_JS(toStringWrapper));
+ JS(
+ 'void',
+ 'Object.defineProperty(#, "message", { get: # })',
+ wrapper,
+ DART_CLOSURE_TO_JS(toStringWrapper),
+ );
JS('void', '#.name = ""', wrapper);
} else {
// In the unlikely event the browser doesn't support Object.defineProperty,
@@ -1279,7 +1425,10 @@
@pragma('dart2js:never-inline')
Error _diagnoseUnsupportedOperation(
- Object o, Object encodedOperation, Object encodedVerb) {
+ Object o,
+ Object encodedOperation,
+ Object encodedVerb,
+) {
String operation;
String verb;
@@ -1387,56 +1536,71 @@
/// Pattern used to recognize a NoSuchMethodError error (and
/// possibly extract the method name).
- static final TypeErrorDecoder noSuchMethodPattern =
- extractPattern(provokeCallErrorOn(buildJavaScriptObject()));
+ static final TypeErrorDecoder noSuchMethodPattern = extractPattern(
+ provokeCallErrorOn(buildJavaScriptObject()),
+ );
/// Pattern used to recognize an "object not a closure" error (and
/// possibly extract the method name).
- static final TypeErrorDecoder notClosurePattern =
- extractPattern(provokeCallErrorOn(buildJavaScriptObjectWithNonClosure()));
+ static final TypeErrorDecoder notClosurePattern = extractPattern(
+ provokeCallErrorOn(buildJavaScriptObjectWithNonClosure()),
+ );
/// Pattern used to recognize a NoSuchMethodError on JavaScript null
/// call.
- static final TypeErrorDecoder nullCallPattern =
- extractPattern(provokeCallErrorOn(JS('', 'null')));
+ static final TypeErrorDecoder nullCallPattern = extractPattern(
+ provokeCallErrorOn(JS('', 'null')),
+ );
/// Pattern used to recognize a NoSuchMethodError on JavaScript literal null
/// call.
- static final TypeErrorDecoder nullLiteralCallPattern =
- extractPattern(provokeCallErrorOnNull());
+ static final TypeErrorDecoder nullLiteralCallPattern = extractPattern(
+ provokeCallErrorOnNull(),
+ );
/// Pattern used to recognize a NoSuchMethodError on JavaScript
/// undefined call.
- static final TypeErrorDecoder undefinedCallPattern =
- extractPattern(provokeCallErrorOn(JS('', 'void 0')));
+ static final TypeErrorDecoder undefinedCallPattern = extractPattern(
+ provokeCallErrorOn(JS('', 'void 0')),
+ );
/// Pattern used to recognize a NoSuchMethodError on JavaScript literal
/// undefined call.
- static final TypeErrorDecoder undefinedLiteralCallPattern =
- extractPattern(provokeCallErrorOnUndefined());
+ static final TypeErrorDecoder undefinedLiteralCallPattern = extractPattern(
+ provokeCallErrorOnUndefined(),
+ );
/// Pattern used to recognize a NoSuchMethodError on JavaScript null
/// property access.
- static final TypeErrorDecoder nullPropertyPattern =
- extractPattern(provokePropertyErrorOn(JS('', 'null')));
+ static final TypeErrorDecoder nullPropertyPattern = extractPattern(
+ provokePropertyErrorOn(JS('', 'null')),
+ );
/// Pattern used to recognize a NoSuchMethodError on JavaScript literal null
/// property access.
- static final TypeErrorDecoder nullLiteralPropertyPattern =
- extractPattern(provokePropertyErrorOnNull());
+ static final TypeErrorDecoder nullLiteralPropertyPattern = extractPattern(
+ provokePropertyErrorOnNull(),
+ );
/// Pattern used to recognize a NoSuchMethodError on JavaScript
/// undefined property access.
- static final TypeErrorDecoder undefinedPropertyPattern =
- extractPattern(provokePropertyErrorOn(JS('', 'void 0')));
+ static final TypeErrorDecoder undefinedPropertyPattern = extractPattern(
+ provokePropertyErrorOn(JS('', 'void 0')),
+ );
/// Pattern used to recognize a NoSuchMethodError on JavaScript literal
/// undefined property access.
static final TypeErrorDecoder undefinedLiteralPropertyPattern =
extractPattern(provokePropertyErrorOnUndefined());
- TypeErrorDecoder(this._arguments, this._argumentsExpr, this._expr,
- this._method, this._receiver, this._pattern);
+ TypeErrorDecoder(
+ this._arguments,
+ this._argumentsExpr,
+ this._expr,
+ this._method,
+ this._receiver,
+ this._pattern,
+ );
/// Returns a JavaScript object literal (map) with at most the
/// following keys:
@@ -1461,7 +1625,11 @@
/// "[object Object]" in recent versions.
matchTypeError(message) {
var match = JS(
- 'JSExtendableArray|Null', 'new RegExp(#).exec(#)', _pattern, message);
+ 'JSExtendableArray|Null',
+ 'new RegExp(#).exec(#)',
+ _pattern,
+ message,
+ );
if (match == null) return null;
var result = JS('', 'Object.create(null)');
if (_arguments != -1) {
@@ -1493,9 +1661,10 @@
/// r"$receiver$". The property "$method" is defined, but is not a function.
static buildJavaScriptObjectWithNonClosure() {
return JS(
- '',
- r'{ $method$: null, '
- r'toString: function() { return "$receiver$"; } }');
+ '',
+ r'{ $method$: null, '
+ r'toString: function() { return "$receiver$"; } }',
+ );
}
/// Extract a pattern from a JavaScript TypeError message.
@@ -1524,8 +1693,11 @@
// Look for the special pattern \$camelCase\$ (all the $ symbols
// have been escaped already), as we will soon be inserting
// regular expression syntax that we want interpreted by RegExp.
- List<String>? match =
- JS('JSExtendableArray|Null', r'#.match(/\\\$[a-zA-Z]+\\\$/g)', message);
+ List<String>? match = JS(
+ 'JSExtendableArray|Null',
+ r'#.match(/\\\$[a-zA-Z]+\\\$/g)',
+ message,
+ );
if (match == null) match = [];
// Find the positions within the substring matches of the error message
@@ -1541,19 +1713,26 @@
// Note: in a perfect world, one would use "(.*)", but not in
// JavaScript, "." does not match newlines.
String pattern = JS(
- 'String',
- r'#.replace(new RegExp("\\\\\\$arguments\\\\\\$", "g"), '
- r'"((?:x|[^x])*)")'
- r'.replace(new RegExp("\\\\\\$argumentsExpr\\\\\\$", "g"), '
- r'"((?:x|[^x])*)")'
- r'.replace(new RegExp("\\\\\\$expr\\\\\\$", "g"), "((?:x|[^x])*)")'
- r'.replace(new RegExp("\\\\\\$method\\\\\\$", "g"), "((?:x|[^x])*)")'
- r'.replace(new RegExp("\\\\\\$receiver\\\\\\$", "g"), '
- r'"((?:x|[^x])*)")',
- message);
+ 'String',
+ r'#.replace(new RegExp("\\\\\\$arguments\\\\\\$", "g"), '
+ r'"((?:x|[^x])*)")'
+ r'.replace(new RegExp("\\\\\\$argumentsExpr\\\\\\$", "g"), '
+ r'"((?:x|[^x])*)")'
+ r'.replace(new RegExp("\\\\\\$expr\\\\\\$", "g"), "((?:x|[^x])*)")'
+ r'.replace(new RegExp("\\\\\\$method\\\\\\$", "g"), "((?:x|[^x])*)")'
+ r'.replace(new RegExp("\\\\\\$receiver\\\\\\$", "g"), '
+ r'"((?:x|[^x])*)")',
+ message,
+ );
return TypeErrorDecoder(
- arguments, argumentsExpr, expr, method, receiver, pattern);
+ arguments,
+ argumentsExpr,
+ expr,
+ method,
+ receiver,
+ pattern,
+ );
}
/// Provokes a TypeError and returns its message.
@@ -1703,9 +1882,8 @@
final String? _receiver;
JsNoSuchMethodError(this._message, match)
- : _method = match == null ? null : JS('String|Null', '#.method', match),
- _receiver =
- match == null ? null : JS('String|Null', '#.receiver', match);
+ : _method = match == null ? null : JS('String|Null', '#.method', match),
+ _receiver = match == null ? null : JS('String|Null', '#.receiver', match);
String toString() {
if (_method == null) return 'NoSuchMethodError: $_message';
@@ -1811,7 +1989,9 @@
switch (ieErrorCode) {
case 438:
return saveStackTrace(
- ex, JsNoSuchMethodError('$message (Error $ieErrorCode)', null));
+ ex,
+ JsNoSuchMethodError('$message (Error $ieErrorCode)', null),
+ );
case 445:
case 5007:
return saveStackTrace(ex, NullError('$message (Error $ieErrorCode)'));
@@ -1855,7 +2035,9 @@
// to reporting this as a generic error. It's probably better than
// nothing.
return saveStackTrace(
- ex, UnknownJsTypeError(message is String ? message : ''));
+ ex,
+ UnknownJsTypeError(message is String ? message : ''),
+ );
}
if (JS('bool', r'# instanceof RangeError', ex)) {
@@ -1876,9 +2058,10 @@
// Check for the Firefox specific stack overflow signal.
if (JS(
- 'bool',
- r'typeof InternalError == "function" && # instanceof InternalError',
- ex)) {
+ 'bool',
+ r'typeof InternalError == "function" && # instanceof InternalError',
+ ex,
+ )) {
if (message is String && message == 'too much recursion') {
return StackOverflowError();
}
@@ -1894,17 +2077,14 @@
// Since this function is called from [unwrapException] which is called from
// code injected into a catch-clause, use JavaScript try-catch to avoid a
// potential loop if stringifying crashes.
- return JS(
- 'String|Null',
- r'''
+ return JS('String|Null', r'''
(function(ex) {
try {
return String(ex);
} catch (e) {}
return null;
})(#)
- ''',
- ex);
+ ''', ex);
}
/// Called by generated code to fetch the stack trace from an
@@ -2032,8 +2212,14 @@
return JS('int', r'#.length', array);
}
-_invokeClosure(Function closure, int numberOfArguments, var arg1, var arg2,
- var arg3, var arg4) {
+_invokeClosure(
+ Function closure,
+ int numberOfArguments,
+ var arg1,
+ var arg2,
+ var arg3,
+ var arg4,
+) {
switch (numberOfArguments) {
case 0:
return closure();
@@ -2097,16 +2283,17 @@
// call sites in `_invokeClosure` to retain the entry points).
return JS(
- 'var',
- r'''
+ 'var',
+ r'''
(function(closure, arity, invoke) {
return function(a1, a2, a3, a4) {
return invoke(closure, arity, a1, a2, a3, a4);
};
})(#,#,#)''',
- closure,
- arity,
- DART_CLOSURE_TO_JS(_invokeClosure));
+ closure,
+ arity,
+ DART_CLOSURE_TO_JS(_invokeClosure),
+ );
}
/// Superclass for Dart closures.
@@ -2148,22 +2335,50 @@
getType(JS('int', '0'));
});
- Object? container =
- JS('', '#.#', parameters, TearOffParametersPropertyNames.container);
+ Object? container = JS(
+ '',
+ '#.#',
+ parameters,
+ TearOffParametersPropertyNames.container,
+ );
- bool isStatic =
- JS('', '#.#', parameters, TearOffParametersPropertyNames.isStatic);
- bool isIntercepted =
- JS('', '#.#', parameters, TearOffParametersPropertyNames.isIntercepted);
- bool needsDirectAccess = JS('', '#.#', parameters,
- TearOffParametersPropertyNames.needsDirectAccess);
- int applyTrampolineIndex =
- JS('', '#.#', parameters, TearOffParametersPropertyNames.applyIndex);
+ bool isStatic = JS(
+ '',
+ '#.#',
+ parameters,
+ TearOffParametersPropertyNames.isStatic,
+ );
+ bool isIntercepted = JS(
+ '',
+ '#.#',
+ parameters,
+ TearOffParametersPropertyNames.isIntercepted,
+ );
+ bool needsDirectAccess = JS(
+ '',
+ '#.#',
+ parameters,
+ TearOffParametersPropertyNames.needsDirectAccess,
+ );
+ int applyTrampolineIndex = JS(
+ '',
+ '#.#',
+ parameters,
+ TearOffParametersPropertyNames.applyIndex,
+ );
- JSArray funsOrNames =
- JS('', '#.#', parameters, TearOffParametersPropertyNames.funsOrNames);
- JSArray callNames =
- JS('', '#.#', parameters, TearOffParametersPropertyNames.callNames);
+ JSArray funsOrNames = JS(
+ '',
+ '#.#',
+ parameters,
+ TearOffParametersPropertyNames.funsOrNames,
+ );
+ JSArray callNames = JS(
+ '',
+ '#.#',
+ parameters,
+ TearOffParametersPropertyNames.callNames,
+ );
// The first function is the primary entry point. It is always a string, the
// property name of the first function within the container.
@@ -2205,27 +2420,36 @@
// Object.create to create the desired prototype.
//
// TODO(sra): Cache the prototype to avoid the allocation.
- var prototype = isStatic
- ? JS('StaticClosure', 'Object.create(#.constructor.prototype)',
- StaticClosure())
- : JS('BoundClosure', 'Object.create(#.constructor.prototype)',
- BoundClosure(null, null));
+ var prototype =
+ isStatic
+ ? JS(
+ 'StaticClosure',
+ 'Object.create(#.constructor.prototype)',
+ StaticClosure(),
+ )
+ : JS(
+ 'BoundClosure',
+ 'Object.create(#.constructor.prototype)',
+ BoundClosure(null, null),
+ );
JS('', '#.\$initialize = #', prototype, JS('', '#.constructor', prototype));
// The constructor functions have names to prevent the JavaScript
// implementation from inventing a name that might have special meaning
// (e.g. clashing with minified 'Object' or 'Interceptor').
- var constructor = isStatic
- ? JS('', 'function static_tear_off(){this.\$initialize()}')
- : isCsp
+ var constructor =
+ isStatic
+ ? JS('', 'function static_tear_off(){this.\$initialize()}')
+ : isCsp
? JS('', 'function tear_off(a,b) {this.\$initialize(a,b)}')
: JS(
- '',
- 'new Function("a,b" + #,'
- ' "this.\$initialize(a,b" + # + ")")',
- functionCounter,
- functionCounter++);
+ '',
+ 'new Function("a,b" + #,'
+ ' "this.\$initialize(a,b" + # + ")")',
+ functionCounter,
+ functionCounter++,
+ );
// It is necessary to set the constructor property, otherwise it will be
// "Object".
@@ -2239,18 +2463,30 @@
// Create a closure and "monkey" patch it with call stubs.
var trampoline = function;
if (!isStatic) {
- trampoline =
- forwardCallTo(name, function, isIntercepted, needsDirectAccess);
+ trampoline = forwardCallTo(
+ name,
+ function,
+ isIntercepted,
+ needsDirectAccess,
+ );
} else {
// TODO(sra): Can this be removed?
JS('', '#[#] = #', prototype, STATIC_FUNCTION_NAME_PROPERTY_NAME, name);
}
- var signatureFunction =
- _computeSignatureFunctionNewRti(functionType, isStatic, isIntercepted);
+ var signatureFunction = _computeSignatureFunction(
+ functionType,
+ isStatic,
+ isIntercepted,
+ );
- JS('', '#[#] = #', prototype, JS_GET_NAME(JsGetName.SIGNATURE_NAME),
- signatureFunction);
+ JS(
+ '',
+ '#[#] = #',
+ prototype,
+ JS_GET_NAME(JsGetName.SIGNATURE_NAME),
+ signatureFunction,
+ );
var applyTrampoline = trampoline;
JS('', '#[#] = #', prototype, callName, trampoline);
@@ -2268,8 +2504,12 @@
// otherwise unused, e.g. `foo<T>({bool strange = true})...`
if (stubCallName != null) {
if (!isStatic) {
- stub =
- forwardCallTo(stubName, stub, isIntercepted, needsDirectAccess);
+ stub = forwardCallTo(
+ stubName,
+ stub,
+ isIntercepted,
+ needsDirectAccess,
+ );
}
JS('', '#[#] = #', prototype, stubCallName, stub);
}
@@ -2278,25 +2518,46 @@
}
}
- JS('', '#[#] = #', prototype, JS_GET_NAME(JsGetName.CALL_CATCH_ALL),
- applyTrampoline);
+ JS(
+ '',
+ '#[#] = #',
+ prototype,
+ JS_GET_NAME(JsGetName.CALL_CATCH_ALL),
+ applyTrampoline,
+ );
String reqArgProperty = JS_GET_NAME(JsGetName.REQUIRED_PARAMETER_PROPERTY);
- Object? requiredParameterCount = JS('', '#.#', parameters,
- TearOffParametersPropertyNames.requiredParameterCount);
+ Object? requiredParameterCount = JS(
+ '',
+ '#.#',
+ parameters,
+ TearOffParametersPropertyNames.requiredParameterCount,
+ );
JS('', '#.# = #', prototype, reqArgProperty, requiredParameterCount);
String defValProperty = JS_GET_NAME(JsGetName.DEFAULT_VALUES_PROPERTY);
- Object? optionalParameterDefaultValues = JS('', '#.#', parameters,
- TearOffParametersPropertyNames.optionalParameterDefaultValues);
- JS('', '#.# = #', prototype, defValProperty,
- optionalParameterDefaultValues);
+ Object? optionalParameterDefaultValues = JS(
+ '',
+ '#.#',
+ parameters,
+ TearOffParametersPropertyNames.optionalParameterDefaultValues,
+ );
+ JS(
+ '',
+ '#.# = #',
+ prototype,
+ defValProperty,
+ optionalParameterDefaultValues,
+ );
return constructor;
}
- static _computeSignatureFunctionNewRti(
- Object functionType, bool isStatic, bool isIntercepted) {
+ static _computeSignatureFunction(
+ Object functionType,
+ bool isStatic,
+ bool isIntercepted,
+ ) {
if (JS('bool', 'typeof # == "number"', functionType)) {
// Index into types table. Handled in rti.dart.
return functionType;
@@ -2309,20 +2570,25 @@
}
final typeEvalMethod = RAW_DART_FUNCTION_REF(BoundClosure.evalRecipe);
return JS(
- '',
- ' function(recipe, evalOnReceiver) {'
- ' return function() {'
- ' return evalOnReceiver(this, recipe);'
- ' };'
- '}(#,#)',
- functionType,
- typeEvalMethod);
+ '',
+ ' function(recipe, evalOnReceiver) {'
+ ' return function() {'
+ ' return evalOnReceiver(this, recipe);'
+ ' };'
+ '}(#,#)',
+ functionType,
+ typeEvalMethod,
+ );
}
throw 'Error in functionType of tearoff';
}
static cspForwardCall(
- int arity, bool needsDirectAccess, String? stubName, function) {
+ int arity,
+ bool needsDirectAccess,
+ String? stubName,
+ function,
+ ) {
var getReceiver = RAW_DART_FUNCTION_REF(BoundClosure.receiverOf);
// We have the target method (or an arity stub for the method) in
@@ -2341,82 +2607,93 @@
switch (arity) {
case 0:
return JS(
- '',
- 'function(entry, receiverOf){'
- 'return function(){'
- 'return receiverOf(this)[entry]()'
- '}'
- '}(#,#)',
- stubName,
- getReceiver);
+ '',
+ 'function(entry, receiverOf){'
+ 'return function(){'
+ 'return receiverOf(this)[entry]()'
+ '}'
+ '}(#,#)',
+ stubName,
+ getReceiver,
+ );
case 1:
return JS(
- '',
- 'function(entry, receiverOf){'
- 'return function(a){'
- 'return receiverOf(this)[entry](a)'
- '}'
- '}(#,#)',
- stubName,
- getReceiver);
+ '',
+ 'function(entry, receiverOf){'
+ 'return function(a){'
+ 'return receiverOf(this)[entry](a)'
+ '}'
+ '}(#,#)',
+ stubName,
+ getReceiver,
+ );
case 2:
return JS(
- '',
- 'function(entry, receiverOf){'
- 'return function(a, b){'
- 'return receiverOf(this)[entry](a, b)'
- '}'
- '}(#,#)',
- stubName,
- getReceiver);
+ '',
+ 'function(entry, receiverOf){'
+ 'return function(a, b){'
+ 'return receiverOf(this)[entry](a, b)'
+ '}'
+ '}(#,#)',
+ stubName,
+ getReceiver,
+ );
case 3:
return JS(
- '',
- 'function(entry, receiverOf){'
- 'return function(a, b, c){'
- 'return receiverOf(this)[entry](a, b, c)'
- '}'
- '}(#,#)',
- stubName,
- getReceiver);
+ '',
+ 'function(entry, receiverOf){'
+ 'return function(a, b, c){'
+ 'return receiverOf(this)[entry](a, b, c)'
+ '}'
+ '}(#,#)',
+ stubName,
+ getReceiver,
+ );
case 4:
return JS(
- '',
- 'function(entry, receiverOf){'
- 'return function(a, b, c, d){'
- 'return receiverOf(this)[entry](a, b, c, d)'
- '}'
- '}(#,#)',
- stubName,
- getReceiver);
+ '',
+ 'function(entry, receiverOf){'
+ 'return function(a, b, c, d){'
+ 'return receiverOf(this)[entry](a, b, c, d)'
+ '}'
+ '}(#,#)',
+ stubName,
+ getReceiver,
+ );
case 5:
return JS(
- '',
- 'function(entry, receiverOf){'
- 'return function(a, b, c, d, e){'
- 'return receiverOf(this)[entry](a, b, c, d, e)'
- '}'
- '}(#,#)',
- stubName,
- getReceiver);
+ '',
+ 'function(entry, receiverOf){'
+ 'return function(a, b, c, d, e){'
+ 'return receiverOf(this)[entry](a, b, c, d, e)'
+ '}'
+ '}(#,#)',
+ stubName,
+ getReceiver,
+ );
default:
// Here we use `Function.prototype.apply`.
return JS(
- '',
- 'function(f, receiverOf){'
- 'return function(){'
- 'return f.apply(receiverOf(this), arguments)'
- '}'
- '}(#,#)',
- function,
- getReceiver);
+ '',
+ 'function(f, receiverOf){'
+ 'return function(){'
+ 'return f.apply(receiverOf(this), arguments)'
+ '}'
+ '}(#,#)',
+ function,
+ getReceiver,
+ );
}
}
static bool get isCsp => JS_GET_FLAG('USE_CONTENT_SECURITY_POLICY');
static forwardCallTo(
- String stubName, function, bool isIntercepted, bool needsDirectAccess) {
+ String stubName,
+ function,
+ bool isIntercepted,
+ bool needsDirectAccess,
+ ) {
if (isIntercepted)
return forwardInterceptedCallTo(stubName, function, needsDirectAccess);
int arity = JS('int', '#.length', function);
@@ -2429,27 +2706,36 @@
// Incorporate functionCounter into a local.
String selfName = 'self${functionCounter++}';
return JS(
- '',
- '(new Function(#))()',
- 'return function(){'
- 'var $selfName = this.${BoundClosure.receiverFieldName()};'
- 'return $selfName.$stubName();'
- '}');
- }
- assert(1 <= arity && arity < 27);
- String arguments = JS('String',
- '"abcdefghijklmnopqrstuvwxyz".split("").splice(0,#).join(",")', arity);
- arguments += '${functionCounter++}';
- return JS(
'',
'(new Function(#))()',
- 'return function($arguments){'
- 'return this.${BoundClosure.receiverFieldName()}.$stubName($arguments);'
- '}');
+ 'return function(){'
+ 'var $selfName = this.${BoundClosure.receiverFieldName()};'
+ 'return $selfName.$stubName();'
+ '}',
+ );
+ }
+ assert(1 <= arity && arity < 27);
+ String arguments = JS(
+ 'String',
+ '"abcdefghijklmnopqrstuvwxyz".split("").splice(0,#).join(",")',
+ arity,
+ );
+ arguments += '${functionCounter++}';
+ return JS(
+ '',
+ '(new Function(#))()',
+ 'return function($arguments){'
+ 'return this.${BoundClosure.receiverFieldName()}.$stubName($arguments);'
+ '}',
+ );
}
static cspForwardInterceptedCall(
- int arity, bool needsDirectAccess, String? stubName, function) {
+ int arity,
+ bool needsDirectAccess,
+ String? stubName,
+ function,
+ ) {
var getReceiver = RAW_DART_FUNCTION_REF(BoundClosure.receiverOf);
var getInterceptor = RAW_DART_FUNCTION_REF(BoundClosure.interceptorOf);
// Handle intercepted stub-names with the default slow case.
@@ -2461,88 +2747,98 @@
throw RuntimeError('Intercepted function with no arguments.');
case 1:
return JS(
- '',
- 'function(entry, interceptorOf, receiverOf){'
- 'return function(){'
- 'return interceptorOf(this)[entry](receiverOf(this))'
- '}'
- '}(#,#,#)',
- stubName,
- getInterceptor,
- getReceiver);
+ '',
+ 'function(entry, interceptorOf, receiverOf){'
+ 'return function(){'
+ 'return interceptorOf(this)[entry](receiverOf(this))'
+ '}'
+ '}(#,#,#)',
+ stubName,
+ getInterceptor,
+ getReceiver,
+ );
case 2:
return JS(
- '',
- 'function(entry, interceptorOf, receiverOf){'
- 'return function(a){'
- 'return interceptorOf(this)[entry](receiverOf(this), a)'
- '}'
- '}(#,#,#)',
- stubName,
- getInterceptor,
- getReceiver);
+ '',
+ 'function(entry, interceptorOf, receiverOf){'
+ 'return function(a){'
+ 'return interceptorOf(this)[entry](receiverOf(this), a)'
+ '}'
+ '}(#,#,#)',
+ stubName,
+ getInterceptor,
+ getReceiver,
+ );
case 3:
return JS(
- '',
- 'function(entry, interceptorOf, receiverOf){'
- 'return function(a, b){'
- 'return interceptorOf(this)[entry](receiverOf(this), a, b)'
- '}'
- '}(#,#,#)',
- stubName,
- getInterceptor,
- getReceiver);
+ '',
+ 'function(entry, interceptorOf, receiverOf){'
+ 'return function(a, b){'
+ 'return interceptorOf(this)[entry](receiverOf(this), a, b)'
+ '}'
+ '}(#,#,#)',
+ stubName,
+ getInterceptor,
+ getReceiver,
+ );
case 4:
return JS(
- '',
- 'function(entry, interceptorOf, receiverOf){'
- 'return function(a, b, c){'
- 'return interceptorOf(this)[entry](receiverOf(this), a, b, c)'
- '}'
- '}(#,#,#)',
- stubName,
- getInterceptor,
- getReceiver);
+ '',
+ 'function(entry, interceptorOf, receiverOf){'
+ 'return function(a, b, c){'
+ 'return interceptorOf(this)[entry](receiverOf(this), a, b, c)'
+ '}'
+ '}(#,#,#)',
+ stubName,
+ getInterceptor,
+ getReceiver,
+ );
case 5:
return JS(
- '',
- 'function(entry, interceptorOf, receiverOf){'
- 'return function(a, b, c, d){'
- 'return interceptorOf(this)[entry](receiverOf(this), a, b, c, d)'
- '}'
- '}(#,#,#)',
- stubName,
- getInterceptor,
- getReceiver);
+ '',
+ 'function(entry, interceptorOf, receiverOf){'
+ 'return function(a, b, c, d){'
+ 'return interceptorOf(this)[entry](receiverOf(this), a, b, c, d)'
+ '}'
+ '}(#,#,#)',
+ stubName,
+ getInterceptor,
+ getReceiver,
+ );
case 6:
return JS(
- '',
- 'function(entry, interceptorOf, receiverOf){'
- 'return function(a, b, c, d, e){'
- 'return interceptorOf(this)[entry](receiverOf(this), a, b, c, d, e)'
- '}'
- '}(#,#,#)',
- stubName,
- getInterceptor,
- getReceiver);
+ '',
+ 'function(entry, interceptorOf, receiverOf){'
+ 'return function(a, b, c, d, e){'
+ 'return interceptorOf(this)[entry](receiverOf(this), a, b, c, d, e)'
+ '}'
+ '}(#,#,#)',
+ stubName,
+ getInterceptor,
+ getReceiver,
+ );
default:
return JS(
- '',
- 'function(f, interceptorOf, receiverOf){'
- 'return function(){'
- 'var a = [receiverOf(this)];'
- 'Array.prototype.push.apply(a, arguments);'
- 'return f.apply(interceptorOf(this), a)'
- '}'
- '}(#,#,#)',
- function,
- getInterceptor,
- getReceiver);
+ '',
+ 'function(f, interceptorOf, receiverOf){'
+ 'return function(){'
+ 'var a = [receiverOf(this)];'
+ 'Array.prototype.push.apply(a, arguments);'
+ 'return f.apply(interceptorOf(this), a)'
+ '}'
+ '}(#,#,#)',
+ function,
+ getInterceptor,
+ getReceiver,
+ );
}
}
static forwardInterceptedCallTo(
- String stubName, function, bool needsDirectAccess) {
+ String stubName,
+ function,
+ bool needsDirectAccess,
+ ) {
String interceptorField = BoundClosure.interceptorFieldName();
String receiverField = BoundClosure.receiverFieldName();
int arity = JS('int', '#.length', function);
@@ -2550,29 +2846,36 @@
if (isCsp || needsDirectAccess || arity >= 28) {
return cspForwardInterceptedCall(
- arity, needsDirectAccess, stubName, function);
+ arity,
+ needsDirectAccess,
+ stubName,
+ function,
+ );
}
if (arity == 1) {
return JS(
- '',
- '(new Function(#))()',
- 'return function(){'
- 'return this.$interceptorField.$stubName(this.$receiverField);'
- '${functionCounter++}'
- '}');
+ '',
+ '(new Function(#))()',
+ 'return function(){'
+ 'return this.$interceptorField.$stubName(this.$receiverField);'
+ '${functionCounter++}'
+ '}',
+ );
}
assert(1 < arity && arity < 28);
String arguments = JS(
- 'String',
- '"abcdefghijklmnopqrstuvwxyz".split("").splice(0,#).join(",")',
- arity - 1);
+ 'String',
+ '"abcdefghijklmnopqrstuvwxyz".split("").splice(0,#).join(",")',
+ arity - 1,
+ );
return JS(
- '',
- '(new Function(#))()',
- 'return function($arguments){'
- 'return this.$interceptorField.$stubName(this.$receiverField, $arguments);'
- '${functionCounter++}'
- '}');
+ '',
+ '(new Function(#))()',
+ 'return function($arguments){'
+ 'return this.$interceptorField.$stubName(this.$receiverField, $arguments);'
+ '${functionCounter++}'
+ '}',
+ );
}
// The backend adds a special getter of the form
@@ -2592,7 +2895,7 @@
return "Closure '${unminifyOrTag(name)}'";
}
- Type get runtimeType => newRti.getRuntimeTypeOfClosure(this);
+ Type get runtimeType => rti.getRuntimeTypeOfClosure(this);
}
/// This is called by the fragment emitter.
@@ -2612,8 +2915,12 @@
final class StaticClosure extends TearOffClosure {
String toString() {
- String? name =
- JS('String|Null', '#[#]', this, STATIC_FUNCTION_NAME_PROPERTY_NAME);
+ String? name = JS(
+ 'String|Null',
+ '#[#]',
+ this,
+ STATIC_FUNCTION_NAME_PROPERTY_NAME,
+ );
if (name == null) return 'Closure of unknown static method';
return "Closure '${unminifyOrTag(name)}'";
}
@@ -2668,7 +2975,7 @@
@pragma('dart2js:parameter:trust')
static evalRecipe(BoundClosure closure, String recipe) {
- return newRti.evalInInstance(closure._receiver, recipe);
+ return rti.evalInInstance(closure._receiver, recipe);
}
@pragma('dart2js:noInline')
@@ -2692,7 +2999,8 @@
static String _computeFieldNamed(String fieldName) {
var template = BoundClosure('receiver', 'interceptor');
var names = JSArray.markFixedList(
- JS('', 'Object.getOwnPropertyNames(#)', template));
+ JS('', 'Object.getOwnPropertyNames(#)', template),
+ );
for (int i = 0; i < names.length; i++) {
var name = names[i];
if (JS('bool', '#[#] === #', template, name, fieldName)) {
@@ -2820,7 +3128,7 @@
if (false == condition) return true;
bool checked = condition as bool;
if (null == condition) {
- newRti.throwTypeError('assert condition must not be null');
+ rti.throwTypeError('assert condition must not be null');
}
return !checked;
}
@@ -2924,11 +3232,12 @@
DeferredLoadCallback? deferredLoadHook;
/// Add events to global initialization event log.
-void _addEvent(
- {required String part,
- required String event,
- String? loadId,
- String? hash}) {
+void _addEvent({
+ required String part,
+ required String event,
+ String? loadId,
+ String? hash,
+}) {
var initializationEventLog = JS_EMBEDDED_GLOBAL('', INITIALIZATION_EVENT_LOG);
var dataObj = JS('=Object', '{p: #, e: #}', part, event);
if (hash != null) JS('', '#.h = #', dataObj, hash);
@@ -2945,14 +3254,15 @@
var initializationEventLog = JS_EMBEDDED_GLOBAL('', INITIALIZATION_EVENT_LOG);
final o = JS('', 'Array.from(#).reverse()', initializationEventLog);
JS(
- '',
- '#.reduce((p, e, i, a) => {e.i = a.length - i; '
- 'if (p == null) return e.s; '
- 'if (e.s == null) return p; '
- 'if (e.s === p) { delete e.s; return p; }'
- 'return e.s;}'
- ', null)',
- o);
+ '',
+ '#.reduce((p, e, i, a) => {e.i = a.length - i; '
+ 'if (p == null) return e.s; '
+ 'if (e.s == null) return p; '
+ 'if (e.s === p) { delete e.s; return p; }'
+ 'return e.s;}'
+ ', null)',
+ o,
+ );
return JS('String', '#.map((e) => JSON.stringify(e)).join("\\n")', o);
}
@@ -3002,7 +3312,11 @@
var hash = hashes[i];
if (JS('bool', '#(#)', isHunkInitialized, hash)) {
_addEvent(
- part: uri, hash: hash, event: 'alreadyInitialized', loadId: loadId);
+ part: uri,
+ hash: hash,
+ event: 'alreadyInitialized',
+ loadId: loadId,
+ );
continue;
}
// This check is just an extra precaution, `isHunkLoaded(hash)` should
@@ -3014,9 +3328,11 @@
} else {
_addEvent(part: uri, hash: hash, event: 'missing', loadId: loadId);
- throw DeferredLoadException("Loading ${uris[i]} failed: "
- "the code with hash '${hash}' was not loaded.\n"
- "event log:\n${_getEventLog()}\n");
+ throw DeferredLoadException(
+ "Loading ${uris[i]} failed: "
+ "the code with hash '${hash}' was not loaded.\n"
+ "event log:\n${_getEventLog()}\n",
+ );
}
}
}
@@ -3032,13 +3348,20 @@
}
}
- var deferredLibraryMultiLoader =
- JS('', 'self.dartDeferredLibraryMultiLoader');
+ var deferredLibraryMultiLoader = JS(
+ '',
+ 'self.dartDeferredLibraryMultiLoader',
+ );
if (JS('bool', 'typeof # === "function"', deferredLibraryMultiLoader)) {
return _loadAllHunks(
- deferredLibraryMultiLoader, uris, hashes, loadId, priority, 0)
- .then((_) {
+ deferredLibraryMultiLoader,
+ uris,
+ hashes,
+ loadId,
+ priority,
+ 0,
+ ).then((_) {
waitingForLoad = List.filled(total, false);
finalizeLoad();
});
@@ -3119,8 +3442,13 @@
final Object? policyFactory = JS('', 'self.trustedTypes');
if (policyFactory == null) return fallbackPolicy;
- final Object? newPolicy = JS('', '#.createPolicy(#, #)', policyFactory,
- _deferredLoadingTrustedTypesPolicyName, policyOptions);
+ final Object? newPolicy = JS(
+ '',
+ '#.createPolicy(#, #)',
+ policyFactory,
+ _deferredLoadingTrustedTypesPolicyName,
+ policyOptions,
+ );
return newPolicy ?? fallbackPolicy;
}
@@ -3172,10 +3500,11 @@
// property is not set until the exception is thrown. The stack
// property was not provided until IE10.
stack = JS(
- 'String|Null',
- '(function() {'
- 'try { throw new Error() } catch(e) { return e.stack }'
- '})()');
+ 'String|Null',
+ '(function() {'
+ 'try { throw new Error() } catch(e) { return e.stack }'
+ '})()',
+ );
if (stack == null) throw UnsupportedError('No stack trace');
}
var pattern, matches;
@@ -3201,11 +3530,19 @@
Object _buildTrustedScriptUriWithRetry(String hunkName, int retryCount) {
return _getBasedScriptUrl(
- hunkName, retryCount > 0 ? '?dart2jsRetry=$retryCount' : '');
+ hunkName,
+ retryCount > 0 ? '?dart2jsRetry=$retryCount' : '',
+ );
}
-Future _loadAllHunks(Object loader, List<String> hunkNames, List<String> hashes,
- String loadId, String priority, int retryCount) {
+Future _loadAllHunks(
+ Object loader,
+ List<String> hunkNames,
+ List<String> hashes,
+ String loadId,
+ String priority,
+ int retryCount,
+) {
const int maxRetries = 3;
var isHunkLoaded = JS_EMBEDDED_GLOBAL('', IS_HUNK_LOADED);
@@ -3226,8 +3563,10 @@
} else {
hunksToLoad.add(hunkName);
hashesToLoad.add(hash);
- Object trustedScriptUri =
- _buildTrustedScriptUriWithRetry(hunkName, retryCount);
+ Object trustedScriptUri = _buildTrustedScriptUriWithRetry(
+ hunkName,
+ retryCount,
+ );
// [trustedScriptUri] is either a String, in which case `toString()` is
// an identity function, or it is a TrustedScriptURL and `toString()`
// returns the sanitized URL.
@@ -3247,30 +3586,46 @@
hunksToLoad.forEach((hunkName) => _loadingLibraries[hunkName] = completer);
_addEvent(part: loadedHunksString, event: 'downloadMulti', loadId: loadId);
- void failure(error, String context, StackTrace? stackTrace,
- List<String>? hunksToRetry, List<String>? hashesToRetry) {
+ void failure(
+ error,
+ String context,
+ StackTrace? stackTrace,
+ List<String>? hunksToRetry,
+ List<String>? hashesToRetry,
+ ) {
if (retryCount < maxRetries && hunksToRetry != null) {
_addEvent(
- part: hunksToRetry.join(';'),
- event: 'retry$retryCount',
- loadId: loadId);
+ part: hunksToRetry.join(';'),
+ event: 'retry$retryCount',
+ loadId: loadId,
+ );
for (var i = 0; i < hunksToRetry.length; i++) {
_loadingLibraries[hunksToRetry[i]] = null;
}
- _loadAllHunks(loader, hunksToRetry, hashesToRetry!, loadId, priority,
- retryCount + 1)
- .then((_) => completer.complete(null),
- onError: completer.completeError);
+ _loadAllHunks(
+ loader,
+ hunksToRetry,
+ hashesToRetry!,
+ loadId,
+ priority,
+ retryCount + 1,
+ ).then((_) => completer.complete(null), onError: completer.completeError);
} else {
_addEvent(
- part: loadedHunksString, event: 'downloadFailure', loadId: loadId);
+ part: loadedHunksString,
+ event: 'downloadFailure',
+ loadId: loadId,
+ );
hunksToLoad.forEach((hunkName) => _loadingLibraries[hunkName] = null);
stackTrace ??= StackTrace.current;
completer.completeError(
- DeferredLoadException('Loading $loadedHunksString failed: $error\n'
- 'Context: $context\n'
- 'event log:\n${_getEventLog()}\n'),
- stackTrace);
+ DeferredLoadException(
+ 'Loading $loadedHunksString failed: $error\n'
+ 'Context: $context\n'
+ 'event log:\n${_getEventLog()}\n',
+ ),
+ stackTrace,
+ );
}
}
@@ -3286,7 +3641,10 @@
}
if (hunksToRetry.isEmpty) {
_addEvent(
- part: loadedHunksString, event: 'downloadSuccess', loadId: loadId);
+ part: loadedHunksString,
+ event: 'downloadSuccess',
+ loadId: loadId,
+ );
completer.complete(null);
} else {
failure(
@@ -3312,18 +3670,36 @@
}, 1);
try {
- JS('void', '#(#, #, #, #, #)', loader, urisToLoad, jsSuccess, jsFailure,
- loadId, priority);
+ JS(
+ 'void',
+ '#(#, #, #, #, #)',
+ loader,
+ urisToLoad,
+ jsSuccess,
+ jsFailure,
+ loadId,
+ priority,
+ );
} catch (error, stackTrace) {
- failure(error, "invoking dartDeferredLibraryMultiLoader hook", stackTrace,
- hunksToLoad, hashesToLoad);
+ failure(
+ error,
+ "invoking dartDeferredLibraryMultiLoader hook",
+ stackTrace,
+ hunksToLoad,
+ hashesToLoad,
+ );
}
return Future.wait([...pendingLoads, completer.future]);
}
-Future<Null> _loadHunk(String hunkName, String loadId, String priority,
- String hash, int retryCount) {
+Future<Null> _loadHunk(
+ String hunkName,
+ String loadId,
+ String priority,
+ String hash,
+ int retryCount,
+) {
const int maxRetries = 3;
var completer = _loadingLibraries[hunkName];
@@ -3334,8 +3710,10 @@
}
completer ??= _loadingLibraries[hunkName] = Completer();
- Object trustedScriptUri =
- _buildTrustedScriptUriWithRetry(hunkName, retryCount);
+ Object trustedScriptUri = _buildTrustedScriptUriWithRetry(
+ hunkName,
+ retryCount,
+ );
String uriAsString = JS('', '#.toString()', trustedScriptUri);
_addEvent(part: hunkName, event: 'download', loadId: loadId);
@@ -3351,10 +3729,13 @@
_loadingLibraries[hunkName] = null;
stackTrace ??= StackTrace.current;
completer!.completeError(
- DeferredLoadException('Loading $uriAsString failed: $error\n'
- 'Context: $context\n'
- 'event log:\n${_getEventLog()}\n'),
- stackTrace);
+ DeferredLoadException(
+ 'Loading $uriAsString failed: $error\n'
+ 'Context: $context\n'
+ 'event log:\n${_getEventLog()}\n',
+ ),
+ stackTrace,
+ );
}
}
@@ -3366,22 +3747,36 @@
completer!.complete(null);
} else {
failure(
- 'Success callback invoked but part $hunkName not loaded.', '', null);
+ 'Success callback invoked but part $hunkName not loaded.',
+ '',
+ null,
+ );
}
}
var jsSuccess = convertDartClosureToJS(success, 0);
var jsFailure = convertDartClosureToJS((error) {
- failure(unwrapException(error), 'js-failure-wrapper',
- getTraceFromException(error));
+ failure(
+ unwrapException(error),
+ 'js-failure-wrapper',
+ getTraceFromException(error),
+ );
}, 1);
if (JS('bool', 'typeof # === "function"', deferredLibraryLoader)) {
try {
// Share the loadId that hunk belongs to, this will allow for any
// additional loadId based bundling optimizations.
- JS('void', '#(#, #, #, #, #)', deferredLibraryLoader, uriAsString,
- jsSuccess, jsFailure, loadId, priority);
+ JS(
+ 'void',
+ '#(#, #, #, #, #)',
+ deferredLibraryLoader,
+ uriAsString,
+ jsSuccess,
+ jsFailure,
+ loadId,
+ priority,
+ );
} catch (error, stackTrace) {
failure(error, "invoking dartDeferredLibraryLoader hook", stackTrace);
}
@@ -3390,24 +3785,25 @@
var xhr = JS('var', 'new XMLHttpRequest()');
JS('void', '#.open("GET", #)', xhr, uriAsString);
JS(
- 'void',
- '#.addEventListener("load", #, false)',
- xhr,
- convertDartClosureToJS((event) {
- int status = JS('int', '#.status', xhr);
- if (status != 200) {
- failure('Request status: $status', 'worker xhr', null);
- }
- String code = JS('String', '#.responseText', xhr);
- try {
- // Create a new function to avoid getting access to current function
- // context.
- JS('void', '(new Function(#))()', code);
- success();
- } catch (error, stackTrace) {
- failure(error, 'evaluating the code in worker xhr', stackTrace);
- }
- }, 1));
+ 'void',
+ '#.addEventListener("load", #, false)',
+ xhr,
+ convertDartClosureToJS((event) {
+ int status = JS('int', '#.status', xhr);
+ if (status != 200) {
+ failure('Request status: $status', 'worker xhr', null);
+ }
+ String code = JS('String', '#.responseText', xhr);
+ try {
+ // Create a new function to avoid getting access to current function
+ // context.
+ JS('void', '(new Function(#))()', code);
+ success();
+ } catch (error, stackTrace) {
+ failure(error, 'evaluating the code in worker xhr', stackTrace);
+ }
+ }, 1),
+ );
JS('void', '#.addEventListener("error", #, false)', xhr, (e) {
failure(e, 'xhr error handler', null);
@@ -3485,8 +3881,9 @@
// See tests/web/platform_environment_variable1_test.dart
const String testPlatformEnvironmentVariableValue = String.fromEnvironment(
- 'dart2js.test.platform.environment.variable',
- defaultValue: 'not-specified');
+ 'dart2js.test.platform.environment.variable',
+ defaultValue: 'not-specified',
+);
String testingGetPlatformEnvironmentVariable() {
return testPlatformEnvironmentVariableValue;
@@ -3510,8 +3907,10 @@
///
/// This function does not recurse if [value] is a collection.
void assertInterop(Object? value) {
- assert(value is! Function || isJSFunction(value),
- 'Dart function requires `allowInterop` to be passed to JavaScript.');
+ assert(
+ value is! Function || isJSFunction(value),
+ 'Dart function requires `allowInterop` to be passed to JavaScript.',
+ );
}
/// Like [assertInterop], except iterates over a list of arguments
@@ -3520,8 +3919,10 @@
/// This function intentionally avoids using [assertInterop] so that this
/// function can become a no-op if assertions are disabled.
void assertInteropArgs(List<Object?> args) {
- assert(args.every((arg) => arg is! Function || isJSFunction(arg)),
- 'Dart function requires `allowInterop` to be passed to JavaScript.');
+ assert(
+ args.every((arg) => arg is! Function || isJSFunction(arg)),
+ 'Dart function requires `allowInterop` to be passed to JavaScript.',
+ );
}
Object? rawStartupMetrics() {
diff --git a/sdk/lib/_internal/js_runtime/lib/records.dart b/sdk/lib/_internal/js_runtime/lib/records.dart
index 49de853..d688fc0 100644
--- a/sdk/lib/_internal/js_runtime/lib/records.dart
+++ b/sdk/lib/_internal/js_runtime/lib/records.dart
@@ -8,8 +8,12 @@
abstract final class _Record implements Record {
const _Record();
- int get _shapeTag => JS('JSUInt31', '#[#]', this,
- JS_GET_NAME(JsGetName.RECORD_SHAPE_TAG_PROPERTY));
+ int get _shapeTag => JS(
+ 'JSUInt31',
+ '#[#]',
+ this,
+ JS_GET_NAME(JsGetName.RECORD_SHAPE_TAG_PROPERTY),
+ );
bool _sameShape(_Record other) => _shapeTag == other._shapeTag;
@@ -19,13 +23,17 @@
Type get runtimeType {
// TODO(51040): Consider caching.
- return newRti.getRuntimeTypeOfRecord(this);
+ return rti.getRuntimeTypeOfRecord(this);
}
- newRti.Rti _getRti() {
- String recipe =
- JS('', '#[#]', this, JS_GET_NAME(JsGetName.RECORD_SHAPE_TYPE_PROPERTY));
- return newRti.evaluateRtiForRecord(recipe, _getFieldValues());
+ rti.Rti _getRti() {
+ String recipe = JS(
+ '',
+ '#[#]',
+ this,
+ JS_GET_NAME(JsGetName.RECORD_SHAPE_TYPE_PROPERTY),
+ );
+ return rti.evaluateRtiForRecord(recipe, _getFieldValues());
}
@override
@@ -67,8 +75,12 @@
}
List<Object> _computeFieldKeys() {
- String recipe =
- JS('', '#[#]', this, JS_GET_NAME(JsGetName.RECORD_SHAPE_TYPE_PROPERTY));
+ String recipe = JS(
+ '',
+ '#[#]',
+ this,
+ JS_GET_NAME(JsGetName.RECORD_SHAPE_TYPE_PROPERTY),
+ );
// TODO(50081): The Rti recipe format is agnostic to what the record shape
// key is. We happen to use a comma-separated list of the names for the
@@ -103,7 +115,7 @@
/// Entrypoint for rti library. Calls rti.evaluateRtiForRecord with components
/// of the record.
@pragma('dart2js:as:trust')
-newRti.Rti getRtiForRecord(Object? record) {
+rti.Rti getRtiForRecord(Object? record) {
return (record as _Record)._getRti();
}
@@ -249,7 +261,7 @@
r3 == anything();
rN == anything();
- newRti.pairwiseIsTest(anything() as JSArray, anything() as JSArray);
+ rti.pairwiseIsTest(anything() as JSArray, anything() as JSArray);
}
// TODO(50081): Can this be `external`?
diff --git a/tests/web/internal/rti/constant_type_test.dart b/tests/web/internal/rti/constant_type_test.dart
index 7e71eb7..21d7a33 100644
--- a/tests/web/internal/rti/constant_type_test.dart
+++ b/tests/web/internal/rti/constant_type_test.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// dart2jsOptions=--experiment-new-rti --no-minify
+// dart2jsOptions=--no-minify
import "package:expect/expect.dart";
diff --git a/tests/web/internal/rti/runtime_type_1_test.dart b/tests/web/internal/rti/runtime_type_1_test.dart
index a3bcf05..4a141f4 100644
--- a/tests/web/internal/rti/runtime_type_1_test.dart
+++ b/tests/web/internal/rti/runtime_type_1_test.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// dart2jsOptions=--experiment-new-rti --no-minify
+// dart2jsOptions=--no-minify
import 'dart:_rti' as rti;
import "package:expect/expect.dart";
diff --git a/tests/web/internal/rti/runtime_type_2_test.dart b/tests/web/internal/rti/runtime_type_2_test.dart
index d8cd534..bf0f453 100644
--- a/tests/web/internal/rti/runtime_type_2_test.dart
+++ b/tests/web/internal/rti/runtime_type_2_test.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// dart2jsOptions=--experiment-new-rti --no-minify
+// dart2jsOptions=--no-minify
import "package:expect/expect.dart";
diff --git a/tests/web/internal/rti/runtime_type_3_test.dart b/tests/web/internal/rti/runtime_type_3_test.dart
index 89b8c8b..a162887 100644
--- a/tests/web/internal/rti/runtime_type_3_test.dart
+++ b/tests/web/internal/rti/runtime_type_3_test.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// dart2jsOptions=--experiment-new-rti --no-minify
+// dart2jsOptions=--no-minify
import "package:expect/expect.dart";
import "dart:_foreign_helper" show JS;
diff --git a/tests/web/internal/rti/simple_is_function_type2_test.dart b/tests/web/internal/rti/simple_is_function_type2_test.dart
index 06e490d..06e1240 100644
--- a/tests/web/internal/rti/simple_is_function_type2_test.dart
+++ b/tests/web/internal/rti/simple_is_function_type2_test.dart
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// dart2jsOptions=--experiment-new-rti
-
import "package:expect/expect.dart";
int fnInt2Int(int x) => x;
diff --git a/tests/web/internal/rti/simple_is_function_type3_test.dart b/tests/web/internal/rti/simple_is_function_type3_test.dart
index 78c5469..dabdb00 100644
--- a/tests/web/internal/rti/simple_is_function_type3_test.dart
+++ b/tests/web/internal/rti/simple_is_function_type3_test.dart
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// dart2jsOptions=--experiment-new-rti
-
// Test that some closures are 'is Function'.
import "package:expect/expect.dart";
diff --git a/tests/web/internal/rti/simple_is_function_type_test.dart b/tests/web/internal/rti/simple_is_function_type_test.dart
index 2f32edc..7ee2e79 100644
--- a/tests/web/internal/rti/simple_is_function_type_test.dart
+++ b/tests/web/internal/rti/simple_is_function_type_test.dart
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// dart2jsOptions=--experiment-new-rti
-
import 'dart:_rti' as rti;
import "package:expect/expect.dart";
diff --git a/tests/web/internal/rti/simple_is_test.dart b/tests/web/internal/rti/simple_is_test.dart
index fb82ac4..3f0bac7 100644
--- a/tests/web/internal/rti/simple_is_test.dart
+++ b/tests/web/internal/rti/simple_is_test.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// dart2jsOptions=--experiment-new-rti --no-minify
+// dart2jsOptions=--no-minify
import 'dart:_rti' as rti;
import "package:expect/expect.dart";
diff --git a/tests/web/internal/rti/simple_type_bound_test.dart b/tests/web/internal/rti/simple_type_bound_test.dart
index 29a8761..6268d0e 100644
--- a/tests/web/internal/rti/simple_type_bound_test.dart
+++ b/tests/web/internal/rti/simple_type_bound_test.dart
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// dart2jsOptions=--experiment-new-rti
-
import "package:expect/expect.dart";
@pragma('dart2js:noInline')
diff --git a/tests/web/lax_runtime_type_closure_to_string3_test.dart b/tests/web/lax_runtime_type_closure_to_string3_test.dart
index 5f0edff..3c4d521 100644
--- a/tests/web/lax_runtime_type_closure_to_string3_test.dart
+++ b/tests/web/lax_runtime_type_closure_to_string3_test.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// dart2jsOptions=--omit-implicit-checks --lax-runtime-type-to-string --experiment-new-rti
+// dart2jsOptions=--omit-implicit-checks --lax-runtime-type-to-string
import 'package:expect/expect.dart';
diff --git a/tests/web/runtime_type_to_string1_test.dart b/tests/web/runtime_type_to_string1_test.dart
index d61335f..76848fb 100644
--- a/tests/web/runtime_type_to_string1_test.dart
+++ b/tests/web/runtime_type_to_string1_test.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// dart2jsOptions=--strong --omit-implicit-checks --lax-runtime-type-to-string --experiment-new-rti
+// dart2jsOptions=--strong --omit-implicit-checks --lax-runtime-type-to-string
import 'package:expect/expect.dart';