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

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

Issue 1576663002: Use FlatBuffers for summaries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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/test/src/summary/summary_test.dart » ('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 eee3081549a313bbc0cfeb68e766e78917a02f89..04f171dfe9dbdf0c3db2a1198272b3ec50616b65 100644
--- a/pkg/analyzer/lib/src/summary/format.dart
+++ b/pkg/analyzer/lib/src/summary/format.dart
@@ -7,8 +7,8 @@
library analyzer.src.summary.format;
-import 'dart:convert';
import 'base.dart' as base;
+import 'flat_buffers.dart' as fb;
/**
* Enum used to indicate the kind of entity referred to by a
@@ -41,32 +41,13 @@ enum UnlinkedParamKind {
named,
}
-/**
- * Information about a dependency that exists between one library and another
- * due to an "import" declaration.
- */
-class PrelinkedDependency extends base.SummaryClass {
- String _uri;
-
- PrelinkedDependency.fromJson(Map json)
- : _uri = json["uri"];
-
- @override
- Map<String, Object> toMap() => {
- "uri": uri,
- };
-
- /**
- * The relative URI used to import one library from the other.
- */
- String get uri => _uri ?? '';
-}
-
class PrelinkedDependencyBuilder {
- final Map _json = {};
-
bool _finished = false;
+ String _uri;
+
+ bool _uriIsSet = false;
Paul Berry 2016/01/09 14:57:41 Personally I would remove booleans like these (and
scheglov 2016/01/09 18:55:33 Done.
+
PrelinkedDependencyBuilder(base.BuilderContext context);
/**
@@ -74,16 +55,23 @@ class PrelinkedDependencyBuilder {
*/
void set uri(String _value) {
assert(!_finished);
- assert(!_json.containsKey("uri"));
- if (_value != null) {
- _json["uri"] = _value;
- }
+ assert(!_uriIsSet);
+ _uriIsSet = true;
+ _uri = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_uri;
+ if (_uri != null) {
+ offset_uri = fbBuilder.writeString(_uri);
+ }
+ fbBuilder.startTable();
+ if (offset_uri != null) {
+ fbBuilder.addOffset(0, offset_uri);
+ }
+ return fbBuilder.endTable();
}
}
@@ -94,61 +82,43 @@ PrelinkedDependencyBuilder encodePrelinkedDependency(base.BuilderContext builder
}
/**
- * Pre-linked summary of a library.
+ * Information about a dependency that exists between one library and another
+ * due to an "import" declaration.
*/
-class PrelinkedLibrary extends base.SummaryClass {
- List<PrelinkedUnit> _units;
- List<PrelinkedDependency> _dependencies;
- List<int> _importDependencies;
+abstract class PrelinkedDependency extends base.SummaryClass {
- PrelinkedLibrary.fromJson(Map json)
- : _units = json["units"]?.map((x) => new PrelinkedUnit.fromJson(x))?.toList(),
- _dependencies = json["dependencies"]?.map((x) => new PrelinkedDependency.fromJson(x))?.toList(),
- _importDependencies = json["importDependencies"];
+ /**
+ * The relative URI used to import one library from the other.
+ */
+ String get uri;
+}
- @override
- Map<String, Object> toMap() => {
- "units": units,
- "dependencies": dependencies,
- "importDependencies": importDependencies,
- };
+class _PrelinkedDependencyReader extends fb.TableReader<_PrelinkedDependencyReader> implements PrelinkedDependency {
+ final fb.BufferPointer _bp;
- PrelinkedLibrary.fromBuffer(List<int> buffer) : this.fromJson(JSON.decode(UTF8.decode(buffer)));
+ const _PrelinkedDependencyReader([this._bp]);
- /**
- * The pre-linked summary of all the compilation units constituting the
- * library. The summary of the defining compilation unit is listed first,
- * followed by the summary of each part, in the order of the `part`
- * declarations in the defining compilation unit.
- */
- List<PrelinkedUnit> get units => _units ?? const <PrelinkedUnit>[];
+ @override
+ _PrelinkedDependencyReader createReader(fb.BufferPointer bp) => new _PrelinkedDependencyReader(bp);
- /**
- * The libraries that this library depends on (either via an explicit import
- * statement or via the implicit dependencies on `dart:core` and
- * `dart:async`). The first element of this array is a pseudo-dependency
- * representing the library itself (it is also used for "dynamic").
- *
- * TODO(paulberry): consider removing this entirely and just using
- * [UnlinkedLibrary.imports].
- */
- List<PrelinkedDependency> get dependencies => _dependencies ?? const <PrelinkedDependency>[];
+ @override
+ Map<String, Object> toMap() => {};
Paul Berry 2016/01/09 14:57:41 Looks like generation of this method got broken by
scheglov 2016/01/09 18:55:33 Done.
- /**
- * For each import in [UnlinkedUnit.imports], an index into [dependencies]
- * of the library being imported.
- *
- * TODO(paulberry): if [dependencies] is removed, this can be removed as
- * well, since there will effectively be a one-to-one mapping.
- */
- List<int> get importDependencies => _importDependencies ?? const <int>[];
+ @override
+ String get uri => const fb.StringReader().vTableGet(_bp, 0, '');
}
class PrelinkedLibraryBuilder {
- final Map _json = {};
-
bool _finished = false;
+ List<PrelinkedUnitBuilder> _units;
+ List<PrelinkedDependencyBuilder> _dependencies;
+ List<int> _importDependencies;
+
+ bool _unitsIsSet = false;
+ bool _dependenciesIsSet = false;
+ bool _importDependenciesIsSet = false;
+
PrelinkedLibraryBuilder(base.BuilderContext context);
/**
@@ -159,10 +129,9 @@ class PrelinkedLibraryBuilder {
*/
void set units(List<PrelinkedUnitBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("units"));
- if (!(_value == null || _value.isEmpty)) {
- _json["units"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_unitsIsSet);
+ _unitsIsSet = true;
+ _units = _value;
}
/**
@@ -176,10 +145,9 @@ class PrelinkedLibraryBuilder {
*/
void set dependencies(List<PrelinkedDependencyBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("dependencies"));
- if (!(_value == null || _value.isEmpty)) {
- _json["dependencies"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_dependenciesIsSet);
+ _dependenciesIsSet = true;
+ _dependencies = _value;
}
/**
@@ -191,18 +159,42 @@ class PrelinkedLibraryBuilder {
*/
void set importDependencies(List<int> _value) {
assert(!_finished);
- assert(!_json.containsKey("importDependencies"));
- if (!(_value == null || _value.isEmpty)) {
- _json["importDependencies"] = _value.toList();
- }
+ assert(!_importDependenciesIsSet);
+ _importDependenciesIsSet = true;
+ _importDependencies = _value;
}
- List<int> toBuffer() => UTF8.encode(JSON.encode(finish()));
+ List<int> toBuffer() {
+ fb.Builder fbBuilder = new fb.Builder();
+ return fbBuilder.finish(finish(fbBuilder));
+ }
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_units;
+ fb.Offset offset_dependencies;
+ fb.Offset offset_importDependencies;
+ if (!(_units == null || _units.isEmpty)) {
+ offset_units = fbBuilder.writeList(_units.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (!(_dependencies == null || _dependencies.isEmpty)) {
+ offset_dependencies = fbBuilder.writeList(_dependencies.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (!(_importDependencies == null || _importDependencies.isEmpty)) {
+ offset_importDependencies = fbBuilder.writeListInt32(_importDependencies);
+ }
+ fbBuilder.startTable();
+ if (offset_units != null) {
+ fbBuilder.addOffset(0, offset_units);
+ }
+ if (offset_dependencies != null) {
+ fbBuilder.addOffset(1, offset_dependencies);
+ }
+ if (offset_importDependencies != null) {
+ fbBuilder.addOffset(2, offset_importDependencies);
+ }
+ return fbBuilder.endTable();
}
}
@@ -215,60 +207,77 @@ PrelinkedLibraryBuilder encodePrelinkedLibrary(base.BuilderContext builderContex
}
/**
- * Information about the resolution of an [UnlinkedReference].
+ * Pre-linked summary of a library.
*/
-class PrelinkedReference extends base.SummaryClass {
- int _dependency;
- PrelinkedReferenceKind _kind;
- int _unit;
- int _numTypeParameters;
-
- PrelinkedReference.fromJson(Map json)
- : _dependency = json["dependency"],
- _kind = json["kind"] == null ? null : PrelinkedReferenceKind.values[json["kind"]],
- _unit = json["unit"],
- _numTypeParameters = json["numTypeParameters"];
-
- @override
- Map<String, Object> toMap() => {
- "dependency": dependency,
- "kind": kind,
- "unit": unit,
- "numTypeParameters": numTypeParameters,
- };
+abstract class PrelinkedLibrary extends base.SummaryClass {
+ factory PrelinkedLibrary.fromBuffer(List<int> buffer) {
+ fb.BufferPointer rootRef = new fb.BufferPointer.fromBytes(buffer);
+ return const _PrelinkedLibraryReader().read(rootRef);
+ }
/**
- * Index into [PrelinkedLibrary.dependencies] indicating which imported library
- * declares the entity being referred to.
+ * The pre-linked summary of all the compilation units constituting the
+ * library. The summary of the defining compilation unit is listed first,
+ * followed by the summary of each part, in the order of the `part`
+ * declarations in the defining compilation unit.
*/
- int get dependency => _dependency ?? 0;
+ List<PrelinkedUnit> get units;
/**
- * The kind of the entity being referred to. For the pseudo-type `dynamic`,
- * the kind is [PrelinkedReferenceKind.classOrEnum].
+ * The libraries that this library depends on (either via an explicit import
+ * statement or via the implicit dependencies on `dart:core` and
+ * `dart:async`). The first element of this array is a pseudo-dependency
+ * representing the library itself (it is also used for "dynamic").
+ *
+ * TODO(paulberry): consider removing this entirely and just using
+ * [UnlinkedLibrary.imports].
*/
- PrelinkedReferenceKind get kind => _kind ?? PrelinkedReferenceKind.classOrEnum;
+ List<PrelinkedDependency> get dependencies;
/**
- * Integer index indicating which unit in the imported library contains the
- * definition of the entity. As with indices into [PrelinkedLibrary.units],
- * zero represents the defining compilation unit, and nonzero values
- * represent parts in the order of the corresponding `part` declarations.
+ * For each import in [UnlinkedUnit.imports], an index into [dependencies]
+ * of the library being imported.
+ *
+ * TODO(paulberry): if [dependencies] is removed, this can be removed as
+ * well, since there will effectively be a one-to-one mapping.
*/
- int get unit => _unit ?? 0;
+ List<int> get importDependencies;
+}
- /**
- * If the entity being referred to is generic, the number of type parameters
- * it accepts. Otherwise zero.
- */
- int get numTypeParameters => _numTypeParameters ?? 0;
+class _PrelinkedLibraryReader extends fb.TableReader<_PrelinkedLibraryReader> implements PrelinkedLibrary {
+ final fb.BufferPointer _bp;
+
+ const _PrelinkedLibraryReader([this._bp]);
+
+ @override
+ _PrelinkedLibraryReader createReader(fb.BufferPointer bp) => new _PrelinkedLibraryReader(bp);
+
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ List<PrelinkedUnit> get units => const fb.ListReader<PrelinkedUnit>(const _PrelinkedUnitReader()).vTableGet(_bp, 0, const <PrelinkedUnit>[]);
+
+ @override
+ List<PrelinkedDependency> get dependencies => const fb.ListReader<PrelinkedDependency>(const _PrelinkedDependencyReader()).vTableGet(_bp, 1, const <PrelinkedDependency>[]);
+
+ @override
+ List<int> get importDependencies => const fb.ListReader<int>(const fb.Int32Reader()).vTableGet(_bp, 2, const <int>[]);
}
class PrelinkedReferenceBuilder {
- final Map _json = {};
-
bool _finished = false;
+ int _dependency;
+ PrelinkedReferenceKind _kind;
+ int _unit;
+ int _numTypeParameters;
+
+ bool _dependencyIsSet = false;
+ bool _kindIsSet = false;
+ bool _unitIsSet = false;
+ bool _numTypeParametersIsSet = false;
+
PrelinkedReferenceBuilder(base.BuilderContext context);
/**
@@ -277,10 +286,9 @@ class PrelinkedReferenceBuilder {
*/
void set dependency(int _value) {
assert(!_finished);
- assert(!_json.containsKey("dependency"));
- if (_value != null) {
- _json["dependency"] = _value;
- }
+ assert(!_dependencyIsSet);
+ _dependencyIsSet = true;
+ _dependency = _value;
}
/**
@@ -289,10 +297,9 @@ class PrelinkedReferenceBuilder {
*/
void set kind(PrelinkedReferenceKind _value) {
assert(!_finished);
- assert(!_json.containsKey("kind"));
- if (!(_value == null || _value == PrelinkedReferenceKind.classOrEnum)) {
- _json["kind"] = _value.index;
- }
+ assert(!_kindIsSet);
+ _kindIsSet = true;
+ _kind = _value;
}
/**
@@ -303,10 +310,9 @@ class PrelinkedReferenceBuilder {
*/
void set unit(int _value) {
assert(!_finished);
- assert(!_json.containsKey("unit"));
- if (_value != null) {
- _json["unit"] = _value;
- }
+ assert(!_unitIsSet);
+ _unitIsSet = true;
+ _unit = _value;
}
/**
@@ -315,16 +321,28 @@ class PrelinkedReferenceBuilder {
*/
void set numTypeParameters(int _value) {
assert(!_finished);
- assert(!_json.containsKey("numTypeParameters"));
- if (_value != null) {
- _json["numTypeParameters"] = _value;
- }
+ assert(!_numTypeParametersIsSet);
+ _numTypeParametersIsSet = true;
+ _numTypeParameters = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fbBuilder.startTable();
+ if (_dependency != null && _dependency != 0) {
+ fbBuilder.addInt32(0, _dependency);
+ }
+ if (_kind != null && _kind != PrelinkedReferenceKind.classOrEnum) {
+ fbBuilder.addInt32(1, _kind.index);
+ }
+ if (_unit != null && _unit != 0) {
+ fbBuilder.addInt32(2, _unit);
+ }
+ if (_numTypeParameters != null && _numTypeParameters != 0) {
+ fbBuilder.addInt32(3, _numTypeParameters);
+ }
+ return fbBuilder.endTable();
}
}
@@ -338,31 +356,71 @@ PrelinkedReferenceBuilder encodePrelinkedReference(base.BuilderContext builderCo
}
/**
- * Pre-linked summary of a compilation unit.
+ * Information about the resolution of an [UnlinkedReference].
*/
-class PrelinkedUnit extends base.SummaryClass {
- List<PrelinkedReference> _references;
+abstract class PrelinkedReference extends base.SummaryClass {
- PrelinkedUnit.fromJson(Map json)
- : _references = json["references"]?.map((x) => new PrelinkedReference.fromJson(x))?.toList();
+ /**
+ * Index into [PrelinkedLibrary.dependencies] indicating which imported library
+ * declares the entity being referred to.
+ */
+ int get dependency;
- @override
- Map<String, Object> toMap() => {
- "references": references,
- };
+ /**
+ * The kind of the entity being referred to. For the pseudo-type `dynamic`,
+ * the kind is [PrelinkedReferenceKind.classOrEnum].
+ */
+ PrelinkedReferenceKind get kind;
/**
- * For each reference in [UnlinkedUnit.references], information about how
- * that reference is resolved.
+ * Integer index indicating which unit in the imported library contains the
+ * definition of the entity. As with indices into [PrelinkedLibrary.units],
+ * zero represents the defining compilation unit, and nonzero values
+ * represent parts in the order of the corresponding `part` declarations.
+ */
+ int get unit;
+
+ /**
+ * If the entity being referred to is generic, the number of type parameters
+ * it accepts. Otherwise zero.
*/
- List<PrelinkedReference> get references => _references ?? const <PrelinkedReference>[];
+ int get numTypeParameters;
}
-class PrelinkedUnitBuilder {
- final Map _json = {};
+class _PrelinkedReferenceReader extends fb.TableReader<_PrelinkedReferenceReader> implements PrelinkedReference {
+ final fb.BufferPointer _bp;
+
+ const _PrelinkedReferenceReader([this._bp]);
+
+ @override
+ _PrelinkedReferenceReader createReader(fb.BufferPointer bp) => new _PrelinkedReferenceReader(bp);
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ int get dependency => const fb.Int32Reader().vTableGet(_bp, 0, 0);
+
+ @override
+ PrelinkedReferenceKind get kind {
+ int index = const fb.Int32Reader().vTableGet(_bp, 1, 0);
+ return PrelinkedReferenceKind.values[index];
+ }
+
+ @override
+ int get unit => const fb.Int32Reader().vTableGet(_bp, 2, 0);
+
+ @override
+ int get numTypeParameters => const fb.Int32Reader().vTableGet(_bp, 3, 0);
+}
+
+class PrelinkedUnitBuilder {
bool _finished = false;
+ List<PrelinkedReferenceBuilder> _references;
+
+ bool _referencesIsSet = false;
+
PrelinkedUnitBuilder(base.BuilderContext context);
/**
@@ -371,16 +429,23 @@ class PrelinkedUnitBuilder {
*/
void set references(List<PrelinkedReferenceBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("references"));
- if (!(_value == null || _value.isEmpty)) {
- _json["references"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_referencesIsSet);
+ _referencesIsSet = true;
+ _references = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_references;
+ if (!(_references == null || _references.isEmpty)) {
+ offset_references = fbBuilder.writeList(_references.map((b) => b.finish(fbBuilder)).toList());
+ }
+ fbBuilder.startTable();
+ if (offset_references != null) {
+ fbBuilder.addOffset(0, offset_references);
+ }
+ return fbBuilder.endTable();
}
}
@@ -391,56 +456,45 @@ PrelinkedUnitBuilder encodePrelinkedUnit(base.BuilderContext builderContext, {Li
}
/**
- * Information about SDK.
+ * Pre-linked summary of a compilation unit.
*/
-class SdkBundle extends base.SummaryClass {
- List<String> _prelinkedLibraryUris;
- List<PrelinkedLibrary> _prelinkedLibraries;
- List<String> _unlinkedUnitUris;
- List<UnlinkedUnit> _unlinkedUnits;
-
- SdkBundle.fromJson(Map json)
- : _prelinkedLibraryUris = json["prelinkedLibraryUris"],
- _prelinkedLibraries = json["prelinkedLibraries"]?.map((x) => new PrelinkedLibrary.fromJson(x))?.toList(),
- _unlinkedUnitUris = json["unlinkedUnitUris"],
- _unlinkedUnits = json["unlinkedUnits"]?.map((x) => new UnlinkedUnit.fromJson(x))?.toList();
-
- @override
- Map<String, Object> toMap() => {
- "prelinkedLibraryUris": prelinkedLibraryUris,
- "prelinkedLibraries": prelinkedLibraries,
- "unlinkedUnitUris": unlinkedUnitUris,
- "unlinkedUnits": unlinkedUnits,
- };
-
- SdkBundle.fromBuffer(List<int> buffer) : this.fromJson(JSON.decode(UTF8.decode(buffer)));
+abstract class PrelinkedUnit extends base.SummaryClass {
/**
- * The list of URIs of items in [prelinkedLibraries], e.g. `dart:core`.
+ * For each reference in [UnlinkedUnit.references], information about how
+ * that reference is resolved.
*/
- List<String> get prelinkedLibraryUris => _prelinkedLibraryUris ?? const <String>[];
+ List<PrelinkedReference> get references;
+}
- /**
- * Pre-linked libraries.
- */
- List<PrelinkedLibrary> get prelinkedLibraries => _prelinkedLibraries ?? const <PrelinkedLibrary>[];
+class _PrelinkedUnitReader extends fb.TableReader<_PrelinkedUnitReader> implements PrelinkedUnit {
+ final fb.BufferPointer _bp;
- /**
- * The list of URIs of items in [unlinkedUnits], e.g. `dart:core/bool.dart`.
- */
- List<String> get unlinkedUnitUris => _unlinkedUnitUris ?? const <String>[];
+ const _PrelinkedUnitReader([this._bp]);
- /**
- * Unlinked information for the compilation units constituting the SDK.
- */
- List<UnlinkedUnit> get unlinkedUnits => _unlinkedUnits ?? const <UnlinkedUnit>[];
+ @override
+ _PrelinkedUnitReader createReader(fb.BufferPointer bp) => new _PrelinkedUnitReader(bp);
+
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ List<PrelinkedReference> get references => const fb.ListReader<PrelinkedReference>(const _PrelinkedReferenceReader()).vTableGet(_bp, 0, const <PrelinkedReference>[]);
}
class SdkBundleBuilder {
- final Map _json = {};
-
bool _finished = false;
+ List<String> _prelinkedLibraryUris;
+ List<PrelinkedLibraryBuilder> _prelinkedLibraries;
+ List<String> _unlinkedUnitUris;
+ List<UnlinkedUnitBuilder> _unlinkedUnits;
+
+ bool _prelinkedLibraryUrisIsSet = false;
+ bool _prelinkedLibrariesIsSet = false;
+ bool _unlinkedUnitUrisIsSet = false;
+ bool _unlinkedUnitsIsSet = false;
+
SdkBundleBuilder(base.BuilderContext context);
/**
@@ -448,10 +502,9 @@ class SdkBundleBuilder {
*/
void set prelinkedLibraryUris(List<String> _value) {
assert(!_finished);
- assert(!_json.containsKey("prelinkedLibraryUris"));
- if (!(_value == null || _value.isEmpty)) {
- _json["prelinkedLibraryUris"] = _value.toList();
- }
+ assert(!_prelinkedLibraryUrisIsSet);
+ _prelinkedLibraryUrisIsSet = true;
+ _prelinkedLibraryUris = _value;
}
/**
@@ -459,10 +512,9 @@ class SdkBundleBuilder {
*/
void set prelinkedLibraries(List<PrelinkedLibraryBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("prelinkedLibraries"));
- if (!(_value == null || _value.isEmpty)) {
- _json["prelinkedLibraries"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_prelinkedLibrariesIsSet);
+ _prelinkedLibrariesIsSet = true;
+ _prelinkedLibraries = _value;
}
/**
@@ -470,10 +522,9 @@ class SdkBundleBuilder {
*/
void set unlinkedUnitUris(List<String> _value) {
assert(!_finished);
- assert(!_json.containsKey("unlinkedUnitUris"));
- if (!(_value == null || _value.isEmpty)) {
- _json["unlinkedUnitUris"] = _value.toList();
- }
+ assert(!_unlinkedUnitUrisIsSet);
+ _unlinkedUnitUrisIsSet = true;
+ _unlinkedUnitUris = _value;
}
/**
@@ -481,18 +532,49 @@ class SdkBundleBuilder {
*/
void set unlinkedUnits(List<UnlinkedUnitBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("unlinkedUnits"));
- if (!(_value == null || _value.isEmpty)) {
- _json["unlinkedUnits"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_unlinkedUnitsIsSet);
+ _unlinkedUnitsIsSet = true;
+ _unlinkedUnits = _value;
}
- List<int> toBuffer() => UTF8.encode(JSON.encode(finish()));
+ List<int> toBuffer() {
+ fb.Builder fbBuilder = new fb.Builder();
+ return fbBuilder.finish(finish(fbBuilder));
+ }
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_prelinkedLibraryUris;
+ fb.Offset offset_prelinkedLibraries;
+ fb.Offset offset_unlinkedUnitUris;
+ fb.Offset offset_unlinkedUnits;
+ if (!(_prelinkedLibraryUris == null || _prelinkedLibraryUris.isEmpty)) {
+ offset_prelinkedLibraryUris = fbBuilder.writeList(_prelinkedLibraryUris.map((b) => fbBuilder.writeString(b)).toList());
+ }
+ if (!(_prelinkedLibraries == null || _prelinkedLibraries.isEmpty)) {
+ offset_prelinkedLibraries = fbBuilder.writeList(_prelinkedLibraries.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (!(_unlinkedUnitUris == null || _unlinkedUnitUris.isEmpty)) {
+ offset_unlinkedUnitUris = fbBuilder.writeList(_unlinkedUnitUris.map((b) => fbBuilder.writeString(b)).toList());
+ }
+ if (!(_unlinkedUnits == null || _unlinkedUnits.isEmpty)) {
+ offset_unlinkedUnits = fbBuilder.writeList(_unlinkedUnits.map((b) => b.finish(fbBuilder)).toList());
+ }
+ fbBuilder.startTable();
+ if (offset_prelinkedLibraryUris != null) {
+ fbBuilder.addOffset(0, offset_prelinkedLibraryUris);
+ }
+ if (offset_prelinkedLibraries != null) {
+ fbBuilder.addOffset(1, offset_prelinkedLibraries);
+ }
+ if (offset_unlinkedUnitUris != null) {
+ fbBuilder.addOffset(2, offset_unlinkedUnitUris);
+ }
+ if (offset_unlinkedUnits != null) {
+ fbBuilder.addOffset(3, offset_unlinkedUnits);
+ }
+ return fbBuilder.endTable();
}
}
@@ -506,122 +588,88 @@ SdkBundleBuilder encodeSdkBundle(base.BuilderContext builderContext, {List<Strin
}
/**
- * Unlinked summary information about a class declaration.
+ * Information about SDK.
*/
-class UnlinkedClass extends base.SummaryClass {
- String _name;
- int _nameOffset;
- UnlinkedDocumentationComment _documentationComment;
- List<UnlinkedTypeParam> _typeParameters;
- UnlinkedTypeRef _supertype;
- List<UnlinkedTypeRef> _mixins;
- List<UnlinkedTypeRef> _interfaces;
- List<UnlinkedVariable> _fields;
- List<UnlinkedExecutable> _executables;
- bool _isAbstract;
- bool _isMixinApplication;
- bool _hasNoSupertype;
-
- UnlinkedClass.fromJson(Map json)
- : _name = json["name"],
- _nameOffset = json["nameOffset"],
- _documentationComment = json["documentationComment"] == null ? null : new UnlinkedDocumentationComment.fromJson(json["documentationComment"]),
- _typeParameters = json["typeParameters"]?.map((x) => new UnlinkedTypeParam.fromJson(x))?.toList(),
- _supertype = json["supertype"] == null ? null : new UnlinkedTypeRef.fromJson(json["supertype"]),
- _mixins = json["mixins"]?.map((x) => new UnlinkedTypeRef.fromJson(x))?.toList(),
- _interfaces = json["interfaces"]?.map((x) => new UnlinkedTypeRef.fromJson(x))?.toList(),
- _fields = json["fields"]?.map((x) => new UnlinkedVariable.fromJson(x))?.toList(),
- _executables = json["executables"]?.map((x) => new UnlinkedExecutable.fromJson(x))?.toList(),
- _isAbstract = json["isAbstract"],
- _isMixinApplication = json["isMixinApplication"],
- _hasNoSupertype = json["hasNoSupertype"];
-
- @override
- Map<String, Object> toMap() => {
- "name": name,
- "nameOffset": nameOffset,
- "documentationComment": documentationComment,
- "typeParameters": typeParameters,
- "supertype": supertype,
- "mixins": mixins,
- "interfaces": interfaces,
- "fields": fields,
- "executables": executables,
- "isAbstract": isAbstract,
- "isMixinApplication": isMixinApplication,
- "hasNoSupertype": hasNoSupertype,
- };
+abstract class SdkBundle extends base.SummaryClass {
+ factory SdkBundle.fromBuffer(List<int> buffer) {
+ fb.BufferPointer rootRef = new fb.BufferPointer.fromBytes(buffer);
+ return const _SdkBundleReader().read(rootRef);
+ }
/**
- * Name of the class.
+ * The list of URIs of items in [prelinkedLibraries], e.g. `dart:core`.
*/
- String get name => _name ?? '';
+ List<String> get prelinkedLibraryUris;
/**
- * Offset of the class name relative to the beginning of the file.
+ * Pre-linked libraries.
*/
- int get nameOffset => _nameOffset ?? 0;
+ List<PrelinkedLibrary> get prelinkedLibraries;
/**
- * Documentation comment for the class, or `null` if there is no
- * documentation comment.
+ * The list of URIs of items in [unlinkedUnits], e.g. `dart:core/bool.dart`.
*/
- UnlinkedDocumentationComment get documentationComment => _documentationComment;
+ List<String> get unlinkedUnitUris;
/**
- * Type parameters of the class, if any.
+ * Unlinked information for the compilation units constituting the SDK.
*/
- List<UnlinkedTypeParam> get typeParameters => _typeParameters ?? const <UnlinkedTypeParam>[];
+ List<UnlinkedUnit> get unlinkedUnits;
+}
- /**
- * 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).
- */
- UnlinkedTypeRef get supertype => _supertype;
+class _SdkBundleReader extends fb.TableReader<_SdkBundleReader> implements SdkBundle {
+ final fb.BufferPointer _bp;
- /**
- * Mixins appearing in a `with` clause, if any.
- */
- List<UnlinkedTypeRef> get mixins => _mixins ?? const <UnlinkedTypeRef>[];
+ const _SdkBundleReader([this._bp]);
- /**
- * Interfaces appearing in an `implements` clause, if any.
- */
- List<UnlinkedTypeRef> get interfaces => _interfaces ?? const <UnlinkedTypeRef>[];
+ @override
+ _SdkBundleReader createReader(fb.BufferPointer bp) => new _SdkBundleReader(bp);
- /**
- * Field declarations contained in the class.
- */
- List<UnlinkedVariable> get fields => _fields ?? const <UnlinkedVariable>[];
+ @override
+ Map<String, Object> toMap() => {};
- /**
- * Executable objects (methods, getters, and setters) contained in the class.
- */
- List<UnlinkedExecutable> get executables => _executables ?? const <UnlinkedExecutable>[];
+ @override
+ List<String> get prelinkedLibraryUris => const fb.ListReader<String>(const fb.StringReader()).vTableGet(_bp, 0, const <String>[]);
- /**
- * Indicates whether the class is declared with the `abstract` keyword.
- */
- bool get isAbstract => _isAbstract ?? false;
+ @override
+ List<PrelinkedLibrary> get prelinkedLibraries => const fb.ListReader<PrelinkedLibrary>(const _PrelinkedLibraryReader()).vTableGet(_bp, 1, const <PrelinkedLibrary>[]);
- /**
- * Indicates whether the class is declared using mixin application syntax.
- */
- bool get isMixinApplication => _isMixinApplication ?? false;
+ @override
+ List<String> get unlinkedUnitUris => const fb.ListReader<String>(const fb.StringReader()).vTableGet(_bp, 2, const <String>[]);
- /**
- * Indicates whether this class is the core "Object" class (and hence has no
- * supertype)
- */
- bool get hasNoSupertype => _hasNoSupertype ?? false;
+ @override
+ List<UnlinkedUnit> get unlinkedUnits => const fb.ListReader<UnlinkedUnit>(const _UnlinkedUnitReader()).vTableGet(_bp, 3, const <UnlinkedUnit>[]);
}
class UnlinkedClassBuilder {
- final Map _json = {};
-
bool _finished = false;
+ 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;
+
+ bool _nameIsSet = false;
+ bool _nameOffsetIsSet = false;
+ bool _documentationCommentIsSet = false;
+ bool _typeParametersIsSet = false;
+ bool _supertypeIsSet = false;
+ bool _mixinsIsSet = false;
+ bool _interfacesIsSet = false;
+ bool _fieldsIsSet = false;
+ bool _executablesIsSet = false;
+ bool _isAbstractIsSet = false;
+ bool _isMixinApplicationIsSet = false;
+ bool _hasNoSupertypeIsSet = false;
+
UnlinkedClassBuilder(base.BuilderContext context);
/**
@@ -629,10 +677,9 @@ class UnlinkedClassBuilder {
*/
void set name(String _value) {
assert(!_finished);
- assert(!_json.containsKey("name"));
- if (_value != null) {
- _json["name"] = _value;
- }
+ assert(!_nameIsSet);
+ _nameIsSet = true;
+ _name = _value;
}
/**
@@ -640,10 +687,9 @@ class UnlinkedClassBuilder {
*/
void set nameOffset(int _value) {
assert(!_finished);
- assert(!_json.containsKey("nameOffset"));
- if (_value != null) {
- _json["nameOffset"] = _value;
- }
+ assert(!_nameOffsetIsSet);
+ _nameOffsetIsSet = true;
+ _nameOffset = _value;
}
/**
@@ -652,10 +698,9 @@ class UnlinkedClassBuilder {
*/
void set documentationComment(UnlinkedDocumentationCommentBuilder _value) {
assert(!_finished);
- assert(!_json.containsKey("documentationComment"));
- if (_value != null) {
- _json["documentationComment"] = _value.finish();
- }
+ assert(!_documentationCommentIsSet);
+ _documentationCommentIsSet = true;
+ _documentationComment = _value;
}
/**
@@ -663,10 +708,9 @@ class UnlinkedClassBuilder {
*/
void set typeParameters(List<UnlinkedTypeParamBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("typeParameters"));
- if (!(_value == null || _value.isEmpty)) {
- _json["typeParameters"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_typeParametersIsSet);
+ _typeParametersIsSet = true;
+ _typeParameters = _value;
}
/**
@@ -676,10 +720,9 @@ class UnlinkedClassBuilder {
*/
void set supertype(UnlinkedTypeRefBuilder _value) {
assert(!_finished);
- assert(!_json.containsKey("supertype"));
- if (_value != null) {
- _json["supertype"] = _value.finish();
- }
+ assert(!_supertypeIsSet);
+ _supertypeIsSet = true;
+ _supertype = _value;
}
/**
@@ -687,10 +730,9 @@ class UnlinkedClassBuilder {
*/
void set mixins(List<UnlinkedTypeRefBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("mixins"));
- if (!(_value == null || _value.isEmpty)) {
- _json["mixins"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_mixinsIsSet);
+ _mixinsIsSet = true;
+ _mixins = _value;
}
/**
@@ -698,10 +740,9 @@ class UnlinkedClassBuilder {
*/
void set interfaces(List<UnlinkedTypeRefBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("interfaces"));
- if (!(_value == null || _value.isEmpty)) {
- _json["interfaces"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_interfacesIsSet);
+ _interfacesIsSet = true;
+ _interfaces = _value;
}
/**
@@ -709,10 +750,9 @@ class UnlinkedClassBuilder {
*/
void set fields(List<UnlinkedVariableBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("fields"));
- if (!(_value == null || _value.isEmpty)) {
- _json["fields"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_fieldsIsSet);
+ _fieldsIsSet = true;
+ _fields = _value;
}
/**
@@ -720,10 +760,9 @@ class UnlinkedClassBuilder {
*/
void set executables(List<UnlinkedExecutableBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("executables"));
- if (!(_value == null || _value.isEmpty)) {
- _json["executables"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_executablesIsSet);
+ _executablesIsSet = true;
+ _executables = _value;
}
/**
@@ -731,10 +770,9 @@ class UnlinkedClassBuilder {
*/
void set isAbstract(bool _value) {
assert(!_finished);
- assert(!_json.containsKey("isAbstract"));
- if (_value != null) {
- _json["isAbstract"] = _value;
- }
+ assert(!_isAbstractIsSet);
+ _isAbstractIsSet = true;
+ _isAbstract = _value;
}
/**
@@ -742,10 +780,9 @@ class UnlinkedClassBuilder {
*/
void set isMixinApplication(bool _value) {
assert(!_finished);
- assert(!_json.containsKey("isMixinApplication"));
- if (_value != null) {
- _json["isMixinApplication"] = _value;
- }
+ assert(!_isMixinApplicationIsSet);
+ _isMixinApplicationIsSet = true;
+ _isMixinApplication = _value;
}
/**
@@ -754,16 +791,84 @@ class UnlinkedClassBuilder {
*/
void set hasNoSupertype(bool _value) {
assert(!_finished);
- assert(!_json.containsKey("hasNoSupertype"));
- if (_value != null) {
- _json["hasNoSupertype"] = _value;
- }
+ assert(!_hasNoSupertypeIsSet);
+ _hasNoSupertypeIsSet = true;
+ _hasNoSupertype = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_name;
+ fb.Offset offset_documentationComment;
+ fb.Offset offset_typeParameters;
+ fb.Offset offset_supertype;
+ fb.Offset offset_mixins;
+ fb.Offset offset_interfaces;
+ fb.Offset offset_fields;
+ fb.Offset offset_executables;
+ if (_name != null) {
+ offset_name = fbBuilder.writeString(_name);
+ }
+ if (_documentationComment != null) {
+ offset_documentationComment = _documentationComment.finish(fbBuilder);
+ }
+ if (!(_typeParameters == null || _typeParameters.isEmpty)) {
+ offset_typeParameters = fbBuilder.writeList(_typeParameters.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (_supertype != null) {
+ offset_supertype = _supertype.finish(fbBuilder);
+ }
+ if (!(_mixins == null || _mixins.isEmpty)) {
+ offset_mixins = fbBuilder.writeList(_mixins.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (!(_interfaces == null || _interfaces.isEmpty)) {
+ offset_interfaces = fbBuilder.writeList(_interfaces.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (!(_fields == null || _fields.isEmpty)) {
+ offset_fields = fbBuilder.writeList(_fields.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (!(_executables == null || _executables.isEmpty)) {
+ offset_executables = fbBuilder.writeList(_executables.map((b) => b.finish(fbBuilder)).toList());
+ }
+ fbBuilder.startTable();
+ if (offset_name != null) {
+ fbBuilder.addOffset(0, offset_name);
+ }
+ if (_nameOffset != null && _nameOffset != 0) {
+ fbBuilder.addInt32(1, _nameOffset);
+ }
+ if (offset_documentationComment != null) {
+ fbBuilder.addOffset(2, offset_documentationComment);
+ }
+ if (offset_typeParameters != null) {
+ fbBuilder.addOffset(3, offset_typeParameters);
+ }
+ if (offset_supertype != null) {
+ fbBuilder.addOffset(4, offset_supertype);
+ }
+ if (offset_mixins != null) {
+ fbBuilder.addOffset(5, offset_mixins);
+ }
+ if (offset_interfaces != null) {
+ fbBuilder.addOffset(6, offset_interfaces);
+ }
+ if (offset_fields != null) {
+ fbBuilder.addOffset(7, offset_fields);
+ }
+ if (offset_executables != null) {
+ fbBuilder.addOffset(8, offset_executables);
+ }
+ if (_isAbstract == true) {
+ fbBuilder.addInt8(9, 1);
+ }
+ if (_isMixinApplication == true) {
+ fbBuilder.addInt8(10, 1);
+ }
+ if (_hasNoSupertype == true) {
+ fbBuilder.addInt8(11, 1);
+ }
+ return fbBuilder.endTable();
}
}
@@ -785,39 +890,132 @@ UnlinkedClassBuilder encodeUnlinkedClass(base.BuilderContext builderContext, {St
}
/**
- * Unlinked summary information about a `show` or `hide` combinator in an
- * import or export declaration.
+ * Unlinked summary information about a class declaration.
*/
-class UnlinkedCombinator extends base.SummaryClass {
- List<String> _shows;
- List<String> _hides;
+abstract class UnlinkedClass extends base.SummaryClass {
+
+ /**
+ * Name of the class.
+ */
+ String get name;
- UnlinkedCombinator.fromJson(Map json)
- : _shows = json["shows"],
- _hides = json["hides"];
+ /**
+ * Offset of the class name relative to the beginning of the file.
+ */
+ int get nameOffset;
- @override
- Map<String, Object> toMap() => {
- "shows": shows,
- "hides": hides,
- };
+ /**
+ * Documentation comment for the class, or `null` if there is no
+ * documentation comment.
+ */
+ UnlinkedDocumentationComment get documentationComment;
/**
- * List of names which are shown. Empty if this is a `hide` combinator.
+ * Type parameters of the class, if any.
*/
- List<String> get shows => _shows ?? const <String>[];
+ List<UnlinkedTypeParam> get typeParameters;
/**
- * List of names which are hidden. Empty if this is a `show` combinator.
+ * 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).
+ */
+ UnlinkedTypeRef get supertype;
+
+ /**
+ * Mixins appearing in a `with` clause, if any.
+ */
+ List<UnlinkedTypeRef> get mixins;
+
+ /**
+ * Interfaces appearing in an `implements` clause, if any.
+ */
+ List<UnlinkedTypeRef> get interfaces;
+
+ /**
+ * Field declarations contained in the class.
+ */
+ List<UnlinkedVariable> get fields;
+
+ /**
+ * Executable objects (methods, getters, and setters) contained in the class.
+ */
+ List<UnlinkedExecutable> get executables;
+
+ /**
+ * Indicates whether the class is declared with the `abstract` keyword.
+ */
+ bool get isAbstract;
+
+ /**
+ * Indicates whether the class is declared using mixin application syntax.
+ */
+ bool get isMixinApplication;
+
+ /**
+ * Indicates whether this class is the core "Object" class (and hence has no
+ * supertype)
*/
- List<String> get hides => _hides ?? const <String>[];
+ bool get hasNoSupertype;
}
-class UnlinkedCombinatorBuilder {
- final Map _json = {};
+class _UnlinkedClassReader extends fb.TableReader<_UnlinkedClassReader> implements UnlinkedClass {
+ final fb.BufferPointer _bp;
+
+ const _UnlinkedClassReader([this._bp]);
+
+ @override
+ _UnlinkedClassReader createReader(fb.BufferPointer bp) => new _UnlinkedClassReader(bp);
+
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ String get name => const fb.StringReader().vTableGet(_bp, 0, '');
+
+ @override
+ int get nameOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
+
+ @override
+ UnlinkedDocumentationComment get documentationComment => const _UnlinkedDocumentationCommentReader().vTableGet(_bp, 2, null);
+
+ @override
+ List<UnlinkedTypeParam> get typeParameters => const fb.ListReader<UnlinkedTypeParam>(const _UnlinkedTypeParamReader()).vTableGet(_bp, 3, const <UnlinkedTypeParam>[]);
+
+ @override
+ UnlinkedTypeRef get supertype => const _UnlinkedTypeRefReader().vTableGet(_bp, 4, null);
+
+ @override
+ List<UnlinkedTypeRef> get mixins => const fb.ListReader<UnlinkedTypeRef>(const _UnlinkedTypeRefReader()).vTableGet(_bp, 5, const <UnlinkedTypeRef>[]);
+ @override
+ List<UnlinkedTypeRef> get interfaces => const fb.ListReader<UnlinkedTypeRef>(const _UnlinkedTypeRefReader()).vTableGet(_bp, 6, const <UnlinkedTypeRef>[]);
+
+ @override
+ List<UnlinkedVariable> get fields => const fb.ListReader<UnlinkedVariable>(const _UnlinkedVariableReader()).vTableGet(_bp, 7, const <UnlinkedVariable>[]);
+
+ @override
+ List<UnlinkedExecutable> get executables => const fb.ListReader<UnlinkedExecutable>(const _UnlinkedExecutableReader()).vTableGet(_bp, 8, const <UnlinkedExecutable>[]);
+
+ @override
+ bool get isAbstract => const fb.Int8Reader().vTableGet(_bp, 9, 0) == 1;
+
+ @override
+ bool get isMixinApplication => const fb.Int8Reader().vTableGet(_bp, 10, 0) == 1;
+
+ @override
+ bool get hasNoSupertype => const fb.Int8Reader().vTableGet(_bp, 11, 0) == 1;
+}
+
+class UnlinkedCombinatorBuilder {
bool _finished = false;
+ List<String> _shows;
+ List<String> _hides;
+
+ bool _showsIsSet = false;
+ bool _hidesIsSet = false;
+
UnlinkedCombinatorBuilder(base.BuilderContext context);
/**
@@ -825,10 +1023,9 @@ class UnlinkedCombinatorBuilder {
*/
void set shows(List<String> _value) {
assert(!_finished);
- assert(!_json.containsKey("shows"));
- if (!(_value == null || _value.isEmpty)) {
- _json["shows"] = _value.toList();
- }
+ assert(!_showsIsSet);
+ _showsIsSet = true;
+ _shows = _value;
}
/**
@@ -836,16 +1033,30 @@ class UnlinkedCombinatorBuilder {
*/
void set hides(List<String> _value) {
assert(!_finished);
- assert(!_json.containsKey("hides"));
- if (!(_value == null || _value.isEmpty)) {
- _json["hides"] = _value.toList();
- }
+ assert(!_hidesIsSet);
+ _hidesIsSet = true;
+ _hides = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_shows;
+ fb.Offset offset_hides;
+ if (!(_shows == null || _shows.isEmpty)) {
+ offset_shows = fbBuilder.writeList(_shows.map((b) => fbBuilder.writeString(b)).toList());
+ }
+ if (!(_hides == null || _hides.isEmpty)) {
+ offset_hides = fbBuilder.writeList(_hides.map((b) => fbBuilder.writeString(b)).toList());
+ }
+ fbBuilder.startTable();
+ if (offset_shows != null) {
+ fbBuilder.addOffset(0, offset_shows);
+ }
+ if (offset_hides != null) {
+ fbBuilder.addOffset(1, offset_hides);
+ }
+ return fbBuilder.endTable();
}
}
@@ -857,33 +1068,47 @@ UnlinkedCombinatorBuilder encodeUnlinkedCombinator(base.BuilderContext builderCo
}
/**
- * Unlinked summary information about a documentation comment.
+ * Unlinked summary information about a `show` or `hide` combinator in an
+ * import or export declaration.
*/
-class UnlinkedDocumentationComment extends base.SummaryClass {
- String _text;
+abstract class UnlinkedCombinator extends base.SummaryClass {
- UnlinkedDocumentationComment.fromJson(Map json)
- : _text = json["text"];
-
- @override
- Map<String, Object> toMap() => {
- "text": text,
- };
+ /**
+ * List of names which are shown. Empty if this is a `hide` combinator.
+ */
+ List<String> get shows;
/**
- * Text of the documentation comment, with '\r\n' replaced by '\n'.
- *
- * References appearing within the doc comment in square brackets are not
- * specially encoded.
+ * List of names which are hidden. Empty if this is a `show` combinator.
*/
- String get text => _text ?? '';
+ List<String> get hides;
}
-class UnlinkedDocumentationCommentBuilder {
- final Map _json = {};
+class _UnlinkedCombinatorReader extends fb.TableReader<_UnlinkedCombinatorReader> implements UnlinkedCombinator {
+ final fb.BufferPointer _bp;
+
+ const _UnlinkedCombinatorReader([this._bp]);
+
+ @override
+ _UnlinkedCombinatorReader createReader(fb.BufferPointer bp) => new _UnlinkedCombinatorReader(bp);
+
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ List<String> get shows => const fb.ListReader<String>(const fb.StringReader()).vTableGet(_bp, 0, const <String>[]);
+
+ @override
+ List<String> get hides => const fb.ListReader<String>(const fb.StringReader()).vTableGet(_bp, 1, const <String>[]);
+}
+class UnlinkedDocumentationCommentBuilder {
bool _finished = false;
+ String _text;
+
+ bool _textIsSet = false;
+
UnlinkedDocumentationCommentBuilder(base.BuilderContext context);
/**
@@ -894,16 +1119,23 @@ class UnlinkedDocumentationCommentBuilder {
*/
void set text(String _value) {
assert(!_finished);
- assert(!_json.containsKey("text"));
- if (_value != null) {
- _json["text"] = _value;
- }
+ assert(!_textIsSet);
+ _textIsSet = true;
+ _text = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_text;
+ if (_text != null) {
+ offset_text = fbBuilder.writeString(_text);
+ }
+ fbBuilder.startTable();
+ if (offset_text != null) {
+ fbBuilder.addOffset(0, offset_text);
+ }
+ return fbBuilder.endTable();
}
}
@@ -914,55 +1146,47 @@ UnlinkedDocumentationCommentBuilder encodeUnlinkedDocumentationComment(base.Buil
}
/**
- * Unlinked summary information about an enum declaration.
+ * Unlinked summary information about a documentation comment.
*/
-class UnlinkedEnum extends base.SummaryClass {
- String _name;
- int _nameOffset;
- UnlinkedDocumentationComment _documentationComment;
- List<UnlinkedEnumValue> _values;
-
- UnlinkedEnum.fromJson(Map json)
- : _name = json["name"],
- _nameOffset = json["nameOffset"],
- _documentationComment = json["documentationComment"] == null ? null : new UnlinkedDocumentationComment.fromJson(json["documentationComment"]),
- _values = json["values"]?.map((x) => new UnlinkedEnumValue.fromJson(x))?.toList();
-
- @override
- Map<String, Object> toMap() => {
- "name": name,
- "nameOffset": nameOffset,
- "documentationComment": documentationComment,
- "values": values,
- };
+abstract class UnlinkedDocumentationComment extends base.SummaryClass {
/**
- * Name of the enum type.
+ * Text of the documentation comment, with '\r\n' replaced by '\n'.
+ *
+ * References appearing within the doc comment in square brackets are not
+ * specially encoded.
*/
- String get name => _name ?? '';
+ String get text;
+}
- /**
- * Offset of the enum name relative to the beginning of the file.
- */
- int get nameOffset => _nameOffset ?? 0;
+class _UnlinkedDocumentationCommentReader extends fb.TableReader<_UnlinkedDocumentationCommentReader> implements UnlinkedDocumentationComment {
+ final fb.BufferPointer _bp;
- /**
- * Documentation comment for the enum, or `null` if there is no documentation
- * comment.
- */
- UnlinkedDocumentationComment get documentationComment => _documentationComment;
+ const _UnlinkedDocumentationCommentReader([this._bp]);
- /**
- * Values listed in the enum declaration, in declaration order.
- */
- List<UnlinkedEnumValue> get values => _values ?? const <UnlinkedEnumValue>[];
+ @override
+ _UnlinkedDocumentationCommentReader createReader(fb.BufferPointer bp) => new _UnlinkedDocumentationCommentReader(bp);
+
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ String get text => const fb.StringReader().vTableGet(_bp, 0, '');
}
class UnlinkedEnumBuilder {
- final Map _json = {};
-
bool _finished = false;
+ String _name;
+ int _nameOffset;
+ UnlinkedDocumentationCommentBuilder _documentationComment;
+ List<UnlinkedEnumValueBuilder> _values;
+
+ bool _nameIsSet = false;
+ bool _nameOffsetIsSet = false;
+ bool _documentationCommentIsSet = false;
+ bool _valuesIsSet = false;
+
UnlinkedEnumBuilder(base.BuilderContext context);
/**
@@ -970,10 +1194,9 @@ class UnlinkedEnumBuilder {
*/
void set name(String _value) {
assert(!_finished);
- assert(!_json.containsKey("name"));
- if (_value != null) {
- _json["name"] = _value;
- }
+ assert(!_nameIsSet);
+ _nameIsSet = true;
+ _name = _value;
}
/**
@@ -981,10 +1204,9 @@ class UnlinkedEnumBuilder {
*/
void set nameOffset(int _value) {
assert(!_finished);
- assert(!_json.containsKey("nameOffset"));
- if (_value != null) {
- _json["nameOffset"] = _value;
- }
+ assert(!_nameOffsetIsSet);
+ _nameOffsetIsSet = true;
+ _nameOffset = _value;
}
/**
@@ -993,10 +1215,9 @@ class UnlinkedEnumBuilder {
*/
void set documentationComment(UnlinkedDocumentationCommentBuilder _value) {
assert(!_finished);
- assert(!_json.containsKey("documentationComment"));
- if (_value != null) {
- _json["documentationComment"] = _value.finish();
- }
+ assert(!_documentationCommentIsSet);
+ _documentationCommentIsSet = true;
+ _documentationComment = _value;
}
/**
@@ -1004,16 +1225,40 @@ class UnlinkedEnumBuilder {
*/
void set values(List<UnlinkedEnumValueBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("values"));
- if (!(_value == null || _value.isEmpty)) {
- _json["values"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_valuesIsSet);
+ _valuesIsSet = true;
+ _values = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_name;
+ fb.Offset offset_documentationComment;
+ fb.Offset offset_values;
+ if (_name != null) {
+ offset_name = fbBuilder.writeString(_name);
+ }
+ if (_documentationComment != null) {
+ offset_documentationComment = _documentationComment.finish(fbBuilder);
+ }
+ if (!(_values == null || _values.isEmpty)) {
+ offset_values = fbBuilder.writeList(_values.map((b) => b.finish(fbBuilder)).toList());
+ }
+ fbBuilder.startTable();
+ if (offset_name != null) {
+ fbBuilder.addOffset(0, offset_name);
+ }
+ if (_nameOffset != null && _nameOffset != 0) {
+ fbBuilder.addInt32(1, _nameOffset);
+ }
+ if (offset_documentationComment != null) {
+ fbBuilder.addOffset(2, offset_documentationComment);
+ }
+ if (offset_values != null) {
+ fbBuilder.addOffset(3, offset_values);
+ }
+ return fbBuilder.endTable();
}
}
@@ -1027,59 +1272,77 @@ UnlinkedEnumBuilder encodeUnlinkedEnum(base.BuilderContext builderContext, {Stri
}
/**
- * Unlinked summary information about a single enumerated value in an enum
- * declaration.
+ * Unlinked summary information about an enum declaration.
*/
-class UnlinkedEnumValue extends base.SummaryClass {
- String _name;
- int _nameOffset;
- UnlinkedDocumentationComment _documentationComment;
-
- UnlinkedEnumValue.fromJson(Map json)
- : _name = json["name"],
- _nameOffset = json["nameOffset"],
- _documentationComment = json["documentationComment"] == null ? null : new UnlinkedDocumentationComment.fromJson(json["documentationComment"]);
+abstract class UnlinkedEnum extends base.SummaryClass {
- @override
- Map<String, Object> toMap() => {
- "name": name,
- "nameOffset": nameOffset,
- "documentationComment": documentationComment,
- };
+ /**
+ * Name of the enum type.
+ */
+ String get name;
/**
- * Name of the enumerated value.
+ * Offset of the enum name relative to the beginning of the file.
*/
- String get name => _name ?? '';
+ int get nameOffset;
/**
- * Offset of the enum value name relative to the beginning of the file.
+ * Documentation comment for the enum, or `null` if there is no documentation
+ * comment.
*/
- int get nameOffset => _nameOffset ?? 0;
+ UnlinkedDocumentationComment get documentationComment;
/**
- * Documentation comment for the enum value, or `null` if there is no
- * documentation comment.
+ * Values listed in the enum declaration, in declaration order.
*/
- UnlinkedDocumentationComment get documentationComment => _documentationComment;
+ List<UnlinkedEnumValue> get values;
}
-class UnlinkedEnumValueBuilder {
- final Map _json = {};
+class _UnlinkedEnumReader extends fb.TableReader<_UnlinkedEnumReader> implements UnlinkedEnum {
+ final fb.BufferPointer _bp;
- bool _finished = false;
+ const _UnlinkedEnumReader([this._bp]);
- UnlinkedEnumValueBuilder(base.BuilderContext context);
+ @override
+ _UnlinkedEnumReader createReader(fb.BufferPointer bp) => new _UnlinkedEnumReader(bp);
- /**
- * Name of the enumerated value.
- */
- void set name(String _value) {
- assert(!_finished);
- assert(!_json.containsKey("name"));
- if (_value != null) {
- _json["name"] = _value;
- }
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ String get name => const fb.StringReader().vTableGet(_bp, 0, '');
+
+ @override
+ int get nameOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
+
+ @override
+ UnlinkedDocumentationComment get documentationComment => const _UnlinkedDocumentationCommentReader().vTableGet(_bp, 2, null);
+
+ @override
+ List<UnlinkedEnumValue> get values => const fb.ListReader<UnlinkedEnumValue>(const _UnlinkedEnumValueReader()).vTableGet(_bp, 3, const <UnlinkedEnumValue>[]);
+}
+
+class UnlinkedEnumValueBuilder {
+ bool _finished = false;
+
+ String _name;
+ int _nameOffset;
+ UnlinkedDocumentationCommentBuilder _documentationComment;
+
+ bool _nameIsSet = false;
+ bool _nameOffsetIsSet = false;
+ bool _documentationCommentIsSet = false;
+
+ UnlinkedEnumValueBuilder(base.BuilderContext context);
+
+ /**
+ * Name of the enumerated value.
+ */
+ void set name(String _value) {
+ assert(!_finished);
+ assert(!_nameIsSet);
+ _nameIsSet = true;
+ _name = _value;
}
/**
@@ -1087,10 +1350,9 @@ class UnlinkedEnumValueBuilder {
*/
void set nameOffset(int _value) {
assert(!_finished);
- assert(!_json.containsKey("nameOffset"));
- if (_value != null) {
- _json["nameOffset"] = _value;
- }
+ assert(!_nameOffsetIsSet);
+ _nameOffsetIsSet = true;
+ _nameOffset = _value;
}
/**
@@ -1099,16 +1361,33 @@ class UnlinkedEnumValueBuilder {
*/
void set documentationComment(UnlinkedDocumentationCommentBuilder _value) {
assert(!_finished);
- assert(!_json.containsKey("documentationComment"));
- if (_value != null) {
- _json["documentationComment"] = _value.finish();
- }
+ assert(!_documentationCommentIsSet);
+ _documentationCommentIsSet = true;
+ _documentationComment = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_name;
+ fb.Offset offset_documentationComment;
+ if (_name != null) {
+ offset_name = fbBuilder.writeString(_name);
+ }
+ if (_documentationComment != null) {
+ offset_documentationComment = _documentationComment.finish(fbBuilder);
+ }
+ fbBuilder.startTable();
+ if (offset_name != null) {
+ fbBuilder.addOffset(0, offset_name);
+ }
+ if (_nameOffset != null && _nameOffset != 0) {
+ fbBuilder.addInt32(1, _nameOffset);
+ }
+ if (offset_documentationComment != null) {
+ fbBuilder.addOffset(2, offset_documentationComment);
+ }
+ return fbBuilder.endTable();
}
}
@@ -1121,144 +1400,80 @@ UnlinkedEnumValueBuilder encodeUnlinkedEnumValue(base.BuilderContext builderCont
}
/**
- * Unlinked summary information about a function, method, getter, or setter
+ * Unlinked summary information about a single enumerated value in an enum
* declaration.
*/
-class UnlinkedExecutable extends base.SummaryClass {
- String _name;
- int _nameOffset;
- UnlinkedDocumentationComment _documentationComment;
- List<UnlinkedTypeParam> _typeParameters;
- UnlinkedTypeRef _returnType;
- List<UnlinkedParam> _parameters;
- UnlinkedExecutableKind _kind;
- bool _isAbstract;
- bool _isStatic;
- bool _isConst;
- bool _isFactory;
- bool _hasImplicitReturnType;
- bool _isExternal;
-
- UnlinkedExecutable.fromJson(Map json)
- : _name = json["name"],
- _nameOffset = json["nameOffset"],
- _documentationComment = json["documentationComment"] == null ? null : new UnlinkedDocumentationComment.fromJson(json["documentationComment"]),
- _typeParameters = json["typeParameters"]?.map((x) => new UnlinkedTypeParam.fromJson(x))?.toList(),
- _returnType = json["returnType"] == null ? null : new UnlinkedTypeRef.fromJson(json["returnType"]),
- _parameters = json["parameters"]?.map((x) => new UnlinkedParam.fromJson(x))?.toList(),
- _kind = json["kind"] == null ? null : UnlinkedExecutableKind.values[json["kind"]],
- _isAbstract = json["isAbstract"],
- _isStatic = json["isStatic"],
- _isConst = json["isConst"],
- _isFactory = json["isFactory"],
- _hasImplicitReturnType = json["hasImplicitReturnType"],
- _isExternal = json["isExternal"];
-
- @override
- Map<String, Object> toMap() => {
- "name": name,
- "nameOffset": nameOffset,
- "documentationComment": documentationComment,
- "typeParameters": typeParameters,
- "returnType": returnType,
- "parameters": parameters,
- "kind": kind,
- "isAbstract": isAbstract,
- "isStatic": isStatic,
- "isConst": isConst,
- "isFactory": isFactory,
- "hasImplicitReturnType": hasImplicitReturnType,
- "isExternal": isExternal,
- };
+abstract class UnlinkedEnumValue extends base.SummaryClass {
/**
- * Name of the executable. For setters, this includes the trailing "=". For
- * named constructors, this excludes the class name and excludes the ".".
- * For unnamed constructors, this is the empty string.
+ * Name of the enumerated value.
*/
- String get name => _name ?? '';
+ String get name;
/**
- * Offset of the executable name relative to the beginning of the file. For
- * named constructors, this excludes the class name and excludes the ".".
- * For unnamed constructors, this is the offset of the class name (i.e. the
- * offset of the second "C" in "class C { C(); }").
+ * Offset of the enum value name relative to the beginning of the file.
*/
- int get nameOffset => _nameOffset ?? 0;
+ int get nameOffset;
/**
- * Documentation comment for the executable, or `null` if there is no
+ * Documentation comment for the enum value, or `null` if there is no
* documentation comment.
*/
- UnlinkedDocumentationComment get documentationComment => _documentationComment;
-
- /**
- * Type parameters of the executable, if any. Empty if support for generic
- * method syntax is disabled.
- */
- List<UnlinkedTypeParam> get typeParameters => _typeParameters ?? const <UnlinkedTypeParam>[];
-
- /**
- * 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.
- */
- UnlinkedTypeRef get returnType => _returnType;
-
- /**
- * Parameters of the executable, if any. Note that getters have no
- * parameters (hence this will be the empty list), and setters have a single
- * parameter.
- */
- List<UnlinkedParam> get parameters => _parameters ?? const <UnlinkedParam>[];
+ UnlinkedDocumentationComment get documentationComment;
+}
- /**
- * The kind of the executable (function/method, getter, setter, or
- * constructor).
- */
- UnlinkedExecutableKind get kind => _kind ?? UnlinkedExecutableKind.functionOrMethod;
+class _UnlinkedEnumValueReader extends fb.TableReader<_UnlinkedEnumValueReader> implements UnlinkedEnumValue {
+ final fb.BufferPointer _bp;
- /**
- * Indicates whether the executable is declared using the `abstract` keyword.
- */
- bool get isAbstract => _isAbstract ?? false;
+ const _UnlinkedEnumValueReader([this._bp]);
- /**
- * Indicates whether the executable is declared using the `static` keyword.
- *
- * Note that for top level executables, this flag is false, since they are
- * not declared using the `static` keyword (even though they are considered
- * static for semantic purposes).
- */
- bool get isStatic => _isStatic ?? false;
+ @override
+ _UnlinkedEnumValueReader createReader(fb.BufferPointer bp) => new _UnlinkedEnumValueReader(bp);
- /**
- * Indicates whether the executable is declared using the `const` keyword.
- */
- bool get isConst => _isConst ?? false;
+ @override
+ Map<String, Object> toMap() => {};
- /**
- * Indicates whether the executable is declared using the `factory` keyword.
- */
- bool get isFactory => _isFactory ?? false;
+ @override
+ String get name => const fb.StringReader().vTableGet(_bp, 0, '');
- /**
- * Indicates whether the executable lacks an explicit return type
- * declaration. False for constructors and setters.
- */
- bool get hasImplicitReturnType => _hasImplicitReturnType ?? false;
+ @override
+ int get nameOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
- /**
- * Indicates whether the executable is declared using the `external` keyword.
- */
- bool get isExternal => _isExternal ?? false;
+ @override
+ UnlinkedDocumentationComment get documentationComment => const _UnlinkedDocumentationCommentReader().vTableGet(_bp, 2, null);
}
class UnlinkedExecutableBuilder {
- final Map _json = {};
-
bool _finished = false;
+ 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;
+
+ bool _nameIsSet = false;
+ bool _nameOffsetIsSet = false;
+ bool _documentationCommentIsSet = false;
+ bool _typeParametersIsSet = false;
+ bool _returnTypeIsSet = false;
+ bool _parametersIsSet = false;
+ bool _kindIsSet = false;
+ bool _isAbstractIsSet = false;
+ bool _isStaticIsSet = false;
+ bool _isConstIsSet = false;
+ bool _isFactoryIsSet = false;
+ bool _hasImplicitReturnTypeIsSet = false;
+ bool _isExternalIsSet = false;
+
UnlinkedExecutableBuilder(base.BuilderContext context);
/**
@@ -1268,10 +1483,9 @@ class UnlinkedExecutableBuilder {
*/
void set name(String _value) {
assert(!_finished);
- assert(!_json.containsKey("name"));
- if (_value != null) {
- _json["name"] = _value;
- }
+ assert(!_nameIsSet);
+ _nameIsSet = true;
+ _name = _value;
}
/**
@@ -1282,10 +1496,9 @@ class UnlinkedExecutableBuilder {
*/
void set nameOffset(int _value) {
assert(!_finished);
- assert(!_json.containsKey("nameOffset"));
- if (_value != null) {
- _json["nameOffset"] = _value;
- }
+ assert(!_nameOffsetIsSet);
+ _nameOffsetIsSet = true;
+ _nameOffset = _value;
}
/**
@@ -1294,10 +1507,9 @@ class UnlinkedExecutableBuilder {
*/
void set documentationComment(UnlinkedDocumentationCommentBuilder _value) {
assert(!_finished);
- assert(!_json.containsKey("documentationComment"));
- if (_value != null) {
- _json["documentationComment"] = _value.finish();
- }
+ assert(!_documentationCommentIsSet);
+ _documentationCommentIsSet = true;
+ _documentationComment = _value;
}
/**
@@ -1306,10 +1518,9 @@ class UnlinkedExecutableBuilder {
*/
void set typeParameters(List<UnlinkedTypeParamBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("typeParameters"));
- if (!(_value == null || _value.isEmpty)) {
- _json["typeParameters"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_typeParametersIsSet);
+ _typeParametersIsSet = true;
+ _typeParameters = _value;
}
/**
@@ -1319,10 +1530,9 @@ class UnlinkedExecutableBuilder {
*/
void set returnType(UnlinkedTypeRefBuilder _value) {
assert(!_finished);
- assert(!_json.containsKey("returnType"));
- if (_value != null) {
- _json["returnType"] = _value.finish();
- }
+ assert(!_returnTypeIsSet);
+ _returnTypeIsSet = true;
+ _returnType = _value;
}
/**
@@ -1332,10 +1542,9 @@ class UnlinkedExecutableBuilder {
*/
void set parameters(List<UnlinkedParamBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("parameters"));
- if (!(_value == null || _value.isEmpty)) {
- _json["parameters"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_parametersIsSet);
+ _parametersIsSet = true;
+ _parameters = _value;
}
/**
@@ -1344,10 +1553,9 @@ class UnlinkedExecutableBuilder {
*/
void set kind(UnlinkedExecutableKind _value) {
assert(!_finished);
- assert(!_json.containsKey("kind"));
- if (!(_value == null || _value == UnlinkedExecutableKind.functionOrMethod)) {
- _json["kind"] = _value.index;
- }
+ assert(!_kindIsSet);
+ _kindIsSet = true;
+ _kind = _value;
}
/**
@@ -1355,10 +1563,9 @@ class UnlinkedExecutableBuilder {
*/
void set isAbstract(bool _value) {
assert(!_finished);
- assert(!_json.containsKey("isAbstract"));
- if (_value != null) {
- _json["isAbstract"] = _value;
- }
+ assert(!_isAbstractIsSet);
+ _isAbstractIsSet = true;
+ _isAbstract = _value;
}
/**
@@ -1370,10 +1577,9 @@ class UnlinkedExecutableBuilder {
*/
void set isStatic(bool _value) {
assert(!_finished);
- assert(!_json.containsKey("isStatic"));
- if (_value != null) {
- _json["isStatic"] = _value;
- }
+ assert(!_isStaticIsSet);
+ _isStaticIsSet = true;
+ _isStatic = _value;
}
/**
@@ -1381,10 +1587,9 @@ class UnlinkedExecutableBuilder {
*/
void set isConst(bool _value) {
assert(!_finished);
- assert(!_json.containsKey("isConst"));
- if (_value != null) {
- _json["isConst"] = _value;
- }
+ assert(!_isConstIsSet);
+ _isConstIsSet = true;
+ _isConst = _value;
}
/**
@@ -1392,10 +1597,9 @@ class UnlinkedExecutableBuilder {
*/
void set isFactory(bool _value) {
assert(!_finished);
- assert(!_json.containsKey("isFactory"));
- if (_value != null) {
- _json["isFactory"] = _value;
- }
+ assert(!_isFactoryIsSet);
+ _isFactoryIsSet = true;
+ _isFactory = _value;
}
/**
@@ -1404,10 +1608,9 @@ class UnlinkedExecutableBuilder {
*/
void set hasImplicitReturnType(bool _value) {
assert(!_finished);
- assert(!_json.containsKey("hasImplicitReturnType"));
- if (_value != null) {
- _json["hasImplicitReturnType"] = _value;
- }
+ assert(!_hasImplicitReturnTypeIsSet);
+ _hasImplicitReturnTypeIsSet = true;
+ _hasImplicitReturnType = _value;
}
/**
@@ -1415,16 +1618,75 @@ class UnlinkedExecutableBuilder {
*/
void set isExternal(bool _value) {
assert(!_finished);
- assert(!_json.containsKey("isExternal"));
- if (_value != null) {
- _json["isExternal"] = _value;
- }
+ assert(!_isExternalIsSet);
+ _isExternalIsSet = true;
+ _isExternal = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_name;
+ fb.Offset offset_documentationComment;
+ fb.Offset offset_typeParameters;
+ fb.Offset offset_returnType;
+ fb.Offset offset_parameters;
+ if (_name != null) {
+ offset_name = fbBuilder.writeString(_name);
+ }
+ if (_documentationComment != null) {
+ offset_documentationComment = _documentationComment.finish(fbBuilder);
+ }
+ if (!(_typeParameters == null || _typeParameters.isEmpty)) {
+ offset_typeParameters = fbBuilder.writeList(_typeParameters.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (_returnType != null) {
+ offset_returnType = _returnType.finish(fbBuilder);
+ }
+ if (!(_parameters == null || _parameters.isEmpty)) {
+ offset_parameters = fbBuilder.writeList(_parameters.map((b) => b.finish(fbBuilder)).toList());
+ }
+ fbBuilder.startTable();
+ if (offset_name != null) {
+ fbBuilder.addOffset(0, offset_name);
+ }
+ if (_nameOffset != null && _nameOffset != 0) {
+ fbBuilder.addInt32(1, _nameOffset);
+ }
+ if (offset_documentationComment != null) {
+ fbBuilder.addOffset(2, offset_documentationComment);
+ }
+ if (offset_typeParameters != null) {
+ fbBuilder.addOffset(3, offset_typeParameters);
+ }
+ if (offset_returnType != null) {
+ fbBuilder.addOffset(4, offset_returnType);
+ }
+ if (offset_parameters != null) {
+ fbBuilder.addOffset(5, offset_parameters);
+ }
+ if (_kind != null && _kind != UnlinkedExecutableKind.functionOrMethod) {
+ fbBuilder.addInt32(6, _kind.index);
+ }
+ if (_isAbstract == true) {
+ fbBuilder.addInt8(7, 1);
+ }
+ if (_isStatic == true) {
+ fbBuilder.addInt8(8, 1);
+ }
+ if (_isConst == true) {
+ fbBuilder.addInt8(9, 1);
+ }
+ if (_isFactory == true) {
+ fbBuilder.addInt8(10, 1);
+ }
+ if (_hasImplicitReturnType == true) {
+ fbBuilder.addInt8(11, 1);
+ }
+ if (_isExternal == true) {
+ fbBuilder.addInt8(12, 1);
+ }
+ return fbBuilder.endTable();
}
}
@@ -1447,49 +1709,159 @@ UnlinkedExecutableBuilder encodeUnlinkedExecutable(base.BuilderContext builderCo
}
/**
- * Unlinked summary information about an export declaration (stored outside
- * [UnlinkedPublicNamespace]).
+ * Unlinked summary information about a function, method, getter, or setter
+ * declaration.
*/
-class UnlinkedExportNonPublic extends base.SummaryClass {
- int _offset;
- int _uriOffset;
- int _uriEnd;
+abstract class UnlinkedExecutable extends base.SummaryClass {
- UnlinkedExportNonPublic.fromJson(Map json)
- : _offset = json["offset"],
- _uriOffset = json["uriOffset"],
- _uriEnd = json["uriEnd"];
+ /**
+ * Name of the executable. For setters, this includes the trailing "=". For
+ * named constructors, this excludes the class name and excludes the ".".
+ * For unnamed constructors, this is the empty string.
+ */
+ String get name;
- @override
- Map<String, Object> toMap() => {
- "offset": offset,
- "uriOffset": uriOffset,
- "uriEnd": uriEnd,
- };
+ /**
+ * Offset of the executable name relative to the beginning of the file. For
+ * named constructors, this excludes the class name and excludes the ".".
+ * For unnamed constructors, this is the offset of the class name (i.e. the
+ * offset of the second "C" in "class C { C(); }").
+ */
+ int get nameOffset;
/**
- * Offset of the "export" keyword.
+ * Documentation comment for the executable, or `null` if there is no
+ * documentation comment.
*/
- int get offset => _offset ?? 0;
+ UnlinkedDocumentationComment get documentationComment;
/**
- * Offset of the URI string (including quotes) relative to the beginning of
- * the file.
+ * Type parameters of the executable, if any. Empty if support for generic
+ * method syntax is disabled.
*/
- int get uriOffset => _uriOffset ?? 0;
+ List<UnlinkedTypeParam> get typeParameters;
/**
- * End of the URI string (including quotes) relative to the beginning of the
- * file.
+ * 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.
+ */
+ UnlinkedTypeRef get returnType;
+
+ /**
+ * Parameters of the executable, if any. Note that getters have no
+ * parameters (hence this will be the empty list), and setters have a single
+ * parameter.
+ */
+ List<UnlinkedParam> get parameters;
+
+ /**
+ * The kind of the executable (function/method, getter, setter, or
+ * constructor).
*/
- int get uriEnd => _uriEnd ?? 0;
+ UnlinkedExecutableKind get kind;
+
+ /**
+ * Indicates whether the executable is declared using the `abstract` keyword.
+ */
+ bool get isAbstract;
+
+ /**
+ * Indicates whether the executable is declared using the `static` keyword.
+ *
+ * Note that for top level executables, this flag is false, since they are
+ * not declared using the `static` keyword (even though they are considered
+ * static for semantic purposes).
+ */
+ bool get isStatic;
+
+ /**
+ * Indicates whether the executable is declared using the `const` keyword.
+ */
+ bool get isConst;
+
+ /**
+ * Indicates whether the executable is declared using the `factory` keyword.
+ */
+ bool get isFactory;
+
+ /**
+ * Indicates whether the executable lacks an explicit return type
+ * declaration. False for constructors and setters.
+ */
+ bool get hasImplicitReturnType;
+
+ /**
+ * Indicates whether the executable is declared using the `external` keyword.
+ */
+ bool get isExternal;
}
-class UnlinkedExportNonPublicBuilder {
- final Map _json = {};
+class _UnlinkedExecutableReader extends fb.TableReader<_UnlinkedExecutableReader> implements UnlinkedExecutable {
+ final fb.BufferPointer _bp;
+
+ const _UnlinkedExecutableReader([this._bp]);
+
+ @override
+ _UnlinkedExecutableReader createReader(fb.BufferPointer bp) => new _UnlinkedExecutableReader(bp);
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ String get name => const fb.StringReader().vTableGet(_bp, 0, '');
+
+ @override
+ int get nameOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
+
+ @override
+ UnlinkedDocumentationComment get documentationComment => const _UnlinkedDocumentationCommentReader().vTableGet(_bp, 2, null);
+
+ @override
+ List<UnlinkedTypeParam> get typeParameters => const fb.ListReader<UnlinkedTypeParam>(const _UnlinkedTypeParamReader()).vTableGet(_bp, 3, const <UnlinkedTypeParam>[]);
+
+ @override
+ UnlinkedTypeRef get returnType => const _UnlinkedTypeRefReader().vTableGet(_bp, 4, null);
+
+ @override
+ List<UnlinkedParam> get parameters => const fb.ListReader<UnlinkedParam>(const _UnlinkedParamReader()).vTableGet(_bp, 5, const <UnlinkedParam>[]);
+
+ @override
+ UnlinkedExecutableKind get kind {
+ int index = const fb.Int32Reader().vTableGet(_bp, 6, 0);
+ return UnlinkedExecutableKind.values[index];
+ }
+
+ @override
+ bool get isAbstract => const fb.Int8Reader().vTableGet(_bp, 7, 0) == 1;
+
+ @override
+ bool get isStatic => const fb.Int8Reader().vTableGet(_bp, 8, 0) == 1;
+
+ @override
+ bool get isConst => const fb.Int8Reader().vTableGet(_bp, 9, 0) == 1;
+
+ @override
+ bool get isFactory => const fb.Int8Reader().vTableGet(_bp, 10, 0) == 1;
+
+ @override
+ bool get hasImplicitReturnType => const fb.Int8Reader().vTableGet(_bp, 11, 0) == 1;
+
+ @override
+ bool get isExternal => const fb.Int8Reader().vTableGet(_bp, 12, 0) == 1;
+}
+
+class UnlinkedExportNonPublicBuilder {
bool _finished = false;
+ int _offset;
+ int _uriOffset;
+ int _uriEnd;
+
+ bool _offsetIsSet = false;
+ bool _uriOffsetIsSet = false;
+ bool _uriEndIsSet = false;
+
UnlinkedExportNonPublicBuilder(base.BuilderContext context);
/**
@@ -1497,10 +1869,9 @@ class UnlinkedExportNonPublicBuilder {
*/
void set offset(int _value) {
assert(!_finished);
- assert(!_json.containsKey("offset"));
- if (_value != null) {
- _json["offset"] = _value;
- }
+ assert(!_offsetIsSet);
+ _offsetIsSet = true;
+ _offset = _value;
}
/**
@@ -1509,10 +1880,9 @@ class UnlinkedExportNonPublicBuilder {
*/
void set uriOffset(int _value) {
assert(!_finished);
- assert(!_json.containsKey("uriOffset"));
- if (_value != null) {
- _json["uriOffset"] = _value;
- }
+ assert(!_uriOffsetIsSet);
+ _uriOffsetIsSet = true;
+ _uriOffset = _value;
}
/**
@@ -1521,16 +1891,25 @@ class UnlinkedExportNonPublicBuilder {
*/
void set uriEnd(int _value) {
assert(!_finished);
- assert(!_json.containsKey("uriEnd"));
- if (_value != null) {
- _json["uriEnd"] = _value;
- }
+ assert(!_uriEndIsSet);
+ _uriEndIsSet = true;
+ _uriEnd = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fbBuilder.startTable();
+ if (_offset != null && _offset != 0) {
+ fbBuilder.addInt32(0, _offset);
+ }
+ if (_uriOffset != null && _uriOffset != 0) {
+ fbBuilder.addInt32(1, _uriOffset);
+ }
+ if (_uriEnd != null && _uriEnd != 0) {
+ fbBuilder.addInt32(2, _uriEnd);
+ }
+ return fbBuilder.endTable();
}
}
@@ -1543,39 +1922,59 @@ UnlinkedExportNonPublicBuilder encodeUnlinkedExportNonPublic(base.BuilderContext
}
/**
- * Unlinked summary information about an export declaration (stored inside
+ * Unlinked summary information about an export declaration (stored outside
* [UnlinkedPublicNamespace]).
*/
-class UnlinkedExportPublic extends base.SummaryClass {
- String _uri;
- List<UnlinkedCombinator> _combinators;
-
- UnlinkedExportPublic.fromJson(Map json)
- : _uri = json["uri"],
- _combinators = json["combinators"]?.map((x) => new UnlinkedCombinator.fromJson(x))?.toList();
+abstract class UnlinkedExportNonPublic extends base.SummaryClass {
- @override
- Map<String, Object> toMap() => {
- "uri": uri,
- "combinators": combinators,
- };
+ /**
+ * Offset of the "export" keyword.
+ */
+ int get offset;
/**
- * URI used in the source code to reference the exported library.
+ * Offset of the URI string (including quotes) relative to the beginning of
+ * the file.
*/
- String get uri => _uri ?? '';
+ int get uriOffset;
/**
- * Combinators contained in this import declaration.
+ * End of the URI string (including quotes) relative to the beginning of the
+ * file.
*/
- List<UnlinkedCombinator> get combinators => _combinators ?? const <UnlinkedCombinator>[];
+ int get uriEnd;
}
-class UnlinkedExportPublicBuilder {
- final Map _json = {};
+class _UnlinkedExportNonPublicReader extends fb.TableReader<_UnlinkedExportNonPublicReader> implements UnlinkedExportNonPublic {
+ final fb.BufferPointer _bp;
+
+ const _UnlinkedExportNonPublicReader([this._bp]);
+
+ @override
+ _UnlinkedExportNonPublicReader createReader(fb.BufferPointer bp) => new _UnlinkedExportNonPublicReader(bp);
+
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ int get offset => const fb.Int32Reader().vTableGet(_bp, 0, 0);
+
+ @override
+ int get uriOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
+ @override
+ int get uriEnd => const fb.Int32Reader().vTableGet(_bp, 2, 0);
+}
+
+class UnlinkedExportPublicBuilder {
bool _finished = false;
+ String _uri;
+ List<UnlinkedCombinatorBuilder> _combinators;
+
+ bool _uriIsSet = false;
+ bool _combinatorsIsSet = false;
+
UnlinkedExportPublicBuilder(base.BuilderContext context);
/**
@@ -1583,10 +1982,9 @@ class UnlinkedExportPublicBuilder {
*/
void set uri(String _value) {
assert(!_finished);
- assert(!_json.containsKey("uri"));
- if (_value != null) {
- _json["uri"] = _value;
- }
+ assert(!_uriIsSet);
+ _uriIsSet = true;
+ _uri = _value;
}
/**
@@ -1594,16 +1992,30 @@ class UnlinkedExportPublicBuilder {
*/
void set combinators(List<UnlinkedCombinatorBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("combinators"));
- if (!(_value == null || _value.isEmpty)) {
- _json["combinators"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_combinatorsIsSet);
+ _combinatorsIsSet = true;
+ _combinators = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_uri;
+ fb.Offset offset_combinators;
+ if (_uri != null) {
+ offset_uri = fbBuilder.writeString(_uri);
+ }
+ if (!(_combinators == null || _combinators.isEmpty)) {
+ offset_combinators = fbBuilder.writeList(_combinators.map((b) => b.finish(fbBuilder)).toList());
+ }
+ fbBuilder.startTable();
+ if (offset_uri != null) {
+ fbBuilder.addOffset(0, offset_uri);
+ }
+ if (offset_combinators != null) {
+ fbBuilder.addOffset(1, offset_combinators);
+ }
+ return fbBuilder.endTable();
}
}
@@ -1615,101 +2027,63 @@ UnlinkedExportPublicBuilder encodeUnlinkedExportPublic(base.BuilderContext build
}
/**
- * Unlinked summary information about an import declaration.
+ * Unlinked summary information about an export declaration (stored inside
+ * [UnlinkedPublicNamespace]).
*/
-class UnlinkedImport extends base.SummaryClass {
- String _uri;
- int _offset;
- int _prefixReference;
- List<UnlinkedCombinator> _combinators;
- bool _isDeferred;
- bool _isImplicit;
- int _uriOffset;
- int _uriEnd;
- int _prefixOffset;
-
- UnlinkedImport.fromJson(Map json)
- : _uri = json["uri"],
- _offset = json["offset"],
- _prefixReference = json["prefixReference"],
- _combinators = json["combinators"]?.map((x) => new UnlinkedCombinator.fromJson(x))?.toList(),
- _isDeferred = json["isDeferred"],
- _isImplicit = json["isImplicit"],
- _uriOffset = json["uriOffset"],
- _uriEnd = json["uriEnd"],
- _prefixOffset = json["prefixOffset"];
-
- @override
- Map<String, Object> toMap() => {
- "uri": uri,
- "offset": offset,
- "prefixReference": prefixReference,
- "combinators": combinators,
- "isDeferred": isDeferred,
- "isImplicit": isImplicit,
- "uriOffset": uriOffset,
- "uriEnd": uriEnd,
- "prefixOffset": prefixOffset,
- };
-
- /**
- * URI used in the source code to reference the imported library.
- */
- String get uri => _uri ?? '';
-
- /**
- * If [isImplicit] is false, offset of the "import" keyword. If [isImplicit]
- * is true, zero.
- */
- int get offset => _offset ?? 0;
+abstract class UnlinkedExportPublic extends base.SummaryClass {
/**
- * Index into [UnlinkedUnit.references] of the prefix declared by this
- * import declaration, or zero if this import declaration declares no prefix.
- *
- * Note that multiple imports can declare the same prefix.
+ * URI used in the source code to reference the exported library.
*/
- int get prefixReference => _prefixReference ?? 0;
+ String get uri;
/**
* Combinators contained in this import declaration.
*/
- List<UnlinkedCombinator> get combinators => _combinators ?? const <UnlinkedCombinator>[];
+ List<UnlinkedCombinator> get combinators;
+}
- /**
- * Indicates whether the import declaration uses the `deferred` keyword.
- */
- bool get isDeferred => _isDeferred ?? false;
+class _UnlinkedExportPublicReader extends fb.TableReader<_UnlinkedExportPublicReader> implements UnlinkedExportPublic {
+ final fb.BufferPointer _bp;
- /**
- * Indicates whether the import declaration is implicit.
- */
- bool get isImplicit => _isImplicit ?? false;
+ const _UnlinkedExportPublicReader([this._bp]);
- /**
- * Offset of the URI string (including quotes) relative to the beginning of
- * the file. If [isImplicit] is true, zero.
- */
- int get uriOffset => _uriOffset ?? 0;
+ @override
+ _UnlinkedExportPublicReader createReader(fb.BufferPointer bp) => new _UnlinkedExportPublicReader(bp);
- /**
- * End of the URI string (including quotes) relative to the beginning of the
- * file. If [isImplicit] is true, zero.
- */
- int get uriEnd => _uriEnd ?? 0;
+ @override
+ Map<String, Object> toMap() => {};
- /**
- * Offset of the prefix name relative to the beginning of the file, or zero
- * if there is no prefix.
- */
- int get prefixOffset => _prefixOffset ?? 0;
+ @override
+ String get uri => const fb.StringReader().vTableGet(_bp, 0, '');
+
+ @override
+ List<UnlinkedCombinator> get combinators => const fb.ListReader<UnlinkedCombinator>(const _UnlinkedCombinatorReader()).vTableGet(_bp, 1, const <UnlinkedCombinator>[]);
}
class UnlinkedImportBuilder {
- final Map _json = {};
-
bool _finished = false;
+ String _uri;
+ int _offset;
+ int _prefixReference;
+ List<UnlinkedCombinatorBuilder> _combinators;
+ bool _isDeferred;
+ bool _isImplicit;
+ int _uriOffset;
+ int _uriEnd;
+ int _prefixOffset;
+
+ bool _uriIsSet = false;
+ bool _offsetIsSet = false;
+ bool _prefixReferenceIsSet = false;
+ bool _combinatorsIsSet = false;
+ bool _isDeferredIsSet = false;
+ bool _isImplicitIsSet = false;
+ bool _uriOffsetIsSet = false;
+ bool _uriEndIsSet = false;
+ bool _prefixOffsetIsSet = false;
+
UnlinkedImportBuilder(base.BuilderContext context);
/**
@@ -1717,10 +2091,9 @@ class UnlinkedImportBuilder {
*/
void set uri(String _value) {
assert(!_finished);
- assert(!_json.containsKey("uri"));
- if (_value != null) {
- _json["uri"] = _value;
- }
+ assert(!_uriIsSet);
+ _uriIsSet = true;
+ _uri = _value;
}
/**
@@ -1729,10 +2102,9 @@ class UnlinkedImportBuilder {
*/
void set offset(int _value) {
assert(!_finished);
- assert(!_json.containsKey("offset"));
- if (_value != null) {
- _json["offset"] = _value;
- }
+ assert(!_offsetIsSet);
+ _offsetIsSet = true;
+ _offset = _value;
}
/**
@@ -1743,10 +2115,9 @@ class UnlinkedImportBuilder {
*/
void set prefixReference(int _value) {
assert(!_finished);
- assert(!_json.containsKey("prefixReference"));
- if (_value != null) {
- _json["prefixReference"] = _value;
- }
+ assert(!_prefixReferenceIsSet);
+ _prefixReferenceIsSet = true;
+ _prefixReference = _value;
}
/**
@@ -1754,10 +2125,9 @@ class UnlinkedImportBuilder {
*/
void set combinators(List<UnlinkedCombinatorBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("combinators"));
- if (!(_value == null || _value.isEmpty)) {
- _json["combinators"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_combinatorsIsSet);
+ _combinatorsIsSet = true;
+ _combinators = _value;
}
/**
@@ -1765,10 +2135,9 @@ class UnlinkedImportBuilder {
*/
void set isDeferred(bool _value) {
assert(!_finished);
- assert(!_json.containsKey("isDeferred"));
- if (_value != null) {
- _json["isDeferred"] = _value;
- }
+ assert(!_isDeferredIsSet);
+ _isDeferredIsSet = true;
+ _isDeferred = _value;
}
/**
@@ -1776,10 +2145,9 @@ class UnlinkedImportBuilder {
*/
void set isImplicit(bool _value) {
assert(!_finished);
- assert(!_json.containsKey("isImplicit"));
- if (_value != null) {
- _json["isImplicit"] = _value;
- }
+ assert(!_isImplicitIsSet);
+ _isImplicitIsSet = true;
+ _isImplicit = _value;
}
/**
@@ -1788,10 +2156,9 @@ class UnlinkedImportBuilder {
*/
void set uriOffset(int _value) {
assert(!_finished);
- assert(!_json.containsKey("uriOffset"));
- if (_value != null) {
- _json["uriOffset"] = _value;
- }
+ assert(!_uriOffsetIsSet);
+ _uriOffsetIsSet = true;
+ _uriOffset = _value;
}
/**
@@ -1800,10 +2167,9 @@ class UnlinkedImportBuilder {
*/
void set uriEnd(int _value) {
assert(!_finished);
- assert(!_json.containsKey("uriEnd"));
- if (_value != null) {
- _json["uriEnd"] = _value;
- }
+ assert(!_uriEndIsSet);
+ _uriEndIsSet = true;
+ _uriEnd = _value;
}
/**
@@ -1812,16 +2178,51 @@ class UnlinkedImportBuilder {
*/
void set prefixOffset(int _value) {
assert(!_finished);
- assert(!_json.containsKey("prefixOffset"));
- if (_value != null) {
- _json["prefixOffset"] = _value;
- }
+ assert(!_prefixOffsetIsSet);
+ _prefixOffsetIsSet = true;
+ _prefixOffset = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_uri;
+ fb.Offset offset_combinators;
+ if (_uri != null) {
+ offset_uri = fbBuilder.writeString(_uri);
+ }
+ if (!(_combinators == null || _combinators.isEmpty)) {
+ offset_combinators = fbBuilder.writeList(_combinators.map((b) => b.finish(fbBuilder)).toList());
+ }
+ fbBuilder.startTable();
+ if (offset_uri != null) {
+ fbBuilder.addOffset(0, offset_uri);
+ }
+ if (_offset != null && _offset != 0) {
+ fbBuilder.addInt32(1, _offset);
+ }
+ if (_prefixReference != null && _prefixReference != 0) {
+ fbBuilder.addInt32(2, _prefixReference);
+ }
+ if (offset_combinators != null) {
+ fbBuilder.addOffset(3, offset_combinators);
+ }
+ if (_isDeferred == true) {
+ fbBuilder.addInt8(4, 1);
+ }
+ if (_isImplicit == true) {
+ fbBuilder.addInt8(5, 1);
+ }
+ if (_uriOffset != null && _uriOffset != 0) {
+ fbBuilder.addInt32(6, _uriOffset);
+ }
+ if (_uriEnd != null && _uriEnd != 0) {
+ fbBuilder.addInt32(7, _uriEnd);
+ }
+ if (_prefixOffset != null && _prefixOffset != 0) {
+ fbBuilder.addInt32(8, _prefixOffset);
+ }
+ return fbBuilder.endTable();
}
}
@@ -1840,92 +2241,123 @@ UnlinkedImportBuilder encodeUnlinkedImport(base.BuilderContext builderContext, {
}
/**
- * Unlinked summary information about a function parameter.
+ * Unlinked summary information about an import declaration.
*/
-class UnlinkedParam extends base.SummaryClass {
- String _name;
- int _nameOffset;
- UnlinkedTypeRef _type;
- List<UnlinkedParam> _parameters;
- UnlinkedParamKind _kind;
- bool _isFunctionTyped;
- bool _isInitializingFormal;
- bool _hasImplicitType;
+abstract class UnlinkedImport extends base.SummaryClass {
- UnlinkedParam.fromJson(Map json)
- : _name = json["name"],
- _nameOffset = json["nameOffset"],
- _type = json["type"] == null ? null : new UnlinkedTypeRef.fromJson(json["type"]),
- _parameters = json["parameters"]?.map((x) => new UnlinkedParam.fromJson(x))?.toList(),
- _kind = json["kind"] == null ? null : UnlinkedParamKind.values[json["kind"]],
- _isFunctionTyped = json["isFunctionTyped"],
- _isInitializingFormal = json["isInitializingFormal"],
- _hasImplicitType = json["hasImplicitType"];
-
- @override
- Map<String, Object> toMap() => {
- "name": name,
- "nameOffset": nameOffset,
- "type": type,
- "parameters": parameters,
- "kind": kind,
- "isFunctionTyped": isFunctionTyped,
- "isInitializingFormal": isInitializingFormal,
- "hasImplicitType": hasImplicitType,
- };
+ /**
+ * URI used in the source code to reference the imported library.
+ */
+ String get uri;
/**
- * Name of the parameter.
+ * If [isImplicit] is false, offset of the "import" keyword. If [isImplicit]
+ * is true, zero.
*/
- String get name => _name ?? '';
+ int get offset;
/**
- * Offset of the parameter name relative to the beginning of the file.
+ * Index into [UnlinkedUnit.references] of the prefix declared by this
+ * import declaration, or zero if this import declaration declares no prefix.
+ *
+ * Note that multiple imports can declare the same prefix.
*/
- int get nameOffset => _nameOffset ?? 0;
+ int get prefixReference;
/**
- * If [isFunctionTyped] is `true`, the declared return type. If
- * [isFunctionTyped] is `false`, the declared type. Absent if
- * [isFunctionTyped] is `true` and the declared return type is `void`. Note
- * that when strong mode is enabled, the actual type may be different due to
- * type inference.
+ * Combinators contained in this import declaration.
*/
- UnlinkedTypeRef get type => _type;
+ List<UnlinkedCombinator> get combinators;
/**
- * If [isFunctionTyped] is `true`, the parameters of the function type.
+ * Indicates whether the import declaration uses the `deferred` keyword.
*/
- List<UnlinkedParam> get parameters => _parameters ?? const <UnlinkedParam>[];
+ bool get isDeferred;
/**
- * Kind of the parameter.
+ * Indicates whether the import declaration is implicit.
*/
- UnlinkedParamKind get kind => _kind ?? UnlinkedParamKind.required;
+ bool get isImplicit;
+
+ /**
+ * Offset of the URI string (including quotes) relative to the beginning of
+ * the file. If [isImplicit] is true, zero.
+ */
+ int get uriOffset;
+
+ /**
+ * End of the URI string (including quotes) relative to the beginning of the
+ * file. If [isImplicit] is true, zero.
+ */
+ int get uriEnd;
+
+ /**
+ * Offset of the prefix name relative to the beginning of the file, or zero
+ * if there is no prefix.
+ */
+ int get prefixOffset;
+}
+
+class _UnlinkedImportReader extends fb.TableReader<_UnlinkedImportReader> implements UnlinkedImport {
+ final fb.BufferPointer _bp;
+
+ const _UnlinkedImportReader([this._bp]);
+
+ @override
+ _UnlinkedImportReader createReader(fb.BufferPointer bp) => new _UnlinkedImportReader(bp);
+
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ String get uri => const fb.StringReader().vTableGet(_bp, 0, '');
+
+ @override
+ int get offset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
+
+ @override
+ int get prefixReference => const fb.Int32Reader().vTableGet(_bp, 2, 0);
+
+ @override
+ List<UnlinkedCombinator> get combinators => const fb.ListReader<UnlinkedCombinator>(const _UnlinkedCombinatorReader()).vTableGet(_bp, 3, const <UnlinkedCombinator>[]);
+
+ @override
+ bool get isDeferred => const fb.Int8Reader().vTableGet(_bp, 4, 0) == 1;
+
+ @override
+ bool get isImplicit => const fb.Int8Reader().vTableGet(_bp, 5, 0) == 1;
- /**
- * Indicates whether this is a function-typed parameter.
- */
- bool get isFunctionTyped => _isFunctionTyped ?? false;
+ @override
+ int get uriOffset => const fb.Int32Reader().vTableGet(_bp, 6, 0);
- /**
- * Indicates whether this is an initializing formal parameter (i.e. it is
- * declared using `this.` syntax).
- */
- bool get isInitializingFormal => _isInitializingFormal ?? false;
+ @override
+ int get uriEnd => const fb.Int32Reader().vTableGet(_bp, 7, 0);
- /**
- * Indicates whether this parameter lacks an explicit type declaration.
- * Always false for a function-typed parameter.
- */
- bool get hasImplicitType => _hasImplicitType ?? false;
+ @override
+ int get prefixOffset => const fb.Int32Reader().vTableGet(_bp, 8, 0);
}
class UnlinkedParamBuilder {
- final Map _json = {};
-
bool _finished = false;
+ String _name;
+ int _nameOffset;
+ UnlinkedTypeRefBuilder _type;
+ List<UnlinkedParamBuilder> _parameters;
+ UnlinkedParamKind _kind;
+ bool _isFunctionTyped;
+ bool _isInitializingFormal;
+ bool _hasImplicitType;
+
+ bool _nameIsSet = false;
+ bool _nameOffsetIsSet = false;
+ bool _typeIsSet = false;
+ bool _parametersIsSet = false;
+ bool _kindIsSet = false;
+ bool _isFunctionTypedIsSet = false;
+ bool _isInitializingFormalIsSet = false;
+ bool _hasImplicitTypeIsSet = false;
+
UnlinkedParamBuilder(base.BuilderContext context);
/**
@@ -1933,10 +2365,9 @@ class UnlinkedParamBuilder {
*/
void set name(String _value) {
assert(!_finished);
- assert(!_json.containsKey("name"));
- if (_value != null) {
- _json["name"] = _value;
- }
+ assert(!_nameIsSet);
+ _nameIsSet = true;
+ _name = _value;
}
/**
@@ -1944,10 +2375,9 @@ class UnlinkedParamBuilder {
*/
void set nameOffset(int _value) {
assert(!_finished);
- assert(!_json.containsKey("nameOffset"));
- if (_value != null) {
- _json["nameOffset"] = _value;
- }
+ assert(!_nameOffsetIsSet);
+ _nameOffsetIsSet = true;
+ _nameOffset = _value;
}
/**
@@ -1959,10 +2389,9 @@ class UnlinkedParamBuilder {
*/
void set type(UnlinkedTypeRefBuilder _value) {
assert(!_finished);
- assert(!_json.containsKey("type"));
- if (_value != null) {
- _json["type"] = _value.finish();
- }
+ assert(!_typeIsSet);
+ _typeIsSet = true;
+ _type = _value;
}
/**
@@ -1970,10 +2399,9 @@ class UnlinkedParamBuilder {
*/
void set parameters(List<UnlinkedParamBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("parameters"));
- if (!(_value == null || _value.isEmpty)) {
- _json["parameters"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_parametersIsSet);
+ _parametersIsSet = true;
+ _parameters = _value;
}
/**
@@ -1981,10 +2409,9 @@ class UnlinkedParamBuilder {
*/
void set kind(UnlinkedParamKind _value) {
assert(!_finished);
- assert(!_json.containsKey("kind"));
- if (!(_value == null || _value == UnlinkedParamKind.required)) {
- _json["kind"] = _value.index;
- }
+ assert(!_kindIsSet);
+ _kindIsSet = true;
+ _kind = _value;
}
/**
@@ -1992,10 +2419,9 @@ class UnlinkedParamBuilder {
*/
void set isFunctionTyped(bool _value) {
assert(!_finished);
- assert(!_json.containsKey("isFunctionTyped"));
- if (_value != null) {
- _json["isFunctionTyped"] = _value;
- }
+ assert(!_isFunctionTypedIsSet);
+ _isFunctionTypedIsSet = true;
+ _isFunctionTyped = _value;
}
/**
@@ -2004,10 +2430,9 @@ class UnlinkedParamBuilder {
*/
void set isInitializingFormal(bool _value) {
assert(!_finished);
- assert(!_json.containsKey("isInitializingFormal"));
- if (_value != null) {
- _json["isInitializingFormal"] = _value;
- }
+ assert(!_isInitializingFormalIsSet);
+ _isInitializingFormalIsSet = true;
+ _isInitializingFormal = _value;
}
/**
@@ -2016,16 +2441,52 @@ class UnlinkedParamBuilder {
*/
void set hasImplicitType(bool _value) {
assert(!_finished);
- assert(!_json.containsKey("hasImplicitType"));
- if (_value != null) {
- _json["hasImplicitType"] = _value;
- }
+ assert(!_hasImplicitTypeIsSet);
+ _hasImplicitTypeIsSet = true;
+ _hasImplicitType = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_name;
+ fb.Offset offset_type;
+ fb.Offset offset_parameters;
+ if (_name != null) {
+ offset_name = fbBuilder.writeString(_name);
+ }
+ if (_type != null) {
+ offset_type = _type.finish(fbBuilder);
+ }
+ if (!(_parameters == null || _parameters.isEmpty)) {
+ offset_parameters = fbBuilder.writeList(_parameters.map((b) => b.finish(fbBuilder)).toList());
+ }
+ fbBuilder.startTable();
+ if (offset_name != null) {
+ fbBuilder.addOffset(0, offset_name);
+ }
+ if (_nameOffset != null && _nameOffset != 0) {
+ fbBuilder.addInt32(1, _nameOffset);
+ }
+ if (offset_type != null) {
+ fbBuilder.addOffset(2, offset_type);
+ }
+ if (offset_parameters != null) {
+ fbBuilder.addOffset(3, offset_parameters);
+ }
+ if (_kind != null && _kind != UnlinkedParamKind.required) {
+ fbBuilder.addInt32(4, _kind.index);
+ }
+ if (_isFunctionTyped == true) {
+ fbBuilder.addInt8(5, 1);
+ }
+ if (_isInitializingFormal == true) {
+ fbBuilder.addInt8(6, 1);
+ }
+ if (_hasImplicitType == true) {
+ fbBuilder.addInt8(7, 1);
+ }
+ return fbBuilder.endTable();
}
}
@@ -2043,40 +2504,105 @@ UnlinkedParamBuilder encodeUnlinkedParam(base.BuilderContext builderContext, {St
}
/**
- * Unlinked summary information about a part declaration.
+ * Unlinked summary information about a function parameter.
*/
-class UnlinkedPart extends base.SummaryClass {
- int _uriOffset;
- int _uriEnd;
+abstract class UnlinkedParam extends base.SummaryClass {
- UnlinkedPart.fromJson(Map json)
- : _uriOffset = json["uriOffset"],
- _uriEnd = json["uriEnd"];
+ /**
+ * Name of the parameter.
+ */
+ String get name;
- @override
- Map<String, Object> toMap() => {
- "uriOffset": uriOffset,
- "uriEnd": uriEnd,
- };
+ /**
+ * Offset of the parameter name relative to the beginning of the file.
+ */
+ int get nameOffset;
/**
- * Offset of the URI string (including quotes) relative to the beginning of
- * the file.
+ * If [isFunctionTyped] is `true`, the declared return type. If
+ * [isFunctionTyped] is `false`, the declared type. Absent if
+ * [isFunctionTyped] is `true` and the declared return type is `void`. Note
+ * that when strong mode is enabled, the actual type may be different due to
+ * type inference.
*/
- int get uriOffset => _uriOffset ?? 0;
+ UnlinkedTypeRef get type;
/**
- * End of the URI string (including quotes) relative to the beginning of the
- * file.
+ * If [isFunctionTyped] is `true`, the parameters of the function type.
+ */
+ List<UnlinkedParam> get parameters;
+
+ /**
+ * Kind of the parameter.
+ */
+ UnlinkedParamKind get kind;
+
+ /**
+ * Indicates whether this is a function-typed parameter.
+ */
+ bool get isFunctionTyped;
+
+ /**
+ * Indicates whether this is an initializing formal parameter (i.e. it is
+ * declared using `this.` syntax).
+ */
+ bool get isInitializingFormal;
+
+ /**
+ * Indicates whether this parameter lacks an explicit type declaration.
+ * Always false for a function-typed parameter.
*/
- int get uriEnd => _uriEnd ?? 0;
+ bool get hasImplicitType;
}
-class UnlinkedPartBuilder {
- final Map _json = {};
+class _UnlinkedParamReader extends fb.TableReader<_UnlinkedParamReader> implements UnlinkedParam {
+ final fb.BufferPointer _bp;
+
+ const _UnlinkedParamReader([this._bp]);
+
+ @override
+ _UnlinkedParamReader createReader(fb.BufferPointer bp) => new _UnlinkedParamReader(bp);
+
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ String get name => const fb.StringReader().vTableGet(_bp, 0, '');
+
+ @override
+ int get nameOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
+
+ @override
+ UnlinkedTypeRef get type => const _UnlinkedTypeRefReader().vTableGet(_bp, 2, null);
+
+ @override
+ List<UnlinkedParam> get parameters => const fb.ListReader<UnlinkedParam>(const _UnlinkedParamReader()).vTableGet(_bp, 3, const <UnlinkedParam>[]);
+
+ @override
+ UnlinkedParamKind get kind {
+ int index = const fb.Int32Reader().vTableGet(_bp, 4, 0);
+ return UnlinkedParamKind.values[index];
+ }
+
+ @override
+ bool get isFunctionTyped => const fb.Int8Reader().vTableGet(_bp, 5, 0) == 1;
+
+ @override
+ bool get isInitializingFormal => const fb.Int8Reader().vTableGet(_bp, 6, 0) == 1;
+
+ @override
+ bool get hasImplicitType => const fb.Int8Reader().vTableGet(_bp, 7, 0) == 1;
+}
+class UnlinkedPartBuilder {
bool _finished = false;
+ int _uriOffset;
+ int _uriEnd;
+
+ bool _uriOffsetIsSet = false;
+ bool _uriEndIsSet = false;
+
UnlinkedPartBuilder(base.BuilderContext context);
/**
@@ -2085,10 +2611,9 @@ class UnlinkedPartBuilder {
*/
void set uriOffset(int _value) {
assert(!_finished);
- assert(!_json.containsKey("uriOffset"));
- if (_value != null) {
- _json["uriOffset"] = _value;
- }
+ assert(!_uriOffsetIsSet);
+ _uriOffsetIsSet = true;
+ _uriOffset = _value;
}
/**
@@ -2097,16 +2622,22 @@ class UnlinkedPartBuilder {
*/
void set uriEnd(int _value) {
assert(!_finished);
- assert(!_json.containsKey("uriEnd"));
- if (_value != null) {
- _json["uriEnd"] = _value;
- }
+ assert(!_uriEndIsSet);
+ _uriEndIsSet = true;
+ _uriEnd = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fbBuilder.startTable();
+ if (_uriOffset != null && _uriOffset != 0) {
+ fbBuilder.addInt32(0, _uriOffset);
+ }
+ if (_uriEnd != null && _uriEnd != 0) {
+ fbBuilder.addInt32(1, _uriEnd);
+ }
+ return fbBuilder.endTable();
}
}
@@ -2118,58 +2649,52 @@ UnlinkedPartBuilder encodeUnlinkedPart(base.BuilderContext builderContext, {int
}
/**
- * Unlinked summary information about a specific name contributed by a
- * compilation unit to a library's public namespace.
- *
- * TODO(paulberry): add a count of generic parameters, so that resynthesis
- * doesn't have to peek into the library to obtain this info.
- *
- * TODO(paulberry): for classes, add info about static members and
- * constructors, since this will be needed to prelink info about constants.
- *
- * TODO(paulberry): some of this information is redundant with information
- * elsewhere in the summary. Consider reducing the redundancy to reduce
- * summary size.
+ * Unlinked summary information about a part declaration.
*/
-class UnlinkedPublicName extends base.SummaryClass {
- String _name;
- PrelinkedReferenceKind _kind;
- int _numTypeParameters;
-
- UnlinkedPublicName.fromJson(Map json)
- : _name = json["name"],
- _kind = json["kind"] == null ? null : PrelinkedReferenceKind.values[json["kind"]],
- _numTypeParameters = json["numTypeParameters"];
-
- @override
- Map<String, Object> toMap() => {
- "name": name,
- "kind": kind,
- "numTypeParameters": numTypeParameters,
- };
+abstract class UnlinkedPart extends base.SummaryClass {
/**
- * The name itself.
+ * Offset of the URI string (including quotes) relative to the beginning of
+ * the file.
*/
- String get name => _name ?? '';
+ int get uriOffset;
/**
- * The kind of object referred to by the name.
+ * End of the URI string (including quotes) relative to the beginning of the
+ * file.
*/
- PrelinkedReferenceKind get kind => _kind ?? PrelinkedReferenceKind.classOrEnum;
+ int get uriEnd;
+}
- /**
- * If the entity being referred to is generic, the number of type parameters
- * it accepts. Otherwise zero.
- */
- int get numTypeParameters => _numTypeParameters ?? 0;
+class _UnlinkedPartReader extends fb.TableReader<_UnlinkedPartReader> implements UnlinkedPart {
+ final fb.BufferPointer _bp;
+
+ const _UnlinkedPartReader([this._bp]);
+
+ @override
+ _UnlinkedPartReader createReader(fb.BufferPointer bp) => new _UnlinkedPartReader(bp);
+
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ int get uriOffset => const fb.Int32Reader().vTableGet(_bp, 0, 0);
+
+ @override
+ int get uriEnd => const fb.Int32Reader().vTableGet(_bp, 1, 0);
}
class UnlinkedPublicNameBuilder {
- final Map _json = {};
-
bool _finished = false;
+ String _name;
+ PrelinkedReferenceKind _kind;
+ int _numTypeParameters;
+
+ bool _nameIsSet = false;
+ bool _kindIsSet = false;
+ bool _numTypeParametersIsSet = false;
+
UnlinkedPublicNameBuilder(base.BuilderContext context);
/**
@@ -2177,10 +2702,9 @@ class UnlinkedPublicNameBuilder {
*/
void set name(String _value) {
assert(!_finished);
- assert(!_json.containsKey("name"));
- if (_value != null) {
- _json["name"] = _value;
- }
+ assert(!_nameIsSet);
+ _nameIsSet = true;
+ _name = _value;
}
/**
@@ -2188,10 +2712,9 @@ class UnlinkedPublicNameBuilder {
*/
void set kind(PrelinkedReferenceKind _value) {
assert(!_finished);
- assert(!_json.containsKey("kind"));
- if (!(_value == null || _value == PrelinkedReferenceKind.classOrEnum)) {
- _json["kind"] = _value.index;
- }
+ assert(!_kindIsSet);
+ _kindIsSet = true;
+ _kind = _value;
}
/**
@@ -2200,16 +2723,29 @@ class UnlinkedPublicNameBuilder {
*/
void set numTypeParameters(int _value) {
assert(!_finished);
- assert(!_json.containsKey("numTypeParameters"));
- if (_value != null) {
- _json["numTypeParameters"] = _value;
- }
+ assert(!_numTypeParametersIsSet);
+ _numTypeParametersIsSet = true;
+ _numTypeParameters = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_name;
+ if (_name != null) {
+ offset_name = fbBuilder.writeString(_name);
+ }
+ fbBuilder.startTable();
+ if (offset_name != null) {
+ fbBuilder.addOffset(0, offset_name);
+ }
+ if (_kind != null && _kind != PrelinkedReferenceKind.classOrEnum) {
+ fbBuilder.addInt32(1, _kind.index);
+ }
+ if (_numTypeParameters != null && _numTypeParameters != 0) {
+ fbBuilder.addInt32(2, _numTypeParameters);
+ }
+ return fbBuilder.endTable();
}
}
@@ -2222,53 +2758,73 @@ UnlinkedPublicNameBuilder encodeUnlinkedPublicName(base.BuilderContext builderCo
}
/**
- * Unlinked summary information about what a compilation unit contributes to a
- * library's public namespace. This is the subset of [UnlinkedUnit] that is
- * required from dependent libraries in order to perform prelinking.
+ * Unlinked summary information about a specific name contributed by a
+ * compilation unit to a library's public namespace.
+ *
+ * TODO(paulberry): add a count of generic parameters, so that resynthesis
+ * doesn't have to peek into the library to obtain this info.
+ *
+ * TODO(paulberry): for classes, add info about static members and
+ * constructors, since this will be needed to prelink info about constants.
+ *
+ * TODO(paulberry): some of this information is redundant with information
+ * elsewhere in the summary. Consider reducing the redundancy to reduce
+ * summary size.
*/
-class UnlinkedPublicNamespace extends base.SummaryClass {
- List<UnlinkedPublicName> _names;
- List<UnlinkedExportPublic> _exports;
- List<String> _parts;
-
- UnlinkedPublicNamespace.fromJson(Map json)
- : _names = json["names"]?.map((x) => new UnlinkedPublicName.fromJson(x))?.toList(),
- _exports = json["exports"]?.map((x) => new UnlinkedExportPublic.fromJson(x))?.toList(),
- _parts = json["parts"];
-
- @override
- Map<String, Object> toMap() => {
- "names": names,
- "exports": exports,
- "parts": parts,
- };
-
- UnlinkedPublicNamespace.fromBuffer(List<int> buffer) : this.fromJson(JSON.decode(UTF8.decode(buffer)));
+abstract class UnlinkedPublicName extends base.SummaryClass {
/**
- * Public names defined in the compilation unit.
- *
- * TODO(paulberry): consider sorting these names to reduce unnecessary
- * relinking.
+ * The name itself.
*/
- List<UnlinkedPublicName> get names => _names ?? const <UnlinkedPublicName>[];
+ String get name;
/**
- * Export declarations in the compilation unit.
+ * The kind of object referred to by the name.
*/
- List<UnlinkedExportPublic> get exports => _exports ?? const <UnlinkedExportPublic>[];
+ PrelinkedReferenceKind get kind;
/**
- * URIs referenced by part declarations in the compilation unit.
+ * If the entity being referred to is generic, the number of type parameters
+ * it accepts. Otherwise zero.
*/
- List<String> get parts => _parts ?? const <String>[];
+ int get numTypeParameters;
}
-class UnlinkedPublicNamespaceBuilder {
- final Map _json = {};
+class _UnlinkedPublicNameReader extends fb.TableReader<_UnlinkedPublicNameReader> implements UnlinkedPublicName {
+ final fb.BufferPointer _bp;
+
+ const _UnlinkedPublicNameReader([this._bp]);
+
+ @override
+ _UnlinkedPublicNameReader createReader(fb.BufferPointer bp) => new _UnlinkedPublicNameReader(bp);
+
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ String get name => const fb.StringReader().vTableGet(_bp, 0, '');
+
+ @override
+ PrelinkedReferenceKind get kind {
+ int index = const fb.Int32Reader().vTableGet(_bp, 1, 0);
+ return PrelinkedReferenceKind.values[index];
+ }
+
+ @override
+ int get numTypeParameters => const fb.Int32Reader().vTableGet(_bp, 2, 0);
+}
+class UnlinkedPublicNamespaceBuilder {
bool _finished = false;
+ List<UnlinkedPublicNameBuilder> _names;
+ List<UnlinkedExportPublicBuilder> _exports;
+ List<String> _parts;
+
+ bool _namesIsSet = false;
+ bool _exportsIsSet = false;
+ bool _partsIsSet = false;
+
UnlinkedPublicNamespaceBuilder(base.BuilderContext context);
/**
@@ -2279,10 +2835,9 @@ class UnlinkedPublicNamespaceBuilder {
*/
void set names(List<UnlinkedPublicNameBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("names"));
- if (!(_value == null || _value.isEmpty)) {
- _json["names"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_namesIsSet);
+ _namesIsSet = true;
+ _names = _value;
}
/**
@@ -2290,10 +2845,9 @@ class UnlinkedPublicNamespaceBuilder {
*/
void set exports(List<UnlinkedExportPublicBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("exports"));
- if (!(_value == null || _value.isEmpty)) {
- _json["exports"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_exportsIsSet);
+ _exportsIsSet = true;
+ _exports = _value;
}
/**
@@ -2301,18 +2855,42 @@ class UnlinkedPublicNamespaceBuilder {
*/
void set parts(List<String> _value) {
assert(!_finished);
- assert(!_json.containsKey("parts"));
- if (!(_value == null || _value.isEmpty)) {
- _json["parts"] = _value.toList();
- }
+ assert(!_partsIsSet);
+ _partsIsSet = true;
+ _parts = _value;
}
- List<int> toBuffer() => UTF8.encode(JSON.encode(finish()));
+ List<int> toBuffer() {
+ fb.Builder fbBuilder = new fb.Builder();
+ return fbBuilder.finish(finish(fbBuilder));
+ }
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_names;
+ fb.Offset offset_exports;
+ fb.Offset offset_parts;
+ if (!(_names == null || _names.isEmpty)) {
+ offset_names = fbBuilder.writeList(_names.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (!(_exports == null || _exports.isEmpty)) {
+ offset_exports = fbBuilder.writeList(_exports.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (!(_parts == null || _parts.isEmpty)) {
+ offset_parts = fbBuilder.writeList(_parts.map((b) => fbBuilder.writeString(b)).toList());
+ }
+ fbBuilder.startTable();
+ if (offset_names != null) {
+ fbBuilder.addOffset(0, offset_names);
+ }
+ if (offset_exports != null) {
+ fbBuilder.addOffset(1, offset_exports);
+ }
+ if (offset_parts != null) {
+ fbBuilder.addOffset(2, offset_parts);
+ }
+ return fbBuilder.endTable();
}
}
@@ -2325,41 +2903,65 @@ UnlinkedPublicNamespaceBuilder encodeUnlinkedPublicNamespace(base.BuilderContext
}
/**
- * Unlinked summary information about a name referred to in one library that
- * might be defined in another.
+ * Unlinked summary information about what a compilation unit contributes to a
+ * library's public namespace. This is the subset of [UnlinkedUnit] that is
+ * required from dependent libraries in order to perform prelinking.
*/
-class UnlinkedReference extends base.SummaryClass {
- String _name;
- int _prefixReference;
-
- UnlinkedReference.fromJson(Map json)
- : _name = json["name"],
- _prefixReference = json["prefixReference"];
+abstract class UnlinkedPublicNamespace extends base.SummaryClass {
+ factory UnlinkedPublicNamespace.fromBuffer(List<int> buffer) {
+ fb.BufferPointer rootRef = new fb.BufferPointer.fromBytes(buffer);
+ return const _UnlinkedPublicNamespaceReader().read(rootRef);
+ }
- @override
- Map<String, Object> toMap() => {
- "name": name,
- "prefixReference": prefixReference,
- };
+ /**
+ * Public names defined in the compilation unit.
+ *
+ * TODO(paulberry): consider sorting these names to reduce unnecessary
+ * relinking.
+ */
+ List<UnlinkedPublicName> get names;
/**
- * Name of the entity being referred to. The empty string refers to the
- * pseudo-type `dynamic`.
+ * Export declarations in the compilation unit.
*/
- String get name => _name ?? '';
+ List<UnlinkedExportPublic> get exports;
/**
- * Prefix used to refer to the entity, or zero if no prefix is used. This is
- * an index into [UnlinkedUnit.references].
+ * URIs referenced by part declarations in the compilation unit.
*/
- int get prefixReference => _prefixReference ?? 0;
+ List<String> get parts;
+}
+
+class _UnlinkedPublicNamespaceReader extends fb.TableReader<_UnlinkedPublicNamespaceReader> implements UnlinkedPublicNamespace {
+ final fb.BufferPointer _bp;
+
+ const _UnlinkedPublicNamespaceReader([this._bp]);
+
+ @override
+ _UnlinkedPublicNamespaceReader createReader(fb.BufferPointer bp) => new _UnlinkedPublicNamespaceReader(bp);
+
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ List<UnlinkedPublicName> get names => const fb.ListReader<UnlinkedPublicName>(const _UnlinkedPublicNameReader()).vTableGet(_bp, 0, const <UnlinkedPublicName>[]);
+
+ @override
+ List<UnlinkedExportPublic> get exports => const fb.ListReader<UnlinkedExportPublic>(const _UnlinkedExportPublicReader()).vTableGet(_bp, 1, const <UnlinkedExportPublic>[]);
+
+ @override
+ List<String> get parts => const fb.ListReader<String>(const fb.StringReader()).vTableGet(_bp, 2, const <String>[]);
}
class UnlinkedReferenceBuilder {
- final Map _json = {};
-
bool _finished = false;
+ String _name;
+ int _prefixReference;
+
+ bool _nameIsSet = false;
+ bool _prefixReferenceIsSet = false;
+
UnlinkedReferenceBuilder(base.BuilderContext context);
/**
@@ -2368,10 +2970,9 @@ class UnlinkedReferenceBuilder {
*/
void set name(String _value) {
assert(!_finished);
- assert(!_json.containsKey("name"));
- if (_value != null) {
- _json["name"] = _value;
- }
+ assert(!_nameIsSet);
+ _nameIsSet = true;
+ _name = _value;
}
/**
@@ -2380,16 +2981,26 @@ class UnlinkedReferenceBuilder {
*/
void set prefixReference(int _value) {
assert(!_finished);
- assert(!_json.containsKey("prefixReference"));
- if (_value != null) {
- _json["prefixReference"] = _value;
- }
+ assert(!_prefixReferenceIsSet);
+ _prefixReferenceIsSet = true;
+ _prefixReference = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_name;
+ if (_name != null) {
+ offset_name = fbBuilder.writeString(_name);
+ }
+ fbBuilder.startTable();
+ if (offset_name != null) {
+ fbBuilder.addOffset(0, offset_name);
+ }
+ if (_prefixReference != null && _prefixReference != 0) {
+ fbBuilder.addInt32(1, _prefixReference);
+ }
+ return fbBuilder.endTable();
}
}
@@ -2401,71 +3012,59 @@ UnlinkedReferenceBuilder encodeUnlinkedReference(base.BuilderContext builderCont
}
/**
- * Unlinked summary information about a typedef declaration.
+ * Unlinked summary information about a name referred to in one library that
+ * might be defined in another.
*/
-class UnlinkedTypedef extends base.SummaryClass {
- String _name;
- int _nameOffset;
- UnlinkedDocumentationComment _documentationComment;
- List<UnlinkedTypeParam> _typeParameters;
- UnlinkedTypeRef _returnType;
- List<UnlinkedParam> _parameters;
-
- UnlinkedTypedef.fromJson(Map json)
- : _name = json["name"],
- _nameOffset = json["nameOffset"],
- _documentationComment = json["documentationComment"] == null ? null : new UnlinkedDocumentationComment.fromJson(json["documentationComment"]),
- _typeParameters = json["typeParameters"]?.map((x) => new UnlinkedTypeParam.fromJson(x))?.toList(),
- _returnType = json["returnType"] == null ? null : new UnlinkedTypeRef.fromJson(json["returnType"]),
- _parameters = json["parameters"]?.map((x) => new UnlinkedParam.fromJson(x))?.toList();
-
- @override
- Map<String, Object> toMap() => {
- "name": name,
- "nameOffset": nameOffset,
- "documentationComment": documentationComment,
- "typeParameters": typeParameters,
- "returnType": returnType,
- "parameters": parameters,
- };
+abstract class UnlinkedReference extends base.SummaryClass {
/**
- * Name of the typedef.
+ * Name of the entity being referred to. The empty string refers to the
+ * pseudo-type `dynamic`.
*/
- String get name => _name ?? '';
+ String get name;
/**
- * Offset of the typedef name relative to the beginning of the file.
+ * Prefix used to refer to the entity, or zero if no prefix is used. This is
+ * an index into [UnlinkedUnit.references].
*/
- int get nameOffset => _nameOffset ?? 0;
+ int get prefixReference;
+}
- /**
- * Documentation comment for the typedef, or `null` if there is no
- * documentation comment.
- */
- UnlinkedDocumentationComment get documentationComment => _documentationComment;
+class _UnlinkedReferenceReader extends fb.TableReader<_UnlinkedReferenceReader> implements UnlinkedReference {
+ final fb.BufferPointer _bp;
- /**
- * Type parameters of the typedef, if any.
- */
- List<UnlinkedTypeParam> get typeParameters => _typeParameters ?? const <UnlinkedTypeParam>[];
+ const _UnlinkedReferenceReader([this._bp]);
- /**
- * Return type of the typedef. Absent if the return type is `void`.
- */
- UnlinkedTypeRef get returnType => _returnType;
+ @override
+ _UnlinkedReferenceReader createReader(fb.BufferPointer bp) => new _UnlinkedReferenceReader(bp);
- /**
- * Parameters of the executable, if any.
- */
- List<UnlinkedParam> get parameters => _parameters ?? const <UnlinkedParam>[];
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ String get name => const fb.StringReader().vTableGet(_bp, 0, '');
+
+ @override
+ int get prefixReference => const fb.Int32Reader().vTableGet(_bp, 1, 0);
}
class UnlinkedTypedefBuilder {
- final Map _json = {};
-
bool _finished = false;
+ String _name;
+ int _nameOffset;
+ UnlinkedDocumentationCommentBuilder _documentationComment;
+ List<UnlinkedTypeParamBuilder> _typeParameters;
+ UnlinkedTypeRefBuilder _returnType;
+ List<UnlinkedParamBuilder> _parameters;
+
+ bool _nameIsSet = false;
+ bool _nameOffsetIsSet = false;
+ bool _documentationCommentIsSet = false;
+ bool _typeParametersIsSet = false;
+ bool _returnTypeIsSet = false;
+ bool _parametersIsSet = false;
+
UnlinkedTypedefBuilder(base.BuilderContext context);
/**
@@ -2473,10 +3072,9 @@ class UnlinkedTypedefBuilder {
*/
void set name(String _value) {
assert(!_finished);
- assert(!_json.containsKey("name"));
- if (_value != null) {
- _json["name"] = _value;
- }
+ assert(!_nameIsSet);
+ _nameIsSet = true;
+ _name = _value;
}
/**
@@ -2484,10 +3082,9 @@ class UnlinkedTypedefBuilder {
*/
void set nameOffset(int _value) {
assert(!_finished);
- assert(!_json.containsKey("nameOffset"));
- if (_value != null) {
- _json["nameOffset"] = _value;
- }
+ assert(!_nameOffsetIsSet);
+ _nameOffsetIsSet = true;
+ _nameOffset = _value;
}
/**
@@ -2496,10 +3093,9 @@ class UnlinkedTypedefBuilder {
*/
void set documentationComment(UnlinkedDocumentationCommentBuilder _value) {
assert(!_finished);
- assert(!_json.containsKey("documentationComment"));
- if (_value != null) {
- _json["documentationComment"] = _value.finish();
- }
+ assert(!_documentationCommentIsSet);
+ _documentationCommentIsSet = true;
+ _documentationComment = _value;
}
/**
@@ -2507,10 +3103,9 @@ class UnlinkedTypedefBuilder {
*/
void set typeParameters(List<UnlinkedTypeParamBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("typeParameters"));
- if (!(_value == null || _value.isEmpty)) {
- _json["typeParameters"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_typeParametersIsSet);
+ _typeParametersIsSet = true;
+ _typeParameters = _value;
}
/**
@@ -2518,10 +3113,9 @@ class UnlinkedTypedefBuilder {
*/
void set returnType(UnlinkedTypeRefBuilder _value) {
assert(!_finished);
- assert(!_json.containsKey("returnType"));
- if (_value != null) {
- _json["returnType"] = _value.finish();
- }
+ assert(!_returnTypeIsSet);
+ _returnTypeIsSet = true;
+ _returnType = _value;
}
/**
@@ -2529,16 +3123,54 @@ class UnlinkedTypedefBuilder {
*/
void set parameters(List<UnlinkedParamBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("parameters"));
- if (!(_value == null || _value.isEmpty)) {
- _json["parameters"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_parametersIsSet);
+ _parametersIsSet = true;
+ _parameters = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_name;
+ fb.Offset offset_documentationComment;
+ fb.Offset offset_typeParameters;
+ fb.Offset offset_returnType;
+ fb.Offset offset_parameters;
+ if (_name != null) {
+ offset_name = fbBuilder.writeString(_name);
+ }
+ if (_documentationComment != null) {
+ offset_documentationComment = _documentationComment.finish(fbBuilder);
+ }
+ if (!(_typeParameters == null || _typeParameters.isEmpty)) {
+ offset_typeParameters = fbBuilder.writeList(_typeParameters.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (_returnType != null) {
+ offset_returnType = _returnType.finish(fbBuilder);
+ }
+ if (!(_parameters == null || _parameters.isEmpty)) {
+ offset_parameters = fbBuilder.writeList(_parameters.map((b) => b.finish(fbBuilder)).toList());
+ }
+ fbBuilder.startTable();
+ if (offset_name != null) {
+ fbBuilder.addOffset(0, offset_name);
+ }
+ if (_nameOffset != null && _nameOffset != 0) {
+ fbBuilder.addInt32(1, _nameOffset);
+ }
+ if (offset_documentationComment != null) {
+ fbBuilder.addOffset(2, offset_documentationComment);
+ }
+ if (offset_typeParameters != null) {
+ fbBuilder.addOffset(3, offset_typeParameters);
+ }
+ if (offset_returnType != null) {
+ fbBuilder.addOffset(4, offset_returnType);
+ }
+ if (offset_parameters != null) {
+ fbBuilder.addOffset(5, offset_parameters);
+ }
+ return fbBuilder.endTable();
}
}
@@ -2554,47 +3186,83 @@ UnlinkedTypedefBuilder encodeUnlinkedTypedef(base.BuilderContext builderContext,
}
/**
- * Unlinked summary information about a type parameter declaration.
+ * Unlinked summary information about a typedef declaration.
*/
-class UnlinkedTypeParam extends base.SummaryClass {
- String _name;
- int _nameOffset;
- UnlinkedTypeRef _bound;
+abstract class UnlinkedTypedef extends base.SummaryClass {
- UnlinkedTypeParam.fromJson(Map json)
- : _name = json["name"],
- _nameOffset = json["nameOffset"],
- _bound = json["bound"] == null ? null : new UnlinkedTypeRef.fromJson(json["bound"]);
+ /**
+ * Name of the typedef.
+ */
+ String get name;
- @override
- Map<String, Object> toMap() => {
- "name": name,
- "nameOffset": nameOffset,
- "bound": bound,
- };
+ /**
+ * Offset of the typedef name relative to the beginning of the file.
+ */
+ int get nameOffset;
/**
- * Name of the type parameter.
+ * Documentation comment for the typedef, or `null` if there is no
+ * documentation comment.
*/
- String get name => _name ?? '';
+ UnlinkedDocumentationComment get documentationComment;
/**
- * Offset of the type parameter name relative to the beginning of the file.
+ * Type parameters of the typedef, if any.
*/
- int get nameOffset => _nameOffset ?? 0;
+ List<UnlinkedTypeParam> get typeParameters;
/**
- * Bound of the type parameter, if a bound is explicitly declared. Otherwise
- * null.
+ * Return type of the typedef. Absent if the return type is `void`.
+ */
+ UnlinkedTypeRef get returnType;
+
+ /**
+ * Parameters of the executable, if any.
*/
- UnlinkedTypeRef get bound => _bound;
+ List<UnlinkedParam> get parameters;
}
-class UnlinkedTypeParamBuilder {
- final Map _json = {};
+class _UnlinkedTypedefReader extends fb.TableReader<_UnlinkedTypedefReader> implements UnlinkedTypedef {
+ final fb.BufferPointer _bp;
+
+ const _UnlinkedTypedefReader([this._bp]);
+
+ @override
+ _UnlinkedTypedefReader createReader(fb.BufferPointer bp) => new _UnlinkedTypedefReader(bp);
+
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ String get name => const fb.StringReader().vTableGet(_bp, 0, '');
+ @override
+ int get nameOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
+
+ @override
+ UnlinkedDocumentationComment get documentationComment => const _UnlinkedDocumentationCommentReader().vTableGet(_bp, 2, null);
+
+ @override
+ List<UnlinkedTypeParam> get typeParameters => const fb.ListReader<UnlinkedTypeParam>(const _UnlinkedTypeParamReader()).vTableGet(_bp, 3, const <UnlinkedTypeParam>[]);
+
+ @override
+ UnlinkedTypeRef get returnType => const _UnlinkedTypeRefReader().vTableGet(_bp, 4, null);
+
+ @override
+ List<UnlinkedParam> get parameters => const fb.ListReader<UnlinkedParam>(const _UnlinkedParamReader()).vTableGet(_bp, 5, const <UnlinkedParam>[]);
+}
+
+class UnlinkedTypeParamBuilder {
bool _finished = false;
+ String _name;
+ int _nameOffset;
+ UnlinkedTypeRefBuilder _bound;
+
+ bool _nameIsSet = false;
+ bool _nameOffsetIsSet = false;
+ bool _boundIsSet = false;
+
UnlinkedTypeParamBuilder(base.BuilderContext context);
/**
@@ -2602,10 +3270,9 @@ class UnlinkedTypeParamBuilder {
*/
void set name(String _value) {
assert(!_finished);
- assert(!_json.containsKey("name"));
- if (_value != null) {
- _json["name"] = _value;
- }
+ assert(!_nameIsSet);
+ _nameIsSet = true;
+ _name = _value;
}
/**
@@ -2613,10 +3280,9 @@ class UnlinkedTypeParamBuilder {
*/
void set nameOffset(int _value) {
assert(!_finished);
- assert(!_json.containsKey("nameOffset"));
- if (_value != null) {
- _json["nameOffset"] = _value;
- }
+ assert(!_nameOffsetIsSet);
+ _nameOffsetIsSet = true;
+ _nameOffset = _value;
}
/**
@@ -2625,16 +3291,33 @@ class UnlinkedTypeParamBuilder {
*/
void set bound(UnlinkedTypeRefBuilder _value) {
assert(!_finished);
- assert(!_json.containsKey("bound"));
- if (_value != null) {
- _json["bound"] = _value.finish();
- }
+ assert(!_boundIsSet);
+ _boundIsSet = true;
+ _bound = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_name;
+ fb.Offset offset_bound;
+ if (_name != null) {
+ offset_name = fbBuilder.writeString(_name);
+ }
+ if (_bound != null) {
+ offset_bound = _bound.finish(fbBuilder);
+ }
+ fbBuilder.startTable();
+ if (offset_name != null) {
+ fbBuilder.addOffset(0, offset_name);
+ }
+ if (_nameOffset != null && _nameOffset != 0) {
+ fbBuilder.addInt32(1, _nameOffset);
+ }
+ if (offset_bound != null) {
+ fbBuilder.addOffset(2, offset_bound);
+ }
+ return fbBuilder.endTable();
}
}
@@ -2647,70 +3330,59 @@ UnlinkedTypeParamBuilder encodeUnlinkedTypeParam(base.BuilderContext builderCont
}
/**
- * Unlinked summary information about a reference to a type.
+ * Unlinked summary information about a type parameter declaration.
*/
-class UnlinkedTypeRef extends base.SummaryClass {
- int _reference;
- int _paramReference;
- List<UnlinkedTypeRef> _typeArguments;
-
- UnlinkedTypeRef.fromJson(Map json)
- : _reference = json["reference"],
- _paramReference = json["paramReference"],
- _typeArguments = json["typeArguments"]?.map((x) => new UnlinkedTypeRef.fromJson(x))?.toList();
-
- @override
- Map<String, Object> toMap() => {
- "reference": reference,
- "paramReference": paramReference,
- "typeArguments": typeArguments,
- };
+abstract class UnlinkedTypeParam 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.
+ * Name of the type parameter.
*/
- int get reference => _reference ?? 0;
+ String get name;
/**
- * 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.
+ * Offset of the type parameter name relative to the beginning of the file.
*/
- int get paramReference => _paramReference ?? 0;
+ int get nameOffset;
/**
- * If this is an instantiation of a generic type, the type arguments used to
- * instantiate it. Trailing type arguments of type `dynamic` are omitted.
+ * Bound of the type parameter, if a bound is explicitly declared. Otherwise
+ * null.
*/
- List<UnlinkedTypeRef> get typeArguments => _typeArguments ?? const <UnlinkedTypeRef>[];
+ UnlinkedTypeRef get bound;
}
-class UnlinkedTypeRefBuilder {
- final Map _json = {};
+class _UnlinkedTypeParamReader extends fb.TableReader<_UnlinkedTypeParamReader> implements UnlinkedTypeParam {
+ final fb.BufferPointer _bp;
+
+ const _UnlinkedTypeParamReader([this._bp]);
+ @override
+ _UnlinkedTypeParamReader createReader(fb.BufferPointer bp) => new _UnlinkedTypeParamReader(bp);
+
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ String get name => const fb.StringReader().vTableGet(_bp, 0, '');
+
+ @override
+ int get nameOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
+
+ @override
+ UnlinkedTypeRef get bound => const _UnlinkedTypeRefReader().vTableGet(_bp, 2, null);
+}
+
+class UnlinkedTypeRefBuilder {
bool _finished = false;
+ int _reference;
+ int _paramReference;
+ List<UnlinkedTypeRefBuilder> _typeArguments;
+
+ bool _referenceIsSet = false;
+ bool _paramReferenceIsSet = false;
+ bool _typeArgumentsIsSet = false;
+
UnlinkedTypeRefBuilder(base.BuilderContext context);
/**
@@ -2725,10 +3397,9 @@ class UnlinkedTypeRefBuilder {
*/
void set reference(int _value) {
assert(!_finished);
- assert(!_json.containsKey("reference"));
- if (_value != null) {
- _json["reference"] = _value;
- }
+ assert(!_referenceIsSet);
+ _referenceIsSet = true;
+ _reference = _value;
}
/**
@@ -2752,10 +3423,9 @@ class UnlinkedTypeRefBuilder {
*/
void set paramReference(int _value) {
assert(!_finished);
- assert(!_json.containsKey("paramReference"));
- if (_value != null) {
- _json["paramReference"] = _value;
- }
+ assert(!_paramReferenceIsSet);
+ _paramReferenceIsSet = true;
+ _paramReference = _value;
}
/**
@@ -2764,16 +3434,29 @@ class UnlinkedTypeRefBuilder {
*/
void set typeArguments(List<UnlinkedTypeRefBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("typeArguments"));
- if (!(_value == null || _value.isEmpty)) {
- _json["typeArguments"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_typeArgumentsIsSet);
+ _typeArgumentsIsSet = true;
+ _typeArguments = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ 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();
}
}
@@ -2786,142 +3469,104 @@ UnlinkedTypeRefBuilder encodeUnlinkedTypeRef(base.BuilderContext builderContext,
}
/**
- * Unlinked summary information about a compilation unit ("part file").
+ * Unlinked summary information about a reference to a type.
*/
-class UnlinkedUnit extends base.SummaryClass {
- String _libraryName;
- int _libraryNameOffset;
- int _libraryNameLength;
- UnlinkedDocumentationComment _libraryDocumentationComment;
- UnlinkedPublicNamespace _publicNamespace;
- List<UnlinkedReference> _references;
- List<UnlinkedClass> _classes;
- List<UnlinkedEnum> _enums;
- List<UnlinkedExecutable> _executables;
- List<UnlinkedExportNonPublic> _exports;
- List<UnlinkedImport> _imports;
- List<UnlinkedPart> _parts;
- List<UnlinkedTypedef> _typedefs;
- List<UnlinkedVariable> _variables;
-
- UnlinkedUnit.fromJson(Map json)
- : _libraryName = json["libraryName"],
- _libraryNameOffset = json["libraryNameOffset"],
- _libraryNameLength = json["libraryNameLength"],
- _libraryDocumentationComment = json["libraryDocumentationComment"] == null ? null : new UnlinkedDocumentationComment.fromJson(json["libraryDocumentationComment"]),
- _publicNamespace = json["publicNamespace"] == null ? null : new UnlinkedPublicNamespace.fromJson(json["publicNamespace"]),
- _references = json["references"]?.map((x) => new UnlinkedReference.fromJson(x))?.toList(),
- _classes = json["classes"]?.map((x) => new UnlinkedClass.fromJson(x))?.toList(),
- _enums = json["enums"]?.map((x) => new UnlinkedEnum.fromJson(x))?.toList(),
- _executables = json["executables"]?.map((x) => new UnlinkedExecutable.fromJson(x))?.toList(),
- _exports = json["exports"]?.map((x) => new UnlinkedExportNonPublic.fromJson(x))?.toList(),
- _imports = json["imports"]?.map((x) => new UnlinkedImport.fromJson(x))?.toList(),
- _parts = json["parts"]?.map((x) => new UnlinkedPart.fromJson(x))?.toList(),
- _typedefs = json["typedefs"]?.map((x) => new UnlinkedTypedef.fromJson(x))?.toList(),
- _variables = json["variables"]?.map((x) => new UnlinkedVariable.fromJson(x))?.toList();
-
- @override
- Map<String, Object> toMap() => {
- "libraryName": libraryName,
- "libraryNameOffset": libraryNameOffset,
- "libraryNameLength": libraryNameLength,
- "libraryDocumentationComment": libraryDocumentationComment,
- "publicNamespace": publicNamespace,
- "references": references,
- "classes": classes,
- "enums": enums,
- "executables": executables,
- "exports": exports,
- "imports": imports,
- "parts": parts,
- "typedefs": typedefs,
- "variables": variables,
- };
-
- UnlinkedUnit.fromBuffer(List<int> buffer) : this.fromJson(JSON.decode(UTF8.decode(buffer)));
-
- /**
- * Name of the library (from a "library" declaration, if present).
- */
- String get libraryName => _libraryName ?? '';
+abstract class UnlinkedTypeRef extends base.SummaryClass {
/**
- * Offset of the library name relative to the beginning of the file (or 0 if
- * the library has no name).
- */
- int get libraryNameOffset => _libraryNameOffset ?? 0;
-
- /**
- * Length of the library name as it appears in the source code (or 0 if the
- * library has no name).
- */
- int get libraryNameLength => _libraryNameLength ?? 0;
-
- /**
- * Documentation comment for the library, or `null` if there is no
- * documentation comment.
- */
- UnlinkedDocumentationComment get libraryDocumentationComment => _libraryDocumentationComment;
-
- /**
- * Unlinked public namespace of this compilation unit.
- */
- UnlinkedPublicNamespace get publicNamespace => _publicNamespace;
-
- /**
- * Top level and prefixed names referred to by this compilation unit. The
- * zeroth element of this array is always populated and always represents a
- * reference to the pseudo-type "dynamic".
- */
- List<UnlinkedReference> get references => _references ?? const <UnlinkedReference>[];
-
- /**
- * Classes declared in the compilation unit.
- */
- List<UnlinkedClass> get classes => _classes ?? const <UnlinkedClass>[];
-
- /**
- * Enums declared in the compilation unit.
- */
- List<UnlinkedEnum> get enums => _enums ?? const <UnlinkedEnum>[];
-
- /**
- * Top level executable objects (functions, getters, and setters) declared in
- * the compilation unit.
- */
- List<UnlinkedExecutable> get executables => _executables ?? const <UnlinkedExecutable>[];
-
- /**
- * Export declarations in the compilation unit.
+ * 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.
*/
- List<UnlinkedExportNonPublic> get exports => _exports ?? const <UnlinkedExportNonPublic>[];
+ int get reference;
/**
- * Import declarations in the compilation unit.
+ * 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.
*/
- List<UnlinkedImport> get imports => _imports ?? const <UnlinkedImport>[];
+ int get paramReference;
/**
- * Part declarations in the compilation unit.
+ * 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<UnlinkedPart> get parts => _parts ?? const <UnlinkedPart>[];
+ List<UnlinkedTypeRef> get typeArguments;
+}
- /**
- * Typedefs declared in the compilation unit.
- */
- List<UnlinkedTypedef> get typedefs => _typedefs ?? const <UnlinkedTypedef>[];
+class _UnlinkedTypeRefReader extends fb.TableReader<_UnlinkedTypeRefReader> implements UnlinkedTypeRef {
+ final fb.BufferPointer _bp;
- /**
- * Top level variables declared in the compilation unit.
- */
- List<UnlinkedVariable> get variables => _variables ?? const <UnlinkedVariable>[];
+ const _UnlinkedTypeRefReader([this._bp]);
+
+ @override
+ _UnlinkedTypeRefReader createReader(fb.BufferPointer bp) => new _UnlinkedTypeRefReader(bp);
+
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ int get reference => const fb.Int32Reader().vTableGet(_bp, 0, 0);
+
+ @override
+ int get paramReference => const fb.Int32Reader().vTableGet(_bp, 1, 0);
+
+ @override
+ List<UnlinkedTypeRef> get typeArguments => const fb.ListReader<UnlinkedTypeRef>(const _UnlinkedTypeRefReader()).vTableGet(_bp, 2, const <UnlinkedTypeRef>[]);
}
class UnlinkedUnitBuilder {
- final Map _json = {};
-
bool _finished = false;
+ String _libraryName;
+ int _libraryNameOffset;
+ int _libraryNameLength;
+ UnlinkedDocumentationCommentBuilder _libraryDocumentationComment;
+ UnlinkedPublicNamespaceBuilder _publicNamespace;
+ List<UnlinkedReferenceBuilder> _references;
+ List<UnlinkedClassBuilder> _classes;
+ List<UnlinkedEnumBuilder> _enums;
+ List<UnlinkedExecutableBuilder> _executables;
+ List<UnlinkedExportNonPublicBuilder> _exports;
+ List<UnlinkedImportBuilder> _imports;
+ List<UnlinkedPartBuilder> _parts;
+ List<UnlinkedTypedefBuilder> _typedefs;
+ List<UnlinkedVariableBuilder> _variables;
+
+ bool _libraryNameIsSet = false;
+ bool _libraryNameOffsetIsSet = false;
+ bool _libraryNameLengthIsSet = false;
+ bool _libraryDocumentationCommentIsSet = false;
+ bool _publicNamespaceIsSet = false;
+ bool _referencesIsSet = false;
+ bool _classesIsSet = false;
+ bool _enumsIsSet = false;
+ bool _executablesIsSet = false;
+ bool _exportsIsSet = false;
+ bool _importsIsSet = false;
+ bool _partsIsSet = false;
+ bool _typedefsIsSet = false;
+ bool _variablesIsSet = false;
+
UnlinkedUnitBuilder(base.BuilderContext context);
/**
@@ -2929,10 +3574,9 @@ class UnlinkedUnitBuilder {
*/
void set libraryName(String _value) {
assert(!_finished);
- assert(!_json.containsKey("libraryName"));
- if (_value != null) {
- _json["libraryName"] = _value;
- }
+ assert(!_libraryNameIsSet);
+ _libraryNameIsSet = true;
+ _libraryName = _value;
}
/**
@@ -2941,10 +3585,9 @@ class UnlinkedUnitBuilder {
*/
void set libraryNameOffset(int _value) {
assert(!_finished);
- assert(!_json.containsKey("libraryNameOffset"));
- if (_value != null) {
- _json["libraryNameOffset"] = _value;
- }
+ assert(!_libraryNameOffsetIsSet);
+ _libraryNameOffsetIsSet = true;
+ _libraryNameOffset = _value;
}
/**
@@ -2953,10 +3596,9 @@ class UnlinkedUnitBuilder {
*/
void set libraryNameLength(int _value) {
assert(!_finished);
- assert(!_json.containsKey("libraryNameLength"));
- if (_value != null) {
- _json["libraryNameLength"] = _value;
- }
+ assert(!_libraryNameLengthIsSet);
+ _libraryNameLengthIsSet = true;
+ _libraryNameLength = _value;
}
/**
@@ -2965,10 +3607,9 @@ class UnlinkedUnitBuilder {
*/
void set libraryDocumentationComment(UnlinkedDocumentationCommentBuilder _value) {
assert(!_finished);
- assert(!_json.containsKey("libraryDocumentationComment"));
- if (_value != null) {
- _json["libraryDocumentationComment"] = _value.finish();
- }
+ assert(!_libraryDocumentationCommentIsSet);
+ _libraryDocumentationCommentIsSet = true;
+ _libraryDocumentationComment = _value;
}
/**
@@ -2976,10 +3617,9 @@ class UnlinkedUnitBuilder {
*/
void set publicNamespace(UnlinkedPublicNamespaceBuilder _value) {
assert(!_finished);
- assert(!_json.containsKey("publicNamespace"));
- if (_value != null) {
- _json["publicNamespace"] = _value.finish();
- }
+ assert(!_publicNamespaceIsSet);
+ _publicNamespaceIsSet = true;
+ _publicNamespace = _value;
}
/**
@@ -2989,10 +3629,9 @@ class UnlinkedUnitBuilder {
*/
void set references(List<UnlinkedReferenceBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("references"));
- if (!(_value == null || _value.isEmpty)) {
- _json["references"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_referencesIsSet);
+ _referencesIsSet = true;
+ _references = _value;
}
/**
@@ -3000,10 +3639,9 @@ class UnlinkedUnitBuilder {
*/
void set classes(List<UnlinkedClassBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("classes"));
- if (!(_value == null || _value.isEmpty)) {
- _json["classes"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_classesIsSet);
+ _classesIsSet = true;
+ _classes = _value;
}
/**
@@ -3011,10 +3649,9 @@ class UnlinkedUnitBuilder {
*/
void set enums(List<UnlinkedEnumBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("enums"));
- if (!(_value == null || _value.isEmpty)) {
- _json["enums"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_enumsIsSet);
+ _enumsIsSet = true;
+ _enums = _value;
}
/**
@@ -3023,10 +3660,9 @@ class UnlinkedUnitBuilder {
*/
void set executables(List<UnlinkedExecutableBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("executables"));
- if (!(_value == null || _value.isEmpty)) {
- _json["executables"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_executablesIsSet);
+ _executablesIsSet = true;
+ _executables = _value;
}
/**
@@ -3034,10 +3670,9 @@ class UnlinkedUnitBuilder {
*/
void set exports(List<UnlinkedExportNonPublicBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("exports"));
- if (!(_value == null || _value.isEmpty)) {
- _json["exports"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_exportsIsSet);
+ _exportsIsSet = true;
+ _exports = _value;
}
/**
@@ -3045,10 +3680,9 @@ class UnlinkedUnitBuilder {
*/
void set imports(List<UnlinkedImportBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("imports"));
- if (!(_value == null || _value.isEmpty)) {
- _json["imports"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_importsIsSet);
+ _importsIsSet = true;
+ _imports = _value;
}
/**
@@ -3056,10 +3690,9 @@ class UnlinkedUnitBuilder {
*/
void set parts(List<UnlinkedPartBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("parts"));
- if (!(_value == null || _value.isEmpty)) {
- _json["parts"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_partsIsSet);
+ _partsIsSet = true;
+ _parts = _value;
}
/**
@@ -3067,10 +3700,9 @@ class UnlinkedUnitBuilder {
*/
void set typedefs(List<UnlinkedTypedefBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("typedefs"));
- if (!(_value == null || _value.isEmpty)) {
- _json["typedefs"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_typedefsIsSet);
+ _typedefsIsSet = true;
+ _typedefs = _value;
}
/**
@@ -3078,18 +3710,111 @@ class UnlinkedUnitBuilder {
*/
void set variables(List<UnlinkedVariableBuilder> _value) {
assert(!_finished);
- assert(!_json.containsKey("variables"));
- if (!(_value == null || _value.isEmpty)) {
- _json["variables"] = _value.map((b) => b.finish()).toList();
- }
+ assert(!_variablesIsSet);
+ _variablesIsSet = true;
+ _variables = _value;
}
- List<int> toBuffer() => UTF8.encode(JSON.encode(finish()));
+ List<int> toBuffer() {
+ fb.Builder fbBuilder = new fb.Builder();
+ return fbBuilder.finish(finish(fbBuilder));
+ }
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_libraryName;
+ fb.Offset offset_libraryDocumentationComment;
+ fb.Offset offset_publicNamespace;
+ fb.Offset offset_references;
+ fb.Offset offset_classes;
+ fb.Offset offset_enums;
+ fb.Offset offset_executables;
+ fb.Offset offset_exports;
+ fb.Offset offset_imports;
+ fb.Offset offset_parts;
+ fb.Offset offset_typedefs;
+ fb.Offset offset_variables;
+ if (_libraryName != null) {
+ offset_libraryName = fbBuilder.writeString(_libraryName);
+ }
+ if (_libraryDocumentationComment != null) {
+ offset_libraryDocumentationComment = _libraryDocumentationComment.finish(fbBuilder);
+ }
+ if (_publicNamespace != null) {
+ offset_publicNamespace = _publicNamespace.finish(fbBuilder);
+ }
+ if (!(_references == null || _references.isEmpty)) {
+ offset_references = fbBuilder.writeList(_references.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (!(_classes == null || _classes.isEmpty)) {
+ offset_classes = fbBuilder.writeList(_classes.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (!(_enums == null || _enums.isEmpty)) {
+ offset_enums = fbBuilder.writeList(_enums.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (!(_executables == null || _executables.isEmpty)) {
+ offset_executables = fbBuilder.writeList(_executables.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (!(_exports == null || _exports.isEmpty)) {
+ offset_exports = fbBuilder.writeList(_exports.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (!(_imports == null || _imports.isEmpty)) {
+ offset_imports = fbBuilder.writeList(_imports.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (!(_parts == null || _parts.isEmpty)) {
+ offset_parts = fbBuilder.writeList(_parts.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (!(_typedefs == null || _typedefs.isEmpty)) {
+ offset_typedefs = fbBuilder.writeList(_typedefs.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (!(_variables == null || _variables.isEmpty)) {
+ offset_variables = fbBuilder.writeList(_variables.map((b) => b.finish(fbBuilder)).toList());
+ }
+ fbBuilder.startTable();
+ if (offset_libraryName != null) {
+ fbBuilder.addOffset(0, offset_libraryName);
+ }
+ if (_libraryNameOffset != null && _libraryNameOffset != 0) {
+ fbBuilder.addInt32(1, _libraryNameOffset);
+ }
+ if (_libraryNameLength != null && _libraryNameLength != 0) {
+ fbBuilder.addInt32(2, _libraryNameLength);
+ }
+ if (offset_libraryDocumentationComment != null) {
+ fbBuilder.addOffset(3, offset_libraryDocumentationComment);
+ }
+ if (offset_publicNamespace != null) {
+ fbBuilder.addOffset(4, offset_publicNamespace);
+ }
+ if (offset_references != null) {
+ fbBuilder.addOffset(5, offset_references);
+ }
+ if (offset_classes != null) {
+ fbBuilder.addOffset(6, offset_classes);
+ }
+ if (offset_enums != null) {
+ fbBuilder.addOffset(7, offset_enums);
+ }
+ if (offset_executables != null) {
+ fbBuilder.addOffset(8, offset_executables);
+ }
+ if (offset_exports != null) {
+ fbBuilder.addOffset(9, offset_exports);
+ }
+ if (offset_imports != null) {
+ fbBuilder.addOffset(10, offset_imports);
+ }
+ if (offset_parts != null) {
+ fbBuilder.addOffset(11, offset_parts);
+ }
+ if (offset_typedefs != null) {
+ fbBuilder.addOffset(12, offset_typedefs);
+ }
+ if (offset_variables != null) {
+ fbBuilder.addOffset(13, offset_variables);
+ }
+ return fbBuilder.endTable();
}
}
@@ -3113,93 +3838,166 @@ UnlinkedUnitBuilder encodeUnlinkedUnit(base.BuilderContext builderContext, {Stri
}
/**
- * Unlinked summary information about a top level variable, local variable, or
- * a field.
+ * Unlinked summary information about a compilation unit ("part file").
*/
-class UnlinkedVariable extends base.SummaryClass {
- String _name;
- int _nameOffset;
- UnlinkedDocumentationComment _documentationComment;
- UnlinkedTypeRef _type;
- bool _isStatic;
- bool _isFinal;
- bool _isConst;
- bool _hasImplicitType;
+abstract class UnlinkedUnit extends base.SummaryClass {
+ factory UnlinkedUnit.fromBuffer(List<int> buffer) {
+ fb.BufferPointer rootRef = new fb.BufferPointer.fromBytes(buffer);
+ return const _UnlinkedUnitReader().read(rootRef);
+ }
- UnlinkedVariable.fromJson(Map json)
- : _name = json["name"],
- _nameOffset = json["nameOffset"],
- _documentationComment = json["documentationComment"] == null ? null : new UnlinkedDocumentationComment.fromJson(json["documentationComment"]),
- _type = json["type"] == null ? null : new UnlinkedTypeRef.fromJson(json["type"]),
- _isStatic = json["isStatic"],
- _isFinal = json["isFinal"],
- _isConst = json["isConst"],
- _hasImplicitType = json["hasImplicitType"];
-
- @override
- Map<String, Object> toMap() => {
- "name": name,
- "nameOffset": nameOffset,
- "documentationComment": documentationComment,
- "type": type,
- "isStatic": isStatic,
- "isFinal": isFinal,
- "isConst": isConst,
- "hasImplicitType": hasImplicitType,
- };
+ /**
+ * Name of the library (from a "library" declaration, if present).
+ */
+ String get libraryName;
/**
- * Name of the variable.
+ * Offset of the library name relative to the beginning of the file (or 0 if
+ * the library has no name).
*/
- String get name => _name ?? '';
+ int get libraryNameOffset;
/**
- * Offset of the variable name relative to the beginning of the file.
+ * Length of the library name as it appears in the source code (or 0 if the
+ * library has no name).
*/
- int get nameOffset => _nameOffset ?? 0;
+ int get libraryNameLength;
/**
- * Documentation comment for the variable, or `null` if there is no
+ * Documentation comment for the library, or `null` if there is no
* documentation comment.
*/
- UnlinkedDocumentationComment get documentationComment => _documentationComment;
+ UnlinkedDocumentationComment get libraryDocumentationComment;
/**
- * 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.
+ * Unlinked public namespace of this compilation unit.
*/
- UnlinkedTypeRef get type => _type;
+ UnlinkedPublicNamespace get publicNamespace;
/**
- * Indicates whether the variable is declared using the `static` keyword.
- *
- * Note that for top level variables, this flag is false, since they are not
- * declared using the `static` keyword (even though they are considered
- * static for semantic purposes).
+ * Top level and prefixed names referred to by this compilation unit. The
+ * zeroth element of this array is always populated and always represents a
+ * reference to the pseudo-type "dynamic".
*/
- bool get isStatic => _isStatic ?? false;
+ List<UnlinkedReference> get references;
/**
- * Indicates whether the variable is declared using the `final` keyword.
+ * Classes declared in the compilation unit.
*/
- bool get isFinal => _isFinal ?? false;
+ List<UnlinkedClass> get classes;
/**
- * Indicates whether the variable is declared using the `const` keyword.
+ * Enums declared in the compilation unit.
*/
- bool get isConst => _isConst ?? false;
+ List<UnlinkedEnum> get enums;
/**
- * Indicates whether this variable lacks an explicit type declaration.
+ * Top level executable objects (functions, getters, and setters) declared in
+ * the compilation unit.
+ */
+ List<UnlinkedExecutable> get executables;
+
+ /**
+ * Export declarations in the compilation unit.
+ */
+ List<UnlinkedExportNonPublic> get exports;
+
+ /**
+ * Import declarations in the compilation unit.
+ */
+ List<UnlinkedImport> get imports;
+
+ /**
+ * Part declarations in the compilation unit.
+ */
+ List<UnlinkedPart> get parts;
+
+ /**
+ * Typedefs declared in the compilation unit.
+ */
+ List<UnlinkedTypedef> get typedefs;
+
+ /**
+ * Top level variables declared in the compilation unit.
*/
- bool get hasImplicitType => _hasImplicitType ?? false;
+ List<UnlinkedVariable> get variables;
}
-class UnlinkedVariableBuilder {
- final Map _json = {};
+class _UnlinkedUnitReader extends fb.TableReader<_UnlinkedUnitReader> implements UnlinkedUnit {
+ final fb.BufferPointer _bp;
+
+ const _UnlinkedUnitReader([this._bp]);
+ @override
+ _UnlinkedUnitReader createReader(fb.BufferPointer bp) => new _UnlinkedUnitReader(bp);
+
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ String get libraryName => const fb.StringReader().vTableGet(_bp, 0, '');
+
+ @override
+ int get libraryNameOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
+
+ @override
+ int get libraryNameLength => const fb.Int32Reader().vTableGet(_bp, 2, 0);
+
+ @override
+ UnlinkedDocumentationComment get libraryDocumentationComment => const _UnlinkedDocumentationCommentReader().vTableGet(_bp, 3, null);
+
+ @override
+ UnlinkedPublicNamespace get publicNamespace => const _UnlinkedPublicNamespaceReader().vTableGet(_bp, 4, null);
+
+ @override
+ List<UnlinkedReference> get references => const fb.ListReader<UnlinkedReference>(const _UnlinkedReferenceReader()).vTableGet(_bp, 5, const <UnlinkedReference>[]);
+
+ @override
+ List<UnlinkedClass> get classes => const fb.ListReader<UnlinkedClass>(const _UnlinkedClassReader()).vTableGet(_bp, 6, const <UnlinkedClass>[]);
+
+ @override
+ List<UnlinkedEnum> get enums => const fb.ListReader<UnlinkedEnum>(const _UnlinkedEnumReader()).vTableGet(_bp, 7, const <UnlinkedEnum>[]);
+
+ @override
+ List<UnlinkedExecutable> get executables => const fb.ListReader<UnlinkedExecutable>(const _UnlinkedExecutableReader()).vTableGet(_bp, 8, const <UnlinkedExecutable>[]);
+
+ @override
+ List<UnlinkedExportNonPublic> get exports => const fb.ListReader<UnlinkedExportNonPublic>(const _UnlinkedExportNonPublicReader()).vTableGet(_bp, 9, const <UnlinkedExportNonPublic>[]);
+
+ @override
+ List<UnlinkedImport> get imports => const fb.ListReader<UnlinkedImport>(const _UnlinkedImportReader()).vTableGet(_bp, 10, const <UnlinkedImport>[]);
+
+ @override
+ List<UnlinkedPart> get parts => const fb.ListReader<UnlinkedPart>(const _UnlinkedPartReader()).vTableGet(_bp, 11, const <UnlinkedPart>[]);
+
+ @override
+ List<UnlinkedTypedef> get typedefs => const fb.ListReader<UnlinkedTypedef>(const _UnlinkedTypedefReader()).vTableGet(_bp, 12, const <UnlinkedTypedef>[]);
+
+ @override
+ List<UnlinkedVariable> get variables => const fb.ListReader<UnlinkedVariable>(const _UnlinkedVariableReader()).vTableGet(_bp, 13, const <UnlinkedVariable>[]);
+}
+
+class UnlinkedVariableBuilder {
bool _finished = false;
+ String _name;
+ int _nameOffset;
+ UnlinkedDocumentationCommentBuilder _documentationComment;
+ UnlinkedTypeRefBuilder _type;
+ bool _isStatic;
+ bool _isFinal;
+ bool _isConst;
+ bool _hasImplicitType;
+
+ bool _nameIsSet = false;
+ bool _nameOffsetIsSet = false;
+ bool _documentationCommentIsSet = false;
+ bool _typeIsSet = false;
+ bool _isStaticIsSet = false;
+ bool _isFinalIsSet = false;
+ bool _isConstIsSet = false;
+ bool _hasImplicitTypeIsSet = false;
+
UnlinkedVariableBuilder(base.BuilderContext context);
/**
@@ -3207,10 +4005,9 @@ class UnlinkedVariableBuilder {
*/
void set name(String _value) {
assert(!_finished);
- assert(!_json.containsKey("name"));
- if (_value != null) {
- _json["name"] = _value;
- }
+ assert(!_nameIsSet);
+ _nameIsSet = true;
+ _name = _value;
}
/**
@@ -3218,10 +4015,9 @@ class UnlinkedVariableBuilder {
*/
void set nameOffset(int _value) {
assert(!_finished);
- assert(!_json.containsKey("nameOffset"));
- if (_value != null) {
- _json["nameOffset"] = _value;
- }
+ assert(!_nameOffsetIsSet);
+ _nameOffsetIsSet = true;
+ _nameOffset = _value;
}
/**
@@ -3230,10 +4026,9 @@ class UnlinkedVariableBuilder {
*/
void set documentationComment(UnlinkedDocumentationCommentBuilder _value) {
assert(!_finished);
- assert(!_json.containsKey("documentationComment"));
- if (_value != null) {
- _json["documentationComment"] = _value.finish();
- }
+ assert(!_documentationCommentIsSet);
+ _documentationCommentIsSet = true;
+ _documentationComment = _value;
}
/**
@@ -3242,10 +4037,9 @@ class UnlinkedVariableBuilder {
*/
void set type(UnlinkedTypeRefBuilder _value) {
assert(!_finished);
- assert(!_json.containsKey("type"));
- if (_value != null) {
- _json["type"] = _value.finish();
- }
+ assert(!_typeIsSet);
+ _typeIsSet = true;
+ _type = _value;
}
/**
@@ -3257,10 +4051,9 @@ class UnlinkedVariableBuilder {
*/
void set isStatic(bool _value) {
assert(!_finished);
- assert(!_json.containsKey("isStatic"));
- if (_value != null) {
- _json["isStatic"] = _value;
- }
+ assert(!_isStaticIsSet);
+ _isStaticIsSet = true;
+ _isStatic = _value;
}
/**
@@ -3268,10 +4061,9 @@ class UnlinkedVariableBuilder {
*/
void set isFinal(bool _value) {
assert(!_finished);
- assert(!_json.containsKey("isFinal"));
- if (_value != null) {
- _json["isFinal"] = _value;
- }
+ assert(!_isFinalIsSet);
+ _isFinalIsSet = true;
+ _isFinal = _value;
}
/**
@@ -3279,10 +4071,9 @@ class UnlinkedVariableBuilder {
*/
void set isConst(bool _value) {
assert(!_finished);
- assert(!_json.containsKey("isConst"));
- if (_value != null) {
- _json["isConst"] = _value;
- }
+ assert(!_isConstIsSet);
+ _isConstIsSet = true;
+ _isConst = _value;
}
/**
@@ -3290,16 +4081,52 @@ class UnlinkedVariableBuilder {
*/
void set hasImplicitType(bool _value) {
assert(!_finished);
- assert(!_json.containsKey("hasImplicitType"));
- if (_value != null) {
- _json["hasImplicitType"] = _value;
- }
+ assert(!_hasImplicitTypeIsSet);
+ _hasImplicitTypeIsSet = true;
+ _hasImplicitType = _value;
}
- Map finish() {
+ fb.Offset finish(fb.Builder fbBuilder) {
assert(!_finished);
_finished = true;
- return _json;
+ fb.Offset offset_name;
+ fb.Offset offset_documentationComment;
+ fb.Offset offset_type;
+ if (_name != null) {
+ offset_name = fbBuilder.writeString(_name);
+ }
+ if (_documentationComment != null) {
+ offset_documentationComment = _documentationComment.finish(fbBuilder);
+ }
+ if (_type != null) {
+ offset_type = _type.finish(fbBuilder);
+ }
+ fbBuilder.startTable();
+ if (offset_name != null) {
+ fbBuilder.addOffset(0, offset_name);
+ }
+ if (_nameOffset != null && _nameOffset != 0) {
+ fbBuilder.addInt32(1, _nameOffset);
+ }
+ if (offset_documentationComment != null) {
+ fbBuilder.addOffset(2, offset_documentationComment);
+ }
+ if (offset_type != null) {
+ fbBuilder.addOffset(3, offset_type);
+ }
+ if (_isStatic == true) {
+ fbBuilder.addInt8(4, 1);
+ }
+ if (_isFinal == true) {
+ fbBuilder.addInt8(5, 1);
+ }
+ if (_isConst == true) {
+ fbBuilder.addInt8(6, 1);
+ }
+ if (_hasImplicitType == true) {
+ fbBuilder.addInt8(7, 1);
+ }
+ return fbBuilder.endTable();
}
}
@@ -3316,3 +4143,92 @@ UnlinkedVariableBuilder encodeUnlinkedVariable(base.BuilderContext builderContex
return builder;
}
+/**
+ * Unlinked summary information about a top level variable, local variable, or
+ * a field.
+ */
+abstract class UnlinkedVariable extends base.SummaryClass {
+
+ /**
+ * Name of the variable.
+ */
+ String get name;
+
+ /**
+ * Offset of the variable name relative to the beginning of the file.
+ */
+ int get nameOffset;
+
+ /**
+ * Documentation comment for the variable, or `null` if there is no
+ * documentation comment.
+ */
+ UnlinkedDocumentationComment get documentationComment;
+
+ /**
+ * 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;
+
+ /**
+ * Indicates whether the variable is declared using the `static` keyword.
+ *
+ * Note that for top level variables, this flag is false, since they are not
+ * declared using the `static` keyword (even though they are considered
+ * static for semantic purposes).
+ */
+ bool get isStatic;
+
+ /**
+ * Indicates whether the variable is declared using the `final` keyword.
+ */
+ bool get isFinal;
+
+ /**
+ * Indicates whether the variable is declared using the `const` keyword.
+ */
+ bool get isConst;
+
+ /**
+ * Indicates whether this variable lacks an explicit type declaration.
+ */
+ bool get hasImplicitType;
+}
+
+class _UnlinkedVariableReader extends fb.TableReader<_UnlinkedVariableReader> implements UnlinkedVariable {
+ final fb.BufferPointer _bp;
+
+ const _UnlinkedVariableReader([this._bp]);
+
+ @override
+ _UnlinkedVariableReader createReader(fb.BufferPointer bp) => new _UnlinkedVariableReader(bp);
+
+ @override
+ Map<String, Object> toMap() => {};
+
+ @override
+ String get name => const fb.StringReader().vTableGet(_bp, 0, '');
+
+ @override
+ int get nameOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
+
+ @override
+ UnlinkedDocumentationComment get documentationComment => const _UnlinkedDocumentationCommentReader().vTableGet(_bp, 2, null);
+
+ @override
+ UnlinkedTypeRef get type => const _UnlinkedTypeRefReader().vTableGet(_bp, 3, null);
+
+ @override
+ bool get isStatic => const fb.Int8Reader().vTableGet(_bp, 4, 0) == 1;
+
+ @override
+ bool get isFinal => const fb.Int8Reader().vTableGet(_bp, 5, 0) == 1;
+
+ @override
+ bool get isConst => const fb.Int8Reader().vTableGet(_bp, 6, 0) == 1;
+
+ @override
+ bool get hasImplicitType => const fb.Int8Reader().vTableGet(_bp, 7, 0) == 1;
+}
+
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/summary_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698