OLD | NEW |
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 import "dart:collection"; | 7 import "dart:collection"; |
8 | 8 |
9 // These values are allowed to be passed directly over the wire. | 9 // These values are allowed to be passed directly over the wire. |
10 bool _isSimpleValue(var value) { | 10 bool _isSimpleValue(var value) { |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 return h ^ 0x36363636; | 314 return h ^ 0x36363636; |
315 } | 315 } |
316 | 316 |
317 static _identityHash(reflectee) | 317 static _identityHash(reflectee) |
318 native "InstanceMirror_identityHash"; | 318 native "InstanceMirror_identityHash"; |
319 | 319 |
320 // Override to include the receiver in the arguments. | 320 // Override to include the receiver in the arguments. |
321 InstanceMirror invoke(Symbol memberName, | 321 InstanceMirror invoke(Symbol memberName, |
322 List positionalArguments, | 322 List positionalArguments, |
323 [Map<Symbol, dynamic> namedArguments]) { | 323 [Map<Symbol, dynamic> namedArguments]) { |
324 | |
325 int numPositionalArguments = positionalArguments.length + 1; // Receiver. | 324 int numPositionalArguments = positionalArguments.length + 1; // Receiver. |
326 int numNamedArguments = namedArguments != null ? namedArguments.length : 0; | 325 int numNamedArguments = namedArguments != null ? namedArguments.length : 0; |
327 int numArguments = numPositionalArguments + numNamedArguments; | 326 int numArguments = numPositionalArguments + numNamedArguments; |
328 List arguments = new List(numArguments); | 327 List arguments = new List(numArguments); |
329 arguments[0] = _reflectee; // Receiver. | 328 arguments[0] = _reflectee; // Receiver. |
330 arguments.setRange(1, numPositionalArguments, positionalArguments); | 329 arguments.setRange(1, numPositionalArguments, positionalArguments); |
331 List names = new List(numNamedArguments); | 330 List names = new List(numNamedArguments); |
332 int argumentIndex = numPositionalArguments; | 331 int argumentIndex = numPositionalArguments; |
333 int nameIndex = 0; | 332 int nameIndex = 0; |
334 if (numNamedArguments > 0) { | 333 if (numNamedArguments > 0) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 } | 367 } |
369 return _function; | 368 return _function; |
370 } | 369 } |
371 | 370 |
372 InstanceMirror apply(List<Object> positionalArguments, | 371 InstanceMirror apply(List<Object> positionalArguments, |
373 [Map<Symbol, Object> namedArguments]) { | 372 [Map<Symbol, Object> namedArguments]) { |
374 // TODO(iposva): When closures get an ordinary call method, this can be | 373 // TODO(iposva): When closures get an ordinary call method, this can be |
375 // replaced with | 374 // replaced with |
376 // return this.invoke(#call, positionalArguments, namedArguments); | 375 // return this.invoke(#call, positionalArguments, namedArguments); |
377 // and the native ClosureMirror_apply can be removed. | 376 // and the native ClosureMirror_apply can be removed. |
378 | |
379 int numPositionalArguments = positionalArguments.length + 1; // Receiver. | 377 int numPositionalArguments = positionalArguments.length + 1; // Receiver. |
380 int numNamedArguments = namedArguments != null ? namedArguments.length : 0; | 378 int numNamedArguments = namedArguments != null ? namedArguments.length : 0; |
381 int numArguments = numPositionalArguments + numNamedArguments; | 379 int numArguments = numPositionalArguments + numNamedArguments; |
382 List arguments = new List(numArguments); | 380 List arguments = new List(numArguments); |
383 arguments[0] = _reflectee; // Receiver. | 381 arguments[0] = _reflectee; // Receiver. |
384 arguments.setRange(1, numPositionalArguments, positionalArguments); | 382 arguments.setRange(1, numPositionalArguments, positionalArguments); |
385 List names = new List(numNamedArguments); | 383 List names = new List(numNamedArguments); |
386 int argumentIndex = numPositionalArguments; | 384 int argumentIndex = numPositionalArguments; |
387 int nameIndex = 0; | 385 int nameIndex = 0; |
388 if (numNamedArguments > 0) { | 386 if (numNamedArguments > 0) { |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1323 if (typeMirror == null) { | 1321 if (typeMirror == null) { |
1324 typeMirror = makeLocalTypeMirror(key); | 1322 typeMirror = makeLocalTypeMirror(key); |
1325 _instanitationCache[key] = typeMirror; | 1323 _instanitationCache[key] = typeMirror; |
1326 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { | 1324 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { |
1327 _declarationCache[key] = typeMirror; | 1325 _declarationCache[key] = typeMirror; |
1328 } | 1326 } |
1329 } | 1327 } |
1330 return typeMirror; | 1328 return typeMirror; |
1331 } | 1329 } |
1332 } | 1330 } |
OLD | NEW |