From c41cec8f50966ef0ac3e40b8d761555c51538dba Mon Sep 17 00:00:00 2001 From: Sigmund Cherem Date: Mon, 3 Oct 2022 17:49:56 +0000 Subject: [PATCH] [dart2js] migrate world.dart Change-Id: Ib0bc169bc58675e9202a35fd232cf24f1dfac1e7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262278 Reviewed-by: Nate Biggs --- pkg/compiler/lib/src/inferrer/types.dart | 5 ++++- pkg/compiler/lib/src/inferrer/types_interfaces.dart | 5 +++++ .../lib/src/js_backend/no_such_method_registry.dart | 5 ++++- .../no_such_method_registry_interfaces.dart | 4 ++++ pkg/compiler/lib/src/world.dart | 11 +++++------ pkg/compiler/lib/src/world_interfaces.dart | 2 +- 6 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 pkg/compiler/lib/src/inferrer/types_interfaces.dart diff --git a/pkg/compiler/lib/src/inferrer/types.dart b/pkg/compiler/lib/src/inferrer/types.dart index 53f8723442f..79e7bc0ccae 100644 --- a/pkg/compiler/lib/src/inferrer/types.dart +++ b/pkg/compiler/lib/src/inferrer/types.dart @@ -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, diff --git a/pkg/compiler/lib/src/inferrer/types_interfaces.dart b/pkg/compiler/lib/src/inferrer/types_interfaces.dart new file mode 100644 index 00000000000..577f273fbe1 --- /dev/null +++ b/pkg/compiler/lib/src/inferrer/types_interfaces.dart @@ -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 {} diff --git a/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart b/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart index 4241ec7afd4..f20fa2c11f5 100644 --- a/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart +++ b/pkg/compiler/lib/src/js_backend/no_such_method_registry.dart @@ -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)) { diff --git a/pkg/compiler/lib/src/js_backend/no_such_method_registry_interfaces.dart b/pkg/compiler/lib/src/js_backend/no_such_method_registry_interfaces.dart index bed5dee1fd3..18de596508d 100644 --- a/pkg/compiler/lib/src/js_backend/no_such_method_registry_interfaces.dart +++ b/pkg/compiler/lib/src/js_backend/no_such_method_registry_interfaces.dart @@ -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); } diff --git a/pkg/compiler/lib/src/world.dart b/pkg/compiler/lib/src/world.dart index b7b9e0b12cf..d056a6d4ecd 100644 --- a/pkg/compiler/lib/src/world.dart +++ b/pkg/compiler/lib/src/world.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. -// @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 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 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. diff --git a/pkg/compiler/lib/src/world_interfaces.dart b/pkg/compiler/lib/src/world_interfaces.dart index eae16605129..774934d86f5 100644 --- a/pkg/compiler/lib/src/world_interfaces.dart +++ b/pkg/compiler/lib/src/world_interfaces.dart @@ -78,7 +78,7 @@ abstract class JClosedWorld implements World { AbstractValueDomain abstractValueDomain); Iterable locateMembersInDomain(Selector selector, - AbstractValue receiver, AbstractValueDomain abstractValueDomain); + AbstractValue? receiver, AbstractValueDomain abstractValueDomain); bool everySubtypeIsSubclassOfOrMixinUseOf(ClassEntity x, ClassEntity y);