Chromium Code Reviews| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 assert(getName(constructorName) == ""); | 116 assert(getName(constructorName) == ""); |
| 117 assert(namedArgs == null || namedArgs.isEmpty); | 117 assert(namedArgs == null || namedArgs.isEmpty); |
| 118 var instance = JS('', 'new #(...#)', _cls, args); | 118 var instance = JS('', 'new #(...#)', _cls, args); |
| 119 return new JsInstanceMirror._(instance); | 119 return new JsInstanceMirror._(instance); |
| 120 } | 120 } |
| 121 | 121 |
| 122 List<ClassMirror> get superinterfaces { | 122 List<ClassMirror> get superinterfaces { |
| 123 var interfaces = JS('Function', '#[dart.implements]', _cls); | 123 var interfaces = JS('Function', '#[dart.implements]', _cls); |
| 124 if (interfaces == null) { | 124 if (interfaces == null) { |
| 125 return []; | 125 return []; |
| 126 } else { | |
| 127 return interfaces().map((t) => new JsClassMirror._(t)); | |
|
Jennifer Messerly
2015/12/01 16:41:39
add a .toList() here?
and is this function allowe
vsm
2015/12/01 17:00:01
Done.
| |
| 126 } | 128 } |
| 127 throw new UnimplementedError("ClassMirror.superinterfaces unimplemented"); | |
| 128 } | 129 } |
| 129 | 130 |
| 130 // TODO(vsm): Implement | 131 // TODO(vsm): Implement |
| 131 InstanceMirror getField(Symbol fieldName) => | 132 InstanceMirror getField(Symbol fieldName) => |
| 132 throw new UnimplementedError("ClassMirror.getField unimplemented"); | 133 throw new UnimplementedError("ClassMirror.getField unimplemented"); |
| 133 InstanceMirror invoke(Symbol memberName, List positionalArguments, | 134 InstanceMirror invoke(Symbol memberName, List positionalArguments, |
| 134 [Map<Symbol, dynamic> namedArguments]) => | 135 [Map<Symbol, dynamic> namedArguments]) => |
| 135 throw new UnimplementedError("ClassMirror.invoke unimplemented"); | 136 throw new UnimplementedError("ClassMirror.invoke unimplemented"); |
| 136 bool isAssignableTo(TypeMirror other) => | 137 bool isAssignableTo(TypeMirror other) => |
| 137 throw new UnimplementedError("ClassMirror.isAssignable unimplemented"); | 138 throw new UnimplementedError("ClassMirror.isAssignable unimplemented"); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 152 bool get isOriginalDeclaration => throw new UnimplementedError( | 153 bool get isOriginalDeclaration => throw new UnimplementedError( |
| 153 "ClassMirror.isOriginalDeclaration unimplemented"); | 154 "ClassMirror.isOriginalDeclaration unimplemented"); |
| 154 bool get isPrivate => | 155 bool get isPrivate => |
| 155 throw new UnimplementedError("ClassMirror.isPrivate unimplemented"); | 156 throw new UnimplementedError("ClassMirror.isPrivate unimplemented"); |
| 156 bool get isTopLevel => | 157 bool get isTopLevel => |
| 157 throw new UnimplementedError("ClassMirror.isTopLevel unimplemented"); | 158 throw new UnimplementedError("ClassMirror.isTopLevel unimplemented"); |
| 158 SourceLocation get location => | 159 SourceLocation get location => |
| 159 throw new UnimplementedError("ClassMirror.location unimplemented"); | 160 throw new UnimplementedError("ClassMirror.location unimplemented"); |
| 160 ClassMirror get mixin => | 161 ClassMirror get mixin => |
| 161 throw new UnimplementedError("ClassMirror.mixin unimplemented"); | 162 throw new UnimplementedError("ClassMirror.mixin unimplemented"); |
| 162 TypeMirror get originalDeclaration => throw new UnimplementedError( | 163 TypeMirror get originalDeclaration { |
| 163 "ClassMirror.originalDeclaration unimplemented"); | 164 // TODO(vsm): Handle generic case. How should we represent an original |
|
Jennifer Messerly
2015/12/01 16:41:39
FWIW, the VM implementation:
https://github.com/da
vsm
2015/12/01 17:00:01
We don't implement isOriginalDeclaration yet. We
| |
| 165 // declaration for a generic class? | |
| 166 return this; | |
| 167 } | |
| 164 DeclarationMirror get owner => | 168 DeclarationMirror get owner => |
| 165 throw new UnimplementedError("ClassMirror.owner unimplemented"); | 169 throw new UnimplementedError("ClassMirror.owner unimplemented"); |
| 166 Symbol get qualifiedName => | 170 Symbol get qualifiedName => |
| 167 throw new UnimplementedError("ClassMirror.qualifiedName unimplemented"); | 171 throw new UnimplementedError("ClassMirror.qualifiedName unimplemented"); |
| 168 Type get reflectedType => | 172 Type get reflectedType { return _cls; } |
| 169 throw new UnimplementedError("ClassMirror.reflectedType unimplemented"); | |
| 170 Map<Symbol, MethodMirror> get staticMembers => | 173 Map<Symbol, MethodMirror> get staticMembers => |
| 171 throw new UnimplementedError("ClassMirror.staticMembers unimplemented"); | 174 throw new UnimplementedError("ClassMirror.staticMembers unimplemented"); |
| 172 ClassMirror get superclass => | 175 ClassMirror get superclass { |
| 173 throw new UnimplementedError("ClassMirror.superclass unimplemented"); | 176 if (_cls == Object) { |
| 177 return null; | |
| 178 } else { | |
| 179 return new JsClassMirror._(JS('Type', '#.__proto__', _cls)); | |
| 180 } | |
| 181 } | |
| 174 List<TypeMirror> get typeArguments => | 182 List<TypeMirror> get typeArguments => |
| 175 throw new UnimplementedError("ClassMirror.typeArguments unimplemented"); | 183 throw new UnimplementedError("ClassMirror.typeArguments unimplemented"); |
| 176 List<TypeVariableMirror> get typeVariables => | 184 List<TypeVariableMirror> get typeVariables => |
| 177 throw new UnimplementedError("ClassMirror.typeVariables unimplemented"); | 185 throw new UnimplementedError("ClassMirror.typeVariables unimplemented"); |
| 178 } | 186 } |
| 179 | 187 |
| 180 class JsTypeMirror implements TypeMirror { | 188 class JsTypeMirror implements TypeMirror { |
| 181 // TODO(vsm): Support original declarations, etc., where there is no actual | 189 // TODO(vsm): Support original declarations, etc., where there is no actual |
| 182 // reflected type. | 190 // reflected type. |
| 183 final Type reflectedType; | 191 final Type reflectedType; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 bool get isSetter => | 330 bool get isSetter => |
| 323 throw new UnimplementedError("MethodMirror.isSetter unimplemented"); | 331 throw new UnimplementedError("MethodMirror.isSetter unimplemented"); |
| 324 bool get isStatic => | 332 bool get isStatic => |
| 325 throw new UnimplementedError("MethodMirror.isStatic unimplemented"); | 333 throw new UnimplementedError("MethodMirror.isStatic unimplemented"); |
| 326 bool get isSynthetic => | 334 bool get isSynthetic => |
| 327 throw new UnimplementedError("MethodMirror.isSynthetic unimplemented"); | 335 throw new UnimplementedError("MethodMirror.isSynthetic unimplemented"); |
| 328 bool get isTopLevel => | 336 bool get isTopLevel => |
| 329 throw new UnimplementedError("MethodMirror.isTopLevel unimplemented"); | 337 throw new UnimplementedError("MethodMirror.isTopLevel unimplemented"); |
| 330 SourceLocation get location => | 338 SourceLocation get location => |
| 331 throw new UnimplementedError("MethodMirror.location unimplemented"); | 339 throw new UnimplementedError("MethodMirror.location unimplemented"); |
| 332 List<InstanceMirror> get metadata => | 340 List<InstanceMirror> get metadata { |
| 333 throw new UnimplementedError("MethodMirror.metadata unimplemented"); | 341 // TODO(vsm): Parse and store method metadata |
| 342 return <InstanceMirror>[]; | |
| 343 } | |
| 334 DeclarationMirror get owner => | 344 DeclarationMirror get owner => |
| 335 throw new UnimplementedError("MethodMirror.owner unimplemented"); | 345 throw new UnimplementedError("MethodMirror.owner unimplemented"); |
| 336 Symbol get qualifiedName => | 346 Symbol get qualifiedName => |
| 337 throw new UnimplementedError("MethodMirror.qualifiedName unimplemented"); | 347 throw new UnimplementedError("MethodMirror.qualifiedName unimplemented"); |
| 338 TypeMirror get returnType => | 348 TypeMirror get returnType => |
| 339 throw new UnimplementedError("MethodMirror.returnType unimplemented"); | 349 throw new UnimplementedError("MethodMirror.returnType unimplemented"); |
| 340 Symbol get simpleName => | 350 Symbol get simpleName => |
| 341 throw new UnimplementedError("MethodMirror.simpleName unimplemented"); | 351 throw new UnimplementedError("MethodMirror.simpleName unimplemented"); |
| 342 String get source => | 352 String get source => |
| 343 throw new UnimplementedError("MethodMirror.source unimplemented"); | 353 throw new UnimplementedError("MethodMirror.source unimplemented"); |
| 344 } | 354 } |
| OLD | NEW |