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

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

Issue 20575003: Fix for issue 12136 (do not try to copy type arguments if the base class (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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 | « no previous file | 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/class_finalizer.h"
8 #include "vm/dart_api_impl.h" 8 #include "vm/dart_api_impl.h"
9 #include "vm/dart_api_state.h" 9 #include "vm/dart_api_state.h"
10 #include "vm/debugger.h" 10 #include "vm/debugger.h"
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in); 516 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in);
517 return Api::NewHandle(isolate, cls.SuperClass()); 517 return Api::NewHandle(isolate, cls.SuperClass());
518 } 518 }
519 519
520 520
521 DART_EXPORT Dart_Handle Dart_GetSupertype(Dart_Handle type_in) { 521 DART_EXPORT Dart_Handle Dart_GetSupertype(Dart_Handle type_in) {
522 Isolate* isolate = Isolate::Current(); 522 Isolate* isolate = Isolate::Current();
523 DARTSCOPE(isolate); 523 DARTSCOPE(isolate);
524 524
525 UNWRAP_AND_CHECK_PARAM(Type, type, type_in); 525 UNWRAP_AND_CHECK_PARAM(Type, type, type_in);
526 if (!type.IsFinalized()) {
527 return Api::NewError("%s: type in 'type_in' is not a finalized type",
528 CURRENT_FUNC);
529 }
530 if (!type.IsInstantiated()) {
531 return Api::NewError("%s: type in 'type_in' is not an instantiated type",
532 CURRENT_FUNC);
533 }
526 const Class& cls= Class::Handle(type.type_class()); 534 const Class& cls= Class::Handle(type.type_class());
527 intptr_t num_expected_type_arguments = cls.NumTypeParameters(); 535 if (cls.NumTypeParameters() == 0) {
528 if (num_expected_type_arguments == 0) {
529 // The super type has no type parameters or it is already instantiated 536 // The super type has no type parameters or it is already instantiated
530 // just return it. 537 // just return it.
531 const AbstractType& type = AbstractType::Handle(cls.super_type()); 538 const AbstractType& type = AbstractType::Handle(cls.super_type());
532 if (type.IsNull()) { 539 if (type.IsNull()) {
533 return Dart_Null(); 540 return Dart_Null();
534 } 541 }
535 return Api::NewHandle(isolate, type.Canonicalize()); 542 return Api::NewHandle(isolate, type.Canonicalize());
536 } 543 }
537 // Set up the type arguments array for the super class type. 544 // Set up the type arguments array for the super class type.
538 const Class& super_cls = Class::Handle(cls.SuperClass()); 545 const Class& super_cls = Class::Handle(cls.SuperClass());
539 num_expected_type_arguments = super_cls.NumTypeParameters(); 546 intptr_t num_expected_type_arguments = super_cls.NumTypeArguments();
547 TypeArguments& super_type_args_array = TypeArguments::Handle();
540 const AbstractTypeArguments& type_args_array = 548 const AbstractTypeArguments& type_args_array =
541 AbstractTypeArguments::Handle(type.arguments()); 549 AbstractTypeArguments::Handle(type.arguments());
542 const TypeArguments& super_type_args_array = 550 if (!type_args_array.IsNull() && (num_expected_type_arguments > 0)) {
543 TypeArguments::Handle(TypeArguments::New(num_expected_type_arguments)); 551 super_type_args_array = TypeArguments::New(num_expected_type_arguments);
544 AbstractType& type_arg = AbstractType::Handle(); 552 AbstractType& type_arg = AbstractType::Handle();
545 intptr_t index_offset = 553 for (intptr_t i = 0; i < num_expected_type_arguments; i++) {
546 super_cls.NumTypeArguments() - num_expected_type_arguments; 554 type_arg ^= type_args_array.TypeAt(i);
547 for (intptr_t i = 0; i < num_expected_type_arguments; i++) { 555 super_type_args_array.SetTypeAt(i, type_arg);
548 type_arg ^= type_args_array.TypeAt(i + index_offset); 556 }
549 super_type_args_array.SetTypeAt(i, type_arg);
550 } 557 }
551 558
552 // Construct the super type object, canonicalize it and return. 559 // Construct the super type object, canonicalize it and return.
553 Type& instantiated_type = Type::Handle( 560 Type& instantiated_type = Type::Handle(
554 Type::New(super_cls, super_type_args_array, Scanner::kDummyTokenIndex)); 561 Type::New(super_cls, super_type_args_array, Scanner::kDummyTokenIndex));
555 ASSERT(!instantiated_type.IsNull()); 562 ASSERT(!instantiated_type.IsNull());
556 instantiated_type ^= ClassFinalizer::FinalizeType( 563 instantiated_type.SetIsFinalized();
557 super_cls, instantiated_type, ClassFinalizer::kCanonicalize); 564 return Api::NewHandle(isolate, instantiated_type.Canonicalize());
558 return Api::NewHandle(isolate, instantiated_type.raw());
559 } 565 }
560 566
561 567
562 DART_EXPORT Dart_Handle Dart_GetClassInfo( 568 DART_EXPORT Dart_Handle Dart_GetClassInfo(
563 intptr_t cls_id, 569 intptr_t cls_id,
564 Dart_Handle* class_name, 570 Dart_Handle* class_name,
565 intptr_t* library_id, 571 intptr_t* library_id,
566 intptr_t* super_class_id, 572 intptr_t* super_class_id,
567 Dart_Handle* static_fields) { 573 Dart_Handle* static_fields) {
568 Isolate* isolate = Isolate::Current(); 574 Isolate* isolate = Isolate::Current();
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 833
828 834
829 DART_EXPORT char* Dart_GetVmStatus(const char* request) { 835 DART_EXPORT char* Dart_GetVmStatus(const char* request) {
830 if (strncmp(request, "/isolate/", 9) == 0) { 836 if (strncmp(request, "/isolate/", 9) == 0) {
831 return Isolate::GetStatus(request); 837 return Isolate::GetStatus(request);
832 } 838 }
833 return NULL; 839 return NULL;
834 } 840 }
835 841
836 } // namespace dart 842 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/debugger_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698