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

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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 184
169 // For now, all VMObjects hold a VMReference. We could consider 185 // For now, all VMObjects hold a VMReference. We could consider
170 // storing the Object reference itself here if the object is a Dart 186 // storing the Object reference itself here if the object is a Dart
171 // language objects (except for objects of type VMReference, of 187 // language objects (except for objects of type VMReference, of
172 // course). 188 // course).
173 VMReference _reference; 189 VMReference _reference;
174 } 190 }
175 191
176 abstract class _LocalObjectMirrorImpl extends _LocalVMObjectMirrorImpl 192 abstract class _LocalObjectMirrorImpl extends _LocalVMObjectMirrorImpl
177 implements ObjectMirror { 193 implements ObjectMirror {
178 _LocalObjectMirrorImpl(ref) : super(ref) {} 194 _LocalObjectMirrorImpl(this._reflectee, ref) : super(ref) {}
195
196 final _reflectee; // May be a MirrorReference or an ordinary object
179 197
180 InstanceMirror invoke(Symbol memberName, 198 InstanceMirror invoke(Symbol memberName,
181 List positionalArguments, 199 List positionalArguments,
182 [Map<Symbol, dynamic> namedArguments]) { 200 [Map<Symbol, dynamic> namedArguments]) {
183 if (namedArguments != null) { 201 if (namedArguments != null) {
184 throw new UnimplementedError( 202 throw new UnimplementedError(
185 'named argument support is not implemented'); 203 'named argument support is not implemented');
186 } 204 }
187 return _invoke(this, _n(memberName), positionalArguments, false); 205 return reflect(this._invoke(_reflectee,
206 _n(memberName),
207 positionalArguments.toList(growable:false)));
188 } 208 }
189 209
190 InstanceMirror getField(Symbol fieldName) { 210 InstanceMirror getField(Symbol memberName) {
191 return _getField(this, _n(fieldName)); 211 return reflect(this._invokeGetter(_reflectee,
212 _n(memberName)));
192 } 213 }
193 214
194 InstanceMirror setField(Symbol fieldName, Object arg) { 215 InstanceMirror setField(Symbol memberName, Object value) {
195 return _setField(this, _n(fieldName), arg, false); 216 return reflect(this._invokeSetter(_reflectee,
217 _n(memberName),
218 value));
196 } 219 }
197 220
198 Future<InstanceMirror> invokeAsync(Symbol memberName, 221 Future<InstanceMirror> invokeAsync(Symbol memberName,
199 List positionalArguments, 222 List positionalArguments,
200 [Map<Symbol, dynamic> namedArguments]) { 223 [Map<Symbol, dynamic> namedArguments]) {
201 if (namedArguments != null) { 224 if (namedArguments != null) {
202 throw new UnimplementedError( 225 throw new UnimplementedError(
203 'named argument support is not implemented'); 226 'named argument support is not implemented');
204 } 227 }
205 // Walk the arguments and make sure they are legal. 228
206 for (int i = 0; i < positionalArguments.length; i++) {
207 var arg = positionalArguments[i];
208 _validateArgument(i, arg);
209 }
210 try { 229 try {
211 return new Future<InstanceMirror>.value( 230 var result = this._invoke(_reflectee,
212 _invoke(this, _n(memberName), positionalArguments, true)); 231 _n(memberName),
213 } catch (exception, s) { 232 _unwarpAsyncPositionals(positionalArguments));
214 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);
215 } 236 }
216 } 237 }
217 238
218 Future<InstanceMirror> getFieldAsync(Symbol fieldName) { 239 Future<InstanceMirror> getFieldAsync(Symbol memberName) {
219 try { 240 try {
220 return new Future<InstanceMirror>.value(_getField(this, _n(fieldName))); 241 var result = this._invokeGetter(_reflectee,
221 } catch (exception, s) { 242 _n(memberName));
222 return new Future<InstanceMirror>.error(exception, s); 243 return new Future.value(reflect(result));
244 } on MirroredError catch(e) {
245 return new Future.error(e);
223 } 246 }
224 } 247 }
225 248
226 Future<InstanceMirror> setFieldAsync(Symbol fieldName, Object arg) { 249 Future<InstanceMirror> setFieldAsync(Symbol memberName, Object value) {
227 _validateArgument(0, arg); 250 try {
251 var unwrappedValue;
252 if(_isSimpleValue(value)) {
253 unwrappedValue = value;
254 } else if(wrappedArg is InstanceMirror) {
255 unwrappedValue = value._reflectee;
256 } else {
257 throw "setter argument ($value) must be a simple value or InstanceMirror ";
258 }
228 259
229 try { 260 var result = this._invokeSetter(_reflectee,
230 return new Future<InstanceMirror>.value( 261 _n(memberName),
231 _setField(this, _n(fieldName), arg, true)); 262 unwrappedValue);
232 } catch (exception, s) { 263 return new Future.value(reflect(result));
233 return new Future<InstanceMirror>.error(exception, s); 264 } on MirroredError catch(e) {
265 return new Future.error(e);
234 } 266 }
235 } 267 }
236 268
237 static _validateArgument(int i, Object arg) 269 static _validateArgument(int i, Object arg)
238 { 270 {
239 if (arg is Mirror) { 271 if (arg is Mirror) {
240 if (arg is! InstanceMirror) { 272 if (arg is! InstanceMirror) {
241 throw new MirrorException( 273 throw new MirrorException(
242 'positional argument $i ($arg) was not an InstanceMirror'); 274 'positional argument $i ($arg) was not an InstanceMirror');
243 } 275 }
244 } else if (!_isSimpleValue(arg)) { 276 } else if (!_isSimpleValue(arg)) {
245 throw new MirrorException( 277 throw new MirrorException(
246 'positional argument $i ($arg) was not a simple value'); 278 'positional argument $i ($arg) was not a simple value');
247 } 279 }
248 } 280 }
249
250 static _invoke(ref, memberName, positionalArguments, async)
251 native 'LocalObjectMirrorImpl_invoke';
252
253 static _getField(ref, fieldName) // same for sync and async versions
254 native 'LocalObjectMirrorImpl_getField';
255
256 static _setField(ref, fieldName, value, async)
257 native 'LocalObjectMirrorImpl_setField';
258 } 281 }
259 282
260 class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl 283 class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl
261 implements InstanceMirror { 284 implements InstanceMirror {
262 // TODO(ahe): This is a hack, see delegate below. 285 // TODO(ahe): This is a hack, see delegate below.
263 static Function _invokeOnClosure; 286 static Function _invokeOnClosure;
264 287
265 _LocalInstanceMirrorImpl(ref, 288 _LocalInstanceMirrorImpl(ref,
266 this._type, 289 this._type,
267 this._reflectee) : super(ref) {} 290 reflectee) : super(reflectee, ref) {}
268 291
269 var _type; 292 var _type;
270 ClassMirror get type { 293 ClassMirror get type {
271 if (_type is! Mirror) { 294 if (_type is! Mirror) {
272 _type = _type.resolve(mirrors); 295 _type = _type.resolve(mirrors);
273 } 296 }
274 return _type; 297 return _type;
275 } 298 }
276 299
277 // LocalInstanceMirrors always reflect local instances 300 // LocalInstanceMirrors always reflect local instances
278 bool hasReflectee = true; 301 bool hasReflectee = true;
279 302
280 var _reflectee;
281 get reflectee => _reflectee; 303 get reflectee => _reflectee;
282 304
283 delegate(Invocation invocation) { 305 delegate(Invocation invocation) {
284 if (_invokeOnClosure == null) { 306 if (_invokeOnClosure == null) {
285 // TODO(ahe): This is a total hack. We're using the mirror 307 // TODO(ahe): This is a total hack. We're using the mirror
286 // system to access a private field in a different library. For 308 // system to access a private field in a different library. For
287 // some reason, that works. On the other hand, calling a 309 // some reason, that works. On the other hand, calling a
288 // private method does not work. 310 // private method does not work.
311
289 _LocalInstanceMirrorImpl mirror = 312 _LocalInstanceMirrorImpl mirror =
290 _Mirrors.makeLocalInstanceMirror(invocation); 313 _Mirrors.makeLocalInstanceMirror(invocation);
291 _invokeOnClosure = 314 _invokeOnClosure =
292 _LocalObjectMirrorImpl._getField(mirror.type, '_invokeOnClosure') 315 reflectClass(invocation.runtimeType).getField(const Symbol('_invokeOnC losure')).reflectee;
293 .reflectee;
294 } 316 }
295 return _invokeOnClosure(reflectee, invocation); 317 return _invokeOnClosure(reflectee, invocation);
296 } 318 }
297 319
298 String toString() => 'InstanceMirror on ${Error.safeToString(_reflectee)}'; 320 String toString() => 'InstanceMirror on ${Error.safeToString(_reflectee)}';
321
322 _invoke(reflectee, functionName, positionalArguments)
323 native 'InstanceMirror_invoke';
324
325 _invokeGetter(reflectee, getterName)
326 native 'InstanceMirror_invokeGetter';
327
328 _invokeSetter(reflectee, setterName, value)
329 native 'InstanceMirror_invokeSetter';
299 } 330 }
300 331
301 class _LocalClosureMirrorImpl extends _LocalInstanceMirrorImpl 332 class _LocalClosureMirrorImpl extends _LocalInstanceMirrorImpl
302 implements ClosureMirror { 333 implements ClosureMirror {
303 _LocalClosureMirrorImpl(ref, 334 _LocalClosureMirrorImpl(ref,
304 type, 335 type,
305 reflectee, 336 reflectee,
306 this.function) : super(ref, type, reflectee) {} 337 this.function) : super(ref, type, reflectee) {}
307 338
308 final MethodMirror function; 339 final MethodMirror function;
309 340
310 String get source { 341 String get source {
311 throw new UnimplementedError( 342 throw new UnimplementedError(
312 'ClosureMirror.source is not implemented'); 343 'ClosureMirror.source is not implemented');
313 } 344 }
314 345
315 InstanceMirror apply(List<Object> positionalArguments, 346 InstanceMirror apply(List<Object> positionalArguments,
316 [Map<Symbol, Object> namedArguments]) { 347 [Map<Symbol, Object> namedArguments]) {
317 if (namedArguments != null) { 348 if (namedArguments != null) {
318 throw new UnimplementedError( 349 throw new UnimplementedError(
319 'named argument support is not implemented'); 350 'named argument support is not implemented');
320 } 351 }
321 return _apply(this, positionalArguments, false); 352 // It is tempting to implement this in terms of Function.apply, but then
353 // lazy compilation errors would be fatal.
354 return reflect(_apply(_reflectee,
355 positionalArguments.toList(growable:false)));
322 } 356 }
323 357
324 Future<InstanceMirror> applyAsync(List<Object> positionalArguments, 358 Future<InstanceMirror> applyAsync(List positionalArguments,
325 [Map<Symbol, Object> namedArguments]) { 359 [Map<Symbol, dynamic> namedArguments]) {
326 if (namedArguments != null) { 360 if (namedArguments != null) {
327 throw new UnimplementedError( 361 throw new UnimplementedError(
328 'named argument support is not implemented'); 362 'named argument support is not implemented');
329 } 363 }
330 // Walk the arguments and make sure they are legal. 364
331 for (int i = 0; i < positionalArguments.length; i++) {
332 var arg = positionalArguments[i];
333 _LocalObjectMirrorImpl._validateArgument(i, arg);
334 }
335 try { 365 try {
336 return new Future<InstanceMirror>.value( 366 var result = _apply(_reflectee,
337 _apply(this, positionalArguments, true)); 367 _unwarpAsyncPositionals(positionalArguments));
338 } catch (exception) { 368 return new Future.value(reflect(result));
339 return new Future<InstanceMirror>.error(exception); 369 } on MirroredError catch(e) {
370 return new Future.error(e);
340 } 371 }
341 } 372 }
342 373
374
375
343 Future<InstanceMirror> findInContext(Symbol name) { 376 Future<InstanceMirror> findInContext(Symbol name) {
344 throw new UnimplementedError( 377 throw new UnimplementedError(
345 'ClosureMirror.findInContext() is not implemented'); 378 'ClosureMirror.findInContext() is not implemented');
346 } 379 }
347 380
348 static _apply(ref, positionalArguments, async) 381 static _apply(reflectee, positionalArguments)
349 native 'LocalClosureMirrorImpl_apply'; 382 native 'ClosureMirror_apply';
350 383
351 String toString() => "ClosureMirror on '${Error.safeToString(_reflectee)}'"; 384 String toString() => "ClosureMirror on '${Error.safeToString(_reflectee)}'";
352 } 385 }
353 386
354 class _LazyTypeMirror { 387 class _LazyTypeMirror {
355 _LazyTypeMirror(String this.libraryUrl, String typeName) 388 _LazyTypeMirror(String this.libraryUrl, String typeName)
356 : this.typeName = _s(typeName); 389 : this.typeName = _s(typeName);
357 390
358 TypeMirror resolve(MirrorSystem mirrors) { 391 TypeMirror resolve(MirrorSystem mirrors) {
359 if (libraryUrl == null) { 392 if (libraryUrl == null) {
(...skipping 13 matching lines...) Expand all
373 } 406 }
374 return resolved; 407 return resolved;
375 } 408 }
376 409
377 final String libraryUrl; 410 final String libraryUrl;
378 final Symbol typeName; 411 final Symbol typeName;
379 } 412 }
380 413
381 class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl 414 class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl
382 implements ClassMirror { 415 implements ClassMirror {
383 _LocalClassMirrorImpl(this._reflectee, 416 _LocalClassMirrorImpl(reflectee,
384 ref, 417 ref,
385 String simpleName, 418 String simpleName,
386 this.isClass, 419 this.isClass,
387 this._owner, 420 this._owner,
388 this._superclass, 421 this._superclass,
389 this._superinterfaces, 422 this._superinterfaces,
390 this._defaultFactory, 423 this._defaultFactory,
391 Map<String, Mirror> members, 424 Map<String, Mirror> members,
392 Map<String, Mirror> constructors, 425 Map<String, Mirror> constructors,
393 Map<String, Mirror> typeVariables) 426 Map<String, Mirror> typeVariables)
394 : this._simpleName = _s(simpleName), 427 : this._simpleName = _s(simpleName),
395 this.members = _convertStringToSymbolMap(members), 428 this.members = _convertStringToSymbolMap(members),
396 this.constructors = _convertStringToSymbolMap(constructors), 429 this.constructors = _convertStringToSymbolMap(constructors),
397 this.typeVariables = _convertStringToSymbolMap(typeVariables), 430 this.typeVariables = _convertStringToSymbolMap(typeVariables),
398 super(ref); 431 super(reflectee, ref);
399
400 final _MirrorReference _reflectee;
401 432
402 Symbol _simpleName; 433 Symbol _simpleName;
403 Symbol get simpleName { 434 Symbol get simpleName {
404 // dynamic, void and the function types have their names set eagerly in the 435 // dynamic, void and the function types have their names set eagerly in the
405 // constructor. 436 // constructor.
406 if(_simpleName == null) { 437 if(_simpleName == null) {
407 _simpleName = _s(_ClassMirror_name(_reflectee)); 438 _simpleName = _s(_name(_reflectee));
408 } 439 }
409 return _simpleName; 440 return _simpleName;
410 } 441 }
411 442
412 Symbol _qualifiedName = null; 443 Symbol _qualifiedName = null;
413 Symbol get qualifiedName { 444 Symbol get qualifiedName {
414 if (_qualifiedName == null) { 445 if (_qualifiedName == null) {
415 _qualifiedName = _computeQualifiedName(owner, simpleName); 446 _qualifiedName = _computeQualifiedName(owner, simpleName);
416 } 447 }
417 return _qualifiedName; 448 return _qualifiedName;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 return "$prettyName on '${_n(simpleName)}'"; 562 return "$prettyName on '${_n(simpleName)}'";
532 } 563 }
533 564
534 InstanceMirror newInstance(Symbol constructorName, 565 InstanceMirror newInstance(Symbol constructorName,
535 List positionalArguments, 566 List positionalArguments,
536 [Map<Symbol, dynamic> namedArguments]) { 567 [Map<Symbol, dynamic> namedArguments]) {
537 if (namedArguments != null) { 568 if (namedArguments != null) {
538 throw new UnimplementedError( 569 throw new UnimplementedError(
539 'named argument support is not implemented'); 570 'named argument support is not implemented');
540 } 571 }
541 return _invokeConstructor(this, 572 return reflect(_invokeConstructor(_reflectee,
542 _n(constructorName), 573 _n(constructorName),
543 positionalArguments, 574 positionalArguments.toList(growable:false) ));
544 false);
545 } 575 }
546 576
547 Future<InstanceMirror> newInstanceAsync(Symbol constructorName, 577 Future<InstanceMirror> newInstanceAsync(Symbol constructorName,
548 List positionalArguments, 578 List positionalArguments,
549 [Map<Symbol, dynamic> namedArguments]) { 579 [Map<Symbol, dynamic> namedArguments]) {
550 if (namedArguments != null) { 580 if (namedArguments != null) {
551 throw new UnimplementedError( 581 throw new UnimplementedError(
552 'named argument support is not implemented'); 582 'named argument support is not implemented');
553 } 583 }
554 // Walk the arguments and make sure they are legal. 584
555 for (int i = 0; i < positionalArguments.length; i++) {
556 var arg = positionalArguments[i];
557 _LocalObjectMirrorImpl._validateArgument(i, arg);
558 }
559 try { 585 try {
560 return new Future<InstanceMirror>.value( 586 var result = _invokeConstructor(_reflectee,
561 _invokeConstructor(this, 587 _n(constructorName),
562 _n(constructorName), 588 _unwarpAsyncPositionals(positionalArgument s));
563 positionalArguments, 589 return new Future.value(reflect(result));
564 true)); 590 } on MirroredError catch(e) {
565 } catch (exception) { 591 return new Future.error(e);
566 return new Future<InstanceMirror>.error(exception);
567 } 592 }
568 } 593 }
569 594
570 // get the metadata objects, convert them into InstanceMirrors using 595 // get the metadata objects, convert them into InstanceMirrors using
571 // reflect() and then make them into a Dart list 596 // reflect() and then make them into a Dart list
572 List<InstanceMirror> get metadata => _metadata(this).map(reflect).toList(); 597 List<InstanceMirror> get metadata => _metadata(this).map(reflect).toList();
573 598
574 static _invokeConstructor(ref, constructorName, positionalArguments, async)
575 native 'LocalClassMirrorImpl_invokeConstructor';
576 599
577 static String _ClassMirror_name(reflectee) 600 static _name(reflectee)
578 native "ClassMirror_name"; 601 native "ClassMirror_name";
602
603 _invoke(reflectee, memberName, positionalArguments)
604 native 'ClassMirror_invoke';
605
606 _invokeGetter(reflectee, getterName)
607 native 'ClassMirror_invokeGetter';
608
609 _invokeSetter(reflectee, setterName, value)
610 native 'ClassMirror_invokeSetter';
611
612 static _invokeConstructor(reflectee, constructorName, positionalArguments)
613 native 'ClassMirror_invokeConstructor';
579 } 614 }
580 615
581 class _LazyFunctionTypeMirror { 616 class _LazyFunctionTypeMirror {
582 _LazyFunctionTypeMirror(this.returnType, this.parameters) {} 617 _LazyFunctionTypeMirror(this.returnType, this.parameters) {}
583 618
584 ClassMirror resolve(MirrorSystem mirrors) { 619 ClassMirror resolve(MirrorSystem mirrors) {
585 return mirrors._lookupFunctionTypeMirror(returnType.resolve(mirrors), 620 return mirrors._lookupFunctionTypeMirror(returnType.resolve(mirrors),
586 parameters); 621 parameters);
587 } 622 }
588 623
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 771
737 LibraryMirror resolve(MirrorSystem mirrors) { 772 LibraryMirror resolve(MirrorSystem mirrors) {
738 return mirrors.libraries[Uri.parse(libraryUrl)]; 773 return mirrors.libraries[Uri.parse(libraryUrl)];
739 } 774 }
740 775
741 final String libraryUrl; 776 final String libraryUrl;
742 } 777 }
743 778
744 class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl 779 class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl
745 implements LibraryMirror { 780 implements LibraryMirror {
746 _LocalLibraryMirrorImpl(ref, 781 _LocalLibraryMirrorImpl(reflectee,
782 ref,
747 String simpleName, 783 String simpleName,
748 String url, 784 String url,
749 Map<String, Mirror> members) 785 Map<String, Mirror> members)
750 : this.simpleName = _s(simpleName), 786 : this.simpleName = _s(simpleName),
751 this.members = _convertStringToSymbolMap(members), 787 this.members = _convertStringToSymbolMap(members),
752 this.uri = Uri.parse(url), 788 this.uri = Uri.parse(url),
753 super(ref); 789 super(reflectee, ref);
754 790
755 final Symbol simpleName; 791 final Symbol simpleName;
756 792
757 // The simple name and the qualified name are the same for a library. 793 // The simple name and the qualified name are the same for a library.
758 Symbol get qualifiedName => simpleName; 794 Symbol get qualifiedName => simpleName;
759 795
760 // Always null for libraries. 796 // Always null for libraries.
761 final DeclarationMirror owner = null; 797 final DeclarationMirror owner = null;
762 798
763 // Always false for libraries. 799 // Always false for libraries.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 (key, value) => (value is VariableMirror)); 854 (key, value) => (value is VariableMirror));
819 } 855 }
820 return _variables; 856 return _variables;
821 } 857 }
822 858
823 // get the metadata objects, convert them into InstanceMirrors using 859 // get the metadata objects, convert them into InstanceMirrors using
824 // reflect() and then make them into a Dart list 860 // reflect() and then make them into a Dart list
825 List<InstanceMirror> get metadata => _metadata(this).map(reflect).toList(); 861 List<InstanceMirror> get metadata => _metadata(this).map(reflect).toList();
826 862
827 String toString() => "LibraryMirror on '${_n(simpleName)}'"; 863 String toString() => "LibraryMirror on '${_n(simpleName)}'";
864
865 _invoke(reflectee, memberName, positionalArguments)
866 native 'LibraryMirror_invoke';
867
868 _invokeGetter(reflectee, getterName)
869 native 'LibraryMirror_invokeGetter';
870
871 _invokeSetter(reflectee, setterName, value)
872 native 'LibraryMirror_invokeSetter';
828 } 873 }
829 874
830 class _LocalMethodMirrorImpl extends _LocalMirrorImpl 875 class _LocalMethodMirrorImpl extends _LocalMirrorImpl
831 implements MethodMirror { 876 implements MethodMirror {
832 _LocalMethodMirrorImpl(this._reflectee, 877 _LocalMethodMirrorImpl(this._reflectee,
833 this._owner, 878 this._owner,
834 this.parameters, 879 this.parameters,
835 this._returnType, 880 this._returnType,
836 this.isStatic, 881 this.isStatic,
837 this.isAbstract, 882 this.isAbstract,
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 } 1111 }
1067 1112
1068 // Creates a new local ClassMirror. 1113 // Creates a new local ClassMirror.
1069 static ClassMirror makeLocalClassMirror(Type key) 1114 static ClassMirror makeLocalClassMirror(Type key)
1070 native "Mirrors_makeLocalClassMirror"; 1115 native "Mirrors_makeLocalClassMirror";
1071 1116
1072 static ClassMirror reflectClass(Type key) { 1117 static ClassMirror reflectClass(Type key) {
1073 return makeLocalClassMirror(key); 1118 return makeLocalClassMirror(key);
1074 } 1119 }
1075 } 1120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698