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:collection'; | 7 import 'dart:collection'; |
8 import 'dart:mirrors'; | 8 import 'dart:mirrors'; |
9 import 'dart:_foreign_helper' show JS; | 9 import 'dart:_foreign_helper' show JS; |
10 import 'dart:_internal' as _internal; | 10 import 'dart:_internal' as _internal; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // TODO(vsm): This is only populating the default constructor right now. | 101 // TODO(vsm): This is only populating the default constructor right now. |
102 _declarations = new Map<Symbol, MethodMirror>(); | 102 _declarations = new Map<Symbol, MethodMirror>(); |
103 _declarations[simpleName] = new JsMethodMirror._(this, _cls); | 103 _declarations[simpleName] = new JsMethodMirror._(this, _cls); |
104 } | 104 } |
105 | 105 |
106 InstanceMirror newInstance(Symbol constructorName, List args, | 106 InstanceMirror newInstance(Symbol constructorName, List args, |
107 [Map<Symbol, dynamic> namedArgs]) { | 107 [Map<Symbol, dynamic> namedArgs]) { |
108 // TODO(vsm): Support named constructors and named arguments. | 108 // TODO(vsm): Support named constructors and named arguments. |
109 assert(getName(constructorName) == ""); | 109 assert(getName(constructorName) == ""); |
110 assert(namedArgs == null || namedArgs.isEmpty); | 110 assert(namedArgs == null || namedArgs.isEmpty); |
111 var instance = JS('', '#.instantiate(#, #)', _dart, _cls, args); | 111 var instance = JS('', 'new #(...#)', _cls, args); |
112 return new JsInstanceMirror._(instance); | 112 return new JsInstanceMirror._(instance); |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 class JsTypeMirror implements TypeMirror { | 116 class JsTypeMirror implements TypeMirror { |
117 final Type reflectedType; | 117 final Type reflectedType; |
118 | 118 |
119 JsTypeMirror._(this.reflectedType); | 119 JsTypeMirror._(this.reflectedType); |
120 } | 120 } |
121 | 121 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 for (var i = 0; i < opts.length; ++i) { | 163 for (var i = 0; i < opts.length; ++i) { |
164 var type = opts[i]; | 164 var type = opts[i]; |
165 // TODO(vsm): Recover the param name. | 165 // TODO(vsm): Recover the param name. |
166 var param = new JsParameterMirror._('', type); | 166 var param = new JsParameterMirror._('', type); |
167 params[i + args.length] = param; | 167 params[i + args.length] = param; |
168 } | 168 } |
169 | 169 |
170 return params; | 170 return params; |
171 } | 171 } |
172 } | 172 } |
OLD | NEW |