| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 CHECK_NOT_NULL(trace); | 166 CHECK_NOT_NULL(trace); |
| 167 *trace = reinterpret_cast<Dart_StackTrace>(isolate->debugger()->StackTrace()); | 167 *trace = reinterpret_cast<Dart_StackTrace>(isolate->debugger()->StackTrace()); |
| 168 return Api::True(isolate); | 168 return Api::True(isolate); |
| 169 } | 169 } |
| 170 | 170 |
| 171 | 171 |
| 172 DART_EXPORT Dart_Handle Dart_ActivationFrameInfo( | 172 DART_EXPORT Dart_Handle Dart_ActivationFrameInfo( |
| 173 Dart_ActivationFrame activation_frame, | 173 Dart_ActivationFrame activation_frame, |
| 174 Dart_Handle* function_name, | 174 Dart_Handle* function_name, |
| 175 Dart_Handle* script_url, | 175 Dart_Handle* script_url, |
| 176 intptr_t* line_number) { | 176 intptr_t* line_number, |
| 177 intptr_t* library_id) { |
| 177 Isolate* isolate = Isolate::Current(); | 178 Isolate* isolate = Isolate::Current(); |
| 178 DARTSCOPE(isolate); | 179 DARTSCOPE(isolate); |
| 179 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 180 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
| 180 if (function_name != NULL) { | 181 if (function_name != NULL) { |
| 181 *function_name = Api::NewHandle(isolate, frame->QualifiedFunctionName()); | 182 *function_name = Api::NewHandle(isolate, frame->QualifiedFunctionName()); |
| 182 } | 183 } |
| 183 if (script_url != NULL) { | 184 if (script_url != NULL) { |
| 184 *script_url = Api::NewHandle(isolate, frame->SourceUrl()); | 185 *script_url = Api::NewHandle(isolate, frame->SourceUrl()); |
| 185 } | 186 } |
| 186 if (line_number != NULL) { | 187 if (line_number != NULL) { |
| 187 *line_number = frame->LineNumber(); | 188 *line_number = frame->LineNumber(); |
| 188 } | 189 } |
| 190 if (library_id != NULL) { |
| 191 const Library& lib = Library::Handle(frame->Library()); |
| 192 *library_id = lib.index(); |
| 193 } |
| 189 return Api::True(isolate); | 194 return Api::True(isolate); |
| 190 } | 195 } |
| 191 | 196 |
| 192 | 197 |
| 193 DART_EXPORT Dart_Handle Dart_GetLocalVariables( | 198 DART_EXPORT Dart_Handle Dart_GetLocalVariables( |
| 194 Dart_ActivationFrame activation_frame) { | 199 Dart_ActivationFrame activation_frame) { |
| 195 Isolate* isolate = Isolate::Current(); | 200 Isolate* isolate = Isolate::Current(); |
| 196 DARTSCOPE(isolate); | 201 DARTSCOPE(isolate); |
| 197 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 202 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
| 198 return Api::NewHandle(isolate, frame->GetLocalVariables()); | 203 return Api::NewHandle(isolate, frame->GetLocalVariables()); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 const Library& lib = | 414 const Library& lib = |
| 410 Library::Handle(isolate, Library::GetLibrary(library_id)); | 415 Library::Handle(isolate, Library::GetLibrary(library_id)); |
| 411 if (lib.IsNull()) { | 416 if (lib.IsNull()) { |
| 412 return Api::NewError("%s: %d is not a valid library id", | 417 return Api::NewError("%s: %d is not a valid library id", |
| 413 CURRENT_FUNC, library_id); | 418 CURRENT_FUNC, library_id); |
| 414 } | 419 } |
| 415 return Api::NewHandle(isolate, isolate->debugger()->GetLibraryFields(lib)); | 420 return Api::NewHandle(isolate, isolate->debugger()->GetLibraryFields(lib)); |
| 416 } | 421 } |
| 417 | 422 |
| 418 | 423 |
| 424 DART_EXPORT Dart_Handle Dart_GetGlobalVariables(intptr_t library_id) { |
| 425 Isolate* isolate = Isolate::Current(); |
| 426 ASSERT(isolate != NULL); |
| 427 DARTSCOPE(isolate); |
| 428 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); |
| 429 if (lib.IsNull()) { |
| 430 return Api::NewError("%s: %d is not a valid library id", |
| 431 CURRENT_FUNC, library_id); |
| 432 } |
| 433 return Api::NewHandle(isolate, isolate->debugger()->GetGlobalFields(lib)); |
| 434 } |
| 435 |
| 436 |
| 419 DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object_in) { | 437 DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object_in) { |
| 420 Isolate* isolate = Isolate::Current(); | 438 Isolate* isolate = Isolate::Current(); |
| 421 DARTSCOPE(isolate); | 439 DARTSCOPE(isolate); |
| 422 Instance& obj = Instance::Handle(); | 440 Instance& obj = Instance::Handle(); |
| 423 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); | 441 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); |
| 424 return Api::NewHandle(isolate, obj.clazz()); | 442 return Api::NewHandle(isolate, obj.clazz()); |
| 425 } | 443 } |
| 426 | 444 |
| 427 | 445 |
| 428 DART_EXPORT Dart_Handle Dart_GetObjClassId(Dart_Handle object_in, | 446 DART_EXPORT Dart_Handle Dart_GetObjClassId(Dart_Handle object_in, |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 | 598 |
| 581 DART_EXPORT Dart_Handle Dart_GetLibraryImports(intptr_t library_id) { | 599 DART_EXPORT Dart_Handle Dart_GetLibraryImports(intptr_t library_id) { |
| 582 Isolate* isolate = Isolate::Current(); | 600 Isolate* isolate = Isolate::Current(); |
| 583 ASSERT(isolate != NULL); | 601 ASSERT(isolate != NULL); |
| 584 DARTSCOPE(isolate); | 602 DARTSCOPE(isolate); |
| 585 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); | 603 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); |
| 586 if (lib.IsNull()) { | 604 if (lib.IsNull()) { |
| 587 return Api::NewError("%s: %d is not a valid library id", | 605 return Api::NewError("%s: %d is not a valid library id", |
| 588 CURRENT_FUNC, library_id); | 606 CURRENT_FUNC, library_id); |
| 589 } | 607 } |
| 590 String& prefix_name = String::Handle(); | 608 const GrowableObjectArray& import_list = |
| 591 LibraryPrefix& prefix = LibraryPrefix::Handle(); | 609 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); |
| 592 Library& imported = Library::Handle(); | 610 |
| 611 String& prefix_name = String::Handle(isolate); |
| 612 Library& imported = Library::Handle(isolate); |
| 593 intptr_t num_imports = lib.num_imports(); | 613 intptr_t num_imports = lib.num_imports(); |
| 594 const Array& import_list = Array::Handle(Array::New(2 * num_imports)); | |
| 595 for (int i = 0; i < num_imports; i++) { | 614 for (int i = 0; i < num_imports; i++) { |
| 596 prefix_name = String::null(); | 615 import_list.Add(prefix_name); // Null prefix name means no prefix. |
| 597 prefix = lib.ImportPrefixAt(i); | |
| 598 if (!prefix.IsNull()) { | |
| 599 prefix_name = prefix.name(); | |
| 600 } | |
| 601 import_list.SetAt(2 * i, prefix_name); | |
| 602 imported = lib.ImportAt(i); | 616 imported = lib.ImportAt(i); |
| 603 ASSERT(!imported.IsNull()); | 617 ASSERT(!imported.IsNull()); |
| 604 ASSERT(Smi::IsValid(imported.index())); | 618 ASSERT(Smi::IsValid(imported.index())); |
| 605 import_list.SetAt(2 * i + 1, Smi::Handle(Smi::New(imported.index()))); | 619 import_list.Add(Smi::Handle(Smi::New(imported.index()))); |
| 606 } | 620 } |
| 607 return Api::NewHandle(isolate, import_list.raw()); | 621 LibraryPrefixIterator it(lib); |
| 622 LibraryPrefix& prefix = LibraryPrefix::Handle(isolate); |
| 623 while (it.HasNext()) { |
| 624 prefix = it.GetNext(); |
| 625 prefix_name = prefix.name(); |
| 626 ASSERT(!prefix_name.IsNull()); |
| 627 prefix_name = String::Concat(prefix_name, |
| 628 String::Handle(isolate, String::New("."))); |
| 629 for (int i = 0; i < prefix.num_libs(); i++) { |
| 630 imported = prefix.GetLibrary(i); |
| 631 import_list.Add(prefix_name); |
| 632 import_list.Add(Smi::Handle(Smi::New(imported.index()))); |
| 633 } |
| 634 } |
| 635 return Api::NewHandle(isolate, Array::MakeArray(import_list)); |
| 608 } | 636 } |
| 609 | 637 |
| 610 | 638 |
| 611 DART_EXPORT Dart_Handle Dart_GetLibraryURL(intptr_t library_id) { | 639 DART_EXPORT Dart_Handle Dart_GetLibraryURL(intptr_t library_id) { |
| 612 Isolate* isolate = Isolate::Current(); | 640 Isolate* isolate = Isolate::Current(); |
| 613 ASSERT(isolate != NULL); | 641 ASSERT(isolate != NULL); |
| 614 DARTSCOPE(isolate); | 642 DARTSCOPE(isolate); |
| 615 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); | 643 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); |
| 616 if (lib.IsNull()) { | 644 if (lib.IsNull()) { |
| 617 return Api::NewError("%s: %d is not a valid library id", | 645 return Api::NewError("%s: %d is not a valid library id", |
| (...skipping 19 matching lines...) Expand all Loading... |
| 637 for (int i = 0; i < num_libs; i++) { | 665 for (int i = 0; i < num_libs; i++) { |
| 638 lib ^= libs.At(i); | 666 lib ^= libs.At(i); |
| 639 ASSERT(!lib.IsNull()); | 667 ASSERT(!lib.IsNull()); |
| 640 lib_url = lib.url(); | 668 lib_url = lib.url(); |
| 641 library_url_list.SetAt(i, lib_url); | 669 library_url_list.SetAt(i, lib_url); |
| 642 } | 670 } |
| 643 return Api::NewHandle(isolate, library_url_list.raw()); | 671 return Api::NewHandle(isolate, library_url_list.raw()); |
| 644 } | 672 } |
| 645 | 673 |
| 646 } // namespace dart | 674 } // namespace dart |
| OLD | NEW |