| 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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 arguments->NativeArgAt(0)); | 454 arguments->NativeArgAt(0)); |
| 455 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); | 455 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); |
| 456 const Class& klass = Class::Handle(ref.GetClassReferent()); | 456 const Class& klass = Class::Handle(ref.GetClassReferent()); |
| 457 | 457 |
| 458 const Error& error = Error::Handle(klass.EnsureIsFinalized(isolate)); | 458 const Error& error = Error::Handle(klass.EnsureIsFinalized(isolate)); |
| 459 if (!error.IsNull()) { | 459 if (!error.IsNull()) { |
| 460 ThrowInvokeError(error); | 460 ThrowInvokeError(error); |
| 461 } | 461 } |
| 462 | 462 |
| 463 const Array& fields = Array::Handle(klass.fields()); | 463 const Array& fields = Array::Handle(klass.fields()); |
| 464 // Some special types like 'dynamic' have a null fields list, but they should | |
| 465 // not wind up as the reflectees of ClassMirrors. | |
| 466 ASSERT(!fields.IsNull()); | |
| 467 const intptr_t num_fields = fields.Length(); | 464 const intptr_t num_fields = fields.Length(); |
| 468 | 465 |
| 469 const Array& functions = Array::Handle(klass.functions()); | 466 const Array& functions = Array::Handle(klass.functions()); |
| 470 // Some special types like 'dynamic' have a null functions list, but they | |
| 471 // should not wind up as the reflectees of ClassMirrors. | |
| 472 ASSERT(!functions.IsNull()); | |
| 473 const intptr_t num_functions = functions.Length(); | 467 const intptr_t num_functions = functions.Length(); |
| 474 | 468 |
| 475 Instance& member_mirror = Instance::Handle(); | 469 Instance& member_mirror = Instance::Handle(); |
| 476 const GrowableObjectArray& member_mirrors = GrowableObjectArray::Handle( | 470 const GrowableObjectArray& member_mirrors = GrowableObjectArray::Handle( |
| 477 GrowableObjectArray::New(num_fields + num_functions)); | 471 GrowableObjectArray::New(num_fields + num_functions)); |
| 478 | 472 |
| 479 Field& field = Field::Handle(); | 473 Field& field = Field::Handle(); |
| 480 for (intptr_t i = 0; i < num_fields; i++) { | 474 for (intptr_t i = 0; i < num_fields; i++) { |
| 481 field ^= fields.At(i); | 475 field ^= fields.At(i); |
| 482 member_mirror = CreateVariableMirror(field, owner_mirror); | 476 member_mirror = CreateVariableMirror(field, owner_mirror); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 504 arguments->NativeArgAt(0)); | 498 arguments->NativeArgAt(0)); |
| 505 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); | 499 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(1)); |
| 506 const Class& klass = Class::Handle(ref.GetClassReferent()); | 500 const Class& klass = Class::Handle(ref.GetClassReferent()); |
| 507 | 501 |
| 508 const Error& error = Error::Handle(klass.EnsureIsFinalized(isolate)); | 502 const Error& error = Error::Handle(klass.EnsureIsFinalized(isolate)); |
| 509 if (!error.IsNull()) { | 503 if (!error.IsNull()) { |
| 510 ThrowInvokeError(error); | 504 ThrowInvokeError(error); |
| 511 } | 505 } |
| 512 | 506 |
| 513 const Array& functions = Array::Handle(klass.functions()); | 507 const Array& functions = Array::Handle(klass.functions()); |
| 514 // Some special types like 'dynamic' have a null functions list, but they | |
| 515 // should not wind up as the reflectees of ClassMirrors. | |
| 516 ASSERT(!functions.IsNull()); | |
| 517 const intptr_t num_functions = functions.Length(); | 508 const intptr_t num_functions = functions.Length(); |
| 518 | 509 |
| 519 Instance& constructor_mirror = Instance::Handle(); | 510 Instance& constructor_mirror = Instance::Handle(); |
| 520 const GrowableObjectArray& constructor_mirrors = GrowableObjectArray::Handle( | 511 const GrowableObjectArray& constructor_mirrors = GrowableObjectArray::Handle( |
| 521 GrowableObjectArray::New(num_functions)); | 512 GrowableObjectArray::New(num_functions)); |
| 522 | 513 |
| 523 Function& func = Function::Handle(); | 514 Function& func = Function::Handle(); |
| 524 for (intptr_t i = 0; i < num_functions; i++) { | 515 for (intptr_t i = 0; i < num_functions; i++) { |
| 525 func ^= functions.At(i); | 516 func ^= functions.At(i); |
| 526 if (func.kind() == RawFunction::kConstructor) { | 517 if (func.kind() == RawFunction::kConstructor) { |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 } | 1264 } |
| 1274 | 1265 |
| 1275 | 1266 |
| 1276 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { | 1267 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { |
| 1277 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | 1268 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); |
| 1278 const Field& field = Field::Handle(ref.GetFieldReferent()); | 1269 const Field& field = Field::Handle(ref.GetFieldReferent()); |
| 1279 return field.type(); | 1270 return field.type(); |
| 1280 } | 1271 } |
| 1281 | 1272 |
| 1282 } // namespace dart | 1273 } // namespace dart |
| OLD | NEW |