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

Side by Side Diff: runtime/vm/object.h

Issue 8776020: Ongoing renaming of type classes: (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
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 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "vm/assert.h" 8 #include "vm/assert.h"
9 #include "vm/dart.h" 9 #include "vm/dart.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 kNullObject = 0, 117 kNullObject = 0,
118 kSentinelObject, 118 kSentinelObject,
119 kClassClass, 119 kClassClass,
120 kNullClass, 120 kNullClass,
121 kDynamicClass, 121 kDynamicClass,
122 kVoidClass, 122 kVoidClass,
123 kUnresolvedClassClass, 123 kUnresolvedClassClass,
124 kTypeClass, 124 kTypeClass,
125 kTypeParameterClass, 125 kTypeParameterClass,
126 kInstantiatedTypeClass, 126 kInstantiatedTypeClass,
127 kAbstractTypeArgumentsClass,
127 kTypeArgumentsClass, 128 kTypeArgumentsClass,
128 kTypeArrayClass,
129 kInstantiatedTypeArgumentsClass, 129 kInstantiatedTypeArgumentsClass,
130 kFunctionClass, 130 kFunctionClass,
131 kFieldClass, 131 kFieldClass,
132 kTokenStreamClass, 132 kTokenStreamClass,
133 kScriptClass, 133 kScriptClass,
134 kLibraryClass, 134 kLibraryClass,
135 kLibraryPrefixClass, 135 kLibraryPrefixClass,
136 kCodeClass, 136 kCodeClass,
137 kInstructionsClass, 137 kInstructionsClass,
138 kPcDescriptorsClass, 138 kPcDescriptorsClass,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 static RawClass* dynamic_class() { return dynamic_class_; } 213 static RawClass* dynamic_class() { return dynamic_class_; }
214 static RawClass* void_class() { return void_class_; } 214 static RawClass* void_class() { return void_class_; }
215 static RawClass* unresolved_class_class() { return unresolved_class_class_; } 215 static RawClass* unresolved_class_class() { return unresolved_class_class_; }
216 static RawClass* type_class() { 216 static RawClass* type_class() {
217 return type_class_; 217 return type_class_;
218 } 218 }
219 static RawClass* type_parameter_class() { return type_parameter_class_; } 219 static RawClass* type_parameter_class() { return type_parameter_class_; }
220 static RawClass* instantiated_type_class() { 220 static RawClass* instantiated_type_class() {
221 return instantiated_type_class_; 221 return instantiated_type_class_;
222 } 222 }
223 static RawClass* type_arguments_class() { return type_arguments_class_; } 223 static RawClass* abstract_type_arguments_class() {
224 return abstract_type_arguments_class_;
225 }
224 static RawClass* type_array_class() { return type_array_class_; } 226 static RawClass* type_array_class() { return type_array_class_; }
225 static RawClass* instantiated_type_arguments_class() { 227 static RawClass* instantiated_type_arguments_class() {
226 return instantiated_type_arguments_class_; 228 return instantiated_type_arguments_class_;
227 } 229 }
228 static RawClass* function_class() { return function_class_; } 230 static RawClass* function_class() { return function_class_; }
229 static RawClass* field_class() { return field_class_; } 231 static RawClass* field_class() { return field_class_; }
230 static RawClass* token_stream_class() { return token_stream_class_; } 232 static RawClass* token_stream_class() { return token_stream_class_; }
231 static RawClass* script_class() { return script_class_; } 233 static RawClass* script_class() { return script_class_; }
232 static RawClass* library_class() { return library_class_; } 234 static RawClass* library_class() { return library_class_; }
233 static RawClass* library_prefix_class() { return library_prefix_class_; } 235 static RawClass* library_prefix_class() { return library_prefix_class_; }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 static RawInstance* transition_sentinel_; 320 static RawInstance* transition_sentinel_;
319 321
320 static RawClass* class_class_; // Class of the Class vm object. 322 static RawClass* class_class_; // Class of the Class vm object.
321 static RawClass* null_class_; // Class of the null object. 323 static RawClass* null_class_; // Class of the null object.
322 static RawClass* dynamic_class_; // Class of the 'Dynamic' type. 324 static RawClass* dynamic_class_; // Class of the 'Dynamic' type.
323 static RawClass* void_class_; // Class of the 'void' type. 325 static RawClass* void_class_; // Class of the 'void' type.
324 static RawClass* unresolved_class_class_; // Class of UnresolvedClass. 326 static RawClass* unresolved_class_class_; // Class of UnresolvedClass.
325 static RawClass* type_class_; // Class of Type. 327 static RawClass* type_class_; // Class of Type.
326 static RawClass* type_parameter_class_; // Class of TypeParameter vm object. 328 static RawClass* type_parameter_class_; // Class of TypeParameter vm object.
327 static RawClass* instantiated_type_class_; // Class of InstantiatedType. 329 static RawClass* instantiated_type_class_; // Class of InstantiatedType.
328 static RawClass* type_arguments_class_; // Class of TypeArguments vm object. 330 // Class of AbstractTypeArguments vm object.
329 static RawClass* type_array_class_; // Class of the TypeArray vm object. 331 static RawClass* abstract_type_arguments_class_;
332 static RawClass* type_array_class_; // Class of the TypeArguments vm object.
330 static RawClass* instantiated_type_arguments_class_; // Class of Inst..ments. 333 static RawClass* instantiated_type_arguments_class_; // Class of Inst..ments.
331 static RawClass* function_class_; // Class of the Function vm object. 334 static RawClass* function_class_; // Class of the Function vm object.
332 static RawClass* field_class_; // Class of the Field vm object. 335 static RawClass* field_class_; // Class of the Field vm object.
333 static RawClass* token_stream_class_; // Class of the TokenStream vm object. 336 static RawClass* token_stream_class_; // Class of the TokenStream vm object.
334 static RawClass* script_class_; // Class of the Script vm object. 337 static RawClass* script_class_; // Class of the Script vm object.
335 static RawClass* library_class_; // Class of the Library vm object. 338 static RawClass* library_class_; // Class of the Library vm object.
336 static RawClass* library_prefix_class_; // Class of Library prefix vm object. 339 static RawClass* library_prefix_class_; // Class of Library prefix vm object.
337 static RawClass* code_class_; // Class of the Code vm object. 340 static RawClass* code_class_; // Class of the Code vm object.
338 static RawClass* instructions_class_; // Class of the Instructions vm object. 341 static RawClass* instructions_class_; // Class of the Instructions vm object.
339 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object. 342 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 RawLibrary* library() const { return raw_ptr()->library_; } 416 RawLibrary* library() const { return raw_ptr()->library_; }
414 void set_library(const Library& value) const; 417 void set_library(const Library& value) const;
415 418
416 // The type parameters are specified as an array of Strings. 419 // The type parameters are specified as an array of Strings.
417 RawArray* type_parameters() const { return raw_ptr()->type_parameters_; } 420 RawArray* type_parameters() const { return raw_ptr()->type_parameters_; }
418 void set_type_parameters(const Array& value) const; 421 void set_type_parameters(const Array& value) const;
419 intptr_t NumTypeParameters() const; 422 intptr_t NumTypeParameters() const;
420 423
421 // Type parameters may optionally extend a Type (Dynamic if no extends). 424 // Type parameters may optionally extend a Type (Dynamic if no extends).
422 // TODO(regis): Should it be Object instead of Dynamic? 425 // TODO(regis): Should it be Object instead of Dynamic?
423 RawTypeArray* type_parameter_extends() const { 426 RawTypeArguments* type_parameter_extends() const {
424 return raw_ptr()->type_parameter_extends_; 427 return raw_ptr()->type_parameter_extends_;
425 } 428 }
426 void set_type_parameter_extends(const TypeArray& value) const; 429 void set_type_parameter_extends(const TypeArguments& value) const;
427 430
428 // Return a TypeParameter if the type_name is a type parameter of this class. 431 // Return a TypeParameter if the type_name is a type parameter of this class.
429 // Return null otherwise. 432 // Return null otherwise.
430 RawTypeParameter* LookupTypeParameter(const String& type_name) const; 433 RawTypeParameter* LookupTypeParameter(const String& type_name) const;
431 434
432 // The type argument vector is flattened and includes the type arguments of 435 // The type argument vector is flattened and includes the type arguments of
433 // the super class. 436 // the super class.
434 bool HasTypeArguments() const; 437 bool HasTypeArguments() const;
435 intptr_t NumTypeArguments() const; 438 intptr_t NumTypeArguments() const;
436 439
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 // Check if this class represents a signature class. 496 // Check if this class represents a signature class.
494 bool IsSignatureClass() const { 497 bool IsSignatureClass() const {
495 return signature_function() != Object::null(); 498 return signature_function() != Object::null();
496 } 499 }
497 500
498 // Check if this class represents a canonical signature class, i.e. not an 501 // Check if this class represents a canonical signature class, i.e. not an
499 // alias as defined in a typedef. 502 // alias as defined in a typedef.
500 bool IsCanonicalSignatureClass() const; 503 bool IsCanonicalSignatureClass() const;
501 504
502 // Check the "more specific than" relationship. 505 // Check the "more specific than" relationship.
503 bool IsMoreSpecificThan(const TypeArguments& type_arguments, 506 bool IsMoreSpecificThan(
504 const Class& other, 507 const AbstractTypeArguments& type_arguments,
505 const TypeArguments& other_type_arguments) const; 508 const Class& other,
509 const AbstractTypeArguments& other_type_arguments) const;
506 510
507 // Check the subtype relationship. 511 // Check the subtype relationship.
508 bool IsSubtypeOf(const TypeArguments& type_arguments, 512 bool IsSubtypeOf(const AbstractTypeArguments& type_arguments,
509 const Class& other, 513 const Class& other,
510 const TypeArguments& other_type_arguments) const { 514 const AbstractTypeArguments& other_type_arguments) const {
511 return TestType(kIsSubtypeOf, 515 return TestType(kIsSubtypeOf,
512 type_arguments, 516 type_arguments,
513 other, 517 other,
514 other_type_arguments); 518 other_type_arguments);
515 } 519 }
516 520
517 // Check the assignability relationship. 521 // Check the assignability relationship.
518 bool IsAssignableTo(const TypeArguments& type_arguments, 522 bool IsAssignableTo(const AbstractTypeArguments& type_arguments,
519 const Class& dst, 523 const Class& dst,
520 const TypeArguments& dst_type_arguments) const { 524 const AbstractTypeArguments& dst_type_arguments) const {
521 return TestType(kIsAssignableTo, 525 return TestType(kIsAssignableTo,
522 type_arguments, 526 type_arguments,
523 dst, 527 dst,
524 dst_type_arguments); 528 dst_type_arguments);
525 } 529 }
526 530
527 // Check if this is the top level class. 531 // Check if this is the top level class.
528 bool IsTopLevel() const; 532 bool IsTopLevel() const;
529 533
530 RawArray* fields() const { return raw_ptr()->fields_; } 534 RawArray* fields() const { return raw_ptr()->fields_; }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 void set_constants(const Array& value) const; 628 void set_constants(const Array& value) const;
625 RawArray* constants() const; 629 RawArray* constants() const;
626 630
627 void set_canonical_types(const Array& value) const; 631 void set_canonical_types(const Array& value) const;
628 RawArray* canonical_types() const; 632 RawArray* canonical_types() const;
629 633
630 void CalculateFieldOffsets() const; 634 void CalculateFieldOffsets() const;
631 635
632 // Check the subtype or assignability relationship. 636 // Check the subtype or assignability relationship.
633 bool TestType(TypeTestKind test, 637 bool TestType(TypeTestKind test,
634 const TypeArguments& type_arguments, 638 const AbstractTypeArguments& type_arguments,
635 const Class& other, 639 const Class& other,
636 const TypeArguments& other_type_arguments) const; 640 const AbstractTypeArguments& other_type_arguments) const;
637 641
638 // Assigns empty array to all raw class array fields. 642 // Assigns empty array to all raw class array fields.
639 void InitEmptyFields(); 643 void InitEmptyFields();
640 644
641 HEAP_OBJECT_IMPLEMENTATION(Class, Object); 645 HEAP_OBJECT_IMPLEMENTATION(Class, Object);
642 friend class Object; 646 friend class Object;
643 friend class Instance; 647 friend class Instance;
644 friend class Type; 648 friend class Type;
645 }; 649 };
646 650
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 // object. 'RawAbstractType' does not relate to a 'raw type', as opposed to a 692 // object. 'RawAbstractType' does not relate to a 'raw type', as opposed to a
689 // 'cooked type' or 'rare type'. 693 // 'cooked type' or 'rare type'.
690 class AbstractType : public Object { 694 class AbstractType : public Object {
691 public: 695 public:
692 virtual bool IsFinalized() const; 696 virtual bool IsFinalized() const;
693 virtual bool IsBeingFinalized() const; 697 virtual bool IsBeingFinalized() const;
694 virtual bool IsResolved() const; 698 virtual bool IsResolved() const;
695 virtual bool HasResolvedTypeClass() const; 699 virtual bool HasResolvedTypeClass() const;
696 virtual RawClass* type_class() const; 700 virtual RawClass* type_class() const;
697 virtual RawUnresolvedClass* unresolved_class() const; 701 virtual RawUnresolvedClass* unresolved_class() const;
698 virtual RawTypeArguments* arguments() const; 702 virtual RawAbstractTypeArguments* arguments() const;
699 virtual bool IsInstantiated() const; 703 virtual bool IsInstantiated() const;
700 virtual bool Equals(const AbstractType& other) const; 704 virtual bool Equals(const AbstractType& other) const;
701 705
702 // Instantiate this type using the given type argument vector starting at the 706 // Instantiate this type using the given type argument vector starting at the
703 // given offset. 707 // given offset.
704 // Return a new type, or return 'this' if it is already instantiated. 708 // Return a new type, or return 'this' if it is already instantiated.
705 virtual RawAbstractType* InstantiateFrom( 709 virtual RawAbstractType* InstantiateFrom(
706 const TypeArguments& instantiator_type_arguments, 710 const AbstractTypeArguments& instantiator_type_arguments,
707 intptr_t offset) const; 711 intptr_t offset) const;
708 712
709 // Return the canonical version of this type. 713 // Return the canonical version of this type.
710 virtual RawAbstractType* Canonicalize() const; 714 virtual RawAbstractType* Canonicalize() const;
711 715
712 // The name of this type, including the names of its type arguments, if any. 716 // The name of this type, including the names of its type arguments, if any.
713 virtual RawString* Name() const; 717 virtual RawString* Name() const;
714 718
715 // The index of this type parameter. Fail if not a type parameter. 719 // The index of this type parameter. Fail if not a type parameter.
716 virtual intptr_t Index() const; 720 virtual intptr_t Index() const;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 778
775 // Check the assignability relationship. 779 // Check the assignability relationship.
776 bool IsAssignableTo(const AbstractType& dst) const { 780 bool IsAssignableTo(const AbstractType& dst) const {
777 return Test(kIsAssignableTo, dst); 781 return Test(kIsAssignableTo, dst);
778 } 782 }
779 783
780 static RawAbstractType* NewTypeParameter(intptr_t index, const String& name); 784 static RawAbstractType* NewTypeParameter(intptr_t index, const String& name);
781 785
782 static RawAbstractType* NewInstantiatedType( 786 static RawAbstractType* NewInstantiatedType(
783 const AbstractType& uninstantiated_type, 787 const AbstractType& uninstantiated_type,
784 const TypeArguments& instantiator_type_arguments); 788 const AbstractTypeArguments& instantiator_type_arguments);
785 789
786 protected: 790 protected:
787 // Check the subtype or assignability relationship. 791 // Check the subtype or assignability relationship.
788 bool Test(TypeTestKind test, const AbstractType& other) const; 792 bool Test(TypeTestKind test, const AbstractType& other) const;
789 793
790 HEAP_OBJECT_IMPLEMENTATION(AbstractType, Object); 794 HEAP_OBJECT_IMPLEMENTATION(AbstractType, Object);
791 friend class Class; 795 friend class Class;
792 }; 796 };
793 797
794 798
795 // A Type consists of a class, possibly parameterized with type 799 // A Type consists of a class, possibly parameterized with type
796 // arguments. Example: C<T1, T2>. 800 // arguments. Example: C<T1, T2>.
797 // An unresolved class is a String specifying the class name. 801 // An unresolved class is a String specifying the class name.
798 class Type : public AbstractType { 802 class Type : public AbstractType {
799 public: 803 public:
800 virtual bool IsFinalized() const { 804 virtual bool IsFinalized() const {
801 return raw_ptr()->type_state_ == RawType::kFinalized; 805 return raw_ptr()->type_state_ == RawType::kFinalized;
802 } 806 }
803 void set_is_finalized() const; 807 void set_is_finalized() const;
804 virtual bool IsBeingFinalized() const { 808 virtual bool IsBeingFinalized() const {
805 return raw_ptr()->type_state_ == RawType::kBeingFinalized; 809 return raw_ptr()->type_state_ == RawType::kBeingFinalized;
806 } 810 }
807 void set_is_being_finalized() const; 811 void set_is_being_finalized() const;
808 virtual bool IsResolved() const; // Class and all arguments classes resolved. 812 virtual bool IsResolved() const; // Class and all arguments classes resolved.
809 virtual bool HasResolvedTypeClass() const; // Own type class resolved. 813 virtual bool HasResolvedTypeClass() const; // Own type class resolved.
810 virtual RawClass* type_class() const; 814 virtual RawClass* type_class() const;
811 void set_type_class(const Object& value) const; 815 void set_type_class(const Object& value) const;
812 virtual RawUnresolvedClass* unresolved_class() const; 816 virtual RawUnresolvedClass* unresolved_class() const;
813 virtual RawTypeArguments* arguments() const; 817 virtual RawAbstractTypeArguments* arguments() const;
814 void set_arguments(const TypeArguments& value) const; 818 void set_arguments(const AbstractTypeArguments& value) const;
815 virtual bool IsInstantiated() const; 819 virtual bool IsInstantiated() const;
816 virtual bool Equals(const AbstractType& other) const; 820 virtual bool Equals(const AbstractType& other) const;
817 virtual RawAbstractType* InstantiateFrom( 821 virtual RawAbstractType* InstantiateFrom(
818 const TypeArguments& instantiator_type_arguments, 822 const AbstractTypeArguments& instantiator_type_arguments,
819 intptr_t offset) const; 823 intptr_t offset) const;
820 virtual RawAbstractType* Canonicalize() const; 824 virtual RawAbstractType* Canonicalize() const;
821 825
822 static intptr_t InstanceSize() { 826 static intptr_t InstanceSize() {
823 return RoundedAllocationSize(sizeof(RawType)); 827 return RoundedAllocationSize(sizeof(RawType));
824 } 828 }
825 829
826 // The type of the literal 'null'. 830 // The type of the literal 'null'.
827 static RawType* NullType(); 831 static RawType* NullType();
828 832
(...skipping 29 matching lines...) Expand all
858 862
859 // The least specific valid raw type of the given class. 863 // The least specific valid raw type of the given class.
860 // For example, type A<Dynamic> would be returned for class A<T>, and type 864 // For example, type A<Dynamic> would be returned for class A<T>, and type
861 // B<Dynamic, A<Dynamic>> would be returned for B<U, V extends A>. 865 // B<Dynamic, A<Dynamic>> would be returned for B<U, V extends A>.
862 static RawType* NewRawType(const Class& type_class); 866 static RawType* NewRawType(const Class& type_class);
863 867
864 // The finalized type of the given non-parameterized class. 868 // The finalized type of the given non-parameterized class.
865 static RawType* NewNonParameterizedType(const Class& type_class); 869 static RawType* NewNonParameterizedType(const Class& type_class);
866 870
867 static RawType* NewParameterizedType( 871 static RawType* NewParameterizedType(
868 const Object& type_class, const TypeArguments& arguments); 872 const Object& type_class, const AbstractTypeArguments& arguments);
869 873
870 static RawType* New(const Object& clazz, 874 static RawType* New(const Object& clazz,
871 const TypeArguments& arguments); 875 const AbstractTypeArguments& arguments);
872 876
873 private: 877 private:
874 void set_type_state(int8_t state) const; 878 void set_type_state(int8_t state) const;
875 879
876 static RawType* New(); 880 static RawType* New();
877 881
878 HEAP_OBJECT_IMPLEMENTATION(Type, AbstractType); 882 HEAP_OBJECT_IMPLEMENTATION(Type, AbstractType);
879 friend class Class; 883 friend class Class;
880 }; 884 };
881 885
882 886
883 // A TypeParameter, in the context of a parameterized class, references a type 887 // A TypeParameter, in the context of a parameterized class, references a type
884 // parameter of a class by its index (and by its name for debugging purposes). 888 // parameter of a class by its index (and by its name for debugging purposes).
885 // For example, the type parameter 'V' is specified as index 1 in the context of 889 // For example, the type parameter 'V' is specified as index 1 in the context of
886 // the class HashMap<K, V>. At compile time, the TypeParameter is not 890 // the class HashMap<K, V>. At compile time, the TypeParameter is not
887 // instantiated yet, i.e. it is only a place holder. 891 // instantiated yet, i.e. it is only a place holder.
888 class TypeParameter : public AbstractType { 892 class TypeParameter : public AbstractType {
889 public: 893 public:
890 virtual bool IsFinalized() const { return true; } 894 virtual bool IsFinalized() const { return true; }
891 virtual bool IsBeingFinalized() const { return false; } 895 virtual bool IsBeingFinalized() const { return false; }
892 virtual bool IsResolved() const { return true; } 896 virtual bool IsResolved() const { return true; }
893 virtual bool HasResolvedTypeClass() const { return false; } 897 virtual bool HasResolvedTypeClass() const { return false; }
894 virtual RawString* Name() const { return raw_ptr()->name_; } 898 virtual RawString* Name() const { return raw_ptr()->name_; }
895 virtual intptr_t Index() const { return raw_ptr()->index_; } 899 virtual intptr_t Index() const { return raw_ptr()->index_; }
896 virtual bool IsInstantiated() const { return false; } 900 virtual bool IsInstantiated() const { return false; }
897 virtual bool Equals(const AbstractType& other) const; 901 virtual bool Equals(const AbstractType& other) const;
898 virtual RawAbstractType* InstantiateFrom( 902 virtual RawAbstractType* InstantiateFrom(
899 const TypeArguments& instantiator_type_arguments, 903 const AbstractTypeArguments& instantiator_type_arguments,
900 intptr_t offset) const; 904 intptr_t offset) const;
901 virtual RawAbstractType* Canonicalize() const { return raw(); } 905 virtual RawAbstractType* Canonicalize() const { return raw(); }
902 906
903 static intptr_t InstanceSize() { 907 static intptr_t InstanceSize() {
904 return RoundedAllocationSize(sizeof(RawTypeParameter)); 908 return RoundedAllocationSize(sizeof(RawTypeParameter));
905 } 909 }
906 910
907 static RawTypeParameter* New(intptr_t index, const String& name); 911 static RawTypeParameter* New(intptr_t index, const String& name);
908 912
909 private: 913 private:
910 void set_index(intptr_t value) const; 914 void set_index(intptr_t value) const;
911 void set_name(const String& value) const; 915 void set_name(const String& value) const;
912 static RawTypeParameter* New(); 916 static RawTypeParameter* New();
913 917
914 HEAP_OBJECT_IMPLEMENTATION(TypeParameter, AbstractType); 918 HEAP_OBJECT_IMPLEMENTATION(TypeParameter, AbstractType);
915 friend class Class; 919 friend class Class;
916 }; 920 };
917 921
918 922
919 // An instance of InstantiatedType is never encountered at compile time, but 923 // An instance of InstantiatedType is never encountered at compile time, but
920 // only at run time, when type parameters can be matched to actual types. 924 // only at run time, when type parameters can be matched to actual types.
921 // An instance of InstantiatedType consists of an uninstantiated AbstractType 925 // An instance of InstantiatedType consists of an uninstantiated AbstractType
922 // object and of a TypeArguments object. The type is uninstantiated, because it 926 // object and of a AbstractTypeArguments object. The type is uninstantiated,
923 // refers to at least one TypeParameter object, i.e. to a type that is not known 927 // because it refers to at least one TypeParameter object, i.e. to a type that
924 // at compile time. 928 // is not known at compile time.
925 // The type argument vector is the instantiator, because each type parameter 929 // The type argument vector is the instantiator, because each type parameter
926 // with index i in the uninstantiated type can be substituted (or 930 // with index i in the uninstantiated type can be substituted (or
927 // "instantiated") with the type at index i in the type argument vector. 931 // "instantiated") with the type at index i in the type argument vector.
928 class InstantiatedType : public AbstractType { 932 class InstantiatedType : public AbstractType {
929 public: 933 public:
930 virtual bool IsFinalized() const { return true; } 934 virtual bool IsFinalized() const { return true; }
931 virtual bool IsBeingFinalized() const { return false; } 935 virtual bool IsBeingFinalized() const { return false; }
932 virtual bool IsResolved() const { return true; } 936 virtual bool IsResolved() const { return true; }
933 virtual bool HasResolvedTypeClass() const { return true; } 937 virtual bool HasResolvedTypeClass() const { return true; }
934 virtual RawClass* type_class() const; 938 virtual RawClass* type_class() const;
935 virtual RawTypeArguments* arguments() const; 939 virtual RawAbstractTypeArguments* arguments() const;
936 virtual bool IsInstantiated() const { return true; } 940 virtual bool IsInstantiated() const { return true; }
937 941
938 RawAbstractType* uninstantiated_type() const { 942 RawAbstractType* uninstantiated_type() const {
939 return raw_ptr()->uninstantiated_type_; 943 return raw_ptr()->uninstantiated_type_;
940 } 944 }
941 RawTypeArguments* instantiator_type_arguments() const { 945 RawAbstractTypeArguments* instantiator_type_arguments() const {
942 return raw_ptr()->instantiator_type_arguments_; 946 return raw_ptr()->instantiator_type_arguments_;
943 } 947 }
944 948
945 static intptr_t InstanceSize() { 949 static intptr_t InstanceSize() {
946 return RoundedAllocationSize(sizeof(RawInstantiatedType)); 950 return RoundedAllocationSize(sizeof(RawInstantiatedType));
947 } 951 }
948 952
949 static RawInstantiatedType* New( 953 static RawInstantiatedType* New(
950 const AbstractType& uninstantiated_type, 954 const AbstractType& uninstantiated_type,
951 const TypeArguments& instantiator_type_arguments); 955 const AbstractTypeArguments& instantiator_type_arguments);
952 956
953 private: 957 private:
954 void set_uninstantiated_type(const AbstractType& value) const; 958 void set_uninstantiated_type(const AbstractType& value) const;
955 void set_instantiator_type_arguments(const TypeArguments& value) const; 959 void set_instantiator_type_arguments(
960 const AbstractTypeArguments& value) const;
956 static RawInstantiatedType* New(); 961 static RawInstantiatedType* New();
957 962
958 HEAP_OBJECT_IMPLEMENTATION(InstantiatedType, AbstractType); 963 HEAP_OBJECT_IMPLEMENTATION(InstantiatedType, AbstractType);
959 friend class Class; 964 friend class Class;
960 }; 965 };
961 966
962 967
963 // TypeArguments is an abstract superclass. 968 // AbstractTypeArguments is an abstract superclass.
964 // Subclasses of TypeArguments are TypeArray and InstantiatedTypes. 969 // Subclasses of AbstractTypeArguments are TypeArguments and InstantiatedTypes.
965 class TypeArguments : public Object { 970 class AbstractTypeArguments : public Object {
966 public: 971 public:
967 static bool AreEqual(const TypeArguments& arguments, 972 static bool AreEqual(const AbstractTypeArguments& arguments,
968 const TypeArguments& other_arguments); 973 const AbstractTypeArguments& other_arguments);
969 974
970 // Return 'this' if this type argument vector is instantiated, i.e. if it does 975 // Return 'this' if this type argument vector is instantiated, i.e. if it does
971 // not refer to type parameters. Otherwise, return a new type argument vector 976 // not refer to type parameters. Otherwise, return a new type argument vector
972 // where each reference to a type parameter is replaced with the corresponding 977 // where each reference to a type parameter is replaced with the corresponding
973 // type of the instantiator type argument vector starting at the given offset. 978 // type of the instantiator type argument vector starting at the given offset.
974 virtual RawTypeArguments* InstantiateFrom( 979 virtual RawAbstractTypeArguments* InstantiateFrom(
975 const TypeArguments& instantiator_type_arguments, 980 const AbstractTypeArguments& instantiator_type_arguments,
976 intptr_t offset) const; 981 intptr_t offset) const;
977 982
978 // Check if this type argument vector consists solely of DynamicType, 983 // Check if this type argument vector consists solely of DynamicType,
979 // considering only a prefix of length 'len'. 984 // considering only a prefix of length 'len'.
980 bool IsDynamicTypes(intptr_t len) const; 985 bool IsDynamicTypes(intptr_t len) const;
981 986
982 // Check the "more specific than" relationship, considering only a prefix of 987 // Check the "more specific than" relationship, considering only a prefix of
983 // length 'len'. 988 // length 'len'.
984 bool IsMoreSpecificThan(const TypeArguments& other, intptr_t len) const; 989 bool IsMoreSpecificThan(
990 const AbstractTypeArguments& other, intptr_t len) const;
985 991
986 static RawTypeArguments* NewTypeArray(intptr_t len); 992 static RawAbstractTypeArguments* NewInstantiatedTypeArguments(
993 const AbstractTypeArguments& uninstantiated_type_arguments,
994 const AbstractTypeArguments& instantiator_type_arguments);
987 995
988 static RawTypeArguments* NewInstantiatedTypeArguments( 996 // UNREACHABLEs as AbstractTypeArguments is an abstract class.
989 const TypeArguments& uninstantiated_type_arguments,
990 const TypeArguments& instantiator_type_arguments);
991
992 // UNREACHABLEs as TypeArguments is an abstract class.
993 virtual intptr_t Length() const; 997 virtual intptr_t Length() const;
994 virtual RawAbstractType* TypeAt(intptr_t index) const; 998 virtual RawAbstractType* TypeAt(intptr_t index) const;
995 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; 999 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const;
996 virtual bool IsResolved() const; 1000 virtual bool IsResolved() const;
997 virtual bool IsInstantiated() const; 1001 virtual bool IsInstantiated() const;
998 virtual bool IsUninstantiatedIdentity() const; 1002 virtual bool IsUninstantiatedIdentity() const;
999 virtual bool Equals(const TypeArguments& other) const; 1003 virtual bool Equals(const AbstractTypeArguments& other) const;
1000 1004
1001 protected: 1005 protected:
1002 HEAP_OBJECT_IMPLEMENTATION(TypeArguments, Object); 1006 HEAP_OBJECT_IMPLEMENTATION(AbstractTypeArguments, Object);
1003 friend class Class; 1007 friend class Class;
1004 }; 1008 };
1005 1009
1006 1010
1007 // A TypeArray is simply an array of Types. 1011 // A TypeArguments is simply an array of Types.
1008 class TypeArray : public TypeArguments { 1012 class TypeArguments : public AbstractTypeArguments {
1009 public: 1013 public:
1010 virtual intptr_t Length() const; 1014 virtual intptr_t Length() const;
1011 virtual RawAbstractType* TypeAt(intptr_t index) const; 1015 virtual RawAbstractType* TypeAt(intptr_t index) const;
1012 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; 1016 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const;
1013 virtual bool IsResolved() const; 1017 virtual bool IsResolved() const;
1014 virtual bool IsInstantiated() const; 1018 virtual bool IsInstantiated() const;
1015 virtual bool IsUninstantiatedIdentity() const; 1019 virtual bool IsUninstantiatedIdentity() const;
1016 virtual bool Equals(const TypeArguments& other) const; 1020 virtual bool Equals(const AbstractTypeArguments& other) const;
1017 1021
1018 virtual RawTypeArguments* InstantiateFrom( 1022 virtual RawAbstractTypeArguments* InstantiateFrom(
1019 const TypeArguments& instantiator_type_arguments, 1023 const AbstractTypeArguments& instantiator_type_arguments,
1020 intptr_t offset) const; 1024 intptr_t offset) const;
1021 1025
1022 static intptr_t length_offset() { return OFFSET_OF(RawTypeArray, length_); } 1026 static intptr_t length_offset() {
1027 return OFFSET_OF(RawTypeArguments, length_);
1028 }
1023 1029
1024 static intptr_t InstanceSize() { 1030 static intptr_t InstanceSize() {
1025 ASSERT(sizeof(RawTypeArray) == OFFSET_OF(RawTypeArray, types_)); 1031 ASSERT(sizeof(RawTypeArguments) == OFFSET_OF(RawTypeArguments, types_));
1026 return 0; 1032 return 0;
1027 } 1033 }
1028 1034
1029 static intptr_t InstanceSize(intptr_t len) { 1035 static intptr_t InstanceSize(intptr_t len) {
1030 // Ensure that the types_ is not adding to the object length. 1036 // Ensure that the types_ is not adding to the object length.
1031 ASSERT(sizeof(RawTypeArray) == 2 * kWordSize); 1037 ASSERT(sizeof(RawTypeArguments) == 2 * kWordSize);
1032 return RoundedAllocationSize(sizeof(RawTypeArray) + (len * kWordSize)); 1038 return RoundedAllocationSize(sizeof(RawTypeArguments) + (len * kWordSize));
1033 } 1039 }
1034 1040
1035 static RawTypeArray* New(intptr_t len); 1041 static RawTypeArguments* New(intptr_t len);
1036 1042
1037 private: 1043 private:
1038 // Make sure that the array size cannot wrap around. 1044 // Make sure that the array size cannot wrap around.
1039 static const intptr_t kMaxTypes = 512 * 1024 * 1024; 1045 static const intptr_t kMaxTypes = 512 * 1024 * 1024;
1040 RawAbstractType** TypeAddr(intptr_t index) const; 1046 RawAbstractType** TypeAddr(intptr_t index) const;
1041 void SetLength(intptr_t value); 1047 void SetLength(intptr_t value);
1042 1048
1043 HEAP_OBJECT_IMPLEMENTATION(TypeArray, TypeArguments); 1049 HEAP_OBJECT_IMPLEMENTATION(TypeArguments, AbstractTypeArguments);
1044 friend class Class; 1050 friend class Class;
1045 }; 1051 };
1046 1052
1047 1053
1048 // An instance of InstantiatedTypeArguments is never encountered at compile 1054 // An instance of InstantiatedTypeArguments is never encountered at compile
1049 // time, but only at run time, when type parameters can be matched to actual 1055 // time, but only at run time, when type parameters can be matched to actual
1050 // types. 1056 // types.
1051 // An instance of InstantiatedTypeArguments consists of a pair of TypeArguments 1057 // An instance of InstantiatedTypeArguments consists of a pair of
1052 // objects. The first type argument vector is uninstantiated, because it 1058 // AbstractTypeArguments objects. The first type argument vector is
1053 // contains type expressions referring to at least one TypeParameter object, 1059 // uninstantiated, because it contains type expressions referring to at least
1054 // i.e. to a type that is not known at compile time. 1060 // one TypeParameter object, i.e. to a type that is not known at compile time.
1055 // The second type argument vector is the instantiator, because each type 1061 // The second type argument vector is the instantiator, because each type
1056 // parameter with index i in the first vector can be substituted (or 1062 // parameter with index i in the first vector can be substituted (or
1057 // "instantiated") with the type at index i in the second type argument vector. 1063 // "instantiated") with the type at index i in the second type argument vector.
1058 class InstantiatedTypeArguments : public TypeArguments { 1064 class InstantiatedTypeArguments : public AbstractTypeArguments {
1059 public: 1065 public:
1060 virtual intptr_t Length() const; 1066 virtual intptr_t Length() const;
1061 virtual RawAbstractType* TypeAt(intptr_t index) const; 1067 virtual RawAbstractType* TypeAt(intptr_t index) const;
1062 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; 1068 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const;
1063 virtual bool IsResolved() const { return true; } 1069 virtual bool IsResolved() const { return true; }
1064 virtual bool IsInstantiated() const { return true; } 1070 virtual bool IsInstantiated() const { return true; }
1065 virtual bool IsUninstantiatedIdentity() const { return false; } 1071 virtual bool IsUninstantiatedIdentity() const { return false; }
1066 1072
1067 RawTypeArguments* uninstantiated_type_arguments() const { 1073 RawAbstractTypeArguments* uninstantiated_type_arguments() const {
1068 return raw_ptr()->uninstantiated_type_arguments_; 1074 return raw_ptr()->uninstantiated_type_arguments_;
1069 } 1075 }
1070 static intptr_t uninstantiated_type_arguments_offset() { 1076 static intptr_t uninstantiated_type_arguments_offset() {
1071 return OFFSET_OF(RawInstantiatedTypeArguments, 1077 return OFFSET_OF(RawInstantiatedTypeArguments,
1072 uninstantiated_type_arguments_); 1078 uninstantiated_type_arguments_);
1073 } 1079 }
1074 1080
1075 RawTypeArguments* instantiator_type_arguments() const { 1081 RawAbstractTypeArguments* instantiator_type_arguments() const {
1076 return raw_ptr()->instantiator_type_arguments_; 1082 return raw_ptr()->instantiator_type_arguments_;
1077 } 1083 }
1078 static intptr_t instantiator_type_arguments_offset() { 1084 static intptr_t instantiator_type_arguments_offset() {
1079 return OFFSET_OF(RawInstantiatedTypeArguments, 1085 return OFFSET_OF(RawInstantiatedTypeArguments,
1080 instantiator_type_arguments_); 1086 instantiator_type_arguments_);
1081 } 1087 }
1082 1088
1083 static intptr_t InstanceSize() { 1089 static intptr_t InstanceSize() {
1084 return RoundedAllocationSize(sizeof(RawInstantiatedTypeArguments)); 1090 return RoundedAllocationSize(sizeof(RawInstantiatedTypeArguments));
1085 } 1091 }
1086 1092
1087 static RawInstantiatedTypeArguments* New( 1093 static RawInstantiatedTypeArguments* New(
1088 const TypeArguments& uninstantiated_type_arguments, 1094 const AbstractTypeArguments& uninstantiated_type_arguments,
1089 const TypeArguments& instantiator_type_arguments); 1095 const AbstractTypeArguments& instantiator_type_arguments);
1090 1096
1091 private: 1097 private:
1092 void set_uninstantiated_type_arguments(const TypeArguments& value) const; 1098 void set_uninstantiated_type_arguments(
1093 void set_instantiator_type_arguments(const TypeArguments& value) const; 1099 const AbstractTypeArguments& value) const;
1100 void set_instantiator_type_arguments(
1101 const AbstractTypeArguments& value) const;
1094 static RawInstantiatedTypeArguments* New(); 1102 static RawInstantiatedTypeArguments* New();
1095 1103
1096 HEAP_OBJECT_IMPLEMENTATION(InstantiatedTypeArguments, TypeArguments); 1104 HEAP_OBJECT_IMPLEMENTATION(InstantiatedTypeArguments, AbstractTypeArguments);
1097 friend class Class; 1105 friend class Class;
1098 }; 1106 };
1099 1107
1100 1108
1101 class Function : public Object { 1109 class Function : public Object {
1102 public: 1110 public:
1103 RawString* name() const { return raw_ptr()->name_; } 1111 RawString* name() const { return raw_ptr()->name_; }
1104 1112
1105 // Build a string of the form '<T, R>(T, [b: B, c: C]) => R' representing the 1113 // Build a string of the form '<T, R>(T, [b: B, c: C]) => R' representing the
1106 // signature of the given function. 1114 // signature of the given function.
1107 RawString* Signature() const { 1115 RawString* Signature() const {
1108 return BuildSignature(false, TypeArguments::Handle(), 0); 1116 return BuildSignature(false, TypeArguments::Handle(), 0);
1109 } 1117 }
1110 1118
1111 // Build a string of the form '(A, [b: B, c: C]) => D' representing the 1119 // Build a string of the form '(A, [b: B, c: C]) => D' representing the
1112 // signature of the given function, where all generic types (e.g. '<T, R>' in 1120 // signature of the given function, where all generic types (e.g. '<T, R>' in
1113 // '<T, R>(T, [b: B, c: C]) => R') are instantiated using the given 1121 // '<T, R>(T, [b: B, c: C]) => R') are instantiated using the given
1114 // instantiator type argument vector (e.g. '<A, D>'). 1122 // instantiator type argument vector (e.g. '<A, D>').
1115 RawString* InstantiatedSignatureFrom(const TypeArguments& instantiator, 1123 RawString* InstantiatedSignatureFrom(
1116 intptr_t offset) const { 1124 const AbstractTypeArguments& instantiator,
1125 intptr_t offset) const {
1117 return BuildSignature(true, instantiator, offset); 1126 return BuildSignature(true, instantiator, offset);
1118 } 1127 }
1119 1128
1120 // Returns true if the signature of this function is instantiated, i.e. if it 1129 // Returns true if the signature of this function is instantiated, i.e. if it
1121 // does not involve generic parameter types or generic result type. 1130 // does not involve generic parameter types or generic result type.
1122 bool HasInstantiatedSignature() const; 1131 bool HasInstantiatedSignature() const;
1123 1132
1124 RawClass* owner() const { return raw_ptr()->owner_; } 1133 RawClass* owner() const { return raw_ptr()->owner_; }
1125 void set_owner(const Class& value) const; 1134 void set_owner(const Class& value) const;
1126 1135
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 // ast printing. The special ':' character, if present, is replaced by '_'. 1237 // ast printing. The special ':' character, if present, is replaced by '_'.
1229 const char* ToFullyQualifiedCString() const; 1238 const char* ToFullyQualifiedCString() const;
1230 1239
1231 // Returns true if this function has parameters that are compatible with the 1240 // Returns true if this function has parameters that are compatible with the
1232 // parameters of the other function in order for this function to override the 1241 // parameters of the other function in order for this function to override the
1233 // other function. Parameter types are ignored. 1242 // other function. Parameter types are ignored.
1234 bool HasCompatibleParametersWith(const Function& other) const; 1243 bool HasCompatibleParametersWith(const Function& other) const;
1235 1244
1236 // Returns true if the type of this function is a subtype of the type of 1245 // Returns true if the type of this function is a subtype of the type of
1237 // the other function. 1246 // the other function.
1238 bool IsSubtypeOf(const TypeArguments& type_arguments, 1247 bool IsSubtypeOf(const AbstractTypeArguments& type_arguments,
1239 const Function& other, 1248 const Function& other,
1240 const TypeArguments& other_type_arguments) const { 1249 const AbstractTypeArguments& other_type_arguments) const {
1241 return TestType(kIsSubtypeOf, 1250 return TestType(kIsSubtypeOf,
1242 type_arguments, 1251 type_arguments,
1243 other, 1252 other,
1244 other_type_arguments); 1253 other_type_arguments);
1245 } 1254 }
1246 1255
1247 // Returns true if the type of this function can be assigned to the type of 1256 // Returns true if the type of this function can be assigned to the type of
1248 // the destination function. 1257 // the destination function.
1249 bool IsAssignableTo(const TypeArguments& type_arguments, 1258 bool IsAssignableTo(const AbstractTypeArguments& type_arguments,
1250 const Function& dst, 1259 const Function& dst,
1251 const TypeArguments& dst_type_arguments) const { 1260 const AbstractTypeArguments& dst_type_arguments) const {
1252 return TestType(kIsAssignableTo, 1261 return TestType(kIsAssignableTo,
1253 type_arguments, 1262 type_arguments,
1254 dst, 1263 dst,
1255 dst_type_arguments); 1264 dst_type_arguments);
1256 } 1265 }
1257 1266
1258 // Returns true if this function represents a (possibly implicit) closure 1267 // Returns true if this function represents a (possibly implicit) closure
1259 // function. 1268 // function.
1260 bool IsClosureFunction() const { 1269 bool IsClosureFunction() const {
1261 return kind() == RawFunction::kClosureFunction; 1270 return kind() == RawFunction::kClosureFunction;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 void set_name(const String& value) const; 1327 void set_name(const String& value) const;
1319 void set_kind(RawFunction::Kind value) const; 1328 void set_kind(RawFunction::Kind value) const;
1320 void set_is_static(bool is_static) const; 1329 void set_is_static(bool is_static) const;
1321 void set_is_const(bool is_const) const; 1330 void set_is_const(bool is_const) const;
1322 void set_parent_function(const Function& value) const; 1331 void set_parent_function(const Function& value) const;
1323 void set_token_index(intptr_t value) const; 1332 void set_token_index(intptr_t value) const;
1324 void set_implicit_closure_function(const Function& value) const; 1333 void set_implicit_closure_function(const Function& value) const;
1325 static RawFunction* New(); 1334 static RawFunction* New();
1326 1335
1327 RawString* BuildSignature(bool instantiate, 1336 RawString* BuildSignature(bool instantiate,
1328 const TypeArguments& instantiator, 1337 const AbstractTypeArguments& instantiator,
1329 intptr_t offset) const; 1338 intptr_t offset) const;
1330 1339
1331 // Checks the subtype or assignability relationship between the type of this 1340 // Checks the subtype or assignability relationship between the type of this
1332 // function and the type of the other function. 1341 // function and the type of the other function.
1333 bool TestType(TypeTestKind test, 1342 bool TestType(TypeTestKind test,
1334 const TypeArguments& type_arguments, 1343 const AbstractTypeArguments& type_arguments,
1335 const Function& other, 1344 const Function& other,
1336 const TypeArguments& other_type_arguments) const; 1345 const AbstractTypeArguments& other_type_arguments) const;
1337 1346
1338 // Checks the type of the formal parameter at the given position for 1347 // Checks the type of the formal parameter at the given position for
1339 // assignability relationship between the type of this function and the type 1348 // assignability relationship between the type of this function and the type
1340 // of the other function. 1349 // of the other function.
1341 bool TestParameterType(intptr_t parameter_position, 1350 bool TestParameterType(
1342 const TypeArguments& type_arguments, 1351 intptr_t parameter_position,
1343 const Function& other, 1352 const AbstractTypeArguments& type_arguments,
1344 const TypeArguments& other_type_arguments) const; 1353 const Function& other,
1354 const AbstractTypeArguments& other_type_arguments) const;
1345 1355
1346 HEAP_OBJECT_IMPLEMENTATION(Function, Object); 1356 HEAP_OBJECT_IMPLEMENTATION(Function, Object);
1347 friend class Class; 1357 friend class Class;
1348 }; 1358 };
1349 1359
1350 1360
1351 class Field : public Object { 1361 class Field : public Object {
1352 public: 1362 public:
1353 RawString* name() const { return raw_ptr()->name_; } 1363 RawString* name() const { return raw_ptr()->name_; }
1354 bool is_static() const { return raw_ptr()->is_static_; } 1364 bool is_static() const { return raw_ptr()->is_static_; }
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 RawObject* GetField(const Field& field) const { 2146 RawObject* GetField(const Field& field) const {
2137 return *FieldAddr(field); 2147 return *FieldAddr(field);
2138 } 2148 }
2139 2149
2140 void SetField(const Field& field, const Object& value) const { 2150 void SetField(const Field& field, const Object& value) const {
2141 *FieldAddr(field) = value.raw(); 2151 *FieldAddr(field) = value.raw();
2142 } 2152 }
2143 2153
2144 RawType* GetType() const; 2154 RawType* GetType() const;
2145 2155
2146 virtual RawTypeArguments* GetTypeArguments() const; 2156 virtual RawAbstractTypeArguments* GetTypeArguments() const;
2147 virtual void SetTypeArguments(const TypeArguments& value) const; 2157 virtual void SetTypeArguments(const AbstractTypeArguments& value) const;
2148 2158
2149 // Check if this instance is an instance of the given type. 2159 // Check if this instance is an instance of the given type.
2150 bool IsInstanceOf(const AbstractType& type, 2160 bool IsInstanceOf(const AbstractType& type,
2151 const TypeArguments& type_instantiator) const { 2161 const AbstractTypeArguments& type_instantiator) const {
2152 return TestType(kIsSubtypeOf, type, type_instantiator); 2162 return TestType(kIsSubtypeOf, type, type_instantiator);
2153 } 2163 }
2154 2164
2155 // Check if this instance is assignable to the given type. 2165 // Check if this instance is assignable to the given type.
2156 bool IsAssignableTo(const AbstractType& type, 2166 bool IsAssignableTo(const AbstractType& type,
2157 const TypeArguments& type_instantiator) const { 2167 const AbstractTypeArguments& type_instantiator) const {
2158 return TestType(kIsAssignableTo, type, type_instantiator); 2168 return TestType(kIsAssignableTo, type, type_instantiator);
2159 } 2169 }
2160 2170
2161 bool IsValidNativeIndex(int index) const; 2171 bool IsValidNativeIndex(int index) const;
2162 2172
2163 intptr_t GetNativeField(int index) const { 2173 intptr_t GetNativeField(int index) const {
2164 return *NativeFieldAddr(index); 2174 return *NativeFieldAddr(index);
2165 } 2175 }
2166 2176
2167 void SetNativeField(int index, intptr_t value) const { 2177 void SetNativeField(int index, intptr_t value) const {
(...skipping 22 matching lines...) Expand all
2190 } 2200 }
2191 void SetFieldAtOffset(intptr_t offset, const Object& value) const { 2201 void SetFieldAtOffset(intptr_t offset, const Object& value) const {
2192 *FieldAddrAtOffset(offset) = value.raw(); 2202 *FieldAddrAtOffset(offset) = value.raw();
2193 } 2203 }
2194 bool IsValidFieldOffset(int offset) const; 2204 bool IsValidFieldOffset(int offset) const;
2195 2205
2196 // Check the subtype or assignability relationship between the type of this 2206 // Check the subtype or assignability relationship between the type of this
2197 // instance and the given type. 2207 // instance and the given type.
2198 bool TestType(TypeTestKind test, 2208 bool TestType(TypeTestKind test,
2199 const AbstractType& type, 2209 const AbstractType& type,
2200 const TypeArguments& type_instantiator) const; 2210 const AbstractTypeArguments& type_instantiator) const;
2201 2211
2202 // TODO(iposva): Determine if this gets in the way of Smi. 2212 // TODO(iposva): Determine if this gets in the way of Smi.
2203 HEAP_OBJECT_IMPLEMENTATION(Instance, Object); 2213 HEAP_OBJECT_IMPLEMENTATION(Instance, Object);
2204 friend class Class; 2214 friend class Class;
2205 }; 2215 };
2206 2216
2207 2217
2208 class Number : public Instance { 2218 class Number : public Instance {
2209 public: 2219 public:
2210 // TODO(iposva): Fill in a useful Number interface. 2220 // TODO(iposva): Fill in a useful Number interface.
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
2880 static intptr_t data_offset() { return length_offset() + kWordSize; } 2890 static intptr_t data_offset() { return length_offset() + kWordSize; }
2881 2891
2882 RawObject* At(intptr_t index) const { 2892 RawObject* At(intptr_t index) const {
2883 return *ObjectAddr(index); 2893 return *ObjectAddr(index);
2884 } 2894 }
2885 void SetAt(intptr_t index, const Object& value) const { 2895 void SetAt(intptr_t index, const Object& value) const {
2886 // TODO(iposva): Add storing NoGCScope. 2896 // TODO(iposva): Add storing NoGCScope.
2887 *ObjectAddr(index) = value.raw(); 2897 *ObjectAddr(index) = value.raw();
2888 } 2898 }
2889 2899
2890 virtual RawTypeArguments* GetTypeArguments() const { 2900 virtual RawAbstractTypeArguments* GetTypeArguments() const {
2891 return raw_ptr()->type_arguments_; 2901 return raw_ptr()->type_arguments_;
2892 } 2902 }
2893 virtual void SetTypeArguments(const TypeArguments& value) const { 2903 virtual void SetTypeArguments(const AbstractTypeArguments& value) const {
2894 raw_ptr()->type_arguments_ = value.raw(); 2904 raw_ptr()->type_arguments_ = value.raw();
2895 } 2905 }
2896 2906
2897 virtual bool Equals(const Instance& other) const; 2907 virtual bool Equals(const Instance& other) const;
2898 2908
2899 static intptr_t type_arguments_offset() { 2909 static intptr_t type_arguments_offset() {
2900 return OFFSET_OF(RawArray, type_arguments_); 2910 return OFFSET_OF(RawArray, type_arguments_);
2901 } 2911 }
2902 2912
2903 static intptr_t InstanceSize() { 2913 static intptr_t InstanceSize() {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
3033 class Closure : public Instance { 3043 class Closure : public Instance {
3034 public: 3044 public:
3035 RawFunction* function() const { return raw_ptr()->function_; } 3045 RawFunction* function() const { return raw_ptr()->function_; }
3036 static intptr_t function_offset() { 3046 static intptr_t function_offset() {
3037 return OFFSET_OF(RawClosure, function_); 3047 return OFFSET_OF(RawClosure, function_);
3038 } 3048 }
3039 3049
3040 RawContext* context() const { return raw_ptr()->context_; } 3050 RawContext* context() const { return raw_ptr()->context_; }
3041 static intptr_t context_offset() { return OFFSET_OF(RawClosure, context_); } 3051 static intptr_t context_offset() { return OFFSET_OF(RawClosure, context_); }
3042 3052
3043 virtual RawTypeArguments* GetTypeArguments() const { 3053 virtual RawAbstractTypeArguments* GetTypeArguments() const {
3044 return raw_ptr()->type_arguments_; 3054 return raw_ptr()->type_arguments_;
3045 } 3055 }
3046 virtual void SetTypeArguments(const TypeArguments& value) const { 3056 virtual void SetTypeArguments(const AbstractTypeArguments& value) const {
3047 raw_ptr()->type_arguments_ = value.raw(); 3057 raw_ptr()->type_arguments_ = value.raw();
3048 } 3058 }
3049 static intptr_t type_arguments_offset() { 3059 static intptr_t type_arguments_offset() {
3050 return OFFSET_OF(RawClosure, type_arguments_); 3060 return OFFSET_OF(RawClosure, type_arguments_);
3051 } 3061 }
3052 3062
3053 // TODO(iposva): Remove smrck support once mapping to arbitrary is available. 3063 // TODO(iposva): Remove smrck support once mapping to arbitrary is available.
3054 RawInteger* smrck() const { return raw_ptr()->smrck_; } 3064 RawInteger* smrck() const { return raw_ptr()->smrck_; }
3055 void set_smrck(const Integer& smrck) const { 3065 void set_smrck(const Integer& smrck) const {
3056 raw_ptr()->smrck_ = smrck.raw(); 3066 raw_ptr()->smrck_ = smrck.raw();
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
3236 } 3246 }
3237 3247
3238 3248
3239 void Context::SetAt(intptr_t index, const Instance& value) const { 3249 void Context::SetAt(intptr_t index, const Instance& value) const {
3240 StorePointer(InstanceAddr(index), value.raw()); 3250 StorePointer(InstanceAddr(index), value.raw());
3241 } 3251 }
3242 3252
3243 } // namespace dart 3253 } // namespace dart
3244 3254
3245 #endif // VM_OBJECT_H_ 3255 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/code_generator_ia32.cc ('k') | runtime/vm/object.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698