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

Side by Side Diff: runtime/vm/debugger_api_impl.cc

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

Powered by Google App Engine
This is Rietveld 408576698