OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
7 | 7 |
8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 473 |
474 intptr_t id() const { return raw_ptr()->id_; } | 474 intptr_t id() const { return raw_ptr()->id_; } |
475 void set_id(intptr_t value) const { | 475 void set_id(intptr_t value) const { |
476 raw_ptr()->id_ = value; | 476 raw_ptr()->id_ = value; |
477 } | 477 } |
478 | 478 |
479 RawString* Name() const; | 479 RawString* Name() const; |
480 | 480 |
481 RawScript* script() const { return raw_ptr()->script_; } | 481 RawScript* script() const { return raw_ptr()->script_; } |
482 | 482 |
483 intptr_t token_index() const { return raw_ptr()->token_index_; } | 483 intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
484 | 484 |
485 // This class represents the signature class of a closure function if | 485 // This class represents the signature class of a closure function if |
486 // signature_function() is not null. | 486 // signature_function() is not null. |
487 // The associated function may be a closure function (with code) or a | 487 // The associated function may be a closure function (with code) or a |
488 // signature function (without code) solely describing the result type and | 488 // signature function (without code) solely describing the result type and |
489 // parameter types of the signature. | 489 // parameter types of the signature. |
490 RawFunction* signature_function() const { | 490 RawFunction* signature_function() const { |
491 return raw_ptr()->signature_function_; | 491 return raw_ptr()->signature_function_; |
492 } | 492 } |
493 static intptr_t signature_function_offset() { | 493 static intptr_t signature_function_offset() { |
(...skipping 23 matching lines...) Expand all Loading... |
517 // Type parameter bounds (implicitly Dynamic if not explicitly specified) as | 517 // Type parameter bounds (implicitly Dynamic if not explicitly specified) as |
518 // an array of AbstractType. | 518 // an array of AbstractType. |
519 RawTypeArguments* type_parameter_bounds() const { | 519 RawTypeArguments* type_parameter_bounds() const { |
520 return raw_ptr()->type_parameter_bounds_; | 520 return raw_ptr()->type_parameter_bounds_; |
521 } | 521 } |
522 void set_type_parameter_bounds(const TypeArguments& value) const; | 522 void set_type_parameter_bounds(const TypeArguments& value) const; |
523 | 523 |
524 // Return a TypeParameter if the type_name is a type parameter of this class. | 524 // Return a TypeParameter if the type_name is a type parameter of this class. |
525 // Return null otherwise. | 525 // Return null otherwise. |
526 RawTypeParameter* LookupTypeParameter(const String& type_name, | 526 RawTypeParameter* LookupTypeParameter(const String& type_name, |
527 intptr_t token_index) const; | 527 intptr_t token_pos) const; |
528 | 528 |
529 // The type argument vector is flattened and includes the type arguments of | 529 // The type argument vector is flattened and includes the type arguments of |
530 // the super class. | 530 // the super class. |
531 bool HasTypeArguments() const; | 531 bool HasTypeArguments() const; |
532 intptr_t NumTypeArguments() const; | 532 intptr_t NumTypeArguments() const; |
533 | 533 |
534 // If this class is parameterized, each instance has a type_arguments field. | 534 // If this class is parameterized, each instance has a type_arguments field. |
535 static const intptr_t kNoTypeArguments = -1; | 535 static const intptr_t kNoTypeArguments = -1; |
536 intptr_t type_arguments_instance_field_offset() const { | 536 intptr_t type_arguments_instance_field_offset() const { |
537 ASSERT(is_finalized() || is_prefinalized()); | 537 ASSERT(is_finalized() || is_prefinalized()); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 RawArray* fields() const { return raw_ptr()->fields_; } | 634 RawArray* fields() const { return raw_ptr()->fields_; } |
635 void SetFields(const Array& value) const; | 635 void SetFields(const Array& value) const; |
636 | 636 |
637 // Returns true if non-static fields are defined. | 637 // Returns true if non-static fields are defined. |
638 bool HasInstanceFields() const; | 638 bool HasInstanceFields() const; |
639 | 639 |
640 RawArray* functions() const { return raw_ptr()->functions_; } | 640 RawArray* functions() const { return raw_ptr()->functions_; } |
641 void SetFunctions(const Array& value) const; | 641 void SetFunctions(const Array& value) const; |
642 | 642 |
643 void AddClosureFunction(const Function& function) const; | 643 void AddClosureFunction(const Function& function) const; |
644 RawFunction* LookupClosureFunction(intptr_t token_index) const; | 644 RawFunction* LookupClosureFunction(intptr_t token_pos) const; |
645 | 645 |
646 RawFunction* LookupDynamicFunction(const String& name) const; | 646 RawFunction* LookupDynamicFunction(const String& name) const; |
647 RawFunction* LookupStaticFunction(const String& name) const; | 647 RawFunction* LookupStaticFunction(const String& name) const; |
648 RawFunction* LookupConstructor(const String& name) const; | 648 RawFunction* LookupConstructor(const String& name) const; |
649 RawFunction* LookupFactory(const String& name) const; | 649 RawFunction* LookupFactory(const String& name) const; |
650 RawFunction* LookupFunction(const String& name) const; | 650 RawFunction* LookupFunction(const String& name) const; |
651 RawFunction* LookupGetterFunction(const String& name) const; | 651 RawFunction* LookupGetterFunction(const String& name) const; |
652 RawFunction* LookupSetterFunction(const String& name) const; | 652 RawFunction* LookupSetterFunction(const String& name) const; |
653 RawFunction* LookupFunctionAtToken(intptr_t token_index) const; | 653 RawFunction* LookupFunctionAtToken(intptr_t token_pos) const; |
654 RawField* LookupInstanceField(const String& name) const; | 654 RawField* LookupInstanceField(const String& name) const; |
655 RawField* LookupStaticField(const String& name) const; | 655 RawField* LookupStaticField(const String& name) const; |
656 RawField* LookupField(const String& name) const; | 656 RawField* LookupField(const String& name) const; |
657 | 657 |
658 RawLibraryPrefix* LookupLibraryPrefix(const String& name) const; | 658 RawLibraryPrefix* LookupLibraryPrefix(const String& name) const; |
659 | 659 |
660 void InsertCanonicalConstant(intptr_t index, const Instance& constant) const; | 660 void InsertCanonicalConstant(intptr_t index, const Instance& constant) const; |
661 | 661 |
662 static intptr_t InstanceSize() { | 662 static intptr_t InstanceSize() { |
663 return RoundedAllocationSize(sizeof(RawClass)); | 663 return RoundedAllocationSize(sizeof(RawClass)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 RawArray* constants() const; | 705 RawArray* constants() const; |
706 | 706 |
707 void Finalize() const; | 707 void Finalize() const; |
708 | 708 |
709 // Allocate a class used for VM internal objects. | 709 // Allocate a class used for VM internal objects. |
710 template <class FakeObject> static RawClass* New(); | 710 template <class FakeObject> static RawClass* New(); |
711 | 711 |
712 // Allocate instance classes and interfaces. | 712 // Allocate instance classes and interfaces. |
713 static RawClass* New(const String& name, | 713 static RawClass* New(const String& name, |
714 const Script& script, | 714 const Script& script, |
715 intptr_t token_index); | 715 intptr_t token_pos); |
716 static RawClass* NewInterface(const String& name, | 716 static RawClass* NewInterface(const String& name, |
717 const Script& script, | 717 const Script& script, |
718 intptr_t token_index); | 718 intptr_t token_pos); |
719 static RawClass* NewNativeWrapper(Library* library, | 719 static RawClass* NewNativeWrapper(Library* library, |
720 const String& name, | 720 const String& name, |
721 int num_fields); | 721 int num_fields); |
722 | 722 |
723 // Allocate a class representing a function signature described by | 723 // Allocate a class representing a function signature described by |
724 // signature_function, which must be a closure function or a signature | 724 // signature_function, which must be a closure function or a signature |
725 // function. | 725 // function. |
726 // The class may be type parameterized unless the signature_function is in a | 726 // The class may be type parameterized unless the signature_function is in a |
727 // static scope. In that case, the type parameters are copied from the owner | 727 // static scope. In that case, the type parameters are copied from the owner |
728 // class of signature_function. | 728 // class of signature_function. |
729 static RawClass* NewSignatureClass(const String& name, | 729 static RawClass* NewSignatureClass(const String& name, |
730 const Function& signature_function, | 730 const Function& signature_function, |
731 const Script& script); | 731 const Script& script); |
732 | 732 |
733 // Return a class object corresponding to the specified kind. If | 733 // Return a class object corresponding to the specified kind. If |
734 // a canonicalized version of it exists then that object is returned | 734 // a canonicalized version of it exists then that object is returned |
735 // otherwise a new object is allocated and returned. | 735 // otherwise a new object is allocated and returned. |
736 static RawClass* GetClass(ObjectKind kind); | 736 static RawClass* GetClass(ObjectKind kind); |
737 | 737 |
738 private: | 738 private: |
739 void set_name(const String& value) const; | 739 void set_name(const String& value) const; |
740 void set_script(const Script& value) const; | 740 void set_script(const Script& value) const; |
741 void set_token_index(intptr_t value) const; | 741 void set_token_pos(intptr_t value) const; |
742 void set_signature_function(const Function& value) const; | 742 void set_signature_function(const Function& value) const; |
743 void set_signature_type(const AbstractType& value) const; | 743 void set_signature_type(const AbstractType& value) const; |
744 void set_class_state(int8_t state) const; | 744 void set_class_state(int8_t state) const; |
745 | 745 |
746 void set_constants(const Array& value) const; | 746 void set_constants(const Array& value) const; |
747 | 747 |
748 void set_canonical_types(const Array& value) const; | 748 void set_canonical_types(const Array& value) const; |
749 RawArray* canonical_types() const; | 749 RawArray* canonical_types() const; |
750 | 750 |
751 void CalculateFieldOffsets() const; | 751 void CalculateFieldOffsets() const; |
752 | 752 |
753 // Assigns empty array to all raw class array fields. | 753 // Assigns empty array to all raw class array fields. |
754 void InitEmptyFields(); | 754 void InitEmptyFields(); |
755 | 755 |
756 RawFunction* LookupAccessorFunction(const char* prefix, | 756 RawFunction* LookupAccessorFunction(const char* prefix, |
757 intptr_t prefix_length, | 757 intptr_t prefix_length, |
758 const String& name) const; | 758 const String& name) const; |
759 | 759 |
760 // Allocate an instance class which has a VM implementation. | 760 // Allocate an instance class which has a VM implementation. |
761 template <class FakeInstance> static RawClass* New(intptr_t id); | 761 template <class FakeInstance> static RawClass* New(intptr_t id); |
762 template <class FakeInstance> static RawClass* New(const String& name, | 762 template <class FakeInstance> static RawClass* New(const String& name, |
763 const Script& script, | 763 const Script& script, |
764 intptr_t token_index); | 764 intptr_t token_pos); |
765 | 765 |
766 // Check the subtype or 'more specific' relationship. | 766 // Check the subtype or 'more specific' relationship. |
767 bool TypeTest(TypeTestKind test_kind, | 767 bool TypeTest(TypeTestKind test_kind, |
768 const AbstractTypeArguments& type_arguments, | 768 const AbstractTypeArguments& type_arguments, |
769 const Class& other, | 769 const Class& other, |
770 const AbstractTypeArguments& other_type_arguments, | 770 const AbstractTypeArguments& other_type_arguments, |
771 Error* malformed_error) const; | 771 Error* malformed_error) const; |
772 | 772 |
773 HEAP_OBJECT_IMPLEMENTATION(Class, Object); | 773 HEAP_OBJECT_IMPLEMENTATION(Class, Object); |
774 friend class Object; | 774 friend class Object; |
775 friend class Instance; | 775 friend class Instance; |
776 friend class AbstractType; | 776 friend class AbstractType; |
777 friend class Type; | 777 friend class Type; |
778 }; | 778 }; |
779 | 779 |
780 | 780 |
781 // Unresolved class is used for storing unresolved names which will be resolved | 781 // Unresolved class is used for storing unresolved names which will be resolved |
782 // to a class after all classes have been loaded and finalized. | 782 // to a class after all classes have been loaded and finalized. |
783 class UnresolvedClass : public Object { | 783 class UnresolvedClass : public Object { |
784 public: | 784 public: |
785 RawLibraryPrefix* library_prefix() const { | 785 RawLibraryPrefix* library_prefix() const { |
786 return raw_ptr()->library_prefix_; | 786 return raw_ptr()->library_prefix_; |
787 } | 787 } |
788 RawString* ident() const { return raw_ptr()->ident_; } | 788 RawString* ident() const { return raw_ptr()->ident_; } |
789 intptr_t token_index() const { return raw_ptr()->token_index_; } | 789 intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
790 | 790 |
791 RawClass* factory_signature_class() const { | 791 RawClass* factory_signature_class() const { |
792 return raw_ptr()->factory_signature_class_; | 792 return raw_ptr()->factory_signature_class_; |
793 } | 793 } |
794 void set_factory_signature_class(const Class& value) const; | 794 void set_factory_signature_class(const Class& value) const; |
795 | 795 |
796 RawString* Name() const; | 796 RawString* Name() const; |
797 | 797 |
798 static intptr_t InstanceSize() { | 798 static intptr_t InstanceSize() { |
799 return RoundedAllocationSize(sizeof(RawUnresolvedClass)); | 799 return RoundedAllocationSize(sizeof(RawUnresolvedClass)); |
800 } | 800 } |
801 static RawUnresolvedClass* New(const LibraryPrefix& library_prefix, | 801 static RawUnresolvedClass* New(const LibraryPrefix& library_prefix, |
802 const String& ident, | 802 const String& ident, |
803 intptr_t token_index); | 803 intptr_t token_pos); |
804 | 804 |
805 private: | 805 private: |
806 void set_library_prefix(const LibraryPrefix& library_prefix) const; | 806 void set_library_prefix(const LibraryPrefix& library_prefix) const; |
807 void set_ident(const String& ident) const; | 807 void set_ident(const String& ident) const; |
808 void set_token_index(intptr_t token_index) const; | 808 void set_token_pos(intptr_t token_pos) const; |
809 | 809 |
810 static RawUnresolvedClass* New(); | 810 static RawUnresolvedClass* New(); |
811 | 811 |
812 HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass, Object); | 812 HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass, Object); |
813 friend class Class; | 813 friend class Class; |
814 }; | 814 }; |
815 | 815 |
816 | 816 |
817 // AbstractType is an abstract superclass. | 817 // AbstractType is an abstract superclass. |
818 // Subclasses of AbstractType are Type and TypeParameter. | 818 // Subclasses of AbstractType are Type and TypeParameter. |
819 class AbstractType : public Object { | 819 class AbstractType : public Object { |
820 public: | 820 public: |
821 virtual bool IsFinalized() const; | 821 virtual bool IsFinalized() const; |
822 virtual bool IsBeingFinalized() const; | 822 virtual bool IsBeingFinalized() const; |
823 virtual bool IsMalformed() const; | 823 virtual bool IsMalformed() const; |
824 virtual RawError* malformed_error() const; | 824 virtual RawError* malformed_error() const; |
825 virtual void set_malformed_error(const Error& value) const; | 825 virtual void set_malformed_error(const Error& value) const; |
826 virtual bool IsResolved() const; | 826 virtual bool IsResolved() const; |
827 virtual bool HasResolvedTypeClass() const; | 827 virtual bool HasResolvedTypeClass() const; |
828 virtual RawClass* type_class() const; | 828 virtual RawClass* type_class() const; |
829 virtual RawUnresolvedClass* unresolved_class() const; | 829 virtual RawUnresolvedClass* unresolved_class() const; |
830 virtual RawAbstractTypeArguments* arguments() const; | 830 virtual RawAbstractTypeArguments* arguments() const; |
831 virtual intptr_t token_index() const; | 831 virtual intptr_t token_pos() const; |
832 virtual bool IsInstantiated() const; | 832 virtual bool IsInstantiated() const; |
833 virtual bool Equals(const AbstractType& other) const; | 833 virtual bool Equals(const AbstractType& other) const; |
834 virtual bool IsIdentical(const AbstractType& other) const; | 834 virtual bool IsIdentical(const AbstractType& other) const; |
835 | 835 |
836 // Instantiate this type using the given type argument vector. | 836 // Instantiate this type using the given type argument vector. |
837 // Return a new type, or return 'this' if it is already instantiated. | 837 // Return a new type, or return 'this' if it is already instantiated. |
838 virtual RawAbstractType* InstantiateFrom( | 838 virtual RawAbstractType* InstantiateFrom( |
839 const AbstractTypeArguments& instantiator_type_arguments) const; | 839 const AbstractTypeArguments& instantiator_type_arguments) const; |
840 | 840 |
841 // Return the canonical version of this type. | 841 // Return the canonical version of this type. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 virtual RawError* malformed_error() const; | 952 virtual RawError* malformed_error() const; |
953 virtual void set_malformed_error(const Error& value) const; | 953 virtual void set_malformed_error(const Error& value) const; |
954 virtual bool IsResolved() const; // Class and all arguments classes resolved. | 954 virtual bool IsResolved() const; // Class and all arguments classes resolved. |
955 virtual bool HasResolvedTypeClass() const; // Own type class resolved. | 955 virtual bool HasResolvedTypeClass() const; // Own type class resolved. |
956 virtual RawClass* type_class() const; | 956 virtual RawClass* type_class() const; |
957 void set_type_class(const Object& value) const; | 957 void set_type_class(const Object& value) const; |
958 virtual RawUnresolvedClass* unresolved_class() const; | 958 virtual RawUnresolvedClass* unresolved_class() const; |
959 RawString* TypeClassName() const; | 959 RawString* TypeClassName() const; |
960 virtual RawAbstractTypeArguments* arguments() const; | 960 virtual RawAbstractTypeArguments* arguments() const; |
961 void set_arguments(const AbstractTypeArguments& value) const; | 961 void set_arguments(const AbstractTypeArguments& value) const; |
962 virtual intptr_t token_index() const { return raw_ptr()->token_index_; } | 962 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
963 virtual bool IsInstantiated() const; | 963 virtual bool IsInstantiated() const; |
964 virtual bool Equals(const AbstractType& other) const; | 964 virtual bool Equals(const AbstractType& other) const; |
965 virtual bool IsIdentical(const AbstractType& other) const; | 965 virtual bool IsIdentical(const AbstractType& other) const; |
966 virtual RawAbstractType* InstantiateFrom( | 966 virtual RawAbstractType* InstantiateFrom( |
967 const AbstractTypeArguments& instantiator_type_arguments) const; | 967 const AbstractTypeArguments& instantiator_type_arguments) const; |
968 virtual RawAbstractType* Canonicalize() const; | 968 virtual RawAbstractType* Canonicalize() const; |
969 | 969 |
970 static intptr_t InstanceSize() { | 970 static intptr_t InstanceSize() { |
971 return RoundedAllocationSize(sizeof(RawType)); | 971 return RoundedAllocationSize(sizeof(RawType)); |
972 } | 972 } |
(...skipping 29 matching lines...) Expand all Loading... |
1002 static RawType* FunctionInterface(); | 1002 static RawType* FunctionInterface(); |
1003 | 1003 |
1004 // The 'List' interface type. | 1004 // The 'List' interface type. |
1005 static RawType* ListInterface(); | 1005 static RawType* ListInterface(); |
1006 | 1006 |
1007 // The finalized type of the given non-parameterized class. | 1007 // The finalized type of the given non-parameterized class. |
1008 static RawType* NewNonParameterizedType(const Class& type_class); | 1008 static RawType* NewNonParameterizedType(const Class& type_class); |
1009 | 1009 |
1010 static RawType* New(const Object& clazz, | 1010 static RawType* New(const Object& clazz, |
1011 const AbstractTypeArguments& arguments, | 1011 const AbstractTypeArguments& arguments, |
1012 intptr_t token_index); | 1012 intptr_t token_pos); |
1013 | 1013 |
1014 private: | 1014 private: |
1015 void set_token_index(intptr_t token_index) const; | 1015 void set_token_pos(intptr_t token_pos) const; |
1016 void set_type_state(int8_t state) const; | 1016 void set_type_state(int8_t state) const; |
1017 | 1017 |
1018 static RawType* New(); | 1018 static RawType* New(); |
1019 | 1019 |
1020 HEAP_OBJECT_IMPLEMENTATION(Type, AbstractType); | 1020 HEAP_OBJECT_IMPLEMENTATION(Type, AbstractType); |
1021 friend class Class; | 1021 friend class Class; |
1022 }; | 1022 }; |
1023 | 1023 |
1024 | 1024 |
1025 // A TypeParameter represents a type parameter of a parameterized class. | 1025 // A TypeParameter represents a type parameter of a parameterized class. |
(...skipping 13 matching lines...) Expand all Loading... |
1039 virtual bool IsBeingFinalized() const { return false; } | 1039 virtual bool IsBeingFinalized() const { return false; } |
1040 virtual bool IsMalformed() const { return false; } | 1040 virtual bool IsMalformed() const { return false; } |
1041 virtual bool IsResolved() const { return true; } | 1041 virtual bool IsResolved() const { return true; } |
1042 virtual bool HasResolvedTypeClass() const { return false; } | 1042 virtual bool HasResolvedTypeClass() const { return false; } |
1043 RawClass* parameterized_class() const { | 1043 RawClass* parameterized_class() const { |
1044 return raw_ptr()->parameterized_class_; | 1044 return raw_ptr()->parameterized_class_; |
1045 } | 1045 } |
1046 virtual RawString* Name() const { return raw_ptr()->name_; } | 1046 virtual RawString* Name() const { return raw_ptr()->name_; } |
1047 virtual intptr_t Index() const { return raw_ptr()->index_; } | 1047 virtual intptr_t Index() const { return raw_ptr()->index_; } |
1048 void set_index(intptr_t value) const; | 1048 void set_index(intptr_t value) const; |
1049 virtual intptr_t token_index() const { return raw_ptr()->token_index_; } | 1049 virtual intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
1050 virtual bool IsInstantiated() const { return false; } | 1050 virtual bool IsInstantiated() const { return false; } |
1051 virtual bool Equals(const AbstractType& other) const; | 1051 virtual bool Equals(const AbstractType& other) const; |
1052 virtual bool IsIdentical(const AbstractType& other) const; | 1052 virtual bool IsIdentical(const AbstractType& other) const; |
1053 virtual RawAbstractType* InstantiateFrom( | 1053 virtual RawAbstractType* InstantiateFrom( |
1054 const AbstractTypeArguments& instantiator_type_arguments) const; | 1054 const AbstractTypeArguments& instantiator_type_arguments) const; |
1055 virtual RawAbstractType* Canonicalize() const { return raw(); } | 1055 virtual RawAbstractType* Canonicalize() const { return raw(); } |
1056 | 1056 |
1057 static intptr_t InstanceSize() { | 1057 static intptr_t InstanceSize() { |
1058 return RoundedAllocationSize(sizeof(RawTypeParameter)); | 1058 return RoundedAllocationSize(sizeof(RawTypeParameter)); |
1059 } | 1059 } |
1060 | 1060 |
1061 static RawTypeParameter* New(const Class& parameterized_class, | 1061 static RawTypeParameter* New(const Class& parameterized_class, |
1062 intptr_t index, | 1062 intptr_t index, |
1063 const String& name, | 1063 const String& name, |
1064 intptr_t token_index); | 1064 intptr_t token_pos); |
1065 | 1065 |
1066 private: | 1066 private: |
1067 void set_parameterized_class(const Class& value) const; | 1067 void set_parameterized_class(const Class& value) const; |
1068 void set_name(const String& value) const; | 1068 void set_name(const String& value) const; |
1069 void set_token_index(intptr_t token_index) const; | 1069 void set_token_pos(intptr_t token_pos) const; |
1070 void set_type_state(int8_t state) const; | 1070 void set_type_state(int8_t state) const; |
1071 static RawTypeParameter* New(); | 1071 static RawTypeParameter* New(); |
1072 | 1072 |
1073 HEAP_OBJECT_IMPLEMENTATION(TypeParameter, AbstractType); | 1073 HEAP_OBJECT_IMPLEMENTATION(TypeParameter, AbstractType); |
1074 friend class Class; | 1074 friend class Class; |
1075 }; | 1075 }; |
1076 | 1076 |
1077 | 1077 |
1078 // AbstractTypeArguments is an abstract superclass. | 1078 // AbstractTypeArguments is an abstract superclass. |
1079 // Subclasses of AbstractTypeArguments are TypeArguments and | 1079 // Subclasses of AbstractTypeArguments are TypeArguments and |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 case RawFunction::kClosureFunction: | 1392 case RawFunction::kClosureFunction: |
1393 case RawFunction::kConstructor: | 1393 case RawFunction::kConstructor: |
1394 return false; | 1394 return false; |
1395 default: | 1395 default: |
1396 UNREACHABLE(); | 1396 UNREACHABLE(); |
1397 return false; | 1397 return false; |
1398 } | 1398 } |
1399 } | 1399 } |
1400 bool IsInFactoryScope() const; | 1400 bool IsInFactoryScope() const; |
1401 | 1401 |
1402 intptr_t token_index() const { return raw_ptr()->token_index_; } | 1402 intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
1403 | 1403 |
1404 intptr_t end_token_index() const { return raw_ptr()->end_token_index_; } | 1404 intptr_t end_token_pos() const { return raw_ptr()->end_token_pos_; } |
1405 void set_end_token_index(intptr_t value) const { | 1405 void set_end_token_pos(intptr_t value) const { |
1406 raw_ptr()->end_token_index_ = value; | 1406 raw_ptr()->end_token_pos_ = value; |
1407 } | 1407 } |
1408 | 1408 |
1409 static intptr_t num_fixed_parameters_offset() { | 1409 static intptr_t num_fixed_parameters_offset() { |
1410 return OFFSET_OF(RawFunction, num_fixed_parameters_); | 1410 return OFFSET_OF(RawFunction, num_fixed_parameters_); |
1411 } | 1411 } |
1412 intptr_t num_fixed_parameters() const { | 1412 intptr_t num_fixed_parameters() const { |
1413 return raw_ptr()->num_fixed_parameters_; | 1413 return raw_ptr()->num_fixed_parameters_; |
1414 } | 1414 } |
1415 void set_num_fixed_parameters(intptr_t value) const; | 1415 void set_num_fixed_parameters(intptr_t value) const; |
1416 | 1416 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1527 | 1527 |
1528 | 1528 |
1529 static intptr_t InstanceSize() { | 1529 static intptr_t InstanceSize() { |
1530 return RoundedAllocationSize(sizeof(RawFunction)); | 1530 return RoundedAllocationSize(sizeof(RawFunction)); |
1531 } | 1531 } |
1532 | 1532 |
1533 static RawFunction* New(const String& name, | 1533 static RawFunction* New(const String& name, |
1534 RawFunction::Kind kind, | 1534 RawFunction::Kind kind, |
1535 bool is_static, | 1535 bool is_static, |
1536 bool is_const, | 1536 bool is_const, |
1537 intptr_t token_index); | 1537 intptr_t token_pos); |
1538 | 1538 |
1539 // Allocates a new Function object representing a closure function, as well as | 1539 // Allocates a new Function object representing a closure function, as well as |
1540 // a new associated Class object representing the signature class of the | 1540 // a new associated Class object representing the signature class of the |
1541 // function. | 1541 // function. |
1542 // The function and the class share the same given name. | 1542 // The function and the class share the same given name. |
1543 static RawFunction* NewClosureFunction(const String& name, | 1543 static RawFunction* NewClosureFunction(const String& name, |
1544 const Function& parent, | 1544 const Function& parent, |
1545 intptr_t token_index); | 1545 intptr_t token_pos); |
1546 | 1546 |
1547 static const int kCtorPhaseInit = 1 << 0; | 1547 static const int kCtorPhaseInit = 1 << 0; |
1548 static const int kCtorPhaseBody = 1 << 1; | 1548 static const int kCtorPhaseBody = 1 << 1; |
1549 static const int kCtorPhaseAll = (kCtorPhaseInit | kCtorPhaseBody); | 1549 static const int kCtorPhaseAll = (kCtorPhaseInit | kCtorPhaseBody); |
1550 | 1550 |
1551 private: | 1551 private: |
1552 void set_name(const String& value) const; | 1552 void set_name(const String& value) const; |
1553 void set_kind(RawFunction::Kind value) const; | 1553 void set_kind(RawFunction::Kind value) const; |
1554 void set_is_static(bool is_static) const; | 1554 void set_is_static(bool is_static) const; |
1555 void set_is_const(bool is_const) const; | 1555 void set_is_const(bool is_const) const; |
1556 void set_parent_function(const Function& value) const; | 1556 void set_parent_function(const Function& value) const; |
1557 void set_token_index(intptr_t value) const; | 1557 void set_token_pos(intptr_t value) const; |
1558 void set_implicit_closure_function(const Function& value) const; | 1558 void set_implicit_closure_function(const Function& value) const; |
1559 static RawFunction* New(); | 1559 static RawFunction* New(); |
1560 | 1560 |
1561 RawString* BuildSignature(bool instantiate, | 1561 RawString* BuildSignature(bool instantiate, |
1562 const AbstractTypeArguments& instantiator) const; | 1562 const AbstractTypeArguments& instantiator) const; |
1563 | 1563 |
1564 // Check the subtype or 'more specific' relationship. | 1564 // Check the subtype or 'more specific' relationship. |
1565 bool TypeTest(TypeTestKind test_kind, | 1565 bool TypeTest(TypeTestKind test_kind, |
1566 const AbstractTypeArguments& type_arguments, | 1566 const AbstractTypeArguments& type_arguments, |
1567 const Function& other, | 1567 const Function& other, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1606 RawAbstractType* type() const { return raw_ptr()->type_; } | 1606 RawAbstractType* type() const { return raw_ptr()->type_; } |
1607 void set_type(const AbstractType& value) const; | 1607 void set_type(const AbstractType& value) const; |
1608 | 1608 |
1609 static intptr_t InstanceSize() { | 1609 static intptr_t InstanceSize() { |
1610 return RoundedAllocationSize(sizeof(RawField)); | 1610 return RoundedAllocationSize(sizeof(RawField)); |
1611 } | 1611 } |
1612 | 1612 |
1613 static RawField* New(const String& name, | 1613 static RawField* New(const String& name, |
1614 bool is_static, | 1614 bool is_static, |
1615 bool is_final, | 1615 bool is_final, |
1616 intptr_t token_index); | 1616 intptr_t token_pos); |
1617 | 1617 |
1618 static intptr_t value_offset() { return OFFSET_OF(RawField, value_); } | 1618 static intptr_t value_offset() { return OFFSET_OF(RawField, value_); } |
1619 | 1619 |
1620 intptr_t token_index() const { return raw_ptr()->token_index_; } | 1620 intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
1621 | 1621 |
1622 bool has_initializer() const { return raw_ptr()->has_initializer_; } | 1622 bool has_initializer() const { return raw_ptr()->has_initializer_; } |
1623 void set_has_initializer(bool has_initializer) const { | 1623 void set_has_initializer(bool has_initializer) const { |
1624 raw_ptr()->has_initializer_ = has_initializer; | 1624 raw_ptr()->has_initializer_ = has_initializer; |
1625 } | 1625 } |
1626 | 1626 |
1627 // Constructs getter and setter names for fields and vice versa. | 1627 // Constructs getter and setter names for fields and vice versa. |
1628 static RawString* GetterName(const String& field_name); | 1628 static RawString* GetterName(const String& field_name); |
1629 static RawString* GetterSymbol(const String& field_name); | 1629 static RawString* GetterSymbol(const String& field_name); |
1630 static RawString* SetterName(const String& field_name); | 1630 static RawString* SetterName(const String& field_name); |
1631 static RawString* SetterSymbol(const String& field_name); | 1631 static RawString* SetterSymbol(const String& field_name); |
1632 static RawString* NameFromGetter(const String& getter_name); | 1632 static RawString* NameFromGetter(const String& getter_name); |
1633 static RawString* NameFromSetter(const String& setter_name); | 1633 static RawString* NameFromSetter(const String& setter_name); |
1634 static bool IsGetterName(const String& function_name); | 1634 static bool IsGetterName(const String& function_name); |
1635 static bool IsSetterName(const String& function_name); | 1635 static bool IsSetterName(const String& function_name); |
1636 | 1636 |
1637 private: | 1637 private: |
1638 void set_name(const String& value) const; | 1638 void set_name(const String& value) const; |
1639 void set_is_static(bool is_static) const { | 1639 void set_is_static(bool is_static) const { |
1640 raw_ptr()->is_static_ = is_static; | 1640 raw_ptr()->is_static_ = is_static; |
1641 } | 1641 } |
1642 void set_is_final(bool is_final) const { | 1642 void set_is_final(bool is_final) const { |
1643 raw_ptr()->is_final_ = is_final; | 1643 raw_ptr()->is_final_ = is_final; |
1644 } | 1644 } |
1645 void set_token_index(intptr_t token_index) const { | 1645 void set_token_pos(intptr_t token_pos) const { |
1646 raw_ptr()->token_index_ = token_index; | 1646 raw_ptr()->token_pos_ = token_pos; |
1647 } | 1647 } |
1648 static RawField* New(); | 1648 static RawField* New(); |
1649 | 1649 |
1650 HEAP_OBJECT_IMPLEMENTATION(Field, Object); | 1650 HEAP_OBJECT_IMPLEMENTATION(Field, Object); |
1651 friend class Class; | 1651 friend class Class; |
1652 }; | 1652 }; |
1653 | 1653 |
1654 | 1654 |
1655 class LiteralToken : public Object { | 1655 class LiteralToken : public Object { |
1656 public: | 1656 public: |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1729 | 1729 |
1730 void Tokenize(const String& private_key) const; | 1730 void Tokenize(const String& private_key) const; |
1731 | 1731 |
1732 RawString* GetLine(intptr_t line_number) const; | 1732 RawString* GetLine(intptr_t line_number) const; |
1733 | 1733 |
1734 RawString* GetSnippet(intptr_t from_line, | 1734 RawString* GetSnippet(intptr_t from_line, |
1735 intptr_t from_column, | 1735 intptr_t from_column, |
1736 intptr_t to_line, | 1736 intptr_t to_line, |
1737 intptr_t to_column) const; | 1737 intptr_t to_column) const; |
1738 | 1738 |
1739 void GetTokenLocation(intptr_t token_index, | 1739 void GetTokenLocation(intptr_t token_pos, |
1740 intptr_t* line, intptr_t* column) const; | 1740 intptr_t* line, intptr_t* column) const; |
1741 | 1741 |
1742 intptr_t TokenIndexAtLine(intptr_t line_number) const; | 1742 intptr_t TokenIndexAtLine(intptr_t line_number) const; |
1743 | 1743 |
1744 static intptr_t InstanceSize() { | 1744 static intptr_t InstanceSize() { |
1745 return RoundedAllocationSize(sizeof(RawScript)); | 1745 return RoundedAllocationSize(sizeof(RawScript)); |
1746 } | 1746 } |
1747 | 1747 |
1748 static RawScript* New(const String& url, | 1748 static RawScript* New(const String& url, |
1749 const String& source, | 1749 const String& source, |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1848 // Library imports. | 1848 // Library imports. |
1849 void AddImport(const Library& library) const; | 1849 void AddImport(const Library& library) const; |
1850 RawLibrary* LookupImport(const String& url) const; | 1850 RawLibrary* LookupImport(const String& url) const; |
1851 intptr_t num_imports() const { return raw_ptr()->num_imports_; } | 1851 intptr_t num_imports() const { return raw_ptr()->num_imports_; } |
1852 RawLibrary* ImportAt(intptr_t index) const; | 1852 RawLibrary* ImportAt(intptr_t index) const; |
1853 RawLibraryPrefix* ImportPrefixAt(intptr_t index) const; | 1853 RawLibraryPrefix* ImportPrefixAt(intptr_t index) const; |
1854 | 1854 |
1855 RawFunction* LookupFunctionInSource(const String& script_url, | 1855 RawFunction* LookupFunctionInSource(const String& script_url, |
1856 intptr_t line_number) const; | 1856 intptr_t line_number) const; |
1857 RawFunction* LookupFunctionInScript(const Script& script, | 1857 RawFunction* LookupFunctionInScript(const Script& script, |
1858 intptr_t token_index) const; | 1858 intptr_t token_pos) const; |
1859 | 1859 |
1860 // Resolving native methods for script loaded in the library. | 1860 // Resolving native methods for script loaded in the library. |
1861 Dart_NativeEntryResolver native_entry_resolver() const { | 1861 Dart_NativeEntryResolver native_entry_resolver() const { |
1862 return raw_ptr()->native_entry_resolver_; | 1862 return raw_ptr()->native_entry_resolver_; |
1863 } | 1863 } |
1864 void set_native_entry_resolver(Dart_NativeEntryResolver value) const { | 1864 void set_native_entry_resolver(Dart_NativeEntryResolver value) const { |
1865 raw_ptr()->native_entry_resolver_ = value; | 1865 raw_ptr()->native_entry_resolver_ = value; |
1866 } | 1866 } |
1867 | 1867 |
1868 RawString* PrivateName(const String& name) const; | 1868 RawString* PrivateName(const String& name) const; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2074 PcDescriptors::Kind DescriptorKind(intptr_t index) const; | 2074 PcDescriptors::Kind DescriptorKind(intptr_t index) const; |
2075 const char* KindAsStr(intptr_t index) const; | 2075 const char* KindAsStr(intptr_t index) const; |
2076 intptr_t NodeId(intptr_t index) const; | 2076 intptr_t NodeId(intptr_t index) const; |
2077 intptr_t TokenIndex(intptr_t index) const; | 2077 intptr_t TokenIndex(intptr_t index) const; |
2078 intptr_t TryIndex(intptr_t index) const; | 2078 intptr_t TryIndex(intptr_t index) const; |
2079 | 2079 |
2080 void AddDescriptor(intptr_t index, | 2080 void AddDescriptor(intptr_t index, |
2081 uword pc, | 2081 uword pc, |
2082 PcDescriptors::Kind kind, | 2082 PcDescriptors::Kind kind, |
2083 intptr_t node_id, | 2083 intptr_t node_id, |
2084 intptr_t token_index, | 2084 intptr_t token_pos, |
2085 intptr_t try_index) const { | 2085 intptr_t try_index) const { |
2086 SetPC(index, pc); | 2086 SetPC(index, pc); |
2087 SetKind(index, kind); | 2087 SetKind(index, kind); |
2088 SetNodeId(index, node_id); | 2088 SetNodeId(index, node_id); |
2089 SetTokenIndex(index, token_index); | 2089 SetTokenIndex(index, token_pos); |
2090 SetTryIndex(index, try_index); | 2090 SetTryIndex(index, try_index); |
2091 } | 2091 } |
2092 | 2092 |
2093 static intptr_t InstanceSize() { | 2093 static intptr_t InstanceSize() { |
2094 ASSERT(sizeof(RawPcDescriptors) == OFFSET_OF(RawPcDescriptors, data_)); | 2094 ASSERT(sizeof(RawPcDescriptors) == OFFSET_OF(RawPcDescriptors, data_)); |
2095 return 0; | 2095 return 0; |
2096 } | 2096 } |
2097 static intptr_t InstanceSize(intptr_t len) { | 2097 static intptr_t InstanceSize(intptr_t len) { |
2098 return RoundedAllocationSize( | 2098 return RoundedAllocationSize( |
2099 sizeof(RawPcDescriptors) + (len * kNumberOfEntries * kWordSize)); | 2099 sizeof(RawPcDescriptors) + (len * kNumberOfEntries * kWordSize)); |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2486 // functions enclosing the local function. Each captured variable is represented | 2486 // functions enclosing the local function. Each captured variable is represented |
2487 // by its token position in the source, its name, its type, its allocation index | 2487 // by its token position in the source, its name, its type, its allocation index |
2488 // in the context, and its context level. The function nesting level and loop | 2488 // in the context, and its context level. The function nesting level and loop |
2489 // nesting level are not preserved, since they are only used until the context | 2489 // nesting level are not preserved, since they are only used until the context |
2490 // level is assigned. | 2490 // level is assigned. |
2491 class ContextScope : public Object { | 2491 class ContextScope : public Object { |
2492 public: | 2492 public: |
2493 intptr_t num_variables() const { return raw_ptr()->num_variables_; } | 2493 intptr_t num_variables() const { return raw_ptr()->num_variables_; } |
2494 | 2494 |
2495 intptr_t TokenIndexAt(intptr_t scope_index) const; | 2495 intptr_t TokenIndexAt(intptr_t scope_index) const; |
2496 void SetTokenIndexAt(intptr_t scope_index, intptr_t token_index) const; | 2496 void SetTokenIndexAt(intptr_t scope_index, intptr_t token_pos) const; |
2497 | 2497 |
2498 RawString* NameAt(intptr_t scope_index) const; | 2498 RawString* NameAt(intptr_t scope_index) const; |
2499 void SetNameAt(intptr_t scope_index, const String& name) const; | 2499 void SetNameAt(intptr_t scope_index, const String& name) const; |
2500 | 2500 |
2501 bool IsFinalAt(intptr_t scope_index) const; | 2501 bool IsFinalAt(intptr_t scope_index) const; |
2502 void SetIsFinalAt(intptr_t scope_index, bool is_const) const; | 2502 void SetIsFinalAt(intptr_t scope_index, bool is_const) const; |
2503 | 2503 |
2504 RawAbstractType* TypeAt(intptr_t scope_index) const; | 2504 RawAbstractType* TypeAt(intptr_t scope_index) const; |
2505 void SetTypeAt(intptr_t scope_index, const AbstractType& type) const; | 2505 void SetTypeAt(intptr_t scope_index, const AbstractType& type) const; |
2506 | 2506 |
(...skipping 2566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5073 } | 5073 } |
5074 | 5074 |
5075 | 5075 |
5076 intptr_t Stackmap::SizeInBits() const { | 5076 intptr_t Stackmap::SizeInBits() const { |
5077 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); | 5077 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); |
5078 } | 5078 } |
5079 | 5079 |
5080 } // namespace dart | 5080 } // namespace dart |
5081 | 5081 |
5082 #endif // VM_OBJECT_H_ | 5082 #endif // VM_OBJECT_H_ |
OLD | NEW |