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

Side by Side 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: Remove IsSet flags and restore toMap() generation. 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/summary_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // 4 //
5 // This file has been automatically generated. Please do not edit it manually. 5 // This file has been automatically generated. Please do not edit it manually.
6 // To regenerate the file, use the script "pkg/analyzer/tool/generate_files". 6 // To regenerate the file, use the script "pkg/analyzer/tool/generate_files".
7 7
8 library analyzer.src.summary.format; 8 library analyzer.src.summary.format;
9 9
10 import 'dart:convert';
11 import 'base.dart' as base; 10 import 'base.dart' as base;
11 import 'flat_buffers.dart' as fb;
12 12
13 /** 13 /**
14 * Enum used to indicate the kind of entity referred to by a 14 * Enum used to indicate the kind of entity referred to by a
15 * [PrelinkedReference]. 15 * [PrelinkedReference].
16 */ 16 */
17 enum PrelinkedReferenceKind { 17 enum PrelinkedReferenceKind {
18 classOrEnum, 18 classOrEnum,
19 typedef, 19 typedef,
20 other, 20 other,
21 prefix, 21 prefix,
(...skipping 12 matching lines...) Expand all
34 34
35 /** 35 /**
36 * Enum used to indicate the kind of a parameter. 36 * Enum used to indicate the kind of a parameter.
37 */ 37 */
38 enum UnlinkedParamKind { 38 enum UnlinkedParamKind {
39 required, 39 required,
40 positional, 40 positional,
41 named, 41 named,
42 } 42 }
43 43
44 /** 44 class PrelinkedDependencyBuilder {
45 * Information about a dependency that exists between one library and another 45 bool _finished = false;
46 * due to an "import" declaration. 46
47 */
48 class PrelinkedDependency extends base.SummaryClass {
49 String _uri; 47 String _uri;
50 48
51 PrelinkedDependency.fromJson(Map json)
52 : _uri = json["uri"];
53
54 @override
55 Map<String, Object> toMap() => {
56 "uri": uri,
57 };
58
59 /**
60 * The relative URI used to import one library from the other.
61 */
62 String get uri => _uri ?? '';
63 }
64
65 class PrelinkedDependencyBuilder {
66 final Map _json = {};
67
68 bool _finished = false;
69
70 PrelinkedDependencyBuilder(base.BuilderContext context); 49 PrelinkedDependencyBuilder(base.BuilderContext context);
71 50
72 /** 51 /**
73 * The relative URI used to import one library from the other. 52 * The relative URI used to import one library from the other.
74 */ 53 */
75 void set uri(String _value) { 54 void set uri(String _value) {
76 assert(!_finished); 55 assert(!_finished);
77 assert(!_json.containsKey("uri")); 56 _uri = _value;
78 if (_value != null) {
79 _json["uri"] = _value;
80 }
81 } 57 }
82 58
83 Map finish() { 59 fb.Offset finish(fb.Builder fbBuilder) {
84 assert(!_finished); 60 assert(!_finished);
85 _finished = true; 61 _finished = true;
86 return _json; 62 fb.Offset offset_uri;
63 if (_uri != null) {
64 offset_uri = fbBuilder.writeString(_uri);
65 }
66 fbBuilder.startTable();
67 if (offset_uri != null) {
68 fbBuilder.addOffset(0, offset_uri);
69 }
70 return fbBuilder.endTable();
87 } 71 }
88 } 72 }
89 73
90 PrelinkedDependencyBuilder encodePrelinkedDependency(base.BuilderContext builder Context, {String uri}) { 74 PrelinkedDependencyBuilder encodePrelinkedDependency(base.BuilderContext builder Context, {String uri}) {
91 PrelinkedDependencyBuilder builder = new PrelinkedDependencyBuilder(builderCon text); 75 PrelinkedDependencyBuilder builder = new PrelinkedDependencyBuilder(builderCon text);
92 builder.uri = uri; 76 builder.uri = uri;
93 return builder; 77 return builder;
94 } 78 }
95 79
96 /** 80 /**
97 * Pre-linked summary of a library. 81 * Information about a dependency that exists between one library and another
82 * due to an "import" declaration.
98 */ 83 */
99 class PrelinkedLibrary extends base.SummaryClass { 84 abstract class PrelinkedDependency extends base.SummaryClass {
100 List<PrelinkedUnit> _units;
101 List<PrelinkedDependency> _dependencies;
102 List<int> _importDependencies;
103 85
104 PrelinkedLibrary.fromJson(Map json) 86 /**
105 : _units = json["units"]?.map((x) => new PrelinkedUnit.fromJson(x))?.toList( ), 87 * The relative URI used to import one library from the other.
106 _dependencies = json["dependencies"]?.map((x) => new PrelinkedDependency.f romJson(x))?.toList(), 88 */
107 _importDependencies = json["importDependencies"]; 89 String get uri;
90 }
91
92 class _PrelinkedDependencyReader extends fb.TableReader<_PrelinkedDependencyRead er> implements PrelinkedDependency {
93 final fb.BufferPointer _bp;
94
95 const _PrelinkedDependencyReader([this._bp]);
96
97 @override
98 _PrelinkedDependencyReader createReader(fb.BufferPointer bp) => new _Prelinked DependencyReader(bp);
108 99
109 @override 100 @override
110 Map<String, Object> toMap() => { 101 Map<String, Object> toMap() => {
111 "units": units, 102 "uri": uri,
112 "dependencies": dependencies,
113 "importDependencies": importDependencies,
114 }; 103 };
115 104
116 PrelinkedLibrary.fromBuffer(List<int> buffer) : this.fromJson(JSON.decode(UTF8 .decode(buffer))); 105 @override
117 106 String get uri => const fb.StringReader().vTableGet(_bp, 0, '');
118 /**
119 * The pre-linked summary of all the compilation units constituting the
120 * library. The summary of the defining compilation unit is listed first,
121 * followed by the summary of each part, in the order of the `part`
122 * declarations in the defining compilation unit.
123 */
124 List<PrelinkedUnit> get units => _units ?? const <PrelinkedUnit>[];
125
126 /**
127 * The libraries that this library depends on (either via an explicit import
128 * statement or via the implicit dependencies on `dart:core` and
129 * `dart:async`). The first element of this array is a pseudo-dependency
130 * representing the library itself (it is also used for "dynamic").
131 *
132 * TODO(paulberry): consider removing this entirely and just using
133 * [UnlinkedLibrary.imports].
134 */
135 List<PrelinkedDependency> get dependencies => _dependencies ?? const <Prelinke dDependency>[];
136
137 /**
138 * For each import in [UnlinkedUnit.imports], an index into [dependencies]
139 * of the library being imported.
140 *
141 * TODO(paulberry): if [dependencies] is removed, this can be removed as
142 * well, since there will effectively be a one-to-one mapping.
143 */
144 List<int> get importDependencies => _importDependencies ?? const <int>[];
145 } 107 }
146 108
147 class PrelinkedLibraryBuilder { 109 class PrelinkedLibraryBuilder {
148 final Map _json = {}; 110 bool _finished = false;
149 111
150 bool _finished = false; 112 List<PrelinkedUnitBuilder> _units;
113 List<PrelinkedDependencyBuilder> _dependencies;
114 List<int> _importDependencies;
151 115
152 PrelinkedLibraryBuilder(base.BuilderContext context); 116 PrelinkedLibraryBuilder(base.BuilderContext context);
153 117
154 /** 118 /**
155 * The pre-linked summary of all the compilation units constituting the 119 * The pre-linked summary of all the compilation units constituting the
156 * library. The summary of the defining compilation unit is listed first, 120 * library. The summary of the defining compilation unit is listed first,
157 * followed by the summary of each part, in the order of the `part` 121 * followed by the summary of each part, in the order of the `part`
158 * declarations in the defining compilation unit. 122 * declarations in the defining compilation unit.
159 */ 123 */
160 void set units(List<PrelinkedUnitBuilder> _value) { 124 void set units(List<PrelinkedUnitBuilder> _value) {
161 assert(!_finished); 125 assert(!_finished);
162 assert(!_json.containsKey("units")); 126 _units = _value;
163 if (!(_value == null || _value.isEmpty)) {
164 _json["units"] = _value.map((b) => b.finish()).toList();
165 }
166 } 127 }
167 128
168 /** 129 /**
169 * The libraries that this library depends on (either via an explicit import 130 * The libraries that this library depends on (either via an explicit import
170 * statement or via the implicit dependencies on `dart:core` and 131 * statement or via the implicit dependencies on `dart:core` and
171 * `dart:async`). The first element of this array is a pseudo-dependency 132 * `dart:async`). The first element of this array is a pseudo-dependency
172 * representing the library itself (it is also used for "dynamic"). 133 * representing the library itself (it is also used for "dynamic").
173 * 134 *
174 * TODO(paulberry): consider removing this entirely and just using 135 * TODO(paulberry): consider removing this entirely and just using
175 * [UnlinkedLibrary.imports]. 136 * [UnlinkedLibrary.imports].
176 */ 137 */
177 void set dependencies(List<PrelinkedDependencyBuilder> _value) { 138 void set dependencies(List<PrelinkedDependencyBuilder> _value) {
178 assert(!_finished); 139 assert(!_finished);
179 assert(!_json.containsKey("dependencies")); 140 _dependencies = _value;
180 if (!(_value == null || _value.isEmpty)) {
181 _json["dependencies"] = _value.map((b) => b.finish()).toList();
182 }
183 } 141 }
184 142
185 /** 143 /**
186 * For each import in [UnlinkedUnit.imports], an index into [dependencies] 144 * For each import in [UnlinkedUnit.imports], an index into [dependencies]
187 * of the library being imported. 145 * of the library being imported.
188 * 146 *
189 * TODO(paulberry): if [dependencies] is removed, this can be removed as 147 * TODO(paulberry): if [dependencies] is removed, this can be removed as
190 * well, since there will effectively be a one-to-one mapping. 148 * well, since there will effectively be a one-to-one mapping.
191 */ 149 */
192 void set importDependencies(List<int> _value) { 150 void set importDependencies(List<int> _value) {
193 assert(!_finished); 151 assert(!_finished);
194 assert(!_json.containsKey("importDependencies")); 152 _importDependencies = _value;
195 if (!(_value == null || _value.isEmpty)) {
196 _json["importDependencies"] = _value.toList();
197 }
198 } 153 }
199 154
200 List<int> toBuffer() => UTF8.encode(JSON.encode(finish())); 155 List<int> toBuffer() {
156 fb.Builder fbBuilder = new fb.Builder();
157 return fbBuilder.finish(finish(fbBuilder));
158 }
201 159
202 Map finish() { 160 fb.Offset finish(fb.Builder fbBuilder) {
203 assert(!_finished); 161 assert(!_finished);
204 _finished = true; 162 _finished = true;
205 return _json; 163 fb.Offset offset_units;
164 fb.Offset offset_dependencies;
165 fb.Offset offset_importDependencies;
166 if (!(_units == null || _units.isEmpty)) {
167 offset_units = fbBuilder.writeList(_units.map((b) => b.finish(fbBuilder)). toList());
168 }
169 if (!(_dependencies == null || _dependencies.isEmpty)) {
170 offset_dependencies = fbBuilder.writeList(_dependencies.map((b) => b.finis h(fbBuilder)).toList());
171 }
172 if (!(_importDependencies == null || _importDependencies.isEmpty)) {
173 offset_importDependencies = fbBuilder.writeListInt32(_importDependencies);
174 }
175 fbBuilder.startTable();
176 if (offset_units != null) {
177 fbBuilder.addOffset(0, offset_units);
178 }
179 if (offset_dependencies != null) {
180 fbBuilder.addOffset(1, offset_dependencies);
181 }
182 if (offset_importDependencies != null) {
183 fbBuilder.addOffset(2, offset_importDependencies);
184 }
185 return fbBuilder.endTable();
206 } 186 }
207 } 187 }
208 188
209 PrelinkedLibraryBuilder encodePrelinkedLibrary(base.BuilderContext builderContex t, {List<PrelinkedUnitBuilder> units, List<PrelinkedDependencyBuilder> dependenc ies, List<int> importDependencies}) { 189 PrelinkedLibraryBuilder encodePrelinkedLibrary(base.BuilderContext builderContex t, {List<PrelinkedUnitBuilder> units, List<PrelinkedDependencyBuilder> dependenc ies, List<int> importDependencies}) {
210 PrelinkedLibraryBuilder builder = new PrelinkedLibraryBuilder(builderContext); 190 PrelinkedLibraryBuilder builder = new PrelinkedLibraryBuilder(builderContext);
211 builder.units = units; 191 builder.units = units;
212 builder.dependencies = dependencies; 192 builder.dependencies = dependencies;
213 builder.importDependencies = importDependencies; 193 builder.importDependencies = importDependencies;
214 return builder; 194 return builder;
215 } 195 }
216 196
217 /** 197 /**
218 * Information about the resolution of an [UnlinkedReference]. 198 * Pre-linked summary of a library.
219 */ 199 */
220 class PrelinkedReference extends base.SummaryClass { 200 abstract class PrelinkedLibrary extends base.SummaryClass {
201 factory PrelinkedLibrary.fromBuffer(List<int> buffer) {
202 fb.BufferPointer rootRef = new fb.BufferPointer.fromBytes(buffer);
203 return const _PrelinkedLibraryReader().read(rootRef);
204 }
205
206 /**
207 * The pre-linked summary of all the compilation units constituting the
208 * library. The summary of the defining compilation unit is listed first,
209 * followed by the summary of each part, in the order of the `part`
210 * declarations in the defining compilation unit.
211 */
212 List<PrelinkedUnit> get units;
213
214 /**
215 * The libraries that this library depends on (either via an explicit import
216 * statement or via the implicit dependencies on `dart:core` and
217 * `dart:async`). The first element of this array is a pseudo-dependency
218 * representing the library itself (it is also used for "dynamic").
219 *
220 * TODO(paulberry): consider removing this entirely and just using
221 * [UnlinkedLibrary.imports].
222 */
223 List<PrelinkedDependency> get dependencies;
224
225 /**
226 * For each import in [UnlinkedUnit.imports], an index into [dependencies]
227 * of the library being imported.
228 *
229 * TODO(paulberry): if [dependencies] is removed, this can be removed as
230 * well, since there will effectively be a one-to-one mapping.
231 */
232 List<int> get importDependencies;
233 }
234
235 class _PrelinkedLibraryReader extends fb.TableReader<_PrelinkedLibraryReader> im plements PrelinkedLibrary {
236 final fb.BufferPointer _bp;
237
238 const _PrelinkedLibraryReader([this._bp]);
239
240 @override
241 _PrelinkedLibraryReader createReader(fb.BufferPointer bp) => new _PrelinkedLib raryReader(bp);
242
243 @override
244 Map<String, Object> toMap() => {
245 "units": units,
246 "dependencies": dependencies,
247 "importDependencies": importDependencies,
248 };
249
250 @override
251 List<PrelinkedUnit> get units => const fb.ListReader<PrelinkedUnit>(const _Pre linkedUnitReader()).vTableGet(_bp, 0, const <PrelinkedUnit>[]);
252
253 @override
254 List<PrelinkedDependency> get dependencies => const fb.ListReader<PrelinkedDep endency>(const _PrelinkedDependencyReader()).vTableGet(_bp, 1, const <PrelinkedD ependency>[]);
255
256 @override
257 List<int> get importDependencies => const fb.ListReader<int>(const fb.Int32Rea der()).vTableGet(_bp, 2, const <int>[]);
258 }
259
260 class PrelinkedReferenceBuilder {
261 bool _finished = false;
262
221 int _dependency; 263 int _dependency;
222 PrelinkedReferenceKind _kind; 264 PrelinkedReferenceKind _kind;
223 int _unit; 265 int _unit;
224 int _numTypeParameters; 266 int _numTypeParameters;
225 267
226 PrelinkedReference.fromJson(Map json)
227 : _dependency = json["dependency"],
228 _kind = json["kind"] == null ? null : PrelinkedReferenceKind.values[json[" kind"]],
229 _unit = json["unit"],
230 _numTypeParameters = json["numTypeParameters"];
231
232 @override
233 Map<String, Object> toMap() => {
234 "dependency": dependency,
235 "kind": kind,
236 "unit": unit,
237 "numTypeParameters": numTypeParameters,
238 };
239
240 /**
241 * Index into [PrelinkedLibrary.dependencies] indicating which imported librar y
242 * declares the entity being referred to.
243 */
244 int get dependency => _dependency ?? 0;
245
246 /**
247 * The kind of the entity being referred to. For the pseudo-type `dynamic`,
248 * the kind is [PrelinkedReferenceKind.classOrEnum].
249 */
250 PrelinkedReferenceKind get kind => _kind ?? PrelinkedReferenceKind.classOrEnum ;
251
252 /**
253 * Integer index indicating which unit in the imported library contains the
254 * definition of the entity. As with indices into [PrelinkedLibrary.units],
255 * zero represents the defining compilation unit, and nonzero values
256 * represent parts in the order of the corresponding `part` declarations.
257 */
258 int get unit => _unit ?? 0;
259
260 /**
261 * If the entity being referred to is generic, the number of type parameters
262 * it accepts. Otherwise zero.
263 */
264 int get numTypeParameters => _numTypeParameters ?? 0;
265 }
266
267 class PrelinkedReferenceBuilder {
268 final Map _json = {};
269
270 bool _finished = false;
271
272 PrelinkedReferenceBuilder(base.BuilderContext context); 268 PrelinkedReferenceBuilder(base.BuilderContext context);
273 269
274 /** 270 /**
275 * Index into [PrelinkedLibrary.dependencies] indicating which imported librar y 271 * Index into [PrelinkedLibrary.dependencies] indicating which imported librar y
276 * declares the entity being referred to. 272 * declares the entity being referred to.
277 */ 273 */
278 void set dependency(int _value) { 274 void set dependency(int _value) {
279 assert(!_finished); 275 assert(!_finished);
280 assert(!_json.containsKey("dependency")); 276 _dependency = _value;
281 if (_value != null) {
282 _json["dependency"] = _value;
283 }
284 } 277 }
285 278
286 /** 279 /**
287 * The kind of the entity being referred to. For the pseudo-type `dynamic`, 280 * The kind of the entity being referred to. For the pseudo-type `dynamic`,
288 * the kind is [PrelinkedReferenceKind.classOrEnum]. 281 * the kind is [PrelinkedReferenceKind.classOrEnum].
289 */ 282 */
290 void set kind(PrelinkedReferenceKind _value) { 283 void set kind(PrelinkedReferenceKind _value) {
291 assert(!_finished); 284 assert(!_finished);
292 assert(!_json.containsKey("kind")); 285 _kind = _value;
293 if (!(_value == null || _value == PrelinkedReferenceKind.classOrEnum)) {
294 _json["kind"] = _value.index;
295 }
296 } 286 }
297 287
298 /** 288 /**
299 * Integer index indicating which unit in the imported library contains the 289 * Integer index indicating which unit in the imported library contains the
300 * definition of the entity. As with indices into [PrelinkedLibrary.units], 290 * definition of the entity. As with indices into [PrelinkedLibrary.units],
301 * zero represents the defining compilation unit, and nonzero values 291 * zero represents the defining compilation unit, and nonzero values
302 * represent parts in the order of the corresponding `part` declarations. 292 * represent parts in the order of the corresponding `part` declarations.
303 */ 293 */
304 void set unit(int _value) { 294 void set unit(int _value) {
305 assert(!_finished); 295 assert(!_finished);
306 assert(!_json.containsKey("unit")); 296 _unit = _value;
307 if (_value != null) {
308 _json["unit"] = _value;
309 }
310 } 297 }
311 298
312 /** 299 /**
313 * If the entity being referred to is generic, the number of type parameters 300 * If the entity being referred to is generic, the number of type parameters
314 * it accepts. Otherwise zero. 301 * it accepts. Otherwise zero.
315 */ 302 */
316 void set numTypeParameters(int _value) { 303 void set numTypeParameters(int _value) {
317 assert(!_finished); 304 assert(!_finished);
318 assert(!_json.containsKey("numTypeParameters")); 305 _numTypeParameters = _value;
319 if (_value != null) {
320 _json["numTypeParameters"] = _value;
321 }
322 } 306 }
323 307
324 Map finish() { 308 fb.Offset finish(fb.Builder fbBuilder) {
325 assert(!_finished); 309 assert(!_finished);
326 _finished = true; 310 _finished = true;
327 return _json; 311 fbBuilder.startTable();
312 if (_dependency != null && _dependency != 0) {
313 fbBuilder.addInt32(0, _dependency);
314 }
315 if (_kind != null && _kind != PrelinkedReferenceKind.classOrEnum) {
316 fbBuilder.addInt32(1, _kind.index);
317 }
318 if (_unit != null && _unit != 0) {
319 fbBuilder.addInt32(2, _unit);
320 }
321 if (_numTypeParameters != null && _numTypeParameters != 0) {
322 fbBuilder.addInt32(3, _numTypeParameters);
323 }
324 return fbBuilder.endTable();
328 } 325 }
329 } 326 }
330 327
331 PrelinkedReferenceBuilder encodePrelinkedReference(base.BuilderContext builderCo ntext, {int dependency, PrelinkedReferenceKind kind, int unit, int numTypeParame ters}) { 328 PrelinkedReferenceBuilder encodePrelinkedReference(base.BuilderContext builderCo ntext, {int dependency, PrelinkedReferenceKind kind, int unit, int numTypeParame ters}) {
332 PrelinkedReferenceBuilder builder = new PrelinkedReferenceBuilder(builderConte xt); 329 PrelinkedReferenceBuilder builder = new PrelinkedReferenceBuilder(builderConte xt);
333 builder.dependency = dependency; 330 builder.dependency = dependency;
334 builder.kind = kind; 331 builder.kind = kind;
335 builder.unit = unit; 332 builder.unit = unit;
336 builder.numTypeParameters = numTypeParameters; 333 builder.numTypeParameters = numTypeParameters;
337 return builder; 334 return builder;
338 } 335 }
339 336
340 /** 337 /**
341 * Pre-linked summary of a compilation unit. 338 * Information about the resolution of an [UnlinkedReference].
342 */ 339 */
343 class PrelinkedUnit extends base.SummaryClass { 340 abstract class PrelinkedReference extends base.SummaryClass {
344 List<PrelinkedReference> _references;
345 341
346 PrelinkedUnit.fromJson(Map json) 342 /**
347 : _references = json["references"]?.map((x) => new PrelinkedReference.fromJs on(x))?.toList(); 343 * Index into [PrelinkedLibrary.dependencies] indicating which imported librar y
344 * declares the entity being referred to.
345 */
346 int get dependency;
347
348 /**
349 * The kind of the entity being referred to. For the pseudo-type `dynamic`,
350 * the kind is [PrelinkedReferenceKind.classOrEnum].
351 */
352 PrelinkedReferenceKind get kind;
353
354 /**
355 * Integer index indicating which unit in the imported library contains the
356 * definition of the entity. As with indices into [PrelinkedLibrary.units],
357 * zero represents the defining compilation unit, and nonzero values
358 * represent parts in the order of the corresponding `part` declarations.
359 */
360 int get unit;
361
362 /**
363 * If the entity being referred to is generic, the number of type parameters
364 * it accepts. Otherwise zero.
365 */
366 int get numTypeParameters;
367 }
368
369 class _PrelinkedReferenceReader extends fb.TableReader<_PrelinkedReferenceReader > implements PrelinkedReference {
370 final fb.BufferPointer _bp;
371
372 const _PrelinkedReferenceReader([this._bp]);
373
374 @override
375 _PrelinkedReferenceReader createReader(fb.BufferPointer bp) => new _PrelinkedR eferenceReader(bp);
348 376
349 @override 377 @override
350 Map<String, Object> toMap() => { 378 Map<String, Object> toMap() => {
351 "references": references, 379 "dependency": dependency,
380 "kind": kind,
381 "unit": unit,
382 "numTypeParameters": numTypeParameters,
352 }; 383 };
353 384
354 /** 385 @override
355 * For each reference in [UnlinkedUnit.references], information about how 386 int get dependency => const fb.Int32Reader().vTableGet(_bp, 0, 0);
356 * that reference is resolved. 387
357 */ 388 @override
358 List<PrelinkedReference> get references => _references ?? const <PrelinkedRefe rence>[]; 389 PrelinkedReferenceKind get kind {
390 int index = const fb.Int32Reader().vTableGet(_bp, 1, 0);
391 return PrelinkedReferenceKind.values[index];
392 }
393
394 @override
395 int get unit => const fb.Int32Reader().vTableGet(_bp, 2, 0);
396
397 @override
398 int get numTypeParameters => const fb.Int32Reader().vTableGet(_bp, 3, 0);
359 } 399 }
360 400
361 class PrelinkedUnitBuilder { 401 class PrelinkedUnitBuilder {
362 final Map _json = {}; 402 bool _finished = false;
363 403
364 bool _finished = false; 404 List<PrelinkedReferenceBuilder> _references;
365 405
366 PrelinkedUnitBuilder(base.BuilderContext context); 406 PrelinkedUnitBuilder(base.BuilderContext context);
367 407
368 /** 408 /**
369 * For each reference in [UnlinkedUnit.references], information about how 409 * For each reference in [UnlinkedUnit.references], information about how
370 * that reference is resolved. 410 * that reference is resolved.
371 */ 411 */
372 void set references(List<PrelinkedReferenceBuilder> _value) { 412 void set references(List<PrelinkedReferenceBuilder> _value) {
373 assert(!_finished); 413 assert(!_finished);
374 assert(!_json.containsKey("references")); 414 _references = _value;
375 if (!(_value == null || _value.isEmpty)) {
376 _json["references"] = _value.map((b) => b.finish()).toList();
377 }
378 } 415 }
379 416
380 Map finish() { 417 fb.Offset finish(fb.Builder fbBuilder) {
381 assert(!_finished); 418 assert(!_finished);
382 _finished = true; 419 _finished = true;
383 return _json; 420 fb.Offset offset_references;
421 if (!(_references == null || _references.isEmpty)) {
422 offset_references = fbBuilder.writeList(_references.map((b) => b.finish(fb Builder)).toList());
423 }
424 fbBuilder.startTable();
425 if (offset_references != null) {
426 fbBuilder.addOffset(0, offset_references);
427 }
428 return fbBuilder.endTable();
384 } 429 }
385 } 430 }
386 431
387 PrelinkedUnitBuilder encodePrelinkedUnit(base.BuilderContext builderContext, {Li st<PrelinkedReferenceBuilder> references}) { 432 PrelinkedUnitBuilder encodePrelinkedUnit(base.BuilderContext builderContext, {Li st<PrelinkedReferenceBuilder> references}) {
388 PrelinkedUnitBuilder builder = new PrelinkedUnitBuilder(builderContext); 433 PrelinkedUnitBuilder builder = new PrelinkedUnitBuilder(builderContext);
389 builder.references = references; 434 builder.references = references;
390 return builder; 435 return builder;
391 } 436 }
392 437
393 /** 438 /**
394 * Information about SDK. 439 * Pre-linked summary of a compilation unit.
395 */ 440 */
396 class SdkBundle extends base.SummaryClass { 441 abstract class PrelinkedUnit extends base.SummaryClass {
397 List<String> _prelinkedLibraryUris;
398 List<PrelinkedLibrary> _prelinkedLibraries;
399 List<String> _unlinkedUnitUris;
400 List<UnlinkedUnit> _unlinkedUnits;
401 442
402 SdkBundle.fromJson(Map json) 443 /**
403 : _prelinkedLibraryUris = json["prelinkedLibraryUris"], 444 * For each reference in [UnlinkedUnit.references], information about how
404 _prelinkedLibraries = json["prelinkedLibraries"]?.map((x) => new Prelinked Library.fromJson(x))?.toList(), 445 * that reference is resolved.
405 _unlinkedUnitUris = json["unlinkedUnitUris"], 446 */
406 _unlinkedUnits = json["unlinkedUnits"]?.map((x) => new UnlinkedUnit.fromJs on(x))?.toList(); 447 List<PrelinkedReference> get references;
448 }
449
450 class _PrelinkedUnitReader extends fb.TableReader<_PrelinkedUnitReader> implemen ts PrelinkedUnit {
451 final fb.BufferPointer _bp;
452
453 const _PrelinkedUnitReader([this._bp]);
454
455 @override
456 _PrelinkedUnitReader createReader(fb.BufferPointer bp) => new _PrelinkedUnitRe ader(bp);
407 457
408 @override 458 @override
409 Map<String, Object> toMap() => { 459 Map<String, Object> toMap() => {
410 "prelinkedLibraryUris": prelinkedLibraryUris, 460 "references": references,
411 "prelinkedLibraries": prelinkedLibraries,
412 "unlinkedUnitUris": unlinkedUnitUris,
413 "unlinkedUnits": unlinkedUnits,
414 }; 461 };
415 462
416 SdkBundle.fromBuffer(List<int> buffer) : this.fromJson(JSON.decode(UTF8.decode (buffer))); 463 @override
417 464 List<PrelinkedReference> get references => const fb.ListReader<PrelinkedRefere nce>(const _PrelinkedReferenceReader()).vTableGet(_bp, 0, const <PrelinkedRefere nce>[]);
418 /**
419 * The list of URIs of items in [prelinkedLibraries], e.g. `dart:core`.
420 */
421 List<String> get prelinkedLibraryUris => _prelinkedLibraryUris ?? const <Strin g>[];
422
423 /**
424 * Pre-linked libraries.
425 */
426 List<PrelinkedLibrary> get prelinkedLibraries => _prelinkedLibraries ?? const <PrelinkedLibrary>[];
427
428 /**
429 * The list of URIs of items in [unlinkedUnits], e.g. `dart:core/bool.dart`.
430 */
431 List<String> get unlinkedUnitUris => _unlinkedUnitUris ?? const <String>[];
432
433 /**
434 * Unlinked information for the compilation units constituting the SDK.
435 */
436 List<UnlinkedUnit> get unlinkedUnits => _unlinkedUnits ?? const <UnlinkedUnit> [];
437 } 465 }
438 466
439 class SdkBundleBuilder { 467 class SdkBundleBuilder {
440 final Map _json = {}; 468 bool _finished = false;
441 469
442 bool _finished = false; 470 List<String> _prelinkedLibraryUris;
471 List<PrelinkedLibraryBuilder> _prelinkedLibraries;
472 List<String> _unlinkedUnitUris;
473 List<UnlinkedUnitBuilder> _unlinkedUnits;
443 474
444 SdkBundleBuilder(base.BuilderContext context); 475 SdkBundleBuilder(base.BuilderContext context);
445 476
446 /** 477 /**
447 * The list of URIs of items in [prelinkedLibraries], e.g. `dart:core`. 478 * The list of URIs of items in [prelinkedLibraries], e.g. `dart:core`.
448 */ 479 */
449 void set prelinkedLibraryUris(List<String> _value) { 480 void set prelinkedLibraryUris(List<String> _value) {
450 assert(!_finished); 481 assert(!_finished);
451 assert(!_json.containsKey("prelinkedLibraryUris")); 482 _prelinkedLibraryUris = _value;
452 if (!(_value == null || _value.isEmpty)) {
453 _json["prelinkedLibraryUris"] = _value.toList();
454 }
455 } 483 }
456 484
457 /** 485 /**
458 * Pre-linked libraries. 486 * Pre-linked libraries.
459 */ 487 */
460 void set prelinkedLibraries(List<PrelinkedLibraryBuilder> _value) { 488 void set prelinkedLibraries(List<PrelinkedLibraryBuilder> _value) {
461 assert(!_finished); 489 assert(!_finished);
462 assert(!_json.containsKey("prelinkedLibraries")); 490 _prelinkedLibraries = _value;
463 if (!(_value == null || _value.isEmpty)) {
464 _json["prelinkedLibraries"] = _value.map((b) => b.finish()).toList();
465 }
466 } 491 }
467 492
468 /** 493 /**
469 * The list of URIs of items in [unlinkedUnits], e.g. `dart:core/bool.dart`. 494 * The list of URIs of items in [unlinkedUnits], e.g. `dart:core/bool.dart`.
470 */ 495 */
471 void set unlinkedUnitUris(List<String> _value) { 496 void set unlinkedUnitUris(List<String> _value) {
472 assert(!_finished); 497 assert(!_finished);
473 assert(!_json.containsKey("unlinkedUnitUris")); 498 _unlinkedUnitUris = _value;
474 if (!(_value == null || _value.isEmpty)) {
475 _json["unlinkedUnitUris"] = _value.toList();
476 }
477 } 499 }
478 500
479 /** 501 /**
480 * Unlinked information for the compilation units constituting the SDK. 502 * Unlinked information for the compilation units constituting the SDK.
481 */ 503 */
482 void set unlinkedUnits(List<UnlinkedUnitBuilder> _value) { 504 void set unlinkedUnits(List<UnlinkedUnitBuilder> _value) {
483 assert(!_finished); 505 assert(!_finished);
484 assert(!_json.containsKey("unlinkedUnits")); 506 _unlinkedUnits = _value;
485 if (!(_value == null || _value.isEmpty)) {
486 _json["unlinkedUnits"] = _value.map((b) => b.finish()).toList();
487 }
488 } 507 }
489 508
490 List<int> toBuffer() => UTF8.encode(JSON.encode(finish())); 509 List<int> toBuffer() {
510 fb.Builder fbBuilder = new fb.Builder();
511 return fbBuilder.finish(finish(fbBuilder));
512 }
491 513
492 Map finish() { 514 fb.Offset finish(fb.Builder fbBuilder) {
493 assert(!_finished); 515 assert(!_finished);
494 _finished = true; 516 _finished = true;
495 return _json; 517 fb.Offset offset_prelinkedLibraryUris;
518 fb.Offset offset_prelinkedLibraries;
519 fb.Offset offset_unlinkedUnitUris;
520 fb.Offset offset_unlinkedUnits;
521 if (!(_prelinkedLibraryUris == null || _prelinkedLibraryUris.isEmpty)) {
522 offset_prelinkedLibraryUris = fbBuilder.writeList(_prelinkedLibraryUris.ma p((b) => fbBuilder.writeString(b)).toList());
523 }
524 if (!(_prelinkedLibraries == null || _prelinkedLibraries.isEmpty)) {
525 offset_prelinkedLibraries = fbBuilder.writeList(_prelinkedLibraries.map((b ) => b.finish(fbBuilder)).toList());
526 }
527 if (!(_unlinkedUnitUris == null || _unlinkedUnitUris.isEmpty)) {
528 offset_unlinkedUnitUris = fbBuilder.writeList(_unlinkedUnitUris.map((b) => fbBuilder.writeString(b)).toList());
529 }
530 if (!(_unlinkedUnits == null || _unlinkedUnits.isEmpty)) {
531 offset_unlinkedUnits = fbBuilder.writeList(_unlinkedUnits.map((b) => b.fin ish(fbBuilder)).toList());
532 }
533 fbBuilder.startTable();
534 if (offset_prelinkedLibraryUris != null) {
535 fbBuilder.addOffset(0, offset_prelinkedLibraryUris);
536 }
537 if (offset_prelinkedLibraries != null) {
538 fbBuilder.addOffset(1, offset_prelinkedLibraries);
539 }
540 if (offset_unlinkedUnitUris != null) {
541 fbBuilder.addOffset(2, offset_unlinkedUnitUris);
542 }
543 if (offset_unlinkedUnits != null) {
544 fbBuilder.addOffset(3, offset_unlinkedUnits);
545 }
546 return fbBuilder.endTable();
496 } 547 }
497 } 548 }
498 549
499 SdkBundleBuilder encodeSdkBundle(base.BuilderContext builderContext, {List<Strin g> prelinkedLibraryUris, List<PrelinkedLibraryBuilder> prelinkedLibraries, List< String> unlinkedUnitUris, List<UnlinkedUnitBuilder> unlinkedUnits}) { 550 SdkBundleBuilder encodeSdkBundle(base.BuilderContext builderContext, {List<Strin g> prelinkedLibraryUris, List<PrelinkedLibraryBuilder> prelinkedLibraries, List< String> unlinkedUnitUris, List<UnlinkedUnitBuilder> unlinkedUnits}) {
500 SdkBundleBuilder builder = new SdkBundleBuilder(builderContext); 551 SdkBundleBuilder builder = new SdkBundleBuilder(builderContext);
501 builder.prelinkedLibraryUris = prelinkedLibraryUris; 552 builder.prelinkedLibraryUris = prelinkedLibraryUris;
502 builder.prelinkedLibraries = prelinkedLibraries; 553 builder.prelinkedLibraries = prelinkedLibraries;
503 builder.unlinkedUnitUris = unlinkedUnitUris; 554 builder.unlinkedUnitUris = unlinkedUnitUris;
504 builder.unlinkedUnits = unlinkedUnits; 555 builder.unlinkedUnits = unlinkedUnits;
505 return builder; 556 return builder;
506 } 557 }
507 558
508 /** 559 /**
509 * Unlinked summary information about a class declaration. 560 * Information about SDK.
510 */ 561 */
511 class UnlinkedClass extends base.SummaryClass { 562 abstract class SdkBundle extends base.SummaryClass {
563 factory SdkBundle.fromBuffer(List<int> buffer) {
564 fb.BufferPointer rootRef = new fb.BufferPointer.fromBytes(buffer);
565 return const _SdkBundleReader().read(rootRef);
566 }
567
568 /**
569 * The list of URIs of items in [prelinkedLibraries], e.g. `dart:core`.
570 */
571 List<String> get prelinkedLibraryUris;
572
573 /**
574 * Pre-linked libraries.
575 */
576 List<PrelinkedLibrary> get prelinkedLibraries;
577
578 /**
579 * The list of URIs of items in [unlinkedUnits], e.g. `dart:core/bool.dart`.
580 */
581 List<String> get unlinkedUnitUris;
582
583 /**
584 * Unlinked information for the compilation units constituting the SDK.
585 */
586 List<UnlinkedUnit> get unlinkedUnits;
587 }
588
589 class _SdkBundleReader extends fb.TableReader<_SdkBundleReader> implements SdkBu ndle {
590 final fb.BufferPointer _bp;
591
592 const _SdkBundleReader([this._bp]);
593
594 @override
595 _SdkBundleReader createReader(fb.BufferPointer bp) => new _SdkBundleReader(bp) ;
596
597 @override
598 Map<String, Object> toMap() => {
599 "prelinkedLibraryUris": prelinkedLibraryUris,
600 "prelinkedLibraries": prelinkedLibraries,
601 "unlinkedUnitUris": unlinkedUnitUris,
602 "unlinkedUnits": unlinkedUnits,
603 };
604
605 @override
606 List<String> get prelinkedLibraryUris => const fb.ListReader<String>(const fb. StringReader()).vTableGet(_bp, 0, const <String>[]);
607
608 @override
609 List<PrelinkedLibrary> get prelinkedLibraries => const fb.ListReader<Prelinked Library>(const _PrelinkedLibraryReader()).vTableGet(_bp, 1, const <PrelinkedLibr ary>[]);
610
611 @override
612 List<String> get unlinkedUnitUris => const fb.ListReader<String>(const fb.Stri ngReader()).vTableGet(_bp, 2, const <String>[]);
613
614 @override
615 List<UnlinkedUnit> get unlinkedUnits => const fb.ListReader<UnlinkedUnit>(cons t _UnlinkedUnitReader()).vTableGet(_bp, 3, const <UnlinkedUnit>[]);
616 }
617
618 class UnlinkedClassBuilder {
619 bool _finished = false;
620
512 String _name; 621 String _name;
513 int _nameOffset; 622 int _nameOffset;
514 UnlinkedDocumentationComment _documentationComment; 623 UnlinkedDocumentationCommentBuilder _documentationComment;
515 List<UnlinkedTypeParam> _typeParameters; 624 List<UnlinkedTypeParamBuilder> _typeParameters;
516 UnlinkedTypeRef _supertype; 625 UnlinkedTypeRefBuilder _supertype;
517 List<UnlinkedTypeRef> _mixins; 626 List<UnlinkedTypeRefBuilder> _mixins;
518 List<UnlinkedTypeRef> _interfaces; 627 List<UnlinkedTypeRefBuilder> _interfaces;
519 List<UnlinkedVariable> _fields; 628 List<UnlinkedVariableBuilder> _fields;
520 List<UnlinkedExecutable> _executables; 629 List<UnlinkedExecutableBuilder> _executables;
521 bool _isAbstract; 630 bool _isAbstract;
522 bool _isMixinApplication; 631 bool _isMixinApplication;
523 bool _hasNoSupertype; 632 bool _hasNoSupertype;
524 633
525 UnlinkedClass.fromJson(Map json)
526 : _name = json["name"],
527 _nameOffset = json["nameOffset"],
528 _documentationComment = json["documentationComment"] == null ? null : new UnlinkedDocumentationComment.fromJson(json["documentationComment"]),
529 _typeParameters = json["typeParameters"]?.map((x) => new UnlinkedTypeParam .fromJson(x))?.toList(),
530 _supertype = json["supertype"] == null ? null : new UnlinkedTypeRef.fromJs on(json["supertype"]),
531 _mixins = json["mixins"]?.map((x) => new UnlinkedTypeRef.fromJson(x))?.toL ist(),
532 _interfaces = json["interfaces"]?.map((x) => new UnlinkedTypeRef.fromJson( x))?.toList(),
533 _fields = json["fields"]?.map((x) => new UnlinkedVariable.fromJson(x))?.to List(),
534 _executables = json["executables"]?.map((x) => new UnlinkedExecutable.from Json(x))?.toList(),
535 _isAbstract = json["isAbstract"],
536 _isMixinApplication = json["isMixinApplication"],
537 _hasNoSupertype = json["hasNoSupertype"];
538
539 @override
540 Map<String, Object> toMap() => {
541 "name": name,
542 "nameOffset": nameOffset,
543 "documentationComment": documentationComment,
544 "typeParameters": typeParameters,
545 "supertype": supertype,
546 "mixins": mixins,
547 "interfaces": interfaces,
548 "fields": fields,
549 "executables": executables,
550 "isAbstract": isAbstract,
551 "isMixinApplication": isMixinApplication,
552 "hasNoSupertype": hasNoSupertype,
553 };
554
555 /**
556 * Name of the class.
557 */
558 String get name => _name ?? '';
559
560 /**
561 * Offset of the class name relative to the beginning of the file.
562 */
563 int get nameOffset => _nameOffset ?? 0;
564
565 /**
566 * Documentation comment for the class, or `null` if there is no
567 * documentation comment.
568 */
569 UnlinkedDocumentationComment get documentationComment => _documentationComment ;
570
571 /**
572 * Type parameters of the class, if any.
573 */
574 List<UnlinkedTypeParam> get typeParameters => _typeParameters ?? const <Unlink edTypeParam>[];
575
576 /**
577 * Supertype of the class, or `null` if either (a) the class doesn't
578 * explicitly declare a supertype (and hence has supertype `Object`), or (b)
579 * the class *is* `Object` (and hence has no supertype).
580 */
581 UnlinkedTypeRef get supertype => _supertype;
582
583 /**
584 * Mixins appearing in a `with` clause, if any.
585 */
586 List<UnlinkedTypeRef> get mixins => _mixins ?? const <UnlinkedTypeRef>[];
587
588 /**
589 * Interfaces appearing in an `implements` clause, if any.
590 */
591 List<UnlinkedTypeRef> get interfaces => _interfaces ?? const <UnlinkedTypeRef> [];
592
593 /**
594 * Field declarations contained in the class.
595 */
596 List<UnlinkedVariable> get fields => _fields ?? const <UnlinkedVariable>[];
597
598 /**
599 * Executable objects (methods, getters, and setters) contained in the class.
600 */
601 List<UnlinkedExecutable> get executables => _executables ?? const <UnlinkedExe cutable>[];
602
603 /**
604 * Indicates whether the class is declared with the `abstract` keyword.
605 */
606 bool get isAbstract => _isAbstract ?? false;
607
608 /**
609 * Indicates whether the class is declared using mixin application syntax.
610 */
611 bool get isMixinApplication => _isMixinApplication ?? false;
612
613 /**
614 * Indicates whether this class is the core "Object" class (and hence has no
615 * supertype)
616 */
617 bool get hasNoSupertype => _hasNoSupertype ?? false;
618 }
619
620 class UnlinkedClassBuilder {
621 final Map _json = {};
622
623 bool _finished = false;
624
625 UnlinkedClassBuilder(base.BuilderContext context); 634 UnlinkedClassBuilder(base.BuilderContext context);
626 635
627 /** 636 /**
628 * Name of the class. 637 * Name of the class.
629 */ 638 */
630 void set name(String _value) { 639 void set name(String _value) {
631 assert(!_finished); 640 assert(!_finished);
632 assert(!_json.containsKey("name")); 641 _name = _value;
633 if (_value != null) {
634 _json["name"] = _value;
635 }
636 } 642 }
637 643
638 /** 644 /**
639 * Offset of the class name relative to the beginning of the file. 645 * Offset of the class name relative to the beginning of the file.
640 */ 646 */
641 void set nameOffset(int _value) { 647 void set nameOffset(int _value) {
642 assert(!_finished); 648 assert(!_finished);
643 assert(!_json.containsKey("nameOffset")); 649 _nameOffset = _value;
644 if (_value != null) {
645 _json["nameOffset"] = _value;
646 }
647 } 650 }
648 651
649 /** 652 /**
650 * Documentation comment for the class, or `null` if there is no 653 * Documentation comment for the class, or `null` if there is no
651 * documentation comment. 654 * documentation comment.
652 */ 655 */
653 void set documentationComment(UnlinkedDocumentationCommentBuilder _value) { 656 void set documentationComment(UnlinkedDocumentationCommentBuilder _value) {
654 assert(!_finished); 657 assert(!_finished);
655 assert(!_json.containsKey("documentationComment")); 658 _documentationComment = _value;
656 if (_value != null) {
657 _json["documentationComment"] = _value.finish();
658 }
659 } 659 }
660 660
661 /** 661 /**
662 * Type parameters of the class, if any. 662 * Type parameters of the class, if any.
663 */ 663 */
664 void set typeParameters(List<UnlinkedTypeParamBuilder> _value) { 664 void set typeParameters(List<UnlinkedTypeParamBuilder> _value) {
665 assert(!_finished); 665 assert(!_finished);
666 assert(!_json.containsKey("typeParameters")); 666 _typeParameters = _value;
667 if (!(_value == null || _value.isEmpty)) {
668 _json["typeParameters"] = _value.map((b) => b.finish()).toList();
669 }
670 } 667 }
671 668
672 /** 669 /**
673 * Supertype of the class, or `null` if either (a) the class doesn't 670 * Supertype of the class, or `null` if either (a) the class doesn't
674 * explicitly declare a supertype (and hence has supertype `Object`), or (b) 671 * explicitly declare a supertype (and hence has supertype `Object`), or (b)
675 * the class *is* `Object` (and hence has no supertype). 672 * the class *is* `Object` (and hence has no supertype).
676 */ 673 */
677 void set supertype(UnlinkedTypeRefBuilder _value) { 674 void set supertype(UnlinkedTypeRefBuilder _value) {
678 assert(!_finished); 675 assert(!_finished);
679 assert(!_json.containsKey("supertype")); 676 _supertype = _value;
680 if (_value != null) {
681 _json["supertype"] = _value.finish();
682 }
683 } 677 }
684 678
685 /** 679 /**
686 * Mixins appearing in a `with` clause, if any. 680 * Mixins appearing in a `with` clause, if any.
687 */ 681 */
688 void set mixins(List<UnlinkedTypeRefBuilder> _value) { 682 void set mixins(List<UnlinkedTypeRefBuilder> _value) {
689 assert(!_finished); 683 assert(!_finished);
690 assert(!_json.containsKey("mixins")); 684 _mixins = _value;
691 if (!(_value == null || _value.isEmpty)) {
692 _json["mixins"] = _value.map((b) => b.finish()).toList();
693 }
694 } 685 }
695 686
696 /** 687 /**
697 * Interfaces appearing in an `implements` clause, if any. 688 * Interfaces appearing in an `implements` clause, if any.
698 */ 689 */
699 void set interfaces(List<UnlinkedTypeRefBuilder> _value) { 690 void set interfaces(List<UnlinkedTypeRefBuilder> _value) {
700 assert(!_finished); 691 assert(!_finished);
701 assert(!_json.containsKey("interfaces")); 692 _interfaces = _value;
702 if (!(_value == null || _value.isEmpty)) {
703 _json["interfaces"] = _value.map((b) => b.finish()).toList();
704 }
705 } 693 }
706 694
707 /** 695 /**
708 * Field declarations contained in the class. 696 * Field declarations contained in the class.
709 */ 697 */
710 void set fields(List<UnlinkedVariableBuilder> _value) { 698 void set fields(List<UnlinkedVariableBuilder> _value) {
711 assert(!_finished); 699 assert(!_finished);
712 assert(!_json.containsKey("fields")); 700 _fields = _value;
713 if (!(_value == null || _value.isEmpty)) {
714 _json["fields"] = _value.map((b) => b.finish()).toList();
715 }
716 } 701 }
717 702
718 /** 703 /**
719 * Executable objects (methods, getters, and setters) contained in the class. 704 * Executable objects (methods, getters, and setters) contained in the class.
720 */ 705 */
721 void set executables(List<UnlinkedExecutableBuilder> _value) { 706 void set executables(List<UnlinkedExecutableBuilder> _value) {
722 assert(!_finished); 707 assert(!_finished);
723 assert(!_json.containsKey("executables")); 708 _executables = _value;
724 if (!(_value == null || _value.isEmpty)) {
725 _json["executables"] = _value.map((b) => b.finish()).toList();
726 }
727 } 709 }
728 710
729 /** 711 /**
730 * Indicates whether the class is declared with the `abstract` keyword. 712 * Indicates whether the class is declared with the `abstract` keyword.
731 */ 713 */
732 void set isAbstract(bool _value) { 714 void set isAbstract(bool _value) {
733 assert(!_finished); 715 assert(!_finished);
734 assert(!_json.containsKey("isAbstract")); 716 _isAbstract = _value;
735 if (_value != null) {
736 _json["isAbstract"] = _value;
737 }
738 } 717 }
739 718
740 /** 719 /**
741 * Indicates whether the class is declared using mixin application syntax. 720 * Indicates whether the class is declared using mixin application syntax.
742 */ 721 */
743 void set isMixinApplication(bool _value) { 722 void set isMixinApplication(bool _value) {
744 assert(!_finished); 723 assert(!_finished);
745 assert(!_json.containsKey("isMixinApplication")); 724 _isMixinApplication = _value;
746 if (_value != null) {
747 _json["isMixinApplication"] = _value;
748 }
749 } 725 }
750 726
751 /** 727 /**
752 * Indicates whether this class is the core "Object" class (and hence has no 728 * Indicates whether this class is the core "Object" class (and hence has no
753 * supertype) 729 * supertype)
754 */ 730 */
755 void set hasNoSupertype(bool _value) { 731 void set hasNoSupertype(bool _value) {
756 assert(!_finished); 732 assert(!_finished);
757 assert(!_json.containsKey("hasNoSupertype")); 733 _hasNoSupertype = _value;
758 if (_value != null) {
759 _json["hasNoSupertype"] = _value;
760 }
761 } 734 }
762 735
763 Map finish() { 736 fb.Offset finish(fb.Builder fbBuilder) {
764 assert(!_finished); 737 assert(!_finished);
765 _finished = true; 738 _finished = true;
766 return _json; 739 fb.Offset offset_name;
740 fb.Offset offset_documentationComment;
741 fb.Offset offset_typeParameters;
742 fb.Offset offset_supertype;
743 fb.Offset offset_mixins;
744 fb.Offset offset_interfaces;
745 fb.Offset offset_fields;
746 fb.Offset offset_executables;
747 if (_name != null) {
748 offset_name = fbBuilder.writeString(_name);
749 }
750 if (_documentationComment != null) {
751 offset_documentationComment = _documentationComment.finish(fbBuilder);
752 }
753 if (!(_typeParameters == null || _typeParameters.isEmpty)) {
754 offset_typeParameters = fbBuilder.writeList(_typeParameters.map((b) => b.f inish(fbBuilder)).toList());
755 }
756 if (_supertype != null) {
757 offset_supertype = _supertype.finish(fbBuilder);
758 }
759 if (!(_mixins == null || _mixins.isEmpty)) {
760 offset_mixins = fbBuilder.writeList(_mixins.map((b) => b.finish(fbBuilder) ).toList());
761 }
762 if (!(_interfaces == null || _interfaces.isEmpty)) {
763 offset_interfaces = fbBuilder.writeList(_interfaces.map((b) => b.finish(fb Builder)).toList());
764 }
765 if (!(_fields == null || _fields.isEmpty)) {
766 offset_fields = fbBuilder.writeList(_fields.map((b) => b.finish(fbBuilder) ).toList());
767 }
768 if (!(_executables == null || _executables.isEmpty)) {
769 offset_executables = fbBuilder.writeList(_executables.map((b) => b.finish( fbBuilder)).toList());
770 }
771 fbBuilder.startTable();
772 if (offset_name != null) {
773 fbBuilder.addOffset(0, offset_name);
774 }
775 if (_nameOffset != null && _nameOffset != 0) {
776 fbBuilder.addInt32(1, _nameOffset);
777 }
778 if (offset_documentationComment != null) {
779 fbBuilder.addOffset(2, offset_documentationComment);
780 }
781 if (offset_typeParameters != null) {
782 fbBuilder.addOffset(3, offset_typeParameters);
783 }
784 if (offset_supertype != null) {
785 fbBuilder.addOffset(4, offset_supertype);
786 }
787 if (offset_mixins != null) {
788 fbBuilder.addOffset(5, offset_mixins);
789 }
790 if (offset_interfaces != null) {
791 fbBuilder.addOffset(6, offset_interfaces);
792 }
793 if (offset_fields != null) {
794 fbBuilder.addOffset(7, offset_fields);
795 }
796 if (offset_executables != null) {
797 fbBuilder.addOffset(8, offset_executables);
798 }
799 if (_isAbstract == true) {
800 fbBuilder.addInt8(9, 1);
801 }
802 if (_isMixinApplication == true) {
803 fbBuilder.addInt8(10, 1);
804 }
805 if (_hasNoSupertype == true) {
806 fbBuilder.addInt8(11, 1);
807 }
808 return fbBuilder.endTable();
767 } 809 }
768 } 810 }
769 811
770 UnlinkedClassBuilder encodeUnlinkedClass(base.BuilderContext builderContext, {St ring name, int nameOffset, UnlinkedDocumentationCommentBuilder documentationComm ent, List<UnlinkedTypeParamBuilder> typeParameters, UnlinkedTypeRefBuilder super type, List<UnlinkedTypeRefBuilder> mixins, List<UnlinkedTypeRefBuilder> interfac es, List<UnlinkedVariableBuilder> fields, List<UnlinkedExecutableBuilder> execut ables, bool isAbstract, bool isMixinApplication, bool hasNoSupertype}) { 812 UnlinkedClassBuilder encodeUnlinkedClass(base.BuilderContext builderContext, {St ring name, int nameOffset, UnlinkedDocumentationCommentBuilder documentationComm ent, List<UnlinkedTypeParamBuilder> typeParameters, UnlinkedTypeRefBuilder super type, List<UnlinkedTypeRefBuilder> mixins, List<UnlinkedTypeRefBuilder> interfac es, List<UnlinkedVariableBuilder> fields, List<UnlinkedExecutableBuilder> execut ables, bool isAbstract, bool isMixinApplication, bool hasNoSupertype}) {
771 UnlinkedClassBuilder builder = new UnlinkedClassBuilder(builderContext); 813 UnlinkedClassBuilder builder = new UnlinkedClassBuilder(builderContext);
772 builder.name = name; 814 builder.name = name;
773 builder.nameOffset = nameOffset; 815 builder.nameOffset = nameOffset;
774 builder.documentationComment = documentationComment; 816 builder.documentationComment = documentationComment;
775 builder.typeParameters = typeParameters; 817 builder.typeParameters = typeParameters;
776 builder.supertype = supertype; 818 builder.supertype = supertype;
777 builder.mixins = mixins; 819 builder.mixins = mixins;
778 builder.interfaces = interfaces; 820 builder.interfaces = interfaces;
779 builder.fields = fields; 821 builder.fields = fields;
780 builder.executables = executables; 822 builder.executables = executables;
781 builder.isAbstract = isAbstract; 823 builder.isAbstract = isAbstract;
782 builder.isMixinApplication = isMixinApplication; 824 builder.isMixinApplication = isMixinApplication;
783 builder.hasNoSupertype = hasNoSupertype; 825 builder.hasNoSupertype = hasNoSupertype;
784 return builder; 826 return builder;
785 } 827 }
786 828
787 /** 829 /**
788 * Unlinked summary information about a `show` or `hide` combinator in an 830 * Unlinked summary information about a class declaration.
789 * import or export declaration.
790 */ 831 */
791 class UnlinkedCombinator extends base.SummaryClass { 832 abstract class UnlinkedClass extends base.SummaryClass {
792 List<String> _shows;
793 List<String> _hides;
794 833
795 UnlinkedCombinator.fromJson(Map json) 834 /**
796 : _shows = json["shows"], 835 * Name of the class.
797 _hides = json["hides"]; 836 */
837 String get name;
838
839 /**
840 * Offset of the class name relative to the beginning of the file.
841 */
842 int get nameOffset;
843
844 /**
845 * Documentation comment for the class, or `null` if there is no
846 * documentation comment.
847 */
848 UnlinkedDocumentationComment get documentationComment;
849
850 /**
851 * Type parameters of the class, if any.
852 */
853 List<UnlinkedTypeParam> get typeParameters;
854
855 /**
856 * Supertype of the class, or `null` if either (a) the class doesn't
857 * explicitly declare a supertype (and hence has supertype `Object`), or (b)
858 * the class *is* `Object` (and hence has no supertype).
859 */
860 UnlinkedTypeRef get supertype;
861
862 /**
863 * Mixins appearing in a `with` clause, if any.
864 */
865 List<UnlinkedTypeRef> get mixins;
866
867 /**
868 * Interfaces appearing in an `implements` clause, if any.
869 */
870 List<UnlinkedTypeRef> get interfaces;
871
872 /**
873 * Field declarations contained in the class.
874 */
875 List<UnlinkedVariable> get fields;
876
877 /**
878 * Executable objects (methods, getters, and setters) contained in the class.
879 */
880 List<UnlinkedExecutable> get executables;
881
882 /**
883 * Indicates whether the class is declared with the `abstract` keyword.
884 */
885 bool get isAbstract;
886
887 /**
888 * Indicates whether the class is declared using mixin application syntax.
889 */
890 bool get isMixinApplication;
891
892 /**
893 * Indicates whether this class is the core "Object" class (and hence has no
894 * supertype)
895 */
896 bool get hasNoSupertype;
897 }
898
899 class _UnlinkedClassReader extends fb.TableReader<_UnlinkedClassReader> implemen ts UnlinkedClass {
900 final fb.BufferPointer _bp;
901
902 const _UnlinkedClassReader([this._bp]);
903
904 @override
905 _UnlinkedClassReader createReader(fb.BufferPointer bp) => new _UnlinkedClassRe ader(bp);
798 906
799 @override 907 @override
800 Map<String, Object> toMap() => { 908 Map<String, Object> toMap() => {
801 "shows": shows, 909 "name": name,
802 "hides": hides, 910 "nameOffset": nameOffset,
911 "documentationComment": documentationComment,
912 "typeParameters": typeParameters,
913 "supertype": supertype,
914 "mixins": mixins,
915 "interfaces": interfaces,
916 "fields": fields,
917 "executables": executables,
918 "isAbstract": isAbstract,
919 "isMixinApplication": isMixinApplication,
920 "hasNoSupertype": hasNoSupertype,
803 }; 921 };
804 922
805 /** 923 @override
806 * List of names which are shown. Empty if this is a `hide` combinator. 924 String get name => const fb.StringReader().vTableGet(_bp, 0, '');
807 */
808 List<String> get shows => _shows ?? const <String>[];
809 925
810 /** 926 @override
811 * List of names which are hidden. Empty if this is a `show` combinator. 927 int get nameOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
812 */ 928
813 List<String> get hides => _hides ?? const <String>[]; 929 @override
930 UnlinkedDocumentationComment get documentationComment => const _UnlinkedDocume ntationCommentReader().vTableGet(_bp, 2, null);
931
932 @override
933 List<UnlinkedTypeParam> get typeParameters => const fb.ListReader<UnlinkedType Param>(const _UnlinkedTypeParamReader()).vTableGet(_bp, 3, const <UnlinkedTypePa ram>[]);
934
935 @override
936 UnlinkedTypeRef get supertype => const _UnlinkedTypeRefReader().vTableGet(_bp, 4, null);
937
938 @override
939 List<UnlinkedTypeRef> get mixins => const fb.ListReader<UnlinkedTypeRef>(const _UnlinkedTypeRefReader()).vTableGet(_bp, 5, const <UnlinkedTypeRef>[]);
940
941 @override
942 List<UnlinkedTypeRef> get interfaces => const fb.ListReader<UnlinkedTypeRef>(c onst _UnlinkedTypeRefReader()).vTableGet(_bp, 6, const <UnlinkedTypeRef>[]);
943
944 @override
945 List<UnlinkedVariable> get fields => const fb.ListReader<UnlinkedVariable>(con st _UnlinkedVariableReader()).vTableGet(_bp, 7, const <UnlinkedVariable>[]);
946
947 @override
948 List<UnlinkedExecutable> get executables => const fb.ListReader<UnlinkedExecut able>(const _UnlinkedExecutableReader()).vTableGet(_bp, 8, const <UnlinkedExecut able>[]);
949
950 @override
951 bool get isAbstract => const fb.Int8Reader().vTableGet(_bp, 9, 0) == 1;
952
953 @override
954 bool get isMixinApplication => const fb.Int8Reader().vTableGet(_bp, 10, 0) == 1;
955
956 @override
957 bool get hasNoSupertype => const fb.Int8Reader().vTableGet(_bp, 11, 0) == 1;
814 } 958 }
815 959
816 class UnlinkedCombinatorBuilder { 960 class UnlinkedCombinatorBuilder {
817 final Map _json = {}; 961 bool _finished = false;
818 962
819 bool _finished = false; 963 List<String> _shows;
964 List<String> _hides;
820 965
821 UnlinkedCombinatorBuilder(base.BuilderContext context); 966 UnlinkedCombinatorBuilder(base.BuilderContext context);
822 967
823 /** 968 /**
824 * List of names which are shown. Empty if this is a `hide` combinator. 969 * List of names which are shown. Empty if this is a `hide` combinator.
825 */ 970 */
826 void set shows(List<String> _value) { 971 void set shows(List<String> _value) {
827 assert(!_finished); 972 assert(!_finished);
828 assert(!_json.containsKey("shows")); 973 _shows = _value;
829 if (!(_value == null || _value.isEmpty)) {
830 _json["shows"] = _value.toList();
831 }
832 } 974 }
833 975
834 /** 976 /**
835 * List of names which are hidden. Empty if this is a `show` combinator. 977 * List of names which are hidden. Empty if this is a `show` combinator.
836 */ 978 */
837 void set hides(List<String> _value) { 979 void set hides(List<String> _value) {
838 assert(!_finished); 980 assert(!_finished);
839 assert(!_json.containsKey("hides")); 981 _hides = _value;
840 if (!(_value == null || _value.isEmpty)) {
841 _json["hides"] = _value.toList();
842 }
843 } 982 }
844 983
845 Map finish() { 984 fb.Offset finish(fb.Builder fbBuilder) {
846 assert(!_finished); 985 assert(!_finished);
847 _finished = true; 986 _finished = true;
848 return _json; 987 fb.Offset offset_shows;
988 fb.Offset offset_hides;
989 if (!(_shows == null || _shows.isEmpty)) {
990 offset_shows = fbBuilder.writeList(_shows.map((b) => fbBuilder.writeString (b)).toList());
991 }
992 if (!(_hides == null || _hides.isEmpty)) {
993 offset_hides = fbBuilder.writeList(_hides.map((b) => fbBuilder.writeString (b)).toList());
994 }
995 fbBuilder.startTable();
996 if (offset_shows != null) {
997 fbBuilder.addOffset(0, offset_shows);
998 }
999 if (offset_hides != null) {
1000 fbBuilder.addOffset(1, offset_hides);
1001 }
1002 return fbBuilder.endTable();
849 } 1003 }
850 } 1004 }
851 1005
852 UnlinkedCombinatorBuilder encodeUnlinkedCombinator(base.BuilderContext builderCo ntext, {List<String> shows, List<String> hides}) { 1006 UnlinkedCombinatorBuilder encodeUnlinkedCombinator(base.BuilderContext builderCo ntext, {List<String> shows, List<String> hides}) {
853 UnlinkedCombinatorBuilder builder = new UnlinkedCombinatorBuilder(builderConte xt); 1007 UnlinkedCombinatorBuilder builder = new UnlinkedCombinatorBuilder(builderConte xt);
854 builder.shows = shows; 1008 builder.shows = shows;
855 builder.hides = hides; 1009 builder.hides = hides;
856 return builder; 1010 return builder;
857 } 1011 }
858 1012
859 /** 1013 /**
860 * Unlinked summary information about a documentation comment. 1014 * Unlinked summary information about a `show` or `hide` combinator in an
1015 * import or export declaration.
861 */ 1016 */
862 class UnlinkedDocumentationComment extends base.SummaryClass { 1017 abstract class UnlinkedCombinator extends base.SummaryClass {
1018
1019 /**
1020 * List of names which are shown. Empty if this is a `hide` combinator.
1021 */
1022 List<String> get shows;
1023
1024 /**
1025 * List of names which are hidden. Empty if this is a `show` combinator.
1026 */
1027 List<String> get hides;
1028 }
1029
1030 class _UnlinkedCombinatorReader extends fb.TableReader<_UnlinkedCombinatorReader > implements UnlinkedCombinator {
1031 final fb.BufferPointer _bp;
1032
1033 const _UnlinkedCombinatorReader([this._bp]);
1034
1035 @override
1036 _UnlinkedCombinatorReader createReader(fb.BufferPointer bp) => new _UnlinkedCo mbinatorReader(bp);
1037
1038 @override
1039 Map<String, Object> toMap() => {
1040 "shows": shows,
1041 "hides": hides,
1042 };
1043
1044 @override
1045 List<String> get shows => const fb.ListReader<String>(const fb.StringReader()) .vTableGet(_bp, 0, const <String>[]);
1046
1047 @override
1048 List<String> get hides => const fb.ListReader<String>(const fb.StringReader()) .vTableGet(_bp, 1, const <String>[]);
1049 }
1050
1051 class UnlinkedDocumentationCommentBuilder {
1052 bool _finished = false;
1053
863 String _text; 1054 String _text;
864 int _offset; 1055 int _offset;
865 int _length; 1056 int _length;
866 1057
867 UnlinkedDocumentationComment.fromJson(Map json)
868 : _text = json["text"],
869 _offset = json["offset"],
870 _length = json["length"];
871
872 @override
873 Map<String, Object> toMap() => {
874 "text": text,
875 "offset": offset,
876 "length": length,
877 };
878
879 /**
880 * Text of the documentation comment, with '\r\n' replaced by '\n'.
881 *
882 * References appearing within the doc comment in square brackets are not
883 * specially encoded.
884 */
885 String get text => _text ?? '';
886
887 /**
888 * Offset of the beginning of the documentation comment relative to the
889 * beginning of the file.
890 */
891 int get offset => _offset ?? 0;
892
893 /**
894 * Length of the documentation comment (prior to replacing '\r\n' with '\n').
895 */
896 int get length => _length ?? 0;
897 }
898
899 class UnlinkedDocumentationCommentBuilder {
900 final Map _json = {};
901
902 bool _finished = false;
903
904 UnlinkedDocumentationCommentBuilder(base.BuilderContext context); 1058 UnlinkedDocumentationCommentBuilder(base.BuilderContext context);
905 1059
906 /** 1060 /**
907 * Text of the documentation comment, with '\r\n' replaced by '\n'. 1061 * Text of the documentation comment, with '\r\n' replaced by '\n'.
908 * 1062 *
909 * References appearing within the doc comment in square brackets are not 1063 * References appearing within the doc comment in square brackets are not
910 * specially encoded. 1064 * specially encoded.
911 */ 1065 */
912 void set text(String _value) { 1066 void set text(String _value) {
913 assert(!_finished); 1067 assert(!_finished);
914 assert(!_json.containsKey("text")); 1068 _text = _value;
915 if (_value != null) {
916 _json["text"] = _value;
917 }
918 } 1069 }
919 1070
920 /** 1071 /**
921 * Offset of the beginning of the documentation comment relative to the 1072 * Offset of the beginning of the documentation comment relative to the
922 * beginning of the file. 1073 * beginning of the file.
923 */ 1074 */
924 void set offset(int _value) { 1075 void set offset(int _value) {
925 assert(!_finished); 1076 assert(!_finished);
926 assert(!_json.containsKey("offset")); 1077 _offset = _value;
927 if (_value != null) {
928 _json["offset"] = _value;
929 }
930 } 1078 }
931 1079
932 /** 1080 /**
933 * Length of the documentation comment (prior to replacing '\r\n' with '\n'). 1081 * Length of the documentation comment (prior to replacing '\r\n' with '\n').
934 */ 1082 */
935 void set length(int _value) { 1083 void set length(int _value) {
936 assert(!_finished); 1084 assert(!_finished);
937 assert(!_json.containsKey("length")); 1085 _length = _value;
938 if (_value != null) {
939 _json["length"] = _value;
940 }
941 } 1086 }
942 1087
943 Map finish() { 1088 fb.Offset finish(fb.Builder fbBuilder) {
944 assert(!_finished); 1089 assert(!_finished);
945 _finished = true; 1090 _finished = true;
946 return _json; 1091 fb.Offset offset_text;
1092 if (_text != null) {
1093 offset_text = fbBuilder.writeString(_text);
1094 }
1095 fbBuilder.startTable();
1096 if (offset_text != null) {
1097 fbBuilder.addOffset(0, offset_text);
1098 }
1099 if (_offset != null && _offset != 0) {
1100 fbBuilder.addInt32(1, _offset);
1101 }
1102 if (_length != null && _length != 0) {
1103 fbBuilder.addInt32(2, _length);
1104 }
1105 return fbBuilder.endTable();
947 } 1106 }
948 } 1107 }
949 1108
950 UnlinkedDocumentationCommentBuilder encodeUnlinkedDocumentationComment(base.Buil derContext builderContext, {String text, int offset, int length}) { 1109 UnlinkedDocumentationCommentBuilder encodeUnlinkedDocumentationComment(base.Buil derContext builderContext, {String text, int offset, int length}) {
951 UnlinkedDocumentationCommentBuilder builder = new UnlinkedDocumentationComment Builder(builderContext); 1110 UnlinkedDocumentationCommentBuilder builder = new UnlinkedDocumentationComment Builder(builderContext);
952 builder.text = text; 1111 builder.text = text;
953 builder.offset = offset; 1112 builder.offset = offset;
954 builder.length = length; 1113 builder.length = length;
955 return builder; 1114 return builder;
956 } 1115 }
957 1116
958 /** 1117 /**
959 * Unlinked summary information about an enum declaration. 1118 * Unlinked summary information about a documentation comment.
960 */ 1119 */
961 class UnlinkedEnum extends base.SummaryClass { 1120 abstract class UnlinkedDocumentationComment extends base.SummaryClass {
962 String _name;
963 int _nameOffset;
964 UnlinkedDocumentationComment _documentationComment;
965 List<UnlinkedEnumValue> _values;
966 1121
967 UnlinkedEnum.fromJson(Map json) 1122 /**
968 : _name = json["name"], 1123 * Text of the documentation comment, with '\r\n' replaced by '\n'.
969 _nameOffset = json["nameOffset"], 1124 *
970 _documentationComment = json["documentationComment"] == null ? null : new UnlinkedDocumentationComment.fromJson(json["documentationComment"]), 1125 * References appearing within the doc comment in square brackets are not
971 _values = json["values"]?.map((x) => new UnlinkedEnumValue.fromJson(x))?.t oList(); 1126 * specially encoded.
1127 */
1128 String get text;
1129
1130 /**
1131 * Offset of the beginning of the documentation comment relative to the
1132 * beginning of the file.
1133 */
1134 int get offset;
1135
1136 /**
1137 * Length of the documentation comment (prior to replacing '\r\n' with '\n').
1138 */
1139 int get length;
1140 }
1141
1142 class _UnlinkedDocumentationCommentReader extends fb.TableReader<_UnlinkedDocume ntationCommentReader> implements UnlinkedDocumentationComment {
1143 final fb.BufferPointer _bp;
1144
1145 const _UnlinkedDocumentationCommentReader([this._bp]);
1146
1147 @override
1148 _UnlinkedDocumentationCommentReader createReader(fb.BufferPointer bp) => new _ UnlinkedDocumentationCommentReader(bp);
972 1149
973 @override 1150 @override
974 Map<String, Object> toMap() => { 1151 Map<String, Object> toMap() => {
975 "name": name, 1152 "text": text,
976 "nameOffset": nameOffset, 1153 "offset": offset,
977 "documentationComment": documentationComment, 1154 "length": length,
978 "values": values,
979 }; 1155 };
980 1156
981 /** 1157 @override
982 * Name of the enum type. 1158 String get text => const fb.StringReader().vTableGet(_bp, 0, '');
983 */
984 String get name => _name ?? '';
985 1159
986 /** 1160 @override
987 * Offset of the enum name relative to the beginning of the file. 1161 int get offset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
988 */
989 int get nameOffset => _nameOffset ?? 0;
990 1162
991 /** 1163 @override
992 * Documentation comment for the enum, or `null` if there is no documentation 1164 int get length => const fb.Int32Reader().vTableGet(_bp, 2, 0);
993 * comment.
994 */
995 UnlinkedDocumentationComment get documentationComment => _documentationComment ;
996
997 /**
998 * Values listed in the enum declaration, in declaration order.
999 */
1000 List<UnlinkedEnumValue> get values => _values ?? const <UnlinkedEnumValue>[];
1001 } 1165 }
1002 1166
1003 class UnlinkedEnumBuilder { 1167 class UnlinkedEnumBuilder {
1004 final Map _json = {}; 1168 bool _finished = false;
1005 1169
1006 bool _finished = false; 1170 String _name;
1171 int _nameOffset;
1172 UnlinkedDocumentationCommentBuilder _documentationComment;
1173 List<UnlinkedEnumValueBuilder> _values;
1007 1174
1008 UnlinkedEnumBuilder(base.BuilderContext context); 1175 UnlinkedEnumBuilder(base.BuilderContext context);
1009 1176
1010 /** 1177 /**
1011 * Name of the enum type. 1178 * Name of the enum type.
1012 */ 1179 */
1013 void set name(String _value) { 1180 void set name(String _value) {
1014 assert(!_finished); 1181 assert(!_finished);
1015 assert(!_json.containsKey("name")); 1182 _name = _value;
1016 if (_value != null) {
1017 _json["name"] = _value;
1018 }
1019 } 1183 }
1020 1184
1021 /** 1185 /**
1022 * Offset of the enum name relative to the beginning of the file. 1186 * Offset of the enum name relative to the beginning of the file.
1023 */ 1187 */
1024 void set nameOffset(int _value) { 1188 void set nameOffset(int _value) {
1025 assert(!_finished); 1189 assert(!_finished);
1026 assert(!_json.containsKey("nameOffset")); 1190 _nameOffset = _value;
1027 if (_value != null) {
1028 _json["nameOffset"] = _value;
1029 }
1030 } 1191 }
1031 1192
1032 /** 1193 /**
1033 * Documentation comment for the enum, or `null` if there is no documentation 1194 * Documentation comment for the enum, or `null` if there is no documentation
1034 * comment. 1195 * comment.
1035 */ 1196 */
1036 void set documentationComment(UnlinkedDocumentationCommentBuilder _value) { 1197 void set documentationComment(UnlinkedDocumentationCommentBuilder _value) {
1037 assert(!_finished); 1198 assert(!_finished);
1038 assert(!_json.containsKey("documentationComment")); 1199 _documentationComment = _value;
1039 if (_value != null) {
1040 _json["documentationComment"] = _value.finish();
1041 }
1042 } 1200 }
1043 1201
1044 /** 1202 /**
1045 * Values listed in the enum declaration, in declaration order. 1203 * Values listed in the enum declaration, in declaration order.
1046 */ 1204 */
1047 void set values(List<UnlinkedEnumValueBuilder> _value) { 1205 void set values(List<UnlinkedEnumValueBuilder> _value) {
1048 assert(!_finished); 1206 assert(!_finished);
1049 assert(!_json.containsKey("values")); 1207 _values = _value;
1050 if (!(_value == null || _value.isEmpty)) {
1051 _json["values"] = _value.map((b) => b.finish()).toList();
1052 }
1053 } 1208 }
1054 1209
1055 Map finish() { 1210 fb.Offset finish(fb.Builder fbBuilder) {
1056 assert(!_finished); 1211 assert(!_finished);
1057 _finished = true; 1212 _finished = true;
1058 return _json; 1213 fb.Offset offset_name;
1214 fb.Offset offset_documentationComment;
1215 fb.Offset offset_values;
1216 if (_name != null) {
1217 offset_name = fbBuilder.writeString(_name);
1218 }
1219 if (_documentationComment != null) {
1220 offset_documentationComment = _documentationComment.finish(fbBuilder);
1221 }
1222 if (!(_values == null || _values.isEmpty)) {
1223 offset_values = fbBuilder.writeList(_values.map((b) => b.finish(fbBuilder) ).toList());
1224 }
1225 fbBuilder.startTable();
1226 if (offset_name != null) {
1227 fbBuilder.addOffset(0, offset_name);
1228 }
1229 if (_nameOffset != null && _nameOffset != 0) {
1230 fbBuilder.addInt32(1, _nameOffset);
1231 }
1232 if (offset_documentationComment != null) {
1233 fbBuilder.addOffset(2, offset_documentationComment);
1234 }
1235 if (offset_values != null) {
1236 fbBuilder.addOffset(3, offset_values);
1237 }
1238 return fbBuilder.endTable();
1059 } 1239 }
1060 } 1240 }
1061 1241
1062 UnlinkedEnumBuilder encodeUnlinkedEnum(base.BuilderContext builderContext, {Stri ng name, int nameOffset, UnlinkedDocumentationCommentBuilder documentationCommen t, List<UnlinkedEnumValueBuilder> values}) { 1242 UnlinkedEnumBuilder encodeUnlinkedEnum(base.BuilderContext builderContext, {Stri ng name, int nameOffset, UnlinkedDocumentationCommentBuilder documentationCommen t, List<UnlinkedEnumValueBuilder> values}) {
1063 UnlinkedEnumBuilder builder = new UnlinkedEnumBuilder(builderContext); 1243 UnlinkedEnumBuilder builder = new UnlinkedEnumBuilder(builderContext);
1064 builder.name = name; 1244 builder.name = name;
1065 builder.nameOffset = nameOffset; 1245 builder.nameOffset = nameOffset;
1066 builder.documentationComment = documentationComment; 1246 builder.documentationComment = documentationComment;
1067 builder.values = values; 1247 builder.values = values;
1068 return builder; 1248 return builder;
1069 } 1249 }
1070 1250
1071 /** 1251 /**
1072 * Unlinked summary information about a single enumerated value in an enum 1252 * Unlinked summary information about an enum declaration.
1073 * declaration.
1074 */ 1253 */
1075 class UnlinkedEnumValue extends base.SummaryClass { 1254 abstract class UnlinkedEnum extends base.SummaryClass {
1076 String _name;
1077 int _nameOffset;
1078 UnlinkedDocumentationComment _documentationComment;
1079 1255
1080 UnlinkedEnumValue.fromJson(Map json) 1256 /**
1081 : _name = json["name"], 1257 * Name of the enum type.
1082 _nameOffset = json["nameOffset"], 1258 */
1083 _documentationComment = json["documentationComment"] == null ? null : new UnlinkedDocumentationComment.fromJson(json["documentationComment"]); 1259 String get name;
1260
1261 /**
1262 * Offset of the enum name relative to the beginning of the file.
1263 */
1264 int get nameOffset;
1265
1266 /**
1267 * Documentation comment for the enum, or `null` if there is no documentation
1268 * comment.
1269 */
1270 UnlinkedDocumentationComment get documentationComment;
1271
1272 /**
1273 * Values listed in the enum declaration, in declaration order.
1274 */
1275 List<UnlinkedEnumValue> get values;
1276 }
1277
1278 class _UnlinkedEnumReader extends fb.TableReader<_UnlinkedEnumReader> implements UnlinkedEnum {
1279 final fb.BufferPointer _bp;
1280
1281 const _UnlinkedEnumReader([this._bp]);
1282
1283 @override
1284 _UnlinkedEnumReader createReader(fb.BufferPointer bp) => new _UnlinkedEnumRead er(bp);
1084 1285
1085 @override 1286 @override
1086 Map<String, Object> toMap() => { 1287 Map<String, Object> toMap() => {
1087 "name": name, 1288 "name": name,
1088 "nameOffset": nameOffset, 1289 "nameOffset": nameOffset,
1089 "documentationComment": documentationComment, 1290 "documentationComment": documentationComment,
1291 "values": values,
1090 }; 1292 };
1091 1293
1092 /** 1294 @override
1093 * Name of the enumerated value. 1295 String get name => const fb.StringReader().vTableGet(_bp, 0, '');
1094 */
1095 String get name => _name ?? '';
1096 1296
1097 /** 1297 @override
1098 * Offset of the enum value name relative to the beginning of the file. 1298 int get nameOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
1099 */
1100 int get nameOffset => _nameOffset ?? 0;
1101 1299
1102 /** 1300 @override
1103 * Documentation comment for the enum value, or `null` if there is no 1301 UnlinkedDocumentationComment get documentationComment => const _UnlinkedDocume ntationCommentReader().vTableGet(_bp, 2, null);
1104 * documentation comment. 1302
1105 */ 1303 @override
1106 UnlinkedDocumentationComment get documentationComment => _documentationComment ; 1304 List<UnlinkedEnumValue> get values => const fb.ListReader<UnlinkedEnumValue>(c onst _UnlinkedEnumValueReader()).vTableGet(_bp, 3, const <UnlinkedEnumValue>[]);
1107 } 1305 }
1108 1306
1109 class UnlinkedEnumValueBuilder { 1307 class UnlinkedEnumValueBuilder {
1110 final Map _json = {}; 1308 bool _finished = false;
1111 1309
1112 bool _finished = false; 1310 String _name;
1311 int _nameOffset;
1312 UnlinkedDocumentationCommentBuilder _documentationComment;
1113 1313
1114 UnlinkedEnumValueBuilder(base.BuilderContext context); 1314 UnlinkedEnumValueBuilder(base.BuilderContext context);
1115 1315
1116 /** 1316 /**
1117 * Name of the enumerated value. 1317 * Name of the enumerated value.
1118 */ 1318 */
1119 void set name(String _value) { 1319 void set name(String _value) {
1120 assert(!_finished); 1320 assert(!_finished);
1121 assert(!_json.containsKey("name")); 1321 _name = _value;
1122 if (_value != null) {
1123 _json["name"] = _value;
1124 }
1125 } 1322 }
1126 1323
1127 /** 1324 /**
1128 * Offset of the enum value name relative to the beginning of the file. 1325 * Offset of the enum value name relative to the beginning of the file.
1129 */ 1326 */
1130 void set nameOffset(int _value) { 1327 void set nameOffset(int _value) {
1131 assert(!_finished); 1328 assert(!_finished);
1132 assert(!_json.containsKey("nameOffset")); 1329 _nameOffset = _value;
1133 if (_value != null) {
1134 _json["nameOffset"] = _value;
1135 }
1136 } 1330 }
1137 1331
1138 /** 1332 /**
1139 * Documentation comment for the enum value, or `null` if there is no 1333 * Documentation comment for the enum value, or `null` if there is no
1140 * documentation comment. 1334 * documentation comment.
1141 */ 1335 */
1142 void set documentationComment(UnlinkedDocumentationCommentBuilder _value) { 1336 void set documentationComment(UnlinkedDocumentationCommentBuilder _value) {
1143 assert(!_finished); 1337 assert(!_finished);
1144 assert(!_json.containsKey("documentationComment")); 1338 _documentationComment = _value;
1145 if (_value != null) {
1146 _json["documentationComment"] = _value.finish();
1147 }
1148 } 1339 }
1149 1340
1150 Map finish() { 1341 fb.Offset finish(fb.Builder fbBuilder) {
1151 assert(!_finished); 1342 assert(!_finished);
1152 _finished = true; 1343 _finished = true;
1153 return _json; 1344 fb.Offset offset_name;
1345 fb.Offset offset_documentationComment;
1346 if (_name != null) {
1347 offset_name = fbBuilder.writeString(_name);
1348 }
1349 if (_documentationComment != null) {
1350 offset_documentationComment = _documentationComment.finish(fbBuilder);
1351 }
1352 fbBuilder.startTable();
1353 if (offset_name != null) {
1354 fbBuilder.addOffset(0, offset_name);
1355 }
1356 if (_nameOffset != null && _nameOffset != 0) {
1357 fbBuilder.addInt32(1, _nameOffset);
1358 }
1359 if (offset_documentationComment != null) {
1360 fbBuilder.addOffset(2, offset_documentationComment);
1361 }
1362 return fbBuilder.endTable();
1154 } 1363 }
1155 } 1364 }
1156 1365
1157 UnlinkedEnumValueBuilder encodeUnlinkedEnumValue(base.BuilderContext builderCont ext, {String name, int nameOffset, UnlinkedDocumentationCommentBuilder documenta tionComment}) { 1366 UnlinkedEnumValueBuilder encodeUnlinkedEnumValue(base.BuilderContext builderCont ext, {String name, int nameOffset, UnlinkedDocumentationCommentBuilder documenta tionComment}) {
1158 UnlinkedEnumValueBuilder builder = new UnlinkedEnumValueBuilder(builderContext ); 1367 UnlinkedEnumValueBuilder builder = new UnlinkedEnumValueBuilder(builderContext );
1159 builder.name = name; 1368 builder.name = name;
1160 builder.nameOffset = nameOffset; 1369 builder.nameOffset = nameOffset;
1161 builder.documentationComment = documentationComment; 1370 builder.documentationComment = documentationComment;
1162 return builder; 1371 return builder;
1163 } 1372 }
1164 1373
1165 /** 1374 /**
1166 * Unlinked summary information about a function, method, getter, or setter 1375 * Unlinked summary information about a single enumerated value in an enum
1167 * declaration. 1376 * declaration.
1168 */ 1377 */
1169 class UnlinkedExecutable extends base.SummaryClass { 1378 abstract class UnlinkedEnumValue extends base.SummaryClass {
1379
1380 /**
1381 * Name of the enumerated value.
1382 */
1383 String get name;
1384
1385 /**
1386 * Offset of the enum value name relative to the beginning of the file.
1387 */
1388 int get nameOffset;
1389
1390 /**
1391 * Documentation comment for the enum value, or `null` if there is no
1392 * documentation comment.
1393 */
1394 UnlinkedDocumentationComment get documentationComment;
1395 }
1396
1397 class _UnlinkedEnumValueReader extends fb.TableReader<_UnlinkedEnumValueReader> implements UnlinkedEnumValue {
1398 final fb.BufferPointer _bp;
1399
1400 const _UnlinkedEnumValueReader([this._bp]);
1401
1402 @override
1403 _UnlinkedEnumValueReader createReader(fb.BufferPointer bp) => new _UnlinkedEnu mValueReader(bp);
1404
1405 @override
1406 Map<String, Object> toMap() => {
1407 "name": name,
1408 "nameOffset": nameOffset,
1409 "documentationComment": documentationComment,
1410 };
1411
1412 @override
1413 String get name => const fb.StringReader().vTableGet(_bp, 0, '');
1414
1415 @override
1416 int get nameOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
1417
1418 @override
1419 UnlinkedDocumentationComment get documentationComment => const _UnlinkedDocume ntationCommentReader().vTableGet(_bp, 2, null);
1420 }
1421
1422 class UnlinkedExecutableBuilder {
1423 bool _finished = false;
1424
1170 String _name; 1425 String _name;
1171 int _nameOffset; 1426 int _nameOffset;
1172 UnlinkedDocumentationComment _documentationComment; 1427 UnlinkedDocumentationCommentBuilder _documentationComment;
1173 List<UnlinkedTypeParam> _typeParameters; 1428 List<UnlinkedTypeParamBuilder> _typeParameters;
1174 UnlinkedTypeRef _returnType; 1429 UnlinkedTypeRefBuilder _returnType;
1175 List<UnlinkedParam> _parameters; 1430 List<UnlinkedParamBuilder> _parameters;
1176 UnlinkedExecutableKind _kind; 1431 UnlinkedExecutableKind _kind;
1177 bool _isAbstract; 1432 bool _isAbstract;
1178 bool _isStatic; 1433 bool _isStatic;
1179 bool _isConst; 1434 bool _isConst;
1180 bool _isFactory; 1435 bool _isFactory;
1181 bool _hasImplicitReturnType; 1436 bool _hasImplicitReturnType;
1182 bool _isExternal; 1437 bool _isExternal;
1183 1438
1184 UnlinkedExecutable.fromJson(Map json)
1185 : _name = json["name"],
1186 _nameOffset = json["nameOffset"],
1187 _documentationComment = json["documentationComment"] == null ? null : new UnlinkedDocumentationComment.fromJson(json["documentationComment"]),
1188 _typeParameters = json["typeParameters"]?.map((x) => new UnlinkedTypeParam .fromJson(x))?.toList(),
1189 _returnType = json["returnType"] == null ? null : new UnlinkedTypeRef.from Json(json["returnType"]),
1190 _parameters = json["parameters"]?.map((x) => new UnlinkedParam.fromJson(x) )?.toList(),
1191 _kind = json["kind"] == null ? null : UnlinkedExecutableKind.values[json[" kind"]],
1192 _isAbstract = json["isAbstract"],
1193 _isStatic = json["isStatic"],
1194 _isConst = json["isConst"],
1195 _isFactory = json["isFactory"],
1196 _hasImplicitReturnType = json["hasImplicitReturnType"],
1197 _isExternal = json["isExternal"];
1198
1199 @override
1200 Map<String, Object> toMap() => {
1201 "name": name,
1202 "nameOffset": nameOffset,
1203 "documentationComment": documentationComment,
1204 "typeParameters": typeParameters,
1205 "returnType": returnType,
1206 "parameters": parameters,
1207 "kind": kind,
1208 "isAbstract": isAbstract,
1209 "isStatic": isStatic,
1210 "isConst": isConst,
1211 "isFactory": isFactory,
1212 "hasImplicitReturnType": hasImplicitReturnType,
1213 "isExternal": isExternal,
1214 };
1215
1216 /**
1217 * Name of the executable. For setters, this includes the trailing "=". For
1218 * named constructors, this excludes the class name and excludes the ".".
1219 * For unnamed constructors, this is the empty string.
1220 */
1221 String get name => _name ?? '';
1222
1223 /**
1224 * Offset of the executable name relative to the beginning of the file. For
1225 * named constructors, this excludes the class name and excludes the ".".
1226 * For unnamed constructors, this is the offset of the class name (i.e. the
1227 * offset of the second "C" in "class C { C(); }").
1228 */
1229 int get nameOffset => _nameOffset ?? 0;
1230
1231 /**
1232 * Documentation comment for the executable, or `null` if there is no
1233 * documentation comment.
1234 */
1235 UnlinkedDocumentationComment get documentationComment => _documentationComment ;
1236
1237 /**
1238 * Type parameters of the executable, if any. Empty if support for generic
1239 * method syntax is disabled.
1240 */
1241 List<UnlinkedTypeParam> get typeParameters => _typeParameters ?? const <Unlink edTypeParam>[];
1242
1243 /**
1244 * Declared return type of the executable. Absent if the return type is
1245 * `void` or the executable is a constructor. Note that when strong mode is
1246 * enabled, the actual return type may be different due to type inference.
1247 */
1248 UnlinkedTypeRef get returnType => _returnType;
1249
1250 /**
1251 * Parameters of the executable, if any. Note that getters have no
1252 * parameters (hence this will be the empty list), and setters have a single
1253 * parameter.
1254 */
1255 List<UnlinkedParam> get parameters => _parameters ?? const <UnlinkedParam>[];
1256
1257 /**
1258 * The kind of the executable (function/method, getter, setter, or
1259 * constructor).
1260 */
1261 UnlinkedExecutableKind get kind => _kind ?? UnlinkedExecutableKind.functionOrM ethod;
1262
1263 /**
1264 * Indicates whether the executable is declared using the `abstract` keyword.
1265 */
1266 bool get isAbstract => _isAbstract ?? false;
1267
1268 /**
1269 * Indicates whether the executable is declared using the `static` keyword.
1270 *
1271 * Note that for top level executables, this flag is false, since they are
1272 * not declared using the `static` keyword (even though they are considered
1273 * static for semantic purposes).
1274 */
1275 bool get isStatic => _isStatic ?? false;
1276
1277 /**
1278 * Indicates whether the executable is declared using the `const` keyword.
1279 */
1280 bool get isConst => _isConst ?? false;
1281
1282 /**
1283 * Indicates whether the executable is declared using the `factory` keyword.
1284 */
1285 bool get isFactory => _isFactory ?? false;
1286
1287 /**
1288 * Indicates whether the executable lacks an explicit return type
1289 * declaration. False for constructors and setters.
1290 */
1291 bool get hasImplicitReturnType => _hasImplicitReturnType ?? false;
1292
1293 /**
1294 * Indicates whether the executable is declared using the `external` keyword.
1295 */
1296 bool get isExternal => _isExternal ?? false;
1297 }
1298
1299 class UnlinkedExecutableBuilder {
1300 final Map _json = {};
1301
1302 bool _finished = false;
1303
1304 UnlinkedExecutableBuilder(base.BuilderContext context); 1439 UnlinkedExecutableBuilder(base.BuilderContext context);
1305 1440
1306 /** 1441 /**
1307 * Name of the executable. For setters, this includes the trailing "=". For 1442 * Name of the executable. For setters, this includes the trailing "=". For
1308 * named constructors, this excludes the class name and excludes the ".". 1443 * named constructors, this excludes the class name and excludes the ".".
1309 * For unnamed constructors, this is the empty string. 1444 * For unnamed constructors, this is the empty string.
1310 */ 1445 */
1311 void set name(String _value) { 1446 void set name(String _value) {
1312 assert(!_finished); 1447 assert(!_finished);
1313 assert(!_json.containsKey("name")); 1448 _name = _value;
1314 if (_value != null) {
1315 _json["name"] = _value;
1316 }
1317 } 1449 }
1318 1450
1319 /** 1451 /**
1320 * Offset of the executable name relative to the beginning of the file. For 1452 * Offset of the executable name relative to the beginning of the file. For
1321 * named constructors, this excludes the class name and excludes the ".". 1453 * named constructors, this excludes the class name and excludes the ".".
1322 * For unnamed constructors, this is the offset of the class name (i.e. the 1454 * For unnamed constructors, this is the offset of the class name (i.e. the
1323 * offset of the second "C" in "class C { C(); }"). 1455 * offset of the second "C" in "class C { C(); }").
1324 */ 1456 */
1325 void set nameOffset(int _value) { 1457 void set nameOffset(int _value) {
1326 assert(!_finished); 1458 assert(!_finished);
1327 assert(!_json.containsKey("nameOffset")); 1459 _nameOffset = _value;
1328 if (_value != null) {
1329 _json["nameOffset"] = _value;
1330 }
1331 } 1460 }
1332 1461
1333 /** 1462 /**
1334 * Documentation comment for the executable, or `null` if there is no 1463 * Documentation comment for the executable, or `null` if there is no
1335 * documentation comment. 1464 * documentation comment.
1336 */ 1465 */
1337 void set documentationComment(UnlinkedDocumentationCommentBuilder _value) { 1466 void set documentationComment(UnlinkedDocumentationCommentBuilder _value) {
1338 assert(!_finished); 1467 assert(!_finished);
1339 assert(!_json.containsKey("documentationComment")); 1468 _documentationComment = _value;
1340 if (_value != null) {
1341 _json["documentationComment"] = _value.finish();
1342 }
1343 } 1469 }
1344 1470
1345 /** 1471 /**
1346 * Type parameters of the executable, if any. Empty if support for generic 1472 * Type parameters of the executable, if any. Empty if support for generic
1347 * method syntax is disabled. 1473 * method syntax is disabled.
1348 */ 1474 */
1349 void set typeParameters(List<UnlinkedTypeParamBuilder> _value) { 1475 void set typeParameters(List<UnlinkedTypeParamBuilder> _value) {
1350 assert(!_finished); 1476 assert(!_finished);
1351 assert(!_json.containsKey("typeParameters")); 1477 _typeParameters = _value;
1352 if (!(_value == null || _value.isEmpty)) {
1353 _json["typeParameters"] = _value.map((b) => b.finish()).toList();
1354 }
1355 } 1478 }
1356 1479
1357 /** 1480 /**
1358 * Declared return type of the executable. Absent if the return type is 1481 * Declared return type of the executable. Absent if the return type is
1359 * `void` or the executable is a constructor. Note that when strong mode is 1482 * `void` or the executable is a constructor. Note that when strong mode is
1360 * enabled, the actual return type may be different due to type inference. 1483 * enabled, the actual return type may be different due to type inference.
1361 */ 1484 */
1362 void set returnType(UnlinkedTypeRefBuilder _value) { 1485 void set returnType(UnlinkedTypeRefBuilder _value) {
1363 assert(!_finished); 1486 assert(!_finished);
1364 assert(!_json.containsKey("returnType")); 1487 _returnType = _value;
1365 if (_value != null) {
1366 _json["returnType"] = _value.finish();
1367 }
1368 } 1488 }
1369 1489
1370 /** 1490 /**
1371 * Parameters of the executable, if any. Note that getters have no 1491 * Parameters of the executable, if any. Note that getters have no
1372 * parameters (hence this will be the empty list), and setters have a single 1492 * parameters (hence this will be the empty list), and setters have a single
1373 * parameter. 1493 * parameter.
1374 */ 1494 */
1375 void set parameters(List<UnlinkedParamBuilder> _value) { 1495 void set parameters(List<UnlinkedParamBuilder> _value) {
1376 assert(!_finished); 1496 assert(!_finished);
1377 assert(!_json.containsKey("parameters")); 1497 _parameters = _value;
1378 if (!(_value == null || _value.isEmpty)) {
1379 _json["parameters"] = _value.map((b) => b.finish()).toList();
1380 }
1381 } 1498 }
1382 1499
1383 /** 1500 /**
1384 * The kind of the executable (function/method, getter, setter, or 1501 * The kind of the executable (function/method, getter, setter, or
1385 * constructor). 1502 * constructor).
1386 */ 1503 */
1387 void set kind(UnlinkedExecutableKind _value) { 1504 void set kind(UnlinkedExecutableKind _value) {
1388 assert(!_finished); 1505 assert(!_finished);
1389 assert(!_json.containsKey("kind")); 1506 _kind = _value;
1390 if (!(_value == null || _value == UnlinkedExecutableKind.functionOrMethod)) {
1391 _json["kind"] = _value.index;
1392 }
1393 } 1507 }
1394 1508
1395 /** 1509 /**
1396 * Indicates whether the executable is declared using the `abstract` keyword. 1510 * Indicates whether the executable is declared using the `abstract` keyword.
1397 */ 1511 */
1398 void set isAbstract(bool _value) { 1512 void set isAbstract(bool _value) {
1399 assert(!_finished); 1513 assert(!_finished);
1400 assert(!_json.containsKey("isAbstract")); 1514 _isAbstract = _value;
1401 if (_value != null) {
1402 _json["isAbstract"] = _value;
1403 }
1404 } 1515 }
1405 1516
1406 /** 1517 /**
1407 * Indicates whether the executable is declared using the `static` keyword. 1518 * Indicates whether the executable is declared using the `static` keyword.
1408 * 1519 *
1409 * Note that for top level executables, this flag is false, since they are 1520 * Note that for top level executables, this flag is false, since they are
1410 * not declared using the `static` keyword (even though they are considered 1521 * not declared using the `static` keyword (even though they are considered
1411 * static for semantic purposes). 1522 * static for semantic purposes).
1412 */ 1523 */
1413 void set isStatic(bool _value) { 1524 void set isStatic(bool _value) {
1414 assert(!_finished); 1525 assert(!_finished);
1415 assert(!_json.containsKey("isStatic")); 1526 _isStatic = _value;
1416 if (_value != null) {
1417 _json["isStatic"] = _value;
1418 }
1419 } 1527 }
1420 1528
1421 /** 1529 /**
1422 * Indicates whether the executable is declared using the `const` keyword. 1530 * Indicates whether the executable is declared using the `const` keyword.
1423 */ 1531 */
1424 void set isConst(bool _value) { 1532 void set isConst(bool _value) {
1425 assert(!_finished); 1533 assert(!_finished);
1426 assert(!_json.containsKey("isConst")); 1534 _isConst = _value;
1427 if (_value != null) {
1428 _json["isConst"] = _value;
1429 }
1430 } 1535 }
1431 1536
1432 /** 1537 /**
1433 * Indicates whether the executable is declared using the `factory` keyword. 1538 * Indicates whether the executable is declared using the `factory` keyword.
1434 */ 1539 */
1435 void set isFactory(bool _value) { 1540 void set isFactory(bool _value) {
1436 assert(!_finished); 1541 assert(!_finished);
1437 assert(!_json.containsKey("isFactory")); 1542 _isFactory = _value;
1438 if (_value != null) {
1439 _json["isFactory"] = _value;
1440 }
1441 } 1543 }
1442 1544
1443 /** 1545 /**
1444 * Indicates whether the executable lacks an explicit return type 1546 * Indicates whether the executable lacks an explicit return type
1445 * declaration. False for constructors and setters. 1547 * declaration. False for constructors and setters.
1446 */ 1548 */
1447 void set hasImplicitReturnType(bool _value) { 1549 void set hasImplicitReturnType(bool _value) {
1448 assert(!_finished); 1550 assert(!_finished);
1449 assert(!_json.containsKey("hasImplicitReturnType")); 1551 _hasImplicitReturnType = _value;
1450 if (_value != null) {
1451 _json["hasImplicitReturnType"] = _value;
1452 }
1453 } 1552 }
1454 1553
1455 /** 1554 /**
1456 * Indicates whether the executable is declared using the `external` keyword. 1555 * Indicates whether the executable is declared using the `external` keyword.
1457 */ 1556 */
1458 void set isExternal(bool _value) { 1557 void set isExternal(bool _value) {
1459 assert(!_finished); 1558 assert(!_finished);
1460 assert(!_json.containsKey("isExternal")); 1559 _isExternal = _value;
1461 if (_value != null) {
1462 _json["isExternal"] = _value;
1463 }
1464 } 1560 }
1465 1561
1466 Map finish() { 1562 fb.Offset finish(fb.Builder fbBuilder) {
1467 assert(!_finished); 1563 assert(!_finished);
1468 _finished = true; 1564 _finished = true;
1469 return _json; 1565 fb.Offset offset_name;
1566 fb.Offset offset_documentationComment;
1567 fb.Offset offset_typeParameters;
1568 fb.Offset offset_returnType;
1569 fb.Offset offset_parameters;
1570 if (_name != null) {
1571 offset_name = fbBuilder.writeString(_name);
1572 }
1573 if (_documentationComment != null) {
1574 offset_documentationComment = _documentationComment.finish(fbBuilder);
1575 }
1576 if (!(_typeParameters == null || _typeParameters.isEmpty)) {
1577 offset_typeParameters = fbBuilder.writeList(_typeParameters.map((b) => b.f inish(fbBuilder)).toList());
1578 }
1579 if (_returnType != null) {
1580 offset_returnType = _returnType.finish(fbBuilder);
1581 }
1582 if (!(_parameters == null || _parameters.isEmpty)) {
1583 offset_parameters = fbBuilder.writeList(_parameters.map((b) => b.finish(fb Builder)).toList());
1584 }
1585 fbBuilder.startTable();
1586 if (offset_name != null) {
1587 fbBuilder.addOffset(0, offset_name);
1588 }
1589 if (_nameOffset != null && _nameOffset != 0) {
1590 fbBuilder.addInt32(1, _nameOffset);
1591 }
1592 if (offset_documentationComment != null) {
1593 fbBuilder.addOffset(2, offset_documentationComment);
1594 }
1595 if (offset_typeParameters != null) {
1596 fbBuilder.addOffset(3, offset_typeParameters);
1597 }
1598 if (offset_returnType != null) {
1599 fbBuilder.addOffset(4, offset_returnType);
1600 }
1601 if (offset_parameters != null) {
1602 fbBuilder.addOffset(5, offset_parameters);
1603 }
1604 if (_kind != null && _kind != UnlinkedExecutableKind.functionOrMethod) {
1605 fbBuilder.addInt32(6, _kind.index);
1606 }
1607 if (_isAbstract == true) {
1608 fbBuilder.addInt8(7, 1);
1609 }
1610 if (_isStatic == true) {
1611 fbBuilder.addInt8(8, 1);
1612 }
1613 if (_isConst == true) {
1614 fbBuilder.addInt8(9, 1);
1615 }
1616 if (_isFactory == true) {
1617 fbBuilder.addInt8(10, 1);
1618 }
1619 if (_hasImplicitReturnType == true) {
1620 fbBuilder.addInt8(11, 1);
1621 }
1622 if (_isExternal == true) {
1623 fbBuilder.addInt8(12, 1);
1624 }
1625 return fbBuilder.endTable();
1470 } 1626 }
1471 } 1627 }
1472 1628
1473 UnlinkedExecutableBuilder encodeUnlinkedExecutable(base.BuilderContext builderCo ntext, {String name, int nameOffset, UnlinkedDocumentationCommentBuilder documen tationComment, List<UnlinkedTypeParamBuilder> typeParameters, UnlinkedTypeRefBui lder returnType, List<UnlinkedParamBuilder> parameters, UnlinkedExecutableKind k ind, bool isAbstract, bool isStatic, bool isConst, bool isFactory, bool hasImpli citReturnType, bool isExternal}) { 1629 UnlinkedExecutableBuilder encodeUnlinkedExecutable(base.BuilderContext builderCo ntext, {String name, int nameOffset, UnlinkedDocumentationCommentBuilder documen tationComment, List<UnlinkedTypeParamBuilder> typeParameters, UnlinkedTypeRefBui lder returnType, List<UnlinkedParamBuilder> parameters, UnlinkedExecutableKind k ind, bool isAbstract, bool isStatic, bool isConst, bool isFactory, bool hasImpli citReturnType, bool isExternal}) {
1474 UnlinkedExecutableBuilder builder = new UnlinkedExecutableBuilder(builderConte xt); 1630 UnlinkedExecutableBuilder builder = new UnlinkedExecutableBuilder(builderConte xt);
1475 builder.name = name; 1631 builder.name = name;
1476 builder.nameOffset = nameOffset; 1632 builder.nameOffset = nameOffset;
1477 builder.documentationComment = documentationComment; 1633 builder.documentationComment = documentationComment;
1478 builder.typeParameters = typeParameters; 1634 builder.typeParameters = typeParameters;
1479 builder.returnType = returnType; 1635 builder.returnType = returnType;
1480 builder.parameters = parameters; 1636 builder.parameters = parameters;
1481 builder.kind = kind; 1637 builder.kind = kind;
1482 builder.isAbstract = isAbstract; 1638 builder.isAbstract = isAbstract;
1483 builder.isStatic = isStatic; 1639 builder.isStatic = isStatic;
1484 builder.isConst = isConst; 1640 builder.isConst = isConst;
1485 builder.isFactory = isFactory; 1641 builder.isFactory = isFactory;
1486 builder.hasImplicitReturnType = hasImplicitReturnType; 1642 builder.hasImplicitReturnType = hasImplicitReturnType;
1487 builder.isExternal = isExternal; 1643 builder.isExternal = isExternal;
1488 return builder; 1644 return builder;
1489 } 1645 }
1490 1646
1491 /** 1647 /**
1492 * Unlinked summary information about an export declaration (stored outside 1648 * Unlinked summary information about a function, method, getter, or setter
1493 * [UnlinkedPublicNamespace]). 1649 * declaration.
1494 */ 1650 */
1495 class UnlinkedExportNonPublic extends base.SummaryClass { 1651 abstract class UnlinkedExecutable extends base.SummaryClass {
1652
1653 /**
1654 * Name of the executable. For setters, this includes the trailing "=". For
1655 * named constructors, this excludes the class name and excludes the ".".
1656 * For unnamed constructors, this is the empty string.
1657 */
1658 String get name;
1659
1660 /**
1661 * Offset of the executable name relative to the beginning of the file. For
1662 * named constructors, this excludes the class name and excludes the ".".
1663 * For unnamed constructors, this is the offset of the class name (i.e. the
1664 * offset of the second "C" in "class C { C(); }").
1665 */
1666 int get nameOffset;
1667
1668 /**
1669 * Documentation comment for the executable, or `null` if there is no
1670 * documentation comment.
1671 */
1672 UnlinkedDocumentationComment get documentationComment;
1673
1674 /**
1675 * Type parameters of the executable, if any. Empty if support for generic
1676 * method syntax is disabled.
1677 */
1678 List<UnlinkedTypeParam> get typeParameters;
1679
1680 /**
1681 * Declared return type of the executable. Absent if the return type is
1682 * `void` or the executable is a constructor. Note that when strong mode is
1683 * enabled, the actual return type may be different due to type inference.
1684 */
1685 UnlinkedTypeRef get returnType;
1686
1687 /**
1688 * Parameters of the executable, if any. Note that getters have no
1689 * parameters (hence this will be the empty list), and setters have a single
1690 * parameter.
1691 */
1692 List<UnlinkedParam> get parameters;
1693
1694 /**
1695 * The kind of the executable (function/method, getter, setter, or
1696 * constructor).
1697 */
1698 UnlinkedExecutableKind get kind;
1699
1700 /**
1701 * Indicates whether the executable is declared using the `abstract` keyword.
1702 */
1703 bool get isAbstract;
1704
1705 /**
1706 * Indicates whether the executable is declared using the `static` keyword.
1707 *
1708 * Note that for top level executables, this flag is false, since they are
1709 * not declared using the `static` keyword (even though they are considered
1710 * static for semantic purposes).
1711 */
1712 bool get isStatic;
1713
1714 /**
1715 * Indicates whether the executable is declared using the `const` keyword.
1716 */
1717 bool get isConst;
1718
1719 /**
1720 * Indicates whether the executable is declared using the `factory` keyword.
1721 */
1722 bool get isFactory;
1723
1724 /**
1725 * Indicates whether the executable lacks an explicit return type
1726 * declaration. False for constructors and setters.
1727 */
1728 bool get hasImplicitReturnType;
1729
1730 /**
1731 * Indicates whether the executable is declared using the `external` keyword.
1732 */
1733 bool get isExternal;
1734 }
1735
1736 class _UnlinkedExecutableReader extends fb.TableReader<_UnlinkedExecutableReader > implements UnlinkedExecutable {
1737 final fb.BufferPointer _bp;
1738
1739 const _UnlinkedExecutableReader([this._bp]);
1740
1741 @override
1742 _UnlinkedExecutableReader createReader(fb.BufferPointer bp) => new _UnlinkedEx ecutableReader(bp);
1743
1744 @override
1745 Map<String, Object> toMap() => {
1746 "name": name,
1747 "nameOffset": nameOffset,
1748 "documentationComment": documentationComment,
1749 "typeParameters": typeParameters,
1750 "returnType": returnType,
1751 "parameters": parameters,
1752 "kind": kind,
1753 "isAbstract": isAbstract,
1754 "isStatic": isStatic,
1755 "isConst": isConst,
1756 "isFactory": isFactory,
1757 "hasImplicitReturnType": hasImplicitReturnType,
1758 "isExternal": isExternal,
1759 };
1760
1761 @override
1762 String get name => const fb.StringReader().vTableGet(_bp, 0, '');
1763
1764 @override
1765 int get nameOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
1766
1767 @override
1768 UnlinkedDocumentationComment get documentationComment => const _UnlinkedDocume ntationCommentReader().vTableGet(_bp, 2, null);
1769
1770 @override
1771 List<UnlinkedTypeParam> get typeParameters => const fb.ListReader<UnlinkedType Param>(const _UnlinkedTypeParamReader()).vTableGet(_bp, 3, const <UnlinkedTypePa ram>[]);
1772
1773 @override
1774 UnlinkedTypeRef get returnType => const _UnlinkedTypeRefReader().vTableGet(_bp , 4, null);
1775
1776 @override
1777 List<UnlinkedParam> get parameters => const fb.ListReader<UnlinkedParam>(const _UnlinkedParamReader()).vTableGet(_bp, 5, const <UnlinkedParam>[]);
1778
1779 @override
1780 UnlinkedExecutableKind get kind {
1781 int index = const fb.Int32Reader().vTableGet(_bp, 6, 0);
1782 return UnlinkedExecutableKind.values[index];
1783 }
1784
1785 @override
1786 bool get isAbstract => const fb.Int8Reader().vTableGet(_bp, 7, 0) == 1;
1787
1788 @override
1789 bool get isStatic => const fb.Int8Reader().vTableGet(_bp, 8, 0) == 1;
1790
1791 @override
1792 bool get isConst => const fb.Int8Reader().vTableGet(_bp, 9, 0) == 1;
1793
1794 @override
1795 bool get isFactory => const fb.Int8Reader().vTableGet(_bp, 10, 0) == 1;
1796
1797 @override
1798 bool get hasImplicitReturnType => const fb.Int8Reader().vTableGet(_bp, 11, 0) == 1;
1799
1800 @override
1801 bool get isExternal => const fb.Int8Reader().vTableGet(_bp, 12, 0) == 1;
1802 }
1803
1804 class UnlinkedExportNonPublicBuilder {
1805 bool _finished = false;
1806
1496 int _offset; 1807 int _offset;
1497 int _uriOffset; 1808 int _uriOffset;
1498 int _uriEnd; 1809 int _uriEnd;
1499 1810
1500 UnlinkedExportNonPublic.fromJson(Map json)
1501 : _offset = json["offset"],
1502 _uriOffset = json["uriOffset"],
1503 _uriEnd = json["uriEnd"];
1504
1505 @override
1506 Map<String, Object> toMap() => {
1507 "offset": offset,
1508 "uriOffset": uriOffset,
1509 "uriEnd": uriEnd,
1510 };
1511
1512 /**
1513 * Offset of the "export" keyword.
1514 */
1515 int get offset => _offset ?? 0;
1516
1517 /**
1518 * Offset of the URI string (including quotes) relative to the beginning of
1519 * the file.
1520 */
1521 int get uriOffset => _uriOffset ?? 0;
1522
1523 /**
1524 * End of the URI string (including quotes) relative to the beginning of the
1525 * file.
1526 */
1527 int get uriEnd => _uriEnd ?? 0;
1528 }
1529
1530 class UnlinkedExportNonPublicBuilder {
1531 final Map _json = {};
1532
1533 bool _finished = false;
1534
1535 UnlinkedExportNonPublicBuilder(base.BuilderContext context); 1811 UnlinkedExportNonPublicBuilder(base.BuilderContext context);
1536 1812
1537 /** 1813 /**
1538 * Offset of the "export" keyword. 1814 * Offset of the "export" keyword.
1539 */ 1815 */
1540 void set offset(int _value) { 1816 void set offset(int _value) {
1541 assert(!_finished); 1817 assert(!_finished);
1542 assert(!_json.containsKey("offset")); 1818 _offset = _value;
1543 if (_value != null) {
1544 _json["offset"] = _value;
1545 }
1546 } 1819 }
1547 1820
1548 /** 1821 /**
1549 * Offset of the URI string (including quotes) relative to the beginning of 1822 * Offset of the URI string (including quotes) relative to the beginning of
1550 * the file. 1823 * the file.
1551 */ 1824 */
1552 void set uriOffset(int _value) { 1825 void set uriOffset(int _value) {
1553 assert(!_finished); 1826 assert(!_finished);
1554 assert(!_json.containsKey("uriOffset")); 1827 _uriOffset = _value;
1555 if (_value != null) {
1556 _json["uriOffset"] = _value;
1557 }
1558 } 1828 }
1559 1829
1560 /** 1830 /**
1561 * End of the URI string (including quotes) relative to the beginning of the 1831 * End of the URI string (including quotes) relative to the beginning of the
1562 * file. 1832 * file.
1563 */ 1833 */
1564 void set uriEnd(int _value) { 1834 void set uriEnd(int _value) {
1565 assert(!_finished); 1835 assert(!_finished);
1566 assert(!_json.containsKey("uriEnd")); 1836 _uriEnd = _value;
1567 if (_value != null) {
1568 _json["uriEnd"] = _value;
1569 }
1570 } 1837 }
1571 1838
1572 Map finish() { 1839 fb.Offset finish(fb.Builder fbBuilder) {
1573 assert(!_finished); 1840 assert(!_finished);
1574 _finished = true; 1841 _finished = true;
1575 return _json; 1842 fbBuilder.startTable();
1843 if (_offset != null && _offset != 0) {
1844 fbBuilder.addInt32(0, _offset);
1845 }
1846 if (_uriOffset != null && _uriOffset != 0) {
1847 fbBuilder.addInt32(1, _uriOffset);
1848 }
1849 if (_uriEnd != null && _uriEnd != 0) {
1850 fbBuilder.addInt32(2, _uriEnd);
1851 }
1852 return fbBuilder.endTable();
1576 } 1853 }
1577 } 1854 }
1578 1855
1579 UnlinkedExportNonPublicBuilder encodeUnlinkedExportNonPublic(base.BuilderContext builderContext, {int offset, int uriOffset, int uriEnd}) { 1856 UnlinkedExportNonPublicBuilder encodeUnlinkedExportNonPublic(base.BuilderContext builderContext, {int offset, int uriOffset, int uriEnd}) {
1580 UnlinkedExportNonPublicBuilder builder = new UnlinkedExportNonPublicBuilder(bu ilderContext); 1857 UnlinkedExportNonPublicBuilder builder = new UnlinkedExportNonPublicBuilder(bu ilderContext);
1581 builder.offset = offset; 1858 builder.offset = offset;
1582 builder.uriOffset = uriOffset; 1859 builder.uriOffset = uriOffset;
1583 builder.uriEnd = uriEnd; 1860 builder.uriEnd = uriEnd;
1584 return builder; 1861 return builder;
1585 } 1862 }
1586 1863
1587 /** 1864 /**
1588 * Unlinked summary information about an export declaration (stored inside 1865 * Unlinked summary information about an export declaration (stored outside
1589 * [UnlinkedPublicNamespace]). 1866 * [UnlinkedPublicNamespace]).
1590 */ 1867 */
1591 class UnlinkedExportPublic extends base.SummaryClass { 1868 abstract class UnlinkedExportNonPublic extends base.SummaryClass {
1592 String _uri;
1593 List<UnlinkedCombinator> _combinators;
1594 1869
1595 UnlinkedExportPublic.fromJson(Map json) 1870 /**
1596 : _uri = json["uri"], 1871 * Offset of the "export" keyword.
1597 _combinators = json["combinators"]?.map((x) => new UnlinkedCombinator.from Json(x))?.toList(); 1872 */
1873 int get offset;
1874
1875 /**
1876 * Offset of the URI string (including quotes) relative to the beginning of
1877 * the file.
1878 */
1879 int get uriOffset;
1880
1881 /**
1882 * End of the URI string (including quotes) relative to the beginning of the
1883 * file.
1884 */
1885 int get uriEnd;
1886 }
1887
1888 class _UnlinkedExportNonPublicReader extends fb.TableReader<_UnlinkedExportNonPu blicReader> implements UnlinkedExportNonPublic {
1889 final fb.BufferPointer _bp;
1890
1891 const _UnlinkedExportNonPublicReader([this._bp]);
1892
1893 @override
1894 _UnlinkedExportNonPublicReader createReader(fb.BufferPointer bp) => new _Unlin kedExportNonPublicReader(bp);
1598 1895
1599 @override 1896 @override
1600 Map<String, Object> toMap() => { 1897 Map<String, Object> toMap() => {
1601 "uri": uri, 1898 "offset": offset,
1602 "combinators": combinators, 1899 "uriOffset": uriOffset,
1900 "uriEnd": uriEnd,
1603 }; 1901 };
1604 1902
1605 /** 1903 @override
1606 * URI used in the source code to reference the exported library. 1904 int get offset => const fb.Int32Reader().vTableGet(_bp, 0, 0);
1607 */
1608 String get uri => _uri ?? '';
1609 1905
1610 /** 1906 @override
1611 * Combinators contained in this import declaration. 1907 int get uriOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
1612 */ 1908
1613 List<UnlinkedCombinator> get combinators => _combinators ?? const <UnlinkedCom binator>[]; 1909 @override
1910 int get uriEnd => const fb.Int32Reader().vTableGet(_bp, 2, 0);
1614 } 1911 }
1615 1912
1616 class UnlinkedExportPublicBuilder { 1913 class UnlinkedExportPublicBuilder {
1617 final Map _json = {}; 1914 bool _finished = false;
1618 1915
1619 bool _finished = false; 1916 String _uri;
1917 List<UnlinkedCombinatorBuilder> _combinators;
1620 1918
1621 UnlinkedExportPublicBuilder(base.BuilderContext context); 1919 UnlinkedExportPublicBuilder(base.BuilderContext context);
1622 1920
1623 /** 1921 /**
1624 * URI used in the source code to reference the exported library. 1922 * URI used in the source code to reference the exported library.
1625 */ 1923 */
1626 void set uri(String _value) { 1924 void set uri(String _value) {
1627 assert(!_finished); 1925 assert(!_finished);
1628 assert(!_json.containsKey("uri")); 1926 _uri = _value;
1629 if (_value != null) {
1630 _json["uri"] = _value;
1631 }
1632 } 1927 }
1633 1928
1634 /** 1929 /**
1635 * Combinators contained in this import declaration. 1930 * Combinators contained in this import declaration.
1636 */ 1931 */
1637 void set combinators(List<UnlinkedCombinatorBuilder> _value) { 1932 void set combinators(List<UnlinkedCombinatorBuilder> _value) {
1638 assert(!_finished); 1933 assert(!_finished);
1639 assert(!_json.containsKey("combinators")); 1934 _combinators = _value;
1640 if (!(_value == null || _value.isEmpty)) {
1641 _json["combinators"] = _value.map((b) => b.finish()).toList();
1642 }
1643 } 1935 }
1644 1936
1645 Map finish() { 1937 fb.Offset finish(fb.Builder fbBuilder) {
1646 assert(!_finished); 1938 assert(!_finished);
1647 _finished = true; 1939 _finished = true;
1648 return _json; 1940 fb.Offset offset_uri;
1941 fb.Offset offset_combinators;
1942 if (_uri != null) {
1943 offset_uri = fbBuilder.writeString(_uri);
1944 }
1945 if (!(_combinators == null || _combinators.isEmpty)) {
1946 offset_combinators = fbBuilder.writeList(_combinators.map((b) => b.finish( fbBuilder)).toList());
1947 }
1948 fbBuilder.startTable();
1949 if (offset_uri != null) {
1950 fbBuilder.addOffset(0, offset_uri);
1951 }
1952 if (offset_combinators != null) {
1953 fbBuilder.addOffset(1, offset_combinators);
1954 }
1955 return fbBuilder.endTable();
1649 } 1956 }
1650 } 1957 }
1651 1958
1652 UnlinkedExportPublicBuilder encodeUnlinkedExportPublic(base.BuilderContext build erContext, {String uri, List<UnlinkedCombinatorBuilder> combinators}) { 1959 UnlinkedExportPublicBuilder encodeUnlinkedExportPublic(base.BuilderContext build erContext, {String uri, List<UnlinkedCombinatorBuilder> combinators}) {
1653 UnlinkedExportPublicBuilder builder = new UnlinkedExportPublicBuilder(builderC ontext); 1960 UnlinkedExportPublicBuilder builder = new UnlinkedExportPublicBuilder(builderC ontext);
1654 builder.uri = uri; 1961 builder.uri = uri;
1655 builder.combinators = combinators; 1962 builder.combinators = combinators;
1656 return builder; 1963 return builder;
1657 } 1964 }
1658 1965
1659 /** 1966 /**
1660 * Unlinked summary information about an import declaration. 1967 * Unlinked summary information about an export declaration (stored inside
1968 * [UnlinkedPublicNamespace]).
1661 */ 1969 */
1662 class UnlinkedImport extends base.SummaryClass { 1970 abstract class UnlinkedExportPublic extends base.SummaryClass {
1971
1972 /**
1973 * URI used in the source code to reference the exported library.
1974 */
1975 String get uri;
1976
1977 /**
1978 * Combinators contained in this import declaration.
1979 */
1980 List<UnlinkedCombinator> get combinators;
1981 }
1982
1983 class _UnlinkedExportPublicReader extends fb.TableReader<_UnlinkedExportPublicRe ader> implements UnlinkedExportPublic {
1984 final fb.BufferPointer _bp;
1985
1986 const _UnlinkedExportPublicReader([this._bp]);
1987
1988 @override
1989 _UnlinkedExportPublicReader createReader(fb.BufferPointer bp) => new _Unlinked ExportPublicReader(bp);
1990
1991 @override
1992 Map<String, Object> toMap() => {
1993 "uri": uri,
1994 "combinators": combinators,
1995 };
1996
1997 @override
1998 String get uri => const fb.StringReader().vTableGet(_bp, 0, '');
1999
2000 @override
2001 List<UnlinkedCombinator> get combinators => const fb.ListReader<UnlinkedCombin ator>(const _UnlinkedCombinatorReader()).vTableGet(_bp, 1, const <UnlinkedCombin ator>[]);
2002 }
2003
2004 class UnlinkedImportBuilder {
2005 bool _finished = false;
2006
1663 String _uri; 2007 String _uri;
1664 int _offset; 2008 int _offset;
1665 int _prefixReference; 2009 int _prefixReference;
1666 List<UnlinkedCombinator> _combinators; 2010 List<UnlinkedCombinatorBuilder> _combinators;
1667 bool _isDeferred; 2011 bool _isDeferred;
1668 bool _isImplicit; 2012 bool _isImplicit;
1669 int _uriOffset; 2013 int _uriOffset;
1670 int _uriEnd; 2014 int _uriEnd;
1671 int _prefixOffset; 2015 int _prefixOffset;
1672 2016
1673 UnlinkedImport.fromJson(Map json)
1674 : _uri = json["uri"],
1675 _offset = json["offset"],
1676 _prefixReference = json["prefixReference"],
1677 _combinators = json["combinators"]?.map((x) => new UnlinkedCombinator.from Json(x))?.toList(),
1678 _isDeferred = json["isDeferred"],
1679 _isImplicit = json["isImplicit"],
1680 _uriOffset = json["uriOffset"],
1681 _uriEnd = json["uriEnd"],
1682 _prefixOffset = json["prefixOffset"];
1683
1684 @override
1685 Map<String, Object> toMap() => {
1686 "uri": uri,
1687 "offset": offset,
1688 "prefixReference": prefixReference,
1689 "combinators": combinators,
1690 "isDeferred": isDeferred,
1691 "isImplicit": isImplicit,
1692 "uriOffset": uriOffset,
1693 "uriEnd": uriEnd,
1694 "prefixOffset": prefixOffset,
1695 };
1696
1697 /**
1698 * URI used in the source code to reference the imported library.
1699 */
1700 String get uri => _uri ?? '';
1701
1702 /**
1703 * If [isImplicit] is false, offset of the "import" keyword. If [isImplicit]
1704 * is true, zero.
1705 */
1706 int get offset => _offset ?? 0;
1707
1708 /**
1709 * Index into [UnlinkedUnit.references] of the prefix declared by this
1710 * import declaration, or zero if this import declaration declares no prefix.
1711 *
1712 * Note that multiple imports can declare the same prefix.
1713 */
1714 int get prefixReference => _prefixReference ?? 0;
1715
1716 /**
1717 * Combinators contained in this import declaration.
1718 */
1719 List<UnlinkedCombinator> get combinators => _combinators ?? const <UnlinkedCom binator>[];
1720
1721 /**
1722 * Indicates whether the import declaration uses the `deferred` keyword.
1723 */
1724 bool get isDeferred => _isDeferred ?? false;
1725
1726 /**
1727 * Indicates whether the import declaration is implicit.
1728 */
1729 bool get isImplicit => _isImplicit ?? false;
1730
1731 /**
1732 * Offset of the URI string (including quotes) relative to the beginning of
1733 * the file. If [isImplicit] is true, zero.
1734 */
1735 int get uriOffset => _uriOffset ?? 0;
1736
1737 /**
1738 * End of the URI string (including quotes) relative to the beginning of the
1739 * file. If [isImplicit] is true, zero.
1740 */
1741 int get uriEnd => _uriEnd ?? 0;
1742
1743 /**
1744 * Offset of the prefix name relative to the beginning of the file, or zero
1745 * if there is no prefix.
1746 */
1747 int get prefixOffset => _prefixOffset ?? 0;
1748 }
1749
1750 class UnlinkedImportBuilder {
1751 final Map _json = {};
1752
1753 bool _finished = false;
1754
1755 UnlinkedImportBuilder(base.BuilderContext context); 2017 UnlinkedImportBuilder(base.BuilderContext context);
1756 2018
1757 /** 2019 /**
1758 * URI used in the source code to reference the imported library. 2020 * URI used in the source code to reference the imported library.
1759 */ 2021 */
1760 void set uri(String _value) { 2022 void set uri(String _value) {
1761 assert(!_finished); 2023 assert(!_finished);
1762 assert(!_json.containsKey("uri")); 2024 _uri = _value;
1763 if (_value != null) {
1764 _json["uri"] = _value;
1765 }
1766 } 2025 }
1767 2026
1768 /** 2027 /**
1769 * If [isImplicit] is false, offset of the "import" keyword. If [isImplicit] 2028 * If [isImplicit] is false, offset of the "import" keyword. If [isImplicit]
1770 * is true, zero. 2029 * is true, zero.
1771 */ 2030 */
1772 void set offset(int _value) { 2031 void set offset(int _value) {
1773 assert(!_finished); 2032 assert(!_finished);
1774 assert(!_json.containsKey("offset")); 2033 _offset = _value;
1775 if (_value != null) {
1776 _json["offset"] = _value;
1777 }
1778 } 2034 }
1779 2035
1780 /** 2036 /**
1781 * Index into [UnlinkedUnit.references] of the prefix declared by this 2037 * Index into [UnlinkedUnit.references] of the prefix declared by this
1782 * import declaration, or zero if this import declaration declares no prefix. 2038 * import declaration, or zero if this import declaration declares no prefix.
1783 * 2039 *
1784 * Note that multiple imports can declare the same prefix. 2040 * Note that multiple imports can declare the same prefix.
1785 */ 2041 */
1786 void set prefixReference(int _value) { 2042 void set prefixReference(int _value) {
1787 assert(!_finished); 2043 assert(!_finished);
1788 assert(!_json.containsKey("prefixReference")); 2044 _prefixReference = _value;
1789 if (_value != null) {
1790 _json["prefixReference"] = _value;
1791 }
1792 } 2045 }
1793 2046
1794 /** 2047 /**
1795 * Combinators contained in this import declaration. 2048 * Combinators contained in this import declaration.
1796 */ 2049 */
1797 void set combinators(List<UnlinkedCombinatorBuilder> _value) { 2050 void set combinators(List<UnlinkedCombinatorBuilder> _value) {
1798 assert(!_finished); 2051 assert(!_finished);
1799 assert(!_json.containsKey("combinators")); 2052 _combinators = _value;
1800 if (!(_value == null || _value.isEmpty)) {
1801 _json["combinators"] = _value.map((b) => b.finish()).toList();
1802 }
1803 } 2053 }
1804 2054
1805 /** 2055 /**
1806 * Indicates whether the import declaration uses the `deferred` keyword. 2056 * Indicates whether the import declaration uses the `deferred` keyword.
1807 */ 2057 */
1808 void set isDeferred(bool _value) { 2058 void set isDeferred(bool _value) {
1809 assert(!_finished); 2059 assert(!_finished);
1810 assert(!_json.containsKey("isDeferred")); 2060 _isDeferred = _value;
1811 if (_value != null) {
1812 _json["isDeferred"] = _value;
1813 }
1814 } 2061 }
1815 2062
1816 /** 2063 /**
1817 * Indicates whether the import declaration is implicit. 2064 * Indicates whether the import declaration is implicit.
1818 */ 2065 */
1819 void set isImplicit(bool _value) { 2066 void set isImplicit(bool _value) {
1820 assert(!_finished); 2067 assert(!_finished);
1821 assert(!_json.containsKey("isImplicit")); 2068 _isImplicit = _value;
1822 if (_value != null) {
1823 _json["isImplicit"] = _value;
1824 }
1825 } 2069 }
1826 2070
1827 /** 2071 /**
1828 * Offset of the URI string (including quotes) relative to the beginning of 2072 * Offset of the URI string (including quotes) relative to the beginning of
1829 * the file. If [isImplicit] is true, zero. 2073 * the file. If [isImplicit] is true, zero.
1830 */ 2074 */
1831 void set uriOffset(int _value) { 2075 void set uriOffset(int _value) {
1832 assert(!_finished); 2076 assert(!_finished);
1833 assert(!_json.containsKey("uriOffset")); 2077 _uriOffset = _value;
1834 if (_value != null) {
1835 _json["uriOffset"] = _value;
1836 }
1837 } 2078 }
1838 2079
1839 /** 2080 /**
1840 * End of the URI string (including quotes) relative to the beginning of the 2081 * End of the URI string (including quotes) relative to the beginning of the
1841 * file. If [isImplicit] is true, zero. 2082 * file. If [isImplicit] is true, zero.
1842 */ 2083 */
1843 void set uriEnd(int _value) { 2084 void set uriEnd(int _value) {
1844 assert(!_finished); 2085 assert(!_finished);
1845 assert(!_json.containsKey("uriEnd")); 2086 _uriEnd = _value;
1846 if (_value != null) {
1847 _json["uriEnd"] = _value;
1848 }
1849 } 2087 }
1850 2088
1851 /** 2089 /**
1852 * Offset of the prefix name relative to the beginning of the file, or zero 2090 * Offset of the prefix name relative to the beginning of the file, or zero
1853 * if there is no prefix. 2091 * if there is no prefix.
1854 */ 2092 */
1855 void set prefixOffset(int _value) { 2093 void set prefixOffset(int _value) {
1856 assert(!_finished); 2094 assert(!_finished);
1857 assert(!_json.containsKey("prefixOffset")); 2095 _prefixOffset = _value;
1858 if (_value != null) {
1859 _json["prefixOffset"] = _value;
1860 }
1861 } 2096 }
1862 2097
1863 Map finish() { 2098 fb.Offset finish(fb.Builder fbBuilder) {
1864 assert(!_finished); 2099 assert(!_finished);
1865 _finished = true; 2100 _finished = true;
1866 return _json; 2101 fb.Offset offset_uri;
2102 fb.Offset offset_combinators;
2103 if (_uri != null) {
2104 offset_uri = fbBuilder.writeString(_uri);
2105 }
2106 if (!(_combinators == null || _combinators.isEmpty)) {
2107 offset_combinators = fbBuilder.writeList(_combinators.map((b) => b.finish( fbBuilder)).toList());
2108 }
2109 fbBuilder.startTable();
2110 if (offset_uri != null) {
2111 fbBuilder.addOffset(0, offset_uri);
2112 }
2113 if (_offset != null && _offset != 0) {
2114 fbBuilder.addInt32(1, _offset);
2115 }
2116 if (_prefixReference != null && _prefixReference != 0) {
2117 fbBuilder.addInt32(2, _prefixReference);
2118 }
2119 if (offset_combinators != null) {
2120 fbBuilder.addOffset(3, offset_combinators);
2121 }
2122 if (_isDeferred == true) {
2123 fbBuilder.addInt8(4, 1);
2124 }
2125 if (_isImplicit == true) {
2126 fbBuilder.addInt8(5, 1);
2127 }
2128 if (_uriOffset != null && _uriOffset != 0) {
2129 fbBuilder.addInt32(6, _uriOffset);
2130 }
2131 if (_uriEnd != null && _uriEnd != 0) {
2132 fbBuilder.addInt32(7, _uriEnd);
2133 }
2134 if (_prefixOffset != null && _prefixOffset != 0) {
2135 fbBuilder.addInt32(8, _prefixOffset);
2136 }
2137 return fbBuilder.endTable();
1867 } 2138 }
1868 } 2139 }
1869 2140
1870 UnlinkedImportBuilder encodeUnlinkedImport(base.BuilderContext builderContext, { String uri, int offset, int prefixReference, List<UnlinkedCombinatorBuilder> com binators, bool isDeferred, bool isImplicit, int uriOffset, int uriEnd, int prefi xOffset}) { 2141 UnlinkedImportBuilder encodeUnlinkedImport(base.BuilderContext builderContext, { String uri, int offset, int prefixReference, List<UnlinkedCombinatorBuilder> com binators, bool isDeferred, bool isImplicit, int uriOffset, int uriEnd, int prefi xOffset}) {
1871 UnlinkedImportBuilder builder = new UnlinkedImportBuilder(builderContext); 2142 UnlinkedImportBuilder builder = new UnlinkedImportBuilder(builderContext);
1872 builder.uri = uri; 2143 builder.uri = uri;
1873 builder.offset = offset; 2144 builder.offset = offset;
1874 builder.prefixReference = prefixReference; 2145 builder.prefixReference = prefixReference;
1875 builder.combinators = combinators; 2146 builder.combinators = combinators;
1876 builder.isDeferred = isDeferred; 2147 builder.isDeferred = isDeferred;
1877 builder.isImplicit = isImplicit; 2148 builder.isImplicit = isImplicit;
1878 builder.uriOffset = uriOffset; 2149 builder.uriOffset = uriOffset;
1879 builder.uriEnd = uriEnd; 2150 builder.uriEnd = uriEnd;
1880 builder.prefixOffset = prefixOffset; 2151 builder.prefixOffset = prefixOffset;
1881 return builder; 2152 return builder;
1882 } 2153 }
1883 2154
1884 /** 2155 /**
1885 * Unlinked summary information about a function parameter. 2156 * Unlinked summary information about an import declaration.
1886 */ 2157 */
1887 class UnlinkedParam extends base.SummaryClass { 2158 abstract class UnlinkedImport extends base.SummaryClass {
2159
2160 /**
2161 * URI used in the source code to reference the imported library.
2162 */
2163 String get uri;
2164
2165 /**
2166 * If [isImplicit] is false, offset of the "import" keyword. If [isImplicit]
2167 * is true, zero.
2168 */
2169 int get offset;
2170
2171 /**
2172 * Index into [UnlinkedUnit.references] of the prefix declared by this
2173 * import declaration, or zero if this import declaration declares no prefix.
2174 *
2175 * Note that multiple imports can declare the same prefix.
2176 */
2177 int get prefixReference;
2178
2179 /**
2180 * Combinators contained in this import declaration.
2181 */
2182 List<UnlinkedCombinator> get combinators;
2183
2184 /**
2185 * Indicates whether the import declaration uses the `deferred` keyword.
2186 */
2187 bool get isDeferred;
2188
2189 /**
2190 * Indicates whether the import declaration is implicit.
2191 */
2192 bool get isImplicit;
2193
2194 /**
2195 * Offset of the URI string (including quotes) relative to the beginning of
2196 * the file. If [isImplicit] is true, zero.
2197 */
2198 int get uriOffset;
2199
2200 /**
2201 * End of the URI string (including quotes) relative to the beginning of the
2202 * file. If [isImplicit] is true, zero.
2203 */
2204 int get uriEnd;
2205
2206 /**
2207 * Offset of the prefix name relative to the beginning of the file, or zero
2208 * if there is no prefix.
2209 */
2210 int get prefixOffset;
2211 }
2212
2213 class _UnlinkedImportReader extends fb.TableReader<_UnlinkedImportReader> implem ents UnlinkedImport {
2214 final fb.BufferPointer _bp;
2215
2216 const _UnlinkedImportReader([this._bp]);
2217
2218 @override
2219 _UnlinkedImportReader createReader(fb.BufferPointer bp) => new _UnlinkedImport Reader(bp);
2220
2221 @override
2222 Map<String, Object> toMap() => {
2223 "uri": uri,
2224 "offset": offset,
2225 "prefixReference": prefixReference,
2226 "combinators": combinators,
2227 "isDeferred": isDeferred,
2228 "isImplicit": isImplicit,
2229 "uriOffset": uriOffset,
2230 "uriEnd": uriEnd,
2231 "prefixOffset": prefixOffset,
2232 };
2233
2234 @override
2235 String get uri => const fb.StringReader().vTableGet(_bp, 0, '');
2236
2237 @override
2238 int get offset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
2239
2240 @override
2241 int get prefixReference => const fb.Int32Reader().vTableGet(_bp, 2, 0);
2242
2243 @override
2244 List<UnlinkedCombinator> get combinators => const fb.ListReader<UnlinkedCombin ator>(const _UnlinkedCombinatorReader()).vTableGet(_bp, 3, const <UnlinkedCombin ator>[]);
2245
2246 @override
2247 bool get isDeferred => const fb.Int8Reader().vTableGet(_bp, 4, 0) == 1;
2248
2249 @override
2250 bool get isImplicit => const fb.Int8Reader().vTableGet(_bp, 5, 0) == 1;
2251
2252 @override
2253 int get uriOffset => const fb.Int32Reader().vTableGet(_bp, 6, 0);
2254
2255 @override
2256 int get uriEnd => const fb.Int32Reader().vTableGet(_bp, 7, 0);
2257
2258 @override
2259 int get prefixOffset => const fb.Int32Reader().vTableGet(_bp, 8, 0);
2260 }
2261
2262 class UnlinkedParamBuilder {
2263 bool _finished = false;
2264
1888 String _name; 2265 String _name;
1889 int _nameOffset; 2266 int _nameOffset;
1890 UnlinkedTypeRef _type; 2267 UnlinkedTypeRefBuilder _type;
1891 List<UnlinkedParam> _parameters; 2268 List<UnlinkedParamBuilder> _parameters;
1892 UnlinkedParamKind _kind; 2269 UnlinkedParamKind _kind;
1893 bool _isFunctionTyped; 2270 bool _isFunctionTyped;
1894 bool _isInitializingFormal; 2271 bool _isInitializingFormal;
1895 bool _hasImplicitType; 2272 bool _hasImplicitType;
1896 2273
1897 UnlinkedParam.fromJson(Map json)
1898 : _name = json["name"],
1899 _nameOffset = json["nameOffset"],
1900 _type = json["type"] == null ? null : new UnlinkedTypeRef.fromJson(json["t ype"]),
1901 _parameters = json["parameters"]?.map((x) => new UnlinkedParam.fromJson(x) )?.toList(),
1902 _kind = json["kind"] == null ? null : UnlinkedParamKind.values[json["kind" ]],
1903 _isFunctionTyped = json["isFunctionTyped"],
1904 _isInitializingFormal = json["isInitializingFormal"],
1905 _hasImplicitType = json["hasImplicitType"];
1906
1907 @override
1908 Map<String, Object> toMap() => {
1909 "name": name,
1910 "nameOffset": nameOffset,
1911 "type": type,
1912 "parameters": parameters,
1913 "kind": kind,
1914 "isFunctionTyped": isFunctionTyped,
1915 "isInitializingFormal": isInitializingFormal,
1916 "hasImplicitType": hasImplicitType,
1917 };
1918
1919 /**
1920 * Name of the parameter.
1921 */
1922 String get name => _name ?? '';
1923
1924 /**
1925 * Offset of the parameter name relative to the beginning of the file.
1926 */
1927 int get nameOffset => _nameOffset ?? 0;
1928
1929 /**
1930 * If [isFunctionTyped] is `true`, the declared return type. If
1931 * [isFunctionTyped] is `false`, the declared type. Absent if
1932 * [isFunctionTyped] is `true` and the declared return type is `void`. Note
1933 * that when strong mode is enabled, the actual type may be different due to
1934 * type inference.
1935 */
1936 UnlinkedTypeRef get type => _type;
1937
1938 /**
1939 * If [isFunctionTyped] is `true`, the parameters of the function type.
1940 */
1941 List<UnlinkedParam> get parameters => _parameters ?? const <UnlinkedParam>[];
1942
1943 /**
1944 * Kind of the parameter.
1945 */
1946 UnlinkedParamKind get kind => _kind ?? UnlinkedParamKind.required;
1947
1948 /**
1949 * Indicates whether this is a function-typed parameter.
1950 */
1951 bool get isFunctionTyped => _isFunctionTyped ?? false;
1952
1953 /**
1954 * Indicates whether this is an initializing formal parameter (i.e. it is
1955 * declared using `this.` syntax).
1956 */
1957 bool get isInitializingFormal => _isInitializingFormal ?? false;
1958
1959 /**
1960 * Indicates whether this parameter lacks an explicit type declaration.
1961 * Always false for a function-typed parameter.
1962 */
1963 bool get hasImplicitType => _hasImplicitType ?? false;
1964 }
1965
1966 class UnlinkedParamBuilder {
1967 final Map _json = {};
1968
1969 bool _finished = false;
1970
1971 UnlinkedParamBuilder(base.BuilderContext context); 2274 UnlinkedParamBuilder(base.BuilderContext context);
1972 2275
1973 /** 2276 /**
1974 * Name of the parameter. 2277 * Name of the parameter.
1975 */ 2278 */
1976 void set name(String _value) { 2279 void set name(String _value) {
1977 assert(!_finished); 2280 assert(!_finished);
1978 assert(!_json.containsKey("name")); 2281 _name = _value;
1979 if (_value != null) {
1980 _json["name"] = _value;
1981 }
1982 } 2282 }
1983 2283
1984 /** 2284 /**
1985 * Offset of the parameter name relative to the beginning of the file. 2285 * Offset of the parameter name relative to the beginning of the file.
1986 */ 2286 */
1987 void set nameOffset(int _value) { 2287 void set nameOffset(int _value) {
1988 assert(!_finished); 2288 assert(!_finished);
1989 assert(!_json.containsKey("nameOffset")); 2289 _nameOffset = _value;
1990 if (_value != null) {
1991 _json["nameOffset"] = _value;
1992 }
1993 } 2290 }
1994 2291
1995 /** 2292 /**
1996 * If [isFunctionTyped] is `true`, the declared return type. If 2293 * If [isFunctionTyped] is `true`, the declared return type. If
1997 * [isFunctionTyped] is `false`, the declared type. Absent if 2294 * [isFunctionTyped] is `false`, the declared type. Absent if
1998 * [isFunctionTyped] is `true` and the declared return type is `void`. Note 2295 * [isFunctionTyped] is `true` and the declared return type is `void`. Note
1999 * that when strong mode is enabled, the actual type may be different due to 2296 * that when strong mode is enabled, the actual type may be different due to
2000 * type inference. 2297 * type inference.
2001 */ 2298 */
2002 void set type(UnlinkedTypeRefBuilder _value) { 2299 void set type(UnlinkedTypeRefBuilder _value) {
2003 assert(!_finished); 2300 assert(!_finished);
2004 assert(!_json.containsKey("type")); 2301 _type = _value;
2005 if (_value != null) {
2006 _json["type"] = _value.finish();
2007 }
2008 } 2302 }
2009 2303
2010 /** 2304 /**
2011 * If [isFunctionTyped] is `true`, the parameters of the function type. 2305 * If [isFunctionTyped] is `true`, the parameters of the function type.
2012 */ 2306 */
2013 void set parameters(List<UnlinkedParamBuilder> _value) { 2307 void set parameters(List<UnlinkedParamBuilder> _value) {
2014 assert(!_finished); 2308 assert(!_finished);
2015 assert(!_json.containsKey("parameters")); 2309 _parameters = _value;
2016 if (!(_value == null || _value.isEmpty)) {
2017 _json["parameters"] = _value.map((b) => b.finish()).toList();
2018 }
2019 } 2310 }
2020 2311
2021 /** 2312 /**
2022 * Kind of the parameter. 2313 * Kind of the parameter.
2023 */ 2314 */
2024 void set kind(UnlinkedParamKind _value) { 2315 void set kind(UnlinkedParamKind _value) {
2025 assert(!_finished); 2316 assert(!_finished);
2026 assert(!_json.containsKey("kind")); 2317 _kind = _value;
2027 if (!(_value == null || _value == UnlinkedParamKind.required)) {
2028 _json["kind"] = _value.index;
2029 }
2030 } 2318 }
2031 2319
2032 /** 2320 /**
2033 * Indicates whether this is a function-typed parameter. 2321 * Indicates whether this is a function-typed parameter.
2034 */ 2322 */
2035 void set isFunctionTyped(bool _value) { 2323 void set isFunctionTyped(bool _value) {
2036 assert(!_finished); 2324 assert(!_finished);
2037 assert(!_json.containsKey("isFunctionTyped")); 2325 _isFunctionTyped = _value;
2038 if (_value != null) {
2039 _json["isFunctionTyped"] = _value;
2040 }
2041 } 2326 }
2042 2327
2043 /** 2328 /**
2044 * Indicates whether this is an initializing formal parameter (i.e. it is 2329 * Indicates whether this is an initializing formal parameter (i.e. it is
2045 * declared using `this.` syntax). 2330 * declared using `this.` syntax).
2046 */ 2331 */
2047 void set isInitializingFormal(bool _value) { 2332 void set isInitializingFormal(bool _value) {
2048 assert(!_finished); 2333 assert(!_finished);
2049 assert(!_json.containsKey("isInitializingFormal")); 2334 _isInitializingFormal = _value;
2050 if (_value != null) {
2051 _json["isInitializingFormal"] = _value;
2052 }
2053 } 2335 }
2054 2336
2055 /** 2337 /**
2056 * Indicates whether this parameter lacks an explicit type declaration. 2338 * Indicates whether this parameter lacks an explicit type declaration.
2057 * Always false for a function-typed parameter. 2339 * Always false for a function-typed parameter.
2058 */ 2340 */
2059 void set hasImplicitType(bool _value) { 2341 void set hasImplicitType(bool _value) {
2060 assert(!_finished); 2342 assert(!_finished);
2061 assert(!_json.containsKey("hasImplicitType")); 2343 _hasImplicitType = _value;
2062 if (_value != null) {
2063 _json["hasImplicitType"] = _value;
2064 }
2065 } 2344 }
2066 2345
2067 Map finish() { 2346 fb.Offset finish(fb.Builder fbBuilder) {
2068 assert(!_finished); 2347 assert(!_finished);
2069 _finished = true; 2348 _finished = true;
2070 return _json; 2349 fb.Offset offset_name;
2350 fb.Offset offset_type;
2351 fb.Offset offset_parameters;
2352 if (_name != null) {
2353 offset_name = fbBuilder.writeString(_name);
2354 }
2355 if (_type != null) {
2356 offset_type = _type.finish(fbBuilder);
2357 }
2358 if (!(_parameters == null || _parameters.isEmpty)) {
2359 offset_parameters = fbBuilder.writeList(_parameters.map((b) => b.finish(fb Builder)).toList());
2360 }
2361 fbBuilder.startTable();
2362 if (offset_name != null) {
2363 fbBuilder.addOffset(0, offset_name);
2364 }
2365 if (_nameOffset != null && _nameOffset != 0) {
2366 fbBuilder.addInt32(1, _nameOffset);
2367 }
2368 if (offset_type != null) {
2369 fbBuilder.addOffset(2, offset_type);
2370 }
2371 if (offset_parameters != null) {
2372 fbBuilder.addOffset(3, offset_parameters);
2373 }
2374 if (_kind != null && _kind != UnlinkedParamKind.required) {
2375 fbBuilder.addInt32(4, _kind.index);
2376 }
2377 if (_isFunctionTyped == true) {
2378 fbBuilder.addInt8(5, 1);
2379 }
2380 if (_isInitializingFormal == true) {
2381 fbBuilder.addInt8(6, 1);
2382 }
2383 if (_hasImplicitType == true) {
2384 fbBuilder.addInt8(7, 1);
2385 }
2386 return fbBuilder.endTable();
2071 } 2387 }
2072 } 2388 }
2073 2389
2074 UnlinkedParamBuilder encodeUnlinkedParam(base.BuilderContext builderContext, {St ring name, int nameOffset, UnlinkedTypeRefBuilder type, List<UnlinkedParamBuilde r> parameters, UnlinkedParamKind kind, bool isFunctionTyped, bool isInitializing Formal, bool hasImplicitType}) { 2390 UnlinkedParamBuilder encodeUnlinkedParam(base.BuilderContext builderContext, {St ring name, int nameOffset, UnlinkedTypeRefBuilder type, List<UnlinkedParamBuilde r> parameters, UnlinkedParamKind kind, bool isFunctionTyped, bool isInitializing Formal, bool hasImplicitType}) {
2075 UnlinkedParamBuilder builder = new UnlinkedParamBuilder(builderContext); 2391 UnlinkedParamBuilder builder = new UnlinkedParamBuilder(builderContext);
2076 builder.name = name; 2392 builder.name = name;
2077 builder.nameOffset = nameOffset; 2393 builder.nameOffset = nameOffset;
2078 builder.type = type; 2394 builder.type = type;
2079 builder.parameters = parameters; 2395 builder.parameters = parameters;
2080 builder.kind = kind; 2396 builder.kind = kind;
2081 builder.isFunctionTyped = isFunctionTyped; 2397 builder.isFunctionTyped = isFunctionTyped;
2082 builder.isInitializingFormal = isInitializingFormal; 2398 builder.isInitializingFormal = isInitializingFormal;
2083 builder.hasImplicitType = hasImplicitType; 2399 builder.hasImplicitType = hasImplicitType;
2084 return builder; 2400 return builder;
2085 } 2401 }
2086 2402
2087 /** 2403 /**
2088 * Unlinked summary information about a part declaration. 2404 * Unlinked summary information about a function parameter.
2089 */ 2405 */
2090 class UnlinkedPart extends base.SummaryClass { 2406 abstract class UnlinkedParam extends base.SummaryClass {
2091 int _uriOffset;
2092 int _uriEnd;
2093 2407
2094 UnlinkedPart.fromJson(Map json) 2408 /**
2095 : _uriOffset = json["uriOffset"], 2409 * Name of the parameter.
2096 _uriEnd = json["uriEnd"]; 2410 */
2411 String get name;
2412
2413 /**
2414 * Offset of the parameter name relative to the beginning of the file.
2415 */
2416 int get nameOffset;
2417
2418 /**
2419 * If [isFunctionTyped] is `true`, the declared return type. If
2420 * [isFunctionTyped] is `false`, the declared type. Absent if
2421 * [isFunctionTyped] is `true` and the declared return type is `void`. Note
2422 * that when strong mode is enabled, the actual type may be different due to
2423 * type inference.
2424 */
2425 UnlinkedTypeRef get type;
2426
2427 /**
2428 * If [isFunctionTyped] is `true`, the parameters of the function type.
2429 */
2430 List<UnlinkedParam> get parameters;
2431
2432 /**
2433 * Kind of the parameter.
2434 */
2435 UnlinkedParamKind get kind;
2436
2437 /**
2438 * Indicates whether this is a function-typed parameter.
2439 */
2440 bool get isFunctionTyped;
2441
2442 /**
2443 * Indicates whether this is an initializing formal parameter (i.e. it is
2444 * declared using `this.` syntax).
2445 */
2446 bool get isInitializingFormal;
2447
2448 /**
2449 * Indicates whether this parameter lacks an explicit type declaration.
2450 * Always false for a function-typed parameter.
2451 */
2452 bool get hasImplicitType;
2453 }
2454
2455 class _UnlinkedParamReader extends fb.TableReader<_UnlinkedParamReader> implemen ts UnlinkedParam {
2456 final fb.BufferPointer _bp;
2457
2458 const _UnlinkedParamReader([this._bp]);
2459
2460 @override
2461 _UnlinkedParamReader createReader(fb.BufferPointer bp) => new _UnlinkedParamRe ader(bp);
2097 2462
2098 @override 2463 @override
2099 Map<String, Object> toMap() => { 2464 Map<String, Object> toMap() => {
2100 "uriOffset": uriOffset, 2465 "name": name,
2101 "uriEnd": uriEnd, 2466 "nameOffset": nameOffset,
2467 "type": type,
2468 "parameters": parameters,
2469 "kind": kind,
2470 "isFunctionTyped": isFunctionTyped,
2471 "isInitializingFormal": isInitializingFormal,
2472 "hasImplicitType": hasImplicitType,
2102 }; 2473 };
2103 2474
2104 /** 2475 @override
2105 * Offset of the URI string (including quotes) relative to the beginning of 2476 String get name => const fb.StringReader().vTableGet(_bp, 0, '');
2106 * the file.
2107 */
2108 int get uriOffset => _uriOffset ?? 0;
2109 2477
2110 /** 2478 @override
2111 * End of the URI string (including quotes) relative to the beginning of the 2479 int get nameOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
2112 * file. 2480
2113 */ 2481 @override
2114 int get uriEnd => _uriEnd ?? 0; 2482 UnlinkedTypeRef get type => const _UnlinkedTypeRefReader().vTableGet(_bp, 2, n ull);
2483
2484 @override
2485 List<UnlinkedParam> get parameters => const fb.ListReader<UnlinkedParam>(const _UnlinkedParamReader()).vTableGet(_bp, 3, const <UnlinkedParam>[]);
2486
2487 @override
2488 UnlinkedParamKind get kind {
2489 int index = const fb.Int32Reader().vTableGet(_bp, 4, 0);
2490 return UnlinkedParamKind.values[index];
2491 }
2492
2493 @override
2494 bool get isFunctionTyped => const fb.Int8Reader().vTableGet(_bp, 5, 0) == 1;
2495
2496 @override
2497 bool get isInitializingFormal => const fb.Int8Reader().vTableGet(_bp, 6, 0) == 1;
2498
2499 @override
2500 bool get hasImplicitType => const fb.Int8Reader().vTableGet(_bp, 7, 0) == 1;
2115 } 2501 }
2116 2502
2117 class UnlinkedPartBuilder { 2503 class UnlinkedPartBuilder {
2118 final Map _json = {}; 2504 bool _finished = false;
2119 2505
2120 bool _finished = false; 2506 int _uriOffset;
2507 int _uriEnd;
2121 2508
2122 UnlinkedPartBuilder(base.BuilderContext context); 2509 UnlinkedPartBuilder(base.BuilderContext context);
2123 2510
2124 /** 2511 /**
2125 * Offset of the URI string (including quotes) relative to the beginning of 2512 * Offset of the URI string (including quotes) relative to the beginning of
2126 * the file. 2513 * the file.
2127 */ 2514 */
2128 void set uriOffset(int _value) { 2515 void set uriOffset(int _value) {
2129 assert(!_finished); 2516 assert(!_finished);
2130 assert(!_json.containsKey("uriOffset")); 2517 _uriOffset = _value;
2131 if (_value != null) {
2132 _json["uriOffset"] = _value;
2133 }
2134 } 2518 }
2135 2519
2136 /** 2520 /**
2137 * End of the URI string (including quotes) relative to the beginning of the 2521 * End of the URI string (including quotes) relative to the beginning of the
2138 * file. 2522 * file.
2139 */ 2523 */
2140 void set uriEnd(int _value) { 2524 void set uriEnd(int _value) {
2141 assert(!_finished); 2525 assert(!_finished);
2142 assert(!_json.containsKey("uriEnd")); 2526 _uriEnd = _value;
2143 if (_value != null) {
2144 _json["uriEnd"] = _value;
2145 }
2146 } 2527 }
2147 2528
2148 Map finish() { 2529 fb.Offset finish(fb.Builder fbBuilder) {
2149 assert(!_finished); 2530 assert(!_finished);
2150 _finished = true; 2531 _finished = true;
2151 return _json; 2532 fbBuilder.startTable();
2533 if (_uriOffset != null && _uriOffset != 0) {
2534 fbBuilder.addInt32(0, _uriOffset);
2535 }
2536 if (_uriEnd != null && _uriEnd != 0) {
2537 fbBuilder.addInt32(1, _uriEnd);
2538 }
2539 return fbBuilder.endTable();
2152 } 2540 }
2153 } 2541 }
2154 2542
2155 UnlinkedPartBuilder encodeUnlinkedPart(base.BuilderContext builderContext, {int uriOffset, int uriEnd}) { 2543 UnlinkedPartBuilder encodeUnlinkedPart(base.BuilderContext builderContext, {int uriOffset, int uriEnd}) {
2156 UnlinkedPartBuilder builder = new UnlinkedPartBuilder(builderContext); 2544 UnlinkedPartBuilder builder = new UnlinkedPartBuilder(builderContext);
2157 builder.uriOffset = uriOffset; 2545 builder.uriOffset = uriOffset;
2158 builder.uriEnd = uriEnd; 2546 builder.uriEnd = uriEnd;
2159 return builder; 2547 return builder;
2160 } 2548 }
2161 2549
2162 /** 2550 /**
2163 * Unlinked summary information about a specific name contributed by a 2551 * Unlinked summary information about a part declaration.
2164 * compilation unit to a library's public namespace.
2165 *
2166 * TODO(paulberry): add a count of generic parameters, so that resynthesis
2167 * doesn't have to peek into the library to obtain this info.
2168 *
2169 * TODO(paulberry): for classes, add info about static members and
2170 * constructors, since this will be needed to prelink info about constants.
2171 *
2172 * TODO(paulberry): some of this information is redundant with information
2173 * elsewhere in the summary. Consider reducing the redundancy to reduce
2174 * summary size.
2175 */ 2552 */
2176 class UnlinkedPublicName extends base.SummaryClass { 2553 abstract class UnlinkedPart extends base.SummaryClass {
2554
2555 /**
2556 * Offset of the URI string (including quotes) relative to the beginning of
2557 * the file.
2558 */
2559 int get uriOffset;
2560
2561 /**
2562 * End of the URI string (including quotes) relative to the beginning of the
2563 * file.
2564 */
2565 int get uriEnd;
2566 }
2567
2568 class _UnlinkedPartReader extends fb.TableReader<_UnlinkedPartReader> implements UnlinkedPart {
2569 final fb.BufferPointer _bp;
2570
2571 const _UnlinkedPartReader([this._bp]);
2572
2573 @override
2574 _UnlinkedPartReader createReader(fb.BufferPointer bp) => new _UnlinkedPartRead er(bp);
2575
2576 @override
2577 Map<String, Object> toMap() => {
2578 "uriOffset": uriOffset,
2579 "uriEnd": uriEnd,
2580 };
2581
2582 @override
2583 int get uriOffset => const fb.Int32Reader().vTableGet(_bp, 0, 0);
2584
2585 @override
2586 int get uriEnd => const fb.Int32Reader().vTableGet(_bp, 1, 0);
2587 }
2588
2589 class UnlinkedPublicNameBuilder {
2590 bool _finished = false;
2591
2177 String _name; 2592 String _name;
2178 PrelinkedReferenceKind _kind; 2593 PrelinkedReferenceKind _kind;
2179 int _numTypeParameters; 2594 int _numTypeParameters;
2180 2595
2181 UnlinkedPublicName.fromJson(Map json)
2182 : _name = json["name"],
2183 _kind = json["kind"] == null ? null : PrelinkedReferenceKind.values[json[" kind"]],
2184 _numTypeParameters = json["numTypeParameters"];
2185
2186 @override
2187 Map<String, Object> toMap() => {
2188 "name": name,
2189 "kind": kind,
2190 "numTypeParameters": numTypeParameters,
2191 };
2192
2193 /**
2194 * The name itself.
2195 */
2196 String get name => _name ?? '';
2197
2198 /**
2199 * The kind of object referred to by the name.
2200 */
2201 PrelinkedReferenceKind get kind => _kind ?? PrelinkedReferenceKind.classOrEnum ;
2202
2203 /**
2204 * If the entity being referred to is generic, the number of type parameters
2205 * it accepts. Otherwise zero.
2206 */
2207 int get numTypeParameters => _numTypeParameters ?? 0;
2208 }
2209
2210 class UnlinkedPublicNameBuilder {
2211 final Map _json = {};
2212
2213 bool _finished = false;
2214
2215 UnlinkedPublicNameBuilder(base.BuilderContext context); 2596 UnlinkedPublicNameBuilder(base.BuilderContext context);
2216 2597
2217 /** 2598 /**
2218 * The name itself. 2599 * The name itself.
2219 */ 2600 */
2220 void set name(String _value) { 2601 void set name(String _value) {
2221 assert(!_finished); 2602 assert(!_finished);
2222 assert(!_json.containsKey("name")); 2603 _name = _value;
2223 if (_value != null) {
2224 _json["name"] = _value;
2225 }
2226 } 2604 }
2227 2605
2228 /** 2606 /**
2229 * The kind of object referred to by the name. 2607 * The kind of object referred to by the name.
2230 */ 2608 */
2231 void set kind(PrelinkedReferenceKind _value) { 2609 void set kind(PrelinkedReferenceKind _value) {
2232 assert(!_finished); 2610 assert(!_finished);
2233 assert(!_json.containsKey("kind")); 2611 _kind = _value;
2234 if (!(_value == null || _value == PrelinkedReferenceKind.classOrEnum)) {
2235 _json["kind"] = _value.index;
2236 }
2237 } 2612 }
2238 2613
2239 /** 2614 /**
2240 * If the entity being referred to is generic, the number of type parameters 2615 * If the entity being referred to is generic, the number of type parameters
2241 * it accepts. Otherwise zero. 2616 * it accepts. Otherwise zero.
2242 */ 2617 */
2243 void set numTypeParameters(int _value) { 2618 void set numTypeParameters(int _value) {
2244 assert(!_finished); 2619 assert(!_finished);
2245 assert(!_json.containsKey("numTypeParameters")); 2620 _numTypeParameters = _value;
2246 if (_value != null) {
2247 _json["numTypeParameters"] = _value;
2248 }
2249 } 2621 }
2250 2622
2251 Map finish() { 2623 fb.Offset finish(fb.Builder fbBuilder) {
2252 assert(!_finished); 2624 assert(!_finished);
2253 _finished = true; 2625 _finished = true;
2254 return _json; 2626 fb.Offset offset_name;
2627 if (_name != null) {
2628 offset_name = fbBuilder.writeString(_name);
2629 }
2630 fbBuilder.startTable();
2631 if (offset_name != null) {
2632 fbBuilder.addOffset(0, offset_name);
2633 }
2634 if (_kind != null && _kind != PrelinkedReferenceKind.classOrEnum) {
2635 fbBuilder.addInt32(1, _kind.index);
2636 }
2637 if (_numTypeParameters != null && _numTypeParameters != 0) {
2638 fbBuilder.addInt32(2, _numTypeParameters);
2639 }
2640 return fbBuilder.endTable();
2255 } 2641 }
2256 } 2642 }
2257 2643
2258 UnlinkedPublicNameBuilder encodeUnlinkedPublicName(base.BuilderContext builderCo ntext, {String name, PrelinkedReferenceKind kind, int numTypeParameters}) { 2644 UnlinkedPublicNameBuilder encodeUnlinkedPublicName(base.BuilderContext builderCo ntext, {String name, PrelinkedReferenceKind kind, int numTypeParameters}) {
2259 UnlinkedPublicNameBuilder builder = new UnlinkedPublicNameBuilder(builderConte xt); 2645 UnlinkedPublicNameBuilder builder = new UnlinkedPublicNameBuilder(builderConte xt);
2260 builder.name = name; 2646 builder.name = name;
2261 builder.kind = kind; 2647 builder.kind = kind;
2262 builder.numTypeParameters = numTypeParameters; 2648 builder.numTypeParameters = numTypeParameters;
2263 return builder; 2649 return builder;
2264 } 2650 }
2265 2651
2266 /** 2652 /**
2267 * Unlinked summary information about what a compilation unit contributes to a 2653 * Unlinked summary information about a specific name contributed by a
2268 * library's public namespace. This is the subset of [UnlinkedUnit] that is 2654 * compilation unit to a library's public namespace.
2269 * required from dependent libraries in order to perform prelinking. 2655 *
2656 * TODO(paulberry): add a count of generic parameters, so that resynthesis
2657 * doesn't have to peek into the library to obtain this info.
2658 *
2659 * TODO(paulberry): for classes, add info about static members and
2660 * constructors, since this will be needed to prelink info about constants.
2661 *
2662 * TODO(paulberry): some of this information is redundant with information
2663 * elsewhere in the summary. Consider reducing the redundancy to reduce
2664 * summary size.
2270 */ 2665 */
2271 class UnlinkedPublicNamespace extends base.SummaryClass { 2666 abstract class UnlinkedPublicName extends base.SummaryClass {
2272 List<UnlinkedPublicName> _names;
2273 List<UnlinkedExportPublic> _exports;
2274 List<String> _parts;
2275 2667
2276 UnlinkedPublicNamespace.fromJson(Map json) 2668 /**
2277 : _names = json["names"]?.map((x) => new UnlinkedPublicName.fromJson(x))?.to List(), 2669 * The name itself.
2278 _exports = json["exports"]?.map((x) => new UnlinkedExportPublic.fromJson(x ))?.toList(), 2670 */
2279 _parts = json["parts"]; 2671 String get name;
2672
2673 /**
2674 * The kind of object referred to by the name.
2675 */
2676 PrelinkedReferenceKind get kind;
2677
2678 /**
2679 * If the entity being referred to is generic, the number of type parameters
2680 * it accepts. Otherwise zero.
2681 */
2682 int get numTypeParameters;
2683 }
2684
2685 class _UnlinkedPublicNameReader extends fb.TableReader<_UnlinkedPublicNameReader > implements UnlinkedPublicName {
2686 final fb.BufferPointer _bp;
2687
2688 const _UnlinkedPublicNameReader([this._bp]);
2689
2690 @override
2691 _UnlinkedPublicNameReader createReader(fb.BufferPointer bp) => new _UnlinkedPu blicNameReader(bp);
2280 2692
2281 @override 2693 @override
2282 Map<String, Object> toMap() => { 2694 Map<String, Object> toMap() => {
2283 "names": names, 2695 "name": name,
2284 "exports": exports, 2696 "kind": kind,
2285 "parts": parts, 2697 "numTypeParameters": numTypeParameters,
2286 }; 2698 };
2287 2699
2288 UnlinkedPublicNamespace.fromBuffer(List<int> buffer) : this.fromJson(JSON.deco de(UTF8.decode(buffer))); 2700 @override
2701 String get name => const fb.StringReader().vTableGet(_bp, 0, '');
2289 2702
2290 /** 2703 @override
2291 * Public names defined in the compilation unit. 2704 PrelinkedReferenceKind get kind {
2292 * 2705 int index = const fb.Int32Reader().vTableGet(_bp, 1, 0);
2293 * TODO(paulberry): consider sorting these names to reduce unnecessary 2706 return PrelinkedReferenceKind.values[index];
2294 * relinking. 2707 }
2295 */
2296 List<UnlinkedPublicName> get names => _names ?? const <UnlinkedPublicName>[];
2297 2708
2298 /** 2709 @override
2299 * Export declarations in the compilation unit. 2710 int get numTypeParameters => const fb.Int32Reader().vTableGet(_bp, 2, 0);
2300 */
2301 List<UnlinkedExportPublic> get exports => _exports ?? const <UnlinkedExportPub lic>[];
2302
2303 /**
2304 * URIs referenced by part declarations in the compilation unit.
2305 */
2306 List<String> get parts => _parts ?? const <String>[];
2307 } 2711 }
2308 2712
2309 class UnlinkedPublicNamespaceBuilder { 2713 class UnlinkedPublicNamespaceBuilder {
2310 final Map _json = {}; 2714 bool _finished = false;
2311 2715
2312 bool _finished = false; 2716 List<UnlinkedPublicNameBuilder> _names;
2717 List<UnlinkedExportPublicBuilder> _exports;
2718 List<String> _parts;
2313 2719
2314 UnlinkedPublicNamespaceBuilder(base.BuilderContext context); 2720 UnlinkedPublicNamespaceBuilder(base.BuilderContext context);
2315 2721
2316 /** 2722 /**
2317 * Public names defined in the compilation unit. 2723 * Public names defined in the compilation unit.
2318 * 2724 *
2319 * TODO(paulberry): consider sorting these names to reduce unnecessary 2725 * TODO(paulberry): consider sorting these names to reduce unnecessary
2320 * relinking. 2726 * relinking.
2321 */ 2727 */
2322 void set names(List<UnlinkedPublicNameBuilder> _value) { 2728 void set names(List<UnlinkedPublicNameBuilder> _value) {
2323 assert(!_finished); 2729 assert(!_finished);
2324 assert(!_json.containsKey("names")); 2730 _names = _value;
2325 if (!(_value == null || _value.isEmpty)) {
2326 _json["names"] = _value.map((b) => b.finish()).toList();
2327 }
2328 } 2731 }
2329 2732
2330 /** 2733 /**
2331 * Export declarations in the compilation unit. 2734 * Export declarations in the compilation unit.
2332 */ 2735 */
2333 void set exports(List<UnlinkedExportPublicBuilder> _value) { 2736 void set exports(List<UnlinkedExportPublicBuilder> _value) {
2334 assert(!_finished); 2737 assert(!_finished);
2335 assert(!_json.containsKey("exports")); 2738 _exports = _value;
2336 if (!(_value == null || _value.isEmpty)) {
2337 _json["exports"] = _value.map((b) => b.finish()).toList();
2338 }
2339 } 2739 }
2340 2740
2341 /** 2741 /**
2342 * URIs referenced by part declarations in the compilation unit. 2742 * URIs referenced by part declarations in the compilation unit.
2343 */ 2743 */
2344 void set parts(List<String> _value) { 2744 void set parts(List<String> _value) {
2345 assert(!_finished); 2745 assert(!_finished);
2346 assert(!_json.containsKey("parts")); 2746 _parts = _value;
2347 if (!(_value == null || _value.isEmpty)) {
2348 _json["parts"] = _value.toList();
2349 }
2350 } 2747 }
2351 2748
2352 List<int> toBuffer() => UTF8.encode(JSON.encode(finish())); 2749 List<int> toBuffer() {
2750 fb.Builder fbBuilder = new fb.Builder();
2751 return fbBuilder.finish(finish(fbBuilder));
2752 }
2353 2753
2354 Map finish() { 2754 fb.Offset finish(fb.Builder fbBuilder) {
2355 assert(!_finished); 2755 assert(!_finished);
2356 _finished = true; 2756 _finished = true;
2357 return _json; 2757 fb.Offset offset_names;
2758 fb.Offset offset_exports;
2759 fb.Offset offset_parts;
2760 if (!(_names == null || _names.isEmpty)) {
2761 offset_names = fbBuilder.writeList(_names.map((b) => b.finish(fbBuilder)). toList());
2762 }
2763 if (!(_exports == null || _exports.isEmpty)) {
2764 offset_exports = fbBuilder.writeList(_exports.map((b) => b.finish(fbBuilde r)).toList());
2765 }
2766 if (!(_parts == null || _parts.isEmpty)) {
2767 offset_parts = fbBuilder.writeList(_parts.map((b) => fbBuilder.writeString (b)).toList());
2768 }
2769 fbBuilder.startTable();
2770 if (offset_names != null) {
2771 fbBuilder.addOffset(0, offset_names);
2772 }
2773 if (offset_exports != null) {
2774 fbBuilder.addOffset(1, offset_exports);
2775 }
2776 if (offset_parts != null) {
2777 fbBuilder.addOffset(2, offset_parts);
2778 }
2779 return fbBuilder.endTable();
2358 } 2780 }
2359 } 2781 }
2360 2782
2361 UnlinkedPublicNamespaceBuilder encodeUnlinkedPublicNamespace(base.BuilderContext builderContext, {List<UnlinkedPublicNameBuilder> names, List<UnlinkedExportPubl icBuilder> exports, List<String> parts}) { 2783 UnlinkedPublicNamespaceBuilder encodeUnlinkedPublicNamespace(base.BuilderContext builderContext, {List<UnlinkedPublicNameBuilder> names, List<UnlinkedExportPubl icBuilder> exports, List<String> parts}) {
2362 UnlinkedPublicNamespaceBuilder builder = new UnlinkedPublicNamespaceBuilder(bu ilderContext); 2784 UnlinkedPublicNamespaceBuilder builder = new UnlinkedPublicNamespaceBuilder(bu ilderContext);
2363 builder.names = names; 2785 builder.names = names;
2364 builder.exports = exports; 2786 builder.exports = exports;
2365 builder.parts = parts; 2787 builder.parts = parts;
2366 return builder; 2788 return builder;
2367 } 2789 }
2368 2790
2369 /** 2791 /**
2370 * Unlinked summary information about a name referred to in one library that 2792 * Unlinked summary information about what a compilation unit contributes to a
2371 * might be defined in another. 2793 * library's public namespace. This is the subset of [UnlinkedUnit] that is
2794 * required from dependent libraries in order to perform prelinking.
2372 */ 2795 */
2373 class UnlinkedReference extends base.SummaryClass { 2796 abstract class UnlinkedPublicNamespace extends base.SummaryClass {
2374 String _name; 2797 factory UnlinkedPublicNamespace.fromBuffer(List<int> buffer) {
2375 int _prefixReference; 2798 fb.BufferPointer rootRef = new fb.BufferPointer.fromBytes(buffer);
2799 return const _UnlinkedPublicNamespaceReader().read(rootRef);
2800 }
2376 2801
2377 UnlinkedReference.fromJson(Map json) 2802 /**
2378 : _name = json["name"], 2803 * Public names defined in the compilation unit.
2379 _prefixReference = json["prefixReference"]; 2804 *
2805 * TODO(paulberry): consider sorting these names to reduce unnecessary
2806 * relinking.
2807 */
2808 List<UnlinkedPublicName> get names;
2809
2810 /**
2811 * Export declarations in the compilation unit.
2812 */
2813 List<UnlinkedExportPublic> get exports;
2814
2815 /**
2816 * URIs referenced by part declarations in the compilation unit.
2817 */
2818 List<String> get parts;
2819 }
2820
2821 class _UnlinkedPublicNamespaceReader extends fb.TableReader<_UnlinkedPublicNames paceReader> implements UnlinkedPublicNamespace {
2822 final fb.BufferPointer _bp;
2823
2824 const _UnlinkedPublicNamespaceReader([this._bp]);
2825
2826 @override
2827 _UnlinkedPublicNamespaceReader createReader(fb.BufferPointer bp) => new _Unlin kedPublicNamespaceReader(bp);
2380 2828
2381 @override 2829 @override
2382 Map<String, Object> toMap() => { 2830 Map<String, Object> toMap() => {
2383 "name": name, 2831 "names": names,
2384 "prefixReference": prefixReference, 2832 "exports": exports,
2833 "parts": parts,
2385 }; 2834 };
2386 2835
2387 /** 2836 @override
2388 * Name of the entity being referred to. The empty string refers to the 2837 List<UnlinkedPublicName> get names => const fb.ListReader<UnlinkedPublicName>( const _UnlinkedPublicNameReader()).vTableGet(_bp, 0, const <UnlinkedPublicName>[ ]);
2389 * pseudo-type `dynamic`.
2390 */
2391 String get name => _name ?? '';
2392 2838
2393 /** 2839 @override
2394 * Prefix used to refer to the entity, or zero if no prefix is used. This is 2840 List<UnlinkedExportPublic> get exports => const fb.ListReader<UnlinkedExportPu blic>(const _UnlinkedExportPublicReader()).vTableGet(_bp, 1, const <UnlinkedExpo rtPublic>[]);
2395 * an index into [UnlinkedUnit.references]. 2841
2396 */ 2842 @override
2397 int get prefixReference => _prefixReference ?? 0; 2843 List<String> get parts => const fb.ListReader<String>(const fb.StringReader()) .vTableGet(_bp, 2, const <String>[]);
2398 } 2844 }
2399 2845
2400 class UnlinkedReferenceBuilder { 2846 class UnlinkedReferenceBuilder {
2401 final Map _json = {}; 2847 bool _finished = false;
2402 2848
2403 bool _finished = false; 2849 String _name;
2850 int _prefixReference;
2404 2851
2405 UnlinkedReferenceBuilder(base.BuilderContext context); 2852 UnlinkedReferenceBuilder(base.BuilderContext context);
2406 2853
2407 /** 2854 /**
2408 * Name of the entity being referred to. The empty string refers to the 2855 * Name of the entity being referred to. The empty string refers to the
2409 * pseudo-type `dynamic`. 2856 * pseudo-type `dynamic`.
2410 */ 2857 */
2411 void set name(String _value) { 2858 void set name(String _value) {
2412 assert(!_finished); 2859 assert(!_finished);
2413 assert(!_json.containsKey("name")); 2860 _name = _value;
2414 if (_value != null) {
2415 _json["name"] = _value;
2416 }
2417 } 2861 }
2418 2862
2419 /** 2863 /**
2420 * Prefix used to refer to the entity, or zero if no prefix is used. This is 2864 * Prefix used to refer to the entity, or zero if no prefix is used. This is
2421 * an index into [UnlinkedUnit.references]. 2865 * an index into [UnlinkedUnit.references].
2422 */ 2866 */
2423 void set prefixReference(int _value) { 2867 void set prefixReference(int _value) {
2424 assert(!_finished); 2868 assert(!_finished);
2425 assert(!_json.containsKey("prefixReference")); 2869 _prefixReference = _value;
2426 if (_value != null) {
2427 _json["prefixReference"] = _value;
2428 }
2429 } 2870 }
2430 2871
2431 Map finish() { 2872 fb.Offset finish(fb.Builder fbBuilder) {
2432 assert(!_finished); 2873 assert(!_finished);
2433 _finished = true; 2874 _finished = true;
2434 return _json; 2875 fb.Offset offset_name;
2876 if (_name != null) {
2877 offset_name = fbBuilder.writeString(_name);
2878 }
2879 fbBuilder.startTable();
2880 if (offset_name != null) {
2881 fbBuilder.addOffset(0, offset_name);
2882 }
2883 if (_prefixReference != null && _prefixReference != 0) {
2884 fbBuilder.addInt32(1, _prefixReference);
2885 }
2886 return fbBuilder.endTable();
2435 } 2887 }
2436 } 2888 }
2437 2889
2438 UnlinkedReferenceBuilder encodeUnlinkedReference(base.BuilderContext builderCont ext, {String name, int prefixReference}) { 2890 UnlinkedReferenceBuilder encodeUnlinkedReference(base.BuilderContext builderCont ext, {String name, int prefixReference}) {
2439 UnlinkedReferenceBuilder builder = new UnlinkedReferenceBuilder(builderContext ); 2891 UnlinkedReferenceBuilder builder = new UnlinkedReferenceBuilder(builderContext );
2440 builder.name = name; 2892 builder.name = name;
2441 builder.prefixReference = prefixReference; 2893 builder.prefixReference = prefixReference;
2442 return builder; 2894 return builder;
2443 } 2895 }
2444 2896
2445 /** 2897 /**
2446 * Unlinked summary information about a typedef declaration. 2898 * Unlinked summary information about a name referred to in one library that
2899 * might be defined in another.
2447 */ 2900 */
2448 class UnlinkedTypedef extends base.SummaryClass { 2901 abstract class UnlinkedReference extends base.SummaryClass {
2449 String _name;
2450 int _nameOffset;
2451 UnlinkedDocumentationComment _documentationComment;
2452 List<UnlinkedTypeParam> _typeParameters;
2453 UnlinkedTypeRef _returnType;
2454 List<UnlinkedParam> _parameters;
2455 2902
2456 UnlinkedTypedef.fromJson(Map json) 2903 /**
2457 : _name = json["name"], 2904 * Name of the entity being referred to. The empty string refers to the
2458 _nameOffset = json["nameOffset"], 2905 * pseudo-type `dynamic`.
2459 _documentationComment = json["documentationComment"] == null ? null : new UnlinkedDocumentationComment.fromJson(json["documentationComment"]), 2906 */
2460 _typeParameters = json["typeParameters"]?.map((x) => new UnlinkedTypeParam .fromJson(x))?.toList(), 2907 String get name;
2461 _returnType = json["returnType"] == null ? null : new UnlinkedTypeRef.from Json(json["returnType"]), 2908
2462 _parameters = json["parameters"]?.map((x) => new UnlinkedParam.fromJson(x) )?.toList(); 2909 /**
2910 * Prefix used to refer to the entity, or zero if no prefix is used. This is
2911 * an index into [UnlinkedUnit.references].
2912 */
2913 int get prefixReference;
2914 }
2915
2916 class _UnlinkedReferenceReader extends fb.TableReader<_UnlinkedReferenceReader> implements UnlinkedReference {
2917 final fb.BufferPointer _bp;
2918
2919 const _UnlinkedReferenceReader([this._bp]);
2920
2921 @override
2922 _UnlinkedReferenceReader createReader(fb.BufferPointer bp) => new _UnlinkedRef erenceReader(bp);
2463 2923
2464 @override 2924 @override
2465 Map<String, Object> toMap() => { 2925 Map<String, Object> toMap() => {
2466 "name": name, 2926 "name": name,
2467 "nameOffset": nameOffset, 2927 "prefixReference": prefixReference,
2468 "documentationComment": documentationComment,
2469 "typeParameters": typeParameters,
2470 "returnType": returnType,
2471 "parameters": parameters,
2472 }; 2928 };
2473 2929
2474 /** 2930 @override
2475 * Name of the typedef. 2931 String get name => const fb.StringReader().vTableGet(_bp, 0, '');
2476 */
2477 String get name => _name ?? '';
2478 2932
2479 /** 2933 @override
2480 * Offset of the typedef name relative to the beginning of the file. 2934 int get prefixReference => const fb.Int32Reader().vTableGet(_bp, 1, 0);
2481 */
2482 int get nameOffset => _nameOffset ?? 0;
2483
2484 /**
2485 * Documentation comment for the typedef, or `null` if there is no
2486 * documentation comment.
2487 */
2488 UnlinkedDocumentationComment get documentationComment => _documentationComment ;
2489
2490 /**
2491 * Type parameters of the typedef, if any.
2492 */
2493 List<UnlinkedTypeParam> get typeParameters => _typeParameters ?? const <Unlink edTypeParam>[];
2494
2495 /**
2496 * Return type of the typedef. Absent if the return type is `void`.
2497 */
2498 UnlinkedTypeRef get returnType => _returnType;
2499
2500 /**
2501 * Parameters of the executable, if any.
2502 */
2503 List<UnlinkedParam> get parameters => _parameters ?? const <UnlinkedParam>[];
2504 } 2935 }
2505 2936
2506 class UnlinkedTypedefBuilder { 2937 class UnlinkedTypedefBuilder {
2507 final Map _json = {}; 2938 bool _finished = false;
2508 2939
2509 bool _finished = false; 2940 String _name;
2941 int _nameOffset;
2942 UnlinkedDocumentationCommentBuilder _documentationComment;
2943 List<UnlinkedTypeParamBuilder> _typeParameters;
2944 UnlinkedTypeRefBuilder _returnType;
2945 List<UnlinkedParamBuilder> _parameters;
2510 2946
2511 UnlinkedTypedefBuilder(base.BuilderContext context); 2947 UnlinkedTypedefBuilder(base.BuilderContext context);
2512 2948
2513 /** 2949 /**
2514 * Name of the typedef. 2950 * Name of the typedef.
2515 */ 2951 */
2516 void set name(String _value) { 2952 void set name(String _value) {
2517 assert(!_finished); 2953 assert(!_finished);
2518 assert(!_json.containsKey("name")); 2954 _name = _value;
2519 if (_value != null) {
2520 _json["name"] = _value;
2521 }
2522 } 2955 }
2523 2956
2524 /** 2957 /**
2525 * Offset of the typedef name relative to the beginning of the file. 2958 * Offset of the typedef name relative to the beginning of the file.
2526 */ 2959 */
2527 void set nameOffset(int _value) { 2960 void set nameOffset(int _value) {
2528 assert(!_finished); 2961 assert(!_finished);
2529 assert(!_json.containsKey("nameOffset")); 2962 _nameOffset = _value;
2530 if (_value != null) {
2531 _json["nameOffset"] = _value;
2532 }
2533 } 2963 }
2534 2964
2535 /** 2965 /**
2536 * Documentation comment for the typedef, or `null` if there is no 2966 * Documentation comment for the typedef, or `null` if there is no
2537 * documentation comment. 2967 * documentation comment.
2538 */ 2968 */
2539 void set documentationComment(UnlinkedDocumentationCommentBuilder _value) { 2969 void set documentationComment(UnlinkedDocumentationCommentBuilder _value) {
2540 assert(!_finished); 2970 assert(!_finished);
2541 assert(!_json.containsKey("documentationComment")); 2971 _documentationComment = _value;
2542 if (_value != null) {
2543 _json["documentationComment"] = _value.finish();
2544 }
2545 } 2972 }
2546 2973
2547 /** 2974 /**
2548 * Type parameters of the typedef, if any. 2975 * Type parameters of the typedef, if any.
2549 */ 2976 */
2550 void set typeParameters(List<UnlinkedTypeParamBuilder> _value) { 2977 void set typeParameters(List<UnlinkedTypeParamBuilder> _value) {
2551 assert(!_finished); 2978 assert(!_finished);
2552 assert(!_json.containsKey("typeParameters")); 2979 _typeParameters = _value;
2553 if (!(_value == null || _value.isEmpty)) {
2554 _json["typeParameters"] = _value.map((b) => b.finish()).toList();
2555 }
2556 } 2980 }
2557 2981
2558 /** 2982 /**
2559 * Return type of the typedef. Absent if the return type is `void`. 2983 * Return type of the typedef. Absent if the return type is `void`.
2560 */ 2984 */
2561 void set returnType(UnlinkedTypeRefBuilder _value) { 2985 void set returnType(UnlinkedTypeRefBuilder _value) {
2562 assert(!_finished); 2986 assert(!_finished);
2563 assert(!_json.containsKey("returnType")); 2987 _returnType = _value;
2564 if (_value != null) {
2565 _json["returnType"] = _value.finish();
2566 }
2567 } 2988 }
2568 2989
2569 /** 2990 /**
2570 * Parameters of the executable, if any. 2991 * Parameters of the executable, if any.
2571 */ 2992 */
2572 void set parameters(List<UnlinkedParamBuilder> _value) { 2993 void set parameters(List<UnlinkedParamBuilder> _value) {
2573 assert(!_finished); 2994 assert(!_finished);
2574 assert(!_json.containsKey("parameters")); 2995 _parameters = _value;
2575 if (!(_value == null || _value.isEmpty)) {
2576 _json["parameters"] = _value.map((b) => b.finish()).toList();
2577 }
2578 } 2996 }
2579 2997
2580 Map finish() { 2998 fb.Offset finish(fb.Builder fbBuilder) {
2581 assert(!_finished); 2999 assert(!_finished);
2582 _finished = true; 3000 _finished = true;
2583 return _json; 3001 fb.Offset offset_name;
3002 fb.Offset offset_documentationComment;
3003 fb.Offset offset_typeParameters;
3004 fb.Offset offset_returnType;
3005 fb.Offset offset_parameters;
3006 if (_name != null) {
3007 offset_name = fbBuilder.writeString(_name);
3008 }
3009 if (_documentationComment != null) {
3010 offset_documentationComment = _documentationComment.finish(fbBuilder);
3011 }
3012 if (!(_typeParameters == null || _typeParameters.isEmpty)) {
3013 offset_typeParameters = fbBuilder.writeList(_typeParameters.map((b) => b.f inish(fbBuilder)).toList());
3014 }
3015 if (_returnType != null) {
3016 offset_returnType = _returnType.finish(fbBuilder);
3017 }
3018 if (!(_parameters == null || _parameters.isEmpty)) {
3019 offset_parameters = fbBuilder.writeList(_parameters.map((b) => b.finish(fb Builder)).toList());
3020 }
3021 fbBuilder.startTable();
3022 if (offset_name != null) {
3023 fbBuilder.addOffset(0, offset_name);
3024 }
3025 if (_nameOffset != null && _nameOffset != 0) {
3026 fbBuilder.addInt32(1, _nameOffset);
3027 }
3028 if (offset_documentationComment != null) {
3029 fbBuilder.addOffset(2, offset_documentationComment);
3030 }
3031 if (offset_typeParameters != null) {
3032 fbBuilder.addOffset(3, offset_typeParameters);
3033 }
3034 if (offset_returnType != null) {
3035 fbBuilder.addOffset(4, offset_returnType);
3036 }
3037 if (offset_parameters != null) {
3038 fbBuilder.addOffset(5, offset_parameters);
3039 }
3040 return fbBuilder.endTable();
2584 } 3041 }
2585 } 3042 }
2586 3043
2587 UnlinkedTypedefBuilder encodeUnlinkedTypedef(base.BuilderContext builderContext, {String name, int nameOffset, UnlinkedDocumentationCommentBuilder documentation Comment, List<UnlinkedTypeParamBuilder> typeParameters, UnlinkedTypeRefBuilder r eturnType, List<UnlinkedParamBuilder> parameters}) { 3044 UnlinkedTypedefBuilder encodeUnlinkedTypedef(base.BuilderContext builderContext, {String name, int nameOffset, UnlinkedDocumentationCommentBuilder documentation Comment, List<UnlinkedTypeParamBuilder> typeParameters, UnlinkedTypeRefBuilder r eturnType, List<UnlinkedParamBuilder> parameters}) {
2588 UnlinkedTypedefBuilder builder = new UnlinkedTypedefBuilder(builderContext); 3045 UnlinkedTypedefBuilder builder = new UnlinkedTypedefBuilder(builderContext);
2589 builder.name = name; 3046 builder.name = name;
2590 builder.nameOffset = nameOffset; 3047 builder.nameOffset = nameOffset;
2591 builder.documentationComment = documentationComment; 3048 builder.documentationComment = documentationComment;
2592 builder.typeParameters = typeParameters; 3049 builder.typeParameters = typeParameters;
2593 builder.returnType = returnType; 3050 builder.returnType = returnType;
2594 builder.parameters = parameters; 3051 builder.parameters = parameters;
2595 return builder; 3052 return builder;
2596 } 3053 }
2597 3054
2598 /** 3055 /**
2599 * Unlinked summary information about a type parameter declaration. 3056 * Unlinked summary information about a typedef declaration.
2600 */ 3057 */
2601 class UnlinkedTypeParam extends base.SummaryClass { 3058 abstract class UnlinkedTypedef extends base.SummaryClass {
2602 String _name;
2603 int _nameOffset;
2604 UnlinkedTypeRef _bound;
2605 3059
2606 UnlinkedTypeParam.fromJson(Map json) 3060 /**
2607 : _name = json["name"], 3061 * Name of the typedef.
2608 _nameOffset = json["nameOffset"], 3062 */
2609 _bound = json["bound"] == null ? null : new UnlinkedTypeRef.fromJson(json[ "bound"]); 3063 String get name;
3064
3065 /**
3066 * Offset of the typedef name relative to the beginning of the file.
3067 */
3068 int get nameOffset;
3069
3070 /**
3071 * Documentation comment for the typedef, or `null` if there is no
3072 * documentation comment.
3073 */
3074 UnlinkedDocumentationComment get documentationComment;
3075
3076 /**
3077 * Type parameters of the typedef, if any.
3078 */
3079 List<UnlinkedTypeParam> get typeParameters;
3080
3081 /**
3082 * Return type of the typedef. Absent if the return type is `void`.
3083 */
3084 UnlinkedTypeRef get returnType;
3085
3086 /**
3087 * Parameters of the executable, if any.
3088 */
3089 List<UnlinkedParam> get parameters;
3090 }
3091
3092 class _UnlinkedTypedefReader extends fb.TableReader<_UnlinkedTypedefReader> impl ements UnlinkedTypedef {
3093 final fb.BufferPointer _bp;
3094
3095 const _UnlinkedTypedefReader([this._bp]);
3096
3097 @override
3098 _UnlinkedTypedefReader createReader(fb.BufferPointer bp) => new _UnlinkedTyped efReader(bp);
2610 3099
2611 @override 3100 @override
2612 Map<String, Object> toMap() => { 3101 Map<String, Object> toMap() => {
2613 "name": name, 3102 "name": name,
2614 "nameOffset": nameOffset, 3103 "nameOffset": nameOffset,
2615 "bound": bound, 3104 "documentationComment": documentationComment,
3105 "typeParameters": typeParameters,
3106 "returnType": returnType,
3107 "parameters": parameters,
2616 }; 3108 };
2617 3109
2618 /** 3110 @override
2619 * Name of the type parameter. 3111 String get name => const fb.StringReader().vTableGet(_bp, 0, '');
2620 */
2621 String get name => _name ?? '';
2622 3112
2623 /** 3113 @override
2624 * Offset of the type parameter name relative to the beginning of the file. 3114 int get nameOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
2625 */
2626 int get nameOffset => _nameOffset ?? 0;
2627 3115
2628 /** 3116 @override
2629 * Bound of the type parameter, if a bound is explicitly declared. Otherwise 3117 UnlinkedDocumentationComment get documentationComment => const _UnlinkedDocume ntationCommentReader().vTableGet(_bp, 2, null);
2630 * null. 3118
2631 */ 3119 @override
2632 UnlinkedTypeRef get bound => _bound; 3120 List<UnlinkedTypeParam> get typeParameters => const fb.ListReader<UnlinkedType Param>(const _UnlinkedTypeParamReader()).vTableGet(_bp, 3, const <UnlinkedTypePa ram>[]);
3121
3122 @override
3123 UnlinkedTypeRef get returnType => const _UnlinkedTypeRefReader().vTableGet(_bp , 4, null);
3124
3125 @override
3126 List<UnlinkedParam> get parameters => const fb.ListReader<UnlinkedParam>(const _UnlinkedParamReader()).vTableGet(_bp, 5, const <UnlinkedParam>[]);
2633 } 3127 }
2634 3128
2635 class UnlinkedTypeParamBuilder { 3129 class UnlinkedTypeParamBuilder {
2636 final Map _json = {}; 3130 bool _finished = false;
2637 3131
2638 bool _finished = false; 3132 String _name;
3133 int _nameOffset;
3134 UnlinkedTypeRefBuilder _bound;
2639 3135
2640 UnlinkedTypeParamBuilder(base.BuilderContext context); 3136 UnlinkedTypeParamBuilder(base.BuilderContext context);
2641 3137
2642 /** 3138 /**
2643 * Name of the type parameter. 3139 * Name of the type parameter.
2644 */ 3140 */
2645 void set name(String _value) { 3141 void set name(String _value) {
2646 assert(!_finished); 3142 assert(!_finished);
2647 assert(!_json.containsKey("name")); 3143 _name = _value;
2648 if (_value != null) {
2649 _json["name"] = _value;
2650 }
2651 } 3144 }
2652 3145
2653 /** 3146 /**
2654 * Offset of the type parameter name relative to the beginning of the file. 3147 * Offset of the type parameter name relative to the beginning of the file.
2655 */ 3148 */
2656 void set nameOffset(int _value) { 3149 void set nameOffset(int _value) {
2657 assert(!_finished); 3150 assert(!_finished);
2658 assert(!_json.containsKey("nameOffset")); 3151 _nameOffset = _value;
2659 if (_value != null) {
2660 _json["nameOffset"] = _value;
2661 }
2662 } 3152 }
2663 3153
2664 /** 3154 /**
2665 * Bound of the type parameter, if a bound is explicitly declared. Otherwise 3155 * Bound of the type parameter, if a bound is explicitly declared. Otherwise
2666 * null. 3156 * null.
2667 */ 3157 */
2668 void set bound(UnlinkedTypeRefBuilder _value) { 3158 void set bound(UnlinkedTypeRefBuilder _value) {
2669 assert(!_finished); 3159 assert(!_finished);
2670 assert(!_json.containsKey("bound")); 3160 _bound = _value;
2671 if (_value != null) {
2672 _json["bound"] = _value.finish();
2673 }
2674 } 3161 }
2675 3162
2676 Map finish() { 3163 fb.Offset finish(fb.Builder fbBuilder) {
2677 assert(!_finished); 3164 assert(!_finished);
2678 _finished = true; 3165 _finished = true;
2679 return _json; 3166 fb.Offset offset_name;
3167 fb.Offset offset_bound;
3168 if (_name != null) {
3169 offset_name = fbBuilder.writeString(_name);
3170 }
3171 if (_bound != null) {
3172 offset_bound = _bound.finish(fbBuilder);
3173 }
3174 fbBuilder.startTable();
3175 if (offset_name != null) {
3176 fbBuilder.addOffset(0, offset_name);
3177 }
3178 if (_nameOffset != null && _nameOffset != 0) {
3179 fbBuilder.addInt32(1, _nameOffset);
3180 }
3181 if (offset_bound != null) {
3182 fbBuilder.addOffset(2, offset_bound);
3183 }
3184 return fbBuilder.endTable();
2680 } 3185 }
2681 } 3186 }
2682 3187
2683 UnlinkedTypeParamBuilder encodeUnlinkedTypeParam(base.BuilderContext builderCont ext, {String name, int nameOffset, UnlinkedTypeRefBuilder bound}) { 3188 UnlinkedTypeParamBuilder encodeUnlinkedTypeParam(base.BuilderContext builderCont ext, {String name, int nameOffset, UnlinkedTypeRefBuilder bound}) {
2684 UnlinkedTypeParamBuilder builder = new UnlinkedTypeParamBuilder(builderContext ); 3189 UnlinkedTypeParamBuilder builder = new UnlinkedTypeParamBuilder(builderContext );
2685 builder.name = name; 3190 builder.name = name;
2686 builder.nameOffset = nameOffset; 3191 builder.nameOffset = nameOffset;
2687 builder.bound = bound; 3192 builder.bound = bound;
2688 return builder; 3193 return builder;
2689 } 3194 }
2690 3195
2691 /** 3196 /**
2692 * Unlinked summary information about a reference to a type. 3197 * Unlinked summary information about a type parameter declaration.
2693 */ 3198 */
2694 class UnlinkedTypeRef extends base.SummaryClass { 3199 abstract class UnlinkedTypeParam extends base.SummaryClass {
2695 int _reference;
2696 int _paramReference;
2697 List<UnlinkedTypeRef> _typeArguments;
2698 3200
2699 UnlinkedTypeRef.fromJson(Map json) 3201 /**
2700 : _reference = json["reference"], 3202 * Name of the type parameter.
2701 _paramReference = json["paramReference"], 3203 */
2702 _typeArguments = json["typeArguments"]?.map((x) => new UnlinkedTypeRef.fro mJson(x))?.toList(); 3204 String get name;
3205
3206 /**
3207 * Offset of the type parameter name relative to the beginning of the file.
3208 */
3209 int get nameOffset;
3210
3211 /**
3212 * Bound of the type parameter, if a bound is explicitly declared. Otherwise
3213 * null.
3214 */
3215 UnlinkedTypeRef get bound;
3216 }
3217
3218 class _UnlinkedTypeParamReader extends fb.TableReader<_UnlinkedTypeParamReader> implements UnlinkedTypeParam {
3219 final fb.BufferPointer _bp;
3220
3221 const _UnlinkedTypeParamReader([this._bp]);
3222
3223 @override
3224 _UnlinkedTypeParamReader createReader(fb.BufferPointer bp) => new _UnlinkedTyp eParamReader(bp);
2703 3225
2704 @override 3226 @override
2705 Map<String, Object> toMap() => { 3227 Map<String, Object> toMap() => {
2706 "reference": reference, 3228 "name": name,
2707 "paramReference": paramReference, 3229 "nameOffset": nameOffset,
2708 "typeArguments": typeArguments, 3230 "bound": bound,
2709 }; 3231 };
2710 3232
3233 @override
3234 String get name => const fb.StringReader().vTableGet(_bp, 0, '');
3235
3236 @override
3237 int get nameOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
3238
3239 @override
3240 UnlinkedTypeRef get bound => const _UnlinkedTypeRefReader().vTableGet(_bp, 2, null);
3241 }
3242
3243 class UnlinkedTypeRefBuilder {
3244 bool _finished = false;
3245
3246 int _reference;
3247 int _paramReference;
3248 List<UnlinkedTypeRefBuilder> _typeArguments;
3249
3250 UnlinkedTypeRefBuilder(base.BuilderContext context);
3251
2711 /** 3252 /**
2712 * Index into [UnlinkedUnit.references] for the type being referred to, or 3253 * Index into [UnlinkedUnit.references] for the type being referred to, or
2713 * zero if this is a reference to a type parameter. 3254 * zero if this is a reference to a type parameter.
2714 * 3255 *
2715 * Note that since zero is also a valid index into 3256 * Note that since zero is also a valid index into
2716 * [UnlinkedUnit.references], we cannot distinguish between references to 3257 * [UnlinkedUnit.references], we cannot distinguish between references to
2717 * type parameters and references to types by checking [reference] against 3258 * type parameters and references to types by checking [reference] against
2718 * zero. To distinguish between references to type parameters and references 3259 * zero. To distinguish between references to type parameters and references
2719 * to types, check whether [paramReference] is zero. 3260 * to types, check whether [paramReference] is zero.
2720 */ 3261 */
2721 int get reference => _reference ?? 0; 3262 void set reference(int _value) {
3263 assert(!_finished);
3264 _reference = _value;
3265 }
2722 3266
2723 /** 3267 /**
2724 * If this is a reference to a type parameter, one-based index into the list 3268 * If this is a reference to a type parameter, one-based index into the list
2725 * of [UnlinkedTypeParam]s currently in effect. Indexing is done using De 3269 * of [UnlinkedTypeParam]s currently in effect. Indexing is done using De
2726 * Bruijn index conventions; that is, innermost parameters come first, and 3270 * Bruijn index conventions; that is, innermost parameters come first, and
2727 * if a class or method has multiple parameters, they are indexed from right 3271 * if a class or method has multiple parameters, they are indexed from right
2728 * to left. So for instance, if the enclosing declaration is 3272 * to left. So for instance, if the enclosing declaration is
2729 * 3273 *
2730 * class C<T,U> { 3274 * class C<T,U> {
2731 * m<V,W> { 3275 * m<V,W> {
2732 * ... 3276 * ...
2733 * } 3277 * }
2734 * } 3278 * }
2735 * 3279 *
2736 * Then [paramReference] values of 1, 2, 3, and 4 represent W, V, U, and T, 3280 * Then [paramReference] values of 1, 2, 3, and 4 represent W, V, U, and T,
2737 * respectively. 3281 * respectively.
2738 * 3282 *
2739 * If the type being referred to is not a type parameter, [paramReference] is 3283 * If the type being referred to is not a type parameter, [paramReference] is
2740 * zero. 3284 * zero.
2741 */ 3285 */
2742 int get paramReference => _paramReference ?? 0; 3286 void set paramReference(int _value) {
3287 assert(!_finished);
3288 _paramReference = _value;
3289 }
2743 3290
2744 /** 3291 /**
2745 * If this is an instantiation of a generic type, the type arguments used to 3292 * If this is an instantiation of a generic type, the type arguments used to
2746 * instantiate it. Trailing type arguments of type `dynamic` are omitted. 3293 * instantiate it. Trailing type arguments of type `dynamic` are omitted.
2747 */ 3294 */
2748 List<UnlinkedTypeRef> get typeArguments => _typeArguments ?? const <UnlinkedTy peRef>[]; 3295 void set typeArguments(List<UnlinkedTypeRefBuilder> _value) {
3296 assert(!_finished);
3297 _typeArguments = _value;
3298 }
3299
3300 fb.Offset finish(fb.Builder fbBuilder) {
3301 assert(!_finished);
3302 _finished = true;
3303 fb.Offset offset_typeArguments;
3304 if (!(_typeArguments == null || _typeArguments.isEmpty)) {
3305 offset_typeArguments = fbBuilder.writeList(_typeArguments.map((b) => b.fin ish(fbBuilder)).toList());
3306 }
3307 fbBuilder.startTable();
3308 if (_reference != null && _reference != 0) {
3309 fbBuilder.addInt32(0, _reference);
3310 }
3311 if (_paramReference != null && _paramReference != 0) {
3312 fbBuilder.addInt32(1, _paramReference);
3313 }
3314 if (offset_typeArguments != null) {
3315 fbBuilder.addOffset(2, offset_typeArguments);
3316 }
3317 return fbBuilder.endTable();
3318 }
2749 } 3319 }
2750 3320
2751 class UnlinkedTypeRefBuilder { 3321 UnlinkedTypeRefBuilder encodeUnlinkedTypeRef(base.BuilderContext builderContext, {int reference, int paramReference, List<UnlinkedTypeRefBuilder> typeArguments} ) {
2752 final Map _json = {}; 3322 UnlinkedTypeRefBuilder builder = new UnlinkedTypeRefBuilder(builderContext);
3323 builder.reference = reference;
3324 builder.paramReference = paramReference;
3325 builder.typeArguments = typeArguments;
3326 return builder;
3327 }
2753 3328
2754 bool _finished = false; 3329 /**
2755 3330 * Unlinked summary information about a reference to a type.
2756 UnlinkedTypeRefBuilder(base.BuilderContext context); 3331 */
3332 abstract class UnlinkedTypeRef extends base.SummaryClass {
2757 3333
2758 /** 3334 /**
2759 * Index into [UnlinkedUnit.references] for the type being referred to, or 3335 * Index into [UnlinkedUnit.references] for the type being referred to, or
2760 * zero if this is a reference to a type parameter. 3336 * zero if this is a reference to a type parameter.
2761 * 3337 *
2762 * Note that since zero is also a valid index into 3338 * Note that since zero is also a valid index into
2763 * [UnlinkedUnit.references], we cannot distinguish between references to 3339 * [UnlinkedUnit.references], we cannot distinguish between references to
2764 * type parameters and references to types by checking [reference] against 3340 * type parameters and references to types by checking [reference] against
2765 * zero. To distinguish between references to type parameters and references 3341 * zero. To distinguish between references to type parameters and references
2766 * to types, check whether [paramReference] is zero. 3342 * to types, check whether [paramReference] is zero.
2767 */ 3343 */
2768 void set reference(int _value) { 3344 int get reference;
2769 assert(!_finished);
2770 assert(!_json.containsKey("reference"));
2771 if (_value != null) {
2772 _json["reference"] = _value;
2773 }
2774 }
2775 3345
2776 /** 3346 /**
2777 * If this is a reference to a type parameter, one-based index into the list 3347 * If this is a reference to a type parameter, one-based index into the list
2778 * of [UnlinkedTypeParam]s currently in effect. Indexing is done using De 3348 * of [UnlinkedTypeParam]s currently in effect. Indexing is done using De
2779 * Bruijn index conventions; that is, innermost parameters come first, and 3349 * Bruijn index conventions; that is, innermost parameters come first, and
2780 * if a class or method has multiple parameters, they are indexed from right 3350 * if a class or method has multiple parameters, they are indexed from right
2781 * to left. So for instance, if the enclosing declaration is 3351 * to left. So for instance, if the enclosing declaration is
2782 * 3352 *
2783 * class C<T,U> { 3353 * class C<T,U> {
2784 * m<V,W> { 3354 * m<V,W> {
2785 * ... 3355 * ...
2786 * } 3356 * }
2787 * } 3357 * }
2788 * 3358 *
2789 * Then [paramReference] values of 1, 2, 3, and 4 represent W, V, U, and T, 3359 * Then [paramReference] values of 1, 2, 3, and 4 represent W, V, U, and T,
2790 * respectively. 3360 * respectively.
2791 * 3361 *
2792 * If the type being referred to is not a type parameter, [paramReference] is 3362 * If the type being referred to is not a type parameter, [paramReference] is
2793 * zero. 3363 * zero.
2794 */ 3364 */
2795 void set paramReference(int _value) { 3365 int get paramReference;
2796 assert(!_finished);
2797 assert(!_json.containsKey("paramReference"));
2798 if (_value != null) {
2799 _json["paramReference"] = _value;
2800 }
2801 }
2802 3366
2803 /** 3367 /**
2804 * If this is an instantiation of a generic type, the type arguments used to 3368 * If this is an instantiation of a generic type, the type arguments used to
2805 * instantiate it. Trailing type arguments of type `dynamic` are omitted. 3369 * instantiate it. Trailing type arguments of type `dynamic` are omitted.
2806 */ 3370 */
2807 void set typeArguments(List<UnlinkedTypeRefBuilder> _value) { 3371 List<UnlinkedTypeRef> get typeArguments;
2808 assert(!_finished);
2809 assert(!_json.containsKey("typeArguments"));
2810 if (!(_value == null || _value.isEmpty)) {
2811 _json["typeArguments"] = _value.map((b) => b.finish()).toList();
2812 }
2813 }
2814
2815 Map finish() {
2816 assert(!_finished);
2817 _finished = true;
2818 return _json;
2819 }
2820 } 3372 }
2821 3373
2822 UnlinkedTypeRefBuilder encodeUnlinkedTypeRef(base.BuilderContext builderContext, {int reference, int paramReference, List<UnlinkedTypeRefBuilder> typeArguments} ) { 3374 class _UnlinkedTypeRefReader extends fb.TableReader<_UnlinkedTypeRefReader> impl ements UnlinkedTypeRef {
2823 UnlinkedTypeRefBuilder builder = new UnlinkedTypeRefBuilder(builderContext); 3375 final fb.BufferPointer _bp;
2824 builder.reference = reference; 3376
2825 builder.paramReference = paramReference; 3377 const _UnlinkedTypeRefReader([this._bp]);
2826 builder.typeArguments = typeArguments; 3378
2827 return builder; 3379 @override
3380 _UnlinkedTypeRefReader createReader(fb.BufferPointer bp) => new _UnlinkedTypeR efReader(bp);
3381
3382 @override
3383 Map<String, Object> toMap() => {
3384 "reference": reference,
3385 "paramReference": paramReference,
3386 "typeArguments": typeArguments,
3387 };
3388
3389 @override
3390 int get reference => const fb.Int32Reader().vTableGet(_bp, 0, 0);
3391
3392 @override
3393 int get paramReference => const fb.Int32Reader().vTableGet(_bp, 1, 0);
3394
3395 @override
3396 List<UnlinkedTypeRef> get typeArguments => const fb.ListReader<UnlinkedTypeRef >(const _UnlinkedTypeRefReader()).vTableGet(_bp, 2, const <UnlinkedTypeRef>[]);
2828 } 3397 }
2829 3398
2830 /** 3399 class UnlinkedUnitBuilder {
2831 * Unlinked summary information about a compilation unit ("part file"). 3400 bool _finished = false;
2832 */ 3401
2833 class UnlinkedUnit extends base.SummaryClass {
2834 String _libraryName; 3402 String _libraryName;
2835 int _libraryNameOffset; 3403 int _libraryNameOffset;
2836 int _libraryNameLength; 3404 int _libraryNameLength;
2837 UnlinkedDocumentationComment _libraryDocumentationComment; 3405 UnlinkedDocumentationCommentBuilder _libraryDocumentationComment;
2838 UnlinkedPublicNamespace _publicNamespace; 3406 UnlinkedPublicNamespaceBuilder _publicNamespace;
2839 List<UnlinkedReference> _references; 3407 List<UnlinkedReferenceBuilder> _references;
2840 List<UnlinkedClass> _classes; 3408 List<UnlinkedClassBuilder> _classes;
2841 List<UnlinkedEnum> _enums; 3409 List<UnlinkedEnumBuilder> _enums;
2842 List<UnlinkedExecutable> _executables; 3410 List<UnlinkedExecutableBuilder> _executables;
2843 List<UnlinkedExportNonPublic> _exports; 3411 List<UnlinkedExportNonPublicBuilder> _exports;
2844 List<UnlinkedImport> _imports; 3412 List<UnlinkedImportBuilder> _imports;
2845 List<UnlinkedPart> _parts; 3413 List<UnlinkedPartBuilder> _parts;
2846 List<UnlinkedTypedef> _typedefs; 3414 List<UnlinkedTypedefBuilder> _typedefs;
2847 List<UnlinkedVariable> _variables; 3415 List<UnlinkedVariableBuilder> _variables;
2848
2849 UnlinkedUnit.fromJson(Map json)
2850 : _libraryName = json["libraryName"],
2851 _libraryNameOffset = json["libraryNameOffset"],
2852 _libraryNameLength = json["libraryNameLength"],
2853 _libraryDocumentationComment = json["libraryDocumentationComment"] == null ? null : new UnlinkedDocumentationComment.fromJson(json["libraryDocumentationCo mment"]),
2854 _publicNamespace = json["publicNamespace"] == null ? null : new UnlinkedPu blicNamespace.fromJson(json["publicNamespace"]),
2855 _references = json["references"]?.map((x) => new UnlinkedReference.fromJso n(x))?.toList(),
2856 _classes = json["classes"]?.map((x) => new UnlinkedClass.fromJson(x))?.toL ist(),
2857 _enums = json["enums"]?.map((x) => new UnlinkedEnum.fromJson(x))?.toList() ,
2858 _executables = json["executables"]?.map((x) => new UnlinkedExecutable.from Json(x))?.toList(),
2859 _exports = json["exports"]?.map((x) => new UnlinkedExportNonPublic.fromJso n(x))?.toList(),
2860 _imports = json["imports"]?.map((x) => new UnlinkedImport.fromJson(x))?.to List(),
2861 _parts = json["parts"]?.map((x) => new UnlinkedPart.fromJson(x))?.toList() ,
2862 _typedefs = json["typedefs"]?.map((x) => new UnlinkedTypedef.fromJson(x))? .toList(),
2863 _variables = json["variables"]?.map((x) => new UnlinkedVariable.fromJson(x ))?.toList();
2864
2865 @override
2866 Map<String, Object> toMap() => {
2867 "libraryName": libraryName,
2868 "libraryNameOffset": libraryNameOffset,
2869 "libraryNameLength": libraryNameLength,
2870 "libraryDocumentationComment": libraryDocumentationComment,
2871 "publicNamespace": publicNamespace,
2872 "references": references,
2873 "classes": classes,
2874 "enums": enums,
2875 "executables": executables,
2876 "exports": exports,
2877 "imports": imports,
2878 "parts": parts,
2879 "typedefs": typedefs,
2880 "variables": variables,
2881 };
2882
2883 UnlinkedUnit.fromBuffer(List<int> buffer) : this.fromJson(JSON.decode(UTF8.dec ode(buffer)));
2884
2885 /**
2886 * Name of the library (from a "library" declaration, if present).
2887 */
2888 String get libraryName => _libraryName ?? '';
2889
2890 /**
2891 * Offset of the library name relative to the beginning of the file (or 0 if
2892 * the library has no name).
2893 */
2894 int get libraryNameOffset => _libraryNameOffset ?? 0;
2895
2896 /**
2897 * Length of the library name as it appears in the source code (or 0 if the
2898 * library has no name).
2899 */
2900 int get libraryNameLength => _libraryNameLength ?? 0;
2901
2902 /**
2903 * Documentation comment for the library, or `null` if there is no
2904 * documentation comment.
2905 */
2906 UnlinkedDocumentationComment get libraryDocumentationComment => _libraryDocume ntationComment;
2907
2908 /**
2909 * Unlinked public namespace of this compilation unit.
2910 */
2911 UnlinkedPublicNamespace get publicNamespace => _publicNamespace;
2912
2913 /**
2914 * Top level and prefixed names referred to by this compilation unit. The
2915 * zeroth element of this array is always populated and always represents a
2916 * reference to the pseudo-type "dynamic".
2917 */
2918 List<UnlinkedReference> get references => _references ?? const <UnlinkedRefere nce>[];
2919
2920 /**
2921 * Classes declared in the compilation unit.
2922 */
2923 List<UnlinkedClass> get classes => _classes ?? const <UnlinkedClass>[];
2924
2925 /**
2926 * Enums declared in the compilation unit.
2927 */
2928 List<UnlinkedEnum> get enums => _enums ?? const <UnlinkedEnum>[];
2929
2930 /**
2931 * Top level executable objects (functions, getters, and setters) declared in
2932 * the compilation unit.
2933 */
2934 List<UnlinkedExecutable> get executables => _executables ?? const <UnlinkedExe cutable>[];
2935
2936 /**
2937 * Export declarations in the compilation unit.
2938 */
2939 List<UnlinkedExportNonPublic> get exports => _exports ?? const <UnlinkedExport NonPublic>[];
2940
2941 /**
2942 * Import declarations in the compilation unit.
2943 */
2944 List<UnlinkedImport> get imports => _imports ?? const <UnlinkedImport>[];
2945
2946 /**
2947 * Part declarations in the compilation unit.
2948 */
2949 List<UnlinkedPart> get parts => _parts ?? const <UnlinkedPart>[];
2950
2951 /**
2952 * Typedefs declared in the compilation unit.
2953 */
2954 List<UnlinkedTypedef> get typedefs => _typedefs ?? const <UnlinkedTypedef>[];
2955
2956 /**
2957 * Top level variables declared in the compilation unit.
2958 */
2959 List<UnlinkedVariable> get variables => _variables ?? const <UnlinkedVariable> [];
2960 }
2961
2962 class UnlinkedUnitBuilder {
2963 final Map _json = {};
2964
2965 bool _finished = false;
2966 3416
2967 UnlinkedUnitBuilder(base.BuilderContext context); 3417 UnlinkedUnitBuilder(base.BuilderContext context);
2968 3418
2969 /** 3419 /**
2970 * Name of the library (from a "library" declaration, if present). 3420 * Name of the library (from a "library" declaration, if present).
2971 */ 3421 */
2972 void set libraryName(String _value) { 3422 void set libraryName(String _value) {
2973 assert(!_finished); 3423 assert(!_finished);
2974 assert(!_json.containsKey("libraryName")); 3424 _libraryName = _value;
2975 if (_value != null) {
2976 _json["libraryName"] = _value;
2977 }
2978 } 3425 }
2979 3426
2980 /** 3427 /**
2981 * Offset of the library name relative to the beginning of the file (or 0 if 3428 * Offset of the library name relative to the beginning of the file (or 0 if
2982 * the library has no name). 3429 * the library has no name).
2983 */ 3430 */
2984 void set libraryNameOffset(int _value) { 3431 void set libraryNameOffset(int _value) {
2985 assert(!_finished); 3432 assert(!_finished);
2986 assert(!_json.containsKey("libraryNameOffset")); 3433 _libraryNameOffset = _value;
2987 if (_value != null) {
2988 _json["libraryNameOffset"] = _value;
2989 }
2990 } 3434 }
2991 3435
2992 /** 3436 /**
2993 * Length of the library name as it appears in the source code (or 0 if the 3437 * Length of the library name as it appears in the source code (or 0 if the
2994 * library has no name). 3438 * library has no name).
2995 */ 3439 */
2996 void set libraryNameLength(int _value) { 3440 void set libraryNameLength(int _value) {
2997 assert(!_finished); 3441 assert(!_finished);
2998 assert(!_json.containsKey("libraryNameLength")); 3442 _libraryNameLength = _value;
2999 if (_value != null) {
3000 _json["libraryNameLength"] = _value;
3001 }
3002 } 3443 }
3003 3444
3004 /** 3445 /**
3005 * Documentation comment for the library, or `null` if there is no 3446 * Documentation comment for the library, or `null` if there is no
3006 * documentation comment. 3447 * documentation comment.
3007 */ 3448 */
3008 void set libraryDocumentationComment(UnlinkedDocumentationCommentBuilder _valu e) { 3449 void set libraryDocumentationComment(UnlinkedDocumentationCommentBuilder _valu e) {
3009 assert(!_finished); 3450 assert(!_finished);
3010 assert(!_json.containsKey("libraryDocumentationComment")); 3451 _libraryDocumentationComment = _value;
3011 if (_value != null) {
3012 _json["libraryDocumentationComment"] = _value.finish();
3013 }
3014 } 3452 }
3015 3453
3016 /** 3454 /**
3017 * Unlinked public namespace of this compilation unit. 3455 * Unlinked public namespace of this compilation unit.
3018 */ 3456 */
3019 void set publicNamespace(UnlinkedPublicNamespaceBuilder _value) { 3457 void set publicNamespace(UnlinkedPublicNamespaceBuilder _value) {
3020 assert(!_finished); 3458 assert(!_finished);
3021 assert(!_json.containsKey("publicNamespace")); 3459 _publicNamespace = _value;
3022 if (_value != null) {
3023 _json["publicNamespace"] = _value.finish();
3024 }
3025 } 3460 }
3026 3461
3027 /** 3462 /**
3028 * Top level and prefixed names referred to by this compilation unit. The 3463 * Top level and prefixed names referred to by this compilation unit. The
3029 * zeroth element of this array is always populated and always represents a 3464 * zeroth element of this array is always populated and always represents a
3030 * reference to the pseudo-type "dynamic". 3465 * reference to the pseudo-type "dynamic".
3031 */ 3466 */
3032 void set references(List<UnlinkedReferenceBuilder> _value) { 3467 void set references(List<UnlinkedReferenceBuilder> _value) {
3033 assert(!_finished); 3468 assert(!_finished);
3034 assert(!_json.containsKey("references")); 3469 _references = _value;
3035 if (!(_value == null || _value.isEmpty)) {
3036 _json["references"] = _value.map((b) => b.finish()).toList();
3037 }
3038 } 3470 }
3039 3471
3040 /** 3472 /**
3041 * Classes declared in the compilation unit. 3473 * Classes declared in the compilation unit.
3042 */ 3474 */
3043 void set classes(List<UnlinkedClassBuilder> _value) { 3475 void set classes(List<UnlinkedClassBuilder> _value) {
3044 assert(!_finished); 3476 assert(!_finished);
3045 assert(!_json.containsKey("classes")); 3477 _classes = _value;
3046 if (!(_value == null || _value.isEmpty)) {
3047 _json["classes"] = _value.map((b) => b.finish()).toList();
3048 }
3049 } 3478 }
3050 3479
3051 /** 3480 /**
3052 * Enums declared in the compilation unit. 3481 * Enums declared in the compilation unit.
3053 */ 3482 */
3054 void set enums(List<UnlinkedEnumBuilder> _value) { 3483 void set enums(List<UnlinkedEnumBuilder> _value) {
3055 assert(!_finished); 3484 assert(!_finished);
3056 assert(!_json.containsKey("enums")); 3485 _enums = _value;
3057 if (!(_value == null || _value.isEmpty)) {
3058 _json["enums"] = _value.map((b) => b.finish()).toList();
3059 }
3060 } 3486 }
3061 3487
3062 /** 3488 /**
3063 * Top level executable objects (functions, getters, and setters) declared in 3489 * Top level executable objects (functions, getters, and setters) declared in
3064 * the compilation unit. 3490 * the compilation unit.
3065 */ 3491 */
3066 void set executables(List<UnlinkedExecutableBuilder> _value) { 3492 void set executables(List<UnlinkedExecutableBuilder> _value) {
3067 assert(!_finished); 3493 assert(!_finished);
3068 assert(!_json.containsKey("executables")); 3494 _executables = _value;
3069 if (!(_value == null || _value.isEmpty)) {
3070 _json["executables"] = _value.map((b) => b.finish()).toList();
3071 }
3072 } 3495 }
3073 3496
3074 /** 3497 /**
3075 * Export declarations in the compilation unit. 3498 * Export declarations in the compilation unit.
3076 */ 3499 */
3077 void set exports(List<UnlinkedExportNonPublicBuilder> _value) { 3500 void set exports(List<UnlinkedExportNonPublicBuilder> _value) {
3078 assert(!_finished); 3501 assert(!_finished);
3079 assert(!_json.containsKey("exports")); 3502 _exports = _value;
3080 if (!(_value == null || _value.isEmpty)) {
3081 _json["exports"] = _value.map((b) => b.finish()).toList();
3082 }
3083 } 3503 }
3084 3504
3085 /** 3505 /**
3086 * Import declarations in the compilation unit. 3506 * Import declarations in the compilation unit.
3087 */ 3507 */
3088 void set imports(List<UnlinkedImportBuilder> _value) { 3508 void set imports(List<UnlinkedImportBuilder> _value) {
3089 assert(!_finished); 3509 assert(!_finished);
3090 assert(!_json.containsKey("imports")); 3510 _imports = _value;
3091 if (!(_value == null || _value.isEmpty)) {
3092 _json["imports"] = _value.map((b) => b.finish()).toList();
3093 }
3094 } 3511 }
3095 3512
3096 /** 3513 /**
3097 * Part declarations in the compilation unit. 3514 * Part declarations in the compilation unit.
3098 */ 3515 */
3099 void set parts(List<UnlinkedPartBuilder> _value) { 3516 void set parts(List<UnlinkedPartBuilder> _value) {
3100 assert(!_finished); 3517 assert(!_finished);
3101 assert(!_json.containsKey("parts")); 3518 _parts = _value;
3102 if (!(_value == null || _value.isEmpty)) {
3103 _json["parts"] = _value.map((b) => b.finish()).toList();
3104 }
3105 } 3519 }
3106 3520
3107 /** 3521 /**
3108 * Typedefs declared in the compilation unit. 3522 * Typedefs declared in the compilation unit.
3109 */ 3523 */
3110 void set typedefs(List<UnlinkedTypedefBuilder> _value) { 3524 void set typedefs(List<UnlinkedTypedefBuilder> _value) {
3111 assert(!_finished); 3525 assert(!_finished);
3112 assert(!_json.containsKey("typedefs")); 3526 _typedefs = _value;
3113 if (!(_value == null || _value.isEmpty)) {
3114 _json["typedefs"] = _value.map((b) => b.finish()).toList();
3115 }
3116 } 3527 }
3117 3528
3118 /** 3529 /**
3119 * Top level variables declared in the compilation unit. 3530 * Top level variables declared in the compilation unit.
3120 */ 3531 */
3121 void set variables(List<UnlinkedVariableBuilder> _value) { 3532 void set variables(List<UnlinkedVariableBuilder> _value) {
3122 assert(!_finished); 3533 assert(!_finished);
3123 assert(!_json.containsKey("variables")); 3534 _variables = _value;
3124 if (!(_value == null || _value.isEmpty)) {
3125 _json["variables"] = _value.map((b) => b.finish()).toList();
3126 }
3127 } 3535 }
3128 3536
3129 List<int> toBuffer() => UTF8.encode(JSON.encode(finish())); 3537 List<int> toBuffer() {
3538 fb.Builder fbBuilder = new fb.Builder();
3539 return fbBuilder.finish(finish(fbBuilder));
3540 }
3130 3541
3131 Map finish() { 3542 fb.Offset finish(fb.Builder fbBuilder) {
3132 assert(!_finished); 3543 assert(!_finished);
3133 _finished = true; 3544 _finished = true;
3134 return _json; 3545 fb.Offset offset_libraryName;
3546 fb.Offset offset_libraryDocumentationComment;
3547 fb.Offset offset_publicNamespace;
3548 fb.Offset offset_references;
3549 fb.Offset offset_classes;
3550 fb.Offset offset_enums;
3551 fb.Offset offset_executables;
3552 fb.Offset offset_exports;
3553 fb.Offset offset_imports;
3554 fb.Offset offset_parts;
3555 fb.Offset offset_typedefs;
3556 fb.Offset offset_variables;
3557 if (_libraryName != null) {
3558 offset_libraryName = fbBuilder.writeString(_libraryName);
3559 }
3560 if (_libraryDocumentationComment != null) {
3561 offset_libraryDocumentationComment = _libraryDocumentationComment.finish(f bBuilder);
3562 }
3563 if (_publicNamespace != null) {
3564 offset_publicNamespace = _publicNamespace.finish(fbBuilder);
3565 }
3566 if (!(_references == null || _references.isEmpty)) {
3567 offset_references = fbBuilder.writeList(_references.map((b) => b.finish(fb Builder)).toList());
3568 }
3569 if (!(_classes == null || _classes.isEmpty)) {
3570 offset_classes = fbBuilder.writeList(_classes.map((b) => b.finish(fbBuilde r)).toList());
3571 }
3572 if (!(_enums == null || _enums.isEmpty)) {
3573 offset_enums = fbBuilder.writeList(_enums.map((b) => b.finish(fbBuilder)). toList());
3574 }
3575 if (!(_executables == null || _executables.isEmpty)) {
3576 offset_executables = fbBuilder.writeList(_executables.map((b) => b.finish( fbBuilder)).toList());
3577 }
3578 if (!(_exports == null || _exports.isEmpty)) {
3579 offset_exports = fbBuilder.writeList(_exports.map((b) => b.finish(fbBuilde r)).toList());
3580 }
3581 if (!(_imports == null || _imports.isEmpty)) {
3582 offset_imports = fbBuilder.writeList(_imports.map((b) => b.finish(fbBuilde r)).toList());
3583 }
3584 if (!(_parts == null || _parts.isEmpty)) {
3585 offset_parts = fbBuilder.writeList(_parts.map((b) => b.finish(fbBuilder)). toList());
3586 }
3587 if (!(_typedefs == null || _typedefs.isEmpty)) {
3588 offset_typedefs = fbBuilder.writeList(_typedefs.map((b) => b.finish(fbBuil der)).toList());
3589 }
3590 if (!(_variables == null || _variables.isEmpty)) {
3591 offset_variables = fbBuilder.writeList(_variables.map((b) => b.finish(fbBu ilder)).toList());
3592 }
3593 fbBuilder.startTable();
3594 if (offset_libraryName != null) {
3595 fbBuilder.addOffset(0, offset_libraryName);
3596 }
3597 if (_libraryNameOffset != null && _libraryNameOffset != 0) {
3598 fbBuilder.addInt32(1, _libraryNameOffset);
3599 }
3600 if (_libraryNameLength != null && _libraryNameLength != 0) {
3601 fbBuilder.addInt32(2, _libraryNameLength);
3602 }
3603 if (offset_libraryDocumentationComment != null) {
3604 fbBuilder.addOffset(3, offset_libraryDocumentationComment);
3605 }
3606 if (offset_publicNamespace != null) {
3607 fbBuilder.addOffset(4, offset_publicNamespace);
3608 }
3609 if (offset_references != null) {
3610 fbBuilder.addOffset(5, offset_references);
3611 }
3612 if (offset_classes != null) {
3613 fbBuilder.addOffset(6, offset_classes);
3614 }
3615 if (offset_enums != null) {
3616 fbBuilder.addOffset(7, offset_enums);
3617 }
3618 if (offset_executables != null) {
3619 fbBuilder.addOffset(8, offset_executables);
3620 }
3621 if (offset_exports != null) {
3622 fbBuilder.addOffset(9, offset_exports);
3623 }
3624 if (offset_imports != null) {
3625 fbBuilder.addOffset(10, offset_imports);
3626 }
3627 if (offset_parts != null) {
3628 fbBuilder.addOffset(11, offset_parts);
3629 }
3630 if (offset_typedefs != null) {
3631 fbBuilder.addOffset(12, offset_typedefs);
3632 }
3633 if (offset_variables != null) {
3634 fbBuilder.addOffset(13, offset_variables);
3635 }
3636 return fbBuilder.endTable();
3135 } 3637 }
3136 } 3638 }
3137 3639
3138 UnlinkedUnitBuilder encodeUnlinkedUnit(base.BuilderContext builderContext, {Stri ng libraryName, int libraryNameOffset, int libraryNameLength, UnlinkedDocumentat ionCommentBuilder libraryDocumentationComment, UnlinkedPublicNamespaceBuilder pu blicNamespace, List<UnlinkedReferenceBuilder> references, List<UnlinkedClassBuil der> classes, List<UnlinkedEnumBuilder> enums, List<UnlinkedExecutableBuilder> e xecutables, List<UnlinkedExportNonPublicBuilder> exports, List<UnlinkedImportBui lder> imports, List<UnlinkedPartBuilder> parts, List<UnlinkedTypedefBuilder> typ edefs, List<UnlinkedVariableBuilder> variables}) { 3640 UnlinkedUnitBuilder encodeUnlinkedUnit(base.BuilderContext builderContext, {Stri ng libraryName, int libraryNameOffset, int libraryNameLength, UnlinkedDocumentat ionCommentBuilder libraryDocumentationComment, UnlinkedPublicNamespaceBuilder pu blicNamespace, List<UnlinkedReferenceBuilder> references, List<UnlinkedClassBuil der> classes, List<UnlinkedEnumBuilder> enums, List<UnlinkedExecutableBuilder> e xecutables, List<UnlinkedExportNonPublicBuilder> exports, List<UnlinkedImportBui lder> imports, List<UnlinkedPartBuilder> parts, List<UnlinkedTypedefBuilder> typ edefs, List<UnlinkedVariableBuilder> variables}) {
3139 UnlinkedUnitBuilder builder = new UnlinkedUnitBuilder(builderContext); 3641 UnlinkedUnitBuilder builder = new UnlinkedUnitBuilder(builderContext);
3140 builder.libraryName = libraryName; 3642 builder.libraryName = libraryName;
3141 builder.libraryNameOffset = libraryNameOffset; 3643 builder.libraryNameOffset = libraryNameOffset;
3142 builder.libraryNameLength = libraryNameLength; 3644 builder.libraryNameLength = libraryNameLength;
3143 builder.libraryDocumentationComment = libraryDocumentationComment; 3645 builder.libraryDocumentationComment = libraryDocumentationComment;
3144 builder.publicNamespace = publicNamespace; 3646 builder.publicNamespace = publicNamespace;
3145 builder.references = references; 3647 builder.references = references;
3146 builder.classes = classes; 3648 builder.classes = classes;
3147 builder.enums = enums; 3649 builder.enums = enums;
3148 builder.executables = executables; 3650 builder.executables = executables;
3149 builder.exports = exports; 3651 builder.exports = exports;
3150 builder.imports = imports; 3652 builder.imports = imports;
3151 builder.parts = parts; 3653 builder.parts = parts;
3152 builder.typedefs = typedefs; 3654 builder.typedefs = typedefs;
3153 builder.variables = variables; 3655 builder.variables = variables;
3154 return builder; 3656 return builder;
3155 } 3657 }
3156 3658
3157 /** 3659 /**
3158 * Unlinked summary information about a top level variable, local variable, or 3660 * Unlinked summary information about a compilation unit ("part file").
3159 * a field.
3160 */ 3661 */
3161 class UnlinkedVariable extends base.SummaryClass { 3662 abstract class UnlinkedUnit extends base.SummaryClass {
3663 factory UnlinkedUnit.fromBuffer(List<int> buffer) {
3664 fb.BufferPointer rootRef = new fb.BufferPointer.fromBytes(buffer);
3665 return const _UnlinkedUnitReader().read(rootRef);
3666 }
3667
3668 /**
3669 * Name of the library (from a "library" declaration, if present).
3670 */
3671 String get libraryName;
3672
3673 /**
3674 * Offset of the library name relative to the beginning of the file (or 0 if
3675 * the library has no name).
3676 */
3677 int get libraryNameOffset;
3678
3679 /**
3680 * Length of the library name as it appears in the source code (or 0 if the
3681 * library has no name).
3682 */
3683 int get libraryNameLength;
3684
3685 /**
3686 * Documentation comment for the library, or `null` if there is no
3687 * documentation comment.
3688 */
3689 UnlinkedDocumentationComment get libraryDocumentationComment;
3690
3691 /**
3692 * Unlinked public namespace of this compilation unit.
3693 */
3694 UnlinkedPublicNamespace get publicNamespace;
3695
3696 /**
3697 * Top level and prefixed names referred to by this compilation unit. The
3698 * zeroth element of this array is always populated and always represents a
3699 * reference to the pseudo-type "dynamic".
3700 */
3701 List<UnlinkedReference> get references;
3702
3703 /**
3704 * Classes declared in the compilation unit.
3705 */
3706 List<UnlinkedClass> get classes;
3707
3708 /**
3709 * Enums declared in the compilation unit.
3710 */
3711 List<UnlinkedEnum> get enums;
3712
3713 /**
3714 * Top level executable objects (functions, getters, and setters) declared in
3715 * the compilation unit.
3716 */
3717 List<UnlinkedExecutable> get executables;
3718
3719 /**
3720 * Export declarations in the compilation unit.
3721 */
3722 List<UnlinkedExportNonPublic> get exports;
3723
3724 /**
3725 * Import declarations in the compilation unit.
3726 */
3727 List<UnlinkedImport> get imports;
3728
3729 /**
3730 * Part declarations in the compilation unit.
3731 */
3732 List<UnlinkedPart> get parts;
3733
3734 /**
3735 * Typedefs declared in the compilation unit.
3736 */
3737 List<UnlinkedTypedef> get typedefs;
3738
3739 /**
3740 * Top level variables declared in the compilation unit.
3741 */
3742 List<UnlinkedVariable> get variables;
3743 }
3744
3745 class _UnlinkedUnitReader extends fb.TableReader<_UnlinkedUnitReader> implements UnlinkedUnit {
3746 final fb.BufferPointer _bp;
3747
3748 const _UnlinkedUnitReader([this._bp]);
3749
3750 @override
3751 _UnlinkedUnitReader createReader(fb.BufferPointer bp) => new _UnlinkedUnitRead er(bp);
3752
3753 @override
3754 Map<String, Object> toMap() => {
3755 "libraryName": libraryName,
3756 "libraryNameOffset": libraryNameOffset,
3757 "libraryNameLength": libraryNameLength,
3758 "libraryDocumentationComment": libraryDocumentationComment,
3759 "publicNamespace": publicNamespace,
3760 "references": references,
3761 "classes": classes,
3762 "enums": enums,
3763 "executables": executables,
3764 "exports": exports,
3765 "imports": imports,
3766 "parts": parts,
3767 "typedefs": typedefs,
3768 "variables": variables,
3769 };
3770
3771 @override
3772 String get libraryName => const fb.StringReader().vTableGet(_bp, 0, '');
3773
3774 @override
3775 int get libraryNameOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
3776
3777 @override
3778 int get libraryNameLength => const fb.Int32Reader().vTableGet(_bp, 2, 0);
3779
3780 @override
3781 UnlinkedDocumentationComment get libraryDocumentationComment => const _Unlinke dDocumentationCommentReader().vTableGet(_bp, 3, null);
3782
3783 @override
3784 UnlinkedPublicNamespace get publicNamespace => const _UnlinkedPublicNamespaceR eader().vTableGet(_bp, 4, null);
3785
3786 @override
3787 List<UnlinkedReference> get references => const fb.ListReader<UnlinkedReferenc e>(const _UnlinkedReferenceReader()).vTableGet(_bp, 5, const <UnlinkedReference> []);
3788
3789 @override
3790 List<UnlinkedClass> get classes => const fb.ListReader<UnlinkedClass>(const _U nlinkedClassReader()).vTableGet(_bp, 6, const <UnlinkedClass>[]);
3791
3792 @override
3793 List<UnlinkedEnum> get enums => const fb.ListReader<UnlinkedEnum>(const _Unlin kedEnumReader()).vTableGet(_bp, 7, const <UnlinkedEnum>[]);
3794
3795 @override
3796 List<UnlinkedExecutable> get executables => const fb.ListReader<UnlinkedExecut able>(const _UnlinkedExecutableReader()).vTableGet(_bp, 8, const <UnlinkedExecut able>[]);
3797
3798 @override
3799 List<UnlinkedExportNonPublic> get exports => const fb.ListReader<UnlinkedExpor tNonPublic>(const _UnlinkedExportNonPublicReader()).vTableGet(_bp, 9, const <Unl inkedExportNonPublic>[]);
3800
3801 @override
3802 List<UnlinkedImport> get imports => const fb.ListReader<UnlinkedImport>(const _UnlinkedImportReader()).vTableGet(_bp, 10, const <UnlinkedImport>[]);
3803
3804 @override
3805 List<UnlinkedPart> get parts => const fb.ListReader<UnlinkedPart>(const _Unlin kedPartReader()).vTableGet(_bp, 11, const <UnlinkedPart>[]);
3806
3807 @override
3808 List<UnlinkedTypedef> get typedefs => const fb.ListReader<UnlinkedTypedef>(con st _UnlinkedTypedefReader()).vTableGet(_bp, 12, const <UnlinkedTypedef>[]);
3809
3810 @override
3811 List<UnlinkedVariable> get variables => const fb.ListReader<UnlinkedVariable>( const _UnlinkedVariableReader()).vTableGet(_bp, 13, const <UnlinkedVariable>[]);
3812 }
3813
3814 class UnlinkedVariableBuilder {
3815 bool _finished = false;
3816
3162 String _name; 3817 String _name;
3163 int _nameOffset; 3818 int _nameOffset;
3164 UnlinkedDocumentationComment _documentationComment; 3819 UnlinkedDocumentationCommentBuilder _documentationComment;
3165 UnlinkedTypeRef _type; 3820 UnlinkedTypeRefBuilder _type;
3166 bool _isStatic; 3821 bool _isStatic;
3167 bool _isFinal; 3822 bool _isFinal;
3168 bool _isConst; 3823 bool _isConst;
3169 bool _hasImplicitType; 3824 bool _hasImplicitType;
3170 3825
3171 UnlinkedVariable.fromJson(Map json)
3172 : _name = json["name"],
3173 _nameOffset = json["nameOffset"],
3174 _documentationComment = json["documentationComment"] == null ? null : new UnlinkedDocumentationComment.fromJson(json["documentationComment"]),
3175 _type = json["type"] == null ? null : new UnlinkedTypeRef.fromJson(json["t ype"]),
3176 _isStatic = json["isStatic"],
3177 _isFinal = json["isFinal"],
3178 _isConst = json["isConst"],
3179 _hasImplicitType = json["hasImplicitType"];
3180
3181 @override
3182 Map<String, Object> toMap() => {
3183 "name": name,
3184 "nameOffset": nameOffset,
3185 "documentationComment": documentationComment,
3186 "type": type,
3187 "isStatic": isStatic,
3188 "isFinal": isFinal,
3189 "isConst": isConst,
3190 "hasImplicitType": hasImplicitType,
3191 };
3192
3193 /**
3194 * Name of the variable.
3195 */
3196 String get name => _name ?? '';
3197
3198 /**
3199 * Offset of the variable name relative to the beginning of the file.
3200 */
3201 int get nameOffset => _nameOffset ?? 0;
3202
3203 /**
3204 * Documentation comment for the variable, or `null` if there is no
3205 * documentation comment.
3206 */
3207 UnlinkedDocumentationComment get documentationComment => _documentationComment ;
3208
3209 /**
3210 * Declared type of the variable. Note that when strong mode is enabled, the
3211 * actual type of the variable may be different due to type inference.
3212 */
3213 UnlinkedTypeRef get type => _type;
3214
3215 /**
3216 * Indicates whether the variable is declared using the `static` keyword.
3217 *
3218 * Note that for top level variables, this flag is false, since they are not
3219 * declared using the `static` keyword (even though they are considered
3220 * static for semantic purposes).
3221 */
3222 bool get isStatic => _isStatic ?? false;
3223
3224 /**
3225 * Indicates whether the variable is declared using the `final` keyword.
3226 */
3227 bool get isFinal => _isFinal ?? false;
3228
3229 /**
3230 * Indicates whether the variable is declared using the `const` keyword.
3231 */
3232 bool get isConst => _isConst ?? false;
3233
3234 /**
3235 * Indicates whether this variable lacks an explicit type declaration.
3236 */
3237 bool get hasImplicitType => _hasImplicitType ?? false;
3238 }
3239
3240 class UnlinkedVariableBuilder {
3241 final Map _json = {};
3242
3243 bool _finished = false;
3244
3245 UnlinkedVariableBuilder(base.BuilderContext context); 3826 UnlinkedVariableBuilder(base.BuilderContext context);
3246 3827
3247 /** 3828 /**
3248 * Name of the variable. 3829 * Name of the variable.
3249 */ 3830 */
3250 void set name(String _value) { 3831 void set name(String _value) {
3251 assert(!_finished); 3832 assert(!_finished);
3252 assert(!_json.containsKey("name")); 3833 _name = _value;
3253 if (_value != null) {
3254 _json["name"] = _value;
3255 }
3256 } 3834 }
3257 3835
3258 /** 3836 /**
3259 * Offset of the variable name relative to the beginning of the file. 3837 * Offset of the variable name relative to the beginning of the file.
3260 */ 3838 */
3261 void set nameOffset(int _value) { 3839 void set nameOffset(int _value) {
3262 assert(!_finished); 3840 assert(!_finished);
3263 assert(!_json.containsKey("nameOffset")); 3841 _nameOffset = _value;
3264 if (_value != null) {
3265 _json["nameOffset"] = _value;
3266 }
3267 } 3842 }
3268 3843
3269 /** 3844 /**
3270 * Documentation comment for the variable, or `null` if there is no 3845 * Documentation comment for the variable, or `null` if there is no
3271 * documentation comment. 3846 * documentation comment.
3272 */ 3847 */
3273 void set documentationComment(UnlinkedDocumentationCommentBuilder _value) { 3848 void set documentationComment(UnlinkedDocumentationCommentBuilder _value) {
3274 assert(!_finished); 3849 assert(!_finished);
3275 assert(!_json.containsKey("documentationComment")); 3850 _documentationComment = _value;
3276 if (_value != null) {
3277 _json["documentationComment"] = _value.finish();
3278 }
3279 } 3851 }
3280 3852
3281 /** 3853 /**
3282 * Declared type of the variable. Note that when strong mode is enabled, the 3854 * Declared type of the variable. Note that when strong mode is enabled, the
3283 * actual type of the variable may be different due to type inference. 3855 * actual type of the variable may be different due to type inference.
3284 */ 3856 */
3285 void set type(UnlinkedTypeRefBuilder _value) { 3857 void set type(UnlinkedTypeRefBuilder _value) {
3286 assert(!_finished); 3858 assert(!_finished);
3287 assert(!_json.containsKey("type")); 3859 _type = _value;
3288 if (_value != null) {
3289 _json["type"] = _value.finish();
3290 }
3291 } 3860 }
3292 3861
3293 /** 3862 /**
3294 * Indicates whether the variable is declared using the `static` keyword. 3863 * Indicates whether the variable is declared using the `static` keyword.
3295 * 3864 *
3296 * Note that for top level variables, this flag is false, since they are not 3865 * Note that for top level variables, this flag is false, since they are not
3297 * declared using the `static` keyword (even though they are considered 3866 * declared using the `static` keyword (even though they are considered
3298 * static for semantic purposes). 3867 * static for semantic purposes).
3299 */ 3868 */
3300 void set isStatic(bool _value) { 3869 void set isStatic(bool _value) {
3301 assert(!_finished); 3870 assert(!_finished);
3302 assert(!_json.containsKey("isStatic")); 3871 _isStatic = _value;
3303 if (_value != null) {
3304 _json["isStatic"] = _value;
3305 }
3306 } 3872 }
3307 3873
3308 /** 3874 /**
3309 * Indicates whether the variable is declared using the `final` keyword. 3875 * Indicates whether the variable is declared using the `final` keyword.
3310 */ 3876 */
3311 void set isFinal(bool _value) { 3877 void set isFinal(bool _value) {
3312 assert(!_finished); 3878 assert(!_finished);
3313 assert(!_json.containsKey("isFinal")); 3879 _isFinal = _value;
3314 if (_value != null) {
3315 _json["isFinal"] = _value;
3316 }
3317 } 3880 }
3318 3881
3319 /** 3882 /**
3320 * Indicates whether the variable is declared using the `const` keyword. 3883 * Indicates whether the variable is declared using the `const` keyword.
3321 */ 3884 */
3322 void set isConst(bool _value) { 3885 void set isConst(bool _value) {
3323 assert(!_finished); 3886 assert(!_finished);
3324 assert(!_json.containsKey("isConst")); 3887 _isConst = _value;
3325 if (_value != null) {
3326 _json["isConst"] = _value;
3327 }
3328 } 3888 }
3329 3889
3330 /** 3890 /**
3331 * Indicates whether this variable lacks an explicit type declaration. 3891 * Indicates whether this variable lacks an explicit type declaration.
3332 */ 3892 */
3333 void set hasImplicitType(bool _value) { 3893 void set hasImplicitType(bool _value) {
3334 assert(!_finished); 3894 assert(!_finished);
3335 assert(!_json.containsKey("hasImplicitType")); 3895 _hasImplicitType = _value;
3336 if (_value != null) {
3337 _json["hasImplicitType"] = _value;
3338 }
3339 } 3896 }
3340 3897
3341 Map finish() { 3898 fb.Offset finish(fb.Builder fbBuilder) {
3342 assert(!_finished); 3899 assert(!_finished);
3343 _finished = true; 3900 _finished = true;
3344 return _json; 3901 fb.Offset offset_name;
3902 fb.Offset offset_documentationComment;
3903 fb.Offset offset_type;
3904 if (_name != null) {
3905 offset_name = fbBuilder.writeString(_name);
3906 }
3907 if (_documentationComment != null) {
3908 offset_documentationComment = _documentationComment.finish(fbBuilder);
3909 }
3910 if (_type != null) {
3911 offset_type = _type.finish(fbBuilder);
3912 }
3913 fbBuilder.startTable();
3914 if (offset_name != null) {
3915 fbBuilder.addOffset(0, offset_name);
3916 }
3917 if (_nameOffset != null && _nameOffset != 0) {
3918 fbBuilder.addInt32(1, _nameOffset);
3919 }
3920 if (offset_documentationComment != null) {
3921 fbBuilder.addOffset(2, offset_documentationComment);
3922 }
3923 if (offset_type != null) {
3924 fbBuilder.addOffset(3, offset_type);
3925 }
3926 if (_isStatic == true) {
3927 fbBuilder.addInt8(4, 1);
3928 }
3929 if (_isFinal == true) {
3930 fbBuilder.addInt8(5, 1);
3931 }
3932 if (_isConst == true) {
3933 fbBuilder.addInt8(6, 1);
3934 }
3935 if (_hasImplicitType == true) {
3936 fbBuilder.addInt8(7, 1);
3937 }
3938 return fbBuilder.endTable();
3345 } 3939 }
3346 } 3940 }
3347 3941
3348 UnlinkedVariableBuilder encodeUnlinkedVariable(base.BuilderContext builderContex t, {String name, int nameOffset, UnlinkedDocumentationCommentBuilder documentati onComment, UnlinkedTypeRefBuilder type, bool isStatic, bool isFinal, bool isCons t, bool hasImplicitType}) { 3942 UnlinkedVariableBuilder encodeUnlinkedVariable(base.BuilderContext builderContex t, {String name, int nameOffset, UnlinkedDocumentationCommentBuilder documentati onComment, UnlinkedTypeRefBuilder type, bool isStatic, bool isFinal, bool isCons t, bool hasImplicitType}) {
3349 UnlinkedVariableBuilder builder = new UnlinkedVariableBuilder(builderContext); 3943 UnlinkedVariableBuilder builder = new UnlinkedVariableBuilder(builderContext);
3350 builder.name = name; 3944 builder.name = name;
3351 builder.nameOffset = nameOffset; 3945 builder.nameOffset = nameOffset;
3352 builder.documentationComment = documentationComment; 3946 builder.documentationComment = documentationComment;
3353 builder.type = type; 3947 builder.type = type;
3354 builder.isStatic = isStatic; 3948 builder.isStatic = isStatic;
3355 builder.isFinal = isFinal; 3949 builder.isFinal = isFinal;
3356 builder.isConst = isConst; 3950 builder.isConst = isConst;
3357 builder.hasImplicitType = hasImplicitType; 3951 builder.hasImplicitType = hasImplicitType;
3358 return builder; 3952 return builder;
3359 } 3953 }
3360 3954
3955 /**
3956 * Unlinked summary information about a top level variable, local variable, or
3957 * a field.
3958 */
3959 abstract class UnlinkedVariable extends base.SummaryClass {
3960
3961 /**
3962 * Name of the variable.
3963 */
3964 String get name;
3965
3966 /**
3967 * Offset of the variable name relative to the beginning of the file.
3968 */
3969 int get nameOffset;
3970
3971 /**
3972 * Documentation comment for the variable, or `null` if there is no
3973 * documentation comment.
3974 */
3975 UnlinkedDocumentationComment get documentationComment;
3976
3977 /**
3978 * Declared type of the variable. Note that when strong mode is enabled, the
3979 * actual type of the variable may be different due to type inference.
3980 */
3981 UnlinkedTypeRef get type;
3982
3983 /**
3984 * Indicates whether the variable is declared using the `static` keyword.
3985 *
3986 * Note that for top level variables, this flag is false, since they are not
3987 * declared using the `static` keyword (even though they are considered
3988 * static for semantic purposes).
3989 */
3990 bool get isStatic;
3991
3992 /**
3993 * Indicates whether the variable is declared using the `final` keyword.
3994 */
3995 bool get isFinal;
3996
3997 /**
3998 * Indicates whether the variable is declared using the `const` keyword.
3999 */
4000 bool get isConst;
4001
4002 /**
4003 * Indicates whether this variable lacks an explicit type declaration.
4004 */
4005 bool get hasImplicitType;
4006 }
4007
4008 class _UnlinkedVariableReader extends fb.TableReader<_UnlinkedVariableReader> im plements UnlinkedVariable {
4009 final fb.BufferPointer _bp;
4010
4011 const _UnlinkedVariableReader([this._bp]);
4012
4013 @override
4014 _UnlinkedVariableReader createReader(fb.BufferPointer bp) => new _UnlinkedVari ableReader(bp);
4015
4016 @override
4017 Map<String, Object> toMap() => {
4018 "name": name,
4019 "nameOffset": nameOffset,
4020 "documentationComment": documentationComment,
4021 "type": type,
4022 "isStatic": isStatic,
4023 "isFinal": isFinal,
4024 "isConst": isConst,
4025 "hasImplicitType": hasImplicitType,
4026 };
4027
4028 @override
4029 String get name => const fb.StringReader().vTableGet(_bp, 0, '');
4030
4031 @override
4032 int get nameOffset => const fb.Int32Reader().vTableGet(_bp, 1, 0);
4033
4034 @override
4035 UnlinkedDocumentationComment get documentationComment => const _UnlinkedDocume ntationCommentReader().vTableGet(_bp, 2, null);
4036
4037 @override
4038 UnlinkedTypeRef get type => const _UnlinkedTypeRefReader().vTableGet(_bp, 3, n ull);
4039
4040 @override
4041 bool get isStatic => const fb.Int8Reader().vTableGet(_bp, 4, 0) == 1;
4042
4043 @override
4044 bool get isFinal => const fb.Int8Reader().vTableGet(_bp, 5, 0) == 1;
4045
4046 @override
4047 bool get isConst => const fb.Int8Reader().vTableGet(_bp, 6, 0) == 1;
4048
4049 @override
4050 bool get hasImplicitType => const fb.Int8Reader().vTableGet(_bp, 7, 0) == 1;
4051 }
4052
OLDNEW
« 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