OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // For the purposes of the mirrors library, we adopt a naming | 5 // For the purposes of the mirrors library, we adopt a naming |
6 // convention with respect to getters and setters. Specifically, for | 6 // convention with respect to getters and setters. Specifically, for |
7 // some variable or field... | 7 // some variable or field... |
8 // | 8 // |
9 // var myField; | 9 // var myField; |
10 // | 10 // |
(...skipping 16 matching lines...) Expand all Loading... | |
27 * of libraries which are not running -- perhaps at compile-time. In | 27 * of libraries which are not running -- perhaps at compile-time. In |
28 * this case, all available reflective functionality would be | 28 * this case, all available reflective functionality would be |
29 * supported, but runtime functionality (such as invoking a function | 29 * supported, but runtime functionality (such as invoking a function |
30 * or inspecting the contents of a variable) would fail dynamically. | 30 * or inspecting the contents of a variable) would fail dynamically. |
31 */ | 31 */ |
32 abstract class MirrorSystem { | 32 abstract class MirrorSystem { |
33 /** | 33 /** |
34 * An immutable map from from library names to mirrors for all | 34 * An immutable map from from library names to mirrors for all |
35 * libraries known to this mirror system. | 35 * libraries known to this mirror system. |
36 */ | 36 */ |
37 Map<String, LibraryMirror> get libraries; | 37 Map<Symbol, LibraryMirror> get libraries; |
gbracha
2013/04/11 18:12:20
So, didn't we just change this to be a map of URIs
ahe
2013/04/11 20:12:27
The CL from Johnni was to modify the copy of this
| |
38 | 38 |
39 /** | 39 /** |
40 * A mirror on the isolate associated with this [MirrorSystem]. | 40 * A mirror on the isolate associated with this [MirrorSystem]. |
41 * This may be null if this mirror system is not running. | 41 * This may be null if this mirror system is not running. |
42 */ | 42 */ |
43 IsolateMirror get isolate; | 43 IsolateMirror get isolate; |
44 | 44 |
45 /** | 45 /** |
46 * A mirror on the [:dynamic:] type. | 46 * A mirror on the [:dynamic:] type. |
47 */ | 47 */ |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 * A [DeclarationMirror] reflects some entity declared in a Dart program. | 108 * A [DeclarationMirror] reflects some entity declared in a Dart program. |
109 */ | 109 */ |
110 abstract class DeclarationMirror implements Mirror { | 110 abstract class DeclarationMirror implements Mirror { |
111 /** | 111 /** |
112 * The simple name for this Dart language entity. | 112 * The simple name for this Dart language entity. |
113 * | 113 * |
114 * The simple name is in most cases the the identifier name of the | 114 * The simple name is in most cases the the identifier name of the |
115 * entity, such as 'method' for a method [:void method() {...}:] or | 115 * entity, such as 'method' for a method [:void method() {...}:] or |
116 * 'mylibrary' for a [:#library('mylibrary');:] declaration. | 116 * 'mylibrary' for a [:#library('mylibrary');:] declaration. |
117 */ | 117 */ |
118 String get simpleName; | 118 Symbol get simpleName; |
119 | 119 |
120 /** | 120 /** |
121 * The fully-qualified name for this Dart language entity. | 121 * The fully-qualified name for this Dart language entity. |
122 * | 122 * |
123 * This name is qualified by the name of the owner. For instance, | 123 * This name is qualified by the name of the owner. For instance, |
124 * the qualified name of a method 'method' in class 'Class' in | 124 * the qualified name of a method 'method' in class 'Class' in |
125 * library 'library' is 'library.Class.method'. | 125 * library 'library' is 'library.Class.method'. |
126 * | 126 * |
127 * TODO(turnidge): Specify whether this name is unique. Currently | 127 * TODO(turnidge): Specify whether this name is unique. Currently |
128 * this is a gray area due to lack of clarity over whether library | 128 * this is a gray area due to lack of clarity over whether library |
129 * names are unique. | 129 * names are unique. |
130 */ | 130 */ |
131 String get qualifiedName; | 131 Symbol get qualifiedName; |
132 | 132 |
133 /** | 133 /** |
134 * A mirror on the owner of this function. This is the declaration | 134 * A mirror on the owner of this function. This is the declaration |
135 * immediately surrounding the reflectee. | 135 * immediately surrounding the reflectee. |
136 * | 136 * |
137 * Note that for libraries, the owner will be [:null:]. | 137 * Note that for libraries, the owner will be [:null:]. |
138 */ | 138 */ |
139 DeclarationMirror get owner; | 139 DeclarationMirror get owner; |
140 | 140 |
141 /** | 141 /** |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 abstract class ObjectMirror implements Mirror { | 174 abstract class ObjectMirror implements Mirror { |
175 /** | 175 /** |
176 * Invokes the named function and returns a mirror on the result. | 176 * Invokes the named function and returns a mirror on the result. |
177 * The arguments must be instances of [InstanceMirror], [num], | 177 * The arguments must be instances of [InstanceMirror], [num], |
178 * [String] or [bool]. | 178 * [String] or [bool]. |
179 */ | 179 */ |
180 /* TODO(turnidge): Properly document. | 180 /* TODO(turnidge): Properly document. |
181 * TODO(turnidge): Handle ambiguous names. | 181 * TODO(turnidge): Handle ambiguous names. |
182 * TODO(turnidge): Handle optional & named arguments. | 182 * TODO(turnidge): Handle optional & named arguments. |
183 */ | 183 */ |
184 Future<InstanceMirror> invokeAsync(String memberName, | 184 Future<InstanceMirror> invokeAsync(Symbol memberName, |
185 List<Object> positionalArguments, | 185 List<Object> positionalArguments, |
186 [Map<String,Object> namedArguments]); | 186 [Map<Symbol,Object> namedArguments]); |
gbracha
2013/04/11 18:12:20
Just an observation: this is an excellent example
ahe
2013/04/11 20:12:27
I agree. I had the same issue when updating Funct
| |
187 | 187 |
188 /** | 188 /** |
189 * Invokes a getter and returns a mirror on the result. The getter | 189 * Invokes a getter and returns a mirror on the result. The getter |
190 * can be the implicit getter for a field or a user-defined getter | 190 * can be the implicit getter for a field or a user-defined getter |
191 * method. | 191 * method. |
192 */ | 192 */ |
193 /* TODO(turnidge): Handle ambiguous names.*/ | 193 /* TODO(turnidge): Handle ambiguous names.*/ |
194 Future<InstanceMirror> getFieldAsync(String fieldName); | 194 Future<InstanceMirror> getFieldAsync(Symbol fieldName); |
195 | 195 |
196 /** | 196 /** |
197 * Invokes a setter and returns a mirror on the result. The setter | 197 * Invokes a setter and returns a mirror on the result. The setter |
198 * may be either the implicit setter for a non-final field or a | 198 * may be either the implicit setter for a non-final field or a |
199 * user-defined setter method. | 199 * user-defined setter method. |
200 * The argument must be an instance of either [InstanceMirror], [num], | 200 * The argument must be an instance of either [InstanceMirror], [num], |
201 * [String] or [bool]. | 201 * [String] or [bool]. |
202 */ | 202 */ |
203 /* TODO(turnidge): Handle ambiguous names.*/ | 203 /* TODO(turnidge): Handle ambiguous names.*/ |
204 Future<InstanceMirror> setFieldAsync(String fieldName, Object value); | 204 Future<InstanceMirror> setFieldAsync(Symbol fieldName, Object value); |
205 } | 205 } |
206 | 206 |
207 /** | 207 /** |
208 * An [InstanceMirror] reflects an instance of a Dart language object. | 208 * An [InstanceMirror] reflects an instance of a Dart language object. |
209 */ | 209 */ |
210 abstract class InstanceMirror implements ObjectMirror { | 210 abstract class InstanceMirror implements ObjectMirror { |
211 /** | 211 /** |
212 * A mirror on the type of the reflectee. | 212 * A mirror on the type of the reflectee. |
213 */ | 213 */ |
214 ClassMirror get type; | 214 ClassMirror get type; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
256 * TODO(turnidge): Would this just be available in function? | 256 * TODO(turnidge): Would this just be available in function? |
257 */ | 257 */ |
258 String get source; | 258 String get source; |
259 | 259 |
260 /** | 260 /** |
261 * Executes the closure. | 261 * Executes the closure. |
262 * The arguments must be instances of [InstanceMirror], [num], | 262 * The arguments must be instances of [InstanceMirror], [num], |
263 * [String] or [bool]. | 263 * [String] or [bool]. |
264 */ | 264 */ |
265 Future<InstanceMirror> applyAsync(List<Object> positionalArguments, | 265 Future<InstanceMirror> applyAsync(List<Object> positionalArguments, |
266 [Map<String,Object> namedArguments]); | 266 [Map<Symbol,Object> namedArguments]); |
267 | 267 |
268 /** | 268 /** |
269 * Looks up the value of a name in the scope of the closure. The | 269 * Looks up the value of a name in the scope of the closure. The |
270 * result is a mirror on that value. | 270 * result is a mirror on that value. |
271 */ | 271 */ |
272 Future<InstanceMirror> findInContext(String name); | 272 Future<InstanceMirror> findInContext(Symbol name); |
273 } | 273 } |
274 | 274 |
275 /** | 275 /** |
276 * A [LibraryMirror] reflects a Dart language library, providing | 276 * A [LibraryMirror] reflects a Dart language library, providing |
277 * access to the variables, functions, and classes of the | 277 * access to the variables, functions, and classes of the |
278 * library. | 278 * library. |
279 */ | 279 */ |
280 abstract class LibraryMirror implements DeclarationMirror, ObjectMirror { | 280 abstract class LibraryMirror implements DeclarationMirror, ObjectMirror { |
281 /** | 281 /** |
282 * The url of the library. | 282 * The url of the library. |
283 * | 283 * |
284 * TODO(turnidge): Document where this url comes from. Will this | 284 * TODO(turnidge): Document where this url comes from. Will this |
285 * value be sensible? | 285 * value be sensible? |
286 */ | 286 */ |
287 String get url; | 287 String get url; |
288 | 288 |
289 /** | 289 /** |
290 * An immutable map from from names to mirrors for all members in | 290 * An immutable map from from names to mirrors for all members in |
291 * this library. | 291 * this library. |
292 * | 292 * |
293 * The members of a library are its top-level classes, | 293 * The members of a library are its top-level classes, |
294 * functions, variables, getters, and setters. | 294 * functions, variables, getters, and setters. |
295 */ | 295 */ |
296 Map<String, Mirror> get members; | 296 Map<Symbol, Mirror> get members; |
297 | 297 |
298 /** | 298 /** |
299 * An immutable map from names to mirrors for all class | 299 * An immutable map from names to mirrors for all class |
300 * declarations in this library. | 300 * declarations in this library. |
301 */ | 301 */ |
302 Map<String, ClassMirror> get classes; | 302 Map<Symbol, ClassMirror> get classes; |
303 | 303 |
304 /** | 304 /** |
305 * An immutable map from names to mirrors for all function, getter, | 305 * An immutable map from names to mirrors for all function, getter, |
306 * and setter declarations in this library. | 306 * and setter declarations in this library. |
307 */ | 307 */ |
308 Map<String, MethodMirror> get functions; | 308 Map<Symbol, MethodMirror> get functions; |
309 | 309 |
310 /** | 310 /** |
311 * An immutable map from names to mirrors for all getter | 311 * An immutable map from names to mirrors for all getter |
312 * declarations in this library. | 312 * declarations in this library. |
313 */ | 313 */ |
314 Map<String, MethodMirror> get getters; | 314 Map<Symbol, MethodMirror> get getters; |
315 | 315 |
316 /** | 316 /** |
317 * An immutable map from names to mirrors for all setter | 317 * An immutable map from names to mirrors for all setter |
318 * declarations in this library. | 318 * declarations in this library. |
319 */ | 319 */ |
320 Map<String, MethodMirror> get setters; | 320 Map<Symbol, MethodMirror> get setters; |
321 | 321 |
322 /** | 322 /** |
323 * An immutable map from names to mirrors for all variable | 323 * An immutable map from names to mirrors for all variable |
324 * declarations in this library. | 324 * declarations in this library. |
325 */ | 325 */ |
326 Map<String, VariableMirror> get variables; | 326 Map<Symbol, VariableMirror> get variables; |
327 } | 327 } |
328 | 328 |
329 /** | 329 /** |
330 * A [TypeMirror] reflects a Dart language class, typedef | 330 * A [TypeMirror] reflects a Dart language class, typedef |
331 * or type variable. | 331 * or type variable. |
332 */ | 332 */ |
333 abstract class TypeMirror implements DeclarationMirror { | 333 abstract class TypeMirror implements DeclarationMirror { |
334 } | 334 } |
335 | 335 |
336 /** | 336 /** |
(...skipping 16 matching lines...) Expand all Loading... | |
353 /** | 353 /** |
354 * An immutable map from from names to mirrors for all members of | 354 * An immutable map from from names to mirrors for all members of |
355 * this type. | 355 * this type. |
356 * | 356 * |
357 * The members of a type are its methods, fields, getters, and | 357 * The members of a type are its methods, fields, getters, and |
358 * setters. Note that constructors and type variables are not | 358 * setters. Note that constructors and type variables are not |
359 * considered to be members of a type. | 359 * considered to be members of a type. |
360 * | 360 * |
361 * This does not include inherited members. | 361 * This does not include inherited members. |
362 */ | 362 */ |
363 Map<String, Mirror> get members; | 363 Map<Symbol, Mirror> get members; |
364 | 364 |
365 /** | 365 /** |
366 * An immutable map from names to mirrors for all method, | 366 * An immutable map from names to mirrors for all method, |
367 * declarations for this type. This does not include getters and | 367 * declarations for this type. This does not include getters and |
368 * setters. | 368 * setters. |
369 */ | 369 */ |
370 Map<String, MethodMirror> get methods; | 370 Map<Symbol, MethodMirror> get methods; |
371 | 371 |
372 /** | 372 /** |
373 * An immutable map from names to mirrors for all getter | 373 * An immutable map from names to mirrors for all getter |
374 * declarations for this type. | 374 * declarations for this type. |
375 */ | 375 */ |
376 Map<String, MethodMirror> get getters; | 376 Map<Symbol, MethodMirror> get getters; |
377 | 377 |
378 /** | 378 /** |
379 * An immutable map from names to mirrors for all setter | 379 * An immutable map from names to mirrors for all setter |
380 * declarations for this type. | 380 * declarations for this type. |
381 */ | 381 */ |
382 Map<String, MethodMirror> get setters; | 382 Map<Symbol, MethodMirror> get setters; |
383 | 383 |
384 /** | 384 /** |
385 * An immutable map from names to mirrors for all variable | 385 * An immutable map from names to mirrors for all variable |
386 * declarations for this type. | 386 * declarations for this type. |
387 */ | 387 */ |
388 Map<String, VariableMirror> get variables; | 388 Map<Symbol, VariableMirror> get variables; |
389 | 389 |
390 /** | 390 /** |
391 * An immutable map from names to mirrors for all constructor | 391 * An immutable map from names to mirrors for all constructor |
392 * declarations for this type. | 392 * declarations for this type. |
393 */ | 393 */ |
394 Map<String, MethodMirror> get constructors; | 394 Map<Symbol, MethodMirror> get constructors; |
395 | 395 |
396 /** | 396 /** |
397 * An immutable map from names to mirrors for all type variables for | 397 * An immutable map from names to mirrors for all type variables for |
398 * this type. | 398 * this type. |
399 * | 399 * |
400 * This map preserves the order of declaration of the type variables. | 400 * This map preserves the order of declaration of the type variables. |
401 */ | 401 */ |
402 Map<String, TypeVariableMirror> get typeVariables; | 402 Map<Symbol, TypeVariableMirror> get typeVariables; |
403 | 403 |
404 /** | 404 /** |
405 * An immutable map from names to mirrors for all type arguments for | 405 * An immutable map from names to mirrors for all type arguments for |
406 * this type. | 406 * this type. |
407 * | 407 * |
408 * This map preserves the order of declaration of the type variables. | 408 * This map preserves the order of declaration of the type variables. |
409 */ | 409 */ |
410 Map<String, TypeMirror> get typeArguments; | 410 Map<Symbol, TypeMirror> get typeArguments; |
411 | 411 |
412 /** | 412 /** |
413 * Is this the original declaration of this type? | 413 * Is this the original declaration of this type? |
414 * | 414 * |
415 * For most classes, they are their own original declaration. For | 415 * For most classes, they are their own original declaration. For |
416 * generic classes, however, there is a distinction between the | 416 * generic classes, however, there is a distinction between the |
417 * original class declaration, which has unbound type variables, and | 417 * original class declaration, which has unbound type variables, and |
418 * the instantiations of generic classes, which have bound type | 418 * the instantiations of generic classes, which have bound type |
419 * variables. | 419 * variables. |
420 */ | 420 */ |
421 bool get isOriginalDeclaration; | 421 bool get isOriginalDeclaration; |
422 | 422 |
423 /** | 423 /** |
424 * A mirror on the original declaration of this type. | 424 * A mirror on the original declaration of this type. |
425 * | 425 * |
426 * For most classes, they are their own original declaration. For | 426 * For most classes, they are their own original declaration. For |
427 * generic classes, however, there is a distinction between the | 427 * generic classes, however, there is a distinction between the |
428 * original class declaration, which has unbound type variables, and | 428 * original class declaration, which has unbound type variables, and |
429 * the instantiations of generic classes, which have bound type | 429 * the instantiations of generic classes, which have bound type |
430 * variables. | 430 * variables. |
431 */ | 431 */ |
432 ClassMirror get originalDeclaration; | 432 ClassMirror get originalDeclaration; |
433 | 433 |
434 /** | 434 /** |
435 * Invokes the named constructor and returns a mirror on the result. | 435 * Invokes the named constructor and returns a mirror on the result. |
436 * The arguments must be instances of [InstanceMirror], [num], | 436 * The arguments must be instances of [InstanceMirror], [num], |
437 */ | 437 */ |
438 /* TODO(turnidge): Properly document.*/ | 438 /* TODO(turnidge): Properly document.*/ |
439 Future<InstanceMirror> newInstanceAsync(String constructorName, | 439 Future<InstanceMirror> newInstanceAsync(Symbol constructorName, |
440 List<Object> positionalArguments, | 440 List<Object> positionalArguments, |
441 [Map<String,Object> namedArguments]); | 441 [Map<Symbol,Object> namedArguments]); |
442 | 442 |
443 /** | 443 /** |
444 * Does this mirror represent a class? | 444 * Does this mirror represent a class? |
445 * | 445 * |
446 * TODO(turnidge): This functions goes away after the | 446 * TODO(turnidge): This functions goes away after the |
447 * class/interface changes. | 447 * class/interface changes. |
448 */ | 448 */ |
449 bool get isClass; | 449 bool get isClass; |
450 | 450 |
451 /** | 451 /** |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
562 | 562 |
563 /** | 563 /** |
564 * The constructor name for named constructors and factory methods. | 564 * The constructor name for named constructors and factory methods. |
565 * | 565 * |
566 * For unnamed constructors, this is the empty string. For | 566 * For unnamed constructors, this is the empty string. For |
567 * non-constructors, this is the empty string. | 567 * non-constructors, this is the empty string. |
568 * | 568 * |
569 * For example, [:'bar':] is the constructor name for constructor | 569 * For example, [:'bar':] is the constructor name for constructor |
570 * [:Foo.bar:] of type [:Foo:]. | 570 * [:Foo.bar:] of type [:Foo:]. |
571 */ | 571 */ |
572 String get constructorName; | 572 Symbol get constructorName; |
573 | 573 |
574 /** | 574 /** |
575 * Is the reflectee a const constructor? | 575 * Is the reflectee a const constructor? |
576 */ | 576 */ |
577 bool get isConstConstructor; | 577 bool get isConstConstructor; |
578 | 578 |
579 /** | 579 /** |
580 * Is the reflectee a generative constructor? | 580 * Is the reflectee a generative constructor? |
581 */ | 581 */ |
582 bool get isGenerativeConstructor; | 582 bool get isGenerativeConstructor; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
634 */ | 634 */ |
635 bool get isNamed; | 635 bool get isNamed; |
636 | 636 |
637 /** | 637 /** |
638 * Does this parameter have a default value? | 638 * Does this parameter have a default value? |
639 */ | 639 */ |
640 bool get hasDefaultValue; | 640 bool get hasDefaultValue; |
641 | 641 |
642 /** | 642 /** |
643 * A mirror on the default value for this parameter, if it exists. | 643 * A mirror on the default value for this parameter, if it exists. |
644 * | |
645 * TODO(turnidge): String may not be a good representation of this | |
646 * at runtime. | |
647 */ | 644 */ |
645 // TODO(ahe): This should return an InstanceMirror. | |
648 String get defaultValue; | 646 String get defaultValue; |
649 } | 647 } |
650 | 648 |
651 /** | 649 /** |
652 * A [SourceLocation] describes the span of an entity in Dart source code. | 650 * A [SourceLocation] describes the span of an entity in Dart source code. |
653 */ | 651 */ |
654 abstract class SourceLocation { | 652 abstract class SourceLocation { |
655 } | 653 } |
656 | 654 |
657 /** | 655 /** |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
756 /** | 754 /** |
757 * Is [:true:] if this comment is a documentation comment. | 755 * Is [:true:] if this comment is a documentation comment. |
758 * | 756 * |
759 * That is, that the comment is either enclosed in [: /** ... */ :] or starts | 757 * That is, that the comment is either enclosed in [: /** ... */ :] or starts |
760 * with [: /// :]. | 758 * with [: /// :]. |
761 */ | 759 */ |
762 final bool isDocComment; | 760 final bool isDocComment; |
763 | 761 |
764 const Comment(this.text, this.trimmedText, this.isDocComment); | 762 const Comment(this.text, this.trimmedText, this.isDocComment); |
765 } | 763 } |
OLD | NEW |