Rename UnlinkedTypeRef to TypeRef.
This data structure is going to be re-used in the "linked" section of summaries to refer to propagated and inferred types. R=scheglov@google.com Review URL: https://codereview.chromium.org/1610003002 .
This commit is contained in:
@@ -1067,6 +1067,185 @@ abstract class _SdkBundleMixin implements SdkBundle {
|
||||
};
|
||||
}
|
||||
|
||||
class TypeRefBuilder extends Object with _TypeRefMixin implements TypeRef {
|
||||
bool _finished = false;
|
||||
|
||||
int _reference;
|
||||
int _paramReference;
|
||||
List<TypeRefBuilder> _typeArguments;
|
||||
|
||||
@override
|
||||
int get reference => _reference ?? 0;
|
||||
|
||||
/**
|
||||
* Index into [UnlinkedUnit.references] for the type being referred to, or
|
||||
* zero if this is a reference to a type parameter.
|
||||
*
|
||||
* Note that since zero is also a valid index into
|
||||
* [UnlinkedUnit.references], we cannot distinguish between references to
|
||||
* type parameters and references to types by checking [reference] against
|
||||
* zero. To distinguish between references to type parameters and references
|
||||
* to types, check whether [paramReference] is zero.
|
||||
*/
|
||||
void set reference(int _value) {
|
||||
assert(!_finished);
|
||||
_reference = _value;
|
||||
}
|
||||
|
||||
@override
|
||||
int get paramReference => _paramReference ?? 0;
|
||||
|
||||
/**
|
||||
* If this is a reference to a type parameter, one-based index into the list
|
||||
* of [UnlinkedTypeParam]s currently in effect. Indexing is done using De
|
||||
* Bruijn index conventions; that is, innermost parameters come first, and
|
||||
* if a class or method has multiple parameters, they are indexed from right
|
||||
* to left. So for instance, if the enclosing declaration is
|
||||
*
|
||||
* class C<T,U> {
|
||||
* m<V,W> {
|
||||
* ...
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* Then [paramReference] values of 1, 2, 3, and 4 represent W, V, U, and T,
|
||||
* respectively.
|
||||
*
|
||||
* If the type being referred to is not a type parameter, [paramReference] is
|
||||
* zero.
|
||||
*/
|
||||
void set paramReference(int _value) {
|
||||
assert(!_finished);
|
||||
_paramReference = _value;
|
||||
}
|
||||
|
||||
@override
|
||||
List<TypeRef> get typeArguments => _typeArguments ?? const <TypeRef>[];
|
||||
|
||||
/**
|
||||
* If this is an instantiation of a generic type, the type arguments used to
|
||||
* instantiate it. Trailing type arguments of type `dynamic` are omitted.
|
||||
*/
|
||||
void set typeArguments(List<TypeRefBuilder> _value) {
|
||||
assert(!_finished);
|
||||
_typeArguments = _value;
|
||||
}
|
||||
|
||||
TypeRefBuilder({int reference, int paramReference, List<TypeRefBuilder> typeArguments})
|
||||
: _reference = reference,
|
||||
_paramReference = paramReference,
|
||||
_typeArguments = typeArguments;
|
||||
|
||||
fb.Offset finish(fb.Builder fbBuilder) {
|
||||
assert(!_finished);
|
||||
_finished = true;
|
||||
fb.Offset offset_typeArguments;
|
||||
if (!(_typeArguments == null || _typeArguments.isEmpty)) {
|
||||
offset_typeArguments = fbBuilder.writeList(_typeArguments.map((b) => b.finish(fbBuilder)).toList());
|
||||
}
|
||||
fbBuilder.startTable();
|
||||
if (_reference != null && _reference != 0) {
|
||||
fbBuilder.addInt32(0, _reference);
|
||||
}
|
||||
if (_paramReference != null && _paramReference != 0) {
|
||||
fbBuilder.addInt32(1, _paramReference);
|
||||
}
|
||||
if (offset_typeArguments != null) {
|
||||
fbBuilder.addOffset(2, offset_typeArguments);
|
||||
}
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary information about a reference to a type.
|
||||
*/
|
||||
abstract class TypeRef extends base.SummaryClass {
|
||||
|
||||
/**
|
||||
* Index into [UnlinkedUnit.references] for the type being referred to, or
|
||||
* zero if this is a reference to a type parameter.
|
||||
*
|
||||
* Note that since zero is also a valid index into
|
||||
* [UnlinkedUnit.references], we cannot distinguish between references to
|
||||
* type parameters and references to types by checking [reference] against
|
||||
* zero. To distinguish between references to type parameters and references
|
||||
* to types, check whether [paramReference] is zero.
|
||||
*/
|
||||
int get reference;
|
||||
|
||||
/**
|
||||
* If this is a reference to a type parameter, one-based index into the list
|
||||
* of [UnlinkedTypeParam]s currently in effect. Indexing is done using De
|
||||
* Bruijn index conventions; that is, innermost parameters come first, and
|
||||
* if a class or method has multiple parameters, they are indexed from right
|
||||
* to left. So for instance, if the enclosing declaration is
|
||||
*
|
||||
* class C<T,U> {
|
||||
* m<V,W> {
|
||||
* ...
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* Then [paramReference] values of 1, 2, 3, and 4 represent W, V, U, and T,
|
||||
* respectively.
|
||||
*
|
||||
* If the type being referred to is not a type parameter, [paramReference] is
|
||||
* zero.
|
||||
*/
|
||||
int get paramReference;
|
||||
|
||||
/**
|
||||
* If this is an instantiation of a generic type, the type arguments used to
|
||||
* instantiate it. Trailing type arguments of type `dynamic` are omitted.
|
||||
*/
|
||||
List<TypeRef> get typeArguments;
|
||||
}
|
||||
|
||||
class _TypeRefReader extends fb.TableReader<_TypeRefImpl> {
|
||||
const _TypeRefReader();
|
||||
|
||||
@override
|
||||
_TypeRefImpl createObject(fb.BufferPointer bp) => new _TypeRefImpl(bp);
|
||||
}
|
||||
|
||||
class _TypeRefImpl extends Object with _TypeRefMixin implements TypeRef {
|
||||
final fb.BufferPointer _bp;
|
||||
|
||||
_TypeRefImpl(this._bp);
|
||||
|
||||
int _reference;
|
||||
int _paramReference;
|
||||
List<TypeRef> _typeArguments;
|
||||
|
||||
@override
|
||||
int get reference {
|
||||
_reference ??= const fb.Int32Reader().vTableGet(_bp, 0, 0);
|
||||
return _reference;
|
||||
}
|
||||
|
||||
@override
|
||||
int get paramReference {
|
||||
_paramReference ??= const fb.Int32Reader().vTableGet(_bp, 1, 0);
|
||||
return _paramReference;
|
||||
}
|
||||
|
||||
@override
|
||||
List<TypeRef> get typeArguments {
|
||||
_typeArguments ??= const fb.ListReader<TypeRef>(const _TypeRefReader()).vTableGet(_bp, 2, const <TypeRef>[]);
|
||||
return _typeArguments;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _TypeRefMixin implements TypeRef {
|
||||
@override
|
||||
Map<String, Object> toMap() => {
|
||||
"reference": reference,
|
||||
"paramReference": paramReference,
|
||||
"typeArguments": typeArguments,
|
||||
};
|
||||
}
|
||||
|
||||
class UnlinkedClassBuilder extends Object with _UnlinkedClassMixin implements UnlinkedClass {
|
||||
bool _finished = false;
|
||||
|
||||
@@ -1074,9 +1253,9 @@ class UnlinkedClassBuilder extends Object with _UnlinkedClassMixin implements Un
|
||||
int _nameOffset;
|
||||
UnlinkedDocumentationCommentBuilder _documentationComment;
|
||||
List<UnlinkedTypeParamBuilder> _typeParameters;
|
||||
UnlinkedTypeRefBuilder _supertype;
|
||||
List<UnlinkedTypeRefBuilder> _mixins;
|
||||
List<UnlinkedTypeRefBuilder> _interfaces;
|
||||
TypeRefBuilder _supertype;
|
||||
List<TypeRefBuilder> _mixins;
|
||||
List<TypeRefBuilder> _interfaces;
|
||||
List<UnlinkedVariableBuilder> _fields;
|
||||
List<UnlinkedExecutableBuilder> _executables;
|
||||
bool _isAbstract;
|
||||
@@ -1129,36 +1308,36 @@ class UnlinkedClassBuilder extends Object with _UnlinkedClassMixin implements Un
|
||||
}
|
||||
|
||||
@override
|
||||
UnlinkedTypeRef get supertype => _supertype;
|
||||
TypeRef get supertype => _supertype;
|
||||
|
||||
/**
|
||||
* Supertype of the class, or `null` if either (a) the class doesn't
|
||||
* explicitly declare a supertype (and hence has supertype `Object`), or (b)
|
||||
* the class *is* `Object` (and hence has no supertype).
|
||||
*/
|
||||
void set supertype(UnlinkedTypeRefBuilder _value) {
|
||||
void set supertype(TypeRefBuilder _value) {
|
||||
assert(!_finished);
|
||||
_supertype = _value;
|
||||
}
|
||||
|
||||
@override
|
||||
List<UnlinkedTypeRef> get mixins => _mixins ?? const <UnlinkedTypeRef>[];
|
||||
List<TypeRef> get mixins => _mixins ?? const <TypeRef>[];
|
||||
|
||||
/**
|
||||
* Mixins appearing in a `with` clause, if any.
|
||||
*/
|
||||
void set mixins(List<UnlinkedTypeRefBuilder> _value) {
|
||||
void set mixins(List<TypeRefBuilder> _value) {
|
||||
assert(!_finished);
|
||||
_mixins = _value;
|
||||
}
|
||||
|
||||
@override
|
||||
List<UnlinkedTypeRef> get interfaces => _interfaces ?? const <UnlinkedTypeRef>[];
|
||||
List<TypeRef> get interfaces => _interfaces ?? const <TypeRef>[];
|
||||
|
||||
/**
|
||||
* Interfaces appearing in an `implements` clause, if any.
|
||||
*/
|
||||
void set interfaces(List<UnlinkedTypeRefBuilder> _value) {
|
||||
void set interfaces(List<TypeRefBuilder> _value) {
|
||||
assert(!_finished);
|
||||
_interfaces = _value;
|
||||
}
|
||||
@@ -1219,7 +1398,7 @@ class UnlinkedClassBuilder extends Object with _UnlinkedClassMixin implements Un
|
||||
_hasNoSupertype = _value;
|
||||
}
|
||||
|
||||
UnlinkedClassBuilder({String name, int nameOffset, UnlinkedDocumentationCommentBuilder documentationComment, List<UnlinkedTypeParamBuilder> typeParameters, UnlinkedTypeRefBuilder supertype, List<UnlinkedTypeRefBuilder> mixins, List<UnlinkedTypeRefBuilder> interfaces, List<UnlinkedVariableBuilder> fields, List<UnlinkedExecutableBuilder> executables, bool isAbstract, bool isMixinApplication, bool hasNoSupertype})
|
||||
UnlinkedClassBuilder({String name, int nameOffset, UnlinkedDocumentationCommentBuilder documentationComment, List<UnlinkedTypeParamBuilder> typeParameters, TypeRefBuilder supertype, List<TypeRefBuilder> mixins, List<TypeRefBuilder> interfaces, List<UnlinkedVariableBuilder> fields, List<UnlinkedExecutableBuilder> executables, bool isAbstract, bool isMixinApplication, bool hasNoSupertype})
|
||||
: _name = name,
|
||||
_nameOffset = nameOffset,
|
||||
_documentationComment = documentationComment,
|
||||
@@ -1340,17 +1519,17 @@ abstract class UnlinkedClass extends base.SummaryClass {
|
||||
* explicitly declare a supertype (and hence has supertype `Object`), or (b)
|
||||
* the class *is* `Object` (and hence has no supertype).
|
||||
*/
|
||||
UnlinkedTypeRef get supertype;
|
||||
TypeRef get supertype;
|
||||
|
||||
/**
|
||||
* Mixins appearing in a `with` clause, if any.
|
||||
*/
|
||||
List<UnlinkedTypeRef> get mixins;
|
||||
List<TypeRef> get mixins;
|
||||
|
||||
/**
|
||||
* Interfaces appearing in an `implements` clause, if any.
|
||||
*/
|
||||
List<UnlinkedTypeRef> get interfaces;
|
||||
List<TypeRef> get interfaces;
|
||||
|
||||
/**
|
||||
* Field declarations contained in the class.
|
||||
@@ -1395,9 +1574,9 @@ class _UnlinkedClassImpl extends Object with _UnlinkedClassMixin implements Unli
|
||||
int _nameOffset;
|
||||
UnlinkedDocumentationComment _documentationComment;
|
||||
List<UnlinkedTypeParam> _typeParameters;
|
||||
UnlinkedTypeRef _supertype;
|
||||
List<UnlinkedTypeRef> _mixins;
|
||||
List<UnlinkedTypeRef> _interfaces;
|
||||
TypeRef _supertype;
|
||||
List<TypeRef> _mixins;
|
||||
List<TypeRef> _interfaces;
|
||||
List<UnlinkedVariable> _fields;
|
||||
List<UnlinkedExecutable> _executables;
|
||||
bool _isAbstract;
|
||||
@@ -1429,20 +1608,20 @@ class _UnlinkedClassImpl extends Object with _UnlinkedClassMixin implements Unli
|
||||
}
|
||||
|
||||
@override
|
||||
UnlinkedTypeRef get supertype {
|
||||
_supertype ??= const _UnlinkedTypeRefReader().vTableGet(_bp, 4, null);
|
||||
TypeRef get supertype {
|
||||
_supertype ??= const _TypeRefReader().vTableGet(_bp, 4, null);
|
||||
return _supertype;
|
||||
}
|
||||
|
||||
@override
|
||||
List<UnlinkedTypeRef> get mixins {
|
||||
_mixins ??= const fb.ListReader<UnlinkedTypeRef>(const _UnlinkedTypeRefReader()).vTableGet(_bp, 5, const <UnlinkedTypeRef>[]);
|
||||
List<TypeRef> get mixins {
|
||||
_mixins ??= const fb.ListReader<TypeRef>(const _TypeRefReader()).vTableGet(_bp, 5, const <TypeRef>[]);
|
||||
return _mixins;
|
||||
}
|
||||
|
||||
@override
|
||||
List<UnlinkedTypeRef> get interfaces {
|
||||
_interfaces ??= const fb.ListReader<UnlinkedTypeRef>(const _UnlinkedTypeRefReader()).vTableGet(_bp, 6, const <UnlinkedTypeRef>[]);
|
||||
List<TypeRef> get interfaces {
|
||||
_interfaces ??= const fb.ListReader<TypeRef>(const _TypeRefReader()).vTableGet(_bp, 6, const <TypeRef>[]);
|
||||
return _interfaces;
|
||||
}
|
||||
|
||||
@@ -1609,7 +1788,7 @@ class UnlinkedConstBuilder extends Object with _UnlinkedConstMixin implements Un
|
||||
List<int> _ints;
|
||||
List<double> _doubles;
|
||||
List<String> _strings;
|
||||
List<UnlinkedTypeRefBuilder> _references;
|
||||
List<TypeRefBuilder> _references;
|
||||
|
||||
@override
|
||||
List<UnlinkedConstOperation> get operations => _operations ?? const <UnlinkedConstOperation>[];
|
||||
@@ -1660,7 +1839,7 @@ class UnlinkedConstBuilder extends Object with _UnlinkedConstMixin implements Un
|
||||
}
|
||||
|
||||
@override
|
||||
List<UnlinkedTypeRef> get references => _references ?? const <UnlinkedTypeRef>[];
|
||||
List<TypeRef> get references => _references ?? const <TypeRef>[];
|
||||
|
||||
/**
|
||||
* Sequence of language constructs consumed by the operations
|
||||
@@ -1668,12 +1847,12 @@ class UnlinkedConstBuilder extends Object with _UnlinkedConstMixin implements Un
|
||||
* that in the case of `pushReference` (and sometimes `invokeConstructor` the
|
||||
* actual entity being referred to may be something other than a type.
|
||||
*/
|
||||
void set references(List<UnlinkedTypeRefBuilder> _value) {
|
||||
void set references(List<TypeRefBuilder> _value) {
|
||||
assert(!_finished);
|
||||
_references = _value;
|
||||
}
|
||||
|
||||
UnlinkedConstBuilder({List<UnlinkedConstOperation> operations, List<int> ints, List<double> doubles, List<String> strings, List<UnlinkedTypeRefBuilder> references})
|
||||
UnlinkedConstBuilder({List<UnlinkedConstOperation> operations, List<int> ints, List<double> doubles, List<String> strings, List<TypeRefBuilder> references})
|
||||
: _operations = operations,
|
||||
_ints = ints,
|
||||
_doubles = doubles,
|
||||
@@ -1765,7 +1944,7 @@ abstract class UnlinkedConst extends base.SummaryClass {
|
||||
* that in the case of `pushReference` (and sometimes `invokeConstructor` the
|
||||
* actual entity being referred to may be something other than a type.
|
||||
*/
|
||||
List<UnlinkedTypeRef> get references;
|
||||
List<TypeRef> get references;
|
||||
}
|
||||
|
||||
class _UnlinkedConstReader extends fb.TableReader<_UnlinkedConstImpl> {
|
||||
@@ -1784,7 +1963,7 @@ class _UnlinkedConstImpl extends Object with _UnlinkedConstMixin implements Unli
|
||||
List<int> _ints;
|
||||
List<double> _doubles;
|
||||
List<String> _strings;
|
||||
List<UnlinkedTypeRef> _references;
|
||||
List<TypeRef> _references;
|
||||
|
||||
@override
|
||||
List<UnlinkedConstOperation> get operations {
|
||||
@@ -1811,8 +1990,8 @@ class _UnlinkedConstImpl extends Object with _UnlinkedConstMixin implements Unli
|
||||
}
|
||||
|
||||
@override
|
||||
List<UnlinkedTypeRef> get references {
|
||||
_references ??= const fb.ListReader<UnlinkedTypeRef>(const _UnlinkedTypeRefReader()).vTableGet(_bp, 4, const <UnlinkedTypeRef>[]);
|
||||
List<TypeRef> get references {
|
||||
_references ??= const fb.ListReader<TypeRef>(const _TypeRefReader()).vTableGet(_bp, 4, const <TypeRef>[]);
|
||||
return _references;
|
||||
}
|
||||
}
|
||||
@@ -2282,7 +2461,7 @@ class UnlinkedExecutableBuilder extends Object with _UnlinkedExecutableMixin imp
|
||||
int _nameOffset;
|
||||
UnlinkedDocumentationCommentBuilder _documentationComment;
|
||||
List<UnlinkedTypeParamBuilder> _typeParameters;
|
||||
UnlinkedTypeRefBuilder _returnType;
|
||||
TypeRefBuilder _returnType;
|
||||
List<UnlinkedParamBuilder> _parameters;
|
||||
UnlinkedExecutableKind _kind;
|
||||
bool _isAbstract;
|
||||
@@ -2344,14 +2523,14 @@ class UnlinkedExecutableBuilder extends Object with _UnlinkedExecutableMixin imp
|
||||
}
|
||||
|
||||
@override
|
||||
UnlinkedTypeRef get returnType => _returnType;
|
||||
TypeRef get returnType => _returnType;
|
||||
|
||||
/**
|
||||
* Declared return type of the executable. Absent if the return type is
|
||||
* `void` or the executable is a constructor. Note that when strong mode is
|
||||
* enabled, the actual return type may be different due to type inference.
|
||||
*/
|
||||
void set returnType(UnlinkedTypeRefBuilder _value) {
|
||||
void set returnType(TypeRefBuilder _value) {
|
||||
assert(!_finished);
|
||||
_returnType = _value;
|
||||
}
|
||||
@@ -2452,7 +2631,7 @@ class UnlinkedExecutableBuilder extends Object with _UnlinkedExecutableMixin imp
|
||||
_isExternal = _value;
|
||||
}
|
||||
|
||||
UnlinkedExecutableBuilder({String name, int nameOffset, UnlinkedDocumentationCommentBuilder documentationComment, List<UnlinkedTypeParamBuilder> typeParameters, UnlinkedTypeRefBuilder returnType, List<UnlinkedParamBuilder> parameters, UnlinkedExecutableKind kind, bool isAbstract, bool isStatic, bool isConst, bool isFactory, bool hasImplicitReturnType, bool isExternal})
|
||||
UnlinkedExecutableBuilder({String name, int nameOffset, UnlinkedDocumentationCommentBuilder documentationComment, List<UnlinkedTypeParamBuilder> typeParameters, TypeRefBuilder returnType, List<UnlinkedParamBuilder> parameters, UnlinkedExecutableKind kind, bool isAbstract, bool isStatic, bool isConst, bool isFactory, bool hasImplicitReturnType, bool isExternal})
|
||||
: _name = name,
|
||||
_nameOffset = nameOffset,
|
||||
_documentationComment = documentationComment,
|
||||
@@ -2572,7 +2751,7 @@ abstract class UnlinkedExecutable extends base.SummaryClass {
|
||||
* `void` or the executable is a constructor. Note that when strong mode is
|
||||
* enabled, the actual return type may be different due to type inference.
|
||||
*/
|
||||
UnlinkedTypeRef get returnType;
|
||||
TypeRef get returnType;
|
||||
|
||||
/**
|
||||
* Parameters of the executable, if any. Note that getters have no
|
||||
@@ -2639,7 +2818,7 @@ class _UnlinkedExecutableImpl extends Object with _UnlinkedExecutableMixin imple
|
||||
int _nameOffset;
|
||||
UnlinkedDocumentationComment _documentationComment;
|
||||
List<UnlinkedTypeParam> _typeParameters;
|
||||
UnlinkedTypeRef _returnType;
|
||||
TypeRef _returnType;
|
||||
List<UnlinkedParam> _parameters;
|
||||
UnlinkedExecutableKind _kind;
|
||||
bool _isAbstract;
|
||||
@@ -2674,8 +2853,8 @@ class _UnlinkedExecutableImpl extends Object with _UnlinkedExecutableMixin imple
|
||||
}
|
||||
|
||||
@override
|
||||
UnlinkedTypeRef get returnType {
|
||||
_returnType ??= const _UnlinkedTypeRefReader().vTableGet(_bp, 4, null);
|
||||
TypeRef get returnType {
|
||||
_returnType ??= const _TypeRefReader().vTableGet(_bp, 4, null);
|
||||
return _returnType;
|
||||
}
|
||||
|
||||
@@ -3314,7 +3493,7 @@ class UnlinkedParamBuilder extends Object with _UnlinkedParamMixin implements Un
|
||||
|
||||
String _name;
|
||||
int _nameOffset;
|
||||
UnlinkedTypeRefBuilder _type;
|
||||
TypeRefBuilder _type;
|
||||
List<UnlinkedParamBuilder> _parameters;
|
||||
UnlinkedParamKind _kind;
|
||||
bool _isFunctionTyped;
|
||||
@@ -3344,7 +3523,7 @@ class UnlinkedParamBuilder extends Object with _UnlinkedParamMixin implements Un
|
||||
}
|
||||
|
||||
@override
|
||||
UnlinkedTypeRef get type => _type;
|
||||
TypeRef get type => _type;
|
||||
|
||||
/**
|
||||
* If [isFunctionTyped] is `true`, the declared return type. If
|
||||
@@ -3353,7 +3532,7 @@ class UnlinkedParamBuilder extends Object with _UnlinkedParamMixin implements Un
|
||||
* that when strong mode is enabled, the actual type may be different due to
|
||||
* type inference.
|
||||
*/
|
||||
void set type(UnlinkedTypeRefBuilder _value) {
|
||||
void set type(TypeRefBuilder _value) {
|
||||
assert(!_finished);
|
||||
_type = _value;
|
||||
}
|
||||
@@ -3415,7 +3594,7 @@ class UnlinkedParamBuilder extends Object with _UnlinkedParamMixin implements Un
|
||||
_hasImplicitType = _value;
|
||||
}
|
||||
|
||||
UnlinkedParamBuilder({String name, int nameOffset, UnlinkedTypeRefBuilder type, List<UnlinkedParamBuilder> parameters, UnlinkedParamKind kind, bool isFunctionTyped, bool isInitializingFormal, bool hasImplicitType})
|
||||
UnlinkedParamBuilder({String name, int nameOffset, TypeRefBuilder type, List<UnlinkedParamBuilder> parameters, UnlinkedParamKind kind, bool isFunctionTyped, bool isInitializingFormal, bool hasImplicitType})
|
||||
: _name = name,
|
||||
_nameOffset = nameOffset,
|
||||
_type = type,
|
||||
@@ -3491,7 +3670,7 @@ abstract class UnlinkedParam extends base.SummaryClass {
|
||||
* that when strong mode is enabled, the actual type may be different due to
|
||||
* type inference.
|
||||
*/
|
||||
UnlinkedTypeRef get type;
|
||||
TypeRef get type;
|
||||
|
||||
/**
|
||||
* If [isFunctionTyped] is `true`, the parameters of the function type.
|
||||
@@ -3535,7 +3714,7 @@ class _UnlinkedParamImpl extends Object with _UnlinkedParamMixin implements Unli
|
||||
|
||||
String _name;
|
||||
int _nameOffset;
|
||||
UnlinkedTypeRef _type;
|
||||
TypeRef _type;
|
||||
List<UnlinkedParam> _parameters;
|
||||
UnlinkedParamKind _kind;
|
||||
bool _isFunctionTyped;
|
||||
@@ -3555,8 +3734,8 @@ class _UnlinkedParamImpl extends Object with _UnlinkedParamMixin implements Unli
|
||||
}
|
||||
|
||||
@override
|
||||
UnlinkedTypeRef get type {
|
||||
_type ??= const _UnlinkedTypeRefReader().vTableGet(_bp, 2, null);
|
||||
TypeRef get type {
|
||||
_type ??= const _TypeRefReader().vTableGet(_bp, 2, null);
|
||||
return _type;
|
||||
}
|
||||
|
||||
@@ -4129,7 +4308,7 @@ class UnlinkedTypedefBuilder extends Object with _UnlinkedTypedefMixin implement
|
||||
int _nameOffset;
|
||||
UnlinkedDocumentationCommentBuilder _documentationComment;
|
||||
List<UnlinkedTypeParamBuilder> _typeParameters;
|
||||
UnlinkedTypeRefBuilder _returnType;
|
||||
TypeRefBuilder _returnType;
|
||||
List<UnlinkedParamBuilder> _parameters;
|
||||
|
||||
@override
|
||||
@@ -4178,12 +4357,12 @@ class UnlinkedTypedefBuilder extends Object with _UnlinkedTypedefMixin implement
|
||||
}
|
||||
|
||||
@override
|
||||
UnlinkedTypeRef get returnType => _returnType;
|
||||
TypeRef get returnType => _returnType;
|
||||
|
||||
/**
|
||||
* Return type of the typedef. Absent if the return type is `void`.
|
||||
*/
|
||||
void set returnType(UnlinkedTypeRefBuilder _value) {
|
||||
void set returnType(TypeRefBuilder _value) {
|
||||
assert(!_finished);
|
||||
_returnType = _value;
|
||||
}
|
||||
@@ -4199,7 +4378,7 @@ class UnlinkedTypedefBuilder extends Object with _UnlinkedTypedefMixin implement
|
||||
_parameters = _value;
|
||||
}
|
||||
|
||||
UnlinkedTypedefBuilder({String name, int nameOffset, UnlinkedDocumentationCommentBuilder documentationComment, List<UnlinkedTypeParamBuilder> typeParameters, UnlinkedTypeRefBuilder returnType, List<UnlinkedParamBuilder> parameters})
|
||||
UnlinkedTypedefBuilder({String name, int nameOffset, UnlinkedDocumentationCommentBuilder documentationComment, List<UnlinkedTypeParamBuilder> typeParameters, TypeRefBuilder returnType, List<UnlinkedParamBuilder> parameters})
|
||||
: _name = name,
|
||||
_nameOffset = nameOffset,
|
||||
_documentationComment = documentationComment,
|
||||
@@ -4282,7 +4461,7 @@ abstract class UnlinkedTypedef extends base.SummaryClass {
|
||||
/**
|
||||
* Return type of the typedef. Absent if the return type is `void`.
|
||||
*/
|
||||
UnlinkedTypeRef get returnType;
|
||||
TypeRef get returnType;
|
||||
|
||||
/**
|
||||
* Parameters of the executable, if any.
|
||||
@@ -4306,7 +4485,7 @@ class _UnlinkedTypedefImpl extends Object with _UnlinkedTypedefMixin implements
|
||||
int _nameOffset;
|
||||
UnlinkedDocumentationComment _documentationComment;
|
||||
List<UnlinkedTypeParam> _typeParameters;
|
||||
UnlinkedTypeRef _returnType;
|
||||
TypeRef _returnType;
|
||||
List<UnlinkedParam> _parameters;
|
||||
|
||||
@override
|
||||
@@ -4334,8 +4513,8 @@ class _UnlinkedTypedefImpl extends Object with _UnlinkedTypedefMixin implements
|
||||
}
|
||||
|
||||
@override
|
||||
UnlinkedTypeRef get returnType {
|
||||
_returnType ??= const _UnlinkedTypeRefReader().vTableGet(_bp, 4, null);
|
||||
TypeRef get returnType {
|
||||
_returnType ??= const _TypeRefReader().vTableGet(_bp, 4, null);
|
||||
return _returnType;
|
||||
}
|
||||
|
||||
@@ -4363,7 +4542,7 @@ class UnlinkedTypeParamBuilder extends Object with _UnlinkedTypeParamMixin imple
|
||||
|
||||
String _name;
|
||||
int _nameOffset;
|
||||
UnlinkedTypeRefBuilder _bound;
|
||||
TypeRefBuilder _bound;
|
||||
|
||||
@override
|
||||
String get name => _name ?? '';
|
||||
@@ -4388,18 +4567,18 @@ class UnlinkedTypeParamBuilder extends Object with _UnlinkedTypeParamMixin imple
|
||||
}
|
||||
|
||||
@override
|
||||
UnlinkedTypeRef get bound => _bound;
|
||||
TypeRef get bound => _bound;
|
||||
|
||||
/**
|
||||
* Bound of the type parameter, if a bound is explicitly declared. Otherwise
|
||||
* null.
|
||||
*/
|
||||
void set bound(UnlinkedTypeRefBuilder _value) {
|
||||
void set bound(TypeRefBuilder _value) {
|
||||
assert(!_finished);
|
||||
_bound = _value;
|
||||
}
|
||||
|
||||
UnlinkedTypeParamBuilder({String name, int nameOffset, UnlinkedTypeRefBuilder bound})
|
||||
UnlinkedTypeParamBuilder({String name, int nameOffset, TypeRefBuilder bound})
|
||||
: _name = name,
|
||||
_nameOffset = nameOffset,
|
||||
_bound = bound;
|
||||
@@ -4448,7 +4627,7 @@ abstract class UnlinkedTypeParam extends base.SummaryClass {
|
||||
* Bound of the type parameter, if a bound is explicitly declared. Otherwise
|
||||
* null.
|
||||
*/
|
||||
UnlinkedTypeRef get bound;
|
||||
TypeRef get bound;
|
||||
}
|
||||
|
||||
class _UnlinkedTypeParamReader extends fb.TableReader<_UnlinkedTypeParamImpl> {
|
||||
@@ -4465,7 +4644,7 @@ class _UnlinkedTypeParamImpl extends Object with _UnlinkedTypeParamMixin impleme
|
||||
|
||||
String _name;
|
||||
int _nameOffset;
|
||||
UnlinkedTypeRef _bound;
|
||||
TypeRef _bound;
|
||||
|
||||
@override
|
||||
String get name {
|
||||
@@ -4480,8 +4659,8 @@ class _UnlinkedTypeParamImpl extends Object with _UnlinkedTypeParamMixin impleme
|
||||
}
|
||||
|
||||
@override
|
||||
UnlinkedTypeRef get bound {
|
||||
_bound ??= const _UnlinkedTypeRefReader().vTableGet(_bp, 2, null);
|
||||
TypeRef get bound {
|
||||
_bound ??= const _TypeRefReader().vTableGet(_bp, 2, null);
|
||||
return _bound;
|
||||
}
|
||||
}
|
||||
@@ -4495,185 +4674,6 @@ abstract class _UnlinkedTypeParamMixin implements UnlinkedTypeParam {
|
||||
};
|
||||
}
|
||||
|
||||
class UnlinkedTypeRefBuilder extends Object with _UnlinkedTypeRefMixin implements UnlinkedTypeRef {
|
||||
bool _finished = false;
|
||||
|
||||
int _reference;
|
||||
int _paramReference;
|
||||
List<UnlinkedTypeRefBuilder> _typeArguments;
|
||||
|
||||
@override
|
||||
int get reference => _reference ?? 0;
|
||||
|
||||
/**
|
||||
* Index into [UnlinkedUnit.references] for the type being referred to, or
|
||||
* zero if this is a reference to a type parameter.
|
||||
*
|
||||
* Note that since zero is also a valid index into
|
||||
* [UnlinkedUnit.references], we cannot distinguish between references to
|
||||
* type parameters and references to types by checking [reference] against
|
||||
* zero. To distinguish between references to type parameters and references
|
||||
* to types, check whether [paramReference] is zero.
|
||||
*/
|
||||
void set reference(int _value) {
|
||||
assert(!_finished);
|
||||
_reference = _value;
|
||||
}
|
||||
|
||||
@override
|
||||
int get paramReference => _paramReference ?? 0;
|
||||
|
||||
/**
|
||||
* If this is a reference to a type parameter, one-based index into the list
|
||||
* of [UnlinkedTypeParam]s currently in effect. Indexing is done using De
|
||||
* Bruijn index conventions; that is, innermost parameters come first, and
|
||||
* if a class or method has multiple parameters, they are indexed from right
|
||||
* to left. So for instance, if the enclosing declaration is
|
||||
*
|
||||
* class C<T,U> {
|
||||
* m<V,W> {
|
||||
* ...
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* Then [paramReference] values of 1, 2, 3, and 4 represent W, V, U, and T,
|
||||
* respectively.
|
||||
*
|
||||
* If the type being referred to is not a type parameter, [paramReference] is
|
||||
* zero.
|
||||
*/
|
||||
void set paramReference(int _value) {
|
||||
assert(!_finished);
|
||||
_paramReference = _value;
|
||||
}
|
||||
|
||||
@override
|
||||
List<UnlinkedTypeRef> get typeArguments => _typeArguments ?? const <UnlinkedTypeRef>[];
|
||||
|
||||
/**
|
||||
* If this is an instantiation of a generic type, the type arguments used to
|
||||
* instantiate it. Trailing type arguments of type `dynamic` are omitted.
|
||||
*/
|
||||
void set typeArguments(List<UnlinkedTypeRefBuilder> _value) {
|
||||
assert(!_finished);
|
||||
_typeArguments = _value;
|
||||
}
|
||||
|
||||
UnlinkedTypeRefBuilder({int reference, int paramReference, List<UnlinkedTypeRefBuilder> typeArguments})
|
||||
: _reference = reference,
|
||||
_paramReference = paramReference,
|
||||
_typeArguments = typeArguments;
|
||||
|
||||
fb.Offset finish(fb.Builder fbBuilder) {
|
||||
assert(!_finished);
|
||||
_finished = true;
|
||||
fb.Offset offset_typeArguments;
|
||||
if (!(_typeArguments == null || _typeArguments.isEmpty)) {
|
||||
offset_typeArguments = fbBuilder.writeList(_typeArguments.map((b) => b.finish(fbBuilder)).toList());
|
||||
}
|
||||
fbBuilder.startTable();
|
||||
if (_reference != null && _reference != 0) {
|
||||
fbBuilder.addInt32(0, _reference);
|
||||
}
|
||||
if (_paramReference != null && _paramReference != 0) {
|
||||
fbBuilder.addInt32(1, _paramReference);
|
||||
}
|
||||
if (offset_typeArguments != null) {
|
||||
fbBuilder.addOffset(2, offset_typeArguments);
|
||||
}
|
||||
return fbBuilder.endTable();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlinked summary information about a reference to a type.
|
||||
*/
|
||||
abstract class UnlinkedTypeRef extends base.SummaryClass {
|
||||
|
||||
/**
|
||||
* Index into [UnlinkedUnit.references] for the type being referred to, or
|
||||
* zero if this is a reference to a type parameter.
|
||||
*
|
||||
* Note that since zero is also a valid index into
|
||||
* [UnlinkedUnit.references], we cannot distinguish between references to
|
||||
* type parameters and references to types by checking [reference] against
|
||||
* zero. To distinguish between references to type parameters and references
|
||||
* to types, check whether [paramReference] is zero.
|
||||
*/
|
||||
int get reference;
|
||||
|
||||
/**
|
||||
* If this is a reference to a type parameter, one-based index into the list
|
||||
* of [UnlinkedTypeParam]s currently in effect. Indexing is done using De
|
||||
* Bruijn index conventions; that is, innermost parameters come first, and
|
||||
* if a class or method has multiple parameters, they are indexed from right
|
||||
* to left. So for instance, if the enclosing declaration is
|
||||
*
|
||||
* class C<T,U> {
|
||||
* m<V,W> {
|
||||
* ...
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* Then [paramReference] values of 1, 2, 3, and 4 represent W, V, U, and T,
|
||||
* respectively.
|
||||
*
|
||||
* If the type being referred to is not a type parameter, [paramReference] is
|
||||
* zero.
|
||||
*/
|
||||
int get paramReference;
|
||||
|
||||
/**
|
||||
* If this is an instantiation of a generic type, the type arguments used to
|
||||
* instantiate it. Trailing type arguments of type `dynamic` are omitted.
|
||||
*/
|
||||
List<UnlinkedTypeRef> get typeArguments;
|
||||
}
|
||||
|
||||
class _UnlinkedTypeRefReader extends fb.TableReader<_UnlinkedTypeRefImpl> {
|
||||
const _UnlinkedTypeRefReader();
|
||||
|
||||
@override
|
||||
_UnlinkedTypeRefImpl createObject(fb.BufferPointer bp) => new _UnlinkedTypeRefImpl(bp);
|
||||
}
|
||||
|
||||
class _UnlinkedTypeRefImpl extends Object with _UnlinkedTypeRefMixin implements UnlinkedTypeRef {
|
||||
final fb.BufferPointer _bp;
|
||||
|
||||
_UnlinkedTypeRefImpl(this._bp);
|
||||
|
||||
int _reference;
|
||||
int _paramReference;
|
||||
List<UnlinkedTypeRef> _typeArguments;
|
||||
|
||||
@override
|
||||
int get reference {
|
||||
_reference ??= const fb.Int32Reader().vTableGet(_bp, 0, 0);
|
||||
return _reference;
|
||||
}
|
||||
|
||||
@override
|
||||
int get paramReference {
|
||||
_paramReference ??= const fb.Int32Reader().vTableGet(_bp, 1, 0);
|
||||
return _paramReference;
|
||||
}
|
||||
|
||||
@override
|
||||
List<UnlinkedTypeRef> get typeArguments {
|
||||
_typeArguments ??= const fb.ListReader<UnlinkedTypeRef>(const _UnlinkedTypeRefReader()).vTableGet(_bp, 2, const <UnlinkedTypeRef>[]);
|
||||
return _typeArguments;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _UnlinkedTypeRefMixin implements UnlinkedTypeRef {
|
||||
@override
|
||||
Map<String, Object> toMap() => {
|
||||
"reference": reference,
|
||||
"paramReference": paramReference,
|
||||
"typeArguments": typeArguments,
|
||||
};
|
||||
}
|
||||
|
||||
class UnlinkedUnitBuilder extends Object with _UnlinkedUnitMixin implements UnlinkedUnit {
|
||||
bool _finished = false;
|
||||
|
||||
@@ -5195,7 +5195,7 @@ class UnlinkedVariableBuilder extends Object with _UnlinkedVariableMixin impleme
|
||||
String _name;
|
||||
int _nameOffset;
|
||||
UnlinkedDocumentationCommentBuilder _documentationComment;
|
||||
UnlinkedTypeRefBuilder _type;
|
||||
TypeRefBuilder _type;
|
||||
UnlinkedConstBuilder _constExpr;
|
||||
bool _isStatic;
|
||||
bool _isFinal;
|
||||
@@ -5237,13 +5237,13 @@ class UnlinkedVariableBuilder extends Object with _UnlinkedVariableMixin impleme
|
||||
}
|
||||
|
||||
@override
|
||||
UnlinkedTypeRef get type => _type;
|
||||
TypeRef get type => _type;
|
||||
|
||||
/**
|
||||
* Declared type of the variable. Note that when strong mode is enabled, the
|
||||
* actual type of the variable may be different due to type inference.
|
||||
*/
|
||||
void set type(UnlinkedTypeRefBuilder _value) {
|
||||
void set type(TypeRefBuilder _value) {
|
||||
assert(!_finished);
|
||||
_type = _value;
|
||||
}
|
||||
@@ -5308,7 +5308,7 @@ class UnlinkedVariableBuilder extends Object with _UnlinkedVariableMixin impleme
|
||||
_hasImplicitType = _value;
|
||||
}
|
||||
|
||||
UnlinkedVariableBuilder({String name, int nameOffset, UnlinkedDocumentationCommentBuilder documentationComment, UnlinkedTypeRefBuilder type, UnlinkedConstBuilder constExpr, bool isStatic, bool isFinal, bool isConst, bool hasImplicitType})
|
||||
UnlinkedVariableBuilder({String name, int nameOffset, UnlinkedDocumentationCommentBuilder documentationComment, TypeRefBuilder type, UnlinkedConstBuilder constExpr, bool isStatic, bool isFinal, bool isConst, bool hasImplicitType})
|
||||
: _name = name,
|
||||
_nameOffset = nameOffset,
|
||||
_documentationComment = documentationComment,
|
||||
@@ -5396,7 +5396,7 @@ abstract class UnlinkedVariable extends base.SummaryClass {
|
||||
* Declared type of the variable. Note that when strong mode is enabled, the
|
||||
* actual type of the variable may be different due to type inference.
|
||||
*/
|
||||
UnlinkedTypeRef get type;
|
||||
TypeRef get type;
|
||||
|
||||
/**
|
||||
* If [isConst] is true, and the variable has an initializer, the constant
|
||||
@@ -5444,7 +5444,7 @@ class _UnlinkedVariableImpl extends Object with _UnlinkedVariableMixin implement
|
||||
String _name;
|
||||
int _nameOffset;
|
||||
UnlinkedDocumentationComment _documentationComment;
|
||||
UnlinkedTypeRef _type;
|
||||
TypeRef _type;
|
||||
UnlinkedConst _constExpr;
|
||||
bool _isStatic;
|
||||
bool _isFinal;
|
||||
@@ -5470,8 +5470,8 @@ class _UnlinkedVariableImpl extends Object with _UnlinkedVariableMixin implement
|
||||
}
|
||||
|
||||
@override
|
||||
UnlinkedTypeRef get type {
|
||||
_type ??= const _UnlinkedTypeRefReader().vTableGet(_bp, 3, null);
|
||||
TypeRef get type {
|
||||
_type ??= const _TypeRefReader().vTableGet(_bp, 3, null);
|
||||
return _type;
|
||||
}
|
||||
|
||||
|
||||
@@ -931,17 +931,16 @@ class _LibraryResynthesizer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a [DartType] object based on an [UnlinkedTypeRef]. This [DartType]
|
||||
* Build a [DartType] object based on a [TypeRef]. This [DartType]
|
||||
* may refer to elements in other libraries than the library being
|
||||
* deserialized, so handles are used to avoid having to deserialize other
|
||||
* libraries in the process.
|
||||
*/
|
||||
DartType buildType(UnlinkedTypeRef type) {
|
||||
DartType buildType(TypeRef type) {
|
||||
if (type.paramReference != 0) {
|
||||
// TODO(paulberry): make this work for generic methods.
|
||||
return currentTypeParameters[
|
||||
currentTypeParameters.length - type.paramReference]
|
||||
.type;
|
||||
currentTypeParameters.length - type.paramReference].type;
|
||||
} else {
|
||||
// TODO(paulberry): handle references to things other than classes (note:
|
||||
// this should only occur in the case of erroneous code).
|
||||
|
||||
@@ -28,8 +28,8 @@ class _ConstExprSerializer extends AbstractConstExprSerializer {
|
||||
|
||||
_ConstExprSerializer(this.visitor);
|
||||
|
||||
UnlinkedTypeRefBuilder serializeIdentifier(Identifier identifier) {
|
||||
UnlinkedTypeRefBuilder b = new UnlinkedTypeRefBuilder();
|
||||
TypeRefBuilder serializeIdentifier(Identifier identifier) {
|
||||
TypeRefBuilder b = new TypeRefBuilder();
|
||||
if (identifier is SimpleIdentifier) {
|
||||
b.reference = visitor.serializeReference(null, identifier.name);
|
||||
} else if (identifier is PrefixedIdentifier) {
|
||||
@@ -44,7 +44,7 @@ class _ConstExprSerializer extends AbstractConstExprSerializer {
|
||||
}
|
||||
|
||||
@override
|
||||
UnlinkedTypeRefBuilder serializeType(TypeName node) {
|
||||
TypeRefBuilder serializeType(TypeName node) {
|
||||
return visitor.serializeTypeName(node);
|
||||
}
|
||||
}
|
||||
@@ -455,7 +455,7 @@ class _SummarizeAstVisitor extends SimpleAstVisitor {
|
||||
*/
|
||||
void serializeFunctionTypedParameterDetails(UnlinkedParamBuilder b,
|
||||
TypeName returnType, FormalParameterList parameters) {
|
||||
UnlinkedTypeRefBuilder serializedReturnType =
|
||||
TypeRefBuilder serializedReturnType =
|
||||
serializeTypeName(returnType, allowVoid: true);
|
||||
if (serializedReturnType != null) {
|
||||
b.type = serializedReturnType;
|
||||
@@ -508,12 +508,11 @@ class _SummarizeAstVisitor extends SimpleAstVisitor {
|
||||
/**
|
||||
* Serialize a type name (which might be defined in a nested scope, at top
|
||||
* level within this library, or at top level within an imported library) to
|
||||
* an [UnlinkedTypeRef]. Note that this method does the right thing if the
|
||||
* a [TypeRef]. Note that this method does the right thing if the
|
||||
* name doesn't refer to an entity other than a type (e.g. a class member).
|
||||
*/
|
||||
UnlinkedTypeRefBuilder serializeTypeName(TypeName node,
|
||||
{bool allowVoid: false}) {
|
||||
UnlinkedTypeRefBuilder b = new UnlinkedTypeRefBuilder();
|
||||
TypeRefBuilder serializeTypeName(TypeName node, {bool allowVoid: false}) {
|
||||
TypeRefBuilder b = new TypeRefBuilder();
|
||||
if (node != null) {
|
||||
Identifier identifier = node.name;
|
||||
if (identifier is SimpleIdentifier) {
|
||||
@@ -561,8 +560,7 @@ class _SummarizeAstVisitor extends SimpleAstVisitor {
|
||||
--numArgsToSerialize;
|
||||
}
|
||||
if (numArgsToSerialize > 0) {
|
||||
List<UnlinkedTypeRefBuilder> serializedArguments =
|
||||
<UnlinkedTypeRefBuilder>[];
|
||||
List<TypeRefBuilder> serializedArguments = <TypeRefBuilder>[];
|
||||
for (int i = 0; i < numArgsToSerialize; i++) {
|
||||
serializedArguments.add(serializeTypeName(args[i]));
|
||||
}
|
||||
@@ -750,7 +748,7 @@ class _SummarizeAstVisitor extends SimpleAstVisitor {
|
||||
b.nameOffset = node.name.offset;
|
||||
b.typeParameters =
|
||||
serializeTypeParameters(node.typeParameters, typeParameterScope);
|
||||
UnlinkedTypeRefBuilder serializedReturnType =
|
||||
TypeRefBuilder serializedReturnType =
|
||||
serializeTypeName(node.returnType, allowVoid: true);
|
||||
if (serializedReturnType != null) {
|
||||
b.returnType = serializedReturnType;
|
||||
|
||||
@@ -36,7 +36,7 @@ abstract class AbstractConstExprSerializer {
|
||||
/**
|
||||
* See [UnlinkedConstBuilder.references].
|
||||
*/
|
||||
final List<UnlinkedTypeRefBuilder> references = <UnlinkedTypeRefBuilder>[];
|
||||
final List<TypeRefBuilder> references = <TypeRefBuilder>[];
|
||||
|
||||
/**
|
||||
* Serialize the given [expr] expression into this serializer state.
|
||||
@@ -103,14 +103,14 @@ abstract class AbstractConstExprSerializer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return [UnlinkedTypeRefBuilder] that corresponds to the given [identifier].
|
||||
* Return [TypeRefBuilder] that corresponds to the given [identifier].
|
||||
*/
|
||||
UnlinkedTypeRefBuilder serializeIdentifier(Identifier identifier);
|
||||
TypeRefBuilder serializeIdentifier(Identifier identifier);
|
||||
|
||||
/**
|
||||
* Return [UnlinkedTypeRefBuilder] that corresponds to the given [type].
|
||||
* Return [TypeRefBuilder] that corresponds to the given [type].
|
||||
*/
|
||||
UnlinkedTypeRefBuilder serializeType(TypeName type);
|
||||
TypeRefBuilder serializeType(TypeName type);
|
||||
|
||||
/**
|
||||
* Return the [UnlinkedConstBuilder] that corresponds to the state of this
|
||||
|
||||
@@ -61,16 +61,16 @@ class _ConstExprSerializer extends AbstractConstExprSerializer {
|
||||
|
||||
_ConstExprSerializer(this.serializer);
|
||||
|
||||
UnlinkedTypeRefBuilder serializeIdentifier(Identifier identifier) {
|
||||
TypeRefBuilder serializeIdentifier(Identifier identifier) {
|
||||
Element element = identifier.staticElement;
|
||||
assert(element != null);
|
||||
// TODO(scheglov) how to serialize element references?
|
||||
return new UnlinkedTypeRefBuilder(
|
||||
return new TypeRefBuilder(
|
||||
reference: serializer._getElementReferenceId(element));
|
||||
}
|
||||
|
||||
@override
|
||||
UnlinkedTypeRefBuilder serializeType(TypeName typeName) {
|
||||
TypeRefBuilder serializeType(TypeName typeName) {
|
||||
DartType type = typeName != null ? typeName.type : DynamicTypeImpl.instance;
|
||||
return serializer.serializeTypeRef(type, null);
|
||||
}
|
||||
@@ -702,10 +702,10 @@ class _LibrarySerializer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the given [type] into an [UnlinkedTypeRef].
|
||||
* Serialize the given [type] into a [TypeRef].
|
||||
*/
|
||||
UnlinkedTypeRefBuilder serializeTypeRef(DartType type, Element context) {
|
||||
UnlinkedTypeRefBuilder b = new UnlinkedTypeRefBuilder();
|
||||
TypeRefBuilder serializeTypeRef(DartType type, Element context) {
|
||||
TypeRefBuilder b = new TypeRefBuilder();
|
||||
if (type is TypeParameterType) {
|
||||
b.paramReference = findTypeParameterIndex(type, context);
|
||||
} else {
|
||||
@@ -735,8 +735,7 @@ class _LibrarySerializer {
|
||||
--numArgsToSerialize;
|
||||
}
|
||||
if (numArgsToSerialize > 0) {
|
||||
List<UnlinkedTypeRefBuilder> serializedArguments =
|
||||
<UnlinkedTypeRefBuilder>[];
|
||||
List<TypeRefBuilder> serializedArguments = <TypeRefBuilder>[];
|
||||
for (int i = 0; i < numArgsToSerialize; i++) {
|
||||
serializedArguments
|
||||
.add(serializeTypeRef(typeArguments[i], context));
|
||||
|
||||
@@ -58,8 +58,7 @@ final Map<String, UnlinkedPublicNamespace> sdkPublicNamespace = () {
|
||||
for (int i = 0; i < serializedLibrary.unlinkedUnits.length; i++) {
|
||||
uriToNamespace[serializedLibrary.unitUris[i]] =
|
||||
new UnlinkedUnit.fromBuffer(
|
||||
serializedLibrary.unlinkedUnits[i].toBuffer())
|
||||
.publicNamespace;
|
||||
serializedLibrary.unlinkedUnits[i].toBuffer()).publicNamespace;
|
||||
}
|
||||
}
|
||||
return uriToNamespace;
|
||||
@@ -120,9 +119,9 @@ UnlinkedPublicNamespace computePublicNamespaceFromText(
|
||||
}
|
||||
|
||||
/**
|
||||
* Type of a function that validates an [UnlinkedTypeRef].
|
||||
* Type of a function that validates an [TypeRef].
|
||||
*/
|
||||
typedef bool _UnlinkedTypeRefValidator(UnlinkedTypeRef unlinkedTypeRef);
|
||||
typedef bool _TypeRefValidator(TypeRef unlinkedTypeRef);
|
||||
|
||||
/**
|
||||
* Override of [SummaryTest] which verifies the correctness of the prelinker by
|
||||
@@ -423,7 +422,7 @@ abstract class SummaryTest {
|
||||
/**
|
||||
* Verify that the given [typeRef] represents the type `dynamic`.
|
||||
*/
|
||||
void checkDynamicTypeRef(UnlinkedTypeRef typeRef) {
|
||||
void checkDynamicTypeRef(TypeRef typeRef) {
|
||||
checkTypeRef(typeRef, null, null, null);
|
||||
}
|
||||
|
||||
@@ -493,8 +492,8 @@ abstract class SummaryTest {
|
||||
* Verify that the given [typeRef] represents a reference to a type parameter
|
||||
* having the given [deBruijnIndex].
|
||||
*/
|
||||
void checkParamTypeRef(UnlinkedTypeRef typeRef, int deBruijnIndex) {
|
||||
expect(typeRef, new isInstanceOf<UnlinkedTypeRef>());
|
||||
void checkParamTypeRef(TypeRef typeRef, int deBruijnIndex) {
|
||||
expect(typeRef, new isInstanceOf<TypeRef>());
|
||||
expect(typeRef.reference, 0);
|
||||
expect(typeRef.typeArguments, isEmpty);
|
||||
expect(typeRef.paramReference, deBruijnIndex);
|
||||
@@ -527,8 +526,8 @@ abstract class SummaryTest {
|
||||
* assumed to be the defining compilation unit. [numTypeParameters] is the
|
||||
* number of type parameters of the thing being referred to.
|
||||
*/
|
||||
void checkTypeRef(UnlinkedTypeRef typeRef, String absoluteUri,
|
||||
String relativeUri, String expectedName,
|
||||
void checkTypeRef(TypeRef typeRef, String absoluteUri, String relativeUri,
|
||||
String expectedName,
|
||||
{String expectedPrefix,
|
||||
bool allowTypeParameters: false,
|
||||
ReferenceKind expectedKind: ReferenceKind.classOrEnum,
|
||||
@@ -538,7 +537,7 @@ abstract class SummaryTest {
|
||||
int numTypeParameters: 0}) {
|
||||
linkedSourceUnit ??= definingUnit;
|
||||
unlinkedSourceUnit ??= unlinkedUnits[0];
|
||||
expect(typeRef, new isInstanceOf<UnlinkedTypeRef>());
|
||||
expect(typeRef, new isInstanceOf<TypeRef>());
|
||||
expect(typeRef.paramReference, 0);
|
||||
int index = typeRef.reference;
|
||||
UnlinkedReference reference = unlinkedSourceUnit.references[index];
|
||||
@@ -583,7 +582,7 @@ abstract class SummaryTest {
|
||||
* type.
|
||||
*/
|
||||
void checkUnresolvedTypeRef(
|
||||
UnlinkedTypeRef typeRef, String expectedPrefix, String expectedName) {
|
||||
TypeRef typeRef, String expectedPrefix, String expectedName) {
|
||||
// When serializing from the element model, unresolved type refs lose their
|
||||
// name.
|
||||
checkTypeRef(typeRef, null, null, checkAstDerivedData ? expectedName : null,
|
||||
@@ -794,15 +793,14 @@ enum E {
|
||||
|
||||
/**
|
||||
* Serialize a type declaration using the given [text] as a type name, and
|
||||
* return a summary of the corresponding [UnlinkedTypeRef]. If the type
|
||||
* return a summary of the corresponding [TypeRef]. If the type
|
||||
* declaration needs to refer to types that are not available in core, those
|
||||
* types may be declared in [otherDeclarations].
|
||||
*/
|
||||
UnlinkedTypeRef serializeTypeText(String text,
|
||||
TypeRef serializeTypeText(String text,
|
||||
{String otherDeclarations: '', bool allowErrors: false}) {
|
||||
return serializeVariableText('$otherDeclarations\n$text v;',
|
||||
allowErrors: allowErrors)
|
||||
.type;
|
||||
allowErrors: allowErrors).type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1022,7 +1020,7 @@ class E {}
|
||||
}
|
||||
|
||||
test_class_alias_reference_generic() {
|
||||
UnlinkedTypeRef typeRef = serializeTypeText('C',
|
||||
TypeRef typeRef = serializeTypeText('C',
|
||||
otherDeclarations: 'class C<D, E> = F with G; class F {} class G {}');
|
||||
checkTypeRef(typeRef, null, null, 'C', numTypeParameters: 2);
|
||||
}
|
||||
@@ -1030,7 +1028,7 @@ class E {}
|
||||
test_class_alias_reference_generic_imported() {
|
||||
addNamedSource(
|
||||
'/lib.dart', 'class C<D, E> = F with G; class F {} class G {}');
|
||||
UnlinkedTypeRef typeRef =
|
||||
TypeRef typeRef =
|
||||
serializeTypeText('C', otherDeclarations: 'import "lib.dart";');
|
||||
checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'C',
|
||||
numTypeParameters: 2);
|
||||
@@ -1166,14 +1164,14 @@ class E {}
|
||||
}
|
||||
|
||||
test_class_reference_generic() {
|
||||
UnlinkedTypeRef typeRef =
|
||||
TypeRef typeRef =
|
||||
serializeTypeText('C', otherDeclarations: 'class C<D, E> {}');
|
||||
checkTypeRef(typeRef, null, null, 'C', numTypeParameters: 2);
|
||||
}
|
||||
|
||||
test_class_reference_generic_imported() {
|
||||
addNamedSource('/lib.dart', 'class C<D, E> {}');
|
||||
UnlinkedTypeRef typeRef =
|
||||
TypeRef typeRef =
|
||||
serializeTypeText('C', otherDeclarations: 'import "lib.dart";');
|
||||
checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'C',
|
||||
numTypeParameters: 2);
|
||||
@@ -1203,13 +1201,13 @@ class E {}
|
||||
|
||||
test_class_type_param_f_bound() {
|
||||
UnlinkedClass cls = serializeClassText('class C<T, U extends List<T>> {}');
|
||||
UnlinkedTypeRef typeArgument = cls.typeParameters[1].bound.typeArguments[0];
|
||||
TypeRef typeArgument = cls.typeParameters[1].bound.typeArguments[0];
|
||||
checkParamTypeRef(typeArgument, 2);
|
||||
}
|
||||
|
||||
test_class_type_param_f_bound_self_ref() {
|
||||
UnlinkedClass cls = serializeClassText('class C<T, U extends List<U>> {}');
|
||||
UnlinkedTypeRef typeArgument = cls.typeParameters[1].bound.typeArguments[0];
|
||||
TypeRef typeArgument = cls.typeParameters[1].bound.typeArguments[0];
|
||||
checkParamTypeRef(typeArgument, 1);
|
||||
}
|
||||
|
||||
@@ -1492,7 +1490,7 @@ const v = const C.named();
|
||||
], strings: [
|
||||
'named'
|
||||
], referenceValidators: [
|
||||
(UnlinkedTypeRef r) => checkTypeRef(r, null, null, 'C',
|
||||
(TypeRef r) => checkTypeRef(r, null, null, 'C',
|
||||
expectedKind: ReferenceKind.classOrEnum)
|
||||
]);
|
||||
}
|
||||
@@ -1520,7 +1518,7 @@ const v = const C.named();
|
||||
], strings: [
|
||||
'named'
|
||||
], referenceValidators: [
|
||||
(UnlinkedTypeRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C',
|
||||
(TypeRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C',
|
||||
expectedKind: ReferenceKind.classOrEnum)
|
||||
]);
|
||||
}
|
||||
@@ -1544,7 +1542,7 @@ const v = const p.C.named();
|
||||
], strings: [
|
||||
'named'
|
||||
], referenceValidators: [
|
||||
(UnlinkedTypeRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C',
|
||||
(TypeRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'C',
|
||||
expectedKind: ReferenceKind.classOrEnum, expectedPrefix: 'p')
|
||||
]);
|
||||
}
|
||||
@@ -1567,7 +1565,7 @@ const v = const C(42, 'sss');
|
||||
'sss',
|
||||
''
|
||||
], referenceValidators: [
|
||||
(UnlinkedTypeRef r) => checkTypeRef(r, null, null, 'C',
|
||||
(TypeRef r) => checkTypeRef(r, null, null, 'C',
|
||||
expectedKind: ReferenceKind.classOrEnum)
|
||||
]);
|
||||
}
|
||||
@@ -1575,12 +1573,10 @@ const v = const C(42, 'sss');
|
||||
test_constExpr_length() {
|
||||
UnlinkedVariable variable =
|
||||
serializeVariableText('const v = "abc".length;');
|
||||
_assertUnlinkedConst(variable.constExpr, operators: [
|
||||
UnlinkedConstOperation.pushString,
|
||||
UnlinkedConstOperation.length
|
||||
], strings: [
|
||||
'abc'
|
||||
]);
|
||||
_assertUnlinkedConst(variable.constExpr,
|
||||
operators:
|
||||
[UnlinkedConstOperation.pushString, UnlinkedConstOperation.length],
|
||||
strings: ['abc']);
|
||||
}
|
||||
|
||||
test_constExpr_makeList_typed() {
|
||||
@@ -1597,7 +1593,7 @@ const v = const C(42, 'sss');
|
||||
33,
|
||||
3
|
||||
], referenceValidators: [
|
||||
(UnlinkedTypeRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int',
|
||||
(TypeRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int',
|
||||
expectedKind: ReferenceKind.classOrEnum)
|
||||
]);
|
||||
}
|
||||
@@ -1616,7 +1612,7 @@ const v = const C(42, 'sss');
|
||||
33,
|
||||
3
|
||||
], referenceValidators: [
|
||||
(UnlinkedTypeRef r) => checkTypeRef(r, null, null, '',
|
||||
(TypeRef r) => checkTypeRef(r, null, null, '',
|
||||
expectedKind: ReferenceKind.classOrEnum)
|
||||
]);
|
||||
}
|
||||
@@ -1642,9 +1638,9 @@ const v = const C(42, 'sss');
|
||||
'bbb',
|
||||
'ccc'
|
||||
], referenceValidators: [
|
||||
(UnlinkedTypeRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int',
|
||||
(TypeRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'int',
|
||||
expectedKind: ReferenceKind.classOrEnum),
|
||||
(UnlinkedTypeRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'String',
|
||||
(TypeRef r) => checkTypeRef(r, 'dart:core', 'dart:core', 'String',
|
||||
expectedKind: ReferenceKind.classOrEnum)
|
||||
]);
|
||||
}
|
||||
@@ -1670,9 +1666,9 @@ const v = const C(42, 'sss');
|
||||
'bbb',
|
||||
'ccc'
|
||||
], referenceValidators: [
|
||||
(UnlinkedTypeRef r) => checkTypeRef(r, null, null, '',
|
||||
(TypeRef r) => checkTypeRef(r, null, null, '',
|
||||
expectedKind: ReferenceKind.classOrEnum),
|
||||
(UnlinkedTypeRef r) => checkTypeRef(r, null, null, '',
|
||||
(TypeRef r) => checkTypeRef(r, null, null, '',
|
||||
expectedKind: ReferenceKind.classOrEnum)
|
||||
]);
|
||||
}
|
||||
@@ -1704,30 +1700,24 @@ const v = const C(42, 'sss');
|
||||
|
||||
test_constExpr_prefix_complement() {
|
||||
UnlinkedVariable variable = serializeVariableText('const v = ~2;');
|
||||
_assertUnlinkedConst(variable.constExpr, operators: [
|
||||
UnlinkedConstOperation.pushInt,
|
||||
UnlinkedConstOperation.complement
|
||||
], ints: [
|
||||
2
|
||||
]);
|
||||
_assertUnlinkedConst(variable.constExpr,
|
||||
operators:
|
||||
[UnlinkedConstOperation.pushInt, UnlinkedConstOperation.complement],
|
||||
ints: [2]);
|
||||
}
|
||||
|
||||
test_constExpr_prefix_negate() {
|
||||
UnlinkedVariable variable = serializeVariableText('const v = -(2);');
|
||||
_assertUnlinkedConst(variable.constExpr, operators: [
|
||||
UnlinkedConstOperation.pushInt,
|
||||
UnlinkedConstOperation.negate
|
||||
], ints: [
|
||||
2
|
||||
]);
|
||||
_assertUnlinkedConst(variable.constExpr,
|
||||
operators:
|
||||
[UnlinkedConstOperation.pushInt, UnlinkedConstOperation.negate],
|
||||
ints: [2]);
|
||||
}
|
||||
|
||||
test_constExpr_prefix_not() {
|
||||
UnlinkedVariable variable = serializeVariableText('const v = !true;');
|
||||
_assertUnlinkedConst(variable.constExpr, operators: [
|
||||
UnlinkedConstOperation.pushTrue,
|
||||
UnlinkedConstOperation.not
|
||||
]);
|
||||
_assertUnlinkedConst(variable.constExpr, operators:
|
||||
[UnlinkedConstOperation.pushTrue, UnlinkedConstOperation.not]);
|
||||
}
|
||||
|
||||
test_constExpr_pushDouble() {
|
||||
@@ -1762,14 +1752,14 @@ const v = C;
|
||||
_assertUnlinkedConst(variable.constExpr, operators: [
|
||||
UnlinkedConstOperation.pushReference
|
||||
], referenceValidators: [
|
||||
(UnlinkedTypeRef r) => checkTypeRef(r, null, null, 'C',
|
||||
(TypeRef r) => checkTypeRef(r, null, null, 'C',
|
||||
expectedKind: ReferenceKind.classOrEnum)
|
||||
]);
|
||||
}
|
||||
|
||||
test_constExpr_pushReference_class_field() {
|
||||
// TODO(scheglov) Not sure for to represent a field reference
|
||||
// using UnlinkedTypeRef.
|
||||
// using TypeRef.
|
||||
// UnlinkedVariable variable = serializeVariableText('''
|
||||
//class C {
|
||||
// static const int F = 1;
|
||||
@@ -1779,7 +1769,7 @@ const v = C;
|
||||
// _assertUnlinkedConst(variable.constExpr, operators: [
|
||||
// UnlinkedConstOperation.pushReference
|
||||
// ], references: [
|
||||
// (UnlinkedTypeRef r) => checkTypeRef(r, null, null, 'F',
|
||||
// (TypeRef r) => checkTypeRef(r, null, null, 'F',
|
||||
// expectedKind: ReferenceKind.classOrEnum, expectedPrefix: 'C')
|
||||
// ]);
|
||||
}
|
||||
@@ -1792,7 +1782,7 @@ const v = C;
|
||||
_assertUnlinkedConst(variable.constExpr, operators: [
|
||||
UnlinkedConstOperation.pushReference
|
||||
], referenceValidators: [
|
||||
(UnlinkedTypeRef r) => checkTypeRef(r, null, null, 'C',
|
||||
(TypeRef r) => checkTypeRef(r, null, null, 'C',
|
||||
expectedKind: ReferenceKind.classOrEnum)
|
||||
]);
|
||||
}
|
||||
@@ -1806,7 +1796,7 @@ const v = a;
|
||||
_assertUnlinkedConst(variable.constExpr, operators: [
|
||||
UnlinkedConstOperation.pushReference
|
||||
], referenceValidators: [
|
||||
(UnlinkedTypeRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a',
|
||||
(TypeRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a',
|
||||
expectedKind: ReferenceKind.topLevelPropertyAccessor)
|
||||
]);
|
||||
}
|
||||
@@ -1820,7 +1810,7 @@ const v = p.a;
|
||||
_assertUnlinkedConst(variable.constExpr, operators: [
|
||||
UnlinkedConstOperation.pushReference
|
||||
], referenceValidators: [
|
||||
(UnlinkedTypeRef r) {
|
||||
(TypeRef r) {
|
||||
return checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'a',
|
||||
expectedKind: ReferenceKind.topLevelPropertyAccessor,
|
||||
expectedPrefix: 'p');
|
||||
@@ -1837,7 +1827,7 @@ const v = a;
|
||||
_assertUnlinkedConst(variable.constExpr, operators: [
|
||||
UnlinkedConstOperation.pushReference
|
||||
], referenceValidators: [
|
||||
(UnlinkedTypeRef r) => checkTypeRef(r, null, null, 'a',
|
||||
(TypeRef r) => checkTypeRef(r, null, null, 'a',
|
||||
expectedKind: ReferenceKind.topLevelPropertyAccessor)
|
||||
]);
|
||||
}
|
||||
@@ -2565,8 +2555,7 @@ enum E { v }''';
|
||||
|
||||
test_executable_operator_index_set() {
|
||||
UnlinkedExecutable executable = serializeClassText(
|
||||
'class C { void operator[]=(int i, bool v) => null; }')
|
||||
.executables[0];
|
||||
'class C { void operator[]=(int i, bool v) => null; }').executables[0];
|
||||
expect(executable.kind, UnlinkedExecutableKind.functionOrMethod);
|
||||
expect(executable.name, '[]=');
|
||||
expect(executable.hasImplicitReturnType, false);
|
||||
@@ -2761,28 +2750,28 @@ enum E { v }''';
|
||||
test_executable_type_param_f_bound_function() {
|
||||
UnlinkedExecutable ex =
|
||||
serializeExecutableText('void f<T, U extends List<T>>() {}');
|
||||
UnlinkedTypeRef typeArgument = ex.typeParameters[1].bound.typeArguments[0];
|
||||
TypeRef typeArgument = ex.typeParameters[1].bound.typeArguments[0];
|
||||
checkParamTypeRef(typeArgument, 2);
|
||||
}
|
||||
|
||||
test_executable_type_param_f_bound_method() {
|
||||
UnlinkedExecutable ex =
|
||||
serializeMethodText('void f<T, U extends List<T>>() {}');
|
||||
UnlinkedTypeRef typeArgument = ex.typeParameters[1].bound.typeArguments[0];
|
||||
TypeRef typeArgument = ex.typeParameters[1].bound.typeArguments[0];
|
||||
checkParamTypeRef(typeArgument, 2);
|
||||
}
|
||||
|
||||
test_executable_type_param_f_bound_self_ref_function() {
|
||||
UnlinkedExecutable ex =
|
||||
serializeExecutableText('void f<T, U extends List<U>>() {}');
|
||||
UnlinkedTypeRef typeArgument = ex.typeParameters[1].bound.typeArguments[0];
|
||||
TypeRef typeArgument = ex.typeParameters[1].bound.typeArguments[0];
|
||||
checkParamTypeRef(typeArgument, 1);
|
||||
}
|
||||
|
||||
test_executable_type_param_f_bound_self_ref_method() {
|
||||
UnlinkedExecutable ex =
|
||||
serializeMethodText('void f<T, U extends List<U>>() {}');
|
||||
UnlinkedTypeRef typeArgument = ex.typeParameters[1].bound.typeArguments[0];
|
||||
TypeRef typeArgument = ex.typeParameters[1].bound.typeArguments[0];
|
||||
checkParamTypeRef(typeArgument, 1);
|
||||
}
|
||||
|
||||
@@ -3343,8 +3332,7 @@ p.B b;
|
||||
return;
|
||||
}
|
||||
checkUnresolvedTypeRef(
|
||||
serializeClassText('class C<T> { T.U x; }', allowErrors: true)
|
||||
.fields[0]
|
||||
serializeClassText('class C<T> { T.U x; }', allowErrors: true).fields[0]
|
||||
.type,
|
||||
'T',
|
||||
'U');
|
||||
@@ -3478,7 +3466,7 @@ void set f(value) {}''';
|
||||
}
|
||||
|
||||
test_type_arguments_explicit() {
|
||||
UnlinkedTypeRef typeRef = serializeTypeText('List<int>');
|
||||
TypeRef typeRef = serializeTypeText('List<int>');
|
||||
checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List',
|
||||
allowTypeParameters: true, numTypeParameters: 1);
|
||||
expect(typeRef.typeArguments, hasLength(1));
|
||||
@@ -3486,14 +3474,14 @@ void set f(value) {}''';
|
||||
}
|
||||
|
||||
test_type_arguments_explicit_dynamic() {
|
||||
UnlinkedTypeRef typeRef = serializeTypeText('List<dynamic>');
|
||||
TypeRef typeRef = serializeTypeText('List<dynamic>');
|
||||
checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List',
|
||||
allowTypeParameters: true, numTypeParameters: 1);
|
||||
expect(typeRef.typeArguments, isEmpty);
|
||||
}
|
||||
|
||||
test_type_arguments_explicit_dynamic_dynamic() {
|
||||
UnlinkedTypeRef typeRef = serializeTypeText('Map<dynamic, dynamic>');
|
||||
TypeRef typeRef = serializeTypeText('Map<dynamic, dynamic>');
|
||||
checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map',
|
||||
allowTypeParameters: true, numTypeParameters: 2);
|
||||
// Trailing type arguments of type `dynamic` are omitted.
|
||||
@@ -3501,7 +3489,7 @@ void set f(value) {}''';
|
||||
}
|
||||
|
||||
test_type_arguments_explicit_dynamic_int() {
|
||||
UnlinkedTypeRef typeRef = serializeTypeText('Map<dynamic, int>');
|
||||
TypeRef typeRef = serializeTypeText('Map<dynamic, int>');
|
||||
checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map',
|
||||
allowTypeParameters: true, numTypeParameters: 2);
|
||||
// Leading type arguments of type `dynamic` are not omitted.
|
||||
@@ -3511,7 +3499,7 @@ void set f(value) {}''';
|
||||
}
|
||||
|
||||
test_type_arguments_explicit_dynamic_typedef() {
|
||||
UnlinkedTypeRef typeRef =
|
||||
TypeRef typeRef =
|
||||
serializeTypeText('F<dynamic>', otherDeclarations: 'typedef T F<T>();');
|
||||
checkTypeRef(typeRef, null, null, 'F',
|
||||
allowTypeParameters: true,
|
||||
@@ -3521,7 +3509,7 @@ void set f(value) {}''';
|
||||
}
|
||||
|
||||
test_type_arguments_explicit_String_dynamic() {
|
||||
UnlinkedTypeRef typeRef = serializeTypeText('Map<String, dynamic>');
|
||||
TypeRef typeRef = serializeTypeText('Map<String, dynamic>');
|
||||
checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map',
|
||||
allowTypeParameters: true, numTypeParameters: 2);
|
||||
// Trailing type arguments of type `dynamic` are omitted.
|
||||
@@ -3530,7 +3518,7 @@ void set f(value) {}''';
|
||||
}
|
||||
|
||||
test_type_arguments_explicit_String_int() {
|
||||
UnlinkedTypeRef typeRef = serializeTypeText('Map<String, int>');
|
||||
TypeRef typeRef = serializeTypeText('Map<String, int>');
|
||||
checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map',
|
||||
allowTypeParameters: true, numTypeParameters: 2);
|
||||
expect(typeRef.typeArguments.length, 2);
|
||||
@@ -3539,7 +3527,7 @@ void set f(value) {}''';
|
||||
}
|
||||
|
||||
test_type_arguments_explicit_typedef() {
|
||||
UnlinkedTypeRef typeRef =
|
||||
TypeRef typeRef =
|
||||
serializeTypeText('F<int>', otherDeclarations: 'typedef T F<T>();');
|
||||
checkTypeRef(typeRef, null, null, 'F',
|
||||
allowTypeParameters: true,
|
||||
@@ -3550,14 +3538,14 @@ void set f(value) {}''';
|
||||
}
|
||||
|
||||
test_type_arguments_implicit() {
|
||||
UnlinkedTypeRef typeRef = serializeTypeText('List');
|
||||
TypeRef typeRef = serializeTypeText('List');
|
||||
checkTypeRef(typeRef, 'dart:core', 'dart:core', 'List',
|
||||
allowTypeParameters: true, numTypeParameters: 1);
|
||||
expect(typeRef.typeArguments, isEmpty);
|
||||
}
|
||||
|
||||
test_type_arguments_implicit_typedef() {
|
||||
UnlinkedTypeRef typeRef =
|
||||
TypeRef typeRef =
|
||||
serializeTypeText('F', otherDeclarations: 'typedef T F<T>();');
|
||||
checkTypeRef(typeRef, null, null, 'F',
|
||||
allowTypeParameters: true,
|
||||
@@ -3567,7 +3555,7 @@ void set f(value) {}''';
|
||||
}
|
||||
|
||||
test_type_arguments_order() {
|
||||
UnlinkedTypeRef typeRef = serializeTypeText('Map<int, Object>');
|
||||
TypeRef typeRef = serializeTypeText('Map<int, Object>');
|
||||
checkTypeRef(typeRef, 'dart:core', 'dart:core', 'Map',
|
||||
allowTypeParameters: true, numTypeParameters: 2);
|
||||
expect(typeRef.typeArguments, hasLength(2));
|
||||
@@ -3678,12 +3666,12 @@ void set f(value) {}''';
|
||||
test_type_reference_to_class_argument() {
|
||||
UnlinkedClass cls = serializeClassText('class C<T, U> { T t; U u; }');
|
||||
{
|
||||
UnlinkedTypeRef typeRef =
|
||||
TypeRef typeRef =
|
||||
findVariable('t', variables: cls.fields, failIfAbsent: true).type;
|
||||
checkParamTypeRef(typeRef, 2);
|
||||
}
|
||||
{
|
||||
UnlinkedTypeRef typeRef =
|
||||
TypeRef typeRef =
|
||||
findVariable('u', variables: cls.fields, failIfAbsent: true).type;
|
||||
checkParamTypeRef(typeRef, 1);
|
||||
}
|
||||
@@ -3770,7 +3758,7 @@ void set f(value) {}''';
|
||||
return;
|
||||
}
|
||||
allowMissingFiles = true;
|
||||
UnlinkedTypeRef typeRef = serializeTypeText('p.C',
|
||||
TypeRef typeRef = serializeTypeText('p.C',
|
||||
otherDeclarations: 'import "foo.dart" as p;', allowErrors: true);
|
||||
checkUnresolvedTypeRef(typeRef, 'p', 'C');
|
||||
}
|
||||
@@ -3823,7 +3811,7 @@ b.C c4;''');
|
||||
addNamedSource('/a.dart', 'library a; part "b.dart"; part "c.dart";');
|
||||
addNamedSource('/b.dart', 'part of a;');
|
||||
addNamedSource('/c.dart', 'part of a; class C {}');
|
||||
UnlinkedTypeRef typeRef =
|
||||
TypeRef typeRef =
|
||||
serializeTypeText('C', otherDeclarations: 'import "a.dart";');
|
||||
// The referenced unit should be 2, since unit 0 is a.dart and unit 1 is
|
||||
// b.dart. a.dart and b.dart are counted even though nothing is imported
|
||||
@@ -3833,7 +3821,7 @@ b.C c4;''');
|
||||
}
|
||||
|
||||
test_type_unresolved() {
|
||||
UnlinkedTypeRef typeRef = serializeTypeText('Foo', allowErrors: true);
|
||||
TypeRef typeRef = serializeTypeText('Foo', allowErrors: true);
|
||||
checkUnresolvedTypeRef(typeRef, null, 'Foo');
|
||||
}
|
||||
|
||||
@@ -3879,7 +3867,7 @@ typedef F();''';
|
||||
}
|
||||
|
||||
test_typedef_reference_generic() {
|
||||
UnlinkedTypeRef typeRef =
|
||||
TypeRef typeRef =
|
||||
serializeTypeText('F', otherDeclarations: 'typedef void F<A, B>();');
|
||||
checkTypeRef(typeRef, null, null, 'F',
|
||||
numTypeParameters: 2, expectedKind: ReferenceKind.typedef);
|
||||
@@ -3887,7 +3875,7 @@ typedef F();''';
|
||||
|
||||
test_typedef_reference_generic_imported() {
|
||||
addNamedSource('/lib.dart', 'typedef void F<A, B>();');
|
||||
UnlinkedTypeRef typeRef =
|
||||
TypeRef typeRef =
|
||||
serializeTypeText('F', otherDeclarations: 'import "lib.dart";');
|
||||
checkTypeRef(typeRef, absUri('/lib.dart'), 'lib.dart', 'F',
|
||||
numTypeParameters: 2, expectedKind: ReferenceKind.typedef);
|
||||
@@ -4035,8 +4023,8 @@ var v;''';
|
||||
List<int> ints: const <int>[],
|
||||
List<double> doubles: const <double>[],
|
||||
List<String> strings: const <String>[],
|
||||
List<_UnlinkedTypeRefValidator> referenceValidators:
|
||||
const <_UnlinkedTypeRefValidator>[]}) {
|
||||
List<_TypeRefValidator> referenceValidators:
|
||||
const <_TypeRefValidator>[]}) {
|
||||
expect(constExpr, isNotNull);
|
||||
expect(constExpr.operations, operators);
|
||||
expect(constExpr.ints, ints);
|
||||
|
||||
@@ -264,6 +264,50 @@ class SdkBundle {
|
||||
List<UnlinkedUnit> unlinkedUnits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary information about a reference to a type.
|
||||
*/
|
||||
class TypeRef {
|
||||
/**
|
||||
* Index into [UnlinkedUnit.references] for the type being referred to, or
|
||||
* zero if this is a reference to a type parameter.
|
||||
*
|
||||
* Note that since zero is also a valid index into
|
||||
* [UnlinkedUnit.references], we cannot distinguish between references to
|
||||
* type parameters and references to types by checking [reference] against
|
||||
* zero. To distinguish between references to type parameters and references
|
||||
* to types, check whether [paramReference] is zero.
|
||||
*/
|
||||
int reference;
|
||||
|
||||
/**
|
||||
* If this is a reference to a type parameter, one-based index into the list
|
||||
* of [UnlinkedTypeParam]s currently in effect. Indexing is done using De
|
||||
* Bruijn index conventions; that is, innermost parameters come first, and
|
||||
* if a class or method has multiple parameters, they are indexed from right
|
||||
* to left. So for instance, if the enclosing declaration is
|
||||
*
|
||||
* class C<T,U> {
|
||||
* m<V,W> {
|
||||
* ...
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* Then [paramReference] values of 1, 2, 3, and 4 represent W, V, U, and T,
|
||||
* respectively.
|
||||
*
|
||||
* If the type being referred to is not a type parameter, [paramReference] is
|
||||
* zero.
|
||||
*/
|
||||
int paramReference;
|
||||
|
||||
/**
|
||||
* If this is an instantiation of a generic type, the type arguments used to
|
||||
* instantiate it. Trailing type arguments of type `dynamic` are omitted.
|
||||
*/
|
||||
List<TypeRef> typeArguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlinked summary information about a class declaration.
|
||||
*/
|
||||
@@ -296,17 +340,17 @@ class UnlinkedClass {
|
||||
* explicitly declare a supertype (and hence has supertype `Object`), or (b)
|
||||
* the class *is* `Object` (and hence has no supertype).
|
||||
*/
|
||||
UnlinkedTypeRef supertype;
|
||||
TypeRef supertype;
|
||||
|
||||
/**
|
||||
* Mixins appearing in a `with` clause, if any.
|
||||
*/
|
||||
List<UnlinkedTypeRef> mixins;
|
||||
List<TypeRef> mixins;
|
||||
|
||||
/**
|
||||
* Interfaces appearing in an `implements` clause, if any.
|
||||
*/
|
||||
List<UnlinkedTypeRef> interfaces;
|
||||
List<TypeRef> interfaces;
|
||||
|
||||
/**
|
||||
* Field declarations contained in the class.
|
||||
@@ -392,7 +436,7 @@ class UnlinkedConst {
|
||||
* that in the case of `pushReference` (and sometimes `invokeConstructor` the
|
||||
* actual entity being referred to may be something other than a type.
|
||||
*/
|
||||
List<UnlinkedTypeRef> references;
|
||||
List<TypeRef> references;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -779,7 +823,7 @@ class UnlinkedExecutable {
|
||||
* `void` or the executable is a constructor. Note that when strong mode is
|
||||
* enabled, the actual return type may be different due to type inference.
|
||||
*/
|
||||
UnlinkedTypeRef returnType;
|
||||
TypeRef returnType;
|
||||
|
||||
/**
|
||||
* Parameters of the executable, if any. Note that getters have no
|
||||
@@ -980,7 +1024,7 @@ class UnlinkedParam {
|
||||
* that when strong mode is enabled, the actual type may be different due to
|
||||
* type inference.
|
||||
*/
|
||||
UnlinkedTypeRef type;
|
||||
TypeRef type;
|
||||
|
||||
/**
|
||||
* If [isFunctionTyped] is `true`, the parameters of the function type.
|
||||
@@ -1159,7 +1203,7 @@ class UnlinkedTypedef {
|
||||
/**
|
||||
* Return type of the typedef. Absent if the return type is `void`.
|
||||
*/
|
||||
UnlinkedTypeRef returnType;
|
||||
TypeRef returnType;
|
||||
|
||||
/**
|
||||
* Parameters of the executable, if any.
|
||||
@@ -1186,51 +1230,7 @@ class UnlinkedTypeParam {
|
||||
* Bound of the type parameter, if a bound is explicitly declared. Otherwise
|
||||
* null.
|
||||
*/
|
||||
UnlinkedTypeRef bound;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlinked summary information about a reference to a type.
|
||||
*/
|
||||
class UnlinkedTypeRef {
|
||||
/**
|
||||
* Index into [UnlinkedUnit.references] for the type being referred to, or
|
||||
* zero if this is a reference to a type parameter.
|
||||
*
|
||||
* Note that since zero is also a valid index into
|
||||
* [UnlinkedUnit.references], we cannot distinguish between references to
|
||||
* type parameters and references to types by checking [reference] against
|
||||
* zero. To distinguish between references to type parameters and references
|
||||
* to types, check whether [paramReference] is zero.
|
||||
*/
|
||||
int reference;
|
||||
|
||||
/**
|
||||
* If this is a reference to a type parameter, one-based index into the list
|
||||
* of [UnlinkedTypeParam]s currently in effect. Indexing is done using De
|
||||
* Bruijn index conventions; that is, innermost parameters come first, and
|
||||
* if a class or method has multiple parameters, they are indexed from right
|
||||
* to left. So for instance, if the enclosing declaration is
|
||||
*
|
||||
* class C<T,U> {
|
||||
* m<V,W> {
|
||||
* ...
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* Then [paramReference] values of 1, 2, 3, and 4 represent W, V, U, and T,
|
||||
* respectively.
|
||||
*
|
||||
* If the type being referred to is not a type parameter, [paramReference] is
|
||||
* zero.
|
||||
*/
|
||||
int paramReference;
|
||||
|
||||
/**
|
||||
* If this is an instantiation of a generic type, the type arguments used to
|
||||
* instantiate it. Trailing type arguments of type `dynamic` are omitted.
|
||||
*/
|
||||
List<UnlinkedTypeRef> typeArguments;
|
||||
TypeRef bound;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1345,7 +1345,7 @@ class UnlinkedVariable {
|
||||
* Declared type of the variable. Note that when strong mode is enabled, the
|
||||
* actual type of the variable may be different due to type inference.
|
||||
*/
|
||||
UnlinkedTypeRef type;
|
||||
TypeRef type;
|
||||
|
||||
/**
|
||||
* If [isConst] is true, and the variable has an initializer, the constant
|
||||
|
||||
Reference in New Issue
Block a user