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

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

Issue 19819003: Make reflective invocations raise NoSuchMethodErrors in the cases where non-reflective invocations … (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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 if (namedArguments != null) { 199 if (namedArguments != null) {
200 throw new UnimplementedError( 200 throw new UnimplementedError(
201 'named argument support is not implemented'); 201 'named argument support is not implemented');
202 } 202 }
203 203
204 try { 204 try {
205 var result = this._invoke(_reflectee, 205 var result = this._invoke(_reflectee,
206 _n(memberName), 206 _n(memberName),
207 _unwarpAsyncPositionals(positionalArguments)); 207 _unwarpAsyncPositionals(positionalArguments));
208 return new Future.value(reflect(result)); 208 return new Future.value(reflect(result));
209 } on MirroredError catch(e) { 209 } catch(e) {
210 return new Future.error(e); 210 return new Future.error(e);
211 } 211 }
212 } 212 }
213 213
214 Future<InstanceMirror> getFieldAsync(Symbol memberName) { 214 Future<InstanceMirror> getFieldAsync(Symbol memberName) {
215 try { 215 try {
216 var result = this._invokeGetter(_reflectee, 216 var result = this._invokeGetter(_reflectee,
217 _n(memberName)); 217 _n(memberName));
218 return new Future.value(reflect(result)); 218 return new Future.value(reflect(result));
219 } on MirroredError catch(e) { 219 } catch(e) {
220 return new Future.error(e); 220 return new Future.error(e);
221 } 221 }
222 } 222 }
223 223
224 Future<InstanceMirror> setFieldAsync(Symbol memberName, Object value) { 224 Future<InstanceMirror> setFieldAsync(Symbol memberName, Object value) {
225 try { 225 try {
226 var unwrappedValue; 226 var unwrappedValue;
227 if(_isSimpleValue(value)) { 227 if(_isSimpleValue(value)) {
228 unwrappedValue = value; 228 unwrappedValue = value;
229 } else if(value is InstanceMirror) { 229 } else if(value is InstanceMirror) {
230 unwrappedValue = value._reflectee; 230 unwrappedValue = value._reflectee;
231 } else { 231 } else {
232 throw "setter argument ($value) must be" 232 throw "setter argument ($value) must be"
233 "a simple value or InstanceMirror"; 233 "a simple value or InstanceMirror";
234 } 234 }
235 235
236 var result = this._invokeSetter(_reflectee, 236 var result = this._invokeSetter(_reflectee,
237 _n(memberName), 237 _n(memberName),
238 unwrappedValue); 238 unwrappedValue);
239 return new Future.value(reflect(result)); 239 return new Future.value(reflect(result));
240 } on MirroredError catch(e) { 240 } catch(e) {
241 return new Future.error(e); 241 return new Future.error(e);
242 } 242 }
243 } 243 }
244 244
245 static _validateArgument(int i, Object arg) 245 static _validateArgument(int i, Object arg)
246 { 246 {
247 if (arg is Mirror) { 247 if (arg is Mirror) {
248 if (arg is! InstanceMirror) { 248 if (arg is! InstanceMirror) {
249 throw new MirrorException( 249 throw new MirrorException(
250 'positional argument $i ($arg) was not an InstanceMirror'); 250 'positional argument $i ($arg) was not an InstanceMirror');
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 if (namedArguments != null) { 556 if (namedArguments != null) {
557 throw new UnimplementedError( 557 throw new UnimplementedError(
558 'named argument support is not implemented'); 558 'named argument support is not implemented');
559 } 559 }
560 560
561 try { 561 try {
562 var result = _invokeConstructor(_reflectee, 562 var result = _invokeConstructor(_reflectee,
563 _n(constructorName), 563 _n(constructorName),
564 _unwarpAsyncPositionals(positionalArgument s)); 564 _unwarpAsyncPositionals(positionalArgument s));
565 return new Future.value(reflect(result)); 565 return new Future.value(reflect(result));
566 } on MirroredError catch(e) { 566 } catch(e) {
567 return new Future.error(e); 567 return new Future.error(e);
568 } 568 }
569 } 569 }
570 570
571 List<InstanceMirror> get metadata { 571 List<InstanceMirror> get metadata {
572 // Get the metadata objects, convert them into InstanceMirrors using 572 // Get the metadata objects, convert them into InstanceMirrors using
573 // reflect() and then make them into a Dart list. 573 // reflect() and then make them into a Dart list.
574 return _metadata(_reflectee).map(reflect).toList(growable:false); 574 return _metadata(_reflectee).map(reflect).toList(growable:false);
575 } 575 }
576 576
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror"); 1178 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror");
1179 static ClassMirror reflectClass(Type key) { 1179 static ClassMirror reflectClass(Type key) {
1180 var classMirror = _classMirrorCache[key]; 1180 var classMirror = _classMirrorCache[key];
1181 if (classMirror == null) { 1181 if (classMirror == null) {
1182 classMirror = makeLocalClassMirror(key); 1182 classMirror = makeLocalClassMirror(key);
1183 _classMirrorCache[key] = classMirror; 1183 _classMirrorCache[key] = classMirror;
1184 } 1184 }
1185 return classMirror; 1185 return classMirror;
1186 } 1186 }
1187 } 1187 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698