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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 } | 447 } |
448 } | 448 } |
449 if (static_fields != NULL) { | 449 if (static_fields != NULL) { |
450 *static_fields = | 450 *static_fields = |
451 Api::NewHandle(isolate, isolate->debugger()->GetStaticFields(cls)); | 451 Api::NewHandle(isolate, isolate->debugger()->GetStaticFields(cls)); |
452 } | 452 } |
453 return Api::True(isolate); | 453 return Api::True(isolate); |
454 } | 454 } |
455 | 455 |
456 | 456 |
| 457 DART_EXPORT Dart_Handle Dart_ScriptGetSource( |
| 458 intptr_t library_id, |
| 459 Dart_Handle script_url_in) { |
| 460 Isolate* isolate = Isolate::Current(); |
| 461 DARTSCOPE(isolate); |
| 462 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); |
| 463 if (lib.IsNull()) { |
| 464 return Api::NewError("%s: %d is not a valid library id", |
| 465 CURRENT_FUNC, library_id); |
| 466 } |
| 467 String& script_url = String::Handle(); |
| 468 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); |
| 469 const Script& script = Script::Handle(lib.LookupScript(script_url)); |
| 470 if (script.IsNull()) { |
| 471 return Api::NewError("%s: script '%s' not found in library '%s'", |
| 472 CURRENT_FUNC, script_url.ToCString(), |
| 473 String::Handle(lib.url()).ToCString()); |
| 474 } |
| 475 return Api::NewHandle(isolate, script.source()); |
| 476 } |
| 477 |
| 478 |
457 DART_EXPORT Dart_Handle Dart_GetScriptSource( | 479 DART_EXPORT Dart_Handle Dart_GetScriptSource( |
458 Dart_Handle library_url_in, | 480 Dart_Handle library_url_in, |
459 Dart_Handle script_url_in) { | 481 Dart_Handle script_url_in) { |
460 Isolate* isolate = Isolate::Current(); | 482 Isolate* isolate = Isolate::Current(); |
461 DARTSCOPE(isolate); | 483 DARTSCOPE(isolate); |
462 String& library_url = String::Handle(); | 484 String& library_url = String::Handle(); |
463 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in); | 485 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in); |
464 String& script_url = String::Handle(); | 486 String& script_url = String::Handle(); |
465 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); | 487 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); |
466 | 488 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 for (int i = 0; i < num_libs; i++) { | 610 for (int i = 0; i < num_libs; i++) { |
589 lib ^= libs.At(i); | 611 lib ^= libs.At(i); |
590 ASSERT(!lib.IsNull()); | 612 ASSERT(!lib.IsNull()); |
591 lib_url = lib.url(); | 613 lib_url = lib.url(); |
592 library_url_list.SetAt(i, lib_url); | 614 library_url_list.SetAt(i, lib_url); |
593 } | 615 } |
594 return Api::NewHandle(isolate, library_url_list.raw()); | 616 return Api::NewHandle(isolate, library_url_list.raw()); |
595 } | 617 } |
596 | 618 |
597 } // namespace dart | 619 } // namespace dart |
OLD | NEW |