Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(832)

Unified Diff: pkg/analyzer/lib/src/summary/format.dart

Issue 2719353002: First cut at idl changes (Closed)
Patch Set: line length Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/format.fbs » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/format.dart
diff --git a/pkg/analyzer/lib/src/summary/format.dart b/pkg/analyzer/lib/src/summary/format.dart
index c86b37cf40df476580d132ffdb34cdb76e7afd58..8771170c01b9c6e262053450d61e09404c185227 100644
--- a/pkg/analyzer/lib/src/summary/format.dart
+++ b/pkg/analyzer/lib/src/summary/format.dart
@@ -64,6 +64,19 @@ class _ReferenceKindReader extends fb.Reader<idl.ReferenceKind> {
}
}
+class _TypedefStyleReader extends fb.Reader<idl.TypedefStyle> {
+ const _TypedefStyleReader() : super();
+
+ @override
+ int get size => 1;
+
+ @override
+ idl.TypedefStyle read(fb.BufferContext bc, int offset) {
+ int index = const fb.Uint8Reader().read(bc, offset);
+ return index < idl.TypedefStyle.values.length ? idl.TypedefStyle.values[index] : idl.TypedefStyle.functionType;
+ }
+}
+
class _UnlinkedConstructorInitializerKindReader extends fb.Reader<idl.UnlinkedConstructorInitializerKind> {
const _UnlinkedConstructorInitializerKindReader() : super();
@@ -1795,6 +1808,7 @@ class EntityRefBuilder extends Object with _EntityRefMixin implements idl.Entity
List<UnlinkedParamBuilder> _syntheticParams;
EntityRefBuilder _syntheticReturnType;
List<EntityRefBuilder> _typeArguments;
+ List<UnlinkedTypeParamBuilder> _typeParameters;
@override
List<int> get implicitFunctionTypeIndices => _implicitFunctionTypeIndices ??= <int>[];
@@ -1917,14 +1931,26 @@ class EntityRefBuilder extends Object with _EntityRefMixin implements idl.Entity
this._typeArguments = value;
}
- EntityRefBuilder({List<int> implicitFunctionTypeIndices, int paramReference, int reference, int slot, List<UnlinkedParamBuilder> syntheticParams, EntityRefBuilder syntheticReturnType, List<EntityRefBuilder> typeArguments})
+ @override
+ List<UnlinkedTypeParamBuilder> get typeParameters => _typeParameters ??= <UnlinkedTypeParamBuilder>[];
+
+ /**
+ * If this is a function type, the type parameters defined for the function
+ * type (if any).
+ */
+ void set typeParameters(List<UnlinkedTypeParamBuilder> value) {
+ this._typeParameters = value;
+ }
+
+ EntityRefBuilder({List<int> implicitFunctionTypeIndices, int paramReference, int reference, int slot, List<UnlinkedParamBuilder> syntheticParams, EntityRefBuilder syntheticReturnType, List<EntityRefBuilder> typeArguments, List<UnlinkedTypeParamBuilder> typeParameters})
: _implicitFunctionTypeIndices = implicitFunctionTypeIndices,
_paramReference = paramReference,
_reference = reference,
_slot = slot,
_syntheticParams = syntheticParams,
_syntheticReturnType = syntheticReturnType,
- _typeArguments = typeArguments;
+ _typeArguments = typeArguments,
+ _typeParameters = typeParameters;
/**
* Flush [informative] data recursively.
@@ -1933,6 +1959,7 @@ class EntityRefBuilder extends Object with _EntityRefMixin implements idl.Entity
_syntheticParams?.forEach((b) => b.flushInformative());
_syntheticReturnType?.flushInformative();
_typeArguments?.forEach((b) => b.flushInformative());
+ _typeParameters?.forEach((b) => b.flushInformative());
}
/**
@@ -1968,6 +1995,14 @@ class EntityRefBuilder extends Object with _EntityRefMixin implements idl.Entity
x?.collectApiSignature(signature);
}
}
+ if (this._typeParameters == null) {
+ signature.addInt(0);
+ } else {
+ signature.addInt(this._typeParameters.length);
+ for (var x in this._typeParameters) {
+ x?.collectApiSignature(signature);
+ }
+ }
}
fb.Offset finish(fb.Builder fbBuilder) {
@@ -1975,6 +2010,7 @@ class EntityRefBuilder extends Object with _EntityRefMixin implements idl.Entity
fb.Offset offset_syntheticParams;
fb.Offset offset_syntheticReturnType;
fb.Offset offset_typeArguments;
+ fb.Offset offset_typeParameters;
if (!(_implicitFunctionTypeIndices == null || _implicitFunctionTypeIndices.isEmpty)) {
offset_implicitFunctionTypeIndices = fbBuilder.writeListUint32(_implicitFunctionTypeIndices);
}
@@ -1987,6 +2023,9 @@ class EntityRefBuilder extends Object with _EntityRefMixin implements idl.Entity
if (!(_typeArguments == null || _typeArguments.isEmpty)) {
offset_typeArguments = fbBuilder.writeList(_typeArguments.map((b) => b.finish(fbBuilder)).toList());
}
+ if (!(_typeParameters == null || _typeParameters.isEmpty)) {
+ offset_typeParameters = fbBuilder.writeList(_typeParameters.map((b) => b.finish(fbBuilder)).toList());
+ }
fbBuilder.startTable();
if (offset_implicitFunctionTypeIndices != null) {
fbBuilder.addOffset(4, offset_implicitFunctionTypeIndices);
@@ -2009,6 +2048,9 @@ class EntityRefBuilder extends Object with _EntityRefMixin implements idl.Entity
if (offset_typeArguments != null) {
fbBuilder.addOffset(1, offset_typeArguments);
}
+ if (offset_typeParameters != null) {
+ fbBuilder.addOffset(7, offset_typeParameters);
+ }
return fbBuilder.endTable();
}
}
@@ -2033,6 +2075,7 @@ class _EntityRefImpl extends Object with _EntityRefMixin implements idl.EntityRe
List<idl.UnlinkedParam> _syntheticParams;
idl.EntityRef _syntheticReturnType;
List<idl.EntityRef> _typeArguments;
+ List<idl.UnlinkedTypeParam> _typeParameters;
@override
List<int> get implicitFunctionTypeIndices {
@@ -2075,6 +2118,12 @@ class _EntityRefImpl extends Object with _EntityRefMixin implements idl.EntityRe
_typeArguments ??= const fb.ListReader<idl.EntityRef>(const _EntityRefReader()).vTableGet(_bc, _bcOffset, 1, const <idl.EntityRef>[]);
return _typeArguments;
}
+
+ @override
+ List<idl.UnlinkedTypeParam> get typeParameters {
+ _typeParameters ??= const fb.ListReader<idl.UnlinkedTypeParam>(const _UnlinkedTypeParamReader()).vTableGet(_bc, _bcOffset, 7, const <idl.UnlinkedTypeParam>[]);
+ return _typeParameters;
+ }
}
abstract class _EntityRefMixin implements idl.EntityRef {
@@ -2088,6 +2137,7 @@ abstract class _EntityRefMixin implements idl.EntityRef {
if (syntheticParams.isNotEmpty) _result["syntheticParams"] = syntheticParams.map((_value) => _value.toJson()).toList();
if (syntheticReturnType != null) _result["syntheticReturnType"] = syntheticReturnType.toJson();
if (typeArguments.isNotEmpty) _result["typeArguments"] = typeArguments.map((_value) => _value.toJson()).toList();
+ if (typeParameters.isNotEmpty) _result["typeParameters"] = typeParameters.map((_value) => _value.toJson()).toList();
return _result;
}
@@ -2100,6 +2150,7 @@ abstract class _EntityRefMixin implements idl.EntityRef {
"syntheticParams": syntheticParams,
"syntheticReturnType": syntheticReturnType,
"typeArguments": typeArguments,
+ "typeParameters": typeParameters,
};
@override
@@ -3748,8 +3799,8 @@ class PackageIndexBuilder extends Object with _PackageIndexMixin implements idl.
/**
* Each item of this list corresponds to a unique referenced element. It is
- * the identifier of the class member element name, or `null` if the element is
- * a top-level element. The list is sorted in ascending order, so that the
+ * the identifier of the class member element name, or `null` if the element
+ * is a top-level element. The list is sorted in ascending order, so that the
* client can quickly check whether an element is referenced in this
* [PackageIndex].
*/
@@ -8371,8 +8422,8 @@ class UnlinkedParamBuilder extends Object with _UnlinkedParamMixin implements id
UnlinkedExecutableBuilder get initializer => _initializer;
/**
- * The synthetic initializer function of the parameter. Absent if the variable
- * does not have an initializer.
+ * The synthetic initializer function of the parameter. Absent if the
+ * variable does not have an initializer.
*/
void set initializer(UnlinkedExecutableBuilder value) {
this._initializer = value;
@@ -8402,7 +8453,14 @@ class UnlinkedParamBuilder extends Object with _UnlinkedParamMixin implements id
bool get isFunctionTyped => _isFunctionTyped ??= false;
/**
- * Indicates whether this is a function-typed parameter.
+ * Indicates whether this is a function-typed parameter. A parameter is
+ * function-typed if the declaration of the parameter has explicit formal
+ * parameters
+ * ```
+ * int functionTyped(int p)
+ * ```
+ * but is not function-typed if it does not, even if the type of the parameter
+ * is a function type.
*/
void set isFunctionTyped(bool value) {
this._isFunctionTyped = value;
@@ -9445,6 +9503,7 @@ class UnlinkedTypedefBuilder extends Object with _UnlinkedTypedefMixin implement
int _nameOffset;
List<UnlinkedParamBuilder> _parameters;
EntityRefBuilder _returnType;
+ idl.TypedefStyle _style;
List<UnlinkedTypeParamBuilder> _typeParameters;
@override
@@ -9513,13 +9572,25 @@ class UnlinkedTypedefBuilder extends Object with _UnlinkedTypedefMixin implement
EntityRefBuilder get returnType => _returnType;
/**
- * Return type of the typedef.
+ * If [style] is [TypedefStyle.functionType], the return type of the typedef.
+ * If [style] is [TypedefStyle.genericFunctionType], the function type being
+ * defined.
*/
void set returnType(EntityRefBuilder value) {
this._returnType = value;
}
@override
+ idl.TypedefStyle get style => _style ??= idl.TypedefStyle.functionType;
+
+ /**
+ * The style of the typedef.
+ */
+ void set style(idl.TypedefStyle value) {
+ this._style = value;
+ }
+
+ @override
List<UnlinkedTypeParamBuilder> get typeParameters => _typeParameters ??= <UnlinkedTypeParamBuilder>[];
/**
@@ -9529,7 +9600,7 @@ class UnlinkedTypedefBuilder extends Object with _UnlinkedTypedefMixin implement
this._typeParameters = value;
}
- UnlinkedTypedefBuilder({List<UnlinkedExprBuilder> annotations, CodeRangeBuilder codeRange, UnlinkedDocumentationCommentBuilder documentationComment, String name, int nameOffset, List<UnlinkedParamBuilder> parameters, EntityRefBuilder returnType, List<UnlinkedTypeParamBuilder> typeParameters})
+ UnlinkedTypedefBuilder({List<UnlinkedExprBuilder> annotations, CodeRangeBuilder codeRange, UnlinkedDocumentationCommentBuilder documentationComment, String name, int nameOffset, List<UnlinkedParamBuilder> parameters, EntityRefBuilder returnType, idl.TypedefStyle style, List<UnlinkedTypeParamBuilder> typeParameters})
: _annotations = annotations,
_codeRange = codeRange,
_documentationComment = documentationComment,
@@ -9537,6 +9608,7 @@ class UnlinkedTypedefBuilder extends Object with _UnlinkedTypedefMixin implement
_nameOffset = nameOffset,
_parameters = parameters,
_returnType = returnType,
+ _style = style,
_typeParameters = typeParameters;
/**
@@ -9583,6 +9655,7 @@ class UnlinkedTypedefBuilder extends Object with _UnlinkedTypedefMixin implement
x?.collectApiSignature(signature);
}
}
+ signature.addInt(this._style == null ? 0 : this._style.index);
}
fb.Offset finish(fb.Builder fbBuilder) {
@@ -9636,6 +9709,9 @@ class UnlinkedTypedefBuilder extends Object with _UnlinkedTypedefMixin implement
if (offset_returnType != null) {
fbBuilder.addOffset(2, offset_returnType);
}
+ if (_style != null && _style != idl.TypedefStyle.functionType) {
+ fbBuilder.addUint8(8, _style.index);
+ }
if (offset_typeParameters != null) {
fbBuilder.addOffset(5, offset_typeParameters);
}
@@ -9663,6 +9739,7 @@ class _UnlinkedTypedefImpl extends Object with _UnlinkedTypedefMixin implements
int _nameOffset;
List<idl.UnlinkedParam> _parameters;
idl.EntityRef _returnType;
+ idl.TypedefStyle _style;
List<idl.UnlinkedTypeParam> _typeParameters;
@override
@@ -9708,6 +9785,12 @@ class _UnlinkedTypedefImpl extends Object with _UnlinkedTypedefMixin implements
}
@override
+ idl.TypedefStyle get style {
+ _style ??= const _TypedefStyleReader().vTableGet(_bc, _bcOffset, 8, idl.TypedefStyle.functionType);
+ return _style;
+ }
+
+ @override
List<idl.UnlinkedTypeParam> get typeParameters {
_typeParameters ??= const fb.ListReader<idl.UnlinkedTypeParam>(const _UnlinkedTypeParamReader()).vTableGet(_bc, _bcOffset, 5, const <idl.UnlinkedTypeParam>[]);
return _typeParameters;
@@ -9725,6 +9808,7 @@ abstract class _UnlinkedTypedefMixin implements idl.UnlinkedTypedef {
if (nameOffset != 0) _result["nameOffset"] = nameOffset;
if (parameters.isNotEmpty) _result["parameters"] = parameters.map((_value) => _value.toJson()).toList();
if (returnType != null) _result["returnType"] = returnType.toJson();
+ if (style != idl.TypedefStyle.functionType) _result["style"] = style.toString().split('.')[1];
if (typeParameters.isNotEmpty) _result["typeParameters"] = typeParameters.map((_value) => _value.toJson()).toList();
return _result;
}
@@ -9738,6 +9822,7 @@ abstract class _UnlinkedTypedefMixin implements idl.UnlinkedTypedef {
"nameOffset": nameOffset,
"parameters": parameters,
"returnType": returnType,
+ "style": style,
"typeParameters": typeParameters,
};
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/format.fbs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698