| 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 #include "lib/invocation_mirror.h" | 5 #include "lib/invocation_mirror.h" |
| 6 #include "vm/bootstrap_natives.h" | 6 #include "vm/bootstrap_natives.h" |
| 7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/exceptions.h" | 9 #include "vm/exceptions.h" |
| 10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 | 428 |
| 429 | 429 |
| 430 DEFINE_NATIVE_ENTRY(MirrorReference_equals, 2) { | 430 DEFINE_NATIVE_ENTRY(MirrorReference_equals, 2) { |
| 431 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, a, arguments->NativeArgAt(0)); | 431 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, a, arguments->NativeArgAt(0)); |
| 432 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, b, arguments->NativeArgAt(1)); | 432 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, b, arguments->NativeArgAt(1)); |
| 433 return Bool::Get(a.referent() == b.referent()).raw(); | 433 return Bool::Get(a.referent() == b.referent()).raw(); |
| 434 } | 434 } |
| 435 | 435 |
| 436 | 436 |
| 437 DEFINE_NATIVE_ENTRY(DeclarationMirror_metadata, 1) { | 437 DEFINE_NATIVE_ENTRY(DeclarationMirror_metadata, 1) { |
| 438 const MirrorReference& decl_ref = | 438 GET_NON_NULL_NATIVE_ARGUMENT(Instance, reflectee, arguments->NativeArgAt(0)); |
| 439 MirrorReference::CheckedHandle(arguments->NativeArgAt(0)); | 439 Object& decl = Object::Handle(); |
| 440 const Object& decl = Object::Handle(decl_ref.referent()); | 440 if (reflectee.IsMirrorReference()) { |
| 441 const MirrorReference& decl_ref = MirrorReference::Cast(reflectee); |
| 442 decl = decl_ref.referent(); |
| 443 } else if (reflectee.IsTypeParameter()) { |
| 444 decl = reflectee.raw(); |
| 445 } else { |
| 446 UNREACHABLE(); |
| 447 } |
| 441 | 448 |
| 442 Class& klass = Class::Handle(); | 449 Class& klass = Class::Handle(); |
| 443 Library& library = Library::Handle(); | 450 Library& library = Library::Handle(); |
| 444 | 451 |
| 445 if (decl.IsClass()) { | 452 if (decl.IsClass()) { |
| 446 klass ^= decl.raw(); | 453 klass ^= decl.raw(); |
| 447 library = klass.library(); | 454 library = klass.library(); |
| 448 } else if (decl.IsFunction()) { | 455 } else if (decl.IsFunction()) { |
| 449 klass = Function::Cast(decl).origin(); | 456 klass = Function::Cast(decl).origin(); |
| 450 library = klass.library(); | 457 library = klass.library(); |
| 451 } else if (decl.IsField()) { | 458 } else if (decl.IsField()) { |
| 452 klass = Field::Cast(decl).origin(); | 459 klass = Field::Cast(decl).origin(); |
| 453 library = klass.library(); | 460 library = klass.library(); |
| 454 } else if (decl.IsLibrary()) { | 461 } else if (decl.IsLibrary()) { |
| 455 library ^= decl.raw(); | 462 library ^= decl.raw(); |
| 463 } else if (decl.IsTypeParameter()) { |
| 464 klass ^= TypeParameter::Cast(decl).parameterized_class(); |
| 465 library = klass.library(); |
| 456 } else { | 466 } else { |
| 457 return Object::empty_array().raw(); | 467 return Object::empty_array().raw(); |
| 458 } | 468 } |
| 459 | 469 |
| 460 const Object& metadata = Object::Handle(library.GetMetadata(decl)); | 470 const Object& metadata = Object::Handle(library.GetMetadata(decl)); |
| 461 if (metadata.IsError()) { | 471 if (metadata.IsError()) { |
| 462 ThrowInvokeError(Error::Cast(metadata)); | 472 ThrowInvokeError(Error::Cast(metadata)); |
| 463 } | 473 } |
| 464 return metadata.raw(); | 474 return metadata.raw(); |
| 465 } | 475 } |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1405 } | 1415 } |
| 1406 | 1416 |
| 1407 | 1417 |
| 1408 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { | 1418 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { |
| 1409 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | 1419 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); |
| 1410 const Field& field = Field::Handle(ref.GetFieldReferent()); | 1420 const Field& field = Field::Handle(ref.GetFieldReferent()); |
| 1411 return field.type(); | 1421 return field.type(); |
| 1412 } | 1422 } |
| 1413 | 1423 |
| 1414 } // namespace dart | 1424 } // namespace dart |
| OLD | NEW |