@@ -27,14 +27,6 @@ abstract class Info {
27
27
/// Name of the element associated with this info.
28
28
String name;
29
29
30
- /// An id to uniquely identify this info among infos of the same [kind] .
31
- // TODO(kevmoo) Consider removing `id` entirely. Make it an impl detail of
32
- // the JSON encoder
33
- int get id;
34
-
35
- /// A globally unique id combining [kind] and [id] together.
36
- String get serializedId;
37
-
38
30
/// Id used by the compiler when instrumenting code for code coverage.
39
31
// TODO(sigmund): It would be nice if we could use the same id for
40
32
// serialization and for coverage. Could we unify them?
@@ -53,46 +45,12 @@ abstract class Info {
53
45
// TODO(sigmund): add more:
54
46
// - inputSize: bytes used in the Dart source program
55
47
abstract class BasicInfo implements Info {
56
- static final Set <int > _ids = new Set <int >();
57
-
58
- /// Frees internal cache used for id uniqueness.
59
- static void resetIds () => BasicInfo ._ids.clear ();
60
-
61
48
final InfoKind kind;
62
49
63
- int _id;
64
- // TODO(kevmoo) Make computation of id explicit and not on-demand.
65
- int get id {
66
- if (_id == null ) {
67
- assert (this is LibraryInfo ||
68
- this is ConstantInfo ||
69
- this is OutputUnitInfo ||
70
- this .parent != null );
71
-
72
- if (this is ConstantInfo ) {
73
- // No name and no parent, so `longName` isn't helpful
74
- assert (this .name == null );
75
- assert (this .parent == null );
76
- assert ((this as ConstantInfo ).code != null );
77
- // Instead, use the content of the code.
78
- _id = (this as ConstantInfo ).code.hashCode;
79
- } else {
80
- _id = longName (this , useLibraryUri: true , forId: true ).hashCode;
81
- }
82
- while (! _ids.add (_id)) {
83
- _id++ ;
84
- }
85
- }
86
-
87
- return _id;
88
- }
89
-
90
50
String coverageId;
91
51
int size;
92
52
Info parent;
93
53
94
- String get serializedId => '${kindToString (kind )}/$id ' ;
95
-
96
54
String name;
97
55
98
56
/// If using deferred libraries, where the element associated with this info
@@ -101,18 +59,16 @@ abstract class BasicInfo implements Info {
101
59
102
60
BasicInfo (this .kind, this .name, this .outputUnit, this .size, this .coverageId);
103
61
104
- BasicInfo ._fromId (String serializedId)
105
- : kind = _kindFromSerializedId (serializedId),
106
- _id = _idFromSerializedId (serializedId);
62
+ BasicInfo ._(this .kind);
107
63
108
- String toString () => '$serializedId $name [$size ]' ;
64
+ String toString () => '$kind $name [$size ]' ;
109
65
}
110
66
111
67
/// Info associated with elements containing executable code (like fields and
112
68
/// methods)
113
69
abstract class CodeInfo implements Info {
114
70
/// How does this function or field depend on others.
115
- final Set <DependencyInfo > uses = new SplayTreeSet < DependencyInfo >() ;
71
+ final List <DependencyInfo > uses = [] ;
116
72
}
117
73
118
74
/// The entire information produced while compiling a program.
@@ -250,7 +206,7 @@ class LibraryInfo extends BasicInfo {
250
206
LibraryInfo (String name, this .uri, OutputUnitInfo outputUnit, int size)
251
207
: super (InfoKind .library, name, outputUnit, size, null );
252
208
253
- LibraryInfo ._(String serializedId ) : super ._fromId (serializedId );
209
+ LibraryInfo ._() : super ._( InfoKind .library );
254
210
255
211
T accept <T >(InfoVisitor <T > visitor) => visitor.visitLibrary (this );
256
212
}
@@ -265,7 +221,7 @@ class OutputUnitInfo extends BasicInfo {
265
221
OutputUnitInfo (String name, int size)
266
222
: super (InfoKind .outputUnit, name, null , size, null );
267
223
268
- OutputUnitInfo ._(String serializedId ) : super ._fromId (serializedId );
224
+ OutputUnitInfo ._() : super ._( InfoKind .outputUnit );
269
225
270
226
T accept <T >(InfoVisitor <T > visitor) => visitor.visitOutput (this );
271
227
}
@@ -288,7 +244,7 @@ class ClassInfo extends BasicInfo {
288
244
{String name, this .isAbstract, OutputUnitInfo outputUnit, int size: 0 })
289
245
: super (InfoKind .clazz, name, outputUnit, size, null );
290
246
291
- ClassInfo ._(String serializedId ) : super ._fromId (serializedId );
247
+ ClassInfo ._() : super ._( InfoKind .clazz );
292
248
293
249
T accept <T >(InfoVisitor <T > visitor) => visitor.visitClass (this );
294
250
}
@@ -303,7 +259,7 @@ class ConstantInfo extends BasicInfo {
303
259
ConstantInfo ({int size: 0 , this .code, OutputUnitInfo outputUnit})
304
260
: super (InfoKind .constant, null , outputUnit, size, null );
305
261
306
- ConstantInfo ._(String serializedId ) : super ._fromId (serializedId );
262
+ ConstantInfo ._() : super ._( InfoKind .constant );
307
263
308
264
T accept <T >(InfoVisitor <T > visitor) => visitor.visitConstant (this );
309
265
}
@@ -340,7 +296,7 @@ class FieldInfo extends BasicInfo with CodeInfo {
340
296
this .isConst})
341
297
: super (InfoKind .field, name, outputUnit, size, coverageId);
342
298
343
- FieldInfo ._(String serializedId ) : super ._fromId (serializedId );
299
+ FieldInfo ._() : super ._( InfoKind .field );
344
300
345
301
T accept <T >(InfoVisitor <T > visitor) => visitor.visitField (this );
346
302
}
@@ -353,7 +309,7 @@ class TypedefInfo extends BasicInfo {
353
309
TypedefInfo (String name, this .type, OutputUnitInfo outputUnit)
354
310
: super (InfoKind .typedef , name, outputUnit, 0 , null );
355
311
356
- TypedefInfo ._(String serializedId ) : super ._fromId (serializedId );
312
+ TypedefInfo ._() : super ._( InfoKind . typedef );
357
313
358
314
T accept <T >(InfoVisitor <T > visitor) => visitor.visitTypedef (this );
359
315
}
@@ -417,7 +373,7 @@ class FunctionInfo extends BasicInfo with CodeInfo {
417
373
this .measurements})
418
374
: super (InfoKind .function, name, outputUnit, size, coverageId);
419
375
420
- FunctionInfo ._(String serializedId ) : super ._fromId (serializedId );
376
+ FunctionInfo ._() : super ._( InfoKind .function );
421
377
422
378
T accept <T >(InfoVisitor <T > visitor) => visitor.visitFunction (this );
423
379
}
@@ -431,13 +387,13 @@ class ClosureInfo extends BasicInfo {
431
387
{String name, OutputUnitInfo outputUnit, int size: 0 , this .function})
432
388
: super (InfoKind .closure, name, outputUnit, size, null );
433
389
434
- ClosureInfo ._(String serializedId ) : super ._fromId (serializedId );
390
+ ClosureInfo ._() : super ._( InfoKind .closure );
435
391
436
392
T accept <T >(InfoVisitor <T > visitor) => visitor.visitClosure (this );
437
393
}
438
394
439
395
/// Information about how a dependency is used.
440
- class DependencyInfo implements Comparable < DependencyInfo > {
396
+ class DependencyInfo {
441
397
/// The dependency, either a FunctionInfo or FieldInfo.
442
398
final Info target;
443
399
@@ -447,21 +403,6 @@ class DependencyInfo implements Comparable<DependencyInfo> {
447
403
final String mask;
448
404
449
405
DependencyInfo (this .target, this .mask);
450
-
451
- int compareTo (DependencyInfo other) {
452
- var value = target.serializedId.compareTo (other.target.serializedId);
453
- if (value == 0 ) {
454
- value = mask.compareTo (other.mask);
455
- }
456
- return value;
457
- }
458
-
459
- bool operator == (other) =>
460
- other is DependencyInfo &&
461
- target.serializedId == other.target.serializedId &&
462
- mask == other.mask;
463
-
464
- int get hashCode => target.serializedId.hashCode * 37 ^ mask.hashCode;
465
406
}
466
407
467
408
/// Name and type information about a function parameter.
@@ -522,12 +463,6 @@ String kindToString(InfoKind kind) {
522
463
}
523
464
}
524
465
525
- int _idFromSerializedId (String serializedId) =>
526
- int .parse (serializedId.substring (serializedId.indexOf ('/' ) + 1 ));
527
-
528
- InfoKind _kindFromSerializedId (String serializedId) =>
529
- kindFromString (serializedId.substring (0 , serializedId.indexOf ('/' )));
530
-
531
466
InfoKind kindFromString (String kind) {
532
467
switch (kind) {
533
468
case 'library' :
0 commit comments