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

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

Issue 2013883003: Migrate UnlinkedVariable.constExpr to UnlinkedExecutable.bodyExpr. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix a comment Created 4 years, 7 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 d16a522b24785e01687528c7255a4ee37418e75b..7a60450b378a2ad17bdadad3e9d7b043130ee710 100644
--- a/pkg/analyzer/lib/src/summary/format.dart
+++ b/pkg/analyzer/lib/src/summary/format.dart
@@ -3550,35 +3550,35 @@ abstract class _UnlinkedConstMixin implements idl.UnlinkedConst {
class UnlinkedConstructorInitializerBuilder extends Object with _UnlinkedConstructorInitializerMixin implements idl.UnlinkedConstructorInitializer {
bool _finished = false;
- List<UnlinkedConstBuilder> _arguments;
List<String> _argumentNames;
+ List<UnlinkedConstBuilder> _arguments;
UnlinkedConstBuilder _expression;
idl.UnlinkedConstructorInitializerKind _kind;
String _name;
@override
- List<UnlinkedConstBuilder> get arguments => _arguments ??= <UnlinkedConstBuilder>[];
+ List<String> get argumentNames => _argumentNames ??= <String>[];
/**
- * If [kind] is `thisInvocation` or `superInvocation`, the arguments of the
- * invocation. Otherwise empty.
+ * If there are `m` [arguments] and `n` [argumentNames], then each argument
+ * from [arguments] with index `i` such that `n + i - m >= 0`, should be used
+ * with the name at `n + i - m`.
*/
- void set arguments(List<UnlinkedConstBuilder> _value) {
+ void set argumentNames(List<String> _value) {
assert(!_finished);
- _arguments = _value;
+ _argumentNames = _value;
}
@override
- List<String> get argumentNames => _argumentNames ??= <String>[];
+ List<UnlinkedConstBuilder> get arguments => _arguments ??= <UnlinkedConstBuilder>[];
/**
- * If there are `m` [arguments] and `n` [argumentNames], then each argument
- * from [arguments] with index `i` such that `n + i - m >= 0`, should be used
- * with the name at `n + i - m`.
+ * If [kind] is `thisInvocation` or `superInvocation`, the arguments of the
+ * invocation. Otherwise empty.
*/
- void set argumentNames(List<String> _value) {
+ void set arguments(List<UnlinkedConstBuilder> _value) {
assert(!_finished);
- _argumentNames = _value;
+ _arguments = _value;
}
@override
@@ -3618,9 +3618,9 @@ class UnlinkedConstructorInitializerBuilder extends Object with _UnlinkedConstru
_name = _value;
}
- UnlinkedConstructorInitializerBuilder({List<UnlinkedConstBuilder> arguments, List<String> argumentNames, UnlinkedConstBuilder expression, idl.UnlinkedConstructorInitializerKind kind, String name})
- : _arguments = arguments,
- _argumentNames = argumentNames,
+ UnlinkedConstructorInitializerBuilder({List<String> argumentNames, List<UnlinkedConstBuilder> arguments, UnlinkedConstBuilder expression, idl.UnlinkedConstructorInitializerKind kind, String name})
+ : _argumentNames = argumentNames,
+ _arguments = arguments,
_expression = expression,
_kind = kind,
_name = name;
@@ -3636,16 +3636,16 @@ class UnlinkedConstructorInitializerBuilder extends Object with _UnlinkedConstru
fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- fb.Offset offset_arguments;
fb.Offset offset_argumentNames;
+ fb.Offset offset_arguments;
fb.Offset offset_expression;
fb.Offset offset_name;
- if (!(_arguments == null || _arguments.isEmpty)) {
- offset_arguments = fbBuilder.writeList(_arguments.map((b) => b.finish(fbBuilder)).toList());
- }
if (!(_argumentNames == null || _argumentNames.isEmpty)) {
offset_argumentNames = fbBuilder.writeList(_argumentNames.map((b) => fbBuilder.writeString(b)).toList());
}
+ if (!(_arguments == null || _arguments.isEmpty)) {
+ offset_arguments = fbBuilder.writeList(_arguments.map((b) => b.finish(fbBuilder)).toList());
+ }
if (_expression != null) {
offset_expression = _expression.finish(fbBuilder);
}
@@ -3653,12 +3653,12 @@ class UnlinkedConstructorInitializerBuilder extends Object with _UnlinkedConstru
offset_name = fbBuilder.writeString(_name);
}
fbBuilder.startTable();
- if (offset_arguments != null) {
- fbBuilder.addOffset(3, offset_arguments);
- }
if (offset_argumentNames != null) {
fbBuilder.addOffset(4, offset_argumentNames);
}
+ if (offset_arguments != null) {
+ fbBuilder.addOffset(3, offset_arguments);
+ }
if (offset_expression != null) {
fbBuilder.addOffset(1, offset_expression);
}
@@ -3685,25 +3685,25 @@ class _UnlinkedConstructorInitializerImpl extends Object with _UnlinkedConstruct
_UnlinkedConstructorInitializerImpl(this._bc, this._bcOffset);
- List<idl.UnlinkedConst> _arguments;
List<String> _argumentNames;
+ List<idl.UnlinkedConst> _arguments;
idl.UnlinkedConst _expression;
idl.UnlinkedConstructorInitializerKind _kind;
String _name;
@override
- List<idl.UnlinkedConst> get arguments {
- _arguments ??= const fb.ListReader<idl.UnlinkedConst>(const _UnlinkedConstReader()).vTableGet(_bc, _bcOffset, 3, const <idl.UnlinkedConst>[]);
- return _arguments;
- }
-
- @override
List<String> get argumentNames {
_argumentNames ??= const fb.ListReader<String>(const fb.StringReader()).vTableGet(_bc, _bcOffset, 4, const <String>[]);
return _argumentNames;
}
@override
+ List<idl.UnlinkedConst> get arguments {
+ _arguments ??= const fb.ListReader<idl.UnlinkedConst>(const _UnlinkedConstReader()).vTableGet(_bc, _bcOffset, 3, const <idl.UnlinkedConst>[]);
+ return _arguments;
+ }
+
+ @override
idl.UnlinkedConst get expression {
_expression ??= const _UnlinkedConstReader().vTableGet(_bc, _bcOffset, 1, null);
return _expression;
@@ -3726,8 +3726,8 @@ abstract class _UnlinkedConstructorInitializerMixin implements idl.UnlinkedConst
@override
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
- if (arguments.isNotEmpty) _result["arguments"] = arguments.map((_value) => _value.toJson()).toList();
if (argumentNames.isNotEmpty) _result["argumentNames"] = argumentNames;
+ if (arguments.isNotEmpty) _result["arguments"] = arguments.map((_value) => _value.toJson()).toList();
if (expression != null) _result["expression"] = expression.toJson();
if (kind != idl.UnlinkedConstructorInitializerKind.field) _result["kind"] = kind.toString().split('.')[1];
if (name != '') _result["name"] = name;
@@ -3736,8 +3736,8 @@ abstract class _UnlinkedConstructorInitializerMixin implements idl.UnlinkedConst
@override
Map<String, Object> toMap() => {
- "arguments": arguments,
"argumentNames": argumentNames,
+ "arguments": arguments,
"expression": expression,
"kind": kind,
"name": name,
@@ -4250,6 +4250,7 @@ class UnlinkedExecutableBuilder extends Object with _UnlinkedExecutableMixin imp
bool _finished = false;
List<UnlinkedConstBuilder> _annotations;
+ UnlinkedConstBuilder _bodyExpr;
CodeRangeBuilder _codeRange;
List<UnlinkedConstructorInitializerBuilder> _constantInitializers;
int _constCycleSlot;
@@ -4291,6 +4292,19 @@ class UnlinkedExecutableBuilder extends Object with _UnlinkedExecutableMixin imp
}
@override
+ UnlinkedConstBuilder get bodyExpr => _bodyExpr;
+
+ /**
+ * If this executable's function body is declared using `=>`, the expression
+ * to the right of the `=>`. May be omitted if neither type inference nor
+ * constant evaluation depends on the function body.
+ */
+ void set bodyExpr(UnlinkedConstBuilder _value) {
+ assert(!_finished);
+ _bodyExpr = _value;
+ }
+
+ @override
CodeRangeBuilder get codeRange => _codeRange;
/**
@@ -4638,8 +4652,9 @@ class UnlinkedExecutableBuilder extends Object with _UnlinkedExecutableMixin imp
_visibleOffset = _value;
}
- UnlinkedExecutableBuilder({List<UnlinkedConstBuilder> annotations, CodeRangeBuilder codeRange, List<UnlinkedConstructorInitializerBuilder> constantInitializers, int constCycleSlot, UnlinkedDocumentationCommentBuilder documentationComment, int inferredReturnTypeSlot, bool isAbstract, bool isAsynchronous, bool isConst, bool isExternal, bool isFactory, bool isGenerator, bool isRedirectedConstructor, bool isStatic, idl.UnlinkedExecutableKind kind, List<UnlinkedExecutableBuilder> localFunctions, List<UnlinkedLabelBuilder> localLabels, List<UnlinkedVariableBuilder> localVariables, String name, int nameEnd, int nameOffset, List<UnlinkedParamBuilder> parameters, int periodOffset, EntityRefBuilder redirectedConstructor, String redirectedConstructorName, EntityRefBuilder returnType, List<UnlinkedTypeParamBuilder> typeParameters, int visibleLength, int visibleOffset})
+ UnlinkedExecutableBuilder({List<UnlinkedConstBuilder> annotations, UnlinkedConstBuilder bodyExpr, CodeRangeBuilder codeRange, List<UnlinkedConstructorInitializerBuilder> constantInitializers, int constCycleSlot, UnlinkedDocumentationCommentBuilder documentationComment, int inferredReturnTypeSlot, bool isAbstract, bool isAsynchronous, bool isConst, bool isExternal, bool isFactory, bool isGenerator, bool isRedirectedConstructor, bool isStatic, idl.UnlinkedExecutableKind kind, List<UnlinkedExecutableBuilder> localFunctions, List<UnlinkedLabelBuilder> localLabels, List<UnlinkedVariableBuilder> localVariables, String name, int nameEnd, int nameOffset, List<UnlinkedParamBuilder> parameters, int periodOffset, EntityRefBuilder redirectedConstructor, String redirectedConstructorName, EntityRefBuilder returnType, List<UnlinkedTypeParamBuilder> typeParameters, int visibleLength, int visibleOffset})
: _annotations = annotations,
+ _bodyExpr = bodyExpr,
_codeRange = codeRange,
_constantInitializers = constantInitializers,
_constCycleSlot = constCycleSlot,
@@ -4674,6 +4689,7 @@ class UnlinkedExecutableBuilder extends Object with _UnlinkedExecutableMixin imp
*/
void flushInformative() {
_annotations?.forEach((b) => b.flushInformative());
+ _bodyExpr?.flushInformative();
_codeRange = null;
_constantInitializers?.forEach((b) => b.flushInformative());
_documentationComment = null;
@@ -4695,6 +4711,7 @@ class UnlinkedExecutableBuilder extends Object with _UnlinkedExecutableMixin imp
assert(!_finished);
_finished = true;
fb.Offset offset_annotations;
+ fb.Offset offset_bodyExpr;
fb.Offset offset_codeRange;
fb.Offset offset_constantInitializers;
fb.Offset offset_documentationComment;
@@ -4710,6 +4727,9 @@ class UnlinkedExecutableBuilder extends Object with _UnlinkedExecutableMixin imp
if (!(_annotations == null || _annotations.isEmpty)) {
offset_annotations = fbBuilder.writeList(_annotations.map((b) => b.finish(fbBuilder)).toList());
}
+ if (_bodyExpr != null) {
+ offset_bodyExpr = _bodyExpr.finish(fbBuilder);
+ }
if (_codeRange != null) {
offset_codeRange = _codeRange.finish(fbBuilder);
}
@@ -4750,6 +4770,9 @@ class UnlinkedExecutableBuilder extends Object with _UnlinkedExecutableMixin imp
if (offset_annotations != null) {
fbBuilder.addOffset(6, offset_annotations);
}
+ if (offset_bodyExpr != null) {
+ fbBuilder.addOffset(29, offset_bodyExpr);
+ }
if (offset_codeRange != null) {
fbBuilder.addOffset(26, offset_codeRange);
}
@@ -4852,6 +4875,7 @@ class _UnlinkedExecutableImpl extends Object with _UnlinkedExecutableMixin imple
_UnlinkedExecutableImpl(this._bc, this._bcOffset);
List<idl.UnlinkedConst> _annotations;
+ idl.UnlinkedConst _bodyExpr;
idl.CodeRange _codeRange;
List<idl.UnlinkedConstructorInitializer> _constantInitializers;
int _constCycleSlot;
@@ -4888,6 +4912,12 @@ class _UnlinkedExecutableImpl extends Object with _UnlinkedExecutableMixin imple
}
@override
+ idl.UnlinkedConst get bodyExpr {
+ _bodyExpr ??= const _UnlinkedConstReader().vTableGet(_bc, _bcOffset, 29, null);
+ return _bodyExpr;
+ }
+
+ @override
idl.CodeRange get codeRange {
_codeRange ??= const _CodeRangeReader().vTableGet(_bc, _bcOffset, 26, null);
return _codeRange;
@@ -5061,6 +5091,7 @@ abstract class _UnlinkedExecutableMixin implements idl.UnlinkedExecutable {
Map<String, Object> toJson() {
Map<String, Object> _result = <String, Object>{};
if (annotations.isNotEmpty) _result["annotations"] = annotations.map((_value) => _value.toJson()).toList();
+ if (bodyExpr != null) _result["bodyExpr"] = bodyExpr.toJson();
if (codeRange != null) _result["codeRange"] = codeRange.toJson();
if (constantInitializers.isNotEmpty) _result["constantInitializers"] = constantInitializers.map((_value) => _value.toJson()).toList();
if (constCycleSlot != 0) _result["constCycleSlot"] = constCycleSlot;
@@ -5095,6 +5126,7 @@ abstract class _UnlinkedExecutableMixin implements idl.UnlinkedExecutable {
@override
Map<String, Object> toMap() => {
"annotations": annotations,
+ "bodyExpr": bodyExpr,
"codeRange": codeRange,
"constantInitializers": constantInitializers,
"constCycleSlot": constCycleSlot,
@@ -8002,7 +8034,6 @@ class UnlinkedVariableBuilder extends Object with _UnlinkedVariableMixin impleme
List<UnlinkedConstBuilder> _annotations;
CodeRangeBuilder _codeRange;
- UnlinkedConstBuilder _constExpr;
UnlinkedDocumentationCommentBuilder _documentationComment;
int _inferredTypeSlot;
UnlinkedExecutableBuilder _initializer;
@@ -8039,19 +8070,6 @@ class UnlinkedVariableBuilder extends Object with _UnlinkedVariableMixin impleme
}
@override
- UnlinkedConstBuilder get constExpr => _constExpr;
-
- /**
- * If [isConst] is true, and the variable has an initializer, the constant
- * expression in the initializer. Note that the presence of this expression
- * does not mean that it is a valid, check [UnlinkedConst.isInvalid].
- */
- void set constExpr(UnlinkedConstBuilder _value) {
- assert(!_finished);
- _constExpr = _value;
- }
-
- @override
UnlinkedDocumentationCommentBuilder get documentationComment => _documentationComment;
/**
@@ -8202,10 +8220,9 @@ class UnlinkedVariableBuilder extends Object with _UnlinkedVariableMixin impleme
_visibleOffset = _value;
}
- UnlinkedVariableBuilder({List<UnlinkedConstBuilder> annotations, CodeRangeBuilder codeRange, UnlinkedConstBuilder constExpr, UnlinkedDocumentationCommentBuilder documentationComment, int inferredTypeSlot, UnlinkedExecutableBuilder initializer, bool isConst, bool isFinal, bool isStatic, String name, int nameOffset, int propagatedTypeSlot, EntityRefBuilder type, int visibleLength, int visibleOffset})
+ UnlinkedVariableBuilder({List<UnlinkedConstBuilder> annotations, CodeRangeBuilder codeRange, UnlinkedDocumentationCommentBuilder documentationComment, int inferredTypeSlot, UnlinkedExecutableBuilder initializer, bool isConst, bool isFinal, bool isStatic, String name, int nameOffset, int propagatedTypeSlot, EntityRefBuilder type, int visibleLength, int visibleOffset})
: _annotations = annotations,
_codeRange = codeRange,
- _constExpr = constExpr,
_documentationComment = documentationComment,
_inferredTypeSlot = inferredTypeSlot,
_initializer = initializer,
@@ -8225,7 +8242,6 @@ class UnlinkedVariableBuilder extends Object with _UnlinkedVariableMixin impleme
void flushInformative() {
_annotations?.forEach((b) => b.flushInformative());
_codeRange = null;
- _constExpr?.flushInformative();
_documentationComment = null;
_initializer?.flushInformative();
_nameOffset = null;
@@ -8237,7 +8253,6 @@ class UnlinkedVariableBuilder extends Object with _UnlinkedVariableMixin impleme
_finished = true;
fb.Offset offset_annotations;
fb.Offset offset_codeRange;
- fb.Offset offset_constExpr;
fb.Offset offset_documentationComment;
fb.Offset offset_initializer;
fb.Offset offset_name;
@@ -8248,9 +8263,6 @@ class UnlinkedVariableBuilder extends Object with _UnlinkedVariableMixin impleme
if (_codeRange != null) {
offset_codeRange = _codeRange.finish(fbBuilder);
}
- if (_constExpr != null) {
- offset_constExpr = _constExpr.finish(fbBuilder);
- }
if (_documentationComment != null) {
offset_documentationComment = _documentationComment.finish(fbBuilder);
}
@@ -8268,10 +8280,7 @@ class UnlinkedVariableBuilder extends Object with _UnlinkedVariableMixin impleme
fbBuilder.addOffset(8, offset_annotations);
}
if (offset_codeRange != null) {
- fbBuilder.addOffset(14, offset_codeRange);
- }
- if (offset_constExpr != null) {
- fbBuilder.addOffset(5, offset_constExpr);
+ fbBuilder.addOffset(5, offset_codeRange);
}
if (offset_documentationComment != null) {
fbBuilder.addOffset(10, offset_documentationComment);
@@ -8328,7 +8337,6 @@ class _UnlinkedVariableImpl extends Object with _UnlinkedVariableMixin implement
List<idl.UnlinkedConst> _annotations;
idl.CodeRange _codeRange;
- idl.UnlinkedConst _constExpr;
idl.UnlinkedDocumentationComment _documentationComment;
int _inferredTypeSlot;
idl.UnlinkedExecutable _initializer;
@@ -8350,17 +8358,11 @@ class _UnlinkedVariableImpl extends Object with _UnlinkedVariableMixin implement
@override
idl.CodeRange get codeRange {
- _codeRange ??= const _CodeRangeReader().vTableGet(_bc, _bcOffset, 14, null);
+ _codeRange ??= const _CodeRangeReader().vTableGet(_bc, _bcOffset, 5, null);
return _codeRange;
}
@override
- idl.UnlinkedConst get constExpr {
- _constExpr ??= const _UnlinkedConstReader().vTableGet(_bc, _bcOffset, 5, null);
- return _constExpr;
- }
-
- @override
idl.UnlinkedDocumentationComment get documentationComment {
_documentationComment ??= const _UnlinkedDocumentationCommentReader().vTableGet(_bc, _bcOffset, 10, null);
return _documentationComment;
@@ -8439,7 +8441,6 @@ abstract class _UnlinkedVariableMixin implements idl.UnlinkedVariable {
Map<String, Object> _result = <String, Object>{};
if (annotations.isNotEmpty) _result["annotations"] = annotations.map((_value) => _value.toJson()).toList();
if (codeRange != null) _result["codeRange"] = codeRange.toJson();
- if (constExpr != null) _result["constExpr"] = constExpr.toJson();
if (documentationComment != null) _result["documentationComment"] = documentationComment.toJson();
if (inferredTypeSlot != 0) _result["inferredTypeSlot"] = inferredTypeSlot;
if (initializer != null) _result["initializer"] = initializer.toJson();
@@ -8459,7 +8460,6 @@ abstract class _UnlinkedVariableMixin implements idl.UnlinkedVariable {
Map<String, Object> toMap() => {
"annotations": annotations,
"codeRange": codeRange,
- "constExpr": constExpr,
"documentationComment": documentationComment,
"inferredTypeSlot": inferredTypeSlot,
"initializer": initializer,
« 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