| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
| 6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 | 446 |
| 447 ObjectKind instance_kind() const { return raw_ptr()->instance_kind_; } | 447 ObjectKind instance_kind() const { return raw_ptr()->instance_kind_; } |
| 448 void set_instance_kind(ObjectKind value) { | 448 void set_instance_kind(ObjectKind value) { |
| 449 raw_ptr()->instance_kind_ = value; | 449 raw_ptr()->instance_kind_ = value; |
| 450 } | 450 } |
| 451 | 451 |
| 452 RawString* Name() const; | 452 RawString* Name() const; |
| 453 | 453 |
| 454 RawScript* script() const { return raw_ptr()->script_; } | 454 RawScript* script() const { return raw_ptr()->script_; } |
| 455 | 455 |
| 456 intptr_t token_index() const { return raw_ptr()->token_index_; } |
| 457 |
| 456 // This class represents the signature class of a closure function if | 458 // This class represents the signature class of a closure function if |
| 457 // signature_function() is not null. | 459 // signature_function() is not null. |
| 458 // The associated function may be a closure function (with code) or a | 460 // The associated function may be a closure function (with code) or a |
| 459 // signature function (without code) solely describing the result type and | 461 // signature function (without code) solely describing the result type and |
| 460 // parameter types of the signature. | 462 // parameter types of the signature. |
| 461 RawFunction* signature_function() const { | 463 RawFunction* signature_function() const { |
| 462 return raw_ptr()->signature_function_; | 464 return raw_ptr()->signature_function_; |
| 463 } | 465 } |
| 464 static intptr_t signature_function_offset() { | 466 static intptr_t signature_function_offset() { |
| 465 return OFFSET_OF(RawClass, signature_function_); | 467 return OFFSET_OF(RawClass, signature_function_); |
| 466 } | 468 } |
| 467 | 469 |
| 468 // Return the signature type of this signature class. | 470 // Return the signature type of this signature class. |
| 469 // For example, if this class represents a signature of the form | 471 // For example, if this class represents a signature of the form |
| 470 // '<T, R>(T, [b: B, c: C]) => R', then its signature type is a parameterized | 472 // '<T, R>(T, [b: B, c: C]) => R', then its signature type is a parameterized |
| 471 // type with this class as the type class and type parameters 'T' and 'R' | 473 // type with this class as the type class and type parameters 'T' and 'R' |
| 472 // as its type argument vector. | 474 // as its type argument vector. |
| 473 RawType* SignatureType() const; | 475 RawType* SignatureType() const; |
| 474 | 476 |
| 475 RawLibrary* library() const { return raw_ptr()->library_; } | 477 RawLibrary* library() const { return raw_ptr()->library_; } |
| 476 void set_library(const Library& value) const; | 478 void set_library(const Library& value) const; |
| 477 | 479 |
| 478 // The type parameters are specified as an array of Strings. | 480 // The type parameters are specified as an array of Strings. |
| 481 // TODO(regis): Store them as an array of TypeParameter with token_index. |
| 479 RawArray* type_parameters() const { return raw_ptr()->type_parameters_; } | 482 RawArray* type_parameters() const { return raw_ptr()->type_parameters_; } |
| 480 void set_type_parameters(const Array& value) const; | 483 void set_type_parameters(const Array& value) const; |
| 481 intptr_t NumTypeParameters() const; | 484 intptr_t NumTypeParameters() const; |
| 482 | 485 |
| 483 // Type parameters may optionally extend a Type (Dynamic if no extends). | 486 // Type parameters may optionally extend a Type (Dynamic if no extends). |
| 484 // TODO(regis): Should it be Object instead of Dynamic? | 487 // TODO(regis): Should it be Object instead of Dynamic? |
| 485 RawTypeArguments* type_parameter_extends() const { | 488 RawTypeArguments* type_parameter_extends() const { |
| 486 return raw_ptr()->type_parameter_extends_; | 489 return raw_ptr()->type_parameter_extends_; |
| 487 } | 490 } |
| 488 void set_type_parameter_extends(const TypeArguments& value) const; | 491 void set_type_parameter_extends(const TypeArguments& value) const; |
| 489 | 492 |
| 490 // Return a TypeParameter if the type_name is a type parameter of this class. | 493 // Return a TypeParameter if the type_name is a type parameter of this class. |
| 491 // Return null otherwise. | 494 // Return null otherwise. |
| 492 RawTypeParameter* LookupTypeParameter(const String& type_name) const; | 495 RawTypeParameter* LookupTypeParameter(const String& type_name, |
| 496 intptr_t token_index) const; |
| 493 | 497 |
| 494 // The type argument vector is flattened and includes the type arguments of | 498 // The type argument vector is flattened and includes the type arguments of |
| 495 // the super class. | 499 // the super class. |
| 496 bool HasTypeArguments() const; | 500 bool HasTypeArguments() const; |
| 497 intptr_t NumTypeArguments() const; | 501 intptr_t NumTypeArguments() const; |
| 498 | 502 |
| 499 // If this class is parameterized, each instance has a type_arguments field. | 503 // If this class is parameterized, each instance has a type_arguments field. |
| 500 static const intptr_t kNoTypeArguments = -1; | 504 static const intptr_t kNoTypeArguments = -1; |
| 501 intptr_t type_arguments_instance_field_offset() const { | 505 intptr_t type_arguments_instance_field_offset() const { |
| 502 ASSERT(is_finalized() || is_prefinalized()); | 506 ASSERT(is_finalized() || is_prefinalized()); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 | 656 |
| 653 RawArray* constants() const; | 657 RawArray* constants() const; |
| 654 | 658 |
| 655 void Finalize() const; | 659 void Finalize() const; |
| 656 | 660 |
| 657 // Allocate a class used for VM internal objects. | 661 // Allocate a class used for VM internal objects. |
| 658 template <class FakeObject> static RawClass* New(); | 662 template <class FakeObject> static RawClass* New(); |
| 659 | 663 |
| 660 // Allocate an instance class which has a VM implementation. | 664 // Allocate an instance class which has a VM implementation. |
| 661 template <class FakeInstance> static RawClass* New(const String& name, | 665 template <class FakeInstance> static RawClass* New(const String& name, |
| 662 const Script& script); | 666 const Script& script, |
| 667 intptr_t token_index); |
| 663 | 668 |
| 664 // Allocate instance classes and interfaces. | 669 // Allocate instance classes and interfaces. |
| 665 static RawClass* New(const String& name, const Script& script); | 670 static RawClass* New(const String& name, |
| 666 static RawClass* NewInterface(const String& name, const Script& script); | 671 const Script& script, |
| 672 intptr_t token_index); |
| 673 static RawClass* NewInterface(const String& name, |
| 674 const Script& script, |
| 675 intptr_t token_index); |
| 667 static RawClass* NewNativeWrapper(Library* library, | 676 static RawClass* NewNativeWrapper(Library* library, |
| 668 const String& name, | 677 const String& name, |
| 669 int num_fields); | 678 int num_fields); |
| 670 | 679 |
| 671 // Allocate a class representing a function signature described by | 680 // Allocate a class representing a function signature described by |
| 672 // signature_function, which must be a closure function or a signature | 681 // signature_function, which must be a closure function or a signature |
| 673 // function. | 682 // function. |
| 674 // The class may be type parameterized unless the signature_function is in a | 683 // The class may be type parameterized unless the signature_function is in a |
| 675 // static scope. In that case, the type parameters are copied from the owner | 684 // static scope. In that case, the type parameters are copied from the owner |
| 676 // class of signature_function. | 685 // class of signature_function. |
| 677 static RawClass* NewSignatureClass(const String& name, | 686 static RawClass* NewSignatureClass(const String& name, |
| 678 const Function& signature_function, | 687 const Function& signature_function, |
| 679 const Script& script); | 688 const Script& script); |
| 680 | 689 |
| 681 // Return a class object corresponding to the specified kind. If | 690 // Return a class object corresponding to the specified kind. If |
| 682 // a canonicalized version of it exists then that object is returned | 691 // a canonicalized version of it exists then that object is returned |
| 683 // otherwise a new object is allocated and returned. | 692 // otherwise a new object is allocated and returned. |
| 684 static RawClass* GetClass(ObjectKind kind); | 693 static RawClass* GetClass(ObjectKind kind); |
| 685 | 694 |
| 686 private: | 695 private: |
| 687 void set_name(const String& value) const; | 696 void set_name(const String& value) const; |
| 688 void set_script(const Script& value) const; | 697 void set_script(const Script& value) const; |
| 698 void set_token_index(intptr_t value) const; |
| 689 void set_signature_function(const Function& value) const; | 699 void set_signature_function(const Function& value) const; |
| 690 void set_signature_type(const AbstractType& value) const; | 700 void set_signature_type(const AbstractType& value) const; |
| 691 void set_class_state(int8_t state) const; | 701 void set_class_state(int8_t state) const; |
| 692 | 702 |
| 693 void set_constants(const Array& value) const; | 703 void set_constants(const Array& value) const; |
| 694 | 704 |
| 695 void set_canonical_types(const Array& value) const; | 705 void set_canonical_types(const Array& value) const; |
| 696 RawArray* canonical_types() const; | 706 RawArray* canonical_types() const; |
| 697 | 707 |
| 698 void CalculateFieldOffsets() const; | 708 void CalculateFieldOffsets() const; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 RawClass* factory_signature_class() const { | 740 RawClass* factory_signature_class() const { |
| 731 return raw_ptr()->factory_signature_class_; | 741 return raw_ptr()->factory_signature_class_; |
| 732 } | 742 } |
| 733 void set_factory_signature_class(const Class& value) const; | 743 void set_factory_signature_class(const Class& value) const; |
| 734 | 744 |
| 735 RawString* Name() const; | 745 RawString* Name() const; |
| 736 | 746 |
| 737 static intptr_t InstanceSize() { | 747 static intptr_t InstanceSize() { |
| 738 return RoundedAllocationSize(sizeof(RawUnresolvedClass)); | 748 return RoundedAllocationSize(sizeof(RawUnresolvedClass)); |
| 739 } | 749 } |
| 740 static RawUnresolvedClass* New(intptr_t token_index, | 750 static RawUnresolvedClass* New(const LibraryPrefix& library_prefix, |
| 741 const LibraryPrefix& library_prefix, | 751 const String& ident, |
| 742 const String& ident); | 752 intptr_t token_index); |
| 743 | 753 |
| 744 private: | 754 private: |
| 755 void set_library_prefix(const LibraryPrefix& library_prefix) const; |
| 756 void set_ident(const String& ident) const; |
| 745 void set_token_index(intptr_t token_index) const; | 757 void set_token_index(intptr_t token_index) const; |
| 746 void set_ident(const String& ident) const; | |
| 747 void set_library_prefix(const LibraryPrefix& library_prefix) const; | |
| 748 | 758 |
| 749 static RawUnresolvedClass* New(); | 759 static RawUnresolvedClass* New(); |
| 750 | 760 |
| 751 HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass, Object); | 761 HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass, Object); |
| 752 friend class Class; | 762 friend class Class; |
| 753 }; | 763 }; |
| 754 | 764 |
| 755 | 765 |
| 756 // AbstractType is an abstract superclass. | 766 // AbstractType is an abstract superclass. |
| 757 // Subclasses of AbstractType are Type, TypeParameter, and | 767 // Subclasses of AbstractType are Type, TypeParameter, and |
| 758 // InstantiatedType. | 768 // InstantiatedType. |
| 759 // | 769 // |
| 760 // Caution: 'RawAbstractType*' denotes a 'raw' pointer to a VM object of class | 770 // Caution: 'RawAbstractType*' denotes a 'raw' pointer to a VM object of class |
| 761 // AbstractType, as opposed to 'AbstractType' denoting a 'handle' to the same | 771 // AbstractType, as opposed to 'AbstractType' denoting a 'handle' to the same |
| 762 // object. 'RawAbstractType' does not relate to a 'raw type', as opposed to a | 772 // object. 'RawAbstractType' does not relate to a 'raw type', as opposed to a |
| 763 // 'cooked type' or 'rare type'. | 773 // 'cooked type' or 'rare type'. |
| 764 class AbstractType : public Object { | 774 class AbstractType : public Object { |
| 765 public: | 775 public: |
| 766 virtual bool IsFinalized() const; | 776 virtual bool IsFinalized() const; |
| 767 virtual bool IsBeingFinalized() const; | 777 virtual bool IsBeingFinalized() const; |
| 768 virtual bool IsResolved() const; | 778 virtual bool IsResolved() const; |
| 769 virtual bool HasResolvedTypeClass() const; | 779 virtual bool HasResolvedTypeClass() const; |
| 770 virtual RawClass* type_class() const; | 780 virtual RawClass* type_class() const; |
| 771 virtual RawUnresolvedClass* unresolved_class() const; | 781 virtual RawUnresolvedClass* unresolved_class() const; |
| 772 virtual RawAbstractTypeArguments* arguments() const; | 782 virtual RawAbstractTypeArguments* arguments() const; |
| 783 virtual intptr_t token_index() const; |
| 773 virtual bool IsInstantiated() const; | 784 virtual bool IsInstantiated() const; |
| 774 virtual bool Equals(const AbstractType& other) const; | 785 virtual bool Equals(const AbstractType& other) const; |
| 775 | 786 |
| 776 // Instantiate this type using the given type argument vector. | 787 // Instantiate this type using the given type argument vector. |
| 777 // Return a new type, or return 'this' if it is already instantiated. | 788 // Return a new type, or return 'this' if it is already instantiated. |
| 778 virtual RawAbstractType* InstantiateFrom( | 789 virtual RawAbstractType* InstantiateFrom( |
| 779 const AbstractTypeArguments& instantiator_type_arguments) const; | 790 const AbstractTypeArguments& instantiator_type_arguments) const; |
| 780 | 791 |
| 781 // Return the canonical version of this type. | 792 // Return the canonical version of this type. |
| 782 virtual RawAbstractType* Canonicalize() const; | 793 virtual RawAbstractType* Canonicalize() const; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 // Check the subtype relationship. | 853 // Check the subtype relationship. |
| 843 bool IsSubtypeOf(const AbstractType& other) const { | 854 bool IsSubtypeOf(const AbstractType& other) const { |
| 844 return Test(kIsSubtypeOf, other); | 855 return Test(kIsSubtypeOf, other); |
| 845 } | 856 } |
| 846 | 857 |
| 847 // Check the assignability relationship. | 858 // Check the assignability relationship. |
| 848 bool IsAssignableTo(const AbstractType& dst) const { | 859 bool IsAssignableTo(const AbstractType& dst) const { |
| 849 return Test(kIsAssignableTo, dst); | 860 return Test(kIsAssignableTo, dst); |
| 850 } | 861 } |
| 851 | 862 |
| 852 static RawAbstractType* NewTypeParameter(intptr_t index, const String& name); | 863 static RawAbstractType* NewTypeParameter(intptr_t index, |
| 864 const String& name, |
| 865 intptr_t token_index); |
| 853 | 866 |
| 854 static RawAbstractType* NewInstantiatedType( | 867 static RawAbstractType* NewInstantiatedType( |
| 855 const AbstractType& uninstantiated_type, | 868 const AbstractType& uninstantiated_type, |
| 856 const AbstractTypeArguments& instantiator_type_arguments); | 869 const AbstractTypeArguments& instantiator_type_arguments); |
| 857 | 870 |
| 858 protected: | 871 protected: |
| 859 // Check the subtype or assignability relationship. | 872 // Check the subtype or assignability relationship. |
| 860 bool Test(TypeTestKind test, const AbstractType& other) const; | 873 bool Test(TypeTestKind test, const AbstractType& other) const; |
| 861 | 874 |
| 862 HEAP_OBJECT_IMPLEMENTATION(AbstractType, Object); | 875 HEAP_OBJECT_IMPLEMENTATION(AbstractType, Object); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 877 return raw_ptr()->type_state_ == RawType::kBeingFinalized; | 890 return raw_ptr()->type_state_ == RawType::kBeingFinalized; |
| 878 } | 891 } |
| 879 void set_is_being_finalized() const; | 892 void set_is_being_finalized() const; |
| 880 virtual bool IsResolved() const; // Class and all arguments classes resolved. | 893 virtual bool IsResolved() const; // Class and all arguments classes resolved. |
| 881 virtual bool HasResolvedTypeClass() const; // Own type class resolved. | 894 virtual bool HasResolvedTypeClass() const; // Own type class resolved. |
| 882 virtual RawClass* type_class() const; | 895 virtual RawClass* type_class() const; |
| 883 void set_type_class(const Object& value) const; | 896 void set_type_class(const Object& value) const; |
| 884 virtual RawUnresolvedClass* unresolved_class() const; | 897 virtual RawUnresolvedClass* unresolved_class() const; |
| 885 virtual RawAbstractTypeArguments* arguments() const; | 898 virtual RawAbstractTypeArguments* arguments() const; |
| 886 void set_arguments(const AbstractTypeArguments& value) const; | 899 void set_arguments(const AbstractTypeArguments& value) const; |
| 900 virtual intptr_t token_index() const { return raw_ptr()->token_index_; } |
| 887 virtual bool IsInstantiated() const; | 901 virtual bool IsInstantiated() const; |
| 888 virtual bool Equals(const AbstractType& other) const; | 902 virtual bool Equals(const AbstractType& other) const; |
| 889 virtual RawAbstractType* InstantiateFrom( | 903 virtual RawAbstractType* InstantiateFrom( |
| 890 const AbstractTypeArguments& instantiator_type_arguments) const; | 904 const AbstractTypeArguments& instantiator_type_arguments) const; |
| 891 virtual RawAbstractType* Canonicalize() const; | 905 virtual RawAbstractType* Canonicalize() const; |
| 892 | 906 |
| 893 static intptr_t InstanceSize() { | 907 static intptr_t InstanceSize() { |
| 894 return RoundedAllocationSize(sizeof(RawType)); | 908 return RoundedAllocationSize(sizeof(RawType)); |
| 895 } | 909 } |
| 896 | 910 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 923 | 937 |
| 924 // The 'Function' interface type. | 938 // The 'Function' interface type. |
| 925 static RawType* FunctionInterface(); | 939 static RawType* FunctionInterface(); |
| 926 | 940 |
| 927 // The 'List' interface type. | 941 // The 'List' interface type. |
| 928 static RawType* ListInterface(); | 942 static RawType* ListInterface(); |
| 929 | 943 |
| 930 // The least specific valid raw type of the given class. | 944 // The least specific valid raw type of the given class. |
| 931 // For example, type A<Dynamic> would be returned for class A<T>, and type | 945 // For example, type A<Dynamic> would be returned for class A<T>, and type |
| 932 // B<Dynamic, A<Dynamic>> would be returned for B<U, V extends A>. | 946 // B<Dynamic, A<Dynamic>> would be returned for B<U, V extends A>. |
| 933 static RawType* NewRawType(const Class& type_class); | 947 static RawType* NewRawType(const Class& type_class, intptr_t token_index); |
| 934 | 948 |
| 935 // The finalized type of the given non-parameterized class. | 949 // The finalized type of the given non-parameterized class. |
| 936 static RawType* NewNonParameterizedType(const Class& type_class); | 950 static RawType* NewNonParameterizedType(const Class& type_class); |
| 937 | 951 |
| 938 static RawType* New(const Object& clazz, | 952 static RawType* New(const Object& clazz, |
| 939 const AbstractTypeArguments& arguments); | 953 const AbstractTypeArguments& arguments, |
| 954 intptr_t token_index); |
| 940 | 955 |
| 941 private: | 956 private: |
| 957 void set_token_index(intptr_t token_index) const; |
| 942 void set_type_state(int8_t state) const; | 958 void set_type_state(int8_t state) const; |
| 943 | 959 |
| 944 static RawType* New(); | 960 static RawType* New(); |
| 945 | 961 |
| 946 HEAP_OBJECT_IMPLEMENTATION(Type, AbstractType); | 962 HEAP_OBJECT_IMPLEMENTATION(Type, AbstractType); |
| 947 friend class Class; | 963 friend class Class; |
| 948 }; | 964 }; |
| 949 | 965 |
| 950 | 966 |
| 951 // A TypeParameter, in the context of a parameterized class, references a type | 967 // A TypeParameter, in the context of a parameterized class, references a type |
| 952 // parameter of a class by its index (and by its name for debugging purposes). | 968 // parameter of a class by its index (and by its name for debugging purposes). |
| 953 // For example, the type parameter 'V' is specified as index 1 in the context of | 969 // For example, the type parameter 'V' is specified as index 1 in the context of |
| 954 // the class HashMap<K, V>. At compile time, the TypeParameter is not | 970 // the class HashMap<K, V>. At compile time, the TypeParameter is not |
| 955 // instantiated yet, i.e. it is only a place holder. | 971 // instantiated yet, i.e. it is only a place holder. |
| 956 // Upon finalization, the TypeParameter index is changed to reflect its position | 972 // Upon finalization, the TypeParameter index is changed to reflect its position |
| 957 // as type argument (rather than type parameter) of the enclosing class. | 973 // as type argument (rather than type parameter) of the enclosing class. |
| 958 class TypeParameter : public AbstractType { | 974 class TypeParameter : public AbstractType { |
| 959 public: | 975 public: |
| 960 virtual bool IsFinalized() const { | 976 virtual bool IsFinalized() const { |
| 961 return raw_ptr()->type_state_ == RawTypeParameter::kFinalized; | 977 return raw_ptr()->type_state_ == RawTypeParameter::kFinalized; |
| 962 } | 978 } |
| 963 void set_is_finalized() const; | 979 void set_is_finalized() const; |
| 964 virtual bool IsBeingFinalized() const { return false; } | 980 virtual bool IsBeingFinalized() const { return false; } |
| 965 virtual bool IsResolved() const { return true; } | 981 virtual bool IsResolved() const { return true; } |
| 966 virtual bool HasResolvedTypeClass() const { return false; } | 982 virtual bool HasResolvedTypeClass() const { return false; } |
| 967 virtual RawString* Name() const { return raw_ptr()->name_; } | 983 virtual RawString* Name() const { return raw_ptr()->name_; } |
| 968 virtual intptr_t Index() const { return raw_ptr()->index_; } | 984 virtual intptr_t Index() const { return raw_ptr()->index_; } |
| 969 void set_index(intptr_t value) const; | 985 void set_index(intptr_t value) const; |
| 986 virtual intptr_t token_index() const { return raw_ptr()->token_index_; } |
| 970 virtual bool IsInstantiated() const { return false; } | 987 virtual bool IsInstantiated() const { return false; } |
| 971 virtual bool Equals(const AbstractType& other) const; | 988 virtual bool Equals(const AbstractType& other) const; |
| 972 virtual RawAbstractType* InstantiateFrom( | 989 virtual RawAbstractType* InstantiateFrom( |
| 973 const AbstractTypeArguments& instantiator_type_arguments) const; | 990 const AbstractTypeArguments& instantiator_type_arguments) const; |
| 974 virtual RawAbstractType* Canonicalize() const { return raw(); } | 991 virtual RawAbstractType* Canonicalize() const { return raw(); } |
| 975 | 992 |
| 976 static intptr_t InstanceSize() { | 993 static intptr_t InstanceSize() { |
| 977 return RoundedAllocationSize(sizeof(RawTypeParameter)); | 994 return RoundedAllocationSize(sizeof(RawTypeParameter)); |
| 978 } | 995 } |
| 979 | 996 |
| 980 static RawTypeParameter* New(intptr_t index, const String& name); | 997 static RawTypeParameter* New(intptr_t index, |
| 998 const String& name, |
| 999 intptr_t token_index); |
| 981 | 1000 |
| 982 private: | 1001 private: |
| 983 void set_name(const String& value) const; | 1002 void set_name(const String& value) const; |
| 1003 void set_token_index(intptr_t token_index) const; |
| 984 void set_type_state(int8_t state) const; | 1004 void set_type_state(int8_t state) const; |
| 985 static RawTypeParameter* New(); | 1005 static RawTypeParameter* New(); |
| 986 | 1006 |
| 987 HEAP_OBJECT_IMPLEMENTATION(TypeParameter, AbstractType); | 1007 HEAP_OBJECT_IMPLEMENTATION(TypeParameter, AbstractType); |
| 988 friend class Class; | 1008 friend class Class; |
| 989 }; | 1009 }; |
| 990 | 1010 |
| 991 | 1011 |
| 992 // An instance of InstantiatedType is never encountered at compile time, but | 1012 // An instance of InstantiatedType is never encountered at compile time, but |
| 993 // only at run time, when type parameters can be matched to actual types. | 1013 // only at run time, when type parameters can be matched to actual types. |
| 994 // An instance of InstantiatedType consists of an uninstantiated AbstractType | 1014 // An instance of InstantiatedType consists of an uninstantiated AbstractType |
| 995 // object and of a AbstractTypeArguments object. The type is uninstantiated, | 1015 // object and of a AbstractTypeArguments object. The type is uninstantiated, |
| 996 // because it refers to at least one TypeParameter object, i.e. to a type that | 1016 // because it refers to at least one TypeParameter object, i.e. to a type that |
| 997 // is not known at compile time. | 1017 // is not known at compile time. |
| 998 // The type argument vector is the instantiator, because each type parameter | 1018 // The type argument vector is the instantiator, because each type parameter |
| 999 // with index i in the uninstantiated type can be substituted (or | 1019 // with index i in the uninstantiated type can be substituted (or |
| 1000 // "instantiated") with the type at index i in the type argument vector. | 1020 // "instantiated") with the type at index i in the type argument vector. |
| 1001 class InstantiatedType : public AbstractType { | 1021 class InstantiatedType : public AbstractType { |
| 1002 public: | 1022 public: |
| 1003 virtual bool IsFinalized() const { return true; } | 1023 virtual bool IsFinalized() const { return true; } |
| 1004 virtual bool IsBeingFinalized() const { return false; } | 1024 virtual bool IsBeingFinalized() const { return false; } |
| 1005 virtual bool IsResolved() const { return true; } | 1025 virtual bool IsResolved() const { return true; } |
| 1006 virtual bool HasResolvedTypeClass() const { return true; } | 1026 virtual bool HasResolvedTypeClass() const { return true; } |
| 1007 virtual RawClass* type_class() const; | 1027 virtual RawClass* type_class() const; |
| 1008 virtual RawAbstractTypeArguments* arguments() const; | 1028 virtual RawAbstractTypeArguments* arguments() const; |
| 1029 virtual intptr_t token_index() const; |
| 1009 virtual bool IsInstantiated() const { return true; } | 1030 virtual bool IsInstantiated() const { return true; } |
| 1010 | 1031 |
| 1011 RawAbstractType* uninstantiated_type() const { | 1032 RawAbstractType* uninstantiated_type() const { |
| 1012 return raw_ptr()->uninstantiated_type_; | 1033 return raw_ptr()->uninstantiated_type_; |
| 1013 } | 1034 } |
| 1014 RawAbstractTypeArguments* instantiator_type_arguments() const { | 1035 RawAbstractTypeArguments* instantiator_type_arguments() const { |
| 1015 return raw_ptr()->instantiator_type_arguments_; | 1036 return raw_ptr()->instantiator_type_arguments_; |
| 1016 } | 1037 } |
| 1017 | 1038 |
| 1018 static intptr_t InstanceSize() { | 1039 static intptr_t InstanceSize() { |
| (...skipping 2608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3627 } | 3648 } |
| 3628 | 3649 |
| 3629 | 3650 |
| 3630 void Context::SetAt(intptr_t index, const Instance& value) const { | 3651 void Context::SetAt(intptr_t index, const Instance& value) const { |
| 3631 StorePointer(InstanceAddr(index), value.raw()); | 3652 StorePointer(InstanceAddr(index), value.raw()); |
| 3632 } | 3653 } |
| 3633 | 3654 |
| 3634 } // namespace dart | 3655 } // namespace dart |
| 3635 | 3656 |
| 3636 #endif // VM_OBJECT_H_ | 3657 #endif // VM_OBJECT_H_ |
| OLD | NEW |