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

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

Issue 23102019: Evaluate expression in the context of a class (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_api_state.h" 10 #include "vm/dart_api_state.h"
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(target)); 458 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(target));
459 // For backwards compatibility we allow class objects to be passed in 459 // For backwards compatibility we allow class objects to be passed in
460 // for now. This needs to be removed once all code that uses class 460 // for now. This needs to be removed once all code that uses class
461 // objects is removed. 461 // objects is removed.
462 Class& cls = Class::Handle(); 462 Class& cls = Class::Handle();
463 if (obj.IsType()) { 463 if (obj.IsType()) {
464 cls = Type::Cast(obj).type_class(); 464 cls = Type::Cast(obj).type_class();
465 } else if (obj.IsClass()) { 465 } else if (obj.IsClass()) {
466 cls = Class::Cast(obj).raw(); 466 cls = Class::Cast(obj).raw();
467 } else { 467 } else {
468 return Api::NewError("%s expects argument 'target' to be a type.", 468 return Api::NewError("%s expects argument 'target' to be a type",
469 CURRENT_FUNC); 469 CURRENT_FUNC);
470 } 470 }
471 return Api::NewHandle(isolate, isolate->debugger()->GetStaticFields(cls)); 471 return Api::NewHandle(isolate, isolate->debugger()->GetStaticFields(cls));
472 } 472 }
473 473
474 474
475 DART_EXPORT Dart_Handle Dart_GetLibraryFields(intptr_t library_id) { 475 DART_EXPORT Dart_Handle Dart_GetLibraryFields(intptr_t library_id) {
476 Isolate* isolate = Isolate::Current(); 476 Isolate* isolate = Isolate::Current();
477 DARTSCOPE(isolate); 477 DARTSCOPE(isolate);
478 const Library& lib = 478 const Library& lib =
(...skipping 12 matching lines...) Expand all
491 DARTSCOPE(isolate); 491 DARTSCOPE(isolate);
492 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); 492 const Library& lib = Library::Handle(Library::GetLibrary(library_id));
493 if (lib.IsNull()) { 493 if (lib.IsNull()) {
494 return Api::NewError("%s: %" Pd " is not a valid library id", 494 return Api::NewError("%s: %" Pd " is not a valid library id",
495 CURRENT_FUNC, library_id); 495 CURRENT_FUNC, library_id);
496 } 496 }
497 return Api::NewHandle(isolate, isolate->debugger()->GetGlobalFields(lib)); 497 return Api::NewHandle(isolate, isolate->debugger()->GetGlobalFields(lib));
498 } 498 }
499 499
500 500
501 DART_EXPORT Dart_Handle Dart_EvaluateExpr(Dart_Handle target, 501 DART_EXPORT Dart_Handle Dart_EvaluateExpr(Dart_Handle target_in,
502 Dart_Handle expr_in) { 502 Dart_Handle expr_in) {
503 Isolate* isolate = Isolate::Current(); 503 Isolate* isolate = Isolate::Current();
504 DARTSCOPE(isolate); 504 DARTSCOPE(isolate);
505 UNWRAP_AND_CHECK_PARAM(Instance, obj, target); 505
506 const Object& target = Object::Handle(isolate, Api::UnwrapHandle(target_in));
507 if (target.IsError()) return target_in;
508 if (target.IsNull()) {
509 return Api::NewError("%s expects argument 'target' to be non-null",
510 CURRENT_FUNC);
511 }
506 UNWRAP_AND_CHECK_PARAM(String, expr, expr_in); 512 UNWRAP_AND_CHECK_PARAM(String, expr, expr_in);
507 return Api::NewHandle(isolate, obj.Evaluate(expr)); 513 if (target.IsInstance()) {
514 return Api::NewHandle(isolate, Instance::Cast(target).Evaluate(expr));
515 } else if (target.IsClass()) {
516 return Api::NewHandle(isolate, Class::Cast(target).Evaluate(expr));
517 }
518 return Api::NewError("%s: unsupported target type", CURRENT_FUNC);
508 } 519 }
509 520
510 521
511 DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object_in) { 522 DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object_in) {
512 Isolate* isolate = Isolate::Current(); 523 Isolate* isolate = Isolate::Current();
513 DARTSCOPE(isolate); 524 DARTSCOPE(isolate);
514 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); 525 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in);
515 return Api::NewHandle(isolate, obj.clazz()); 526 return Api::NewHandle(isolate, obj.clazz());
516 } 527 }
517 528
518 529
519 DART_EXPORT Dart_Handle Dart_GetObjClassId(Dart_Handle object_in, 530 DART_EXPORT Dart_Handle Dart_GetObjClassId(Dart_Handle object_in,
520 intptr_t* class_id) { 531 intptr_t* class_id) {
521 Isolate* isolate = Isolate::Current(); 532 Isolate* isolate = Isolate::Current();
522 DARTSCOPE(isolate); 533 DARTSCOPE(isolate);
523 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); 534 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in);
524 CHECK_NOT_NULL(class_id); 535 CHECK_NOT_NULL(class_id);
525 *class_id = obj.GetClassId(); 536 *class_id = obj.GetClassId();
526 return Api::Success(); 537 return Api::Success();
527 } 538 }
528 539
529 540
541 DART_EXPORT Dart_Handle Dart_GetClassFromId(intptr_t class_id) {
542 Isolate* isolate = Isolate::Current();
543 DARTSCOPE(isolate);
544 if (!isolate->class_table()->IsValidIndex(class_id)) {
545 return Api::NewError("%s: %" Pd " is not a valid class id",
546 CURRENT_FUNC, class_id);
547 }
548 return Api::NewHandle(isolate, isolate->class_table()->At(class_id));
549 }
550
551
530 DART_EXPORT Dart_Handle Dart_GetSuperclass(Dart_Handle cls_in) { 552 DART_EXPORT Dart_Handle Dart_GetSuperclass(Dart_Handle cls_in) {
531 Isolate* isolate = Isolate::Current(); 553 Isolate* isolate = Isolate::Current();
532 DARTSCOPE(isolate); 554 DARTSCOPE(isolate);
533 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in); 555 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in);
534 return Api::NewHandle(isolate, cls.SuperClass()); 556 return Api::NewHandle(isolate, cls.SuperClass());
535 } 557 }
536 558
537 559
538 DART_EXPORT Dart_Handle Dart_GetSupertype(Dart_Handle type_in) { 560 DART_EXPORT Dart_Handle Dart_GetSupertype(Dart_Handle type_in) {
539 Isolate* isolate = Isolate::Current(); 561 Isolate* isolate = Isolate::Current();
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 872
851 873
852 DART_EXPORT char* Dart_GetVmStatus(const char* request) { 874 DART_EXPORT char* Dart_GetVmStatus(const char* request) {
853 if (strncmp(request, "/isolate/", 9) == 0) { 875 if (strncmp(request, "/isolate/", 9) == 0) {
854 return Isolate::GetStatus(request); 876 return Isolate::GetStatus(request);
855 } 877 }
856 return NULL; 878 return NULL;
857 } 879 }
858 880
859 } // namespace dart 881 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/include/dart_debugger_api.h ('k') | runtime/vm/object.h » ('j') | runtime/vm/object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698