| 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 // VM-specific implementation of the dart:mirrors library. | 5 // VM-specific implementation of the dart:mirrors library. |
| 6 | 6 |
| 7 import "dart:collection"; | 7 import "dart:collection"; |
| 8 | 8 |
| 9 // These values are allowed to be passed directly over the wire. | 9 // These values are allowed to be passed directly over the wire. |
| 10 bool _isSimpleValue(var value) { | 10 bool _isSimpleValue(var value) { |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 } | 396 } |
| 397 | 397 |
| 398 Future<InstanceMirror> applyAsync(List positionalArguments, | 398 Future<InstanceMirror> applyAsync(List positionalArguments, |
| 399 [Map<Symbol, dynamic> namedArguments]) { | 399 [Map<Symbol, dynamic> namedArguments]) { |
| 400 return new Future(() { | 400 return new Future(() { |
| 401 return this.apply(_unwrapAsyncPositionals(positionalArguments), | 401 return this.apply(_unwrapAsyncPositionals(positionalArguments), |
| 402 _unwrapAsyncNamed(namedArguments)); | 402 _unwrapAsyncNamed(namedArguments)); |
| 403 }); | 403 }); |
| 404 } | 404 } |
| 405 | 405 |
| 406 Future<InstanceMirror> findInContext(Symbol name) { | 406 InstanceMirror findInContext(Symbol name, {ifAbsent: null}) { |
| 407 throw new UnimplementedError( | 407 List<String> parts = _n(name).split(".").toList(growable: false); |
| 408 'ClosureMirror.findInContext() is not implemented'); | 408 if (parts.length > 3) { |
| 409 throw new ArgumentError("Invalid symbol: ${name}"); |
| 410 } |
| 411 var instance = _computeFindInContext(_reflectee, parts); |
| 412 if (instance != null) { |
| 413 return reflect(instance); |
| 414 } |
| 415 return ifAbsent == null ? null : ifAbsent(); |
| 409 } | 416 } |
| 410 | 417 |
| 411 String toString() => "ClosureMirror on '${Error.safeToString(_reflectee)}'"; | 418 String toString() => "ClosureMirror on '${Error.safeToString(_reflectee)}'"; |
| 412 | 419 |
| 413 static _apply(reflectee, arguments, argumentNames) | 420 static _apply(reflectee, arguments, argumentNames) |
| 414 native 'ClosureMirror_apply'; | 421 native 'ClosureMirror_apply'; |
| 415 | 422 |
| 416 static _computeFunction(reflectee) | 423 static _computeFunction(reflectee) |
| 417 native 'ClosureMirror_function'; | 424 native 'ClosureMirror_function'; |
| 425 |
| 426 static _computeFindInContext(reflectee, name) |
| 427 native 'ClosureMirror_find_in_context'; |
| 418 } | 428 } |
| 419 | 429 |
| 420 class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl | 430 class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl |
| 421 implements ClassMirror { | 431 implements ClassMirror { |
| 422 _LocalClassMirrorImpl(reflectee, | 432 _LocalClassMirrorImpl(reflectee, |
| 423 this._reflectedType, | 433 this._reflectedType, |
| 424 String simpleName, | 434 String simpleName, |
| 425 this._isGeneric, | 435 this._isGeneric, |
| 426 this._isMixinTypedef, | 436 this._isMixinTypedef, |
| 427 this._isGenericDeclaration) | 437 this._isGenericDeclaration) |
| (...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1321 if (typeMirror == null) { | 1331 if (typeMirror == null) { |
| 1322 typeMirror = makeLocalTypeMirror(key); | 1332 typeMirror = makeLocalTypeMirror(key); |
| 1323 _instanitationCache[key] = typeMirror; | 1333 _instanitationCache[key] = typeMirror; |
| 1324 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { | 1334 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { |
| 1325 _declarationCache[key] = typeMirror; | 1335 _declarationCache[key] = typeMirror; |
| 1326 } | 1336 } |
| 1327 } | 1337 } |
| 1328 return typeMirror; | 1338 return typeMirror; |
| 1329 } | 1339 } |
| 1330 } | 1340 } |
| OLD | NEW |