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

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

Issue 18238003: Add Dart_GetSupertype to the dart debugger API so that the dartium (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/debugger_api_impl_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/dart_api_impl.h" 8 #include "vm/dart_api_impl.h"
8 #include "vm/dart_api_state.h" 9 #include "vm/dart_api_state.h"
9 #include "vm/debugger.h" 10 #include "vm/debugger.h"
10 #include "vm/isolate.h" 11 #include "vm/isolate.h"
11 #include "vm/object_store.h" 12 #include "vm/object_store.h"
12 #include "vm/symbols.h" 13 #include "vm/symbols.h"
13 14
14 namespace dart { 15 namespace dart {
15 16
16 #define UNWRAP_AND_CHECK_PARAM(type, var, param) \ 17 #define UNWRAP_AND_CHECK_PARAM(type, var, param) \
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 499
499 500
500 DART_EXPORT Dart_Handle Dart_GetSuperclass(Dart_Handle cls_in) { 501 DART_EXPORT Dart_Handle Dart_GetSuperclass(Dart_Handle cls_in) {
501 Isolate* isolate = Isolate::Current(); 502 Isolate* isolate = Isolate::Current();
502 DARTSCOPE(isolate); 503 DARTSCOPE(isolate);
503 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in); 504 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in);
504 return Api::NewHandle(isolate, cls.SuperClass()); 505 return Api::NewHandle(isolate, cls.SuperClass());
505 } 506 }
506 507
507 508
509 DART_EXPORT Dart_Handle Dart_GetSupertype(Dart_Handle type_in) {
510 Isolate* isolate = Isolate::Current();
511 DARTSCOPE(isolate);
512
513 UNWRAP_AND_CHECK_PARAM(Type, type, type_in);
514 const Class& cls= Class::Handle(type.type_class());
515 intptr_t num_expected_type_arguments = cls.NumTypeParameters();
516 if (num_expected_type_arguments == 0) {
517 // The super type has no type parameters or it is already instantiated
518 // just return it.
519 const AbstractType& type = AbstractType::Handle(cls.super_type());
520 if (type.IsNull()) {
521 return Dart_Null();
522 }
523 return Api::NewHandle(isolate, type.Canonicalize());
524 }
525 // Set up the type arguments array for the super class type.
526 const Class& super_cls = Class::Handle(cls.SuperClass());
527 num_expected_type_arguments = super_cls.NumTypeParameters();
528 const AbstractTypeArguments& type_args_array =
529 AbstractTypeArguments::Handle(type.arguments());
530 const TypeArguments& super_type_args_array =
531 TypeArguments::Handle(TypeArguments::New(num_expected_type_arguments));
532 AbstractType& type_arg = AbstractType::Handle();
533 intptr_t index_offset =
534 super_cls.NumTypeArguments() - num_expected_type_arguments;
535 for (intptr_t i = 0; i < num_expected_type_arguments; i++) {
536 ASSERT(type_args_array.Length() > (i + index_offset));
regis 2013/07/01 18:55:49 Isn't this ASSERT already checked as part of TypeA
siva 2013/07/01 19:41:40 True it is, removed the assert. On 2013/07/01 18:
537 type_arg ^= type_args_array.TypeAt(i + index_offset);
538 super_type_args_array.SetTypeAt(i, type_arg);
539 }
540
541 // Construct the super type object, canonicalize it and return.
542 Type& instantiated_type = Type::Handle(
543 Type::New(super_cls, super_type_args_array, Scanner::kDummyTokenIndex));
544 ASSERT(!instantiated_type.IsNull());
545 instantiated_type ^= ClassFinalizer::FinalizeType(
546 super_cls, instantiated_type, ClassFinalizer::kCanonicalize);
547 return Api::NewHandle(isolate, instantiated_type.raw());
548 }
549
550
508 DART_EXPORT Dart_Handle Dart_GetClassInfo( 551 DART_EXPORT Dart_Handle Dart_GetClassInfo(
509 intptr_t cls_id, 552 intptr_t cls_id,
510 Dart_Handle* class_name, 553 Dart_Handle* class_name,
511 intptr_t* library_id, 554 intptr_t* library_id,
512 intptr_t* super_class_id, 555 intptr_t* super_class_id,
513 Dart_Handle* static_fields) { 556 Dart_Handle* static_fields) {
514 Isolate* isolate = Isolate::Current(); 557 Isolate* isolate = Isolate::Current();
515 DARTSCOPE(isolate); 558 DARTSCOPE(isolate);
516 if (!isolate->class_table()->IsValidIndex(cls_id)) { 559 if (!isolate->class_table()->IsValidIndex(cls_id)) {
517 return Api::NewError("%s: %"Pd" is not a valid class id", 560 return Api::NewError("%s: %"Pd" is not a valid class id",
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 816
774 817
775 DART_EXPORT char* Dart_GetVmStatus(const char* request) { 818 DART_EXPORT char* Dart_GetVmStatus(const char* request) {
776 if (strncmp(request, "/isolate/", 9) == 0) { 819 if (strncmp(request, "/isolate/", 9) == 0) {
777 return Isolate::GetStatus(request); 820 return Isolate::GetStatus(request);
778 } 821 }
779 return NULL; 822 return NULL;
780 } 823 }
781 824
782 } // namespace dart 825 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/debugger_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698