| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 return _toDartMap(sig); | 140 return _toDartMap(sig); |
| 141 } | 141 } |
| 142 | 142 |
| 143 // TODO(vsm): These methods need to validate whether we really have a | 143 // TODO(vsm): These methods need to validate whether we really have a |
| 144 // WrappedType or a raw type that should be wrapped (as opposed to a | 144 // WrappedType or a raw type that should be wrapped (as opposed to a |
| 145 // function). | 145 // function). |
| 146 dynamic _unwrap(obj) => JS('', '#.unwrapType(#)', _dart, obj); | 146 dynamic _unwrap(obj) => JS('', '#.unwrapType(#)', _dart, obj); |
| 147 | 147 |
| 148 dynamic _wrap(obj) => JS('', '#.wrapType(#)', _dart, obj); | 148 dynamic _wrap(obj) => JS('', '#.wrapType(#)', _dart, obj); |
| 149 | 149 |
| 150 dynamic _runtimeType(obj) => |
| 151 _wrap(JS('', '#.getReifiedType(#)', _dart, obj)); |
| 152 |
| 150 _unimplemented(Type t, Invocation i) { | 153 _unimplemented(Type t, Invocation i) { |
| 151 throw new UnimplementedError('$t.${getName(i.memberName)} unimplemented'); | 154 throw new UnimplementedError('$t.${getName(i.memberName)} unimplemented'); |
| 152 } | 155 } |
| 153 | 156 |
| 154 dynamic _toJsMap(Map<Symbol, dynamic> map) { | 157 dynamic _toJsMap(Map<Symbol, dynamic> map) { |
| 155 var obj = JS('', '{}'); | 158 var obj = JS('', '{}'); |
| 156 map.forEach((Symbol key, value) { | 159 map.forEach((Symbol key, value) { |
| 157 JS('', '#[#] = #', obj, getName(key), value); | 160 JS('', '#[#] = #', obj, getName(key), value); |
| 158 }); | 161 }); |
| 159 return obj; | 162 return obj; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 183 class JsInstanceMirror extends JsObjectMirror implements InstanceMirror { | 186 class JsInstanceMirror extends JsObjectMirror implements InstanceMirror { |
| 184 | 187 |
| 185 // Reflected object | 188 // Reflected object |
| 186 final reflectee; | 189 final reflectee; |
| 187 bool get hasReflectee => true; | 190 bool get hasReflectee => true; |
| 188 | 191 |
| 189 ClassMirror get type { | 192 ClassMirror get type { |
| 190 // The spec guarantees that `null` is the singleton instance of the `Null` | 193 // The spec guarantees that `null` is the singleton instance of the `Null` |
| 191 // class. | 194 // class. |
| 192 if (reflectee == null) return reflectClass(Null); | 195 if (reflectee == null) return reflectClass(Null); |
| 193 return reflectType(reflectee.runtimeType); | 196 return reflectType(_runtimeType(reflectee)); |
| 194 } | 197 } |
| 195 | 198 |
| 196 JsInstanceMirror._(this.reflectee); | 199 JsInstanceMirror._(this.reflectee); |
| 197 | 200 |
| 198 bool operator==(Object other) { | 201 bool operator==(Object other) { |
| 199 return (other is JsInstanceMirror) && identical(reflectee, other.reflectee); | 202 return (other is JsInstanceMirror) && identical(reflectee, other.reflectee); |
| 200 } | 203 } |
| 201 | 204 |
| 202 int get hashCode { | 205 int get hashCode { |
| 203 // Avoid hash collisions with the reflectee. This constant is in Smi range | 206 // Avoid hash collisions with the reflectee. This constant is in Smi range |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 // TODO(vsm): Recover the param name. | 566 // TODO(vsm): Recover the param name. |
| 564 var param = new JsParameterMirror._('', _wrap(type), metadata); | 567 var param = new JsParameterMirror._('', _wrap(type), metadata); |
| 565 params[i + args.length] = param; | 568 params[i + args.length] = param; |
| 566 } | 569 } |
| 567 | 570 |
| 568 _params = new List.unmodifiable(params); | 571 _params = new List.unmodifiable(params); |
| 569 } | 572 } |
| 570 | 573 |
| 571 String toString() => "MethodMirror on '$_name'"; | 574 String toString() => "MethodMirror on '$_name'"; |
| 572 } | 575 } |
| OLD | NEW |