Chromium Code Reviews| 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/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 Loading... | |
| 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 for (intptr_t i = 0; i < num_expected_type_arguments; i++) { | |
|
regis
2013/07/01 16:29:27
It is not correct to start at index 0. Since you c
siva
2013/07/01 18:45:15
As discussed offline I went with the adjustment to
| |
| 534 type_arg ^= type_args_array.TypeAt(i); | |
| 535 super_type_args_array.SetTypeAt(i, type_arg); | |
| 536 } | |
| 537 | |
| 538 // Construct the super type object, canonicalize it and return. | |
| 539 Type& instantiated_type = Type::Handle( | |
| 540 Type::New(super_cls, super_type_args_array, Scanner::kDummyTokenIndex)); | |
| 541 ASSERT(!instantiated_type.IsNull()); | |
| 542 instantiated_type ^= ClassFinalizer::FinalizeType( | |
| 543 super_cls, instantiated_type, ClassFinalizer::kCanonicalize); | |
| 544 return Api::NewHandle(isolate, instantiated_type.raw()); | |
| 545 } | |
| 546 | |
| 547 | |
| 508 DART_EXPORT Dart_Handle Dart_GetClassInfo( | 548 DART_EXPORT Dart_Handle Dart_GetClassInfo( |
| 509 intptr_t cls_id, | 549 intptr_t cls_id, |
| 510 Dart_Handle* class_name, | 550 Dart_Handle* class_name, |
| 511 intptr_t* library_id, | 551 intptr_t* library_id, |
| 512 intptr_t* super_class_id, | 552 intptr_t* super_class_id, |
| 513 Dart_Handle* static_fields) { | 553 Dart_Handle* static_fields) { |
| 514 Isolate* isolate = Isolate::Current(); | 554 Isolate* isolate = Isolate::Current(); |
| 515 DARTSCOPE(isolate); | 555 DARTSCOPE(isolate); |
| 516 if (!isolate->class_table()->IsValidIndex(cls_id)) { | 556 if (!isolate->class_table()->IsValidIndex(cls_id)) { |
| 517 return Api::NewError("%s: %"Pd" is not a valid class id", | 557 return Api::NewError("%s: %"Pd" is not a valid class id", |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 773 | 813 |
| 774 | 814 |
| 775 DART_EXPORT char* Dart_GetVmStatus(const char* request) { | 815 DART_EXPORT char* Dart_GetVmStatus(const char* request) { |
| 776 if (strncmp(request, "/isolate/", 9) == 0) { | 816 if (strncmp(request, "/isolate/", 9) == 0) { |
| 777 return Isolate::GetStatus(request); | 817 return Isolate::GetStatus(request); |
| 778 } | 818 } |
| 779 return NULL; | 819 return NULL; |
| 780 } | 820 } |
| 781 | 821 |
| 782 } // namespace dart | 822 } // namespace dart |
| OLD | NEW |