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

Side by Side Diff: runtime/lib/mirrors_impl.dart

Issue 10919146: Get rid of a lot of () for getters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « runtime/lib/isolate_patch.dart ('k') | runtime/lib/regexp_patch.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 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 // VM-specific implementation of the dart:mirrors library. 5 // VM-specific implementation of the dart:mirrors library.
6 6
7 // These values are allowed to be passed directly over the wire. 7 // These values are allowed to be passed directly over the wire.
8 bool isSimpleValue(var value) { 8 bool isSimpleValue(var value) {
9 return (value === null || value is num || value is String || value is bool); 9 return (value === null || value is num || value is String || value is bool);
10 } 10 }
11 11
12 Map filterMap(Map old_map, bool filter(key, value)) { 12 Map filterMap(Map old_map, bool filter(key, value)) {
13 Map new_map = new Map(); 13 Map new_map = new Map();
14 old_map.forEach((key, value) { 14 old_map.forEach((key, value) {
15 if (filter(key, value)) { 15 if (filter(key, value)) {
16 new_map[key] = value; 16 new_map[key] = value;
17 } 17 }
18 }); 18 });
19 return new_map; 19 return new_map;
20 } 20 }
21 21
22 class _LocalMirrorSystemImpl implements MirrorSystem { 22 class _LocalMirrorSystemImpl implements MirrorSystem {
23 _LocalMirrorSystemImpl(this.libraries, this.isolate) {} 23 _LocalMirrorSystemImpl(this.libraries, this.isolate) {}
24 24
25 final Map<String, LibraryMirror> libraries; 25 final Map<String, LibraryMirror> libraries;
26 final IsolateMirror isolate; 26 final IsolateMirror isolate;
27 27
28 TypeMirror _dynamicType = null; 28 TypeMirror _dynamicType = null;
29 29
30 TypeMirror get dynamicType() { 30 TypeMirror get dynamicType {
31 if (_dynamicType === null) { 31 if (_dynamicType === null) {
32 _dynamicType = 32 _dynamicType =
33 new _LocalClassMirrorImpl( 33 new _LocalClassMirrorImpl(
34 null, 'Dynamic', false, null, null, [], null, const {}); 34 null, 'Dynamic', false, null, null, [], null, const {});
35 } 35 }
36 return _dynamicType; 36 return _dynamicType;
37 } 37 }
38 38
39 TypeMirror _voidType = null; 39 TypeMirror _voidType = null;
40 40
41 TypeMirror get voidType() { 41 TypeMirror get voidType {
42 if (_voidType === null) { 42 if (_voidType === null) {
43 _voidType = 43 _voidType =
44 new _LocalClassMirrorImpl( 44 new _LocalClassMirrorImpl(
45 null, 'void', false, null, null, [], null, const {}); 45 null, 'void', false, null, null, [], null, const {});
46 } 46 }
47 return _voidType; 47 return _voidType;
48 } 48 }
49 49
50 String toString() => "MirrorSystem for isolate '${isolate.debugName}'"; 50 String toString() => "MirrorSystem for isolate '${isolate.debugName}'";
51 } 51 }
52 52
53 abstract class _LocalMirrorImpl implements Mirror { 53 abstract class _LocalMirrorImpl implements Mirror {
54 int hashCode() { 54 int hashCode() {
55 throw new NotImplementedException('Mirror.hashCode() not yet implemented'); 55 throw new NotImplementedException('Mirror.hashCode() not yet implemented');
56 } 56 }
57 57
58 // Local mirrors always return the same MirrorSystem. This field 58 // Local mirrors always return the same MirrorSystem. This field
59 // is more interesting once we implement remote mirrors. 59 // is more interesting once we implement remote mirrors.
60 MirrorSystem get mirrors() => _Mirrors.currentMirrorSystem(); 60 MirrorSystem get mirrors => _Mirrors.currentMirrorSystem();
61 } 61 }
62 62
63 class _LocalIsolateMirrorImpl extends _LocalMirrorImpl 63 class _LocalIsolateMirrorImpl extends _LocalMirrorImpl
64 implements IsolateMirror { 64 implements IsolateMirror {
65 _LocalIsolateMirrorImpl(this.debugName, this._rootLibrary) {} 65 _LocalIsolateMirrorImpl(this.debugName, this._rootLibrary) {}
66 66
67 final String debugName; 67 final String debugName;
68 final bool isCurrent = true; 68 final bool isCurrent = true;
69 69
70 var _rootLibrary; 70 var _rootLibrary;
71 LibraryMirror get rootLibrary() { 71 LibraryMirror get rootLibrary {
72 if (_rootLibrary is _LazyLibraryMirror) { 72 if (_rootLibrary is _LazyLibraryMirror) {
73 _rootLibrary = _rootLibrary.resolve(mirrors); 73 _rootLibrary = _rootLibrary.resolve(mirrors);
74 } 74 }
75 return _rootLibrary; 75 return _rootLibrary;
76 } 76 }
77 77
78 String toString() => "IsolateMirror on '$debugName'"; 78 String toString() => "IsolateMirror on '$debugName'";
79 } 79 }
80 80
81 // A VMReference is used to hold a reference to a VM-internal object, 81 // A VMReference is used to hold a reference to a VM-internal object,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 return buf.toString(); 213 return buf.toString();
214 } 214 }
215 215
216 class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl 216 class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl
217 implements InstanceMirror { 217 implements InstanceMirror {
218 _LocalInstanceMirrorImpl(ref, 218 _LocalInstanceMirrorImpl(ref,
219 this._type, 219 this._type,
220 this._reflectee) : super(ref) {} 220 this._reflectee) : super(ref) {}
221 221
222 var _type; 222 var _type;
223 ClassMirror get type() { 223 ClassMirror get type {
224 if (_type is _LazyClassMirror) { 224 if (_type is _LazyClassMirror) {
225 _type = _type.resolve(mirrors); 225 _type = _type.resolve(mirrors);
226 } 226 }
227 return _type; 227 return _type;
228 } 228 }
229 229
230 // LocalInstanceMirrors always reflect local instances 230 // LocalInstanceMirrors always reflect local instances
231 bool hasReflectee = true; 231 bool hasReflectee = true;
232 232
233 var _reflectee; 233 var _reflectee;
234 get reflectee() => _reflectee; 234 get reflectee => _reflectee;
235 235
236 String toString() { 236 String toString() {
237 if (isSimpleValue(_reflectee)) { 237 if (isSimpleValue(_reflectee)) {
238 if (_reflectee is String) { 238 if (_reflectee is String) {
239 return "InstanceMirror on <'${_dartEscape(_reflectee)}'>"; 239 return "InstanceMirror on <'${_dartEscape(_reflectee)}'>";
240 } else { 240 } else {
241 return "InstanceMirror on <$_reflectee>"; 241 return "InstanceMirror on <$_reflectee>";
242 } 242 }
243 } else { 243 } else {
244 return "InstanceMirror on instance of '${type.simpleName}'"; 244 return "InstanceMirror on instance of '${type.simpleName}'";
245 } 245 }
246 } 246 }
247 } 247 }
248 248
249 class _LocalClosureMirrorImpl extends _LocalInstanceMirrorImpl 249 class _LocalClosureMirrorImpl extends _LocalInstanceMirrorImpl
250 implements ClosureMirror { 250 implements ClosureMirror {
251 _LocalClosureMirrorImpl(ref, 251 _LocalClosureMirrorImpl(ref,
252 klass, 252 klass,
253 reflectee) : super(ref, klass, reflectee) {} 253 reflectee) : super(ref, klass, reflectee) {}
254 254
255 MethodMirror _function; 255 MethodMirror _function;
256 MethodMirror function() => _function; 256 MethodMirror function() => _function;
257 257
258 String get source() { 258 String get source {
259 throw new NotImplementedException('ClosureMirror.source not implemented'); 259 throw new NotImplementedException('ClosureMirror.source not implemented');
260 } 260 }
261 261
262 Future<ObjectMirror> apply(List<Object> positionalArguments, 262 Future<ObjectMirror> apply(List<Object> positionalArguments,
263 [Map<String,Object> namedArguments]) { 263 [Map<String,Object> namedArguments]) {
264 if (namedArguments !== null) { 264 if (namedArguments !== null) {
265 throw new NotImplementedException('named arguments not implemented'); 265 throw new NotImplementedException('named arguments not implemented');
266 } 266 }
267 // Walk the arguments and make sure they are legal. 267 // Walk the arguments and make sure they are legal.
268 for (int i = 0; i < positionalArguments.length; i++) { 268 for (int i = 0; i < positionalArguments.length; i++) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 this.isClass, 316 this.isClass,
317 this._owner, 317 this._owner,
318 this._superclass, 318 this._superclass,
319 this._superinterfaces, 319 this._superinterfaces,
320 this._defaultFactory, 320 this._defaultFactory,
321 this.members) : super(ref) {} 321 this.members) : super(ref) {}
322 322
323 final String simpleName; 323 final String simpleName;
324 324
325 String _qualifiedName = null; 325 String _qualifiedName = null;
326 String get qualifiedName() { 326 String get qualifiedName {
327 if (_qualifiedName === null) { 327 if (_qualifiedName === null) {
328 _qualifiedName = '${owner.qualifiedName}.${simpleName}'; 328 _qualifiedName = '${owner.qualifiedName}.${simpleName}';
329 } 329 }
330 return _qualifiedName; 330 return _qualifiedName;
331 } 331 }
332 332
333 var _owner; 333 var _owner;
334 DeclarationMirror get owner() { 334 DeclarationMirror get owner {
335 if (_owner is! Mirror) { 335 if (_owner is! Mirror) {
336 _owner = _owner.resolve(mirrors); 336 _owner = _owner.resolve(mirrors);
337 } 337 }
338 return _owner; 338 return _owner;
339 } 339 }
340 340
341 bool get isPrivate() => simpleName.startsWith('_'); 341 bool get isPrivate => simpleName.startsWith('_');
342 342
343 final bool isTopLevel = true; 343 final bool isTopLevel = true;
344 344
345 SourceLocation get location() { 345 SourceLocation get location {
346 throw new NotImplementedException( 346 throw new NotImplementedException(
347 'ClassMirror.location not yet implemented'); 347 'ClassMirror.location not yet implemented');
348 } 348 }
349 349
350 final bool isClass; 350 final bool isClass;
351 351
352 var _superclass; 352 var _superclass;
353 ClassMirror get superclass() { 353 ClassMirror get superclass {
354 if (_superclass is _LazyClassMirror) { 354 if (_superclass is _LazyClassMirror) {
355 _superclass = _superclass.resolve(mirrors); 355 _superclass = _superclass.resolve(mirrors);
356 } 356 }
357 return _superclass; 357 return _superclass;
358 } 358 }
359 359
360 var _superinterfaces; 360 var _superinterfaces;
361 List<ClassMirror> get superinterfaces() { 361 List<ClassMirror> get superinterfaces {
362 if (_superinterfaces.length > 0 && 362 if (_superinterfaces.length > 0 &&
363 _superinterfaces[0] is _LazyClassMirror) { 363 _superinterfaces[0] is _LazyClassMirror) {
364 List<ClassMirror> resolved = new List<ClassMirror>(); 364 List<ClassMirror> resolved = new List<ClassMirror>();
365 for (int i = 0; i < _superinterfaces.length; i++) { 365 for (int i = 0; i < _superinterfaces.length; i++) {
366 resolved.add(_superinterfaces[i].resolve(mirrors)); 366 resolved.add(_superinterfaces[i].resolve(mirrors));
367 } 367 }
368 _superinterfaces = resolved; 368 _superinterfaces = resolved;
369 } 369 }
370 return _superinterfaces; 370 return _superinterfaces;
371 } 371 }
372 372
373 var _defaultFactory; 373 var _defaultFactory;
374 ClassMirror get defaultFactory() { 374 ClassMirror get defaultFactory {
375 if (_defaultFactory is _LazyClassMirror) { 375 if (_defaultFactory is _LazyClassMirror) {
376 _defaultFactory = _defaultFactory.resolve(mirrors); 376 _defaultFactory = _defaultFactory.resolve(mirrors);
377 } 377 }
378 return _defaultFactory; 378 return _defaultFactory;
379 } 379 }
380 380
381 final Map<String, Mirror> members; 381 final Map<String, Mirror> members;
382 382
383 Map<String, MethodMirror> _methods = null; 383 Map<String, MethodMirror> _methods = null;
384 Map<String, MethodMirror> _constructors = null; 384 Map<String, MethodMirror> _constructors = null;
385 Map<String, MethodMirror> _getters = null; 385 Map<String, MethodMirror> _getters = null;
386 Map<String, MethodMirror> _setters = null; 386 Map<String, MethodMirror> _setters = null;
387 Map<String, VariableMirror> _variables = null; 387 Map<String, VariableMirror> _variables = null;
388 388
389 Map<String, MethodMirror> get methods() { 389 Map<String, MethodMirror> get methods {
390 if (_methods == null) { 390 if (_methods == null) {
391 _methods = filterMap(members, 391 _methods = filterMap(members,
392 (key, value) => (value is MethodMirror)); 392 (key, value) => (value is MethodMirror));
393 } 393 }
394 return _methods; 394 return _methods;
395 } 395 }
396 396
397 Map<String, MethodMirror> get constructors() { 397 Map<String, MethodMirror> get constructors {
398 if (_constructors == null) { 398 if (_constructors == null) {
399 _constructors = filterMap(methods, 399 _constructors = filterMap(methods,
400 (key, value) => (value.isConstructor)); 400 (key, value) => (value.isConstructor));
401 } 401 }
402 return _constructors; 402 return _constructors;
403 } 403 }
404 404
405 Map<String, MethodMirror> get getters() { 405 Map<String, MethodMirror> get getters {
406 if (_getters == null) { 406 if (_getters == null) {
407 _getters = filterMap(methods, 407 _getters = filterMap(methods,
408 (key, value) => (value.isGetter)); 408 (key, value) => (value.isGetter));
409 } 409 }
410 return _getters; 410 return _getters;
411 } 411 }
412 412
413 Map<String, MethodMirror> get setters() { 413 Map<String, MethodMirror> get setters {
414 if (_setters == null) { 414 if (_setters == null) {
415 _setters = filterMap(methods, 415 _setters = filterMap(methods,
416 (key, value) => (value.isSetter)); 416 (key, value) => (value.isSetter));
417 } 417 }
418 return _setters; 418 return _setters;
419 } 419 }
420 420
421 Map<String, VariableMirror> get variables() { 421 Map<String, VariableMirror> get variables {
422 if (_variables == null) { 422 if (_variables == null) {
423 _variables = filterMap(members, 423 _variables = filterMap(members,
424 (key, value) => (value is VariableMirror)); 424 (key, value) => (value is VariableMirror));
425 } 425 }
426 return _variables; 426 return _variables;
427 } 427 }
428 428
429 List<TypeVariableMirror> get typeVariables() { 429 List<TypeVariableMirror> get typeVariables {
430 throw new NotImplementedException( 430 throw new NotImplementedException(
431 'ClassMirror.typeVariables not yet implemented'); 431 'ClassMirror.typeVariables not yet implemented');
432 } 432 }
433 433
434 List<TypeMirror> get typeArguments() { 434 List<TypeMirror> get typeArguments {
435 throw new NotImplementedException( 435 throw new NotImplementedException(
436 'ClassMirror.typeArguments not yet implemented'); 436 'ClassMirror.typeArguments not yet implemented');
437 } 437 }
438 438
439 bool isGenericDeclaration() { 439 bool isGenericDeclaration() {
440 throw new NotImplementedException( 440 throw new NotImplementedException(
441 'ClassMirror.isGenericDeclaration not yet implemented'); 441 'ClassMirror.isGenericDeclaration not yet implemented');
442 } 442 }
443 443
444 ClassMirror genericDeclaration() { 444 ClassMirror genericDeclaration() {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl 486 class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl
487 implements LibraryMirror { 487 implements LibraryMirror {
488 _LocalLibraryMirrorImpl(ref, 488 _LocalLibraryMirrorImpl(ref,
489 this.simpleName, 489 this.simpleName,
490 this.url, 490 this.url,
491 this.members) : super(ref) {} 491 this.members) : super(ref) {}
492 492
493 final String simpleName; 493 final String simpleName;
494 494
495 // The simple name and the qualified name are the same for a library. 495 // The simple name and the qualified name are the same for a library.
496 String get qualifiedName() => simpleName; 496 String get qualifiedName => simpleName;
497 497
498 // Always null for libraries. 498 // Always null for libraries.
499 final DeclarationMirror owner = null; 499 final DeclarationMirror owner = null;
500 500
501 // Always false for libraries. 501 // Always false for libraries.
502 final bool isPrivate = false; 502 final bool isPrivate = false;
503 503
504 // Always false for libraries. 504 // Always false for libraries.
505 final bool isTopLevel = false; 505 final bool isTopLevel = false;
506 506
507 SourceLocation get location() { 507 SourceLocation get location {
508 throw new NotImplementedException( 508 throw new NotImplementedException(
509 'LibraryMirror.location not yet implemented'); 509 'LibraryMirror.location not yet implemented');
510 } 510 }
511 511
512 final String url; 512 final String url;
513 final Map<String, Mirror> members; 513 final Map<String, Mirror> members;
514 514
515 Map<String, ClassMirror> _classes = null; 515 Map<String, ClassMirror> _classes = null;
516 Map<String, MethodMirror> _functions = null; 516 Map<String, MethodMirror> _functions = null;
517 Map<String, MethodMirror> _getters = null; 517 Map<String, MethodMirror> _getters = null;
518 Map<String, MethodMirror> _setters = null; 518 Map<String, MethodMirror> _setters = null;
519 Map<String, VariableMirror> _variables = null; 519 Map<String, VariableMirror> _variables = null;
520 520
521 Map<String, ClassMirror> get classes() { 521 Map<String, ClassMirror> get classes {
522 if (_classes == null) { 522 if (_classes == null) {
523 _classes = filterMap(members, 523 _classes = filterMap(members,
524 (key, value) => (value is ClassMirror)); 524 (key, value) => (value is ClassMirror));
525 } 525 }
526 return _classes; 526 return _classes;
527 } 527 }
528 528
529 Map<String, MethodMirror> get functions() { 529 Map<String, MethodMirror> get functions {
530 if (_functions == null) { 530 if (_functions == null) {
531 _functions = filterMap(members, 531 _functions = filterMap(members,
532 (key, value) => (value is MethodMirror)); 532 (key, value) => (value is MethodMirror));
533 } 533 }
534 return _functions; 534 return _functions;
535 } 535 }
536 536
537 Map<String, MethodMirror> get getters() { 537 Map<String, MethodMirror> get getters {
538 if (_getters == null) { 538 if (_getters == null) {
539 _getters = filterMap(functions, 539 _getters = filterMap(functions,
540 (key, value) => (value.isGetter)); 540 (key, value) => (value.isGetter));
541 } 541 }
542 return _getters; 542 return _getters;
543 } 543 }
544 544
545 Map<String, MethodMirror> get setters() { 545 Map<String, MethodMirror> get setters {
546 if (_setters == null) { 546 if (_setters == null) {
547 _setters = filterMap(functions, 547 _setters = filterMap(functions,
548 (key, value) => (value.isSetter)); 548 (key, value) => (value.isSetter));
549 } 549 }
550 return _setters; 550 return _setters;
551 } 551 }
552 552
553 Map<String, VariableMirror> get variables() { 553 Map<String, VariableMirror> get variables {
554 if (_variables == null) { 554 if (_variables == null) {
555 _variables = filterMap(members, 555 _variables = filterMap(members,
556 (key, value) => (value is VariableMirror)); 556 (key, value) => (value is VariableMirror));
557 } 557 }
558 return _variables; 558 return _variables;
559 } 559 }
560 560
561 String toString() => "LibraryMirror on '$simpleName'"; 561 String toString() => "LibraryMirror on '$simpleName'";
562 } 562 }
563 563
564 class _LocalMethodMirrorImpl extends _LocalMirrorImpl 564 class _LocalMethodMirrorImpl extends _LocalMirrorImpl
565 implements MethodMirror { 565 implements MethodMirror {
566 _LocalMethodMirrorImpl(this.simpleName, 566 _LocalMethodMirrorImpl(this.simpleName,
567 this._owner, 567 this._owner,
568 this.parameters, 568 this.parameters,
569 this.isStatic, 569 this.isStatic,
570 this.isAbstract, 570 this.isAbstract,
571 this.isGetter, 571 this.isGetter,
572 this.isSetter, 572 this.isSetter,
573 this.isConstructor, 573 this.isConstructor,
574 this.isConstConstructor, 574 this.isConstConstructor,
575 this.isGenerativeConstructor, 575 this.isGenerativeConstructor,
576 this.isRedirectingConstructor, 576 this.isRedirectingConstructor,
577 this.isFactoryConstructor) {} 577 this.isFactoryConstructor) {}
578 578
579 final String simpleName; 579 final String simpleName;
580 580
581 String _qualifiedName = null; 581 String _qualifiedName = null;
582 String get qualifiedName() { 582 String get qualifiedName {
583 if (_qualifiedName === null) { 583 if (_qualifiedName === null) {
584 _qualifiedName = '${owner.qualifiedName}.${simpleName}'; 584 _qualifiedName = '${owner.qualifiedName}.${simpleName}';
585 } 585 }
586 return _qualifiedName; 586 return _qualifiedName;
587 } 587 }
588 588
589 var _owner; 589 var _owner;
590 DeclarationMirror get owner() { 590 DeclarationMirror get owner {
591 if (_owner is! Mirror) { 591 if (_owner is! Mirror) {
592 _owner = _owner.resolve(mirrors); 592 _owner = _owner.resolve(mirrors);
593 } 593 }
594 return _owner; 594 return _owner;
595 } 595 }
596 596
597 bool get isPrivate() { 597 bool get isPrivate {
598 return simpleName.startsWith('_') || constructorName.startsWith('_'); 598 return simpleName.startsWith('_') || constructorName.startsWith('_');
599 } 599 }
600 600
601 bool get isTopLevel() => owner is LibraryMirror; 601 bool get isTopLevel => owner is LibraryMirror;
602 602
603 SourceLocation get location() { 603 SourceLocation get location {
604 throw new NotImplementedException( 604 throw new NotImplementedException(
605 'MethodMirror.location not yet implemented'); 605 'MethodMirror.location not yet implemented');
606 } 606 }
607 607
608 TypeMirror get returnType() { 608 TypeMirror get returnType {
609 throw new NotImplementedException( 609 throw new NotImplementedException(
610 'MethodMirror.returnType not yet implemented'); 610 'MethodMirror.returnType not yet implemented');
611 } 611 }
612 612
613 final List<ParameterMirror> parameters; 613 final List<ParameterMirror> parameters;
614 614
615 final bool isStatic; 615 final bool isStatic;
616 final bool isAbstract; 616 final bool isAbstract;
617 617
618 bool get isRegularMethod() => !isGetter && !isSetter && !isConstructor; 618 bool get isRegularMethod => !isGetter && !isSetter && !isConstructor;
619 619
620 TypeMirror get isOperator() { 620 TypeMirror get isOperator {
621 throw new NotImplementedException( 621 throw new NotImplementedException(
622 'MethodMirror.isOperator not yet implemented'); 622 'MethodMirror.isOperator not yet implemented');
623 } 623 }
624 624
625 final bool isGetter; 625 final bool isGetter;
626 final bool isSetter; 626 final bool isSetter;
627 final bool isConstructor; 627 final bool isConstructor;
628 628
629 var _constructorName = null; 629 var _constructorName = null;
630 String get constructorName() { 630 String get constructorName {
631 if (_constructorName === null) { 631 if (_constructorName === null) {
632 if (!isConstructor) { 632 if (!isConstructor) {
633 _constructorName = ''; 633 _constructorName = '';
634 } else { 634 } else {
635 var parts = simpleName.split('.'); 635 var parts = simpleName.split('.');
636 if (parts.length > 2) { 636 if (parts.length > 2) {
637 throw new MirrorException( 637 throw new MirrorException(
638 'Internal error in MethodMirror.constructorName: ' 638 'Internal error in MethodMirror.constructorName: '
639 'malformed name <$simpleName>'); 639 'malformed name <$simpleName>');
640 } else if (parts.length == 2) { 640 } else if (parts.length == 2) {
(...skipping 17 matching lines...) Expand all
658 class _LocalVariableMirrorImpl extends _LocalMirrorImpl 658 class _LocalVariableMirrorImpl extends _LocalMirrorImpl
659 implements VariableMirror { 659 implements VariableMirror {
660 _LocalVariableMirrorImpl(this.simpleName, 660 _LocalVariableMirrorImpl(this.simpleName,
661 this._owner, 661 this._owner,
662 this.isStatic, 662 this.isStatic,
663 this.isFinal) {} 663 this.isFinal) {}
664 664
665 final String simpleName; 665 final String simpleName;
666 666
667 String _qualifiedName = null; 667 String _qualifiedName = null;
668 String get qualifiedName() { 668 String get qualifiedName {
669 if (_qualifiedName === null) { 669 if (_qualifiedName === null) {
670 _qualifiedName = '${owner.qualifiedName}.${simpleName}'; 670 _qualifiedName = '${owner.qualifiedName}.${simpleName}';
671 } 671 }
672 return _qualifiedName; 672 return _qualifiedName;
673 } 673 }
674 674
675 var _owner; 675 var _owner;
676 DeclarationMirror get owner() { 676 DeclarationMirror get owner {
677 if (_owner is! Mirror) { 677 if (_owner is! Mirror) {
678 _owner = _owner.resolve(mirrors); 678 _owner = _owner.resolve(mirrors);
679 } 679 }
680 return _owner; 680 return _owner;
681 } 681 }
682 682
683 bool get isPrivate() { 683 bool get isPrivate {
684 return simpleName.startsWith('_'); 684 return simpleName.startsWith('_');
685 } 685 }
686 686
687 bool get isTopLevel() { 687 bool get isTopLevel {
688 return owner is LibraryMirror; 688 return owner is LibraryMirror;
689 } 689 }
690 690
691 SourceLocation get location() { 691 SourceLocation get location {
692 throw new NotImplementedException( 692 throw new NotImplementedException(
693 'VariableMirror.location not yet implemented'); 693 'VariableMirror.location not yet implemented');
694 } 694 }
695 695
696 TypeMirror get type() { 696 TypeMirror get type {
697 throw new NotImplementedException( 697 throw new NotImplementedException(
698 'VariableMirror.type not yet implemented'); 698 'VariableMirror.type not yet implemented');
699 } 699 }
700 700
701 final bool isStatic; 701 final bool isStatic;
702 final bool isFinal; 702 final bool isFinal;
703 703
704 String toString() => "VariableMirror on '$simpleName'"; 704 String toString() => "VariableMirror on '$simpleName'";
705 } 705 }
706 706
707 class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl 707 class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl
708 implements ParameterMirror { 708 implements ParameterMirror {
709 // TODO(rmacnak): Fill these mirrors will real information 709 // TODO(rmacnak): Fill these mirrors will real information
710 _LocalParameterMirrorImpl(this.isOptional) 710 _LocalParameterMirrorImpl(this.isOptional)
711 : super(null, null, false, false) {} 711 : super(null, null, false, false) {}
712 712
713 final bool isOptional; 713 final bool isOptional;
714 714
715 TypeMirror get type() { 715 TypeMirror get type {
716 throw new NotImplementedException( 716 throw new NotImplementedException(
717 'ParameterMirror.type not yet implemented'); 717 'ParameterMirror.type not yet implemented');
718 } 718 }
719 719
720 String get defaultValue() { 720 String get defaultValue {
721 throw new NotImplementedException( 721 throw new NotImplementedException(
722 'ParameterMirror.defaultValue not yet implemented'); 722 'ParameterMirror.defaultValue not yet implemented');
723 } 723 }
724 724
725 bool get hasDefaultValue() { 725 bool get hasDefaultValue {
726 throw new NotImplementedException( 726 throw new NotImplementedException(
727 'ParameterMirror.hasDefaultValue not yet implemented'); 727 'ParameterMirror.hasDefaultValue not yet implemented');
728 } 728 }
729 } 729 }
730 730
731 class _Mirrors { 731 class _Mirrors {
732 // Does a port refer to our local isolate? 732 // Does a port refer to our local isolate?
733 static bool isLocalPort(SendPort port) native 'Mirrors_isLocalPort'; 733 static bool isLocalPort(SendPort port) native 'Mirrors_isLocalPort';
734 734
735 static MirrorSystem _currentMirrorSystem = null; 735 static MirrorSystem _currentMirrorSystem = null;
(...skipping 28 matching lines...) Expand all
764 764
765 // Creates a new local InstanceMirror 765 // Creates a new local InstanceMirror
766 static InstanceMirror makeLocalInstanceMirror(Object reflectee) 766 static InstanceMirror makeLocalInstanceMirror(Object reflectee)
767 native 'Mirrors_makeLocalInstanceMirror'; 767 native 'Mirrors_makeLocalInstanceMirror';
768 768
769 // Creates a new local mirror for some Object. 769 // Creates a new local mirror for some Object.
770 static InstanceMirror reflect(Object reflectee) { 770 static InstanceMirror reflect(Object reflectee) {
771 return makeLocalInstanceMirror(reflectee); 771 return makeLocalInstanceMirror(reflectee);
772 } 772 }
773 } 773 }
OLDNEW
« no previous file with comments | « runtime/lib/isolate_patch.dart ('k') | runtime/lib/regexp_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698