[dart2js] migrate world.dart

Change-Id: Ib0bc169bc58675e9202a35fd232cf24f1dfac1e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262278
Reviewed-by: Nate Biggs <natebiggs@google.com>
This commit is contained in:
Sigmund Cherem 2022-10-03 17:49:56 +00:00 committed by Commit Queue
parent 9768f74c59
commit c41cec8f50
6 changed files with 23 additions and 9 deletions

View file

@ -25,6 +25,8 @@ import '../universe/selector.dart' show Selector;
import '../world.dart' show JClosedWorld;
import 'abstract_value_domain.dart';
import 'types_interfaces.dart' as interfaces;
/// Results about a single element (e.g. a method, parameter, or field)
/// produced by the global type-inference algorithm.
///
@ -114,7 +116,8 @@ abstract class TypesInferrer {
/// closed-world semantics. Any [AbstractValue] for an element or node that we
/// return was inferred to be a "guaranteed type", that means, it is a type that
/// we can prove to be correct for all executions of the program.
abstract class GlobalTypeInferenceResults {
abstract class GlobalTypeInferenceResults
implements interfaces.GlobalTypeInferenceResults {
/// Deserializes a [GlobalTypeInferenceResults] object from [source].
factory GlobalTypeInferenceResults.readFromDataSource(
DataSourceReader source,

View file

@ -0,0 +1,5 @@
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// 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.
abstract class GlobalTypeInferenceResults {}

View file

@ -239,7 +239,9 @@ class NoSuchMethodData implements interfaces.NoSuchMethodData {
/// Now that type inference is complete, split category D into two
/// subcategories: D1, those that have no return type, and D2, those
/// that have a return type.
void categorizeComplexImplementations(GlobalTypeInferenceResults results) {
@override
void categorizeComplexImplementations(
covariant GlobalTypeInferenceResults results) {
_otherImpls.forEach((FunctionEntity element) {
if (results.resultOfMember(element).throwsAlways) {
_complexNoReturnImpls.add(element);
@ -250,6 +252,7 @@ class NoSuchMethodData implements interfaces.NoSuchMethodData {
}
/// Emits a diagnostic about methods in categories `B`, `D1` and `D2`.
@override
void emitDiagnostic(DiagnosticReporter reporter) {
_throwingImpls.forEach((e) {
if (!_forwardingSyntaxImpls.contains(e)) {

View file

@ -2,7 +2,9 @@
// 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.
import '../common.dart';
import '../elements/entities.dart';
import '../inferrer/types_interfaces.dart';
abstract class NoSuchMethodRegistry {
void registerNoSuchMethod(FunctionEntity noSuchMethodElement);
@ -13,4 +15,6 @@ abstract class NoSuchMethodRegistry {
abstract class NoSuchMethodData {
bool isComplex(FunctionEntity element);
void categorizeComplexImplementations(GlobalTypeInferenceResults results);
void emitDiagnostic(DiagnosticReporter reporter);
}

View file

@ -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.
// @dart = 2.10
library dart2js.world;
import 'closure.dart';
@ -18,7 +16,8 @@ import 'js_backend/field_analysis.dart' show JFieldAnalysis;
import 'js_backend/backend_usage.dart' show BackendUsage;
import 'js_backend/interceptor_data.dart' show InterceptorData;
import 'js_backend/native_data.dart' show NativeData;
import 'js_backend/no_such_method_registry.dart' show NoSuchMethodData;
import 'js_backend/no_such_method_registry_interfaces.dart'
show NoSuchMethodData;
import 'js_backend/runtime_types_resolution.dart' show RuntimeTypesNeed;
import 'js_emitter/sorter.dart';
import 'universe/class_hierarchy.dart';
@ -212,7 +211,7 @@ abstract class JClosedWorld implements interfaces.JClosedWorld {
/// signature so it cannot be modelled by a [FunctionEntity]. Also,
/// call-methods for tear-off are not part of the element model.
@override
bool includesClosureCall(Selector selector, AbstractValue receiver);
bool includesClosureCall(Selector selector, AbstractValue? receiver);
/// Returns the mask for the potential receivers of a dynamic call to
/// [selector] on [receiver].
@ -229,7 +228,7 @@ abstract class JClosedWorld implements interfaces.JClosedWorld {
/// mechanism.
@override
Iterable<MemberEntity> locateMembersInDomain(Selector selector,
AbstractValue receiver, AbstractValueDomain abstractValueDomain);
AbstractValue? receiver, AbstractValueDomain abstractValueDomain);
/// Returns all the instance members that may be invoked with the [selector]
/// on the given [receiver]. The returned elements may include noSuchMethod
@ -237,7 +236,7 @@ abstract class JClosedWorld implements interfaces.JClosedWorld {
/// mechanism.
@override
Iterable<MemberEntity> locateMembers(
Selector selector, AbstractValue receiver);
Selector selector, AbstractValue? receiver);
/// Returns the single [MemberEntity] that matches a call to [selector] on the
/// [receiver]. If multiple targets exist, `null` is returned.

View file

@ -78,7 +78,7 @@ abstract class JClosedWorld implements World {
AbstractValueDomain abstractValueDomain);
Iterable<MemberEntity> locateMembersInDomain(Selector selector,
AbstractValue receiver, AbstractValueDomain abstractValueDomain);
AbstractValue? receiver, AbstractValueDomain abstractValueDomain);
bool everySubtypeIsSubclassOfOrMixinUseOf(ClassEntity x, ClassEntity y);