mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 08:24:39 +00:00
[dart2js] Remove typedefs from backend.
Change-Id: Ia170535b5d35d97003cff93acbf33cb3fe75725f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134206 Reviewed-by: Sigmund Cherem <sigmund@google.com> Commit-Queue: Mayank Patke <fishythefish@google.com>
This commit is contained in:
parent
f831f121d7
commit
450924a8cd
|
@ -22,22 +22,22 @@ const null_ = /*cfe.TypeLiteral(Null)*/ Null;
|
|||
main() {
|
||||
print(
|
||||
/*cfe|analyzer.TypeLiteral(dynamic Function())*/
|
||||
/*dart2js.TypeLiteral(Typedef)*/
|
||||
/*dart2js.TypeLiteral(()->dynamic)*/
|
||||
typedef);
|
||||
|
||||
print(
|
||||
/*cfe|analyzer.TypeLiteral(void Function(dynamic))*/
|
||||
/*dart2js.TypeLiteral(GenericTypedef<dynamic>)*/
|
||||
/*dart2js.TypeLiteral((dynamic)->void)*/
|
||||
genericTypedef);
|
||||
|
||||
print(
|
||||
/*cfe|analyzer.TypeLiteral(void Function<T>(T))*/
|
||||
/*dart2js.TypeLiteral(GenericFunctionTypedef)*/
|
||||
/*dart2js.TypeLiteral((0)->void)*/
|
||||
genericFunctionTypedef);
|
||||
|
||||
print(
|
||||
/*cfe|analyzer.TypeLiteral(void Function<T>(FutureOr<T>))*/
|
||||
/*dart2js.TypeLiteral(TypedefWithFutureOr)*/
|
||||
/*dart2js.TypeLiteral((FutureOr<0>)->void)*/
|
||||
typedefWithFutureOr);
|
||||
|
||||
print(
|
||||
|
|
|
@ -676,13 +676,6 @@ class ModularName extends js.Name implements js.AstContainer {
|
|||
break;
|
||||
case ModularNameKind.globalPropertyNameForType:
|
||||
case ModularNameKind.runtimeTypeName:
|
||||
bool dataIsClassEntity = source.readBool();
|
||||
if (dataIsClassEntity) {
|
||||
data = source.readClass();
|
||||
} else {
|
||||
data = source.readTypedef();
|
||||
}
|
||||
break;
|
||||
case ModularNameKind.className:
|
||||
case ModularNameKind.operatorIs:
|
||||
case ModularNameKind.substitution:
|
||||
|
@ -730,13 +723,6 @@ class ModularName extends js.Name implements js.AstContainer {
|
|||
break;
|
||||
case ModularNameKind.globalPropertyNameForType:
|
||||
case ModularNameKind.runtimeTypeName:
|
||||
sink.writeBool(data is ClassEntity);
|
||||
if (data is ClassEntity) {
|
||||
sink.writeClass(data);
|
||||
} else {
|
||||
sink.writeTypedef(data);
|
||||
}
|
||||
break;
|
||||
case ModularNameKind.className:
|
||||
case ModularNameKind.operatorIs:
|
||||
case ModularNameKind.substitution:
|
||||
|
@ -868,12 +854,7 @@ class ModularExpression extends js.DeferredExpression
|
|||
data = source.readClass();
|
||||
break;
|
||||
case ModularExpressionKind.globalObjectForType:
|
||||
bool dataIsClassEntity = source.readBool();
|
||||
if (dataIsClassEntity) {
|
||||
data = source.readClass();
|
||||
} else {
|
||||
data = source.readTypedef();
|
||||
}
|
||||
data = source.readClass();
|
||||
break;
|
||||
case ModularExpressionKind.globalObjectForMember:
|
||||
data = source.readMember();
|
||||
|
@ -900,12 +881,7 @@ class ModularExpression extends js.DeferredExpression
|
|||
sink.writeClass(data);
|
||||
break;
|
||||
case ModularExpressionKind.globalObjectForType:
|
||||
sink.writeBool(data is ClassEntity);
|
||||
if (data is ClassEntity) {
|
||||
sink.writeClass(data);
|
||||
} else {
|
||||
sink.writeTypedef(data);
|
||||
}
|
||||
sink.writeClass(data);
|
||||
break;
|
||||
case ModularExpressionKind.globalObjectForMember:
|
||||
sink.writeMember(data);
|
||||
|
|
|
@ -173,10 +173,6 @@ abstract class DeferredLoadTask extends CompilerTask {
|
|||
Iterable<ImportEntity> memberImportsTo(
|
||||
MemberEntity element, LibraryEntity library);
|
||||
|
||||
/// Returns every [ImportEntity] that imports [element] into [library].
|
||||
Iterable<ImportEntity> typedefImportsTo(
|
||||
TypedefEntity element, LibraryEntity library);
|
||||
|
||||
/// Collects all direct dependencies of [element].
|
||||
///
|
||||
/// The collected dependent elements and constants are are added to
|
||||
|
@ -558,10 +554,6 @@ abstract class DeferredLoadTask extends CompilerTask {
|
|||
var imports = classImportsTo(type.element, library);
|
||||
_fixDependencyInfo(
|
||||
info, imports, "Class (in constant) ", type.element.name, context);
|
||||
} else if (type is TypedefType) {
|
||||
var imports = typedefImportsTo(type.element, library);
|
||||
_fixDependencyInfo(
|
||||
info, imports, "Typedef ", type.element.name, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1696,12 +1688,6 @@ class TypeDependencyVisitor implements DartTypeVisitor<void, Null> {
|
|||
// Nothing to add.
|
||||
}
|
||||
|
||||
@override
|
||||
void visitTypedefType(TypedefType type, Null argument) {
|
||||
visitList(type.typeArguments);
|
||||
visit(type.unaliased);
|
||||
}
|
||||
|
||||
@override
|
||||
void visitInterfaceType(InterfaceType type, Null argument) {
|
||||
visitList(type.typeArguments);
|
||||
|
|
|
@ -75,11 +75,6 @@ abstract class ClassEntity extends Entity {
|
|||
bool get isAbstract;
|
||||
}
|
||||
|
||||
abstract class TypedefEntity extends Entity {
|
||||
/// The library in which the typedef was declared.
|
||||
LibraryEntity get library;
|
||||
}
|
||||
|
||||
abstract class TypeVariableEntity extends Entity {
|
||||
/// The class or generic method that declared this type variable.
|
||||
Entity get typeDeclaration;
|
||||
|
|
|
@ -45,11 +45,6 @@ abstract class IndexedTypeVariable extends _Indexed
|
|||
int get typeVariableIndex => _index;
|
||||
}
|
||||
|
||||
abstract class IndexedTypedef extends _Indexed implements TypedefEntity {
|
||||
/// Typedef index used for fast lookup in [KernelToElementMapBase].
|
||||
int get typedefIndex => _index;
|
||||
}
|
||||
|
||||
abstract class IndexedLocal extends _Indexed implements Local {
|
||||
int get localIndex => _index;
|
||||
}
|
||||
|
|
|
@ -292,68 +292,6 @@ class InterfaceType extends DartType {
|
|||
}
|
||||
}
|
||||
|
||||
class TypedefType extends DartType {
|
||||
final TypedefEntity element;
|
||||
final List<DartType> typeArguments;
|
||||
@override
|
||||
final FunctionType unaliased;
|
||||
|
||||
TypedefType(this.element, this.typeArguments, this.unaliased);
|
||||
|
||||
@override
|
||||
bool _isTop(bool isLegacy) => unaliased._isTop(isLegacy);
|
||||
|
||||
@override
|
||||
bool get containsTypeVariables =>
|
||||
typeArguments.any((type) => type.containsTypeVariables);
|
||||
|
||||
@override
|
||||
void forEachTypeVariable(f(TypeVariableType variable)) {
|
||||
typeArguments.forEach((type) => type.forEachTypeVariable(f));
|
||||
}
|
||||
|
||||
@override
|
||||
bool _treatAsRaw(bool isLegacy) {
|
||||
for (DartType type in typeArguments) {
|
||||
if (!type._isTop(isLegacy)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@override
|
||||
R accept<R, A>(DartTypeVisitor<R, A> visitor, A argument) =>
|
||||
visitor.visitTypedefType(this, argument);
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
int hash = element.hashCode;
|
||||
for (DartType argument in typeArguments) {
|
||||
int argumentHash = argument != null ? argument.hashCode : 0;
|
||||
hash = 17 * hash + 3 * argumentHash;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
if (identical(this, other)) return true;
|
||||
if (other is! TypedefType) return false;
|
||||
return _equalsInternal(other, null);
|
||||
}
|
||||
|
||||
@override
|
||||
bool _equals(DartType other, _Assumptions assumptions) {
|
||||
if (identical(this, other)) return true;
|
||||
if (other is! TypedefType) return false;
|
||||
return _equalsInternal(other, assumptions);
|
||||
}
|
||||
|
||||
bool _equalsInternal(TypedefType other, _Assumptions assumptions) {
|
||||
return identical(element, other.element) &&
|
||||
_equalTypes(typeArguments, other.typeArguments, assumptions);
|
||||
}
|
||||
}
|
||||
|
||||
class TypeVariableType extends DartType {
|
||||
final TypeVariableEntity element;
|
||||
|
||||
|
@ -752,8 +690,6 @@ abstract class DartTypeVisitor<R, A> {
|
|||
|
||||
R visitInterfaceType(covariant InterfaceType type, A argument) => null;
|
||||
|
||||
R visitTypedefType(covariant TypedefType type, A argument) => null;
|
||||
|
||||
R visitDynamicType(covariant DynamicType type, A argument) => null;
|
||||
|
||||
R visitErasedType(covariant ErasedType type, A argument) => null;
|
||||
|
@ -1012,22 +948,6 @@ abstract class DartTypeSubstitutionVisitor<A>
|
|||
return _mapped(type, InterfaceType(type.element, newTypeArguments));
|
||||
}
|
||||
|
||||
@override
|
||||
DartType visitTypedefType(covariant TypedefType type, A argument) {
|
||||
DartType probe = _map[type];
|
||||
if (probe != null) return probe;
|
||||
|
||||
List<DartType> newTypeArguments = _substTypes(type.typeArguments, argument);
|
||||
FunctionType newUnaliased = visit(type.unaliased, argument);
|
||||
// Create a new type only if necessary.
|
||||
if (identical(type.typeArguments, newTypeArguments) &&
|
||||
identical(type.unaliased, newUnaliased)) {
|
||||
return _mapped(type, type);
|
||||
}
|
||||
return _mapped(
|
||||
type, TypedefType(type.element, newTypeArguments, newUnaliased));
|
||||
}
|
||||
|
||||
@override
|
||||
DartType visitDynamicType(covariant DynamicType type, A argument) => type;
|
||||
|
||||
|
@ -1107,7 +1027,6 @@ abstract class DartTypeStructuralPredicateVisitor
|
|||
bool handleFreeFunctionTypeVariable(FunctionTypeVariable type) => false;
|
||||
bool handleFunctionType(FunctionType type) => false;
|
||||
bool handleInterfaceType(InterfaceType type) => false;
|
||||
bool handleTypedefType(TypedefType type) => false;
|
||||
bool handleDynamicType(DynamicType type) => false;
|
||||
bool handleErasedType(ErasedType type) => false;
|
||||
bool handleAnyType(AnyType type) => false;
|
||||
|
@ -1172,13 +1091,6 @@ abstract class DartTypeStructuralPredicateVisitor
|
|||
return _visitAll(type.typeArguments, bindings);
|
||||
}
|
||||
|
||||
@override
|
||||
bool visitTypedefType(TypedefType type, List<FunctionTypeVariable> bindings) {
|
||||
if (handleTypedefType(type)) return true;
|
||||
if (_visitAll(type.typeArguments, bindings)) return true;
|
||||
return visit(type.unaliased, bindings);
|
||||
}
|
||||
|
||||
@override
|
||||
bool visitDynamicType(
|
||||
DynamicType type, List<FunctionTypeVariable> bindings) =>
|
||||
|
@ -1452,12 +1364,6 @@ class _DartTypeToStringVisitor extends DartTypeVisitor<void, void> {
|
|||
_optionalTypeArguments(type.typeArguments);
|
||||
}
|
||||
|
||||
@override
|
||||
void visitTypedefType(covariant TypedefType type, _) {
|
||||
_identifier(type.element.name);
|
||||
_optionalTypeArguments(type.typeArguments);
|
||||
}
|
||||
|
||||
void _optionalTypeArguments(List<DartType> types) {
|
||||
if (types.isNotEmpty) {
|
||||
_token('<');
|
||||
|
|
|
@ -2262,7 +2262,7 @@ AbstractValue _narrowType(
|
|||
otherType = abstractValueDomain.createNonNullSubtype(annotation.element);
|
||||
} else if (annotation is VoidType) {
|
||||
return type;
|
||||
} else if (annotation is TypedefType || annotation is FunctionType) {
|
||||
} else if (annotation is FunctionType) {
|
||||
otherType = closedWorld.abstractValueDomain.functionType;
|
||||
} else if (annotation is FutureOrType) {
|
||||
// TODO(johnniwinther): Narrow FutureOr types.
|
||||
|
|
|
@ -335,7 +335,7 @@ class TypeSystem {
|
|||
otherType =
|
||||
_abstractValueDomain.createNonNullSubtype(interface.element);
|
||||
}
|
||||
} else if (annotation is TypedefType || annotation is FunctionType) {
|
||||
} else if (annotation is FunctionType) {
|
||||
otherType = functionType.type;
|
||||
} else if (annotation is FutureOrType) {
|
||||
// TODO(johnniwinther): Support narrowing of FutureOr.
|
||||
|
|
|
@ -42,9 +42,6 @@ abstract class IrToElementMap {
|
|||
/// Returns the [FunctionType] of the [node].
|
||||
FunctionType getFunctionType(ir.FunctionNode node);
|
||||
|
||||
/// Returns the [TypedefType] corresponding to raw type of the typedef [node].
|
||||
TypedefType getTypedefType(ir.Typedef node);
|
||||
|
||||
/// Return the [InterfaceType] corresponding to the [cls] with the given
|
||||
/// [typeArguments].
|
||||
InterfaceType createInterfaceType(
|
||||
|
|
|
@ -173,13 +173,7 @@ class ConstantValuefier extends ir.ComputeOnceConstantVisitor<ConstantValue> {
|
|||
|
||||
@override
|
||||
ConstantValue visitTypeLiteralConstant(ir.TypeLiteralConstant node) {
|
||||
DartType type;
|
||||
if (node.type is ir.FunctionType) {
|
||||
ir.FunctionType functionType = node.type;
|
||||
type = elementMap.getTypedefType(functionType.typedef);
|
||||
} else {
|
||||
type = elementMap.getDartType(node.type);
|
||||
}
|
||||
DartType type = elementMap.getDartType(node.type);
|
||||
return constant_system.createType(elementMap.commonElements, type);
|
||||
}
|
||||
|
||||
|
|
|
@ -203,8 +203,6 @@ class CheckedModeHelpers {
|
|||
String getCheckedModeHelperNameInternal(
|
||||
DartType type, CommonElements commonElements,
|
||||
{bool typeCast, bool nativeCheckOnly}) {
|
||||
assert(type is! TypedefType);
|
||||
|
||||
DartTypes dartTypes = commonElements.dartTypes;
|
||||
|
||||
if (type is TypeVariableType) {
|
||||
|
|
|
@ -1433,17 +1433,11 @@ class Namer extends ModularNamer {
|
|||
}
|
||||
|
||||
String globalObjectForType(Entity element) {
|
||||
if (element is TypedefEntity) {
|
||||
return globalObjectForLibrary(element.library);
|
||||
}
|
||||
return globalObjectForClass(element);
|
||||
}
|
||||
|
||||
@override
|
||||
jsAst.VariableUse readGlobalObjectForType(Entity element) {
|
||||
if (element is TypedefEntity) {
|
||||
return readGlobalObjectForLibrary(element.library);
|
||||
}
|
||||
return readGlobalObjectForClass(element);
|
||||
}
|
||||
|
||||
|
@ -1619,10 +1613,6 @@ class Namer extends ModularNamer {
|
|||
|
||||
String getTypeRepresentationForTypeConstant(DartType type) {
|
||||
if (type is DynamicType) return "dynamic";
|
||||
if (type is TypedefType) {
|
||||
return uniqueNameForTypeConstantElement(
|
||||
type.element.library, type.element);
|
||||
}
|
||||
if (type is FutureOrType) {
|
||||
return "FutureOr<dynamic>";
|
||||
}
|
||||
|
@ -1897,8 +1887,6 @@ class ConstantNamingVisitor implements ConstantValueVisitor {
|
|||
String name;
|
||||
if (type is InterfaceType) {
|
||||
name = type.element.name;
|
||||
} else if (type is TypedefType) {
|
||||
name = type.element.name;
|
||||
}
|
||||
if (name == null) {
|
||||
// e.g. DartType 'dynamic' has no element.
|
||||
|
@ -2171,11 +2159,6 @@ class FunctionTypeNamer extends BaseDartTypeVisitor {
|
|||
sb.write(type.element.name);
|
||||
}
|
||||
|
||||
@override
|
||||
visitTypedefType(TypedefType type, _) {
|
||||
sb.write(type.element.name);
|
||||
}
|
||||
|
||||
@override
|
||||
visitTypeVariableType(TypeVariableType type, _) {
|
||||
sb.write(type.element.name);
|
||||
|
@ -2581,8 +2564,6 @@ abstract class ModularNamer {
|
|||
return asName(fixedNames.operatorSignature);
|
||||
case JsGetName.RTI_NAME:
|
||||
return asName(fixedNames.rtiName);
|
||||
case JsGetName.TYPEDEF_TAG:
|
||||
return asName(rtiTags.typedefTag);
|
||||
case JsGetName.FUNCTION_TYPE_TAG:
|
||||
return asName(rtiTags.functionTypeTag);
|
||||
case JsGetName.FUNCTION_TYPE_GENERIC_BOUNDS_TAG:
|
||||
|
|
|
@ -270,7 +270,7 @@ class ResolutionEnqueuerListener extends EnqueuerListener {
|
|||
..addAll(functionType.optionalParameterTypes)
|
||||
..addAll(functionType.namedParameterTypes);
|
||||
for (var type in allParameterTypes) {
|
||||
if (type is FunctionType || type is TypedefType) {
|
||||
if (type is FunctionType) {
|
||||
var closureConverter = _commonElements.closureConverter;
|
||||
worldImpact.registerStaticUse(
|
||||
new StaticUse.implicitInvoke(closureConverter));
|
||||
|
|
|
@ -27,7 +27,6 @@ import 'runtime_types_codegen.dart';
|
|||
import 'runtime_types_resolution.dart';
|
||||
|
||||
typedef jsAst.Expression OnVariableCallback(TypeVariableType variable);
|
||||
typedef bool ShouldEncodeTypedefCallback(TypedefType variable);
|
||||
|
||||
/// Interface for the needed runtime type checks.
|
||||
abstract class RuntimeTypesChecks {
|
||||
|
@ -499,8 +498,7 @@ abstract class RuntimeTypesEncoder {
|
|||
/// Returns a [jsAst.Expression] representing the given [type]. Type variables
|
||||
/// are replaced by the [jsAst.Expression] returned by [onVariable].
|
||||
jsAst.Expression getTypeRepresentation(
|
||||
ModularEmitter emitter, DartType type, OnVariableCallback onVariable,
|
||||
[ShouldEncodeTypedefCallback shouldEncodeTypedef]);
|
||||
ModularEmitter emitter, DartType type, OnVariableCallback onVariable);
|
||||
|
||||
jsAst.Expression getJsInteropTypeArguments(int count);
|
||||
|
||||
|
@ -832,8 +830,8 @@ class RuntimeTypesEncoderImpl implements RuntimeTypesEncoder {
|
|||
|
||||
RuntimeTypesEncoderImpl(this.rtiTags, NativeBasicData nativeData,
|
||||
this._elementEnvironment, this.commonElements, this._rtiNeed)
|
||||
: _representationGenerator = new TypeRepresentationGenerator(
|
||||
commonElements.dartTypes, rtiTags, nativeData);
|
||||
: _representationGenerator =
|
||||
new TypeRepresentationGenerator(rtiTags, nativeData);
|
||||
|
||||
/// Returns the JavaScript template to determine at runtime if a type object
|
||||
/// is a function type.
|
||||
|
@ -870,10 +868,9 @@ class RuntimeTypesEncoderImpl implements RuntimeTypesEncoder {
|
|||
|
||||
@override
|
||||
jsAst.Expression getTypeRepresentation(
|
||||
ModularEmitter emitter, DartType type, OnVariableCallback onVariable,
|
||||
[ShouldEncodeTypedefCallback shouldEncodeTypedef]) {
|
||||
ModularEmitter emitter, DartType type, OnVariableCallback onVariable) {
|
||||
return _representationGenerator.getTypeRepresentation(
|
||||
emitter, type, onVariable, shouldEncodeTypedef);
|
||||
emitter, type, onVariable);
|
||||
}
|
||||
|
||||
String getTypeVariableName(TypeVariableType type) {
|
||||
|
@ -946,8 +943,6 @@ class RuntimeTypesEncoderImpl implements RuntimeTypesEncoder {
|
|||
class RuntimeTypeTags {
|
||||
const RuntimeTypeTags();
|
||||
|
||||
String get typedefTag => r'typedef';
|
||||
|
||||
String get functionTypeTag => r'func';
|
||||
|
||||
String get functionTypeVoidReturnTag => r'v';
|
||||
|
@ -969,31 +964,21 @@ class RuntimeTypeTags {
|
|||
|
||||
class TypeRepresentationGenerator
|
||||
implements DartTypeVisitor<jsAst.Expression, ModularEmitter> {
|
||||
final DartTypes _dartTypes;
|
||||
final RuntimeTypeTags _rtiTags;
|
||||
final NativeBasicData _nativeData;
|
||||
|
||||
OnVariableCallback onVariable;
|
||||
ShouldEncodeTypedefCallback shouldEncodeTypedef;
|
||||
Map<TypeVariableType, jsAst.Expression> typedefBindings;
|
||||
List<FunctionTypeVariable> functionTypeVariables = <FunctionTypeVariable>[];
|
||||
|
||||
TypeRepresentationGenerator(this._dartTypes, this._rtiTags, this._nativeData);
|
||||
TypeRepresentationGenerator(this._rtiTags, this._nativeData);
|
||||
|
||||
/// Creates a type representation for [type]. [onVariable] is called to
|
||||
/// provide the type representation for type variables.
|
||||
jsAst.Expression getTypeRepresentation(
|
||||
ModularEmitter emitter,
|
||||
DartType type,
|
||||
OnVariableCallback onVariable,
|
||||
ShouldEncodeTypedefCallback encodeTypedef) {
|
||||
assert(typedefBindings == null);
|
||||
ModularEmitter emitter, DartType type, OnVariableCallback onVariable) {
|
||||
this.onVariable = onVariable;
|
||||
this.shouldEncodeTypedef =
|
||||
(encodeTypedef != null) ? encodeTypedef : (TypedefType type) => false;
|
||||
jsAst.Expression representation = visit(type, emitter);
|
||||
this.onVariable = null;
|
||||
this.shouldEncodeTypedef = null;
|
||||
assert(functionTypeVariables.isEmpty);
|
||||
return representation;
|
||||
}
|
||||
|
@ -1016,10 +1001,6 @@ class TypeRepresentationGenerator
|
|||
@override
|
||||
jsAst.Expression visitTypeVariableType(
|
||||
TypeVariableType type, ModularEmitter emitter) {
|
||||
if (typedefBindings != null) {
|
||||
assert(typedefBindings[type] != null);
|
||||
return typedefBindings[type];
|
||||
}
|
||||
return onVariable(type);
|
||||
}
|
||||
|
||||
|
@ -1204,61 +1185,6 @@ class TypeRepresentationGenerator
|
|||
return getVoidValue();
|
||||
}
|
||||
|
||||
@override
|
||||
jsAst.Expression visitTypedefType(TypedefType type, ModularEmitter emitter) {
|
||||
bool shouldEncode = shouldEncodeTypedef(type);
|
||||
DartType unaliasedType = type.unaliased;
|
||||
|
||||
var oldBindings = typedefBindings;
|
||||
if (typedefBindings == null) {
|
||||
// First level typedef - capture arguments for re-use within typedef body.
|
||||
//
|
||||
// The type `Map<T, Foo<Set<T>>>` contains one type variable referenced
|
||||
// twice, so there are two inputs into the HTypeInfoExpression
|
||||
// instruction.
|
||||
//
|
||||
// If Foo is a typedef, T can be reused, e.g.
|
||||
//
|
||||
// typedef E Foo<E>(E a, E b);
|
||||
//
|
||||
// As the typedef is expanded (to (Set<T>, Set<T>) => Set<T>) it should
|
||||
// not consume additional types from the to-level input. We prevent this
|
||||
// by capturing the types and using the captured type expressions inside
|
||||
// the typedef expansion.
|
||||
//
|
||||
// TODO(sra): We should make the type subexpression Foo<...> be a second
|
||||
// HTypeInfoExpression, with Set<T> as its input (a third
|
||||
// HTypeInfoExpression). This would share all the Set<T> subexpressions
|
||||
// instead of duplicating them. This would require HTypeInfoExpression
|
||||
// inputs to correspond to type variables AND typedefs.
|
||||
typedefBindings = <TypeVariableType, jsAst.Expression>{};
|
||||
type.forEachTypeVariable((TypeVariableType variable) {
|
||||
typedefBindings[variable] = onVariable(variable);
|
||||
});
|
||||
}
|
||||
|
||||
jsAst.Expression finish(jsAst.Expression result) {
|
||||
typedefBindings = oldBindings;
|
||||
return result;
|
||||
}
|
||||
|
||||
if (shouldEncode) {
|
||||
jsAst.ObjectInitializer initializer = visit(unaliasedType, emitter);
|
||||
// We have to encode the aliased type.
|
||||
jsAst.Expression name = getJavaScriptClassName(type.element, emitter);
|
||||
jsAst.Expression encodedTypedef = _dartTypes.treatAsRawType(type)
|
||||
? name
|
||||
: visitList(type.typeArguments, emitter, head: name);
|
||||
|
||||
// Add it to the function-type object.
|
||||
jsAst.LiteralString tag = js.string(_rtiTags.typedefTag);
|
||||
initializer.properties.add(new jsAst.Property(tag, encodedTypedef));
|
||||
return finish(initializer);
|
||||
} else {
|
||||
return finish(visit(unaliasedType, emitter));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
jsAst.Expression visitFutureOrType(
|
||||
FutureOrType type, ModularEmitter emitter) {
|
||||
|
@ -1337,11 +1263,6 @@ class ArgumentCollector extends DartTypeVisitor<void, void> {
|
|||
collect(type.typeArgument);
|
||||
}
|
||||
|
||||
@override
|
||||
void visitTypedefType(TypedefType type, _) {
|
||||
collect(type.unaliased);
|
||||
}
|
||||
|
||||
@override
|
||||
void visitInterfaceType(InterfaceType type, _) {
|
||||
addClass(type.element);
|
||||
|
@ -1454,11 +1375,6 @@ class TypeVisitor extends DartTypeVisitor<void, TypeVisitorState> {
|
|||
_visitedFunctionTypeVariables.removeAll(type.typeVariables);
|
||||
}
|
||||
|
||||
@override
|
||||
visitTypedefType(TypedefType type, TypeVisitorState state) {
|
||||
visitType(type.unaliased, state);
|
||||
}
|
||||
|
||||
@override
|
||||
visitFunctionTypeVariable(FunctionTypeVariable type, TypeVisitorState state) {
|
||||
if (_visitedFunctionTypeVariables.add(type)) {
|
||||
|
|
|
@ -419,11 +419,6 @@ class _RecipeGenerator implements DartTypeVisitor<void, void> {
|
|||
_emitCode(Recipe.pushVoid);
|
||||
}
|
||||
|
||||
@override
|
||||
void visitTypedefType(TypedefType type, _) {
|
||||
visit(type.unaliased, _);
|
||||
}
|
||||
|
||||
@override
|
||||
void visitFutureOrType(FutureOrType type, _) {
|
||||
visit(type.typeArgument, _);
|
||||
|
|
|
@ -772,11 +772,6 @@ class _RecipeToIdentifier extends DartTypeVisitor<void, DartType> {
|
|||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
void visitTypedefType(covariant TypedefType type, _) {
|
||||
throw StateError('Typedefs should be elided $type');
|
||||
}
|
||||
|
||||
/// Returns `true` for types which print as a single identifier.
|
||||
static bool _isSimple(DartType type) {
|
||||
return type is DynamicType ||
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
library dart2js.js_emitter.constant_ordering;
|
||||
|
||||
import '../constants/values.dart';
|
||||
import '../elements/entities.dart'
|
||||
show ClassEntity, FieldEntity, MemberEntity, TypedefEntity;
|
||||
import '../elements/entities.dart' show ClassEntity, FieldEntity, MemberEntity;
|
||||
import '../elements/types.dart';
|
||||
import 'sorter.dart' show Sorter;
|
||||
|
||||
|
@ -58,12 +57,6 @@ class _ConstantOrdering
|
|||
return _sorter.compareMembersByLocation(a, b);
|
||||
}
|
||||
|
||||
int compareTypedefs(TypedefEntity a, TypedefEntity b) {
|
||||
int r = a.name.compareTo(b.name);
|
||||
if (r != 0) return r;
|
||||
return _sorter.compareTypedefsByLocation(a, b);
|
||||
}
|
||||
|
||||
int compareDartTypes(DartType a, DartType b) {
|
||||
return _dartTypeOrdering.compare(a, b);
|
||||
}
|
||||
|
@ -211,7 +204,7 @@ class _DartTypeKindVisitor implements DartTypeVisitor<int, Null> {
|
|||
@override
|
||||
int visitInterfaceType(InterfaceType type, _) => 1;
|
||||
@override
|
||||
int visitTypedefType(TypedefType type, _) => 2;
|
||||
int visitFunctionTypeVariable(FunctionTypeVariable type, _) => 2;
|
||||
@override
|
||||
int visitTypeVariableType(TypeVariableType type, _) => 3;
|
||||
@override
|
||||
|
@ -230,15 +223,13 @@ class _DartTypeKindVisitor implements DartTypeVisitor<int, Null> {
|
|||
int visitNullableType(NullableType type, _) => 10;
|
||||
@override
|
||||
int visitFutureOrType(FutureOrType type, _) => 11;
|
||||
@override
|
||||
int visitFunctionTypeVariable(FunctionTypeVariable type, _) =>
|
||||
throw new UnsupportedError(
|
||||
'FunctionTypeVariable unsupported in constant.');
|
||||
}
|
||||
|
||||
class _DartTypeOrdering extends DartTypeVisitor<int, DartType> {
|
||||
final _ConstantOrdering _constantOrdering;
|
||||
DartType _root;
|
||||
List<FunctionTypeVariable> _leftFunctionTypeVariables = [];
|
||||
List<FunctionTypeVariable> _rightFunctionTypeVariables = [];
|
||||
_DartTypeOrdering(this._constantOrdering);
|
||||
|
||||
int compare(DartType a, DartType b) {
|
||||
|
@ -283,21 +274,46 @@ class _DartTypeOrdering extends DartTypeVisitor<int, DartType> {
|
|||
"Type variables are not expected in constants: '$type' in '$_root'");
|
||||
}
|
||||
|
||||
@override
|
||||
int visitFunctionTypeVariable(covariant FunctionTypeVariable type,
|
||||
covariant FunctionTypeVariable other) {
|
||||
int leftIndex = _leftFunctionTypeVariables.indexOf(type);
|
||||
int rightIndex = _rightFunctionTypeVariables.indexOf(other);
|
||||
assert(leftIndex != -1);
|
||||
assert(rightIndex != -1);
|
||||
int r = leftIndex.compareTo(rightIndex);
|
||||
if (r != 0) return r;
|
||||
return compare(type.bound, other.bound);
|
||||
}
|
||||
|
||||
@override
|
||||
int visitFunctionType(
|
||||
covariant FunctionType type, covariant FunctionType other) {
|
||||
int leftLength = _leftFunctionTypeVariables.length;
|
||||
int rightLength = _rightFunctionTypeVariables.length;
|
||||
_leftFunctionTypeVariables.addAll(type.typeVariables);
|
||||
_rightFunctionTypeVariables.addAll(other.typeVariables);
|
||||
int r = _compareTypeArguments(type.parameterTypes, other.parameterTypes);
|
||||
if (r != 0) return r;
|
||||
r = _compareTypeArguments(
|
||||
type.optionalParameterTypes, other.optionalParameterTypes);
|
||||
if (r != 0) return r;
|
||||
r = _ConstantOrdering.compareLists((String a, String b) => a.compareTo(b),
|
||||
type.namedParameters, other.namedParameters);
|
||||
if (r != 0) return r;
|
||||
r = _compareTypeArguments(
|
||||
type.namedParameterTypes, other.namedParameterTypes);
|
||||
if (r != 0) return r;
|
||||
return compare(type.returnType, other.returnType);
|
||||
if (r == 0) {
|
||||
r = _compareTypeArguments(
|
||||
type.optionalParameterTypes, other.optionalParameterTypes);
|
||||
}
|
||||
if (r == 0) {
|
||||
r = _ConstantOrdering.compareLists((String a, String b) => a.compareTo(b),
|
||||
type.namedParameters, other.namedParameters);
|
||||
}
|
||||
if (r == 0) {
|
||||
r = _compareTypeArguments(
|
||||
type.namedParameterTypes, other.namedParameterTypes);
|
||||
}
|
||||
if (r == 0) {
|
||||
r = compare(type.returnType, other.returnType);
|
||||
}
|
||||
_leftFunctionTypeVariables.removeRange(
|
||||
leftLength, _leftFunctionTypeVariables.length);
|
||||
_rightFunctionTypeVariables.removeRange(
|
||||
rightLength, _rightFunctionTypeVariables.length);
|
||||
return r;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -308,14 +324,6 @@ class _DartTypeOrdering extends DartTypeVisitor<int, DartType> {
|
|||
return _compareTypeArguments(type.typeArguments, other.typeArguments);
|
||||
}
|
||||
|
||||
@override
|
||||
int visitTypedefType(
|
||||
covariant TypedefType type, covariant TypedefType other) {
|
||||
int r = _constantOrdering.compareTypedefs(type.element, other.element);
|
||||
if (r != 0) return r;
|
||||
return _compareTypeArguments(type.typeArguments, other.typeArguments);
|
||||
}
|
||||
|
||||
@override
|
||||
int visitDynamicType(
|
||||
covariant DynamicType type, covariant DynamicType other) {
|
||||
|
|
|
@ -181,8 +181,6 @@ class MetadataCollector implements jsAst.TokenFinalizer {
|
|||
"Type representation for type variable $variable in "
|
||||
"$type is not supported.");
|
||||
return jsAst.LiteralNull();
|
||||
}, (TypedefType typedef) {
|
||||
return false;
|
||||
});
|
||||
|
||||
if (representation is jsAst.LiteralString) {
|
||||
|
|
|
@ -351,11 +351,6 @@ class _TypeContainedInOutputUnitVisitor
|
|||
@override
|
||||
bool visitAnyType(AnyType type, OutputUnit argument) => true;
|
||||
|
||||
@override
|
||||
bool visitTypedefType(TypedefType type, OutputUnit argument) {
|
||||
return visit(type.unaliased, argument);
|
||||
}
|
||||
|
||||
@override
|
||||
bool visitInterfaceType(InterfaceType type, OutputUnit argument) {
|
||||
if (_outputUnitData.outputUnitForClass(type.element) != argument) {
|
||||
|
|
|
@ -14,14 +14,10 @@ abstract class Sorter {
|
|||
/// Returns a sorted list of [classes].
|
||||
Iterable<ClassEntity> sortClasses(Iterable<ClassEntity> classes);
|
||||
|
||||
/// Returns a sorted list of [typedefs].
|
||||
Iterable<TypedefEntity> sortTypedefs(Iterable<TypedefEntity> typedefs);
|
||||
|
||||
/// Returns a sorted list of [members].
|
||||
Iterable<T> sortMembers<T extends MemberEntity>(Iterable<T> members);
|
||||
|
||||
int compareLibrariesByLocation(LibraryEntity a, LibraryEntity b);
|
||||
int compareClassesByLocation(ClassEntity a, ClassEntity b);
|
||||
int compareTypedefsByLocation(TypedefEntity a, TypedefEntity b);
|
||||
int compareMembersByLocation(MemberEntity a, MemberEntity b);
|
||||
}
|
||||
|
|
|
@ -74,9 +74,6 @@ abstract class JsToElementMap {
|
|||
/// Returns the [ClassEntity] corresponding to the class [node].
|
||||
ClassEntity getClass(ir.Class node);
|
||||
|
||||
/// Returns the [TypedefType] corresponding to raw type of the typedef [node].
|
||||
TypedefType getTypedefType(ir.Typedef node);
|
||||
|
||||
/// Returns the super [MemberEntity] for a super invocation, get or set of
|
||||
/// [name] from the member [context].
|
||||
MemberEntity getSuperMember(MemberEntity context, ir.Name name,
|
||||
|
|
|
@ -65,12 +65,10 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap {
|
|||
/// [JsKernelToElementMap] object in a debugging data stream.
|
||||
static const String libraryTag = 'libraries';
|
||||
static const String classTag = 'classes';
|
||||
static const String typedefTag = 'typedefs';
|
||||
static const String memberTag = 'members';
|
||||
static const String typeVariableTag = 'type-variables';
|
||||
static const String libraryDataTag = 'library-data';
|
||||
static const String classDataTag = 'class-data';
|
||||
static const String typedefDataTag = 'typedef-data';
|
||||
static const String memberDataTag = 'member-data';
|
||||
static const String typeVariableDataTag = 'type-variable-data';
|
||||
static const String nestedClosuresTag = 'nested-closures';
|
||||
|
@ -100,12 +98,9 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap {
|
|||
new EntityDataMap<IndexedMember, JMemberData>();
|
||||
final EntityDataMap<IndexedTypeVariable, JTypeVariableData> typeVariables =
|
||||
new EntityDataMap<IndexedTypeVariable, JTypeVariableData>();
|
||||
final EntityDataMap<IndexedTypedef, JTypedefData> typedefs =
|
||||
new EntityDataMap<IndexedTypedef, JTypedefData>();
|
||||
|
||||
final Map<ir.Library, IndexedLibrary> libraryMap = {};
|
||||
final Map<ir.Class, IndexedClass> classMap = {};
|
||||
final Map<ir.Typedef, IndexedTypedef> typedefMap = {};
|
||||
|
||||
/// Map from [ir.TypeParameter] nodes to the corresponding
|
||||
/// [TypeVariableEntity].
|
||||
|
@ -179,25 +174,6 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap {
|
|||
assert(newClass.classIndex == oldClass.classIndex);
|
||||
libraries.getEnv(newClass.library).registerClass(newClass.name, newEnv);
|
||||
}
|
||||
for (int typedefIndex = 0;
|
||||
typedefIndex < _elementMap.typedefs.length;
|
||||
typedefIndex++) {
|
||||
IndexedTypedef oldTypedef = _elementMap.typedefs.getEntity(typedefIndex);
|
||||
KTypedefData data = _elementMap.typedefs.getData(oldTypedef);
|
||||
IndexedLibrary oldLibrary = oldTypedef.library;
|
||||
LibraryEntity newLibrary = libraries.getEntity(oldLibrary.libraryIndex);
|
||||
IndexedTypedef newTypedef = new JTypedef(newLibrary, oldTypedef.name);
|
||||
typedefMap[data.node] = typedefs.register(
|
||||
newTypedef,
|
||||
new JTypedefData(
|
||||
data.node,
|
||||
new TypedefType(
|
||||
newTypedef,
|
||||
new List<DartType>.filled(
|
||||
data.node.typeParameters.length, DynamicType()),
|
||||
getDartType(data.node.type))));
|
||||
assert(newTypedef.typedefIndex == oldTypedef.typedefIndex);
|
||||
}
|
||||
|
||||
for (int memberIndex = 0;
|
||||
memberIndex < _elementMap.members.length;
|
||||
|
@ -350,15 +326,6 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap {
|
|||
}
|
||||
source.end(classTag);
|
||||
|
||||
source.begin(typedefTag);
|
||||
int typedefCount = source.readInt();
|
||||
for (int i = 0; i < typedefCount; i++) {
|
||||
int index = source.readInt();
|
||||
JTypedef typedef = new JTypedef.readFromDataSource(source);
|
||||
entityLookup.registerTypedef(index, typedef);
|
||||
}
|
||||
source.end(typedefTag);
|
||||
|
||||
source.begin(memberTag);
|
||||
int memberCount = source.readInt();
|
||||
for (int i = 0; i < memberCount; i++) {
|
||||
|
@ -402,14 +369,6 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap {
|
|||
});
|
||||
source.end(classDataTag);
|
||||
|
||||
source.begin(typedefDataTag);
|
||||
entityLookup.forEachTypedef((int index, JTypedef typedef) {
|
||||
JTypedefData data = new JTypedefData.readFromDataSource(source);
|
||||
typedefMap[data.node] = typedefs.registerByIndex(index, typedef, data);
|
||||
assert(index == typedef.typedefIndex);
|
||||
});
|
||||
source.end(typedefDataTag);
|
||||
|
||||
source.begin(memberDataTag);
|
||||
entityLookup.forEachMember((int index, IndexedMember member) {
|
||||
JMemberData data = new JMemberData.readFromDataSource(source);
|
||||
|
@ -469,7 +428,6 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap {
|
|||
libraries.close();
|
||||
classes.close();
|
||||
members.close();
|
||||
typedefs.close();
|
||||
typeVariables.close();
|
||||
return length;
|
||||
}
|
||||
|
@ -495,14 +453,6 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap {
|
|||
});
|
||||
sink.end(classTag);
|
||||
|
||||
sink.begin(typedefTag);
|
||||
sink.writeInt(typedefs.size);
|
||||
typedefs.forEach((JTypedef typedef, _) {
|
||||
sink.writeInt(typedef.typedefIndex);
|
||||
typedef.writeToDataSink(sink);
|
||||
});
|
||||
sink.end(typedefTag);
|
||||
|
||||
sink.begin(memberTag);
|
||||
sink.writeInt(members.size);
|
||||
members.forEach((JMember member, _) {
|
||||
|
@ -534,12 +484,6 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap {
|
|||
});
|
||||
sink.end(classDataTag);
|
||||
|
||||
sink.begin(typedefDataTag);
|
||||
typedefs.forEach((_, JTypedefData data) {
|
||||
data.writeToDataSink(sink);
|
||||
});
|
||||
sink.end(typedefDataTag);
|
||||
|
||||
sink.begin(memberDataTag);
|
||||
members.forEach((_, JMemberData data) {
|
||||
data.writeToDataSink(sink);
|
||||
|
@ -822,12 +766,6 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap {
|
|||
}
|
||||
}
|
||||
|
||||
@override
|
||||
TypedefType getTypedefType(ir.Typedef node) {
|
||||
IndexedTypedef typedef = getTypedefInternal(node);
|
||||
return typedefs.getData(typedef).rawType;
|
||||
}
|
||||
|
||||
@override
|
||||
MemberEntity getMember(ir.Member node) {
|
||||
if (node is ir.Field) {
|
||||
|
@ -1677,12 +1615,6 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap {
|
|||
return typeVariable;
|
||||
}
|
||||
|
||||
TypedefEntity getTypedefInternal(ir.Typedef node) {
|
||||
TypedefEntity typedef = typedefMap[node];
|
||||
assert(typedef != null, "No typedef entity for $node");
|
||||
return typedef;
|
||||
}
|
||||
|
||||
@override
|
||||
FunctionEntity getConstructorBody(ir.Constructor node) {
|
||||
ConstructorEntity constructor = getConstructor(node);
|
||||
|
@ -2552,7 +2484,6 @@ class JsBehaviorBuilder extends BehaviorBuilder {
|
|||
class _EntityLookup implements EntityLookup {
|
||||
final Map<int, JLibrary> _libraries = {};
|
||||
final Map<int, JClass> _classes = {};
|
||||
final Map<int, JTypedef> _typedefs = {};
|
||||
final Map<int, JMember> _members = {};
|
||||
final Map<int, JTypeVariable> _typeVariables = {};
|
||||
|
||||
|
@ -2568,12 +2499,6 @@ class _EntityLookup implements EntityLookup {
|
|||
_classes[index] = cls;
|
||||
}
|
||||
|
||||
void registerTypedef(int index, JTypedef typedef) {
|
||||
assert(!_typedefs.containsKey(index),
|
||||
"Typedef for index $index has already been defined.");
|
||||
_typedefs[index] = typedef;
|
||||
}
|
||||
|
||||
void registerMember(int index, JMember member) {
|
||||
assert(!_members.containsKey(index),
|
||||
"Member for index $index has already been defined.");
|
||||
|
@ -2594,10 +2519,6 @@ class _EntityLookup implements EntityLookup {
|
|||
_classes.forEach(f);
|
||||
}
|
||||
|
||||
void forEachTypedef(void f(int index, JTypedef typedef)) {
|
||||
_typedefs.forEach(f);
|
||||
}
|
||||
|
||||
void forEachMember(void f(int index, JMember member)) {
|
||||
_members.forEach(f);
|
||||
}
|
||||
|
@ -2620,13 +2541,6 @@ class _EntityLookup implements EntityLookup {
|
|||
return cls;
|
||||
}
|
||||
|
||||
@override
|
||||
IndexedTypedef getTypedefByIndex(int index) {
|
||||
IndexedTypedef typedef = _typedefs[index];
|
||||
assert(typedef != null, "No typedef found for index $index");
|
||||
return typedef;
|
||||
}
|
||||
|
||||
@override
|
||||
IndexedMember getMemberByIndex(int index) {
|
||||
IndexedMember member = _members[index];
|
||||
|
@ -2658,11 +2572,6 @@ class ClosedEntityLookup implements EntityLookup {
|
|||
return _elementMap.members.getEntity(index);
|
||||
}
|
||||
|
||||
@override
|
||||
IndexedTypedef getTypedefByIndex(int index) {
|
||||
return _elementMap.typedefs.getEntity(index);
|
||||
}
|
||||
|
||||
@override
|
||||
IndexedClass getClassByIndex(int index) {
|
||||
return _elementMap.classes.getEntity(index);
|
||||
|
|
|
@ -102,40 +102,6 @@ class JClass extends IndexedClass with ClassHierarchyNodesMapKey {
|
|||
String toString() => '${jsElementPrefix}class($name)';
|
||||
}
|
||||
|
||||
class JTypedef extends IndexedTypedef {
|
||||
/// Tag used for identifying serialized [JTypedef] objects in a
|
||||
/// debugging data stream.
|
||||
static const String tag = 'typedef';
|
||||
|
||||
@override
|
||||
final JLibrary library;
|
||||
|
||||
@override
|
||||
final String name;
|
||||
|
||||
JTypedef(this.library, this.name);
|
||||
|
||||
/// Deserializes a [JTypedef] object from [source].
|
||||
factory JTypedef.readFromDataSource(DataSource source) {
|
||||
source.begin(tag);
|
||||
JLibrary library = source.readLibrary();
|
||||
String name = source.readString();
|
||||
source.end(tag);
|
||||
return new JTypedef(library, name);
|
||||
}
|
||||
|
||||
/// Serializes this [JTypedef] to [sink].
|
||||
void writeToDataSink(DataSink sink) {
|
||||
sink.begin(tag);
|
||||
sink.writeLibrary(library);
|
||||
sink.writeString(name);
|
||||
sink.end(tag);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => '${jsElementPrefix}typedef($name)';
|
||||
}
|
||||
|
||||
/// Enum used for identifying [JMember] subclasses in serialization.
|
||||
enum JMemberKind {
|
||||
generativeConstructor,
|
||||
|
@ -787,7 +753,7 @@ class JSignatureMethod extends JMethod {
|
|||
}
|
||||
|
||||
/// Enum used for identifying [JTypeVariable] variants in serialization.
|
||||
enum JTypeVariableKind { cls, member, typedef, local }
|
||||
enum JTypeVariableKind { cls, member, local }
|
||||
|
||||
class JTypeVariable extends IndexedTypeVariable {
|
||||
/// Tag used for identifying serialized [JTypeVariable] objects in a
|
||||
|
@ -815,9 +781,6 @@ class JTypeVariable extends IndexedTypeVariable {
|
|||
case JTypeVariableKind.member:
|
||||
typeDeclaration = source.readMember();
|
||||
break;
|
||||
case JTypeVariableKind.typedef:
|
||||
typeDeclaration = source.readTypedef();
|
||||
break;
|
||||
case JTypeVariableKind.local:
|
||||
// Type variables declared by local functions don't point to their
|
||||
// declaration, since the corresponding closure call methods is created
|
||||
|
@ -842,10 +805,6 @@ class JTypeVariable extends IndexedTypeVariable {
|
|||
IndexedMember member = typeDeclaration;
|
||||
sink.writeEnum(JTypeVariableKind.member);
|
||||
sink.writeMember(member);
|
||||
} else if (typeDeclaration is IndexedTypedef) {
|
||||
IndexedTypedef typedef = typeDeclaration;
|
||||
sink.writeEnum(JTypeVariableKind.typedef);
|
||||
sink.writeTypedef(typedef);
|
||||
} else if (typeDeclaration == null) {
|
||||
sink.writeEnum(JTypeVariableKind.local);
|
||||
} else {
|
||||
|
|
|
@ -1014,32 +1014,6 @@ class JFieldDataImpl extends JMemberDataImpl implements JFieldData {
|
|||
}
|
||||
}
|
||||
|
||||
class JTypedefData {
|
||||
/// Tag used for identifying serialized [JTypedefData] objects in
|
||||
/// a debugging data stream.
|
||||
static const String tag = 'typedef-data';
|
||||
|
||||
final ir.Typedef node;
|
||||
final TypedefType rawType;
|
||||
|
||||
JTypedefData(this.node, this.rawType);
|
||||
|
||||
factory JTypedefData.readFromDataSource(DataSource source) {
|
||||
source.begin(tag);
|
||||
ir.Typedef node = source.readTypedefNode();
|
||||
TypedefType rawType = source.readDartType();
|
||||
source.end(tag);
|
||||
return new JTypedefData(node, rawType);
|
||||
}
|
||||
|
||||
void writeToDataSink(DataSink sink) {
|
||||
sink.begin(tag);
|
||||
sink.writeTypedefNode(node);
|
||||
sink.writeDartType(rawType);
|
||||
sink.end(tag);
|
||||
}
|
||||
}
|
||||
|
||||
class JTypeVariableData {
|
||||
/// Tag used for identifying serialized [JTypeVariableData] objects in
|
||||
/// a debugging data stream.
|
||||
|
|
|
@ -643,13 +643,6 @@ class KernelSorter implements Sorter {
|
|||
return sorted;
|
||||
}
|
||||
|
||||
@override
|
||||
Iterable<TypedefEntity> sortTypedefs(Iterable<TypedefEntity> typedefs) {
|
||||
// TODO(redemption): Support this.
|
||||
assert(typedefs.isEmpty);
|
||||
return typedefs;
|
||||
}
|
||||
|
||||
@override
|
||||
int compareLibrariesByLocation(LibraryEntity a, LibraryEntity b) {
|
||||
return _compareLibraries(a, b);
|
||||
|
@ -665,13 +658,6 @@ class KernelSorter implements Sorter {
|
|||
a, definition1.location, b, definition2.location);
|
||||
}
|
||||
|
||||
@override
|
||||
int compareTypedefsByLocation(TypedefEntity a, TypedefEntity b) {
|
||||
// TODO(redemption): Support this.
|
||||
failedAt(a, 'KernelSorter.compareTypedefsByLocation unimplemented');
|
||||
return 0;
|
||||
}
|
||||
|
||||
@override
|
||||
int compareMembersByLocation(MemberEntity a, MemberEntity b) {
|
||||
int r = _compareLibraries(a.library, b.library);
|
||||
|
|
|
@ -683,7 +683,6 @@ class JsToFrontendMapImpl extends JsToFrontendMap {
|
|||
Entity toBackendEntity(Entity entity) {
|
||||
if (entity is ClassEntity) return toBackendClass(entity);
|
||||
if (entity is MemberEntity) return toBackendMember(entity);
|
||||
if (entity is TypedefEntity) return toBackendTypedef(entity);
|
||||
if (entity is TypeVariableEntity) {
|
||||
return toBackendTypeVariable(entity);
|
||||
}
|
||||
|
@ -706,10 +705,6 @@ class JsToFrontendMapImpl extends JsToFrontendMap {
|
|||
return _backend.members.getEntity(member.memberIndex);
|
||||
}
|
||||
|
||||
TypedefEntity toBackendTypedef(covariant IndexedTypedef typedef) {
|
||||
return _backend.typedefs.getEntity(typedef.typedefIndex);
|
||||
}
|
||||
|
||||
TypeVariableEntity toBackendTypeVariable(TypeVariableEntity typeVariable) {
|
||||
if (typeVariable is KLocalTypeVariable) {
|
||||
failedAt(
|
||||
|
@ -791,14 +786,6 @@ class _TypeConverter implements DartTypeVisitor<DartType, _EntityConverter> {
|
|||
converter(type.element), visitList(type.typeArguments, converter));
|
||||
}
|
||||
|
||||
@override
|
||||
DartType visitTypedefType(TypedefType type, _EntityConverter converter) {
|
||||
return new TypedefType(
|
||||
converter(type.element),
|
||||
visitList(type.typeArguments, converter),
|
||||
visit(type.unaliased, converter));
|
||||
}
|
||||
|
||||
@override
|
||||
DartType visitTypeVariableType(
|
||||
TypeVariableType type, _EntityConverter converter) {
|
||||
|
|
|
@ -47,13 +47,6 @@ class KernelDeferredLoadTask extends DeferredLoadTask {
|
|||
return _findImportsTo(node, node.name, node.enclosingLibrary, library);
|
||||
}
|
||||
|
||||
@override
|
||||
Iterable<ImportEntity> typedefImportsTo(
|
||||
TypedefEntity element, LibraryEntity library) {
|
||||
ir.Typedef node = _elementMap.getTypedefNode(element);
|
||||
return _findImportsTo(node, node.name, node.enclosingLibrary, library);
|
||||
}
|
||||
|
||||
@override
|
||||
Iterable<ImportEntity> memberImportsTo(
|
||||
Entity element, LibraryEntity library) {
|
||||
|
|
|
@ -81,9 +81,6 @@ abstract class KernelToElementMap {
|
|||
/// Returns the [ClassEntity] corresponding to the class [node].
|
||||
ClassEntity getClass(ir.Class node);
|
||||
|
||||
/// Returns the [TypedefType] corresponding to raw type of the typedef [node].
|
||||
TypedefType getTypedefType(ir.Typedef node);
|
||||
|
||||
/// Returns the super [MemberEntity] for a super invocation, get or set of
|
||||
/// [name] from the member [context].
|
||||
MemberEntity getSuperMember(MemberEntity context, ir.Name name,
|
||||
|
@ -174,9 +171,6 @@ abstract class KernelToElementMap {
|
|||
/// Returns the [ir.Library] corresponding to [library].
|
||||
ir.Library getLibraryNode(LibraryEntity library);
|
||||
|
||||
/// Returns the node that defines [typedef].
|
||||
ir.Typedef getTypedefNode(covariant TypedefEntity typedef);
|
||||
|
||||
/// Returns the defining node for [member].
|
||||
ir.Member getMemberNode(covariant MemberEntity member);
|
||||
|
||||
|
|
|
@ -87,8 +87,6 @@ class KernelToElementMapImpl implements KernelToElementMap, IrToElementMap {
|
|||
new EntityDataMap<IndexedMember, KMemberData>();
|
||||
final EntityDataMap<IndexedTypeVariable, KTypeVariableData> typeVariables =
|
||||
new EntityDataMap<IndexedTypeVariable, KTypeVariableData>();
|
||||
final EntityDataMap<IndexedTypedef, KTypedefData> typedefs =
|
||||
new EntityDataMap<IndexedTypedef, KTypedefData>();
|
||||
|
||||
/// Set to `true` before creating the J-World from the K-World to assert that
|
||||
/// no entities are created late.
|
||||
|
@ -96,7 +94,6 @@ class KernelToElementMapImpl implements KernelToElementMap, IrToElementMap {
|
|||
|
||||
final Map<ir.Library, IndexedLibrary> libraryMap = {};
|
||||
final Map<ir.Class, IndexedClass> classMap = {};
|
||||
final Map<ir.Typedef, IndexedTypedef> typedefMap = {};
|
||||
|
||||
/// Map from [ir.TypeParameter] nodes to the corresponding
|
||||
/// [TypeVariableEntity].
|
||||
|
@ -389,12 +386,6 @@ class KernelToElementMapImpl implements KernelToElementMap, IrToElementMap {
|
|||
}
|
||||
}
|
||||
|
||||
@override
|
||||
TypedefType getTypedefType(ir.Typedef node) {
|
||||
IndexedTypedef typedef = getTypedefInternal(node);
|
||||
return typedefs.getData(typedef).rawType;
|
||||
}
|
||||
|
||||
@override
|
||||
MemberEntity getMember(ir.Member node) {
|
||||
if (node is ir.Field) {
|
||||
|
@ -760,10 +751,6 @@ class KernelToElementMapImpl implements KernelToElementMap, IrToElementMap {
|
|||
return classes.getData(cls).node;
|
||||
}
|
||||
|
||||
ir.Typedef _getTypedefNode(covariant IndexedTypedef typedef) {
|
||||
return typedefs.getData(typedef).node;
|
||||
}
|
||||
|
||||
@override
|
||||
ImportEntity getImport(ir.LibraryDependency node) {
|
||||
if (node == null) return null;
|
||||
|
@ -1172,25 +1159,6 @@ class KernelToElementMapImpl implements KernelToElementMap, IrToElementMap {
|
|||
return classes.register(cls, new KClassDataImpl(node), classEnv);
|
||||
}
|
||||
|
||||
TypedefEntity getTypedefInternal(ir.Typedef node) {
|
||||
return typedefMap[node] ??= _getTypedefCreate(node);
|
||||
}
|
||||
|
||||
TypedefEntity _getTypedefCreate(ir.Typedef node) {
|
||||
assert(
|
||||
!envIsClosed,
|
||||
"Environment of $this is closed. Trying to create "
|
||||
"typedef for $node.");
|
||||
IndexedLibrary library = getLibraryInternal(node.enclosingLibrary);
|
||||
IndexedTypedef typedef = createTypedef(library, node.name);
|
||||
TypedefType typedefType = new TypedefType(
|
||||
typedef,
|
||||
new List<DartType>.filled(node.typeParameters.length, DynamicType()),
|
||||
getDartType(node.type));
|
||||
return typedefs.register(
|
||||
typedef, new KTypedefData(node, typedef, typedefType));
|
||||
}
|
||||
|
||||
TypeVariableEntity getTypeVariableInternal(ir.TypeParameter node) {
|
||||
return typeVariableMap[node] ??= _getTypeVariableCreate(node);
|
||||
}
|
||||
|
@ -1504,11 +1472,6 @@ class KernelToElementMapImpl implements KernelToElementMap, IrToElementMap {
|
|||
return data.callType is FunctionType;
|
||||
}
|
||||
|
||||
@override
|
||||
ir.Typedef getTypedefNode(TypedefEntity typedef) {
|
||||
return _getTypedefNode(typedef);
|
||||
}
|
||||
|
||||
@override
|
||||
ForeignKind getForeignKind(ir.StaticInvocation node) {
|
||||
if (commonElements.isForeignHelper(getMember(node.target))) {
|
||||
|
@ -1585,10 +1548,6 @@ class KernelToElementMapImpl implements KernelToElementMap, IrToElementMap {
|
|||
return new KClass(library, name, isAbstract: isAbstract);
|
||||
}
|
||||
|
||||
IndexedTypedef createTypedef(LibraryEntity library, String name) {
|
||||
return new KTypedef(library, name);
|
||||
}
|
||||
|
||||
TypeVariableEntity createTypeVariable(
|
||||
Entity typeDeclaration, String name, int index) {
|
||||
return new KTypeVariable(typeDeclaration, name, index);
|
||||
|
|
|
@ -881,14 +881,6 @@ class KFieldDataImpl extends KMemberDataImpl implements KFieldData {
|
|||
}
|
||||
}
|
||||
|
||||
class KTypedefData {
|
||||
final ir.Typedef node;
|
||||
final TypedefEntity element;
|
||||
final TypedefType rawType;
|
||||
|
||||
KTypedefData(this.node, this.element, this.rawType);
|
||||
}
|
||||
|
||||
class KTypeVariableData {
|
||||
final ir.TypeParameter node;
|
||||
DartType _bound;
|
||||
|
|
|
@ -42,19 +42,6 @@ class KClass extends IndexedClass {
|
|||
String toString() => '${kElementPrefix}class($name)';
|
||||
}
|
||||
|
||||
class KTypedef extends IndexedTypedef {
|
||||
@override
|
||||
final KLibrary library;
|
||||
|
||||
@override
|
||||
final String name;
|
||||
|
||||
KTypedef(this.library, this.name);
|
||||
|
||||
@override
|
||||
String toString() => '${kElementPrefix}typedef($name)';
|
||||
}
|
||||
|
||||
abstract class KMember extends IndexedMember {
|
||||
@override
|
||||
final KLibrary library;
|
||||
|
|
|
@ -790,12 +790,6 @@ abstract class KernelImpactRegistryMixin implements ImpactRegistry {
|
|||
ImportEntity deferredImport = elementMap.getImport(import);
|
||||
impactBuilder.registerTypeUse(
|
||||
new TypeUse.typeLiteral(elementMap.getDartType(type), deferredImport));
|
||||
if (type is ir.FunctionType) {
|
||||
assert(type.typedef != null);
|
||||
// TODO(johnniwinther): Can we avoid the typedef type altogether?
|
||||
// We need to ensure that the typedef is live.
|
||||
elementMap.getTypedefType(type.typedef);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -400,11 +400,6 @@ abstract class AbstractDataSink extends DataSinkMixin implements DataSink {
|
|||
_entityWriter.writeClassToDataSink(this, value);
|
||||
}
|
||||
|
||||
@override
|
||||
void writeTypedef(IndexedTypedef value) {
|
||||
_entityWriter.writeTypedefToDataSink(this, value);
|
||||
}
|
||||
|
||||
@override
|
||||
void writeMember(IndexedMember value) {
|
||||
_entityWriter.writeMemberToDataSink(this, value);
|
||||
|
|
|
@ -130,11 +130,6 @@ abstract class AbstractDataSource extends DataSourceMixin
|
|||
return _entityReader.readClassFromDataSource(this, entityLookup);
|
||||
}
|
||||
|
||||
@override
|
||||
IndexedTypedef readTypedef() {
|
||||
return _entityReader.readTypedefFromDataSource(this, entityLookup);
|
||||
}
|
||||
|
||||
@override
|
||||
IndexedMember readMember() {
|
||||
return _entityReader.readMemberFromDataSource(this, entityLookup);
|
||||
|
@ -235,11 +230,6 @@ abstract class AbstractDataSource extends DataSourceMixin
|
|||
IndexedClass cls = readClass();
|
||||
List<DartType> typeArguments = _readDartTypes(functionTypeVariables);
|
||||
return new InterfaceType(cls, typeArguments);
|
||||
case DartTypeKind.typedef:
|
||||
IndexedTypedef typedef = readTypedef();
|
||||
List<DartType> typeArguments = _readDartTypes(functionTypeVariables);
|
||||
DartType unaliased = _readDartType(functionTypeVariables);
|
||||
return new TypedefType(typedef, typeArguments, unaliased);
|
||||
case DartTypeKind.dynamicType:
|
||||
return DynamicType();
|
||||
case DartTypeKind.erasedType:
|
||||
|
|
|
@ -97,7 +97,6 @@ enum DartTypeKind {
|
|||
functionTypeVariable,
|
||||
functionType,
|
||||
interfaceType,
|
||||
typedef,
|
||||
dynamicType,
|
||||
erasedType,
|
||||
anyType,
|
||||
|
@ -199,15 +198,6 @@ class DartTypeWriter
|
|||
visitTypes(type.typeArguments, functionTypeVariables);
|
||||
}
|
||||
|
||||
@override
|
||||
void visitTypedefType(covariant TypedefType type,
|
||||
List<FunctionTypeVariable> functionTypeVariables) {
|
||||
_sink.writeEnum(DartTypeKind.typedef);
|
||||
_sink.writeTypedef(type.element);
|
||||
visitTypes(type.typeArguments, functionTypeVariables);
|
||||
_sink._writeDartType(type.unaliased, functionTypeVariables);
|
||||
}
|
||||
|
||||
@override
|
||||
void visitDynamicType(covariant DynamicType type,
|
||||
List<FunctionTypeVariable> functionTypeVariables) {
|
||||
|
|
|
@ -301,9 +301,6 @@ abstract class DataSink {
|
|||
void writeClassMap<V>(Map<ClassEntity, V> map, void f(V value),
|
||||
{bool allowNull: false});
|
||||
|
||||
/// Writes a reference to the indexed typedef [value] to this data sink.
|
||||
void writeTypedef(IndexedTypedef value);
|
||||
|
||||
/// Writes a reference to the indexed member [value] to this data sink.
|
||||
void writeMember(IndexedMember value);
|
||||
|
||||
|
@ -721,9 +718,6 @@ abstract class DataSource {
|
|||
Map<K, V> readClassMap<K extends ClassEntity, V>(V f(),
|
||||
{bool emptyAsNull: false});
|
||||
|
||||
/// Reads a reference to an indexed typedef from this data source.
|
||||
IndexedTypedef readTypedef();
|
||||
|
||||
/// Reads a reference to an indexed member from this data source.
|
||||
IndexedMember readMember();
|
||||
|
||||
|
@ -857,9 +851,6 @@ abstract class EntityLookup {
|
|||
/// Returns the indexed class corresponding to [index].
|
||||
IndexedClass getClassByIndex(int index);
|
||||
|
||||
/// Returns the indexed typedef corresponding to [index].
|
||||
IndexedTypedef getTypedefByIndex(int index);
|
||||
|
||||
/// Returns the indexed member corresponding to [index].
|
||||
IndexedMember getMemberByIndex(int index);
|
||||
|
||||
|
@ -881,11 +872,6 @@ class EntityReader {
|
|||
return entityLookup.getClassByIndex(source.readInt());
|
||||
}
|
||||
|
||||
IndexedTypedef readTypedefFromDataSource(
|
||||
DataSource source, EntityLookup entityLookup) {
|
||||
return entityLookup.getTypedefByIndex(source.readInt());
|
||||
}
|
||||
|
||||
IndexedMember readMemberFromDataSource(
|
||||
DataSource source, EntityLookup entityLookup) {
|
||||
return entityLookup.getMemberByIndex(source.readInt());
|
||||
|
@ -909,10 +895,6 @@ class EntityWriter {
|
|||
sink.writeInt(value.classIndex);
|
||||
}
|
||||
|
||||
void writeTypedefToDataSink(DataSink sink, IndexedTypedef value) {
|
||||
sink.writeInt(value.typedefIndex);
|
||||
}
|
||||
|
||||
void writeMemberToDataSink(DataSink sink, IndexedMember value) {
|
||||
sink.writeInt(value.memberIndex);
|
||||
}
|
||||
|
|
|
@ -3216,7 +3216,6 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
|
|||
void visitTypeConversion(HTypeConversion node) {
|
||||
assert(node.isTypeCheck || node.isCastCheck);
|
||||
DartType type = node.typeExpression;
|
||||
assert(type is! TypedefType);
|
||||
assert(type is! DynamicType);
|
||||
assert(type is! VoidType);
|
||||
if (type is FunctionType) {
|
||||
|
|
|
@ -3687,7 +3687,6 @@ class HTypeConversion extends HCheck {
|
|||
HInstruction input, SourceInformation sourceInformation)
|
||||
: checkedType = type,
|
||||
super(<HInstruction>[input], type) {
|
||||
assert(typeExpression == null || typeExpression is! TypedefType);
|
||||
this.sourceElement = input.sourceElement;
|
||||
this.sourceInformation = sourceInformation;
|
||||
}
|
||||
|
@ -3696,7 +3695,6 @@ class HTypeConversion extends HCheck {
|
|||
AbstractValue type, HInstruction input, HInstruction typeRepresentation)
|
||||
: checkedType = type,
|
||||
super(<HInstruction>[input, typeRepresentation], type) {
|
||||
assert(typeExpression is! TypedefType);
|
||||
sourceElement = input.sourceElement;
|
||||
}
|
||||
|
||||
|
|
|
@ -1167,8 +1167,6 @@ class SsaInstructionSimplifier extends HBaseVisitor
|
|||
|
||||
if (!node.isRawCheck) {
|
||||
return node;
|
||||
} else if (type is TypedefType) {
|
||||
return node;
|
||||
} else if (type is FunctionType) {
|
||||
return node;
|
||||
} else if (type is FutureOrType) {
|
||||
|
@ -3266,8 +3264,6 @@ class SsaTypeConversionInserter extends HBaseVisitor
|
|||
DartType type = instruction.typeExpression;
|
||||
if (!instruction.isRawCheck) {
|
||||
return;
|
||||
} else if (type is TypedefType) {
|
||||
return;
|
||||
} else if (type is FutureOrType) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -281,9 +281,6 @@ enum JsGetName {
|
|||
/// instances of parameterized classes.
|
||||
RTI_NAME,
|
||||
|
||||
/// Name used to tag typedefs.
|
||||
TYPEDEF_TAG,
|
||||
|
||||
/// Name used to tag a function type.
|
||||
FUNCTION_TYPE_TAG,
|
||||
|
||||
|
|
|
@ -281,9 +281,6 @@ enum JsGetName {
|
|||
/// instances of parameterized classes.
|
||||
RTI_NAME,
|
||||
|
||||
/// Name used to tag typedefs.
|
||||
TYPEDEF_TAG,
|
||||
|
||||
/// Name used to tag a function type.
|
||||
FUNCTION_TYPE_TAG,
|
||||
|
||||
|
|
|
@ -4,12 +4,7 @@
|
|||
|
||||
import 'lib1.dart' deferred as lib1;
|
||||
|
||||
/*member: main:
|
||||
OutputUnit(main, {}),
|
||||
constants=[
|
||||
ConstructedConstant(C(a=TypeConstant(MyF1),b=FunctionConstant(topLevelMethod)))=OutputUnit(1, {lib1}),
|
||||
TypeConstant(MyF1)=OutputUnit(1, {lib1})]
|
||||
*/
|
||||
/*member: main:OutputUnit(main, {}),constants=[ConstructedConstant(C(a=TypeConstant(void Function()),b=FunctionConstant(topLevelMethod)))=OutputUnit(1, {lib1}),TypeConstant(void Function())=OutputUnit(1, {lib1})]*/
|
||||
main() async {
|
||||
await lib1.loadLibrary();
|
||||
print(lib1.cA);
|
||||
|
|
|
@ -32,7 +32,9 @@ main(List<String> args) {
|
|||
asyncTest(() async {
|
||||
Directory dataDir = new Directory.fromUri(Platform.script.resolve('data'));
|
||||
await checkTests(dataDir, const OutputUnitDataComputer(),
|
||||
options: compilerOptions, args: args, setUpFunction: () {
|
||||
options: compilerOptions,
|
||||
args: args,
|
||||
supportedMarkers: [strongMarker], setUpFunction: () {
|
||||
importPrefixes.clear();
|
||||
}, testedConfigs: allStrongConfigs);
|
||||
});
|
||||
|
|
|
@ -472,16 +472,6 @@ class DartTypePrinter implements DartTypeVisitor {
|
|||
sb.write('any');
|
||||
}
|
||||
|
||||
@override
|
||||
visitTypedefType(TypedefType type, _) {
|
||||
sb.write(type.element.name);
|
||||
if (type.typeArguments.any((type) => type is! DynamicType)) {
|
||||
sb.write('<');
|
||||
visitTypes(type.typeArguments);
|
||||
sb.write('>');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
visitInterfaceType(InterfaceType type, _) {
|
||||
sb.write(type.element.name);
|
||||
|
|
|
@ -93,16 +93,6 @@ class DartTypeToTextVisitor extends DartTypeVisitor<void, StringBuffer> {
|
|||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void visitTypedefType(TypedefType type, StringBuffer sb) {
|
||||
sb.write(type.element.name);
|
||||
if (type.typeArguments.isNotEmpty) {
|
||||
sb.write('<');
|
||||
visitList(type.typeArguments, sb);
|
||||
sb.write('>');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void visitDynamicType(DynamicType type, StringBuffer sb) {
|
||||
sb.write('dynamic');
|
||||
|
|
|
@ -70,9 +70,7 @@ main() {
|
|||
RuntimeTypeTags rtiTags = const RuntimeTypeTags();
|
||||
TypeRepresentationGenerator typeRepresentation =
|
||||
new TypeRepresentationGenerator(
|
||||
compiler.frontendStrategy.commonElements.dartTypes,
|
||||
rtiTags,
|
||||
compiler.backendClosedWorldForTesting.nativeData);
|
||||
rtiTags, compiler.backendClosedWorldForTesting.nativeData);
|
||||
|
||||
Expression onVariable(TypeVariableType _variable) {
|
||||
TypeVariableType variable = _variable;
|
||||
|
@ -86,20 +84,12 @@ main() {
|
|||
|
||||
void expect(DartType type, String expectedRepresentation,
|
||||
[String expectedTypedefRepresentation]) {
|
||||
bool encodeTypedefName = false;
|
||||
Expression expression = typeRepresentation.getTypeRepresentation(
|
||||
backendStrategy.emitterTask.emitter,
|
||||
type,
|
||||
onVariable,
|
||||
(x) => encodeTypedefName);
|
||||
backendStrategy.emitterTask.emitter, type, onVariable);
|
||||
Expect.stringEquals(expectedRepresentation, stringify(expression));
|
||||
|
||||
encodeTypedefName = true;
|
||||
expression = typeRepresentation.getTypeRepresentation(
|
||||
backendStrategy.emitterTask.emitter,
|
||||
type,
|
||||
onVariable,
|
||||
(x) => encodeTypedefName);
|
||||
backendStrategy.emitterTask.emitter, type, onVariable);
|
||||
if (expectedTypedefRepresentation == null) {
|
||||
expectedTypedefRepresentation = expectedRepresentation;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue