| 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 25 matching lines...) Expand all Loading... |
| 36 type* var = reinterpret_cast<type*>(param); | 36 type* var = reinterpret_cast<type*>(param); |
| 37 | 37 |
| 38 | 38 |
| 39 #define CHECK_NOT_NULL(param) \ | 39 #define CHECK_NOT_NULL(param) \ |
| 40 if (param == NULL) { \ | 40 if (param == NULL) { \ |
| 41 return Api::NewError("%s expects argument '%s' to be non-null.", \ | 41 return Api::NewError("%s expects argument '%s' to be non-null.", \ |
| 42 CURRENT_FUNC, #param); \ | 42 CURRENT_FUNC, #param); \ |
| 43 } | 43 } |
| 44 | 44 |
| 45 | 45 |
| 46 DART_EXPORT intptr_t Dart_CacheObject(Dart_Handle object_in) { |
| 47 Isolate* isolate = Isolate::Current(); |
| 48 DARTSCOPE(isolate); |
| 49 const Object& obj = Object::Handle(Api::UnwrapHandle(object_in)); |
| 50 if (obj.IsApiError()) { |
| 51 return -1; |
| 52 } |
| 53 return isolate->debugger()->CacheObject(obj); |
| 54 } |
| 55 |
| 56 |
| 57 DART_EXPORT Dart_Handle Dart_GetCachedObject(intptr_t obj_id) { |
| 58 Isolate* isolate = Isolate::Current(); |
| 59 DARTSCOPE(isolate); |
| 60 if (!isolate->debugger()->IsValidObjectId(obj_id)) { |
| 61 return Api::NewError("%s: object id %d is invalid", CURRENT_FUNC, obj_id); |
| 62 } |
| 63 return Api::NewHandle(isolate, isolate->debugger()->GetCachedObject(obj_id)); |
| 64 } |
| 65 |
| 66 |
| 46 DART_EXPORT Dart_Handle Dart_StackTraceLength( | 67 DART_EXPORT Dart_Handle Dart_StackTraceLength( |
| 47 Dart_StackTrace trace, | 68 Dart_StackTrace trace, |
| 48 intptr_t* length) { | 69 intptr_t* length) { |
| 49 Isolate* isolate = Isolate::Current(); | 70 Isolate* isolate = Isolate::Current(); |
| 50 DARTSCOPE(isolate); | 71 DARTSCOPE(isolate); |
| 51 CHECK_NOT_NULL(length); | 72 CHECK_NOT_NULL(length); |
| 52 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace); | 73 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace); |
| 53 *length = stack_trace->Length(); | 74 *length = stack_trace->Length(); |
| 54 return Api::True(isolate); | 75 return Api::True(isolate); |
| 55 } | 76 } |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 | 378 |
| 358 DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object_in) { | 379 DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object_in) { |
| 359 Isolate* isolate = Isolate::Current(); | 380 Isolate* isolate = Isolate::Current(); |
| 360 DARTSCOPE(isolate); | 381 DARTSCOPE(isolate); |
| 361 Instance& obj = Instance::Handle(); | 382 Instance& obj = Instance::Handle(); |
| 362 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); | 383 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); |
| 363 return Api::NewHandle(isolate, obj.clazz()); | 384 return Api::NewHandle(isolate, obj.clazz()); |
| 364 } | 385 } |
| 365 | 386 |
| 366 | 387 |
| 388 DART_EXPORT Dart_Handle Dart_GetObjClassId(Dart_Handle object_in, |
| 389 intptr_t* class_id) { |
| 390 Isolate* isolate = Isolate::Current(); |
| 391 DARTSCOPE(isolate); |
| 392 Instance& obj = Instance::Handle(); |
| 393 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); |
| 394 CHECK_NOT_NULL(class_id); |
| 395 *class_id = Class::Handle(obj.clazz()).index(); |
| 396 return Api::True(isolate); |
| 397 } |
| 398 |
| 399 |
| 367 DART_EXPORT Dart_Handle Dart_GetSuperclass(Dart_Handle cls_in) { | 400 DART_EXPORT Dart_Handle Dart_GetSuperclass(Dart_Handle cls_in) { |
| 368 Isolate* isolate = Isolate::Current(); | 401 Isolate* isolate = Isolate::Current(); |
| 369 DARTSCOPE(isolate); | 402 DARTSCOPE(isolate); |
| 370 Class& cls = Class::Handle(); | 403 Class& cls = Class::Handle(); |
| 371 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in); | 404 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in); |
| 372 return Api::NewHandle(isolate, cls.SuperClass()); | 405 return Api::NewHandle(isolate, cls.SuperClass()); |
| 373 } | 406 } |
| 374 | 407 |
| 375 | 408 |
| 409 DART_EXPORT Dart_Handle Dart_GetClassInfo( |
| 410 intptr_t cls_id, |
| 411 Dart_Handle* class_name, |
| 412 Dart_Handle* library, |
| 413 intptr_t* super_class_id, |
| 414 Dart_Handle* static_fields) { |
| 415 Isolate* isolate = Isolate::Current(); |
| 416 DARTSCOPE(isolate); |
| 417 if (!isolate->class_table()->IsValidIndex(cls_id)) { |
| 418 return Api::NewError("%s: %d is not a valid class id", |
| 419 CURRENT_FUNC, cls_id); |
| 420 } |
| 421 Class& cls = Class::Handle(isolate->class_table()->At(cls_id)); |
| 422 if (class_name != NULL) { |
| 423 *class_name = Api::NewHandle(isolate, cls.Name()); |
| 424 } |
| 425 if (library != NULL) { |
| 426 *library = Api::NewHandle(isolate, cls.library()); |
| 427 } |
| 428 if (super_class_id != NULL) { |
| 429 *super_class_id = 0; |
| 430 cls = cls.SuperClass(); |
| 431 if (!cls.IsNull()) { |
| 432 *super_class_id = cls.index(); |
| 433 } |
| 434 } |
| 435 if (static_fields != NULL) { |
| 436 *static_fields = |
| 437 Api::NewHandle(isolate, isolate->debugger()->GetStaticFields(cls)); |
| 438 } |
| 439 return Api::True(isolate); |
| 440 } |
| 441 |
| 442 |
| 376 DART_EXPORT Dart_Handle Dart_GetScriptSource( | 443 DART_EXPORT Dart_Handle Dart_GetScriptSource( |
| 377 Dart_Handle library_url_in, | 444 Dart_Handle library_url_in, |
| 378 Dart_Handle script_url_in) { | 445 Dart_Handle script_url_in) { |
| 379 Isolate* isolate = Isolate::Current(); | 446 Isolate* isolate = Isolate::Current(); |
| 380 DARTSCOPE(isolate); | 447 DARTSCOPE(isolate); |
| 381 String& library_url = String::Handle(); | 448 String& library_url = String::Handle(); |
| 382 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in); | 449 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in); |
| 383 String& script_url = String::Handle(); | 450 String& script_url = String::Handle(); |
| 384 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); | 451 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); |
| 385 | 452 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 for (int i = 0; i < num_libs; i++) { | 514 for (int i = 0; i < num_libs; i++) { |
| 448 ASSERT(!lib.IsNull()); | 515 ASSERT(!lib.IsNull()); |
| 449 lib_url = lib.url(); | 516 lib_url = lib.url(); |
| 450 library_list.SetAt(i, lib_url); | 517 library_list.SetAt(i, lib_url); |
| 451 lib = lib.next_registered(); | 518 lib = lib.next_registered(); |
| 452 } | 519 } |
| 453 return Api::NewHandle(isolate, library_list.raw()); | 520 return Api::NewHandle(isolate, library_list.raw()); |
| 454 } | 521 } |
| 455 | 522 |
| 456 } // namespace dart | 523 } // namespace dart |
| OLD | NEW |