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

Side by Side Diff: pkg/analyzer/tool/summary/idl.dart

Issue 1667723002: Use summary IDL file for interface classes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 | « pkg/analyzer/tool/summary/generate.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * This file is an "idl" style description of the summary format. It is not
7 * executed directly; instead it is parsed and transformed into code that
8 * implements the summary format.
9 *
10 * The code generation process introduces the following non-typical semantics:
11 * - Fields of type List are never null, and have a default value of the empty
12 * list.
13 * - Fields of type int are unsigned 32-bit integers, never null, and have a
14 * default value of zero.
15 * - Fields of type String are never null, and have a default value of ''.
16 * - Fields of type bool are never null, and have a default value of false.
17 * - Fields whose type is an enum are never null, and have a default value of
18 * the first value declared in the enum.
19 *
20 * Terminology used in this document:
21 * - "Unlinked" refers to information that can be determined from reading a
22 * single .dart file in isolation.
23 * - "Prelinked" refers to information that can be determined from the defining
24 * compilation unit of a library, plus direct imports, plus the transitive
25 * closure of exports reachable from those libraries, plus all part files
26 * constituting those libraries.
27 * - "Linked" refers to all other information; in theory, this information may
28 * depend on all files in the transitive import/export closure. However, in
29 * practice we expect that the number of additional dependencies will usually
30 * be small, since the additional dependencies only need to be consulted for
31 * type propagation, type inference, and constant evaluation, which typically
32 * have short dependency chains.
33 *
34 * Since we expect "linked" and "prelinked" dependencies to be similar, we only
35 * rarely distinguish between them; most information is that is not "unlinked"
36 * is typically considered "linked" for simplicity.
37 *
38 * Except as otherwise noted, synthetic elements are not stored in the summary;
39 * they are re-synthesized at the time the summary is read.
40 */
41 library analyzer.tool.summary.idl;
42
43 /**
44 * Annotation describing information which is not part of Dart semantics; in
45 * other words, if this information (or any information it refers to) changes,
46 * static analysis and runtime behavior of the library are unaffected.
47 *
48 * TODO(paulberry): some informative information is currently missing from the
49 * summary format.
50 */
51 const informative = null;
52
53 /**
54 * Annotation describing information which is not part of the public API to a
55 * library; in other words, if this information (or any information it refers
56 * to) changes, libraries outside this one are unaffected.
57 *
58 * TODO(paulberry): currently the summary format does not contain private
59 * information.
60 */
61 const private = null;
62
63 /**
64 * Annotation describing a class which can be the top level object in an
65 * encoded summary.
66 */
67 const topLevel = null;
68
69 /**
70 * Summary information about a reference to a an entity such as a type, top
71 * level executable, or executable within a class.
72 */
73 class EntityRef {
74 /**
75 * If this [EntityRef] is contained within [LinkedUnit.types], slot id (which
76 * is unique within the compilation unit) identifying the target of type
77 * propagation or type inference with which this [EntityRef] is associated.
78 *
79 * Otherwise zero.
80 */
81 int slot;
82
83 /**
84 * Index into [UnlinkedUnit.references] for the entity being referred to, or
85 * zero if this is a reference to a type parameter.
86 */
87 int reference;
88
89 /**
90 * If this is a reference to a type parameter, one-based index into the list
91 * of [UnlinkedTypeParam]s currently in effect. Indexing is done using De
92 * Bruijn index conventions; that is, innermost parameters come first, and
93 * if a class or method has multiple parameters, they are indexed from right
94 * to left. So for instance, if the enclosing declaration is
95 *
96 * class C<T,U> {
97 * m<V,W> {
98 * ...
99 * }
100 * }
101 *
102 * Then [paramReference] values of 1, 2, 3, and 4 represent W, V, U, and T,
103 * respectively.
104 *
105 * If the type being referred to is not a type parameter, [paramReference] is
106 * zero.
107 */
108 int paramReference;
109
110 /**
111 * If this is a reference to a function type implicitly defined by a
112 * function-typed parameter, a list of zero-based indices indicating the path
113 * from the entity referred to by [reference] to the appropriate type
114 * parameter. Otherwise the empty list.
115 *
116 * If there are N indices in this list, then the entity being referred to is
117 * the function type implicitly defined by a function-typed parameter of a
118 * function-typed parameter, to N levels of nesting. The first index in the
119 * list refers to the outermost level of nesting; for example if [reference]
120 * refers to the entity defined by:
121 *
122 * void f(x, void g(y, z, int h(String w))) { ... }
123 *
124 * Then to refer to the function type implicitly defined by parameter `h`
125 * (which is parameter 2 of parameter 1 of `f`), then
126 * [implicitFunctionTypeIndices] should be [1, 2].
127 *
128 * Note that if the entity being referred to is a generic method inside a
129 * generic class, then the type arguments in [typeArguments] are applied
130 * first to the class and then to the method.
131 */
132 List<int> implicitFunctionTypeIndices;
133
134 /**
135 * If this is an instantiation of a generic type or generic executable, the
136 * type arguments used to instantiate it. Trailing type arguments of type
137 * `dynamic` are omitted.
138 */
139 List<EntityRef> typeArguments;
140 }
141
142 /**
143 * Information about a dependency that exists between one library and another
144 * due to an "import" declaration.
145 */
146 class LinkedDependency {
147 /**
148 * The relative URI of the dependent library. This URI is relative to the
149 * importing library, even if there are intervening `export` declarations.
150 * So, for example, if `a.dart` imports `b/c.dart` and `b/c.dart` exports
151 * `d/e.dart`, the URI listed for `a.dart`'s dependency on `e.dart` will be
152 * `b/d/e.dart`.
153 */
154 String uri;
155
156 /**
157 * URI for the compilation units listed in the library's `part` declarations.
158 * These URIs are relative to the importing library.
159 */
160 List<String> parts;
161 }
162
163 /**
164 * Information about a single name in the export namespace of the library that
165 * is not in the public namespace.
166 */
167 class LinkedExportName {
168 /**
169 * Name of the exported entity. For an exported setter, this name includes
170 * the trailing '='.
171 */
172 String name;
173
174 /**
175 * Index into [LinkedLibrary.dependencies] for the library in which the
176 * entity is defined.
177 */
178 int dependency;
179
180 /**
181 * Integer index indicating which unit in the exported library contains the
182 * definition of the entity. As with indices into [LinkedLibrary.units],
183 * zero represents the defining compilation unit, and nonzero values
184 * represent parts in the order of the corresponding `part` declarations.
185 */
186 int unit;
187
188 /**
189 * The kind of the entity being referred to.
190 */
191 ReferenceKind kind;
192 }
193
194 /**
195 * Linked summary of a library.
196 */
197 @topLevel
198 class LinkedLibrary {
199 /**
200 * The linked summary of all the compilation units constituting the
201 * library. The summary of the defining compilation unit is listed first,
202 * followed by the summary of each part, in the order of the `part`
203 * declarations in the defining compilation unit.
204 */
205 List<LinkedUnit> units;
206
207 /**
208 * The libraries that this library depends on (either via an explicit import
209 * statement or via the implicit dependencies on `dart:core` and
210 * `dart:async`). The first element of this array is a pseudo-dependency
211 * representing the library itself (it is also used for `dynamic` and
212 * `void`). This is followed by elements representing "prelinked"
213 * dependencies (direct imports and the transitive closure of exports).
214 * After the prelinked dependencies are elements representing "linked"
215 * dependencies.
216 *
217 * A library is only included as a "linked" dependency if it is a true
218 * dependency (e.g. a propagated or inferred type or constant value
219 * implicitly refers to an element declared in the library) or
220 * anti-dependency (e.g. the result of type propagation or type inference
221 * depends on the lack of a certain declaration in the library).
222 */
223 List<LinkedDependency> dependencies;
224
225 /**
226 * For each import in [UnlinkedUnit.imports], an index into [dependencies]
227 * of the library being imported.
228 */
229 List<int> importDependencies;
230
231 /**
232 * Information about entities in the export namespace of the library that are
233 * not in the public namespace of the library (that is, entities that are
234 * brought into the namespace via `export` directives).
235 *
236 * Sorted by name.
237 */
238 List<LinkedExportName> exportNames;
239
240 /**
241 * The number of elements in [dependencies] which are not "linked"
242 * dependencies (that is, the number of libraries in the direct imports plus
243 * the transitive closure of exports, plus the library itself).
244 */
245 int numPrelinkedDependencies;
246 }
247
248 /**
249 * Information about the resolution of an [UnlinkedReference].
250 */
251 class LinkedReference {
252 /**
253 * Index into [LinkedLibrary.dependencies] indicating which imported library
254 * declares the entity being referred to.
255 *
256 * Zero if this entity is contained within another entity (e.g. a class
257 * member).
258 */
259 int dependency;
260
261 /**
262 * The kind of the entity being referred to. For the pseudo-types `dynamic`
263 * and `void`, the kind is [ReferenceKind.classOrEnum].
264 */
265 ReferenceKind kind;
266
267 /**
268 * Integer index indicating which unit in the imported library contains the
269 * definition of the entity. As with indices into [LinkedLibrary.units],
270 * zero represents the defining compilation unit, and nonzero values
271 * represent parts in the order of the corresponding `part` declarations.
272 *
273 * Zero if this entity is contained within another entity (e.g. a class
274 * member).
275 */
276 int unit;
277
278 /**
279 * If the entity being referred to is generic, the number of type parameters
280 * it accepts. Otherwise zero.
281 */
282 int numTypeParameters;
283
284 /**
285 * If this [LinkedReference] doesn't have an associated [UnlinkedReference],
286 * name of the entity being referred to. For the pseudo-type `dynamic`, the
287 * string is "dynamic". For the pseudo-type `void`, the string is "void".
288 */
289 String name;
290
291 /**
292 * If this [LinkedReference] doesn't have an associated [UnlinkedReference],
293 * and the entity being referred to is contained within another entity, index
294 * of the containing entity. This behaves similarly to
295 * [UnlinkedReference.prefixReference], however it is only used for class
296 * members, not for prefixed imports.
297 *
298 * Containing references must always point backward; that is, for all i, if
299 * LinkedUnit.references[i].containingReference != 0, then
300 * LinkedUnit.references[i].containingReference < i.
301 */
302 int containingReference;
303 }
304
305 /**
306 * Linked summary of a compilation unit.
307 */
308 class LinkedUnit {
309 /**
310 * Information about the resolution of references within the compilation
311 * unit. Each element of [UnlinkedUnit.references] has a corresponding
312 * element in this list (at the same index). If this list has additional
313 * elements beyond the number of elements in [UnlinkedUnit.references], those
314 * additional elements are references that are only referred to implicitly
315 * (e.g. elements involved in inferred or propagated types).
316 */
317 List<LinkedReference> references;
318
319 /**
320 * List associating slot ids found inside the unlinked summary for the
321 * compilation unit with propagated and inferred types.
322 */
323 List<EntityRef> types;
324 }
325
326 /**
327 * Enum used to indicate the kind of entity referred to by a
328 * [LinkedReference].
329 */
330 enum ReferenceKind {
331 /**
332 * The entity is a class or enum.
333 */
334 classOrEnum,
335
336 /**
337 * The entity is a constructor.
338 */
339 constructor,
340
341 /**
342 * The entity is a getter or setter inside a class. Note: this is used in
343 * the case where a constant refers to a static const declared inside a
344 * class.
345 */
346 propertyAccessor,
347
348 /**
349 * The entity is a method.
350 */
351 method,
352
353 /**
354 * The `length` property access.
355 */
356 length,
357
358 /**
359 * The entity is a typedef.
360 */
361 typedef,
362
363 /**
364 * The entity is a top level function.
365 */
366 topLevelFunction,
367
368 /**
369 * The entity is a top level getter or setter.
370 */
371 topLevelPropertyAccessor,
372
373 /**
374 * The entity is a prefix.
375 */
376 prefix,
377
378 /**
379 * The entity being referred to does not exist.
380 */
381 unresolved
382 }
383
384 /**
385 * Information about SDK.
386 */
387 @topLevel
388 class SdkBundle {
389 /**
390 * The list of URIs of items in [linkedLibraries], e.g. `dart:core`.
391 */
392 List<String> linkedLibraryUris;
393
394 /**
395 * Linked libraries.
396 */
397 List<LinkedLibrary> linkedLibraries;
398
399 /**
400 * The list of URIs of items in [unlinkedUnits], e.g. `dart:core/bool.dart`.
401 */
402 List<String> unlinkedUnitUris;
403
404 /**
405 * Unlinked information for the compilation units constituting the SDK.
406 */
407 List<UnlinkedUnit> unlinkedUnits;
408 }
409
410 /**
411 * Unlinked summary information about a class declaration.
412 */
413 class UnlinkedClass {
414 /**
415 * Name of the class.
416 */
417 String name;
418
419 /**
420 * Offset of the class name relative to the beginning of the file.
421 */
422 @informative
423 int nameOffset;
424
425 /**
426 * Documentation comment for the class, or `null` if there is no
427 * documentation comment.
428 */
429 @informative
430 UnlinkedDocumentationComment documentationComment;
431
432 /**
433 * Type parameters of the class, if any.
434 */
435 List<UnlinkedTypeParam> typeParameters;
436
437 /**
438 * Supertype of the class, or `null` if either (a) the class doesn't
439 * explicitly declare a supertype (and hence has supertype `Object`), or (b)
440 * the class *is* `Object` (and hence has no supertype).
441 */
442 EntityRef supertype;
443
444 /**
445 * Mixins appearing in a `with` clause, if any.
446 */
447 List<EntityRef> mixins;
448
449 /**
450 * Interfaces appearing in an `implements` clause, if any.
451 */
452 List<EntityRef> interfaces;
453
454 /**
455 * Field declarations contained in the class.
456 */
457 List<UnlinkedVariable> fields;
458
459 /**
460 * Executable objects (methods, getters, and setters) contained in the class.
461 */
462 List<UnlinkedExecutable> executables;
463
464 /**
465 * Indicates whether the class is declared with the `abstract` keyword.
466 */
467 bool isAbstract;
468
469 /**
470 * Indicates whether the class is declared using mixin application syntax.
471 */
472 bool isMixinApplication;
473
474 /**
475 * Indicates whether this class is the core "Object" class (and hence has no
476 * supertype)
477 */
478 bool hasNoSupertype;
479 }
480
481 /**
482 * Unlinked summary information about a `show` or `hide` combinator in an
483 * import or export declaration.
484 */
485 class UnlinkedCombinator {
486 /**
487 * List of names which are shown. Empty if this is a `hide` combinator.
488 */
489 List<String> shows;
490
491 /**
492 * List of names which are hidden. Empty if this is a `show` combinator.
493 */
494 List<String> hides;
495 }
496
497 /**
498 * Unlinked summary information about a compile-time constant expression, or a
499 * potentially constant expression.
500 *
501 * Constant expressions are represented using a simple stack-based language
502 * where [operations] is a sequence of operations to execute starting with an
503 * empty stack. Once all operations have been executed, the stack should
504 * contain a single value which is the value of the constant. Note that some
505 * operations consume additional data from the other fields of this class.
506 */
507 class UnlinkedConst {
508 /**
509 * Sequence of operations to execute (starting with an empty stack) to form
510 * the constant value.
511 */
512 List<UnlinkedConstOperation> operations;
513
514 /**
515 * Sequence of unsigned 32-bit integers consumed by the operations
516 * `pushArgument`, `pushInt`, `shiftOr`, `concatenate`, `invokeConstructor`,
517 * `makeList`, and `makeMap`.
518 */
519 List<int> ints;
520
521 /**
522 * Sequence of 64-bit doubles consumed by the operation `pushDouble`.
523 */
524 List<double> doubles;
525
526 /**
527 * Sequence of strings consumed by the operations `pushString` and
528 * `invokeConstructor`.
529 */
530 List<String> strings;
531
532 /**
533 * Sequence of language constructs consumed by the operations
534 * `pushReference`, `invokeConstructor`, `makeList`, and `makeMap`. Note
535 * that in the case of `pushReference` (and sometimes `invokeConstructor` the
536 * actual entity being referred to may be something other than a type.
537 */
538 List<EntityRef> references;
539 }
540
541 /**
542 * Enum representing the various kinds of operations which may be performed to
543 * produce a constant value. These options are assumed to execute in the
544 * context of a stack which is initially empty.
545 */
546 enum UnlinkedConstOperation {
547 /**
548 * Push the next value from [UnlinkedConst.ints] (a 32-bit unsigned integer)
549 * onto the stack.
550 *
551 * Note that Dart supports integers larger than 32 bits; these are
552 * represented by composing 32-bit values using the [pushLongInt] operation.
553 */
554 pushInt,
555
556 /**
557 * Get the number of components from [UnlinkedConst.ints], then do this number
558 * of times the following operations: multiple the current value by 2^32, "or"
559 * it with the next value in [UnlinkedConst.ints]. The initial value is zero.
560 * Push the result into the stack.
561 */
562 pushLongInt,
563
564 /**
565 * Push the next value from [UnlinkedConst.doubles] (a double precision
566 * floating point value) onto the stack.
567 */
568 pushDouble,
569
570 /**
571 * Push the constant `true` onto the stack.
572 */
573 pushTrue,
574
575 /**
576 * Push the constant `false` onto the stack.
577 */
578 pushFalse,
579
580 /**
581 * Push the next value from [UnlinkedConst.strings] onto the stack.
582 */
583 pushString,
584
585 /**
586 * Pop the top n values from the stack (where n is obtained from
587 * [UnlinkedConst.ints]), convert them to strings (if they aren't already),
588 * concatenate them into a single string, and push it back onto the stack.
589 *
590 * This operation is used to represent constants whose value is a literal
591 * string containing string interpolations.
592 */
593 concatenate,
594
595 /**
596 * Get the next value from [UnlinkedConst.strings], convert it to a symbol,
597 * and push it onto the stack.
598 */
599 makeSymbol,
600
601 /**
602 * Push the constant `null` onto the stack.
603 */
604 pushNull,
605
606 /**
607 * Evaluate a (potentially qualified) identifier expression and push the
608 * resulting value onto the stack. The identifier to be evaluated is
609 * obtained from [UnlinkedConst.references].
610 *
611 * This operation is used to represent the following kinds of constants
612 * (which are indistinguishable from an unresolved AST alone):
613 *
614 * - A qualified reference to a static constant variable (e.g. `C.v`, where
615 * C is a class and `v` is a constant static variable in `C`).
616 * - An identifier expression referring to a constant variable.
617 * - A simple or qualified identifier denoting a class or type alias.
618 * - A simple or qualified identifier denoting a top-level function or a
619 * static method.
620 */
621 pushReference,
622
623 /**
624 * Pop the top `n` values from the stack (where `n` is obtained from
625 * [UnlinkedConst.ints]) into a list (filled from the end) and take the next
626 * `n` values from [UnlinkedConst.strings] and use the lists of names and
627 * values to create named arguments. Then pop the top `m` values from the
628 * stack (where `m` is obtained from [UnlinkedConst.ints]) into a list (filled
629 * from the end) and use them as positional arguments. Use the lists of
630 * positional and names arguments to invoke a constant constructor obtained
631 * from [UnlinkedConst.references], and push the resulting value back onto the
632 * stack.
633 *
634 * Note that for an invocation of the form `const a.b(...)` (where no type
635 * arguments are specified), it is impossible to tell from the unresolved AST
636 * alone whether `a` is a class name and `b` is a constructor name, or `a` is
637 * a prefix name and `b` is a class name. For consistency between AST based
638 * and elements based summaries, references to default constructors are always
639 * recorded as references to corresponding classes.
640 */
641 invokeConstructor,
642
643 /**
644 * Pop the top n values from the stack (where n is obtained from
645 * [UnlinkedConst.ints]), place them in a [List], and push the result back
646 * onto the stack. The type parameter for the [List] is implicitly `dynamic`.
647 */
648 makeUntypedList,
649
650 /**
651 * Pop the top 2*n values from the stack (where n is obtained from
652 * [UnlinkedConst.ints]), interpret them as key/value pairs, place them in a
653 * [Map], and push the result back onto the stack. The two type parameters
654 * for the [Map] are implicitly `dynamic`.
655 */
656 makeUntypedMap,
657
658 /**
659 * Pop the top n values from the stack (where n is obtained from
660 * [UnlinkedConst.ints]), place them in a [List], and push the result back
661 * onto the stack. The type parameter for the [List] is obtained from
662 * [UnlinkedConst.references].
663 */
664 makeTypedList,
665
666 /**
667 * Pop the top 2*n values from the stack (where n is obtained from
668 * [UnlinkedConst.ints]), interpret them as key/value pairs, place them in a
669 * [Map], and push the result back onto the stack. The two type parameters fo r
670 * the [Map] are obtained from [UnlinkedConst.references].
671 */
672 makeTypedMap,
673
674 /**
675 * Pop the top 2 values from the stack, pass them to the predefined Dart
676 * function `identical`, and push the result back onto the stack.
677 */
678 identical,
679
680 /**
681 * Pop the top 2 values from the stack, evaluate `v1 == v2`, and push the
682 * result back onto the stack.
683 */
684 equal,
685
686 /**
687 * Pop the top 2 values from the stack, evaluate `v1 != v2`, and push the
688 * result back onto the stack.
689 */
690 notEqual,
691
692 /**
693 * Pop the top value from the stack, compute its boolean negation, and push
694 * the result back onto the stack.
695 */
696 not,
697
698 /**
699 * Pop the top 2 values from the stack, compute `v1 && v2`, and push the
700 * result back onto the stack.
701 */
702 and,
703
704 /**
705 * Pop the top 2 values from the stack, compute `v1 || v2`, and push the
706 * result back onto the stack.
707 */
708 or,
709
710 /**
711 * Pop the top value from the stack, compute its integer complement, and push
712 * the result back onto the stack.
713 */
714 complement,
715
716 /**
717 * Pop the top 2 values from the stack, compute `v1 ^ v2`, and push the
718 * result back onto the stack.
719 */
720 bitXor,
721
722 /**
723 * Pop the top 2 values from the stack, compute `v1 & v2`, and push the
724 * result back onto the stack.
725 */
726 bitAnd,
727
728 /**
729 * Pop the top 2 values from the stack, compute `v1 | v2`, and push the
730 * result back onto the stack.
731 */
732 bitOr,
733
734 /**
735 * Pop the top 2 values from the stack, compute `v1 >> v2`, and push the
736 * result back onto the stack.
737 */
738 bitShiftRight,
739
740 /**
741 * Pop the top 2 values from the stack, compute `v1 << v2`, and push the
742 * result back onto the stack.
743 */
744 bitShiftLeft,
745
746 /**
747 * Pop the top 2 values from the stack, compute `v1 + v2`, and push the
748 * result back onto the stack.
749 */
750 add,
751
752 /**
753 * Pop the top value from the stack, compute its integer negation, and push
754 * the result back onto the stack.
755 */
756 negate,
757
758 /**
759 * Pop the top 2 values from the stack, compute `v1 - v2`, and push the
760 * result back onto the stack.
761 */
762 subtract,
763
764 /**
765 * Pop the top 2 values from the stack, compute `v1 * v2`, and push the
766 * result back onto the stack.
767 */
768 multiply,
769
770 /**
771 * Pop the top 2 values from the stack, compute `v1 / v2`, and push the
772 * result back onto the stack.
773 */
774 divide,
775
776 /**
777 * Pop the top 2 values from the stack, compute `v1 ~/ v2`, and push the
778 * result back onto the stack.
779 */
780 floorDivide,
781
782 /**
783 * Pop the top 2 values from the stack, compute `v1 > v2`, and push the
784 * result back onto the stack.
785 */
786 greater,
787
788 /**
789 * Pop the top 2 values from the stack, compute `v1 < v2`, and push the
790 * result back onto the stack.
791 */
792 less,
793
794 /**
795 * Pop the top 2 values from the stack, compute `v1 >= v2`, and push the
796 * result back onto the stack.
797 */
798 greaterEqual,
799
800 /**
801 * Pop the top 2 values from the stack, compute `v1 <= v2`, and push the
802 * result back onto the stack.
803 */
804 lessEqual,
805
806 /**
807 * Pop the top 2 values from the stack, compute `v1 % v2`, and push the
808 * result back onto the stack.
809 */
810 modulo,
811
812 /**
813 * Pop the top 3 values from the stack, compute `v1 ? v2 : v3`, and push the
814 * result back onto the stack.
815 */
816 conditional,
817
818 /**
819 * Pop the top value from the stack, evaluate `v.length`, and push the result
820 * back onto the stack.
821 */
822 length,
823 }
824
825 /**
826 * Unlinked summary information about a documentation comment.
827 */
828 class UnlinkedDocumentationComment {
829 /**
830 * Text of the documentation comment, with '\r\n' replaced by '\n'.
831 *
832 * References appearing within the doc comment in square brackets are not
833 * specially encoded.
834 */
835 String text;
836
837 /**
838 * Offset of the beginning of the documentation comment relative to the
839 * beginning of the file.
840 */
841 int offset;
842
843 /**
844 * Length of the documentation comment (prior to replacing '\r\n' with '\n').
845 */
846 int length;
847 }
848
849 /**
850 * Unlinked summary information about an enum declaration.
851 */
852 class UnlinkedEnum {
853 /**
854 * Name of the enum type.
855 */
856 String name;
857
858 /**
859 * Offset of the enum name relative to the beginning of the file.
860 */
861 @informative
862 int nameOffset;
863
864 /**
865 * Documentation comment for the enum, or `null` if there is no documentation
866 * comment.
867 */
868 @informative
869 UnlinkedDocumentationComment documentationComment;
870
871 /**
872 * Values listed in the enum declaration, in declaration order.
873 */
874 List<UnlinkedEnumValue> values;
875 }
876
877 /**
878 * Unlinked summary information about a single enumerated value in an enum
879 * declaration.
880 */
881 class UnlinkedEnumValue {
882 /**
883 * Name of the enumerated value.
884 */
885 String name;
886
887 /**
888 * Offset of the enum value name relative to the beginning of the file.
889 */
890 @informative
891 int nameOffset;
892
893 /**
894 * Documentation comment for the enum value, or `null` if there is no
895 * documentation comment.
896 */
897 @informative
898 UnlinkedDocumentationComment documentationComment;
899 }
900
901 /**
902 * Unlinked summary information about a function, method, getter, or setter
903 * declaration.
904 */
905 class UnlinkedExecutable {
906 /**
907 * Name of the executable. For setters, this includes the trailing "=". For
908 * named constructors, this excludes the class name and excludes the ".".
909 * For unnamed constructors, this is the empty string.
910 */
911 String name;
912
913 /**
914 * Offset of the executable name relative to the beginning of the file. For
915 * named constructors, this excludes the class name and excludes the ".".
916 * For unnamed constructors, this is the offset of the class name (i.e. the
917 * offset of the second "C" in "class C { C(); }").
918 */
919 @informative
920 int nameOffset;
921
922 /**
923 * Documentation comment for the executable, or `null` if there is no
924 * documentation comment.
925 */
926 @informative
927 UnlinkedDocumentationComment documentationComment;
928
929 /**
930 * Type parameters of the executable, if any. Empty if support for generic
931 * method syntax is disabled.
932 */
933 List<UnlinkedTypeParam> typeParameters;
934
935 /**
936 * Declared return type of the executable. Absent if the executable is a
937 * constructor or the return type is implicit.
938 */
939 EntityRef returnType;
940
941 /**
942 * Parameters of the executable, if any. Note that getters have no
943 * parameters (hence this will be the empty list), and setters have a single
944 * parameter.
945 */
946 List<UnlinkedParam> parameters;
947
948 /**
949 * The kind of the executable (function/method, getter, setter, or
950 * constructor).
951 */
952 UnlinkedExecutableKind kind;
953
954 /**
955 * Indicates whether the executable is declared using the `abstract` keyword.
956 */
957 bool isAbstract;
958
959 /**
960 * Indicates whether the executable is declared using the `static` keyword.
961 *
962 * Note that for top level executables, this flag is false, since they are
963 * not declared using the `static` keyword (even though they are considered
964 * static for semantic purposes).
965 */
966 bool isStatic;
967
968 /**
969 * Indicates whether the executable is declared using the `const` keyword.
970 */
971 bool isConst;
972
973 /**
974 * Indicates whether the executable is declared using the `factory` keyword.
975 */
976 bool isFactory;
977
978 /**
979 * Indicates whether the executable is declared using the `external` keyword.
980 */
981 bool isExternal;
982
983 /**
984 * If this executable's return type is inferrable, nonzero slot id
985 * identifying which entry in [LinkedLibrary.types] contains the inferred
986 * return type. If there is no matching entry in [LinkedLibrary.types], then
987 * no return type was inferred for this variable, so its static type is
988 * `dynamic`.
989 */
990 int inferredReturnTypeSlot;
991 }
992
993 /**
994 * Enum used to indicate the kind of an executable.
995 */
996 enum UnlinkedExecutableKind {
997 /**
998 * Executable is a function or method.
999 */
1000 functionOrMethod,
1001
1002 /**
1003 * Executable is a getter.
1004 */
1005 getter,
1006
1007 /**
1008 * Executable is a setter.
1009 */
1010 setter,
1011
1012 /**
1013 * Executable is a constructor.
1014 */
1015 constructor
1016 }
1017
1018 /**
1019 * Unlinked summary information about an export declaration (stored outside
1020 * [UnlinkedPublicNamespace]).
1021 */
1022 class UnlinkedExportNonPublic {
1023 /**
1024 * Offset of the "export" keyword.
1025 */
1026 @informative
1027 int offset;
1028
1029 /**
1030 * Offset of the URI string (including quotes) relative to the beginning of
1031 * the file.
1032 */
1033 @informative
1034 int uriOffset;
1035
1036 /**
1037 * End of the URI string (including quotes) relative to the beginning of the
1038 * file.
1039 */
1040 @informative
1041 int uriEnd;
1042 }
1043
1044 /**
1045 * Unlinked summary information about an export declaration (stored inside
1046 * [UnlinkedPublicNamespace]).
1047 */
1048 class UnlinkedExportPublic {
1049 /**
1050 * URI used in the source code to reference the exported library.
1051 */
1052 String uri;
1053
1054 /**
1055 * Combinators contained in this import declaration.
1056 */
1057 List<UnlinkedCombinator> combinators;
1058 }
1059
1060 /**
1061 * Unlinked summary information about an import declaration.
1062 */
1063 class UnlinkedImport {
1064 /**
1065 * URI used in the source code to reference the imported library.
1066 */
1067 String uri;
1068
1069 /**
1070 * If [isImplicit] is false, offset of the "import" keyword. If [isImplicit]
1071 * is true, zero.
1072 */
1073 @informative
1074 int offset;
1075
1076 /**
1077 * Index into [UnlinkedUnit.references] of the prefix declared by this
1078 * import declaration, or zero if this import declaration declares no prefix.
1079 *
1080 * Note that multiple imports can declare the same prefix.
1081 */
1082 int prefixReference;
1083
1084 /**
1085 * Combinators contained in this import declaration.
1086 */
1087 List<UnlinkedCombinator> combinators;
1088
1089 /**
1090 * Indicates whether the import declaration uses the `deferred` keyword.
1091 */
1092 bool isDeferred;
1093
1094 /**
1095 * Indicates whether the import declaration is implicit.
1096 */
1097 bool isImplicit;
1098
1099 /**
1100 * Offset of the URI string (including quotes) relative to the beginning of
1101 * the file. If [isImplicit] is true, zero.
1102 */
1103 @informative
1104 int uriOffset;
1105
1106 /**
1107 * End of the URI string (including quotes) relative to the beginning of the
1108 * file. If [isImplicit] is true, zero.
1109 */
1110 @informative
1111 int uriEnd;
1112
1113 /**
1114 * Offset of the prefix name relative to the beginning of the file, or zero
1115 * if there is no prefix.
1116 */
1117 @informative
1118 int prefixOffset;
1119 }
1120
1121 /**
1122 * Unlinked summary information about a function parameter.
1123 */
1124 class UnlinkedParam {
1125 /**
1126 * Name of the parameter.
1127 */
1128 String name;
1129
1130 /**
1131 * Offset of the parameter name relative to the beginning of the file.
1132 */
1133 @informative
1134 int nameOffset;
1135
1136 /**
1137 * If [isFunctionTyped] is `true`, the declared return type. If
1138 * [isFunctionTyped] is `false`, the declared type. Absent if the type is
1139 * implicit.
1140 */
1141 EntityRef type;
1142
1143 /**
1144 * If [isFunctionTyped] is `true`, the parameters of the function type.
1145 */
1146 List<UnlinkedParam> parameters;
1147
1148 /**
1149 * Kind of the parameter.
1150 */
1151 UnlinkedParamKind kind;
1152
1153 /**
1154 * Indicates whether this is a function-typed parameter.
1155 */
1156 bool isFunctionTyped;
1157
1158 /**
1159 * Indicates whether this is an initializing formal parameter (i.e. it is
1160 * declared using `this.` syntax).
1161 */
1162 bool isInitializingFormal;
1163
1164 /**
1165 * If this parameter's type is inferrable, nonzero slot id identifying which
1166 * entry in [LinkedLibrary.types] contains the inferred type. If there is no
1167 * matching entry in [LinkedLibrary.types], then no type was inferred for
1168 * this variable, so its static type is `dynamic`.
1169 *
1170 * Note that although strong mode considers initializing formals to be
1171 * inferrable, they are not marked as such in the summary; if their type is
1172 * not specified, they always inherit the static type of the corresponding
1173 * field.
1174 */
1175 int inferredTypeSlot;
1176 }
1177
1178 /**
1179 * Enum used to indicate the kind of a parameter.
1180 */
1181 enum UnlinkedParamKind {
1182 /**
1183 * Parameter is required.
1184 */
1185 required,
1186
1187 /**
1188 * Parameter is positional optional (enclosed in `[]`)
1189 */
1190 positional,
1191
1192 /**
1193 * Parameter is named optional (enclosed in `{}`)
1194 */
1195 named
1196 }
1197
1198 /**
1199 * Unlinked summary information about a part declaration.
1200 */
1201 class UnlinkedPart {
1202 /**
1203 * Offset of the URI string (including quotes) relative to the beginning of
1204 * the file.
1205 */
1206 @informative
1207 int uriOffset;
1208
1209 /**
1210 * End of the URI string (including quotes) relative to the beginning of the
1211 * file.
1212 */
1213 @informative
1214 int uriEnd;
1215 }
1216
1217 /**
1218 * Unlinked summary information about a specific name contributed by a
1219 * compilation unit to a library's public namespace.
1220 *
1221 * TODO(paulberry): some of this information is redundant with information
1222 * elsewhere in the summary. Consider reducing the redundancy to reduce
1223 * summary size.
1224 */
1225 class UnlinkedPublicName {
1226 /**
1227 * The name itself.
1228 */
1229 String name;
1230
1231 /**
1232 * The kind of object referred to by the name.
1233 */
1234 ReferenceKind kind;
1235
1236 /**
1237 * If the entity being referred to is generic, the number of type parameters
1238 * it accepts. Otherwise zero.
1239 */
1240 int numTypeParameters;
1241
1242 /**
1243 * If this [UnlinkedPublicName] is a class, the list of members which can be
1244 * referenced from constants - static constant fields, static methods, and
1245 * constructors. Otherwise empty.
1246 */
1247 List<UnlinkedPublicName> constMembers;
1248 }
1249
1250 /**
1251 * Unlinked summary information about what a compilation unit contributes to a
1252 * library's public namespace. This is the subset of [UnlinkedUnit] that is
1253 * required from dependent libraries in order to perform prelinking.
1254 */
1255 @topLevel
1256 class UnlinkedPublicNamespace {
1257 /**
1258 * Public names defined in the compilation unit.
1259 *
1260 * TODO(paulberry): consider sorting these names to reduce unnecessary
1261 * relinking.
1262 */
1263 List<UnlinkedPublicName> names;
1264
1265 /**
1266 * Export declarations in the compilation unit.
1267 */
1268 List<UnlinkedExportPublic> exports;
1269
1270 /**
1271 * URIs referenced by part declarations in the compilation unit.
1272 */
1273 List<String> parts;
1274 }
1275
1276 /**
1277 * Unlinked summary information about a name referred to in one library that
1278 * might be defined in another.
1279 */
1280 class UnlinkedReference {
1281 /**
1282 * Name of the entity being referred to. For the pseudo-type `dynamic`, the
1283 * string is "dynamic". For the pseudo-type `void`, the string is "void".
1284 */
1285 String name;
1286
1287 /**
1288 * Prefix used to refer to the entity, or zero if no prefix is used. This is
1289 * an index into [UnlinkedUnit.references].
1290 *
1291 * Prefix references must always point backward; that is, for all i, if
1292 * UnlinkedUnit.references[i].prefixReference != 0, then
1293 * UnlinkedUnit.references[i].prefixReference < i.
1294 */
1295 int prefixReference;
1296 }
1297
1298 /**
1299 * Unlinked summary information about a typedef declaration.
1300 */
1301 class UnlinkedTypedef {
1302 /**
1303 * Name of the typedef.
1304 */
1305 String name;
1306
1307 /**
1308 * Offset of the typedef name relative to the beginning of the file.
1309 */
1310 @informative
1311 int nameOffset;
1312
1313 /**
1314 * Documentation comment for the typedef, or `null` if there is no
1315 * documentation comment.
1316 */
1317 @informative
1318 UnlinkedDocumentationComment documentationComment;
1319
1320 /**
1321 * Type parameters of the typedef, if any.
1322 */
1323 List<UnlinkedTypeParam> typeParameters;
1324
1325 /**
1326 * Return type of the typedef.
1327 */
1328 EntityRef returnType;
1329
1330 /**
1331 * Parameters of the executable, if any.
1332 */
1333 List<UnlinkedParam> parameters;
1334 }
1335
1336 /**
1337 * Unlinked summary information about a type parameter declaration.
1338 */
1339 class UnlinkedTypeParam {
1340 /**
1341 * Name of the type parameter.
1342 */
1343 String name;
1344
1345 /**
1346 * Offset of the type parameter name relative to the beginning of the file.
1347 */
1348 @informative
1349 int nameOffset;
1350
1351 /**
1352 * Bound of the type parameter, if a bound is explicitly declared. Otherwise
1353 * null.
1354 */
1355 EntityRef bound;
1356 }
1357
1358 /**
1359 * Unlinked summary information about a compilation unit ("part file").
1360 */
1361 @topLevel
1362 class UnlinkedUnit {
1363 /**
1364 * Name of the library (from a "library" declaration, if present).
1365 */
1366 String libraryName;
1367
1368 /**
1369 * Offset of the library name relative to the beginning of the file (or 0 if
1370 * the library has no name).
1371 */
1372 @informative
1373 int libraryNameOffset;
1374
1375 /**
1376 * Length of the library name as it appears in the source code (or 0 if the
1377 * library has no name).
1378 */
1379 @informative
1380 int libraryNameLength;
1381
1382 /**
1383 * Documentation comment for the library, or `null` if there is no
1384 * documentation comment.
1385 */
1386 @informative
1387 UnlinkedDocumentationComment libraryDocumentationComment;
1388
1389 /**
1390 * Unlinked public namespace of this compilation unit.
1391 */
1392 UnlinkedPublicNamespace publicNamespace;
1393
1394 /**
1395 * Top level and prefixed names referred to by this compilation unit. The
1396 * zeroth element of this array is always populated and is used to represent
1397 * the absence of a reference in places where a reference is optional (for
1398 * example [UnlinkedReference.prefixReference or
1399 * UnlinkedImport.prefixReference]).
1400 */
1401 List<UnlinkedReference> references;
1402
1403 /**
1404 * Classes declared in the compilation unit.
1405 */
1406 List<UnlinkedClass> classes;
1407
1408 /**
1409 * Enums declared in the compilation unit.
1410 */
1411 List<UnlinkedEnum> enums;
1412
1413 /**
1414 * Top level executable objects (functions, getters, and setters) declared in
1415 * the compilation unit.
1416 */
1417 List<UnlinkedExecutable> executables;
1418
1419 /**
1420 * Export declarations in the compilation unit.
1421 */
1422 List<UnlinkedExportNonPublic> exports;
1423
1424 /**
1425 * Import declarations in the compilation unit.
1426 */
1427 List<UnlinkedImport> imports;
1428
1429 /**
1430 * Part declarations in the compilation unit.
1431 */
1432 List<UnlinkedPart> parts;
1433
1434 /**
1435 * Typedefs declared in the compilation unit.
1436 */
1437 List<UnlinkedTypedef> typedefs;
1438
1439 /**
1440 * Top level variables declared in the compilation unit.
1441 */
1442 List<UnlinkedVariable> variables;
1443 }
1444
1445 /**
1446 * Unlinked summary information about a top level variable, local variable, or
1447 * a field.
1448 */
1449 class UnlinkedVariable {
1450 /**
1451 * Name of the variable.
1452 */
1453 String name;
1454
1455 /**
1456 * Offset of the variable name relative to the beginning of the file.
1457 */
1458 @informative
1459 int nameOffset;
1460
1461 /**
1462 * Documentation comment for the variable, or `null` if there is no
1463 * documentation comment.
1464 */
1465 @informative
1466 UnlinkedDocumentationComment documentationComment;
1467
1468 /**
1469 * Declared type of the variable. Absent if the type is implicit.
1470 */
1471 EntityRef type;
1472
1473 /**
1474 * If [isConst] is true, and the variable has an initializer, the constant
1475 * expression in the initializer.
1476 */
1477 UnlinkedConst constExpr;
1478
1479 /**
1480 * Indicates whether the variable is declared using the `static` keyword.
1481 *
1482 * Note that for top level variables, this flag is false, since they are not
1483 * declared using the `static` keyword (even though they are considered
1484 * static for semantic purposes).
1485 */
1486 bool isStatic;
1487
1488 /**
1489 * Indicates whether the variable is declared using the `final` keyword.
1490 */
1491 bool isFinal;
1492
1493 /**
1494 * Indicates whether the variable is declared using the `const` keyword.
1495 */
1496 bool isConst;
1497
1498 /**
1499 * If this variable is propagable, nonzero slot id identifying which entry in
1500 * [LinkedLibrary.types] contains the propagated type for this variable. If
1501 * there is no matching entry in [LinkedLibrary.types], then this variable's
1502 * propagated type is the same as its declared type.
1503 *
1504 * Non-propagable variables have a [propagatedTypeSlot] of zero.
1505 */
1506 int propagatedTypeSlot;
1507
1508 /**
1509 * If this variable is inferrable, nonzero slot id identifying which entry in
1510 * [LinkedLibrary.types] contains the inferred type for this variable. If
1511 * there is no matching entry in [LinkedLibrary.types], then no type was
1512 * inferred for this variable, so its static type is `dynamic`.
1513 */
1514 int inferredTypeSlot;
1515 }
OLDNEW
« no previous file with comments | « pkg/analyzer/tool/summary/generate.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698