Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: runtime/lib/mirrors_impl.dart

Issue 18463003: Implement the invoke methods (invoke, getField, setField, newInstance, apply) as internal natives. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // These values are allowed to be passed directly over the wire. 7 // These values are allowed to be passed directly over the wire.
8 bool _isSimpleValue(var value) { 8 bool _isSimpleValue(var value) {
9 return (value == null || value is num || value is String || value is bool); 9 return (value == null || value is num || value is String || value is bool);
10 } 10 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 var result = new Map<Uri, LibraryMirror>(); 66 var result = new Map<Uri, LibraryMirror>();
67 map.forEach((String url, LibraryMirror mirror) { 67 map.forEach((String url, LibraryMirror mirror) {
68 result[Uri.parse(url)] = mirror; 68 result[Uri.parse(url)] = mirror;
69 }); 69 });
70 return result; 70 return result;
71 } 71 }
72 72
73 List<InstanceMirror> _metadata(mirror) 73 List<InstanceMirror> _metadata(mirror)
74 native 'Mirrors_metadata'; 74 native 'Mirrors_metadata';
75 75
76 // This will verify the argument types, unwrap them, and ensure we have a fixed
77 // array.
78 List _unwarpAsyncPositionals(wrappedArgs){
79 List unwrappedArgs = new List(wrappedArgs.length);
80 for(int i = 0; i < wrappedArgs.length; i++){
81 var wrappedArg = wrappedArgs[i];
82 if(_isSimpleValue(wrappedArg)) {
83 unwrappedArgs[i] = wrappedArg;
84 } else if(wrappedArg is InstanceMirror) {
85 unwrappedArgs[i] = wrappedArg._reflectee;
86 } else {
87 throw "positional argument $i ($arg) was not a simple value or InstanceMir ror";
88 }
89 }
90 return unwrappedArgs;
91 }
76 92
77 class _LocalMirrorSystemImpl extends MirrorSystem { 93 class _LocalMirrorSystemImpl extends MirrorSystem {
78 // Change parameter back to "this.libraries" when native code is changed. 94 // Change parameter back to "this.libraries" when native code is changed.
79 _LocalMirrorSystemImpl(Map<String, LibraryMirror> libraries, this.isolate) 95 _LocalMirrorSystemImpl(Map<String, LibraryMirror> libraries, this.isolate)
80 : this.libraries = _createLibrariesMap(libraries), 96 : this.libraries = _createLibrariesMap(libraries),
81 _functionTypes = new Map<String, FunctionTypeMirror>(); 97 _functionTypes = new Map<String, FunctionTypeMirror>();
82 98
83 final Map<Uri, LibraryMirror> libraries; 99 final Map<Uri, LibraryMirror> libraries;
84 final IsolateMirror isolate; 100 final IsolateMirror isolate;
85 101
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 174
159 // For now, all VMObjects hold a VMReference. We could consider 175 // For now, all VMObjects hold a VMReference. We could consider
160 // storing the Object reference itself here if the object is a Dart 176 // storing the Object reference itself here if the object is a Dart
161 // language objects (except for objects of type VMReference, of 177 // language objects (except for objects of type VMReference, of
162 // course). 178 // course).
163 VMReference _reference; 179 VMReference _reference;
164 } 180 }
165 181
166 abstract class _LocalObjectMirrorImpl extends _LocalVMObjectMirrorImpl 182 abstract class _LocalObjectMirrorImpl extends _LocalVMObjectMirrorImpl
167 implements ObjectMirror { 183 implements ObjectMirror {
168 _LocalObjectMirrorImpl(ref) : super(ref) {} 184 _LocalObjectMirrorImpl(this._reflectee, ref) : super(ref) {}
185
186 final _reflectee; // May be a MirrorReference or an ordinary object.
169 187
170 InstanceMirror invoke(Symbol memberName, 188 InstanceMirror invoke(Symbol memberName,
171 List positionalArguments, 189 List positionalArguments,
172 [Map<Symbol, dynamic> namedArguments]) { 190 [Map<Symbol, dynamic> namedArguments]) {
173 if (namedArguments != null) { 191 if (namedArguments != null) {
174 throw new UnimplementedError( 192 throw new UnimplementedError(
175 'named argument support is not implemented'); 193 'named argument support is not implemented');
176 } 194 }
177 return _invoke(this, _n(memberName), positionalArguments, false); 195 return reflect(this._invoke(_reflectee,
196 _n(memberName),
197 positionalArguments.toList(growable:false)));
178 } 198 }
179 199
180 InstanceMirror getField(Symbol fieldName) { 200 InstanceMirror getField(Symbol memberName) {
181 return _getField(this, _n(fieldName)); 201 return reflect(this._invokeGetter(_reflectee,
202 _n(memberName)));
182 } 203 }
183 204
184 InstanceMirror setField(Symbol fieldName, Object arg) { 205 InstanceMirror setField(Symbol memberName, Object value) {
185 return _setField(this, _n(fieldName), arg, false); 206 return reflect(this._invokeSetter(_reflectee,
207 _n(memberName),
208 value));
186 } 209 }
187 210
188 Future<InstanceMirror> invokeAsync(Symbol memberName, 211 Future<InstanceMirror> invokeAsync(Symbol memberName,
189 List positionalArguments, 212 List positionalArguments,
190 [Map<Symbol, dynamic> namedArguments]) { 213 [Map<Symbol, dynamic> namedArguments]) {
191 if (namedArguments != null) { 214 if (namedArguments != null) {
192 throw new UnimplementedError( 215 throw new UnimplementedError(
193 'named argument support is not implemented'); 216 'named argument support is not implemented');
194 } 217 }
195 // Walk the arguments and make sure they are legal. 218
196 for (int i = 0; i < positionalArguments.length; i++) {
197 var arg = positionalArguments[i];
198 _validateArgument(i, arg);
199 }
200 try { 219 try {
201 return new Future<InstanceMirror>.value( 220 var result = this._invoke(_reflectee,
202 _invoke(this, _n(memberName), positionalArguments, true)); 221 _n(memberName),
203 } catch (exception, s) { 222 _unwarpAsyncPositionals(positionalArguments));
204 return new Future<InstanceMirror>.error(exception, s); 223 return new Future.value(reflect(result));
224 } on MirroredError catch(e) {
225 return new Future.error(e);
205 } 226 }
206 } 227 }
207 228
208 Future<InstanceMirror> getFieldAsync(Symbol fieldName) { 229 Future<InstanceMirror> getFieldAsync(Symbol memberName) {
209 try { 230 try {
210 return new Future<InstanceMirror>.value(_getField(this, _n(fieldName))); 231 var result = this._invokeGetter(_reflectee,
211 } catch (exception, s) { 232 _n(memberName));
212 return new Future<InstanceMirror>.error(exception, s); 233 return new Future.value(reflect(result));
234 } on MirroredError catch(e) {
235 return new Future.error(e);
213 } 236 }
214 } 237 }
215 238
216 Future<InstanceMirror> setFieldAsync(Symbol fieldName, Object arg) { 239 Future<InstanceMirror> setFieldAsync(Symbol memberName, Object value) {
217 _validateArgument(0, arg); 240 try {
241 var unwrappedValue;
242 if(_isSimpleValue(value)) {
243 unwrappedValue = value;
244 } else if(wrappedArg is InstanceMirror) {
245 unwrappedValue = value._reflectee;
246 } else {
247 throw "setter argument ($value) must be a simple value or InstanceMirror ";
248 }
218 249
219 try { 250 var result = this._invokeSetter(_reflectee,
220 return new Future<InstanceMirror>.value( 251 _n(memberName),
221 _setField(this, _n(fieldName), arg, true)); 252 unwrappedValue);
222 } catch (exception, s) { 253 return new Future.value(reflect(result));
223 return new Future<InstanceMirror>.error(exception, s); 254 } on MirroredError catch(e) {
255 return new Future.error(e);
224 } 256 }
225 } 257 }
226 258
227 static _validateArgument(int i, Object arg) 259 static _validateArgument(int i, Object arg)
228 { 260 {
229 if (arg is Mirror) { 261 if (arg is Mirror) {
230 if (arg is! InstanceMirror) { 262 if (arg is! InstanceMirror) {
231 throw new MirrorException( 263 throw new MirrorException(
232 'positional argument $i ($arg) was not an InstanceMirror'); 264 'positional argument $i ($arg) was not an InstanceMirror');
233 } 265 }
234 } else if (!_isSimpleValue(arg)) { 266 } else if (!_isSimpleValue(arg)) {
235 throw new MirrorException( 267 throw new MirrorException(
236 'positional argument $i ($arg) was not a simple value'); 268 'positional argument $i ($arg) was not a simple value');
237 } 269 }
238 } 270 }
239
240 static _invoke(ref, memberName, positionalArguments, async)
241 native 'LocalObjectMirrorImpl_invoke';
242
243 static _getField(ref, fieldName) // same for sync and async versions
244 native 'LocalObjectMirrorImpl_getField';
245
246 static _setField(ref, fieldName, value, async)
247 native 'LocalObjectMirrorImpl_setField';
248 } 271 }
249 272
250 class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl 273 class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl
251 implements InstanceMirror { 274 implements InstanceMirror {
252 // TODO(ahe): This is a hack, see delegate below. 275 // TODO(ahe): This is a hack, see delegate below.
253 static Function _invokeOnClosure; 276 static Function _invokeOnClosure;
254 277
255 _LocalInstanceMirrorImpl(ref, 278 _LocalInstanceMirrorImpl(ref,
256 this._type, 279 this._type,
257 this._reflectee) : super(ref) {} 280 reflectee) : super(reflectee, ref) {}
258 281
259 var _type; 282 var _type;
260 ClassMirror get type { 283 ClassMirror get type {
261 if (_type is! Mirror) { 284 if (_type is! Mirror) {
262 _type = _type.resolve(mirrors); 285 _type = _type.resolve(mirrors);
263 } 286 }
264 return _type; 287 return _type;
265 } 288 }
266 289
267 // LocalInstanceMirrors always reflect local instances 290 // LocalInstanceMirrors always reflect local instances
268 bool hasReflectee = true; 291 bool hasReflectee = true;
269 292
270 var _reflectee;
271 get reflectee => _reflectee; 293 get reflectee => _reflectee;
272 294
273 delegate(Invocation invocation) { 295 delegate(Invocation invocation) {
274 if (_invokeOnClosure == null) { 296 if (_invokeOnClosure == null) {
275 // TODO(ahe): This is a total hack. We're using the mirror 297 // TODO(ahe): This is a total hack. We're using the mirror
276 // system to access a private field in a different library. For 298 // system to access a private field in a different library. For
277 // some reason, that works. On the other hand, calling a 299 // some reason, that works. On the other hand, calling a
278 // private method does not work. 300 // private method does not work.
301
279 _LocalInstanceMirrorImpl mirror = 302 _LocalInstanceMirrorImpl mirror =
280 _Mirrors.makeLocalInstanceMirror(invocation); 303 _Mirrors.makeLocalInstanceMirror(invocation);
281 _invokeOnClosure = 304 _invokeOnClosure =
282 _LocalObjectMirrorImpl._getField(mirror.type, '_invokeOnClosure') 305 reflectClass(invocation.runtimeType).getField(const Symbol('_invokeOnC losure')).reflectee;
283 .reflectee;
284 } 306 }
285 return _invokeOnClosure(reflectee, invocation); 307 return _invokeOnClosure(reflectee, invocation);
286 } 308 }
287 309
288 String toString() => 'InstanceMirror on ${Error.safeToString(_reflectee)}'; 310 String toString() => 'InstanceMirror on ${Error.safeToString(_reflectee)}';
311
312 _invoke(reflectee, functionName, positionalArguments)
313 native 'InstanceMirror_invoke';
314
315 _invokeGetter(reflectee, getterName)
316 native 'InstanceMirror_invokeGetter';
317
318 _invokeSetter(reflectee, setterName, value)
319 native 'InstanceMirror_invokeSetter';
289 } 320 }
290 321
291 class _LocalClosureMirrorImpl extends _LocalInstanceMirrorImpl 322 class _LocalClosureMirrorImpl extends _LocalInstanceMirrorImpl
292 implements ClosureMirror { 323 implements ClosureMirror {
293 _LocalClosureMirrorImpl(ref, 324 _LocalClosureMirrorImpl(ref,
294 type, 325 type,
295 reflectee, 326 reflectee,
296 this.function) : super(ref, type, reflectee) {} 327 this.function) : super(ref, type, reflectee) {}
297 328
298 final MethodMirror function; 329 final MethodMirror function;
299 330
300 String get source { 331 String get source {
301 throw new UnimplementedError( 332 throw new UnimplementedError(
302 'ClosureMirror.source is not implemented'); 333 'ClosureMirror.source is not implemented');
303 } 334 }
304 335
305 InstanceMirror apply(List<Object> positionalArguments, 336 InstanceMirror apply(List<Object> positionalArguments,
306 [Map<Symbol, Object> namedArguments]) { 337 [Map<Symbol, Object> namedArguments]) {
307 if (namedArguments != null) { 338 if (namedArguments != null) {
308 throw new UnimplementedError( 339 throw new UnimplementedError(
309 'named argument support is not implemented'); 340 'named argument support is not implemented');
310 } 341 }
311 return _apply(this, positionalArguments, false); 342 // It is tempting to implement this in terms of Function.apply, but then
343 // lazy compilation errors would be fatal.
344 return reflect(_apply(_reflectee,
345 positionalArguments.toList(growable:false)));
312 } 346 }
313 347
314 Future<InstanceMirror> applyAsync(List<Object> positionalArguments, 348 Future<InstanceMirror> applyAsync(List positionalArguments,
315 [Map<Symbol, Object> namedArguments]) { 349 [Map<Symbol, dynamic> namedArguments]) {
316 if (namedArguments != null) { 350 if (namedArguments != null) {
317 throw new UnimplementedError( 351 throw new UnimplementedError(
318 'named argument support is not implemented'); 352 'named argument support is not implemented');
319 } 353 }
320 // Walk the arguments and make sure they are legal. 354
321 for (int i = 0; i < positionalArguments.length; i++) {
322 var arg = positionalArguments[i];
323 _LocalObjectMirrorImpl._validateArgument(i, arg);
324 }
325 try { 355 try {
326 return new Future<InstanceMirror>.value( 356 var result = _apply(_reflectee,
327 _apply(this, positionalArguments, true)); 357 _unwarpAsyncPositionals(positionalArguments));
328 } catch (exception) { 358 return new Future.value(reflect(result));
329 return new Future<InstanceMirror>.error(exception); 359 } on MirroredError catch(e) {
360 return new Future.error(e);
330 } 361 }
331 } 362 }
332 363
364
365
333 Future<InstanceMirror> findInContext(Symbol name) { 366 Future<InstanceMirror> findInContext(Symbol name) {
334 throw new UnimplementedError( 367 throw new UnimplementedError(
335 'ClosureMirror.findInContext() is not implemented'); 368 'ClosureMirror.findInContext() is not implemented');
336 } 369 }
337 370
338 static _apply(ref, positionalArguments, async) 371 static _apply(reflectee, positionalArguments)
339 native 'LocalClosureMirrorImpl_apply'; 372 native 'ClosureMirror_apply';
340 373
341 String toString() => "ClosureMirror on '${Error.safeToString(_reflectee)}'"; 374 String toString() => "ClosureMirror on '${Error.safeToString(_reflectee)}'";
342 } 375 }
343 376
344 class _LazyTypeMirror { 377 class _LazyTypeMirror {
345 _LazyTypeMirror(String this.libraryUrl, String typeName) 378 _LazyTypeMirror(String this.libraryUrl, String typeName)
346 : this.typeName = _s(typeName); 379 : this.typeName = _s(typeName);
347 380
348 TypeMirror resolve(MirrorSystem mirrors) { 381 TypeMirror resolve(MirrorSystem mirrors) {
349 if (libraryUrl == null) { 382 if (libraryUrl == null) {
(...skipping 13 matching lines...) Expand all
363 } 396 }
364 return resolved; 397 return resolved;
365 } 398 }
366 399
367 final String libraryUrl; 400 final String libraryUrl;
368 final Symbol typeName; 401 final Symbol typeName;
369 } 402 }
370 403
371 class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl 404 class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl
372 implements ClassMirror { 405 implements ClassMirror {
373 _LocalClassMirrorImpl(this._reflectee, 406 _LocalClassMirrorImpl(reflectee,
374 ref, 407 ref,
375 String simpleName, 408 String simpleName,
376 this.isClass, 409 this.isClass,
377 this._owner, 410 this._owner,
378 this._superclass, 411 this._superclass,
379 this._superinterfaces, 412 this._superinterfaces,
380 this._defaultFactory, 413 this._defaultFactory,
381 Map<String, Mirror> members, 414 Map<String, Mirror> members,
382 Map<String, Mirror> constructors, 415 Map<String, Mirror> constructors,
383 Map<String, Mirror> typeVariables) 416 Map<String, Mirror> typeVariables)
384 : this._simpleName = _s(simpleName), 417 : this._simpleName = _s(simpleName),
385 this.members = _convertStringToSymbolMap(members), 418 this.members = _convertStringToSymbolMap(members),
386 this.constructors = _convertStringToSymbolMap(constructors), 419 this.constructors = _convertStringToSymbolMap(constructors),
387 this.typeVariables = _convertStringToSymbolMap(typeVariables), 420 this.typeVariables = _convertStringToSymbolMap(typeVariables),
388 super(ref); 421 super(reflectee, ref);
389
390 final _MirrorReference _reflectee;
391 422
392 Symbol _simpleName; 423 Symbol _simpleName;
393 Symbol get simpleName { 424 Symbol get simpleName {
394 // dynamic, void and the function types have their names set eagerly in the 425 // dynamic, void and the function types have their names set eagerly in the
395 // constructor. 426 // constructor.
396 if(_simpleName == null) { 427 if(_simpleName == null) {
397 _simpleName = _s(_ClassMirror_name(_reflectee)); 428 _simpleName = _s(_name(_reflectee));
398 } 429 }
399 return _simpleName; 430 return _simpleName;
400 } 431 }
401 432
402 Symbol _qualifiedName = null; 433 Symbol _qualifiedName = null;
403 Symbol get qualifiedName { 434 Symbol get qualifiedName {
404 if (_qualifiedName == null) { 435 if (_qualifiedName == null) {
405 _qualifiedName = _computeQualifiedName(owner, simpleName); 436 _qualifiedName = _computeQualifiedName(owner, simpleName);
406 } 437 }
407 return _qualifiedName; 438 return _qualifiedName;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 return "$prettyName on '${_n(simpleName)}'"; 552 return "$prettyName on '${_n(simpleName)}'";
522 } 553 }
523 554
524 InstanceMirror newInstance(Symbol constructorName, 555 InstanceMirror newInstance(Symbol constructorName,
525 List positionalArguments, 556 List positionalArguments,
526 [Map<Symbol, dynamic> namedArguments]) { 557 [Map<Symbol, dynamic> namedArguments]) {
527 if (namedArguments != null) { 558 if (namedArguments != null) {
528 throw new UnimplementedError( 559 throw new UnimplementedError(
529 'named argument support is not implemented'); 560 'named argument support is not implemented');
530 } 561 }
531 return _invokeConstructor(this, 562 return reflect(_invokeConstructor(_reflectee,
532 _n(constructorName), 563 _n(constructorName),
533 positionalArguments, 564 positionalArguments.toList(growable:false) ));
534 false);
535 } 565 }
536 566
537 Future<InstanceMirror> newInstanceAsync(Symbol constructorName, 567 Future<InstanceMirror> newInstanceAsync(Symbol constructorName,
538 List positionalArguments, 568 List positionalArguments,
539 [Map<Symbol, dynamic> namedArguments]) { 569 [Map<Symbol, dynamic> namedArguments]) {
540 if (namedArguments != null) { 570 if (namedArguments != null) {
541 throw new UnimplementedError( 571 throw new UnimplementedError(
542 'named argument support is not implemented'); 572 'named argument support is not implemented');
543 } 573 }
544 // Walk the arguments and make sure they are legal. 574
545 for (int i = 0; i < positionalArguments.length; i++) {
546 var arg = positionalArguments[i];
547 _LocalObjectMirrorImpl._validateArgument(i, arg);
548 }
549 try { 575 try {
550 return new Future<InstanceMirror>.value( 576 var result = _invokeConstructor(_reflectee,
551 _invokeConstructor(this, 577 _n(constructorName),
552 _n(constructorName), 578 _unwarpAsyncPositionals(positionalArgument s));
553 positionalArguments, 579 return new Future.value(reflect(result));
554 true)); 580 } on MirroredError catch(e) {
555 } catch (exception) { 581 return new Future.error(e);
556 return new Future<InstanceMirror>.error(exception);
557 } 582 }
558 } 583 }
559 584
560 // get the metadata objects, convert them into InstanceMirrors using 585 // get the metadata objects, convert them into InstanceMirrors using
561 // reflect() and then make them into a Dart list 586 // reflect() and then make them into a Dart list
562 List<InstanceMirror> get metadata => _metadata(this).map(reflect).toList(); 587 List<InstanceMirror> get metadata => _metadata(this).map(reflect).toList();
563 588
564 static _invokeConstructor(ref, constructorName, positionalArguments, async)
565 native 'LocalClassMirrorImpl_invokeConstructor';
566 589
567 static String _ClassMirror_name(reflectee) 590 static _name(reflectee)
568 native "ClassMirror_name"; 591 native "ClassMirror_name";
592
593 _invoke(reflectee, memberName, positionalArguments)
594 native 'ClassMirror_invoke';
595
596 _invokeGetter(reflectee, getterName)
597 native 'ClassMirror_invokeGetter';
598
599 _invokeSetter(reflectee, setterName, value)
600 native 'ClassMirror_invokeSetter';
601
602 static _invokeConstructor(reflectee, constructorName, positionalArguments)
603 native 'ClassMirror_invokeConstructor';
569 } 604 }
570 605
571 class _LazyFunctionTypeMirror { 606 class _LazyFunctionTypeMirror {
572 _LazyFunctionTypeMirror(this.returnType, this.parameters) {} 607 _LazyFunctionTypeMirror(this.returnType, this.parameters) {}
573 608
574 ClassMirror resolve(MirrorSystem mirrors) { 609 ClassMirror resolve(MirrorSystem mirrors) {
575 return mirrors._lookupFunctionTypeMirror(returnType.resolve(mirrors), 610 return mirrors._lookupFunctionTypeMirror(returnType.resolve(mirrors),
576 parameters); 611 parameters);
577 } 612 }
578 613
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 761
727 LibraryMirror resolve(MirrorSystem mirrors) { 762 LibraryMirror resolve(MirrorSystem mirrors) {
728 return mirrors.libraries[Uri.parse(libraryUrl)]; 763 return mirrors.libraries[Uri.parse(libraryUrl)];
729 } 764 }
730 765
731 final String libraryUrl; 766 final String libraryUrl;
732 } 767 }
733 768
734 class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl 769 class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl
735 implements LibraryMirror { 770 implements LibraryMirror {
736 _LocalLibraryMirrorImpl(ref, 771 _LocalLibraryMirrorImpl(reflectee,
772 ref,
737 String simpleName, 773 String simpleName,
738 String url, 774 String url,
739 Map<String, Mirror> members) 775 Map<String, Mirror> members)
740 : this.simpleName = _s(simpleName), 776 : this.simpleName = _s(simpleName),
741 this.members = _convertStringToSymbolMap(members), 777 this.members = _convertStringToSymbolMap(members),
742 this.uri = Uri.parse(url), 778 this.uri = Uri.parse(url),
743 super(ref); 779 super(reflectee, ref);
744 780
745 final Symbol simpleName; 781 final Symbol simpleName;
746 782
747 // The simple name and the qualified name are the same for a library. 783 // The simple name and the qualified name are the same for a library.
748 Symbol get qualifiedName => simpleName; 784 Symbol get qualifiedName => simpleName;
749 785
750 // Always null for libraries. 786 // Always null for libraries.
751 final DeclarationMirror owner = null; 787 final DeclarationMirror owner = null;
752 788
753 // Always false for libraries. 789 // Always false for libraries.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 (key, value) => (value is VariableMirror)); 844 (key, value) => (value is VariableMirror));
809 } 845 }
810 return _variables; 846 return _variables;
811 } 847 }
812 848
813 // get the metadata objects, convert them into InstanceMirrors using 849 // get the metadata objects, convert them into InstanceMirrors using
814 // reflect() and then make them into a Dart list 850 // reflect() and then make them into a Dart list
815 List<InstanceMirror> get metadata => _metadata(this).map(reflect).toList(); 851 List<InstanceMirror> get metadata => _metadata(this).map(reflect).toList();
816 852
817 String toString() => "LibraryMirror on '${_n(simpleName)}'"; 853 String toString() => "LibraryMirror on '${_n(simpleName)}'";
854
855 _invoke(reflectee, memberName, positionalArguments)
856 native 'LibraryMirror_invoke';
857
858 _invokeGetter(reflectee, getterName)
859 native 'LibraryMirror_invokeGetter';
860
861 _invokeSetter(reflectee, setterName, value)
862 native 'LibraryMirror_invokeSetter';
818 } 863 }
819 864
820 class _LocalMethodMirrorImpl extends _LocalMirrorImpl 865 class _LocalMethodMirrorImpl extends _LocalMirrorImpl
821 implements MethodMirror { 866 implements MethodMirror {
822 _LocalMethodMirrorImpl(this._reflectee, 867 _LocalMethodMirrorImpl(this._reflectee,
823 this._owner, 868 this._owner,
824 this.parameters, 869 this.parameters,
825 this._returnType, 870 this._returnType,
826 this.isStatic, 871 this.isStatic,
827 this.isAbstract, 872 this.isAbstract,
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 } 1126 }
1082 1127
1083 // Creates a new local ClassMirror. 1128 // Creates a new local ClassMirror.
1084 static ClassMirror makeLocalClassMirror(Type key) 1129 static ClassMirror makeLocalClassMirror(Type key)
1085 native "Mirrors_makeLocalClassMirror"; 1130 native "Mirrors_makeLocalClassMirror";
1086 1131
1087 static ClassMirror reflectClass(Type key) { 1132 static ClassMirror reflectClass(Type key) {
1088 return makeLocalClassMirror(key); 1133 return makeLocalClassMirror(key);
1089 } 1134 }
1090 } 1135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698