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

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

Issue 8772009: Address Regis' comments, replace AbstractType with Type where possible. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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/class_finalizer.h ('k') | runtime/vm/code_generator_ia32.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/class_finalizer.h" 5 #include "vm/class_finalizer.h"
6 6
7 #include "vm/flags.h" 7 #include "vm/flags.h"
8 #include "vm/heap.h" 8 #include "vm/heap.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 } 285 }
286 return resolved_class.raw(); 286 return resolved_class.raw();
287 } 287 }
288 288
289 289
290 // Resolve unresolved supertype (String -> Class). 290 // Resolve unresolved supertype (String -> Class).
291 void ClassFinalizer::ResolveSuperType(const Class& cls) { 291 void ClassFinalizer::ResolveSuperType(const Class& cls) {
292 if (cls.is_finalized()) { 292 if (cls.is_finalized()) {
293 return; 293 return;
294 } 294 }
295 AbstractType& super_type = AbstractType::Handle(cls.super_type()); 295 Type& super_type = Type::Handle(cls.super_type());
296 if (super_type.IsNull()) { 296 if (super_type.IsNull()) {
297 return; 297 return;
298 } 298 }
299 // Resolve failures lead to a longjmp. 299 // Resolve failures lead to a longjmp.
300 super_type = ResolveType(cls, super_type); 300 ResolveType(cls, super_type);
301 if (super_type.IsTypeParameter()) {
302 String& class_name = String::Handle(cls.Name());
303 String& type_parameter_name = String::Handle(super_type.Name());
304 ReportError("'%s' cannot extend or implement type parameter '%s'.\n",
305 class_name.ToCString(),
306 type_parameter_name.ToCString());
307 }
308 cls.set_super_type(super_type); 301 cls.set_super_type(super_type);
regis 2011/12/01 20:53:17 Since we now resolve the type in place, you do not
srdjan 2011/12/01 21:04:00 Done.
309 const Class& super_class = Class::Handle(super_type.type_class()); 302 const Class& super_class = Class::Handle(super_type.type_class());
310 if (cls.is_interface() != super_class.is_interface()) { 303 if (cls.is_interface() != super_class.is_interface()) {
311 String& class_name = String::Handle(cls.Name()); 304 String& class_name = String::Handle(cls.Name());
312 String& super_class_name = String::Handle(super_class.Name()); 305 String& super_class_name = String::Handle(super_class.Name());
313 const Script& script = Script::Handle(cls.script()); 306 const Script& script = Script::Handle(cls.script());
314 ReportError(script, -1, 307 ReportError(script, -1,
315 "class '%s' and superclass '%s' are not " 308 "class '%s' and superclass '%s' are not "
316 "both classes or both interfaces.\n", 309 "both classes or both interfaces.\n",
317 class_name.ToCString(), 310 class_name.ToCString(),
318 super_class_name.ToCString()); 311 super_class_name.ToCString());
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 ReportError(script, unresolved_factory_class.token_index(), 427 ReportError(script, unresolved_factory_class.token_index(),
435 "mismatch in number or names of type parameters between " 428 "mismatch in number or names of type parameters between "
436 "factory clause of interface '%s' and actual factory " 429 "factory clause of interface '%s' and actual factory "
437 "class '%s'.\n", 430 "class '%s'.\n",
438 interface_name.ToCString(), 431 interface_name.ToCString(),
439 factory_name.ToCString()); 432 factory_name.ToCString());
440 } 433 }
441 } 434 }
442 435
443 436
444 // TODO(regis): Now that we do not resolve type parameters anymore, we could 437 void ClassFinalizer::ResolveType(const Class& cls, const AbstractType& type) {
445 // make this function void and resolve the type in place.
446 RawAbstractType* ClassFinalizer::ResolveType(
447 const Class& cls, const AbstractType& type) {
448 if (type.IsResolved()) { 438 if (type.IsResolved()) {
449 return type.raw(); 439 return;
450 } 440 }
451 if (FLAG_trace_type_finalization) { 441 if (FLAG_trace_type_finalization) {
452 OS::Print("Resolve type '%s'\n", String::Handle(type.Name()).ToCString()); 442 OS::Print("Resolve type '%s'\n", String::Handle(type.Name()).ToCString());
453 } 443 }
454 444
455 // Resolve the type class. 445 // Resolve the type class.
456 if (!type.HasResolvedTypeClass()) { 446 if (!type.HasResolvedTypeClass()) {
457 // Type parameters are always resolved in the parser in the correct 447 // Type parameters are always resolved in the parser in the correct
458 // non-static scope or factory scope. That resolution scope is unknown here. 448 // non-static scope or factory scope. That resolution scope is unknown here.
459 // Being able to resolve a type parameter from class cls here would indicate 449 // Being able to resolve a type parameter from class cls here would indicate
(...skipping 13 matching lines...) Expand all
473 parameterized_type.set_type_class(Object::Handle(type_class.raw())); 463 parameterized_type.set_type_class(Object::Handle(type_class.raw()));
474 } 464 }
475 465
476 // Resolve type arguments, if any. 466 // Resolve type arguments, if any.
477 const TypeArguments& arguments = TypeArguments::Handle(type.arguments()); 467 const TypeArguments& arguments = TypeArguments::Handle(type.arguments());
478 if (!arguments.IsNull()) { 468 if (!arguments.IsNull()) {
479 intptr_t num_arguments = arguments.Length(); 469 intptr_t num_arguments = arguments.Length();
480 AbstractType& type_argument = AbstractType::Handle(); 470 AbstractType& type_argument = AbstractType::Handle();
481 for (intptr_t i = 0; i < num_arguments; i++) { 471 for (intptr_t i = 0; i < num_arguments; i++) {
482 type_argument = arguments.TypeAt(i); 472 type_argument = arguments.TypeAt(i);
483 type_argument = ResolveType(cls, type_argument); 473 ResolveType(cls, type_argument);
484 arguments.SetTypeAt(i, type_argument); 474 arguments.SetTypeAt(i, type_argument);
regis 2011/12/01 20:53:17 ditto
srdjan 2011/12/01 21:04:00 Done.
485 } 475 }
486 } 476 }
487 return type.raw();
488 } 477 }
489 478
490 479
491 // Finalize the type argument vector 'arguments' of the type defined by the 480 // Finalize the type argument vector 'arguments' of the type defined by the
492 // class 'cls' parameterized with the type arguments 'cls_args'. 481 // class 'cls' parameterized with the type arguments 'cls_args'.
493 // The vector 'cls_args' is already initialized as a subvector at the correct 482 // The vector 'cls_args' is already initialized as a subvector at the correct
494 // position in the passed in 'arguments' vector. 483 // position in the passed in 'arguments' vector.
495 // The subvector 'cls_args' has length cls.NumTypeParameters() and starts at 484 // The subvector 'cls_args' has length cls.NumTypeParameters() and starts at
496 // offset cls.NumTypeArguments() - cls.NumTypeParameters() of the 'arguments' 485 // offset cls.NumTypeArguments() - cls.NumTypeParameters() of the 'arguments'
497 // vector. 486 // vector.
498 // Example: 487 // Example:
499 // Declared: class C<K, V> extends B<V> { ... } 488 // Declared: class C<K, V> extends B<V> { ... }
500 // class B<T> extends Array<int> { ... } 489 // class B<T> extends Array<int> { ... }
501 // Input: C<String, double> expressed as 490 // Input: C<String, double> expressed as
502 // cls = C, arguments = [null, null, String, double], 491 // cls = C, arguments = [null, null, String, double],
503 // i.e. cls_args = [String, double], offset = 2, length = 2. 492 // i.e. cls_args = [String, double], offset = 2, length = 2.
504 // Output: arguments = [int, double, String, double] 493 // Output: arguments = [int, double, String, double]
505 void ClassFinalizer::FinalizeTypeArguments(const Class& cls, 494 void ClassFinalizer::FinalizeTypeArguments(const Class& cls,
506 const TypeArguments& arguments) { 495 const TypeArguments& arguments) {
507 ASSERT(arguments.Length() >= cls.NumTypeArguments()); 496 ASSERT(arguments.Length() >= cls.NumTypeArguments());
508 AbstractType& super_type = AbstractType::Handle(cls.super_type()); 497 Type& super_type = Type::Handle(cls.super_type());
509 if (!super_type.IsNull()) { 498 if (!super_type.IsNull()) {
510 super_type = FinalizeType(super_type); 499 super_type ^= FinalizeType(super_type);
511 cls.set_super_type(super_type); 500 cls.set_super_type(super_type);
512 const Class& super_class = Class::Handle(super_type.type_class()); 501 const Class& super_class = Class::Handle(super_type.type_class());
513 const TypeArguments& super_type_args = 502 const TypeArguments& super_type_args =
514 TypeArguments::Handle(super_type.arguments()); 503 TypeArguments::Handle(super_type.arguments());
515 const intptr_t num_super_type_params = super_class.NumTypeParameters(); 504 const intptr_t num_super_type_params = super_class.NumTypeParameters();
516 const intptr_t offset = super_class.NumTypeArguments(); 505 const intptr_t offset = super_class.NumTypeArguments();
517 const intptr_t super_offset = offset - num_super_type_params; 506 const intptr_t super_offset = offset - num_super_type_params;
518 ASSERT(offset == (cls.NumTypeArguments() - cls.NumTypeParameters())); 507 ASSERT(offset == (cls.NumTypeArguments() - cls.NumTypeParameters()));
519 AbstractType& super_type_arg = AbstractType::Handle(); 508 AbstractType& super_type_arg = AbstractType::Handle();
520 for (intptr_t i = 0; i < num_super_type_params; i++) { 509 for (intptr_t i = 0; i < num_super_type_params; i++) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 ReportError(script, -1, 550 ReportError(script, -1,
562 "type argument '%s' of class '%s' " 551 "type argument '%s' of class '%s' "
563 "does not extend type '%s'\n", 552 "does not extend type '%s'\n",
564 type_argument_name.ToCString(), 553 type_argument_name.ToCString(),
565 class_name.ToCString(), 554 class_name.ToCString(),
566 extends_name.ToCString()); 555 extends_name.ToCString());
567 } 556 }
568 } 557 }
569 } 558 }
570 } 559 }
571 AbstractType& super_type = AbstractType::Handle(cls.super_type()); 560 const Type& super_type = Type::Handle(cls.super_type());
572 if (!super_type.IsNull()) { 561 if (!super_type.IsNull()) {
573 ASSERT(super_type.IsFinalized()); 562 ASSERT(super_type.IsFinalized());
574 const Class& super_class = Class::Handle(super_type.type_class()); 563 const Class& super_class = Class::Handle(super_type.type_class());
575 VerifyUpperBounds(super_class, arguments); 564 VerifyUpperBounds(super_class, arguments);
576 } 565 }
577 } 566 }
578 567
579 568
580 RawAbstractType* ClassFinalizer::FinalizeType(const AbstractType& type) { 569 RawAbstractType* ClassFinalizer::FinalizeType(const AbstractType& type) {
581 ASSERT(type.IsResolved()); 570 ASSERT(type.IsResolved());
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 if (FLAG_enable_type_checks) { 670 if (FLAG_enable_type_checks) {
682 VerifyUpperBounds(type_class, full_arguments); 671 VerifyUpperBounds(type_class, full_arguments);
683 } 672 }
684 } else { 673 } else {
685 parameterized_type.set_is_finalized(); 674 parameterized_type.set_is_finalized();
686 } 675 }
687 return parameterized_type.Canonicalize(); 676 return parameterized_type.Canonicalize();
688 } 677 }
689 678
690 679
691 RawAbstractType* ClassFinalizer::FinalizeAndCanonicalizeType( 680 RawType* ClassFinalizer::FinalizeAndCanonicalizeType(const Type& type,
692 const AbstractType& type, String* errmsg) { 681 String* errmsg) {
693 Isolate* isolate = Isolate::Current(); 682 Isolate* isolate = Isolate::Current();
694 ASSERT(isolate != NULL); 683 ASSERT(isolate != NULL);
695 LongJump* base = isolate->long_jump_base(); 684 LongJump* base = isolate->long_jump_base();
696 LongJump jump; 685 LongJump jump;
697 isolate->set_long_jump_base(&jump); 686 isolate->set_long_jump_base(&jump);
698 if (setjmp(*jump.Set()) == 0) { 687 if (setjmp(*jump.Set()) == 0) {
699 const AbstractType& canonical_type = 688 Type& canonical_type = Type::Handle();
700 AbstractType::Handle(FinalizeType(type)); 689 canonical_type ^= FinalizeType(type);
701 isolate->set_long_jump_base(base); 690 isolate->set_long_jump_base(base);
702 *errmsg = String::null(); 691 *errmsg = String::null();
703 return canonical_type.raw(); 692 return canonical_type.raw();
704 } else { 693 } else {
705 // Error occured: Get the error message. 694 // Error occured: Get the error message.
706 isolate->set_long_jump_base(base); 695 isolate->set_long_jump_base(base);
707 *errmsg = isolate->object_store()->sticky_error(); 696 *errmsg = isolate->object_store()->sticky_error();
708 return type.raw(); 697 return type.raw();
709 } 698 }
710 UNREACHABLE(); 699 UNREACHABLE();
711 return NULL; 700 return NULL;
712 } 701 }
713 702
714 703
715 void ClassFinalizer::ResolveAndFinalizeSignature(const Class& cls, 704 void ClassFinalizer::ResolveAndFinalizeSignature(const Class& cls,
716 const Function& function) { 705 const Function& function) {
717 // Resolve result type. 706 // Resolve result type.
718 AbstractType& type = AbstractType::Handle(function.result_type()); 707 AbstractType& type = AbstractType::Handle(function.result_type());
719 if (!type.IsResolved()) { 708 if (!type.IsResolved()) {
720 if (function.IsFactory()) { 709 if (function.IsFactory()) {
721 // The signature class of the factory for a generic class holds the type 710 // The signature class of the factory for a generic class holds the type
722 // parameters and their upper bounds. Copy the signature class from the 711 // parameters and their upper bounds. Copy the signature class from the
723 // result before it gets resolved. 712 // result before it gets resolved.
724 const UnresolvedClass& unresolved_type_class = 713 const UnresolvedClass& unresolved_type_class =
725 UnresolvedClass::Handle(type.unresolved_class()); 714 UnresolvedClass::Handle(type.unresolved_class());
726 const Class& factory_signature_class = 715 const Class& factory_signature_class =
727 Class::Handle(unresolved_type_class.factory_signature_class()); 716 Class::Handle(unresolved_type_class.factory_signature_class());
728 ASSERT(!factory_signature_class.IsNull()); 717 ASSERT(!factory_signature_class.IsNull());
729 function.set_signature_class(factory_signature_class); 718 function.set_signature_class(factory_signature_class);
730 type = ResolveType(cls, type); 719 ResolveType(cls, type);
731 function.set_result_type(type); 720 function.set_result_type(type);
regis 2011/12/01 20:53:17 ditto
srdjan 2011/12/01 21:04:00 Done.
732 const Class& type_class = Class::Handle(type.type_class()); 721 const Class& type_class = Class::Handle(type.type_class());
733 // Verify that the factory signature declares the same number of type 722 // Verify that the factory signature declares the same number of type
734 // parameters as the return type class or interface. 723 // parameters as the return type class or interface.
735 ResolveAndFinalizeUpperBounds(factory_signature_class); 724 ResolveAndFinalizeUpperBounds(factory_signature_class);
736 if (factory_signature_class.NumTypeParameters() != 725 if (factory_signature_class.NumTypeParameters() !=
737 type_class.NumTypeParameters()) { 726 type_class.NumTypeParameters()) {
738 const String& function_name = String::Handle(function.name()); 727 const String& function_name = String::Handle(function.name());
739 if (factory_signature_class.NumTypeParameters() == 0) { 728 if (factory_signature_class.NumTypeParameters() == 0) {
740 // TODO(regis): For now, and until the core lib is fixed, we accept a 729 // TODO(regis): For now, and until the core lib is fixed, we accept a
741 // factory method with missing list of type parameters and use the 730 // factory method with missing list of type parameters and use the
(...skipping 12 matching lines...) Expand all
754 const Class& enclosing_class = Class::Handle(function.owner()); 743 const Class& enclosing_class = Class::Handle(function.owner());
755 const Script& script = Script::Handle(enclosing_class.script()); 744 const Script& script = Script::Handle(enclosing_class.script());
756 ReportError(script, unresolved_type_class.token_index(), 745 ReportError(script, unresolved_type_class.token_index(),
757 "factory method '%s' must declare %d type parameter%s.\n", 746 "factory method '%s' must declare %d type parameter%s.\n",
758 function_name.ToCString(), 747 function_name.ToCString(),
759 type_class.NumTypeParameters(), 748 type_class.NumTypeParameters(),
760 type_class.NumTypeParameters() > 1 ? "s" : ""); 749 type_class.NumTypeParameters() > 1 ? "s" : "");
761 } 750 }
762 } 751 }
763 } else { 752 } else {
764 type = ResolveType(cls, type); 753 ResolveType(cls, type);
765 function.set_result_type(type); 754 function.set_result_type(type);
regis 2011/12/01 20:53:17 ditto
srdjan 2011/12/01 21:04:00 Done.
766 } 755 }
767 } 756 }
768 type = FinalizeType(type); 757 type = FinalizeType(type);
769 function.set_result_type(type); 758 function.set_result_type(type);
770 // Resolve formal parameter types. 759 // Resolve formal parameter types.
771 const intptr_t num_parameters = function.NumberOfParameters(); 760 const intptr_t num_parameters = function.NumberOfParameters();
772 for (intptr_t i = 0; i < num_parameters; i++) { 761 for (intptr_t i = 0; i < num_parameters; i++) {
773 type = function.ParameterTypeAt(i); 762 type = function.ParameterTypeAt(i);
774 type = ResolveType(cls, type); 763 ResolveType(cls, type);
775 function.SetParameterTypeAt(i, type); 764 function.SetParameterTypeAt(i, type);
regis 2011/12/01 20:53:17 ditto
srdjan 2011/12/01 21:04:00 Done.
776 type = FinalizeType(type); 765 type = FinalizeType(type);
777 function.SetParameterTypeAt(i, type); 766 function.SetParameterTypeAt(i, type);
778 } 767 }
779 } 768 }
780 769
781 770
782 static RawClass* FindSuperOwnerOfInstanceMember(const Class& cls, 771 static RawClass* FindSuperOwnerOfInstanceMember(const Class& cls,
783 const String& name) { 772 const String& name) {
784 Class& super_class = Class::Handle(); 773 Class& super_class = Class::Handle();
785 Function& function = Function::Handle(); 774 Function& function = Function::Handle();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 // Resolve and finalize the upper bounds of the type parameters of class cls. 810 // Resolve and finalize the upper bounds of the type parameters of class cls.
822 void ClassFinalizer::ResolveAndFinalizeUpperBounds(const Class& cls) { 811 void ClassFinalizer::ResolveAndFinalizeUpperBounds(const Class& cls) {
823 const intptr_t num_type_params = cls.NumTypeParameters(); 812 const intptr_t num_type_params = cls.NumTypeParameters();
824 AbstractType& type_extends = AbstractType::Handle(); 813 AbstractType& type_extends = AbstractType::Handle();
825 const TypeArguments& extends_array = 814 const TypeArguments& extends_array =
826 TypeArguments::Handle(cls.type_parameter_extends()); 815 TypeArguments::Handle(cls.type_parameter_extends());
827 ASSERT((extends_array.IsNull() && (num_type_params == 0)) || 816 ASSERT((extends_array.IsNull() && (num_type_params == 0)) ||
828 (extends_array.Length() == num_type_params)); 817 (extends_array.Length() == num_type_params));
829 for (intptr_t i = 0; i < num_type_params; i++) { 818 for (intptr_t i = 0; i < num_type_params; i++) {
830 type_extends = extends_array.TypeAt(i); 819 type_extends = extends_array.TypeAt(i);
831 type_extends = ResolveType(cls, type_extends); 820 ResolveType(cls, type_extends);
832 extends_array.SetTypeAt(i, type_extends); 821 extends_array.SetTypeAt(i, type_extends);
regis 2011/12/01 20:53:17 ditto
srdjan 2011/12/01 21:04:00 Done.
833 type_extends = FinalizeType(type_extends); 822 type_extends = FinalizeType(type_extends);
834 extends_array.SetTypeAt(i, type_extends); 823 extends_array.SetTypeAt(i, type_extends);
835 } 824 }
836 } 825 }
837 826
838 827
839 void ClassFinalizer::ResolveAndFinalizeMemberTypes(const Class& cls) { 828 void ClassFinalizer::ResolveAndFinalizeMemberTypes(const Class& cls) {
840 // Note that getters and setters are explicitly listed as such in the list of 829 // Note that getters and setters are explicitly listed as such in the list of
841 // functions of a class, so we do not need to consider fields as implicitly 830 // functions of a class, so we do not need to consider fields as implicitly
842 // generating getters and setters. 831 // generating getters and setters.
843 // The only compile errors we report are therefore: 832 // The only compile errors we report are therefore:
844 // - a getter having the same name as a method (but not a getter) in a super 833 // - a getter having the same name as a method (but not a getter) in a super
845 // class or in a subclass. 834 // class or in a subclass.
846 // - a setter having the same name as a method (but not a setter) in a super 835 // - a setter having the same name as a method (but not a setter) in a super
847 // class or in a subclass. 836 // class or in a subclass.
848 // - a static field, instance field, or static method (but not an instance 837 // - a static field, instance field, or static method (but not an instance
849 // method) having the same name as an instance member in a super class. 838 // method) having the same name as an instance member in a super class.
850 839
851 // Resolve type of fields and check for conflicts in super classes. 840 // Resolve type of fields and check for conflicts in super classes.
852 Array& array = Array::Handle(cls.fields()); 841 Array& array = Array::Handle(cls.fields());
853 Field& field = Field::Handle(); 842 Field& field = Field::Handle();
854 AbstractType& type = AbstractType::Handle(); 843 AbstractType& type = AbstractType::Handle();
855 String& name = String::Handle(); 844 String& name = String::Handle();
856 Class& super_class = Class::Handle(); 845 Class& super_class = Class::Handle();
857 intptr_t num_fields = array.Length(); 846 intptr_t num_fields = array.Length();
858 for (intptr_t i = 0; i < num_fields; i++) { 847 for (intptr_t i = 0; i < num_fields; i++) {
859 field ^= array.At(i); 848 field ^= array.At(i);
860 type = field.type(); 849 type = field.type();
861 type = ResolveType(cls, type); 850 ResolveType(cls, type);
862 field.set_type(type); 851 field.set_type(type);
regis 2011/12/01 20:53:17 ditto
srdjan 2011/12/01 21:04:00 Done.
863 type = FinalizeType(type); 852 type = FinalizeType(type);
864 field.set_type(type); 853 field.set_type(type);
865 name = field.name(); 854 name = field.name();
866 super_class = FindSuperOwnerOfInstanceMember(cls, name); 855 super_class = FindSuperOwnerOfInstanceMember(cls, name);
867 if (!super_class.IsNull()) { 856 if (!super_class.IsNull()) {
868 const String& class_name = String::Handle(cls.Name()); 857 const String& class_name = String::Handle(cls.Name());
869 const String& super_class_name = String::Handle(super_class.Name()); 858 const String& super_class_name = String::Handle(super_class.Name());
870 const Script& script = Script::Handle(cls.script()); 859 const Script& script = Script::Handle(cls.script());
871 ReportError(script, field.token_index(), 860 ReportError(script, field.token_index(),
872 "field '%s' of class '%s' conflicts with instance " 861 "field '%s' of class '%s' conflicts with instance "
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 ASSERT(!cls.IsSignatureClass()); 986 ASSERT(!cls.IsSignatureClass());
998 if (!IsSuperCycleFree(cls)) { 987 if (!IsSuperCycleFree(cls)) {
999 const String& name = String::Handle(cls.Name()); 988 const String& name = String::Handle(cls.Name());
1000 const Script& script = Script::Handle(cls.script()); 989 const Script& script = Script::Handle(cls.script());
1001 ReportError(script, -1, 990 ReportError(script, -1,
1002 "class '%s' has a cycle in its superclass relationship.\n", 991 "class '%s' has a cycle in its superclass relationship.\n",
1003 name.ToCString()); 992 name.ToCString());
1004 } 993 }
1005 GrowableArray<const Class*> visited; 994 GrowableArray<const Class*> visited;
1006 ResolveInterfaces(cls, &visited); 995 ResolveInterfaces(cls, &visited);
1007 AbstractType& super_type = AbstractType::Handle(cls.super_type()); 996 Type& super_type = Type::Handle(cls.super_type());
1008 if (!super_type.IsNull()) { 997 if (!super_type.IsNull()) {
1009 const Class& super_class = Class::Handle(super_type.type_class()); 998 const Class& super_class = Class::Handle(super_type.type_class());
1010 // Finalize super class and super type. 999 // Finalize super class and super type.
1011 FinalizeClass(super_class, generating_snapshot); 1000 FinalizeClass(super_class, generating_snapshot);
1012 super_type = FinalizeType(super_type); 1001 super_type ^= FinalizeType(super_type);
1013 cls.set_super_type(super_type); 1002 cls.set_super_type(super_type);
1014 } 1003 }
1015 if (cls.is_interface()) { 1004 if (cls.is_interface()) {
1016 if (cls.HasFactoryClass()) { 1005 if (cls.HasFactoryClass()) {
1017 const Class& factory_class = Class::Handle(cls.FactoryClass()); 1006 const Class& factory_class = Class::Handle(cls.FactoryClass());
1018 // Finalize factory class. 1007 // Finalize factory class.
1019 if (!factory_class.is_finalized()) { 1008 if (!factory_class.is_finalized()) {
1020 FinalizeClass(factory_class, generating_snapshot); 1009 FinalizeClass(factory_class, generating_snapshot);
1021 // Finalizing the factory class may indirectly finalize this interface. 1010 // Finalizing the factory class may indirectly finalize this interface.
1022 if (cls.is_finalized()) { 1011 if (cls.is_finalized()) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 // about allowed interfaces are lifted. 1138 // about allowed interfaces are lifted.
1150 const bool cls_belongs_to_core_lib = 1139 const bool cls_belongs_to_core_lib =
1151 (cls.library() == Library::CoreLibrary()) || 1140 (cls.library() == Library::CoreLibrary()) ||
1152 (cls.library() == Library::CoreImplLibrary()); 1141 (cls.library() == Library::CoreImplLibrary());
1153 1142
1154 // Resolve and check the interfaces of cls. 1143 // Resolve and check the interfaces of cls.
1155 visited->Add(&cls); 1144 visited->Add(&cls);
1156 AbstractType& interface = AbstractType::Handle(); 1145 AbstractType& interface = AbstractType::Handle();
1157 for (intptr_t i = 0; i < super_interfaces.Length(); i++) { 1146 for (intptr_t i = 0; i < super_interfaces.Length(); i++) {
1158 interface ^= super_interfaces.At(i); 1147 interface ^= super_interfaces.At(i);
1159 interface = ResolveType(cls, interface); 1148 ResolveType(cls, interface);
1160 super_interfaces.SetAt(i, interface); 1149 super_interfaces.SetAt(i, interface);
regis 2011/12/01 20:53:17 ditto
srdjan 2011/12/01 21:04:00 Done.
1161 if (interface.IsTypeParameter()) { 1150 if (interface.IsTypeParameter()) {
1162 const Script& script = Script::Handle(cls.script()); 1151 const Script& script = Script::Handle(cls.script());
1163 ReportError(script, -1, 1152 ReportError(script, -1,
1164 "Type parameter '%s' cannot be used as interface\n", 1153 "Type parameter '%s' cannot be used as interface\n",
1165 String::Handle(interface.Name()).ToCString()); 1154 String::Handle(interface.Name()).ToCString());
1166 } 1155 }
1167 const Class& interface_class = Class::Handle(interface.type_class()); 1156 const Class& interface_class = Class::Handle(interface.type_class());
1168 if (!interface_class.is_interface()) { 1157 if (!interface_class.is_interface()) {
1169 const Script& script = Script::Handle(cls.script()); 1158 const Script& script = Script::Handle(cls.script());
1170 ReportError(script, -1, 1159 ReportError(script, -1,
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 va_end(args); 1298 va_end(args);
1310 if (FLAG_warning_as_error) { 1299 if (FLAG_warning_as_error) {
1311 Isolate::Current()->long_jump_base()->Jump(1, message_buffer); 1300 Isolate::Current()->long_jump_base()->Jump(1, message_buffer);
1312 UNREACHABLE(); 1301 UNREACHABLE();
1313 } else { 1302 } else {
1314 OS::Print(message_buffer); 1303 OS::Print(message_buffer);
1315 } 1304 }
1316 } 1305 }
1317 1306
1318 } // namespace dart 1307 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_finalizer.h ('k') | runtime/vm/code_generator_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698