[dart2js] migrate ssa/types.dart

Change-Id: I721f584c61ff40863d4e9461330bb0d1db11d0d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263080
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
This commit is contained in:
Stephen Adams 2022-10-07 18:50:17 +00:00 committed by Commit Queue
parent 8d1297628a
commit fe98a5642e

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
import '../common/elements.dart' show CommonElements;
import '../elements/entities.dart';
import '../elements/types.dart';
@ -16,26 +14,22 @@ import '../world_interfaces.dart' show JClosedWorld;
class AbstractValueFactory {
static AbstractValue inferredReturnTypeForElement(
FunctionEntity element, GlobalTypeInferenceResults results) {
return results.resultOfMember(element).returnType ??
results.closedWorld.abstractValueDomain.dynamicType;
return results.resultOfMember(element).returnType;
}
static AbstractValue inferredTypeForMember(
MemberEntity element, GlobalTypeInferenceResults results) {
return results.resultOfMember(element).type ??
results.closedWorld.abstractValueDomain.dynamicType;
return results.resultOfMember(element).type;
}
static AbstractValue inferredTypeForParameter(
Local element, GlobalTypeInferenceResults results) {
return results.resultOfParameter(element) ??
results.closedWorld.abstractValueDomain.dynamicType;
return results.resultOfParameter(element);
}
static AbstractValue inferredResultTypeForSelector(Selector selector,
AbstractValue receiver, GlobalTypeInferenceResults results) {
return results.resultTypeOfSelector(selector, receiver) ??
results.closedWorld.abstractValueDomain.dynamicType;
return results.resultTypeOfSelector(selector, receiver);
}
static AbstractValue fromNativeBehavior(
@ -52,17 +46,22 @@ class AbstractValueFactory {
if (type == SpecialType.JsObject) {
return abstractValueDomain
.createNonNullExact(commonElements.objectClass);
} else if (type is VoidType) {
return abstractValueDomain.nullType;
} else if (closedWorld.dartTypes.isTopType(type)) {
return abstractValueDomain.dynamicType;
} else if (type == commonElements.nullType) {
return abstractValueDomain.nullType;
} else if (type is InterfaceType) {
return abstractValueDomain.createNonNullSubtype(type.element);
} else {
throw 'Unexpected type $type';
}
if (type is DartType) {
if (type is VoidType) {
return abstractValueDomain.nullType;
}
if (closedWorld.dartTypes.isTopType(type)) {
return abstractValueDomain.dynamicType;
}
if (type == commonElements.nullType) {
return abstractValueDomain.nullType;
}
if (type is InterfaceType) {
return abstractValueDomain.createNonNullSubtype(type.element);
}
}
throw 'Unexpected type $type';
}
AbstractValue result =