Chromium Code Reviews| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 // Index for Singleton internal VM classes, | 114 // Index for Singleton internal VM classes, |
| 115 // this index is used in snapshots to refer to these classes directly. | 115 // this index is used in snapshots to refer to these classes directly. |
| 116 enum { | 116 enum { |
| 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 kParameterizedTypeClass, | 124 kTypeClass, |
| 125 kTypeParameterClass, | 125 kTypeParameterClass, |
| 126 kInstantiatedTypeClass, | 126 kInstantiatedTypeClass, |
| 127 kTypeArgumentsClass, | 127 kTypeArgumentsClass, |
| 128 kTypeArrayClass, | 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, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 static RawInstance* sentinel() { return sentinel_; } | 206 static RawInstance* sentinel() { return sentinel_; } |
| 207 // Value marking that we are transitioning from sentinel, e.g., computing | 207 // Value marking that we are transitioning from sentinel, e.g., computing |
| 208 // a field value. Used to detect circular initialization. | 208 // a field value. Used to detect circular initialization. |
| 209 static RawInstance* transition_sentinel() { return transition_sentinel_; } | 209 static RawInstance* transition_sentinel() { return transition_sentinel_; } |
| 210 | 210 |
| 211 static RawClass* class_class() { return class_class_; } | 211 static RawClass* class_class() { return class_class_; } |
| 212 static RawClass* null_class() { return null_class_; } | 212 static RawClass* null_class() { return null_class_; } |
| 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* parameterized_type_class() { | 216 static RawClass* type_class() { |
| 217 return parameterized_type_class_; | 217 return type_class_; |
| 218 } | 218 } |
| 219 static RawClass* type_parameter_class() { return type_parameter_class_; } | 219 static RawClass* type_parameter_class() { return type_parameter_class_; } |
| 220 static RawClass* instantiated_type_class() { | 220 static RawClass* instantiated_type_class() { |
| 221 return instantiated_type_class_; | 221 return instantiated_type_class_; |
| 222 } | 222 } |
| 223 static RawClass* type_arguments_class() { return type_arguments_class_; } | 223 static RawClass* type_arguments_class() { return type_arguments_class_; } |
| 224 static RawClass* type_array_class() { return type_array_class_; } | 224 static RawClass* type_array_class() { return type_array_class_; } |
| 225 static RawClass* instantiated_type_arguments_class() { | 225 static RawClass* instantiated_type_arguments_class() { |
| 226 return instantiated_type_arguments_class_; | 226 return instantiated_type_arguments_class_; |
| 227 } | 227 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_. | 315 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_. |
| 316 static RawObject* null_; | 316 static RawObject* null_; |
| 317 static RawInstance* sentinel_; | 317 static RawInstance* sentinel_; |
| 318 static RawInstance* transition_sentinel_; | 318 static RawInstance* transition_sentinel_; |
| 319 | 319 |
| 320 static RawClass* class_class_; // Class of the Class vm object. | 320 static RawClass* class_class_; // Class of the Class vm object. |
| 321 static RawClass* null_class_; // Class of the null object. | 321 static RawClass* null_class_; // Class of the null object. |
| 322 static RawClass* dynamic_class_; // Class of the 'Dynamic' type. | 322 static RawClass* dynamic_class_; // Class of the 'Dynamic' type. |
| 323 static RawClass* void_class_; // Class of the 'void' type. | 323 static RawClass* void_class_; // Class of the 'void' type. |
| 324 static RawClass* unresolved_class_class_; // Class of UnresolvedClass. | 324 static RawClass* unresolved_class_class_; // Class of UnresolvedClass. |
| 325 static RawClass* parameterized_type_class_; // Class of ParameterizedType. | 325 static RawClass* type_class_; // Class of Type. |
| 326 static RawClass* type_parameter_class_; // Class of TypeParameter vm object. | 326 static RawClass* type_parameter_class_; // Class of TypeParameter vm object. |
| 327 static RawClass* instantiated_type_class_; // Class of InstantiatedType. | 327 static RawClass* instantiated_type_class_; // Class of InstantiatedType. |
| 328 static RawClass* type_arguments_class_; // Class of TypeArguments vm object. | 328 static RawClass* type_arguments_class_; // Class of TypeArguments vm object. |
| 329 static RawClass* type_array_class_; // Class of the TypeArray vm object. | 329 static RawClass* type_array_class_; // Class of the TypeArray vm object. |
| 330 static RawClass* instantiated_type_arguments_class_; // Class of Inst..ments. | 330 static RawClass* instantiated_type_arguments_class_; // Class of Inst..ments. |
| 331 static RawClass* function_class_; // Class of the Function vm object. | 331 static RawClass* function_class_; // Class of the Function vm object. |
| 332 static RawClass* field_class_; // Class of the Field vm object. | 332 static RawClass* field_class_; // Class of the Field vm object. |
| 333 static RawClass* token_stream_class_; // Class of the TokenStream vm object. | 333 static RawClass* token_stream_class_; // Class of the TokenStream vm object. |
| 334 static RawClass* script_class_; // Class of the Script vm object. | 334 static RawClass* script_class_; // Class of the Script vm object. |
| 335 static RawClass* library_class_; // Class of the Library vm object. | 335 static RawClass* library_class_; // Class of the Library vm object. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 } | 401 } |
| 402 static intptr_t signature_function_offset() { | 402 static intptr_t signature_function_offset() { |
| 403 return OFFSET_OF(RawClass, signature_function_); | 403 return OFFSET_OF(RawClass, signature_function_); |
| 404 } | 404 } |
| 405 | 405 |
| 406 // Return the signature type of this signature class. | 406 // Return the signature type of this signature class. |
| 407 // For example, if this class represents a signature of the form | 407 // For example, if this class represents a signature of the form |
| 408 // '<T, R>(T, [b: B, c: C]) => R', then its signature type is a parameterized | 408 // '<T, R>(T, [b: B, c: C]) => R', then its signature type is a parameterized |
| 409 // type with this class as the type class and type parameters 'T' and 'R' | 409 // type with this class as the type class and type parameters 'T' and 'R' |
| 410 // as its type argument vector. | 410 // as its type argument vector. |
| 411 RawType* SignatureType() const; | 411 RawAbstractType* SignatureType() const; |
|
regis
2011/12/01 04:24:07
A signature type is always a Type based on a signa
srdjan
2011/12/01 17:48:42
Done in next CL.
| |
| 412 | 412 |
| 413 RawLibrary* library() const { return raw_ptr()->library_; } | 413 RawLibrary* library() const { return raw_ptr()->library_; } |
| 414 void set_library(const Library& value) const; | 414 void set_library(const Library& value) const; |
| 415 | 415 |
| 416 // The type parameters are specified as an array of Strings. | 416 // The type parameters are specified as an array of Strings. |
| 417 RawArray* type_parameters() const { return raw_ptr()->type_parameters_; } | 417 RawArray* type_parameters() const { return raw_ptr()->type_parameters_; } |
| 418 void set_type_parameters(const Array& value) const; | 418 void set_type_parameters(const Array& value) const; |
| 419 intptr_t NumTypeParameters() const; | 419 intptr_t NumTypeParameters() const; |
| 420 | 420 |
| 421 // Type parameters may optionally extend a Type (Dynamic if no extends). | 421 // Type parameters may optionally extend a Type (Dynamic if no extends). |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 438 static const intptr_t kNoTypeArguments = -1; | 438 static const intptr_t kNoTypeArguments = -1; |
| 439 intptr_t type_arguments_instance_field_offset() const { | 439 intptr_t type_arguments_instance_field_offset() const { |
| 440 ASSERT(is_finalized() || is_prefinalized()); | 440 ASSERT(is_finalized() || is_prefinalized()); |
| 441 return raw_ptr()->type_arguments_instance_field_offset_; | 441 return raw_ptr()->type_arguments_instance_field_offset_; |
| 442 } | 442 } |
| 443 void set_type_arguments_instance_field_offset(intptr_t value) const { | 443 void set_type_arguments_instance_field_offset(intptr_t value) const { |
| 444 raw_ptr()->type_arguments_instance_field_offset_ = value; | 444 raw_ptr()->type_arguments_instance_field_offset_ = value; |
| 445 } | 445 } |
| 446 | 446 |
| 447 // The super type of this class, Object type if not explicitly specified. | 447 // The super type of this class, Object type if not explicitly specified. |
| 448 RawType* super_type() const { return raw_ptr()->super_type_; } | 448 RawAbstractType* super_type() const { return raw_ptr()->super_type_; } |
| 449 void set_super_type(const Type& value) const; | 449 void set_super_type(const AbstractType& value) const; |
|
regis
2011/12/01 04:24:07
A super type is always a Type based on a class kno
srdjan
2011/12/01 17:48:42
Done in next CL.
| |
| 450 | 450 |
| 451 // Asserts that the class of the super type has been resolved. | 451 // Asserts that the class of the super type has been resolved. |
| 452 RawClass* SuperClass() const; | 452 RawClass* SuperClass() const; |
| 453 | 453 |
| 454 // Return true if this interface has a factory class. | 454 // Return true if this interface has a factory class. |
| 455 bool HasFactoryClass() const; | 455 bool HasFactoryClass() const; |
| 456 | 456 |
| 457 // Return true if the factory class of this interface is resolved. | 457 // Return true if the factory class of this interface is resolved. |
| 458 bool HasResolvedFactoryClass() const; | 458 bool HasResolvedFactoryClass() const; |
| 459 | 459 |
| 460 // Return the resolved factory class of this interface. | 460 // Return the resolved factory class of this interface. |
| 461 RawClass* FactoryClass() const; | 461 RawClass* FactoryClass() const; |
| 462 | 462 |
| 463 // Return the unresolved factory class of this interface. | 463 // Return the unresolved factory class of this interface. |
| 464 RawUnresolvedClass* UnresolvedFactoryClass() const; | 464 RawUnresolvedClass* UnresolvedFactoryClass() const; |
| 465 | 465 |
| 466 // Set the resolved or unresolved factory class of this interface. | 466 // Set the resolved or unresolved factory class of this interface. |
| 467 void set_factory_class(const Object& value) const; | 467 void set_factory_class(const Object& value) const; |
| 468 | 468 |
| 469 // Interfaces is an array of Types. | 469 // Interfaces is an array of Types. |
| 470 RawArray* interfaces() const { return raw_ptr()->interfaces_; } | 470 RawArray* interfaces() const { return raw_ptr()->interfaces_; } |
|
regis
2011/12/01 04:24:07
We could maybe change this to return a TypeArgumen
srdjan
2011/12/01 17:48:42
Added TODO
| |
| 471 void set_interfaces(const Array& value) const; | 471 void set_interfaces(const Array& value) const; |
| 472 | 472 |
| 473 RawArray* functions_cache() const { return raw_ptr()->functions_cache_; } | 473 RawArray* functions_cache() const { return raw_ptr()->functions_cache_; } |
| 474 void set_functions_cache(const Array& value) const; | 474 void set_functions_cache(const Array& value) const; |
| 475 | 475 |
| 476 static intptr_t functions_cache_offset() { | 476 static intptr_t functions_cache_offset() { |
| 477 return OFFSET_OF(RawClass, functions_cache_); | 477 return OFFSET_OF(RawClass, functions_cache_); |
| 478 } | 478 } |
| 479 | 479 |
| 480 // Check if this class represents the class of null. | 480 // Check if this class represents the class of null. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 610 | 610 |
| 611 // Return a class object corresponding to the specified kind. If | 611 // Return a class object corresponding to the specified kind. If |
| 612 // a canonicalized version of it exists then that object is returned | 612 // a canonicalized version of it exists then that object is returned |
| 613 // otherwise a new object is allocated and returned. | 613 // otherwise a new object is allocated and returned. |
| 614 static RawClass* GetClass(ObjectKind kind); | 614 static RawClass* GetClass(ObjectKind kind); |
| 615 | 615 |
| 616 private: | 616 private: |
| 617 void set_name(const String& value) const; | 617 void set_name(const String& value) const; |
| 618 void set_script(const Script& value) const; | 618 void set_script(const Script& value) const; |
| 619 void set_signature_function(const Function& value) const; | 619 void set_signature_function(const Function& value) const; |
| 620 void set_signature_type(const Type& value) const; | 620 void set_signature_type(const AbstractType& value) const; |
| 621 void set_class_state(int8_t state) const; | 621 void set_class_state(int8_t state) const; |
| 622 | 622 |
| 623 void set_constants(const Array& value) const; | 623 void set_constants(const Array& value) const; |
| 624 RawArray* constants() const; | 624 RawArray* constants() const; |
| 625 | 625 |
| 626 void set_canonical_types(const Array& value) const; | 626 void set_canonical_types(const Array& value) const; |
| 627 RawArray* canonical_types() const; | 627 RawArray* canonical_types() const; |
| 628 | 628 |
| 629 void CalculateFieldOffsets() const; | 629 void CalculateFieldOffsets() const; |
| 630 | 630 |
| 631 // Check the subtype or assignability relationship. | 631 // Check the subtype or assignability relationship. |
| 632 bool TestType(TypeTestKind test, | 632 bool TestType(TypeTestKind test, |
| 633 const TypeArguments& type_arguments, | 633 const TypeArguments& type_arguments, |
| 634 const Class& other, | 634 const Class& other, |
| 635 const TypeArguments& other_type_arguments) const; | 635 const TypeArguments& other_type_arguments) const; |
| 636 | 636 |
| 637 // Assigns empty array to all raw class array fields. | 637 // Assigns empty array to all raw class array fields. |
| 638 void InitEmptyFields(); | 638 void InitEmptyFields(); |
| 639 | 639 |
| 640 HEAP_OBJECT_IMPLEMENTATION(Class, Object); | 640 HEAP_OBJECT_IMPLEMENTATION(Class, Object); |
| 641 friend class Object; | 641 friend class Object; |
| 642 friend class Instance; | 642 friend class Instance; |
| 643 friend class ParameterizedType; | 643 friend class Type; |
| 644 }; | 644 }; |
| 645 | 645 |
| 646 | 646 |
| 647 // Unresolved class is used for storing unresolved names which will be resolved | 647 // Unresolved class is used for storing unresolved names which will be resolved |
| 648 // to a class after all classes have been loaded and finalized. | 648 // to a class after all classes have been loaded and finalized. |
| 649 class UnresolvedClass : public Object { | 649 class UnresolvedClass : public Object { |
| 650 public: | 650 public: |
| 651 RawString* qualifier() const { return raw_ptr()->qualifier_; } | 651 RawString* qualifier() const { return raw_ptr()->qualifier_; } |
| 652 RawString* ident() const { return raw_ptr()->ident_; } | 652 RawString* ident() const { return raw_ptr()->ident_; } |
| 653 intptr_t token_index() const { return raw_ptr()->token_index_; } | 653 intptr_t token_index() const { return raw_ptr()->token_index_; } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 671 void set_ident(const String& ident) const; | 671 void set_ident(const String& ident) const; |
| 672 void set_qualifier(const String& qualifier) const; | 672 void set_qualifier(const String& qualifier) const; |
| 673 | 673 |
| 674 static RawUnresolvedClass* New(); | 674 static RawUnresolvedClass* New(); |
| 675 | 675 |
| 676 HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass, Object); | 676 HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass, Object); |
| 677 friend class Class; | 677 friend class Class; |
| 678 }; | 678 }; |
| 679 | 679 |
| 680 | 680 |
| 681 // Type is an abstract superclass. | 681 // AbstractType is an abstract superclass. |
| 682 // Subclasses of Type are ParameterizedType, TypeParameter, and | 682 // Subclasses of AbstractType are Type, TypeParameter, and |
| 683 // InstantiatedType. | 683 // InstantiatedType. |
| 684 // | 684 // |
| 685 // Caution: 'RawType*' denotes a 'raw' pointer to a VM object of class Type, | 685 // Caution: 'RawAbstractType*' denotes a 'raw' pointer to a VM object of class |
| 686 // as opposed to 'Type' denoting a 'handle' to the same object. 'RawType' does | 686 // AbstractType, as opposed to 'AbstractType' denoting a 'handle' to the same |
| 687 // not relate to a 'raw type', as opposed to a 'cooked type' or 'rare type'. | 687 // object. 'RawAbstractType' does not relate to a 'raw type', as opposed to a |
| 688 class Type : public Object { | 688 // 'cooked type' or 'rare type'. |
| 689 class AbstractType : public Object { | |
| 689 public: | 690 public: |
| 690 virtual bool IsFinalized() const; | 691 virtual bool IsFinalized() const; |
| 691 virtual bool IsBeingFinalized() const; | 692 virtual bool IsBeingFinalized() const; |
| 692 virtual bool IsResolved() const; | 693 virtual bool IsResolved() const; |
| 693 virtual bool HasResolvedTypeClass() const; | 694 virtual bool HasResolvedTypeClass() const; |
| 694 virtual RawClass* type_class() const; | 695 virtual RawClass* type_class() const; |
| 695 virtual RawUnresolvedClass* unresolved_class() const; | 696 virtual RawUnresolvedClass* unresolved_class() const; |
| 696 virtual RawTypeArguments* arguments() const; | 697 virtual RawTypeArguments* arguments() const; |
| 697 virtual bool IsInstantiated() const; | 698 virtual bool IsInstantiated() const; |
| 698 virtual bool Equals(const Type& other) const; | 699 virtual bool Equals(const AbstractType& other) const; |
| 699 | 700 |
| 700 // Instantiate this type using the given type argument vector starting at the | 701 // Instantiate this type using the given type argument vector starting at the |
| 701 // given offset. | 702 // given offset. |
| 702 // Return a new type, or return 'this' if it is already instantiated. | 703 // Return a new type, or return 'this' if it is already instantiated. |
| 703 virtual RawType* InstantiateFrom( | 704 virtual RawAbstractType* InstantiateFrom( |
| 704 const TypeArguments& instantiator_type_arguments, | 705 const TypeArguments& instantiator_type_arguments, |
| 705 intptr_t offset) const; | 706 intptr_t offset) const; |
| 706 | 707 |
| 707 // Return the canonical version of this type. | 708 // Return the canonical version of this type. |
| 708 virtual RawType* Canonicalize() const; | 709 virtual RawAbstractType* Canonicalize() const; |
| 709 | 710 |
| 710 // The name of this type, including the names of its type arguments, if any. | 711 // The name of this type, including the names of its type arguments, if any. |
| 711 virtual RawString* Name() const; | 712 virtual RawString* Name() const; |
| 712 | 713 |
| 713 // The index of this type parameter. Fail if not a type parameter. | 714 // The index of this type parameter. Fail if not a type parameter. |
| 714 virtual intptr_t Index() const; | 715 virtual intptr_t Index() const; |
| 715 | 716 |
| 716 // The name of this type's class, i.e. without the type argument names of this | 717 // The name of this type's class, i.e. without the type argument names of this |
| 717 // type. | 718 // type. |
| 718 RawString* ClassName() const; | 719 RawString* ClassName() const; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 756 // Check if this type is an interface type. | 757 // Check if this type is an interface type. |
| 757 bool IsInterfaceType() const { | 758 bool IsInterfaceType() const { |
| 758 if (!HasResolvedTypeClass()) { | 759 if (!HasResolvedTypeClass()) { |
| 759 return false; | 760 return false; |
| 760 } | 761 } |
| 761 const Class& cls = Class::Handle(type_class()); | 762 const Class& cls = Class::Handle(type_class()); |
| 762 return !cls.IsNull() && cls.is_interface(); | 763 return !cls.IsNull() && cls.is_interface(); |
| 763 } | 764 } |
| 764 | 765 |
| 765 // Check the "more specific than" relationship. | 766 // Check the "more specific than" relationship. |
| 766 bool IsMoreSpecificThan(const Type& other) const; | 767 bool IsMoreSpecificThan(const AbstractType& other) const; |
| 767 | 768 |
| 768 // Check the subtype relationship. | 769 // Check the subtype relationship. |
| 769 bool IsSubtypeOf(const Type& other) const { | 770 bool IsSubtypeOf(const AbstractType& other) const { |
| 770 return Test(kIsSubtypeOf, other); | 771 return Test(kIsSubtypeOf, other); |
| 771 } | 772 } |
| 772 | 773 |
| 773 // Check the assignability relationship. | 774 // Check the assignability relationship. |
| 774 bool IsAssignableTo(const Type& dst) const { | 775 bool IsAssignableTo(const AbstractType& dst) const { |
| 775 return Test(kIsAssignableTo, dst); | 776 return Test(kIsAssignableTo, dst); |
| 776 } | 777 } |
| 777 | 778 |
| 778 // The type of the literal 'null'. | 779 static RawAbstractType* NewTypeParameter(intptr_t index, const String& name); |
| 779 static RawParameterizedType* NullType(); | |
| 780 | 780 |
| 781 // The 'Dynamic' type. | 781 static RawAbstractType* NewInstantiatedType( |
| 782 static RawParameterizedType* DynamicType(); | 782 const AbstractType& uninstantiated_type, |
| 783 | |
| 784 // The 'void' type. | |
| 785 static RawParameterizedType* VoidType(); | |
| 786 | |
| 787 // The 'Object' type. | |
| 788 static RawParameterizedType* ObjectType(); | |
| 789 | |
| 790 // The 'bool' interface type. | |
| 791 static RawParameterizedType* BoolInterface(); | |
| 792 | |
| 793 // The 'int' interface type. | |
| 794 static RawParameterizedType* IntInterface(); | |
| 795 | |
| 796 // The 'double' interface type. | |
| 797 static RawParameterizedType* DoubleInterface(); | |
| 798 | |
| 799 // The 'num' interface type. | |
| 800 static RawParameterizedType* NumberInterface(); | |
| 801 | |
| 802 // The 'String' interface type. | |
| 803 static RawParameterizedType* StringInterface(); | |
| 804 | |
| 805 // The 'Function' interface type. | |
| 806 static RawParameterizedType* FunctionInterface(); | |
| 807 | |
| 808 // The 'List' interface type. | |
| 809 static RawParameterizedType* ListInterface(); | |
| 810 | |
| 811 // The least specific valid raw type of the given class. | |
| 812 // For example, type A<Dynamic> would be returned for class A<T>, and type | |
| 813 // B<Dynamic, A<Dynamic>> would be returned for B<U, V extends A>. | |
| 814 static RawParameterizedType* NewRawType(const Class& type_class); | |
| 815 | |
| 816 // The finalized type of the given non-parameterized class. | |
| 817 static RawParameterizedType* NewNonParameterizedType(const Class& type_class); | |
| 818 | |
| 819 static RawParameterizedType* NewParameterizedType( | |
| 820 const Object& type_class, const TypeArguments& arguments); | |
| 821 | |
| 822 static RawType* NewTypeParameter(intptr_t index, const String& name); | |
| 823 | |
| 824 static RawType* NewInstantiatedType( | |
| 825 const Type& uninstantiated_type, | |
| 826 const TypeArguments& instantiator_type_arguments); | 783 const TypeArguments& instantiator_type_arguments); |
| 827 | 784 |
| 828 protected: | 785 protected: |
| 829 // Check the subtype or assignability relationship. | 786 // Check the subtype or assignability relationship. |
| 830 bool Test(TypeTestKind test, const Type& other) const; | 787 bool Test(TypeTestKind test, const AbstractType& other) const; |
| 831 | 788 |
| 832 HEAP_OBJECT_IMPLEMENTATION(Type, Object); | 789 HEAP_OBJECT_IMPLEMENTATION(AbstractType, Object); |
| 833 friend class Class; | 790 friend class Class; |
| 834 }; | 791 }; |
| 835 | 792 |
| 836 | 793 |
| 837 // A ParameterizedType consists of a class, possibly parameterized with type | 794 // A Type consists of a class, possibly parameterized with type |
| 838 // arguments. Example: C<T1, T2>. | 795 // arguments. Example: C<T1, T2>. |
| 839 // An unresolved class is a String specifying the class name. | 796 // An unresolved class is a String specifying the class name. |
| 840 class ParameterizedType : public Type { | 797 class Type : public AbstractType { |
| 841 public: | 798 public: |
| 842 virtual bool IsFinalized() const { | 799 virtual bool IsFinalized() const { |
| 843 return raw_ptr()->type_state_ == RawParameterizedType::kFinalized; | 800 return raw_ptr()->type_state_ == RawType::kFinalized; |
| 844 } | 801 } |
| 845 void set_is_finalized() const; | 802 void set_is_finalized() const; |
| 846 virtual bool IsBeingFinalized() const { | 803 virtual bool IsBeingFinalized() const { |
| 847 return raw_ptr()->type_state_ == RawParameterizedType::kBeingFinalized; | 804 return raw_ptr()->type_state_ == RawType::kBeingFinalized; |
| 848 } | 805 } |
| 849 void set_is_being_finalized() const; | 806 void set_is_being_finalized() const; |
| 850 virtual bool IsResolved() const; // Class and all arguments classes resolved. | 807 virtual bool IsResolved() const; // Class and all arguments classes resolved. |
| 851 virtual bool HasResolvedTypeClass() const; // Own type class resolved. | 808 virtual bool HasResolvedTypeClass() const; // Own type class resolved. |
| 852 virtual RawClass* type_class() const; | 809 virtual RawClass* type_class() const; |
| 853 void set_type_class(const Object& value) const; | 810 void set_type_class(const Object& value) const; |
| 854 virtual RawUnresolvedClass* unresolved_class() const; | 811 virtual RawUnresolvedClass* unresolved_class() const; |
| 855 virtual RawTypeArguments* arguments() const; | 812 virtual RawTypeArguments* arguments() const; |
| 856 void set_arguments(const TypeArguments& value) const; | 813 void set_arguments(const TypeArguments& value) const; |
| 857 virtual bool IsInstantiated() const; | 814 virtual bool IsInstantiated() const; |
| 858 virtual bool Equals(const Type& other) const; | 815 virtual bool Equals(const AbstractType& other) const; |
| 859 virtual RawType* InstantiateFrom( | 816 virtual RawAbstractType* InstantiateFrom( |
| 860 const TypeArguments& instantiator_type_arguments, | 817 const TypeArguments& instantiator_type_arguments, |
| 861 intptr_t offset) const; | 818 intptr_t offset) const; |
| 862 virtual RawType* Canonicalize() const; | 819 virtual RawAbstractType* Canonicalize() const; |
| 863 | 820 |
| 864 static intptr_t InstanceSize() { | 821 static intptr_t InstanceSize() { |
| 865 return RoundedAllocationSize(sizeof(RawParameterizedType)); | 822 return RoundedAllocationSize(sizeof(RawType)); |
| 866 } | 823 } |
| 867 | 824 |
| 868 static RawParameterizedType* New(const Object& clazz, | 825 // The type of the literal 'null'. |
| 826 static RawType* NullType(); | |
| 827 | |
| 828 // The 'Dynamic' type. | |
| 829 static RawType* DynamicType(); | |
| 830 | |
| 831 // The 'void' type. | |
| 832 static RawType* VoidType(); | |
| 833 | |
| 834 // The 'Object' type. | |
| 835 static RawType* ObjectType(); | |
| 836 | |
| 837 // The 'bool' interface type. | |
| 838 static RawType* BoolInterface(); | |
| 839 | |
| 840 // The 'int' interface type. | |
| 841 static RawType* IntInterface(); | |
| 842 | |
| 843 // The 'double' interface type. | |
| 844 static RawType* DoubleInterface(); | |
| 845 | |
| 846 // The 'num' interface type. | |
| 847 static RawType* NumberInterface(); | |
| 848 | |
| 849 // The 'String' interface type. | |
| 850 static RawType* StringInterface(); | |
| 851 | |
| 852 // The 'Function' interface type. | |
| 853 static RawType* FunctionInterface(); | |
| 854 | |
| 855 // The 'List' interface type. | |
| 856 static RawType* ListInterface(); | |
| 857 | |
| 858 // The least specific valid raw type of the given class. | |
| 859 // For example, type A<Dynamic> would be returned for class A<T>, and type | |
| 860 // B<Dynamic, A<Dynamic>> would be returned for B<U, V extends A>. | |
| 861 static RawType* NewRawType(const Class& type_class); | |
| 862 | |
| 863 // The finalized type of the given non-parameterized class. | |
| 864 static RawType* NewNonParameterizedType(const Class& type_class); | |
| 865 | |
| 866 static RawType* NewParameterizedType( | |
| 867 const Object& type_class, const TypeArguments& arguments); | |
| 868 | |
| 869 static RawType* New(const Object& clazz, | |
| 869 const TypeArguments& arguments); | 870 const TypeArguments& arguments); |
| 870 | 871 |
| 871 private: | 872 private: |
| 872 void set_type_state(int8_t state) const; | 873 void set_type_state(int8_t state) const; |
| 873 | 874 |
| 874 static RawParameterizedType* New(); | 875 static RawType* New(); |
| 875 | 876 |
| 876 HEAP_OBJECT_IMPLEMENTATION(ParameterizedType, Type); | 877 HEAP_OBJECT_IMPLEMENTATION(Type, AbstractType); |
| 877 friend class Class; | 878 friend class Class; |
| 878 }; | 879 }; |
| 879 | 880 |
| 880 | 881 |
| 881 // A TypeParameter, in the context of a parameterized class, references a type | 882 // A TypeParameter, in the context of a parameterized class, references a type |
| 882 // parameter of a class by its index (and by its name for debugging purposes). | 883 // parameter of a class by its index (and by its name for debugging purposes). |
| 883 // For example, the type parameter 'V' is specified as index 1 in the context of | 884 // For example, the type parameter 'V' is specified as index 1 in the context of |
| 884 // the class HashMap<K, V>. At compile time, the TypeParameter is not | 885 // the class HashMap<K, V>. At compile time, the TypeParameter is not |
| 885 // instantiated yet, i.e. it is only a place holder. | 886 // instantiated yet, i.e. it is only a place holder. |
| 886 class TypeParameter : public Type { | 887 class TypeParameter : public AbstractType { |
| 887 public: | 888 public: |
| 888 virtual bool IsFinalized() const { return true; } | 889 virtual bool IsFinalized() const { return true; } |
| 889 virtual bool IsBeingFinalized() const { return false; } | 890 virtual bool IsBeingFinalized() const { return false; } |
| 890 virtual bool IsResolved() const { return true; } | 891 virtual bool IsResolved() const { return true; } |
| 891 virtual bool HasResolvedTypeClass() const { return false; } | 892 virtual bool HasResolvedTypeClass() const { return false; } |
| 892 virtual RawString* Name() const { return raw_ptr()->name_; } | 893 virtual RawString* Name() const { return raw_ptr()->name_; } |
| 893 virtual intptr_t Index() const { return raw_ptr()->index_; } | 894 virtual intptr_t Index() const { return raw_ptr()->index_; } |
| 894 virtual bool IsInstantiated() const { return false; } | 895 virtual bool IsInstantiated() const { return false; } |
| 895 virtual bool Equals(const Type& other) const; | 896 virtual bool Equals(const AbstractType& other) const; |
| 896 virtual RawType* InstantiateFrom( | 897 virtual RawAbstractType* InstantiateFrom( |
| 897 const TypeArguments& instantiator_type_arguments, | 898 const TypeArguments& instantiator_type_arguments, |
| 898 intptr_t offset) const; | 899 intptr_t offset) const; |
| 899 virtual RawType* Canonicalize() const { return raw(); } | 900 virtual RawAbstractType* Canonicalize() const { return raw(); } |
| 900 | 901 |
| 901 static intptr_t InstanceSize() { | 902 static intptr_t InstanceSize() { |
| 902 return RoundedAllocationSize(sizeof(RawTypeParameter)); | 903 return RoundedAllocationSize(sizeof(RawTypeParameter)); |
| 903 } | 904 } |
| 904 | 905 |
| 905 static RawTypeParameter* New(intptr_t index, const String& name); | 906 static RawTypeParameter* New(intptr_t index, const String& name); |
| 906 | 907 |
| 907 private: | 908 private: |
| 908 void set_index(intptr_t value) const; | 909 void set_index(intptr_t value) const; |
| 909 void set_name(const String& value) const; | 910 void set_name(const String& value) const; |
| 910 static RawTypeParameter* New(); | 911 static RawTypeParameter* New(); |
| 911 | 912 |
| 912 HEAP_OBJECT_IMPLEMENTATION(TypeParameter, Type); | 913 HEAP_OBJECT_IMPLEMENTATION(TypeParameter, AbstractType); |
| 913 friend class Class; | 914 friend class Class; |
| 914 }; | 915 }; |
| 915 | 916 |
| 916 | 917 |
| 917 // An instance of InstantiatedType is never encountered at compile time, but | 918 // An instance of InstantiatedType is never encountered at compile time, but |
| 918 // only at run time, when type parameters can be matched to actual types. | 919 // only at run time, when type parameters can be matched to actual types. |
| 919 // An instance of InstantiatedType consists of an uninstantiated Type object | 920 // An instance of InstantiatedType consists of an uninstantiated AbstractType |
| 920 // and of a TypeArguments object. The type is uninstantiated, because it | 921 // object and of a TypeArguments object. The type is uninstantiated, because it |
| 921 // refers to at least one TypeParameter object, i.e. to a type that is not known | 922 // refers to at least one TypeParameter object, i.e. to a type that is not known |
| 922 // at compile time. | 923 // at compile time. |
| 923 // The type argument vector is the instantiator, because each type parameter | 924 // The type argument vector is the instantiator, because each type parameter |
| 924 // with index i in the uninstantiated type can be substituted (or | 925 // with index i in the uninstantiated type can be substituted (or |
| 925 // "instantiated") with the type at index i in the type argument vector. | 926 // "instantiated") with the type at index i in the type argument vector. |
| 926 class InstantiatedType : public Type { | 927 class InstantiatedType : public AbstractType { |
| 927 public: | 928 public: |
| 928 virtual bool IsFinalized() const { return true; } | 929 virtual bool IsFinalized() const { return true; } |
| 929 virtual bool IsBeingFinalized() const { return false; } | 930 virtual bool IsBeingFinalized() const { return false; } |
| 930 virtual bool IsResolved() const { return true; } | 931 virtual bool IsResolved() const { return true; } |
| 931 virtual bool HasResolvedTypeClass() const { return true; } | 932 virtual bool HasResolvedTypeClass() const { return true; } |
| 932 virtual RawClass* type_class() const; | 933 virtual RawClass* type_class() const; |
| 933 virtual RawTypeArguments* arguments() const; | 934 virtual RawTypeArguments* arguments() const; |
| 934 virtual bool IsInstantiated() const { return true; } | 935 virtual bool IsInstantiated() const { return true; } |
| 935 | 936 |
| 936 RawType* uninstantiated_type() const { | 937 RawAbstractType* uninstantiated_type() const { |
| 937 return raw_ptr()->uninstantiated_type_; | 938 return raw_ptr()->uninstantiated_type_; |
| 938 } | 939 } |
| 939 RawTypeArguments* instantiator_type_arguments() const { | 940 RawTypeArguments* instantiator_type_arguments() const { |
| 940 return raw_ptr()->instantiator_type_arguments_; | 941 return raw_ptr()->instantiator_type_arguments_; |
| 941 } | 942 } |
| 942 | 943 |
| 943 static intptr_t InstanceSize() { | 944 static intptr_t InstanceSize() { |
| 944 return RoundedAllocationSize(sizeof(RawInstantiatedType)); | 945 return RoundedAllocationSize(sizeof(RawInstantiatedType)); |
| 945 } | 946 } |
| 946 | 947 |
| 947 static RawInstantiatedType* New( | 948 static RawInstantiatedType* New( |
| 948 const Type& uninstantiated_type, | 949 const AbstractType& uninstantiated_type, |
| 949 const TypeArguments& instantiator_type_arguments); | 950 const TypeArguments& instantiator_type_arguments); |
| 950 | 951 |
| 951 private: | 952 private: |
| 952 void set_uninstantiated_type(const Type& value) const; | 953 void set_uninstantiated_type(const AbstractType& value) const; |
| 953 void set_instantiator_type_arguments(const TypeArguments& value) const; | 954 void set_instantiator_type_arguments(const TypeArguments& value) const; |
| 954 static RawInstantiatedType* New(); | 955 static RawInstantiatedType* New(); |
| 955 | 956 |
| 956 HEAP_OBJECT_IMPLEMENTATION(InstantiatedType, Type); | 957 HEAP_OBJECT_IMPLEMENTATION(InstantiatedType, AbstractType); |
| 957 friend class Class; | 958 friend class Class; |
| 958 }; | 959 }; |
| 959 | 960 |
| 960 | 961 |
| 961 // TypeArguments is an abstract superclass. | 962 // TypeArguments is an abstract superclass. |
| 962 // Subclasses of TypeArguments are TypeArray and InstantiatedTypes. | 963 // Subclasses of TypeArguments are TypeArray and InstantiatedTypes. |
| 963 class TypeArguments : public Object { | 964 class TypeArguments : public Object { |
| 964 public: | 965 public: |
| 965 static bool AreEqual(const TypeArguments& arguments, | 966 static bool AreEqual(const TypeArguments& arguments, |
| 966 const TypeArguments& other_arguments); | 967 const TypeArguments& other_arguments); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 982 bool IsMoreSpecificThan(const TypeArguments& other, intptr_t len) const; | 983 bool IsMoreSpecificThan(const TypeArguments& other, intptr_t len) const; |
| 983 | 984 |
| 984 static RawTypeArguments* NewTypeArray(intptr_t len); | 985 static RawTypeArguments* NewTypeArray(intptr_t len); |
| 985 | 986 |
| 986 static RawTypeArguments* NewInstantiatedTypeArguments( | 987 static RawTypeArguments* NewInstantiatedTypeArguments( |
| 987 const TypeArguments& uninstantiated_type_arguments, | 988 const TypeArguments& uninstantiated_type_arguments, |
| 988 const TypeArguments& instantiator_type_arguments); | 989 const TypeArguments& instantiator_type_arguments); |
| 989 | 990 |
| 990 // UNREACHABLEs as TypeArguments is an abstract class. | 991 // UNREACHABLEs as TypeArguments is an abstract class. |
| 991 virtual intptr_t Length() const; | 992 virtual intptr_t Length() const; |
| 992 virtual RawType* TypeAt(intptr_t index) const; | 993 virtual RawAbstractType* TypeAt(intptr_t index) const; |
| 993 virtual void SetTypeAt(intptr_t index, const Type& value) const; | 994 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; |
| 994 virtual bool IsResolved() const; | 995 virtual bool IsResolved() const; |
| 995 virtual bool IsInstantiated() const; | 996 virtual bool IsInstantiated() const; |
| 996 virtual bool IsUninstantiatedIdentity() const; | 997 virtual bool IsUninstantiatedIdentity() const; |
| 997 virtual bool Equals(const TypeArguments& other) const; | 998 virtual bool Equals(const TypeArguments& other) const; |
| 998 | 999 |
| 999 protected: | 1000 protected: |
| 1000 HEAP_OBJECT_IMPLEMENTATION(TypeArguments, Object); | 1001 HEAP_OBJECT_IMPLEMENTATION(TypeArguments, Object); |
| 1001 friend class Class; | 1002 friend class Class; |
| 1002 }; | 1003 }; |
| 1003 | 1004 |
| 1004 | 1005 |
| 1005 // A TypeArray is simply an array of Types. | 1006 // A TypeArray is simply an array of Types. |
| 1006 class TypeArray : public TypeArguments { | 1007 class TypeArray : public TypeArguments { |
| 1007 public: | 1008 public: |
| 1008 virtual intptr_t Length() const; | 1009 virtual intptr_t Length() const; |
| 1009 virtual RawType* TypeAt(intptr_t index) const; | 1010 virtual RawAbstractType* TypeAt(intptr_t index) const; |
| 1010 virtual void SetTypeAt(intptr_t index, const Type& value) const; | 1011 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; |
| 1011 virtual bool IsResolved() const; | 1012 virtual bool IsResolved() const; |
| 1012 virtual bool IsInstantiated() const; | 1013 virtual bool IsInstantiated() const; |
| 1013 virtual bool IsUninstantiatedIdentity() const; | 1014 virtual bool IsUninstantiatedIdentity() const; |
| 1014 virtual bool Equals(const TypeArguments& other) const; | 1015 virtual bool Equals(const TypeArguments& other) const; |
| 1015 | 1016 |
| 1016 virtual RawTypeArguments* InstantiateFrom( | 1017 virtual RawTypeArguments* InstantiateFrom( |
| 1017 const TypeArguments& instantiator_type_arguments, | 1018 const TypeArguments& instantiator_type_arguments, |
| 1018 intptr_t offset) const; | 1019 intptr_t offset) const; |
| 1019 | 1020 |
| 1020 static intptr_t length_offset() { return OFFSET_OF(RawTypeArray, length_); } | 1021 static intptr_t length_offset() { return OFFSET_OF(RawTypeArray, length_); } |
| 1021 | 1022 |
| 1022 static intptr_t InstanceSize() { | 1023 static intptr_t InstanceSize() { |
| 1023 ASSERT(sizeof(RawTypeArray) == OFFSET_OF(RawTypeArray, types_)); | 1024 ASSERT(sizeof(RawTypeArray) == OFFSET_OF(RawTypeArray, types_)); |
| 1024 return 0; | 1025 return 0; |
| 1025 } | 1026 } |
| 1026 | 1027 |
| 1027 static intptr_t InstanceSize(intptr_t len) { | 1028 static intptr_t InstanceSize(intptr_t len) { |
| 1028 // Ensure that the types_ is not adding to the object length. | 1029 // Ensure that the types_ is not adding to the object length. |
| 1029 ASSERT(sizeof(RawTypeArray) == 2 * kWordSize); | 1030 ASSERT(sizeof(RawTypeArray) == 2 * kWordSize); |
| 1030 return RoundedAllocationSize(sizeof(RawTypeArray) + (len * kWordSize)); | 1031 return RoundedAllocationSize(sizeof(RawTypeArray) + (len * kWordSize)); |
| 1031 } | 1032 } |
| 1032 | 1033 |
| 1033 static RawTypeArray* New(intptr_t len); | 1034 static RawTypeArray* New(intptr_t len); |
| 1034 | 1035 |
| 1035 private: | 1036 private: |
| 1036 // Make sure that the array size cannot wrap around. | 1037 // Make sure that the array size cannot wrap around. |
| 1037 static const intptr_t kMaxTypes = 512 * 1024 * 1024; | 1038 static const intptr_t kMaxTypes = 512 * 1024 * 1024; |
| 1038 RawType** TypeAddr(intptr_t index) const; | 1039 RawAbstractType** TypeAddr(intptr_t index) const; |
| 1039 void SetLength(intptr_t value); | 1040 void SetLength(intptr_t value); |
| 1040 | 1041 |
| 1041 HEAP_OBJECT_IMPLEMENTATION(TypeArray, TypeArguments); | 1042 HEAP_OBJECT_IMPLEMENTATION(TypeArray, TypeArguments); |
| 1042 friend class Class; | 1043 friend class Class; |
| 1043 }; | 1044 }; |
| 1044 | 1045 |
| 1045 | 1046 |
| 1046 // An instance of InstantiatedTypeArguments is never encountered at compile | 1047 // An instance of InstantiatedTypeArguments is never encountered at compile |
| 1047 // time, but only at run time, when type parameters can be matched to actual | 1048 // time, but only at run time, when type parameters can be matched to actual |
| 1048 // types. | 1049 // types. |
| 1049 // An instance of InstantiatedTypeArguments consists of a pair of TypeArguments | 1050 // An instance of InstantiatedTypeArguments consists of a pair of TypeArguments |
| 1050 // objects. The first type argument vector is uninstantiated, because it | 1051 // objects. The first type argument vector is uninstantiated, because it |
| 1051 // contains type expressions referring to at least one TypeParameter object, | 1052 // contains type expressions referring to at least one TypeParameter object, |
| 1052 // i.e. to a type that is not known at compile time. | 1053 // i.e. to a type that is not known at compile time. |
| 1053 // The second type argument vector is the instantiator, because each type | 1054 // The second type argument vector is the instantiator, because each type |
| 1054 // parameter with index i in the first vector can be substituted (or | 1055 // parameter with index i in the first vector can be substituted (or |
| 1055 // "instantiated") with the type at index i in the second type argument vector. | 1056 // "instantiated") with the type at index i in the second type argument vector. |
| 1056 class InstantiatedTypeArguments : public TypeArguments { | 1057 class InstantiatedTypeArguments : public TypeArguments { |
| 1057 public: | 1058 public: |
| 1058 virtual intptr_t Length() const; | 1059 virtual intptr_t Length() const; |
| 1059 virtual RawType* TypeAt(intptr_t index) const; | 1060 virtual RawAbstractType* TypeAt(intptr_t index) const; |
| 1060 virtual void SetTypeAt(intptr_t index, const Type& value) const; | 1061 virtual void SetTypeAt(intptr_t index, const AbstractType& value) const; |
| 1061 virtual bool IsResolved() const { return true; } | 1062 virtual bool IsResolved() const { return true; } |
| 1062 virtual bool IsInstantiated() const { return true; } | 1063 virtual bool IsInstantiated() const { return true; } |
| 1063 virtual bool IsUninstantiatedIdentity() const { return false; } | 1064 virtual bool IsUninstantiatedIdentity() const { return false; } |
| 1064 | 1065 |
| 1065 RawTypeArguments* uninstantiated_type_arguments() const { | 1066 RawTypeArguments* uninstantiated_type_arguments() const { |
| 1066 return raw_ptr()->uninstantiated_type_arguments_; | 1067 return raw_ptr()->uninstantiated_type_arguments_; |
| 1067 } | 1068 } |
| 1068 static intptr_t uninstantiated_type_arguments_offset() { | 1069 static intptr_t uninstantiated_type_arguments_offset() { |
| 1069 return OFFSET_OF(RawInstantiatedTypeArguments, | 1070 return OFFSET_OF(RawInstantiatedTypeArguments, |
| 1070 uninstantiated_type_arguments_); | 1071 uninstantiated_type_arguments_); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1115 return BuildSignature(true, instantiator, offset); | 1116 return BuildSignature(true, instantiator, offset); |
| 1116 } | 1117 } |
| 1117 | 1118 |
| 1118 // Returns true if the signature of this function is instantiated, i.e. if it | 1119 // Returns true if the signature of this function is instantiated, i.e. if it |
| 1119 // does not involve generic parameter types or generic result type. | 1120 // does not involve generic parameter types or generic result type. |
| 1120 bool HasInstantiatedSignature() const; | 1121 bool HasInstantiatedSignature() const; |
| 1121 | 1122 |
| 1122 RawClass* owner() const { return raw_ptr()->owner_; } | 1123 RawClass* owner() const { return raw_ptr()->owner_; } |
| 1123 void set_owner(const Class& value) const; | 1124 void set_owner(const Class& value) const; |
| 1124 | 1125 |
| 1125 RawType* result_type() const { return raw_ptr()->result_type_; } | 1126 RawAbstractType* result_type() const { return raw_ptr()->result_type_; } |
| 1126 void set_result_type(const Type& value) const; | 1127 void set_result_type(const AbstractType& value) const; |
| 1127 | 1128 |
| 1128 RawType* ParameterTypeAt(intptr_t index) const; | 1129 RawAbstractType* ParameterTypeAt(intptr_t index) const; |
| 1129 void SetParameterTypeAt(intptr_t index, const Type& value) const; | 1130 void SetParameterTypeAt(intptr_t index, const AbstractType& value) const; |
| 1130 void set_parameter_types(const Array& value) const; | 1131 void set_parameter_types(const Array& value) const; |
| 1131 | 1132 |
| 1132 // Parameter names are valid for all valid parameter indices, and are not | 1133 // Parameter names are valid for all valid parameter indices, and are not |
| 1133 // limited to named optional parameters. | 1134 // limited to named optional parameters. |
| 1134 RawString* ParameterNameAt(intptr_t index) const; | 1135 RawString* ParameterNameAt(intptr_t index) const; |
| 1135 void SetParameterNameAt(intptr_t index, const String& value) const; | 1136 void SetParameterNameAt(intptr_t index, const String& value) const; |
| 1136 void set_parameter_names(const Array& value) const; | 1137 void set_parameter_names(const Array& value) const; |
| 1137 | 1138 |
| 1138 RawCode* code() const { return raw_ptr()->code_; } | 1139 RawCode* code() const { return raw_ptr()->code_; } |
| 1139 // Sets function's code and code's function. | 1140 // Sets function's code and code's function. |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1356 inline void SetOffset(intptr_t value) const; | 1357 inline void SetOffset(intptr_t value) const; |
| 1357 | 1358 |
| 1358 RawInstance* value() const; | 1359 RawInstance* value() const; |
| 1359 void set_value(const Instance& value) const; | 1360 void set_value(const Instance& value) const; |
| 1360 | 1361 |
| 1361 RawClass* owner() const { return raw_ptr()->owner_; } | 1362 RawClass* owner() const { return raw_ptr()->owner_; } |
| 1362 void set_owner(const Class& value) const { | 1363 void set_owner(const Class& value) const { |
| 1363 StorePointer(&raw_ptr()->owner_, value.raw()); | 1364 StorePointer(&raw_ptr()->owner_, value.raw()); |
| 1364 } | 1365 } |
| 1365 | 1366 |
| 1366 RawType* type() const { return raw_ptr()->type_; } | 1367 RawAbstractType* type() const { return raw_ptr()->type_; } |
| 1367 void set_type(const Type& value) const; | 1368 void set_type(const AbstractType& value) const; |
| 1368 | 1369 |
| 1369 static intptr_t InstanceSize() { | 1370 static intptr_t InstanceSize() { |
| 1370 return RoundedAllocationSize(sizeof(RawField)); | 1371 return RoundedAllocationSize(sizeof(RawField)); |
| 1371 } | 1372 } |
| 1372 | 1373 |
| 1373 static RawField* New(const String& name, | 1374 static RawField* New(const String& name, |
| 1374 bool is_static, | 1375 bool is_static, |
| 1375 bool is_final, | 1376 bool is_final, |
| 1376 intptr_t token_index); | 1377 intptr_t token_index); |
| 1377 | 1378 |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2024 | 2025 |
| 2025 intptr_t TokenIndexAt(intptr_t scope_index) const; | 2026 intptr_t TokenIndexAt(intptr_t scope_index) const; |
| 2026 void SetTokenIndexAt(intptr_t scope_index, intptr_t token_index) const; | 2027 void SetTokenIndexAt(intptr_t scope_index, intptr_t token_index) const; |
| 2027 | 2028 |
| 2028 RawString* NameAt(intptr_t scope_index) const; | 2029 RawString* NameAt(intptr_t scope_index) const; |
| 2029 void SetNameAt(intptr_t scope_index, const String& name) const; | 2030 void SetNameAt(intptr_t scope_index, const String& name) const; |
| 2030 | 2031 |
| 2031 bool IsFinalAt(intptr_t scope_index) const; | 2032 bool IsFinalAt(intptr_t scope_index) const; |
| 2032 void SetIsFinalAt(intptr_t scope_index, bool is_const) const; | 2033 void SetIsFinalAt(intptr_t scope_index, bool is_const) const; |
| 2033 | 2034 |
| 2034 RawType* TypeAt(intptr_t scope_index) const; | 2035 RawAbstractType* TypeAt(intptr_t scope_index) const; |
| 2035 void SetTypeAt(intptr_t scope_index, const Type& type) const; | 2036 void SetTypeAt(intptr_t scope_index, const AbstractType& type) const; |
| 2036 | 2037 |
| 2037 intptr_t ContextIndexAt(intptr_t scope_index) const; | 2038 intptr_t ContextIndexAt(intptr_t scope_index) const; |
| 2038 void SetContextIndexAt(intptr_t scope_index, intptr_t context_index) const; | 2039 void SetContextIndexAt(intptr_t scope_index, intptr_t context_index) const; |
| 2039 | 2040 |
| 2040 intptr_t ContextLevelAt(intptr_t scope_index) const; | 2041 intptr_t ContextLevelAt(intptr_t scope_index) const; |
| 2041 void SetContextLevelAt(intptr_t scope_index, intptr_t context_level) const; | 2042 void SetContextLevelAt(intptr_t scope_index, intptr_t context_level) const; |
| 2042 | 2043 |
| 2043 static intptr_t InstanceSize() { | 2044 static intptr_t InstanceSize() { |
| 2044 ASSERT(sizeof(RawContextScope) == OFFSET_OF(RawContextScope, data_)); | 2045 ASSERT(sizeof(RawContextScope) == OFFSET_OF(RawContextScope, data_)); |
| 2045 return 0; | 2046 return 0; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2132 virtual RawInstance* Canonicalize() const; | 2133 virtual RawInstance* Canonicalize() const; |
| 2133 | 2134 |
| 2134 RawObject* GetField(const Field& field) const { | 2135 RawObject* GetField(const Field& field) const { |
| 2135 return *FieldAddr(field); | 2136 return *FieldAddr(field); |
| 2136 } | 2137 } |
| 2137 | 2138 |
| 2138 void SetField(const Field& field, const Object& value) const { | 2139 void SetField(const Field& field, const Object& value) const { |
| 2139 *FieldAddr(field) = value.raw(); | 2140 *FieldAddr(field) = value.raw(); |
| 2140 } | 2141 } |
| 2141 | 2142 |
| 2142 RawParameterizedType* GetType() const; | 2143 RawType* GetType() const; |
| 2143 | 2144 |
| 2144 virtual RawTypeArguments* GetTypeArguments() const; | 2145 virtual RawTypeArguments* GetTypeArguments() const; |
| 2145 virtual void SetTypeArguments(const TypeArguments& value) const; | 2146 virtual void SetTypeArguments(const TypeArguments& value) const; |
| 2146 | 2147 |
| 2147 // Check if this instance is an instance of the given type. | 2148 // Check if this instance is an instance of the given type. |
| 2148 bool IsInstanceOf(const Type& type, | 2149 bool IsInstanceOf(const AbstractType& type, |
| 2149 const TypeArguments& type_instantiator) const { | 2150 const TypeArguments& type_instantiator) const { |
| 2150 return TestType(kIsSubtypeOf, type, type_instantiator); | 2151 return TestType(kIsSubtypeOf, type, type_instantiator); |
| 2151 } | 2152 } |
| 2152 | 2153 |
| 2153 // Check if this instance is assignable to the given type. | 2154 // Check if this instance is assignable to the given type. |
| 2154 bool IsAssignableTo(const Type& type, | 2155 bool IsAssignableTo(const AbstractType& type, |
| 2155 const TypeArguments& type_instantiator) const { | 2156 const TypeArguments& type_instantiator) const { |
| 2156 return TestType(kIsAssignableTo, type, type_instantiator); | 2157 return TestType(kIsAssignableTo, type, type_instantiator); |
| 2157 } | 2158 } |
| 2158 | 2159 |
| 2159 bool IsValidNativeIndex(int index) const; | 2160 bool IsValidNativeIndex(int index) const; |
| 2160 | 2161 |
| 2161 intptr_t GetNativeField(int index) const { | 2162 intptr_t GetNativeField(int index) const { |
| 2162 return *NativeFieldAddr(index); | 2163 return *NativeFieldAddr(index); |
| 2163 } | 2164 } |
| 2164 | 2165 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 2187 + sizeof(RawObject)); | 2188 + sizeof(RawObject)); |
| 2188 } | 2189 } |
| 2189 void SetFieldAtOffset(intptr_t offset, const Object& value) const { | 2190 void SetFieldAtOffset(intptr_t offset, const Object& value) const { |
| 2190 *FieldAddrAtOffset(offset) = value.raw(); | 2191 *FieldAddrAtOffset(offset) = value.raw(); |
| 2191 } | 2192 } |
| 2192 bool IsValidFieldOffset(int offset) const; | 2193 bool IsValidFieldOffset(int offset) const; |
| 2193 | 2194 |
| 2194 // Check the subtype or assignability relationship between the type of this | 2195 // Check the subtype or assignability relationship between the type of this |
| 2195 // instance and the given type. | 2196 // instance and the given type. |
| 2196 bool TestType(TypeTestKind test, | 2197 bool TestType(TypeTestKind test, |
| 2197 const Type& type, | 2198 const AbstractType& type, |
| 2198 const TypeArguments& type_instantiator) const; | 2199 const TypeArguments& type_instantiator) const; |
| 2199 | 2200 |
| 2200 // TODO(iposva): Determine if this gets in the way of Smi. | 2201 // TODO(iposva): Determine if this gets in the way of Smi. |
| 2201 HEAP_OBJECT_IMPLEMENTATION(Instance, Object); | 2202 HEAP_OBJECT_IMPLEMENTATION(Instance, Object); |
| 2202 friend class Class; | 2203 friend class Class; |
| 2203 }; | 2204 }; |
| 2204 | 2205 |
| 2205 | 2206 |
| 2206 class Number : public Instance { | 2207 class Number : public Instance { |
| 2207 public: | 2208 public: |
| (...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3097 const GrowableArray<uword>& stack_frame_pcs) const; | 3098 const GrowableArray<uword>& stack_frame_pcs) const; |
| 3098 | 3099 |
| 3099 HEAP_OBJECT_IMPLEMENTATION(Stacktrace, Instance); | 3100 HEAP_OBJECT_IMPLEMENTATION(Stacktrace, Instance); |
| 3100 friend class Class; | 3101 friend class Class; |
| 3101 }; | 3102 }; |
| 3102 | 3103 |
| 3103 | 3104 |
| 3104 // Internal JavaScript regular expression object. | 3105 // Internal JavaScript regular expression object. |
| 3105 class JSRegExp : public Instance { | 3106 class JSRegExp : public Instance { |
| 3106 public: | 3107 public: |
| 3107 // Meaning of Type: | 3108 // Meaning of RegExType: |
| 3108 // kUninitialized: the type of th regexp has not been initialized yet. | 3109 // kUninitialized: the type of th regexp has not been initialized yet. |
| 3109 // kSimple: A simple pattern to match against, using string indexOf operation. | 3110 // kSimple: A simple pattern to match against, using string indexOf operation. |
| 3110 // kComplex: A complex pattern to match. | 3111 // kComplex: A complex pattern to match. |
| 3111 enum Type { | 3112 enum RegExType { |
| 3112 kUnitialized = 0, | 3113 kUnitialized = 0, |
| 3113 kSimple, | 3114 kSimple, |
| 3114 kComplex, | 3115 kComplex, |
| 3115 }; | 3116 }; |
| 3116 | 3117 |
| 3117 // Flags are passed to a regex object as follows: | 3118 // Flags are passed to a regex object as follows: |
| 3118 // 'i': ignore case, 'g': do global matches, 'm': pattern is multi line. | 3119 // 'i': ignore case, 'g': do global matches, 'm': pattern is multi line. |
| 3119 enum Flags { | 3120 enum Flags { |
| 3120 kNone = 0, | 3121 kNone = 0, |
| 3121 kGlobal = 1, | 3122 kGlobal = 1, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3155 return 0; | 3156 return 0; |
| 3156 } | 3157 } |
| 3157 | 3158 |
| 3158 static intptr_t InstanceSize(intptr_t len) { | 3159 static intptr_t InstanceSize(intptr_t len) { |
| 3159 return RoundedAllocationSize(sizeof(RawJSRegExp) + len); | 3160 return RoundedAllocationSize(sizeof(RawJSRegExp) + len); |
| 3160 } | 3161 } |
| 3161 | 3162 |
| 3162 static RawJSRegExp* New(intptr_t length, Heap::Space space = Heap::kNew); | 3163 static RawJSRegExp* New(intptr_t length, Heap::Space space = Heap::kNew); |
| 3163 | 3164 |
| 3164 private: | 3165 private: |
| 3165 void set_type(Type type) const { raw_ptr()->type_ = type; } | 3166 void set_type(RegExType type) const { raw_ptr()->type_ = type; } |
| 3166 void set_flags(intptr_t value) const { raw_ptr()->flags_ = value; } | 3167 void set_flags(intptr_t value) const { raw_ptr()->flags_ = value; } |
| 3167 | 3168 |
| 3168 void SetLength(intptr_t value) { | 3169 void SetLength(intptr_t value) { |
| 3169 // This is only safe because we create a new Smi, which does not cause | 3170 // This is only safe because we create a new Smi, which does not cause |
| 3170 // heap allocation. | 3171 // heap allocation. |
| 3171 raw_ptr()->data_length_ = Smi::New(value); | 3172 raw_ptr()->data_length_ = Smi::New(value); |
| 3172 } | 3173 } |
| 3173 | 3174 |
| 3174 HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance); | 3175 HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance); |
| 3175 friend class Class; | 3176 friend class Class; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3234 } | 3235 } |
| 3235 | 3236 |
| 3236 | 3237 |
| 3237 void Context::SetAt(intptr_t index, const Instance& value) const { | 3238 void Context::SetAt(intptr_t index, const Instance& value) const { |
| 3238 StorePointer(InstanceAddr(index), value.raw()); | 3239 StorePointer(InstanceAddr(index), value.raw()); |
| 3239 } | 3240 } |
| 3240 | 3241 |
| 3241 } // namespace dart | 3242 } // namespace dart |
| 3242 | 3243 |
| 3243 #endif // VM_OBJECT_H_ | 3244 #endif // VM_OBJECT_H_ |
| OLD | NEW |