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 library dart._js_mirrors; | 5 library dart._js_mirrors; |
6 | 6 |
7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
8 import 'dart:_foreign_helper' show JS; | 8 import 'dart:_foreign_helper' show JS; |
9 import 'dart:_internal' as _internal; | 9 import 'dart:_internal' as _internal; |
10 | 10 |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 _typeArguments = | 435 _typeArguments = |
436 new List.unmodifiable(typeArgs.map((t) => reflectType(_wrap(t)))); | 436 new List.unmodifiable(typeArgs.map((t) => reflectType(_wrap(t)))); |
437 } | 437 } |
438 } | 438 } |
439 | 439 |
440 InstanceMirror newInstance(Symbol constructorName, List args, | 440 InstanceMirror newInstance(Symbol constructorName, List args, |
441 [Map<Symbol, dynamic> namedArgs]) { | 441 [Map<Symbol, dynamic> namedArgs]) { |
442 // TODO(vsm): Support factory constructors and named arguments. | 442 // TODO(vsm): Support factory constructors and named arguments. |
443 var name = getName(constructorName); | 443 var name = getName(constructorName); |
444 assert(namedArgs == null || namedArgs.isEmpty); | 444 assert(namedArgs == null || namedArgs.isEmpty); |
445 var instance = (name == 'new' || name == '') | 445 if (name == '') name = 'new'; |
446 ? JS('', 'new #(...#)', _unwrap(_cls), args) | 446 var instance = JS('', 'new (#.#)(...#)', _unwrap(_cls), name, args); |
447 : JS('', 'new (#.#)(...#)', _unwrap(_cls), name, args); | |
448 return reflect(instance); | 447 return reflect(instance); |
449 } | 448 } |
450 | 449 |
451 // TODO(vsm): Need to check for NSM, types on accessors below. Unlike the | 450 // TODO(vsm): Need to check for NSM, types on accessors below. Unlike the |
452 // InstanceMirror case, there is no dynamic helper to delegate to - we never | 451 // InstanceMirror case, there is no dynamic helper to delegate to - we never |
453 // need a dload, etc. on a static. | 452 // need a dload, etc. on a static. |
454 | 453 |
455 InstanceMirror getField(Symbol symbol) { | 454 InstanceMirror getField(Symbol symbol) { |
456 var name = getName(symbol); | 455 var name = getName(symbol); |
457 return reflect(JS('', '#[#]', _unwrap(_cls), name)); | 456 return reflect(JS('', '#[#]', _unwrap(_cls), name)); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 var param = | 658 var param = |
660 new JsParameterMirror._(new Symbol(''), _wrap(type), metadata); | 659 new JsParameterMirror._(new Symbol(''), _wrap(type), metadata); |
661 params[i + args.length] = param; | 660 params[i + args.length] = param; |
662 } | 661 } |
663 | 662 |
664 _params = new List.unmodifiable(params); | 663 _params = new List.unmodifiable(params); |
665 } | 664 } |
666 | 665 |
667 String toString() => "MethodMirror on '$_name'"; | 666 String toString() => "MethodMirror on '$_name'"; |
668 } | 667 } |
OLD | NEW |