| 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 "include/dart_debugger_api.h" | 5 #include "include/dart_debugger_api.h" |
| 6 | 6 |
| 7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
| 8 #include "vm/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
| 9 #include "vm/debugger.h" | 9 #include "vm/debugger.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 | 369 |
| 370 DART_EXPORT Dart_Handle Dart_GetStaticFields(Dart_Handle cls_in) { | 370 DART_EXPORT Dart_Handle Dart_GetStaticFields(Dart_Handle cls_in) { |
| 371 Isolate* isolate = Isolate::Current(); | 371 Isolate* isolate = Isolate::Current(); |
| 372 DARTSCOPE(isolate); | 372 DARTSCOPE(isolate); |
| 373 Class& cls = Class::Handle(); | 373 Class& cls = Class::Handle(); |
| 374 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in); | 374 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in); |
| 375 return Api::NewHandle(isolate, isolate->debugger()->GetStaticFields(cls)); | 375 return Api::NewHandle(isolate, isolate->debugger()->GetStaticFields(cls)); |
| 376 } | 376 } |
| 377 | 377 |
| 378 | 378 |
| 379 DART_EXPORT Dart_Handle Dart_GetLibraryFields(intptr_t library_id) { |
| 380 Isolate* isolate = Isolate::Current(); |
| 381 DARTSCOPE(isolate); |
| 382 const Library& lib = |
| 383 Library::Handle(isolate, Library::GetLibrary(library_id)); |
| 384 if (lib.IsNull()) { |
| 385 return Api::NewError("%s: %d is not a valid library id", |
| 386 CURRENT_FUNC, library_id); |
| 387 } |
| 388 return Api::NewHandle(isolate, isolate->debugger()->GetLibraryFields(lib)); |
| 389 } |
| 390 |
| 391 |
| 379 DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object_in) { | 392 DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object_in) { |
| 380 Isolate* isolate = Isolate::Current(); | 393 Isolate* isolate = Isolate::Current(); |
| 381 DARTSCOPE(isolate); | 394 DARTSCOPE(isolate); |
| 382 Instance& obj = Instance::Handle(); | 395 Instance& obj = Instance::Handle(); |
| 383 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); | 396 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); |
| 384 return Api::NewHandle(isolate, obj.clazz()); | 397 return Api::NewHandle(isolate, obj.clazz()); |
| 385 } | 398 } |
| 386 | 399 |
| 387 | 400 |
| 388 DART_EXPORT Dart_Handle Dart_GetObjClassId(Dart_Handle object_in, | 401 DART_EXPORT Dart_Handle Dart_GetObjClassId(Dart_Handle object_in, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 402 DARTSCOPE(isolate); | 415 DARTSCOPE(isolate); |
| 403 Class& cls = Class::Handle(); | 416 Class& cls = Class::Handle(); |
| 404 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in); | 417 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in); |
| 405 return Api::NewHandle(isolate, cls.SuperClass()); | 418 return Api::NewHandle(isolate, cls.SuperClass()); |
| 406 } | 419 } |
| 407 | 420 |
| 408 | 421 |
| 409 DART_EXPORT Dart_Handle Dart_GetClassInfo( | 422 DART_EXPORT Dart_Handle Dart_GetClassInfo( |
| 410 intptr_t cls_id, | 423 intptr_t cls_id, |
| 411 Dart_Handle* class_name, | 424 Dart_Handle* class_name, |
| 412 Dart_Handle* library, | 425 intptr_t* library_id, |
| 413 intptr_t* super_class_id, | 426 intptr_t* super_class_id, |
| 414 Dart_Handle* static_fields) { | 427 Dart_Handle* static_fields) { |
| 415 Isolate* isolate = Isolate::Current(); | 428 Isolate* isolate = Isolate::Current(); |
| 416 DARTSCOPE(isolate); | 429 DARTSCOPE(isolate); |
| 417 if (!isolate->class_table()->IsValidIndex(cls_id)) { | 430 if (!isolate->class_table()->IsValidIndex(cls_id)) { |
| 418 return Api::NewError("%s: %d is not a valid class id", | 431 return Api::NewError("%s: %d is not a valid class id", |
| 419 CURRENT_FUNC, cls_id); | 432 CURRENT_FUNC, cls_id); |
| 420 } | 433 } |
| 421 Class& cls = Class::Handle(isolate->class_table()->At(cls_id)); | 434 Class& cls = Class::Handle(isolate->class_table()->At(cls_id)); |
| 422 if (class_name != NULL) { | 435 if (class_name != NULL) { |
| 423 *class_name = Api::NewHandle(isolate, cls.Name()); | 436 *class_name = Api::NewHandle(isolate, cls.Name()); |
| 424 } | 437 } |
| 425 if (library != NULL) { | 438 if (library_id != NULL) { |
| 426 *library = Api::NewHandle(isolate, cls.library()); | 439 const Library& lib = Library::Handle(isolate, cls.library()); |
| 440 *library_id = lib.index(); |
| 427 } | 441 } |
| 428 if (super_class_id != NULL) { | 442 if (super_class_id != NULL) { |
| 429 *super_class_id = 0; | 443 *super_class_id = 0; |
| 430 cls = cls.SuperClass(); | 444 cls = cls.SuperClass(); |
| 431 if (!cls.IsNull()) { | 445 if (!cls.IsNull()) { |
| 432 *super_class_id = cls.index(); | 446 *super_class_id = cls.index(); |
| 433 } | 447 } |
| 434 } | 448 } |
| 435 if (static_fields != NULL) { | 449 if (static_fields != NULL) { |
| 436 *static_fields = | 450 *static_fields = |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 String& url = String::Handle(); | 500 String& url = String::Handle(); |
| 487 for (int i = 0; i < num_scripts; i++) { | 501 for (int i = 0; i < num_scripts; i++) { |
| 488 script ^= loaded_scripts.At(i); | 502 script ^= loaded_scripts.At(i); |
| 489 url = script.url(); | 503 url = script.url(); |
| 490 script_list.SetAt(i, url); | 504 script_list.SetAt(i, url); |
| 491 } | 505 } |
| 492 return Api::NewHandle(isolate, script_list.raw()); | 506 return Api::NewHandle(isolate, script_list.raw()); |
| 493 } | 507 } |
| 494 | 508 |
| 495 | 509 |
| 510 DART_EXPORT Dart_Handle Dart_GetLibraryIds() { |
| 511 Isolate* isolate = Isolate::Current(); |
| 512 ASSERT(isolate != NULL); |
| 513 DARTSCOPE(isolate); |
| 514 |
| 515 const GrowableObjectArray& libs = |
| 516 GrowableObjectArray::Handle(isolate->object_store()->libraries()); |
| 517 int num_libs = libs.Length(); |
| 518 |
| 519 // Create new list and populate with the url of loaded libraries. |
| 520 Library &lib = Library::Handle(); |
| 521 const Array& library_id_list = Array::Handle(Array::New(num_libs)); |
| 522 for (int i = 0; i < num_libs; i++) { |
| 523 lib ^= libs.At(i); |
| 524 ASSERT(!lib.IsNull()); |
| 525 ASSERT(Smi::IsValid(lib.index())); |
| 526 library_id_list.SetAt(i, Smi::Handle(Smi::New(lib.index()))); |
| 527 } |
| 528 return Api::NewHandle(isolate, library_id_list.raw()); |
| 529 } |
| 530 |
| 531 |
| 532 DART_EXPORT Dart_Handle Dart_GetLibraryImports(intptr_t library_id) { |
| 533 Isolate* isolate = Isolate::Current(); |
| 534 ASSERT(isolate != NULL); |
| 535 DARTSCOPE(isolate); |
| 536 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); |
| 537 if (lib.IsNull()) { |
| 538 return Api::NewError("%s: %d is not a valid library id", |
| 539 CURRENT_FUNC, library_id); |
| 540 } |
| 541 String& prefix_name = String::Handle(); |
| 542 LibraryPrefix& prefix = LibraryPrefix::Handle(); |
| 543 Library& imported = Library::Handle(); |
| 544 intptr_t num_imports = lib.num_imports(); |
| 545 const Array& import_list = Array::Handle(Array::New(2 * num_imports)); |
| 546 for (int i = 0; i < num_imports; i++) { |
| 547 prefix_name = String::null(); |
| 548 prefix = lib.ImportPrefixAt(i); |
| 549 if (!prefix.IsNull()) { |
| 550 prefix_name = prefix.name(); |
| 551 } |
| 552 import_list.SetAt(2 * i, prefix_name); |
| 553 imported = lib.ImportAt(i); |
| 554 ASSERT(!imported.IsNull()); |
| 555 ASSERT(Smi::IsValid(imported.index())); |
| 556 import_list.SetAt(2 * i + 1, Smi::Handle(Smi::New(imported.index()))); |
| 557 } |
| 558 return Api::NewHandle(isolate, import_list.raw()); |
| 559 } |
| 560 |
| 561 |
| 562 DART_EXPORT Dart_Handle Dart_GetLibraryURL(intptr_t library_id) { |
| 563 Isolate* isolate = Isolate::Current(); |
| 564 ASSERT(isolate != NULL); |
| 565 DARTSCOPE(isolate); |
| 566 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); |
| 567 if (lib.IsNull()) { |
| 568 return Api::NewError("%s: %d is not a valid library id", |
| 569 CURRENT_FUNC, library_id); |
| 570 } |
| 571 return Api::NewHandle(isolate, lib.url()); |
| 572 } |
| 573 |
| 574 |
| 496 DART_EXPORT Dart_Handle Dart_GetLibraryURLs() { | 575 DART_EXPORT Dart_Handle Dart_GetLibraryURLs() { |
| 497 Isolate* isolate = Isolate::Current(); | 576 Isolate* isolate = Isolate::Current(); |
| 498 ASSERT(isolate != NULL); | 577 ASSERT(isolate != NULL); |
| 499 DARTSCOPE(isolate); | 578 DARTSCOPE(isolate); |
| 500 | 579 |
| 501 const GrowableObjectArray& libs = | 580 const GrowableObjectArray& libs = |
| 502 GrowableObjectArray::Handle(isolate->object_store()->libraries()); | 581 GrowableObjectArray::Handle(isolate->object_store()->libraries()); |
| 503 int num_libs = libs.Length(); | 582 int num_libs = libs.Length(); |
| 504 | 583 |
| 505 // Create new list and populate with the url of loaded libraries. | 584 // Create new list and populate with the url of loaded libraries. |
| 506 Library &lib = Library::Handle(); | 585 Library &lib = Library::Handle(); |
| 507 String& lib_url = String::Handle(); | 586 String& lib_url = String::Handle(); |
| 508 const Array& library_url_list = Array::Handle(Array::New(num_libs)); | 587 const Array& library_url_list = Array::Handle(Array::New(num_libs)); |
| 509 for (int i = 0; i < num_libs; i++) { | 588 for (int i = 0; i < num_libs; i++) { |
| 510 lib ^= libs.At(i); | 589 lib ^= libs.At(i); |
| 511 ASSERT(!lib.IsNull()); | 590 ASSERT(!lib.IsNull()); |
| 512 lib_url = lib.url(); | 591 lib_url = lib.url(); |
| 513 library_url_list.SetAt(i, lib_url); | 592 library_url_list.SetAt(i, lib_url); |
| 514 } | 593 } |
| 515 return Api::NewHandle(isolate, library_url_list.raw()); | 594 return Api::NewHandle(isolate, library_url_list.raw()); |
| 516 } | 595 } |
| 517 | 596 |
| 518 } // namespace dart | 597 } // namespace dart |
| OLD | NEW |