Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 /** | 5 /** |
| 6 * This file is an "idl" style description of the summary format. It is not | 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 | 7 * executed directly; instead it is parsed and transformed into code that |
| 8 * implements the summary format. | 8 * implements the summary format. |
| 9 * | 9 * |
| 10 * The code generation process introduces the following non-typical semantics: | 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 | 11 * - Fields of type List are never null, and have a default value of the empty |
| 12 * list. | 12 * list. |
| 13 * - Fields of type int are never null, and have a default value of zero. | 13 * - Fields of type int are never null, and have a default value of zero. |
| 14 * - Fields of type String are never null, and have a default value of ''. | 14 * - Fields of type String are never null, and have a default value of ''. |
| 15 * - Fields of type bool are never null, and have a default value of false. | |
| 16 * - Fields whose type is an enum are never null, and have a default value of | |
| 17 * the first value declared in the enum. | |
| 15 * | 18 * |
| 16 * Terminology used in this document: | 19 * Terminology used in this document: |
| 17 * - "Unlinked" refers to information that can be determined from reading the | 20 * - "Unlinked" refers to information that can be determined from reading the |
| 18 * .dart file for the library itself (including all parts) and no other | 21 * .dart file for the library itself (including all parts) and no other |
| 19 * files. | 22 * files. |
| 20 * - "Prelinked" refers to information that can be determined from reading the | 23 * - "Prelinked" refers to information that can be determined from reading the |
| 21 * unlinked information for the library itself and the unlinked information | 24 * unlinked information for the library itself and the unlinked information |
| 22 * for all direct imports (plus the transitive closure of exports reachable | 25 * for all direct imports (plus the transitive closure of exports reachable |
| 23 * from those direct imports). | 26 * from those direct imports). |
| 24 * - "Linked" refers to information that can be determined only from reading | 27 * - "Linked" refers to information that can be determined only from reading |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 47 * Annotation describing information which is not part of the public API to a | 50 * Annotation describing information which is not part of the public API to a |
| 48 * library; in other words, if this information (or any information it refers | 51 * library; in other words, if this information (or any information it refers |
| 49 * to) changes, libraries outside this one are unaffected. | 52 * to) changes, libraries outside this one are unaffected. |
| 50 * | 53 * |
| 51 * TODO(paulberry): currently the summary format does not contain private | 54 * TODO(paulberry): currently the summary format does not contain private |
| 52 * information. | 55 * information. |
| 53 */ | 56 */ |
| 54 const private = null; | 57 const private = null; |
| 55 | 58 |
| 56 /** | 59 /** |
| 57 * Annotation used to mark possible values of a "flags" field. These will be | |
| 58 * transformed into static constants. | |
| 59 */ | |
| 60 class Flag { | |
| 61 final String name; | |
| 62 final int value; | |
| 63 final String comment; | |
| 64 | |
| 65 const Flag(this.name, this.value, this.comment); | |
| 66 } | |
| 67 | |
| 68 /** | |
| 69 * Information about a dependency that exists between one library and another | 60 * Information about a dependency that exists between one library and another |
| 70 * due to an "import" declaration. | 61 * due to an "import" declaration. |
| 71 */ | 62 */ |
| 72 class PrelinkedDependency { | 63 class PrelinkedDependency { |
| 73 /** | 64 /** |
| 74 * The relative URI used to import one library from the other. | 65 * The relative URI used to import one library from the other. |
| 75 */ | 66 */ |
| 76 String uri; | 67 String uri; |
| 77 } | 68 } |
| 78 | 69 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 106 List<int> importDependencies; | 97 List<int> importDependencies; |
| 107 | 98 |
| 108 /** | 99 /** |
| 109 * For each reference in [UnlinkedLibrary.references], information about how | 100 * For each reference in [UnlinkedLibrary.references], information about how |
| 110 * that reference is resolved. | 101 * that reference is resolved. |
| 111 */ | 102 */ |
| 112 List<PrelinkedReference> references; | 103 List<PrelinkedReference> references; |
| 113 } | 104 } |
| 114 | 105 |
| 115 /** | 106 /** |
| 107 * Enum used to indicate the kind of entity referred to by a | |
| 108 * [PrelinkedReference]. | |
| 109 */ | |
| 110 enum PrelinkedReferenceKind { | |
| 111 /** | |
| 112 * The entity is a class or enum. | |
| 113 */ | |
| 114 classOrEnum, | |
| 115 | |
| 116 /** | |
| 117 * The entity is a typedef. | |
| 118 */ | |
| 119 typedef, | |
| 120 | |
| 121 /** | |
| 122 * The entity is a variable or executable. | |
| 123 */ | |
| 124 other, | |
| 125 | |
| 126 /** | |
| 127 * The entity being referred to does not exist. | |
| 128 */ | |
| 129 unresolved | |
| 130 } | |
| 131 | |
| 132 /** | |
| 116 * Information about the resolution of an [UnlinkedReference]. | 133 * Information about the resolution of an [UnlinkedReference]. |
| 117 */ | 134 */ |
| 118 class PrelinkedReference { | 135 class PrelinkedReference { |
| 119 /** | 136 /** |
| 120 * Index into [UnlinkedLibrary.dependencies] indicating which imported library | 137 * Index into [UnlinkedLibrary.dependencies] indicating which imported library |
| 121 * declares the entity being referred to. | 138 * declares the entity being referred to. |
| 122 */ | 139 */ |
| 123 int dependency; | 140 int dependency; |
| 124 | 141 |
| 125 @Flag('CLASS', 0, | 142 /** |
| 126 'Indicates that the thing being referred to is a class or enum') | 143 * The kind of the entity being referred to. |
| 127 @Flag('TYPEDEF', 1, 'Indicates that the thing being referred to is a typedef') | 144 */ |
| 128 @Flag('OTHER', 2, | 145 PrelinkedReferenceKind kind; |
| 129 'Indicates that the thing being referred to is a variable or executable') | |
| 130 @Flag('UNRESOLVED', 3, | |
| 131 'Indicates that the thing being referred to was not found') | |
| 132 int flags; | |
| 133 } | 146 } |
| 134 | 147 |
| 135 /** | 148 /** |
| 136 * Unlinked summary information about a class declaration. | 149 * Unlinked summary information about a class declaration. |
| 137 */ | 150 */ |
| 138 class UnlinkedClass { | 151 class UnlinkedClass { |
| 139 /** | 152 /** |
| 140 * Name of the class. | 153 * Name of the class. |
| 141 */ | 154 */ |
| 142 String name; | 155 String name; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 173 /** | 186 /** |
| 174 * Field declarations contained in the class. | 187 * Field declarations contained in the class. |
| 175 */ | 188 */ |
| 176 List<UnlinkedVariable> fields; | 189 List<UnlinkedVariable> fields; |
| 177 | 190 |
| 178 /** | 191 /** |
| 179 * Executable objects (methods, getters, and setters) contained in the class. | 192 * Executable objects (methods, getters, and setters) contained in the class. |
| 180 */ | 193 */ |
| 181 List<UnlinkedExecutable> executables; | 194 List<UnlinkedExecutable> executables; |
| 182 | 195 |
| 183 @Flag( | 196 /** |
| 184 'ABSTRACT', 1, 'Set if the class is declared with the `abstract` keyword') | 197 * Indicates whether the class is declared with the `abstract` keyword. |
| 185 @Flag('MIXIN_APP', 2, | 198 */ |
| 186 'Set if the class is declared using mixin appliation syntax') | 199 bool isAbstract; |
| 187 int flags; | 200 |
| 201 /** | |
| 202 * Indicates whether the class is declared using mixin application syntax. | |
| 203 */ | |
| 204 bool isMixinApplication; | |
| 188 } | 205 } |
| 189 | 206 |
| 190 /** | 207 /** |
| 191 * Unlinked summary information about a `show` or `hide` combinator in an | 208 * Unlinked summary information about a `show` or `hide` combinator in an |
| 192 * import or export declaration. | 209 * import or export declaration. |
| 193 */ | 210 */ |
| 194 class UnlinkedCombinator { | 211 class UnlinkedCombinator { |
| 195 /** | 212 /** |
| 196 * List of names which are shown. Empty if this is a `hide` combinator. | 213 * List of names which are shown. Empty if this is a `hide` combinator. |
| 197 */ | 214 */ |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 * declaration. | 247 * declaration. |
| 231 */ | 248 */ |
| 232 class UnlinkedEnumValue { | 249 class UnlinkedEnumValue { |
| 233 /** | 250 /** |
| 234 * Name of the enumerated value. | 251 * Name of the enumerated value. |
| 235 */ | 252 */ |
| 236 String name; | 253 String name; |
| 237 } | 254 } |
| 238 | 255 |
| 239 /** | 256 /** |
| 257 * Enum used to indicate the kind of an executable. | |
| 258 */ | |
| 259 enum UnlinkedExecutableKind { | |
| 260 /** | |
| 261 * Executable is a function or method. | |
| 262 */ | |
| 263 functionOrMethod, | |
| 264 | |
| 265 /** | |
| 266 * Executable is a getter. | |
| 267 */ | |
| 268 getter, | |
| 269 | |
| 270 /** | |
| 271 * Executable is a setter. | |
| 272 */ | |
| 273 setter, | |
| 274 | |
| 275 /** | |
| 276 * Executable is a constructor. | |
| 277 */ | |
| 278 constructor | |
| 279 } | |
| 280 | |
| 281 /** | |
| 240 * Unlinked summary information about a function, method, getter, or setter | 282 * Unlinked summary information about a function, method, getter, or setter |
| 241 * declaration. | 283 * declaration. |
| 242 */ | 284 */ |
| 243 class UnlinkedExecutable { | 285 class UnlinkedExecutable { |
| 244 /** | 286 /** |
| 245 * Name of the executable. For setters, this includes the trailing "=". For | 287 * Name of the executable. For setters, this includes the trailing "=". For |
| 246 * named constructors, this excludes the class name and excludes the ".". | 288 * named constructors, this excludes the class name and excludes the ".". |
| 247 * For unnamed constructors, this is the empty string. | 289 * For unnamed constructors, this is the empty string. |
| 248 */ | 290 */ |
| 249 String name; | 291 String name; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 269 */ | 311 */ |
| 270 UnlinkedTypeRef returnType; | 312 UnlinkedTypeRef returnType; |
| 271 | 313 |
| 272 /** | 314 /** |
| 273 * Parameters of the executable, if any. Note that getters have no | 315 * Parameters of the executable, if any. Note that getters have no |
| 274 * parameters (hence this will be the empty list), and setters have a single | 316 * parameters (hence this will be the empty list), and setters have a single |
| 275 * parameter. | 317 * parameter. |
| 276 */ | 318 */ |
| 277 List<UnlinkedParam> parameters; | 319 List<UnlinkedParam> parameters; |
| 278 | 320 |
| 279 @Flag('FUNCTION', 0, | 321 /** |
| 280 'Indicates that the declaration is for a function or method') | 322 * The kind of the executable (function/method, getter, setter, or |
| 281 @Flag('GETTER', 1, 'Indicates that the declaration is for a getter') | 323 * constructor). |
| 282 @Flag('SETTER', 2, 'Indicates that the declaration is for a setter') | 324 */ |
| 283 @Flag('CONSTRUCTOR', 3, 'Indicates that the declaration is for a constructor') | 325 UnlinkedExecutableKind kind; |
| 284 @Flag('ABSTRACT', 4, 'Set if the declaration lacks a function body') | 326 |
| 285 @Flag('STATIC', 8, 'Set if the declaration includes the `static` keyword') | 327 /** |
| 286 @Flag('CONST', 16, | 328 * Indicates whether the executable is declared using the `abstract` keyword. |
| 287 'Set if the declaration includes the `const` keyword (constructors only)') | 329 */ |
| 288 @Flag('FACTORY', 32, | 330 bool isAbstract; |
| 289 'Set if the declaration includes the `factory` keyword (constructors only) ') | 331 |
| 290 int flags; | 332 /** |
| 333 * Indicates whether the executable is declared using the `static` keyword. | |
| 334 * | |
| 335 * Note that for top level executables, this flag is false, since they are | |
| 336 * not declared using the `static` keyword (even though they are considered | |
| 337 * static for semantic purposes). | |
| 338 */ | |
| 339 bool isStatic; | |
| 340 | |
| 341 /** | |
| 342 * Indicates whether the executable is declared using the `const` keyword. | |
| 343 */ | |
| 344 bool isConst; | |
| 345 | |
| 346 /** | |
| 347 * Indicates whether the executable is declared using the `factory` keyword. | |
| 348 */ | |
| 349 bool isFactory; | |
| 291 } | 350 } |
| 292 | 351 |
| 293 /** | 352 /** |
| 294 * Unlinked summary information about an export declaration. | 353 * Unlinked summary information about an export declaration. |
| 295 */ | 354 */ |
| 296 class UnlinkedExport { | 355 class UnlinkedExport { |
| 297 /** | 356 /** |
| 298 * URI used in the source code to reference the exported library. | 357 * URI used in the source code to reference the exported library. |
| 299 */ | 358 */ |
| 300 String uri; | 359 String uri; |
| 301 | 360 |
| 302 /** | 361 /** |
| 303 * Combinators contained in this import declaration. | 362 * Combinators contained in this import declaration. |
| 304 */ | 363 */ |
| 305 List<UnlinkedCombinator> combinators; | 364 List<UnlinkedCombinator> combinators; |
| 306 } | 365 } |
| 307 | 366 |
| 308 /** | 367 /** |
| 309 * Unlinked summary information about an import declaration. | 368 * Unlinked summary information about an import declaration. |
| 310 */ | 369 */ |
| 311 class UnlinkedImport { | 370 class UnlinkedImport { |
| 312 /** | 371 /** |
| 313 * URI used in the source code to reference the imported library. | 372 * URI used in the source code to reference the imported library. |
| 314 */ | 373 */ |
| 315 String uri; | 374 String uri; |
| 316 | 375 |
| 317 /** | 376 /** |
| 318 * Offset of the "import" keyword. Zero for implicit imports. | 377 * If [isImplicit] is false, offset of the "import" keyword. If [isImplicit] |
| 319 * | 378 * is true, zero. |
| 320 * Note that explicit imports may also have an offset of zero. To | |
| 321 * distinguish explicit from implicit imports, look for the presence of the | |
| 322 * [IMPLICIT] flag. | |
| 323 */ | 379 */ |
| 324 @informative | 380 @informative |
| 325 int offset; | 381 int offset; |
| 326 | 382 |
| 327 /** | 383 /** |
| 328 * Index into [UnlinkedLibrary.prefixes] of the prefix declared by this | 384 * Index into [UnlinkedLibrary.prefixes] of the prefix declared by this |
| 329 * import declaration, or zero if this import declaration declares no prefix. | 385 * import declaration, or zero if this import declaration declares no prefix. |
| 330 * | 386 * |
| 331 * Note that multiple imports can declare the same prefix. | 387 * Note that multiple imports can declare the same prefix. |
| 332 */ | 388 */ |
| 333 int prefix; | 389 int prefix; |
| 334 | 390 |
| 335 /** | 391 /** |
| 336 * Combinators contained in this import declaration. | 392 * Combinators contained in this import declaration. |
| 337 */ | 393 */ |
| 338 List<UnlinkedCombinator> combinators; | 394 List<UnlinkedCombinator> combinators; |
| 339 | 395 |
| 340 @Flag('DEFERRED', 1, 'Set if this declaration uses the `deferred` keyword') | 396 /** |
| 341 @Flag('IMPLICIT', 2, 'Set if this is an implicit import') | 397 * Indicates whether the import declaration uses the `deferred` keyword. |
| 342 int flags; | 398 */ |
| 399 bool isDeferred; | |
| 400 | |
| 401 /** | |
| 402 * Indicates whether the import declaration is implicit. | |
| 403 */ | |
| 404 bool isImplicit; | |
| 343 } | 405 } |
| 344 | 406 |
| 345 /** | 407 /** |
| 346 * Unlinked summary of an entire library. | 408 * Unlinked summary of an entire library. |
| 347 */ | 409 */ |
| 348 class UnlinkedLibrary { | 410 class UnlinkedLibrary { |
| 349 /** | 411 /** |
| 350 * Top level and prefixed names referred to by this library. | 412 * Top level and prefixed names referred to by this library. |
| 351 */ | 413 */ |
| 352 List<UnlinkedReference> references; | 414 List<UnlinkedReference> references; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 399 List<UnlinkedVariable> variables; | 461 List<UnlinkedVariable> variables; |
| 400 | 462 |
| 401 /** | 463 /** |
| 402 * Prefixes introduced by import declarations. The first element in this | 464 * Prefixes introduced by import declarations. The first element in this |
| 403 * array is a pseudo-prefix used by references made with no prefix. | 465 * array is a pseudo-prefix used by references made with no prefix. |
| 404 */ | 466 */ |
| 405 List<UnlinkedPrefix> prefixes; | 467 List<UnlinkedPrefix> prefixes; |
| 406 } | 468 } |
| 407 | 469 |
| 408 /** | 470 /** |
| 471 * Enum used to indicate the kind of a parameter. | |
| 472 */ | |
| 473 enum UnlinkedParamKind { | |
| 474 /** | |
| 475 * Parameter is required. | |
| 476 */ | |
| 477 required, | |
| 478 | |
| 479 /** | |
| 480 * Parameter is positional optional (enclosed in `[]`) | |
| 481 */ | |
| 482 positional, | |
| 483 | |
| 484 /** | |
| 485 * Parameter is named optional (enclosed in `{}`) | |
| 486 */ | |
| 487 named | |
| 488 } | |
| 489 | |
| 490 /** | |
| 409 * Unlinked summary information about a function parameter. | 491 * Unlinked summary information about a function parameter. |
| 410 */ | 492 */ |
| 411 class UnlinkedParam { | 493 class UnlinkedParam { |
| 412 /** | 494 /** |
| 413 * Name of the parameter. | 495 * Name of the parameter. |
| 414 */ | 496 */ |
| 415 String name; | 497 String name; |
| 416 | 498 |
| 417 /** | 499 /** |
| 418 * If this is a function-typed parameter, the declared return type. | 500 * If [isFunctionTyped] is `true`, the declared return type. If |
| 419 * Otherwise, the declared type. Absent if this is a function-typed | 501 * [isFunctionTyped] is `false`, the declared type. Absent if |
| 420 * parameter and the declared return type is `void`. Note that when strong | 502 * [isFunctionTyped] is `true` and the declared return type is `void`. Note |
| 421 * mode is enabled, the actual type may be different due to type inference. | 503 * that when strong mode is enabled, the actual type may be different due to |
| 504 * type inference. | |
| 422 */ | 505 */ |
| 423 UnlinkedTypeRef type; | 506 UnlinkedTypeRef type; |
| 424 | 507 |
| 425 /** | 508 /** |
| 426 * If this is a function-typed parameter, the parameters of the function | 509 * If [isFunctionTyped] is `true`, the parameters of the function type. |
| 427 * type. | |
| 428 */ | 510 */ |
| 429 List<UnlinkedParam> parameters; | 511 List<UnlinkedParam> parameters; |
| 430 | 512 |
| 431 @Flag('REQUIRED', 0, 'Indicates that this is a required parameter') | 513 /** |
| 432 @Flag( | 514 * Kind of the parameter. |
| 433 'POSITIONAL', 1, 'Indicates that this is a positional optional parameter') | 515 */ |
| 434 @Flag('NAMED', 2, 'Indicates that this is a named optional parameter') | 516 UnlinkedParamKind kind; |
| 435 @Flag('FUNCTION_TYPED', 4, 'Set if this is a function-typed parameter') | 517 |
| 436 @Flag('INITIALIZING_FORMAL', 8, | 518 /** |
| 437 'Set if this is an initializing formal parameter') | 519 * Indicates whether this is a function-typed parameter. |
| 438 int flags; | 520 */ |
| 521 bool isFunctionTyped; | |
| 522 | |
| 523 /** | |
| 524 * Indicates whether this is an initializing formal parameter (i.e. it is | |
| 525 * declared using `this.` syntax). | |
| 526 */ | |
| 527 bool isInitializingFormal; | |
| 439 } | 528 } |
| 440 | 529 |
| 441 class UnlinkedPrefix { | 530 class UnlinkedPrefix { |
| 442 /** | 531 /** |
| 443 * The name of the prefix, or the empty string in the case of the | 532 * The name of the prefix, or the empty string in the case of the |
| 444 * pseudo-prefix which represents "no prefix". | 533 * pseudo-prefix which represents "no prefix". |
| 445 */ | 534 */ |
| 446 String name; | 535 String name; |
| 447 } | 536 } |
| 448 | 537 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 575 */ | 664 */ |
| 576 @informative | 665 @informative |
| 577 int unit; | 666 int unit; |
| 578 | 667 |
| 579 /** | 668 /** |
| 580 * Declared type of the variable. Note that when strong mode is enabled, the | 669 * Declared type of the variable. Note that when strong mode is enabled, the |
| 581 * actual type of the variable may be different due to type inference. | 670 * actual type of the variable may be different due to type inference. |
| 582 */ | 671 */ |
| 583 UnlinkedTypeRef type; | 672 UnlinkedTypeRef type; |
| 584 | 673 |
| 585 @Flag('STATIC', 1, 'Set if the declaration includes the `static` keyword') | 674 /** |
| 586 @Flag('FINAL', 2, 'Set if the declaration includes the `final` keyword') | 675 * Indicates whether the variable is declared using the `static` keyword. |
| 587 @Flag('CONST', 4, 'Set if the declaration includes the `const` keyword') | 676 * |
| 588 int flags; | 677 * Note that for top level variables, this flag is false, since they are not |
| 678 * declared using the `static` keyword (even though they are considered | |
| 679 * static for semantic purposes). | |
| 680 */ | |
| 681 bool isStatic; | |
| 682 | |
| 683 /** | |
| 684 * Indicates whether the variable is declared using the `final` keyword. | |
| 685 */ | |
| 686 bool isFinal; | |
| 687 | |
| 688 /** | |
| 689 * Indicates whether the variable is declared using the `factory` keyword. | |
| 690 */ | |
| 691 bool isFactory; | |
|
Brian Wilkerson
2015/10/21 20:21:08
I think this should be "isConst".
| |
| 589 } | 692 } |
| OLD | NEW |