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

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

Issue 8742028: Use ParametrizedType instead of Type where appropriate. Expand ToCString of type related 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
« no previous file with comments | « runtime/vm/code_generator.cc ('k') | runtime/vm/object.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 #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 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 // The name of this type, including the names of its type arguments, if any. 710 // The name of this type, including the names of its type arguments, if any.
711 virtual RawString* Name() const; 711 virtual RawString* Name() const;
712 712
713 // The index of this type parameter. Fail if not a type parameter. 713 // The index of this type parameter. Fail if not a type parameter.
714 virtual intptr_t Index() const; 714 virtual intptr_t Index() const;
715 715
716 // The name of this type's class, i.e. without the type argument names of this 716 // The name of this type's class, i.e. without the type argument names of this
717 // type. 717 // type.
718 RawString* ClassName() const; 718 RawString* ClassName() const;
719 719
720 // Check if this type represents the 'null' type.
721 bool IsNullType() const {
722 return HasResolvedTypeClass() && (type_class() == Object::null_class());
723 }
724
725 // Check if this type represents the 'Dynamic' type. 720 // Check if this type represents the 'Dynamic' type.
726 bool IsDynamicType() const { 721 bool IsDynamicType() const {
727 return HasResolvedTypeClass() && (type_class() == Object::dynamic_class()); 722 return HasResolvedTypeClass() && (type_class() == Object::dynamic_class());
728 } 723 }
729 724
730 // Check if this type represents the 'void' type. 725 // Check if this type represents the 'void' type.
731 bool IsVoidType() const { 726 bool IsVoidType() const {
732 return HasResolvedTypeClass() && (type_class() == Object::void_class()); 727 return HasResolvedTypeClass() && (type_class() == Object::void_class());
733 } 728 }
734 729
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 bool IsSubtypeOf(const Type& other) const { 769 bool IsSubtypeOf(const Type& other) const {
775 return Test(kIsSubtypeOf, other); 770 return Test(kIsSubtypeOf, other);
776 } 771 }
777 772
778 // Check the assignability relationship. 773 // Check the assignability relationship.
779 bool IsAssignableTo(const Type& dst) const { 774 bool IsAssignableTo(const Type& dst) const {
780 return Test(kIsAssignableTo, dst); 775 return Test(kIsAssignableTo, dst);
781 } 776 }
782 777
783 // The type of the literal 'null'. 778 // The type of the literal 'null'.
784 static RawType* NullType(); 779 static RawParameterizedType* NullType();
785 780
786 // The 'Dynamic' type. 781 // The 'Dynamic' type.
787 static RawType* DynamicType(); 782 static RawParameterizedType* DynamicType();
788 783
789 // The 'void' type. 784 // The 'void' type.
790 static RawType* VoidType(); 785 static RawParameterizedType* VoidType();
791 786
792 // The 'Object' type. 787 // The 'Object' type.
793 static RawType* ObjectType(); 788 static RawParameterizedType* ObjectType();
794 789
795 // The 'bool' interface type. 790 // The 'bool' interface type.
796 static RawType* BoolInterface(); 791 static RawParameterizedType* BoolInterface();
797 792
798 // The 'int' interface type. 793 // The 'int' interface type.
799 static RawType* IntInterface(); 794 static RawParameterizedType* IntInterface();
800 795
801 // The 'double' interface type. 796 // The 'double' interface type.
802 static RawType* DoubleInterface(); 797 static RawParameterizedType* DoubleInterface();
803 798
804 // The 'num' interface type. 799 // The 'num' interface type.
805 static RawType* NumberInterface(); 800 static RawParameterizedType* NumberInterface();
806 801
807 // The 'String' interface type. 802 // The 'String' interface type.
808 static RawType* StringInterface(); 803 static RawParameterizedType* StringInterface();
809 804
810 // The 'Function' interface type. 805 // The 'Function' interface type.
811 static RawType* FunctionInterface(); 806 static RawParameterizedType* FunctionInterface();
812 807
813 // The 'List' interface type. 808 // The 'List' interface type.
814 static RawType* ListInterface(); 809 static RawParameterizedType* ListInterface();
815 810
816 // The least specific valid raw type of the given class. 811 // The least specific valid raw type of the given class.
817 // For example, type A<Dynamic> would be returned for class A<T>, and type 812 // For example, type A<Dynamic> would be returned for class A<T>, and type
818 // B<Dynamic, A<Dynamic>> would be returned for B<U, V extends A>. 813 // B<Dynamic, A<Dynamic>> would be returned for B<U, V extends A>.
819 static RawType* NewRawType(const Class& type_class); 814 static RawParameterizedType* NewRawType(const Class& type_class);
820 815
821 // The finalized type of the given non-parameterized class. 816 // The finalized type of the given non-parameterized class.
822 static RawType* NewNonParameterizedType(const Class& type_class); 817 static RawParameterizedType* NewNonParameterizedType(const Class& type_class);
823 818
824 static RawType* NewParameterizedType(const Object& type_class, 819 static RawParameterizedType* NewParameterizedType(
825 const TypeArguments& arguments); 820 const Object& type_class, const TypeArguments& arguments);
826 821
827 static RawType* NewTypeParameter(intptr_t index, const String& name); 822 static RawType* NewTypeParameter(intptr_t index, const String& name);
828 823
829 static RawType* NewInstantiatedType( 824 static RawType* NewInstantiatedType(
830 const Type& uninstantiated_type, 825 const Type& uninstantiated_type,
831 const TypeArguments& instantiator_type_arguments); 826 const TypeArguments& instantiator_type_arguments);
832 827
833 protected: 828 protected:
834 // Check the subtype or assignability relationship. 829 // Check the subtype or assignability relationship.
835 bool Test(TypeTestKind test, const Type& other) const; 830 bool Test(TypeTestKind test, const Type& other) const;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 955
961 HEAP_OBJECT_IMPLEMENTATION(InstantiatedType, Type); 956 HEAP_OBJECT_IMPLEMENTATION(InstantiatedType, Type);
962 friend class Class; 957 friend class Class;
963 }; 958 };
964 959
965 960
966 // TypeArguments is an abstract superclass. 961 // TypeArguments is an abstract superclass.
967 // Subclasses of TypeArguments are TypeArray and InstantiatedTypes. 962 // Subclasses of TypeArguments are TypeArray and InstantiatedTypes.
968 class TypeArguments : public Object { 963 class TypeArguments : public Object {
969 public: 964 public:
970 virtual intptr_t Length() const;
971 virtual RawType* TypeAt(intptr_t index) const;
972 virtual void SetTypeAt(intptr_t index, const Type& value) const;
973 virtual bool IsResolved() const;
974 virtual bool IsInstantiated() const;
975 virtual bool IsUninstantiatedIdentity() const;
976 virtual bool Equals(const TypeArguments& other) const;
977 static bool AreEqual(const TypeArguments& arguments, 965 static bool AreEqual(const TypeArguments& arguments,
978 const TypeArguments& other_arguments); 966 const TypeArguments& other_arguments);
979 967
980 // Return 'this' if this type argument vector is instantiated, i.e. if it does 968 // Return 'this' if this type argument vector is instantiated, i.e. if it does
981 // not refer to type parameters. Otherwise, return a new type argument vector 969 // not refer to type parameters. Otherwise, return a new type argument vector
982 // where each reference to a type parameter is replaced with the corresponding 970 // where each reference to a type parameter is replaced with the corresponding
983 // type of the instantiator type argument vector starting at the given offset. 971 // type of the instantiator type argument vector starting at the given offset.
984 virtual RawTypeArguments* InstantiateFrom( 972 virtual RawTypeArguments* InstantiateFrom(
985 const TypeArguments& instantiator_type_arguments, 973 const TypeArguments& instantiator_type_arguments,
986 intptr_t offset) const; 974 intptr_t offset) const;
987 975
988 // Check if this type argument vector consists solely of DynamicType, 976 // Check if this type argument vector consists solely of DynamicType,
989 // considering only a prefix of length 'len'. 977 // considering only a prefix of length 'len'.
990 bool IsDynamicTypes(intptr_t len) const; 978 bool IsDynamicTypes(intptr_t len) const;
991 979
992 // Check the "more specific than" relationship, considering only a prefix of 980 // Check the "more specific than" relationship, considering only a prefix of
993 // length 'len'. 981 // length 'len'.
994 bool IsMoreSpecificThan(const TypeArguments& other, intptr_t len) const; 982 bool IsMoreSpecificThan(const TypeArguments& other, intptr_t len) const;
995 983
996 static RawTypeArguments* NewTypeArray(intptr_t len); 984 static RawTypeArguments* NewTypeArray(intptr_t len);
997 985
998 static RawTypeArguments* NewInstantiatedTypeArguments( 986 static RawTypeArguments* NewInstantiatedTypeArguments(
999 const TypeArguments& uninstantiated_type_arguments, 987 const TypeArguments& uninstantiated_type_arguments,
1000 const TypeArguments& instantiator_type_arguments); 988 const TypeArguments& instantiator_type_arguments);
1001 989
990 // UNREACHABLEs as TypeArguments is an abstract class.
991 virtual intptr_t Length() const;
992 virtual RawType* TypeAt(intptr_t index) const;
993 virtual void SetTypeAt(intptr_t index, const Type& value) const;
994 virtual bool IsResolved() const;
995 virtual bool IsInstantiated() const;
996 virtual bool IsUninstantiatedIdentity() const;
997 virtual bool Equals(const TypeArguments& other) const;
998
1002 protected: 999 protected:
1003 HEAP_OBJECT_IMPLEMENTATION(TypeArguments, Object); 1000 HEAP_OBJECT_IMPLEMENTATION(TypeArguments, Object);
1004 friend class Class; 1001 friend class Class;
1005 }; 1002 };
1006 1003
1007 1004
1008 // A TypeArray is simply an array of Types. 1005 // A TypeArray is simply an array of Types.
1009 class TypeArray : public TypeArguments { 1006 class TypeArray : public TypeArguments {
1010 public: 1007 public:
1011 virtual intptr_t Length() const; 1008 virtual intptr_t Length() const;
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
2135 virtual RawInstance* Canonicalize() const; 2132 virtual RawInstance* Canonicalize() const;
2136 2133
2137 RawObject* GetField(const Field& field) const { 2134 RawObject* GetField(const Field& field) const {
2138 return *FieldAddr(field); 2135 return *FieldAddr(field);
2139 } 2136 }
2140 2137
2141 void SetField(const Field& field, const Object& value) const { 2138 void SetField(const Field& field, const Object& value) const {
2142 *FieldAddr(field) = value.raw(); 2139 *FieldAddr(field) = value.raw();
2143 } 2140 }
2144 2141
2145 RawType* GetType() const; 2142 RawParameterizedType* GetType() const;
2146 2143
2147 virtual RawTypeArguments* GetTypeArguments() const; 2144 virtual RawTypeArguments* GetTypeArguments() const;
2148 virtual void SetTypeArguments(const TypeArguments& value) const; 2145 virtual void SetTypeArguments(const TypeArguments& value) const;
2149 2146
2150 // Check if this instance is an instance of the given type. 2147 // Check if this instance is an instance of the given type.
2151 bool IsInstanceOf(const Type& type, 2148 bool IsInstanceOf(const Type& type,
2152 const TypeArguments& type_instantiator) const { 2149 const TypeArguments& type_instantiator) const {
2153 return TestType(kIsSubtypeOf, type, type_instantiator); 2150 return TestType(kIsSubtypeOf, type, type_instantiator);
2154 } 2151 }
2155 2152
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after
3237 } 3234 }
3238 3235
3239 3236
3240 void Context::SetAt(intptr_t index, const Instance& value) const { 3237 void Context::SetAt(intptr_t index, const Instance& value) const {
3241 StorePointer(InstanceAddr(index), value.raw()); 3238 StorePointer(InstanceAddr(index), value.raw());
3242 } 3239 }
3243 3240
3244 } // namespace dart 3241 } // namespace dart
3245 3242
3246 #endif // VM_OBJECT_H_ 3243 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/code_generator.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698