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