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

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

Issue 10778005: Add a limited version of ParameterMirrors that can only tell whether they are (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } 176 }
177 buf.add(output); 177 buf.add(output);
178 } 178 }
179 return buf.toString(); 179 return buf.toString();
180 } 180 }
181 181
182 class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl 182 class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl
183 implements InstanceMirror { 183 implements InstanceMirror {
184 _LocalInstanceMirrorImpl(ref, 184 _LocalInstanceMirrorImpl(ref,
185 this._class, 185 this._class,
186 this._hasSimpleValue,
187 this._reflectee) : super(ref) {} 186 this._reflectee) : super(ref) {}
188 187
189 var _class; 188 var _class;
190 InterfaceMirror getClass() { 189 InterfaceMirror getClass() {
191 if (_class is _LazyInterfaceMirror) { 190 if (_class is _LazyInterfaceMirror) {
192 _class = _class.resolve(mirrors); 191 _class = _class.resolve(mirrors);
193 } 192 }
194 return _class; 193 return _class;
195 } 194 }
196 195
197 // LocalInstanceMirrors always reflect local instances 196 // LocalInstanceMirrors always reflect local instances
198 bool hasReflectee = true; 197 bool hasReflectee = true;
199 198
200 var _hasSimpleValue;
201 var _reflectee; 199 var _reflectee;
202 get reflectee() => _reflectee; 200 get reflectee() => _reflectee;
203 201
204 String toString() { 202 String toString() {
205 if (_hasSimpleValue) { 203 if (isSimpleValue(_reflectee)) {
206 if (_reflectee is String) { 204 if (_reflectee is String) {
207 return "InstanceMirror on <'${_dartEscape(_reflectee)}'>"; 205 return "InstanceMirror on <'${_dartEscape(_reflectee)}'>";
208 } else { 206 } else {
209 return "InstanceMirror on <$_reflectee>"; 207 return "InstanceMirror on <$_reflectee>";
210 } 208 }
211 } else { 209 } else {
212 return "InstanceMirror on instance of '${getClass().simpleName}'"; 210 return "InstanceMirror on instance of '${getClass().simpleName}'";
213 } 211 }
214 } 212 }
215 } 213 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 363
366 String toString() { 364 String toString() {
367 return "LibraryMirror on '$simpleName'"; 365 return "LibraryMirror on '$simpleName'";
368 } 366 }
369 } 367 }
370 368
371 class _LocalMethodMirrorImpl extends _LocalMirrorImpl 369 class _LocalMethodMirrorImpl extends _LocalMirrorImpl
372 implements MethodMirror { 370 implements MethodMirror {
373 _LocalMethodMirrorImpl(this.simpleName, 371 _LocalMethodMirrorImpl(this.simpleName,
374 this._owner, 372 this._owner,
373 this._parameters,
375 this.isStatic, 374 this.isStatic,
376 this.isAbstract, 375 this.isAbstract,
377 this.isGetter, 376 this.isGetter,
378 this.isSetter, 377 this.isSetter,
379 this.isConstructor, 378 this.isConstructor,
380 this.isConstConstructor, 379 this.isConstConstructor,
381 this.isGenerativeConstructor, 380 this.isGenerativeConstructor,
382 this.isRedirectingConstructor, 381 this.isRedirectingConstructor,
383 this.isFactoryConstructor) {} 382 this.isFactoryConstructor) {}
384 383
(...skipping 20 matching lines...) Expand all
405 final bool isAbstract; 404 final bool isAbstract;
406 final bool isGetter; 405 final bool isGetter;
407 final bool isSetter; 406 final bool isSetter;
408 final bool isConstructor; 407 final bool isConstructor;
409 408
410 final bool isConstConstructor; 409 final bool isConstConstructor;
411 final bool isGenerativeConstructor; 410 final bool isGenerativeConstructor;
412 final bool isRedirectingConstructor; 411 final bool isRedirectingConstructor;
413 final bool isFactoryConstructor; 412 final bool isFactoryConstructor;
414 413
414 List<ParameterMirror> _parameters;
415 List<ParameterMirror> parameters() => _parameters;
416
415 String toString() { 417 String toString() {
416 return "MethodMirror on '$simpleName'"; 418 return "MethodMirror on '$simpleName'";
417 } 419 }
418 } 420 }
419 421
422 class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl
423 implements ParameterMirror {
424 // TODO(rmacnak): Fill these mirrors will real information
425 _LocalParameterMirrorImpl(this.isOptional)
426 : super(null, null, false, false) {}
427
428 final bool isOptional;
429
430 TypeMirror get type() => null;
431 String get defaultValue() => null;
432 bool get hasDefaultValue() => null;
433 }
434
420 class _LocalVariableMirrorImpl extends _LocalMirrorImpl 435 class _LocalVariableMirrorImpl extends _LocalMirrorImpl
421 implements VariableMirror { 436 implements VariableMirror {
422 _LocalVariableMirrorImpl(this.simpleName, 437 _LocalVariableMirrorImpl(this.simpleName,
423 this._owner, 438 this._owner,
424 this.isStatic, 439 this.isStatic,
425 this.isFinal) {} 440 this.isFinal) {}
426 441
427 final String simpleName; 442 final String simpleName;
428 443
429 var _owner; 444 var _owner;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 497
483 // Creates a new local InstanceMirror 498 // Creates a new local InstanceMirror
484 static InstanceMirror makeLocalInstanceMirror(Object reflectee) 499 static InstanceMirror makeLocalInstanceMirror(Object reflectee)
485 native 'Mirrors_makeLocalInstanceMirror'; 500 native 'Mirrors_makeLocalInstanceMirror';
486 501
487 // Creates a new local mirror for some Object. 502 // Creates a new local mirror for some Object.
488 static InstanceMirror mirrorOf(Object reflectee) { 503 static InstanceMirror mirrorOf(Object reflectee) {
489 return makeLocalInstanceMirror(reflectee); 504 return makeLocalInstanceMirror(reflectee);
490 } 505 }
491 } 506 }
OLDNEW
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698